@spicenet-io/spiceflow-ui 1.11.6 → 1.11.7

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 CHANGED
@@ -61,7 +61,7 @@
61
61
  transform: translateY(100%);
62
62
  }
63
63
  }
64
- `})]})},ys=({depositBatches:t,tokenAddress:o,tokenDecimals:a,tokenTransferAmount:n,supportedChains:s,supportedTokens:i,theme:c="light",styles:l,className:h="",depositInputHook:x,onDepositSuccess:u,onDepositError:d,onTopUp:S,onComplete:k,submitButtonText:I,maxAmount:w})=>{const p=ue.createTheme(c),f={...p,typography:{...p.typography,fontFamily:l?.fontFamily||p.typography.fontFamily},colors:{...p.colors,primary:l?.primaryColor||p.colors.primary,primaryHover:l?.primaryColor?`${l.primaryColor}dd`:p.colors.primaryHover}},v=Mt(),{isReady:F,isAuthenticated:A,isConnected:C,address:g,provider:y,actions:m}=v,[b,Q]=r.useState(null),{assets:q,loading:_,error:$,hasBalance:te,refetch:B}=fs({address:g,supportedChains:s,enabled:C,refetchInterval:3e4}),[H,K]=r.useState(!1),[E,G]=r.useState(null),[U,X]=r.useState(!1),[j,se]=r.useState(!1),[le,oe]=r.useState(!1),ge=r.useRef(null),{intentStatus:L,startStatusPolling:O,clearStatus:pe}=It({checkStepStatus:(M,re)=>Ie.checkStepStatus(M,re)});r.useEffect(()=>{if(L?.overallStatus==="success"&&L.intentId&&ge.current!==L.intentId&&b&&g){const M=L.steps.find(re=>re.transactionHash);if(M?.transactionHash){ge.current=L.intentId;const re=ce.parseUnits(b.amount,b.asset.decimals);Ie.submitSpiceDeposit({user:g,txHash:M.transactionHash,sender:g,tokenAddress:b.asset.address,chainId:b.asset.chainId,amount:re.toString(),isDeposit:!1}).then(()=>{B()}).catch(()=>{ge.current=null})}}},[L,g]),r.useEffect(()=>{if(x&&x.assetAmount!==b?.amount&&b){let M=x.assetAmount;w&&M&&parseFloat(M)>parseFloat(w)&&(M=w,x.setAssetAmount(M)),Q({...b,amount:M})}},[x?.assetAmount,b,w]),r.useEffect(()=>{if(!x?.selectedAsset)return;const M=x.selectedAsset,re=M.address.toLowerCase(),D=re==="0x0"||re==="0x0000000000000000000000000000000000000000"||re==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",N=q.find(P=>{const ie=P.address.toLowerCase();return(D&&P.isNative||ie===re)&&(M.chainId?P.chainId===M.chainId:!0)});N&&Q(P=>({asset:N,amount:P?.amount||x.assetAmount||""}))},[x?.selectedAsset,q,x?.assetAmount]);const ne=r.useCallback(()=>{G(null)},[]),Fe=M=>{Q({asset:M,amount:b?.amount||""}),x?.setSelectedAsset&&x.setSelectedAsset({symbol:M.symbol,address:M.address,decimals:M.decimals,chainId:M.chainId}),ne()},ke=r.useCallback(M=>{if(b){let re=M;w&&M!==""&&parseFloat(M)>parseFloat(w)&&(re=w),r.startTransition(()=>{Q({...b,amount:re}),ne()}),x&&x.setAssetAmount(re)}},[b,x,ne,w]),Ce=async()=>{if(!(!b||!g||t.length===0)){if(!F||!A){G(`Please authenticate with ${y||"wallet provider"} to continue`);return}K(!0),G(null),oe(!0);try{const M=[...t],re=[...new Set(M.map(ee=>ee.chainId))],D=[];for(const ee of re){const me=Ue(ee),Ne=pt(ee),Ge=await Je.getAccountNonce(g,me),We=await m.signAuthorization({contractAddress:Ne,chainId:ee,nonce:Number(Ge)});D.push(We)}const N=Je.hashChainBatches(M),P=Math.floor(Date.now()/1e3)+60*10,ie=Je.getIntentHash(0n,BigInt(P),N),de=await m.signMessage({raw:ie}),xe=typeof de=="string"?de:de.signature;if(!xe)throw new Error("Failed to sign intent authorization");const W={mode:"7702",signatureType:"ecdsa",signature:xe,nbf:0,exp:P,chainBatches:N.map(ee=>({hash:ee.hash,chainId:ee.chainId,tokenTransfers:[{from:"solver",to:g,token:"0x0000000000000000000000000000000000000000",amount:ce.parseUnits("0.00001",18)},{from:"solver",to:g,token:o,amount:n??ce.parseUnits(b.amount,a)}],calls:ee.calls}))},J=await Ie.createAction({user:g,chainAuthorizations:D.map(ee=>({...ee,r:ee.r,s:ee.s,yParity:ee.yParity,address:ee.address,chainId:Number(ee.chainId),nonce:Number(ee.nonce)})),intents:[W]});if(J){const ee=jt(M,We=>`Chain ${We}`),[me,Ne]=J.intentIds[0].split("/"),Ge=parseInt(Ne||"0",10);O(J.intentIds[0],ee);for(let We=0;We<M.length;We++)await Ie.executeStep(me,Ge,We,{action:"execute"})}window.dispatchEvent(new CustomEvent("deposit-completed"))}catch(M){const re=M instanceof Error?M.message:"Deposit failed";G(re),d?.(re)}finally{K(!1)}}},Se=r.useMemo(()=>i&&i.length>0?q.filter(M=>i.some(re=>re.toLowerCase()===M.symbol.toLowerCase())):q,[q,i]),Ae=b&&b.amount&&parseFloat(b.amount)>0&&parseFloat(b.amount)<=b.asset.balanceFormatted&&C&&!H&&t.length>0,ze=$||E,Ve={backgroundColor:l?.container?.backgroundColor||l?.primaryBackground||f.colors.background,border:`1px solid ${l?.container?.borderColor||f.colors.border}`,borderRadius:l?.container?.borderRadius||f.borderRadius.lg,padding:l?.container?.padding||f.spacing.md,width:l?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:f.colors.text,fontFamily:f.typography.fontFamily,boxShadow:l?.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)")},Y=L?e.jsx(Zt,{type:"deposit",isOpen:!!L&&L.overallStatus!=="processing",isProcessing:H||L?.overallStatus==="processing",closeOnComplete:!0,onRetryTx:()=>{pe(),oe(!1),Ce()},onNewTx:()=>{pe(),oe(!1),Q(null),ge.current=null,B()},onClose:()=>{pe(),oe(!1)},onComplete:()=>{pe(),oe(!1),Q(null),ge.current=null,B(),k?.()},results:L?.overallStatus==="success"||L?.overallStatus==="failed"?L.steps.map(M=>({asset:{symbol:b?.asset.symbol||"Token",address:b?.asset.address||""},txHash:M.transactionHash||"",success:M.status==="success",amount:b?.amount})):void 0,chainName:b?st(t[t.length-1].chainId):"Network",explorerUrl:b?wt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:f}):null;return e.jsxs("div",{style:{...Ve,position:"relative"},className:h,children:[Y&&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:Y})}),!_&&!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(xt,{assets:Se,selectedAsset:b||void 0,onAssetSelect:Fe,onAmountChange:ke,loading:_,label:"Amount",showBalance:!0,showMaxButton:!0,theme:f,styles:l})}),ze&&e.jsx("div",{style:{backgroundColor:l?.errorMessage?.backgroundColor||(f.mode==="light"?"#fef2f2":`${l?.statusDisplay?.errorColor||f.colors.error}20`),border:`1px solid ${l?.errorMessage?.borderColor||(f.mode==="light"?"#fecaca":l?.statusDisplay?.errorColor||f.colors.error)}`,borderRadius:l?.errorMessage?.borderRadius||f.borderRadius.md,padding:l?.errorMessage?.padding||f.spacing.md,marginBottom:f.spacing.sm},children:e.jsx("p",{style:{color:l?.errorMessage?.color||l?.statusDisplay?.errorColor||f.colors.error,fontSize:l?.errorMessage?.fontSize||f.typography.fontSize.sm,fontWeight:l?.errorMessage?.fontWeight,fontFamily:l?.errorMessage?.fontFamily||f.typography.fontFamily,margin:0},children:ze})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.spacing.sm},children:e.jsx(ue.Button,{variant:"outline",fullWidth:!0,onClick:Ce,onMouseEnter:()=>X(!0),onMouseLeave:()=>{X(!1),se(!1)},onMouseDown:()=>se(!0),onMouseUp:()=>se(!1),loading:H,disabled:!Ae||!C,theme:f,styles:l,style:{width:"100%",padding:"8px",backgroundColor:Ae?j?"#d43d3d":U?"#f05555":"#ea4b4b":"#d1d5db",color:Ae?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:Ae?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:Ae?j?"scale(0.98)":U?"translateY(-2px)":"none":"none",boxShadow:j?"1px 1px 0px black":U&&Ae?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:F?A?C?H?"Executing Deposit...":b?b.amount?parseFloat(b.amount)>b.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:i,tokenDecimals:c,tokenTransferAmount:l,supportedChains:h,supportedTokens:x,theme:u="light",styles:d,className:S,depositInputHook:k,onDepositSuccess:I,onDepositError:w,onComplete:p,submitButtonText:f})=>{const v=ue.createTheme(u),F=A=>{I?.(A),o()};return e.jsx(rt,{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:v,maxWidth:n,children:e.jsx("div",{style:{padding:"0 24px 24px 24px"},children:e.jsx(ys,{depositBatches:s,tokenAddress:i,tokenDecimals:c,tokenTransferAmount:l,supportedChains:h,supportedTokens:x,theme:u,styles:{...d,container:{...d?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:S,depositInputHook:k,onDepositSuccess:F,onDepositError:w,onComplete:p,submitButtonText:f})})})},Io=({asset:t,amount:o,onAmountChange:a,onPercentageClick:n,usdValue:s,disabled:i,styles:c,theme:l})=>{const h=t.balanceFormatted??0,x=parseFloat(o)||0,u=h>0?x/h*100:0,[d,S]=r.useState(null),[k,I]=r.useState(null),w=p=>{const f=p.target.value;(f===""||/^\d*\.?\d*$/.test(f))&&a(f)};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||l.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:"Amount"}),e.jsx("input",{type:"text",value:o,onChange:w,placeholder:"0.00",disabled:i,style:{fontFamily:c?.fontFamily||l.typography.fontFamily,fontSize:"40px",fontWeight:700,color:i?"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||l.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",h.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(tt,{symbol:t.symbol,logoURI:t.logoURI,size:30,theme:l}),e.jsx("span",{style:{fontFamily:c?.fontFamily||l.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,f)=>{const v=Math.abs(u-p)<1,F=f===4,A=p/100,C=d===p,g=k===p;return e.jsx("button",{onClick:()=>n(p),onMouseEnter:()=>S(p),onMouseLeave:()=>{S(null),I(null)},onMouseDown:()=>I(p),onMouseUp:()=>I(null),disabled:i,title:`${p}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:i?"not-allowed":"pointer",opacity:v?1:C?.8:.5,transform:g?"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:F?"#ea4b4b":"none",stroke:F?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!F&&A>0&&e.jsx("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${A>.5?1:0} 1 ${7+6.84375*Math.sin(A*2*Math.PI)} ${7-6.84375*Math.cos(A*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:i,embeddedWalletAddress:c,externalWalletAddress:l,escrowAddress:h="0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",airdropTokenSymbol:x,getChainConfig:u,getSupportedTokens:d})=>{const S=ue.createTheme("light"),[k,I]=r.useState(new Map),[w,p]=r.useState(!1),[f,v]=r.useState(null),[F,A]=r.useState([]),[C,g]=r.useState(!1),[y,m]=r.useState(null),[b,Q]=r.useState(null),[q,_]=r.useState(!1),[$,te]=r.useState(!1),[B,H]=r.useState(!1),[K,E]=r.useState(!1);r.useState(null),r.useState(null);const[G,U]=r.useState(null),{chain:X}=be.useAccount(),{data:j,isLoading:se}=be.useWalletClient(),{switchChainAsync:le}=be.useSwitchChain(),oe=r.useMemo(()=>d(i),[i,d]),{erc20Tokens:ge,nativeToken:L}=r.useMemo(()=>{const D=[];let N=null;return oe.forEach(P=>{ut(P.address)?N=P:D.push(P)}),{erc20Tokens:D,nativeToken:N}},[oe]),{data:O}=be.useReadContracts({contracts:ge.map(D=>({address:D.address,abi:ce.erc20Abi,functionName:"balanceOf",args:[l],chainId:i}))}),{data:pe}=be.useBalance({address:l,chainId:i}),ne=r.useMemo(()=>{if(!u(i))return[];const D=[];if(L){const N=L,P=pe?.value??BigInt(0),ie=Number(P)/Math.pow(10,N.decimals);D.push({address:N.address,symbol:N.symbol,name:N.name,decimals:N.decimals,isNative:!0,chainId:i,balance:P,balanceFormatted:ie})}return ge.forEach((N,P)=>{const ie=O?.[P],de=ie?.status==="success"?ie.result:BigInt(0),xe=Number(de)/Math.pow(10,N.decimals);D.push({address:N.address,symbol:N.symbol,name:N.name,decimals:N.decimals,isNative:!1,chainId:i,balance:de,balanceFormatted:xe})}),D},[i,O,pe,ge,L,u]);r.useMemo(()=>x?ne.find(D=>D.symbol.toUpperCase()===x.toUpperCase()):void 0,[ne,x]),r.useEffect(()=>{if(ne.length>0&&k.size>0){const D=new Map(k);let N=!1;k.forEach((P,ie)=>{const de=ne.find(xe=>xe.address===ie);de&&de.balanceFormatted!==P.asset.balanceFormatted&&(D.set(ie,{...P,asset:de}),N=!0)}),N&&I(D)}},[ne,k]);const Fe=u(i),ke=D=>{const N=new Map(k);N.has(D.address)?N.delete(D.address):N.set(D.address,{asset:D,amount:""}),I(N),v(null)},Ce=(D,N)=>{if(N===""||/^\d*\.?\d*$/.test(N)){const P=new Map(k),ie=P.get(D);if(ie){let de=N;if(N!==""&&ie.asset.balanceFormatted!==void 0){const xe=parseFloat(N);!isNaN(xe)&&xe>ie.asset.balanceFormatted&&(de=ie.asset.balanceFormatted.toString())}P.set(D,{...ie,amount:de}),I(P),v(null)}}},Se=(D,N)=>{const P=k.get(D);if(P?.asset.balanceFormatted!==void 0){const ie=P.asset.balanceFormatted*N/100,de=Math.floor(ie*1e6)/1e6;Ce(D,de.toString())}},Ae=r.useCallback(async()=>{if(k.size===0){v("Please select at least one asset");return}for(const[N,P]of Array.from(k.entries())){if(!P.amount){v(`Please enter an amount for ${P.asset.symbol}`);return}const ie=parseFloat(P.amount);if(isNaN(ie)||ie<=0){v(`Please enter a valid amount for ${P.asset.symbol}`);return}const de=ne.find(xe=>xe.address===N)?.balanceFormatted??P.asset.balanceFormatted;if(de!==void 0&&ie>de){v(`Insufficient ${P.asset.symbol} balance`);return}}if(!j){v("Wallet not connected. Please reconnect your external wallet.");return}p(!0),v(null);const D=[];try{X?.id!==i&&await le({chainId:i});for(const[,N]of Array.from(k.entries())){const{asset:P,amount:ie}=N;try{const de=ce.parseUnits(ie,P.decimals);let xe;if(P.isNative)xe=await j.sendTransaction({to:h,value:de});else{const ee=ce.encodeFunctionData({abi:ce.erc20Abi,functionName:"transfer",args:[h,de]});xe=await j.sendTransaction({to:P.address,data:ee})}const W=Ue(i),J=await W.waitForTransactionReceipt({hash:xe,timeout:12e4,pollingInterval:2e3,confirmations:2});if(J.status!=="success")throw new Error(`Transfer to escrow failed for ${P.symbol}`);await W.getBlockNumber()-J.blockNumber<2&&await new Promise(ee=>setTimeout(ee,3e3)),await Ie.submitSpiceDeposit({txHash:xe,sender:c,tokenAddress:P.address,chainId:i,amount:ce.parseUnits(ie,P.decimals).toString(),user:c,isDeposit:!0}),D.push({asset:P,txHash:xe,success:!0}),window.dispatchEvent(new CustomEvent("cross-chain-deposit-completed"))}catch(de){const xe=de;let W=xe?.message||"Deposit failed";xe?.code===4001||xe?.message?.includes("rejected")?W="Transaction rejected by user":xe?.message?.includes("insufficient funds")&&(W="Insufficient funds for transaction"),D.push({asset:P,txHash:"",success:!1,error:W})}finally{}}A(D),g(!0);try{const N=Array.from(k.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){v(N?.message||"Deposit failed")}finally{p(!1)}},[k,j,X,i,le,h,ne]);r.useEffect(()=>{t||(I(new Map),v(null),A([]),g(!1),p(!1))},[t]);const ze=r.useCallback(()=>{A([]),g(!1),v(null)},[]),Ve=r.useCallback(()=>{window.dispatchEvent(new CustomEvent("cross-chain-deposit-skipped"))},[]),Y=k.size>0&&Array.from(k.values()).every(D=>D.amount&&parseFloat(D.amount)>0)&&!w&&!C&&j,M=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})]}),re=w||C&&F.length>0?e.jsx(Zt,{type:"deposit",isOpen:C&&F.length>0,isProcessing:w,onClose:o,onComplete:a,closeOnComplete:!1,onRetryTx:ze,onNewTx:()=>{},results:F.length>0?F.map(D=>({asset:{symbol:D.asset.symbol,address:D.asset.address},txHash:D.txHash,success:D.success,error:D.error})):void 0,chainName:st(i),explorerUrl:Fe?.blockExplorers?.default?.url,theme:S}):null;return e.jsxs(rt,{isOpen:t,onClose:o,title:n,subtitle:M,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:[re&&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:re})}),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(D=>{const N=k.has(D.address);return e.jsx("div",{onClick:()=>ke(D),onMouseEnter:()=>m(D.address),onMouseLeave:()=>{m(null),Q(null)},onMouseDown:()=>Q(D.address),onMouseUp:()=>Q(null),style:{padding:"4px 8px 4px 8px",borderRadius:"8px",border:`1px solid ${N?"#EA4B4B7A":y===D.address?"#F4A5A5":"#e5e7eb"}`,backgroundColor:N?"#FEF2F2":b===D.address?"#f5f5f5":y===D.address?"#fafafa":"white",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease",transform:b===D.address?"scale(0.96)":y===D.address?"translateY(-1px)":"none",boxShadow:N?"0 0 0 3px #FBDBDB":b===D.address?"0 1px 2px rgba(0, 0, 0, 0.05)":y===D.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(tt,{symbol:D.symbol,size:24,theme:S}),e.jsx("span",{style:{fontSize:"16px",fontWeight:510,color:"#3C3E42"},children:D.symbol}),D.balanceFormatted!==void 0&&e.jsxs("span",{style:{fontSize:"10px",fontWeight:500,color:"#939291",fontFamily:'"IBM Plex Mono", monospace'},children:["(",D.balanceFormatted.toFixed(4),")"]})]})},D.address)})})]}),k.size>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:Array.from(k.values()).map(({asset:D,amount:N})=>e.jsx(Io,{asset:D,amount:N,onAmountChange:P=>Ce(D.address,P),onPercentageClick:P=>Se(D.address,P),theme:S,disabled:w},D.address))})]}),f&&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:f})}),!C&&e.jsxs("div",{style:{display:"flex",gap:"12px",marginTop:"20px"},children:[e.jsx(ue.Button,{variant:"outline",onClick:Ae,onMouseEnter:()=>_(!0),onMouseLeave:()=>{_(!1),te(!1)},onMouseDown:()=>te(!0),onMouseUp:()=>te(!1),disabled:!Y,theme:S,style:{flex:2,padding:"8px",backgroundColor:Y?$?"#d43d3d":q?"#f05555":"#ea4b4b":"#d1d5db",color:Y?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:Y?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:Y?$?"scale(0.98)":q?"translateY(-2px)":"none":"none",boxShadow:$?"1px 1px 0px black":q&&Y?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:w?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..."})]}):se?"CONNECTING WALLET...":j?k.size===0?"SELECT ASSETS":Array.from(k.values()).every(D=>D.amount)?"DEPOSIT":"ENTER AMOUNTS":"WALLET NOT CONNECTED"}),e.jsx(ue.Button,{variant:"outline",onClick:Ve,onMouseEnter:()=>H(!0),onMouseLeave:()=>{H(!1),E(!1)},onMouseDown:()=>E(!0),onMouseUp:()=>E(!1),disabled:w,theme:S,style:{flex:1,padding:"8px",backgroundColor:K?"#b0b0b0":B?"#e0e0e0":"#d0d0d0",color:"#1a1a1a",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:w?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:K?"scale(0.98)":B?"translateY(-2px)":"none",boxShadow:K?"1px 1px 0px black":B?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"SKIP"})]}),e.jsx("style",{children:`
64
+ `})]})},ys=({depositBatches:t,tokenAddress:o,tokenDecimals:a,tokenTransferAmount:n,supportedChains:s,supportedTokens:i,theme:c="light",styles:l,className:h="",depositInputHook:x,onDepositSuccess:u,onDepositError:d,onTopUp:S,onComplete:k,submitButtonText:I,maxAmount:w})=>{const p=ue.createTheme(c),f={...p,typography:{...p.typography,fontFamily:l?.fontFamily||p.typography.fontFamily},colors:{...p.colors,primary:l?.primaryColor||p.colors.primary,primaryHover:l?.primaryColor?`${l.primaryColor}dd`:p.colors.primaryHover}},v=Mt(),{isReady:F,isAuthenticated:A,isConnected:C,address:g,provider:y,actions:m}=v,[b,Q]=r.useState(null),{assets:q,loading:_,error:$,hasBalance:te,refetch:B}=fs({address:g,supportedChains:s,enabled:C,refetchInterval:3e4}),[H,K]=r.useState(!1),[E,G]=r.useState(null),[U,X]=r.useState(!1),[j,se]=r.useState(!1),[le,oe]=r.useState(!1),ge=r.useRef(null),{intentStatus:L,startStatusPolling:O,clearStatus:pe}=It({checkStepStatus:(M,re)=>Ie.checkStepStatus(M,re)});r.useEffect(()=>{if(L?.overallStatus==="success"&&L.intentId&&ge.current!==L.intentId&&b&&g){const M=L.steps.find(re=>re.transactionHash);if(M?.transactionHash){ge.current=L.intentId;const re=ce.parseUnits(b.amount,b.asset.decimals);Ie.submitSpiceDeposit({user:g,txHash:M.transactionHash,sender:g,tokenAddress:b.asset.address,chainId:b.asset.chainId,amount:re.toString(),isDeposit:!1}).then(()=>{B()}).catch(()=>{ge.current=null})}}},[L,g]),r.useEffect(()=>{if(x&&x.assetAmount!==b?.amount&&b){let M=x.assetAmount;w&&M&&parseFloat(M)>parseFloat(w)&&(M=w,x.setAssetAmount(M)),Q({...b,amount:M})}},[x?.assetAmount,b,w]),r.useEffect(()=>{if(!x?.selectedAsset)return;const M=x.selectedAsset,re=M.address.toLowerCase(),D=re==="0x0"||re==="0x0000000000000000000000000000000000000000"||re==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",N=q.find(P=>{const ie=P.address.toLowerCase();return(D&&P.isNative||ie===re)&&(M.chainId?P.chainId===M.chainId:!0)});N&&Q(P=>({asset:N,amount:P?.amount||x.assetAmount||""}))},[x?.selectedAsset,q,x?.assetAmount]);const ne=r.useCallback(()=>{G(null)},[]),Fe=M=>{Q({asset:M,amount:b?.amount||""}),x?.setSelectedAsset&&x.setSelectedAsset({symbol:M.symbol,address:M.address,decimals:M.decimals,chainId:M.chainId}),ne()},ke=r.useCallback(M=>{if(b){let re=M;w&&M!==""&&parseFloat(M)>parseFloat(w)&&(re=w),r.startTransition(()=>{Q({...b,amount:re}),ne()}),x&&x.setAssetAmount(re)}},[b,x,ne,w]),Ce=async()=>{if(!(!b||!g||t.length===0)){if(!F||!A){G(`Please authenticate with ${y||"wallet provider"} to continue`);return}K(!0),G(null),oe(!0);try{const M=[...t],re=[...new Set(M.map(ee=>ee.chainId))],D=[];for(const ee of re){const me=Ue(ee),Ne=pt(ee),Ge=await Je.getAccountNonce(g,me),We=await m.signAuthorization({contractAddress:Ne,chainId:ee,nonce:Number(Ge)});D.push(We)}const N=Je.hashChainBatches(M),P=Math.floor(Date.now()/1e3)+60*10,ie=Je.getIntentHash(0n,BigInt(P),N),de=await m.signMessage({raw:ie}),xe=typeof de=="string"?de:de.signature;if(!xe)throw new Error("Failed to sign intent authorization");const W={mode:"7702",signatureType:"ecdsa",signature:xe,nbf:0,exp:P,chainBatches:N.map(ee=>({hash:ee.hash,chainId:ee.chainId,tokenTransfers:[{from:"solver",to:g,token:"0x0000000000000000000000000000000000000000",amount:ce.parseUnits("0.00001",18)},{from:"solver",to:g,token:o,amount:n??ce.parseUnits(b.amount,a)}],calls:ee.calls}))},J=await Ie.createAction({user:g,chainAuthorizations:D.map(ee=>({...ee,r:ee.r,s:ee.s,yParity:ee.yParity,address:ee.address,chainId:Number(ee.chainId),nonce:Number(ee.nonce)})),intents:[W]});if(J){const ee=jt(M,We=>`Chain ${We}`),[me,Ne]=J.intentIds[0].split("/"),Ge=parseInt(Ne||"0",10);O(J.intentIds[0],ee);for(let We=0;We<M.length;We++)await Ie.executeStep(me,Ge,We,{action:"execute"})}window.dispatchEvent(new CustomEvent("deposit-completed"))}catch(M){const re=M instanceof Error?M.message:"Deposit failed";G(re),d?.(re)}finally{K(!1)}}},Se=r.useMemo(()=>i&&i.length>0?q.filter(M=>i.some(re=>re.toLowerCase()===M.symbol.toLowerCase())):q,[q,i]),Ae=b&&b.amount&&parseFloat(b.amount)>0&&parseFloat(b.amount)<=b.asset.balanceFormatted&&C&&!H&&t.length>0,ze=$||E,Ve={backgroundColor:l?.container?.backgroundColor||l?.primaryBackground||f.colors.background,border:`1px solid ${l?.container?.borderColor||f.colors.border}`,borderRadius:l?.container?.borderRadius||f.borderRadius.lg,padding:l?.container?.padding||f.spacing.md,width:l?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:f.colors.text,fontFamily:f.typography.fontFamily,boxShadow:l?.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)")},Y=L?e.jsx(Zt,{type:"deposit",isOpen:!!L&&L.overallStatus!=="processing",isProcessing:H||L?.overallStatus==="processing",closeOnComplete:!0,onRetryTx:()=>{pe(),oe(!1),Ce()},onNewTx:()=>{pe(),oe(!1),Q(null),ge.current=null,B()},onClose:()=>{pe(),oe(!1)},onComplete:()=>{pe(),oe(!1),Q(null),ge.current=null,B(),k?.()},results:L?.overallStatus==="success"||L?.overallStatus==="failed"?L.steps.map(M=>({asset:{symbol:b?.asset.symbol||"Token",address:b?.asset.address||""},txHash:M.transactionHash||"",success:M.status==="success",amount:b?.amount})):void 0,chainName:b?st(t[t.length-1].chainId):"Network",explorerUrl:b?wt(t[t.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:f}):null;return e.jsxs("div",{style:{...Ve,position:"relative"},className:h,children:[Y&&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:Y})}),!_&&!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(xt,{assets:Se,selectedAsset:b||void 0,onAssetSelect:Fe,onAmountChange:ke,loading:_,label:"Amount",showBalance:!0,showMaxButton:!0,theme:f,styles:l})}),ze&&e.jsx("div",{style:{backgroundColor:l?.errorMessage?.backgroundColor||(f.mode==="light"?"#fef2f2":`${l?.statusDisplay?.errorColor||f.colors.error}20`),border:`1px solid ${l?.errorMessage?.borderColor||(f.mode==="light"?"#fecaca":l?.statusDisplay?.errorColor||f.colors.error)}`,borderRadius:l?.errorMessage?.borderRadius||f.borderRadius.md,padding:l?.errorMessage?.padding||f.spacing.md,marginBottom:f.spacing.sm},children:e.jsx("p",{style:{color:l?.errorMessage?.color||l?.statusDisplay?.errorColor||f.colors.error,fontSize:l?.errorMessage?.fontSize||f.typography.fontSize.sm,fontWeight:l?.errorMessage?.fontWeight,fontFamily:l?.errorMessage?.fontFamily||f.typography.fontFamily,margin:0},children:ze})}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:f.spacing.sm},children:e.jsx(ue.Button,{variant:"outline",fullWidth:!0,onClick:Ce,onMouseEnter:()=>X(!0),onMouseLeave:()=>{X(!1),se(!1)},onMouseDown:()=>se(!0),onMouseUp:()=>se(!1),loading:H,disabled:!Ae||!C,theme:f,styles:l,style:{width:"100%",padding:"8px",backgroundColor:Ae?j?"#d43d3d":U?"#f05555":"#ea4b4b":"#d1d5db",color:Ae?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:Ae?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:Ae?j?"scale(0.98)":U?"translateY(-2px)":"none":"none",boxShadow:j?"1px 1px 0px black":U&&Ae?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:F?A?C?H?"Executing Deposit...":b?b.amount?parseFloat(b.amount)>b.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:i,tokenDecimals:c,tokenTransferAmount:l,supportedChains:h,supportedTokens:x,theme:u="light",styles:d,className:S,depositInputHook:k,onDepositSuccess:I,onDepositError:w,onComplete:p,submitButtonText:f,maxAmount:v})=>{const F=ue.createTheme(u),A=C=>{I?.(C),o()};return e.jsx(rt,{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:F,maxWidth:n,children:e.jsx("div",{style:{padding:"0 24px 24px 24px"},children:e.jsx(ys,{depositBatches:s,tokenAddress:i,tokenDecimals:c,tokenTransferAmount:l,supportedChains:h,supportedTokens:x,theme:u,styles:{...d,container:{...d?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:S,depositInputHook:k,onDepositSuccess:A,onDepositError:w,onComplete:p,submitButtonText:f,maxAmount:v})})})},Io=({asset:t,amount:o,onAmountChange:a,onPercentageClick:n,usdValue:s,disabled:i,styles:c,theme:l})=>{const h=t.balanceFormatted??0,x=parseFloat(o)||0,u=h>0?x/h*100:0,[d,S]=r.useState(null),[k,I]=r.useState(null),w=p=>{const f=p.target.value;(f===""||/^\d*\.?\d*$/.test(f))&&a(f)};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||l.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:"Amount"}),e.jsx("input",{type:"text",value:o,onChange:w,placeholder:"0.00",disabled:i,style:{fontFamily:c?.fontFamily||l.typography.fontFamily,fontSize:"40px",fontWeight:700,color:i?"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||l.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",h.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(tt,{symbol:t.symbol,logoURI:t.logoURI,size:30,theme:l}),e.jsx("span",{style:{fontFamily:c?.fontFamily||l.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,f)=>{const v=Math.abs(u-p)<1,F=f===4,A=p/100,C=d===p,g=k===p;return e.jsx("button",{onClick:()=>n(p),onMouseEnter:()=>S(p),onMouseLeave:()=>{S(null),I(null)},onMouseDown:()=>I(p),onMouseUp:()=>I(null),disabled:i,title:`${p}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:i?"not-allowed":"pointer",opacity:v?1:C?.8:.5,transform:g?"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:F?"#ea4b4b":"none",stroke:F?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!F&&A>0&&e.jsx("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${A>.5?1:0} 1 ${7+6.84375*Math.sin(A*2*Math.PI)} ${7-6.84375*Math.cos(A*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:i,embeddedWalletAddress:c,externalWalletAddress:l,escrowAddress:h="0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",airdropTokenSymbol:x,getChainConfig:u,getSupportedTokens:d})=>{const S=ue.createTheme("light"),[k,I]=r.useState(new Map),[w,p]=r.useState(!1),[f,v]=r.useState(null),[F,A]=r.useState([]),[C,g]=r.useState(!1),[y,m]=r.useState(null),[b,Q]=r.useState(null),[q,_]=r.useState(!1),[$,te]=r.useState(!1),[B,H]=r.useState(!1),[K,E]=r.useState(!1);r.useState(null),r.useState(null);const[G,U]=r.useState(null),{chain:X}=be.useAccount(),{data:j,isLoading:se}=be.useWalletClient(),{switchChainAsync:le}=be.useSwitchChain(),oe=r.useMemo(()=>d(i),[i,d]),{erc20Tokens:ge,nativeToken:L}=r.useMemo(()=>{const D=[];let N=null;return oe.forEach(P=>{ut(P.address)?N=P:D.push(P)}),{erc20Tokens:D,nativeToken:N}},[oe]),{data:O}=be.useReadContracts({contracts:ge.map(D=>({address:D.address,abi:ce.erc20Abi,functionName:"balanceOf",args:[l],chainId:i}))}),{data:pe}=be.useBalance({address:l,chainId:i}),ne=r.useMemo(()=>{if(!u(i))return[];const D=[];if(L){const N=L,P=pe?.value??BigInt(0),ie=Number(P)/Math.pow(10,N.decimals);D.push({address:N.address,symbol:N.symbol,name:N.name,decimals:N.decimals,isNative:!0,chainId:i,balance:P,balanceFormatted:ie})}return ge.forEach((N,P)=>{const ie=O?.[P],de=ie?.status==="success"?ie.result:BigInt(0),xe=Number(de)/Math.pow(10,N.decimals);D.push({address:N.address,symbol:N.symbol,name:N.name,decimals:N.decimals,isNative:!1,chainId:i,balance:de,balanceFormatted:xe})}),D},[i,O,pe,ge,L,u]);r.useMemo(()=>x?ne.find(D=>D.symbol.toUpperCase()===x.toUpperCase()):void 0,[ne,x]),r.useEffect(()=>{if(ne.length>0&&k.size>0){const D=new Map(k);let N=!1;k.forEach((P,ie)=>{const de=ne.find(xe=>xe.address===ie);de&&de.balanceFormatted!==P.asset.balanceFormatted&&(D.set(ie,{...P,asset:de}),N=!0)}),N&&I(D)}},[ne,k]);const Fe=u(i),ke=D=>{const N=new Map(k);N.has(D.address)?N.delete(D.address):N.set(D.address,{asset:D,amount:""}),I(N),v(null)},Ce=(D,N)=>{if(N===""||/^\d*\.?\d*$/.test(N)){const P=new Map(k),ie=P.get(D);if(ie){let de=N;if(N!==""&&ie.asset.balanceFormatted!==void 0){const xe=parseFloat(N);!isNaN(xe)&&xe>ie.asset.balanceFormatted&&(de=ie.asset.balanceFormatted.toString())}P.set(D,{...ie,amount:de}),I(P),v(null)}}},Se=(D,N)=>{const P=k.get(D);if(P?.asset.balanceFormatted!==void 0){const ie=P.asset.balanceFormatted*N/100,de=Math.floor(ie*1e6)/1e6;Ce(D,de.toString())}},Ae=r.useCallback(async()=>{if(k.size===0){v("Please select at least one asset");return}for(const[N,P]of Array.from(k.entries())){if(!P.amount){v(`Please enter an amount for ${P.asset.symbol}`);return}const ie=parseFloat(P.amount);if(isNaN(ie)||ie<=0){v(`Please enter a valid amount for ${P.asset.symbol}`);return}const de=ne.find(xe=>xe.address===N)?.balanceFormatted??P.asset.balanceFormatted;if(de!==void 0&&ie>de){v(`Insufficient ${P.asset.symbol} balance`);return}}if(!j){v("Wallet not connected. Please reconnect your external wallet.");return}p(!0),v(null);const D=[];try{X?.id!==i&&await le({chainId:i});for(const[,N]of Array.from(k.entries())){const{asset:P,amount:ie}=N;try{const de=ce.parseUnits(ie,P.decimals);let xe;if(P.isNative)xe=await j.sendTransaction({to:h,value:de});else{const ee=ce.encodeFunctionData({abi:ce.erc20Abi,functionName:"transfer",args:[h,de]});xe=await j.sendTransaction({to:P.address,data:ee})}const W=Ue(i),J=await W.waitForTransactionReceipt({hash:xe,timeout:12e4,pollingInterval:2e3,confirmations:2});if(J.status!=="success")throw new Error(`Transfer to escrow failed for ${P.symbol}`);await W.getBlockNumber()-J.blockNumber<2&&await new Promise(ee=>setTimeout(ee,3e3)),await Ie.submitSpiceDeposit({txHash:xe,sender:c,tokenAddress:P.address,chainId:i,amount:ce.parseUnits(ie,P.decimals).toString(),user:c,isDeposit:!0}),D.push({asset:P,txHash:xe,success:!0}),window.dispatchEvent(new CustomEvent("cross-chain-deposit-completed"))}catch(de){const xe=de;let W=xe?.message||"Deposit failed";xe?.code===4001||xe?.message?.includes("rejected")?W="Transaction rejected by user":xe?.message?.includes("insufficient funds")&&(W="Insufficient funds for transaction"),D.push({asset:P,txHash:"",success:!1,error:W})}finally{}}A(D),g(!0);try{const N=Array.from(k.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){v(N?.message||"Deposit failed")}finally{p(!1)}},[k,j,X,i,le,h,ne]);r.useEffect(()=>{t||(I(new Map),v(null),A([]),g(!1),p(!1))},[t]);const ze=r.useCallback(()=>{A([]),g(!1),v(null)},[]),Ve=r.useCallback(()=>{window.dispatchEvent(new CustomEvent("cross-chain-deposit-skipped"))},[]),Y=k.size>0&&Array.from(k.values()).every(D=>D.amount&&parseFloat(D.amount)>0)&&!w&&!C&&j,M=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})]}),re=w||C&&F.length>0?e.jsx(Zt,{type:"deposit",isOpen:C&&F.length>0,isProcessing:w,onClose:o,onComplete:a,closeOnComplete:!1,onRetryTx:ze,onNewTx:()=>{},results:F.length>0?F.map(D=>({asset:{symbol:D.asset.symbol,address:D.asset.address},txHash:D.txHash,success:D.success,error:D.error})):void 0,chainName:st(i),explorerUrl:Fe?.blockExplorers?.default?.url,theme:S}):null;return e.jsxs(rt,{isOpen:t,onClose:o,title:n,subtitle:M,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:[re&&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:re})}),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(D=>{const N=k.has(D.address);return e.jsx("div",{onClick:()=>ke(D),onMouseEnter:()=>m(D.address),onMouseLeave:()=>{m(null),Q(null)},onMouseDown:()=>Q(D.address),onMouseUp:()=>Q(null),style:{padding:"4px 8px 4px 8px",borderRadius:"8px",border:`1px solid ${N?"#EA4B4B7A":y===D.address?"#F4A5A5":"#e5e7eb"}`,backgroundColor:N?"#FEF2F2":b===D.address?"#f5f5f5":y===D.address?"#fafafa":"white",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease",transform:b===D.address?"scale(0.96)":y===D.address?"translateY(-1px)":"none",boxShadow:N?"0 0 0 3px #FBDBDB":b===D.address?"0 1px 2px rgba(0, 0, 0, 0.05)":y===D.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(tt,{symbol:D.symbol,size:24,theme:S}),e.jsx("span",{style:{fontSize:"16px",fontWeight:510,color:"#3C3E42"},children:D.symbol}),D.balanceFormatted!==void 0&&e.jsxs("span",{style:{fontSize:"10px",fontWeight:500,color:"#939291",fontFamily:'"IBM Plex Mono", monospace'},children:["(",D.balanceFormatted.toFixed(4),")"]})]})},D.address)})})]}),k.size>0&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:Array.from(k.values()).map(({asset:D,amount:N})=>e.jsx(Io,{asset:D,amount:N,onAmountChange:P=>Ce(D.address,P),onPercentageClick:P=>Se(D.address,P),theme:S,disabled:w},D.address))})]}),f&&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:f})}),!C&&e.jsxs("div",{style:{display:"flex",gap:"12px",marginTop:"20px"},children:[e.jsx(ue.Button,{variant:"outline",onClick:Ae,onMouseEnter:()=>_(!0),onMouseLeave:()=>{_(!1),te(!1)},onMouseDown:()=>te(!0),onMouseUp:()=>te(!1),disabled:!Y,theme:S,style:{flex:2,padding:"8px",backgroundColor:Y?$?"#d43d3d":q?"#f05555":"#ea4b4b":"#d1d5db",color:Y?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:Y?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:Y?$?"scale(0.98)":q?"translateY(-2px)":"none":"none",boxShadow:$?"1px 1px 0px black":q&&Y?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:w?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..."})]}):se?"CONNECTING WALLET...":j?k.size===0?"SELECT ASSETS":Array.from(k.values()).every(D=>D.amount)?"DEPOSIT":"ENTER AMOUNTS":"WALLET NOT CONNECTED"}),e.jsx(ue.Button,{variant:"outline",onClick:Ve,onMouseEnter:()=>H(!0),onMouseLeave:()=>{H(!1),E(!1)},onMouseDown:()=>E(!0),onMouseUp:()=>E(!1),disabled:w,theme:S,style:{flex:1,padding:"8px",backgroundColor:K?"#b0b0b0":B?"#e0e0e0":"#d0d0d0",color:"#1a1a1a",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:w?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:K?"scale(0.98)":B?"translateY(-2px)":"none",boxShadow:K?"1px 1px 0px black":B?"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
@@ -61,7 +61,7 @@ import{defineChain as xo,createPublicClient as bo,http as Co,isAddress as oo,get
61
61
  transform: translateY(100%);
62
62
  }
