vbss-translator 1.1.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +47 -4
- package/dist/cli/index.js +24 -24
- package/dist/generator.cjs +17 -17
- package/dist/generator.js +304 -187
- package/dist/vbss-translator.js +2035 -1383
- package/dist/vbss-translator.umd.cjs +9 -9
- package/package.json +121 -111
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
(function(k,j){typeof exports=="object"&&typeof module<"u"?j(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],j):(k=typeof globalThis<"u"?globalThis:k||self,j(k["vbss/translator"]={},k.ReactJSXRuntime,k.React))})(this,(function(k,j,T){"use strict";var Ir=Object.defineProperty;var Hr=(k,j,T)=>j in k?Ir(k,j,{enumerable:!0,configurable:!0,writable:!0,value:T}):k[j]=T;var I=(k,j,T)=>Hr(k,typeof j!="symbol"?j+"":j,T);const Ke=T.createContext(null),Ut=()=>{const t=T.useContext(Ke);if(!t)throw new Error("useTranslatorContext must be used within a TranslatorProvider");return t};class $e extends Error{constructor(n){super(n);I(this,"code","timeout");this.name="ExternalTranslationTimeoutError"}}const Mt="auto",ge=t=>typeof t=="number"&&Number.isFinite(t)&&t>0,jt=t=>{const e=Object.entries(t).sort(([n],[r])=>n===r?0:n<r?-1:1);return Object.fromEntries(e)};class Bt{constructor(e){I(this,"provider");I(this,"config");I(this,"cache");I(this,"logger");I(this,"inFlight",new Map);this.provider=e.provider,this.config=e.config,this.cache=e.cache,this.logger=e.logger}isEnabled(){return this.config.enabled}async translate(e){if(!this.isEnabled()){this.debug("external_translation_disabled",{key:e.key,targetLanguage:e.targetLanguage});return}const n=this.normalizeRequest(e);if(!await this.shouldTranslate(n.externalRequest)){this.debug("external_translation_skipped",{key:n.externalRequest.key,targetLanguage:n.externalRequest.targetLanguage});return}const r=this.readFromCache(n.cacheKey);if(r)return this.debug("external_translation_cache_hit",{key:n.externalRequest.key,cacheKey:n.cacheKey}),r;const s=this.inFlight.get(n.cacheKey);if(s)return this.debug("external_translation_deduped",{key:n.externalRequest.key,cacheKey:n.cacheKey}),s;const o=this.executeTranslation(n);return this.inFlight.set(n.cacheKey,o),o}normalizeRequest(e){const n=e.sourceLanguage??Mt,r={text:e.text,sourceLanguage:n,targetLanguage:e.targetLanguage,glossary:e.glossary},s=this.createCacheKey(r),o=ge(e.timeoutMs)?e.timeoutMs:this.config.timeoutMs;return{externalRequest:{key:e.key,text:e.text,targetLanguage:e.targetLanguage,sourceLanguage:n},translateRequest:r,cacheKey:s,timeoutMs:o,signal:e.signal}}async shouldTranslate(e){if(!this.config.shouldTranslate)return!0;try{return this.config.shouldTranslate(e)}catch(n){return this.warn("external_translation_should_translate_error",{key:e.key,language:e.targetLanguage,error:n}),!0}}async executeTranslation(e){try{if(!await this.invokeExternalTranslationHook(e.externalRequest)){this.debug("external_translation_vetoed",{key:e.externalRequest.key,targetLanguage:e.externalRequest.targetLanguage});return}this.debug("external_translation_started",{key:e.externalRequest.key,cacheKey:e.cacheKey});const n=await this.translateWithTimeout(e.translateRequest,e.timeoutMs,e.signal);return this.writeToCache(e.cacheKey,n),this.notifyTranslationComplete(n),this.debug("external_translation_succeeded",{key:e.externalRequest.key,cacheKey:e.cacheKey}),n}catch(n){const r=this.normalizeError(n);this.handleTranslationError(e,r);return}finally{this.inFlight.delete(e.cacheKey)}}async invokeExternalTranslationHook(e){const n=this.config.onExternalTranslation;if(!n)return!0;try{const r=await n(e);return typeof r=="boolean"?r:!0}catch(r){return this.warn("external_translation_hook_error",{key:e.key,language:e.targetLanguage,error:r}),!0}}async translateWithTimeout(e,n,r){if(!(typeof AbortController=="function"))return this.provider.translate(e,{timeoutMs:ge(n)?n:void 0,signal:r});const o=new AbortController;let i=!1,l;r&&(r.aborted?o.abort():(l=()=>{o.abort()},r.addEventListener("abort",l,{once:!0})));const f=ge(n)&&n?setTimeout(()=>{i=!0,o.abort()},n):void 0;try{return await this.provider.translate(e,{timeoutMs:ge(n)?n:void 0,signal:o.signal})}catch(u){throw i?new $e(`External translation timed out after ${n}ms`):(o.signal.aborted&&!i,u)}finally{f&&clearTimeout(f),l&&r&&r.removeEventListener("abort",l)}}readFromCache(e){var n;return(n=this.cache)==null?void 0:n.get(e)}writeToCache(e,n){var r;(r=this.cache)==null||r.set(e,n)}handleTranslationError(e,n){const r={key:e.externalRequest.key,language:e.externalRequest.targetLanguage,originalText:e.externalRequest.text,error:n};this.notifyTranslationError(r),this.warn("external_fallback_failed",{provider:this.provider.type,key:r.key,language:r.language,errorCode:n.code,retryable:n.retryable,message:n.message,details:n.details})}normalizeError(e){return this.provider.normalizeError?this.provider.normalizeError(e):e instanceof $e?{code:"timeout",message:e.message,retryable:!0,details:e}:e instanceof Error?{code:e.name||"unknown_error",message:e.message,retryable:!1,details:e}:{code:"unknown_error",message:"Unknown provider error",retryable:!1,details:e}}createCacheKey(e){return[e.sourceLanguage,e.targetLanguage,this.hashText(e.text,e.glossary)].join("|")}hashText(e,n){let r=2166136261;const s=n&&Object.keys(n).length>0?`${e}|${JSON.stringify(jt(n))}`:e;for(let o=0;o<s.length;o+=1)r^=s.charCodeAt(o),r+=(r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24);return(r>>>0).toString(16)}warn(e,n){const r={scope:"translator",event:e,...n};if(this.logger){this.logger.warn(e,r);return}console.warn("[vbss-translator]",r)}debug(e,n){var s;if(!this.config.debug)return;const r={scope:"translator",event:e,...n};if((s=this.logger)!=null&&s.debug){this.logger.debug(e,r);return}console.debug("[vbss-translator]",r)}notifyTranslationComplete(e){const n=this.config.onTranslationComplete;if(n)try{n(e)}catch(r){this.warn("external_translation_complete_callback_error",{provider:this.provider.type,error:r})}}notifyTranslationError(e){const n=this.config.onTranslationError;if(n)try{n(e)}catch(r){this.warn("external_translation_error_callback_error",{provider:this.provider.type,key:e.key,language:e.language,error:r})}}}const Ce=()=>Date.now(),me=t=>typeof t=="number"&&Number.isFinite(t)&&t>0;class It{constructor(e){I(this,"store",new Map);I(this,"enabled");I(this,"ttlMs");I(this,"maxEntries");this.enabled=e.enabled,this.ttlMs=Math.max(0,e.ttlMs),this.maxEntries=e.maxEntries}isEnabled(){return this.enabled}setEnabled(e){e||this.clear(),this.enabled=e}setTtl(e){this.ttlMs=Math.max(0,e)}size(){return this.store.size}clear(){this.store.clear()}get(e){if(!this.enabled)return;const n=this.store.get(e);if(n){if(this.isExpired(n)){this.store.delete(e);return}return n.value}}set(e,n,r){if(!this.enabled)return;const s=me(r)?r:this.ttlMs,o=me(s)?Ce()+s:void 0;this.store.set(e,{value:n,expiresAt:o,insertedAt:Ce()}),this.enforceMaxEntries()}delete(e){this.store.delete(e)}has(e){if(!this.enabled)return!1;const n=this.store.get(e);return n?this.isExpired(n)?(this.store.delete(e),!1):!0:!1}entries(){const e=[];for(const[n,r]of this.store.entries()){if(this.isExpired(r)){this.store.delete(n);continue}e.push({key:n,result:r.value,expiresAt:r.expiresAt})}return e}prune(){for(const[e,n]of this.store.entries())this.isExpired(n)&&this.store.delete(e)}enforceMaxEntries(){if(!me(this.maxEntries))return;const e=this.maxEntries;for(;this.store.size>e;){const n=this.findOldestKey();if(!n)break;this.store.delete(n)}}findOldestKey(){let e,n=Number.POSITIVE_INFINITY;for(const[r,s]of this.store.entries())s.insertedAt<n&&(e=r,n=s.insertedAt);return e}isExpired(e){return me(e.expiresAt)?e.expiresAt<=Ce():!1}}function Ve(t,e){return function(){return t.apply(e,arguments)}}const{toString:Ht}=Object.prototype,{getPrototypeOf:ye}=Object,{iterator:be,toStringTag:ze}=Symbol,Ee=(t=>e=>{const n=Ht.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),K=t=>(t=t.toLowerCase(),e=>Ee(e)===t),we=t=>e=>typeof e===t,{isArray:ne}=Array,re=we("undefined");function ie(t){return t!==null&&!re(t)&&t.constructor!==null&&!re(t.constructor)&&F(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Je=K("ArrayBuffer");function qt(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Je(t.buffer),e}const Kt=we("string"),F=we("function"),We=we("number"),ae=t=>t!==null&&typeof t=="object",$t=t=>t===!0||t===!1,Re=t=>{if(Ee(t)!=="object")return!1;const e=ye(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(ze in t)&&!(be in t)},Vt=t=>{if(!ae(t)||ie(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},zt=K("Date"),Jt=K("File"),Wt=t=>!!(t&&typeof t.uri<"u"),Xt=t=>t&&typeof t.getParts<"u",Gt=K("Blob"),Qt=K("FileList"),Yt=t=>ae(t)&&F(t.pipe);function Zt(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const Xe=Zt(),Ge=typeof Xe.FormData<"u"?Xe.FormData:void 0,en=t=>{if(!t)return!1;if(Ge&&t instanceof Ge)return!0;const e=ye(t);if(!e||e===Object.prototype||!F(t.append))return!1;const n=Ee(t);return n==="formdata"||n==="object"&&F(t.toString)&&t.toString()==="[object FormData]"},tn=K("URLSearchParams"),[nn,rn,sn,on]=["ReadableStream","Request","Response","Headers"].map(K),an=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function le(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,s;if(typeof t!="object"&&(t=[t]),ne(t))for(r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else{if(ie(t))return;const o=n?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length;let l;for(r=0;r<i;r++)l=o[r],e.call(null,t[l],l,t)}}function Qe(t,e){if(ie(t))return null;e=e.toLowerCase();const n=Object.keys(t);let r=n.length,s;for(;r-- >0;)if(s=n[r],e===s.toLowerCase())return s;return null}const Q=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Ye=t=>!re(t)&&t!==Q;function Pe(){const{caseless:t,skipUndefined:e}=Ye(this)&&this||{},n={},r=(s,o)=>{if(o==="__proto__"||o==="constructor"||o==="prototype")return;const i=t&&Qe(n,o)||o;Re(n[i])&&Re(s)?n[i]=Pe(n[i],s):Re(s)?n[i]=Pe({},s):ne(s)?n[i]=s.slice():(!e||!re(s))&&(n[i]=s)};for(let s=0,o=arguments.length;s<o;s++)arguments[s]&&le(arguments[s],r);return n}const ln=(t,e,n,{allOwnKeys:r}={})=>(le(e,(s,o)=>{n&&F(s)?Object.defineProperty(t,o,{value:Ve(s,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,o,{value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),cn=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),un=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),Object.defineProperty(t.prototype,"constructor",{value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{value:e.prototype}),n&&Object.assign(t.prototype,n)},dn=(t,e,n,r)=>{let s,o,i;const l={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),o=s.length;o-- >0;)i=s[o],(!r||r(i,t,e))&&!l[i]&&(e[i]=t[i],l[i]=!0);t=n!==!1&&ye(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},fn=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return r!==-1&&r===n},hn=t=>{if(!t)return null;if(ne(t))return t;let e=t.length;if(!We(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},pn=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&ye(Uint8Array)),gn=(t,e)=>{const r=(t&&t[be]).call(t);let s;for(;(s=r.next())&&!s.done;){const o=s.value;e.call(t,o[0],o[1])}},mn=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},yn=K("HTMLFormElement"),bn=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ze=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),En=K("RegExp"),et=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};le(n,(s,o)=>{let i;(i=e(s,o,t))!==!1&&(r[o]=i||s)}),Object.defineProperties(t,r)},wn=t=>{et(t,(e,n)=>{if(F(t)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=t[n];if(F(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},Rn=(t,e)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return ne(t)?r(t):r(String(t).split(e)),n},Tn=()=>{},xn=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function Sn(t){return!!(t&&F(t.append)&&t[ze]==="FormData"&&t[be])}const On=t=>{const e=new Array(10),n=(r,s)=>{if(ae(r)){if(e.indexOf(r)>=0)return;if(ie(r))return r;if(!("toJSON"in r)){e[s]=r;const o=ne(r)?[]:{};return le(r,(i,l)=>{const f=n(i,s+1);!re(f)&&(o[l]=f)}),e[s]=void 0,o}}return r};return n(t,0)},_n=K("AsyncFunction"),An=t=>t&&(ae(t)||F(t))&&F(t.then)&&F(t.catch),tt=((t,e)=>t?setImmediate:e?((n,r)=>(Q.addEventListener("message",({source:s,data:o})=>{s===Q&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),Q.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",F(Q.postMessage)),Cn=typeof queueMicrotask<"u"?queueMicrotask.bind(Q):typeof process<"u"&&process.nextTick||tt,a={isArray:ne,isArrayBuffer:Je,isBuffer:ie,isFormData:en,isArrayBufferView:qt,isString:Kt,isNumber:We,isBoolean:$t,isObject:ae,isPlainObject:Re,isEmptyObject:Vt,isReadableStream:nn,isRequest:rn,isResponse:sn,isHeaders:on,isUndefined:re,isDate:zt,isFile:Jt,isReactNativeBlob:Wt,isReactNative:Xt,isBlob:Gt,isRegExp:En,isFunction:F,isStream:Yt,isURLSearchParams:tn,isTypedArray:pn,isFileList:Qt,forEach:le,merge:Pe,extend:ln,trim:an,stripBOM:cn,inherits:un,toFlatObject:dn,kindOf:Ee,kindOfTest:K,endsWith:fn,toArray:hn,forEachEntry:gn,matchAll:mn,isHTMLForm:yn,hasOwnProperty:Ze,hasOwnProp:Ze,reduceDescriptors:et,freezeMethods:wn,toObjectSet:Rn,toCamelCase:bn,noop:Tn,toFiniteNumber:xn,findKey:Qe,global:Q,isContextDefined:Ye,isSpecCompliantForm:Sn,toJSONObject:On,isAsyncFn:_n,isThenable:An,setImmediate:tt,asap:Cn,isIterable:t=>t!=null&&F(t[be])};let y=class Dt extends Error{static from(e,n,r,s,o,i){const l=new Dt(e.message,n||e.code,r,s,o);return l.cause=e,l.name=e.name,e.status!=null&&l.status==null&&(l.status=e.status),i&&Object.assign(l,i),l}constructor(e,n,r,s,o){super(e),Object.defineProperty(this,"message",{value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),s&&(this.request=s),o&&(this.response=o,this.status=o.status)}toJSON(){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:a.toJSONObject(this.config),code:this.code,status:this.status}}};y.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",y.ERR_BAD_OPTION="ERR_BAD_OPTION",y.ECONNABORTED="ECONNABORTED",y.ETIMEDOUT="ETIMEDOUT",y.ERR_NETWORK="ERR_NETWORK",y.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",y.ERR_DEPRECATED="ERR_DEPRECATED",y.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",y.ERR_BAD_REQUEST="ERR_BAD_REQUEST",y.ERR_CANCELED="ERR_CANCELED",y.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",y.ERR_INVALID_URL="ERR_INVALID_URL",y.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const Pn=null;function Le(t){return a.isPlainObject(t)||a.isArray(t)}function nt(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function ke(t,e,n){return t?t.concat(e).map(function(s,o){return s=nt(s),!n&&o?"["+s+"]":s}).join(n?".":""):e}function Ln(t){return a.isArray(t)&&!t.some(Le)}const kn=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function Te(t,e,n){if(!a.isObject(t))throw new TypeError("target must be an object");e=e||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,S){return!a.isUndefined(S[h])});const r=n.metaTokens,s=n.visitor||d,o=n.dots,i=n.indexes,l=n.Blob||typeof Blob<"u"&&Blob,f=n.maxDepth===void 0?100:n.maxDepth,u=l&&a.isSpecCompliantForm(e);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function c(g){if(g===null)return"";if(a.isDate(g))return g.toISOString();if(a.isBoolean(g))return g.toString();if(!u&&a.isBlob(g))throw new y("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(g)||a.isTypedArray(g)?u&&typeof Blob=="function"?new Blob([g]):Buffer.from(g):g}function d(g,h,S){let q=g;if(a.isReactNative(e)&&a.isReactNativeBlob(g))return e.append(ke(S,h,o),c(g)),!1;if(g&&!S&&typeof g=="object"){if(a.endsWith(h,"{}"))h=r?h:h.slice(0,-2),g=JSON.stringify(g);else if(a.isArray(g)&&Ln(g)||(a.isFileList(g)||a.endsWith(h,"[]"))&&(q=a.toArray(g)))return h=nt(h),q.forEach(function(x,N){!(a.isUndefined(x)||x===null)&&e.append(i===!0?ke([h],N,o):i===null?h:h+"[]",c(x))}),!1}return Le(g)?!0:(e.append(ke(S,h,o),c(g)),!1)}const R=[],_=Object.assign(kn,{defaultVisitor:d,convertValue:c,isVisitable:Le});function p(g,h,S=0){if(!a.isUndefined(g)){if(S>f)throw new y("Object is too deeply nested ("+S+" levels). Max depth: "+f,y.ERR_FORM_DATA_DEPTH_EXCEEDED);if(R.indexOf(g)!==-1)throw Error("Circular reference detected in "+h.join("."));R.push(g),a.forEach(g,function(O,x){(!(a.isUndefined(O)||O===null)&&s.call(e,O,a.isString(x)?x.trim():x,h,_))===!0&&p(O,h?h.concat(x):[x],S+1)}),R.pop()}}if(!a.isObject(t))throw new TypeError("data must be an object");return p(t),e}function rt(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return e[r]})}function ve(t,e){this._pairs=[],t&&Te(t,this,e)}const st=ve.prototype;st.append=function(e,n){this._pairs.push([e,n])},st.toString=function(e){const n=e?function(r){return e.call(this,r,rt)}:rt;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function vn(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function ot(t,e,n){if(!e)return t;const r=n&&n.encode||vn,s=a.isFunction(n)?{serialize:n}:n,o=s&&s.serialize;let i;if(o?i=o(e,s):i=a.isURLSearchParams(e)?e.toString():new ve(e,s).toString(r),i){const l=t.indexOf("#");l!==-1&&(t=t.slice(0,l)),t+=(t.indexOf("?")===-1?"?":"&")+i}return t}class it{constructor(){this.handlers=[]}use(e,n,r){return this.handlers.push({fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,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){a.forEach(this.handlers,function(r){r!==null&&e(r)})}}const Ne={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0},Nn={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ve,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},De=typeof window<"u"&&typeof document<"u",Fe=typeof navigator=="object"&&navigator||void 0,Dn=De&&(!Fe||["ReactNative","NativeScript","NS"].indexOf(Fe.product)<0),Fn=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Un=De&&window.location.href||"http://localhost",v={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:De,hasStandardBrowserEnv:Dn,hasStandardBrowserWebWorkerEnv:Fn,navigator:Fe,origin:Un},Symbol.toStringTag,{value:"Module"})),...Nn};function Mn(t,e){return Te(t,new v.classes.URLSearchParams,{visitor:function(n,r,s,o){return v.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}function jn(t){return a.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function Bn(t){const e={},n=Object.keys(t);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],e[o]=t[o];return e}function at(t){function e(n,r,s,o){let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),f=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,f?(a.hasOwnProp(s,i)?s[i]=a.isArray(s[i])?s[i].concat(r):[s[i],r]:s[i]=r,!l):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),e(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=Bn(s[i])),!l)}if(a.isFormData(t)&&a.isFunction(t.entries)){const n={};return a.forEachEntry(t,(r,s)=>{e(jn(r),s,n,0)}),n}return null}const se=(t,e)=>t!=null&&a.hasOwnProp(t,e)?t[e]:void 0;function In(t,e,n){if(a.isString(t))try{return(e||JSON.parse)(t),a.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const ce={transitional:Ne,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(e);if(o&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return s?JSON.stringify(at(e)):e;if(a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)||a.isReadableStream(e))return e;if(a.isArrayBufferView(e))return e.buffer;if(a.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(o){const f=se(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return Mn(e,f).toString();if((l=a.isFileList(e))||r.indexOf("multipart/form-data")>-1){const u=se(this,"env"),c=u&&u.FormData;return Te(l?{"files[]":e}:e,c&&new c,f)}}return o||s?(n.setContentType("application/json",!1),In(e)):e}],transformResponse:[function(e){const n=se(this,"transitional")||ce.transitional,r=n&&n.forcedJSONParsing,s=se(this,"responseType"),o=s==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(r&&!s||o)){const l=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(e,se(this,"parseReviver"))}catch(f){if(l)throw f.name==="SyntaxError"?y.from(f,y.ERR_BAD_RESPONSE,this,null,se(this,"response")):f}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:v.classes.FormData,Blob:v.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],t=>{ce.headers[t]={}});const Hn=a.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"]),qn=t=>{const e={};let n,r,s;return t&&t.split(`
|
|
2
|
-
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim()
|
|
3
|
-
`)}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,...n){const r=new this(e);return n.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[lt]=this[lt]={accessors:{}}).accessors,s=this.prototype;function o(i){const l=ue(i);r[l]||(Xn(s,i),r[l]=!0)}return a.isArray(e)?e.forEach(o):o(e),this}};U.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(U.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}}),a.freezeMethods(U);function Me(t,e){const n=this||ce,r=e||n,s=U.from(r.headers);let o=r.data;return a.forEach(t,function(l){o=l.call(n,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function ct(t){return!!(t&&t.__CANCEL__)}let de=class extends y{constructor(e,n,r){super(e??"canceled",y.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function ut(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new y("Request failed with status code "+n.status,[y.ERR_BAD_REQUEST,y.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Gn(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Qn(t,e){t=t||10;const n=new Array(t),r=new Array(t);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(f){const u=Date.now(),c=r[o];i||(i=u),n[s]=f,r[s]=u;let d=o,R=0;for(;d!==s;)R+=n[d++],d=d%t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),u-i<e)return;const _=c&&u-c;return _?Math.round(R*1e3/_):void 0}}function Yn(t,e){let n=0,r=1e3/e,s,o;const i=(u,c=Date.now())=>{n=c,s=null,o&&(clearTimeout(o),o=null),t(...u)};return[(...u)=>{const c=Date.now(),d=c-n;d>=r?i(u,c):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-d)))},()=>s&&i(s)]}const Se=(t,e,n=3)=>{let r=0;const s=Qn(50,250);return Yn(o=>{const i=o.loaded,l=o.lengthComputable?o.total:void 0,f=l!=null?Math.min(i,l):i,u=Math.max(0,f-r),c=s(u);r=Math.max(r,f);const d={loaded:f,total:l,progress:l?f/l:void 0,bytes:u,rate:c||void 0,estimated:c&&l?(l-f)/c:void 0,event:o,lengthComputable:l!=null,[e?"download":"upload"]:!0};t(d)},n)},dt=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},ft=t=>(...e)=>a.asap(()=>t(...e)),Zn=v.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,v.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(v.origin),v.navigator&&/(msie|trident)/i.test(v.navigator.userAgent)):()=>!0,er=v.hasStandardBrowserEnv?{write(t,e,n,r,s,o,i){if(typeof document>"u")return;const l=[`${t}=${encodeURIComponent(e)}`];a.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&l.push(`path=${r}`),a.isString(s)&&l.push(`domain=${s}`),o===!0&&l.push("secure"),a.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(t){if(typeof document>"u")return null;const e=document.cookie.match(new RegExp("(?:^|; )"+t+"=([^;]*)"));return e?decodeURIComponent(e[1]):null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function tr(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function nr(t,e){return e?t.replace(/\/?\/$/,"")+"/"+e.replace(/^\/+/,""):t}function ht(t,e,n){let r=!tr(e);return t&&(r||n===!1)?nr(t,e):e}const pt=t=>t instanceof U?{...t}:t;function Y(t,e){e=e||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(u,c,d,R){return a.isPlainObject(u)&&a.isPlainObject(c)?a.merge.call({caseless:R},u,c):a.isPlainObject(c)?a.merge({},c):a.isArray(c)?c.slice():c}function s(u,c,d,R){if(a.isUndefined(c)){if(!a.isUndefined(u))return r(void 0,u,d,R)}else return r(u,c,d,R)}function o(u,c){if(!a.isUndefined(c))return r(void 0,c)}function i(u,c){if(a.isUndefined(c)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,c)}function l(u,c,d){if(a.hasOwnProp(e,d))return r(u,c);if(a.hasOwnProp(t,d))return r(void 0,u)}const f={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,allowedSocketPaths:i,responseEncoding:i,validateStatus:l,headers:(u,c,d)=>s(pt(u),pt(c),d,!0)};return a.forEach(Object.keys({...t,...e}),function(c){if(c==="__proto__"||c==="constructor"||c==="prototype")return;const d=a.hasOwnProp(f,c)?f[c]:s,R=a.hasOwnProp(t,c)?t[c]:void 0,_=a.hasOwnProp(e,c)?e[c]:void 0,p=d(R,_,c);a.isUndefined(p)&&d!==l||(n[c]=p)}),n}const gt=t=>{const e=Y({},t),n=R=>a.hasOwnProp(e,R)?e[R]:void 0,r=n("data");let s=n("withXSRFToken");const o=n("xsrfHeaderName"),i=n("xsrfCookieName");let l=n("headers");const f=n("auth"),u=n("baseURL"),c=n("allowAbsoluteUrls"),d=n("url");if(e.headers=l=U.from(l),e.url=ot(ht(u,d,c),t.params,t.paramsSerializer),f&&l.set("Authorization","Basic "+btoa((f.username||"")+":"+(f.password?unescape(encodeURIComponent(f.password)):""))),a.isFormData(r)){if(v.hasStandardBrowserEnv||v.hasStandardBrowserWebWorkerEnv)l.setContentType(void 0);else if(a.isFunction(r.getHeaders)){const R=r.getHeaders(),_=["content-type","content-length"];Object.entries(R).forEach(([p,g])=>{_.includes(p.toLowerCase())&&l.set(p,g)})}}if(v.hasStandardBrowserEnv&&(a.isFunction(s)&&(s=s(e)),s===!0||s==null&&Zn(e.url))){const _=o&&i&&er.read(i);_&&l.set(o,_)}return e},rr=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(n,r){const s=gt(t);let o=s.data;const i=U.from(s.headers).normalize();let{responseType:l,onUploadProgress:f,onDownloadProgress:u}=s,c,d,R,_,p;function g(){_&&_(),p&&p(),s.cancelToken&&s.cancelToken.unsubscribe(c),s.signal&&s.signal.removeEventListener("abort",c)}let h=new XMLHttpRequest;h.open(s.method.toUpperCase(),s.url,!0),h.timeout=s.timeout;function S(){if(!h)return;const O=U.from("getAllResponseHeaders"in h&&h.getAllResponseHeaders()),N={data:!l||l==="text"||l==="json"?h.responseText:h.response,status:h.status,statusText:h.statusText,headers:O,config:t,request:h};ut(function(D){n(D),g()},function(D){r(D),g()},N),h=null}"onloadend"in h?h.onloadend=S:h.onreadystatechange=function(){!h||h.readyState!==4||h.status===0&&!(h.responseURL&&h.responseURL.indexOf("file:")===0)||setTimeout(S)},h.onabort=function(){h&&(r(new y("Request aborted",y.ECONNABORTED,t,h)),h=null)},h.onerror=function(x){const N=x&&x.message?x.message:"Network Error",z=new y(N,y.ERR_NETWORK,t,h);z.event=x||null,r(z),h=null},h.ontimeout=function(){let x=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const N=s.transitional||Ne;s.timeoutErrorMessage&&(x=s.timeoutErrorMessage),r(new y(x,N.clarifyTimeoutError?y.ETIMEDOUT:y.ECONNABORTED,t,h)),h=null},o===void 0&&i.setContentType(null),"setRequestHeader"in h&&a.forEach(i.toJSON(),function(x,N){h.setRequestHeader(N,x)}),a.isUndefined(s.withCredentials)||(h.withCredentials=!!s.withCredentials),l&&l!=="json"&&(h.responseType=s.responseType),u&&([R,p]=Se(u,!0),h.addEventListener("progress",R)),f&&h.upload&&([d,_]=Se(f),h.upload.addEventListener("progress",d),h.upload.addEventListener("loadend",_)),(s.cancelToken||s.signal)&&(c=O=>{h&&(r(!O||O.type?new de(null,t,h):O),h.abort(),h=null)},s.cancelToken&&s.cancelToken.subscribe(c),s.signal&&(s.signal.aborted?c():s.signal.addEventListener("abort",c)));const q=Gn(s.url);if(q&&v.protocols.indexOf(q)===-1){r(new y("Unsupported protocol "+q+":",y.ERR_BAD_REQUEST,t));return}h.send(o||null)})},sr=(t,e)=>{const{length:n}=t=t?t.filter(Boolean):[];if(e||n){let r=new AbortController,s;const o=function(u){if(!s){s=!0,l();const c=u instanceof Error?u:this.reason;r.abort(c instanceof y?c:new de(c instanceof Error?c.message:c))}};let i=e&&setTimeout(()=>{i=null,o(new y(`timeout of ${e}ms exceeded`,y.ETIMEDOUT))},e);const l=()=>{t&&(i&&clearTimeout(i),i=null,t.forEach(u=>{u.unsubscribe?u.unsubscribe(o):u.removeEventListener("abort",o)}),t=null)};t.forEach(u=>u.addEventListener("abort",o));const{signal:f}=r;return f.unsubscribe=()=>a.asap(l),f}},or=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let r=0,s;for(;r<n;)s=r+e,yield t.slice(r,s),r=s},ir=async function*(t,e){for await(const n of ar(t))yield*or(n,e)},ar=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},mt=(t,e,n,r)=>{const s=ir(t,e);let o=0,i,l=f=>{i||(i=!0,r&&r(f))};return new ReadableStream({async pull(f){try{const{done:u,value:c}=await s.next();if(u){l(),f.close();return}let d=c.byteLength;if(n){let R=o+=d;n(R)}f.enqueue(new Uint8Array(c))}catch(u){throw l(u),u}},cancel(f){return l(f),s.return()}},{highWaterMark:2})},yt=64*1024,{isFunction:Oe}=a,lr=(({Request:t,Response:e})=>({Request:t,Response:e}))(a.global),{ReadableStream:bt,TextEncoder:Et}=a.global,wt=(t,...e)=>{try{return!!t(...e)}catch{return!1}},cr=t=>{t=a.merge.call({skipUndefined:!0},lr,t);const{fetch:e,Request:n,Response:r}=t,s=e?Oe(e):typeof fetch=="function",o=Oe(n),i=Oe(r);if(!s)return!1;const l=s&&Oe(bt),f=s&&(typeof Et=="function"?(p=>g=>p.encode(g))(new Et):async p=>new Uint8Array(await new n(p).arrayBuffer())),u=o&&l&&wt(()=>{let p=!1;const g=new n(v.origin,{body:new bt,method:"POST",get duplex(){return p=!0,"half"}}),h=g.headers.has("Content-Type");return g.body!=null&&g.body.cancel(),p&&!h}),c=i&&l&&wt(()=>a.isReadableStream(new r("").body)),d={stream:c&&(p=>p.body)};s&&["text","arrayBuffer","blob","formData","stream"].forEach(p=>{!d[p]&&(d[p]=(g,h)=>{let S=g&&g[p];if(S)return S.call(g);throw new y(`Response type '${p}' is not supported`,y.ERR_NOT_SUPPORT,h)})});const R=async p=>{if(p==null)return 0;if(a.isBlob(p))return p.size;if(a.isSpecCompliantForm(p))return(await new n(v.origin,{method:"POST",body:p}).arrayBuffer()).byteLength;if(a.isArrayBufferView(p)||a.isArrayBuffer(p))return p.byteLength;if(a.isURLSearchParams(p)&&(p=p+""),a.isString(p))return(await f(p)).byteLength},_=async(p,g)=>{const h=a.toFiniteNumber(p.getContentLength());return h??R(g)};return async p=>{let{url:g,method:h,data:S,signal:q,cancelToken:O,timeout:x,onDownloadProgress:N,onUploadProgress:z,responseType:D,headers:B,withCredentials:V="same-origin",fetchOptions:he}=gt(p),ee=e||fetch;D=D?(D+"").toLowerCase():"text";let te=sr([q,O&&O.toAbortSignal()],x),X=null;const J=te&&te.unsubscribe&&(()=>{te.unsubscribe()});let m;try{if(z&&u&&h!=="get"&&h!=="head"&&(m=await _(B,S))!==0){let P=new n(g,{method:"POST",body:S,duplex:"half"}),L;if(a.isFormData(S)&&(L=P.headers.get("content-type"))&&B.setContentType(L),P.body){const[$,oe]=dt(m,Se(ft(z)));S=mt(P.body,yt,$,oe)}}a.isString(V)||(V=V?"include":"omit");const b=o&&"credentials"in n.prototype;if(a.isFormData(S)){const P=B.getContentType();P&&/^multipart\/form-data/i.test(P)&&!/boundary=/i.test(P)&&B.delete("content-type")}const w={...he,signal:te,method:h.toUpperCase(),headers:B.normalize().toJSON(),body:S,duplex:"half",credentials:b?V:void 0};X=o&&new n(g,w);let E=await(o?ee(X,he):ee(g,w));const C=c&&(D==="stream"||D==="response");if(c&&(N||C&&J)){const P={};["status","statusText","headers"].forEach(pe=>{P[pe]=E[pe]});const L=a.toFiniteNumber(E.headers.get("content-length")),[$,oe]=N&&dt(L,Se(ft(N),!0))||[];E=new r(mt(E.body,yt,$,()=>{oe&&oe(),J&&J()}),P)}D=D||"text";let G=await d[a.findKey(d,D)||"text"](E,p);return!C&&J&&J(),await new Promise((P,L)=>{ut(P,L,{data:G,headers:U.from(E.headers),status:E.status,statusText:E.statusText,config:p,request:X})})}catch(b){throw J&&J(),b&&b.name==="TypeError"&&/Load failed|fetch/i.test(b.message)?Object.assign(new y("Network Error",y.ERR_NETWORK,p,X,b&&b.response),{cause:b.cause||b}):y.from(b,b&&b.code,p,X,b&&b.response)}}},ur=new Map,Rt=t=>{let e=t&&t.env||{};const{fetch:n,Request:r,Response:s}=e,o=[r,s,n];let i=o.length,l=i,f,u,c=ur;for(;l--;)f=o[l],u=c.get(f),u===void 0&&c.set(f,u=l?new Map:cr(e)),c=u;return u};Rt();const je={http:Pn,xhr:rr,fetch:{get:Rt}};a.forEach(je,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Tt=t=>`- ${t}`,dr=t=>a.isFunction(t)||t===null||t===!1;function fr(t,e){t=a.isArray(t)?t:[t];const{length:n}=t;let r,s;const o={};for(let i=0;i<n;i++){r=t[i];let l;if(s=r,!dr(r)&&(s=je[(l=String(r)).toLowerCase()],s===void 0))throw new y(`Unknown adapter '${l}'`);if(s&&(a.isFunction(s)||(s=s.get(e))))break;o[l||"#"+i]=s}if(!s){const i=Object.entries(o).map(([f,u])=>`adapter ${f} `+(u===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
|
|
4
|
-
`+i.map(
|
|
5
|
-
`):" "+
|
|
6
|
-
`);
|
|
7
|
-
`),l
|
|
8
|
-
`,
|
|
9
|
-
`+o)}}catch{}}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=Y(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&Ae.assertOptions(r,{silentJSONParsing:H.transitional(H.boolean),forcedJSONParsing:H.transitional(H.boolean),clarifyTimeoutError:H.transitional(H.boolean),legacyInterceptorReqResOrdering:H.transitional(H.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:Ae.assertOptions(s,{encode:H.function,serialize:H.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),Ae.assertOptions(n,{baseUrl:H.spelling("baseURL"),withXsrfToken:H.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(["delete","get","head","post","put","patch","common"],p=>{delete o[p]}),n.headers=U.concat(i,o);const l=[];let f=!0;this.interceptors.request.forEach(function(g){if(typeof g.runWhen=="function"&&g.runWhen(n)===!1)return;f=f&&g.synchronous;const h=n.transitional||Ne;h&&h.legacyInterceptorReqResOrdering?l.unshift(g.fulfilled,g.rejected):l.push(g.fulfilled,g.rejected)});const u=[];this.interceptors.response.forEach(function(g){u.push(g.fulfilled,g.rejected)});let c,d=0,R;if(!f){const p=[St.bind(this),void 0];for(p.unshift(...l),p.push(...u),R=p.length,c=Promise.resolve(n);d<R;)c=c.then(p[d++],p[d++]);return c}R=l.length;let _=n;for(;d<R;){const p=l[d++],g=l[d++];try{_=p(_)}catch(h){g.call(this,h);break}}try{c=St.call(this,_)}catch(p){return Promise.reject(p)}for(d=0,R=u.length;d<R;)c=c.then(u[d++],u[d++]);return c}getUri(e){e=Y(this.defaults,e);const n=ht(e.baseURL,e.url,e.allowAbsoluteUrls);return ot(n,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){Z.prototype[e]=function(n,r){return this.request(Y(r||{},{method:e,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(e){function n(r){return function(o,i,l){return this.request(Y(l||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}Z.prototype[e]=n(),Z.prototype[e+"Form"]=n(!0)});let pr=class Ft{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(l=>{r.subscribe(l),o=l}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},e(function(o,i,l){r.reason||(r.reason=new de(o,i,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new Ft(function(s){e=s}),cancel:e}}};function gr(t){return function(n){return t.apply(null,n)}}function mr(t){return a.isObject(t)&&t.isAxiosError===!0}const Ie={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,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(Ie).forEach(([t,e])=>{Ie[e]=t});function At(t){const e=new Z(t),n=Ve(Z.prototype.request,e);return a.extend(n,Z.prototype,e,{allOwnKeys:!0}),a.extend(n,e,null,{allOwnKeys:!0}),n.create=function(s){return At(Y(t,s))},n}const A=At(ce);A.Axios=Z,A.CanceledError=de,A.CancelToken=pr,A.isCancel=ct,A.VERSION=Ot,A.toFormData=Te,A.AxiosError=y,A.Cancel=A.CanceledError,A.all=function(e){return Promise.all(e)},A.spread=gr,A.isAxiosError=mr,A.mergeConfig=Y,A.AxiosHeaders=U,A.formToJSON=t=>at(a.isHTMLForm(t)?new FormData(t):t),A.getAdapter=xt.getAdapter,A.HttpStatusCode=Ie,A.default=A;const{Axios:Wr,AxiosError:Xr,CanceledError:Gr,isCancel:Qr,CancelToken:Yr,VERSION:Zr,all:es,Cancel:ts,isAxiosError:ns,spread:rs,toFormData:ss,AxiosHeaders:os,HttpStatusCode:is,formToJSON:as,getAdapter:ls,mergeConfig:cs}=A,Ct="https://translation.googleapis.com/language/translate/v2",yr=new Set([408,425,429,500,502,503,504]),br=t=>!!t,Er=t=>A.isAxiosError(t);class wr{constructor(e){I(this,"type","google");I(this,"axios");this.config=e,this.axios=A.create({baseURL:e.endpoint??Ct,headers:{"Content-Type":"application/json",...e.headers}})}isAvailable(){return this.config.apiKey||br(this.config.headers)?{available:!0}:{available:!0}}async translate(e,n){var f,u,c;const r={q:e.text,target:e.targetLanguage,format:"text"};e.sourceLanguage&&e.sourceLanguage!=="auto"&&(r.source=e.sourceLanguage),e.glossary&&Object.keys(e.glossary).length>0&&(r.glossaryConfig={glossaryData:{languagePair:{sourceLanguageCode:e.sourceLanguage??"auto",targetLanguageCode:e.targetLanguage},terms:Object.entries(e.glossary).map(([d,R])=>({sourceText:d,targetText:R}))}});const s={...this.config.headers,...n==null?void 0:n.headers},i=(c=(u=(f=(await this.axios.post("",r,{headers:s,params:this.createQueryParams(),timeout:n==null?void 0:n.timeoutMs,signal:n==null?void 0:n.signal})).data)==null?void 0:f.data)==null?void 0:u.translations)==null?void 0:c[0];if(!(i!=null&&i.translatedText))throw new Error("Google Translate response did not include translatedText");const l={endpoint:this.config.endpoint??Ct};return i.model&&(l.model=i.model),this.config.projectId&&(l.projectId=this.config.projectId),this.config.region&&(l.region=this.config.region),{translatedText:i.translatedText,detectedSourceLanguage:i.detectedSourceLanguage,providerMetadata:l}}normalizeError(e){var n,r,s,o,i;if(Er(e)){const l=(n=e.response)==null?void 0:n.status,f=((r=e.response)==null?void 0:r.data)??{},u=((s=f.error)==null?void 0:s.message)??e.message??"Google Translate request failed";return{code:String(((o=f.error)==null?void 0:o.code)??l??"E_GOOGLE"),message:u,retryable:l?yr.has(l):!1,details:{status:l,data:f,headers:(i=e.response)==null?void 0:i.headers}}}return e instanceof Error?{code:e.name||"unknown_error",message:e.message,retryable:!1,details:e}:{code:"unknown_error",message:"Unknown provider error",retryable:!1,details:e}}createQueryParams(){if(this.config.apiKey)return{key:this.config.apiKey}}}const He=t=>{if(!t)throw new Error("Provider instance is null or undefined");if(!t.type)throw new Error("Provider missing required 'type' property");if(typeof t.translate!="function")throw new Error("Provider missing required 'translate' method");if(t.isAvailable&&typeof t.isAvailable!="function")throw new Error("Provider 'isAvailable' must be a function");if(t.normalizeError&&typeof t.normalizeError!="function")throw new Error("Provider 'normalizeError' must be a function")},Pt=t=>{if(t.id==="google"){const e=new wr(t);return He(e),e}if(t.implementation)return He(t.implementation),t.implementation;if(t.factory){const e=t.factory();return He(e),e}throw new Error("Custom provider configuration must include either 'implementation' or 'factory'")},Rr="translator",Tr=5e3,Lt=3e4,xr="::",Sr=t=>{var n,r;return((r=(n=navigator==null?void 0:navigator.language)==null?void 0:n.split("-"))==null?void 0:r[0])||t},Or=t=>localStorage.getItem(t),_r=(t,e)=>{localStorage.setItem(t,e)},Ar=t=>t?t instanceof Set?new Set(t):new Set(t):new Set,kt=(t,e)=>({scope:Rr,event:t,...e}),fe=(t,e)=>{console.warn("[vbss-translator]",kt(t,e))},M=(t,e)=>{console.debug("[vbss-translator]",kt(t,e))},Cr=()=>({warn:(t,e)=>{fe(t,e??{})},debug:(t,e)=>{M(t,e??{})}}),Pr=t=>{const{provider:e,cache:n,alwaysExternalKeys:r,enabled:s,timeoutMs:o,debug:i,...l}=t??{};return{enabled:s??!1,timeoutMs:o??Tr,debug:i??!1,provider:{...Lr,...e},cache:{...kr,...n},alwaysExternalKeys:Ar(r),...l}},Lr={id:"google"},kr={enabled:!1,ttlMs:36e5},vr=(t,e)=>`${t}${xr}${e}`,Nr=t=>t?new Map(t):new Map,Dr=(t,e)=>{const n=t.toLocaleLowerCase();return e.find(r=>Object.values(r).some(s=>s.toLocaleLowerCase()===n))},Fr=({children:t,translations:e,defaultLanguage:n="en",persist:r=!1,persistKey:s="language",autoDetectLanguage:o=!1,externalTranslation:i})=>{const l=T.useMemo(()=>Pr(i),[i]),[f,u]=T.useState(()=>new Set(l.alwaysExternalKeys));T.useEffect(()=>{u(m=>{const b=new Set(l.alwaysExternalKeys);return m.forEach(w=>b.add(w)),b})},[l]);const c=T.useCallback(m=>{u(b=>{if(b.has(m))return b;const w=new Set(b);return w.add(m),w})},[]),d=T.useMemo(()=>({...l,alwaysExternalKeys:f}),[l,f]),R=r?Or(s):null,_=o?Sr(n):null,[p,g]=T.useState(R??_??n);T.useEffect(()=>{r&&_r(s,p)},[p,r,s]);const h=T.useMemo(()=>Object.keys(e[0]||{}),[e]),S=T.useMemo(()=>Cr(),[]),q=T.useMemo(()=>new It(d.cache),[d.cache]),O=T.useMemo(()=>{let m;try{if(m=Pt(d.provider),d.debug&&M("TranslatorProvider_provider_created",{providerType:m.type,providerId:d.provider.id,timestamp:Date.now()}),m.isAvailable){const b=m.isAvailable();b.available?d.debug&&M("TranslatorProvider_provider_available",{providerType:m.type,providerId:d.provider.id,timestamp:Date.now()}):fe("TranslatorProvider_provider_unavailable",{providerType:m.type,providerId:d.provider.id,reason:b.reason,timestamp:Date.now()})}}catch(b){throw fe("TranslatorProvider_provider_creation_failed",{providerId:d.provider.id,error:b instanceof Error?b.message:"Unknown error",timestamp:Date.now()}),b}return new Bt({provider:m,config:d,cache:d.cache.enabled?q:void 0,logger:S})},[d,S,q]),[x,N]=T.useState(()=>new Map),[z,D]=T.useState(0),B=T.useRef(!0);T.useEffect(()=>(d.debug&&M("TranslatorProvider_mounted",{timestamp:Date.now()}),B.current=!0,()=>{d.debug&&M("TranslatorProvider_unmounting",{timestamp:Date.now()}),B.current=!1}),[d]);const V=T.useCallback((m,b,w)=>{var G;d.debug&&w&&M("setExternalStateEntry_called",{targetLanguage:m,key:b,status:w.status,value:w.value,isMounted:B.current});const E=()=>{N(P=>{const L=new Map(P),$=Nr(L.get(m));return w?($.set(b,w),L.set(m,$)):($.delete(b),$.size>0?L.set(m,$):L.delete(m)),L}),(w==null?void 0:w.status)==="resolved"&&(d.debug&&M("forceUpdate_triggered",{targetLanguage:m,key:b}),D(P=>P+1))};typeof process<"u"&&((G=process.env)==null?void 0:G.NODE_ENV)==="test"?E():T.startTransition(()=>{E()})},[d,D]),he=T.useCallback(m=>{var b;O.isEnabled()&&(V(m.targetLanguage,m.key,{status:"pending",value:m.displayValue}),O.translate({key:m.key,text:m.originalText,targetLanguage:m.targetLanguage,sourceLanguage:m.sourceLanguage,signal:(b=m.options)==null?void 0:b.signal}).then(w=>{if(d.debug&&M("translation_promise_resolved",{key:m.key,targetLanguage:m.targetLanguage,isMounted:B.current,hasResult:!!w,hasTranslatedText:!!(w&&w.translatedText),translatedText:w==null?void 0:w.translatedText}),w&&w.translatedText){d.debug&&M("translation_applying_resolved",{key:m.key,targetLanguage:m.targetLanguage,isMounted:B.current,translatedText:w.translatedText}),V(m.targetLanguage,m.key,{status:"resolved",value:w.translatedText});return}d.debug&&M("translation_invalid_result",{key:m.key,result:w}),V(m.targetLanguage,m.key,{status:"error",value:m.displayValue,retryAt:Date.now()+Lt})}).catch(w=>{d.debug&&M("translation_promise_rejected",{key:m.key,targetLanguage:m.targetLanguage,isMounted:B.current,error:(w==null?void 0:w.message)||String(w)}),fe("external_translation_unexpected_rejection",{key:m.key,language:m.targetLanguage,error:w,isMounted:B.current}),V(m.targetLanguage,m.key,{status:"error",value:m.displayValue,error:w,retryAt:Date.now()+Lt})}))},[d,V,O]),ee=T.useMemo(()=>{const m={};return x.forEach((b,w)=>{b.forEach((E,C)=>{m[vr(C,w)]=E.status==="pending"})}),d.debug&&M("isTranslatingRecord_recalculated",{recordSize:Object.keys(m).length,record:{...m}}),m},[x,d]),te=T.useMemo(()=>Object.values(ee).some(Boolean),[ee]),X=T.useCallback((m,b={})=>{var vt;const w=x.get(p),E=w==null?void 0:w.get(m);if(d.debug&&b.preferExternal&&M("t_called",{text:m,language:p,hasStateForLanguage:!!w,existingStateStatus:E==null?void 0:E.status,existingStateValue:E==null?void 0:E.value,preferExternal:b.preferExternal}),(E==null?void 0:E.status)==="resolved"&&E.value)return d.debug&&M("t_returning_resolved",{text:m,value:E.value}),E.value;const C=Dr(m,e),G=C==null?void 0:C[p],P=C?Object.values(C).find(Nt=>!!Nt):void 0,L=b.fallbackValue??(E==null?void 0:E.value)??G??P??m,$=b.preferExternal===!0||d.alwaysExternalKeys.has(m),oe=O.isEnabled(),pe=typeof G=="string";if(pe||fe("missing_translation",{key:m,language:p}),!(oe&&($||!pe)))return(E==null?void 0:E.status)==="pending"&&E.value?E.value:G??L;const Mr=Date.now(),jr=(E==null?void 0:E.status)==="error"&&(!E.retryAt||E.retryAt<=Mr);if(!E||jr){const qe=b.sourceLanguage??(C&&C[n]?n:void 0),Br=(qe&&(C==null?void 0:C[qe]))??(C==null?void 0:C[n])??m;he({key:m,targetLanguage:p,originalText:Br,displayValue:(E==null?void 0:E.value)??L,sourceLanguage:qe,options:b})}const W=((vt=x.get(p))==null?void 0:vt.get(m))??E;return(W==null?void 0:W.status)==="resolved"&&W.value?W.value:(W==null?void 0:W.status)==="pending"?W.value??L:L},[n,d.alwaysExternalKeys,x,p,he,O,e]),J=T.useMemo(()=>({t:X,language:p,languages:h,setLanguage:g,isTranslating:ee,isTranslatingAny:te,registerExternalKey:c,externalConfig:d}),[X,p,h,g,ee,te,c,d,z]);return j.jsx(Ke.Provider,{value:J,children:t})},Ur=()=>Ut();k.TranslatorProvider=Fr,k.createTranslationProvider=Pt,k.useTranslator=Ur,Object.defineProperty(k,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(j,W){typeof exports=="object"&&typeof module<"u"?W(exports,require("react/jsx-runtime"),require("react")):typeof define=="function"&&define.amd?define(["exports","react/jsx-runtime","react"],W):(j=typeof globalThis<"u"?globalThis:j||self,W(j["vbss/translator"]={},j.ReactJSXRuntime,j.React))})(this,(function(j,W,T){"use strict";var Js=Object.defineProperty;var Xs=(j,W,T)=>W in j?Js(j,W,{enumerable:!0,configurable:!0,writable:!0,value:T}):j[W]=T;var Y=(j,W,T)=>Xs(j,typeof W!="symbol"?W+"":W,T);const gt=T.createContext(null),wn=()=>{const t=T.useContext(gt);if(!t)throw new Error("useTranslatorContext must be used within a TranslatorProvider");return t};class mt extends Error{constructor(n){super(n);Y(this,"code","timeout");this.name="ExternalTranslationTimeoutError"}}const Rn="auto",De=t=>typeof t=="number"&&Number.isFinite(t)&&t>0,On=t=>{const e=Object.entries(t).sort(([n],[r])=>n<r?-1:1);return Object.fromEntries(e)};class Sn{constructor(e){Y(this,"provider");Y(this,"config");Y(this,"cache");Y(this,"logger");Y(this,"inFlight",new Map);this.provider=e.provider,this.config=e.config,this.cache=e.cache,this.logger=e.logger}isEnabled(){return this.config.enabled}async translate(e){if(!this.isEnabled()){this.debug("external_translation_disabled",{key:e.key,targetLanguage:e.targetLanguage});return}const n=this.normalizeRequest(e);if(!await this.shouldTranslate(n.externalRequest)){this.debug("external_translation_skipped",{key:n.externalRequest.key,targetLanguage:n.externalRequest.targetLanguage});return}const r=this.readFromCache(n.cacheKey);if(r)return this.debug("external_translation_cache_hit",{key:n.externalRequest.key,cacheKey:n.cacheKey}),r;const s=this.inFlight.get(n.cacheKey);if(s)return this.debug("external_translation_deduped",{key:n.externalRequest.key,cacheKey:n.cacheKey}),s;const o=this.executeTranslation(n);return this.inFlight.set(n.cacheKey,o),o}normalizeRequest(e){const n=e.sourceLanguage??Rn,r={text:e.text,sourceLanguage:n,targetLanguage:e.targetLanguage,glossary:e.glossary},s=this.createCacheKey(r),o=De(e.timeoutMs)?e.timeoutMs:this.config.timeoutMs;return{externalRequest:{key:e.key,text:e.text,targetLanguage:e.targetLanguage,sourceLanguage:n},translateRequest:r,cacheKey:s,timeoutMs:o,signal:e.signal}}async shouldTranslate(e){if(!this.config.shouldTranslate)return!0;try{return this.config.shouldTranslate(e)}catch(n){return this.warn("external_translation_should_translate_error",{key:e.key,language:e.targetLanguage,error:n}),!0}}async executeTranslation(e){try{if(!await this.invokeExternalTranslationHook(e.externalRequest)){this.debug("external_translation_vetoed",{key:e.externalRequest.key,targetLanguage:e.externalRequest.targetLanguage});return}this.debug("external_translation_started",{key:e.externalRequest.key,cacheKey:e.cacheKey});const n=await this.translateWithTimeout(e.translateRequest,e.timeoutMs,e.signal);return this.writeToCache(e.cacheKey,n),this.notifyTranslationComplete(n),this.debug("external_translation_succeeded",{key:e.externalRequest.key,cacheKey:e.cacheKey}),n}catch(n){const r=this.normalizeError(n);this.handleTranslationError(e,r);return}finally{this.inFlight.delete(e.cacheKey)}}async invokeExternalTranslationHook(e){const n=this.config.onExternalTranslation;if(!n)return!0;try{const r=await n(e);return typeof r=="boolean"?r:!0}catch(r){return this.warn("external_translation_hook_error",{key:e.key,language:e.targetLanguage,error:r}),!0}}async translateWithTimeout(e,n,r){if(!(typeof AbortController=="function"))return this.provider.translate(e,{timeoutMs:De(n)?n:void 0,signal:r});const o=new AbortController;let i,l;r&&(r.aborted?o.abort():(l=()=>{o.abort()},r.addEventListener("abort",l,{once:!0})));const c=De(n)?new Promise((u,h)=>{i=setTimeout(()=>{o.abort(),h(new mt(`External translation timed out after ${n}ms`))},n)}):void 0,d=new Promise(u=>{u(this.provider.translate(e,{timeoutMs:De(n)?n:void 0,signal:o.signal}))});try{return await(c?Promise.race([d,c]):d)}finally{i&&clearTimeout(i),l&&r&&r.removeEventListener("abort",l),d.catch(()=>{})}}readFromCache(e){var n;return(n=this.cache)==null?void 0:n.get(e)}writeToCache(e,n){var r;(r=this.cache)==null||r.set(e,n)}handleTranslationError(e,n){const r={key:e.externalRequest.key,language:e.externalRequest.targetLanguage,originalText:e.externalRequest.text,error:n};this.notifyTranslationError(r),this.warn("external_fallback_failed",{provider:this.provider.type,key:r.key,language:r.language,errorCode:n.code,retryable:n.retryable,message:n.message,details:n.details})}normalizeError(e){return this.provider.normalizeError?this.provider.normalizeError(e):e instanceof mt?{code:"timeout",message:e.message,retryable:!0,details:e}:e instanceof Error?{code:e.name||"unknown_error",message:e.message,retryable:!1,details:e}:{code:"unknown_error",message:"Unknown provider error",retryable:!1,details:e}}createCacheKey(e){return[e.sourceLanguage,e.targetLanguage,this.hashText(e.text,e.glossary)].join("|")}hashText(e,n){let r=2166136261;const s=n&&Object.keys(n).length>0?`${e}|${JSON.stringify(On(n))}`:e;for(let o=0;o<s.length;o+=1)r^=s.charCodeAt(o),r+=(r<<1)+(r<<4)+(r<<7)+(r<<8)+(r<<24);return(r>>>0).toString(16)}warn(e,n){const r={scope:"translator",event:e,...n};if(this.logger){this.logger.warn(e,r);return}console.warn("[vbss-translator]",r)}debug(e,n){var s;if(!this.config.debug)return;const r={scope:"translator",event:e,...n};if((s=this.logger)!=null&&s.debug){this.logger.debug(e,r);return}console.debug("[vbss-translator]",r)}notifyTranslationComplete(e){const n=this.config.onTranslationComplete;if(n)try{n(e)}catch(r){this.warn("external_translation_complete_callback_error",{provider:this.provider.type,error:r})}}notifyTranslationError(e){const n=this.config.onTranslationError;if(n)try{n(e)}catch(r){this.warn("external_translation_error_callback_error",{provider:this.provider.type,key:e.key,language:e.language,error:r})}}}const Ve=()=>Date.now(),Ne=t=>typeof t=="number"&&Number.isFinite(t)&&t>0;class _n{constructor(e){Y(this,"store",new Map);Y(this,"enabled");Y(this,"ttlMs");Y(this,"maxEntries");this.enabled=e.enabled,this.ttlMs=Math.max(0,e.ttlMs),this.maxEntries=e.maxEntries}isEnabled(){return this.enabled}setEnabled(e){e||this.clear(),this.enabled=e}setTtl(e){this.ttlMs=Math.max(0,e)}size(){return this.store.size}clear(){this.store.clear()}get(e){if(!this.enabled)return;const n=this.store.get(e);if(n){if(this.isExpired(n)){this.store.delete(e);return}return n.value}}set(e,n,r){if(!this.enabled)return;const s=Ne(r)?r:this.ttlMs,o=Ne(s)?Ve()+s:void 0;this.store.set(e,{value:n,expiresAt:o,insertedAt:Ve()}),this.enforceMaxEntries()}delete(e){this.store.delete(e)}has(e){if(!this.enabled)return!1;const n=this.store.get(e);return n?this.isExpired(n)?(this.store.delete(e),!1):!0:!1}entries(){const e=[];for(const[n,r]of this.store.entries()){if(this.isExpired(r)){this.store.delete(n);continue}e.push({key:n,result:r.value,expiresAt:r.expiresAt})}return e}prune(){for(const[e,n]of this.store.entries())this.isExpired(n)&&this.store.delete(e)}enforceMaxEntries(){if(!Ne(this.maxEntries))return;const e=this.maxEntries;for(;this.store.size>e;){const n=this.findOldestKey();if(!n)break;this.store.delete(n)}}findOldestKey(){let e,n=Number.POSITIVE_INFINITY;for(const[r,s]of this.store.entries())s.insertedAt<n&&(e=r,n=s.insertedAt);return e}isExpired(e){return Ne(e.expiresAt)?e.expiresAt<=Ve():!1}}function yt(t,e){return function(){return t.apply(e,arguments)}}const{toString:xn}=Object.prototype,{getPrototypeOf:oe}=Object,{iterator:we,toStringTag:bt}=Symbol,Re=(({hasOwnProperty:t})=>(e,n)=>t.call(e,n))(Object.prototype),Et=t=>typeof t=="string"&&(t==="__proto__"||t==="constructor"||t==="prototype"),wt=(t,e,n)=>t===Object.prototype||!n&&e===null,Tn=t=>{if(!Object.isExtensible(t))return!1;const e=Object.getOwnPropertyNames(t);return Object.getOwnPropertySymbols&&e.push(...Object.getOwnPropertySymbols(t)),e.every(n=>{if(Et(n))return!1;const r=Object.getOwnPropertyDescriptor(t,n);return!!r&&r.configurable&&r.writable===!0})},Oe=(t,e)=>{let n=t;const r=[];for(;n!=null;){if(r.indexOf(n)!==-1)return!1;r.push(n);const s=oe(n);if(wt(n,s,n===t))return!1;if(Re(n,e))return!0;n=s}return!1},An=(t,e)=>t!=null&&Oe(t,e)?t[e]:void 0,Pn=t=>{if(t==null||typeof t!="object"&&typeof t!="function")return t;const e=oe(t);if(e===null&&Tn(t))return t;const n=Object.create(null),r=Object.create(null),s=[];let o=t;for(;o!=null&&s.indexOf(o)===-1;){s.push(o);const i=o===t?e:oe(o);if(wt(o,i,o===t))break;const l=Object.getOwnPropertyNames(o);Object.getOwnPropertySymbols&&l.push(...Object.getOwnPropertySymbols(o));for(const c of l)Et(c)||Re(r,c)||(n[c]=t[c],r[c]=!0);o=i}return n},We=(t=>e=>{const n=xn.call(e);return t[n]||(t[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),Z=t=>(t=t.toLowerCase(),e=>We(e)===t),ke=t=>e=>typeof e===t,{isArray:le}=Array,ce=ke("undefined");function me(t){return t!==null&&!ce(t)&&t.constructor!==null&&!ce(t.constructor)&&K(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Rt=Z("ArrayBuffer");function Cn(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Rt(t.buffer),e}const Ln=ke("string"),K=ke("function"),Ot=ke("number"),ye=t=>t!==null&&typeof t=="object",Dn=t=>t===!0||t===!1,ve=t=>{if(!ye(t))return!1;const e=oe(t);return(e===null||e===Object.prototype||oe(e)===null)&&!Oe(t,bt)&&!Oe(t,we)},Nn=t=>{if(!ye(t)||me(t))return!1;try{return Object.keys(t).length===0&&Object.getPrototypeOf(t)===Object.prototype}catch{return!1}},kn=Z("Date"),vn=Z("File"),Un=t=>!!(t&&typeof t.uri<"u"),Fn=t=>t&&typeof t.getParts<"u",jn=Z("Blob"),Bn=Z("FileList"),Mn=Z("Set"),In=t=>ye(t)&&K(t.pipe);function Hn(){return typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:{}}const St=Hn(),_t=typeof St.FormData<"u"?St.FormData:void 0,qn=t=>{if(!t)return!1;if(_t&&t instanceof _t)return!0;const e=oe(t);if(!e||e===Object.prototype||!K(t.append))return!1;const n=We(t);return n==="formdata"||n==="object"&&K(t.toString)&&t.toString()==="[object FormData]"},$n=Z("URLSearchParams"),[Kn,zn,Vn,Wn]=["ReadableStream","Request","Response","Headers"].map(Z),Jn=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Se(t,e,{allOwnKeys:n=!1}={}){if(t===null||typeof t>"u")return;let r,s;if(typeof t!="object"&&(t=[t]),le(t))for(r=0,s=t.length;r<s;r++)e.call(null,t[r],r,t);else{if(me(t))return;const o=n?Object.getOwnPropertyNames(t):Object.keys(t),i=o.length;let l;for(r=0;r<i;r++)l=o[r],e.call(null,t[l],l,t)}}function xt(t,e){if(me(t))return null;e=e.toLowerCase();const n=Object.keys(t);let r=n.length,s;for(;r-- >0;)if(s=n[r],e===s.toLowerCase())return s;return null}const ue=typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global,Tt=t=>!ce(t)&&t!==ue;function Je(...t){const{caseless:e,skipUndefined:n}=Tt(this)&&this||{},r={},s=(o,i)=>{if(i==="__proto__"||i==="constructor"||i==="prototype")return;const l=e&&typeof i=="string"&&xt(r,i)||i,c=Re(r,l)?r[l]:void 0;ve(c)&&ve(o)?r[l]=Je(c,o):ve(o)?r[l]=Je({},o):le(o)?r[l]=o.slice():(!n||!ce(o))&&(r[l]=o)};for(let o=0,i=t.length;o<i;o++){const l=t[o];if(!l||me(l)||(Se(l,s),typeof l!="object"||le(l)))continue;const c=Object.getOwnPropertySymbols(l);for(let d=0;d<c.length;d++){const u=c[d];ir.call(l,u)&&s(l[u],u)}}return r}const Xn=(t,e,n,{allOwnKeys:r}={})=>(Se(e,(s,o)=>{n&&K(s)?Object.defineProperty(t,o,{__proto__:null,value:yt(s,n),writable:!0,enumerable:!0,configurable:!0}):Object.defineProperty(t,o,{__proto__:null,value:s,writable:!0,enumerable:!0,configurable:!0})},{allOwnKeys:r}),t),Gn=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Qn=(t,e,n,r)=>{t.prototype=Object.create(e.prototype,r),Object.defineProperty(t.prototype,"constructor",{__proto__:null,value:t,writable:!0,enumerable:!1,configurable:!0}),Object.defineProperty(t,"super",{__proto__:null,value:e.prototype}),n&&Object.assign(t.prototype,n)},Yn=(t,e,n,r)=>{let s,o,i;const l={};if(e=e||{},t==null)return e;do{for(s=Object.getOwnPropertyNames(t),o=s.length;o-- >0;)i=s[o],(!r||r(i,t,e))&&!l[i]&&(e[i]=t[i],l[i]=!0);t=n!==!1&&oe(t)}while(t&&(!n||n(t,e))&&t!==Object.prototype);return e},Zn=(t,e,n)=>{t=String(t),(n===void 0||n>t.length)&&(n=t.length),n-=e.length;const r=t.indexOf(e,n);return r!==-1&&r===n},er=t=>{if(!t)return null;if(le(t))return t;let e=t.length;if(!Ot(e))return null;const n=new Array(e);for(;e-- >0;)n[e]=t[e];return n},tr=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&oe(Uint8Array)),nr=(t,e)=>{const r=(t&&t[we]).call(t);let s;for(;(s=r.next())&&!s.done;){const o=s.value;e.call(t,o[0],o[1])}},rr=(t,e)=>{let n;const r=[];for(;(n=t.exec(e))!==null;)r.push(n);return r},sr=Z("HTMLFormElement"),or=t=>t.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),{propertyIsEnumerable:ir}=Object.prototype,ar=Z("RegExp"),At=(t,e)=>{const n=Object.getOwnPropertyDescriptors(t),r={};Se(n,(s,o)=>{let i;(i=e(s,o,t))!==!1&&(r[o]=i||s)}),Object.defineProperties(t,r)},lr=t=>{At(t,(e,n)=>{if(K(t)&&["arguments","caller","callee"].includes(n))return!1;const r=t[n];if(K(r)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},cr=(t,e)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return le(t)?r(t):r(String(t).split(e)),n},ur=()=>{},fr=(t,e)=>t!=null&&Number.isFinite(t=+t)?t:e;function dr(t){return!!(t&&K(t.append)&&t[bt]==="FormData"&&t[we])}const hr=t=>{const e=new WeakSet,n=r=>{if(ye(r)){if(e.has(r))return;if(me(r))return r;if(!("toJSON"in r)){e.add(r);let s;if(Mn(r)){s=[];for(const o of r){const i=n(o);!ce(i)&&s.push(i)}}else s=le(r)?[]:{},Se(r,(o,i)=>{const l=n(o);!ce(l)&&(s[i]=l)});return e.delete(r),s}}return r};return n(t)},pr=Z("AsyncFunction"),gr=t=>t&&(ye(t)||K(t))&&K(t.then)&&K(t.catch),Pt=((t,e)=>t?setImmediate:e?((n,r)=>(ue.addEventListener("message",({source:s,data:o})=>{s===ue&&o===n&&r.length&&r.shift()()},!1),s=>{r.push(s),ue.postMessage(n,"*")}))(`axios@${Math.random()}`,[]):n=>setTimeout(n))(typeof setImmediate=="function",K(ue.postMessage)),mr=typeof queueMicrotask<"u"?queueMicrotask.bind(ue):typeof process<"u"&&process.nextTick||Pt,Ct=t=>t!=null&&K(t[we]),a={isArray:le,isArrayBuffer:Rt,isBuffer:me,isFormData:qn,isArrayBufferView:Cn,isString:Ln,isNumber:Ot,isBoolean:Dn,isObject:ye,isPlainObject:ve,isEmptyObject:Nn,isReadableStream:Kn,isRequest:zn,isResponse:Vn,isHeaders:Wn,isUndefined:ce,isDate:kn,isFile:vn,isReactNativeBlob:Un,isReactNative:Fn,isBlob:jn,isRegExp:ar,isFunction:K,isStream:In,isURLSearchParams:$n,isTypedArray:tr,isFileList:Bn,forEach:Se,merge:Je,extend:Xn,trim:Jn,stripBOM:Gn,inherits:Qn,toFlatObject:Yn,kindOf:We,kindOfTest:Z,endsWith:Zn,toArray:er,forEachEntry:nr,matchAll:rr,isHTMLForm:sr,hasOwnProperty:Re,hasOwnProp:Re,hasOwnInPrototypeChain:Oe,getSafeProp:An,toSafeFlatObject:Pn,reduceDescriptors:At,freezeMethods:lr,toObjectSet:cr,toCamelCase:or,noop:ur,toFiniteNumber:fr,findKey:xt,global:ue,isContextDefined:Tt,isSpecCompliantForm:dr,toJSONObject:hr,isAsyncFn:pr,isThenable:gr,setImmediate:Pt,asap:mr,isIterable:Ct,isSafeIterable:t=>t!=null&&Oe(t,we)&&Ct(t)},yr=a.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"]),br=t=>{const e={};let n,r,s;return t&&t.split(`
|
|
2
|
+
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim();const l=a.hasOwnProp(e,n);!n||l&&a.hasOwnProp(yr,n)||(n==="set-cookie"?l?e[n].push(r):e[n]=[r]:e[n]=l?e[n]+", "+r:r)}),e};function Er(t){let e=0,n=t.length;for(;e<n;){const r=t.charCodeAt(e);if(r!==9&&r!==32)break;e+=1}for(;n>e;){const r=t.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return e===0&&n===t.length?t:t.slice(e,n)}const wr=new RegExp("[\\u0000-\\u0008\\u000a-\\u001f\\u007f]+","g"),Rr=new RegExp("[^\\u0009\\u0020-\\u007e\\u0080-\\u00ff]+","g");function Xe(t,e){return a.isArray(t)?t.map(n=>Xe(n,e)):Er(String(t).replace(e,""))}const Or=t=>Xe(t,wr),Sr=t=>Xe(t,Rr);function Lt(t){const e=Object.create(null);return a.forEach(t.toJSON(),(n,r)=>{e[r]=Sr(n)}),e}const Dt=Symbol("internals");function _e(t){return t&&String(t).trim().toLowerCase()}function Ue(t){return t===!1||t==null?t:a.isArray(t)?t.map(Ue):Or(String(t))}function _r(t){const e=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(t);)e[r[1]]=r[2];return e}const xr=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;function Ge(t){let e=0,n=t.length;for(;e<n;){const r=t.charCodeAt(e);if(r!==9&&r!==32)break;e+=1}for(;n>e;){const r=t.charCodeAt(n-1);if(r!==9&&r!==32)break;n-=1}return e===0&&n===t.length?t:t.slice(e,n)}function Tr(t){const e=t.length-1;if(e<1||t.charCodeAt(0)!==34||t.charCodeAt(e)!==34)return t;let n="";for(let r=1;r<e;r++){const s=t.charCodeAt(r);if(s===34||s===92&&(r+=1,r>=e))return t;n+=t[r]}return n}function Ar(t){const e=Object.create(null),n=String(t);let r=0,s=!1,o=!1;function i(l){const c=Ge(n.slice(r,l)),d=c.indexOf("=");if(d<1)return;const u=Ge(c.slice(0,d));if(!xr.test(u))return;const h=u.toLowerCase();if(h==="__proto__"||h==="constructor"||h==="prototype")return;const p=Ge(c.slice(d+1));e[h]=Tr(p)}for(let l=0;l<n.length;l++){const c=n.charCodeAt(l);s?o?o=!1:c===92?o=!0:c===34&&(s=!1):c===34?s=!0:(c===44||c===59)&&(i(l),r=l+1)}return i(n.length),e}const Pr=t=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(t.trim());function Qe(t,e,n,r,s){if(a.isFunction(r))return r.call(this,e,n);if(s&&(e=n),!!a.isString(e)){if(a.isString(r))return e.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(e)}}function Cr(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,n,r)=>n.toUpperCase()+r)}function Lr(t,e){const n=a.toCamelCase(" "+e);["get","set","has"].forEach(r=>{Object.defineProperty(t,r+n,{__proto__:null,value:function(s,o,i){return this[r].call(this,e,s,o,i)},configurable:!0})})}let B=class{constructor(e){e&&this.set(e)}set(e,n,r){const s=this;function o(l,c,d){const u=_e(c);if(!u)return;const h=a.findKey(s,u);(!h||s[h]===void 0||d===!0||d===void 0&&s[h]!==!1)&&(s[h||c]=Ue(l))}const i=(l,c)=>a.forEach(l,(d,u)=>o(d,u,c));if(a.isPlainObject(e)||e instanceof this.constructor)i(e,n);else if(a.isString(e)&&(e=e.trim())&&!Pr(e))i(br(e),n);else if(a.isObject(e)&&a.isSafeIterable(e)){let l=Object.create(null),c,d;for(const u of e){if(!a.isArray(u))throw new TypeError("Object iterator must return a key-value pair");d=u[0],a.hasOwnProp(l,d)?(c=l[d],l[d]=a.isArray(c)?[...c,u[1]]:[c,u[1]]):l[d]=u[1]}i(l,n)}else e!=null&&o(n,e,r);return this}get(e,n){if(e=_e(e),e){const r=a.findKey(this,e);if(r){const s=this[r];if(!n)return s;if(n===!0)return _r(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,n){if(e=_e(e),e){const r=a.findKey(this,e);return!!(r&&this[r]!==void 0&&(!n||Qe(this,this[r],r,n)))}return!1}delete(e,n){const r=this;let s=!1;function o(i){if(i=_e(i),i){const l=a.findKey(r,i);l&&(!n||Qe(r,r[l],l,n))&&(delete r[l],s=!0)}}return a.isArray(e)?e.forEach(o):o(e),s}clear(e){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!e||Qe(this,this[o],o,e,!0))&&(delete this[o],s=!0)}return s}normalize(e){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=Ue(s),delete n[o];return}const l=e?Cr(o):String(o).trim();l!==o&&delete n[o],n[l]=Ue(s),r[l]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=e&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,n])=>e+": "+n).join(`
|
|
3
|
+
`)}getSetCookie(){const e=this.get("set-cookie");return a.isArray(e)?e:e==null||e===!1?[]:[e]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static parseParameters(e){return Ar(e)}static concat(e,...n){const r=new this(e);return n.forEach(s=>r.set(s)),r}static accessor(e){const r=(this[Dt]=this[Dt]={accessors:{}}).accessors,s=this.prototype;function o(i){const l=_e(i);r[l]||(Lr(s,i),r[l]=!0)}return a.isArray(e)?e.forEach(o):o(e),this}};B.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(B.prototype,({value:t},e)=>{let n=e[0].toUpperCase()+e.slice(1);return{get:()=>t,set(r){this[n]=r}}}),a.freezeMethods(B);const Fe="[REDACTED ****]";function Dr(t){if(a.hasOwnProp(t,"toJSON"))return!0;let e=Object.getPrototypeOf(t);for(;e&&e!==Object.prototype;){if(a.hasOwnProp(e,"toJSON"))return!0;e=Object.getPrototypeOf(e)}return!1}function Nr(t,e){const n=new Set(e.map(o=>String(o).toLowerCase())),r=[],s=o=>{if(o===null||typeof o!="object"||a.isBuffer(o))return o;if(r.indexOf(o)!==-1)return;o instanceof B&&(o=o.toJSON()),r.push(o);let i;if(a.isArray(o))i=[],o.forEach((l,c)=>{const d=s(l);a.isUndefined(d)||(i[c]=d)});else{if(!a.isPlainObject(o)&&Dr(o))return r.pop(),o;i=Object.create(null);for(const[l,c]of Object.entries(o)){const d=n.has(l.toLowerCase())?Fe:s(c);a.isUndefined(d)||(i[l]=d)}}return r.pop(),i};return s(t)}function Nt(t){try{return String(t)}catch{return""}}function kr(t){return t.errors.map(n=>{try{return n&&n.message?Nt(n.message):Nt(n)}catch{return""}}).filter(Boolean).join("; ")||t.name||"AggregateError"}let g=class bn extends Error{static from(e,n,r,s,o,i){let l=e.message;!l&&a.isArray(e.errors)&&e.errors.length&&(l=kr(e));const c=new bn(l,n||e.code,r,s,o);return Object.defineProperty(c,"cause",{__proto__:null,value:e,writable:!0,enumerable:!1,configurable:!0}),c.name=e.name,e.status!=null&&c.status==null&&(c.status=e.status),i&&Object.assign(c,i),c}constructor(e,n,r,s,o){super(e),Object.defineProperty(this,"message",{__proto__:null,value:e,enumerable:!0,writable:!0,configurable:!0}),this.name="AxiosError",this.isAxiosError=!0,n&&(this.code=n),r&&(this.config=r),s&&(this.request=s),o&&(this.response=o,this.status=o.status)}toJSON(){const e=this.config,n=e&&a.hasOwnProp(e,"redact")?e.redact:void 0,r=a.isArray(n)&&n.length>0?Nr(e,n):a.toJSONObject(e);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:r,code:this.code,status:this.status}}};g.ERR_BAD_OPTION_VALUE="ERR_BAD_OPTION_VALUE",g.ERR_BAD_OPTION="ERR_BAD_OPTION",g.ECONNABORTED="ECONNABORTED",g.ETIMEDOUT="ETIMEDOUT",g.ECONNREFUSED="ECONNREFUSED",g.ERR_NETWORK="ERR_NETWORK",g.ERR_FR_TOO_MANY_REDIRECTS="ERR_FR_TOO_MANY_REDIRECTS",g.ERR_DEPRECATED="ERR_DEPRECATED",g.ERR_BAD_RESPONSE="ERR_BAD_RESPONSE",g.ERR_BAD_REQUEST="ERR_BAD_REQUEST",g.ERR_CANCELED="ERR_CANCELED",g.ERR_NOT_SUPPORT="ERR_NOT_SUPPORT",g.ERR_INVALID_URL="ERR_INVALID_URL",g.ERR_FORM_DATA_DEPTH_EXCEEDED="ERR_FORM_DATA_DEPTH_EXCEEDED";const vr=null,kt=100;function Ye(t){return a.isPlainObject(t)||a.isArray(t)}function vt(t){return a.endsWith(t,"[]")?t.slice(0,-2):t}function Ze(t,e,n){return t?t.concat(e).map(function(s,o){return s=vt(s),!n&&o?"["+s+"]":s}).join(n?".":""):e}function Ur(t){return a.isArray(t)&&!t.some(Ye)}const Fr=a.toFlatObject(a,{},null,function(e){return/^is[A-Z]/.test(e)});function je(t,e,n){if(!a.isObject(t))throw new TypeError("target must be an object");e=e||new FormData;const r=(m,w)=>{const E=a.getSafeProp(n,m);return a.isUndefined(E)?w:E},s=r("metaTokens",!0),o=r("visitor")||O,i=r("dots",!1),l=r("indexes",!1),c=r("Blob")||typeof Blob<"u"&&Blob,d=r("maxDepth",kt),u=c&&a.isSpecCompliantForm(e),h=[];if(!a.isFunction(o))throw new TypeError("visitor must be a function");function p(m){if(m===null)return"";if(a.isDate(m))return m.toISOString();if(a.isBoolean(m))return m.toString();if(!u&&a.isBlob(m))throw new g("Blob is not supported. Use a Buffer instead.");if(a.isArrayBuffer(m)||a.isTypedArray(m)){if(u&&typeof c=="function")return new c([m]);throw new g("Blob is not supported. Use a Buffer instead.",g.ERR_NOT_SUPPORT)}return m}function S(m){if(m>d)throw new g("Object is too deeply nested ("+m+" levels). Max depth: "+d,g.ERR_FORM_DATA_DEPTH_EXCEEDED)}function _(m,w){if(d===1/0)return JSON.stringify(m);const E=[];return JSON.stringify(m,function(F,D){if(!a.isObject(D))return D;for(;E.length&&E[E.length-1]!==this;)E.pop();return E.push(D),S(w+E.length-1),D})}function O(m,w,E){let L=m;if(a.isReactNative(e)&&a.isReactNativeBlob(m))return e.append(Ze(E,w,i),p(m)),!1;if(m&&!E&&typeof m=="object"){if(a.endsWith(w,"{}"))w=s?w:w.slice(0,-2),m=_(m,1);else if(a.isArray(m)&&Ur(m)||(a.isFileList(m)||a.endsWith(w,"[]"))&&(L=a.toArray(m)))return w=vt(w),L.forEach(function(D,J){!(a.isUndefined(D)||D===null)&&e.append(l===!0?Ze([w],J,i):l===null?w:w+"[]",p(D))}),!1}return Ye(m)?!0:(e.append(Ze(E,w,i),p(m)),!1)}const k=Object.assign(Fr,{defaultVisitor:O,convertValue:p,isVisitable:Ye});function f(m,w,E=0){if(!a.isUndefined(m)){if(S(E),h.indexOf(m)!==-1)throw new Error("Circular reference detected in "+w.join("."));h.push(m),a.forEach(m,function(F,D){(!(a.isUndefined(F)||F===null)&&o.call(e,F,a.isString(D)?D.trim():D,w,k))===!0&&f(F,w?w.concat(D):[D],E+1)}),h.pop()}}if(!a.isObject(t))throw new TypeError("data must be an object");return f(t),e}function Ut(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+"};return encodeURIComponent(t).replace(/[!'()~]|%20/g,function(r){return e[r]})}function et(t,e){this._pairs=[],t&&je(t,this,e)}const Ft=et.prototype;Ft.append=function(e,n){this._pairs.push([e,n])},Ft.toString=function(e){const n=e?r=>e.call(this,r,Ut):Ut;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function jr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+")}function jt(t,e,n){if(!e)return t;t=t||"";const r=a.isFunction(n)?{serialize:n}:n,s=a.getSafeProp(r,"encode")||jr,o=a.getSafeProp(r,"serialize");let i;if(o?i=o(e,r):i=a.isURLSearchParams(e)?e.toString():new et(e,r).toString(s),i){const l=t.indexOf("#");l!==-1&&(t=t.slice(0,l)),t+=(t.indexOf("?")===-1?"?":"&")+i}return t}const xe=Symbol("internals");function Bt(t){return t?t.length:0}function Mt(t){if(t)for(;t.length&&t[t.length-1]===null;)t.pop()}function Te(t,e){const n=t.handlers,r=Bt(n);n!==e.handlersRef?(e.handlersRef=n,e.handlerEntries.clear()):r!==e.handlersLength&&(r?e.handlerEntries.forEach(function(o,i){n[o.index]!==o.handler&&e.handlerEntries.delete(i)}):e.handlerEntries.clear()),e.handlersLength=r}class It{constructor(){this.handlers=[],this[xe]={handlersRef:this.handlers,handlersLength:this.handlers.length,handlerEntries:new Map,iterationDepth:0,nextId:0}}use(e,n,r){const s={fulfilled:e,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null},o=this[xe];this.handlers==null&&(this.handlers=[]),Te(this,o);const i=o.nextId++;return this.handlers.push(s),o.handlerEntries.set(i,{handler:s,index:this.handlers.length-1}),o.handlersLength=this.handlers.length,i}eject(e){const n=this[xe];Te(this,n);const r=n.handlerEntries.get(e);if(r){if(n.handlerEntries.delete(e),this.handlers[r.index]!==r.handler)return;this.handlers[r.index]=null,n.iterationDepth||(Mt(this.handlers),n.handlersLength=this.handlers.length)}}clear(){this.handlers&&(this.handlers=[],Te(this,this[xe]))}forEach(e){const n=this[xe];Te(this,n),n.iterationDepth++;try{a.forEach(this.handlers,function(s){s!==null&&e(s)})}finally{--n.iterationDepth||(Te(this,n),Mt(this.handlers),n.handlersLength=Bt(this.handlers))}}}const tt={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1,legacyInterceptorReqResOrdering:!0,advertiseZstdAcceptEncoding:!1,validateStatusUndefinedResolves:!0},Br={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:et,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},nt=typeof window<"u"&&typeof document<"u",rt=typeof navigator=="object"&&navigator||void 0,Mr=nt&&(!rt||["ReactNative","NativeScript","NS"].indexOf(rt.product)<0),Ir=typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function",Hr=nt&&window.location.href||"http://localhost",U={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:nt,hasStandardBrowserEnv:Mr,hasStandardBrowserWebWorkerEnv:Ir,navigator:rt,origin:Hr},Symbol.toStringTag,{value:"Module"})),...Br};function qr(t,e){return je(t,new U.classes.URLSearchParams,{visitor:function(n,r,s,o){return U.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)},...e})}const Ht=kt;function qt(t){if(t>Ht)throw new g("FormData field is too deeply nested ("+t+" levels). Max depth: "+Ht,g.ERR_FORM_DATA_DEPTH_EXCEEDED)}function $r(t){const e=[],n=/[^.[\]]+|\[([^.[\]]*)]/g;let r;for(;(r=n.exec(t))!==null;)qt(e.length),e.push(r[0]==="[]"?"":r[1]||r[0]);return e}function Kr(t){const e={},n=Object.keys(t);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],e[o]=t[o];return e}function $t(t){function e(n,r,s,o){qt(o);let i=n[o++];if(i==="__proto__")return!0;const l=Number.isFinite(+i),c=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,c?(a.hasOwnProp(s,i)?s[i]=a.isArray(s[i])?s[i].concat(r):[s[i],r]:s[i]=r,!l):((!a.hasOwnProp(s,i)||!a.isObject(s[i]))&&(s[i]=[]),e(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=Kr(s[i])),!l)}if(a.isFormData(t)&&a.isFunction(t.entries)){const n={};return a.forEachEntry(t,(r,s)=>{e($r(r),s,n,0)}),n}return null}const Kt=Object.freeze(["get","delete","head","options","post","put","patch","purge","link","unlink","query"]),be=(t,e)=>t!=null&&a.hasOwnProp(t,e)?t[e]:void 0;function zr(t,e,n){if(a.isString(t))try{return(e||JSON.parse)(t),a.trim(t)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(t)}const Ae={transitional:tt,adapter:["xhr","http","fetch"],transformRequest:[function(e,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(e);if(o&&a.isHTMLForm(e)&&(e=new FormData(e)),a.isFormData(e))return s?JSON.stringify($t(e)):e;if(a.isArrayBuffer(e)||a.isBuffer(e)||a.isStream(e)||a.isFile(e)||a.isBlob(e)||a.isReadableStream(e))return e;if(a.isArrayBufferView(e))return e.buffer;if(a.isURLSearchParams(e))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let l;if(o){const c=be(this,"formSerializer");if(r.indexOf("application/x-www-form-urlencoded")>-1)return qr(e,c).toString();if((l=a.isFileList(e))||r.indexOf("multipart/form-data")>-1){const d=be(this,"env"),u=d&&d.FormData;return je(l?{"files[]":e}:e,u&&new u,c)}}return o||s?(n.setContentType("application/json",!1),zr(e)):e}],transformResponse:[function(e){const n=be(this,"transitional")||Ae.transitional,r=n&&n.forcedJSONParsing,s=be(this,"responseType"),o=s==="json";if(a.isResponse(e)||a.isReadableStream(e))return e;if(e&&a.isString(e)&&(r&&!s||o)){const l=!(n&&n.silentJSONParsing)&&o;try{return JSON.parse(e,be(this,"parseReviver"))}catch(c){if(l)throw c.name==="SyntaxError"?g.from(c,g.ERR_BAD_RESPONSE,this,null,be(this,"response")):c}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:U.classes.FormData,Blob:U.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(Kt,t=>{Ae.headers[t]={}});function st(t,e){const n=this||Ae,r=e||n,s=B.from(r.headers);let o=r.data;return a.forEach(t,function(l){o=l.call(n,o,s.normalize(),e?e.status:void 0)}),s.normalize(),o}function zt(t){return!!(t&&t.__CANCEL__)}let Pe=class extends g{constructor(e,n,r){super(e??"canceled",g.ERR_CANCELED,n,r),this.name="CanceledError",this.__CANCEL__=!0}};function Vt(t,e,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?t(n):e(new g("Request failed with status code "+n.status,n.status>=400&&n.status<500?g.ERR_BAD_REQUEST:g.ERR_BAD_RESPONSE,n.config,n.request,n))}const Vr=/[\t\n\r]/g;function Wt(t){if(typeof t!="string")return t;let e=0;for(;e<t.length&&t.charCodeAt(e)<=32;)e++;return t.slice(e).replace(Vr,"")}function ot(t){const e=/^([-+\w]{1,25}):(?:\/\/)?/.exec(t);return e&&e[1]||""}function Wr(t,e){t=t||10;const n=new Array(t),r=new Array(t);let s=0,o=0,i;return e=e!==void 0?e:1e3,function(c){const d=Date.now(),u=r[o];i||(i=d),n[s]=c,r[s]=d;let h=o,p=0;for(;h!==s;)p+=n[h++],h=h%t;if(s=(s+1)%t,s===o&&(o=(o+1)%t),d-i<e)return;const S=u&&d-u;return S?Math.round(p*1e3/S):void 0}}function Jr(t,e){let n=0,r=1e3/e,s,o;const i=(u,h=Date.now())=>{n=h,s=null,o&&(clearTimeout(o),o=null),t(...u)};return[(...u)=>{const h=Date.now(),p=h-n;p>=r?i(u,h):(s=u,o||(o=setTimeout(()=>{o=null,i(s)},r-p)))},()=>s&&i(s),(...u)=>i(u)]}const Be=(t,e,n=3)=>{let r=0;const s=Wr(50,250);return Jr(o=>{if(!o||!a.isNumber(o.loaded))return;const i=o.loaded,l=o.lengthComputable?o.total:void 0,c=Math.max(0,l!=null?Math.min(i,l):i),d=Math.max(0,c-r),u=s(d);r=Math.max(r,c);const h={loaded:c,total:l,progress:l?c/l:void 0,bytes:d,rate:u||void 0,estimated:u&&l?(l-c)/u:void 0,event:o,lengthComputable:l!=null,[e?"download":"upload"]:!0};t(h)},n)},Jt=(t,e)=>{const n=t!=null;return[r=>e[0]({lengthComputable:n,total:t,loaded:r}),e[1]]},Xt=(t,e=a.asap)=>(...n)=>e(()=>t(...n)),Xr=U.hasStandardBrowserEnv?((t,e)=>n=>(n=new URL(n,U.origin),t.protocol===n.protocol&&t.host===n.host&&(e||t.port===n.port)))(new URL(U.origin),U.navigator&&/(msie|trident)/i.test(U.navigator.userAgent)):()=>!0,Gr=U.hasStandardBrowserEnv?{write(t,e,n,r,s,o,i){if(typeof document>"u")return;const l=[`${t}=${encodeURIComponent(e)}`];a.isNumber(n)&&l.push(`expires=${new Date(n).toUTCString()}`),a.isString(r)&&l.push(`path=${r}`),a.isString(s)&&l.push(`domain=${s}`),o===!0&&l.push("secure"),a.isString(i)&&l.push(`SameSite=${i}`),document.cookie=l.join("; ")},read(t){if(typeof document>"u")return null;const e=document.cookie.split(";");for(let n=0;n<e.length;n++){const r=e[n].replace(/^\s+/,""),s=r.indexOf("=");if(s!==-1&&r.slice(0,s)===t)try{return decodeURIComponent(r.slice(s+1))}catch{return r.slice(s+1)}}return null},remove(t){this.write(t,"",Date.now()-864e5,"/")}}:{write(){},read(){return null},remove(){}};function Qr(t){return typeof t!="string"?!1:/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Yr(t,e){if(!e)return t;let n=t.length;for(;n>0&&t.charCodeAt(n-1)===47;)n--;return t.slice(0,n)+"/"+e.replace(/^\/+/,"")}const Zr=/^https?:(?!\/\/)/i;function es(t){return t&&t.replace(/(^|&)([^=&]*=)?[^&]+/g,(e,n,r="")=>`${n}${r}${Fe}`)}function ts(t){const e=t.replace(/^(https?:\/{0,2})[^/?#]*@/i,`$1${Fe}@`),n=e.indexOf("#"),s=(n===-1?e:e.slice(0,n)).replace(/([?&][^=&#]*=)[^&#]*/g,`$1${Fe}`);return n===-1?s:`${s}#${es(e.slice(n+1))}`}function Gt(t,e){if(typeof t=="string"){const n=Wt(t);if(Zr.test(n))throw new g(`Invalid URL ${JSON.stringify(ts(n))}: missing "//" after protocol`,g.ERR_INVALID_URL,e)}}function Qt(t,e,n,r){Gt(e,r);let s=!Qr(e);return t&&(s||n===!1)?(Gt(t,r),Yr(t,e)):e}const Yt=t=>t instanceof B?{...t}:t,ns=t=>Object.getOwnPropertySymbols&&Object.getOwnPropertyDescriptor?Object.keys(t).concat(Object.getOwnPropertySymbols(t).filter(e=>Object.getOwnPropertyDescriptor(t,e).enumerable)):Object.keys(t);function fe(t,e){t=t||{},e=e||{};const n=Object.create(null);Object.defineProperty(n,"hasOwnProperty",{__proto__:null,value:Object.prototype.hasOwnProperty,enumerable:!1,writable:!0,configurable:!0});function r(u,h,p,S){return a.isPlainObject(u)&&a.isPlainObject(h)?a.merge.call({caseless:S},u,h):a.isPlainObject(h)?a.merge({},h):a.isArray(h)?h.slice():h}function s(u,h,p,S){if(a.isUndefined(h)){if(!a.isUndefined(u))return r(void 0,u,p,S)}else return r(u,h,p,S)}function o(u,h){if(!a.isUndefined(h))return r(void 0,h)}function i(u,h){if(a.isUndefined(h)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,h)}function l(u){const h=a.hasOwnProp(e,"transitional")?e.transitional:void 0;if(!a.isUndefined(h))if(a.isPlainObject(h)){if(a.hasOwnProp(h,u))return h[u]}else return;const p=a.hasOwnProp(t,"transitional")?t.transitional:void 0;if(a.isPlainObject(p)&&a.hasOwnProp(p,u))return p[u]}function c(u,h,p){if(a.hasOwnProp(e,p))return r(u,h);if(a.hasOwnProp(t,p))return r(void 0,u)}const d={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutErrorMessage:i,withCredentials:i,withXSRFToken:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,allowedSocketPaths:i,responseEncoding:i,validateStatus:c,headers:(u,h,p)=>s(Yt(u),Yt(h),p,!0)};return a.forEach(ns({...t,...e}),function(h){if(h==="__proto__"||h==="constructor"||h==="prototype")return;const p=a.hasOwnProp(d,h)?d[h]:s,S=a.hasOwnProp(t,h)?t[h]:void 0,_=a.hasOwnProp(e,h)?e[h]:void 0,O=p(S,_,h);a.isUndefined(O)&&p!==c||(n[h]=O)}),a.hasOwnProp(e,"validateStatus")&&a.isUndefined(e.validateStatus)&&l("validateStatusUndefinedResolves")===!1&&(a.hasOwnProp(t,"validateStatus")?n.validateStatus=r(void 0,t.validateStatus):delete n.validateStatus),n}const rs=["content-type","content-length"];function ss(t,e,n){if(n!=="content-only"){t.set(e);return}Object.entries(e||{}).forEach(([r,s])=>{rs.includes(r.toLowerCase())&&t.set(r,s)})}const os=t=>encodeURIComponent(t).replace(/%([0-9A-F]{2})/gi,(e,n)=>String.fromCharCode(parseInt(n,16)));function Zt(t){const e=fe({},t),n=p=>a.hasOwnProp(e,p)?e[p]:void 0,r=n("data");let s=n("withXSRFToken");const o=n("xsrfHeaderName"),i=n("xsrfCookieName");let l=n("headers");const c=n("auth"),d=n("baseURL"),u=n("allowAbsoluteUrls"),h=n("url");if(e.headers=l=B.from(l),e.url=jt(Qt(d,h,u,e),n("params"),n("paramsSerializer")),c){const p=a.getSafeProp(c,"username")||"",S=a.getSafeProp(c,"password")||"";try{l.set("Authorization","Basic "+btoa(p+":"+(S?os(S):"")))}catch(_){throw g.from(_,g.ERR_BAD_OPTION_VALUE,t)}}if(a.isFormData(r)){const p=a.getSafeProp(r,"getHeaders");U.hasStandardBrowserEnv||U.hasStandardBrowserWebWorkerEnv||a.isReactNative(r)?l.setContentType(void 0):a.isFunction(p)&&ss(l,p.call(r),n("formDataHeaderPolicy"))}if(U.hasStandardBrowserEnv&&(a.isFunction(s)&&(s=s(e)),s===!0||s==null&&Xr(e.url))){const S=o&&i&&Gr.read(i);S&&l.set(o,S)}return e}const is=typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(n,r){const s=Zt(t);let o=s.data;const i=B.from(s.headers).normalize();let{responseType:l,onUploadProgress:c,onDownloadProgress:d}=s,u,h,p,S,_,O;function k(){S&&S(),_&&_(),s.cancelToken&&s.cancelToken.unsubscribe(u),s.signal&&s.signal.removeEventListener("abort",u)}let f=new XMLHttpRequest;f.open(s.method.toUpperCase(),s.url,!0),f.timeout=s.timeout;function m(E){if(!f)return;if(f.status===0&&(ot(Wt(s.url))||ot(U.origin))!=="file"&&!(f.responseURL&&f.responseURL.startsWith("file:"))){r(new g("Request aborted",g.ECONNABORTED,t,f)),k(),f=null;return}try{E?O&&O(E):_&&_()}catch(J){setTimeout(()=>{throw J})}if(!f)return;const L=B.from("getAllResponseHeaders"in f&&f.getAllResponseHeaders()),D={data:!l||l==="text"||l==="json"?f.responseText:f.response,status:f.status,statusText:f.statusText,headers:L,config:t,request:f};Vt(function(H){n(H),k()},function(H){r(H),k()},D),f=null}"onloadend"in f?f.onloadend=m:f.onreadystatechange=function(){!f||f.readyState!==4||f.status===0&&!(f.responseURL&&f.responseURL.startsWith("file:"))||setTimeout(m)},f.onabort=function(){f&&(r(new g("Request aborted",g.ECONNABORTED,t,f)),k(),f=null)},f.onerror=function(L){const F=L&&L.message?L.message:"Network Error",D=new g(F,g.ERR_NETWORK,t,f);D.event=L||null,r(D),k(),f=null},f.ontimeout=function(){let L=s.timeout?"timeout of "+s.timeout+"ms exceeded":"timeout exceeded";const F=s.transitional||tt;s.timeoutErrorMessage&&(L=s.timeoutErrorMessage),r(new g(L,F.clarifyTimeoutError?g.ETIMEDOUT:g.ECONNABORTED,t,f)),k(),f=null},o===void 0&&i.setContentType(null),"setRequestHeader"in f&&a.forEach(Lt(i),function(L,F){f.setRequestHeader(F,L)}),a.isUndefined(s.withCredentials)||(f.withCredentials=!!s.withCredentials),l&&l!=="json"&&(f.responseType=s.responseType),d&&([p,_,O]=Be(d,!0),f.addEventListener("progress",p)),c&&f.upload&&([h,S]=Be(c),f.upload.addEventListener("progress",h),f.upload.addEventListener("loadend",S)),(s.cancelToken||s.signal)&&(u=E=>{f&&(r(!E||E.type?new Pe(null,t,f):E),f.abort(),k(),f=null)},s.cancelToken&&s.cancelToken.subscribe(u),s.signal&&(s.signal.aborted?u():s.signal.addEventListener("abort",u)));const w=ot(s.url);if(w&&!U.protocols.includes(w)){r(new g("Unsupported protocol "+w+":",g.ERR_BAD_REQUEST,t)),k();return}f.send(o||null)})},as=(t,e)=>{if(t=t?t.filter(Boolean):[],!e&&!t.length)return;const n=new AbortController;let r=!1;const s=function(c){if(!r){r=!0,i();const d=c instanceof Error?c:this.reason;n.abort(d instanceof g?d:new Pe(d instanceof Error?d.message:d))}};let o=e&&setTimeout(()=>{o=null,s(new g(`timeout of ${e}ms exceeded`,g.ETIMEDOUT))},e);const i=()=>{t&&(o&&clearTimeout(o),o=null,t.forEach(c=>{c.unsubscribe?c.unsubscribe(s):c.removeEventListener("abort",s)}),t=null)};t.forEach(c=>{if(!r){if(c.aborted){s.call(c);return}c.addEventListener("abort",s,{once:!0})}});const{signal:l}=n;return l.unsubscribe=()=>a.asap(i),l},ls=function*(t,e){let n=t.byteLength;if(n<e){yield t;return}let r=0,s;for(;r<n;)s=r+e,yield t.slice(r,s),r=s},cs=async function*(t,e){for await(const n of us(t))yield*ls(n,e)},us=async function*(t){if(t[Symbol.asyncIterator]){yield*t;return}const e=t.getReader();try{for(;;){const{done:n,value:r}=await e.read();if(n)break;yield r}}finally{await e.cancel()}},en=(t,e,n,r)=>{const s=cs(t,e);let o=0,i,l=c=>{i||(i=!0,r&&r(c))};return new ReadableStream({async pull(c){try{const{done:d,value:u}=await s.next();if(d){l(),c.close();return}let h=u.byteLength;if(n){let p=o+=h;n(p)}c.enqueue(new Uint8Array(u))}catch(d){throw l(d),d}},cancel(c){return l(c),s.return()}},{highWaterMark:2})},tn=t=>t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102,nn=(t,e,n)=>e+2<n&&tn(t.charCodeAt(e+1))&&tn(t.charCodeAt(e+2)),rn=t=>t<=57?t-48:(t&223)-55,fs=t=>t>=65&&t<=90||t>=97&&t<=122||t>=48&&t<=57||t===43||t===47||t===45||t===95,ds=t=>t===9||t===10||t===12||t===13||t===32,hs=t=>{const e=Math.floor(t/4),n=t%4;return e*3+(n===2?1:n===3?2:0)},ps=t=>{const e=t.length;let n=0;return e>0&&t.charCodeAt(e-1)===61&&(n++,e>1&&t.charCodeAt(e-2)===61&&n++),Math.floor((e-n)*3/4)},gs=t=>{const e=t.length;let n=0,r=0,s=!1;for(let o=0;o<e;o++){let i=t.charCodeAt(o);if(i===37&&nn(t,o,e)&&(i=rn(t.charCodeAt(o+1))*16+rn(t.charCodeAt(o+2)),o+=2),!ds(i)){if(i===61){r++;continue}if(!fs(i)||r>0){s=!0;continue}n++}}return s||r>2||r>0&&(n+r)%4!==0||n%4===1?ps(t):hs(n)},ms=(t,e)=>{if(!t||typeof t!="string"||!t.startsWith("data:"))return 0;const n=t.indexOf(",");if(n<0)return 0;const r=t.slice(5,n),s=t.slice(n+1);if(/;base64/i.test(r))return e(s);let i=0;for(let l=0,c=s.length;l<c;l++){const d=s.charCodeAt(l);if(d===37&&nn(s,l,c))i+=1,l+=2;else if(d<128)i+=1;else if(d<2048)i+=2;else if(d>=55296&&d<=56319&&l+1<c){const u=s.charCodeAt(l+1);u>=56320&&u<=57343?(i+=4,l++):i+=3}else i+=3}return i};function ys(t){const e=typeof t=="string"?t.indexOf("#"):-1;return ms(e===-1?t:t.slice(0,e),gs)}const it="1.20.0",sn=64*1024,bs={cache:"default",redirect:"follow",referrer:"about:client",referrerPolicy:"",mode:"cors",integrity:"",keepalive:!1,priority:"auto",window:null},{isFunction:Me}=a,Es=t=>encodeURIComponent(t).replace(/%([0-9A-F]{2})/gi,(e,n)=>String.fromCharCode(parseInt(n,16))),on=t=>{if(!a.isString(t))return t;try{return decodeURIComponent(t)}catch{return t}},an=(t,...e)=>{try{return!!t(...e)}catch{return!1}},ws=t=>{const e=t.indexOf("://");let n=t;return e!==-1&&(n=n.slice(e+3)),n.includes("@")||n.includes(":")},Rs=t=>{const e=a.global!==void 0&&a.global!==null?a.global:globalThis,{ReadableStream:n,TextEncoder:r}=e;t=a.merge.call({skipUndefined:!0},{Request:e.Request,Response:e.Response},t);const{fetch:s,Request:o,Response:i}=t,l=s?Me(s):typeof fetch=="function",c=Me(o),d=Me(i);if(!l)return!1;const u=l&&Me(n),h=l&&(typeof r=="function"?(f=>m=>f.encode(m))(new r):async f=>new Uint8Array(await new o(f).arrayBuffer())),p=c&&u&&an(()=>{let f=!1;const m=new o(U.origin,{body:new n,method:"POST",get duplex(){return f=!0,"half"}}),w=m.headers.has("Content-Type");return m.body!=null&&m.body.cancel(),f&&!w}),S=d&&u&&an(()=>a.isReadableStream(new i("").body)),_={stream:S&&(f=>f.body)};l&&["text","arrayBuffer","blob","formData","stream"].forEach(f=>{!_[f]&&(_[f]=(m,w)=>{let E=m&&m[f];if(E)return E.call(m);throw new g(`Response type '${f}' is not supported`,g.ERR_NOT_SUPPORT,w)})});const O=async f=>{if(f==null)return 0;if(a.isBlob(f))return f.size;if(a.isSpecCompliantForm(f))return(await new o(U.origin,{method:"POST",body:f}).arrayBuffer()).byteLength;if(a.isArrayBufferView(f)||a.isArrayBuffer(f))return f.byteLength;if(a.isURLSearchParams(f)&&(f=f+""),a.isString(f))return(await h(f)).byteLength},k=async(f,m)=>{const w=a.toFiniteNumber(f.getContentLength());return w??O(m)};return async f=>{let{url:m,method:w,data:E,signal:L,cancelToken:F,timeout:D,onDownloadProgress:J,onUploadProgress:H,responseType:V,headers:ee,withCredentials:he="same-origin",fetchOptions:ie,maxContentLength:X,maxBodyLength:pe,maxRedirects:ht}=Zt(f);const y=a.isNumber(X)&&X>-1,A=a.isNumber(pe)&&pe>-1,v=x=>a.hasOwnProp(f,x)?f[x]:void 0;let b=s||fetch;V=V?(V+"").toLowerCase():"text";let P=as([L,F&&F.toAbortSignal()],D),C=null;const G=P&&P.unsubscribe&&(()=>{P.unsubscribe()});let q,ne=null;const $e=()=>new g("Request body larger than maxBodyLength limit",g.ERR_BAD_REQUEST,f,C);try{let x;const Q=v("auth");if(Q){const R=a.getSafeProp(Q,"username")||"",I=a.getSafeProp(Q,"password")||"";x={username:R,password:I}}if(ws(m)){const R=new URL(m,U.origin);if(!x&&(R.username||R.password)){const I=on(R.username),ae=on(R.password);x={username:I,password:ae}}(R.username||R.password)&&(R.username="",R.password="",m=R.href)}if(x&&(ee.delete("authorization"),ee.set("Authorization","Basic "+btoa(Es((x.username||"")+":"+(x.password||""))))),y&&typeof m=="string"&&m.startsWith("data:")&&ys(m)>X)throw new g("maxContentLength size of "+X+" exceeded",g.ERR_BAD_RESPONSE,f,C);if(A&&w!=="get"&&w!=="head"){const R=await O(E);if(typeof R=="number"&&isFinite(R)&&(q=R,R>pe))throw $e()}const Ee=A&&(a.isReadableStream(E)||a.isStream(E)),Ke=(R,I,ae)=>en(R,sn,ge=>{if(A&&ge>pe)throw ne=$e();I&&I(ge)},ae);if(p&&w!=="get"&&w!=="head"&&(H||Ee)){if(q=q??await k(ee,E),q!==0||Ee){let R=new o(m,{method:"POST",body:E,duplex:"half"}),I;if(a.isFormData(E)&&(I=R.headers.get("content-type"))&&ee.setContentType(I),R.body){const[ae,ge]=H&&Jt(q,Be(Xt(H)))||[];E=Ke(R.body,ae,ge)}}}else if(Ee&&!c&&u&&w!=="get"&&w!=="head")E=Ke(E);else if(Ee&&c&&!p&&w!=="get"&&w!=="head")throw new g("Stream request bodies are not supported by the current fetch implementation",g.ERR_NOT_SUPPORT,f,C);a.isString(he)||(he=he?"include":"omit");const ze=c&&"credentials"in o.prototype;if(a.isFormData(E)){const R=ee.getContentType();R&&/^multipart\/form-data/i.test(R)&&!/boundary=/i.test(R)&&ee.delete("content-type")}ee.set("User-Agent","axios/"+it,!1);const $=ie==null?ie:Object.assign(Object.create(null),ie);$&&(delete $.body,delete $.headers,delete $.method,delete $.signal,delete $.duplex,delete $.credentials);const te=Object.assign(Object.create(null),$,{signal:P,method:w.toUpperCase(),headers:Lt(ee.normalize()),body:E,duplex:"half",credentials:ze?he:void 0});c&&(a.forEach(bs,(R,I)=>{te[I]===void 0&&(te[I]=R)}),te.signal===void 0&&(te.signal=null),te.body===void 0&&(te.body=null)),ht===0&&(te.redirect="manual",$&&($.redirect="manual")),C=c&&new o(m,te);let re=await(c?b(C,$):b(m,te));const mn=B.from(re.headers);if(y){const R=a.toFiniteNumber(mn.getContentLength());if(R!=null&&R>X)throw new g("maxContentLength size of "+X+" exceeded",g.ERR_BAD_RESPONSE,f,C)}const pt=S&&(V==="stream"||V==="response");if(S&&re.body&&(J||y||pt&&G)){const R={};["status","statusText","headers"].forEach(Le=>{R[Le]=re[Le]});const I=a.toFiniteNumber(mn.getContentLength()),[ae,ge]=J&&Jt(I,Be(Xt(J),!0))||[];let yn=0;const Ws=Le=>{if(y&&(yn=Le,yn>X))throw new g("maxContentLength size of "+X+" exceeded",g.ERR_BAD_RESPONSE,f,C);ae&&ae(Le)};re=new i(en(re.body,sn,Ws,()=>{ge&&ge(),G&&G()}),R)}V=V||"text";let se=await _[a.findKey(_,V)||"text"](re,f);if(y&&!S&&!pt){let R;if(se!=null&&(typeof se.byteLength=="number"?R=se.byteLength:typeof se.size=="number"?R=se.size:typeof se=="string"&&(R=typeof r=="function"?new r().encode(se).byteLength:se.length)),typeof R=="number"&&R>X)throw new g("maxContentLength size of "+X+" exceeded",g.ERR_BAD_RESPONSE,f,C)}return!pt&&G&&G(),await new Promise((R,I)=>{Vt(R,I,{data:se,headers:B.from(re.headers),status:re.status,statusText:re.statusText,config:f,request:C})})}catch(x){if(G&&G(),P&&P.aborted&&P.reason instanceof g){const Q=P.reason;throw Q.config=f,C&&(Q.request=C),x!==Q&&Object.defineProperty(Q,"cause",{__proto__:null,value:x,writable:!0,enumerable:!1,configurable:!0}),Q}if(ne)throw C&&!ne.request&&(ne.request=C),ne;if(x instanceof g)throw C&&!x.request&&(x.request=C),x;if(x&&x.name==="TypeError"&&/Load failed|fetch/i.test(x.message)){const Q=new g("Network Error",g.ERR_NETWORK,f,C,x&&x.response);throw Object.defineProperty(Q,"cause",{__proto__:null,value:x.cause||x,writable:!0,enumerable:!1,configurable:!0}),Q}throw g.from(x,x&&x.code,f,C,x&&x.response)}}},Os=new Map,ln=t=>{let e=t&&t.env||{};const{fetch:n,Request:r,Response:s}=e,o=[r,s,n];let i=o.length,l=i,c,d,u=Os;for(;l--;)c=o[l],d=u.get(c),d===void 0&&u.set(c,d=l?new Map:Rs(e)),u=d;return d};ln();const at={http:vr,xhr:is,fetch:{get:ln}};a.forEach(at,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{__proto__:null,value:e})}catch{}Object.defineProperty(t,"adapterName",{__proto__:null,value:e})}});const cn=t=>`- ${t}`,Ss=t=>a.isFunction(t)||t===null||t===!1;function _s(t,e){t=a.isArray(t)?t:[t];const{length:n}=t;let r,s;const o={};for(let i=0;i<n;i++){r=t[i];let l;if(s=r,!Ss(r)&&(s=at[(l=String(r)).toLowerCase()],s===void 0))throw new g(`Unknown adapter '${l}'`);if(s&&(a.isFunction(s)||(s=s.get(e))))break;o[l||"#"+i]=s}if(!s){const i=Object.entries(o).map(([c,d])=>`adapter ${c} `+(d===!1?"is not supported by the environment":"is not available in the build"));let l=n?i.length>1?`since :
|
|
4
|
+
`+i.map(cn).join(`
|
|
5
|
+
`):" "+cn(i[0]):"as no adapter specified";throw new g("There is no suitable adapter to dispatch the request "+l,g.ERR_NOT_SUPPORT)}return s}const un={getAdapter:_s,adapters:at};function lt(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Pe(null,t)}function ct(t){const e=a.toSafeFlatObject(t);return lt(e),e.headers=B.from(a.getSafeProp(e,"headers")),e.data=st.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),un.getAdapter(e.adapter||Ae.adapter,e)(e).then(function(s){lt(e),e.response=s;try{s.data=st.call(e,e.transformResponse,s)}finally{delete e.response}return s.headers=B.from(s.headers),s},function(s){if(!zt(s)&&(lt(e),s&&s.response)){e.response=s.response;try{s.response.data=st.call(e,e.transformResponse,s.response)}finally{delete e.response}s.response.headers=B.from(s.response.headers)}return Promise.reject(s)})}const Ie={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{Ie[t]=function(r){return typeof r===t||"a"+(e<1?"n ":" ")+t}});const fn={};Ie.transitional=function(e,n,r){function s(o,i){return"[Axios v"+it+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,l)=>{if(e===!1)throw new g(s(i," has been removed"+(n?" in "+n:"")),g.ERR_DEPRECATED);return n&&!fn[i]&&(fn[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),e?e(o,i,l):!0}},Ie.spelling=function(e){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${e}`),!0)};function xs(t,e,n){if(typeof t!="object"||t===null)throw new g("options must be an object",g.ERR_BAD_OPTION_VALUE);const r=Object.keys(t);let s=r.length;for(;s-- >0;){const o=r[s],i=Object.prototype.hasOwnProperty.call(e,o)?e[o]:void 0;if(i){const l=t[o],c=l===void 0||i(l,o,t);if(c!==!0)throw new g("option "+o+" must be "+c,g.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new g("Unknown option "+o,g.ERR_BAD_OPTION)}}const He={assertOptions:xs,validators:Ie},M=He.validators;let de=class{constructor(e){this.defaults=e||{},this.interceptors={request:new It,response:new It}}async request(e,n){try{return await this._request(e,n)}catch(r){if(r instanceof Error)try{let s={};Error.captureStackTrace?Error.captureStackTrace(s):s=new Error;const o=s.stack;let i="";if(typeof o=="string"){const l=o.indexOf(`
|
|
6
|
+
`);i=l===-1?"":o.slice(l+1)}if(!r.stack)r.stack=i;else if(i){const l=i.indexOf(`
|
|
7
|
+
`),c=l===-1?-1:i.indexOf(`
|
|
8
|
+
`,l+1),d=c===-1?"":i.slice(c+1);String(r.stack).endsWith(d)||(r.stack+=`
|
|
9
|
+
`+i)}}catch{}throw r}}_request(e,n){typeof e=="string"?(n=n||{},n.url=e):n=e||{},n=fe(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&He.assertOptions(r,{silentJSONParsing:M.transitional(M.boolean),forcedJSONParsing:M.transitional(M.boolean),clarifyTimeoutError:M.transitional(M.boolean),legacyInterceptorReqResOrdering:M.transitional(M.boolean),advertiseZstdAcceptEncoding:M.transitional(M.boolean),validateStatusUndefinedResolves:M.transitional(M.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:He.assertOptions(s,{encode:M.function,serialize:M.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),He.assertOptions(n,{baseUrl:M.spelling("baseURL"),withXsrfToken:M.spelling("withXSRFToken")},!0),n.method=(a.getSafeProp(n,"method")||a.getSafeProp(this.defaults,"method")||"get").toLowerCase();let i=o&&a.merge(o.common,o[n.method]);o&&a.forEach(Kt.concat("common"),_=>{delete o[_]}),n.headers=B.concat(i,o);const l=[];let c=!0;this.interceptors.request.forEach(function(O){if(typeof O.runWhen=="function"&&O.runWhen(n)===!1)return;c=c&&O.synchronous;const k=n.transitional||tt;k&&k.legacyInterceptorReqResOrdering?l.unshift(O.fulfilled,O.rejected):l.push(O.fulfilled,O.rejected)});const d=[];this.interceptors.response.forEach(function(O){d.push(O.fulfilled,O.rejected)});let u,h=0,p;if(!c){const _=[ct.bind(this),void 0];for(_.unshift(...l),_.push(...d),p=_.length,u=Promise.resolve(n);h<p;)u=u.then(_[h++],_[h++]);return u}p=l.length;let S=n;for(;h<p;){const _=l[h++],O=l[h++];try{S=_?_(S):S}catch(k){if(!O){u=Promise.reject(k);break}try{const f=O.call(this,k);a.isThenable(f)&&(u=Promise.resolve(f).then(()=>ct.call(this,S)))}catch(f){u=Promise.reject(f)}break}}if(!u)try{u=ct.call(this,S)}catch(_){u=Promise.reject(_)}for(h=0,p=d.length;h<p;)u=u.then(d[h++],d[h++]);return u}getUri(e){e=fe(this.defaults,e);const n=Qt(e.baseURL,e.url,e.allowAbsoluteUrls,e);return jt(n,e.params,e.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(e){de.prototype[e]=function(n,r){return this.request(fe(r||{},{method:e,url:n,data:r&&a.hasOwnProp(r,"data")?r.data:void 0}))}}),a.forEach(["post","put","patch","query"],function(e){function n(r){return function(o,i,l){return this.request(fe(l||{},{method:e,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}de.prototype[e]=n(),e!=="query"&&(de.prototype[e+"Form"]=n(!0))});let Ts=class En{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(l=>{r.subscribe(l),o=l}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},e(function(o,i,l){r.reason||(r.reason=new Pe(o,i,l),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const n=this._listeners.indexOf(e);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const e=new AbortController,n=r=>{e.abort(r)};return this.subscribe(n),e.signal.unsubscribe=()=>this.unsubscribe(n),e.signal}static source(){let e;return{token:new En(function(s){e=s}),cancel:e}}};function As(t){return function(n){return t.apply(null,n)}}function Ps(t){return a.isObject(t)&&t.isAxiosError===!0}const qe={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,ContentTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,UnprocessableContent: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,WebServerReturnsAnUnknownError:520,WebServerIsDown:521,ConnectionTimedOut:522,OriginIsUnreachable:523,TimeoutOccurred:524,SslHandshakeFailed:525,InvalidSslCertificate:526};Object.entries(qe).forEach(([t,e])=>{qe[e]===void 0&&(qe[e]=t)});function dn(t){const e=new de(t),n=yt(de.prototype.request,e);return a.extend(n,de.prototype,e,{allOwnKeys:!0}),a.extend(n,e,null,{allOwnKeys:!0}),n.create=function(s){return dn(fe(t,s))},n}const N=dn(Ae);N.Axios=de,N.CanceledError=Pe,N.CancelToken=Ts,N.isCancel=zt,N.VERSION=it,N.toFormData=je,N.AxiosError=g,N.Cancel=N.CanceledError,N.all=function(e){return Promise.all(e)},N.spread=As,N.isAxiosError=Ps,N.mergeConfig=fe,N.AxiosHeaders=B,N.formToJSON=t=>$t(a.isHTMLForm(t)?new FormData(t):t),N.getAdapter=un.getAdapter,N.HttpStatusCode=qe,N.default=N;const{Axios:no,AxiosError:ro,CanceledError:so,isCancel:oo,CancelToken:io,VERSION:ao,all:lo,Cancel:co,isAxiosError:uo,spread:fo,toFormData:ho,AxiosHeaders:po,HttpStatusCode:go,formToJSON:mo,getAdapter:yo,mergeConfig:bo,create:Eo}=N,ut="https://translation.googleapis.com/language/translate/v2",Cs=new Set([408,425,429,500,502,503,504]),Ls=t=>N.isAxiosError(t);class Ds{constructor(e){Y(this,"type","google");Y(this,"axios");this.config=e,this.axios=N.create({baseURL:e.endpoint??ut,headers:{"Content-Type":"application/json",...e.headers}})}isAvailable(){const{apiKey:e,headers:n,endpoint:r}=this.config;return!!e||n!==void 0&&Object.keys(n).length>0||r!==void 0&&r!==ut?{available:!0}:{available:!1,reason:"Google Translate requires an apiKey, authentication headers or a custom endpoint"}}async translate(e,n){var c,d,u;const r={q:e.text,target:e.targetLanguage,format:"text"};e.sourceLanguage&&e.sourceLanguage!=="auto"&&(r.source=e.sourceLanguage),e.glossary&&Object.keys(e.glossary).length>0&&(r.glossaryConfig={glossaryData:{languagePair:{sourceLanguageCode:e.sourceLanguage??"auto",targetLanguageCode:e.targetLanguage},terms:Object.entries(e.glossary).map(([h,p])=>({sourceText:h,targetText:p}))}});const s={...this.config.headers,...n==null?void 0:n.headers},i=(u=(d=(c=(await this.axios.post("",r,{headers:s,params:this.createQueryParams(),timeout:n==null?void 0:n.timeoutMs,signal:n==null?void 0:n.signal})).data)==null?void 0:c.data)==null?void 0:d.translations)==null?void 0:u[0];if(!(i!=null&&i.translatedText))throw new Error("Google Translate response did not include translatedText");const l={endpoint:this.config.endpoint??ut};return i.model&&(l.model=i.model),this.config.projectId&&(l.projectId=this.config.projectId),this.config.region&&(l.region=this.config.region),{translatedText:i.translatedText,detectedSourceLanguage:i.detectedSourceLanguage,providerMetadata:l}}normalizeError(e){var n,r,s,o,i;if(Ls(e)){const l=(n=e.response)==null?void 0:n.status,c=((r=e.response)==null?void 0:r.data)??{},d=((s=c.error)==null?void 0:s.message)??e.message??"Google Translate request failed";return{code:String(((o=c.error)==null?void 0:o.code)??l??"E_GOOGLE"),message:d,retryable:l?Cs.has(l):!1,details:{status:l,data:c,headers:(i=e.response)==null?void 0:i.headers}}}return e instanceof Error?{code:e.name||"unknown_error",message:e.message,retryable:!1,details:e}:{code:"unknown_error",message:"Unknown provider error",retryable:!1,details:e}}createQueryParams(){if(this.config.apiKey)return{key:this.config.apiKey}}}const ft=t=>{if(!t)throw new Error("Provider instance is null or undefined");if(!t.type)throw new Error("Provider missing required 'type' property");if(typeof t.translate!="function")throw new Error("Provider missing required 'translate' method");if(t.isAvailable&&typeof t.isAvailable!="function")throw new Error("Provider 'isAvailable' must be a function");if(t.normalizeError&&typeof t.normalizeError!="function")throw new Error("Provider 'normalizeError' must be a function")},hn=t=>{if(t.id==="google"){const e=new Ds(t);return ft(e),e}if(t.implementation)return ft(t.implementation),t.implementation;if(t.factory){const e=t.factory();return ft(e),e}throw new Error("Custom provider configuration must include either 'implementation' or 'factory'")},Ns="translator",ks=5e3,pn=3e4,vs="::",Us=t=>{var n,r;return((r=(n=navigator==null?void 0:navigator.language)==null?void 0:n.split("-"))==null?void 0:r[0])||t},Fs=t=>localStorage.getItem(t),js=(t,e)=>{localStorage.setItem(t,e)},Bs=t=>t?t instanceof Set?new Set(t):new Set(t):new Set,gn=(t,e)=>({scope:Ns,event:t,...e}),Ce=(t,e)=>{console.warn("[vbss-translator]",gn(t,e))},z=(t,e)=>{console.debug("[vbss-translator]",gn(t,e))},Ms=()=>({warn:(t,e)=>{Ce(t,e??{})},debug:(t,e)=>{z(t,e??{})}}),Is=t=>{const{provider:e,cache:n,alwaysExternalKeys:r,enabled:s,timeoutMs:o,debug:i,...l}=t??{};return{enabled:s??!1,timeoutMs:o??ks,debug:i??!1,provider:{...Hs,...e},cache:{...qs,...n},alwaysExternalKeys:Bs(r),...l}},Hs={id:"google"},qs={enabled:!1,ttlMs:36e5},dt=(t,e)=>`${t}${vs}${e}`,$s=t=>t?new Map(t):new Map,Ks=(t,e)=>{const n=t.toLocaleLowerCase();return e.find(r=>Object.values(r).some(s=>s.toLocaleLowerCase()===n))},zs=({children:t,translations:e,defaultLanguage:n="en",persist:r=!1,persistKey:s="language",autoDetectLanguage:o=!1,externalTranslation:i})=>{const l=T.useMemo(()=>Is(i),[i]),[c,d]=T.useState(()=>new Set),u=T.useMemo(()=>new Set([...l.alwaysExternalKeys,...c]),[l,c]),h=T.useCallback(y=>{d(A=>{if(A.has(y))return A;const v=new Set(A);return v.add(y),v})},[]),p=T.useMemo(()=>({...l,alwaysExternalKeys:u}),[l,u]),S=r?Fs(s):null,_=o?Us(n):null,[O,k]=T.useState(S??_??n);T.useEffect(()=>{r&&js(s,O)},[O,r,s]);const f=T.useMemo(()=>Object.keys(e[0]||{}),[e]),m=T.useMemo(()=>Ms(),[]),w=T.useMemo(()=>new _n(p.cache),[p.cache]),E=T.useMemo(()=>{let y;try{if(y=hn(p.provider),p.debug&&z("TranslatorProvider_provider_created",{providerType:y.type,providerId:p.provider.id,timestamp:Date.now()}),p.enabled&&y.isAvailable){const A=y.isAvailable();A.available?p.debug&&z("TranslatorProvider_provider_available",{providerType:y.type,providerId:p.provider.id,timestamp:Date.now()}):Ce("TranslatorProvider_provider_unavailable",{providerType:y.type,providerId:p.provider.id,reason:A.reason,timestamp:Date.now()})}}catch(A){throw Ce("TranslatorProvider_provider_creation_failed",{providerId:p.provider.id,error:A instanceof Error?A.message:"Unknown error",timestamp:Date.now()}),A}return new Sn({provider:y,config:p,cache:p.cache.enabled?w:void 0,logger:m})},[p,m,w]),[L,F]=T.useState(()=>new Map),[D,J]=T.useState(0),H=T.useRef(!0);T.useEffect(()=>(p.debug&&z("TranslatorProvider_mounted",{timestamp:Date.now()}),H.current=!0,()=>{p.debug&&z("TranslatorProvider_unmounting",{timestamp:Date.now()}),H.current=!1}),[p]);const V=T.useCallback((y,A,v)=>{var C;p.debug&&z("setExternalStateEntry_called",{targetLanguage:y,key:A,status:v.status,value:v.value,isMounted:H.current});const b=()=>{F(G=>{const q=new Map(G),ne=$s(q.get(y));return ne.set(A,v),q.set(y,ne),q}),v.status==="resolved"&&(p.debug&&z("forceUpdate_triggered",{targetLanguage:y,key:A}),J(G=>G+1))};typeof process<"u"&&((C=process.env)==null?void 0:C.NODE_ENV)==="test"?b():T.startTransition(()=>{b()})},[p,J]),ee=T.useRef(new Set),he=T.useCallback(y=>{var v;if(!E.isEnabled())return;const A=dt(y.key,y.targetLanguage);ee.current.has(A)||(ee.current.add(A),Promise.resolve().then(()=>{V(y.targetLanguage,y.key,{status:"pending",value:y.displayValue})}),E.translate({key:y.key,text:y.originalText,targetLanguage:y.targetLanguage,sourceLanguage:y.sourceLanguage,signal:(v=y.options)==null?void 0:v.signal}).then(b=>{if(p.debug&&z("translation_promise_resolved",{key:y.key,targetLanguage:y.targetLanguage,isMounted:H.current,hasResult:!!b,hasTranslatedText:!!(b&&b.translatedText),translatedText:b==null?void 0:b.translatedText}),b&&b.translatedText){p.debug&&z("translation_applying_resolved",{key:y.key,targetLanguage:y.targetLanguage,isMounted:H.current,translatedText:b.translatedText}),V(y.targetLanguage,y.key,{status:"resolved",value:b.translatedText});return}p.debug&&z("translation_invalid_result",{key:y.key,result:b}),V(y.targetLanguage,y.key,{status:"error",value:y.displayValue,retryAt:Date.now()+pn})}).catch(b=>{p.debug&&z("translation_promise_rejected",{key:y.key,targetLanguage:y.targetLanguage,isMounted:H.current,error:(b==null?void 0:b.message)||String(b)}),Ce("external_translation_unexpected_rejection",{key:y.key,language:y.targetLanguage,error:b,isMounted:H.current}),V(y.targetLanguage,y.key,{status:"error",value:y.displayValue,error:b,retryAt:Date.now()+pn})}).finally(()=>{ee.current.delete(dt(y.key,y.targetLanguage))}))},[p,V,E]),ie=T.useMemo(()=>{const y={};return L.forEach((A,v)=>{A.forEach((b,P)=>{y[dt(P,v)]=b.status==="pending"})}),p.debug&&z("isTranslatingRecord_recalculated",{recordSize:Object.keys(y).length,record:{...y}}),y},[L,p]),X=T.useMemo(()=>Object.values(ie).some(Boolean),[ie]),pe=T.useCallback((y,A={})=>{const v=L.get(O),b=v==null?void 0:v.get(y);if(p.debug&&A.preferExternal&&z("t_called",{text:y,language:O,hasStateForLanguage:!!v,existingStateStatus:b==null?void 0:b.status,existingStateValue:b==null?void 0:b.value,preferExternal:A.preferExternal}),(b==null?void 0:b.status)==="resolved"&&b.value)return p.debug&&z("t_returning_resolved",{text:y,value:b.value}),b.value;const P=Ks(y,e),C=P==null?void 0:P[O],G=P?Object.values(P).find(ze=>!!ze):void 0,q=A.fallbackValue??(b==null?void 0:b.value)??C??G??y,ne=A.preferExternal===!0||p.alwaysExternalKeys.has(y),$e=E.isEnabled(),x=typeof C=="string";if(x||Ce("missing_translation",{key:y,language:O}),!($e&&(ne||!x)))return(b==null?void 0:b.status)==="pending"&&b.value?b.value:C??q;const Ee=Date.now(),Ke=(b==null?void 0:b.status)==="error"&&(!b.retryAt||b.retryAt<=Ee);if(!b||Ke){const $=A.sourceLanguage??(P&&P[n]?n:void 0),te=($&&(P==null?void 0:P[$]))??(P==null?void 0:P[n])??y;he({key:y,targetLanguage:O,originalText:te,displayValue:(b==null?void 0:b.value)??q,sourceLanguage:$,options:A})}return(b==null?void 0:b.status)==="pending"?b.value??q:q},[n,p.alwaysExternalKeys,L,O,he,E,e]),ht=T.useMemo(()=>({t:pe,language:O,languages:f,setLanguage:k,isTranslating:ie,isTranslatingAny:X,registerExternalKey:h,externalConfig:p}),[pe,O,f,k,ie,X,h,p,D]);return W.jsx(gt.Provider,{value:ht,children:t})},Vs=()=>wn();j.TranslatorProvider=zs,j.createTranslationProvider=hn,j.useTranslator=Vs,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,111 +1,121 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "vbss-translator",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "A lightweight React translation toolkit focused on ergonomics, sensible defaults, and escape hatches when local dictionaries are not enough",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"react",
|
|
7
|
-
"translation",
|
|
8
|
-
"i18n",
|
|
9
|
-
"internationalization",
|
|
10
|
-
"translator",
|
|
11
|
-
"react-hooks",
|
|
12
|
-
"context",
|
|
13
|
-
"cli",
|
|
14
|
-
"google-translate",
|
|
15
|
-
"typescript"
|
|
16
|
-
],
|
|
17
|
-
"private": false,
|
|
18
|
-
"type": "module",
|
|
19
|
-
"license": "MIT",
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"
|
|
76
|
-
"
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
"
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
"
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
"
|
|
90
|
-
"
|
|
91
|
-
"
|
|
92
|
-
"
|
|
93
|
-
"
|
|
94
|
-
"
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"eslint": "^9.15.0",
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"
|
|
102
|
-
"
|
|
103
|
-
"
|
|
104
|
-
"
|
|
105
|
-
"
|
|
106
|
-
"
|
|
107
|
-
"
|
|
108
|
-
"
|
|
109
|
-
"
|
|
110
|
-
|
|
111
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "vbss-translator",
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "A lightweight React translation toolkit focused on ergonomics, sensible defaults, and escape hatches when local dictionaries are not enough",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"translation",
|
|
8
|
+
"i18n",
|
|
9
|
+
"internationalization",
|
|
10
|
+
"translator",
|
|
11
|
+
"react-hooks",
|
|
12
|
+
"context",
|
|
13
|
+
"cli",
|
|
14
|
+
"google-translate",
|
|
15
|
+
"typescript"
|
|
16
|
+
],
|
|
17
|
+
"private": false,
|
|
18
|
+
"type": "module",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"funding": [
|
|
21
|
+
{
|
|
22
|
+
"type": "github",
|
|
23
|
+
"url": "https://github.com/sponsors/vbss-io"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"type": "individual",
|
|
27
|
+
"url": "https://buymeacoffee.com/vbss.io"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"main": "dist/vbss-translator.umd.cjs",
|
|
34
|
+
"module": "dist/vbss-translator.js",
|
|
35
|
+
"exports": {
|
|
36
|
+
".": {
|
|
37
|
+
"types": "./dist/vbss-translator.d.ts",
|
|
38
|
+
"import": "./dist/vbss-translator.js",
|
|
39
|
+
"require": "./dist/vbss-translator.umd.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./generator": {
|
|
42
|
+
"types": "./dist/generator.d.ts",
|
|
43
|
+
"import": "./dist/generator.js",
|
|
44
|
+
"require": "./dist/generator.cjs"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"types": "./dist/vbss-translator.d.ts",
|
|
48
|
+
"sideEffects": false,
|
|
49
|
+
"bin": {
|
|
50
|
+
"vbss-translator": "dist/cli/index.js"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/vbss-io/vbss-translator.git"
|
|
55
|
+
},
|
|
56
|
+
"author": "Vitor Bastos <vitor@vbss.io> (https://vbss.io/)",
|
|
57
|
+
"homepage": "https://ui.vbss.io/tools/vbss-translator",
|
|
58
|
+
"scripts": {
|
|
59
|
+
"dev": "vite",
|
|
60
|
+
"build": "tsc && vite build && vite build --mode generator && vite build --mode cli",
|
|
61
|
+
"lint": "eslint . --report-unused-disable-directives --max-warnings 0",
|
|
62
|
+
"test": "jest",
|
|
63
|
+
"test:watch": "jest --watch",
|
|
64
|
+
"coverage": "jest --coverage",
|
|
65
|
+
"test:coverage": "jest --coverage --maxWorkers=2 && node scripts/coverage-per-file.mjs",
|
|
66
|
+
"generate-translations": "node dist/cli/index.js",
|
|
67
|
+
"typecheck": "tsc --noEmit",
|
|
68
|
+
"release": "node scripts/release.mjs",
|
|
69
|
+
"release:dry": "node scripts/release.mjs --dry-run",
|
|
70
|
+
"patch-deploy": "node scripts/release.mjs patch",
|
|
71
|
+
"minor-deploy": "node scripts/release.mjs minor",
|
|
72
|
+
"major-deploy": "node scripts/release.mjs major",
|
|
73
|
+
"lock-guard": "node scripts/lock-guard-since-published.mjs",
|
|
74
|
+
"audit-gate": "node scripts/audit-gate.mjs",
|
|
75
|
+
"verify": "npm run lint && npm run typecheck && npm run test:coverage && npm run lock-guard && npm run audit-gate && npm run build",
|
|
76
|
+
"prepublishOnly": "node scripts/release-gate.mjs"
|
|
77
|
+
},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"axios": "^1.20.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependencies": {
|
|
82
|
+
"react": "^18.3.1 || ^19.0.0",
|
|
83
|
+
"react-dom": "^18.3.1 || ^19.0.0"
|
|
84
|
+
},
|
|
85
|
+
"overrides": {
|
|
86
|
+
"@eslint/plugin-kit": "0.3.5",
|
|
87
|
+
"@isaacs/nonrecursive-glob-match": "1.0.1",
|
|
88
|
+
"ajv@^8": "8.20.0",
|
|
89
|
+
"glob@^10.3.10": "14.0.2",
|
|
90
|
+
"js-yaml": "4.3.2",
|
|
91
|
+
"lodash": "4.18.1",
|
|
92
|
+
"minimatch@^3": "3.1.5",
|
|
93
|
+
"minimatch@^9": "11.0.1",
|
|
94
|
+
"minimatch@^11.0.0": "11.0.1"
|
|
95
|
+
},
|
|
96
|
+
"devDependencies": {
|
|
97
|
+
"@eslint/js": "^9.15.0",
|
|
98
|
+
"@testing-library/jest-dom": "^6.9.1",
|
|
99
|
+
"@testing-library/react": "^16.3.0",
|
|
100
|
+
"@types/jest": "^30.0.0",
|
|
101
|
+
"@types/node": "^22.10.2",
|
|
102
|
+
"@types/react": "^18.3.12",
|
|
103
|
+
"@types/react-dom": "^18.3.1",
|
|
104
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
105
|
+
"eslint": "^9.15.0",
|
|
106
|
+
"eslint-plugin-react-hooks": "^5.0.0",
|
|
107
|
+
"eslint-plugin-react-refresh": "^0.4.14",
|
|
108
|
+
"globals": "^15.12.0",
|
|
109
|
+
"jest": "^30.2.0",
|
|
110
|
+
"jest-environment-jsdom": "^30.2.0",
|
|
111
|
+
"react": "^18.3.1",
|
|
112
|
+
"react-dom": "^18.3.1",
|
|
113
|
+
"ts-jest": "^29.4.5",
|
|
114
|
+
"ts-node": "^10.9.2",
|
|
115
|
+
"typescript": "~5.6.2",
|
|
116
|
+
"typescript-eslint": "^8.15.0",
|
|
117
|
+
"vite": "^6.4.5",
|
|
118
|
+
"vite-plugin-dts": "^4.3.0",
|
|
119
|
+
"vite-tsconfig-paths": "^5.1.4"
|
|
120
|
+
}
|
|
121
|
+
}
|