@starfish-codes/hellgate 3.5.0 → 3.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- (function(v,ae){typeof exports=="object"&&typeof module<"u"?ae(exports):typeof define=="function"&&define.amd?define(["exports"],ae):(v=typeof globalThis<"u"?globalThis:v||self,ae(v.HellgateSDK={}))})(this,function(v){"use strict";function ae(e){return Array.isArray(e)?e.filter(Boolean):Object.fromEntries(Object.entries(e).map(([t,r])=>[t,typeof r=="object"&&r&&!Array.isArray(r)?ae(r):r]).filter(([t,r])=>typeof r=="object"&&r&&!Array.isArray(r)?!!Object.keys(r).length:r!=null&&r!=null))}function oe(e,t){const r={...e,...t},n=Object.keys(r);for(const s of n){const i=e[s],a=t[s];typeof i=="object"&&!Array.isArray(i)&&i&&typeof a=="object"&&!Array.isArray(a)&&a&&(r[s]=oe(i,a))}return r}function yt(e){if(!e.ok)throw e;return e.json()}const cs=2e3;class pr{constructor(t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"iframeId",{enumerable:!0,configurable:!0,writable:!0,value:String(Math.floor(1e5+Math.random()*9e5))}),Object.defineProperty(this,"resultPollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"transactionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"decoupledAuthHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"disposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"check3dsIframeDisposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"domContainer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"labelText",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onStartHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFinishHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onDecoupledAuth",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.decoupledAuthHandlers.push(n)}}),Object.defineProperty(this,"onStartChallenge",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onStartHandler=n}}),Object.defineProperty(this,"onChallengeFinished",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onFinishHandler=n}}),Object.defineProperty(this,"sessionStateHandle",{enumerable:!0,configurable:!0,writable:!0,value:n=>{var s,i;switch(n.next_action){case"3ds_check":{this.initCheck3DSIframes(n.data.threeds_server_callback_url,n.data.mon_url);break}case"3ds_challenge":{(s=this.onStartHandler)==null||s.call(this),this.disposeCheck3DSIframe(),this.startChallenge(n.data.challenge_url,n.data.result_mon_url);break}case"3ds_challenge_decoupled":{this.startDecoupledAuth(n.data.cardholder_info,n.data.result_mon_url,n.data.transaction_id);break}case null:{this.dispose(),(i=this.onFinishHandler)==null||i.call(this);break}}}}),this.domContainer=r.domContainer??bt(),this.disposers.push(this.session.onStateChange(this.sessionStateHandle)),this.labelText=r.labelText}dispose(){this.disposers.forEach(t=>t()),this.check3dsIframeDisposers.forEach(t=>t())}initCheck3DSIframes(t,r){const n=bt();n.insertAdjacentHTML("beforeend",`<iframe id="check_3ds_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${t}"></iframe>`);const s=n.querySelector(`#check_3ds_${this.iframeId}`);if(s){const i=a=>{a.source===s.contentWindow&&this.session.completeAction({action:"3ds_check",result:a.data})};window.addEventListener("message",i),this.check3dsIframeDisposers.push(()=>window.removeEventListener("message",i),()=>s.remove())}if(r){n.insertAdjacentHTML("beforeend",`<iframe id="mon_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${r}"></iframe>`);const i=n.querySelector(`#mon_${this.iframeId}`);i&&this.disposers.push(()=>i.remove())}}disposeCheck3DSIframe(){this.check3dsIframeDisposers.forEach(t=>t()),this.check3dsIframeDisposers=[]}startChallenge(t,r){const n=bt(),s=`<div style="display: flex; flex-direction: column; gap: 10px; align-items: center; ${this.domContainer===n?'border:0; max-width: 800px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width:100% " ':'border:0;" width="100%" height="100%"'}><iframe id="cha_${this.iframeId}" src="${t}" width="100%" height="500"></iframe>${this.labelText?'<span id="tds_label_text" style="font-size: large;">'+this.labelText+"</span>":""}<div>`;this.domContainer.insertAdjacentHTML("beforeend",this.domContainer===n?`<div id="cha_${this.iframeId}_wrap" style="background: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000;">${s}</div>`:s);const i=this.domContainer.querySelector(`#cha_${this.iframeId}`),a=this.domContainer.querySelector(`#cha_${this.iframeId}_wrap`);if(!i)throw new Error("3DS Challenge Iframe initialization failed");this.disposers.push(()=>{i.remove(),a==null||a.remove()});const o=new Promise(u=>{const l=f=>{f.source!==i.contentWindow||f.data.event!=="AuthResultReady"||u(f.data)};window.addEventListener("message",l),this.disposers.push(()=>window.removeEventListener("message",l))}),d=new Promise(u=>{const l=this.startAuthResultPolling(r,f=>{f.event==="AuthResultReady"&&(l(),u({requestor_trans_id:f.threeDSRequestorTransID,event:f.event}))})});Promise.any([o,d]).then(u=>{this.session.completeAction({action:"3ds_challenge",result:u})})}startDecoupledAuth(t,r,n){this.transactionId||(this.transactionId=n),this.decoupledAuthHandlers.forEach(i=>i(t));const s=this.startAuthResultPolling(r,i=>{i.event==="AuthResultReady"&&(this.session.completeAction({action:"3ds_challenge_decoupled",result:{...i,event:i.event}}),s())})}startAuthResultPolling(t,r){return window.clearTimeout(this.resultPollingTimer),this.resultPollingTimer=window.setTimeout(()=>fetch(t).then(n=>yt(n)).then(n=>{this.startAuthResultPolling(t,r),r(n)}).catch(()=>{}),cs),()=>window.clearTimeout(this.resultPollingTimer)}}function bt(){return document.body}var us=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ls(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return e[n]}})}),r}var mr={},ve={},ce={};Object.defineProperty(ce,"__esModule",{value:!0}),ce.makeRequestWithoutElementsPayloadCheck=ce.makeRequestWithElementsPayloadCheck=void 0;function ds(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class Er extends ds(Error){constructor(t){super(t),this.name="NoElementsError"}}const fs=(e,t,r,n,s={})=>{if(e!=null&&e.hasElement(n))return e.client[t](r,n,s);let i="Elements not initialized.";throw e&&(i="Element not found in payload."),new Er(`${i} Use a regular HTTP client if no elements are needed.`)};ce.makeRequestWithElementsPayloadCheck=fs;const hs=(e,t,r,n={})=>{if(e)return e.client[t](r,n);throw new Er("Elements not initialized. Use a regular HTTP client if no elements are needed.")};ce.makeRequestWithoutElementsPayloadCheck=hs;var yr={},Oe={},D={},_={};Object.defineProperty(_,"__esModule",{value:!0}),_.USER_AGENT_HEADER=_.USER_AGENT_CLIENT=_.MERGE_CONTENT_TYPE=_.DEFAULT_ELEMENTS_BASE_URL=_.DEFAULT_BASE_URL=_.CONTENT_TYPE_HEADER=_.CLIENT_USER_AGENT_HEADER=_.CLIENT_BASE_PATHS=_.BT_TRANSACTION_ID_HEADER=_.BT_TRACE_ID_HEADER=_.BT_IDEMPOTENCY_KEY_HEADER=_.BT_EXPOSE_PROXY_RESPONSE_HEADER=_.BROWSER_LIST=_.API_KEY_HEADER=void 0;const ps="BT-API-KEY";_.API_KEY_HEADER=ps;const ms="bt-trace-id";_.BT_TRACE_ID_HEADER=ms;const Es="bt-idempotency-key";_.BT_IDEMPOTENCY_KEY_HEADER=Es;const ys="BT-EXPOSE-RAW-PROXY-RESPONSE";_.BT_EXPOSE_PROXY_RESPONSE_HEADER=ys;const bs="BT-TRANSACTION-ID";_.BT_TRANSACTION_ID_HEADER=bs;const _s="Content-Type";_.CONTENT_TYPE_HEADER=_s;const gs="application/merge-patch+json";_.MERGE_CONTENT_TYPE=gs;const ws="User-Agent";_.USER_AGENT_HEADER=ws;const Ss="BT-CLIENT-USER-AGENT";_.CLIENT_USER_AGENT_HEADER=Ss;const Ts="BasisTheoryJS";_.USER_AGENT_CLIENT=Ts;const Rs="https://api.basistheory.com";_.DEFAULT_BASE_URL=Rs;const As="https://js.basistheory.com/hosted-elements";_.DEFAULT_ELEMENTS_BASE_URL=As;const vs={tokens:"tokens",tokenize:"tokenize",applications:"applications",tenants:"tenants/self",logs:"logs",reactorFormulas:"reactor-formulas",reactors:"reactors",permissions:"permissions",proxies:"proxies",proxy:"proxy",sessions:"sessions",transactions:"transactions"};_.CLIENT_BASE_PATHS=vs;const Os=[{browserName:"Firefox",browserUA:"Firefox"},{browserName:"SamsungBrowser",browserUA:"SamsungBrowser"},{browserName:"Opera",browserUA:"Opera"},{browserName:"Opera",browserUA:"OPR"},{browserName:"Microsoft Internet Explorer",browserUA:"Trident"},{browserName:"Microsoft Edge (Legacy)",browserUA:"Edge"},{browserName:"Microsoft Edge (Chromium)",browserUA:"Edg"},{browserName:"Google Chrome/Chromium",browserUA:"Chrome"},{browserName:"Safari",browserUA:"Safari"}];_.BROWSER_LIST=Os;var m={};function br(e,t){return function(){return e.apply(t,arguments)}}const{toString:Cs}=Object.prototype,{getPrototypeOf:_t}=Object,Ce=(e=>t=>{const r=Cs.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),M=e=>(e=e.toLowerCase(),t=>Ce(t)===e),Pe=e=>t=>typeof t===e,{isArray:ue}=Array,Ee=Pe("undefined");function Ps(e){return e!==null&&!Ee(e)&&e.constructor!==null&&!Ee(e.constructor)&&U(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const _r=M("ArrayBuffer");function Bs(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&_r(e.buffer),t}const xs=Pe("string"),U=Pe("function"),gr=Pe("number"),Be=e=>e!==null&&typeof e=="object",Ns=e=>e===!0||e===!1,xe=e=>{if(Ce(e)!=="object")return!1;const t=_t(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},js=M("Date"),Ds=M("File"),Us=M("Blob"),Hs=M("FileList"),Ls=e=>Be(e)&&U(e.pipe),Ms=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||U(e.append)&&((t=Ce(e))==="formdata"||t==="object"&&U(e.toString)&&e.toString()==="[object FormData]"))},Is=M("URLSearchParams"),[$s,qs,Ks,Fs]=["ReadableStream","Request","Response","Headers"].map(M),zs=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ye(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,s;if(typeof e!="object"&&(e=[e]),ue(e))for(n=0,s=e.length;n<s;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let o;for(n=0;n<a;n++)o=i[n],t.call(null,e[o],o,e)}}function wr(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,s;for(;n-- >0;)if(s=r[n],t===s.toLowerCase())return s;return null}const Q=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:us,Sr=e=>!Ee(e)&&e!==Q;function gt(){const{caseless:e}=Sr(this)&&this||{},t={},r=(n,s)=>{const i=e&&wr(t,s)||s;xe(t[i])&&xe(n)?t[i]=gt(t[i],n):xe(n)?t[i]=gt({},n):ue(n)?t[i]=n.slice():t[i]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&ye(arguments[n],r);return t}const Ws=(e,t,r,{allOwnKeys:n}={})=>(ye(t,(s,i)=>{r&&U(s)?e[i]=br(s,r):e[i]=s},{allOwnKeys:n}),e),ks=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Vs=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Gs=(e,t,r,n)=>{let s,i,a;const o={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)a=s[i],(!n||n(a,e,t))&&!o[a]&&(t[a]=e[a],o[a]=!0);e=r!==!1&&_t(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Js=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},Ys=e=>{if(!e)return null;if(ue(e))return e;let t=e.length;if(!gr(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Xs=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&_t(Uint8Array)),Zs=(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=n.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},Qs=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},ei=M("HTMLFormElement"),ti=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),Tr=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ri=M("RegExp"),Rr=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ye(r,(s,i)=>{let a;(a=t(s,i,e))!==!1&&(n[i]=a||s)}),Object.defineProperties(e,n)},ni=e=>{Rr(e,(t,r)=>{if(U(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(U(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},si=(e,t)=>{const r={},n=s=>{s.forEach(i=>{r[i]=!0})};return ue(e)?n(e):n(String(e).split(t)),r},ii=()=>{},ai=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,wt="abcdefghijklmnopqrstuvwxyz",Ar="0123456789",vr={DIGIT:Ar,ALPHA:wt,ALPHA_DIGIT:wt+wt.toUpperCase()+Ar},oi=(e=16,t=vr.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function ci(e){return!!(e&&U(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const ui=e=>{const t=new Array(10),r=(n,s)=>{if(Be(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[s]=n;const i=ue(n)?[]:{};return ye(n,(a,o)=>{const d=r(a,s+1);!Ee(d)&&(i[o]=d)}),t[s]=void 0,i}}return n};return r(e,0)},li=M("AsyncFunction"),di=e=>e&&(Be(e)||U(e))&&U(e.then)&&U(e.catch),Or=((e,t)=>e?setImmediate:t?((r,n)=>(Q.addEventListener("message",({source:s,data:i})=>{s===Q&&i===r&&n.length&&n.shift()()},!1),s=>{n.push(s),Q.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",U(Q.postMessage)),fi=typeof queueMicrotask<"u"?queueMicrotask.bind(Q):typeof process<"u"&&process.nextTick||Or;var c={isArray:ue,isArrayBuffer:_r,isBuffer:Ps,isFormData:Ms,isArrayBufferView:Bs,isString:xs,isNumber:gr,isBoolean:Ns,isObject:Be,isPlainObject:xe,isReadableStream:$s,isRequest:qs,isResponse:Ks,isHeaders:Fs,isUndefined:Ee,isDate:js,isFile:Ds,isBlob:Us,isRegExp:ri,isFunction:U,isStream:Ls,isURLSearchParams:Is,isTypedArray:Xs,isFileList:Hs,forEach:ye,merge:gt,extend:Ws,trim:zs,stripBOM:ks,inherits:Vs,toFlatObject:Gs,kindOf:Ce,kindOfTest:M,endsWith:Js,toArray:Ys,forEachEntry:Zs,matchAll:Qs,isHTMLForm:ei,hasOwnProperty:Tr,hasOwnProp:Tr,reduceDescriptors:Rr,freezeMethods:ni,toObjectSet:si,toCamelCase:ti,noop:ii,toFiniteNumber:ai,findKey:wr,global:Q,isContextDefined:Sr,ALPHABET:vr,generateString:oi,isSpecCompliantForm:ci,toJSONObject:ui,isAsyncFn:li,isThenable:di,setImmediate:Or,asap:fi};function y(e,t,r,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}c.inherits(y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:c.toJSONObject(this.config),code:this.code,status:this.status}}});const Cr=y.prototype,Pr={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Pr[e]={value:e}}),Object.defineProperties(y,Pr),Object.defineProperty(Cr,"isAxiosError",{value:!0}),y.from=(e,t,r,n,s,i)=>{const a=Object.create(Cr);return c.toFlatObject(e,a,function(d){return d!==Error.prototype},o=>o!=="isAxiosError"),y.call(a,e.message,t,r,n,s),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};var hi=null;function St(e){return c.isPlainObject(e)||c.isArray(e)}function Br(e){return c.endsWith(e,"[]")?e.slice(0,-2):e}function xr(e,t,r){return e?e.concat(t).map(function(s,i){return s=Br(s),!r&&i?"["+s+"]":s}).join(r?".":""):t}function pi(e){return c.isArray(e)&&!e.some(St)}const mi=c.toFlatObject(c,{},null,function(t){return/^is[A-Z]/.test(t)});function Ne(e,t,r){if(!c.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=c.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(E,p){return!c.isUndefined(p[E])});const n=r.metaTokens,s=r.visitor||l,i=r.dots,a=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&c.isSpecCompliantForm(t);if(!c.isFunction(s))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(c.isDate(h))return h.toISOString();if(!d&&c.isBlob(h))throw new y("Blob is not supported. Use a Buffer instead.");return c.isArrayBuffer(h)||c.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function l(h,E,p){let S=h;if(h&&!p&&typeof h=="object"){if(c.endsWith(E,"{}"))E=n?E:E.slice(0,-2),h=JSON.stringify(h);else if(c.isArray(h)&&pi(h)||(c.isFileList(h)||c.endsWith(E,"[]"))&&(S=c.toArray(h)))return E=Br(E),S.forEach(function(C,V){!(c.isUndefined(C)||C===null)&&t.append(a===!0?xr([E],V,i):a===null?E:E+"[]",u(C))}),!1}return St(h)?!0:(t.append(xr(p,E,i),u(h)),!1)}const f=[],b=Object.assign(mi,{defaultVisitor:l,convertValue:u,isVisitable:St});function w(h,E){if(!c.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+E.join("."));f.push(h),c.forEach(h,function(S,O){(!(c.isUndefined(S)||S===null)&&s.call(t,S,c.isString(O)?O.trim():O,E,b))===!0&&w(S,E?E.concat(O):[O])}),f.pop()}}if(!c.isObject(e))throw new TypeError("data must be an object");return w(e),t}function Nr(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Tt(e,t){this._pairs=[],e&&Ne(e,this,t)}const jr=Tt.prototype;jr.append=function(t,r){this._pairs.push([t,r])},jr.toString=function(t){const r=t?function(n){return t.call(this,n,Nr)}:Nr;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function Ei(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Dr(e,t,r){if(!t)return e;const n=r&&r.encode||Ei,s=r&&r.serialize;let i;if(s?i=s(t,r):i=c.isURLSearchParams(t)?t.toString():new Tt(t,r).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class yi{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){c.forEach(this.handlers,function(n){n!==null&&t(n)})}}var Ur=yi,Hr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},bi=typeof URLSearchParams<"u"?URLSearchParams:Tt,_i=typeof FormData<"u"?FormData:null,gi=typeof Blob<"u"?Blob:null,wi={isBrowser:!0,classes:{URLSearchParams:bi,FormData:_i,Blob:gi},protocols:["http","https","file","blob","url","data"]};const Rt=typeof window<"u"&&typeof document<"u",At=typeof navigator=="object"&&navigator||void 0,Si=Rt&&(!At||["ReactNative","NativeScript","NS"].indexOf(At.product)<0),Ti=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ri=Rt&&window.location.href||"http://localhost";var Ai=Object.freeze({__proto__:null,hasBrowserEnv:Rt,hasStandardBrowserWebWorkerEnv:Ti,hasStandardBrowserEnv:Si,navigator:At,origin:Ri}),B={...Ai,...wi};function vi(e,t){return Ne(e,new B.classes.URLSearchParams,Object.assign({visitor:function(r,n,s,i){return B.isNode&&c.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function Oi(e){return c.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Ci(e){const t={},r=Object.keys(e);let n;const s=r.length;let i;for(n=0;n<s;n++)i=r[n],t[i]=e[i];return t}function Lr(e){function t(r,n,s,i){let a=r[i++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),d=i>=r.length;return a=!a&&c.isArray(s)?s.length:a,d?(c.hasOwnProp(s,a)?s[a]=[s[a],n]:s[a]=n,!o):((!s[a]||!c.isObject(s[a]))&&(s[a]=[]),t(r,n,s[a],i)&&c.isArray(s[a])&&(s[a]=Ci(s[a])),!o)}if(c.isFormData(e)&&c.isFunction(e.entries)){const r={};return c.forEachEntry(e,(n,s)=>{t(Oi(n),s,r,0)}),r}return null}function Pi(e,t,r){if(c.isString(e))try{return(t||JSON.parse)(e),c.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const vt={transitional:Hr,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,i=c.isObject(t);if(i&&c.isHTMLForm(t)&&(t=new FormData(t)),c.isFormData(t))return s?JSON.stringify(Lr(t)):t;if(c.isArrayBuffer(t)||c.isBuffer(t)||c.isStream(t)||c.isFile(t)||c.isBlob(t)||c.isReadableStream(t))return t;if(c.isArrayBufferView(t))return t.buffer;if(c.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return vi(t,this.formSerializer).toString();if((o=c.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Ne(o?{"files[]":t}:t,d&&new d,this.formSerializer)}}return i||s?(r.setContentType("application/json",!1),Pi(t)):t}],transformResponse:[function(t){const r=this.transitional||vt.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(c.isResponse(t)||c.isReadableStream(t))return t;if(t&&c.isString(t)&&(n&&!this.responseType||s)){const a=!(r&&r.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(o){if(a)throw o.name==="SyntaxError"?y.from(o,y.ERR_BAD_RESPONSE,this,null,this.response):o}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:B.classes.FormData,Blob:B.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};c.forEach(["delete","get","head","post","put","patch"],e=>{vt.headers[e]={}});var Ot=vt;const Bi=c.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var xi=e=>{const t={};let r,n,s;return e&&e.split(`
2
- `).forEach(function(a){s=a.indexOf(":"),r=a.substring(0,s).trim().toLowerCase(),n=a.substring(s+1).trim(),!(!r||t[r]&&Bi[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};const Mr=Symbol("internals");function be(e){return e&&String(e).trim().toLowerCase()}function je(e){return e===!1||e==null?e:c.isArray(e)?e.map(je):String(e)}function Ni(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const ji=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ct(e,t,r,n,s){if(c.isFunction(n))return n.call(this,t,r);if(s&&(t=r),!!c.isString(t)){if(c.isString(n))return t.indexOf(n)!==-1;if(c.isRegExp(n))return n.test(t)}}function Di(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function Ui(e,t){const r=c.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(s,i,a){return this[n].call(this,t,s,i,a)},configurable:!0})})}class De{constructor(t){t&&this.set(t)}set(t,r,n){const s=this;function i(o,d,u){const l=be(d);if(!l)throw new Error("header name must be a non-empty string");const f=c.findKey(s,l);(!f||s[f]===void 0||u===!0||u===void 0&&s[f]!==!1)&&(s[f||d]=je(o))}const a=(o,d)=>c.forEach(o,(u,l)=>i(u,l,d));if(c.isPlainObject(t)||t instanceof this.constructor)a(t,r);else if(c.isString(t)&&(t=t.trim())&&!ji(t))a(xi(t),r);else if(c.isHeaders(t))for(const[o,d]of t.entries())i(d,o,n);else t!=null&&i(r,t,n);return this}get(t,r){if(t=be(t),t){const n=c.findKey(this,t);if(n){const s=this[n];if(!r)return s;if(r===!0)return Ni(s);if(c.isFunction(r))return r.call(this,s,n);if(c.isRegExp(r))return r.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=be(t),t){const n=c.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Ct(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let s=!1;function i(a){if(a=be(a),a){const o=c.findKey(n,a);o&&(!r||Ct(n,n[o],o,r))&&(delete n[o],s=!0)}}return c.isArray(t)?t.forEach(i):i(t),s}clear(t){const r=Object.keys(this);let n=r.length,s=!1;for(;n--;){const i=r[n];(!t||Ct(this,this[i],i,t,!0))&&(delete this[i],s=!0)}return s}normalize(t){const r=this,n={};return c.forEach(this,(s,i)=>{const a=c.findKey(n,i);if(a){r[a]=je(s),delete r[i];return}const o=t?Di(i):String(i).trim();o!==i&&delete r[i],r[o]=je(s),n[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return c.forEach(this,(n,s)=>{n!=null&&n!==!1&&(r[s]=t&&c.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
3
- `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(s=>n.set(s)),n}static accessor(t){const n=(this[Mr]=this[Mr]={accessors:{}}).accessors,s=this.prototype;function i(a){const o=be(a);n[o]||(Ui(s,a),n[o]=!0)}return c.isArray(t)?t.forEach(i):i(t),this}}De.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),c.reduceDescriptors(De.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),c.freezeMethods(De);var I=De;function Pt(e,t){const r=this||Ot,n=t||r,s=I.from(n.headers);let i=n.data;return c.forEach(e,function(o){i=o.call(r,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function Ir(e){return!!(e&&e.__CANCEL__)}function le(e,t,r){y.call(this,e??"canceled",y.ERR_CANCELED,t,r),this.name="CanceledError"}c.inherits(le,y,{__CANCEL__:!0});function $r(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new y("Request failed with status code "+r.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Hi(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Li(e,t){e=e||10;const r=new Array(e),n=new Array(e);let s=0,i=0,a;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=n[i];a||(a=u),r[s]=d,n[s]=u;let f=i,b=0;for(;f!==s;)b+=r[f++],f=f%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),u-a<t)return;const w=l&&u-l;return w?Math.round(b*1e3/w):void 0}}function Mi(e,t){let r=0,n=1e3/t,s,i;const a=(u,l=Date.now())=>{r=l,s=null,i&&(clearTimeout(i),i=null),e.apply(null,u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?a(u,l):(s=u,i||(i=setTimeout(()=>{i=null,a(s)},n-f)))},()=>s&&a(s)]}const Ue=(e,t,r=3)=>{let n=0;const s=Li(50,250);return Mi(i=>{const a=i.loaded,o=i.lengthComputable?i.total:void 0,d=a-n,u=s(d),l=a<=o;n=a;const f={loaded:a,total:o,progress:o?a/o:void 0,bytes:d,rate:u||void 0,estimated:u&&o&&l?(o-a)/u:void 0,event:i,lengthComputable:o!=null,[t?"download":"upload"]:!0};e(f)},r)},qr=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Kr=e=>(...t)=>c.asap(()=>e(...t));var Ii=B.hasStandardBrowserEnv?function(){const t=B.navigator&&/(msie|trident)/i.test(B.navigator.userAgent),r=document.createElement("a");let n;function s(i){let a=i;return t&&(r.setAttribute("href",a),a=r.href),r.setAttribute("href",a),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(a){const o=c.isString(a)?s(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}(),$i=B.hasStandardBrowserEnv?{write(e,t,r,n,s,i){const a=[e+"="+encodeURIComponent(t)];c.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),c.isString(n)&&a.push("path="+n),c.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function qi(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ki(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Fr(e,t){return e&&!qi(t)?Ki(e,t):t}const zr=e=>e instanceof I?{...e}:e;function ee(e,t){t=t||{};const r={};function n(u,l,f){return c.isPlainObject(u)&&c.isPlainObject(l)?c.merge.call({caseless:f},u,l):c.isPlainObject(l)?c.merge({},l):c.isArray(l)?l.slice():l}function s(u,l,f){if(c.isUndefined(l)){if(!c.isUndefined(u))return n(void 0,u,f)}else return n(u,l,f)}function i(u,l){if(!c.isUndefined(l))return n(void 0,l)}function a(u,l){if(c.isUndefined(l)){if(!c.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function o(u,l,f){if(f in t)return n(u,l);if(f in e)return n(void 0,u)}const d={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(u,l)=>s(zr(u),zr(l),!0)};return c.forEach(Object.keys(Object.assign({},e,t)),function(l){const f=d[l]||s,b=f(e[l],t[l],l);c.isUndefined(b)&&f!==o||(r[l]=b)}),r}var Wr=e=>{const t=ee({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:i,headers:a,auth:o}=t;t.headers=a=I.from(a),t.url=Dr(Fr(t.baseURL,t.url),e.params,e.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let d;if(c.isFormData(r)){if(B.hasStandardBrowserEnv||B.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((d=a.getContentType())!==!1){const[u,...l]=d?d.split(";").map(f=>f.trim()).filter(Boolean):[];a.setContentType([u||"multipart/form-data",...l].join("; "))}}if(B.hasStandardBrowserEnv&&(n&&c.isFunction(n)&&(n=n(t)),n||n!==!1&&Ii(t.url))){const u=s&&i&&$i.read(i);u&&a.set(s,u)}return t},Fi=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const s=Wr(e);let i=s.data;const a=I.from(s.headers).normalize();let{responseType:o,onUploadProgress:d,onDownloadProgress:u}=s,l,f,b,w,h;function E(){w&&w(),h&&h(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function S(){if(!p)return;const C=I.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),j={data:!o||o==="text"||o==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:C,config:e,request:p};$r(function(ie){r(ie),E()},function(ie){n(ie),E()},j),p=null}"onloadend"in p?p.onloadend=S:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(S)},p.onabort=function(){p&&(n(new y("Request aborted",y.ECONNABORTED,e,p)),p=null)},p.onerror=function(){n(new y("Network Error",y.ERR_NETWORK,e,p)),p=null},p.ontimeout=function(){let V=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const j=s.transitional||Hr;s.timeoutErrorMessage&&(V=s.timeoutErrorMessage),n(new y(V,j.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,p)),p=null},i===void 0&&a.setContentType(null),"setRequestHeader"in p&&c.forEach(a.toJSON(),function(V,j){p.setRequestHeader(j,V)}),c.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),o&&o!=="json"&&(p.responseType=s.responseType),u&&([b,h]=Ue(u,!0),p.addEventListener("progress",b)),d&&p.upload&&([f,w]=Ue(d),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",w)),(s.cancelToken||s.signal)&&(l=C=>{p&&(n(!C||C.type?new le(null,e,p):C),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const O=Hi(s.url);if(O&&B.protocols.indexOf(O)===-1){n(new y("Unsupported protocol "+O+":",y.ERR_BAD_REQUEST,e));return}p.send(i||null)})},zi=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,s;const i=function(u){if(!s){s=!0,o();const l=u instanceof Error?u:this.reason;n.abort(l instanceof y?l:new le(l instanceof Error?l.message:l))}};let a=t&&setTimeout(()=>{a=null,i(new y(`timeout ${t} of ms exceeded`,y.ETIMEDOUT))},t);const o=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:d}=n;return d.unsubscribe=()=>c.asap(o),d}};const Wi=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,s;for(;n<r;)s=n+t,yield e.slice(n,s),n=s},ki=async function*(e,t){for await(const r of Vi(e))yield*Wi(r,t)},Vi=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},kr=(e,t,r,n)=>{const s=ki(e,t);let i=0,a,o=d=>{a||(a=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){o(),d.close();return}let f=l.byteLength;if(r){let b=i+=f;r(b)}d.enqueue(new Uint8Array(l))}catch(u){throw o(u),u}},cancel(d){return o(d),s.return()}},{highWaterMark:2})},He=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Vr=He&&typeof ReadableStream=="function",Gi=He&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Gr=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ji=Vr&&Gr(()=>{let e=!1;const t=new Request(B.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Jr=64*1024,Bt=Vr&&Gr(()=>c.isReadableStream(new Response("").body)),Le={stream:Bt&&(e=>e.body)};He&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Le[t]&&(Le[t]=c.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new y(`Response type '${t}' is not supported`,y.ERR_NOT_SUPPORT,n)})})})(new Response);const Yi=async e=>{if(e==null)return 0;if(c.isBlob(e))return e.size;if(c.isSpecCompliantForm(e))return(await new Request(B.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(c.isArrayBufferView(e)||c.isArrayBuffer(e))return e.byteLength;if(c.isURLSearchParams(e)&&(e=e+""),c.isString(e))return(await Gi(e)).byteLength},Xi=async(e,t)=>{const r=c.toFiniteNumber(e.getContentLength());return r??Yi(t)};var Zi=He&&(async e=>{let{url:t,method:r,data:n,signal:s,cancelToken:i,timeout:a,onDownloadProgress:o,onUploadProgress:d,responseType:u,headers:l,withCredentials:f="same-origin",fetchOptions:b}=Wr(e);u=u?(u+"").toLowerCase():"text";let w=zi([s,i&&i.toAbortSignal()],a),h;const E=w&&w.unsubscribe&&(()=>{w.unsubscribe()});let p;try{if(d&&Ji&&r!=="get"&&r!=="head"&&(p=await Xi(l,n))!==0){let j=new Request(t,{method:"POST",body:n,duplex:"half"}),Z;if(c.isFormData(n)&&(Z=j.headers.get("content-type"))&&l.setContentType(Z),j.body){const[ie,Et]=qr(p,Ue(Kr(d)));n=kr(j.body,Jr,ie,Et)}}c.isString(f)||(f=f?"include":"omit");const S="credentials"in Request.prototype;h=new Request(t,{...b,signal:w,method:r.toUpperCase(),headers:l.normalize().toJSON(),body:n,duplex:"half",credentials:S?f:void 0});let O=await fetch(h);const C=Bt&&(u==="stream"||u==="response");if(Bt&&(o||C&&E)){const j={};["status","statusText","headers"].forEach(os=>{j[os]=O[os]});const Z=c.toFiniteNumber(O.headers.get("content-length")),[ie,Et]=o&&qr(Z,Ue(Kr(o),!0))||[];O=new Response(kr(O.body,Jr,ie,()=>{Et&&Et(),E&&E()}),j)}u=u||"text";let V=await Le[c.findKey(Le,u)||"text"](O,e);return!C&&E&&E(),await new Promise((j,Z)=>{$r(j,Z,{data:V,headers:I.from(O.headers),status:O.status,statusText:O.statusText,config:e,request:h})})}catch(S){throw E&&E(),S&&S.name==="TypeError"&&/fetch/i.test(S.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,e,h),{cause:S.cause||S}):y.from(S,S&&S.code,e,h)}});const xt={http:hi,xhr:Fi,fetch:Zi};c.forEach(xt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Yr=e=>`- ${e}`,Qi=e=>c.isFunction(e)||e===null||e===!1;var Xr={getAdapter:e=>{e=c.isArray(e)?e:[e];const{length:t}=e;let r,n;const s={};for(let i=0;i<t;i++){r=e[i];let a;if(n=r,!Qi(r)&&(n=xt[(a=String(r)).toLowerCase()],n===void 0))throw new y(`Unknown adapter '${a}'`);if(n)break;s[a||"#"+i]=n}if(!n){const i=Object.entries(s).map(([o,d])=>`adapter ${o} `+(d===!1?"is not supported by the environment":"is not available in the build"));let a=t?i.length>1?`since :
1
+ (function(v,ae){typeof exports=="object"&&typeof module<"u"?ae(exports):typeof define=="function"&&define.amd?define(["exports"],ae):(v=typeof globalThis<"u"?globalThis:v||self,ae(v.HellgateSDK={}))})(this,function(v){"use strict";function ae(e){return Array.isArray(e)?e.filter(Boolean):Object.fromEntries(Object.entries(e).map(([t,r])=>[t,typeof r=="object"&&r&&!Array.isArray(r)?ae(r):r]).filter(([t,r])=>typeof r=="object"&&r&&!Array.isArray(r)?!!Object.keys(r).length:r!=null&&r!=null))}function oe(e,t){const r={...e,...t},n=Object.keys(r);for(const s of n){const i=e[s],a=t[s];typeof i=="object"&&!Array.isArray(i)&&i&&typeof a=="object"&&!Array.isArray(a)&&a&&(r[s]=oe(i,a))}return r}function yt(e){if(!e.ok)throw e;return e.json()}const cs=2e3;class pr{constructor(t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"iframeId",{enumerable:!0,configurable:!0,writable:!0,value:String(Math.floor(1e5+Math.random()*9e5))}),Object.defineProperty(this,"resultPollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"transactionId",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"decoupledAuthHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"disposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"check3dsIframeDisposers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"domContainer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"labelText",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onStartHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onFinishHandler",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"onDecoupledAuth",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.decoupledAuthHandlers.push(n)}}),Object.defineProperty(this,"onStartChallenge",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onStartHandler=n}}),Object.defineProperty(this,"onChallengeFinished",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onFinishHandler=n}}),Object.defineProperty(this,"sessionStateHandle",{enumerable:!0,configurable:!0,writable:!0,value:n=>{var s,i;switch(n.next_action){case"3ds_check":{this.initCheck3DSIframes(n.data.threeds_server_callback_url,n.data.mon_url);break}case"3ds_challenge":{(s=this.onStartHandler)==null||s.call(this),this.disposeCheck3DSIframe(),this.startChallenge(n.data.challenge_url,n.data.result_mon_url);break}case"3ds_challenge_decoupled":{this.startDecoupledAuth(n.data.cardholder_info,n.data.result_mon_url,n.data.transaction_id);break}case null:{this.dispose(),(i=this.onFinishHandler)==null||i.call(this);break}}}}),this.domContainer=r.domContainer??bt(),this.disposers.push(this.session.onStateChange(this.sessionStateHandle)),this.labelText=r.labelText}dispose(){this.disposers.forEach(t=>t()),this.check3dsIframeDisposers.forEach(t=>t())}initCheck3DSIframes(t,r){const n=bt();n.insertAdjacentHTML("beforeend",`<iframe id="check_3ds_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${t}"></iframe>`);const s=n.querySelector(`#check_3ds_${this.iframeId}`);if(s){const i=a=>{a.source===s.contentWindow&&this.session.completeAction({action:"3ds_check",result:a.data})};window.addEventListener("message",i),this.check3dsIframeDisposers.push(()=>window.removeEventListener("message",i),()=>s.remove())}if(r){n.insertAdjacentHTML("beforeend",`<iframe id="mon_${this.iframeId}" width="0" height="0" style="border:0;visibility: hidden;" src="${r}"></iframe>`);const i=n.querySelector(`#mon_${this.iframeId}`);i&&this.disposers.push(()=>i.remove())}}disposeCheck3DSIframe(){this.check3dsIframeDisposers.forEach(t=>t()),this.check3dsIframeDisposers=[]}startChallenge(t,r){const n=bt(),s=`<div style="display: flex; flex-direction: column; gap: 10px; align-items: center; ${this.domContainer===n?'border:0; max-width: 800px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width:100% " ':'border:0;" width="100%" height="100%"'}><iframe id="cha_${this.iframeId}" src="${t}" width="100%" height="500"></iframe>${this.labelText?'<span id="tds_label_text" style="font-size: large;">'+this.labelText+"</span>":""}<div>`;this.domContainer.insertAdjacentHTML("beforeend",this.domContainer===n?`<div id="cha_${this.iframeId}_wrap" style="background: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 10000;">${s}</div>`:s);const i=this.domContainer.querySelector(`#cha_${this.iframeId}`),a=this.domContainer.querySelector(`#cha_${this.iframeId}_wrap`);if(!i)throw new Error("3DS Challenge Iframe initialization failed");this.disposers.push(()=>{i.remove(),a==null||a.remove()});const o=new Promise(u=>{const l=f=>{f.source!==i.contentWindow||f.data.event!=="AuthResultReady"||u(f.data)};window.addEventListener("message",l),this.disposers.push(()=>window.removeEventListener("message",l))}),d=new Promise(u=>{const l=this.startAuthResultPolling(r,f=>{f.event==="AuthResultReady"&&(l(),u({requestor_trans_id:f.threeDSRequestorTransID,event:f.event}))})});Promise.any([o,d]).then(u=>{this.session.completeAction({action:"3ds_challenge",result:u})})}startDecoupledAuth(t,r,n){this.transactionId||(this.transactionId=n),this.decoupledAuthHandlers.forEach(i=>i(t));const s=this.startAuthResultPolling(r,i=>{i.event==="AuthResultReady"&&(this.session.completeAction({action:"3ds_challenge_decoupled",result:{...i,event:i.event}}),s())})}startAuthResultPolling(t,r){return window.clearTimeout(this.resultPollingTimer),this.resultPollingTimer=window.setTimeout(()=>fetch(t).then(n=>yt(n)).then(n=>{this.startAuthResultPolling(t,r),r(n)}).catch(()=>{}),cs),()=>window.clearTimeout(this.resultPollingTimer)}}function bt(){return document.body}var us=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ls(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,s.get?s:{enumerable:!0,get:function(){return e[n]}})}),r}var mr={},ve={},ce={};Object.defineProperty(ce,"__esModule",{value:!0}),ce.makeRequestWithoutElementsPayloadCheck=ce.makeRequestWithElementsPayloadCheck=void 0;function ds(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class Er extends ds(Error){constructor(t){super(t),this.name="NoElementsError"}}const fs=(e,t,r,n,s={})=>{if(e!=null&&e.hasElement(n))return e.client[t](r,n,s);let i="Elements not initialized.";throw e&&(i="Element not found in payload."),new Er(`${i} Use a regular HTTP client if no elements are needed.`)};ce.makeRequestWithElementsPayloadCheck=fs;const hs=(e,t,r,n={})=>{if(e)return e.client[t](r,n);throw new Er("Elements not initialized. Use a regular HTTP client if no elements are needed.")};ce.makeRequestWithoutElementsPayloadCheck=hs;var yr={},Ce={},D={},_={};Object.defineProperty(_,"__esModule",{value:!0}),_.USER_AGENT_HEADER=_.USER_AGENT_CLIENT=_.MERGE_CONTENT_TYPE=_.DEFAULT_ELEMENTS_BASE_URL=_.DEFAULT_BASE_URL=_.CONTENT_TYPE_HEADER=_.CLIENT_USER_AGENT_HEADER=_.CLIENT_BASE_PATHS=_.BT_TRANSACTION_ID_HEADER=_.BT_TRACE_ID_HEADER=_.BT_IDEMPOTENCY_KEY_HEADER=_.BT_EXPOSE_PROXY_RESPONSE_HEADER=_.BROWSER_LIST=_.API_KEY_HEADER=void 0;const ps="BT-API-KEY";_.API_KEY_HEADER=ps;const ms="bt-trace-id";_.BT_TRACE_ID_HEADER=ms;const Es="bt-idempotency-key";_.BT_IDEMPOTENCY_KEY_HEADER=Es;const ys="BT-EXPOSE-RAW-PROXY-RESPONSE";_.BT_EXPOSE_PROXY_RESPONSE_HEADER=ys;const bs="BT-TRANSACTION-ID";_.BT_TRANSACTION_ID_HEADER=bs;const _s="Content-Type";_.CONTENT_TYPE_HEADER=_s;const gs="application/merge-patch+json";_.MERGE_CONTENT_TYPE=gs;const ws="User-Agent";_.USER_AGENT_HEADER=ws;const Ss="BT-CLIENT-USER-AGENT";_.CLIENT_USER_AGENT_HEADER=Ss;const Ts="BasisTheoryJS";_.USER_AGENT_CLIENT=Ts;const Rs="https://api.basistheory.com";_.DEFAULT_BASE_URL=Rs;const As="https://js.basistheory.com/hosted-elements";_.DEFAULT_ELEMENTS_BASE_URL=As;const vs={tokens:"tokens",tokenize:"tokenize",applications:"applications",tenants:"tenants/self",logs:"logs",reactorFormulas:"reactor-formulas",reactors:"reactors",permissions:"permissions",proxies:"proxies",proxy:"proxy",sessions:"sessions",transactions:"transactions"};_.CLIENT_BASE_PATHS=vs;const Cs=[{browserName:"Firefox",browserUA:"Firefox"},{browserName:"SamsungBrowser",browserUA:"SamsungBrowser"},{browserName:"Opera",browserUA:"Opera"},{browserName:"Opera",browserUA:"OPR"},{browserName:"Microsoft Internet Explorer",browserUA:"Trident"},{browserName:"Microsoft Edge (Legacy)",browserUA:"Edge"},{browserName:"Microsoft Edge (Chromium)",browserUA:"Edg"},{browserName:"Google Chrome/Chromium",browserUA:"Chrome"},{browserName:"Safari",browserUA:"Safari"}];_.BROWSER_LIST=Cs;var m={};function br(e,t){return function(){return e.apply(t,arguments)}}const{toString:Os}=Object.prototype,{getPrototypeOf:_t}=Object,Oe=(e=>t=>{const r=Os.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),M=e=>(e=e.toLowerCase(),t=>Oe(t)===e),Pe=e=>t=>typeof t===e,{isArray:ue}=Array,Ee=Pe("undefined");function Ps(e){return e!==null&&!Ee(e)&&e.constructor!==null&&!Ee(e.constructor)&&U(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const _r=M("ArrayBuffer");function Bs(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&_r(e.buffer),t}const xs=Pe("string"),U=Pe("function"),gr=Pe("number"),Be=e=>e!==null&&typeof e=="object",Ns=e=>e===!0||e===!1,xe=e=>{if(Oe(e)!=="object")return!1;const t=_t(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},js=M("Date"),Ds=M("File"),Us=M("Blob"),Hs=M("FileList"),Ls=e=>Be(e)&&U(e.pipe),Ms=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||U(e.append)&&((t=Oe(e))==="formdata"||t==="object"&&U(e.toString)&&e.toString()==="[object FormData]"))},Is=M("URLSearchParams"),[$s,qs,Ks,Fs]=["ReadableStream","Request","Response","Headers"].map(M),zs=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function ye(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,s;if(typeof e!="object"&&(e=[e]),ue(e))for(n=0,s=e.length;n<s;n++)t.call(null,e[n],n,e);else{const i=r?Object.getOwnPropertyNames(e):Object.keys(e),a=i.length;let o;for(n=0;n<a;n++)o=i[n],t.call(null,e[o],o,e)}}function wr(e,t){t=t.toLowerCase();const r=Object.keys(e);let n=r.length,s;for(;n-- >0;)if(s=r[n],t===s.toLowerCase())return s;return null}const Q=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:us,Sr=e=>!Ee(e)&&e!==Q;function gt(){const{caseless:e}=Sr(this)&&this||{},t={},r=(n,s)=>{const i=e&&wr(t,s)||s;xe(t[i])&&xe(n)?t[i]=gt(t[i],n):xe(n)?t[i]=gt({},n):ue(n)?t[i]=n.slice():t[i]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&ye(arguments[n],r);return t}const Ws=(e,t,r,{allOwnKeys:n}={})=>(ye(t,(s,i)=>{r&&U(s)?e[i]=br(s,r):e[i]=s},{allOwnKeys:n}),e),ks=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Vs=(e,t,r,n)=>{e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),r&&Object.assign(e.prototype,r)},Gs=(e,t,r,n)=>{let s,i,a;const o={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)a=s[i],(!n||n(a,e,t))&&!o[a]&&(t[a]=e[a],o[a]=!0);e=r!==!1&&_t(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Js=(e,t,r)=>{e=String(e),(r===void 0||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return n!==-1&&n===r},Ys=e=>{if(!e)return null;if(ue(e))return e;let t=e.length;if(!gr(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Xs=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&_t(Uint8Array)),Zs=(e,t)=>{const n=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=n.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},Qs=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},ei=M("HTMLFormElement"),ti=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),Tr=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),ri=M("RegExp"),Rr=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};ye(r,(s,i)=>{let a;(a=t(s,i,e))!==!1&&(n[i]=a||s)}),Object.defineProperties(e,n)},ni=e=>{Rr(e,(t,r)=>{if(U(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(U(n)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},si=(e,t)=>{const r={},n=s=>{s.forEach(i=>{r[i]=!0})};return ue(e)?n(e):n(String(e).split(t)),r},ii=()=>{},ai=(e,t)=>e!=null&&Number.isFinite(e=+e)?e:t,wt="abcdefghijklmnopqrstuvwxyz",Ar="0123456789",vr={DIGIT:Ar,ALPHA:wt,ALPHA_DIGIT:wt+wt.toUpperCase()+Ar},oi=(e=16,t=vr.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function ci(e){return!!(e&&U(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const ui=e=>{const t=new Array(10),r=(n,s)=>{if(Be(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[s]=n;const i=ue(n)?[]:{};return ye(n,(a,o)=>{const d=r(a,s+1);!Ee(d)&&(i[o]=d)}),t[s]=void 0,i}}return n};return r(e,0)},li=M("AsyncFunction"),di=e=>e&&(Be(e)||U(e))&&U(e.then)&&U(e.catch),Cr=((e,t)=>e?setImmediate:t?((r,n)=>(Q.addEventListener("message",({source:s,data:i})=>{s===Q&&i===r&&n.length&&n.shift()()},!1),s=>{n.push(s),Q.postMessage(r,"*")}))(`axios@${Math.random()}`,[]):r=>setTimeout(r))(typeof setImmediate=="function",U(Q.postMessage)),fi=typeof queueMicrotask<"u"?queueMicrotask.bind(Q):typeof process<"u"&&process.nextTick||Cr;var c={isArray:ue,isArrayBuffer:_r,isBuffer:Ps,isFormData:Ms,isArrayBufferView:Bs,isString:xs,isNumber:gr,isBoolean:Ns,isObject:Be,isPlainObject:xe,isReadableStream:$s,isRequest:qs,isResponse:Ks,isHeaders:Fs,isUndefined:Ee,isDate:js,isFile:Ds,isBlob:Us,isRegExp:ri,isFunction:U,isStream:Ls,isURLSearchParams:Is,isTypedArray:Xs,isFileList:Hs,forEach:ye,merge:gt,extend:Ws,trim:zs,stripBOM:ks,inherits:Vs,toFlatObject:Gs,kindOf:Oe,kindOfTest:M,endsWith:Js,toArray:Ys,forEachEntry:Zs,matchAll:Qs,isHTMLForm:ei,hasOwnProperty:Tr,hasOwnProp:Tr,reduceDescriptors:Rr,freezeMethods:ni,toObjectSet:si,toCamelCase:ti,noop:ii,toFiniteNumber:ai,findKey:wr,global:Q,isContextDefined:Sr,ALPHABET:vr,generateString:oi,isSpecCompliantForm:ci,toJSONObject:ui,isAsyncFn:li,isThenable:di,setImmediate:Cr,asap:fi};function y(e,t,r,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}c.inherits(y,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:c.toJSONObject(this.config),code:this.code,status:this.status}}});const Or=y.prototype,Pr={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Pr[e]={value:e}}),Object.defineProperties(y,Pr),Object.defineProperty(Or,"isAxiosError",{value:!0}),y.from=(e,t,r,n,s,i)=>{const a=Object.create(Or);return c.toFlatObject(e,a,function(d){return d!==Error.prototype},o=>o!=="isAxiosError"),y.call(a,e.message,t,r,n,s),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};var hi=null;function St(e){return c.isPlainObject(e)||c.isArray(e)}function Br(e){return c.endsWith(e,"[]")?e.slice(0,-2):e}function xr(e,t,r){return e?e.concat(t).map(function(s,i){return s=Br(s),!r&&i?"["+s+"]":s}).join(r?".":""):t}function pi(e){return c.isArray(e)&&!e.some(St)}const mi=c.toFlatObject(c,{},null,function(t){return/^is[A-Z]/.test(t)});function Ne(e,t,r){if(!c.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=c.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(E,p){return!c.isUndefined(p[E])});const n=r.metaTokens,s=r.visitor||l,i=r.dots,a=r.indexes,d=(r.Blob||typeof Blob<"u"&&Blob)&&c.isSpecCompliantForm(t);if(!c.isFunction(s))throw new TypeError("visitor must be a function");function u(h){if(h===null)return"";if(c.isDate(h))return h.toISOString();if(!d&&c.isBlob(h))throw new y("Blob is not supported. Use a Buffer instead.");return c.isArrayBuffer(h)||c.isTypedArray(h)?d&&typeof Blob=="function"?new Blob([h]):Buffer.from(h):h}function l(h,E,p){let S=h;if(h&&!p&&typeof h=="object"){if(c.endsWith(E,"{}"))E=n?E:E.slice(0,-2),h=JSON.stringify(h);else if(c.isArray(h)&&pi(h)||(c.isFileList(h)||c.endsWith(E,"[]"))&&(S=c.toArray(h)))return E=Br(E),S.forEach(function(O,V){!(c.isUndefined(O)||O===null)&&t.append(a===!0?xr([E],V,i):a===null?E:E+"[]",u(O))}),!1}return St(h)?!0:(t.append(xr(p,E,i),u(h)),!1)}const f=[],b=Object.assign(mi,{defaultVisitor:l,convertValue:u,isVisitable:St});function w(h,E){if(!c.isUndefined(h)){if(f.indexOf(h)!==-1)throw Error("Circular reference detected in "+E.join("."));f.push(h),c.forEach(h,function(S,C){(!(c.isUndefined(S)||S===null)&&s.call(t,S,c.isString(C)?C.trim():C,E,b))===!0&&w(S,E?E.concat(C):[C])}),f.pop()}}if(!c.isObject(e))throw new TypeError("data must be an object");return w(e),t}function Nr(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function Tt(e,t){this._pairs=[],e&&Ne(e,this,t)}const jr=Tt.prototype;jr.append=function(t,r){this._pairs.push([t,r])},jr.toString=function(t){const r=t?function(n){return t.call(this,n,Nr)}:Nr;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function Ei(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Dr(e,t,r){if(!t)return e;const n=r&&r.encode||Ei,s=r&&r.serialize;let i;if(s?i=s(t,r):i=c.isURLSearchParams(t)?t.toString():new Tt(t,r).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class yi{constructor(){this.handlers=[]}use(t,r,n){return this.handlers.push({fulfilled:t,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){c.forEach(this.handlers,function(n){n!==null&&t(n)})}}var Ur=yi,Hr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},bi=typeof URLSearchParams<"u"?URLSearchParams:Tt,_i=typeof FormData<"u"?FormData:null,gi=typeof Blob<"u"?Blob:null,wi={isBrowser:!0,classes:{URLSearchParams:bi,FormData:_i,Blob:gi},protocols:["http","https","file","blob","url","data"]};const Rt=typeof window<"u"&&typeof document<"u",At=typeof navigator=="object"&&navigator||void 0,Si=Rt&&(!At||["ReactNative","NativeScript","NS"].indexOf(At.product)<0),Ti=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Ri=Rt&&window.location.href||"http://localhost";var Ai=Object.freeze({__proto__:null,hasBrowserEnv:Rt,hasStandardBrowserWebWorkerEnv:Ti,hasStandardBrowserEnv:Si,navigator:At,origin:Ri}),B={...Ai,...wi};function vi(e,t){return Ne(e,new B.classes.URLSearchParams,Object.assign({visitor:function(r,n,s,i){return B.isNode&&c.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function Ci(e){return c.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Oi(e){const t={},r=Object.keys(e);let n;const s=r.length;let i;for(n=0;n<s;n++)i=r[n],t[i]=e[i];return t}function Lr(e){function t(r,n,s,i){let a=r[i++];if(a==="__proto__")return!0;const o=Number.isFinite(+a),d=i>=r.length;return a=!a&&c.isArray(s)?s.length:a,d?(c.hasOwnProp(s,a)?s[a]=[s[a],n]:s[a]=n,!o):((!s[a]||!c.isObject(s[a]))&&(s[a]=[]),t(r,n,s[a],i)&&c.isArray(s[a])&&(s[a]=Oi(s[a])),!o)}if(c.isFormData(e)&&c.isFunction(e.entries)){const r={};return c.forEachEntry(e,(n,s)=>{t(Ci(n),s,r,0)}),r}return null}function Pi(e,t,r){if(c.isString(e))try{return(t||JSON.parse)(e),c.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(0,JSON.stringify)(e)}const vt={transitional:Hr,adapter:["xhr","http","fetch"],transformRequest:[function(t,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,i=c.isObject(t);if(i&&c.isHTMLForm(t)&&(t=new FormData(t)),c.isFormData(t))return s?JSON.stringify(Lr(t)):t;if(c.isArrayBuffer(t)||c.isBuffer(t)||c.isStream(t)||c.isFile(t)||c.isBlob(t)||c.isReadableStream(t))return t;if(c.isArrayBufferView(t))return t.buffer;if(c.isURLSearchParams(t))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let o;if(i){if(n.indexOf("application/x-www-form-urlencoded")>-1)return vi(t,this.formSerializer).toString();if((o=c.isFileList(t))||n.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return Ne(o?{"files[]":t}:t,d&&new d,this.formSerializer)}}return i||s?(r.setContentType("application/json",!1),Pi(t)):t}],transformResponse:[function(t){const r=this.transitional||vt.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(c.isResponse(t)||c.isReadableStream(t))return t;if(t&&c.isString(t)&&(n&&!this.responseType||s)){const a=!(r&&r.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(o){if(a)throw o.name==="SyntaxError"?y.from(o,y.ERR_BAD_RESPONSE,this,null,this.response):o}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:B.classes.FormData,Blob:B.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};c.forEach(["delete","get","head","post","put","patch"],e=>{vt.headers[e]={}});var Ct=vt;const Bi=c.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]);var xi=e=>{const t={};let r,n,s;return e&&e.split(`
2
+ `).forEach(function(a){s=a.indexOf(":"),r=a.substring(0,s).trim().toLowerCase(),n=a.substring(s+1).trim(),!(!r||t[r]&&Bi[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};const Mr=Symbol("internals");function be(e){return e&&String(e).trim().toLowerCase()}function je(e){return e===!1||e==null?e:c.isArray(e)?e.map(je):String(e)}function Ni(e){const t=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(e);)t[n[1]]=n[2];return t}const ji=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function Ot(e,t,r,n,s){if(c.isFunction(n))return n.call(this,t,r);if(s&&(t=r),!!c.isString(t)){if(c.isString(n))return t.indexOf(n)!==-1;if(c.isRegExp(n))return n.test(t)}}function Di(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function Ui(e,t){const r=c.toCamelCase(" "+t);["get","set","has"].forEach(n=>{Object.defineProperty(e,n+r,{value:function(s,i,a){return this[n].call(this,t,s,i,a)},configurable:!0})})}class De{constructor(t){t&&this.set(t)}set(t,r,n){const s=this;function i(o,d,u){const l=be(d);if(!l)throw new Error("header name must be a non-empty string");const f=c.findKey(s,l);(!f||s[f]===void 0||u===!0||u===void 0&&s[f]!==!1)&&(s[f||d]=je(o))}const a=(o,d)=>c.forEach(o,(u,l)=>i(u,l,d));if(c.isPlainObject(t)||t instanceof this.constructor)a(t,r);else if(c.isString(t)&&(t=t.trim())&&!ji(t))a(xi(t),r);else if(c.isHeaders(t))for(const[o,d]of t.entries())i(d,o,n);else t!=null&&i(r,t,n);return this}get(t,r){if(t=be(t),t){const n=c.findKey(this,t);if(n){const s=this[n];if(!r)return s;if(r===!0)return Ni(s);if(c.isFunction(r))return r.call(this,s,n);if(c.isRegExp(r))return r.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=be(t),t){const n=c.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||Ot(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let s=!1;function i(a){if(a=be(a),a){const o=c.findKey(n,a);o&&(!r||Ot(n,n[o],o,r))&&(delete n[o],s=!0)}}return c.isArray(t)?t.forEach(i):i(t),s}clear(t){const r=Object.keys(this);let n=r.length,s=!1;for(;n--;){const i=r[n];(!t||Ot(this,this[i],i,t,!0))&&(delete this[i],s=!0)}return s}normalize(t){const r=this,n={};return c.forEach(this,(s,i)=>{const a=c.findKey(n,i);if(a){r[a]=je(s),delete r[i];return}const o=t?Di(i):String(i).trim();o!==i&&delete r[i],r[o]=je(s),n[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return c.forEach(this,(n,s)=>{n!=null&&n!==!1&&(r[s]=t&&c.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,r])=>t+": "+r).join(`
3
+ `)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...r){const n=new this(t);return r.forEach(s=>n.set(s)),n}static accessor(t){const n=(this[Mr]=this[Mr]={accessors:{}}).accessors,s=this.prototype;function i(a){const o=be(a);n[o]||(Ui(s,a),n[o]=!0)}return c.isArray(t)?t.forEach(i):i(t),this}}De.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),c.reduceDescriptors(De.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),c.freezeMethods(De);var I=De;function Pt(e,t){const r=this||Ct,n=t||r,s=I.from(n.headers);let i=n.data;return c.forEach(e,function(o){i=o.call(r,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function Ir(e){return!!(e&&e.__CANCEL__)}function le(e,t,r){y.call(this,e??"canceled",y.ERR_CANCELED,t,r),this.name="CanceledError"}c.inherits(le,y,{__CANCEL__:!0});function $r(e,t,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?e(r):t(new y("Request failed with status code "+r.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}function Hi(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Li(e,t){e=e||10;const r=new Array(e),n=new Array(e);let s=0,i=0,a;return t=t!==void 0?t:1e3,function(d){const u=Date.now(),l=n[i];a||(a=u),r[s]=d,n[s]=u;let f=i,b=0;for(;f!==s;)b+=r[f++],f=f%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),u-a<t)return;const w=l&&u-l;return w?Math.round(b*1e3/w):void 0}}function Mi(e,t){let r=0,n=1e3/t,s,i;const a=(u,l=Date.now())=>{r=l,s=null,i&&(clearTimeout(i),i=null),e.apply(null,u)};return[(...u)=>{const l=Date.now(),f=l-r;f>=n?a(u,l):(s=u,i||(i=setTimeout(()=>{i=null,a(s)},n-f)))},()=>s&&a(s)]}const Ue=(e,t,r=3)=>{let n=0;const s=Li(50,250);return Mi(i=>{const a=i.loaded,o=i.lengthComputable?i.total:void 0,d=a-n,u=s(d),l=a<=o;n=a;const f={loaded:a,total:o,progress:o?a/o:void 0,bytes:d,rate:u||void 0,estimated:u&&o&&l?(o-a)/u:void 0,event:i,lengthComputable:o!=null,[t?"download":"upload"]:!0};e(f)},r)},qr=(e,t)=>{const r=e!=null;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Kr=e=>(...t)=>c.asap(()=>e(...t));var Ii=B.hasStandardBrowserEnv?function(){const t=B.navigator&&/(msie|trident)/i.test(B.navigator.userAgent),r=document.createElement("a");let n;function s(i){let a=i;return t&&(r.setAttribute("href",a),a=r.href),r.setAttribute("href",a),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(a){const o=c.isString(a)?s(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}(),$i=B.hasStandardBrowserEnv?{write(e,t,r,n,s,i){const a=[e+"="+encodeURIComponent(t)];c.isNumber(r)&&a.push("expires="+new Date(r).toGMTString()),c.isString(n)&&a.push("path="+n),c.isString(s)&&a.push("domain="+s),i===!0&&a.push("secure"),document.cookie=a.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function qi(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Ki(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Fr(e,t){return e&&!qi(t)?Ki(e,t):t}const zr=e=>e instanceof I?{...e}:e;function ee(e,t){t=t||{};const r={};function n(u,l,f){return c.isPlainObject(u)&&c.isPlainObject(l)?c.merge.call({caseless:f},u,l):c.isPlainObject(l)?c.merge({},l):c.isArray(l)?l.slice():l}function s(u,l,f){if(c.isUndefined(l)){if(!c.isUndefined(u))return n(void 0,u,f)}else return n(u,l,f)}function i(u,l){if(!c.isUndefined(l))return n(void 0,l)}function a(u,l){if(c.isUndefined(l)){if(!c.isUndefined(u))return n(void 0,u)}else return n(void 0,l)}function o(u,l,f){if(f in t)return n(u,l);if(f in e)return n(void 0,u)}const d={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:o,headers:(u,l)=>s(zr(u),zr(l),!0)};return c.forEach(Object.keys(Object.assign({},e,t)),function(l){const f=d[l]||s,b=f(e[l],t[l],l);c.isUndefined(b)&&f!==o||(r[l]=b)}),r}var Wr=e=>{const t=ee({},e);let{data:r,withXSRFToken:n,xsrfHeaderName:s,xsrfCookieName:i,headers:a,auth:o}=t;t.headers=a=I.from(a),t.url=Dr(Fr(t.baseURL,t.url),e.params,e.paramsSerializer),o&&a.set("Authorization","Basic "+btoa((o.username||"")+":"+(o.password?unescape(encodeURIComponent(o.password)):"")));let d;if(c.isFormData(r)){if(B.hasStandardBrowserEnv||B.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if((d=a.getContentType())!==!1){const[u,...l]=d?d.split(";").map(f=>f.trim()).filter(Boolean):[];a.setContentType([u||"multipart/form-data",...l].join("; "))}}if(B.hasStandardBrowserEnv&&(n&&c.isFunction(n)&&(n=n(t)),n||n!==!1&&Ii(t.url))){const u=s&&i&&$i.read(i);u&&a.set(s,u)}return t},Fi=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){const s=Wr(e);let i=s.data;const a=I.from(s.headers).normalize();let{responseType:o,onUploadProgress:d,onDownloadProgress:u}=s,l,f,b,w,h;function E(){w&&w(),h&&h(),s.cancelToken&&s.cancelToken.unsubscribe(l),s.signal&&s.signal.removeEventListener("abort",l)}let p=new XMLHttpRequest;p.open(s.method.toUpperCase(),s.url,!0),p.timeout=s.timeout;function S(){if(!p)return;const O=I.from("getAllResponseHeaders"in p&&p.getAllResponseHeaders()),j={data:!o||o==="text"||o==="json"?p.responseText:p.response,status:p.status,statusText:p.statusText,headers:O,config:e,request:p};$r(function(ie){r(ie),E()},function(ie){n(ie),E()},j),p=null}"onloadend"in p?p.onloadend=S:p.onreadystatechange=function(){!p||p.readyState!==4||p.status===0&&!(p.responseURL&&p.responseURL.indexOf("file:")===0)||setTimeout(S)},p.onabort=function(){p&&(n(new y("Request aborted",y.ECONNABORTED,e,p)),p=null)},p.onerror=function(){n(new y("Network Error",y.ERR_NETWORK,e,p)),p=null},p.ontimeout=function(){let V=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const j=s.transitional||Hr;s.timeoutErrorMessage&&(V=s.timeoutErrorMessage),n(new y(V,j.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,p)),p=null},i===void 0&&a.setContentType(null),"setRequestHeader"in p&&c.forEach(a.toJSON(),function(V,j){p.setRequestHeader(j,V)}),c.isUndefined(s.withCredentials)||(p.withCredentials=!!s.withCredentials),o&&o!=="json"&&(p.responseType=s.responseType),u&&([b,h]=Ue(u,!0),p.addEventListener("progress",b)),d&&p.upload&&([f,w]=Ue(d),p.upload.addEventListener("progress",f),p.upload.addEventListener("loadend",w)),(s.cancelToken||s.signal)&&(l=O=>{p&&(n(!O||O.type?new le(null,e,p):O),p.abort(),p=null)},s.cancelToken&&s.cancelToken.subscribe(l),s.signal&&(s.signal.aborted?l():s.signal.addEventListener("abort",l)));const C=Hi(s.url);if(C&&B.protocols.indexOf(C)===-1){n(new y("Unsupported protocol "+C+":",y.ERR_BAD_REQUEST,e));return}p.send(i||null)})},zi=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let n=new AbortController,s;const i=function(u){if(!s){s=!0,o();const l=u instanceof Error?u:this.reason;n.abort(l instanceof y?l:new le(l instanceof Error?l.message:l))}};let a=t&&setTimeout(()=>{a=null,i(new y(`timeout ${t} of ms exceeded`,y.ETIMEDOUT))},t);const o=()=>{e&&(a&&clearTimeout(a),a=null,e.forEach(u=>{u.unsubscribe?u.unsubscribe(i):u.removeEventListener("abort",i)}),e=null)};e.forEach(u=>u.addEventListener("abort",i));const{signal:d}=n;return d.unsubscribe=()=>c.asap(o),d}};const Wi=function*(e,t){let r=e.byteLength;if(r<t){yield e;return}let n=0,s;for(;n<r;)s=n+t,yield e.slice(n,s),n=s},ki=async function*(e,t){for await(const r of Vi(e))yield*Wi(r,t)},Vi=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:r,value:n}=await t.read();if(r)break;yield n}}finally{await t.cancel()}},kr=(e,t,r,n)=>{const s=ki(e,t);let i=0,a,o=d=>{a||(a=!0,n&&n(d))};return new ReadableStream({async pull(d){try{const{done:u,value:l}=await s.next();if(u){o(),d.close();return}let f=l.byteLength;if(r){let b=i+=f;r(b)}d.enqueue(new Uint8Array(l))}catch(u){throw o(u),u}},cancel(d){return o(d),s.return()}},{highWaterMark:2})},He=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",Vr=He&&typeof ReadableStream=="function",Gi=He&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),Gr=(e,...t)=>{try{return!!e(...t)}catch{return!1}},Ji=Vr&&Gr(()=>{let e=!1;const t=new Request(B.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),Jr=64*1024,Bt=Vr&&Gr(()=>c.isReadableStream(new Response("").body)),Le={stream:Bt&&(e=>e.body)};He&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!Le[t]&&(Le[t]=c.isFunction(e[t])?r=>r[t]():(r,n)=>{throw new y(`Response type '${t}' is not supported`,y.ERR_NOT_SUPPORT,n)})})})(new Response);const Yi=async e=>{if(e==null)return 0;if(c.isBlob(e))return e.size;if(c.isSpecCompliantForm(e))return(await new Request(B.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(c.isArrayBufferView(e)||c.isArrayBuffer(e))return e.byteLength;if(c.isURLSearchParams(e)&&(e=e+""),c.isString(e))return(await Gi(e)).byteLength},Xi=async(e,t)=>{const r=c.toFiniteNumber(e.getContentLength());return r??Yi(t)};var Zi=He&&(async e=>{let{url:t,method:r,data:n,signal:s,cancelToken:i,timeout:a,onDownloadProgress:o,onUploadProgress:d,responseType:u,headers:l,withCredentials:f="same-origin",fetchOptions:b}=Wr(e);u=u?(u+"").toLowerCase():"text";let w=zi([s,i&&i.toAbortSignal()],a),h;const E=w&&w.unsubscribe&&(()=>{w.unsubscribe()});let p;try{if(d&&Ji&&r!=="get"&&r!=="head"&&(p=await Xi(l,n))!==0){let j=new Request(t,{method:"POST",body:n,duplex:"half"}),Z;if(c.isFormData(n)&&(Z=j.headers.get("content-type"))&&l.setContentType(Z),j.body){const[ie,Et]=qr(p,Ue(Kr(d)));n=kr(j.body,Jr,ie,Et)}}c.isString(f)||(f=f?"include":"omit");const S="credentials"in Request.prototype;h=new Request(t,{...b,signal:w,method:r.toUpperCase(),headers:l.normalize().toJSON(),body:n,duplex:"half",credentials:S?f:void 0});let C=await fetch(h);const O=Bt&&(u==="stream"||u==="response");if(Bt&&(o||O&&E)){const j={};["status","statusText","headers"].forEach(os=>{j[os]=C[os]});const Z=c.toFiniteNumber(C.headers.get("content-length")),[ie,Et]=o&&qr(Z,Ue(Kr(o),!0))||[];C=new Response(kr(C.body,Jr,ie,()=>{Et&&Et(),E&&E()}),j)}u=u||"text";let V=await Le[c.findKey(Le,u)||"text"](C,e);return!O&&E&&E(),await new Promise((j,Z)=>{$r(j,Z,{data:V,headers:I.from(C.headers),status:C.status,statusText:C.statusText,config:e,request:h})})}catch(S){throw E&&E(),S&&S.name==="TypeError"&&/fetch/i.test(S.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,e,h),{cause:S.cause||S}):y.from(S,S&&S.code,e,h)}});const xt={http:hi,xhr:Fi,fetch:Zi};c.forEach(xt,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Yr=e=>`- ${e}`,Qi=e=>c.isFunction(e)||e===null||e===!1;var Xr={getAdapter:e=>{e=c.isArray(e)?e:[e];const{length:t}=e;let r,n;const s={};for(let i=0;i<t;i++){r=e[i];let a;if(n=r,!Qi(r)&&(n=xt[(a=String(r)).toLowerCase()],n===void 0))throw new y(`Unknown adapter '${a}'`);if(n)break;s[a||"#"+i]=n}if(!n){const i=Object.entries(s).map(([o,d])=>`adapter ${o} `+(d===!1?"is not supported by the environment":"is not available in the build"));let a=t?i.length>1?`since :
4
4
  `+i.map(Yr).join(`
5
- `):" "+Yr(i[0]):"as no adapter specified";throw new y("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return n},adapters:xt};function Nt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new le(null,e)}function Zr(e){return Nt(e),e.headers=I.from(e.headers),e.data=Pt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Xr.getAdapter(e.adapter||Ot.adapter)(e).then(function(n){return Nt(e),n.data=Pt.call(e,e.transformResponse,n),n.headers=I.from(n.headers),n},function(n){return Ir(n)||(Nt(e),n&&n.response&&(n.response.data=Pt.call(e,e.transformResponse,n.response),n.response.headers=I.from(n.response.headers))),Promise.reject(n)})}const Qr="1.7.7",jt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{jt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const en={};jt.transitional=function(t,r,n){function s(i,a){return"[Axios v"+Qr+"] Transitional option '"+i+"'"+a+(n?". "+n:"")}return(i,a,o)=>{if(t===!1)throw new y(s(a," has been removed"+(r?" in "+r:"")),y.ERR_DEPRECATED);return r&&!en[a]&&(en[a]=!0,console.warn(s(a," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,a,o):!0}};function ea(e,t,r){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let s=n.length;for(;s-- >0;){const i=n[s],a=t[i];if(a){const o=e[i],d=o===void 0||a(o,i,e);if(d!==!0)throw new y("option "+i+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}var Dt={assertOptions:ea,validators:jt};const G=Dt.validators;class Me{constructor(t){this.defaults=t,this.interceptors={request:new Ur,response:new Ur}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let s;Error.captureStackTrace?Error.captureStackTrace(s={}):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
6
- `+i):n.stack=i}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ee(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&Dt.assertOptions(n,{silentJSONParsing:G.transitional(G.boolean),forcedJSONParsing:G.transitional(G.boolean),clarifyTimeoutError:G.transitional(G.boolean)},!1),s!=null&&(c.isFunction(s)?r.paramsSerializer={serialize:s}:Dt.assertOptions(s,{encode:G.function,serialize:G.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&c.merge(i.common,i[r.method]);i&&c.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),r.headers=I.concat(a,i);const o=[];let d=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(d=d&&E.synchronous,o.unshift(E.fulfilled,E.rejected))});const u=[];this.interceptors.response.forEach(function(E){u.push(E.fulfilled,E.rejected)});let l,f=0,b;if(!d){const h=[Zr.bind(this),void 0];for(h.unshift.apply(h,o),h.push.apply(h,u),b=h.length,l=Promise.resolve(r);f<b;)l=l.then(h[f++],h[f++]);return l}b=o.length;let w=r;for(f=0;f<b;){const h=o[f++],E=o[f++];try{w=h(w)}catch(p){E.call(this,p);break}}try{l=Zr.call(this,w)}catch(h){return Promise.reject(h)}for(f=0,b=u.length;f<b;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=ee(this.defaults,t);const r=Fr(t.baseURL,t.url);return Dr(r,t.params,t.paramsSerializer)}}c.forEach(["delete","get","head","options"],function(t){Me.prototype[t]=function(r,n){return this.request(ee(n||{},{method:t,url:r,data:(n||{}).data}))}}),c.forEach(["post","put","patch"],function(t){function r(n){return function(i,a,o){return this.request(ee(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}Me.prototype[t]=r(),Me.prototype[t+"Form"]=r(!0)});var Ie=Me;class Ut{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const a=new Promise(o=>{n.subscribe(o),i=o}).then(s);return a.cancel=function(){n.unsubscribe(i)},a},t(function(i,a,o){n.reason||(n.reason=new le(i,a,o),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Ut(function(s){t=s}),cancel:t}}}var ta=Ut;function ra(e){return function(r){return e.apply(null,r)}}function na(e){return c.isObject(e)&&e.isAxiosError===!0}const Ht={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ht).forEach(([e,t])=>{Ht[t]=e});var sa=Ht;function tn(e){const t=new Ie(e),r=br(Ie.prototype.request,t);return c.extend(r,Ie.prototype,t,{allOwnKeys:!0}),c.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return tn(ee(e,s))},r}const A=tn(Ot);A.Axios=Ie,A.CanceledError=le,A.CancelToken=ta,A.isCancel=Ir,A.VERSION=Qr,A.toFormData=Ne,A.AxiosError=y,A.Cancel=A.CanceledError,A.all=function(t){return Promise.all(t)},A.spread=ra,A.isAxiosError=na,A.mergeConfig=ee,A.AxiosHeaders=I,A.formToJSON=e=>Lr(c.isHTMLForm(e)?new FormData(e):e),A.getAdapter=Xr.getAdapter,A.HttpStatusCode=sa,A.default=A;var rn=A,Lt={exports:{}};const nn=e=>typeof e=="object"&&e!==null,sn=Symbol("skip"),an=e=>nn(e)&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),Mt=(e,t,r,n=new WeakMap)=>{if(r={deep:!1,target:{},...r},n.has(e))return n.get(e);n.set(e,r.target);const{target:s}=r;delete r.target;const i=a=>a.map(o=>an(o)?Mt(o,t,r,n):o);if(Array.isArray(e))return i(e);for(const[a,o]of Object.entries(e)){const d=t(a,o,e);if(d===sn)continue;let[u,l,{shouldRecurse:f=!0}={}]=d;u!=="__proto__"&&(r.deep&&f&&an(l)&&(l=Array.isArray(l)?i(l):Mt(l,t,r,n)),s[u]=l)}return s};Lt.exports=(e,t,r)=>{if(!nn(e))throw new TypeError(`Expected an object, got \`${e}\` (${typeof e})`);return Mt(e,t,r)},Lt.exports.mapObjectSkip=sn;var on=Lt.exports,It={exports:{}};const ia=e=>{let t=!1,r=!1,n=!1;for(let s=0;s<e.length;s++){const i=e[s];t&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(e=e.slice(0,s)+"-"+e.slice(s),t=!1,n=r,r=!0,s++):r&&n&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(e=e.slice(0,s-1)+"-"+e.slice(s-1),n=r,r=!1,t=!0):(t=i.toLowerCase()===i&&i.toUpperCase()!==i,n=r,r=i.toUpperCase()===i&&i.toLowerCase()!==i)}return e},cn=(e,t)=>{if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");t=Object.assign({pascalCase:!1},t);const r=s=>t.pascalCase?s.charAt(0).toUpperCase()+s.slice(1):s;return Array.isArray(e)?e=e.map(s=>s.trim()).filter(s=>s.length).join("-"):e=e.trim(),e.length===0?"":e.length===1?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=ia(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(s,i)=>i.toUpperCase()).replace(/\d+(\w|$)/g,s=>s.toUpperCase()),r(e))};It.exports=cn,It.exports.default=cn;var aa=It.exports;class oa{constructor(t={}){if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=t.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(t,r){this.cache.set(t,r),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t)){const r=this.oldCache.get(t);return this.oldCache.delete(t),this._set(t,r),r}}set(t,r){return this.cache.has(t)?this.cache.set(t,r):this._set(t,r),this}has(t){return this.cache.has(t)||this.oldCache.has(t)}peek(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t))return this.oldCache.get(t)}delete(t){const r=this.cache.delete(t);return r&&this._size--,this.oldCache.delete(t)||r}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache)yield t;for(const t of this.oldCache){const[r]=t;this.cache.has(r)||(yield t)}}get size(){let t=0;for(const r of this.oldCache.keys())this.cache.has(r)||t++;return this._size+t}}var ca=oa;const un=on,ua=aa,la=ca,da=(e,t)=>e.some(r=>typeof r=="string"?r===t:(r.lastIndex=0,r.test(t))),$t=new la({maxSize:1e5}),ln=e=>typeof e=="object"&&e!==null&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),dn=(e,t)=>{if(!ln(e))return e;t={deep:!1,pascalCase:!1,...t};const{exclude:r,pascalCase:n,stopPaths:s,deep:i}=t,a=new Set(s),o=d=>(u,l)=>{if(i&&ln(l)){const f=d===void 0?u:`${d}.${u}`;a.has(f)||(l=un(l,o(f)))}if(!(r&&da(r,u))){const f=n?`${u}_`:u;if($t.has(f))u=$t.get(f);else{const b=ua(u,{pascalCase:n});u.length<100&&$t.set(f,b),u=b}}return[u,l]};return un(e,o(void 0))};var fa=(e,t)=>Array.isArray(e)?Object.keys(e).map(r=>dn(e[r],t)):dn(e,t),qt,fn;function hn(){return fn||(fn=1,qt=hn()),qt}var $e=function(){return $e=Object.assign||function(t){for(var r,n=1,s=arguments.length;n<s;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},$e.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function ha(e){return e.toLowerCase()}var pa=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],ma=/[^A-Z0-9]+/gi;function Ea(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,n=r===void 0?pa:r,s=t.stripRegexp,i=s===void 0?ma:s,a=t.transform,o=a===void 0?ha:a,d=t.delimiter,u=d===void 0?" ":d,l=pn(pn(e,n,"$1\0$2"),i,"\0"),f=0,b=l.length;l.charAt(f)==="\0";)f++;for(;l.charAt(b-1)==="\0";)b--;return l.slice(f,b).split("\0").map(o).join(u)}function pn(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(n,s){return n.replace(s,r)},e)}function ya(e,t){return t===void 0&&(t={}),Ea(e,$e({delimiter:"."},t))}function ba(e,t){return t===void 0&&(t={}),ya(e,$e({delimiter:"_"},t))}const _a=ls(Object.freeze(Object.defineProperty({__proto__:null,snakeCase:ba},Symbol.toStringTag,{value:"Module"})));var ga=Ra,wa=/\s/,Sa=/(_|-|\.|:)/,Ta=/([a-z][A-Z]|[A-Z][a-z])/;function Ra(e){return wa.test(e)?e.toLowerCase():Sa.test(e)?(va(e)||e).toLowerCase():Ta.test(e)?Ca(e).toLowerCase():e.toLowerCase()}var Aa=/[\W_]+(.|$)/g;function va(e){return e.replace(Aa,function(t,r){return r?" "+r:""})}var Oa=/(.)([A-Z]+)/g;function Ca(e){return e.replace(Oa,function(t,r,n){return r+" "+n.toLowerCase().split("").join(" ")})}var Pa=ga,Ba=xa;function xa(e){return Pa(e).replace(/[\W_]+(.|$)/g,function(t,r){return r?" "+r:""}).trim()}var Na=Ba,ja=Da;function Da(e){return Na(e).replace(/\s/g,"_")}const Ua=on,Ha=ja;var La=function(e,t){return t=Object.assign({deep:!0,exclude:[]},t),Ua(e,function(r,n){return[Ma(t.exclude,r)?r:Ha(r),n]},t)};function Ma(e,t){return e.some(function(r){return typeof r=="string"?r===t:r.test(t)})}var _e={};Object.defineProperty(_e,"__esModule",{value:!0}),_e.BasisTheoryApiError=void 0;function Ia(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class Kt extends Ia(Error){constructor(t,r,n){super(t),this.status=r,this.data=n,this.name="BasisTheoryApiError",Object.setPrototypeOf(this,Kt.prototype)}}_e.BasisTheoryApiError=Kt,Object.defineProperty(m,"__esModule",{value:!0}),m.transformTokenResponseCamelCase=m.transformTokenRequestSnakeCase=m.transformResponseCamelCase=m.transformRequestSnakeCase=m.transformReactorResponseCamelCase=m.transformReactorRequestSnakeCase=m.transformProxyResponseCamelCase=m.transformProxyRequestSnakeCase=m.proxyRaw=m.getRuntime=m.getQueryParams=m.getOSVersion=m.getBrowser=m.errorInterceptor=m.dataExtractor=m.dataAndHeadersExtractor=m.createRequestConfig=m.concatResponseTransformerWithDefault=m.concatRequestTransformerWithDefault=m.buildUserAgentString=m.buildClientUserAgentString=m.assertInit=void 0;var mn=qe(rn),q=qe(fa),En=qe(hn()),$a=_a,ge=qe(La),qa=_e,te=_;function qe(e){return e&&e.__esModule?e:{default:e}}const Ka=e=>{if(e==null)throw new Error("BasisTheory has not yet been properly initialized.");return e};m.assertInit=Ka;const Fa=e=>{if(!(typeof e>"u"))return(0,ge.default)(e,{deep:!0})};m.transformRequestSnakeCase=Fa;const za=e=>e;m.proxyRaw=za;const Wa=e=>{if(!(typeof e>"u"))return{...(0,ge.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorRequestSnakeCase=Wa;const ka=e=>{if(!(typeof e>"u"))return{...(0,ge.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyRequestSnakeCase=ka;const Va=e=>{if(!(typeof e>"u"))return{...(0,ge.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenRequestSnakeCase=Va;const Ft=e=>e&&(e==null?void 0:e.pagination)!==void 0&&(e==null?void 0:e.data)!==void 0,Ga=e=>{if(!(typeof e>"u"))return Ft(e)?{data:e.data.map(n=>({...(0,q.default)(n,{deep:!0}),...n.data!==void 0?{data:n.data}:{},...n.metadata!==void 0?{metadata:n.metadata}:{}})),pagination:(0,q.default)(e.pagination,{deep:!0})}:{...(0,q.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenResponseCamelCase=Ga;const Ja=e=>{if(!(typeof e>"u"))return Ft(e)?{data:e.data.map(n=>({...(0,q.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,q.default)(e.pagination,{deep:!0})}:{...(0,q.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorResponseCamelCase=Ja;const Ya=e=>{if(!(typeof e>"u"))return Ft(e)?{data:e.data.map(n=>({...(0,q.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,q.default)(e.pagination,{deep:!0})}:{...(0,q.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyResponseCamelCase=Ya;const Xa=e=>{if(!(typeof e>"u"))return(0,q.default)(e,{deep:!0})};m.transformResponseCamelCase=Xa;const Za=e=>e==null?void 0:e.data;m.dataExtractor=Za;const Qa=e=>({data:e==null?void 0:e.data,headers:e==null?void 0:e.headers});m.dataAndHeadersExtractor=Qa;const zt=e=>[e,...mn.default.defaults.transformRequest];m.concatRequestTransformerWithDefault=zt;const Wt=e=>[...mn.default.defaults.transformResponse,e];m.concatResponseTransformerWithDefault=Wt;const eo=(e,t)=>{if(!e)return t?{...t.transformRequest!==void 0?{transformRequest:zt(t.transformRequest)}:{},...t.transformResponse!==void 0?{transformResponse:Wt(t.transformResponse)}:{}}:void 0;const{apiKey:r,correlationId:n,idempotencyKey:s,transactionId:i,query:a,headers:o}=e,d=r?{[te.API_KEY_HEADER]:r}:{},u=n?{[te.BT_TRACE_ID_HEADER]:n}:{},l=s?{[te.BT_IDEMPOTENCY_KEY_HEADER]:s}:{},f=i?{[te.BT_TRANSACTION_ID_HEADER]:i}:{};return{headers:{...d,...u,...l,...f,...typeof o<"u"&&{...o}},...typeof a<"u"&&{params:a},...(t==null?void 0:t.transformRequest)!==void 0?{transformRequest:zt(t.transformRequest)}:{},...(t==null?void 0:t.transformResponse)!==void 0?{transformResponse:Wt(t.transformResponse)}:{}}};m.createRequestConfig=eo;const to=e=>{var t,r;const n=((t=e.response)===null||t===void 0?void 0:t.status)||-1,s=(r=e.response)===null||r===void 0?void 0:r.data;throw new qa.BasisTheoryApiError(e.message,n,s)};m.errorInterceptor=to;const ro=(e={})=>{const t=Object.keys(e);if(t.length){const r=new URLSearchParams,n=(s,i,a=!1)=>{const o=typeof i,d=a?s:(0,$a.snakeCase)(s);(i===null||["boolean","number","string"].includes(o))&&r.append(d,i)};return t.forEach(s=>{const i=e[s];Array.isArray(i)?i.forEach(a=>{n(String(s),a)}):i&&typeof i=="object"?Object.keys(i).forEach(o=>{n(`${String(s)}.${o}`,i[o],!0)}):n(String(s),i)}),`?${r.toString()}`}return""};m.getQueryParams=ro;const no=e=>`(${e.name||""}; ${e.version||""}; ${e.url||""})`,so=e=>{let t=`${te.USER_AGENT_CLIENT}/unknown`;return e&&Object.keys(e||{}).length&&(t+=` ${no(e)}`),t};m.buildUserAgentString=so;const yn=()=>{const{userAgent:e}=window.navigator;let t="unknown";const r=te.BROWSER_LIST.find(n=>e.includes(n.browserUA));if(r)try{t=e.split(`${r.browserUA}/`)[1]}catch{t="unknown"}return`${(r==null?void 0:r.browserName)||"unknown"}/${t}`};m.getBrowser=yn;const bn=()=>typeof window=="object"&&window.navigator.product==="ReactNative",_n=()=>{if(bn())return"ReactNative";if(typeof window>"u")try{return`${En.default.type()}/${En.default.version()}`}catch{return"unknown"}try{const t=window.navigator.appVersion.match(/\(([^)]+)\)/u);return t&&t.length>1?t[1]:"unknown"}catch{return"unknown"}};m.getOSVersion=_n;const gn=()=>bn()?"ReactNative":typeof window>"u"?`NodeJS/${process.version}`:yn();m.getRuntime=gn;const io=e=>{const t={client:te.USER_AGENT_CLIENT,clientVersion:"unknown",osVersion:_n(),runtimeVersion:gn(),application:{}};return e&&(t.application=e),JSON.stringify((0,ge.default)(t))};m.buildClientUserAgentString=io;var Ke={};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.BasisTheoryValidationError=void 0;function ao(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class kt extends ao(Error){constructor(t,r,n){super(t),this.details=r,this.validation=n,this.name="BasisTheoryValidationError",Object.setPrototypeOf(this,kt.prototype)}}Ke.BasisTheoryValidationError=kt;var Fe={};Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.HttpClientError=void 0;function oo(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class Vt extends oo(Error){constructor(t,r,n,s){super(t),this.name="HttpClientError",this.status=r,this.data=n,this.headers=s,Object.setPrototypeOf(this,Vt.prototype)}}Fe.HttpClientError=Vt,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={BasisTheoryApiError:!0,BasisTheoryValidationError:!0,HttpClientError:!0};Object.defineProperty(e,"BasisTheoryApiError",{enumerable:!0,get:function(){return s.BasisTheoryApiError}}),Object.defineProperty(e,"BasisTheoryValidationError",{enumerable:!0,get:function(){return i.BasisTheoryValidationError}}),Object.defineProperty(e,"HttpClientError",{enumerable:!0,get:function(){return a.HttpClientError}});var r=_;Object.keys(r).forEach(function(o){o==="default"||o==="__esModule"||Object.prototype.hasOwnProperty.call(t,o)||o in e&&e[o]===r[o]||Object.defineProperty(e,o,{enumerable:!0,get:function(){return r[o]}})});var n=m;Object.keys(n).forEach(function(o){o==="default"||o==="__esModule"||Object.prototype.hasOwnProperty.call(t,o)||o in e&&e[o]===n[o]||Object.defineProperty(e,o,{enumerable:!0,get:function(){return n[o]}})});var s=_e,i=Ke,a=Fe}(D);var H={},co={},ze={};Object.defineProperty(ze,"__esModule",{value:!0}),ze.BasisTheoryService=void 0;var We=uo(rn),J=D;function uo(e){return e&&e.__esModule?e:{default:e}}class lo{constructor(t){const{apiKey:r,baseURL:n,transformRequest:s,transformResponse:i,appInfo:a}=t;if(typeof We.default=="string")throw new Error("basis-theory-js@1.77.0+ and basis-theory-react@1.12.1+ are not supported with CRA 5, go to https://github.com/Basis-Theory/basis-theory-js/issues/365#issuecomment-1662883062 for workarounds.");this.client=We.default.create({baseURL:n,headers:{[J.API_KEY_HEADER]:r,[J.CLIENT_USER_AGENT_HEADER]:(0,J.buildClientUserAgentString)(a),...typeof window>"u"&&{[J.USER_AGENT_HEADER]:(0,J.buildUserAgentString)(a)}},transformRequest:[].concat(s||J.transformRequestSnakeCase,We.default.defaults.transformRequest),transformResponse:We.default.defaults.transformResponse.concat(i||J.transformResponseCamelCase)}),this.client.interceptors.response.use(void 0,J.errorInterceptor)}}ze.BasisTheoryService=lo,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=co;Object.keys(t).forEach(function(n){n==="default"||n==="__esModule"||n in e&&e[n]===t[n]||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var r=ze;Object.keys(r).forEach(function(n){n==="default"||n==="__esModule"||n in e&&e[n]===r[n]||Object.defineProperty(e,n,{enumerable:!0,get:function(){return r[n]}})})}(H),Object.defineProperty(Oe,"__esModule",{value:!0}),Oe.BasisTheoryTransactions=void 0;var Gt=D,we=m,fo=H;class ho extends fo.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(we.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(we.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,Gt.createRequestConfig)(t)).then(we.dataExtractor)}commit(t,r={}){const n=`/${t}/commit`;return this.client.post(n,void 0,(0,Gt.createRequestConfig)(r)).then(we.dataExtractor)}rollback(t,r={}){const n=`/${t}/rollback`;return this.client.post(n,void 0,(0,Gt.createRequestConfig)(r)).then(we.dataExtractor)}}Oe.BasisTheoryTransactions=ho,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Oe;Object.keys(t).forEach(function(r){r==="default"||r==="__esModule"||r in e&&e[r]===t[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(yr);var Jt={},ke={},K={};Object.defineProperty(K,"__esModule",{value:!0}),K.CrudBuilder=void 0;var x=D;const po=e=>class extends e{create(r,n){return this.client.post("/",r,(0,x.createRequestConfig)(n)).then(x.dataExtractor)}},mo=e=>class extends e{retrieve(r,n){return this.client.get(r,(0,x.createRequestConfig)(n)).then(x.dataExtractor)}},Eo=e=>class extends e{update(r,n,s){return this.client.put(r,n,(0,x.createRequestConfig)(s)).then(x.dataExtractor)}},yo=e=>class extends e{patch(r,n,s){const i=(0,x.createRequestConfig)(s);return this.client.patch(r,n,{...i,headers:{...(i==null?void 0:i.headers)||{},[x.CONTENT_TYPE_HEADER]:x.MERGE_CONTENT_TYPE}}).then(x.dataExtractor)}},bo=e=>class extends e{async delete(r,n){await this.client.delete(r,(0,x.createRequestConfig)(n))}},_o=e=>class extends e{list(r={},n={}){const s=`/${(0,x.getQueryParams)(r)}`;return this.client.get(s,(0,x.createRequestConfig)(n)).then(x.dataExtractor)}};class go{constructor(t){this.BaseService=t}create(){return this.BaseService=po(this.BaseService),this}retrieve(){return this.BaseService=mo(this.BaseService),this}update(){return this.BaseService=Eo(this.BaseService),this}patch(){return this.BaseService=yo(this.BaseService),this}delete(){return this.BaseService=bo(this.BaseService),this}list(){return this.BaseService=_o(this.BaseService),this}build(){return this.BaseService}}K.CrudBuilder=go,Object.defineProperty(ke,"__esModule",{value:!0}),ke.BasisTheoryApplications=void 0;var Ve=D,wo=H,So=K;const To=new So.CrudBuilder(class extends wo.BasisTheoryService{getApplicationByKey(){return this.retrieveByKey()}retrieveByKey(t){return this.client.get("/key",(0,Ve.createRequestConfig)(t)).then(Ve.dataExtractor)}regenerateKey(t,r){return this.client.post(`${t}/regenerate`,void 0,(0,Ve.createRequestConfig)(r)).then(Ve.dataExtractor)}}).create().retrieve().update().delete().list().build();ke.BasisTheoryApplications=To,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryApplications",{enumerable:!0,get:function(){return t.BasisTheoryApplications}});var t=ke}(Jt);var wn={},Sn={},Ge={},Tn={},Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.BasisTheoryTokenize=void 0;var Ye=D,Ro=H;class Ao extends Ro.BasisTheoryService{tokenize(t,r={}){return this.client.post("/",t,(0,Ye.createRequestConfig)(r,{transformRequest:Ye.proxyRaw,transformResponse:Ye.proxyRaw})).then(Ye.dataExtractor)}}Je.BasisTheoryTokenize=Ao,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokenize",{enumerable:!0,get:function(){return t.BasisTheoryTokenize}});var t=Je}(Tn),Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.delegateTokenize=void 0;var vo=Tn;const Oo=e=>class extends vo.BasisTheoryTokenize{tokenize(r,n){return e!=null&&e.hasElement(r)?e.tokenize(r,n):super.tokenize(r,n)}};Ge.delegateTokenize=Oo;var Xe={},Yt={},Ze={};Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.BasisTheoryTokens=void 0;var F=D,re=m,Co=H,Po=K;const Bo=new Po.CrudBuilder(class extends Co.BasisTheoryService{constructor(t){const r=t;r.transformRequest=[].concat(re.transformTokenRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(re.transformTokenResponseCamelCase,t.transformResponse||[]),super(r)}retrieve(t,r={}){const n=`/${t}`;return this.client.get(n,(0,F.createRequestConfig)(r)).then(re.dataExtractor)}update(t,r,n={}){const s=`/${t}`,i=(0,F.createRequestConfig)(n);return this.client.patch(s,r,{...i,headers:{...(i==null?void 0:i.headers)||{},[F.CONTENT_TYPE_HEADER]:F.MERGE_CONTENT_TYPE}}).then(re.dataExtractor)}async createAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.post(s,{},(0,F.createRequestConfig)(n))}async deleteAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.delete(s,(0,F.createRequestConfig)(n))}createChild(t,r,n){const s=`/${t}/children`;return this.client.post(s,r,(0,F.createRequestConfig)(n)).then(re.dataExtractor)}listChildren(t,r={},n={}){const s=`/${t}/children${(0,F.getQueryParams)(r)}`;return this.client.get(s,(0,F.createRequestConfig)(n)).then(re.dataExtractor)}search(t,r){return this.client.post("/search",t,(0,F.createRequestConfig)(r)).then(re.dataExtractor)}}).create().delete().list().build();Ze.BasisTheoryTokens=Bo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokens",{enumerable:!0,get:function(){return t.BasisTheoryTokens}});var t=Ze}(Yt),Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.delegateTokens=void 0;var xo=Yt;const No=e=>class extends xo.BasisTheoryTokens{create(r,n){return e!=null&&e.hasElement(r)?e.tokens.create(r,n):super.create(r,n)}update(r,n,s){return e!=null&&e.hasElement(n)?e.tokens.update(r,n,s):super.update(r,n,s)}retrieve(r,n){return e!==void 0?e.tokens.retrieve(r,n):super.retrieve(r,n)}};Xe.delegateTokens=No;var Qe={},Rn={},et={};Object.defineProperty(et,"__esModule",{value:!0}),et.BasisTheoryProxy=void 0;var k=D,jo=H;class Do extends jo.BasisTheoryService{get(t){return this.proxyRequest("get",t)}post(t){return this.proxyRequest("post",t)}put(t){return this.proxyRequest("put",t)}patch(t){return this.proxyRequest("patch",t)}delete(t){return this.proxyRequest("delete",t)}proxyRequest(t,r){var n;if(t==="post"||t==="put"||t==="patch"){var s,i;const a=r!=null&&r.includeResponseHeaders&&t==="post"?k.dataAndHeadersExtractor:k.dataExtractor;return this.client[t]((s=r==null?void 0:r.path)!==null&&s!==void 0?s:"",(i=r==null?void 0:r.body)!==null&&i!==void 0?i:void 0,(0,k.createRequestConfig)(r,{transformRequest:k.proxyRaw,transformResponse:k.proxyRaw})).then(a)}return this.client[t]((n=r==null?void 0:r.path)!==null&&n!==void 0?n:"/",(0,k.createRequestConfig)(r,{transformRequest:k.proxyRaw,transformResponse:k.proxyRaw})).then(k.dataExtractor)}}et.BasisTheoryProxy=Do,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=et;Object.keys(t).forEach(function(r){r==="default"||r==="__esModule"||r in e&&e[r]===t[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(Rn),Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.delegateProxy=void 0;var Uo=Rn;const Ho=e=>class extends Uo.BasisTheoryProxy{get(r){return e!==void 0?e.proxy.get(r):super.get(r)}post(r){return e!==void 0?e.proxy.post(r):super.post(r)}put(r){return e!==void 0?e.proxy.put(r):super.put(r)}patch(r){return e!==void 0?e.proxy.patch(r):super.patch(r)}delete(r){return e!==void 0?e.proxy.delete(r):super.delete(r)}};Qe.delegateProxy=Ho,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ge;Object.keys(t).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===t[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return t[s]}})});var r=Xe;Object.keys(r).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===r[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return r[s]}})});var n=Qe;Object.keys(n).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===n[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return n[s]}})})}(Sn);var ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.injectScript=ne.findScript=void 0;const Lo=e=>document.querySelector(`script[src^="${e}"]`);ne.findScript=Lo;const Mo=e=>{const t=document.createElement("script");t.src=e;const r=document.head||document.body;if(!r)throw new Error("No <head> or <body> elements found in document.");return r.append(t),t};ne.injectScript=Mo;var tt={},P={};Object.defineProperty(P,"__esModule",{value:!0}),P.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=P.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=P.ELEMENTS_NOM_DOM_ERROR_MESSAGE=P.ELEMENTS_INIT_ERROR_MESSAGE=P.CARD_ICON_POSITIONS=P.CARD_BRANDS=P.AUTOCOMPLETE_VALUES=void 0;const Io="BasisTheory Elements was not properly initialized.";P.ELEMENTS_INIT_ERROR_MESSAGE=Io;const $o="Tried to load BasisTheoryElements in a non-DOM environment.";P.ELEMENTS_NOM_DOM_ERROR_MESSAGE=$o;const qo="Basis Theory Elements did not load properly.";P.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=qo;const Ko="There was an unknown error when loading Basis Theory Elements. Check the console for details.";P.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=Ko;const Fo=["visa","mastercard","american-express","discover","diners-club","jcb","unionpay","maestro","elo","hiper","hipercard","mir","unknown"];P.CARD_BRANDS=Fo;const zo=["left","right","none"];P.CARD_ICON_POSITIONS=zo;const Wo=["off","on"];P.AUTOCOMPLETE_VALUES=Wo,Object.defineProperty(tt,"__esModule",{value:!0}),tt.loadElements=void 0;var Xt=P,An=ne;let Zt;const ko=e=>(Zt||(Zt=new Promise((t,r)=>{if(typeof window!="object"){r(new Error(Xt.ELEMENTS_NOM_DOM_ERROR_MESSAGE));return}if(window.BasisTheoryElements){t(window.BasisTheoryElements);return}try{let n="https://js.basistheory.com/elements";if(typeof e<"u")try{n=new URL(e).toString().replace(/\/$/u,"")}catch{throw new Error("Invalid format for the given Elements client url.")}let s=(0,An.findScript)(n);s||(s=(0,An.injectScript)(n)),s.addEventListener("load",()=>{window.BasisTheoryElements?t(window.BasisTheoryElements):r(new Error(Xt.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE))}),s.addEventListener("error",i=>{r((i==null?void 0:i.error)||new Error(Xt.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE))})}catch(n){r(n);return}})),Zt);tt.loadElements=ko,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Sn;Object.keys(t).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===t[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return t[s]}})});var r=ne;Object.keys(r).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===r[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return r[s]}})});var n=tt;Object.keys(n).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===n[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return n[s]}})})}(wn);var vn={},rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.BasisTheoryLogs=void 0;var Vo=H,Go=K;const Jo=new Go.CrudBuilder(class extends Vo.BasisTheoryService{}).list().build();rt.BasisTheoryLogs=Jo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryLogs",{enumerable:!0,get:function(){return t.BasisTheoryLogs}});var t=rt}(vn);var On={},nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.BasisTheoryPermissions=void 0;var Cn=D,Yo=H;class Xo extends Yo.BasisTheoryService{list(t){return this.client.get("/",(0,Cn.createRequestConfig)(t)).then(Cn.dataExtractor)}}nt.BasisTheoryPermissions=Xo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryPermissions",{enumerable:!0,get:function(){return t.BasisTheoryPermissions}});var t=nt}(On);var Pn={},st={};Object.defineProperty(st,"__esModule",{value:!0}),st.BasisTheoryProxies=void 0;var Bn=m,Zo=H,Qo=K;const ec=new Qo.CrudBuilder(class extends Zo.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(Bn.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(Bn.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}}).create().retrieve().update().patch().delete().list().build();st.BasisTheoryProxies=ec,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=st;Object.keys(t).forEach(function(r){r==="default"||r==="__esModule"||r in e&&e[r]===t[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(Pn);var xn={},it={};Object.defineProperty(it,"__esModule",{value:!0}),it.BasisTheoryReactorFormulas=void 0;var tc=H,rc=K;const nc=new rc.CrudBuilder(class extends tc.BasisTheoryService{}).create().retrieve().update().delete().list().build();it.BasisTheoryReactorFormulas=nc,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactorFormulas",{enumerable:!0,get:function(){return t.BasisTheoryReactorFormulas}});var t=it}(xn);var Nn={},at={};Object.defineProperty(at,"__esModule",{value:!0}),at.BasisTheoryReactors=void 0;var ot=D,jn=m,sc=H,ic=K;const ac=new ic.CrudBuilder(class extends sc.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(jn.transformReactorRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(jn.transformReactorResponseCamelCase,t.transformResponse||[]),super(r)}react(t,r,n){return this.client.post(`/${t}/react`,r,(0,ot.createRequestConfig)(n,{transformRequest:ot.proxyRaw,transformResponse:ot.proxyRaw})).then(ot.dataExtractor)}}).create().retrieve().update().patch().delete().list().build();at.BasisTheoryReactors=ac,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactors",{enumerable:!0,get:function(){return t.BasisTheoryReactors}});var t=at}(Nn);var Dn={},ct={};Object.defineProperty(ct,"__esModule",{value:!0}),ct.BasisTheorySessions=void 0;var Un=D,ut=m,oc=H;class cc extends oc.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(ut.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(ut.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,Un.createRequestConfig)(t)).then(ut.dataExtractor)}authorize(t,r={}){return this.client.post("/authorize",t,(0,Un.createRequestConfig)(r)).then(ut.dataExtractor)}}ct.BasisTheorySessions=cc,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheorySessions",{enumerable:!0,get:function(){return t.BasisTheorySessions}});var t=ct}(Dn);var Hn={},lt={};Object.defineProperty(lt,"__esModule",{value:!0}),lt.BasisTheoryTenants=void 0;var R=D,uc=H,lc=K;const dc=new lc.CrudBuilder(class extends uc.BasisTheoryService{retrieve(t){return this.client.get("/",(0,R.createRequestConfig)(t)).then(R.dataExtractor)}update(t,r){return this.client.put("/",t,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}async delete(t){await this.client.delete("/",(0,R.createRequestConfig)(t))}retrieveUsageReport(t){return this.client.get("/reports/usage",(0,R.createRequestConfig)(t)).then(R.dataExtractor)}createInvitation(t,r){return this.client.post("/invitations",t,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}resendInvitation(t,r){return this.client.post(`/invitations/${t}/resend`,{},(0,R.createRequestConfig)(r)).then(R.dataExtractor)}listInvitations(t,r){const n=`/invitations${(0,R.getQueryParams)(t)}`;return this.client.get(n,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}retrieveInvitation(t,r){return this.client.get(`/invitations/${t}`,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}async deleteInvitation(t,r){await this.client.delete(`/invitations/${t}`,(0,R.createRequestConfig)(r))}listMembers(t,r){const n=`/members${(0,R.getQueryParams)(t)}`;return this.client.get(n,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}async deleteMember(t,r){await this.client.delete(`/members/${t}`,(0,R.createRequestConfig)(r))}}).build();lt.BasisTheoryTenants=dc,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTenants",{enumerable:!0,get:function(){return t.BasisTheoryTenants}});var t=lt}(Hn),Object.defineProperty(ve,"__esModule",{value:!0}),ve.BasisTheory=void 0;var Se=ce,fc=yr,hc=Jt,g=D,dt=wn,pc=P,mc=vn,Ec=On,yc=Pn,bc=xn,_c=Nn,gc=Dn,wc=Hn;function Sc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Tc={apiBaseUrl:g.DEFAULT_BASE_URL,elements:!1,appInfo:{}};class Rc{constructor(){Sc(this,"_initStatus","not-started")}async init(t,r={}){if(this._initStatus!=="not-started"&&this._initStatus!=="error")throw new Error("This BasisTheory instance has been already initialized.");this._initStatus="in-progress";try{this._initOptions=Object.freeze({...Tc,...r});let n=this._initOptions.apiBaseUrl;try{const i=new URL(this.initOptions.apiBaseUrl);i.hostname==="localhost"?i.protocol="http":i.protocol="https",n=i.toString().replace(/\/$/u,"")}catch{throw new Error("Invalid format for the given API base url.")}const s=this._initOptions.appInfo;this._initOptions.elements&&await this.loadElements(t),this._tokens=new((0,dt.delegateTokens)(this._elements))({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.tokens,n).toString(),appInfo:s}),this._tokenize=new((0,dt.delegateTokenize)(this._elements))({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.tokenize,n).toString(),appInfo:s}),this._applications=new hc.BasisTheoryApplications({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.applications,n).toString(),appInfo:s}),this._tenants=new wc.BasisTheoryTenants({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.tenants,n).toString(),appInfo:s}),this._logs=new mc.BasisTheoryLogs({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.logs,n).toString(),appInfo:s}),this._reactorFormulas=new bc.BasisTheoryReactorFormulas({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.reactorFormulas,n).toString(),appInfo:s}),this._reactors=new _c.BasisTheoryReactors({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.reactors,n).toString(),appInfo:s}),this._permissions=new Ec.BasisTheoryPermissions({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.permissions,n).toString(),appInfo:s}),this._proxies=new yc.BasisTheoryProxies({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.proxies,n).toString(),appInfo:s}),this._proxy=new((0,dt.delegateProxy)(this._elements))({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.proxy,n).toString(),appInfo:s}),this._sessions=new gc.BasisTheorySessions({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.sessions,n).toString(),appInfo:s}),this._transactions=new fc.BasisTheoryTransactions({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.transactions,n).toString(),appInfo:s}),this._initStatus="done"}catch(n){throw this._initStatus="error",n}return this}createElement(t,r){if(!this._elements)throw new Error(pc.ELEMENTS_INIT_ERROR_MESSAGE);return this._elements.createElement(t,r)}tokenize(t,r){return(0,g.assertInit)(this._tokenize).tokenize(t,r)}post(t,r,n){return(0,Se.makeRequestWithElementsPayloadCheck)(this._elements,"post",t,r,n)}put(t,r,n){return(0,Se.makeRequestWithElementsPayloadCheck)(this._elements,"put",t,r,n)}patch(t,r,n){return(0,Se.makeRequestWithElementsPayloadCheck)(this._elements,"patch",t,r,n)}get(t,r){return(0,Se.makeRequestWithoutElementsPayloadCheck)(this._elements,"get",t,r)}delete(t,r){return(0,Se.makeRequestWithoutElementsPayloadCheck)(this._elements,"delete",t,r)}async loadElements(t){let r;try{r=new URL(this.initOptions.elementsBaseUrl||g.DEFAULT_ELEMENTS_BASE_URL)}catch{throw new Error("Invalid format for the given Elements base url.")}const n=await(0,dt.loadElements)(this.initOptions.elementsClientUrl);await n.init(t,r.toString().replace(/\/$/u,"")),this.elements=n}get initOptions(){return(0,g.assertInit)(this._initOptions)}get tokens(){return(0,g.assertInit)(this._tokens)}get applications(){return(0,g.assertInit)(this._applications)}get tenants(){return(0,g.assertInit)(this._tenants)}get logs(){return(0,g.assertInit)(this._logs)}get reactorFormulas(){return(0,g.assertInit)(this._reactorFormulas)}get reactors(){return(0,g.assertInit)(this._reactors)}get permissions(){return(0,g.assertInit)(this._permissions)}get proxies(){return(0,g.assertInit)(this._proxies)}get proxy(){return(0,g.assertInit)(this._proxy)}get sessions(){return(0,g.assertInit)(this._sessions)}get transactions(){return(0,g.assertInit)(this._transactions)}get elements(){return(0,g.assertInit)(this._elements)}set elements(t){this._elements=t}}ve.BasisTheory=Rc,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={_instance:!0};e._instance=void 0;var r=ve;Object.keys(r).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in e&&e[a]===r[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[a]}})});var n=Jt;Object.keys(n).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in e&&e[a]===n[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return n[a]}})});var s=Yt;Object.keys(s).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in e&&e[a]===s[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return s[a]}})});const i=new r.BasisTheory;e._instance=i}(mr);const T=crypto,z=e=>e instanceof CryptoKey,Ac=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await T.subtle.digest(r,t))},se=new TextEncoder,Ln=new TextDecoder,ft=2**32;function Te(...e){const t=e.reduce((s,{length:i})=>s+i,0),r=new Uint8Array(t);let n=0;for(const s of e)r.set(s,n),n+=s.length;return r}function vc(e,t){return Te(se.encode(e),new Uint8Array([0]),t)}function Qt(e,t,r){if(t<0||t>=ft)throw new RangeError(`value must be >= 0 and <= ${ft-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function Oc(e){const t=Math.floor(e/ft),r=e%ft,n=new Uint8Array(8);return Qt(n,t,0),Qt(n,r,4),n}function er(e){const t=new Uint8Array(4);return Qt(t,e),t}function tr(e){return Te(er(e.length),e)}async function Cc(e,t,r){const n=Math.ceil((t>>3)/32),s=new Uint8Array(n*32);for(let i=0;i<n;i++){const a=new Uint8Array(4+e.length+r.length);a.set(er(i+1)),a.set(e,4),a.set(r,4+e.length),s.set(await Ac("sha256",a),i*32)}return s.slice(0,t>>3)}const Pc=e=>{let t=e;typeof t=="string"&&(t=se.encode(t));const r=32768,n=[];for(let s=0;s<t.length;s+=r)n.push(String.fromCharCode.apply(null,t.subarray(s,s+r)));return btoa(n.join(""))},L=e=>Pc(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Bc=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r},Mn=e=>{let t=e;t instanceof Uint8Array&&(t=Ln.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Bc(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class In extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(t){var r;super(t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(r=Error.captureStackTrace)==null||r.call(Error,this,this.constructor)}}class N extends In{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class Y extends In{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}const rr=T.getRandomValues.bind(T);function $n(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new N(`Unsupported JWE Algorithm: ${e}`)}}const xc=e=>rr(new Uint8Array($n(e)>>3)),Nc=(e,t)=>{if(t.length<<3!==$n(e))throw new Y("Invalid Initialization Vector length")},qn=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new Y(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function X(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function ht(e,t){return e.name===t}function jc(e){return parseInt(e.name.slice(4),10)}function Dc(e,t){if(t.length&&!t.some(r=>e.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const n=t.pop();r+=`one of ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of ${t[0]} or ${t[1]}.`:r+=`${t[0]}.`;throw new TypeError(r)}}function de(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!ht(e.algorithm,"AES-GCM"))throw X("AES-GCM");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw X(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!ht(e.algorithm,"AES-KW"))throw X("AES-KW");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw X(n,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw X("ECDH, X25519, or X448")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!ht(e.algorithm,"PBKDF2"))throw X("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!ht(e.algorithm,"RSA-OAEP"))throw X("RSA-OAEP");const n=parseInt(t.slice(9),10)||1;if(jc(e.algorithm.hash)!==n)throw X(`SHA-${n}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}Dc(e,r)}function Kn(e,t,...r){var n;if(r.length>2){const s=r.pop();e+=`one of type ${r.join(", ")}, or ${s}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&(n=t.constructor)!=null&&n.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const W=(e,...t)=>Kn("Key must be ",e,...t);function Fn(e,t,...r){return Kn(`Key for the ${e} algorithm must be `,t,...r)}const zn=e=>z(e)?!0:(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",$=["CryptoKey"],Uc=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(const n of t){const s=Object.keys(n);if(!r||r.size===0){r=new Set(s);continue}for(const i of s){if(r.has(i))return!1;r.add(i)}}return!0};function Hc(e){return typeof e=="object"&&e!==null}function Lc(e){if(!Hc(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}const Wn=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function Mc(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function Ic(e,t,r){if(z(e))return de(e,t,r),e;if(e instanceof Uint8Array)return T.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError(W(e,...$,"Uint8Array"))}const nr=async(e,t,r)=>{const n=await Ic(t,e,"wrapKey");Mc(n,e);const s=await T.subtle.importKey("raw",r,...Wn);return new Uint8Array(await T.subtle.wrapKey("raw",s,n,"AES-KW"))};async function $c(e,t,r,n,s=new Uint8Array(0),i=new Uint8Array(0)){if(!z(e))throw new TypeError(W(e,...$));if(de(e,"ECDH"),!z(t))throw new TypeError(W(t,...$));de(t,"ECDH","deriveBits");const a=Te(tr(se.encode(r)),tr(s),tr(i),er(n));let o;e.algorithm.name==="X25519"?o=256:e.algorithm.name==="X448"?o=448:o=Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3;const d=new Uint8Array(await T.subtle.deriveBits({name:e.algorithm.name,public:e},t,o));return Cc(d,n,a)}async function qc(e){if(!z(e))throw new TypeError(W(e,...$));return T.subtle.generateKey(e.algorithm,!0,["deriveBits"])}function Kc(e){if(!z(e))throw new TypeError(W(e,...$));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||e.algorithm.name==="X25519"||e.algorithm.name==="X448"}function Fc(e){if(!(e instanceof Uint8Array)||e.length<8)throw new Y("PBES2 Salt Input must be 8 or more octets")}function zc(e,t){if(e instanceof Uint8Array)return T.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if(z(e))return de(e,t,"deriveBits","deriveKey"),e;throw new TypeError(W(e,...$,"Uint8Array"))}async function Wc(e,t,r,n){Fc(e);const s=vc(t,e),i=parseInt(t.slice(13,16),10),a={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:s},o={length:i,name:"AES-KW"},d=await zc(n,t);if(d.usages.includes("deriveBits"))return new Uint8Array(await T.subtle.deriveBits(a,d,i));if(d.usages.includes("deriveKey"))return T.subtle.deriveKey(a,d,o,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}const kc=async(e,t,r,n=2048,s=rr(new Uint8Array(16)))=>{const i=await Wc(s,e,n,t);return{encryptedKey:await nr(e.slice(-6),i,r),p2c:n,p2s:L(s)}};function kn(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new N(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}const Vc=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}},Gc=async(e,t,r)=>{if(!z(t))throw new TypeError(W(t,...$));if(de(t,e,"encrypt","wrapKey"),Vc(e,t),t.usages.includes("encrypt"))return new Uint8Array(await T.subtle.encrypt(kn(e),t,r));if(t.usages.includes("wrapKey")){const n=await T.subtle.importKey("raw",r,...Wn);return new Uint8Array(await T.subtle.wrapKey("raw",n,t,kn(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')};function Jc(e){let t,r;switch(e.kty){case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(e.alg){case"EdDSA":t={name:e.crv},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new N('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}const Vn=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=Jc(e),n=[t,e.ext??!1,e.key_ops??r],s={...e};return delete s.alg,delete s.use,T.subtle.importKey("jwk",s,...n)},Gn=e=>Mn(e);let sr,ir;const Jn=e=>(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",Yn=async(e,t,r,n)=>{let s=e.get(t);if(s!=null&&s[n])return s[n];const i=await Vn({...r,alg:n});return s?s[n]=i:e.set(t,{[n]:i}),i},ar={normalizePublicKey:(e,t)=>{if(Jn(e)){let r=e.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?Gn(r.k):(ir||(ir=new WeakMap),Yn(ir,e,r,t))}return e},normalizePrivateKey:(e,t)=>{if(Jn(e)){let r=e.export({format:"jwk"});return r.k?Gn(r.k):(sr||(sr=new WeakMap),Yn(sr,e,r,t))}return e}};function Xn(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new N(`Unsupported JWE Algorithm: ${e}`)}}const Re=e=>rr(new Uint8Array(Xn(e)>>3));async function Yc(e,t){if(!Lc(e))throw new TypeError("JWK must be an object");switch(e.kty){case"oct":if(typeof e.k!="string"||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return Mn(e.k);case"RSA":if(e.oth!==void 0)throw new N('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return Vn({...e,alg:t});default:throw new N('Unsupported "kty" (Key Type) Parameter value')}}const pt=e=>e==null?void 0:e[Symbol.toStringTag],Xc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!zn(t))throw new TypeError(Fn(e,t,...$,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${pt(t)} instances for symmetric algorithms must be of type "secret"`)}},Zc=(e,t,r)=>{if(!zn(t))throw new TypeError(Fn(e,t,...$));if(t.type==="secret")throw new TypeError(`${pt(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${pt(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${pt(t)} instances for asymmetric algorithm encryption must be of type "public"`)},Qc=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?Xc(e,t):Zc(e,t,r)};async function eu(e,t,r,n,s){if(!(r instanceof Uint8Array))throw new TypeError(W(r,"Uint8Array"));const i=parseInt(e.slice(1,4),10),a=await T.subtle.importKey("raw",r.subarray(i>>3),"AES-CBC",!1,["encrypt"]),o=await T.subtle.importKey("raw",r.subarray(0,i>>3),{hash:`SHA-${i<<1}`,name:"HMAC"},!1,["sign"]),d=new Uint8Array(await T.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),u=Te(s,n,d,Oc(s.length<<3)),l=new Uint8Array((await T.subtle.sign("HMAC",o,u)).slice(0,i>>3));return{ciphertext:d,tag:l,iv:n}}async function tu(e,t,r,n,s){let i;r instanceof Uint8Array?i=await T.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(de(r,e,"encrypt"),i=r);const a=new Uint8Array(await T.subtle.encrypt({additionalData:s,iv:n,name:"AES-GCM",tagLength:128},i,t)),o=a.slice(-16);return{ciphertext:a.slice(0,-16),tag:o,iv:n}}const Zn=async(e,t,r,n,s)=>{if(!z(r)&&!(r instanceof Uint8Array))throw new TypeError(W(r,...$,"Uint8Array"));switch(n?Nc(e,n):n=xc(e),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&qn(r,parseInt(e.slice(-3),10)),eu(e,t,r,n,s);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&qn(r,parseInt(e.slice(1,4),10)),tu(e,t,r,n,s);default:throw new N("Unsupported JWE Content Encryption Algorithm")}};async function ru(e,t,r,n){const s=e.slice(0,7),i=await Zn(s,r,t,n,new Uint8Array(0));return{encryptedKey:i.ciphertext,iv:L(i.iv),tag:L(i.tag)}}function nu(e,t,r,n,s){if(s.crit!==void 0&&(n==null?void 0:n.crit)===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(a=>typeof a!="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;r!==void 0?i=new Map([...Object.entries(r),...t.entries()]):i=t;for(const a of n.crit){if(!i.has(a))throw new N(`Extension Header Parameter "${a}" is not recognized`);if(s[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(i.get(a)&&n[a]===void 0)throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return new Set(n.crit)}const su=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:L(e)};if(!z(e))throw new TypeError(W(e,...$,"Uint8Array"));if(!e.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:t,key_ops:r,alg:n,use:s,...i}=await T.subtle.exportKey("jwk",e);return i};async function iu(e){return su(e)}async function au(e,t,r,n,s={}){var d;let i,a,o;switch(Qc(e,r,"encrypt"),r=await((d=ar.normalizePublicKey)==null?void 0:d.call(ar,r,e))||r,e){case"dir":{o=r;break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!Kc(r))throw new N("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:u,apv:l}=s;let{epk:f}=s;f||(f=(await qc(r)).privateKey);const{x:b,y:w,crv:h,kty:E}=await iu(f),p=await $c(r,f,e==="ECDH-ES"?t:e,e==="ECDH-ES"?Xn(t):parseInt(e.slice(-5,-2),10),u,l);if(a={epk:{x:b,crv:h,kty:E}},E==="EC"&&(a.epk.y=w),u&&(a.apu=L(u)),l&&(a.apv=L(l)),e==="ECDH-ES"){o=p;break}o=n||Re(t);const S=e.slice(-6);i=await nr(S,p,o);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{o=n||Re(t),i=await Gc(e,r,o);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{o=n||Re(t);const{p2c:u,p2s:l}=s;({encryptedKey:i,...a}=await kc(e,r,o,u,l));break}case"A128KW":case"A192KW":case"A256KW":{o=n||Re(t),i=await nr(e,r,o);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{o=n||Re(t);const{iv:u}=s;({encryptedKey:i,...a}=await ru(e,r,o,u));break}default:throw new N('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:o,encryptedKey:i,parameters:a}}const ou=Symbol();class cu{constructor(t){if(!(t instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=t}setKeyManagementParameters(t){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=t,this}setProtectedHeader(t){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=t,this}setSharedUnprotectedHeader(t){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=t,this}setUnprotectedHeader(t){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=t,this}setAdditionalAuthenticatedData(t){return this._aad=t,this}setContentEncryptionKey(t){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=t,this}setInitializationVector(t){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=t,this}async encrypt(t,r){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new Y("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!Uc(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new Y("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(nu(Y,new Map,r==null?void 0:r.crit,this._protectedHeader,n),n.zip!==void 0)throw new N('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:s,enc:i}=n;if(typeof s!="string"||!s)throw new Y('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof i!="string"||!i)throw new Y('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let a;if(this._cek&&(s==="dir"||s==="ECDH-ES"))throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${s}`);let o;{let E;({cek:o,encryptedKey:a,parameters:E}=await au(s,i,t,this._cek,this._keyManagementParameters)),E&&(r&&ou in r?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...E}:this.setUnprotectedHeader(E):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...E}:this.setProtectedHeader(E))}let d,u,l;this._protectedHeader?u=se.encode(L(JSON.stringify(this._protectedHeader))):u=se.encode(""),this._aad?(l=L(this._aad),d=Te(u,se.encode("."),se.encode(l))):d=u;const{ciphertext:f,tag:b,iv:w}=await Zn(i,this._plaintext,o,this._iv,d),h={ciphertext:L(f)};return w&&(h.iv=L(w)),b&&(h.tag=L(b)),a&&(h.encrypted_key=L(a)),l&&(h.aad=l),this._protectedHeader&&(h.protected=Ln.decode(u)),this._sharedUnprotectedHeader&&(h.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(h.header=this._unprotectedHeader),h}}class uu{constructor(t){this._flattened=new cu(t)}setContentEncryptionKey(t){return this._flattened.setContentEncryptionKey(t),this}setInitializationVector(t){return this._flattened.setInitializationVector(t),this}setProtectedHeader(t){return this._flattened.setProtectedHeader(t),this}setKeyManagementParameters(t){return this._flattened.setKeyManagementParameters(t),this}async encrypt(t,r){const n=await this._flattened.encrypt(t,r);return[n.protected,n.encrypted_key,n.iv,n.ciphertext,n.tag].join(".")}}const or={base:{":disabled":{backgroundColor:"transparent"}}},lu={mask:{number:"{{ data.number | card_mask: 'true', 'true' }}",expiration_month:"{{ data.expiration_month }}",expiration_year:"{{ data.expiration_year }}"}},du="DOM Element was not found",Qn=e=>e!=null;var fu={VITE_PACKAGE_VERSION:"v3.5.0",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const hu="v3.5.0";class Ae{constructor(t,r){if(Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"IFRAME_BASE_URL",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"subscriptions",{enumerable:!0,configurable:!0,writable:!0,value:{ready:[],blur:[],focus:[],keydown:[],change:[]}}),Object.defineProperty(this,"update",{enumerable:!0,configurable:!0,writable:!0,value:async({...n})=>{this.iframe&&Qn(n.height)&&(this.iframe.height=n.height),this.iframePostMessage({type:"update",data:{...n,value:n.value?this.putValue(n.value)??void 0:void 0}})}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"clear"})}}),Object.defineProperty(this,"focus",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"focus"})}}),Object.defineProperty(this,"blur",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"blur"})}}),Object.defineProperty(this,"unmount",{enumerable:!0,configurable:!0,writable:!0,value:()=>{var n;(n=this.iframe)==null||n.remove(),this.iframe=null}}),this.IFRAME_BASE_URL=fu.VITE_IFRAME_BASE_URL??pu(hu),!this.IFRAME_BASE_URL)throw new Error("IFRAME_BASE_URL not found");r&&cr.set(this,{key:r})}mount(t){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error(du);r.innerHTML=`<iframe width="100%" height="29" src="${this.IFRAME_BASE_URL}?field=${this.type}&origin=${location.origin}"></iframe>`,this.iframe=r.querySelector("iframe");const n=s=>{var i;if(!(s.source!==((i=this.iframe)==null?void 0:i.contentWindow)||s.data.element!==this.type))if(s.data.type==="change"){const a=this.extractValue(s.data.data.value),o={...s.data.data};delete o.value;const d=cr.get(this);d&&(d.value=a),this.emitEvent({...s.data,data:o})}else this.emitEvent(s.data)};return window.addEventListener("message",n),new Promise(s=>{this.on("ready",()=>{this.update(this.options),s()})})}on(t,r){return this.subscriptions[t].push(r),{unsubscribe:()=>this.subscriptions[t].splice(this.subscriptions[t].indexOf(r),1)}}secureValue(t){const r=cr.get(this);return(r==null?void 0:r.key)!==t?null:(r==null?void 0:r.value)??null}emitEvent(t){var r;(r=this.subscriptions[t.type])==null||r.forEach(n=>n(t.data))}iframePostMessage(t){var r,n;(n=(r=this.iframe)==null?void 0:r.contentWindow)==null||n.postMessage(t,this.IFRAME_BASE_URL)}}function pu(e){return`https://${window.HG_IFRAME_HOST??"sdk.hellgate.io"}/web/${e}/iframe/`}const cr=new Map;function ur(e){const[t=null,r=null]=(e??"").split("/").map(n=>Number(n.trim()));return{month:t,year:r&&r>10?+`20${r}`:null}}function lr(e){if(!e)return null;const{month:t,year:r}=e;return[t&&t<10?`0${t}`:t,r&&r>=100?String(r).slice(-2):r].filter(Qn).join(" / ")}class es extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationDate"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:ur}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:lr})}}function dr(e){return(e==null?void 0:e.replaceAll(" ",""))??null}function ts(e){return e}class rs extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardNumber"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:dr}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:ts})}}class ns extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"card"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t?{number:t.cardNumber?dr(t.cardNumber):null,expiry_date:t.cardExpirationDate?ur(t.cardExpirationDate):null,cvc:t.cardVerificationCode??null}:null}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t?{cardNumber:t.number?t.number:null,cardExpirationDate:t.expiry_date?lr(t.expiry_date):null,cardVerificationCode:t.cvc??null}:null})}}class ss extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardVerificationCode"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t})}}class fr extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"text"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t})}}function fe(e,t,r){switch(e){case"card":return new ns(t,r);case"cardNumber":return new rs(t,r);case"cardExpirationDate":return new es(t,r);case"cardVerificationCode":return new ss(t,r);case"text":return new fr(t,r);default:ASSERT_EXHAUSTIVE(e)}}function is(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function as(e){return[e.issuer_identification_number,"".padEnd(e.account_number_length-e.issuer_identification_number.length-e.account_number_last_four.length,"*"),e.account_number_last_four].join(" ")}class mt{static async init(t){var n;const r=t.isNextAction("tokenize_card")&&((n=t.state)==null?void 0:n.data.provider)==="basis_theory"?await new mr.BasisTheory().init(t.state.data.api_key,{elements:!1}):void 0;return new mt(t,r)}constructor(t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"bt",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:this.createFieldDefaultState()}),Object.defineProperty(this,"cardElements",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"textElements",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"cvcOnlyEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"createForm",{enumerable:!0,configurable:!0,writable:!0,value:(n={})=>{var o;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const s=he.get(this);if(!s)throw new Error("Secure key not found");const i=oe({disabled:!1,autocomplete:"on",style:{...or}},n);if(this.session.isNextAction("refresh_security_code")&&((o=this.session.state)!=null&&o.data)){const d=this.session.state.data;i.cvcOnly=!0,i.value={number:as(d),expiry_date:{month:(d==null?void 0:d.expiry_month)??null,year:(d==null?void 0:d.expiry_year)??null},cvc:null}}const a=fe("card",i,s);return this.cardElements.card={element:a,state:this.createFieldDefaultState()},this.addElementStateListener("card"),a}}),Object.defineProperty(this,"createFormFields",{enumerable:!0,configurable:!0,writable:!0,value:(n={})=>{var w,h;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const s=he.get(this);if(!s)throw new Error("Secure key not found");const i={disabled:this.cvcOnlyEnabled,autocomplete:"on",style:{...or}},{cardNumber:a={},expiryDate:o={},securityCode:d={},...u}=n,l=fe("cardNumber",{...oe(i,{...u,...a,cvc2Only:this.cvcOnlyEnabled,value:this.session.isNextAction("refresh_security_code")&&((w=this.session.state)!=null&&w.data)?as(this.session.state.data):null})},s),f=fe("cardExpirationDate",{...oe(i,{...u,...o,value:this.session.isNextAction("refresh_security_code")&&((h=this.session.state)!=null&&h.data)?{month:this.session.state.data.expiry_month,year:this.session.state.data.expiry_year}:null})},s),b=fe("cardVerificationCode",{...oe({...i,disabled:!1,autofocus:this.cvcOnlyEnabled},{...u,...d})},s);return this.cardElements={cardNumber:{element:l,state:this.createFieldDefaultState()},cardExpirationDate:{element:f,state:this.createFieldDefaultState()},cardVerificationCode:{element:b,state:this.createFieldDefaultState()}},this.addElementStateListener("cardNumber"),this.addElementStateListener("cardExpirationDate"),this.addElementStateListener("cardVerificationCode"),{cardNumber:l,expiryDate:f,securityCode:b}}}),Object.defineProperty(this,"createTextField",{enumerable:!0,configurable:!0,writable:!0,value:(n={})=>{const s=he.get(this);if(!s)throw new Error("Secure key not found");const i={disabled:!1,autocomplete:"on",style:{...or}},a=fe("text",{...oe(i,{...n})},s);return this.textElements.push(a),a}}),Object.defineProperty(this,"tokenize",{enumerable:!0,configurable:!0,writable:!0,value:async n=>{var o,d;if(((o=this.session.state)==null?void 0:o.next_action)!=="tokenize_card")throw new Error(`The session's next_action='${(d=this.session.state)==null?void 0:d.next_action}'. tokenize() is available only if next_action='tokenize_card'`);const s=this.getFormValue(),i=this.extractAdditionalData(n);if(!s)throw new Error("Form elements must be initialized before tokenization");if(!s.number||!s.expiration_month||!s.expiration_year||!s.cvc)throw new Error("Card data is not complete");const a=this.session.state.data;switch(a.provider){case"basis_theory":{if(!this.bt)throw new Error("basis_theory SDK not found");return this.bt.tokenize({type:"card",data:s,...lu}).then(u=>Array.isArray(u)?null:{token_id:u.id,additional_data:i})}case"guardian":return this.encryptCardData({account_number:s.number,expiry_month:s.expiration_month,expiry_year:s.expiration_year,security_code:s.cvc,additional_data:i},a.jwk);default:ASSERT_EXHAUSTIVE(a)}}}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.stateChangeHandlers.push(n),n(this.state)}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(n=>n==null?void 0:n.element.clear()),this.textElements.forEach(n=>n==null?void 0:n.clear())}}),Object.defineProperty(this,"reset",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(n=>n==null?void 0:n.element.unmount()),this.textElements.forEach(n=>n==null?void 0:n.unmount()),this.cardElements={},this.textElements=[]}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.reset()}}),Object.defineProperty(this,"process",{enumerable:!0,configurable:!0,writable:!0,value:async(n={})=>{if(!this.hasFormElements())throw new Error("Card form must be initialized and completed before processing");if(this.session.isNextAction("refresh_security_code"))return this.refreshSecurityCode();this.disableFormElements();const s=await this.tokenize(n);if(!s)throw new Error("Tokenization failed");return this.session.completeAction({action:"tokenize_card",result:s}).catch(i=>{if(i instanceof Error)throw i;return{status:"failure",data:i}})}}),he.set(this,is()),this.cvcOnlyEnabled=this.session.isNextAction("refresh_security_code")}async refreshSecurityCode(){const t=this.getFormValue();if(this.disableFormElements(),!(t!=null&&t.cvc))throw new Error("cvc field was not filled");if(!this.session.isNextAction("refresh_security_code")||!this.session.state)throw new Error("refreshSecurityCode() is available only if next_action=refresh_security_code");const r=await this.encryptCardData({security_code:t.cvc},this.session.state.data.jwk);return this.session.completeAction({action:"refresh_security_code",result:{...r}}).catch(n=>{if(n instanceof Error)throw n;return{status:"failure",data:n}})}getFormValue(){var a,o,d,u,l;const{card:t,cardNumber:r,cardExpirationDate:n,cardVerificationCode:s}=this.cardElements;let i;if(t){const f=pe(this,t.element);i={number:(f==null?void 0:f.number)??null,expiration_month:((a=f==null?void 0:f.expiry_date)==null?void 0:a.month)??null,expiration_year:((o=f==null?void 0:f.expiry_date)==null?void 0:o.year)??null,cvc:(f==null?void 0:f.cvc)??null}}return r&&n&&s&&(i={number:((d=pe(this,r.element))==null?void 0:d.replaceAll(" ",""))??null,expiration_month:((u=pe(this,n.element))==null?void 0:u.month)??null,expiration_year:((l=pe(this,n.element))==null?void 0:l.year)??null,cvc:pe(this,s.element)}),i}hasFormElements(){return!!Object.keys(this.cardElements).length}disableFormElements(){Object.values(this.cardElements).forEach(({element:t})=>{t.update({disabled:!0})})}extractAdditionalData({cardholder_name:t,billing_address:r={}}){return ae({cardholder_name:me(this,t),billing_address:{line1:me(this,r.line1),line2:me(this,r.line2),line3:me(this,r.line3),city:me(this,r.city),postal_code:me(this,r.postal_code)}})}async encryptCardData(t,r){const n=await Yc(r,"RSA-OAEP"),s=JSON.stringify(t),i=new TextEncoder().encode(s);return{enc_payload:await new uu(i).setProtectedHeader({alg:"RSA-OAEP",enc:"A256GCM"}).encrypt(n)}}addElementStateListener(t){const r=this.cardElements[t];r&&r.element.on("change",n=>{r.state=n,this.updateFormState()})}updateFormState(){const t=this.cvcOnlyEnabled&&this.cardElements.cardVerificationCode?[this.cardElements.cardVerificationCode]:Object.values(this.cardElements);t.length?this.state=t.reduce((r,{state:n})=>(r.valid=!!r.valid&&!!n.valid,r.complete=!!r.complete&&!!n.complete,r.empty=!!r.empty&&!!n.empty,r.error=r.error||n.error,r),{valid:!0,complete:!0,empty:!0,value:null}):this.state=this.createFieldDefaultState(),this.stateChangeHandlers.forEach(r=>r(this.state))}createFieldDefaultState(){return{empty:!0,complete:!1,valid:!1}}}const he=new Map;function pe(e,t){const r=he.get(e);return r?t.secureValue(r):null}function me(e,t){const r=he.get(e);return t instanceof fr&&r?pe(e,t)??void 0:t}class mu{constructor(t="https://api.hellgate.io",r=new AbortController){Object.defineProperty(this,"abortCtrl",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=t.endsWith("/")?t.substring(0,t.length-1):t}getSession(t){return fetch(`${this.baseUrl}/sessions/${t}`,{signal:this.abortCtrl.signal}).then(r=>yt(r))}completeAction(t,r){return fetch(`${this.baseUrl}/sessions/${t}/complete-action`,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:JSON.stringify(r),signal:this.abortCtrl.signal}).then(n=>yt(n))}cancelAll(){this.abortCtrl.abort()}}const Eu=2e3;class yu{constructor(t,r){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"api",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"onCloseHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"init",{enumerable:!0,configurable:!0,writable:!0,value:async()=>new Promise((n,s)=>{const i=this.onStateChange(a=>{a.next_action!=="wait"&&(n(a),i())});this.updateSessionState().catch(a=>{a instanceof Response&&a.status===404&&s(new Error(`Session ${this.id} doesn't exist or has expired`)),s(a)})})}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:n=>(this.stateChangeHandlers.push(n),this.state&&n(this.state),()=>this.stateChangeHandlers=this.stateChangeHandlers.filter(s=>s!==n))}),Object.defineProperty(this,"onClose",{enumerable:!0,configurable:!0,writable:!0,value:n=>{var s;return((s=this.state)==null?void 0:s.next_action)===null?(n(this.state),()=>{}):(this.onCloseHandlers.push(n),()=>this.onCloseHandlers=this.onCloseHandlers.filter(i=>i!==n))}}),Object.defineProperty(this,"completeAction",{enumerable:!0,configurable:!0,writable:!0,value:async n=>{const s=this.state;return new Promise((i,a)=>{const o=this.onStateChange(d=>{d.next_action!==(s==null?void 0:s.next_action)&&d.next_action===null&&(i(d),o())});this.api.completeAction(this.id,n).then(d=>this.newStateHandle(d,a)).catch(async d=>a(await bu(d)))})}}),Object.defineProperty(this,"completeSession",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onCloseHandlers.forEach(s=>s(n)),this.stop()}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.stop(),this.api.cancelAll()}})}isNextAction(t){var r;return((r=this.state)==null?void 0:r.next_action)===t}stop(){window.clearTimeout(this.pollingTimer),this.stateChangeHandlers=[],this.onCloseHandlers=[]}async updateSessionState(t){const r=await this.api.getSession(this.id);this.newStateHandle(r,t)}newStateHandle(t,r){var n;switch(!t.next_action&&t.status&&(t.next_action=null),t.next_action){case"wait":{window.clearTimeout(this.pollingTimer),this.pollingTimer=window.setTimeout(()=>this.updateSessionState(r).catch(s=>{s instanceof Response&&s.status===404&&(r==null||r(new Error(`Session ${this.id} has expired`)))}),Eu);break}}t.next_action!==((n=this.state)==null?void 0:n.next_action)&&this.stateChangeHandlers.forEach(s=>s(t)),t.next_action===null&&this.completeSession(t),this.state=t}}async function bu(e){return!e.ok&&e.status>=400&&e.status<=500?e.json():e}const _u={base_url:"https://api.hellgate.io"};class hr{constructor(t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"paymentFlowHandlers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.session.dispose(),Object.values(this.paymentFlowHandlers).forEach(n=>n==null?void 0:n.dispose())}})}use(t){return this.paymentFlowHandlers[t]}static async init(t,r={}){const{session:n,cardHandler:s,handler3DS:i}=await this.initHandlers(t,r);return new hr(n,{CARD:s,"3DS":i})}static async initHandlers(t,r){const n={..._u,...r},s=new mu(n.base_url,n.abortCtrl),i=new yu(t,s);await i.init();const a=i.isNextAction("tokenize_card")||i.isNextAction("refresh_security_code")?await this.createCardHandler(i):void 0,o=this.create3DSHandler(i,r);return{session:i,cardHandler:a,handler3DS:o}}static createCardHandler(t){return mt.init(t)}static create3DSHandler(t,r){return new pr(t,{domContainer:r.challenge_3ds_container,labelText:r.challenge_3ds_label_text})}}v.CardElement=ns,v.CardExpirationDateElement=es,v.CardNumberElement=rs,v.CardVerificationCodeElement=ss,v.Hellgate=hr,v.Hellgate3DSHandler=pr,v.HellgateCardHandler=mt,v.TextElement=fr,v.createElement=fe,v.extractCardNumberValue=dr,v.extractExpiryDateValue=ur,v.putCardNumberValue=ts,v.putExpiryDateValue=lr,v.uid=is,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});globalThis.HellgateSDK&&(globalThis.Hellgate=globalThis.HellgateSDK.Hellgate,delete globalThis.HellgateSDK);
5
+ `):" "+Yr(i[0]):"as no adapter specified";throw new y("There is no suitable adapter to dispatch the request "+a,"ERR_NOT_SUPPORT")}return n},adapters:xt};function Nt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new le(null,e)}function Zr(e){return Nt(e),e.headers=I.from(e.headers),e.data=Pt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Xr.getAdapter(e.adapter||Ct.adapter)(e).then(function(n){return Nt(e),n.data=Pt.call(e,e.transformResponse,n),n.headers=I.from(n.headers),n},function(n){return Ir(n)||(Nt(e),n&&n.response&&(n.response.data=Pt.call(e,e.transformResponse,n.response),n.response.headers=I.from(n.response.headers))),Promise.reject(n)})}const Qr="1.7.7",jt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{jt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const en={};jt.transitional=function(t,r,n){function s(i,a){return"[Axios v"+Qr+"] Transitional option '"+i+"'"+a+(n?". "+n:"")}return(i,a,o)=>{if(t===!1)throw new y(s(a," has been removed"+(r?" in "+r:"")),y.ERR_DEPRECATED);return r&&!en[a]&&(en[a]=!0,console.warn(s(a," has been deprecated since v"+r+" and will be removed in the near future"))),t?t(i,a,o):!0}};function ea(e,t,r){if(typeof e!="object")throw new y("options must be an object",y.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let s=n.length;for(;s-- >0;){const i=n[s],a=t[i];if(a){const o=e[i],d=o===void 0||a(o,i,e);if(d!==!0)throw new y("option "+i+" must be "+d,y.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}var Dt={assertOptions:ea,validators:jt};const G=Dt.validators;class Me{constructor(t){this.defaults=t,this.interceptors={request:new Ur,response:new Ur}}async request(t,r){try{return await this._request(t,r)}catch(n){if(n instanceof Error){let s;Error.captureStackTrace?Error.captureStackTrace(s={}):s=new Error;const i=s.stack?s.stack.replace(/^.+\n/,""):"";try{n.stack?i&&!String(n.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(n.stack+=`
6
+ `+i):n.stack=i}catch{}}throw n}}_request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ee(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&Dt.assertOptions(n,{silentJSONParsing:G.transitional(G.boolean),forcedJSONParsing:G.transitional(G.boolean),clarifyTimeoutError:G.transitional(G.boolean)},!1),s!=null&&(c.isFunction(s)?r.paramsSerializer={serialize:s}:Dt.assertOptions(s,{encode:G.function,serialize:G.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&c.merge(i.common,i[r.method]);i&&c.forEach(["delete","get","head","post","put","patch","common"],h=>{delete i[h]}),r.headers=I.concat(a,i);const o=[];let d=!0;this.interceptors.request.forEach(function(E){typeof E.runWhen=="function"&&E.runWhen(r)===!1||(d=d&&E.synchronous,o.unshift(E.fulfilled,E.rejected))});const u=[];this.interceptors.response.forEach(function(E){u.push(E.fulfilled,E.rejected)});let l,f=0,b;if(!d){const h=[Zr.bind(this),void 0];for(h.unshift.apply(h,o),h.push.apply(h,u),b=h.length,l=Promise.resolve(r);f<b;)l=l.then(h[f++],h[f++]);return l}b=o.length;let w=r;for(f=0;f<b;){const h=o[f++],E=o[f++];try{w=h(w)}catch(p){E.call(this,p);break}}try{l=Zr.call(this,w)}catch(h){return Promise.reject(h)}for(f=0,b=u.length;f<b;)l=l.then(u[f++],u[f++]);return l}getUri(t){t=ee(this.defaults,t);const r=Fr(t.baseURL,t.url);return Dr(r,t.params,t.paramsSerializer)}}c.forEach(["delete","get","head","options"],function(t){Me.prototype[t]=function(r,n){return this.request(ee(n||{},{method:t,url:r,data:(n||{}).data}))}}),c.forEach(["post","put","patch"],function(t){function r(n){return function(i,a,o){return this.request(ee(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}Me.prototype[t]=r(),Me.prototype[t+"Form"]=r(!0)});var Ie=Me;class Ut{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(i){r=i});const n=this;this.promise.then(s=>{if(!n._listeners)return;let i=n._listeners.length;for(;i-- >0;)n._listeners[i](s);n._listeners=null}),this.promise.then=s=>{let i;const a=new Promise(o=>{n.subscribe(o),i=o}).then(s);return a.cancel=function(){n.unsubscribe(i)},a},t(function(i,a,o){n.reason||(n.reason=new le(i,a,o),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const r=this._listeners.indexOf(t);r!==-1&&this._listeners.splice(r,1)}toAbortSignal(){const t=new AbortController,r=n=>{t.abort(n)};return this.subscribe(r),t.signal.unsubscribe=()=>this.unsubscribe(r),t.signal}static source(){let t;return{token:new Ut(function(s){t=s}),cancel:t}}}var ta=Ut;function ra(e){return function(r){return e.apply(null,r)}}function na(e){return c.isObject(e)&&e.isAxiosError===!0}const Ht={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Ht).forEach(([e,t])=>{Ht[t]=e});var sa=Ht;function tn(e){const t=new Ie(e),r=br(Ie.prototype.request,t);return c.extend(r,Ie.prototype,t,{allOwnKeys:!0}),c.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return tn(ee(e,s))},r}const A=tn(Ct);A.Axios=Ie,A.CanceledError=le,A.CancelToken=ta,A.isCancel=Ir,A.VERSION=Qr,A.toFormData=Ne,A.AxiosError=y,A.Cancel=A.CanceledError,A.all=function(t){return Promise.all(t)},A.spread=ra,A.isAxiosError=na,A.mergeConfig=ee,A.AxiosHeaders=I,A.formToJSON=e=>Lr(c.isHTMLForm(e)?new FormData(e):e),A.getAdapter=Xr.getAdapter,A.HttpStatusCode=sa,A.default=A;var rn=A,Lt={exports:{}};const nn=e=>typeof e=="object"&&e!==null,sn=Symbol("skip"),an=e=>nn(e)&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),Mt=(e,t,r,n=new WeakMap)=>{if(r={deep:!1,target:{},...r},n.has(e))return n.get(e);n.set(e,r.target);const{target:s}=r;delete r.target;const i=a=>a.map(o=>an(o)?Mt(o,t,r,n):o);if(Array.isArray(e))return i(e);for(const[a,o]of Object.entries(e)){const d=t(a,o,e);if(d===sn)continue;let[u,l,{shouldRecurse:f=!0}={}]=d;u!=="__proto__"&&(r.deep&&f&&an(l)&&(l=Array.isArray(l)?i(l):Mt(l,t,r,n)),s[u]=l)}return s};Lt.exports=(e,t,r)=>{if(!nn(e))throw new TypeError(`Expected an object, got \`${e}\` (${typeof e})`);return Mt(e,t,r)},Lt.exports.mapObjectSkip=sn;var on=Lt.exports,It={exports:{}};const ia=e=>{let t=!1,r=!1,n=!1;for(let s=0;s<e.length;s++){const i=e[s];t&&/[a-zA-Z]/.test(i)&&i.toUpperCase()===i?(e=e.slice(0,s)+"-"+e.slice(s),t=!1,n=r,r=!0,s++):r&&n&&/[a-zA-Z]/.test(i)&&i.toLowerCase()===i?(e=e.slice(0,s-1)+"-"+e.slice(s-1),n=r,r=!1,t=!0):(t=i.toLowerCase()===i&&i.toUpperCase()!==i,n=r,r=i.toUpperCase()===i&&i.toLowerCase()!==i)}return e},cn=(e,t)=>{if(!(typeof e=="string"||Array.isArray(e)))throw new TypeError("Expected the input to be `string | string[]`");t=Object.assign({pascalCase:!1},t);const r=s=>t.pascalCase?s.charAt(0).toUpperCase()+s.slice(1):s;return Array.isArray(e)?e=e.map(s=>s.trim()).filter(s=>s.length).join("-"):e=e.trim(),e.length===0?"":e.length===1?t.pascalCase?e.toUpperCase():e.toLowerCase():(e!==e.toLowerCase()&&(e=ia(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(s,i)=>i.toUpperCase()).replace(/\d+(\w|$)/g,s=>s.toUpperCase()),r(e))};It.exports=cn,It.exports.default=cn;var aa=It.exports;class oa{constructor(t={}){if(!(t.maxSize&&t.maxSize>0))throw new TypeError("`maxSize` must be a number greater than 0");this.maxSize=t.maxSize,this.cache=new Map,this.oldCache=new Map,this._size=0}_set(t,r){this.cache.set(t,r),this._size++,this._size>=this.maxSize&&(this._size=0,this.oldCache=this.cache,this.cache=new Map)}get(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t)){const r=this.oldCache.get(t);return this.oldCache.delete(t),this._set(t,r),r}}set(t,r){return this.cache.has(t)?this.cache.set(t,r):this._set(t,r),this}has(t){return this.cache.has(t)||this.oldCache.has(t)}peek(t){if(this.cache.has(t))return this.cache.get(t);if(this.oldCache.has(t))return this.oldCache.get(t)}delete(t){const r=this.cache.delete(t);return r&&this._size--,this.oldCache.delete(t)||r}clear(){this.cache.clear(),this.oldCache.clear(),this._size=0}*keys(){for(const[t]of this)yield t}*values(){for(const[,t]of this)yield t}*[Symbol.iterator](){for(const t of this.cache)yield t;for(const t of this.oldCache){const[r]=t;this.cache.has(r)||(yield t)}}get size(){let t=0;for(const r of this.oldCache.keys())this.cache.has(r)||t++;return this._size+t}}var ca=oa;const un=on,ua=aa,la=ca,da=(e,t)=>e.some(r=>typeof r=="string"?r===t:(r.lastIndex=0,r.test(t))),$t=new la({maxSize:1e5}),ln=e=>typeof e=="object"&&e!==null&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),dn=(e,t)=>{if(!ln(e))return e;t={deep:!1,pascalCase:!1,...t};const{exclude:r,pascalCase:n,stopPaths:s,deep:i}=t,a=new Set(s),o=d=>(u,l)=>{if(i&&ln(l)){const f=d===void 0?u:`${d}.${u}`;a.has(f)||(l=un(l,o(f)))}if(!(r&&da(r,u))){const f=n?`${u}_`:u;if($t.has(f))u=$t.get(f);else{const b=ua(u,{pascalCase:n});u.length<100&&$t.set(f,b),u=b}}return[u,l]};return un(e,o(void 0))};var fa=(e,t)=>Array.isArray(e)?Object.keys(e).map(r=>dn(e[r],t)):dn(e,t),qt,fn;function hn(){return fn||(fn=1,qt=hn()),qt}var $e=function(){return $e=Object.assign||function(t){for(var r,n=1,s=arguments.length;n<s;n++){r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t},$e.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function ha(e){return e.toLowerCase()}var pa=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],ma=/[^A-Z0-9]+/gi;function Ea(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,n=r===void 0?pa:r,s=t.stripRegexp,i=s===void 0?ma:s,a=t.transform,o=a===void 0?ha:a,d=t.delimiter,u=d===void 0?" ":d,l=pn(pn(e,n,"$1\0$2"),i,"\0"),f=0,b=l.length;l.charAt(f)==="\0";)f++;for(;l.charAt(b-1)==="\0";)b--;return l.slice(f,b).split("\0").map(o).join(u)}function pn(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(n,s){return n.replace(s,r)},e)}function ya(e,t){return t===void 0&&(t={}),Ea(e,$e({delimiter:"."},t))}function ba(e,t){return t===void 0&&(t={}),ya(e,$e({delimiter:"_"},t))}const _a=ls(Object.freeze(Object.defineProperty({__proto__:null,snakeCase:ba},Symbol.toStringTag,{value:"Module"})));var ga=Ra,wa=/\s/,Sa=/(_|-|\.|:)/,Ta=/([a-z][A-Z]|[A-Z][a-z])/;function Ra(e){return wa.test(e)?e.toLowerCase():Sa.test(e)?(va(e)||e).toLowerCase():Ta.test(e)?Oa(e).toLowerCase():e.toLowerCase()}var Aa=/[\W_]+(.|$)/g;function va(e){return e.replace(Aa,function(t,r){return r?" "+r:""})}var Ca=/(.)([A-Z]+)/g;function Oa(e){return e.replace(Ca,function(t,r,n){return r+" "+n.toLowerCase().split("").join(" ")})}var Pa=ga,Ba=xa;function xa(e){return Pa(e).replace(/[\W_]+(.|$)/g,function(t,r){return r?" "+r:""}).trim()}var Na=Ba,ja=Da;function Da(e){return Na(e).replace(/\s/g,"_")}const Ua=on,Ha=ja;var La=function(e,t){return t=Object.assign({deep:!0,exclude:[]},t),Ua(e,function(r,n){return[Ma(t.exclude,r)?r:Ha(r),n]},t)};function Ma(e,t){return e.some(function(r){return typeof r=="string"?r===t:r.test(t)})}var _e={};Object.defineProperty(_e,"__esModule",{value:!0}),_e.BasisTheoryApiError=void 0;function Ia(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class Kt extends Ia(Error){constructor(t,r,n){super(t),this.status=r,this.data=n,this.name="BasisTheoryApiError",Object.setPrototypeOf(this,Kt.prototype)}}_e.BasisTheoryApiError=Kt,Object.defineProperty(m,"__esModule",{value:!0}),m.transformTokenResponseCamelCase=m.transformTokenRequestSnakeCase=m.transformResponseCamelCase=m.transformRequestSnakeCase=m.transformReactorResponseCamelCase=m.transformReactorRequestSnakeCase=m.transformProxyResponseCamelCase=m.transformProxyRequestSnakeCase=m.proxyRaw=m.getRuntime=m.getQueryParams=m.getOSVersion=m.getBrowser=m.errorInterceptor=m.dataExtractor=m.dataAndHeadersExtractor=m.createRequestConfig=m.concatResponseTransformerWithDefault=m.concatRequestTransformerWithDefault=m.buildUserAgentString=m.buildClientUserAgentString=m.assertInit=void 0;var mn=qe(rn),q=qe(fa),En=qe(hn()),$a=_a,ge=qe(La),qa=_e,te=_;function qe(e){return e&&e.__esModule?e:{default:e}}const Ka=e=>{if(e==null)throw new Error("BasisTheory has not yet been properly initialized.");return e};m.assertInit=Ka;const Fa=e=>{if(!(typeof e>"u"))return(0,ge.default)(e,{deep:!0})};m.transformRequestSnakeCase=Fa;const za=e=>e;m.proxyRaw=za;const Wa=e=>{if(!(typeof e>"u"))return{...(0,ge.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorRequestSnakeCase=Wa;const ka=e=>{if(!(typeof e>"u"))return{...(0,ge.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyRequestSnakeCase=ka;const Va=e=>{if(!(typeof e>"u"))return{...(0,ge.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenRequestSnakeCase=Va;const Ft=e=>e&&(e==null?void 0:e.pagination)!==void 0&&(e==null?void 0:e.data)!==void 0,Ga=e=>{if(!(typeof e>"u"))return Ft(e)?{data:e.data.map(n=>({...(0,q.default)(n,{deep:!0}),...n.data!==void 0?{data:n.data}:{},...n.metadata!==void 0?{metadata:n.metadata}:{}})),pagination:(0,q.default)(e.pagination,{deep:!0})}:{...(0,q.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenResponseCamelCase=Ga;const Ja=e=>{if(!(typeof e>"u"))return Ft(e)?{data:e.data.map(n=>({...(0,q.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,q.default)(e.pagination,{deep:!0})}:{...(0,q.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorResponseCamelCase=Ja;const Ya=e=>{if(!(typeof e>"u"))return Ft(e)?{data:e.data.map(n=>({...(0,q.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,q.default)(e.pagination,{deep:!0})}:{...(0,q.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyResponseCamelCase=Ya;const Xa=e=>{if(!(typeof e>"u"))return(0,q.default)(e,{deep:!0})};m.transformResponseCamelCase=Xa;const Za=e=>e==null?void 0:e.data;m.dataExtractor=Za;const Qa=e=>({data:e==null?void 0:e.data,headers:e==null?void 0:e.headers});m.dataAndHeadersExtractor=Qa;const zt=e=>[e,...mn.default.defaults.transformRequest];m.concatRequestTransformerWithDefault=zt;const Wt=e=>[...mn.default.defaults.transformResponse,e];m.concatResponseTransformerWithDefault=Wt;const eo=(e,t)=>{if(!e)return t?{...t.transformRequest!==void 0?{transformRequest:zt(t.transformRequest)}:{},...t.transformResponse!==void 0?{transformResponse:Wt(t.transformResponse)}:{}}:void 0;const{apiKey:r,correlationId:n,idempotencyKey:s,transactionId:i,query:a,headers:o}=e,d=r?{[te.API_KEY_HEADER]:r}:{},u=n?{[te.BT_TRACE_ID_HEADER]:n}:{},l=s?{[te.BT_IDEMPOTENCY_KEY_HEADER]:s}:{},f=i?{[te.BT_TRANSACTION_ID_HEADER]:i}:{};return{headers:{...d,...u,...l,...f,...typeof o<"u"&&{...o}},...typeof a<"u"&&{params:a},...(t==null?void 0:t.transformRequest)!==void 0?{transformRequest:zt(t.transformRequest)}:{},...(t==null?void 0:t.transformResponse)!==void 0?{transformResponse:Wt(t.transformResponse)}:{}}};m.createRequestConfig=eo;const to=e=>{var t,r;const n=((t=e.response)===null||t===void 0?void 0:t.status)||-1,s=(r=e.response)===null||r===void 0?void 0:r.data;throw new qa.BasisTheoryApiError(e.message,n,s)};m.errorInterceptor=to;const ro=(e={})=>{const t=Object.keys(e);if(t.length){const r=new URLSearchParams,n=(s,i,a=!1)=>{const o=typeof i,d=a?s:(0,$a.snakeCase)(s);(i===null||["boolean","number","string"].includes(o))&&r.append(d,i)};return t.forEach(s=>{const i=e[s];Array.isArray(i)?i.forEach(a=>{n(String(s),a)}):i&&typeof i=="object"?Object.keys(i).forEach(o=>{n(`${String(s)}.${o}`,i[o],!0)}):n(String(s),i)}),`?${r.toString()}`}return""};m.getQueryParams=ro;const no=e=>`(${e.name||""}; ${e.version||""}; ${e.url||""})`,so=e=>{let t=`${te.USER_AGENT_CLIENT}/unknown`;return e&&Object.keys(e||{}).length&&(t+=` ${no(e)}`),t};m.buildUserAgentString=so;const yn=()=>{const{userAgent:e}=window.navigator;let t="unknown";const r=te.BROWSER_LIST.find(n=>e.includes(n.browserUA));if(r)try{t=e.split(`${r.browserUA}/`)[1]}catch{t="unknown"}return`${(r==null?void 0:r.browserName)||"unknown"}/${t}`};m.getBrowser=yn;const bn=()=>typeof window=="object"&&window.navigator.product==="ReactNative",_n=()=>{if(bn())return"ReactNative";if(typeof window>"u")try{return`${En.default.type()}/${En.default.version()}`}catch{return"unknown"}try{const t=window.navigator.appVersion.match(/\(([^)]+)\)/u);return t&&t.length>1?t[1]:"unknown"}catch{return"unknown"}};m.getOSVersion=_n;const gn=()=>bn()?"ReactNative":typeof window>"u"?`NodeJS/${process.version}`:yn();m.getRuntime=gn;const io=e=>{const t={client:te.USER_AGENT_CLIENT,clientVersion:"unknown",osVersion:_n(),runtimeVersion:gn(),application:{}};return e&&(t.application=e),JSON.stringify((0,ge.default)(t))};m.buildClientUserAgentString=io;var Ke={};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.BasisTheoryValidationError=void 0;function ao(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class kt extends ao(Error){constructor(t,r,n){super(t),this.details=r,this.validation=n,this.name="BasisTheoryValidationError",Object.setPrototypeOf(this,kt.prototype)}}Ke.BasisTheoryValidationError=kt;var Fe={};Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.HttpClientError=void 0;function oo(e){function t(){var r=Reflect.construct(e,Array.from(arguments));return Object.setPrototypeOf(r,Object.getPrototypeOf(this)),r}return t.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e,t}class Vt extends oo(Error){constructor(t,r,n,s){super(t),this.name="HttpClientError",this.status=r,this.data=n,this.headers=s,Object.setPrototypeOf(this,Vt.prototype)}}Fe.HttpClientError=Vt,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={BasisTheoryApiError:!0,BasisTheoryValidationError:!0,HttpClientError:!0};Object.defineProperty(e,"BasisTheoryApiError",{enumerable:!0,get:function(){return s.BasisTheoryApiError}}),Object.defineProperty(e,"BasisTheoryValidationError",{enumerable:!0,get:function(){return i.BasisTheoryValidationError}}),Object.defineProperty(e,"HttpClientError",{enumerable:!0,get:function(){return a.HttpClientError}});var r=_;Object.keys(r).forEach(function(o){o==="default"||o==="__esModule"||Object.prototype.hasOwnProperty.call(t,o)||o in e&&e[o]===r[o]||Object.defineProperty(e,o,{enumerable:!0,get:function(){return r[o]}})});var n=m;Object.keys(n).forEach(function(o){o==="default"||o==="__esModule"||Object.prototype.hasOwnProperty.call(t,o)||o in e&&e[o]===n[o]||Object.defineProperty(e,o,{enumerable:!0,get:function(){return n[o]}})});var s=_e,i=Ke,a=Fe}(D);var H={},co={},ze={};Object.defineProperty(ze,"__esModule",{value:!0}),ze.BasisTheoryService=void 0;var We=uo(rn),J=D;function uo(e){return e&&e.__esModule?e:{default:e}}class lo{constructor(t){const{apiKey:r,baseURL:n,transformRequest:s,transformResponse:i,appInfo:a}=t;if(typeof We.default=="string")throw new Error("basis-theory-js@1.77.0+ and basis-theory-react@1.12.1+ are not supported with CRA 5, go to https://github.com/Basis-Theory/basis-theory-js/issues/365#issuecomment-1662883062 for workarounds.");this.client=We.default.create({baseURL:n,headers:{[J.API_KEY_HEADER]:r,[J.CLIENT_USER_AGENT_HEADER]:(0,J.buildClientUserAgentString)(a),...typeof window>"u"&&{[J.USER_AGENT_HEADER]:(0,J.buildUserAgentString)(a)}},transformRequest:[].concat(s||J.transformRequestSnakeCase,We.default.defaults.transformRequest),transformResponse:We.default.defaults.transformResponse.concat(i||J.transformResponseCamelCase)}),this.client.interceptors.response.use(void 0,J.errorInterceptor)}}ze.BasisTheoryService=lo,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=co;Object.keys(t).forEach(function(n){n==="default"||n==="__esModule"||n in e&&e[n]===t[n]||Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[n]}})});var r=ze;Object.keys(r).forEach(function(n){n==="default"||n==="__esModule"||n in e&&e[n]===r[n]||Object.defineProperty(e,n,{enumerable:!0,get:function(){return r[n]}})})}(H),Object.defineProperty(Ce,"__esModule",{value:!0}),Ce.BasisTheoryTransactions=void 0;var Gt=D,we=m,fo=H;class ho extends fo.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(we.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(we.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,Gt.createRequestConfig)(t)).then(we.dataExtractor)}commit(t,r={}){const n=`/${t}/commit`;return this.client.post(n,void 0,(0,Gt.createRequestConfig)(r)).then(we.dataExtractor)}rollback(t,r={}){const n=`/${t}/rollback`;return this.client.post(n,void 0,(0,Gt.createRequestConfig)(r)).then(we.dataExtractor)}}Ce.BasisTheoryTransactions=ho,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ce;Object.keys(t).forEach(function(r){r==="default"||r==="__esModule"||r in e&&e[r]===t[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(yr);var Jt={},ke={},K={};Object.defineProperty(K,"__esModule",{value:!0}),K.CrudBuilder=void 0;var x=D;const po=e=>class extends e{create(r,n){return this.client.post("/",r,(0,x.createRequestConfig)(n)).then(x.dataExtractor)}},mo=e=>class extends e{retrieve(r,n){return this.client.get(r,(0,x.createRequestConfig)(n)).then(x.dataExtractor)}},Eo=e=>class extends e{update(r,n,s){return this.client.put(r,n,(0,x.createRequestConfig)(s)).then(x.dataExtractor)}},yo=e=>class extends e{patch(r,n,s){const i=(0,x.createRequestConfig)(s);return this.client.patch(r,n,{...i,headers:{...(i==null?void 0:i.headers)||{},[x.CONTENT_TYPE_HEADER]:x.MERGE_CONTENT_TYPE}}).then(x.dataExtractor)}},bo=e=>class extends e{async delete(r,n){await this.client.delete(r,(0,x.createRequestConfig)(n))}},_o=e=>class extends e{list(r={},n={}){const s=`/${(0,x.getQueryParams)(r)}`;return this.client.get(s,(0,x.createRequestConfig)(n)).then(x.dataExtractor)}};class go{constructor(t){this.BaseService=t}create(){return this.BaseService=po(this.BaseService),this}retrieve(){return this.BaseService=mo(this.BaseService),this}update(){return this.BaseService=Eo(this.BaseService),this}patch(){return this.BaseService=yo(this.BaseService),this}delete(){return this.BaseService=bo(this.BaseService),this}list(){return this.BaseService=_o(this.BaseService),this}build(){return this.BaseService}}K.CrudBuilder=go,Object.defineProperty(ke,"__esModule",{value:!0}),ke.BasisTheoryApplications=void 0;var Ve=D,wo=H,So=K;const To=new So.CrudBuilder(class extends wo.BasisTheoryService{getApplicationByKey(){return this.retrieveByKey()}retrieveByKey(t){return this.client.get("/key",(0,Ve.createRequestConfig)(t)).then(Ve.dataExtractor)}regenerateKey(t,r){return this.client.post(`${t}/regenerate`,void 0,(0,Ve.createRequestConfig)(r)).then(Ve.dataExtractor)}}).create().retrieve().update().delete().list().build();ke.BasisTheoryApplications=To,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryApplications",{enumerable:!0,get:function(){return t.BasisTheoryApplications}});var t=ke}(Jt);var wn={},Sn={},Ge={},Tn={},Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.BasisTheoryTokenize=void 0;var Ye=D,Ro=H;class Ao extends Ro.BasisTheoryService{tokenize(t,r={}){return this.client.post("/",t,(0,Ye.createRequestConfig)(r,{transformRequest:Ye.proxyRaw,transformResponse:Ye.proxyRaw})).then(Ye.dataExtractor)}}Je.BasisTheoryTokenize=Ao,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokenize",{enumerable:!0,get:function(){return t.BasisTheoryTokenize}});var t=Je}(Tn),Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.delegateTokenize=void 0;var vo=Tn;const Co=e=>class extends vo.BasisTheoryTokenize{tokenize(r,n){return e!=null&&e.hasElement(r)?e.tokenize(r,n):super.tokenize(r,n)}};Ge.delegateTokenize=Co;var Xe={},Yt={},Ze={};Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.BasisTheoryTokens=void 0;var F=D,re=m,Oo=H,Po=K;const Bo=new Po.CrudBuilder(class extends Oo.BasisTheoryService{constructor(t){const r=t;r.transformRequest=[].concat(re.transformTokenRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(re.transformTokenResponseCamelCase,t.transformResponse||[]),super(r)}retrieve(t,r={}){const n=`/${t}`;return this.client.get(n,(0,F.createRequestConfig)(r)).then(re.dataExtractor)}update(t,r,n={}){const s=`/${t}`,i=(0,F.createRequestConfig)(n);return this.client.patch(s,r,{...i,headers:{...(i==null?void 0:i.headers)||{},[F.CONTENT_TYPE_HEADER]:F.MERGE_CONTENT_TYPE}}).then(re.dataExtractor)}async createAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.post(s,{},(0,F.createRequestConfig)(n))}async deleteAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.delete(s,(0,F.createRequestConfig)(n))}createChild(t,r,n){const s=`/${t}/children`;return this.client.post(s,r,(0,F.createRequestConfig)(n)).then(re.dataExtractor)}listChildren(t,r={},n={}){const s=`/${t}/children${(0,F.getQueryParams)(r)}`;return this.client.get(s,(0,F.createRequestConfig)(n)).then(re.dataExtractor)}search(t,r){return this.client.post("/search",t,(0,F.createRequestConfig)(r)).then(re.dataExtractor)}}).create().delete().list().build();Ze.BasisTheoryTokens=Bo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokens",{enumerable:!0,get:function(){return t.BasisTheoryTokens}});var t=Ze}(Yt),Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.delegateTokens=void 0;var xo=Yt;const No=e=>class extends xo.BasisTheoryTokens{create(r,n){return e!=null&&e.hasElement(r)?e.tokens.create(r,n):super.create(r,n)}update(r,n,s){return e!=null&&e.hasElement(n)?e.tokens.update(r,n,s):super.update(r,n,s)}retrieve(r,n){return e!==void 0?e.tokens.retrieve(r,n):super.retrieve(r,n)}};Xe.delegateTokens=No;var Qe={},Rn={},et={};Object.defineProperty(et,"__esModule",{value:!0}),et.BasisTheoryProxy=void 0;var k=D,jo=H;class Do extends jo.BasisTheoryService{get(t){return this.proxyRequest("get",t)}post(t){return this.proxyRequest("post",t)}put(t){return this.proxyRequest("put",t)}patch(t){return this.proxyRequest("patch",t)}delete(t){return this.proxyRequest("delete",t)}proxyRequest(t,r){var n;if(t==="post"||t==="put"||t==="patch"){var s,i;const a=r!=null&&r.includeResponseHeaders&&t==="post"?k.dataAndHeadersExtractor:k.dataExtractor;return this.client[t]((s=r==null?void 0:r.path)!==null&&s!==void 0?s:"",(i=r==null?void 0:r.body)!==null&&i!==void 0?i:void 0,(0,k.createRequestConfig)(r,{transformRequest:k.proxyRaw,transformResponse:k.proxyRaw})).then(a)}return this.client[t]((n=r==null?void 0:r.path)!==null&&n!==void 0?n:"/",(0,k.createRequestConfig)(r,{transformRequest:k.proxyRaw,transformResponse:k.proxyRaw})).then(k.dataExtractor)}}et.BasisTheoryProxy=Do,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=et;Object.keys(t).forEach(function(r){r==="default"||r==="__esModule"||r in e&&e[r]===t[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(Rn),Object.defineProperty(Qe,"__esModule",{value:!0}),Qe.delegateProxy=void 0;var Uo=Rn;const Ho=e=>class extends Uo.BasisTheoryProxy{get(r){return e!==void 0?e.proxy.get(r):super.get(r)}post(r){return e!==void 0?e.proxy.post(r):super.post(r)}put(r){return e!==void 0?e.proxy.put(r):super.put(r)}patch(r){return e!==void 0?e.proxy.patch(r):super.patch(r)}delete(r){return e!==void 0?e.proxy.delete(r):super.delete(r)}};Qe.delegateProxy=Ho,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ge;Object.keys(t).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===t[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return t[s]}})});var r=Xe;Object.keys(r).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===r[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return r[s]}})});var n=Qe;Object.keys(n).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===n[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return n[s]}})})}(Sn);var ne={};Object.defineProperty(ne,"__esModule",{value:!0}),ne.injectScript=ne.findScript=void 0;const Lo=e=>document.querySelector(`script[src^="${e}"]`);ne.findScript=Lo;const Mo=e=>{const t=document.createElement("script");t.src=e;const r=document.head||document.body;if(!r)throw new Error("No <head> or <body> elements found in document.");return r.append(t),t};ne.injectScript=Mo;var tt={},P={};Object.defineProperty(P,"__esModule",{value:!0}),P.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=P.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=P.ELEMENTS_NOM_DOM_ERROR_MESSAGE=P.ELEMENTS_INIT_ERROR_MESSAGE=P.CARD_ICON_POSITIONS=P.CARD_BRANDS=P.AUTOCOMPLETE_VALUES=void 0;const Io="BasisTheory Elements was not properly initialized.";P.ELEMENTS_INIT_ERROR_MESSAGE=Io;const $o="Tried to load BasisTheoryElements in a non-DOM environment.";P.ELEMENTS_NOM_DOM_ERROR_MESSAGE=$o;const qo="Basis Theory Elements did not load properly.";P.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=qo;const Ko="There was an unknown error when loading Basis Theory Elements. Check the console for details.";P.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=Ko;const Fo=["visa","mastercard","american-express","discover","diners-club","jcb","unionpay","maestro","elo","hiper","hipercard","mir","unknown"];P.CARD_BRANDS=Fo;const zo=["left","right","none"];P.CARD_ICON_POSITIONS=zo;const Wo=["off","on"];P.AUTOCOMPLETE_VALUES=Wo,Object.defineProperty(tt,"__esModule",{value:!0}),tt.loadElements=void 0;var Xt=P,An=ne;let Zt;const ko=e=>(Zt||(Zt=new Promise((t,r)=>{if(typeof window!="object"){r(new Error(Xt.ELEMENTS_NOM_DOM_ERROR_MESSAGE));return}if(window.BasisTheoryElements){t(window.BasisTheoryElements);return}try{let n="https://js.basistheory.com/elements";if(typeof e<"u")try{n=new URL(e).toString().replace(/\/$/u,"")}catch{throw new Error("Invalid format for the given Elements client url.")}let s=(0,An.findScript)(n);s||(s=(0,An.injectScript)(n)),s.addEventListener("load",()=>{window.BasisTheoryElements?t(window.BasisTheoryElements):r(new Error(Xt.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE))}),s.addEventListener("error",i=>{r((i==null?void 0:i.error)||new Error(Xt.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE))})}catch(n){r(n);return}})),Zt);tt.loadElements=ko,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Sn;Object.keys(t).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===t[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return t[s]}})});var r=ne;Object.keys(r).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===r[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return r[s]}})});var n=tt;Object.keys(n).forEach(function(s){s==="default"||s==="__esModule"||s in e&&e[s]===n[s]||Object.defineProperty(e,s,{enumerable:!0,get:function(){return n[s]}})})}(wn);var vn={},rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.BasisTheoryLogs=void 0;var Vo=H,Go=K;const Jo=new Go.CrudBuilder(class extends Vo.BasisTheoryService{}).list().build();rt.BasisTheoryLogs=Jo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryLogs",{enumerable:!0,get:function(){return t.BasisTheoryLogs}});var t=rt}(vn);var Cn={},nt={};Object.defineProperty(nt,"__esModule",{value:!0}),nt.BasisTheoryPermissions=void 0;var On=D,Yo=H;class Xo extends Yo.BasisTheoryService{list(t){return this.client.get("/",(0,On.createRequestConfig)(t)).then(On.dataExtractor)}}nt.BasisTheoryPermissions=Xo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryPermissions",{enumerable:!0,get:function(){return t.BasisTheoryPermissions}});var t=nt}(Cn);var Pn={},st={};Object.defineProperty(st,"__esModule",{value:!0}),st.BasisTheoryProxies=void 0;var Bn=m,Zo=H,Qo=K;const ec=new Qo.CrudBuilder(class extends Zo.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(Bn.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(Bn.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}}).create().retrieve().update().patch().delete().list().build();st.BasisTheoryProxies=ec,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=st;Object.keys(t).forEach(function(r){r==="default"||r==="__esModule"||r in e&&e[r]===t[r]||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})})}(Pn);var xn={},it={};Object.defineProperty(it,"__esModule",{value:!0}),it.BasisTheoryReactorFormulas=void 0;var tc=H,rc=K;const nc=new rc.CrudBuilder(class extends tc.BasisTheoryService{}).create().retrieve().update().delete().list().build();it.BasisTheoryReactorFormulas=nc,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactorFormulas",{enumerable:!0,get:function(){return t.BasisTheoryReactorFormulas}});var t=it}(xn);var Nn={},at={};Object.defineProperty(at,"__esModule",{value:!0}),at.BasisTheoryReactors=void 0;var ot=D,jn=m,sc=H,ic=K;const ac=new ic.CrudBuilder(class extends sc.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(jn.transformReactorRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(jn.transformReactorResponseCamelCase,t.transformResponse||[]),super(r)}react(t,r,n){return this.client.post(`/${t}/react`,r,(0,ot.createRequestConfig)(n,{transformRequest:ot.proxyRaw,transformResponse:ot.proxyRaw})).then(ot.dataExtractor)}}).create().retrieve().update().patch().delete().list().build();at.BasisTheoryReactors=ac,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactors",{enumerable:!0,get:function(){return t.BasisTheoryReactors}});var t=at}(Nn);var Dn={},ct={};Object.defineProperty(ct,"__esModule",{value:!0}),ct.BasisTheorySessions=void 0;var Un=D,ut=m,oc=H;class cc extends oc.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(ut.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(ut.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,Un.createRequestConfig)(t)).then(ut.dataExtractor)}authorize(t,r={}){return this.client.post("/authorize",t,(0,Un.createRequestConfig)(r)).then(ut.dataExtractor)}}ct.BasisTheorySessions=cc,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheorySessions",{enumerable:!0,get:function(){return t.BasisTheorySessions}});var t=ct}(Dn);var Hn={},lt={};Object.defineProperty(lt,"__esModule",{value:!0}),lt.BasisTheoryTenants=void 0;var R=D,uc=H,lc=K;const dc=new lc.CrudBuilder(class extends uc.BasisTheoryService{retrieve(t){return this.client.get("/",(0,R.createRequestConfig)(t)).then(R.dataExtractor)}update(t,r){return this.client.put("/",t,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}async delete(t){await this.client.delete("/",(0,R.createRequestConfig)(t))}retrieveUsageReport(t){return this.client.get("/reports/usage",(0,R.createRequestConfig)(t)).then(R.dataExtractor)}createInvitation(t,r){return this.client.post("/invitations",t,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}resendInvitation(t,r){return this.client.post(`/invitations/${t}/resend`,{},(0,R.createRequestConfig)(r)).then(R.dataExtractor)}listInvitations(t,r){const n=`/invitations${(0,R.getQueryParams)(t)}`;return this.client.get(n,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}retrieveInvitation(t,r){return this.client.get(`/invitations/${t}`,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}async deleteInvitation(t,r){await this.client.delete(`/invitations/${t}`,(0,R.createRequestConfig)(r))}listMembers(t,r){const n=`/members${(0,R.getQueryParams)(t)}`;return this.client.get(n,(0,R.createRequestConfig)(r)).then(R.dataExtractor)}async deleteMember(t,r){await this.client.delete(`/members/${t}`,(0,R.createRequestConfig)(r))}}).build();lt.BasisTheoryTenants=dc,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTenants",{enumerable:!0,get:function(){return t.BasisTheoryTenants}});var t=lt}(Hn),Object.defineProperty(ve,"__esModule",{value:!0}),ve.BasisTheory=void 0;var Se=ce,fc=yr,hc=Jt,g=D,dt=wn,pc=P,mc=vn,Ec=Cn,yc=Pn,bc=xn,_c=Nn,gc=Dn,wc=Hn;function Sc(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Tc={apiBaseUrl:g.DEFAULT_BASE_URL,elements:!1,appInfo:{}};class Rc{constructor(){Sc(this,"_initStatus","not-started")}async init(t,r={}){if(this._initStatus!=="not-started"&&this._initStatus!=="error")throw new Error("This BasisTheory instance has been already initialized.");this._initStatus="in-progress";try{this._initOptions=Object.freeze({...Tc,...r});let n=this._initOptions.apiBaseUrl;try{const i=new URL(this.initOptions.apiBaseUrl);i.hostname==="localhost"?i.protocol="http":i.protocol="https",n=i.toString().replace(/\/$/u,"")}catch{throw new Error("Invalid format for the given API base url.")}const s=this._initOptions.appInfo;this._initOptions.elements&&await this.loadElements(t),this._tokens=new((0,dt.delegateTokens)(this._elements))({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.tokens,n).toString(),appInfo:s}),this._tokenize=new((0,dt.delegateTokenize)(this._elements))({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.tokenize,n).toString(),appInfo:s}),this._applications=new hc.BasisTheoryApplications({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.applications,n).toString(),appInfo:s}),this._tenants=new wc.BasisTheoryTenants({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.tenants,n).toString(),appInfo:s}),this._logs=new mc.BasisTheoryLogs({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.logs,n).toString(),appInfo:s}),this._reactorFormulas=new bc.BasisTheoryReactorFormulas({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.reactorFormulas,n).toString(),appInfo:s}),this._reactors=new _c.BasisTheoryReactors({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.reactors,n).toString(),appInfo:s}),this._permissions=new Ec.BasisTheoryPermissions({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.permissions,n).toString(),appInfo:s}),this._proxies=new yc.BasisTheoryProxies({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.proxies,n).toString(),appInfo:s}),this._proxy=new((0,dt.delegateProxy)(this._elements))({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.proxy,n).toString(),appInfo:s}),this._sessions=new gc.BasisTheorySessions({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.sessions,n).toString(),appInfo:s}),this._transactions=new fc.BasisTheoryTransactions({apiKey:t,baseURL:new URL(g.CLIENT_BASE_PATHS.transactions,n).toString(),appInfo:s}),this._initStatus="done"}catch(n){throw this._initStatus="error",n}return this}createElement(t,r){if(!this._elements)throw new Error(pc.ELEMENTS_INIT_ERROR_MESSAGE);return this._elements.createElement(t,r)}tokenize(t,r){return(0,g.assertInit)(this._tokenize).tokenize(t,r)}post(t,r,n){return(0,Se.makeRequestWithElementsPayloadCheck)(this._elements,"post",t,r,n)}put(t,r,n){return(0,Se.makeRequestWithElementsPayloadCheck)(this._elements,"put",t,r,n)}patch(t,r,n){return(0,Se.makeRequestWithElementsPayloadCheck)(this._elements,"patch",t,r,n)}get(t,r){return(0,Se.makeRequestWithoutElementsPayloadCheck)(this._elements,"get",t,r)}delete(t,r){return(0,Se.makeRequestWithoutElementsPayloadCheck)(this._elements,"delete",t,r)}async loadElements(t){let r;try{r=new URL(this.initOptions.elementsBaseUrl||g.DEFAULT_ELEMENTS_BASE_URL)}catch{throw new Error("Invalid format for the given Elements base url.")}const n=await(0,dt.loadElements)(this.initOptions.elementsClientUrl);await n.init(t,r.toString().replace(/\/$/u,"")),this.elements=n}get initOptions(){return(0,g.assertInit)(this._initOptions)}get tokens(){return(0,g.assertInit)(this._tokens)}get applications(){return(0,g.assertInit)(this._applications)}get tenants(){return(0,g.assertInit)(this._tenants)}get logs(){return(0,g.assertInit)(this._logs)}get reactorFormulas(){return(0,g.assertInit)(this._reactorFormulas)}get reactors(){return(0,g.assertInit)(this._reactors)}get permissions(){return(0,g.assertInit)(this._permissions)}get proxies(){return(0,g.assertInit)(this._proxies)}get proxy(){return(0,g.assertInit)(this._proxy)}get sessions(){return(0,g.assertInit)(this._sessions)}get transactions(){return(0,g.assertInit)(this._transactions)}get elements(){return(0,g.assertInit)(this._elements)}set elements(t){this._elements=t}}ve.BasisTheory=Rc,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={_instance:!0};e._instance=void 0;var r=ve;Object.keys(r).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in e&&e[a]===r[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return r[a]}})});var n=Jt;Object.keys(n).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in e&&e[a]===n[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return n[a]}})});var s=Yt;Object.keys(s).forEach(function(a){a==="default"||a==="__esModule"||Object.prototype.hasOwnProperty.call(t,a)||a in e&&e[a]===s[a]||Object.defineProperty(e,a,{enumerable:!0,get:function(){return s[a]}})});const i=new r.BasisTheory;e._instance=i}(mr);const T=crypto,z=e=>e instanceof CryptoKey,Ac=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await T.subtle.digest(r,t))},se=new TextEncoder,Ln=new TextDecoder,ft=2**32;function Te(...e){const t=e.reduce((s,{length:i})=>s+i,0),r=new Uint8Array(t);let n=0;for(const s of e)r.set(s,n),n+=s.length;return r}function vc(e,t){return Te(se.encode(e),new Uint8Array([0]),t)}function Qt(e,t,r){if(t<0||t>=ft)throw new RangeError(`value must be >= 0 and <= ${ft-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function Cc(e){const t=Math.floor(e/ft),r=e%ft,n=new Uint8Array(8);return Qt(n,t,0),Qt(n,r,4),n}function er(e){const t=new Uint8Array(4);return Qt(t,e),t}function tr(e){return Te(er(e.length),e)}async function Oc(e,t,r){const n=Math.ceil((t>>3)/32),s=new Uint8Array(n*32);for(let i=0;i<n;i++){const a=new Uint8Array(4+e.length+r.length);a.set(er(i+1)),a.set(e,4),a.set(r,4+e.length),s.set(await Ac("sha256",a),i*32)}return s.slice(0,t>>3)}const Pc=e=>{let t=e;typeof t=="string"&&(t=se.encode(t));const r=32768,n=[];for(let s=0;s<t.length;s+=r)n.push(String.fromCharCode.apply(null,t.subarray(s,s+r)));return btoa(n.join(""))},L=e=>Pc(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Bc=e=>{const t=atob(e),r=new Uint8Array(t.length);for(let n=0;n<t.length;n++)r[n]=t.charCodeAt(n);return r},Mn=e=>{let t=e;t instanceof Uint8Array&&(t=Ln.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Bc(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class In extends Error{static get code(){return"ERR_JOSE_GENERIC"}constructor(t){var r;super(t),this.code="ERR_JOSE_GENERIC",this.name=this.constructor.name,(r=Error.captureStackTrace)==null||r.call(Error,this,this.constructor)}}class N extends In{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class Y extends In{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}const rr=T.getRandomValues.bind(T);function $n(e){switch(e){case"A128GCM":case"A128GCMKW":case"A192GCM":case"A192GCMKW":case"A256GCM":case"A256GCMKW":return 96;case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return 128;default:throw new N(`Unsupported JWE Algorithm: ${e}`)}}const xc=e=>rr(new Uint8Array($n(e)>>3)),Nc=(e,t)=>{if(t.length<<3!==$n(e))throw new Y("Invalid Initialization Vector length")},qn=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new Y(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function X(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function ht(e,t){return e.name===t}function jc(e){return parseInt(e.name.slice(4),10)}function Dc(e,t){if(t.length&&!t.some(r=>e.usages.includes(r))){let r="CryptoKey does not support this operation, its usages must include ";if(t.length>2){const n=t.pop();r+=`one of ${t.join(", ")}, or ${n}.`}else t.length===2?r+=`one of ${t[0]} or ${t[1]}.`:r+=`${t[0]}.`;throw new TypeError(r)}}function de(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!ht(e.algorithm,"AES-GCM"))throw X("AES-GCM");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw X(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!ht(e.algorithm,"AES-KW"))throw X("AES-KW");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw X(n,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw X("ECDH, X25519, or X448")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!ht(e.algorithm,"PBKDF2"))throw X("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!ht(e.algorithm,"RSA-OAEP"))throw X("RSA-OAEP");const n=parseInt(t.slice(9),10)||1;if(jc(e.algorithm.hash)!==n)throw X(`SHA-${n}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}Dc(e,r)}function Kn(e,t,...r){var n;if(r.length>2){const s=r.pop();e+=`one of type ${r.join(", ")}, or ${s}.`}else r.length===2?e+=`one of type ${r[0]} or ${r[1]}.`:e+=`of type ${r[0]}.`;return t==null?e+=` Received ${t}`:typeof t=="function"&&t.name?e+=` Received function ${t.name}`:typeof t=="object"&&t!=null&&(n=t.constructor)!=null&&n.name&&(e+=` Received an instance of ${t.constructor.name}`),e}const W=(e,...t)=>Kn("Key must be ",e,...t);function Fn(e,t,...r){return Kn(`Key for the ${e} algorithm must be `,t,...r)}const zn=e=>z(e)?!0:(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",$=["CryptoKey"],Uc=(...e)=>{const t=e.filter(Boolean);if(t.length===0||t.length===1)return!0;let r;for(const n of t){const s=Object.keys(n);if(!r||r.size===0){r=new Set(s);continue}for(const i of s){if(r.has(i))return!1;r.add(i)}}return!0};function Hc(e){return typeof e=="object"&&e!==null}function Lc(e){if(!Hc(e)||Object.prototype.toString.call(e)!=="[object Object]")return!1;if(Object.getPrototypeOf(e)===null)return!0;let t=e;for(;Object.getPrototypeOf(t)!==null;)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}const Wn=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function Mc(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function Ic(e,t,r){if(z(e))return de(e,t,r),e;if(e instanceof Uint8Array)return T.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError(W(e,...$,"Uint8Array"))}const nr=async(e,t,r)=>{const n=await Ic(t,e,"wrapKey");Mc(n,e);const s=await T.subtle.importKey("raw",r,...Wn);return new Uint8Array(await T.subtle.wrapKey("raw",s,n,"AES-KW"))};async function $c(e,t,r,n,s=new Uint8Array(0),i=new Uint8Array(0)){if(!z(e))throw new TypeError(W(e,...$));if(de(e,"ECDH"),!z(t))throw new TypeError(W(t,...$));de(t,"ECDH","deriveBits");const a=Te(tr(se.encode(r)),tr(s),tr(i),er(n));let o;e.algorithm.name==="X25519"?o=256:e.algorithm.name==="X448"?o=448:o=Math.ceil(parseInt(e.algorithm.namedCurve.substr(-3),10)/8)<<3;const d=new Uint8Array(await T.subtle.deriveBits({name:e.algorithm.name,public:e},t,o));return Oc(d,n,a)}async function qc(e){if(!z(e))throw new TypeError(W(e,...$));return T.subtle.generateKey(e.algorithm,!0,["deriveBits"])}function Kc(e){if(!z(e))throw new TypeError(W(e,...$));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||e.algorithm.name==="X25519"||e.algorithm.name==="X448"}function Fc(e){if(!(e instanceof Uint8Array)||e.length<8)throw new Y("PBES2 Salt Input must be 8 or more octets")}function zc(e,t){if(e instanceof Uint8Array)return T.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if(z(e))return de(e,t,"deriveBits","deriveKey"),e;throw new TypeError(W(e,...$,"Uint8Array"))}async function Wc(e,t,r,n){Fc(e);const s=vc(t,e),i=parseInt(t.slice(13,16),10),a={hash:`SHA-${t.slice(8,11)}`,iterations:r,name:"PBKDF2",salt:s},o={length:i,name:"AES-KW"},d=await zc(n,t);if(d.usages.includes("deriveBits"))return new Uint8Array(await T.subtle.deriveBits(a,d,i));if(d.usages.includes("deriveKey"))return T.subtle.deriveKey(a,d,o,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}const kc=async(e,t,r,n=2048,s=rr(new Uint8Array(16)))=>{const i=await Wc(s,e,n,t);return{encryptedKey:await nr(e.slice(-6),i,r),p2c:n,p2s:L(s)}};function kn(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new N(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}const Vc=(e,t)=>{if(e.startsWith("RS")||e.startsWith("PS")){const{modulusLength:r}=t.algorithm;if(typeof r!="number"||r<2048)throw new TypeError(`${e} requires key modulusLength to be 2048 bits or larger`)}},Gc=async(e,t,r)=>{if(!z(t))throw new TypeError(W(t,...$));if(de(t,e,"encrypt","wrapKey"),Vc(e,t),t.usages.includes("encrypt"))return new Uint8Array(await T.subtle.encrypt(kn(e),t,r));if(t.usages.includes("wrapKey")){const n=await T.subtle.importKey("raw",r,...Wn);return new Uint8Array(await T.subtle.wrapKey("raw",n,t,kn(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')};function Jc(e){let t,r;switch(e.kty){case"RSA":{switch(e.alg){case"PS256":case"PS384":case"PS512":t={name:"RSA-PSS",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RS256":case"RS384":case"RS512":t={name:"RSASSA-PKCS1-v1_5",hash:`SHA-${e.alg.slice(-3)}`},r=e.d?["sign"]:["verify"];break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":t={name:"RSA-OAEP",hash:`SHA-${parseInt(e.alg.slice(-3),10)||1}`},r=e.d?["decrypt","unwrapKey"]:["encrypt","wrapKey"];break;default:throw new N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"EC":{switch(e.alg){case"ES256":t={name:"ECDSA",namedCurve:"P-256"},r=e.d?["sign"]:["verify"];break;case"ES384":t={name:"ECDSA",namedCurve:"P-384"},r=e.d?["sign"]:["verify"];break;case"ES512":t={name:"ECDSA",namedCurve:"P-521"},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:"ECDH",namedCurve:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}case"OKP":{switch(e.alg){case"EdDSA":t={name:e.crv},r=e.d?["sign"]:["verify"];break;case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":t={name:e.crv},r=e.d?["deriveBits"]:[];break;default:throw new N('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new N('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}const Vn=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=Jc(e),n=[t,e.ext??!1,e.key_ops??r],s={...e};return delete s.alg,delete s.use,T.subtle.importKey("jwk",s,...n)},Gn=e=>Mn(e);let sr,ir;const Jn=e=>(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",Yn=async(e,t,r,n)=>{let s=e.get(t);if(s!=null&&s[n])return s[n];const i=await Vn({...r,alg:n});return s?s[n]=i:e.set(t,{[n]:i}),i},ar={normalizePublicKey:(e,t)=>{if(Jn(e)){let r=e.export({format:"jwk"});return delete r.d,delete r.dp,delete r.dq,delete r.p,delete r.q,delete r.qi,r.k?Gn(r.k):(ir||(ir=new WeakMap),Yn(ir,e,r,t))}return e},normalizePrivateKey:(e,t)=>{if(Jn(e)){let r=e.export({format:"jwk"});return r.k?Gn(r.k):(sr||(sr=new WeakMap),Yn(sr,e,r,t))}return e}};function Xn(e){switch(e){case"A128GCM":return 128;case"A192GCM":return 192;case"A256GCM":case"A128CBC-HS256":return 256;case"A192CBC-HS384":return 384;case"A256CBC-HS512":return 512;default:throw new N(`Unsupported JWE Algorithm: ${e}`)}}const Re=e=>rr(new Uint8Array(Xn(e)>>3));async function Yc(e,t){if(!Lc(e))throw new TypeError("JWK must be an object");switch(e.kty){case"oct":if(typeof e.k!="string"||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return Mn(e.k);case"RSA":if(e.oth!==void 0)throw new N('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return Vn({...e,alg:t});default:throw new N('Unsupported "kty" (Key Type) Parameter value')}}const pt=e=>e==null?void 0:e[Symbol.toStringTag],Xc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!zn(t))throw new TypeError(Fn(e,t,...$,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${pt(t)} instances for symmetric algorithms must be of type "secret"`)}},Zc=(e,t,r)=>{if(!zn(t))throw new TypeError(Fn(e,t,...$));if(t.type==="secret")throw new TypeError(`${pt(t)} instances for asymmetric algorithms must not be of type "secret"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${pt(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${pt(t)} instances for asymmetric algorithm encryption must be of type "public"`)},Qc=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?Xc(e,t):Zc(e,t,r)};async function eu(e,t,r,n,s){if(!(r instanceof Uint8Array))throw new TypeError(W(r,"Uint8Array"));const i=parseInt(e.slice(1,4),10),a=await T.subtle.importKey("raw",r.subarray(i>>3),"AES-CBC",!1,["encrypt"]),o=await T.subtle.importKey("raw",r.subarray(0,i>>3),{hash:`SHA-${i<<1}`,name:"HMAC"},!1,["sign"]),d=new Uint8Array(await T.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),u=Te(s,n,d,Cc(s.length<<3)),l=new Uint8Array((await T.subtle.sign("HMAC",o,u)).slice(0,i>>3));return{ciphertext:d,tag:l,iv:n}}async function tu(e,t,r,n,s){let i;r instanceof Uint8Array?i=await T.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(de(r,e,"encrypt"),i=r);const a=new Uint8Array(await T.subtle.encrypt({additionalData:s,iv:n,name:"AES-GCM",tagLength:128},i,t)),o=a.slice(-16);return{ciphertext:a.slice(0,-16),tag:o,iv:n}}const Zn=async(e,t,r,n,s)=>{if(!z(r)&&!(r instanceof Uint8Array))throw new TypeError(W(r,...$,"Uint8Array"));switch(n?Nc(e,n):n=xc(e),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&qn(r,parseInt(e.slice(-3),10)),eu(e,t,r,n,s);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&qn(r,parseInt(e.slice(1,4),10)),tu(e,t,r,n,s);default:throw new N("Unsupported JWE Content Encryption Algorithm")}};async function ru(e,t,r,n){const s=e.slice(0,7),i=await Zn(s,r,t,n,new Uint8Array(0));return{encryptedKey:i.ciphertext,iv:L(i.iv),tag:L(i.tag)}}function nu(e,t,r,n,s){if(s.crit!==void 0&&(n==null?void 0:n.crit)===void 0)throw new e('"crit" (Critical) Header Parameter MUST be integrity protected');if(!n||n.crit===void 0)return new Set;if(!Array.isArray(n.crit)||n.crit.length===0||n.crit.some(a=>typeof a!="string"||a.length===0))throw new e('"crit" (Critical) Header Parameter MUST be an array of non-empty strings when present');let i;r!==void 0?i=new Map([...Object.entries(r),...t.entries()]):i=t;for(const a of n.crit){if(!i.has(a))throw new N(`Extension Header Parameter "${a}" is not recognized`);if(s[a]===void 0)throw new e(`Extension Header Parameter "${a}" is missing`);if(i.get(a)&&n[a]===void 0)throw new e(`Extension Header Parameter "${a}" MUST be integrity protected`)}return new Set(n.crit)}const su=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:L(e)};if(!z(e))throw new TypeError(W(e,...$,"Uint8Array"));if(!e.extractable)throw new TypeError("non-extractable CryptoKey cannot be exported as a JWK");const{ext:t,key_ops:r,alg:n,use:s,...i}=await T.subtle.exportKey("jwk",e);return i};async function iu(e){return su(e)}async function au(e,t,r,n,s={}){var d;let i,a,o;switch(Qc(e,r,"encrypt"),r=await((d=ar.normalizePublicKey)==null?void 0:d.call(ar,r,e))||r,e){case"dir":{o=r;break}case"ECDH-ES":case"ECDH-ES+A128KW":case"ECDH-ES+A192KW":case"ECDH-ES+A256KW":{if(!Kc(r))throw new N("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:u,apv:l}=s;let{epk:f}=s;f||(f=(await qc(r)).privateKey);const{x:b,y:w,crv:h,kty:E}=await iu(f),p=await $c(r,f,e==="ECDH-ES"?t:e,e==="ECDH-ES"?Xn(t):parseInt(e.slice(-5,-2),10),u,l);if(a={epk:{x:b,crv:h,kty:E}},E==="EC"&&(a.epk.y=w),u&&(a.apu=L(u)),l&&(a.apv=L(l)),e==="ECDH-ES"){o=p;break}o=n||Re(t);const S=e.slice(-6);i=await nr(S,p,o);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{o=n||Re(t),i=await Gc(e,r,o);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{o=n||Re(t);const{p2c:u,p2s:l}=s;({encryptedKey:i,...a}=await kc(e,r,o,u,l));break}case"A128KW":case"A192KW":case"A256KW":{o=n||Re(t),i=await nr(e,r,o);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{o=n||Re(t);const{iv:u}=s;({encryptedKey:i,...a}=await ru(e,r,o,u));break}default:throw new N('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:o,encryptedKey:i,parameters:a}}const ou=Symbol();class cu{constructor(t){if(!(t instanceof Uint8Array))throw new TypeError("plaintext must be an instance of Uint8Array");this._plaintext=t}setKeyManagementParameters(t){if(this._keyManagementParameters)throw new TypeError("setKeyManagementParameters can only be called once");return this._keyManagementParameters=t,this}setProtectedHeader(t){if(this._protectedHeader)throw new TypeError("setProtectedHeader can only be called once");return this._protectedHeader=t,this}setSharedUnprotectedHeader(t){if(this._sharedUnprotectedHeader)throw new TypeError("setSharedUnprotectedHeader can only be called once");return this._sharedUnprotectedHeader=t,this}setUnprotectedHeader(t){if(this._unprotectedHeader)throw new TypeError("setUnprotectedHeader can only be called once");return this._unprotectedHeader=t,this}setAdditionalAuthenticatedData(t){return this._aad=t,this}setContentEncryptionKey(t){if(this._cek)throw new TypeError("setContentEncryptionKey can only be called once");return this._cek=t,this}setInitializationVector(t){if(this._iv)throw new TypeError("setInitializationVector can only be called once");return this._iv=t,this}async encrypt(t,r){if(!this._protectedHeader&&!this._unprotectedHeader&&!this._sharedUnprotectedHeader)throw new Y("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!Uc(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new Y("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(nu(Y,new Map,r==null?void 0:r.crit,this._protectedHeader,n),n.zip!==void 0)throw new N('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:s,enc:i}=n;if(typeof s!="string"||!s)throw new Y('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof i!="string"||!i)throw new Y('JWE "enc" (Encryption Algorithm) Header Parameter missing or invalid');let a;if(this._cek&&(s==="dir"||s==="ECDH-ES"))throw new TypeError(`setContentEncryptionKey cannot be called with JWE "alg" (Algorithm) Header ${s}`);let o;{let E;({cek:o,encryptedKey:a,parameters:E}=await au(s,i,t,this._cek,this._keyManagementParameters)),E&&(r&&ou in r?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...E}:this.setUnprotectedHeader(E):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...E}:this.setProtectedHeader(E))}let d,u,l;this._protectedHeader?u=se.encode(L(JSON.stringify(this._protectedHeader))):u=se.encode(""),this._aad?(l=L(this._aad),d=Te(u,se.encode("."),se.encode(l))):d=u;const{ciphertext:f,tag:b,iv:w}=await Zn(i,this._plaintext,o,this._iv,d),h={ciphertext:L(f)};return w&&(h.iv=L(w)),b&&(h.tag=L(b)),a&&(h.encrypted_key=L(a)),l&&(h.aad=l),this._protectedHeader&&(h.protected=Ln.decode(u)),this._sharedUnprotectedHeader&&(h.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(h.header=this._unprotectedHeader),h}}class uu{constructor(t){this._flattened=new cu(t)}setContentEncryptionKey(t){return this._flattened.setContentEncryptionKey(t),this}setInitializationVector(t){return this._flattened.setInitializationVector(t),this}setProtectedHeader(t){return this._flattened.setProtectedHeader(t),this}setKeyManagementParameters(t){return this._flattened.setKeyManagementParameters(t),this}async encrypt(t,r){const n=await this._flattened.encrypt(t,r);return[n.protected,n.encrypted_key,n.iv,n.ciphertext,n.tag].join(".")}}const or={base:{":disabled":{backgroundColor:"transparent"}}},lu={mask:{number:"{{ data.number | card_mask: 'true', 'true' }}",expiration_month:"{{ data.expiration_month }}",expiration_year:"{{ data.expiration_year }}"}},du="DOM Element was not found",Qn=e=>e!=null;var fu={VITE_PACKAGE_VERSION:"v3.5.1",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const hu="v3.5.1";class Ae{constructor(t,r){if(Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"IFRAME_BASE_URL",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"iframe",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"subscriptions",{enumerable:!0,configurable:!0,writable:!0,value:{ready:[],blur:[],focus:[],keydown:[],change:[]}}),Object.defineProperty(this,"update",{enumerable:!0,configurable:!0,writable:!0,value:async({...n})=>{this.iframe&&Qn(n.height)&&(this.iframe.height=n.height),this.iframePostMessage({type:"update",data:{...n,value:n.value?this.putValue(n.value)??void 0:void 0}})}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"clear"})}}),Object.defineProperty(this,"focus",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"focus"})}}),Object.defineProperty(this,"blur",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.iframePostMessage({type:"blur"})}}),Object.defineProperty(this,"unmount",{enumerable:!0,configurable:!0,writable:!0,value:()=>{var n;(n=this.iframe)==null||n.remove(),this.iframe=null}}),this.IFRAME_BASE_URL=fu.VITE_IFRAME_BASE_URL??pu(hu),!this.IFRAME_BASE_URL)throw new Error("IFRAME_BASE_URL not found");r&&cr.set(this,{key:r})}mount(t){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error(du);r.innerHTML=`<iframe width="100%" height="29" src="${this.IFRAME_BASE_URL}?field=${this.type}&origin=${location.origin}"></iframe>`,this.iframe=r.querySelector("iframe");const n=s=>{var i;if(!(s.source!==((i=this.iframe)==null?void 0:i.contentWindow)||s.data.element!==this.type))if(s.data.type==="change"){const a=this.extractValue(s.data.data.value),o={...s.data.data};delete o.value;const d=cr.get(this);d&&(d.value=a),this.emitEvent({...s.data,data:o})}else this.emitEvent(s.data)};return window.addEventListener("message",n),new Promise(s=>{this.on("ready",()=>{this.update(this.options),s()})})}on(t,r){return this.subscriptions[t].push(r),{unsubscribe:()=>this.subscriptions[t].splice(this.subscriptions[t].indexOf(r),1)}}secureValue(t){const r=cr.get(this);return(r==null?void 0:r.key)!==t?null:(r==null?void 0:r.value)??null}emitEvent(t){var r;(r=this.subscriptions[t.type])==null||r.forEach(n=>n(t.data))}iframePostMessage(t){var r,n;(n=(r=this.iframe)==null?void 0:r.contentWindow)==null||n.postMessage(t,this.IFRAME_BASE_URL)}}function pu(e){return`https://${window.HG_IFRAME_HOST??"sdk.hellgate.io"}/web/${e}/iframe/`}const cr=new Map;function ur(e){const[t=null,r=null]=(e??"").split("/").map(n=>Number(n.trim()));return{month:t,year:r&&r>10?+`20${r}`:null}}function lr(e){if(!e)return null;const{month:t,year:r}=e;return[t&&t<10?`0${t}`:t,r&&r>=100?String(r).slice(-2):r].filter(Qn).join(" / ")}class es extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardExpirationDate"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:ur}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:lr})}}function dr(e){return(e==null?void 0:e.replaceAll(" ",""))??null}function ts(e){return e}class rs extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardNumber"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:dr}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:ts})}}class ns extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"card"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t?{number:t.cardNumber?dr(t.cardNumber):null,expiry_date:t.cardExpirationDate?ur(t.cardExpirationDate):null,cvc:t.cardVerificationCode??null}:null}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t?{cardNumber:t.number?t.number:null,cardExpirationDate:t.expiry_date?lr(t.expiry_date):null,cardVerificationCode:t.cvc??null}:null})}}class ss extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"cardVerificationCode"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t})}}class fr extends Ae{constructor(){super(...arguments),Object.defineProperty(this,"type",{enumerable:!0,configurable:!0,writable:!0,value:"text"}),Object.defineProperty(this,"extractValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:t=>t})}}function fe(e,t,r){switch(e){case"card":return new ns(t,r);case"cardNumber":return new rs(t,r);case"cardExpirationDate":return new es(t,r);case"cardVerificationCode":return new ss(t,r);case"text":return new fr(t,r);default:ASSERT_EXHAUSTIVE(e)}}function is(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}function as(e){return[e.issuer_identification_number,"".padEnd(e.account_number_length-e.issuer_identification_number.length-e.account_number_last_four.length,"*"),e.account_number_last_four].join(" ")}class mt{static async init(t){var n;const r=t.isNextAction("tokenize_card")&&((n=t.state)==null?void 0:n.data.provider)==="basis_theory"?await new mr.BasisTheory().init(t.state.data.api_key,{elements:!1}):void 0;return new mt(t,r)}constructor(t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"bt",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:this.createFieldDefaultState()}),Object.defineProperty(this,"cardElements",{enumerable:!0,configurable:!0,writable:!0,value:{}}),Object.defineProperty(this,"textElements",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"cvcOnlyEnabled",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"createForm",{enumerable:!0,configurable:!0,writable:!0,value:(n={})=>{var o;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const s=he.get(this);if(!s)throw new Error("Secure key not found");const i=oe({disabled:!1,autocomplete:"on",style:{...or}},n);if(this.session.isNextAction("refresh_security_code")&&((o=this.session.state)!=null&&o.data)){const d=this.session.state.data;i.cvcOnly=!0,i.value={number:as(d),expiry_date:{month:(d==null?void 0:d.expiry_month)??null,year:(d==null?void 0:d.expiry_year)??null},cvc:null}}const a=fe("card",i,s);return this.cardElements.card={element:a,state:this.createFieldDefaultState()},this.addElementStateListener("card"),a}}),Object.defineProperty(this,"createFormFields",{enumerable:!0,configurable:!0,writable:!0,value:(n={})=>{var w,h;if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const s=he.get(this);if(!s)throw new Error("Secure key not found");const i={disabled:this.cvcOnlyEnabled,autocomplete:"on",style:{...or}},{cardNumber:a={},expiryDate:o={},securityCode:d={},...u}=n,l=fe("cardNumber",{...oe(i,{...u,...a,cvc2Only:this.cvcOnlyEnabled,value:this.session.isNextAction("refresh_security_code")&&((w=this.session.state)!=null&&w.data)?as(this.session.state.data):null})},s),f=fe("cardExpirationDate",{...oe(i,{...u,...o,value:this.session.isNextAction("refresh_security_code")&&((h=this.session.state)!=null&&h.data)?{month:this.session.state.data.expiry_month,year:this.session.state.data.expiry_year}:null})},s),b=fe("cardVerificationCode",{...oe({...i,disabled:!1,autofocus:this.cvcOnlyEnabled},{...u,...d})},s);return this.cardElements={cardNumber:{element:l,state:this.createFieldDefaultState()},cardExpirationDate:{element:f,state:this.createFieldDefaultState()},cardVerificationCode:{element:b,state:this.createFieldDefaultState()}},this.addElementStateListener("cardNumber"),this.addElementStateListener("cardExpirationDate"),this.addElementStateListener("cardVerificationCode"),{cardNumber:l,expiryDate:f,securityCode:b}}}),Object.defineProperty(this,"createTextField",{enumerable:!0,configurable:!0,writable:!0,value:(n={})=>{const s=he.get(this);if(!s)throw new Error("Secure key not found");const i={disabled:!1,autocomplete:"on",style:{...or}},a=fe("text",{...oe(i,{...n})},s);return this.textElements.push(a),a}}),Object.defineProperty(this,"tokenize",{enumerable:!0,configurable:!0,writable:!0,value:async n=>{var d,u;if(((d=this.session.state)==null?void 0:d.next_action)!=="tokenize_card")throw new Error(`The session's next_action='${(u=this.session.state)==null?void 0:u.next_action}'. tokenize() is available only if next_action='tokenize_card'`);const s=this.getFormValue(),i=this.extractAdditionalData(n);if(!s)throw new Error("Form elements must be initialized before tokenization");const a=this.getCardDataValidationError();if(a)throw a;if(!s.number||!s.expiration_month||!s.expiration_year||!s.cvc)throw new Error("Card data is not complete");const o=this.session.state.data;switch(o.provider){case"basis_theory":{if(!this.bt)throw new Error("basis_theory SDK not found");return this.bt.tokenize({type:"card",data:s,...lu}).then(l=>Array.isArray(l)?null:{token_id:l.id,additional_data:i})}case"guardian":return this.encryptCardData({account_number:s.number,expiry_month:s.expiration_month,expiry_year:s.expiration_year,security_code:s.cvc,additional_data:i},o.jwk);default:ASSERT_EXHAUSTIVE(o)}}}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.stateChangeHandlers.push(n),n(this.state)}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(n=>n==null?void 0:n.element.clear()),this.textElements.forEach(n=>n==null?void 0:n.clear())}}),Object.defineProperty(this,"reset",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(n=>n==null?void 0:n.element.unmount()),this.textElements.forEach(n=>n==null?void 0:n.unmount()),this.cardElements={},this.textElements=[]}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.reset()}}),Object.defineProperty(this,"process",{enumerable:!0,configurable:!0,writable:!0,value:async(n={})=>{if(!this.hasFormElements())throw new Error("Card form must be initialized and completed before processing");if(this.session.isNextAction("refresh_security_code"))return this.refreshSecurityCode();this.disableFormElements(!0);const s=await this.tokenize(n).catch(i=>{throw this.disableFormElements(!1),i});if(!s)throw new Error("Tokenization failed");return this.session.completeAction({action:"tokenize_card",result:s}).catch(i=>{if(i instanceof Error)throw i;return{status:"failure",data:i}})}}),he.set(this,is()),this.cvcOnlyEnabled=this.session.isNextAction("refresh_security_code")}async refreshSecurityCode(){const t=this.getFormValue();if(!(t!=null&&t.cvc))throw new Error("cvc field was not filled");if(!this.session.isNextAction("refresh_security_code")||!this.session.state)throw new Error("refreshSecurityCode() is available only if next_action=refresh_security_code");this.disableFormElements(!0);const r=await this.encryptCardData({security_code:t.cvc},this.session.state.data.jwk);return this.session.completeAction({action:"refresh_security_code",result:{...r}}).catch(n=>{if(this.disableFormElements(!1),n instanceof Error)throw n;return{status:"failure",data:n}})}getFormValue(){var a,o,d,u,l;const{card:t,cardNumber:r,cardExpirationDate:n,cardVerificationCode:s}=this.cardElements;let i;if(t){const f=pe(this,t.element);i={number:(f==null?void 0:f.number)??null,expiration_month:((a=f==null?void 0:f.expiry_date)==null?void 0:a.month)??null,expiration_year:((o=f==null?void 0:f.expiry_date)==null?void 0:o.year)??null,cvc:(f==null?void 0:f.cvc)??null}}return r&&n&&s&&(i={number:((d=pe(this,r.element))==null?void 0:d.replaceAll(" ",""))??null,expiration_month:((u=pe(this,n.element))==null?void 0:u.month)??null,expiration_year:((l=pe(this,n.element))==null?void 0:l.year)??null,cvc:pe(this,s.element)}),i}hasFormElements(){return!!Object.keys(this.cardElements).length}disableFormElements(t){Object.values(this.cardElements).forEach(({element:r})=>{r.update({disabled:t})})}extractAdditionalData({cardholder_name:t,billing_address:r={}}){return ae({cardholder_name:me(this,t),billing_address:{line1:me(this,r.line1),line2:me(this,r.line2),line3:me(this,r.line3),city:me(this,r.city),postal_code:me(this,r.postal_code)}})}async encryptCardData(t,r){const n=await Yc(r,"RSA-OAEP"),s=JSON.stringify(t),i=new TextEncoder().encode(s);return{enc_payload:await new uu(i).setProtectedHeader({alg:"RSA-OAEP",enc:"A256GCM"}).encrypt(n)}}addElementStateListener(t){const r=this.cardElements[t];r&&r.element.on("change",n=>{r.state=n,this.updateFormState()})}updateFormState(){const t=this.cvcOnlyEnabled&&this.cardElements.cardVerificationCode?[this.cardElements.cardVerificationCode]:Object.values(this.cardElements);t.length?this.state=t.reduce((r,{state:n})=>(r.valid=!!r.valid&&!!n.valid,r.complete=!!r.complete&&!!n.complete,r.empty=!!r.empty&&!!n.empty,r.error=r.error||n.error,r),{valid:!0,complete:!0,empty:!0,value:null}):this.state=this.createFieldDefaultState(),this.stateChangeHandlers.forEach(r=>r(this.state))}createFieldDefaultState(){return{empty:!0,complete:!1,valid:!1}}getCardDataValidationError(){if(!this.state.complete)return new Error(this.state.error??"Card data is not complete");if(!this.state.valid)return new Error(`Card data is not valid. ${this.state.error}`)}}const he=new Map;function pe(e,t){const r=he.get(e);return r?t.secureValue(r):null}function me(e,t){const r=he.get(e);return t instanceof fr&&r?pe(e,t)??void 0:t}class mu{constructor(t="https://api.hellgate.io",r=new AbortController){Object.defineProperty(this,"abortCtrl",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"baseUrl",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.baseUrl=t.endsWith("/")?t.substring(0,t.length-1):t}getSession(t){return fetch(`${this.baseUrl}/sessions/${t}`,{signal:this.abortCtrl.signal}).then(r=>yt(r))}completeAction(t,r){return fetch(`${this.baseUrl}/sessions/${t}/complete-action`,{method:"POST",headers:{"Content-Type":"application/json"},mode:"cors",body:JSON.stringify(r),signal:this.abortCtrl.signal}).then(n=>yt(n))}cancelAll(){this.abortCtrl.abort()}}const Eu=2e3;class yu{constructor(t,r){Object.defineProperty(this,"id",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"api",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"state",{enumerable:!0,configurable:!0,writable:!0,value:null}),Object.defineProperty(this,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"onCloseHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"pollingTimer",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"init",{enumerable:!0,configurable:!0,writable:!0,value:async()=>new Promise((n,s)=>{const i=this.onStateChange(a=>{a.next_action!=="wait"&&(n(a),i())});this.updateSessionState().catch(a=>{a instanceof Response&&a.status===404&&s(new Error(`Session ${this.id} doesn't exist or has expired`)),s(a)})})}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:n=>(this.stateChangeHandlers.push(n),this.state&&n(this.state),()=>this.stateChangeHandlers=this.stateChangeHandlers.filter(s=>s!==n))}),Object.defineProperty(this,"onClose",{enumerable:!0,configurable:!0,writable:!0,value:n=>{var s;return((s=this.state)==null?void 0:s.next_action)===null?(n(this.state),()=>{}):(this.onCloseHandlers.push(n),()=>this.onCloseHandlers=this.onCloseHandlers.filter(i=>i!==n))}}),Object.defineProperty(this,"completeAction",{enumerable:!0,configurable:!0,writable:!0,value:async n=>{const s=this.state;return new Promise((i,a)=>{const o=this.onStateChange(d=>{d.next_action!==(s==null?void 0:s.next_action)&&d.next_action===null&&(i(d),o())});this.api.completeAction(this.id,n).then(d=>this.newStateHandle(d,a)).catch(async d=>a(await bu(d)))})}}),Object.defineProperty(this,"completeSession",{enumerable:!0,configurable:!0,writable:!0,value:n=>{this.onCloseHandlers.forEach(s=>s(n)),this.stop()}}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.stop(),this.api.cancelAll()}})}isNextAction(t){var r;return((r=this.state)==null?void 0:r.next_action)===t}stop(){window.clearTimeout(this.pollingTimer),this.stateChangeHandlers=[],this.onCloseHandlers=[]}async updateSessionState(t){const r=await this.api.getSession(this.id);this.newStateHandle(r,t)}newStateHandle(t,r){var n;switch(!t.next_action&&t.status&&(t.next_action=null),t.next_action){case"wait":{window.clearTimeout(this.pollingTimer),this.pollingTimer=window.setTimeout(()=>this.updateSessionState(r).catch(s=>{s instanceof Response&&s.status===404&&(r==null||r(new Error(`Session ${this.id} has expired`)))}),Eu);break}}t.next_action!==((n=this.state)==null?void 0:n.next_action)&&this.stateChangeHandlers.forEach(s=>s(t)),t.next_action===null&&this.completeSession(t),this.state=t}}async function bu(e){return!e.ok&&e.status>=400&&e.status<=500?e.json():e}const _u={base_url:"https://api.hellgate.io"};class hr{constructor(t,r){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"paymentFlowHandlers",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"dispose",{enumerable:!0,configurable:!0,writable:!0,value:()=>{this.session.dispose(),Object.values(this.paymentFlowHandlers).forEach(n=>n==null?void 0:n.dispose())}})}use(t){return this.paymentFlowHandlers[t]}static async init(t,r={}){const{session:n,cardHandler:s,handler3DS:i}=await this.initHandlers(t,r);return new hr(n,{CARD:s,"3DS":i})}static async initHandlers(t,r){const n={..._u,...r},s=new mu(n.base_url,n.abortCtrl),i=new yu(t,s);await i.init();const a=i.isNextAction("tokenize_card")||i.isNextAction("refresh_security_code")?await this.createCardHandler(i):void 0,o=this.create3DSHandler(i,r);return{session:i,cardHandler:a,handler3DS:o}}static createCardHandler(t){return mt.init(t)}static create3DSHandler(t,r){return new pr(t,{domContainer:r.challenge_3ds_container,labelText:r.challenge_3ds_label_text})}}v.CardElement=ns,v.CardExpirationDateElement=es,v.CardNumberElement=rs,v.CardVerificationCodeElement=ss,v.Hellgate=hr,v.Hellgate3DSHandler=pr,v.HellgateCardHandler=mt,v.TextElement=fr,v.createElement=fe,v.extractCardNumberValue=dr,v.extractExpiryDateValue=ur,v.putCardNumberValue=ts,v.putExpiryDateValue=lr,v.uid=is,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"})});globalThis.HellgateSDK&&(globalThis.Hellgate=globalThis.HellgateSDK.Hellgate,delete globalThis.HellgateSDK);