best-unit 0.0.12 → 0.0.13

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.
@@ -3,4 +3,4 @@
3
3
  `)}getSetCookie(){return this.get("set-cookie")||[]}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(o=>r.set(o)),r}static accessor(t){const r=(this[ct]=this[ct]={accessors:{}}).accessors,o=this.prototype;function i(s){const a=X(s);r[a]||(Tr(o,s),r[a]=!0)}return d.isArray(t)?t.forEach(i):i(t),this}};B.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]);d.reduceDescriptors(B.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}});d.freezeMethods(B);function ke(e,t){const n=this||oe,r=t||n,o=B.from(r.headers);let i=r.data;return d.forEach(e,function(a){i=a.call(n,i,o.normalize(),t?t.status:void 0)}),o.normalize(),i}function Gt(e){return!!(e&&e.__CANCEL__)}function V(e,t,n){x.call(this,e??"canceled",x.ERR_CANCELED,t,n),this.name="CanceledError"}d.inherits(V,x,{__CANCEL__:!0});function Qt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new x("Request failed with status code "+n.status,[x.ERR_BAD_REQUEST,x.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}function Ar(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Or(e,t){e=e||10;const n=new Array(e),r=new Array(e);let o=0,i=0,s;return t=t!==void 0?t:1e3,function(u){const c=Date.now(),f=r[i];s||(s=c),n[o]=u,r[o]=c;let l=i,y=0;for(;l!==o;)y+=n[l++],l=l%e;if(o=(o+1)%e,o===i&&(i=(i+1)%e),c-s<t)return;const h=f&&c-f;return h?Math.round(y*1e3/h):void 0}}function Fr(e,t){let n=0,r=1e3/t,o,i;const s=(c,f=Date.now())=>{n=f,o=null,i&&(clearTimeout(i),i=null),e.apply(null,c)};return[(...c)=>{const f=Date.now(),l=f-n;l>=r?s(c,f):(o=c,i||(i=setTimeout(()=>{i=null,s(o)},r-l)))},()=>o&&s(o)]}const pe=(e,t,n=3)=>{let r=0;const o=Or(50,250);return Fr(i=>{const s=i.loaded,a=i.lengthComputable?i.total:void 0,u=s-r,c=o(u),f=s<=a;r=s;const l={loaded:s,total:a,progress:a?s/a:void 0,bytes:u,rate:c||void 0,estimated:c&&a&&f?(a-s)/c:void 0,event:i,lengthComputable:a!=null,[t?"download":"upload"]:!0};e(l)},n)},ut=(e,t)=>{const n=e!=null;return[r=>t[0]({lengthComputable:n,total:e,loaded:r}),t[1]]},ft=e=>(...t)=>d.asap(()=>e(...t)),Br=A.hasStandardBrowserEnv?((e,t)=>n=>(n=new URL(n,A.origin),e.protocol===n.protocol&&e.host===n.host&&(t||e.port===n.port)))(new URL(A.origin),A.navigator&&/(msie|trident)/i.test(A.navigator.userAgent)):()=>!0,Pr=A.hasStandardBrowserEnv?{write(e,t,n,r,o,i){const s=[e+"="+encodeURIComponent(t)];d.isNumber(n)&&s.push("expires="+new Date(n).toGMTString()),d.isString(r)&&s.push("path="+r),d.isString(o)&&s.push("domain="+o),i===!0&&s.push("secure"),document.cookie=s.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function Nr(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Dr(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Yt(e,t,n){let r=!Nr(t);return e&&(r||n==!1)?Dr(e,t):t}const dt=e=>e instanceof B?{...e}:e;function q(e,t){t=t||{};const n={};function r(c,f,l,y){return d.isPlainObject(c)&&d.isPlainObject(f)?d.merge.call({caseless:y},c,f):d.isPlainObject(f)?d.merge({},f):d.isArray(f)?f.slice():f}function o(c,f,l,y){if(d.isUndefined(f)){if(!d.isUndefined(c))return r(void 0,c,l,y)}else return r(c,f,l,y)}function i(c,f){if(!d.isUndefined(f))return r(void 0,f)}function s(c,f){if(d.isUndefined(f)){if(!d.isUndefined(c))return r(void 0,c)}else return r(void 0,f)}function a(c,f,l){if(l in t)return r(c,f);if(l in e)return r(void 0,c)}const u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,withXSRFToken:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a,headers:(c,f,l)=>o(dt(c),dt(f),l,!0)};return d.forEach(Object.keys(Object.assign({},e,t)),function(f){const l=u[f]||o,y=l(e[f],t[f],f);d.isUndefined(y)&&l!==a||(n[f]=y)}),n}const Zt=e=>{const t=q({},e);let{data:n,withXSRFToken:r,xsrfHeaderName:o,xsrfCookieName:i,headers:s,auth:a}=t;t.headers=s=B.from(s),t.url=Vt(Yt(t.baseURL,t.url,t.allowAbsoluteUrls),e.params,e.paramsSerializer),a&&s.set("Authorization","Basic "+btoa((a.username||"")+":"+(a.password?unescape(encodeURIComponent(a.password)):"")));let u;if(d.isFormData(n)){if(A.hasStandardBrowserEnv||A.hasStandardBrowserWebWorkerEnv)s.setContentType(void 0);else if((u=s.getContentType())!==!1){const[c,...f]=u?u.split(";").map(l=>l.trim()).filter(Boolean):[];s.setContentType([c||"multipart/form-data",...f].join("; "))}}if(A.hasStandardBrowserEnv&&(r&&d.isFunction(r)&&(r=r(t)),r||r!==!1&&Br(t.url))){const c=o&&i&&Pr.read(i);c&&s.set(o,c)}return t},Ur=typeof XMLHttpRequest<"u",Lr=Ur&&function(e){return new Promise(function(n,r){const o=Zt(e);let i=o.data;const s=B.from(o.headers).normalize();let{responseType:a,onUploadProgress:u,onDownloadProgress:c}=o,f,l,y,h,p;function m(){h&&h(),p&&p(),o.cancelToken&&o.cancelToken.unsubscribe(f),o.signal&&o.signal.removeEventListener("abort",f)}let _=new XMLHttpRequest;_.open(o.method.toUpperCase(),o.url,!0),_.timeout=o.timeout;function g(){if(!_)return;const v=B.from("getAllResponseHeaders"in _&&_.getAllResponseHeaders()),k={data:!a||a==="text"||a==="json"?_.responseText:_.response,status:_.status,statusText:_.statusText,headers:v,config:e,request:_};Qt(function(N){n(N),m()},function(N){r(N),m()},k),_=null}"onloadend"in _?_.onloadend=g:_.onreadystatechange=function(){!_||_.readyState!==4||_.status===0&&!(_.responseURL&&_.responseURL.indexOf("file:")===0)||setTimeout(g)},_.onabort=function(){_&&(r(new x("Request aborted",x.ECONNABORTED,e,_)),_=null)},_.onerror=function(){r(new x("Network Error",x.ERR_NETWORK,e,_)),_=null},_.ontimeout=function(){let T=o.timeout?"timeout of "+o.timeout+"ms exceeded":"timeout exceeded";const k=o.transitional||Kt;o.timeoutErrorMessage&&(T=o.timeoutErrorMessage),r(new x(T,k.clarifyTimeoutError?x.ETIMEDOUT:x.ECONNABORTED,e,_)),_=null},i===void 0&&s.setContentType(null),"setRequestHeader"in _&&d.forEach(s.toJSON(),function(T,k){_.setRequestHeader(k,T)}),d.isUndefined(o.withCredentials)||(_.withCredentials=!!o.withCredentials),a&&a!=="json"&&(_.responseType=o.responseType),c&&([y,p]=pe(c,!0),_.addEventListener("progress",y)),u&&_.upload&&([l,h]=pe(u),_.upload.addEventListener("progress",l),_.upload.addEventListener("loadend",h)),(o.cancelToken||o.signal)&&(f=v=>{_&&(r(!v||v.type?new V(null,e,_):v),_.abort(),_=null)},o.cancelToken&&o.cancelToken.subscribe(f),o.signal&&(o.signal.aborted?f():o.signal.addEventListener("abort",f)));const E=Ar(o.url);if(E&&A.protocols.indexOf(E)===-1){r(new x("Unsupported protocol "+E+":",x.ERR_BAD_REQUEST,e));return}_.send(i||null)})},jr=(e,t)=>{const{length:n}=e=e?e.filter(Boolean):[];if(t||n){let r=new AbortController,o;const i=function(c){if(!o){o=!0,a();const f=c instanceof Error?c:this.reason;r.abort(f instanceof x?f:new V(f instanceof Error?f.message:f))}};let s=t&&setTimeout(()=>{s=null,i(new x(`timeout ${t} of ms exceeded`,x.ETIMEDOUT))},t);const a=()=>{e&&(s&&clearTimeout(s),s=null,e.forEach(c=>{c.unsubscribe?c.unsubscribe(i):c.removeEventListener("abort",i)}),e=null)};e.forEach(c=>c.addEventListener("abort",i));const{signal:u}=r;return u.unsubscribe=()=>d.asap(a),u}},Ir=function*(e,t){let n=e.byteLength;if(n<t){yield e;return}let r=0,o;for(;r<n;)o=r+t,yield e.slice(r,o),r=o},zr=async function*(e,t){for await(const n of Hr(e))yield*Ir(n,t)},Hr=async function*(e){if(e[Symbol.asyncIterator]){yield*e;return}const t=e.getReader();try{for(;;){const{done:n,value:r}=await t.read();if(n)break;yield r}}finally{await t.cancel()}},pt=(e,t,n,r)=>{const o=zr(e,t);let i=0,s,a=u=>{s||(s=!0,r&&r(u))};return new ReadableStream({async pull(u){try{const{done:c,value:f}=await o.next();if(c){a(),u.close();return}let l=f.byteLength;if(n){let y=i+=l;n(y)}u.enqueue(new Uint8Array(f))}catch(c){throw a(c),c}},cancel(u){return a(u),o.return()}},{highWaterMark:2})},we=typeof fetch=="function"&&typeof Request=="function"&&typeof Response=="function",en=we&&typeof ReadableStream=="function",$r=we&&(typeof TextEncoder=="function"?(e=>t=>e.encode(t))(new TextEncoder):async e=>new Uint8Array(await new Response(e).arrayBuffer())),tn=(e,...t)=>{try{return!!e(...t)}catch{return!1}},qr=en&&tn(()=>{let e=!1;const t=new Request(A.origin,{body:new ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type");return e&&!t}),ht=64*1024,De=en&&tn(()=>d.isReadableStream(new Response("").body)),he={stream:De&&(e=>e.body)};we&&(e=>{["text","arrayBuffer","blob","formData","stream"].forEach(t=>{!he[t]&&(he[t]=d.isFunction(e[t])?n=>n[t]():(n,r)=>{throw new x(`Response type '${t}' is not supported`,x.ERR_NOT_SUPPORT,r)})})})(new Response);const Mr=async e=>{if(e==null)return 0;if(d.isBlob(e))return e.size;if(d.isSpecCompliantForm(e))return(await new Request(A.origin,{method:"POST",body:e}).arrayBuffer()).byteLength;if(d.isArrayBufferView(e)||d.isArrayBuffer(e))return e.byteLength;if(d.isURLSearchParams(e)&&(e=e+""),d.isString(e))return(await $r(e)).byteLength},Wr=async(e,t)=>{const n=d.toFiniteNumber(e.getContentLength());return n??Mr(t)},Jr=we&&(async e=>{let{url:t,method:n,data:r,signal:o,cancelToken:i,timeout:s,onDownloadProgress:a,onUploadProgress:u,responseType:c,headers:f,withCredentials:l="same-origin",fetchOptions:y}=Zt(e);c=c?(c+"").toLowerCase():"text";let h=jr([o,i&&i.toAbortSignal()],s),p;const m=h&&h.unsubscribe&&(()=>{h.unsubscribe()});let _;try{if(u&&qr&&n!=="get"&&n!=="head"&&(_=await Wr(f,r))!==0){let k=new Request(t,{method:"POST",body:r,duplex:"half"}),O;if(d.isFormData(r)&&(O=k.headers.get("content-type"))&&f.setContentType(O),k.body){const[N,j]=ut(_,pe(ft(u)));r=pt(k.body,ht,N,j)}}d.isString(l)||(l=l?"include":"omit");const g="credentials"in Request.prototype;p=new Request(t,{...y,signal:h,method:n.toUpperCase(),headers:f.normalize().toJSON(),body:r,duplex:"half",credentials:g?l:void 0});let E=await fetch(p,y);const v=De&&(c==="stream"||c==="response");if(De&&(a||v&&m)){const k={};["status","statusText","headers"].forEach(I=>{k[I]=E[I]});const O=d.toFiniteNumber(E.headers.get("content-length")),[N,j]=a&&ut(O,pe(ft(a),!0))||[];E=new Response(pt(E.body,ht,N,()=>{j&&j(),m&&m()}),k)}c=c||"text";let T=await he[d.findKey(he,c)||"text"](E,e);return!v&&m&&m(),await new Promise((k,O)=>{Qt(k,O,{data:T,headers:B.from(E.headers),status:E.status,statusText:E.statusText,config:e,request:p})})}catch(g){throw m&&m(),g&&g.name==="TypeError"&&/Load failed|fetch/i.test(g.message)?Object.assign(new x("Network Error",x.ERR_NETWORK,e,p),{cause:g.cause||g}):x.from(g,g&&g.code,e,p)}}),Ue={http:ar,xhr:Lr,fetch:Jr};d.forEach(Ue,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const _t=e=>`- ${e}`,Vr=e=>d.isFunction(e)||e===null||e===!1,nn={getAdapter:e=>{e=d.isArray(e)?e:[e];const{length:t}=e;let n,r;const o={};for(let i=0;i<t;i++){n=e[i];let s;if(r=n,!Vr(n)&&(r=Ue[(s=String(n)).toLowerCase()],r===void 0))throw new x(`Unknown adapter '${s}'`);if(r)break;o[s||"#"+i]=r}if(!r){const i=Object.entries(o).map(([a,u])=>`adapter ${a} `+(u===!1?"is not supported by the environment":"is not available in the build"));let s=t?i.length>1?`since :
