@starfish-codes/hellgate 3.1.0 → 3.1.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,5 +1,5 @@
1
- (function(A,Q){typeof exports=="object"&&typeof module<"u"?Q(exports):typeof define=="function"&&define.amd?define(["exports"],Q):(A=typeof globalThis<"u"?globalThis:A||self,Q(A.HellgateSDK={}))})(this,function(A){"use strict";function Q(e){return Array.isArray(e)?e.filter(Boolean):Object.fromEntries(Object.entries(e).map(([t,r])=>[t,typeof r=="object"&&r&&!Array.isArray(r)?Q(r):r]).filter(([t,r])=>typeof r=="object"&&r&&!Array.isArray(r)?!!Object.keys(r).length:r!=null&&r!=null))}function ee(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]=ee(i,a))}return r}function ct(e){if(!e.ok)throw e;return e.json()}const qn=2e3;class nr{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??ut(),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=ut();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=ut(),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(d=>{const c=h=>{h.source===i.contentWindow&&d(h.data)};window.addEventListener("message",c),this.disposers.push(()=>window.removeEventListener("message",c))}),l=new Promise(d=>{const c=this.startAuthResultPolling(r,h=>{h.event==="AuthResultReady"&&(c(),d({requestor_trans_id:h.threeDSRequestorTransID,event:h.event}))})});Promise.any([o,l]).then(d=>{this.session.completeAction({action:"3ds_challenge",result:d})})}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=>ct(n)).then(n=>{this.startAuthResultPolling(t,r),r(n)}).catch(()=>{}),qn),()=>window.clearTimeout(this.resultPollingTimer)}}function ut(){return document.body}var Fn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function zn(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 sr={},we={},te={};Object.defineProperty(te,"__esModule",{value:!0}),te.makeRequestWithoutElementsPayloadCheck=te.makeRequestWithElementsPayloadCheck=void 0;function Wn(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 ir extends Wn(Error){constructor(t){super(t),this.name="NoElementsError"}}const kn=(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 ir(`${i} Use a regular HTTP client if no elements are needed.`)};te.makeRequestWithElementsPayloadCheck=kn;const Vn=(e,t,r,n={})=>{if(e)return e.client[t](r,n);throw new ir("Elements not initialized. Use a regular HTTP client if no elements are needed.")};te.makeRequestWithoutElementsPayloadCheck=Vn;var ar={},Se={},P={},b={};Object.defineProperty(b,"__esModule",{value:!0}),b.USER_AGENT_HEADER=b.USER_AGENT_CLIENT=b.MERGE_CONTENT_TYPE=b.DEFAULT_ELEMENTS_BASE_URL=b.DEFAULT_BASE_URL=b.CONTENT_TYPE_HEADER=b.CLIENT_USER_AGENT_HEADER=b.CLIENT_BASE_PATHS=b.BT_TRANSACTION_ID_HEADER=b.BT_TRACE_ID_HEADER=b.BT_IDEMPOTENCY_KEY_HEADER=b.BT_EXPOSE_PROXY_RESPONSE_HEADER=b.BROWSER_LIST=b.API_KEY_HEADER=void 0;const Gn="BT-API-KEY";b.API_KEY_HEADER=Gn;const Jn="bt-trace-id";b.BT_TRACE_ID_HEADER=Jn;const Yn="bt-idempotency-key";b.BT_IDEMPOTENCY_KEY_HEADER=Yn;const Xn="BT-EXPOSE-RAW-PROXY-RESPONSE";b.BT_EXPOSE_PROXY_RESPONSE_HEADER=Xn;const Zn="BT-TRANSACTION-ID";b.BT_TRANSACTION_ID_HEADER=Zn;const Qn="Content-Type";b.CONTENT_TYPE_HEADER=Qn;const es="application/merge-patch+json";b.MERGE_CONTENT_TYPE=es;const ts="User-Agent";b.USER_AGENT_HEADER=ts;const rs="BT-CLIENT-USER-AGENT";b.CLIENT_USER_AGENT_HEADER=rs;const ns="BasisTheoryJS";b.USER_AGENT_CLIENT=ns;const ss="https://api.basistheory.com";b.DEFAULT_BASE_URL=ss;const is="https://js.basistheory.com/hosted-elements";b.DEFAULT_ELEMENTS_BASE_URL=is;const as={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"};b.CLIENT_BASE_PATHS=as;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"}];b.BROWSER_LIST=os;var m={};function or(e,t){return function(){return e.apply(t,arguments)}}const{toString:cs}=Object.prototype,{getPrototypeOf:lt}=Object,Te=(e=>t=>{const r=cs.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),H=e=>(e=e.toLowerCase(),t=>Te(t)===e),Ae=e=>t=>typeof t===e,{isArray:re}=Array,le=Ae("undefined");function us(e){return e!==null&&!le(e)&&e.constructor!==null&&!le(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const cr=H("ArrayBuffer");function ls(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&cr(e.buffer),t}const ds=Ae("string"),x=Ae("function"),ur=Ae("number"),Re=e=>e!==null&&typeof e=="object",fs=e=>e===!0||e===!1,ve=e=>{if(Te(e)!=="object")return!1;const t=lt(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},hs=H("Date"),ps=H("File"),ms=H("Blob"),Es=H("FileList"),ys=e=>Re(e)&&x(e.pipe),bs=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x(e.append)&&((t=Te(e))==="formdata"||t==="object"&&x(e.toString)&&e.toString()==="[object FormData]"))},_s=H("URLSearchParams"),gs=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function de(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,s;if(typeof e!="object"&&(e=[e]),re(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 lr(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 dr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:Fn,fr=e=>!le(e)&&e!==dr;function dt(){const{caseless:e}=fr(this)&&this||{},t={},r=(n,s)=>{const i=e&&lr(t,s)||s;ve(t[i])&&ve(n)?t[i]=dt(t[i],n):ve(n)?t[i]=dt({},n):re(n)?t[i]=n.slice():t[i]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&de(arguments[n],r);return t}const ws=(e,t,r,{allOwnKeys:n}={})=>(de(t,(s,i)=>{r&&x(s)?e[i]=or(s,r):e[i]=s},{allOwnKeys:n}),e),Ss=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ts=(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)},As=(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&&lt(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},Rs=(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},vs=e=>{if(!e)return null;if(re(e))return e;let t=e.length;if(!ur(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},Os=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&lt(Uint8Array)),Cs=(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])}},Ps=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Bs=H("HTMLFormElement"),xs=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),hr=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),js=H("RegExp"),pr=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};de(r,(s,i)=>{let a;(a=t(s,i,e))!==!1&&(n[i]=a||s)}),Object.defineProperties(e,n)},Ns=e=>{pr(e,(t,r)=>{if(x(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(x(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+"'")})}})},Ds=(e,t)=>{const r={},n=s=>{s.forEach(i=>{r[i]=!0})};return re(e)?n(e):n(String(e).split(t)),r},Hs=()=>{},Us=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ft="abcdefghijklmnopqrstuvwxyz",mr="0123456789",Er={DIGIT:mr,ALPHA:ft,ALPHA_DIGIT:ft+ft.toUpperCase()+mr},Ms=(e=16,t=Er.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function Ls(e){return!!(e&&x(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const Is=e=>{const t=new Array(10),r=(n,s)=>{if(Re(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[s]=n;const i=re(n)?[]:{};return de(n,(a,o)=>{const l=r(a,s+1);!le(l)&&(i[o]=l)}),t[s]=void 0,i}}return n};return r(e,0)},$s=H("AsyncFunction");var u={isArray:re,isArrayBuffer:cr,isBuffer:us,isFormData:bs,isArrayBufferView:ls,isString:ds,isNumber:ur,isBoolean:fs,isObject:Re,isPlainObject:ve,isUndefined:le,isDate:hs,isFile:ps,isBlob:ms,isRegExp:js,isFunction:x,isStream:ys,isURLSearchParams:_s,isTypedArray:Os,isFileList:Es,forEach:de,merge:dt,extend:ws,trim:gs,stripBOM:Ss,inherits:Ts,toFlatObject:As,kindOf:Te,kindOfTest:H,endsWith:Rs,toArray:vs,forEachEntry:Cs,matchAll:Ps,isHTMLForm:Bs,hasOwnProperty:hr,hasOwnProp:hr,reduceDescriptors:pr,freezeMethods:Ns,toObjectSet:Ds,toCamelCase:xs,noop:Hs,toFiniteNumber:Us,findKey:lr,global:dr,isContextDefined:fr,ALPHABET:Er,generateString:Ms,isSpecCompliantForm:Ls,toJSONObject:Is,isAsyncFn:$s,isThenable:e=>e&&(Re(e)||x(e))&&x(e.then)&&x(e.catch)};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)}u.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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const yr=y.prototype,br={};["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=>{br[e]={value:e}}),Object.defineProperties(y,br),Object.defineProperty(yr,"isAxiosError",{value:!0}),y.from=(e,t,r,n,s,i)=>{const a=Object.create(yr);return u.toFlatObject(e,a,function(l){return l!==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 Ks=null;function ht(e){return u.isPlainObject(e)||u.isArray(e)}function _r(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function gr(e,t,r){return e?e.concat(t).map(function(s,i){return s=_r(s),!r&&i?"["+s+"]":s}).join(r?".":""):t}function qs(e){return u.isArray(e)&&!e.some(ht)}const Fs=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function Oe(e,t,r){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=u.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,R){return!u.isUndefined(R[p])});const n=r.metaTokens,s=r.visitor||c,i=r.dots,a=r.indexes,l=(r.Blob||typeof Blob<"u"&&Blob)&&u.isSpecCompliantForm(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function d(f){if(f===null)return"";if(u.isDate(f))return f.toISOString();if(!l&&u.isBlob(f))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(f)||u.isTypedArray(f)?l&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function c(f,p,R){let D=f;if(f&&!R&&typeof f=="object"){if(u.endsWith(p,"{}"))p=n?p:p.slice(0,-2),f=JSON.stringify(f);else if(u.isArray(f)&&qs(f)||(u.isFileList(f)||u.endsWith(p,"[]"))&&(D=u.toArray(f)))return p=_r(p),D.forEach(function(ot,Lc){!(u.isUndefined(ot)||ot===null)&&t.append(a===!0?gr([p],Lc,i):a===null?p:p+"[]",d(ot))}),!1}return ht(f)?!0:(t.append(gr(R,p,i),d(f)),!1)}const h=[],E=Object.assign(Fs,{defaultVisitor:c,convertValue:d,isVisitable:ht});function g(f,p){if(!u.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+p.join("."));h.push(f),u.forEach(f,function(D,q){(!(u.isUndefined(D)||D===null)&&s.call(t,D,u.isString(q)?q.trim():q,p,E))===!0&&g(D,p?p.concat(q):[q])}),h.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return g(e),t}function wr(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function pt(e,t){this._pairs=[],e&&Oe(e,this,t)}const Sr=pt.prototype;Sr.append=function(t,r){this._pairs.push([t,r])},Sr.toString=function(t){const r=t?function(n){return t.call(this,n,wr)}:wr;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function zs(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Tr(e,t,r){if(!t)return e;const n=r&&r.encode||zs,s=r&&r.serialize;let i;if(s?i=s(t,r):i=u.isURLSearchParams(t)?t.toString():new pt(t,r).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Ws{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){u.forEach(this.handlers,function(n){n!==null&&t(n)})}}var Ar=Ws,Rr={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},ks=typeof URLSearchParams<"u"?URLSearchParams:pt,Vs=typeof FormData<"u"?FormData:null,Gs=typeof Blob<"u"?Blob:null,Js={isBrowser:!0,classes:{URLSearchParams:ks,FormData:Vs,Blob:Gs},protocols:["http","https","file","blob","url","data"]};const vr=typeof window<"u"&&typeof document<"u",Ys=(e=>vr&&["ReactNative","NativeScript","NS"].indexOf(e)<0)(typeof navigator<"u"&&navigator.product),Xs=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function";var Zs=Object.freeze({__proto__:null,hasBrowserEnv:vr,hasStandardBrowserWebWorkerEnv:Xs,hasStandardBrowserEnv:Ys}),U={...Zs,...Js};function Qs(e,t){return Oe(e,new U.classes.URLSearchParams,Object.assign({visitor:function(r,n,s,i){return U.isNode&&u.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function ei(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ti(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 Or(e){function t(r,n,s,i){let a=r[i++];const o=Number.isFinite(+a),l=i>=r.length;return a=!a&&u.isArray(s)?s.length:a,l?(u.hasOwnProp(s,a)?s[a]=[s[a],n]:s[a]=n,!o):((!s[a]||!u.isObject(s[a]))&&(s[a]=[]),t(r,n,s[a],i)&&u.isArray(s[a])&&(s[a]=ti(s[a])),!o)}if(u.isFormData(e)&&u.isFunction(e.entries)){const r={};return u.forEachEntry(e,(n,s)=>{t(ei(n),s,r,0)}),r}return null}function ri(e,t,r){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const mt={transitional:Rr,adapter:["xhr","http"],transformRequest:[function(t,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,i=u.isObject(t);if(i&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(Or(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.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 Qs(t,this.formSerializer).toString();if((o=u.isFileList(t))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Oe(o?{"files[]":t}:t,l&&new l,this.formSerializer)}}return i||s?(r.setContentType("application/json",!1),ri(t)):t}],transformResponse:[function(t){const r=this.transitional||mt.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(t&&u.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:U.classes.FormData,Blob:U.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};u.forEach(["delete","get","head","post","put","patch"],e=>{mt.headers[e]={}});var Et=mt;const ni=u.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 si=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]&&ni[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};const Cr=Symbol("internals");function fe(e){return e&&String(e).trim().toLowerCase()}function Ce(e){return e===!1||e==null?e:u.isArray(e)?e.map(Ce):String(e)}function ii(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 ai=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function yt(e,t,r,n,s){if(u.isFunction(n))return n.call(this,t,r);if(s&&(t=r),!!u.isString(t)){if(u.isString(n))return t.indexOf(n)!==-1;if(u.isRegExp(n))return n.test(t)}}function oi(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function ci(e,t){const r=u.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 Pe{constructor(t){t&&this.set(t)}set(t,r,n){const s=this;function i(o,l,d){const c=fe(l);if(!c)throw new Error("header name must be a non-empty string");const h=u.findKey(s,c);(!h||s[h]===void 0||d===!0||d===void 0&&s[h]!==!1)&&(s[h||l]=Ce(o))}const a=(o,l)=>u.forEach(o,(d,c)=>i(d,c,l));return u.isPlainObject(t)||t instanceof this.constructor?a(t,r):u.isString(t)&&(t=t.trim())&&!ai(t)?a(si(t),r):t!=null&&i(r,t,n),this}get(t,r){if(t=fe(t),t){const n=u.findKey(this,t);if(n){const s=this[n];if(!r)return s;if(r===!0)return ii(s);if(u.isFunction(r))return r.call(this,s,n);if(u.isRegExp(r))return r.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=fe(t),t){const n=u.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||yt(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let s=!1;function i(a){if(a=fe(a),a){const o=u.findKey(n,a);o&&(!r||yt(n,n[o],o,r))&&(delete n[o],s=!0)}}return u.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||yt(this,this[i],i,t,!0))&&(delete this[i],s=!0)}return s}normalize(t){const r=this,n={};return u.forEach(this,(s,i)=>{const a=u.findKey(n,i);if(a){r[a]=Ce(s),delete r[i];return}const o=t?oi(i):String(i).trim();o!==i&&delete r[i],r[o]=Ce(s),n[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return u.forEach(this,(n,s)=>{n!=null&&n!==!1&&(r[s]=t&&u.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[Cr]=this[Cr]={accessors:{}}).accessors,s=this.prototype;function i(a){const o=fe(a);n[o]||(ci(s,a),n[o]=!0)}return u.isArray(t)?t.forEach(i):i(t),this}}Pe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),u.reduceDescriptors(Pe.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),u.freezeMethods(Pe);var F=Pe;function bt(e,t){const r=this||Et,n=t||r,s=F.from(n.headers);let i=n.data;return u.forEach(e,function(o){i=o.call(r,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function Pr(e){return!!(e&&e.__CANCEL__)}function he(e,t,r){y.call(this,e??"canceled",y.ERR_CANCELED,t,r),this.name="CanceledError"}u.inherits(he,y,{__CANCEL__:!0});function ui(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))}var li=U.hasStandardBrowserEnv?function(){return{write:function(r,n,s,i,a,o){const l=[];l.push(r+"="+encodeURIComponent(n)),u.isNumber(s)&&l.push("expires="+new Date(s).toGMTString()),u.isString(i)&&l.push("path="+i),u.isString(a)&&l.push("domain="+a),o===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(r){const n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function di(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function fi(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function Br(e,t){return e&&!di(t)?fi(e,t):t}var hi=U.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(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=u.isString(a)?s(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}();function pi(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function mi(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(l){const d=Date.now(),c=n[i];a||(a=d),r[s]=l,n[s]=d;let h=i,E=0;for(;h!==s;)E+=r[h++],h=h%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),d-a<t)return;const g=c&&d-c;return g?Math.round(E*1e3/g):void 0}}function xr(e,t){let r=0;const n=mi(50,250);return s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,o=i-r,l=n(o),d=i<=a;r=i;const c={loaded:i,total:a,progress:a?i/a:void 0,bytes:o,rate:l||void 0,estimated:l&&a&&d?(a-i)/l:void 0,event:s};c[t?"download":"upload"]=!0,e(c)}}var Ei=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){let s=e.data;const i=F.from(e.headers).normalize(),a=e.responseType;let o;function l(){e.cancelToken&&e.cancelToken.unsubscribe(o),e.signal&&e.signal.removeEventListener("abort",o)}let d;if(u.isFormData(s)){if(U.hasStandardBrowserEnv||U.hasStandardBrowserWebWorkerEnv)i.setContentType(!1);else if((d=i.getContentType())!==!1){const[f,...p]=d?d.split(";").map(R=>R.trim()).filter(Boolean):[];i.setContentType([f||"multipart/form-data",...p].join("; "))}}let c=new XMLHttpRequest;if(e.auth){const f=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(f+":"+p))}const h=Br(e.baseURL,e.url);c.open(e.method.toUpperCase(),Tr(h,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function E(){if(!c)return;const f=F.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),R={data:!a||a==="text"||a==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:f,config:e,request:c};ui(function(q){r(q),l()},function(q){n(q),l()},R),c=null}if("onloadend"in c?c.onloadend=E:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(E)},c.onabort=function(){c&&(n(new y("Request aborted",y.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new y("Network Error",y.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const R=e.transitional||Rr;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),n(new y(p,R.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,c)),c=null},U.hasStandardBrowserEnv){const f=hi(h)&&e.xsrfCookieName&&li.read(e.xsrfCookieName);f&&i.set(e.xsrfHeaderName,f)}s===void 0&&i.setContentType(null),"setRequestHeader"in c&&u.forEach(i.toJSON(),function(p,R){c.setRequestHeader(R,p)}),u.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),a&&a!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",xr(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",xr(e.onUploadProgress)),(e.cancelToken||e.signal)&&(o=f=>{c&&(n(!f||f.type?new he(null,e,c):f),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(o),e.signal&&(e.signal.aborted?o():e.signal.addEventListener("abort",o)));const g=pi(h);if(g&&U.protocols.indexOf(g)===-1){n(new y("Unsupported protocol "+g+":",y.ERR_BAD_REQUEST,e));return}c.send(s||null)})};const _t={http:Ks,xhr:Ei};u.forEach(_t,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const jr=e=>`- ${e}`,yi=e=>u.isFunction(e)||e===null||e===!1;var Nr={getAdapter:e=>{e=u.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,!yi(r)&&(n=_t[(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,l])=>`adapter ${o} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=t?i.length>1?`since :
4
- `+i.map(jr).join(`
5
- `):" "+jr(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:_t};function gt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new he(null,e)}function Dr(e){return gt(e),e.headers=F.from(e.headers),e.data=bt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Nr.getAdapter(e.adapter||Et.adapter)(e).then(function(n){return gt(e),n.data=bt.call(e,e.transformResponse,n),n.headers=F.from(n.headers),n},function(n){return Pr(n)||(gt(e),n&&n.response&&(n.response.data=bt.call(e,e.transformResponse,n.response),n.response.headers=F.from(n.response.headers))),Promise.reject(n)})}const Hr=e=>e instanceof F?e.toJSON():e;function ne(e,t){t=t||{};const r={};function n(d,c,h){return u.isPlainObject(d)&&u.isPlainObject(c)?u.merge.call({caseless:h},d,c):u.isPlainObject(c)?u.merge({},c):u.isArray(c)?c.slice():c}function s(d,c,h){if(u.isUndefined(c)){if(!u.isUndefined(d))return n(void 0,d,h)}else return n(d,c,h)}function i(d,c){if(!u.isUndefined(c))return n(void 0,c)}function a(d,c){if(u.isUndefined(c)){if(!u.isUndefined(d))return n(void 0,d)}else return n(void 0,c)}function o(d,c,h){if(h in t)return n(d,c);if(h in e)return n(void 0,d)}const l={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials: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:(d,c)=>s(Hr(d),Hr(c),!0)};return u.forEach(Object.keys(Object.assign({},e,t)),function(c){const h=l[c]||s,E=h(e[c],t[c],c);u.isUndefined(E)&&h!==o||(r[c]=E)}),r}const Ur="1.6.1",wt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{wt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Mr={};wt.transitional=function(t,r,n){function s(i,a){return"[Axios v"+Ur+"] 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&&!Mr[a]&&(Mr[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 bi(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],l=o===void 0||a(o,i,e);if(l!==!0)throw new y("option "+i+" must be "+l,y.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}var St={assertOptions:bi,validators:wt};const W=St.validators;class Be{constructor(t){this.defaults=t,this.interceptors={request:new Ar,response:new Ar}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ne(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&St.assertOptions(n,{silentJSONParsing:W.transitional(W.boolean),forcedJSONParsing:W.transitional(W.boolean),clarifyTimeoutError:W.transitional(W.boolean)},!1),s!=null&&(u.isFunction(s)?r.paramsSerializer={serialize:s}:St.assertOptions(s,{encode:W.function,serialize:W.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&u.merge(i.common,i[r.method]);i&&u.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),r.headers=F.concat(a,i);const o=[];let l=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(r)===!1||(l=l&&p.synchronous,o.unshift(p.fulfilled,p.rejected))});const d=[];this.interceptors.response.forEach(function(p){d.push(p.fulfilled,p.rejected)});let c,h=0,E;if(!l){const f=[Dr.bind(this),void 0];for(f.unshift.apply(f,o),f.push.apply(f,d),E=f.length,c=Promise.resolve(r);h<E;)c=c.then(f[h++],f[h++]);return c}E=o.length;let g=r;for(h=0;h<E;){const f=o[h++],p=o[h++];try{g=f(g)}catch(R){p.call(this,R);break}}try{c=Dr.call(this,g)}catch(f){return Promise.reject(f)}for(h=0,E=d.length;h<E;)c=c.then(d[h++],d[h++]);return c}getUri(t){t=ne(this.defaults,t);const r=Br(t.baseURL,t.url);return Tr(r,t.params,t.paramsSerializer)}}u.forEach(["delete","get","head","options"],function(t){Be.prototype[t]=function(r,n){return this.request(ne(n||{},{method:t,url:r,data:(n||{}).data}))}}),u.forEach(["post","put","patch"],function(t){function r(n){return function(i,a,o){return this.request(ne(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}Be.prototype[t]=r(),Be.prototype[t+"Form"]=r(!0)});var xe=Be;class Tt{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 he(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)}static source(){let t;return{token:new Tt(function(s){t=s}),cancel:t}}}var _i=Tt;function gi(e){return function(r){return e.apply(null,r)}}function wi(e){return u.isObject(e)&&e.isAxiosError===!0}const At={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(At).forEach(([e,t])=>{At[t]=e});var Si=At;function Lr(e){const t=new xe(e),r=or(xe.prototype.request,t);return u.extend(r,xe.prototype,t,{allOwnKeys:!0}),u.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return Lr(ne(e,s))},r}const T=Lr(Et);T.Axios=xe,T.CanceledError=he,T.CancelToken=_i,T.isCancel=Pr,T.VERSION=Ur,T.toFormData=Oe,T.AxiosError=y,T.Cancel=T.CanceledError,T.all=function(t){return Promise.all(t)},T.spread=gi,T.isAxiosError=wi,T.mergeConfig=ne,T.AxiosHeaders=F,T.formToJSON=e=>Or(u.isHTMLForm(e)?new FormData(e):e),T.getAdapter=Nr.getAdapter,T.HttpStatusCode=Si,T.default=T;var Ir=T,Rt={exports:{}};const $r=e=>typeof e=="object"&&e!==null,Kr=Symbol("skip"),qr=e=>$r(e)&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),vt=(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=>qr(o)?vt(o,t,r,n):o);if(Array.isArray(e))return i(e);for(const[a,o]of Object.entries(e)){const l=t(a,o,e);if(l===Kr)continue;let[d,c,{shouldRecurse:h=!0}={}]=l;d!=="__proto__"&&(r.deep&&h&&qr(c)&&(c=Array.isArray(c)?i(c):vt(c,t,r,n)),s[d]=c)}return s};Rt.exports=(e,t,r)=>{if(!$r(e))throw new TypeError(`Expected an object, got \`${e}\` (${typeof e})`);return vt(e,t,r)},Rt.exports.mapObjectSkip=Kr;var Fr=Rt.exports,Ot={exports:{}};const Ti=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},zr=(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=Ti(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(s,i)=>i.toUpperCase()).replace(/\d+(\w|$)/g,s=>s.toUpperCase()),r(e))};Ot.exports=zr,Ot.exports.default=zr;var Ai=Ot.exports;class Ri{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 vi=Ri;const Wr=Fr,Oi=Ai,Ci=vi,Pi=(e,t)=>e.some(r=>typeof r=="string"?r===t:(r.lastIndex=0,r.test(t))),Ct=new Ci({maxSize:1e5}),kr=e=>typeof e=="object"&&e!==null&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),Vr=(e,t)=>{if(!kr(e))return e;t={deep:!1,pascalCase:!1,...t};const{exclude:r,pascalCase:n,stopPaths:s,deep:i}=t,a=new Set(s),o=l=>(d,c)=>{if(i&&kr(c)){const h=l===void 0?d:`${l}.${d}`;a.has(h)||(c=Wr(c,o(h)))}if(!(r&&Pi(r,d))){const h=n?`${d}_`:d;if(Ct.has(h))d=Ct.get(h);else{const E=Oi(d,{pascalCase:n});d.length<100&&Ct.set(h,E),d=E}}return[d,c]};return Wr(e,o(void 0))};var Bi=(e,t)=>Array.isArray(e)?Object.keys(e).map(r=>Vr(e[r],t)):Vr(e,t),Pt,Gr;function Jr(){return Gr||(Gr=1,Pt=Jr()),Pt}var je=function(){return je=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},je.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function xi(e){return e.toLowerCase()}var ji=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],Ni=/[^A-Z0-9]+/gi;function Di(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,n=r===void 0?ji:r,s=t.stripRegexp,i=s===void 0?Ni:s,a=t.transform,o=a===void 0?xi:a,l=t.delimiter,d=l===void 0?" ":l,c=Yr(Yr(e,n,"$1\0$2"),i,"\0"),h=0,E=c.length;c.charAt(h)==="\0";)h++;for(;c.charAt(E-1)==="\0";)E--;return c.slice(h,E).split("\0").map(o).join(d)}function Yr(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(n,s){return n.replace(s,r)},e)}function Hi(e,t){return t===void 0&&(t={}),Di(e,je({delimiter:"."},t))}function Ui(e,t){return t===void 0&&(t={}),Hi(e,je({delimiter:"_"},t))}const Mi=zn(Object.freeze(Object.defineProperty({__proto__:null,snakeCase:Ui},Symbol.toStringTag,{value:"Module"})));var Li=qi,Ii=/\s/,$i=/(_|-|\.|:)/,Ki=/([a-z][A-Z]|[A-Z][a-z])/;function qi(e){return Ii.test(e)?e.toLowerCase():$i.test(e)?(zi(e)||e).toLowerCase():Ki.test(e)?ki(e).toLowerCase():e.toLowerCase()}var Fi=/[\W_]+(.|$)/g;function zi(e){return e.replace(Fi,function(t,r){return r?" "+r:""})}var Wi=/(.)([A-Z]+)/g;function ki(e){return e.replace(Wi,function(t,r,n){return r+" "+n.toLowerCase().split("").join(" ")})}var Vi=Li,Gi=Ji;function Ji(e){return Vi(e).replace(/[\W_]+(.|$)/g,function(t,r){return r?" "+r:""}).trim()}var Yi=Gi,Xi=Zi;function Zi(e){return Yi(e).replace(/\s/g,"_")}const Qi=Fr,ea=Xi;var ta=function(e,t){return t=Object.assign({deep:!0,exclude:[]},t),Qi(e,function(r,n){return[ra(t.exclude,r)?r:ea(r),n]},t)};function ra(e,t){return e.some(function(r){return typeof r=="string"?r===t:r.test(t)})}var pe={};Object.defineProperty(pe,"__esModule",{value:!0}),pe.BasisTheoryApiError=void 0;function na(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 Bt extends na(Error){constructor(t,r,n){super(t),this.status=r,this.data=n,this.name="BasisTheoryApiError",Object.setPrototypeOf(this,Bt.prototype)}}pe.BasisTheoryApiError=Bt,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 Xr=Ne(Ir),M=Ne(Bi),Zr=Ne(Jr()),sa=Mi,me=Ne(ta),ia=pe,J=b;function Ne(e){return e&&e.__esModule?e:{default:e}}const aa=e=>{if(e==null)throw new Error("BasisTheory has not yet been properly initialized.");return e};m.assertInit=aa;const oa=e=>{if(!(typeof e>"u"))return(0,me.default)(e,{deep:!0})};m.transformRequestSnakeCase=oa;const ca=e=>e;m.proxyRaw=ca;const ua=e=>{if(!(typeof e>"u"))return{...(0,me.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorRequestSnakeCase=ua;const la=e=>{if(!(typeof e>"u"))return{...(0,me.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyRequestSnakeCase=la;const da=e=>{if(!(typeof e>"u"))return{...(0,me.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenRequestSnakeCase=da;const xt=e=>e&&(e==null?void 0:e.pagination)!==void 0&&(e==null?void 0:e.data)!==void 0,fa=e=>{if(!(typeof e>"u"))return xt(e)?{data:e.data.map(n=>({...(0,M.default)(n,{deep:!0}),...n.data!==void 0?{data:n.data}:{},...n.metadata!==void 0?{metadata:n.metadata}:{}})),pagination:(0,M.default)(e.pagination,{deep:!0})}:{...(0,M.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenResponseCamelCase=fa;const ha=e=>{if(!(typeof e>"u"))return xt(e)?{data:e.data.map(n=>({...(0,M.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,M.default)(e.pagination,{deep:!0})}:{...(0,M.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorResponseCamelCase=ha;const pa=e=>{if(!(typeof e>"u"))return xt(e)?{data:e.data.map(n=>({...(0,M.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,M.default)(e.pagination,{deep:!0})}:{...(0,M.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyResponseCamelCase=pa;const ma=e=>{if(!(typeof e>"u"))return(0,M.default)(e,{deep:!0})};m.transformResponseCamelCase=ma;const Ea=e=>e==null?void 0:e.data;m.dataExtractor=Ea;const ya=e=>({data:e==null?void 0:e.data,headers:e==null?void 0:e.headers});m.dataAndHeadersExtractor=ya;const jt=e=>[e,...Xr.default.defaults.transformRequest];m.concatRequestTransformerWithDefault=jt;const Nt=e=>[...Xr.default.defaults.transformResponse,e];m.concatResponseTransformerWithDefault=Nt;const ba=(e,t)=>{if(!e)return t?{...t.transformRequest!==void 0?{transformRequest:jt(t.transformRequest)}:{},...t.transformResponse!==void 0?{transformResponse:Nt(t.transformResponse)}:{}}:void 0;const{apiKey:r,correlationId:n,idempotencyKey:s,transactionId:i,query:a,headers:o}=e,l=r?{[J.API_KEY_HEADER]:r}:{},d=n?{[J.BT_TRACE_ID_HEADER]:n}:{},c=s?{[J.BT_IDEMPOTENCY_KEY_HEADER]:s}:{},h=i?{[J.BT_TRANSACTION_ID_HEADER]:i}:{};return{headers:{...l,...d,...c,...h,...typeof o<"u"&&{...o}},...typeof a<"u"&&{params:a},...(t==null?void 0:t.transformRequest)!==void 0?{transformRequest:jt(t.transformRequest)}:{},...(t==null?void 0:t.transformResponse)!==void 0?{transformResponse:Nt(t.transformResponse)}:{}}};m.createRequestConfig=ba;const _a=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 ia.BasisTheoryApiError(e.message,n,s)};m.errorInterceptor=_a;const ga=(e={})=>{const t=Object.keys(e);if(t.length){const r=new URLSearchParams,n=(s,i,a=!1)=>{const o=typeof i,l=a?s:(0,sa.snakeCase)(s);(i===null||["boolean","number","string"].includes(o))&&r.append(l,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=ga;const wa=e=>`(${e.name||""}; ${e.version||""}; ${e.url||""})`,Sa=e=>{let t=`${J.USER_AGENT_CLIENT}/unknown`;return e&&Object.keys(e||{}).length&&(t+=` ${wa(e)}`),t};m.buildUserAgentString=Sa;const Qr=()=>{const{userAgent:e}=window.navigator;let t="unknown";const r=J.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=Qr;const en=()=>typeof window=="object"&&window.navigator.product==="ReactNative",tn=()=>{if(en())return"ReactNative";if(typeof window>"u")try{return`${Zr.default.type()}/${Zr.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=tn;const rn=()=>en()?"ReactNative":typeof window>"u"?`NodeJS/${process.version}`:Qr();m.getRuntime=rn;const Ta=e=>{const t={client:J.USER_AGENT_CLIENT,clientVersion:"unknown",osVersion:tn(),runtimeVersion:rn(),application:{}};return e&&(t.application=e),JSON.stringify((0,me.default)(t))};m.buildClientUserAgentString=Ta;var De={};Object.defineProperty(De,"__esModule",{value:!0}),De.BasisTheoryValidationError=void 0;function Aa(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 Dt extends Aa(Error){constructor(t,r,n){super(t),this.details=r,this.validation=n,this.name="BasisTheoryValidationError",Object.setPrototypeOf(this,Dt.prototype)}}De.BasisTheoryValidationError=Dt;var He={};Object.defineProperty(He,"__esModule",{value:!0}),He.HttpClientError=void 0;function Ra(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 Ht extends Ra(Error){constructor(t,r,n,s){super(t),this.name="HttpClientError",this.status=r,this.data=n,this.headers=s,Object.setPrototypeOf(this,Ht.prototype)}}He.HttpClientError=Ht,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=b;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=pe,i=De,a=He}(P);var B={},va={},Ue={};Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.BasisTheoryService=void 0;var Me=Oa(Ir),k=P;function Oa(e){return e&&e.__esModule?e:{default:e}}class Ca{constructor(t){const{apiKey:r,baseURL:n,transformRequest:s,transformResponse:i,appInfo:a}=t;if(typeof Me.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=Me.default.create({baseURL:n,headers:{[k.API_KEY_HEADER]:r,[k.CLIENT_USER_AGENT_HEADER]:(0,k.buildClientUserAgentString)(a),...typeof window>"u"&&{[k.USER_AGENT_HEADER]:(0,k.buildUserAgentString)(a)}},transformRequest:[].concat(s||k.transformRequestSnakeCase,Me.default.defaults.transformRequest),transformResponse:Me.default.defaults.transformResponse.concat(i||k.transformResponseCamelCase)}),this.client.interceptors.response.use(void 0,k.errorInterceptor)}}Ue.BasisTheoryService=Ca,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=va;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=Ue;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]}})})}(B),Object.defineProperty(Se,"__esModule",{value:!0}),Se.BasisTheoryTransactions=void 0;var Ut=P,Ee=m,Pa=B;class Ba extends Pa.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(Ee.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(Ee.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,Ut.createRequestConfig)(t)).then(Ee.dataExtractor)}commit(t,r={}){const n=`/${t}/commit`;return this.client.post(n,void 0,(0,Ut.createRequestConfig)(r)).then(Ee.dataExtractor)}rollback(t,r={}){const n=`/${t}/rollback`;return this.client.post(n,void 0,(0,Ut.createRequestConfig)(r)).then(Ee.dataExtractor)}}Se.BasisTheoryTransactions=Ba,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Se;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]}})})}(ar);var Mt={},Le={},L={};Object.defineProperty(L,"__esModule",{value:!0}),L.CrudBuilder=void 0;var O=P;const xa=e=>class extends e{create(r,n){return this.client.post("/",r,(0,O.createRequestConfig)(n)).then(O.dataExtractor)}},ja=e=>class extends e{retrieve(r,n){return this.client.get(r,(0,O.createRequestConfig)(n)).then(O.dataExtractor)}},Na=e=>class extends e{update(r,n,s){return this.client.put(r,n,(0,O.createRequestConfig)(s)).then(O.dataExtractor)}},Da=e=>class extends e{patch(r,n,s){const i=(0,O.createRequestConfig)(s);return this.client.patch(r,n,{...i,headers:{...(i==null?void 0:i.headers)||{},[O.CONTENT_TYPE_HEADER]:O.MERGE_CONTENT_TYPE}}).then(O.dataExtractor)}},Ha=e=>class extends e{async delete(r,n){await this.client.delete(r,(0,O.createRequestConfig)(n))}},Ua=e=>class extends e{list(r={},n={}){const s=`/${(0,O.getQueryParams)(r)}`;return this.client.get(s,(0,O.createRequestConfig)(n)).then(O.dataExtractor)}};class Ma{constructor(t){this.BaseService=t}create(){return this.BaseService=xa(this.BaseService),this}retrieve(){return this.BaseService=ja(this.BaseService),this}update(){return this.BaseService=Na(this.BaseService),this}patch(){return this.BaseService=Da(this.BaseService),this}delete(){return this.BaseService=Ha(this.BaseService),this}list(){return this.BaseService=Ua(this.BaseService),this}build(){return this.BaseService}}L.CrudBuilder=Ma,Object.defineProperty(Le,"__esModule",{value:!0}),Le.BasisTheoryApplications=void 0;var Ie=P,La=B,Ia=L;const $a=new Ia.CrudBuilder(class extends La.BasisTheoryService{getApplicationByKey(){return this.retrieveByKey()}retrieveByKey(t){return this.client.get("/key",(0,Ie.createRequestConfig)(t)).then(Ie.dataExtractor)}regenerateKey(t,r){return this.client.post(`${t}/regenerate`,void 0,(0,Ie.createRequestConfig)(r)).then(Ie.dataExtractor)}}).create().retrieve().update().delete().list().build();Le.BasisTheoryApplications=$a,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryApplications",{enumerable:!0,get:function(){return t.BasisTheoryApplications}});var t=Le}(Mt);var nn={},sn={},$e={},an={},Ke={};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.BasisTheoryTokenize=void 0;var qe=P,Ka=B;class qa extends Ka.BasisTheoryService{tokenize(t,r={}){return this.client.post("/",t,(0,qe.createRequestConfig)(r,{transformRequest:qe.proxyRaw,transformResponse:qe.proxyRaw})).then(qe.dataExtractor)}}Ke.BasisTheoryTokenize=qa,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokenize",{enumerable:!0,get:function(){return t.BasisTheoryTokenize}});var t=Ke}(an),Object.defineProperty($e,"__esModule",{value:!0}),$e.delegateTokenize=void 0;var Fa=an;const za=e=>class extends Fa.BasisTheoryTokenize{tokenize(r,n){return e!=null&&e.hasElement(r)?e.tokenize(r,n):super.tokenize(r,n)}};$e.delegateTokenize=za;var Fe={},Lt={},ze={};Object.defineProperty(ze,"__esModule",{value:!0}),ze.BasisTheoryTokens=void 0;var I=P,Y=m,Wa=B,ka=L;const Va=new ka.CrudBuilder(class extends Wa.BasisTheoryService{constructor(t){const r=t;r.transformRequest=[].concat(Y.transformTokenRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(Y.transformTokenResponseCamelCase,t.transformResponse||[]),super(r)}retrieve(t,r={}){const n=`/${t}`;return this.client.get(n,(0,I.createRequestConfig)(r)).then(Y.dataExtractor)}update(t,r,n={}){const s=`/${t}`,i=(0,I.createRequestConfig)(n);return this.client.patch(s,r,{...i,headers:{...(i==null?void 0:i.headers)||{},[I.CONTENT_TYPE_HEADER]:I.MERGE_CONTENT_TYPE}}).then(Y.dataExtractor)}async createAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.post(s,{},(0,I.createRequestConfig)(n))}async deleteAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.delete(s,(0,I.createRequestConfig)(n))}createChild(t,r,n){const s=`/${t}/children`;return this.client.post(s,r,(0,I.createRequestConfig)(n)).then(Y.dataExtractor)}listChildren(t,r={},n={}){const s=`/${t}/children${(0,I.getQueryParams)(r)}`;return this.client.get(s,(0,I.createRequestConfig)(n)).then(Y.dataExtractor)}search(t,r){return this.client.post("/search",t,(0,I.createRequestConfig)(r)).then(Y.dataExtractor)}}).create().delete().list().build();ze.BasisTheoryTokens=Va,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokens",{enumerable:!0,get:function(){return t.BasisTheoryTokens}});var t=ze}(Lt),Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.delegateTokens=void 0;var Ga=Lt;const Ja=e=>class extends Ga.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)}};Fe.delegateTokens=Ja;var We={},on={},ke={};Object.defineProperty(ke,"__esModule",{value:!0}),ke.BasisTheoryProxy=void 0;var z=P,Ya=B;class Xa extends Ya.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"?z.dataAndHeadersExtractor:z.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,z.createRequestConfig)(r,{transformRequest:z.proxyRaw,transformResponse:z.proxyRaw})).then(a)}return this.client[t]((n=r==null?void 0:r.path)!==null&&n!==void 0?n:"/",(0,z.createRequestConfig)(r,{transformRequest:z.proxyRaw,transformResponse:z.proxyRaw})).then(z.dataExtractor)}}ke.BasisTheoryProxy=Xa,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=ke;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]}})})}(on),Object.defineProperty(We,"__esModule",{value:!0}),We.delegateProxy=void 0;var Za=on;const Qa=e=>class extends Za.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)}};We.delegateProxy=Qa,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=$e;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=Fe;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=We;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 X={};Object.defineProperty(X,"__esModule",{value:!0}),X.injectScript=X.findScript=void 0;const eo=e=>document.querySelector(`script[src^="${e}"]`);X.findScript=eo;const to=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};X.injectScript=to;var Ve={},v={};Object.defineProperty(v,"__esModule",{value:!0}),v.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=v.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=v.ELEMENTS_NOM_DOM_ERROR_MESSAGE=v.ELEMENTS_INIT_ERROR_MESSAGE=v.CARD_ICON_POSITIONS=v.CARD_BRANDS=v.AUTOCOMPLETE_VALUES=void 0;const ro="BasisTheory Elements was not properly initialized.";v.ELEMENTS_INIT_ERROR_MESSAGE=ro;const no="Tried to load BasisTheoryElements in a non-DOM environment.";v.ELEMENTS_NOM_DOM_ERROR_MESSAGE=no;const so="Basis Theory Elements did not load properly.";v.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=so;const io="There was an unknown error when loading Basis Theory Elements. Check the console for details.";v.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=io;const ao=["visa","mastercard","american-express","discover","diners-club","jcb","unionpay","maestro","elo","hiper","hipercard","mir","unknown"];v.CARD_BRANDS=ao;const oo=["left","right","none"];v.CARD_ICON_POSITIONS=oo;const co=["off","on"];v.AUTOCOMPLETE_VALUES=co,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.loadElements=void 0;var It=v,cn=X;let $t;const uo=e=>($t||($t=new Promise((t,r)=>{if(typeof window!="object"){r(new Error(It.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,cn.findScript)(n);s||(s=(0,cn.injectScript)(n)),s.addEventListener("load",()=>{window.BasisTheoryElements?t(window.BasisTheoryElements):r(new Error(It.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE))}),s.addEventListener("error",i=>{r((i==null?void 0:i.error)||new Error(It.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE))})}catch(n){r(n);return}})),$t);Ve.loadElements=uo,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=X;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=Ve;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]}})})}(nn);var un={},Ge={};Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.BasisTheoryLogs=void 0;var lo=B,fo=L;const ho=new fo.CrudBuilder(class extends lo.BasisTheoryService{}).list().build();Ge.BasisTheoryLogs=ho,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryLogs",{enumerable:!0,get:function(){return t.BasisTheoryLogs}});var t=Ge}(un);var ln={},Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.BasisTheoryPermissions=void 0;var dn=P,po=B;class mo extends po.BasisTheoryService{list(t){return this.client.get("/",(0,dn.createRequestConfig)(t)).then(dn.dataExtractor)}}Je.BasisTheoryPermissions=mo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryPermissions",{enumerable:!0,get:function(){return t.BasisTheoryPermissions}});var t=Je}(ln);var fn={},Ye={};Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.BasisTheoryProxies=void 0;var hn=m,Eo=B,yo=L;const bo=new yo.CrudBuilder(class extends Eo.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(hn.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(hn.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}}).create().retrieve().update().patch().delete().list().build();Ye.BasisTheoryProxies=bo,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ye;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]}})})}(fn);var pn={},Xe={};Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.BasisTheoryReactorFormulas=void 0;var _o=B,go=L;const wo=new go.CrudBuilder(class extends _o.BasisTheoryService{}).create().retrieve().update().delete().list().build();Xe.BasisTheoryReactorFormulas=wo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactorFormulas",{enumerable:!0,get:function(){return t.BasisTheoryReactorFormulas}});var t=Xe}(pn);var mn={},Ze={};Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.BasisTheoryReactors=void 0;var Qe=P,En=m,So=B,To=L;const Ao=new To.CrudBuilder(class extends So.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(En.transformReactorRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(En.transformReactorResponseCamelCase,t.transformResponse||[]),super(r)}react(t,r,n){return this.client.post(`/${t}/react`,r,(0,Qe.createRequestConfig)(n,{transformRequest:Qe.proxyRaw,transformResponse:Qe.proxyRaw})).then(Qe.dataExtractor)}}).create().retrieve().update().patch().delete().list().build();Ze.BasisTheoryReactors=Ao,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactors",{enumerable:!0,get:function(){return t.BasisTheoryReactors}});var t=Ze}(mn);var yn={},et={};Object.defineProperty(et,"__esModule",{value:!0}),et.BasisTheorySessions=void 0;var bn=P,tt=m,Ro=B;class vo extends Ro.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(tt.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(tt.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,bn.createRequestConfig)(t)).then(tt.dataExtractor)}authorize(t,r={}){return this.client.post("/authorize",t,(0,bn.createRequestConfig)(r)).then(tt.dataExtractor)}}et.BasisTheorySessions=vo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheorySessions",{enumerable:!0,get:function(){return t.BasisTheorySessions}});var t=et}(yn);var _n={},rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.BasisTheoryTenants=void 0;var S=P,Oo=B,Co=L;const Po=new Co.CrudBuilder(class extends Oo.BasisTheoryService{retrieve(t){return this.client.get("/",(0,S.createRequestConfig)(t)).then(S.dataExtractor)}update(t,r){return this.client.put("/",t,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}async delete(t){await this.client.delete("/",(0,S.createRequestConfig)(t))}retrieveUsageReport(t){return this.client.get("/reports/usage",(0,S.createRequestConfig)(t)).then(S.dataExtractor)}createInvitation(t,r){return this.client.post("/invitations",t,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}resendInvitation(t,r){return this.client.post(`/invitations/${t}/resend`,{},(0,S.createRequestConfig)(r)).then(S.dataExtractor)}listInvitations(t,r){const n=`/invitations${(0,S.getQueryParams)(t)}`;return this.client.get(n,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}retrieveInvitation(t,r){return this.client.get(`/invitations/${t}`,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}async deleteInvitation(t,r){await this.client.delete(`/invitations/${t}`,(0,S.createRequestConfig)(r))}listMembers(t,r){const n=`/members${(0,S.getQueryParams)(t)}`;return this.client.get(n,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}async deleteMember(t,r){await this.client.delete(`/members/${t}`,(0,S.createRequestConfig)(r))}}).build();rt.BasisTheoryTenants=Po,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTenants",{enumerable:!0,get:function(){return t.BasisTheoryTenants}});var t=rt}(_n),Object.defineProperty(we,"__esModule",{value:!0}),we.BasisTheory=void 0;var ye=te,Bo=ar,xo=Mt,_=P,nt=nn,jo=v,No=un,Do=ln,Ho=fn,Uo=pn,Mo=mn,Lo=yn,Io=_n;function $o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const Ko={apiBaseUrl:_.DEFAULT_BASE_URL,elements:!1,appInfo:{}};class qo{constructor(){$o(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({...Ko,...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,nt.delegateTokens)(this._elements))({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.tokens,n).toString(),appInfo:s}),this._tokenize=new((0,nt.delegateTokenize)(this._elements))({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.tokenize,n).toString(),appInfo:s}),this._applications=new xo.BasisTheoryApplications({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.applications,n).toString(),appInfo:s}),this._tenants=new Io.BasisTheoryTenants({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.tenants,n).toString(),appInfo:s}),this._logs=new No.BasisTheoryLogs({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.logs,n).toString(),appInfo:s}),this._reactorFormulas=new Uo.BasisTheoryReactorFormulas({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.reactorFormulas,n).toString(),appInfo:s}),this._reactors=new Mo.BasisTheoryReactors({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.reactors,n).toString(),appInfo:s}),this._permissions=new Do.BasisTheoryPermissions({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.permissions,n).toString(),appInfo:s}),this._proxies=new Ho.BasisTheoryProxies({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.proxies,n).toString(),appInfo:s}),this._proxy=new((0,nt.delegateProxy)(this._elements))({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.proxy,n).toString(),appInfo:s}),this._sessions=new Lo.BasisTheorySessions({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.sessions,n).toString(),appInfo:s}),this._transactions=new Bo.BasisTheoryTransactions({apiKey:t,baseURL:new URL(_.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(jo.ELEMENTS_INIT_ERROR_MESSAGE);return this._elements.createElement(t,r)}tokenize(t,r){return(0,_.assertInit)(this._tokenize).tokenize(t,r)}post(t,r,n){return(0,ye.makeRequestWithElementsPayloadCheck)(this._elements,"post",t,r,n)}put(t,r,n){return(0,ye.makeRequestWithElementsPayloadCheck)(this._elements,"put",t,r,n)}patch(t,r,n){return(0,ye.makeRequestWithElementsPayloadCheck)(this._elements,"patch",t,r,n)}get(t,r){return(0,ye.makeRequestWithoutElementsPayloadCheck)(this._elements,"get",t,r)}delete(t,r){return(0,ye.makeRequestWithoutElementsPayloadCheck)(this._elements,"delete",t,r)}async loadElements(t){let r;try{r=new URL(this.initOptions.elementsBaseUrl||_.DEFAULT_ELEMENTS_BASE_URL)}catch{throw new Error("Invalid format for the given Elements base url.")}const n=await(0,nt.loadElements)(this.initOptions.elementsClientUrl);await n.init(t,r.toString().replace(/\/$/u,"")),this.elements=n}get initOptions(){return(0,_.assertInit)(this._initOptions)}get tokens(){return(0,_.assertInit)(this._tokens)}get applications(){return(0,_.assertInit)(this._applications)}get tenants(){return(0,_.assertInit)(this._tenants)}get logs(){return(0,_.assertInit)(this._logs)}get reactorFormulas(){return(0,_.assertInit)(this._reactorFormulas)}get reactors(){return(0,_.assertInit)(this._reactors)}get permissions(){return(0,_.assertInit)(this._permissions)}get proxies(){return(0,_.assertInit)(this._proxies)}get proxy(){return(0,_.assertInit)(this._proxy)}get sessions(){return(0,_.assertInit)(this._sessions)}get transactions(){return(0,_.assertInit)(this._transactions)}get elements(){return(0,_.assertInit)(this._elements)}set elements(t){this._elements=t}}we.BasisTheory=qo,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={_instance:!0};e._instance=void 0;var r=we;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=Mt;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=Lt;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}(sr);const w=crypto,$=e=>e instanceof CryptoKey,Fo=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await w.subtle.digest(r,t))},Z=new TextEncoder,gn=new TextDecoder,st=2**32;function be(...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 zo(e,t){return be(Z.encode(e),new Uint8Array([0]),t)}function Kt(e,t,r){if(t<0||t>=st)throw new RangeError(`value must be >= 0 and <= ${st-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function Wo(e){const t=Math.floor(e/st),r=e%st,n=new Uint8Array(8);return Kt(n,t,0),Kt(n,r,4),n}function qt(e){const t=new Uint8Array(4);return Kt(t,e),t}function Ft(e){return be(qt(e.length),e)}async function ko(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(qt(i+1)),a.set(e,4),a.set(r,4+e.length),s.set(await Fo("sha256",a),i*32)}return s.slice(0,t>>3)}const Vo=e=>{let t=e;typeof t=="string"&&(t=Z.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(""))},j=e=>Vo(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Go=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},wn=e=>{let t=e;t instanceof Uint8Array&&(t=gn.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Go(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class Sn 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 C extends Sn{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class V extends Sn{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}const zt=w.getRandomValues.bind(w);function Tn(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 C(`Unsupported JWE Algorithm: ${e}`)}}const Jo=e=>zt(new Uint8Array(Tn(e)>>3)),Yo=(e,t)=>{if(t.length<<3!==Tn(e))throw new V("Invalid Initialization Vector length")},An=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new V(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function G(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function it(e,t){return e.name===t}function Xo(e){return parseInt(e.name.slice(4),10)}function Zo(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 se(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!it(e.algorithm,"AES-GCM"))throw G("AES-GCM");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw G(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!it(e.algorithm,"AES-KW"))throw G("AES-KW");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw G(n,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw G("ECDH, X25519, or X448")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!it(e.algorithm,"PBKDF2"))throw G("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!it(e.algorithm,"RSA-OAEP"))throw G("RSA-OAEP");const n=parseInt(t.slice(9),10)||1;if(Xo(e.algorithm.hash)!==n)throw G(`SHA-${n}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}Zo(e,r)}function Rn(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 K=(e,...t)=>Rn("Key must be ",e,...t);function vn(e,t,...r){return Rn(`Key for the ${e} algorithm must be `,t,...r)}const On=e=>$(e)?!0:(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",N=["CryptoKey"],Qo=(...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 ec(e){return typeof e=="object"&&e!==null}function tc(e){if(!ec(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 Cn=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function rc(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function nc(e,t,r){if($(e))return se(e,t,r),e;if(e instanceof Uint8Array)return w.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError(K(e,...N,"Uint8Array"))}const Wt=async(e,t,r)=>{const n=await nc(t,e,"wrapKey");rc(n,e);const s=await w.subtle.importKey("raw",r,...Cn);return new Uint8Array(await w.subtle.wrapKey("raw",s,n,"AES-KW"))};async function sc(e,t,r,n,s=new Uint8Array(0),i=new Uint8Array(0)){if(!$(e))throw new TypeError(K(e,...N));if(se(e,"ECDH"),!$(t))throw new TypeError(K(t,...N));se(t,"ECDH","deriveBits");const a=be(Ft(Z.encode(r)),Ft(s),Ft(i),qt(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 l=new Uint8Array(await w.subtle.deriveBits({name:e.algorithm.name,public:e},t,o));return ko(l,n,a)}async function ic(e){if(!$(e))throw new TypeError(K(e,...N));return w.subtle.generateKey(e.algorithm,!0,["deriveBits"])}function ac(e){if(!$(e))throw new TypeError(K(e,...N));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||e.algorithm.name==="X25519"||e.algorithm.name==="X448"}function oc(e){if(!(e instanceof Uint8Array)||e.length<8)throw new V("PBES2 Salt Input must be 8 or more octets")}function cc(e,t){if(e instanceof Uint8Array)return w.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if($(e))return se(e,t,"deriveBits","deriveKey"),e;throw new TypeError(K(e,...N,"Uint8Array"))}async function uc(e,t,r,n){oc(e);const s=zo(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"},l=await cc(n,t);if(l.usages.includes("deriveBits"))return new Uint8Array(await w.subtle.deriveBits(a,l,i));if(l.usages.includes("deriveKey"))return w.subtle.deriveKey(a,l,o,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}const lc=async(e,t,r,n=2048,s=zt(new Uint8Array(16)))=>{const i=await uc(s,e,n,t);return{encryptedKey:await Wt(e.slice(-6),i,r),p2c:n,p2s:j(s)}};function Pn(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new C(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}const dc=(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`)}},fc=async(e,t,r)=>{if(!$(t))throw new TypeError(K(t,...N));if(se(t,e,"encrypt","wrapKey"),dc(e,t),t.usages.includes("encrypt"))return new Uint8Array(await w.subtle.encrypt(Pn(e),t,r));if(t.usages.includes("wrapKey")){const n=await w.subtle.importKey("raw",r,...Cn);return new Uint8Array(await w.subtle.wrapKey("raw",n,t,Pn(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')};function hc(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 C('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 C('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 C('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new C('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}const Bn=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=hc(e),n=[t,e.ext??!1,e.key_ops??r],s={...e};return delete s.alg,delete s.use,w.subtle.importKey("jwk",s,...n)},xn=e=>wn(e);let kt,Vt;const jn=e=>(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",Nn=async(e,t,r,n)=>{let s=e.get(t);if(s!=null&&s[n])return s[n];const i=await Bn({...r,alg:n});return s?s[n]=i:e.set(t,{[n]:i}),i},Gt={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?xn(r.k):(Vt||(Vt=new WeakMap),Nn(Vt,e,r,t))}return e},normalizePrivateKey:(e,t)=>{if(jn(e)){let r=e.export({format:"jwk"});return r.k?xn(r.k):(kt||(kt=new WeakMap),Nn(kt,e,r,t))}return e}};function Dn(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 C(`Unsupported JWE Algorithm: ${e}`)}}const _e=e=>zt(new Uint8Array(Dn(e)>>3));async function pc(e,t){if(!tc(e))throw new TypeError("JWK must be an object");switch(t||(t=e.alg),e.kty){case"oct":if(typeof e.k!="string"||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return wn(e.k);case"RSA":if(e.oth!==void 0)throw new C('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return Bn({...e,alg:t});default:throw new C('Unsupported "kty" (Key Type) Parameter value')}}const ie=e=>e==null?void 0:e[Symbol.toStringTag],mc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!On(t))throw new TypeError(vn(e,t,...N,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${ie(t)} instances for symmetric algorithms must be of type "secret"`)}},Ec=(e,t,r)=>{if(!On(t))throw new TypeError(vn(e,t,...N));if(t.type==="secret")throw new TypeError(`${ie(t)} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&t.type==="public")throw new TypeError(`${ie(t)} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&t.type==="public")throw new TypeError(`${ie(t)} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${ie(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${ie(t)} instances for asymmetric algorithm encryption must be of type "public"`)},yc=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?mc(e,t):Ec(e,t,r)};async function bc(e,t,r,n,s){if(!(r instanceof Uint8Array))throw new TypeError(K(r,"Uint8Array"));const i=parseInt(e.slice(1,4),10),a=await w.subtle.importKey("raw",r.subarray(i>>3),"AES-CBC",!1,["encrypt"]),o=await w.subtle.importKey("raw",r.subarray(0,i>>3),{hash:`SHA-${i<<1}`,name:"HMAC"},!1,["sign"]),l=new Uint8Array(await w.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),d=be(s,n,l,Wo(s.length<<3)),c=new Uint8Array((await w.subtle.sign("HMAC",o,d)).slice(0,i>>3));return{ciphertext:l,tag:c,iv:n}}async function _c(e,t,r,n,s){let i;r instanceof Uint8Array?i=await w.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(se(r,e,"encrypt"),i=r);const a=new Uint8Array(await w.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 Hn=async(e,t,r,n,s)=>{if(!$(r)&&!(r instanceof Uint8Array))throw new TypeError(K(r,...N,"Uint8Array"));switch(n?Yo(e,n):n=Jo(e),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&An(r,parseInt(e.slice(-3),10)),bc(e,t,r,n,s);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&An(r,parseInt(e.slice(1,4),10)),_c(e,t,r,n,s);default:throw new C("Unsupported JWE Content Encryption Algorithm")}};async function gc(e,t,r,n){const s=e.slice(0,7),i=await Hn(s,r,t,n,new Uint8Array(0));return{encryptedKey:i.ciphertext,iv:j(i.iv),tag:j(i.tag)}}function wc(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 C(`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 Sc=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:j(e)};if(!$(e))throw new TypeError(K(e,...N,"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 w.subtle.exportKey("jwk",e);return i};async function Tc(e){return Sc(e)}async function Ac(e,t,r,n,s={}){var l;let i,a,o;switch(yc(e,r,"encrypt"),r=await((l=Gt.normalizePublicKey)==null?void 0:l.call(Gt,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(!ac(r))throw new C("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:d,apv:c}=s;let{epk:h}=s;h||(h=(await ic(r)).privateKey);const{x:E,y:g,crv:f,kty:p}=await Tc(h),R=await sc(r,h,e==="ECDH-ES"?t:e,e==="ECDH-ES"?Dn(t):parseInt(e.slice(-5,-2),10),d,c);if(a={epk:{x:E,crv:f,kty:p}},p==="EC"&&(a.epk.y=g),d&&(a.apu=j(d)),c&&(a.apv=j(c)),e==="ECDH-ES"){o=R;break}o=n||_e(t);const D=e.slice(-6);i=await Wt(D,R,o);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{o=n||_e(t),i=await fc(e,r,o);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{o=n||_e(t);const{p2c:d,p2s:c}=s;({encryptedKey:i,...a}=await lc(e,r,o,d,c));break}case"A128KW":case"A192KW":case"A256KW":{o=n||_e(t),i=await Wt(e,r,o);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{o=n||_e(t);const{iv:d}=s;({encryptedKey:i,...a}=await gc(e,r,o,d));break}default:throw new C('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:o,encryptedKey:i,parameters:a}}const Rc=Symbol();class vc{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 V("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!Qo(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new V("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(wc(V,new Map,r==null?void 0:r.crit,this._protectedHeader,n),n.zip!==void 0)throw new C('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:s,enc:i}=n;if(typeof s!="string"||!s)throw new V('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof i!="string"||!i)throw new V('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 p;({cek:o,encryptedKey:a,parameters:p}=await Ac(s,i,t,this._cek,this._keyManagementParameters)),p&&(r&&Rc in r?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...p}:this.setUnprotectedHeader(p):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...p}:this.setProtectedHeader(p))}let l,d,c;this._protectedHeader?d=Z.encode(j(JSON.stringify(this._protectedHeader))):d=Z.encode(""),this._aad?(c=j(this._aad),l=be(d,Z.encode("."),Z.encode(c))):l=d;const{ciphertext:h,tag:E,iv:g}=await Hn(i,this._plaintext,o,this._iv,l),f={ciphertext:j(h)};return g&&(f.iv=j(g)),E&&(f.tag=j(E)),a&&(f.encrypted_key=j(a)),c&&(f.aad=c),this._protectedHeader&&(f.protected=gn.decode(d)),this._sharedUnprotectedHeader&&(f.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(f.header=this._unprotectedHeader),f}}class Oc{constructor(t){this._flattened=new vc(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 Jt={base:{":disabled":{backgroundColor:"transparent"}}},Cc={mask:{number:"{{ data.number | card_mask: 'true', 'true' }}",expiration_month:"{{ data.expiration_month }}",expiration_year:"{{ data.expiration_year }}"}},Pc="DOM Element was not found";var Bc={VITE_PACKAGE_VERSION:"v3.1.0",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Yt=Bc.VITE_IFRAME_BASE_URL??xc("v3.1.0");class ge{constructor(t,r){if(Object.defineProperty(this,"options",{enumerable:!0,configurable:!0,writable:!0,value:t}),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.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}}),!Yt)throw new Error("IFRAME_BASE_URL not found");r&&Xt.set(this,{key:r})}mount(t){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error(Pc);r.innerHTML=`<iframe width="100%" height="29" src="${Yt}?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 l=Xt.get(this);l&&(l.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=Xt.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,Yt)}}function xc(e){return`https://sdk.hellgate.io/web/${e}/iframe/`}const Xt=new Map,jc=e=>e!=null;function Zt(e){const[t=null,r=null]=(e??"").split("/").map(n=>Number(n.trim()));return{month:t,year:r&&r>10?+`20${r}`:null}}function Qt(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(jc).join(" / ")}class Un extends ge{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:Zt}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:Qt})}}function er(e){return(e==null?void 0:e.replaceAll(" ",""))??null}function Mn(e){return e}class Ln extends ge{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:er}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:Mn})}}class In extends ge{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?er(t.cardNumber):null,expiry_date:t.cardExpirationDate?Zt(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?Qt(t.expiry_date):null,cardVerificationCode:t.cvc??null}:null})}}class $n extends ge{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 tr extends ge{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 ae(e,t,r){switch(e){case"card":return new In(t,r);case"cardNumber":return new Ln(t,r);case"cardExpirationDate":return new Un(t,r);case"cardVerificationCode":return new $n(t,r);case"text":return new tr(t,r);default:ASSERT_EXHAUSTIVE(e)}}function Kn(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}class at{static async init(t,r){const n=r.provider==="basis_theory"?await new sr.BasisTheory().init(r.api_key,{elements:!1}):void 0;return new at(t,r,n)}constructor(t,r,n,s){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"tokenizeConfig",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"bt",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"cardAdditionalData",{enumerable:!0,configurable:!0,writable:!0,value:s}),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,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"createForm",{enumerable:!0,configurable:!0,writable:!0,value:(i={})=>{if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const a=oe.get(this);if(!a)throw new Error("Secure key not found");const o=ee({disabled:!1,autocomplete:"on",style:{...Jt}},i),l=ae("card",o,a);return this.cardElements.card={element:l,state:this.createFieldDefaultState()},this.addElementStateListener("card"),l}}),Object.defineProperty(this,"createFormFields",{enumerable:!0,configurable:!0,writable:!0,value:(i={})=>{if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const a=oe.get(this);if(!a)throw new Error("Secure key not found");const o={disabled:!1,autocomplete:"on",style:{...Jt}},{cardNumber:l={},expiryDate:d={},securityCode:c={},...h}=i,E=ae("cardNumber",{...ee(o,{...h,...l})},a),g=ae("cardExpirationDate",{...ee(o,{...h,...d})},a),f=ae("cardVerificationCode",{...ee(o,{...h,...c})},a);return this.cardElements={cardNumber:{element:E,state:this.createFieldDefaultState()},cardExpirationDate:{element:g,state:this.createFieldDefaultState()},cardVerificationCode:{element:f,state:this.createFieldDefaultState()}},this.addElementStateListener("cardNumber"),this.addElementStateListener("cardExpirationDate"),this.addElementStateListener("cardVerificationCode"),{cardNumber:E,expiryDate:g,securityCode:f}}}),Object.defineProperty(this,"createTextField",{enumerable:!0,configurable:!0,writable:!0,value:(i={})=>{const a=oe.get(this);if(!a)throw new Error("Secure key not found");const o={disabled:!1,autocomplete:"on",style:{...Jt}};return ae("text",{...ee(o,{...i})},a)}}),Object.defineProperty(this,"tokenize",{enumerable:!0,configurable:!0,writable:!0,value:async()=>{var c,h,E,g,f;const{card:i,cardNumber:a,cardExpirationDate:o,cardVerificationCode:l}=this.cardElements;let d;if(i){const p=ce(this,i.element);d={number:(p==null?void 0:p.number)??null,expiration_month:((c=p==null?void 0:p.expiry_date)==null?void 0:c.month)??null,expiration_year:((h=p==null?void 0:p.expiry_date)==null?void 0:h.year)??null,cvc:(p==null?void 0:p.cvc)??null}}if(a&&o&&l&&(d={number:((E=ce(this,a.element))==null?void 0:E.replaceAll(" ",""))??null,expiration_month:((g=ce(this,o.element))==null?void 0:g.month)??null,expiration_year:((f=ce(this,o.element))==null?void 0:f.year)??null,cvc:ce(this,l.element)}),!d)throw new Error("Form elements must be initialized before tokenization");if(!d.number||!d.expiration_month||!d.expiration_year||!d.cvc)throw new Error("Card data is not complete");switch(this.tokenizeConfig.provider){case"basis_theory":{if(!this.bt)throw new Error("basis_theory SDK not found");return this.bt.tokenize({type:"card",data:d,...Cc})}case"guardian":return this.encryptCardData({account_number:d.number,expiry_month:d.expiration_month,expiry_year:d.expiration_year,security_code:d.cvc},this.tokenizeConfig.jwk);default:ASSERT_EXHAUSTIVE(this.tokenizeConfig)}}}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:i=>{this.stateChangeHandlers.push(i),i(this.state)}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(i=>i==null?void 0:i.element.clear())}}),Object.defineProperty(this,"reset",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(i=>i==null?void 0:i.element.unmount()),this.cardElements={}}}),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 i=>{if(!this.hasFormElements())throw new Error("Card form must be initialized and completed before processing");this.cardAdditionalData=i?this.extractAdditionalData(i):{},this.disableFormElements();const a=await this.tokenize();return this.session.completeAction({action:"tokenize_card",result:{enc_payload:a.enc_payload,additional_data:this.cardAdditionalData}})}}),oe.set(this,Kn())}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 Q({cardholder_name:ue(this,t),billing_address:{line1:ue(this,r.line1),line2:ue(this,r.line2),line3:ue(this,r.line3),city:ue(this,r.city),postal_code:ue(this,r.postal_code)}})}async encryptCardData(t,r){const n=await pc(r,"RSA-OAEP"),s=JSON.stringify(t),i=new TextEncoder().encode(s);return{enc_payload:await new Oc(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=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 oe=new Map;function ce(e,t){const r=oe.get(e);return r?t.secureValue(r):null}function ue(e,t){const r=oe.get(e);return t instanceof tr&&r?ce(e,t)??void 0:t}class Nc{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=>ct(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=>ct(n))}cancelAll(){this.abortCtrl.abort()}}const Dc=2e3;class Hc{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(l=>{l.next_action!==(s==null?void 0:s.next_action)&&l.next_action===null&&(i(l),o())});this.api.completeAction(this.id,n).then(l=>this.newStateHandle(l,a)).catch(async l=>a(await Uc(l)))})}}),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()}})}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`)))}),Dc);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 Uc(e){if(!e.ok)switch(e.status){case 400:{const t=await e.json();return new Error([t.classifier,t.message].filter(Boolean).join(". "))}}return e}const Mc={base_url:"https://api.hellgate.io"};class rr{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 rr(n,{CARD:s,"3DS":i})}static async initHandlers(t,r){const n={...Mc,...r},s=new Nc(n.base_url,n.abortCtrl),i=new Hc(t,s),a=await i.init(),o=a.next_action==="tokenize_card"?await this.createCardHandler(i,a.data):void 0,l=this.create3DSHandler(i,r);return{session:i,cardHandler:o,handler3DS:l}}static createCardHandler(t,r){return at.init(t,r)}static create3DSHandler(t,r){return new nr(t,{domContainer:r.challenge_3ds_container,labelText:r.challenge_3ds_label_text})}}A.CardElement=In,A.CardExpirationDateElement=Un,A.CardNumberElement=Ln,A.CardVerificationCodeElement=$n,A.Hellgate=rr,A.Hellgate3DSHandler=nr,A.HellgateCardHandler=at,A.TextElement=tr,A.createElement=ae,A.extractCardNumberValue=er,A.extractExpiryDateValue=Zt,A.putCardNumberValue=Mn,A.putExpiryDateValue=Qt,A.uid=Kn,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});globalThis.HellgateSDK&&(globalThis.Hellgate=globalThis.HellgateSDK.Hellgate,delete globalThis.HellgateSDK);
1
+ (function(A,Q){typeof exports=="object"&&typeof module<"u"?Q(exports):typeof define=="function"&&define.amd?define(["exports"],Q):(A=typeof globalThis<"u"?globalThis:A||self,Q(A.HellgateSDK={}))})(this,function(A){"use strict";function Q(e){return Array.isArray(e)?e.filter(Boolean):Object.fromEntries(Object.entries(e).map(([t,r])=>[t,typeof r=="object"&&r&&!Array.isArray(r)?Q(r):r]).filter(([t,r])=>typeof r=="object"&&r&&!Array.isArray(r)?!!Object.keys(r).length:r!=null&&r!=null))}function ee(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]=ee(i,a))}return r}function ct(e){if(!e.ok)throw e;return e.json()}const Kn=2e3;class rr{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??ut(),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=ut();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=ut(),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(d=>{const c=h=>{h.source===i.contentWindow&&d(h.data)};window.addEventListener("message",c),this.disposers.push(()=>window.removeEventListener("message",c))}),l=new Promise(d=>{const c=this.startAuthResultPolling(r,h=>{h.event==="AuthResultReady"&&(c(),d({requestor_trans_id:h.threeDSRequestorTransID,event:h.event}))})});Promise.any([o,l]).then(d=>{this.session.completeAction({action:"3ds_challenge",result:d})})}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=>ct(n)).then(n=>{this.startAuthResultPolling(t,r),r(n)}).catch(()=>{}),Kn),()=>window.clearTimeout(this.resultPollingTimer)}}function ut(){return document.body}var qn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fn(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 nr={},ge={},te={};Object.defineProperty(te,"__esModule",{value:!0}),te.makeRequestWithoutElementsPayloadCheck=te.makeRequestWithElementsPayloadCheck=void 0;function zn(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 sr extends zn(Error){constructor(t){super(t),this.name="NoElementsError"}}const Wn=(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 sr(`${i} Use a regular HTTP client if no elements are needed.`)};te.makeRequestWithElementsPayloadCheck=Wn;const kn=(e,t,r,n={})=>{if(e)return e.client[t](r,n);throw new sr("Elements not initialized. Use a regular HTTP client if no elements are needed.")};te.makeRequestWithoutElementsPayloadCheck=kn;var ir={},Se={},P={},b={};Object.defineProperty(b,"__esModule",{value:!0}),b.USER_AGENT_HEADER=b.USER_AGENT_CLIENT=b.MERGE_CONTENT_TYPE=b.DEFAULT_ELEMENTS_BASE_URL=b.DEFAULT_BASE_URL=b.CONTENT_TYPE_HEADER=b.CLIENT_USER_AGENT_HEADER=b.CLIENT_BASE_PATHS=b.BT_TRANSACTION_ID_HEADER=b.BT_TRACE_ID_HEADER=b.BT_IDEMPOTENCY_KEY_HEADER=b.BT_EXPOSE_PROXY_RESPONSE_HEADER=b.BROWSER_LIST=b.API_KEY_HEADER=void 0;const Gn="BT-API-KEY";b.API_KEY_HEADER=Gn;const Vn="bt-trace-id";b.BT_TRACE_ID_HEADER=Vn;const Jn="bt-idempotency-key";b.BT_IDEMPOTENCY_KEY_HEADER=Jn;const Yn="BT-EXPOSE-RAW-PROXY-RESPONSE";b.BT_EXPOSE_PROXY_RESPONSE_HEADER=Yn;const Xn="BT-TRANSACTION-ID";b.BT_TRANSACTION_ID_HEADER=Xn;const Zn="Content-Type";b.CONTENT_TYPE_HEADER=Zn;const Qn="application/merge-patch+json";b.MERGE_CONTENT_TYPE=Qn;const es="User-Agent";b.USER_AGENT_HEADER=es;const ts="BT-CLIENT-USER-AGENT";b.CLIENT_USER_AGENT_HEADER=ts;const rs="BasisTheoryJS";b.USER_AGENT_CLIENT=rs;const ns="https://api.basistheory.com";b.DEFAULT_BASE_URL=ns;const ss="https://js.basistheory.com/hosted-elements";b.DEFAULT_ELEMENTS_BASE_URL=ss;const is={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"};b.CLIENT_BASE_PATHS=is;const as=[{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"}];b.BROWSER_LIST=as;var m={};function ar(e,t){return function(){return e.apply(t,arguments)}}const{toString:os}=Object.prototype,{getPrototypeOf:lt}=Object,Te=(e=>t=>{const r=os.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),H=e=>(e=e.toLowerCase(),t=>Te(t)===e),Ae=e=>t=>typeof t===e,{isArray:re}=Array,le=Ae("undefined");function cs(e){return e!==null&&!le(e)&&e.constructor!==null&&!le(e.constructor)&&x(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const or=H("ArrayBuffer");function us(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&or(e.buffer),t}const ls=Ae("string"),x=Ae("function"),cr=Ae("number"),Re=e=>e!==null&&typeof e=="object",ds=e=>e===!0||e===!1,ve=e=>{if(Te(e)!=="object")return!1;const t=lt(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},fs=H("Date"),hs=H("File"),ps=H("Blob"),ms=H("FileList"),Es=e=>Re(e)&&x(e.pipe),ys=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||x(e.append)&&((t=Te(e))==="formdata"||t==="object"&&x(e.toString)&&e.toString()==="[object FormData]"))},bs=H("URLSearchParams"),_s=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function de(e,t,{allOwnKeys:r=!1}={}){if(e===null||typeof e>"u")return;let n,s;if(typeof e!="object"&&(e=[e]),re(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 ur(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 lr=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:qn,dr=e=>!le(e)&&e!==lr;function dt(){const{caseless:e}=dr(this)&&this||{},t={},r=(n,s)=>{const i=e&&ur(t,s)||s;ve(t[i])&&ve(n)?t[i]=dt(t[i],n):ve(n)?t[i]=dt({},n):re(n)?t[i]=n.slice():t[i]=n};for(let n=0,s=arguments.length;n<s;n++)arguments[n]&&de(arguments[n],r);return t}const ws=(e,t,r,{allOwnKeys:n}={})=>(de(t,(s,i)=>{r&&x(s)?e[i]=ar(s,r):e[i]=s},{allOwnKeys:n}),e),gs=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),Ss=(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)},Ts=(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&&lt(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},As=(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},Rs=e=>{if(!e)return null;if(re(e))return e;let t=e.length;if(!cr(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},vs=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&lt(Uint8Array)),Os=(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])}},Cs=(e,t)=>{let r;const n=[];for(;(r=e.exec(t))!==null;)n.push(r);return n},Ps=H("HTMLFormElement"),Bs=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(r,n,s){return n.toUpperCase()+s}),fr=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),xs=H("RegExp"),hr=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};de(r,(s,i)=>{let a;(a=t(s,i,e))!==!1&&(n[i]=a||s)}),Object.defineProperties(e,n)},js=e=>{hr(e,(t,r)=>{if(x(e)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=e[r];if(x(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+"'")})}})},Ns=(e,t)=>{const r={},n=s=>{s.forEach(i=>{r[i]=!0})};return re(e)?n(e):n(String(e).split(t)),r},Ds=()=>{},Hs=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ft="abcdefghijklmnopqrstuvwxyz",pr="0123456789",mr={DIGIT:pr,ALPHA:ft,ALPHA_DIGIT:ft+ft.toUpperCase()+pr},Us=(e=16,t=mr.ALPHA_DIGIT)=>{let r="";const{length:n}=t;for(;e--;)r+=t[Math.random()*n|0];return r};function Ms(e){return!!(e&&x(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const Ls=e=>{const t=new Array(10),r=(n,s)=>{if(Re(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[s]=n;const i=re(n)?[]:{};return de(n,(a,o)=>{const l=r(a,s+1);!le(l)&&(i[o]=l)}),t[s]=void 0,i}}return n};return r(e,0)},Is=H("AsyncFunction");var u={isArray:re,isArrayBuffer:or,isBuffer:cs,isFormData:ys,isArrayBufferView:us,isString:ls,isNumber:cr,isBoolean:ds,isObject:Re,isPlainObject:ve,isUndefined:le,isDate:fs,isFile:hs,isBlob:ps,isRegExp:xs,isFunction:x,isStream:Es,isURLSearchParams:bs,isTypedArray:vs,isFileList:ms,forEach:de,merge:dt,extend:ws,trim:_s,stripBOM:gs,inherits:Ss,toFlatObject:Ts,kindOf:Te,kindOfTest:H,endsWith:As,toArray:Rs,forEachEntry:Os,matchAll:Cs,isHTMLForm:Ps,hasOwnProperty:fr,hasOwnProp:fr,reduceDescriptors:hr,freezeMethods:js,toObjectSet:Ns,toCamelCase:Bs,noop:Ds,toFiniteNumber:Hs,findKey:ur,global:lr,isContextDefined:dr,ALPHABET:mr,generateString:Us,isSpecCompliantForm:Ms,toJSONObject:Ls,isAsyncFn:Is,isThenable:e=>e&&(Re(e)||x(e))&&x(e.then)&&x(e.catch)};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)}u.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:u.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Er=y.prototype,yr={};["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=>{yr[e]={value:e}}),Object.defineProperties(y,yr),Object.defineProperty(Er,"isAxiosError",{value:!0}),y.from=(e,t,r,n,s,i)=>{const a=Object.create(Er);return u.toFlatObject(e,a,function(l){return l!==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 $s=null;function ht(e){return u.isPlainObject(e)||u.isArray(e)}function br(e){return u.endsWith(e,"[]")?e.slice(0,-2):e}function _r(e,t,r){return e?e.concat(t).map(function(s,i){return s=br(s),!r&&i?"["+s+"]":s}).join(r?".":""):t}function Ks(e){return u.isArray(e)&&!e.some(ht)}const qs=u.toFlatObject(u,{},null,function(t){return/^is[A-Z]/.test(t)});function Oe(e,t,r){if(!u.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,r=u.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,R){return!u.isUndefined(R[p])});const n=r.metaTokens,s=r.visitor||c,i=r.dots,a=r.indexes,l=(r.Blob||typeof Blob<"u"&&Blob)&&u.isSpecCompliantForm(t);if(!u.isFunction(s))throw new TypeError("visitor must be a function");function d(f){if(f===null)return"";if(u.isDate(f))return f.toISOString();if(!l&&u.isBlob(f))throw new y("Blob is not supported. Use a Buffer instead.");return u.isArrayBuffer(f)||u.isTypedArray(f)?l&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function c(f,p,R){let D=f;if(f&&!R&&typeof f=="object"){if(u.endsWith(p,"{}"))p=n?p:p.slice(0,-2),f=JSON.stringify(f);else if(u.isArray(f)&&Ks(f)||(u.isFileList(f)||u.endsWith(p,"[]"))&&(D=u.toArray(f)))return p=br(p),D.forEach(function(ot,Lc){!(u.isUndefined(ot)||ot===null)&&t.append(a===!0?_r([p],Lc,i):a===null?p:p+"[]",d(ot))}),!1}return ht(f)?!0:(t.append(_r(R,p,i),d(f)),!1)}const h=[],E=Object.assign(qs,{defaultVisitor:c,convertValue:d,isVisitable:ht});function w(f,p){if(!u.isUndefined(f)){if(h.indexOf(f)!==-1)throw Error("Circular reference detected in "+p.join("."));h.push(f),u.forEach(f,function(D,q){(!(u.isUndefined(D)||D===null)&&s.call(t,D,u.isString(q)?q.trim():q,p,E))===!0&&w(D,p?p.concat(q):[q])}),h.pop()}}if(!u.isObject(e))throw new TypeError("data must be an object");return w(e),t}function wr(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(n){return t[n]})}function pt(e,t){this._pairs=[],e&&Oe(e,this,t)}const gr=pt.prototype;gr.append=function(t,r){this._pairs.push([t,r])},gr.toString=function(t){const r=t?function(n){return t.call(this,n,wr)}:wr;return this._pairs.map(function(s){return r(s[0])+"="+r(s[1])},"").join("&")};function Fs(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Sr(e,t,r){if(!t)return e;const n=r&&r.encode||Fs,s=r&&r.serialize;let i;if(s?i=s(t,r):i=u.isURLSearchParams(t)?t.toString():new pt(t,r).toString(n),i){const a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class zs{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){u.forEach(this.handlers,function(n){n!==null&&t(n)})}}var Tr=zs,Ar={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Ws=typeof URLSearchParams<"u"?URLSearchParams:pt,ks=typeof FormData<"u"?FormData:null,Gs=typeof Blob<"u"?Blob:null,Vs={isBrowser:!0,classes:{URLSearchParams:Ws,FormData:ks,Blob:Gs},protocols:["http","https","file","blob","url","data"]};const Rr=typeof window<"u"&&typeof document<"u",Js=(e=>Rr&&["ReactNative","NativeScript","NS"].indexOf(e)<0)(typeof navigator<"u"&&navigator.product),Ys=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function";var Xs=Object.freeze({__proto__:null,hasBrowserEnv:Rr,hasStandardBrowserWebWorkerEnv:Ys,hasStandardBrowserEnv:Js}),U={...Xs,...Vs};function Zs(e,t){return Oe(e,new U.classes.URLSearchParams,Object.assign({visitor:function(r,n,s,i){return U.isNode&&u.isBuffer(r)?(this.append(n,r.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function Qs(e){return u.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function ei(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 vr(e){function t(r,n,s,i){let a=r[i++];const o=Number.isFinite(+a),l=i>=r.length;return a=!a&&u.isArray(s)?s.length:a,l?(u.hasOwnProp(s,a)?s[a]=[s[a],n]:s[a]=n,!o):((!s[a]||!u.isObject(s[a]))&&(s[a]=[]),t(r,n,s[a],i)&&u.isArray(s[a])&&(s[a]=ei(s[a])),!o)}if(u.isFormData(e)&&u.isFunction(e.entries)){const r={};return u.forEachEntry(e,(n,s)=>{t(Qs(n),s,r,0)}),r}return null}function ti(e,t,r){if(u.isString(e))try{return(t||JSON.parse)(e),u.trim(e)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(e)}const mt={transitional:Ar,adapter:["xhr","http"],transformRequest:[function(t,r){const n=r.getContentType()||"",s=n.indexOf("application/json")>-1,i=u.isObject(t);if(i&&u.isHTMLForm(t)&&(t=new FormData(t)),u.isFormData(t))return s&&s?JSON.stringify(vr(t)):t;if(u.isArrayBuffer(t)||u.isBuffer(t)||u.isStream(t)||u.isFile(t)||u.isBlob(t))return t;if(u.isArrayBufferView(t))return t.buffer;if(u.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 Zs(t,this.formSerializer).toString();if((o=u.isFileList(t))||n.indexOf("multipart/form-data")>-1){const l=this.env&&this.env.FormData;return Oe(o?{"files[]":t}:t,l&&new l,this.formSerializer)}}return i||s?(r.setContentType("application/json",!1),ti(t)):t}],transformResponse:[function(t){const r=this.transitional||mt.transitional,n=r&&r.forcedJSONParsing,s=this.responseType==="json";if(t&&u.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:U.classes.FormData,Blob:U.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};u.forEach(["delete","get","head","post","put","patch"],e=>{mt.headers[e]={}});var Et=mt;const ri=u.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 ni=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]&&ri[r])&&(r==="set-cookie"?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)}),t};const Or=Symbol("internals");function fe(e){return e&&String(e).trim().toLowerCase()}function Ce(e){return e===!1||e==null?e:u.isArray(e)?e.map(Ce):String(e)}function si(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 ii=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function yt(e,t,r,n,s){if(u.isFunction(n))return n.call(this,t,r);if(s&&(t=r),!!u.isString(t)){if(u.isString(n))return t.indexOf(n)!==-1;if(u.isRegExp(n))return n.test(t)}}function ai(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,r,n)=>r.toUpperCase()+n)}function oi(e,t){const r=u.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 Pe{constructor(t){t&&this.set(t)}set(t,r,n){const s=this;function i(o,l,d){const c=fe(l);if(!c)throw new Error("header name must be a non-empty string");const h=u.findKey(s,c);(!h||s[h]===void 0||d===!0||d===void 0&&s[h]!==!1)&&(s[h||l]=Ce(o))}const a=(o,l)=>u.forEach(o,(d,c)=>i(d,c,l));return u.isPlainObject(t)||t instanceof this.constructor?a(t,r):u.isString(t)&&(t=t.trim())&&!ii(t)?a(ni(t),r):t!=null&&i(r,t,n),this}get(t,r){if(t=fe(t),t){const n=u.findKey(this,t);if(n){const s=this[n];if(!r)return s;if(r===!0)return si(s);if(u.isFunction(r))return r.call(this,s,n);if(u.isRegExp(r))return r.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,r){if(t=fe(t),t){const n=u.findKey(this,t);return!!(n&&this[n]!==void 0&&(!r||yt(this,this[n],n,r)))}return!1}delete(t,r){const n=this;let s=!1;function i(a){if(a=fe(a),a){const o=u.findKey(n,a);o&&(!r||yt(n,n[o],o,r))&&(delete n[o],s=!0)}}return u.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||yt(this,this[i],i,t,!0))&&(delete this[i],s=!0)}return s}normalize(t){const r=this,n={};return u.forEach(this,(s,i)=>{const a=u.findKey(n,i);if(a){r[a]=Ce(s),delete r[i];return}const o=t?ai(i):String(i).trim();o!==i&&delete r[i],r[o]=Ce(s),n[o]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const r=Object.create(null);return u.forEach(this,(n,s)=>{n!=null&&n!==!1&&(r[s]=t&&u.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[Or]=this[Or]={accessors:{}}).accessors,s=this.prototype;function i(a){const o=fe(a);n[o]||(oi(s,a),n[o]=!0)}return u.isArray(t)?t.forEach(i):i(t),this}}Pe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),u.reduceDescriptors(Pe.prototype,({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(n){this[r]=n}}}),u.freezeMethods(Pe);var F=Pe;function bt(e,t){const r=this||Et,n=t||r,s=F.from(n.headers);let i=n.data;return u.forEach(e,function(o){i=o.call(r,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function Cr(e){return!!(e&&e.__CANCEL__)}function he(e,t,r){y.call(this,e??"canceled",y.ERR_CANCELED,t,r),this.name="CanceledError"}u.inherits(he,y,{__CANCEL__:!0});function ci(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))}var ui=U.hasStandardBrowserEnv?function(){return{write:function(r,n,s,i,a,o){const l=[];l.push(r+"="+encodeURIComponent(n)),u.isNumber(s)&&l.push("expires="+new Date(s).toGMTString()),u.isString(i)&&l.push("path="+i),u.isString(a)&&l.push("domain="+a),o===!0&&l.push("secure"),document.cookie=l.join("; ")},read:function(r){const n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function li(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function di(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function Pr(e,t){return e&&!li(t)?di(e,t):t}var fi=U.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(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=u.isString(a)?s(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}();function hi(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function pi(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(l){const d=Date.now(),c=n[i];a||(a=d),r[s]=l,n[s]=d;let h=i,E=0;for(;h!==s;)E+=r[h++],h=h%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),d-a<t)return;const w=c&&d-c;return w?Math.round(E*1e3/w):void 0}}function Br(e,t){let r=0;const n=pi(50,250);return s=>{const i=s.loaded,a=s.lengthComputable?s.total:void 0,o=i-r,l=n(o),d=i<=a;r=i;const c={loaded:i,total:a,progress:a?i/a:void 0,bytes:o,rate:l||void 0,estimated:l&&a&&d?(a-i)/l:void 0,event:s};c[t?"download":"upload"]=!0,e(c)}}var mi=typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(r,n){let s=e.data;const i=F.from(e.headers).normalize(),a=e.responseType;let o;function l(){e.cancelToken&&e.cancelToken.unsubscribe(o),e.signal&&e.signal.removeEventListener("abort",o)}let d;if(u.isFormData(s)){if(U.hasStandardBrowserEnv||U.hasStandardBrowserWebWorkerEnv)i.setContentType(!1);else if((d=i.getContentType())!==!1){const[f,...p]=d?d.split(";").map(R=>R.trim()).filter(Boolean):[];i.setContentType([f||"multipart/form-data",...p].join("; "))}}let c=new XMLHttpRequest;if(e.auth){const f=e.auth.username||"",p=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(f+":"+p))}const h=Pr(e.baseURL,e.url);c.open(e.method.toUpperCase(),Sr(h,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function E(){if(!c)return;const f=F.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),R={data:!a||a==="text"||a==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:f,config:e,request:c};ci(function(q){r(q),l()},function(q){n(q),l()},R),c=null}if("onloadend"in c?c.onloadend=E:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(E)},c.onabort=function(){c&&(n(new y("Request aborted",y.ECONNABORTED,e,c)),c=null)},c.onerror=function(){n(new y("Network Error",y.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let p=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const R=e.transitional||Ar;e.timeoutErrorMessage&&(p=e.timeoutErrorMessage),n(new y(p,R.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,e,c)),c=null},U.hasStandardBrowserEnv){const f=fi(h)&&e.xsrfCookieName&&ui.read(e.xsrfCookieName);f&&i.set(e.xsrfHeaderName,f)}s===void 0&&i.setContentType(null),"setRequestHeader"in c&&u.forEach(i.toJSON(),function(p,R){c.setRequestHeader(R,p)}),u.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),a&&a!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",Br(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",Br(e.onUploadProgress)),(e.cancelToken||e.signal)&&(o=f=>{c&&(n(!f||f.type?new he(null,e,c):f),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(o),e.signal&&(e.signal.aborted?o():e.signal.addEventListener("abort",o)));const w=hi(h);if(w&&U.protocols.indexOf(w)===-1){n(new y("Unsupported protocol "+w+":",y.ERR_BAD_REQUEST,e));return}c.send(s||null)})};const _t={http:$s,xhr:mi};u.forEach(_t,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const xr=e=>`- ${e}`,Ei=e=>u.isFunction(e)||e===null||e===!1;var jr={getAdapter:e=>{e=u.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,!Ei(r)&&(n=_t[(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,l])=>`adapter ${o} `+(l===!1?"is not supported by the environment":"is not available in the build"));let a=t?i.length>1?`since :
4
+ `+i.map(xr).join(`
5
+ `):" "+xr(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:_t};function wt(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new he(null,e)}function Nr(e){return wt(e),e.headers=F.from(e.headers),e.data=bt.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),jr.getAdapter(e.adapter||Et.adapter)(e).then(function(n){return wt(e),n.data=bt.call(e,e.transformResponse,n),n.headers=F.from(n.headers),n},function(n){return Cr(n)||(wt(e),n&&n.response&&(n.response.data=bt.call(e,e.transformResponse,n.response),n.response.headers=F.from(n.response.headers))),Promise.reject(n)})}const Dr=e=>e instanceof F?e.toJSON():e;function ne(e,t){t=t||{};const r={};function n(d,c,h){return u.isPlainObject(d)&&u.isPlainObject(c)?u.merge.call({caseless:h},d,c):u.isPlainObject(c)?u.merge({},c):u.isArray(c)?c.slice():c}function s(d,c,h){if(u.isUndefined(c)){if(!u.isUndefined(d))return n(void 0,d,h)}else return n(d,c,h)}function i(d,c){if(!u.isUndefined(c))return n(void 0,c)}function a(d,c){if(u.isUndefined(c)){if(!u.isUndefined(d))return n(void 0,d)}else return n(void 0,c)}function o(d,c,h){if(h in t)return n(d,c);if(h in e)return n(void 0,d)}const l={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials: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:(d,c)=>s(Dr(d),Dr(c),!0)};return u.forEach(Object.keys(Object.assign({},e,t)),function(c){const h=l[c]||s,E=h(e[c],t[c],c);u.isUndefined(E)&&h!==o||(r[c]=E)}),r}const Hr="1.6.1",gt={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{gt[e]=function(n){return typeof n===e||"a"+(t<1?"n ":" ")+e}});const Ur={};gt.transitional=function(t,r,n){function s(i,a){return"[Axios v"+Hr+"] 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&&!Ur[a]&&(Ur[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 yi(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],l=o===void 0||a(o,i,e);if(l!==!0)throw new y("option "+i+" must be "+l,y.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new y("Unknown option "+i,y.ERR_BAD_OPTION)}}var St={assertOptions:yi,validators:gt};const W=St.validators;class Be{constructor(t){this.defaults=t,this.interceptors={request:new Tr,response:new Tr}}request(t,r){typeof t=="string"?(r=r||{},r.url=t):r=t||{},r=ne(this.defaults,r);const{transitional:n,paramsSerializer:s,headers:i}=r;n!==void 0&&St.assertOptions(n,{silentJSONParsing:W.transitional(W.boolean),forcedJSONParsing:W.transitional(W.boolean),clarifyTimeoutError:W.transitional(W.boolean)},!1),s!=null&&(u.isFunction(s)?r.paramsSerializer={serialize:s}:St.assertOptions(s,{encode:W.function,serialize:W.function},!0)),r.method=(r.method||this.defaults.method||"get").toLowerCase();let a=i&&u.merge(i.common,i[r.method]);i&&u.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),r.headers=F.concat(a,i);const o=[];let l=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(r)===!1||(l=l&&p.synchronous,o.unshift(p.fulfilled,p.rejected))});const d=[];this.interceptors.response.forEach(function(p){d.push(p.fulfilled,p.rejected)});let c,h=0,E;if(!l){const f=[Nr.bind(this),void 0];for(f.unshift.apply(f,o),f.push.apply(f,d),E=f.length,c=Promise.resolve(r);h<E;)c=c.then(f[h++],f[h++]);return c}E=o.length;let w=r;for(h=0;h<E;){const f=o[h++],p=o[h++];try{w=f(w)}catch(R){p.call(this,R);break}}try{c=Nr.call(this,w)}catch(f){return Promise.reject(f)}for(h=0,E=d.length;h<E;)c=c.then(d[h++],d[h++]);return c}getUri(t){t=ne(this.defaults,t);const r=Pr(t.baseURL,t.url);return Sr(r,t.params,t.paramsSerializer)}}u.forEach(["delete","get","head","options"],function(t){Be.prototype[t]=function(r,n){return this.request(ne(n||{},{method:t,url:r,data:(n||{}).data}))}}),u.forEach(["post","put","patch"],function(t){function r(n){return function(i,a,o){return this.request(ne(o||{},{method:t,headers:n?{"Content-Type":"multipart/form-data"}:{},url:i,data:a}))}}Be.prototype[t]=r(),Be.prototype[t+"Form"]=r(!0)});var xe=Be;class Tt{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 he(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)}static source(){let t;return{token:new Tt(function(s){t=s}),cancel:t}}}var bi=Tt;function _i(e){return function(r){return e.apply(null,r)}}function wi(e){return u.isObject(e)&&e.isAxiosError===!0}const At={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(At).forEach(([e,t])=>{At[t]=e});var gi=At;function Mr(e){const t=new xe(e),r=ar(xe.prototype.request,t);return u.extend(r,xe.prototype,t,{allOwnKeys:!0}),u.extend(r,t,null,{allOwnKeys:!0}),r.create=function(s){return Mr(ne(e,s))},r}const T=Mr(Et);T.Axios=xe,T.CanceledError=he,T.CancelToken=bi,T.isCancel=Cr,T.VERSION=Hr,T.toFormData=Oe,T.AxiosError=y,T.Cancel=T.CanceledError,T.all=function(t){return Promise.all(t)},T.spread=_i,T.isAxiosError=wi,T.mergeConfig=ne,T.AxiosHeaders=F,T.formToJSON=e=>vr(u.isHTMLForm(e)?new FormData(e):e),T.getAdapter=jr.getAdapter,T.HttpStatusCode=gi,T.default=T;var Lr=T,Rt={exports:{}};const Ir=e=>typeof e=="object"&&e!==null,$r=Symbol("skip"),Kr=e=>Ir(e)&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),vt=(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=>Kr(o)?vt(o,t,r,n):o);if(Array.isArray(e))return i(e);for(const[a,o]of Object.entries(e)){const l=t(a,o,e);if(l===$r)continue;let[d,c,{shouldRecurse:h=!0}={}]=l;d!=="__proto__"&&(r.deep&&h&&Kr(c)&&(c=Array.isArray(c)?i(c):vt(c,t,r,n)),s[d]=c)}return s};Rt.exports=(e,t,r)=>{if(!Ir(e))throw new TypeError(`Expected an object, got \`${e}\` (${typeof e})`);return vt(e,t,r)},Rt.exports.mapObjectSkip=$r;var qr=Rt.exports,Ot={exports:{}};const Si=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},Fr=(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=Si(e)),e=e.replace(/^[_.\- ]+/,"").toLowerCase().replace(/[_.\- ]+(\w|$)/g,(s,i)=>i.toUpperCase()).replace(/\d+(\w|$)/g,s=>s.toUpperCase()),r(e))};Ot.exports=Fr,Ot.exports.default=Fr;var Ti=Ot.exports;class Ai{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 Ri=Ai;const zr=qr,vi=Ti,Oi=Ri,Ci=(e,t)=>e.some(r=>typeof r=="string"?r===t:(r.lastIndex=0,r.test(t))),Ct=new Oi({maxSize:1e5}),Wr=e=>typeof e=="object"&&e!==null&&!(e instanceof RegExp)&&!(e instanceof Error)&&!(e instanceof Date),kr=(e,t)=>{if(!Wr(e))return e;t={deep:!1,pascalCase:!1,...t};const{exclude:r,pascalCase:n,stopPaths:s,deep:i}=t,a=new Set(s),o=l=>(d,c)=>{if(i&&Wr(c)){const h=l===void 0?d:`${l}.${d}`;a.has(h)||(c=zr(c,o(h)))}if(!(r&&Ci(r,d))){const h=n?`${d}_`:d;if(Ct.has(h))d=Ct.get(h);else{const E=vi(d,{pascalCase:n});d.length<100&&Ct.set(h,E),d=E}}return[d,c]};return zr(e,o(void 0))};var Pi=(e,t)=>Array.isArray(e)?Object.keys(e).map(r=>kr(e[r],t)):kr(e,t),Pt,Gr;function Vr(){return Gr||(Gr=1,Pt=Vr()),Pt}var je=function(){return je=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},je.apply(this,arguments)};typeof SuppressedError=="function"&&SuppressedError;function Bi(e){return e.toLowerCase()}var xi=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],ji=/[^A-Z0-9]+/gi;function Ni(e,t){t===void 0&&(t={});for(var r=t.splitRegexp,n=r===void 0?xi:r,s=t.stripRegexp,i=s===void 0?ji:s,a=t.transform,o=a===void 0?Bi:a,l=t.delimiter,d=l===void 0?" ":l,c=Jr(Jr(e,n,"$1\0$2"),i,"\0"),h=0,E=c.length;c.charAt(h)==="\0";)h++;for(;c.charAt(E-1)==="\0";)E--;return c.slice(h,E).split("\0").map(o).join(d)}function Jr(e,t,r){return t instanceof RegExp?e.replace(t,r):t.reduce(function(n,s){return n.replace(s,r)},e)}function Di(e,t){return t===void 0&&(t={}),Ni(e,je({delimiter:"."},t))}function Hi(e,t){return t===void 0&&(t={}),Di(e,je({delimiter:"_"},t))}const Ui=Fn(Object.freeze(Object.defineProperty({__proto__:null,snakeCase:Hi},Symbol.toStringTag,{value:"Module"})));var Mi=Ki,Li=/\s/,Ii=/(_|-|\.|:)/,$i=/([a-z][A-Z]|[A-Z][a-z])/;function Ki(e){return Li.test(e)?e.toLowerCase():Ii.test(e)?(Fi(e)||e).toLowerCase():$i.test(e)?Wi(e).toLowerCase():e.toLowerCase()}var qi=/[\W_]+(.|$)/g;function Fi(e){return e.replace(qi,function(t,r){return r?" "+r:""})}var zi=/(.)([A-Z]+)/g;function Wi(e){return e.replace(zi,function(t,r,n){return r+" "+n.toLowerCase().split("").join(" ")})}var ki=Mi,Gi=Vi;function Vi(e){return ki(e).replace(/[\W_]+(.|$)/g,function(t,r){return r?" "+r:""}).trim()}var Ji=Gi,Yi=Xi;function Xi(e){return Ji(e).replace(/\s/g,"_")}const Zi=qr,Qi=Yi;var ea=function(e,t){return t=Object.assign({deep:!0,exclude:[]},t),Zi(e,function(r,n){return[ta(t.exclude,r)?r:Qi(r),n]},t)};function ta(e,t){return e.some(function(r){return typeof r=="string"?r===t:r.test(t)})}var pe={};Object.defineProperty(pe,"__esModule",{value:!0}),pe.BasisTheoryApiError=void 0;function ra(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 Bt extends ra(Error){constructor(t,r,n){super(t),this.status=r,this.data=n,this.name="BasisTheoryApiError",Object.setPrototypeOf(this,Bt.prototype)}}pe.BasisTheoryApiError=Bt,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 Yr=Ne(Lr),M=Ne(Pi),Xr=Ne(Vr()),na=Ui,me=Ne(ea),sa=pe,J=b;function Ne(e){return e&&e.__esModule?e:{default:e}}const ia=e=>{if(e==null)throw new Error("BasisTheory has not yet been properly initialized.");return e};m.assertInit=ia;const aa=e=>{if(!(typeof e>"u"))return(0,me.default)(e,{deep:!0})};m.transformRequestSnakeCase=aa;const oa=e=>e;m.proxyRaw=oa;const ca=e=>{if(!(typeof e>"u"))return{...(0,me.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorRequestSnakeCase=ca;const ua=e=>{if(!(typeof e>"u"))return{...(0,me.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyRequestSnakeCase=ua;const la=e=>{if(!(typeof e>"u"))return{...(0,me.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenRequestSnakeCase=la;const xt=e=>e&&(e==null?void 0:e.pagination)!==void 0&&(e==null?void 0:e.data)!==void 0,da=e=>{if(!(typeof e>"u"))return xt(e)?{data:e.data.map(n=>({...(0,M.default)(n,{deep:!0}),...n.data!==void 0?{data:n.data}:{},...n.metadata!==void 0?{metadata:n.metadata}:{}})),pagination:(0,M.default)(e.pagination,{deep:!0})}:{...(0,M.default)(e,{deep:!0}),...e.data!==void 0?{data:e.data}:{},...e.metadata!==void 0?{metadata:e.metadata}:{}}};m.transformTokenResponseCamelCase=da;const fa=e=>{if(!(typeof e>"u"))return xt(e)?{data:e.data.map(n=>({...(0,M.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,M.default)(e.pagination,{deep:!0})}:{...(0,M.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformReactorResponseCamelCase=fa;const ha=e=>{if(!(typeof e>"u"))return xt(e)?{data:e.data.map(n=>({...(0,M.default)(n,{deep:!0}),...n.configuration!==void 0?{configuration:n.configuration}:{}})),pagination:(0,M.default)(e.pagination,{deep:!0})}:{...(0,M.default)(e,{deep:!0}),...e.configuration!==void 0?{configuration:e.configuration}:{}}};m.transformProxyResponseCamelCase=ha;const pa=e=>{if(!(typeof e>"u"))return(0,M.default)(e,{deep:!0})};m.transformResponseCamelCase=pa;const ma=e=>e==null?void 0:e.data;m.dataExtractor=ma;const Ea=e=>({data:e==null?void 0:e.data,headers:e==null?void 0:e.headers});m.dataAndHeadersExtractor=Ea;const jt=e=>[e,...Yr.default.defaults.transformRequest];m.concatRequestTransformerWithDefault=jt;const Nt=e=>[...Yr.default.defaults.transformResponse,e];m.concatResponseTransformerWithDefault=Nt;const ya=(e,t)=>{if(!e)return t?{...t.transformRequest!==void 0?{transformRequest:jt(t.transformRequest)}:{},...t.transformResponse!==void 0?{transformResponse:Nt(t.transformResponse)}:{}}:void 0;const{apiKey:r,correlationId:n,idempotencyKey:s,transactionId:i,query:a,headers:o}=e,l=r?{[J.API_KEY_HEADER]:r}:{},d=n?{[J.BT_TRACE_ID_HEADER]:n}:{},c=s?{[J.BT_IDEMPOTENCY_KEY_HEADER]:s}:{},h=i?{[J.BT_TRANSACTION_ID_HEADER]:i}:{};return{headers:{...l,...d,...c,...h,...typeof o<"u"&&{...o}},...typeof a<"u"&&{params:a},...(t==null?void 0:t.transformRequest)!==void 0?{transformRequest:jt(t.transformRequest)}:{},...(t==null?void 0:t.transformResponse)!==void 0?{transformResponse:Nt(t.transformResponse)}:{}}};m.createRequestConfig=ya;const ba=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 sa.BasisTheoryApiError(e.message,n,s)};m.errorInterceptor=ba;const _a=(e={})=>{const t=Object.keys(e);if(t.length){const r=new URLSearchParams,n=(s,i,a=!1)=>{const o=typeof i,l=a?s:(0,na.snakeCase)(s);(i===null||["boolean","number","string"].includes(o))&&r.append(l,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=_a;const wa=e=>`(${e.name||""}; ${e.version||""}; ${e.url||""})`,ga=e=>{let t=`${J.USER_AGENT_CLIENT}/unknown`;return e&&Object.keys(e||{}).length&&(t+=` ${wa(e)}`),t};m.buildUserAgentString=ga;const Zr=()=>{const{userAgent:e}=window.navigator;let t="unknown";const r=J.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=Zr;const Qr=()=>typeof window=="object"&&window.navigator.product==="ReactNative",en=()=>{if(Qr())return"ReactNative";if(typeof window>"u")try{return`${Xr.default.type()}/${Xr.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=en;const tn=()=>Qr()?"ReactNative":typeof window>"u"?`NodeJS/${process.version}`:Zr();m.getRuntime=tn;const Sa=e=>{const t={client:J.USER_AGENT_CLIENT,clientVersion:"unknown",osVersion:en(),runtimeVersion:tn(),application:{}};return e&&(t.application=e),JSON.stringify((0,me.default)(t))};m.buildClientUserAgentString=Sa;var De={};Object.defineProperty(De,"__esModule",{value:!0}),De.BasisTheoryValidationError=void 0;function Ta(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 Dt extends Ta(Error){constructor(t,r,n){super(t),this.details=r,this.validation=n,this.name="BasisTheoryValidationError",Object.setPrototypeOf(this,Dt.prototype)}}De.BasisTheoryValidationError=Dt;var He={};Object.defineProperty(He,"__esModule",{value:!0}),He.HttpClientError=void 0;function Aa(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 Ht extends Aa(Error){constructor(t,r,n,s){super(t),this.name="HttpClientError",this.status=r,this.data=n,this.headers=s,Object.setPrototypeOf(this,Ht.prototype)}}He.HttpClientError=Ht,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=b;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=pe,i=De,a=He}(P);var B={},Ra={},Ue={};Object.defineProperty(Ue,"__esModule",{value:!0}),Ue.BasisTheoryService=void 0;var Me=va(Lr),k=P;function va(e){return e&&e.__esModule?e:{default:e}}class Oa{constructor(t){const{apiKey:r,baseURL:n,transformRequest:s,transformResponse:i,appInfo:a}=t;if(typeof Me.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=Me.default.create({baseURL:n,headers:{[k.API_KEY_HEADER]:r,[k.CLIENT_USER_AGENT_HEADER]:(0,k.buildClientUserAgentString)(a),...typeof window>"u"&&{[k.USER_AGENT_HEADER]:(0,k.buildUserAgentString)(a)}},transformRequest:[].concat(s||k.transformRequestSnakeCase,Me.default.defaults.transformRequest),transformResponse:Me.default.defaults.transformResponse.concat(i||k.transformResponseCamelCase)}),this.client.interceptors.response.use(void 0,k.errorInterceptor)}}Ue.BasisTheoryService=Oa,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ra;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=Ue;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]}})})}(B),Object.defineProperty(Se,"__esModule",{value:!0}),Se.BasisTheoryTransactions=void 0;var Ut=P,Ee=m,Ca=B;class Pa extends Ca.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(Ee.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(Ee.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,Ut.createRequestConfig)(t)).then(Ee.dataExtractor)}commit(t,r={}){const n=`/${t}/commit`;return this.client.post(n,void 0,(0,Ut.createRequestConfig)(r)).then(Ee.dataExtractor)}rollback(t,r={}){const n=`/${t}/rollback`;return this.client.post(n,void 0,(0,Ut.createRequestConfig)(r)).then(Ee.dataExtractor)}}Se.BasisTheoryTransactions=Pa,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Se;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]}})})}(ir);var Mt={},Le={},L={};Object.defineProperty(L,"__esModule",{value:!0}),L.CrudBuilder=void 0;var O=P;const Ba=e=>class extends e{create(r,n){return this.client.post("/",r,(0,O.createRequestConfig)(n)).then(O.dataExtractor)}},xa=e=>class extends e{retrieve(r,n){return this.client.get(r,(0,O.createRequestConfig)(n)).then(O.dataExtractor)}},ja=e=>class extends e{update(r,n,s){return this.client.put(r,n,(0,O.createRequestConfig)(s)).then(O.dataExtractor)}},Na=e=>class extends e{patch(r,n,s){const i=(0,O.createRequestConfig)(s);return this.client.patch(r,n,{...i,headers:{...(i==null?void 0:i.headers)||{},[O.CONTENT_TYPE_HEADER]:O.MERGE_CONTENT_TYPE}}).then(O.dataExtractor)}},Da=e=>class extends e{async delete(r,n){await this.client.delete(r,(0,O.createRequestConfig)(n))}},Ha=e=>class extends e{list(r={},n={}){const s=`/${(0,O.getQueryParams)(r)}`;return this.client.get(s,(0,O.createRequestConfig)(n)).then(O.dataExtractor)}};class Ua{constructor(t){this.BaseService=t}create(){return this.BaseService=Ba(this.BaseService),this}retrieve(){return this.BaseService=xa(this.BaseService),this}update(){return this.BaseService=ja(this.BaseService),this}patch(){return this.BaseService=Na(this.BaseService),this}delete(){return this.BaseService=Da(this.BaseService),this}list(){return this.BaseService=Ha(this.BaseService),this}build(){return this.BaseService}}L.CrudBuilder=Ua,Object.defineProperty(Le,"__esModule",{value:!0}),Le.BasisTheoryApplications=void 0;var Ie=P,Ma=B,La=L;const Ia=new La.CrudBuilder(class extends Ma.BasisTheoryService{getApplicationByKey(){return this.retrieveByKey()}retrieveByKey(t){return this.client.get("/key",(0,Ie.createRequestConfig)(t)).then(Ie.dataExtractor)}regenerateKey(t,r){return this.client.post(`${t}/regenerate`,void 0,(0,Ie.createRequestConfig)(r)).then(Ie.dataExtractor)}}).create().retrieve().update().delete().list().build();Le.BasisTheoryApplications=Ia,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryApplications",{enumerable:!0,get:function(){return t.BasisTheoryApplications}});var t=Le}(Mt);var rn={},nn={},$e={},sn={},Ke={};Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.BasisTheoryTokenize=void 0;var qe=P,$a=B;class Ka extends $a.BasisTheoryService{tokenize(t,r={}){return this.client.post("/",t,(0,qe.createRequestConfig)(r,{transformRequest:qe.proxyRaw,transformResponse:qe.proxyRaw})).then(qe.dataExtractor)}}Ke.BasisTheoryTokenize=Ka,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokenize",{enumerable:!0,get:function(){return t.BasisTheoryTokenize}});var t=Ke}(sn),Object.defineProperty($e,"__esModule",{value:!0}),$e.delegateTokenize=void 0;var qa=sn;const Fa=e=>class extends qa.BasisTheoryTokenize{tokenize(r,n){return e!=null&&e.hasElement(r)?e.tokenize(r,n):super.tokenize(r,n)}};$e.delegateTokenize=Fa;var Fe={},Lt={},ze={};Object.defineProperty(ze,"__esModule",{value:!0}),ze.BasisTheoryTokens=void 0;var I=P,Y=m,za=B,Wa=L;const ka=new Wa.CrudBuilder(class extends za.BasisTheoryService{constructor(t){const r=t;r.transformRequest=[].concat(Y.transformTokenRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(Y.transformTokenResponseCamelCase,t.transformResponse||[]),super(r)}retrieve(t,r={}){const n=`/${t}`;return this.client.get(n,(0,I.createRequestConfig)(r)).then(Y.dataExtractor)}update(t,r,n={}){const s=`/${t}`,i=(0,I.createRequestConfig)(n);return this.client.patch(s,r,{...i,headers:{...(i==null?void 0:i.headers)||{},[I.CONTENT_TYPE_HEADER]:I.MERGE_CONTENT_TYPE}}).then(Y.dataExtractor)}async createAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.post(s,{},(0,I.createRequestConfig)(n))}async deleteAssociation(t,r,n){const s=`/${t}/children/${r}`;await this.client.delete(s,(0,I.createRequestConfig)(n))}createChild(t,r,n){const s=`/${t}/children`;return this.client.post(s,r,(0,I.createRequestConfig)(n)).then(Y.dataExtractor)}listChildren(t,r={},n={}){const s=`/${t}/children${(0,I.getQueryParams)(r)}`;return this.client.get(s,(0,I.createRequestConfig)(n)).then(Y.dataExtractor)}search(t,r){return this.client.post("/search",t,(0,I.createRequestConfig)(r)).then(Y.dataExtractor)}}).create().delete().list().build();ze.BasisTheoryTokens=ka,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTokens",{enumerable:!0,get:function(){return t.BasisTheoryTokens}});var t=ze}(Lt),Object.defineProperty(Fe,"__esModule",{value:!0}),Fe.delegateTokens=void 0;var Ga=Lt;const Va=e=>class extends Ga.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)}};Fe.delegateTokens=Va;var We={},an={},ke={};Object.defineProperty(ke,"__esModule",{value:!0}),ke.BasisTheoryProxy=void 0;var z=P,Ja=B;class Ya extends Ja.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"?z.dataAndHeadersExtractor:z.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,z.createRequestConfig)(r,{transformRequest:z.proxyRaw,transformResponse:z.proxyRaw})).then(a)}return this.client[t]((n=r==null?void 0:r.path)!==null&&n!==void 0?n:"/",(0,z.createRequestConfig)(r,{transformRequest:z.proxyRaw,transformResponse:z.proxyRaw})).then(z.dataExtractor)}}ke.BasisTheoryProxy=Ya,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=ke;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]}})})}(an),Object.defineProperty(We,"__esModule",{value:!0}),We.delegateProxy=void 0;var Xa=an;const Za=e=>class extends Xa.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)}};We.delegateProxy=Za,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=$e;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=Fe;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=We;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]}})})}(nn);var X={};Object.defineProperty(X,"__esModule",{value:!0}),X.injectScript=X.findScript=void 0;const Qa=e=>document.querySelector(`script[src^="${e}"]`);X.findScript=Qa;const eo=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};X.injectScript=eo;var Ge={},v={};Object.defineProperty(v,"__esModule",{value:!0}),v.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=v.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=v.ELEMENTS_NOM_DOM_ERROR_MESSAGE=v.ELEMENTS_INIT_ERROR_MESSAGE=v.CARD_ICON_POSITIONS=v.CARD_BRANDS=v.AUTOCOMPLETE_VALUES=void 0;const to="BasisTheory Elements was not properly initialized.";v.ELEMENTS_INIT_ERROR_MESSAGE=to;const ro="Tried to load BasisTheoryElements in a non-DOM environment.";v.ELEMENTS_NOM_DOM_ERROR_MESSAGE=ro;const no="Basis Theory Elements did not load properly.";v.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE=no;const so="There was an unknown error when loading Basis Theory Elements. Check the console for details.";v.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE=so;const io=["visa","mastercard","american-express","discover","diners-club","jcb","unionpay","maestro","elo","hiper","hipercard","mir","unknown"];v.CARD_BRANDS=io;const ao=["left","right","none"];v.CARD_ICON_POSITIONS=ao;const oo=["off","on"];v.AUTOCOMPLETE_VALUES=oo,Object.defineProperty(Ge,"__esModule",{value:!0}),Ge.loadElements=void 0;var It=v,on=X;let $t;const co=e=>($t||($t=new Promise((t,r)=>{if(typeof window!="object"){r(new Error(It.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,on.findScript)(n);s||(s=(0,on.injectScript)(n)),s.addEventListener("load",()=>{window.BasisTheoryElements?t(window.BasisTheoryElements):r(new Error(It.ELEMENTS_SCRIPT_LOAD_ERROR_MESSAGE))}),s.addEventListener("error",i=>{r((i==null?void 0:i.error)||new Error(It.ELEMENTS_SCRIPT_UNKNOWN_ERROR_MESSAGE))})}catch(n){r(n);return}})),$t);Ge.loadElements=co,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=nn;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=X;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=Ge;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]}})})}(rn);var cn={},Ve={};Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.BasisTheoryLogs=void 0;var uo=B,lo=L;const fo=new lo.CrudBuilder(class extends uo.BasisTheoryService{}).list().build();Ve.BasisTheoryLogs=fo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryLogs",{enumerable:!0,get:function(){return t.BasisTheoryLogs}});var t=Ve}(cn);var un={},Je={};Object.defineProperty(Je,"__esModule",{value:!0}),Je.BasisTheoryPermissions=void 0;var ln=P,ho=B;class po extends ho.BasisTheoryService{list(t){return this.client.get("/",(0,ln.createRequestConfig)(t)).then(ln.dataExtractor)}}Je.BasisTheoryPermissions=po,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryPermissions",{enumerable:!0,get:function(){return t.BasisTheoryPermissions}});var t=Je}(un);var dn={},Ye={};Object.defineProperty(Ye,"__esModule",{value:!0}),Ye.BasisTheoryProxies=void 0;var fn=m,mo=B,Eo=L;const yo=new Eo.CrudBuilder(class extends mo.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(fn.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(fn.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}}).create().retrieve().update().patch().delete().list().build();Ye.BasisTheoryProxies=yo,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t=Ye;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]}})})}(dn);var hn={},Xe={};Object.defineProperty(Xe,"__esModule",{value:!0}),Xe.BasisTheoryReactorFormulas=void 0;var bo=B,_o=L;const wo=new _o.CrudBuilder(class extends bo.BasisTheoryService{}).create().retrieve().update().delete().list().build();Xe.BasisTheoryReactorFormulas=wo,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactorFormulas",{enumerable:!0,get:function(){return t.BasisTheoryReactorFormulas}});var t=Xe}(hn);var pn={},Ze={};Object.defineProperty(Ze,"__esModule",{value:!0}),Ze.BasisTheoryReactors=void 0;var Qe=P,mn=m,go=B,So=L;const To=new So.CrudBuilder(class extends go.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(mn.transformReactorRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(mn.transformReactorResponseCamelCase,t.transformResponse||[]),super(r)}react(t,r,n){return this.client.post(`/${t}/react`,r,(0,Qe.createRequestConfig)(n,{transformRequest:Qe.proxyRaw,transformResponse:Qe.proxyRaw})).then(Qe.dataExtractor)}}).create().retrieve().update().patch().delete().list().build();Ze.BasisTheoryReactors=To,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryReactors",{enumerable:!0,get:function(){return t.BasisTheoryReactors}});var t=Ze}(pn);var En={},et={};Object.defineProperty(et,"__esModule",{value:!0}),et.BasisTheorySessions=void 0;var yn=P,tt=m,Ao=B;class Ro extends Ao.BasisTheoryService{constructor(t){const r={...t};r.transformRequest=[].concat(tt.transformProxyRequestSnakeCase,t.transformRequest||[]),r.transformResponse=[].concat(tt.transformProxyResponseCamelCase,t.transformResponse||[]),super(r)}create(t={}){return this.client.post("/",void 0,(0,yn.createRequestConfig)(t)).then(tt.dataExtractor)}authorize(t,r={}){return this.client.post("/authorize",t,(0,yn.createRequestConfig)(r)).then(tt.dataExtractor)}}et.BasisTheorySessions=Ro,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheorySessions",{enumerable:!0,get:function(){return t.BasisTheorySessions}});var t=et}(En);var bn={},rt={};Object.defineProperty(rt,"__esModule",{value:!0}),rt.BasisTheoryTenants=void 0;var S=P,vo=B,Oo=L;const Co=new Oo.CrudBuilder(class extends vo.BasisTheoryService{retrieve(t){return this.client.get("/",(0,S.createRequestConfig)(t)).then(S.dataExtractor)}update(t,r){return this.client.put("/",t,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}async delete(t){await this.client.delete("/",(0,S.createRequestConfig)(t))}retrieveUsageReport(t){return this.client.get("/reports/usage",(0,S.createRequestConfig)(t)).then(S.dataExtractor)}createInvitation(t,r){return this.client.post("/invitations",t,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}resendInvitation(t,r){return this.client.post(`/invitations/${t}/resend`,{},(0,S.createRequestConfig)(r)).then(S.dataExtractor)}listInvitations(t,r){const n=`/invitations${(0,S.getQueryParams)(t)}`;return this.client.get(n,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}retrieveInvitation(t,r){return this.client.get(`/invitations/${t}`,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}async deleteInvitation(t,r){await this.client.delete(`/invitations/${t}`,(0,S.createRequestConfig)(r))}listMembers(t,r){const n=`/members${(0,S.getQueryParams)(t)}`;return this.client.get(n,(0,S.createRequestConfig)(r)).then(S.dataExtractor)}async deleteMember(t,r){await this.client.delete(`/members/${t}`,(0,S.createRequestConfig)(r))}}).build();rt.BasisTheoryTenants=Co,function(e){Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"BasisTheoryTenants",{enumerable:!0,get:function(){return t.BasisTheoryTenants}});var t=rt}(bn),Object.defineProperty(ge,"__esModule",{value:!0}),ge.BasisTheory=void 0;var ye=te,Po=ir,Bo=Mt,_=P,nt=rn,xo=v,jo=cn,No=un,Do=dn,Ho=hn,Uo=pn,Mo=En,Lo=bn;function Io(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const $o={apiBaseUrl:_.DEFAULT_BASE_URL,elements:!1,appInfo:{}};class Ko{constructor(){Io(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({...$o,...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,nt.delegateTokens)(this._elements))({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.tokens,n).toString(),appInfo:s}),this._tokenize=new((0,nt.delegateTokenize)(this._elements))({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.tokenize,n).toString(),appInfo:s}),this._applications=new Bo.BasisTheoryApplications({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.applications,n).toString(),appInfo:s}),this._tenants=new Lo.BasisTheoryTenants({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.tenants,n).toString(),appInfo:s}),this._logs=new jo.BasisTheoryLogs({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.logs,n).toString(),appInfo:s}),this._reactorFormulas=new Ho.BasisTheoryReactorFormulas({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.reactorFormulas,n).toString(),appInfo:s}),this._reactors=new Uo.BasisTheoryReactors({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.reactors,n).toString(),appInfo:s}),this._permissions=new No.BasisTheoryPermissions({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.permissions,n).toString(),appInfo:s}),this._proxies=new Do.BasisTheoryProxies({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.proxies,n).toString(),appInfo:s}),this._proxy=new((0,nt.delegateProxy)(this._elements))({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.proxy,n).toString(),appInfo:s}),this._sessions=new Mo.BasisTheorySessions({apiKey:t,baseURL:new URL(_.CLIENT_BASE_PATHS.sessions,n).toString(),appInfo:s}),this._transactions=new Po.BasisTheoryTransactions({apiKey:t,baseURL:new URL(_.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(xo.ELEMENTS_INIT_ERROR_MESSAGE);return this._elements.createElement(t,r)}tokenize(t,r){return(0,_.assertInit)(this._tokenize).tokenize(t,r)}post(t,r,n){return(0,ye.makeRequestWithElementsPayloadCheck)(this._elements,"post",t,r,n)}put(t,r,n){return(0,ye.makeRequestWithElementsPayloadCheck)(this._elements,"put",t,r,n)}patch(t,r,n){return(0,ye.makeRequestWithElementsPayloadCheck)(this._elements,"patch",t,r,n)}get(t,r){return(0,ye.makeRequestWithoutElementsPayloadCheck)(this._elements,"get",t,r)}delete(t,r){return(0,ye.makeRequestWithoutElementsPayloadCheck)(this._elements,"delete",t,r)}async loadElements(t){let r;try{r=new URL(this.initOptions.elementsBaseUrl||_.DEFAULT_ELEMENTS_BASE_URL)}catch{throw new Error("Invalid format for the given Elements base url.")}const n=await(0,nt.loadElements)(this.initOptions.elementsClientUrl);await n.init(t,r.toString().replace(/\/$/u,"")),this.elements=n}get initOptions(){return(0,_.assertInit)(this._initOptions)}get tokens(){return(0,_.assertInit)(this._tokens)}get applications(){return(0,_.assertInit)(this._applications)}get tenants(){return(0,_.assertInit)(this._tenants)}get logs(){return(0,_.assertInit)(this._logs)}get reactorFormulas(){return(0,_.assertInit)(this._reactorFormulas)}get reactors(){return(0,_.assertInit)(this._reactors)}get permissions(){return(0,_.assertInit)(this._permissions)}get proxies(){return(0,_.assertInit)(this._proxies)}get proxy(){return(0,_.assertInit)(this._proxy)}get sessions(){return(0,_.assertInit)(this._sessions)}get transactions(){return(0,_.assertInit)(this._transactions)}get elements(){return(0,_.assertInit)(this._elements)}set elements(t){this._elements=t}}ge.BasisTheory=Ko,function(e){Object.defineProperty(e,"__esModule",{value:!0});var t={_instance:!0};e._instance=void 0;var r=ge;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=Mt;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=Lt;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}(nr);const g=crypto,$=e=>e instanceof CryptoKey,qo=async(e,t)=>{const r=`SHA-${e.slice(-3)}`;return new Uint8Array(await g.subtle.digest(r,t))},Z=new TextEncoder,_n=new TextDecoder,st=2**32;function be(...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 Fo(e,t){return be(Z.encode(e),new Uint8Array([0]),t)}function Kt(e,t,r){if(t<0||t>=st)throw new RangeError(`value must be >= 0 and <= ${st-1}. Received ${t}`);e.set([t>>>24,t>>>16,t>>>8,t&255],r)}function zo(e){const t=Math.floor(e/st),r=e%st,n=new Uint8Array(8);return Kt(n,t,0),Kt(n,r,4),n}function qt(e){const t=new Uint8Array(4);return Kt(t,e),t}function Ft(e){return be(qt(e.length),e)}async function Wo(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(qt(i+1)),a.set(e,4),a.set(r,4+e.length),s.set(await qo("sha256",a),i*32)}return s.slice(0,t>>3)}const ko=e=>{let t=e;typeof t=="string"&&(t=Z.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(""))},j=e=>ko(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_"),Go=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},wn=e=>{let t=e;t instanceof Uint8Array&&(t=_n.decode(t)),t=t.replace(/-/g,"+").replace(/_/g,"/").replace(/\s/g,"");try{return Go(t)}catch{throw new TypeError("The input to be decoded is not correctly encoded.")}};class gn 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 C extends gn{constructor(){super(...arguments),this.code="ERR_JOSE_NOT_SUPPORTED"}static get code(){return"ERR_JOSE_NOT_SUPPORTED"}}class G extends gn{constructor(){super(...arguments),this.code="ERR_JWE_INVALID"}static get code(){return"ERR_JWE_INVALID"}}const zt=g.getRandomValues.bind(g);function Sn(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 C(`Unsupported JWE Algorithm: ${e}`)}}const Vo=e=>zt(new Uint8Array(Sn(e)>>3)),Jo=(e,t)=>{if(t.length<<3!==Sn(e))throw new G("Invalid Initialization Vector length")},Tn=(e,t)=>{const r=e.byteLength<<3;if(r!==t)throw new G(`Invalid Content Encryption Key length. Expected ${t} bits, got ${r} bits`)};function V(e,t="algorithm.name"){return new TypeError(`CryptoKey does not support this operation, its ${t} must be ${e}`)}function it(e,t){return e.name===t}function Yo(e){return parseInt(e.name.slice(4),10)}function Xo(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 se(e,t,...r){switch(t){case"A128GCM":case"A192GCM":case"A256GCM":{if(!it(e.algorithm,"AES-GCM"))throw V("AES-GCM");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw V(n,"algorithm.length");break}case"A128KW":case"A192KW":case"A256KW":{if(!it(e.algorithm,"AES-KW"))throw V("AES-KW");const n=parseInt(t.slice(1,4),10);if(e.algorithm.length!==n)throw V(n,"algorithm.length");break}case"ECDH":{switch(e.algorithm.name){case"ECDH":case"X25519":case"X448":break;default:throw V("ECDH, X25519, or X448")}break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":if(!it(e.algorithm,"PBKDF2"))throw V("PBKDF2");break;case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{if(!it(e.algorithm,"RSA-OAEP"))throw V("RSA-OAEP");const n=parseInt(t.slice(9),10)||1;if(Yo(e.algorithm.hash)!==n)throw V(`SHA-${n}`,"algorithm.hash");break}default:throw new TypeError("CryptoKey does not support this operation")}Xo(e,r)}function An(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 K=(e,...t)=>An("Key must be ",e,...t);function Rn(e,t,...r){return An(`Key for the ${e} algorithm must be `,t,...r)}const vn=e=>$(e)?!0:(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",N=["CryptoKey"],Zo=(...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 Qo(e){return typeof e=="object"&&e!==null}function ec(e){if(!Qo(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 On=[{hash:"SHA-256",name:"HMAC"},!0,["sign"]];function tc(e,t){if(e.algorithm.length!==parseInt(t.slice(1,4),10))throw new TypeError(`Invalid key size for alg: ${t}`)}function rc(e,t,r){if($(e))return se(e,t,r),e;if(e instanceof Uint8Array)return g.subtle.importKey("raw",e,"AES-KW",!0,[r]);throw new TypeError(K(e,...N,"Uint8Array"))}const Wt=async(e,t,r)=>{const n=await rc(t,e,"wrapKey");tc(n,e);const s=await g.subtle.importKey("raw",r,...On);return new Uint8Array(await g.subtle.wrapKey("raw",s,n,"AES-KW"))};async function nc(e,t,r,n,s=new Uint8Array(0),i=new Uint8Array(0)){if(!$(e))throw new TypeError(K(e,...N));if(se(e,"ECDH"),!$(t))throw new TypeError(K(t,...N));se(t,"ECDH","deriveBits");const a=be(Ft(Z.encode(r)),Ft(s),Ft(i),qt(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 l=new Uint8Array(await g.subtle.deriveBits({name:e.algorithm.name,public:e},t,o));return Wo(l,n,a)}async function sc(e){if(!$(e))throw new TypeError(K(e,...N));return g.subtle.generateKey(e.algorithm,!0,["deriveBits"])}function ic(e){if(!$(e))throw new TypeError(K(e,...N));return["P-256","P-384","P-521"].includes(e.algorithm.namedCurve)||e.algorithm.name==="X25519"||e.algorithm.name==="X448"}function ac(e){if(!(e instanceof Uint8Array)||e.length<8)throw new G("PBES2 Salt Input must be 8 or more octets")}function oc(e,t){if(e instanceof Uint8Array)return g.subtle.importKey("raw",e,"PBKDF2",!1,["deriveBits"]);if($(e))return se(e,t,"deriveBits","deriveKey"),e;throw new TypeError(K(e,...N,"Uint8Array"))}async function cc(e,t,r,n){ac(e);const s=Fo(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"},l=await oc(n,t);if(l.usages.includes("deriveBits"))return new Uint8Array(await g.subtle.deriveBits(a,l,i));if(l.usages.includes("deriveKey"))return g.subtle.deriveKey(a,l,o,!1,["wrapKey","unwrapKey"]);throw new TypeError('PBKDF2 key "usages" must include "deriveBits" or "deriveKey"')}const uc=async(e,t,r,n=2048,s=zt(new Uint8Array(16)))=>{const i=await cc(s,e,n,t);return{encryptedKey:await Wt(e.slice(-6),i,r),p2c:n,p2s:j(s)}};function Cn(e){switch(e){case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":return"RSA-OAEP";default:throw new C(`alg ${e} is not supported either by JOSE or your javascript runtime`)}}const lc=(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`)}},dc=async(e,t,r)=>{if(!$(t))throw new TypeError(K(t,...N));if(se(t,e,"encrypt","wrapKey"),lc(e,t),t.usages.includes("encrypt"))return new Uint8Array(await g.subtle.encrypt(Cn(e),t,r));if(t.usages.includes("wrapKey")){const n=await g.subtle.importKey("raw",r,...On);return new Uint8Array(await g.subtle.wrapKey("raw",n,t,Cn(e)))}throw new TypeError('RSA-OAEP key "usages" must include "encrypt" or "wrapKey" for this operation')};function fc(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 C('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 C('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 C('Invalid or unsupported JWK "alg" (Algorithm) Parameter value')}break}default:throw new C('Invalid or unsupported JWK "kty" (Key Type) Parameter value')}return{algorithm:t,keyUsages:r}}const Pn=async e=>{if(!e.alg)throw new TypeError('"alg" argument is required when "jwk.alg" is not present');const{algorithm:t,keyUsages:r}=fc(e),n=[t,e.ext??!1,e.key_ops??r],s={...e};return delete s.alg,delete s.use,g.subtle.importKey("jwk",s,...n)},Bn=e=>wn(e);let kt,Gt;const xn=e=>(e==null?void 0:e[Symbol.toStringTag])==="KeyObject",jn=async(e,t,r,n)=>{let s=e.get(t);if(s!=null&&s[n])return s[n];const i=await Pn({...r,alg:n});return s?s[n]=i:e.set(t,{[n]:i}),i},Vt={normalizePublicKey:(e,t)=>{if(xn(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?Bn(r.k):(Gt||(Gt=new WeakMap),jn(Gt,e,r,t))}return e},normalizePrivateKey:(e,t)=>{if(xn(e)){let r=e.export({format:"jwk"});return r.k?Bn(r.k):(kt||(kt=new WeakMap),jn(kt,e,r,t))}return e}};function Nn(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 C(`Unsupported JWE Algorithm: ${e}`)}}const _e=e=>zt(new Uint8Array(Nn(e)>>3));async function hc(e,t){if(!ec(e))throw new TypeError("JWK must be an object");switch(t||(t=e.alg),e.kty){case"oct":if(typeof e.k!="string"||!e.k)throw new TypeError('missing "k" (Key Value) Parameter value');return wn(e.k);case"RSA":if(e.oth!==void 0)throw new C('RSA JWK "oth" (Other Primes Info) Parameter value is not supported');case"EC":case"OKP":return Pn({...e,alg:t});default:throw new C('Unsupported "kty" (Key Type) Parameter value')}}const ie=e=>e==null?void 0:e[Symbol.toStringTag],pc=(e,t)=>{if(!(t instanceof Uint8Array)){if(!vn(t))throw new TypeError(Rn(e,t,...N,"Uint8Array"));if(t.type!=="secret")throw new TypeError(`${ie(t)} instances for symmetric algorithms must be of type "secret"`)}},mc=(e,t,r)=>{if(!vn(t))throw new TypeError(Rn(e,t,...N));if(t.type==="secret")throw new TypeError(`${ie(t)} instances for asymmetric algorithms must not be of type "secret"`);if(r==="sign"&&t.type==="public")throw new TypeError(`${ie(t)} instances for asymmetric algorithm signing must be of type "private"`);if(r==="decrypt"&&t.type==="public")throw new TypeError(`${ie(t)} instances for asymmetric algorithm decryption must be of type "private"`);if(t.algorithm&&r==="verify"&&t.type==="private")throw new TypeError(`${ie(t)} instances for asymmetric algorithm verifying must be of type "public"`);if(t.algorithm&&r==="encrypt"&&t.type==="private")throw new TypeError(`${ie(t)} instances for asymmetric algorithm encryption must be of type "public"`)},Ec=(e,t,r)=>{e.startsWith("HS")||e==="dir"||e.startsWith("PBES2")||/^A\d{3}(?:GCM)?KW$/.test(e)?pc(e,t):mc(e,t,r)};async function yc(e,t,r,n,s){if(!(r instanceof Uint8Array))throw new TypeError(K(r,"Uint8Array"));const i=parseInt(e.slice(1,4),10),a=await g.subtle.importKey("raw",r.subarray(i>>3),"AES-CBC",!1,["encrypt"]),o=await g.subtle.importKey("raw",r.subarray(0,i>>3),{hash:`SHA-${i<<1}`,name:"HMAC"},!1,["sign"]),l=new Uint8Array(await g.subtle.encrypt({iv:n,name:"AES-CBC"},a,t)),d=be(s,n,l,zo(s.length<<3)),c=new Uint8Array((await g.subtle.sign("HMAC",o,d)).slice(0,i>>3));return{ciphertext:l,tag:c,iv:n}}async function bc(e,t,r,n,s){let i;r instanceof Uint8Array?i=await g.subtle.importKey("raw",r,"AES-GCM",!1,["encrypt"]):(se(r,e,"encrypt"),i=r);const a=new Uint8Array(await g.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 Dn=async(e,t,r,n,s)=>{if(!$(r)&&!(r instanceof Uint8Array))throw new TypeError(K(r,...N,"Uint8Array"));switch(n?Jo(e,n):n=Vo(e),e){case"A128CBC-HS256":case"A192CBC-HS384":case"A256CBC-HS512":return r instanceof Uint8Array&&Tn(r,parseInt(e.slice(-3),10)),yc(e,t,r,n,s);case"A128GCM":case"A192GCM":case"A256GCM":return r instanceof Uint8Array&&Tn(r,parseInt(e.slice(1,4),10)),bc(e,t,r,n,s);default:throw new C("Unsupported JWE Content Encryption Algorithm")}};async function _c(e,t,r,n){const s=e.slice(0,7),i=await Dn(s,r,t,n,new Uint8Array(0));return{encryptedKey:i.ciphertext,iv:j(i.iv),tag:j(i.tag)}}function wc(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 C(`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 gc=async e=>{if(e instanceof Uint8Array)return{kty:"oct",k:j(e)};if(!$(e))throw new TypeError(K(e,...N,"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 g.subtle.exportKey("jwk",e);return i};async function Sc(e){return gc(e)}async function Tc(e,t,r,n,s={}){var l;let i,a,o;switch(Ec(e,r,"encrypt"),r=await((l=Vt.normalizePublicKey)==null?void 0:l.call(Vt,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(!ic(r))throw new C("ECDH with the provided key is not allowed or not supported by your javascript runtime");const{apu:d,apv:c}=s;let{epk:h}=s;h||(h=(await sc(r)).privateKey);const{x:E,y:w,crv:f,kty:p}=await Sc(h),R=await nc(r,h,e==="ECDH-ES"?t:e,e==="ECDH-ES"?Nn(t):parseInt(e.slice(-5,-2),10),d,c);if(a={epk:{x:E,crv:f,kty:p}},p==="EC"&&(a.epk.y=w),d&&(a.apu=j(d)),c&&(a.apv=j(c)),e==="ECDH-ES"){o=R;break}o=n||_e(t);const D=e.slice(-6);i=await Wt(D,R,o);break}case"RSA1_5":case"RSA-OAEP":case"RSA-OAEP-256":case"RSA-OAEP-384":case"RSA-OAEP-512":{o=n||_e(t),i=await dc(e,r,o);break}case"PBES2-HS256+A128KW":case"PBES2-HS384+A192KW":case"PBES2-HS512+A256KW":{o=n||_e(t);const{p2c:d,p2s:c}=s;({encryptedKey:i,...a}=await uc(e,r,o,d,c));break}case"A128KW":case"A192KW":case"A256KW":{o=n||_e(t),i=await Wt(e,r,o);break}case"A128GCMKW":case"A192GCMKW":case"A256GCMKW":{o=n||_e(t);const{iv:d}=s;({encryptedKey:i,...a}=await _c(e,r,o,d));break}default:throw new C('Invalid or unsupported "alg" (JWE Algorithm) header value')}return{cek:o,encryptedKey:i,parameters:a}}const Ac=Symbol();class Rc{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 G("either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()");if(!Zo(this._protectedHeader,this._unprotectedHeader,this._sharedUnprotectedHeader))throw new G("JWE Protected, JWE Shared Unprotected and JWE Per-Recipient Header Parameter names must be disjoint");const n={...this._protectedHeader,...this._unprotectedHeader,...this._sharedUnprotectedHeader};if(wc(G,new Map,r==null?void 0:r.crit,this._protectedHeader,n),n.zip!==void 0)throw new C('JWE "zip" (Compression Algorithm) Header Parameter is not supported.');const{alg:s,enc:i}=n;if(typeof s!="string"||!s)throw new G('JWE "alg" (Algorithm) Header Parameter missing or invalid');if(typeof i!="string"||!i)throw new G('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 p;({cek:o,encryptedKey:a,parameters:p}=await Tc(s,i,t,this._cek,this._keyManagementParameters)),p&&(r&&Ac in r?this._unprotectedHeader?this._unprotectedHeader={...this._unprotectedHeader,...p}:this.setUnprotectedHeader(p):this._protectedHeader?this._protectedHeader={...this._protectedHeader,...p}:this.setProtectedHeader(p))}let l,d,c;this._protectedHeader?d=Z.encode(j(JSON.stringify(this._protectedHeader))):d=Z.encode(""),this._aad?(c=j(this._aad),l=be(d,Z.encode("."),Z.encode(c))):l=d;const{ciphertext:h,tag:E,iv:w}=await Dn(i,this._plaintext,o,this._iv,l),f={ciphertext:j(h)};return w&&(f.iv=j(w)),E&&(f.tag=j(E)),a&&(f.encrypted_key=j(a)),c&&(f.aad=c),this._protectedHeader&&(f.protected=_n.decode(d)),this._sharedUnprotectedHeader&&(f.unprotected=this._sharedUnprotectedHeader),this._unprotectedHeader&&(f.header=this._unprotectedHeader),f}}class vc{constructor(t){this._flattened=new Rc(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 Jt={base:{":disabled":{backgroundColor:"transparent"}}},Oc={mask:{number:"{{ data.number | card_mask: 'true', 'true' }}",expiration_month:"{{ data.expiration_month }}",expiration_year:"{{ data.expiration_year }}"}},Cc="DOM Element was not found";var Pc={VITE_PACKAGE_VERSION:"v3.1.1",BASE_URL:"/",MODE:"production",DEV:!1,PROD:!0,SSR:!1};const Bc="v3.1.1";class we{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.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=Pc.VITE_IFRAME_BASE_URL??xc(Bc),!this.IFRAME_BASE_URL)throw new Error("IFRAME_BASE_URL not found");r&&Yt.set(this,{key:r})}mount(t){const r=typeof t=="string"?document.querySelector(t):t;if(!r)throw new Error(Cc);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 l=Yt.get(this);l&&(l.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=Yt.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 xc(e){return`https://${window.HG_IFRAME_HOST??"sdk.hellgate.io"}/web/${e}/iframe/`}const Yt=new Map,jc=e=>e!=null;function Xt(e){const[t=null,r=null]=(e??"").split("/").map(n=>Number(n.trim()));return{month:t,year:r&&r>10?+`20${r}`:null}}function Zt(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(jc).join(" / ")}class Hn extends we{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:Xt}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:Zt})}}function Qt(e){return(e==null?void 0:e.replaceAll(" ",""))??null}function Un(e){return e}class Mn extends we{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:Qt}),Object.defineProperty(this,"putValue",{enumerable:!0,configurable:!0,writable:!0,value:Un})}}class Ln extends we{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?Qt(t.cardNumber):null,expiry_date:t.cardExpirationDate?Xt(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?Zt(t.expiry_date):null,cardVerificationCode:t.cvc??null}:null})}}class In extends we{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 er extends we{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 ae(e,t,r){switch(e){case"card":return new Ln(t,r);case"cardNumber":return new Mn(t,r);case"cardExpirationDate":return new Hn(t,r);case"cardVerificationCode":return new In(t,r);case"text":return new er(t,r);default:ASSERT_EXHAUSTIVE(e)}}function $n(){return Date.now().toString(36)+Math.random().toString(36).slice(2)}class at{static async init(t,r){const n=r.provider==="basis_theory"?await new nr.BasisTheory().init(r.api_key,{elements:!1}):void 0;return new at(t,r,n)}constructor(t,r,n,s){Object.defineProperty(this,"session",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"tokenizeConfig",{enumerable:!0,configurable:!0,writable:!0,value:r}),Object.defineProperty(this,"bt",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"cardAdditionalData",{enumerable:!0,configurable:!0,writable:!0,value:s}),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,"stateChangeHandlers",{enumerable:!0,configurable:!0,writable:!0,value:[]}),Object.defineProperty(this,"createForm",{enumerable:!0,configurable:!0,writable:!0,value:(i={})=>{if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const a=oe.get(this);if(!a)throw new Error("Secure key not found");const o=ee({disabled:!1,autocomplete:"on",style:{...Jt}},i),l=ae("card",o,a);return this.cardElements.card={element:l,state:this.createFieldDefaultState()},this.addElementStateListener("card"),l}}),Object.defineProperty(this,"createFormFields",{enumerable:!0,configurable:!0,writable:!0,value:(i={})=>{if(this.hasFormElements())throw new Error("Form elements can't be initialized twice. You can call `reset()` method or create new Hellgate client.");const a=oe.get(this);if(!a)throw new Error("Secure key not found");const o={disabled:!1,autocomplete:"on",style:{...Jt}},{cardNumber:l={},expiryDate:d={},securityCode:c={},...h}=i,E=ae("cardNumber",{...ee(o,{...h,...l})},a),w=ae("cardExpirationDate",{...ee(o,{...h,...d})},a),f=ae("cardVerificationCode",{...ee(o,{...h,...c})},a);return this.cardElements={cardNumber:{element:E,state:this.createFieldDefaultState()},cardExpirationDate:{element:w,state:this.createFieldDefaultState()},cardVerificationCode:{element:f,state:this.createFieldDefaultState()}},this.addElementStateListener("cardNumber"),this.addElementStateListener("cardExpirationDate"),this.addElementStateListener("cardVerificationCode"),{cardNumber:E,expiryDate:w,securityCode:f}}}),Object.defineProperty(this,"createTextField",{enumerable:!0,configurable:!0,writable:!0,value:(i={})=>{const a=oe.get(this);if(!a)throw new Error("Secure key not found");const o={disabled:!1,autocomplete:"on",style:{...Jt}};return ae("text",{...ee(o,{...i})},a)}}),Object.defineProperty(this,"tokenize",{enumerable:!0,configurable:!0,writable:!0,value:async()=>{var c,h,E,w,f;const{card:i,cardNumber:a,cardExpirationDate:o,cardVerificationCode:l}=this.cardElements;let d;if(i){const p=ce(this,i.element);d={number:(p==null?void 0:p.number)??null,expiration_month:((c=p==null?void 0:p.expiry_date)==null?void 0:c.month)??null,expiration_year:((h=p==null?void 0:p.expiry_date)==null?void 0:h.year)??null,cvc:(p==null?void 0:p.cvc)??null}}if(a&&o&&l&&(d={number:((E=ce(this,a.element))==null?void 0:E.replaceAll(" ",""))??null,expiration_month:((w=ce(this,o.element))==null?void 0:w.month)??null,expiration_year:((f=ce(this,o.element))==null?void 0:f.year)??null,cvc:ce(this,l.element)}),!d)throw new Error("Form elements must be initialized before tokenization");if(!d.number||!d.expiration_month||!d.expiration_year||!d.cvc)throw new Error("Card data is not complete");switch(this.tokenizeConfig.provider){case"basis_theory":{if(!this.bt)throw new Error("basis_theory SDK not found");return this.bt.tokenize({type:"card",data:d,...Oc}).then(p=>Array.isArray(p)?null:{token_id:p.id})}case"guardian":return this.encryptCardData({account_number:d.number,expiry_month:d.expiration_month,expiry_year:d.expiration_year,security_code:d.cvc},this.tokenizeConfig.jwk);default:ASSERT_EXHAUSTIVE(this.tokenizeConfig)}}}),Object.defineProperty(this,"onStateChange",{enumerable:!0,configurable:!0,writable:!0,value:i=>{this.stateChangeHandlers.push(i),i(this.state)}}),Object.defineProperty(this,"clear",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(i=>i==null?void 0:i.element.clear())}}),Object.defineProperty(this,"reset",{enumerable:!0,configurable:!0,writable:!0,value:()=>{Object.values(this.cardElements).forEach(i=>i==null?void 0:i.element.unmount()),this.cardElements={}}}),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 i=>{if(!this.hasFormElements())throw new Error("Card form must be initialized and completed before processing");this.cardAdditionalData=i?this.extractAdditionalData(i):{},this.disableFormElements();const a=await this.tokenize();if(!a)throw new Error("Tokenization failed");return this.session.completeAction({action:"tokenize_card",result:{...a,additional_data:this.cardAdditionalData}})}}),oe.set(this,$n())}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 Q({cardholder_name:ue(this,t),billing_address:{line1:ue(this,r.line1),line2:ue(this,r.line2),line3:ue(this,r.line3),city:ue(this,r.city),postal_code:ue(this,r.postal_code)}})}async encryptCardData(t,r){const n=await hc(r,"RSA-OAEP"),s=JSON.stringify(t),i=new TextEncoder().encode(s);return{enc_payload:await new vc(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=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 oe=new Map;function ce(e,t){const r=oe.get(e);return r?t.secureValue(r):null}function ue(e,t){const r=oe.get(e);return t instanceof er&&r?ce(e,t)??void 0:t}class Nc{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=>ct(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=>ct(n))}cancelAll(){this.abortCtrl.abort()}}const Dc=2e3;class Hc{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(l=>{l.next_action!==(s==null?void 0:s.next_action)&&l.next_action===null&&(i(l),o())});this.api.completeAction(this.id,n).then(l=>this.newStateHandle(l,a)).catch(async l=>a(await Uc(l)))})}}),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()}})}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`)))}),Dc);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 Uc(e){if(!e.ok)switch(e.status){case 400:{const t=await e.json();return new Error([t.classifier,t.message].filter(Boolean).join(". "))}}return e}const Mc={base_url:"https://api.hellgate.io"};class tr{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 tr(n,{CARD:s,"3DS":i})}static async initHandlers(t,r){const n={...Mc,...r},s=new Nc(n.base_url,n.abortCtrl),i=new Hc(t,s),a=await i.init(),o=a.next_action==="tokenize_card"?await this.createCardHandler(i,a.data):void 0,l=this.create3DSHandler(i,r);return{session:i,cardHandler:o,handler3DS:l}}static createCardHandler(t,r){return at.init(t,r)}static create3DSHandler(t,r){return new rr(t,{domContainer:r.challenge_3ds_container,labelText:r.challenge_3ds_label_text})}}A.CardElement=Ln,A.CardExpirationDateElement=Hn,A.CardNumberElement=Mn,A.CardVerificationCodeElement=In,A.Hellgate=tr,A.Hellgate3DSHandler=rr,A.HellgateCardHandler=at,A.TextElement=er,A.createElement=ae,A.extractCardNumberValue=Qt,A.extractExpiryDateValue=Xt,A.putCardNumberValue=Un,A.putExpiryDateValue=Zt,A.uid=$n,Object.defineProperty(A,Symbol.toStringTag,{value:"Module"})});globalThis.HellgateSDK&&(globalThis.Hellgate=globalThis.HellgateSDK.Hellgate,delete globalThis.HellgateSDK);