import{j as e,al as s,a7 as B,bb as W,cB as N,aT as I,X as d}from"./vendor-mui-core-D7t4vMS5.js";import{r as l}from"./vendor-react-DX7tU9aY.js";import{z as v}from"./vendor-utils-BzQg432x.js";import{b3 as L}from"./vendor-ux-Dl3wVbv_.js";import{x as $,u as z,w as E}from"./index-Ca33rdd_.js";import{W as T}from"./did-address-DRYM96gB.js";import{a as A}from"./page-header-B0HpJClf.js";import{S as D}from"./layout-CydCBGqn.js";import{S as F}from"./step-actions-CArEuzNw.js";import{S as m}from"./button-B_Qd9K_t.js";import"./vendor-hooks-DAZ1H6Va.js";import"./vendor-arcblock-ivFYo5vP.js";import"./content-layout-CanSZTqf.js";import"./use-mobile-TAIHvgoJ.js";function P({onNext:n=()=>{},onPrevious:x=()=>{}}){const{locale:u,t}=l.useContext(L),{blocklet:a,gas:c,tokenInfo:f,actions:h}=$(),{api:j}=z(),[y,o]=l.useState(!1),{need:p="",current:g="",owe:r=99999,deficiency:b,symbol:k="",endpoint:i}=c||{},{origin:S="/"}=i?new URL(i):{};l.useEffect(()=>{const w=setInterval(()=>{h.refreshFuel()},2e3);return()=>{clearInterval(w)}},[]);const C=()=>{o(!1)};return c?e.jsxs(R,{children:[e.jsx("div",{className:"header",children:e.jsx(A,{title:t("setup.fuel.title"),onClickBack:x})}),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(T,{className:"address",did:a.appDid}),e.jsx(W,{style:{lineHeight:1},target:"_blank",href:v(S,"/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(E,{popup:!0,open:y,action:"fuel",checkFn:j.get,checkTimeout:600*1e3,onSuccess:C,onClose:()=>o(!1),locale:u,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(B,{})})}P.propTypes={onNext:d.func,onPrevious:d.func};const R=I(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};