4
4
  `+i.map(_t).join(`
5
5
  `):" "+_t(i[0]):"as no adapter specified";throw new x("There is no suitable adapter to dispatch the request "+s,"ERR_NOT_SUPPORT")}return r},adapters:Ue};function Te(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new V(null,e)}function mt(e){return Te(e),e.headers=B.from(e.headers),e.data=ke.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),nn.getAdapter(e.adapter||oe.adapter)(e).then(function(r){return Te(e),r.data=ke.call(e,e.transformResponse,r),r.headers=B.from(r.headers),r},function(r){return Gt(r)||(Te(e),r&&r.response&&(r.response.data=ke.call(e,e.transformResponse,r.response),r.response.headers=B.from(r.response.headers))),Promise.reject(r)})}const rn="1.10.0",ve={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ve[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const bt={};ve.transitional=function(t,n,r){function o(i,s){return"[Axios v"+rn+"] Transitional option '"+i+"'"+s+(r?". "+r:"")}return(i,s,a)=>{if(t===!1)throw new x(o(s," has been removed"+(n?" in "+n:"")),x.ERR_DEPRECATED);return n&&!bt[s]&&(bt[s]=!0,console.warn(o(s," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,s,a):!0}};ve.spelling=function(t){return(n,r)=>(console.warn(`${r} is likely a misspelling of ${t}`),!0)};function Kr(e,t,n){if(typeof e!="object")throw new x("options must be an object",x.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let o=r.length;for(;o-- >0;){const i=r[o],s=t[i];if(s){const a=e[i],u=a===void 0||s(a,i,e);if(u!==!0)throw new x("option "+i+" must be "+u,x.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new x("Unknown option "+i,x.ERR_BAD_OPTION)}}const ue={assertOptions:Kr,validators:ve},U=ue.validators;let $=class{constructor(t){this.defaults=t||{},this.interceptors={request:new lt,response:new lt}}async request(t,n){try{return await this._request(t,n)}catch(r){if(r instanceof Error){let o={};Error.captureStackTrace?Error.captureStackTrace(o):o=new Error;const i=o.stack?o.stack.replace(/^.+\n/,""):"";try{r.stack?i&&!String(r.stack).endsWith(i.replace(/^.+\n.+\n/,""))&&(r.stack+=`
