Files
to_session/text/3.65.22_0/scripts/ui/chunk-SN5KMB4Y.js
Administrator a0720d80dc fefdwef
2025-11-12 12:54:37 +08:00

8 lines
6.9 KiB
JavaScript

import{a as q}from"./chunk-GAE6SO53.js";import{a as fe,b as Ce,d as pe,g as O}from"./chunk-3KQ34RWP.js";import{c as Z,d as $}from"./chunk-PICDHKDX.js";import{a as Y,b as L,c as me}from"./chunk-P65JCIKD.js";import{g as X}from"./chunk-JJLCPFOT.js";import{a as E}from"./chunk-YYLTB5E4.js";import{e as G}from"./chunk-4FLAC4IK.js";import{o as _}from"./chunk-64WUUNDB.js";import{Ba as ae,Fa as ue,Ga as k,Ha as H,Kb as le,jc as J,k as se}from"./chunk-QY24TFF7.js";import{J as S,K as V,Td as ie,Xd as Se,gd as oe,ia as z,md as ce,od as Me}from"./chunk-I5E2ION7.js";import{H as te,n as R,s as Q}from"./chunk-SQMXULWT.js";import{H as K,L as re,ra as Ne,y as U}from"./chunk-GSIHKWLV.js";import{b as j}from"./chunk-BF2V36QE.js";import{a as Re}from"./chunk-EFTDVKCQ.js";import{f as T,o as P,q as b}from"./chunk-QTLWQ5AJ.js";P();b();var M=T(j()),C=T(_());Ne();te();P();b();var ye=T(j()),de=T(J());z();function he(){let e=L(),n=(0,de.useDispatch)();return(0,ye.useCallback)(async t=>{let r=await n(fe(t)),c={};return r&&Object.entries(r).forEach(([o,s])=>{let l=[];s.forEach(i=>{let m;"childrenCoin"in i&&i.childrenCoin?.length&&(m=i.childrenCoin?.map(f=>({...f,currencyAmount:S(f.currencyAmountUSD,e.usdToThisRate)}))),l.push({...i,childrenCoin:m,currencyAmount:S(i.currencyAmountUSD,e.usdToThisRate)})}),c[o]=l}),c},[e.usdToThisRate,n])}P();b();var ge=T(j()),Pe=T(J()),F=T(_());z();var I=()=>{let e=(0,Pe.useSelector)(le),n=O();return(0,F.useCreation)(()=>{let t={},{symbol:r}=e;return Object.keys(n).forEach(c=>{t[c]={currencySymbol:r,usdPrice:n?.[c]?.coinToUSDRate,currencyPrice:S(n?.[c]?.coinToUSDRate,e?.usdToThisRate),priceChangePercent24h:n?.[c]?.coinPriceChangePercent24h}}),t},[n,e])},be=e=>{let n=I(),t=L(),{data:r,run:c}=(0,F.useRequest)(k,{manual:!0,ready:!0,retryCount:3,staleTime:36e5,cacheTime:864e5});return(0,ge.useEffect)(()=>{!n[e]&&ae(e)&&c(+e)},[n,e]),(0,F.useCreation)(()=>{let o=n[e];if(o)return o;if(r&&t){let{currencyAmount:s,priceChangePercent24h:l}=r;return{currencySymbol:t.symbol,usdPrice:s,currencyPrice:S(s,t.usdToThisRate),priceChangePercent24h:l}}return null},[n,e,t,r])};P();b();var Te=T(J());function ee(){return(0,Te.useSelector)(se)}Me();Se();z();var we=e=>!!e&&!Number.isNaN(e),W=(e={})=>{let n=q(),t=Y(),r=ee(),c=I(),o=O(),s=(0,C.useLatest)(n),l=(0,C.useLatest)(c),i=(0,C.useLatest)(o),{withPrice:m=!1,withPriceChangePercent24h:f=!1}=e||{},[y,g]=(0,M.useState)(void 0),{runAsync:h}=(0,C.useRequest)(H,{manual:!0,cacheKey:y,retryCount:3,staleTime:36e5,cacheTime:864e5});return(0,M.useCallback)(async(d,a)=>{if(d===0||!r||Number.isNaN(d))return null;let p;if(typeof d<"u")p=s?.current?.[d];else if(a){let u=Object.values(n);if(a.aggregation&&a.symbol)return t[a.symbol]?{...t[a.symbol][0],childrenCoin:t[a.symbol]}:null;if($(a)){let N=Q(u,a);N.length>0&&(p=N[0])}}if(!p&&d!==0){let u;typeof d<"u"&&!Number.isNaN(d)?u={coinId:d}:a&&(u=!K(a)&&ue(a)?a:null),u&&(g(Z(u)),p=await h(u))}if(!p)return null;let A;if((m||f)&&!s?.current?.[d]&&(A=await k(p.coinId)),m){let{currencySymbol:u,usdPrice:B,currencyPrice:N}=l?.current?.[d]??A??{};p={...p,currencySymbol:u,usdPrice:B,currencyPrice:N}}if(f){let u=i?.current?.[d]?.coinPriceChangePercent24h??A?.priceChangePercent24h;p={...p,priceChangePercent24h:u}}return p},[m,f,n,t,h,r])},xe=(e,n,t)=>(0,C.useCreation)(()=>{let r;if(!(t||e===0)&&(typeof e<"u"&&!Number.isNaN(e)?r={coinId:e}:r=K(n)?null:n,r))return Z(r)},[e,n,t]),w=(e,n={},t)=>{let r=Y(),c=q(),o=ee(),{withPrice:s,withPriceChangePercent24h:l}=n,i=me(t),m=[e,c,r,i,o],f=[],y=(0,C.useCreation)(()=>{let u;if(e===0||!o||Number.isNaN(e))return null;if(typeof e<"u")u=c?.[e];else if(i){let B=Object.values(c);if(i.aggregation&&i.symbol)return r[i.symbol]?{...r[i.symbol][0],childrenCoin:r[i.symbol]}:null;if($(i)){let v=Q(B,i);v.length>0&&(u=v[0])}}return u||null},m),g=!!y,h=xe(e,i,g),{data:d,run:a}=(0,C.useRequest)(H,{manual:!0,ready:!0,cacheKey:h,retryCount:3,staleTime:36e5,cacheTime:864e5});(0,M.useEffect)(()=>{if(!g&&o&&!!h){let u=we(e)?{coinId:e}:i;a(u)}},[g,o,h,e,i]);let p=y||d,A=be(s||l?p?.coinId:null);return f.push(p,A),(0,C.useCreation)(()=>{if(!p)return null;let u=p;if(s&&A){let{currencySymbol:B,usdPrice:N,currencyPrice:v}=A;u={...u,currencySymbol:B,usdPrice:N,currencyPrice:v}}if(l){let{priceChangePercent24h:B}=A;u={...u,priceChangePercent24h:B}}return u},f)},Fe=e=>{let n=W(e),t=X(),r=pe(),c=he();return(0,C.useMemoizedFn)(async(o,s)=>{let l=await n(o);if(!l)return null;let i;s&&s!==t?i=(await c({walletIds:[s],coinId:o,chainId:l.chainId,flatten:!0}))[s]??[]:i=r;let{coinAmountInt:m="0",currencyAmount:f="0",currencyAmountUSD:y="0"}=U(i,g=>g?.coinId===o)||{};return{...l,coinAmountInt:m,currencyAmount:f,currencyAmountUSD:y,coinAmount:V(m,10**l?.decimals)}},[r,t,n])};function We(e,{key:n,coinId:t,addressType:r,localType:c}){return U(e,o=>{let s;if(n?s=o.key===n:s=o.coinId===t,r){let l=ie[ce(c)]?.[r];s=s&&l===o?.addressType}return s})}var De=(e,n,t)=>{let{addressType:r,key:c,withBalanceStatus:o}=t||{},s=w(e,t,c?{key:c}:void 0),l=X(),i=n||l,m=Ce(i,{withBalanceStatus:o}),f=!1,y;o?(y=m?.balance?.coins,f=!m?.loading):(y=m?.coins,f=!!m),y=y||[];let g=(0,C.useCreation)(()=>We(y,{key:c,coinId:e,addressType:r,localType:s?.localType}),[y,i,e,r,c,s?.localType]),{coinAmountInt:h,currencyAmount:d}=g||{};return(0,C.useCreation)(()=>{if(!s)return null;let a={...s,coinAmountInt:h,currencyAmount:d};return o&&(a.requestBalance=m?.request,a.isBalanceLoading=!f,a.isBalanceLoadError=!!m?.error),re(h)?f?(a.coinAmountInt="0",a.coinAmount="0",a.currencyAmount="0",a.currencyAmountUSD="0",a):(a.coinAmount=void 0,a):(a.coinAmount=V(h,10**s.decimals),a)},[s,h,f,m,o])},ve=(e,n)=>{let t=w(e,n),r=w(t?.baseCoinId,n);return[t,r||t]},Ae=e=>{let n=W(e);return(0,C.useMemoizedFn)(async t=>{let r=await n(t),c=await n(r?.baseCoinId);return[r,c||r]},[n])};var ke=(e={})=>{let n=Ae(e);return(0,C.useMemoizedFn)(async t=>{let[,r]=await n(t),c=r?.coinId;return oe.indexOf(c)!==-1},[n])},Pn=(e,n={})=>{let t=ke(n),[r,c]=(0,M.useState)(!1);return(0,C.useAsyncEffect)(async()=>{let o=await t(e);c(o)},[t]),r};P();b();P();b();var D=T(_()),ne=T(Re());te();var Ee=(e={})=>{let{currencyId:n,formatted:t=!0,useApproximate:r}=e||{},c=E(n),{symbol:o,usdToThisRate:s}=c,l=W({withPrice:!0});return(0,D.useMemoizedFn)(async(i,m)=>{let f=await l(i),y=R.div(m,10**f?.decimals),g=R.mul(f?.usdPrice,s),h=R.mul(y,g);return t?G(h,{useApproximate:r,currencySign:o}).value:h},[o,t,l,s,r])},Be=(e,n,t={})=>{let{currencyId:r,useMinPrecision:c=!0}=t||{},o=w(e,{withPrice:!0}),{usdToThisRate:s}=E(r);return(0,D.useCreation)(()=>{if((0,ne.isNil)(o?.usdPrice))return null;let l=c?R.div(n,10**o?.decimals):n,i=R.mul(o?.usdPrice,s);return R.mul(l,i)},[s,n,o?.usdPrice,o?.decimals,c])},Le=(e,n,t={})=>{let{currencyId:r,useApproximate:c}=t||{},o=Be(e,n,t),{symbol:s}=E(r);return(0,D.useCreation)(()=>(0,ne.isNil)(o)?"":G(o,{currencySign:s,useApproximate:c}).value,[s,o,c])};export{he as a,ee as b,W as c,w as d,Fe as e,De as f,ve as g,Pn as h,Ee as i,Be as j,Le as k};
window.inOKXExtension = true;
window.inMiniApp = false;
window.ASSETS_BUILD_TYPE = "publish";
//# sourceMappingURL=chunk-SN5KMB4Y.js.map