import{j as e,al as s,a7 as W,bb as B,cC as N,aT as v,X as d}from"./vendor-mui-core-CDEc-eG6.js";import{r as l}from"./vendor-react-DX7tU9aY.js";import{y as I}from"./vendor-utils-_C9URqjS.js";import{b4 as L}from"./vendor-ux-bFYdDLNG.js";import{v as $,u as E,w as T}from"./index-DGZk149v.js";import{W as z}from"./did-address-B_YXB1wQ.js";import{a as A}from"./page-header-CEL5h6do.js";import{S as D}from"./layout-D7JBXyAe.js";import{S as F}from"./step-actions-DiRyepq4.js";import{S as m}from"./button-DJOGWCMI.js";import"./vendor-hooks-BrgYeCrj.js";import"./vendor-arcblock-DY2miJjh.js";import"./content-layout-D49-hpq6.js";import"./use-mobile-DUKvJoqs.js";function P({onNext:n=()=>{},onPrevious:u=()=>{}}){const{locale:x,t}=l.useContext(L),{blocklet:a,gas:c,tokenInfo:f,actions:h}=$(),{api:j}=E(),[y,o]=l.useState(!1),{need:p="",current:g="",owe:r=99999,deficiency:b,symbol:k="",endpoint:i}=c||{},{origin:C="/"}=i?new URL(i):{};l.useEffect(()=>{const w=setInterval(()=>{h.refreshFuel()},2e3);return()=>{clearInterval(w)}},[]);const S=()=>{o(!1)};return c?e.jsxs(R,{children:[e.jsx("div",{className:"header",children:e.jsx(A,{title:t("setup.fuel.title"),onClickBack:u})}),e.jsxs(s,{className:"qr-body",children:[e.jsxs(s,{className:"tip",sx:{mb:6},children:[t("setup.fuel.tipStart").replace("slot",""),e.jsx("span",{className:"amount",children:`${p} ${k}`}),t("setup.fuel.tipEnd")]}),e.jsx(s,{sx:{fontSize:16,fontWeight:"fontWeightBold",mb:.5},children:t("setup.fuel.addressTitle")}),e.jsxs(s,{sx:{display:"flex",alignItems:"center"},children:[e.jsx(z,{className:"address",did:a.appDid}),e.jsx(B,{style:{lineHeight:1},target:"_blank",href:I(C,"/explorer/accounts/",a.appDid),underline:"hover",children:e.jsx(N,{className:"icon-launch"})})]}),e.jsx(s,{sx:{my:2},children:e.jsx(m,{color:"primary",onClick:()=>o(!0),disabled:!r,children:t("setup.fuel.fuelApp")})}),e.jsx(T,{popup:!0,open:y,action:"fuel",checkFn:j.get,checkTimeout:600*1e3,onSuccess:S,onClose:()=>o(!1),locale:x,messages:{title:t("setup.connect.title"),scan:t("setup.connect.scan"),confirm:t("setup.connect.confirm"),success:t("setup.connect.success")},extraParams:{amount:b,...f,endpoint:i}}),e.jsxs(s,{sx:{display:"flex",color:"text.secondary"},children:[e.jsxs(s,{sx:{display:"flex"},children:[e.jsxs(s,{children:[t("setup.fuel.need"),":"]}),e.jsx(s,{sx:{ml:.5,color:"primary.main",fontWeight:"fontWeightBold"},children:p})]}),e.jsxs(s,{sx:{display:"flex",ml:3},children:[e.jsxs(s,{children:[t("setup.fuel.current"),":"]}),e.jsx(s,{sx:{ml:.5,color:r>0?"error.main":"primary.main",fontWeight:"fontWeightBold"},children:g})]})]})]}),e.jsx(F,{mt:8,children:e.jsx(m,{disabled:r>0,onClick:()=>n(),children:t("setup.next")})})]}):e.jsx(s,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%"},children:e.jsx(W,{})})}P.propTypes={onNext:d.func,onPrevious:d.func};const R=v(D)`
  .qr-body {
    width: 580px;
    ${n=>n.theme.breakpoints.down("md")} {
      width: 80%;
    }
    display: flex;
    flex-direction: column;
    align-items: center;

    .tip {
      font-size: 16px;
      font-weight: bold;
    }

    .address {
      width: 100%;
      text-align: center;
    }

    .amount {
      color: ${n=>n.theme.palette.primary.main};
    }

    .icon-launch {
      font-size: 16px;
      margin-left: 6px;
      line-height: 1;
      color: ${n=>n.theme.palette.primary.main};
    }
  }
`;export{P as default};