6
- `+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=q(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&ue.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),o!=null&&(d.isFunction(o)?n.paramsSerializer={serialize:o}:ue.assertOptions(o,{encode:U.function,serialize:U.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ue.assertOptions(n,{baseUrl:U.spelling("baseURL"),withXsrfToken:U.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let s=i&&d.merge(i.common,i[n.method]);i&&d.forEach(["delete","get","head","post","put","patch","common"],p=>{delete i[p]}),n.headers=B.concat(s,i);const a=[];let u=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(u=u&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let f,l=0,y;if(!u){const p=[mt.bind(this),void 0];for(p.unshift.apply(p,a),p.push.apply(p,c),y=p.length,f=Promise.resolve(n);l<y;)f=f.then(p[l++],p[l++]);return f}y=a.length;let h=n;for(l=0;l<y;){const p=a[l++],m=a[l++];try{h=p(h)}catch(_){m.call(this,_);break}}try{f=mt.call(this,h)}catch(p){return Promise.reject(p)}for(l=0,y=c.length;l<y;)f=f.then(c[l++],c[l++]);return f}getUri(t){t=q(this.defaults,t);const n=Yt(t.baseURL,t.url,t.allowAbsoluteUrls);return Vt(n,t.params,t.paramsSerializer)}};d.forEach(["delete","get","head","options"],function(t){$.prototype[t]=function(n,r){return this.request(q(r||{},{method:t,url:n,data:(r||{}).data}))}});d.forEach(["post","put","patch"],function(t){function n(r){return function(i,s,a){return this.request(q(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}$.prototype[t]=n(),$.prototype[t+"Form"]=n(!0)});let Xr=class on{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(o=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i;const s=new Promise(a=>{r.subscribe(a),i=a}).then(o);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i,s,a){r.reason||(r.reason=new V(i,s,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new on(function(o){t=o}),cancel:t}}};function Gr(e){return function(n){return e.apply(null,n)}}function Qr(e){return d.isObject(e)&&e.isAxiosError===!0}const Le={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Le).forEach(([e,t])=>{Le[t]=e});function sn(e){const t=new $(e),n=Dt($.prototype.request,t);return d.extend(n,$.prototype,t,{allOwnKeys:!0}),d.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return sn(q(e,o))},n}const R=sn(oe);R.Axios=$;R.CanceledError=V;R.CancelToken=Xr;R.isCancel=Gt;R.VERSION=rn;R.toFormData=xe;R.AxiosError=x;R.Cancel=R.CanceledError;R.all=function(t){return Promise.all(t)};R.spread=Gr;R.isAxiosError=Qr;R.mergeConfig=q;R.AxiosHeaders=B;R.formToJSON=e=>Xt(d.isHTMLForm(e)?new FormData(e):e);R.getAdapter=nn.getAdapter;R.HttpStatusCode=Le;R.default=R;const{Axios:mo,AxiosError:bo,CanceledError:yo,isCancel:go,CancelToken:Eo,VERSION:xo,all:wo,Cancel:vo,isAxiosError:So,spread:Ro,toFormData:Co,AxiosHeaders:ko,HttpStatusCode:To,formToJSON:Ao,getAdapter:Oo,mergeConfig:Fo}=R;function Yr(e={}){const{baseURL:t="/api",timeout:n=1e4,getToken:r,getLocale:o,onError:i}=e,s=R.create({baseURL:t,timeout:n});return s.interceptors.request.use(a=>{if(r){const u=r();u&&(a.headers={...a.headers,Authorization:u})}if(o){const u=o();u&&(a.headers={...a.headers,"Accept-Language":u})}return a}),s.interceptors.response.use(a=>a.data&&a.data.code===0?a.data:(i&&i(a.data?.msg||a.data?.message||"未知错误",a),Promise.reject(a.data||{message:"未知错误"})),a=>(i&&i(a.message,a),Promise.reject(a))),s}const Zr=Yr();function eo(e){const{token:t,...n}=e;return Zr.get("/balance",{params:n,headers:t?{Authorization:t}:void 0})}function to({onClick:e,color:t,children:n,merchantId:r,bizType:o,token:i}){return r&&o&&eo({merchant_id:r,biz_type:o,token:i}).then(s=>console.log(s)),b("button",{style:{background:t||"#1890ff",color:"#fff",border:"none",borderRadius:4,padding:"8px 16px",cursor:"pointer",fontSize:16},onClick:e,children:n})}const no=({formState:e,setFormState:t,onClose:n,loading:r,whiteTheme:o=!1})=>{const i=o?{label:{marginBottom:8,fontSize:14,color:"#222",textAlign:"left",display:"block"},input:{width:"100%",padding:"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},error:{color:"#ff4d4f",fontSize:13,marginTop:4,textAlign:"left"}}:{label:{marginBottom:8,fontSize:14,color:"#fff",textAlign:"left",display:"block"},input:{width:"100%",padding:"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #23262F",background:"#23262F",color:"#fff",fontSize:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid #23262F",background:"#23262F",color:"#fff",fontSize:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},error:{color:"#ff4d4f",fontSize:13,marginTop:4,textAlign:"left"}},s=o?{background:"#fff",color:"#222",border:"1px solid #E5E6EB",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer"}:{background:"#23262F",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer"},a=o?{background:"#155EEF",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer",fontWeight:600}:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer",fontWeight:600};return b(ne,{children:[b("div",{style:{marginBottom:18},children:[b("div",{style:i.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 充值币种"]}),b("select",{style:{...i.select},value:e.currency,onInput:u=>{const c=u.target.value;t(f=>({...f,currency:c}))},children:[b("option",{value:"USD",children:"USD - 美元"}),b("option",{value:"CNY",children:"CNY - 人民币"}),b("option",{value:"EUR",children:"EUR - 欧元"})]})]}),b("div",{style:{marginBottom:18},children:[b("div",{style:i.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 充值金额"]}),b("input",{type:"text",placeholder:"请输入充值金额",value:e.amount,onInput:u=>{const c=u.target.value;t(f=>({...f,amount:c,amountError:c.trim()?"":f.amountError}))},style:{...i.input,...e.amountError?i.inputError:{}}}),e.amountError&&b("div",{style:i.error,children:e.amountError})]}),b("div",{style:{marginBottom:24},children:[b("div",{style:i.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 支付平台"]}),b("select",{style:{...i.select,...e.rechargeChannelError?i.selectError:{}},value:e.rechargeChannel,onInput:u=>{const c=u.target.value;t(f=>({...f,rechargeChannel:c,rechargeChannelError:c?"":f.rechargeChannelError}))},children:[b("option",{value:"alipay",children:"支付宝"}),b("option",{value:"wechat",children:"微信"}),b("option",{value:"paypal",children:"PayPal"})]}),e.rechargeChannelError&&b("div",{style:i.error,children:e.rechargeChannelError})]}),e.error&&b("div",{style:{color:"#ff4d4f",marginBottom:12},children:e.error}),b("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[b("button",{type:"button",onClick:n,style:s,children:"取消"}),b("button",{type:"submit",disabled:r,style:a,children:r?"提交中...":"去支付"})]})]})},ro=({formState:e,setFormState:t,onClose:n,loading:r,whiteTheme:o=!1})=>{const i=yn(null),s=o?{label:{marginBottom:8,fontSize:14,color:"#222",textAlign:"left",display:"block"},input:{width:"100%",padding:"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},upload:{border:"1px dashed #E5E6EB",borderRadius:8,background:"#FCFCFD",padding:24,textAlign:"center",cursor:"pointer",minHeight:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:15},uploadError:{border:"1px dashed #ff4d4f"},fileItem:{display:"flex",alignItems:"center",background:"#F7F8FA",borderRadius:8,padding:"12px 16px",marginBottom:8,fontSize:15,color:"#222",justifyContent:"space-between"},buttonCancel:{background:"#fff",color:"#222",border:"1px solid #E5E6EB",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer"},buttonSubmit:{background:"#155EEF",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer",fontWeight:600},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:"4px 14px",fontSize:15,marginLeft:16,cursor:"pointer"},error:{color:"#ff4d4f",fontSize:13,marginTop:4,textAlign:"left"}}:{label:{marginBottom:8,fontSize:14,color:"#fff",textAlign:"left",display:"block"},input:{width:"100%",padding:"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #23262F",background:"#23262F",color:"#fff",fontSize:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid #23262F",background:"#23262F",color:"#fff",fontSize:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},upload:{border:"1px dashed #23262F",borderRadius:8,background:"#181A20",padding:24,textAlign:"center",cursor:"pointer",minHeight:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:15},uploadError:{border:"1px dashed #ff4d4f"},fileItem:{display:"flex",alignItems:"center",background:"#23262F",borderRadius:8,padding:"12px 16px",marginBottom:8,fontSize:15,color:"#fff",justifyContent:"space-between"},buttonCancel:{background:"#23262F",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer"},buttonSubmit:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer",fontWeight:600},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:"4px 14px",fontSize:15,marginLeft:16,cursor:"pointer"},error:{color:"#ff4d4f",fontSize:13,marginTop:4,textAlign:"left"}},a=h=>{const p=Array.from(h.target.files).slice(0,10);t(m=>({...m,files:p,filesError:""}))},u=h=>{h.preventDefault();const p=Array.from(h.dataTransfer.files).slice(0,10);t(m=>({...m,files:p,filesError:""}))},c=h=>{h.preventDefault()},f=h=>{t(p=>({...p,files:p.files.filter((m,_)=>_!==h)}))},l=h=>{h.preventDefault();let p=!0;t(m=>({...m,platformError:"",transactionIdError:"",filesError:""})),e.platform||(t(m=>({...m,platformError:"请选择支付平台"})),p=!1),e.transactionId.trim()||(t(m=>({...m,transactionIdError:"请输入转账交易ID"})),p=!1),(!e.files||e.files.length===0)&&(t(m=>({...m,filesError:"请上传转账凭证"})),p=!1),p&&console.log("OfflineTransferForm values:",e)},y=h=>h>1024*1024?(h/1024/1024).toFixed(2)+" MB":h>1024?(h/1024).toFixed(2)+" KB":h+" B";return b("form",{onSubmit:l,children:[b("div",{style:{marginBottom:18},children:[b("div",{style:s.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 第三方支付平台"]}),b("select",{style:{...s.select,...e.platformError?s.selectError:{}},value:e.platform,onInput:h=>{const p=h.target.value;t(m=>({...m,platform:p,platformError:p?"":m.platformError}))},children:[b("option",{value:"paypal",children:"PayPal"}),b("option",{value:"alipay",children:"支付宝"}),b("option",{value:"wechat",children:"微信"})]}),e.platformError&&b("div",{style:s.error,children:e.platformError})]}),b("div",{style:{marginBottom:18},children:[b("div",{style:s.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 交易ID"]}),b("input",{type:"text",placeholder:"请输入转账交易ID",value:e.transactionId,onInput:h=>{const p=h.target.value;t(m=>({...m,transactionId:p,transactionIdError:p?"":m.transactionIdError}))},style:{...s.input,...e.transactionIdError?s.inputError:{}}}),e.transactionIdError&&b("div",{style:s.error,children:e.transactionIdError})]}),b("div",{style:{marginBottom:24},children:[b("div",{style:s.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 上传文件"]}),b("div",{style:{...s.upload,...e.filesError?s.uploadError:{}},onClick:()=>i.current?.click(),onDrop:u,onDragOver:c,children:[b("div",{style:{fontSize:48,marginBottom:12},children:b("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[b("rect",{x:"8",y:"8",width:"48",height:"48",rx:"12",fill:"#F4F6FA"}),b("rect",{x:"28",y:"20",width:"8",height:"24",rx:"4",fill:"#E5E6EB"})]})}),b("div",{style:{color:"#222",fontSize:15,marginBottom:4},children:"点击或拖拽文件到此处上传"}),b("div",{style:{color:"#999",fontSize:13},children:"支持 JPG、PNG、PDF 格式,单个文件不超过 20MB,最多上传 10 个文件"}),b("input",{ref:i,type:"file",multiple:!0,accept:".jpg,.jpeg,.png,.pdf",style:{display:"none"},onChange:a})]}),e.files&&e.files.length>0&&b("div",{style:{marginTop:12},children:e.files.map((h,p)=>b("div",{style:s.fileItem,children:[b("div",{style:{display:"flex",alignItems:"center",flex:1},children:[b("span",{style:{fontWeight:500},children:h.name}),b("span",{style:{color:"#8C8F93",fontSize:13,marginLeft:8},children:["(",y(h.size),")"]})]}),b("button",{type:"button",onClick:m=>{m.stopPropagation(),f(p)},style:s.removeBtn,children:"移除"})]},p))}),e.filesError&&b("div",{style:s.error,children:e.filesError})]}),b("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[b("button",{type:"button",onClick:n,style:s.buttonCancel,children:"取消"}),b("button",{type:"submit",disabled:r,style:s.buttonSubmit,children:"去支付"})]})]})};function oo({visible:e,onClose:t,onSubmit:n,color:r,whiteTheme:o=!0}){console.log(1111);const[i,s]=Q({amount:"",rechargeChannel:"paypal",currency:"USD",loading:!1,error:"",amountError:"",rechargeChannelError:"",currencyError:""}),[a,u]=Q("online"),[c,f]=Q({platform:"paypal",transactionId:"",files:[],platformError:"",transactionIdError:"",filesError:"",loading:!1});if(bn(()=>{e||(u("online"),s({amount:"",rechargeChannel:"paypal",currency:"USD",loading:!1,error:"",amountError:"",rechargeChannelError:"",currencyError:""}),f({platform:"paypal",transactionId:"",files:[],platformError:"",transactionIdError:"",filesError:"",loading:!1}))},[e]),!e)return null;const l=async p=>{p.preventDefault();let m=!0;if(s(_=>({..._,amountError:"",rechargeChannelError:""})),i.amount.trim()||(s(_=>({..._,amountError:"请输入充值金额"})),m=!1),i.rechargeChannel||(s(_=>({..._,rechargeChannelError:"请选择支付平台"})),m=!1),!!m){s(_=>({..._,loading:!0,error:""}));try{await n({amount:i.amount,rechargeChannel:i.rechargeChannel,currency:i.currency}),t()}catch{s(_=>({..._,error:"提交失败,请重试"}))}finally{s(_=>({..._,loading:!1}))}}},y=p=>{p.target===p.currentTarget&&t()},h=o?{modalBg:"#fff",modalColor:"#222",modalBoxShadow:"0 4px 24px rgba(0,0,0,0.08)",mask:"rgba(0,0,0,0.3)",title:{fontWeight:600,fontSize:20,marginBottom:24,textAlign:"left",color:"#222"},closeBtn:{position:"absolute",right:16,top:16,background:"none",border:"none",color:"#222",fontSize:22,cursor:"pointer",lineHeight:1},tabBtn:(p,m)=>({flex:1,background:p?"#fff":"#F7F8FA",color:p?"#155EEF":"#222",border:"none",borderRadius:m?"8px 0 0 8px":"0 8px 8px 0",fontWeight:p?600:400,fontSize:16,height:48,boxShadow:p?"0 2px 8px 0 rgba(20,20,20,0.04)":"none",outline:"none",cursor:"pointer",borderRight:m?"1px solid #F0F1F3":void 0,borderLeft:m?void 0:"1px solid #F0F1F3",transition:"all 0.2s"})}:{modalBg:"#181A20",modalColor:"#fff",modalBoxShadow:"0 4px 24px rgba(0,0,0,0.5)",mask:"rgba(0,0,0,0.7)",title:{fontWeight:600,fontSize:20,marginBottom:24,textAlign:"left",color:"#fff"},closeBtn:{position:"absolute",right:16,top:16,background:"none",border:"none",color:"#fff",fontSize:22,cursor:"pointer",lineHeight:1},tabBtn:(p,m)=>({flex:1,background:p?"#23262F":"#181A20",color:p?"#00E8C6":"#fff",border:"none",borderRadius:m?"8px 0 0 8px":"0 8px 8px 0",fontWeight:p?600:400,fontSize:16,height:48,boxShadow:p?"0 2px 8px 0 rgba(20,20,20,0.10)":"none",outline:"none",cursor:"pointer",borderRight:m?"1px solid #23262F":void 0,borderLeft:m?void 0:"1px solid #23262F",transition:"all 0.2s"})};return b("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:h.mask,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},onClick:y,children:b("form",{onSubmit:l,style:{background:h.modalBg,padding:32,borderRadius:12,minWidth:400,color:r||h.modalColor,boxShadow:h.modalBoxShadow,position:"relative"},onClick:p=>p.stopPropagation(),children:[b("button",{type:"button",onClick:t,style:h.closeBtn,"aria-label":"关闭",children:"×"}),b("div",{style:h.title,children:"充值 / 转账"}),b("div",{style:{display:"flex",marginBottom:28},children:[b("button",{type:"button",onClick:()=>u("online"),style:h.tabBtn(a==="online",!0),children:"在线充值"}),b("button",{type:"button",onClick:()=>u("offline"),style:h.tabBtn(a==="offline",!1),children:"线下转账"})]}),a==="online"?b(no,{formState:i,setFormState:s,onClose:t,loading:i.loading,whiteTheme:o}):b(ro,{formState:c,setFormState:f,onClose:t,loading:c.loading,whiteTheme:o})]})})}function Je(){return(Je=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var io=["context","children"];function so(e){this.getChildContext=function(){return e.context};var t=e.children,n=function(r,o){if(r==null)return{};var i,s,a={},u=Object.keys(r);for(s=0;s<u.length;s++)o.indexOf(i=u[s])>=0||(a[i]=r[i]);return a}(e,io);return Ft(t,n)}function ao(){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=M(so,Je({},this._props,{context:e.detail.context}),function t(n,r){if(n.nodeType===3)return n.data;if(n.nodeType!==1)return null;var o=[],i={},s=0,a=n.attributes,u=n.childNodes;for(s=a.length;s--;)a[s].name!=="slot"&&(i[a[s].name]=a[s].value,i[an(a[s].name)]=a[s].value);for(s=u.length;s--;){var c=t(u[s],null),f=u[s].slot;f?i[f]=M(yt,{name:f},c):o[s]=c}var l=r?M(yt,null,o):o;return M(r||n.nodeName.toLowerCase(),i,l)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?Ot:me)(this._vdom,this._root)}function an(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function lo(e,t,n){if(this._vdom){var r={};r[e]=n=n??void 0,r[an(e)]=n,this._vdom=Ft(this._vdom,r),me(this._vdom,this._root)}}function co(){me(this._vdom=null,this._root)}function yt(e,t){var n=this;return M("slot",Je({},e,{ref:function(r){r?(n.ref=r,n._listener||(n._listener=function(o){o.stopPropagation(),o.detail.context=t},r.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function uo(e,t,n,r){function o(){var i=Reflect.construct(HTMLElement,[],o);return i._vdomComponent=e,i._root=i,i}return(o.prototype=Object.create(HTMLElement.prototype)).constructor=o,o.prototype.connectedCallback=ao,o.prototype.attributeChangedCallback=lo,o.prototype.disconnectedCallback=co,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),o.observedAttributes=n,n.forEach(function(i){Object.defineProperty(o.prototype,i,{get:function(){return this._vdom.props[i]},set:function(s){this._vdom?this.attributeChangedCallback(i,null,s):(this._props||(this._props={}),this._props[i]=s,this.connectedCallback());var a=typeof s;s!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(i,s)}})}),customElements.define(t,o)}function fo(e){const[t,n]=Q(!1),[r,o]=Q(!0),i=e.theme?.primaryColor,s=e.merchantId,a=e.bizType,u=e.token;return b("div",{children:[b(to,{color:i,onClick:()=>n(!0),merchantId:s,bizType:a,token:u,children:"打开表单"}),b("button",{style:{marginLeft:16,padding:"8px 16px",borderRadius:6,border:"1px solid #eee",cursor:"pointer"},onClick:()=>o(f=>!f),children:r?"切换为暗黑主题":"切换为白色主题"}),b(oo,{visible:t,onClose:()=>n(!1),onSubmit:async f=>{console.log("submit",f)},color:i,whiteTheme:r,merchantId:s,bizType:a,token:u})]})}uo(fo,"x-best-modal-form",["theme"]);const po=["x-greeting","x-best-modal-form"];exports.components=po;exports.npmTest=ln;exports.printCurrentTime=cn;
6
+ `+i):r.stack=i}catch{}}throw r}}_request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=q(this.defaults,n);const{transitional:r,paramsSerializer:o,headers:i}=n;r!==void 0&&ue.assertOptions(r,{silentJSONParsing:U.transitional(U.boolean),forcedJSONParsing:U.transitional(U.boolean),clarifyTimeoutError:U.transitional(U.boolean)},!1),o!=null&&(d.isFunction(o)?n.paramsSerializer={serialize:o}:ue.assertOptions(o,{encode:U.function,serialize:U.function},!0)),n.allowAbsoluteUrls!==void 0||(this.defaults.allowAbsoluteUrls!==void 0?n.allowAbsoluteUrls=this.defaults.allowAbsoluteUrls:n.allowAbsoluteUrls=!0),ue.assertOptions(n,{baseUrl:U.spelling("baseURL"),withXsrfToken:U.spelling("withXSRFToken")},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let s=i&&d.merge(i.common,i[n.method]);i&&d.forEach(["delete","get","head","post","put","patch","common"],p=>{delete i[p]}),n.headers=B.concat(s,i);const a=[];let u=!0;this.interceptors.request.forEach(function(m){typeof m.runWhen=="function"&&m.runWhen(n)===!1||(u=u&&m.synchronous,a.unshift(m.fulfilled,m.rejected))});const c=[];this.interceptors.response.forEach(function(m){c.push(m.fulfilled,m.rejected)});let f,l=0,y;if(!u){const p=[mt.bind(this),void 0];for(p.unshift.apply(p,a),p.push.apply(p,c),y=p.length,f=Promise.resolve(n);l<y;)f=f.then(p[l++],p[l++]);return f}y=a.length;let h=n;for(l=0;l<y;){const p=a[l++],m=a[l++];try{h=p(h)}catch(_){m.call(this,_);break}}try{f=mt.call(this,h)}catch(p){return Promise.reject(p)}for(l=0,y=c.length;l<y;)f=f.then(c[l++],c[l++]);return f}getUri(t){t=q(this.defaults,t);const n=Yt(t.baseURL,t.url,t.allowAbsoluteUrls);return Vt(n,t.params,t.paramsSerializer)}};d.forEach(["delete","get","head","options"],function(t){$.prototype[t]=function(n,r){return this.request(q(r||{},{method:t,url:n,data:(r||{}).data}))}});d.forEach(["post","put","patch"],function(t){function n(r){return function(i,s,a){return this.request(q(a||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:s}))}}$.prototype[t]=n(),$.prototype[t+"Form"]=n(!0)});let Xr=class on{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(o=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](o);r._listeners=null}),this.promise.then=o=>{let i;const s=new Promise(a=>{r.subscribe(a),i=a}).then(o);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i,s,a){r.reason||(r.reason=new V(i,s,a),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}toAbortSignal(){const t=new AbortController,n=r=>{t.abort(r)};return this.subscribe(n),t.signal.unsubscribe=()=>this.unsubscribe(n),t.signal}static source(){let t;return{token:new on(function(o){t=o}),cancel:t}}};function Gr(e){return function(n){return e.apply(null,n)}}function Qr(e){return d.isObject(e)&&e.isAxiosError===!0}const Le={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Le).forEach(([e,t])=>{Le[t]=e});function sn(e){const t=new $(e),n=Dt($.prototype.request,t);return d.extend(n,$.prototype,t,{allOwnKeys:!0}),d.extend(n,t,null,{allOwnKeys:!0}),n.create=function(o){return sn(q(e,o))},n}const R=sn(oe);R.Axios=$;R.CanceledError=V;R.CancelToken=Xr;R.isCancel=Gt;R.VERSION=rn;R.toFormData=xe;R.AxiosError=x;R.Cancel=R.CanceledError;R.all=function(t){return Promise.all(t)};R.spread=Gr;R.isAxiosError=Qr;R.mergeConfig=q;R.AxiosHeaders=B;R.formToJSON=e=>Xt(d.isHTMLForm(e)?new FormData(e):e);R.getAdapter=nn.getAdapter;R.HttpStatusCode=Le;R.default=R;const{Axios:mo,AxiosError:bo,CanceledError:yo,isCancel:go,CancelToken:Eo,VERSION:xo,all:wo,Cancel:vo,isAxiosError:So,spread:Ro,toFormData:Co,AxiosHeaders:ko,HttpStatusCode:To,formToJSON:Ao,getAdapter:Oo,mergeConfig:Fo}=R;function Yr(e={}){const{baseURL:t="/api",timeout:n=1e4,getToken:r,getLocale:o,onError:i}=e,s=R.create({baseURL:t,timeout:n});return s.interceptors.request.use(a=>{if(r){const u=r();u&&(a.headers={...a.headers,Authorization:u})}if(o){const u=o();u&&(a.headers={...a.headers,"Accept-Language":u})}return a}),s.interceptors.response.use(a=>a.data&&a.data.code===0?a.data:(i&&i(a.data?.msg||a.data?.message||"未知错误",a),Promise.reject(a.data||{message:"未知错误"})),a=>(i&&i(a.message,a),Promise.reject(a))),s}const Zr=Yr();function eo(e){const{token:t,...n}=e;return Zr.get("/balance",{params:n,headers:t?{Authorization:t}:void 0})}function to({onClick:e,color:t,children:n,merchantId:r,bizType:o,token:i}){return r&&o&&eo({merchant_id:r,biz_type:o,token:i}).then(s=>console.log(s)),b("button",{style:{background:t||"#1890ff",color:"#fff",border:"none",borderRadius:4,padding:"8px 16px",cursor:"pointer",fontSize:16},onClick:e,children:n})}const no=({formState:e,setFormState:t,onClose:n,loading:r,whiteTheme:o=!1})=>{const i=o?{label:{marginBottom:8,fontSize:14,color:"#222",textAlign:"left",display:"block"},input:{width:"100%",padding:"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},error:{color:"#ff4d4f",fontSize:13,marginTop:4,textAlign:"left"}}:{label:{marginBottom:8,fontSize:14,color:"#fff",textAlign:"left",display:"block"},input:{width:"100%",padding:"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #23262F",background:"#23262F",color:"#fff",fontSize:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid #23262F",background:"#23262F",color:"#fff",fontSize:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},error:{color:"#ff4d4f",fontSize:13,marginTop:4,textAlign:"left"}},s=o?{background:"#fff",color:"#222",border:"1px solid #E5E6EB",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer"}:{background:"#23262F",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer"},a=o?{background:"#155EEF",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer",fontWeight:600}:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer",fontWeight:600};return b(ne,{children:[b("div",{style:{marginBottom:18},children:[b("div",{style:i.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 充值币种"]}),b("select",{style:{...i.select},value:e.currency,onInput:u=>{const c=u.target.value;t(f=>({...f,currency:c}))},children:[b("option",{value:"USD",children:"USD - 美元"}),b("option",{value:"CNY",children:"CNY - 人民币"}),b("option",{value:"EUR",children:"EUR - 欧元"})]})]}),b("div",{style:{marginBottom:18},children:[b("div",{style:i.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 充值金额"]}),b("input",{type:"text",placeholder:"请输入充值金额",value:e.amount,onInput:u=>{const c=u.target.value;t(f=>({...f,amount:c,amountError:c.trim()?"":f.amountError}))},style:{...i.input,...e.amountError?i.inputError:{}}}),e.amountError&&b("div",{style:i.error,children:e.amountError})]}),b("div",{style:{marginBottom:24},children:[b("div",{style:i.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 支付平台"]}),b("select",{style:{...i.select,...e.rechargeChannelError?i.selectError:{}},value:e.rechargeChannel,onInput:u=>{const c=u.target.value;t(f=>({...f,rechargeChannel:c,rechargeChannelError:c?"":f.rechargeChannelError}))},children:[b("option",{value:"alipay",children:"支付宝"}),b("option",{value:"wechat",children:"微信"}),b("option",{value:"paypal",children:"PayPal"})]}),e.rechargeChannelError&&b("div",{style:i.error,children:e.rechargeChannelError})]}),e.error&&b("div",{style:{color:"#ff4d4f",marginBottom:12},children:e.error}),b("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[b("button",{type:"button",onClick:n,style:s,children:"取消"}),b("button",{type:"submit",disabled:r,style:a,children:r?"提交中...":"去支付"})]})]})},ro=({formState:e,setFormState:t,onClose:n,loading:r,whiteTheme:o=!1})=>{const i=yn(null),s=o?{label:{marginBottom:8,fontSize:14,color:"#222",textAlign:"left",display:"block"},input:{width:"100%",padding:"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid #E5E6EB",background:"#fff",color:"#222",fontSize:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},upload:{border:"1px dashed #E5E6EB",borderRadius:8,background:"#FCFCFD",padding:24,textAlign:"center",cursor:"pointer",minHeight:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:15},uploadError:{border:"1px dashed #ff4d4f"},fileItem:{display:"flex",alignItems:"center",background:"#F7F8FA",borderRadius:8,padding:"12px 16px",marginBottom:8,fontSize:15,color:"#222",justifyContent:"space-between"},buttonCancel:{background:"#fff",color:"#222",border:"1px solid #E5E6EB",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer"},buttonSubmit:{background:"#155EEF",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer",fontWeight:600},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:"4px 14px",fontSize:15,marginLeft:16,cursor:"pointer"},error:{color:"#ff4d4f",fontSize:13,marginTop:4,textAlign:"left"}}:{label:{marginBottom:8,fontSize:14,color:"#fff",textAlign:"left",display:"block"},input:{width:"100%",padding:"10px 12px",borderRadius:6,boxSizing:"border-box",border:"1px solid #23262F",background:"#23262F",color:"#fff",fontSize:15,outline:"none",marginBottom:0},inputError:{border:"1px solid #ff4d4f"},select:{width:"100%",padding:"10px 12px",borderRadius:6,border:"1px solid #23262F",background:"#23262F",color:"#fff",fontSize:15,outline:"none"},selectError:{border:"1px solid #ff4d4f"},upload:{border:"1px dashed #23262F",borderRadius:8,background:"#181A20",padding:24,textAlign:"center",cursor:"pointer",minHeight:120,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",color:"#999",fontSize:15},uploadError:{border:"1px dashed #ff4d4f"},fileItem:{display:"flex",alignItems:"center",background:"#23262F",borderRadius:8,padding:"12px 16px",marginBottom:8,fontSize:15,color:"#fff",justifyContent:"space-between"},buttonCancel:{background:"#23262F",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer"},buttonSubmit:{background:"#00E8C6",color:"#fff",border:"none",borderRadius:6,padding:"8px 24px",fontSize:15,cursor:"pointer",fontWeight:600},removeBtn:{background:"#FF4D4F",color:"#fff",border:"none",borderRadius:6,padding:"4px 14px",fontSize:15,marginLeft:16,cursor:"pointer"},error:{color:"#ff4d4f",fontSize:13,marginTop:4,textAlign:"left"}},a=h=>{const p=Array.from(h.target.files).slice(0,10);t(m=>({...m,files:p,filesError:""}))},u=h=>{h.preventDefault();const p=Array.from(h.dataTransfer.files).slice(0,10);t(m=>({...m,files:p,filesError:""}))},c=h=>{h.preventDefault()},f=h=>{t(p=>({...p,files:p.files.filter((m,_)=>_!==h)}))},l=h=>{h.preventDefault();let p=!0;t(m=>({...m,platformError:"",transactionIdError:"",filesError:""})),e.platform||(t(m=>({...m,platformError:"请选择支付平台"})),p=!1),e.transactionId.trim()||(t(m=>({...m,transactionIdError:"请输入转账交易ID"})),p=!1),(!e.files||e.files.length===0)&&(t(m=>({...m,filesError:"请上传转账凭证"})),p=!1),p&&console.log("OfflineTransferForm values:",e)},y=h=>h>1024*1024?(h/1024/1024).toFixed(2)+" MB":h>1024?(h/1024).toFixed(2)+" KB":h+" B";return b("form",{onSubmit:l,children:[b("div",{style:{marginBottom:18},children:[b("div",{style:s.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 第三方支付平台"]}),b("select",{style:{...s.select,...e.platformError?s.selectError:{}},value:e.platform,onInput:h=>{const p=h.target.value;t(m=>({...m,platform:p,platformError:p?"":m.platformError}))},children:[b("option",{value:"paypal",children:"PayPal"}),b("option",{value:"alipay",children:"支付宝"}),b("option",{value:"wechat",children:"微信"})]}),e.platformError&&b("div",{style:s.error,children:e.platformError})]}),b("div",{style:{marginBottom:18},children:[b("div",{style:s.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 交易ID"]}),b("input",{type:"text",placeholder:"请输入转账交易ID",value:e.transactionId,onInput:h=>{const p=h.target.value;t(m=>({...m,transactionId:p,transactionIdError:p?"":m.transactionIdError}))},style:{...s.input,...e.transactionIdError?s.inputError:{}}}),e.transactionIdError&&b("div",{style:s.error,children:e.transactionIdError})]}),b("div",{style:{marginBottom:24},children:[b("div",{style:s.label,children:[b("span",{style:{color:"#F53F3F"},children:"*"})," 上传文件"]}),b("div",{style:{...s.upload,...e.filesError?s.uploadError:{}},onClick:()=>i.current?.click(),onDrop:u,onDragOver:c,children:[b("div",{style:{fontSize:48,marginBottom:12},children:b("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[b("rect",{x:"8",y:"8",width:"48",height:"48",rx:"12",fill:"#F4F6FA"}),b("rect",{x:"28",y:"20",width:"8",height:"24",rx:"4",fill:"#E5E6EB"})]})}),b("div",{style:{color:"#222",fontSize:15,marginBottom:4},children:"点击或拖拽文件到此处上传"}),b("div",{style:{color:"#999",fontSize:13},children:"支持 JPG、PNG、PDF 格式,单个文件不超过 20MB,最多上传 10 个文件"}),b("input",{ref:i,type:"file",multiple:!0,accept:".jpg,.jpeg,.png,.pdf",style:{display:"none"},onChange:a})]}),e.files&&e.files.length>0&&b("div",{style:{marginTop:12},children:e.files.map((h,p)=>b("div",{style:s.fileItem,children:[b("div",{style:{display:"flex",alignItems:"center",flex:1},children:[b("span",{style:{fontWeight:500},children:h.name}),b("span",{style:{color:"#8C8F93",fontSize:13,marginLeft:8},children:["(",y(h.size),")"]})]}),b("button",{type:"button",onClick:m=>{m.stopPropagation(),f(p)},style:s.removeBtn,children:"移除"})]},p))}),e.filesError&&b("div",{style:s.error,children:e.filesError})]}),b("div",{style:{display:"flex",justifyContent:"flex-end",gap:12},children:[b("button",{type:"button",onClick:n,style:s.buttonCancel,children:"取消"}),b("button",{type:"submit",disabled:r,style:s.buttonSubmit,children:"去支付"})]})]})};function oo({visible:e,onClose:t,onSubmit:n,color:r,whiteTheme:o=!0}){console.log(1111);const[i,s]=Q({amount:"",rechargeChannel:"paypal",currency:"USD",loading:!1,error:"",amountError:"",rechargeChannelError:"",currencyError:""}),[a,u]=Q("online"),[c,f]=Q({platform:"paypal",transactionId:"",files:[],platformError:"",transactionIdError:"",filesError:"",loading:!1});if(bn(()=>{e||(u("online"),s({amount:"",rechargeChannel:"paypal",currency:"USD",loading:!1,error:"",amountError:"",rechargeChannelError:"",currencyError:""}),f({platform:"paypal",transactionId:"",files:[],platformError:"",transactionIdError:"",filesError:"",loading:!1}))},[e]),!e)return null;const l=async p=>{p.preventDefault();let m=!0;if(s(_=>({..._,amountError:"",rechargeChannelError:""})),i.amount.trim()||(s(_=>({..._,amountError:"请输入充值金额"})),m=!1),i.rechargeChannel||(s(_=>({..._,rechargeChannelError:"请选择支付平台"})),m=!1),!!m){s(_=>({..._,loading:!0,error:""}));try{await n({amount:i.amount,rechargeChannel:i.rechargeChannel,currency:i.currency}),t()}catch{s(_=>({..._,error:"提交失败,请重试"}))}finally{s(_=>({..._,loading:!1}))}}},y=p=>{p.target===p.currentTarget&&t()},h=o?{modalBg:"#fff",modalColor:"#222",modalBoxShadow:"0 4px 24px rgba(0,0,0,0.08)",mask:"rgba(0,0,0,0.3)",title:{fontWeight:600,fontSize:20,marginBottom:24,textAlign:"left",color:"#222"},closeBtn:{position:"absolute",right:16,top:16,background:"none",border:"none",color:"#222",fontSize:22,cursor:"pointer",lineHeight:1},tabBtn:(p,m)=>({flex:1,background:p?"#fff":"#F7F8FA",color:p?"#155EEF":"#222",border:"none",borderRadius:m?"8px 0 0 8px":"0 8px 8px 0",fontWeight:p?600:400,fontSize:16,height:48,boxShadow:p?"0 2px 8px 0 rgba(20,20,20,0.04)":"none",outline:"none",cursor:"pointer",borderRight:m?"1px solid #F0F1F3":void 0,borderLeft:m?void 0:"1px solid #F0F1F3",transition:"all 0.2s"})}:{modalBg:"#181A20",modalColor:"#fff",modalBoxShadow:"0 4px 24px rgba(0,0,0,0.5)",mask:"rgba(0,0,0,0.7)",title:{fontWeight:600,fontSize:20,marginBottom:24,textAlign:"left",color:"#fff"},closeBtn:{position:"absolute",right:16,top:16,background:"none",border:"none",color:"#fff",fontSize:22,cursor:"pointer",lineHeight:1},tabBtn:(p,m)=>({flex:1,background:p?"#23262F":"#181A20",color:p?"#00E8C6":"#fff",border:"none",borderRadius:m?"8px 0 0 8px":"0 8px 8px 0",fontWeight:p?600:400,fontSize:16,height:48,boxShadow:p?"0 2px 8px 0 rgba(20,20,20,0.10)":"none",outline:"none",cursor:"pointer",borderRight:m?"1px solid #23262F":void 0,borderLeft:m?void 0:"1px solid #23262F",transition:"all 0.2s"})};return b("div",{style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:h.mask,display:"flex",alignItems:"center",justifyContent:"center",zIndex:9999},onClick:y,children:b("form",{onSubmit:l,style:{background:h.modalBg,padding:32,borderRadius:12,minWidth:400,color:r||h.modalColor,boxShadow:h.modalBoxShadow,position:"relative"},onClick:p=>p.stopPropagation(),children:[b("button",{type:"button",onClick:t,style:h.closeBtn,"aria-label":"关闭",children:"×"}),b("div",{style:h.title,children:"充值 / 转账"}),b("div",{style:{display:"flex",marginBottom:28},children:[b("button",{type:"button",onClick:()=>u("online"),style:h.tabBtn(a==="online",!0),children:"在线充值"}),b("button",{type:"button",onClick:()=>u("offline"),style:h.tabBtn(a==="offline",!1),children:"线下转账"})]}),a==="online"?b(no,{formState:i,setFormState:s,onClose:t,loading:i.loading,whiteTheme:o}):b(ro,{formState:c,setFormState:f,onClose:t,loading:c.loading,whiteTheme:o})]})})}function Je(){return(Je=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}var io=["context","children"];function so(e){this.getChildContext=function(){return e.context};var t=e.children,n=function(r,o){if(r==null)return{};var i,s,a={},u=Object.keys(r);for(s=0;s<u.length;s++)o.indexOf(i=u[s])>=0||(a[i]=r[i]);return a}(e,io);return Ft(t,n)}function ao(){var e=new CustomEvent("_preact",{detail:{},bubbles:!0,cancelable:!0});this.dispatchEvent(e),this._vdom=M(so,Je({},this._props,{context:e.detail.context}),function t(n,r){if(n.nodeType===3)return n.data;if(n.nodeType!==1)return null;var o=[],i={},s=0,a=n.attributes,u=n.childNodes;for(s=a.length;s--;)a[s].name!=="slot"&&(i[a[s].name]=a[s].value,i[an(a[s].name)]=a[s].value);for(s=u.length;s--;){var c=t(u[s],null),f=u[s].slot;f?i[f]=M(yt,{name:f},c):o[s]=c}var l=r?M(yt,null,o):o;return M(r||n.nodeName.toLowerCase(),i,l)}(this,this._vdomComponent)),(this.hasAttribute("hydrate")?Ot:me)(this._vdom,this._root)}function an(e){return e.replace(/-(\w)/g,function(t,n){return n?n.toUpperCase():""})}function lo(e,t,n){if(this._vdom){var r={};r[e]=n=n??void 0,r[an(e)]=n,this._vdom=Ft(this._vdom,r),me(this._vdom,this._root)}}function co(){me(this._vdom=null,this._root)}function yt(e,t){var n=this;return M("slot",Je({},e,{ref:function(r){r?(n.ref=r,n._listener||(n._listener=function(o){o.stopPropagation(),o.detail.context=t},r.addEventListener("_preact",n._listener))):n.ref.removeEventListener("_preact",n._listener)}}))}function uo(e,t,n,r){function o(){var i=Reflect.construct(HTMLElement,[],o);return i._vdomComponent=e,i._root=i,i}return(o.prototype=Object.create(HTMLElement.prototype)).constructor=o,o.prototype.connectedCallback=ao,o.prototype.attributeChangedCallback=lo,o.prototype.disconnectedCallback=co,n=n||e.observedAttributes||Object.keys(e.propTypes||{}),o.observedAttributes=n,n.forEach(function(i){Object.defineProperty(o.prototype,i,{get:function(){return this._vdom.props[i]},set:function(s){this._vdom?this.attributeChangedCallback(i,null,s):(this._props||(this._props={}),this._props[i]=s,this.connectedCallback());var a=typeof s;s!=null&&a!=="string"&&a!=="boolean"&&a!=="number"||this.setAttribute(i,s)}})}),customElements.define(t,o)}function fo(e){const[t,n]=Q(!1),[r,o]=Q(!0),i=e.theme?.primaryColor,s=e.merchant_id,a=e.biz_type,u=e.token;return b("div",{children:[b(to,{color:i,onClick:()=>n(!0),merchantId:s,bizType:a,token:u,children:"打开表单"}),b("button",{style:{marginLeft:16,padding:"8px 16px",borderRadius:6,border:"1px solid #eee",cursor:"pointer"},onClick:()=>o(f=>!f),children:r?"切换为暗黑主题":"切换为白色主题"}),b(oo,{visible:t,onClose:()=>n(!1),onSubmit:async f=>{console.log("submit",f)},color:i,whiteTheme:r,merchantId:s,bizType:a,token:u})]})}uo(fo,"x-best-modal-form",["theme"]);const po=["x-greeting","x-best-modal-form"];exports.components=po;exports.npmTest=ln;exports.printCurrentTime=cn;
package/dist/best-unit.js CHANGED
@@ -4,12 +4,12 @@ function uo() {
4
4
  function fo() {
5
5
  console.log("Current time:", (/* @__PURE__ */ new Date()).toISOString());
6
6
  }
7
- var te, w, gt, z, Ve, Et, xt, wt, Ie, Te, Oe, Y = {}, vt = [], ln = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, _e = Array.isArray;
7
+ var te, w, gt, z, Ve, Et, xt, wt, je, Te, Oe, Y = {}, vt = [], ln = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i, _e = Array.isArray;
8
8
  function L(e, t) {
9
9
  for (var n in t) e[n] = t[n];
10
10
  return e;
11
11
  }
12
- function je(e) {
12
+ function Ie(e) {
13
13
  e && e.parentNode && e.parentNode.removeChild(e);
14
14
  }
15
15
  function M(e, t, n) {
@@ -98,7 +98,7 @@ function ie(e, t, n, r, o) {
98
98
  if (typeof r == "string" && (e.style.cssText = r = ""), r) for (t in r) n && t in n || Xe(e.style, t, "");
99
99
  if (n) for (t in n) r && n[t] == r[t] || Xe(e.style, t, n[t]);
100
100
  }
101
- else if (t[0] == "o" && t[1] == "n") i = t != (t = t.replace(wt, "$1")), s = t.toLowerCase(), t = s in e || t == "onFocusOut" || t == "onFocusIn" ? s.slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + i] = n, n ? r ? n.u = r.u : (n.u = Ie, e.addEventListener(t, i ? Oe : Te, i)) : e.removeEventListener(t, i ? Oe : Te, i);
101
+ else if (t[0] == "o" && t[1] == "n") i = t != (t = t.replace(wt, "$1")), s = t.toLowerCase(), t = s in e || t == "onFocusOut" || t == "onFocusIn" ? s.slice(2) : t.slice(2), e.l || (e.l = {}), e.l[t + i] = n, n ? r ? n.u = r.u : (n.u = je, e.addEventListener(t, i ? Oe : Te, i)) : e.removeEventListener(t, i ? Oe : Te, i);
102
102
  else {
103
103
  if (o == "http://www.w3.org/2000/svg") t = t.replace(/xlink(H|:h)/, "h").replace(/sName$/, "s");
104
104
  else if (t != "width" && t != "height" && t != "href" && t != "list" && t != "form" && t != "tabIndex" && t != "download" && t != "rowSpan" && t != "colSpan" && t != "role" && t != "popover" && t in e) try {
@@ -113,14 +113,14 @@ function Ge(e) {
113
113
  return function(t) {
114
114
  if (this.l) {
115
115
  var n = this.l[t.type + e];
116
- if (t.t == null) t.t = Ie++;
116
+ if (t.t == null) t.t = je++;
117
117
  else if (t.t < n.u) return;
118
118
  return n(w.event ? w.event(t) : t);
119
119
  }
120
120
  };
121
121
  }
122
122
  function ze(e, t, n, r, o, i, s, a, u, c) {
123
- var f, l, y, h, p, m, _, g, E, v, A, k, O, N, I, j, Se, D = t.type;
123
+ var f, l, y, h, p, m, _, g, E, v, A, k, O, N, j, I, Se, D = t.type;
124
124
  if (t.constructor != null) return null;
125
125
  128 & n.__u && (u = !!(32 & n.__u), i = [a = t.__e = n.__e]), (f = w.__b) && f(t);
126
126
  e: if (typeof D == "function") try {
@@ -138,17 +138,17 @@ function ze(e, t, n, r, o, i, s, a, u, c) {
138
138
  });
139
139
  }
140
140
  if (l.context = A, l.props = g, l.__P = e, l.__e = !1, O = w.__r, N = 0, E) {
141
- for (l.state = l.__s, l.__d = !1, O && O(t), f = l.render(l.props, l.state, l.context), I = 0; I < l._sb.length; I++) l.__h.push(l._sb[I]);
141
+ for (l.state = l.__s, l.__d = !1, O && O(t), f = l.render(l.props, l.state, l.context), j = 0; j < l._sb.length; j++) l.__h.push(l._sb[j]);
142
142
  l._sb = [];
143
143
  } else do
144
144
  l.__d = !1, O && O(t), f = l.render(l.props, l.state, l.context), l.state = l.__s;
145
145
  while (l.__d && ++N < 25);
146
- l.state = l.__s, l.getChildContext != null && (r = L(L({}, r), l.getChildContext())), E && !y && l.getSnapshotBeforeUpdate != null && (m = l.getSnapshotBeforeUpdate(h, p)), j = f, f != null && f.type === ne && f.key == null && (j = At(f.props.children)), a = Rt(e, _e(j) ? j : [j], t, n, r, o, i, s, a, u, c), l.base = t.__e, t.__u &= -161, l.__h.length && s.push(l), _ && (l.__E = l.__ = null);
146
+ l.state = l.__s, l.getChildContext != null && (r = L(L({}, r), l.getChildContext())), E && !y && l.getSnapshotBeforeUpdate != null && (m = l.getSnapshotBeforeUpdate(h, p)), I = f, f != null && f.type === ne && f.key == null && (I = At(f.props.children)), a = Rt(e, _e(I) ? I : [I], t, n, r, o, i, s, a, u, c), l.base = t.__e, t.__u &= -161, l.__h.length && s.push(l), _ && (l.__E = l.__ = null);
147
147
  } catch (K) {
148
148
  if (t.__v = null, u || i != null) if (K.then) {
149
149
  for (t.__u |= u ? 160 : 128; a && a.nodeType == 8 && a.nextSibling; ) a = a.nextSibling;
150
150
  i[i.indexOf(a)] = null, t.__e = a;
151
- } else for (Se = i.length; Se--; ) je(i[Se]);
151
+ } else for (Se = i.length; Se--; ) Ie(i[Se]);
152
152
  else t.__e = n.__e, t.__k = n.__k;
153
153
  w.__e(K, t, n);
154
154
  }
@@ -194,7 +194,7 @@ function fn(e, t, n, r, o, i, s, a, u) {
194
194
  }
195
195
  for (c in g) h = g[c], c == "children" ? y = h : c == "dangerouslySetInnerHTML" ? f = h : c == "value" ? p = h : c == "checked" ? m = h : a && typeof h != "function" || _[c] === h || ie(e, c, h, _[c], o);
196
196
  if (f) a || l && (f.__html == l.__html || f.__html == e.innerHTML) || (e.innerHTML = f.__html), t.__k = [];
197
- else if (l && (e.innerHTML = ""), Rt(t.type == "template" ? e.content : e, _e(y) ? y : [y], t, n, r, E == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, i, s, i ? i[0] : n.__k && W(n, 0), a, u), i != null) for (c = i.length; c--; ) je(i[c]);
197
+ else if (l && (e.innerHTML = ""), Rt(t.type == "template" ? e.content : e, _e(y) ? y : [y], t, n, r, E == "foreignObject" ? "http://www.w3.org/1999/xhtml" : o, i, s, i ? i[0] : n.__k && W(n, 0), a, u), i != null) for (c = i.length; c--; ) Ie(i[c]);
198
198
  a || (c = "value", E == "progress" && p == null ? e.removeAttribute("value") : p != null && (p !== e[c] || E == "progress" && !p || E == "option" && p != _[c]) && ie(e, c, p, _[c], o), c = "checked", m != null && m != e[c] && ie(e, c, m, _[c], o));
199
199
  }
200
200
  return e;
@@ -220,7 +220,7 @@ function Tt(e, t, n) {
220
220
  r.base = r.__P = null;
221
221
  }
222
222
  if (r = e.__k) for (o = 0; o < r.length; o++) r[o] && Tt(r[o], t, n || typeof e.type != "function");
223
- n || je(e.__e), e.__c = e.__ = e.__e = void 0;
223
+ n || Ie(e.__e), e.__c = e.__ = e.__e = void 0;
224
224
  }
225
225
  function dn(e, t, n) {
226
226
  return this.constructor(e, n);
@@ -251,7 +251,7 @@ te = vt.slice, w = { __e: function(e, t, n, r) {
251
251
  this.__v && (this.__e = !0, e && this.__h.push(e), Ke(this));
252
252
  }, se.prototype.render = ne, z = [], Et = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, xt = function(e, t) {
253
253
  return e.__v.__b - t.__v.__b;
254
- }, fe.__r = 0, wt = /(PointerCapture)$|Capture$/i, Ie = 0, Te = Ge(!1), Oe = Ge(!0);
254
+ }, fe.__r = 0, wt = /(PointerCapture)$|Capture$/i, je = 0, Te = Ge(!1), Oe = Ge(!0);
255
255
  var pn = 0;
256
256
  function b(e, t, n, r, o, i) {
257
257
  t || (t = {});
@@ -403,7 +403,7 @@ function wn(e) {
403
403
  let t;
404
404
  return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && Lt(e.buffer), t;
405
405
  }
406
- const vn = ge("string"), F = ge("function"), It = ge("number"), Ee = (e) => e !== null && typeof e == "object", Sn = (e) => e === !0 || e === !1, le = (e) => {
406
+ const vn = ge("string"), F = ge("function"), jt = ge("number"), Ee = (e) => e !== null && typeof e == "object", Sn = (e) => e === !0 || e === !1, le = (e) => {
407
407
  if (ye(e) !== "object")
408
408
  return !1;
409
409
  const t = qe(e);
@@ -427,7 +427,7 @@ function re(e, t, { allOwnKeys: n = !1 } = {}) {
427
427
  a = i[r], t.call(null, e[a], a, e);
428
428
  }
429
429
  }
430
- function jt(e, t) {
430
+ function It(e, t) {
431
431
  t = t.toLowerCase();
432
432
  const n = Object.keys(e);
433
433
  let r = n.length, o;
@@ -439,7 +439,7 @@ function jt(e, t) {
439
439
  const H = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, zt = (e) => !ee(e) && e !== H;
440
440
  function Be() {
441
441
  const { caseless: e } = zt(this) && this || {}, t = {}, n = (r, o) => {
442
- const i = e && jt(t, o) || o;
442
+ const i = e && It(t, o) || o;
443
443
  le(t[i]) && le(r) ? t[i] = Be(t[i], r) : le(r) ? t[i] = Be({}, r) : J(r) ? t[i] = r.slice() : t[i] = r;
444
444
  };
445
445
  for (let r = 0, o = arguments.length; r < o; r++)
@@ -448,7 +448,7 @@ function Be() {
448
448
  }
449
449
  const Ln = (e, t, n, { allOwnKeys: r } = {}) => (re(t, (o, i) => {
450
450
  n && F(o) ? e[i] = Dt(o, n) : e[i] = o;
451
- }, { allOwnKeys: r }), e), In = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), jn = (e, t, n, r) => {
451
+ }, { allOwnKeys: r }), e), jn = (e) => (e.charCodeAt(0) === 65279 && (e = e.slice(1)), e), In = (e, t, n, r) => {
452
452
  e.prototype = Object.create(t.prototype, r), e.prototype.constructor = e, Object.defineProperty(e, "super", {
453
453
  value: t.prototype
454
454
  }), n && Object.assign(e.prototype, n);
@@ -470,7 +470,7 @@ const Ln = (e, t, n, { allOwnKeys: r } = {}) => (re(t, (o, i) => {
470
470
  if (!e) return null;
471
471
  if (J(e)) return e;
472
472
  let t = e.length;
473
- if (!It(t)) return null;
473
+ if (!jt(t)) return null;
474
474
  const n = new Array(t);
475
475
  for (; t-- > 0; )
476
476
  n[t] = e[t];
@@ -557,7 +557,7 @@ const er = (e) => {
557
557
  isFormData: On,
558
558
  isArrayBufferView: wn,
559
559
  isString: vn,
560
- isNumber: It,
560
+ isNumber: jt,
561
561
  isBoolean: Sn,
562
562
  isObject: Ee,
563
563
  isPlainObject: le,
@@ -579,8 +579,8 @@ const er = (e) => {
579
579
  merge: Be,
580
580
  extend: Ln,
581
581
  trim: Un,
582
- stripBOM: In,
583
- inherits: jn,
582
+ stripBOM: jn,
583
+ inherits: In,
584
584
  toFlatObject: zn,
585
585
  kindOf: ye,
586
586
  kindOfTest: P,
@@ -598,7 +598,7 @@ const er = (e) => {
598
598
  toCamelCase: Vn,
599
599
  noop: Qn,
600
600
  toFiniteNumber: Yn,
601
- findKey: jt,
601
+ findKey: It,
602
602
  global: H,
603
603
  isContextDefined: zt,
604
604
  isSpecCompliantForm: Zn,
@@ -1478,10 +1478,10 @@ const Zt = (e) => {
1478
1478
  let r = 0, o;
1479
1479
  for (; r < n; )
1480
1480
  o = r + t, yield e.slice(r, o), r = o;
1481
- }, Ir = async function* (e, t) {
1482
- for await (const n of jr(e))
1481
+ }, jr = async function* (e, t) {
1482
+ for await (const n of Ir(e))
1483
1483
  yield* Lr(n, t);
1484
- }, jr = async function* (e) {
1484
+ }, Ir = async function* (e) {
1485
1485
  if (e[Symbol.asyncIterator]) {
1486
1486
  yield* e;
1487
1487
  return;
@@ -1498,7 +1498,7 @@ const Zt = (e) => {
1498
1498
  await t.cancel();
1499
1499
  }
1500
1500
  }, pt = (e, t, n, r) => {
1501
- const o = Ir(e, t);
1501
+ const o = jr(e, t);
1502
1502
  let i = 0, s, a = (u) => {
1503
1503
  s || (s = !0, r && r(u));
1504
1504
  };
@@ -1598,11 +1598,11 @@ const $r = async (e) => {
1598
1598
  duplex: "half"
1599
1599
  }), O;
1600
1600
  if (d.isFormData(r) && (O = k.headers.get("content-type")) && f.setContentType(O), k.body) {
1601
- const [N, I] = ut(
1601
+ const [N, j] = ut(
1602
1602
  _,
1603
1603
  pe(ft(u))
1604
1604
  );
1605
- r = pt(k.body, ht, N, I);
1605
+ r = pt(k.body, ht, N, j);
1606
1606
  }
1607
1607
  }
1608
1608
  d.isString(l) || (l = l ? "include" : "omit");
@@ -1620,16 +1620,16 @@ const $r = async (e) => {
1620
1620
  const v = De && (c === "stream" || c === "response");
1621
1621
  if (De && (a || v && m)) {
1622
1622
  const k = {};
1623
- ["status", "statusText", "headers"].forEach((j) => {
1624
- k[j] = E[j];
1623
+ ["status", "statusText", "headers"].forEach((I) => {
1624
+ k[I] = E[I];
1625
1625
  });
1626
- const O = d.toFiniteNumber(E.headers.get("content-length")), [N, I] = a && ut(
1626
+ const O = d.toFiniteNumber(E.headers.get("content-length")), [N, j] = a && ut(
1627
1627
  O,
1628
1628
  pe(ft(a), !0)
1629
1629
  ) || [];
1630
1630
  E = new Response(
1631
1631
  pt(E.body, ht, N, () => {
1632
- I && I(), m && m();
1632
+ j && j(), m && m();
1633
1633
  }),
1634
1634
  k
1635
1635
  );
@@ -3039,7 +3039,7 @@ function lo(e, t, n, r) {
3039
3039
  }), customElements.define(t, o);
3040
3040
  }
3041
3041
  function co(e) {
3042
- const [t, n] = Q(!1), [r, o] = Q(!0), i = e.theme?.primaryColor, s = e.merchantId, a = e.bizType, u = e.token;
3042
+ const [t, n] = Q(!1), [r, o] = Q(!0), i = e.theme?.primaryColor, s = e.merchant_id, a = e.biz_type, u = e.token;
3043
3043
  return /* @__PURE__ */ b("div", { children: [
3044
3044
  /* @__PURE__ */ b(
3045
3045
  Zr,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "best-unit",
3
3
  "private": false,
4
- "version": "0.0.12",
4
+ "version": "0.0.13",
5
5
  "type": "module",
6
6
  "main": "dist/best-unit.cjs",
7
7
  "module": "dist/best-unit.js",
@@ -7,8 +7,8 @@ export function BestUnit(props: any) {
7
7
  const [visible, setVisible] = useState(false);
8
8
  const [whiteTheme, setWhiteTheme] = useState(true);
9
9
  const color = props.theme?.primaryColor;
10
- const merchantId = props.merchantId;
11
- const bizType = props.bizType;
10
+ const merchantId = props.merchant_id;
11
+ const bizType = props.biz_type;
12
12
  const token = props.token;
13
13
 
14
14
  const handleSubmit = async (form: {
package/src/demo/App.tsx CHANGED
@@ -1,5 +1,5 @@
1
- import { npmTest, printCurrentTime } from '../main';
2
- import { BestUnit } from '../components/ModalForm';
1
+ import { npmTest, printCurrentTime } from "../main";
2
+ import { BestUnit } from "../components/ModalForm";
3
3
 
4
4
  export default function DemoApp() {
5
5
  return (
@@ -7,13 +7,20 @@ export default function DemoApp() {
7
7
  <h2>组件库可视化测试</h2>
8
8
  <div>
9
9
  <h3>BestUnit 组件演示:</h3>
10
- <BestUnit theme={{ primaryColor: '#6366f1' }} />
10
+ <BestUnit
11
+ theme={{ primaryColor: "#6366f1" }}
12
+ merchant_id="1128"
13
+ biz_type="ad"
14
+ token="123"
15
+ />
11
16
  </div>
12
17
  <div>
13
18
  <h3>方法演示:</h3>
14
- <button onClick={npmTest} style={{ marginRight: 10 }}>调用 npmTest()</button>
19
+ <button onClick={npmTest} style={{ marginRight: 10 }}>
20
+ 调用 npmTest()
21
+ </button>
15
22
  <button onClick={printCurrentTime}>调用 printCurrentTime()</button>
16
23
  </div>
17
24
  </div>
18
25
  );
19
- }
26
+ }