@spicenet-io/spiceflow-ui 3.3.20 → 3.3.22

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.
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ import{jsx as I,jsxs as Ue}from"react/jsx-runtime";import{useContext as W,useState as O,useEffect as L,useMemo as F,createContext as oe,useCallback as Me,useRef as _e}from"react";import{getChainMeta as ie,getTokensForChain as Oe,getDelegateContract as Le,ZERO_ADDRESS as Fe,isNativeToken as G,getTokenByAddress as De,getChainIdsByNetwork as je}from"@spicenet-io/spiceflow-core";import{isAddress as N,getAddress as q,defineChain as ze,createPublicClient as Je,http as He,formatUnits as ce,createWalletClient as Ye,custom as Ge}from"viem";import{readContract as qe}from"viem/actions";import{useQuery as Xe}from"@tanstack/react-query";import{useWallets as X,usePrivy as Q,getEmbeddedConnectedWallet as V,useSign7702Authorization as Qe,useSignMessage as Ve}from"@privy-io/react-auth";import{useDynamicContext as K}from"@dynamic-labs/sdk-react-core";import{useAccount as le}from"wagmi";function D(t,e){return!t||!e?!1:N(t)&&N(e)?q(t)===q(e):t.toLowerCase()===e.toLowerCase()}const de=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],Ke="0xcA11bde05977b3631167028862bE2a173976CA11",Ze={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},et=new Set([5115]);function tt(t){const e=Ze[t.id]??(et.has(t.id)?void 0:Ke);return ze({id:t.id,name:t.name,nativeCurrency:t.nativeCurrency,rpcUrls:{default:{http:[t.rpcUrl]}},blockExplorers:{default:{name:t.displayName,url:t.blockExplorer}},testnet:t.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const rt=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],j=Object.fromEntries(rt.map(t=>ie(t)).filter(t=>t!=null).map(t=>[t.id,{...t,viemChain:tt(t),supportedTokens:Oe(t.id)}])),at=j;let ue={};const Z=new Map,fe=t=>{ue={...t||{}},Z.clear()},ee=t=>{const e=ue[t];return e&&typeof e=="string"&&e.length>0?e:j[t]?.rpcUrl},$=t=>j[t],te=t=>{const e=ie(t);return e?.displayName||e?.name||`Chain ${t}`},nt=t=>{const e=Le(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e},st=(t,e,a)=>{const r=$(t);return r?.blockExplorer?`${r.blockExplorer}/tx/${e}`:"#"};async function ot(t,e){const a=`0x${e.toString(16)}`;try{await t.request({method:"wallet_switchEthereumChain",params:[{chainId:a}]});return}catch(n){if(!(n?.code===4902||typeof n?.message=="string"&&n.message.includes("Unrecognized chain ID")))throw n}const r=$(e);if(!r)throw new Error(`Cannot add unknown chain ${e} to wallet`);await t.request({method:"wallet_addEthereumChain",params:[{chainId:a,chainName:r.name||`Chain ${e}`,nativeCurrency:r.nativeCurrency||{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:[ee(e)||r.rpcUrl],blockExplorerUrls:r.blockExplorer?[r.blockExplorer]:void 0}]})}const pe=t=>{const e=$(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);const a=ee(t);if(!a)throw new Error(`No RPC URL configured for chain ID: ${t}`);const r=`${t}:${a}`,n=Z.get(r);if(n)return n;const s=Je({chain:e.viemChain,transport:He(a,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return Z.set(r,s),s},it=()=>{const t={};return Object.values(j).forEach(e=>{t[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:ee(e.id)||e.rpcUrl}}),t},ct=(t,e=[])=>{const a=$(t);if(!a)return[];const r=[];if(![11155111,421614,84532,688689].includes(t)){const s=e.find(l=>l.chainId===t&&l.isNative);s?r.push(s):r.push({address:Fe,name:a.nativeCurrency.name,symbol:a.nativeCurrency.symbol,decimals:a.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t})}if(!a.supportedTokens)return r;const n=r.some(s=>s.isNative);return a.supportedTokens.forEach(s=>{if(n&&G(s.address))return;const l=e.find(o=>o.chainId===t&&D(o.address,s.address));l?r.push(l):r.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:!1,chainId:t})}),r},lt=async(t,e)=>{const a=$(t);if(!a)throw new Error(`Unsupported chain ID: ${t}`);const r=e.toLowerCase();if(G(r)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const n=a.supportedTokens.find(s=>D(s.address,r));if(n)return n.decimals}try{if(!N(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const n=q(e),s=pe(t),l=await qe(s,{address:n,abi:de,functionName:"decimals"});return Number(l)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${t}`)}};class E extends Error{constructor(e,a,r={}){super(a),this.code=e,this.context=r,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,E)}}function re(t){return t instanceof E}const dt=["user rejected","user denied","user cancelled","rejected the request","action_rejected","4001"];function me(t){if(!t)return"";if(typeof t=="string")return t;const e=t,a=e.message||e.reason||"",r=e.details||"";return`${a} ${r}`.trim()}const he=t=>{if(re(t))return t.code==="WALLET_REJECTED";const e=me(t).toLowerCase();return dt.some(a=>e.includes(a))},ut=(t,e="Something went wrong. Please try again.")=>he(t)?"Transaction was rejected.":re(t)?t.message||e:me(t)||e;function ft(t,e){const a=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!a)return e;const[,r,n,s]=a,l=Number(s),o=BigInt(r),h=BigInt(n);let d;for(const f of t.intents){const y=f.chainBatches.find(g=>g.chainId===l);if(y){d=y;break}}const m=d?.tokenTransfers.find(f=>f.from==="escrow"&&D(f.to,t.user)&&!G(f.token)),c=te(l);if(!m)return`Amount is too small to cover the estimated fee on ${c}.`;const p=De(m.token,l),u=p?.decimals??18,b=p?.symbol??"tokens",i=ce(o,u),w=ce(h,u);return`Amount is too small to cover the estimated fee on ${c}. Amount: ${i} ${b}. Estimated fee: ${w} ${b}.`}const ye=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-submission-api.spicenet.io";function z(t,e){return typeof e=="bigint"?e.toString():e}function x(t,e){if(!t)return e;const a=t.error;return(typeof t.message=="string"?t.message:"")||(a&&typeof a=="object"&&"message"in a&&typeof a.message=="string"?a.message:"")||(typeof a=="string"?a:"")||e}async function pt(t){try{return await t.json()}catch{return null}}function mt(t){return(Array.isArray(t?.balances)?t.balances:[]).flatMap(e=>{if(!e||typeof e!="object")return[];const a=e;return[{receiptToken:typeof a.receiptToken=="string"?a.receiptToken:void 0,tokenName:String(a.tokenName??""),balanceAvailable:String(a.balanceAvailable??"0"),chainTokens:Array.isArray(a.chainTokens)?a.chainTokens.filter(r=>typeof r=="string"):a.chainTokens&&typeof a.chainTokens=="object"?a.chainTokens:a.chainTokenConfig&&typeof a.chainTokenConfig=="object"?a.chainTokenConfig:void 0,decimals:typeof a.decimals=="number"?a.decimals:void 0,balanceUsd:typeof a.balanceUsd=="number"||typeof a.balanceUsd=="string"?a.balanceUsd:null}]})}class ht{constructor(){this.baseUrl=ye}setBaseUrl(e){this.baseUrl=e}getBaseUrl(){return this.baseUrl}async createAction(e){const a=`${this.baseUrl}/actions`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,z)}),n=await r.json();if(!r.ok||n.success===!1)throw new E("RELAYER_ERROR",x(n,`Relayer API error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:"/actions"});return n}async estimateActionFees(e){const a=`${this.baseUrl}/actions/fees/estimate`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,z)}),n=await r.json();if(!r.ok||!n.success||!n.data?.feeEstimate){const s=x(n,`Relayer fee estimate error: ${r.status}`);throw new E("RELAYER_ERROR",ft(e,s),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:"/actions/fees/estimate"})}return n.data.feeEstimate}async estimateBatchGas(e){const a=`${this.baseUrl}/actions/gas/estimate`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,z)}),n=await r.json();if(!r.ok||!n.success||!n.data?.gasFee)throw new E("RELAYER_ERROR",x(n,`Relayer gas estimate error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:"/actions/gas/estimate"});return{gasFee:BigInt(n.data.gasFee),gasQuoteSource:n.data.gasQuoteSource}}async executeStep(e,a,r,n){const s=`${this.baseUrl}/actions/${e}/intents/${a}/steps/${r}`,l=`/actions/${e}/intents/${a}/steps/${r}`,o=1e4,h=new Promise((c,p)=>setTimeout(()=>p(new E("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${o/1e3}s`,{actionId:e,intentIndex:a,stepIndex:r,endpoint:l})),o)),d=await Promise.race([fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),h]),m=await d.json();if(!d.ok||m.success===!1)throw new E("RELAYER_EXECUTE_ERROR",x(m,`Execute step error: ${d.status}`),{httpStatus:d.status,responseBody:JSON.stringify(m),endpoint:l,actionId:e});if(m?.status==="error"||m?.status==="reverted"){const c=x(m,""),p=c?`: ${c}`:"";throw new E("RELAYER_EXECUTE_ERROR",`Step ${r} previously ${m.status}${p}`,{httpStatus:d.status,responseBody:JSON.stringify(m),endpoint:l,actionId:e,intentIndex:a,stepIndex:r,stepStatus:m.status})}return{success:!0,transactionHash:m.transactionHash}}async checkStepStatus(e,a){const r=e.split("/"),n=r[0],s=r.length>=2?r[1]:"0",l=`${this.baseUrl}/actions/${n}/intents/${s}/steps/${a}`,o=await fetch(l),h=await o.json();if(!o.ok||h.success===!1)throw new E("RELAYER_STATUS_ERROR",x(h,`Intent step status check failed: ${o.status}`),{httpStatus:o.status,responseBody:JSON.stringify(h),endpoint:l,intentId:e});return{success:!0,data:{status:h.status==="error"?"reverted":h.status,transactionHash:h.txid,error:x(h,"")}}}async createWallet(e,a){const r=`${this.baseUrl}/wallets/${e}`,n=await fetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),s=await n.json();if(!n.ok||s.success===!1)throw new E("RELAYER_ERROR",x(s,`Create wallet error: ${n.status}`),{httpStatus:n.status,responseBody:JSON.stringify(s),endpoint:`/wallets/${e}`});return s}async getWallet(e){const a=`${this.baseUrl}/wallets/${e}`,r=await fetch(a),n=await r.json();if(!r.ok||n.success===!1)throw new E("RELAYER_ERROR",x(n,`Get wallet error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:`/wallets/${e}`});return n}async createWithdrawal(e){const a=`${this.baseUrl}/withdrawals`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,z)}),n=await r.json();if(!r.ok||n.success===!1)throw new E("RELAYER_ERROR",x(n,`Create withdrawal error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:"/withdrawals"});return n}async getWithdrawal(e){const a=`${this.baseUrl}/withdrawals/${e}`,r=await fetch(a),n=await r.json();if(!r.ok||n.success===!1)throw new E("RELAYER_ERROR",x(n,`Get withdrawal error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:`/withdrawals/${e}`});return n}async getRollupTimestamp(){const e=`${this.baseUrl}/time`,a=await fetch(e),r=await a.json();if(!a.ok||r.success===!1)throw new E("RELAYER_ERROR",x(r,`Get rollup timestamp error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(r),endpoint:"/time"});return r}}const S=new ht;async function yt(t){const e=`${S.getBaseUrl()}/wallets/${t}/balance`,a=await fetch(e,{cache:"no-store"}),r=await pt(a);if(!a.ok||r?.success===!1)throw new E("RELAYER_ERROR",x(r,`Unable to verify Spice balance: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(r),endpoint:`/wallets/${t}/balance`});return mt(r)}const ae=new Map;async function ne(t,e){const a=t.toLowerCase(),r=ae.get(a);if(r)return r;const n=(async()=>{try{await S.getWallet(t);return}catch{}const{unix_timestamp:s}=await S.getRollupTimestamp(),l=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${t.slice(2).toLowerCase()}. Nonce: ${s}`,o=await e(l),h=typeof o=="string"?o:o.signature;if(!h)throw new Error("Wallet returned no smart wallet signature");await S.createWallet(t,{timestamp:s,signature:h})})();ae.set(a,n);try{await n}finally{ae.delete(a)}}const gt=(t,e)=>{const a=n=>e?e(n):te(n),r=[];return t.forEach((n,s)=>{const l=n.calls&&n.calls.length>0,o=n.tokenTransfers&&n.tokenTransfers.length>0;!l&&!o||r.push({stepId:s,status:s===0?"processing":"pending",chainId:n.chainId,chainName:a(n.chainId),description:"Processing transaction"})}),r},se=t=>{if(!t)return!1;const e=t.connector;if(!e)return!1;if(e.isEmbeddedWallet===!0)return!0;const a=(e.key||e.connectorKey||"").toLowerCase();if(a.includes("embedded")||a.includes("turnkey"))return!0;const r=(e.name||t.walletName||"").toLowerCase();return!!(r.includes("embedded")||r.includes("turnkey"))},J=t=>(t?.connectedWallets||[]).find(e=>se(e))||(se(t?.primaryWallet)?t.primaryWallet:null),wt=t=>(t?.connectedWallets||[]).find(e=>e?.address&&e?.connector&&!se(e))||null,ge=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getWalletClient=="function"){const a=e===void 0?[void 0]:[String(e),e,void 0];let r=null;for(const n of a)try{const s=await t.getWalletClient(n);if(s)return s}catch(s){r=s}if(r)throw r}if(typeof t.getEthereumProvider=="function"){const a=await t.getEthereumProvider(),r=e?$(e)?.viemChain:void 0;return Ye({account:t.address,chain:r,transport:Ge(a)})}throw new Error("Wallet client not available")},we=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getEthereumProvider=="function")return t.getEthereumProvider();const a=await ge(t,e);return{request:r=>a.request(r)}},bt=(t,e)=>({address:t?.address||e.address,chainId:Number(t?.chainId??e.chainId),contractAddress:t?.contractAddress||t?.delegate||e.contractAddress,nonce:BigInt(t?.nonce??e.nonce),r:t?.r,s:t?.s,yParity:(()=>{if(typeof t?.yParity=="number")return t.yParity;const a=Number(t?.v??27);return Number.isFinite(a)?a>=27?a-27:a:0})()}),C=t=>t?.address?{address:t.address,wallet:t,getWalletClient:e=>ge(t,e),getEthereumProvider:e=>we(t,e)}:null,be=()=>{const t=W(R),{address:e,connector:a}=le();let r=null,n=null;try{r=X(),{user:n}=Q()}catch{r=null,n=null}let s=null;try{s=K()}catch{s=null}const l=r?.wallets||[],o=V(l),h=o?.address?.toLowerCase(),d=l.find(g=>g.connectorType!=="embedded"&&g.address?.toLowerCase()!==h),m=J(s),c=wt(s),p=e&&a?{address:e,connector:a,getEthereumProvider:()=>a.getProvider()}:null,u=t?.provider,b=C(o)||C(m),i=C(p)||C(d)||C(c)||null,w=u==="dynamic"?C(m):u==="privy"?C(o):b,f=u==="dynamic"?C(p)||C(c):u==="privy"?C(p)||C(d):i,y=u==="dynamic"?w?.address:u==="privy"?w?.address||n?.wallet?.address:b?.address||n?.wallet?.address;return{embeddedWallet:w,externalWallet:f,embeddedAddress:y,externalAddress:f?.address}},Et=()=>{const[t,e]=O(!1);let a=null,r=null;try{a=K()}catch(u){r=u instanceof Error?u.message:String(u)}if(L(()=>{e(!0)},[]),r)return{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:"dynamic",actions:{signAuthorization:async()=>{throw new Error("Dynamic context not available")},signMessage:async()=>{throw new Error("Dynamic context not available")},getEthereumProvider:async()=>{throw new Error("Dynamic context not available")}}};const{user:n,primaryWallet:s,connectedWallets:l}=a||{},o=J({connectedWallets:l,primaryWallet:s})||s,h=!!n,d=o?.address,m={isReady:t&&!!a,isAuthenticated:h,isConnected:h&&!!d,address:d,provider:"dynamic"},c=async u=>{if(!o)throw new Error("Dynamic embedded wallet not available");const{isEthereumWallet:b}=await import("@dynamic-labs/ethereum");if(!b(o))throw new Error("Embedded wallet is not an Ethereum wallet");const i=await o.getWalletClient();if(!i)throw new Error("Dynamic wallet client not available");return{signature:await i.signMessage({message:u,account:o.address})}},p=async()=>{if(!d)throw new Error("Dynamic embedded wallet not available");await ne(d,c)};return{...m,actions:{signAuthorization:async u=>{if(!o)throw new Error("Dynamic embedded wallet not available");await p();const{isEthereumWallet:b}=await import("@dynamic-labs/ethereum");if(!b(o))throw new Error("Embedded wallet is not an Ethereum wallet");const i=o.connector,w={address:o.address,chainId:u.chainId,contractAddress:u.contractAddress,nonce:u.nonce},f={address:u.contractAddress,chainId:u.chainId,nonce:u.nonce},y=typeof i?.getWaasWalletClient=="function"?await i.getWaasWalletClient():null;if(y&&typeof y.signRawMessage=="function"){const{hashAuthorization:g}=await import("viem/experimental"),{parseSignature:B}=await import("viem"),k={address:u.contractAddress,chainId:u.chainId,nonce:u.nonce},U=i.getSignedSessionId,Y=typeof U=="function"?await U.call(i):void 0,M=i.getAuthToken,_=typeof M=="function"?M.call(i):void 0,v=await y.signRawMessage({accountAddress:o.address,authToken:_,context:{eip7702Auth:k},message:g(k).slice(2),signedSessionId:Y}),A=B(v);return{address:w.contractAddress,chainId:w.chainId,contractAddress:w.contractAddress,nonce:BigInt(w.nonce),r:A.r,s:A.s,yParity:Number(A.yParity)}}if(typeof i?.signAuthorization=="function"){typeof i.switchNetwork=="function"&&await i.switchNetwork({networkChainId:u.chainId});const g=await i.signAuthorization(f);return bt(g,w)}throw new Error("Dynamic embedded wallet does not support EIP-7702 authorization. Ensure @dynamic-labs packages are v4.15+.")},signMessage:async u=>{if(!(typeof u=="object"&&"raw"in u))return c(u);if(await p(),!o)throw new Error("Dynamic embedded wallet not available");const b=await o.getWalletClient();if(!b)throw new Error("Dynamic wallet client not available");return{signature:await b.signMessage({message:{raw:u.raw},account:o.address})}},getEthereumProvider:async()=>{if(!o)throw new Error("Dynamic embedded wallet not available");const{isEthereumWallet:u}=await import("@dynamic-labs/ethereum");if(!u(o))throw new Error("Embedded wallet is not an Ethereum wallet");return we(o)}}}},Ee=()=>{const t=W(R),e=t?.mode||"7702";let a=null,r=null;try{a=X(),{user:r}=Q()}catch{a=null}const n=V(a?.wallets||[])?.address,s=r?.wallet?.address;let l=null;try{l=K()}catch{l=null}const o=(J(l)||l?.primaryWallet)?.address;if(!(!t||e!=="7702"))return t.provider==="privy"?n??s:t.provider==="dynamic"?o:n??s??o},vt=()=>{const t=W(R)?.mode,{isConnected:e,address:a}=le();let r=null,n=null,s=null,l=null,o=null;try{r=Q(),n=Qe(),s=Ve(),l=X()}catch(f){o=f instanceof Error?f.message:String(f)}if(o)return t==="ondemand"&&e&&a?{isReady:!0,isAuthenticated:!0,isConnected:!0,address:a,provider:"privy",actions:{signAuthorization:async()=>{throw new Error("Not available in ondemand mode")},signMessage:async()=>{throw new Error("Not available in ondemand mode")},getEthereumProvider:async()=>{throw new Error("Not available in ondemand mode")}}}:{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("Privy not available")},signMessage:async()=>{throw new Error("Privy not available")},getEthereumProvider:async()=>{throw new Error("Privy not available")}}};const{ready:h=!1,authenticated:d=!1}=r||{},m=Ee(),c=V(l?.wallets||[]),p=m||c?.address,u=!!p&&!!c,b={isReady:t==="ondemand"?!0:h,isAuthenticated:t==="ondemand"?!0:d||u,isConnected:t==="ondemand"?e&&!!a||h&&(d||u)&&u:h&&u,address:t==="ondemand"&&!m&&e?a:p,provider:"privy"},i=async f=>{if(s)try{return{signature:(await s.signMessage({message:f})).signature}}catch(k){if(!c)throw k}if(!c)throw new Error("Privy sign message not available");const y=await c.getEthereumProvider(),{createWalletClient:g,custom:B}=await import("viem");return{signature:await g({account:c.address,transport:B(y)}).signMessage({account:c.address,message:f})}},w=async()=>{if(!p)throw new Error("Embedded wallet not available for smart wallet setup");await ne(p,i)};return{...b,actions:{signAuthorization:async f=>{if(!n)throw new Error("Privy sign authorization not available");try{await w();const y=await n.signAuthorization({contractAddress:f.contractAddress,chainId:f.chainId,nonce:f.nonce},{address:p});return delete y.v,y}catch(y){const g=y?.message||String(y);throw g.includes("not configured")||g.includes("chain")?new Error(`Chain ${f.chainId} is not configured in PrivyProvider. Add this chain to your Privy dashboard or supportedChainIds.`):y}},signMessage:async f=>{if(typeof f=="object"&&"raw"in f){if(await w(),!c)throw new Error("Embedded wallet not available for raw signing");const y=await c.getEthereumProvider(),{createWalletClient:g,custom:B}=await import("viem");return{signature:await g({account:c.address,transport:B(y)}).signMessage({account:c.address,message:f})}}return i(f)},getEthereumProvider:async()=>{if(!c)throw new Error("Embedded wallet not available");return c.getEthereumProvider()}}}},ve=()=>{const t=W(R)?.provider,e=vt(),a=Et();return t==="privy"?e:t==="dynamic"?a:{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("No wallet provider available")},signMessage:async()=>{throw new Error("No wallet provider available")},getEthereumProvider:async()=>{throw new Error("No wallet provider available")}}}},xt=typeof process<"u"&&process.env?.NEXT_PUBLIC_PORTAL_API_URL||typeof import.meta<"u"&&import.meta.env?.VITE_PORTAL_API_URL||"https://portal-backend.spicenet.io/api/v1",xe=t=>t.replace(/\/+$/,"");function Ce({walletAddress:t,campaignId:e,campaignGroup:a,partnerId:r,apiBaseUrl:n=xt,enabled:s=!0,staleTime:l=5*60*1e3,refetchInterval:o=!1}={}){const{isAuthenticated:h,isConnected:d}=ve(),{externalAddress:m}=be(),c=t??m,p=typeof c=="string"?c.toLowerCase():void 0,u=s&&h&&d&&!!m&&!!p&&N(p)&&!!e&&!!a&&!!r,b=F(()=>["partner-whitelist","check",p,e,a,r,xe(n)],[p,e,a,r,n]),i=Xe({queryKey:b,enabled:u,staleTime:l,refetchInterval:o,queryFn:async()=>{if(!p||!N(p))throw new Error("A valid wallet address is required");if(!e||!a||!r)throw new Error("campaignId, campaignGroup, and partnerId are required");const w=new URLSearchParams({walletAddress:p,campaignId:e,campaignGroup:a,partnerId:r}),f=await fetch(`${xe(n)}/portal/mainnet/whitelist/check?${w.toString()}`,{cache:"no-store"});if(!f.ok)throw new Error(`Failed to check whitelist: ${f.status}`);return await f.json()}});return{isWhitelisted:i.data?.isWhitelisted??!1,whitelistCheck:i.data,checkedWalletAddress:p,externalWalletAddress:m,isExternalWalletConnected:!!m,isWhitelistCheckEnabled:u,...i}}const Be="spiceflow-mode",ke=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(Be);return t==="embedded"?"7702":t==="external"?"ondemand":null}catch{return null}},Ct=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(Be,t==="7702"?"embedded":"external")}catch{}},Bt=()=>ke()!==null,Se=oe(null),kt=["__spicenet_whitelist_blocked__"],R=oe(null),St=({children:t,value:e,whitelist:a})=>{const r=Ce(a===!1?{enabled:!1}:a),n=r.isWhitelistCheckEnabled&&r.isSuccess,s=r.isWhitelistCheckEnabled&&!r.isWhitelisted,l=F(()=>({...e,allowedTokens:s?kt:e.allowedTokens,mode:s?"ondemand":e.mode,isUserWhitelisted:n?r.isWhitelisted:null,isWhitelistChecking:r.isWhitelistCheckEnabled&&(r.isLoading||r.isFetching),isWhitelistGateActive:s,whitelistCheck:r.whitelistCheck}),[e,s,n,r.isWhitelisted,r.isWhitelistCheckEnabled,r.isLoading,r.isFetching,r.whitelistCheck]);return I(R.Provider,{value:l,children:t})},$t=({children:t,provider:e,supportedChainIds:a,allowedTokens:r,network:n="testnet",mode:s="7702",skipFlow:l=[],nativeChainId:o,appName:h="Spicenet",apiUrl:d,theme:m,rpcOverrides:c,whitelist:p})=>{L(()=>{if(!d)return;const g=S.getBaseUrl();return S.setBaseUrl(d),()=>S.setBaseUrl(g)},[d]),L(()=>(fe(c),()=>fe(void 0)),[c]);const u=a??je(n),b=m??null,[i,w]=O(()=>ke()??s),f=Me(g=>{w(g),Ct(g)},[]),y=F(()=>({provider:e,supportedChainIds:u,allowedTokens:r,skipFlow:l,mode:i,setMode:f,network:n,nativeChainId:o,appName:h,apiUrl:d,rpcOverrides:c,isUserWhitelisted:null,isWhitelistChecking:!1,isWhitelistGateActive:!1}),[e,u,r,l,i,f,n,o,h,d,c]);return I(Se.Provider,{value:b,children:I(R.Provider,{value:y,children:I(St,{value:y,whitelist:p,children:t})})})},Rt={spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},typography:{fontFamily:'"Helvetica Neue", sans-serif',fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.75rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},shadows:{sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1)"},animation:{fast:"150ms ease-in-out",normal:"200ms ease-in-out",slow:"300ms ease-in-out"}},At={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#f3f4f6",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderHover:"#d1d5db",text:"#111827",textSecondary:"#374151",textMuted:"#6b7280",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},It={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#171717",background:"#141414",surface:"#1e1e1e",surfaceHover:"#2a2a2a",border:"#2d2d2d",borderHover:"#3a3a3a",text:"#ffffff",textSecondary:"#888888",textMuted:"#666666",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},$e=(t="light")=>({mode:t,...Rt,colors:t==="light"?At:It});function H(t,e){const a=t.replace("#",""),r=Math.max(0,Math.round(parseInt(a.substring(0,2),16)*(1-e))),n=Math.max(0,Math.round(parseInt(a.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(a.substring(4,6),16)*(1-e)));return`#${r.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function Tt(t,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??H(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??H(e?.shell??"#141414",.55),cardBg:e?.cardBg??"#1e1e1e",inputBg:e?.inputBg??"#171717",hoverBg:e?.hoverBg??"#2a2a2a",textPrimary:e?.textPrimary??"#ffffff",textSecondary:e?.textSecondary??"#888888",inputText:e?.inputText??"#e0e0e0",inputPlaceholder:e?.inputPlaceholder??"#555555",cardBorder:e?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:e?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:e?.buttonBorder??"rgba(255,255,255,0.12)",successBg:e?.successBg??"#0a1f18",successBorder:e?.successBorder??"#1a4a3a",successText:e?.successText??"#6ee7b7",warningBg:e?.warningBg??"#1f1a0d",warningBorder:e?.warningBorder??"#4a3820",warningText:e?.warningText??"#fbbf24",errorBg:e?.errorBg??"#1f0d0d",errorBorder:e?.errorBorder??"#4a2020",errorText:e?.errorText??"#f87171",infoBg:e?.infoBg??"#0d1325",infoBorder:e?.infoBorder??"#2a3a5a",infoText:e?.infoText??"#60a5fa"}}function Pt(t){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#e5e7eb",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fde68a",warningText:"#92400e",errorBg:"#fef2f2",errorBorder:"#fecaca",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function Re(t,e){const a=e?{...t,...e}:t,r=a.dark??!1,n=a.primaryColor,s=a.shell??(r?"#141414":"#ffffff");return{primaryColor:n,dark:r,fontFamily:a.fontFamily??'"Helvetica Neue", sans-serif',appName:a.appName??"Spicenet",logo:a.logo,borderRadius:a.borderRadius??"8px",shell:s,shellBorder:H(s,r?.35:.085),shellInnerBorder:H(s,r?.55:.165),card:a.card??(r?"#1e1e1e":"#f9fafb"),input:r?"#171717":"#ffffff",hover:r?"#2a2a2a":"#f3f4f6",text:a.text??(r?"#ffffff":"#111827"),textMuted:a.textMuted??(r?"#888888":"#6b7280"),inputText:r?"#e0e0e0":"#111827",inputPlaceholder:r?"#555555":"#9ca3af",border:a.border??(r?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:r?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:r?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:r?"#0a1f18":"#d1fae5",successBorder:r?"#1a4a3a":"#6ee7b7",successText:r?"#6ee7b7":"#065f46",warningBg:r?"#1f1a0d":"#fef3c7",warningBorder:r?"#4a3820":"#fde68a",warningText:r?"#fbbf24":"#92400e",errorBg:r?"#1f0d0d":"#fef2f2",errorBorder:r?"#4a2020":"#fecaca",errorText:r?"#f87171":"#dc2626",infoBg:r?"#0d1325":"#dbeafe",infoBorder:r?"#2a3a5a":"#93c5fd",infoText:r?"#60a5fa":"#1e40af"}}const Wt='"IBM Plex Mono", monospace';function Ae(t,e){const a=W(Se)??void 0;return F(()=>{const r=a??{primaryColor:"#EA4B4B"},n={...t?.primaryColor?{primaryColor:t.primaryColor}:{},...t?.fontFamily?{fontFamily:t.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=Re(r,n),{dark:l,primaryColor:o,appName:h}=s,d=$e(l?"dark":"light"),m={...d,colors:{...d.colors,primary:o,primaryHover:`${o}dd`},typography:{...d.typography,fontFamily:s.fontFamily}},c={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText},p=t?.inputVariant?t.inputVariant==="dark":l;return{brand:a,theme:m,dark:l,appName:h,primaryColor:o,dk:c,palette:c,fontFamily:s.fontFamily,monoFont:Wt,inputDark:p,cardBg:p?c.cardBg:"#E9E9E9",cardBorder:p?c.cardBorder:"#C6C6C6",textPrimary:c.textPrimary,textSecondary:c.textSecondary,subtitleText:p?c.textSecondary:"#979AA0"}},[a,t,e])}const Ie="spiceflow-spinner-keyframes";function Nt(){if(typeof document>"u"||document.getElementById(Ie))return;const t=document.createElement("style");t.id=Ie,t.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(t)}const Te=({size:t=16,borderWidth:e=2,color:a="currentColor",style:r})=>{const n=_e(!1);return L(()=>{n.current||(Nt(),n.current=!0)},[]),I("div",{role:"status","aria-label":"Loading",style:{width:`${t}px`,height:`${t}px`,border:`${e}px solid ${a}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...r}})},Ut=({variant:t="primary",size:e="md",loading:a=!1,fullWidth:r=!1,disabled:n,children:s,className:l="",style:o,theme:h,styles:d,dark:m,...c})=>{const{theme:p,dark:u,palette:b}=Ae(d,m),i=h||p,w=m??u,[f,y]=O(!1),[g,B]=O(!1),k=w?b.shell:"white",U=()=>{switch(t){case"primary":return{backgroundColor:d?.button?.backgroundColor||i.colors.primary,color:d?.button?.color||"#ffffff",border:`1px solid ${d?.button?.backgroundColor||i.colors.primary}`};case"secondary":return{backgroundColor:i.colors.secondary,color:i.colors.text,border:`1px solid ${i.colors.border}`};case"success":return{backgroundColor:i.colors.success,color:i.colors.text,border:`1px solid ${i.colors.success}`};case"error":return{backgroundColor:i.colors.error,color:i.colors.text,border:`1px solid ${i.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:i.colors.textSecondary,border:`1px solid ${i.colors.border}`};case"outline":{const v=d?.button?.backgroundColor||i.colors.primary,A=d?.button?.color||(w?"#ffffff":"#0e0d0b"),T=d?.button?.borderColor||(w?`${i.colors.primary}88`:"#0e0d0b"),P=n||a,Pe=w?"1px":"1.5px",We=d?.button?.disabledBackgroundColor||`${v}88`,Ne=d?.button?.disabledColor||A;return{height:"56px",backgroundColor:P?We:g?`${v}cc`:f?`${v}ee`:v,color:P?Ne:A,border:`${Pe} solid ${T}`,borderRadius:d?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:P?.78:1,transform:P?"none":g?"scale(0.98)":f?"translateY(-2px)":"none",boxShadow:P?`3px 3px 0px ${k}, 4px 4px 0px ${T}`:g?`2px 2px 0px ${T}`:f?`5px 5px 0px ${k}, 6px 6px 0px ${T}`:`3px 3px 0px ${k}, 4px 4px 0px ${T}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},Y=()=>{if(t==="outline")return{};switch(e){case"sm":return{padding:`${i.spacing.sm} ${i.spacing.md}`,fontSize:i.typography.fontSize.sm};case"md":return{padding:`${i.spacing.md} ${i.spacing.lg}`,fontSize:i.typography.fontSize.base};case"lg":return{padding:`${i.spacing.lg} ${i.spacing.xl}`,fontSize:i.typography.fontSize.lg};default:return{}}},M={borderRadius:d?.button?.borderRadius||i.borderRadius.md,fontWeight:d?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:d?.button?.fontFamily||i.typography.fontFamily,fontSize:d?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:n||a?"not-allowed":"pointer",opacity:(n||a)&&t!=="outline"?.6:1,width:r?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...U(),...Y(),...d?.button?.fontSize&&{fontSize:d.button.fontSize}},_=n||a;return Ue("button",{type:c.type??"button","data-spiceflow-focus":!0,"aria-busy":a||void 0,"aria-disabled":_||void 0,style:{...M,...o},className:l,disabled:_,onMouseEnter:v=>{y(!0),c.onMouseEnter?.(v)},onMouseLeave:v=>{y(!1),B(!1),c.onMouseLeave?.(v)},onMouseDown:v=>{B(!0),c.onMouseDown?.(v)},onMouseUp:v=>{B(!1),c.onMouseUp?.(v)},...c,children:[a&&I(Te,{size:16}),s]})};export{re as A,Ut as B,at as C,$t as D,Ce as E,Re as F,Tt as G,Pt as H,ye as R,Te as S,it as a,$ as b,$e as c,pe as d,te as e,R as f,J as g,st as h,he as i,D as j,ot as k,nt as l,lt as m,gt as n,ve as o,be as p,Ee as q,S as r,ut as s,ct as t,Ae as u,E as v,yt as w,Bt as x,ne as y,de as z};
@@ -0,0 +1,2 @@
1
+ "use client";
2
+ "use strict";var Ae=Object.create;var re=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,Pe=Object.prototype.hasOwnProperty;var Ne=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Te(e))!Pe.call(t,n)&&n!==a&&re(t,n,{get:()=>e[n],enumerable:!(r=Ie(e,n))||r.enumerable});return t};var T=(t,e,a)=>(a=t!=null?Ae(We(t)):{},Ne(e||!t||!t.__esModule?re(a,"default",{value:t,enumerable:!0}):a,t));const W=require("react/jsx-runtime"),b=require("react"),R=require("@spicenet-io/spiceflow-core"),x=require("viem"),Ue=require("viem/actions"),_e=require("@tanstack/react-query"),S=require("@privy-io/react-auth"),Y=require("@dynamic-labs/sdk-react-core"),ae=require("wagmi");var G=typeof document<"u"?document.currentScript:null;function j(t,e){return!t||!e?!1:x.isAddress(t)&&x.isAddress(e)?x.getAddress(t)===x.getAddress(e):t.toLowerCase()===e.toLowerCase()}const ne=[{constant:!0,inputs:[],name:"name",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_spender",type:"address"},{name:"_value",type:"uint256"}],name:"approve",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transferFrom",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"}],name:"balanceOf",outputs:[{name:"balance",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{constant:!0,inputs:[],name:"symbol",outputs:[{name:"",type:"string"}],payable:!1,stateMutability:"view",type:"function"},{constant:!1,inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],payable:!1,stateMutability:"nonpayable",type:"function"},{constant:!0,inputs:[{name:"_owner",type:"address"},{name:"_spender",type:"address"}],name:"allowance",outputs:[{name:"",type:"uint256"}],payable:!1,stateMutability:"view",type:"function"},{payable:!0,stateMutability:"payable",type:"fallback"},{anonymous:!1,inputs:[{indexed:!0,name:"owner",type:"address"},{indexed:!0,name:"spender",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,name:"from",type:"address"},{indexed:!0,name:"to",type:"address"},{indexed:!1,name:"value",type:"uint256"}],name:"Transfer",type:"event"}],Me="0xcA11bde05977b3631167028862bE2a173976CA11",Oe={4114:"0x860aFc632a6D625B95d8B96f39ECC48E988c6962"},Fe=new Set([5115]);function Le(t){const e=Oe[t.id]??(Fe.has(t.id)?void 0:Me);return x.defineChain({id:t.id,name:t.name,nativeCurrency:t.nativeCurrency,rpcUrls:{default:{http:[t.rpcUrl]}},blockExplorers:{default:{name:t.displayName,url:t.blockExplorer}},testnet:t.network==="testnet",...e?{contracts:{multicall3:{address:e}}}:{}})}const je=[1,8453,42161,4114,11155111,421614,84532,5115,123420001114,688688,688689],D=Object.fromEntries(je.map(t=>R.getChainMeta(t)).filter(t=>t!=null).map(t=>[t.id,{...t,viemChain:Le(t),supportedTokens:R.getTokensForChain(t.id)}])),De=D;let se={};const X=new Map,oe=t=>{se={...t||{}},X.clear()},Q=t=>{const e=se[t];return e&&typeof e=="string"&&e.length>0?e:D[t]?.rpcUrl},P=t=>D[t],V=t=>{const e=R.getChainMeta(t);return e?.displayName||e?.name||`Chain ${t}`},ze=t=>{const e=R.getDelegateContract(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);return e},qe=(t,e,a)=>{const r=P(t);return r?.blockExplorer?`${r.blockExplorer}/tx/${e}`:"#"};async function Je(t,e){const a=`0x${e.toString(16)}`;try{await t.request({method:"wallet_switchEthereumChain",params:[{chainId:a}]});return}catch(n){if(!(n?.code===4902||typeof n?.message=="string"&&n.message.includes("Unrecognized chain ID")))throw n}const r=P(e);if(!r)throw new Error(`Cannot add unknown chain ${e} to wallet`);await t.request({method:"wallet_addEthereumChain",params:[{chainId:a,chainName:r.name||`Chain ${e}`,nativeCurrency:r.nativeCurrency||{name:"ETH",symbol:"ETH",decimals:18},rpcUrls:[Q(e)||r.rpcUrl],blockExplorerUrls:r.blockExplorer?[r.blockExplorer]:void 0}]})}const ie=t=>{const e=P(t);if(!e)throw new Error(`Unsupported chain ID: ${t}`);const a=Q(t);if(!a)throw new Error(`No RPC URL configured for chain ID: ${t}`);const r=`${t}:${a}`,n=X.get(r);if(n)return n;const s=x.createPublicClient({chain:e.viemChain,transport:x.http(a,{timeout:15e3,retryCount:2,retryDelay:300}),batch:{multicall:{wait:16}}});return X.set(r,s),s},He=()=>{const t={};return Object.values(D).forEach(e=>{t[e.id]={name:e.name,moralisName:e.moralisId||"",chain:e.viemChain,rpcUrl:Q(e.id)||e.rpcUrl}}),t},Ye=(t,e=[])=>{const a=P(t);if(!a)return[];const r=[];if(![11155111,421614,84532,688689].includes(t)){const s=e.find(d=>d.chainId===t&&d.isNative);s?r.push(s):r.push({address:R.ZERO_ADDRESS,name:a.nativeCurrency.name,symbol:a.nativeCurrency.symbol,decimals:a.nativeCurrency.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:void 0,isNative:!0,chainId:t})}if(!a.supportedTokens)return r;const n=r.some(s=>s.isNative);return a.supportedTokens.forEach(s=>{if(n&&R.isNativeToken(s.address))return;const d=e.find(o=>o.chainId===t&&j(o.address,s.address));d?r.push(d):r.push({address:s.address,name:s.name,symbol:s.symbol,decimals:s.decimals,balance:BigInt(0),balanceFormatted:0,balanceUsd:0,logoURI:s.logo,isNative:!1,chainId:t})}),r},Ge=async(t,e)=>{const a=P(t);if(!a)throw new Error(`Unsupported chain ID: ${t}`);const r=e.toLowerCase();if(R.isNativeToken(r)){if(!a.nativeCurrency?.decimals)throw new Error(`Native currency decimals not configured for chain ${t}`);return a.nativeCurrency.decimals}if(a.supportedTokens){const n=a.supportedTokens.find(s=>j(s.address,r));if(n)return n.decimals}try{if(!x.isAddress(e,{strict:!1}))throw new Error(`Invalid token address: ${e}`);const n=x.getAddress(e),s=ie(t),d=await Ue.readContract(s,{address:n,abi:ne,functionName:"decimals"});return Number(d)}catch{throw new Error(`Could not determine decimals for token ${e} on chain ${t}`)}};class v extends Error{constructor(e,a,r={}){super(a),this.code=e,this.context=r,this.name="SpiceflowError",Error.captureStackTrace&&Error.captureStackTrace(this,v)}}function K(t){return t instanceof v}const Xe=["user rejected","user denied","user cancelled","rejected the request","action_rejected","4001"];function ce(t){if(!t)return"";if(typeof t=="string")return t;const e=t,a=e.message||e.reason||"",r=e.details||"";return`${a} ${r}`.trim()}const de=t=>{if(K(t))return t.code==="WALLET_REJECTED";const e=ce(t).toLowerCase();return Xe.some(a=>e.includes(a))},Qe=(t,e="Something went wrong. Please try again.")=>de(t)?"Transaction was rejected.":K(t)?t.message||e:ce(t)||e;function Ve(t,e){const a=e.match(/Output amount (\d+) is insufficient after fees (\d+) on chain (\d+)/);if(!a)return e;const[,r,n,s]=a,d=Number(s),o=BigInt(r),h=BigInt(n);let l;for(const f of t.intents){const y=f.chainBatches.find(g=>g.chainId===d);if(y){l=y;break}}const m=l?.tokenTransfers.find(f=>f.from==="escrow"&&j(f.to,t.user)&&!R.isNativeToken(f.token)),c=V(d);if(!m)return`Amount is too small to cover the estimated fee on ${c}.`;const p=R.getTokenByAddress(m.token,d),u=p?.decimals??18,E=p?.symbol??"tokens",i=x.formatUnits(o,u),w=x.formatUnits(h,u);return`Amount is too small to cover the estimated fee on ${c}. Amount: ${i} ${E}. Estimated fee: ${w} ${E}.`}const le=typeof process<"u"&&process.env?.NEXT_PUBLIC_RELAYER_API_URL||"https://tx-submission-api.spicenet.io";function z(t,e){return typeof e=="bigint"?e.toString():e}function B(t,e){if(!t)return e;const a=t.error;return(typeof t.message=="string"?t.message:"")||(a&&typeof a=="object"&&"message"in a&&typeof a.message=="string"?a.message:"")||(typeof a=="string"?a:"")||e}async function Ke(t){try{return await t.json()}catch{return null}}function Ze(t){return(Array.isArray(t?.balances)?t.balances:[]).flatMap(e=>{if(!e||typeof e!="object")return[];const a=e;return[{receiptToken:typeof a.receiptToken=="string"?a.receiptToken:void 0,tokenName:String(a.tokenName??""),balanceAvailable:String(a.balanceAvailable??"0"),chainTokens:Array.isArray(a.chainTokens)?a.chainTokens.filter(r=>typeof r=="string"):a.chainTokens&&typeof a.chainTokens=="object"?a.chainTokens:a.chainTokenConfig&&typeof a.chainTokenConfig=="object"?a.chainTokenConfig:void 0,decimals:typeof a.decimals=="number"?a.decimals:void 0,balanceUsd:typeof a.balanceUsd=="number"||typeof a.balanceUsd=="string"?a.balanceUsd:null}]})}class et{constructor(){this.baseUrl=le}setBaseUrl(e){this.baseUrl=e}getBaseUrl(){return this.baseUrl}async createAction(e){const a=`${this.baseUrl}/actions`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,z)}),n=await r.json();if(!r.ok||n.success===!1)throw new v("RELAYER_ERROR",B(n,`Relayer API error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:"/actions"});return n}async estimateActionFees(e){const a=`${this.baseUrl}/actions/fees/estimate`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,z)}),n=await r.json();if(!r.ok||!n.success||!n.data?.feeEstimate){const s=B(n,`Relayer fee estimate error: ${r.status}`);throw new v("RELAYER_ERROR",Ve(e,s),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:"/actions/fees/estimate"})}return n.data.feeEstimate}async estimateBatchGas(e){const a=`${this.baseUrl}/actions/gas/estimate`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,z)}),n=await r.json();if(!r.ok||!n.success||!n.data?.gasFee)throw new v("RELAYER_ERROR",B(n,`Relayer gas estimate error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:"/actions/gas/estimate"});return{gasFee:BigInt(n.data.gasFee),gasQuoteSource:n.data.gasQuoteSource}}async executeStep(e,a,r,n){const s=`${this.baseUrl}/actions/${e}/intents/${a}/steps/${r}`,d=`/actions/${e}/intents/${a}/steps/${r}`,o=1e4,h=new Promise((c,p)=>setTimeout(()=>p(new v("RELAYER_EXECUTE_ERROR",`Execute step request timed out after ${o/1e3}s`,{actionId:e,intentIndex:a,stepIndex:r,endpoint:d})),o)),l=await Promise.race([fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)}),h]),m=await l.json();if(!l.ok||m.success===!1)throw new v("RELAYER_EXECUTE_ERROR",B(m,`Execute step error: ${l.status}`),{httpStatus:l.status,responseBody:JSON.stringify(m),endpoint:d,actionId:e});if(m?.status==="error"||m?.status==="reverted"){const c=B(m,""),p=c?`: ${c}`:"";throw new v("RELAYER_EXECUTE_ERROR",`Step ${r} previously ${m.status}${p}`,{httpStatus:l.status,responseBody:JSON.stringify(m),endpoint:d,actionId:e,intentIndex:a,stepIndex:r,stepStatus:m.status})}return{success:!0,transactionHash:m.transactionHash}}async checkStepStatus(e,a){const r=e.split("/"),n=r[0],s=r.length>=2?r[1]:"0",d=`${this.baseUrl}/actions/${n}/intents/${s}/steps/${a}`,o=await fetch(d),h=await o.json();if(!o.ok||h.success===!1)throw new v("RELAYER_STATUS_ERROR",B(h,`Intent step status check failed: ${o.status}`),{httpStatus:o.status,responseBody:JSON.stringify(h),endpoint:d,intentId:e});return{success:!0,data:{status:h.status==="error"?"reverted":h.status,transactionHash:h.txid,error:B(h,"")}}}async createWallet(e,a){const r=`${this.baseUrl}/wallets/${e}`,n=await fetch(r,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(a)}),s=await n.json();if(!n.ok||s.success===!1)throw new v("RELAYER_ERROR",B(s,`Create wallet error: ${n.status}`),{httpStatus:n.status,responseBody:JSON.stringify(s),endpoint:`/wallets/${e}`});return s}async getWallet(e){const a=`${this.baseUrl}/wallets/${e}`,r=await fetch(a),n=await r.json();if(!r.ok||n.success===!1)throw new v("RELAYER_ERROR",B(n,`Get wallet error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:`/wallets/${e}`});return n}async createWithdrawal(e){const a=`${this.baseUrl}/withdrawals`,r=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e,z)}),n=await r.json();if(!r.ok||n.success===!1)throw new v("RELAYER_ERROR",B(n,`Create withdrawal error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:"/withdrawals"});return n}async getWithdrawal(e){const a=`${this.baseUrl}/withdrawals/${e}`,r=await fetch(a),n=await r.json();if(!r.ok||n.success===!1)throw new v("RELAYER_ERROR",B(n,`Get withdrawal error: ${r.status}`),{httpStatus:r.status,responseBody:JSON.stringify(n),endpoint:`/withdrawals/${e}`});return n}async getRollupTimestamp(){const e=`${this.baseUrl}/time`,a=await fetch(e),r=await a.json();if(!a.ok||r.success===!1)throw new v("RELAYER_ERROR",B(r,`Get rollup timestamp error: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(r),endpoint:"/time"});return r}}const I=new et;async function tt(t){const e=`${I.getBaseUrl()}/wallets/${t}/balance`,a=await fetch(e,{cache:"no-store"}),r=await Ke(a);if(!a.ok||r?.success===!1)throw new v("RELAYER_ERROR",B(r,`Unable to verify Spice balance: ${a.status}`),{httpStatus:a.status,responseBody:JSON.stringify(r),endpoint:`/wallets/${t}/balance`});return Ze(r)}const Z=new Map;async function ee(t,e){const a=t.toLowerCase(),r=Z.get(a);if(r)return r;const n=(async()=>{try{await I.getWallet(t);return}catch{}const{unix_timestamp:s}=await I.getRollupTimestamp(),d=`I am creating a new smart wallet and adding an admin wallet ethereum:0x${t.slice(2).toLowerCase()}. Nonce: ${s}`,o=await e(d),h=typeof o=="string"?o:o.signature;if(!h)throw new Error("Wallet returned no smart wallet signature");await I.createWallet(t,{timestamp:s,signature:h})})();Z.set(a,n);try{await n}finally{Z.delete(a)}}const rt=(t,e)=>{const a=n=>e?e(n):V(n),r=[];return t.forEach((n,s)=>{const d=n.calls&&n.calls.length>0,o=n.tokenTransfers&&n.tokenTransfers.length>0;!d&&!o||r.push({stepId:s,status:s===0?"processing":"pending",chainId:n.chainId,chainName:a(n.chainId),description:"Processing transaction"})}),r},te=t=>{if(!t)return!1;const e=t.connector;if(!e)return!1;if(e.isEmbeddedWallet===!0)return!0;const a=(e.key||e.connectorKey||"").toLowerCase();if(a.includes("embedded")||a.includes("turnkey"))return!0;const r=(e.name||t.walletName||"").toLowerCase();return!!(r.includes("embedded")||r.includes("turnkey"))},q=t=>(t?.connectedWallets||[]).find(e=>te(e))||(te(t?.primaryWallet)?t.primaryWallet:null),at=t=>(t?.connectedWallets||[]).find(e=>e?.address&&e?.connector&&!te(e))||null,ue=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getWalletClient=="function"){const a=e===void 0?[void 0]:[String(e),e,void 0];let r=null;for(const n of a)try{const s=await t.getWalletClient(n);if(s)return s}catch(s){r=s}if(r)throw r}if(typeof t.getEthereumProvider=="function"){const a=await t.getEthereumProvider(),r=e?P(e)?.viemChain:void 0;return x.createWalletClient({account:t.address,chain:r,transport:x.custom(a)})}throw new Error("Wallet client not available")},fe=async(t,e)=>{if(!t?.address)throw new Error("Wallet not available");if(typeof t.getEthereumProvider=="function")return t.getEthereumProvider();const a=await ue(t,e);return{request:r=>a.request(r)}},nt=(t,e)=>({address:t?.address||e.address,chainId:Number(t?.chainId??e.chainId),contractAddress:t?.contractAddress||t?.delegate||e.contractAddress,nonce:BigInt(t?.nonce??e.nonce),r:t?.r,s:t?.s,yParity:(()=>{if(typeof t?.yParity=="number")return t.yParity;const a=Number(t?.v??27);return Number.isFinite(a)?a>=27?a-27:a:0})()}),k=t=>t?.address?{address:t.address,wallet:t,getWalletClient:e=>ue(t,e),getEthereumProvider:e=>fe(t,e)}:null,pe=()=>{const t=b.useContext(N),{address:e,connector:a}=ae.useAccount();let r=null,n=null;try{r=S.useWallets(),{user:n}=S.usePrivy()}catch{r=null,n=null}let s=null;try{s=Y.useDynamicContext()}catch{s=null}const d=r?.wallets||[],o=S.getEmbeddedConnectedWallet(d),h=o?.address?.toLowerCase(),l=d.find(g=>g.connectorType!=="embedded"&&g.address?.toLowerCase()!==h),m=q(s),c=at(s),p=e&&a?{address:e,connector:a,getEthereumProvider:()=>a.getProvider()}:null,u=t?.provider,E=k(o)||k(m),i=k(p)||k(l)||k(c)||null,w=u==="dynamic"?k(m):u==="privy"?k(o):E,f=u==="dynamic"?k(p)||k(c):u==="privy"?k(p)||k(l):i,y=u==="dynamic"?w?.address:u==="privy"?w?.address||n?.wallet?.address:E?.address||n?.wallet?.address;return{embeddedWallet:w,externalWallet:f,embeddedAddress:y,externalAddress:f?.address}},st=()=>{const[t,e]=b.useState(!1);let a=null,r=null;try{a=Y.useDynamicContext()}catch(u){r=u instanceof Error?u.message:String(u)}if(b.useEffect(()=>{e(!0)},[]),r)return{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:"dynamic",actions:{signAuthorization:async()=>{throw new Error("Dynamic context not available")},signMessage:async()=>{throw new Error("Dynamic context not available")},getEthereumProvider:async()=>{throw new Error("Dynamic context not available")}}};const{user:n,primaryWallet:s,connectedWallets:d}=a||{},o=q({connectedWallets:d,primaryWallet:s})||s,h=!!n,l=o?.address,m={isReady:t&&!!a,isAuthenticated:h,isConnected:h&&!!l,address:l,provider:"dynamic"},c=async u=>{if(!o)throw new Error("Dynamic embedded wallet not available");const{isEthereumWallet:E}=await import("@dynamic-labs/ethereum");if(!E(o))throw new Error("Embedded wallet is not an Ethereum wallet");const i=await o.getWalletClient();if(!i)throw new Error("Dynamic wallet client not available");return{signature:await i.signMessage({message:u,account:o.address})}},p=async()=>{if(!l)throw new Error("Dynamic embedded wallet not available");await ee(l,c)};return{...m,actions:{signAuthorization:async u=>{if(!o)throw new Error("Dynamic embedded wallet not available");await p();const{isEthereumWallet:E}=await import("@dynamic-labs/ethereum");if(!E(o))throw new Error("Embedded wallet is not an Ethereum wallet");const i=o.connector,w={address:o.address,chainId:u.chainId,contractAddress:u.contractAddress,nonce:u.nonce},f={address:u.contractAddress,chainId:u.chainId,nonce:u.nonce},y=typeof i?.getWaasWalletClient=="function"?await i.getWaasWalletClient():null;if(y&&typeof y.signRawMessage=="function"){const{hashAuthorization:g}=await import("viem/experimental"),{parseSignature:$}=await import("viem"),A={address:u.contractAddress,chainId:u.chainId,nonce:u.nonce},O=i.getSignedSessionId,H=typeof O=="function"?await O.call(i):void 0,F=i.getAuthToken,L=typeof F=="function"?F.call(i):void 0,C=await y.signRawMessage({accountAddress:o.address,authToken:L,context:{eip7702Auth:A},message:g(A).slice(2),signedSessionId:H}),U=$(C);return{address:w.contractAddress,chainId:w.chainId,contractAddress:w.contractAddress,nonce:BigInt(w.nonce),r:U.r,s:U.s,yParity:Number(U.yParity)}}if(typeof i?.signAuthorization=="function"){typeof i.switchNetwork=="function"&&await i.switchNetwork({networkChainId:u.chainId});const g=await i.signAuthorization(f);return nt(g,w)}throw new Error("Dynamic embedded wallet does not support EIP-7702 authorization. Ensure @dynamic-labs packages are v4.15+.")},signMessage:async u=>{if(!(typeof u=="object"&&"raw"in u))return c(u);if(await p(),!o)throw new Error("Dynamic embedded wallet not available");const E=await o.getWalletClient();if(!E)throw new Error("Dynamic wallet client not available");return{signature:await E.signMessage({message:{raw:u.raw},account:o.address})}},getEthereumProvider:async()=>{if(!o)throw new Error("Dynamic embedded wallet not available");const{isEthereumWallet:u}=await import("@dynamic-labs/ethereum");if(!u(o))throw new Error("Embedded wallet is not an Ethereum wallet");return fe(o)}}}},me=()=>{const t=b.useContext(N),e=t?.mode||"7702";let a=null,r=null;try{a=S.useWallets(),{user:r}=S.usePrivy()}catch{a=null}const n=S.getEmbeddedConnectedWallet(a?.wallets||[])?.address,s=r?.wallet?.address;let d=null;try{d=Y.useDynamicContext()}catch{d=null}const o=(q(d)||d?.primaryWallet)?.address;if(!(!t||e!=="7702"))return t.provider==="privy"?n??s:t.provider==="dynamic"?o:n??s??o},ot=()=>{const t=b.useContext(N)?.mode,{isConnected:e,address:a}=ae.useAccount();let r=null,n=null,s=null,d=null,o=null;try{r=S.usePrivy(),n=S.useSign7702Authorization(),s=S.useSignMessage(),d=S.useWallets()}catch(f){o=f instanceof Error?f.message:String(f)}if(o)return t==="ondemand"&&e&&a?{isReady:!0,isAuthenticated:!0,isConnected:!0,address:a,provider:"privy",actions:{signAuthorization:async()=>{throw new Error("Not available in ondemand mode")},signMessage:async()=>{throw new Error("Not available in ondemand mode")},getEthereumProvider:async()=>{throw new Error("Not available in ondemand mode")}}}:{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("Privy not available")},signMessage:async()=>{throw new Error("Privy not available")},getEthereumProvider:async()=>{throw new Error("Privy not available")}}};const{ready:h=!1,authenticated:l=!1}=r||{},m=me(),c=S.getEmbeddedConnectedWallet(d?.wallets||[]),p=m||c?.address,u=!!p&&!!c,E={isReady:t==="ondemand"?!0:h,isAuthenticated:t==="ondemand"?!0:l||u,isConnected:t==="ondemand"?e&&!!a||h&&(l||u)&&u:h&&u,address:t==="ondemand"&&!m&&e?a:p,provider:"privy"},i=async f=>{if(s)try{return{signature:(await s.signMessage({message:f})).signature}}catch(A){if(!c)throw A}if(!c)throw new Error("Privy sign message not available");const y=await c.getEthereumProvider(),{createWalletClient:g,custom:$}=await import("viem");return{signature:await g({account:c.address,transport:$(y)}).signMessage({account:c.address,message:f})}},w=async()=>{if(!p)throw new Error("Embedded wallet not available for smart wallet setup");await ee(p,i)};return{...E,actions:{signAuthorization:async f=>{if(!n)throw new Error("Privy sign authorization not available");try{await w();const y=await n.signAuthorization({contractAddress:f.contractAddress,chainId:f.chainId,nonce:f.nonce},{address:p});return delete y.v,y}catch(y){const g=y?.message||String(y);throw g.includes("not configured")||g.includes("chain")?new Error(`Chain ${f.chainId} is not configured in PrivyProvider. Add this chain to your Privy dashboard or supportedChainIds.`):y}},signMessage:async f=>{if(typeof f=="object"&&"raw"in f){if(await w(),!c)throw new Error("Embedded wallet not available for raw signing");const y=await c.getEthereumProvider(),{createWalletClient:g,custom:$}=await import("viem");return{signature:await g({account:c.address,transport:$(y)}).signMessage({account:c.address,message:f})}}return i(f)},getEthereumProvider:async()=>{if(!c)throw new Error("Embedded wallet not available");return c.getEthereumProvider()}}}},he=()=>{const t=b.useContext(N)?.provider,e=ot(),a=st();return t==="privy"?e:t==="dynamic"?a:{isReady:!1,isAuthenticated:!1,isConnected:!1,provider:null,actions:{signAuthorization:async()=>{throw new Error("No wallet provider available")},signMessage:async()=>{throw new Error("No wallet provider available")},getEthereumProvider:async()=>{throw new Error("No wallet provider available")}}}},it=typeof process<"u"&&process.env?.NEXT_PUBLIC_PORTAL_API_URL||typeof{url:typeof document>"u"?require("url").pathToFileURL(__filename).href:G&&G.tagName.toUpperCase()==="SCRIPT"&&G.src||new URL("Button-DSsTibdR.js",document.baseURI).href}<"u"&&void 0||"https://portal-backend.spicenet.io/api/v1",ye=t=>t.replace(/\/+$/,"");function ge({walletAddress:t,campaignId:e,campaignGroup:a,partnerId:r,apiBaseUrl:n=it,enabled:s=!0,staleTime:d=5*60*1e3,refetchInterval:o=!1}={}){const{isAuthenticated:h,isConnected:l}=he(),{externalAddress:m}=pe(),c=t??m,p=typeof c=="string"?c.toLowerCase():void 0,u=s&&h&&l&&!!m&&!!p&&x.isAddress(p)&&!!e&&!!a&&!!r,E=b.useMemo(()=>["partner-whitelist","check",p,e,a,r,ye(n)],[p,e,a,r,n]),i=_e.useQuery({queryKey:E,enabled:u,staleTime:d,refetchInterval:o,queryFn:async()=>{if(!p||!x.isAddress(p))throw new Error("A valid wallet address is required");if(!e||!a||!r)throw new Error("campaignId, campaignGroup, and partnerId are required");const w=new URLSearchParams({walletAddress:p,campaignId:e,campaignGroup:a,partnerId:r}),f=await fetch(`${ye(n)}/portal/mainnet/whitelist/check?${w.toString()}`,{cache:"no-store"});if(!f.ok)throw new Error(`Failed to check whitelist: ${f.status}`);return await f.json()}});return{isWhitelisted:i.data?.isWhitelisted??!1,whitelistCheck:i.data,checkedWalletAddress:p,externalWalletAddress:m,isExternalWalletConnected:!!m,isWhitelistCheckEnabled:u,...i}}const we="spiceflow-mode",be=()=>{if(typeof window>"u")return null;try{const t=window.localStorage.getItem(we);return t==="embedded"?"7702":t==="external"?"ondemand":null}catch{return null}},ct=t=>{if(!(typeof window>"u"))try{window.localStorage.setItem(we,t==="7702"?"embedded":"external")}catch{}},dt=()=>be()!==null,Ee=b.createContext(null),lt=["__spicenet_whitelist_blocked__"],N=b.createContext(null),ut=({children:t,value:e,whitelist:a})=>{const r=ge(a===!1?{enabled:!1}:a),n=r.isWhitelistCheckEnabled&&r.isSuccess,s=r.isWhitelistCheckEnabled&&!r.isWhitelisted,d=b.useMemo(()=>({...e,allowedTokens:s?lt:e.allowedTokens,mode:s?"ondemand":e.mode,isUserWhitelisted:n?r.isWhitelisted:null,isWhitelistChecking:r.isWhitelistCheckEnabled&&(r.isLoading||r.isFetching),isWhitelistGateActive:s,whitelistCheck:r.whitelistCheck}),[e,s,n,r.isWhitelisted,r.isWhitelistCheckEnabled,r.isLoading,r.isFetching,r.whitelistCheck]);return W.jsx(N.Provider,{value:d,children:t})},ft=({children:t,provider:e,supportedChainIds:a,allowedTokens:r,network:n="testnet",mode:s="7702",skipFlow:d=[],nativeChainId:o,appName:h="Spicenet",apiUrl:l,theme:m,rpcOverrides:c,whitelist:p})=>{b.useEffect(()=>{if(!l)return;const g=I.getBaseUrl();return I.setBaseUrl(l),()=>I.setBaseUrl(g)},[l]),b.useEffect(()=>(oe(c),()=>oe(void 0)),[c]);const u=a??R.getChainIdsByNetwork(n),E=m??null,[i,w]=b.useState(()=>be()??s),f=b.useCallback(g=>{w(g),ct(g)},[]),y=b.useMemo(()=>({provider:e,supportedChainIds:u,allowedTokens:r,skipFlow:d,mode:i,setMode:f,network:n,nativeChainId:o,appName:h,apiUrl:l,rpcOverrides:c,isUserWhitelisted:null,isWhitelistChecking:!1,isWhitelistGateActive:!1}),[e,u,r,d,i,f,n,o,h,l,c]);return W.jsx(Ee.Provider,{value:E,children:W.jsx(N.Provider,{value:y,children:W.jsx(ut,{value:y,whitelist:p,children:t})})})},pt={spacing:{xs:"0.25rem",sm:"0.5rem",md:"1rem",lg:"1.5rem",xl:"2rem"},borderRadius:{sm:"0.25rem",md:"0.5rem",lg:"0.75rem",full:"9999px"},typography:{fontFamily:'"Helvetica Neue", sans-serif',fontSize:{xs:"0.75rem",sm:"0.875rem",base:"1rem",lg:"1.125rem",xl:"1.25rem","2xl":"1.5rem","3xl":"1.75rem"},fontWeight:{normal:400,medium:500,semibold:600,bold:700}},shadows:{sm:"0 1px 2px 0 rgb(0 0 0 / 0.05)",md:"0 4px 6px -1px rgb(0 0 0 / 0.1)",lg:"0 10px 15px -3px rgb(0 0 0 / 0.1)"},animation:{fast:"150ms ease-in-out",normal:"200ms ease-in-out",slow:"300ms ease-in-out"}},mt={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#f3f4f6",background:"#ffffff",surface:"#f9fafb",surfaceHover:"#f3f4f6",border:"#e5e7eb",borderHover:"#d1d5db",text:"#111827",textSecondary:"#374151",textMuted:"#6b7280",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},ht={primary:"#EA4B4B",primaryHover:"#E43838",secondary:"#171717",background:"#141414",surface:"#1e1e1e",surfaceHover:"#2a2a2a",border:"#2d2d2d",borderHover:"#3a3a3a",text:"#ffffff",textSecondary:"#888888",textMuted:"#666666",success:"#10b981",error:"#ef4444",warning:"#f59e0b",info:"#3b82f6"},ve=(t="light")=>({mode:t,...pt,colors:t==="light"?mt:ht});function J(t,e){const a=t.replace("#",""),r=Math.max(0,Math.round(parseInt(a.substring(0,2),16)*(1-e))),n=Math.max(0,Math.round(parseInt(a.substring(2,4),16)*(1-e))),s=Math.max(0,Math.round(parseInt(a.substring(4,6),16)*(1-e)));return`#${r.toString(16).padStart(2,"0")}${n.toString(16).padStart(2,"0")}${s.toString(16).padStart(2,"0")}`}function yt(t,e){return{shell:e?.shell??"#141414",shellBorder:e?.shellBorder??J(e?.shell??"#141414",.35),shellInnerBorder:e?.shellInnerBorder??J(e?.shell??"#141414",.55),cardBg:e?.cardBg??"#1e1e1e",inputBg:e?.inputBg??"#171717",hoverBg:e?.hoverBg??"#2a2a2a",textPrimary:e?.textPrimary??"#ffffff",textSecondary:e?.textSecondary??"#888888",inputText:e?.inputText??"#e0e0e0",inputPlaceholder:e?.inputPlaceholder??"#555555",cardBorder:e?.cardBorder??"rgba(255,255,255,0.08)",inputBorder:e?.inputBorder??"rgba(255,255,255,0.10)",buttonBorder:e?.buttonBorder??"rgba(255,255,255,0.12)",successBg:e?.successBg??"#0a1f18",successBorder:e?.successBorder??"#1a4a3a",successText:e?.successText??"#6ee7b7",warningBg:e?.warningBg??"#1f1a0d",warningBorder:e?.warningBorder??"#4a3820",warningText:e?.warningText??"#fbbf24",errorBg:e?.errorBg??"#1f0d0d",errorBorder:e?.errorBorder??"#4a2020",errorText:e?.errorText??"#f87171",infoBg:e?.infoBg??"#0d1325",infoBorder:e?.infoBorder??"#2a3a5a",infoText:e?.infoText??"#60a5fa"}}function gt(t){return{shell:"#ffffff",shellBorder:"#E9E9E9",shellInnerBorder:"#D5D5D5",cardBg:"#f9fafb",inputBg:"#ffffff",hoverBg:"#f3f4f6",textPrimary:"#111827",textSecondary:"#6b7280",inputText:"#111827",inputPlaceholder:"#9ca3af",cardBorder:"#e5e7eb",inputBorder:"#d1d5db",buttonBorder:"#0e0d0b",successBg:"#d1fae5",successBorder:"#6ee7b7",successText:"#065f46",warningBg:"#fef3c7",warningBorder:"#fde68a",warningText:"#92400e",errorBg:"#fef2f2",errorBorder:"#fecaca",errorText:"#dc2626",infoBg:"#dbeafe",infoBorder:"#93c5fd",infoText:"#1e40af"}}function xe(t,e){const a=e?{...t,...e}:t,r=a.dark??!1,n=a.primaryColor,s=a.shell??(r?"#141414":"#ffffff");return{primaryColor:n,dark:r,fontFamily:a.fontFamily??'"Helvetica Neue", sans-serif',appName:a.appName??"Spicenet",logo:a.logo,borderRadius:a.borderRadius??"8px",shell:s,shellBorder:J(s,r?.35:.085),shellInnerBorder:J(s,r?.55:.165),card:a.card??(r?"#1e1e1e":"#f9fafb"),input:r?"#171717":"#ffffff",hover:r?"#2a2a2a":"#f3f4f6",text:a.text??(r?"#ffffff":"#111827"),textMuted:a.textMuted??(r?"#888888":"#6b7280"),inputText:r?"#e0e0e0":"#111827",inputPlaceholder:r?"#555555":"#9ca3af",border:a.border??(r?"rgba(255,255,255,0.08)":"#e5e7eb"),inputBorder:r?"rgba(255,255,255,0.10)":"#d1d5db",buttonBorder:r?"rgba(255,255,255,0.12)":"#0e0d0b",successBg:r?"#0a1f18":"#d1fae5",successBorder:r?"#1a4a3a":"#6ee7b7",successText:r?"#6ee7b7":"#065f46",warningBg:r?"#1f1a0d":"#fef3c7",warningBorder:r?"#4a3820":"#fde68a",warningText:r?"#fbbf24":"#92400e",errorBg:r?"#1f0d0d":"#fef2f2",errorBorder:r?"#4a2020":"#fecaca",errorText:r?"#f87171":"#dc2626",infoBg:r?"#0d1325":"#dbeafe",infoBorder:r?"#2a3a5a":"#93c5fd",infoText:r?"#60a5fa":"#1e40af"}}const wt='"IBM Plex Mono", monospace';function Ce(t,e){const a=b.useContext(Ee)??void 0;return b.useMemo(()=>{const r=a??{primaryColor:"#EA4B4B"},n={...t?.primaryColor?{primaryColor:t.primaryColor}:{},...t?.fontFamily?{fontFamily:t.fontFamily}:{},...e!==void 0?{dark:e}:{}},s=xe(r,n),{dark:d,primaryColor:o,appName:h}=s,l=ve(d?"dark":"light"),m={...l,colors:{...l.colors,primary:o,primaryHover:`${o}dd`},typography:{...l.typography,fontFamily:s.fontFamily}},c={shell:s.shell,shellBorder:s.shellBorder,shellInnerBorder:s.shellInnerBorder,cardBg:s.card,inputBg:s.input,hoverBg:s.hover,textPrimary:s.text,textSecondary:s.textMuted,inputText:s.inputText,inputPlaceholder:s.inputPlaceholder,cardBorder:s.border,inputBorder:s.inputBorder,buttonBorder:s.buttonBorder,successBg:s.successBg,successBorder:s.successBorder,successText:s.successText,warningBg:s.warningBg,warningBorder:s.warningBorder,warningText:s.warningText,errorBg:s.errorBg,errorBorder:s.errorBorder,errorText:s.errorText,infoBg:s.infoBg,infoBorder:s.infoBorder,infoText:s.infoText},p=t?.inputVariant?t.inputVariant==="dark":d;return{brand:a,theme:m,dark:d,appName:h,primaryColor:o,dk:c,palette:c,fontFamily:s.fontFamily,monoFont:wt,inputDark:p,cardBg:p?c.cardBg:"#E9E9E9",cardBorder:p?c.cardBorder:"#C6C6C6",textPrimary:c.textPrimary,textSecondary:c.textSecondary,subtitleText:p?c.textSecondary:"#979AA0"}},[a,t,e])}const Be="spiceflow-spinner-keyframes";function bt(){if(typeof document>"u"||document.getElementById(Be))return;const t=document.createElement("style");t.id=Be,t.textContent="@keyframes spiceflow-spin{from{transform:rotate(0deg)}to{transform:rotate(360deg)}}",document.head.appendChild(t)}const Se=({size:t=16,borderWidth:e=2,color:a="currentColor",style:r})=>{const n=b.useRef(!1);return b.useEffect(()=>{n.current||(bt(),n.current=!0)},[]),W.jsx("div",{role:"status","aria-label":"Loading",style:{width:`${t}px`,height:`${t}px`,border:`${e}px solid ${a}`,borderTop:`${e}px solid transparent`,borderRadius:"50%",animation:"spiceflow-spin 1s linear infinite",flexShrink:0,...r}})},Et=({variant:t="primary",size:e="md",loading:a=!1,fullWidth:r=!1,disabled:n,children:s,className:d="",style:o,theme:h,styles:l,dark:m,...c})=>{const{theme:p,dark:u,palette:E}=Ce(l,m),i=h||p,w=m??u,[f,y]=b.useState(!1),[g,$]=b.useState(!1),A=w?E.shell:"white",O=()=>{switch(t){case"primary":return{backgroundColor:l?.button?.backgroundColor||i.colors.primary,color:l?.button?.color||"#ffffff",border:`1px solid ${l?.button?.backgroundColor||i.colors.primary}`};case"secondary":return{backgroundColor:i.colors.secondary,color:i.colors.text,border:`1px solid ${i.colors.border}`};case"success":return{backgroundColor:i.colors.success,color:i.colors.text,border:`1px solid ${i.colors.success}`};case"error":return{backgroundColor:i.colors.error,color:i.colors.text,border:`1px solid ${i.colors.error}`};case"ghost":return{backgroundColor:"transparent",color:i.colors.textSecondary,border:`1px solid ${i.colors.border}`};case"outline":{const C=l?.button?.backgroundColor||i.colors.primary,U=l?.button?.color||(w?"#ffffff":"#0e0d0b"),_=l?.button?.borderColor||(w?`${i.colors.primary}88`:"#0e0d0b"),M=n||a,ke=w?"1px":"1.5px",Re=l?.button?.disabledBackgroundColor||`${C}88`,$e=l?.button?.disabledColor||U;return{height:"56px",backgroundColor:M?Re:g?`${C}cc`:f?`${C}ee`:C,color:M?$e:U,border:`${ke} solid ${_}`,borderRadius:l?.button?.borderRadius||"12px",fontSize:"22px",fontWeight:500,fontFamily:'"IBM Plex Mono", monospace',opacity:M?.78:1,transform:M?"none":g?"scale(0.98)":f?"translateY(-2px)":"none",boxShadow:M?`3px 3px 0px ${A}, 4px 4px 0px ${_}`:g?`2px 2px 0px ${_}`:f?`5px 5px 0px ${A}, 6px 6px 0px ${_}`:`3px 3px 0px ${A}, 4px 4px 0px ${_}`,transition:"transform 150ms ease, box-shadow 150ms ease, background-color 150ms ease, border-color 150ms ease, color 150ms ease"}}default:return{}}},H=()=>{if(t==="outline")return{};switch(e){case"sm":return{padding:`${i.spacing.sm} ${i.spacing.md}`,fontSize:i.typography.fontSize.sm};case"md":return{padding:`${i.spacing.md} ${i.spacing.lg}`,fontSize:i.typography.fontSize.base};case"lg":return{padding:`${i.spacing.lg} ${i.spacing.xl}`,fontSize:i.typography.fontSize.lg};default:return{}}},F={borderRadius:l?.button?.borderRadius||i.borderRadius.md,fontWeight:l?.button?.fontWeight||i.typography.fontWeight.medium,fontFamily:l?.button?.fontFamily||i.typography.fontFamily,fontSize:l?.button?.fontSize||void 0,transition:"background-color 150ms ease, border-color 150ms ease, color 150ms ease, opacity 150ms ease",cursor:n||a?"not-allowed":"pointer",opacity:(n||a)&&t!=="outline"?.6:1,width:r?"100%":"auto",display:"flex",alignItems:"center",justifyContent:"center",gap:i.spacing.sm,...O(),...H(),...l?.button?.fontSize&&{fontSize:l.button.fontSize}},L=n||a;return W.jsxs("button",{type:c.type??"button","data-spiceflow-focus":!0,"aria-busy":a||void 0,"aria-disabled":L||void 0,style:{...F,...o},className:d,disabled:L,onMouseEnter:C=>{y(!0),c.onMouseEnter?.(C)},onMouseLeave:C=>{y(!1),$(!1),c.onMouseLeave?.(C)},onMouseDown:C=>{$(!0),c.onMouseDown?.(C)},onMouseUp:C=>{$(!1),c.onMouseUp?.(C)},...c,children:[a&&W.jsx(Se,{size:16}),s]})};exports.Button=Et,exports.CHAIN_CONFIGS=De,exports.RELAYER_API_URL=le,exports.SpiceFlowProvider=ft,exports.SpiceFlowProviderContext=N,exports.SpiceflowError=v,exports.Spinner=Se,exports.addressesEqual=j,exports.buildDarkPalette=yt,exports.buildLightPalette=gt,exports.createInitialSteps=rt,exports.createTheme=ve,exports.ensureSmartWallet=ee,exports.ensureWalletOnChain=Je,exports.getAllAssetsForChain=Ye,exports.getChainConfig=P,exports.getChainName=V,exports.getChainsForAssets=He,exports.getClientForChain=ie,exports.getDelegateContractAddress=ze,exports.getDynamicEmbeddedWallet=q,exports.getExplorerUrl=qe,exports.getTokenDecimals=Ge,exports.getWalletBalanceEntries=tt,exports.hasStoredSpiceFlowMode=dt,exports.isSpiceflowError=K,exports.isUserRejection=de,exports.relayerService=I,exports.resolveTheme=xe,exports.sanitizeError=Qe,exports.useEmbeddedWalletAddress=me,exports.useIsUserWhitelisted=ge,exports.useProviderWallets=pe,exports.useSpiceBrand=Ce,exports.useWallet=he,exports.z=ne;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-DWuLK4c8.js"),L=require("@dynamic-labs/sdk-react-core");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@tanstack/react-query"),require("@privy-io/react-auth"),require("wagmi");const k=({onAuthSuccess:a,onAuthError:r,theme:h="light",className:i="",buttonText:o="Login with Dynamic",autoTrigger:l=!1})=>{const s=t.createTheme(h),[m,D]=c.useState(!1),[g,S]=c.useState(!1),w=L.useDynamicContext(),{user:E,primaryWallet:f,connectedWallets:b,handleLogOut:q,setShowAuthFlow:x,sdkHasLoaded:p,showAuthFlow:j}=w,n=(t.getDynamicEmbeddedWallet({connectedWallets:b,primaryWallet:f})||f)?.address,v=!!E,d=v&&!!n;c.useEffect(()=>{D(!0)},[]),c.useEffect(()=>{d&&n&&a&&a(n)},[d,n,a]),c.useEffect(()=>{l&&p&&m&&!d&&!j&&!g&&(S(!0),x(!0))},[l,p,m,d,j,g,x]);const C=()=>{try{x(!0)}catch(y){const u=`Dynamic login failed: ${String(y)}`;r?r(u):console.error(u)}},N=async()=>{try{await q()}catch(y){const u=`Dynamic logout failed: ${String(y)}`;r?r(u):console.error(u)}};return m?p?v&&!n?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):d&&n?e.jsx("div",{className:i,children:e.jsxs(t.Button,{variant:"primary",onClick:N,theme:s,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):l?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",onClick:C,theme:s,children:o})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:"Loading..."})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:o})})};class W extends c.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const B=a=>{const{theme:r="light",className:h="",buttonText:i="Login with Dynamic",onAuthError:o}=a,l=t.createTheme(r);return e.jsx(W,{fallback:e.jsx("div",{className:h,children:e.jsx(t.Button,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:l,children:i})}),children:e.jsx(k,{...a})})};exports.DynamicLogin=B;
2
+ "use strict";const e=require("react/jsx-runtime"),c=require("react"),t=require("./Button-DSsTibdR.js"),L=require("@dynamic-labs/sdk-react-core");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@tanstack/react-query"),require("@privy-io/react-auth"),require("wagmi");const k=({onAuthSuccess:a,onAuthError:r,theme:h="light",className:i="",buttonText:o="Login with Dynamic",autoTrigger:l=!1})=>{const s=t.createTheme(h),[m,D]=c.useState(!1),[g,S]=c.useState(!1),w=L.useDynamicContext(),{user:E,primaryWallet:f,connectedWallets:b,handleLogOut:q,setShowAuthFlow:x,sdkHasLoaded:p,showAuthFlow:j}=w,n=(t.getDynamicEmbeddedWallet({connectedWallets:b,primaryWallet:f})||f)?.address,v=!!E,d=v&&!!n;c.useEffect(()=>{D(!0)},[]),c.useEffect(()=>{d&&n&&a&&a(n)},[d,n,a]),c.useEffect(()=>{l&&p&&m&&!d&&!j&&!g&&(S(!0),x(!0))},[l,p,m,d,j,g,x]);const C=()=>{try{x(!0)}catch(y){const u=`Dynamic login failed: ${String(y)}`;r?r(u):console.error(u)}},N=async()=>{try{await q()}catch(y){const u=`Dynamic logout failed: ${String(y)}`;r?r(u):console.error(u)}};return m?p?v&&!n?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):d&&n?e.jsx("div",{className:i,children:e.jsxs(t.Button,{variant:"primary",onClick:N,theme:s,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):l?e.jsx("div",{className:i,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(t.Spinner,{size:40,borderWidth:3,color:s.colors.primary}),e.jsx("p",{style:{color:s.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",onClick:C,theme:s,children:o})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:"Loading..."})}):e.jsx("div",{className:i,children:e.jsx(t.Button,{variant:"primary",disabled:!0,theme:s,children:o})})};class W extends c.Component{constructor(r){super(r),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const B=a=>{const{theme:r="light",className:h="",buttonText:i="Login with Dynamic",onAuthError:o}=a,l=t.createTheme(r);return e.jsx(W,{fallback:e.jsx("div",{className:h,children:e.jsx(t.Button,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:l,children:i})}),children:e.jsx(k,{...a})})};exports.DynamicLogin=B;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as N,useEffect as f}from"react";import{B as d,c as S,g as j,S as b}from"./Button-yBlOTM-o.js";import{useDynamicContext as z}from"@dynamic-labs/sdk-react-core";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@privy-io/react-auth";import"wagmi";const M=({onAuthSuccess:a,onAuthError:t,theme:m="light",className:r="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=S(m),[h,C]=N(!1),[x,E]=N(!1),L=z(),{user:W,primaryWallet:v,connectedWallets:k,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=L,n=(j({connectedWallets:k,primaryWallet:v})||v)?.address,w=!!W,l=w&&!!n;return f(()=>{C(!0)},[]),f(()=>{l&&n&&a&&a(n)},[l,n,a]),f(()=>{s&&u&&h&&!l&&!D&&!x&&(E(!0),p(!0))},[s,u,h,l,D,x,p]),h?u?w&&!n?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):l&&n?e("div",{className:r,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:r,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:o})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class T extends A.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const B=a=>{const{theme:t="light",className:m="",buttonText:r="Login with Dynamic",onAuthError:o}=a,s=S(t);return e(T,{fallback:e("div",{className:m,children:e(d,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:s,children:r})}),children:e(M,{...a})})};export{B as DynamicLogin};
2
+ import{jsx as e,jsxs as g}from"react/jsx-runtime";import A,{useState as N,useEffect as f}from"react";import{B as d,c as S,g as j,S as b}from"./Button-CchsukJQ.js";import{useDynamicContext as z}from"@dynamic-labs/sdk-react-core";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@privy-io/react-auth";import"wagmi";const M=({onAuthSuccess:a,onAuthError:t,theme:m="light",className:r="",buttonText:o="Login with Dynamic",autoTrigger:s=!1})=>{const i=S(m),[h,C]=N(!1),[x,E]=N(!1),L=z(),{user:W,primaryWallet:v,connectedWallets:k,handleLogOut:F,setShowAuthFlow:p,sdkHasLoaded:u,showAuthFlow:D}=L,n=(j({connectedWallets:k,primaryWallet:v})||v)?.address,w=!!W,l=w&&!!n;return f(()=>{C(!0)},[]),f(()=>{l&&n&&a&&a(n)},[l,n,a]),f(()=>{s&&u&&h&&!l&&!D&&!x&&(E(!0),p(!0))},[s,u,h,l,D,x,p]),h?u?w&&!n?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Finishing wallet setup..."})]})}):l&&n?e("div",{className:r,children:g(d,{variant:"primary",onClick:async()=>{try{await F()}catch(y){const c=`Dynamic logout failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:["Logout (",n.slice(0,6),"...",n.slice(-4),")"]})}):s?e("div",{className:r,children:g("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e(b,{size:40,borderWidth:3,color:i.colors.primary}),e("p",{style:{color:i.colors.textMuted,fontSize:"14px"},children:"Opening login..."})]})}):e("div",{className:r,children:e(d,{variant:"primary",onClick:()=>{try{p(!0)}catch(y){const c=`Dynamic login failed: ${String(y)}`;t?t(c):console.error(c)}},theme:i,children:o})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:"Loading..."})}):e("div",{className:r,children:e(d,{variant:"primary",disabled:!0,theme:i,children:o})})};class T extends A.Component{constructor(t){super(t),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?this.props.fallback:this.props.children}}const B=a=>{const{theme:t="light",className:m="",buttonText:r="Login with Dynamic",onAuthError:o}=a,s=S(t);return e(T,{fallback:e("div",{className:m,children:e(d,{variant:"primary",onClick:()=>{o&&o('DynamicLogin must be used within SpiceFlowProvider provider="dynamic" and a mounted DynamicContextProvider.')},theme:s,children:r})}),children:e(M,{...a})})};export{B as DynamicLogin};
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- "use strict";const e=require("react/jsx-runtime"),o=require("react"),c=require("./Button-DWuLK4c8.js"),f=require("@privy-io/react-auth");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@tanstack/react-query"),require("@dynamic-labs/sdk-react-core"),require("wagmi");const S=({onAuthSuccess:d,onAuthError:a,theme:v="light",className:l="",buttonText:g="Login with Privy",autoTrigger:h=!1})=>{const u=c.createTheme(v),[m,j]=o.useState(!1),[x,p]=o.useState(!1),{ready:s,authenticated:n,user:t}=f.usePrivy(),{login:q}=f.useLogin(),{logout:L}=f.useLogout();o.useEffect(()=>{j(!0)},[]),o.useEffect(()=>{h&&s&&!n&&m&&!x&&(p(!0),y())},[h,s,n,m,x]),o.useEffect(()=>{if(s&&n&&t&&d){const r=t.wallet?.address||t.email?.address;r&&d(r)}},[s,n,t,d]),o.useEffect(()=>{},[s,n,a]);const y=()=>{try{q()}catch(r){const i=`Login failed: ${String(r)}`;a?a(i):console.error(i)}},b=()=>{try{L()}catch(r){const i=`Logout failed: ${String(r)}`;a?a(i):console.error(i)}};if(!m)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:g})});if(!s)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:"Loading..."})});if(n&&t){const r=t.wallet?.address||t.email?.address,i=r?`${r.slice(0,6)}...${r.slice(-4)}`:"Connected";return e.jsx("div",{className:l,children:e.jsxs(c.Button,{variant:"primary",onClick:b,theme:u,children:["Logout (",i,")"]})})}return h?e.jsx("div",{className:l,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(c.Spinner,{size:40,borderWidth:3,color:"#3b82f6"}),e.jsx("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",onClick:y,theme:u,children:g})})};exports.PrivyLogin=S;
2
+ "use strict";const e=require("react/jsx-runtime"),o=require("react"),c=require("./Button-DSsTibdR.js"),f=require("@privy-io/react-auth");require("@spicenet-io/spiceflow-core"),require("viem"),require("viem/actions"),require("@tanstack/react-query"),require("@dynamic-labs/sdk-react-core"),require("wagmi");const S=({onAuthSuccess:d,onAuthError:a,theme:v="light",className:l="",buttonText:g="Login with Privy",autoTrigger:h=!1})=>{const u=c.createTheme(v),[m,j]=o.useState(!1),[x,p]=o.useState(!1),{ready:s,authenticated:n,user:t}=f.usePrivy(),{login:q}=f.useLogin(),{logout:L}=f.useLogout();o.useEffect(()=>{j(!0)},[]),o.useEffect(()=>{h&&s&&!n&&m&&!x&&(p(!0),y())},[h,s,n,m,x]),o.useEffect(()=>{if(s&&n&&t&&d){const r=t.wallet?.address||t.email?.address;r&&d(r)}},[s,n,t,d]),o.useEffect(()=>{},[s,n,a]);const y=()=>{try{q()}catch(r){const i=`Login failed: ${String(r)}`;a?a(i):console.error(i)}},b=()=>{try{L()}catch(r){const i=`Logout failed: ${String(r)}`;a?a(i):console.error(i)}};if(!m)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:g})});if(!s)return e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",disabled:!0,theme:u,children:"Loading..."})});if(n&&t){const r=t.wallet?.address||t.email?.address,i=r?`${r.slice(0,6)}...${r.slice(-4)}`:"Connected";return e.jsx("div",{className:l,children:e.jsxs(c.Button,{variant:"primary",onClick:b,theme:u,children:["Logout (",i,")"]})})}return h?e.jsx("div",{className:l,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[e.jsx(c.Spinner,{size:40,borderWidth:3,color:"#3b82f6"}),e.jsx("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):e.jsx("div",{className:l,children:e.jsx(c.Button,{variant:"primary",onClick:y,theme:u,children:g})})};exports.PrivyLogin=S;
@@ -1,2 +1,2 @@
1
1
  "use client";
2
- import{jsx as r,jsxs as y}from"react/jsx-runtime";import{useState as v,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-yBlOTM-o.js";import{usePrivy as j,useLogin as w,useLogout as B}from"@privy-io/react-auth";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@dynamic-labs/sdk-react-core";import"wagmi";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:p="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=v(!1),[g,b]=v(!1),{ready:o,authenticated:s,user:t}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&o&&!s&&h&&!g&&(b(!0),f())},[u,o,s,h,g]),c(()=>{if(o&&s&&t&&m){const e=t.wallet?.address||t.email?.address;e&&m(e)}},[o,s,t,m]),c(()=>{},[o,s,n]);const f=()=>{try{S()}catch(e){const i=`Login failed: ${String(e)}`;n?n(i):console.error(i)}},C=()=>{try{N()}catch(e){const i=`Logout failed: ${String(e)}`;n?n(i):console.error(i)}};if(!h)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:p})});if(!o)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(s&&t){const e=t.wallet?.address||t.email?.address,i=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:y(d,{variant:"primary",onClick:C,theme:l,children:["Logout (",i,")"]})})}return u?r("div",{className:a,children:y("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r($,{size:40,borderWidth:3,color:"#3b82f6"}),r("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):r("div",{className:a,children:r(d,{variant:"primary",onClick:f,theme:l,children:p})})};export{T as PrivyLogin};
2
+ import{jsx as r,jsxs as y}from"react/jsx-runtime";import{useState as v,useEffect as c}from"react";import{B as d,c as P,S as $}from"./Button-CchsukJQ.js";import{usePrivy as j,useLogin as w,useLogout as B}from"@privy-io/react-auth";import"@spicenet-io/spiceflow-core";import"viem";import"viem/actions";import"@tanstack/react-query";import"@dynamic-labs/sdk-react-core";import"wagmi";const T=({onAuthSuccess:m,onAuthError:n,theme:x="light",className:a="",buttonText:p="Login with Privy",autoTrigger:u=!1})=>{const l=P(x),[h,L]=v(!1),[g,b]=v(!1),{ready:o,authenticated:s,user:t}=j(),{login:S}=w(),{logout:N}=B();c(()=>{L(!0)},[]),c(()=>{u&&o&&!s&&h&&!g&&(b(!0),f())},[u,o,s,h,g]),c(()=>{if(o&&s&&t&&m){const e=t.wallet?.address||t.email?.address;e&&m(e)}},[o,s,t,m]),c(()=>{},[o,s,n]);const f=()=>{try{S()}catch(e){const i=`Login failed: ${String(e)}`;n?n(i):console.error(i)}},C=()=>{try{N()}catch(e){const i=`Logout failed: ${String(e)}`;n?n(i):console.error(i)}};if(!h)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:p})});if(!o)return r("div",{className:a,children:r(d,{variant:"primary",disabled:!0,theme:l,children:"Loading..."})});if(s&&t){const e=t.wallet?.address||t.email?.address,i=e?`${e.slice(0,6)}...${e.slice(-4)}`:"Connected";return r("div",{className:a,children:y(d,{variant:"primary",onClick:C,theme:l,children:["Logout (",i,")"]})})}return u?r("div",{className:a,children:y("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"20px",flexDirection:"column",gap:"12px"},children:[r($,{size:40,borderWidth:3,color:"#3b82f6"}),r("p",{style:{color:"#6b7280",fontSize:"14px"},children:"Opening login..."})]})}):r("div",{className:a,children:r(d,{variant:"primary",onClick:f,theme:l,children:p})})};export{T as PrivyLogin};
@@ -12,6 +12,7 @@ export type LockExecutorContext = {
12
12
  selectedDuration: LockDurationOption | undefined;
13
13
  isInsufficientBalance: boolean;
14
14
  isSemi7702: boolean;
15
+ isWhitelistGateActive: boolean;
15
16
  isSourceDestToken: boolean;
16
17
  isDirectDeposit: boolean;
17
18
  requiresRelayerFeeEstimate: boolean;
@@ -22,6 +22,7 @@ export type ExecutorContext = {
22
22
  isInsufficientBalance: boolean;
23
23
  isPayMode: boolean;
24
24
  isNon7702: boolean;
25
+ isWhitelistGateActive: boolean;
25
26
  isSourceDestToken: boolean;
26
27
  needsSwap: boolean;
27
28
  exactOutputSwap: ResolvedExactOutputSwap | null;