@edgex-web/components 0.2.0-beta.22 → 0.2.0-beta.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import { o as e, C as i, D as t, n, p as r, L as p, o as d, S as L, T as h, W as D, y as g, r as u, A as w, h as W, w as C, G as m, q as E, z as A, v as O, F as T, t as M, E as S, u as l, j as f, x as P, m as _, k as c, I as v } from "./index-BRTnkVLg.mjs";
1
+ import { o as e, C as i, D as t, n, p as r, L as p, o as d, S as L, T as h, W as D, y as g, r as u, A as w, h as W, w as C, G as m, q as E, z as A, v as O, F as T, t as M, E as S, u as l, j as f, x as P, m as _, k as c, I as v } from "./index-CsFAoL0Y.mjs";
2
2
  import "react";
3
3
  export {
4
4
  e as ChromeLoader,
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(re,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],x):(re=typeof globalThis<"u"?globalThis:re||self,x(re.EdgeXComponents={},re.React,re.ReactDOM))})(this,function(re,x,je){"use strict";var uS=Object.defineProperty;var lS=(re,x,je)=>x in re?uS(re,x,{enumerable:!0,configurable:!0,writable:!0,value:je}):re[x]=je;var Go=(re,x,je)=>lS(re,typeof x!="symbol"?x+"":x,je);function Cu(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=Cu(x),Br=Cu(je);function Lm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mi={exports:{}},Lr={};/**
1
+ (function(re,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","react-dom"],x):(re=typeof globalThis<"u"?globalThis:re||self,x(re.EdgeXComponents={},re.React,re.ReactDOM))})(this,function(re,x,je){"use strict";var cS=Object.defineProperty;var uS=(re,x,je)=>x in re?cS(re,x,{enumerable:!0,configurable:!0,writable:!0,value:je}):re[x]=je;var Go=(re,x,je)=>uS(re,typeof x!="symbol"?x+"":x,je);function Cu(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const U=Cu(x),Br=Cu(je);function Lm(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mi={exports:{}},Lr={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -18,16 +18,16 @@
18
18
  `+Z+R}}var oe=!1,me;{var ge=typeof WeakMap=="function"?WeakMap:Map;me=new ge}function de(R,q){if(!R||oe)return"";{var Y=me.get(R);if(Y!==void 0)return Y}var te;oe=!0;var he=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var be;be=H.current,H.current=null,K();try{if(q){var ue=function(){throw Error()};if(Object.defineProperty(ue.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(ue,[])}catch(Xe){te=Xe}Reflect.construct(R,[],ue)}else{try{ue.call()}catch(Xe){te=Xe}R.call(ue.prototype)}}else{try{throw Error()}catch(Xe){te=Xe}R()}}catch(Xe){if(Xe&&te&&typeof Xe.stack=="string"){for(var ce=Xe.stack.split(`
19
19
  `),Re=te.stack.split(`
20
20
  `),Pe=ce.length-1,$e=Re.length-1;Pe>=1&&$e>=0&&ce[Pe]!==Re[$e];)$e--;for(;Pe>=1&&$e>=0;Pe--,$e--)if(ce[Pe]!==Re[$e]){if(Pe!==1||$e!==1)do if(Pe--,$e--,$e<0||ce[Pe]!==Re[$e]){var yt=`
21
- `+ce[Pe].replace(" at new "," at ");return R.displayName&&yt.includes("<anonymous>")&&(yt=yt.replace("<anonymous>",R.displayName)),typeof R=="function"&&me.set(R,yt),yt}while(Pe>=1&&$e>=0);break}}}finally{oe=!1,H.current=be,G(),Error.prepareStackTrace=he}var kr=R?R.displayName||R.name:"",Jn=kr?J(kr):"";return typeof R=="function"&&me.set(R,Jn),Jn}function se(R,q,Y){return de(R,!1)}function pe(R){var q=R.prototype;return!!(q&&q.isReactComponent)}function ee(R,q,Y){if(R==null)return"";if(typeof R=="function")return de(R,pe(R));if(typeof R=="string")return J(R);switch(R){case u:return J("Suspense");case l:return J("SuspenseList")}if(typeof R=="object")switch(R.$$typeof){case a:return se(R.render);case f:return ee(R.type,q,Y);case p:{var te=R,he=te._payload,be=te._init;try{return ee(be(he),q,Y)}catch{}}}return""}var Se=Object.prototype.hasOwnProperty,Nn={},gt=$.ReactDebugCurrentFrame;function hi(R){if(R){var q=R._owner,Y=ee(R.type,R._source,q?q.type:null);gt.setExtraStackFrame(Y)}else gt.setExtraStackFrame(null)}function U4(R,q,Y,te,he){{var be=Function.call.bind(Se);for(var ue in R)if(be(R,ue)){var ce=void 0;try{if(typeof R[ue]!="function"){var Re=Error((te||"React class")+": "+Y+" type `"+ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof R[ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Re.name="Invariant Violation",Re}ce=R[ue](q,ue,te,Y,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Pe){ce=Pe}ce&&!(ce instanceof Error)&&(hi(he),E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",te||"React class",Y,ue,typeof ce),hi(null)),ce instanceof Error&&!(ce.message in Nn)&&(Nn[ce.message]=!0,hi(he),E("Failed %s type: %s",Y,ce.message),hi(null))}}}var z4=Array.isArray;function Su(R){return z4(R)}function H4(R){{var q=typeof Symbol=="function"&&Symbol.toStringTag,Y=q&&R[Symbol.toStringTag]||R.constructor.name||"Object";return Y}}function W4(R){try{return Em(R),!1}catch{return!0}}function Em(R){return""+R}function Sm(R){if(W4(R))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",H4(R)),Em(R)}var Pm=$.ReactCurrentOwner,V4={key:!0,ref:!0,__self:!0,__source:!0},$m,Tm;function G4(R){if(Se.call(R,"ref")){var q=Object.getOwnPropertyDescriptor(R,"ref").get;if(q&&q.isReactWarning)return!1}return R.ref!==void 0}function q4(R){if(Se.call(R,"key")){var q=Object.getOwnPropertyDescriptor(R,"key").get;if(q&&q.isReactWarning)return!1}return R.key!==void 0}function Z4(R,q){typeof R.ref=="string"&&Pm.current}function Y4(R,q){{var Y=function(){$m||($m=!0,E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};Y.isReactWarning=!0,Object.defineProperty(R,"key",{get:Y,configurable:!0})}}function K4(R,q){{var Y=function(){Tm||(Tm=!0,E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};Y.isReactWarning=!0,Object.defineProperty(R,"ref",{get:Y,configurable:!0})}}var X4=function(R,q,Y,te,he,be,ue){var ce={$$typeof:t,type:R,key:q,ref:Y,props:ue,_owner:be};return ce._store={},Object.defineProperty(ce._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ce,"_self",{configurable:!1,enumerable:!1,writable:!1,value:te}),Object.defineProperty(ce,"_source",{configurable:!1,enumerable:!1,writable:!1,value:he}),Object.freeze&&(Object.freeze(ce.props),Object.freeze(ce)),ce};function Q4(R,q,Y,te,he){{var be,ue={},ce=null,Re=null;Y!==void 0&&(Sm(Y),ce=""+Y),q4(q)&&(Sm(q.key),ce=""+q.key),G4(q)&&(Re=q.ref,Z4(q,he));for(be in q)Se.call(q,be)&&!V4.hasOwnProperty(be)&&(ue[be]=q[be]);if(R&&R.defaultProps){var Pe=R.defaultProps;for(be in Pe)ue[be]===void 0&&(ue[be]=Pe[be])}if(ce||Re){var $e=typeof R=="function"?R.displayName||R.name||"Unknown":R;ce&&Y4(ue,$e),Re&&K4(ue,$e)}return X4(R,ce,Re,he,te,Pm.current,ue)}}var Pu=$.ReactCurrentOwner,Am=$.ReactDebugCurrentFrame;function Mr(R){if(R){var q=R._owner,Y=ee(R.type,R._source,q?q.type:null);Am.setExtraStackFrame(Y)}else Am.setExtraStackFrame(null)}var $u;$u=!1;function Tu(R){return typeof R=="object"&&R!==null&&R.$$typeof===t}function Om(){{if(Pu.current){var R=I(Pu.current.type);if(R)return`
21
+ `+ce[Pe].replace(" at new "," at ");return R.displayName&&yt.includes("<anonymous>")&&(yt=yt.replace("<anonymous>",R.displayName)),typeof R=="function"&&me.set(R,yt),yt}while(Pe>=1&&$e>=0);break}}}finally{oe=!1,H.current=be,G(),Error.prepareStackTrace=he}var kr=R?R.displayName||R.name:"",Jn=kr?J(kr):"";return typeof R=="function"&&me.set(R,Jn),Jn}function se(R,q,Y){return de(R,!1)}function pe(R){var q=R.prototype;return!!(q&&q.isReactComponent)}function ee(R,q,Y){if(R==null)return"";if(typeof R=="function")return de(R,pe(R));if(typeof R=="string")return J(R);switch(R){case u:return J("Suspense");case l:return J("SuspenseList")}if(typeof R=="object")switch(R.$$typeof){case a:return se(R.render);case f:return ee(R.type,q,Y);case p:{var te=R,he=te._payload,be=te._init;try{return ee(be(he),q,Y)}catch{}}}return""}var Se=Object.prototype.hasOwnProperty,Nn={},gt=$.ReactDebugCurrentFrame;function hi(R){if(R){var q=R._owner,Y=ee(R.type,R._source,q?q.type:null);gt.setExtraStackFrame(Y)}else gt.setExtraStackFrame(null)}function _4(R,q,Y,te,he){{var be=Function.call.bind(Se);for(var ue in R)if(be(R,ue)){var ce=void 0;try{if(typeof R[ue]!="function"){var Re=Error((te||"React class")+": "+Y+" type `"+ue+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof R[ue]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Re.name="Invariant Violation",Re}ce=R[ue](q,ue,te,Y,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Pe){ce=Pe}ce&&!(ce instanceof Error)&&(hi(he),E("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",te||"React class",Y,ue,typeof ce),hi(null)),ce instanceof Error&&!(ce.message in Nn)&&(Nn[ce.message]=!0,hi(he),E("Failed %s type: %s",Y,ce.message),hi(null))}}}var U4=Array.isArray;function Su(R){return U4(R)}function z4(R){{var q=typeof Symbol=="function"&&Symbol.toStringTag,Y=q&&R[Symbol.toStringTag]||R.constructor.name||"Object";return Y}}function H4(R){try{return Em(R),!1}catch{return!0}}function Em(R){return""+R}function Sm(R){if(H4(R))return E("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",z4(R)),Em(R)}var Pm=$.ReactCurrentOwner,W4={key:!0,ref:!0,__self:!0,__source:!0},$m,Tm;function V4(R){if(Se.call(R,"ref")){var q=Object.getOwnPropertyDescriptor(R,"ref").get;if(q&&q.isReactWarning)return!1}return R.ref!==void 0}function G4(R){if(Se.call(R,"key")){var q=Object.getOwnPropertyDescriptor(R,"key").get;if(q&&q.isReactWarning)return!1}return R.key!==void 0}function q4(R,q){typeof R.ref=="string"&&Pm.current}function Z4(R,q){{var Y=function(){$m||($m=!0,E("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};Y.isReactWarning=!0,Object.defineProperty(R,"key",{get:Y,configurable:!0})}}function Y4(R,q){{var Y=function(){Tm||(Tm=!0,E("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",q))};Y.isReactWarning=!0,Object.defineProperty(R,"ref",{get:Y,configurable:!0})}}var K4=function(R,q,Y,te,he,be,ue){var ce={$$typeof:t,type:R,key:q,ref:Y,props:ue,_owner:be};return ce._store={},Object.defineProperty(ce._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(ce,"_self",{configurable:!1,enumerable:!1,writable:!1,value:te}),Object.defineProperty(ce,"_source",{configurable:!1,enumerable:!1,writable:!1,value:he}),Object.freeze&&(Object.freeze(ce.props),Object.freeze(ce)),ce};function X4(R,q,Y,te,he){{var be,ue={},ce=null,Re=null;Y!==void 0&&(Sm(Y),ce=""+Y),G4(q)&&(Sm(q.key),ce=""+q.key),V4(q)&&(Re=q.ref,q4(q,he));for(be in q)Se.call(q,be)&&!W4.hasOwnProperty(be)&&(ue[be]=q[be]);if(R&&R.defaultProps){var Pe=R.defaultProps;for(be in Pe)ue[be]===void 0&&(ue[be]=Pe[be])}if(ce||Re){var $e=typeof R=="function"?R.displayName||R.name||"Unknown":R;ce&&Z4(ue,$e),Re&&Y4(ue,$e)}return K4(R,ce,Re,he,te,Pm.current,ue)}}var Pu=$.ReactCurrentOwner,Am=$.ReactDebugCurrentFrame;function Mr(R){if(R){var q=R._owner,Y=ee(R.type,R._source,q?q.type:null);Am.setExtraStackFrame(Y)}else Am.setExtraStackFrame(null)}var $u;$u=!1;function Tu(R){return typeof R=="object"&&R!==null&&R.$$typeof===t}function Om(){{if(Pu.current){var R=I(Pu.current.type);if(R)return`
22
22
 
23
- Check the render method of \``+R+"`."}return""}}function J4(R){return""}var Nm={};function eS(R){{var q=Om();if(!q){var Y=typeof R=="string"?R:R.displayName||R.name;Y&&(q=`
23
+ Check the render method of \``+R+"`."}return""}}function Q4(R){return""}var Nm={};function J4(R){{var q=Om();if(!q){var Y=typeof R=="string"?R:R.displayName||R.name;Y&&(q=`
24
24
 
25
- Check the top-level render call using <`+Y+">.")}return q}}function Cm(R,q){{if(!R._store||R._store.validated||R.key!=null)return;R._store.validated=!0;var Y=eS(q);if(Nm[Y])return;Nm[Y]=!0;var te="";R&&R._owner&&R._owner!==Pu.current&&(te=" It was passed a child from "+I(R._owner.type)+"."),Mr(R),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Y,te),Mr(null)}}function Im(R,q){{if(typeof R!="object")return;if(Su(R))for(var Y=0;Y<R.length;Y++){var te=R[Y];Tu(te)&&Cm(te,q)}else if(Tu(R))R._store&&(R._store.validated=!0);else if(R){var he=w(R);if(typeof he=="function"&&he!==R.entries)for(var be=he.call(R),ue;!(ue=be.next()).done;)Tu(ue.value)&&Cm(ue.value,q)}}}function tS(R){{var q=R.type;if(q==null||typeof q=="string")return;var Y;if(typeof q=="function")Y=q.propTypes;else if(typeof q=="object"&&(q.$$typeof===a||q.$$typeof===f))Y=q.propTypes;else return;if(Y){var te=I(q);U4(Y,R.props,"prop",te,R)}else if(q.PropTypes!==void 0&&!$u){$u=!0;var he=I(q);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",he||"Unknown")}typeof q.getDefaultProps=="function"&&!q.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function nS(R){{for(var q=Object.keys(R.props),Y=0;Y<q.length;Y++){var te=q[Y];if(te!=="children"&&te!=="key"){Mr(R),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",te),Mr(null);break}}R.ref!==null&&(Mr(R),E("Invalid attribute `ref` supplied to `React.Fragment`."),Mr(null))}}var Mm={};function km(R,q,Y,te,he,be){{var ue=v(R);if(!ue){var ce="";(R===void 0||typeof R=="object"&&R!==null&&Object.keys(R).length===0)&&(ce+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Re=J4();Re?ce+=Re:ce+=Om();var Pe;R===null?Pe="null":Su(R)?Pe="array":R!==void 0&&R.$$typeof===t?(Pe="<"+(I(R.type)||"Unknown")+" />",ce=" Did you accidentally export a JSX literal instead of a component?"):Pe=typeof R,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Pe,ce)}var $e=Q4(R,q,Y,he,be);if($e==null)return $e;if(ue){var yt=q.children;if(yt!==void 0)if(te)if(Su(yt)){for(var kr=0;kr<yt.length;kr++)Im(yt[kr],R);Object.freeze&&Object.freeze(yt)}else E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Im(yt,R)}if(Se.call(q,"key")){var Jn=I(R),Xe=Object.keys(q).filter(function(cS){return cS!=="key"}),Au=Xe.length>0?"{key: someKey, "+Xe.join(": ..., ")+": ...}":"{key: someKey}";if(!Mm[Jn+Au]){var aS=Xe.length>0?"{"+Xe.join(": ..., ")+": ...}":"{}";E(`A props object containing a "key" prop is being spread into JSX:
25
+ Check the top-level render call using <`+Y+">.")}return q}}function Cm(R,q){{if(!R._store||R._store.validated||R.key!=null)return;R._store.validated=!0;var Y=J4(q);if(Nm[Y])return;Nm[Y]=!0;var te="";R&&R._owner&&R._owner!==Pu.current&&(te=" It was passed a child from "+I(R._owner.type)+"."),Mr(R),E('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',Y,te),Mr(null)}}function Im(R,q){{if(typeof R!="object")return;if(Su(R))for(var Y=0;Y<R.length;Y++){var te=R[Y];Tu(te)&&Cm(te,q)}else if(Tu(R))R._store&&(R._store.validated=!0);else if(R){var he=w(R);if(typeof he=="function"&&he!==R.entries)for(var be=he.call(R),ue;!(ue=be.next()).done;)Tu(ue.value)&&Cm(ue.value,q)}}}function eS(R){{var q=R.type;if(q==null||typeof q=="string")return;var Y;if(typeof q=="function")Y=q.propTypes;else if(typeof q=="object"&&(q.$$typeof===a||q.$$typeof===f))Y=q.propTypes;else return;if(Y){var te=I(q);_4(Y,R.props,"prop",te,R)}else if(q.PropTypes!==void 0&&!$u){$u=!0;var he=I(q);E("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",he||"Unknown")}typeof q.getDefaultProps=="function"&&!q.getDefaultProps.isReactClassApproved&&E("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function tS(R){{for(var q=Object.keys(R.props),Y=0;Y<q.length;Y++){var te=q[Y];if(te!=="children"&&te!=="key"){Mr(R),E("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",te),Mr(null);break}}R.ref!==null&&(Mr(R),E("Invalid attribute `ref` supplied to `React.Fragment`."),Mr(null))}}var Mm={};function km(R,q,Y,te,he,be){{var ue=v(R);if(!ue){var ce="";(R===void 0||typeof R=="object"&&R!==null&&Object.keys(R).length===0)&&(ce+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Re=Q4();Re?ce+=Re:ce+=Om();var Pe;R===null?Pe="null":Su(R)?Pe="array":R!==void 0&&R.$$typeof===t?(Pe="<"+(I(R.type)||"Unknown")+" />",ce=" Did you accidentally export a JSX literal instead of a component?"):Pe=typeof R,E("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Pe,ce)}var $e=X4(R,q,Y,he,be);if($e==null)return $e;if(ue){var yt=q.children;if(yt!==void 0)if(te)if(Su(yt)){for(var kr=0;kr<yt.length;kr++)Im(yt[kr],R);Object.freeze&&Object.freeze(yt)}else E("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Im(yt,R)}if(Se.call(q,"key")){var Jn=I(R),Xe=Object.keys(q).filter(function(aS){return aS!=="key"}),Au=Xe.length>0?"{key: someKey, "+Xe.join(": ..., ")+": ...}":"{key: someKey}";if(!Mm[Jn+Au]){var iS=Xe.length>0?"{"+Xe.join(": ..., ")+": ...}":"{}";E(`A props object containing a "key" prop is being spread into JSX:
26
26
  let props = %s;
27
27
  <%s {...props} />
28
28
  React keys must be passed directly to JSX without using spread:
29
29
  let props = %s;
30
- <%s key={someKey} {...props} />`,Au,Jn,aS,Jn),Mm[Jn+Au]=!0}}return R===r?nS($e):tS($e),$e}}function rS(R,q,Y){return km(R,q,Y,!0)}function oS(R,q,Y){return km(R,q,Y,!1)}var sS=oS,iS=rS;Fr.Fragment=r,Fr.jsx=sS,Fr.jsxs=iS}()),Fr}process.env.NODE_ENV==="production"?mi.exports=Fm():mi.exports=Dm();var k=mi.exports;const Rm={deposit:{title:"充值",chain:"链",asset:"资产",amount:"数量",available:"可用",equity:"总资产",confirmDeposit:"充值确认",switchNetwork:"切换网络",max:"最大",arrivalTime:"到账时间",ethCrossChainDepositInitiated:"ETH 跨链充值已发起,预计 2–5 分钟到账。",minDeposit:"最小充值金额",minDepositParsed:"最少充值 {{amount}} {{token}}",maxDeposit:"最大充值金额",depositTipFor25w:"单笔充值金额上限为 200,000。若充值金额大于200,000,请使用Ethereum链充值。",depositAllTip:`仅支持发送 {{coin}} ({{v}}) 资产到此地址。
30
+ <%s key={someKey} {...props} />`,Au,Jn,iS,Jn),Mm[Jn+Au]=!0}}return R===r?tS($e):eS($e),$e}}function nS(R,q,Y){return km(R,q,Y,!0)}function rS(R,q,Y){return km(R,q,Y,!1)}var oS=rS,sS=nS;Fr.Fragment=r,Fr.jsx=oS,Fr.jsxs=sS}()),Fr}process.env.NODE_ENV==="production"?mi.exports=Fm():mi.exports=Dm();var k=mi.exports;const Rm={deposit:{title:"充值",chain:"链",asset:"资产",amount:"数量",available:"可用",equity:"总资产",confirmDeposit:"充值确认",switchNetwork:"切换网络",max:"最大",arrivalTime:"到账时间",ethCrossChainDepositInitiated:"ETH 跨链充值已发起,预计 2–5 分钟到账。",minDeposit:"最小充值金额",minDepositParsed:"最少充值 {{amount}} {{token}}",maxDeposit:"最大充值金额",depositTipFor25w:"单笔充值金额上限为 200,000。若充值金额大于200,000,请使用Ethereum链充值。",depositAllTip:`仅支持发送 {{coin}} ({{v}}) 资产到此地址。
31
31
  充值金额大于 200,000 时,到账时间存在一定延迟,请耐心等待。`,maxDepositSplitTip:"单笔充值金额上限为200,000。若需要充值金额大于200,000,请分多笔进行操作。",spotDepositNotSupportedTip:"不支持充值,请先充入合约账户再划转。",crossChainDepositFeeTip:`仅支持发送 {{coin}} ({{v}}) 资产到此地址。
32
32
  跨链充值需由您承担 Edge 网络手续费。到账金额会略小于您的充值金额。`,addressUpdatedNotice:"注意:充值地址已更新,请改用新地址。原地址仅在过渡期可用,随后停用。若旧地址已存于其他平台,请尽快更新。",enableSystemProWithToken:"在{{network}}上启用{{token}}",enableTokenDesc:"您首次在{{network}}上存款时必须启用{{token}}。",enableWithToken:"启用 {{token}}",arrivaltimeTooltip1:"资金约在 {{v}} 分钟 内 (达到 {{v1}} 个区块确认后) 到账。",arrivaltimeTooltip2:"预计时间是根据历史数据计算所得,仅供参考。网络拥堵可能会导致实际到账时间变长。",arrivalEstimated:"≈ {{v}}分钟",availableDesc:"您可以充值的最大金额。当可用为0或负数时,无法进行充值。",noPrivateKeyWalletWarning:"请勿使用无私钥钱包进行充值,无私钥钱包充值会导致资金损失且无法追回。",layerZeroDepositTip:"系统会根据充值资金实际情况,将您的充值通过LayerZero完成。",layerZeroDepositTipExceedPool:"由于充值资金大于资金池,将通过LayerZero完成您的充值。",layerZeroDepositTipGte200k:"由于充值资金大于等于200,000 USDT,将通过LayerZero完成您的充值。",layerZeroDepositButton:"使用LayerZero充值",defaultSpotNotice:"默认充值至现货账户",defaultSpotToPerpNotice:"仅支持发送 {{coin}} ({{v}}) 资产到此地址。默认充值至现货账户。若需充入合约账户,请从现货账户划转至合约账户。"},withdraw:{noticeDesc:"普通提现是一个两步过程。 此步骤将发起您的提现请求,并将在 Layer2 进行处理。 一旦资金准备就绪(可能需要最多 4 小时),您将收到一条将资金提现到钱包的通知。受链同步等情况影响下,时长可能到 48 小时。您需要自行承担交易 gas 费用。",crossChainTips:"跨链提币需在 L2(通过零知识证明)进行验证。提币过程最多约需2小时。相关链的资产池中需有充足的资金来处理跨链提币,其间还将产生矿工费。 edgeX 将收取一定的手续费作为矿工费。",commonWithdraw:"提现说明",withdraw:"提现",speed:"速度",confirmWithdraw:"提现确认",speedNote:"处理时间:",speedNoteSpeed1:"用时约8分钟",speedNoteSpeed2:"用时约 2-4 小时",speedNoteSpeed3:"用时约4小时",receiverAddress:"接收地址",fee:"手续费",feeRate:"费率",withdrawlAmount:"提现金额",amountToReceive:"到账金额",minWithdraw:"最小提现金额",minWithdrawParsed:"最小提现 {{amount}} {{token}}",invalidReceiverAddress:"接收地址不能为空",availableDesc:"您可以提现的最大金额。当可用为0或负数时,无法进行提现。",feeCalculationTip:"提现手续费按照提现金额乘以费率计算,最低为1 USDT/USDC。费率会根据链上实际情况进行调整。",crossChainPoolBalance:"跨链资金池余额",poolBalance:"资金池余额",poolBalanceInsufficientTip:"提现金额大于资金池余额,无法进行提现。请选择资金池余额充足的选项。"},account:{title:"账户",perpetual:"合约账户",spot:"现货账户"}},jm={deposit:{title:"Deposit",chain:"Chain",asset:"Asset",amount:"Amount",available:"Available",equity:"Equity",confirmDeposit:"Confirm Deposit",switchNetwork:"Switch Network",max:"Max",arrivalTime:"Arrival Time",ethCrossChainDepositInitiated:"ETH cross-chain deposit initiated. Estimated arrival in 2–5 minutes.",minDeposit:"Minimum Deposit Amount",minDepositParsed:"Min. Deposit {{amount}} {{token}}",maxDeposit:"Maximum Deposit Amount",depositTipFor25w:"The maximum amount per deposit is 200,000. If your deposit exceeds 200,000, please use the Ethereum chain.",depositAllTip:`Only {{coin}} ({{v}}) is supported for deposits to this address.
33
33
  If the deposit amount exceeds 200,000, there may be a delay in the arrival time. Please be patient.`,maxDepositSplitTip:"The maximum amount per deposit is 200,000. If you need to deposit more than 200,000, please split it into multiple deposits.",spotDepositNotSupportedTip:"Deposits aren't supported. Please deposit to perpetual account, then transfer.",crossChainDepositFeeTip:`Only {{coin}} ({{v}}) is supported for deposits to this address.
@@ -175,5 +175,5 @@ ${dg(d)}`),super(t.shortMessage,{cause:t,docsPath:r,metaMessages:[...t.metaMessa
175
175
  ${c}
176
176
  ${s}
177
177
  `,children:[t,o&&k.jsx(am,{ref:f,placement:h.placement||n})]})})]})},Wo="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAABYlAAAWJQFJUiTwAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAIcSURBVHgBxZc/T8JAGMafA4mDEXFw0DiQmDi4CP5JHGFx0qizg8QvIHwCZHYAvwEm7mji5CJuJv7DxcWYYMLmIEYXY/R8j6tQaBvuaCm/pOlbSu99+rZ97zlgwDBowvNLCdrF6NJ50891OvNC+wrL3JShgZIAnl+JAj97FKXoMNLl7ySGnQDBHMtcVeFGAM8nKNlnlsI0eoIVuwlhzsmXqcwoURSFK1iVRCSdRDDn5PwC3cutingsJOK60nkiYE0unrdi8uFRIDwFBSJiTKOqzgKMl00teXgS2D0Fto+BiVkoIMYs8Xws4iiAkmeVn/n0oqyA2NQEQI4dytoKMEqfQt/haZmrQ4C8e7/4TtsI4JvwDbYDswCjvXr1yakQMXI2KxCD/8RMAtx2ux5gcjIzBAT8LH8bAQwYbwR8fUAb/vtuEsAr0OX5Eng8o30ZqN1BHzFLAkPGkb4AcdfnObigkbM5HdN3+Qb/ekGdrNu4CMyd8Ag6iElo/QBYzcpYByYsm8QkIFSADmI2nEkAc2sUL0ALHsxZBEjLxA+hSu22tb0+KV9Gd18027M2SybNQui+f53R6g/b+gDLVMi7YQsND+c5dTtzamlE0jiyJLwVYZhSqzO27YRSxFD8v1m4Q4xh74gdBUgRQm2QKsH0Ps82xEs9EndK3sgDlWGkW96naANqSzMSHSy4XprZi2kuTqN09VjrBH9AD4vTgfMHJt+rxIFF7EgAAAAASUVORK5CYII=",x4=({currentActiveChain:e,selectedToken:t,address:n,accountType:r,onDeposit:o,onCopy:s,onClose:i})=>{const{t:c}=vt(),a=r===p5,u=x.useMemo(()=>{if(!e)return!1;const h=Number(e.chainId);return!Number.isNaN(h)&&(h===42161||h===421614)},[e]),l=a,f=x.useMemo(()=>{var h;return(h=e==null?void 0:e.tokenList)==null?void 0:h.find(m=>m.token===t||m.symbol===t)},[e,t]),p=x.useMemo(()=>{const h=(t||"").toUpperCase();if(!l&&h==="USDC")return c("deposit.defaultSpotToPerpNotice",{coin:t,v:e==null?void 0:e.chain});const $=c(l?"deposit.crossChainDepositFeeTip":"deposit.depositAllTip",{coin:t,v:e==null?void 0:e.chain});return l&&(!u||h==="USDC")?String($).split(`
178
- `)[0]:$},[c,t,e==null?void 0:e.chain,l,u]),d=(f==null?void 0:f.minDepositSize)||"10";return k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"flex justify-center mt-4 mb-3",children:n&&k.jsx("div",{className:"bg-white rounded-lg",children:k.jsx(zh,{value:n,size:120,level:"L",bgColor:"#ffffff",fgColor:"#000000",marginSize:0})})}),n&&k.jsxs("div",{className:"flex items-center justify-between bg-fill-input-primary rounded-lg py-2 px-3 mb-3",children:[k.jsx("span",{className:"flex-1 text-text-primary text-sm font-medium break-all mr-3",children:n}),k.jsx(T3,{onCopy:()=>{s&&s(n)},text:n,children:k.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[k.jsx("rect",{x:"2.08496",y:"4.02295",width:"9.89893",height:"9.89893",rx:"2",stroke:"#F9F9F9"}),k.jsx("path",{d:"M5.85547 2.07861H11.415C12.7957 2.07861 13.915 3.1979 13.915 4.57861V10.0786",stroke:"#F9F9F9",strokeLinecap:"round"})]})},"copy")]}),k.jsxs("div",{className:"border-b border-dashed border-line-divider-secondary pb-4",children:[k.jsxs("div",{className:"flex items-start",children:[k.jsx("div",{className:"w-5",children:k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1",children:k.jsx("p",{className:"text-xs text-functional-orange-1",children:p})})]}),r===a0&&k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"my-2 ml-5 h-[1px] border-b border-dashed border-line-divider-secondary"}),k.jsx("div",{className:"flex items-start pl-5 text-functional-orange-1 text-xs",children:c("deposit.addressUpdatedNotice")})]})]}),k.jsxs("div",{className:"text-sm",children:[(a||t.toUpperCase()!=="USDC")&&k.jsxs("div",{className:"flex justify-between items-center h-[18px] mt-4",children:[k.jsx("span",{className:"text-text-tertiary",children:c("deposit.arrivalTime")}),k.jsx(Qn,{content:k.jsxs("div",{className:"grid flex-grow max-w-[300px] min-w-[80px] rounded-2xl flex-col gap-[10px]",children:[k.jsx("p",{children:c("deposit.arrivaltimeTooltip1",{v:(e==null?void 0:e.blockTime)*e.txConfirm/60,v1:e==null?void 0:e.txConfirm})}),k.jsx("p",{children:c("deposit.arrivaltimeTooltip2")})]}),placement:"top",children:k.jsx("span",{className:"text-text-primary font-medium text-right border-b-[2px] border-dashed border-line-divider-primary decoration-dashed",children:c("deposit.arrivalEstimated",{v:(e==null?void 0:e.blockTime)*e.txConfirm/60})})})]}),k.jsxs("div",{className:`flex justify-between items-center h-[18px] ${a||t.toUpperCase()!=="USDC"?"mt-1":"mt-4"}`,children:[k.jsx("span",{className:"text-text-tertiary",children:c("deposit.minDeposit")}),k.jsxs("span",{className:"text-text-primary font-medium text-right",children:[d," ",t]})]}),r===a0&&t.toUpperCase()!=="USDC"&&k.jsxs("div",{className:"flex justify-between items-center h-[18px] mt-1",children:[k.jsx("span",{className:"text-text-tertiary",children:c("deposit.maxDeposit")}),k.jsxs("span",{className:"text-text-primary font-medium text-right",children:["200,000 ",t]})]})]}),k.jsx("button",{className:"w-full h-[38px] bg-fill-btn-primary rounded-xl text-sm font-medium text-text-on-sec-btn mt-4",onClick:()=>{o&&o({amount:"",chainId:e.chainId,tokenAddress:n,tokenSymbol:t}),i()},children:c("deposit.title")})]})},Vo=({size:e="xs",color:t,className:n="",label:r="Loading...",inline:o=!1})=>{const s=t?`loading-${t}`:"",i=o?"loading-inline":"";return k.jsx("span",{className:`loading loading-${e} loading-spinner ${s} ${i} ${n}`.trim(),"aria-label":r,role:"status","aria-live":"polite"})},E4=(e,t)=>Number(e)>Number(t),Mt=e=>{if(!e||e===""||isNaN(Number(e)))return"0.00";const t=Number(e);if(t===0)return"0.00";let n=t.toString();n.includes("e")&&(n=t.toFixed(20));const r=n.split("."),o=r[0];let s=r[1]||"";return s.length>6&&(s=s.substring(0,6)),s=s.replace(/0+$/,""),s?(s.length===1&&(s+="0"),o+"."+s):o+".00"},fi=(e,t="0")=>{if(/[^0-9.]/.test(e))return{isValid:!1,formattedValue:"",errorType:"invalid_char"};if(e===".")return{isValid:!0,formattedValue:"0."};if((e.match(/\./g)||[]).length>1)return{isValid:!1,formattedValue:"",errorType:"invalid_char"};if(!e||e==="")return{isValid:!0,formattedValue:""};const o=e.split(".");if(o.length===2&&o[1].length>6){const a=o[0]+"."+o[1].substring(0,6);return fi(a,t)}const s=parseFloat(e),i=parseFloat(t);return!isNaN(s)&&!isNaN(i)&&s>i?{isValid:!0,formattedValue:Mt(t),errorType:"auto_adjusted_to_max"}:{isValid:!0,formattedValue:e}},S4=(e,t,n)=>{const r=parseFloat(String(e)||"0"),o=parseFloat(String(t)||"0");if(o>0){const s=r-o,i=Mt(Math.max(0,s).toString());return k.jsxs("span",{className:"flex items-center gap-1",children:[Mt(e),k.jsx("span",{className:"text-sm font-edgex-harmony text-functional-green-1 leading-[18px] font-medium",children:"→"}),i," ",n]})}return`${Mt(e)} ${n}`},P4=(e,t,n)=>{if(!e||e===""||e==="0"||e==="0.00")return!1;const r=parseFloat(e),o=parseFloat(t);return!(isNaN(r)||isNaN(o)||r>o||!n)},$4=(e,t,n)=>{if(!xh(e,n))return!1;try{const r=new Ie(t||"0"),o=new Ie("200000");return r.isNaN()||o.isNaN()?!1:r.gte(o)}catch{return!1}},T4=(e,t,n,r)=>{let o=t||"0";if(!(r==="spot")&&xh(e,n))try{const i=new Ie(o),c=new Ie("200000");i.gt(c)&&(o="200000")}catch(i){console.warn("Error calculating max amount limit:",i)}try{const i=new Ie(o||"0");return console.log("bn:",i),console.log("bn:",i.isNaN()),i.isNaN()?o:i.decimalPlaces(6,Ie.ROUND_DOWN).toString()}catch{return o}},cm={chains:[],spotChains:[],currentActiveAccount:{wallet:"EVM",ethAddress:"",accountId:"",smartWalletAddress:""},defaultChainId:1,defaultAccountType:"perpetual",balances:{spot:{},perpetual:{}}};let Ye=null;const um=x.forwardRef((e,t)=>{const[n,r]=x.useState(!1),[o,s]=x.useState(!1),[i,c]=x.useState(cm),a=x.useCallback(h=>{c(h),r(!0)},[]),u=x.useCallback(h=>{c(m=>({...m,...h}))},[]),l=x.useCallback(()=>{r(!1),s(!1),i.onClose&&i.onClose()},[i.onClose]),f=x.useCallback(h=>{s(h)},[]),p=x.useCallback(()=>n,[n]),d=x.useCallback(()=>o,[o]);return x.useImperativeHandle(t,()=>({openDeposit:a,closeDeposit:l,updateDepositOptions:u,setDepositLoading:f,isOpen:p,isLoading:d}),[a,l,u,f,p,d]),x.useEffect(()=>(Ye={openDeposit:a,closeDeposit:l,updateDepositOptions:u,setDepositLoading:f,isOpen:p,isLoading:d},()=>{Ye=null}),[a,l,u,f,p,d]),n?k.jsx(mm,{isOpen:n,isLoading:o,onClose:l,currentActiveAccount:i.currentActiveAccount,chains:i.chains,spotChains:i.spotChains,defaultChainId:i.defaultChainId,defaultSymbol:i.defaultSymbol,defaultAccountType:i.defaultAccountType,balances:i.balances,wagmiHooks:i.wagmiHooks,onDeposit:i.onDeposit,onCopy:i.onCopy,onChainChange:h=>{var m;return(m=i.onChainChange)==null?void 0:m.call(i,h)},onTokenChange:h=>{var m;return(m=i.onTokenChange)==null?void 0:m.call(i,h)}}):null});um.displayName="DepositManager";const lm=e=>{if(!Ye){console.error("DepositManager not initialized. Make sure to render <DepositManager /> in your app.");return}Ye.openDeposit(e||cm)},fm=()=>{if(!Ye){console.error("DepositManager not initialized. Make sure to render <DepositManager /> in your app.");return}Ye.closeDeposit()},dm=e=>{Ye&&Ye.updateDepositOptions(e)},di=e=>{if(!Ye){console.error("DepositManager not initialized. Make sure to render <DepositManager /> in your app.");return}Ye.setDepositLoading(e)},A4=()=>Ye?Ye.isOpen():!1,pm=()=>Ye?Ye.isLoading():!1,O4=()=>({openDeposit:lm,closeDeposit:fm,updateDepositOptions:dm,setDepositLoading:di,isOpen:A4,isLoading:pm}),N4=e=>{const{t}=vt(),{isNetworkMismatch:n,depositAmount:r,approved:o,currentTokenBalance:s,selectedToken:i,showLayerZeroTip:c,minDeposit:a=10}=e;return x.useMemo(()=>{if(n)return{text:t("deposit.switchNetwork"),disabled:!0,isNetworkSwitch:!0};const u=parseFloat(r||"0"),l=a,f=P4(r,s||"0",o);return!r||u===0||!o?{text:t(c?"deposit.layerZeroDepositButton":"deposit.confirmDeposit"),disabled:!0,isNetworkSwitch:!1}:u<l?{text:t("deposit.minDepositParsed",{amount:l,token:i}),disabled:!0,isNetworkSwitch:!1}:{text:t(c?"deposit.layerZeroDepositButton":"deposit.confirmDeposit"),disabled:!f,isNetworkSwitch:!1}},[n,r,o,s,i,c,a,t])};function C4(e){const{account:t,accountChainId:n,targetChainId:r,tokenInfo:o,amount:s}=e,{useReadContract:i,useWriteContract:c,usePublicClient:a,useSwitchChain:u}=e.wagmiHooks,l=o==null?void 0:o.tokenAddress,f=(o==null?void 0:o.decimals)??18,p=o==null?void 0:o.contractAddress,d=!l||l.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",{switchChainAsync:h}=u(),{writeContractAsync:m}=c(),w=a(),$=i({address:l,abi:yr,functionName:"allowance",args:[mn(t||""),p],chainId:r,query:{enabled:!!(!d&&t&&r&&l&&p)}}),E=$!=null&&$.isSuccess?$.data:void 0,S=x.useMemo(()=>{if(d)return!0;if(!$.isSuccess||E===void 0||E===0n)return!1;try{const B=x6(String(Number(s||"0")||0),Number(f));return E>=B}catch{return!1}},[d,$.isSuccess,E,s,f]),N=x.useCallback(async()=>{try{if(r&&n&&+n!=+r&&await h({chainId:+r}),!m||!w||!l||!p)return;const F=mn(l),D=mn(p);if((E||0n)>0n){const v=await m({abi:yr,address:F,functionName:"approve",args:[D,0n]});await w.waitForTransactionReceipt({hash:v})}const g=await m({abi:yr,address:F,functionName:"approve",args:[D,ef]});await w.waitForTransactionReceipt({hash:g}),$!=null&&$.refetch&&await $.refetch()}catch(B){console.error("[useApprove] onApprove failed:",B)}},[r,n,l,p,E,$,m,w,h]);return{approve:S,onApprove:N}}const I4=({token:e,account:t,chainId:n,wagmiHooks:r,onResult:o})=>{var i;const s=(i=r==null?void 0:r.useBalance)==null?void 0:i.call(r,{address:t,token:e.tokenAddress,chainId:n,query:{enabled:!!t&&!!n&&!!e.tokenAddress&&!!(r!=null&&r.useBalance)}});return x.useEffect(()=>{o(mn(e.tokenAddress),{balance:s})},[s,e.tokenAddress,o]),null},M4=({account:e,chainId:t,contractAddress:n,tokens:r=[],wagmiHooks:o})=>{var E;const s=typeof t=="string"?Number.isFinite(Number(t))?Number(t):void 0:t,i=x.useMemo(()=>{const S="0x0000000000000000000000000000000000000000",N="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";return r.filter(B=>{const F=B.tokenAddress;if(!F)return!1;const D=F.toLowerCase();return!(F===S||D===N)})},[r]),[c,a]=x.useState({}),u=x.useCallback((S,N)=>{a(B=>({...B,[S]:N}))},[]),l=(E=o==null?void 0:o.useBalance)==null?void 0:E.call(o,{address:e,chainId:s,query:{enabled:!!e&&!!s&&!!(o!=null&&o.useBalance)}}),[f,p]=x.useState(0),d=x.useMemo(()=>i.map(S=>x.createElement(I4,{key:`${S.tokenAddress}-${f}`,token:S,account:e,chainId:s,contractAddress:n,wagmiHooks:o,onResult:u})),[i,e,s,n,o,u,f]),h=x.useMemo(()=>{const S=l!=null&&l.data?{value:l.data.value,formatted:l.data.formatted,decimals:l.data.decimals,symbol:l.data.symbol}:{value:BigInt(0),formatted:"0",decimals:18,symbol:"ETH"},N=i.map(F=>{const D=c[mn(F.tokenAddress)],b=D==null?void 0:D.balance,g=b==null?void 0:b.data;return{address:mn(F.tokenAddress),value:(g==null?void 0:g.value)||BigInt(0),formatted:(g==null?void 0:g.formatted)||"0",decimals:(g==null?void 0:g.decimals)||F.decimals}}).filter(F=>F.address),B=N.reduce((F,D)=>({...F,[D.address]:{balance:D}}),{});return{balanceList:N,baseTokenBalance:S,combinedData:B}},[l,c,i]),m=x.useCallback(async()=>h,[h]),w=x.useMemo(()=>{const S=(l==null?void 0:l.isLoading)||!1,N=Object.values(c).some(B=>{var F;return(F=B.balance)==null?void 0:F.isLoading});return S||N},[l==null?void 0:l.isLoading,c]),$=x.useCallback(()=>p(S=>S+1),[]);return{multicallRun:m,multicallRefresh:$,multicallResult:h,validErcTokens:i,isLoading:w,queryComponents:d}},k4=({address:e,currentActiveChain:t,selectedToken:n,accountType:r,platformBalance:o,isLoading:s,wagmiHooks:i,onChainChange:c,onDeposit:a})=>{const{t:u}=vt(),l=i.useAccount(),f=t.tokenList.find(_=>_.token===n||_.symbol===n),p=t.chainId,[d,h]=x.useState("");x.useEffect(()=>{h("")},[n,t.chainId]);const{multicallResult:m,queryComponents:w}=M4({account:e,chainId:t.chainId,contractAddress:(f==null?void 0:f.contractAddress)||(t==null?void 0:t.contractAddress),tokens:(t==null?void 0:t.tokenList)||[],wagmiHooks:i}),$=x.useMemo(()=>{var W;if(!f)return"0";if(!f.tokenAddress||f.tokenAddress.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")return m.baseTokenBalance.formatted;const _=m.combinedData[f.tokenAddress];return((W=_==null?void 0:_.balance)==null?void 0:W.formatted)||"0"},[f,m]),E="0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",S="0xceeed84620e5eb9ab1d6dfc316867d2cda332e41",N=x.useMemo(()=>{var _,W;return s5({chain:u5,transport:c5(t.rpcUrl||((_=window==null?void 0:window.ENV)==null?void 0:_.CHAIN_RPC_URL_42161)||((W=window==null?void 0:window.ENV)==null?void 0:W.CHAIN_RPC_URL_421614))})},[t.rpcUrl]),B="1000000000000",{formatted:F}=l5({client:N,tokenAddress:E,holder:S,decimals:6,fallbackFormatted:B,pollingInterval:12e3}),[D,b]=x.useState(!1),{approve:g,onApprove:v}=C4({account:e,accountChainId:l.chainId,targetChainId:+t.chainId,tokenInfo:f,amount:d,wagmiHooks:i}),C=x.useCallback(async()=>{if(!D)try{b(!0),await v()}catch(_){console.error("Approve failed:",_)}finally{b(!1)}},[D,v]),O=x.useMemo(()=>+l.chainId!=+t.chainId,[l.chainId,t.chainId]),I=x.useCallback(async()=>{c&&c(p)},[c,p]);x.useEffect(()=>{O&&I()},[O,I]);const{showLayerZeroTip:M,layerZeroTipKey:y}=x.useMemo(()=>{const _=+t.chainId==42161||+t.chainId==421614,W=(n==null?void 0:n.toUpperCase())==="USDT",K=new Ie(d||"0"),G=new Ie("200000");let H=!1,Z;if(_&&W&&d)if(K.gte(G))H=!0,Z="deposit.layerZeroDepositTipGte200k";else{const J=F;if(typeof J=="string"&&J.length>0){const me=new Ie(J);!me.isNaN()&&K.gte(me)&&(H=!0,Z="deposit.layerZeroDepositTipExceedPool")}}return{showLayerZeroTip:H,layerZeroTipKey:Z}},[t.chainId,n,d,F]),A=x.useCallback(()=>T4(+t.chainId,$||"0",n,r),[$,t==null?void 0:t.chainId,n,r]),T=x.useMemo(()=>r!=="spot"&&$4(+t.chainId,d,n),[r,t==null?void 0:t.chainId,d,n]),P=x.useMemo(()=>"deposit.maxDepositSplitTip",[]),L=N4({isNetworkMismatch:O,depositAmount:d,approved:g,currentTokenBalance:$,selectedToken:n,showLayerZeroTip:M,minDeposit:f!=null&&f.minDepositSize?parseFloat(f.minDepositSize):10}),j=_=>{const W=_.target.value,K=A(),G=fi(W,K);if(G.isValid)h(G.formattedValue),G.errorType;else return G.errorType==="exceed_balance",void 0},z=x.useCallback(async()=>{di(!0);try{a&&a({amount:d,chainId:p,tokenAddress:(f==null?void 0:f.tokenAddress)||"",tokenSymbol:n,accountType:r})}catch(_){console.error("Deposit error:",_),di(!1)}},[a,d,p,f==null?void 0:f.tokenAddress,r,n]);return k.jsxs(k.Fragment,{children:[w,k.jsxs("div",{className:"bg-fill-input-primary rounded-lg px-3 py-3 my-4",children:[k.jsxs("div",{className:"flex justify-between items-center h-[18px] mb-3",children:[k.jsx("input",{type:"text",placeholder:u("deposit.amount"),value:d,onChange:j,className:"flex-1 bg-transparent text-text-primary text-sm font-medium placeholder-text-tertiary placeholder:font-normal focus:outline-none border-none p-0 h-full"}),k.jsx("button",{onClick:()=>{const _=A();h(_)},className:"text-theme-normal text-xs font-medium cursor-pointer hover:opacity-80 transition-opacity h-full flex items-center",children:u("deposit.max")})]}),k.jsx("div",{className:"h-[1px] bg-line-divider-secondary mb-2"}),k.jsxs("div",{className:"flex justify-between items-center",children:[k.jsx(Qn,{content:u("deposit.availableDesc"),children:k.jsx("span",{className:"text-text-tertiary text-xs leading-[14px] border-b border-dashed border-line-divider-primary",children:u("deposit.available")})}),k.jsx("span",{className:"text-text-primary text-xs leading-[14px]",children:S4($||"0",d,n)})]})]}),!g&&E4(d||"0",0)&&k.jsxs("div",{className:"flex justify-center flex-col items-center",children:[k.jsx("h3",{className:"text-text-primary text-sm leading-4 font-medium",children:u("deposit.enableSystemProWithToken",{token:n,network:t==null?void 0:t.chain})}),k.jsx("p",{className:"text-text-secondary text-xs leading-3 mt-4",children:u("deposit.enableTokenDesc",{token:n,network:t==null?void 0:t.chain})}),k.jsx("button",{className:"w-[180px] h-8 bg-fill-btn-primary hover:bg-fill-btn-primary-hover text-text-on-sec-btn rounded-xl text-sm font-medium transition-colors my-4 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center",onClick:C,disabled:D,children:D?k.jsx(Vo,{size:"xs",inline:!0}):u("deposit.enableWithToken",{token:n})})]}),M&&k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"flex mb-4",children:[k.jsx("div",{className:"w-5",children:k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1 text-xs text-functional-orange-1",children:u(y||"deposit.layerZeroDepositTip")})]}),k.jsx("div",{className:"my-2 ml-5 h-[1px] border-b border-dashed border-line-divider-secondary"})]}),T&&k.jsxs("div",{className:"flex mb-4",children:[k.jsx("div",{className:"w-5",children:k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1 text-xs text-functional-orange-1",children:u(P)})]}),T&&k.jsx("div",{className:"my-2 ml-5 h-[1px] border-b border-dashed border-line-divider-secondary"}),k.jsxs("div",{className:"flex mb-4",children:[k.jsx("div",{className:"w-5",children:!(T||M)&&k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1 text-xs text-functional-orange-1 whitespace-pre-line",children:u("deposit.noPrivateKeyWalletWarning")})]}),k.jsxs("div",{className:"border-t border-line-divider-secondary border-dashed py-4",children:[k.jsxs("div",{className:"flex justify-between items-center h-[18px] leading-4",children:[k.jsx("span",{className:"text-sm text-text-tertiary",children:u("deposit.arrivalTime")}),k.jsx(Qn,{content:k.jsxs("div",{className:"grid flex-grow max-w-[300px] min-w-[80px] rounded-2xl flex-col gap-[10px]",children:[k.jsx("p",{children:u("deposit.arrivaltimeTooltip1",{v:(t==null?void 0:t.blockTime)*t.txConfirm/60,v1:t==null?void 0:t.txConfirm})}),k.jsx("p",{children:u("deposit.arrivaltimeTooltip2")})]}),placement:"top",children:k.jsx("span",{className:"text-text-primary font-medium text-right border-b-[2px] border-dashed border-line-divider-primary decoration-dashed text-sm",children:u("deposit.arrivalEstimated",{v:(t==null?void 0:t.blockTime)*t.txConfirm/60})})})]}),k.jsxs("div",{className:"flex justify-between items-center h-[18px] leading-4 mt-2",children:[k.jsx("span",{className:"text-sm text-text-tertiary",children:u("deposit.equity")}),k.jsx("span",{className:"text-sm text-text-primary font-medium",children:d?k.jsxs("span",{className:"flex items-center gap-1",children:[Mt(o),k.jsx("span",{className:"text-sm font-edgex-harmony text-functional-green-1 leading-[18px] font-medium",children:"→"}),Mt((parseFloat(o)+parseFloat(d)).toString())," ",n]}):`${Mt(o)} ${n}`})]})]}),k.jsxs("button",{className:`w-full h-[38px] text-sm rounded-xl font-medium transition-colors flex items-center justify-center gap-2 ${L.disabled||s?"bg-text-disabled text-text-secondary cursor-not-allowed":"bg-fill-btn-primary text-text-on-sec-btn"}`,onClick:z,disabled:L.disabled||s,children:[(s||O)&&k.jsx(Vo,{size:"xs"}),L.text]})]})},hm=e=>e.toLocaleUpperCase()===xn?xn:sc,Eu=e=>hm(e.wallet)===xn,B4=e=>hm(e.wallet)===sc,mm=({isOpen:e,isLoading:t=!1,onClose:n,currentActiveAccount:r,chains:o,spotChains:s=[],defaultChainId:i,defaultSymbol:c,defaultAccountType:a="perpetual",balances:u,wagmiHooks:l,onDeposit:f,onCopy:p,onChainChange:d,onTokenChange:h})=>{const{t:m}=vt(),[w,$]=x.useState(a),E=x.useCallback(T=>T==="spot"&&s&&s.length>0?s:o,[o,s]),S=E(a),[N,B]=x.useState(()=>{var T;return!S||S.length===0?1:i||((T=S[0])==null?void 0:T.chainId)||1}),F=x.useMemo(()=>E(w),[w,E]),D=F.find(T=>T.chainId===N)||F[0],[b,g]=x.useState(()=>{var _;if(!S||S.length===0)return"";const T=i||((_=S[0])==null?void 0:_.chainId),P=S.find(W=>W.chainId===T)||S[0],L=((P==null?void 0:P.tokenList)||[]).length>0?P:S.find(W=>(W.tokenList||[]).length>0),j=(L==null?void 0:L.tokenList)||[];if(c&&j.length>0){const W=c.toUpperCase(),K=j.find(G=>(G.token||G.symbol||"").toUpperCase()===W);if(K)return K.token||K.symbol||""}const z=j[0];return(z==null?void 0:z.token)||(z==null?void 0:z.symbol)||""}),v=x.useCallback(T=>{B(T),d==null||d(T)},[d]),C=x.useCallback(T=>{g(T),h==null||h(T)},[h]),O=x.useMemo(()=>{const T=(b||"").toLowerCase();if(!T)return"0";const P=w==="spot"?u==null?void 0:u.spot:u==null?void 0:u.perpetual,L=P==null?void 0:P[T];return typeof L=="string"&&L.length>0?L:"0"},[u,w,b]),[I,M]=x.useState(!1),y=T=>{T.target===T.currentTarget?M(!0):M(!1)},A=T=>{I&&T.target===T.currentTarget&&n(),M(!1)};return e?je.createPortal(k.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 w-screen h-screen",style:{zIndex:98},children:k.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 z-[99] flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)"},onMouseDown:y,onMouseUp:A,"aria-hidden":"true",children:k.jsxs("div",{className:"relative w-[420px] max-h-[85vh] bg-fill-page-secondary overflow-auto rounded-lg p-6 shadow-xl border-[2px] border-solid border-line-divider-secondary",onClick:T=>{T.stopPropagation()},children:[k.jsxs("div",{className:"flex items-center justify-between mb-4",children:[k.jsx("h2",{className:"text-lg font-semibold text-white",children:m("deposit.title")}),k.jsx("button",{className:"text-gray-400 hover:text-gray-200 transition-colors",onClick:n,"aria-label":"Close",children:k.jsx(l0,{className:"h-4 w-4"})})]}),k.jsx(Sh,{selectedAccount:w,onAccountChange:T=>{var H,Z;const P=T||"perpetual";$(P);const L=E(P);if(!L||L.length===0)return;const j=L.find(J=>J.chainId===N),z=j?j.chainId:L[0].chainId;B(z),d==null||d(z);const _=L.find(J=>J.chainId===z),W=(_==null?void 0:_.tokenList)||[],G=W.some(J=>(J.symbol||J.token)===b)?b:((H=W[0])==null?void 0:H.symbol)||((Z=W[0])==null?void 0:Z.token)||"";G&&(g(G),h==null||h(G))},className:"w-full"}),k.jsx(Eh,{currentActiveChain:D,chainList:F,onChainChange:v,curSelectToken:b,onTokenChange:C,walletType:Eu(r)?xn:sc,accountType:w}),Eu(r)&&k.jsx(x4,{address:r.smartWalletAddress,currentActiveChain:D,selectedToken:b,accountType:w,onDeposit:f,onCopy:p,onClose:n}),B4(r)&&k.jsx(k4,{address:r.ethAddress,currentActiveChain:D,selectedToken:b,accountType:w,platformBalance:O,isLoading:t,wagmiHooks:l,onChainChange:v,onDeposit:f,onClose:n})]})})}),document.body):null},L4=e=>{if(e==null||e==="")return 2;const t=String(e),n=t.indexOf(".");if(n===-1)return 0;const r=t.length-n-1;return r>0?r:2},F4=({withdrawAmount:e,curSelectToken:t,tokenInfo:n,currentActiveChain:r,platformBalance:o="0",fee:s="0.00",walletType:i="evm",receiverAddress:c="",accountType:a="perpetual",onWithdrawAmountChange:u,onReceiverAddressChange:l,onAmountChanged:f,showPoolBalanceInsufficientTip:p=!1})=>{const{t:d}=vt(),h=x.useMemo(()=>{const F=L4(n==null?void 0:n.showStepSize);if(a==="spot"||!ln(r==null?void 0:r.chainId)){const D=new Ie(e||"0").minus(s||"0").decimalPlaces(F,Ie.ROUND_DOWN);return D.isNegative()?"0.00":D.toString()}return e||"0"},[e,s,r==null?void 0:r.chainId,a,n==null?void 0:n.showStepSize]),m=x.useMemo(()=>o||"0",[o]),w=x.useMemo(()=>{const F=(n==null?void 0:n.feeRate)||(n==null?void 0:n.withdrawFeeRate)||(r==null?void 0:r.feeRate)||0;try{return new Ie(F||0).times(100).toString()}catch{return"0"}},[n==null?void 0:n.feeRate,n==null?void 0:n.withdrawFeeRate,r==null?void 0:r.feeRate]),$=x.useMemo(()=>w==="0",[w]),E=x.useMemo(()=>{const F=(t||"").toUpperCase();return F==="USDT"||F==="USDC"},[t]),S=F=>{const D=F.target.value,g=fi(D,m||"0");if(g.isValid)u(g.formattedValue),g.errorType;else return g.errorType==="exceed_balance",void 0;f==null||f(g.formattedValue)},N=()=>{const F=m||"0",b=fi(F,F).formattedValue;u(b),f==null||f(b)},B=()=>{const F=parseFloat(o||"0"),D=parseFloat(e||"0");if(D>0){const b=F-D,g=Mt(Math.max(0,b).toString());return k.jsxs("span",{className:"flex items-center gap-1",children:[Mt(o||"0"),k.jsx("span",{className:"text-sm font-edgex-harmony text-functional-green-1 leading-[18px] font-medium",children:"→"}),g," ",t]})}return`${Mt(o||"0")} ${t}`};return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"bg-fill-input-primary rounded-lg px-3 py-3 my-4",children:[k.jsxs("div",{className:"flex justify-between items-center h-[18px] mb-3",children:[k.jsx("input",{type:"text",placeholder:d("deposit.amount"),value:e,onChange:S,className:"flex-1 bg-transparent text-text-primary text-sm font-medium placeholder-text-tertiary placeholder:font-normal focus:outline-none border-none p-0 h-full"}),k.jsx("button",{onClick:N,className:"text-theme-normal text-xs font-medium cursor-pointer hover:opacity-80 transition-opacity h-full flex items-center",children:d("deposit.max")})]}),k.jsx("div",{className:"h-[1px] bg-line-divider-secondary mb-2"}),k.jsxs("div",{className:"flex justify-between items-center",children:[k.jsx(Qn,{content:d("withdraw.availableDesc"),children:k.jsx("span",{className:"text-text-tertiary text-xs leading-[14px] border-b border-dashed border-line-divider-primary",children:d("deposit.available")})}),k.jsx("span",{className:"text-text-primary text-xs leading-[14px]",children:B()})]})]}),i==="mpc"&&(a==="spot"||!ln(r==null?void 0:r.chainId))?k.jsx("div",{className:"bg-fill-input-primary rounded-lg my-4 h-9 flex items-center px-3",children:k.jsx("input",{type:"text",placeholder:d("withdraw.receiverAddress"),value:c,onChange:F=>l==null?void 0:l(F.target.value),className:"flex-1 bg-transparent text-text-primary text-sm font-medium placeholder-text-tertiary placeholder:font-normal focus:outline-none border-none p-0 h-full"})}):null,k.jsx("div",{className:"bg-fill-page-secondary rounded-lg mb-4",children:ln(r==null?void 0:r.chainId)?k.jsxs(k.Fragment,{children:[k.jsx("p",{className:"text-text-tertiary text-xs leading-[18px]",children:d("withdraw.noticeDesc")}),k.jsx("a",{className:"block text-xs leading-[18px] mt-1 text-theme-normal",href:"https://edgex-1.gitbook.io/edgeX-documentation/getting-started/deposits-and-withdrawals/withdrawals",rel:"noreferrer",target:"_blank",children:d("withdraw.commonWithdraw")})]}):k.jsx("p",{className:"text-text-tertiary text-xs leading-[18px]",children:d("withdraw.crossChainTips")})}),p&&k.jsxs("div",{className:"flex mb-4",children:[k.jsx("div",{className:"w-5",children:k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1 text-xs text-functional-orange-1",children:d("withdraw.poolBalanceInsufficientTip")})]}),k.jsxs("div",{className:"py-4 border-t border-line-divider-secondary border-dashed",children:[k.jsxs("div",{className:"flex items-center justify-between h-[18px] leading-[18px]",children:[k.jsx(Qn,{content:k.jsxs("div",{children:[k.jsx("div",{children:d("withdraw.speedNote")}),k.jsxs("div",{className:"flex gap-1 items-center mt-1",children:[k.jsx(Uo,{selectedLevel:It.FAST,maxLevel:3}),k.jsx("span",{children:d("withdraw.speedNoteSpeed1")})]}),k.jsxs("div",{className:"flex gap-1 items-center mt-1",children:[k.jsx(Uo,{selectedLevel:It.Medium,maxLevel:3}),k.jsx("span",{children:d("withdraw.speedNoteSpeed2")})]}),k.jsxs("div",{className:"flex gap-1 items-center mt-1",children:[k.jsx(Uo,{selectedLevel:It.SLOW,maxLevel:3}),k.jsx("span",{children:d("withdraw.speedNoteSpeed3")})]})]}),children:k.jsx("span",{className:"text-text-tertiary text-sm leading-4 border-b border-dashed border-line-divider-primary",children:d("withdraw.speed")})}),k.jsx("div",{className:"flex items-center",children:k.jsx(Uo,{selectedLevel:ln(r==null?void 0:r.chainId)?It.SLOW:It.FAST,maxLevel:3})})]}),(a==="spot"||!ln(r==null?void 0:r.chainId))&&k.jsxs("div",{className:"flex items-center justify-between mt-2 h-[18px]",children:[$||!E?k.jsx("span",{className:"text-text-tertiary text-sm leading-4",children:$?d("withdraw.fee"):`${d("withdraw.fee")}/${d("withdraw.feeRate")}`}):k.jsx(Qn,{className:"w-[320px] font-normal flex items-center justify-center",content:k.jsx("span",{className:"flex items-center justify-center text-center",children:d("withdraw.feeCalculationTip")}),children:k.jsx("span",{className:"text-text-tertiary text-sm leading-4 border-b border-dashed border-line-divider-primary",children:`${d("withdraw.fee")}/${d("withdraw.feeRate")}`})}),k.jsxs("span",{className:"text-text-primary text-sm leading-4 font-medium",children:[s," ",t,!$&&` / ${w}%`]})]}),k.jsxs("div",{className:"flex items-center justify-between mt-2 h-[18px]",children:[k.jsx("span",{className:"text-text-tertiary text-sm leading-4",children:d(ln(r==null?void 0:r.chainId)?"withdraw.withdrawlAmount":"withdraw.amountToReceive")}),k.jsxs("span",{className:"text-text-primary text-sm leading-4 font-medium",children:[Mt(h)," ",t]})]})]})]})},D4=[];let Ke=null;const bm=x.forwardRef((e,t)=>{const[n,r]=x.useState(!1),[o,s]=x.useState(!1),[i,c]=x.useState({chains:[],currentActiveAccount:{wallet:"EVM",ethAddress:"",accountId:"",smartWalletAddress:""}}),a=x.useCallback(h=>{c(h||{chains:[],currentActiveAccount:{wallet:"EVM",ethAddress:"",accountId:"",smartWalletAddress:""}}),r(!0)},[]),u=x.useCallback(h=>{c(m=>({...m,...h}))},[]),l=x.useCallback(()=>{r(!1),s(!1),i.onClose&&i.onClose()},[i.onClose]),f=x.useCallback(h=>{s(h)},[]),p=x.useCallback(()=>n,[n]),d=x.useCallback(()=>o,[o]);return x.useImperativeHandle(t,()=>({openWithdraw:a,closeWithdraw:l,updateWithdrawOptions:u,setWithdrawLoading:f,isOpen:p,isLoading:d}),[a,l,u,f,p,d]),x.useEffect(()=>(Ke={openWithdraw:a,closeWithdraw:l,updateWithdrawOptions:u,setWithdrawLoading:f,isOpen:p,isLoading:d},()=>{Ke=null}),[a,l,u,f,p,d]),n?k.jsx(xm,{isOpen:n,isLoading:o,onClose:l,config:i.config||{symbol:"USDT"},currentActiveAccount:i.currentActiveAccount,chains:i.chains||D4,spotChains:i.spotChains,balances:i.balances,defaultChainId:i.defaultChainId,defaultSymbol:i.defaultSymbol,defaultAmount:i.defaultAmount,defaultAccountType:i.defaultAccountType,currentEquity:i.currentEquity??5e3,platformBalance:i.platformBalance||"0",fee:i.fee,wagmiHooks:i.wagmiHooks,onWithdraw:i.onWithdraw,onAccountChange:i.onAccountChange,onChainChange:i.onChainChange,onTokenChange:i.onTokenChange,onAmountChanged:i.onAmountChanged}):null});bm.displayName="WithdrawManager";const gm=e=>{if(!Ke){console.error("WithdrawManager not initialized. Make sure to render <WithdrawManager /> in your app.");return}Ke.openWithdraw(e||{chains:[],currentActiveAccount:{wallet:"EVM",ethAddress:"",accountId:"",smartWalletAddress:""}})},ym=()=>{if(!Ke){console.error("WithdrawManager not initialized. Make sure to render <WithdrawManager /> in your app.");return}Ke.closeWithdraw()},wm=e=>{if(!Ke){console.error("WithdrawManager not initialized. Make sure to render <WithdrawManager /> in your app.");return}Ke.updateWithdrawOptions(e)},pi=e=>{if(!Ke){console.error("WithdrawManager not initialized. Make sure to render <WithdrawManager /> in your app.");return}Ke.setWithdrawLoading(e)},R4=()=>Ke?Ke.isOpen():!1,vm=()=>Ke?Ke.isLoading():!1,j4=()=>({openWithdraw:gm,closeWithdraw:ym,updateWithdrawOptions:wm,setWithdrawLoading:pi,isOpen:R4,isLoading:vm}),_4=({walletType:e,chains:t,spotChains:n=[],defaultChainId:r,defaultSymbol:o,defaultAmount:s="",defaultAccountType:i="perpetual",currentEquity:c,platformBalance:a="0",balances:u,fee:l="0.00",isLoading:f=!1,onWithdraw:p,onClose:d,onChainChange:h,onTokenChange:m,onAmountChanged:w,onAccountChange:$})=>{var H;const{t:E}=vt(),[S,N]=x.useState(i),B=x.useCallback(Z=>Z==="spot"&&n&&n.length>0?n:t,[t,n]),F=x.useMemo(()=>B(S),[S,B]),D=x.useMemo(()=>{if(!F||F.length===0)return{chainId:1,tokenSymbol:""};const Z=de=>{const se=de||[];if(!se.length)return"";const ee="USDC".toUpperCase(),Nn=se.find(gt=>(gt.token||gt.symbol||"").toUpperCase()===ee)||se[0];return Nn.token||Nn.symbol||""};if(o){const de=o==null?void 0:o.toUpperCase();for(const se of F){const pe=se.tokenList||[];let ee;if(de&&(ee=pe.find(Se=>(Se.token||Se.symbol||"").toUpperCase()===de)),ee){const Se=ee.token||ee.symbol||o||"";return{chainId:se.chainId,tokenSymbol:Se}}}}if(r){const de=F.find(ee=>ee.chainId===r)||F[0],se=de.tokenList||[],pe=Z(se);return{chainId:de.chainId,tokenSymbol:pe}}const J="USDC",oe=de=>Array.isArray(de.tokenList)&&de.tokenList.some(se=>(se.token||se.symbol||"").toUpperCase()===J),me=F.find(oe)||F[0];if(!me)return{chainId:1,tokenSymbol:""};const ge=Z(me.tokenList);return{chainId:me.chainId,tokenSymbol:ge}},[F,r,o]),[b,g]=x.useState(()=>D.chainId),[v,C]=x.useState(()=>D.tokenSymbol),[O,I]=x.useState(s),[M,y]=x.useState(""),A=x.useCallback(Z=>{g(Z),h==null||h(Z)},[h]),T=x.useCallback(Z=>{C(Z),m==null||m(Z)},[m]),P=x.useRef(!0),L=x.useRef(v),j=x.useRef(b);x.useEffect(()=>{if(P.current){P.current=!1,L.current=v,j.current=b;return}(L.current!==v||j.current!==b)&&(I(""),L.current=v,j.current=b)},[v,b]);const z=F&&F.length>0?F.find(Z=>Z.chainId===b)||F[0]:null,_=(H=z==null?void 0:z.tokenList)==null?void 0:H.find(Z=>Z.token===v),W=x.useMemo(()=>{const Z=new Ie(O||"0"),J=new Ie(l||"0"),oe=ln(b);return _!=null&&_.minWithdrawSize&&Z.lt(_.minWithdrawSize)?{text:E("withdraw.minWithdrawParsed",{amount:_.minWithdrawSize,token:_.symbol||_.token}),disabled:!0}:!O||Z.isZero()||!oe&&Z.isLessThan(J)?{text:E("withdraw.confirmWithdraw"),disabled:!0}:e==="mpc"&&(!oe||S==="spot")&&!M.trim()?{text:E("withdraw.invalidReceiverAddress"),disabled:!0}:{text:E("withdraw.confirmWithdraw"),disabled:!1}},[E,b,O,e,M,l,S,_]),K=x.useMemo(()=>{const Z=(v||"").toLowerCase();if(!Z)return a||"0";const J=S==="spot"?u==null?void 0:u.spot:u==null?void 0:u.perpetual,oe=J==null?void 0:J[Z];return typeof oe=="string"&&oe.length>0?oe:a||"0"},[u,S,v,a]),G=x.useCallback(async()=>{pi(!0);try{if(p){const J={amount:new Ie(O||"0").toString(),chainId:b,tokenAddress:(_==null?void 0:_.tokenAddress)||"",coinId:(_==null?void 0:_.coinId)||"",tokenSymbol:v,accountType:S,selectedToken:_};e==="mpc"&&(!ln(b)||S==="spot")&&(J.receiverAddress=M),p(J)}}catch{pi(!1)}},[p,S,_,O,b,v,e,M]);return!F||F.length===0?k.jsx("div",{className:"text-center py-8",children:k.jsx("p",{className:"text-gray-400",children:"No chains available"})}):z?k.jsxs(k.Fragment,{children:[k.jsx(Sh,{selectedAccount:S,onAccountChange:Z=>{var Se,Nn;const J=Z||"perpetual";N(J),$==null||$(J);const oe=B(J);if(!oe||oe.length===0)return;const me=oe.find(gt=>gt.chainId===b),ge=me?me.chainId:oe[0].chainId;g(ge),h==null||h(ge);const de=oe.find(gt=>gt.chainId===ge),se=(de==null?void 0:de.tokenList)||[],ee=se.some(gt=>(gt.symbol||gt.token)===v)?v:((Se=se[0])==null?void 0:Se.symbol)||((Nn=se[0])==null?void 0:Nn.token)||"";ee&&(C(ee),m==null||m(ee))},className:"w-full"}),k.jsx(Eh,{currentActiveChain:z,chainList:F,onChainChange:A,curSelectToken:v,onTokenChange:T,walletType:"EVM",txType:"withdraw"}),k.jsx(F4,{withdrawAmount:O,curSelectToken:v,tokenInfo:_,curSelectTokenData:{balance:_==null?void 0:_.balance,allowance:_==null?void 0:_.allowance},currentActiveChain:z,currentEquity:c||0,decimals:(_==null?void 0:_.decimals)||6,platformBalance:K,fee:l,walletType:e,accountType:S,receiverAddress:M,onWithdrawAmountChange:I,onReceiverAddressChange:y,onAmountChanged:w}),k.jsxs("button",{className:`w-full h-[38px] text-sm rounded-xl font-medium transition-colors flex items-center justify-center gap-2 ${W.disabled||f?"bg-text-disabled text-text-secondary cursor-not-allowed":"bg-fill-btn-primary text-text-on-sec-btn"}`,onClick:G,disabled:W.disabled||f,children:[f&&k.jsx(Vo,{size:"xs"}),W.text]})]}):k.jsx("div",{className:"text-center py-8",children:k.jsx("p",{className:"text-gray-400",children:"Loading..."})})},xm=({isOpen:e,isLoading:t=!1,defaultAccountType:n="perpetual",onClose:r,config:o,currentActiveAccount:s,chains:i,spotChains:c=[],defaultChainId:a,defaultSymbol:u,defaultAmount:l="",currentEquity:f=5e3,platformBalance:p="0",balances:d,fee:h,wagmiHooks:m,onWithdraw:w,onChainChange:$,onTokenChange:E,onAmountChanged:S,onAccountChange:N})=>{const{t:B}=vt(),[F,D]=x.useState(!1),b=v=>{v.target===v.currentTarget?D(!0):D(!1)},g=v=>{F&&v.target===v.currentTarget&&r(),D(!1)};return e?je.createPortal(k.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 w-screen h-screen",style:{zIndex:98},children:k.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 z-[99] flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)"},onMouseDown:b,onMouseUp:g,"aria-hidden":"true",children:k.jsxs("div",{className:"relative w-[420px] max-h-[85vh] bg-fill-page-secondary overflow-auto rounded-lg p-6 shadow-xl",onClick:v=>{v.stopPropagation()},children:[k.jsxs("div",{className:"flex items-center justify-between mb-4",children:[k.jsx("h2",{className:"text-lg font-semibold text-white",children:B("withdraw.withdraw")}),k.jsx("button",{className:"text-gray-400 hover:text-gray-200 transition-colors",onClick:r,"aria-label":"Close",children:k.jsx(l0,{className:"h-4 w-4"})})]}),k.jsx(_4,{chains:i,spotChains:c,walletType:Eu(s)?"mpc":"evm",defaultChainId:a,defaultSymbol:u,defaultAmount:l,defaultAccountType:n,currentEquity:f,platformBalance:p,balances:d,fee:h,isLoading:t,wagmiHooks:m,onWithdraw:w,onClose:r,onChainChange:$,onTokenChange:E,onAmountChanged:S,onAccountChange:N})]})})}),document.body):null};re.ChromeLoader=Vo,re.ComponentProvider=Gm,re.DEFAULT_LOCALE=qo,re.Deposit=mm,re.DepositManager=um,re.LOCALE_NAMES=Hm,re.LoadingSpinner=Vo,re.SUPPORTED_LOCALES=bi,re.Tooltip=Qn,re.Withdraw=xm,re.WithdrawManager=bm,re.closeDeposit=fm,re.closeWithdraw=ym,re.formatThousands=Zm,re.isDepositLoading=pm,re.isWithdrawLoading=vm,re.openDeposit=lm,re.openWithdraw=gm,re.setDepositLoading=di,re.setWithdrawLoading=pi,re.updateDepositOptions=dm,re.updateWithdrawOptions=wm,re.useComponentConfig=Lu,re.useDeposit=f5,re.useDepositManager=O4,re.useTranslation=vt,re.useWithdraw=d5,re.useWithdrawManager=j4,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"})});
178
+ `)[0]:$},[c,t,e==null?void 0:e.chain,l,u]),d=(f==null?void 0:f.minDepositSize)||"10";return k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"flex justify-center mt-4 mb-3",children:n&&k.jsx("div",{className:"bg-white rounded-lg",children:k.jsx(zh,{value:n,size:120,level:"L",bgColor:"#ffffff",fgColor:"#000000",marginSize:0})})}),n&&k.jsxs("div",{className:"flex items-center justify-between bg-fill-input-primary rounded-lg py-2 px-3 mb-3",children:[k.jsx("span",{className:"flex-1 text-text-primary text-sm font-medium break-all mr-3",children:n}),k.jsx(T3,{onCopy:()=>{s&&s(n)},text:n,children:k.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",children:[k.jsx("rect",{x:"2.08496",y:"4.02295",width:"9.89893",height:"9.89893",rx:"2",stroke:"#F9F9F9"}),k.jsx("path",{d:"M5.85547 2.07861H11.415C12.7957 2.07861 13.915 3.1979 13.915 4.57861V10.0786",stroke:"#F9F9F9",strokeLinecap:"round"})]})},"copy")]}),k.jsxs("div",{className:"border-b border-dashed border-line-divider-secondary pb-4",children:[k.jsxs("div",{className:"flex items-start",children:[k.jsx("div",{className:"w-5",children:k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1",children:k.jsx("p",{className:"text-xs text-functional-orange-1",children:p})})]}),r===a0&&k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"my-2 ml-5 h-[1px] border-b border-dashed border-line-divider-secondary"}),k.jsx("div",{className:"flex items-start pl-5 text-functional-orange-1 text-xs",children:c("deposit.addressUpdatedNotice")})]})]}),k.jsxs("div",{className:"text-sm",children:[(a||t.toUpperCase()!=="USDC")&&k.jsxs("div",{className:"flex justify-between items-center h-[18px] mt-4",children:[k.jsx("span",{className:"text-text-tertiary",children:c("deposit.arrivalTime")}),k.jsx(Qn,{content:k.jsxs("div",{className:"grid flex-grow max-w-[300px] min-w-[80px] rounded-2xl flex-col gap-[10px]",children:[k.jsx("p",{children:c("deposit.arrivaltimeTooltip1",{v:(e==null?void 0:e.blockTime)*e.txConfirm/60,v1:e==null?void 0:e.txConfirm})}),k.jsx("p",{children:c("deposit.arrivaltimeTooltip2")})]}),placement:"top",children:k.jsx("span",{className:"text-text-primary font-medium text-right border-b-[2px] border-dashed border-line-divider-primary decoration-dashed",children:c("deposit.arrivalEstimated",{v:(e==null?void 0:e.blockTime)*e.txConfirm/60})})})]}),k.jsxs("div",{className:`flex justify-between items-center h-[18px] ${a||t.toUpperCase()!=="USDC"?"mt-1":"mt-4"}`,children:[k.jsx("span",{className:"text-text-tertiary",children:c("deposit.minDeposit")}),k.jsxs("span",{className:"text-text-primary font-medium text-right",children:[d," ",t]})]}),r===a0&&t.toUpperCase()!=="USDC"&&k.jsxs("div",{className:"flex justify-between items-center h-[18px] mt-1",children:[k.jsx("span",{className:"text-text-tertiary",children:c("deposit.maxDeposit")}),k.jsxs("span",{className:"text-text-primary font-medium text-right",children:["200,000 ",t]})]})]}),k.jsx("button",{className:"w-full h-[38px] bg-fill-btn-primary rounded-xl text-sm font-medium text-text-on-sec-btn mt-4",onClick:()=>{o&&o({amount:"",chainId:e.chainId,tokenAddress:n,tokenSymbol:t}),i()},children:c("deposit.title")})]})},Vo=({size:e="xs",color:t,className:n="",label:r="Loading...",inline:o=!1})=>{const s=t?`loading-${t}`:"",i=o?"loading-inline":"";return k.jsx("span",{className:`loading loading-${e} loading-spinner ${s} ${i} ${n}`.trim(),"aria-label":r,role:"status","aria-live":"polite"})},E4=(e,t)=>Number(e)>Number(t),Mt=e=>{if(!e||e===""||isNaN(Number(e)))return"0.00";const t=Number(e);if(t===0)return"0.00";let n=t.toString();n.includes("e")&&(n=t.toFixed(20));const r=n.split("."),o=r[0];let s=r[1]||"";return s.length>6&&(s=s.substring(0,6)),s=s.replace(/0+$/,""),s?(s.length===1&&(s+="0"),o+"."+s):o+".00"},fi=(e,t="0")=>{if(/[^0-9.]/.test(e))return{isValid:!1,formattedValue:"",errorType:"invalid_char"};if(e===".")return{isValid:!0,formattedValue:"0."};if((e.match(/\./g)||[]).length>1)return{isValid:!1,formattedValue:"",errorType:"invalid_char"};if(!e||e==="")return{isValid:!0,formattedValue:""};const o=e.split(".");if(o.length===2&&o[1].length>6){const a=o[0]+"."+o[1].substring(0,6);return fi(a,t)}const s=parseFloat(e),i=parseFloat(t);return!isNaN(s)&&!isNaN(i)&&s>i?{isValid:!0,formattedValue:Mt(t),errorType:"auto_adjusted_to_max"}:{isValid:!0,formattedValue:e}},S4=(e,t,n)=>{const r=parseFloat(String(e)||"0"),o=parseFloat(String(t)||"0");if(o>0){const s=r-o,i=Mt(Math.max(0,s).toString());return k.jsxs("span",{className:"flex items-center gap-1",children:[Mt(e),k.jsx("span",{className:"text-sm font-edgex-harmony text-functional-green-1 leading-[18px] font-medium",children:"→"}),i," ",n]})}return`${Mt(e)} ${n}`},P4=(e,t,n)=>{if(!e||e===""||e==="0"||e==="0.00")return!1;const r=parseFloat(e),o=parseFloat(t);return!(isNaN(r)||isNaN(o)||r>o||!n)},$4=(e,t,n)=>{if(!xh(e,n))return!1;try{const r=new Ie(t||"0"),o=new Ie("200000");return r.isNaN()||o.isNaN()?!1:r.gte(o)}catch{return!1}},T4=(e,t,n,r)=>{let o=t||"0";if(!(r==="spot")&&xh(e,n))try{const i=new Ie(o),c=new Ie("200000");i.gt(c)&&(o="200000")}catch(i){console.warn("Error calculating max amount limit:",i)}try{const i=new Ie(o||"0");return console.log("bn:",i),console.log("bn:",i.isNaN()),i.isNaN()?o:i.decimalPlaces(6,Ie.ROUND_DOWN).toString()}catch{return o}},cm={chains:[],spotChains:[],currentActiveAccount:{wallet:"EVM",ethAddress:"",accountId:"",smartWalletAddress:""},defaultChainId:1,defaultAccountType:"perpetual",balances:{spot:{},perpetual:{}}};let Ye=null;const um=x.forwardRef((e,t)=>{const[n,r]=x.useState(!1),[o,s]=x.useState(!1),[i,c]=x.useState(cm),a=x.useCallback(h=>{c(h),r(!0)},[]),u=x.useCallback(h=>{c(m=>({...m,...h}))},[]),l=x.useCallback(()=>{r(!1),s(!1),i.onClose&&i.onClose()},[i.onClose]),f=x.useCallback(h=>{s(h)},[]),p=x.useCallback(()=>n,[n]),d=x.useCallback(()=>o,[o]);return x.useImperativeHandle(t,()=>({openDeposit:a,closeDeposit:l,updateDepositOptions:u,setDepositLoading:f,isOpen:p,isLoading:d}),[a,l,u,f,p,d]),x.useEffect(()=>(Ye={openDeposit:a,closeDeposit:l,updateDepositOptions:u,setDepositLoading:f,isOpen:p,isLoading:d},()=>{Ye=null}),[a,l,u,f,p,d]),n?k.jsx(mm,{isOpen:n,isLoading:o,onClose:l,currentActiveAccount:i.currentActiveAccount,chains:i.chains,spotChains:i.spotChains,defaultChainId:i.defaultChainId,defaultSymbol:i.defaultSymbol,defaultAccountType:i.defaultAccountType,balances:i.balances,wagmiHooks:i.wagmiHooks,onDeposit:i.onDeposit,onCopy:i.onCopy,onChainChange:h=>{var m;return(m=i.onChainChange)==null?void 0:m.call(i,h)},onTokenChange:h=>{var m;return(m=i.onTokenChange)==null?void 0:m.call(i,h)}}):null});um.displayName="DepositManager";const lm=e=>{if(!Ye){console.error("DepositManager not initialized. Make sure to render <DepositManager /> in your app.");return}Ye.openDeposit(e||cm)},fm=()=>{if(!Ye){console.error("DepositManager not initialized. Make sure to render <DepositManager /> in your app.");return}Ye.closeDeposit()},dm=e=>{Ye&&Ye.updateDepositOptions(e)},di=e=>{if(!Ye){console.error("DepositManager not initialized. Make sure to render <DepositManager /> in your app.");return}Ye.setDepositLoading(e)},A4=()=>Ye?Ye.isOpen():!1,pm=()=>Ye?Ye.isLoading():!1,O4=()=>({openDeposit:lm,closeDeposit:fm,updateDepositOptions:dm,setDepositLoading:di,isOpen:A4,isLoading:pm}),N4=e=>{const{t}=vt(),{isNetworkMismatch:n,depositAmount:r,approved:o,currentTokenBalance:s,selectedToken:i,showLayerZeroTip:c,minDeposit:a=10}=e;return x.useMemo(()=>{if(n)return{text:t("deposit.switchNetwork"),disabled:!0,isNetworkSwitch:!0};const u=parseFloat(r||"0"),l=a,f=P4(r,s||"0",o);return!r||u===0||!o?{text:t(c?"deposit.layerZeroDepositButton":"deposit.confirmDeposit"),disabled:!0,isNetworkSwitch:!1}:u<l?{text:t("deposit.minDepositParsed",{amount:l,token:i}),disabled:!0,isNetworkSwitch:!1}:{text:t(c?"deposit.layerZeroDepositButton":"deposit.confirmDeposit"),disabled:!f,isNetworkSwitch:!1}},[n,r,o,s,i,c,a,t])};function C4(e){const{account:t,accountChainId:n,targetChainId:r,tokenInfo:o,amount:s}=e,{useReadContract:i,useWriteContract:c,usePublicClient:a,useSwitchChain:u}=e.wagmiHooks,l=o==null?void 0:o.tokenAddress,f=(o==null?void 0:o.decimals)??18,p=o==null?void 0:o.contractAddress,d=!l||l.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",{switchChainAsync:h}=u(),{writeContractAsync:m}=c(),w=a(),$=i({address:l,abi:yr,functionName:"allowance",args:[mn(t||""),p],chainId:r,query:{enabled:!!(!d&&t&&r&&l&&p)}}),E=$!=null&&$.isSuccess?$.data:void 0,S=x.useMemo(()=>{if(d)return!0;if(!$.isSuccess||E===void 0||E===0n)return!1;try{const B=x6(String(Number(s||"0")||0),Number(f));return E>=B}catch{return!1}},[d,$.isSuccess,E,s,f]),N=x.useCallback(async()=>{try{if(r&&n&&+n!=+r&&await h({chainId:+r}),!m||!w||!l||!p)return;const F=mn(l),D=mn(p);if((E||0n)>0n){const v=await m({abi:yr,address:F,functionName:"approve",args:[D,0n]});await w.waitForTransactionReceipt({hash:v})}const g=await m({abi:yr,address:F,functionName:"approve",args:[D,ef]});await w.waitForTransactionReceipt({hash:g}),$!=null&&$.refetch&&await $.refetch()}catch(B){console.error("[useApprove] onApprove failed:",B)}},[r,n,l,p,E,$,m,w,h]);return{approve:S,onApprove:N}}const I4=({token:e,account:t,chainId:n,wagmiHooks:r,onResult:o})=>{var i;const s=(i=r==null?void 0:r.useBalance)==null?void 0:i.call(r,{address:t,token:e.tokenAddress,chainId:n,query:{enabled:!!t&&!!n&&!!e.tokenAddress&&!!(r!=null&&r.useBalance)}});return x.useEffect(()=>{o(mn(e.tokenAddress),{balance:s})},[s,e.tokenAddress,o]),null},M4=({account:e,chainId:t,contractAddress:n,tokens:r=[],wagmiHooks:o})=>{var E;const s=typeof t=="string"?Number.isFinite(Number(t))?Number(t):void 0:t,i=x.useMemo(()=>{const S="0x0000000000000000000000000000000000000000",N="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";return r.filter(B=>{const F=B.tokenAddress;if(!F)return!1;const D=F.toLowerCase();return!(F===S||D===N)})},[r]),[c,a]=x.useState({}),u=x.useCallback((S,N)=>{a(B=>({...B,[S]:N}))},[]),l=(E=o==null?void 0:o.useBalance)==null?void 0:E.call(o,{address:e,chainId:s,query:{enabled:!!e&&!!s&&!!(o!=null&&o.useBalance)}}),[f,p]=x.useState(0),d=x.useMemo(()=>i.map(S=>x.createElement(I4,{key:`${S.tokenAddress}-${f}`,token:S,account:e,chainId:s,contractAddress:n,wagmiHooks:o,onResult:u})),[i,e,s,n,o,u,f]),h=x.useMemo(()=>{const S=l!=null&&l.data?{value:l.data.value,formatted:l.data.formatted,decimals:l.data.decimals,symbol:l.data.symbol}:{value:BigInt(0),formatted:"0",decimals:18,symbol:"ETH"},N=i.map(F=>{const D=c[mn(F.tokenAddress)],b=D==null?void 0:D.balance,g=b==null?void 0:b.data;return{address:mn(F.tokenAddress),value:(g==null?void 0:g.value)||BigInt(0),formatted:(g==null?void 0:g.formatted)||"0",decimals:(g==null?void 0:g.decimals)||F.decimals}}).filter(F=>F.address),B=N.reduce((F,D)=>({...F,[D.address]:{balance:D}}),{});return{balanceList:N,baseTokenBalance:S,combinedData:B}},[l,c,i]),m=x.useCallback(async()=>h,[h]),w=x.useMemo(()=>{const S=(l==null?void 0:l.isLoading)||!1,N=Object.values(c).some(B=>{var F;return(F=B.balance)==null?void 0:F.isLoading});return S||N},[l==null?void 0:l.isLoading,c]),$=x.useCallback(()=>p(S=>S+1),[]);return{multicallRun:m,multicallRefresh:$,multicallResult:h,validErcTokens:i,isLoading:w,queryComponents:d}},k4=({address:e,currentActiveChain:t,selectedToken:n,accountType:r,platformBalance:o,isLoading:s,wagmiHooks:i,onChainChange:c,onDeposit:a})=>{const{t:u}=vt(),l=i.useAccount(),f=t.tokenList.find(_=>_.token===n||_.symbol===n),p=t.chainId,[d,h]=x.useState("");x.useEffect(()=>{h("")},[n,t.chainId]);const{multicallResult:m,queryComponents:w}=M4({account:e,chainId:t.chainId,contractAddress:(f==null?void 0:f.contractAddress)||(t==null?void 0:t.contractAddress),tokens:(t==null?void 0:t.tokenList)||[],wagmiHooks:i}),$=x.useMemo(()=>{var W;if(!f)return"0";if(!f.tokenAddress||f.tokenAddress.toLowerCase()==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")return m.baseTokenBalance.formatted;const _=m.combinedData[f.tokenAddress];return((W=_==null?void 0:_.balance)==null?void 0:W.formatted)||"0"},[f,m]),E="0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9",S="0xceeed84620e5eb9ab1d6dfc316867d2cda332e41",N=x.useMemo(()=>{var _,W;return s5({chain:u5,transport:c5(t.rpcUrl||((_=window==null?void 0:window.ENV)==null?void 0:_.CHAIN_RPC_URL_42161)||((W=window==null?void 0:window.ENV)==null?void 0:W.CHAIN_RPC_URL_421614))})},[t.rpcUrl]),B="1000000000000",{formatted:F}=l5({client:N,tokenAddress:E,holder:S,decimals:6,fallbackFormatted:B,pollingInterval:12e3}),[D,b]=x.useState(!1),{approve:g,onApprove:v}=C4({account:e,accountChainId:l.chainId,targetChainId:+t.chainId,tokenInfo:f,amount:d,wagmiHooks:i}),C=x.useCallback(async()=>{if(!D)try{b(!0),await v()}catch(_){console.error("Approve failed:",_)}finally{b(!1)}},[D,v]),O=x.useMemo(()=>+l.chainId!=+t.chainId,[l.chainId,t.chainId]),I=x.useCallback(async()=>{c&&c(p)},[c,p]);x.useEffect(()=>{O&&I()},[O,I]);const{showLayerZeroTip:M,layerZeroTipKey:y}=x.useMemo(()=>{const _=+t.chainId==42161||+t.chainId==421614,W=(n==null?void 0:n.toUpperCase())==="USDT",K=new Ie(d||"0"),G=new Ie("200000");let H=!1,Z;if(_&&W&&d)if(K.gte(G))H=!0,Z="deposit.layerZeroDepositTipGte200k";else{const J=F;if(typeof J=="string"&&J.length>0){const me=new Ie(J);!me.isNaN()&&K.gte(me)&&(H=!0,Z="deposit.layerZeroDepositTipExceedPool")}}return{showLayerZeroTip:H,layerZeroTipKey:Z}},[t.chainId,n,d,F]),A=x.useCallback(()=>T4(+t.chainId,$||"0",n,r),[$,t==null?void 0:t.chainId,n,r]),T=x.useMemo(()=>r!=="spot"&&$4(+t.chainId,d,n),[r,t==null?void 0:t.chainId,d,n]),P=x.useMemo(()=>"deposit.maxDepositSplitTip",[]),L=N4({isNetworkMismatch:O,depositAmount:d,approved:g,currentTokenBalance:$,selectedToken:n,showLayerZeroTip:M,minDeposit:f!=null&&f.minDepositSize?parseFloat(f.minDepositSize):10}),j=_=>{const W=_.target.value,K=A(),G=fi(W,K);if(G.isValid)h(G.formattedValue),G.errorType;else return G.errorType==="exceed_balance",void 0},z=x.useCallback(async()=>{di(!0);try{a&&a({amount:d,chainId:p,tokenAddress:(f==null?void 0:f.tokenAddress)||"",tokenSymbol:n,accountType:r})}catch(_){console.error("Deposit error:",_),di(!1)}},[a,d,p,f==null?void 0:f.tokenAddress,r,n]);return k.jsxs(k.Fragment,{children:[w,k.jsxs("div",{className:"bg-fill-input-primary rounded-lg px-3 py-3 my-4",children:[k.jsxs("div",{className:"flex justify-between items-center h-[18px] mb-3",children:[k.jsx("input",{type:"text",placeholder:u("deposit.amount"),value:d,onChange:j,className:"flex-1 bg-transparent text-text-primary text-sm font-medium placeholder-text-tertiary placeholder:font-normal focus:outline-none border-none p-0 h-full"}),k.jsx("button",{onClick:()=>{const _=A();h(_)},className:"text-theme-normal text-xs font-medium cursor-pointer hover:opacity-80 transition-opacity h-full flex items-center",children:u("deposit.max")})]}),k.jsx("div",{className:"h-[1px] bg-line-divider-secondary mb-2"}),k.jsxs("div",{className:"flex justify-between items-center",children:[k.jsx(Qn,{content:u("deposit.availableDesc"),children:k.jsx("span",{className:"text-text-tertiary text-xs leading-[14px] border-b border-dashed border-line-divider-primary",children:u("deposit.available")})}),k.jsx("span",{className:"text-text-primary text-xs leading-[14px]",children:S4($||"0",d,n)})]})]}),!g&&E4(d||"0",0)&&k.jsxs("div",{className:"flex justify-center flex-col items-center",children:[k.jsx("h3",{className:"text-text-primary text-sm leading-4 font-medium",children:u("deposit.enableSystemProWithToken",{token:n,network:t==null?void 0:t.chain})}),k.jsx("p",{className:"text-text-secondary text-xs leading-3 mt-4",children:u("deposit.enableTokenDesc",{token:n,network:t==null?void 0:t.chain})}),k.jsx("button",{className:"w-[180px] h-8 bg-fill-btn-primary hover:bg-fill-btn-primary-hover text-text-on-sec-btn rounded-xl text-sm font-medium transition-colors my-4 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center",onClick:C,disabled:D,children:D?k.jsx(Vo,{size:"xs",inline:!0}):u("deposit.enableWithToken",{token:n})})]}),M&&k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"flex mb-4",children:[k.jsx("div",{className:"w-5",children:k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1 text-xs text-functional-orange-1",children:u(y||"deposit.layerZeroDepositTip")})]}),k.jsx("div",{className:"my-2 ml-5 h-[1px] border-b border-dashed border-line-divider-secondary"})]}),T&&k.jsxs("div",{className:"flex mb-4",children:[k.jsx("div",{className:"w-5",children:k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1 text-xs text-functional-orange-1",children:u(P)})]}),T&&k.jsx("div",{className:"my-2 ml-5 h-[1px] border-b border-dashed border-line-divider-secondary"}),k.jsxs("div",{className:"flex mb-4",children:[k.jsx("div",{className:"w-5",children:!(T||M)&&k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1 text-xs text-functional-orange-1 whitespace-pre-line",children:u("deposit.noPrivateKeyWalletWarning")})]}),k.jsxs("div",{className:"border-t border-line-divider-secondary border-dashed py-4",children:[k.jsxs("div",{className:"flex justify-between items-center h-[18px] leading-4",children:[k.jsx("span",{className:"text-sm text-text-tertiary",children:u("deposit.arrivalTime")}),k.jsx(Qn,{content:k.jsxs("div",{className:"grid flex-grow max-w-[300px] min-w-[80px] rounded-2xl flex-col gap-[10px]",children:[k.jsx("p",{children:u("deposit.arrivaltimeTooltip1",{v:(t==null?void 0:t.blockTime)*t.txConfirm/60,v1:t==null?void 0:t.txConfirm})}),k.jsx("p",{children:u("deposit.arrivaltimeTooltip2")})]}),placement:"top",children:k.jsx("span",{className:"text-text-primary font-medium text-right border-b-[2px] border-dashed border-line-divider-primary decoration-dashed text-sm",children:u("deposit.arrivalEstimated",{v:(t==null?void 0:t.blockTime)*t.txConfirm/60})})})]}),k.jsxs("div",{className:"flex justify-between items-center h-[18px] leading-4 mt-2",children:[k.jsx("span",{className:"text-sm text-text-tertiary",children:u("deposit.equity")}),k.jsx("span",{className:"text-sm text-text-primary font-medium",children:d?k.jsxs("span",{className:"flex items-center gap-1",children:[Mt(o),k.jsx("span",{className:"text-sm font-edgex-harmony text-functional-green-1 leading-[18px] font-medium",children:"→"}),Mt((parseFloat(o)+parseFloat(d)).toString())," ",n]}):`${Mt(o)} ${n}`})]})]}),k.jsxs("button",{className:`w-full h-[38px] text-sm rounded-xl font-medium transition-colors flex items-center justify-center gap-2 ${L.disabled||s?"bg-text-disabled text-text-secondary cursor-not-allowed":"bg-fill-btn-primary text-text-on-sec-btn"}`,onClick:z,disabled:L.disabled||s,children:[(s||O)&&k.jsx(Vo,{size:"xs"}),L.text]})]})},hm=e=>e.toLocaleUpperCase()===xn?xn:sc,Eu=e=>hm(e.wallet)===xn,B4=e=>hm(e.wallet)===sc,mm=({isOpen:e,isLoading:t=!1,onClose:n,currentActiveAccount:r,chains:o,spotChains:s=[],defaultChainId:i,defaultSymbol:c,defaultAccountType:a="perpetual",balances:u,wagmiHooks:l,onDeposit:f,onCopy:p,onChainChange:d,onTokenChange:h})=>{const{t:m}=vt(),[w,$]=x.useState(a),E=x.useCallback(T=>T==="spot"&&s&&s.length>0?s:o,[o,s]),S=E(a),[N,B]=x.useState(()=>{var T;return!S||S.length===0?1:i||((T=S[0])==null?void 0:T.chainId)||1}),F=x.useMemo(()=>E(w),[w,E]),D=F.find(T=>T.chainId===N)||F[0],[b,g]=x.useState(()=>{var _;if(!S||S.length===0)return"";const T=i||((_=S[0])==null?void 0:_.chainId),P=S.find(W=>W.chainId===T)||S[0],L=((P==null?void 0:P.tokenList)||[]).length>0?P:S.find(W=>(W.tokenList||[]).length>0),j=(L==null?void 0:L.tokenList)||[];if(c&&j.length>0){const W=c.toUpperCase(),K=j.find(G=>(G.token||G.symbol||"").toUpperCase()===W);if(K)return K.token||K.symbol||""}const z=j[0];return(z==null?void 0:z.token)||(z==null?void 0:z.symbol)||""}),v=x.useCallback(T=>{B(T),d==null||d(T)},[d]),C=x.useCallback(T=>{g(T),h==null||h(T)},[h]),O=x.useMemo(()=>{const T=(b||"").toLowerCase();if(!T)return"0";const P=w==="spot"?u==null?void 0:u.spot:u==null?void 0:u.perpetual,L=P==null?void 0:P[T];return typeof L=="string"&&L.length>0?L:"0"},[u,w,b]),[I,M]=x.useState(!1),y=T=>{T.target===T.currentTarget?M(!0):M(!1)},A=T=>{I&&T.target===T.currentTarget&&n(),M(!1)};return e?je.createPortal(k.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 w-screen h-screen",style:{zIndex:98},children:k.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 z-[99] flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)"},onMouseDown:y,onMouseUp:A,"aria-hidden":"true",children:k.jsxs("div",{className:"relative w-[420px] max-h-[85vh] bg-fill-page-secondary overflow-auto rounded-lg p-6 shadow-xl border-[2px] border-solid border-line-divider-secondary",onClick:T=>{T.stopPropagation()},children:[k.jsxs("div",{className:"flex items-center justify-between mb-4",children:[k.jsx("h2",{className:"text-lg font-semibold text-white",children:m("deposit.title")}),k.jsx("button",{className:"text-gray-400 hover:text-gray-200 transition-colors",onClick:n,"aria-label":"Close",children:k.jsx(l0,{className:"h-4 w-4"})})]}),k.jsx(Sh,{selectedAccount:w,onAccountChange:T=>{var H,Z;const P=T||"perpetual";$(P);const L=E(P);if(!L||L.length===0)return;const j=L.find(J=>J.chainId===N),z=j?j.chainId:L[0].chainId;B(z),d==null||d(z);const _=L.find(J=>J.chainId===z),W=(_==null?void 0:_.tokenList)||[],G=W.some(J=>(J.symbol||J.token)===b)?b:((H=W[0])==null?void 0:H.symbol)||((Z=W[0])==null?void 0:Z.token)||"";G&&(g(G),h==null||h(G))},className:"w-full"}),k.jsx(Eh,{currentActiveChain:D,chainList:F,onChainChange:v,curSelectToken:b,onTokenChange:C,walletType:Eu(r)?xn:sc,accountType:w}),Eu(r)&&k.jsx(x4,{address:r.smartWalletAddress,currentActiveChain:D,selectedToken:b,accountType:w,onDeposit:f,onCopy:p,onClose:n}),B4(r)&&k.jsx(k4,{address:r.ethAddress,currentActiveChain:D,selectedToken:b,accountType:w,platformBalance:O,isLoading:t,wagmiHooks:l,onChainChange:v,onDeposit:f,onClose:n})]})})}),document.body):null},L4=({withdrawAmount:e,curSelectToken:t,tokenInfo:n,currentActiveChain:r,platformBalance:o="0",fee:s="0.00",walletType:i="evm",receiverAddress:c="",accountType:a="perpetual",onWithdrawAmountChange:u,onReceiverAddressChange:l,onAmountChanged:f,showPoolBalanceInsufficientTip:p=!1})=>{const{t:d}=vt(),h=x.useMemo(()=>{if(a==="spot"||!ln(r==null?void 0:r.chainId)){const F=new Ie(e||"0").minus(s||"0");if(F.isNegative()||F.isZero())return"0";const D=Math.min(F.decimalPlaces()??0,18);return F.decimalPlaces(D,Ie.ROUND_DOWN).toString()}return e||"0"},[e,s,r==null?void 0:r.chainId,a]),m=x.useMemo(()=>o||"0",[o]),w=x.useMemo(()=>{const F=(n==null?void 0:n.feeRate)||(n==null?void 0:n.withdrawFeeRate)||(r==null?void 0:r.feeRate)||0;try{return new Ie(F||0).times(100).toString()}catch{return"0"}},[n==null?void 0:n.feeRate,n==null?void 0:n.withdrawFeeRate,r==null?void 0:r.feeRate]),$=x.useMemo(()=>w==="0",[w]),E=x.useMemo(()=>{const F=(t||"").toUpperCase();return F==="USDT"||F==="USDC"},[t]),S=F=>{const D=F.target.value,g=fi(D,m||"0");if(g.isValid)u(g.formattedValue),g.errorType;else return g.errorType==="exceed_balance",void 0;f==null||f(g.formattedValue)},N=()=>{const F=m||"0",b=fi(F,F).formattedValue;u(b),f==null||f(b)},B=()=>{const F=parseFloat(o||"0"),D=parseFloat(e||"0");if(D>0){const b=F-D,g=Mt(Math.max(0,b).toString());return k.jsxs("span",{className:"flex items-center gap-1",children:[Mt(o||"0"),k.jsx("span",{className:"text-sm font-edgex-harmony text-functional-green-1 leading-[18px] font-medium",children:"→"}),g," ",t]})}return`${Mt(o||"0")} ${t}`};return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"bg-fill-input-primary rounded-lg px-3 py-3 my-4",children:[k.jsxs("div",{className:"flex justify-between items-center h-[18px] mb-3",children:[k.jsx("input",{type:"text",placeholder:d("deposit.amount"),value:e,onChange:S,className:"flex-1 bg-transparent text-text-primary text-sm font-medium placeholder-text-tertiary placeholder:font-normal focus:outline-none border-none p-0 h-full"}),k.jsx("button",{onClick:N,className:"text-theme-normal text-xs font-medium cursor-pointer hover:opacity-80 transition-opacity h-full flex items-center",children:d("deposit.max")})]}),k.jsx("div",{className:"h-[1px] bg-line-divider-secondary mb-2"}),k.jsxs("div",{className:"flex justify-between items-center",children:[k.jsx(Qn,{content:d("withdraw.availableDesc"),children:k.jsx("span",{className:"text-text-tertiary text-xs leading-[14px] border-b border-dashed border-line-divider-primary",children:d("deposit.available")})}),k.jsx("span",{className:"text-text-primary text-xs leading-[14px]",children:B()})]})]}),i==="mpc"&&(a==="spot"||!ln(r==null?void 0:r.chainId))?k.jsx("div",{className:"bg-fill-input-primary rounded-lg my-4 h-9 flex items-center px-3",children:k.jsx("input",{type:"text",placeholder:d("withdraw.receiverAddress"),value:c,onChange:F=>l==null?void 0:l(F.target.value),className:"flex-1 bg-transparent text-text-primary text-sm font-medium placeholder-text-tertiary placeholder:font-normal focus:outline-none border-none p-0 h-full"})}):null,k.jsx("div",{className:"bg-fill-page-secondary rounded-lg mb-4",children:ln(r==null?void 0:r.chainId)?k.jsxs(k.Fragment,{children:[k.jsx("p",{className:"text-text-tertiary text-xs leading-[18px]",children:d("withdraw.noticeDesc")}),k.jsx("a",{className:"block text-xs leading-[18px] mt-1 text-theme-normal",href:"https://edgex-1.gitbook.io/edgeX-documentation/getting-started/deposits-and-withdrawals/withdrawals",rel:"noreferrer",target:"_blank",children:d("withdraw.commonWithdraw")})]}):k.jsx("p",{className:"text-text-tertiary text-xs leading-[18px]",children:d("withdraw.crossChainTips")})}),p&&k.jsxs("div",{className:"flex mb-4",children:[k.jsx("div",{className:"w-5",children:k.jsx("img",{src:Wo,className:"w-4 h-4",alt:"Warning"})}),k.jsx("div",{className:"flex-1 text-xs text-functional-orange-1",children:d("withdraw.poolBalanceInsufficientTip")})]}),k.jsxs("div",{className:"py-4 border-t border-line-divider-secondary border-dashed",children:[k.jsxs("div",{className:"flex items-center justify-between h-[18px] leading-[18px]",children:[k.jsx(Qn,{content:k.jsxs("div",{children:[k.jsx("div",{children:d("withdraw.speedNote")}),k.jsxs("div",{className:"flex gap-1 items-center mt-1",children:[k.jsx(Uo,{selectedLevel:It.FAST,maxLevel:3}),k.jsx("span",{children:d("withdraw.speedNoteSpeed1")})]}),k.jsxs("div",{className:"flex gap-1 items-center mt-1",children:[k.jsx(Uo,{selectedLevel:It.Medium,maxLevel:3}),k.jsx("span",{children:d("withdraw.speedNoteSpeed2")})]}),k.jsxs("div",{className:"flex gap-1 items-center mt-1",children:[k.jsx(Uo,{selectedLevel:It.SLOW,maxLevel:3}),k.jsx("span",{children:d("withdraw.speedNoteSpeed3")})]})]}),children:k.jsx("span",{className:"text-text-tertiary text-sm leading-4 border-b border-dashed border-line-divider-primary",children:d("withdraw.speed")})}),k.jsx("div",{className:"flex items-center",children:k.jsx(Uo,{selectedLevel:ln(r==null?void 0:r.chainId)?It.SLOW:It.FAST,maxLevel:3})})]}),(a==="spot"||!ln(r==null?void 0:r.chainId))&&k.jsxs("div",{className:"flex items-center justify-between mt-2 h-[18px]",children:[$||!E?k.jsx("span",{className:"text-text-tertiary text-sm leading-4",children:$?d("withdraw.fee"):`${d("withdraw.fee")}/${d("withdraw.feeRate")}`}):k.jsx(Qn,{className:"w-[320px] font-normal flex items-center justify-center",content:k.jsx("span",{className:"flex items-center justify-center text-center",children:d("withdraw.feeCalculationTip")}),children:k.jsx("span",{className:"text-text-tertiary text-sm leading-4 border-b border-dashed border-line-divider-primary",children:`${d("withdraw.fee")}/${d("withdraw.feeRate")}`})}),k.jsxs("span",{className:"text-text-primary text-sm leading-4 font-medium",children:[s," ",t,!$&&` / ${w}%`]})]}),k.jsxs("div",{className:"flex items-center justify-between mt-2 h-[18px]",children:[k.jsx("span",{className:"text-text-tertiary text-sm leading-4",children:d(ln(r==null?void 0:r.chainId)?"withdraw.withdrawlAmount":"withdraw.amountToReceive")}),k.jsxs("span",{className:"text-text-primary text-sm leading-4 font-medium",children:[Mt(h)," ",t]})]})]})]})},F4=[];let Ke=null;const bm=x.forwardRef((e,t)=>{const[n,r]=x.useState(!1),[o,s]=x.useState(!1),[i,c]=x.useState({chains:[],currentActiveAccount:{wallet:"EVM",ethAddress:"",accountId:"",smartWalletAddress:""}}),a=x.useCallback(h=>{c(h||{chains:[],currentActiveAccount:{wallet:"EVM",ethAddress:"",accountId:"",smartWalletAddress:""}}),r(!0)},[]),u=x.useCallback(h=>{c(m=>({...m,...h}))},[]),l=x.useCallback(()=>{r(!1),s(!1),i.onClose&&i.onClose()},[i.onClose]),f=x.useCallback(h=>{s(h)},[]),p=x.useCallback(()=>n,[n]),d=x.useCallback(()=>o,[o]);return x.useImperativeHandle(t,()=>({openWithdraw:a,closeWithdraw:l,updateWithdrawOptions:u,setWithdrawLoading:f,isOpen:p,isLoading:d}),[a,l,u,f,p,d]),x.useEffect(()=>(Ke={openWithdraw:a,closeWithdraw:l,updateWithdrawOptions:u,setWithdrawLoading:f,isOpen:p,isLoading:d},()=>{Ke=null}),[a,l,u,f,p,d]),n?k.jsx(xm,{isOpen:n,isLoading:o,onClose:l,config:i.config||{symbol:"USDT"},currentActiveAccount:i.currentActiveAccount,chains:i.chains||F4,spotChains:i.spotChains,balances:i.balances,defaultChainId:i.defaultChainId,defaultSymbol:i.defaultSymbol,defaultAmount:i.defaultAmount,defaultAccountType:i.defaultAccountType,currentEquity:i.currentEquity??5e3,platformBalance:i.platformBalance||"0",fee:i.fee,wagmiHooks:i.wagmiHooks,onWithdraw:i.onWithdraw,onAccountChange:i.onAccountChange,onChainChange:i.onChainChange,onTokenChange:i.onTokenChange,onAmountChanged:i.onAmountChanged}):null});bm.displayName="WithdrawManager";const gm=e=>{if(!Ke){console.error("WithdrawManager not initialized. Make sure to render <WithdrawManager /> in your app.");return}Ke.openWithdraw(e||{chains:[],currentActiveAccount:{wallet:"EVM",ethAddress:"",accountId:"",smartWalletAddress:""}})},ym=()=>{if(!Ke){console.error("WithdrawManager not initialized. Make sure to render <WithdrawManager /> in your app.");return}Ke.closeWithdraw()},wm=e=>{if(!Ke){console.error("WithdrawManager not initialized. Make sure to render <WithdrawManager /> in your app.");return}Ke.updateWithdrawOptions(e)},pi=e=>{if(!Ke){console.error("WithdrawManager not initialized. Make sure to render <WithdrawManager /> in your app.");return}Ke.setWithdrawLoading(e)},D4=()=>Ke?Ke.isOpen():!1,vm=()=>Ke?Ke.isLoading():!1,R4=()=>({openWithdraw:gm,closeWithdraw:ym,updateWithdrawOptions:wm,setWithdrawLoading:pi,isOpen:D4,isLoading:vm}),j4=({walletType:e,chains:t,spotChains:n=[],defaultChainId:r,defaultSymbol:o,defaultAmount:s="",defaultAccountType:i="perpetual",currentEquity:c,platformBalance:a="0",balances:u,fee:l="0.00",isLoading:f=!1,onWithdraw:p,onClose:d,onChainChange:h,onTokenChange:m,onAmountChanged:w,onAccountChange:$})=>{var H;const{t:E}=vt(),[S,N]=x.useState(i),B=x.useCallback(Z=>Z==="spot"&&n&&n.length>0?n:t,[t,n]),F=x.useMemo(()=>B(S),[S,B]),D=x.useMemo(()=>{if(!F||F.length===0)return{chainId:1,tokenSymbol:""};const Z=de=>{const se=de||[];if(!se.length)return"";const ee="USDC".toUpperCase(),Nn=se.find(gt=>(gt.token||gt.symbol||"").toUpperCase()===ee)||se[0];return Nn.token||Nn.symbol||""};if(o){const de=o==null?void 0:o.toUpperCase();for(const se of F){const pe=se.tokenList||[];let ee;if(de&&(ee=pe.find(Se=>(Se.token||Se.symbol||"").toUpperCase()===de)),ee){const Se=ee.token||ee.symbol||o||"";return{chainId:se.chainId,tokenSymbol:Se}}}}if(r){const de=F.find(ee=>ee.chainId===r)||F[0],se=de.tokenList||[],pe=Z(se);return{chainId:de.chainId,tokenSymbol:pe}}const J="USDC",oe=de=>Array.isArray(de.tokenList)&&de.tokenList.some(se=>(se.token||se.symbol||"").toUpperCase()===J),me=F.find(oe)||F[0];if(!me)return{chainId:1,tokenSymbol:""};const ge=Z(me.tokenList);return{chainId:me.chainId,tokenSymbol:ge}},[F,r,o]),[b,g]=x.useState(()=>D.chainId),[v,C]=x.useState(()=>D.tokenSymbol),[O,I]=x.useState(s),[M,y]=x.useState(""),A=x.useCallback(Z=>{g(Z),h==null||h(Z)},[h]),T=x.useCallback(Z=>{C(Z),m==null||m(Z)},[m]),P=x.useRef(!0),L=x.useRef(v),j=x.useRef(b);x.useEffect(()=>{if(P.current){P.current=!1,L.current=v,j.current=b;return}(L.current!==v||j.current!==b)&&(I(""),L.current=v,j.current=b)},[v,b]);const z=F&&F.length>0?F.find(Z=>Z.chainId===b)||F[0]:null,_=(H=z==null?void 0:z.tokenList)==null?void 0:H.find(Z=>Z.token===v),W=x.useMemo(()=>{const Z=new Ie(O||"0"),J=new Ie(l||"0"),oe=ln(b);return _!=null&&_.minWithdrawSize&&Z.lt(_.minWithdrawSize)?{text:E("withdraw.minWithdrawParsed",{amount:_.minWithdrawSize,token:_.symbol||_.token}),disabled:!0}:!O||Z.isZero()||!oe&&Z.isLessThan(J)?{text:E("withdraw.confirmWithdraw"),disabled:!0}:e==="mpc"&&(!oe||S==="spot")&&!M.trim()?{text:E("withdraw.invalidReceiverAddress"),disabled:!0}:{text:E("withdraw.confirmWithdraw"),disabled:!1}},[E,b,O,e,M,l,S,_]),K=x.useMemo(()=>{const Z=(v||"").toLowerCase();if(!Z)return a||"0";const J=S==="spot"?u==null?void 0:u.spot:u==null?void 0:u.perpetual,oe=J==null?void 0:J[Z];return typeof oe=="string"&&oe.length>0?oe:a||"0"},[u,S,v,a]),G=x.useCallback(async()=>{pi(!0);try{if(p){const J={amount:new Ie(O||"0").toString(),chainId:b,tokenAddress:(_==null?void 0:_.tokenAddress)||"",coinId:(_==null?void 0:_.coinId)||"",tokenSymbol:v,accountType:S,selectedToken:_};e==="mpc"&&(!ln(b)||S==="spot")&&(J.receiverAddress=M),p(J)}}catch{pi(!1)}},[p,S,_,O,b,v,e,M]);return!F||F.length===0?k.jsx("div",{className:"text-center py-8",children:k.jsx("p",{className:"text-gray-400",children:"No chains available"})}):z?k.jsxs(k.Fragment,{children:[k.jsx(Sh,{selectedAccount:S,onAccountChange:Z=>{var Se,Nn;const J=Z||"perpetual";N(J),$==null||$(J);const oe=B(J);if(!oe||oe.length===0)return;const me=oe.find(gt=>gt.chainId===b),ge=me?me.chainId:oe[0].chainId;g(ge),h==null||h(ge);const de=oe.find(gt=>gt.chainId===ge),se=(de==null?void 0:de.tokenList)||[],ee=se.some(gt=>(gt.symbol||gt.token)===v)?v:((Se=se[0])==null?void 0:Se.symbol)||((Nn=se[0])==null?void 0:Nn.token)||"";ee&&(C(ee),m==null||m(ee))},className:"w-full"}),k.jsx(Eh,{currentActiveChain:z,chainList:F,onChainChange:A,curSelectToken:v,onTokenChange:T,walletType:"EVM",txType:"withdraw"}),k.jsx(L4,{withdrawAmount:O,curSelectToken:v,tokenInfo:_,curSelectTokenData:{balance:_==null?void 0:_.balance,allowance:_==null?void 0:_.allowance},currentActiveChain:z,currentEquity:c||0,decimals:(_==null?void 0:_.decimals)||6,platformBalance:K,fee:l,walletType:e,accountType:S,receiverAddress:M,onWithdrawAmountChange:I,onReceiverAddressChange:y,onAmountChanged:w}),k.jsxs("button",{className:`w-full h-[38px] text-sm rounded-xl font-medium transition-colors flex items-center justify-center gap-2 ${W.disabled||f?"bg-text-disabled text-text-secondary cursor-not-allowed":"bg-fill-btn-primary text-text-on-sec-btn"}`,onClick:G,disabled:W.disabled||f,children:[f&&k.jsx(Vo,{size:"xs"}),W.text]})]}):k.jsx("div",{className:"text-center py-8",children:k.jsx("p",{className:"text-gray-400",children:"Loading..."})})},xm=({isOpen:e,isLoading:t=!1,defaultAccountType:n="perpetual",onClose:r,config:o,currentActiveAccount:s,chains:i,spotChains:c=[],defaultChainId:a,defaultSymbol:u,defaultAmount:l="",currentEquity:f=5e3,platformBalance:p="0",balances:d,fee:h,wagmiHooks:m,onWithdraw:w,onChainChange:$,onTokenChange:E,onAmountChanged:S,onAccountChange:N})=>{const{t:B}=vt(),[F,D]=x.useState(!1),b=v=>{v.target===v.currentTarget?D(!0):D(!1)},g=v=>{F&&v.target===v.currentTarget&&r(),D(!1)};return e?je.createPortal(k.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 w-screen h-screen",style:{zIndex:98},children:k.jsx("div",{className:"fixed top-0 left-0 right-0 bottom-0 z-[99] flex items-center justify-center",style:{background:"rgba(0, 0, 0, 0.6)",backdropFilter:"blur(10px)",WebkitBackdropFilter:"blur(10px)"},onMouseDown:b,onMouseUp:g,"aria-hidden":"true",children:k.jsxs("div",{className:"relative w-[420px] max-h-[85vh] bg-fill-page-secondary overflow-auto rounded-lg p-6 shadow-xl",onClick:v=>{v.stopPropagation()},children:[k.jsxs("div",{className:"flex items-center justify-between mb-4",children:[k.jsx("h2",{className:"text-lg font-semibold text-white",children:B("withdraw.withdraw")}),k.jsx("button",{className:"text-gray-400 hover:text-gray-200 transition-colors",onClick:r,"aria-label":"Close",children:k.jsx(l0,{className:"h-4 w-4"})})]}),k.jsx(j4,{chains:i,spotChains:c,walletType:Eu(s)?"mpc":"evm",defaultChainId:a,defaultSymbol:u,defaultAmount:l,defaultAccountType:n,currentEquity:f,platformBalance:p,balances:d,fee:h,isLoading:t,wagmiHooks:m,onWithdraw:w,onClose:r,onChainChange:$,onTokenChange:E,onAmountChanged:S,onAccountChange:N})]})})}),document.body):null};re.ChromeLoader=Vo,re.ComponentProvider=Gm,re.DEFAULT_LOCALE=qo,re.Deposit=mm,re.DepositManager=um,re.LOCALE_NAMES=Hm,re.LoadingSpinner=Vo,re.SUPPORTED_LOCALES=bi,re.Tooltip=Qn,re.Withdraw=xm,re.WithdrawManager=bm,re.closeDeposit=fm,re.closeWithdraw=ym,re.formatThousands=Zm,re.isDepositLoading=pm,re.isWithdrawLoading=vm,re.openDeposit=lm,re.openWithdraw=gm,re.setDepositLoading=di,re.setWithdrawLoading=pi,re.updateDepositOptions=dm,re.updateWithdrawOptions=wm,re.useComponentConfig=Lu,re.useDeposit=f5,re.useDepositManager=O4,re.useTranslation=vt,re.useWithdraw=d5,re.useWithdrawManager=R4,Object.defineProperty(re,Symbol.toStringTag,{value:"Module"})});
179
179
  //# sourceMappingURL=index.umd.js.map