@spicenet-io/spiceflow-ui 1.10.23 → 1.10.24
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.cjs.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
from { transform: rotate(0deg); }
|
|
45
45
|
to { transform: rotate(360deg); }
|
|
46
46
|
}
|
|
47
|
-
`}),!f&&l&&l.length>1&&e.jsx("div",{style:{overflow:"hidden",maxHeight:y?"200px":"0px",opacity:y?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease",marginBottom:y?"16px":"0"},children:e.jsx("div",{style:{maxHeight:"180px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"8px"},children:l.map((O,X)=>e.jsxs("div",{style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontWeight:600,fontSize:"13px",color:"#111827",fontFamily:'"IBM Plex Mono", monospace'},children:O.asset.symbol}),O.amount&&e.jsx("span",{style:{fontSize:"12px",color:"#6b7280"},children:O.amount})]}),e.jsx("span",{style:{fontSize:"12px",color:O.success?"#10b981":"#ef4444",fontWeight:500},children:O.success?"\u2713":"\u2717"})]},X))})}),!f&&!R&&l&&e.jsx("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginBottom:"16px"},children:e.jsx("p",{style:{fontSize:"13px",color:"#dc2626",margin:0,lineHeight:1.5},children:l.find(O=>!O.success)?.error||`${s.charAt(0).toUpperCase()+s.slice(1)} failed. Please try again.`})}),!f&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[!R&&I&&e.jsxs("button",{onClick:I,onMouseEnter:()=>h("retry-tx"),onMouseLeave:()=>{h(null),A(null)},onMouseDown:()=>A("retry-tx"),onMouseUp:()=>A(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:m==="retry-tx"?"#d43d3d":C==="retry-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:m==="retry-results"?"scale(0.98)":C==="retry-results"?"translateY(-2px)":"none",boxShadow:m==="retry-tx"?"1px 1px 0px black":C==="retry-tx"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["TRY AGAIN $",s]}),R&&e.
|
|
47
|
+
`}),!f&&l&&l.length>1&&e.jsx("div",{style:{overflow:"hidden",maxHeight:y?"200px":"0px",opacity:y?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease",marginBottom:y?"16px":"0"},children:e.jsx("div",{style:{maxHeight:"180px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"8px"},children:l.map((O,X)=>e.jsxs("div",{style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontWeight:600,fontSize:"13px",color:"#111827",fontFamily:'"IBM Plex Mono", monospace'},children:O.asset.symbol}),O.amount&&e.jsx("span",{style:{fontSize:"12px",color:"#6b7280"},children:O.amount})]}),e.jsx("span",{style:{fontSize:"12px",color:O.success?"#10b981":"#ef4444",fontWeight:500},children:O.success?"\u2713":"\u2717"})]},X))})}),!f&&!R&&l&&e.jsx("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginBottom:"16px"},children:e.jsx("p",{style:{fontSize:"13px",color:"#dc2626",margin:0,lineHeight:1.5},children:l.find(O=>!O.success)?.error||`${s.charAt(0).toUpperCase()+s.slice(1)} failed. Please try again.`})}),!f&&e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[!R&&I&&e.jsxs("button",{onClick:I,onMouseEnter:()=>h("retry-tx"),onMouseLeave:()=>{h(null),A(null)},onMouseDown:()=>A("retry-tx"),onMouseUp:()=>A(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:m==="retry-tx"?"#d43d3d":C==="retry-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:m==="retry-results"?"scale(0.98)":C==="retry-results"?"translateY(-2px)":"none",boxShadow:m==="retry-tx"?"1px 1px 0px black":C==="retry-tx"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["TRY AGAIN $",s]}),R&&e.jsx("button",{onClick:B,onMouseEnter:()=>h("continue-tx"),onMouseLeave:()=>{h(null),A(null)},onMouseDown:()=>A("continue-tx"),onMouseUp:()=>A(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:m==="continue-tx"?"#d43d3d":C==="continue-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:m==="continue-tx"?"scale(0.98)":C==="continue-tx"?"translateY(-2px)":"none",boxShadow:m==="continue-tx"?"1px 1px 0px black":C==="continue-results"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"DONE"})]})]}),e.jsx("style",{children:`
|
|
48
48
|
@keyframes slideUp {
|
|
49
49
|
from {
|
|
50
50
|
transform: translateY(100%);
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
transform: translateY(100%);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`})]})},fs=({depositBatches:t,tokenAddress:o,tokenDecimals:a,tokenTransferAmount:n,supportedChains:s,supportedTokens:l,theme:c="light",styles:i,className:x="",depositInputHook:g,onDepositSuccess:u,onDepositError:d,onTopUp:S,submitButtonText:I})=>{const k=ce.createTheme(c),f={...k,typography:{...k.typography,fontFamily:i?.fontFamily||k.typography.fontFamily},colors:{...k.colors,primary:i?.primaryColor||k.colors.primary,primaryHover:i?.primaryColor?`${i.primaryColor}dd`:k.colors.primaryHover}},p=Mt(),{isReady:w,isAuthenticated:E,isConnected:y,address:b,provider:C,actions:h}=p,[m,A]=r.useState(null),{assets:B,loading:M,error:R,hasBalance:te,refetch:O}=xs({address:b,supportedChains:s,enabled:y,refetchInterval:3e4}),[X,K]=r.useState(!1),[H,q]=r.useState(null),[v,N]=r.useState(!1),[D,Y]=r.useState(!1),[W,ee]=r.useState(!1),ie=r.useRef(null),{intentStatus:$,startStatusPolling:be,clearStatus:Q}=Ft({checkStepStatus:(se,L)=>Fe.checkStepStatus(se,L)});r.useEffect(()=>{if($?.overallStatus==="success"&&$.intentId&&ie.current!==$.intentId&&m&&b){const se=$.steps.find(L=>L.transactionHash);if(se?.transactionHash){ie.current=$.intentId;const L=le.parseUnits(m.amount,m.asset.decimals);Fe.submitSpiceDeposit({user:b,txHash:se.transactionHash,sender:b,tokenAddress:m.asset.address,chainId:m.asset.chainId,amount:L.toString(),isDeposit:!1}).then(()=>{O()}).catch(()=>{ie.current=null})}}},[$,b]),r.useEffect(()=>{g&&g.assetAmount!==m?.amount&&m&&A({...m,amount:g.assetAmount})},[g?.assetAmount,m]),r.useEffect(()=>{if(!g?.selectedAsset)return;const se=g.selectedAsset,L=se.address.toLowerCase(),oe=L==="0x0"||L==="0x0000000000000000000000000000000000000000"||L==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",xe=B.find(j=>{const z=j.address.toLowerCase();return(oe&&j.isNative||z===L)&&(se.chainId?j.chainId===se.chainId:!0)});xe&&A(j=>({asset:xe,amount:j?.amount||g.assetAmount||""}))},[g?.selectedAsset,B,g?.assetAmount]);const P=r.useCallback(()=>{q(null)},[]),ue=se=>{A({asset:se,amount:m?.amount||""}),g?.setSelectedAsset&&g.setSelectedAsset({symbol:se.symbol,address:se.address,decimals:se.decimals,chainId:se.chainId}),P()},ne=r.useCallback(se=>{m&&(r.startTransition(()=>{A({...m,amount:se}),P()}),g&&g.setAssetAmount(se))},[m,g,P]),Ce=async()=>{if(!(!m||!b||t.length===0)){if(!w||!E){q(`Please authenticate with ${C||"wallet provider"} to continue`);return}K(!0),q(null),ee(!0);try{const se=[...t],L=[...new Set(se.map(F=>F.chainId))],oe=[];for(const F of L){const _=ze(F),de=ut(F),ge=await qe.getAccountNonce(b,_),Re=await h.signAuthorization({contractAddress:de,chainId:F,nonce:Number(ge)});oe.push(Re)}const xe=qe.hashChainBatches(se),j=Math.floor(Date.now()/1e3)+60*10,z=qe.getIntentHash(0n,BigInt(j),xe),J=await h.signMessage({raw:z}),re=typeof J=="string"?J:J.signature;if(!re)throw new Error("Failed to sign intent authorization");const pe={mode:"7702",signatureType:"ecdsa",signature:re,nbf:0,exp:j,chainBatches:xe.map(F=>({hash:F.hash,chainId:F.chainId,tokenTransfers:[{from:"solver",to:b,token:"0x0000000000000000000000000000000000000000",amount:le.parseUnits("0.00001",18)},{from:"solver",to:b,token:o,amount:n??le.parseUnits(m.amount,a)}],calls:F.calls}))},he=await Fe.createAction({user:b,chainAuthorizations:oe.map(F=>({...F,r:F.r,s:F.s,yParity:F.yParity,address:F.address,chainId:Number(F.chainId),nonce:Number(F.nonce)})),intents:[pe]});if(he){const F=jt(se,Re=>`Chain ${Re}`),[_,de]=he.intentIds[0].split("/"),ge=parseInt(de||"0",10);be(he.intentIds[0],F);for(let Re=0;Re<se.length;Re++)await Fe.executeStep(_,ge,Re,{action:"execute"})}}catch(se){const L=se instanceof Error?se.message:"Deposit failed";q(L),d?.(L)}finally{K(!1)}}},Ae=r.useMemo(()=>l&&l.length>0?B.filter(se=>l.some(L=>L.toLowerCase()===se.symbol.toLowerCase())):B,[B,l]),fe=m&&m.amount&&parseFloat(m.amount)>0&&parseFloat(m.amount)<=m.asset.balanceFormatted&&y&&!X&&t.length>0,me=R||H,ve={backgroundColor:i?.container?.backgroundColor||i?.primaryBackground||f.colors.background,border:`1px solid ${i?.container?.borderColor||f.colors.border}`,borderRadius:i?.container?.borderRadius||f.borderRadius.lg,padding:i?.container?.padding||f.spacing.md,width:i?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:f.colors.text,fontFamily:f.typography.fontFamily,boxShadow:i?.container?.boxShadow||(f.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")},Ve=$?e.jsx(Pt,{type:"deposit",isOpen:!!$&&$.overallStatus!=="processing",isProcessing:X||$?.overallStatus==="processing",closeOnComplete:!0,onRetryTx:()=>{Q(),ee(!1),Ce()},onNewTx:()=>{Q(),ee(!1),A(null),ie.current=null,O()},onClose:()=>{Q(),ee(!1)},onComplete:()=>{Q(),ee(!1),A(null),ie.current=null,O()},results:$?.overallStatus==="success"||$?.overallStatus==="failed"?$.steps.map(se=>({asset:{symbol:m?.asset.symbol||"Token",address:m?.asset.address||""},txHash:se.transactionHash||"",success:se.status==="success",amount:m?.amount})):void 0,chainName:m?st(t[t.length-1].chainId):"Network",explorerUrl:m?Dt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:f}):null;return e.jsxs("div",{style:{...ve,position:"relative"},className:x,children:[Ve&&e.jsx("div",{style:{position:"absolute",top:0,left:"-25px",right:"-25px",bottom:"-16px"},children:e.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",pointerEvents:"auto"},children:Ve})}),!M&&!te&&e.jsx("div",{style:{backgroundColor:f.mode==="light"?"#fef3c7":`${f.colors.warning||"#f59e0b"}20`,border:`1px solid ${f.mode==="light"?"#fcd34d":f.colors.warning||"#f59e0b"}`,borderRadius:f.borderRadius.md,padding:f.spacing.md,marginBottom:f.spacing.md,textAlign:"center"},children:e.jsxs("p",{style:{color:f.mode==="light"?"#92400e":"#fbbf24",fontSize:f.typography.fontSize.sm,fontFamily:f.typography.fontFamily,margin:0,lineHeight:1.5},children:["You do not have any cross-chain balance."," ",S&&e.jsx("span",{onClick:S,style:{color:f.colors.primary,textDecoration:"underline",cursor:"pointer",fontWeight:600},children:"Top-up here."})]})}),e.jsx("div",{style:{marginBottom:f.spacing.sm},children:e.jsx(gt,{assets:Ae,selectedAsset:m||void 0,onAssetSelect:ue,onAmountChange:ne,loading:M,label:"Amount",showBalance:!0,showMaxButton:!0,theme:f,styles:i})}),me&&e.jsx("div",{style:{backgroundColor:i?.errorMessage?.backgroundColor||(f.mode==="light"?"#fef2f2":`${i?.statusDisplay?.errorColor||f.colors.error}20`),border:`1px solid ${i?.errorMessage?.borderColor||(f.mode==="light"?"#fecaca":i?.statusDisplay?.errorColor||f.colors.error)}`,borderRadius:i?.errorMessage?.borderRadius||f.borderRadius.md,padding:i?.errorMessage?.padding||f.spacing.md,marginBottom:f.spacing.sm},children:e.jsx("p",{style:{color:i?.errorMessage?.color||i?.statusDisplay?.errorColor||f.colors.error,fontSize:i?.errorMessage?.fontSize||f.typography.fontSize.sm,fontWeight:i?.errorMessage?.fontWeight,fontFamily:i?.errorMessage?.fontFamily||f.typography.fontFamily,margin:0},children:me})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.spacing.sm},children:e.jsx(ce.Button,{variant:"outline",fullWidth:!0,onClick:Ce,onMouseEnter:()=>N(!0),onMouseLeave:()=>{N(!1),Y(!1)},onMouseDown:()=>Y(!0),onMouseUp:()=>Y(!1),loading:X,disabled:!fe||!y,theme:f,styles:i,style:{width:"100%",padding:"8px",backgroundColor:fe?D?"#d43d3d":v?"#f05555":"#ea4b4b":"#d1d5db",color:fe?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:fe?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:fe?D?"scale(0.98)":v?"translateY(-2px)":"none":"none",boxShadow:D?"1px 1px 0px black":v&&fe?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:w?E?y?X?"Executing Deposit...":m?m.amount?parseFloat(m.amount)>m.asset.balanceFormatted?"Insufficient Balance":t.length===0?"No Deposit Batches":I||"Execute Deposit":"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},ko=({isOpen:t,onClose:o,title:a="Deposit",maxWidth:n="480px",depositBatches:s,tokenAddress:l,tokenDecimals:c,tokenTransferAmount:i,supportedChains:x,supportedTokens:g,theme:u="light",styles:d,className:S,depositInputHook:I,onDepositSuccess:k,onDepositError:f,submitButtonText:p})=>{const w=ce.createTheme(u),E=y=>{k?.(y)};return e.jsx(at,{isOpen:t,onClose:o,title:a,subtitle:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e.jsx("img",{src:Qt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e.jsx("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:"Use your cross-chain balance to deposit WBTC to earn 6.3% yield, all in one click."})]}),styles:d,theme:w,maxWidth:n,children:e.jsx("div",{style:{padding:"0 24px 24px 24px"},children:e.jsx(fs,{depositBatches:s,tokenAddress:l,tokenDecimals:c,tokenTransferAmount:i,supportedChains:x,supportedTokens:g,theme:u,styles:{...d,container:{...d?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:S,depositInputHook:I,onDepositSuccess:E,onDepositError:f,submitButtonText:p})})})},Io=({asset:t,amount:o,onAmountChange:a,onPercentageClick:n,usdValue:s,disabled:l,styles:c,theme:i})=>{const x=t.balanceFormatted??0,g=parseFloat(o)||0,u=x>0?g/x*100:0,[d,S]=r.useState(null),[I,k]=r.useState(null),f=p=>{const w=p.target.value;(w===""||/^\d*\.?\d*$/.test(w))&&a(w)};return e.jsx("div",{style:{backgroundColor:"#e9e9e9",border:"0.5px solid #A8A8A7",borderRadius:"6px",padding:"16px",height:"144px",display:"flex",flexDirection:"column",gap:"8px",position:"relative"},children:e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",justifyContent:"space-between",height:"100%"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("span",{style:{fontFamily:c?.fontFamily||i.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:"Amount"}),e.jsx("input",{type:"text",value:o,onChange:f,placeholder:"0.00",disabled:l,style:{fontFamily:c?.fontFamily||i.typography.fontFamily,fontSize:"40px",fontWeight:700,color:l?"rgba(14, 13, 11, 0.16)":o?"#0e0d0b":"#d1d5db",lineHeight:"1.08",letterSpacing:"-1.2px",backgroundColor:"transparent",border:"none",outline:"none",padding:0,width:"100%",maxWidth:"200px"}})]})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"space-between",height:"100%",gap:"12px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px",alignItems:"flex-end"},children:[e.jsxs("span",{style:{fontFamily:c?.fontFamily||i.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",x.toFixed(4)]}),e.jsx("div",{style:{width:"128px"},children:e.jsxs("div",{style:{border:"1px solid #CDCFD1",borderRadius:"6px 6px 6px 6px",backgroundColor:"transparent",padding:"8px 12px 8px 8px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(et,{symbol:t.symbol,logoURI:t.logoURI,size:30,theme:i}),e.jsx("span",{style:{fontFamily:c?.fontFamily||i.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#3c3e42",lineHeight:"1.5"},children:t.symbol})]})})]}),e.jsx("div",{style:{display:"flex",gap:"10px",height:"14px",alignItems:"center",justifyContent:"flex-end"},children:[0,25,50,75,100].map((p,w)=>{const E=Math.abs(u-p)<1,y=w===4,b=p/100,C=d===p,h=I===p;return e.jsx("button",{onClick:()=>n(p),onMouseEnter:()=>S(p),onMouseLeave:()=>{S(null),k(null)},onMouseDown:()=>k(p),onMouseUp:()=>k(null),disabled:l,title:`${p}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:l?"not-allowed":"pointer",opacity:E?1:C?.8:.5,transform:h?"scale(0.85)":C?"scale(1.15)":"scale(1)",transition:"all 0.15s ease"},children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",children:[e.jsx("circle",{cx:"7",cy:"7",r:"6.84375",fill:y?"#ea4b4b":"none",stroke:y?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!y&&b>0&&e.jsx("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${b>.5?1:0} 1 ${7+6.84375*Math.sin(b*2*Math.PI)} ${7-6.84375*Math.cos(b*2*Math.PI)} Z`,fill:"#3C3E42"})]})},p)})})]})]})})};var Fo="data:image/svg+xml,%3csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M5.83337 11.0833C8.73287 11.0833 11.0834 8.73275 11.0834 5.83325C11.0834 2.93376 8.73287 0.583252 5.83337 0.583252C2.93388 0.583252 0.583374 2.93376 0.583374 5.83325C0.583374 8.73275 2.93388 11.0833 5.83337 11.0833Z' stroke='%23757171' stroke-width='1.16667' stroke-linecap='round' stroke-linejoin='round'/%3e%3cpath d='M4.84329 4.48988C5.18981 4.14336 5.36306 3.97011 5.56285 3.90519C5.73859 3.84809 5.92789 3.84809 6.10363 3.90519C6.30342 3.97011 6.47668 4.14336 6.82319 4.48988L7.17663 4.84331C7.52314 5.18983 7.6964 5.36308 7.76131 5.56287C7.81841 5.73861 7.81841 5.92791 7.76131 6.10365C7.6964 6.30344 7.52314 6.4767 7.17663 6.82321L6.82319 7.17665C6.47668 7.52316 6.30342 7.69642 6.10363 7.76133C5.92789 7.81843 5.73859 7.81843 5.56285 7.76133C5.36306 7.69642 5.18981 7.52316 4.84329 7.17665L4.48986 6.82321C4.14334 6.4767 3.97009 6.30344 3.90517 6.10365C3.84807 5.92791 3.84807 5.73861 3.90517 5.56287C3.97009 5.36308 4.14334 5.18983 4.48986 4.84331L4.84329 4.48988Z' stroke='%23757171' stroke-width='1.16667' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e";const Eo=({isOpen:t,onClose:o,onComplete:a,title:n="Deposit to Spicenet",description:s="Select tokens and enter amounts to deposit to your Spicenet Account",chainId:l,embeddedWalletAddress:c,externalWalletAddress:i,escrowAddress:x="0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",airdropTokenSymbol:g,getChainConfig:u,getSupportedTokens:d})=>{const S=ce.createTheme("light"),[I,k]=r.useState(new Map),[f,p]=r.useState(!1),[w,E]=r.useState(null),[y,b]=r.useState([]),[C,h]=r.useState(!1),[m,A]=r.useState(null),[B,M]=r.useState(null),[R,te]=r.useState(!1),[O,X]=r.useState(!1),[K,H]=r.useState(!1),[q,v]=r.useState(!1);r.useState(null),r.useState(null);const[N,D]=r.useState(null),{chain:Y}=ye.useAccount(),{data:W,isLoading:ee}=ye.useWalletClient(),{switchChainAsync:ie}=ye.useSwitchChain(),$=r.useMemo(()=>d(l),[l,d]),{erc20Tokens:be,nativeToken:Q}=r.useMemo(()=>{const j=[];let z=null;return $.forEach(J=>{ht(J.address)?z=J:j.push(J)}),{erc20Tokens:j,nativeToken:z}},[$]),{data:P}=ye.useReadContracts({contracts:be.map(j=>({address:j.address,abi:le.erc20Abi,functionName:"balanceOf",args:[i],chainId:l}))}),{data:ue}=ye.useBalance({address:i,chainId:l}),ne=r.useMemo(()=>{if(!u(l))return[];const j=[];if(Q){const z=Q,J=ue?.value??BigInt(0),re=Number(J)/Math.pow(10,z.decimals);j.push({address:z.address,symbol:z.symbol,name:z.name,decimals:z.decimals,isNative:!0,chainId:l,balance:J,balanceFormatted:re})}return be.forEach((z,J)=>{const re=P?.[J],pe=re?.status==="success"?re.result:BigInt(0),he=Number(pe)/Math.pow(10,z.decimals);j.push({address:z.address,symbol:z.symbol,name:z.name,decimals:z.decimals,isNative:!1,chainId:l,balance:pe,balanceFormatted:he})}),j},[l,P,ue,be,Q,u]);r.useMemo(()=>g?ne.find(j=>j.symbol.toUpperCase()===g.toUpperCase()):void 0,[ne,g]),r.useEffect(()=>{if(ne.length>0&&I.size>0){const j=new Map(I);let z=!1;I.forEach((J,re)=>{const pe=ne.find(he=>he.address===re);pe&&pe.balanceFormatted!==J.asset.balanceFormatted&&(j.set(re,{...J,asset:pe}),z=!0)}),z&&k(j)}},[ne,I]);const Ce=u(l),Ae=j=>{const z=new Map(I);z.has(j.address)?z.delete(j.address):z.set(j.address,{asset:j,amount:""}),k(z),E(null)},fe=(j,z)=>{if(z===""||/^\d*\.?\d*$/.test(z)){const J=new Map(I),re=J.get(j);if(re){let pe=z;if(z!==""&&re.asset.balanceFormatted!==void 0){const he=parseFloat(z);!isNaN(he)&&he>re.asset.balanceFormatted&&(pe=re.asset.balanceFormatted.toString())}J.set(j,{...re,amount:pe}),k(J),E(null)}}},me=(j,z)=>{const J=I.get(j);if(J?.asset.balanceFormatted!==void 0){const re=J.asset.balanceFormatted*z/100,pe=Math.floor(re*1e6)/1e6;fe(j,pe.toString())}},ve=r.useCallback(async()=>{if(I.size===0){E("Please select at least one asset");return}for(const[z,J]of Array.from(I.entries())){if(!J.amount){E(`Please enter an amount for ${J.asset.symbol}`);return}const re=parseFloat(J.amount);if(isNaN(re)||re<=0){E(`Please enter a valid amount for ${J.asset.symbol}`);return}const pe=ne.find(he=>he.address===z)?.balanceFormatted??J.asset.balanceFormatted;if(pe!==void 0&&re>pe){E(`Insufficient ${J.asset.symbol} balance`);return}}if(!W){E("Wallet not connected. Please reconnect your external wallet.");return}p(!0),E(null);const j=[];try{Y?.id!==l&&await ie({chainId:l});for(const[,z]of Array.from(I.entries())){const{asset:J,amount:re}=z;try{const pe=le.parseUnits(re,J.decimals);let he;if(J.isNative)he=await W.sendTransaction({to:x,value:pe});else{const de=le.encodeFunctionData({abi:le.erc20Abi,functionName:"transfer",args:[x,pe]});he=await W.sendTransaction({to:J.address,data:de})}const F=ze(l),_=await F.waitForTransactionReceipt({hash:he,timeout:12e4,pollingInterval:2e3,confirmations:2});if(_.status!=="success")throw new Error(`Transfer to escrow failed for ${J.symbol}`);await F.getBlockNumber()-_.blockNumber<2&&await new Promise(de=>setTimeout(de,3e3)),await Fe.submitSpiceDeposit({txHash:he,sender:c,tokenAddress:J.address,chainId:l,amount:le.parseUnits(re,J.decimals).toString(),user:c,isDeposit:!0}),j.push({asset:J,txHash:he,success:!0})}catch(pe){const he=pe;let F=he?.message||"Deposit failed";he?.code===4001||he?.message?.includes("rejected")?F="Transaction rejected by user":he?.message?.includes("insufficient funds")&&(F="Insufficient funds for transaction"),j.push({asset:J,txHash:"",success:!1,error:F})}}b(j),h(!0);try{const z=Array.from(I.values())[0];z?.asset&&z.amount&&sessionStorage.setItem("spiceflow:lastDepositSelection",JSON.stringify({symbol:z.asset.symbol,address:z.asset.address,decimals:z.asset.decimals,chainId:z.asset.chainId,amount:z.amount}))}catch{}}catch(z){E(z?.message||"Deposit failed")}finally{p(!1)}},[I,W,Y,l,ie,x,ne]);r.useEffect(()=>{t||(k(new Map),E(null),b([]),h(!1),p(!1))},[t]);const Ve=r.useCallback(()=>{b([]),h(!1),E(null)},[]),se=r.useCallback(()=>{window.dispatchEvent(new CustomEvent("cross-chain-deposit-skipped"))},[]),L=I.size>0&&Array.from(I.values()).every(j=>j.amount&&parseFloat(j.amount)>0)&&!f&&!C&&W,oe=e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e.jsx("img",{src:Qt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e.jsx("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:s})]}),xe=f||C&&y.length>0?e.jsx(Pt,{type:"deposit",isOpen:C&&y.length>0,isProcessing:f,onClose:o,onComplete:a,closeOnComplete:!1,onRetryTx:Ve,onNewTx:()=>{},results:y.length>0?y.map(j=>({asset:{symbol:j.asset.symbol,address:j.asset.address},txHash:j.txHash,success:j.success,error:j.error})):void 0,chainName:st(l),explorerUrl:Ce?.blockExplorers?.default?.url,theme:S}):null;return e.jsxs(at,{isOpen:t,onClose:o,title:n,subtitle:oe,theme:S,maxWidth:"480px",children:[e.jsxs("div",{style:{padding:"0 24px 32px 24px",position:"relative",display:"flex",flexDirection:"column",maxHeight:"calc(80vh - 180px)"},children:[xe&&e.jsx("div",{style:{position:"absolute",inset:0,overflow:"hidden",pointerEvents:"none",zIndex:10},children:e.jsx("div",{style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto"},children:xe})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,paddingRight:"4px",marginRight:"-4px"},children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",marginBottom:"10px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px",color:"#6b7280"},children:e.jsx("img",{src:Fo,alt:"Info",style:{width:"10.5px",height:"10.5px",top:"1.75px",left:"1.75px",flexShrink:0}})}),e.jsx("label",{style:{fontSize:"12px",fontWeight:590,color:"#374151"},children:"Select Assets to Deposit"})]})}),e.jsx("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:ne.map(j=>{const z=I.has(j.address);return e.jsx("div",{onClick:()=>Ae(j),onMouseEnter:()=>A(j.address),onMouseLeave:()=>{A(null),M(null)},onMouseDown:()=>M(j.address),onMouseUp:()=>M(null),style:{padding:"4px 8px 4px 8px",borderRadius:"8px",border:`1px solid ${z?"#EA4B4B7A":m===j.address?"#F4A5A5":"#e5e7eb"}`,backgroundColor:z?"#FEF2F2":B===j.address?"#f5f5f5":m===j.address?"#fafafa":"white",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease",transform:B===j.address?"scale(0.96)":m===j.address?"translateY(-1px)":"none",boxShadow:z?"0 0 0 3px #FBDBDB":B===j.address?"0 1px 2px rgba(0, 0, 0, 0.05)":m===j.address?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(et,{symbol:j.symbol,size:24,theme:S}),e.jsx("span",{style:{fontSize:"16px",fontWeight:510,color:"#3C3E42"},children:j.symbol}),j.balanceFormatted!==void 0&&e.jsxs("span",{style:{fontSize:"10px",fontWeight:500,color:"#939291",fontFamily:'"IBM Plex Mono", monospace'},children:["(",j.balanceFormatted.toFixed(4),")"]})]})},j.address)})})]}),I.size>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:Array.from(I.values()).map(({asset:j,amount:z})=>e.jsx(Io,{asset:j,amount:z,onAmountChange:J=>fe(j.address,J),onPercentageClick:J=>me(j.address,J),theme:S,disabled:f},j.address))})]}),w&&e.jsx("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginTop:"16px"},children:e.jsx("p",{style:{fontSize:"14px",color:"#dc2626",margin:0},children:w})}),!C&&e.jsxs("div",{style:{display:"flex",gap:"12px",marginTop:"20px"},children:[e.jsx(ce.Button,{variant:"outline",onClick:ve,onMouseEnter:()=>te(!0),onMouseLeave:()=>{te(!1),X(!1)},onMouseDown:()=>X(!0),onMouseUp:()=>X(!1),disabled:!L,theme:S,style:{flex:2,padding:"8px",backgroundColor:L?O?"#d43d3d":R?"#f05555":"#ea4b4b":"#d1d5db",color:L?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:L?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:L?O?"scale(0.98)":R?"translateY(-2px)":"none":"none",boxShadow:O?"1px 1px 0px black":R&&L?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:f?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"18px",height:"18px",border:"2px solid white",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"PROCESSING..."})]}):ee?"CONNECTING WALLET...":W?I.size===0?"SELECT ASSETS":Array.from(I.values()).every(j=>j.amount)?"DEPOSIT":"ENTER AMOUNTS":"WALLET NOT CONNECTED"}),e.jsx(ce.Button,{variant:"outline",onClick:se,onMouseEnter:()=>H(!0),onMouseLeave:()=>{H(!1),v(!1)},onMouseDown:()=>v(!0),onMouseUp:()=>v(!1),disabled:f,theme:S,style:{flex:1,padding:"8px",backgroundColor:q?"#d43d3d":K?"#f05555":"#ea4b4b",color:"#0e0d0b",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:f?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:q?"scale(0.98)":K?"translateY(-2px)":"none",boxShadow:q?"1px 1px 0px black":K?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"SKIP"})]}),e.jsx("style",{children:`
|
|
64
|
+
`})]})},fs=({depositBatches:t,tokenAddress:o,tokenDecimals:a,tokenTransferAmount:n,supportedChains:s,supportedTokens:l,theme:c="light",styles:i,className:x="",depositInputHook:g,onDepositSuccess:u,onDepositError:d,onTopUp:S,submitButtonText:I})=>{const k=ce.createTheme(c),f={...k,typography:{...k.typography,fontFamily:i?.fontFamily||k.typography.fontFamily},colors:{...k.colors,primary:i?.primaryColor||k.colors.primary,primaryHover:i?.primaryColor?`${i.primaryColor}dd`:k.colors.primaryHover}},p=Mt(),{isReady:w,isAuthenticated:E,isConnected:y,address:b,provider:C,actions:h}=p,[m,A]=r.useState(null),{assets:B,loading:M,error:R,hasBalance:te,refetch:O}=xs({address:b,supportedChains:s,enabled:y,refetchInterval:3e4}),[X,K]=r.useState(!1),[H,q]=r.useState(null),[v,N]=r.useState(!1),[D,Y]=r.useState(!1),[W,ee]=r.useState(!1),ie=r.useRef(null),{intentStatus:$,startStatusPolling:be,clearStatus:Q}=Ft({checkStepStatus:(se,L)=>Fe.checkStepStatus(se,L)});r.useEffect(()=>{if($?.overallStatus==="success"&&$.intentId&&ie.current!==$.intentId&&m&&b){const se=$.steps.find(L=>L.transactionHash);if(se?.transactionHash){ie.current=$.intentId;const L=le.parseUnits(m.amount,m.asset.decimals);Fe.submitSpiceDeposit({user:b,txHash:se.transactionHash,sender:b,tokenAddress:m.asset.address,chainId:m.asset.chainId,amount:L.toString(),isDeposit:!1}).then(()=>{O()}).catch(()=>{ie.current=null})}}},[$,b]),r.useEffect(()=>{g&&g.assetAmount!==m?.amount&&m&&A({...m,amount:g.assetAmount})},[g?.assetAmount,m]),r.useEffect(()=>{if(!g?.selectedAsset)return;const se=g.selectedAsset,L=se.address.toLowerCase(),oe=L==="0x0"||L==="0x0000000000000000000000000000000000000000"||L==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",xe=B.find(j=>{const z=j.address.toLowerCase();return(oe&&j.isNative||z===L)&&(se.chainId?j.chainId===se.chainId:!0)});xe&&A(j=>({asset:xe,amount:j?.amount||g.assetAmount||""}))},[g?.selectedAsset,B,g?.assetAmount]);const P=r.useCallback(()=>{q(null)},[]),ue=se=>{A({asset:se,amount:m?.amount||""}),g?.setSelectedAsset&&g.setSelectedAsset({symbol:se.symbol,address:se.address,decimals:se.decimals,chainId:se.chainId}),P()},ne=r.useCallback(se=>{m&&(r.startTransition(()=>{A({...m,amount:se}),P()}),g&&g.setAssetAmount(se))},[m,g,P]),Ce=async()=>{if(!(!m||!b||t.length===0)){if(!w||!E){q(`Please authenticate with ${C||"wallet provider"} to continue`);return}K(!0),q(null),ee(!0);try{const se=[...t],L=[...new Set(se.map(F=>F.chainId))],oe=[];for(const F of L){const _=ze(F),de=ut(F),ge=await qe.getAccountNonce(b,_),Re=await h.signAuthorization({contractAddress:de,chainId:F,nonce:Number(ge)});oe.push(Re)}const xe=qe.hashChainBatches(se),j=Math.floor(Date.now()/1e3)+60*10,z=qe.getIntentHash(0n,BigInt(j),xe),J=await h.signMessage({raw:z}),re=typeof J=="string"?J:J.signature;if(!re)throw new Error("Failed to sign intent authorization");const pe={mode:"7702",signatureType:"ecdsa",signature:re,nbf:0,exp:j,chainBatches:xe.map(F=>({hash:F.hash,chainId:F.chainId,tokenTransfers:[{from:"solver",to:b,token:"0x0000000000000000000000000000000000000000",amount:le.parseUnits("0.00001",18)},{from:"solver",to:b,token:o,amount:n??le.parseUnits(m.amount,a)}],calls:F.calls}))},he=await Fe.createAction({user:b,chainAuthorizations:oe.map(F=>({...F,r:F.r,s:F.s,yParity:F.yParity,address:F.address,chainId:Number(F.chainId),nonce:Number(F.nonce)})),intents:[pe]});if(he){const F=jt(se,Re=>`Chain ${Re}`),[_,de]=he.intentIds[0].split("/"),ge=parseInt(de||"0",10);be(he.intentIds[0],F);for(let Re=0;Re<se.length;Re++)await Fe.executeStep(_,ge,Re,{action:"execute"})}}catch(se){const L=se instanceof Error?se.message:"Deposit failed";q(L),d?.(L)}finally{K(!1),window.dispatchEvent(new CustomEvent("deposit-completed"))}}},Ae=r.useMemo(()=>l&&l.length>0?B.filter(se=>l.some(L=>L.toLowerCase()===se.symbol.toLowerCase())):B,[B,l]),fe=m&&m.amount&&parseFloat(m.amount)>0&&parseFloat(m.amount)<=m.asset.balanceFormatted&&y&&!X&&t.length>0,me=R||H,ve={backgroundColor:i?.container?.backgroundColor||i?.primaryBackground||f.colors.background,border:`1px solid ${i?.container?.borderColor||f.colors.border}`,borderRadius:i?.container?.borderRadius||f.borderRadius.lg,padding:i?.container?.padding||f.spacing.md,width:i?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:f.colors.text,fontFamily:f.typography.fontFamily,boxShadow:i?.container?.boxShadow||(f.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")},Ve=$?e.jsx(Pt,{type:"deposit",isOpen:!!$&&$.overallStatus!=="processing",isProcessing:X||$?.overallStatus==="processing",closeOnComplete:!0,onRetryTx:()=>{Q(),ee(!1),Ce()},onNewTx:()=>{Q(),ee(!1),A(null),ie.current=null,O()},onClose:()=>{Q(),ee(!1)},onComplete:()=>{Q(),ee(!1),A(null),ie.current=null,O()},results:$?.overallStatus==="success"||$?.overallStatus==="failed"?$.steps.map(se=>({asset:{symbol:m?.asset.symbol||"Token",address:m?.asset.address||""},txHash:se.transactionHash||"",success:se.status==="success",amount:m?.amount})):void 0,chainName:m?st(t[t.length-1].chainId):"Network",explorerUrl:m?Dt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:f}):null;return e.jsxs("div",{style:{...ve,position:"relative"},className:x,children:[Ve&&e.jsx("div",{style:{position:"absolute",top:0,left:"-25px",right:"-25px",bottom:"-16px"},children:e.jsx("div",{style:{position:"absolute",width:"100%",height:"100%",pointerEvents:"auto"},children:Ve})}),!M&&!te&&e.jsx("div",{style:{backgroundColor:f.mode==="light"?"#fef3c7":`${f.colors.warning||"#f59e0b"}20`,border:`1px solid ${f.mode==="light"?"#fcd34d":f.colors.warning||"#f59e0b"}`,borderRadius:f.borderRadius.md,padding:f.spacing.md,marginBottom:f.spacing.md,textAlign:"center"},children:e.jsxs("p",{style:{color:f.mode==="light"?"#92400e":"#fbbf24",fontSize:f.typography.fontSize.sm,fontFamily:f.typography.fontFamily,margin:0,lineHeight:1.5},children:["You do not have any cross-chain balance."," ",S&&e.jsx("span",{onClick:S,style:{color:f.colors.primary,textDecoration:"underline",cursor:"pointer",fontWeight:600},children:"Top-up here."})]})}),e.jsx("div",{style:{marginBottom:f.spacing.sm},children:e.jsx(gt,{assets:Ae,selectedAsset:m||void 0,onAssetSelect:ue,onAmountChange:ne,loading:M,label:"Amount",showBalance:!0,showMaxButton:!0,theme:f,styles:i})}),me&&e.jsx("div",{style:{backgroundColor:i?.errorMessage?.backgroundColor||(f.mode==="light"?"#fef2f2":`${i?.statusDisplay?.errorColor||f.colors.error}20`),border:`1px solid ${i?.errorMessage?.borderColor||(f.mode==="light"?"#fecaca":i?.statusDisplay?.errorColor||f.colors.error)}`,borderRadius:i?.errorMessage?.borderRadius||f.borderRadius.md,padding:i?.errorMessage?.padding||f.spacing.md,marginBottom:f.spacing.sm},children:e.jsx("p",{style:{color:i?.errorMessage?.color||i?.statusDisplay?.errorColor||f.colors.error,fontSize:i?.errorMessage?.fontSize||f.typography.fontSize.sm,fontWeight:i?.errorMessage?.fontWeight,fontFamily:i?.errorMessage?.fontFamily||f.typography.fontFamily,margin:0},children:me})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.spacing.sm},children:e.jsx(ce.Button,{variant:"outline",fullWidth:!0,onClick:Ce,onMouseEnter:()=>N(!0),onMouseLeave:()=>{N(!1),Y(!1)},onMouseDown:()=>Y(!0),onMouseUp:()=>Y(!1),loading:X,disabled:!fe||!y,theme:f,styles:i,style:{width:"100%",padding:"8px",backgroundColor:fe?D?"#d43d3d":v?"#f05555":"#ea4b4b":"#d1d5db",color:fe?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:fe?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:fe?D?"scale(0.98)":v?"translateY(-2px)":"none":"none",boxShadow:D?"1px 1px 0px black":v&&fe?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:w?E?y?X?"Executing Deposit...":m?m.amount?parseFloat(m.amount)>m.asset.balanceFormatted?"Insufficient Balance":t.length===0?"No Deposit Batches":I||"Execute Deposit":"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},ko=({isOpen:t,onClose:o,title:a="Deposit",maxWidth:n="480px",depositBatches:s,tokenAddress:l,tokenDecimals:c,tokenTransferAmount:i,supportedChains:x,supportedTokens:g,theme:u="light",styles:d,className:S,depositInputHook:I,onDepositSuccess:k,onDepositError:f,submitButtonText:p})=>{const w=ce.createTheme(u),E=y=>{k?.(y)};return e.jsx(at,{isOpen:t,onClose:o,title:a,subtitle:e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e.jsx("img",{src:Qt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e.jsx("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:"Use your cross-chain balance to deposit WBTC to earn 6.3% yield, all in one click."})]}),styles:d,theme:w,maxWidth:n,children:e.jsx("div",{style:{padding:"0 24px 24px 24px"},children:e.jsx(fs,{depositBatches:s,tokenAddress:l,tokenDecimals:c,tokenTransferAmount:i,supportedChains:x,supportedTokens:g,theme:u,styles:{...d,container:{...d?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:S,depositInputHook:I,onDepositSuccess:E,onDepositError:f,submitButtonText:p})})})},Io=({asset:t,amount:o,onAmountChange:a,onPercentageClick:n,usdValue:s,disabled:l,styles:c,theme:i})=>{const x=t.balanceFormatted??0,g=parseFloat(o)||0,u=x>0?g/x*100:0,[d,S]=r.useState(null),[I,k]=r.useState(null),f=p=>{const w=p.target.value;(w===""||/^\d*\.?\d*$/.test(w))&&a(w)};return e.jsx("div",{style:{backgroundColor:"#e9e9e9",border:"0.5px solid #A8A8A7",borderRadius:"6px",padding:"16px",height:"144px",display:"flex",flexDirection:"column",gap:"8px",position:"relative"},children:e.jsxs("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("div",{style:{display:"flex",flexDirection:"column",justifyContent:"space-between",height:"100%"},children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e.jsx("span",{style:{fontFamily:c?.fontFamily||i.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:"Amount"}),e.jsx("input",{type:"text",value:o,onChange:f,placeholder:"0.00",disabled:l,style:{fontFamily:c?.fontFamily||i.typography.fontFamily,fontSize:"40px",fontWeight:700,color:l?"rgba(14, 13, 11, 0.16)":o?"#0e0d0b":"#d1d5db",lineHeight:"1.08",letterSpacing:"-1.2px",backgroundColor:"transparent",border:"none",outline:"none",padding:0,width:"100%",maxWidth:"200px"}})]})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"space-between",height:"100%",gap:"12px"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px",alignItems:"flex-end"},children:[e.jsxs("span",{style:{fontFamily:c?.fontFamily||i.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",x.toFixed(4)]}),e.jsx("div",{style:{width:"128px"},children:e.jsxs("div",{style:{border:"1px solid #CDCFD1",borderRadius:"6px 6px 6px 6px",backgroundColor:"transparent",padding:"8px 12px 8px 8px",display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(et,{symbol:t.symbol,logoURI:t.logoURI,size:30,theme:i}),e.jsx("span",{style:{fontFamily:c?.fontFamily||i.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#3c3e42",lineHeight:"1.5"},children:t.symbol})]})})]}),e.jsx("div",{style:{display:"flex",gap:"10px",height:"14px",alignItems:"center",justifyContent:"flex-end"},children:[0,25,50,75,100].map((p,w)=>{const E=Math.abs(u-p)<1,y=w===4,b=p/100,C=d===p,h=I===p;return e.jsx("button",{onClick:()=>n(p),onMouseEnter:()=>S(p),onMouseLeave:()=>{S(null),k(null)},onMouseDown:()=>k(p),onMouseUp:()=>k(null),disabled:l,title:`${p}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:l?"not-allowed":"pointer",opacity:E?1:C?.8:.5,transform:h?"scale(0.85)":C?"scale(1.15)":"scale(1)",transition:"all 0.15s ease"},children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",children:[e.jsx("circle",{cx:"7",cy:"7",r:"6.84375",fill:y?"#ea4b4b":"none",stroke:y?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!y&&b>0&&e.jsx("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${b>.5?1:0} 1 ${7+6.84375*Math.sin(b*2*Math.PI)} ${7-6.84375*Math.cos(b*2*Math.PI)} Z`,fill:"#3C3E42"})]})},p)})})]})]})})};var Fo="data:image/svg+xml,%3csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M5.83337 11.0833C8.73287 11.0833 11.0834 8.73275 11.0834 5.83325C11.0834 2.93376 8.73287 0.583252 5.83337 0.583252C2.93388 0.583252 0.583374 2.93376 0.583374 5.83325C0.583374 8.73275 2.93388 11.0833 5.83337 11.0833Z' stroke='%23757171' stroke-width='1.16667' stroke-linecap='round' stroke-linejoin='round'/%3e%3cpath d='M4.84329 4.48988C5.18981 4.14336 5.36306 3.97011 5.56285 3.90519C5.73859 3.84809 5.92789 3.84809 6.10363 3.90519C6.30342 3.97011 6.47668 4.14336 6.82319 4.48988L7.17663 4.84331C7.52314 5.18983 7.6964 5.36308 7.76131 5.56287C7.81841 5.73861 7.81841 5.92791 7.76131 6.10365C7.6964 6.30344 7.52314 6.4767 7.17663 6.82321L6.82319 7.17665C6.47668 7.52316 6.30342 7.69642 6.10363 7.76133C5.92789 7.81843 5.73859 7.81843 5.56285 7.76133C5.36306 7.69642 5.18981 7.52316 4.84329 7.17665L4.48986 6.82321C4.14334 6.4767 3.97009 6.30344 3.90517 6.10365C3.84807 5.92791 3.84807 5.73861 3.90517 5.56287C3.97009 5.36308 4.14334 5.18983 4.48986 4.84331L4.84329 4.48988Z' stroke='%23757171' stroke-width='1.16667' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e";const Eo=({isOpen:t,onClose:o,onComplete:a,title:n="Deposit to Spicenet",description:s="Select tokens and enter amounts to deposit to your Spicenet Account",chainId:l,embeddedWalletAddress:c,externalWalletAddress:i,escrowAddress:x="0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",airdropTokenSymbol:g,getChainConfig:u,getSupportedTokens:d})=>{const S=ce.createTheme("light"),[I,k]=r.useState(new Map),[f,p]=r.useState(!1),[w,E]=r.useState(null),[y,b]=r.useState([]),[C,h]=r.useState(!1),[m,A]=r.useState(null),[B,M]=r.useState(null),[R,te]=r.useState(!1),[O,X]=r.useState(!1),[K,H]=r.useState(!1),[q,v]=r.useState(!1);r.useState(null),r.useState(null);const[N,D]=r.useState(null),{chain:Y}=ye.useAccount(),{data:W,isLoading:ee}=ye.useWalletClient(),{switchChainAsync:ie}=ye.useSwitchChain(),$=r.useMemo(()=>d(l),[l,d]),{erc20Tokens:be,nativeToken:Q}=r.useMemo(()=>{const j=[];let z=null;return $.forEach(J=>{ht(J.address)?z=J:j.push(J)}),{erc20Tokens:j,nativeToken:z}},[$]),{data:P}=ye.useReadContracts({contracts:be.map(j=>({address:j.address,abi:le.erc20Abi,functionName:"balanceOf",args:[i],chainId:l}))}),{data:ue}=ye.useBalance({address:i,chainId:l}),ne=r.useMemo(()=>{if(!u(l))return[];const j=[];if(Q){const z=Q,J=ue?.value??BigInt(0),re=Number(J)/Math.pow(10,z.decimals);j.push({address:z.address,symbol:z.symbol,name:z.name,decimals:z.decimals,isNative:!0,chainId:l,balance:J,balanceFormatted:re})}return be.forEach((z,J)=>{const re=P?.[J],pe=re?.status==="success"?re.result:BigInt(0),he=Number(pe)/Math.pow(10,z.decimals);j.push({address:z.address,symbol:z.symbol,name:z.name,decimals:z.decimals,isNative:!1,chainId:l,balance:pe,balanceFormatted:he})}),j},[l,P,ue,be,Q,u]);r.useMemo(()=>g?ne.find(j=>j.symbol.toUpperCase()===g.toUpperCase()):void 0,[ne,g]),r.useEffect(()=>{if(ne.length>0&&I.size>0){const j=new Map(I);let z=!1;I.forEach((J,re)=>{const pe=ne.find(he=>he.address===re);pe&&pe.balanceFormatted!==J.asset.balanceFormatted&&(j.set(re,{...J,asset:pe}),z=!0)}),z&&k(j)}},[ne,I]);const Ce=u(l),Ae=j=>{const z=new Map(I);z.has(j.address)?z.delete(j.address):z.set(j.address,{asset:j,amount:""}),k(z),E(null)},fe=(j,z)=>{if(z===""||/^\d*\.?\d*$/.test(z)){const J=new Map(I),re=J.get(j);if(re){let pe=z;if(z!==""&&re.asset.balanceFormatted!==void 0){const he=parseFloat(z);!isNaN(he)&&he>re.asset.balanceFormatted&&(pe=re.asset.balanceFormatted.toString())}J.set(j,{...re,amount:pe}),k(J),E(null)}}},me=(j,z)=>{const J=I.get(j);if(J?.asset.balanceFormatted!==void 0){const re=J.asset.balanceFormatted*z/100,pe=Math.floor(re*1e6)/1e6;fe(j,pe.toString())}},ve=r.useCallback(async()=>{if(I.size===0){E("Please select at least one asset");return}for(const[z,J]of Array.from(I.entries())){if(!J.amount){E(`Please enter an amount for ${J.asset.symbol}`);return}const re=parseFloat(J.amount);if(isNaN(re)||re<=0){E(`Please enter a valid amount for ${J.asset.symbol}`);return}const pe=ne.find(he=>he.address===z)?.balanceFormatted??J.asset.balanceFormatted;if(pe!==void 0&&re>pe){E(`Insufficient ${J.asset.symbol} balance`);return}}if(!W){E("Wallet not connected. Please reconnect your external wallet.");return}p(!0),E(null);const j=[];try{Y?.id!==l&&await ie({chainId:l});for(const[,z]of Array.from(I.entries())){const{asset:J,amount:re}=z;try{const pe=le.parseUnits(re,J.decimals);let he;if(J.isNative)he=await W.sendTransaction({to:x,value:pe});else{const de=le.encodeFunctionData({abi:le.erc20Abi,functionName:"transfer",args:[x,pe]});he=await W.sendTransaction({to:J.address,data:de})}const F=ze(l),_=await F.waitForTransactionReceipt({hash:he,timeout:12e4,pollingInterval:2e3,confirmations:2});if(_.status!=="success")throw new Error(`Transfer to escrow failed for ${J.symbol}`);await F.getBlockNumber()-_.blockNumber<2&&await new Promise(de=>setTimeout(de,3e3)),await Fe.submitSpiceDeposit({txHash:he,sender:c,tokenAddress:J.address,chainId:l,amount:le.parseUnits(re,J.decimals).toString(),user:c,isDeposit:!0}),j.push({asset:J,txHash:he,success:!0})}catch(pe){const he=pe;let F=he?.message||"Deposit failed";he?.code===4001||he?.message?.includes("rejected")?F="Transaction rejected by user":he?.message?.includes("insufficient funds")&&(F="Insufficient funds for transaction"),j.push({asset:J,txHash:"",success:!1,error:F})}finally{window.dispatchEvent(new CustomEvent("cross-chain-deposit-completed"))}}b(j),h(!0);try{const z=Array.from(I.values())[0];z?.asset&&z.amount&&sessionStorage.setItem("spiceflow:lastDepositSelection",JSON.stringify({symbol:z.asset.symbol,address:z.asset.address,decimals:z.asset.decimals,chainId:z.asset.chainId,amount:z.amount}))}catch{}}catch(z){E(z?.message||"Deposit failed")}finally{p(!1)}},[I,W,Y,l,ie,x,ne]);r.useEffect(()=>{t||(k(new Map),E(null),b([]),h(!1),p(!1))},[t]);const Ve=r.useCallback(()=>{b([]),h(!1),E(null)},[]),se=r.useCallback(()=>{window.dispatchEvent(new CustomEvent("cross-chain-deposit-skipped"))},[]),L=I.size>0&&Array.from(I.values()).every(j=>j.amount&&parseFloat(j.amount)>0)&&!f&&!C&&W,oe=e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e.jsx("img",{src:Qt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e.jsx("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:s})]}),xe=f||C&&y.length>0?e.jsx(Pt,{type:"deposit",isOpen:C&&y.length>0,isProcessing:f,onClose:o,onComplete:a,closeOnComplete:!1,onRetryTx:Ve,onNewTx:()=>{},results:y.length>0?y.map(j=>({asset:{symbol:j.asset.symbol,address:j.asset.address},txHash:j.txHash,success:j.success,error:j.error})):void 0,chainName:st(l),explorerUrl:Ce?.blockExplorers?.default?.url,theme:S}):null;return e.jsxs(at,{isOpen:t,onClose:o,title:n,subtitle:oe,theme:S,maxWidth:"480px",children:[e.jsxs("div",{style:{padding:"0 24px 32px 24px",position:"relative",display:"flex",flexDirection:"column",maxHeight:"calc(80vh - 180px)"},children:[xe&&e.jsx("div",{style:{position:"absolute",inset:0,overflow:"hidden",pointerEvents:"none",zIndex:10},children:e.jsx("div",{style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto"},children:xe})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,paddingRight:"4px",marginRight:"-4px"},children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",marginBottom:"10px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px",color:"#6b7280"},children:e.jsx("img",{src:Fo,alt:"Info",style:{width:"10.5px",height:"10.5px",top:"1.75px",left:"1.75px",flexShrink:0}})}),e.jsx("label",{style:{fontSize:"12px",fontWeight:590,color:"#374151"},children:"Select Assets to Deposit"})]})}),e.jsx("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:ne.map(j=>{const z=I.has(j.address);return e.jsx("div",{onClick:()=>Ae(j),onMouseEnter:()=>A(j.address),onMouseLeave:()=>{A(null),M(null)},onMouseDown:()=>M(j.address),onMouseUp:()=>M(null),style:{padding:"4px 8px 4px 8px",borderRadius:"8px",border:`1px solid ${z?"#EA4B4B7A":m===j.address?"#F4A5A5":"#e5e7eb"}`,backgroundColor:z?"#FEF2F2":B===j.address?"#f5f5f5":m===j.address?"#fafafa":"white",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease",transform:B===j.address?"scale(0.96)":m===j.address?"translateY(-1px)":"none",boxShadow:z?"0 0 0 3px #FBDBDB":B===j.address?"0 1px 2px rgba(0, 0, 0, 0.05)":m===j.address?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(et,{symbol:j.symbol,size:24,theme:S}),e.jsx("span",{style:{fontSize:"16px",fontWeight:510,color:"#3C3E42"},children:j.symbol}),j.balanceFormatted!==void 0&&e.jsxs("span",{style:{fontSize:"10px",fontWeight:500,color:"#939291",fontFamily:'"IBM Plex Mono", monospace'},children:["(",j.balanceFormatted.toFixed(4),")"]})]})},j.address)})})]}),I.size>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:Array.from(I.values()).map(({asset:j,amount:z})=>e.jsx(Io,{asset:j,amount:z,onAmountChange:J=>fe(j.address,J),onPercentageClick:J=>me(j.address,J),theme:S,disabled:f},j.address))})]}),w&&e.jsx("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginTop:"16px"},children:e.jsx("p",{style:{fontSize:"14px",color:"#dc2626",margin:0},children:w})}),!C&&e.jsxs("div",{style:{display:"flex",gap:"12px",marginTop:"20px"},children:[e.jsx(ce.Button,{variant:"outline",onClick:ve,onMouseEnter:()=>te(!0),onMouseLeave:()=>{te(!1),X(!1)},onMouseDown:()=>X(!0),onMouseUp:()=>X(!1),disabled:!L,theme:S,style:{flex:2,padding:"8px",backgroundColor:L?O?"#d43d3d":R?"#f05555":"#ea4b4b":"#d1d5db",color:L?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:L?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:L?O?"scale(0.98)":R?"translateY(-2px)":"none":"none",boxShadow:O?"1px 1px 0px black":R&&L?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:f?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{width:"18px",height:"18px",border:"2px solid white",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),e.jsx("span",{children:"PROCESSING..."})]}):ee?"CONNECTING WALLET...":W?I.size===0?"SELECT ASSETS":Array.from(I.values()).every(j=>j.amount)?"DEPOSIT":"ENTER AMOUNTS":"WALLET NOT CONNECTED"}),e.jsx(ce.Button,{variant:"outline",onClick:se,onMouseEnter:()=>H(!0),onMouseLeave:()=>{H(!1),v(!1)},onMouseDown:()=>v(!0),onMouseUp:()=>v(!1),disabled:f,theme:S,style:{flex:1,padding:"8px",backgroundColor:q?"#d43d3d":K?"#f05555":"#ea4b4b",color:"#0e0d0b",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:f?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:q?"scale(0.98)":K?"translateY(-2px)":"none",boxShadow:q?"1px 1px 0px black":K?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"SKIP"})]}),e.jsx("style",{children:`
|
|
65
65
|
@keyframes spin {
|
|
66
66
|
from { transform: rotate(0deg); }
|
|
67
67
|
to { transform: rotate(360deg); }
|
package/dist/index.js
CHANGED
|
@@ -44,7 +44,7 @@ import{defineChain as mo,createPublicClient as yo,http as xo,isAddress as eo,get
|
|
|
44
44
|
from { transform: rotate(0deg); }
|
|
45
45
|
to { transform: rotate(360deg); }
|
|
46
46
|
}
|
|
47
|
-
`}),!m&&a&&a.length>1&&e("div",{style:{overflow:"hidden",maxHeight:b?"200px":"0px",opacity:b?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease",marginBottom:b?"16px":"0"},children:e("div",{style:{maxHeight:"180px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"8px"},children:a.map((X,$)=>l("div",{style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e("span",{style:{fontWeight:600,fontSize:"13px",color:"#111827",fontFamily:'"IBM Plex Mono", monospace'},children:X.asset.symbol}),X.amount&&e("span",{style:{fontSize:"12px",color:"#6b7280"},children:X.amount})]}),e("span",{style:{fontSize:"12px",color:X.success?"#10b981":"#ef4444",fontWeight:500},children:X.success?"\u2713":"\u2717"})]},$))})}),!m&&!L&&a&&e("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginBottom:"16px"},children:e("p",{style:{fontSize:"13px",color:"#dc2626",margin:0,lineHeight:1.5},children:a.find(X=>!X.success)?.error||`${o.charAt(0).toUpperCase()+o.slice(1)} failed. Please try again.`})}),!m&&l("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[!L&&F&&l("button",{onClick:F,onMouseEnter:()=>h("retry-tx"),onMouseLeave:()=>{h(null),w(null)},onMouseDown:()=>w("retry-tx"),onMouseUp:()=>w(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:y==="retry-tx"?"#d43d3d":A==="retry-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:y==="retry-results"?"scale(0.98)":A==="retry-results"?"translateY(-2px)":"none",boxShadow:y==="retry-tx"?"1px 1px 0px black":A==="retry-tx"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["TRY AGAIN $",o]}),L&&
|
|
47
|
+
`}),!m&&a&&a.length>1&&e("div",{style:{overflow:"hidden",maxHeight:b?"200px":"0px",opacity:b?1:0,transition:"max-height 0.3s ease, opacity 0.3s ease",marginBottom:b?"16px":"0"},children:e("div",{style:{maxHeight:"180px",overflowY:"auto",display:"flex",flexDirection:"column",gap:"8px"},children:a.map((X,$)=>l("div",{style:{padding:"10px 12px",borderRadius:"6px",backgroundColor:"#f9fafb",border:"1px solid #e5e7eb",display:"flex",justifyContent:"space-between",alignItems:"center"},children:[l("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e("span",{style:{fontWeight:600,fontSize:"13px",color:"#111827",fontFamily:'"IBM Plex Mono", monospace'},children:X.asset.symbol}),X.amount&&e("span",{style:{fontSize:"12px",color:"#6b7280"},children:X.amount})]}),e("span",{style:{fontSize:"12px",color:X.success?"#10b981":"#ef4444",fontWeight:500},children:X.success?"\u2713":"\u2717"})]},$))})}),!m&&!L&&a&&e("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginBottom:"16px"},children:e("p",{style:{fontSize:"13px",color:"#dc2626",margin:0,lineHeight:1.5},children:a.find(X=>!X.success)?.error||`${o.charAt(0).toUpperCase()+o.slice(1)} failed. Please try again.`})}),!m&&l("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[!L&&F&&l("button",{onClick:F,onMouseEnter:()=>h("retry-tx"),onMouseLeave:()=>{h(null),w(null)},onMouseDown:()=>w("retry-tx"),onMouseUp:()=>w(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:y==="retry-tx"?"#d43d3d":A==="retry-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:y==="retry-results"?"scale(0.98)":A==="retry-results"?"translateY(-2px)":"none",boxShadow:y==="retry-tx"?"1px 1px 0px black":A==="retry-tx"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:["TRY AGAIN $",o]}),L&&e("button",{onClick:R,onMouseEnter:()=>h("continue-tx"),onMouseLeave:()=>{h(null),w(null)},onMouseDown:()=>w("continue-tx"),onMouseUp:()=>w(null),style:{width:"100%",height:"48px",padding:"14px 24px",borderRadius:"6px",backgroundColor:y==="continue-tx"?"#d43d3d":A==="continue-tx"?"#f05555":"#ea4b4b",border:"1px solid #0e0d0b",color:"#0e0d0b",fontFamily:'"IBM Plex Mono", monospace',fontWeight:500,fontSize:"16px",lineHeight:"156%",textTransform:"uppercase",cursor:"pointer",transition:"all 0.15s ease",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px",transform:y==="continue-tx"?"scale(0.98)":A==="continue-tx"?"translateY(-2px)":"none",boxShadow:y==="continue-tx"?"1px 1px 0px black":A==="continue-results"?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"DONE"})]})]}),e("style",{children:`
|
|
48
48
|
@keyframes slideUp {
|
|
49
49
|
from {
|
|
50
50
|
transform: translateY(100%);
|
|
@@ -61,7 +61,7 @@ import{defineChain as mo,createPublicClient as yo,http as xo,isAddress as eo,get
|
|
|
61
61
|
transform: translateY(100%);
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
`})]})},Yo=({depositBatches:t,tokenAddress:n,tokenDecimals:i,tokenTransferAmount:r,supportedChains:o,supportedTokens:a,theme:c="light",styles:s,className:g="",depositInputHook:f,onDepositSuccess:u,onDepositError:d,onTopUp:k,submitButtonText:F})=>{const S=De(c),m={...S,typography:{...S.typography,fontFamily:s?.fontFamily||S.typography.fontFamily},colors:{...S.colors,primary:s?.primaryColor||S.colors.primary,primaryHover:s?.primaryColor?`${s.primaryColor}dd`:S.colors.primaryHover}},p=Gt(),{isReady:I,isAuthenticated:E,isConnected:b,address:C,provider:A,actions:h}=p,[y,w]=x(null),{assets:R,loading:H,error:L,hasBalance:re,refetch:X}=Vo({address:C,supportedChains:o,enabled:b,refetchInterval:3e4}),[$,O]=x(!1),[T,P]=x(null),[B,q]=x(!1),[M,j]=x(!1),[D,oe]=x(!1),ce=Me(null),{intentStatus:ee,startStatusPolling:be,clearStatus:U}=Lt({checkStepStatus:(ie,Q)=>ve.checkStepStatus(ie,Q)});_(()=>{if(ee?.overallStatus==="success"&&ee.intentId&&ce.current!==ee.intentId&&y&&C){const ie=ee.steps.find(Q=>Q.transactionHash);if(ie?.transactionHash){ce.current=ee.intentId;const Q=Ge(y.amount,y.asset.decimals);ve.submitSpiceDeposit({user:C,txHash:ie.transactionHash,sender:C,tokenAddress:y.asset.address,chainId:y.asset.chainId,amount:Q.toString(),isDeposit:!1}).then(()=>{X()}).catch(()=>{ce.current=null})}}},[ee,C]),_(()=>{f&&f.assetAmount!==y?.amount&&y&&w({...y,amount:f.assetAmount})},[f?.assetAmount,y]),_(()=>{if(!f?.selectedAsset)return;const ie=f.selectedAsset,Q=ie.address.toLowerCase(),se=Q==="0x0"||Q==="0x0000000000000000000000000000000000000000"||Q==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",fe=R.find(W=>{const N=W.address.toLowerCase();return(se&&W.isNative||N===Q)&&(ie.chainId?W.chainId===ie.chainId:!0)});fe&&w(W=>({asset:fe,amount:W?.amount||f.assetAmount||""}))},[f?.selectedAsset,R,f?.assetAmount]);const J=ne(()=>{P(null)},[]),he=ie=>{w({asset:ie,amount:y?.amount||""}),f?.setSelectedAsset&&f.setSelectedAsset({symbol:ie.symbol,address:ie.address,decimals:ie.decimals,chainId:ie.chainId}),J()},ae=ne(ie=>{y&&(wo(()=>{w({...y,amount:ie}),J()}),f&&f.setAssetAmount(ie))},[y,f,J]),Ce=async()=>{if(!(!y||!C||t.length===0)){if(!I||!E){P(`Please authenticate with ${A||"wallet provider"} to continue`);return}O(!0),P(null),oe(!0);try{const ie=[...t],Q=[...new Set(ie.map(v=>v.chainId))],se=[];for(const v of Q){const te=Pe(v),pe=xt(v),me=await Yt(C,te),He=await h.signAuthorization({contractAddress:pe,chainId:v,nonce:Number(me)});se.push(He)}const fe=qt(ie),W=Math.floor(Date.now()/1e3)+60*10,N=jt(0n,BigInt(W),fe),Z=await h.signMessage({raw:N}),le=typeof Z=="string"?Z:Z.signature;if(!le)throw new Error("Failed to sign intent authorization");const ue={mode:"7702",signatureType:"ecdsa",signature:le,nbf:0,exp:W,chainBatches:fe.map(v=>({hash:v.hash,chainId:v.chainId,tokenTransfers:[{from:"solver",to:C,token:"0x0000000000000000000000000000000000000000",amount:Ge("0.00001",18)},{from:"solver",to:C,token:n,amount:r??Ge(y.amount,i)}],calls:v.calls}))},ge=await ve.createAction({user:C,chainAuthorizations:se.map(v=>({...v,r:v.r,s:v.s,yParity:v.yParity,address:v.address,chainId:Number(v.chainId),nonce:Number(v.nonce)})),intents:[ue]});if(ge){const v=Ht(ie,He=>`Chain ${He}`),[te,pe]=ge.intentIds[0].split("/"),me=parseInt(pe||"0",10);be(ge.intentIds[0],v);for(let He=0;He<ie.length;He++)await ve.executeStep(te,me,He,{action:"execute"})}}catch(ie){const Q=ie instanceof Error?ie.message:"Deposit failed";P(Q),d?.(Q)}finally{O(!1)}}},Ae=Fe(()=>a&&a.length>0?R.filter(ie=>a.some(Q=>Q.toLowerCase()===ie.symbol.toLowerCase())):R,[R,a]),ye=y&&y.amount&&parseFloat(y.amount)>0&&parseFloat(y.amount)<=y.asset.balanceFormatted&&b&&!$&&t.length>0,xe=L||T,Be={backgroundColor:s?.container?.backgroundColor||s?.primaryBackground||m.colors.background,border:`1px solid ${s?.container?.borderColor||m.colors.border}`,borderRadius:s?.container?.borderRadius||m.borderRadius.lg,padding:s?.container?.padding||m.spacing.md,width:s?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:m.colors.text,fontFamily:m.typography.fontFamily,boxShadow:s?.container?.boxShadow||(m.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")},Je=ee?e(lo,{type:"deposit",isOpen:!!ee&&ee.overallStatus!=="processing",isProcessing:$||ee?.overallStatus==="processing",closeOnComplete:!0,onRetryTx:()=>{U(),oe(!1),Ce()},onNewTx:()=>{U(),oe(!1),w(null),ce.current=null,X()},onClose:()=>{U(),oe(!1)},onComplete:()=>{U(),oe(!1),w(null),ce.current=null,X()},results:ee?.overallStatus==="success"||ee?.overallStatus==="failed"?ee.steps.map(ie=>({asset:{symbol:y?.asset.symbol||"Token",address:y?.asset.address||""},txHash:ie.transactionHash||"",success:ie.status==="success",amount:y?.amount})):void 0,chainName:y?lt(t[t.length-1].chainId):"Network",explorerUrl:y?Jt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:m}):null;return l("div",{style:{...Be,position:"relative"},className:g,children:[Je&&e("div",{style:{position:"absolute",top:0,left:"-25px",right:"-25px",bottom:"-16px"},children:e("div",{style:{position:"absolute",width:"100%",height:"100%",pointerEvents:"auto"},children:Je})}),!H&&!re&&e("div",{style:{backgroundColor:m.mode==="light"?"#fef3c7":`${m.colors.warning||"#f59e0b"}20`,border:`1px solid ${m.mode==="light"?"#fcd34d":m.colors.warning||"#f59e0b"}`,borderRadius:m.borderRadius.md,padding:m.spacing.md,marginBottom:m.spacing.md,textAlign:"center"},children:l("p",{style:{color:m.mode==="light"?"#92400e":"#fbbf24",fontSize:m.typography.fontSize.sm,fontFamily:m.typography.fontFamily,margin:0,lineHeight:1.5},children:["You do not have any cross-chain balance."," ",k&&e("span",{onClick:k,style:{color:m.colors.primary,textDecoration:"underline",cursor:"pointer",fontWeight:600},children:"Top-up here."})]})}),e("div",{style:{marginBottom:m.spacing.sm},children:e(At,{assets:Ae,selectedAsset:y||void 0,onAssetSelect:he,onAmountChange:ae,loading:H,label:"Amount",showBalance:!0,showMaxButton:!0,theme:m,styles:s})}),xe&&e("div",{style:{backgroundColor:s?.errorMessage?.backgroundColor||(m.mode==="light"?"#fef2f2":`${s?.statusDisplay?.errorColor||m.colors.error}20`),border:`1px solid ${s?.errorMessage?.borderColor||(m.mode==="light"?"#fecaca":s?.statusDisplay?.errorColor||m.colors.error)}`,borderRadius:s?.errorMessage?.borderRadius||m.borderRadius.md,padding:s?.errorMessage?.padding||m.spacing.md,marginBottom:m.spacing.sm},children:e("p",{style:{color:s?.errorMessage?.color||s?.statusDisplay?.errorColor||m.colors.error,fontSize:s?.errorMessage?.fontSize||m.typography.fontSize.sm,fontWeight:s?.errorMessage?.fontWeight,fontFamily:s?.errorMessage?.fontFamily||m.typography.fontFamily,margin:0},children:xe})}),e("div",{style:{display:"flex",flexDirection:"column",gap:m.spacing.sm},children:e(Qe,{variant:"outline",fullWidth:!0,onClick:Ce,onMouseEnter:()=>q(!0),onMouseLeave:()=>{q(!1),j(!1)},onMouseDown:()=>j(!0),onMouseUp:()=>j(!1),loading:$,disabled:!ye||!b,theme:m,styles:s,style:{width:"100%",padding:"8px",backgroundColor:ye?M?"#d43d3d":B?"#f05555":"#ea4b4b":"#d1d5db",color:ye?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:ye?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:ye?M?"scale(0.98)":B?"translateY(-2px)":"none":"none",boxShadow:M?"1px 1px 0px black":B&&ye?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:I?E?b?$?"Executing Deposit...":y?y.amount?parseFloat(y.amount)>y.asset.balanceFormatted?"Insufficient Balance":t.length===0?"No Deposit Batches":F||"Execute Deposit":"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},pr=({isOpen:t,onClose:n,title:i="Deposit",maxWidth:r="480px",depositBatches:o,tokenAddress:a,tokenDecimals:c,tokenTransferAmount:s,supportedChains:g,supportedTokens:f,theme:u="light",styles:d,className:k,depositInputHook:F,onDepositSuccess:S,onDepositError:m,submitButtonText:p})=>{const I=De(u),E=b=>{S?.(b)};return e(ht,{isOpen:t,onClose:n,title:i,subtitle:l("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e("img",{src:Kt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:"Use your cross-chain balance to deposit WBTC to earn 6.3% yield, all in one click."})]}),styles:d,theme:I,maxWidth:r,children:e("div",{style:{padding:"0 24px 24px 24px"},children:e(Yo,{depositBatches:o,tokenAddress:a,tokenDecimals:c,tokenTransferAmount:s,supportedChains:g,supportedTokens:f,theme:u,styles:{...d,container:{...d?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:k,depositInputHook:F,onDepositSuccess:E,onDepositError:m,submitButtonText:p})})})},ur=({asset:t,amount:n,onAmountChange:i,onPercentageClick:r,usdValue:o,disabled:a,styles:c,theme:s})=>{const g=t.balanceFormatted??0,f=parseFloat(n)||0,u=g>0?f/g*100:0,[d,k]=x(null),[F,S]=x(null),m=p=>{const I=p.target.value;(I===""||/^\d*\.?\d*$/.test(I))&&i(I)};return e("div",{style:{backgroundColor:"#e9e9e9",border:"0.5px solid #A8A8A7",borderRadius:"6px",padding:"16px",height:"144px",display:"flex",flexDirection:"column",gap:"8px",position:"relative"},children:l("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e("div",{style:{display:"flex",flexDirection:"column",justifyContent:"space-between",height:"100%"},children:l("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e("span",{style:{fontFamily:c?.fontFamily||s.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:"Amount"}),e("input",{type:"text",value:n,onChange:m,placeholder:"0.00",disabled:a,style:{fontFamily:c?.fontFamily||s.typography.fontFamily,fontSize:"40px",fontWeight:700,color:a?"rgba(14, 13, 11, 0.16)":n?"#0e0d0b":"#d1d5db",lineHeight:"1.08",letterSpacing:"-1.2px",backgroundColor:"transparent",border:"none",outline:"none",padding:0,width:"100%",maxWidth:"200px"}})]})}),l("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"space-between",height:"100%",gap:"12px"},children:[l("div",{style:{display:"flex",flexDirection:"column",gap:"8px",alignItems:"flex-end"},children:[l("span",{style:{fontFamily:c?.fontFamily||s.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",g.toFixed(4)]}),e("div",{style:{width:"128px"},children:l("div",{style:{border:"1px solid #CDCFD1",borderRadius:"6px 6px 6px 6px",backgroundColor:"transparent",padding:"8px 12px 8px 8px",display:"flex",alignItems:"center",gap:"8px"},children:[e(st,{symbol:t.symbol,logoURI:t.logoURI,size:30,theme:s}),e("span",{style:{fontFamily:c?.fontFamily||s.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#3c3e42",lineHeight:"1.5"},children:t.symbol})]})})]}),e("div",{style:{display:"flex",gap:"10px",height:"14px",alignItems:"center",justifyContent:"flex-end"},children:[0,25,50,75,100].map((p,I)=>{const E=Math.abs(u-p)<1,b=I===4,C=p/100,A=d===p,h=F===p;return e("button",{onClick:()=>r(p),onMouseEnter:()=>k(p),onMouseLeave:()=>{k(null),S(null)},onMouseDown:()=>S(p),onMouseUp:()=>S(null),disabled:a,title:`${p}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:a?"not-allowed":"pointer",opacity:E?1:A?.8:.5,transform:h?"scale(0.85)":A?"scale(1.15)":"scale(1)",transition:"all 0.15s ease"},children:l("svg",{width:"14",height:"14",viewBox:"0 0 14 14",children:[e("circle",{cx:"7",cy:"7",r:"6.84375",fill:b?"#ea4b4b":"none",stroke:b?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!b&&C>0&&e("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${C>.5?1:0} 1 ${7+6.84375*Math.sin(C*2*Math.PI)} ${7-6.84375*Math.cos(C*2*Math.PI)} Z`,fill:"#3C3E42"})]})},p)})})]})]})})};var hr="data:image/svg+xml,%3csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M5.83337 11.0833C8.73287 11.0833 11.0834 8.73275 11.0834 5.83325C11.0834 2.93376 8.73287 0.583252 5.83337 0.583252C2.93388 0.583252 0.583374 2.93376 0.583374 5.83325C0.583374 8.73275 2.93388 11.0833 5.83337 11.0833Z' stroke='%23757171' stroke-width='1.16667' stroke-linecap='round' stroke-linejoin='round'/%3e%3cpath d='M4.84329 4.48988C5.18981 4.14336 5.36306 3.97011 5.56285 3.90519C5.73859 3.84809 5.92789 3.84809 6.10363 3.90519C6.30342 3.97011 6.47668 4.14336 6.82319 4.48988L7.17663 4.84331C7.52314 5.18983 7.6964 5.36308 7.76131 5.56287C7.81841 5.73861 7.81841 5.92791 7.76131 6.10365C7.6964 6.30344 7.52314 6.4767 7.17663 6.82321L6.82319 7.17665C6.47668 7.52316 6.30342 7.69642 6.10363 7.76133C5.92789 7.81843 5.73859 7.81843 5.56285 7.76133C5.36306 7.69642 5.18981 7.52316 4.84329 7.17665L4.48986 6.82321C4.14334 6.4767 3.97009 6.30344 3.90517 6.10365C3.84807 5.92791 3.84807 5.73861 3.90517 5.56287C3.97009 5.36308 4.14334 5.18983 4.48986 4.84331L4.84329 4.48988Z' stroke='%23757171' stroke-width='1.16667' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e";const gr=({isOpen:t,onClose:n,onComplete:i,title:r="Deposit to Spicenet",description:o="Select tokens and enter amounts to deposit to your Spicenet Account",chainId:a,embeddedWalletAddress:c,externalWalletAddress:s,escrowAddress:g="0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",airdropTokenSymbol:f,getChainConfig:u,getSupportedTokens:d})=>{const k=De("light"),[F,S]=x(new Map),[m,p]=x(!1),[I,E]=x(null),[b,C]=x([]),[A,h]=x(!1),[y,w]=x(null),[R,H]=x(null),[L,re]=x(!1),[X,$]=x(!1),[O,T]=x(!1),[P,B]=x(!1);x(null),x(null);const[q,M]=x(null),{chain:j}=pt(),{data:D,isLoading:oe}=Pt(),{switchChainAsync:ce}=Wt(),ee=Fe(()=>d(a),[a,d]),{erc20Tokens:be,nativeToken:U}=Fe(()=>{const W=[];let N=null;return ee.forEach(Z=>{bt(Z.address)?N=Z:W.push(Z)}),{erc20Tokens:W,nativeToken:N}},[ee]),{data:J}=vo({contracts:be.map(W=>({address:W.address,abi:Vt,functionName:"balanceOf",args:[s],chainId:a}))}),{data:he}=kn({address:s,chainId:a}),ae=Fe(()=>{if(!u(a))return[];const W=[];if(U){const N=U,Z=he?.value??BigInt(0),le=Number(Z)/Math.pow(10,N.decimals);W.push({address:N.address,symbol:N.symbol,name:N.name,decimals:N.decimals,isNative:!0,chainId:a,balance:Z,balanceFormatted:le})}return be.forEach((N,Z)=>{const le=J?.[Z],ue=le?.status==="success"?le.result:BigInt(0),ge=Number(ue)/Math.pow(10,N.decimals);W.push({address:N.address,symbol:N.symbol,name:N.name,decimals:N.decimals,isNative:!1,chainId:a,balance:ue,balanceFormatted:ge})}),W},[a,J,he,be,U,u]);Fe(()=>f?ae.find(W=>W.symbol.toUpperCase()===f.toUpperCase()):void 0,[ae,f]),_(()=>{if(ae.length>0&&F.size>0){const W=new Map(F);let N=!1;F.forEach((Z,le)=>{const ue=ae.find(ge=>ge.address===le);ue&&ue.balanceFormatted!==Z.asset.balanceFormatted&&(W.set(le,{...Z,asset:ue}),N=!0)}),N&&S(W)}},[ae,F]);const Ce=u(a),Ae=W=>{const N=new Map(F);N.has(W.address)?N.delete(W.address):N.set(W.address,{asset:W,amount:""}),S(N),E(null)},ye=(W,N)=>{if(N===""||/^\d*\.?\d*$/.test(N)){const Z=new Map(F),le=Z.get(W);if(le){let ue=N;if(N!==""&&le.asset.balanceFormatted!==void 0){const ge=parseFloat(N);!isNaN(ge)&&ge>le.asset.balanceFormatted&&(ue=le.asset.balanceFormatted.toString())}Z.set(W,{...le,amount:ue}),S(Z),E(null)}}},xe=(W,N)=>{const Z=F.get(W);if(Z?.asset.balanceFormatted!==void 0){const le=Z.asset.balanceFormatted*N/100,ue=Math.floor(le*1e6)/1e6;ye(W,ue.toString())}},Be=ne(async()=>{if(F.size===0){E("Please select at least one asset");return}for(const[N,Z]of Array.from(F.entries())){if(!Z.amount){E(`Please enter an amount for ${Z.asset.symbol}`);return}const le=parseFloat(Z.amount);if(isNaN(le)||le<=0){E(`Please enter a valid amount for ${Z.asset.symbol}`);return}const ue=ae.find(ge=>ge.address===N)?.balanceFormatted??Z.asset.balanceFormatted;if(ue!==void 0&&le>ue){E(`Insufficient ${Z.asset.symbol} balance`);return}}if(!D){E("Wallet not connected. Please reconnect your external wallet.");return}p(!0),E(null);const W=[];try{j?.id!==a&&await ce({chainId:a});for(const[,N]of Array.from(F.entries())){const{asset:Z,amount:le}=N;try{const ue=Ge(le,Z.decimals);let ge;if(Z.isNative)ge=await D.sendTransaction({to:g,value:ue});else{const pe=Bt({abi:Vt,functionName:"transfer",args:[g,ue]});ge=await D.sendTransaction({to:Z.address,data:pe})}const v=Pe(a),te=await v.waitForTransactionReceipt({hash:ge,timeout:12e4,pollingInterval:2e3,confirmations:2});if(te.status!=="success")throw new Error(`Transfer to escrow failed for ${Z.symbol}`);await v.getBlockNumber()-te.blockNumber<2&&await new Promise(pe=>setTimeout(pe,3e3)),await ve.submitSpiceDeposit({txHash:ge,sender:c,tokenAddress:Z.address,chainId:a,amount:Ge(le,Z.decimals).toString(),user:c,isDeposit:!0}),W.push({asset:Z,txHash:ge,success:!0})}catch(ue){const ge=ue;let v=ge?.message||"Deposit failed";ge?.code===4001||ge?.message?.includes("rejected")?v="Transaction rejected by user":ge?.message?.includes("insufficient funds")&&(v="Insufficient funds for transaction"),W.push({asset:Z,txHash:"",success:!1,error:v})}}C(W),h(!0);try{const N=Array.from(F.values())[0];N?.asset&&N.amount&&sessionStorage.setItem("spiceflow:lastDepositSelection",JSON.stringify({symbol:N.asset.symbol,address:N.asset.address,decimals:N.asset.decimals,chainId:N.asset.chainId,amount:N.amount}))}catch{}}catch(N){E(N?.message||"Deposit failed")}finally{p(!1)}},[F,D,j,a,ce,g,ae]);_(()=>{t||(S(new Map),E(null),C([]),h(!1),p(!1))},[t]);const Je=ne(()=>{C([]),h(!1),E(null)},[]),ie=ne(()=>{window.dispatchEvent(new CustomEvent("cross-chain-deposit-skipped"))},[]),Q=F.size>0&&Array.from(F.values()).every(W=>W.amount&&parseFloat(W.amount)>0)&&!m&&!A&&D,se=l("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e("img",{src:Kt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:o})]}),fe=m||A&&b.length>0?e(lo,{type:"deposit",isOpen:A&&b.length>0,isProcessing:m,onClose:n,onComplete:i,closeOnComplete:!1,onRetryTx:Je,onNewTx:()=>{},results:b.length>0?b.map(W=>({asset:{symbol:W.asset.symbol,address:W.asset.address},txHash:W.txHash,success:W.success,error:W.error})):void 0,chainName:lt(a),explorerUrl:Ce?.blockExplorers?.default?.url,theme:k}):null;return l(ht,{isOpen:t,onClose:n,title:r,subtitle:se,theme:k,maxWidth:"480px",children:[l("div",{style:{padding:"0 24px 32px 24px",position:"relative",display:"flex",flexDirection:"column",maxHeight:"calc(80vh - 180px)"},children:[fe&&e("div",{style:{position:"absolute",inset:0,overflow:"hidden",pointerEvents:"none",zIndex:10},children:e("div",{style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto"},children:fe})}),l("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,paddingRight:"4px",marginRight:"-4px"},children:[l("div",{style:{marginBottom:"16px"},children:[e("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",marginBottom:"10px"},children:l("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[e("span",{style:{fontSize:"14px",color:"#6b7280"},children:e("img",{src:hr,alt:"Info",style:{width:"10.5px",height:"10.5px",top:"1.75px",left:"1.75px",flexShrink:0}})}),e("label",{style:{fontSize:"12px",fontWeight:590,color:"#374151"},children:"Select Assets to Deposit"})]})}),e("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:ae.map(W=>{const N=F.has(W.address);return e("div",{onClick:()=>Ae(W),onMouseEnter:()=>w(W.address),onMouseLeave:()=>{w(null),H(null)},onMouseDown:()=>H(W.address),onMouseUp:()=>H(null),style:{padding:"4px 8px 4px 8px",borderRadius:"8px",border:`1px solid ${N?"#EA4B4B7A":y===W.address?"#F4A5A5":"#e5e7eb"}`,backgroundColor:N?"#FEF2F2":R===W.address?"#f5f5f5":y===W.address?"#fafafa":"white",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease",transform:R===W.address?"scale(0.96)":y===W.address?"translateY(-1px)":"none",boxShadow:N?"0 0 0 3px #FBDBDB":R===W.address?"0 1px 2px rgba(0, 0, 0, 0.05)":y===W.address?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:l("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e(st,{symbol:W.symbol,size:24,theme:k}),e("span",{style:{fontSize:"16px",fontWeight:510,color:"#3C3E42"},children:W.symbol}),W.balanceFormatted!==void 0&&l("span",{style:{fontSize:"10px",fontWeight:500,color:"#939291",fontFamily:'"IBM Plex Mono", monospace'},children:["(",W.balanceFormatted.toFixed(4),")"]})]})},W.address)})})]}),F.size>0&&e("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:Array.from(F.values()).map(({asset:W,amount:N})=>e(ur,{asset:W,amount:N,onAmountChange:Z=>ye(W.address,Z),onPercentageClick:Z=>xe(W.address,Z),theme:k,disabled:m},W.address))})]}),I&&e("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginTop:"16px"},children:e("p",{style:{fontSize:"14px",color:"#dc2626",margin:0},children:I})}),!A&&l("div",{style:{display:"flex",gap:"12px",marginTop:"20px"},children:[e(Qe,{variant:"outline",onClick:Be,onMouseEnter:()=>re(!0),onMouseLeave:()=>{re(!1),$(!1)},onMouseDown:()=>$(!0),onMouseUp:()=>$(!1),disabled:!Q,theme:k,style:{flex:2,padding:"8px",backgroundColor:Q?X?"#d43d3d":L?"#f05555":"#ea4b4b":"#d1d5db",color:Q?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:Q?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:Q?X?"scale(0.98)":L?"translateY(-2px)":"none":"none",boxShadow:X?"1px 1px 0px black":L&&Q?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:m?l(je,{children:[e("div",{style:{width:"18px",height:"18px",border:"2px solid white",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),e("span",{children:"PROCESSING..."})]}):oe?"CONNECTING WALLET...":D?F.size===0?"SELECT ASSETS":Array.from(F.values()).every(W=>W.amount)?"DEPOSIT":"ENTER AMOUNTS":"WALLET NOT CONNECTED"}),e(Qe,{variant:"outline",onClick:ie,onMouseEnter:()=>T(!0),onMouseLeave:()=>{T(!1),B(!1)},onMouseDown:()=>B(!0),onMouseUp:()=>B(!1),disabled:m,theme:k,style:{flex:1,padding:"8px",backgroundColor:P?"#d43d3d":O?"#f05555":"#ea4b4b",color:"#0e0d0b",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:m?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:P?"scale(0.98)":O?"translateY(-2px)":"none",boxShadow:P?"1px 1px 0px black":O?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"SKIP"})]}),e("style",{children:`
|
|
64
|
+
`})]})},Yo=({depositBatches:t,tokenAddress:n,tokenDecimals:i,tokenTransferAmount:r,supportedChains:o,supportedTokens:a,theme:c="light",styles:s,className:g="",depositInputHook:f,onDepositSuccess:u,onDepositError:d,onTopUp:k,submitButtonText:F})=>{const S=De(c),m={...S,typography:{...S.typography,fontFamily:s?.fontFamily||S.typography.fontFamily},colors:{...S.colors,primary:s?.primaryColor||S.colors.primary,primaryHover:s?.primaryColor?`${s.primaryColor}dd`:S.colors.primaryHover}},p=Gt(),{isReady:I,isAuthenticated:E,isConnected:b,address:C,provider:A,actions:h}=p,[y,w]=x(null),{assets:R,loading:H,error:L,hasBalance:re,refetch:X}=Vo({address:C,supportedChains:o,enabled:b,refetchInterval:3e4}),[$,O]=x(!1),[T,P]=x(null),[B,q]=x(!1),[M,j]=x(!1),[D,oe]=x(!1),ce=Me(null),{intentStatus:ee,startStatusPolling:be,clearStatus:U}=Lt({checkStepStatus:(ie,Q)=>ve.checkStepStatus(ie,Q)});_(()=>{if(ee?.overallStatus==="success"&&ee.intentId&&ce.current!==ee.intentId&&y&&C){const ie=ee.steps.find(Q=>Q.transactionHash);if(ie?.transactionHash){ce.current=ee.intentId;const Q=Ge(y.amount,y.asset.decimals);ve.submitSpiceDeposit({user:C,txHash:ie.transactionHash,sender:C,tokenAddress:y.asset.address,chainId:y.asset.chainId,amount:Q.toString(),isDeposit:!1}).then(()=>{X()}).catch(()=>{ce.current=null})}}},[ee,C]),_(()=>{f&&f.assetAmount!==y?.amount&&y&&w({...y,amount:f.assetAmount})},[f?.assetAmount,y]),_(()=>{if(!f?.selectedAsset)return;const ie=f.selectedAsset,Q=ie.address.toLowerCase(),se=Q==="0x0"||Q==="0x0000000000000000000000000000000000000000"||Q==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",fe=R.find(W=>{const N=W.address.toLowerCase();return(se&&W.isNative||N===Q)&&(ie.chainId?W.chainId===ie.chainId:!0)});fe&&w(W=>({asset:fe,amount:W?.amount||f.assetAmount||""}))},[f?.selectedAsset,R,f?.assetAmount]);const J=ne(()=>{P(null)},[]),he=ie=>{w({asset:ie,amount:y?.amount||""}),f?.setSelectedAsset&&f.setSelectedAsset({symbol:ie.symbol,address:ie.address,decimals:ie.decimals,chainId:ie.chainId}),J()},ae=ne(ie=>{y&&(wo(()=>{w({...y,amount:ie}),J()}),f&&f.setAssetAmount(ie))},[y,f,J]),Ce=async()=>{if(!(!y||!C||t.length===0)){if(!I||!E){P(`Please authenticate with ${A||"wallet provider"} to continue`);return}O(!0),P(null),oe(!0);try{const ie=[...t],Q=[...new Set(ie.map(v=>v.chainId))],se=[];for(const v of Q){const te=Pe(v),pe=xt(v),me=await Yt(C,te),He=await h.signAuthorization({contractAddress:pe,chainId:v,nonce:Number(me)});se.push(He)}const fe=qt(ie),W=Math.floor(Date.now()/1e3)+60*10,N=jt(0n,BigInt(W),fe),Z=await h.signMessage({raw:N}),le=typeof Z=="string"?Z:Z.signature;if(!le)throw new Error("Failed to sign intent authorization");const ue={mode:"7702",signatureType:"ecdsa",signature:le,nbf:0,exp:W,chainBatches:fe.map(v=>({hash:v.hash,chainId:v.chainId,tokenTransfers:[{from:"solver",to:C,token:"0x0000000000000000000000000000000000000000",amount:Ge("0.00001",18)},{from:"solver",to:C,token:n,amount:r??Ge(y.amount,i)}],calls:v.calls}))},ge=await ve.createAction({user:C,chainAuthorizations:se.map(v=>({...v,r:v.r,s:v.s,yParity:v.yParity,address:v.address,chainId:Number(v.chainId),nonce:Number(v.nonce)})),intents:[ue]});if(ge){const v=Ht(ie,He=>`Chain ${He}`),[te,pe]=ge.intentIds[0].split("/"),me=parseInt(pe||"0",10);be(ge.intentIds[0],v);for(let He=0;He<ie.length;He++)await ve.executeStep(te,me,He,{action:"execute"})}}catch(ie){const Q=ie instanceof Error?ie.message:"Deposit failed";P(Q),d?.(Q)}finally{O(!1),window.dispatchEvent(new CustomEvent("deposit-completed"))}}},Ae=Fe(()=>a&&a.length>0?R.filter(ie=>a.some(Q=>Q.toLowerCase()===ie.symbol.toLowerCase())):R,[R,a]),ye=y&&y.amount&&parseFloat(y.amount)>0&&parseFloat(y.amount)<=y.asset.balanceFormatted&&b&&!$&&t.length>0,xe=L||T,Be={backgroundColor:s?.container?.backgroundColor||s?.primaryBackground||m.colors.background,border:`1px solid ${s?.container?.borderColor||m.colors.border}`,borderRadius:s?.container?.borderRadius||m.borderRadius.lg,padding:s?.container?.padding||m.spacing.md,width:s?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:m.colors.text,fontFamily:m.typography.fontFamily,boxShadow:s?.container?.boxShadow||(m.mode==="light"?"0 4px 6px -1px rgb(0 0 0 / 0.1)":"0 4px 6px -1px rgb(0 0 0 / 0.3)")},Je=ee?e(lo,{type:"deposit",isOpen:!!ee&&ee.overallStatus!=="processing",isProcessing:$||ee?.overallStatus==="processing",closeOnComplete:!0,onRetryTx:()=>{U(),oe(!1),Ce()},onNewTx:()=>{U(),oe(!1),w(null),ce.current=null,X()},onClose:()=>{U(),oe(!1)},onComplete:()=>{U(),oe(!1),w(null),ce.current=null,X()},results:ee?.overallStatus==="success"||ee?.overallStatus==="failed"?ee.steps.map(ie=>({asset:{symbol:y?.asset.symbol||"Token",address:y?.asset.address||""},txHash:ie.transactionHash||"",success:ie.status==="success",amount:y?.amount})):void 0,chainName:y?lt(t[t.length-1].chainId):"Network",explorerUrl:y?Jt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:m}):null;return l("div",{style:{...Be,position:"relative"},className:g,children:[Je&&e("div",{style:{position:"absolute",top:0,left:"-25px",right:"-25px",bottom:"-16px"},children:e("div",{style:{position:"absolute",width:"100%",height:"100%",pointerEvents:"auto"},children:Je})}),!H&&!re&&e("div",{style:{backgroundColor:m.mode==="light"?"#fef3c7":`${m.colors.warning||"#f59e0b"}20`,border:`1px solid ${m.mode==="light"?"#fcd34d":m.colors.warning||"#f59e0b"}`,borderRadius:m.borderRadius.md,padding:m.spacing.md,marginBottom:m.spacing.md,textAlign:"center"},children:l("p",{style:{color:m.mode==="light"?"#92400e":"#fbbf24",fontSize:m.typography.fontSize.sm,fontFamily:m.typography.fontFamily,margin:0,lineHeight:1.5},children:["You do not have any cross-chain balance."," ",k&&e("span",{onClick:k,style:{color:m.colors.primary,textDecoration:"underline",cursor:"pointer",fontWeight:600},children:"Top-up here."})]})}),e("div",{style:{marginBottom:m.spacing.sm},children:e(At,{assets:Ae,selectedAsset:y||void 0,onAssetSelect:he,onAmountChange:ae,loading:H,label:"Amount",showBalance:!0,showMaxButton:!0,theme:m,styles:s})}),xe&&e("div",{style:{backgroundColor:s?.errorMessage?.backgroundColor||(m.mode==="light"?"#fef2f2":`${s?.statusDisplay?.errorColor||m.colors.error}20`),border:`1px solid ${s?.errorMessage?.borderColor||(m.mode==="light"?"#fecaca":s?.statusDisplay?.errorColor||m.colors.error)}`,borderRadius:s?.errorMessage?.borderRadius||m.borderRadius.md,padding:s?.errorMessage?.padding||m.spacing.md,marginBottom:m.spacing.sm},children:e("p",{style:{color:s?.errorMessage?.color||s?.statusDisplay?.errorColor||m.colors.error,fontSize:s?.errorMessage?.fontSize||m.typography.fontSize.sm,fontWeight:s?.errorMessage?.fontWeight,fontFamily:s?.errorMessage?.fontFamily||m.typography.fontFamily,margin:0},children:xe})}),e("div",{style:{display:"flex",flexDirection:"column",gap:m.spacing.sm},children:e(Qe,{variant:"outline",fullWidth:!0,onClick:Ce,onMouseEnter:()=>q(!0),onMouseLeave:()=>{q(!1),j(!1)},onMouseDown:()=>j(!0),onMouseUp:()=>j(!1),loading:$,disabled:!ye||!b,theme:m,styles:s,style:{width:"100%",padding:"8px",backgroundColor:ye?M?"#d43d3d":B?"#f05555":"#ea4b4b":"#d1d5db",color:ye?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:ye?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:ye?M?"scale(0.98)":B?"translateY(-2px)":"none":"none",boxShadow:M?"1px 1px 0px black":B&&ye?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:I?E?b?$?"Executing Deposit...":y?y.amount?parseFloat(y.amount)>y.asset.balanceFormatted?"Insufficient Balance":t.length===0?"No Deposit Batches":F||"Execute Deposit":"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},pr=({isOpen:t,onClose:n,title:i="Deposit",maxWidth:r="480px",depositBatches:o,tokenAddress:a,tokenDecimals:c,tokenTransferAmount:s,supportedChains:g,supportedTokens:f,theme:u="light",styles:d,className:k,depositInputHook:F,onDepositSuccess:S,onDepositError:m,submitButtonText:p})=>{const I=De(u),E=b=>{S?.(b)};return e(ht,{isOpen:t,onClose:n,title:i,subtitle:l("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e("img",{src:Kt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:"Use your cross-chain balance to deposit WBTC to earn 6.3% yield, all in one click."})]}),styles:d,theme:I,maxWidth:r,children:e("div",{style:{padding:"0 24px 24px 24px"},children:e(Yo,{depositBatches:o,tokenAddress:a,tokenDecimals:c,tokenTransferAmount:s,supportedChains:g,supportedTokens:f,theme:u,styles:{...d,container:{...d?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:k,depositInputHook:F,onDepositSuccess:E,onDepositError:m,submitButtonText:p})})})},ur=({asset:t,amount:n,onAmountChange:i,onPercentageClick:r,usdValue:o,disabled:a,styles:c,theme:s})=>{const g=t.balanceFormatted??0,f=parseFloat(n)||0,u=g>0?f/g*100:0,[d,k]=x(null),[F,S]=x(null),m=p=>{const I=p.target.value;(I===""||/^\d*\.?\d*$/.test(I))&&i(I)};return e("div",{style:{backgroundColor:"#e9e9e9",border:"0.5px solid #A8A8A7",borderRadius:"6px",padding:"16px",height:"144px",display:"flex",flexDirection:"column",gap:"8px",position:"relative"},children:l("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e("div",{style:{display:"flex",flexDirection:"column",justifyContent:"space-between",height:"100%"},children:l("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[e("span",{style:{fontFamily:c?.fontFamily||s.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:"Amount"}),e("input",{type:"text",value:n,onChange:m,placeholder:"0.00",disabled:a,style:{fontFamily:c?.fontFamily||s.typography.fontFamily,fontSize:"40px",fontWeight:700,color:a?"rgba(14, 13, 11, 0.16)":n?"#0e0d0b":"#d1d5db",lineHeight:"1.08",letterSpacing:"-1.2px",backgroundColor:"transparent",border:"none",outline:"none",padding:0,width:"100%",maxWidth:"200px"}})]})}),l("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",justifyContent:"space-between",height:"100%",gap:"12px"},children:[l("div",{style:{display:"flex",flexDirection:"column",gap:"8px",alignItems:"flex-end"},children:[l("span",{style:{fontFamily:c?.fontFamily||s.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",g.toFixed(4)]}),e("div",{style:{width:"128px"},children:l("div",{style:{border:"1px solid #CDCFD1",borderRadius:"6px 6px 6px 6px",backgroundColor:"transparent",padding:"8px 12px 8px 8px",display:"flex",alignItems:"center",gap:"8px"},children:[e(st,{symbol:t.symbol,logoURI:t.logoURI,size:30,theme:s}),e("span",{style:{fontFamily:c?.fontFamily||s.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#3c3e42",lineHeight:"1.5"},children:t.symbol})]})})]}),e("div",{style:{display:"flex",gap:"10px",height:"14px",alignItems:"center",justifyContent:"flex-end"},children:[0,25,50,75,100].map((p,I)=>{const E=Math.abs(u-p)<1,b=I===4,C=p/100,A=d===p,h=F===p;return e("button",{onClick:()=>r(p),onMouseEnter:()=>k(p),onMouseLeave:()=>{k(null),S(null)},onMouseDown:()=>S(p),onMouseUp:()=>S(null),disabled:a,title:`${p}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:a?"not-allowed":"pointer",opacity:E?1:A?.8:.5,transform:h?"scale(0.85)":A?"scale(1.15)":"scale(1)",transition:"all 0.15s ease"},children:l("svg",{width:"14",height:"14",viewBox:"0 0 14 14",children:[e("circle",{cx:"7",cy:"7",r:"6.84375",fill:b?"#ea4b4b":"none",stroke:b?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!b&&C>0&&e("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${C>.5?1:0} 1 ${7+6.84375*Math.sin(C*2*Math.PI)} ${7-6.84375*Math.cos(C*2*Math.PI)} Z`,fill:"#3C3E42"})]})},p)})})]})]})})};var hr="data:image/svg+xml,%3csvg width='12' height='12' viewBox='0 0 12 12' fill='none' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M5.83337 11.0833C8.73287 11.0833 11.0834 8.73275 11.0834 5.83325C11.0834 2.93376 8.73287 0.583252 5.83337 0.583252C2.93388 0.583252 0.583374 2.93376 0.583374 5.83325C0.583374 8.73275 2.93388 11.0833 5.83337 11.0833Z' stroke='%23757171' stroke-width='1.16667' stroke-linecap='round' stroke-linejoin='round'/%3e%3cpath d='M4.84329 4.48988C5.18981 4.14336 5.36306 3.97011 5.56285 3.90519C5.73859 3.84809 5.92789 3.84809 6.10363 3.90519C6.30342 3.97011 6.47668 4.14336 6.82319 4.48988L7.17663 4.84331C7.52314 5.18983 7.6964 5.36308 7.76131 5.56287C7.81841 5.73861 7.81841 5.92791 7.76131 6.10365C7.6964 6.30344 7.52314 6.4767 7.17663 6.82321L6.82319 7.17665C6.47668 7.52316 6.30342 7.69642 6.10363 7.76133C5.92789 7.81843 5.73859 7.81843 5.56285 7.76133C5.36306 7.69642 5.18981 7.52316 4.84329 7.17665L4.48986 6.82321C4.14334 6.4767 3.97009 6.30344 3.90517 6.10365C3.84807 5.92791 3.84807 5.73861 3.90517 5.56287C3.97009 5.36308 4.14334 5.18983 4.48986 4.84331L4.84329 4.48988Z' stroke='%23757171' stroke-width='1.16667' stroke-linecap='round' stroke-linejoin='round'/%3e%3c/svg%3e";const gr=({isOpen:t,onClose:n,onComplete:i,title:r="Deposit to Spicenet",description:o="Select tokens and enter amounts to deposit to your Spicenet Account",chainId:a,embeddedWalletAddress:c,externalWalletAddress:s,escrowAddress:g="0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",airdropTokenSymbol:f,getChainConfig:u,getSupportedTokens:d})=>{const k=De("light"),[F,S]=x(new Map),[m,p]=x(!1),[I,E]=x(null),[b,C]=x([]),[A,h]=x(!1),[y,w]=x(null),[R,H]=x(null),[L,re]=x(!1),[X,$]=x(!1),[O,T]=x(!1),[P,B]=x(!1);x(null),x(null);const[q,M]=x(null),{chain:j}=pt(),{data:D,isLoading:oe}=Pt(),{switchChainAsync:ce}=Wt(),ee=Fe(()=>d(a),[a,d]),{erc20Tokens:be,nativeToken:U}=Fe(()=>{const W=[];let N=null;return ee.forEach(Z=>{bt(Z.address)?N=Z:W.push(Z)}),{erc20Tokens:W,nativeToken:N}},[ee]),{data:J}=vo({contracts:be.map(W=>({address:W.address,abi:Vt,functionName:"balanceOf",args:[s],chainId:a}))}),{data:he}=kn({address:s,chainId:a}),ae=Fe(()=>{if(!u(a))return[];const W=[];if(U){const N=U,Z=he?.value??BigInt(0),le=Number(Z)/Math.pow(10,N.decimals);W.push({address:N.address,symbol:N.symbol,name:N.name,decimals:N.decimals,isNative:!0,chainId:a,balance:Z,balanceFormatted:le})}return be.forEach((N,Z)=>{const le=J?.[Z],ue=le?.status==="success"?le.result:BigInt(0),ge=Number(ue)/Math.pow(10,N.decimals);W.push({address:N.address,symbol:N.symbol,name:N.name,decimals:N.decimals,isNative:!1,chainId:a,balance:ue,balanceFormatted:ge})}),W},[a,J,he,be,U,u]);Fe(()=>f?ae.find(W=>W.symbol.toUpperCase()===f.toUpperCase()):void 0,[ae,f]),_(()=>{if(ae.length>0&&F.size>0){const W=new Map(F);let N=!1;F.forEach((Z,le)=>{const ue=ae.find(ge=>ge.address===le);ue&&ue.balanceFormatted!==Z.asset.balanceFormatted&&(W.set(le,{...Z,asset:ue}),N=!0)}),N&&S(W)}},[ae,F]);const Ce=u(a),Ae=W=>{const N=new Map(F);N.has(W.address)?N.delete(W.address):N.set(W.address,{asset:W,amount:""}),S(N),E(null)},ye=(W,N)=>{if(N===""||/^\d*\.?\d*$/.test(N)){const Z=new Map(F),le=Z.get(W);if(le){let ue=N;if(N!==""&&le.asset.balanceFormatted!==void 0){const ge=parseFloat(N);!isNaN(ge)&&ge>le.asset.balanceFormatted&&(ue=le.asset.balanceFormatted.toString())}Z.set(W,{...le,amount:ue}),S(Z),E(null)}}},xe=(W,N)=>{const Z=F.get(W);if(Z?.asset.balanceFormatted!==void 0){const le=Z.asset.balanceFormatted*N/100,ue=Math.floor(le*1e6)/1e6;ye(W,ue.toString())}},Be=ne(async()=>{if(F.size===0){E("Please select at least one asset");return}for(const[N,Z]of Array.from(F.entries())){if(!Z.amount){E(`Please enter an amount for ${Z.asset.symbol}`);return}const le=parseFloat(Z.amount);if(isNaN(le)||le<=0){E(`Please enter a valid amount for ${Z.asset.symbol}`);return}const ue=ae.find(ge=>ge.address===N)?.balanceFormatted??Z.asset.balanceFormatted;if(ue!==void 0&&le>ue){E(`Insufficient ${Z.asset.symbol} balance`);return}}if(!D){E("Wallet not connected. Please reconnect your external wallet.");return}p(!0),E(null);const W=[];try{j?.id!==a&&await ce({chainId:a});for(const[,N]of Array.from(F.entries())){const{asset:Z,amount:le}=N;try{const ue=Ge(le,Z.decimals);let ge;if(Z.isNative)ge=await D.sendTransaction({to:g,value:ue});else{const pe=Bt({abi:Vt,functionName:"transfer",args:[g,ue]});ge=await D.sendTransaction({to:Z.address,data:pe})}const v=Pe(a),te=await v.waitForTransactionReceipt({hash:ge,timeout:12e4,pollingInterval:2e3,confirmations:2});if(te.status!=="success")throw new Error(`Transfer to escrow failed for ${Z.symbol}`);await v.getBlockNumber()-te.blockNumber<2&&await new Promise(pe=>setTimeout(pe,3e3)),await ve.submitSpiceDeposit({txHash:ge,sender:c,tokenAddress:Z.address,chainId:a,amount:Ge(le,Z.decimals).toString(),user:c,isDeposit:!0}),W.push({asset:Z,txHash:ge,success:!0})}catch(ue){const ge=ue;let v=ge?.message||"Deposit failed";ge?.code===4001||ge?.message?.includes("rejected")?v="Transaction rejected by user":ge?.message?.includes("insufficient funds")&&(v="Insufficient funds for transaction"),W.push({asset:Z,txHash:"",success:!1,error:v})}finally{window.dispatchEvent(new CustomEvent("cross-chain-deposit-completed"))}}C(W),h(!0);try{const N=Array.from(F.values())[0];N?.asset&&N.amount&&sessionStorage.setItem("spiceflow:lastDepositSelection",JSON.stringify({symbol:N.asset.symbol,address:N.asset.address,decimals:N.asset.decimals,chainId:N.asset.chainId,amount:N.amount}))}catch{}}catch(N){E(N?.message||"Deposit failed")}finally{p(!1)}},[F,D,j,a,ce,g,ae]);_(()=>{t||(S(new Map),E(null),C([]),h(!1),p(!1))},[t]);const Je=ne(()=>{C([]),h(!1),E(null)},[]),ie=ne(()=>{window.dispatchEvent(new CustomEvent("cross-chain-deposit-skipped"))},[]),Q=F.size>0&&Array.from(F.values()).every(W=>W.amount&&parseFloat(W.amount)>0)&&!m&&!A&&D,se=l("div",{style:{display:"flex",alignItems:"flex-start",gap:"5px",backgroundColor:"#f9fafb",border:"1px solid #ed6969",borderRadius:"8px",padding:"10px",margin:"0 0 0 0"},children:[e("img",{src:Kt,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:o})]}),fe=m||A&&b.length>0?e(lo,{type:"deposit",isOpen:A&&b.length>0,isProcessing:m,onClose:n,onComplete:i,closeOnComplete:!1,onRetryTx:Je,onNewTx:()=>{},results:b.length>0?b.map(W=>({asset:{symbol:W.asset.symbol,address:W.asset.address},txHash:W.txHash,success:W.success,error:W.error})):void 0,chainName:lt(a),explorerUrl:Ce?.blockExplorers?.default?.url,theme:k}):null;return l(ht,{isOpen:t,onClose:n,title:r,subtitle:se,theme:k,maxWidth:"480px",children:[l("div",{style:{padding:"0 24px 32px 24px",position:"relative",display:"flex",flexDirection:"column",maxHeight:"calc(80vh - 180px)"},children:[fe&&e("div",{style:{position:"absolute",inset:0,overflow:"hidden",pointerEvents:"none",zIndex:10},children:e("div",{style:{position:"relative",width:"100%",height:"100%",pointerEvents:"auto"},children:fe})}),l("div",{style:{flex:1,overflowY:"auto",overflowX:"hidden",minHeight:0,paddingRight:"4px",marginRight:"-4px"},children:[l("div",{style:{marginBottom:"16px"},children:[e("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px",marginBottom:"10px"},children:l("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[e("span",{style:{fontSize:"14px",color:"#6b7280"},children:e("img",{src:hr,alt:"Info",style:{width:"10.5px",height:"10.5px",top:"1.75px",left:"1.75px",flexShrink:0}})}),e("label",{style:{fontSize:"12px",fontWeight:590,color:"#374151"},children:"Select Assets to Deposit"})]})}),e("div",{style:{display:"flex",gap:"12px",flexWrap:"wrap"},children:ae.map(W=>{const N=F.has(W.address);return e("div",{onClick:()=>Ae(W),onMouseEnter:()=>w(W.address),onMouseLeave:()=>{w(null),H(null)},onMouseDown:()=>H(W.address),onMouseUp:()=>H(null),style:{padding:"4px 8px 4px 8px",borderRadius:"8px",border:`1px solid ${N?"#EA4B4B7A":y===W.address?"#F4A5A5":"#e5e7eb"}`,backgroundColor:N?"#FEF2F2":R===W.address?"#f5f5f5":y===W.address?"#fafafa":"white",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease",transform:R===W.address?"scale(0.96)":y===W.address?"translateY(-1px)":"none",boxShadow:N?"0 0 0 3px #FBDBDB":R===W.address?"0 1px 2px rgba(0, 0, 0, 0.05)":y===W.address?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:l("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e(st,{symbol:W.symbol,size:24,theme:k}),e("span",{style:{fontSize:"16px",fontWeight:510,color:"#3C3E42"},children:W.symbol}),W.balanceFormatted!==void 0&&l("span",{style:{fontSize:"10px",fontWeight:500,color:"#939291",fontFamily:'"IBM Plex Mono", monospace'},children:["(",W.balanceFormatted.toFixed(4),")"]})]})},W.address)})})]}),F.size>0&&e("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:Array.from(F.values()).map(({asset:W,amount:N})=>e(ur,{asset:W,amount:N,onAmountChange:Z=>ye(W.address,Z),onPercentageClick:Z=>xe(W.address,Z),theme:k,disabled:m},W.address))})]}),I&&e("div",{style:{padding:"12px",backgroundColor:"#fef2f2",border:"1px solid #fecaca",borderRadius:"8px",marginTop:"16px"},children:e("p",{style:{fontSize:"14px",color:"#dc2626",margin:0},children:I})}),!A&&l("div",{style:{display:"flex",gap:"12px",marginTop:"20px"},children:[e(Qe,{variant:"outline",onClick:Be,onMouseEnter:()=>re(!0),onMouseLeave:()=>{re(!1),$(!1)},onMouseDown:()=>$(!0),onMouseUp:()=>$(!1),disabled:!Q,theme:k,style:{flex:2,padding:"8px",backgroundColor:Q?X?"#d43d3d":L?"#f05555":"#ea4b4b":"#d1d5db",color:Q?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:Q?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:Q?X?"scale(0.98)":L?"translateY(-2px)":"none":"none",boxShadow:X?"1px 1px 0px black":L&&Q?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:m?l(je,{children:[e("div",{style:{width:"18px",height:"18px",border:"2px solid white",borderTopColor:"transparent",borderRadius:"50%",animation:"spin 1s linear infinite"}}),e("span",{children:"PROCESSING..."})]}):oe?"CONNECTING WALLET...":D?F.size===0?"SELECT ASSETS":Array.from(F.values()).every(W=>W.amount)?"DEPOSIT":"ENTER AMOUNTS":"WALLET NOT CONNECTED"}),e(Qe,{variant:"outline",onClick:ie,onMouseEnter:()=>T(!0),onMouseLeave:()=>{T(!1),B(!1)},onMouseDown:()=>B(!0),onMouseUp:()=>B(!1),disabled:m,theme:k,style:{flex:1,padding:"8px",backgroundColor:P?"#d43d3d":O?"#f05555":"#ea4b4b",color:"#0e0d0b",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:m?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:P?"scale(0.98)":O?"translateY(-2px)":"none",boxShadow:P?"1px 1px 0px black":O?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"SKIP"})]}),e("style",{children:`
|
|
65
65
|
@keyframes spin {
|
|
66
66
|
from { transform: rotate(0deg); }
|
|
67
67
|
to { transform: rotate(360deg); }
|