@merit-systems/echo-react-sdk 1.0.6 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/echo-react-sdk.umd.js +1 -1
- package/dist/echo-react-sdk.umd.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -61
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";Object.create;var e,t=Object.defineProperty,r=(Object.getOwnPropertyDescriptor,Object.getOwnPropertyNames,Object.getPrototypeOf,Object.prototype.hasOwnProperty,(e,r,n)=>((e,r,n)=>r in e?t(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n)(e,"symbol"!=typeof r?r+"":r,n));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),s=require("react");class i extends Error{}function o(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw new Error("base64 string is not of the correct length")}try{return function(e){return decodeURIComponent(atob(e).replace(/(.)/g,((e,t)=>{let r=t.charCodeAt(0).toString(16).toUpperCase();return r.length<2&&(r="0"+r),"%"+r})))}(t)}catch(r){return atob(t)}}i.prototype.name="InvalidTokenError";var a,c,l,u={debug:()=>{},info:()=>{},warn:()=>{},error:()=>{}},d=(e=>(e[e.NONE=0]="NONE",e[e.ERROR=1]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=3]="INFO",e[e.DEBUG=4]="DEBUG",e))(d||{});(l=d||(d={})).reset=function(){a=3,c=u},l.setLevel=function(e){if(!(0<=e&&e<=4))throw new Error("Invalid log level");a=e},l.setLogger=function(e){c=e};var h=class e{constructor(e){this._name=e}debug(...t){a>=4&&c.debug(e._format(this._name,this._method),...t)}info(...t){a>=3&&c.info(e._format(this._name,this._method),...t)}warn(...t){a>=2&&c.warn(e._format(this._name,this._method),...t)}error(...t){a>=1&&c.error(e._format(this._name,this._method),...t)}throw(e){throw this.error(e),e}create(e){const t=Object.create(this);return t._method=e,t.debug("begin"),t}static createStatic(t,r){const n=new e(`${t}.${r}`);return n.debug("begin"),n}static _format(e,t){const r=`[${e}]`;return t?`${r} ${t}:`:r}static debug(t,...r){a>=4&&c.debug(e._format(t),...r)}static info(t,...r){a>=3&&c.info(e._format(t),...r)}static warn(t,...r){a>=2&&c.warn(e._format(t),...r)}static error(t,...r){a>=1&&c.error(e._format(t),...r)}};d.reset();var p=class{static decode(e){try{return function(e,t){if("string"!=typeof e)throw new i("Invalid token specified: must be a string");t||(t={});const r=!0===t.header?0:1,n=e.split(".")[r];if("string"!=typeof n)throw new i(`Invalid token specified: missing part #${r+1}`);let s;try{s=o(n)}catch(en){throw new i(`Invalid token specified: invalid base64 for part #${r+1} (${en.message})`)}try{return JSON.parse(s)}catch(en){throw new i(`Invalid token specified: invalid json for part #${r+1} (${en.message})`)}}(e)}catch(t){throw h.error("JwtUtils.decode",t),t}}static async generateSignedJwt(e,t,r){const n=`${m.encodeBase64Url((new TextEncoder).encode(JSON.stringify(e)))}.${m.encodeBase64Url((new TextEncoder).encode(JSON.stringify(t)))}`,s=await window.crypto.subtle.sign({name:"ECDSA",hash:{name:"SHA-256"}},r,(new TextEncoder).encode(n));return`${n}.${m.encodeBase64Url(new Uint8Array(s))}`}},f=e=>btoa([...new Uint8Array(e)].map((e=>String.fromCharCode(e))).join("")),g=class e{static _randomWord(){const e=new Uint32Array(1);return crypto.getRandomValues(e),e[0]}static generateUUIDv4(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(t=>(+t^e._randomWord()&15>>+t/4).toString(16))).replace(/-/g,"")}static generateCodeVerifier(){return e.generateUUIDv4()+e.generateUUIDv4()+e.generateUUIDv4()}static async generateCodeChallenge(e){if(!crypto.subtle)throw new Error("Crypto.subtle is available only in secure contexts (HTTPS).");try{const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-256",t);return f(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}catch(t){throw h.error("CryptoUtils.generateCodeChallenge",t),t}}static generateBasicAuth(e,t){const r=(new TextEncoder).encode([e,t].join(":"));return f(r)}static async hash(e,t){const r=(new TextEncoder).encode(t),n=await crypto.subtle.digest(e,r);return new Uint8Array(n)}static async customCalculateJwkThumbprint(t){let r;switch(t.kty){case"RSA":r={e:t.e,kty:t.kty,n:t.n};break;case"EC":r={crv:t.crv,kty:t.kty,x:t.x,y:t.y};break;case"OKP":r={crv:t.crv,kty:t.kty,x:t.x};break;case"oct":r={crv:t.k,kty:t.kty};break;default:throw new Error("Unknown jwk type")}const n=await e.hash("SHA-256",JSON.stringify(r));return e.encodeBase64Url(n)}static async generateDPoPProof({url:t,accessToken:r,httpMethod:n,keyPair:s,nonce:i}){let o,a;const c={jti:window.crypto.randomUUID(),htm:null!=n?n:"GET",htu:t,iat:Math.floor(Date.now()/1e3)};r&&(o=await e.hash("SHA-256",r),a=e.encodeBase64Url(o),c.ath=a),i&&(c.nonce=i);try{const e=await crypto.subtle.exportKey("jwk",s.publicKey),t={alg:"ES256",typ:"dpop+jwt",jwk:{crv:e.crv,kty:e.kty,x:e.x,y:e.y}};return await p.generateSignedJwt(t,c,s.privateKey)}catch(l){throw l instanceof TypeError?new Error(`Error exporting dpop public key: ${l.message}`):l}}static async generateDPoPJkt(t){try{const r=await crypto.subtle.exportKey("jwk",t.publicKey);return await e.customCalculateJwkThumbprint(r)}catch(r){throw r instanceof TypeError?new Error(`Could not retrieve dpop keys from storage: ${r.message}`):r}}static async generateDPoPKeys(){return await window.crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!1,["sign","verify"])}};g.encodeBase64Url=e=>f(e).replace(/=/g,"").replace(/\+/g,"-").replace(/\//g,"_");var m=g,_=class{constructor(e){this._name=e,this._callbacks=[],this._logger=new h(`Event('${this._name}')`)}addHandler(e){return this._callbacks.push(e),()=>this.removeHandler(e)}removeHandler(e){const t=this._callbacks.lastIndexOf(e);t>=0&&this._callbacks.splice(t,1)}async raise(...e){this._logger.debug("raise:",...e);for(const t of this._callbacks)await t(...e)}},w=class{static center({...e}){var t;return null==e.width&&(e.width=null!=(t=[800,720,600,480].find((e=>e<=window.outerWidth/1.618)))?t:360),null!=e.left||(e.left=Math.max(0,Math.round(window.screenX+(window.outerWidth-e.width)/2))),null!=e.height&&(null!=e.top||(e.top=Math.max(0,Math.round(window.screenY+(window.outerHeight-e.height)/2)))),e}static serialize(e){return Object.entries(e).filter((([,e])=>null!=e)).map((([e,t])=>`${e}=${"boolean"!=typeof t?t:t?"yes":"no"}`)).join(",")}},y=class e extends _{constructor(){super(...arguments),this._logger=new h(`Timer('${this._name}')`),this._timerHandle=null,this._expiration=0,this._callback=()=>{const t=this._expiration-e.getEpochTime();this._logger.debug("timer completes in",t),this._expiration<=e.getEpochTime()&&(this.cancel(),super.raise())}}static getEpochTime(){return Math.floor(Date.now()/1e3)}init(t){const r=this._logger.create("init");t=Math.max(Math.floor(t),1);const n=e.getEpochTime()+t;if(this.expiration===n&&this._timerHandle)return void r.debug("skipping since already initialized for expiration at",this.expiration);this.cancel(),r.debug("using duration",t),this._expiration=n;const s=Math.min(t,5);this._timerHandle=setInterval(this._callback,1e3*s)}get expiration(){return this._expiration}cancel(){this._logger.create("cancel"),this._timerHandle&&(clearInterval(this._timerHandle),this._timerHandle=null)}},b=class{static readParams(e,t="query"){if(!e)throw new TypeError("Invalid URL");const r=new URL(e,"http://127.0.0.1")["fragment"===t?"hash":"search"];return new URLSearchParams(r.slice(1))}},S=";",v=class extends Error{constructor(e,t){var r,n,s;if(super(e.error_description||e.error||""),this.form=t,this.name="ErrorResponse",!e.error)throw h.error("ErrorResponse","No error passed"),new Error("No error passed");this.error=e.error,this.error_description=null!=(r=e.error_description)?r:null,this.error_uri=null!=(n=e.error_uri)?n:null,this.state=e.userState,this.session_state=null!=(s=e.session_state)?s:null,this.url_state=e.url_state}},E=class extends Error{constructor(e){super(e),this.name="ErrorTimeout"}},k=class{constructor(e){this._logger=new h("AccessTokenEvents"),this._expiringTimer=new y("Access token expiring"),this._expiredTimer=new y("Access token expired"),this._expiringNotificationTimeInSeconds=e.expiringNotificationTimeInSeconds}async load(e){const t=this._logger.create("load");if(e.access_token&&void 0!==e.expires_in){const r=e.expires_in;if(t.debug("access token present, remaining duration:",r),r>0){let e=r-this._expiringNotificationTimeInSeconds;e<=0&&(e=1),t.debug("registering expiring timer, raising in",e,"seconds"),this._expiringTimer.init(e)}else t.debug("canceling existing expiring timer because we're past expiration."),this._expiringTimer.cancel();const n=r+1;t.debug("registering expired timer, raising in",n,"seconds"),this._expiredTimer.init(n)}else this._expiringTimer.cancel(),this._expiredTimer.cancel()}async unload(){this._logger.debug("unload: canceling existing access token timers"),this._expiringTimer.cancel(),this._expiredTimer.cancel()}addAccessTokenExpiring(e){return this._expiringTimer.addHandler(e)}removeAccessTokenExpiring(e){this._expiringTimer.removeHandler(e)}addAccessTokenExpired(e){return this._expiredTimer.addHandler(e)}removeAccessTokenExpired(e){this._expiredTimer.removeHandler(e)}},R=class{constructor(e,t,r,n,s){this._callback=e,this._client_id=t,this._intervalInSeconds=n,this._stopOnError=s,this._logger=new h("CheckSessionIFrame"),this._timer=null,this._session_state=null,this._message=e=>{e.origin===this._frame_origin&&e.source===this._frame.contentWindow&&("error"===e.data?(this._logger.error("error message from check session op iframe"),this._stopOnError&&this.stop()):"changed"===e.data?(this._logger.debug("changed message from check session op iframe"),this.stop(),this._callback()):this._logger.debug(e.data+" message from check session op iframe"))};const i=new URL(r);this._frame_origin=i.origin,this._frame=window.document.createElement("iframe"),this._frame.style.visibility="hidden",this._frame.style.position="fixed",this._frame.style.left="-1000px",this._frame.style.top="0",this._frame.width="0",this._frame.height="0",this._frame.src=i.href}load(){return new Promise((e=>{this._frame.onload=()=>{e()},window.document.body.appendChild(this._frame),window.addEventListener("message",this._message,!1)}))}start(e){if(this._session_state===e)return;this._logger.create("start"),this.stop(),this._session_state=e;const t=()=>{this._frame.contentWindow&&this._session_state&&this._frame.contentWindow.postMessage(this._client_id+" "+this._session_state,this._frame_origin)};t(),this._timer=setInterval(t,1e3*this._intervalInSeconds)}stop(){this._logger.create("stop"),this._session_state=null,this._timer&&(clearInterval(this._timer),this._timer=null)}},T=class{constructor(){this._logger=new h("InMemoryWebStorage"),this._data={}}clear(){this._logger.create("clear"),this._data={}}getItem(e){return this._logger.create(`getItem('${e}')`),this._data[e]}setItem(e,t){this._logger.create(`setItem('${e}')`),this._data[e]=t}removeItem(e){this._logger.create(`removeItem('${e}')`),delete this._data[e]}get length(){return Object.getOwnPropertyNames(this._data).length}key(e){return Object.getOwnPropertyNames(this._data)[e]}},x=class extends Error{constructor(e,t){super(t),this.name="ErrorDPoPNonce",this.nonce=e}},O=class{constructor(e=[],t=null,r={}){this._jwtHandler=t,this._extraHeaders=r,this._logger=new h("JsonService"),this._contentTypes=[],this._contentTypes.push(...e,"application/json"),t&&this._contentTypes.push("application/jwt")}async fetchWithTimeout(e,t={}){const{timeoutInSeconds:r,...n}=t;if(!r)return await fetch(e,n);const s=new AbortController,i=setTimeout((()=>s.abort()),1e3*r);try{return await fetch(e,{...t,signal:s.signal})}catch(o){if(o instanceof DOMException&&"AbortError"===o.name)throw new E("Network timed out");throw o}finally{clearTimeout(i)}}async getJson(e,{token:t,credentials:r,timeoutInSeconds:n}={}){const s=this._logger.create("getJson"),i={Accept:this._contentTypes.join(", ")};let o;t&&(s.debug("token passed, setting Authorization header"),i.Authorization="Bearer "+t),this._appendExtraHeaders(i);try{s.debug("url:",e),o=await this.fetchWithTimeout(e,{method:"GET",headers:i,timeoutInSeconds:n,credentials:r})}catch(l){throw s.error("Network Error"),l}s.debug("HTTP response received, status",o.status);const a=o.headers.get("Content-Type");if(a&&!this._contentTypes.find((e=>a.startsWith(e)))&&s.throw(new Error(`Invalid response Content-Type: ${null!=a?a:"undefined"}, from URL: ${e}`)),o.ok&&this._jwtHandler&&(null==a?void 0:a.startsWith("application/jwt")))return await this._jwtHandler(await o.text());let c;try{c=await o.json()}catch(l){if(s.error("Error parsing JSON response",l),o.ok)throw l;throw new Error(`${o.statusText} (${o.status})`)}if(!o.ok){if(s.error("Error from server:",c),c.error)throw new v(c);throw new Error(`${o.statusText} (${o.status}): ${JSON.stringify(c)}`)}return c}async postForm(e,{body:t,basicAuth:r,timeoutInSeconds:n,initCredentials:s,extraHeaders:i}){const o=this._logger.create("postForm"),a={Accept:this._contentTypes.join(", "),"Content-Type":"application/x-www-form-urlencoded",...i};let c;void 0!==r&&(a.Authorization="Basic "+r),this._appendExtraHeaders(a);try{o.debug("url:",e),c=await this.fetchWithTimeout(e,{method:"POST",headers:a,body:t,timeoutInSeconds:n,credentials:s})}catch(h){throw o.error("Network error"),h}o.debug("HTTP response received, status",c.status);const l=c.headers.get("Content-Type");if(l&&!this._contentTypes.find((e=>l.startsWith(e))))throw new Error(`Invalid response Content-Type: ${null!=l?l:"undefined"}, from URL: ${e}`);const u=await c.text();let d={};if(u)try{d=JSON.parse(u)}catch(h){if(o.error("Error parsing JSON response",h),c.ok)throw h;throw new Error(`${c.statusText} (${c.status})`)}if(!c.ok){if(o.error("Error from server:",d),c.headers.has("dpop-nonce")){const e=c.headers.get("dpop-nonce");throw new x(e,`${JSON.stringify(d)}`)}if(d.error)throw new v(d,t);throw new Error(`${c.statusText} (${c.status}): ${JSON.stringify(d)}`)}return d}_appendExtraHeaders(e){const t=this._logger.create("appendExtraHeaders"),r=Object.keys(this._extraHeaders),n=["accept","content-type"],s=["authorization"];0!==r.length&&r.forEach((r=>{if(n.includes(r.toLocaleLowerCase()))return void t.warn("Protected header could not be set",r,n);if(s.includes(r.toLocaleLowerCase())&&Object.keys(e).includes(r))return void t.warn("Header could not be overridden",r,s);const i="function"==typeof this._extraHeaders[r]?this._extraHeaders[r]():this._extraHeaders[r];i&&""!==i&&(e[r]=i)}))}},A=class{constructor(e){this._settings=e,this._logger=new h("MetadataService"),this._signingKeys=null,this._metadata=null,this._metadataUrl=this._settings.metadataUrl,this._jsonService=new O(["application/jwk-set+json"],null,this._settings.extraHeaders),this._settings.signingKeys&&(this._logger.debug("using signingKeys from settings"),this._signingKeys=this._settings.signingKeys),this._settings.metadata&&(this._logger.debug("using metadata from settings"),this._metadata=this._settings.metadata),this._settings.fetchRequestCredentials&&(this._logger.debug("using fetchRequestCredentials from settings"),this._fetchRequestCredentials=this._settings.fetchRequestCredentials)}resetSigningKeys(){this._signingKeys=null}async getMetadata(){const e=this._logger.create("getMetadata");if(this._metadata)return e.debug("using cached values"),this._metadata;if(!this._metadataUrl)throw e.throw(new Error("No authority or metadataUrl configured on settings")),null;e.debug("getting metadata from",this._metadataUrl);const t=await this._jsonService.getJson(this._metadataUrl,{credentials:this._fetchRequestCredentials,timeoutInSeconds:this._settings.requestTimeoutInSeconds});return e.debug("merging remote JSON with seed metadata"),this._metadata=Object.assign({},t,this._settings.metadataSeed),this._metadata}getIssuer(){return this._getMetadataProperty("issuer")}getAuthorizationEndpoint(){return this._getMetadataProperty("authorization_endpoint")}getUserInfoEndpoint(){return this._getMetadataProperty("userinfo_endpoint")}getTokenEndpoint(e=!0){return this._getMetadataProperty("token_endpoint",e)}getCheckSessionIframe(){return this._getMetadataProperty("check_session_iframe",!0)}getEndSessionEndpoint(){return this._getMetadataProperty("end_session_endpoint",!0)}getRevocationEndpoint(e=!0){return this._getMetadataProperty("revocation_endpoint",e)}getKeysEndpoint(e=!0){return this._getMetadataProperty("jwks_uri",e)}async _getMetadataProperty(e,t=!1){const r=this._logger.create(`_getMetadataProperty('${e}')`),n=await this.getMetadata();if(r.debug("resolved"),void 0===n[e]){if(!0===t)return void r.warn("Metadata does not contain optional property");r.throw(new Error("Metadata does not contain property "+e))}return n[e]}async getSigningKeys(){const e=this._logger.create("getSigningKeys");if(this._signingKeys)return e.debug("returning signingKeys from cache"),this._signingKeys;const t=await this.getKeysEndpoint(!1);e.debug("got jwks_uri",t);const r=await this._jsonService.getJson(t,{timeoutInSeconds:this._settings.requestTimeoutInSeconds});if(e.debug("got key set",r),!Array.isArray(r.keys))throw e.throw(new Error("Missing keys on keyset")),null;return this._signingKeys=r.keys,this._signingKeys}},C=class{constructor({prefix:e="oidc.",store:t=localStorage}={}){this._logger=new h("WebStorageStateStore"),this._store=t,this._prefix=e}async set(e,t){this._logger.create(`set('${e}')`),e=this._prefix+e,await this._store.setItem(e,t)}async get(e){this._logger.create(`get('${e}')`),e=this._prefix+e;return await this._store.getItem(e)}async remove(e){this._logger.create(`remove('${e}')`),e=this._prefix+e;const t=await this._store.getItem(e);return await this._store.removeItem(e),t}async getAllKeys(){this._logger.create("getAllKeys");const e=await this._store.length,t=[];for(let r=0;r<e;r++){const e=await this._store.key(r);e&&0===e.indexOf(this._prefix)&&t.push(e.substr(this._prefix.length))}return t}},N=class{constructor({authority:e,metadataUrl:t,metadata:r,signingKeys:n,metadataSeed:s,client_id:i,client_secret:o,response_type:a="code",scope:c="openid",redirect_uri:l,post_logout_redirect_uri:u,client_authentication:d="client_secret_post",prompt:h,display:p,max_age:f,ui_locales:g,acr_values:m,resource:_,response_mode:w,filterProtocolClaims:y=!0,loadUserInfo:b=!1,requestTimeoutInSeconds:S,staleStateAgeInSeconds:v=900,mergeClaimsStrategy:E={array:"replace"},disablePKCE:k=!1,stateStore:R,revokeTokenAdditionalContentTypes:x,fetchRequestCredentials:O,refreshTokenAllowedScope:A,extraQueryParams:N={},extraTokenParams:P={},extraHeaders:I={},dpop:U,omitScopeWhenRequesting:j=!1}){var L;if(this.authority=e,t?this.metadataUrl=t:(this.metadataUrl=e,e&&(this.metadataUrl.endsWith("/")||(this.metadataUrl+="/"),this.metadataUrl+=".well-known/openid-configuration")),this.metadata=r,this.metadataSeed=s,this.signingKeys=n,this.client_id=i,this.client_secret=o,this.response_type=a,this.scope=c,this.redirect_uri=l,this.post_logout_redirect_uri=u,this.client_authentication=d,this.prompt=h,this.display=p,this.max_age=f,this.ui_locales=g,this.acr_values=m,this.resource=_,this.response_mode=w,this.filterProtocolClaims=null==y||y,this.loadUserInfo=!!b,this.staleStateAgeInSeconds=v,this.mergeClaimsStrategy=E,this.omitScopeWhenRequesting=j,this.disablePKCE=!!k,this.revokeTokenAdditionalContentTypes=x,this.fetchRequestCredentials=O||"same-origin",this.requestTimeoutInSeconds=S,R)this.stateStore=R;else{const e="undefined"!=typeof window?window.localStorage:new T;this.stateStore=new C({store:e})}if(this.refreshTokenAllowedScope=A,this.extraQueryParams=N,this.extraTokenParams=P,this.extraHeaders=I,this.dpop=U,this.dpop&&!(null==(L=this.dpop)?void 0:L.store))throw new Error("A DPoPStore is required when dpop is enabled")}},P=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new h("UserInfoService"),this._getClaimsFromJwt=async e=>{const t=this._logger.create("_getClaimsFromJwt");try{const r=p.decode(e);return t.debug("JWT decoding successful"),r}catch(r){throw t.error("Error parsing JWT response"),r}},this._jsonService=new O(void 0,this._getClaimsFromJwt,this._settings.extraHeaders)}async getClaims(e){const t=this._logger.create("getClaims");e||this._logger.throw(new Error("No token passed"));const r=await this._metadataService.getUserInfoEndpoint();t.debug("got userinfo url",r);const n=await this._jsonService.getJson(r,{token:e,credentials:this._settings.fetchRequestCredentials,timeoutInSeconds:this._settings.requestTimeoutInSeconds});return t.debug("got claims",n),n}},I=class{constructor(e,t){this._settings=e,this._metadataService=t,this._logger=new h("TokenClient"),this._jsonService=new O(this._settings.revokeTokenAdditionalContentTypes,null,this._settings.extraHeaders)}async exchangeCode({grant_type:e="authorization_code",redirect_uri:t=this._settings.redirect_uri,client_id:r=this._settings.client_id,client_secret:n=this._settings.client_secret,extraHeaders:s,...i}){const o=this._logger.create("exchangeCode");r||o.throw(new Error("A client_id is required")),t||o.throw(new Error("A redirect_uri is required")),i.code||o.throw(new Error("A code is required"));const a=new URLSearchParams({grant_type:e,redirect_uri:t});for(const[d,h]of Object.entries(i))null!=h&&a.set(d,h);let c;switch(this._settings.client_authentication){case"client_secret_basic":if(null==n)throw o.throw(new Error("A client_secret is required")),null;c=m.generateBasicAuth(r,n);break;case"client_secret_post":a.append("client_id",r),n&&a.append("client_secret",n)}const l=await this._metadataService.getTokenEndpoint(!1);o.debug("got token endpoint");const u=await this._jsonService.postForm(l,{body:a,basicAuth:c,timeoutInSeconds:this._settings.requestTimeoutInSeconds,initCredentials:this._settings.fetchRequestCredentials,extraHeaders:s});return o.debug("got response"),u}async exchangeCredentials({grant_type:e="password",client_id:t=this._settings.client_id,client_secret:r=this._settings.client_secret,scope:n=this._settings.scope,...s}){const i=this._logger.create("exchangeCredentials");t||i.throw(new Error("A client_id is required"));const o=new URLSearchParams({grant_type:e});this._settings.omitScopeWhenRequesting||o.set("scope",n);for(const[u,d]of Object.entries(s))null!=d&&o.set(u,d);let a;switch(this._settings.client_authentication){case"client_secret_basic":if(null==r)throw i.throw(new Error("A client_secret is required")),null;a=m.generateBasicAuth(t,r);break;case"client_secret_post":o.append("client_id",t),r&&o.append("client_secret",r)}const c=await this._metadataService.getTokenEndpoint(!1);i.debug("got token endpoint");const l=await this._jsonService.postForm(c,{body:o,basicAuth:a,timeoutInSeconds:this._settings.requestTimeoutInSeconds,initCredentials:this._settings.fetchRequestCredentials});return i.debug("got response"),l}async exchangeRefreshToken({grant_type:e="refresh_token",client_id:t=this._settings.client_id,client_secret:r=this._settings.client_secret,timeoutInSeconds:n,extraHeaders:s,...i}){const o=this._logger.create("exchangeRefreshToken");t||o.throw(new Error("A client_id is required")),i.refresh_token||o.throw(new Error("A refresh_token is required"));const a=new URLSearchParams({grant_type:e});for(const[d,h]of Object.entries(i))Array.isArray(h)?h.forEach((e=>a.append(d,e))):null!=h&&a.set(d,h);let c;switch(this._settings.client_authentication){case"client_secret_basic":if(null==r)throw o.throw(new Error("A client_secret is required")),null;c=m.generateBasicAuth(t,r);break;case"client_secret_post":a.append("client_id",t),r&&a.append("client_secret",r)}const l=await this._metadataService.getTokenEndpoint(!1);o.debug("got token endpoint");const u=await this._jsonService.postForm(l,{body:a,basicAuth:c,timeoutInSeconds:n,initCredentials:this._settings.fetchRequestCredentials,extraHeaders:s});return o.debug("got response"),u}async revoke(e){var t;const r=this._logger.create("revoke");e.token||r.throw(new Error("A token is required"));const n=await this._metadataService.getRevocationEndpoint(!1);r.debug(`got revocation endpoint, revoking ${null!=(t=e.token_type_hint)?t:"default token type"}`);const s=new URLSearchParams;for(const[i,o]of Object.entries(e))null!=o&&s.set(i,o);s.set("client_id",this._settings.client_id),this._settings.client_secret&&s.set("client_secret",this._settings.client_secret),await this._jsonService.postForm(n,{body:s,timeoutInSeconds:this._settings.requestTimeoutInSeconds}),r.debug("got response")}},U=class{constructor(e,t,r){this._settings=e,this._metadataService=t,this._claimsService=r,this._logger=new h("ResponseValidator"),this._userInfoService=new P(this._settings,this._metadataService),this._tokenClient=new I(this._settings,this._metadataService)}async validateSigninResponse(e,t,r){const n=this._logger.create("validateSigninResponse");this._processSigninState(e,t),n.debug("state processed"),await this._processCode(e,t,r),n.debug("code processed"),e.isOpenId&&this._validateIdTokenAttributes(e),n.debug("tokens validated"),await this._processClaims(e,null==t?void 0:t.skipUserInfo,e.isOpenId),n.debug("claims processed")}async validateCredentialsResponse(e,t){const r=this._logger.create("validateCredentialsResponse"),n=e.isOpenId&&!!e.id_token;n&&this._validateIdTokenAttributes(e),r.debug("tokens validated"),await this._processClaims(e,t,n),r.debug("claims processed")}async validateRefreshResponse(e,t){const r=this._logger.create("validateRefreshResponse");e.userState=t.data,null!=e.session_state||(e.session_state=t.session_state),null!=e.scope||(e.scope=t.scope),e.isOpenId&&e.id_token&&(this._validateIdTokenAttributes(e,t.id_token),r.debug("ID Token validated")),e.id_token||(e.id_token=t.id_token,e.profile=t.profile);const n=e.isOpenId&&!!e.id_token;await this._processClaims(e,!1,n),r.debug("claims processed")}validateSignoutResponse(e,t){const r=this._logger.create("validateSignoutResponse");if(t.id!==e.state&&r.throw(new Error("State does not match")),r.debug("state validated"),e.userState=t.data,e.error)throw r.warn("Response was error",e.error),new v(e)}_processSigninState(e,t){const r=this._logger.create("_processSigninState");if(t.id!==e.state&&r.throw(new Error("State does not match")),t.client_id||r.throw(new Error("No client_id on state")),t.authority||r.throw(new Error("No authority on state")),this._settings.authority!==t.authority&&r.throw(new Error("authority mismatch on settings vs. signin state")),this._settings.client_id&&this._settings.client_id!==t.client_id&&r.throw(new Error("client_id mismatch on settings vs. signin state")),r.debug("state validated"),e.userState=t.data,e.url_state=t.url_state,null!=e.scope||(e.scope=t.scope),e.error)throw r.warn("Response was error",e.error),new v(e);t.code_verifier&&!e.code&&r.throw(new Error("Expected code in response"))}async _processClaims(e,t=!1,r=!0){const n=this._logger.create("_processClaims");if(e.profile=this._claimsService.filterProtocolClaims(e.profile),t||!this._settings.loadUserInfo||!e.access_token)return void n.debug("not loading user info");n.debug("loading user info");const s=await this._userInfoService.getClaims(e.access_token);n.debug("user info claims received from user info endpoint"),r&&s.sub!==e.profile.sub&&n.throw(new Error("subject from UserInfo response does not match subject in ID Token")),e.profile=this._claimsService.mergeClaims(e.profile,this._claimsService.filterProtocolClaims(s)),n.debug("user info claims received, updated profile:",e.profile)}async _processCode(e,t,r){const n=this._logger.create("_processCode");if(e.code){n.debug("Validating code");const s=await this._tokenClient.exchangeCode({client_id:t.client_id,client_secret:t.client_secret,code:e.code,redirect_uri:t.redirect_uri,code_verifier:t.code_verifier,extraHeaders:r,...t.extraTokenParams});Object.assign(e,s)}else n.debug("No code to process")}_validateIdTokenAttributes(e,t){var r;const n=this._logger.create("_validateIdTokenAttributes");n.debug("decoding ID Token JWT");const s=p.decode(null!=(r=e.id_token)?r:"");if(s.sub||n.throw(new Error("ID Token is missing a subject claim")),t){const e=p.decode(t);s.sub!==e.sub&&n.throw(new Error("sub in id_token does not match current sub")),s.auth_time&&s.auth_time!==e.auth_time&&n.throw(new Error("auth_time in id_token does not match original auth_time")),s.azp&&s.azp!==e.azp&&n.throw(new Error("azp in id_token does not match original azp")),!s.azp&&e.azp&&n.throw(new Error("azp not in id_token, but present in original id_token"))}e.profile=s}},j=class e{constructor(e){this.id=e.id||m.generateUUIDv4(),this.data=e.data,e.created&&e.created>0?this.created=e.created:this.created=y.getEpochTime(),this.request_type=e.request_type,this.url_state=e.url_state}toStorageString(){return new h("State").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,url_state:this.url_state})}static fromStorageString(t){return h.createStatic("State","fromStorageString"),Promise.resolve(new e(JSON.parse(t)))}static async clearStaleState(t,r){const n=h.createStatic("State","clearStaleState"),s=y.getEpochTime()-r,i=await t.getAllKeys();n.debug("got keys",i);for(let a=0;a<i.length;a++){const r=i[a],c=await t.get(r);let l=!1;if(c)try{const t=await e.fromStorageString(c);n.debug("got item from key:",r,t.created),t.created<=s&&(l=!0)}catch(o){n.error("Error parsing state for key:",r,o),l=!0}else n.debug("no item in storage for key:",r),l=!0;l&&(n.debug("removed item for key:",r),t.remove(r))}}},L=class e extends j{constructor(e){super(e),this.code_verifier=e.code_verifier,this.code_challenge=e.code_challenge,this.authority=e.authority,this.client_id=e.client_id,this.redirect_uri=e.redirect_uri,this.scope=e.scope,this.client_secret=e.client_secret,this.extraTokenParams=e.extraTokenParams,this.response_mode=e.response_mode,this.skipUserInfo=e.skipUserInfo}static async create(t){const r=!0===t.code_verifier?m.generateCodeVerifier():t.code_verifier||void 0,n=r?await m.generateCodeChallenge(r):void 0;return new e({...t,code_verifier:r,code_challenge:n})}toStorageString(){return new h("SigninState").create("toStorageString"),JSON.stringify({id:this.id,data:this.data,created:this.created,request_type:this.request_type,url_state:this.url_state,code_verifier:this.code_verifier,authority:this.authority,client_id:this.client_id,redirect_uri:this.redirect_uri,scope:this.scope,client_secret:this.client_secret,extraTokenParams:this.extraTokenParams,response_mode:this.response_mode,skipUserInfo:this.skipUserInfo})}static fromStorageString(t){h.createStatic("SigninState","fromStorageString");const r=JSON.parse(t);return e.create(r)}},D=class e{constructor(e){this.url=e.url,this.state=e.state}static async create({url:t,authority:r,client_id:n,redirect_uri:s,response_type:i,scope:o,state_data:a,response_mode:c,request_type:l,client_secret:u,nonce:d,url_state:h,resource:p,skipUserInfo:f,extraQueryParams:g,extraTokenParams:m,disablePKCE:_,dpopJkt:w,omitScopeWhenRequesting:y,...b}){if(!t)throw this._logger.error("create: No url passed"),new Error("url");if(!n)throw this._logger.error("create: No client_id passed"),new Error("client_id");if(!s)throw this._logger.error("create: No redirect_uri passed"),new Error("redirect_uri");if(!i)throw this._logger.error("create: No response_type passed"),new Error("response_type");if(!o)throw this._logger.error("create: No scope passed"),new Error("scope");if(!r)throw this._logger.error("create: No authority passed"),new Error("authority");const v=await L.create({data:a,request_type:l,url_state:h,code_verifier:!_,client_id:n,authority:r,redirect_uri:s,response_mode:c,client_secret:u,scope:o,extraTokenParams:m,skipUserInfo:f}),E=new URL(t);E.searchParams.append("client_id",n),E.searchParams.append("redirect_uri",s),E.searchParams.append("response_type",i),y||E.searchParams.append("scope",o),d&&E.searchParams.append("nonce",d),w&&E.searchParams.append("dpop_jkt",w);let k=v.id;if(h&&(k=`${k}${S}${h}`),E.searchParams.append("state",k),v.code_challenge&&(E.searchParams.append("code_challenge",v.code_challenge),E.searchParams.append("code_challenge_method","S256")),p){(Array.isArray(p)?p:[p]).forEach((e=>E.searchParams.append("resource",e)))}for(const[e,S]of Object.entries({response_mode:c,...b,...g}))null!=S&&E.searchParams.append(e,S.toString());return new e({url:E.href,state:v})}};D._logger=new h("SigninRequest");var F=D,M=class{constructor(e){if(this.access_token="",this.token_type="",this.profile={},this.state=e.get("state"),this.session_state=e.get("session_state"),this.state){const e=decodeURIComponent(this.state).split(S);this.state=e[0],e.length>1&&(this.url_state=e.slice(1).join(S))}this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri"),this.code=e.get("code")}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-y.getEpochTime()}set expires_in(e){"string"==typeof e&&(e=Number(e)),void 0!==e&&e>=0&&(this.expires_at=Math.floor(e)+y.getEpochTime())}get isOpenId(){var e;return(null==(e=this.scope)?void 0:e.split(" ").includes("openid"))||!!this.id_token}},q=class{constructor({url:e,state_data:t,id_token_hint:r,post_logout_redirect_uri:n,extraQueryParams:s,request_type:i,client_id:o,url_state:a}){if(this._logger=new h("SignoutRequest"),!e)throw this._logger.error("ctor: No url passed"),new Error("url");const c=new URL(e);if(r&&c.searchParams.append("id_token_hint",r),o&&c.searchParams.append("client_id",o),n&&(c.searchParams.append("post_logout_redirect_uri",n),t||a)){this.state=new j({data:t,request_type:i,url_state:a});let e=this.state.id;a&&(e=`${e}${S}${a}`),c.searchParams.append("state",e)}for(const[l,u]of Object.entries({...s}))null!=u&&c.searchParams.append(l,u.toString());this.url=c.href}},B=class{constructor(e){if(this.state=e.get("state"),this.state){const e=decodeURIComponent(this.state).split(S);this.state=e[0],e.length>1&&(this.url_state=e.slice(1).join(S))}this.error=e.get("error"),this.error_description=e.get("error_description"),this.error_uri=e.get("error_uri")}},H=["nbf","jti","auth_time","nonce","acr","amr","azp","at_hash"],z=["sub","iss","aud","exp","iat"],W=class{constructor(e){this._settings=e,this._logger=new h("ClaimsService")}filterProtocolClaims(e){const t={...e};if(this._settings.filterProtocolClaims){let e;e=Array.isArray(this._settings.filterProtocolClaims)?this._settings.filterProtocolClaims:H;for(const r of e)z.includes(r)||delete t[r]}return t}mergeClaims(e,t){const r={...e};for(const[n,s]of Object.entries(t))if(r[n]!==s)if(Array.isArray(r[n])||Array.isArray(s))if("replace"==this._settings.mergeClaimsStrategy.array)r[n]=s;else{const e=Array.isArray(r[n])?r[n]:[r[n]];for(const t of Array.isArray(s)?s:[s])e.includes(t)||e.push(t);r[n]=e}else"object"==typeof r[n]&&"object"==typeof s?r[n]=this.mergeClaims(r[n],s):r[n]=s;return r}},$=class{constructor(e,t){this.keys=e,this.nonce=t}},K=class{constructor(e,t){this._logger=new h("OidcClient"),this.settings=e instanceof N?e:new N(e),this.metadataService=null!=t?t:new A(this.settings),this._claimsService=new W(this.settings),this._validator=new U(this.settings,this.metadataService,this._claimsService),this._tokenClient=new I(this.settings,this.metadataService)}async createSigninRequest({state:e,request:t,request_uri:r,request_type:n,id_token_hint:s,login_hint:i,skipUserInfo:o,nonce:a,url_state:c,response_type:l=this.settings.response_type,scope:u=this.settings.scope,redirect_uri:d=this.settings.redirect_uri,prompt:h=this.settings.prompt,display:p=this.settings.display,max_age:f=this.settings.max_age,ui_locales:g=this.settings.ui_locales,acr_values:m=this.settings.acr_values,resource:_=this.settings.resource,response_mode:w=this.settings.response_mode,extraQueryParams:y=this.settings.extraQueryParams,extraTokenParams:b=this.settings.extraTokenParams,dpopJkt:S,omitScopeWhenRequesting:v=this.settings.omitScopeWhenRequesting}){const E=this._logger.create("createSigninRequest");if("code"!==l)throw new Error("Only the Authorization Code flow (with PKCE) is supported");const k=await this.metadataService.getAuthorizationEndpoint();E.debug("Received authorization endpoint",k);const R=await F.create({url:k,authority:this.settings.authority,client_id:this.settings.client_id,redirect_uri:d,response_type:l,scope:u,state_data:e,url_state:c,prompt:h,display:p,max_age:f,ui_locales:g,id_token_hint:s,login_hint:i,acr_values:m,dpopJkt:S,resource:_,request:t,request_uri:r,extraQueryParams:y,extraTokenParams:b,request_type:n,response_mode:w,client_secret:this.settings.client_secret,skipUserInfo:o,nonce:a,disablePKCE:this.settings.disablePKCE,omitScopeWhenRequesting:v});await this.clearStaleState();const T=R.state;return await this.settings.stateStore.set(T.id,T.toStorageString()),R}async readSigninResponseState(e,t=!1){const r=this._logger.create("readSigninResponseState"),n=new M(b.readParams(e,this.settings.response_mode));if(!n.state)throw r.throw(new Error("No state in response")),null;const s=await this.settings.stateStore[t?"remove":"get"](n.state);if(!s)throw r.throw(new Error("No matching state found in storage")),null;return{state:await L.fromStorageString(s),response:n}}async processSigninResponse(e,t,r=!0){const n=this._logger.create("processSigninResponse"),{state:s,response:i}=await this.readSigninResponseState(e,r);if(n.debug("received state from storage; validating response"),this.settings.dpop&&this.settings.dpop.store){const e=await this.getDpopProof(this.settings.dpop.store);t={...t,DPoP:e}}try{await this._validator.validateSigninResponse(i,s,t)}catch(o){if(!(o instanceof x&&this.settings.dpop))throw o;{const e=await this.getDpopProof(this.settings.dpop.store,o.nonce);t.DPoP=e,await this._validator.validateSigninResponse(i,s,t)}}return i}async getDpopProof(e,t){let r,n;return(await e.getAllKeys()).includes(this.settings.client_id)?(n=await e.get(this.settings.client_id),n.nonce!==t&&t&&(n.nonce=t,await e.set(this.settings.client_id,n))):(r=await m.generateDPoPKeys(),n=new $(r,t),await e.set(this.settings.client_id,n)),await m.generateDPoPProof({url:await this.metadataService.getTokenEndpoint(!1),httpMethod:"POST",keyPair:n.keys,nonce:n.nonce})}async processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:r=!1,extraTokenParams:n={}}){const s=await this._tokenClient.exchangeCredentials({username:e,password:t,...n}),i=new M(new URLSearchParams);return Object.assign(i,s),await this._validator.validateCredentialsResponse(i,r),i}async useRefreshToken({state:e,redirect_uri:t,resource:r,timeoutInSeconds:n,extraHeaders:s,extraTokenParams:i}){var o;const a=this._logger.create("useRefreshToken");let c,l;if(void 0===this.settings.refreshTokenAllowedScope)c=e.scope;else{const t=this.settings.refreshTokenAllowedScope.split(" ");c=((null==(o=e.scope)?void 0:o.split(" "))||[]).filter((e=>t.includes(e))).join(" ")}if(this.settings.dpop&&this.settings.dpop.store){const e=await this.getDpopProof(this.settings.dpop.store);s={...s,DPoP:e}}try{l=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:c,redirect_uri:t,resource:r,timeoutInSeconds:n,extraHeaders:s,...i})}catch(d){if(!(d instanceof x&&this.settings.dpop))throw d;s.DPoP=await this.getDpopProof(this.settings.dpop.store,d.nonce),l=await this._tokenClient.exchangeRefreshToken({refresh_token:e.refresh_token,scope:c,redirect_uri:t,resource:r,timeoutInSeconds:n,extraHeaders:s,...i})}const u=new M(new URLSearchParams);return Object.assign(u,l),a.debug("validating response",u),await this._validator.validateRefreshResponse(u,{...e,scope:c}),u}async createSignoutRequest({state:e,id_token_hint:t,client_id:r,request_type:n,url_state:s,post_logout_redirect_uri:i=this.settings.post_logout_redirect_uri,extraQueryParams:o=this.settings.extraQueryParams}={}){const a=this._logger.create("createSignoutRequest"),c=await this.metadataService.getEndSessionEndpoint();if(!c)throw a.throw(new Error("No end session endpoint")),null;a.debug("Received end session endpoint",c),r||!i||t||(r=this.settings.client_id);const l=new q({url:c,id_token_hint:t,client_id:r,post_logout_redirect_uri:i,state_data:e,extraQueryParams:o,request_type:n,url_state:s});await this.clearStaleState();const u=l.state;return u&&(a.debug("Signout request has state to persist"),await this.settings.stateStore.set(u.id,u.toStorageString())),l}async readSignoutResponseState(e,t=!1){const r=this._logger.create("readSignoutResponseState"),n=new B(b.readParams(e,this.settings.response_mode));if(!n.state){if(r.debug("No state in response"),n.error)throw r.warn("Response was error:",n.error),new v(n);return{state:void 0,response:n}}const s=await this.settings.stateStore[t?"remove":"get"](n.state);if(!s)throw r.throw(new Error("No matching state found in storage")),null;return{state:await j.fromStorageString(s),response:n}}async processSignoutResponse(e){const t=this._logger.create("processSignoutResponse"),{state:r,response:n}=await this.readSignoutResponseState(e,!0);return r?(t.debug("Received state from storage; validating response"),this._validator.validateSignoutResponse(n,r)):t.debug("No state from storage; skipping response validation"),n}clearStaleState(){return this._logger.create("clearStaleState"),j.clearStaleState(this.settings.stateStore,this.settings.staleStateAgeInSeconds)}async revokeToken(e,t){return this._logger.create("revokeToken"),await this._tokenClient.revoke({token:e,token_type_hint:t})}},J=class{constructor(e){this._userManager=e,this._logger=new h("SessionMonitor"),this._start=async e=>{const t=e.session_state;if(!t)return;const r=this._logger.create("_start");if(e.profile?(this._sub=e.profile.sub,r.debug("session_state",t,", sub",this._sub)):(this._sub=void 0,r.debug("session_state",t,", anonymous user")),this._checkSessionIFrame)this._checkSessionIFrame.start(t);else try{const e=await this._userManager.metadataService.getCheckSessionIframe();if(e){r.debug("initializing check session iframe");const n=this._userManager.settings.client_id,s=this._userManager.settings.checkSessionIntervalInSeconds,i=this._userManager.settings.stopCheckSessionOnError,o=new R(this._callback,n,e,s,i);await o.load(),this._checkSessionIFrame=o,o.start(t)}else r.warn("no check session iframe found in the metadata")}catch(n){r.error("Error from getCheckSessionIframe:",n instanceof Error?n.message:n)}},this._stop=()=>{const e=this._logger.create("_stop");if(this._sub=void 0,this._checkSessionIFrame&&this._checkSessionIFrame.stop(),this._userManager.settings.monitorAnonymousSession){const t=setInterval((async()=>{clearInterval(t);try{const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub?{sub:e.sub}:null};this._start(t)}}catch(r){e.error("error from querySessionStatus",r instanceof Error?r.message:r)}}),1e3)}},this._callback=async()=>{const e=this._logger.create("_callback");try{const t=await this._userManager.querySessionStatus();let r=!0;t&&this._checkSessionIFrame?t.sub===this._sub?(r=!1,this._checkSessionIFrame.start(t.session_state),e.debug("same sub still logged in at OP, session state has changed, restarting check session iframe; session_state",t.session_state),await this._userManager.events._raiseUserSessionChanged()):e.debug("different subject signed into OP",t.sub):e.debug("subject no longer signed into OP"),r?this._sub?await this._userManager.events._raiseUserSignedOut():await this._userManager.events._raiseUserSignedIn():e.debug("no change in session detected, no event to raise")}catch(t){this._sub&&(e.debug("Error calling queryCurrentSigninSession; raising signed out event",t),await this._userManager.events._raiseUserSignedOut())}},e||this._logger.throw(new Error("No user manager passed")),this._userManager.events.addUserLoaded(this._start),this._userManager.events.addUserUnloaded(this._stop),this._init().catch((e=>{this._logger.error(e)}))}async _init(){this._logger.create("_init");const e=await this._userManager.getUser();if(e)this._start(e);else if(this._userManager.settings.monitorAnonymousSession){const e=await this._userManager.querySessionStatus();if(e){const t={session_state:e.session_state,profile:e.sub?{sub:e.sub}:null};this._start(t)}}}},V=class e{constructor(e){var t;this.id_token=e.id_token,this.session_state=null!=(t=e.session_state)?t:null,this.access_token=e.access_token,this.refresh_token=e.refresh_token,this.token_type=e.token_type,this.scope=e.scope,this.profile=e.profile,this.expires_at=e.expires_at,this.state=e.userState,this.url_state=e.url_state}get expires_in(){if(void 0!==this.expires_at)return this.expires_at-y.getEpochTime()}set expires_in(e){void 0!==e&&(this.expires_at=Math.floor(e)+y.getEpochTime())}get expired(){const e=this.expires_in;if(void 0!==e)return e<=0}get scopes(){var e,t;return null!=(t=null==(e=this.scope)?void 0:e.split(" "))?t:[]}toStorageString(){return new h("User").create("toStorageString"),JSON.stringify({id_token:this.id_token,session_state:this.session_state,access_token:this.access_token,refresh_token:this.refresh_token,token_type:this.token_type,scope:this.scope,profile:this.profile,expires_at:this.expires_at})}static fromStorageString(t){return h.createStatic("User","fromStorageString"),new e(JSON.parse(t))}},G="oidc-client",X=class{constructor(){this._abort=new _("Window navigation aborted"),this._disposeHandlers=new Set,this._window=null}async navigate(e){const t=this._logger.create("navigate");if(!this._window)throw new Error("Attempted to navigate on a disposed window");t.debug("setting URL in window"),this._window.location.replace(e.url);const{url:r,keepOpen:n}=await new Promise(((r,n)=>{const s=s=>{var i;const o=s.data,a=null!=(i=e.scriptOrigin)?i:window.location.origin;if(s.origin===a&&(null==o?void 0:o.source)===G){try{const r=b.readParams(o.url,e.response_mode).get("state");if(r||t.warn("no state found in response url"),s.source!==this._window&&r!==e.state)return}catch{this._dispose(),n(new Error("Invalid response from window"))}r(o)}};window.addEventListener("message",s,!1),this._disposeHandlers.add((()=>window.removeEventListener("message",s,!1)));const i=new BroadcastChannel(`oidc-client-popup-${e.state}`);i.addEventListener("message",s,!1),this._disposeHandlers.add((()=>i.close())),this._disposeHandlers.add(this._abort.addHandler((e=>{this._dispose(),n(e)})))}));return t.debug("got response from window"),this._dispose(),n||this.close(),{url:r}}_dispose(){this._logger.create("_dispose");for(const e of this._disposeHandlers)e();this._disposeHandlers.clear()}static _notifyParent(e,t,r=!1,n=window.location.origin){const s={source:G,url:t,keepOpen:r},i=new h("_notifyParent");if(e)i.debug("With parent. Using parent.postMessage."),e.postMessage(s,n);else{i.debug("No parent. Using BroadcastChannel.");const e=new URL(t).searchParams.get("state");if(!e)throw new Error("No parent and no state in URL. Can't complete notification.");const r=new BroadcastChannel(`oidc-client-popup-${e}`);r.postMessage(s),r.close()}}},Q={location:!1,toolbar:!1,height:640,closePopupWindowAfterInSeconds:-1},Y="_blank",Z=60,ee=2,te=class extends N{constructor(e){const{popup_redirect_uri:t=e.redirect_uri,popup_post_logout_redirect_uri:r=e.post_logout_redirect_uri,popupWindowFeatures:n=Q,popupWindowTarget:s=Y,redirectMethod:i="assign",redirectTarget:o="self",iframeNotifyParentOrigin:a=e.iframeNotifyParentOrigin,iframeScriptOrigin:c=e.iframeScriptOrigin,requestTimeoutInSeconds:l,silent_redirect_uri:u=e.redirect_uri,silentRequestTimeoutInSeconds:d,automaticSilentRenew:h=!0,validateSubOnSilentRenew:p=!0,includeIdTokenInSilentRenew:f=!1,monitorSession:g=!1,monitorAnonymousSession:m=!1,checkSessionIntervalInSeconds:_=ee,query_status_response_type:w="code",stopCheckSessionOnError:y=!0,revokeTokenTypes:b=["access_token","refresh_token"],revokeTokensOnSignout:S=!1,includeIdTokenInSilentSignout:v=!1,accessTokenExpiringNotificationTimeInSeconds:E=Z,userStore:k}=e;if(super(e),this.popup_redirect_uri=t,this.popup_post_logout_redirect_uri=r,this.popupWindowFeatures=n,this.popupWindowTarget=s,this.redirectMethod=i,this.redirectTarget=o,this.iframeNotifyParentOrigin=a,this.iframeScriptOrigin=c,this.silent_redirect_uri=u,this.silentRequestTimeoutInSeconds=d||l||10,this.automaticSilentRenew=h,this.validateSubOnSilentRenew=p,this.includeIdTokenInSilentRenew=f,this.monitorSession=g,this.monitorAnonymousSession=m,this.checkSessionIntervalInSeconds=_,this.stopCheckSessionOnError=y,this.query_status_response_type=w,this.revokeTokenTypes=b,this.revokeTokensOnSignout=S,this.includeIdTokenInSilentSignout=v,this.accessTokenExpiringNotificationTimeInSeconds=E,k)this.userStore=k;else{const e="undefined"!=typeof window?window.sessionStorage:new T;this.userStore=new C({store:e})}}},re=class e extends X{constructor({silentRequestTimeoutInSeconds:t=10}){super(),this._logger=new h("IFrameWindow"),this._timeoutInSeconds=t,this._frame=e.createHiddenIframe(),this._window=this._frame.contentWindow}static createHiddenIframe(){const e=window.document.createElement("iframe");return e.style.visibility="hidden",e.style.position="fixed",e.style.left="-1000px",e.style.top="0",e.width="0",e.height="0",window.document.body.appendChild(e),e}async navigate(e){this._logger.debug("navigate: Using timeout of:",this._timeoutInSeconds);const t=setTimeout((()=>{this._abort.raise(new E("IFrame timed out without a response"))}),1e3*this._timeoutInSeconds);return this._disposeHandlers.add((()=>clearTimeout(t))),await super.navigate(e)}close(){var e;this._frame&&(this._frame.parentNode&&(this._frame.addEventListener("load",(e=>{var t;const r=e.target;null==(t=r.parentNode)||t.removeChild(r),this._abort.raise(new Error("IFrame removed from DOM"))}),!0),null==(e=this._frame.contentWindow)||e.location.replace("about:blank")),this._frame=null),this._window=null}static notifyParent(e,t){return super._notifyParent(window.parent,e,!1,t)}},ne=class{constructor(e){this._settings=e,this._logger=new h("IFrameNavigator")}async prepare({silentRequestTimeoutInSeconds:e=this._settings.silentRequestTimeoutInSeconds}){return new re({silentRequestTimeoutInSeconds:e})}async callback(e){this._logger.create("callback"),re.notifyParent(e,this._settings.iframeNotifyParentOrigin)}},se=class extends X{constructor({popupWindowTarget:e=Y,popupWindowFeatures:t={},popupSignal:r}){super(),this._logger=new h("PopupWindow");const n=w.center({...Q,...t});this._window=window.open(void 0,e,w.serialize(n)),r&&r.addEventListener("abort",(()=>{var e;this._abort.raise(new Error(null!=(e=r.reason)?e:"Popup aborted"))})),t.closePopupWindowAfterInSeconds&&t.closePopupWindowAfterInSeconds>0&&setTimeout((()=>{this._window&&"boolean"==typeof this._window.closed&&!this._window.closed?this.close():this._abort.raise(new Error("Popup blocked by user"))}),1e3*t.closePopupWindowAfterInSeconds)}async navigate(e){var t;null==(t=this._window)||t.focus();const r=setInterval((()=>{this._window&&!this._window.closed||(this._logger.debug("Popup closed by user or isolated by redirect"),n(),this._disposeHandlers.delete(n))}),500),n=()=>clearInterval(r);return this._disposeHandlers.add(n),await super.navigate(e)}close(){this._window&&(this._window.closed||(this._window.close(),this._abort.raise(new Error("Popup closed")))),this._window=null}static notifyOpener(e,t){super._notifyParent(window.opener,e,t),t||window.opener||window.close()}},ie=class{constructor(e){this._settings=e,this._logger=new h("PopupNavigator")}async prepare({popupWindowFeatures:e=this._settings.popupWindowFeatures,popupWindowTarget:t=this._settings.popupWindowTarget,popupSignal:r}){return new se({popupWindowFeatures:e,popupWindowTarget:t,popupSignal:r})}async callback(e,{keepOpen:t=!1}){this._logger.create("callback"),se.notifyOpener(e,t)}},oe=class{constructor(e){this._settings=e,this._logger=new h("RedirectNavigator")}async prepare({redirectMethod:e=this._settings.redirectMethod,redirectTarget:t=this._settings.redirectTarget}){var r;this._logger.create("prepare");let n=window.self;"top"===t&&(n=null!=(r=window.top)?r:window.self);const s=n.location[e].bind(n.location);let i;return{navigate:async e=>{this._logger.create("navigate");const t=new Promise(((e,t)=>{i=t}));return s(e.url),await t},close:()=>{this._logger.create("close"),null==i||i(new Error("Redirect aborted")),n.stop()}}}async callback(){}},ae=class extends k{constructor(e){super({expiringNotificationTimeInSeconds:e.accessTokenExpiringNotificationTimeInSeconds}),this._logger=new h("UserManagerEvents"),this._userLoaded=new _("User loaded"),this._userUnloaded=new _("User unloaded"),this._silentRenewError=new _("Silent renew error"),this._userSignedIn=new _("User signed in"),this._userSignedOut=new _("User signed out"),this._userSessionChanged=new _("User session changed")}async load(e,t=!0){await super.load(e),t&&await this._userLoaded.raise(e)}async unload(){await super.unload(),await this._userUnloaded.raise()}addUserLoaded(e){return this._userLoaded.addHandler(e)}removeUserLoaded(e){return this._userLoaded.removeHandler(e)}addUserUnloaded(e){return this._userUnloaded.addHandler(e)}removeUserUnloaded(e){return this._userUnloaded.removeHandler(e)}addSilentRenewError(e){return this._silentRenewError.addHandler(e)}removeSilentRenewError(e){return this._silentRenewError.removeHandler(e)}async _raiseSilentRenewError(e){await this._silentRenewError.raise(e)}addUserSignedIn(e){return this._userSignedIn.addHandler(e)}removeUserSignedIn(e){this._userSignedIn.removeHandler(e)}async _raiseUserSignedIn(){await this._userSignedIn.raise()}addUserSignedOut(e){return this._userSignedOut.addHandler(e)}removeUserSignedOut(e){this._userSignedOut.removeHandler(e)}async _raiseUserSignedOut(){await this._userSignedOut.raise()}addUserSessionChanged(e){return this._userSessionChanged.addHandler(e)}removeUserSessionChanged(e){this._userSessionChanged.removeHandler(e)}async _raiseUserSessionChanged(){await this._userSessionChanged.raise()}},ce=class{constructor(e){this._userManager=e,this._logger=new h("SilentRenewService"),this._isStarted=!1,this._retryTimer=new y("Retry Silent Renew"),this._tokenExpiring=async()=>{const e=this._logger.create("_tokenExpiring");try{await this._userManager.signinSilent(),e.debug("silent token renewal successful")}catch(t){if(t instanceof E)return e.warn("ErrorTimeout from signinSilent:",t,"retry in 5s"),void this._retryTimer.init(5);e.error("Error from signinSilent:",t),await this._userManager.events._raiseSilentRenewError(t)}}}async start(){const e=this._logger.create("start");if(!this._isStarted){this._isStarted=!0,this._userManager.events.addAccessTokenExpiring(this._tokenExpiring),this._retryTimer.addHandler(this._tokenExpiring);try{await this._userManager.getUser()}catch(t){e.error("getUser error",t)}}}stop(){this._isStarted&&(this._retryTimer.cancel(),this._retryTimer.removeHandler(this._tokenExpiring),this._userManager.events.removeAccessTokenExpiring(this._tokenExpiring),this._isStarted=!1)}},le=class{constructor(e){this.refresh_token=e.refresh_token,this.id_token=e.id_token,this.session_state=e.session_state,this.scope=e.scope,this.profile=e.profile,this.data=e.state}},ue=class{constructor(e,t,r,n){this._logger=new h("UserManager"),this.settings=new te(e),this._client=new K(e),this._redirectNavigator=null!=t?t:new oe(this.settings),this._popupNavigator=null!=r?r:new ie(this.settings),this._iframeNavigator=null!=n?n:new ne(this.settings),this._events=new ae(this.settings),this._silentRenewService=new ce(this),this.settings.automaticSilentRenew&&this.startSilentRenew(),this._sessionMonitor=null,this.settings.monitorSession&&(this._sessionMonitor=new J(this))}get events(){return this._events}get metadataService(){return this._client.metadataService}async getUser(e=!1){const t=this._logger.create("getUser"),r=await this._loadUser();return r?(t.info("user loaded"),await this._events.load(r,e),r):(t.info("user not found in storage"),null)}async removeUser(){const e=this._logger.create("removeUser");await this.storeUser(null),e.info("user removed from storage"),await this._events.unload()}async signinRedirect(e={}){var t;this._logger.create("signinRedirect");const{redirectMethod:r,...n}=e;let s;(null==(t=this.settings.dpop)?void 0:t.bind_authorization_code)&&(s=await this.generateDPoPJkt(this.settings.dpop));const i=await this._redirectNavigator.prepare({redirectMethod:r});await this._signinStart({request_type:"si:r",dpopJkt:s,...n},i)}async signinRedirectCallback(e=window.location.href){const t=this._logger.create("signinRedirectCallback"),r=await this._signinEnd(e);return r.profile&&r.profile.sub?t.info("success, signed in subject",r.profile.sub):t.info("no subject"),r}async signinResourceOwnerCredentials({username:e,password:t,skipUserInfo:r=!1}){const n=this._logger.create("signinResourceOwnerCredential"),s=await this._client.processResourceOwnerPasswordCredentials({username:e,password:t,skipUserInfo:r,extraTokenParams:this.settings.extraTokenParams});n.debug("got signin response");const i=await this._buildUser(s);return i.profile&&i.profile.sub?n.info("success, signed in subject",i.profile.sub):n.info("no subject"),i}async signinPopup(e={}){var t;const r=this._logger.create("signinPopup");let n;(null==(t=this.settings.dpop)?void 0:t.bind_authorization_code)&&(n=await this.generateDPoPJkt(this.settings.dpop));const{popupWindowFeatures:s,popupWindowTarget:i,popupSignal:o,...a}=e,c=this.settings.popup_redirect_uri;c||r.throw(new Error("No popup_redirect_uri configured"));const l=await this._popupNavigator.prepare({popupWindowFeatures:s,popupWindowTarget:i,popupSignal:o}),u=await this._signin({request_type:"si:p",redirect_uri:c,display:"popup",dpopJkt:n,...a},l);return u&&(u.profile&&u.profile.sub?r.info("success, signed in subject",u.profile.sub):r.info("no subject")),u}async signinPopupCallback(e=window.location.href,t=!1){const r=this._logger.create("signinPopupCallback");await this._popupNavigator.callback(e,{keepOpen:t}),r.info("success")}async signinSilent(e={}){var t,r;const n=this._logger.create("signinSilent"),{silentRequestTimeoutInSeconds:s,...i}=e;let o,a=await this._loadUser();if(null==a?void 0:a.refresh_token){n.debug("using refresh token");const e=new le(a);return await this._useRefreshToken({state:e,redirect_uri:i.redirect_uri,resource:i.resource,extraTokenParams:i.extraTokenParams,timeoutInSeconds:s})}(null==(t=this.settings.dpop)?void 0:t.bind_authorization_code)&&(o=await this.generateDPoPJkt(this.settings.dpop));const c=this.settings.silent_redirect_uri;let l;c||n.throw(new Error("No silent_redirect_uri configured")),a&&this.settings.validateSubOnSilentRenew&&(n.debug("subject prior to silent renew:",a.profile.sub),l=a.profile.sub);const u=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:s});return a=await this._signin({request_type:"si:s",redirect_uri:c,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==a?void 0:a.id_token:void 0,dpopJkt:o,...i},u,l),a&&((null==(r=a.profile)?void 0:r.sub)?n.info("success, signed in subject",a.profile.sub):n.info("no subject")),a}async _useRefreshToken(e){const t=await this._client.useRefreshToken({timeoutInSeconds:this.settings.silentRequestTimeoutInSeconds,...e}),r=new V({...e.state,...t});return await this.storeUser(r),await this._events.load(r),r}async signinSilentCallback(e=window.location.href){const t=this._logger.create("signinSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async signinCallback(e=window.location.href){const{state:t}=await this._client.readSigninResponseState(e);switch(t.request_type){case"si:r":return await this.signinRedirectCallback(e);case"si:p":await this.signinPopupCallback(e);break;case"si:s":await this.signinSilentCallback(e);break;default:throw new Error("invalid response_type in state")}}async signoutCallback(e=window.location.href,t=!1){const{state:r}=await this._client.readSignoutResponseState(e);if(r)switch(r.request_type){case"so:r":return await this.signoutRedirectCallback(e);case"so:p":await this.signoutPopupCallback(e,t);break;case"so:s":await this.signoutSilentCallback(e);break;default:throw new Error("invalid response_type in state")}}async querySessionStatus(e={}){const t=this._logger.create("querySessionStatus"),{silentRequestTimeoutInSeconds:r,...n}=e,s=this.settings.silent_redirect_uri;s||t.throw(new Error("No silent_redirect_uri configured"));const i=await this._loadUser(),o=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:r}),a=await this._signinStart({request_type:"si:s",redirect_uri:s,prompt:"none",id_token_hint:this.settings.includeIdTokenInSilentRenew?null==i?void 0:i.id_token:void 0,response_type:this.settings.query_status_response_type,scope:"openid",skipUserInfo:!0,...n},o);try{const e={},r=await this._client.processSigninResponse(a.url,e);return t.debug("got signin response"),r.session_state&&r.profile.sub?(t.info("success for subject",r.profile.sub),{session_state:r.session_state,sub:r.profile.sub}):(t.info("success, user not authenticated"),null)}catch(c){if(this.settings.monitorAnonymousSession&&c instanceof v)switch(c.error){case"login_required":case"consent_required":case"interaction_required":case"account_selection_required":return t.info("success for anonymous user"),{session_state:c.session_state}}throw c}}async _signin(e,t,r){const n=await this._signinStart(e,t);return await this._signinEnd(n.url,r)}async _signinStart(e,t){const r=this._logger.create("_signinStart");try{const n=await this._client.createSigninRequest(e);return r.debug("got signin request"),await t.navigate({url:n.url,state:n.state.id,response_mode:n.state.response_mode,scriptOrigin:this.settings.iframeScriptOrigin})}catch(n){throw r.debug("error after preparing navigator, closing navigator window"),t.close(),n}}async _signinEnd(e,t){const r=this._logger.create("_signinEnd"),n=await this._client.processSigninResponse(e,{});r.debug("got signin response");return await this._buildUser(n,t)}async _buildUser(e,t){const r=this._logger.create("_buildUser"),n=new V(e);if(t){if(t!==n.profile.sub)throw r.debug("current user does not match user returned from signin. sub from signin:",n.profile.sub),new v({...e,error:"login_required"});r.debug("current user matches user returned from signin")}return await this.storeUser(n),r.debug("user stored"),await this._events.load(n),n}async signoutRedirect(e={}){const t=this._logger.create("signoutRedirect"),{redirectMethod:r,...n}=e,s=await this._redirectNavigator.prepare({redirectMethod:r});await this._signoutStart({request_type:"so:r",post_logout_redirect_uri:this.settings.post_logout_redirect_uri,...n},s),t.info("success")}async signoutRedirectCallback(e=window.location.href){const t=this._logger.create("signoutRedirectCallback"),r=await this._signoutEnd(e);return t.info("success"),r}async signoutPopup(e={}){const t=this._logger.create("signoutPopup"),{popupWindowFeatures:r,popupWindowTarget:n,popupSignal:s,...i}=e,o=this.settings.popup_post_logout_redirect_uri,a=await this._popupNavigator.prepare({popupWindowFeatures:r,popupWindowTarget:n,popupSignal:s});await this._signout({request_type:"so:p",post_logout_redirect_uri:o,state:null==o?void 0:{},...i},a),t.info("success")}async signoutPopupCallback(e=window.location.href,t=!1){const r=this._logger.create("signoutPopupCallback");await this._popupNavigator.callback(e,{keepOpen:t}),r.info("success")}async _signout(e,t){const r=await this._signoutStart(e,t);return await this._signoutEnd(r.url)}async _signoutStart(e={},t){var r;const n=this._logger.create("_signoutStart");try{const s=await this._loadUser();n.debug("loaded current user from storage"),this.settings.revokeTokensOnSignout&&await this._revokeInternal(s);const i=e.id_token_hint||s&&s.id_token;i&&(n.debug("setting id_token_hint in signout request"),e.id_token_hint=i),await this.removeUser(),n.debug("user removed, creating signout request");const o=await this._client.createSignoutRequest(e);return n.debug("got signout request"),await t.navigate({url:o.url,state:null==(r=o.state)?void 0:r.id,scriptOrigin:this.settings.iframeScriptOrigin})}catch(s){throw n.debug("error after preparing navigator, closing navigator window"),t.close(),s}}async _signoutEnd(e){const t=this._logger.create("_signoutEnd"),r=await this._client.processSignoutResponse(e);return t.debug("got signout response"),r}async signoutSilent(e={}){var t;const r=this._logger.create("signoutSilent"),{silentRequestTimeoutInSeconds:n,...s}=e,i=this.settings.includeIdTokenInSilentSignout?null==(t=await this._loadUser())?void 0:t.id_token:void 0,o=this.settings.popup_post_logout_redirect_uri,a=await this._iframeNavigator.prepare({silentRequestTimeoutInSeconds:n});await this._signout({request_type:"so:s",post_logout_redirect_uri:o,id_token_hint:i,...s},a),r.info("success")}async signoutSilentCallback(e=window.location.href){const t=this._logger.create("signoutSilentCallback");await this._iframeNavigator.callback(e),t.info("success")}async revokeTokens(e){const t=await this._loadUser();await this._revokeInternal(t,e)}async _revokeInternal(e,t=this.settings.revokeTokenTypes){const r=this._logger.create("_revokeInternal");if(!e)return;const n=t.filter((t=>"string"==typeof e[t]));if(n.length){for(const t of n)await this._client.revokeToken(e[t],t),r.info(`${t} revoked successfully`),"access_token"!==t&&(e[t]=null);await this.storeUser(e),r.debug("user stored"),await this._events.load(e)}else r.debug("no need to revoke due to no token(s)")}startSilentRenew(){this._logger.create("startSilentRenew"),this._silentRenewService.start()}stopSilentRenew(){this._silentRenewService.stop()}get _userStoreKey(){return`user:${this.settings.authority}:${this.settings.client_id}`}async _loadUser(){const e=this._logger.create("_loadUser"),t=await this.settings.userStore.get(this._userStoreKey);return t?(e.debug("user storageString loaded"),V.fromStorageString(t)):(e.debug("no user storageString"),null)}async storeUser(e){const t=this._logger.create("storeUser");if(e){t.debug("storing user");const r=e.toStorageString();await this.settings.userStore.set(this._userStoreKey,r)}else this._logger.debug("removing user"),await this.settings.userStore.remove(this._userStoreKey),this.settings.dpop&&await this.settings.dpop.store.remove(this.settings.client_id)}async clearStaleState(){await this._client.clearStaleState()}async dpopProof(e,t,r,n){var s,i;const o=await(null==(i=null==(s=this.settings.dpop)?void 0:s.store)?void 0:i.get(this.settings.client_id));if(o)return await m.generateDPoPProof({url:e,accessToken:null==t?void 0:t.access_token,httpMethod:r,keyPair:o.keys,nonce:n})}async generateDPoPJkt(e){let t=await e.store.get(this.settings.client_id);if(!t){const r=await m.generateDPoPKeys();t=new $(r),await e.store.set(this.settings.client_id,t)}return await m.generateDPoPJkt(t.keys)}},de=s.createContext(void 0);de.displayName="AuthContext";var he={isLoading:!0,isAuthenticated:!1},pe=(e,t)=>{switch(t.type){case"INITIALISED":case"USER_LOADED":return{...e,user:t.user,isLoading:!1,isAuthenticated:!!t.user&&!t.user.expired,error:void 0};case"USER_SIGNED_OUT":case"USER_UNLOADED":return{...e,user:void 0,isAuthenticated:!1};case"NAVIGATOR_INIT":return{...e,isLoading:!0,activeNavigator:t.method};case"NAVIGATOR_CLOSE":return{...e,isLoading:!1,activeNavigator:void 0};case"ERROR":{const r=t.error;return r.toString=()=>`${r.name}: ${r.message}`,{...e,isLoading:!1,error:r}}default:{const r=new TypeError(`unknown type ${t.type}`),n={name:r.name,message:r.message,innerError:r,stack:r.stack,source:"unknown",toString:()=>`${n.name}: ${n.message}`};return{...e,isLoading:!1,error:n}}}},fe=we("signinCallback","Sign-in failed"),ge=we("signoutCallback","Sign-out failed"),me=we("renewSilent","Renew silent failed");function _e(e,t){return{name:ye(e,"name",(()=>"Error")),message:ye(e,"message",(()=>t)),stack:ye(e,"stack",(()=>(new Error).stack)),innerError:e}}function we(e,t){return r=>({..._e(r,t),source:e})}function ye(e,t,r){if(e&&"object"==typeof e){const r=e[t];if("string"==typeof r)return r}return r()}var be=["clearStaleState","querySessionStatus","revokeTokens","startSilentRenew","stopSilentRenew"],Se=["signinPopup","signinSilent","signinRedirect","signinResourceOwnerCredentials","signoutPopup","signoutRedirect","signoutSilent"],ve=e=>()=>{throw new Error(`UserManager#${e} was called from an unsupported context. If this is a server-rendered page, defer this call with useEffect() or pass a custom UserManager implementation.`)},Ee="undefined"==typeof window?null:ue,ke=e=>{const{children:t,onSigninCallback:r,skipSigninCallback:n,matchSignoutCallback:i,onSignoutCallback:o,onRemoveUser:a,userManager:c=null,...l}=e,[u]=s.useState((()=>null!=c?c:Ee?new Ee(l):{settings:l})),[d,h]=s.useReducer(pe,he),p=s.useMemo((()=>Object.assign({settings:u.settings,events:u.events},Object.fromEntries(be.map((e=>{var t,r;return[e,null!=(r=null==(t=u[e])?void 0:t.bind(u))?r:ve(e)]}))),Object.fromEntries(Se.map((e=>[e,u[e]?async t=>{h({type:"NAVIGATOR_INIT",method:e});try{return await u[e](t)}catch(r){return h({type:"ERROR",error:{..._e(r,`Unknown error while executing ${e}(...).`),source:e,args:t}}),null}finally{h({type:"NAVIGATOR_CLOSE"})}}:ve(e)]))))),[u]),f=s.useRef(!1);s.useEffect((()=>{u&&!f.current&&(f.current=!0,(async()=>{try{let e=null;((e=window.location)=>{let t=new URLSearchParams(e.search);return!!((t.get("code")||t.get("error"))&&t.get("state")||(t=new URLSearchParams(e.hash.replace("#","?")),(t.get("code")||t.get("error"))&&t.get("state")))})()&&!n&&(e=await u.signinCallback(),r&&await r(e)),e=e||await u.getUser(),h({type:"INITIALISED",user:e})}catch(e){h({type:"ERROR",error:fe(e)})}try{if(i&&i(u.settings)){const e=await u.signoutCallback();o&&await o(e)}}catch(e){h({type:"ERROR",error:ge(e)})}})())}),[u,n,r,o,i]),s.useEffect((()=>{if(!u)return;const e=e=>{h({type:"USER_LOADED",user:e})};u.events.addUserLoaded(e);const t=()=>{h({type:"USER_UNLOADED"})};u.events.addUserUnloaded(t);const r=()=>{h({type:"USER_SIGNED_OUT"})};u.events.addUserSignedOut(r);const n=e=>{h({type:"ERROR",error:me(e)})};return u.events.addSilentRenewError(n),()=>{u.events.removeUserLoaded(e),u.events.removeUserUnloaded(t),u.events.removeUserSignedOut(r),u.events.removeSilentRenewError(n)}}),[u]);const g=s.useCallback((async()=>{await u.removeUser(),a&&await a()}),[u,a]),m=s.useMemo((()=>({...d,...p,removeUser:g})),[d,p,g]);return s.createElement(de.Provider,{value:m},t)},Re=()=>{const e=s.useContext(de);return e||console.warn("AuthProvider context is undefined, please verify you are calling useAuth() as child of a <AuthProvider> component."),e};function Te(e,t){return function(){return e.apply(t,arguments)}}const{toString:xe}=Object.prototype,{getPrototypeOf:Oe}=Object,{iterator:Ae,toStringTag:Ce}=Symbol,Ne=(e=>t=>{const r=xe.call(t);return e[r]||(e[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),Pe=e=>(e=e.toLowerCase(),t=>Ne(t)===e),Ie=e=>t=>typeof t===e,{isArray:Ue}=Array,je=Ie("undefined");const Le=Pe("ArrayBuffer");const De=Ie("string"),Fe=Ie("function"),Me=Ie("number"),qe=e=>null!==e&&"object"==typeof e,Be=e=>{if("object"!==Ne(e))return!1;const t=Oe(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Ce in e||Ae in e)},He=Pe("Date"),ze=Pe("File"),We=Pe("Blob"),$e=Pe("FileList"),Ke=Pe("URLSearchParams"),[Je,Ve,Ge,Xe]=["ReadableStream","Request","Response","Headers"].map(Pe);function Qe(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,s;if("object"!=typeof e&&(e=[e]),Ue(e))for(n=0,s=e.length;n<s;n++)t.call(null,e[n],n,e);else{const s=r?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let o;for(n=0;n<i;n++)o=s[n],t.call(null,e[o],o,e)}}function Ye(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,s=r.length;for(;s-- >0;)if(n=r[s],t===n.toLowerCase())return n;return null}const Ze="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,et=e=>!je(e)&&e!==Ze;const tt=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&Oe(Uint8Array)),rt=Pe("HTMLFormElement"),nt=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),st=Pe("RegExp"),it=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};Qe(r,((r,s)=>{let i;!1!==(i=t(r,s,e))&&(n[s]=i||r)})),Object.defineProperties(e,n)};const ot=Pe("AsyncFunction"),at=(ct="function"==typeof setImmediate,lt=Fe(Ze.postMessage),ct?setImmediate:lt?(ut=`axios@${Math.random()}`,dt=[],Ze.addEventListener("message",(({source:e,data:t})=>{e===Ze&&t===ut&&dt.length&&dt.shift()()}),!1),e=>{dt.push(e),Ze.postMessage(ut,"*")}):e=>setTimeout(e));var ct,lt,ut,dt;const ht="undefined"!=typeof queueMicrotask?queueMicrotask.bind(Ze):"undefined"!=typeof process&&process.nextTick||at,pt={isArray:Ue,isArrayBuffer:Le,isBuffer:function(e){return null!==e&&!je(e)&&null!==e.constructor&&!je(e.constructor)&&Fe(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||Fe(e.append)&&("formdata"===(t=Ne(e))||"object"===t&&Fe(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&Le(e.buffer),t},isString:De,isNumber:Me,isBoolean:e=>!0===e||!1===e,isObject:qe,isPlainObject:Be,isReadableStream:Je,isRequest:Ve,isResponse:Ge,isHeaders:Xe,isUndefined:je,isDate:He,isFile:ze,isBlob:We,isRegExp:st,isFunction:Fe,isStream:e=>qe(e)&&Fe(e.pipe),isURLSearchParams:Ke,isTypedArray:tt,isFileList:$e,forEach:Qe,merge:function e(){const{caseless:t}=et(this)&&this||{},r={},n=(n,s)=>{const i=t&&Ye(r,s)||s;Be(r[i])&&Be(n)?r[i]=e(r[i],n):Be(n)?r[i]=e({},n):Ue(n)?r[i]=n.slice():r[i]=n};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&Qe(arguments[s],n);return r},extend:(e,t,r,{allOwnKeys:n}={})=>(Qe(t,((t,n)=>{r&&Fe(t)?e[n]=Te(t,r):e[n]=t}),{allOwnKeys:n}),e),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(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)},toFlatObject:(e,t,r,n)=>{let s,i,o;const a={};if(t=t||{},null==e)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)o=s[i],n&&!n(o,e,t)||a[o]||(t[o]=e[o],a[o]=!0);e=!1!==r&&Oe(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:Ne,kindOfTest:Pe,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(Ue(e))return e;let t=e.length;if(!Me(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[Ae]).call(e);let n;for(;(n=r.next())&&!n.done;){const r=n.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:rt,hasOwnProperty:nt,hasOwnProp:nt,reduceDescriptors:it,freezeMethods:e=>{it(e,((t,r)=>{if(Fe(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];Fe(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return Ue(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:Ye,global:Ze,isContextDefined:et,isSpecCompliantForm:function(e){return!!(e&&Fe(e.append)&&"FormData"===e[Ce]&&e[Ae])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(qe(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const s=Ue(e)?[]:{};return Qe(e,((e,t)=>{const i=r(e,n+1);!je(i)&&(s[t]=i)})),t[n]=void 0,s}}return e};return r(e,0)},isAsyncFn:ot,isThenable:e=>e&&(qe(e)||Fe(e))&&Fe(e.then)&&Fe(e.catch),setImmediate:at,asap:ht,isIterable:e=>null!=e&&Fe(e[Ae])};function ft(e,t,r,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}pt.inherits(ft,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:pt.toJSONObject(this.config),code:this.code,status:this.status}}});const gt=ft.prototype,mt={};["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=>{mt[e]={value:e}})),Object.defineProperties(ft,mt),Object.defineProperty(gt,"isAxiosError",{value:!0}),ft.from=(e,t,r,n,s,i)=>{const o=Object.create(gt);return pt.toFlatObject(e,o,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),ft.call(o,e.message,t,r,n,s),o.cause=e,o.name=e.name,i&&Object.assign(o,i),o};function _t(e){return pt.isPlainObject(e)||pt.isArray(e)}function wt(e){return pt.endsWith(e,"[]")?e.slice(0,-2):e}function yt(e,t,r){return e?e.concat(t).map((function(e,t){return e=wt(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const bt=pt.toFlatObject(pt,{},null,(function(e){return/^is[A-Z]/.test(e)}));function St(e,t,r){if(!pt.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=pt.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!pt.isUndefined(t[e])}))).metaTokens,s=r.visitor||l,i=r.dots,o=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&pt.isSpecCompliantForm(t);if(!pt.isFunction(s))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(pt.isDate(e))return e.toISOString();if(pt.isBoolean(e))return e.toString();if(!a&&pt.isBlob(e))throw new ft("Blob is not supported. Use a Buffer instead.");return pt.isArrayBuffer(e)||pt.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,r,s){let a=e;if(e&&!s&&"object"==typeof e)if(pt.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(pt.isArray(e)&&function(e){return pt.isArray(e)&&!e.some(_t)}(e)||(pt.isFileList(e)||pt.endsWith(r,"[]"))&&(a=pt.toArray(e)))return r=wt(r),a.forEach((function(e,n){!pt.isUndefined(e)&&null!==e&&t.append(!0===o?yt([r],n,i):null===o?r:r+"[]",c(e))})),!1;return!!_t(e)||(t.append(yt(s,r,i),c(e)),!1)}const u=[],d=Object.assign(bt,{defaultVisitor:l,convertValue:c,isVisitable:_t});if(!pt.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!pt.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),pt.forEach(r,(function(r,i){!0===(!(pt.isUndefined(r)||null===r)&&s.call(t,r,pt.isString(i)?i.trim():i,n,d))&&e(r,n?n.concat(i):[i])})),u.pop()}}(e),t}function vt(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function Et(e,t){this._pairs=[],e&&St(e,this,t)}const kt=Et.prototype;function Rt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Tt(e,t,r){if(!t)return e;const n=r&&r.encode||Rt;pt.isFunction(r)&&(r={serialize:r});const s=r&&r.serialize;let i;if(i=s?s(t,r):pt.isURLSearchParams(t)?t.toString():new Et(t,r).toString(n),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}kt.append=function(e,t){this._pairs.push([e,t])},kt.toString=function(e){const t=e?function(t){return e.call(this,t,vt)}:vt;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};class xt{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){pt.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}const Ot={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},At={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:Et,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},Ct="undefined"!=typeof window&&"undefined"!=typeof document,Nt="object"==typeof navigator&&navigator||void 0,Pt=Ct&&(!Nt||["ReactNative","NativeScript","NS"].indexOf(Nt.product)<0),It="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,Ut=Ct&&window.location.href||"http://localhost",jt={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ct,hasStandardBrowserEnv:Pt,hasStandardBrowserWebWorkerEnv:It,navigator:Nt,origin:Ut},Symbol.toStringTag,{value:"Module"})),...At};function Lt(e){function t(e,r,n,s){let i=e[s++];if("__proto__"===i)return!0;const o=Number.isFinite(+i),a=s>=e.length;if(i=!i&&pt.isArray(n)?n.length:i,a)return pt.hasOwnProp(n,i)?n[i]=[n[i],r]:n[i]=r,!o;n[i]&&pt.isObject(n[i])||(n[i]=[]);return t(e,r,n[i],s)&&pt.isArray(n[i])&&(n[i]=function(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}(n[i])),!o}if(pt.isFormData(e)&&pt.isFunction(e.entries)){const r={};return pt.forEachEntry(e,((e,n)=>{t(function(e){return pt.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const Dt={transitional:Ot,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,s=pt.isObject(e);s&&pt.isHTMLForm(e)&&(e=new FormData(e));if(pt.isFormData(e))return n?JSON.stringify(Lt(e)):e;if(pt.isArrayBuffer(e)||pt.isBuffer(e)||pt.isStream(e)||pt.isFile(e)||pt.isBlob(e)||pt.isReadableStream(e))return e;if(pt.isArrayBufferView(e))return e.buffer;if(pt.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return St(e,new jt.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return jt.isNode&&pt.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=pt.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return St(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return s||n?(t.setContentType("application/json",!1),function(e,t,r){if(pt.isString(e))try{return(t||JSON.parse)(e),pt.trim(e)}catch(en){if("SyntaxError"!==en.name)throw en}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||Dt.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(pt.isResponse(e)||pt.isReadableStream(e))return e;if(e&&pt.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(en){if(r){if("SyntaxError"===en.name)throw ft.from(en,ft.ERR_BAD_RESPONSE,this,null,this.response);throw en}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:jt.classes.FormData,Blob:jt.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};pt.forEach(["delete","get","head","post","put","patch"],(e=>{Dt.headers[e]={}}));const Ft=pt.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"]),Mt=Symbol("internals");function qt(e){return e&&String(e).trim().toLowerCase()}function Bt(e){return!1===e||null==e?e:pt.isArray(e)?e.map(Bt):String(e)}function Ht(e,t,r,n,s){return pt.isFunction(n)?n.call(this,t,r):(s&&(t=r),pt.isString(t)?pt.isString(n)?-1!==t.indexOf(n):pt.isRegExp(n)?n.test(t):void 0:void 0)}let zt=class{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function s(e,t,r){const s=qt(t);if(!s)throw new Error("header name must be a non-empty string");const i=pt.findKey(n,s);(!i||void 0===n[i]||!0===r||void 0===r&&!1!==n[i])&&(n[i||t]=Bt(e))}const i=(e,t)=>pt.forEach(e,((e,r)=>s(e,r,t)));if(pt.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(pt.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let r,n,s;return e&&e.split("\n").forEach((function(e){s=e.indexOf(":"),r=e.substring(0,s).trim().toLowerCase(),n=e.substring(s+1).trim(),!r||t[r]&&Ft[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t);else if(pt.isObject(e)&&pt.isIterable(e)){let r,n,s={};for(const t of e){if(!pt.isArray(t))throw TypeError("Object iterator must return a key-value pair");s[n=t[0]]=(r=s[n])?pt.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}i(s,t)}else null!=e&&s(t,e,r);return this}get(e,t){if(e=qt(e)){const r=pt.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(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}(e);if(pt.isFunction(t))return t.call(this,e,r);if(pt.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=qt(e)){const r=pt.findKey(this,e);return!(!r||void 0===this[r]||t&&!Ht(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function s(e){if(e=qt(e)){const s=pt.findKey(r,e);!s||t&&!Ht(0,r[s],s,t)||(delete r[s],n=!0)}}return pt.isArray(e)?e.forEach(s):s(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const s=t[r];e&&!Ht(0,this[s],s,e,!0)||(delete this[s],n=!0)}return n}normalize(e){const t=this,r={};return pt.forEach(this,((n,s)=>{const i=pt.findKey(r,s);if(i)return t[i]=Bt(n),void delete t[s];const o=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(s):String(s).trim();o!==s&&delete t[s],t[o]=Bt(n),r[o]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return pt.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&pt.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[Mt]=this[Mt]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=qt(e);t[n]||(!function(e,t){const r=pt.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,s){return this[n].call(this,t,e,r,s)},configurable:!0})}))}(r,e),t[n]=!0)}return pt.isArray(e)?e.forEach(n):n(e),this}};function Wt(e,t){const r=this||Dt,n=t||r,s=zt.from(n.headers);let i=n.data;return pt.forEach(e,(function(e){i=e.call(r,i,s.normalize(),t?t.status:void 0)})),s.normalize(),i}function $t(e){return!(!e||!e.__CANCEL__)}function Kt(e,t,r){ft.call(this,null==e?"canceled":e,ft.ERR_CANCELED,t,r),this.name="CanceledError"}function Jt(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new ft("Request failed with status code "+r.status,[ft.ERR_BAD_REQUEST,ft.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}zt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),pt.reduceDescriptors(zt.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),pt.freezeMethods(zt),pt.inherits(Kt,ft,{__CANCEL__:!0});const Vt=(e,t,r=3)=>{let n=0;const s=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let s,i=0,o=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=n[o];s||(s=c),r[i]=a,n[i]=c;let u=o,d=0;for(;u!==i;)d+=r[u++],u%=e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),c-s<t)return;const h=l&&c-l;return h?Math.round(1e3*d/h):void 0}}(50,250);return function(e,t){let r,n,s=0,i=1e3/t;const o=(t,i=Date.now())=>{s=i,r=null,n&&(clearTimeout(n),n=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-s;a>=i?o(e,t):(r=e,n||(n=setTimeout((()=>{n=null,o(r)}),i-a)))},()=>r&&o(r)]}((r=>{const i=r.loaded,o=r.lengthComputable?r.total:void 0,a=i-n,c=s(a);n=i;e({loaded:i,total:o,progress:o?i/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&i<=o?(o-i)/c:void 0,event:r,lengthComputable:null!=o,[t?"download":"upload"]:!0})}),r)},Gt=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},Xt=e=>(...t)=>pt.asap((()=>e(...t))),Qt=jt.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,jt.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(jt.origin),jt.navigator&&/(msie|trident)/i.test(jt.navigator.userAgent)):()=>!0,Yt=jt.hasStandardBrowserEnv?{write(e,t,r,n,s,i){const o=[e+"="+encodeURIComponent(t)];pt.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),pt.isString(n)&&o.push("path="+n),pt.isString(s)&&o.push("domain="+s),!0===i&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Zt(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const er=e=>e instanceof zt?{...e}:e;function tr(e,t){t=t||{};const r={};function n(e,t,r,n){return pt.isPlainObject(e)&&pt.isPlainObject(t)?pt.merge.call({caseless:n},e,t):pt.isPlainObject(t)?pt.merge({},t):pt.isArray(t)?t.slice():t}function s(e,t,r,s){return pt.isUndefined(t)?pt.isUndefined(e)?void 0:n(void 0,e,0,s):n(e,t,0,s)}function i(e,t){if(!pt.isUndefined(t))return n(void 0,t)}function o(e,t){return pt.isUndefined(t)?pt.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,s,i){return i in t?n(r,s):i in e?n(void 0,r):void 0}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(e,t,r)=>s(er(e),er(t),0,!0)};return pt.forEach(Object.keys(Object.assign({},e,t)),(function(n){const i=c[n]||s,o=i(e[n],t[n],n);pt.isUndefined(o)&&i!==a||(r[n]=o)})),r}const rr=e=>{const t=tr({},e);let r,{data:n,withXSRFToken:s,xsrfHeaderName:i,xsrfCookieName:o,headers:a,auth:c}=t;if(t.headers=a=zt.from(a),t.url=Tt(Zt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),pt.isFormData(n))if(jt.hasStandardBrowserEnv||jt.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(r=a.getContentType())){const[e,...t]=r?r.split(";").map((e=>e.trim())).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(jt.hasStandardBrowserEnv&&(s&&pt.isFunction(s)&&(s=s(t)),s||!1!==s&&Qt(t.url))){const e=i&&o&&Yt.read(o);e&&a.set(i,e)}return t},nr="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){const n=rr(e);let s=n.data;const i=zt.from(n.headers).normalize();let o,a,c,l,u,{responseType:d,onUploadProgress:h,onDownloadProgress:p}=n;function f(){l&&l(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let g=new XMLHttpRequest;function m(){if(!g)return;const n=zt.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());Jt((function(e){t(e),f()}),(function(e){r(e),f()}),{data:d&&"text"!==d&&"json"!==d?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:n,config:e,request:g}),g=null}g.open(n.method.toUpperCase(),n.url,!0),g.timeout=n.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(m)},g.onabort=function(){g&&(r(new ft("Request aborted",ft.ECONNABORTED,e,g)),g=null)},g.onerror=function(){r(new ft("Network Error",ft.ERR_NETWORK,e,g)),g=null},g.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const s=n.transitional||Ot;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new ft(t,s.clarifyTimeoutError?ft.ETIMEDOUT:ft.ECONNABORTED,e,g)),g=null},void 0===s&&i.setContentType(null),"setRequestHeader"in g&&pt.forEach(i.toJSON(),(function(e,t){g.setRequestHeader(t,e)})),pt.isUndefined(n.withCredentials)||(g.withCredentials=!!n.withCredentials),d&&"json"!==d&&(g.responseType=n.responseType),p&&([c,u]=Vt(p,!0),g.addEventListener("progress",c)),h&&g.upload&&([a,l]=Vt(h),g.upload.addEventListener("progress",a),g.upload.addEventListener("loadend",l)),(n.cancelToken||n.signal)&&(o=t=>{g&&(r(!t||t.type?new Kt(null,e,g):t),g.abort(),g=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));const _=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);_&&-1===jt.protocols.indexOf(_)?r(new ft("Unsupported protocol "+_+":",ft.ERR_BAD_REQUEST,e)):g.send(s||null)}))},sr=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const s=function(e){if(!r){r=!0,o();const t=e instanceof Error?e:this.reason;n.abort(t instanceof ft?t:new Kt(t instanceof Error?t.message:t))}};let i=t&&setTimeout((()=>{i=null,s(new ft(`timeout ${t} of ms exceeded`,ft.ETIMEDOUT))}),t);const o=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(s):e.removeEventListener("abort",s)})),e=null)};e.forEach((e=>e.addEventListener("abort",s)));const{signal:a}=n;return a.unsubscribe=()=>pt.asap(o),a}},ir=function*(e,t){let r=e.byteLength;if(r<t)return void(yield e);let n,s=0;for(;s<r;)n=s+t,yield e.slice(s,n),s=n},or=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},ar=(e,t,r,n)=>{const s=async function*(e,t){for await(const r of or(e))yield*ir(r,t)}(e,t);let i,o=0,a=e=>{i||(i=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await s.next();if(t)return a(),void e.close();let i=n.byteLength;if(r){let e=o+=i;r(e)}e.enqueue(new Uint8Array(n))}catch(t){throw a(t),t}},cancel:e=>(a(e),s.return())},{highWaterMark:2})},cr="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,lr=cr&&"function"==typeof ReadableStream,ur=cr&&("function"==typeof TextEncoder?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),dr=(e,...t)=>{try{return!!e(...t)}catch(en){return!1}},hr=lr&&dr((()=>{let e=!1;const t=new Request(jt.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),pr=lr&&dr((()=>pt.isReadableStream(new Response("").body))),fr={stream:pr&&(e=>e.body)};var gr;cr&&(gr=new Response,["text","arrayBuffer","blob","formData","stream"].forEach((e=>{!fr[e]&&(fr[e]=pt.isFunction(gr[e])?t=>t[e]():(t,r)=>{throw new ft(`Response type '${e}' is not supported`,ft.ERR_NOT_SUPPORT,r)})})));const mr=async(e,t)=>{const r=pt.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(pt.isBlob(e))return e.size;if(pt.isSpecCompliantForm(e)){const t=new Request(jt.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return pt.isArrayBufferView(e)||pt.isArrayBuffer(e)?e.byteLength:(pt.isURLSearchParams(e)&&(e+=""),pt.isString(e)?(await ur(e)).byteLength:void 0)})(t):r},_r={http:null,xhr:nr,fetch:cr&&(async e=>{let{url:t,method:r,data:n,signal:s,cancelToken:i,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:u,withCredentials:d="same-origin",fetchOptions:h}=rr(e);l=l?(l+"").toLowerCase():"text";let p,f=sr([s,i&&i.toAbortSignal()],o);const g=f&&f.unsubscribe&&(()=>{f.unsubscribe()});let m;try{if(c&&hr&&"get"!==r&&"head"!==r&&0!==(m=await mr(u,n))){let e,r=new Request(t,{method:"POST",body:n,duplex:"half"});if(pt.isFormData(n)&&(e=r.headers.get("content-type"))&&u.setContentType(e),r.body){const[e,t]=Gt(m,Vt(Xt(c)));n=ar(r.body,65536,e,t)}}pt.isString(d)||(d=d?"include":"omit");const s="credentials"in Request.prototype;p=new Request(t,{...h,signal:f,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:s?d:void 0});let i=await fetch(p,h);const o=pr&&("stream"===l||"response"===l);if(pr&&(a||o&&g)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=i[t]}));const t=pt.toFiniteNumber(i.headers.get("content-length")),[r,n]=a&&Gt(t,Vt(Xt(a),!0))||[];i=new Response(ar(i.body,65536,r,(()=>{n&&n(),g&&g()})),e)}l=l||"text";let _=await fr[pt.findKey(fr,l)||"text"](i,e);return!o&&g&&g(),await new Promise(((t,r)=>{Jt(t,r,{data:_,headers:zt.from(i.headers),status:i.status,statusText:i.statusText,config:e,request:p})}))}catch(_){if(g&&g(),_&&"TypeError"===_.name&&/Load failed|fetch/i.test(_.message))throw Object.assign(new ft("Network Error",ft.ERR_NETWORK,e,p),{cause:_.cause||_});throw ft.from(_,_&&_.code,e,p)}})};pt.forEach(_r,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(en){}Object.defineProperty(e,"adapterName",{value:t})}}));const wr=e=>`- ${e}`,yr=e=>pt.isFunction(e)||null===e||!1===e,br=e=>{e=pt.isArray(e)?e:[e];const{length:t}=e;let r,n;const s={};for(let i=0;i<t;i++){let t;if(r=e[i],n=r,!yr(r)&&(n=_r[(t=String(r)).toLowerCase()],void 0===n))throw new ft(`Unknown adapter '${t}'`);if(n)break;s[t||"#"+i]=n}if(!n){const e=Object.entries(s).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new ft("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(wr).join("\n"):" "+wr(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function Sr(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Kt(null,e)}function vr(e){Sr(e),e.headers=zt.from(e.headers),e.data=Wt.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return br(e.adapter||Dt.adapter)(e).then((function(t){return Sr(e),t.data=Wt.call(e,e.transformResponse,t),t.headers=zt.from(t.headers),t}),(function(t){return $t(t)||(Sr(e),t&&t.response&&(t.response.data=Wt.call(e,e.transformResponse,t.response),t.response.headers=zt.from(t.response.headers))),Promise.reject(t)}))}const Er="1.10.0",kr={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{kr[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Rr={};kr.transitional=function(e,t,r){function n(e,t){return"[Axios v"+Er+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,s,i)=>{if(!1===e)throw new ft(n(s," has been removed"+(t?" in "+t:"")),ft.ERR_DEPRECATED);return t&&!Rr[s]&&(Rr[s]=!0,console.warn(n(s," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,s,i)}},kr.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};const Tr={assertOptions:function(e,t,r){if("object"!=typeof e)throw new ft("options must be an object",ft.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let s=n.length;for(;s-- >0;){const i=n[s],o=t[i];if(o){const t=e[i],r=void 0===t||o(t,i,e);if(!0!==r)throw new ft("option "+i+" must be "+r,ft.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new ft("Unknown option "+i,ft.ERR_BAD_OPTION)}},validators:kr},xr=Tr.validators;let Or=class{constructor(e){this.defaults=e||{},this.interceptors={request:new xt,response:new xt}}async request(e,t){try{return await this._request(e,t)}catch(r){if(r instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const t=e.stack?e.stack.replace(/^.+\n/,""):"";try{r.stack?t&&!String(r.stack).endsWith(t.replace(/^.+\n.+\n/,""))&&(r.stack+="\n"+t):r.stack=t}catch(en){}}throw r}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=tr(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:s}=t;void 0!==r&&Tr.assertOptions(r,{silentJSONParsing:xr.transitional(xr.boolean),forcedJSONParsing:xr.transitional(xr.boolean),clarifyTimeoutError:xr.transitional(xr.boolean)},!1),null!=n&&(pt.isFunction(n)?t.paramsSerializer={serialize:n}:Tr.assertOptions(n,{encode:xr.function,serialize:xr.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Tr.assertOptions(t,{baseUrl:xr.spelling("baseURL"),withXsrfToken:xr.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=s&&pt.merge(s.common,s[t.method]);s&&pt.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete s[e]})),t.headers=zt.concat(i,s);const o=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,o.unshift(e.fulfilled,e.rejected))}));const c=[];let l;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,d=0;if(!a){const e=[vr.bind(this),void 0];for(e.unshift.apply(e,o),e.push.apply(e,c),u=e.length,l=Promise.resolve(t);d<u;)l=l.then(e[d++],e[d++]);return l}u=o.length;let h=t;for(d=0;d<u;){const e=o[d++],t=o[d++];try{h=e(h)}catch(p){t.call(this,p);break}}try{l=vr.call(this,h)}catch(p){return Promise.reject(p)}for(d=0,u=c.length;d<u;)l=l.then(c[d++],c[d++]);return l}getUri(e){return Tt(Zt((e=tr(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}};pt.forEach(["delete","get","head","options"],(function(e){Or.prototype[e]=function(t,r){return this.request(tr(r||{},{method:e,url:t,data:(r||{}).data}))}})),pt.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,s){return this.request(tr(s||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Or.prototype[e]=t(),Or.prototype[e+"Form"]=t(!0)}));const Ar={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(Ar).forEach((([e,t])=>{Ar[t]=e}));const Cr=function e(t){const r=new Or(t),n=Te(Or.prototype.request,r);return pt.extend(n,Or.prototype,r,{allOwnKeys:!0}),pt.extend(n,r,null,{allOwnKeys:!0}),n.create=function(r){return e(tr(t,r))},n}(Dt);Cr.Axios=Or,Cr.CanceledError=Kt,Cr.CancelToken=class e{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,s){r.reason||(r.reason=new Kt(e,n,s),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let t;return{token:new e((function(e){t=e})),cancel:t}}},Cr.isCancel=$t,Cr.VERSION=Er,Cr.toFormData=St,Cr.AxiosError=ft,Cr.Cancel=Cr.CanceledError,Cr.all=function(e){return Promise.all(e)},Cr.spread=function(e){return function(t){return e.apply(null,t)}},Cr.isAxiosError=function(e){return pt.isObject(e)&&!0===e.isAxiosError},Cr.mergeConfig=tr,Cr.AxiosHeaders=zt,Cr.formToJSON=e=>Lt(pt.isHTMLForm(e)?new FormData(e):e),Cr.getAdapter=br,Cr.HttpStatusCode=Ar,Cr.default=Cr;const{Axios:Nr,AxiosError:Pr,CanceledError:Ir,isCancel:Ur,CancelToken:jr,VERSION:Lr,all:Dr,Cancel:Fr,isAxiosError:Mr,spread:qr,toFormData:Br,AxiosHeaders:Hr,HttpStatusCode:zr,formToJSON:Wr,getAdapter:$r,mergeConfig:Kr}=Cr;var Jr="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function Vr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Gr,Xr,Qr={exports:{}};
|
|
2
2
|
/*! Axios v1.10.0 Copyright (c) 2025 Matt Zabriskie and contributors */function Yr(){if(Xr)return Gr;function e(e,t){return function(){return e.apply(t,arguments)}}Xr=1;const{toString:t}=Object.prototype,{getPrototypeOf:r}=Object,{iterator:n,toStringTag:s}=Symbol,i=(e=>r=>{const n=t.call(r);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),o=e=>(e=e.toLowerCase(),t=>i(t)===e),a=e=>t=>typeof t===e,{isArray:c}=Array,l=a("undefined");const u=o("ArrayBuffer");const d=a("string"),h=a("function"),p=a("number"),f=e=>null!==e&&"object"==typeof e,g=e=>{if("object"!==i(e))return!1;const t=r(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||s in e||n in e)},m=o("Date"),_=o("File"),w=o("Blob"),y=o("FileList"),b=o("URLSearchParams"),[S,v,E,k]=["ReadableStream","Request","Response","Headers"].map(o);function R(e,t,{allOwnKeys:r=!1}={}){if(null==e)return;let n,s;if("object"!=typeof e&&(e=[e]),c(e))for(n=0,s=e.length;n<s;n++)t.call(null,e[n],n,e);else{const s=r?Object.getOwnPropertyNames(e):Object.keys(e),i=s.length;let o;for(n=0;n<i;n++)o=s[n],t.call(null,e[o],o,e)}}function T(e,t){t=t.toLowerCase();const r=Object.keys(e);let n,s=r.length;for(;s-- >0;)if(n=r[s],t===n.toLowerCase())return n;return null}const x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:Jr,O=e=>!l(e)&&e!==x;const A=(e=>t=>e&&t instanceof e)("undefined"!=typeof Uint8Array&&r(Uint8Array)),C=o("HTMLFormElement"),N=(({hasOwnProperty:e})=>(t,r)=>e.call(t,r))(Object.prototype),P=o("RegExp"),I=(e,t)=>{const r=Object.getOwnPropertyDescriptors(e),n={};R(r,((r,s)=>{let i;!1!==(i=t(r,s,e))&&(n[s]=i||r)})),Object.defineProperties(e,n)};const U=o("AsyncFunction"),j=((e,t)=>e?setImmediate:t?((e,t)=>(x.addEventListener("message",(({source:r,data:n})=>{r===x&&n===e&&t.length&&t.shift()()}),!1),r=>{t.push(r),x.postMessage(e,"*")}))(`axios@${Math.random()}`,[]):e=>setTimeout(e))("function"==typeof setImmediate,h(x.postMessage)),L="undefined"!=typeof queueMicrotask?queueMicrotask.bind(x):"undefined"!=typeof process&&process.nextTick||j;var D={isArray:c,isArrayBuffer:u,isBuffer:function(e){return null!==e&&!l(e)&&null!==e.constructor&&!l(e.constructor)&&h(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:e=>{let t;return e&&("function"==typeof FormData&&e instanceof FormData||h(e.append)&&("formdata"===(t=i(e))||"object"===t&&h(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){let t;return t="undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&u(e.buffer),t},isString:d,isNumber:p,isBoolean:e=>!0===e||!1===e,isObject:f,isPlainObject:g,isReadableStream:S,isRequest:v,isResponse:E,isHeaders:k,isUndefined:l,isDate:m,isFile:_,isBlob:w,isRegExp:P,isFunction:h,isStream:e=>f(e)&&h(e.pipe),isURLSearchParams:b,isTypedArray:A,isFileList:y,forEach:R,merge:function e(){const{caseless:t}=O(this)&&this||{},r={},n=(n,s)=>{const i=t&&T(r,s)||s;g(r[i])&&g(n)?r[i]=e(r[i],n):g(n)?r[i]=e({},n):c(n)?r[i]=n.slice():r[i]=n};for(let s=0,i=arguments.length;s<i;s++)arguments[s]&&R(arguments[s],n);return r},extend:(t,r,n,{allOwnKeys:s}={})=>(R(r,((r,s)=>{n&&h(r)?t[s]=e(r,n):t[s]=r}),{allOwnKeys:s}),t),trim:e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,""),stripBOM:e=>(65279===e.charCodeAt(0)&&(e=e.slice(1)),e),inherits:(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)},toFlatObject:(e,t,n,s)=>{let i,o,a;const c={};if(t=t||{},null==e)return t;do{for(i=Object.getOwnPropertyNames(e),o=i.length;o-- >0;)a=i[o],s&&!s(a,e,t)||c[a]||(t[a]=e[a],c[a]=!0);e=!1!==n&&r(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:i,kindOfTest:o,endsWith:(e,t,r)=>{e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;const n=e.indexOf(t,r);return-1!==n&&n===r},toArray:e=>{if(!e)return null;if(c(e))return e;let t=e.length;if(!p(t))return null;const r=new Array(t);for(;t-- >0;)r[t]=e[t];return r},forEachEntry:(e,t)=>{const r=(e&&e[n]).call(e);let s;for(;(s=r.next())&&!s.done;){const r=s.value;t.call(e,r[0],r[1])}},matchAll:(e,t)=>{let r;const n=[];for(;null!==(r=e.exec(t));)n.push(r);return n},isHTMLForm:C,hasOwnProperty:N,hasOwnProp:N,reduceDescriptors:I,freezeMethods:e=>{I(e,((t,r)=>{if(h(e)&&-1!==["arguments","caller","callee"].indexOf(r))return!1;const n=e[r];h(n)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")}))}))},toObjectSet:(e,t)=>{const r={},n=e=>{e.forEach((e=>{r[e]=!0}))};return c(e)?n(e):n(String(e).split(t)),r},toCamelCase:e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,r){return t.toUpperCase()+r})),noop:()=>{},toFiniteNumber:(e,t)=>null!=e&&Number.isFinite(e=+e)?e:t,findKey:T,global:x,isContextDefined:O,isSpecCompliantForm:function(e){return!!(e&&h(e.append)&&"FormData"===e[s]&&e[n])},toJSONObject:e=>{const t=new Array(10),r=(e,n)=>{if(f(e)){if(t.indexOf(e)>=0)return;if(!("toJSON"in e)){t[n]=e;const s=c(e)?[]:{};return R(e,((e,t)=>{const i=r(e,n+1);!l(i)&&(s[t]=i)})),t[n]=void 0,s}}return e};return r(e,0)},isAsyncFn:U,isThenable:e=>e&&(f(e)||h(e))&&h(e.then)&&h(e.catch),setImmediate:j,asap:L,isIterable:e=>null!=e&&h(e[n])};function F(e,t,r,n,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),s&&(this.response=s,this.status=s.status?s.status:null)}D.inherits(F,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:D.toJSONObject(this.config),code:this.code,status:this.status}}});const M=F.prototype,q={};["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=>{q[e]={value:e}})),Object.defineProperties(F,q),Object.defineProperty(M,"isAxiosError",{value:!0}),F.from=(e,t,r,n,s,i)=>{const o=Object.create(M);return D.toFlatObject(e,o,(function(e){return e!==Error.prototype}),(e=>"isAxiosError"!==e)),F.call(o,e.message,t,r,n,s),o.cause=e,o.name=e.name,i&&Object.assign(o,i),o};function B(e){return D.isPlainObject(e)||D.isArray(e)}function H(e){return D.endsWith(e,"[]")?e.slice(0,-2):e}function z(e,t,r){return e?e.concat(t).map((function(e,t){return e=H(e),!r&&t?"["+e+"]":e})).join(r?".":""):t}const W=D.toFlatObject(D,{},null,(function(e){return/^is[A-Z]/.test(e)}));function $(e,t,r){if(!D.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;const n=(r=D.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!D.isUndefined(t[e])}))).metaTokens,s=r.visitor||l,i=r.dots,o=r.indexes,a=(r.Blob||"undefined"!=typeof Blob&&Blob)&&D.isSpecCompliantForm(t);if(!D.isFunction(s))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(D.isDate(e))return e.toISOString();if(D.isBoolean(e))return e.toString();if(!a&&D.isBlob(e))throw new F("Blob is not supported. Use a Buffer instead.");return D.isArrayBuffer(e)||D.isTypedArray(e)?a&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function l(e,r,s){let a=e;if(e&&!s&&"object"==typeof e)if(D.endsWith(r,"{}"))r=n?r:r.slice(0,-2),e=JSON.stringify(e);else if(D.isArray(e)&&function(e){return D.isArray(e)&&!e.some(B)}(e)||(D.isFileList(e)||D.endsWith(r,"[]"))&&(a=D.toArray(e)))return r=H(r),a.forEach((function(e,n){!D.isUndefined(e)&&null!==e&&t.append(!0===o?z([r],n,i):null===o?r:r+"[]",c(e))})),!1;return!!B(e)||(t.append(z(s,r,i),c(e)),!1)}const u=[],d=Object.assign(W,{defaultVisitor:l,convertValue:c,isVisitable:B});if(!D.isObject(e))throw new TypeError("data must be an object");return function e(r,n){if(!D.isUndefined(r)){if(-1!==u.indexOf(r))throw Error("Circular reference detected in "+n.join("."));u.push(r),D.forEach(r,(function(r,i){!0===(!(D.isUndefined(r)||null===r)&&s.call(t,r,D.isString(i)?i.trim():i,n,d))&&e(r,n?n.concat(i):[i])})),u.pop()}}(e),t}function K(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function J(e,t){this._pairs=[],e&&$(e,this,t)}const V=J.prototype;function G(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function X(e,t,r){if(!t)return e;const n=r&&r.encode||G;D.isFunction(r)&&(r={serialize:r});const s=r&&r.serialize;let i;if(i=s?s(t,r):D.isURLSearchParams(t)?t.toString():new J(t,r).toString(n),i){const t=e.indexOf("#");-1!==t&&(e=e.slice(0,t)),e+=(-1===e.indexOf("?")?"?":"&")+i}return e}V.append=function(e,t){this._pairs.push([e,t])},V.toString=function(e){const t=e?function(t){return e.call(this,t,K)}:K;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var Q=class{constructor(){this.handlers=[]}use(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){D.forEach(this.handlers,(function(t){null!==t&&e(t)}))}},Y={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Z={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:J,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]};const ee="undefined"!=typeof window&&"undefined"!=typeof document,te="object"==typeof navigator&&navigator||void 0,re=ee&&(!te||["ReactNative","NativeScript","NS"].indexOf(te.product)<0),ne="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,se=ee&&window.location.href||"http://localhost";var ie={...Object.freeze({__proto__:null,hasBrowserEnv:ee,hasStandardBrowserWebWorkerEnv:ne,hasStandardBrowserEnv:re,navigator:te,origin:se}),...Z};function oe(e){function t(e,r,n,s){let i=e[s++];if("__proto__"===i)return!0;const o=Number.isFinite(+i),a=s>=e.length;if(i=!i&&D.isArray(n)?n.length:i,a)return D.hasOwnProp(n,i)?n[i]=[n[i],r]:n[i]=r,!o;n[i]&&D.isObject(n[i])||(n[i]=[]);return t(e,r,n[i],s)&&D.isArray(n[i])&&(n[i]=function(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}(n[i])),!o}if(D.isFormData(e)&&D.isFunction(e.entries)){const r={};return D.forEachEntry(e,((e,n)=>{t(function(e){return D.matchAll(/\w+|\[(\w*)]/g,e).map((e=>"[]"===e[0]?"":e[1]||e[0]))}(e),n,r,0)})),r}return null}const ae={transitional:Y,adapter:["xhr","http","fetch"],transformRequest:[function(e,t){const r=t.getContentType()||"",n=r.indexOf("application/json")>-1,s=D.isObject(e);s&&D.isHTMLForm(e)&&(e=new FormData(e));if(D.isFormData(e))return n?JSON.stringify(oe(e)):e;if(D.isArrayBuffer(e)||D.isBuffer(e)||D.isStream(e)||D.isFile(e)||D.isBlob(e)||D.isReadableStream(e))return e;if(D.isArrayBufferView(e))return e.buffer;if(D.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let i;if(s){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return $(e,new ie.classes.URLSearchParams,Object.assign({visitor:function(e,t,r,n){return ie.isNode&&D.isBuffer(e)?(this.append(t,e.toString("base64")),!1):n.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((i=D.isFileList(e))||r.indexOf("multipart/form-data")>-1){const t=this.env&&this.env.FormData;return $(i?{"files[]":e}:e,t&&new t,this.formSerializer)}}return s||n?(t.setContentType("application/json",!1),function(e,t,r){if(D.isString(e))try{return(t||JSON.parse)(e),D.trim(e)}catch(en){if("SyntaxError"!==en.name)throw en}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){const t=this.transitional||ae.transitional,r=t&&t.forcedJSONParsing,n="json"===this.responseType;if(D.isResponse(e)||D.isReadableStream(e))return e;if(e&&D.isString(e)&&(r&&!this.responseType||n)){const r=!(t&&t.silentJSONParsing)&&n;try{return JSON.parse(e)}catch(en){if(r){if("SyntaxError"===en.name)throw F.from(en,F.ERR_BAD_RESPONSE,this,null,this.response);throw en}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ie.classes.FormData,Blob:ie.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};D.forEach(["delete","get","head","post","put","patch"],(e=>{ae.headers[e]={}}));var ce=ae;const le=D.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"]);const ue=Symbol("internals");function de(e){return e&&String(e).trim().toLowerCase()}function he(e){return!1===e||null==e?e:D.isArray(e)?e.map(he):String(e)}function pe(e,t,r,n,s){return D.isFunction(n)?n.call(this,t,r):(s&&(t=r),D.isString(t)?D.isString(n)?-1!==t.indexOf(n):D.isRegExp(n)?n.test(t):void 0:void 0)}class fe{constructor(e){e&&this.set(e)}set(e,t,r){const n=this;function s(e,t,r){const s=de(t);if(!s)throw new Error("header name must be a non-empty string");const i=D.findKey(n,s);(!i||void 0===n[i]||!0===r||void 0===r&&!1!==n[i])&&(n[i||t]=he(e))}const i=(e,t)=>D.forEach(e,((e,r)=>s(e,r,t)));if(D.isPlainObject(e)||e instanceof this.constructor)i(e,t);else if(D.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim()))i((e=>{const t={};let r,n,s;return e&&e.split("\n").forEach((function(e){s=e.indexOf(":"),r=e.substring(0,s).trim().toLowerCase(),n=e.substring(s+1).trim(),!r||t[r]&&le[r]||("set-cookie"===r?t[r]?t[r].push(n):t[r]=[n]:t[r]=t[r]?t[r]+", "+n:n)})),t})(e),t);else if(D.isObject(e)&&D.isIterable(e)){let r,n,s={};for(const t of e){if(!D.isArray(t))throw TypeError("Object iterator must return a key-value pair");s[n=t[0]]=(r=s[n])?D.isArray(r)?[...r,t[1]]:[r,t[1]]:t[1]}i(s,t)}else null!=e&&s(t,e,r);return this}get(e,t){if(e=de(e)){const r=D.findKey(this,e);if(r){const e=this[r];if(!t)return e;if(!0===t)return function(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}(e);if(D.isFunction(t))return t.call(this,e,r);if(D.isRegExp(t))return t.exec(e);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,t){if(e=de(e)){const r=D.findKey(this,e);return!(!r||void 0===this[r]||t&&!pe(0,this[r],r,t))}return!1}delete(e,t){const r=this;let n=!1;function s(e){if(e=de(e)){const s=D.findKey(r,e);!s||t&&!pe(0,r[s],s,t)||(delete r[s],n=!0)}}return D.isArray(e)?e.forEach(s):s(e),n}clear(e){const t=Object.keys(this);let r=t.length,n=!1;for(;r--;){const s=t[r];e&&!pe(0,this[s],s,e,!0)||(delete this[s],n=!0)}return n}normalize(e){const t=this,r={};return D.forEach(this,((n,s)=>{const i=D.findKey(r,s);if(i)return t[i]=he(n),void delete t[s];const o=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,((e,t,r)=>t.toUpperCase()+r))}(s):String(s).trim();o!==s&&delete t[s],t[o]=he(n),r[o]=!0})),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const t=Object.create(null);return D.forEach(this,((r,n)=>{null!=r&&!1!==r&&(t[n]=e&&D.isArray(r)?r.join(", "):r)})),t}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map((([e,t])=>e+": "+t)).join("\n")}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...t){const r=new this(e);return t.forEach((e=>r.set(e))),r}static accessor(e){const t=(this[ue]=this[ue]={accessors:{}}).accessors,r=this.prototype;function n(e){const n=de(e);t[n]||(!function(e,t){const r=D.toCamelCase(" "+t);["get","set","has"].forEach((n=>{Object.defineProperty(e,n+r,{value:function(e,r,s){return this[n].call(this,t,e,r,s)},configurable:!0})}))}(r,e),t[n]=!0)}return D.isArray(e)?e.forEach(n):n(e),this}}fe.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),D.reduceDescriptors(fe.prototype,(({value:e},t)=>{let r=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(e){this[r]=e}}})),D.freezeMethods(fe);var ge=fe;function me(e,t){const r=this||ce,n=t||r,s=ge.from(n.headers);let i=n.data;return D.forEach(e,(function(e){i=e.call(r,i,s.normalize(),t?t.status:void 0)})),s.normalize(),i}function _e(e){return!(!e||!e.__CANCEL__)}function we(e,t,r){F.call(this,null==e?"canceled":e,F.ERR_CANCELED,t,r),this.name="CanceledError"}function ye(e,t,r){const n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new F("Request failed with status code "+r.status,[F.ERR_BAD_REQUEST,F.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}D.inherits(we,F,{__CANCEL__:!0});const be=(e,t,r=3)=>{let n=0;const s=function(e,t){e=e||10;const r=new Array(e),n=new Array(e);let s,i=0,o=0;return t=void 0!==t?t:1e3,function(a){const c=Date.now(),l=n[o];s||(s=c),r[i]=a,n[i]=c;let u=o,d=0;for(;u!==i;)d+=r[u++],u%=e;if(i=(i+1)%e,i===o&&(o=(o+1)%e),c-s<t)return;const h=l&&c-l;return h?Math.round(1e3*d/h):void 0}}(50,250);return function(e,t){let r,n,s=0,i=1e3/t;const o=(t,i=Date.now())=>{s=i,r=null,n&&(clearTimeout(n),n=null),e.apply(null,t)};return[(...e)=>{const t=Date.now(),a=t-s;a>=i?o(e,t):(r=e,n||(n=setTimeout((()=>{n=null,o(r)}),i-a)))},()=>r&&o(r)]}((r=>{const i=r.loaded,o=r.lengthComputable?r.total:void 0,a=i-n,c=s(a);n=i;e({loaded:i,total:o,progress:o?i/o:void 0,bytes:a,rate:c||void 0,estimated:c&&o&&i<=o?(o-i)/c:void 0,event:r,lengthComputable:null!=o,[t?"download":"upload"]:!0})}),r)},Se=(e,t)=>{const r=null!=e;return[n=>t[0]({lengthComputable:r,total:e,loaded:n}),t[1]]},ve=e=>(...t)=>D.asap((()=>e(...t)));var Ee=ie.hasStandardBrowserEnv?((e,t)=>r=>(r=new URL(r,ie.origin),e.protocol===r.protocol&&e.host===r.host&&(t||e.port===r.port)))(new URL(ie.origin),ie.navigator&&/(msie|trident)/i.test(ie.navigator.userAgent)):()=>!0,ke=ie.hasStandardBrowserEnv?{write(e,t,r,n,s,i){const o=[e+"="+encodeURIComponent(t)];D.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),D.isString(n)&&o.push("path="+n),D.isString(s)&&o.push("domain="+s),!0===i&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read:()=>null,remove(){}};function Re(e,t,r){let n=!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t);return e&&(n||0==r)?function(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}const Te=e=>e instanceof ge?{...e}:e;function xe(e,t){t=t||{};const r={};function n(e,t,r,n){return D.isPlainObject(e)&&D.isPlainObject(t)?D.merge.call({caseless:n},e,t):D.isPlainObject(t)?D.merge({},t):D.isArray(t)?t.slice():t}function s(e,t,r,s){return D.isUndefined(t)?D.isUndefined(e)?void 0:n(void 0,e,0,s):n(e,t,0,s)}function i(e,t){if(!D.isUndefined(t))return n(void 0,t)}function o(e,t){return D.isUndefined(t)?D.isUndefined(e)?void 0:n(void 0,e):n(void 0,t)}function a(r,s,i){return i in t?n(r,s):i in e?n(void 0,r):void 0}const c={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(e,t,r)=>s(Te(e),Te(t),0,!0)};return D.forEach(Object.keys(Object.assign({},e,t)),(function(n){const i=c[n]||s,o=i(e[n],t[n],n);D.isUndefined(o)&&i!==a||(r[n]=o)})),r}var Oe=e=>{const t=xe({},e);let r,{data:n,withXSRFToken:s,xsrfHeaderName:i,xsrfCookieName:o,headers:a,auth:c}=t;if(t.headers=a=ge.from(a),t.url=X(Re(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),c&&a.set("Authorization","Basic "+btoa((c.username||"")+":"+(c.password?unescape(encodeURIComponent(c.password)):""))),D.isFormData(n))if(ie.hasStandardBrowserEnv||ie.hasStandardBrowserWebWorkerEnv)a.setContentType(void 0);else if(!1!==(r=a.getContentType())){const[e,...t]=r?r.split(";").map((e=>e.trim())).filter(Boolean):[];a.setContentType([e||"multipart/form-data",...t].join("; "))}if(ie.hasStandardBrowserEnv&&(s&&D.isFunction(s)&&(s=s(t)),s||!1!==s&&Ee(t.url))){const e=i&&o&&ke.read(o);e&&a.set(i,e)}return t};var Ae="undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,r){const n=Oe(e);let s=n.data;const i=ge.from(n.headers).normalize();let o,a,c,l,u,{responseType:d,onUploadProgress:h,onDownloadProgress:p}=n;function f(){l&&l(),u&&u(),n.cancelToken&&n.cancelToken.unsubscribe(o),n.signal&&n.signal.removeEventListener("abort",o)}let g=new XMLHttpRequest;function m(){if(!g)return;const n=ge.from("getAllResponseHeaders"in g&&g.getAllResponseHeaders());ye((function(e){t(e),f()}),(function(e){r(e),f()}),{data:d&&"text"!==d&&"json"!==d?g.response:g.responseText,status:g.status,statusText:g.statusText,headers:n,config:e,request:g}),g=null}g.open(n.method.toUpperCase(),n.url,!0),g.timeout=n.timeout,"onloadend"in g?g.onloadend=m:g.onreadystatechange=function(){g&&4===g.readyState&&(0!==g.status||g.responseURL&&0===g.responseURL.indexOf("file:"))&&setTimeout(m)},g.onabort=function(){g&&(r(new F("Request aborted",F.ECONNABORTED,e,g)),g=null)},g.onerror=function(){r(new F("Network Error",F.ERR_NETWORK,e,g)),g=null},g.ontimeout=function(){let t=n.timeout?"timeout of "+n.timeout+"ms exceeded":"timeout exceeded";const s=n.transitional||Y;n.timeoutErrorMessage&&(t=n.timeoutErrorMessage),r(new F(t,s.clarifyTimeoutError?F.ETIMEDOUT:F.ECONNABORTED,e,g)),g=null},void 0===s&&i.setContentType(null),"setRequestHeader"in g&&D.forEach(i.toJSON(),(function(e,t){g.setRequestHeader(t,e)})),D.isUndefined(n.withCredentials)||(g.withCredentials=!!n.withCredentials),d&&"json"!==d&&(g.responseType=n.responseType),p&&([c,u]=be(p,!0),g.addEventListener("progress",c)),h&&g.upload&&([a,l]=be(h),g.upload.addEventListener("progress",a),g.upload.addEventListener("loadend",l)),(n.cancelToken||n.signal)&&(o=t=>{g&&(r(!t||t.type?new we(null,e,g):t),g.abort(),g=null)},n.cancelToken&&n.cancelToken.subscribe(o),n.signal&&(n.signal.aborted?o():n.signal.addEventListener("abort",o)));const _=function(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}(n.url);_&&-1===ie.protocols.indexOf(_)?r(new F("Unsupported protocol "+_+":",F.ERR_BAD_REQUEST,e)):g.send(s||null)}))};var Ce=(e,t)=>{const{length:r}=e=e?e.filter(Boolean):[];if(t||r){let r,n=new AbortController;const s=function(e){if(!r){r=!0,o();const t=e instanceof Error?e:this.reason;n.abort(t instanceof F?t:new we(t instanceof Error?t.message:t))}};let i=t&&setTimeout((()=>{i=null,s(new F(`timeout ${t} of ms exceeded`,F.ETIMEDOUT))}),t);const o=()=>{e&&(i&&clearTimeout(i),i=null,e.forEach((e=>{e.unsubscribe?e.unsubscribe(s):e.removeEventListener("abort",s)})),e=null)};e.forEach((e=>e.addEventListener("abort",s)));const{signal:a}=n;return a.unsubscribe=()=>D.asap(o),a}};const Ne=function*(e,t){let r=e.byteLength;if(r<t)return void(yield e);let n,s=0;for(;s<r;)n=s+t,yield e.slice(s,n),s=n},Pe=async function*(e){if(e[Symbol.asyncIterator])return void(yield*e);const t=e.getReader();try{for(;;){const{done:e,value:r}=await t.read();if(e)break;yield r}}finally{await t.cancel()}},Ie=(e,t,r,n)=>{const s=async function*(e,t){for await(const r of Pe(e))yield*Ne(r,t)}(e,t);let i,o=0,a=e=>{i||(i=!0,n&&n(e))};return new ReadableStream({async pull(e){try{const{done:t,value:n}=await s.next();if(t)return a(),void e.close();let i=n.byteLength;if(r){let e=o+=i;r(e)}e.enqueue(new Uint8Array(n))}catch(t){throw a(t),t}},cancel:e=>(a(e),s.return())},{highWaterMark:2})},Ue="function"==typeof fetch&&"function"==typeof Request&&"function"==typeof Response,je=Ue&&"function"==typeof ReadableStream,Le=Ue&&("function"==typeof TextEncoder?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),De=(e,...t)=>{try{return!!e(...t)}catch(en){return!1}},Fe=je&&De((()=>{let e=!1;const t=new Request(ie.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t})),Me=je&&De((()=>D.isReadableStream(new Response("").body))),qe={stream:Me&&(e=>e.body)};Ue&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach((t=>{!qe[t]&&(qe[t]=D.isFunction(e[t])?e=>e[t]():(e,r)=>{throw new F(`Response type '${t}' is not supported`,F.ERR_NOT_SUPPORT,r)})}))})(new Response);const Be=async(e,t)=>{const r=D.toFiniteNumber(e.getContentLength());return null==r?(async e=>{if(null==e)return 0;if(D.isBlob(e))return e.size;if(D.isSpecCompliantForm(e)){const t=new Request(ie.origin,{method:"POST",body:e});return(await t.arrayBuffer()).byteLength}return D.isArrayBufferView(e)||D.isArrayBuffer(e)?e.byteLength:(D.isURLSearchParams(e)&&(e+=""),D.isString(e)?(await Le(e)).byteLength:void 0)})(t):r};const He={http:null,xhr:Ae,fetch:Ue&&(async e=>{let{url:t,method:r,data:n,signal:s,cancelToken:i,timeout:o,onDownloadProgress:a,onUploadProgress:c,responseType:l,headers:u,withCredentials:d="same-origin",fetchOptions:h}=Oe(e);l=l?(l+"").toLowerCase():"text";let p,f=Ce([s,i&&i.toAbortSignal()],o);const g=f&&f.unsubscribe&&(()=>{f.unsubscribe()});let m;try{if(c&&Fe&&"get"!==r&&"head"!==r&&0!==(m=await Be(u,n))){let e,r=new Request(t,{method:"POST",body:n,duplex:"half"});if(D.isFormData(n)&&(e=r.headers.get("content-type"))&&u.setContentType(e),r.body){const[e,t]=Se(m,be(ve(c)));n=Ie(r.body,65536,e,t)}}D.isString(d)||(d=d?"include":"omit");const s="credentials"in Request.prototype;p=new Request(t,{...h,signal:f,method:r.toUpperCase(),headers:u.normalize().toJSON(),body:n,duplex:"half",credentials:s?d:void 0});let i=await fetch(p,h);const o=Me&&("stream"===l||"response"===l);if(Me&&(a||o&&g)){const e={};["status","statusText","headers"].forEach((t=>{e[t]=i[t]}));const t=D.toFiniteNumber(i.headers.get("content-length")),[r,n]=a&&Se(t,be(ve(a),!0))||[];i=new Response(Ie(i.body,65536,r,(()=>{n&&n(),g&&g()})),e)}l=l||"text";let _=await qe[D.findKey(qe,l)||"text"](i,e);return!o&&g&&g(),await new Promise(((t,r)=>{ye(t,r,{data:_,headers:ge.from(i.headers),status:i.status,statusText:i.statusText,config:e,request:p})}))}catch(_){if(g&&g(),_&&"TypeError"===_.name&&/Load failed|fetch/i.test(_.message))throw Object.assign(new F("Network Error",F.ERR_NETWORK,e,p),{cause:_.cause||_});throw F.from(_,_&&_.code,e,p)}})};D.forEach(He,((e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch(en){}Object.defineProperty(e,"adapterName",{value:t})}}));const ze=e=>`- ${e}`,We=e=>D.isFunction(e)||null===e||!1===e;var $e=e=>{e=D.isArray(e)?e:[e];const{length:t}=e;let r,n;const s={};for(let i=0;i<t;i++){let t;if(r=e[i],n=r,!We(r)&&(n=He[(t=String(r)).toLowerCase()],void 0===n))throw new F(`Unknown adapter '${t}'`);if(n)break;s[t||"#"+i]=n}if(!n){const e=Object.entries(s).map((([e,t])=>`adapter ${e} `+(!1===t?"is not supported by the environment":"is not available in the build")));throw new F("There is no suitable adapter to dispatch the request "+(t?e.length>1?"since :\n"+e.map(ze).join("\n"):" "+ze(e[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function Ke(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new we(null,e)}function Je(e){Ke(e),e.headers=ge.from(e.headers),e.data=me.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1);return $e(e.adapter||ce.adapter)(e).then((function(t){return Ke(e),t.data=me.call(e,e.transformResponse,t),t.headers=ge.from(t.headers),t}),(function(t){return _e(t)||(Ke(e),t&&t.response&&(t.response.data=me.call(e,e.transformResponse,t.response),t.response.headers=ge.from(t.response.headers))),Promise.reject(t)}))}const Ve="1.10.0",Ge={};["object","boolean","number","function","string","symbol"].forEach(((e,t)=>{Ge[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));const Xe={};Ge.transitional=function(e,t,r){function n(e,t){return"[Axios v"+Ve+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return(r,s,i)=>{if(!1===e)throw new F(n(s," has been removed"+(t?" in "+t:"")),F.ERR_DEPRECATED);return t&&!Xe[s]&&(Xe[s]=!0,console.warn(n(s," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,s,i)}},Ge.spelling=function(e){return(t,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};var Qe={assertOptions:function(e,t,r){if("object"!=typeof e)throw new F("options must be an object",F.ERR_BAD_OPTION_VALUE);const n=Object.keys(e);let s=n.length;for(;s-- >0;){const i=n[s],o=t[i];if(o){const t=e[i],r=void 0===t||o(t,i,e);if(!0!==r)throw new F("option "+i+" must be "+r,F.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new F("Unknown option "+i,F.ERR_BAD_OPTION)}},validators:Ge};const Ye=Qe.validators;class Ze{constructor(e){this.defaults=e||{},this.interceptors={request:new Q,response:new Q}}async request(e,t){try{return await this._request(e,t)}catch(r){if(r instanceof Error){let e={};Error.captureStackTrace?Error.captureStackTrace(e):e=new Error;const t=e.stack?e.stack.replace(/^.+\n/,""):"";try{r.stack?t&&!String(r.stack).endsWith(t.replace(/^.+\n.+\n/,""))&&(r.stack+="\n"+t):r.stack=t}catch(en){}}throw r}}_request(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},t=xe(this.defaults,t);const{transitional:r,paramsSerializer:n,headers:s}=t;void 0!==r&&Qe.assertOptions(r,{silentJSONParsing:Ye.transitional(Ye.boolean),forcedJSONParsing:Ye.transitional(Ye.boolean),clarifyTimeoutError:Ye.transitional(Ye.boolean)},!1),null!=n&&(D.isFunction(n)?t.paramsSerializer={serialize:n}:Qe.assertOptions(n,{encode:Ye.function,serialize:Ye.function},!0)),void 0!==t.allowAbsoluteUrls||(void 0!==this.defaults.allowAbsoluteUrls?t.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:t.allowAbsoluteUrls=!0),Qe.assertOptions(t,{baseUrl:Ye.spelling("baseURL"),withXsrfToken:Ye.spelling("withXSRFToken")},!0),t.method=(t.method||this.defaults.method||"get").toLowerCase();let i=s&&D.merge(s.common,s[t.method]);s&&D.forEach(["delete","get","head","post","put","patch","common"],(e=>{delete s[e]})),t.headers=ge.concat(i,s);const o=[];let a=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(a=a&&e.synchronous,o.unshift(e.fulfilled,e.rejected))}));const c=[];let l;this.interceptors.response.forEach((function(e){c.push(e.fulfilled,e.rejected)}));let u,d=0;if(!a){const e=[Je.bind(this),void 0];for(e.unshift.apply(e,o),e.push.apply(e,c),u=e.length,l=Promise.resolve(t);d<u;)l=l.then(e[d++],e[d++]);return l}u=o.length;let h=t;for(d=0;d<u;){const e=o[d++],t=o[d++];try{h=e(h)}catch(p){t.call(this,p);break}}try{l=Je.call(this,h)}catch(p){return Promise.reject(p)}for(d=0,u=c.length;d<u;)l=l.then(c[d++],c[d++]);return l}getUri(e){return X(Re((e=xe(this.defaults,e)).baseURL,e.url,e.allowAbsoluteUrls),e.params,e.paramsSerializer)}}D.forEach(["delete","get","head","options"],(function(e){Ze.prototype[e]=function(t,r){return this.request(xe(r||{},{method:e,url:t,data:(r||{}).data}))}})),D.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,s){return this.request(xe(s||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}Ze.prototype[e]=t(),Ze.prototype[e+"Form"]=t(!0)}));var et=Ze;class tt{constructor(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");let t;this.promise=new Promise((function(e){t=e}));const r=this;this.promise.then((e=>{if(!r._listeners)return;let t=r._listeners.length;for(;t-- >0;)r._listeners[t](e);r._listeners=null})),this.promise.then=e=>{let t;const n=new Promise((e=>{r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e,n,s){r.reason||(r.reason=new we(e,n,s),t(r.reason))}))}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}toAbortSignal(){const e=new AbortController,t=t=>{e.abort(t)};return this.subscribe(t),e.signal.unsubscribe=()=>this.unsubscribe(t),e.signal}static source(){let e;return{token:new tt((function(t){e=t})),cancel:e}}}var rt=tt;const nt={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(nt).forEach((([e,t])=>{nt[t]=e}));var st=nt;const it=function t(r){const n=new et(r),s=e(et.prototype.request,n);return D.extend(s,et.prototype,n,{allOwnKeys:!0}),D.extend(s,n,null,{allOwnKeys:!0}),s.create=function(e){return t(xe(r,e))},s}(ce);return it.Axios=et,it.CanceledError=we,it.CancelToken=rt,it.isCancel=_e,it.VERSION=Ve,it.toFormData=$,it.AxiosError=F,it.Cancel=it.CanceledError,it.all=function(e){return Promise.all(e)},it.spread=function(e){return function(t){return e.apply(null,t)}},it.isAxiosError=function(e){return D.isObject(e)&&!0===e.isAxiosError},it.mergeConfig=xe,it.AxiosHeaders=ge,it.formToJSON=e=>oe(D.isHTMLForm(e)?new FormData(e):e),it.getAdapter=$e,it.HttpStatusCode=st,it.default=it,Gr=it}var Zr,en;const tn=Vr(Zr?Qr.exports:(Zr=1,Qr.exports=(en=Yr(),function(){var e={593:function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.resendFailedRequest=t.getRetryInstance=t.unsetCache=t.createRequestQueueInterceptor=t.createRefreshCall=t.shouldInterceptError=t.mergeOptions=t.defaultOptions=void 0;const n=r(300);t.defaultOptions={statusCodes:[401],pauseInstanceWhileRefreshing:!1},t.mergeOptions=function(e,t){return Object.assign(Object.assign(Object.assign({},e),{pauseInstanceWhileRefreshing:t.skipWhileRefreshing}),t)},t.shouldInterceptError=function(e,t,r,n){var s,i;return!(!e||(null===(s=e.config)||void 0===s?void 0:s.skipAuthRefresh)||!(t.interceptNetworkError&&!e.response&&0===e.request.status||e.response&&((null==t?void 0:t.shouldRefresh)?t.shouldRefresh(e):null===(i=t.statusCodes)||void 0===i?void 0:i.includes(parseInt(e.response.status))))||(e.response||(e.response={config:e.config}),t.pauseInstanceWhileRefreshing&&n.skipInstances.includes(r)))},t.createRefreshCall=function(e,t,r){return r.refreshCall||(r.refreshCall=t(e),"function"==typeof r.refreshCall.then)?r.refreshCall:(console.warn("axios-auth-refresh requires `refreshTokenCall` to return a promise."),Promise.reject())},t.createRequestQueueInterceptor=function(e,t,r){return void 0===t.requestQueueInterceptorId&&(t.requestQueueInterceptorId=e.interceptors.request.use((e=>t.refreshCall.catch((()=>{throw new n.default.Cancel("Request call failed")})).then((()=>r.onRetry?r.onRetry(e):e))))),t.requestQueueInterceptorId},t.unsetCache=function(e,t){e.interceptors.request.eject(t.requestQueueInterceptorId),t.requestQueueInterceptorId=void 0,t.refreshCall=void 0,t.skipInstances=t.skipInstances.filter((t=>t!==e))},t.getRetryInstance=function(e,t){return t.retryInstance||e},t.resendFailedRequest=function(e,t){return e.config.skipAuthRefresh=!0,t(e.response.config)}},300:function(e){e.exports=en}},t={};function r(n){var s=t[n];if(void 0!==s)return s.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}var n={};return function(){var e=n;Object.defineProperty(e,"__esModule",{value:!0});const t=r(593);e.default=function(e,r,n={}){if("function"!=typeof r)throw new Error("axios-auth-refresh requires `refreshAuthCall` to be a function that returns a promise.");const s={skipInstances:[],refreshCall:void 0,requestQueueInterceptorId:void 0};return e.interceptors.response.use((e=>e),(i=>{if(n=(0,t.mergeOptions)(t.defaultOptions,n),!(0,t.shouldInterceptError)(i,n,e,s))return Promise.reject(i);n.pauseInstanceWhileRefreshing&&s.skipInstances.push(e);const o=(0,t.createRefreshCall)(i,r,s);return(0,t.createRequestQueueInterceptor)(e,s,n),o.catch((e=>Promise.reject(e))).then((()=>(0,t.resendFailedRequest)(i,(0,t.getRetryInstance)(e,n)))).finally((()=>(0,t.unsetCache)(e,s)))}))}}(),n}())));var rn=class{constructor(e){this.apiKey=e}async getAccessToken(){return this.apiKey}async refreshToken(){return Promise.resolve()}},nn=class{constructor(e){r(this,"getTokenFn"),r(this,"refreshTokenFn"),r(this,"onRefreshErrorFn"),this.getTokenFn=e.getTokenFn,this.refreshTokenFn=e.refreshTokenFn,this.onRefreshErrorFn=e.onRefreshErrorFn}async getAccessToken(){return this.getTokenFn()}async refreshToken(){return this.refreshTokenFn()}onRefreshError(e){this.onRefreshErrorFn&&this.onRefreshErrorFn(e)}},sn={baseUrl:"undefined"!=typeof process&&(null==(e=process.env)?void 0:e.ECHO_BASE_URL)||"https://echo.merit.systems"};var on=class e extends Error{constructor(t,n,s){super(n),r(this,"code"),r(this,"details"),r(this,"statusCode"),r(this,"endpoint"),r(this,"originalError"),this.name="EchoError",this.code=t,void 0!==(null==s?void 0:s.details)&&(this.details=s.details),void 0!==(null==s?void 0:s.statusCode)&&(this.statusCode=s.statusCode),void 0!==(null==s?void 0:s.endpoint)&&(this.endpoint=s.endpoint),void 0!==(null==s?void 0:s.originalError)&&(this.originalError=s.originalError),Error.captureStackTrace&&Error.captureStackTrace(this,e)}},an=class extends on{constructor(e,t,r,n,s){const i={};void 0!==n&&(i.details=n),void 0!==r&&(i.statusCode=r),void 0!==s&&(i.endpoint=s),super(e,t,i),this.name="EchoApiError"}},cn=class extends on{constructor(e,t,r){const n={originalError:t};void 0!==r&&(n.endpoint=r),super("NETWORK_ERROR",e,n),this.name="EchoNetworkError"}},ln=class extends on{constructor(e,t,n){const s={};void 0!==n&&(s.endpoint=n),super("TIMEOUT_ERROR",e,s),r(this,"timeout"),this.name="EchoTimeoutError",this.timeout=t}},un="UNAUTHORIZED",dn="TOKEN_EXPIRED",hn="INVALID_TOKEN",pn="BAD_REQUEST",fn="NOT_FOUND",gn="RATE_LIMITED",mn="INSUFFICIENT_BALANCE",_n="VALIDATION_ERROR",wn="NETWORK_ERROR",yn="TIMEOUT_ERROR",bn="SERVER_ERROR",Sn="SERVICE_UNAVAILABLE";function vn(e,t,r){if(e&&"object"==typeof e&&"isAxiosError"in e){const n=e;if("ECONNABORTED"===n.code)return new ln("Request timeout"+(t?` while ${t}`:""),3e4,r);if(!n.response)return new cn("Network error"+(t?` while ${t}`:""),n,r);const s=n.response.status,i=n.response.data;let o,a;const c=(null==i?void 0:i.error)||(null==i?void 0:i.message);switch(s){case 401:o=un,a=c||"Authentication required. Please sign in again.";break;case 403:o=hn,a=c||"Access denied. Your session may have expired.";break;case 404:o=fn,a=c||"Resource not found";break;case 429:o=gn,a=c||"Too many requests. Please try again later.";break;case 400:o=pn,a=c||"Invalid request";break;case 402:o=mn,a=c||"Insufficient balance. Please add credits to continue.";break;case 422:o=_n,a=c||"Validation failed";break;case 503:o=Sn,a=c||"Service temporarily unavailable. Please try again.";break;default:o=bn,a=c||"An unexpected error occurred"}return new an(o,t?`Failed to ${t}: ${a}`:a,s,(null==i?void 0:i.details)||(null==i?void 0:i.error_description),r)}return e instanceof Error?new cn(e.message||"Unknown error"+(t?` while ${t}`:""),e,r):"string"==typeof e?new an(bn,e,void 0,void 0,r):new an(bn,"Unknown error"+(t?` while ${t}`:""),void 0,String(e),r)}function En(e){switch(e.code){case un:case dn:case hn:return"Please sign in to continue";case mn:return"Insufficient balance. Please add credits to your account.";case gn:return"Too many requests. Please wait a moment and try again.";case wn:return"Connection failed. Please check your internet connection.";case yn:return"Request timed out. Please try again.";case Sn:return"Service is temporarily unavailable. Please try again later.";case fn:return e.message||"The requested resource was not found.";case _n:return e.message||"Please check your input and try again.";default:return e.message||"An unexpected error occurred. Please try again."}}var kn=class{constructor(e){this.http=e}async handleRequest(e,t,r){try{return(await e()).data}catch(n){throw vn(n,t,r)}}handleError(e,t,r){throw vn(e,t,r)}},Rn=class extends kn{constructor(e,t){super(e),this.baseUrl=t}async listEchoApps(){return(await this.handleRequest((()=>this.http.get("/api/v1/apps")),"listing Echo apps","/api/v1/apps")).apps}async getEchoApp(e){return this.handleRequest((()=>this.http.get(`/api/v1/apps/${e}`)),"fetching Echo app",`/api/v1/apps/${e}`)}getAppUrl(e){return`${this.baseUrl}/apps/${e}`}},Tn=class extends kn{constructor(e){super(e)}async getBalance(){return this.handleRequest((()=>this.http.get("/api/v1/balance")),"fetching balance","/api/v1/balance")}async getFreeBalance(e){const t={echoAppId:e};return this.handleRequest((()=>this.http.post("/api/v1/balance/free",t)),"fetching free tier balance","/api/v1/balance/free")}},xn=class extends kn{constructor(e){super(e)}async getSupportedModels(){return this.handleRequest((()=>this.http.get("/api/v1/supported-models")),"fetching supported models","/api/v1/supported-models")}async listSupportedModels(){try{return(await this.getSupportedModels()).models}catch(e){throw this.handleError(e,"listing supported models")}}async getSupportedModelsByProvider(){try{return(await this.getSupportedModels()).models_by_provider}catch(e){throw this.handleError(e,"getting models by provider")}}},On=class extends kn{constructor(e){super(e)}async createPaymentLink(e){return this.handleRequest((()=>this.http.post("/api/v1/stripe/payment-link",e)),"creating payment link","/api/v1/stripe/payment-link")}async getPaymentUrl(e,t,r){const n={amount:e,description:t||"Echo Credits"};r&&(n.successUrl=r);try{return(await this.createPaymentLink(n)).paymentLink.url}catch(s){throw this.handleError(s,"getting payment URL")}}},An=class extends kn{constructor(e){super(e)}async getUserInfo(){return this.handleRequest((()=>this.http.get("/api/v1/user")),"fetching user info","/api/v1/user")}async registerReferralCode(e,t){const r={echoAppId:e,code:t};return this.handleRequest((()=>this.http.post("/api/v1/user/referral",r)),"registering referral code","/api/v1/user/referral")}},Cn=class{constructor(e){var t;if(r(this,"http"),r(this,"config"),r(this,"tokenProvider"),r(this,"balance"),r(this,"payments"),r(this,"apps"),r(this,"users"),r(this,"models"),this.config=(t=e,{...sn,...t}),null==e?void 0:e.tokenProvider)this.tokenProvider=e.tokenProvider;else{const e=this.config.apiKey||process.env.ECHO_API_KEY;if(!e)throw new Error("No API key or token provider provided");this.tokenProvider=new rn(e)}this.http=Cr.create({baseURL:this.config.baseUrl,timeout:3e4}),this.http.interceptors.request.use((async e=>{const t=await this.tokenProvider.getAccessToken();return t&&(e.headers.Authorization=`Bearer ${t}`),e}));tn(this.http,(async e=>{try{await this.tokenProvider.refreshToken();const t=await this.tokenProvider.getAccessToken();return t&&(e.response.config.headers.Authorization=`Bearer ${t}`),Promise.resolve()}catch(t){return this.tokenProvider.onRefreshError&&this.tokenProvider.onRefreshError(t),Promise.reject(t)}}),{statusCodes:[401],pauseInstanceWhileRefreshing:!0}),this.balance=new Tn(this.http),this.payments=new On(this.http),this.apps=new Rn(this.http,this.config.baseUrl),this.users=new An(this.http),this.models=new xn(this.http)}};function Nn({apiUrl:e}){var t;const r=Re(),[n,i]=s.useState(null);return s.useEffect((()=>{var t;if(!(null==(t=r.user)?void 0:t.access_token))return void i(null);const n=new nn({getTokenFn:()=>{var e;return Promise.resolve((null==(e=r.user)?void 0:e.access_token)||null)},refreshTokenFn:async()=>{await r.signinSilent()},onRefreshErrorFn:e=>{console.error("Token refresh failed:",e),r.signoutSilent()}}),s=new Cn({baseUrl:e,tokenProvider:n});return i(s),()=>{i(null)}}),[e,null==(t=r.user)?void 0:t.access_token,r.signinSilent,r.signoutSilent]),n}const Pn=s.createContext(null);function In({config:e,children:t}){var r,i,o;const a=Re(),c=a.user,l=c?function(e){return{id:e.profile.sub||"",email:e.profile.email||"",name:e.profile.name||e.profile.preferred_username||"",picture:e.profile.picture||""}}(c):null,u=e.apiUrl||"https://echo.merit.systems",d=(null==(r=a.user)?void 0:r.access_token)||null,h=Nn({apiUrl:u}),{balance:p,freeTierBalance:f,refreshBalance:g,error:m,isLoading:_}=function(e,t){const[r,n]=s.useState(null),[i,o]=s.useState(null),[a,c]=s.useState(null),[l,u]=s.useState(!1),d=s.useCallback((async()=>{if(!e)throw new Error("Not authenticated");u(!0);try{const[r,s]=await Promise.all([e.balance.getBalance(),e.balance.getFreeBalance(t)]);n(r),o(s),c(null)}catch(r){const e=vn(r,"refreshing balance"),t=En(e);throw c(t),e}finally{u(!1)}}),[e,t]);return s.useEffect((()=>{e&&t?d().catch((e=>{console.error("Error loading initial balance:",e)})):(n(null),o(null),c(null))}),[e,t,d]),{balance:r,freeTierBalance:i,error:a,isLoading:l,refreshBalance:d}}(h,e.appId),{createPaymentLink:w,error:y,isLoading:b}=function(e){const[t,r]=s.useState(null),[n,i]=s.useState(!1);return{createPaymentLink:s.useCallback((async(t,n,s)=>{if(!e)throw new Error("Not authenticated");i(!0);try{const i=await e.payments.createPaymentLink({amount:t,description:n||"Echo Credits",successUrl:s||window.location.origin});return r(null),i.paymentLink.url}catch(o){const e=vn(o,"creating payment link"),t=En(e);throw r(t),e}finally{i(!1)}}),[e]),error:t,isLoading:n}}(h),S=s.useCallback((async()=>{try{await a.removeUser()}catch(e){console.error("Error during auth cleanup:",e)}}),[a.removeUser]),v=s.useCallback((async()=>{var e;return(null==(e=a.user)?void 0:e.access_token)||null}),[null==(i=a.user)?void 0:i.access_token]),E=(null==(o=a.error)?void 0:o.message)||m||y||null,k=a.isLoading||_||b,R={user:l||null,rawUser:c,balance:p,freeTierBalance:f,isAuthenticated:a.isAuthenticated,isLoading:k,error:E,token:d,echoClient:h,signIn:a.signinRedirect,signOut:S,refreshBalance:g,createPaymentLink:w,getToken:v,clearAuth:S};return n.jsx(Pn.Provider,{value:R,children:t})}function Un(){const e=s.useContext(Pn);if(!e)throw new Error("useEcho must be used within an EchoProvider");return e}
|
|
3
|
-
/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:jn,setPrototypeOf:Ln,isFrozen:Dn,getPrototypeOf:Fn,getOwnPropertyDescriptor:Mn}=Object;let{freeze:qn,seal:Bn,create:Hn}=Object,{apply:zn,construct:Wn}="undefined"!=typeof Reflect&&Reflect;qn||(qn=function(e){return e}),Bn||(Bn=function(e){return e}),zn||(zn=function(e,t,r){return e.apply(t,r)}),Wn||(Wn=function(e,t){return new e(...t)});const $n=os(Array.prototype.forEach),Kn=os(Array.prototype.lastIndexOf),Jn=os(Array.prototype.pop),Vn=os(Array.prototype.push),Gn=os(Array.prototype.splice),Xn=os(String.prototype.toLowerCase),Qn=os(String.prototype.toString),Yn=os(String.prototype.match),Zn=os(String.prototype.replace),es=os(String.prototype.indexOf),ts=os(String.prototype.trim),rs=os(Object.prototype.hasOwnProperty),ns=os(RegExp.prototype.test),ss=(is=TypeError,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wn(is,t)});var is;function os(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,n=new Array(r>1?r-1:0),s=1;s<r;s++)n[s-1]=arguments[s];return zn(e,t,n)}}function as(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Xn;Ln&&Ln(e,null);let n=t.length;for(;n--;){let s=t[n];if("string"==typeof s){const e=r(s);e!==s&&(Dn(t)||(t[n]=e),s=e)}e[s]=!0}return e}function cs(e){for(let t=0;t<e.length;t++){rs(e,t)||(e[t]=null)}return e}function ls(e){const t=Hn(null);for(const[r,n]of jn(e)){rs(e,r)&&(Array.isArray(n)?t[r]=cs(n):n&&"object"==typeof n&&n.constructor===Object?t[r]=ls(n):t[r]=n)}return t}function us(e,t){for(;null!==e;){const r=Mn(e,t);if(r){if(r.get)return os(r.get);if("function"==typeof r.value)return os(r.value)}e=Fn(e)}return function(){return null}}const ds=qn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),hs=qn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ps=qn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),fs=qn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),gs=qn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ms=qn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),_s=qn(["#text"]),ws=qn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ys=qn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),bs=qn(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ss=qn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),vs=Bn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Es=Bn(/<%[\w\W]*|[\w\W]*%>/gm),ks=Bn(/\$\{[\w\W]*/gm),Rs=Bn(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ts=Bn(/^aria-[\-\w]+$/),xs=Bn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Os=Bn(/^(?:\w+script|data):/i),As=Bn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cs=Bn(/^html$/i),Ns=Bn(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ps=Object.freeze({__proto__:null,ARIA_ATTR:Ts,ATTR_WHITESPACE:As,CUSTOM_ELEMENT:Ns,DATA_ATTR:Rs,DOCTYPE_NAME:Cs,ERB_EXPR:Es,IS_ALLOWED_URI:xs,IS_SCRIPT_OR_DATA:Os,MUSTACHE_EXPR:vs,TMPLIT_EXPR:ks});const Is=1,Us=3,js=7,Ls=8,Ds=9;var Fs=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const r=t=>e(t);if(r.version="3.2.6",r.removed=[],!t||!t.document||t.document.nodeType!==Ds||!t.Element)return r.isSupported=!1,r;let{document:n}=t;const s=n,i=s.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:c,Element:l,NodeFilter:u,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:h,DOMParser:p,trustedTypes:f}=t,g=l.prototype,m=us(g,"cloneNode"),_=us(g,"remove"),w=us(g,"nextSibling"),y=us(g,"childNodes"),b=us(g,"parentNode");if("function"==typeof a){const e=n.createElement("template");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let S,v="";const{implementation:E,createNodeIterator:k,createDocumentFragment:R,getElementsByTagName:T}=n,{importNode:x}=s;let O={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};r.isSupported="function"==typeof jn&&"function"==typeof b&&E&&void 0!==E.createHTMLDocument;const{MUSTACHE_EXPR:A,ERB_EXPR:C,TMPLIT_EXPR:N,DATA_ATTR:P,ARIA_ATTR:I,IS_SCRIPT_OR_DATA:U,ATTR_WHITESPACE:j,CUSTOM_ELEMENT:L}=Ps;let{IS_ALLOWED_URI:D}=Ps,F=null;const M=as({},[...ds,...hs,...ps,...gs,..._s]);let q=null;const B=as({},[...ws,...ys,...bs,...Ss]);let H=Object.seal(Hn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),z=null,W=null,$=!0,K=!0,J=!1,V=!0,G=!1,X=!0,Q=!1,Y=!1,Z=!1,ee=!1,te=!1,re=!1,ne=!0,se=!1,ie=!0,oe=!1,ae={},ce=null;const le=as({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ue=null;const de=as({},["audio","video","img","source","image","track"]);let he=null;const pe=as({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),fe="http://www.w3.org/1998/Math/MathML",ge="http://www.w3.org/2000/svg",me="http://www.w3.org/1999/xhtml";let _e=me,we=!1,ye=null;const be=as({},[fe,ge,me],Qn);let Se=as({},["mi","mo","mn","ms","mtext"]),ve=as({},["annotation-xml"]);const Ee=as({},["title","style","font","a","script"]);let ke=null;const Re=["application/xhtml+xml","text/html"];let Te=null,xe=null;const Oe=n.createElement("form"),Ae=function(e){return e instanceof RegExp||e instanceof Function},Ce=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!xe||xe!==e){if(e&&"object"==typeof e||(e={}),e=ls(e),ke=-1===Re.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Te="application/xhtml+xml"===ke?Qn:Xn,F=rs(e,"ALLOWED_TAGS")?as({},e.ALLOWED_TAGS,Te):M,q=rs(e,"ALLOWED_ATTR")?as({},e.ALLOWED_ATTR,Te):B,ye=rs(e,"ALLOWED_NAMESPACES")?as({},e.ALLOWED_NAMESPACES,Qn):be,he=rs(e,"ADD_URI_SAFE_ATTR")?as(ls(pe),e.ADD_URI_SAFE_ATTR,Te):pe,ue=rs(e,"ADD_DATA_URI_TAGS")?as(ls(de),e.ADD_DATA_URI_TAGS,Te):de,ce=rs(e,"FORBID_CONTENTS")?as({},e.FORBID_CONTENTS,Te):le,z=rs(e,"FORBID_TAGS")?as({},e.FORBID_TAGS,Te):ls({}),W=rs(e,"FORBID_ATTR")?as({},e.FORBID_ATTR,Te):ls({}),ae=!!rs(e,"USE_PROFILES")&&e.USE_PROFILES,$=!1!==e.ALLOW_ARIA_ATTR,K=!1!==e.ALLOW_DATA_ATTR,J=e.ALLOW_UNKNOWN_PROTOCOLS||!1,V=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,G=e.SAFE_FOR_TEMPLATES||!1,X=!1!==e.SAFE_FOR_XML,Q=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,re=e.RETURN_TRUSTED_TYPE||!1,Z=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,se=e.SANITIZE_NAMED_PROPS||!1,ie=!1!==e.KEEP_CONTENT,oe=e.IN_PLACE||!1,D=e.ALLOWED_URI_REGEXP||xs,_e=e.NAMESPACE||me,Se=e.MATHML_TEXT_INTEGRATION_POINTS||Se,ve=e.HTML_INTEGRATION_POINTS||ve,H=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Ae(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(H.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Ae(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(H.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(H.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),G&&(K=!1),te&&(ee=!0),ae&&(F=as({},_s),q=[],!0===ae.html&&(as(F,ds),as(q,ws)),!0===ae.svg&&(as(F,hs),as(q,ys),as(q,Ss)),!0===ae.svgFilters&&(as(F,ps),as(q,ys),as(q,Ss)),!0===ae.mathMl&&(as(F,gs),as(q,bs),as(q,Ss))),e.ADD_TAGS&&(F===M&&(F=ls(F)),as(F,e.ADD_TAGS,Te)),e.ADD_ATTR&&(q===B&&(q=ls(q)),as(q,e.ADD_ATTR,Te)),e.ADD_URI_SAFE_ATTR&&as(he,e.ADD_URI_SAFE_ATTR,Te),e.FORBID_CONTENTS&&(ce===le&&(ce=ls(ce)),as(ce,e.FORBID_CONTENTS,Te)),ie&&(F["#text"]=!0),Q&&as(F,["html","head","body"]),F.table&&(as(F,["tbody"]),delete z.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ss('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ss('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=e.TRUSTED_TYPES_POLICY,v=S.createHTML("")}else void 0===S&&(S=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let r=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(r=t.getAttribute(n));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(i){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(f,i)),null!==S&&"string"==typeof v&&(v=S.createHTML(""));qn&&qn(e),xe=e}},Ne=as({},[...hs,...ps,...fs]),Pe=as({},[...gs,...ms]),Ie=function(e){Vn(r.removed,{element:e});try{b(e).removeChild(e)}catch(t){_(e)}},Ue=function(e,t){try{Vn(r.removed,{attribute:t.getAttributeNode(e),from:t})}catch(n){Vn(r.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ee||te)try{Ie(t)}catch(n){}else try{t.setAttribute(e,"")}catch(n){}},je=function(e){let t=null,r=null;if(Z)e="<remove></remove>"+e;else{const t=Yn(e,/^[\r\n\t ]+/);r=t&&t[0]}"application/xhtml+xml"===ke&&_e===me&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const s=S?S.createHTML(e):e;if(_e===me)try{t=(new p).parseFromString(s,ke)}catch(o){}if(!t||!t.documentElement){t=E.createDocument(_e,"template",null);try{t.documentElement.innerHTML=we?v:s}catch(o){}}const i=t.body||t.documentElement;return e&&r&&i.insertBefore(n.createTextNode(r),i.childNodes[0]||null),_e===me?T.call(t,Q?"html":"body")[0]:Q?t.documentElement:i},Le=function(e){return k.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},De=function(e){return e instanceof h&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof d)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Fe=function(e){return"function"==typeof c&&e instanceof c};function Me(e,t,n){$n(e,(e=>{e.call(r,t,n,xe)}))}const qe=function(e){let t=null;if(Me(O.beforeSanitizeElements,e,null),De(e))return Ie(e),!0;const n=Te(e.nodeName);if(Me(O.uponSanitizeElement,e,{tagName:n,allowedTags:F}),X&&e.hasChildNodes()&&!Fe(e.firstElementChild)&&ns(/<[/\w!]/g,e.innerHTML)&&ns(/<[/\w!]/g,e.textContent))return Ie(e),!0;if(e.nodeType===js)return Ie(e),!0;if(X&&e.nodeType===Ls&&ns(/<[/\w]/g,e.data))return Ie(e),!0;if(!F[n]||z[n]){if(!z[n]&&He(n)){if(H.tagNameCheck instanceof RegExp&&ns(H.tagNameCheck,n))return!1;if(H.tagNameCheck instanceof Function&&H.tagNameCheck(n))return!1}if(ie&&!ce[n]){const t=b(e)||e.parentNode,r=y(e)||e.childNodes;if(r&&t){for(let n=r.length-1;n>=0;--n){const s=m(r[n],!0);s.__removalCount=(e.__removalCount||0)+1,t.insertBefore(s,w(e))}}}return Ie(e),!0}return e instanceof l&&!function(e){let t=b(e);t&&t.tagName||(t={namespaceURI:_e,tagName:"template"});const r=Xn(e.tagName),n=Xn(t.tagName);return!!ye[e.namespaceURI]&&(e.namespaceURI===ge?t.namespaceURI===me?"svg"===r:t.namespaceURI===fe?"svg"===r&&("annotation-xml"===n||Se[n]):Boolean(Ne[r]):e.namespaceURI===fe?t.namespaceURI===me?"math"===r:t.namespaceURI===ge?"math"===r&&ve[n]:Boolean(Pe[r]):e.namespaceURI===me?!(t.namespaceURI===ge&&!ve[n])&&!(t.namespaceURI===fe&&!Se[n])&&!Pe[r]&&(Ee[r]||!Ne[r]):!("application/xhtml+xml"!==ke||!ye[e.namespaceURI]))}(e)?(Ie(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!ns(/<\/no(script|embed|frames)/i,e.innerHTML)?(G&&e.nodeType===Us&&(t=e.textContent,$n([A,C,N],(e=>{t=Zn(t,e," ")})),e.textContent!==t&&(Vn(r.removed,{element:e.cloneNode()}),e.textContent=t)),Me(O.afterSanitizeElements,e,null),!1):(Ie(e),!0)},Be=function(e,t,r){if(ne&&("id"===t||"name"===t)&&(r in n||r in Oe))return!1;if(K&&!W[t]&&ns(P,t));else if($&&ns(I,t));else if(!q[t]||W[t]){if(!(He(e)&&(H.tagNameCheck instanceof RegExp&&ns(H.tagNameCheck,e)||H.tagNameCheck instanceof Function&&H.tagNameCheck(e))&&(H.attributeNameCheck instanceof RegExp&&ns(H.attributeNameCheck,t)||H.attributeNameCheck instanceof Function&&H.attributeNameCheck(t))||"is"===t&&H.allowCustomizedBuiltInElements&&(H.tagNameCheck instanceof RegExp&&ns(H.tagNameCheck,r)||H.tagNameCheck instanceof Function&&H.tagNameCheck(r))))return!1}else if(he[t]);else if(ns(D,Zn(r,j,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==es(r,"data:")||!ue[e]){if(J&&!ns(U,Zn(r,j,"")));else if(r)return!1}else;return!0},He=function(e){return"annotation-xml"!==e&&Yn(e,L)},ze=function(e){Me(O.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||De(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:q,forceKeepAttr:void 0};let s=t.length;for(;s--;){const o=t[s],{name:a,namespaceURI:c,value:l}=o,u=Te(a),d=l;let h="value"===a?d:ts(d);if(n.attrName=u,n.attrValue=h,n.keepAttr=!0,n.forceKeepAttr=void 0,Me(O.uponSanitizeAttribute,e,n),h=n.attrValue,!se||"id"!==u&&"name"!==u||(Ue(a,e),h="user-content-"+h),X&&ns(/((--!?|])>)|<\/(style|title)/i,h)){Ue(a,e);continue}if(n.forceKeepAttr)continue;if(!n.keepAttr){Ue(a,e);continue}if(!V&&ns(/\/>/i,h)){Ue(a,e);continue}G&&$n([A,C,N],(e=>{h=Zn(h,e," ")}));const p=Te(e.nodeName);if(Be(p,u,h)){if(S&&"object"==typeof f&&"function"==typeof f.getAttributeType)if(c);else switch(f.getAttributeType(p,u)){case"TrustedHTML":h=S.createHTML(h);break;case"TrustedScriptURL":h=S.createScriptURL(h)}if(h!==d)try{c?e.setAttributeNS(c,a,h):e.setAttribute(a,h),De(e)?Ie(e):Jn(r.removed)}catch(i){Ue(a,e)}}else Ue(a,e)}Me(O.afterSanitizeAttributes,e,null)},We=function e(t){let r=null;const n=Le(t);for(Me(O.beforeSanitizeShadowDOM,t,null);r=n.nextNode();)Me(O.uponSanitizeShadowNode,r,null),qe(r),ze(r),r.content instanceof o&&e(r.content);Me(O.afterSanitizeShadowDOM,t,null)};return r.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,i=null,a=null,l=null;if(we=!e,we&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Fe(e)){if("function"!=typeof e.toString)throw ss("toString is not a function");if("string"!=typeof(e=e.toString()))throw ss("dirty is not a string, aborting")}if(!r.isSupported)return e;if(Y||Ce(t),r.removed=[],"string"==typeof e&&(oe=!1),oe){if(e.nodeName){const t=Te(e.nodeName);if(!F[t]||z[t])throw ss("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof c)n=je("\x3c!----\x3e"),i=n.ownerDocument.importNode(e,!0),i.nodeType===Is&&"BODY"===i.nodeName||"HTML"===i.nodeName?n=i:n.appendChild(i);else{if(!ee&&!G&&!Q&&-1===e.indexOf("<"))return S&&re?S.createHTML(e):e;if(n=je(e),!n)return ee?null:re?v:""}n&&Z&&Ie(n.firstChild);const u=Le(oe?e:n);for(;a=u.nextNode();)qe(a),ze(a),a.content instanceof o&&We(a.content);if(oe)return e;if(ee){if(te)for(l=R.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(q.shadowroot||q.shadowrootmode)&&(l=x.call(s,l,!0)),l}let d=Q?n.outerHTML:n.innerHTML;return Q&&F["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&ns(Cs,n.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+d),G&&$n([A,C,N],(e=>{d=Zn(d,e," ")})),S&&re?S.createHTML(d):d},r.setConfig=function(){Ce(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Y=!0},r.clearConfig=function(){xe=null,Y=!1},r.isValidAttribute=function(e,t,r){xe||Ce({});const n=Te(e),s=Te(t);return Be(n,s,r)},r.addHook=function(e,t){"function"==typeof t&&Vn(O[e],t)},r.removeHook=function(e,t){if(void 0!==t){const r=Kn(O[e],t);return-1===r?void 0:Gn(O[e],r,1)[0]}return Jn(O[e])},r.removeHooks=function(e){O[e]=[]},r.removeAllHooks=function(){O={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},r}();const Ms=(()=>{if("undefined"!=typeof window)return Fs;try{const{JSDOM:e}=require("jsdom"),{window:t}=new e("");return Fs(t)}catch{return{sanitize:e=>String(e||"").replace(/<[^>]*>/g,"")}}})();function qs(e){if(!e)return"";const t=String(e);try{let e=Ms.sanitize(t,{ALLOWED_TAGS:[],ALLOWED_ATTR:[],KEEP_CONTENT:!0,RETURN_DOM:!1,RETURN_DOM_FRAGMENT:!1,FORCE_BODY:!0});if(!e.trim()&&t){t.replace(/<[^>]*>/g,"").trim()&&(e=t.replace(/<[^>]*>/g,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").trim())}return e.trim().slice(0,1e3)}catch{return t.replace(/<[^>]*>/g,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").trim().slice(0,1e3)}}async function Bs(e,t={}){const{onComplete:r,onCancel:n,onError:s}=t,i=function(e){if(!e)return"";const t=qs(e);try{const e=new URL(t);return"http:"===e.protocol||"https:"===e.protocol?t:""}catch{return""}}(e);if(!i){const e=new Error("Invalid payment URL provided");throw null==s||s(e),e}try{const e=window.open(i,"echo-payment","width=600,height=700,scrollbars=yes,resizable=yes");if(e&&!e.closed)return new Promise((t=>{const s=()=>{try{if(e.closed)return null==r||r(),void t();setTimeout(s,1e3)}catch{null==r||r(),t()}};s(),setTimeout((()=>{e.close(),null==n||n(),t()}),6e5)}));return confirm("Payment will open in a new tab. Click OK to continue, or Cancel to abort.")?(sessionStorage.setItem("echo_payment_flow","true"),window.location.href=i,new Promise((e=>{const t=()=>{"completed"===sessionStorage.getItem("echo_payment_flow")&&(sessionStorage.removeItem("echo_payment_flow"),null==r||r(),window.removeEventListener("focus",t),e())};window.addEventListener("focus",t),setTimeout((()=>{window.removeEventListener("focus",t),sessionStorage.removeItem("echo_payment_flow"),null==n||n(),e()}),18e5)}))):(null==n||n(),Promise.resolve())}catch(o){const e=o instanceof Error?o:new Error("Payment flow failed");throw null==s||s(e),e}}const Hs=({className:e="",width:t=16,height:r=16,variant:s="light"})=>{const i="dark"===s?"#DFE2D9":"#232323";return n.jsxs("svg",{id:"Layer_1","data-name":"Layer 1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 226.03 261",className:e,width:t,height:r,"aria-label":"Echo Logo",children:[n.jsx("defs",{children:n.jsx("style",{children:`\n .cls-1 {\n fill: none;\n }\n .cls-3 {\n fill: #7f0404;\n }\n .cls-4 {\n fill: ${i};\n }\n .cls-5 {\n fill: #a50404;\n }\n .cls-6 {\n fill: #cd0202;\n opacity: .9;\n }\n `})}),n.jsx("polygon",{className:"cls-6",points:"59.23 99.45 59.23 161.55 113.02 192.61 113.02 130.5 59.23 99.45"}),n.jsx("polygon",{className:"cls-5",points:"113.02 68.39 113.02 68.39 59.23 99.45 113.02 130.5 166.8 99.45 113.02 68.39"}),n.jsx("polygon",{className:"cls-3",points:"166.8 99.45 113.02 130.5 113.02 192.61 113.02 192.61 166.8 161.55 166.8 99.45"}),n.jsxs("g",{children:[n.jsx("path",{className:"cls-4",d:"m113.02,196.41l-57.08-32.95v-65.91l57.08-32.95,57.08,32.95v65.91l-57.08,32.95Zm-52.53-35.58l52.53,30.33,52.53-30.33v-60.66l-52.53-30.33-52.53,30.33v60.66Z"}),n.jsx("path",{className:"cls-4",d:"m113.02,261L0,195.75V65.25L113.02,0l113.02,65.25v130.5l-113.02,65.25ZM6.82,191.81l106.2,61.31,106.2-61.31v-122.62L113.02,7.88,6.82,69.19v122.62Z"}),n.jsx("rect",{className:"cls-4",x:"111.88",y:"3.94",width:"2.27",height:"63.28"}),n.jsx("rect",{className:"cls-4",x:"-.83",y:"176.82",width:"63.28",height:"2.27",transform:"translate(-84.84 39.24) rotate(-29.99)"}),n.jsx("rect",{className:"cls-4",x:"194.08",y:"146.32",width:"2.27",height:"63.28",transform:"translate(-56.51 258.05) rotate(-60)"}),n.jsx("rect",{className:"cls-4",x:"111.88",y:"130.5",width:"2.27",height:"126.56"}),n.jsx("rect",{className:"cls-4",x:"104.54",y:"97.72",width:"126.56",height:"2.27",transform:"translate(-26.95 97.14) rotate(-29.99)"}),n.jsx("rect",{className:"cls-4",x:"57.08",y:"35.58",width:"2.27",height:"126.56",transform:"translate(-56.51 99.84) rotate(-60)"})]})]})};const zs=({onAddCredits:e,onCancel:t,isProcessing:r})=>{const[i,o]=s.useState(""),a=s.useRef(null);s.useEffect((()=>{a.current&&a.current.focus()}),[]);const c=""!==i&&Number(i)>0;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"8px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{style:{fontSize:"14px",color:"#6b7280",fontFamily:"HelveticaNowDisplay, sans-serif"},children:"$"}),n.jsx("input",{ref:a,type:"number",placeholder:"0.00",value:i,onChange:e=>o(e.target.value),style:{width:"96px",textAlign:"right",padding:"8px 12px",border:"1px solid #e5e7eb",borderRadius:"6px",fontSize:"14px",fontFamily:"HelveticaNowDisplay, sans-serif",outline:"none",backgroundColor:"#ffffff"},min:"1",step:"0.01"})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("button",{onClick:t,style:{padding:"8px 12px",backgroundColor:"transparent",color:"#6b7280",border:"none",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontFamily:"HelveticaNowDisplay, sans-serif",textDecoration:"none"},onMouseEnter:e=>{e.currentTarget.style.color="#111827"},onMouseLeave:e=>{e.currentTarget.style.color="#6b7280"},children:"Cancel"}),n.jsx("button",{onClick:()=>{const t=Number(i);t>0&&e(t)},disabled:r||!c,style:{padding:"8px 16px",backgroundColor:r||!c?"#9ca3af":"#dc2626",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"500",cursor:r||!c?"not-allowed":"pointer",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:e=>{!r&&c&&(e.currentTarget.style.backgroundColor="#b91c1c")},onMouseLeave:e=>{!r&&c&&(e.currentTarget.style.backgroundColor="#dc2626")},children:r?"Processing...":"Add Credits"})]})]})};exports.EchoProvider=function({config:e,children:t}){const[r,i]=s.useState(!1);if(s.useEffect((()=>{i(!0)}),[]),!r)return null;const o=e.apiUrl||"https://echo.merit.systems",a={userManager:"undefined"!=typeof window&&window.__echoUserManager||new ue({authority:o,client_id:e.appId,redirect_uri:e.redirectUri||window.location.origin,scope:e.scope||"llm:invoke offline_access",silentRequestTimeoutInSeconds:10,silent_redirect_uri:e.redirectUri||window.location.origin,includeIdTokenInSilentRenew:!1,validateSubOnSilentRenew:!0,loadUserInfo:!0,metadata:{authorization_endpoint:`${o}/api/oauth/authorize`,token_endpoint:`${o}/api/oauth/token`,userinfo_endpoint:`${o}/api/oauth/userinfo`,issuer:o,jwks_uri:`${o}/.well-known/jwks.json`,end_session_endpoint:`${o}/api/oauth/logout`},userStore:new C({store:window.localStorage})}),onSigninCallback:()=>{window.location.search.includes("code=")&&window.history.replaceState({},document.title,window.location.pathname)}};return n.jsx(ke,{...a,children:n.jsx(In,{config:e,children:t})})},exports.EchoSignIn=function({onSuccess:e,onError:t,className:r="",children:i}){const{signIn:o,isAuthenticated:a,isLoading:c,user:l,error:u}=Un(),[d,h]=s.useState(!1);s.useEffect((()=>{a&&l&&e&&e(l)}),[a,l,e]),s.useEffect((()=>{u&&t&&t(new Error(u))}),[u,t]);const p=async()=>{try{await o()}catch(e){t&&t(e instanceof Error?e:new Error("Sign in failed"))}};return a?n.jsx("div",{className:`echo-signin-success ${r}`,children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:"8px",color:"#334155",fontSize:"14px",fontFamily:"HelveticaNowDisplay, sans-serif",fontWeight:"800",width:"fit-content"},children:[n.jsx(Hs,{width:16,height:16,variant:"light"}),n.jsxs("span",{children:["Signed in as ",qs((null==l?void 0:l.name)||(null==l?void 0:l.email))]})]})}):n.jsxs("div",{className:`echo-signin ${r}`,children:[i?n.jsx("div",{onClick:p,style:{cursor:"pointer"},children:i}):n.jsxs("button",{onClick:p,disabled:c,className:"echo-signin-button",style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 20px",backgroundColor:c?"#f3f4f6":d?"#f1f5f9":"#ffffff",color:c?"#9ca3af":"#09090b",border:"1px solid #e2e8f0",borderRadius:"8px",cursor:c?"not-allowed":"pointer",fontSize:"14px",fontWeight:"800",fontFamily:"HelveticaNowDisplay, sans-serif",transition:"all 0.2s ease",boxShadow:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",backdropFilter:"blur(8px)"},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:[n.jsx(Hs,{width:16,height:16,variant:"light"}),n.jsx("span",{children:c?"Signing in...":"Sign in"})]}),u&&n.jsx("div",{className:"echo-signin-error",style:{marginTop:"12px",display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",color:"#dc2626",fontSize:"14px",fontFamily:"HelveticaNowDisplay, sans-serif",fontWeight:"800",width:"fit-content"},children:n.jsx("span",{children:u})})]})},exports.EchoTokenPurchase=function({onPurchaseComplete:e,onError:t,className:r="",children:i}){const{createPaymentLink:o,isAuthenticated:a,balance:c,freeTierBalance:l,refreshBalance:u}=Un(),[d,h]=s.useState(!1),[p,f]=s.useState(null),[g,m]=s.useState(!1),[_,w]=s.useState(!1),y=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(e),b=()=>{var e;return((null==(e=null==l?void 0:l.userSpendInfo)?void 0:e.amountLeft)||0)+((null==c?void 0:c.balance)||0)},S=async r=>{if(!a){const e=new Error("Please sign in to purchase tokens");return f(e.message),void(t&&t(e))}try{h(!0),f(null);const n=await o(r);await Bs(n,{onComplete:async()=>{try{await u(),m(!1),w(!1),e&&c&&e(c)}catch(r){const e=r instanceof Error?r:new Error("Failed to refresh balance");f(e.message),t&&t(e)}finally{h(!1)}},onCancel:()=>{h(!1)},onError:e=>{f(e.message),t&&t(e),h(!1)}})}catch(n){const e=n instanceof Error?n:new Error("Failed to create payment link");f(e.message),t&&t(e),h(!1)}},v=()=>{m(!1),w(!1),f(null)};if(!a)return n.jsx("div",{className:`echo-token-purchase ${r}`,children:n.jsx("div",{className:"echo-token-purchase-unauthorized",style:{padding:"12px",backgroundColor:"#fef3c7",color:"#92400e",borderRadius:"8px",fontSize:"14px"},children:"Please sign in to purchase tokens"})});const E=()=>{const[e,t]=s.useState(!1);return n.jsxs("button",{onClick:()=>m(!0),className:`echo-token-purchase-compact ${r}`,style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 12px",borderRadius:"8px",backgroundColor:e?"#f1f5f9":"#ffffff",border:"1px solid #e5e7eb",color:"#09090b",fontSize:"14px",fontWeight:"800",cursor:"pointer",backdropFilter:"blur(8px)",transition:"all 0.2s ease",boxShadow:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",height:"40px",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[n.jsx(Hs,{width:16,height:16,variant:"light"}),n.jsx("span",{children:y(b())}),n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:e?"#dc2626":"#6b7280",transition:"color 0.2s ease"},children:[n.jsx("path",{d:"M7 7h10v10"}),n.jsx("path",{d:"M7 17 17 7"})]})]})},k=()=>n.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"16px"},onClick:e=>{e.target===e.currentTarget&&v()},children:n.jsxs("div",{style:{backgroundColor:"#ffffff",borderRadius:"12px",border:"1px solid #e5e7eb",padding:"0",width:"100%",maxWidth:"450px",maxHeight:"90vh",overflow:"hidden",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",fontFamily:"HelveticaNowDisplay, sans-serif",display:"flex",flexDirection:"column",minHeight:"320px"},children:[n.jsx("div",{style:{padding:"16px 16px 0 16px",marginBottom:"12px"},children:n.jsx("h2",{style:{fontSize:"18px",fontWeight:"500",color:"#111827",margin:0,fontFamily:"HelveticaNowDisplay, sans-serif"},children:"Credits"})}),n.jsxs("div",{style:{padding:"0 16px",marginBottom:"16px"},children:[n.jsx("p",{style:{fontSize:"14px",color:"#6b7280",margin:"0 0 4px 0",fontFamily:"HelveticaNowDisplay, sans-serif"},children:"Total Available"}),n.jsx("p",{style:{fontSize:"28px",fontWeight:"700",color:"#111827",margin:"0 0 12px 0",fontFamily:"HelveticaNowDisplay, sans-serif"},children:y(((null==c?void 0:c.balance)||0)+b())}),n.jsxs("div",{style:{marginBottom:"8px"},children:[l&&b()>0&&n.jsxs("div",{style:{marginBottom:"8px"},children:[n.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",fontFamily:"HelveticaNowDisplay, sans-serif",display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"},children:[n.jsx("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#ef4444"}}),n.jsxs("span",{children:[y(b())," Free Tier",l.userSpendInfo&&l.userSpendInfo.spendLimit&&n.jsxs("span",{style:{color:"#9ca3af",marginLeft:"8px"},children:[y(l.userSpendInfo.amountSpent)," ","of"," ",y(l.userSpendInfo.amountLeft+l.userSpendInfo.amountSpent)," ","used"]})]})]}),l.userSpendInfo&&l.userSpendInfo.spendLimit&&n.jsx("div",{style:{width:"100%",height:"4px",backgroundColor:"#e5e7eb",borderRadius:"2px",overflow:"hidden",marginBottom:"4px",border:"1px solid #d1d5db"},children:n.jsx("div",{style:{width:`${Math.min(100,l.userSpendInfo.amountSpent/(l.userSpendInfo.spendLimit||1)*100)}%`,height:"100%",backgroundColor:"#dc2626"}})})]}),c&&c.balance>0&&n.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",fontFamily:"HelveticaNowDisplay, sans-serif",display:"flex",alignItems:"center",gap:"6px"},children:[n.jsx("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#3b82f6"}}),y(c.balance)," Paid Credits"]})]})]}),n.jsxs("div",{style:{padding:"0 16px 16px 16px",borderTop:"1px solid #f3f4f6",paddingTop:"16px"},children:[n.jsx("p",{style:{fontSize:"14px",color:"#6b7280",margin:"0 0 12px 0",fontFamily:"HelveticaNowDisplay, sans-serif"},children:"Add Credits"}),_?n.jsx(zs,{onAddCredits:S,onCancel:()=>w(!1),isProcessing:d}):n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.jsx("button",{onClick:()=>S(10),disabled:d,style:{width:"100%",padding:"12px 16px",backgroundColor:d?"#9ca3af":"#dc2626",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"600",cursor:d?"not-allowed":"pointer",transition:"background-color 0.2s ease",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:e=>{d||(e.currentTarget.style.backgroundColor="#b91c1c")},onMouseLeave:e=>{d||(e.currentTarget.style.backgroundColor="#dc2626")},children:d?"Processing...":"Add $10 Credits"}),n.jsx("button",{onClick:()=>w(!0),style:{width:"100%",padding:"8px 16px",fontSize:"14px",color:"#6b7280",backgroundColor:"transparent",border:"1px solid #e5e7eb",borderRadius:"6px",cursor:"pointer",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:e=>{e.currentTarget.style.color="#111827",e.currentTarget.style.borderColor="#d1d5db"},onMouseLeave:e=>{e.currentTarget.style.color="#6b7280",e.currentTarget.style.borderColor="#e5e7eb"},children:"Choose different amount"})]})]}),p&&n.jsx("div",{style:{margin:"0 16px 12px 16px",padding:"8px 12px",backgroundColor:"#fee2e2",color:"#dc2626",borderRadius:"6px",fontSize:"14px",fontFamily:"HelveticaNowDisplay, sans-serif"},children:p}),n.jsx("div",{style:{padding:"12px 16px",display:"flex",justifyContent:"flex-end",borderTop:"1px solid #f3f4f6"},children:n.jsx("button",{onClick:v,style:{padding:"8px 16px",backgroundColor:"#f3f4f6",color:"#374151",border:"none",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#e5e7eb"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="#f3f4f6"},children:"Close"})})]})});return n.jsxs(n.Fragment,{children:[i?n.jsx("div",{onClick:()=>m(!0),style:{cursor:"pointer"},children:i}):n.jsx(E,{}),g&&n.jsx(k,{})]})},exports.Logo=Hs,exports.useEcho=Un,exports.useEchoClient=Nn,exports.useEchoOpenAI=function(e={}){const{baseURL:t="https://echo.router.merit.systems",enabled:r=!0}=e,{token:n,isAuthenticated:i}=Un(),[o,a]=s.useState(void 0),[c,l]=s.useState(null),[u,d]=s.useState(!1),h=s.useRef(null);return s.useEffect((()=>{if(h.current&&h.current.abort(),!r||!n||!i)return a(void 0),l(null),void d(!1);return(async()=>{const e=new AbortController;h.current=e,d(!0),l(null);try{if(e.signal.aborted)return;const{default:r}=await import("openai");if(e.signal.aborted)return;const s=new r({apiKey:n,baseURL:t,dangerouslyAllowBrowser:!0});e.signal.aborted||a(s)}catch(r){if(!e.signal.aborted){const e=r instanceof Error?r.message:"Failed to load OpenAI";e.includes("Cannot resolve module")||e.includes("Module not found")||e.includes("openai")?l("OpenAI package not found. Please install it with: pnpm add openai"):l(`Failed to initialize OpenAI client: ${e}`),console.error("Error loading OpenAI:",r),a(void 0)}}finally{e.signal.aborted||d(!1)}})(),()=>{h.current&&h.current.abort()}}),[n,i,t,r]),{openai:o,isReady:void 0!==o&&!u,error:c,isLoading:u}};
|
|
3
|
+
/*! @license DOMPurify 3.2.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.6/LICENSE */const{entries:jn,setPrototypeOf:Ln,isFrozen:Dn,getPrototypeOf:Fn,getOwnPropertyDescriptor:Mn}=Object;let{freeze:qn,seal:Bn,create:Hn}=Object,{apply:zn,construct:Wn}="undefined"!=typeof Reflect&&Reflect;qn||(qn=function(e){return e}),Bn||(Bn=function(e){return e}),zn||(zn=function(e,t,r){return e.apply(t,r)}),Wn||(Wn=function(e,t){return new e(...t)});const $n=os(Array.prototype.forEach),Kn=os(Array.prototype.lastIndexOf),Jn=os(Array.prototype.pop),Vn=os(Array.prototype.push),Gn=os(Array.prototype.splice),Xn=os(String.prototype.toLowerCase),Qn=os(String.prototype.toString),Yn=os(String.prototype.match),Zn=os(String.prototype.replace),es=os(String.prototype.indexOf),ts=os(String.prototype.trim),rs=os(Object.prototype.hasOwnProperty),ns=os(RegExp.prototype.test),ss=(is=TypeError,function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return Wn(is,t)});var is;function os(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,n=new Array(r>1?r-1:0),s=1;s<r;s++)n[s-1]=arguments[s];return zn(e,t,n)}}function as(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Xn;Ln&&Ln(e,null);let n=t.length;for(;n--;){let s=t[n];if("string"==typeof s){const e=r(s);e!==s&&(Dn(t)||(t[n]=e),s=e)}e[s]=!0}return e}function cs(e){for(let t=0;t<e.length;t++){rs(e,t)||(e[t]=null)}return e}function ls(e){const t=Hn(null);for(const[r,n]of jn(e)){rs(e,r)&&(Array.isArray(n)?t[r]=cs(n):n&&"object"==typeof n&&n.constructor===Object?t[r]=ls(n):t[r]=n)}return t}function us(e,t){for(;null!==e;){const r=Mn(e,t);if(r){if(r.get)return os(r.get);if("function"==typeof r.value)return os(r.value)}e=Fn(e)}return function(){return null}}const ds=qn(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),hs=qn(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),ps=qn(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),fs=qn(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),gs=qn(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),ms=qn(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),_s=qn(["#text"]),ws=qn(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns","slot"]),ys=qn(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),bs=qn(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),Ss=qn(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),vs=Bn(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Es=Bn(/<%[\w\W]*|[\w\W]*%>/gm),ks=Bn(/\$\{[\w\W]*/gm),Rs=Bn(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ts=Bn(/^aria-[\-\w]+$/),xs=Bn(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Os=Bn(/^(?:\w+script|data):/i),As=Bn(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cs=Bn(/^html$/i),Ns=Bn(/^[a-z][.\w]*(-[.\w]+)+$/i);var Ps=Object.freeze({__proto__:null,ARIA_ATTR:Ts,ATTR_WHITESPACE:As,CUSTOM_ELEMENT:Ns,DATA_ATTR:Rs,DOCTYPE_NAME:Cs,ERB_EXPR:Es,IS_ALLOWED_URI:xs,IS_SCRIPT_OR_DATA:Os,MUSTACHE_EXPR:vs,TMPLIT_EXPR:ks});const Is=1,Us=3,js=7,Ls=8,Ds=9;var Fs=function e(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"undefined"==typeof window?null:window;const r=t=>e(t);if(r.version="3.2.6",r.removed=[],!t||!t.document||t.document.nodeType!==Ds||!t.Element)return r.isSupported=!1,r;let{document:n}=t;const s=n,i=s.currentScript,{DocumentFragment:o,HTMLTemplateElement:a,Node:c,Element:l,NodeFilter:u,NamedNodeMap:d=t.NamedNodeMap||t.MozNamedAttrMap,HTMLFormElement:h,DOMParser:p,trustedTypes:f}=t,g=l.prototype,m=us(g,"cloneNode"),_=us(g,"remove"),w=us(g,"nextSibling"),y=us(g,"childNodes"),b=us(g,"parentNode");if("function"==typeof a){const e=n.createElement("template");e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let S,v="";const{implementation:E,createNodeIterator:k,createDocumentFragment:R,getElementsByTagName:T}=n,{importNode:x}=s;let O={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]};r.isSupported="function"==typeof jn&&"function"==typeof b&&E&&void 0!==E.createHTMLDocument;const{MUSTACHE_EXPR:A,ERB_EXPR:C,TMPLIT_EXPR:N,DATA_ATTR:P,ARIA_ATTR:I,IS_SCRIPT_OR_DATA:U,ATTR_WHITESPACE:j,CUSTOM_ELEMENT:L}=Ps;let{IS_ALLOWED_URI:D}=Ps,F=null;const M=as({},[...ds,...hs,...ps,...gs,..._s]);let q=null;const B=as({},[...ws,...ys,...bs,...Ss]);let H=Object.seal(Hn(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),z=null,W=null,$=!0,K=!0,J=!1,V=!0,G=!1,X=!0,Q=!1,Y=!1,Z=!1,ee=!1,te=!1,re=!1,ne=!0,se=!1,ie=!0,oe=!1,ae={},ce=null;const le=as({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let ue=null;const de=as({},["audio","video","img","source","image","track"]);let he=null;const pe=as({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),fe="http://www.w3.org/1998/Math/MathML",ge="http://www.w3.org/2000/svg",me="http://www.w3.org/1999/xhtml";let _e=me,we=!1,ye=null;const be=as({},[fe,ge,me],Qn);let Se=as({},["mi","mo","mn","ms","mtext"]),ve=as({},["annotation-xml"]);const Ee=as({},["title","style","font","a","script"]);let ke=null;const Re=["application/xhtml+xml","text/html"];let Te=null,xe=null;const Oe=n.createElement("form"),Ae=function(e){return e instanceof RegExp||e instanceof Function},Ce=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!xe||xe!==e){if(e&&"object"==typeof e||(e={}),e=ls(e),ke=-1===Re.indexOf(e.PARSER_MEDIA_TYPE)?"text/html":e.PARSER_MEDIA_TYPE,Te="application/xhtml+xml"===ke?Qn:Xn,F=rs(e,"ALLOWED_TAGS")?as({},e.ALLOWED_TAGS,Te):M,q=rs(e,"ALLOWED_ATTR")?as({},e.ALLOWED_ATTR,Te):B,ye=rs(e,"ALLOWED_NAMESPACES")?as({},e.ALLOWED_NAMESPACES,Qn):be,he=rs(e,"ADD_URI_SAFE_ATTR")?as(ls(pe),e.ADD_URI_SAFE_ATTR,Te):pe,ue=rs(e,"ADD_DATA_URI_TAGS")?as(ls(de),e.ADD_DATA_URI_TAGS,Te):de,ce=rs(e,"FORBID_CONTENTS")?as({},e.FORBID_CONTENTS,Te):le,z=rs(e,"FORBID_TAGS")?as({},e.FORBID_TAGS,Te):ls({}),W=rs(e,"FORBID_ATTR")?as({},e.FORBID_ATTR,Te):ls({}),ae=!!rs(e,"USE_PROFILES")&&e.USE_PROFILES,$=!1!==e.ALLOW_ARIA_ATTR,K=!1!==e.ALLOW_DATA_ATTR,J=e.ALLOW_UNKNOWN_PROTOCOLS||!1,V=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,G=e.SAFE_FOR_TEMPLATES||!1,X=!1!==e.SAFE_FOR_XML,Q=e.WHOLE_DOCUMENT||!1,ee=e.RETURN_DOM||!1,te=e.RETURN_DOM_FRAGMENT||!1,re=e.RETURN_TRUSTED_TYPE||!1,Z=e.FORCE_BODY||!1,ne=!1!==e.SANITIZE_DOM,se=e.SANITIZE_NAMED_PROPS||!1,ie=!1!==e.KEEP_CONTENT,oe=e.IN_PLACE||!1,D=e.ALLOWED_URI_REGEXP||xs,_e=e.NAMESPACE||me,Se=e.MATHML_TEXT_INTEGRATION_POINTS||Se,ve=e.HTML_INTEGRATION_POINTS||ve,H=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&Ae(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(H.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&Ae(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(H.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(H.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),G&&(K=!1),te&&(ee=!0),ae&&(F=as({},_s),q=[],!0===ae.html&&(as(F,ds),as(q,ws)),!0===ae.svg&&(as(F,hs),as(q,ys),as(q,Ss)),!0===ae.svgFilters&&(as(F,ps),as(q,ys),as(q,Ss)),!0===ae.mathMl&&(as(F,gs),as(q,bs),as(q,Ss))),e.ADD_TAGS&&(F===M&&(F=ls(F)),as(F,e.ADD_TAGS,Te)),e.ADD_ATTR&&(q===B&&(q=ls(q)),as(q,e.ADD_ATTR,Te)),e.ADD_URI_SAFE_ATTR&&as(he,e.ADD_URI_SAFE_ATTR,Te),e.FORBID_CONTENTS&&(ce===le&&(ce=ls(ce)),as(ce,e.FORBID_CONTENTS,Te)),ie&&(F["#text"]=!0),Q&&as(F,["html","head","body"]),F.table&&(as(F,["tbody"]),delete z.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw ss('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw ss('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');S=e.TRUSTED_TYPES_POLICY,v=S.createHTML("")}else void 0===S&&(S=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let r=null;const n="data-tt-policy-suffix";t&&t.hasAttribute(n)&&(r=t.getAttribute(n));const s="dompurify"+(r?"#"+r:"");try{return e.createPolicy(s,{createHTML:e=>e,createScriptURL:e=>e})}catch(i){return console.warn("TrustedTypes policy "+s+" could not be created."),null}}(f,i)),null!==S&&"string"==typeof v&&(v=S.createHTML(""));qn&&qn(e),xe=e}},Ne=as({},[...hs,...ps,...fs]),Pe=as({},[...gs,...ms]),Ie=function(e){Vn(r.removed,{element:e});try{b(e).removeChild(e)}catch(t){_(e)}},Ue=function(e,t){try{Vn(r.removed,{attribute:t.getAttributeNode(e),from:t})}catch(n){Vn(r.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e)if(ee||te)try{Ie(t)}catch(n){}else try{t.setAttribute(e,"")}catch(n){}},je=function(e){let t=null,r=null;if(Z)e="<remove></remove>"+e;else{const t=Yn(e,/^[\r\n\t ]+/);r=t&&t[0]}"application/xhtml+xml"===ke&&_e===me&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");const s=S?S.createHTML(e):e;if(_e===me)try{t=(new p).parseFromString(s,ke)}catch(o){}if(!t||!t.documentElement){t=E.createDocument(_e,"template",null);try{t.documentElement.innerHTML=we?v:s}catch(o){}}const i=t.body||t.documentElement;return e&&r&&i.insertBefore(n.createTextNode(r),i.childNodes[0]||null),_e===me?T.call(t,Q?"html":"body")[0]:Q?t.documentElement:i},Le=function(e){return k.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},De=function(e){return e instanceof h&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof d)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Fe=function(e){return"function"==typeof c&&e instanceof c};function Me(e,t,n){$n(e,(e=>{e.call(r,t,n,xe)}))}const qe=function(e){let t=null;if(Me(O.beforeSanitizeElements,e,null),De(e))return Ie(e),!0;const n=Te(e.nodeName);if(Me(O.uponSanitizeElement,e,{tagName:n,allowedTags:F}),X&&e.hasChildNodes()&&!Fe(e.firstElementChild)&&ns(/<[/\w!]/g,e.innerHTML)&&ns(/<[/\w!]/g,e.textContent))return Ie(e),!0;if(e.nodeType===js)return Ie(e),!0;if(X&&e.nodeType===Ls&&ns(/<[/\w]/g,e.data))return Ie(e),!0;if(!F[n]||z[n]){if(!z[n]&&He(n)){if(H.tagNameCheck instanceof RegExp&&ns(H.tagNameCheck,n))return!1;if(H.tagNameCheck instanceof Function&&H.tagNameCheck(n))return!1}if(ie&&!ce[n]){const t=b(e)||e.parentNode,r=y(e)||e.childNodes;if(r&&t){for(let n=r.length-1;n>=0;--n){const s=m(r[n],!0);s.__removalCount=(e.__removalCount||0)+1,t.insertBefore(s,w(e))}}}return Ie(e),!0}return e instanceof l&&!function(e){let t=b(e);t&&t.tagName||(t={namespaceURI:_e,tagName:"template"});const r=Xn(e.tagName),n=Xn(t.tagName);return!!ye[e.namespaceURI]&&(e.namespaceURI===ge?t.namespaceURI===me?"svg"===r:t.namespaceURI===fe?"svg"===r&&("annotation-xml"===n||Se[n]):Boolean(Ne[r]):e.namespaceURI===fe?t.namespaceURI===me?"math"===r:t.namespaceURI===ge?"math"===r&&ve[n]:Boolean(Pe[r]):e.namespaceURI===me?!(t.namespaceURI===ge&&!ve[n])&&!(t.namespaceURI===fe&&!Se[n])&&!Pe[r]&&(Ee[r]||!Ne[r]):!("application/xhtml+xml"!==ke||!ye[e.namespaceURI]))}(e)?(Ie(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!ns(/<\/no(script|embed|frames)/i,e.innerHTML)?(G&&e.nodeType===Us&&(t=e.textContent,$n([A,C,N],(e=>{t=Zn(t,e," ")})),e.textContent!==t&&(Vn(r.removed,{element:e.cloneNode()}),e.textContent=t)),Me(O.afterSanitizeElements,e,null),!1):(Ie(e),!0)},Be=function(e,t,r){if(ne&&("id"===t||"name"===t)&&(r in n||r in Oe))return!1;if(K&&!W[t]&&ns(P,t));else if($&&ns(I,t));else if(!q[t]||W[t]){if(!(He(e)&&(H.tagNameCheck instanceof RegExp&&ns(H.tagNameCheck,e)||H.tagNameCheck instanceof Function&&H.tagNameCheck(e))&&(H.attributeNameCheck instanceof RegExp&&ns(H.attributeNameCheck,t)||H.attributeNameCheck instanceof Function&&H.attributeNameCheck(t))||"is"===t&&H.allowCustomizedBuiltInElements&&(H.tagNameCheck instanceof RegExp&&ns(H.tagNameCheck,r)||H.tagNameCheck instanceof Function&&H.tagNameCheck(r))))return!1}else if(he[t]);else if(ns(D,Zn(r,j,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==es(r,"data:")||!ue[e]){if(J&&!ns(U,Zn(r,j,"")));else if(r)return!1}else;return!0},He=function(e){return"annotation-xml"!==e&&Yn(e,L)},ze=function(e){Me(O.beforeSanitizeAttributes,e,null);const{attributes:t}=e;if(!t||De(e))return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:q,forceKeepAttr:void 0};let s=t.length;for(;s--;){const o=t[s],{name:a,namespaceURI:c,value:l}=o,u=Te(a),d=l;let h="value"===a?d:ts(d);if(n.attrName=u,n.attrValue=h,n.keepAttr=!0,n.forceKeepAttr=void 0,Me(O.uponSanitizeAttribute,e,n),h=n.attrValue,!se||"id"!==u&&"name"!==u||(Ue(a,e),h="user-content-"+h),X&&ns(/((--!?|])>)|<\/(style|title)/i,h)){Ue(a,e);continue}if(n.forceKeepAttr)continue;if(!n.keepAttr){Ue(a,e);continue}if(!V&&ns(/\/>/i,h)){Ue(a,e);continue}G&&$n([A,C,N],(e=>{h=Zn(h,e," ")}));const p=Te(e.nodeName);if(Be(p,u,h)){if(S&&"object"==typeof f&&"function"==typeof f.getAttributeType)if(c);else switch(f.getAttributeType(p,u)){case"TrustedHTML":h=S.createHTML(h);break;case"TrustedScriptURL":h=S.createScriptURL(h)}if(h!==d)try{c?e.setAttributeNS(c,a,h):e.setAttribute(a,h),De(e)?Ie(e):Jn(r.removed)}catch(i){Ue(a,e)}}else Ue(a,e)}Me(O.afterSanitizeAttributes,e,null)},We=function e(t){let r=null;const n=Le(t);for(Me(O.beforeSanitizeShadowDOM,t,null);r=n.nextNode();)Me(O.uponSanitizeShadowNode,r,null),qe(r),ze(r),r.content instanceof o&&e(r.content);Me(O.afterSanitizeShadowDOM,t,null)};return r.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,i=null,a=null,l=null;if(we=!e,we&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Fe(e)){if("function"!=typeof e.toString)throw ss("toString is not a function");if("string"!=typeof(e=e.toString()))throw ss("dirty is not a string, aborting")}if(!r.isSupported)return e;if(Y||Ce(t),r.removed=[],"string"==typeof e&&(oe=!1),oe){if(e.nodeName){const t=Te(e.nodeName);if(!F[t]||z[t])throw ss("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof c)n=je("\x3c!----\x3e"),i=n.ownerDocument.importNode(e,!0),i.nodeType===Is&&"BODY"===i.nodeName||"HTML"===i.nodeName?n=i:n.appendChild(i);else{if(!ee&&!G&&!Q&&-1===e.indexOf("<"))return S&&re?S.createHTML(e):e;if(n=je(e),!n)return ee?null:re?v:""}n&&Z&&Ie(n.firstChild);const u=Le(oe?e:n);for(;a=u.nextNode();)qe(a),ze(a),a.content instanceof o&&We(a.content);if(oe)return e;if(ee){if(te)for(l=R.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(q.shadowroot||q.shadowrootmode)&&(l=x.call(s,l,!0)),l}let d=Q?n.outerHTML:n.innerHTML;return Q&&F["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&ns(Cs,n.ownerDocument.doctype.name)&&(d="<!DOCTYPE "+n.ownerDocument.doctype.name+">\n"+d),G&&$n([A,C,N],(e=>{d=Zn(d,e," ")})),S&&re?S.createHTML(d):d},r.setConfig=function(){Ce(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}),Y=!0},r.clearConfig=function(){xe=null,Y=!1},r.isValidAttribute=function(e,t,r){xe||Ce({});const n=Te(e),s=Te(t);return Be(n,s,r)},r.addHook=function(e,t){"function"==typeof t&&Vn(O[e],t)},r.removeHook=function(e,t){if(void 0!==t){const r=Kn(O[e],t);return-1===r?void 0:Gn(O[e],r,1)[0]}return Jn(O[e])},r.removeHooks=function(e){O[e]=[]},r.removeAllHooks=function(){O={afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},r}();const Ms=(()=>{if("undefined"!=typeof window)return Fs;try{const{JSDOM:e}=require("jsdom"),{window:t}=new e("");return Fs(t)}catch{return{sanitize:e=>String(e||"").replace(/<[^>]*>/g,"")}}})();function qs(e){if(!e)return"";const t=String(e);try{let e=Ms.sanitize(t,{ALLOWED_TAGS:[],ALLOWED_ATTR:[],KEEP_CONTENT:!0,RETURN_DOM:!1,RETURN_DOM_FRAGMENT:!1,FORCE_BODY:!0});if(!e.trim()&&t){t.replace(/<[^>]*>/g,"").trim()&&(e=t.replace(/<[^>]*>/g,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").trim())}return e.trim().slice(0,1e3)}catch{return t.replace(/<[^>]*>/g,"").replace(/javascript:/gi,"").replace(/on\w+\s*=/gi,"").trim().slice(0,1e3)}}async function Bs(e,t={}){const{onComplete:r,onCancel:n,onError:s}=t,i=function(e){if(!e)return"";const t=qs(e);try{const e=new URL(t);return"http:"===e.protocol||"https:"===e.protocol?t:""}catch{return""}}(e);if(!i){const e=new Error("Invalid payment URL provided");throw null==s||s(e),e}try{const e=window.open(i,"echo-payment","width=600,height=700,scrollbars=yes,resizable=yes");if(e&&!e.closed)return new Promise((t=>{const s=()=>{try{if(e.closed)return null==r||r(),void t();setTimeout(s,1e3)}catch{null==r||r(),t()}};s(),setTimeout((()=>{e.close(),null==n||n(),t()}),6e5)}));return confirm("Payment will open in a new tab. Click OK to continue, or Cancel to abort.")?(sessionStorage.setItem("echo_payment_flow","true"),window.location.href=i,new Promise((e=>{const t=()=>{"completed"===sessionStorage.getItem("echo_payment_flow")&&(sessionStorage.removeItem("echo_payment_flow"),null==r||r(),window.removeEventListener("focus",t),e())};window.addEventListener("focus",t),setTimeout((()=>{window.removeEventListener("focus",t),sessionStorage.removeItem("echo_payment_flow"),null==n||n(),e()}),18e5)}))):(null==n||n(),Promise.resolve())}catch(o){const e=o instanceof Error?o:new Error("Payment flow failed");throw null==s||s(e),e}}const Hs=({className:e="",width:t=16,height:r=16,variant:s="light"})=>{const i="dark"===s?"#DFE2D9":"#232323";return n.jsxs("svg",{id:"Layer_1","data-name":"Layer 1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 226.03 261",className:e,width:t,height:r,"aria-label":"Echo Logo",children:[n.jsx("defs",{children:n.jsx("style",{children:`\n .cls-1 {\n fill: none;\n }\n .cls-3 {\n fill: #7f0404;\n }\n .cls-4 {\n fill: ${i};\n }\n .cls-5 {\n fill: #a50404;\n }\n .cls-6 {\n fill: #cd0202;\n opacity: .9;\n }\n `})}),n.jsx("polygon",{className:"cls-6",points:"59.23 99.45 59.23 161.55 113.02 192.61 113.02 130.5 59.23 99.45"}),n.jsx("polygon",{className:"cls-5",points:"113.02 68.39 113.02 68.39 59.23 99.45 113.02 130.5 166.8 99.45 113.02 68.39"}),n.jsx("polygon",{className:"cls-3",points:"166.8 99.45 113.02 130.5 113.02 192.61 113.02 192.61 166.8 161.55 166.8 99.45"}),n.jsxs("g",{children:[n.jsx("path",{className:"cls-4",d:"m113.02,196.41l-57.08-32.95v-65.91l57.08-32.95,57.08,32.95v65.91l-57.08,32.95Zm-52.53-35.58l52.53,30.33,52.53-30.33v-60.66l-52.53-30.33-52.53,30.33v60.66Z"}),n.jsx("path",{className:"cls-4",d:"m113.02,261L0,195.75V65.25L113.02,0l113.02,65.25v130.5l-113.02,65.25ZM6.82,191.81l106.2,61.31,106.2-61.31v-122.62L113.02,7.88,6.82,69.19v122.62Z"}),n.jsx("rect",{className:"cls-4",x:"111.88",y:"3.94",width:"2.27",height:"63.28"}),n.jsx("rect",{className:"cls-4",x:"-.83",y:"176.82",width:"63.28",height:"2.27",transform:"translate(-84.84 39.24) rotate(-29.99)"}),n.jsx("rect",{className:"cls-4",x:"194.08",y:"146.32",width:"2.27",height:"63.28",transform:"translate(-56.51 258.05) rotate(-60)"}),n.jsx("rect",{className:"cls-4",x:"111.88",y:"130.5",width:"2.27",height:"126.56"}),n.jsx("rect",{className:"cls-4",x:"104.54",y:"97.72",width:"126.56",height:"2.27",transform:"translate(-26.95 97.14) rotate(-29.99)"}),n.jsx("rect",{className:"cls-4",x:"57.08",y:"35.58",width:"2.27",height:"126.56",transform:"translate(-56.51 99.84) rotate(-60)"})]})]})};const zs=({onAddCredits:e,onCancel:t,isProcessing:r})=>{const[i,o]=s.useState(""),a=s.useRef(null);s.useEffect((()=>{a.current&&a.current.focus()}),[]);const c=""!==i&&Number(i)>0;return n.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:"8px"},children:[n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("span",{style:{fontSize:"14px",color:"#6b7280",fontFamily:"HelveticaNowDisplay, sans-serif"},children:"$"}),n.jsx("input",{ref:a,type:"number",placeholder:"0.00",value:i,onChange:e=>o(e.target.value),style:{width:"96px",textAlign:"right",padding:"8px 12px",border:"1px solid #e5e7eb",borderRadius:"6px",fontSize:"14px",fontFamily:"HelveticaNowDisplay, sans-serif",outline:"none",backgroundColor:"#ffffff"},min:"1",step:"0.01"})]}),n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[n.jsx("button",{onClick:t,style:{padding:"8px 12px",backgroundColor:"transparent",color:"#6b7280",border:"none",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontFamily:"HelveticaNowDisplay, sans-serif",textDecoration:"none"},onMouseEnter:e=>{e.currentTarget.style.color="#111827"},onMouseLeave:e=>{e.currentTarget.style.color="#6b7280"},children:"Cancel"}),n.jsx("button",{onClick:()=>{const t=Number(i);t>0&&e(t)},disabled:r||!c,style:{padding:"8px 16px",backgroundColor:r||!c?"#9ca3af":"#dc2626",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"500",cursor:r||!c?"not-allowed":"pointer",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:e=>{!r&&c&&(e.currentTarget.style.backgroundColor="#b91c1c")},onMouseLeave:e=>{!r&&c&&(e.currentTarget.style.backgroundColor="#dc2626")},children:r?"Processing...":"Add Credits"})]})]})};exports.EchoProvider=function({config:e,children:t}){const[r,i]=s.useState(!1);if(s.useEffect((()=>{i(!0)}),[]),!r)return null;const o=e.apiUrl||"https://echo.merit.systems",a={userManager:"undefined"!=typeof window&&window.__echoUserManager||new ue({authority:o,client_id:e.appId,redirect_uri:e.redirectUri||window.location.origin,scope:e.scope||"llm:invoke offline_access",silentRequestTimeoutInSeconds:10,silent_redirect_uri:e.redirectUri||window.location.origin,includeIdTokenInSilentRenew:!1,validateSubOnSilentRenew:!0,loadUserInfo:!0,metadata:{authorization_endpoint:`${o}/api/oauth/authorize`,token_endpoint:`${o}/api/oauth/token`,userinfo_endpoint:`${o}/api/oauth/userinfo`,issuer:o,jwks_uri:`${o}/.well-known/jwks.json`,end_session_endpoint:`${o}/api/oauth/logout`},userStore:new C({store:window.localStorage})}),onSigninCallback:()=>{window.location.search.includes("code=")&&window.history.replaceState({},document.title,window.location.pathname)}};return n.jsx(ke,{...a,children:n.jsx(In,{config:e,children:t})})},exports.EchoSignIn=function({onSuccess:e,onError:t,className:r="",children:i}){const{signIn:o,isAuthenticated:a,isLoading:c,user:l,error:u}=Un(),[d,h]=s.useState(!1);s.useEffect((()=>{a&&l&&e&&e(l)}),[a,l,e]),s.useEffect((()=>{u&&t&&t(new Error(u))}),[u,t]);const p=async()=>{try{await o()}catch(e){t&&t(e instanceof Error?e:new Error("Sign in failed"))}};return a?n.jsx("div",{className:`echo-signin-success ${r}`,children:n.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 16px",backgroundColor:"#f8fafc",border:"1px solid #e2e8f0",borderRadius:"8px",color:"#334155",fontSize:"14px",fontFamily:"HelveticaNowDisplay, sans-serif",fontWeight:"800",width:"fit-content"},children:[n.jsx(Hs,{width:16,height:16,variant:"light"}),n.jsxs("span",{children:["Signed in as ",qs((null==l?void 0:l.name)||(null==l?void 0:l.email))]})]})}):n.jsx("div",{className:`echo-signin ${r}`,children:i?n.jsx("div",{onClick:p,style:{cursor:"pointer"},children:i}):n.jsxs("button",{onClick:p,disabled:c,className:"echo-signin-button",style:{display:"flex",alignItems:"center",gap:"8px",padding:"12px 20px",backgroundColor:c?"#f3f4f6":d?"#f1f5f9":"#ffffff",color:c?"#9ca3af":"#09090b",border:"1px solid #e2e8f0",borderRadius:"8px",cursor:c?"not-allowed":"pointer",fontSize:"14px",fontWeight:"800",fontFamily:"HelveticaNowDisplay, sans-serif",transition:"all 0.2s ease",boxShadow:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",backdropFilter:"blur(8px)"},onMouseEnter:()=>h(!0),onMouseLeave:()=>h(!1),children:[n.jsx(Hs,{width:16,height:16,variant:"light"}),n.jsx("span",{children:c?"Signing in...":"Sign in"})]})})},exports.EchoTokenPurchase=function({onPurchaseComplete:e,onError:t,className:r="",children:i}){const{createPaymentLink:o,isAuthenticated:a,balance:c,freeTierBalance:l,refreshBalance:u}=Un(),[d,h]=s.useState(!1),[p,f]=s.useState(null),[g,m]=s.useState(!1),[_,w]=s.useState(!1),y=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD"}).format(e),b=()=>{var e;return((null==(e=null==l?void 0:l.userSpendInfo)?void 0:e.amountLeft)||0)+((null==c?void 0:c.balance)||0)},S=async r=>{if(!a){const e=new Error("Please sign in to purchase tokens");return f(e.message),void(t&&t(e))}try{h(!0),f(null);const n=await o(r);await Bs(n,{onComplete:async()=>{try{await u(),m(!1),w(!1),e&&c&&e(c)}catch(r){const e=r instanceof Error?r:new Error("Failed to refresh balance");f(e.message),t&&t(e)}finally{h(!1)}},onCancel:()=>{h(!1)},onError:e=>{f(e.message),t&&t(e),h(!1)}})}catch(n){const e=n instanceof Error?n:new Error("Failed to create payment link");f(e.message),t&&t(e),h(!1)}},v=()=>{m(!1),w(!1),f(null)};if(!a)return n.jsx("div",{className:`echo-token-purchase ${r}`,children:n.jsx("div",{className:"echo-token-purchase-unauthorized",style:{padding:"12px",backgroundColor:"#fef3c7",color:"#92400e",borderRadius:"8px",fontSize:"14px"},children:"Please sign in to purchase tokens"})});const E=()=>{const[e,t]=s.useState(!1);return n.jsxs("button",{onClick:()=>m(!0),className:`echo-token-purchase-compact ${r}`,style:{display:"flex",alignItems:"center",gap:"8px",padding:"10px 12px",borderRadius:"8px",backgroundColor:e?"#f1f5f9":"#ffffff",border:"1px solid #e5e7eb",color:"#09090b",fontSize:"14px",fontWeight:"800",cursor:"pointer",backdropFilter:"blur(8px)",transition:"all 0.2s ease",boxShadow:"0 1px 2px 0 rgba(0, 0, 0, 0.05)",height:"40px",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),children:[n.jsx(Hs,{width:16,height:16,variant:"light"}),n.jsx("span",{children:y(b())}),n.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{color:e?"#dc2626":"#6b7280",transition:"color 0.2s ease"},children:[n.jsx("path",{d:"M7 7h10v10"}),n.jsx("path",{d:"M7 17 17 7"})]})]})},k=()=>n.jsx("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:1e3,padding:"16px"},onClick:e=>{e.target===e.currentTarget&&v()},children:n.jsxs("div",{style:{backgroundColor:"#ffffff",borderRadius:"12px",border:"1px solid #e5e7eb",padding:"0",width:"100%",maxWidth:"450px",maxHeight:"90vh",overflow:"hidden",boxShadow:"0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)",fontFamily:"HelveticaNowDisplay, sans-serif",display:"flex",flexDirection:"column",minHeight:"320px"},children:[n.jsx("div",{style:{padding:"16px 16px 0 16px",marginBottom:"12px"},children:n.jsx("h2",{style:{fontSize:"18px",fontWeight:"500",color:"#111827",margin:0,fontFamily:"HelveticaNowDisplay, sans-serif"},children:"Credits"})}),n.jsxs("div",{style:{padding:"0 16px",marginBottom:"16px"},children:[n.jsx("p",{style:{fontSize:"14px",color:"#6b7280",margin:"0 0 4px 0",fontFamily:"HelveticaNowDisplay, sans-serif"},children:"Total Available"}),n.jsx("p",{style:{fontSize:"28px",fontWeight:"700",color:"#111827",margin:"0 0 12px 0",fontFamily:"HelveticaNowDisplay, sans-serif"},children:y(b())}),n.jsxs("div",{style:{marginBottom:"8px"},children:[l&&b()>0&&n.jsxs("div",{style:{marginBottom:"8px"},children:[n.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",fontFamily:"HelveticaNowDisplay, sans-serif",display:"flex",alignItems:"center",gap:"6px",marginBottom:"4px"},children:[n.jsx("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#ef4444"}}),n.jsxs("span",{children:[y(l.userSpendInfo.amountLeft)," ","Free Tier",l.userSpendInfo&&l.userSpendInfo.spendLimit&&n.jsxs("span",{style:{color:"#9ca3af",marginLeft:"8px"},children:[y(l.userSpendInfo.amountSpent)," ","of"," ",y(l.userSpendInfo.spendLimit)," ","used"]})]})]}),l.userSpendInfo&&l.userSpendInfo.spendLimit&&n.jsx("div",{style:{width:"100%",height:"4px",backgroundColor:"#e5e7eb",borderRadius:"2px",overflow:"hidden",marginBottom:"4px",border:"1px solid #d1d5db"},children:n.jsx("div",{style:{width:`${Math.min(100,l.userSpendInfo.amountSpent/(l.userSpendInfo.spendLimit||1)*100)}%`,height:"100%",backgroundColor:"#dc2626"}})})]}),c&&c.balance>0&&n.jsxs("div",{style:{fontSize:"12px",color:"#6b7280",fontFamily:"HelveticaNowDisplay, sans-serif",display:"flex",alignItems:"center",gap:"6px"},children:[n.jsx("div",{style:{width:"6px",height:"6px",borderRadius:"50%",backgroundColor:"#3b82f6"}}),y(c.balance)," Paid Credits"]})]})]}),n.jsxs("div",{style:{padding:"0 16px 16px 16px",borderTop:"1px solid #f3f4f6",paddingTop:"16px"},children:[n.jsx("p",{style:{fontSize:"14px",color:"#6b7280",margin:"0 0 12px 0",fontFamily:"HelveticaNowDisplay, sans-serif"},children:"Add Credits"}),_?n.jsx(zs,{onAddCredits:S,onCancel:()=>w(!1),isProcessing:d}):n.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[n.jsx("button",{onClick:()=>S(10),disabled:d,style:{width:"100%",padding:"12px 16px",backgroundColor:d?"#9ca3af":"#dc2626",color:"white",border:"none",borderRadius:"6px",fontSize:"14px",fontWeight:"600",cursor:d?"not-allowed":"pointer",transition:"background-color 0.2s ease",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:e=>{d||(e.currentTarget.style.backgroundColor="#b91c1c")},onMouseLeave:e=>{d||(e.currentTarget.style.backgroundColor="#dc2626")},children:d?"Processing...":"Add $10 Credits"}),n.jsx("button",{onClick:()=>w(!0),style:{width:"100%",padding:"8px 16px",fontSize:"14px",color:"#6b7280",backgroundColor:"transparent",border:"1px solid #e5e7eb",borderRadius:"6px",cursor:"pointer",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:e=>{e.currentTarget.style.color="#111827",e.currentTarget.style.borderColor="#d1d5db"},onMouseLeave:e=>{e.currentTarget.style.color="#6b7280",e.currentTarget.style.borderColor="#e5e7eb"},children:"Choose different amount"})]})]}),p&&n.jsx("div",{style:{margin:"0 16px 12px 16px",padding:"8px 12px",backgroundColor:"#fee2e2",color:"#dc2626",borderRadius:"6px",fontSize:"14px",fontFamily:"HelveticaNowDisplay, sans-serif"},children:p}),n.jsx("div",{style:{padding:"12px 16px",display:"flex",justifyContent:"flex-end",borderTop:"1px solid #f3f4f6"},children:n.jsx("button",{onClick:v,style:{padding:"8px 16px",backgroundColor:"#f3f4f6",color:"#374151",border:"none",borderRadius:"6px",fontSize:"14px",cursor:"pointer",fontFamily:"HelveticaNowDisplay, sans-serif"},onMouseEnter:e=>{e.currentTarget.style.backgroundColor="#e5e7eb"},onMouseLeave:e=>{e.currentTarget.style.backgroundColor="#f3f4f6"},children:"Close"})})]})});return n.jsxs(n.Fragment,{children:[i?n.jsx("div",{onClick:()=>m(!0),style:{cursor:"pointer"},children:i}):n.jsx(E,{}),g&&n.jsx(k,{})]})},exports.Logo=Hs,exports.useEcho=Un,exports.useEchoClient=Nn,exports.useEchoOpenAI=function(e={}){const{baseURL:t="https://echo.router.merit.systems",enabled:r=!0}=e,{token:n,isAuthenticated:i}=Un(),[o,a]=s.useState(void 0),[c,l]=s.useState(null),[u,d]=s.useState(!1),h=s.useRef(null);return s.useEffect((()=>{if(h.current&&h.current.abort(),!r||!n||!i)return a(void 0),l(null),void d(!1);return(async()=>{const e=new AbortController;h.current=e,d(!0),l(null);try{if(e.signal.aborted)return;const{default:r}=await import("openai");if(e.signal.aborted)return;const s=new r({apiKey:n,baseURL:t,dangerouslyAllowBrowser:!0});e.signal.aborted||a(s)}catch(r){if(!e.signal.aborted){const e=r instanceof Error?r.message:"Failed to load OpenAI";e.includes("Cannot resolve module")||e.includes("Module not found")||e.includes("openai")?l("OpenAI package not found. Please install it with: pnpm add openai"):l(`Failed to initialize OpenAI client: ${e}`),console.error("Error loading OpenAI:",r),a(void 0)}}finally{e.signal.aborted||d(!1)}})(),()=>{h.current&&h.current.abort()}}),[n,i,t,r]),{openai:o,isReady:void 0!==o&&!u,error:c,isLoading:u}};
|
|
4
4
|
//# sourceMappingURL=index.cjs.map
|