@fuels/react
Advanced tools
Comparing version
# @fuels/react | ||
## 0.36.0-pr-403-17936bd | ||
## 0.36.0-pr-404-4ea3721 | ||
@@ -5,0 +5,0 @@ ### Patch Changes |
@@ -1,3 +0,3 @@ | ||
import { Provider } from 'fuels'; | ||
import { type UseNamedQueryParams } from '../core'; | ||
import type { Provider } from 'fuels'; | ||
import type { UseNamedQueryParams } from '../core'; | ||
type UseProviderParams = { | ||
@@ -22,3 +22,5 @@ /** | ||
*/ | ||
export declare const useProvider: (params?: UseProviderParams) => import("../core").DefinedNamedUseQueryResult<"provider", Provider | null, Error>; | ||
export declare const useProvider: (_params?: UseProviderParams) => { | ||
provider: Provider | undefined; | ||
}; | ||
export {}; |
@@ -746,3 +746,5 @@ import * as _tanstack_react_query from '@tanstack/react-query'; | ||
*/ | ||
declare const useProvider: (params?: UseProviderParams) => DefinedNamedUseQueryResult<"provider", Provider | null, Error>; | ||
declare const useProvider: (_params?: UseProviderParams) => { | ||
provider: Provider | undefined; | ||
}; | ||
@@ -1141,3 +1143,3 @@ /** | ||
balance: (address?: string, assetId?: BytesLike, provider?: Provider | null) => QueryKey; | ||
wallet: (address?: string | null, provider?: Provider | null) => QueryKey; | ||
wallet: (address?: string | null, providerUrl?: string | null) => QueryKey; | ||
transaction: (id?: string) => QueryKey; | ||
@@ -1144,0 +1146,0 @@ transactionReceipts: (id?: string, provider?: Provider | null) => QueryKey; |
@@ -29,20 +29,20 @@ 'use strict'; | ||
function Cr(e){return {get(r,o){return o===e?Reflect.get(r,"data"):Reflect.get(r,o)}}}function u(e,t,r){let o=reactQuery.useQuery(t,r);return react.useMemo(()=>new Proxy(o,Cr(e)),[e,o])}var _e=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationFn:async a=>(a&&await e.selectConnector(a),e.connect())});return {connect:t,connectAsync:r,...o}};var n={base:["fuel"],account:()=>n.base.concat("account"),accounts:()=>n.base.concat("accounts"),assets:()=>n.base.concat("assets"),contract:(e,t,r)=>{let o=n.base.concat("contract").concat(e);return typeof r<"u"&&o.push(r),typeof t<"u"&&o.push(t),o},chain:()=>n.base.concat("chain"),isConnected:()=>n.base.concat("isConnected"),networks:()=>n.base.concat("networks"),provider:()=>n.base.concat("provider"),balance:(e,t,r)=>{let o=n.base.concat("balance");return e&&o.push(e),t&&o.push(t),r?.getChainId?.()!==void 0&&o.push(r.getChainId()),o},wallet:(e,t)=>{let r=n.base.concat("wallet");return e&&r.push(e),t?.getChainId?.()!==void 0&&r.push(t.getChainId()),r},transaction:e=>{let t=n.base.concat("transaction");return e&&t.push(e),t},transactionReceipts:(e,t)=>{let r=n.transaction(e).concat("receipts");return t?.getChainId?.()!==void 0&&r.push(t.getChainId()),r},transactionResult:(e,t)=>{let r=n.transaction(e).concat("result");return t?.getChainId?.()!==void 0&&r.push(t.getChainId()),r},nodeInfo:e=>{let t=n.base.concat("nodeInfo");return e&&t.push(e),t},connectorList:()=>n.base.concat("connectorList"),currentConnector:()=>n.base.concat(["currentConnector"]),currentNetwork:()=>n.base.concat("currentNetwork"),isSupportedNetwork:(e,t,r,o)=>{let a=n.base.concat("isSupportedNetwork");return e&&a.push(e),t&&a.push(t),r&&a.push(r),o&&a.push(o),a}},j={connect:"connect",addAssets:"addAssets",addNetwork:"addNetwork"};var k=["Bako Safe","Burner Wallet","Fuel Wallet","Fuel Wallet Development","Fuelet Wallet"],Se=[{chainId:fuels.CHAIN_IDS.fuel.testnet,bridgeURL:"https://app-testnet.fuel.network/bridge?from=eth&to=fuel&auto_close=true"},{chainId:fuels.CHAIN_IDS.fuel.devnet,bridgeURL:"https://app-devnet.fuel.network/bridge?from=eth&to=fuel&auto_close=true"},{chainId:fuels.CHAIN_IDS.fuel.mainnet,bridgeURL:"https://app.fuel.network/bridge?from=eth&to=fuel&auto_close=true"}];function Ve(e){return k.includes(e?.name)}var Ze=({query:e}={})=>{let{fuel:t}=l();return u("connectors",{queryKey:n.connectorList(),queryFn:async()=>t.connectors(),placeholderData:[],...e})};var Je=react.createContext(null);var v=()=>{let e=react.useContext(Je);if(!e)throw new Error("useConnectUI must be used within a FuelUIProvider");return e},br=e=>e.sort((t,r)=>{if(t.connected!==r.connected)return t.connected?-1:1;let o=k.includes(t.name)&&t.installed,a=k.includes(r.name)&&r.installed;return o!==a?o?-1:1:t.name.localeCompare(r.name)});function Xe({fuelConfig:e,children:t,theme:r,uiConfig:o}){let{isPending:a,isError:c,connectAsync:s}=_e(),{connectors:d,isLoading:p}=Ze({query:{select:br}}),{isConnected:S}=R(),[f,T]=react.useState(null),[L,g]=react.useState("list"),[N,$]=react.useState(!1),[Me,q]=react.useState(null);react.useEffect(()=>{if(!f)return;let m=d.find(xe=>xe.name===f.name);m&&f.installed!==m?.installed&&T(m);},[d,f]);let Be=react.useCallback(()=>{q(null),T(null),g("list");},[]),J=react.useCallback(async m=>{try{q(null),await s(m.name);}catch(xe){q(xe);}},[s]),X=react.useCallback(async m=>{g("connecting"),await J(m);},[J]),We=react.useCallback(async m=>{T(m),m.installed?Ve(m)?X(m):g("disclaimer"):g("install");},[X]),He=react.useCallback(m=>{g(m);},[]),Oe=react.useMemo(()=>{let m=(e.connectors||[]).length>d.length;return p||m},[d,p,e]),ze=react.useCallback(()=>{T(null),q(null),g("list"),$(!0);},[]),Ye=react.useCallback(({clean:m}={})=>{q(null),$(!1),m&&(T(null),g("list"));},[]);react.useEffect(()=>{let m=document.createElement("style");return m.appendChild(document.createTextNode(`@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&display=swap"); .fuel-connectors * { box-sizing: border-box; } .fuel-connectors .fuel-connectors-dialog-content:focus { outline: none; } @media (max-width: 430px) { .fuel-connectors .fuel-connectors-dialog-content { top: 50%; width: 100%; border-radius: 36px; } } .fuel-connectors .fuel-connectors-connector-item { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-connector-background); } .fuel-connectors .fuel-connectors-connector-item:active { opacity: 0.8; } .fuel-connectors .fuel-connectors-connector-item:hover { background-color: var(--fuel-connector-hover); } .fuel-connectors .fuel-connectors-connector-button { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-button-background); color: var(--fuel-color-bold); } .fuel-connectors .fuel-connectors-connector-button:visited { color: var(--fuel-color-bold); } .fuel-connectors .fuel-connectors-connector-button:hover { background-color: var(--fuel-button-background-hover); } .fuel-connectors .fuel-connectors-connector-button-primary { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-green-11); color: var(--fuel-black-color); } .fuel-connectors .fuel-connectors-connector-button-primary:visited { color: var(--fuel-black-color); } .fuel-connectors .fuel-connectors-connector-button-primary:hover { background-color: var(--fuel-green-11); } .fuel-connectors .fuel-connectors-back-icon { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); } .fuel-connectors .fuel-connectors-back-icon[data-connector='false'] { visibility: hidden; } .fuel-connectors .fuel-connectors-back-icon:hover, .fuel-connectors .fuel-connectors-back-icon:active { opacity: 1; background-color: var(--fuel-connector-hover); } .fuel-connectors .fuel-connectors-close-icon { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); } .fuel-connectors .fuel-connectors-close-icon:hover, .fuel-connectors .fuel-connectors-close-icon:active { opacity: 1; background-color: var(--fuel-connector-hover); } .fuel-connectors .fuel-connectors-button-base { cursor: pointer; } .fuel-connectors .fuel-connectors-button:disabled { cursor: not-allowed; } .fuel-connectors .fuel-connectors-button { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-green-11); } .fuel-connectors .fuel-connectors-button:disabled { background-color: var(--fuel-border-color); } .fuel-connectors .fuel-connectors-button-disconnect { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-button-background); } .fuel-connectors .fuel-connectors-button-disconnect:hover { background-color: var(--fuel-button-background-hover); } @keyframes fuelOverlayShow { from { opacity: 0; } to { opacity: 1; } } @keyframes fuelSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes fuelContentShow { from { opacity: 0; transform: translate(-50%, -48%) scale(0.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } } @keyframes fuelLoader { 0% { background-position: -468px 0 } 100% { background-position: 468px 0 } }`)),document.head.appendChild(m),()=>{document.head.removeChild(m);}},[]);let fr=react.useMemo(()=>({theme:r||"light",fuelConfig:e,uiConfig:o,error:Me,setError:q,isConnected:!!S,isConnecting:a,isLoading:Oe,isError:c,connectors:d,connect:ze,cancel:Ye,dialog:{route:L,setRoute:He,connector:f,isOpen:N,connect:We,retryConnect:J,back:Be,_startConnection:X}}),[r,e,o,Me,S,a,Oe,c,d,f,L,N,Ye,X,He,We,ze,J,Be]);return jsxRuntime.jsx(Je.Provider,{value:fr,children:t})}function je({size:e,...t}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 490 496",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[jsxRuntime.jsx("title",{children:"FuelWallet Development Icon"}),jsxRuntime.jsx("rect",{x:"42.509",y:"28.3438",width:"396.739",height:"425.143",fill:"#00F58C"}),jsxRuntime.jsx("path",{d:"M32.5836 0C14.5545 0 0 14.7327 0 32.9826V496H405.427C419.129 496 432.307 490.492 442.01 480.67L474.856 447.422C484.559 437.6 490 424.261 490 410.391V0H32.5836ZM319.936 63.7752L160.558 225.105C156.624 229.086 151.248 231.343 145.676 231.343C137.546 231.343 130.072 226.565 126.598 219.132L64.8394 87.0024C59.7913 76.1852 67.593 63.7752 79.3939 63.7752H319.936ZM63.0037 432.225V275.275C63.0037 266.914 69.6909 260.145 77.9516 260.145H233.002L63.0037 432.225ZM245.852 231.343H194.518L348.979 74.9906C356.06 67.8234 365.697 63.7752 375.728 63.7752H427.062L272.601 220.127C265.521 227.295 255.883 231.343 245.852 231.343Z",fill:"#080808"})]})}function et({size:e,...t}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 491 496",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[jsxRuntime.jsx("title",{children:"Fuel Wallet Icon"}),jsxRuntime.jsx("rect",{x:"42.5535",y:"28.3438",width:"397.154",height:"425.143",fill:"#080808"}),jsxRuntime.jsx("path",{d:"M32.6178 0C14.5697 0 0 14.7327 0 32.9826V496H405.852C419.568 496 432.759 490.492 442.473 480.67L475.353 447.422C485.066 437.6 490.513 424.261 490.513 410.391V0H32.6178ZM320.271 63.7752L160.726 225.105C156.788 229.086 151.407 231.343 145.828 231.343C137.69 231.343 130.208 226.565 126.73 219.132L64.9074 87.0024C59.8539 76.1852 67.6638 63.7752 79.4771 63.7752H320.271ZM63.0697 432.225V275.275C63.0697 266.914 69.7639 260.145 78.0332 260.145H233.246L63.0697 432.225ZM246.11 231.343H194.722L349.345 74.9906C356.433 67.8234 366.08 63.7752 376.121 63.7752H427.509L272.887 220.127C265.799 227.295 256.151 231.343 246.11 231.343Z",fill:"#00F58C"})]})}function rt({theme:e,size:t,...r}){return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:[jsxRuntime.jsx("title",{children:"Fuelet Icon"}),jsxRuntime.jsx("path",{d:"M20 40C14.9355 40 10.3145 38.114 6.7905 35.0105L18.146 26.907C18.845 26.4085 19.8065 26.9645 19.722 27.8195L19.2745 32.3605C19.182 33.295 20.3125 33.8295 20.9765 33.1655L27.071 27.071C31.062 23.08 30.9745 16.5555 26.8085 12.6755C22.8405 8.98 16.5935 9.264 12.7595 13.0985L6.853 19.0045C6.187 19.671 6.7275 20.8045 7.6645 20.7065L12.209 20.231C13.0655 20.1415 13.6275 21.105 13.127 21.8065L4.9895 33.2095C1.886 29.6855 0 25.0645 0 20C0 8.9545 8.9545 0 20 0C31.0455 0 40 8.9545 40 20C40 31.0455 31.0455 40 20 40Z",fill:e==="dark"?"white":"#28282F"})]})}var ot=(e,t)=>{let{image:r}=e;return typeof r=="object"?t==="dark"?r.dark:r.light:r};function K({connectorName:e,connectorMetadata:t,...r}){switch(e){case"Fuelet Wallet":return jsxRuntime.jsx(rt,{...r});case"Fuel Wallet":return jsxRuntime.jsx(et,{...r});case"Fuel Wallet Development":return jsxRuntime.jsx(je,{...r});default:return t.image?jsxRuntime.jsx("img",{height:`${r.size}px`,width:`${r.size}px`,src:ot(t,r.theme),alt:`${e} icon`}):null}}var Te={textAlign:"center",fontSize:"1.2em",fontWeight:500,color:"var(--fuel-color-bold)",margin:"0 0 0.4em 0",padding:"0 1.8em"},M=({children:e})=>jsxRuntime.jsx("h2",{style:Te,children:e}),re={color:"var(--fuel-gray-12)",fontSize:"0.9em",fontWeight:400,textAlign:"center",margin:"0 1.2em",lineHeight:"1.2em",padding:"0 2em",opacity:.8},Q=({children:e})=>jsxRuntime.jsx("p",{style:re,children:e}),Nr={color:"var(--fuel-gray-12)",fontSize:"0.8em",fontWeight:400,textAlign:"center",margin:"2em auto 0",lineHeight:"1.2em",padding:"0 2em",opacity:.5},nt=({children:e})=>jsxRuntime.jsx("p",{style:Nr,children:e}),kr={...re,color:"var(--fuel-color-error)"},at=({children:e})=>jsxRuntime.jsx("p",{style:kr,children:e}),Rr={display:"flex",justifyContent:"center",height:"6.2em",width:"100%",marginTop:"1.6em",marginBottom:"1.2em"},B=({children:e})=>jsxRuntime.jsx("div",{style:Rr,children:e}),it={display:"flex",boxSizing:"border-box",textDecoration:"none",cursor:"pointer",justifyContent:"center",alignItems:"center",margin:"0.4rem 1rem 0",padding:"0.6rem 0",fontSize:"0.875em",borderRadius:"var(--fuel-border-radius)"},W=({href:e,children:t,style:r,...o})=>jsxRuntime.jsx("a",{href:e,style:it,...o,className:"fuel-connectors-connector-button",children:t}),Ne={display:"flex",flexDirection:"column",gap:"8px",marginBottom:"24px"},H=({children:e})=>jsxRuntime.jsx("div",{style:Ne,children:e}),I=({href:e,children:t,...r})=>jsxRuntime.jsx("a",{href:e,style:it,...r,className:"fuel-connectors-connector-button-primary",children:t});function ct(){let{theme:e,dialog:{connector:t,setRoute:r}}=v();if(!t)return null;let{install:{action:o,link:a,description:c}}=t.metadata;react.useEffect(()=>{(async()=>{await t.ping()&&r("connecting");})();},[t,r]);let s=o||"Install";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(B,{children:jsxRuntime.jsx(K,{connectorMetadata:t.metadata,connectorName:t.name,size:100,theme:e})}),jsxRuntime.jsxs(H,{children:[jsxRuntime.jsx(M,{children:t.name}),jsxRuntime.jsx(Q,{children:c})]}),jsxRuntime.jsx(I,{href:a,target:"_blank",children:s}),jsxRuntime.jsxs(nt,{children:["If you have installed it and it is not detected,",jsxRuntime.jsx("br",{}),"try refreshing the page."]})]})}var Dr={display:"flex",alignItems:"center",boxSizing:"border-box",cursor:"pointer",width:"100%",gap:"var(--fuel-items-gap)",padding:"0.8em",borderRadius:"16px",fontWeight:400},oe=({children:e,...t})=>jsxRuntime.jsx("div",{style:Dr,...t,className:"fuel-connectors-connector-item",children:e}),Fr={display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--fuel-items-gap)",padding:"0px 14px"},Re=({children:e})=>jsxRuntime.jsx("div",{style:Fr,children:e}),Er={fontSize:"0.875em"},ne=({children:e})=>jsxRuntime.jsx("div",{style:Er,children:e});var lt={borderRadius:"var(--fuel-border-radius)",fontSize:"var(--fuel-font-size-xs)",padding:"2px 8px",textTransform:"uppercase",marginLeft:"auto"},ut=({children:e})=>{let t={...lt,backgroundColor:"var(--fuel-blue-3)",color:"var(--fuel-blue-11)"};return jsxRuntime.jsx("div",{style:t,children:e})},pt=({children:e})=>{let t={...lt,backgroundColor:"var(--fuel-green-3)",color:"var(--fuel-green-11)"};return jsxRuntime.jsx("div",{style:t,children:e})},dt={width:"100%",color:"#797979",fontSize:"var(--fuel-font-size-xs)",fontStyle:"normal",fontWeight:400,margin:0},mt=({children:e})=>jsxRuntime.jsx("p",{style:dt,children:e}),ft=({children:e})=>{let t={...dt,marginTop:"14px"};return jsxRuntime.jsx("p",{style:t,children:e})};function gt({name:e,connected:t,installed:r}){let o=react.useMemo(()=>!k.includes(e),[e]);return t?jsxRuntime.jsx(pt,{children:"Connected"}):!o&&r?jsxRuntime.jsx(ut,{children:"Installed"}):null}var Ar=({connect:e,theme:t,connector:r,index:o})=>jsxRuntime.jsxs(oe,{tabIndex:o+1,"aria-label":`Connect to ${r.name}`,"data-installed":r.installed,"data-connected":r.connected,onClick:a=>{a.preventDefault(),e(r);},children:[jsxRuntime.jsx(K,{connectorMetadata:r.metadata,connectorName:r.name,size:32,theme:t}),jsxRuntime.jsx(ne,{children:r.name}),jsxRuntime.jsx(gt,{name:r.name,connected:r.connected,installed:r.installed})]},r.name),De=react.memo(Ar);function ht({size:e,...t}){return jsxRuntime.jsxs("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",...t,children:[jsxRuntime.jsx("title",{children:"Back Icon"}),jsxRuntime.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M11.04 1.46a1 1 0 0 1 0 1.41L5.91 8l5.13 5.13a1 1 0 1 1-1.41 1.41L3.79 8.71a1 1 0 0 1 0-1.42l5.84-5.83a1 1 0 0 1 1.41 0Z",clipRule:"evenodd"})]})}function xt({size:e,...t}){return jsxRuntime.jsxs("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",...t,children:[jsxRuntime.jsx("title",{children:"Close Icon"}),jsxRuntime.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M2.54 2.54a1 1 0 0 1 1.42 0L8 6.6l4.04-4.05a1 1 0 1 1 1.42 1.42L9.4 8l4.05 4.04a1 1 0 0 1-1.42 1.42L8 9.4l-4.04 4.05a1 1 0 0 1-1.42-1.42L6.6 8 2.54 3.96a1 1 0 0 1 0-1.42Z",clipRule:"evenodd"})]})}var Mr={display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"16px",paddingRight:"16px"},ae=({children:e,...t})=>jsxRuntime.jsx("div",{style:Mr,...t,children:e}),Br={padding:"8px 14px 12px",margin:0,textAlign:"center",fontSize:"var(--fuel-font-size)",fontWeight:500},ie=({children:e,...t})=>jsxRuntime.jsx(ye__namespace.Title,{style:Br,...t,children:e}),Wr={height:"1px",width:"100%",backgroundColor:"var(--fuel-border-color)",margin:"10px 0",padding:0},se=e=>jsxRuntime.jsx("div",{style:Wr,...e}),Hr={position:"relative",overflowY:"auto"},ce=e=>jsxRuntime.jsx("div",{style:Hr,...e}),Or={fill:"var(--fuel-color)",padding:"7px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},le=({size:e,...t})=>jsxRuntime.jsx(ht,{size:e,style:Or,...t,className:"fuel-connectors-back-icon"}),zr={fill:"var(--fuel-color)",padding:"7px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},ue=({size:e,...t})=>jsxRuntime.jsx(xt,{size:e,style:zr,...t,className:"fuel-connectors-close-icon"});var Yr={animationDuration:"1s",animationFillMode:"forwards",animationIterationCount:"infinite",animationName:"fuelLoader",animationTimingFunction:"linear",backgroundColor:"#d1d5d9",background:"var(--fuel-loader-background)",backgroundSize:"1000px 104px",height:"fit-content",position:"relative",overflow:"hidden",color:"transparent",pointerEvents:"none"},Fe=({children:e,...t})=>jsxRuntime.jsx("div",{style:Yr,...t,children:e});function St({items:e}){return Array.from({length:e}).map((r,o)=>jsxRuntime.jsxs(oe,{children:[jsxRuntime.jsx(Fe,{children:jsxRuntime.jsx("div",{style:{height:32,width:32}})}),jsxRuntime.jsx(Fe,{children:jsxRuntime.jsx(ne,{children:"Fuel Wallet"})})]},o))}function wt(){let{fuelConfig:e,connectors:t,isLoading:r,theme:o,dialog:{connect:a}}=v(),{native:c,external:s}=react.useMemo(()=>{let p=t.filter(f=>!k.includes(f.name));return {native:t.filter(f=>k.includes(f.name)),external:p}},[t]),d=!!c.length&&!!s.length;return r?jsxRuntime.jsx(Re,{children:jsxRuntime.jsx(St,{items:e.connectors?.length||2})}):jsxRuntime.jsxs(Re,{children:[d&&jsxRuntime.jsx(mt,{children:"Fuel Native Wallets"}),c.map((p,S)=>jsxRuntime.jsx(De,{connect:a,theme:o,connector:p,index:S},p.name)),d&&jsxRuntime.jsx(ft,{children:"Non-Native Wallets"}),s.map((p,S)=>jsxRuntime.jsx(De,{connect:a,theme:o,connector:p,index:S},p.name))]})}var de=({size:e,color:t})=>{let r={height:`${e}px`,width:`${e}px`,border:"4px solid rgba(0, 0, 0, 0.1)",borderTopColor:t,borderRadius:"50%",animation:"fuelSpin 1s infinite linear"};return jsxRuntime.jsx("div",{style:r})};function Pt({className:e}){let{error:t,isConnecting:r,theme:o,cancel:a,dialog:{route:c,connector:s,retryConnect:d},isConnected:p}=v();return react.useEffect(()=>{p&&c==="connecting"&&!r&&a();},[p,c,r,a]),s?jsxRuntime.jsxs("div",{className:e,children:[jsxRuntime.jsx(B,{children:jsxRuntime.jsx(K,{connectorMetadata:s.metadata,connectorName:s.name,size:100,theme:o})}),jsxRuntime.jsxs(H,{children:[jsxRuntime.jsx(M,{children:s.name}),t?jsxRuntime.jsx(at,{children:t.message}):r?jsxRuntime.jsxs(Q,{children:["Requesting connection to ",jsxRuntime.jsx("br",{})," ",s.name,"."]}):jsxRuntime.jsxs(Q,{children:["Click on the button below to connect to ",location.origin,"."]})]}),r?jsxRuntime.jsx(W,{children:jsxRuntime.jsx(de,{size:26,color:"var(--fuel-loader-background)"})}):jsxRuntime.jsx(I,{onClick:()=>d(s),children:"Connect"})]}):null}var Jr={display:"flex",flexDirection:"column",overflow:"hidden",color:"var(--fuel-color)",userSelect:"none",maxHeight:"calc(100% - 20px)",backgroundColor:"var(--fuel-dialog-background)",position:"fixed",left:"50%",transform:"translate(-50%, -50%)",borderRadius:"36px",padding:"14px 0px",paddingBottom:"36px",animation:"fuelContentShow 150ms cubic-bezier(0.16, 1, 0.3, 1)",top:"50%",width:"360px",maxWidth:"calc(100% - 20px)",boxShadow:"hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px"},Y=e=>jsxRuntime.jsx(ye__namespace.Content,{style:Jr,...e,className:"fuel-connectors-dialog-content"});var jr={"--fuel-font-family":'"Inter", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',"--fuel-font-size":"16px","--fuel-font-size-xs":"12px","--fuel-letter-spacing":"-0.64px","--fuel-border-radius":"6px","--fuel-items-gap":"8px","--fuel-border":"1px solid var(--fuel-border-color)","--fuel-color-error":"#f25a68"},eo={"--fuel-color":"#141414","--fuel-color-bold":"#000000","--fuel-dialog-background":"white","--fuel-overlay-background":"rgba(71,88,107,0.24)","--fuel-connector-background":"rgb(250 250 250)","--fuel-connector-hover":"rgb(241 243 244)","--fuel-border-color":"hsl(210deg 9.52% 83.53%)","--fuel-border-hover":"hsla(0, 0%, 78.04%, 1)","--fuel-button-background":"rgb(220 220 220)","--fuel-button-background-hover":"rgb(203 205 207)","--fuel-loader-background":"linear-gradient(to right, hsl(0, 0%, 92%) 8%, hsl(0, 0%, 85%) 18%, hsl(0, 0%, 92%) 33%)","--fuel-green-3":"#D9FCE3","--fuel-green-11":"#008347","--fuel-blue-3":"#E6F4FE","--fuel-blue-11":"#0D74CE","--fuel-gray-10":"#838383","--fuel-gray-11":"#646464","--fuel-gray-12":"#202020","--fuel-separator-color":"rgb(83 79 79 / 13%)","--fuel-black-color":"#FFFFFF"},to={"--fuel-color":"#e4e7e7","--fuel-color-bold":"#ffffff","--fuel-dialog-background":"rgb(25 26 26)","--fuel-overlay-background":"rgba(20, 20, 20, 0.8)","--fuel-connector-background":"rgba(255, 255, 255, 0.02)","--fuel-connector-hover":"rgba(255, 255, 255, 0.05)","--fuel-border-color":"rgba(255, 255, 255, 0.05)","--fuel-border-hover":"hsla(0, 0%, 50%, 1)","--fuel-button-background":"hsla(0, 0%, 30%, 1)","--fuel-button-background-hover":"hsla(0, 0%, 40%, 1)","--fuel-loader-background":"linear-gradient(to right, hsl(0, 0%, 20%) 8%, hsl(0, 0%, 25%) 18%, hsl(0, 0%, 20%) 33%)","--fuel-green-3":"#0F2E1B","--fuel-green-11":"#00DD75","--fuel-blue-3":"#0D2847","--fuel-blue-11":"#70B9FF","--fuel-gray-10":"#7b7b7b","--fuel-gray-11":"#b4b4b4","--fuel-gray-12":"#eee","--fuel-separator-color":"rgb(165 165 165 / 13%)","--fuel-black-color":"#141414"},ro={light:eo,dark:to},Nt=e=>{let t=ro[e];return {...jr,...t}};var oo={backgroundColor:"var(--fuel-overlay-background)",position:"fixed",inset:0,animation:"fuelOverlayShow 150ms cubic-bezier(0.16, 1, 0.3, 1)"},Rt=({children:e})=>jsxRuntime.jsx(ye__namespace.Overlay,{style:oo,asChild:!0,children:e}),no={position:"fixed",top:0,left:0,bottom:0,right:0,height:"100%",width:"100%",margin:0,padding:0,zIndex:99,fontFamily:"var(--fuel-font-family)",fontSize:"var(--fuel-font-size)"},It=({style:e,children:t})=>jsxRuntime.jsx("div",{className:"fuel-connectors",style:{...no,...e},children:t});function _({children:e,theme:t,open:r,onOpenChange:o}){let[a,c]=react.useState(!1);return react.useEffect(()=>{c(!0);},[]),a?jsxRuntime.jsx(ye__namespace.Root,{open:r,onOpenChange:o,children:jsxRuntime.jsx(ye__namespace.Portal,{children:jsxRuntime.jsx(Rt,{children:jsxRuntime.jsx(It,{style:Nt(t),children:e})})})}):null}var so={...Ne,gap:"12px",borderLeft:"2px solid",borderColor:"#F5CC00",marginLeft:"1rem",padding:"0.5em 2em",fontSize:"1em"},Ft=({children:e})=>jsxRuntime.jsx("div",{style:so,children:e}),co={fontWeight:400,textAlign:"left",margin:0,paddingInlineStart:"16px",lineHeight:"1.4em",opacity:.8,listStyleType:"disc"},Et=({children:e,...t})=>jsxRuntime.jsx("ul",{style:co,...t,className:"fuel-connectors-disclaimer-list",children:e});function Ut(){let{dialog:{connector:e,_startConnection:t,back:r}}=v();return e?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs(Ft,{children:[jsxRuntime.jsx("h2",{style:{...Te,color:"var(--fuel-color-bold)",fontSize:"1.2em",textAlign:"left",margin:0,padding:0},children:"Non-Native Wallet"}),jsxRuntime.jsx("p",{style:{...re,fontSize:"0.9em",textAlign:"left",margin:0,padding:0},children:"Fuel supports any wallet from Ethereum or Solana, but these wallets have limited functionality for now:"}),jsxRuntime.jsxs(Et,{children:[jsxRuntime.jsxs("li",{children:[jsxRuntime.jsx("span",{style:{fontSize:"0.9em",fontWeight:600,color:"var(--fuel-gray-12)"},children:"Limited Balance Visibility"}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{style:{fontSize:"0.8em",color:"var(--fuel-gray-11)"},children:"You cannot see balances natively in the wallet (e.g. Metamask). You must visit the Fuel Block Explorer to see balances."})]}),jsxRuntime.jsxs("li",{style:{marginTop:5,marginBottom:5},children:[jsxRuntime.jsx("span",{style:{fontSize:"0.9em",fontWeight:600,color:"var(--fuel-gray-12)"},children:"Signatures are Blind"}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{style:{fontSize:"0.8em",color:"var(--fuel-gray-11)"},children:"Ensure you only use trusted applications."})]}),jsxRuntime.jsxs("li",{children:[jsxRuntime.jsx("span",{style:{fontSize:"0.9em",fontWeight:600,color:"var(--fuel-gray-12)"},children:"No Multi-Sigs"}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{style:{fontSize:"0.8em",color:"var(--fuel-gray-11)"},children:"Multi-sigs and smart contract wallets (e.g. SAFE) are not supported."})]})]})]}),jsxRuntime.jsx(I,{onClick:()=>t(e),children:"Proceed anyway"}),jsxRuntime.jsx(W,{onClick:()=>r(),children:"Select a Native Wallet"})]}):null}var lo=({state:e})=>{switch(e){case"list":return jsxRuntime.jsx(wt,{});case"install":return jsxRuntime.jsx(ct,{});case"disclaimer":return jsxRuntime.jsx(Ut,{});case"connecting":return jsxRuntime.jsx(Pt,{});default:return null}};function qt(){let{theme:e,cancel:t,dialog:{isOpen:r,route:o,connector:a,back:c}}=v();return jsxRuntime.jsx(_,{open:r,theme:e,onOpenChange:d=>{d||t();},children:jsxRuntime.jsxs(Y,{"data-connector":!!a,children:[jsxRuntime.jsxs(ae,{children:[jsxRuntime.jsx(le,{size:32,onClick:c,"data-connector":!!a}),jsxRuntime.jsx(ie,{children:"Connect Wallet"}),jsxRuntime.jsx(ye__namespace.Close,{asChild:!0,children:jsxRuntime.jsx(ue,{size:32,onClick:()=>t()})})]}),jsxRuntime.jsx(se,{}),jsxRuntime.jsx(ce,{children:jsxRuntime.jsx(lo,{state:o})})]})})}function Mt({size:e,...t}){return jsxRuntime.jsxs("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 95 95",width:e,height:e,...t,children:[jsxRuntime.jsx("title",{children:"No Funds Icon"}),jsxRuntime.jsx("path",{d:"M46.88 90.124C30.395 90.124 20 74.39 20 46.679 20 18.97 30.395 3 46.88 3s26.88 15.969 26.88 43.68c0 27.71-10.395 43.444-26.88 43.444Zm0-13.15c8.505 0 13.44-11.038 13.44-30.295 0-6.223-.525-11.624-1.47-16.086L39.005 72.511c2.1 2.936 4.725 4.462 7.875 4.462ZM33.44 46.678c0 6.106.525 11.507 1.47 15.852l19.845-41.918c-2.1-2.936-4.725-4.462-7.875-4.462-8.505 0-13.44 11.154-13.44 30.528Z",fill:"#EEE"}),jsxRuntime.jsx("path",{d:"M67 91.281c5.523 0 10-4.876 10-10.89C77 74.376 72.523 69.5 67 69.5s-10 4.876-10 10.89c0 6.015 4.477 10.891 10 10.891Z",fill:"#000"}),jsxRuntime.jsx("path",{d:"M67 91.281c5.523 0 10-4.876 10-10.89C77 74.376 72.523 69.5 67 69.5s-10 4.876-10 10.89c0 6.015 4.477 10.891 10 10.891Z",fill:"#627EEA"}),jsxRuntime.jsx("path",{d:"M67 91.281c5.523 0 10-4.876 10-10.89C77 74.376 72.523 69.5 67 69.5s-10 4.876-10 10.89c0 6.015 4.477 10.891 10 10.891Z",fill:"url(#a)",style:{"mix-blend-mode":"soft-light"}}),jsxRuntime.jsx("path",{d:"M67.166 73.13v5.368l4.166 2.027-4.166-7.395Z",fill:"#fff",fillOpacity:".602"}),jsxRuntime.jsx("path",{d:"M67.166 73.13 63 80.525l4.166-2.027V73.13Z",fill:"#fff"}),jsxRuntime.jsx("path",{d:"M67.166 84.004v3.647l4.17-6.281-4.17 2.634Z",fill:"#fff",fillOpacity:".602"}),jsxRuntime.jsx("path",{d:"M67.166 87.65v-3.646L63 81.37l4.166 6.28Z",fill:"#fff"}),jsxRuntime.jsx("path",{d:"m67.166 83.16 4.166-2.635-4.166-2.026v4.66Z",fill:"#fff",fillOpacity:".2"}),jsxRuntime.jsx("path",{d:"m63 80.525 4.166 2.634V78.5L63 80.525Z",fill:"#fff",fillOpacity:".602"}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"a",x1:"67",y1:"69.5",x2:"67",y2:"91.281",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{stopColor:"#fff",stopOpacity:".5"}),jsxRuntime.jsx("stop",{offset:"1",stopOpacity:".5"})]})})]})}function ge(e){return {networks:react.useMemo(()=>e?e.map(r=>r.chainId?{...Se.find(a=>a.chainId===r.chainId),...r}:r):Se,[e])??[]}}function Ht({theme:e}){let{networks:t}=ge(),{provider:r}=h(),o=react.useMemo(()=>{let g=t.find($=>$.chainId===r?.getChainId());if(!g||!g.bridgeURL)return null;let N=new URL(g.bridgeURL);return N.searchParams.set("","true"),N.toString()},[t,r]),{isConnected:a,uiConfig:c,dialog:{isOpen:s}}=v(),{isSupportedNetwork:d}=Ce(),{account:p}=Ot(),{balance:S}=zt({account:p}),[f,T]=react.useState(!1),L=react.useMemo(()=>f||s||!o||!c.suggestBridge||!a||!d?!1:!!S?.isZero(),[c,S,d,a,f,o,s]);return jsxRuntime.jsx(_,{open:L,theme:e,onOpenChange:g=>{g||T(!0);},children:jsxRuntime.jsxs(Y,{"data-connector":!0,children:[jsxRuntime.jsxs(ae,{children:[jsxRuntime.jsx(le,{size:32,"data-connector":!1}),jsxRuntime.jsx(ie,{children:"Bridge Funds"}),jsxRuntime.jsx(ye__namespace.Close,{asChild:!0,children:jsxRuntime.jsx(ue,{size:32})})]}),jsxRuntime.jsx(se,{}),jsxRuntime.jsx(ce,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(B,{children:jsxRuntime.jsx(Mt,{size:100,theme:e})}),jsxRuntime.jsxs(H,{children:[jsxRuntime.jsxs(M,{children:["Bridge Funds ",jsxRuntime.jsx("br",{})," to Fuel Ignition"]}),jsxRuntime.jsx(Q,{children:"Looks like you don't have ETH balance, bridge funds to Fuel Ignition and use the application without stopping."})]}),jsxRuntime.jsx(I,{href:o??"",target:"_blank",children:"Bridge now"}),jsxRuntime.jsx(W,{onClick:()=>T(!0),children:"Continue to application"})]})})]})})}var he=({query:e}={})=>{let{fuel:t}=l();return u("currentConnector",{queryKey:n.currentConnector(),queryFn:async()=>await t.isConnected()?t.currentConnector()??null:null,placeholderData:null,...e})};var R=e=>{let{fuel:t}=l();return u("isConnected",{queryKey:n.isConnected(),queryFn:async()=>{try{return await t.isConnected()||!1}catch{return !1}},placeholderData:!1,...e?.query,refetchInterval:1e3})};var Yt=e=>{let{fuel:t}=l(),{isConnected:r}=R();return u("network",{queryKey:n.currentNetwork(),queryFn:async()=>{let o=await t.currentNetwork();if(!o&&r)throw new Error("Network not found");return o},placeholderData:null,refetchOnMount:!0,refetchInterval:o=>!o.state.data||o.state.error?4e3:!1,enabled:r,...e?.query})};function Ce(e){let{networks:t}=l(),{network:r}=Yt(),{isConnected:o}=R(),{currentConnector:a}=he();return u("isSupportedNetwork",{queryKey:n.isSupportedNetwork(a?.name,t,r,o),queryFn:async()=>{if(!a||!o||!r)return !0;let c=r.chainId;return c==null&&(c=(await fuels.Provider.create(r.url)).getChainId()),!!t.find(s=>s.chainId===c)},placeholderData:!0,...e})}var _t="0.8em",fo={position:"relative",padding:"calc(0.8em + 4px) 16px 0.8em 16px"},Vt=({children:e})=>jsxRuntime.jsx("div",{style:fo,children:e}),yo={display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--fuel-items-gap)"},Zt=({children:e})=>jsxRuntime.jsx("div",{style:yo,children:e}),go={textAlign:"center",fontSize:"1.2em",fontWeight:500,color:"var(--fuel-color-bold)",lineHeight:1},Gt=({children:e})=>jsxRuntime.jsx("h2",{style:go,children:e}),Co={height:"1px",width:"100%",backgroundColor:"var(--fuel-separator-color)",margin:"10px 0",boxSizing:"border-box"},Ee=()=>jsxRuntime.jsx("div",{style:Co}),ho={margin:"20px 20px 0 20px",display:"flex",flexDirection:"column",alignItems:"center",gap:_t,marginBottom:_t},$t=({children:e})=>jsxRuntime.jsx("div",{style:ho,children:e}),Jt={fontWeight:400,textAlign:"center",lineHeight:"1.2em",color:"var(--fuel-gray-11)",marginBottom:"10px",marginTop:"10px"},Xt=({children:e})=>jsxRuntime.jsx("p",{style:Jt,children:e}),vo={...Jt,marginBottom:"4px",marginTop:"4px"},Qe=({children:e})=>jsxRuntime.jsx("p",{style:vo,children:e}),xo={fontWeight:400,textAlign:"center",lineHeight:"1.2em",opacity:.8,color:"var(--fuel-color-error)"},jt=({children:e})=>jsxRuntime.jsx("div",{style:xo,children:e}),Ue={width:"100%",height:"40px",display:"flex",borderRadius:"11px",textDecoration:"none",justifyContent:"center",alignItems:"center",margin:"0.4rem 0",fontSize:"0.875em",marginBottom:0,color:"var(--fuel-black-color)"},er=e=>jsxRuntime.jsx("input",{style:Ue,...e,className:"fuel-connectors-button-base fuel-connectors-button"}),bo={...Ue,backgroundColor:"var(--fuel-button-background)",color:"var(--fuel-color-bold)"},tr=e=>jsxRuntime.jsx("input",{style:bo,...e,className:"fuel-connectors-button-base fuel-connectors-button-disconnect"}),So={fontWeight:400,textAlign:"center",lineHeight:1,color:"var(--fuel-gray-11)"},rr=({children:e})=>jsxRuntime.jsx("div",{style:So,children:e}),wo={...Ue,marginBottom:0},or=({children:e,...t})=>jsxRuntime.jsx("div",{style:wo,...t,className:"fuel-connectors-button-base",children:e});function nr({theme:e}){let{networks:t}=l(),{disconnect:r}=ar(),{currentConnector:o}=he(),{isSupportedNetwork:a}=Ce(),{selectNetwork:c,isError:s,error:d,isPending:p}=ir(),{isConnected:S}=R(),{data:f}=reactQuery.useQuery({queryKey:["chainName",t[0]],queryFn:async()=>t[0].url?(await fuels.Provider.create(t[0].url)).getChain().name:"",placeholderData:""});function T(){t[0].chainId!=null&&c({chainId:t[0].chainId});}function L(){r();}function g(){return s&&(d?.message==="Method not implemented."||d?.message==="Method not found")?"The selected Wallet does not support switching networks, please switch manually in your wallet.":s?d?.message||"Failed to switch network":""}return t==null||!S?null:jsxRuntime.jsx(_,{open:!a&&!!f,theme:e,children:jsxRuntime.jsx(Y,{"data-connector":!!o,onPointerDownOutside:N=>{N.preventDefault();},onEscapeKeyDown:N=>{N.preventDefault();},children:jsxRuntime.jsx(Vt,{children:jsxRuntime.jsxs(Zt,{children:[jsxRuntime.jsxs($t,{children:[jsxRuntime.jsx(Gt,{children:"Network Switch Required"}),jsxRuntime.jsx(Xt,{children:"This app does not support the current connected network."}),f&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Qe,{children:"Switch to:"}),jsxRuntime.jsx(Qe,{children:jsxRuntime.jsx("span",{style:{fontWeight:"bold"},children:f})})]}),!!s&&jsxRuntime.jsx(jt,{children:g()})]}),!p&&jsxRuntime.jsx(er,{type:"button",disabled:p,onClick:T,value:"Switch Network"}),p&&jsxRuntime.jsx(or,{children:jsxRuntime.jsx(de,{size:26,color:"var(--fuel-loader-background)"})}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"6px",width:"100%"},children:[jsxRuntime.jsx(Ee,{}),jsxRuntime.jsx(rr,{children:"or"}),jsxRuntime.jsx(Ee,{})]}),jsxRuntime.jsx(tr,{type:"button",onClick:L,value:"Disconnect",color:"var(--fuel-border-color)"})]})})})})}function sr(){let{fuel:e}=l(),t=reactQuery.useQueryClient();function r(){t.invalidateQueries({queryKey:n.account()}),t.invalidateQueries({queryKey:n.isConnected()}),t.invalidateQueries({queryKey:n.wallet()}),t.invalidateQueries({queryKey:n.balance()}),t.invalidateQueries({queryKey:n.provider()}),t.invalidateQueries({queryKey:n.nodeInfo()}),t.invalidateQueries({queryKey:n.accounts()}),t.invalidateQueries({queryKey:n.currentConnector()});}async function o(){t.resetQueries({queryKey:n.connectorList(),exact:!0}),t.invalidateQueries({queryKey:n.currentConnector()});}function a(){t.invalidateQueries({queryKey:n.account()}),t.invalidateQueries({queryKey:n.wallet()}),t.invalidateQueries({queryKey:n.balance()});}function c(){t.invalidateQueries({queryKey:n.currentConnector()}),t.invalidateQueries({queryKey:n.isConnected()}),t.invalidateQueries({queryKey:n.account()}),t.invalidateQueries({queryKey:n.wallet()}),t.invalidateQueries({queryKey:n.balance()}),t.invalidateQueries({queryKey:n.provider()}),t.invalidateQueries({queryKey:n.nodeInfo()}),t.invalidateQueries({queryKey:n.accounts()}),t.resetQueries({queryKey:n.connectorList(),exact:!0});}function s(){t.invalidateQueries({queryKey:n.currentNetwork()}),t.invalidateQueries({queryKey:n.networks()}),t.invalidateQueries({queryKey:n.provider()}),t.invalidateQueries({queryKey:n.transactionReceipts()}),t.invalidateQueries({queryKey:n.chain()}),t.invalidateQueries({queryKey:n.nodeInfo()});}function d(){t.invalidateQueries({queryKey:n.account()}),t.invalidateQueries({queryKey:n.accounts()});}function p(){t.invalidateQueries({queryKey:n.assets()});}return react.useEffect(()=>(e.on(e.events.currentAccount,a),e.on(e.events.currentConnector,r),e.on(e.events.connectors,o),e.on(e.events.connection,c),e.on(e.events.accounts,d),e.on(e.events.currentNetwork,s),e.on(e.events.assets,p),()=>{e.off(e.events.currentConnector,r),e.off(e.events.currentAccount,a),e.off(e.events.connectors,o),e.off(e.events.connection,c),e.off(e.events.accounts,d),e.off(e.events.currentNetwork,s),e.off(e.events.assets,p);}),[e,t]),null}var cr=react.createContext(null),l=()=>{let e=react.useContext(cr);if(!e)throw new Error("useFuel must be used within a FuelHooksProvider");return e},Ae=({children:e,fuelConfig:t,networks:r})=>{let o=react.useRef(new fuels.Fuel(t));return jsxRuntime.jsxs(cr.Provider,{value:{fuel:o.current,networks:r},children:[jsxRuntime.jsx(sr,{}),e]})};function Nc({theme:e,children:t,fuelConfig:r,uiConfig:o,ui:a=!0,networks:c}){let s=e||"light",{networks:d}=ge(c),p=react.useMemo(()=>Object.assign({suggestBridge:!0},o??{}),[o]);return a?jsxRuntime.jsx(Ae,{fuelConfig:r,networks:d,children:jsxRuntime.jsxs(Xe,{theme:s,fuelConfig:r,uiConfig:p,children:[jsxRuntime.jsx(qt,{}),jsxRuntime.jsx(nr,{theme:s}),p.suggestBridge&&jsxRuntime.jsx(Ht,{theme:s}),t]})}):jsxRuntime.jsx(Ae,{fuelConfig:r,networks:d,children:t})}var Ot=e=>{let{fuel:t}=l();return u("account",{queryKey:n.account(),queryFn:async()=>{try{return await t?.currentAccount()}catch{return null}},placeholderData:null,...e?.query})};var Oc=e=>{let{fuel:t}=l();return u("accounts",{queryKey:n.accounts(),queryFn:async()=>{try{return await t.accounts()}catch{return []}},placeholderData:[],...e?.query})};var Gc=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationKey:[j.addAssets],mutationFn:async a=>Array.isArray(a)?e.addAssets(a):e.addAsset(a)});return {addAssets:t,addAssetsAsync:r,...o}};var tl=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationKey:[j.addNetwork],mutationFn:async a=>e.addNetwork(a)});return {addNetwork:t,addNetworkAsync:r,...o}};var sl=e=>{let{fuel:t}=l();return u("assets",{queryKey:n.assets(),queryFn:async()=>{try{return await t.assets()}catch{return []}},placeholderData:[],...e?.query})};var h=e=>{let{fuel:t,networks:r}=l();return u("provider",{queryKey:n.provider(),queryFn:async()=>{let o=await t.currentNetwork(),a=r.find(s=>s.chainId===o.chainId);if(!a?.url){let s=await t.getProvider();return console.warn("Please provide a networks with a RPC url configuration to your FuelProvider getProvider will be removed."),s||null}let c=await fuels.Provider.create(a.url);if(c.getChainId()!==o.chainId)throw new Error(`The provider's chainId (${c.getChainId()}) does not match the current network's chainId (${o.chainId})`);return c},placeholderData:null,...e?.query})};var zt=({address:e,account:t,assetId:r,query:o})=>{let{provider:a}=h(),c=t??e??void 0;return u("balance",{queryKey:n.balance(c,r,a),queryFn:async()=>{try{if(!a)throw new Error("Provider is needed");let s=r||a.getBaseAssetId();return await a.getBalance(fuels.Address.fromString(c||""),s)||null}catch{return null}},placeholderData:null,enabled:!!a&&!!c,...o})};var Tl=e=>{let{provider:t}=h();return u("chain",{queryKey:n.chain(),queryFn:async()=>{try{return await t?.getChain()||null}catch{return null}},placeholderData:null,enabled:!!t,...e?.query})};var Ho=e=>"functions"in e,Fl=({contract:e,functionName:t,args:r})=>{let o=Ho(e),a=e?.provider?.getChainId();return u("contractRead",{queryKey:n.contract(o?e?.id?.toString():e?.address?.toString(),a,r?.toString()),queryFn:async()=>{if(!(o?!!e&&"provider"in e:!!e.abi&&!!e.address&&!!e.provider))throw new Error("Invalid input `contract` is required to read the contract");let s=o?e:new fuels.Contract(e.address,e.abi,e.provider);if(!s?.functions?.[t])throw new Error(`Function ${t||""} not found on contract`);if(s.functions[t].isReadOnly?.()!==void 0?!s.functions[t].isReadOnly():Object.values(s.interface.functions).find(p=>p.name===t)?.attributes?.find(p=>p.name==="storage")?.arguments?.includes("write"))throw new Error("Methods that write to storage should not be called with useContractRead");return r!==void 0?s.functions[t](r):s.functions[t]()},placeholderData:void 0})};var ar=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationFn:async()=>e?.disconnect()});return {disconnect:t,disconnectAsync:r,...o}};var Wl=e=>{let{fuel:t}=l();return u("networks",{queryKey:n.networks(),queryFn:t.networks,placeholderData:[],...e?.query})};var zo=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Le=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");let t=e.match(zo);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},lr=e=>e==="*"||e==="x"||e==="X",ur=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},Yo=(e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t],_o=(e,t)=>{if(lr(e)||lr(t))return 0;let[r,o]=Yo(ur(e),ur(t));return r>o?1:r<o?-1:0},qe=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){let o=_o(e[r]||"0",t[r]||"0");if(o!==0)return o}return 0};var pr=(e,t)=>{let r=Le(e),o=Le(t),a=r.pop(),c=o.pop(),s=qe(r,o);return s!==0?s:a&&c?qe(a.split("."),c.split(".")):a||c?a?-1:1:0};var Ke=(e,t,r)=>{Vo(r);let o=pr(e,t);return mr[r].includes(o)},mr={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},dr=Object.keys(mr),Vo=e=>{if(dr.indexOf(e)===-1)throw new Error(`Invalid operator, expected one of ${dr.join("|")}`)};var au=({version:e="0.0.0",query:t}={})=>{let{provider:r}=h(),o=u("nodeInfo",{queryKey:n.nodeInfo(r?.url),queryFn:()=>{try{return r?.fetchNode()||null}catch{return null}},placeholderData:null,enabled:!!r,...t});return new Proxy(o,{get(a,c){return c==="isCompatible"?a.nodeInfo?.nodeVersion?Ke(a.nodeInfo?.nodeVersion,e,">="):null:Reflect.get(a,c)}})};var ir=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationFn:e.selectNetwork});return {selectNetwork:t,selectNetworkAsync:r,...o}};var yu=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationFn:({address:a,transaction:c})=>{let s=fuels.Address.fromDynamicInput(a).toString();return e.sendTransaction(s,c)}});return {sendTransaction:t,sendTransactionAsync:r,...o}};var bu=e=>{let{fuel:t}=l();return u("transaction",{queryKey:n.transaction(e),queryFn:async()=>{try{let r=await t?.getProvider();return r?await r.getTransaction(e||""):null}catch{return null}},placeholderData:null,enabled:!!e})};var Ru=({txId:e,query:t})=>{let{provider:r}=h();return u("transactionReceipts",{queryKey:n.transactionReceipts(e,r),queryFn:async()=>{try{if(!r)return null;let o=new fuels.TransactionResponse(e||"",r);if(!o)return null;let{receipts:a}=await o.waitForResult();return a||null}catch{return null}},placeholderData:null,enabled:!!e,...t})};var Au=({txId:e="",query:t={}})=>{let{provider:r}=h(),{name:o="transactionResult",...a}=t;return u(o,{queryKey:n.transactionResult(e,r),queryFn:async()=>r&&await new fuels.TransactionResponse(e,r).waitForResult()||null,placeholderData:null,enabled:!!e,...a})};function Ou(e){let{fuel:t}=l(),{provider:r}=h(),o=typeof e=="string"?{account:e}:e??{};return u("wallet",{queryKey:n.wallet(o.account,r),queryFn:async()=>{try{if(!r)return null;let a=o.account||await t.currentAccount()||"";await fuels.Address.fromString(a);let c=await t.getWallet(a);return c.connect(r),c||null}catch{return null}},placeholderData:null,...o.query})} | ||
function hr(e){return {get(r,o){return o===e?Reflect.get(r,"data"):Reflect.get(r,o)}}}function d(e,t,r){let o=reactQuery.useQuery(t,r);return react.useMemo(()=>new Proxy(o,hr(e)),[e,o])}var Ze=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationFn:async a=>(a&&await e.selectConnector(a),e.connect())});return {connect:t,connectAsync:r,...o}};var n={base:["fuel"],account:()=>n.base.concat("account"),accounts:()=>n.base.concat("accounts"),assets:()=>n.base.concat("assets"),contract:(e,t,r)=>{let o=n.base.concat("contract").concat(e);return typeof r<"u"&&o.push(r),typeof t<"u"&&o.push(t),o},chain:()=>n.base.concat("chain"),isConnected:()=>n.base.concat("isConnected"),networks:()=>n.base.concat("networks"),provider:()=>n.base.concat("provider"),balance:(e,t,r)=>{let o=n.base.concat("balance");return e&&o.push(e),t&&o.push(t),r?.getChainId?.()!==void 0&&o.push(r.getChainId()),o},wallet:(e,t)=>{let r=n.base.concat("wallet");return e&&r.push(e),t&&r.push(t),r},transaction:e=>{let t=n.base.concat("transaction");return e&&t.push(e),t},transactionReceipts:(e,t)=>{let r=n.transaction(e).concat("receipts");return t?.getChainId?.()!==void 0&&r.push(t.getChainId()),r},transactionResult:(e,t)=>{let r=n.transaction(e).concat("result");return t?.getChainId?.()!==void 0&&r.push(t.getChainId()),r},nodeInfo:e=>{let t=n.base.concat("nodeInfo");return e&&t.push(e),t},connectorList:()=>n.base.concat("connectorList"),currentConnector:()=>n.base.concat(["currentConnector"]),currentNetwork:()=>n.base.concat("currentNetwork"),isSupportedNetwork:(e,t,r,o)=>{let a=n.base.concat("isSupportedNetwork");return e&&a.push(e),t&&a.push(t),r&&a.push(r),o&&a.push(o),a}},j={connect:"connect",addAssets:"addAssets",addNetwork:"addNetwork"};var k=["Bako Safe","Burner Wallet","Fuel Wallet","Fuel Wallet Development","Fuelet Wallet"],Pe=[{chainId:fuels.CHAIN_IDS.fuel.testnet,bridgeURL:"https://app-testnet.fuel.network/bridge?from=eth&to=fuel&auto_close=true"},{chainId:fuels.CHAIN_IDS.fuel.devnet,bridgeURL:"https://app-devnet.fuel.network/bridge?from=eth&to=fuel&auto_close=true"},{chainId:fuels.CHAIN_IDS.fuel.mainnet,bridgeURL:"https://app.fuel.network/bridge?from=eth&to=fuel&auto_close=true"}];function Ge(e){return k.includes(e?.name)}var $e=({query:e}={})=>{let{fuel:t}=l();return d("connectors",{queryKey:n.connectorList(),queryFn:async()=>t.connectors(),placeholderData:[],...e})};var je=react.createContext(null);var v=()=>{let e=react.useContext(je);if(!e)throw new Error("useConnectUI must be used within a FuelUIProvider");return e},Sr=e=>e.sort((t,r)=>{if(t.connected!==r.connected)return t.connected?-1:1;let o=k.includes(t.name)&&t.installed,a=k.includes(r.name)&&r.installed;return o!==a?o?-1:1:t.name.localeCompare(r.name)});function et({fuelConfig:e,children:t,theme:r,uiConfig:o}){let{isPending:a,isError:c,connectAsync:i}=Ze(),{connectors:u,isLoading:p}=$e({query:{select:Sr}}),{isConnected:y}=R(),[f,w]=react.useState(null),[L,C]=react.useState("list"),[N,$]=react.useState(!1),[We,q]=react.useState(null);react.useEffect(()=>{if(!f)return;let m=u.find(Se=>Se.name===f.name);m&&f.installed!==m?.installed&&w(m);},[u,f]);let He=react.useCallback(()=>{q(null),w(null),C("list");},[]),J=react.useCallback(async m=>{try{q(null),await i(m.name);}catch(Se){q(Se);}},[i]),X=react.useCallback(async m=>{C("connecting"),await J(m);},[J]),Oe=react.useCallback(async m=>{w(m),m.installed?Ge(m)?X(m):C("disclaimer"):C("install");},[X]),ze=react.useCallback(m=>{C(m);},[]),Ye=react.useMemo(()=>{let m=(e.connectors||[]).length>u.length;return p||m},[u,p,e]),_e=react.useCallback(()=>{w(null),q(null),C("list"),$(!0);},[]),Ve=react.useCallback(({clean:m}={})=>{q(null),$(!1),m&&(w(null),C("list"));},[]);react.useEffect(()=>{let m=document.createElement("style");return m.appendChild(document.createTextNode(`@import url("https://fonts.googleapis.com/css2?family=Inter:opsz,wght@14..32,100..900&display=swap"); .fuel-connectors * { box-sizing: border-box; } .fuel-connectors .fuel-connectors-dialog-content:focus { outline: none; } @media (max-width: 430px) { .fuel-connectors .fuel-connectors-dialog-content { top: 50%; width: 100%; border-radius: 36px; } } .fuel-connectors .fuel-connectors-connector-item { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-connector-background); } .fuel-connectors .fuel-connectors-connector-item:active { opacity: 0.8; } .fuel-connectors .fuel-connectors-connector-item:hover { background-color: var(--fuel-connector-hover); } .fuel-connectors .fuel-connectors-connector-button { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-button-background); color: var(--fuel-color-bold); } .fuel-connectors .fuel-connectors-connector-button:visited { color: var(--fuel-color-bold); } .fuel-connectors .fuel-connectors-connector-button:hover { background-color: var(--fuel-button-background-hover); } .fuel-connectors .fuel-connectors-connector-button-primary { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-green-11); color: var(--fuel-black-color); } .fuel-connectors .fuel-connectors-connector-button-primary:visited { color: var(--fuel-black-color); } .fuel-connectors .fuel-connectors-connector-button-primary:hover { background-color: var(--fuel-green-11); } .fuel-connectors .fuel-connectors-back-icon { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); } .fuel-connectors .fuel-connectors-back-icon[data-connector='false'] { visibility: hidden; } .fuel-connectors .fuel-connectors-back-icon:hover, .fuel-connectors .fuel-connectors-back-icon:active { opacity: 1; background-color: var(--fuel-connector-hover); } .fuel-connectors .fuel-connectors-close-icon { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); } .fuel-connectors .fuel-connectors-close-icon:hover, .fuel-connectors .fuel-connectors-close-icon:active { opacity: 1; background-color: var(--fuel-connector-hover); } .fuel-connectors .fuel-connectors-button-base { cursor: pointer; } .fuel-connectors .fuel-connectors-button:disabled { cursor: not-allowed; } .fuel-connectors .fuel-connectors-button { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-green-11); } .fuel-connectors .fuel-connectors-button:disabled { background-color: var(--fuel-border-color); } .fuel-connectors .fuel-connectors-button-disconnect { transition: background-color 50ms cubic-bezier(0.16, 1, 0.3, 1); background-color: var(--fuel-button-background); } .fuel-connectors .fuel-connectors-button-disconnect:hover { background-color: var(--fuel-button-background-hover); } @keyframes fuelOverlayShow { from { opacity: 0; } to { opacity: 1; } } @keyframes fuelSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } } @keyframes fuelContentShow { from { opacity: 0; transform: translate(-50%, -48%) scale(0.96); } to { opacity: 1; transform: translate(-50%, -50%) scale(1); } } @keyframes fuelLoader { 0% { background-position: -468px 0 } 100% { background-position: 468px 0 } }`)),document.head.appendChild(m),()=>{document.head.removeChild(m);}},[]);let yr=react.useMemo(()=>({theme:r||"light",fuelConfig:e,uiConfig:o,error:We,setError:q,isConnected:!!y,isConnecting:a,isLoading:Ye,isError:c,connectors:u,connect:_e,cancel:Ve,dialog:{route:L,setRoute:ze,connector:f,isOpen:N,connect:Oe,retryConnect:J,back:He,_startConnection:X}}),[r,e,o,We,y,a,Ye,c,u,f,L,N,Ve,X,ze,Oe,_e,J,He]);return jsxRuntime.jsx(je.Provider,{value:yr,children:t})}function tt({size:e,...t}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 490 496",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[jsxRuntime.jsx("title",{children:"FuelWallet Development Icon"}),jsxRuntime.jsx("rect",{x:"42.509",y:"28.3438",width:"396.739",height:"425.143",fill:"#00F58C"}),jsxRuntime.jsx("path",{d:"M32.5836 0C14.5545 0 0 14.7327 0 32.9826V496H405.427C419.129 496 432.307 490.492 442.01 480.67L474.856 447.422C484.559 437.6 490 424.261 490 410.391V0H32.5836ZM319.936 63.7752L160.558 225.105C156.624 229.086 151.248 231.343 145.676 231.343C137.546 231.343 130.072 226.565 126.598 219.132L64.8394 87.0024C59.7913 76.1852 67.593 63.7752 79.3939 63.7752H319.936ZM63.0037 432.225V275.275C63.0037 266.914 69.6909 260.145 77.9516 260.145H233.002L63.0037 432.225ZM245.852 231.343H194.518L348.979 74.9906C356.06 67.8234 365.697 63.7752 375.728 63.7752H427.062L272.601 220.127C265.521 227.295 255.883 231.343 245.852 231.343Z",fill:"#080808"})]})}function rt({size:e,...t}){return jsxRuntime.jsxs("svg",{width:e,height:e,viewBox:"0 0 491 496",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:[jsxRuntime.jsx("title",{children:"Fuel Wallet Icon"}),jsxRuntime.jsx("rect",{x:"42.5535",y:"28.3438",width:"397.154",height:"425.143",fill:"#080808"}),jsxRuntime.jsx("path",{d:"M32.6178 0C14.5697 0 0 14.7327 0 32.9826V496H405.852C419.568 496 432.759 490.492 442.473 480.67L475.353 447.422C485.066 437.6 490.513 424.261 490.513 410.391V0H32.6178ZM320.271 63.7752L160.726 225.105C156.788 229.086 151.407 231.343 145.828 231.343C137.69 231.343 130.208 226.565 126.73 219.132L64.9074 87.0024C59.8539 76.1852 67.6638 63.7752 79.4771 63.7752H320.271ZM63.0697 432.225V275.275C63.0697 266.914 69.7639 260.145 78.0332 260.145H233.246L63.0697 432.225ZM246.11 231.343H194.722L349.345 74.9906C356.433 67.8234 366.08 63.7752 376.121 63.7752H427.509L272.887 220.127C265.799 227.295 256.151 231.343 246.11 231.343Z",fill:"#00F58C"})]})}function nt({theme:e,size:t,...r}){return jsxRuntime.jsxs("svg",{width:t,height:t,viewBox:"0 0 40 40",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r,children:[jsxRuntime.jsx("title",{children:"Fuelet Icon"}),jsxRuntime.jsx("path",{d:"M20 40C14.9355 40 10.3145 38.114 6.7905 35.0105L18.146 26.907C18.845 26.4085 19.8065 26.9645 19.722 27.8195L19.2745 32.3605C19.182 33.295 20.3125 33.8295 20.9765 33.1655L27.071 27.071C31.062 23.08 30.9745 16.5555 26.8085 12.6755C22.8405 8.98 16.5935 9.264 12.7595 13.0985L6.853 19.0045C6.187 19.671 6.7275 20.8045 7.6645 20.7065L12.209 20.231C13.0655 20.1415 13.6275 21.105 13.127 21.8065L4.9895 33.2095C1.886 29.6855 0 25.0645 0 20C0 8.9545 8.9545 0 20 0C31.0455 0 40 8.9545 40 20C40 31.0455 31.0455 40 20 40Z",fill:e==="dark"?"white":"#28282F"})]})}var at=(e,t)=>{let{image:r}=e;return typeof r=="object"?t==="dark"?r.dark:r.light:r};function K({connectorName:e,connectorMetadata:t,...r}){switch(e){case"Fuelet Wallet":return jsxRuntime.jsx(nt,{...r});case"Fuel Wallet":return jsxRuntime.jsx(rt,{...r});case"Fuel Wallet Development":return jsxRuntime.jsx(tt,{...r});default:return t.image?jsxRuntime.jsx("img",{height:`${r.size}px`,width:`${r.size}px`,src:at(t,r.theme),alt:`${e} icon`}):null}}var ke={textAlign:"center",fontSize:"1.2em",fontWeight:500,color:"var(--fuel-color-bold)",margin:"0 0 0.4em 0",padding:"0 1.8em"},M=({children:e})=>jsxRuntime.jsx("h2",{style:ke,children:e}),re={color:"var(--fuel-gray-12)",fontSize:"0.9em",fontWeight:400,textAlign:"center",margin:"0 1.2em",lineHeight:"1.2em",padding:"0 2em",opacity:.8},Q=({children:e})=>jsxRuntime.jsx("p",{style:re,children:e}),kr={color:"var(--fuel-gray-12)",fontSize:"0.8em",fontWeight:400,textAlign:"center",margin:"2em auto 0",lineHeight:"1.2em",padding:"0 2em",opacity:.5},st=({children:e})=>jsxRuntime.jsx("p",{style:kr,children:e}),Rr={...re,color:"var(--fuel-color-error)"},it=({children:e})=>jsxRuntime.jsx("p",{style:Rr,children:e}),Dr={display:"flex",justifyContent:"center",height:"6.2em",width:"100%",marginTop:"1.6em",marginBottom:"1.2em"},B=({children:e})=>jsxRuntime.jsx("div",{style:Dr,children:e}),ct={display:"flex",boxSizing:"border-box",textDecoration:"none",cursor:"pointer",justifyContent:"center",alignItems:"center",margin:"0.4rem 1rem 0",padding:"0.6rem 0",fontSize:"0.875em",borderRadius:"var(--fuel-border-radius)"},W=({href:e,children:t,style:r,...o})=>jsxRuntime.jsx("a",{href:e,style:ct,...o,className:"fuel-connectors-connector-button",children:t}),Re={display:"flex",flexDirection:"column",gap:"8px",marginBottom:"24px"},H=({children:e})=>jsxRuntime.jsx("div",{style:Re,children:e}),D=({href:e,children:t,...r})=>jsxRuntime.jsx("a",{href:e,style:ct,...r,className:"fuel-connectors-connector-button-primary",children:t});function ut(){let{theme:e,dialog:{connector:t,setRoute:r}}=v();if(!t)return null;let{install:{action:o,link:a,description:c}}=t.metadata;react.useEffect(()=>{(async()=>{await t.ping()&&r("connecting");})();},[t,r]);let i=o||"Install";return jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(B,{children:jsxRuntime.jsx(K,{connectorMetadata:t.metadata,connectorName:t.name,size:100,theme:e})}),jsxRuntime.jsxs(H,{children:[jsxRuntime.jsx(M,{children:t.name}),jsxRuntime.jsx(Q,{children:c})]}),jsxRuntime.jsx(D,{href:a,target:"_blank",children:i}),jsxRuntime.jsxs(st,{children:["If you have installed it and it is not detected,",jsxRuntime.jsx("br",{}),"try refreshing the page."]})]})}var Fr={display:"flex",alignItems:"center",boxSizing:"border-box",cursor:"pointer",width:"100%",gap:"var(--fuel-items-gap)",padding:"0.8em",borderRadius:"16px",fontWeight:400},oe=({children:e,...t})=>jsxRuntime.jsx("div",{style:Fr,...t,className:"fuel-connectors-connector-item",children:e}),Er={display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--fuel-items-gap)",padding:"0px 14px"},Ie=({children:e})=>jsxRuntime.jsx("div",{style:Er,children:e}),Qr={fontSize:"0.875em"},ne=({children:e})=>jsxRuntime.jsx("div",{style:Qr,children:e});var pt={borderRadius:"var(--fuel-border-radius)",fontSize:"var(--fuel-font-size-xs)",padding:"2px 8px",textTransform:"uppercase",marginLeft:"auto"},dt=({children:e})=>{let t={...pt,backgroundColor:"var(--fuel-blue-3)",color:"var(--fuel-blue-11)"};return jsxRuntime.jsx("div",{style:t,children:e})},mt=({children:e})=>{let t={...pt,backgroundColor:"var(--fuel-green-3)",color:"var(--fuel-green-11)"};return jsxRuntime.jsx("div",{style:t,children:e})},ft={width:"100%",color:"#797979",fontSize:"var(--fuel-font-size-xs)",fontStyle:"normal",fontWeight:400,margin:0},yt=({children:e})=>jsxRuntime.jsx("p",{style:ft,children:e}),gt=({children:e})=>{let t={...ft,marginTop:"14px"};return jsxRuntime.jsx("p",{style:t,children:e})};function ht({name:e,connected:t,installed:r}){let o=react.useMemo(()=>!k.includes(e),[e]);return t?jsxRuntime.jsx(mt,{children:"Connected"}):!o&&r?jsxRuntime.jsx(dt,{children:"Installed"}):null}var Lr=({connect:e,theme:t,connector:r,index:o})=>jsxRuntime.jsxs(oe,{tabIndex:o+1,"aria-label":`Connect to ${r.name}`,"data-installed":r.installed,"data-connected":r.connected,onClick:a=>{a.preventDefault(),e(r);},children:[jsxRuntime.jsx(K,{connectorMetadata:r.metadata,connectorName:r.name,size:32,theme:t}),jsxRuntime.jsx(ne,{children:r.name}),jsxRuntime.jsx(ht,{name:r.name,connected:r.connected,installed:r.installed})]},r.name),Ee=react.memo(Lr);function xt({size:e,...t}){return jsxRuntime.jsxs("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",...t,children:[jsxRuntime.jsx("title",{children:"Back Icon"}),jsxRuntime.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M11.04 1.46a1 1 0 0 1 0 1.41L5.91 8l5.13 5.13a1 1 0 1 1-1.41 1.41L3.79 8.71a1 1 0 0 1 0-1.42l5.84-5.83a1 1 0 0 1 1.41 0Z",clipRule:"evenodd"})]})}function St({size:e,...t}){return jsxRuntime.jsxs("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",width:e,height:e,viewBox:"0 0 16 16",...t,children:[jsxRuntime.jsx("title",{children:"Close Icon"}),jsxRuntime.jsx("path",{fill:"currentColor",fillRule:"evenodd",d:"M2.54 2.54a1 1 0 0 1 1.42 0L8 6.6l4.04-4.05a1 1 0 1 1 1.42 1.42L9.4 8l4.05 4.04a1 1 0 0 1-1.42 1.42L8 9.4l-4.04 4.05a1 1 0 0 1-1.42-1.42L6.6 8 2.54 3.96a1 1 0 0 1 0-1.42Z",clipRule:"evenodd"})]})}var Br={display:"flex",alignItems:"center",justifyContent:"space-between",paddingLeft:"16px",paddingRight:"16px"},ae=({children:e,...t})=>jsxRuntime.jsx("div",{style:Br,...t,children:e}),Wr={padding:"8px 14px 12px",margin:0,textAlign:"center",fontSize:"var(--fuel-font-size)",fontWeight:500},se=({children:e,...t})=>jsxRuntime.jsx(ye__namespace.Title,{style:Wr,...t,children:e}),Hr={height:"1px",width:"100%",backgroundColor:"var(--fuel-border-color)",margin:"10px 0",padding:0},ie=e=>jsxRuntime.jsx("div",{style:Hr,...e}),Or={position:"relative",overflowY:"auto"},ce=e=>jsxRuntime.jsx("div",{style:Or,...e}),zr={fill:"var(--fuel-color)",padding:"7px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},le=({size:e,...t})=>jsxRuntime.jsx(xt,{size:e,style:zr,...t,className:"fuel-connectors-back-icon"}),Yr={fill:"var(--fuel-color)",padding:"7px",borderRadius:"12px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},ue=({size:e,...t})=>jsxRuntime.jsx(St,{size:e,style:Yr,...t,className:"fuel-connectors-close-icon"});var _r={animationDuration:"1s",animationFillMode:"forwards",animationIterationCount:"infinite",animationName:"fuelLoader",animationTimingFunction:"linear",backgroundColor:"#d1d5d9",background:"var(--fuel-loader-background)",backgroundSize:"1000px 104px",height:"fit-content",position:"relative",overflow:"hidden",color:"transparent",pointerEvents:"none"},Qe=({children:e,...t})=>jsxRuntime.jsx("div",{style:_r,...t,children:e});function Pt({items:e}){return Array.from({length:e}).map((r,o)=>jsxRuntime.jsxs(oe,{children:[jsxRuntime.jsx(Qe,{children:jsxRuntime.jsx("div",{style:{height:32,width:32}})}),jsxRuntime.jsx(Qe,{children:jsxRuntime.jsx(ne,{children:"Fuel Wallet"})})]},o))}function wt(){let{fuelConfig:e,connectors:t,isLoading:r,theme:o,dialog:{connect:a}}=v(),{native:c,external:i}=react.useMemo(()=>{let p=t.filter(f=>!k.includes(f.name));return {native:t.filter(f=>k.includes(f.name)),external:p}},[t]),u=!!c.length&&!!i.length;return r?jsxRuntime.jsx(Ie,{children:jsxRuntime.jsx(Pt,{items:e.connectors?.length||2})}):jsxRuntime.jsxs(Ie,{children:[u&&jsxRuntime.jsx(yt,{children:"Fuel Native Wallets"}),c.map((p,y)=>jsxRuntime.jsx(Ee,{connect:a,theme:o,connector:p,index:y},p.name)),u&&jsxRuntime.jsx(gt,{children:"Non-Native Wallets"}),i.map((p,y)=>jsxRuntime.jsx(Ee,{connect:a,theme:o,connector:p,index:y},p.name))]})}var de=({size:e,color:t})=>{let r={height:`${e}px`,width:`${e}px`,border:"4px solid rgba(0, 0, 0, 0.1)",borderTopColor:t,borderRadius:"50%",animation:"fuelSpin 1s infinite linear"};return jsxRuntime.jsx("div",{style:r})};function Nt({className:e}){let{error:t,isConnecting:r,theme:o,cancel:a,dialog:{route:c,connector:i,retryConnect:u},isConnected:p}=v();return react.useEffect(()=>{p&&c==="connecting"&&!r&&a();},[p,c,r,a]),i?jsxRuntime.jsxs("div",{className:e,children:[jsxRuntime.jsx(B,{children:jsxRuntime.jsx(K,{connectorMetadata:i.metadata,connectorName:i.name,size:100,theme:o})}),jsxRuntime.jsxs(H,{children:[jsxRuntime.jsx(M,{children:i.name}),t?jsxRuntime.jsx(it,{children:t.message}):r?jsxRuntime.jsxs(Q,{children:["Requesting connection to ",jsxRuntime.jsx("br",{})," ",i.name,"."]}):jsxRuntime.jsxs(Q,{children:["Click on the button below to connect to ",location.origin,"."]})]}),r?jsxRuntime.jsx(W,{children:jsxRuntime.jsx(de,{size:26,color:"var(--fuel-loader-background)"})}):jsxRuntime.jsx(D,{onClick:()=>u(i),children:"Connect"})]}):null}var Xr={display:"flex",flexDirection:"column",overflow:"hidden",color:"var(--fuel-color)",userSelect:"none",maxHeight:"calc(100% - 20px)",backgroundColor:"var(--fuel-dialog-background)",position:"fixed",left:"50%",transform:"translate(-50%, -50%)",borderRadius:"36px",padding:"14px 0px",paddingBottom:"36px",animation:"fuelContentShow 150ms cubic-bezier(0.16, 1, 0.3, 1)",top:"50%",width:"360px",maxWidth:"calc(100% - 20px)",boxShadow:"hsl(206 22% 7% / 35%) 0px 10px 38px -10px, hsl(206 22% 7% / 20%) 0px 10px 20px -15px"},Y=e=>jsxRuntime.jsx(ye__namespace.Content,{style:Xr,...e,className:"fuel-connectors-dialog-content"});var eo={"--fuel-font-family":'"Inter", "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif',"--fuel-font-size":"16px","--fuel-font-size-xs":"12px","--fuel-letter-spacing":"-0.64px","--fuel-border-radius":"6px","--fuel-items-gap":"8px","--fuel-border":"1px solid var(--fuel-border-color)","--fuel-color-error":"#f25a68"},to={"--fuel-color":"#141414","--fuel-color-bold":"#000000","--fuel-dialog-background":"white","--fuel-overlay-background":"rgba(71,88,107,0.24)","--fuel-connector-background":"rgb(250 250 250)","--fuel-connector-hover":"rgb(241 243 244)","--fuel-border-color":"hsl(210deg 9.52% 83.53%)","--fuel-border-hover":"hsla(0, 0%, 78.04%, 1)","--fuel-button-background":"rgb(220 220 220)","--fuel-button-background-hover":"rgb(203 205 207)","--fuel-loader-background":"linear-gradient(to right, hsl(0, 0%, 92%) 8%, hsl(0, 0%, 85%) 18%, hsl(0, 0%, 92%) 33%)","--fuel-green-3":"#D9FCE3","--fuel-green-11":"#008347","--fuel-blue-3":"#E6F4FE","--fuel-blue-11":"#0D74CE","--fuel-gray-10":"#838383","--fuel-gray-11":"#646464","--fuel-gray-12":"#202020","--fuel-separator-color":"rgb(83 79 79 / 13%)","--fuel-black-color":"#FFFFFF"},ro={"--fuel-color":"#e4e7e7","--fuel-color-bold":"#ffffff","--fuel-dialog-background":"rgb(25 26 26)","--fuel-overlay-background":"rgba(20, 20, 20, 0.8)","--fuel-connector-background":"rgba(255, 255, 255, 0.02)","--fuel-connector-hover":"rgba(255, 255, 255, 0.05)","--fuel-border-color":"rgba(255, 255, 255, 0.05)","--fuel-border-hover":"hsla(0, 0%, 50%, 1)","--fuel-button-background":"hsla(0, 0%, 30%, 1)","--fuel-button-background-hover":"hsla(0, 0%, 40%, 1)","--fuel-loader-background":"linear-gradient(to right, hsl(0, 0%, 20%) 8%, hsl(0, 0%, 25%) 18%, hsl(0, 0%, 20%) 33%)","--fuel-green-3":"#0F2E1B","--fuel-green-11":"#00DD75","--fuel-blue-3":"#0D2847","--fuel-blue-11":"#70B9FF","--fuel-gray-10":"#7b7b7b","--fuel-gray-11":"#b4b4b4","--fuel-gray-12":"#eee","--fuel-separator-color":"rgb(165 165 165 / 13%)","--fuel-black-color":"#141414"},oo={light:to,dark:ro},Rt=e=>{let t=oo[e];return {...eo,...t}};var no={backgroundColor:"var(--fuel-overlay-background)",position:"fixed",inset:0,animation:"fuelOverlayShow 150ms cubic-bezier(0.16, 1, 0.3, 1)"},It=({children:e})=>jsxRuntime.jsx(ye__namespace.Overlay,{style:no,asChild:!0,children:e}),ao={position:"fixed",top:0,left:0,bottom:0,right:0,height:"100%",width:"100%",margin:0,padding:0,zIndex:99,fontFamily:"var(--fuel-font-family)",fontSize:"var(--fuel-font-size)"},Ft=({style:e,children:t})=>jsxRuntime.jsx("div",{className:"fuel-connectors",style:{...ao,...e},children:t});function _({children:e,theme:t,open:r,onOpenChange:o}){let[a,c]=react.useState(!1);return react.useEffect(()=>{c(!0);},[]),a?jsxRuntime.jsx(ye__namespace.Root,{open:r,onOpenChange:o,children:jsxRuntime.jsx(ye__namespace.Portal,{children:jsxRuntime.jsx(It,{children:jsxRuntime.jsx(Ft,{style:Rt(t),children:e})})})}):null}var co={...Re,gap:"12px",borderLeft:"2px solid",borderColor:"#F5CC00",marginLeft:"1rem",padding:"0.5em 2em",fontSize:"1em"},Qt=({children:e})=>jsxRuntime.jsx("div",{style:co,children:e}),lo={fontWeight:400,textAlign:"left",margin:0,paddingInlineStart:"16px",lineHeight:"1.4em",opacity:.8,listStyleType:"disc"},Ut=({children:e,...t})=>jsxRuntime.jsx("ul",{style:lo,...t,className:"fuel-connectors-disclaimer-list",children:e});function Lt(){let{dialog:{connector:e,_startConnection:t,back:r}}=v();return e?jsxRuntime.jsxs("div",{children:[jsxRuntime.jsxs(Qt,{children:[jsxRuntime.jsx("h2",{style:{...ke,color:"var(--fuel-color-bold)",fontSize:"1.2em",textAlign:"left",margin:0,padding:0},children:"Non-Native Wallet"}),jsxRuntime.jsx("p",{style:{...re,fontSize:"0.9em",textAlign:"left",margin:0,padding:0},children:"Fuel supports any wallet from Ethereum or Solana, but these wallets have limited functionality for now:"}),jsxRuntime.jsxs(Ut,{children:[jsxRuntime.jsxs("li",{children:[jsxRuntime.jsx("span",{style:{fontSize:"0.9em",fontWeight:600,color:"var(--fuel-gray-12)"},children:"Limited Balance Visibility"}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{style:{fontSize:"0.8em",color:"var(--fuel-gray-11)"},children:"You cannot see balances natively in the wallet (e.g. Metamask). You must visit the Fuel Block Explorer to see balances."})]}),jsxRuntime.jsxs("li",{style:{marginTop:5,marginBottom:5},children:[jsxRuntime.jsx("span",{style:{fontSize:"0.9em",fontWeight:600,color:"var(--fuel-gray-12)"},children:"Signatures are Blind"}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{style:{fontSize:"0.8em",color:"var(--fuel-gray-11)"},children:"Ensure you only use trusted applications."})]}),jsxRuntime.jsxs("li",{children:[jsxRuntime.jsx("span",{style:{fontSize:"0.9em",fontWeight:600,color:"var(--fuel-gray-12)"},children:"No Multi-Sigs"}),jsxRuntime.jsx("br",{}),jsxRuntime.jsx("span",{style:{fontSize:"0.8em",color:"var(--fuel-gray-11)"},children:"Multi-sigs and smart contract wallets (e.g. SAFE) are not supported."})]})]})]}),jsxRuntime.jsx(D,{onClick:()=>t(e),children:"Proceed anyway"}),jsxRuntime.jsx(W,{onClick:()=>r(),children:"Select a Native Wallet"})]}):null}var uo=({state:e})=>{switch(e){case"list":return jsxRuntime.jsx(wt,{});case"install":return jsxRuntime.jsx(ut,{});case"disclaimer":return jsxRuntime.jsx(Lt,{});case"connecting":return jsxRuntime.jsx(Nt,{});default:return null}};function Mt(){let{theme:e,cancel:t,dialog:{isOpen:r,route:o,connector:a,back:c}}=v();return jsxRuntime.jsx(_,{open:r,theme:e,onOpenChange:u=>{u||t();},children:jsxRuntime.jsxs(Y,{"data-connector":!!a,children:[jsxRuntime.jsxs(ae,{children:[jsxRuntime.jsx(le,{size:32,onClick:c,"data-connector":!!a}),jsxRuntime.jsx(se,{children:"Connect Wallet"}),jsxRuntime.jsx(ye__namespace.Close,{asChild:!0,children:jsxRuntime.jsx(ue,{size:32,onClick:()=>t()})})]}),jsxRuntime.jsx(ie,{}),jsxRuntime.jsx(ce,{children:jsxRuntime.jsx(uo,{state:o})})]})})}function Wt({size:e,...t}){return jsxRuntime.jsxs("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 95 95",width:e,height:e,...t,children:[jsxRuntime.jsx("title",{children:"No Funds Icon"}),jsxRuntime.jsx("path",{d:"M46.88 90.124C30.395 90.124 20 74.39 20 46.679 20 18.97 30.395 3 46.88 3s26.88 15.969 26.88 43.68c0 27.71-10.395 43.444-26.88 43.444Zm0-13.15c8.505 0 13.44-11.038 13.44-30.295 0-6.223-.525-11.624-1.47-16.086L39.005 72.511c2.1 2.936 4.725 4.462 7.875 4.462ZM33.44 46.678c0 6.106.525 11.507 1.47 15.852l19.845-41.918c-2.1-2.936-4.725-4.462-7.875-4.462-8.505 0-13.44 11.154-13.44 30.528Z",fill:"#EEE"}),jsxRuntime.jsx("path",{d:"M67 91.281c5.523 0 10-4.876 10-10.89C77 74.376 72.523 69.5 67 69.5s-10 4.876-10 10.89c0 6.015 4.477 10.891 10 10.891Z",fill:"#000"}),jsxRuntime.jsx("path",{d:"M67 91.281c5.523 0 10-4.876 10-10.89C77 74.376 72.523 69.5 67 69.5s-10 4.876-10 10.89c0 6.015 4.477 10.891 10 10.891Z",fill:"#627EEA"}),jsxRuntime.jsx("path",{d:"M67 91.281c5.523 0 10-4.876 10-10.89C77 74.376 72.523 69.5 67 69.5s-10 4.876-10 10.89c0 6.015 4.477 10.891 10 10.891Z",fill:"url(#a)",style:{"mix-blend-mode":"soft-light"}}),jsxRuntime.jsx("path",{d:"M67.166 73.13v5.368l4.166 2.027-4.166-7.395Z",fill:"#fff",fillOpacity:".602"}),jsxRuntime.jsx("path",{d:"M67.166 73.13 63 80.525l4.166-2.027V73.13Z",fill:"#fff"}),jsxRuntime.jsx("path",{d:"M67.166 84.004v3.647l4.17-6.281-4.17 2.634Z",fill:"#fff",fillOpacity:".602"}),jsxRuntime.jsx("path",{d:"M67.166 87.65v-3.646L63 81.37l4.166 6.28Z",fill:"#fff"}),jsxRuntime.jsx("path",{d:"m67.166 83.16 4.166-2.635-4.166-2.026v4.66Z",fill:"#fff",fillOpacity:".2"}),jsxRuntime.jsx("path",{d:"m63 80.525 4.166 2.634V78.5L63 80.525Z",fill:"#fff",fillOpacity:".602"}),jsxRuntime.jsx("defs",{children:jsxRuntime.jsxs("linearGradient",{id:"a",x1:"67",y1:"69.5",x2:"67",y2:"91.281",gradientUnits:"userSpaceOnUse",children:[jsxRuntime.jsx("stop",{stopColor:"#fff",stopOpacity:".5"}),jsxRuntime.jsx("stop",{offset:"1",stopOpacity:".5"})]})})]})}function ge(e){return {networks:react.useMemo(()=>e?e.map(r=>r.chainId?{...Pe.find(a=>a.chainId===r.chainId),...r}:r):Pe,[e])??[]}}function zt({theme:e}){let{networks:t}=ge(),{provider:r}=T(),o=react.useMemo(()=>{let C=t.find($=>$.chainId===r?.getChainId());if(!C||!C.bridgeURL)return null;let N=new URL(C.bridgeURL);return N.searchParams.set("","true"),N.toString()},[t,r]),{isConnected:a,uiConfig:c,dialog:{isOpen:i}}=v(),{isSupportedNetwork:u}=Ce(),{account:p}=he(),{balance:y}=Yt({account:p}),[f,w]=react.useState(!1),L=react.useMemo(()=>f||i||!o||!c.suggestBridge||!a||!u?!1:!!y?.isZero(),[c,y,u,a,f,o,i]);return jsxRuntime.jsx(_,{open:L,theme:e,onOpenChange:C=>{C||w(!0);},children:jsxRuntime.jsxs(Y,{"data-connector":!0,children:[jsxRuntime.jsxs(ae,{children:[jsxRuntime.jsx(le,{size:32,"data-connector":!1}),jsxRuntime.jsx(se,{children:"Bridge Funds"}),jsxRuntime.jsx(ye__namespace.Close,{asChild:!0,children:jsxRuntime.jsx(ue,{size:32})})]}),jsxRuntime.jsx(ie,{}),jsxRuntime.jsx(ce,{children:jsxRuntime.jsxs("div",{children:[jsxRuntime.jsx(B,{children:jsxRuntime.jsx(Wt,{size:100,theme:e})}),jsxRuntime.jsxs(H,{children:[jsxRuntime.jsxs(M,{children:["Bridge Funds ",jsxRuntime.jsx("br",{})," to Fuel Ignition"]}),jsxRuntime.jsx(Q,{children:"Looks like you don't have ETH balance, bridge funds to Fuel Ignition and use the application without stopping."})]}),jsxRuntime.jsx(D,{href:o??"",target:"_blank",children:"Bridge now"}),jsxRuntime.jsx(W,{onClick:()=>w(!0),children:"Continue to application"})]})})]})})}var ve=({query:e}={})=>{let{fuel:t}=l();return d("currentConnector",{queryKey:n.currentConnector(),queryFn:async()=>await t.isConnected()?t.currentConnector()??null:null,placeholderData:null,...e})};var R=e=>{let{fuel:t}=l();return d("isConnected",{queryKey:n.isConnected(),queryFn:async()=>{try{return await t.isConnected()||!1}catch{return !1}},placeholderData:!1,...e?.query,refetchInterval:1e3})};var xe=e=>{let{fuel:t}=l(),{isConnected:r}=R();return d("network",{queryKey:n.currentNetwork(),queryFn:async()=>{let o=await t.currentNetwork();if(!o&&r)throw new Error("Network not found");return o},placeholderData:null,refetchOnMount:!0,refetchInterval:o=>!o.state.data||o.state.error?4e3:!1,enabled:r,...e?.query})};function Ce(e){let{networks:t}=l(),{network:r}=xe(),{isConnected:o}=R(),{currentConnector:a}=ve();return d("isSupportedNetwork",{queryKey:n.isSupportedNetwork(a?.name,t,r,o),queryFn:async()=>{if(!a||!o||!r)return !0;let c=r.chainId;return c==null&&(c=(await fuels.Provider.create(r.url)).getChainId()),!!t.find(i=>i.chainId===c)},placeholderData:!0,...e})}var _t="0.8em",yo={position:"relative",padding:"calc(0.8em + 4px) 16px 0.8em 16px"},Vt=({children:e})=>jsxRuntime.jsx("div",{style:yo,children:e}),go={display:"flex",flexDirection:"column",alignItems:"center",gap:"var(--fuel-items-gap)"},Zt=({children:e})=>jsxRuntime.jsx("div",{style:go,children:e}),Co={textAlign:"center",fontSize:"1.2em",fontWeight:500,color:"var(--fuel-color-bold)",lineHeight:1},Gt=({children:e})=>jsxRuntime.jsx("h2",{style:Co,children:e}),ho={height:"1px",width:"100%",backgroundColor:"var(--fuel-separator-color)",margin:"10px 0",boxSizing:"border-box"},Ue=()=>jsxRuntime.jsx("div",{style:ho}),vo={margin:"20px 20px 0 20px",display:"flex",flexDirection:"column",alignItems:"center",gap:_t,marginBottom:_t},$t=({children:e})=>jsxRuntime.jsx("div",{style:vo,children:e}),Jt={fontWeight:400,textAlign:"center",lineHeight:"1.2em",color:"var(--fuel-gray-11)",marginBottom:"10px",marginTop:"10px"},Xt=({children:e})=>jsxRuntime.jsx("p",{style:Jt,children:e}),xo={...Jt,marginBottom:"4px",marginTop:"4px"},Ae=({children:e})=>jsxRuntime.jsx("p",{style:xo,children:e}),bo={fontWeight:400,textAlign:"center",lineHeight:"1.2em",opacity:.8,color:"var(--fuel-color-error)"},jt=({children:e})=>jsxRuntime.jsx("div",{style:bo,children:e}),Le={width:"100%",height:"40px",display:"flex",borderRadius:"11px",textDecoration:"none",justifyContent:"center",alignItems:"center",margin:"0.4rem 0",fontSize:"0.875em",marginBottom:0,color:"var(--fuel-black-color)"},er=e=>jsxRuntime.jsx("input",{style:Le,...e,className:"fuel-connectors-button-base fuel-connectors-button"}),So={...Le,backgroundColor:"var(--fuel-button-background)",color:"var(--fuel-color-bold)"},tr=e=>jsxRuntime.jsx("input",{style:So,...e,className:"fuel-connectors-button-base fuel-connectors-button-disconnect"}),To={fontWeight:400,textAlign:"center",lineHeight:1,color:"var(--fuel-gray-11)"},rr=({children:e})=>jsxRuntime.jsx("div",{style:To,children:e}),Po={...Le,marginBottom:0},or=({children:e,...t})=>jsxRuntime.jsx("div",{style:Po,...t,className:"fuel-connectors-button-base",children:e});function nr({theme:e}){let{networks:t}=l(),{disconnect:r}=ar(),{currentConnector:o}=ve(),{isSupportedNetwork:a}=Ce(),{selectNetwork:c,isError:i,error:u,isPending:p}=sr(),{isConnected:y}=R(),{data:f}=reactQuery.useQuery({queryKey:["chainName",t[0]],queryFn:async()=>t[0].url?(await fuels.Provider.create(t[0].url)).getChain().name:"",placeholderData:""});function w(){t[0].chainId!=null&&c({chainId:t[0].chainId});}function L(){r();}function C(){return i&&(u?.message==="Method not implemented."||u?.message==="Method not found")?"The selected Wallet does not support switching networks, please switch manually in your wallet.":i?u?.message||"Failed to switch network":""}return t==null||!y?null:jsxRuntime.jsx(_,{open:!a&&!!f,theme:e,children:jsxRuntime.jsx(Y,{"data-connector":!!o,onPointerDownOutside:N=>{N.preventDefault();},onEscapeKeyDown:N=>{N.preventDefault();},children:jsxRuntime.jsx(Vt,{children:jsxRuntime.jsxs(Zt,{children:[jsxRuntime.jsxs($t,{children:[jsxRuntime.jsx(Gt,{children:"Network Switch Required"}),jsxRuntime.jsx(Xt,{children:"This app does not support the current connected network."}),f&&jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Ae,{children:"Switch to:"}),jsxRuntime.jsx(Ae,{children:jsxRuntime.jsx("span",{style:{fontWeight:"bold"},children:f})})]}),!!i&&jsxRuntime.jsx(jt,{children:C()})]}),!p&&jsxRuntime.jsx(er,{type:"button",disabled:p,onClick:w,value:"Switch Network"}),p&&jsxRuntime.jsx(or,{children:jsxRuntime.jsx(de,{size:26,color:"var(--fuel-loader-background)"})}),jsxRuntime.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",gap:"6px",width:"100%"},children:[jsxRuntime.jsx(Ue,{}),jsxRuntime.jsx(rr,{children:"or"}),jsxRuntime.jsx(Ue,{})]}),jsxRuntime.jsx(tr,{type:"button",onClick:L,value:"Disconnect",color:"var(--fuel-border-color)"})]})})})})}function ir(){let{fuel:e}=l(),t=reactQuery.useQueryClient();function r(){t.invalidateQueries({queryKey:n.account()}),t.invalidateQueries({queryKey:n.isConnected()}),t.invalidateQueries({queryKey:n.wallet()}),t.invalidateQueries({queryKey:n.balance()}),t.invalidateQueries({queryKey:n.provider()}),t.invalidateQueries({queryKey:n.nodeInfo()}),t.invalidateQueries({queryKey:n.accounts()}),t.invalidateQueries({queryKey:n.currentConnector()});}async function o(){t.resetQueries({queryKey:n.connectorList(),exact:!0}),t.invalidateQueries({queryKey:n.currentConnector()});}function a(){t.invalidateQueries({queryKey:n.account()}),t.invalidateQueries({queryKey:n.wallet()}),t.invalidateQueries({queryKey:n.balance()});}function c(){t.invalidateQueries({queryKey:n.currentConnector()}),t.invalidateQueries({queryKey:n.isConnected()}),t.invalidateQueries({queryKey:n.account()}),t.invalidateQueries({queryKey:n.wallet()}),t.invalidateQueries({queryKey:n.balance()}),t.invalidateQueries({queryKey:n.provider()}),t.invalidateQueries({queryKey:n.nodeInfo()}),t.invalidateQueries({queryKey:n.accounts()}),t.resetQueries({queryKey:n.connectorList(),exact:!0});}function i(){t.invalidateQueries({queryKey:n.currentNetwork()}),t.invalidateQueries({queryKey:n.networks()}),t.invalidateQueries({queryKey:n.provider()}),t.invalidateQueries({queryKey:n.transactionReceipts()}),t.invalidateQueries({queryKey:n.chain()}),t.invalidateQueries({queryKey:n.nodeInfo()});}function u(){t.invalidateQueries({queryKey:n.account()}),t.invalidateQueries({queryKey:n.accounts()});}function p(){t.invalidateQueries({queryKey:n.assets()});}return react.useEffect(()=>(e.on(e.events.currentAccount,a),e.on(e.events.currentConnector,r),e.on(e.events.connectors,o),e.on(e.events.connection,c),e.on(e.events.accounts,u),e.on(e.events.currentNetwork,i),e.on(e.events.assets,p),()=>{e.off(e.events.currentConnector,r),e.off(e.events.currentAccount,a),e.off(e.events.connectors,o),e.off(e.events.connection,c),e.off(e.events.accounts,u),e.off(e.events.currentNetwork,i),e.off(e.events.assets,p);}),[e,t]),null}var cr=react.createContext(null),l=()=>{let e=react.useContext(cr);if(!e)throw new Error("useFuel must be used within a FuelHooksProvider");return e},qe=({children:e,fuelConfig:t,networks:r})=>{let o=react.useRef(new fuels.Fuel(t));return jsxRuntime.jsxs(cr.Provider,{value:{fuel:o.current,networks:r},children:[jsxRuntime.jsx(ir,{}),e]})};function Rc({theme:e,children:t,fuelConfig:r,uiConfig:o,ui:a=!0,networks:c}){let i=e||"light",{networks:u}=ge(c),p=react.useMemo(()=>Object.assign({suggestBridge:!0},o??{}),[o]);return a?jsxRuntime.jsx(qe,{fuelConfig:r,networks:u,children:jsxRuntime.jsxs(et,{theme:i,fuelConfig:r,uiConfig:p,children:[jsxRuntime.jsx(Mt,{}),jsxRuntime.jsx(nr,{theme:i}),p.suggestBridge&&jsxRuntime.jsx(zt,{theme:i}),t]})}):jsxRuntime.jsx(qe,{fuelConfig:r,networks:u,children:t})}var he=e=>{let{fuel:t}=l();return d("account",{queryKey:n.account(),queryFn:async()=>{try{return await t?.currentAccount()}catch{return null}},placeholderData:null,...e?.query})};var Yc=e=>{let{fuel:t}=l();return d("accounts",{queryKey:n.accounts(),queryFn:async()=>{try{return await t.accounts()}catch{return []}},placeholderData:[],...e?.query})};var Jc=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationKey:[j.addAssets],mutationFn:async a=>Array.isArray(a)?e.addAssets(a):e.addAsset(a)});return {addAssets:t,addAssetsAsync:r,...o}};var ol=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationKey:[j.addNetwork],mutationFn:async a=>e.addNetwork(a)});return {addNetwork:t,addNetworkAsync:r,...o}};var ll=e=>{let{fuel:t}=l();return d("assets",{queryKey:n.assets(),queryFn:async()=>{try{return await t.assets()}catch{return []}},placeholderData:[],...e?.query})};function lr(e){let{fuel:t,networks:r}=l(),{network:o}=xe(),{account:a}=he(),c=typeof e=="string"?{account:e}:e??{};return d("wallet",{queryKey:n.wallet(a,o?.url),queryFn:async()=>{try{if(console.log("asd useWallet querying start",a,o?.url),!a||!o?.url)return null;await fuels.Address.fromString(a);let u=await t.getWallet(a);console.log("asd useWallet querying completed",u);let p=r.find(y=>y.chainId===o.chainId);if(p?.url&&p.url!==o.url){let y=await fuels.Provider.create(p.url);u.connect(y);}return u}catch{return null}},enabled:!!a&&!!o?.url,placeholderData:null,...c.query})}var T=e=>{let{wallet:t}=lr();return {provider:react.useMemo(()=>t?.provider,[t?.provider,t?.provider.url])}};var Yt=({address:e,account:t,assetId:r,query:o})=>{let{provider:a}=T(),c=t??e??void 0;return d("balance",{queryKey:n.balance(c,r,a),queryFn:async()=>{try{if(!a)throw new Error("Provider is needed");let i=r||a.getBaseAssetId();return await a.getBalance(fuels.Address.fromString(c||""),i)||null}catch{return null}},placeholderData:null,enabled:!!a&&!!c,...o})};var Ql=e=>{let{provider:t}=T();return d("chain",{queryKey:n.chain(),queryFn:async()=>{try{return await t?.getChain()||null}catch{return null}},placeholderData:null,enabled:!!t,...e?.query})};var Yo=e=>"functions"in e,Ml=({contract:e,functionName:t,args:r})=>{let o=Yo(e),a=e?.provider?.getChainId();return d("contractRead",{queryKey:n.contract(o?e?.id?.toString():e?.address?.toString(),a,r?.toString()),queryFn:async()=>{if(!(o?!!e&&"provider"in e:!!e.abi&&!!e.address&&!!e.provider))throw new Error("Invalid input `contract` is required to read the contract");let i=o?e:new fuels.Contract(e.address,e.abi,e.provider);if(!i?.functions?.[t])throw new Error(`Function ${t||""} not found on contract`);if(i.functions[t].isReadOnly?.()!==void 0?!i.functions[t].isReadOnly():Object.values(i.interface.functions).find(p=>p.name===t)?.attributes?.find(p=>p.name==="storage")?.arguments?.includes("write"))throw new Error("Methods that write to storage should not be called with useContractRead");return r!==void 0?i.functions[t](r):i.functions[t]()},placeholderData:void 0})};var ar=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationFn:async()=>e?.disconnect()});return {disconnect:t,disconnectAsync:r,...o}};var Gl=e=>{let{fuel:t}=l();return d("networks",{queryKey:n.networks(),queryFn:t.networks,placeholderData:[],...e?.query})};var Vo=/^[v^~<>=]*?(\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+)(?:\.([x*]|\d+))?(?:-([\da-z\-]+(?:\.[\da-z\-]+)*))?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Ke=e=>{if(typeof e!="string")throw new TypeError("Invalid argument expected string");let t=e.match(Vo);if(!t)throw new Error(`Invalid argument not valid semver ('${e}' received)`);return t.shift(),t},ur=e=>e==="*"||e==="x"||e==="X",pr=e=>{let t=parseInt(e,10);return isNaN(t)?e:t},Zo=(e,t)=>typeof e!=typeof t?[String(e),String(t)]:[e,t],Go=(e,t)=>{if(ur(e)||ur(t))return 0;let[r,o]=Zo(pr(e),pr(t));return r>o?1:r<o?-1:0},Me=(e,t)=>{for(let r=0;r<Math.max(e.length,t.length);r++){let o=Go(e[r]||"0",t[r]||"0");if(o!==0)return o}return 0};var dr=(e,t)=>{let r=Ke(e),o=Ke(t),a=r.pop(),c=o.pop(),i=Me(r,o);return i!==0?i:a&&c?Me(a.split("."),c.split(".")):a||c?a?-1:1:0};var Be=(e,t,r)=>{$o(r);let o=dr(e,t);return fr[r].includes(o)},fr={">":[1],">=":[0,1],"=":[0],"<=":[-1,0],"<":[-1],"!=":[-1,1]},mr=Object.keys(fr),$o=e=>{if(mr.indexOf(e)===-1)throw new Error(`Invalid operator, expected one of ${mr.join("|")}`)};var mu=({version:e="0.0.0",query:t}={})=>{let{provider:r}=T(),o=d("nodeInfo",{queryKey:n.nodeInfo(r?.url),queryFn:()=>{try{return r?.fetchNode()||null}catch{return null}},placeholderData:null,enabled:!!r,...t});return new Proxy(o,{get(a,c){return c==="isCompatible"?a.nodeInfo?.nodeVersion?Be(a.nodeInfo?.nodeVersion,e,">="):null:Reflect.get(a,c)}})};var sr=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationFn:e.selectNetwork});return {selectNetwork:t,selectNetworkAsync:r,...o}};var Tu=()=>{let{fuel:e}=l(),{mutate:t,mutateAsync:r,...o}=reactQuery.useMutation({mutationFn:({address:a,transaction:c})=>{let i=fuels.Address.fromDynamicInput(a).toString();return e.sendTransaction(i,c)}});return {sendTransaction:t,sendTransactionAsync:r,...o}};var Du=e=>{let{fuel:t}=l();return d("transaction",{queryKey:n.transaction(e),queryFn:async()=>{try{let r=await t?.getProvider();return r?await r.getTransaction(e||""):null}catch{return null}},placeholderData:null,enabled:!!e})};var Lu=({txId:e,query:t})=>{let{provider:r}=T();return d("transactionReceipts",{queryKey:n.transactionReceipts(e,r),queryFn:async()=>{try{if(!r)return null;let o=new fuels.TransactionResponse(e||"",r);if(!o)return null;let{receipts:a}=await o.waitForResult();return a||null}catch{return null}},placeholderData:null,enabled:!!e,...t})};var Ou=({txId:e="",query:t={}})=>{let{provider:r}=T(),{name:o="transactionResult",...a}=t;return d(o,{queryKey:n.transactionResult(e,r),queryFn:async()=>r&&await new fuels.TransactionResponse(e,r).waitForResult()||null,placeholderData:null,enabled:!!e,...a})}; | ||
exports.FuelProvider = Nc; | ||
exports.FuelProvider = Rc; | ||
exports.MUTATION_KEYS = j; | ||
exports.QUERY_KEYS = n; | ||
exports.isNativeConnector = Ve; | ||
exports.useAccount = Ot; | ||
exports.useAccounts = Oc; | ||
exports.useAddAssets = Gc; | ||
exports.useAddNetwork = tl; | ||
exports.useAssets = sl; | ||
exports.useBalance = zt; | ||
exports.useChain = Tl; | ||
exports.useConnect = _e; | ||
exports.isNativeConnector = Ge; | ||
exports.useAccount = he; | ||
exports.useAccounts = Yc; | ||
exports.useAddAssets = Jc; | ||
exports.useAddNetwork = ol; | ||
exports.useAssets = ll; | ||
exports.useBalance = Yt; | ||
exports.useChain = Ql; | ||
exports.useConnect = Ze; | ||
exports.useConnectUI = v; | ||
exports.useConnectors = Ze; | ||
exports.useContractRead = Fl; | ||
exports.useCurrentConnector = he; | ||
exports.useConnectors = $e; | ||
exports.useContractRead = Ml; | ||
exports.useCurrentConnector = ve; | ||
exports.useDisconnect = ar; | ||
@@ -52,14 +52,14 @@ exports.useFuel = l; | ||
exports.useIsSupportedNetwork = Ce; | ||
exports.useNamedQuery = u; | ||
exports.useNetwork = Yt; | ||
exports.useNetworks = Wl; | ||
exports.useNodeInfo = au; | ||
exports.useProvider = h; | ||
exports.useSelectNetwork = ir; | ||
exports.useSendTransaction = yu; | ||
exports.useTransaction = bu; | ||
exports.useTransactionReceipts = Ru; | ||
exports.useTransactionResult = Au; | ||
exports.useWallet = Ou; | ||
exports.useNamedQuery = d; | ||
exports.useNetwork = xe; | ||
exports.useNetworks = Gl; | ||
exports.useNodeInfo = mu; | ||
exports.useProvider = T; | ||
exports.useSelectNetwork = sr; | ||
exports.useSendTransaction = Tu; | ||
exports.useTransaction = Du; | ||
exports.useTransactionReceipts = Lu; | ||
exports.useTransactionResult = Ou; | ||
exports.useWallet = lr; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.js.map |
@@ -15,3 +15,3 @@ import type { QueryKey } from '@tanstack/react-query'; | ||
balance: (address?: string, assetId?: BytesLike, provider?: Provider | null) => QueryKey; | ||
wallet: (address?: string | null, provider?: Provider | null) => QueryKey; | ||
wallet: (address?: string | null, providerUrl?: string | null) => QueryKey; | ||
transaction: (id?: string) => QueryKey; | ||
@@ -18,0 +18,0 @@ transactionReceipts: (id?: string, provider?: Provider | null) => QueryKey; |
{ | ||
"name": "@fuels/react", | ||
"description": "Interact with the Fuel Wallet Extension in React.", | ||
"version": "0.36.0-pr-403-17936bd", | ||
"version": "0.36.0-pr-404-4ea3721", | ||
"license": "Apache-2.0", | ||
@@ -6,0 +6,0 @@ "main": "./dist/index.js", |
@@ -1,5 +0,5 @@ | ||
import { Provider } from 'fuels'; | ||
import { type UseNamedQueryParams, useNamedQuery } from '../core'; | ||
import { useFuel } from '../providers'; | ||
import { QUERY_KEYS } from '../utils'; | ||
import type { Provider } from 'fuels'; | ||
import { useMemo } from 'react'; | ||
import type { UseNamedQueryParams } from '../core'; | ||
import { useWallet } from './useWallet'; | ||
@@ -32,31 +32,10 @@ type UseProviderParams = { | ||
*/ | ||
export const useProvider = (params?: UseProviderParams) => { | ||
const { fuel, networks } = useFuel(); | ||
return useNamedQuery('provider', { | ||
queryKey: QUERY_KEYS.provider(), | ||
queryFn: async () => { | ||
const currentNetwork = await fuel.currentNetwork(); | ||
const network = networks.find( | ||
(n) => n.chainId === currentNetwork.chainId, | ||
); | ||
if (!network?.url) { | ||
const provider = await fuel.getProvider(); | ||
console.warn( | ||
'Please provide a networks with a RPC url configuration to your FuelProvider getProvider will be removed.', | ||
); | ||
return provider || null; | ||
} | ||
const provider = await Provider.create(network.url); | ||
if (provider.getChainId() !== currentNetwork.chainId) { | ||
throw new Error( | ||
`The provider's chainId (${provider.getChainId()}) does not match the current network's chainId (${ | ||
currentNetwork.chainId | ||
})`, | ||
); | ||
} | ||
return provider; | ||
}, | ||
placeholderData: null, | ||
...params?.query, | ||
}); | ||
export const useProvider = (_params?: UseProviderParams) => { | ||
const { wallet } = useWallet(); | ||
const provider = useMemo(() => { | ||
return wallet?.provider; | ||
}, [wallet?.provider, wallet?.provider.url]); | ||
return { provider }; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { type Account, Address } from 'fuels'; | ||
import { type Account, Address, Provider } from 'fuels'; | ||
@@ -10,3 +10,4 @@ import { | ||
import { QUERY_KEYS } from '../utils'; | ||
import { useProvider } from './useProvider'; | ||
import { useAccount } from './useAccount'; | ||
import { useNetwork } from './useNetwork'; | ||
@@ -60,20 +61,32 @@ type UseWalletParamsDeprecated = string | null; | ||
params?: UseWalletParamsDeprecated | UseWalletParams, | ||
): DefinedNamedUseQueryResult<'wallet', Account | null, Error> { | ||
const { fuel } = useFuel(); | ||
const { provider } = useProvider(); | ||
) { | ||
const { fuel, networks } = useFuel(); | ||
const { network } = useNetwork(); | ||
const { account } = useAccount(); | ||
const _params: UseWalletParams = | ||
typeof params === 'string' ? { account: params } : params ?? {}; | ||
typeof params === 'string' ? { account: params } : (params ?? {}); | ||
return useNamedQuery('wallet', { | ||
queryKey: QUERY_KEYS.wallet(_params.account, provider), | ||
const queried = useNamedQuery('wallet', { | ||
queryKey: QUERY_KEYS.wallet(account, network?.url), | ||
queryFn: async () => { | ||
try { | ||
if (!provider) return null; | ||
const accountAddress = | ||
_params.account || (await fuel.currentAccount()) || ''; | ||
// Check if the address is valid | ||
await Address.fromString(accountAddress); | ||
const wallet = await fuel.getWallet(accountAddress); | ||
wallet.connect(provider); | ||
return wallet || null; | ||
console.log('asd useWallet querying start', account, network?.url); | ||
if (!account || !network?.url) return null; | ||
await Address.fromString(account); | ||
const wallet = await fuel.getWallet(account); | ||
console.log('asd useWallet querying completed', wallet); | ||
const configuredNetwork = networks.find( | ||
(n) => n.chainId === network.chainId, | ||
); | ||
if (configuredNetwork?.url && configuredNetwork.url !== network.url) { | ||
// if the user configured a different network for the same chainId, we connect to the configured network instead | ||
const provider = await Provider.create(configuredNetwork.url); | ||
wallet.connect(provider); | ||
} | ||
return wallet; | ||
} catch (_error: unknown) { | ||
@@ -83,5 +96,8 @@ return null; | ||
}, | ||
enabled: !!account && !!network?.url, | ||
placeholderData: null, | ||
..._params.query, | ||
}); | ||
return queried; | ||
} |
@@ -50,7 +50,6 @@ import type { QueryKey } from '@tanstack/react-query'; | ||
}, | ||
wallet: (address?: string | null, provider?: Provider | null): QueryKey => { | ||
wallet: (address?: string | null, providerUrl?: string | null): QueryKey => { | ||
const queryKey = QUERY_KEYS.base.concat('wallet'); | ||
if (address) queryKey.push(address); | ||
if (provider?.getChainId?.() !== undefined) | ||
queryKey.push(provider.getChainId()); | ||
if (providerUrl) queryKey.push(providerUrl); | ||
return queryKey; | ||
@@ -57,0 +56,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
156
1.3%6737
0.13%728856
-0.18%