63
63
  }
64
- `})]})},jo=({depositBatches:o,tokenAddress:n,tokenDecimals:s,tokenTransferAmount:r,supportedChains:t,supportedTokens:i,theme:c="light",styles:a,className:h="",depositInputHook:g,onDepositSuccess:u,onDepositError:d,onTopUp:I,onComplete:S,submitButtonText:F,maxAmount:k})=>{const p=De(c),m={...p,typography:{...p.typography,fontFamily:a?.fontFamily||p.typography.fontFamily},colors:{...p.colors,primary:a?.primaryColor||p.colors.primary,primaryHover:a?.primaryColor?`${a.primaryColor}dd`:p.colors.primaryHover}},B=Gt(),{isReady:v,isAuthenticated:w,isConnected:A,address:f,provider:b,actions:y}=B,[C,U]=x(null),{assets:P,loading:ee,error:_,hasBalance:ne,refetch:R}=Yo({address:f,supportedChains:t,enabled:A,refetchInterval:3e4}),[T,X]=x(!1),[E,O]=x(null),[z,$]=x(!1),[W,re]=x(!1),[pe,ie]=x(!1),me=Fe(null),{intentStatus:Q,startStatusPolling:K,clearStatus:he}=Lt({checkStepStatus:(H,le)=>ve.checkStepStatus(H,le)});te(()=>{if(Q?.overallStatus==="success"&&Q.intentId&&me.current!==Q.intentId&&C&&f){const H=Q.steps.find(le=>le.transactionHash);if(H?.transactionHash){me.current=Q.intentId;const le=Ke(C.amount,C.asset.decimals);ve.submitSpiceDeposit({user:f,txHash:H.transactionHash,sender:f,tokenAddress:C.asset.address,chainId:C.asset.chainId,amount:le.toString(),isDeposit:!1}).then(()=>{R()}).catch(()=>{me.current=null})}}},[Q,f]),te(()=>{if(g&&g.assetAmount!==C?.amount&&C){let H=g.assetAmount;k&&H&&parseFloat(H)>parseFloat(k)&&(H=k,g.setAssetAmount(H)),U({...C,amount:H})}},[g?.assetAmount,C,k]),te(()=>{if(!g?.selectedAsset)return;const H=g.selectedAsset,le=H.address.toLowerCase(),M=le==="0x0"||le==="0x0000000000000000000000000000000000000000"||le==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",q=P.find(J=>{const ce=J.address.toLowerCase();return(M&&J.isNative||ce===le)&&(H.chainId?J.chainId===H.chainId:!0)});q&&U(J=>({asset:q,amount:J?.amount||g.assetAmount||""}))},[g?.selectedAsset,P,g?.assetAmount]);const ae=se(()=>{O(null)},[]),Ee=H=>{U({asset:H,amount:C?.amount||""}),g?.setSelectedAsset&&g.setSelectedAsset({symbol:H.symbol,address:H.address,decimals:H.decimals,chainId:H.chainId}),ae()},Se=se(H=>{if(C){let le=H;k&&H!==""&&parseFloat(H)>parseFloat(k)&&(le=k),Io(()=>{U({...C,amount:le}),ae()}),g&&g.setAssetAmount(le)}},[C,g,ae,k]),Ce=async()=>{if(!(!C||!f||o.length===0)){if(!v||!w){O(`Please authenticate with ${b||"wallet provider"} to continue`);return}X(!0),O(null),ie(!0);try{const H=[...o],le=[...new Set(H.map(oe=>oe.chainId))],M=[];for(const oe of le){const xe=qe(oe),Ze=yt(oe),et=await qt(f,xe),Me=await y.signAuthorization({contractAddress:Ze,chainId:oe,nonce:Number(et)});M.push(Me)}const q=jt(H),J=Math.floor(Date.now()/1e3)+60*10,ce=Pt(0n,BigInt(J),q),ue=await y.signMessage({raw:ce}),fe=typeof ue=="string"?ue:ue.signature;if(!fe)throw new Error("Failed to sign intent authorization");const D={mode:"7702",signatureType:"ecdsa",signature:fe,nbf:0,exp:J,chainBatches:q.map(oe=>({hash:oe.hash,chainId:oe.chainId,tokenTransfers:[{from:"solver",to:f,token:"0x0000000000000000000000000000000000000000",amount:Ke("0.00001",18)},{from:"solver",to:f,token:n,amount:r??Ke(C.amount,s)}],calls:oe.calls}))},Z=await ve.createAction({user:f,chainAuthorizations:M.map(oe=>({...oe,r:oe.r,s:oe.s,yParity:oe.yParity,address:oe.address,chainId:Number(oe.chainId),nonce:Number(oe.nonce)})),intents:[D]});if(Z){const oe=Ut(H,Me=>`Chain ${Me}`),[xe,Ze]=Z.intentIds[0].split("/"),et=parseInt(Ze||"0",10);K(Z.intentIds[0],oe);for(let Me=0;Me<H.length;Me++)await ve.executeStep(xe,et,Me,{action:"execute"})}window.dispatchEvent(new CustomEvent("deposit-completed"))}catch(H){const le=H instanceof Error?H.message:"Deposit failed";O(le),d?.(le)}finally{X(!1)}}},Ie=we(()=>i&&i.length>0?P.filter(H=>i.some(le=>le.toLowerCase()===H.symbol.toLowerCase())):P,[P,i]),Ae=C&&C.amount&&parseFloat(C.amount)>0&&parseFloat(C.amount)<=C.asset.balanceFormatted&&A&&!T&&o.length>0,Pe=_||E,Je={backgroundColor:a?.container?.backgroundColor||a?.primaryBackground||m.colors.background,border:`1px solid ${a?.container?.borderColor||m.colors.border}`,borderRadius:a?.container?.borderRadius||m.borderRadius.lg,padding:a?.container?.padding||m.spacing.md,width:a?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:m.colors.text,fontFamily:m.typography.fontFamily,boxShadow:a?.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)")},j=Q?e(po,{type:"deposit",isOpen:!!Q&&Q.overallStatus!=="processing",isProcessing:T||Q?.overallStatus==="processing",closeOnComplete:!0,onRetryTx:()=>{he(),ie(!1),Ce()},onNewTx:()=>{he(),ie(!1),U(null),me.current=null,R()},onClose:()=>{he(),ie(!1)},onComplete:()=>{he(),ie(!1),U(null),me.current=null,R(),S?.()},results:Q?.overallStatus==="success"||Q?.overallStatus==="failed"?Q.steps.map(H=>({asset:{symbol:C?.asset.symbol||"Token",address:C?.asset.address||""},txHash:H.transactionHash||"",success:H.status==="success",amount:C?.amount})):void 0,chainName:C?lt(o[o.length-1].chainId):"Network",explorerUrl:C?Wt(o[o.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:m}):null;return l("div",{style:{...Je,position:"relative"},className:h,children:[j&&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:j})}),!ee&&!ne&&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."," ",I&&e("span",{onClick:I,style:{color:m.colors.primary,textDecoration:"underline",cursor:"pointer",fontWeight:600},children:"Top-up here."})]})}),e("div",{style:{marginBottom:m.spacing.sm},children:e(Ct,{assets:Ie,selectedAsset:C||void 0,onAssetSelect:Ee,onAmountChange:Se,loading:ee,label:"Amount",showBalance:!0,showMaxButton:!0,theme:m,styles:a})}),Pe&&e("div",{style:{backgroundColor:a?.errorMessage?.backgroundColor||(m.mode==="light"?"#fef2f2":`${a?.statusDisplay?.errorColor||m.colors.error}20`),border:`1px solid ${a?.errorMessage?.borderColor||(m.mode==="light"?"#fecaca":a?.statusDisplay?.errorColor||m.colors.error)}`,borderRadius:a?.errorMessage?.borderRadius||m.borderRadius.md,padding:a?.errorMessage?.padding||m.spacing.md,marginBottom:m.spacing.sm},children:e("p",{style:{color:a?.errorMessage?.color||a?.statusDisplay?.errorColor||m.colors.error,fontSize:a?.errorMessage?.fontSize||m.typography.fontSize.sm,fontWeight:a?.errorMessage?.fontWeight,fontFamily:a?.errorMessage?.fontFamily||m.typography.fontFamily,margin:0},children:Pe})}),e("div",{style:{display:"flex",flexDirection:"column",gap:m.spacing.sm},children:e(Qe,{variant:"outline",fullWidth:!0,onClick:Ce,onMouseEnter:()=>$(!0),onMouseLeave:()=>{$(!1),re(!1)},onMouseDown:()=>re(!0),onMouseUp:()=>re(!1),loading:T,disabled:!Ae||!A,theme:m,styles:a,style:{width:"100%",padding:"8px",backgroundColor:Ae?W?"#d43d3d":z?"#f05555":"#ea4b4b":"#d1d5db",color:Ae?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:Ae?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:Ae?W?"scale(0.98)":z?"translateY(-2px)":"none":"none",boxShadow:W?"1px 1px 0px black":z&&Ae?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:v?w?A?T?"Executing Deposit...":C?C.amount?parseFloat(C.amount)>C.asset.balanceFormatted?"Insufficient Balance":o.length===0?"No Deposit Batches":F||"Execute Deposit":"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},pr=({isOpen:o,onClose:n,title:s="Deposit",maxWidth:r="480px",depositBatches:t,tokenAddress:i,tokenDecimals:c,tokenTransferAmount:a,supportedChains:h,supportedTokens:g,theme:u="light",styles:d,className:I,depositInputHook:S,onDepositSuccess:F,onDepositError:k,onComplete:p,submitButtonText:m})=>{const B=De(u),v=w=>{F?.(w),n()};return e(ut,{isOpen:o,onClose:n,title:s,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:Ot,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:B,maxWidth:r,children:e("div",{style:{padding:"0 24px 24px 24px"},children:e(jo,{depositBatches:t,tokenAddress:i,tokenDecimals:c,tokenTransferAmount:a,supportedChains:h,supportedTokens:g,theme:u,styles:{...d,container:{...d?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:I,depositInputHook:S,onDepositSuccess:v,onDepositError:k,onComplete:p,submitButtonText:m})})})},ur=({asset:o,amount:n,onAmountChange:s,onPercentageClick:r,usdValue:t,disabled:i,styles:c,theme:a})=>{const h=o.balanceFormatted??0,g=parseFloat(n)||0,u=h>0?g/h*100:0,[d,I]=x(null),[S,F]=x(null),k=p=>{const m=p.target.value;(m===""||/^\d*\.?\d*$/.test(m))&&s(m)};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||a.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:"Amount"}),e("input",{type:"text",value:n,onChange:k,placeholder:"0.00",disabled:i,style:{fontFamily:c?.fontFamily||a.typography.fontFamily,fontSize:"40px",fontWeight:700,color:i?"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||a.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",h.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(at,{symbol:o.symbol,logoURI:o.logoURI,size:30,theme:a}),e("span",{style:{fontFamily:c?.fontFamily||a.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#3c3e42",lineHeight:"1.5"},children:o.symbol})]})})]}),e("div",{style:{display:"flex",gap:"10px",height:"14px",alignItems:"center",justifyContent:"flex-end"},children:[0,25,50,75,100].map((p,m)=>{const B=Math.abs(u-p)<1,v=m===4,w=p/100,A=d===p,f=S===p;return e("button",{onClick:()=>r(p),onMouseEnter:()=>I(p),onMouseLeave:()=>{I(null),F(null)},onMouseDown:()=>F(p),onMouseUp:()=>F(null),disabled:i,title:`${p}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:i?"not-allowed":"pointer",opacity:B?1:A?.8:.5,transform:f?"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:v?"#ea4b4b":"none",stroke:v?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!v&&w>0&&e("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${w>.5?1:0} 1 ${7+6.84375*Math.sin(w*2*Math.PI)} ${7-6.84375*Math.cos(w*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:o,onClose:n,onComplete:s,title:r="Deposit to Spicenet",description:t="Select tokens and enter amounts to deposit to your Spicenet Account",chainId:i,embeddedWalletAddress:c,externalWalletAddress:a,escrowAddress:h="0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",airdropTokenSymbol:g,getChainConfig:u,getSupportedTokens:d})=>{const I=De("light"),[S,F]=x(new Map),[k,p]=x(!1),[m,B]=x(null),[v,w]=x([]),[A,f]=x(!1),[b,y]=x(null),[C,U]=x(null),[P,ee]=x(!1),[_,ne]=x(!1),[R,T]=x(!1),[X,E]=x(!1);x(null),x(null);const[O,z]=x(null),{chain:$}=ct(),{data:W,isLoading:re}=Jt(),{switchChainAsync:pe}=Bt(),ie=we(()=>d(i),[i,d]),{erc20Tokens:me,nativeToken:Q}=we(()=>{const M=[];let q=null;return ie.forEach(J=>{xt(J.address)?q=J:M.push(J)}),{erc20Tokens:M,nativeToken:q}},[ie]),{data:K}=Bo({contracts:me.map(M=>({address:M.address,abi:Yt,functionName:"balanceOf",args:[a],chainId:i}))}),{data:he}=Sn({address:a,chainId:i}),ae=we(()=>{if(!u(i))return[];const M=[];if(Q){const q=Q,J=he?.value??BigInt(0),ce=Number(J)/Math.pow(10,q.decimals);M.push({address:q.address,symbol:q.symbol,name:q.name,decimals:q.decimals,isNative:!0,chainId:i,balance:J,balanceFormatted:ce})}return me.forEach((q,J)=>{const ce=K?.[J],ue=ce?.status==="success"?ce.result:BigInt(0),fe=Number(ue)/Math.pow(10,q.decimals);M.push({address:q.address,symbol:q.symbol,name:q.name,decimals:q.decimals,isNative:!1,chainId:i,balance:ue,balanceFormatted:fe})}),M},[i,K,he,me,Q,u]);we(()=>g?ae.find(M=>M.symbol.toUpperCase()===g.toUpperCase()):void 0,[ae,g]),te(()=>{if(ae.length>0&&S.size>0){const M=new Map(S);let q=!1;S.forEach((J,ce)=>{const ue=ae.find(fe=>fe.address===ce);ue&&ue.balanceFormatted!==J.asset.balanceFormatted&&(M.set(ce,{...J,asset:ue}),q=!0)}),q&&F(M)}},[ae,S]);const Ee=u(i),Se=M=>{const q=new Map(S);q.has(M.address)?q.delete(M.address):q.set(M.address,{asset:M,amount:""}),F(q),B(null)},Ce=(M,q)=>{if(q===""||/^\d*\.?\d*$/.test(q)){const J=new Map(S),ce=J.get(M);if(ce){let ue=q;if(q!==""&&ce.asset.balanceFormatted!==void 0){const fe=parseFloat(q);!isNaN(fe)&&fe>ce.asset.balanceFormatted&&(ue=ce.asset.balanceFormatted.toString())}J.set(M,{...ce,amount:ue}),F(J),B(null)}}},Ie=(M,q)=>{const J=S.get(M);if(J?.asset.balanceFormatted!==void 0){const ce=J.asset.balanceFormatted*q/100,ue=Math.floor(ce*1e6)/1e6;Ce(M,ue.toString())}},Ae=se(async()=>{if(S.size===0){B("Please select at least one asset");return}for(const[q,J]of Array.from(S.entries())){if(!J.amount){B(`Please enter an amount for ${J.asset.symbol}`);return}const ce=parseFloat(J.amount);if(isNaN(ce)||ce<=0){B(`Please enter a valid amount for ${J.asset.symbol}`);return}const ue=ae.find(fe=>fe.address===q)?.balanceFormatted??J.asset.balanceFormatted;if(ue!==void 0&&ce>ue){B(`Insufficient ${J.asset.symbol} balance`);return}}if(!W){B("Wallet not connected. Please reconnect your external wallet.");return}p(!0),B(null);const M=[];try{$?.id!==i&&await pe({chainId:i});for(const[,q]of Array.from(S.entries())){const{asset:J,amount:ce}=q;try{const ue=Ke(ce,J.decimals);let fe;if(J.isNative)fe=await W.sendTransaction({to:h,value:ue});else{const oe=vt({abi:Yt,functionName:"transfer",args:[h,ue]});fe=await W.sendTransaction({to:J.address,data:oe})}const D=qe(i),Z=await D.waitForTransactionReceipt({hash:fe,timeout:12e4,pollingInterval:2e3,confirmations:2});if(Z.status!=="success")throw new Error(`Transfer to escrow failed for ${J.symbol}`);await D.getBlockNumber()-Z.blockNumber<2&&await new Promise(oe=>setTimeout(oe,3e3)),await ve.submitSpiceDeposit({txHash:fe,sender:c,tokenAddress:J.address,chainId:i,amount:Ke(ce,J.decimals).toString(),user:c,isDeposit:!0}),M.push({asset:J,txHash:fe,success:!0}),window.dispatchEvent(new CustomEvent("cross-chain-deposit-completed"))}catch(ue){const fe=ue;let D=fe?.message||"Deposit failed";fe?.code===4001||fe?.message?.includes("rejected")?D="Transaction rejected by user":fe?.message?.includes("insufficient funds")&&(D="Insufficient funds for transaction"),M.push({asset:J,txHash:"",success:!1,error:D})}finally{}}w(M),f(!0);try{const q=Array.from(S.values())[0];q?.asset&&q.amount&&sessionStorage.setItem("spiceflow:lastDepositSelection",JSON.stringify({symbol:q.asset.symbol,address:q.asset.address,decimals:q.asset.decimals,chainId:q.asset.chainId,amount:q.amount}))}catch{}}catch(q){B(q?.message||"Deposit failed")}finally{p(!1)}},[S,W,$,i,pe,h,ae]);te(()=>{o||(F(new Map),B(null),w([]),f(!1),p(!1))},[o]);const Pe=se(()=>{w([]),f(!1),B(null)},[]),Je=se(()=>{window.dispatchEvent(new CustomEvent("cross-chain-deposit-skipped"))},[]),j=S.size>0&&Array.from(S.values()).every(M=>M.amount&&parseFloat(M.amount)>0)&&!k&&!A&&W,H=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:Ot,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:t})]}),le=k||A&&v.length>0?e(po,{type:"deposit",isOpen:A&&v.length>0,isProcessing:k,onClose:n,onComplete:s,closeOnComplete:!1,onRetryTx:Pe,onNewTx:()=>{},results:v.length>0?v.map(M=>({asset:{symbol:M.asset.symbol,address:M.asset.address},txHash:M.txHash,success:M.success,error:M.error})):void 0,chainName:lt(i),explorerUrl:Ee?.blockExplorers?.default?.url,theme:I}):null;return l(ut,{isOpen:o,onClose:n,title:r,subtitle:H,theme:I,maxWidth:"480px",children:[l("div",{style:{padding:"0 24px 32px 24px",position:"relative",display:"flex",flexDirection:"column",maxHeight:"calc(80vh - 180px)"},children:[le&&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:le})}),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(M=>{const q=S.has(M.address);return e("div",{onClick:()=>Se(M),onMouseEnter:()=>y(M.address),onMouseLeave:()=>{y(null),U(null)},onMouseDown:()=>U(M.address),onMouseUp:()=>U(null),style:{padding:"4px 8px 4px 8px",borderRadius:"8px",border:`1px solid ${q?"#EA4B4B7A":b===M.address?"#F4A5A5":"#e5e7eb"}`,backgroundColor:q?"#FEF2F2":C===M.address?"#f5f5f5":b===M.address?"#fafafa":"white",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease",transform:C===M.address?"scale(0.96)":b===M.address?"translateY(-1px)":"none",boxShadow:q?"0 0 0 3px #FBDBDB":C===M.address?"0 1px 2px rgba(0, 0, 0, 0.05)":b===M.address?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:l("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e(at,{symbol:M.symbol,size:24,theme:I}),e("span",{style:{fontSize:"16px",fontWeight:510,color:"#3C3E42"},children:M.symbol}),M.balanceFormatted!==void 0&&l("span",{style:{fontSize:"10px",fontWeight:500,color:"#939291",fontFamily:'"IBM Plex Mono", monospace'},children:["(",M.balanceFormatted.toFixed(4),")"]})]})},M.address)})})]}),S.size>0&&e("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:Array.from(S.values()).map(({asset:M,amount:q})=>e(ur,{asset:M,amount:q,onAmountChange:J=>Ce(M.address,J),onPercentageClick:J=>Ie(M.address,J),theme:I,disabled:k},M.address))})]}),m&&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:m})}),!A&&l("div",{style:{display:"flex",gap:"12px",marginTop:"20px"},children:[e(Qe,{variant:"outline",onClick:Ae,onMouseEnter:()=>ee(!0),onMouseLeave:()=>{ee(!1),ne(!1)},onMouseDown:()=>ne(!0),onMouseUp:()=>ne(!1),disabled:!j,theme:I,style:{flex:2,padding:"8px",backgroundColor:j?_?"#d43d3d":P?"#f05555":"#ea4b4b":"#d1d5db",color:j?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:j?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:j?_?"scale(0.98)":P?"translateY(-2px)":"none":"none",boxShadow:_?"1px 1px 0px black":P&&j?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:k?l(Ye,{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..."})]}):re?"CONNECTING WALLET...":W?S.size===0?"SELECT ASSETS":Array.from(S.values()).every(M=>M.amount)?"DEPOSIT":"ENTER AMOUNTS":"WALLET NOT CONNECTED"}),e(Qe,{variant:"outline",onClick:Je,onMouseEnter:()=>T(!0),onMouseLeave:()=>{T(!1),E(!1)},onMouseDown:()=>E(!0),onMouseUp:()=>E(!1),disabled:k,theme:I,style:{flex:1,padding:"8px",backgroundColor:X?"#b0b0b0":R?"#e0e0e0":"#d0d0d0",color:"#1a1a1a",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:k?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:X?"scale(0.98)":R?"translateY(-2px)":"none",boxShadow:X?"1px 1px 0px black":R?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:"SKIP"})]}),e("style",{children:`
64
+ `})]})},jo=({depositBatches:o,tokenAddress:n,tokenDecimals:s,tokenTransferAmount:r,supportedChains:t,supportedTokens:i,theme:c="light",styles:a,className:h="",depositInputHook:g,onDepositSuccess:u,onDepositError:d,onTopUp:I,onComplete:S,submitButtonText:F,maxAmount:k})=>{const p=De(c),m={...p,typography:{...p.typography,fontFamily:a?.fontFamily||p.typography.fontFamily},colors:{...p.colors,primary:a?.primaryColor||p.colors.primary,primaryHover:a?.primaryColor?`${a.primaryColor}dd`:p.colors.primaryHover}},B=Gt(),{isReady:v,isAuthenticated:w,isConnected:A,address:f,provider:b,actions:y}=B,[C,U]=x(null),{assets:P,loading:ee,error:_,hasBalance:ne,refetch:R}=Yo({address:f,supportedChains:t,enabled:A,refetchInterval:3e4}),[T,X]=x(!1),[E,O]=x(null),[z,$]=x(!1),[W,re]=x(!1),[pe,ie]=x(!1),me=Fe(null),{intentStatus:Q,startStatusPolling:K,clearStatus:he}=Lt({checkStepStatus:(H,le)=>ve.checkStepStatus(H,le)});te(()=>{if(Q?.overallStatus==="success"&&Q.intentId&&me.current!==Q.intentId&&C&&f){const H=Q.steps.find(le=>le.transactionHash);if(H?.transactionHash){me.current=Q.intentId;const le=Ke(C.amount,C.asset.decimals);ve.submitSpiceDeposit({user:f,txHash:H.transactionHash,sender:f,tokenAddress:C.asset.address,chainId:C.asset.chainId,amount:le.toString(),isDeposit:!1}).then(()=>{R()}).catch(()=>{me.current=null})}}},[Q,f]),te(()=>{if(g&&g.assetAmount!==C?.amount&&C){let H=g.assetAmount;k&&H&&parseFloat(H)>parseFloat(k)&&(H=k,g.setAssetAmount(H)),U({...C,amount:H})}},[g?.assetAmount,C,k]),te(()=>{if(!g?.selectedAsset)return;const H=g.selectedAsset,le=H.address.toLowerCase(),M=le==="0x0"||le==="0x0000000000000000000000000000000000000000"||le==="0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",q=P.find(J=>{const ce=J.address.toLowerCase();return(M&&J.isNative||ce===le)&&(H.chainId?J.chainId===H.chainId:!0)});q&&U(J=>({asset:q,amount:J?.amount||g.assetAmount||""}))},[g?.selectedAsset,P,g?.assetAmount]);const ae=se(()=>{O(null)},[]),Ee=H=>{U({asset:H,amount:C?.amount||""}),g?.setSelectedAsset&&g.setSelectedAsset({symbol:H.symbol,address:H.address,decimals:H.decimals,chainId:H.chainId}),ae()},Se=se(H=>{if(C){let le=H;k&&H!==""&&parseFloat(H)>parseFloat(k)&&(le=k),Io(()=>{U({...C,amount:le}),ae()}),g&&g.setAssetAmount(le)}},[C,g,ae,k]),Ce=async()=>{if(!(!C||!f||o.length===0)){if(!v||!w){O(`Please authenticate with ${b||"wallet provider"} to continue`);return}X(!0),O(null),ie(!0);try{const H=[...o],le=[...new Set(H.map(oe=>oe.chainId))],M=[];for(const oe of le){const xe=qe(oe),Ze=yt(oe),et=await qt(f,xe),Me=await y.signAuthorization({contractAddress:Ze,chainId:oe,nonce:Number(et)});M.push(Me)}const q=jt(H),J=Math.floor(Date.now()/1e3)+60*10,ce=Pt(0n,BigInt(J),q),ue=await y.signMessage({raw:ce}),fe=typeof ue=="string"?ue:ue.signature;if(!fe)throw new Error("Failed to sign intent authorization");const D={mode:"7702",signatureType:"ecdsa",signature:fe,nbf:0,exp:J,chainBatches:q.map(oe=>({hash:oe.hash,chainId:oe.chainId,tokenTransfers:[{from:"solver",to:f,token:"0x0000000000000000000000000000000000000000",amount:Ke("0.00001",18)},{from:"solver",to:f,token:n,amount:r??Ke(C.amount,s)}],calls:oe.calls}))},Z=await ve.createAction({user:f,chainAuthorizations:M.map(oe=>({...oe,r:oe.r,s:oe.s,yParity:oe.yParity,address:oe.address,chainId:Number(oe.chainId),nonce:Number(oe.nonce)})),intents:[D]});if(Z){const oe=Ut(H,Me=>`Chain ${Me}`),[xe,Ze]=Z.intentIds[0].split("/"),et=parseInt(Ze||"0",10);K(Z.intentIds[0],oe);for(let Me=0;Me<H.length;Me++)await ve.executeStep(xe,et,Me,{action:"execute"})}window.dispatchEvent(new CustomEvent("deposit-completed"))}catch(H){const le=H instanceof Error?H.message:"Deposit failed";O(le),d?.(le)}finally{X(!1)}}},Ie=we(()=>i&&i.length>0?P.filter(H=>i.some(le=>le.toLowerCase()===H.symbol.toLowerCase())):P,[P,i]),Ae=C&&C.amount&&parseFloat(C.amount)>0&&parseFloat(C.amount)<=C.asset.balanceFormatted&&A&&!T&&o.length>0,Pe=_||E,Je={backgroundColor:a?.container?.backgroundColor||a?.primaryBackground||m.colors.background,border:`1px solid ${a?.container?.borderColor||m.colors.border}`,borderRadius:a?.container?.borderRadius||m.borderRadius.lg,padding:a?.container?.padding||m.spacing.md,width:a?.container?.width||"100%",maxWidth:"28rem",minHeight:"200px",margin:"0 auto",color:m.colors.text,fontFamily:m.typography.fontFamily,boxShadow:a?.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)")},j=Q?e(po,{type:"deposit",isOpen:!!Q&&Q.overallStatus!=="processing",isProcessing:T||Q?.overallStatus==="processing",closeOnComplete:!0,onRetryTx:()=>{he(),ie(!1),Ce()},onNewTx:()=>{he(),ie(!1),U(null),me.current=null,R()},onClose:()=>{he(),ie(!1)},onComplete:()=>{he(),ie(!1),U(null),me.current=null,R(),S?.()},results:Q?.overallStatus==="success"||Q?.overallStatus==="failed"?Q.steps.map(H=>({asset:{symbol:C?.asset.symbol||"Token",address:C?.asset.address||""},txHash:H.transactionHash||"",success:H.status==="success",amount:C?.amount})):void 0,chainName:C?lt(o[o.length-1].chainId):"Network",explorerUrl:C?Wt(o[o.length-1].chainId,"").replace(/\/tx\/.*$/,""):void 0,theme:m}):null;return l("div",{style:{...Je,position:"relative"},className:h,children:[j&&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:j})}),!ee&&!ne&&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."," ",I&&e("span",{onClick:I,style:{color:m.colors.primary,textDecoration:"underline",cursor:"pointer",fontWeight:600},children:"Top-up here."})]})}),e("div",{style:{marginBottom:m.spacing.sm},children:e(Ct,{assets:Ie,selectedAsset:C||void 0,onAssetSelect:Ee,onAmountChange:Se,loading:ee,label:"Amount",showBalance:!0,showMaxButton:!0,theme:m,styles:a})}),Pe&&e("div",{style:{backgroundColor:a?.errorMessage?.backgroundColor||(m.mode==="light"?"#fef2f2":`${a?.statusDisplay?.errorColor||m.colors.error}20`),border:`1px solid ${a?.errorMessage?.borderColor||(m.mode==="light"?"#fecaca":a?.statusDisplay?.errorColor||m.colors.error)}`,borderRadius:a?.errorMessage?.borderRadius||m.borderRadius.md,padding:a?.errorMessage?.padding||m.spacing.md,marginBottom:m.spacing.sm},children:e("p",{style:{color:a?.errorMessage?.color||a?.statusDisplay?.errorColor||m.colors.error,fontSize:a?.errorMessage?.fontSize||m.typography.fontSize.sm,fontWeight:a?.errorMessage?.fontWeight,fontFamily:a?.errorMessage?.fontFamily||m.typography.fontFamily,margin:0},children:Pe})}),e("div",{style:{display:"flex",flexDirection:"column",gap:m.spacing.sm},children:e(Qe,{variant:"outline",fullWidth:!0,onClick:Ce,onMouseEnter:()=>$(!0),onMouseLeave:()=>{$(!1),re(!1)},onMouseDown:()=>re(!0),onMouseUp:()=>re(!1),loading:T,disabled:!Ae||!A,theme:m,styles:a,style:{width:"100%",padding:"8px",backgroundColor:Ae?W?"#d43d3d":z?"#f05555":"#ea4b4b":"#d1d5db",color:Ae?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:Ae?"pointer":"not-allowed",marginTop:"20px",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:Ae?W?"scale(0.98)":z?"translateY(-2px)":"none":"none",boxShadow:W?"1px 1px 0px black":z&&Ae?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:v?w?A?T?"Executing Deposit...":C?C.amount?parseFloat(C.amount)>C.asset.balanceFormatted?"Insufficient Balance":o.length===0?"No Deposit Batches":F||"Execute Deposit":"Enter Amount":"Select Token":"Wallet Not Connected":"Authentication Required":"Loading..."})})]})},pr=({isOpen:o,onClose:n,title:s="Deposit",maxWidth:r="480px",depositBatches:t,tokenAddress:i,tokenDecimals:c,tokenTransferAmount:a,supportedChains:h,supportedTokens:g,theme:u="light",styles:d,className:I,depositInputHook:S,onDepositSuccess:F,onDepositError:k,onComplete:p,submitButtonText:m,maxAmount:B})=>{const v=De(u),w=A=>{F?.(A),n()};return e(ut,{isOpen:o,onClose:n,title:s,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:Ot,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:v,maxWidth:r,children:e("div",{style:{padding:"0 24px 24px 24px"},children:e(jo,{depositBatches:t,tokenAddress:i,tokenDecimals:c,tokenTransferAmount:a,supportedChains:h,supportedTokens:g,theme:u,styles:{...d,container:{...d?.container,boxShadow:"none",borderColor:"transparent",padding:"0",backgroundColor:"transparent"}},className:I,depositInputHook:S,onDepositSuccess:w,onDepositError:k,onComplete:p,submitButtonText:m,maxAmount:B})})})},ur=({asset:o,amount:n,onAmountChange:s,onPercentageClick:r,usdValue:t,disabled:i,styles:c,theme:a})=>{const h=o.balanceFormatted??0,g=parseFloat(n)||0,u=h>0?g/h*100:0,[d,I]=x(null),[S,F]=x(null),k=p=>{const m=p.target.value;(m===""||/^\d*\.?\d*$/.test(m))&&s(m)};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||a.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#7d7c7b",lineHeight:"24px"},children:"Amount"}),e("input",{type:"text",value:n,onChange:k,placeholder:"0.00",disabled:i,style:{fontFamily:c?.fontFamily||a.typography.fontFamily,fontSize:"40px",fontWeight:700,color:i?"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||a.typography.fontFamily,fontSize:"12px",fontWeight:500,color:"#71757a",lineHeight:"16px"},children:["Balance: ",h.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(at,{symbol:o.symbol,logoURI:o.logoURI,size:30,theme:a}),e("span",{style:{fontFamily:c?.fontFamily||a.typography.fontFamily,fontSize:"16px",fontWeight:500,color:"#3c3e42",lineHeight:"1.5"},children:o.symbol})]})})]}),e("div",{style:{display:"flex",gap:"10px",height:"14px",alignItems:"center",justifyContent:"flex-end"},children:[0,25,50,75,100].map((p,m)=>{const B=Math.abs(u-p)<1,v=m===4,w=p/100,A=d===p,f=S===p;return e("button",{onClick:()=>r(p),onMouseEnter:()=>I(p),onMouseLeave:()=>{I(null),F(null)},onMouseDown:()=>F(p),onMouseUp:()=>F(null),disabled:i,title:`${p}%`,style:{width:"14px",height:"14px",padding:0,border:"none",backgroundColor:"transparent",cursor:i?"not-allowed":"pointer",opacity:B?1:A?.8:.5,transform:f?"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:v?"#ea4b4b":"none",stroke:v?"#ea4b4b":"#3C3E42",strokeWidth:"0.3125"}),!v&&w>0&&e("path",{d:`M 7 7 L 7 0.15625 A 6.84375 6.84375 0 ${w>.5?1:0} 1 ${7+6.84375*Math.sin(w*2*Math.PI)} ${7-6.84375*Math.cos(w*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:o,onClose:n,onComplete:s,title:r="Deposit to Spicenet",description:t="Select tokens and enter amounts to deposit to your Spicenet Account",chainId:i,embeddedWalletAddress:c,externalWalletAddress:a,escrowAddress:h="0xeee2b52e7CFe6e2168341a34cEB783b68FEdf1A2",airdropTokenSymbol:g,getChainConfig:u,getSupportedTokens:d})=>{const I=De("light"),[S,F]=x(new Map),[k,p]=x(!1),[m,B]=x(null),[v,w]=x([]),[A,f]=x(!1),[b,y]=x(null),[C,U]=x(null),[P,ee]=x(!1),[_,ne]=x(!1),[R,T]=x(!1),[X,E]=x(!1);x(null),x(null);const[O,z]=x(null),{chain:$}=ct(),{data:W,isLoading:re}=Jt(),{switchChainAsync:pe}=Bt(),ie=we(()=>d(i),[i,d]),{erc20Tokens:me,nativeToken:Q}=we(()=>{const M=[];let q=null;return ie.forEach(J=>{xt(J.address)?q=J:M.push(J)}),{erc20Tokens:M,nativeToken:q}},[ie]),{data:K}=Bo({contracts:me.map(M=>({address:M.address,abi:Yt,functionName:"balanceOf",args:[a],chainId:i}))}),{data:he}=Sn({address:a,chainId:i}),ae=we(()=>{if(!u(i))return[];const M=[];if(Q){const q=Q,J=he?.value??BigInt(0),ce=Number(J)/Math.pow(10,q.decimals);M.push({address:q.address,symbol:q.symbol,name:q.name,decimals:q.decimals,isNative:!0,chainId:i,balance:J,balanceFormatted:ce})}return me.forEach((q,J)=>{const ce=K?.[J],ue=ce?.status==="success"?ce.result:BigInt(0),fe=Number(ue)/Math.pow(10,q.decimals);M.push({address:q.address,symbol:q.symbol,name:q.name,decimals:q.decimals,isNative:!1,chainId:i,balance:ue,balanceFormatted:fe})}),M},[i,K,he,me,Q,u]);we(()=>g?ae.find(M=>M.symbol.toUpperCase()===g.toUpperCase()):void 0,[ae,g]),te(()=>{if(ae.length>0&&S.size>0){const M=new Map(S);let q=!1;S.forEach((J,ce)=>{const ue=ae.find(fe=>fe.address===ce);ue&&ue.balanceFormatted!==J.asset.balanceFormatted&&(M.set(ce,{...J,asset:ue}),q=!0)}),q&&F(M)}},[ae,S]);const Ee=u(i),Se=M=>{const q=new Map(S);q.has(M.address)?q.delete(M.address):q.set(M.address,{asset:M,amount:""}),F(q),B(null)},Ce=(M,q)=>{if(q===""||/^\d*\.?\d*$/.test(q)){const J=new Map(S),ce=J.get(M);if(ce){let ue=q;if(q!==""&&ce.asset.balanceFormatted!==void 0){const fe=parseFloat(q);!isNaN(fe)&&fe>ce.asset.balanceFormatted&&(ue=ce.asset.balanceFormatted.toString())}J.set(M,{...ce,amount:ue}),F(J),B(null)}}},Ie=(M,q)=>{const J=S.get(M);if(J?.asset.balanceFormatted!==void 0){const ce=J.asset.balanceFormatted*q/100,ue=Math.floor(ce*1e6)/1e6;Ce(M,ue.toString())}},Ae=se(async()=>{if(S.size===0){B("Please select at least one asset");return}for(const[q,J]of Array.from(S.entries())){if(!J.amount){B(`Please enter an amount for ${J.asset.symbol}`);return}const ce=parseFloat(J.amount);if(isNaN(ce)||ce<=0){B(`Please enter a valid amount for ${J.asset.symbol}`);return}const ue=ae.find(fe=>fe.address===q)?.balanceFormatted??J.asset.balanceFormatted;if(ue!==void 0&&ce>ue){B(`Insufficient ${J.asset.symbol} balance`);return}}if(!W){B("Wallet not connected. Please reconnect your external wallet.");return}p(!0),B(null);const M=[];try{$?.id!==i&&await pe({chainId:i});for(const[,q]of Array.from(S.entries())){const{asset:J,amount:ce}=q;try{const ue=Ke(ce,J.decimals);let fe;if(J.isNative)fe=await W.sendTransaction({to:h,value:ue});else{const oe=vt({abi:Yt,functionName:"transfer",args:[h,ue]});fe=await W.sendTransaction({to:J.address,data:oe})}const D=qe(i),Z=await D.waitForTransactionReceipt({hash:fe,timeout:12e4,pollingInterval:2e3,confirmations:2});if(Z.status!=="success")throw new Error(`Transfer to escrow failed for ${J.symbol}`);await D.getBlockNumber()-Z.blockNumber<2&&await new Promise(oe=>setTimeout(oe,3e3)),await ve.submitSpiceDeposit({txHash:fe,sender:c,tokenAddress:J.address,chainId:i,amount:Ke(ce,J.decimals).toString(),user:c,isDeposit:!0}),M.push({asset:J,txHash:fe,success:!0}),window.dispatchEvent(new CustomEvent("cross-chain-deposit-completed"))}catch(ue){const fe=ue;let D=fe?.message||"Deposit failed";fe?.code===4001||fe?.message?.includes("rejected")?D="Transaction rejected by user":fe?.message?.includes("insufficient funds")&&(D="Insufficient funds for transaction"),M.push({asset:J,txHash:"",success:!1,error:D})}finally{}}w(M),f(!0);try{const q=Array.from(S.values())[0];q?.asset&&q.amount&&sessionStorage.setItem("spiceflow:lastDepositSelection",JSON.stringify({symbol:q.asset.symbol,address:q.asset.address,decimals:q.asset.decimals,chainId:q.asset.chainId,amount:q.amount}))}catch{}}catch(q){B(q?.message||"Deposit failed")}finally{p(!1)}},[S,W,$,i,pe,h,ae]);te(()=>{o||(F(new Map),B(null),w([]),f(!1),p(!1))},[o]);const Pe=se(()=>{w([]),f(!1),B(null)},[]),Je=se(()=>{window.dispatchEvent(new CustomEvent("cross-chain-deposit-skipped"))},[]),j=S.size>0&&Array.from(S.values()).every(M=>M.amount&&parseFloat(M.amount)>0)&&!k&&!A&&W,H=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:Ot,alt:"Info",style:{width:"14px",height:"14px",marginTop:"2px",flexShrink:0}}),e("p",{style:{fontSize:"13px",color:"#374151",margin:0,lineHeight:"1.5"},children:t})]}),le=k||A&&v.length>0?e(po,{type:"deposit",isOpen:A&&v.length>0,isProcessing:k,onClose:n,onComplete:s,closeOnComplete:!1,onRetryTx:Pe,onNewTx:()=>{},results:v.length>0?v.map(M=>({asset:{symbol:M.asset.symbol,address:M.asset.address},txHash:M.txHash,success:M.success,error:M.error})):void 0,chainName:lt(i),explorerUrl:Ee?.blockExplorers?.default?.url,theme:I}):null;return l(ut,{isOpen:o,onClose:n,title:r,subtitle:H,theme:I,maxWidth:"480px",children:[l("div",{style:{padding:"0 24px 32px 24px",position:"relative",display:"flex",flexDirection:"column",maxHeight:"calc(80vh - 180px)"},children:[le&&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:le})}),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(M=>{const q=S.has(M.address);return e("div",{onClick:()=>Se(M),onMouseEnter:()=>y(M.address),onMouseLeave:()=>{y(null),U(null)},onMouseDown:()=>U(M.address),onMouseUp:()=>U(null),style:{padding:"4px 8px 4px 8px",borderRadius:"8px",border:`1px solid ${q?"#EA4B4B7A":b===M.address?"#F4A5A5":"#e5e7eb"}`,backgroundColor:q?"#FEF2F2":C===M.address?"#f5f5f5":b===M.address?"#fafafa":"white",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",transition:"all 150ms ease",transform:C===M.address?"scale(0.96)":b===M.address?"translateY(-1px)":"none",boxShadow:q?"0 0 0 3px #FBDBDB":C===M.address?"0 1px 2px rgba(0, 0, 0, 0.05)":b===M.address?"0 4px 8px rgba(0, 0, 0, 0.1)":"none"},children:l("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e(at,{symbol:M.symbol,size:24,theme:I}),e("span",{style:{fontSize:"16px",fontWeight:510,color:"#3C3E42"},children:M.symbol}),M.balanceFormatted!==void 0&&l("span",{style:{fontSize:"10px",fontWeight:500,color:"#939291",fontFamily:'"IBM Plex Mono", monospace'},children:["(",M.balanceFormatted.toFixed(4),")"]})]})},M.address)})})]}),S.size>0&&e("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:Array.from(S.values()).map(({asset:M,amount:q})=>e(ur,{asset:M,amount:q,onAmountChange:J=>Ce(M.address,J),onPercentageClick:J=>Ie(M.address,J),theme:I,disabled:k},M.address))})]}),m&&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:m})}),!A&&l("div",{style:{display:"flex",gap:"12px",marginTop:"20px"},children:[e(Qe,{variant:"outline",onClick:Ae,onMouseEnter:()=>ee(!0),onMouseLeave:()=>{ee(!1),ne(!1)},onMouseDown:()=>ne(!0),onMouseUp:()=>ne(!1),disabled:!j,theme:I,style:{flex:2,padding:"8px",backgroundColor:j?_?"#d43d3d":P?"#f05555":"#ea4b4b":"#d1d5db",color:j?"#0e0d0b":"#6b7280",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:j?"pointer":"not-allowed",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:j?_?"scale(0.98)":P?"translateY(-2px)":"none":"none",boxShadow:_?"1px 1px 0px black":P&&j?"5px 5px 0px white, 6px 6px 0px black":"3px 3px 0px white, 4px 4px 0px black"},children:k?l(Ye,{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..."})]}):re?"CONNECTING WALLET...":W?S.size===0?"SELECT ASSETS":Array.from(S.values()).every(M=>M.amount)?"DEPOSIT":"ENTER AMOUNTS":"WALLET NOT CONNECTED"}),e(Qe,{variant:"outline",onClick:Je,onMouseEnter:()=>T(!0),onMouseLeave:()=>{T(!1),E(!1)},onMouseDown:()=>E(!0),onMouseUp:()=>E(!1),disabled:k,theme:I,style:{flex:1,padding:"8px",backgroundColor:X?"#b0b0b0":R?"#e0e0e0":"#d0d0d0",color:"#1a1a1a",border:"1px solid #0e0d0b",fontWeight:500,fontSize:"18px",fontFamily:'"IBM Plex Mono", monospace',lineHeight:"156%",textTransform:"uppercase",cursor:k?"not-allowed":"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"10px",transition:"all 150ms ease",transform:X?"scale(0.98)":R?"translateY(-2px)":"none",boxShadow:X?"1px 1px 0px black":R?"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); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicenet-io/spiceflow-ui",
3
- "version": "1.11.6",
3
+ "version": "1.11.7",
4
4
  "description": "Spiceflow UI SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs.js",