@qonto/embed-sdk 0.67.0 → 0.69.0

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 (106) hide show
  1. package/dist/cards/client/cards.client.d.ts.map +1 -1
  2. package/dist/common/common.types.d.ts +0 -1
  3. package/dist/common/common.types.d.ts.map +1 -1
  4. package/dist/common/common.utils.d.ts +3 -4
  5. package/dist/common/common.utils.d.ts.map +1 -1
  6. package/dist/common/constants.d.ts +1 -0
  7. package/dist/common/constants.d.ts.map +1 -1
  8. package/dist/common/initialize/initialize.validate.d.ts.map +1 -1
  9. package/dist/common/operation-settings/operation-settings.d.ts +0 -2
  10. package/dist/common/operation-settings/operation-settings.d.ts.map +1 -1
  11. package/dist/index.umd.js +5 -5
  12. package/dist/mocks/handlers.d.ts +2 -1
  13. package/dist/mocks/handlers.d.ts.map +1 -1
  14. package/dist/organizations/client/organizations.client.d.ts +33 -1
  15. package/dist/organizations/client/organizations.client.d.ts.map +1 -1
  16. package/dist/organizations/index.d.ts +3 -0
  17. package/dist/organizations/index.d.ts.map +1 -1
  18. package/dist/organizations/index.server.d.ts +3 -0
  19. package/dist/organizations/index.server.d.ts.map +1 -1
  20. package/dist/organizations/server/organizations.server.d.ts +24 -1
  21. package/dist/organizations/server/organizations.server.d.ts.map +1 -1
  22. package/dist/organizations/shared/organizations.api.d.ts +11 -1
  23. package/dist/organizations/shared/organizations.api.d.ts.map +1 -1
  24. package/dist/organizations/shared/organizations.serializer.d.ts +2 -1
  25. package/dist/organizations/shared/organizations.serializer.d.ts.map +1 -1
  26. package/dist/organizations/shared/organizations.types.d.ts +54 -0
  27. package/dist/organizations/shared/organizations.types.d.ts.map +1 -1
  28. package/dist/sepa-transfers/bulk-transfers/client/bulk-transfers.client.d.ts.map +1 -1
  29. package/dist/sepa-transfers/bulk-transfers/index.d.ts +1 -1
  30. package/dist/sepa-transfers/shared/sepa-transfers.api.d.ts +3 -3
  31. package/dist/server/cards/client/cards.client.d.ts.map +1 -1
  32. package/dist/server/common/common.types.d.ts +0 -1
  33. package/dist/server/common/common.types.d.ts.map +1 -1
  34. package/dist/server/common/common.utils.d.ts +3 -4
  35. package/dist/server/common/common.utils.d.ts.map +1 -1
  36. package/dist/server/common/constants.d.ts +1 -0
  37. package/dist/server/common/constants.d.ts.map +1 -1
  38. package/dist/server/common/initialize/initialize.validate.d.ts.map +1 -1
  39. package/dist/server/common/operation-settings/operation-settings.d.ts +0 -2
  40. package/dist/server/common/operation-settings/operation-settings.d.ts.map +1 -1
  41. package/dist/server/index.server.umd.js +1 -1
  42. package/dist/server/mocks/handlers.d.ts +2 -1
  43. package/dist/server/mocks/handlers.d.ts.map +1 -1
  44. package/dist/server/organizations/client/organizations.client.d.ts +33 -1
  45. package/dist/server/organizations/client/organizations.client.d.ts.map +1 -1
  46. package/dist/server/organizations/index.d.ts +3 -0
  47. package/dist/server/organizations/index.d.ts.map +1 -1
  48. package/dist/server/organizations/index.server.d.ts +3 -0
  49. package/dist/server/organizations/index.server.d.ts.map +1 -1
  50. package/dist/server/organizations/server/organizations.server.d.ts +24 -1
  51. package/dist/server/organizations/server/organizations.server.d.ts.map +1 -1
  52. package/dist/server/organizations/shared/organizations.api.d.ts +11 -1
  53. package/dist/server/organizations/shared/organizations.api.d.ts.map +1 -1
  54. package/dist/server/organizations/shared/organizations.serializer.d.ts +2 -1
  55. package/dist/server/organizations/shared/organizations.serializer.d.ts.map +1 -1
  56. package/dist/server/organizations/shared/organizations.types.d.ts +54 -0
  57. package/dist/server/organizations/shared/organizations.types.d.ts.map +1 -1
  58. package/dist/server/sepa-transfers/bulk-transfers/client/bulk-transfers.client.d.ts.map +1 -1
  59. package/dist/server/sepa-transfers/bulk-transfers/index.d.ts +1 -1
  60. package/dist/server/sepa-transfers/shared/sepa-transfers.api.d.ts +3 -3
  61. package/dist/server/src/common/common.utils.js +1 -1
  62. package/dist/server/src/common/operation-settings/operation-settings.js +1 -1
  63. package/dist/server/src/errors/AuthenticationError.js +1 -1
  64. package/dist/server/src/organizations/index.server.js +1 -1
  65. package/dist/server/src/organizations/server/organizations.server.js +1 -1
  66. package/dist/server/src/organizations/shared/organizations.api.js +1 -1
  67. package/dist/server/src/organizations/shared/organizations.serializer.js +1 -1
  68. package/dist/server/src/validation/operation-settings-validation.js +1 -1
  69. package/dist/server/ui/ui-elements/sca-passkey/qonto-sca-passkey-waiting.d.ts.map +1 -1
  70. package/dist/server/ui/ui-elements/sepa-transfer-creation/create-sepa-transfer-creation-element.d.ts +1 -1
  71. package/dist/server/ui/ui-elements/sepa-transfer-creation/sepa-transfer-creation.d.ts.map +1 -1
  72. package/dist/server/ui/ui-elements/transaction-list/create-transaction-list-element.d.ts +1 -1
  73. package/dist/server/ui/ui-elements/transaction-list/transaction-list.d.ts.map +1 -1
  74. package/dist/server/ui/ui-elements/transfer-list/create-transfer-list-element.d.ts +1 -1
  75. package/dist/server/ui/ui-elements.types.d.ts +2 -3
  76. package/dist/server/ui/ui-elements.types.d.ts.map +1 -1
  77. package/dist/server/validation/operation-settings-validation.d.ts +8 -45
  78. package/dist/server/validation/operation-settings-validation.d.ts.map +1 -1
  79. package/dist/src/cards/client/cards.client.js +1 -1
  80. package/dist/src/common/common.utils.js +1 -1
  81. package/dist/src/common/constants.js +1 -1
  82. package/dist/src/common/initialize/initialize.validate.js +1 -1
  83. package/dist/src/common/operation-settings/operation-settings.js +1 -1
  84. package/dist/src/errors/AuthenticationError.js +1 -1
  85. package/dist/src/organizations/client/organizations.client.js +1 -1
  86. package/dist/src/organizations/index.js +1 -1
  87. package/dist/src/organizations/shared/organizations.api.js +1 -1
  88. package/dist/src/organizations/shared/organizations.serializer.js +1 -1
  89. package/dist/src/sepa-transfers/client/sepa-transfers.client.js +1 -1
  90. package/dist/src/sepa-transfers/shared/sepa-transfers.utils.js +1 -1
  91. package/dist/src/ui/ui-elements/sca-passkey/qonto-sca-passkey-waiting.js +1 -1
  92. package/dist/src/ui/ui-elements/sepa-transfer-creation/sepa-transfer-creation.js +7 -7
  93. package/dist/src/ui/ui-elements/transaction-list/transaction-list.js +4 -4
  94. package/dist/src/validation/operation-settings-validation.js +1 -1
  95. package/dist/ui/ui-elements/sca-passkey/qonto-sca-passkey-waiting.d.ts.map +1 -1
  96. package/dist/ui/ui-elements/sepa-transfer-creation/create-sepa-transfer-creation-element.d.ts +1 -1
  97. package/dist/ui/ui-elements/sepa-transfer-creation/sepa-transfer-creation.d.ts.map +1 -1
  98. package/dist/ui/ui-elements/transaction-list/create-transaction-list-element.d.ts +1 -1
  99. package/dist/ui/ui-elements/transaction-list/transaction-list.d.ts.map +1 -1
  100. package/dist/ui/ui-elements/transfer-list/create-transfer-list-element.d.ts +1 -1
  101. package/dist/ui/ui-elements.types.d.ts +2 -3
  102. package/dist/ui/ui-elements.types.d.ts.map +1 -1
  103. package/dist/validation/operation-settings-validation.d.ts +8 -45
  104. package/dist/validation/operation-settings-validation.d.ts.map +1 -1
  105. package/package.json +1 -1
  106. package/dist/server/src/errors/EmbedOperationError.js +0 -1
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbedServer={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}class n{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return n.instance||(n.instance=new n),n.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const r=n.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class o extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid authentication method. Provide either a proxyRequestFunction (recommended) or accessToken, either as parameters or by calling the initialize function first."}}function s(){if(!r.hasAccessToken())throw new o;return r.getAccessToken()}function a(){return!("undefined"!=typeof window&&"undefined"!=typeof document)}const c={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},l={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},d=3e4,f="REJECT",p={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"},g="https://embed.qonto.com",h="https://embed-js{branch}.staging.qonto.co",v="https://embed.dev.qonto.co",m={[c.PRODUCTION]:{EMBED_BASE_URL:g,EMBED_URL:`${g}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[c.STAGING]:{EMBED_BASE_URL:h,EMBED_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[c.LOCAL]:{EMBED_BASE_URL:v,EMBED_URL:`${v}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class y{constructor(){let e,t;this.environment=c.PRODUCTION,this.branch=u.SANDBOX,"undefined"!=typeof process&&process.env&&(e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH),this.environment=Object.values(c).includes(e)?e:c.PRODUCTION,this.branch=Object.values(u).includes(t)?t:u.SANDBOX}static getInstance(){return y.instance||(y.instance=new y),y.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===c.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=c.PRODUCTION,this.branch=u.MASTER}getEnvironmentUrls(){if(this.environment===c.PRODUCTION)return m.production;{const e=m[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const b=y.getInstance();class w{constructor(){this.currentLocale="en"}static getInstance(){return w.instance||(w.instance=new w),w.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const T=w.getInstance();class k{constructor(){this.mfaPreference=l.PASSKEY,this.debugMode=!1}static getInstance(){return k.instance||(k.instance=new k),k.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyRequestFunction&&(this.proxyRequestFunction=e.proxyRequestFunction),e.proxyEndpointDescriptor&&(this.proxyEndpointDescriptor=e.proxyEndpointDescriptor)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyRequestFunction(){return this.proxyRequestFunction}getProxyEndpointDescriptor(){return this.proxyEndpointDescriptor}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=l.PASSKEY,this.debugMode=!1,this.proxyRequestFunction=void 0,this.proxyEndpointDescriptor=void 0}getSettings(){return{uiParentElementId:this.uiParentElementId,mfaPreference:this.mfaPreference,debugMode:this.debugMode,proxyRequestFunction:this.proxyRequestFunction}}}const E=k.getInstance();class S extends i{constructor({message:e,data:t,code:n}){super(),this.code=500;const r=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${r}`,this.data=t||{},this.code=n||this.code}}function _({accessToken:e,stagingToken:t,idempotencyKey:n,mfaPreference:i,scaSessionToken:o}){const s=new Headers;s.append("Authorization",`Bearer ${e}`);const a=t||r.getStagingToken();a&&s.append("X-Qonto-Staging-Token",a),n&&s.append("X-Qonto-Idempotency-Key",n);const c=i||E.getMFAPreference();return c&&s.append("X-Qonto-2fa-Preference",c),o&&s.append("X-Qonto-SCA-Session-Token",o),s.append("Content-Type","application/json"),s.append("Accept-Language",T.getLocale()),s}async function I({path:e,options:t}){const n=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,r=await fetch(n,{...t,headers:_(t.headers),body:t.body?JSON.stringify(t.body):void 0});if(204===r.status)return;const i=await r.json();if(!r.ok)throw i.errors?new S({code:r.status,message:i.errors.map((e=>`${e.code}: ${e.detail}`))}):new S({code:r.status,message:`${i.code}: ${i.detail}`,data:i});return i}function P(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return r=n,a()?Buffer.from(r).toString("base64"):btoa(r);var r}function A(e){return JSON.parse((t=e,a()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function O({accessToken:e,stagingToken:t,action:n,callbackUrl:r}){const i={post_authn_action:n};return r&&(i.callback_url=r),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:i}}}}async function x(e){const t=O({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await I(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}function C(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}class R extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}function D(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new R(n.map((e=>`Missing required parameter: ${e}`)))}function L(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function N(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}function U(e){if(!e||"object"!=typeof e)throw new R("requestSettings must be an object");const t=e,{action:n,callbackUrl:r}=e;D(t,[{name:"action"}]);const i=L(t),o=Object.values(p);if(o.includes(n)||i.push(`action must be one of ${o.join(", ")}`),i.length>0)throw new R(i);if(void 0!==r&&""===r.trim())throw new R("callbackUrl cannot be empty")}async function M({requestSettings:e,operationSettings:t}){U(e);const{accessToken:n,stagingToken:r}=t||{},i=n||s();return C(await x({accessToken:i,stagingToken:r,action:e.action,callbackUrl:e.callbackUrl}))}const j={request:M};function q(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function F(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}const B=[];for(let e=0;e<256;++e)B.push((e+256).toString(16).slice(1));let $;const H=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function z(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!$){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");$=crypto.getRandomValues.bind(crypto)}return $(H)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(B[e[t+0]]+B[e[t+1]]+B[e[t+2]]+B[e[t+3]]+"-"+B[e[t+4]]+B[e[t+5]]+"-"+B[e[t+6]]+B[e[t+7]]+"-"+B[e[t+8]]+B[e[t+9]]+"-"+B[e[t+10]]+B[e[t+11]]+B[e[t+12]]+B[e[t+13]]+B[e[t+14]]+B[e[t+15]]).toLowerCase()}(r)}function V(e,t,n){return K.randomUUID&&!e?K.randomUUID():z(e)}function G(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function W(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const J="/v2/sepa/beneficiaries";async function Y({paginationSettings:e,accessToken:t,stagingToken:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=q(e),o=i.size?`?${i.toString()}`:"";return{path:`${J}${o}`,options:r}}({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:i,meta:o}=await I(r);return{beneficiaries:i,meta:o}}function X({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${J}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Q({accessToken:e,stagingToken:t,beneficiaryId:n}){const r=X({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:i}=await I(r);return i}async function Z({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r=V()}){const i=function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r=V()}){return{path:J,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:r},body:{beneficiary:W(e)}}}}({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r}),{beneficiary:o}=await I(i);return o}async function ee({beneficiaryIds:e,accessToken:t,stagingToken:n}){const r=function({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${J}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:i}=await I(r);return i}async function te({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}){const o=function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}){const{name:o,email:s,activityTag:a}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i},body:{beneficiary:{name:o,email:s,activity_tag:a}}};return{path:`${J}/${e.id}`,options:c}}({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}),{beneficiary:s}=await I(o);return s}const ne=[{name:"name"},{name:"iban"}];function re(e){if(!e)throw new R("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new R("beneficiaryId must be a string");return e}const ie={getBeneficiaries:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||s(),o=await Y({accessToken:i,stagingToken:n,paginationSettings:r}),a=o.beneficiaries.map((e=>G(e))),c=F(o.meta);return{beneficiaries:a,...c?{meta:c}:{}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=re(e?.beneficiaryId),{accessToken:r,stagingToken:i}=t||{},o=r||s();return G(await Q({beneficiaryId:n,accessToken:o,stagingToken:i}))},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new R("beneficiary must be an object");D(e,ne);const t=L({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new R(t);return e}(e),{accessToken:r,stagingToken:i,idempotencyKey:o}=t||{},a=r||s();return G(await Z({beneficiary:n,accessToken:a,stagingToken:i,idempotencyKey:o}))},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:r,activityTag:i}=e||{};if(!t)throw new R("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!r&&!i)throw new R("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const o=L({name:n,email:r,activityTag:i});if(o.length>0)throw new R(o);return{id:t,name:n,email:r,activityTag:i}}(e),{accessToken:r,stagingToken:i,idempotencyKey:o,mfaPreference:a}=t||{},c={beneficiaryParamsBeingEdited:n,accessToken:r||s(),stagingToken:i,idempotencyKey:o,mfaPreference:a};return G(await te(c))},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new R("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{accessToken:r,stagingToken:i}=t||{},o=r||s();return(await ee({beneficiaryIds:n,accessToken:o,stagingToken:i})).map(G)}},oe="SDK Initialized",se="Cards List";var ae=function(e,t){return ae=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},ae(e,t)};function ce(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}ae(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var ue,le,de=function(){return de=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},de.apply(this,arguments)};function fe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function pe(e,t,n,r){return new(n||(n=Promise))((function(i,o){function s(e){try{c(r.next(e))}catch(e){o(e)}}function a(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))}function ge(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},s=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return s.next=a(0),s.throw=a(1),s.return=a(2),"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(a){return function(c){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,a[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&a[0]?r.return:a[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,a[1])).done)return i;switch(r=0,i&&(a=[2&a[0],i.value]),a[0]){case 0:case 1:i=a;break;case 4:return o.label++,{value:a[1],done:!1};case 5:o.label++,r=a[1],a=[0];continue;case 7:a=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==a[0]&&2!==a[0])){o=0;continue}if(3===a[0]&&(!i||a[1]>i[0]&&a[1]<i[3])){o.label=a[1];break}if(6===a[0]&&o.label<i[1]){o.label=i[1],i=a;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(a);break}i[2]&&o.ops.pop(),o.trys.pop();continue}a=t.call(e,o)}catch(e){a=[6,e],r=0}finally{n=i=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,c])}}}function he(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ve(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function me(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(ue||(ue={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(le||(le={}));var ye,be="AMP",we="".concat(be,"_unsent"),Te="$default_instance",ke="https://api2.amplitude.com/2/httpapi",Ee="https://api.eu.amplitude.com/2/httpapi",Se="https://api2.amplitude.com/batch",_e="https://api.eu.amplitude.com/batch",Ie="dclid",Pe="fbclid",Ae="gbraid",Oe="gclid",xe="ko_click_id",Ce="li_fat_id",Re="msclkid",De="rdt_cid",Le="ttclid",Ne="twclid",Ue="wbraid",Me={utm_campaign:void 0,utm_content:void 0,utm_id:void 0,utm_medium:void 0,utm_source:void 0,utm_term:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gbraid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,li_fat_id:void 0,msclkid:void 0,rdt_cid:void 0,ttclid:void 0,twclid:void 0,wbraid:void 0},je=["access-control-allow-origin","access-control-allow-credentials","access-control-expose-headers","access-control-max-age","access-control-allow-methods","access-control-allow-headers","accept-patch","accept-ranges","age","allow","alt-svc","cache-control","connection","content-disposition","content-encoding","content-language","content-length","content-location","content-md5","content-range","content-type","date","delta-base","etag","expires","im","last-modified","link","location","permanent","p3p","pragma","proxy-authenticate","public-key-pins","retry-after","server","status","strict-transport-security","trailer","transfer-encoding","tk","upgrade","vary","via","warning","www-authenticate","x-b3-traceid","x-frame-options"],qe=["authorization","cookie","set-cookie"],Fe=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!Be(t,n))return!1}return!0},Be=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=he(t),s=o.next();!s.done;s=o.next()){var a=s.value;if(Array.isArray(a))return!1;if("object"==typeof a)i=i&&Fe(a);else if(!["number","string"].includes(typeof a))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return Fe(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},$e=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return de({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(ye.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(ye.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(ye.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(ye.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(ye.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(ye.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(ye.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(ye.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(ye.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[ye.CLEAR_ALL]="-",this},e.prototype._safeSet=function(e,t,n){if(this._validate(e,t,n)){var r=this._properties[e];return void 0===r&&(r={},this._properties[e]=r),r[t]=n,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,n){return void 0===this._properties[ye.CLEAR_ALL]&&(!this._propertySet.has(t)&&(e===ye.ADD?"number"==typeof n:e===ye.UNSET||e===ye.REMOVE||Be(t,n)))},e}();!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(ye||(ye={}));var He,Ke=[ye.CLEAR_ALL,ye.UNSET,ye.SET,ye.SET_ONCE,ye.ADD,ye.APPEND,ye.PREPEND,ye.PREINSERT,ye.POSTINSERT,ye.REMOVE];!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(He||(He={}));var ze,Ve=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=He.Unknown),{event:e,code:t,message:n}},Ge=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},We=me([],ve(Array(256).keys()),!1).map((function(e){return e.toString(16).padStart(2,"0")})),Je=function(e){var t,n=Ge();if(!(null===(t=null==n?void 0:n.crypto)||void 0===t?void 0:t.getRandomValues))return function(e){return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,Je)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,me([],ve(r.entries()),!1).map((function(e){var t=ve(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(We[r]):We[r]})).join("")},Ye=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this._optOutListeners=[]}return e.prototype.register=function(e,t){var n,r;return pe(this,void 0,void 0,(function(){return ge(this,(function(i){switch(i.label){case 0:return this.plugins.some((function(t){return t.name===e.name}))?(this.loggerProvider.warn("Plugin with name ".concat(e.name," already exists, skipping registration")),[2]):(void 0===e.name&&(e.name=Je(),this.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(e.name,". \n Set a name for the plugin to prevent it from being added multiple times."))),e.type=null!==(n=e.type)&&void 0!==n?n:"enrichment",[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)]);case 1:return i.sent(),this.plugins.push(e),[2]}}))}))},e.prototype.deregister=function(e,t){var n;return pe(this,void 0,void 0,(function(){var r,i;return ge(this,(function(o){switch(o.label){case 0:return r=this.plugins.findIndex((function(t){return t.name===e})),-1===r?(t.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2]):(i=this.plugins[r],this.plugins.splice(r,1),[4,null===(n=i.teardown)||void 0===n?void 0:n.call(i)]);case 1:return o.sent(),[2]}}))}))},e.prototype.reset=function(e){this._clearOptOutListeners(),this.applying=!1,this.plugins.map((function(e){var t;return null===(t=e.teardown)||void 0===t?void 0:t.call(e)})),this.plugins=[],this.client=e},e.prototype.push=function(e){var t=this;return new Promise((function(n){t.queue.push([e,n]),t.scheduleApply(0)}))},e.prototype.scheduleApply=function(e){var t=this;this.applying||(this.applying=!0,setTimeout((function(){t.apply(t.queue.shift()).then((function(){t.applying=!1,t.queue.length>0&&t.scheduleApply(0)}))}),e))},e.prototype.apply=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,c,u,l,d,f,p,g,h,v,m,y,b,w;return ge(this,(function(T){switch(T.label){case 0:if(!e)return[2];t=ve(e,1),n=t[0],r=ve(e,2),i=r[1],this.loggerProvider.log("Timeline.apply: Initial event",n),o=this.plugins.filter((function(e){return"before"===e.type})),T.label=1;case 1:T.trys.push([1,6,7,8]),s=he(o),a=s.next(),T.label=2;case 2:return a.done?[3,5]:(f=a.value).execute?[4,f.execute(de({},n))]:[3,4];case 3:if(null===(p=T.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),i({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),T.label=4;case 4:return a=s.next(),[3,2];case 5:return[3,8];case 6:return c=T.sent(),m={error:c},[3,8];case 7:try{a&&!a.done&&(y=s.return)&&y.call(s)}finally{if(m)throw m.error}return[7];case 8:u=this.plugins.filter((function(e){return"enrichment"===e.type||void 0===e.type})),T.label=9;case 9:T.trys.push([9,14,15,16]),l=he(u),d=l.next(),T.label=10;case 10:return d.done?[3,13]:(f=d.value).execute?[4,f.execute(de({},n))]:[3,12];case 11:if(null===(p=T.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),i({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),T.label=12;case 12:return d=l.next(),[3,10];case 13:return[3,16];case 14:return g=T.sent(),b={error:g},[3,16];case 15:try{d&&!d.done&&(w=l.return)&&w.call(l)}finally{if(b)throw b.error}return[7];case 16:return h=this.plugins.filter((function(e){return"destination"===e.type})),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(n))),v=h.map((function(e){var t=de({},n);return e.execute(t).catch((function(e){return Ve(t,0,String(e))}))})),Promise.all(v).then((function(e){var t=ve(e,1)[0]||Ve(n,100,"Event not tracked, no destination plugins on the instance");i(t)})),[2]}}))}))},e.prototype.flush=function(){return pe(this,void 0,void 0,(function(){var e,t,n,r=this;return ge(this,(function(i){switch(i.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map((function(e){return r.apply(e)})))];case 1:return i.sent(),t=this.plugins.filter((function(e){return"destination"===e.type})),n=t.map((function(e){return e.flush&&e.flush()})),[4,Promise.all(n)];case 2:return i.sent(),[2]}}))}))},e.prototype.addOptOutListener=function(e){this._optOutListeners.push(e)},e.prototype._clearOptOutListeners=function(){this._optOutListeners=[]},e.prototype.onIdentityChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onIdentityChanged)||void 0===n||n.call(t,e)}))},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onSessionIdChanged)||void 0===n||n.call(t,e)}))},e.prototype.onOptOutChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onOptOutChanged)||void 0===n||n.call(t,e)})),this._callOptOutListeners(e)},e.prototype._callOptOutListeners=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o,s,a;return ge(this,(function(c){switch(c.label){case 0:c.trys.push([0,7,8,9]),t=he(this._optOutListeners),n=t.next(),c.label=1;case 1:if(n.done)return[3,6];r=n.value,c.label=2;case 2:return c.trys.push([2,4,,5]),[4,r(e)];case 3:return c.sent(),[3,5];case 4:return i=c.sent(),this.loggerProvider.error("Error calling optOut listener",i),[3,5];case 5:return n=t.next(),[3,1];case 6:return[3,9];case 7:return o=c.sent(),s={error:o},[3,9];case 8:try{n&&!n.done&&(a=t.return)&&a.call(t)}finally{if(s)throw s.error}return[7];case 9:return[2]}}))}))},e.prototype.onReset=function(){this.plugins.forEach((function(e){var t;null===(t=e.onReset)||void 0===t||t.call(e)}))},e}(),Xe=function(e,t){return de(de({},t),{event_type:le.IDENTIFY,user_properties:e.getUserProperties()})},Qe=function(e){return{promise:e||Promise.resolve()}},Ze=function(){function e(e){void 0===e&&(e="$default"),this.initializing=!1,this.isReady=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new Ye(this),this.name=e}return e.prototype._init=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){switch(t.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q")];case 1:return t.sent(),this.isReady=!0,[2]}}))}))},e.prototype.runQueuedFunctions=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o,s,a,c;return ge(this,(function(u){switch(u.label){case 0:t=this[e],this[e]=[],u.label=1;case 1:u.trys.push([1,8,9,10]),n=he(t),r=n.next(),u.label=2;case 2:return r.done?[3,7]:(i=r.value,(o=i())&&"promise"in o?[4,o.promise]:[3,4]);case 3:return u.sent(),[3,6];case 4:return[4,o];case 5:u.sent(),u.label=6;case 6:return r=n.next(),[3,2];case 7:return[3,10];case 8:return s=u.sent(),a={error:s},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(a)throw a.error}return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e)]:[3,12];case 11:u.sent(),u.label=12;case 12:return[2]}}))}))},e.prototype.track=function(e,t,n){var r=function(e,t,n){return de(de(de({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),Qe(this.dispatch(r))},e.prototype.identify=function(e,t){var n=Xe(e,t);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),Qe(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var i=function(e,t,n,r){var i;return de(de({},r),{event_type:le.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(i={},i[e]=t,i)})}(e,t,n,r);return Qe(this.dispatch(i))},e.prototype.setGroup=function(e,t,n){var r=function(e,t,n){var r,i=new $e;return i.set(e,t),de(de({},n),{event_type:le.IDENTIFY,user_properties:i.getUserProperties(),groups:(r={},r[e]=t,r)})}(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),Qe(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=function(e,t){return de(de({},t),{event_type:le.REVENUE,event_properties:e.getEventProperties()})}(e,t);return Qe(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),Qe())},e.prototype._addPlugin=function(e){return Qe(this.timeline.register(e,this.config))},e.prototype.remove=function(e){return this.isReady?this._removePlugin(e):(this.q.push(this._removePlugin.bind(this,e)),Qe())},e.prototype._removePlugin=function(e){return Qe(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(Ve(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return pe(this,void 0,void 0,(function(){var t=this;return ge(this,(function(n){return this.isReady?[2,this.process(e)]:[2,new Promise((function(n){t.dispatchQ.push(t.dispatchWithCallback.bind(t,e,n))}))]}))}))},e.prototype.getOperationAppliedUserProperties=function(e){var t,n=null!==(t=this.userProperties)&&void 0!==t?t:{},r=de({},n);if(void 0===e)return r;var i={};return Object.keys(e).forEach((function(t){Object.values(ue).includes(t)||(i[t]=e[t])})),Ke.forEach((function(t){if(Object.keys(e).includes(t)){var n=e[t];switch(t){case ue.CLEAR_ALL:Object.keys(r).forEach((function(e){delete r[e]}));break;case ue.UNSET:Object.keys(n).forEach((function(e){delete r[e]}));break;case ue.SET:Object.assign(r,n)}}})),Object.assign(r,i),r},e.prototype.process=function(e){return pe(this,void 0,void 0,(function(){var t,n,r;return ge(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.config.optOut?[2,Ve(e,0,"Event skipped due to optOut config")]:(e.event_type===le.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)]);case 1:return 200===(r=i.sent()).code?this.config.loggerProvider.log(r.message):100===r.code?this.config.loggerProvider.warn(r.message):this.config.loggerProvider.error(r.message),[2,r];case 2:return t=i.sent(),n=String(t),this.config.loggerProvider.error(n),[2,r=Ve(e,0,n)];case 3:return[2]}}))}))},e.prototype.setOptOut=function(e){this.isReady?this._setOptOut(e):this.q.push(this._setOptOut.bind(this,Boolean(e)))},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.config.optOut=Boolean(e),this.timeline.onOptOutChanged(e))},e.prototype.flush=function(){return Qe(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find((function(t){return t.name===e}));if(void 0!==t)return t;this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e))},e.prototype.plugins=function(e){return this.timeline.plugins.filter((function(t){return t instanceof e}))},e}(),et=function(){function e(){this.productId="",this.quantity=1,this.price=0}return e.prototype.setProductId=function(e){return this.productId=e,this},e.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},e.prototype.setPrice=function(e){return this.price=e,this},e.prototype.setRevenueType=function(e){return this.revenueType=e,this},e.prototype.setCurrency=function(e){return this.currency=e,this},e.prototype.setRevenue=function(e){return this.revenue=e,this},e.prototype.setReceipt=function(e){return this.receipt=e,this},e.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},e.prototype.setEventProperties=function(e){try{var t=JSON.parse(JSON.stringify(e));Fe(t)&&(this.properties=t)}catch(e){}return this},e.prototype.getEventProperties=function(){var e=this.properties?de({},this.properties):{};return e[ze.REVENUE_PRODUCT_ID]=this.productId,e[ze.REVENUE_QUANTITY]=this.quantity,e[ze.REVENUE_PRICE]=this.price,e[ze.REVENUE_TYPE]=this.revenueType,e[ze.REVENUE_CURRENCY]=this.currency,e[ze.REVENUE]=this.revenue,e[ze.RECEIPT]=this.receipt,e[ze.RECEIPT_SIG]=this.receiptSig,e},e}();!function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE_CURRENCY="$currency",e.REVENUE="$revenue",e.RECEIPT="$receipt",e.RECEIPT_SIG="$receiptSig"}(ze||(ze={}));var tt;!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(tt||(tt={}));var nt="Amplitude Logger ",rt=function(){function e(){this.logLevel=tt.None}return e.prototype.disable=function(){this.logLevel=tt.None},e.prototype.enable=function(e){void 0===e&&(e=tt.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<tt.Verbose||console.log("".concat(nt,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<tt.Warn||console.warn("".concat(nt,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<tt.Error||console.error("".concat(nt,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<tt.Debug||console.log("".concat(nt,"[Debug]: ").concat(e.join(" ")))},e}(),it=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:Te,logLevel:tt.Warn,loggerProvider:new rt,offline:!1,optOut:!1,serverUrl:ke,serverZone:"US",useBatch:!1}},ot=function(){function e(e){var t,n,r,i;this._optOut=!1;var o=it();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:o.offline,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(i=e.useBatch)&&void 0!==i?i:o.useBatch,this.loggerProvider.enable(this.logLevel);var s=at(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=s.serverZone,this.serverUrl=s.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),st=function(e,t){return"EU"===e?t?_e:Ee:t?Se:ke},at=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=it().serverZone),void 0===n&&(n=it().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:it().serverZone;return{serverZone:r,serverUrl:st(r,n)}},ct=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function ut(e){return e>=200&&e<300}var lt=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},dt=function(e){return function(){var t=de({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},ft=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=he(t.split(".")),o=i.next();!o.done;o=i.next()){var s=o.value;if(!(s in e))return;e=e[s]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},pt=function(e,t){return function(){var n,r,i={};try{for(var o=he(t),s=o.next();!s.done;s=o.next()){var a=s.value;i[a]=ft(e,a)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},gt=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],s=0;s<arguments.length;s++)o[s]=arguments[s];var a=n(),c=a.logger,u=a.logLevel;if(u&&u<tt.Debug||!u||!c)return e.apply(i,o);var l={type:"invoke public method",name:t,args:o,stacktrace:lt(1),time:{start:(new Date).toISOString()},states:{}};r&&l.states&&(l.states.before=r());var d=e.apply(i,o);return d&&d.promise?d.promise.then((function(){r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))})):(r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))),d}},ht=new Set([ke,Ee,Se,_e]);function vt(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var mt=function(){function e(e){this.name="amplitude",this.type="destination",this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey="",this.scheduleId=null,this.scheduledTimeout=0,this.flushId=null,this.queue=[],this.diagnosticsClient=null==e?void 0:e.diagnosticsClient}return e.prototype.setup=function(e){var t;return pe(this,void 0,void 0,(function(){var n,r=this;return ge(this,(function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(we,"_").concat(this.config.apiKey.substring(0,10)),[4,null===(t=this.config.storageProvider)||void 0===t?void 0:t.get(this.storageKey)];case 1:return(n=i.sent())&&n.length>0&&Promise.all(n.map((function(e){return r.execute(e)}))).catch(),[2,Promise.resolve(void 0)]}}))}))},e.prototype.execute=function(e){var t=this;return e.insert_id||(e.insert_id=Je()),new Promise((function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()}))},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter((function(e){return e.attempts+=1,e.attempts<t.config.flushMaxRetries||(t.fulfillRequest([e],500,"Event rejected due to exceeded retry count"),!1)}))},e.prototype.scheduleEvents=function(e){var t=this;e.forEach((function(e){t.schedule(0===e.timeout?t.config.flushIntervalMillis:e.timeout)}))},e.prototype.schedule=function(e){var t=this;if(!this.config.offline)return null===this.scheduleId||this.scheduleId&&e>this.scheduledTimeout?(this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,void(this.scheduleId=setTimeout((function(){t.queue=t.queue.map((function(e){return e.timeout=0,e})),t.flush(!0)}),e))):void 0},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return void 0===e&&(e=!1),pe(this,void 0,void 0,(function(){var t,n,r,i=this;return ge(this,(function(o){switch(o.label){case 0:return this.config.offline?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush while offline."),[2]):this.flushId?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved."),[2]):(this.flushId=this.scheduleId,this.resetSchedule(),t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),s=t,a=this.config.flushQueueSize,c=Math.max(a,1),r=s.reduce((function(e,t,n){var r=Math.floor(n/c);return e[r]||(e[r]=[]),e[r].push(t),e}),[]),[4,r.reduce((function(t,n){return pe(i,void 0,void 0,(function(){return ge(this,(function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}}))}))}),Promise.resolve())]);case 1:return o.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}var s,a,c}))}))},e.prototype.send=function(e,t){var n;return void 0===t&&(t=!0),pe(this,void 0,void 0,(function(){var r,i,o,s,a,c;return ge(this,(function(u){switch(u.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];r={api_key:this.config.apiKey,events:e.map((function(e){var t=e.event;return t.extra,fe(t,["extra"])})),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new ct,u.label=1;case 1:return u.trys.push([1,3,,4]),i=at(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,o=function(e,t){return void 0===t&&(t=!1),!!ht.has(e)||t}(i,this.config.enableRequestBodyCompression),[4,this.config.transportProvider.send(i,r,this.config._enableRequestBodyCompressionExperimental&&o)];case 2:return null===(s=u.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(s,e),[3,4]):("body"in s?this.fulfillRequest(e,s.statusCode,"".concat(s.status,": ").concat(vt(s))):this.fulfillRequest(e,s.statusCode,s.status),[2]);case 3:return a=u.sent(),c=(l=a)instanceof Error?l.message:String(l),this.config.loggerProvider.error(c),null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map((function(e){return e.event.event_type})),message:c,stack_trace:lt()}),this.handleResponse({status:He.Failed,statusCode:0},e),[3,4];case 4:return[2]}var l}))}))},e.prototype.handleResponse=function(e,t){var n;ut(e.statusCode)||null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful",{events:t.map((function(e){return e.event.event_type})),code:e.statusCode,status:e.status,body:vt(e),stack_trace:lt()});var r=e.status;switch(r){case He.Success:this.handleSuccessResponse(e,t);break;case He.Invalid:this.handleInvalidResponse(e,t);break;case He.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case He.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(r,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))this.fulfillRequest(t,e.statusCode,e.body.error);else{var r=me(me(me(me([],ve(Object.values(e.body.eventsWithInvalidFields)),!1),ve(Object.values(e.body.eventsWithMissingFields)),!1),ve(Object.values(e.body.eventsWithInvalidIdLengths)),!1),ve(e.body.silencedEvents),!1).flat(),i=new Set(r),o=t.filter((function(t,r){if(!i.has(r))return!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));o.length>0&&this.config.loggerProvider.warn(vt(e));var s=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(s)}},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1!==t.length){this.config.loggerProvider.warn(vt(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)}else this.fulfillRequest(t,e.statusCode,e.body.error)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,s=new Set(r),a=new Set(i),c=new Set(o),u=t.filter((function(t,r){if(!(t.event.user_id&&s.has(t.event.user_id)||t.event.device_id&&a.has(t.event.device_id)))return c.has(r)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));u.length>0&&this.config.loggerProvider.warn(vt(e));var l=this.removeEventsExceedFlushMaxRetries(u);this.scheduleEvents(l)},e.prototype.handleOtherResponse=function(e){var t=this,n=e.map((function(e){return e.timeout=e.attempts*t.retryTimeout,e})),r=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(r)},e.prototype.fulfillRequest=function(e,t,n){var r,i,o;ut(t)?null===(o=this.diagnosticsClient)||void 0===o||o.increment("analytics.events.sent",e.length):(null===(r=this.diagnosticsClient)||void 0===r||r.increment("analytics.events.dropped",e.length),null===(i=this.diagnosticsClient)||void 0===i||i.recordEvent("analytics.events.dropped",{events:e.map((function(e){return e.event.event_type})),code:t,message:n,stack_trace:lt()})),this.removeEvents(e),e.forEach((function(e){return e.callback(Ve(e.event,t,n))}))},e.prototype.saveEvents=function(){if(this.config.storageProvider){var e=this.queue.map((function(e){return e.event}));this.config.storageProvider.set(this.storageKey,e)}},e.prototype.removeEvents=function(e){this.queue=this.queue.filter((function(t){return!e.some((function(e){return e.event.insert_id===t.event.insert_id}))})),this.saveEvents()},e}(),yt=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:bt(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),bt=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},wt=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach((function(t){e(t)})),this.queue=[])},e}(),Tt=function(){return Tt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},Tt.apply(this,arguments)};function kt(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Et(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),s=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)s.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}"function"==typeof SuppressedError&&SuppressedError;var St=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=kt(["string","number","boolean","undefined"]),s=o.next();!s.done;s=o.next()){if(s.value===i)return e===t}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var a=Array.isArray(e),c=Array.isArray(t);if(a!==c)return!1;if(!a||!c){var u=Object.keys(e).sort(),l=Object.keys(t).sort();if(!St(u,l))return!1;var d=!0;return Object.keys(e).forEach((function(n){St(e[n],t[n])||(d=!1)})),d}for(var f=0;f<e.length;f++)if(!St(e[f],t[f]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var _t=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=Tt({},this.identity.userProperties),n=Tt(Tt({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,i,o,s,a,c=n.userProperties||{};try{for(var u=kt(Object.entries(e)),l=u.next();!l.done;l=u.next()){var d=Et(l.value,2),f=d[0],p=d[1];switch(f){case"$set":try{for(var g=(i=void 0,kt(Object.entries(p))),h=g.next();!h.done;h=g.next()){var v=Et(h.value,2),m=v[0],y=v[1];c[m]=y}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=g.return)&&o.call(g)}finally{if(i)throw i.error}}break;case"$unset":try{for(var b=(s=void 0,kt(Object.keys(p))),w=b.next();!w.done;w=b.next()){delete c[m=w.value]}}catch(e){s={error:e}}finally{try{w&&!w.done&&(a=b.return)&&a.call(b)}finally{if(s)throw s.error}}break;case"$clearAll":c={}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return n.userProperties=c,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return Tt({},this.identity)},e.prototype.setIdentity=function(e){var t=Tt({},this.identity);this.identity=Tt({},e),St(t,this.identity)||this.listeners.forEach((function(t){t(e)}))},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),It="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,Pt=function(){function e(){this.identityStore=new _t,this.eventBridge=new wt,this.applicationContextProvider=new yt}return e.getInstance=function(t){return It.analyticsConnectorInstances||(It.analyticsConnectorInstances={}),It.analyticsConnectorInstances[t]||(It.analyticsConnectorInstances[t]=new e),It.analyticsConnectorInstances[t]},e}(),At=function(e){return void 0===e&&(e=Te),Pt.getInstance(e)},Ot=function(){function e(){this.name="identity",this.type="before",this.identityStore=At().identityStore}return e.prototype.execute=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]}))}))},e.prototype.setup=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){return e.instanceName&&(this.identityStore=At(e.instanceName).identityStore),[2]}))}))},e}(),xt=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},Ct=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[be,t,e.substring(0,n)].filter(Boolean).join("_")},Rt=function(){var e,t,n,r;if("undefined"==typeof navigator)return"";var i=navigator.userLanguage;return null!==(r=null!==(n=null!==(t=null===(e=navigator.languages)||void 0===e?void 0:e[0])&&void 0!==t?t:navigator.language)&&void 0!==n?n:i)&&void 0!==r?r:""},Dt=function(){var e,t=Ge();return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.search)?t.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),r=Lt(n[0]),i=Lt(n[1]);return i?(e[r]=i,e):e}),{}):{}},Lt=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},Nt=function(e,t){return!t||!t.length||t.some((function(t){return"string"==typeof t?e===t:e.match(t)}))},Ut=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},Mt=function(e,t){var n=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}(e.toString());return 31*Math.abs(n)%1e5/1e5<t},jt=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return[2,!0]}))}))},e.prototype.get=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){return[2,this.memoryStorage.get(e)]}))}))},e.prototype.getRaw=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return[2,(t=n.sent())?JSON.stringify(t):void 0]}}))}))},e.prototype.set=function(e,t){return pe(this,void 0,void 0,(function(){return ge(this,(function(n){return this.memoryStorage.set(e,t),[2]}))}))},e.prototype.remove=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){return this.memoryStorage.delete(e),[2]}))}))},e.prototype.reset=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return this.memoryStorage.clear(),[2]}))}))},e}(),qt=function(){function e(e,t){void 0===t&&(t={}),this.options=de({},e),this.config=t}return e.prototype.isEnabled=function(){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(s){switch(s.label){case 0:return t="AMP_TEST",n=de({},this.options),r=new e(n),i=String(Date.now()),[4,r.transaction(t,(function(e){var n,r;try{e.set(i);var s=e.get()===i;return!s&&o.config.diagnosticsClient&&(null===(n=o.config.diagnosticsClient)||void 0===n||n.recordEvent("cookies.isEnabled.failure",{reason:"Test Value mismatch",testKey:t,testValue:i,sync:!0})),s}catch(e){if(o.config.diagnosticsClient){var a=e instanceof Error?e.message:String(e);null===(r=o.config.diagnosticsClient)||void 0===r||r.recordEvent("cookies.isEnabled.failure",{reason:"Cookie getter/setter failed",testKey:t,testValue:i,error:a,sync:!0})}return!1}finally{e.set(null)}}))];case 1:return[2,s.sent()]}}))}))},e.prototype.get=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return t=n.sent(),[2,this.decodeCookieValue(e,t)]}}))}))},e.prototype.decodeCookieValue=function(e,t){if(t)try{var n=Ft(t);return void 0===n?void console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(t)):JSON.parse(n)}catch(n){return void console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(t))}},e.prototype.getSync=function(e){var t=this.getRawSync(e);return this.decodeCookieValue(e,t)},e.prototype.getRaw=function(e){var t,n;return pe(this,void 0,void 0,(function(){var r,i,o,s,a,c,u,l,d;return ge(this,(function(f){switch(f.label){case 0:r=Ge(),i=r,f.label=1;case 1:return f.trys.push([1,4,,5]),(o=null==i?void 0:i.cookieStore)?[4,o.getAll(e)]:[3,3];case 2:if(s=f.sent()){s.length>1&&(null===(t=this.config.diagnosticsClient)||void 0===t||t.recordEvent("cookies.duplicate",{cookies:s.map((function(e){return e.domain}))}),null===(n=this.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(a=he(s),c=a.next();!c.done;c=a.next())if(u=c.value,Bt(u.domain,this.options.domain))return[2,u.value]}catch(e){l={error:e}}finally{try{c&&!c.done&&(d=a.return)&&d.call(a)}finally{if(l)throw l.error}}}f.label=3;case 3:return[3,5];case 4:return f.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}}))}))},e.prototype.getRawSync=function(e){var t,n,r=this,i=Ge(),o=(null!==(n=null===(t=null==i?void 0:i.document)||void 0===t?void 0:t.cookie.split("; "))&&void 0!==n?n:[]).filter((function(t){return 0===t.indexOf(e+"=")})),s=void 0,a=this.config.duplicateResolverFn;if("function"==typeof a&&o.length>1&&(s=o.find((function(t){var n;try{var i=a(t.substring(e.length+1));return i||null===(n=r.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.document.cookie"),i}catch(e){return!1}}))),s||(s=o[0]),s)return s.substring(e.length+1)},e.prototype.set=function(e,t){return pe(this,void 0,void 0,(function(){return ge(this,(function(n){return this.setSync(e,t),[2]}))}))},e.prototype.setSync=function(e,t){var n;try{var r=null!==(n=this.options.expirationDays)&&void 0!==n?n:0,i=null!==t?r:-1,o=void 0;if(i){var s=new Date;s.setTime(s.getTime()+24*i*60*60*1e3),o=s}var a="".concat(e,"=").concat(btoa(encodeURIComponent(JSON.stringify(t))));o&&(a+="; expires=".concat(o.toUTCString())),a+="; path=/",this.options.domain&&(a+="; domain=".concat(this.options.domain)),this.options.secure&&(a+="; Secure"),this.options.sameSite&&(a+="; SameSite=".concat(this.options.sameSite));var c=Ge();(null==c?void 0:c.document)&&(c.document.cookie=a)}catch(t){var u=t instanceof Error?t.message:String(t);console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(u))}},e.prototype.remove=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){switch(t.label){case 0:return[4,this.set(e,null)];case 1:return t.sent(),[2]}}))}))},e.prototype.reset=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return[2]}))}))},e.isDomainWritable=function(t){return pe(this,void 0,void 0,(function(){var n,r;return ge(this,(function(i){switch(i.label){case 0:if(e.cachedTlds[t])return[2,!0];n="AMP_TLDTEST",r=new e({domain:"."+t}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r.transaction(n,(function(n){if(e.cachedTlds[t])return!0;try{n.set(1);var r=!!n.get();return r&&(e.cachedTlds[t]=!0),r}finally{n.set(null)}}))];case 2:return[2,!!i.sent()];case 3:return i.sent(),[2,!1];case 4:return[2]}}))}))},e.prototype.transaction=function(e,t){return pe(this,void 0,void 0,(function(){var n,r,i=this;return ge(this,(function(o){switch(o.label){case 0:if(n=function(){var e,t=Ge();return null===(e=null==t?void 0:t.navigator)||void 0===e?void 0:e.locks}(),r=function(){return t({get:function(){return i.getSync(e)},set:function(t){return i.setSync(e,t)}})},!n)return[2,r()];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.request("com.amplitude:cookie-lock:".concat(e),r)];case 2:return[2,o.sent()];case 3:return o.sent(),[2,r()];case 4:return[2]}}))}))},e.cachedTlds={},e}(),Ft=function(e){var t;return null!==(t=function(e){try{return decodeURIComponent(atob(e))}catch(e){return}}(e))&&void 0!==t?t:function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch(e){return}}(e)},Bt=function(e,t){if(""===e&&""===t)return!0;if(!e||!t)return!1;var n=e.startsWith(".")?e.substring(1):e,r=t.startsWith(".")?t.substring(1):t;return n.toLowerCase()===r.toLowerCase()},$t=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[be,t,e.substring(0,n)].filter(Boolean).join("_")},Ht=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return pe(this,void 0,void 0,(function(){var t,n,r;return ge(this,(function(i){switch(i.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),r="AMP_TEST",i.label=1;case 1:return i.trys.push([1,4,5,7]),[4,n.set(r,t)];case 2:return i.sent(),[4,n.get(r)];case 3:return[2,i.sent()===t];case 4:return i.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return i.sent(),[7];case 7:return[2]}}))}))},e.prototype.get=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return(t=n.sent())?[2,JSON.parse(t)]:[2,void 0];case 2:return n.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}}))}))},e.prototype.getRaw=function(e){var t;return pe(this,void 0,void 0,(function(){return ge(this,(function(n){return[2,(null===(t=this.storage)||void 0===t?void 0:t.getItem(e))||void 0]}))}))},e.prototype.set=function(e,t){var n;return pe(this,void 0,void 0,(function(){return ge(this,(function(r){try{null===(n=this.storage)||void 0===n||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]}))}))},e.prototype.remove=function(e){var t;return pe(this,void 0,void 0,(function(){return ge(this,(function(n){try{null===(t=this.storage)||void 0===t||t.removeItem(e)}catch(e){}return[2]}))}))},e.prototype.reset=function(){var e;return pe(this,void 0,void 0,(function(){return ge(this,(function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]}))}))},e}(),Kt="tags",zt="counters",Vt="histograms",Gt="events",Wt="internal",Jt="last_flush_timestamp",Yt=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return e.isSupported=function(){var e;return void 0!==(null===(e=Ge())||void 0===e?void 0:e.indexedDB)},e.prototype.getDB=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]}))}))},e.prototype.openDB=function(){var e=this;return new Promise((function(t,n){var r=indexedDB.open(e.dbName,1);r.onerror=function(){e.dbPromise=null,n(new Error("Failed to open IndexedDB"))},r.onsuccess=function(){var n=r.result;n.onclose=function(){e.dbPromise=null,e.logger.debug("DiagnosticsStorage: DB connection closed.")},n.onerror=function(t){e.logger.debug("DiagnosticsStorage: A global database error occurred.",t),n.close()},t(n)},r.onupgradeneeded=function(t){var n=t.target.result;e.createTables(n)}}))},e.prototype.createTables=function(e){(e.objectStoreNames.contains(Kt)||e.createObjectStore(Kt,{keyPath:"key"}),e.objectStoreNames.contains(zt)||e.createObjectStore(zt,{keyPath:"key"}),e.objectStoreNames.contains(Vt)||e.createObjectStore(Vt,{keyPath:"key"}),e.objectStoreNames.contains(Gt))||e.createObjectStore(Gt,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1});e.objectStoreNames.contains(Wt)||e.createObjectStore(Wt,{keyPath:"key"})},e.prototype.setTags=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([Kt],"readwrite"),r=n.objectStore(Kt),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tags",e),t()},i.forEach((function(e){var t=ve(e,2),n=t[0],i=t[1];r.put({key:n,value:i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tag",n,i,e)}}))}))];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",i),[3,3];case 3:return[2]}}))}))},e.prototype.incrementCounters=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([zt],"readwrite"),r=n.objectStore(zt),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to increment counters",e),t()},i.forEach((function(e){var t=ve(e,2),n=t[0],i=t[1],s=r.get(n);s.onsuccess=function(){var e=s.result,t=e?e.value:0;r.put({key:n,value:t+i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to update counter",n,e)}},s.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing counter",n,e)}}))}))];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",i),[3,3];case 3:return[2]}}))}))},e.prototype.setHistogramStats=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([Vt],"readwrite"),r=n.objectStore(Vt),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",e),t()},i.forEach((function(e){var t=ve(e,2),n=t[0],i=t[1],s=r.get(n);s.onsuccess=function(){var e,t=s.result;e=t?{key:n,count:t.count+i.count,min:Math.min(t.min,i.min),max:Math.max(t.max,i.max),sum:t.sum+i.sum}:{key:n,count:i.count,min:i.min,max:i.max,sum:i.sum},r.put(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",n,e)}},s.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",n,e)}}))}))];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",i),[3,3];case 3:return[2]}}))}))},e.prototype.addEventRecords=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),0===e.length?[2]:[4,this.getDB()];case 1:return t=s.sent(),n=t.transaction([Gt],"readwrite"),r=n.objectStore(Gt),[2,new Promise((function(t){n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event records",e),t()};var i=r.count();i.onsuccess=function(){var t=i.result,n=Math.max(0,10-t);n<e.length&&o.logger.debug("DiagnosticsStorage: Only added ".concat(n," of ").concat(e.length," events due to storage limit")),e.slice(0,n).forEach((function(e){r.add(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event record",e)}}))},i.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to count existing events",e)}}))];case 2:return i=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",i),[3,3];case 3:return[2]}}))}))},e.prototype.setInternal=function(e,t){return pe(this,void 0,void 0,(function(){var n,r,i,o;return ge(this,(function(s){switch(s.label){case 0:return s.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=s.sent(),r=n.transaction([Wt],"readwrite"),i=r.objectStore(Wt),[2,new Promise((function(n,o){r.onabort=function(){return o(new Error("Failed to set internal value"))};var s=i.put({key:e,value:t});s.onsuccess=function(){return n()},s.onerror=function(){return o(new Error("Failed to set internal value"))}}))];case 2:return o=s.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",o),[3,3];case 3:return[2]}}))}))},e.prototype.getInternal=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i;return ge(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Wt],"readonly"),r=n.objectStore(Wt),[2,new Promise((function(t,i){n.onabort=function(){return i(new Error("Failed to get internal value"))};var o=r.get(e);o.onsuccess=function(){return t(o.result)},o.onerror=function(){return i(new Error("Failed to get internal value"))}}))];case 2:return i=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",i),[2,void 0];case 3:return[2]}}))}))},e.prototype.getLastFlushTimestamp=function(){return pe(this,void 0,void 0,(function(){var e,t;return ge(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(Jt)];case 1:return[2,(e=n.sent())?parseInt(e.value,10):void 0];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",t),[2,void 0];case 3:return[2]}}))}))},e.prototype.setLastFlushTimestamp=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(Jt,e.toString())];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to set last flush timestamp",t),[3,3];case 3:return[2]}}))}))},e.prototype.clearTable=function(e,t){return new Promise((function(n,r){var i=e.objectStore(t).clear();i.onsuccess=function(){return n()},i.onerror=function(){return r(new Error("Failed to clear table ".concat(t)))}}))},e.prototype.getAllAndClear=function(){return pe(this,void 0,void 0,(function(){var e,t,n,r,i,o,s,a;return ge(this,(function(c){switch(c.label){case 0:return c.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=c.sent(),t=e.transaction([Kt,zt,Vt,Gt],"readwrite"),[4,Promise.all([this.getAllFromStore(t,Kt),this.getAllFromStore(t,zt),this.getAllFromStore(t,Vt),this.getAllFromStore(t,Gt)])];case 2:return n=ve.apply(void 0,[c.sent(),4]),r=n[0],i=n[1],o=n[2],s=n[3],[4,Promise.all([this.clearTable(t,zt),this.clearTable(t,Vt),this.clearTable(t,Gt)])];case 3:return c.sent(),[2,{tags:r,counters:i,histogramStats:o,events:s}];case 4:return a=c.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",a),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}}))}))},e.prototype.getAllFromStore=function(e,t){return new Promise((function(n,r){var i=e.objectStore(t).getAll();i.onsuccess=function(){return n(i.result)},i.onerror=function(){return r(new Error("Failed to get all from ".concat(t)))}}))},e}(),Xt=function(e){var t,n,r=function(){var e=Ge();if(!e)return[];var t=e.__AMPLITUDE_SCRIPT_URL__;return Array.isArray(t)?t:"string"==typeof t?[t]:[]}();if(0!==r.length)try{for(var i=he(r),o=i.next();!o.done;o=i.next()){var s=o.value;if(e.filename&&e.filename.includes(s))return"filename";if(e.stack&&e.stack.includes(s))return"stack"}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},Qt=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},Zt=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},en=3e5,tn=1e4,nn=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=t,this.serverUrl="US"===n?"https://diagnostics.prod.us-west-2.amplitude.com/v1/capture":"https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(r,null,2)),this.config=de({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=Mt(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,Yt.isSupported()?this.storage=new Yt(e,t):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),function(e){var t=Ge();if(t&&"function"==typeof t.addEventListener){var n=function(t){e.recordEvent("sdk.error.uncaught",de({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};t.addEventListener("error",(function(e){var t=e.error instanceof Error?e.error:void 0,r=null==t?void 0:t.stack,i=Xt({filename:e.filename,stack:r});i&&n({type:"error",message:e.message,stack:r,filename:e.filename,errorName:null==t?void 0:t.name,metadata:{colno:e.colno,lineno:e.lineno,isTrusted:e.isTrusted,matchReason:i}})}),!0),t.addEventListener("unhandledrejection",(function(e){var t,r=e.reason instanceof Error?e.reason:void 0,i=null==r?void 0:r.stack,o=Qt(i),s=Xt({filename:o,stack:i});s&&n({type:"unhandledrejection",message:null!==(t=null==r?void 0:r.message)&&void 0!==t?t:Zt(e.reason),stack:i,filename:o,errorName:null==r?void 0:r.name,metadata:{isTrusted:e.isTrusted,matchReason:s}})}),!0)}}(this))}return e.prototype.isStorageAndTrackEnabled=function(){return Boolean(this.storage)&&Boolean(this.shouldTrack)},e.prototype.setTag=function(e,t){this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryTags).length>=tn?this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit"):(this.inMemoryTags[e]=t,this.startTimersIfNeeded()))},e.prototype.increment=function(e,t){void 0===t&&(t=1),this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryCounters).length>=tn?this.logger.debug("DiagnosticsClient: Early return increment as reaching memory limit"):(this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+t,this.startTimersIfNeeded()))},e.prototype.recordHistogram=function(e,t){if(this.isStorageAndTrackEnabled())if(Object.keys(this.inMemoryHistograms).length>=tn)this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");else{var n=this.inMemoryHistograms[e];n?(n.count+=1,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.sum+=t):this.inMemoryHistograms[e]={count:1,min:t,max:t,sum:t},this.startTimersIfNeeded()}},e.prototype.recordEvent=function(e,t){this.isStorageAndTrackEnabled()&&(this.inMemoryEvents.length>=10?this.logger.debug("DiagnosticsClient: Early return recordEvent as reaching memory limit"):(this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:t}),this.startTimersIfNeeded()))},e.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||(this.saveTimer=setTimeout((function(){e.saveAllDataToStorage().catch((function(t){e.logger.debug("DiagnosticsClient: Failed to save all data to storage",t)})).finally((function(){e.saveTimer=null}))}),1e3)),this.flushTimer||(this.flushTimer=setTimeout((function(){e._flush().catch((function(t){e.logger.debug("DiagnosticsClient: Failed to flush",t)})).finally((function(){e.flushTimer=null}))}),en))},e.prototype.saveAllDataToStorage=function(){return pe(this,void 0,void 0,(function(){var e,t,n,r;return ge(this,(function(i){switch(i.label){case 0:return this.storage?(e=de({},this.inMemoryTags),t=de({},this.inMemoryCounters),n=de({},this.inMemoryHistograms),r=me([],ve(this.inMemoryEvents),!1),this.inMemoryEvents=[],this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},[4,Promise.all([this.storage.setTags(e),this.storage.incrementCounters(t),this.storage.setHistogramStats(n),this.storage.addEventRecords(r)])]):[2];case 1:return i.sent(),[2]}}))}))},e.prototype._flush=function(){return pe(this,void 0,void 0,(function(){var e,t,n,r,i,o,s,a,c,u;return ge(this,(function(l){switch(l.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return l.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=l.sent(),t=e.tags,n=e.counters,r=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach((function(e){o[e.key]=e.value})),s={},n.forEach((function(e){s[e.key]=e.value})),a={},r.forEach((function(e){a[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}})),c=i.map((function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}})),0===Object.keys(s).length&&0===Object.keys(a).length&&0===c.length?[2]:(u={tags:o,histogram:a,counters:s,events:c},this.fetch(u),[2])}}))}))},e.prototype.fetch=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!Ge())throw new Error("DiagnosticsClient: Fetch is not supported");return[4,fetch(this.serverUrl,{method:"POST",headers:{"X-ApiKey":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return n.sent().ok?(this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3]):(this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2]);case 2:return t=n.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",t),[3,3];case 3:return[2]}}))}))},e.prototype.initializeFlushInterval=function(){return pe(this,void 0,void 0,(function(){var e,t,n;return ge(this,(function(r){switch(r.label){case 0:return this.storage?(e=Date.now(),[4,this.storage.getLastFlushTimestamp()]):[2];case 1:return-1===(t=r.sent()||-1)?(this.storage.setLastFlushTimestamp(e),this._setFlushTimer(en),[2]):(n=e-t)>=en?(this._flush(),[2]):(this._setFlushTimer(en-n),[2])}}))}))},e.prototype._setFlushTimer=function(e){var t=this;this.flushTimer=setTimeout((function(){t._flush().catch((function(e){t.logger.debug("DiagnosticsClient: Failed to flush",e)})).finally((function(){t.flushTimer=null}))}),e)},e.prototype._setSampleRate=function(e){this.logger.debug("DiagnosticsClient: Setting sample rate to",e),this.config.sampleRate=e,this.shouldTrack=Mt(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),rn=function(){function e(){}return e.prototype.send=function(e,t,n){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,i,o,s,a,c,u,l,d,f,p,g,h,v,m,y,b,w,T,k;if("object"!=typeof e)return null;var E=e.code||0,S=this.buildStatus(E);switch(S){case He.Success:return{status:S,statusCode:E,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case He.Invalid:return{status:S,statusCode:E,body:{error:null!==(i=e.error)&&void 0!==i?i:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(s=e.events_with_invalid_fields)&&void 0!==s?s:{},eventsWithMissingFields:null!==(a=e.events_with_missing_fields)&&void 0!==a?a:{},eventsWithInvalidIdLengths:null!==(c=e.events_with_invalid_id_lengths)&&void 0!==c?c:{},epsThreshold:null!==(u=e.eps_threshold)&&void 0!==u?u:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(f=e.silenced_events)&&void 0!==f?f:[],throttledDevices:null!==(p=e.throttled_devices)&&void 0!==p?p:{},throttledEvents:null!==(g=e.throttled_events)&&void 0!==g?g:[]}};case He.PayloadTooLarge:return{status:S,statusCode:E,body:{error:null!==(h=e.error)&&void 0!==h?h:""}};case He.RateLimit:return{status:S,statusCode:E,body:{error:null!==(v=e.error)&&void 0!==v?v:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(w=e.exceeded_daily_quota_devices)&&void 0!==w?w:{},exceededDailyQuotaUsers:null!==(T=e.exceeded_daily_quota_users)&&void 0!==T?T:{},throttledEvents:null!==(k=e.throttled_events)&&void 0!==k?k:[]}};case He.Timeout:default:return{status:S,statusCode:E}}},e.prototype.buildStatus=function(e){return ut(e)?He.Success:429===e?He.RateLimit:413===e?He.PayloadTooLarge:408===e?He.Timeout:e>=400&&e<500?He.Invalid:e>=500?He.Failed:He.Unknown},e}();function on(){return"undefined"!=typeof CompressionStream}function sn(e){return pe(this,void 0,void 0,(function(){var t,n;return ge(this,(function(r){switch(r.label){case 0:if(void 0===(t=CompressionStream))return[2,void 0];r.label=1;case 1:return r.trys.push([1,3,,4]),n=new Blob([e]).stream().pipeThrough(new t("gzip")),[4,new Response(n).arrayBuffer()];case 2:return[2,r.sent()];case 3:return r.sent(),[2,void 0];case 4:return[2]}}))}))}var an=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),cn=401,un=403,ln=429,dn=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new an(e,t)}return e.prototype.subscribe=function(e,t,n){var r=Je(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex((function(t){return t.id===e}));return-1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return pe(this,void 0,void 0,(function(){var e,t=this;return ge(this,(function(n){switch(n.label){case 0:return this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach((function(n){t.sendCallback(n,e,"remote")})),[2]}}))}))},e.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise?this.fetchPromise:this.isLastFetchInvalidApiKey?(this.logger.debug("Remote config client skipping fetch: Invalid API key"),this.fetchPromise=Promise.resolve({remoteConfig:null,lastFetch:new Date}).finally((function(){e.fetchPromise=null})),this.fetchPromise):(this.fetchPromise=this.fetch().then((function(t){return null!==t.remoteConfig&&(e.lastSuccessfulFetch=Date.now()),t})).finally((function(){e.fetchPromise=null})),this.fetchPromise)},e.prototype.subscribeAll=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i=this;return ge(this,(function(o){switch(o.label){case 0:return t=this.getOrCreateFetchPromise().then((function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)})),n=this.storage.fetchConfig().then((function(e){return e})),[4,Promise.race([t,n])];case 1:return void 0!==(r=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),null!==r.remoteConfig?this.sendCallback(e,r,"cache"):this.logger.debug("Remote config client skips sending callback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}}))}))},e.prototype.subscribeWaitForRemote=function(e,t){return pe(this,void 0,void 0,(function(){var n,r;return ge(this,(function(i){switch(i.label){case 0:n=new Promise((function(e,n){setTimeout((function(){n("Timeout exceeded")}),t)})),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}}))}))},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce((function(e,t){return null===e?e:t in e?e[t]:null}),t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),pe(this,void 0,void 0,(function(){var n,r,i,o,s,a,c=this;return ge(this,(function(u){switch(u.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,s,a,u,l,d;return ge(this,(function(f){switch(f.label){case 0:i=!0,s=new AbortController,a=setTimeout((function(){return s.abort()}),t),f.label=1;case 1:return f.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:s.signal})];case 2:return(u=f.sent()).ok?[3,4]:[4,u.text()];case 3:return l=f.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(u.status,": ").concat(l)),u.status===cn||u.status===un?(o.logger.error("Remote config client fetch failed with ".concat(u.status,". Invalid API key; future fetches will be skipped.")),o.isLastFetchInvalidApiKey=!0,i=!1):u.status>=400&&u.status<500&&u.status!==ln&&(i=!1),[3,6];case 4:return[4,u.json()];case 5:return[2,{value:{remoteConfig:f.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(d=f.sent())instanceof Error&&"AbortError"===d.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),d),[3,9];case 8:return clearTimeout(a),[7];case 9:return i?r<e-1?[4,new Promise((function(e){return setTimeout(e,c.getJitterDelay(n))}))]:[3,11]:[2,"break"];case 10:f.sent(),f.label=11;case 11:return[2]}}))},o=this,s=0,u.label=1;case 1:return s<e?[5,i(s)]:[3,4];case 2:if("object"==typeof(a=u.sent()))return[2,a.value];if("break"===a)return[3,4];u.label=3;case 3:return s++,[3,1];case 4:return[2,r]}}))}))},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}(),fn=Ge(),pn=null==fn?void 0:fn.console,gn={},hn={},vn=!1;var mn,yn={addListener:function(e,t){var n,r=(n=e,!!pn&&"function"==typeof pn[n]&&(hn[n]||(hn[n]=pn[n],pn[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{if(gn[n]&&!vn){vn=!0;var r=gn[n];r&&r.forEach((function(t){try{t(n,e)}catch(e){}}))}}catch(e){}return vn=!1,hn[n].apply(pn,e)}),!0));if(!r)return new Error("Console override failed");gn[e]?gn[e].push(t):gn[e]=[t]},removeListener:function(e){var t,n;try{for(var r=he(Object.values(gn)),i=r.next();!i.done;i=r.next())for(var o=i.value,s=o.length-1;s>=0;s--)if(o[s]===e){o.splice(s,1);break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},_restoreConsole:function(){var e,t;try{for(var n=he(Object.entries(hn)),r=n.next();!r.done;r=n.next()){var i=ve(r.value,2),o=i[0],s=i[1];s&&(pn[o]=s)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}hn={},gn={}}};!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(mn||(mn={}));var bn=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],wn="data-amp-track-",Tn=["div","span","h1","h2","h3","h4","h5","h6"],kn=me(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],ve(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),En=kn,Sn=kn,_n=["*"];function In(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e}function Pn(e,t,n){e&&An({json:e,allowlist:t.map(On),excludelist:n.map(On),ancestors:[]})}function An(e){var t,n,r=e.json,i=e.targetObject,o=e.allowlist,s=e.excludelist,a=e.ancestors,c=e.parentObject,u=e.targetKey;i||(i=r);var l=Object.keys(i);try{for(var d=he(l),f=d.next();!f.done;f=d.next()){var p=f.value,g=me(me([],ve(a),!1),[p],!1);In(i[p])?Cn(g,o)&&!Cn(g,s)||delete i[p]:An({json:r,targetObject:i[p],allowlist:o,excludelist:s,ancestors:g,parentObject:i,targetKey:p})}}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}0===Object.keys(i).length&&c&&u&&delete c[u]}function On(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/").map((function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")}))}function xn(e,t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=0),r===t.length)return n===e.length;if(n===e.length){for(;r<t.length&&"**"===t[r];)r++;return r===t.length}var i=t[r];if("**"===i){if(r+1===t.length)return!0;for(var o=n;o<=e.length;o++)if(xn(e,t,o,r+1))return!0;return!1}return("*"===i||i===e[n])&&xn(e,t,n+1,r+1)}function Cn(e,t){return t.some((function(t){return xn(e,t)}))}var Rn=function(){function e(e){this.request=e}return e.prototype.headers=function(e){var t,n;void 0===e&&(e=[]);var r=this.request.headers,i={};if(Array.isArray(r))r.forEach((function(e){var t=ve(e,2),n=t[0],r=t[1];i[n]=r}));else if(r instanceof Headers)r.forEach((function(e,t){i[t]=e}));else if("object"==typeof r&&null!==r)try{for(var o=he(Object.entries(r)),s=o.next();!s.done;s=o.next()){var a=ve(s.value,2),c=a[0],u=a[1];i[c]=u}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Fn(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=Ge();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=Ln(t,100),this._bodySize}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.request.body?this.request.body:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),pe(this,void 0,void 0,(function(){return ge(this,(function(n){return 0===e.length?[2,null]:[2,jn(this.body,e,t)]}))}))},e}(),Dn=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),Fn(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return Ln(this.bodyRaw,100)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.bodyRaw?this.bodyRaw:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),pe(this,void 0,void 0,(function(){return ge(this,(function(n){return 0===e.length?[2,null]:[2,jn(this.body,e,t)]}))}))},e}();function Ln(e,t){var n,r,i,o=Ge(),s=null==o?void 0:o.TextEncoder;if(s){var a;if("string"==typeof e)a=e,i=(new s).encode(a).length;else if(e instanceof Blob)i=(a=e).size;else if(e instanceof URLSearchParams)a=e,i=(new s).encode(a.toString()).length;else if(ArrayBuffer.isView(e))i=(a=e).byteLength;else if(e instanceof ArrayBuffer)i=(a=e).byteLength;else if(e instanceof FormData){var c=e,u=0,l=0;try{for(var d=he(c.entries()),f=d.next();!f.done;f=d.next()){var p=ve(f.value,2),g=p[0],h=p[1];if(u+=g.length,"string"==typeof h)u+=(new s).encode(h).length;else{if(!(h instanceof Blob))return;u+=h.size}if(++l>=t)return}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}i=u}else if(e instanceof ReadableStream)return void(a=e);return i}}var Nn,Un=function(){function e(e){this.response=e}return e.prototype.headers=function(e){var t;if(void 0===e&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,r={};return null===(t=null==n?void 0:n.forEach)||void 0===t||t.call(n,(function(e,t){r[t]=e})),Fn(r,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){var e,t;if(void 0!==this._bodySize)return this._bodySize;var n=null===(t=null===(e=this.response.headers)||void 0===e?void 0:e.get)||void 0===t?void 0:t.call(e,"content-length"),r=n?parseInt(n,10):void 0;return this._bodySize=r,r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),e.prototype.text=function(){return pe(this,void 0,void 0,(function(){var e,t;return ge(this,(function(n){switch(n.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),n.label=1;case 1:return n.trys.push([1,3,,4]),e=this.clonedResponse.text(),t=new Promise((function(e){return setTimeout((function(){return e(null)}),500)})),[4,Promise.race([e,t])];case 2:return[2,n.sent()];case 3:return n.sent(),[2,null];case 4:return[2]}}))}))},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),pe(this,void 0,void 0,(function(){return ge(this,(function(n){switch(n.label){case 0:return 0===e.length?[2,null]:[4,this.text()];case 1:return[2,jn(n.sent(),e,t)]}}))}))},e}(),Mn=function(){function e(e,t,n,r){this.statusCode=e,this.headersString=t,this.size=n,this.getJson=r}return Object.defineProperty(e.prototype,"bodySize",{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),e.prototype.headers=function(e){var t,n;if(void 0===e&&(e=[]),!this.headersString)return{};var r={},i=this.headersString.split("\r\n");try{for(var o=he(i),s=o.next();!s.done;s=o.next()){var a=ve(s.value.split(": "),2),c=a[0],u=a[1];c&&u&&(r[c]=u)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Fn(r,{allow:e})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),pe(this,void 0,void 0,(function(){var n;return ge(this,(function(r){return 0===e.length?[2,null]:(n=this.getJson())?(Pn(n,e,t),[2,n]):[2,null]}))}))},e}();function jn(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return Pn(r,t,n),r}catch(e){return null}}!function(e){e.REDACT="redact",e.REMOVE="remove"}(Nn||(Nn={}));var qn="[REDACTED]",Fn=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,s=t.strategy,a=void 0===s?Nn.REMOVE:s,c=me([],ve(qe),!1),u={},l=function(t){var n=t.toLowerCase();c.find((function(e){return e.toLowerCase()===n}))?a===Nn.REDACT&&(u[t]=qn):o.find((function(e){return e.toLowerCase()===n}))?u[t]=e[t]:a===Nn.REDACT&&(u[t]=qn)};try{for(var d=he(Object.keys(e)),f=d.next();!f.done;f=d.next()){l(f.value)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return u},Bn=function(){function e(e,t,n,r,i,o,s,a,c,u,l){void 0===s&&(s=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=s,this.duration=a,this.responseWrapper=c,this.error=u,this.endTime=l}return e.prototype.toSerializable=function(){var e,t,n,r,i={type:this.type,method:this.method,url:this.url,timestamp:this.timestamp,status:this.status,duration:this.duration,error:this.error,startTime:this.startTime,endTime:this.endTime,requestHeaders:null===(e=this.requestWrapper)||void 0===e?void 0:e.headers(me([],ve(je),!1)),requestBodySize:null===(t=this.requestWrapper)||void 0===t?void 0:t.bodySize,responseHeaders:null===(n=this.responseWrapper)||void 0===n?void 0:n.headers(me([],ve(je),!1)),responseBodySize:null===(r=this.responseWrapper)||void 0===r?void 0:r.bodySize};return Object.fromEntries(Object.entries(i).filter((function(e){var t=ve(e,2);return t[0],void 0!==t[1]})))},e}();var $n=function(e,t){void 0===t&&(t=Je()),this.callback=e,this.id=t};function Hn(e){try{e()}catch(e){}}var Kn=function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=Ge();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=Ge();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,s,a,c,u,l,d;if(this.logger||(this.logger=t),this.eventCallbacks.set(e.id,e),!this.isObserving){var f=null===(i=null===(r=null===(n=this.globalScope)||void 0===n?void 0:n.XMLHttpRequest)||void 0===r?void 0:r.prototype)||void 0===i?void 0:i.open,p=null===(a=null===(s=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===s?void 0:s.prototype)||void 0===a?void 0:a.send,g=null===(l=null===(u=null===(c=this.globalScope)||void 0===c?void 0:c.XMLHttpRequest)||void 0===u?void 0:u.prototype)||void 0===l?void 0:l.setRequestHeader;f&&p&&g&&this.observeXhr(f,p,g);var h=null===(d=this.globalScope)||void 0===d?void 0:d.fetch;h&&this.observeFetch(h),this.isObserving=!0}},e.prototype.unsubscribe=function(e){this.eventCallbacks.delete(e.id)},e.prototype.triggerEventCallbacks=function(e){var t=this;this.eventCallbacks.forEach((function(n){try{n.callback(e)}catch(e){Hn((function(){var n;null===(n=t.logger)||void 0===n||n.debug("an unexpected error occurred while triggering event callbacks",e)}))}}))},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,s){var a;if(void 0!==o&&void 0!==s){var c,u,l,d="GET";if(!function(e){return"object"==typeof e&&null!==e&&"url"in e&&"method"in e}(t)?c=null===(a=null==t?void 0:t.toString)||void 0===a?void 0:a.call(t):(c=t.url,d=t.method),c)try{var f=new URL(c);c="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch(e){}d=(null==n?void 0:n.method)||d,r&&(u=r.status),i&&(l={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},u=0);var p=Math.floor(performance.now()-s),g=Math.floor(o+p),h=new Bn(e,d,o,o,c,n,u,p,r,l,g);this.triggerEventCallbacks(h)}},e.prototype.getTimestamps=function(){var e,t;return{startTime:null===(e=Date.now)||void 0===e?void 0:e.call(Date),durationStart:null===(t=null===performance||void 0===performance?void 0:performance.now)||void 0===t?void 0:t.call(performance)}},e.prototype.observeFetch=function(e){var t=this;this.globalScope&&e&&(this.globalScope.fetch=function(n,r){return pe(t,void 0,void 0,(function(){var t,i,o,s,a=this;return ge(this,(function(c){switch(c.label){case 0:try{t=this.getTimestamps()}catch(e){Hn((function(){var t;return null===(t=a.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while retrieving timestamps",e)}))}c.label=1;case 1:return c.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=c.sent(),[3,4];case 3:return s=c.sent(),o=s,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new Rn(r):void 0,i?new Un(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){Hn((function(){var t;return null===(t=a.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while handling fetch",e)}))}if(i)return[2,i];throw o}}))}))})},e.createXhrJsonParser=function(e,t){return function(){var n;try{if("json"===e.responseType){if(null===(n=t.globalScope)||void 0===n?void 0:n.structuredClone)return t.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(n){return n instanceof Error&&"InvalidStateError"===n.name&&Hn((function(){var n;return null===(n=t.logger)||void 0===n?void 0:n.debug("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))})),null}return null}},e.prototype.observeXhr=function(t,n,r){if(this.globalScope&&t&&n){var i=this.globalScope.XMLHttpRequest.prototype,o=this;i.open=function(){for(var e,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=ve(n,2),s=i[0],a=i[1];try{this.$$AmplitudeAnalyticsEvent=de({method:s,url:null===(e=null==a?void 0:a.toString)||void 0===e?void 0:e.call(a),headers:{}},o.getTimestamps())}catch(e){Hn((function(){var t;return null===(t=o.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while calling xhr open",e)}))}return t.apply(this,n)},i.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,s=e.createXhrJsonParser(this,o),a=t[0],c=i.$$AmplitudeAnalyticsEvent;return i.$$AmplitudeAnalyticsEvent&&i.addEventListener("loadend",(function(){try{var e=i.getAllResponseHeaders(),t=i.getResponseHeader("content-length"),n=new Mn(i.status,e,t?parseInt(t,10):void 0,s),r=i.$$AmplitudeAnalyticsEvent.headers,u=new Dn(a,r);c.status=i.status,o.handleNetworkRequestEvent("xhr",{url:c.url,method:c.method},u,n,void 0,c.startTime,c.durationStart)}catch(e){Hn((function(){var t;return null===(t=o.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while handling xhr send",e)}))}})),n.apply(i,t)},i.setRequestHeader=function(e,t){try{var n=this.$$AmplitudeAnalyticsEvent;n&&(n.headers[e]=t)}catch(e){Hn((function(){var t;return null===(t=o.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while calling xhr setRequestHeader",e)}))}r.apply(this,[e,t])}}},e}(),zn=new Kn,Vn=function(){function e(){}return e.prototype.parse=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return[2,de(de(de(de({},Me),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=Dt();return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=Dt();return(e={})[Ie]=t[Ie],e[Pe]=t[Pe],e[Ae]=t[Ae],e[Oe]=t[Oe],e[xe]=t[xe],e[Ce]=t[Ce],e[Re]=t[Re],e[De]=t[De],e[Le]=t[Le],e[Ne]=t[Ne],e[Ue]=t[Ue],e},e}(),Gn="data-amp-mask",Wn="*****",Jn=/\b(?:\d[ -]*?){13,16}\b/,Yn=/(\d{3}-?\d{2}-?\d{4})/g,Xn=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,Qn=function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var i=e;i=(i=(i=i.replace(Jn,Wn)).replace(Yn,Wn)).replace(Xn,Wn);try{for(var o=he(t),s=o.next();!s.done;s=o.next()){var a=s.value;try{i=i.replace(a,Wn)}catch(e){}}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},Zn=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(Gn)?Wn:e?e(document.title):document.title};function er(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var tr,nr,rr,ir={};function or(){if(tr)return ir;tr=1,Object.defineProperty(ir,"__esModule",{value:!0}),ir.Observable=void 0;const e=e=>Boolean(Symbol[e]),t=t=>e(t)?Symbol[t]:"@@"+t,n=t("iterator"),r=t("observable"),i=t("species");function o(e,t){let n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function s(e){let t=e.constructor;return void 0!==t&&(t=t[i],null===t&&(t=void 0)),void 0!==t?t:g}function a(e){a.log?a.log(e):setTimeout((()=>{throw e}))}function c(e){Promise.resolve().then((()=>{try{e()}catch(e){a(e)}}))}function u(e){let t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{let e=o(t,"unsubscribe");e&&e.call(t)}}catch(e){a(e)}}function l(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function d(e,t,n){e._state="running";let r=e._observer;try{let i=o(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(l(e),!i)throw n;i.call(r,n);break;case"complete":l(e),i&&i.call(r)}}catch(e){a(e)}"closed"===e._state?u(e):"running"===e._state&&(e._state="ready")}function f(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void c((()=>function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let n=0;n<t.length&&(d(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)))):void d(e,t,n);e._queue.push({type:t,value:n})}}class p{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let n=this,r={get closed(){return"closed"===n._state},next(e){f(n,"next",e)},error(e){f(n,"error",e)},complete(){f(n,"complete")}};try{this._cleanup=t.call(void 0,r)}catch(e){r.error(e)}"initializing"===this._state&&(this._state="ready")}get closed(){return"closed"===this._state}unsubscribe(){"closed"!==this._state&&(l(this),u(this))}}class g{constructor(e){if(!(this instanceof g))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof e)throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new p(e,this._subscriber)}forEach(e){return new Promise(((t,n)=>{if("function"!=typeof e)return void n(new TypeError(e+" is not a function"));function r(){i.unsubscribe(),t()}let i=this.subscribe({next(t){try{e(t,r)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t})}))}map(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(s(this))((t=>this.subscribe({next(n){try{n=e(n)}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}})))}filter(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(s(this))((t=>this.subscribe({next(n){try{if(!e(n))return}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}})))}reduce(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=s(this),n=arguments.length>1,r=!1,i=arguments[1];return new t((t=>this.subscribe({next(o){let s=!r;if(r=!0,!s||n)try{i=e(i,o)}catch(e){return t.error(e)}else i=o},error(e){t.error(e)},complete(){if(!r&&!n)return t.error(new TypeError("Cannot reduce an empty sequence"));t.next(i),t.complete()}})))}async all(){let e=[];return await this.forEach((t=>e.push(t))),e}concat(...e){let t=s(this);return new t((n=>{let r,i=0;return function o(s){r=s.subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){i===e.length?(r=void 0,n.complete()):o(t.from(e[i++]))}})}(this),()=>{r&&(r.unsubscribe(),r=void 0)}}))}flatMap(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=s(this);return new t((n=>{let r=[],i=this.subscribe({next(i){if(e)try{i=e(i)}catch(e){return n.error(e)}let s=t.from(i).subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){let e=r.indexOf(s);e>=0&&r.splice(e,1),o()}});r.push(s)},error(e){n.error(e)},complete(){o()}});function o(){i.closed&&0===r.length&&n.complete()}return()=>{r.forEach((e=>e.unsubscribe())),i.unsubscribe()}}))}[r](){return this}static from(t){let i="function"==typeof this?this:g;if(null==t)throw new TypeError(t+" is not an object");let s=o(t,r);if(s){let e=s.call(t);if(Object(e)!==e)throw new TypeError(e+" is not an object");return function(e){return e instanceof g}(e)&&e.constructor===i?e:new i((t=>e.subscribe(t)))}if(e("iterator")&&(s=o(t,n),s))return new i((e=>{c((()=>{if(!e.closed){for(let n of s.call(t))if(e.next(n),e.closed)return;e.complete()}}))}));if(Array.isArray(t))return new i((e=>{c((()=>{if(!e.closed){for(let n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}}))}));throw new TypeError(t+" is not observable")}static of(...e){return new("function"==typeof this?this:g)((t=>{c((()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}}))}))}static get[i](){return this}}return ir.Observable=g,Object.defineProperty(g,Symbol("extensions"),{value:{symbol:r,hostReportError:a},configurable:!0}),ir}var sr=er(rr?nr:(rr=1,nr=or().Observable));function ar(e,t){return new sr((function(n){e.subscribe({next:function(e){t(e).then((function(e){return n.next(e)})).catch((function(e){return n.error(e)}))},error:function(e){n.error(e)},complete:function(){n.complete()}})}))}function cr(e,t){return new sr((function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=he(i),o=n.next();!o.done;o=n.next()){var s=o.value;try{s.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.clear()},s=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),o())},complete:function(){i.delete(t),r||0!==i.size||(n.complete(),o(),r=!0)}});i.add(t)};return s(e),s(t),o}))}function ur(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new sr((function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){var n,r,i;try{for(var o=he(t),s=o.next();!s.done;s=o.next()){var a=s.value;null===(i=a.next)||void 0===i||i.call(a,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){var n,i,o;try{for(var s=he(t),a=s.next();!a.done;a=s.next()){var c=a.value;null===(o=c.error)||void 0===o||o.call(c,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,i;try{for(var o=he(t),s=o.next();!s.done;s=o.next()){var a=s.value;null===(i=a.complete)||void 0===i||i.call(a)}}catch(t){e={error:t}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r()}})),function(){t.delete(i),0===t.size&&n&&(n.unsubscribe(),n=null)}}))}var lr,dr={exports:{}};var fr,pr=function(){if(lr)return dr.exports;lr=1;var e=Object.prototype.hasOwnProperty;function t(e){return"[Throws: "+(e?e.message:"?")+"]"}function n(n){var r=[];return function n(i){if(null===i||"object"!=typeof i)return i;if(-1!==r.indexOf(i))return"[Circular]";if(r.push(i),"function"==typeof i.toJSON)try{var o=n(i.toJSON());return r.pop(),o}catch(e){return t(e)}if(Array.isArray(i)){var s=i.map(n);return r.pop(),s}var a=Object.keys(i).reduce((function(r,o){return r[o]=n(function(n,r){if(e.call(n,r))try{return n[r]}catch(e){return t(e)}return n[r]}(i,o)),r}),{});return r.pop(),a}(n)}return dr.exports=function(e,t,r){return JSON.stringify(n(e),t,r)},dr.exports.ensureProperties=n,dr.exports}(),gr=er(pr),hr=gr||t({__proto__:null,default:gr},[pr]),vr="https://app.amplitude.com",mr={US:vr,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"};var yr="__AMPLITUDE_MESSENGER_INSTANCE__",br="__AMPLITUDE_MESSENGER__",wr=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?vr:t;this[fr]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(i=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===i||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var i="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),o={id:i,action:e,args:t};return new Promise((function(t,s){r.requestCallbacks[i]={resolve:t,reject:s},r.notify(o),n.timeout>0&&setTimeout((function(){s(new Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]}),n.timeout)}))},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.registerActionHandler=function(e,t){var n,r,i,o;this.actionHandlers.has(e)&&(null===(o=null===(i=this.logger)||void 0===i?void 0:i.warn)||void 0===o||o.call(i,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var s=this.pendingMessages.get(e);if(s){this.pendingMessages.delete(e);try{for(var a=he(s),c=a.next();!c.done;c=a.next()){t(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return pe(this,void 0,void 0,(function(){var t,n,r;return ge(this,(function(i){switch(i.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];n=function(e){return document.querySelector('script[src="'.concat(CSS.escape(e),'"]'))?Promise.resolve({status:!0}):new Promise((function(t,n){var r;try{var i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.addEventListener("load",(function(){t({status:!0})}),{once:!0}),i.addEventListener("error",(function(){n({status:!1,message:"Failed to load the script ".concat(e)})})),null===(r=document.head)||void 0===r||r.appendChild(i)}catch(e){n(e)}}))}(e).then((function(){})),this.scriptLoadPromises.set(e,n),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),this.scriptLoadPromises.delete(e),r;case 4:return[2]}}))}))},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{}:e,o=i.logger,s=i.endpoint;o&&(this.logger=o),s&&this.endpoint===vr&&(this.endpoint=s),this.isSetup||(this.isSetup=!0,null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Setting up messenger"),this.messageHandler=function(e){var t,n,i,o,s;if(null===(n=null===(t=r.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message received: ",JSON.stringify(e)),r.endpoint===e.origin){var a=e.data,c=null==a?void 0:a.action;if(c)if("id"in a&&a.id)null===(o=null===(i=r.logger)||void 0===i?void 0:i.debug)||void 0===o||o.call(i,"Received Response to previous request: ",JSON.stringify(e)),r.handleResponse(a);else{if("ping"===c)return void r.notify({action:"pong"});var u=r.actionHandlers.get(c);if(u)u(a.data);else{var l=null!==(s=r.pendingMessages.get(c))&&void 0!==s?s:[];l.push(a.data),r.pendingMessages.set(c,l)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},e.prototype.destroy=function(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.isSetup=!1,this.actionHandlers.clear(),this.pendingMessages.clear(),this.requestCallbacks={},this.scriptLoadPromises.clear();var e=Ge();(null==e?void 0:e[br])===this&&delete e[br]},e}();function Tr(e){var t,n=Ge(),r=null==n?void 0:n[br];if("object"==typeof(t=r)&&null!==t&&yr in t&&!0===t[yr])return r;var i=new wr(e);return n&&(n[br]=i),i}fr=yr;var kr="__AMPLITUDE_BACKGROUND_CAPTURE__";var Er={always:"always",ifEmptyCampaign:"ifEmptyCampaign"},Sr=function(e,t){return"boolean"==typeof e?e:!1!==(null==e?void 0:e[t])},_r=function(e){return Sr(e,"attribution")},Ir=function(e){return Sr(e,"formInteractions")},Pr=function(e){return Sr(e,"pageViews")},Ar=function(e){return Sr(e,"sessions")},Or=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},xr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},Cr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},Rr=function(e){if(xr(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},Dr=function(e){if(Cr(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},Lr=function(e){var t;if(Or(e.autocapture)){var n=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?n=e.autocapture.networkTracking:e.networkTrackingOptions&&(n=e.networkTrackingOptions),de(de({},n),{captureRules:null===(t=null==n?void 0:n.captureRules)||void 0===t?void 0:t.map((function(t){var n,r,i;if((null===(n=t.urls)||void 0===n?void 0:n.length)&&(null===(r=t.hosts)||void 0===r?void 0:r.length)){var o=JSON.stringify(t.hosts),s=JSON.stringify(t.urls);return null===(i=e.loggerProvider)||void 0===i||i.warn("Found network capture rule with both urls='".concat(s,"' and hosts='").concat(o,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),de(de({},t),{hosts:void 0})}return t}))})}},Nr=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return Pr(e.defaultTracking)&&(n=void 0,t=void 0,e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.pageViews&&"object"==typeof e.defaultTracking.pageViews&&("trackOn"in e.defaultTracking.pageViews&&(n=e.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in e.defaultTracking.pageViews&&(r=e.defaultTracking.pageViews.trackHistoryChanges),"eventType"in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(t=e.defaultTracking.pageViews.eventType))),{trackOn:n,trackHistoryChanges:r,eventType:t,pageCounter:i}},Ur=function(e){return _r(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.attribution&&"object"==typeof e.defaultTracking.attribution?de({},e.defaultTracking.attribution):{}},Mr=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.args,s=r.resolve,a=e&&e[i];if("function"==typeof a){var c=a.apply(e,o);"function"==typeof s&&s(null==c?void 0:c.promise)}}return e},jr=function(e){return e&&void 0!==e._q},qr="2.37.2",Fr="amplitude-ts",Br=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(Fr,"/").concat(qr),"undefined"!=typeof navigator&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){var t,n;return pe(this,void 0,void 0,(function(){var r,i,o;return ge(this,(function(s){return r=(new Date).getTime(),i=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1,o=null!==(n=e.event_id)&&void 0!==n?n:i+1,this.config.lastEventId=o,e.time||(this.config.lastEventTime=r),[2,de(de(de(de(de(de(de(de({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:r},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:Rt()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:Je(),partner_id:this.config.partnerId,plan:this.config.plan}),this.config.ingestionMetadata&&{ingestion_metadata:{source_name:this.config.ingestionMetadata.sourceName,source_version:this.config.ingestionMetadata.sourceVersion}}),e),{event_id:o,library:this.library,user_agent:this.userAgent})]}))}))},e}(),$r=1e3,Hr=function(e){function t(t){var n,r,i,o=this;try{i=null===(n=Ge())||void 0===n?void 0:n.localStorage}catch(e){null===(r=null==t?void 0:t.loggerProvider)||void 0===r||r.debug("Failed to access localStorage. error=".concat(JSON.stringify(e))),i=void 0}return(o=e.call(this,i)||this).loggerProvider=null==t?void 0:t.loggerProvider,o}return ce(t,e),t.prototype.set=function(t,n){var r;return pe(this,void 0,void 0,(function(){var i;return ge(this,(function(o){switch(o.label){case 0:return Array.isArray(n)&&n.length>$r?(i=n.length-$r,[4,e.prototype.set.call(this,t,n.slice(0,$r))]):[3,2];case 1:return o.sent(),null===(r=this.loggerProvider)||void 0===r||r.error("Failed to save ".concat(i," events because the queue length exceeded ").concat($r,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))},t}(Ht),Kr=function(e){function t(){var t;return e.call(this,null===(t=Ge())||void 0===t?void 0:t.sessionStorage)||this}return ce(t,e),t}(Ht),zr=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.state={done:4},n.customHeaders=t,n}return ce(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),pe(this,void 0,void 0,(function(){var r=this;return ge(this,(function(i){return[2,new Promise((function(i,o){"undefined"==typeof XMLHttpRequest&&o(new Error("XHRTransport is not supported."));var s=new XMLHttpRequest;s.open("POST",e,!0),s.onreadystatechange=function(){if(s.readyState===r.state.done){var e=s.responseText;try{i(r.buildResponse(JSON.parse(e)))}catch(e){i(r.buildResponse({code:s.status}))}}};var a={"Content-Type":"application/json",Accept:"*/*"},c=JSON.stringify(t),u=n&&c.length>=2048&&on(),l=function(e){var t,n;a=de(de({},r.customHeaders),a);try{for(var i=he(Object.entries(a)),o=i.next();!o.done;o=i.next()){var c=ve(o.value,2),u=c[0],l=c[1];s.setRequestHeader(u,l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}s.send(e)};pe(r,void 0,void 0,(function(){var e;return ge(this,(function(t){switch(t.label){case 0:return u?[4,sn(c)]:[3,2];case 1:return(e=t.sent())?(a["Content-Encoding"]="gzip",l(e)):l(c),[3,3];case 2:l(c),t.label=3;case 3:return[2]}}))})).catch(o)}))]}))}))},t}(rn),Vr=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return ce(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),pe(this,void 0,void 0,(function(){var r,i,o,s,a,c,u;return ge(this,(function(l){switch(l.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return r=JSON.stringify(t),i=n&&r.length>=2048&&on(),o=r,s={"Content-Type":"application/json",Accept:"*/*"},i?[4,sn(r)]:[3,2];case 1:(a=l.sent())&&(s["Content-Encoding"]="gzip",o=a),l.label=2;case 2:return s=de(de({},this.customHeaders),s),[4,fetch(e,{headers:s,body:o,method:"POST"})];case 3:return[4,(c=l.sent()).text()];case 4:u=l.sent();try{return[2,this.buildResponse(JSON.parse(u))]}catch(e){return[2,this.buildResponse({code:c.status})]}return[2]}}))}))},t}(rn),Gr=function(e){function t(){return e.call(this)||this}return ce(t,e),t.prototype.send=function(e,t,n){return pe(this,void 0,void 0,(function(){var n=this;return ge(this,(function(r){return[2,new Promise((function(r,i){var o=Ge();if(!(null==o?void 0:o.navigator.sendBeacon))throw new Error("SendBeaconTransport is not supported");try{var s=JSON.stringify(t);return r(o.navigator.sendBeacon(e,s)?n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:s.length,server_upload_time:Date.now()}):n.buildResponse({code:500}))}catch(e){i(e)}}))]}))}))},t}(rn),Wr=function(e,t,n){return void 0===n&&(n=!0),pe(void 0,void 0,void 0,(function(){var r,i,o,s,a,c,u,l,d;return ge(this,(function(f){switch(f.label){case 0:return r=function(e){return"".concat(be.toLowerCase(),"_").concat(e.substring(0,6))}(e),[4,t.getRaw(r)];case 1:return(i=f.sent())?n?[4,t.remove(r)]:[3,3]:[2,{optOut:!1}];case 2:f.sent(),f.label=3;case 3:return o=ve(i.split("."),6),s=o[0],a=o[1],c=o[2],u=o[3],l=o[4],d=o[5],[2,{deviceId:s,userId:Yr(a),sessionId:Jr(u),lastEventId:Jr(d),lastEventTime:Jr(l),optOut:Boolean(c)}]}}))}))},Jr=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},Yr=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},Xr="[Amplitude]",Qr="".concat(Xr," Form Started"),Zr="".concat(Xr," Form Submitted"),ei="".concat(Xr," File Downloaded"),ti="session_start",ni="session_end",ri="".concat(Xr," File Extension"),ii="".concat(Xr," File Name"),oi="".concat(Xr," Link ID"),si="".concat(Xr," Link Text"),ai="".concat(Xr," Link URL"),ci="".concat(Xr," Form ID"),ui="".concat(Xr," Form Name"),li="".concat(Xr," Form Destination"),di="cookie",fi=Object.freeze({__proto__:null,DEFAULT_ACTION_CLICK_ALLOWLIST:Tn,DEFAULT_CSS_SELECTOR_ALLOWLIST:bn,DEFAULT_DATA_ATTRIBUTE_PREFIX:wn,EXCLUDE_INTERNAL_REFERRERS_CONDITIONS:Er,get IdentifyOperation(){return ue},get LogLevel(){return tt},OfflineDisabled:null,get RevenueProperty(){return ze},get ServerZone(){return mn},get SpecialEventType(){return le}}),pi=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},gi=function(e,t,n,r,i,o){void 0===i&&(i=!0),e.referrer;var s=e.referring_domain,a=fe(e,["referrer","referring_domain"]),c=t||{};c.referrer;var u,l=c.referring_domain,d=fe(c,["referrer","referring_domain"]),f=n.excludeInternalReferrers;if(f){var p=vi(f,r);if(!(p instanceof TypeError)&&e.referring_domain&&wi(e.referring_domain,o)){if("always"===p)return mi(p,e.referring_domain,r),!1;if("ifEmptyCampaign"===p&&(u=de(de({},e),{referring_domain:void 0,referrer:void 0}),Object.values(u).every((function(e){return!e}))))return mi(p,e.referring_domain,r),!1}}if(hi(n.excludeReferrers,e.referring_domain))return r.debug("This is not a new campaign because ".concat(e.referring_domain," is in the exclude referrer list.")),!1;if(!i&&function(e){return Object.values(e).every((function(e){return!e}))}(e)&&t)return r.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var g=JSON.stringify(a)!==JSON.stringify(d),h=pi(s||"")!==pi(l||""),v=!t||g||h;return v?r.debug("This is a new campaign. An $identify event will be sent."):r.debug("This is not a new campaign because it's the same as the previous one."),v},hi=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=""),e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))},vi=function(e,t){if(!0===e)return Er.always;if("object"==typeof e){var n=e.condition;if("string"==typeof n&&Object.keys(Er).includes(n))return n;if(void 0===n)return Er.always}var r="Invalid configuration provided for attribution.excludeInternalReferrers: ".concat(JSON.stringify(e));return t.error(r),new TypeError(r)};function mi(e,t,n){var r="This is not a new campaign because referring_domain=".concat(t," is on the same domain as the current page and it is configured to exclude internal referrers");"always"===e?n.debug(r):"ifEmptyCampaign"===e&&n.debug("".concat(r," with empty campaign parameters"))}var yi=["ac.in","ac.jp","ac.kr","ac.th","ac.uk","ac.za","appspot.com","asn.au","azurewebsites.net","cloudfront.net","myshopify.com","blogspot.com","co.ca","co.in","co.jp","co.kr","co.nz","co.th","co.uk","co.za","com.ar","com.au","com.br","com.cn","com.hk","com.in","com.jp","com.kr","com.mx","com.pl","com.sg","com.tr","com.tw","ed.jp","edu.au","edu.br","edu.cn","edu.hk","edu.sg","edu.th","edu.tr","edu.tw","firebaseapp.com","fly.dev","gc.ca","geek.nz","github.io","gitlab.io","go.jp","go.kr","go.th","gob.ar","gob.mx","gov.au","gov.br","gov.cn","gov.hk","gov.in","gov.pl","gov.sg","gov.tr","gov.tw","gov.uk","gov.za","govt.nz","gr.jp","herokuapp.com","id.au","idv.hk","iwi.nz","lg.jp","ltd.uk","maori.nz","me.uk","mil.kr","ne.jp","ne.kr","net.au","net.br","net.cn","net.hk","net.in","net.nz","net.pl","net.sg","net.tr","net.tw","net.za","onrender.com","or.jp","or.kr","or.th","org.ar","org.au","org.br","org.cn","org.hk","org.in","org.mx","org.nz","org.pl","org.sg","org.tw","org.uk","org.za","pages.dev","pe.kr","plc.uk","re.kr","res.in","sch.uk","vercel.app","netlify.app","workers.dev"],bi=function(e){var t,n,r=e||(null===(n=null===(t=Ge())||void 0===t?void 0:t.location)||void 0===n?void 0:n.hostname);if(!r)return"";var i=r.split("."),o=i[i.length-1],s=i[i.length-2];return yi.find((function(e){return r.endsWith(".".concat(e))}))&&(o=i[i.length-2]+"."+i[i.length-1],s=i[i.length-3]),s?"".concat(s,".").concat(o):o},wi=function(e,t){var n=Ge();if(!n)return!1;var r,i,o,s=(t||"").trim()||bi(n.location.hostname);return r=e,o=(i=s).startsWith(".")?i:".".concat(i),!!(r.startsWith(".")?r:".".concat(r)).endsWith(o)},Ti=function(e){function t(t,n,r,i,o,s,a,c,u,l,d,f,p,g,h,v,m,y,b,w,T,k,E,S,_,I,P,A,O,x,C,R,D,L,N,U,M,j,q,F,B,$,H,K,z){void 0===r&&(r=new jt),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===c&&(c=1e3),void 0===u&&(u=5),void 0===l&&(l=30),void 0===d&&(d=di),void 0===v&&(v=new rt),void 0===m&&(m=tt.Warn),void 0===b&&(b=!1),void 0===w&&(w=!1),void 0===E&&(E=""),void 0===S&&(S="US"),void 0===P&&(P=18e5),void 0===A&&(A=new Hr({loggerProvider:v})),void 0===O&&(O={ipAddress:!0,language:!0,platform:!0}),void 0===x&&(x="fetch"),void 0===C&&(C=!1),void 0===R&&(R=!0),void 0===j&&(j=!0),void 0===q&&(q=0),void 0===H&&(H=!1),void 0===K&&(K=!1);var V,G=this;(G=e.call(this,{apiKey:t,storageProvider:A,transportProvider:Si(x)})||this).apiKey=t,G.appVersion=n,G.cookieOptions=i,G.defaultTracking=o,G.autocapture=s,G.flushIntervalMillis=c,G.flushMaxRetries=u,G.flushQueueSize=l,G.identityStorage=d,G.ingestionMetadata=f,G.instanceName=p,G.loggerProvider=v,G.logLevel=m,G.minIdLength=y,G.offline=b,G.partnerId=T,G.plan=k,G.serverUrl=E,G.serverZone=S,G.sessionTimeout=P,G.storageProvider=A,G.trackingOptions=O,G.transport=x,G.useBatch=C,G.fetchRemoteConfig=R,G.networkTrackingOptions=U,G.identify=M,G.enableDiagnostics=j,G.diagnosticsSampleRate=q,G.diagnosticsClient=F,G.remoteConfig=B,G.topLevelDomain=$,G.enableRequestBodyCompression=H,G._enableRequestBodyCompressionExperimental=K,G.customEnrichment=z,G.version=qr,G._optOut=!1,G._cookieStorage=r,G.deviceId=a,G.lastEventId=g,G.lastEventTime=h,G.optOut=w,G.deferredSessionId=I,G.sessionId=_,G.pageCounter=L,G.userId=D,G.debugLogsEnabled=N,G.loggerProvider.enable(N?tt.Debug:G.logLevel),G.networkTrackingOptions=U,G.identify=M,G.enableDiagnostics=j,G.diagnosticsSampleRate=q,G.diagnosticsClient=F;var W=null!==(V=null==B?void 0:B.fetchRemoteConfig)&&void 0!==V?V:R;return G.remoteConfig=G.remoteConfig||{},G.remoteConfig.fetchRemoteConfig=W,G.fetchRemoteConfig=W,G.topLevelDomain=$||bi(),G}return ce(t,e),Object.defineProperty(t.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceId",{get:function(){return this._deviceId},set:function(e){this._deviceId!==e&&(this._deviceId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userId",{get:function(){return this._userId},set:function(e){this._userId!==e&&(this._userId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sessionId",{get:function(){return this._sessionId},set:function(e){this._sessionId!==e&&(this._sessionId=e,void 0!==e&&void 0!==this._deferredSessionId&&(this._deferredSessionId=void 0),this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deferredSessionId",{get:function(){return this._deferredSessionId},set:function(e){this._deferredSessionId!==e&&e!==this.sessionId&&(this._deferredSessionId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut!==e&&(this._optOut=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(e){this._lastEventTime!==e&&(this._lastEventTime=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(e){this._lastEventId!==e&&(this._lastEventId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(e){this._pageCounter!==e&&(this._pageCounter=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugLogsEnabled",{set:function(e){this._debugLogsEnabled!==e&&(this._debugLogsEnabled=e,this.updateStorage())},enumerable:!1,configurable:!0}),t.prototype.updateStorage=function(){var e={deviceId:this._deviceId,userId:this._userId,sessionId:this._sessionId,deferredSessionId:this._deferredSessionId,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled,cookieDomain:void 0};this.cookieStorage instanceof qt&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(Ct(this.apiKey),e)},t}(ot),ki=function(e,t,n,r,i){return void 0===t&&(t={}),pe(void 0,void 0,void 0,(function(){var o,s,a,c,u,l,d,f,p,g,h,v,m,y,b,w,T,k,E,S,_,I,P,A,O,x,C,R,D,L,N,U,M,j,q,F,B,$,H,K,z,V,G,W,J,Y,X,Q,Z,ee,te;return ge(this,(function(ne){switch(ne.label){case 0:return o=t.identityStorage||di,s="",o!==di||(null===(I=t.cookieOptions)||void 0===I?void 0:I.domain)||""===(null===(P=t.cookieOptions)||void 0===P?void 0:P.domain)?[3,2]:[4,_i(void 0,r)];case 1:s=ne.sent(),ne.label=2;case 2:return a=de({domain:null!==(O=null===(A=t.cookieOptions)||void 0===A?void 0:A.domain)&&void 0!==O?O:s,expiration:365,sameSite:"Lax",secure:!1,upgrade:!0},t.cookieOptions),c={duplicateResolverFn:function(e){var t=Ft(e);if(!t)return!1;var n=JSON.parse(t);return Bt(n.cookieDomain,a.domain)},diagnosticsClient:r},u=Ei(t.identityStorage,a,c),[4,Wr(e,u,null===(C=null===(x=t.cookieOptions)||void 0===x?void 0:x.upgrade)||void 0===C||C)];case 3:return l=ne.sent(),[4,u.get(Ct(e))];case 4:return d=ne.sent(),f=Dt(),p=f.ampTimestamp?Number(f.ampTimestamp):void 0,g=!p||Date.now()<p,h=null!==(U=null!==(N=null!==(L=null!==(R=t.deviceId)&&void 0!==R?R:g?null!==(D=f.ampDeviceId)&&void 0!==D?D:f.deviceId:void 0)&&void 0!==L?L:null==d?void 0:d.deviceId)&&void 0!==N?N:l.deviceId)&&void 0!==U?U:Je(),v=null!==(M=null==d?void 0:d.lastEventId)&&void 0!==M?M:l.lastEventId,m=null!==(j=null==d?void 0:d.lastEventTime)&&void 0!==j?j:l.lastEventTime,y=null!==(F=null!==(q=t.optOut)&&void 0!==q?q:null==d?void 0:d.optOut)&&void 0!==F?F:l.optOut,b=null!==(B=null==d?void 0:d.sessionId)&&void 0!==B?B:l.sessionId,w=null==d?void 0:d.deferredSessionId,T=null!==(H=null!==($=t.userId)&&void 0!==$?$:null==d?void 0:d.userId)&&void 0!==H?H:l.userId,n.previousSessionDeviceId=null!==(K=null==d?void 0:d.deviceId)&&void 0!==K?K:l.deviceId,n.previousSessionUserId=null!==(z=null==d?void 0:d.userId)&&void 0!==z?z:l.userId,k={ipAddress:null===(G=null===(V=t.trackingOptions)||void 0===V?void 0:V.ipAddress)||void 0===G||G,language:null===(J=null===(W=t.trackingOptions)||void 0===W?void 0:W.language)||void 0===J||J,platform:null===(X=null===(Y=t.trackingOptions)||void 0===Y?void 0:Y.platform)||void 0===X||X},E=null==d?void 0:d.pageCounter,S=null==d?void 0:d.debugLogsEnabled,void 0!==t.autocapture&&(t.defaultTracking=t.autocapture),[4,(_=new Ti(e,t.appVersion,u,a,t.defaultTracking,t.autocapture,h,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,o,t.ingestionMetadata,t.instanceName,v,m,null!==(Q=null==i?void 0:i.loggerProvider)&&void 0!==Q?Q:t.loggerProvider,t.logLevel,t.minIdLength,t.offline,y,t.partnerId,t.plan,t.serverUrl,null!==(Z=null==i?void 0:i.serverZone)&&void 0!==Z?Z:t.serverZone,b,w,t.sessionTimeout,t.storageProvider,k,t.transport,t.useBatch,t.fetchRemoteConfig,T,E,S,t.networkTrackingOptions,t.identify,null!==(ee=null==i?void 0:i.enableDiagnostics)&&void 0!==ee?ee:t.enableDiagnostics,null!==(te=null==i?void 0:i.diagnosticsSampleRate)&&void 0!==te?te:n._diagnosticsSampleRate,r,t.remoteConfig,s,t.enableRequestBodyCompression,n._enableRequestBodyCompressionExperimentalValue,t.customEnrichment)).storageProvider.isEnabled()];case 5:return ne.sent()||(_.loggerProvider.warn("Storage provider ".concat(_.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),_.storageProvider=new jt),[2,_]}}))}))},Ei=function(e,t,n){switch(void 0===e&&(e=di),void 0===t&&(t={}),e){case"localStorage":return new Hr;case"sessionStorage":return new Kr;case"none":return new jt;default:return new qt(de(de({},t),{expirationDays:t.expiration}),n)}},Si=function(e){var t="object"==typeof e?e.type:e,n="object"==typeof e?e.headers:void 0;return"xhr"===t?new zr(n):"beacon"===t?new Gr:new Vr(n)},_i=function(e,t){return pe(void 0,void 0,void 0,(function(){var e,n,r,i,o,s,a;return ge(this,(function(c){switch(c.label){case 0:return[4,new qt(void 0,{diagnosticsClient:t}).isEnabled()];case 1:if(!c.sent()||"undefined"==typeof location||!location.hostname)return[2,""];if(e=location.hostname,1===(n=e.split(".")).length)return[2,""];for(r=[],i=1,yi.find((function(t){return e.endsWith(".".concat(t))}))&&(i=2),o=n.length-i-1;o>=0;--o)r.push(n.slice(o).join("."));o=0,c.label=2;case 2:if(!(o<r.length))return[3,7];s=r[o],c.label=3;case 3:return c.trys.push([3,5,,6]),[4,qt.isDomainWritable(s)];case 4:return c.sent()?[2,"."+s]:[3,6];case 5:return a=c.sent(),t&&t.recordEvent("cookies.tld.failure",{reason:"Unexpected exception checking domain is writable: ".concat(s),error:a instanceof Error?a.message:String(a)}),[3,6];case 6:return o++,[3,2];case 7:return t&&t.recordEvent("cookies.tld.failure",{reason:"Could not determine TLD for host ".concat(e)}),[2,""]}}))}))},Ii=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},Pi="AMP_PAGE_VIEW",Ai=function(e){var t;void 0===e&&(e={});var n,r,i=Ge(),o=void 0,s=!1,a=e.trackOn,c=e.trackHistoryChanges,u=e.eventType,l=void 0===u?"[Amplitude] Page Viewed":u,d=function(e){var t=e;try{t=decodeURI(e)}catch(e){null==o||o.error("Malformed URI sequence: ",e)}return t},f=function(e){return pe(void 0,void 0,void 0,(function(){var t,n,r;return ge(this,(function(i){switch(i.label){case 0:return t=d("undefined"!=typeof location&&location.href||""),r={event_type:l},n=[{}],[4,Oi()];case 1:return[2,(r.event_properties=de.apply(void 0,[de.apply(void 0,n.concat([i.sent()])),{"[Amplitude] Page Domain":"undefined"!=typeof location&&location.hostname||"","[Amplitude] Page Location":t,"[Amplitude] Page Path":"undefined"!=typeof location&&d(location.pathname)||"","[Amplitude] Page Title":Zn(Qn),"[Amplitude] Page URL":t.split("?")[0],"[Amplitude] Page View ID":e}]),r)]}}))}))},p=function(){return void 0===a||"function"==typeof a&&a()},g="undefined"!=typeof location?location.href:null,h=function(){pe(void 0,void 0,void 0,(function(){var e,n,i,s,a;return ge(this,(function(u){switch(u.label){case 0:return e=location.href,n=Ci(c,e,g||"")&&p(),g=e,n?(i=void 0,r&&(i=Je(),r.set(Pi,{pageViewId:i})),null==o||o.log("Tracking page view event"),null!=t?[3,1]:[3,3]):[3,4];case 1:return a=(s=t).track,[4,f(i)];case 2:a.apply(s,[u.sent()]),u.label=3;case 3:u.label=4;case 4:return[2]}}))}))},v={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,a){return pe(void 0,void 0,void 0,(function(){var c,u,l;return ge(this,(function(d){switch(d.label){case 0:if(t=a,n=e,(o=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),s=!0,i){try{r=new Ht(i.sessionStorage)}catch(e){null==o||o.debug("sessionStorage is not available in this environment.")}i.addEventListener("popstate",h),i.history.pushState=new Proxy(i.history.pushState,{apply:function(e,t,n){var r=ve(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),s&&h()}})}return p()?(o.log("Tracking page view event"),c=void 0,r&&(c=Je(),r.set(Pi,{pageViewId:c})),l=(u=t).track,[4,f(c)]):[3,2];case 1:l.apply(u,[d.sent()]),d.label=2;case 2:return[2]}}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){var t,i,s;return ge(this,(function(c){switch(c.label){case 0:return"attribution"===a&&xi(e)?(null==o||o.log("Enriching campaign event to page view event with campaign parameters"),t=void 0,r?[4,r.get(Pi)]:[3,2]):[3,4];case 1:i=c.sent(),t=null==i?void 0:i.pageViewId,c.label=2;case 2:return[4,f(t)];case 3:s=c.sent(),e.event_type=s.event_type,e.event_properties=de(de({},e.event_properties),s.event_properties),c.label=4;case 4:return n&&e.event_type===l&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=de(de({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(e){return i&&(i.removeEventListener("popstate",h),s=!1),[2]}))}))}};return v},Oi=function(){return pe(void 0,void 0,void 0,(function(){var e;return ge(this,(function(t){switch(t.label){case 0:return e=Ii,[4,(new Vn).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},xi=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[ue.SET]||{},r=t[ue.UNSET]||{},i=me(me([],ve(Object.keys(n)),!1),ve(Object.keys(r)),!1);return Object.keys(Me).every((function(e){return i.includes(e)}))}return!1},Ci=function(e,t,n){if("pathOnly"===e){if(""==n)return!0;var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname}return t!==n},Ri=function(){var e,t,n=[],r=function(e,t,r){e.addEventListener(t,r),n.push({element:e,type:t,handler:r})};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(n,i){return pe(void 0,void 0,void 0,(function(){var o,s;return ge(this,(function(a){return t=function(e){if(Ir(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&"object"==typeof e.defaultTracking.formInteractions)return e.defaultTracking.formInteractions}(n),o=function(){if(i){if("undefined"!=typeof document){var o=new WeakSet,s=function(e){if(!o.has(e)){o.add(e);var s=!1;r(e,"change",(function(){var t,n=Li(e);s||i.track(Qr,((t={})[ci]=Di(e.id),t[ui]=Di(e.name),t[li]=n,t)),s=!0})),r(e,"submit",(function(r){var o,a,c=Li(e);if(s||i.track(Qr,((o={})[ci]=Di(e.id),o[ui]=Di(e.name),o[li]=c,o)),s=!0,void 0!==(null==t?void 0:t.shouldTrackSubmit))if("function"==typeof t.shouldTrackSubmit&&"undefined"!=typeof SubmitEvent&&r instanceof SubmitEvent)try{if(!t.shouldTrackSubmit(r))return}catch(e){n.loggerProvider.warn("shouldTrackSubmit callback threw an error, proceeding with tracking.")}else n.loggerProvider.warn("shouldTrackSubmit is ignored because it is not a function or event is not a SubmitEvent.");i.track(Zr,((a={})[ci]=Di(e.id),a[ui]=Di(e.name),a[li]=c,a)),s=!1}))}};Array.from(document.getElementsByTagName("form")).forEach(s),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"FORM"===e.nodeName&&s(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("form")).map(s)}))}))}))).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.")},"complete"===document.readyState?o():(s=Ge())?s.addEventListener("load",o):n.loggerProvider.debug("Form interaction tracking is not installed because global is undefined."),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return null==e||e.disconnect(),n.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),n=[],[2]}))}))}}},Di=function(e){if("string"==typeof e)return e},Li=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},Ni=function(){var e,t=[];return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(n,r){return pe(void 0,void 0,void 0,(function(){var i,o;return ge(this,(function(s){return i=function(){if(r){if("undefined"!=typeof document){var i=function(e){var n;try{n=new URL(e.href,window.location.href)}catch(e){return}var i=o.exec(n.href),s=null==i?void 0:i[1];s&&function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})}(e,"click",(function(){var t;s&&r.track(ei,((t={})[ri]=s,t[ii]=n.pathname,t[oi]=e.id,t[si]=e.text,t[ai]=e.href,t))}))},o=/\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)(\?.+)?$/;Array.from(document.getElementsByTagName("a")).forEach(i),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("a")).map(i)}))}))}))).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.")},"complete"===document.readyState?i():(o=Ge())?o.addEventListener("load",i):n.loggerProvider.debug("File download tracking is not installed because global is undefined."),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(n){return null==e||e.disconnect(),t.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),t=[],[2]}))}))}}},Ui=!1,Mi=function(){var e=Ge(),t=[],n=function(n,r){(null==e?void 0:e.addEventListener)&&(null==e||e.addEventListener(n,r),t.push({type:n,handler:r}))};return{name:"@amplitude/plugin-network-checker-browser",type:"before",setup:function(e,t){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(r){return"undefined"==typeof navigator?(e.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),e.offline=!1,[2]):(e.offline=!navigator.onLine,n("online",(function(){e.loggerProvider.debug("Network connectivity changed to online."),e.offline=!1,setTimeout((function(){t.flush()}),e.flushIntervalMillis)})),n("offline",(function(){e.loggerProvider.debug("Network connectivity changed to offline."),e.offline=!0})),[2])}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(n){return t.forEach((function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)})),t=[],[2]}))}))}}};function ji(e){var t,n,r,i,o,s,a,c,u,l,d;if("object"==typeof e&&null!==e&&!Array.isArray(e)){var f=Object.keys(e);try{for(var p=he(f),g=p.next();!g.done;g=p.next()){var h=g.value;try{var v=e[h];"boolean"==typeof(null==v?void 0:v.enabled)&&(v.enabled?(delete v.enabled,0===Object.keys(v).length&&(e[h]=!0)):e[h]=!1),ji(v)}catch(e){}}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}try{if(null===(u=null===(c=null===(a=e.autocapture)||void 0===a?void 0:a.networkTracking)||void 0===c?void 0:c.captureRules)||void 0===u?void 0:u.length)try{for(var m=he(e.autocapture.networkTracking.captureRules),y=m.next();!y.done;y=m.next()){var b=y.value;try{for(var w=(o=void 0,he(["responseHeaders","requestHeaders"])),T=w.next();!T.done;T=w.next()){var k=T.value,E=null!==(l=b[k])&&void 0!==l?l:{},S=E.captureSafeHeaders,_=E.allowlist;(S||_)&&(void 0===_||Array.isArray(_)?b[k]=me(me([],ve(S?je:[]),!1),ve(null!=_?_:[]),!1):delete b[k])}}catch(e){o={error:e}}finally{try{T&&!T.done&&(s=w.return)&&s.call(w)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}}catch(e){}var I=null===(d=e.autocapture)||void 0===d?void 0:d.frustrationInteractions;I&&(I.rageClick&&(I.rageClicks=I.rageClick,delete I.rageClick),I.deadClick&&(I.deadClicks=I.deadClick,delete I.deadClick))}}function qi(e,t,n){var r,i,o=[];try{for(var s=he(null!=t?t:[]),a=s.next();!a.done;a=s.next()){var c=a.value;try{o.push(new RegExp(c))}catch(e){n.loggerProvider.warn("Invalid regex pattern: ".concat(c),e)}}}catch(e){r={error:e}}finally{try{a&&!a.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return e.concat(o)}function Fi(e,t){var n,r,i,o,s,a,c;if(e){ji(e);try{t.loggerProvider.debug("Update browser config with remote configuration:",JSON.stringify(e));var u=e;if(u&&"autocapture"in u){if("boolean"==typeof u.autocapture&&(t.autocapture=u.autocapture),"object"==typeof u.autocapture&&null!==u.autocapture){var l=de({},u.autocapture);if(void 0===t.autocapture&&(t.autocapture=u.autocapture),"object"==typeof u.autocapture.elementInteractions&&null!==u.autocapture.elementInteractions&&(null===(i=u.autocapture.elementInteractions.pageUrlAllowlistRegex)||void 0===i?void 0:i.length)){l.elementInteractions=de({},u.autocapture.elementInteractions);var d=l.elementInteractions,f=null!==(o=d.pageUrlAllowlist)&&void 0!==o?o:[],p=u.autocapture.elementInteractions.pageUrlAllowlistRegex;d.pageUrlAllowlist=qi(f,p,t),delete d.pageUrlAllowlistRegex}if("object"==typeof u.autocapture.networkTracking&&null!==u.autocapture.networkTracking&&(null===(s=u.autocapture.networkTracking.captureRules)||void 0===s?void 0:s.length)){l.networkTracking=de({},u.autocapture.networkTracking);var g=null!==(a=l.networkTracking.captureRules)&&void 0!==a?a:[];try{for(var h=he(g),v=h.next();!v.done;v=h.next()){var m=v.value;m.urls=qi(null!==(c=m.urls)&&void 0!==c?c:[],m.urlsRegex,t),delete m.urlsRegex}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}}"boolean"==typeof t.autocapture&&(t.autocapture=de({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},l)),"object"==typeof t.autocapture&&(t.autocapture=de(de({},t.autocapture),l))}t.defaultTracking=t.autocapture}"customEnrichment"in u&&null!==u.customEnrichment&&(t.customEnrichment=u.customEnrichment),t.loggerProvider.debug("Browser config after remote config update:",JSON.stringify(t))}catch(e){t.loggerProvider.error("Failed to apply remote configuration because of error: ",e)}}}var Bi,$i="1.24.2",Hi="[Amplitude] Element Clicked",Ki="[Amplitude] Element Tag",zi="[Amplitude] Element Text",Vi="[Amplitude] Page URL",Gi="[Amplitude] Viewport Height",Wi="[Amplitude] Viewport Width",Ji="[Amplitude] Page View ID",Yi="data-amp-mask-attributes",Xi=["input","select","textarea"],Qi=function(e,t){var n,r=null===(n=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===n?void 0:n.call(window,e);return"pointer"===(null==r?void 0:r.getPropertyValue("cursor"))&&"click"===t},Zi=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&Nt(window.location.href,n))&&!!Nt(window.location.href,t)},eo=function(e,t,n){return void 0===n&&(n=!1),function(r,i){var o,s,a=e.shouldTrackEventResolver,c=null===(s=null===(o=null==i?void 0:i.tagName)||void 0===o?void 0:o.toLowerCase)||void 0===s?void 0:s.call(o);if(!c)return!1;if(a)return a(r,i);if(!Zi(e))return!1;var u=String(null==i?void 0:i.getAttribute("type"))||"";if("string"==typeof u)switch(u.toLowerCase()){case"hidden":case"password":return!1}var l=Qi(i,r);if(n&&l)return!0;if(t){var d=t.some((function(e){var t;return!!(null===(t=null==i?void 0:i.matches)||void 0===t?void 0:t.call(i,e))}));if(!d)return!1}switch(c){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:return!!l||"click"===r}}},to=function(e){return Object.keys(e).reduce((function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t}),{})},no=function(){var e;try{var t=Ge(),n=null===(e=null==t?void 0:t.sessionStorage)||void 0===e?void 0:e.getItem("AMP_PAGE_VIEW");if(!n)return;var r=JSON.parse(n);if("string"==typeof r.pageViewId)return r.pageViewId}catch(e){}},ro=function(e,t){return e?t.some((function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))?e:ro(null==e?void 0:e.parentElement,t):null},io=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};!function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",e[e.MIDDLE=1]="MIDDLE",e[e.RIGHT=2]="RIGHT"}(Bi||(Bi={}));var oo="__AMPLITUDE_VISUAL_TAGGING__";var so=Ge(),ao=function(){return new sr((function(e){var t=new MutationObserver((function(t){e.next(t)}));return document.body&&t.observe(document.body,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),function(){return t.disconnect()}}))},co=function(e){return void 0===e&&(e="click"),new sr((function(t){var n,r=function(e){t.next(e)};return null===(n=Ge())||void 0===n||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null===(t=Ge())||void 0===t||t.document.removeEventListener(e,r,{capture:!0})}}))},uo=function(){var e=cr(new sr((function(e){var t=function(t){if(t instanceof ErrorEvent){var n={kind:"error"};t.error instanceof Error||t.error instanceof DOMException?n=de(de({},n),{message:t.error.message,stack:t.error.stack,filename:t.filename,lineNumber:t.lineno,columnNumber:t.colno}):"string"==typeof t.error&&(n.message=t.error),e.next(n)}};return so.addEventListener("error",t),function(){so.removeEventListener("error",t)}})),new sr((function(e){var t=function(t){var n={kind:"unhandledrejection"};t.reason instanceof Error||t.reason instanceof DOMException?(n.message=t.reason.message,n.stack=t.reason.stack):"string"==typeof t.reason&&(n.message=t.reason),e.next(n)};return so.addEventListener("unhandledrejection",t),function(){so.removeEventListener("unhandledrejection",t)}})));return cr(e,new sr((function(e){var t=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=void 0;Array.isArray(n[0])&&"string"==typeof n[0][0]&&(i=n[0][0]),e.next({kind:"console",message:i})};return yn.addListener("error",t),function(){yn.removeListener(t)}})))},lo=function(e,t,n){e.forEach((function(e){if("string"!=typeof e&&"ATTACH_EVENT_PROPERTY"===e.actionType){var r=n.extractDataFromDataSource(e.dataSource,t.closestTrackedAncestor);t.targetElementProperties[e.destinationKey]=r}}))},fo={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},po=function(e){var t,n,r,i,o=Object.values(fo).reduce((function(e,t){return e[t]=new Set,e}),{});if(!e)return o;try{for(var s=he(e),a=s.next();!a.done;a=s.next()){var c=a.value;try{try{for(var u=(r=void 0,he(c.definition)),l=u.next();!l.done;l=u.next()){var d=l.value,f=fo[d.event_type];f&&o[f].add(c.id)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==c?void 0:c.id,e)}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},go=function(e){var t,n,r,i,o=new Map;try{for(var s=he(e),a=s.next();!a.done;a=s.next()){var c=a.value;try{for(var u=(r=void 0,he(c.conditions)),l=u.next();!l.done;l=u.next()){var d=l.value;if("LABELED_EVENT"===d.type){var f=d.match.eventId,p=o.get(f);p||(p=[],o.set(f,p)),p.push(c)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return o},ho=function(e,t){return t.filter((function(t){return t.definition.some((function(t){return fo[t.event_type]===e.type&&t.filters.every((function(t){return function(e,t){try{if("[Amplitude] Element Text"===t.subprop_key)return"is"===t.subprop_op&&t.subprop_value.includes(e.targetElementProperties["[Amplitude] Element Text"]);if("[Amplitude] Element Hierarchy"===t.subprop_key)return"autotrack css match"===t.subprop_op&&!!e.closestTrackedAncestor.closest(t.subprop_value.toString())}catch(e){return console.error("Error matching event to filter",e),!1}return!1}(e,t)}))}))}))},vo=function(){function e(e,t,n,r){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.dataExtractor=n,this.options=r}return e.prototype.evaluate=function(e){var t,n,r=this.options.pageActions;if(!r)return e;var i=function(e,t){var n,r,i,o,s=new Set;try{for(var a=he(e),c=a.next();!c.done;c=a.next()){var u=c.value,l=t.get(u.id);if(l)try{for(var d=(i=void 0,he(l)),f=d.next();!f.done;f=d.next()){var p=f.value;s.add(p)}}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(n)throw n.error}}return Array.from(s)}(ho(e,Array.from(this.groupedLabeledEvents[e.type]).map((function(e){return r.labeledEvents[e]}))),this.labeledEventToTriggerMap);try{for(var o=he(i),s=o.next();!s.done;s=o.next()){var a=s.value;lo(a.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return e},e.prototype.update=function(e,t,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.options=n},e}(),mo=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",Yi,Gn]),yo=["type"],bo=["svg","path","g"],wo=["password","hidden"];function To(e,t){var n,r,i,o,s,a;if(null===e)return null;var c=String(e.tagName).toLowerCase(),u={tag:c},l=Array.from(null!==(o=null===(i=e.parentElement)||void 0===i?void 0:i.children)&&void 0!==o?o:[]);l.length&&(u.index=l.indexOf(e),u.indexOfType=l.filter((function(t){return t.tagName===e.tagName})).indexOf(e));var d=null===(a=null===(s=e.previousElementSibling)||void 0===s?void 0:s.tagName)||void 0===a?void 0:a.toLowerCase();d&&(u.prevSib=String(d));var f=e.getAttribute("id");f&&(u.id=String(f));var p=Array.from(e.classList);p.length&&(u.classes=p);var g={},h=Array.from(e.attributes).filter((function(e){return!mo.has(e.name)})),v=!function(e){var t,n,r,i=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o=e instanceof HTMLElement&&"true"===(null===(r=e.getAttribute("contenteditable"))||void 0===r?void 0:r.toLowerCase());return!Xi.includes(i)&&!o}(e);if(!wo.includes(String(e.getAttribute("type")))&&!bo.includes(c))try{for(var m=he(h),y=m.next();!y.done;y=m.next()){var b=y.value;v&&!yo.includes(b.name)||(t.has(b.name)?g[b.name]=Wn:g[b.name]=String(b.value).substring(0,128))}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return Object.keys(g).length&&(u.attrs=g),u}var ko,Eo=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),So=function(e,t,n){var r,i;if(e.nodeType!==Node.ELEMENT_NODE)return null;var o=e.getAttribute("id");if(t){if(o)return new Eo(l(o),!0);var s=e.tagName.toLowerCase();if("body"===s||"head"===s||"html"===s)return new Eo(s,!0)}var a=e.tagName.toLowerCase();if(o)return new Eo(a+l(o),!0);var c=e.parentNode;if(!c||c.nodeType===Node.DOCUMENT_NODE)return new Eo(a,!0);function u(e){var t=e.getAttribute("class");return t?t.split(/\s+/g).filter(Boolean).map((function(e){return"$"+e})):[]}function l(e){return"#"+CSS.escape(e)}for(var d=u(e),f=!1,p=!1,g=-1,h=-1,v=c.children,m=0;v&&(-1===g||!p)&&m<v.length;++m){var y=v[m];if(y.nodeType===Node.ELEMENT_NODE)if(h+=1,y!==e){if(!p&&y.tagName.toLowerCase()===a){f=!0;var b=new Set(d);if(b.size)for(var w=u(y),T=0;T<w.length;++T){var k=w[T];if(b.has(k)&&(b.delete(k),!b.size)){p=!0;break}}else p=!0}}else g=h}var E=a;if(n&&"input"===a.toLowerCase()&&e.getAttribute("type")&&!e.getAttribute("id")&&!e.getAttribute("class")&&(E+="[type="+CSS.escape(e.getAttribute("type")||"")+"]"),p)E+=":nth-child("+String(g+1)+")";else if(f)try{for(var S=he(d),_=S.next();!_.done;_=S.next()){var I=_.value;E+="."+CSS.escape(I.slice(1))}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=S.return)&&i.call(S)}finally{if(r)throw r.error}}return new Eo(E,!1)},_o=function(e,t){var n,r,i,o=this;this.replaceSensitiveString=function(e){return Qn(e,o.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,i,s,a=performance.now();if(!e)return[];for(var c,u=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),l=new Map,d=u.length-1;d>=0;d--){var f=u[d];if(f){var p=(c=f.getAttribute(Yi))?c.split(",").map((function(e){return e.trim()})).filter((function(e){return e.length>0&&"id"!==e&&"class"!==e})):[],g=d===u.length-1?[]:null!==(r=l.get(u[d+1]))&&void 0!==r?r:new Set,h=new Set(me(me([],ve(g),!1),ve(p),!1));l.set(f,h)}}s=u.map((function(e){var t;return To(e,null!==(t=l.get(e))&&void 0!==t?t:new Set)}));var v=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach((function(t){var n=ve(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=o.replaceSensitiveString(i))}))};try{for(var m=he(s),y=m.next();!y.done;y=m.next())v(y.value)}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}var b=performance.now();return null===(i=o.diagnosticsClient)||void 0===i||i.recordHistogram("autocapturePlugin.getHierarchy",b-a),s},this.getNearestLabel=function(e){var t,n=e.parentElement;if(!n)return"";try{t=n.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(e){t=null}return t?o.getText(t):o.getNearestLabel(n)},this.getElementPath=function(e){var t;if(!e)return"";var n=performance.now(),r=function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"";for(var n=[],r=e;r;){var i=So(r,Boolean(t),r===e);if(!i)break;if(n.push(i),i.optimized)break;r=r.parentElement}return n.reverse(),n.join(" > ")}(e),i=performance.now();return null===(t=o.diagnosticsClient)||void 0===t||t.recordHistogram("autocapturePlugin.getElementPath",i-n),r},this.getEventProperties=function(e,t,n){var r,i,s,a,c,u,l=null===(s=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===s?void 0:s.call(i),d="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},f=o.getHierarchy(t),p=null===(a=f[0])||void 0===a?void 0:a.attrs,g=o.getNearestLabel(t),h=(c=null!=p?p:{},u=n,Object.entries(c).reduce((function(e,t){var n=ve(t,2),r=n[0],i=n[1];if(r.startsWith(u)){var o=r.replace(u,"");o&&(e[o]=i||"")}return e}),{})),v=((r={})["[Amplitude] Element Hierarchy"]=f,r[Ki]=l,r[zi]=o.getText(t),r["[Amplitude] Element Position Left"]=null==d.left?null:Math.round(d.left),r["[Amplitude] Element Position Top"]=null==d.top?null:Math.round(d.top),r["[Amplitude] Element Attributes"]=h,r["[Amplitude] Element Path"]=o.getElementPath(t),r["[Amplitude] Element Parent Label"]=g,r[Vi]=Ut(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=Zn(o.replaceSensitiveString),r[Gi]=window.innerHeight,r[Wi]=window.innerWidth,r),m=no();if(m&&(v[Ji]=m),v["[Amplitude] Element ID"]=t.getAttribute("id")||"",v["[Amplitude] Element Class"]=t.getAttribute("class"),v["[Amplitude] Element Aria Label"]=null==p?void 0:p["aria-label"],"a"===l&&"click"===e&&t instanceof HTMLAnchorElement){var y=t.href.substring(0,128);v["[Amplitude] Element Href"]=o.replaceSensitiveString(y)}return to(v)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var s=o.addTypeAndTimestamp(e,t);if(function(e){return"click"===e.type||"change"===e.type}(s)&&null!==s.event.target){if(i&&Qi(s.event.target,s.type))return s.closestTrackedAncestor=s.event.target,s.targetElementProperties=o.getEventProperties(s.type,s.closestTrackedAncestor,r),s;var a=ro(s.event.target,n);return a&&(s.closestTrackedAncestor=a,s.targetElementProperties=o.getEventProperties(s.type,a,r)),s}return s},this.extractDataFromDataSource=function(e,t){if("DOM_ELEMENT"===e.sourceType){var n=function(e,t){try{if("DOM_ELEMENT"===e.sourceType){var n=document.documentElement;return e.scope&&t&&(n=t.closest(e.scope)),n&&e.selector?n.querySelector(e.selector):n}}catch(e){return}}(e,t);if(!n)return;return"TEXT"===e.elementExtractType?o.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getTextWithMaskedDescendants=function(e){var t,n,r="[".concat(Gn,"], [contenteditable]");if(!e.querySelector(r))return e.innerText;var i="",s=Array.from(e.childNodes);try{for(var a=he(s),c=a.next();!c.done;c=a.next()){var u=c.value;u.nodeType!==Node.TEXT_NODE?u instanceof Element&&(u.hasAttribute(Gn)||u.hasAttribute("contenteditable")?i+=Wn:i+=o.getTextWithMaskedDescendants(u)):i+=u.textContent||""}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return i},this.getText=function(e){if(null!==e.closest("[".concat(Gn,"]")))return Wn;var t="";return t=e.querySelector("[".concat(Gn,"], [contenteditable]"))?o.getTextWithMaskedDescendants(e):e.innerText||"",o.replaceSensitiveString(t.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(e){var t,n,r;if(!e)return{};var i=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n),s=((t={})[Ki]=i,t[zi]=o.getText(e),t[Vi]=window.location.href.split("?")[0],t);return to(s)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient;var s=null!==(i=e.maskTextRegex)&&void 0!==i?i:[],a=[];try{for(var c=he(s),u=c.next();!u.done;u=c.next()){var l=u.value;if(a.length>=25)break;if(l instanceof RegExp)a.push(l);else if("pattern"in l&&"string"==typeof l.pattern)try{a.push(new RegExp(l.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=a};!function(e){e.ClickObservable="clickObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable",e.ScrollObservable="scrollObservable",e.ExposureObservable="exposureObservable",e.BrowserErrorObservable="browserErrorObservable",e.SelectionObservable="selectionObservable",e.MouseMoveObservable="mouseMoveObservable"}(ko||(ko={}));var Io=function(e,t){var n,r,i,o,s,a,c,u,l,d,f;void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",$i);var p=e.dataAttributePrefix,g=void 0===p?wn:p,h=e.visualTaggingOptions,v=void 0===h?{enabled:!0}:h;e.cssSelectorAllowlist=null!==(n=e.cssSelectorAllowlist)&&void 0!==n?n:bn,e.actionClickAllowlist=null!==(r=e.actionClickAllowlist)&&void 0!==r?r:Tn,e.debounceTime=null!==(i=e.debounceTime)&&void 0!==i?i:0;var m=null!==(a=null!==(s=null===(o=e.viewportContentUpdated)||void 0===o?void 0:o.exposureDuration)&&void 0!==s?s:e.exposureDuration)&&void 0!==a?a:150;e.viewportContentUpdated=de(de({},e.viewportContentUpdated),{exposureDuration:m}),e.pageUrlExcludelist=null===(c=e.pageUrlExcludelist)||void 0===c?void 0:c.reduce((function(e,t){if("string"==typeof t&&e.push(t),t instanceof RegExp&&e.push(t),"object"==typeof t&&null!==t&&"pattern"in t)try{e.push(new RegExp(t.pattern))}catch(n){return console.warn("Invalid regex pattern: ".concat(t.pattern),n),e}return e}),[]);var y,b="@amplitude/plugin-autocapture-browser",w=[],T=new _o(e,t),k=new Set,E=new Set,S=function(){var t,n,r=ur(co().map((function(t){return T.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,g)}))),i=ur(new sr((function(t){var n,r=function(n){var r=T.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,g);t.next(r)};return null===(n=Ge())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=Ge())||void 0===e?void 0:e.document.removeEventListener("change",r)}})));window.navigation&&(n=ur(new sr((function(t){var n=function(n){var r=T.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,g);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}}))));var o=ur(ao().map((function(t){return T.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,g)}))),s=new sr((function(e){var t,n=function(t){e.next(t)};return null===(t=Ge())||void 0===t||t.addEventListener("scroll",n),function(){var e;null===(e=Ge())||void 0===e||e.removeEventListener("scroll",n)}})),a=function(e,t){return new sr((function(n){var r,i=Ge();if(!(null==i?void 0:i.IntersectionObserver))return function(){};var o=new IntersectionObserver((function(e){e.forEach((function(e){n.next(e)}))}),{root:null,rootMargin:"0px",threshold:1}),s=t.join(",");(null!==(r=null==i?void 0:i.document.querySelectorAll(s))&&void 0!==r?r:[]).forEach((function(e){o.observe(e)}));var a=e.subscribe((function(e){return e.event.forEach((function(e){return e.addedNodes.forEach((function(e){e instanceof Element&&(e.matches(s)&&o.observe(e),e.querySelectorAll(s).forEach((function(e){o.observe(e)})))}))}))}));return function(){a.unsubscribe(),o.disconnect()}}))}(o,e.cssSelectorAllowlist);return(t={})[ko.ChangeObservable]=i,t[ko.ClickObservable]=r,t[ko.MutationObservable]=o,t[ko.NavigateObservable]=n,t[ko.ScrollObservable]=s,t[ko.ExposureObservable]=a,t},_=po(Object.values(null!==(l=null===(u=e.pageActions)||void 0===u?void 0:u.labeledEvents)&&void 0!==l?l:{})),I=go(null!==(f=null===(d=e.pageActions)||void 0===d?void 0:d.triggers)&&void 0!==f?f:[]),P=function(e,t,n,r){return new vo(e,t,n,r)}(_,I,T,e);return{name:b,type:"enrichment",setup:function(t,n){return pe(void 0,void 0,void 0,(function(){var r,i,o,s,a,c,u,l,d,f,p,h,A,O,x,C,R,D,L,N,U;return ge(this,(function(M){return"undefined"==typeof document||(r=!1,i={maxX:void 0,maxY:void 0},t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",(function(t){!function(t){var n,r;t&&(e.pageActions=de(de({},e.pageActions),t),_=po(Object.values(null!==(n=e.pageActions.labeledEvents)&&void 0!==n?n:{})),I=go(null!==(r=e.pageActions.triggers)&&void 0!==r?r:[]),P.update(_,I,e))}(t)})):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),o=eo(e,e.cssSelectorAllowlist),s=eo(e,e.actionClickAllowlist),a=S(),c=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(io).filter((function(e){return r("click",e.closestTrackedAncestor)})).map((function(e){return i(e)})).subscribe((function(e){null==t||t.track(Hi,e.targetElementProperties)}))}({allObservables:a,amplitude:n,shouldTrackEvent:o,evaluateTriggers:P.evaluate.bind(P)}),w.push(c),u=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,o=e.evaluateTriggers;return n.changeObservable.filter(io).filter((function(e){return i("change",e.closestTrackedAncestor)})).map((function(e){return o(e)})).subscribe((function(e){null==t||t.track("[Amplitude] Element Changed",r("change",e.closestTrackedAncestor))}))}({allObservables:a,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return T.getEventProperties.apply(T,me(me([],ve(e),!1),[g],!1))},amplitude:n,shouldTrackEvent:o,evaluateTriggers:P.evaluate.bind(P)}),w.push(u),l=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,s=e.shouldTrackActionClick,a=n.clickObservable,c=n.mutationObservable,u=n.navigateObservable,l=a.filter((function(e){return!o("click",e.closestTrackedAncestor)})).map((function(e){var t=ro(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e})).filter(io).filter((function(e){return s("click",e.closestTrackedAncestor)})),d=u?cr(c,u):c,f=cr(l,d),p=null,g=null;return ar(f,(function(e){if(p&&(clearTimeout(p),p=null),"click"===e.type)return g=e,p=setTimeout((function(){p=null,g=null}),500),Promise.resolve(null);if(g){var t=g;return g=null,Promise.resolve(t)}return Promise.resolve(null)})).subscribe((function(e){e&&(null==t||t.track(Hi,i("click",e.closestTrackedAncestor)))}))}({allObservables:a,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return T.getEventProperties.apply(T,me(me([],ve(e),!1),[g],!1))},amplitude:n,shouldTrackEvent:o,shouldTrackActionClick:s}),l&&w.push(l),d=function(e){var t=e.allObservables.scrollObservable,n={maxX:0,maxY:0},r=t.subscribe((function(){var e,t,r,i,o=Ge(),s=Math.floor(null!==(t=null!==(e=null==o?void 0:o.scrollX)&&void 0!==e?e:null==o?void 0:o.pageXOffset)&&void 0!==t?t:0),a=Math.floor(null!==(i=null!==(r=null==o?void 0:o.scrollY)&&void 0!==r?r:null==o?void 0:o.pageYOffset)&&void 0!==i?i:0);n.maxX=Math.max(n.maxX,s),n.maxY=Math.max(n.maxY,a)}));return{unsubscribe:function(){r.unsubscribe()},getState:function(){return n},reset:function(){n.maxX=0,n.maxY=0}}}({allObservables:a}),w.push(d),f={},p=Ge(),h=function(e){e&&r||(setTimeout((function(){r=!1}),100),r=!0,function(e){var t,n,r,i,o=e.amplitude,s=e.scrollTracker,a=e.currentElementExposed,c=e.elementExposedForPage,u=e.exposureTracker,l=e.isPageEnd,d=e.lastScroll,f=s.getState(),p=Ge(),g=null!==(n=null==p?void 0:p.innerWidth)&&void 0!==n?n:0,h=null!==(r=null==p?void 0:p.innerHeight)&&void 0!==r?r:0,v=((t={})[Vi]=null===(i=null==p?void 0:p.location)||void 0===i?void 0:i.href,t["[Amplitude] Max Page X"]=f.maxX+g,t["[Amplitude] Max Page Y"]=f.maxY+h,t[Gi]=h,t[Wi]=g,t["[Amplitude] Element Exposed"]=Array.from(a),t),m=no();m&&(v[Ji]=m),0!==a.size||f.maxX!==d.maxX||f.maxY!==d.maxY?(null==o||o.track("[Amplitude] Viewport Content Updated",v),d.maxX=f.maxX,d.maxY=f.maxY,a.clear(),l&&(s.reset(),c.clear(),null==u||u.reset())):l&&(s.reset(),c.clear(),null==u||u.reset())}({amplitude:n,scrollTracker:d,currentElementExposed:E,elementExposedForPage:k,exposureTracker:f.exposure,isPageEnd:e,lastScroll:i}))},A=function(e){!function(e,t,n,r){if(!t.has(e)){t.add(e),n.add(e);var i=Array.from(n);JSON.stringify(i).length>=18e3&&r(!1)}}(e,k,E,h)},f.exposure=function(e){var t=e.allObservables,n=e.onExposure,r=e.dataExtractor,i=e.exposureDuration,o=void 0===i?150:i,s=new Map,a=new Map,c=t.exposureObservable.subscribe((function(e){var t=e,i=t.target;if(t.isIntersecting){if(!s.get(i)){var c=setTimeout((function(){s.set(i,!0);var e=r.getElementPath(i);n(e),a.set(i,null)}),o);a.set(i,c)}}else!t.isIntersecting&&t.intersectionRatio<1&&(c=a.get(i))&&(clearTimeout(c),a.set(i,null))}));return{unsubscribe:function(){c.unsubscribe()},reset:function(){a.forEach((function(e){e&&clearTimeout(e)})),a.clear(),s.clear()}}}({allObservables:a,onExposure:A,dataExtractor:T,exposureDuration:m}),f.exposure&&w.push(f.exposure),O=function(){h(!0)},null==p||p.addEventListener("beforeunload",O),y=function(){null==p||p.removeEventListener("beforeunload",O)},w.push({unsubscribe:function(){return y()}}),(x=a[ko.NavigateObservable])?w.push(x.subscribe((function(){h(!0)}))):p&&(C=function(){h(!0)},p.addEventListener("popstate",C),R=p.history.pushState,p.history&&R&&(p.history.pushState=new Proxy(R,{apply:function(e,t,n){var r=ve(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),h(!0)}})),w.push({unsubscribe:function(){p.removeEventListener("popstate",C),p.history&&R&&(p.history.pushState=R)}})),null===(U=null==t?void 0:t.loggerProvider)||void 0===U||U.log("".concat(b," has been successfully added.")),window.opener&&v.enabled&&(D=e.cssSelectorAllowlist,L=e.actionClickAllowlist,function(e,t){var n=e;if(!0!==n[oo]){n[oo]=!0;var r=t.dataExtractor,i=t.isElementSelectable,o=t.cssSelectorAllowlist,s=t.actionClickAllowlist,a=null,c=function(t){e.notify({action:"element-selected",data:t})},u=function(t,n){"selector-mode-changed"===t?e.notify({action:"track-selector-mode-changed",data:n}):"selector-moved"===t&&e.notify({action:"track-selector-moved",data:n})};e.registerActionHandler("initialize-visual-tagging-selector",(function(t){e.loadScriptOnce("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz").then((function(){var n;a=null===(n=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===n?void 0:n.call(window,{getEventTagProps:r.getEventTagProps,isElementSelectable:function(e){return!i||i((null==t?void 0:t.actionType)||"click",e)},onTrack:u,onSelect:c,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:e,cssSelectorAllowlist:o,actionClickAllowlist:s,extractDataFromDataSource:r.extractDataFromDataSource,dataExtractor:r,diagnostics:{autocapture:{version:$i}}}),e.notify({action:"selector-loaded"})})).catch((function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize visual tagging selector")}))})),e.registerActionHandler("close-visual-tagging-selector",(function(){var e;null===(e=null==a?void 0:a.close)||void 0===e||e.call(a)}))}}(N=Tr(),{dataExtractor:T,isElementSelectable:eo(e,me(me([],ve(D),!1),ve(L),!1)),cssSelectorAllowlist:D,actionClickAllowlist:L}),function(e){var t=e;if(!0!==t[kr]){t[kr]=!0;var n="https://cdn.amplitude.com/libs/background-capture-1.0.0-alpha.3.js.gz",r=null,i=function(t,n){var r,i;"background-capture-complete"===t&&(null===(i=null===(r=e.logger)||void 0===r?void 0:r.debug)||void 0===i||i.call(r,"Background capture complete"),e.notify({action:"background-capture-complete",data:n}))};e.registerActionHandler("initialize-background-capture",(function(){var t,o;null===(o=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===o||o.call(t,"Initializing background capture (external script)");var s=new URL(n,e.endpoint).toString();e.loadScriptOnce(s).then((function(){var t,n,o;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Background capture script loaded (external)"),r=null===(o=null===window||void 0===window?void 0:window.amplitudeBackgroundCapture)||void 0===o?void 0:o.call(window,{messenger:e,onBackgroundCapture:i}),e.notify({action:"background-capture-loaded"})})).catch((function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize background capture")}))})),e.registerActionHandler("close-background-capture",(function(){var e;null===(e=null==r?void 0:r.close)||void 0===e||e.call(r),r=null}))}}(N),N.setup(de({logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:mr[t.serverZone]})))),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){var e,t,n,r;return ge(this,(function(i){try{for(e=he(w),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},Po=["mutation","navigate"];function Ao(e,t){var n,r,i,o,s=t.event,a=s.pageX,c=s.pageY;e.yMin=Math.min(null!==(n=e.yMin)&&void 0!==n?n:c,c),e.yMax=Math.max(null!==(r=e.yMax)&&void 0!==r?r:c,c),e.xMin=Math.min(null!==(i=e.xMin)&&void 0!==i?i:a,a),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:a,a),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function Oo(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:de({"[Amplitude] Begin Time":new Date(t.timestamp).toISOString(),"[Amplitude] End Time":new Date(n.timestamp).toISOString(),"[Amplitude] Duration":n.timestamp-t.timestamp,"[Amplitude] Clicks":e.map((function(e){return{X:e.event.pageX,Y:e.event.pageY,Time:e.timestamp}})),"[Amplitude] Click Count":e.length},t.targetElementProperties),time:t.timestamp}}function xo(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,o=r.clickObservable,s=r.selectionObservable,a=[],c={},u=null;function l(e){a=[],c={},e&&(Ao(c,e),a.push(e))}var d=ar(o.filter((function(e){return i("click",e.closestTrackedAncestor)})),(function(e){return pe(t,void 0,void 0,(function(){var t;return ge(this,(function(n){return Ao(c,e),t=null,0===a.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(a,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(a,e)||c.isOutOfBounds?(u&&(t=Oo(a)),l(e)):a.push(e),u&&(clearTimeout(u.timerId),u.resolve(t),u=null),a.length>=4?[2,new Promise((function(e){u={resolve:e,timerId:setTimeout((function(){e(Oo(a))}),1e3)}}))]:[2,null]}))}))})),f=null==s?void 0:s.subscribe((function(){l()})),p=d.subscribe((function(e){null!==e&&n.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})}));return{unsubscribe:function(){p.unsubscribe(),null==f||f.unsubscribe()}}}var Co,Ro;!function(e){e.INCREASING="increasing",e.DECREASING="decreasing"}(Co||(Co={})),function(e){e.X="x",e.Y="y"}(Ro||(Ro={}));function Do(e){var t=e.changes,n=e.changesThreshold,r=e.thresholdMs;return!(t.length<n)&&t[t.length-1]-t[0]<r}function Lo(e){e.changes=[],e.startTime=void 0}function No(e){for(var t=e.changes,n=e.thresholdMs,r=0,i=t[t.length-1];r<t.length;r++){if(i-t[r]<n)break}0!==r&&(e.startTime=t[r],e.changes.splice(0,r))}var Uo=function(e){var t=e.mouseDirectionChangeObservable,n=e.directionChanges,r=void 0===n?20:n,i=e.thresholdMs,o=void 0===i?2e3:i;return new sr((function(e){var n={changes:[],changesThreshold:r,thresholdMs:o},i={changes:[],changesThreshold:r,thresholdMs:o},s=void 0,a=null;function c(){void 0!==s&&(e.next(s),s=void 0,null!==a&&clearTimeout(a),Lo(n),Lo(i))}return t.subscribe((function(e){null!==a&&clearTimeout(a),function(e){var t=+Date.now();e.startTime=e.startTime||t;var n=e.changes,r=e.changesThreshold;n.push(t),n.length>r&&n.shift()}(e===Ro.X?n:i);var t=function(e,t){var n=void 0;if(Do(e)&&(n=e.startTime),Do(t)){var r=t.startTime;r&&(!n||r<n)&&(n=r)}return n}(n,i);return t?(s=s||t,a=setTimeout((function(){c(),a=null}),o)):c(),No(n),No(i),function(){null!==a&&(clearTimeout(a),a=null)}}))}))},Mo=function(e){var t=e.amplitude,n=e.options,r=e.allObservables,i=e.directionChanges,o=void 0===i?20:i,s=e.thresholdMs,a=void 0===s?2e3:s,c=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new sr((function(e){var n=null,r=null,i=null;return t.subscribe((function(t){var o={x:t.clientX,y:t.clientY};null!==n?(o.x>n.x?(r===Co.DECREASING&&e.next(Ro.X),r=Co.INCREASING):o.x<n.x&&(r===Co.INCREASING&&e.next(Ro.X),r=Co.DECREASING),o.y>n.y?(i===Co.DECREASING&&e.next(Ro.Y),i=Co.INCREASING):o.y<n.y&&(i===Co.INCREASING&&e.next(Ro.Y),i=Co.DECREASING),n=o):n=o}))}))}({allWindowObservables:r});return Uo({mouseDirectionChangeObservable:c,directionChanges:o,thresholdMs:a}).subscribe((function(e){Zi(n)&&t.track("[Amplitude] Thrashed Cursor",void 0,{time:e})}))};function jo(e,t,n,r){if(!r)return[];var i=e[t];return"object"==typeof i&&null!==i&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:n}var qo,Fo,Bo=4e3,$o=function(e){var t;void 0===e&&(e={});var n="@amplitude/plugin-frustration-browser",r=[],i=!1!==e.errorClicks;e.errorClicks||(i=!1);var o=!1!==e.deadClicks&&null!==e.deadClicks,s=!1!==e.rageClicks&&null!==e.rageClicks,a=!1!==e.thrashedCursor&&null!==e.thrashedCursor;e.thrashedCursor||(a=!1);var c=jo(e,"rageClicks",_n,s),u=jo(e,"deadClicks",En,o),l=jo(e,"errorClicks",Sn,i),d=null!==(t=e.dataAttributePrefix)&&void 0!==t?t:wn,f=new _o(e),p=me([],ve(new Set(me(me(me([],ve(c),!1),ve(u),!1),ve(l),!1))),!1),g=function(){var e,t,n=ur(co("pointerdown").map((function(e){return f.addAdditionalEventProperties(e,"click",p,d,!0)}))),r=ur(uo().map((function(e){return f.addTypeAndTimestamp(e,"error")}))),i=ur(ao().map((function(e){return f.addAdditionalEventProperties(e,"mutation",p,d)})));window.navigation&&(t=ur(new sr((function(e){var t=function(t){e.next(de(de({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}})).map((function(e){return f.addAdditionalEventProperties(e,"navigate",p,d)}))));var o=ur(new sr((function(e){var t=function(){var t=document.activeElement;if(t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName)){try{if(t.selectionStart===t.selectionEnd)return}catch(e){return}return e.next()}var n=window.getSelection();if(n&&!n.isCollapsed)return e.next()};return window.document.addEventListener("selectionchange",t),function(){window.document.removeEventListener("selectionchange",t)}}))),s=ur(new sr((function(e){var t=function(t){e.next(t)},n={capture:!0};return so.document.addEventListener("mousemove",t,n),function(){so.document.removeEventListener("mousemove",t,n)}})));return(e={})[ko.ClickObservable]=n,e[ko.MutationObservable]=i,e[ko.NavigateObservable]=t,e[ko.BrowserErrorObservable]=r,e[ko.SelectionObservable]=o,e[ko.MouseMoveObservable]=s,e};return{name:n,type:"enrichment",setup:function(t,p){return pe(void 0,void 0,void 0,(function(){var h,v,m,y,b,w,T,k,E,S,_;return ge(this,(function(I){return"undefined"==typeof document||(h=g(),s&&(v=eo(e,c),m=xo({allObservables:h,amplitude:p,shouldTrackRageClick:v}),r.push(m)),o&&(y=eo(e,u),b=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackDeadClick,o=n.clickObservable,s=n.mutationObservable,a=n.navigateObservable,c=o.filter((function(e){return io(e)&&i("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Bi.LEFT_OR_TOUCH_CONTACT})),u=a?cr(s,a):s,l=cr(c,u),d=null;return ar(l,(function(e){return d&&Po.includes(e.type)?(clearTimeout(d),d=null,Promise.resolve(null)):"click"===e.type?d?Promise.resolve(null):new Promise((function(t){d=setTimeout((function(){t(e),d=null}),3e3)})):Promise.resolve(null)})).subscribe((function(e){if(e){var n={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};t.track("[Amplitude] Dead Click",de(de({},r("click",e.closestTrackedAncestor)),n),{time:e.timestamp})}}))}({amplitude:p,allObservables:h,getEventProperties:function(e,t){return f.getEventProperties(e,t,d)},shouldTrackDeadClick:y}),r.push(b)),i&&(w=eo(e,l),T=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackErrorClick,i=n.clickObservable,o=n.browserErrorObservable,s=i.filter((function(e){return io(e)&&r("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Bi.LEFT_OR_TOUCH_CONTACT})),a=null,c=null,u=function(){null!==a&&(clearTimeout(a),a=null),c=null};return cr(s,o).subscribe((function(e){var n;if("click"===e.type)return u(),c=e,void(a=setTimeout(u,2e3));"error"===e.type&&c&&(t.track("[Amplitude] Error Click",de(((n={})["[Amplitude] Kind"]=e.event.kind,n["[Amplitude] Message"]=e.event.message,n["[Amplitude] Stack"]=e.event.stack,n["[Amplitude] Filename"]=e.event.filename,n["[Amplitude] Line Number"]=e.event.lineNumber,n["[Amplitude] Column Number"]=e.event.columnNumber,n),c.targetElementProperties)),u())}))}({amplitude:p,allObservables:h,shouldTrackErrorClick:w}),r.push(T)),a&&(k=void 0,E=void 0,"object"==typeof e.thrashedCursor&&(k=e.thrashedCursor.directionChanges,E=e.thrashedCursor.threshold,k&&k<5&&(t.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(k," is below the minimum of ").concat(5,", setting to ").concat(5)),k=5),E&&E>Bo&&(t.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(E," is above the maximum of ").concat(Bo,", setting to ").concat(Bo)),E=Bo)),S=Mo({amplitude:p,options:e,allObservables:h,directionChanges:k,thresholdMs:E}),r.push(S)),null===(_=null==t?void 0:t.loggerProvider)||void 0===_||_.log("".concat(n," has been successfully added."))),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){var e,t,n,i;return ge(this,(function(o){try{for(e=he(r),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},Ho="[Amplitude] Network Request",Ko="500-599";function zo(e,t){var n="^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(n).test(e)}function Vo(e,t){var n,r,i=t.split(",");try{for(var o=he(i),s=o.next();!s.done;s=o.next()){var a=ve(s.value.split("-").map(Number),2),c=a[0],u=a[1];if(e===c&&void 0===u)return!0;if(e>=c&&e<=u)return!0}}catch(e){n={error:e}}finally{try{s&&!s.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function Go(e){var t;if(e)try{var n=null===(t=Ge())||void 0===t?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),s=r.href,a=r.host;return r.hash="",r.search="",{query:i,fragment:o,href:s,hrefWithoutQueryOrHash:r.href,host:a}}catch(e){return}}function Wo(e){if("object"==typeof e&&null!==e){if(0!==e.length)return e}else{if(e)return me([],ve(je),!1);if(void 0===e){return}}}function Jo(e){var t,n;return!(null===(t=null==e?void 0:e.allowlist)||void 0===t?void 0:t.length)&&!(null===(n=null==e?void 0:e.blocklist)||void 0===n?void 0:n.length)}function Yo(e,t){var n;void 0===t&&(t={});var r=Go(e.url);if(!r)return!1;var i,o=r.host;if(!1!==t.ignoreAmplitudeRequests&&(zo(o,"*.amplitude.com")||zo(o,"amplitude.com")))return!1;if(null===(n=t.ignoreHosts)||void 0===n?void 0:n.find((function(e){return zo(o,e)})))return!1;if(!t.captureRules&&void 0!==e.status&&!Vo(e.status,Ko))return!1;if(t.captureRules&&(me([],ve(t.captureRules),!1).reverse().find((function(t){if(i=function(e,t,n,r,i){if((!e.hosts||e.hosts.find((function(e){return zo(t,e)})))&&(!r||!e.urls||Nt(r,e.urls))&&(!i||!e.methods||e.methods.find((function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e}))))return!((n||0===n)&&!Vo(n,e.statusCodeRange||Ko))}(t,o,e.status,e.url,e.method),i){var n=Wo(t.responseHeaders);if(e.responseWrapper&&n){var r=e.responseWrapper.headers(n);r&&(e.responseHeaders=r)}var s=Wo(t.requestHeaders);if(e.requestWrapper&&s){var a=e.requestWrapper.headers(s);a&&(e.requestHeaders=a)}e.responseWrapper&&t.responseBody&&!Jo(t.responseBody)&&(e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,t.responseBody.blocklist)),e.requestWrapper&&t.requestBody&&!Jo(t.requestBody)&&(e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,t.requestBody.blocklist))}return void 0!==i})),!i))return!1;return!e.requestWrapper||!function(e,t){if(e.includes("amplitude.com"))try{var n=t.body;if("string"!=typeof n)return!1;if(JSON.parse(n).events.find((function(e){return e.event_type===Ho})))return!0}catch(e){}return!1}(o,e.requestWrapper)}function Xo(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter((function(e){return Yo(e.event,n)})).subscribe((function(e){var t,n,o,s=e.event,a=Go(s.url);if(a){var c=null===(n=s.responseWrapper)||void 0===n?void 0:n.bodySize,u=null===(o=s.requestWrapper)||void 0===o?void 0:o.bodySize;!function(e,t,n,r){pe(this,void 0,void 0,(function(){var i,o,s;return ge(this,(function(a){switch(a.label){case 0:return t.requestBodyJson||t.responseBodyJson?[4,Promise.all([t.requestBodyJson,t.responseBodyJson])]:[3,2];case 1:if(i=ve.apply(void 0,[a.sent(),2]),o=i[0],s=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==r||r.debug("Failed to stringify request body",e)}if(s)try{e["[Amplitude] Response Body"]=JSON.stringify(s)}catch(e){null==r||r.debug("Failed to stringify response body")}a.label=2;case 2:return null==n||n.track(Ho,e),[2]}}))}))}(((t={})["[Amplitude] URL"]=a.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=a.query,t["[Amplitude] URL Fragment"]=a.fragment,t["[Amplitude] Request Method"]=s.method,t["[Amplitude] Status Code"]=s.status,t["[Amplitude] Start Time"]=s.startTime,t["[Amplitude] Completion Time"]=s.endTime,t["[Amplitude] Duration"]=s.duration,t["[Amplitude] Request Body Size"]=u,t["[Amplitude] Response Body Size"]=c,t["[Amplitude] Request Type"]=s.type,t["[Amplitude] Request Headers"]=s.requestHeaders,t["[Amplitude] Response Headers"]=s.responseHeaders,t),s,r,i)}}))}!function(e){e.NetworkObservable="networkObservable"}(qo||(qo={}));var Qo=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new sr((function(e){var n=new $n((function(t){var n=function(e,t){return{event:e,timestamp:Date.now(),type:t}}(t,"network");e.next(n)}));return zn.subscribe(n,t),function(){zn.unsubscribe(n)}}));return(e={})[qo.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return pe(void 0,void 0,void 0,(function(){var s;return ge(this,(function(a){return"undefined"==typeof document||(s=r(),t=null==i?void 0:i.loggerProvider,Fo=Xo({allObservables:s,networkTrackingOptions:e,amplitude:o,loggerProvider:t}),null==t||t.log("".concat(n," has been successfully added."))),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(e){return Fo.unsubscribe(),[2]}))}))}}};let Zo=-1;const es=e=>{addEventListener("pageshow",(t=>{t.persisted&&(Zo=t.timeStamp,e(t))}),!0)},ts=(e,t,n,r)=>{let i,o;return s=>{t.value>=0&&(s||r)&&(o=t.value-(i??0),(o||void 0===i)&&(i=t.value,t.delta=o,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,n),e(t)))}},ns=e=>{requestAnimationFrame((()=>requestAnimationFrame((()=>e()))))},rs=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},is=()=>{const e=rs();return e?.activationStart??0},os=(e,t=-1)=>{const n=rs();let r="navigate";return Zo>=0?r="back-forward-cache":n&&(document.prerendering||is()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},ss=new WeakMap;function as(e,t){return ss.get(e)||ss.set(e,new t),ss.get(e)}class cs{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}}const us=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const r=new PerformanceObserver((e=>{Promise.resolve().then((()=>{t(e.getEntries())}))}));return r.observe({type:e,buffered:!0,...n}),r}}catch{}},ls=e=>{let t=!1;return()=>{t||(e(),t=!0)}};let ds=-1;const fs=new Set,ps=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,gs=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of fs)e();isFinite(ds)||(ds="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",gs,!0))}},hs=()=>{if(ds<0){const e=is(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>"hidden"===t.name&&t.startTime>e))[0]?.startTime;ds=t??ps(),addEventListener("visibilitychange",gs,!0),addEventListener("prerenderingchange",gs,!0),es((()=>{setTimeout((()=>{ds=ps()}))}))}return{get firstHiddenTime(){return ds},onHidden(e){fs.add(e)}}},vs=e=>{document.prerendering?addEventListener("prerenderingchange",(()=>e()),!0):e()},ms=[1800,3e3],ys=(e,t={})=>{vs((()=>{const n=hs();let r,i=os("FCP");const o=us("paint",(e=>{for(const t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-is(),0),i.entries.push(t),r(!0)))}));o&&(r=ts(e,i,ms,t.reportAllChanges),es((n=>{i=os("FCP"),r=ts(e,i,ms,t.reportAllChanges),ns((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))})))}))},bs=[.1,.25];let ws=0,Ts=1/0,ks=0;const Es=e=>{for(const t of e)t.interactionId&&(Ts=Math.min(Ts,t.interactionId),ks=Math.max(ks,t.interactionId),ws=ks?(ks-Ts)/7+1:0)};let Ss;const _s=()=>Ss?ws:performance.interactionCount??0;let Is=0;class Ps{u=[];l=new Map;m;p;v(){Is=_s(),this.u.length=0,this.l.clear()}L(){const e=Math.min(this.u.length-1,Math.floor((_s()-Is)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;const t=this.u.at(-1);let n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort(((e,t)=>t.P-e.P)),this.u.length>10){const e=this.u.splice(10);for(const t of e)this.l.delete(t.id)}this.p?.(n)}}}const As=e=>{const t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(e=ls(e),addEventListener("visibilitychange",e,{once:!0,capture:!0}),t((()=>{e(),removeEventListener("visibilitychange",e,{capture:!0})})))},Os=[200,500],xs=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const n=hs();vs((()=>{"interactionCount"in performance||Ss||(Ss=us("event",Es,{type:"event",buffered:!0,durationThreshold:0}));let r,i=os("INP");const o=as(t,Ps),s=e=>{As((()=>{for(const t of e)o.h(t);const t=o.L();t&&t.P!==i.value&&(i.value=t.P,i.entries=t.entries,r())}))},a=us("event",s,{durationThreshold:t.durationThreshold??40});r=ts(e,i,Os,t.reportAllChanges),a&&(a.observe({type:"first-input",buffered:!0}),n.onHidden((()=>{s(a.takeRecords()),r(!0)})),es((()=>{o.v(),i=os("INP"),r=ts(e,i,Os,t.reportAllChanges)})))}))};class Cs{m;h(e){this.m?.(e)}}const Rs=[2500,4e3],Ds=[800,1800],Ls=e=>{document.prerendering?vs((()=>Ls(e))):"complete"!==document.readyState?addEventListener("load",(()=>Ls(e)),!0):setTimeout(e)};function Ns(e){var t,n=(null===(t=e.entries[0])||void 0===t?void 0:t.startTime)||0;return performance.timeOrigin+n}function Us(e){return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor(Ns(e)),navigationStart:Math.floor(performance.timeOrigin)}}var Ms,js=function(){var e=null,t=Ge(),n=null==t?void 0:t.document,r=null==t?void 0:t.location;return{name:"web-vitals-browser",type:"enrichment",setup:function(t,i){return pe(void 0,void 0,void 0,(function(){var o,s;return ge(this,(function(a){return void 0===n||(o=Ut((null==r?void 0:r.href)||"",t.loggerProvider),s={"[Amplitude] Page Domain":(null==r?void 0:r.hostname)||"","[Amplitude] Page Location":o,"[Amplitude] Page Path":Ut((null==r?void 0:r.pathname)||"",t.loggerProvider),"[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":Ut(o.split("?")[0],t.loggerProvider)},((e,t={})=>{vs((()=>{const n=hs();let r,i=os("LCP");const o=as(t,Cs),s=e=>{t.reportAllChanges||(e=e.slice(-1));for(const t of e)o.h(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-is(),0),i.entries=[t],r())},a=us("largest-contentful-paint",s);if(a){r=ts(e,i,Rs,t.reportAllChanges);const n=ls((()=>{s(a.takeRecords()),a.disconnect(),r(!0)})),o=e=>{e.isTrusted&&(As(n),removeEventListener(e.type,o,{capture:!0}))};for(const e of["keydown","click","visibilitychange"])addEventListener(e,o,{capture:!0});es((n=>{i=os("LCP"),r=ts(e,i,Rs,t.reportAllChanges),ns((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))}))}}))})((function(e){s["[Amplitude] LCP"]=Us(e)})),ys((function(e){s["[Amplitude] FCP"]=Us(e)})),xs((function(e){s["[Amplitude] INP"]=Us(e)})),((e,t={})=>{const n=hs();ys(ls((()=>{let r,i=os("CLS",0);const o=as(t,cs),s=e=>{for(const t of e)o.h(t);o.i>i.value&&(i.value=o.i,i.entries=o.o,r())},a=us("layout-shift",s);a&&(r=ts(e,i,bs,t.reportAllChanges),n.onHidden((()=>{s(a.takeRecords()),r(!0)})),es((()=>{o.i=0,i=os("CLS",0),r=ts(e,i,bs,t.reportAllChanges),ns((()=>r()))})),setTimeout(r))})))})((function(e){s["[Amplitude] CLS"]=Us(e)})),((e,t={})=>{let n=os("TTFB"),r=ts(e,n,Ds,t.reportAllChanges);Ls((()=>{const i=rs();i&&(n.value=Math.max(i.responseStart-is(),0),n.entries=[i],r(!0),es((()=>{n=os("TTFB",0),r=ts(e,n,Ds,t.reportAllChanges),r(!0)})))}))})((function(e){s["[Amplitude] TTFB"]=Us(e)})),e=function(){"hidden"===n.visibilityState&&e&&(i.track("[Amplitude] Web Vitals",s),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]}))}))}}},qs=function(){function e(e,t){var n,r,i;this.shouldTrackNewCampaign=!1,this.options=de({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(r=(null===(n=t.cookieOptions)||void 0===n?void 0:n.domain)||t.topLevelDomain,i=r,i?(i.startsWith(".")&&(i=i.substring(1)),[new RegExp("".concat(i.replace(".","\\."),"$"))]):[]),optOut:t.optOut},e),this.storage=t.cookieStorage,this.storageKey=$t(t.apiKey,"MKTG"),this.webExpStorageKey=$t(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=Me,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,this.topLevelDomain=t.topLevelDomain,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return pe(this,void 0,void 0,(function(){var e,t;return ge(this,(function(n){switch(n.label){case 0:return this.options.optOut?[2]:[4,this.fetchCampaign()];case 1:return t=ve.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||xt(this.sessionTimeout,this.lastEventTime),gi(this.currentCampaign,this.previousCampaign,this.options,this.logger,e,this.topLevelDomain)?(this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.fetchCampaign=function(){return pe(this,void 0,void 0,(function(){var e;return ge(this,(function(t){switch(t.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:return(e=t.sent())?[4,this.storage.remove(this.webExpStorageKey)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[4,Promise.all([e||(new Vn).parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}}))}))},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r,i,o=(t=this.currentCampaign,n=this.options,r=de(de({},Me),t),i=Object.entries(r).reduce((function(e,t){var r,i=ve(t,2),o=i[0],s=i[1];return e.setOnce("initial_".concat(o),null!==(r=null!=s?s:n.initialEmptyValue)&&void 0!==r?r:"EMPTY"),s?e.set(o,s):e.unset(o)}),new $e),Xe(i));return e&&(o.event_id=e),o},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),Fs="AMP_CURRENT_PAGE",Bs="AMP_PREVIOUS_PAGE",$s="AMP_URL_INFO";!function(e){e.Direct="direct",e.Internal="internal",e.External="external"}(Ms||(Ms={}));var Hs=new Set([le.IDENTIFY,le.GROUP_IDENTIFY,le.REVENUE]),Ks=function(e){var t={}.internalDomains,n=void 0===t?[]:t,r=Ge(),i=void 0,o=!1,s=void 0,a=!1,c=!1,u=function(e){var t="undefined"!=typeof location&&location.hostname||"",r=e?function(e){var t;try{var n=Ut(e,s);t=new URL(n).hostname}catch(e){null==s||s.error("Could not parse URL: ",e)}return t}(e):void 0;if(!r)return Ms.Direct;var i=n.some((function(e){return-1!==t.indexOf(e)})),o=n.some((function(e){return-1!==r.indexOf(e)}));return t===r||o&&i?Ms.Internal:Ms.External},l=function(){pe(void 0,void 0,void 0,(function(){var e,t,n,r,s;return ge(this,(function(a){switch(a.label){case 0:return i&&o?[4,i.get($s)]:[3,3];case 1:return e=a.sent(),t=Ut("undefined"!=typeof location&&location.href||""),n=(null==e?void 0:e[Fs])||"",r=void 0,r=t===n?(null==e?void 0:e[Bs])||"":n||document.referrer||"",[4,i.set($s,(s={},s[Fs]=t,s[Bs]=r,s))];case 2:a.sent(),a.label=3;case 3:return[2]}}))}))},d={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return pe(void 0,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:if((s=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),c=!0,!r)return[3,2];try{i=new Ht(r.sessionStorage)}catch(e){null==s||s.debug("sessionStorage is not available in this environment.")}return[4,null==i?void 0:i.isEnabled()];case 1:o=null!==(t=n.sent())&&void 0!==t&&t,r.addEventListener("popstate",l),a||(r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=ve(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),c&&l()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=ve(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),c&&l()}}),a=!0),n.label=2;case 2:return[2]}}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){var t,n,r,s,a;return ge(this,(function(c){switch(c.label){case 0:return t=Ut("undefined"!=typeof location&&location.href||""),i&&o?[4,i.get($s)]:[3,5];case 1:return(null==(n=c.sent())?void 0:n[Fs])?[3,3]:[4,i.set($s,(a={},a[Fs]=t,a[Bs]=document.referrer||"",a))];case 2:c.sent(),c.label=3;case 3:return[4,i.get($s)];case 4:if(r=c.sent(),s="",r&&(s=r[Bs]||""),Hs.has(e.event_type))return[2,e];e.event_properties=de(de({},e.event_properties||{}),{"[Amplitude] Page Domain":zs(e,"[Amplitude] Page Domain","undefined"!=typeof location&&location.hostname||""),"[Amplitude] Page Location":zs(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":zs(e,"[Amplitude] Page Path","undefined"!=typeof location&&Ut(location.pathname)||""),"[Amplitude] Page Title":zs(e,"[Amplitude] Page Title",Zn(Qn)),"[Amplitude] Page URL":zs(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":s,"[Amplitude] Previous Page Type":u(s)}),c.label=5;case 5:return[2,e]}}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(e){switch(e.label){case 0:return r&&(r.removeEventListener("popstate",l),c=!1),i&&o?[4,i.set($s,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))}};return d};function zs(e,t,n){return e.event_properties||(e.event_properties={}),void 0===e.event_properties[t]?n:e.event_properties[t]}var Vs=function(){var e,t,n;function r(t){if(t)try{var n=new Function("return "+t)();if("function"==typeof n)return n;null==e||e.error("Custom enrichment body did not evaluate to a function")}catch(t){null==e||e.error("Could not create custom enrichment function",t)}return function(e){return e}}var i={name:"@amplitude/plugin-custom-enrichment-browser",type:"enrichment",setup:function(i,o){return pe(void 0,void 0,void 0,(function(){var o,s;return ge(this,(function(a){return null==(e=i.loggerProvider)||e.log("Installing @amplitude/plugin-custom-enrichment-browser"),(null===(s=i.remoteConfig)||void 0===s?void 0:s.fetchRemoteConfig)&&(i.remoteConfigClient?(o=i.remoteConfigClient.subscribe("configs.analyticsSDK.browserSDK.customEnrichment","all",(function(e){n=e&&function(e){return"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body}(e)?r(e.body||""):r("")})),t=function(){var e;return null===(e=i.remoteConfigClient)||void 0===e?void 0:e.unsubscribe(o)}):null==e||e.debug("Remote config client is not provided, skipping remote config fetch")),[2]}))}))},execute:function(t){return pe(void 0,void 0,void 0,(function(){var r;return ge(this,(function(i){if(n)try{return[2,null!==(r=n(t))&&void 0!==r?r:null]}catch(n){return null==e||e.error("Could not execute custom enrichment function",n),[2,t]}return[2,t]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(e){return t&&t(),[2]}))}))}};return i},Gs=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t._enableRequestBodyCompressionExperimentalValue=!1,t}return ce(t,e),t.prototype.init=function(e,t,n){var r,i;return void 0===e&&(e=""),arguments.length>2?(r=t,i=n):"string"==typeof t?(r=t,i=void 0):(r=null==t?void 0:t.userId,i=t),Qe(this._init(de(de({},i),{userId:r,apiKey:e})))},t.prototype._init=function(t){var n,r,i,o,s,a,c,u;return pe(this,void 0,void 0,(function(){var l,d,f,p,g,h,v,m,y,b,w,T,k,E,S,_=this;return ge(this,(function(I){switch(I.label){case 0:return this.initializing?[2]:(this.initializing=!0,l=function(e){var t,n;return void 0===e&&(e={}),!0===(null===(t=e.remoteConfig)||void 0===t?void 0:t.fetchRemoteConfig)||!1!==(null===(n=e.remoteConfig)||void 0===n?void 0:n.fetchRemoteConfig)&&!1!==e.fetchRemoteConfig}(t),d=null!==(n=t.loggerProvider)&&void 0!==n?n:new rt,t.loggerProvider||d.enable(null!==(r=t.logLevel)&&void 0!==r?r:tt.Warn),f=null!==(i=t.serverZone)&&void 0!==i?i:"US",g=this._diagnosticsSampleRate,h=null===(o=t.enableDiagnostics)||void 0===o||o,l?(p=new dn(t.apiKey,d,f,null===(s=t.remoteConfig)||void 0===s?void 0:s.serverUrl),[4,new Promise((function(e){null==p||p.subscribe("configs.diagnostics.browserSDK","all",(function(t,n,r){if(d.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t){var i=t.sampleRate;"number"!=typeof i||isNaN(i)||(g=i);var o=t.enabled;"boolean"==typeof o&&(h=o)}e()}))}))]):[3,2]);case 1:I.sent(),I.label=2;case 2:return(v=new nn(t.apiKey,d,f,{enabled:h,sampleRate:g})).setTag("library","".concat(Fr,"/").concat(qr)),"undefined"!=typeof navigator&&v.setTag("user_agent",navigator.userAgent),[4,ki(t.apiKey,t,this,v,{loggerProvider:d,serverZone:f,enableDiagnostics:h,diagnosticsSampleRate:g})];case 3:return m=I.sent(),l&&p?[4,new Promise((function(e){null==p||p.subscribe("configs.analyticsSDK.browserSDK","all",(function(t,n,r){m.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&Fi(t,m),e()}))}))]:[3,5];case 4:I.sent(),I.label=5;case 5:return[4,e.prototype._init.call(this,m)];case 6:return I.sent(),this.logBrowserOptions(m),this.config.remoteConfigClient=p,_r(this.config.defaultTracking)?(this.config.optOut&&this.timeline.addOptOutListener((function(e){return pe(_,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return e?[3,2]:(t=Ur(this.config),this.webAttribution=new qs(t,this.config),[4,this.webAttribution.init()]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))})),y=Ur(this.config),this.webAttribution=new qs(y,this.config),[4,this.webAttribution.init()]):[3,8];case 7:I.sent(),I.label=8;case 8:return b=Dt(),w=b.ampTimestamp?Number(b.ampTimestamp):void 0,T=!w||Date.now()<w,k=T&&!Number.isNaN(Number(b.ampSessionId))?Number(b.ampSessionId):void 0,-1!==(E=this.config.deferredSessionId)||this.config.optOut||(E=Date.now()),this.setSessionId(null!==(u=null!==(c=null!==(a=t.sessionId)&&void 0!==a?a:k)&&void 0!==c?c:E)&&void 0!==u?u:this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener((function(e){return pe(_,void 0,void 0,(function(){return ge(this,(function(t){return!e&&this.config.deferredSessionId&&(-1===this.config.deferredSessionId?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]}))}))})),(S=At(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline?[3,10]:[4,this.add(Mi()).promise];case 9:I.sent(),I.label=10;case 10:return[4,this.add(new mt({diagnosticsClient:v})).promise];case 11:return I.sent(),[4,this.add(new Br).promise];case 12:return I.sent(),[4,this.add(new Ot).promise];case 13:return I.sent(),O=this.config,Ui||void 0!==O.defaultTracking||(O.loggerProvider.warn("`options.defaultTracking` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to `options.defaultTracking`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:\n\namplitude.init(<YOUR_API_KEY>, {\n defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),Ui=!0),A=this.config.defaultTracking,Sr(A,"fileDownloads")?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(Ni()).promise]):[3,15];case 14:I.sent(),I.label=15;case 15:return Ir(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(Ri()).promise]):[3,17];case 16:I.sent(),I.label=17;case 17:return Pr(this.config.defaultTracking)?this.config.optOut?[3,19]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Ai(Nr(this.config))).promise]):[3,20];case 18:return I.sent(),[3,20];case 19:this.timeline.addOptOutListener((function(e){return pe(_,void 0,void 0,(function(){return ge(this,(function(t){switch(t.label){case 0:return e?[2]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Ai(Nr(this.config))).promise]);case 1:return t.sent(),[2]}}))}))})),I.label=20;case 20:return xr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(Io(Rr(this.config),{diagnosticsClient:v})).promise]):[3,22];case 21:I.sent(),I.label=22;case 22:return Cr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add($o(Dr(this.config))).promise]):[3,24];case 23:I.sent(),I.label=24;case 24:return Or(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(Qo(Lr(this.config))).promise]):[3,26];case 25:I.sent(),I.label=26;case 26:return function(e){return"boolean"==typeof e?e:"object"==typeof e&&!0===e.webVitals}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(js()).promise]):[3,28];case 27:I.sent(),I.label=28;case 28:return function(e){return Sr(e,"pageUrlEnrichment")}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(Ks()).promise]):[3,30];case 29:I.sent(),I.label=30;case 30:return("boolean"==typeof(P=this.config.customEnrichment)?P:"object"==typeof P&&null!==P&&!1!==P.enabled)?(this.config.loggerProvider.debug("Adding custom enrichment plugin"),[4,this.add(Vs()).promise]):[3,32];case 31:I.sent(),I.label=32;case 32:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 33:return I.sent(),S.eventBridge.setEventReceiver((function(e){var t=e.eventProperties||{},n=t.time,r=fe(t,["time"]),i="number"==typeof n?{time:n}:void 0;_.track(e.eventType,r,i)})),[2]}var P,A,O}))}))},t.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},t.prototype.setUserId=function(e){this.config?(this.config.loggerProvider.debug("function setUserId: ",e),e===this.config.userId&&void 0!==e||(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),function(e,t){At(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},t.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},t.prototype.setDeviceId=function(e){this.config?(this.config.loggerProvider.debug("function setDeviceId: ",e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),function(e,t){At(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},t.prototype.reset=function(){this.setDeviceId(Je()),this.setUserId(void 0),this.timeline.onReset()},t.prototype.getIdentity=function(){var e,t;return{deviceId:null===(e=this.config)||void 0===e?void 0:e.deviceId,userId:null===(t=this.config)||void 0===t?void 0:t.userId,userProperties:this.userProperties}},t.prototype.setIdentity=function(e){var t,n,r;if("userId"in e&&this.setUserId(e.userId),"deviceId"in e&&e.deviceId&&this.setDeviceId(e.deviceId),"userProperties"in e){this.userProperties=e.userProperties;var i=new $e,o=null!==(r=e.userProperties)&&void 0!==r?r:{};try{for(var s=he(Object.entries(o)),a=s.next();!a.done;a=s.next()){var c=ve(a.value,2),u=c[0],l=c[1];i.set(u,l)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}this.identify(i)}},t.prototype.getOptOut=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.optOut},t.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},t.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),Qe(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=null!=e?e:-1,Qe(Promise.resolve());if(void 0===e&&(e=Date.now()),e===this.config.sessionId)return Qe(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",e);var r=this.getSessionId();r!==e&&this.timeline.onSessionIdChanged(e);var i=this.config.lastEventTime,o=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,Ar(this.config.defaultTracking)&&(r&&i&&n.push(this.track(ni,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:r,time:i+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var s=this.trackCampaignEventIfNeeded(++o,n);return this.config.identify&&n.push(this.track(Xe(this.config.identify)).promise),Ar(this.config.defaultTracking)&&n.push(this.track(ti,void 0,{event_id:s?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,Qe(Promise.all(n))},t.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},t.prototype.setTransport=function(e){this.config?this.config.transportProvider=Si(e):this.q.push(this.setTransport.bind(this,e))},t.prototype.identify=function(t,n){if(jr(t)){var r=t._q;t._q=[],t=Mr(new $e,r)}return(null==n?void 0:n.user_id)&&this.setUserId(n.user_id),(null==n?void 0:n.device_id)&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},t.prototype.groupIdentify=function(t,n,r,i){if(jr(r)){var o=r._q;r._q=[],r=Mr(new $e,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},t.prototype.revenue=function(t,n){if(jr(t)){var r=t._q;t._q=[],t=Mr(new et,r)}return e.prototype.revenue.call(this,t,n)},t.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign)return!1;var n=this.webAttribution.generateCampaignEvent(e);return t?t.push(this.track(n).promise):this.track(n),this.config.loggerProvider.log("Tracking attribution."),!0},t.prototype.process=function(t){return pe(this,void 0,void 0,(function(){var n,r,i;return ge(this,(function(o){return n=Date.now(),r=xt(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type===ti||t.event_type===ni||t.session_id&&t.session_id!==this.getSessionId()||(r||i?(this.setSessionId(n),i&&this.config.loggerProvider.log("Created a new session for new campaign.")):r||this.trackCampaignEventIfNeeded()),[2,e.prototype.process.call(this,t)]}))}))},t.prototype.logBrowserOptions=function(e){try{var t=de(de({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",hr(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},t.prototype._setDiagnosticsSampleRate=function(e){e>1||e<0||this.config||(this._diagnosticsSampleRate=e)},t.prototype._enableRequestBodyCompressionExperimental=function(e){this.config||(this._enableRequestBodyCompressionExperimentalValue=e)},t}(Ze),Ws=function(){var e=new Gs;return{init:gt(e.init.bind(e),"init",dt(e),pt(e,["config"])),add:gt(e.add.bind(e),"add",dt(e),pt(e,["config.apiKey","timeline.plugins"])),remove:gt(e.remove.bind(e),"remove",dt(e),pt(e,["config.apiKey","timeline.plugins"])),track:gt(e.track.bind(e),"track",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),logEvent:gt(e.logEvent.bind(e),"logEvent",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),identify:gt(e.identify.bind(e),"identify",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),groupIdentify:gt(e.groupIdentify.bind(e),"groupIdentify",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),setGroup:gt(e.setGroup.bind(e),"setGroup",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),revenue:gt(e.revenue.bind(e),"revenue",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),flush:gt(e.flush.bind(e),"flush",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),getUserId:gt(e.getUserId.bind(e),"getUserId",dt(e),pt(e,["config","config.userId"])),setUserId:gt(e.setUserId.bind(e),"setUserId",dt(e),pt(e,["config","config.userId"])),getDeviceId:gt(e.getDeviceId.bind(e),"getDeviceId",dt(e),pt(e,["config","config.deviceId"])),setDeviceId:gt(e.setDeviceId.bind(e),"setDeviceId",dt(e),pt(e,["config","config.deviceId"])),reset:gt(e.reset.bind(e),"reset",dt(e),pt(e,["config","config.userId","config.deviceId"])),getSessionId:gt(e.getSessionId.bind(e),"getSessionId",dt(e),pt(e,["config"])),setSessionId:gt(e.setSessionId.bind(e),"setSessionId",dt(e),pt(e,["config"])),extendSession:gt(e.extendSession.bind(e),"extendSession",dt(e),pt(e,["config"])),setOptOut:gt(e.setOptOut.bind(e),"setOptOut",dt(e),pt(e,["config"])),setTransport:gt(e.setTransport.bind(e),"setTransport",dt(e),pt(e,["config"])),getIdentity:gt(e.getIdentity.bind(e),"getIdentity",dt(e),pt(e,["config"])),setIdentity:gt(e.setIdentity.bind(e),"setIdentity",dt(e),pt(e,["config","config.userId","config.deviceId"])),getOptOut:gt(e.getOptOut.bind(e),"getOptOut",dt(e),pt(e,["config"])),_setDiagnosticsSampleRate:gt(e._setDiagnosticsSampleRate.bind(e),"_setDiagnosticsSampleRate",dt(e),pt(e,["config"])),_enableRequestBodyCompressionExperimental:gt(e._enableRequestBodyCompressionExperimental.bind(e),"_enableRequestBodyCompressionExperimental",dt(e),pt(e,["config"]))}},Js=Ws(),Ys=Js.add,Xs=Js.extendSession,Qs=Js.flush,Zs=Js.getDeviceId,ea=Js.getIdentity,ta=Js.getOptOut,na=Js.getSessionId,ra=Js.getUserId,ia=Js.groupIdentify,oa=Js.identify,sa=Js.init,aa=Js.logEvent,ca=Js.remove,ua=Js.reset,la=Js.revenue,da=Js.setDeviceId,fa=Js.setGroup,pa=Js.setIdentity,ga=Js.setOptOut,ha=Js.setSessionId,va=Js.setTransport,ma=Js.setUserId,ya=Js.track,ba=Js._setDiagnosticsSampleRate,wa=Js._enableRequestBodyCompressionExperimental,Ta=Object.freeze({__proto__:null,AmplitudeBrowser:Gs,Identify:$e,Revenue:et,Types:fi,_enableRequestBodyCompressionExperimental:wa,_setDiagnosticsSampleRate:ba,add:Ys,createInstance:Ws,extendSession:Xs,flush:Qs,getDeviceId:Zs,getIdentity:ea,getOptOut:ta,getSessionId:na,getUserId:ra,groupIdentify:ia,identify:oa,init:sa,logEvent:aa,remove:ca,reset:ua,revenue:la,runQueuedFunctions:function(e,t){Mr(e,t)},setDeviceId:da,setGroup:fa,setIdentity:pa,setOptOut:ga,setSessionId:ha,setTransport:va,setUserId:ma,track:ya});class ka{constructor(){this.isInitialized=!1}static getInstance(){return ka.instance||(ka.instance=new ka),ka.instance}initialize(){if(this.isInitialized||a())return;const e=b.getEnvironment()||"production",t=e===c.PRODUCTION?"52c120d2f5c89ca646fae6649a1ce7ad":"373aa80c38e5bc2a55895a96c8447fef";try{if(!Ta||"function"!=typeof sa)throw new Error("Analytics SDK module not available");const n={defaultTracking:{sessions:!1,pageViews:!1,formInteractions:!1,fileDownloads:!1},logLevel:e!==c.PRODUCTION?tt.Debug:tt.None};sa(t,void 0,n),this.isInitialized=!0,this.track(oe)}catch(e){console.error("Failed to initialize analytics tracking:",e)}}isEnabled(){return this.isInitialized}track(e,t){if(this.isInitialized)try{ya(e,t)}catch(e){console.error("Failed to track analytics event:",e)}}reset(){if(this.isInitialized)try{ua()}catch(e){console.error("Failed to reset analytics:",e)}}}const Ea=ka.getInstance();function Sa(e,t){Ea.track(e,t)}const _a=e=>{Sa(se,e)};class Ia extends i{constructor(e){super(),this.name="EmbedOperationError",this.message=e}}async function Pa({proxyFunction:e,networkCallDescriptor:t,proxyEndpointDescriptor:n}){if(n){const e={...Object.fromEntries([..._(t.options?.headers)??{}])},r=P({...t,options:{...t.options,headers:e}}),i=await fetch(n.path,{method:n.method,headers:n.options.headers,body:r}),o=A(await i.text());if(!i.ok)throw new S({code:i.status,data:o,message:`Error from proxy endpoint: ${i.status} ${i.statusText}`});return o}if(e){const n=Object.fromEntries([..._(t.options?.headers)??{}]),r=P({...t,options:{...t.options,headers:n}});return A(await e(r))}throw new Ia("No proxy function or proxy endpoint descriptor provided for proxy call.")}var Aa;function Oa(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(Aa||(Aa={}));const xa={getCards:async function(e){_a();const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new R("membershipId must be a string");const{accessToken:n,stagingToken:r}=e?.operationSettings||{},i=n||s(),o=await async function({membershipId:e,accessToken:t,stagingToken:n}){const r=function({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({membershipId:e,accessToken:t,stagingToken:n}),{cards:i}=await I(r);return i}({membershipId:t,accessToken:i,stagingToken:r});return o.map((e=>Oa(e)))},getCard:async function({cardSettings:e,operationSettings:t}){!function(e){if(!e)throw new R("cardSettings parameter is required for the called function");if(!e.cardId)throw new R("cardId parameter is required for the called function");const t=L({cardId:e.cardId});if(t.length>0)throw new R(t)}(e);const n=e.cardId,{accessToken:r,stagingToken:i}=t||{},o=r||s(),a=await async function({cardId:e,accessToken:t,stagingToken:n}){const r=function({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({cardId:e,accessToken:t,stagingToken:n}),{cards:i}=await I(r);return i[0]}({cardId:n,accessToken:o,stagingToken:i});return Oa(a)}},Ca=e=>({id:e?.id,slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:parseFloat(e.balance),balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),Ra={getOrganization:async({operationSettings:e}={})=>{const{accessToken:t,stagingToken:n}=e||{},r=t||s(),i=await(async({accessToken:e,stagingToken:t})=>{const n=(({accessToken:e,stagingToken:t})=>({path:"/v2/organization/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}))({accessToken:e,stagingToken:t});return await I(n)})({accessToken:r,stagingToken:n});return{id:(o=i.organization).id,slug:o.slug,legalName:o.legal_name,legalNumber:o.legal_number,legalSector:o.legal_sector,legalRegistrationDate:o.legal_registration_date,legalAddress:o.legal_address,legalForm:o.legal_form,legalCountry:o.legal_country,legalShareCapital:o.legal_share_capital,locale:o.locale,contractSignedAt:o.contract_signed_at,bankAccounts:o.bank_accounts.map(Ca)};var o},getBankAccounts:async({operationSettings:e}={})=>{const{accessToken:t,stagingToken:n}=e||{},r=t||s(),i=await(async({accessToken:e,stagingToken:t})=>{const n=(({accessToken:e,stagingToken:t})=>({path:"/v2/bank_accounts/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}))({accessToken:e,stagingToken:t});return await I(n)})({accessToken:r,stagingToken:n});return i.bank_accounts.map(Ca)}},Da={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},La=e=>{if(!(e=>Object.values(Da).includes(e))(e))throw new R(`currency ${e} is not valid, valid currencies are ${Object.values(Da).join(", ")}`)},Na={GOOD:"good",SERVICE:"service"},Ua={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},Ma=e=>{if(!(e=>Object.values(Ua).includes(e))(e))throw new R(`unit ${e} is not valid, valid units are ${Object.values(Ua).join(", ")}`)},ja=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],qa=[{name:"currency"},{name:"value"}];const Fa=e=>{if(!Object.values(Na).includes(e))throw new R(`type ${e} is not valid, valid types are ${Object.values(Na).join(", ")}`)};const Ba={getPaymentLinkCreationFlowUrl:async({paymentLinkSettings:e,operationSettings:t})=>{const{items:n}=e;!function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{D(e,ja),D(e.unitPrice,qa);const t=[...L({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...N({quantity:e.quantity})].flat();if(t.length>0)throw new R(t);Fa(e.type),La(e.unitPrice.currency),Ma(e.measureUnit)}))}(n);const r=function(e){if(!e?.callbackUrl)throw new R("callbackUrl parameter is required for the payment link creation flow");if("string"!=typeof e.callbackUrl)throw new R("callbackUrl must be a string");if(""===e.callbackUrl.trim())throw new R("callbackUrl cannot be empty");return e.callbackUrl}(e),i=await M({requestSettings:{action:p.PAYMENT_LINK_CREATE,callbackUrl:r},operationSettings:t}),o=new URLSearchParams({...n?{items:JSON.stringify(n)}:{}});return o.toString()?`${i.url}?${o.toString()}`:i.url}};function $a(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function Ha(e){return{name:e.name,iban:e.iban}}const Ka="/v2/sepa",za=`${Ka}/transfers`;async function Va({accessToken:e,stagingToken:t,paginationSettings:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=q(e),o=i.size?`?${i.toString()}`:"";return{path:`${za}${o}`,options:r}}({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:i,meta:o}=await I(r);return{transfers:i,meta:o}}async function Ga({accessToken:e,stagingToken:t,sepaTransferId:n}){const r=function({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${za}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:i}=await I(r);return i}async function Wa({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}){const s=function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}){const s=function(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}(e);return{path:za,options:{method:"POST",headers:{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o},body:{transfer:s,vop_proof_token:t}}}}({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}),{transfer:a}=await I(s);return a}async function Ja({sepaTransferId:e,accessToken:t,stagingToken:n}){const r=function({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${za}/${e}/cancel`,options:{method:"POST",headers:{accessToken:t,stagingToken:n}}}}({sepaTransferId:e,accessToken:t,stagingToken:n});await I(r)}async function Ya({sepaPayee:e,accessToken:t,stagingToken:n}){const r=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${Ka}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await I(r)}function Xa(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Qa(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}const Za="/v2/sepa/bulk_transfers";async function ec({accessToken:e,stagingToken:t,paginationSettings:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=q(e),o=i.size?`?${i.toString()}`:"";return{path:`${Za}${o}`,options:r}}({paginationSettings:n,accessToken:e,stagingToken:t}),{bulk_transfers:i,meta:o}=await I(r);return{bulkTransfers:i,meta:o}}async function tc({accessToken:e,stagingToken:t,bulkTransferId:n}){const r=function({bulkTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Za}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({bulkTransferId:n,accessToken:e,stagingToken:t}),{bulk_transfer:i}=await I(r);return i}async function nc({sepaPayees:e,accessToken:t,stagingToken:n}){const r=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${Ka}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map(Ha)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await I(r)}function rc(e){if(!e)throw new R("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new R("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new R("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new R("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new R(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new R(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new R(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new R(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=L({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),r=N({amount:e.amount}),i=[...n,...r].flat();if(i.length>0)throw new R(i);if(e.amount>d&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new R(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const ic={requiresUI:!1};function oc(e,{requiresUI:t}=ic){const n=e?.uiParentElementId||E.getUIParentElementId();if(t){if(!n)throw new R("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");if(!["string","function"].includes(typeof n))throw new R("operationSettings.uiParentElementId must be a string or a function returning an HTMLElement")}const r=e?.mfaPreference||E.getMFAPreference();if(r){const e=(i=Object.values(l),b.isProductionEnvironment()?i.filter((e=>e!==l.MOCK)):i);if(!e.includes(r))throw new R(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(b.isProductionEnvironment()&&r===l.MOCK)throw new R("operationSettings.mfaPreference cannot be set to mock in production environment.")}var i;const o=e?.debugMode||E.getDebugMode();if(void 0!==o&&"boolean"!=typeof o)throw new R("operationSettings.debugMode must be a boolean.");const s=e?.proxyRequestFunction||E.getProxyRequestFunction();if(s&&"function"!=typeof s)throw new R("operationSettings.proxyRequestFunction must be a function.");const a=e?.proxyEndpointDescriptor||E.getProxyEndpointDescriptor();if(a&&!a.path)throw new R("operationSettings.proxyEndpointDescriptor must have at least a string-formatted path property.");return{...e,uiParentElementId:n,mfaPreference:r,debugMode:o,proxyRequestFunction:s,proxyEndpointDescriptor:a}}async function sc({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:await async function({beneficiarySettings:e,operationSettings:t}){const n=re(e?.beneficiaryId),{proxyEndpointDescriptor:r,accessToken:i,stagingToken:o}=oc(t||{});if(r){const e=X({beneficiaryId:n});return G((await Pa({proxyEndpointDescriptor:r,networkCallDescriptor:e})).body.beneficiary)}{const e=i||s();return G(await Q({beneficiaryId:n,accessToken:e,stagingToken:o}))}}({beneficiarySettings:{beneficiaryId:e?.beneficiaryId},operationSettings:t})}function ac(e,t){const n=t?.locale||T.getLocale(),r=new URL(e);return n&&r.searchParams.append("lang",n),t?.mfaPreference&&r.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&r.searchParams.append("idempotencyKey",t.idempotencyKey),r.toString()}const cc=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];const uc={getSepaTransfers:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||s(),o=await Va({accessToken:i,stagingToken:n,paginationSettings:r}),a=o.transfers.map($a),c=F(o.meta);return{transfers:a,...c?{meta:c}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new R("sepaTransferId must be a string");return e}(e?.sepaTransferId),{accessToken:r,stagingToken:i}=t||{},o=r||s();return $a(await Ga({sepaTransferId:n,accessToken:o,stagingToken:i}))},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}=t||{},a=n||s(),c=o||V();!function(e){if(!e)throw new R("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new R("sepaTransferSettings must be an object");if(!e.beneficiaryId&&!e.beneficiary)throw new R("Either beneficiaryId or beneficiary must be provided");const t=L({beneficiaryId:e.beneficiaryId});if(t.length>0)throw new R(t)}(e);const u=e?.beneficiary?e.beneficiary:await sc({sepaTransferSettings:e,operationSettings:t}),l={name:u.name,iban:u.iban},p=await Ya({sepaPayee:l,accessToken:a,stagingToken:r}),g=yield(h=p,{matchResult:h.match_result,matchedName:h.matched_name});var h;let v;if("string"==typeof g){if(g===f)return}else{if(g.vopDecision===f)return;v=g.sepaTransferSettings}const m={...e,...v};!function(e){if(!e)throw new R("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new R("sepaTransferSettings must be an object");D(e,cc);const t=[...L({bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...N({amount:e.amount})].flat();if(t.length>0)throw new R(t);if(e.amount>d&&(!e.attachmentIds||0===e.attachmentIds.length))throw new R("Attachments are required for transfers over €30,000")}(m);const y={...m,beneficiary:u};return{transfer:$a(await Wa({transfer:y,vopProofToken:p.proof_token.token,accessToken:a,stagingToken:r,scaSessionToken:i,idempotencyKey:c})),meta:{idempotencyKey:c}}},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new R("sepaTransferId must be a string");return e}(e?.sepaTransferId),{accessToken:r,stagingToken:i}=t||{},o=r||s();await Ja({sepaTransferId:n,accessToken:o,stagingToken:i})},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new R("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new R("callbackUrl must be a string");return e.callbackUrl}(e),{accessToken:r,stagingToken:i}=t||{},o=r||s(),a=await async function({requestSettings:e,operationSettings:t}){U(e);const{proxyEndpointDescriptor:n,stagingToken:r}=oc(t||{});if(n){const t=O({stagingToken:r,action:e.action,callbackUrl:e.callbackUrl});return C((await Pa({proxyEndpointDescriptor:n,networkCallDescriptor:t})).body)}{const n=t?.accessToken||s();return C(await x({accessToken:n,stagingToken:r,action:e.action,callbackUrl:e.callbackUrl}))}}({requestSettings:{action:p.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:{stagingToken:i,accessToken:o}});return{...a,url:ac(a.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||s(),o=await ec({accessToken:i,stagingToken:n,paginationSettings:r}),a=o.bulkTransfers?.map(Xa),c=F(o.meta);return{bulkTransfers:a,...c?{meta:c}:{}}},getBulkTransfer:async function({bulkTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new R("bulkTransferId must be a string.");return e}(e?.bulkTransferId),{accessToken:r,stagingToken:i}=t||{},o=r||s();return Xa(await tc({accessToken:o,stagingToken:i,bulkTransferId:n}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}=t||{},a=n||s(),c=o||V(),u=rc(e),l=new Map;for(const e of u.bulkTransfers){const t=e.beneficiary;if(t){const e=t.iban;e&&!l.has(e)&&l.set(e,{name:t.name,iban:e})}}const d=Array.from(l.values()),p=await nc({sepaPayees:d,accessToken:a,stagingToken:r});if((yield p.requests.map(Qa))===f)return;const g=await async function({bulkTransfers:e,accessToken:t,stagingToken:n,scaSessionToken:r,bankAccountId:i,idempotencyKey:o}){const s={method:"POST",headers:{..._({accessToken:t,stagingToken:n,scaSessionToken:r,idempotencyKey:o})},body:JSON.stringify({bank_account_id:i,bulk_transfers:e.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))})},a=new URL(`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${Za}`),c=await fetch(a,s),u=await c.json();if(!c.ok||u.errors)throw new S({message:u.errors?u.errors.map((e=>`${e.code}: ${e.detail}`)).join(", "):"Failed to create SEPA bulk transfer"});return u.bulk_transfer}({bulkTransfers:u.bulkTransfers,bankAccountId:u.bankAccountId,accessToken:a,stagingToken:r,scaSessionToken:i,idempotencyKey:c});return{bulkTransfer:Xa(g),meta:{idempotencyKey:c}}}}},lc="/v2/transactions";async function dc(e){const t=function({bankAccountId:e,iban:t,status:n,updatedAtFrom:r,updatedAtTo:i,emittedAtFrom:o,emittedAtTo:s,settledAtFrom:a,settledAtTo:c,side:u,operationType:l,withAttachments:d,paginationSettings:f,accessToken:p,stagingToken:g}){const h={method:"GET",headers:{accessToken:p,stagingToken:g}},v=new URLSearchParams;e&&v.append("bank_account_id",e),t&&v.append("iban",t),n&&v.append("status",n),r&&v.append("updated_at_from",r),i&&v.append("updated_at_to",i),o&&v.append("emitted_at_from",o),s&&v.append("emitted_at_to",s),a&&v.append("settled_at_from",a),c&&v.append("settled_at_to",c),u&&v.append("side",u),l&&v.append("operation_type",l),void 0!==d&&v.append("with_attachments",String(d));const m=q(f);for(const[e,t]of m)v.append(e,t);const y=v.toString();return{path:`${lc}${y?`?${y}`:""}`,options:h}}(e),{transactions:n,meta:r}=await I(t);return{transactions:n,meta:r}}async function fc(e){const t=function({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${lc}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}(e),{transaction:n}=await I(t);return n}function pc(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const gc={getTransactions:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i={...e?.transactionSettings||{},paginationSettings:r},o=t||s(),a=await dc({...i,accessToken:o,stagingToken:n});return{transactions:a.transactions.map(pc),meta:F(a.meta)}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r}=t||{},{transactionId:i}=function(e){if(!e)throw new R("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new R("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new R("transactionSettings.transactionId must be a string.");return e}(e),o=n||s();return pc(await fc({transactionId:i,accessToken:o,stagingToken:r}))}};e.authLinks=j,e.beneficiaries=ie,e.cards=xa,e.organizations=Ra,e.paymentLinks=Ba,e.sepaTransfers=uc,e.transactions=gc}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).QontoEmbedServer={})}(this,(function(e){"use strict";function t(e,t){return t.forEach((function(t){t&&"string"!=typeof t&&!Array.isArray(t)&&Object.keys(t).forEach((function(n){if("default"!==n&&!(n in e)){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}}))})),Object.freeze(e)}class n{constructor(){this.accessToken=null,this.stagingToken=null}static getInstance(){return n.instance||(n.instance=new n),n.instance}setAccessToken(e){this.accessToken=e}getAccessToken(){return this.accessToken}hasAccessToken(){return null!==this.accessToken&&""!==this.accessToken}clearAccessToken(){this.accessToken=null}setStagingToken(e){this.stagingToken=e}getStagingToken(){return this.stagingToken}hasStagingToken(){return null!==this.stagingToken&&""!==this.stagingToken}clearStagingToken(){this.stagingToken=null}}const r=n.getInstance();class i extends Error{constructor(){super(),this.stack=""}toString(){return`${this.name}: ${this.message}`}}class o extends i{constructor(){super(),this.name="AuthenticationError",this.message="Authentication failed due to missing or invalid authentication method. Provide either a proxyEndpointDescriptor or accessToken, either as parameters or by calling the initialize function first."}}function a(){if(!r.hasAccessToken())throw new o;return r.getAccessToken()}function s(){return!("undefined"!=typeof window&&"undefined"!=typeof document)}const c={PRODUCTION:"production",STAGING:"staging",LOCAL:"local"},u={MASTER:"master",SANDBOX:"sandbox",QA:"qa"},l={PASSKEY:"passkey",SMS_OTP:"sms-otp",PAIRED_DEVICE:"paired-device",MOCK:"mock"},d=3e4,f="REJECT",p={CARD_DISPLAY:"display_card",PAYMENT_LINK_CREATE:"create_payment_link",SEPA_TRANSFER_CREATE:"create_sepa_transfer"},g="https://embed.qonto.com",h="https://embed-js{branch}.staging.qonto.co",v="https://embed.dev.qonto.co",m={[c.PRODUCTION]:{EMBED_BASE_URL:g,EMBED_URL:`${g}/connect`,THIRD_PARTY_API_URL:"https://thirdparty.qonto.com"},[c.STAGING]:{EMBED_BASE_URL:h,EMBED_URL:`${h}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"},[c.LOCAL]:{EMBED_BASE_URL:v,EMBED_URL:`${v}/connect`,THIRD_PARTY_API_URL:"https://thirdparty{branch}.staging.qonto.co"}};class y{constructor(){let e,t;this.environment=c.PRODUCTION,this.branch=u.SANDBOX,"undefined"!=typeof process&&process.env&&(e=process.env.QONTO_EMBED_ENVIRONMENT,t=process.env.QONTO_EMBED_BRANCH),this.environment=Object.values(c).includes(e)?e:c.PRODUCTION,this.branch=Object.values(u).includes(t)?t:u.SANDBOX}static getInstance(){return y.instance||(y.instance=new y),y.instance}setEnvironment(e){this.environment=e}getEnvironment(){return this.environment}isProductionEnvironment(){return this.environment===c.PRODUCTION}setBranch(e){this.branch=e}getBranch(){return this.branch}clear(){this.environment=c.PRODUCTION,this.branch=u.MASTER}getEnvironmentUrls(){if(this.environment===c.PRODUCTION)return m.production;{const e=m[this.environment];return Object.entries(e).reduce(((e,[t,n])=>({...e,[t]:n.replace("{branch}",`-${this.branch}`)})),{})}}}const b=y.getInstance();class T{constructor(){this.currentLocale="en"}static getInstance(){return T.instance||(T.instance=new T),T.instance}setLocale(e){this.currentLocale=e}getLocale(){return this.currentLocale}setDefaultLocale(){this.currentLocale="en"}}const w=T.getInstance();class k{constructor(){this.mfaPreference=l.PASSKEY,this.debugMode=!1}static getInstance(){return k.instance||(k.instance=new k),k.instance}setSettings(e){e.uiParentElementId&&(this.uiParentElementId=e.uiParentElementId),e.mfaPreference&&(this.mfaPreference=e.mfaPreference),e.debugMode&&(this.debugMode=e.debugMode),e.proxyEndpointDescriptor&&(this.proxyEndpointDescriptor=e.proxyEndpointDescriptor)}getUIParentElementId(){return this.uiParentElementId}getMFAPreference(){return this.mfaPreference}getDebugMode(){return this.debugMode}getProxyEndpointDescriptor(){return this.proxyEndpointDescriptor}clearSettings(){this.uiParentElementId=void 0,this.mfaPreference=l.PASSKEY,this.debugMode=!1,this.proxyEndpointDescriptor=void 0}getSettings(){return{uiParentElementId:this.uiParentElementId,mfaPreference:this.mfaPreference,debugMode:this.debugMode}}}const E=k.getInstance();class S extends i{constructor({message:e,data:t,code:n}){super(),this.code=500;const r=Array.isArray(e)?e.join("\n"):e;this.name="EmbedApiError",this.message=`The call to the Embed API failed with the following errors:\n${r}`,this.data=t||{},this.code=n||this.code}}function _({accessToken:e,stagingToken:t,idempotencyKey:n,mfaPreference:i,scaSessionToken:o}){const a=new Headers;a.append("Authorization",`Bearer ${e}`);const s=t||r.getStagingToken();s&&a.append("X-Qonto-Staging-Token",s),n&&a.append("X-Qonto-Idempotency-Key",n);const c=i||E.getMFAPreference();return c&&a.append("X-Qonto-2fa-Preference",c),o&&a.append("X-Qonto-SCA-Session-Token",o),a.append("Content-Type","application/json"),a.append("Accept-Language",w.getLocale()),a}async function I({path:e,options:t}){const n=`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${e}`,r=await fetch(n,{...t,headers:_(t.headers),body:t.body?JSON.stringify(t.body):void 0});if(204===r.status)return;const i=await r.json();if(!r.ok)throw i.errors?new S({code:r.status,message:i.errors.map((e=>`${e.code}: ${e.detail}`))}):new S({code:r.status,message:`${i.code}: ${i.detail}`,data:i});return i}function P(e){const t={method:e.options.method,headers:e.options.headers,path:e.path,payload:e.options?.body},n=JSON.stringify(t);return r=n,s()?Buffer.from(r).toString("base64"):btoa(r);var r}function A(e){return JSON.parse((t=e,s()?Buffer.from(t,"base64").toString("utf-8"):atob(t)));var t}function O({accessToken:e,stagingToken:t,action:n,callbackUrl:r}){const i={post_authn_action:n};return r&&(i.callback_url=r),{path:"/v1/embed_auth_links",options:{method:"POST",headers:{accessToken:e,stagingToken:t},body:{embed_auth_link:i}}}}async function C(e){const t=O({accessToken:e.accessToken,stagingToken:e.stagingToken,action:e.action,callbackUrl:e.callbackUrl}),{embed_auth_link:n}=await I(t);return{url:n.url,post_authn_action:n.post_authn_action,callback_url:n.callback_url,expired_at:n.expired_at,used_at:n.used_at}}function x(e){return{url:e.url,postAuthAction:e.post_authn_action,callbackUrl:e.callback_url,expiresAt:e.expired_at,usedAt:e.used_at}}class R extends i{constructor(e){super(),this.name="InvalidParametersError",this.invalidParameters=Array.isArray(e)?e:[e],this.message=`Invalid parameters were passed to the function:\n${this.invalidParameters.map((e=>e)).join("\n")}`}}function D(e,t){const n=t.filter((t=>t.requiredIfPresent?!e[t.name]&&e[t.requiredIfPresent]:void 0===e[t.name])).map((e=>e.name));if(n.length>0)throw new R(n.map((e=>`Missing required parameter: ${e}`)))}function L(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"string"!=typeof e)).map((([e])=>`${e} must be a string`))}function N(e){return Object.entries(e).filter((([,e])=>void 0!==e)).filter((([,e])=>"number"!=typeof e)).map((([e])=>`${e} must be a number`))}function U(e){if(!e||"object"!=typeof e)throw new R("requestSettings must be an object");const t=e,{action:n,callbackUrl:r}=e;D(t,[{name:"action"}]);const i=L(t),o=Object.values(p);if(o.includes(n)||i.push(`action must be one of ${o.join(", ")}`),i.length>0)throw new R(i);if(void 0!==r&&""===r.trim())throw new R("callbackUrl cannot be empty")}async function M({requestSettings:e,operationSettings:t}){U(e);const{accessToken:n,stagingToken:r}=t||{},i=n||a();return x(await C({accessToken:i,stagingToken:r,action:e.action,callbackUrl:e.callbackUrl}))}const j={request:M};function q(e){const t=new URLSearchParams;return e?.page&&t.append("page",e.page.toString()),e?.itemsPerPage&&t.append("per_page",e.itemsPerPage.toString()),t}function F(e){if(e)return{totalItems:e?.total_count,totalPages:e?.total_pages,currentPage:e?.current_page,itemsPerPage:e?.per_page,previousPage:e?.prev_page||null,nextPage:e?.next_page||null}}const B=[];for(let e=0;e<256;++e)B.push((e+256).toString(16).slice(1));let $;const H=new Uint8Array(16);var K={randomUUID:"undefined"!=typeof crypto&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function z(e,t,n){const r=(e=e||{}).random??e.rng?.()??function(){if(!$){if("undefined"==typeof crypto||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");$=crypto.getRandomValues.bind(crypto)}return $(H)}();if(r.length<16)throw new Error("Random bytes length must be >= 16");return r[6]=15&r[6]|64,r[8]=63&r[8]|128,function(e,t=0){return(B[e[t+0]]+B[e[t+1]]+B[e[t+2]]+B[e[t+3]]+"-"+B[e[t+4]]+B[e[t+5]]+"-"+B[e[t+6]]+B[e[t+7]]+"-"+B[e[t+8]]+B[e[t+9]]+"-"+B[e[t+10]]+B[e[t+11]]+B[e[t+12]]+B[e[t+13]]+B[e[t+14]]+B[e[t+15]]).toLowerCase()}(r)}function G(e,t,n){return K.randomUUID&&!e?K.randomUUID():z(e)}function V(e){return{id:e.id,name:e.name,email:e.email,activityTag:e.activity_tag,iban:e.iban,bic:e.bic,currency:e.currency,status:e.status,trusted:e.trusted,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at)}}function W(e){return{name:e.name,...e.email&&{email:e.email},...e.activityTag&&{activity_tag:e.activityTag},iban:e.iban,...e.bic&&{bic:e.bic}}}const J="/v2/sepa/beneficiaries";async function Y({paginationSettings:e,accessToken:t,stagingToken:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=q(e),o=i.size?`?${i.toString()}`:"";return{path:`${J}${o}`,options:r}}({paginationSettings:e,accessToken:t,stagingToken:n}),{beneficiaries:i,meta:o}=await I(r);return{beneficiaries:i,meta:o}}function X({beneficiaryId:e,accessToken:t,stagingToken:n}){return{path:`${J}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}async function Q({accessToken:e,stagingToken:t,beneficiaryId:n}){const r=X({beneficiaryId:n,accessToken:e,stagingToken:t}),{beneficiary:i}=await I(r);return i}async function Z({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r=G()}){const i=function({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r=G()}){return{path:J,options:{method:"POST",headers:{accessToken:t,stagingToken:n,idempotencyKey:r},body:{beneficiary:W(e)}}}}({beneficiary:e,accessToken:t,stagingToken:n,idempotencyKey:r}),{beneficiary:o}=await I(i);return o}async function ee({beneficiaryIds:e,accessToken:t,stagingToken:n}){const r=function({beneficiaryIds:e,accessToken:t,stagingToken:n}){return{path:`${J}/untrust`,options:{method:"PATCH",headers:{accessToken:t,stagingToken:n},body:{ids:e}}}}({beneficiaryIds:e,accessToken:t,stagingToken:n}),{beneficiaries:i}=await I(r);return i}async function te({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}){const o=function({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}){const{name:o,email:a,activityTag:s}=e,c={method:"PATCH",headers:{accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i},body:{beneficiary:{name:o,email:a,activity_tag:s}}};return{path:`${J}/${e.id}`,options:c}}({beneficiaryParamsBeingEdited:e,accessToken:t,stagingToken:n,idempotencyKey:r,mfaPreference:i}),{beneficiary:a}=await I(o);return a}const ne=[{name:"name"},{name:"iban"}];function re(e){if(!e)throw new R("beneficiaryId parameter is required for the called function");if(e&&"string"!=typeof e)throw new R("beneficiaryId must be a string");return e}const ie={getBeneficiaries:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||a(),o=await Y({accessToken:i,stagingToken:n,paginationSettings:r}),s=o.beneficiaries.map((e=>V(e))),c=F(o.meta);return{beneficiaries:s,...c?{meta:c}:{}}},getBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=re(e?.beneficiaryId),{accessToken:r,stagingToken:i}=t||{},o=r||a();return V(await Q({beneficiaryId:n,accessToken:o,stagingToken:i}))},addBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("beneficiary parameter is required for the called function");if("object"!=typeof e)throw new R("beneficiary must be an object");D(e,ne);const t=L({name:e.name,iban:e.iban,email:e.email,activityTag:e.activityTag,bic:e.bic});if(t.length>0)throw new R(t);return e}(e),{accessToken:r,stagingToken:i,idempotencyKey:o}=t||{},s=r||a();return V(await Z({beneficiary:n,accessToken:s,stagingToken:i,idempotencyKey:o}))},updateBeneficiary:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){const{id:t,name:n,email:r,activityTag:i}=e||{};if(!t)throw new R("Invalid parameters were passed to the function:\nA beneficiary ID is required for the called function");if(!n&&!r&&!i)throw new R("Invalid parameters were passed to the function:\nAt least one of the following properties must be provided: name, email, activityTag");const o=L({name:n,email:r,activityTag:i});if(o.length>0)throw new R(o);return{id:t,name:n,email:r,activityTag:i}}(e),{accessToken:r,stagingToken:i,idempotencyKey:o,mfaPreference:s}=t||{},c={beneficiaryParamsBeingEdited:n,accessToken:r||a(),stagingToken:i,idempotencyKey:o,mfaPreference:s};return V(await te(c))},untrustBeneficiaries:async function({beneficiarySettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("beneficiaryIds parameter is required for the called function");if(!Array.isArray(e)||!e.every((e=>"string"==typeof e)))throw new R("beneficiaryIds must be an array of strings");return e}(e?.beneficiaryIds),{accessToken:r,stagingToken:i}=t||{},o=r||a();return(await ee({beneficiaryIds:n,accessToken:o,stagingToken:i})).map(V)}},oe="SDK Initialized",ae="Cards List";var se=function(e,t){return se=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},se(e,t)};function ce(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}se(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var ue,le,de=function(){return de=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},de.apply(this,arguments)};function fe(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function pe(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{c(r.next(e))}catch(e){o(e)}}function s(e){try{c(r.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))}function ge(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(i=o.trys,(i=i.length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}function he(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function ve(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}function me(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;i<o;i++)!r&&i in t||(r||(r=Array.prototype.slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||Array.prototype.slice.call(t))}"function"==typeof SuppressedError&&SuppressedError,function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(ue||(ue={})),function(e){e.IDENTIFY="$identify",e.GROUP_IDENTIFY="$groupidentify",e.REVENUE="revenue_amount"}(le||(le={}));var ye,be="AMP",Te="".concat(be,"_unsent"),we="$default_instance",ke="https://api2.amplitude.com/2/httpapi",Ee="https://api.eu.amplitude.com/2/httpapi",Se="https://api2.amplitude.com/batch",_e="https://api.eu.amplitude.com/batch",Ie="dclid",Pe="fbclid",Ae="gbraid",Oe="gclid",Ce="ko_click_id",xe="li_fat_id",Re="msclkid",De="rdt_cid",Le="ttclid",Ne="twclid",Ue="wbraid",Me={utm_campaign:void 0,utm_content:void 0,utm_id:void 0,utm_medium:void 0,utm_source:void 0,utm_term:void 0,referrer:void 0,referring_domain:void 0,dclid:void 0,gbraid:void 0,gclid:void 0,fbclid:void 0,ko_click_id:void 0,li_fat_id:void 0,msclkid:void 0,rdt_cid:void 0,ttclid:void 0,twclid:void 0,wbraid:void 0},je=["access-control-allow-origin","access-control-allow-credentials","access-control-expose-headers","access-control-max-age","access-control-allow-methods","access-control-allow-headers","accept-patch","accept-ranges","age","allow","alt-svc","cache-control","connection","content-disposition","content-encoding","content-language","content-length","content-location","content-md5","content-range","content-type","date","delta-base","etag","expires","im","last-modified","link","location","permanent","p3p","pragma","proxy-authenticate","public-key-pins","retry-after","server","status","strict-transport-security","trailer","transfer-encoding","tk","upgrade","vary","via","warning","www-authenticate","x-b3-traceid","x-frame-options"],qe=["authorization","cookie","set-cookie"],Fe=function(e){if(Object.keys(e).length>1e3)return!1;for(var t in e){var n=e[t];if(!Be(t,n))return!1}return!0},Be=function(e,t){var n,r;if("string"!=typeof e)return!1;if(Array.isArray(t)){var i=!0;try{for(var o=he(t),a=o.next();!a.done;a=o.next()){var s=a.value;if(Array.isArray(s))return!1;if("object"==typeof s)i=i&&Fe(s);else if(!["number","string"].includes(typeof s))return!1;if(!i)return!1}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}}else{if(null==t)return!1;if("object"==typeof t)return Fe(t);if(!["number","string","boolean"].includes(typeof t))return!1}return!0},$e=function(){function e(){this._propertySet=new Set,this._properties={}}return e.prototype.getUserProperties=function(){return de({},this._properties)},e.prototype.set=function(e,t){return this._safeSet(ye.SET,e,t),this},e.prototype.setOnce=function(e,t){return this._safeSet(ye.SET_ONCE,e,t),this},e.prototype.append=function(e,t){return this._safeSet(ye.APPEND,e,t),this},e.prototype.prepend=function(e,t){return this._safeSet(ye.PREPEND,e,t),this},e.prototype.postInsert=function(e,t){return this._safeSet(ye.POSTINSERT,e,t),this},e.prototype.preInsert=function(e,t){return this._safeSet(ye.PREINSERT,e,t),this},e.prototype.remove=function(e,t){return this._safeSet(ye.REMOVE,e,t),this},e.prototype.add=function(e,t){return this._safeSet(ye.ADD,e,t),this},e.prototype.unset=function(e){return this._safeSet(ye.UNSET,e,"-"),this},e.prototype.clearAll=function(){return this._properties={},this._properties[ye.CLEAR_ALL]="-",this},e.prototype._safeSet=function(e,t,n){if(this._validate(e,t,n)){var r=this._properties[e];return void 0===r&&(r={},this._properties[e]=r),r[t]=n,this._propertySet.add(t),!0}return!1},e.prototype._validate=function(e,t,n){return void 0===this._properties[ye.CLEAR_ALL]&&(!this._propertySet.has(t)&&(e===ye.ADD?"number"==typeof n:e===ye.UNSET||e===ye.REMOVE||Be(t,n)))},e}();!function(e){e.SET="$set",e.SET_ONCE="$setOnce",e.ADD="$add",e.APPEND="$append",e.PREPEND="$prepend",e.REMOVE="$remove",e.PREINSERT="$preInsert",e.POSTINSERT="$postInsert",e.UNSET="$unset",e.CLEAR_ALL="$clearAll"}(ye||(ye={}));var He,Ke=[ye.CLEAR_ALL,ye.UNSET,ye.SET,ye.SET_ONCE,ye.ADD,ye.APPEND,ye.PREPEND,ye.PREINSERT,ye.POSTINSERT,ye.REMOVE];!function(e){e.Unknown="unknown",e.Skipped="skipped",e.Success="success",e.RateLimit="rate_limit",e.PayloadTooLarge="payload_too_large",e.Invalid="invalid",e.Failed="failed",e.Timeout="Timeout",e.SystemError="SystemError"}(He||(He={}));var ze,Ge=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=He.Unknown),{event:e,code:t,message:n}},Ve=function(){var e="ampIntegrationContext";return"undefined"!=typeof globalThis&&void 0!==globalThis[e]?globalThis[e]:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof self?self:"undefined"!=typeof global?global:void 0},We=me([],ve(Array(256).keys()),!1).map((function(e){return e.toString(16).padStart(2,"0")})),Je=function(e){var t,n=Ve();if(!(null===(t=null==n?void 0:n.crypto)||void 0===t?void 0:t.getRandomValues))return function(e){return e?(e^16*Math.random()>>e/4).toString(16):(String(1e7)+String(-1e3)+String(-4e3)+String(-8e3)+String(-1e11)).replace(/[018]/g,Je)}(e);var r=n.crypto.getRandomValues(new Uint8Array(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,me([],ve(r.entries()),!1).map((function(e){var t=ve(e,2),n=t[0],r=t[1];return[4,6,8,10].includes(n)?"-".concat(We[r]):We[r]})).join("")},Ye=function(){function e(e){this.client=e,this.queue=[],this.applying=!1,this.plugins=[],this._optOutListeners=[]}return e.prototype.register=function(e,t){var n,r;return pe(this,void 0,void 0,(function(){return ge(this,(function(i){switch(i.label){case 0:return this.plugins.some((function(t){return t.name===e.name}))?(this.loggerProvider.warn("Plugin with name ".concat(e.name," already exists, skipping registration")),[2]):(void 0===e.name&&(e.name=Je(),this.loggerProvider.warn("Plugin name is undefined. \n Generating a random UUID for plugin name: ".concat(e.name,". \n Set a name for the plugin to prevent it from being added multiple times."))),e.type=null!==(n=e.type)&&void 0!==n?n:"enrichment",[4,null===(r=e.setup)||void 0===r?void 0:r.call(e,t,this.client)]);case 1:return i.sent(),this.plugins.push(e),[2]}}))}))},e.prototype.deregister=function(e,t){var n;return pe(this,void 0,void 0,(function(){var r,i;return ge(this,(function(o){switch(o.label){case 0:return r=this.plugins.findIndex((function(t){return t.name===e})),-1===r?(t.loggerProvider.warn("Plugin with name ".concat(e," does not exist, skipping deregistration")),[2]):(i=this.plugins[r],this.plugins.splice(r,1),[4,null===(n=i.teardown)||void 0===n?void 0:n.call(i)]);case 1:return o.sent(),[2]}}))}))},e.prototype.reset=function(e){this._clearOptOutListeners(),this.applying=!1,this.plugins.map((function(e){var t;return null===(t=e.teardown)||void 0===t?void 0:t.call(e)})),this.plugins=[],this.client=e},e.prototype.push=function(e){var t=this;return new Promise((function(n){t.queue.push([e,n]),t.scheduleApply(0)}))},e.prototype.scheduleApply=function(e){var t=this;this.applying||(this.applying=!0,setTimeout((function(){t.apply(t.queue.shift()).then((function(){t.applying=!1,t.queue.length>0&&t.scheduleApply(0)}))}),e))},e.prototype.apply=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T;return ge(this,(function(w){switch(w.label){case 0:if(!e)return[2];t=ve(e,1),n=t[0],r=ve(e,2),i=r[1],this.loggerProvider.log("Timeline.apply: Initial event",n),o=this.plugins.filter((function(e){return"before"===e.type})),w.label=1;case 1:w.trys.push([1,6,7,8]),a=he(o),s=a.next(),w.label=2;case 2:return s.done?[3,5]:(f=s.value).execute?[4,f.execute(de({},n))]:[3,4];case 3:if(null===(p=w.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by before plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),i({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after before plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),w.label=4;case 4:return s=a.next(),[3,2];case 5:return[3,8];case 6:return c=w.sent(),m={error:c},[3,8];case 7:try{s&&!s.done&&(y=a.return)&&y.call(a)}finally{if(m)throw m.error}return[7];case 8:u=this.plugins.filter((function(e){return"enrichment"===e.type||void 0===e.type})),w.label=9;case 9:w.trys.push([9,14,15,16]),l=he(u),d=l.next(),w.label=10;case 10:return d.done?[3,13]:(f=d.value).execute?[4,f.execute(de({},n))]:[3,12];case 11:if(null===(p=w.sent()))return this.loggerProvider.log("Timeline.apply: Event filtered out by enrichment plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),i({event:n,code:0,message:""}),[2];n=p,this.loggerProvider.log("Timeline.apply: Event after enrichment plugin '".concat(String(f.name),"', event: ").concat(JSON.stringify(n))),w.label=12;case 12:return d=l.next(),[3,10];case 13:return[3,16];case 14:return g=w.sent(),b={error:g},[3,16];case 15:try{d&&!d.done&&(T=l.return)&&T.call(l)}finally{if(b)throw b.error}return[7];case 16:return h=this.plugins.filter((function(e){return"destination"===e.type})),this.loggerProvider.log("Timeline.apply: Final event before destinations, event: ".concat(JSON.stringify(n))),v=h.map((function(e){var t=de({},n);return e.execute(t).catch((function(e){return Ge(t,0,String(e))}))})),Promise.all(v).then((function(e){var t=ve(e,1)[0]||Ge(n,100,"Event not tracked, no destination plugins on the instance");i(t)})),[2]}}))}))},e.prototype.flush=function(){return pe(this,void 0,void 0,(function(){var e,t,n,r=this;return ge(this,(function(i){switch(i.label){case 0:return e=this.queue,this.queue=[],[4,Promise.all(e.map((function(e){return r.apply(e)})))];case 1:return i.sent(),t=this.plugins.filter((function(e){return"destination"===e.type})),n=t.map((function(e){return e.flush&&e.flush()})),[4,Promise.all(n)];case 2:return i.sent(),[2]}}))}))},e.prototype.addOptOutListener=function(e){this._optOutListeners.push(e)},e.prototype._clearOptOutListeners=function(){this._optOutListeners=[]},e.prototype.onIdentityChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onIdentityChanged)||void 0===n||n.call(t,e)}))},e.prototype.onSessionIdChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onSessionIdChanged)||void 0===n||n.call(t,e)}))},e.prototype.onOptOutChanged=function(e){this.plugins.forEach((function(t){var n;null===(n=t.onOptOutChanged)||void 0===n||n.call(t,e)})),this._callOptOutListeners(e)},e.prototype._callOptOutListeners=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o,a,s;return ge(this,(function(c){switch(c.label){case 0:c.trys.push([0,7,8,9]),t=he(this._optOutListeners),n=t.next(),c.label=1;case 1:if(n.done)return[3,6];r=n.value,c.label=2;case 2:return c.trys.push([2,4,,5]),[4,r(e)];case 3:return c.sent(),[3,5];case 4:return i=c.sent(),this.loggerProvider.error("Error calling optOut listener",i),[3,5];case 5:return n=t.next(),[3,1];case 6:return[3,9];case 7:return o=c.sent(),a={error:o},[3,9];case 8:try{n&&!n.done&&(s=t.return)&&s.call(t)}finally{if(a)throw a.error}return[7];case 9:return[2]}}))}))},e.prototype.onReset=function(){this.plugins.forEach((function(e){var t;null===(t=e.onReset)||void 0===t||t.call(e)}))},e}(),Xe=function(e,t){return de(de({},t),{event_type:le.IDENTIFY,user_properties:e.getUserProperties()})},Qe=function(e){return{promise:e||Promise.resolve()}},Ze=function(){function e(e){void 0===e&&(e="$default"),this.initializing=!1,this.isReady=!1,this.q=[],this.dispatchQ=[],this.logEvent=this.track.bind(this),this.timeline=new Ye(this),this.name=e}return e.prototype._init=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){switch(t.label){case 0:return this.config=e,this.timeline.reset(this),this.timeline.loggerProvider=this.config.loggerProvider,[4,this.runQueuedFunctions("q")];case 1:return t.sent(),this.isReady=!0,[2]}}))}))},e.prototype.runQueuedFunctions=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o,a,s,c;return ge(this,(function(u){switch(u.label){case 0:t=this[e],this[e]=[],u.label=1;case 1:u.trys.push([1,8,9,10]),n=he(t),r=n.next(),u.label=2;case 2:return r.done?[3,7]:(i=r.value,(o=i())&&"promise"in o?[4,o.promise]:[3,4]);case 3:return u.sent(),[3,6];case 4:return[4,o];case 5:u.sent(),u.label=6;case 6:return r=n.next(),[3,2];case 7:return[3,10];case 8:return a=u.sent(),s={error:a},[3,10];case 9:try{r&&!r.done&&(c=n.return)&&c.call(n)}finally{if(s)throw s.error}return[7];case 10:return this[e].length?[4,this.runQueuedFunctions(e)]:[3,12];case 11:u.sent(),u.label=12;case 12:return[2]}}))}))},e.prototype.track=function(e,t,n){var r=function(e,t,n){return de(de(de({},"string"==typeof e?{event_type:e}:e),n),t&&{event_properties:t})}(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),Qe(this.dispatch(r))},e.prototype.identify=function(e,t){var n=Xe(e,t);return this.userProperties=this.getOperationAppliedUserProperties(n.user_properties),Qe(this.dispatch(n))},e.prototype.groupIdentify=function(e,t,n,r){var i=function(e,t,n,r){var i;return de(de({},r),{event_type:le.GROUP_IDENTIFY,group_properties:n.getUserProperties(),groups:(i={},i[e]=t,i)})}(e,t,n,r);return Qe(this.dispatch(i))},e.prototype.setGroup=function(e,t,n){var r=function(e,t,n){var r,i=new $e;return i.set(e,t),de(de({},n),{event_type:le.IDENTIFY,user_properties:i.getUserProperties(),groups:(r={},r[e]=t,r)})}(e,t,n);return this.userProperties=this.getOperationAppliedUserProperties(r.user_properties),Qe(this.dispatch(r))},e.prototype.revenue=function(e,t){var n=function(e,t){return de(de({},t),{event_type:le.REVENUE,event_properties:e.getEventProperties()})}(e,t);return Qe(this.dispatch(n))},e.prototype.add=function(e){return this.isReady?this._addPlugin(e):(this.q.push(this._addPlugin.bind(this,e)),Qe())},e.prototype._addPlugin=function(e){return Qe(this.timeline.register(e,this.config))},e.prototype.remove=function(e){return this.isReady?this._removePlugin(e):(this.q.push(this._removePlugin.bind(this,e)),Qe())},e.prototype._removePlugin=function(e){return Qe(this.timeline.deregister(e,this.config))},e.prototype.dispatchWithCallback=function(e,t){if(!this.isReady)return t(Ge(e,0,"Client not initialized"));this.process(e).then(t)},e.prototype.dispatch=function(e){return pe(this,void 0,void 0,(function(){var t=this;return ge(this,(function(n){return this.isReady?[2,this.process(e)]:[2,new Promise((function(n){t.dispatchQ.push(t.dispatchWithCallback.bind(t,e,n))}))]}))}))},e.prototype.getOperationAppliedUserProperties=function(e){var t,n=null!==(t=this.userProperties)&&void 0!==t?t:{},r=de({},n);if(void 0===e)return r;var i={};return Object.keys(e).forEach((function(t){Object.values(ue).includes(t)||(i[t]=e[t])})),Ke.forEach((function(t){if(Object.keys(e).includes(t)){var n=e[t];switch(t){case ue.CLEAR_ALL:Object.keys(r).forEach((function(e){delete r[e]}));break;case ue.UNSET:Object.keys(n).forEach((function(e){delete r[e]}));break;case ue.SET:Object.assign(r,n)}}})),Object.assign(r,i),r},e.prototype.process=function(e){return pe(this,void 0,void 0,(function(){var t,n,r;return ge(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),this.config.optOut?[2,Ge(e,0,"Event skipped due to optOut config")]:(e.event_type===le.IDENTIFY&&this.timeline.onIdentityChanged({userProperties:this.userProperties}),[4,this.timeline.push(e)]);case 1:return 200===(r=i.sent()).code?this.config.loggerProvider.log(r.message):100===r.code?this.config.loggerProvider.warn(r.message):this.config.loggerProvider.error(r.message),[2,r];case 2:return t=i.sent(),n=String(t),this.config.loggerProvider.error(n),[2,r=Ge(e,0,n)];case 3:return[2]}}))}))},e.prototype.setOptOut=function(e){this.isReady?this._setOptOut(e):this.q.push(this._setOptOut.bind(this,Boolean(e)))},e.prototype._setOptOut=function(e){this.config.optOut!==e&&(this.config.optOut=Boolean(e),this.timeline.onOptOutChanged(e))},e.prototype.flush=function(){return Qe(this.timeline.flush())},e.prototype.plugin=function(e){var t=this.timeline.plugins.find((function(t){return t.name===e}));if(void 0!==t)return t;this.config.loggerProvider.debug("Cannot find plugin with name ".concat(e))},e.prototype.plugins=function(e){return this.timeline.plugins.filter((function(t){return t instanceof e}))},e}(),et=function(){function e(){this.productId="",this.quantity=1,this.price=0}return e.prototype.setProductId=function(e){return this.productId=e,this},e.prototype.setQuantity=function(e){return e>0&&(this.quantity=e),this},e.prototype.setPrice=function(e){return this.price=e,this},e.prototype.setRevenueType=function(e){return this.revenueType=e,this},e.prototype.setCurrency=function(e){return this.currency=e,this},e.prototype.setRevenue=function(e){return this.revenue=e,this},e.prototype.setReceipt=function(e){return this.receipt=e,this},e.prototype.setReceiptSig=function(e){return this.receiptSig=e,this},e.prototype.setEventProperties=function(e){try{var t=JSON.parse(JSON.stringify(e));Fe(t)&&(this.properties=t)}catch(e){}return this},e.prototype.getEventProperties=function(){var e=this.properties?de({},this.properties):{};return e[ze.REVENUE_PRODUCT_ID]=this.productId,e[ze.REVENUE_QUANTITY]=this.quantity,e[ze.REVENUE_PRICE]=this.price,e[ze.REVENUE_TYPE]=this.revenueType,e[ze.REVENUE_CURRENCY]=this.currency,e[ze.REVENUE]=this.revenue,e[ze.RECEIPT]=this.receipt,e[ze.RECEIPT_SIG]=this.receiptSig,e},e}();!function(e){e.REVENUE_PRODUCT_ID="$productId",e.REVENUE_QUANTITY="$quantity",e.REVENUE_PRICE="$price",e.REVENUE_TYPE="$revenueType",e.REVENUE_CURRENCY="$currency",e.REVENUE="$revenue",e.RECEIPT="$receipt",e.RECEIPT_SIG="$receiptSig"}(ze||(ze={}));var tt;!function(e){e[e.None=0]="None",e[e.Error=1]="Error",e[e.Warn=2]="Warn",e[e.Verbose=3]="Verbose",e[e.Debug=4]="Debug"}(tt||(tt={}));var nt="Amplitude Logger ",rt=function(){function e(){this.logLevel=tt.None}return e.prototype.disable=function(){this.logLevel=tt.None},e.prototype.enable=function(e){void 0===e&&(e=tt.Warn),this.logLevel=e},e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<tt.Verbose||console.log("".concat(nt,"[Log]: ").concat(e.join(" ")))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<tt.Warn||console.warn("".concat(nt,"[Warn]: ").concat(e.join(" ")))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<tt.Error||console.error("".concat(nt,"[Error]: ").concat(e.join(" ")))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this.logLevel<tt.Debug||console.log("".concat(nt,"[Debug]: ").concat(e.join(" ")))},e}(),it=function(){return{flushMaxRetries:12,flushQueueSize:200,flushIntervalMillis:1e4,instanceName:we,logLevel:tt.Warn,loggerProvider:new rt,offline:!1,optOut:!1,serverUrl:ke,serverZone:"US",useBatch:!1}},ot=function(){function e(e){var t,n,r,i;this._optOut=!1;var o=it();this.apiKey=e.apiKey,this.flushIntervalMillis=null!==(t=e.flushIntervalMillis)&&void 0!==t?t:o.flushIntervalMillis,this.flushMaxRetries=e.flushMaxRetries||o.flushMaxRetries,this.flushQueueSize=e.flushQueueSize||o.flushQueueSize,this.instanceName=e.instanceName||o.instanceName,this.loggerProvider=e.loggerProvider||o.loggerProvider,this.logLevel=null!==(n=e.logLevel)&&void 0!==n?n:o.logLevel,this.minIdLength=e.minIdLength,this.plan=e.plan,this.ingestionMetadata=e.ingestionMetadata,this.offline=void 0!==e.offline?e.offline:o.offline,this.optOut=null!==(r=e.optOut)&&void 0!==r?r:o.optOut,this.serverUrl=e.serverUrl,this.serverZone=e.serverZone||o.serverZone,this.storageProvider=e.storageProvider,this.transportProvider=e.transportProvider,this.useBatch=null!==(i=e.useBatch)&&void 0!==i?i:o.useBatch,this.loggerProvider.enable(this.logLevel);var a=st(e.serverUrl,e.serverZone,e.useBatch);this.serverZone=a.serverZone,this.serverUrl=a.serverUrl}return Object.defineProperty(e.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut=e},enumerable:!1,configurable:!0}),e}(),at=function(e,t){return"EU"===e?t?_e:Ee:t?Se:ke},st=function(e,t,n){if(void 0===e&&(e=""),void 0===t&&(t=it().serverZone),void 0===n&&(n=it().useBatch),e)return{serverUrl:e,serverZone:void 0};var r=["US","EU"].includes(t)?t:it().serverZone;return{serverZone:r,serverUrl:at(r,n)}},ct=function(){function e(){this.sdk={metrics:{histogram:{}}}}return e.prototype.recordHistogram=function(e,t){this.sdk.metrics.histogram[e]=t},e}();function ut(e){return e>=200&&e<300}var lt=function(e){return void 0===e&&(e=0),((new Error).stack||"").split("\n").slice(2+e).map((function(e){return e.trim()}))},dt=function(e){return function(){var t=de({},e.config);return{logger:t.loggerProvider,logLevel:t.logLevel}}},ft=function(e,t){var n,r;t=(t=t.replace(/\[(\w+)\]/g,".$1")).replace(/^\./,"");try{for(var i=he(t.split(".")),o=i.next();!o.done;o=i.next()){var a=o.value;if(!(a in e))return;e=e[a]}}catch(e){n={error:e}}finally{try{o&&!o.done&&(r=i.return)&&r.call(i)}finally{if(n)throw n.error}}return e},pt=function(e,t){return function(){var n,r,i={};try{for(var o=he(t),a=o.next();!a.done;a=o.next()){var s=a.value;i[s]=ft(e,s)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i}},gt=function(e,t,n,r,i){return void 0===i&&(i=null),function(){for(var o=[],a=0;a<arguments.length;a++)o[a]=arguments[a];var s=n(),c=s.logger,u=s.logLevel;if(u&&u<tt.Debug||!u||!c)return e.apply(i,o);var l={type:"invoke public method",name:t,args:o,stacktrace:lt(1),time:{start:(new Date).toISOString()},states:{}};r&&l.states&&(l.states.before=r());var d=e.apply(i,o);return d&&d.promise?d.promise.then((function(){r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))})):(r&&l.states&&(l.states.after=r()),l.time&&(l.time.end=(new Date).toISOString()),c.debug(JSON.stringify(l,null,2))),d}},ht=new Set([ke,Ee,Se,_e]);function vt(e){var t="";try{"body"in e&&(t=JSON.stringify(e.body,null,2))}catch(e){}return t}var mt=function(){function e(e){this.name="amplitude",this.type="destination",this.retryTimeout=1e3,this.throttleTimeout=3e4,this.storageKey="",this.scheduleId=null,this.scheduledTimeout=0,this.flushId=null,this.queue=[],this.diagnosticsClient=null==e?void 0:e.diagnosticsClient}return e.prototype.setup=function(e){var t;return pe(this,void 0,void 0,(function(){var n,r=this;return ge(this,(function(i){switch(i.label){case 0:return this.config=e,this.storageKey="".concat(Te,"_").concat(this.config.apiKey.substring(0,10)),[4,null===(t=this.config.storageProvider)||void 0===t?void 0:t.get(this.storageKey)];case 1:return(n=i.sent())&&n.length>0&&Promise.all(n.map((function(e){return r.execute(e)}))).catch(),[2,Promise.resolve(void 0)]}}))}))},e.prototype.execute=function(e){var t=this;return e.insert_id||(e.insert_id=Je()),new Promise((function(n){var r={event:e,attempts:0,callback:function(e){return n(e)},timeout:0};t.queue.push(r),t.schedule(t.config.flushIntervalMillis),t.saveEvents()}))},e.prototype.removeEventsExceedFlushMaxRetries=function(e){var t=this;return e.filter((function(e){return e.attempts+=1,e.attempts<t.config.flushMaxRetries||(t.fulfillRequest([e],500,"Event rejected due to exceeded retry count"),!1)}))},e.prototype.scheduleEvents=function(e){var t=this;e.forEach((function(e){t.schedule(0===e.timeout?t.config.flushIntervalMillis:e.timeout)}))},e.prototype.schedule=function(e){var t=this;if(!this.config.offline)return null===this.scheduleId||this.scheduleId&&e>this.scheduledTimeout?(this.scheduleId&&clearTimeout(this.scheduleId),this.scheduledTimeout=e,void(this.scheduleId=setTimeout((function(){t.queue=t.queue.map((function(e){return e.timeout=0,e})),t.flush(!0)}),e))):void 0},e.prototype.resetSchedule=function(){this.scheduleId=null,this.scheduledTimeout=0},e.prototype.flush=function(e){return void 0===e&&(e=!1),pe(this,void 0,void 0,(function(){var t,n,r,i=this;return ge(this,(function(o){switch(o.label){case 0:return this.config.offline?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush while offline."),[2]):this.flushId?(this.resetSchedule(),this.config.loggerProvider.debug("Skipping flush because previous flush has not resolved."),[2]):(this.flushId=this.scheduleId,this.resetSchedule(),t=[],n=[],this.queue.forEach((function(e){return 0===e.timeout?t.push(e):n.push(e)})),a=t,s=this.config.flushQueueSize,c=Math.max(s,1),r=a.reduce((function(e,t,n){var r=Math.floor(n/c);return e[r]||(e[r]=[]),e[r].push(t),e}),[]),[4,r.reduce((function(t,n){return pe(i,void 0,void 0,(function(){return ge(this,(function(r){switch(r.label){case 0:return[4,t];case 1:return r.sent(),[4,this.send(n,e)];case 2:return[2,r.sent()]}}))}))}),Promise.resolve())]);case 1:return o.sent(),this.flushId=null,this.scheduleEvents(this.queue),[2]}var a,s,c}))}))},e.prototype.send=function(e,t){var n;return void 0===t&&(t=!0),pe(this,void 0,void 0,(function(){var r,i,o,a,s,c;return ge(this,(function(u){switch(u.label){case 0:if(!this.config.apiKey)return[2,this.fulfillRequest(e,400,"Event rejected due to missing API key")];r={api_key:this.config.apiKey,events:e.map((function(e){var t=e.event;return t.extra,fe(t,["extra"])})),options:{min_id_length:this.config.minIdLength},client_upload_time:(new Date).toISOString(),request_metadata:this.config.requestMetadata},this.config.requestMetadata=new ct,u.label=1;case 1:return u.trys.push([1,3,,4]),i=st(this.config.serverUrl,this.config.serverZone,this.config.useBatch).serverUrl,o=function(e,t){return void 0===t&&(t=!1),!!ht.has(e)||t}(i,this.config.enableRequestBodyCompression),[4,this.config.transportProvider.send(i,r,this.config._enableRequestBodyCompressionExperimental&&o)];case 2:return null===(a=u.sent())?(this.fulfillRequest(e,0,"Unexpected error occurred"),[2]):t?(this.handleResponse(a,e),[3,4]):("body"in a?this.fulfillRequest(e,a.statusCode,"".concat(a.status,": ").concat(vt(a))):this.fulfillRequest(e,a.statusCode,a.status),[2]);case 3:return s=u.sent(),c=(l=s)instanceof Error?l.message:String(l),this.config.loggerProvider.error(c),null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful.from.catch.error",{events:e.map((function(e){return e.event.event_type})),message:c,stack_trace:lt()}),this.handleResponse({status:He.Failed,statusCode:0},e),[3,4];case 4:return[2]}var l}))}))},e.prototype.handleResponse=function(e,t){var n;ut(e.statusCode)||null===(n=this.diagnosticsClient)||void 0===n||n.recordEvent("analytics.events.unsuccessful",{events:t.map((function(e){return e.event.event_type})),code:e.statusCode,status:e.status,body:vt(e),stack_trace:lt()});var r=e.status;switch(r){case He.Success:this.handleSuccessResponse(e,t);break;case He.Invalid:this.handleInvalidResponse(e,t);break;case He.PayloadTooLarge:this.handlePayloadTooLargeResponse(e,t);break;case He.RateLimit:this.handleRateLimitResponse(e,t);break;default:this.config.loggerProvider.warn("{code: 0, error: \"Status '".concat(r,"' provided for ").concat(t.length,' events"}')),this.handleOtherResponse(t)}},e.prototype.handleSuccessResponse=function(e,t){this.fulfillRequest(t,e.statusCode,"Event tracked successfully")},e.prototype.handleInvalidResponse=function(e,t){var n=this;if(e.body.missingField||e.body.error.startsWith("Invalid API key"))this.fulfillRequest(t,e.statusCode,e.body.error);else{var r=me(me(me(me([],ve(Object.values(e.body.eventsWithInvalidFields)),!1),ve(Object.values(e.body.eventsWithMissingFields)),!1),ve(Object.values(e.body.eventsWithInvalidIdLengths)),!1),ve(e.body.silencedEvents),!1).flat(),i=new Set(r),o=t.filter((function(t,r){if(!i.has(r))return!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));o.length>0&&this.config.loggerProvider.warn(vt(e));var a=this.removeEventsExceedFlushMaxRetries(o);this.scheduleEvents(a)}},e.prototype.handlePayloadTooLargeResponse=function(e,t){if(1!==t.length){this.config.loggerProvider.warn(vt(e)),this.config.flushQueueSize/=2;var n=this.removeEventsExceedFlushMaxRetries(t);this.scheduleEvents(n)}else this.fulfillRequest(t,e.statusCode,e.body.error)},e.prototype.handleRateLimitResponse=function(e,t){var n=this,r=Object.keys(e.body.exceededDailyQuotaUsers),i=Object.keys(e.body.exceededDailyQuotaDevices),o=e.body.throttledEvents,a=new Set(r),s=new Set(i),c=new Set(o),u=t.filter((function(t,r){if(!(t.event.user_id&&a.has(t.event.user_id)||t.event.device_id&&s.has(t.event.device_id)))return c.has(r)&&(t.timeout=n.throttleTimeout),!0;n.fulfillRequest([t],e.statusCode,e.body.error)}));u.length>0&&this.config.loggerProvider.warn(vt(e));var l=this.removeEventsExceedFlushMaxRetries(u);this.scheduleEvents(l)},e.prototype.handleOtherResponse=function(e){var t=this,n=e.map((function(e){return e.timeout=e.attempts*t.retryTimeout,e})),r=this.removeEventsExceedFlushMaxRetries(n);this.scheduleEvents(r)},e.prototype.fulfillRequest=function(e,t,n){var r,i,o;ut(t)?null===(o=this.diagnosticsClient)||void 0===o||o.increment("analytics.events.sent",e.length):(null===(r=this.diagnosticsClient)||void 0===r||r.increment("analytics.events.dropped",e.length),null===(i=this.diagnosticsClient)||void 0===i||i.recordEvent("analytics.events.dropped",{events:e.map((function(e){return e.event.event_type})),code:t,message:n,stack_trace:lt()})),this.removeEvents(e),e.forEach((function(e){return e.callback(Ge(e.event,t,n))}))},e.prototype.saveEvents=function(){if(this.config.storageProvider){var e=this.queue.map((function(e){return e.event}));this.config.storageProvider.set(this.storageKey,e)}},e.prototype.removeEvents=function(e){this.queue=this.queue.filter((function(t){return!e.some((function(e){return e.event.insert_id===t.event.insert_id}))})),this.saveEvents()},e}(),yt=function(){function e(){}return e.prototype.getApplicationContext=function(){return{versionName:this.versionName,language:bt(),platform:"Web",os:void 0,deviceModel:void 0}},e}(),bt=function(){return"undefined"!=typeof navigator&&(navigator.languages&&navigator.languages[0]||navigator.language)||""},Tt=function(){function e(){this.queue=[]}return e.prototype.logEvent=function(e){this.receiver?this.receiver(e):this.queue.length<512&&this.queue.push(e)},e.prototype.setEventReceiver=function(e){this.receiver=e,this.queue.length>0&&(this.queue.forEach((function(t){e(t)})),this.queue=[])},e}(),wt=function(){return wt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},wt.apply(this,arguments)};function kt(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Et(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,o=n.call(e),a=[];try{for(;(void 0===t||t-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a}"function"==typeof SuppressedError&&SuppressedError;var St=function(e,t){var n,r,i=typeof e;if(i!==typeof t)return!1;try{for(var o=kt(["string","number","boolean","undefined"]),a=o.next();!a.done;a=o.next()){if(a.value===i)return e===t}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}if(null==e&&null==t)return!0;if(null==e||null==t)return!1;if(e.length!==t.length)return!1;var s=Array.isArray(e),c=Array.isArray(t);if(s!==c)return!1;if(!s||!c){var u=Object.keys(e).sort(),l=Object.keys(t).sort();if(!St(u,l))return!1;var d=!0;return Object.keys(e).forEach((function(n){St(e[n],t[n])||(d=!1)})),d}for(var f=0;f<e.length;f++)if(!St(e[f],t[f]))return!1;return!0};Object.entries||(Object.entries=function(e){for(var t=Object.keys(e),n=t.length,r=new Array(n);n--;)r[n]=[t[n],e[t[n]]];return r});var _t=function(){function e(){this.identity={userProperties:{}},this.listeners=new Set}return e.prototype.editIdentity=function(){var e=this,t=wt({},this.identity.userProperties),n=wt(wt({},this.identity),{userProperties:t});return{setUserId:function(e){return n.userId=e,this},setDeviceId:function(e){return n.deviceId=e,this},setUserProperties:function(e){return n.userProperties=e,this},setOptOut:function(e){return n.optOut=e,this},updateUserProperties:function(e){var t,r,i,o,a,s,c=n.userProperties||{};try{for(var u=kt(Object.entries(e)),l=u.next();!l.done;l=u.next()){var d=Et(l.value,2),f=d[0],p=d[1];switch(f){case"$set":try{for(var g=(i=void 0,kt(Object.entries(p))),h=g.next();!h.done;h=g.next()){var v=Et(h.value,2),m=v[0],y=v[1];c[m]=y}}catch(e){i={error:e}}finally{try{h&&!h.done&&(o=g.return)&&o.call(g)}finally{if(i)throw i.error}}break;case"$unset":try{for(var b=(a=void 0,kt(Object.keys(p))),T=b.next();!T.done;T=b.next()){delete c[m=T.value]}}catch(e){a={error:e}}finally{try{T&&!T.done&&(s=b.return)&&s.call(b)}finally{if(a)throw a.error}}break;case"$clearAll":c={}}}}catch(e){t={error:e}}finally{try{l&&!l.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}return n.userProperties=c,this},commit:function(){return e.setIdentity(n),this}}},e.prototype.getIdentity=function(){return wt({},this.identity)},e.prototype.setIdentity=function(e){var t=wt({},this.identity);this.identity=wt({},e),St(t,this.identity)||this.listeners.forEach((function(t){t(e)}))},e.prototype.addIdentityListener=function(e){this.listeners.add(e)},e.prototype.removeIdentityListener=function(e){this.listeners.delete(e)},e}(),It="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:self,Pt=function(){function e(){this.identityStore=new _t,this.eventBridge=new Tt,this.applicationContextProvider=new yt}return e.getInstance=function(t){return It.analyticsConnectorInstances||(It.analyticsConnectorInstances={}),It.analyticsConnectorInstances[t]||(It.analyticsConnectorInstances[t]=new e),It.analyticsConnectorInstances[t]},e}(),At=function(e){return void 0===e&&(e=we),Pt.getInstance(e)},Ot=function(){function e(){this.name="identity",this.type="before",this.identityStore=At().identityStore}return e.prototype.execute=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){return(t=e.user_properties)&&this.identityStore.editIdentity().updateUserProperties(t).commit(),[2,e]}))}))},e.prototype.setup=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){return e.instanceName&&(this.identityStore=At(e.instanceName).identityStore),[2]}))}))},e}(),Ct=function(e,t){return void 0===t&&(t=Date.now()),Date.now()-t>e},xt=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[be,t,e.substring(0,n)].filter(Boolean).join("_")},Rt=function(){var e,t,n,r;if("undefined"==typeof navigator)return"";var i=navigator.userLanguage;return null!==(r=null!==(n=null!==(t=null===(e=navigator.languages)||void 0===e?void 0:e[0])&&void 0!==t?t:navigator.language)&&void 0!==n?n:i)&&void 0!==r?r:""},Dt=function(){var e,t=Ve();return(null===(e=null==t?void 0:t.location)||void 0===e?void 0:e.search)?t.location.search.substring(1).split("&").filter(Boolean).reduce((function(e,t){var n=t.split("=",2),r=Lt(n[0]),i=Lt(n[1]);return i?(e[r]=i,e):e}),{}):{}},Lt=function(e){void 0===e&&(e="");try{return decodeURIComponent(e)}catch(e){return""}},Nt=function(e,t){return!t||!t.length||t.some((function(t){return"string"==typeof t?e===t:e.match(t)}))},Ut=function(e,t){var n=e;try{n=decodeURI(e)}catch(e){null==t||t.error("Malformed URI sequence: ",e)}return n},Mt=function(e,t){var n=function(e){var t=0;if(0===e.length)return t;for(var n=0;n<e.length;n++)t=(t<<5)-t+e.charCodeAt(n),t|=0;return t}(e.toString());return 31*Math.abs(n)%1e5/1e5<t},jt=function(){function e(){this.memoryStorage=new Map}return e.prototype.isEnabled=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return[2,!0]}))}))},e.prototype.get=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){return[2,this.memoryStorage.get(e)]}))}))},e.prototype.getRaw=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return[4,this.get(e)];case 1:return[2,(t=n.sent())?JSON.stringify(t):void 0]}}))}))},e.prototype.set=function(e,t){return pe(this,void 0,void 0,(function(){return ge(this,(function(n){return this.memoryStorage.set(e,t),[2]}))}))},e.prototype.remove=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){return this.memoryStorage.delete(e),[2]}))}))},e.prototype.reset=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return this.memoryStorage.clear(),[2]}))}))},e}(),qt=function(){function e(e,t){void 0===t&&(t={}),this.options=de({},e),this.config=t}return e.prototype.isEnabled=function(){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(a){switch(a.label){case 0:return t="AMP_TEST",n=de({},this.options),r=new e(n),i=String(Date.now()),[4,r.transaction(t,(function(e){var n,r;try{e.set(i);var a=e.get()===i;return!a&&o.config.diagnosticsClient&&(null===(n=o.config.diagnosticsClient)||void 0===n||n.recordEvent("cookies.isEnabled.failure",{reason:"Test Value mismatch",testKey:t,testValue:i,sync:!0})),a}catch(e){if(o.config.diagnosticsClient){var s=e instanceof Error?e.message:String(e);null===(r=o.config.diagnosticsClient)||void 0===r||r.recordEvent("cookies.isEnabled.failure",{reason:"Cookie getter/setter failed",testKey:t,testValue:i,error:s,sync:!0})}return!1}finally{e.set(null)}}))];case 1:return[2,a.sent()]}}))}))},e.prototype.get=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return[4,this.getRaw(e)];case 1:return t=n.sent(),[2,this.decodeCookieValue(e,t)]}}))}))},e.prototype.decodeCookieValue=function(e,t){if(t)try{var n=Ft(t);return void 0===n?void console.error("Amplitude Logger [Error]: Failed to decode cookie value for key: ".concat(e,", value: ").concat(t)):JSON.parse(n)}catch(n){return void console.error("Amplitude Logger [Error]: Failed to parse cookie value for key: ".concat(e,", value: ").concat(t))}},e.prototype.getSync=function(e){var t=this.getRawSync(e);return this.decodeCookieValue(e,t)},e.prototype.getRaw=function(e){var t,n;return pe(this,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,d;return ge(this,(function(f){switch(f.label){case 0:r=Ve(),i=r,f.label=1;case 1:return f.trys.push([1,4,,5]),(o=null==i?void 0:i.cookieStore)?[4,o.getAll(e)]:[3,3];case 2:if(a=f.sent()){a.length>1&&(null===(t=this.config.diagnosticsClient)||void 0===t||t.recordEvent("cookies.duplicate",{cookies:a.map((function(e){return e.domain}))}),null===(n=this.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.cookieStore"));try{for(s=he(a),c=s.next();!c.done;c=s.next())if(u=c.value,Bt(u.domain,this.options.domain))return[2,u.value]}catch(e){l={error:e}}finally{try{c&&!c.done&&(d=s.return)&&d.call(s)}finally{if(l)throw l.error}}}f.label=3;case 3:return[3,5];case 4:return f.sent(),[3,5];case 5:return[2,this.getRawSync(e)]}}))}))},e.prototype.getRawSync=function(e){var t,n,r=this,i=Ve(),o=(null!==(n=null===(t=null==i?void 0:i.document)||void 0===t?void 0:t.cookie.split("; "))&&void 0!==n?n:[]).filter((function(t){return 0===t.indexOf(e+"=")})),a=void 0,s=this.config.duplicateResolverFn;if("function"==typeof s&&o.length>1&&(a=o.find((function(t){var n;try{var i=s(t.substring(e.length+1));return i||null===(n=r.config.diagnosticsClient)||void 0===n||n.increment("cookies.duplicate.occurrence.document.cookie"),i}catch(e){return!1}}))),a||(a=o[0]),a)return a.substring(e.length+1)},e.prototype.set=function(e,t){return pe(this,void 0,void 0,(function(){return ge(this,(function(n){return this.setSync(e,t),[2]}))}))},e.prototype.setSync=function(e,t){var n;try{var r=null!==(n=this.options.expirationDays)&&void 0!==n?n:0,i=null!==t?r:-1,o=void 0;if(i){var a=new Date;a.setTime(a.getTime()+24*i*60*60*1e3),o=a}var s="".concat(e,"=").concat(btoa(encodeURIComponent(JSON.stringify(t))));o&&(s+="; expires=".concat(o.toUTCString())),s+="; path=/",this.options.domain&&(s+="; domain=".concat(this.options.domain)),this.options.secure&&(s+="; Secure"),this.options.sameSite&&(s+="; SameSite=".concat(this.options.sameSite));var c=Ve();(null==c?void 0:c.document)&&(c.document.cookie=s)}catch(t){var u=t instanceof Error?t.message:String(t);console.error("Amplitude Logger [Error]: Failed to set cookie for key: ".concat(e,". Error: ").concat(u))}},e.prototype.remove=function(e){return pe(this,void 0,void 0,(function(){return ge(this,(function(t){switch(t.label){case 0:return[4,this.set(e,null)];case 1:return t.sent(),[2]}}))}))},e.prototype.reset=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return[2]}))}))},e.isDomainWritable=function(t){return pe(this,void 0,void 0,(function(){var n,r;return ge(this,(function(i){switch(i.label){case 0:if(e.cachedTlds[t])return[2,!0];n="AMP_TLDTEST",r=new e({domain:"."+t}),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,r.transaction(n,(function(n){if(e.cachedTlds[t])return!0;try{n.set(1);var r=!!n.get();return r&&(e.cachedTlds[t]=!0),r}finally{n.set(null)}}))];case 2:return[2,!!i.sent()];case 3:return i.sent(),[2,!1];case 4:return[2]}}))}))},e.prototype.transaction=function(e,t){return pe(this,void 0,void 0,(function(){var n,r,i=this;return ge(this,(function(o){switch(o.label){case 0:if(n=function(){var e,t=Ve();return null===(e=null==t?void 0:t.navigator)||void 0===e?void 0:e.locks}(),r=function(){return t({get:function(){return i.getSync(e)},set:function(t){return i.setSync(e,t)}})},!n)return[2,r()];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.request("com.amplitude:cookie-lock:".concat(e),r)];case 2:return[2,o.sent()];case 3:return o.sent(),[2,r()];case 4:return[2]}}))}))},e.cachedTlds={},e}(),Ft=function(e){var t;return null!==(t=function(e){try{return decodeURIComponent(atob(e))}catch(e){return}}(e))&&void 0!==t?t:function(e){try{return decodeURIComponent(atob(decodeURIComponent(e)))}catch(e){return}}(e)},Bt=function(e,t){if(""===e&&""===t)return!0;if(!e||!t)return!1;var n=e.startsWith(".")?e.substring(1):e,r=t.startsWith(".")?t.substring(1):t;return n.toLowerCase()===r.toLowerCase()},$t=function(e,t,n){return void 0===t&&(t=""),void 0===n&&(n=10),[be,t,e.substring(0,n)].filter(Boolean).join("_")},Ht=function(){function e(e){this.storage=e}return e.prototype.isEnabled=function(){return pe(this,void 0,void 0,(function(){var t,n,r;return ge(this,(function(i){switch(i.label){case 0:if(!this.storage)return[2,!1];t=String(Date.now()),n=new e(this.storage),r="AMP_TEST",i.label=1;case 1:return i.trys.push([1,4,5,7]),[4,n.set(r,t)];case 2:return i.sent(),[4,n.get(r)];case 3:return[2,i.sent()===t];case 4:return i.sent(),[2,!1];case 5:return[4,n.remove(r)];case 6:return i.sent(),[7];case 7:return[2]}}))}))},e.prototype.get=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getRaw(e)];case 1:return(t=n.sent())?[2,JSON.parse(t)]:[2,void 0];case 2:return n.sent(),console.error("[Amplitude] Error: Could not get value from storage"),[2,void 0];case 3:return[2]}}))}))},e.prototype.getRaw=function(e){var t;return pe(this,void 0,void 0,(function(){return ge(this,(function(n){return[2,(null===(t=this.storage)||void 0===t?void 0:t.getItem(e))||void 0]}))}))},e.prototype.set=function(e,t){var n;return pe(this,void 0,void 0,(function(){return ge(this,(function(r){try{null===(n=this.storage)||void 0===n||n.setItem(e,JSON.stringify(t))}catch(e){}return[2]}))}))},e.prototype.remove=function(e){var t;return pe(this,void 0,void 0,(function(){return ge(this,(function(n){try{null===(t=this.storage)||void 0===t||t.removeItem(e)}catch(e){}return[2]}))}))},e.prototype.reset=function(){var e;return pe(this,void 0,void 0,(function(){return ge(this,(function(t){try{null===(e=this.storage)||void 0===e||e.clear()}catch(e){}return[2]}))}))},e}(),Kt="tags",zt="counters",Gt="histograms",Vt="events",Wt="internal",Jt="last_flush_timestamp",Yt=function(){function e(e,t){this.dbPromise=null,this.logger=t,this.dbName="AMP_diagnostics_".concat(e.substring(0,10))}return e.isSupported=function(){var e;return void 0!==(null===(e=Ve())||void 0===e?void 0:e.indexedDB)},e.prototype.getDB=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return this.dbPromise||(this.dbPromise=this.openDB()),[2,this.dbPromise]}))}))},e.prototype.openDB=function(){var e=this;return new Promise((function(t,n){var r=indexedDB.open(e.dbName,1);r.onerror=function(){e.dbPromise=null,n(new Error("Failed to open IndexedDB"))},r.onsuccess=function(){var n=r.result;n.onclose=function(){e.dbPromise=null,e.logger.debug("DiagnosticsStorage: DB connection closed.")},n.onerror=function(t){e.logger.debug("DiagnosticsStorage: A global database error occurred.",t),n.close()},t(n)},r.onupgradeneeded=function(t){var n=t.target.result;e.createTables(n)}}))},e.prototype.createTables=function(e){(e.objectStoreNames.contains(Kt)||e.createObjectStore(Kt,{keyPath:"key"}),e.objectStoreNames.contains(zt)||e.createObjectStore(zt,{keyPath:"key"}),e.objectStoreNames.contains(Gt)||e.createObjectStore(Gt,{keyPath:"key"}),e.objectStoreNames.contains(Vt))||e.createObjectStore(Vt,{keyPath:"id",autoIncrement:!0}).createIndex("time_idx","time",{unique:!1});e.objectStoreNames.contains(Wt)||e.createObjectStore(Wt,{keyPath:"key"})},e.prototype.setTags=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Kt],"readwrite"),r=n.objectStore(Kt),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tags",e),t()},i.forEach((function(e){var t=ve(e,2),n=t[0],i=t[1];r.put({key:n,value:i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set tag",n,i,e)}}))}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to set tags",i),[3,3];case 3:return[2]}}))}))},e.prototype.incrementCounters=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([zt],"readwrite"),r=n.objectStore(zt),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to increment counters",e),t()},i.forEach((function(e){var t=ve(e,2),n=t[0],i=t[1],a=r.get(n);a.onsuccess=function(){var e=a.result,t=e?e.value:0;r.put({key:n,value:t+i}).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to update counter",n,e)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing counter",n,e)}}))}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to increment counters",i),[3,3];case 3:return[2]}}))}))},e.prototype.setHistogramStats=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===Object.entries(e).length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Gt],"readwrite"),r=n.objectStore(Gt),[2,new Promise((function(t){var i=Object.entries(e);n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",e),t()},i.forEach((function(e){var t=ve(e,2),n=t[0],i=t[1],a=r.get(n);a.onsuccess=function(){var e,t=a.result;e=t?{key:n,count:t.count+i.count,min:Math.min(t.min,i.min),max:Math.max(t.max,i.max),sum:t.sum+i.sum}:{key:n,count:i.count,min:i.min,max:i.max,sum:i.sum},r.put(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to set histogram stats",n,e)}},a.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to read existing histogram stats",n,e)}}))}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to set histogram stats",i),[3,3];case 3:return[2]}}))}))},e.prototype.addEventRecords=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i,o=this;return ge(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),0===e.length?[2]:[4,this.getDB()];case 1:return t=a.sent(),n=t.transaction([Vt],"readwrite"),r=n.objectStore(Vt),[2,new Promise((function(t){n.oncomplete=function(){t()},n.onabort=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event records",e),t()};var i=r.count();i.onsuccess=function(){var t=i.result,n=Math.max(0,10-t);n<e.length&&o.logger.debug("DiagnosticsStorage: Only added ".concat(n," of ").concat(e.length," events due to storage limit")),e.slice(0,n).forEach((function(e){r.add(e).onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to add event record",e)}}))},i.onerror=function(e){o.logger.debug("DiagnosticsStorage: Failed to count existing events",e)}}))];case 2:return i=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to add event records",i),[3,3];case 3:return[2]}}))}))},e.prototype.setInternal=function(e,t){return pe(this,void 0,void 0,(function(){var n,r,i,o;return ge(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.getDB()];case 1:return n=a.sent(),r=n.transaction([Wt],"readwrite"),i=r.objectStore(Wt),[2,new Promise((function(n,o){r.onabort=function(){return o(new Error("Failed to set internal value"))};var a=i.put({key:e,value:t});a.onsuccess=function(){return n()},a.onerror=function(){return o(new Error("Failed to set internal value"))}}))];case 2:return o=a.sent(),this.logger.debug("DiagnosticsStorage: Failed to set internal value",o),[3,3];case 3:return[2]}}))}))},e.prototype.getInternal=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i;return ge(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,,3]),[4,this.getDB()];case 1:return t=o.sent(),n=t.transaction([Wt],"readonly"),r=n.objectStore(Wt),[2,new Promise((function(t,i){n.onabort=function(){return i(new Error("Failed to get internal value"))};var o=r.get(e);o.onsuccess=function(){return t(o.result)},o.onerror=function(){return i(new Error("Failed to get internal value"))}}))];case 2:return i=o.sent(),this.logger.debug("DiagnosticsStorage: Failed to get internal value",i),[2,void 0];case 3:return[2]}}))}))},e.prototype.getLastFlushTimestamp=function(){return pe(this,void 0,void 0,(function(){var e,t;return ge(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.getInternal(Jt)];case 1:return[2,(e=n.sent())?parseInt(e.value,10):void 0];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to get last flush timestamp",t),[2,void 0];case 3:return[2]}}))}))},e.prototype.setLastFlushTimestamp=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.setInternal(Jt,e.toString())];case 1:return n.sent(),[3,3];case 2:return t=n.sent(),this.logger.debug("DiagnosticsStorage: Failed to set last flush timestamp",t),[3,3];case 3:return[2]}}))}))},e.prototype.clearTable=function(e,t){return new Promise((function(n,r){var i=e.objectStore(t).clear();i.onsuccess=function(){return n()},i.onerror=function(){return r(new Error("Failed to clear table ".concat(t)))}}))},e.prototype.getAllAndClear=function(){return pe(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,s;return ge(this,(function(c){switch(c.label){case 0:return c.trys.push([0,4,,5]),[4,this.getDB()];case 1:return e=c.sent(),t=e.transaction([Kt,zt,Gt,Vt],"readwrite"),[4,Promise.all([this.getAllFromStore(t,Kt),this.getAllFromStore(t,zt),this.getAllFromStore(t,Gt),this.getAllFromStore(t,Vt)])];case 2:return n=ve.apply(void 0,[c.sent(),4]),r=n[0],i=n[1],o=n[2],a=n[3],[4,Promise.all([this.clearTable(t,zt),this.clearTable(t,Gt),this.clearTable(t,Vt)])];case 3:return c.sent(),[2,{tags:r,counters:i,histogramStats:o,events:a}];case 4:return s=c.sent(),this.logger.debug("DiagnosticsStorage: Failed to get all and clear data",s),[2,{tags:[],counters:[],histogramStats:[],events:[]}];case 5:return[2]}}))}))},e.prototype.getAllFromStore=function(e,t){return new Promise((function(n,r){var i=e.objectStore(t).getAll();i.onsuccess=function(){return n(i.result)},i.onerror=function(){return r(new Error("Failed to get all from ".concat(t)))}}))},e}(),Xt=function(e){var t,n,r=function(){var e=Ve();if(!e)return[];var t=e.__AMPLITUDE_SCRIPT_URL__;return Array.isArray(t)?t:"string"==typeof t?[t]:[]}();if(0!==r.length)try{for(var i=he(r),o=i.next();!o.done;o=i.next()){var a=o.value;if(e.filename&&e.filename.includes(a))return"filename";if(e.stack&&e.stack.includes(a))return"stack"}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}},Qt=function(e){if(e){var t=e.match(/(https?:\/\/\S+?)(?=[)\s]|$)/);return t?t[1]:void 0}},Zt=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(e){return"[object Object]"}},en=3e5,tn=1e4,nn=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},this.inMemoryEvents=[],this.saveTimer=null,this.flushTimer=null,this.apiKey=e,this.logger=t,this.serverUrl="US"===n?"https://diagnostics.prod.us-west-2.amplitude.com/v1/capture":"https://diagnostics.prod.eu-central-1.amplitude.com/v1/capture",this.logger.debug("DiagnosticsClient: Initializing with options",JSON.stringify(r,null,2)),this.config=de({enabled:!0,sampleRate:0},r),this.startTimestamp=Date.now(),this.shouldTrack=Mt(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,Yt.isSupported()?this.storage=new Yt(e,t):this.logger.debug("DiagnosticsClient: IndexedDB is not supported"),this.initializeFlushInterval(),this.shouldTrack&&(this.increment("sdk.diagnostics.sampled.in.and.enabled"),function(e){var t=Ve();if(t&&"function"==typeof t.addEventListener){var n=function(t){e.recordEvent("sdk.error.uncaught",de({type:t.type,message:t.message,filename:t.filename,error_name:t.errorName,stack:t.stack},t.metadata))};t.addEventListener("error",(function(e){var t=e.error instanceof Error?e.error:void 0,r=null==t?void 0:t.stack,i=Xt({filename:e.filename,stack:r});i&&n({type:"error",message:e.message,stack:r,filename:e.filename,errorName:null==t?void 0:t.name,metadata:{colno:e.colno,lineno:e.lineno,isTrusted:e.isTrusted,matchReason:i}})}),!0),t.addEventListener("unhandledrejection",(function(e){var t,r=e.reason instanceof Error?e.reason:void 0,i=null==r?void 0:r.stack,o=Qt(i),a=Xt({filename:o,stack:i});a&&n({type:"unhandledrejection",message:null!==(t=null==r?void 0:r.message)&&void 0!==t?t:Zt(e.reason),stack:i,filename:o,errorName:null==r?void 0:r.name,metadata:{isTrusted:e.isTrusted,matchReason:a}})}),!0)}}(this))}return e.prototype.isStorageAndTrackEnabled=function(){return Boolean(this.storage)&&Boolean(this.shouldTrack)},e.prototype.setTag=function(e,t){this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryTags).length>=tn?this.logger.debug("DiagnosticsClient: Early return setTags as reaching memory limit"):(this.inMemoryTags[e]=t,this.startTimersIfNeeded()))},e.prototype.increment=function(e,t){void 0===t&&(t=1),this.isStorageAndTrackEnabled()&&(Object.keys(this.inMemoryCounters).length>=tn?this.logger.debug("DiagnosticsClient: Early return increment as reaching memory limit"):(this.inMemoryCounters[e]=(this.inMemoryCounters[e]||0)+t,this.startTimersIfNeeded()))},e.prototype.recordHistogram=function(e,t){if(this.isStorageAndTrackEnabled())if(Object.keys(this.inMemoryHistograms).length>=tn)this.logger.debug("DiagnosticsClient: Early return recordHistogram as reaching memory limit");else{var n=this.inMemoryHistograms[e];n?(n.count+=1,n.min=Math.min(n.min,t),n.max=Math.max(n.max,t),n.sum+=t):this.inMemoryHistograms[e]={count:1,min:t,max:t,sum:t},this.startTimersIfNeeded()}},e.prototype.recordEvent=function(e,t){this.isStorageAndTrackEnabled()&&(this.inMemoryEvents.length>=10?this.logger.debug("DiagnosticsClient: Early return recordEvent as reaching memory limit"):(this.inMemoryEvents.push({event_name:e,time:Date.now(),event_properties:t}),this.startTimersIfNeeded()))},e.prototype.startTimersIfNeeded=function(){var e=this;this.saveTimer||(this.saveTimer=setTimeout((function(){e.saveAllDataToStorage().catch((function(t){e.logger.debug("DiagnosticsClient: Failed to save all data to storage",t)})).finally((function(){e.saveTimer=null}))}),1e3)),this.flushTimer||(this.flushTimer=setTimeout((function(){e._flush().catch((function(t){e.logger.debug("DiagnosticsClient: Failed to flush",t)})).finally((function(){e.flushTimer=null}))}),en))},e.prototype.saveAllDataToStorage=function(){return pe(this,void 0,void 0,(function(){var e,t,n,r;return ge(this,(function(i){switch(i.label){case 0:return this.storage?(e=de({},this.inMemoryTags),t=de({},this.inMemoryCounters),n=de({},this.inMemoryHistograms),r=me([],ve(this.inMemoryEvents),!1),this.inMemoryEvents=[],this.inMemoryTags={},this.inMemoryCounters={},this.inMemoryHistograms={},[4,Promise.all([this.storage.setTags(e),this.storage.incrementCounters(t),this.storage.setHistogramStats(n),this.storage.addEventRecords(r)])]):[2];case 1:return i.sent(),[2]}}))}))},e.prototype._flush=function(){return pe(this,void 0,void 0,(function(){var e,t,n,r,i,o,a,s,c,u;return ge(this,(function(l){switch(l.label){case 0:return this.storage?[4,this.saveAllDataToStorage()]:[2];case 1:return l.sent(),this.saveTimer=null,this.flushTimer=null,[4,this.storage.getAllAndClear()];case 2:return e=l.sent(),t=e.tags,n=e.counters,r=e.histogramStats,i=e.events,this.storage.setLastFlushTimestamp(Date.now()),o={},t.forEach((function(e){o[e.key]=e.value})),a={},n.forEach((function(e){a[e.key]=e.value})),s={},r.forEach((function(e){s[e.key]={count:e.count,min:e.min,max:e.max,avg:Math.round(e.sum/e.count*100)/100}})),c=i.map((function(e){return{event_name:e.event_name,time:e.time,event_properties:e.event_properties}})),0===Object.keys(a).length&&0===Object.keys(s).length&&0===c.length?[2]:(u={tags:o,histogram:s,counters:a,events:c},this.fetch(u),[2])}}))}))},e.prototype.fetch=function(e){return pe(this,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,2,,3]),!Ve())throw new Error("DiagnosticsClient: Fetch is not supported");return[4,fetch(this.serverUrl,{method:"POST",headers:{"X-ApiKey":this.apiKey,"Content-Type":"application/json"},body:JSON.stringify(e)})];case 1:return n.sent().ok?(this.logger.debug("DiagnosticsClient: Successfully sent diagnostics data"),[3,3]):(this.logger.debug("DiagnosticsClient: Failed to send diagnostics data."),[2]);case 2:return t=n.sent(),this.logger.debug("DiagnosticsClient: Failed to send diagnostics data. ",t),[3,3];case 3:return[2]}}))}))},e.prototype.initializeFlushInterval=function(){return pe(this,void 0,void 0,(function(){var e,t,n;return ge(this,(function(r){switch(r.label){case 0:return this.storage?(e=Date.now(),[4,this.storage.getLastFlushTimestamp()]):[2];case 1:return-1===(t=r.sent()||-1)?(this.storage.setLastFlushTimestamp(e),this._setFlushTimer(en),[2]):(n=e-t)>=en?(this._flush(),[2]):(this._setFlushTimer(en-n),[2])}}))}))},e.prototype._setFlushTimer=function(e){var t=this;this.flushTimer=setTimeout((function(){t._flush().catch((function(e){t.logger.debug("DiagnosticsClient: Failed to flush",e)})).finally((function(){t.flushTimer=null}))}),e)},e.prototype._setSampleRate=function(e){this.logger.debug("DiagnosticsClient: Setting sample rate to",e),this.config.sampleRate=e,this.shouldTrack=Mt(this.startTimestamp,this.config.sampleRate)&&this.config.enabled,this.logger.debug("DiagnosticsClient: Should track is",this.shouldTrack)},e}(),rn=function(){function e(){}return e.prototype.send=function(e,t,n){return Promise.resolve(null)},e.prototype.buildResponse=function(e){var t,n,r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T,w,k;if("object"!=typeof e)return null;var E=e.code||0,S=this.buildStatus(E);switch(S){case He.Success:return{status:S,statusCode:E,body:{eventsIngested:null!==(t=e.events_ingested)&&void 0!==t?t:0,payloadSizeBytes:null!==(n=e.payload_size_bytes)&&void 0!==n?n:0,serverUploadTime:null!==(r=e.server_upload_time)&&void 0!==r?r:0}};case He.Invalid:return{status:S,statusCode:E,body:{error:null!==(i=e.error)&&void 0!==i?i:"",missingField:null!==(o=e.missing_field)&&void 0!==o?o:"",eventsWithInvalidFields:null!==(a=e.events_with_invalid_fields)&&void 0!==a?a:{},eventsWithMissingFields:null!==(s=e.events_with_missing_fields)&&void 0!==s?s:{},eventsWithInvalidIdLengths:null!==(c=e.events_with_invalid_id_lengths)&&void 0!==c?c:{},epsThreshold:null!==(u=e.eps_threshold)&&void 0!==u?u:0,exceededDailyQuotaDevices:null!==(l=e.exceeded_daily_quota_devices)&&void 0!==l?l:{},silencedDevices:null!==(d=e.silenced_devices)&&void 0!==d?d:[],silencedEvents:null!==(f=e.silenced_events)&&void 0!==f?f:[],throttledDevices:null!==(p=e.throttled_devices)&&void 0!==p?p:{},throttledEvents:null!==(g=e.throttled_events)&&void 0!==g?g:[]}};case He.PayloadTooLarge:return{status:S,statusCode:E,body:{error:null!==(h=e.error)&&void 0!==h?h:""}};case He.RateLimit:return{status:S,statusCode:E,body:{error:null!==(v=e.error)&&void 0!==v?v:"",epsThreshold:null!==(m=e.eps_threshold)&&void 0!==m?m:0,throttledDevices:null!==(y=e.throttled_devices)&&void 0!==y?y:{},throttledUsers:null!==(b=e.throttled_users)&&void 0!==b?b:{},exceededDailyQuotaDevices:null!==(T=e.exceeded_daily_quota_devices)&&void 0!==T?T:{},exceededDailyQuotaUsers:null!==(w=e.exceeded_daily_quota_users)&&void 0!==w?w:{},throttledEvents:null!==(k=e.throttled_events)&&void 0!==k?k:[]}};case He.Timeout:default:return{status:S,statusCode:E}}},e.prototype.buildStatus=function(e){return ut(e)?He.Success:429===e?He.RateLimit:413===e?He.PayloadTooLarge:408===e?He.Timeout:e>=400&&e<500?He.Invalid:e>=500?He.Failed:He.Unknown},e}();function on(){return"undefined"!=typeof CompressionStream}function an(e){return pe(this,void 0,void 0,(function(){var t,n;return ge(this,(function(r){switch(r.label){case 0:if(void 0===(t=CompressionStream))return[2,void 0];r.label=1;case 1:return r.trys.push([1,3,,4]),n=new Blob([e]).stream().pipeThrough(new t("gzip")),[4,new Response(n).arrayBuffer()];case 2:return[2,r.sent()];case 3:return r.sent(),[2,void 0];case 4:return[2]}}))}))}var sn=function(){function e(e,t){this.key="AMP_remote_config_".concat(e.substring(0,10)),this.logger=t}return e.prototype.fetchConfig=function(){var e=null,t={remoteConfig:null,lastFetch:new Date};try{e=localStorage.getItem(this.key)}catch(e){return this.logger.debug("Remote config localstorage failed to access: ",e),Promise.resolve(t)}if(null===e)return this.logger.debug("Remote config localstorage gets null because the key does not exist"),Promise.resolve(t);try{var n=JSON.parse(e);return this.logger.debug("Remote config localstorage parsed successfully: ".concat(JSON.stringify(n))),Promise.resolve({remoteConfig:n.remoteConfig,lastFetch:new Date(n.lastFetch)})}catch(e){return this.logger.debug("Remote config localstorage failed to parse: ",e),localStorage.removeItem(this.key),Promise.resolve(t)}},e.prototype.setConfig=function(e){try{return localStorage.setItem(this.key,JSON.stringify(e)),this.logger.debug("Remote config localstorage set successfully."),Promise.resolve(!0)}catch(e){this.logger.debug("Remote config localstorage failed to set: ",e)}return Promise.resolve(!1)},e}(),cn=401,un=403,ln=429,dn=function(){function e(e,t,n,r){void 0===n&&(n="US"),this.callbackInfos=[],this.lastSuccessfulFetch=null,this.fetchPromise=null,this.isLastFetchInvalidApiKey=!1,this.apiKey=e,this.serverUrl=r||("US"===n?"https://sr-client-cfg.amplitude.com/config":"https://sr-client-cfg.eu.amplitude.com/config"),this.logger=t,this.storage=new sn(e,t)}return e.prototype.subscribe=function(e,t,n){var r=Je(),i={id:r,key:e,deliveryMode:t,callback:n};return this.callbackInfos.push(i),"all"===t?this.subscribeAll(i):this.subscribeWaitForRemote(i,t.timeout),r},e.prototype.unsubscribe=function(e){var t=this.callbackInfos.findIndex((function(t){return t.id===e}));return-1===t?(this.logger.debug("Remote config client unsubscribe failed because callback with id ".concat(e," doesn't exist.")),!1):(this.callbackInfos.splice(t,1),this.logger.debug("Remote config client unsubscribe succeeded removing callback with id ".concat(e,".")),!0)},e.prototype.updateConfigs=function(){return pe(this,void 0,void 0,(function(){var e,t=this;return ge(this,(function(n){switch(n.label){case 0:return this.lastSuccessfulFetch&&Date.now()-this.lastSuccessfulFetch<3e5?(this.logger.debug("Remote config client skipping updateConfigs: Too recent"),[2]):[4,this.getOrCreateFetchPromise()];case 1:return e=n.sent(),this.storage.setConfig(e),this.callbackInfos.forEach((function(n){t.sendCallback(n,e,"remote")})),[2]}}))}))},e.prototype.getOrCreateFetchPromise=function(){var e=this;return this.fetchPromise?this.fetchPromise:this.isLastFetchInvalidApiKey?(this.logger.debug("Remote config client skipping fetch: Invalid API key"),this.fetchPromise=Promise.resolve({remoteConfig:null,lastFetch:new Date}).finally((function(){e.fetchPromise=null})),this.fetchPromise):(this.fetchPromise=this.fetch().then((function(t){return null!==t.remoteConfig&&(e.lastSuccessfulFetch=Date.now()),t})).finally((function(){e.fetchPromise=null})),this.fetchPromise)},e.prototype.subscribeAll=function(e){return pe(this,void 0,void 0,(function(){var t,n,r,i=this;return ge(this,(function(o){switch(o.label){case 0:return t=this.getOrCreateFetchPromise().then((function(t){i.logger.debug("Remote config client subscription all mode fetched from remote: ".concat(JSON.stringify(t))),i.sendCallback(e,t,"remote"),i.storage.setConfig(t)})),n=this.storage.fetchConfig().then((function(e){return e})),[4,Promise.race([t,n])];case 1:return void 0!==(r=o.sent())&&(this.logger.debug("Remote config client subscription all mode fetched from cache: ".concat(JSON.stringify(r))),null!==r.remoteConfig?this.sendCallback(e,r,"cache"):this.logger.debug("Remote config client skips sending callback because cache is empty (first time user).")),[4,t];case 2:return o.sent(),[2]}}))}))},e.prototype.subscribeWaitForRemote=function(e,t){return pe(this,void 0,void 0,(function(){var n,r;return ge(this,(function(i){switch(i.label){case 0:n=new Promise((function(e,n){setTimeout((function(){n("Timeout exceeded")}),t)})),i.label=1;case 1:return i.trys.push([1,3,,5]),[4,Promise.race([this.getOrCreateFetchPromise(),n])];case 2:return r=i.sent(),this.logger.debug("Remote config client subscription wait for remote mode returns from remote."),this.sendCallback(e,r,"remote"),this.storage.setConfig(r),[3,5];case 3:return i.sent(),this.logger.debug("Remote config client subscription wait for remote mode exceeded timeout. Try to fetch from cache."),[4,this.storage.fetchConfig()];case 4:return null!==(r=i.sent()).remoteConfig?(this.logger.debug("Remote config client subscription wait for remote mode returns a cached copy."),this.sendCallback(e,r,"cache")):(this.logger.debug("Remote config client subscription wait for remote mode failed to fetch cache."),this.sendCallback(e,r,"remote")),[3,5];case 5:return[2]}}))}))},e.prototype.sendCallback=function(e,t,n){var r;e.lastCallback=new Date,r=e.key?e.key.split(".").reduce((function(e,t){return null===e?e:t in e?e[t]:null}),t.remoteConfig):t.remoteConfig,e.callback(r,n,t.lastFetch)},e.prototype.fetch=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=1e3),pe(this,void 0,void 0,(function(){var n,r,i,o,a,s,c=this;return ge(this,(function(u){switch(u.label){case 0:n=t/e,r={remoteConfig:null,lastFetch:new Date},i=function(r){var i,a,s,u,l,d;return ge(this,(function(f){switch(f.label){case 0:i=!0,a=new AbortController,s=setTimeout((function(){return a.abort()}),t),f.label=1;case 1:return f.trys.push([1,7,8,9]),[4,fetch(o.getUrlParams(),{method:"GET",headers:{Accept:"*/*"},signal:a.signal})];case 2:return(u=f.sent()).ok?[3,4]:[4,u.text()];case 3:return l=f.sent(),o.logger.debug("Remote config client fetch with retry time ".concat(e," failed with ").concat(u.status,": ").concat(l)),u.status===cn||u.status===un?(o.logger.error("Remote config client fetch failed with ".concat(u.status,". Invalid API key; future fetches will be skipped.")),o.isLastFetchInvalidApiKey=!0,i=!1):u.status>=400&&u.status<500&&u.status!==ln&&(i=!1),[3,6];case 4:return[4,u.json()];case 5:return[2,{value:{remoteConfig:f.sent(),lastFetch:new Date}}];case 6:return[3,9];case 7:return(d=f.sent())instanceof Error&&"AbortError"===d.name?o.logger.debug("Remote config client fetch with retry time ".concat(e," timed out after ").concat(t,"ms")):o.logger.debug("Remote config client fetch with retry time ".concat(e," is rejected because: "),d),[3,9];case 8:return clearTimeout(s),[7];case 9:return i?r<e-1?[4,new Promise((function(e){return setTimeout(e,c.getJitterDelay(n))}))]:[3,11]:[2,"break"];case 10:f.sent(),f.label=11;case 11:return[2]}}))},o=this,a=0,u.label=1;case 1:return a<e?[5,i(a)]:[3,4];case 2:if("object"==typeof(s=u.sent()))return[2,s.value];if("break"===s)return[3,4];u.label=3;case 3:return a++,[3,1];case 4:return[2,r]}}))}))},e.prototype.getJitterDelay=function(e){return Math.floor(Math.random()*e)},e.prototype.getUrlParams=function(){var t=encodeURIComponent(this.apiKey),n=new URLSearchParams;return n.append("config_group",e.CONFIG_GROUP),"".concat(this.serverUrl,"/").concat(t,"?").concat(n.toString())},e.CONFIG_GROUP="browser",e}(),fn=Ve(),pn=null==fn?void 0:fn.console,gn={},hn={},vn=!1;var mn,yn={addListener:function(e,t){var n,r=(n=e,!!pn&&"function"==typeof pn[n]&&(hn[n]||(hn[n]=pn[n],pn[n]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];try{if(gn[n]&&!vn){vn=!0;var r=gn[n];r&&r.forEach((function(t){try{t(n,e)}catch(e){}}))}}catch(e){}return vn=!1,hn[n].apply(pn,e)}),!0));if(!r)return new Error("Console override failed");gn[e]?gn[e].push(t):gn[e]=[t]},removeListener:function(e){var t,n;try{for(var r=he(Object.values(gn)),i=r.next();!i.done;i=r.next())for(var o=i.value,a=o.length-1;a>=0;a--)if(o[a]===e){o.splice(a,1);break}}catch(e){t={error:e}}finally{try{i&&!i.done&&(n=r.return)&&n.call(r)}finally{if(t)throw t.error}}},_restoreConsole:function(){var e,t;try{for(var n=he(Object.entries(hn)),r=n.next();!r.done;r=n.next()){var i=ve(r.value,2),o=i[0],a=i[1];a&&(pn[o]=a)}}catch(t){e={error:t}}finally{try{r&&!r.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}hn={},gn={}}};!function(e){e.US="US",e.EU="EU",e.STAGING="STAGING"}(mn||(mn={}));var bn=["a","button","input","select","textarea","label","video","audio",'[contenteditable="true" i]',"[data-amp-default-track]",".amp-default-track"],Tn="data-amp-track-",wn=["div","span","h1","h2","h3","h4","h5","h6"],kn=me(['input[type="button"]','input[type="submit"]','input[type="reset"]','input[type="image"]','input[type="file"]'],ve(["a","button",'[role="button"]','[role="link"]','[role="menuitem"]','[role="menuitemcheckbox"]','[role="menuitemradio"]','[role="option"]','[role="tab"]','[role="treeitem"]','[contenteditable="true" i]']),!1),En=kn,Sn=kn,_n=["*"];function In(e){return"string"==typeof e||"number"==typeof e||"boolean"==typeof e||null==e}function Pn(e,t,n){e&&An({json:e,allowlist:t.map(On),excludelist:n.map(On),ancestors:[]})}function An(e){var t,n,r=e.json,i=e.targetObject,o=e.allowlist,a=e.excludelist,s=e.ancestors,c=e.parentObject,u=e.targetKey;i||(i=r);var l=Object.keys(i);try{for(var d=he(l),f=d.next();!f.done;f=d.next()){var p=f.value,g=me(me([],ve(s),!1),[p],!1);In(i[p])?xn(g,o)&&!xn(g,a)||delete i[p]:An({json:r,targetObject:i[p],allowlist:o,excludelist:a,ancestors:g,parentObject:i,targetKey:p})}}catch(e){t={error:e}}finally{try{f&&!f.done&&(n=d.return)&&n.call(d)}finally{if(t)throw t.error}}0===Object.keys(i).length&&c&&u&&delete c[u]}function On(e){return e.startsWith("/")&&(e=e.slice(1)),e.split("/").map((function(e){return e.replace(/~0/g,"~").replace(/~1/g,"/")}))}function Cn(e,t,n,r){if(void 0===n&&(n=0),void 0===r&&(r=0),r===t.length)return n===e.length;if(n===e.length){for(;r<t.length&&"**"===t[r];)r++;return r===t.length}var i=t[r];if("**"===i){if(r+1===t.length)return!0;for(var o=n;o<=e.length;o++)if(Cn(e,t,o,r+1))return!0;return!1}return("*"===i||i===e[n])&&Cn(e,t,n+1,r+1)}function xn(e,t){return t.some((function(t){return Cn(e,t)}))}var Rn=function(){function e(e){this.request=e}return e.prototype.headers=function(e){var t,n;void 0===e&&(e=[]);var r=this.request.headers,i={};if(Array.isArray(r))r.forEach((function(e){var t=ve(e,2),n=t[0],r=t[1];i[n]=r}));else if(r instanceof Headers)r.forEach((function(e,t){i[t]=e}));else if("object"==typeof r&&null!==r)try{for(var o=he(Object.entries(r)),a=o.next();!a.done;a=o.next()){var s=ve(a.value,2),c=s[0],u=s[1];i[c]=u}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Fn(i,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){if("number"==typeof this._bodySize)return this._bodySize;var e=Ve();if(null==e?void 0:e.TextEncoder){var t=this.request.body;return this._bodySize=Ln(t,100),this._bodySize}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"method",{get:function(){return this.request.method},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.request.body?this.request.body:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),pe(this,void 0,void 0,(function(){return ge(this,(function(n){return 0===e.length?[2,null]:[2,jn(this.body,e,t)]}))}))},e}(),Dn=function(){function e(e,t){this.bodyRaw=e,this.requestHeaders=t}return e.prototype.headers=function(e){return void 0===e&&(e=[]),Fn(this.requestHeaders,{allow:e})},Object.defineProperty(e.prototype,"bodySize",{get:function(){return Ln(this.bodyRaw,100)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"body",{get:function(){return"string"==typeof this.bodyRaw?this.bodyRaw:null},enumerable:!1,configurable:!0}),e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),pe(this,void 0,void 0,(function(){return ge(this,(function(n){return 0===e.length?[2,null]:[2,jn(this.body,e,t)]}))}))},e}();function Ln(e,t){var n,r,i,o=Ve(),a=null==o?void 0:o.TextEncoder;if(a){var s;if("string"==typeof e)s=e,i=(new a).encode(s).length;else if(e instanceof Blob)i=(s=e).size;else if(e instanceof URLSearchParams)s=e,i=(new a).encode(s.toString()).length;else if(ArrayBuffer.isView(e))i=(s=e).byteLength;else if(e instanceof ArrayBuffer)i=(s=e).byteLength;else if(e instanceof FormData){var c=e,u=0,l=0;try{for(var d=he(c.entries()),f=d.next();!f.done;f=d.next()){var p=ve(f.value,2),g=p[0],h=p[1];if(u+=g.length,"string"==typeof h)u+=(new a).encode(h).length;else{if(!(h instanceof Blob))return;u+=h.size}if(++l>=t)return}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}i=u}else if(e instanceof ReadableStream)return void(s=e);return i}}var Nn,Un=function(){function e(e){this.response=e}return e.prototype.headers=function(e){var t;if(void 0===e&&(e=[]),this.response.headers instanceof Headers){var n=this.response.headers,r={};return null===(t=null==n?void 0:n.forEach)||void 0===t||t.call(n,(function(e,t){r[t]=e})),Fn(r,{allow:e})}},Object.defineProperty(e.prototype,"bodySize",{get:function(){var e,t;if(void 0!==this._bodySize)return this._bodySize;var n=null===(t=null===(e=this.response.headers)||void 0===e?void 0:e.get)||void 0===t?void 0:t.call(e,"content-length"),r=n?parseInt(n,10):void 0;return this._bodySize=r,r},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.response.status},enumerable:!1,configurable:!0}),e.prototype.text=function(){return pe(this,void 0,void 0,(function(){var e,t;return ge(this,(function(n){switch(n.label){case 0:this.clonedResponse||(this.clonedResponse=this.response.clone()),n.label=1;case 1:return n.trys.push([1,3,,4]),e=this.clonedResponse.text(),t=new Promise((function(e){return setTimeout((function(){return e(null)}),500)})),[4,Promise.race([e,t])];case 2:return[2,n.sent()];case 3:return n.sent(),[2,null];case 4:return[2]}}))}))},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),pe(this,void 0,void 0,(function(){return ge(this,(function(n){switch(n.label){case 0:return 0===e.length?[2,null]:[4,this.text()];case 1:return[2,jn(n.sent(),e,t)]}}))}))},e}(),Mn=function(){function e(e,t,n,r){this.statusCode=e,this.headersString=t,this.size=n,this.getJson=r}return Object.defineProperty(e.prototype,"bodySize",{get:function(){return this.size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this.statusCode},enumerable:!1,configurable:!0}),e.prototype.headers=function(e){var t,n;if(void 0===e&&(e=[]),!this.headersString)return{};var r={},i=this.headersString.split("\r\n");try{for(var o=he(i),a=o.next();!a.done;a=o.next()){var s=ve(a.value.split(": "),2),c=s[0],u=s[1];c&&u&&(r[c]=u)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return Fn(r,{allow:e})},e.prototype.json=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=[]),pe(this,void 0,void 0,(function(){var n;return ge(this,(function(r){return 0===e.length?[2,null]:(n=this.getJson())?(Pn(n,e,t),[2,n]):[2,null]}))}))},e}();function jn(e,t,n){if(!e)return null;try{var r=JSON.parse(e);return Pn(r,t,n),r}catch(e){return null}}!function(e){e.REDACT="redact",e.REMOVE="remove"}(Nn||(Nn={}));var qn="[REDACTED]",Fn=function(e,t){var n,r,i=t.allow,o=void 0===i?[]:i,a=t.strategy,s=void 0===a?Nn.REMOVE:a,c=me([],ve(qe),!1),u={},l=function(t){var n=t.toLowerCase();c.find((function(e){return e.toLowerCase()===n}))?s===Nn.REDACT&&(u[t]=qn):o.find((function(e){return e.toLowerCase()===n}))?u[t]=e[t]:s===Nn.REDACT&&(u[t]=qn)};try{for(var d=he(Object.keys(e)),f=d.next();!f.done;f=d.next()){l(f.value)}}catch(e){n={error:e}}finally{try{f&&!f.done&&(r=d.return)&&r.call(d)}finally{if(n)throw n.error}}return u},Bn=function(){function e(e,t,n,r,i,o,a,s,c,u,l){void 0===a&&(a=0),this.type=e,this.method=t,this.timestamp=n,this.startTime=r,this.url=i,this.requestWrapper=o,this.status=a,this.duration=s,this.responseWrapper=c,this.error=u,this.endTime=l}return e.prototype.toSerializable=function(){var e,t,n,r,i={type:this.type,method:this.method,url:this.url,timestamp:this.timestamp,status:this.status,duration:this.duration,error:this.error,startTime:this.startTime,endTime:this.endTime,requestHeaders:null===(e=this.requestWrapper)||void 0===e?void 0:e.headers(me([],ve(je),!1)),requestBodySize:null===(t=this.requestWrapper)||void 0===t?void 0:t.bodySize,responseHeaders:null===(n=this.responseWrapper)||void 0===n?void 0:n.headers(me([],ve(je),!1)),responseBodySize:null===(r=this.responseWrapper)||void 0===r?void 0:r.bodySize};return Object.fromEntries(Object.entries(i).filter((function(e){var t=ve(e,2);return t[0],void 0!==t[1]})))},e}();var $n=function(e,t){void 0===t&&(t=Je()),this.callback=e,this.id=t};function Hn(e){try{e()}catch(e){}}var Kn=function(){function e(t){this.eventCallbacks=new Map,this.isObserving=!1,this.logger=t;var n=Ve();e.isSupported()&&(this.globalScope=n)}return e.isSupported=function(){var e=Ve();return!!e&&!!e.fetch},e.prototype.subscribe=function(e,t){var n,r,i,o,a,s,c,u,l,d;if(this.logger||(this.logger=t),this.eventCallbacks.set(e.id,e),!this.isObserving){var f=null===(i=null===(r=null===(n=this.globalScope)||void 0===n?void 0:n.XMLHttpRequest)||void 0===r?void 0:r.prototype)||void 0===i?void 0:i.open,p=null===(s=null===(a=null===(o=this.globalScope)||void 0===o?void 0:o.XMLHttpRequest)||void 0===a?void 0:a.prototype)||void 0===s?void 0:s.send,g=null===(l=null===(u=null===(c=this.globalScope)||void 0===c?void 0:c.XMLHttpRequest)||void 0===u?void 0:u.prototype)||void 0===l?void 0:l.setRequestHeader;f&&p&&g&&this.observeXhr(f,p,g);var h=null===(d=this.globalScope)||void 0===d?void 0:d.fetch;h&&this.observeFetch(h),this.isObserving=!0}},e.prototype.unsubscribe=function(e){this.eventCallbacks.delete(e.id)},e.prototype.triggerEventCallbacks=function(e){var t=this;this.eventCallbacks.forEach((function(n){try{n.callback(e)}catch(e){Hn((function(){var n;null===(n=t.logger)||void 0===n||n.debug("an unexpected error occurred while triggering event callbacks",e)}))}}))},e.prototype.handleNetworkRequestEvent=function(e,t,n,r,i,o,a){var s;if(void 0!==o&&void 0!==a){var c,u,l,d="GET";if(!function(e){return"object"==typeof e&&null!==e&&"url"in e&&"method"in e}(t)?c=null===(s=null==t?void 0:t.toString)||void 0===s?void 0:s.call(t):(c=t.url,d=t.method),c)try{var f=new URL(c);c="".concat(f.protocol,"//").concat(f.host).concat(f.pathname).concat(f.search).concat(f.hash)}catch(e){}d=(null==n?void 0:n.method)||d,r&&(u=r.status),i&&(l={name:i.name||"UnknownError",message:i.message||"An unknown error occurred"},u=0);var p=Math.floor(performance.now()-a),g=Math.floor(o+p),h=new Bn(e,d,o,o,c,n,u,p,r,l,g);this.triggerEventCallbacks(h)}},e.prototype.getTimestamps=function(){var e,t;return{startTime:null===(e=Date.now)||void 0===e?void 0:e.call(Date),durationStart:null===(t=null===performance||void 0===performance?void 0:performance.now)||void 0===t?void 0:t.call(performance)}},e.prototype.observeFetch=function(e){var t=this;this.globalScope&&e&&(this.globalScope.fetch=function(n,r){return pe(t,void 0,void 0,(function(){var t,i,o,a,s=this;return ge(this,(function(c){switch(c.label){case 0:try{t=this.getTimestamps()}catch(e){Hn((function(){var t;return null===(t=s.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while retrieving timestamps",e)}))}c.label=1;case 1:return c.trys.push([1,3,,4]),[4,e(n,r)];case 2:return i=c.sent(),[3,4];case 3:return a=c.sent(),o=a,[3,4];case 4:try{this.handleNetworkRequestEvent("fetch",n,r?new Rn(r):void 0,i?new Un(i):void 0,o,null==t?void 0:t.startTime,null==t?void 0:t.durationStart)}catch(e){Hn((function(){var t;return null===(t=s.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while handling fetch",e)}))}if(i)return[2,i];throw o}}))}))})},e.createXhrJsonParser=function(e,t){return function(){var n;try{if("json"===e.responseType){if(null===(n=t.globalScope)||void 0===n?void 0:n.structuredClone)return t.globalScope.structuredClone(e.response)}else if(["text",""].includes(e.responseType))return JSON.parse(e.responseText)}catch(n){return n instanceof Error&&"InvalidStateError"===n.name&&Hn((function(){var n;return null===(n=t.logger)||void 0===n?void 0:n.debug("unexpected error when retrieving responseText. responseType='".concat(e.responseType,"'"))})),null}return null}},e.prototype.observeXhr=function(t,n,r){if(this.globalScope&&t&&n){var i=this.globalScope.XMLHttpRequest.prototype,o=this;i.open=function(){for(var e,n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var i=ve(n,2),a=i[0],s=i[1];try{this.$$AmplitudeAnalyticsEvent=de({method:a,url:null===(e=null==s?void 0:s.toString)||void 0===e?void 0:e.call(s),headers:{}},o.getTimestamps())}catch(e){Hn((function(){var t;return null===(t=o.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while calling xhr open",e)}))}return t.apply(this,n)},i.send=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];var i=this,a=e.createXhrJsonParser(this,o),s=t[0],c=i.$$AmplitudeAnalyticsEvent;return i.$$AmplitudeAnalyticsEvent&&i.addEventListener("loadend",(function(){try{var e=i.getAllResponseHeaders(),t=i.getResponseHeader("content-length"),n=new Mn(i.status,e,t?parseInt(t,10):void 0,a),r=i.$$AmplitudeAnalyticsEvent.headers,u=new Dn(s,r);c.status=i.status,o.handleNetworkRequestEvent("xhr",{url:c.url,method:c.method},u,n,void 0,c.startTime,c.durationStart)}catch(e){Hn((function(){var t;return null===(t=o.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while handling xhr send",e)}))}})),n.apply(i,t)},i.setRequestHeader=function(e,t){try{var n=this.$$AmplitudeAnalyticsEvent;n&&(n.headers[e]=t)}catch(e){Hn((function(){var t;return null===(t=o.logger)||void 0===t?void 0:t.debug("an unexpected error occurred while calling xhr setRequestHeader",e)}))}r.apply(this,[e,t])}}},e}(),zn=new Kn,Gn=function(){function e(){}return e.prototype.parse=function(){return pe(this,void 0,void 0,(function(){return ge(this,(function(e){return[2,de(de(de(de({},Me),this.getUtmParam()),this.getReferrer()),this.getClickIds())]}))}))},e.prototype.getUtmParam=function(){var e=Dt();return{utm_campaign:e.utm_campaign,utm_content:e.utm_content,utm_id:e.utm_id,utm_medium:e.utm_medium,utm_source:e.utm_source,utm_term:e.utm_term}},e.prototype.getReferrer=function(){var e,t,n={referrer:void 0,referring_domain:void 0};try{n.referrer=document.referrer||void 0,n.referring_domain=null!==(t=null===(e=n.referrer)||void 0===e?void 0:e.split("/")[2])&&void 0!==t?t:void 0}catch(e){}return n},e.prototype.getClickIds=function(){var e,t=Dt();return(e={})[Ie]=t[Ie],e[Pe]=t[Pe],e[Ae]=t[Ae],e[Oe]=t[Oe],e[Ce]=t[Ce],e[xe]=t[xe],e[Re]=t[Re],e[De]=t[De],e[Le]=t[Le],e[Ne]=t[Ne],e[Ue]=t[Ue],e},e}(),Vn="data-amp-mask",Wn="*****",Jn=/\b(?:\d[ -]*?){13,16}\b/,Yn=/(\d{3}-?\d{2}-?\d{4})/g,Xn=/[^\s@]+@[^\s@.]+\.[^\s@]+/g,Qn=function(e,t){var n,r;if(void 0===t&&(t=[]),"string"!=typeof e)return"";var i=e;i=(i=(i=i.replace(Jn,Wn)).replace(Yn,Wn)).replace(Xn,Wn);try{for(var o=he(t),a=o.next();!a.done;a=o.next()){var s=a.value;try{i=i.replace(s,Wn)}catch(e){}}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return i},Zn=function(e){if("undefined"==typeof document||!document.title)return"";var t=document.querySelector("title");return t&&t.hasAttribute(Vn)?Wn:e?e(document.title):document.title};function er(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var tr,nr,rr,ir={};function or(){if(tr)return ir;tr=1,Object.defineProperty(ir,"__esModule",{value:!0}),ir.Observable=void 0;const e=e=>Boolean(Symbol[e]),t=t=>e(t)?Symbol[t]:"@@"+t,n=t("iterator"),r=t("observable"),i=t("species");function o(e,t){let n=e[t];if(null!=n){if("function"!=typeof n)throw new TypeError(n+" is not a function");return n}}function a(e){let t=e.constructor;return void 0!==t&&(t=t[i],null===t&&(t=void 0)),void 0!==t?t:g}function s(e){s.log?s.log(e):setTimeout((()=>{throw e}))}function c(e){Promise.resolve().then((()=>{try{e()}catch(e){s(e)}}))}function u(e){let t=e._cleanup;if(void 0!==t&&(e._cleanup=void 0,t))try{if("function"==typeof t)t();else{let e=o(t,"unsubscribe");e&&e.call(t)}}catch(e){s(e)}}function l(e){e._observer=void 0,e._queue=void 0,e._state="closed"}function d(e,t,n){e._state="running";let r=e._observer;try{let i=o(r,t);switch(t){case"next":i&&i.call(r,n);break;case"error":if(l(e),!i)throw n;i.call(r,n);break;case"complete":l(e),i&&i.call(r)}}catch(e){s(e)}"closed"===e._state?u(e):"running"===e._state&&(e._state="ready")}function f(e,t,n){if("closed"!==e._state){if("buffering"!==e._state)return"ready"!==e._state?(e._state="buffering",e._queue=[{type:t,value:n}],void c((()=>function(e){let t=e._queue;if(t){e._queue=void 0,e._state="ready";for(let n=0;n<t.length&&(d(e,t[n].type,t[n].value),"closed"!==e._state);++n);}}(e)))):void d(e,t,n);e._queue.push({type:t,value:n})}}class p{constructor(e,t){this._cleanup=void 0,this._observer=e,this._queue=void 0,this._state="initializing";let n=this,r={get closed(){return"closed"===n._state},next(e){f(n,"next",e)},error(e){f(n,"error",e)},complete(){f(n,"complete")}};try{this._cleanup=t.call(void 0,r)}catch(e){r.error(e)}"initializing"===this._state&&(this._state="ready")}get closed(){return"closed"===this._state}unsubscribe(){"closed"!==this._state&&(l(this),u(this))}}class g{constructor(e){if(!(this instanceof g))throw new TypeError("Observable cannot be called as a function");if("function"!=typeof e)throw new TypeError("Observable initializer must be a function");this._subscriber=e}subscribe(e){return"object"==typeof e&&null!==e||(e={next:e,error:arguments[1],complete:arguments[2]}),new p(e,this._subscriber)}forEach(e){return new Promise(((t,n)=>{if("function"!=typeof e)return void n(new TypeError(e+" is not a function"));function r(){i.unsubscribe(),t()}let i=this.subscribe({next(t){try{e(t,r)}catch(e){n(e),i.unsubscribe()}},error:n,complete:t})}))}map(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(a(this))((t=>this.subscribe({next(n){try{n=e(n)}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}})))}filter(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return new(a(this))((t=>this.subscribe({next(n){try{if(!e(n))return}catch(e){return t.error(e)}t.next(n)},error(e){t.error(e)},complete(){t.complete()}})))}reduce(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=a(this),n=arguments.length>1,r=!1,i=arguments[1];return new t((t=>this.subscribe({next(o){let a=!r;if(r=!0,!a||n)try{i=e(i,o)}catch(e){return t.error(e)}else i=o},error(e){t.error(e)},complete(){if(!r&&!n)return t.error(new TypeError("Cannot reduce an empty sequence"));t.next(i),t.complete()}})))}async all(){let e=[];return await this.forEach((t=>e.push(t))),e}concat(...e){let t=a(this);return new t((n=>{let r,i=0;return function o(a){r=a.subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){i===e.length?(r=void 0,n.complete()):o(t.from(e[i++]))}})}(this),()=>{r&&(r.unsubscribe(),r=void 0)}}))}flatMap(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");let t=a(this);return new t((n=>{let r=[],i=this.subscribe({next(i){if(e)try{i=e(i)}catch(e){return n.error(e)}let a=t.from(i).subscribe({next(e){n.next(e)},error(e){n.error(e)},complete(){let e=r.indexOf(a);e>=0&&r.splice(e,1),o()}});r.push(a)},error(e){n.error(e)},complete(){o()}});function o(){i.closed&&0===r.length&&n.complete()}return()=>{r.forEach((e=>e.unsubscribe())),i.unsubscribe()}}))}[r](){return this}static from(t){let i="function"==typeof this?this:g;if(null==t)throw new TypeError(t+" is not an object");let a=o(t,r);if(a){let e=a.call(t);if(Object(e)!==e)throw new TypeError(e+" is not an object");return function(e){return e instanceof g}(e)&&e.constructor===i?e:new i((t=>e.subscribe(t)))}if(e("iterator")&&(a=o(t,n),a))return new i((e=>{c((()=>{if(!e.closed){for(let n of a.call(t))if(e.next(n),e.closed)return;e.complete()}}))}));if(Array.isArray(t))return new i((e=>{c((()=>{if(!e.closed){for(let n=0;n<t.length;++n)if(e.next(t[n]),e.closed)return;e.complete()}}))}));throw new TypeError(t+" is not observable")}static of(...e){return new("function"==typeof this?this:g)((t=>{c((()=>{if(!t.closed){for(let n=0;n<e.length;++n)if(t.next(e[n]),t.closed)return;t.complete()}}))}))}static get[i](){return this}}return ir.Observable=g,Object.defineProperty(g,Symbol("extensions"),{value:{symbol:r,hostReportError:s},configurable:!0}),ir}var ar=er(rr?nr:(rr=1,nr=or().Observable));function sr(e,t){return new ar((function(n){e.subscribe({next:function(e){t(e).then((function(e){return n.next(e)})).catch((function(e){return n.error(e)}))},error:function(e){n.error(e)},complete:function(){n.complete()}})}))}function cr(e,t){return new ar((function(n){var r=!1,i=new Set,o=function(){var e,t;r=!0;try{for(var n=he(i),o=n.next();!o.done;o=n.next()){var a=o.value;try{a.unsubscribe()}catch(e){}}}catch(t){e={error:t}}finally{try{o&&!o.done&&(t=n.return)&&t.call(n)}finally{if(e)throw e.error}}i.clear()},a=function(e){var t=e.subscribe({next:function(e){r||n.next(e)},error:function(e){r||(r=!0,n.error(e),o())},complete:function(){i.delete(t),r||0!==i.size||(n.complete(),o(),r=!0)}});i.add(t)};return a(e),a(t),o}))}function ur(e){var t=new Set,n=null;function r(){null==n||n.unsubscribe(),n=null,t.clear()}return new ar((function(i){return t.add(i),null===n&&(n=e.subscribe({next:function(e){var n,r,i;try{for(var o=he(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.next)||void 0===i||i.call(s,e)}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}},error:function(e){var n,i,o;try{for(var a=he(t),s=a.next();!s.done;s=a.next()){var c=s.value;null===(o=c.error)||void 0===o||o.call(c,e)}}catch(e){n={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(n)throw n.error}}r()},complete:function(){var e,n,i;try{for(var o=he(t),a=o.next();!a.done;a=o.next()){var s=a.value;null===(i=s.complete)||void 0===i||i.call(s)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(e)throw e.error}}r()}})),function(){t.delete(i),0===t.size&&n&&(n.unsubscribe(),n=null)}}))}var lr,dr={exports:{}};var fr,pr=function(){if(lr)return dr.exports;lr=1;var e=Object.prototype.hasOwnProperty;function t(e){return"[Throws: "+(e?e.message:"?")+"]"}function n(n){var r=[];return function n(i){if(null===i||"object"!=typeof i)return i;if(-1!==r.indexOf(i))return"[Circular]";if(r.push(i),"function"==typeof i.toJSON)try{var o=n(i.toJSON());return r.pop(),o}catch(e){return t(e)}if(Array.isArray(i)){var a=i.map(n);return r.pop(),a}var s=Object.keys(i).reduce((function(r,o){return r[o]=n(function(n,r){if(e.call(n,r))try{return n[r]}catch(e){return t(e)}return n[r]}(i,o)),r}),{});return r.pop(),s}(n)}return dr.exports=function(e,t,r){return JSON.stringify(n(e),t,r)},dr.exports.ensureProperties=n,dr.exports}(),gr=er(pr),hr=gr||t({__proto__:null,default:gr},[pr]),vr="https://app.amplitude.com",mr={US:vr,EU:"https://app.eu.amplitude.com",STAGING:"https://apps.stag2.amplitude.com"};var yr="__AMPLITUDE_MESSENGER_INSTANCE__",br="__AMPLITUDE_MESSENGER__",Tr=function(){function e(e){var t=(void 0===e?{}:e).origin,n=void 0===t?vr:t;this[fr]=!0,this.isSetup=!1,this.messageHandler=null,this.requestCallbacks={},this.actionHandlers=new Map,this.pendingMessages=new Map,this.scriptLoadPromises=new Map,this.endpoint=n}return e.prototype.notify=function(e){var t,n,r,i;null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message sent: ",JSON.stringify(e)),null===(i=null===(r=window.opener)||void 0===r?void 0:r.postMessage)||void 0===i||i.call(r,e,this.endpoint)},e.prototype.sendRequest=function(e,t,n){var r=this;void 0===n&&(n={timeout:15e3});var i="".concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9)),o={id:i,action:e,args:t};return new Promise((function(t,a){r.requestCallbacks[i]={resolve:t,reject:a},r.notify(o),n.timeout>0&&setTimeout((function(){a(new Error("".concat(e," timed out (id: ").concat(i,")"))),delete r.requestCallbacks[i]}),n.timeout)}))},e.prototype.handleResponse=function(e){var t;this.requestCallbacks[e.id]?(this.requestCallbacks[e.id].resolve(e.responseData),delete this.requestCallbacks[e.id]):null===(t=this.logger)||void 0===t||t.warn("No callback found for request id: ".concat(e.id))},e.prototype.registerActionHandler=function(e,t){var n,r,i,o;this.actionHandlers.has(e)&&(null===(o=null===(i=this.logger)||void 0===i?void 0:i.warn)||void 0===o||o.call(i,"Overwriting existing action handler for: ".concat(e))),this.actionHandlers.set(e,t);var a=this.pendingMessages.get(e);if(a){this.pendingMessages.delete(e);try{for(var s=he(a),c=s.next();!c.done;c=s.next()){t(c.value)}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}}},e.prototype.loadScriptOnce=function(e){return pe(this,void 0,void 0,(function(){var t,n,r;return ge(this,(function(i){switch(i.label){case 0:if(t=this.scriptLoadPromises.get(e))return[2,t];n=function(e){return document.querySelector('script[src="'.concat(CSS.escape(e),'"]'))?Promise.resolve({status:!0}):new Promise((function(t,n){var r;try{var i=document.createElement("script");i.type="text/javascript",i.async=!0,i.src=e,i.addEventListener("load",(function(){t({status:!0})}),{once:!0}),i.addEventListener("error",(function(){n({status:!1,message:"Failed to load the script ".concat(e)})})),null===(r=document.head)||void 0===r||r.appendChild(i)}catch(e){n(e)}}))}(e).then((function(){})),this.scriptLoadPromises.set(e,n),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n];case 2:return i.sent(),[3,4];case 3:throw r=i.sent(),this.scriptLoadPromises.delete(e),r;case 4:return[2]}}))}))},e.prototype.setup=function(e){var t,n,r=this,i=void 0===e?{}:e,o=i.logger,a=i.endpoint;o&&(this.logger=o),a&&this.endpoint===vr&&(this.endpoint=a),this.isSetup||(this.isSetup=!0,null===(n=null===(t=this.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Setting up messenger"),this.messageHandler=function(e){var t,n,i,o,a;if(null===(n=null===(t=r.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Message received: ",JSON.stringify(e)),r.endpoint===e.origin){var s=e.data,c=null==s?void 0:s.action;if(c)if("id"in s&&s.id)null===(o=null===(i=r.logger)||void 0===i?void 0:i.debug)||void 0===o||o.call(i,"Received Response to previous request: ",JSON.stringify(e)),r.handleResponse(s);else{if("ping"===c)return void r.notify({action:"pong"});var u=r.actionHandlers.get(c);if(u)u(s.data);else{var l=null!==(a=r.pendingMessages.get(c))&&void 0!==a?a:[];l.push(s.data),r.pendingMessages.set(c,l)}}}},window.addEventListener("message",this.messageHandler),this.notify({action:"page-loaded"}))},e.prototype.destroy=function(){this.messageHandler&&(window.removeEventListener("message",this.messageHandler),this.messageHandler=null),this.isSetup=!1,this.actionHandlers.clear(),this.pendingMessages.clear(),this.requestCallbacks={},this.scriptLoadPromises.clear();var e=Ve();(null==e?void 0:e[br])===this&&delete e[br]},e}();function wr(e){var t,n=Ve(),r=null==n?void 0:n[br];if("object"==typeof(t=r)&&null!==t&&yr in t&&!0===t[yr])return r;var i=new Tr(e);return n&&(n[br]=i),i}fr=yr;var kr="__AMPLITUDE_BACKGROUND_CAPTURE__";var Er={always:"always",ifEmptyCampaign:"ifEmptyCampaign"},Sr=function(e,t){return"boolean"==typeof e?e:!1!==(null==e?void 0:e[t])},_r=function(e){return Sr(e,"attribution")},Ir=function(e){return Sr(e,"formInteractions")},Pr=function(e){return Sr(e,"pageViews")},Ar=function(e){return Sr(e,"sessions")},Or=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.networkTracking||"object"==typeof e.networkTracking)},Cr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.elementInteractions||"object"==typeof e.elementInteractions)},xr=function(e){return"boolean"==typeof e?e:"object"==typeof e&&(!0===e.frustrationInteractions||"object"==typeof e.frustrationInteractions)},Rr=function(e){if(Cr(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.elementInteractions)return e.autocapture.elementInteractions},Dr=function(e){if(xr(e.autocapture)&&"object"==typeof e.autocapture&&"object"==typeof e.autocapture.frustrationInteractions)return e.autocapture.frustrationInteractions},Lr=function(e){var t;if(Or(e.autocapture)){var n=void 0;return"object"==typeof e.autocapture&&"object"==typeof e.autocapture.networkTracking?n=e.autocapture.networkTracking:e.networkTrackingOptions&&(n=e.networkTrackingOptions),de(de({},n),{captureRules:null===(t=null==n?void 0:n.captureRules)||void 0===t?void 0:t.map((function(t){var n,r,i;if((null===(n=t.urls)||void 0===n?void 0:n.length)&&(null===(r=t.hosts)||void 0===r?void 0:r.length)){var o=JSON.stringify(t.hosts),a=JSON.stringify(t.urls);return null===(i=e.loggerProvider)||void 0===i||i.warn("Found network capture rule with both urls='".concat(a,"' and hosts='").concat(o,"' set. ")+"Definition of urls takes precedence over hosts, so ignoring hosts."),de(de({},t),{hosts:void 0})}return t}))})}},Nr=function(e){var t,n=function(){return!1},r=void 0,i=e.pageCounter;return Pr(e.defaultTracking)&&(n=void 0,t=void 0,e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.pageViews&&"object"==typeof e.defaultTracking.pageViews&&("trackOn"in e.defaultTracking.pageViews&&(n=e.defaultTracking.pageViews.trackOn),"trackHistoryChanges"in e.defaultTracking.pageViews&&(r=e.defaultTracking.pageViews.trackHistoryChanges),"eventType"in e.defaultTracking.pageViews&&e.defaultTracking.pageViews.eventType&&(t=e.defaultTracking.pageViews.eventType))),{trackOn:n,trackHistoryChanges:r,eventType:t,pageCounter:i}},Ur=function(e){return _r(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&e.defaultTracking.attribution&&"object"==typeof e.defaultTracking.attribution?de({},e.defaultTracking.attribution):{}},Mr=function(e,t){for(var n=0;n<t.length;n++){var r=t[n],i=r.name,o=r.args,a=r.resolve,s=e&&e[i];if("function"==typeof s){var c=s.apply(e,o);"function"==typeof a&&a(null==c?void 0:c.promise)}}return e},jr=function(e){return e&&void 0!==e._q},qr="2.37.2",Fr="amplitude-ts",Br=function(){function e(){this.name="@amplitude/plugin-context-browser",this.type="before",this.library="".concat(Fr,"/").concat(qr),"undefined"!=typeof navigator&&(this.userAgent=navigator.userAgent)}return e.prototype.setup=function(e){return this.config=e,Promise.resolve(void 0)},e.prototype.execute=function(e){var t,n;return pe(this,void 0,void 0,(function(){var r,i,o;return ge(this,(function(a){return r=(new Date).getTime(),i=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1,o=null!==(n=e.event_id)&&void 0!==n?n:i+1,this.config.lastEventId=o,e.time||(this.config.lastEventTime=r),[2,de(de(de(de(de(de(de(de({user_id:this.config.userId,device_id:this.config.deviceId,session_id:this.config.sessionId,time:r},this.config.appVersion&&{app_version:this.config.appVersion}),this.config.trackingOptions.platform&&{platform:"Web"}),this.config.trackingOptions.language&&{language:Rt()}),this.config.trackingOptions.ipAddress&&{ip:"$remote"}),{insert_id:Je(),partner_id:this.config.partnerId,plan:this.config.plan}),this.config.ingestionMetadata&&{ingestion_metadata:{source_name:this.config.ingestionMetadata.sourceName,source_version:this.config.ingestionMetadata.sourceVersion}}),e),{event_id:o,library:this.library,user_agent:this.userAgent})]}))}))},e}(),$r=1e3,Hr=function(e){function t(t){var n,r,i,o=this;try{i=null===(n=Ve())||void 0===n?void 0:n.localStorage}catch(e){null===(r=null==t?void 0:t.loggerProvider)||void 0===r||r.debug("Failed to access localStorage. error=".concat(JSON.stringify(e))),i=void 0}return(o=e.call(this,i)||this).loggerProvider=null==t?void 0:t.loggerProvider,o}return ce(t,e),t.prototype.set=function(t,n){var r;return pe(this,void 0,void 0,(function(){var i;return ge(this,(function(o){switch(o.label){case 0:return Array.isArray(n)&&n.length>$r?(i=n.length-$r,[4,e.prototype.set.call(this,t,n.slice(0,$r))]):[3,2];case 1:return o.sent(),null===(r=this.loggerProvider)||void 0===r||r.error("Failed to save ".concat(i," events because the queue length exceeded ").concat($r,".")),[3,4];case 2:return[4,e.prototype.set.call(this,t,n)];case 3:o.sent(),o.label=4;case 4:return[2]}}))}))},t}(Ht),Kr=function(e){function t(){var t;return e.call(this,null===(t=Ve())||void 0===t?void 0:t.sessionStorage)||this}return ce(t,e),t}(Ht),zr=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.state={done:4},n.customHeaders=t,n}return ce(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),pe(this,void 0,void 0,(function(){var r=this;return ge(this,(function(i){return[2,new Promise((function(i,o){"undefined"==typeof XMLHttpRequest&&o(new Error("XHRTransport is not supported."));var a=new XMLHttpRequest;a.open("POST",e,!0),a.onreadystatechange=function(){if(a.readyState===r.state.done){var e=a.responseText;try{i(r.buildResponse(JSON.parse(e)))}catch(e){i(r.buildResponse({code:a.status}))}}};var s={"Content-Type":"application/json",Accept:"*/*"},c=JSON.stringify(t),u=n&&c.length>=2048&&on(),l=function(e){var t,n;s=de(de({},r.customHeaders),s);try{for(var i=he(Object.entries(s)),o=i.next();!o.done;o=i.next()){var c=ve(o.value,2),u=c[0],l=c[1];a.setRequestHeader(u,l)}}catch(e){t={error:e}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(t)throw t.error}}a.send(e)};pe(r,void 0,void 0,(function(){var e;return ge(this,(function(t){switch(t.label){case 0:return u?[4,an(c)]:[3,2];case 1:return(e=t.sent())?(s["Content-Encoding"]="gzip",l(e)):l(c),[3,3];case 2:l(c),t.label=3;case 3:return[2]}}))})).catch(o)}))]}))}))},t}(rn),Gr=function(e){function t(t){void 0===t&&(t={});var n=e.call(this)||this;return n.customHeaders=t,n}return ce(t,e),t.prototype.send=function(e,t,n){return void 0===n&&(n=!1),pe(this,void 0,void 0,(function(){var r,i,o,a,s,c,u;return ge(this,(function(l){switch(l.label){case 0:if("undefined"==typeof fetch)throw new Error("FetchTransport is not supported");return r=JSON.stringify(t),i=n&&r.length>=2048&&on(),o=r,a={"Content-Type":"application/json",Accept:"*/*"},i?[4,an(r)]:[3,2];case 1:(s=l.sent())&&(a["Content-Encoding"]="gzip",o=s),l.label=2;case 2:return a=de(de({},this.customHeaders),a),[4,fetch(e,{headers:a,body:o,method:"POST"})];case 3:return[4,(c=l.sent()).text()];case 4:u=l.sent();try{return[2,this.buildResponse(JSON.parse(u))]}catch(e){return[2,this.buildResponse({code:c.status})]}return[2]}}))}))},t}(rn),Vr=function(e){function t(){return e.call(this)||this}return ce(t,e),t.prototype.send=function(e,t,n){return pe(this,void 0,void 0,(function(){var n=this;return ge(this,(function(r){return[2,new Promise((function(r,i){var o=Ve();if(!(null==o?void 0:o.navigator.sendBeacon))throw new Error("SendBeaconTransport is not supported");try{var a=JSON.stringify(t);return r(o.navigator.sendBeacon(e,a)?n.buildResponse({code:200,events_ingested:t.events.length,payload_size_bytes:a.length,server_upload_time:Date.now()}):n.buildResponse({code:500}))}catch(e){i(e)}}))]}))}))},t}(rn),Wr=function(e,t,n){return void 0===n&&(n=!0),pe(void 0,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,d;return ge(this,(function(f){switch(f.label){case 0:return r=function(e){return"".concat(be.toLowerCase(),"_").concat(e.substring(0,6))}(e),[4,t.getRaw(r)];case 1:return(i=f.sent())?n?[4,t.remove(r)]:[3,3]:[2,{optOut:!1}];case 2:f.sent(),f.label=3;case 3:return o=ve(i.split("."),6),a=o[0],s=o[1],c=o[2],u=o[3],l=o[4],d=o[5],[2,{deviceId:a,userId:Yr(s),sessionId:Jr(u),lastEventId:Jr(d),lastEventTime:Jr(l),optOut:Boolean(c)}]}}))}))},Jr=function(e){var t=parseInt(e,32);if(!isNaN(t))return t},Yr=function(e){if(atob&&escape&&e)try{return decodeURIComponent(escape(atob(e)))}catch(e){return}},Xr="[Amplitude]",Qr="".concat(Xr," Form Started"),Zr="".concat(Xr," Form Submitted"),ei="".concat(Xr," File Downloaded"),ti="session_start",ni="session_end",ri="".concat(Xr," File Extension"),ii="".concat(Xr," File Name"),oi="".concat(Xr," Link ID"),ai="".concat(Xr," Link Text"),si="".concat(Xr," Link URL"),ci="".concat(Xr," Form ID"),ui="".concat(Xr," Form Name"),li="".concat(Xr," Form Destination"),di="cookie",fi=Object.freeze({__proto__:null,DEFAULT_ACTION_CLICK_ALLOWLIST:wn,DEFAULT_CSS_SELECTOR_ALLOWLIST:bn,DEFAULT_DATA_ATTRIBUTE_PREFIX:Tn,EXCLUDE_INTERNAL_REFERRERS_CONDITIONS:Er,get IdentifyOperation(){return ue},get LogLevel(){return tt},OfflineDisabled:null,get RevenueProperty(){return ze},get ServerZone(){return mn},get SpecialEventType(){return le}}),pi=function(e){var t=e.split(".");return t.length<=2?e:t.slice(t.length-2,t.length).join(".")},gi=function(e,t,n,r,i,o){void 0===i&&(i=!0),e.referrer;var a=e.referring_domain,s=fe(e,["referrer","referring_domain"]),c=t||{};c.referrer;var u,l=c.referring_domain,d=fe(c,["referrer","referring_domain"]),f=n.excludeInternalReferrers;if(f){var p=vi(f,r);if(!(p instanceof TypeError)&&e.referring_domain&&Ti(e.referring_domain,o)){if("always"===p)return mi(p,e.referring_domain,r),!1;if("ifEmptyCampaign"===p&&(u=de(de({},e),{referring_domain:void 0,referrer:void 0}),Object.values(u).every((function(e){return!e}))))return mi(p,e.referring_domain,r),!1}}if(hi(n.excludeReferrers,e.referring_domain))return r.debug("This is not a new campaign because ".concat(e.referring_domain," is in the exclude referrer list.")),!1;if(!i&&function(e){return Object.values(e).every((function(e){return!e}))}(e)&&t)return r.debug("This is not a new campaign because this is a direct traffic in the same session."),!1;var g=JSON.stringify(s)!==JSON.stringify(d),h=pi(a||"")!==pi(l||""),v=!t||g||h;return v?r.debug("This is a new campaign. An $identify event will be sent."):r.debug("This is not a new campaign because it's the same as the previous one."),v},hi=function(e,t){return void 0===e&&(e=[]),void 0===t&&(t=""),e.some((function(e){return e instanceof RegExp?e.test(t):e===t}))},vi=function(e,t){if(!0===e)return Er.always;if("object"==typeof e){var n=e.condition;if("string"==typeof n&&Object.keys(Er).includes(n))return n;if(void 0===n)return Er.always}var r="Invalid configuration provided for attribution.excludeInternalReferrers: ".concat(JSON.stringify(e));return t.error(r),new TypeError(r)};function mi(e,t,n){var r="This is not a new campaign because referring_domain=".concat(t," is on the same domain as the current page and it is configured to exclude internal referrers");"always"===e?n.debug(r):"ifEmptyCampaign"===e&&n.debug("".concat(r," with empty campaign parameters"))}var yi=["ac.in","ac.jp","ac.kr","ac.th","ac.uk","ac.za","appspot.com","asn.au","azurewebsites.net","cloudfront.net","myshopify.com","blogspot.com","co.ca","co.in","co.jp","co.kr","co.nz","co.th","co.uk","co.za","com.ar","com.au","com.br","com.cn","com.hk","com.in","com.jp","com.kr","com.mx","com.pl","com.sg","com.tr","com.tw","ed.jp","edu.au","edu.br","edu.cn","edu.hk","edu.sg","edu.th","edu.tr","edu.tw","firebaseapp.com","fly.dev","gc.ca","geek.nz","github.io","gitlab.io","go.jp","go.kr","go.th","gob.ar","gob.mx","gov.au","gov.br","gov.cn","gov.hk","gov.in","gov.pl","gov.sg","gov.tr","gov.tw","gov.uk","gov.za","govt.nz","gr.jp","herokuapp.com","id.au","idv.hk","iwi.nz","lg.jp","ltd.uk","maori.nz","me.uk","mil.kr","ne.jp","ne.kr","net.au","net.br","net.cn","net.hk","net.in","net.nz","net.pl","net.sg","net.tr","net.tw","net.za","onrender.com","or.jp","or.kr","or.th","org.ar","org.au","org.br","org.cn","org.hk","org.in","org.mx","org.nz","org.pl","org.sg","org.tw","org.uk","org.za","pages.dev","pe.kr","plc.uk","re.kr","res.in","sch.uk","vercel.app","netlify.app","workers.dev"],bi=function(e){var t,n,r=e||(null===(n=null===(t=Ve())||void 0===t?void 0:t.location)||void 0===n?void 0:n.hostname);if(!r)return"";var i=r.split("."),o=i[i.length-1],a=i[i.length-2];return yi.find((function(e){return r.endsWith(".".concat(e))}))&&(o=i[i.length-2]+"."+i[i.length-1],a=i[i.length-3]),a?"".concat(a,".").concat(o):o},Ti=function(e,t){var n=Ve();if(!n)return!1;var r,i,o,a=(t||"").trim()||bi(n.location.hostname);return r=e,o=(i=a).startsWith(".")?i:".".concat(i),!!(r.startsWith(".")?r:".".concat(r)).endsWith(o)},wi=function(e){function t(t,n,r,i,o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T,w,k,E,S,_,I,P,A,O,C,x,R,D,L,N,U,M,j,q,F,B,$,H,K,z){void 0===r&&(r=new jt),void 0===i&&(i={domain:"",expiration:365,sameSite:"Lax",secure:!1,upgrade:!0}),void 0===c&&(c=1e3),void 0===u&&(u=5),void 0===l&&(l=30),void 0===d&&(d=di),void 0===v&&(v=new rt),void 0===m&&(m=tt.Warn),void 0===b&&(b=!1),void 0===T&&(T=!1),void 0===E&&(E=""),void 0===S&&(S="US"),void 0===P&&(P=18e5),void 0===A&&(A=new Hr({loggerProvider:v})),void 0===O&&(O={ipAddress:!0,language:!0,platform:!0}),void 0===C&&(C="fetch"),void 0===x&&(x=!1),void 0===R&&(R=!0),void 0===j&&(j=!0),void 0===q&&(q=0),void 0===H&&(H=!1),void 0===K&&(K=!1);var G,V=this;(V=e.call(this,{apiKey:t,storageProvider:A,transportProvider:Si(C)})||this).apiKey=t,V.appVersion=n,V.cookieOptions=i,V.defaultTracking=o,V.autocapture=a,V.flushIntervalMillis=c,V.flushMaxRetries=u,V.flushQueueSize=l,V.identityStorage=d,V.ingestionMetadata=f,V.instanceName=p,V.loggerProvider=v,V.logLevel=m,V.minIdLength=y,V.offline=b,V.partnerId=w,V.plan=k,V.serverUrl=E,V.serverZone=S,V.sessionTimeout=P,V.storageProvider=A,V.trackingOptions=O,V.transport=C,V.useBatch=x,V.fetchRemoteConfig=R,V.networkTrackingOptions=U,V.identify=M,V.enableDiagnostics=j,V.diagnosticsSampleRate=q,V.diagnosticsClient=F,V.remoteConfig=B,V.topLevelDomain=$,V.enableRequestBodyCompression=H,V._enableRequestBodyCompressionExperimental=K,V.customEnrichment=z,V.version=qr,V._optOut=!1,V._cookieStorage=r,V.deviceId=s,V.lastEventId=g,V.lastEventTime=h,V.optOut=T,V.deferredSessionId=I,V.sessionId=_,V.pageCounter=L,V.userId=D,V.debugLogsEnabled=N,V.loggerProvider.enable(N?tt.Debug:V.logLevel),V.networkTrackingOptions=U,V.identify=M,V.enableDiagnostics=j,V.diagnosticsSampleRate=q,V.diagnosticsClient=F;var W=null!==(G=null==B?void 0:B.fetchRemoteConfig)&&void 0!==G?G:R;return V.remoteConfig=V.remoteConfig||{},V.remoteConfig.fetchRemoteConfig=W,V.fetchRemoteConfig=W,V.topLevelDomain=$||bi(),V}return ce(t,e),Object.defineProperty(t.prototype,"cookieStorage",{get:function(){return this._cookieStorage},set:function(e){this._cookieStorage!==e&&(this._cookieStorage=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deviceId",{get:function(){return this._deviceId},set:function(e){this._deviceId!==e&&(this._deviceId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"userId",{get:function(){return this._userId},set:function(e){this._userId!==e&&(this._userId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sessionId",{get:function(){return this._sessionId},set:function(e){this._sessionId!==e&&(this._sessionId=e,void 0!==e&&void 0!==this._deferredSessionId&&(this._deferredSessionId=void 0),this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"deferredSessionId",{get:function(){return this._deferredSessionId},set:function(e){this._deferredSessionId!==e&&e!==this.sessionId&&(this._deferredSessionId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"optOut",{get:function(){return this._optOut},set:function(e){this._optOut!==e&&(this._optOut=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventTime",{get:function(){return this._lastEventTime},set:function(e){this._lastEventTime!==e&&(this._lastEventTime=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lastEventId",{get:function(){return this._lastEventId},set:function(e){this._lastEventId!==e&&(this._lastEventId=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pageCounter",{get:function(){return this._pageCounter},set:function(e){this._pageCounter!==e&&(this._pageCounter=e,this.updateStorage())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debugLogsEnabled",{set:function(e){this._debugLogsEnabled!==e&&(this._debugLogsEnabled=e,this.updateStorage())},enumerable:!1,configurable:!0}),t.prototype.updateStorage=function(){var e={deviceId:this._deviceId,userId:this._userId,sessionId:this._sessionId,deferredSessionId:this._deferredSessionId,optOut:this._optOut,lastEventTime:this._lastEventTime,lastEventId:this._lastEventId,pageCounter:this._pageCounter,debugLogsEnabled:this._debugLogsEnabled,cookieDomain:void 0};this.cookieStorage instanceof qt&&(e.cookieDomain=this.cookieStorage.options.domain),this.cookieStorage.set(xt(this.apiKey),e)},t}(ot),ki=function(e,t,n,r,i){return void 0===t&&(t={}),pe(void 0,void 0,void 0,(function(){var o,a,s,c,u,l,d,f,p,g,h,v,m,y,b,T,w,k,E,S,_,I,P,A,O,C,x,R,D,L,N,U,M,j,q,F,B,$,H,K,z,G,V,W,J,Y,X,Q,Z,ee,te;return ge(this,(function(ne){switch(ne.label){case 0:return o=t.identityStorage||di,a="",o!==di||(null===(I=t.cookieOptions)||void 0===I?void 0:I.domain)||""===(null===(P=t.cookieOptions)||void 0===P?void 0:P.domain)?[3,2]:[4,_i(void 0,r)];case 1:a=ne.sent(),ne.label=2;case 2:return s=de({domain:null!==(O=null===(A=t.cookieOptions)||void 0===A?void 0:A.domain)&&void 0!==O?O:a,expiration:365,sameSite:"Lax",secure:!1,upgrade:!0},t.cookieOptions),c={duplicateResolverFn:function(e){var t=Ft(e);if(!t)return!1;var n=JSON.parse(t);return Bt(n.cookieDomain,s.domain)},diagnosticsClient:r},u=Ei(t.identityStorage,s,c),[4,Wr(e,u,null===(x=null===(C=t.cookieOptions)||void 0===C?void 0:C.upgrade)||void 0===x||x)];case 3:return l=ne.sent(),[4,u.get(xt(e))];case 4:return d=ne.sent(),f=Dt(),p=f.ampTimestamp?Number(f.ampTimestamp):void 0,g=!p||Date.now()<p,h=null!==(U=null!==(N=null!==(L=null!==(R=t.deviceId)&&void 0!==R?R:g?null!==(D=f.ampDeviceId)&&void 0!==D?D:f.deviceId:void 0)&&void 0!==L?L:null==d?void 0:d.deviceId)&&void 0!==N?N:l.deviceId)&&void 0!==U?U:Je(),v=null!==(M=null==d?void 0:d.lastEventId)&&void 0!==M?M:l.lastEventId,m=null!==(j=null==d?void 0:d.lastEventTime)&&void 0!==j?j:l.lastEventTime,y=null!==(F=null!==(q=t.optOut)&&void 0!==q?q:null==d?void 0:d.optOut)&&void 0!==F?F:l.optOut,b=null!==(B=null==d?void 0:d.sessionId)&&void 0!==B?B:l.sessionId,T=null==d?void 0:d.deferredSessionId,w=null!==(H=null!==($=t.userId)&&void 0!==$?$:null==d?void 0:d.userId)&&void 0!==H?H:l.userId,n.previousSessionDeviceId=null!==(K=null==d?void 0:d.deviceId)&&void 0!==K?K:l.deviceId,n.previousSessionUserId=null!==(z=null==d?void 0:d.userId)&&void 0!==z?z:l.userId,k={ipAddress:null===(V=null===(G=t.trackingOptions)||void 0===G?void 0:G.ipAddress)||void 0===V||V,language:null===(J=null===(W=t.trackingOptions)||void 0===W?void 0:W.language)||void 0===J||J,platform:null===(X=null===(Y=t.trackingOptions)||void 0===Y?void 0:Y.platform)||void 0===X||X},E=null==d?void 0:d.pageCounter,S=null==d?void 0:d.debugLogsEnabled,void 0!==t.autocapture&&(t.defaultTracking=t.autocapture),[4,(_=new wi(e,t.appVersion,u,s,t.defaultTracking,t.autocapture,h,t.flushIntervalMillis,t.flushMaxRetries,t.flushQueueSize,o,t.ingestionMetadata,t.instanceName,v,m,null!==(Q=null==i?void 0:i.loggerProvider)&&void 0!==Q?Q:t.loggerProvider,t.logLevel,t.minIdLength,t.offline,y,t.partnerId,t.plan,t.serverUrl,null!==(Z=null==i?void 0:i.serverZone)&&void 0!==Z?Z:t.serverZone,b,T,t.sessionTimeout,t.storageProvider,k,t.transport,t.useBatch,t.fetchRemoteConfig,w,E,S,t.networkTrackingOptions,t.identify,null!==(ee=null==i?void 0:i.enableDiagnostics)&&void 0!==ee?ee:t.enableDiagnostics,null!==(te=null==i?void 0:i.diagnosticsSampleRate)&&void 0!==te?te:n._diagnosticsSampleRate,r,t.remoteConfig,a,t.enableRequestBodyCompression,n._enableRequestBodyCompressionExperimentalValue,t.customEnrichment)).storageProvider.isEnabled()];case 5:return ne.sent()||(_.loggerProvider.warn("Storage provider ".concat(_.storageProvider.constructor.name," is not enabled. Falling back to MemoryStorage.")),_.storageProvider=new jt),[2,_]}}))}))},Ei=function(e,t,n){switch(void 0===e&&(e=di),void 0===t&&(t={}),e){case"localStorage":return new Hr;case"sessionStorage":return new Kr;case"none":return new jt;default:return new qt(de(de({},t),{expirationDays:t.expiration}),n)}},Si=function(e){var t="object"==typeof e?e.type:e,n="object"==typeof e?e.headers:void 0;return"xhr"===t?new zr(n):"beacon"===t?new Vr:new Gr(n)},_i=function(e,t){return pe(void 0,void 0,void 0,(function(){var e,n,r,i,o,a,s;return ge(this,(function(c){switch(c.label){case 0:return[4,new qt(void 0,{diagnosticsClient:t}).isEnabled()];case 1:if(!c.sent()||"undefined"==typeof location||!location.hostname)return[2,""];if(e=location.hostname,1===(n=e.split(".")).length)return[2,""];for(r=[],i=1,yi.find((function(t){return e.endsWith(".".concat(t))}))&&(i=2),o=n.length-i-1;o>=0;--o)r.push(n.slice(o).join("."));o=0,c.label=2;case 2:if(!(o<r.length))return[3,7];a=r[o],c.label=3;case 3:return c.trys.push([3,5,,6]),[4,qt.isDomainWritable(a)];case 4:return c.sent()?[2,"."+a]:[3,6];case 5:return s=c.sent(),t&&t.recordEvent("cookies.tld.failure",{reason:"Unexpected exception checking domain is writable: ".concat(a),error:s instanceof Error?s.message:String(s)}),[3,6];case 6:return o++,[3,2];case 7:return t&&t.recordEvent("cookies.tld.failure",{reason:"Could not determine TLD for host ".concat(e)}),[2,""]}}))}))},Ii=function(e){var t={};for(var n in e){var r=e[n];r&&(t[n]=r)}return t},Pi="AMP_PAGE_VIEW",Ai=function(e){var t;void 0===e&&(e={});var n,r,i=Ve(),o=void 0,a=!1,s=e.trackOn,c=e.trackHistoryChanges,u=e.eventType,l=void 0===u?"[Amplitude] Page Viewed":u,d=function(e){var t=e;try{t=decodeURI(e)}catch(e){null==o||o.error("Malformed URI sequence: ",e)}return t},f=function(e){return pe(void 0,void 0,void 0,(function(){var t,n,r;return ge(this,(function(i){switch(i.label){case 0:return t=d("undefined"!=typeof location&&location.href||""),r={event_type:l},n=[{}],[4,Oi()];case 1:return[2,(r.event_properties=de.apply(void 0,[de.apply(void 0,n.concat([i.sent()])),{"[Amplitude] Page Domain":"undefined"!=typeof location&&location.hostname||"","[Amplitude] Page Location":t,"[Amplitude] Page Path":"undefined"!=typeof location&&d(location.pathname)||"","[Amplitude] Page Title":Zn(Qn),"[Amplitude] Page URL":t.split("?")[0],"[Amplitude] Page View ID":e}]),r)]}}))}))},p=function(){return void 0===s||"function"==typeof s&&s()},g="undefined"!=typeof location?location.href:null,h=function(){pe(void 0,void 0,void 0,(function(){var e,n,i,a,s;return ge(this,(function(u){switch(u.label){case 0:return e=location.href,n=xi(c,e,g||"")&&p(),g=e,n?(i=void 0,r&&(i=Je(),r.set(Pi,{pageViewId:i})),null==o||o.log("Tracking page view event"),null!=t?[3,1]:[3,3]):[3,4];case 1:return s=(a=t).track,[4,f(i)];case 2:s.apply(a,[u.sent()]),u.label=3;case 3:u.label=4;case 4:return[2]}}))}))},v={name:"@amplitude/plugin-page-view-tracking-browser",type:"enrichment",setup:function(e,s){return pe(void 0,void 0,void 0,(function(){var c,u,l;return ge(this,(function(d){switch(d.label){case 0:if(t=s,n=e,(o=e.loggerProvider).log("Installing @amplitude/plugin-page-view-tracking-browser"),a=!0,i){try{r=new Ht(i.sessionStorage)}catch(e){null==o||o.debug("sessionStorage is not available in this environment.")}i.addEventListener("popstate",h),i.history.pushState=new Proxy(i.history.pushState,{apply:function(e,t,n){var r=ve(n,3),i=r[0],o=r[1],s=r[2];e.apply(t,[i,o,s]),a&&h()}})}return p()?(o.log("Tracking page view event"),c=void 0,r&&(c=Je(),r.set(Pi,{pageViewId:c})),l=(u=t).track,[4,f(c)]):[3,2];case 1:l.apply(u,[d.sent()]),d.label=2;case 2:return[2]}}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){var t,i,a;return ge(this,(function(c){switch(c.label){case 0:return"attribution"===s&&Ci(e)?(null==o||o.log("Enriching campaign event to page view event with campaign parameters"),t=void 0,r?[4,r.get(Pi)]:[3,2]):[3,4];case 1:i=c.sent(),t=null==i?void 0:i.pageViewId,c.label=2;case 2:return[4,f(t)];case 3:a=c.sent(),e.event_type=a.event_type,e.event_properties=de(de({},e.event_properties),a.event_properties),c.label=4;case 4:return n&&e.event_type===l&&(n.pageCounter=n.pageCounter?n.pageCounter+1:1,e.event_properties=de(de({},e.event_properties),{"[Amplitude] Page Counter":n.pageCounter})),[2,e]}}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(e){return i&&(i.removeEventListener("popstate",h),a=!1),[2]}))}))}};return v},Oi=function(){return pe(void 0,void 0,void 0,(function(){var e;return ge(this,(function(t){switch(t.label){case 0:return e=Ii,[4,(new Gn).parse()];case 1:return[2,e.apply(void 0,[t.sent()])]}}))}))},Ci=function(e){if("$identify"===e.event_type&&e.user_properties){var t=e.user_properties,n=t[ue.SET]||{},r=t[ue.UNSET]||{},i=me(me([],ve(Object.keys(n)),!1),ve(Object.keys(r)),!1);return Object.keys(Me).every((function(e){return i.includes(e)}))}return!1},xi=function(e,t,n){if("pathOnly"===e){if(""==n)return!0;var r=new URL(t),i=new URL(n);return r.origin+r.pathname!==i.origin+i.pathname}return t!==n},Ri=function(){var e,t,n=[],r=function(e,t,r){e.addEventListener(t,r),n.push({element:e,type:t,handler:r})};return{name:"@amplitude/plugin-form-interaction-tracking-browser",type:"enrichment",setup:function(n,i){return pe(void 0,void 0,void 0,(function(){var o,a;return ge(this,(function(s){return t=function(e){if(Ir(e.defaultTracking)&&e.defaultTracking&&"object"==typeof e.defaultTracking&&"object"==typeof e.defaultTracking.formInteractions)return e.defaultTracking.formInteractions}(n),o=function(){if(i){if("undefined"!=typeof document){var o=new WeakSet,a=function(e){if(!o.has(e)){o.add(e);var a=!1;r(e,"change",(function(){var t,n=Li(e);a||i.track(Qr,((t={})[ci]=Di(e.id),t[ui]=Di(e.name),t[li]=n,t)),a=!0})),r(e,"submit",(function(r){var o,s,c=Li(e);if(a||i.track(Qr,((o={})[ci]=Di(e.id),o[ui]=Di(e.name),o[li]=c,o)),a=!0,void 0!==(null==t?void 0:t.shouldTrackSubmit))if("function"==typeof t.shouldTrackSubmit&&"undefined"!=typeof SubmitEvent&&r instanceof SubmitEvent)try{if(!t.shouldTrackSubmit(r))return}catch(e){n.loggerProvider.warn("shouldTrackSubmit callback threw an error, proceeding with tracking.")}else n.loggerProvider.warn("shouldTrackSubmit is ignored because it is not a function or event is not a SubmitEvent.");i.track(Zr,((s={})[ci]=Di(e.id),s[ui]=Di(e.name),s[li]=c,s)),a=!1}))}};Array.from(document.getElementsByTagName("form")).forEach(a),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"FORM"===e.nodeName&&a(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("form")).map(a)}))}))}))).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("Form interaction tracking requires a later version of @amplitude/analytics-browser. Form interaction events are not tracked.")},"complete"===document.readyState?o():(a=Ve())?a.addEventListener("load",o):n.loggerProvider.debug("Form interaction tracking is not installed because global is undefined."),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return null==e||e.disconnect(),n.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),n=[],[2]}))}))}}},Di=function(e){if("string"==typeof e)return e},Li=function(e){var t=e.getAttribute("action");try{t=new URL(encodeURI(null!=t?t:""),window.location.href).href}catch(e){}return t},Ni=function(){var e,t=[];return{name:"@amplitude/plugin-file-download-tracking-browser",type:"enrichment",setup:function(n,r){return pe(void 0,void 0,void 0,(function(){var i,o;return ge(this,(function(a){return i=function(){if(r){if("undefined"!=typeof document){var i=function(e){var n;try{n=new URL(e.href,window.location.href)}catch(e){return}var i=o.exec(n.href),a=null==i?void 0:i[1];a&&function(e,n,r){e.addEventListener(n,r),t.push({element:e,type:n,handler:r})}(e,"click",(function(){var t;a&&r.track(ei,((t={})[ri]=a,t[ii]=n.pathname,t[oi]=e.id,t[ai]=e.text,t[si]=e.href,t))}))},o=/\.(pdf|xlsx?|docx?|txt|rtf|csv|exe|key|pp(s|t|tx)|7z|pkg|rar|gz|zip|avi|mov|mp4|mpe?g|wmv|midi?|mp3|wav|wma)(\?.+)?$/;Array.from(document.getElementsByTagName("a")).forEach(i),"undefined"!=typeof MutationObserver&&(e=new MutationObserver((function(e){e.forEach((function(e){e.addedNodes.forEach((function(e){"A"===e.nodeName&&i(e),"querySelectorAll"in e&&"function"==typeof e.querySelectorAll&&Array.from(e.querySelectorAll("a")).map(i)}))}))}))).observe(document.body,{subtree:!0,childList:!0})}}else n.loggerProvider.warn("File download tracking requires a later version of @amplitude/analytics-browser. File download events are not tracked.")},"complete"===document.readyState?i():(o=Ve())?o.addEventListener("load",i):n.loggerProvider.debug("File download tracking is not installed because global is undefined."),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(n){return null==e||e.disconnect(),t.forEach((function(e){var t=e.element,n=e.type,r=e.handler;null==t||t.removeEventListener(n,r)})),t=[],[2]}))}))}}},Ui=!1,Mi=function(){var e=Ve(),t=[],n=function(n,r){(null==e?void 0:e.addEventListener)&&(null==e||e.addEventListener(n,r),t.push({type:n,handler:r}))};return{name:"@amplitude/plugin-network-checker-browser",type:"before",setup:function(e,t){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(r){return"undefined"==typeof navigator?(e.loggerProvider.debug("Network connectivity checker plugin is disabled because navigator is not available."),e.offline=!1,[2]):(e.offline=!navigator.onLine,n("online",(function(){e.loggerProvider.debug("Network connectivity changed to online."),e.offline=!1,setTimeout((function(){t.flush()}),e.flushIntervalMillis)})),n("offline",(function(){e.loggerProvider.debug("Network connectivity changed to offline."),e.offline=!0})),[2])}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(n){return t.forEach((function(t){var n=t.type,r=t.handler;null==e||e.removeEventListener(n,r)})),t=[],[2]}))}))}}};function ji(e){var t,n,r,i,o,a,s,c,u,l,d;if("object"==typeof e&&null!==e&&!Array.isArray(e)){var f=Object.keys(e);try{for(var p=he(f),g=p.next();!g.done;g=p.next()){var h=g.value;try{var v=e[h];"boolean"==typeof(null==v?void 0:v.enabled)&&(v.enabled?(delete v.enabled,0===Object.keys(v).length&&(e[h]=!0)):e[h]=!1),ji(v)}catch(e){}}}catch(e){t={error:e}}finally{try{g&&!g.done&&(n=p.return)&&n.call(p)}finally{if(t)throw t.error}}try{if(null===(u=null===(c=null===(s=e.autocapture)||void 0===s?void 0:s.networkTracking)||void 0===c?void 0:c.captureRules)||void 0===u?void 0:u.length)try{for(var m=he(e.autocapture.networkTracking.captureRules),y=m.next();!y.done;y=m.next()){var b=y.value;try{for(var T=(o=void 0,he(["responseHeaders","requestHeaders"])),w=T.next();!w.done;w=T.next()){var k=w.value,E=null!==(l=b[k])&&void 0!==l?l:{},S=E.captureSafeHeaders,_=E.allowlist;(S||_)&&(void 0===_||Array.isArray(_)?b[k]=me(me([],ve(S?je:[]),!1),ve(null!=_?_:[]),!1):delete b[k])}}catch(e){o={error:e}}finally{try{w&&!w.done&&(a=T.return)&&a.call(T)}finally{if(o)throw o.error}}}}catch(e){r={error:e}}finally{try{y&&!y.done&&(i=m.return)&&i.call(m)}finally{if(r)throw r.error}}}catch(e){}var I=null===(d=e.autocapture)||void 0===d?void 0:d.frustrationInteractions;I&&(I.rageClick&&(I.rageClicks=I.rageClick,delete I.rageClick),I.deadClick&&(I.deadClicks=I.deadClick,delete I.deadClick))}}function qi(e,t,n){var r,i,o=[];try{for(var a=he(null!=t?t:[]),s=a.next();!s.done;s=a.next()){var c=s.value;try{o.push(new RegExp(c))}catch(e){n.loggerProvider.warn("Invalid regex pattern: ".concat(c),e)}}}catch(e){r={error:e}}finally{try{s&&!s.done&&(i=a.return)&&i.call(a)}finally{if(r)throw r.error}}return e.concat(o)}function Fi(e,t){var n,r,i,o,a,s,c;if(e){ji(e);try{t.loggerProvider.debug("Update browser config with remote configuration:",JSON.stringify(e));var u=e;if(u&&"autocapture"in u){if("boolean"==typeof u.autocapture&&(t.autocapture=u.autocapture),"object"==typeof u.autocapture&&null!==u.autocapture){var l=de({},u.autocapture);if(void 0===t.autocapture&&(t.autocapture=u.autocapture),"object"==typeof u.autocapture.elementInteractions&&null!==u.autocapture.elementInteractions&&(null===(i=u.autocapture.elementInteractions.pageUrlAllowlistRegex)||void 0===i?void 0:i.length)){l.elementInteractions=de({},u.autocapture.elementInteractions);var d=l.elementInteractions,f=null!==(o=d.pageUrlAllowlist)&&void 0!==o?o:[],p=u.autocapture.elementInteractions.pageUrlAllowlistRegex;d.pageUrlAllowlist=qi(f,p,t),delete d.pageUrlAllowlistRegex}if("object"==typeof u.autocapture.networkTracking&&null!==u.autocapture.networkTracking&&(null===(a=u.autocapture.networkTracking.captureRules)||void 0===a?void 0:a.length)){l.networkTracking=de({},u.autocapture.networkTracking);var g=null!==(s=l.networkTracking.captureRules)&&void 0!==s?s:[];try{for(var h=he(g),v=h.next();!v.done;v=h.next()){var m=v.value;m.urls=qi(null!==(c=m.urls)&&void 0!==c?c:[],m.urlsRegex,t),delete m.urlsRegex}}catch(e){n={error:e}}finally{try{v&&!v.done&&(r=h.return)&&r.call(h)}finally{if(n)throw n.error}}}"boolean"==typeof t.autocapture&&(t.autocapture=de({attribution:t.autocapture,fileDownloads:t.autocapture,formInteractions:t.autocapture,pageViews:t.autocapture,sessions:t.autocapture,elementInteractions:t.autocapture,webVitals:t.autocapture,frustrationInteractions:t.autocapture},l)),"object"==typeof t.autocapture&&(t.autocapture=de(de({},t.autocapture),l))}t.defaultTracking=t.autocapture}"customEnrichment"in u&&null!==u.customEnrichment&&(t.customEnrichment=u.customEnrichment),t.loggerProvider.debug("Browser config after remote config update:",JSON.stringify(t))}catch(e){t.loggerProvider.error("Failed to apply remote configuration because of error: ",e)}}}var Bi,$i="1.24.2",Hi="[Amplitude] Element Clicked",Ki="[Amplitude] Element Tag",zi="[Amplitude] Element Text",Gi="[Amplitude] Page URL",Vi="[Amplitude] Viewport Height",Wi="[Amplitude] Viewport Width",Ji="[Amplitude] Page View ID",Yi="data-amp-mask-attributes",Xi=["input","select","textarea"],Qi=function(e,t){var n,r=null===(n=null===window||void 0===window?void 0:window.getComputedStyle)||void 0===n?void 0:n.call(window,e);return"pointer"===(null==r?void 0:r.getPropertyValue("cursor"))&&"click"===t},Zi=function(e){var t=e.pageUrlAllowlist,n=e.pageUrlExcludelist;return!(n&&n.length>0&&Nt(window.location.href,n))&&!!Nt(window.location.href,t)},eo=function(e,t,n){return void 0===n&&(n=!1),function(r,i){var o,a,s=e.shouldTrackEventResolver,c=null===(a=null===(o=null==i?void 0:i.tagName)||void 0===o?void 0:o.toLowerCase)||void 0===a?void 0:a.call(o);if(!c)return!1;if(s)return s(r,i);if(!Zi(e))return!1;var u=String(null==i?void 0:i.getAttribute("type"))||"";if("string"==typeof u)switch(u.toLowerCase()){case"hidden":case"password":return!1}var l=Qi(i,r);if(n&&l)return!0;if(t){var d=t.some((function(e){var t;return!!(null===(t=null==i?void 0:i.matches)||void 0===t?void 0:t.call(i,e))}));if(!d)return!1}switch(c){case"input":case"select":case"textarea":return"change"===r||"click"===r;default:return!!l||"click"===r}}},to=function(e){return Object.keys(e).reduce((function(t,n){var r=e[n];return function(e){return null==e||"object"==typeof e&&0===Object.keys(e).length||"string"==typeof e&&0===e.trim().length}(r)||(t[n]=r),t}),{})},no=function(){var e;try{var t=Ve(),n=null===(e=null==t?void 0:t.sessionStorage)||void 0===e?void 0:e.getItem("AMP_PAGE_VIEW");if(!n)return;var r=JSON.parse(n);if("string"==typeof r.pageViewId)return r.pageViewId}catch(e){}},ro=function(e,t){return e?t.some((function(t){var n;return null===(n=null==e?void 0:e.matches)||void 0===n?void 0:n.call(e,t)}))?e:ro(null==e?void 0:e.parentElement,t):null},io=function(e){return!(null===e.event.target||!e.closestTrackedAncestor)};!function(e){e[e.LEFT_OR_TOUCH_CONTACT=0]="LEFT_OR_TOUCH_CONTACT",e[e.MIDDLE=1]="MIDDLE",e[e.RIGHT=2]="RIGHT"}(Bi||(Bi={}));var oo="__AMPLITUDE_VISUAL_TAGGING__";var ao=Ve(),so=function(){return new ar((function(e){var t=new MutationObserver((function(t){e.next(t)}));return document.body&&t.observe(document.body,{childList:!0,attributes:!0,characterData:!0,subtree:!0}),function(){return t.disconnect()}}))},co=function(e){return void 0===e&&(e="click"),new ar((function(t){var n,r=function(e){t.next(e)};return null===(n=Ve())||void 0===n||n.document.addEventListener(e,r,{capture:!0}),function(){var t;null===(t=Ve())||void 0===t||t.document.removeEventListener(e,r,{capture:!0})}}))},uo=function(){var e=cr(new ar((function(e){var t=function(t){if(t instanceof ErrorEvent){var n={kind:"error"};t.error instanceof Error||t.error instanceof DOMException?n=de(de({},n),{message:t.error.message,stack:t.error.stack,filename:t.filename,lineNumber:t.lineno,columnNumber:t.colno}):"string"==typeof t.error&&(n.message=t.error),e.next(n)}};return ao.addEventListener("error",t),function(){ao.removeEventListener("error",t)}})),new ar((function(e){var t=function(t){var n={kind:"unhandledrejection"};t.reason instanceof Error||t.reason instanceof DOMException?(n.message=t.reason.message,n.stack=t.reason.stack):"string"==typeof t.reason&&(n.message=t.reason),e.next(n)};return ao.addEventListener("unhandledrejection",t),function(){ao.removeEventListener("unhandledrejection",t)}})));return cr(e,new ar((function(e){var t=function(t){for(var n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];var i=void 0;Array.isArray(n[0])&&"string"==typeof n[0][0]&&(i=n[0][0]),e.next({kind:"console",message:i})};return yn.addListener("error",t),function(){yn.removeListener(t)}})))},lo=function(e,t,n){e.forEach((function(e){if("string"!=typeof e&&"ATTACH_EVENT_PROPERTY"===e.actionType){var r=n.extractDataFromDataSource(e.dataSource,t.closestTrackedAncestor);t.targetElementProperties[e.destinationKey]=r}}))},fo={"[Amplitude] Element Clicked":"click","[Amplitude] Element Changed":"change"},po=function(e){var t,n,r,i,o=Object.values(fo).reduce((function(e,t){return e[t]=new Set,e}),{});if(!e)return o;try{for(var a=he(e),s=a.next();!s.done;s=a.next()){var c=s.value;try{try{for(var u=(r=void 0,he(c.definition)),l=u.next();!l.done;l=u.next()){var d=l.value,f=fo[d.event_type];f&&o[f].add(c.id)}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}catch(e){console.warn("Skipping Labeled Event due to malformed definition",null==c?void 0:c.id,e)}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},go=function(e){var t,n,r,i,o=new Map;try{for(var a=he(e),s=a.next();!s.done;s=a.next()){var c=s.value;try{for(var u=(r=void 0,he(c.conditions)),l=u.next();!l.done;l=u.next()){var d=l.value;if("LABELED_EVENT"===d.type){var f=d.match.eventId,p=o.get(f);p||(p=[],o.set(f,p)),p.push(c)}}}catch(e){r={error:e}}finally{try{l&&!l.done&&(i=u.return)&&i.call(u)}finally{if(r)throw r.error}}}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}return o},ho=function(e,t){return t.filter((function(t){return t.definition.some((function(t){return fo[t.event_type]===e.type&&t.filters.every((function(t){return function(e,t){try{if("[Amplitude] Element Text"===t.subprop_key)return"is"===t.subprop_op&&t.subprop_value.includes(e.targetElementProperties["[Amplitude] Element Text"]);if("[Amplitude] Element Hierarchy"===t.subprop_key)return"autotrack css match"===t.subprop_op&&!!e.closestTrackedAncestor.closest(t.subprop_value.toString())}catch(e){return console.error("Error matching event to filter",e),!1}return!1}(e,t)}))}))}))},vo=function(){function e(e,t,n,r){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.dataExtractor=n,this.options=r}return e.prototype.evaluate=function(e){var t,n,r=this.options.pageActions;if(!r)return e;var i=function(e,t){var n,r,i,o,a=new Set;try{for(var s=he(e),c=s.next();!c.done;c=s.next()){var u=c.value,l=t.get(u.id);if(l)try{for(var d=(i=void 0,he(l)),f=d.next();!f.done;f=d.next()){var p=f.value;a.add(p)}}catch(e){i={error:e}}finally{try{f&&!f.done&&(o=d.return)&&o.call(d)}finally{if(i)throw i.error}}}}catch(e){n={error:e}}finally{try{c&&!c.done&&(r=s.return)&&r.call(s)}finally{if(n)throw n.error}}return Array.from(a)}(ho(e,Array.from(this.groupedLabeledEvents[e.type]).map((function(e){return r.labeledEvents[e]}))),this.labeledEventToTriggerMap);try{for(var o=he(i),a=o.next();!a.done;a=o.next()){var s=a.value;lo(s.actions,e,this.dataExtractor)}}catch(e){t={error:e}}finally{try{a&&!a.done&&(n=o.return)&&n.call(o)}finally{if(t)throw t.error}}return e},e.prototype.update=function(e,t,n){this.groupedLabeledEvents=e,this.labeledEventToTriggerMap=t,this.options=n},e}(),mo=new Set(["id","class","style","value","onclick","onchange","oninput","onblur","onsubmit","onfocus","onkeydown","onkeyup","onkeypress","data-reactid","data-react-checksum","data-reactroot",Yi,Vn]),yo=["type"],bo=["svg","path","g"],To=["password","hidden"];function wo(e,t){var n,r,i,o,a,s;if(null===e)return null;var c=String(e.tagName).toLowerCase(),u={tag:c},l=Array.from(null!==(o=null===(i=e.parentElement)||void 0===i?void 0:i.children)&&void 0!==o?o:[]);l.length&&(u.index=l.indexOf(e),u.indexOfType=l.filter((function(t){return t.tagName===e.tagName})).indexOf(e));var d=null===(s=null===(a=e.previousElementSibling)||void 0===a?void 0:a.tagName)||void 0===s?void 0:s.toLowerCase();d&&(u.prevSib=String(d));var f=e.getAttribute("id");f&&(u.id=String(f));var p=Array.from(e.classList);p.length&&(u.classes=p);var g={},h=Array.from(e.attributes).filter((function(e){return!mo.has(e.name)})),v=!function(e){var t,n,r,i=null===(n=null===(t=null==e?void 0:e.tagName)||void 0===t?void 0:t.toLowerCase)||void 0===n?void 0:n.call(t),o=e instanceof HTMLElement&&"true"===(null===(r=e.getAttribute("contenteditable"))||void 0===r?void 0:r.toLowerCase());return!Xi.includes(i)&&!o}(e);if(!To.includes(String(e.getAttribute("type")))&&!bo.includes(c))try{for(var m=he(h),y=m.next();!y.done;y=m.next()){var b=y.value;v&&!yo.includes(b.name)||(t.has(b.name)?g[b.name]=Wn:g[b.name]=String(b.value).substring(0,128))}}catch(e){n={error:e}}finally{try{y&&!y.done&&(r=m.return)&&r.call(m)}finally{if(n)throw n.error}}return Object.keys(g).length&&(u.attrs=g),u}var ko,Eo=function(){function e(e,t){this.value=e,this.optimized=t}return e.prototype.toString=function(){return this.value},e}(),So=function(e,t,n){var r,i;if(e.nodeType!==Node.ELEMENT_NODE)return null;var o=e.getAttribute("id");if(t){if(o)return new Eo(l(o),!0);var a=e.tagName.toLowerCase();if("body"===a||"head"===a||"html"===a)return new Eo(a,!0)}var s=e.tagName.toLowerCase();if(o)return new Eo(s+l(o),!0);var c=e.parentNode;if(!c||c.nodeType===Node.DOCUMENT_NODE)return new Eo(s,!0);function u(e){var t=e.getAttribute("class");return t?t.split(/\s+/g).filter(Boolean).map((function(e){return"$"+e})):[]}function l(e){return"#"+CSS.escape(e)}for(var d=u(e),f=!1,p=!1,g=-1,h=-1,v=c.children,m=0;v&&(-1===g||!p)&&m<v.length;++m){var y=v[m];if(y.nodeType===Node.ELEMENT_NODE)if(h+=1,y!==e){if(!p&&y.tagName.toLowerCase()===s){f=!0;var b=new Set(d);if(b.size)for(var T=u(y),w=0;w<T.length;++w){var k=T[w];if(b.has(k)&&(b.delete(k),!b.size)){p=!0;break}}else p=!0}}else g=h}var E=s;if(n&&"input"===s.toLowerCase()&&e.getAttribute("type")&&!e.getAttribute("id")&&!e.getAttribute("class")&&(E+="[type="+CSS.escape(e.getAttribute("type")||"")+"]"),p)E+=":nth-child("+String(g+1)+")";else if(f)try{for(var S=he(d),_=S.next();!_.done;_=S.next()){var I=_.value;E+="."+CSS.escape(I.slice(1))}}catch(e){r={error:e}}finally{try{_&&!_.done&&(i=S.return)&&i.call(S)}finally{if(r)throw r.error}}return new Eo(E,!1)},_o=function(e,t){var n,r,i,o=this;this.replaceSensitiveString=function(e){return Qn(e,o.additionalMaskTextPatterns)},this.getHierarchy=function(e){var t,n,r,i,a,s=performance.now();if(!e)return[];for(var c,u=function(e){var t=[];if(!e)return t;t.push(e);for(var n=e.parentElement;n&&"HTML"!==n.tagName;)t.push(n),n=n.parentElement;return t}(e),l=new Map,d=u.length-1;d>=0;d--){var f=u[d];if(f){var p=(c=f.getAttribute(Yi))?c.split(",").map((function(e){return e.trim()})).filter((function(e){return e.length>0&&"id"!==e&&"class"!==e})):[],g=d===u.length-1?[]:null!==(r=l.get(u[d+1]))&&void 0!==r?r:new Set,h=new Set(me(me([],ve(g),!1),ve(p),!1));l.set(f,h)}}a=u.map((function(e){var t;return wo(e,null!==(t=l.get(e))&&void 0!==t?t:new Set)}));var v=function(e){(null==e?void 0:e.attrs)&&Object.entries(e.attrs).forEach((function(t){var n=ve(t,2),r=n[0],i=n[1];e.attrs&&(e.attrs[r]=o.replaceSensitiveString(i))}))};try{for(var m=he(a),y=m.next();!y.done;y=m.next())v(y.value)}catch(e){t={error:e}}finally{try{y&&!y.done&&(n=m.return)&&n.call(m)}finally{if(t)throw t.error}}var b=performance.now();return null===(i=o.diagnosticsClient)||void 0===i||i.recordHistogram("autocapturePlugin.getHierarchy",b-s),a},this.getNearestLabel=function(e){var t,n=e.parentElement;if(!n)return"";try{t=n.querySelector(":scope>span,h1,h2,h3,h4,h5,h6")}catch(e){t=null}return t?o.getText(t):o.getNearestLabel(n)},this.getElementPath=function(e){var t;if(!e)return"";var n=performance.now(),r=function(e,t){if(e.nodeType!==Node.ELEMENT_NODE)return"";for(var n=[],r=e;r;){var i=So(r,Boolean(t),r===e);if(!i)break;if(n.push(i),i.optimized)break;r=r.parentElement}return n.reverse(),n.join(" > ")}(e),i=performance.now();return null===(t=o.diagnosticsClient)||void 0===t||t.recordHistogram("autocapturePlugin.getElementPath",i-n),r},this.getEventProperties=function(e,t,n){var r,i,a,s,c,u,l=null===(a=null===(i=null==t?void 0:t.tagName)||void 0===i?void 0:i.toLowerCase)||void 0===a?void 0:a.call(i),d="function"==typeof t.getBoundingClientRect?t.getBoundingClientRect():{left:null,top:null},f=o.getHierarchy(t),p=null===(s=f[0])||void 0===s?void 0:s.attrs,g=o.getNearestLabel(t),h=(c=null!=p?p:{},u=n,Object.entries(c).reduce((function(e,t){var n=ve(t,2),r=n[0],i=n[1];if(r.startsWith(u)){var o=r.replace(u,"");o&&(e[o]=i||"")}return e}),{})),v=((r={})["[Amplitude] Element Hierarchy"]=f,r[Ki]=l,r[zi]=o.getText(t),r["[Amplitude] Element Position Left"]=null==d.left?null:Math.round(d.left),r["[Amplitude] Element Position Top"]=null==d.top?null:Math.round(d.top),r["[Amplitude] Element Attributes"]=h,r["[Amplitude] Element Path"]=o.getElementPath(t),r["[Amplitude] Element Parent Label"]=g,r[Gi]=Ut(window.location.href.split("?")[0]),r["[Amplitude] Page Title"]=Zn(o.replaceSensitiveString),r[Vi]=window.innerHeight,r[Wi]=window.innerWidth,r),m=no();if(m&&(v[Ji]=m),v["[Amplitude] Element ID"]=t.getAttribute("id")||"",v["[Amplitude] Element Class"]=t.getAttribute("class"),v["[Amplitude] Element Aria Label"]=null==p?void 0:p["aria-label"],"a"===l&&"click"===e&&t instanceof HTMLAnchorElement){var y=t.href.substring(0,128);v["[Amplitude] Element Href"]=o.replaceSensitiveString(y)}return to(v)},this.addTypeAndTimestamp=function(e,t){return{event:e,timestamp:Date.now(),type:t}},this.addAdditionalEventProperties=function(e,t,n,r,i){void 0===i&&(i=!1);var a=o.addTypeAndTimestamp(e,t);if(function(e){return"click"===e.type||"change"===e.type}(a)&&null!==a.event.target){if(i&&Qi(a.event.target,a.type))return a.closestTrackedAncestor=a.event.target,a.targetElementProperties=o.getEventProperties(a.type,a.closestTrackedAncestor,r),a;var s=ro(a.event.target,n);return s&&(a.closestTrackedAncestor=s,a.targetElementProperties=o.getEventProperties(a.type,s,r)),a}return a},this.extractDataFromDataSource=function(e,t){if("DOM_ELEMENT"===e.sourceType){var n=function(e,t){try{if("DOM_ELEMENT"===e.sourceType){var n=document.documentElement;return e.scope&&t&&(n=t.closest(e.scope)),n&&e.selector?n.querySelector(e.selector):n}}catch(e){return}}(e,t);if(!n)return;return"TEXT"===e.elementExtractType?o.getText(n):"ATTRIBUTE"===e.elementExtractType&&e.attribute?n.getAttribute(e.attribute):void 0}},this.getTextWithMaskedDescendants=function(e){var t,n,r="[".concat(Vn,"], [contenteditable]");if(!e.querySelector(r))return e.innerText;var i="",a=Array.from(e.childNodes);try{for(var s=he(a),c=s.next();!c.done;c=s.next()){var u=c.value;u.nodeType!==Node.TEXT_NODE?u instanceof Element&&(u.hasAttribute(Vn)||u.hasAttribute("contenteditable")?i+=Wn:i+=o.getTextWithMaskedDescendants(u)):i+=u.textContent||""}}catch(e){t={error:e}}finally{try{c&&!c.done&&(n=s.return)&&n.call(s)}finally{if(t)throw t.error}}return i},this.getText=function(e){if(null!==e.closest("[".concat(Vn,"]")))return Wn;var t="";return t=e.querySelector("[".concat(Vn,"], [contenteditable]"))?o.getTextWithMaskedDescendants(e):e.innerText||"",o.replaceSensitiveString(t.substring(0,255)).replace(/\s+/g," ").trim()},this.getEventTagProps=function(e){var t,n,r;if(!e)return{};var i=null===(r=null===(n=null==e?void 0:e.tagName)||void 0===n?void 0:n.toLowerCase)||void 0===r?void 0:r.call(n),a=((t={})[Ki]=i,t[zi]=o.getText(e),t[Gi]=window.location.href.split("?")[0],t);return to(a)},this.diagnosticsClient=null==t?void 0:t.diagnosticsClient;var a=null!==(i=e.maskTextRegex)&&void 0!==i?i:[],s=[];try{for(var c=he(a),u=c.next();!u.done;u=c.next()){var l=u.value;if(s.length>=25)break;if(l instanceof RegExp)s.push(l);else if("pattern"in l&&"string"==typeof l.pattern)try{s.push(new RegExp(l.pattern,"i"))}catch(e){}}}catch(e){n={error:e}}finally{try{u&&!u.done&&(r=c.return)&&r.call(c)}finally{if(n)throw n.error}}this.additionalMaskTextPatterns=s};!function(e){e.ClickObservable="clickObservable",e.ChangeObservable="changeObservable",e.NavigateObservable="navigateObservable",e.MutationObservable="mutationObservable",e.ScrollObservable="scrollObservable",e.ExposureObservable="exposureObservable",e.BrowserErrorObservable="browserErrorObservable",e.SelectionObservable="selectionObservable",e.MouseMoveObservable="mouseMoveObservable"}(ko||(ko={}));var Io=function(e,t){var n,r,i,o,a,s,c,u,l,d,f;void 0===e&&(e={}),null==t||t.diagnosticsClient.setTag("plugin.autocapture.version",$i);var p=e.dataAttributePrefix,g=void 0===p?Tn:p,h=e.visualTaggingOptions,v=void 0===h?{enabled:!0}:h;e.cssSelectorAllowlist=null!==(n=e.cssSelectorAllowlist)&&void 0!==n?n:bn,e.actionClickAllowlist=null!==(r=e.actionClickAllowlist)&&void 0!==r?r:wn,e.debounceTime=null!==(i=e.debounceTime)&&void 0!==i?i:0;var m=null!==(s=null!==(a=null===(o=e.viewportContentUpdated)||void 0===o?void 0:o.exposureDuration)&&void 0!==a?a:e.exposureDuration)&&void 0!==s?s:150;e.viewportContentUpdated=de(de({},e.viewportContentUpdated),{exposureDuration:m}),e.pageUrlExcludelist=null===(c=e.pageUrlExcludelist)||void 0===c?void 0:c.reduce((function(e,t){if("string"==typeof t&&e.push(t),t instanceof RegExp&&e.push(t),"object"==typeof t&&null!==t&&"pattern"in t)try{e.push(new RegExp(t.pattern))}catch(n){return console.warn("Invalid regex pattern: ".concat(t.pattern),n),e}return e}),[]);var y,b="@amplitude/plugin-autocapture-browser",T=[],w=new _o(e,t),k=new Set,E=new Set,S=function(){var t,n,r=ur(co().map((function(t){return w.addAdditionalEventProperties(t,"click",e.cssSelectorAllowlist,g)}))),i=ur(new ar((function(t){var n,r=function(n){var r=w.addAdditionalEventProperties(n,"change",e.cssSelectorAllowlist,g);t.next(r)};return null===(n=Ve())||void 0===n||n.document.addEventListener("change",r,{capture:!0}),function(){var e;return null===(e=Ve())||void 0===e?void 0:e.document.removeEventListener("change",r)}})));window.navigation&&(n=ur(new ar((function(t){var n=function(n){var r=w.addAdditionalEventProperties(n,"navigate",e.cssSelectorAllowlist,g);t.next(r)};return window.navigation.addEventListener("navigate",n),function(){window.navigation.removeEventListener("navigate",n)}}))));var o=ur(so().map((function(t){return w.addAdditionalEventProperties(t,"mutation",e.cssSelectorAllowlist,g)}))),a=new ar((function(e){var t,n=function(t){e.next(t)};return null===(t=Ve())||void 0===t||t.addEventListener("scroll",n),function(){var e;null===(e=Ve())||void 0===e||e.removeEventListener("scroll",n)}})),s=function(e,t){return new ar((function(n){var r,i=Ve();if(!(null==i?void 0:i.IntersectionObserver))return function(){};var o=new IntersectionObserver((function(e){e.forEach((function(e){n.next(e)}))}),{root:null,rootMargin:"0px",threshold:1}),a=t.join(",");(null!==(r=null==i?void 0:i.document.querySelectorAll(a))&&void 0!==r?r:[]).forEach((function(e){o.observe(e)}));var s=e.subscribe((function(e){return e.event.forEach((function(e){return e.addedNodes.forEach((function(e){e instanceof Element&&(e.matches(a)&&o.observe(e),e.querySelectorAll(a).forEach((function(e){o.observe(e)})))}))}))}));return function(){s.unsubscribe(),o.disconnect()}}))}(o,e.cssSelectorAllowlist);return(t={})[ko.ChangeObservable]=i,t[ko.ClickObservable]=r,t[ko.MutationObservable]=o,t[ko.NavigateObservable]=n,t[ko.ScrollObservable]=a,t[ko.ExposureObservable]=s,t},_=po(Object.values(null!==(l=null===(u=e.pageActions)||void 0===u?void 0:u.labeledEvents)&&void 0!==l?l:{})),I=go(null!==(f=null===(d=e.pageActions)||void 0===d?void 0:d.triggers)&&void 0!==f?f:[]),P=function(e,t,n,r){return new vo(e,t,n,r)}(_,I,w,e);return{name:b,type:"enrichment",setup:function(t,n){return pe(void 0,void 0,void 0,(function(){var r,i,o,a,s,c,u,l,d,f,p,h,A,O,C,x,R,D,L,N,U;return ge(this,(function(M){return"undefined"==typeof document||(r=!1,i={maxX:void 0,maxY:void 0},t.fetchRemoteConfig&&(t.remoteConfigClient?t.remoteConfigClient.subscribe("configs.analyticsSDK.pageActions","all",(function(t){!function(t){var n,r;t&&(e.pageActions=de(de({},e.pageActions),t),_=po(Object.values(null!==(n=e.pageActions.labeledEvents)&&void 0!==n?n:{})),I=go(null!==(r=e.pageActions.triggers)&&void 0!==r?r:[]),P.update(_,I,e))}(t)})):t.loggerProvider.debug("Remote config client is not provided, skipping remote config fetch")),o=eo(e,e.cssSelectorAllowlist),a=eo(e,e.actionClickAllowlist),s=S(),c=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackEvent,i=e.evaluateTriggers;return n.clickObservable.filter(io).filter((function(e){return r("click",e.closestTrackedAncestor)})).map((function(e){return i(e)})).subscribe((function(e){null==t||t.track(Hi,e.targetElementProperties)}))}({allObservables:s,amplitude:n,shouldTrackEvent:o,evaluateTriggers:P.evaluate.bind(P)}),T.push(c),u=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackEvent,o=e.evaluateTriggers;return n.changeObservable.filter(io).filter((function(e){return i("change",e.closestTrackedAncestor)})).map((function(e){return o(e)})).subscribe((function(e){null==t||t.track("[Amplitude] Element Changed",r("change",e.closestTrackedAncestor))}))}({allObservables:s,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return w.getEventProperties.apply(w,me(me([],ve(e),!1),[g],!1))},amplitude:n,shouldTrackEvent:o,evaluateTriggers:P.evaluate.bind(P)}),T.push(u),l=function(e){var t=e.amplitude,n=e.allObservables,r=e.options,i=e.getEventProperties,o=e.shouldTrackEvent,a=e.shouldTrackActionClick,s=n.clickObservable,c=n.mutationObservable,u=n.navigateObservable,l=s.filter((function(e){return!o("click",e.closestTrackedAncestor)})).map((function(e){var t=ro(e.event.target,r.actionClickAllowlist);return e.closestTrackedAncestor=t,null!==e.closestTrackedAncestor&&(e.targetElementProperties=i(e.type,e.closestTrackedAncestor)),e})).filter(io).filter((function(e){return a("click",e.closestTrackedAncestor)})),d=u?cr(c,u):c,f=cr(l,d),p=null,g=null;return sr(f,(function(e){if(p&&(clearTimeout(p),p=null),"click"===e.type)return g=e,p=setTimeout((function(){p=null,g=null}),500),Promise.resolve(null);if(g){var t=g;return g=null,Promise.resolve(t)}return Promise.resolve(null)})).subscribe((function(e){e&&(null==t||t.track(Hi,i("click",e.closestTrackedAncestor)))}))}({allObservables:s,options:e,getEventProperties:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return w.getEventProperties.apply(w,me(me([],ve(e),!1),[g],!1))},amplitude:n,shouldTrackEvent:o,shouldTrackActionClick:a}),l&&T.push(l),d=function(e){var t=e.allObservables.scrollObservable,n={maxX:0,maxY:0},r=t.subscribe((function(){var e,t,r,i,o=Ve(),a=Math.floor(null!==(t=null!==(e=null==o?void 0:o.scrollX)&&void 0!==e?e:null==o?void 0:o.pageXOffset)&&void 0!==t?t:0),s=Math.floor(null!==(i=null!==(r=null==o?void 0:o.scrollY)&&void 0!==r?r:null==o?void 0:o.pageYOffset)&&void 0!==i?i:0);n.maxX=Math.max(n.maxX,a),n.maxY=Math.max(n.maxY,s)}));return{unsubscribe:function(){r.unsubscribe()},getState:function(){return n},reset:function(){n.maxX=0,n.maxY=0}}}({allObservables:s}),T.push(d),f={},p=Ve(),h=function(e){e&&r||(setTimeout((function(){r=!1}),100),r=!0,function(e){var t,n,r,i,o=e.amplitude,a=e.scrollTracker,s=e.currentElementExposed,c=e.elementExposedForPage,u=e.exposureTracker,l=e.isPageEnd,d=e.lastScroll,f=a.getState(),p=Ve(),g=null!==(n=null==p?void 0:p.innerWidth)&&void 0!==n?n:0,h=null!==(r=null==p?void 0:p.innerHeight)&&void 0!==r?r:0,v=((t={})[Gi]=null===(i=null==p?void 0:p.location)||void 0===i?void 0:i.href,t["[Amplitude] Max Page X"]=f.maxX+g,t["[Amplitude] Max Page Y"]=f.maxY+h,t[Vi]=h,t[Wi]=g,t["[Amplitude] Element Exposed"]=Array.from(s),t),m=no();m&&(v[Ji]=m),0!==s.size||f.maxX!==d.maxX||f.maxY!==d.maxY?(null==o||o.track("[Amplitude] Viewport Content Updated",v),d.maxX=f.maxX,d.maxY=f.maxY,s.clear(),l&&(a.reset(),c.clear(),null==u||u.reset())):l&&(a.reset(),c.clear(),null==u||u.reset())}({amplitude:n,scrollTracker:d,currentElementExposed:E,elementExposedForPage:k,exposureTracker:f.exposure,isPageEnd:e,lastScroll:i}))},A=function(e){!function(e,t,n,r){if(!t.has(e)){t.add(e),n.add(e);var i=Array.from(n);JSON.stringify(i).length>=18e3&&r(!1)}}(e,k,E,h)},f.exposure=function(e){var t=e.allObservables,n=e.onExposure,r=e.dataExtractor,i=e.exposureDuration,o=void 0===i?150:i,a=new Map,s=new Map,c=t.exposureObservable.subscribe((function(e){var t=e,i=t.target;if(t.isIntersecting){if(!a.get(i)){var c=setTimeout((function(){a.set(i,!0);var e=r.getElementPath(i);n(e),s.set(i,null)}),o);s.set(i,c)}}else!t.isIntersecting&&t.intersectionRatio<1&&(c=s.get(i))&&(clearTimeout(c),s.set(i,null))}));return{unsubscribe:function(){c.unsubscribe()},reset:function(){s.forEach((function(e){e&&clearTimeout(e)})),s.clear(),a.clear()}}}({allObservables:s,onExposure:A,dataExtractor:w,exposureDuration:m}),f.exposure&&T.push(f.exposure),O=function(){h(!0)},null==p||p.addEventListener("beforeunload",O),y=function(){null==p||p.removeEventListener("beforeunload",O)},T.push({unsubscribe:function(){return y()}}),(C=s[ko.NavigateObservable])?T.push(C.subscribe((function(){h(!0)}))):p&&(x=function(){h(!0)},p.addEventListener("popstate",x),R=p.history.pushState,p.history&&R&&(p.history.pushState=new Proxy(R,{apply:function(e,t,n){var r=ve(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),h(!0)}})),T.push({unsubscribe:function(){p.removeEventListener("popstate",x),p.history&&R&&(p.history.pushState=R)}})),null===(U=null==t?void 0:t.loggerProvider)||void 0===U||U.log("".concat(b," has been successfully added.")),window.opener&&v.enabled&&(D=e.cssSelectorAllowlist,L=e.actionClickAllowlist,function(e,t){var n=e;if(!0!==n[oo]){n[oo]=!0;var r=t.dataExtractor,i=t.isElementSelectable,o=t.cssSelectorAllowlist,a=t.actionClickAllowlist,s=null,c=function(t){e.notify({action:"element-selected",data:t})},u=function(t,n){"selector-mode-changed"===t?e.notify({action:"track-selector-mode-changed",data:n}):"selector-moved"===t&&e.notify({action:"track-selector-moved",data:n})};e.registerActionHandler("initialize-visual-tagging-selector",(function(t){e.loadScriptOnce("https://cdn.amplitude.com/libs/visual-tagging-selector-1.0.0-alpha.js.gz").then((function(){var n;s=null===(n=null===window||void 0===window?void 0:window.amplitudeVisualTaggingSelector)||void 0===n?void 0:n.call(window,{getEventTagProps:r.getEventTagProps,isElementSelectable:function(e){return!i||i((null==t?void 0:t.actionType)||"click",e)},onTrack:u,onSelect:c,visualHighlightClass:"amp-visual-tagging-selector-highlight",messenger:e,cssSelectorAllowlist:o,actionClickAllowlist:a,extractDataFromDataSource:r.extractDataFromDataSource,dataExtractor:r,diagnostics:{autocapture:{version:$i}}}),e.notify({action:"selector-loaded"})})).catch((function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize visual tagging selector")}))})),e.registerActionHandler("close-visual-tagging-selector",(function(){var e;null===(e=null==s?void 0:s.close)||void 0===e||e.call(s)}))}}(N=wr(),{dataExtractor:w,isElementSelectable:eo(e,me(me([],ve(D),!1),ve(L),!1)),cssSelectorAllowlist:D,actionClickAllowlist:L}),function(e){var t=e;if(!0!==t[kr]){t[kr]=!0;var n="https://cdn.amplitude.com/libs/background-capture-1.0.0-alpha.3.js.gz",r=null,i=function(t,n){var r,i;"background-capture-complete"===t&&(null===(i=null===(r=e.logger)||void 0===r?void 0:r.debug)||void 0===i||i.call(r,"Background capture complete"),e.notify({action:"background-capture-complete",data:n}))};e.registerActionHandler("initialize-background-capture",(function(){var t,o;null===(o=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===o||o.call(t,"Initializing background capture (external script)");var a=new URL(n,e.endpoint).toString();e.loadScriptOnce(a).then((function(){var t,n,o;null===(n=null===(t=e.logger)||void 0===t?void 0:t.debug)||void 0===n||n.call(t,"Background capture script loaded (external)"),r=null===(o=null===window||void 0===window?void 0:window.amplitudeBackgroundCapture)||void 0===o?void 0:o.call(window,{messenger:e,onBackgroundCapture:i}),e.notify({action:"background-capture-loaded"})})).catch((function(){var t;null===(t=e.logger)||void 0===t||t.warn("Failed to initialize background capture")}))})),e.registerActionHandler("close-background-capture",(function(){var e;null===(e=null==r?void 0:r.close)||void 0===e||e.call(r),r=null}))}}(N),N.setup(de({logger:null==t?void 0:t.loggerProvider},(null==t?void 0:t.serverZone)&&{endpoint:mr[t.serverZone]})))),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){var e,t,n,r;return ge(this,(function(i){try{for(e=he(T),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(r=e.return)&&r.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},Po=["mutation","navigate"];function Ao(e,t){var n,r,i,o,a=t.event,s=a.pageX,c=a.pageY;e.yMin=Math.min(null!==(n=e.yMin)&&void 0!==n?n:c,c),e.yMax=Math.max(null!==(r=e.yMax)&&void 0!==r?r:c,c),e.xMin=Math.min(null!==(i=e.xMin)&&void 0!==i?i:s,s),e.xMax=Math.max(null!==(o=e.xMax)&&void 0!==o?o:s,s),e.isOutOfBounds=e.yMax-e.yMin>50||e.xMax-e.xMin>50}function Oo(e){if(0===e.length)return null;var t=e[0],n=e[e.length-1];return{rageClickEvent:de({"[Amplitude] Begin Time":new Date(t.timestamp).toISOString(),"[Amplitude] End Time":new Date(n.timestamp).toISOString(),"[Amplitude] Duration":n.timestamp-t.timestamp,"[Amplitude] Clicks":e.map((function(e){return{X:e.event.pageX,Y:e.event.pageY,Time:e.timestamp}})),"[Amplitude] Click Count":e.length},t.targetElementProperties),time:t.timestamp}}function Co(e){var t=this,n=e.amplitude,r=e.allObservables,i=e.shouldTrackRageClick,o=r.clickObservable,a=r.selectionObservable,s=[],c={},u=null;function l(e){s=[],c={},e&&(Ao(c,e),s.push(e))}var d=sr(o.filter((function(e){return i("click",e.closestTrackedAncestor)})),(function(e){return pe(t,void 0,void 0,(function(){var t;return ge(this,(function(n){return Ao(c,e),t=null,0===s.length||function(e,t){return e.length>0&&e[e.length-1].closestTrackedAncestor!==t.closestTrackedAncestor}(s,e)||function(e,t){var n=e[Math.max(0,e.length-4+1)];return t.timestamp-n.timestamp>=1e3}(s,e)||c.isOutOfBounds?(u&&(t=Oo(s)),l(e)):s.push(e),u&&(clearTimeout(u.timerId),u.resolve(t),u=null),s.length>=4?[2,new Promise((function(e){u={resolve:e,timerId:setTimeout((function(){e(Oo(s))}),1e3)}}))]:[2,null]}))}))})),f=null==a?void 0:a.subscribe((function(){l()})),p=d.subscribe((function(e){null!==e&&n.track("[Amplitude] Rage Click",e.rageClickEvent,{time:e.time})}));return{unsubscribe:function(){p.unsubscribe(),null==f||f.unsubscribe()}}}var xo,Ro;!function(e){e.INCREASING="increasing",e.DECREASING="decreasing"}(xo||(xo={})),function(e){e.X="x",e.Y="y"}(Ro||(Ro={}));function Do(e){var t=e.changes,n=e.changesThreshold,r=e.thresholdMs;return!(t.length<n)&&t[t.length-1]-t[0]<r}function Lo(e){e.changes=[],e.startTime=void 0}function No(e){for(var t=e.changes,n=e.thresholdMs,r=0,i=t[t.length-1];r<t.length;r++){if(i-t[r]<n)break}0!==r&&(e.startTime=t[r],e.changes.splice(0,r))}var Uo=function(e){var t=e.mouseDirectionChangeObservable,n=e.directionChanges,r=void 0===n?20:n,i=e.thresholdMs,o=void 0===i?2e3:i;return new ar((function(e){var n={changes:[],changesThreshold:r,thresholdMs:o},i={changes:[],changesThreshold:r,thresholdMs:o},a=void 0,s=null;function c(){void 0!==a&&(e.next(a),a=void 0,null!==s&&clearTimeout(s),Lo(n),Lo(i))}return t.subscribe((function(e){null!==s&&clearTimeout(s),function(e){var t=+Date.now();e.startTime=e.startTime||t;var n=e.changes,r=e.changesThreshold;n.push(t),n.length>r&&n.shift()}(e===Ro.X?n:i);var t=function(e,t){var n=void 0;if(Do(e)&&(n=e.startTime),Do(t)){var r=t.startTime;r&&(!n||r<n)&&(n=r)}return n}(n,i);return t?(a=a||t,s=setTimeout((function(){c(),s=null}),o)):c(),No(n),No(i),function(){null!==s&&(clearTimeout(s),s=null)}}))}))},Mo=function(e){var t=e.amplitude,n=e.options,r=e.allObservables,i=e.directionChanges,o=void 0===i?20:i,a=e.thresholdMs,s=void 0===a?2e3:a,c=function(e){var t=e.allWindowObservables.mouseMoveObservable;return new ar((function(e){var n=null,r=null,i=null;return t.subscribe((function(t){var o={x:t.clientX,y:t.clientY};null!==n?(o.x>n.x?(r===xo.DECREASING&&e.next(Ro.X),r=xo.INCREASING):o.x<n.x&&(r===xo.INCREASING&&e.next(Ro.X),r=xo.DECREASING),o.y>n.y?(i===xo.DECREASING&&e.next(Ro.Y),i=xo.INCREASING):o.y<n.y&&(i===xo.INCREASING&&e.next(Ro.Y),i=xo.DECREASING),n=o):n=o}))}))}({allWindowObservables:r});return Uo({mouseDirectionChangeObservable:c,directionChanges:o,thresholdMs:s}).subscribe((function(e){Zi(n)&&t.track("[Amplitude] Thrashed Cursor",void 0,{time:e})}))};function jo(e,t,n,r){if(!r)return[];var i=e[t];return"object"==typeof i&&null!==i&&"cssSelectorAllowlist"in i&&Array.isArray(i.cssSelectorAllowlist)?i.cssSelectorAllowlist:n}var qo,Fo,Bo=4e3,$o=function(e){var t;void 0===e&&(e={});var n="@amplitude/plugin-frustration-browser",r=[],i=!1!==e.errorClicks;e.errorClicks||(i=!1);var o=!1!==e.deadClicks&&null!==e.deadClicks,a=!1!==e.rageClicks&&null!==e.rageClicks,s=!1!==e.thrashedCursor&&null!==e.thrashedCursor;e.thrashedCursor||(s=!1);var c=jo(e,"rageClicks",_n,a),u=jo(e,"deadClicks",En,o),l=jo(e,"errorClicks",Sn,i),d=null!==(t=e.dataAttributePrefix)&&void 0!==t?t:Tn,f=new _o(e),p=me([],ve(new Set(me(me(me([],ve(c),!1),ve(u),!1),ve(l),!1))),!1),g=function(){var e,t,n=ur(co("pointerdown").map((function(e){return f.addAdditionalEventProperties(e,"click",p,d,!0)}))),r=ur(uo().map((function(e){return f.addTypeAndTimestamp(e,"error")}))),i=ur(so().map((function(e){return f.addAdditionalEventProperties(e,"mutation",p,d)})));window.navigation&&(t=ur(new ar((function(e){var t=function(t){e.next(de(de({},t),{type:"navigate"}))};return window.navigation.addEventListener("navigate",t),function(){window.navigation.removeEventListener("navigate",t)}})).map((function(e){return f.addAdditionalEventProperties(e,"navigate",p,d)}))));var o=ur(new ar((function(e){var t=function(){var t=document.activeElement;if(t&&("TEXTAREA"===t.tagName||"INPUT"===t.tagName)){try{if(t.selectionStart===t.selectionEnd)return}catch(e){return}return e.next()}var n=window.getSelection();if(n&&!n.isCollapsed)return e.next()};return window.document.addEventListener("selectionchange",t),function(){window.document.removeEventListener("selectionchange",t)}}))),a=ur(new ar((function(e){var t=function(t){e.next(t)},n={capture:!0};return ao.document.addEventListener("mousemove",t,n),function(){ao.document.removeEventListener("mousemove",t,n)}})));return(e={})[ko.ClickObservable]=n,e[ko.MutationObservable]=i,e[ko.NavigateObservable]=t,e[ko.BrowserErrorObservable]=r,e[ko.SelectionObservable]=o,e[ko.MouseMoveObservable]=a,e};return{name:n,type:"enrichment",setup:function(t,p){return pe(void 0,void 0,void 0,(function(){var h,v,m,y,b,T,w,k,E,S,_;return ge(this,(function(I){return"undefined"==typeof document||(h=g(),a&&(v=eo(e,c),m=Co({allObservables:h,amplitude:p,shouldTrackRageClick:v}),r.push(m)),o&&(y=eo(e,u),b=function(e){var t=e.amplitude,n=e.allObservables,r=e.getEventProperties,i=e.shouldTrackDeadClick,o=n.clickObservable,a=n.mutationObservable,s=n.navigateObservable,c=o.filter((function(e){return io(e)&&i("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Bi.LEFT_OR_TOUCH_CONTACT})),u=s?cr(a,s):a,l=cr(c,u),d=null;return sr(l,(function(e){return d&&Po.includes(e.type)?(clearTimeout(d),d=null,Promise.resolve(null)):"click"===e.type?d?Promise.resolve(null):new Promise((function(t){d=setTimeout((function(){t(e),d=null}),3e3)})):Promise.resolve(null)})).subscribe((function(e){if(e){var n={"[Amplitude] X":e.event.clientX,"[Amplitude] Y":e.event.clientY};t.track("[Amplitude] Dead Click",de(de({},r("click",e.closestTrackedAncestor)),n),{time:e.timestamp})}}))}({amplitude:p,allObservables:h,getEventProperties:function(e,t){return f.getEventProperties(e,t,d)},shouldTrackDeadClick:y}),r.push(b)),i&&(T=eo(e,l),w=function(e){var t=e.amplitude,n=e.allObservables,r=e.shouldTrackErrorClick,i=n.clickObservable,o=n.browserErrorObservable,a=i.filter((function(e){return io(e)&&r("click",e.closestTrackedAncestor)&&e.event.target instanceof Element&&null===e.event.target.closest('a[target="_blank"]')&&e.event.button===Bi.LEFT_OR_TOUCH_CONTACT})),s=null,c=null,u=function(){null!==s&&(clearTimeout(s),s=null),c=null};return cr(a,o).subscribe((function(e){var n;if("click"===e.type)return u(),c=e,void(s=setTimeout(u,2e3));"error"===e.type&&c&&(t.track("[Amplitude] Error Click",de(((n={})["[Amplitude] Kind"]=e.event.kind,n["[Amplitude] Message"]=e.event.message,n["[Amplitude] Stack"]=e.event.stack,n["[Amplitude] Filename"]=e.event.filename,n["[Amplitude] Line Number"]=e.event.lineNumber,n["[Amplitude] Column Number"]=e.event.columnNumber,n),c.targetElementProperties)),u())}))}({amplitude:p,allObservables:h,shouldTrackErrorClick:T}),r.push(w)),s&&(k=void 0,E=void 0,"object"==typeof e.thrashedCursor&&(k=e.thrashedCursor.directionChanges,E=e.thrashedCursor.threshold,k&&k<5&&(t.loggerProvider.warn("'thrashedCursor.directionChanges' of ".concat(k," is below the minimum of ").concat(5,", setting to ").concat(5)),k=5),E&&E>Bo&&(t.loggerProvider.warn("'thrashedCursor.threshold' of ".concat(E," is above the maximum of ").concat(Bo,", setting to ").concat(Bo)),E=Bo)),S=Mo({amplitude:p,options:e,allObservables:h,directionChanges:k,thresholdMs:E}),r.push(S)),null===(_=null==t?void 0:t.loggerProvider)||void 0===_||_.log("".concat(n," has been successfully added."))),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){var e,t,n,i;return ge(this,(function(o){try{for(e=he(r),t=e.next();!t.done;t=e.next())t.value.unsubscribe()}catch(e){n={error:e}}finally{try{t&&!t.done&&(i=e.return)&&i.call(e)}finally{if(n)throw n.error}}return[2]}))}))}}},Ho="[Amplitude] Network Request",Ko="500-599";function zo(e,t){var n="^"+t.replace(/[-[\]{}()+?.,\\^$|#\s]/g,"\\$&").replace(/\*/g,".*")+"$";return new RegExp(n).test(e)}function Go(e,t){var n,r,i=t.split(",");try{for(var o=he(i),a=o.next();!a.done;a=o.next()){var s=ve(a.value.split("-").map(Number),2),c=s[0],u=s[1];if(e===c&&void 0===u)return!0;if(e>=c&&e<=u)return!0}}catch(e){n={error:e}}finally{try{a&&!a.done&&(r=o.return)&&r.call(o)}finally{if(n)throw n.error}}return!1}function Vo(e){var t;if(e)try{var n=null===(t=Ve())||void 0===t?void 0:t.location.href,r=new URL(e,n),i=r.searchParams.toString(),o=r.hash.replace("#",""),a=r.href,s=r.host;return r.hash="",r.search="",{query:i,fragment:o,href:a,hrefWithoutQueryOrHash:r.href,host:s}}catch(e){return}}function Wo(e){if("object"==typeof e&&null!==e){if(0!==e.length)return e}else{if(e)return me([],ve(je),!1);if(void 0===e){return}}}function Jo(e){var t,n;return!(null===(t=null==e?void 0:e.allowlist)||void 0===t?void 0:t.length)&&!(null===(n=null==e?void 0:e.blocklist)||void 0===n?void 0:n.length)}function Yo(e,t){var n;void 0===t&&(t={});var r=Vo(e.url);if(!r)return!1;var i,o=r.host;if(!1!==t.ignoreAmplitudeRequests&&(zo(o,"*.amplitude.com")||zo(o,"amplitude.com")))return!1;if(null===(n=t.ignoreHosts)||void 0===n?void 0:n.find((function(e){return zo(o,e)})))return!1;if(!t.captureRules&&void 0!==e.status&&!Go(e.status,Ko))return!1;if(t.captureRules&&(me([],ve(t.captureRules),!1).reverse().find((function(t){if(i=function(e,t,n,r,i){if((!e.hosts||e.hosts.find((function(e){return zo(t,e)})))&&(!r||!e.urls||Nt(r,e.urls))&&(!i||!e.methods||e.methods.find((function(e){return i.toLowerCase()===e.toLowerCase()||"*"===e}))))return!((n||0===n)&&!Go(n,e.statusCodeRange||Ko))}(t,o,e.status,e.url,e.method),i){var n=Wo(t.responseHeaders);if(e.responseWrapper&&n){var r=e.responseWrapper.headers(n);r&&(e.responseHeaders=r)}var a=Wo(t.requestHeaders);if(e.requestWrapper&&a){var s=e.requestWrapper.headers(a);s&&(e.requestHeaders=s)}e.responseWrapper&&t.responseBody&&!Jo(t.responseBody)&&(e.responseBodyJson=e.responseWrapper.json(t.responseBody.allowlist,t.responseBody.blocklist)),e.requestWrapper&&t.requestBody&&!Jo(t.requestBody)&&(e.requestBodyJson=e.requestWrapper.json(t.requestBody.allowlist,t.requestBody.blocklist))}return void 0!==i})),!i))return!1;return!e.requestWrapper||!function(e,t){if(e.includes("amplitude.com"))try{var n=t.body;if("string"!=typeof n)return!1;if(JSON.parse(n).events.find((function(e){return e.event_type===Ho})))return!0}catch(e){}return!1}(o,e.requestWrapper)}function Xo(e){var t=e.allObservables,n=e.networkTrackingOptions,r=e.amplitude,i=e.loggerProvider;return t.networkObservable.filter((function(e){return Yo(e.event,n)})).subscribe((function(e){var t,n,o,a=e.event,s=Vo(a.url);if(s){var c=null===(n=a.responseWrapper)||void 0===n?void 0:n.bodySize,u=null===(o=a.requestWrapper)||void 0===o?void 0:o.bodySize;!function(e,t,n,r){pe(this,void 0,void 0,(function(){var i,o,a;return ge(this,(function(s){switch(s.label){case 0:return t.requestBodyJson||t.responseBodyJson?[4,Promise.all([t.requestBodyJson,t.responseBodyJson])]:[3,2];case 1:if(i=ve.apply(void 0,[s.sent(),2]),o=i[0],a=i[1],o)try{e["[Amplitude] Request Body"]=JSON.stringify(o)}catch(e){null==r||r.debug("Failed to stringify request body",e)}if(a)try{e["[Amplitude] Response Body"]=JSON.stringify(a)}catch(e){null==r||r.debug("Failed to stringify response body")}s.label=2;case 2:return null==n||n.track(Ho,e),[2]}}))}))}(((t={})["[Amplitude] URL"]=s.hrefWithoutQueryOrHash,t["[Amplitude] URL Query"]=s.query,t["[Amplitude] URL Fragment"]=s.fragment,t["[Amplitude] Request Method"]=a.method,t["[Amplitude] Status Code"]=a.status,t["[Amplitude] Start Time"]=a.startTime,t["[Amplitude] Completion Time"]=a.endTime,t["[Amplitude] Duration"]=a.duration,t["[Amplitude] Request Body Size"]=u,t["[Amplitude] Response Body Size"]=c,t["[Amplitude] Request Type"]=a.type,t["[Amplitude] Request Headers"]=a.requestHeaders,t["[Amplitude] Response Headers"]=a.responseHeaders,t),a,r,i)}}))}!function(e){e.NetworkObservable="networkObservable"}(qo||(qo={}));var Qo=function(e){void 0===e&&(e={});var t,n="@amplitude/plugin-network-capture-browser",r=function(){var e,n=new ar((function(e){var n=new $n((function(t){var n=function(e,t){return{event:e,timestamp:Date.now(),type:t}}(t,"network");e.next(n)}));return zn.subscribe(n,t),function(){zn.unsubscribe(n)}}));return(e={})[qo.NetworkObservable]=n,e};return{name:n,type:"enrichment",setup:function(i,o){return pe(void 0,void 0,void 0,(function(){var a;return ge(this,(function(s){return"undefined"==typeof document||(a=r(),t=null==i?void 0:i.loggerProvider,Fo=Xo({allObservables:a,networkTrackingOptions:e,amplitude:o,loggerProvider:t}),null==t||t.log("".concat(n," has been successfully added."))),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(e){return Fo.unsubscribe(),[2]}))}))}}};let Zo=-1;const ea=e=>{addEventListener("pageshow",(t=>{t.persisted&&(Zo=t.timeStamp,e(t))}),!0)},ta=(e,t,n,r)=>{let i,o;return a=>{t.value>=0&&(a||r)&&(o=t.value-(i??0),(o||void 0===i)&&(i=t.value,t.delta=o,t.rating=((e,t)=>e>t[1]?"poor":e>t[0]?"needs-improvement":"good")(t.value,n),e(t)))}},na=e=>{requestAnimationFrame((()=>requestAnimationFrame((()=>e()))))},ra=()=>{const e=performance.getEntriesByType("navigation")[0];if(e&&e.responseStart>0&&e.responseStart<performance.now())return e},ia=()=>{const e=ra();return e?.activationStart??0},oa=(e,t=-1)=>{const n=ra();let r="navigate";return Zo>=0?r="back-forward-cache":n&&(document.prerendering||ia()>0?r="prerender":document.wasDiscarded?r="restore":n.type&&(r=n.type.replace(/_/g,"-"))),{name:e,value:t,rating:"good",delta:0,entries:[],id:`v5-${Date.now()}-${Math.floor(8999999999999*Math.random())+1e12}`,navigationType:r}},aa=new WeakMap;function sa(e,t){return aa.get(e)||aa.set(e,new t),aa.get(e)}class ca{t;i=0;o=[];h(e){if(e.hadRecentInput)return;const t=this.o[0],n=this.o.at(-1);this.i&&t&&n&&e.startTime-n.startTime<1e3&&e.startTime-t.startTime<5e3?(this.i+=e.value,this.o.push(e)):(this.i=e.value,this.o=[e]),this.t?.(e)}}const ua=(e,t,n={})=>{try{if(PerformanceObserver.supportedEntryTypes.includes(e)){const r=new PerformanceObserver((e=>{Promise.resolve().then((()=>{t(e.getEntries())}))}));return r.observe({type:e,buffered:!0,...n}),r}}catch{}},la=e=>{let t=!1;return()=>{t||(e(),t=!0)}};let da=-1;const fa=new Set,pa=()=>"hidden"!==document.visibilityState||document.prerendering?1/0:0,ga=e=>{if("hidden"===document.visibilityState){if("visibilitychange"===e.type)for(const e of fa)e();isFinite(da)||(da="visibilitychange"===e.type?e.timeStamp:0,removeEventListener("prerenderingchange",ga,!0))}},ha=()=>{if(da<0){const e=ia(),t=document.prerendering?void 0:globalThis.performance.getEntriesByType("visibility-state").filter((t=>"hidden"===t.name&&t.startTime>e))[0]?.startTime;da=t??pa(),addEventListener("visibilitychange",ga,!0),addEventListener("prerenderingchange",ga,!0),ea((()=>{setTimeout((()=>{da=pa()}))}))}return{get firstHiddenTime(){return da},onHidden(e){fa.add(e)}}},va=e=>{document.prerendering?addEventListener("prerenderingchange",(()=>e()),!0):e()},ma=[1800,3e3],ya=(e,t={})=>{va((()=>{const n=ha();let r,i=oa("FCP");const o=ua("paint",(e=>{for(const t of e)"first-contentful-paint"===t.name&&(o.disconnect(),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-ia(),0),i.entries.push(t),r(!0)))}));o&&(r=ta(e,i,ma,t.reportAllChanges),ea((n=>{i=oa("FCP"),r=ta(e,i,ma,t.reportAllChanges),na((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))})))}))},ba=[.1,.25];let Ta=0,wa=1/0,ka=0;const Ea=e=>{for(const t of e)t.interactionId&&(wa=Math.min(wa,t.interactionId),ka=Math.max(ka,t.interactionId),Ta=ka?(ka-wa)/7+1:0)};let Sa;const _a=()=>Sa?Ta:performance.interactionCount??0;let Ia=0;class Pa{u=[];l=new Map;m;p;v(){Ia=_a(),this.u.length=0,this.l.clear()}L(){const e=Math.min(this.u.length-1,Math.floor((_a()-Ia)/50));return this.u[e]}h(e){if(this.m?.(e),!e.interactionId&&"first-input"!==e.entryType)return;const t=this.u.at(-1);let n=this.l.get(e.interactionId);if(n||this.u.length<10||e.duration>t.P){if(n?e.duration>n.P?(n.entries=[e],n.P=e.duration):e.duration===n.P&&e.startTime===n.entries[0].startTime&&n.entries.push(e):(n={id:e.interactionId,entries:[e],P:e.duration},this.l.set(n.id,n),this.u.push(n)),this.u.sort(((e,t)=>t.P-e.P)),this.u.length>10){const e=this.u.splice(10);for(const t of e)this.l.delete(t.id)}this.p?.(n)}}}const Aa=e=>{const t=globalThis.requestIdleCallback||setTimeout;"hidden"===document.visibilityState?e():(e=la(e),addEventListener("visibilitychange",e,{once:!0,capture:!0}),t((()=>{e(),removeEventListener("visibilitychange",e,{capture:!0})})))},Oa=[200,500],Ca=(e,t={})=>{if(!globalThis.PerformanceEventTiming||!("interactionId"in PerformanceEventTiming.prototype))return;const n=ha();va((()=>{"interactionCount"in performance||Sa||(Sa=ua("event",Ea,{type:"event",buffered:!0,durationThreshold:0}));let r,i=oa("INP");const o=sa(t,Pa),a=e=>{Aa((()=>{for(const t of e)o.h(t);const t=o.L();t&&t.P!==i.value&&(i.value=t.P,i.entries=t.entries,r())}))},s=ua("event",a,{durationThreshold:t.durationThreshold??40});r=ta(e,i,Oa,t.reportAllChanges),s&&(s.observe({type:"first-input",buffered:!0}),n.onHidden((()=>{a(s.takeRecords()),r(!0)})),ea((()=>{o.v(),i=oa("INP"),r=ta(e,i,Oa,t.reportAllChanges)})))}))};class xa{m;h(e){this.m?.(e)}}const Ra=[2500,4e3],Da=[800,1800],La=e=>{document.prerendering?va((()=>La(e))):"complete"!==document.readyState?addEventListener("load",(()=>La(e)),!0):setTimeout(e)};function Na(e){var t,n=(null===(t=e.entries[0])||void 0===t?void 0:t.startTime)||0;return performance.timeOrigin+n}function Ua(e){return{value:e.value,rating:e.rating,delta:e.delta,navigationType:e.navigationType,id:e.id,timestamp:Math.floor(Na(e)),navigationStart:Math.floor(performance.timeOrigin)}}var Ma,ja=function(){var e=null,t=Ve(),n=null==t?void 0:t.document,r=null==t?void 0:t.location;return{name:"web-vitals-browser",type:"enrichment",setup:function(t,i){return pe(void 0,void 0,void 0,(function(){var o,a;return ge(this,(function(s){return void 0===n||(o=Ut((null==r?void 0:r.href)||"",t.loggerProvider),a={"[Amplitude] Page Domain":(null==r?void 0:r.hostname)||"","[Amplitude] Page Location":o,"[Amplitude] Page Path":Ut((null==r?void 0:r.pathname)||"",t.loggerProvider),"[Amplitude] Page Title":"undefined"!=typeof document&&document.title||"","[Amplitude] Page URL":Ut(o.split("?")[0],t.loggerProvider)},((e,t={})=>{va((()=>{const n=ha();let r,i=oa("LCP");const o=sa(t,xa),a=e=>{t.reportAllChanges||(e=e.slice(-1));for(const t of e)o.h(t),t.startTime<n.firstHiddenTime&&(i.value=Math.max(t.startTime-ia(),0),i.entries=[t],r())},s=ua("largest-contentful-paint",a);if(s){r=ta(e,i,Ra,t.reportAllChanges);const n=la((()=>{a(s.takeRecords()),s.disconnect(),r(!0)})),o=e=>{e.isTrusted&&(Aa(n),removeEventListener(e.type,o,{capture:!0}))};for(const e of["keydown","click","visibilitychange"])addEventListener(e,o,{capture:!0});ea((n=>{i=oa("LCP"),r=ta(e,i,Ra,t.reportAllChanges),na((()=>{i.value=performance.now()-n.timeStamp,r(!0)}))}))}}))})((function(e){a["[Amplitude] LCP"]=Ua(e)})),ya((function(e){a["[Amplitude] FCP"]=Ua(e)})),Ca((function(e){a["[Amplitude] INP"]=Ua(e)})),((e,t={})=>{const n=ha();ya(la((()=>{let r,i=oa("CLS",0);const o=sa(t,ca),a=e=>{for(const t of e)o.h(t);o.i>i.value&&(i.value=o.i,i.entries=o.o,r())},s=ua("layout-shift",a);s&&(r=ta(e,i,ba,t.reportAllChanges),n.onHidden((()=>{a(s.takeRecords()),r(!0)})),ea((()=>{o.i=0,i=oa("CLS",0),r=ta(e,i,ba,t.reportAllChanges),na((()=>r()))})),setTimeout(r))})))})((function(e){a["[Amplitude] CLS"]=Ua(e)})),((e,t={})=>{let n=oa("TTFB"),r=ta(e,n,Da,t.reportAllChanges);La((()=>{const i=ra();i&&(n.value=Math.max(i.responseStart-ia(),0),n.entries=[i],r(!0),ea((()=>{n=oa("TTFB",0),r=ta(e,n,Da,t.reportAllChanges),r(!0)})))}))})((function(e){a["[Amplitude] TTFB"]=Ua(e)})),e=function(){"hidden"===n.visibilityState&&e&&(i.track("[Amplitude] Web Vitals",a),n.removeEventListener("visibilitychange",e),e=null)},n.addEventListener("visibilitychange",e)),[2]}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return[2,e]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(t){return e&&(null==n||n.removeEventListener("visibilitychange",e)),[2]}))}))}}},qa=function(){function e(e,t){var n,r,i;this.shouldTrackNewCampaign=!1,this.options=de({initialEmptyValue:"EMPTY",resetSessionOnNewCampaign:!1,excludeReferrers:(r=(null===(n=t.cookieOptions)||void 0===n?void 0:n.domain)||t.topLevelDomain,i=r,i?(i.startsWith(".")&&(i=i.substring(1)),[new RegExp("".concat(i.replace(".","\\."),"$"))]):[]),optOut:t.optOut},e),this.storage=t.cookieStorage,this.storageKey=$t(t.apiKey,"MKTG"),this.webExpStorageKey=$t(t.apiKey,"MKTG_ORIGINAL"),this.currentCampaign=Me,this.sessionTimeout=t.sessionTimeout,this.lastEventTime=t.lastEventTime,this.logger=t.loggerProvider,this.topLevelDomain=t.topLevelDomain,t.loggerProvider.log("Installing web attribution tracking.")}return e.prototype.init=function(){return pe(this,void 0,void 0,(function(){var e,t;return ge(this,(function(n){switch(n.label){case 0:return this.options.optOut?[2]:[4,this.fetchCampaign()];case 1:return t=ve.apply(void 0,[n.sent(),2]),this.currentCampaign=t[0],this.previousCampaign=t[1],e=!this.lastEventTime||Ct(this.sessionTimeout,this.lastEventTime),gi(this.currentCampaign,this.previousCampaign,this.options,this.logger,e,this.topLevelDomain)?(this.shouldTrackNewCampaign=!0,[4,this.storage.set(this.storageKey,this.currentCampaign)]):[3,3];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.fetchCampaign=function(){return pe(this,void 0,void 0,(function(){var e;return ge(this,(function(t){switch(t.label){case 0:return[4,this.storage.get(this.webExpStorageKey)];case 1:return(e=t.sent())?[4,this.storage.remove(this.webExpStorageKey)]:[3,3];case 2:t.sent(),t.label=3;case 3:return[4,Promise.all([e||(new Gn).parse(),this.storage.get(this.storageKey)])];case 4:return[2,t.sent()]}}))}))},e.prototype.generateCampaignEvent=function(e){this.shouldTrackNewCampaign=!1;var t,n,r,i,o=(t=this.currentCampaign,n=this.options,r=de(de({},Me),t),i=Object.entries(r).reduce((function(e,t){var r,i=ve(t,2),o=i[0],a=i[1];return e.setOnce("initial_".concat(o),null!==(r=null!=a?a:n.initialEmptyValue)&&void 0!==r?r:"EMPTY"),a?e.set(o,a):e.unset(o)}),new $e),Xe(i));return e&&(o.event_id=e),o},e.prototype.shouldSetSessionIdOnNewCampaign=function(){return this.shouldTrackNewCampaign&&!!this.options.resetSessionOnNewCampaign},e}(),Fa="AMP_CURRENT_PAGE",Ba="AMP_PREVIOUS_PAGE",$a="AMP_URL_INFO";!function(e){e.Direct="direct",e.Internal="internal",e.External="external"}(Ma||(Ma={}));var Ha=new Set([le.IDENTIFY,le.GROUP_IDENTIFY,le.REVENUE]),Ka=function(e){var t={}.internalDomains,n=void 0===t?[]:t,r=Ve(),i=void 0,o=!1,a=void 0,s=!1,c=!1,u=function(e){var t="undefined"!=typeof location&&location.hostname||"",r=e?function(e){var t;try{var n=Ut(e,a);t=new URL(n).hostname}catch(e){null==a||a.error("Could not parse URL: ",e)}return t}(e):void 0;if(!r)return Ma.Direct;var i=n.some((function(e){return-1!==t.indexOf(e)})),o=n.some((function(e){return-1!==r.indexOf(e)}));return t===r||o&&i?Ma.Internal:Ma.External},l=function(){pe(void 0,void 0,void 0,(function(){var e,t,n,r,a;return ge(this,(function(s){switch(s.label){case 0:return i&&o?[4,i.get($a)]:[3,3];case 1:return e=s.sent(),t=Ut("undefined"!=typeof location&&location.href||""),n=(null==e?void 0:e[Fa])||"",r=void 0,r=t===n?(null==e?void 0:e[Ba])||"":n||document.referrer||"",[4,i.set($a,(a={},a[Fa]=t,a[Ba]=r,a))];case 2:s.sent(),s.label=3;case 3:return[2]}}))}))},d={name:"@amplitude/plugin-page-url-enrichment-browser",type:"enrichment",setup:function(e,t){return pe(void 0,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:if((a=e.loggerProvider).log("Installing @amplitude/plugin-page-url-enrichment-browser"),c=!0,!r)return[3,2];try{i=new Ht(r.sessionStorage)}catch(e){null==a||a.debug("sessionStorage is not available in this environment.")}return[4,null==i?void 0:i.isEnabled()];case 1:o=null!==(t=n.sent())&&void 0!==t&&t,r.addEventListener("popstate",l),s||(r.history.pushState=new Proxy(r.history.pushState,{apply:function(e,t,n){var r=ve(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),c&&l()}}),r.history.replaceState=new Proxy(r.history.replaceState,{apply:function(e,t,n){var r=ve(n,3),i=r[0],o=r[1],a=r[2];e.apply(t,[i,o,a]),c&&l()}}),s=!0),n.label=2;case 2:return[2]}}))}))},execute:function(e){return pe(void 0,void 0,void 0,(function(){var t,n,r,a,s;return ge(this,(function(c){switch(c.label){case 0:return t=Ut("undefined"!=typeof location&&location.href||""),i&&o?[4,i.get($a)]:[3,5];case 1:return(null==(n=c.sent())?void 0:n[Fa])?[3,3]:[4,i.set($a,(s={},s[Fa]=t,s[Ba]=document.referrer||"",s))];case 2:c.sent(),c.label=3;case 3:return[4,i.get($a)];case 4:if(r=c.sent(),a="",r&&(a=r[Ba]||""),Ha.has(e.event_type))return[2,e];e.event_properties=de(de({},e.event_properties||{}),{"[Amplitude] Page Domain":za(e,"[Amplitude] Page Domain","undefined"!=typeof location&&location.hostname||""),"[Amplitude] Page Location":za(e,"[Amplitude] Page Location",t),"[Amplitude] Page Path":za(e,"[Amplitude] Page Path","undefined"!=typeof location&&Ut(location.pathname)||""),"[Amplitude] Page Title":za(e,"[Amplitude] Page Title",Zn(Qn)),"[Amplitude] Page URL":za(e,"[Amplitude] Page URL",t.split("?")[0]),"[Amplitude] Previous Page Location":a,"[Amplitude] Previous Page Type":u(a)}),c.label=5;case 5:return[2,e]}}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(e){switch(e.label){case 0:return r&&(r.removeEventListener("popstate",l),c=!1),i&&o?[4,i.set($a,{})]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2]}}))}))}};return d};function za(e,t,n){return e.event_properties||(e.event_properties={}),void 0===e.event_properties[t]?n:e.event_properties[t]}var Ga=function(){var e,t,n;function r(t){if(t)try{var n=new Function("return "+t)();if("function"==typeof n)return n;null==e||e.error("Custom enrichment body did not evaluate to a function")}catch(t){null==e||e.error("Could not create custom enrichment function",t)}return function(e){return e}}var i={name:"@amplitude/plugin-custom-enrichment-browser",type:"enrichment",setup:function(i,o){return pe(void 0,void 0,void 0,(function(){var o,a;return ge(this,(function(s){return null==(e=i.loggerProvider)||e.log("Installing @amplitude/plugin-custom-enrichment-browser"),(null===(a=i.remoteConfig)||void 0===a?void 0:a.fetchRemoteConfig)&&(i.remoteConfigClient?(o=i.remoteConfigClient.subscribe("configs.analyticsSDK.browserSDK.customEnrichment","all",(function(e){n=e&&function(e){return"object"==typeof e&&null!==e&&"body"in e&&"string"==typeof e.body}(e)?r(e.body||""):r("")})),t=function(){var e;return null===(e=i.remoteConfigClient)||void 0===e?void 0:e.unsubscribe(o)}):null==e||e.debug("Remote config client is not provided, skipping remote config fetch")),[2]}))}))},execute:function(t){return pe(void 0,void 0,void 0,(function(){var r;return ge(this,(function(i){if(n)try{return[2,null!==(r=n(t))&&void 0!==r?r:null]}catch(n){return null==e||e.error("Could not execute custom enrichment function",n),[2,t]}return[2,t]}))}))},teardown:function(){return pe(void 0,void 0,void 0,(function(){return ge(this,(function(e){return t&&t(),[2]}))}))}};return i},Va=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._diagnosticsSampleRate=0,t._enableRequestBodyCompressionExperimentalValue=!1,t}return ce(t,e),t.prototype.init=function(e,t,n){var r,i;return void 0===e&&(e=""),arguments.length>2?(r=t,i=n):"string"==typeof t?(r=t,i=void 0):(r=null==t?void 0:t.userId,i=t),Qe(this._init(de(de({},i),{userId:r,apiKey:e})))},t.prototype._init=function(t){var n,r,i,o,a,s,c,u;return pe(this,void 0,void 0,(function(){var l,d,f,p,g,h,v,m,y,b,T,w,k,E,S,_=this;return ge(this,(function(I){switch(I.label){case 0:return this.initializing?[2]:(this.initializing=!0,l=function(e){var t,n;return void 0===e&&(e={}),!0===(null===(t=e.remoteConfig)||void 0===t?void 0:t.fetchRemoteConfig)||!1!==(null===(n=e.remoteConfig)||void 0===n?void 0:n.fetchRemoteConfig)&&!1!==e.fetchRemoteConfig}(t),d=null!==(n=t.loggerProvider)&&void 0!==n?n:new rt,t.loggerProvider||d.enable(null!==(r=t.logLevel)&&void 0!==r?r:tt.Warn),f=null!==(i=t.serverZone)&&void 0!==i?i:"US",g=this._diagnosticsSampleRate,h=null===(o=t.enableDiagnostics)||void 0===o||o,l?(p=new dn(t.apiKey,d,f,null===(a=t.remoteConfig)||void 0===a?void 0:a.serverUrl),[4,new Promise((function(e){null==p||p.subscribe("configs.diagnostics.browserSDK","all",(function(t,n,r){if(d.debug("Diagnostics remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t){var i=t.sampleRate;"number"!=typeof i||isNaN(i)||(g=i);var o=t.enabled;"boolean"==typeof o&&(h=o)}e()}))}))]):[3,2]);case 1:I.sent(),I.label=2;case 2:return(v=new nn(t.apiKey,d,f,{enabled:h,sampleRate:g})).setTag("library","".concat(Fr,"/").concat(qr)),"undefined"!=typeof navigator&&v.setTag("user_agent",navigator.userAgent),[4,ki(t.apiKey,t,this,v,{loggerProvider:d,serverZone:f,enableDiagnostics:h,diagnosticsSampleRate:g})];case 3:return m=I.sent(),l&&p?[4,new Promise((function(e){null==p||p.subscribe("configs.analyticsSDK.browserSDK","all",(function(t,n,r){m.loggerProvider.debug("Remote configuration received:",JSON.stringify({remoteConfig:t,source:n,lastFetch:r},null,2)),t&&Fi(t,m),e()}))}))]:[3,5];case 4:I.sent(),I.label=5;case 5:return[4,e.prototype._init.call(this,m)];case 6:return I.sent(),this.logBrowserOptions(m),this.config.remoteConfigClient=p,_r(this.config.defaultTracking)?(this.config.optOut&&this.timeline.addOptOutListener((function(e){return pe(_,void 0,void 0,(function(){var t;return ge(this,(function(n){switch(n.label){case 0:return e?[3,2]:(t=Ur(this.config),this.webAttribution=new qa(t,this.config),[4,this.webAttribution.init()]);case 1:n.sent(),n.label=2;case 2:return[2]}}))}))})),y=Ur(this.config),this.webAttribution=new qa(y,this.config),[4,this.webAttribution.init()]):[3,8];case 7:I.sent(),I.label=8;case 8:return b=Dt(),T=b.ampTimestamp?Number(b.ampTimestamp):void 0,w=!T||Date.now()<T,k=w&&!Number.isNaN(Number(b.ampSessionId))?Number(b.ampSessionId):void 0,-1!==(E=this.config.deferredSessionId)||this.config.optOut||(E=Date.now()),this.setSessionId(null!==(u=null!==(c=null!==(s=t.sessionId)&&void 0!==s?s:k)&&void 0!==c?c:E)&&void 0!==u?u:this.config.sessionId),this.config.optOut&&this.timeline.addOptOutListener((function(e){return pe(_,void 0,void 0,(function(){return ge(this,(function(t){return!e&&this.config.deferredSessionId&&(-1===this.config.deferredSessionId?this.setSessionId(void 0):this.setSessionId(this.config.deferredSessionId)),[2]}))}))})),(S=At(t.instanceName)).identityStore.setIdentity({userId:this.config.userId,deviceId:this.config.deviceId}),null===this.config.offline?[3,10]:[4,this.add(Mi()).promise];case 9:I.sent(),I.label=10;case 10:return[4,this.add(new mt({diagnosticsClient:v})).promise];case 11:return I.sent(),[4,this.add(new Br).promise];case 12:return I.sent(),[4,this.add(new Ot).promise];case 13:return I.sent(),O=this.config,Ui||void 0!==O.defaultTracking||(O.loggerProvider.warn("`options.defaultTracking` is set to undefined. This implicitly configures your Amplitude instance to track Page Views, Sessions, File Downloads, and Form Interactions. You can suppress this warning by explicitly setting a value to `options.defaultTracking`. The value must either be a boolean, to enable and disable all default events, or an object, for advanced configuration. For example:\n\namplitude.init(<YOUR_API_KEY>, {\n defaultTracking: true,\n});\n\nVisit https://www.docs.developers.amplitude.com/data/sdks/browser-2/#tracking-default-events for more details."),Ui=!0),A=this.config.defaultTracking,Sr(A,"fileDownloads")?(this.config.loggerProvider.debug("Adding file download tracking plugin"),[4,this.add(Ni()).promise]):[3,15];case 14:I.sent(),I.label=15;case 15:return Ir(this.config.defaultTracking)?(this.config.loggerProvider.debug("Adding form interaction plugin"),[4,this.add(Ri()).promise]):[3,17];case 16:I.sent(),I.label=17;case 17:return Pr(this.config.defaultTracking)?this.config.optOut?[3,19]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Ai(Nr(this.config))).promise]):[3,20];case 18:return I.sent(),[3,20];case 19:this.timeline.addOptOutListener((function(e){return pe(_,void 0,void 0,(function(){return ge(this,(function(t){switch(t.label){case 0:return e?[2]:(this.config.loggerProvider.debug("Adding page view tracking plugin"),[4,this.add(Ai(Nr(this.config))).promise]);case 1:return t.sent(),[2]}}))}))})),I.label=20;case 20:return Cr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding user interactions plugin (autocapture plugin)"),[4,this.add(Io(Rr(this.config),{diagnosticsClient:v})).promise]):[3,22];case 21:I.sent(),I.label=22;case 22:return xr(this.config.autocapture)?(this.config.loggerProvider.debug("Adding frustration interactions plugin"),[4,this.add($o(Dr(this.config))).promise]):[3,24];case 23:I.sent(),I.label=24;case 24:return Or(this.config.autocapture)?(this.config.loggerProvider.debug("Adding network tracking plugin"),[4,this.add(Qo(Lr(this.config))).promise]):[3,26];case 25:I.sent(),I.label=26;case 26:return function(e){return"boolean"==typeof e?e:"object"==typeof e&&!0===e.webVitals}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding web vitals plugin"),[4,this.add(ja()).promise]):[3,28];case 27:I.sent(),I.label=28;case 28:return function(e){return Sr(e,"pageUrlEnrichment")}(this.config.autocapture)?(this.config.loggerProvider.debug("Adding referrer page url plugin"),[4,this.add(Ka()).promise]):[3,30];case 29:I.sent(),I.label=30;case 30:return("boolean"==typeof(P=this.config.customEnrichment)?P:"object"==typeof P&&null!==P&&!1!==P.enabled)?(this.config.loggerProvider.debug("Adding custom enrichment plugin"),[4,this.add(Ga()).promise]):[3,32];case 31:I.sent(),I.label=32;case 32:return this.initializing=!1,[4,this.runQueuedFunctions("dispatchQ")];case 33:return I.sent(),S.eventBridge.setEventReceiver((function(e){var t=e.eventProperties||{},n=t.time,r=fe(t,["time"]),i="number"==typeof n?{time:n}:void 0;_.track(e.eventType,r,i)})),[2]}var P,A,O}))}))},t.prototype.getUserId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.userId},t.prototype.setUserId=function(e){this.config?(this.config.loggerProvider.debug("function setUserId: ",e),e===this.config.userId&&void 0!==e||(this.config.userId=e,this.timeline.onIdentityChanged({userId:e}),function(e,t){At(t).identityStore.editIdentity().setUserId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setUserId.bind(this,e))},t.prototype.getDeviceId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.deviceId},t.prototype.setDeviceId=function(e){this.config?(this.config.loggerProvider.debug("function setDeviceId: ",e),e!==this.config.deviceId&&(this.config.deviceId=e,this.timeline.onIdentityChanged({deviceId:e}),function(e,t){At(t).identityStore.editIdentity().setDeviceId(e).commit()}(e,this.config.instanceName))):this.q.push(this.setDeviceId.bind(this,e))},t.prototype.reset=function(){this.setDeviceId(Je()),this.setUserId(void 0),this.timeline.onReset()},t.prototype.getIdentity=function(){var e,t;return{deviceId:null===(e=this.config)||void 0===e?void 0:e.deviceId,userId:null===(t=this.config)||void 0===t?void 0:t.userId,userProperties:this.userProperties}},t.prototype.setIdentity=function(e){var t,n,r;if("userId"in e&&this.setUserId(e.userId),"deviceId"in e&&e.deviceId&&this.setDeviceId(e.deviceId),"userProperties"in e){this.userProperties=e.userProperties;var i=new $e,o=null!==(r=e.userProperties)&&void 0!==r?r:{};try{for(var a=he(Object.entries(o)),s=a.next();!s.done;s=a.next()){var c=ve(s.value,2),u=c[0],l=c[1];i.set(u,l)}}catch(e){t={error:e}}finally{try{s&&!s.done&&(n=a.return)&&n.call(a)}finally{if(t)throw t.error}}this.identify(i)}},t.prototype.getOptOut=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.optOut},t.prototype.getSessionId=function(){var e;return null===(e=this.config)||void 0===e?void 0:e.sessionId},t.prototype.setSessionId=function(e){var t,n=[];if(!this.config)return this.q.push(this.setSessionId.bind(this,e)),Qe(Promise.resolve());if(this.config.optOut)return this.config.deferredSessionId=null!=e?e:-1,Qe(Promise.resolve());if(void 0===e&&(e=Date.now()),e===this.config.sessionId)return Qe(Promise.resolve());this.config.loggerProvider.debug("function setSessionId: ",e);var r=this.getSessionId();r!==e&&this.timeline.onSessionIdChanged(e);var i=this.config.lastEventTime,o=null!==(t=this.config.lastEventId)&&void 0!==t?t:-1;this.config.sessionId=e,this.config.lastEventTime=void 0,this.config.pageCounter=0,Ar(this.config.defaultTracking)&&(r&&i&&n.push(this.track(ni,void 0,{device_id:this.previousSessionDeviceId,event_id:++o,session_id:r,time:i+1,user_id:this.previousSessionUserId}).promise),this.config.lastEventTime=this.config.sessionId);var a=this.trackCampaignEventIfNeeded(++o,n);return this.config.identify&&n.push(this.track(Xe(this.config.identify)).promise),Ar(this.config.defaultTracking)&&n.push(this.track(ti,void 0,{event_id:a?++o:o,session_id:this.config.sessionId,time:this.config.lastEventTime}).promise),this.previousSessionDeviceId=this.config.deviceId,this.previousSessionUserId=this.config.userId,Qe(Promise.all(n))},t.prototype.extendSession=function(){this.config?this.config.lastEventTime=Date.now():this.q.push(this.extendSession.bind(this))},t.prototype.setTransport=function(e){this.config?this.config.transportProvider=Si(e):this.q.push(this.setTransport.bind(this,e))},t.prototype.identify=function(t,n){if(jr(t)){var r=t._q;t._q=[],t=Mr(new $e,r)}return(null==n?void 0:n.user_id)&&this.setUserId(n.user_id),(null==n?void 0:n.device_id)&&this.setDeviceId(n.device_id),e.prototype.identify.call(this,t,n)},t.prototype.groupIdentify=function(t,n,r,i){if(jr(r)){var o=r._q;r._q=[],r=Mr(new $e,o)}return e.prototype.groupIdentify.call(this,t,n,r,i)},t.prototype.revenue=function(t,n){if(jr(t)){var r=t._q;t._q=[],t=Mr(new et,r)}return e.prototype.revenue.call(this,t,n)},t.prototype.trackCampaignEventIfNeeded=function(e,t){if(!this.webAttribution||!this.webAttribution.shouldTrackNewCampaign)return!1;var n=this.webAttribution.generateCampaignEvent(e);return t?t.push(this.track(n).promise):this.track(n),this.config.loggerProvider.log("Tracking attribution."),!0},t.prototype.process=function(t){return pe(this,void 0,void 0,(function(){var n,r,i;return ge(this,(function(o){return n=Date.now(),r=Ct(this.config.sessionTimeout,this.config.lastEventTime),i=this.webAttribution&&this.webAttribution.shouldSetSessionIdOnNewCampaign(),t.event_type===ti||t.event_type===ni||t.session_id&&t.session_id!==this.getSessionId()||(r||i?(this.setSessionId(n),i&&this.config.loggerProvider.log("Created a new session for new campaign.")):r||this.trackCampaignEventIfNeeded()),[2,e.prototype.process.call(this,t)]}))}))},t.prototype.logBrowserOptions=function(e){try{var t=de(de({},e),{apiKey:e.apiKey.substring(0,10)+"********"});this.config.loggerProvider.debug("Initialized Amplitude with BrowserConfig:",hr(t))}catch(e){this.config.loggerProvider.error("Error logging browser config",e)}},t.prototype._setDiagnosticsSampleRate=function(e){e>1||e<0||this.config||(this._diagnosticsSampleRate=e)},t.prototype._enableRequestBodyCompressionExperimental=function(e){this.config||(this._enableRequestBodyCompressionExperimentalValue=e)},t}(Ze),Wa=function(){var e=new Va;return{init:gt(e.init.bind(e),"init",dt(e),pt(e,["config"])),add:gt(e.add.bind(e),"add",dt(e),pt(e,["config.apiKey","timeline.plugins"])),remove:gt(e.remove.bind(e),"remove",dt(e),pt(e,["config.apiKey","timeline.plugins"])),track:gt(e.track.bind(e),"track",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),logEvent:gt(e.logEvent.bind(e),"logEvent",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),identify:gt(e.identify.bind(e),"identify",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),groupIdentify:gt(e.groupIdentify.bind(e),"groupIdentify",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),setGroup:gt(e.setGroup.bind(e),"setGroup",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),revenue:gt(e.revenue.bind(e),"revenue",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),flush:gt(e.flush.bind(e),"flush",dt(e),pt(e,["config.apiKey","timeline.queue.length"])),getUserId:gt(e.getUserId.bind(e),"getUserId",dt(e),pt(e,["config","config.userId"])),setUserId:gt(e.setUserId.bind(e),"setUserId",dt(e),pt(e,["config","config.userId"])),getDeviceId:gt(e.getDeviceId.bind(e),"getDeviceId",dt(e),pt(e,["config","config.deviceId"])),setDeviceId:gt(e.setDeviceId.bind(e),"setDeviceId",dt(e),pt(e,["config","config.deviceId"])),reset:gt(e.reset.bind(e),"reset",dt(e),pt(e,["config","config.userId","config.deviceId"])),getSessionId:gt(e.getSessionId.bind(e),"getSessionId",dt(e),pt(e,["config"])),setSessionId:gt(e.setSessionId.bind(e),"setSessionId",dt(e),pt(e,["config"])),extendSession:gt(e.extendSession.bind(e),"extendSession",dt(e),pt(e,["config"])),setOptOut:gt(e.setOptOut.bind(e),"setOptOut",dt(e),pt(e,["config"])),setTransport:gt(e.setTransport.bind(e),"setTransport",dt(e),pt(e,["config"])),getIdentity:gt(e.getIdentity.bind(e),"getIdentity",dt(e),pt(e,["config"])),setIdentity:gt(e.setIdentity.bind(e),"setIdentity",dt(e),pt(e,["config","config.userId","config.deviceId"])),getOptOut:gt(e.getOptOut.bind(e),"getOptOut",dt(e),pt(e,["config"])),_setDiagnosticsSampleRate:gt(e._setDiagnosticsSampleRate.bind(e),"_setDiagnosticsSampleRate",dt(e),pt(e,["config"])),_enableRequestBodyCompressionExperimental:gt(e._enableRequestBodyCompressionExperimental.bind(e),"_enableRequestBodyCompressionExperimental",dt(e),pt(e,["config"]))}},Ja=Wa(),Ya=Ja.add,Xa=Ja.extendSession,Qa=Ja.flush,Za=Ja.getDeviceId,es=Ja.getIdentity,ts=Ja.getOptOut,ns=Ja.getSessionId,rs=Ja.getUserId,is=Ja.groupIdentify,os=Ja.identify,as=Ja.init,ss=Ja.logEvent,cs=Ja.remove,us=Ja.reset,ls=Ja.revenue,ds=Ja.setDeviceId,fs=Ja.setGroup,ps=Ja.setIdentity,gs=Ja.setOptOut,hs=Ja.setSessionId,vs=Ja.setTransport,ms=Ja.setUserId,ys=Ja.track,bs=Ja._setDiagnosticsSampleRate,Ts=Ja._enableRequestBodyCompressionExperimental,ws=Object.freeze({__proto__:null,AmplitudeBrowser:Va,Identify:$e,Revenue:et,Types:fi,_enableRequestBodyCompressionExperimental:Ts,_setDiagnosticsSampleRate:bs,add:Ya,createInstance:Wa,extendSession:Xa,flush:Qa,getDeviceId:Za,getIdentity:es,getOptOut:ts,getSessionId:ns,getUserId:rs,groupIdentify:is,identify:os,init:as,logEvent:ss,remove:cs,reset:us,revenue:ls,runQueuedFunctions:function(e,t){Mr(e,t)},setDeviceId:ds,setGroup:fs,setIdentity:ps,setOptOut:gs,setSessionId:hs,setTransport:vs,setUserId:ms,track:ys});class ks{constructor(){this.isInitialized=!1}static getInstance(){return ks.instance||(ks.instance=new ks),ks.instance}initialize(){if(this.isInitialized||s())return;const e=b.getEnvironment()||"production",t=e===c.PRODUCTION?"52c120d2f5c89ca646fae6649a1ce7ad":"373aa80c38e5bc2a55895a96c8447fef";try{if(!ws||"function"!=typeof as)throw new Error("Analytics SDK module not available");const n={defaultTracking:{sessions:!1,pageViews:!1,formInteractions:!1,fileDownloads:!1},logLevel:e!==c.PRODUCTION?tt.Debug:tt.None};as(t,void 0,n),this.isInitialized=!0,this.track(oe)}catch(e){console.error("Failed to initialize analytics tracking:",e)}}isEnabled(){return this.isInitialized}track(e,t){if(this.isInitialized)try{ys(e,t)}catch(e){console.error("Failed to track analytics event:",e)}}reset(){if(this.isInitialized)try{us()}catch(e){console.error("Failed to reset analytics:",e)}}}const Es=ks.getInstance();function Ss(e,t){Es.track(e,t)}const _s=e=>{Ss(ae,e)};async function Is({networkCallDescriptor:e,proxyEndpointDescriptor:t}){const n={...Object.fromEntries([..._(e.options?.headers)??{}])},r=P({...e,options:{...e.options,headers:n}}),i=await fetch(t.path,{method:t.method,headers:t.options.headers,body:r}),o=A(await i.text());if(!i.ok)throw new S({code:i.status,data:o,message:`Error from proxy endpoint: ${i.status} ${i.statusText}`});return o}var Ps;function As(e){return{id:e.id,nickname:e.nickname,embossedName:e.embossed_name,status:e.status,maskPan:e.mask_pan,expMonth:parseInt(e.exp_month,10),expYear:parseInt(e.exp_year,10),lastActivityAt:new Date(e.last_activity_at),lastDigits:e.last_digits,shipToBusiness:e.ship_to_business,atmOption:e.atm_option,atmDailyLimitOption:e.atm_daily_limit_option,nfcOption:e.nfc_option,onlineOption:e.online_option,foreignOption:e.foreign_option,atmMonthlyLimit:e.atm_monthly_limit,atmMonthlySpent:e.atm_monthly_spent,atmDailyLimit:e.atm_daily_limit,atmDailySpent:e.atm_daily_spent,paymentMonthlyLimit:e.payment_monthly_limit,paymentMonthlySpent:e.payment_monthly_spent,paymentDailyLimit:e.payment_daily_limit,paymentDailySpent:e.payment_daily_spent,paymentDailyLimitOption:e.payment_daily_limit_option,paymentTransactionLimit:e.payment_transaction_limit,paymentTransactionLimitOption:e.payment_transaction_limit_option,activeDays:e.active_days,holderId:e.holder_id,bankAccountId:e.bank_account_id,organizationId:e.organization_id,updatedAt:new Date(e.updated_at),createdAt:new Date(e.created_at),shippedAt:new Date(e.shipped_at),cardType:e.card_type,cardLevel:e.card_level,paymentLifespanLimit:e.payment_lifespan_limit,paymentLifespanSpent:e.payment_lifespan_spent,preExpiresAt:new Date(e.pre_expires_at),categories:e.categories,renewed:e.renewed,renewal:e.renewal,...e.parent_card_summary&&{parentCardSummary:{id:e.parent_card_summary.id,lastDigits:e.parent_card_summary.last_digits}},hadOperation:e.had_operation,hadPinOperation:e.had_pin_operation,cardDesign:e.card_design,typeOfPrint:e.type_of_print,upsold:e.upsold,upsell:e.upsell,discardOn:new Date(e.discard_on),reordered:e.reordered}}!function(e){e.PENDING="pending",e.ONHOLD="onhold",e.ORDER_CANCELED="order_canceled",e.LIVE="live",e.PAUSED="paused",e.STOLEN="stolen",e.LOST="lost",e.PIN_BLOCKED="pin_blocked",e.DELETED="deleted",e.PRE_EXPIRED="pre_expired",e.EXPIRED="expired",e.DISCARDED="discarded",e.SHIPPED_LOST="shipped_lost",e.ABUSIVE="abusive"}(Ps||(Ps={}));const Os={getCards:async function(e){_s();const t=e?.cardSettings?.membershipId;if(t&&"string"!=typeof t)throw new R("membershipId must be a string");const{accessToken:n,stagingToken:r}=e?.operationSettings||{},i=n||a(),o=await async function({membershipId:e,accessToken:t,stagingToken:n}){const r=function({membershipId:e,accessToken:t,stagingToken:n}){return{path:e?`/v2/cards?holder_ids[]=${e}`:"/v2/cards",options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({membershipId:e,accessToken:t,stagingToken:n}),{cards:i}=await I(r);return i}({membershipId:t,accessToken:i,stagingToken:r});return o.map((e=>As(e)))},getCard:async function({cardSettings:e,operationSettings:t}){!function(e){if(!e)throw new R("cardSettings parameter is required for the called function");if(!e.cardId)throw new R("cardId parameter is required for the called function");const t=L({cardId:e.cardId});if(t.length>0)throw new R(t)}(e);const n=e.cardId,{accessToken:r,stagingToken:i}=t||{},o=r||a(),s=await async function({cardId:e,accessToken:t,stagingToken:n}){const r=function({cardId:e,accessToken:t,stagingToken:n}){return{path:`/v2/cards?ids[]=${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({cardId:e,accessToken:t,stagingToken:n}),{cards:i}=await I(r);return i[0]}({cardId:n,accessToken:o,stagingToken:i});return As(s)}},Cs=e=>({id:e?.id,slug:e.slug,iban:e.iban,bic:e.bic,currency:e.currency,balance:parseFloat(e.balance),balanceCents:e.balance_cents,authorizedBalance:e.authorized_balance,authorizedBalanceCents:e.authorized_balance_cents,name:e.name,updatedAt:new Date(e.updated_at),status:e.status,main:e.main}),xs={getOrganization:async({operationSettings:e}={})=>{const{accessToken:t,stagingToken:n}=e||{},r=t||a(),i=await(async({accessToken:e,stagingToken:t})=>{const n=(({accessToken:e,stagingToken:t})=>({path:"/v2/organization/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}))({accessToken:e,stagingToken:t});return await I(n)})({accessToken:r,stagingToken:n});return{id:(o=i.organization).id,slug:o.slug,legalName:o.legal_name,legalNumber:o.legal_number,legalSector:o.legal_sector,legalRegistrationDate:o.legal_registration_date,legalAddress:o.legal_address,legalForm:o.legal_form,legalCountry:o.legal_country,legalShareCapital:o.legal_share_capital,locale:o.locale,contractSignedAt:o.contract_signed_at,bankAccounts:o.bank_accounts.map(Cs)};var o},getBankAccounts:async({operationSettings:e}={})=>{const{accessToken:t,stagingToken:n}=e||{},r=t||a(),i=await(async({accessToken:e,stagingToken:t})=>{const n=(({accessToken:e,stagingToken:t})=>({path:"/v2/bank_accounts/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}))({accessToken:e,stagingToken:t});return await I(n)})({accessToken:r,stagingToken:n});return i.bank_accounts.map(Cs)},getMembership:async({operationSettings:e}={})=>{const{accessToken:t,stagingToken:n}=e||{},r=t||a(),i=await(async({accessToken:e,stagingToken:t})=>{const n=(({accessToken:e,stagingToken:t})=>({path:"/v2/membership/",options:{method:"GET",headers:{accessToken:e,stagingToken:t}}}))({accessToken:e,stagingToken:t});return await I(n)})({accessToken:r,stagingToken:n});return{id:(o=i.membership).id,userId:o.user_id,organizationId:o.organization_id,firstName:o.first_name,lastName:o.last_name,email:o.email,role:o.role,status:o.status,createdAt:o.created_at,updatedAt:o.updated_at};var o}},Rs={AED:"AED",AUD:"AUD",BGN:"BGN",CAD:"CAD",CHF:"CHF",CNY:"CNY",CZK:"CZK",DKK:"DKK",EUR:"EUR",GBP:"GBP",GHS:"GHS",HKD:"HKD",HUF:"HUF",ILS:"ILS",INR:"INR",MXN:"MXN",NOK:"NOK",NZD:"NZD",PEN:"PEN",PLN:"PLN",RON:"RON",RSD:"RSD",SAR:"SAR",SEK:"SEK",SGD:"SGD",TRY:"TRY",USD:"USD",ZAR:"ZAR",ZMW:"ZMW"},Ds=e=>{if(!(e=>Object.values(Rs).includes(e))(e))throw new R(`currency ${e} is not valid, valid currencies are ${Object.values(Rs).join(", ")}`)},Ls={GOOD:"good",SERVICE:"service"},Ns={UNIT:"unit",HOUR:"hour",DAY:"day",MONTH:"month",GRAM:"gram",KILOGRAM:"kilogram",LITER:"liter",METER:"meter",SQUARE_METER:"square_meter",CUBIC_METER:"cubic_meter",AMPERE:"ampere",NUMBER_OF_ARTICLES:"number_of_articles",CENTIMETER:"centimeter",CUBIC_METER_PER_HOUR:"cubic_meter_per_hour",GIGAJOULE:"gigajoule",GIGAWATT:"gigawatt",GIGAWATT_HOUR:"gigawatt_hour",HALF_YEAR:"half_year",JOULE:"joule",KILOJOULE:"kilojoule",KILOVAR:"kilovar",KILOWATT:"kilowatt",KILOWATT_HOUR:"kilowatt_hour",MEGAJOULE:"megajoule",MEGAWATT:"megawatt",MEGAWATT_HOUR:"megawatt_hour",MILLIGRAM:"milligram",MILLILITER:"milliliter",MILLIMETER:"millimeter",MINUTE:"minute",PAIR:"pair",QUARTER:"quarter",SECOND:"second",SET:"set",TON:"ton",TWO_WEEK:"two_week",WATT_HOUR:"watt_hour",WEEK:"week",YEAR:"year"},Us=e=>{if(!(e=>Object.values(Ns).includes(e))(e))throw new R(`unit ${e} is not valid, valid units are ${Object.values(Ns).join(", ")}`)},Ms=[{name:"id"},{name:"title"},{name:"type"},{name:"quantity"},{name:"measureUnit"},{name:"unitPrice"},{name:"vatRate"}],js=[{name:"currency"},{name:"value"}];const qs=e=>{if(!Object.values(Ls).includes(e))throw new R(`type ${e} is not valid, valid types are ${Object.values(Ls).join(", ")}`)};const Fs={getPaymentLinkCreationFlowUrl:async({paymentLinkSettings:e,operationSettings:t})=>{const{items:n}=e;!function(e){if(!e||!Array.isArray(e))return[];e.forEach((e=>{D(e,Ms),D(e.unitPrice,js);const t=[...L({id:e.id,title:e.title,vatRate:e.vatRate,currency:e.unitPrice.currency,measureUnit:e.measureUnit,unitPrice:e.unitPrice.value,...e.description?{description:e.description}:{}}),...N({quantity:e.quantity})].flat();if(t.length>0)throw new R(t);qs(e.type),Ds(e.unitPrice.currency),Us(e.measureUnit)}))}(n);const r=function(e){if(!e?.callbackUrl)throw new R("callbackUrl parameter is required for the payment link creation flow");if("string"!=typeof e.callbackUrl)throw new R("callbackUrl must be a string");if(""===e.callbackUrl.trim())throw new R("callbackUrl cannot be empty");return e.callbackUrl}(e),i=await M({requestSettings:{action:p.PAYMENT_LINK_CREATE,callbackUrl:r},operationSettings:t}),o=new URLSearchParams({...n?{items:JSON.stringify(n)}:{}});return o.toString()?`${i.url}?${o.toString()}`:i.url}};function Bs(e){return{id:e.id,initiatorId:e.initiator_id,bankAccountId:e.bank_account_id,amount:Number(e.amount),amountCents:Number(e.amount_cents),amountCurrency:e.amount_currency,status:e.status,beneficiaryId:e.beneficiary_id,reference:e.reference,note:e.note,declinedReason:e.declined_reason,scheduledDate:new Date(e.scheduled_date),createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),processedAt:new Date(e.processed_at),completedAt:new Date(e.completed_at),transactionId:e.transaction_id}}function $s(e){return{name:e.name,iban:e.iban}}const Hs="/v2/sepa",Ks=`${Hs}/transfers`;async function zs({accessToken:e,stagingToken:t,paginationSettings:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=q(e),o=i.size?`?${i.toString()}`:"";return{path:`${Ks}${o}`,options:r}}({paginationSettings:n,accessToken:e,stagingToken:t}),{transfers:i,meta:o}=await I(r);return{transfers:i,meta:o}}async function Gs({accessToken:e,stagingToken:t,sepaTransferId:n}){const r=function({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ks}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({sepaTransferId:n,accessToken:e,stagingToken:t}),{transfer:i}=await I(r);return i}async function Vs({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}){const a=function({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}){const a=function(e){const t=e.beneficiaryId||e.beneficiary?.id;return{bank_account_id:e.bankAccountId,beneficiary_id:t,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentIds?{attachment_ids:e.attachmentIds}:{}}}(e);return{path:Ks,options:{method:"POST",headers:{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o},body:{transfer:a,vop_proof_token:t}}}}({transfer:e,vopProofToken:t,accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}),{transfer:s}=await I(a);return s}async function Ws({sepaTransferId:e,accessToken:t,stagingToken:n}){const r=function({sepaTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Ks}/${e}/cancel`,options:{method:"POST",headers:{accessToken:t,stagingToken:n}}}}({sepaTransferId:e,accessToken:t,stagingToken:n});await I(r)}async function Js({sepaPayee:e,accessToken:t,stagingToken:n}){const r=function({sepaPayee:e,accessToken:t,stagingToken:n}){return{path:`${Hs}/verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{beneficiary_name:e.name,iban:e.iban}}}}({sepaPayee:e,accessToken:t,stagingToken:n});return await I(r)}function Ys(e){return{id:e.id,initiatorId:e.initiator_id,createdAt:new Date(e.created_at),updatedAt:new Date(e.updated_at),totalCount:Number(e.total_count),completedCount:Number(e.completed_count),failedCount:Number(e.failed_count),pendingCount:Number(e.pending_count),results:e.results.map((e=>({clientTransferId:e.client_transfer_id,transferId:e.transfer_id??null,errors:e.errors||null,status:e.status})))}}function Xs(e){return{id:e.id,response:{matchResult:e.response.match_result,matchedName:e.response.matched_name}}}const Qs="/v2/sepa/bulk_transfers";async function Zs({accessToken:e,stagingToken:t,paginationSettings:n}){const r=function({paginationSettings:e,accessToken:t,stagingToken:n}){const r={method:"GET",headers:{accessToken:t,stagingToken:n}},i=q(e),o=i.size?`?${i.toString()}`:"";return{path:`${Qs}${o}`,options:r}}({paginationSettings:n,accessToken:e,stagingToken:t}),{bulk_transfers:i,meta:o}=await I(r);return{bulkTransfers:i,meta:o}}async function ec({accessToken:e,stagingToken:t,bulkTransferId:n}){const r=function({bulkTransferId:e,accessToken:t,stagingToken:n}){return{path:`${Qs}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}({bulkTransferId:n,accessToken:e,stagingToken:t}),{bulk_transfer:i}=await I(r);return i}async function tc({sepaPayees:e,accessToken:t,stagingToken:n}){const r=function({sepaPayees:e,accessToken:t,stagingToken:n}){return{path:`${Hs}/bulk_verify_payee`,options:{method:"POST",headers:{accessToken:t,stagingToken:n},body:{requests:e.map($s)}}}}({sepaPayees:e,accessToken:t,stagingToken:n});return await I(r)}function nc(e){if(!e)throw new R("bulkTransferSettings parameter is required for the called function.");if(!e.bankAccountId)throw new R("bankAccountId is required");if(!Array.isArray(e.bulkTransfers))throw new R("bulkTransfers must be an array");if(e.bulkTransfers.length>400)throw new R("Maximum of 400 bulk transfers allowed");return e.bulkTransfers.forEach(((e,t)=>{!function(e,t){if(!e)throw new R(`Invalid bulkTransfer at index ${t}: bulkTransfer object is required`);if(!e.beneficiary)throw new R(`Invalid bulkTransfer at index ${t}: Beneficiary details must be provided in the bulkTransferSettings.beneficiary field`);if(!e.beneficiary.iban)throw new R(`Invalid bulkTransfer at index ${t}: IBAN is required as part of the beneficiary details`);if(!e.beneficiary.name)throw new R(`Invalid bulkTransfer at index ${t}: Beneficiary name is required as part of the beneficiary details`);const n=L({reference:e.reference,clientTransferId:e.clientTransferId,note:e.note}),r=N({amount:e.amount}),i=[...n,...r].flat();if(i.length>0)throw new R(i);if(e.amount>d&&(!e.attachmentsIds||0===e.attachmentsIds.length))throw new R(`Invalid bulkTransfer at index ${t}: Attachments are required for transfers over €30000`)}(e,t)})),e}const rc={requiresUI:!1};function ic(e,{requiresUI:t}=rc){const n=e?.uiParentElementId||E.getUIParentElementId();if(t){if(!n)throw new R("operationSettings parameter must have a uiParentElementId for the called function.\nYou can pass it either to the initialize function or in a per function basis.");if(!["string","function"].includes(typeof n))throw new R("operationSettings.uiParentElementId must be a string or a function returning an HTMLElement")}const r=e?.mfaPreference||E.getMFAPreference();if(r){const e=(i=Object.values(l),b.isProductionEnvironment()?i.filter((e=>e!==l.MOCK)):i);if(!e.includes(r))throw new R(`operationSettings.mfaPreference must be one of ${e.join(", ")}`);if(b.isProductionEnvironment()&&r===l.MOCK)throw new R("operationSettings.mfaPreference cannot be set to mock in production environment.")}var i;const o=e?.debugMode||E.getDebugMode();if(void 0!==o&&"boolean"!=typeof o)throw new R("operationSettings.debugMode must be a boolean.");const a=e?.proxyEndpointDescriptor||E.getProxyEndpointDescriptor();if(a&&!a.path)throw new R("operationSettings.proxyEndpointDescriptor must have at least a string-formatted path property.");return{...e,uiParentElementId:n,mfaPreference:r,debugMode:o,proxyEndpointDescriptor:a}}async function oc({sepaTransferSettings:e,operationSettings:t}){return e?.beneficiary?e.beneficiary:await async function({beneficiarySettings:e,operationSettings:t}){const n=re(e?.beneficiaryId),{proxyEndpointDescriptor:r,accessToken:i,stagingToken:o}=ic(t||{});if(r){const e=X({beneficiaryId:n});return V((await Is({proxyEndpointDescriptor:r,networkCallDescriptor:e})).body.beneficiary)}{const e=i||a();return V(await Q({beneficiaryId:n,accessToken:e,stagingToken:o}))}}({beneficiarySettings:{beneficiaryId:e?.beneficiaryId},operationSettings:t})}function ac(e,t){const n=t?.locale||w.getLocale(),r=new URL(e);return n&&r.searchParams.append("lang",n),t?.mfaPreference&&r.searchParams.append("mfaPreference",t.mfaPreference),t?.idempotencyKey&&r.searchParams.append("idempotencyKey",t.idempotencyKey),r.toString()}const sc=[{name:"bankAccountId"},{name:"reference"},{name:"amount"}];const cc={getSepaTransfers:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||a(),o=await zs({accessToken:i,stagingToken:n,paginationSettings:r}),s=o.transfers.map(Bs),c=F(o.meta);return{transfers:s,...c?{meta:c}:{}}},getSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("sepaTransferId parameter is required for the called function");if(e&&"string"!=typeof e)throw new R("sepaTransferId must be a string");return e}(e?.sepaTransferId),{accessToken:r,stagingToken:i}=t||{},o=r||a();return Bs(await Gs({sepaTransferId:n,accessToken:o,stagingToken:i}))},createSepaTransfer:async function*({sepaTransferSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}=t||{},s=n||a(),c=o||G();!function(e){if(!e)throw new R("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new R("sepaTransferSettings must be an object");if(!e.beneficiaryId&&!e.beneficiary)throw new R("Either beneficiaryId or beneficiary must be provided");const t=L({beneficiaryId:e.beneficiaryId});if(t.length>0)throw new R(t)}(e);const u=e?.beneficiary?e.beneficiary:await oc({sepaTransferSettings:e,operationSettings:t}),l={name:u.name,iban:u.iban},p=await Js({sepaPayee:l,accessToken:s,stagingToken:r}),g=yield(h=p,{matchResult:h.match_result,matchedName:h.matched_name});var h;let v;if("string"==typeof g){if(g===f)return}else{if(g.vopDecision===f)return;v=g.sepaTransferSettings}const m={...e,...v};!function(e){if(!e)throw new R("sepaTransferSettings parameter is required for the called function");if("object"!=typeof e)throw new R("sepaTransferSettings must be an object");D(e,sc);const t=[...L({bankAccountId:e.bankAccountId,note:e.note,reference:e.reference}),...N({amount:e.amount})].flat();if(t.length>0)throw new R(t);if(e.amount>d&&(!e.attachmentIds||0===e.attachmentIds.length))throw new R("Attachments are required for transfers over €30,000")}(m);const y={...m,beneficiary:u};return{transfer:Bs(await Vs({transfer:y,vopProofToken:p.proof_token.token,accessToken:s,stagingToken:r,scaSessionToken:i,idempotencyKey:c})),meta:{idempotencyKey:c}}},cancelSepaTransfer:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("sepaTransferId parameter is required for the called function");if("string"!=typeof e)throw new R("sepaTransferId must be a string");return e}(e?.sepaTransferId),{accessToken:r,stagingToken:i}=t||{},o=r||a();await Ws({sepaTransferId:n,accessToken:o,stagingToken:i})},getSepaTransferCreationFlowLink:async function({sepaTransferSettings:e,operationSettings:t}){const n=function(e){if(!e||!e.callbackUrl)throw new R("callbackUrl parameter is required for the getSepaTransferCreationFlowLink function");if("string"!=typeof e.callbackUrl)throw new R("callbackUrl must be a string");return e.callbackUrl}(e),{accessToken:r,stagingToken:i}=t||{},o=r||a(),s=await async function({requestSettings:e,operationSettings:t}){U(e);const{proxyEndpointDescriptor:n,stagingToken:r}=ic(t||{});if(n){const t=O({stagingToken:r,action:e.action,callbackUrl:e.callbackUrl});return x((await Is({proxyEndpointDescriptor:n,networkCallDescriptor:t})).body)}{const n=t?.accessToken||a();return x(await C({accessToken:n,stagingToken:r,action:e.action,callbackUrl:e.callbackUrl}))}}({requestSettings:{action:p.SEPA_TRANSFER_CREATE,callbackUrl:n},operationSettings:{stagingToken:i,accessToken:o}});return{...s,url:ac(s.url,t)}},bulkTransfers:{getBulkTransfers:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i=t||a(),o=await Zs({accessToken:i,stagingToken:n,paginationSettings:r}),s=o.bulkTransfers?.map(Ys),c=F(o.meta);return{bulkTransfers:s,...c?{meta:c}:{}}},getBulkTransfer:async function({bulkTransferSettings:e,operationSettings:t}){const n=function(e){if(!e)throw new R("bulkTransferId parameter is required for the called function.");if("string"!=typeof e)throw new R("bulkTransferId must be a string.");return e}(e?.bulkTransferId),{accessToken:r,stagingToken:i}=t||{},o=r||a();return Ys(await ec({accessToken:o,stagingToken:i,bulkTransferId:n}))},createBulkTransfer:async function*({bulkTransferSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r,scaSessionToken:i,idempotencyKey:o}=t||{},s=n||a(),c=o||G(),u=nc(e),l=new Map;for(const e of u.bulkTransfers){const t=e.beneficiary;if(t){const e=t.iban;e&&!l.has(e)&&l.set(e,{name:t.name,iban:e})}}const d=Array.from(l.values()),p=await tc({sepaPayees:d,accessToken:s,stagingToken:r});if((yield p.requests.map(Xs))===f)return;const g=await async function({bulkTransfers:e,accessToken:t,stagingToken:n,scaSessionToken:r,bankAccountId:i,idempotencyKey:o}){const a={method:"POST",headers:{..._({accessToken:t,stagingToken:n,scaSessionToken:r,idempotencyKey:o})},body:JSON.stringify({bank_account_id:i,bulk_transfers:e.map((e=>function(e){return{beneficiary_id:e.beneficiaryId||e.beneficiary?.id,client_transfer_id:e.clientTransferId,amount:e.amount.toString(),reference:e.reference,...e.note?{note:e.note}:{},...e.scheduledDate?{scheduled_date:e.scheduledDate.toISOString().split("T")[0]}:{},...e.attachmentsIds?{attachment_ids:e.attachmentsIds}:{}}}(e)))})},s=new URL(`${b.getEnvironmentUrls().THIRD_PARTY_API_URL}${Qs}`),c=await fetch(s,a),u=await c.json();if(!c.ok||u.errors)throw new S({message:u.errors?u.errors.map((e=>`${e.code}: ${e.detail}`)).join(", "):"Failed to create SEPA bulk transfer"});return u.bulk_transfer}({bulkTransfers:u.bulkTransfers,bankAccountId:u.bankAccountId,accessToken:s,stagingToken:r,scaSessionToken:i,idempotencyKey:c});return{bulkTransfer:Ys(g),meta:{idempotencyKey:c}}}}},uc="/v2/transactions";async function lc(e){const t=function({bankAccountId:e,iban:t,status:n,updatedAtFrom:r,updatedAtTo:i,emittedAtFrom:o,emittedAtTo:a,settledAtFrom:s,settledAtTo:c,side:u,operationType:l,withAttachments:d,paginationSettings:f,accessToken:p,stagingToken:g}){const h={method:"GET",headers:{accessToken:p,stagingToken:g}},v=new URLSearchParams;e&&v.append("bank_account_id",e),t&&v.append("iban",t),n&&v.append("status",n),r&&v.append("updated_at_from",r),i&&v.append("updated_at_to",i),o&&v.append("emitted_at_from",o),a&&v.append("emitted_at_to",a),s&&v.append("settled_at_from",s),c&&v.append("settled_at_to",c),u&&v.append("side",u),l&&v.append("operation_type",l),void 0!==d&&v.append("with_attachments",String(d));const m=q(f);for(const[e,t]of m)v.append(e,t);const y=v.toString();return{path:`${uc}${y?`?${y}`:""}`,options:h}}(e),{transactions:n,meta:r}=await I(t);return{transactions:n,meta:r}}async function dc(e){const t=function({transactionId:e,accessToken:t,stagingToken:n}){return{path:`${uc}/${e}`,options:{method:"GET",headers:{accessToken:t,stagingToken:n}}}}(e),{transaction:n}=await I(t);return n}function fc(e){return{transactionId:e.transaction_id,amount:e.amount,amountCents:e.amount_cents,settledBalance:e.settled_balance,settledBalanceCents:e.settled_balance_cents,attachmentIds:e.attachment_ids,localAmount:e.local_amount,localAmountCents:e.local_amount_cents,side:e.side,operationType:e.operation_type,currency:e.currency,localCurrency:e.local_currency,label:e.label,settledAt:new Date(e.settled_at),emittedAt:new Date(e.emitted_at),updatedAt:new Date(e.updated_at),status:e.status,note:e.note,reference:e.reference,vatAmount:e.vat_amount,vatAmountCents:e.vat_amount_cents,vatRate:e.vat_rate,initiatorId:e.initiator_id,labelIds:e.label_ids,attachmentLost:e.attachment_lost,attachmentRequired:e.attachment_required,cardLastDigits:e.card_last_digits,category:e.category,cashflowCategory:{name:e.cashflow_category?.name||""},cashflowSubcategory:{name:e.cashflow_subcategory?.name||""},id:e.id,subjectType:e.subject_type,...e.transfer?{transfer:{counterpartyAccountNumber:e.transfer.counterparty_account_number,counterpartyName:e.transfer.counterparty_name,counterpartyBic:e.transfer.counterparty_bic,counterpartyIban:e.transfer.counterparty_iban}}:{}}}const pc={getTransactions:async function(e){const{accessToken:t,stagingToken:n,paginationSettings:r}=e?.operationSettings||{},i={...e?.transactionSettings||{},paginationSettings:r},o=t||a(),s=await lc({...i,accessToken:o,stagingToken:n});return{transactions:s.transactions.map(fc),meta:F(s.meta)}},getTransaction:async function({transactionSettings:e,operationSettings:t}){const{accessToken:n,stagingToken:r}=t||{},{transactionId:i}=function(e){if(!e)throw new R("transactionSettings parameter is required for the called function");if(!e.transactionId)throw new R("transactionSettings.transactionId parameter is required for the called function");if(e.transactionId&&"string"!=typeof e.transactionId)throw new R("transactionSettings.transactionId must be a string.");return e}(e),o=n||a();return fc(await dc({transactionId:i,accessToken:o,stagingToken:r}))}};e.authLinks=j,e.beneficiaries=ie,e.cards=Os,e.organizations=xs,e.paymentLinks=Fs,e.sepaTransfers=cc,e.transactions=pc}));