@chainrails/react 0.2.27 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- (function(S,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],g):(S=typeof globalThis<"u"?globalThis:S||self,g(S.Chainrails={},S.React,S.jsxRuntime))})(this,(function(S,g,x){"use strict";var ye=document.createElement("style");ye.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;transition:all .1s ease-in-out}.payment-modal-wrapper.loading{background-color:#0003;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.payment-modal-wrapper.not-loading{background-color:#0008;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;inset:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
2
- /*$vite$:1*/`,document.head.appendChild(ye);class K extends Error{response;request;options;constructor(t,s,n){const r=t.status||t.status===0?t.status:"",i=t.statusText??"",o=`${r} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${s.method} ${s.url}`),this.name="HTTPError",this.response=t,this.request=s,this.options=n}}class we extends Error{name="NonError";value;constructor(t){let s="Non-error value was thrown";try{typeof t=="string"?s=t:t&&typeof t=="object"&&"message"in t&&typeof t.message=="string"&&(s=t.message)}catch{}super(s),this.value=t}}class W extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(t){const s=t?.cause?t.cause instanceof Error?t.cause:new we(t.cause):void 0;super(t?.code?`Forced retry: ${t.code}`:"Forced retry",s?{cause:s}:void 0),this.customDelay=t?.delay,this.code=t?.code,this.customRequest=t?.request}}const be=(()=>{let e=!1,t=!1;const s=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(s&&n)try{t=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return e=!0,"half"}}).headers.has("Content-Type")}catch(r){if(r instanceof Error&&r.message==="unsupported BodyInit type")return!1;throw r}return e&&!t})(),St=typeof globalThis.AbortController=="function",Se=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",Et=typeof globalThis.ReadableStream=="function",Tt=typeof globalThis.FormData=="function",Ee=["get","post","put","patch","head","delete"],Rt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},V=2147483647,At=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Te=Symbol("stop");class Re{options;constructor(t){this.options=t}}const vt=e=>new Re(e),Pt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},It={next:!0},Ct={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},Ut=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(const[s,n]of e)t+=At,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length,t+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return t}if(e instanceof Blob)return e.size;if(e instanceof ArrayBuffer)return e.byteLength;if(typeof e=="string")return new TextEncoder().encode(e).length;if(e instanceof URLSearchParams)return new TextEncoder().encode(e.toString()).length;if("byteLength"in e)return e.byteLength;if(typeof e=="object"&&e!==null)try{const t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},Ae=(e,t,s)=>{let n,r=0;return e.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),n){r+=n.byteLength;let a=t===0?0:r/t;a>=1&&(a=1-Number.EPSILON),s?.({percent:a,totalBytes:Math.max(t,r),transferredBytes:r},n)}n=i},flush(){n&&(r+=n.byteLength,s?.({percent:1,totalBytes:Math.max(t,r),transferredBytes:r},n))}}))},kt=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});const s=Math.max(0,Number(e.headers.get("content-length"))||0);return new Response(Ae(e.body,s,t),{status:e.status,statusText:e.statusText,headers:e.headers})},xt=(e,t,s)=>{if(!e.body)return e;const n=Ut(s??e.body);return new Request(e,{duplex:"half",body:Ae(e.body,n,t)})},C=e=>e!==null&&typeof e=="object",z=(...e)=>{for(const t of e)if((!C(t)||Array.isArray(t))&&t!==void 0)throw new TypeError("The `options` argument must be an object");return Y({},...e)},ve=(e={},t={})=>{const s=new globalThis.Headers(e),n=t instanceof globalThis.Headers,r=new globalThis.Headers(t);for(const[i,o]of r.entries())n&&o==="undefined"||o===void 0?s.delete(i):s.set(i,o);return s};function B(e,t,s){return Object.hasOwn(t,s)&&t[s]===void 0?[]:Y(e[s]??[],t[s]??[])}const Pe=(e={},t={})=>({beforeRequest:B(e,t,"beforeRequest"),beforeRetry:B(e,t,"beforeRetry"),afterResponse:B(e,t,"afterResponse"),beforeError:B(e,t,"beforeError")}),Dt=(e,t)=>{const s=new URLSearchParams;for(const n of[e,t])if(n!==void 0)if(n instanceof URLSearchParams)for(const[r,i]of n.entries())s.append(r,i);else if(Array.isArray(n))for(const r of n){if(!Array.isArray(r)||r.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");s.append(String(r[0]),String(r[1]))}else if(C(n))for(const[r,i]of Object.entries(n))i!==void 0&&s.append(r,String(i));else{const r=new URLSearchParams(n);for(const[i,o]of r.entries())s.append(i,o)}return s},Y=(...e)=>{let t={},s={},n={},r;const i=[];for(const o of e)if(Array.isArray(o))Array.isArray(t)||(t=[]),t=[...t,...o];else if(C(o)){for(let[a,c]of Object.entries(o)){if(a==="signal"&&c instanceof globalThis.AbortSignal){i.push(c);continue}if(a==="context"){if(c!=null&&(!C(c)||Array.isArray(c)))throw new TypeError("The `context` option must be an object");t={...t,context:c==null?{}:{...t.context,...c}};continue}if(a==="searchParams"){c==null?r=void 0:r=r===void 0?c:Dt(r,c);continue}C(c)&&a in t&&(c=Y(t[a],c)),t={...t,[a]:c}}C(o.hooks)&&(n=Pe(n,o.hooks),t.hooks=n),C(o.headers)&&(s=ve(s,o.headers),t.headers=s)}return r!==void 0&&(t.searchParams=r),i.length>0&&(i.length===1?t.signal=i[0]:Se?t.signal=AbortSignal.any(i):t.signal=i.at(-1)),t.context===void 0&&(t.context={}),t},Ot=e=>Ee.includes(e)?e.toUpperCase():e,Ie={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},Nt=(e={})=>{if(typeof e=="number")return{...Ie,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Ie,...e}};class X extends Error{request;constructor(t){super(`Request timed out: ${t.method} ${t.url}`),this.name="TimeoutError",this.request=t}}async function Mt(e,t,s,n){return new Promise((r,i)=>{const o=setTimeout(()=>{s&&s.abort(),i(new X(e))},n.timeout);n.fetch(e,t).then(r).catch(i).then(()=>{clearTimeout(o)})})}async function zt(e,{signal:t}){return new Promise((s,n)=>{t&&(t.throwIfAborted(),t.addEventListener("abort",r,{once:!0}));function r(){clearTimeout(i),n(t.reason)}const i=setTimeout(()=>{t?.removeEventListener("abort",r),s()},e)})}const Bt=(e,t)=>{const s={};for(const n in t)Object.hasOwn(t,n)&&!(n in Ct)&&!(n in Pt)&&(!(n in e)||n in It)&&(s[n]=t[n]);return s},$t=e=>e===void 0?!1:Array.isArray(e)?e.length>0:e instanceof URLSearchParams?e.size>0:typeof e=="object"?Object.keys(e).length>0:typeof e=="string"?e.trim().length>0:!!e;function jt(e){return e instanceof K||e?.name===K.name}function Lt(e){return e instanceof X||e?.name===X.name}class D{static create(t,s){const n=new D(t,s),r=async()=>{if(typeof n.#e.timeout=="number"&&n.#e.timeout>V)throw new RangeError(`The \`timeout\` option cannot be greater than ${V}`);await Promise.resolve();let o=await n.#g();for(const a of n.#e.hooks.afterResponse){const c=n.#l(o.clone()),u=await a(n.request,n.#a(),c,{retryCount:n.#s});if(u instanceof globalThis.Response&&(o=u),u instanceof Re)throw await Promise.all([c.body?.cancel(),o.body?.cancel()]),new W(u.options)}if(n.#l(o),!o.ok&&(typeof n.#e.throwHttpErrors=="function"?n.#e.throwHttpErrors(o.status):n.#e.throwHttpErrors)){let a=new K(o,n.request,n.#a());for(const c of n.#e.hooks.beforeError)a=await c(a,{retryCount:n.#s});throw a}if(n.#e.onDownloadProgress){if(typeof n.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!Et)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return kt(o.clone(),n.#e.onDownloadProgress)}return o},i=n.#f(r).finally(async()=>{const o=n.#o,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),n.request.bodyUsed||a.push(n.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries(Rt))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||a);const c=await i;if(o==="json"){if(c.status===204)return"";const u=await c.text();return u===""?"":s.parseJson?s.parseJson(u):JSON.parse(u)}return c[o]()});return i}static#d(t){return t&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof URLSearchParams)?Object.fromEntries(Object.entries(t).filter(([,s])=>s!==void 0)):t}request;#n;#s=0;#t;#e;#o;#r;#i;constructor(t,s={}){if(this.#t=t,this.#e={...s,headers:ve(this.#t.headers,s.headers),hooks:Pe({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:Ot(s.method??this.#t.method??"GET"),prefixUrl:String(s.prefixUrl||""),retry:Nt(s.retry),throwHttpErrors:s.throwHttpErrors??!0,timeout:s.timeout??1e4,fetch:s.fetch??globalThis.fetch.bind(globalThis),context:s.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}St&&Se&&(this.#r=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal),be&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const n=s.headers&&new globalThis.Headers(s.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(Tt&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!n&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),$t(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(D.#d(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!be)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#h(this.request,this.#e.body??void 0)}}#c(){const t=this.#e.retry.delay(this.#s);let s=t;return this.#e.retry.jitter===!0?s=Math.random()*t:typeof this.#e.retry.jitter=="function"&&(s=this.#e.retry.jitter(t),(!Number.isFinite(s)||s<0)&&(s=t)),Math.min(this.#e.retry.backoffLimit,s)}async#p(t){if(this.#s++,this.#s>this.#e.retry.limit)throw t;const s=t instanceof Error?t:new we(t);if(s instanceof W)return s.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw t;if(this.#e.retry.shouldRetry!==void 0){const n=await this.#e.retry.shouldRetry({error:s,retryCount:this.#s});if(n===!1)throw t;if(n===!0)return this.#c()}if(Lt(t)&&!this.#e.retry.retryOnTimeout)throw t;if(jt(t)){if(!this.#e.retry.statusCodes.includes(t.response.status))throw t;const n=t.response.headers.get("Retry-After")??t.response.headers.get("RateLimit-Reset")??t.response.headers.get("X-RateLimit-Retry-After")??t.response.headers.get("X-RateLimit-Reset")??t.response.headers.get("X-Rate-Limit-Reset");if(n&&this.#e.retry.afterStatusCodes.includes(t.response.status)){let r=Number(n)*1e3;Number.isNaN(r)?r=Date.parse(n)-Date.now():r>=Date.parse("2024-01-01")&&(r-=Date.now());const i=this.#e.retry.maxRetryAfter??r;return r<i?r:i}if(t.response.status===413)throw t}return this.#c()}#l(t){return this.#e.parseJson&&(t.json=async()=>this.#e.parseJson(await t.text())),t}async#f(t){try{return await t()}catch(s){const n=Math.min(await this.#p(s),V);if(this.#s<1)throw s;if(await zt(n,this.#r?{signal:this.#r}:{}),s instanceof W&&s.customRequest){const r=this.#e.signal?new globalThis.Request(s.customRequest,{signal:this.#e.signal}):new globalThis.Request(s.customRequest);this.#u(r)}for(const r of this.#e.hooks.beforeRetry){const i=await r({request:this.request,options:this.#a(),error:s,retryCount:this.#s});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===Te)return}return this.#f(t)}}async#g(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const s of this.#e.hooks.beforeRequest){const n=await s(this.request,this.#a(),{retryCount:this.#s});if(n instanceof Response)return n;if(n instanceof globalThis.Request){this.#u(n);break}}const t=Bt(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,t):Mt(this.#o,t,this.#n,this.#e)}#a(){if(!this.#i){const{hooks:t,...s}=this.#e;this.#i=Object.freeze(s)}return this.#i}#u(t){this.#i=void 0,this.request=this.#h(t)}#h(t,s){return!this.#e.onUploadProgress||!t.body?t:xt(t,this.#e.onUploadProgress,s??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const J=e=>{const t=(s,n)=>D.create(s,z(e,n));for(const s of Ee)t[s]=(n,r)=>D.create(n,z(e,r,{method:s}));return t.create=s=>J(z(s)),t.extend=s=>(typeof s=="function"&&(s=s(e??{})),J(z(e,s))),t.stop=Te,t.retry=vt,t},_t=J();var R=(e=>(e.USDC="USDC",e))(R||{});const Ce={type:"evm",chainId:42161,name:"Arbitrum",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},Ue={type:"evm",chainId:421614,name:"Arbitrum Sepolia",cctpDomain:3,logoURI:"/images/chains/arbitrum.svg"},ke={type:"evm",chainId:8453,name:"Base",cctpDomain:6,logoURI:"/images/chains/base.webp"},xe={type:"evm",chainId:84532,name:"Base Sepolia",cctpDomain:6,logoURI:"/images/chains/base.webp"},De={type:"evm",chainId:56,name:"BNB Chain",cctpDomain:null,logoURI:"/images/chains/bsc.webp"},Oe={type:"evm",chainId:1,name:"Ethereum",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},Ne={type:"evm",chainId:11155111,name:"Ethereum Sepolia",cctpDomain:0,logoURI:"/images/chains/ethereum.svg"},Me={type:"evm",chainId:43114,name:"Avalanche",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},ze={type:"evm",chainId:43113,name:"Avalanche Fuji",cctpDomain:1,logoURI:"/images/chains/avalanche.svg"},Be={type:"starknet",chainId:"0x534e5f4d41494e",name:"Starknet",cctpDomain:null,logoURI:"/images/chains/starknet.svg"};function G(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function $e(e){return G(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}const je="2.43.4";let Z={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:s})=>t?`${e??"https://viem.sh"}${t}${s?`#${s}`:""}`:void 0,version:`viem@${je}`};class P extends Error{constructor(t,s={}){const n=s.cause instanceof P?s.cause.details:s.cause?.message?s.cause.message:s.details,r=s.cause instanceof P&&s.cause.docsPath||s.docsPath,i=Z.getDocsUrl?.({...s,docsPath:r}),o=[t||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...n?[`Details: ${n}`]:[],...Z.version?[`Version: ${Z.version}`]:[]].join(`
3
- `);super(o,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=r,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=t,this.version=je}walk(t){return Le(this,t)}}function Le(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause!==void 0?Le(e.cause,t):t?null:e}class _e extends P{constructor({size:t,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function $(e,{dir:t,size:s=32}={}){return typeof e=="string"?qt(e,{dir:t,size:s}):Ft(e,{dir:t,size:s})}function qt(e,{dir:t,size:s=32}={}){if(s===null)return e;const n=e.replace("0x","");if(n.length>s*2)throw new _e({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](s*2,"0")}`}function Ft(e,{dir:t,size:s=32}={}){if(s===null)return e;if(e.length>s)throw new _e({size:e.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let r=0;r<s;r++){const i=t==="right";n[i?r:s-r-1]=e[i?r:e.length-r-1]}return n}class Ht extends P{constructor({max:t,min:s,signed:n,size:r,value:i}){super(`Number "${i}" is not in safe ${r?`${r*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${s} to ${t})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Kt extends P{constructor({givenSize:t,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function Q(e,{size:t}){if($e(e)>t)throw new Kt({givenSize:$e(e),maxSize:t})}function Wt(e,t={}){const{signed:s,size:n}=t,r=BigInt(e);let i;n?s?i=(1n<<BigInt(n)*8n-1n)-1n:i=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&s?-i-1n:0;if(i&&r>i||r<o){const c=typeof e=="bigint"?"n":"";throw new Ht({max:i?`${i}${c}`:void 0,min:`${o}${c}`,signed:s,size:n,value:`${e}${c}`})}const a=`0x${(s&&r<0?(1n<<BigInt(n*8))+BigInt(r):r).toString(16)}`;return n?$(a,{size:n}):a}const Vt=new TextEncoder;function Yt(e,t={}){return typeof e=="number"||typeof e=="bigint"?Jt(e,t):typeof e=="boolean"?Xt(e,t):G(e)?Fe(e,t):He(e,t)}function Xt(e,t={}){const s=new Uint8Array(1);return s[0]=Number(e),typeof t.size=="number"?(Q(s,{size:t.size}),$(s,{size:t.size})):s}const A={zero:48,nine:57,A:65,F:70,a:97,f:102};function qe(e){if(e>=A.zero&&e<=A.nine)return e-A.zero;if(e>=A.A&&e<=A.F)return e-(A.A-10);if(e>=A.a&&e<=A.f)return e-(A.a-10)}function Fe(e,t={}){let s=e;t.size&&(Q(s,{size:t.size}),s=$(s,{dir:"right",size:t.size}));let n=s.slice(2);n.length%2&&(n=`0${n}`);const r=n.length/2,i=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const c=qe(n.charCodeAt(a++)),u=qe(n.charCodeAt(a++));if(c===void 0||u===void 0)throw new P(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);i[o]=c*16+u}return i}function Jt(e,t){const s=Wt(e,t);return Fe(s)}function He(e,t={}){const s=Vt.encode(e);return typeof t.size=="number"?(Q(s,{size:t.size}),$(s,{dir:"right",size:t.size})):s}const j=BigInt(2**32-1),Ke=BigInt(32);function Gt(e,t=!1){return t?{h:Number(e&j),l:Number(e>>Ke&j)}:{h:Number(e>>Ke&j)|0,l:Number(e&j)|0}}function Zt(e,t=!1){const s=e.length;let n=new Uint32Array(s),r=new Uint32Array(s);for(let i=0;i<s;i++){const{h:o,l:a}=Gt(e[i],t);[n[i],r[i]]=[o,a]}return[n,r]}const Qt=(e,t,s)=>e<<s|t>>>32-s,es=(e,t,s)=>t<<s|e>>>32-s,ts=(e,t,s)=>t<<s-32|e>>>64-s,ss=(e,t,s)=>e<<s-32|t>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function ns(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function We(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function L(e,...t){if(!ns(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ve(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function rs(e,t){L(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function os(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Ye(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const is=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function as(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function cs(e){for(let t=0;t<e.length;t++)e[t]=as(e[t]);return e}const Xe=is?e=>e:cs;function us(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function Je(e){return typeof e=="string"&&(e=us(e)),L(e),e}class ls{}function fs(e){const t=n=>e().update(Je(n)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const hs=BigInt(0),O=BigInt(1),ds=BigInt(2),ps=BigInt(7),gs=BigInt(256),ms=BigInt(113),Ge=[],Ze=[],Qe=[];for(let e=0,t=O,s=1,n=0;e<24;e++){[s,n]=[n,(2*s+3*n)%5],Ge.push(2*(5*n+s)),Ze.push((e+1)*(e+2)/2%64);let r=hs;for(let i=0;i<7;i++)t=(t<<O^(t>>ps)*ms)%gs,t&ds&&(r^=O<<(O<<BigInt(i))-O);Qe.push(r)}const et=Zt(Qe,!0),ys=et[0],ws=et[1],tt=(e,t,s)=>s>32?ts(e,t,s):Qt(e,t,s),st=(e,t,s)=>s>32?ss(e,t,s):es(e,t,s);function bs(e,t=24){const s=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let o=0;o<10;o++)s[o]=e[o]^e[o+10]^e[o+20]^e[o+30]^e[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,u=s[c],f=s[c+1],b=tt(u,f,1)^s[a],p=st(u,f,1)^s[a+1];for(let y=0;y<50;y+=10)e[o+y]^=b,e[o+y+1]^=p}let r=e[2],i=e[3];for(let o=0;o<24;o++){const a=Ze[o],c=tt(r,i,a),u=st(r,i,a),f=Ge[o];r=e[f],i=e[f+1],e[f]=c,e[f+1]=u}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=e[o+a];for(let a=0;a<10;a++)e[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}e[0]^=ys[n],e[1]^=ws[n]}Ye(s)}class ee extends ls{constructor(t,s,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=s,this.outputLen=n,this.enableXOF=r,this.rounds=i,We(n),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=os(this.state)}clone(){return this._cloneInto()}keccak(){Xe(this.state32),bs(this.state32,this.rounds),Xe(this.state32),this.posOut=0,this.pos=0}update(t){Ve(this),t=Je(t),L(t);const{blockLen:s,state:n}=this,r=t.length;for(let i=0;i<r;){const o=Math.min(s-this.pos,r-i);for(let a=0;a<o;a++)n[this.pos++]^=t[i++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:s,pos:n,blockLen:r}=this;t[n]^=s,(s&128)!==0&&n===r-1&&this.keccak(),t[r-1]^=128,this.keccak()}writeInto(t){Ve(this,!1),L(t),this.finish();const s=this.state,{blockLen:n}=this;for(let r=0,i=t.length;r<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-r);t.set(s.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return We(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(rs(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Ye(this.state)}_cloneInto(t){const{blockLen:s,suffix:n,outputLen:r,rounds:i,enableXOF:o}=this;return t||(t=new ee(s,n,r,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=n,t.outputLen=r,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Ss=(e,t,s)=>fs(()=>new ee(t,e,s)),Es=Ss(1,136,256/8);function Ts(e,t){return Es(G(e,{strict:!1})?Yt(e):e)}class Rs extends P{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class nt extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const s=super.get(t);return super.has(t)&&s!==void 0&&(this.delete(t),super.set(t,s)),s}set(t,s){if(super.set(t,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const te=new nt(8192);function rt(e,t){if(te.has(`${e}.${t}`))return te.get(`${e}.${t}`);const s=e.substring(2).toLowerCase(),n=Ts(He(s)),r=s.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(n[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const i=`0x${r.join("")}`;return te.set(`${e}.${t}`,i),i}function v(e,t){if(!vs(e,{strict:!1}))throw new Rs({address:e});return rt(e,t)}const As=/^0x[a-fA-F0-9]{40}$/,se=new nt(8192);function vs(e,t){const{strict:s=!0}=t??{},n=`${e}.${s}`;if(se.has(n))return se.get(n);const r=As.test(e)?e.toLowerCase()===e?!0:s?rt(e)===e:!0:!1;return se.set(n,r),r}const Ps={chainId:Ue.chainId,address:v("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Is={chainId:Ce.chainId,address:v("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:"USDC",name:"USD Coin",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png"},Cs={chainId:ze.chainId,address:v("0x5425890298aed601595a70ab815c96711a31bc65"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Us={chainId:Me.chainId,address:v("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},ks={chainId:xe.chainId,address:v("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},xs={chainId:ke.chainId,address:v("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:"USDC",fiatISO:"USD",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ds={chainId:De.chainId,address:v("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:"USDC",decimals:18,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Os={chainId:Ne.chainId,address:v("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ns={chainId:Oe.chainId,address:v("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},Ms={chainId:Be.chainId,address:"0x053C91253BC9682c04929cA02ED00b3E423f6710D2ee7e0D5EBB06F3eCF368A8",symbol:"USDC",decimals:6,logoURI:"https://pay.daimo.com/coin-logos/usdc.png",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},ot={ARBITRUM_MAINNET:{...Ce,tokens:{[R.USDC]:Is},explorer:"https://arbiscan.io"},ARBITRUM_TESTNET:{...Ue,explorer:"https://sepolia.arbiscan.io",tokens:{[R.USDC]:Ps}},AVALANCHE_MAINNET:{...Me,tokens:{[R.USDC]:Us},explorer:"https://snowtrace.io"},AVALANCHE_TESTNET:{...ze,tokens:{[R.USDC]:Cs},explorer:"https://testnet.snowtrace.io"},BASE_MAINNET:{...ke,tokens:{[R.USDC]:xs},explorer:"https://basescan.org"},BASE_TESTNET:{...xe,tokens:{[R.USDC]:ks},explorer:"https://sepolia.basescan.org"},BSC_MAINNET:{...De,tokens:{[R.USDC]:Ds},explorer:"https://bscscan.com"},ETHEREUM_MAINNET:{...Oe,tokens:{[R.USDC]:Ns},explorer:"https://etherscan.io"},ETHEREUM_TESTNET:{...Ne,tokens:{[R.USDC]:Os},explorer:"https://sepolia.etherscan.io"},STARKNET_MAINNET:{...Be,tokens:{[R.USDC]:Ms},explorer:""}};var _=(e=>(e.ARBITRUM="ARBITRUM_MAINNET",e.ARBITRUM_TESTNET="ARBITRUM_TESTNET",e.AVALANCHE="AVALANCHE_MAINNET",e.AVALANCHE_TESTNET="AVALANCHE_TESTNET",e.BASE="BASE_MAINNET",e.BASE_TESTNET="BASE_TESTNET",e.BSC="BSC_MAINNET",e.ETHEREUM="ETHEREUM_MAINNET",e.ETHEREUM_TESTNET="ETHEREUM_TESTNET",e.STARKNET="STARKNET_MAINNET",e))(_||{}),ne=(e=>(e.USDC="USDC",e))(ne||{});const zs=e=>{const t=e?.trim().toUpperCase();if(ot[t])return ot[t]};function Bs(e,t){return zs(e)?.tokens[t]?.address}var re=(e=>(e.PRODUCTION="production",e.STAGING="staging",e))(re||{});class l{constructor({api_key:t,env:s,seesion_token:n,props:r}){this.api_key=t||"",this.sessionToken=n||"",this.env=s??re.PRODUCTION,this.props=r}static async config(t){if(!l.app){if(!t)throw new Error("Please provide an api_key");l.app=new l(t)}return t&&(t.api_key!==void 0&&(l.app.api_key=t.api_key),t.seesion_token!==void 0&&(l.app.sessionToken=t.seesion_token),t.env!==void 0&&(l.app.env=t.env),t.props!==void 0&&(l.app.props=t.props)),l.app}static getApiKey(){if(!l.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return l.app.api_key}static getSessionToken(){if(!l.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return l.app.sessionToken}static getProps(){if(!l.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return l.app.props}static getEnv(){if(!l.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return l.app.env==="internal"?"staging":l.app.env}static getBaseUrl(){if(!l.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(l.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(t){if(!l.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const s=l.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",n=Number(t),r=t&&!isNaN(Number(t))&&n>0?"/pay/":"/deposit/",i=`${t&&!isNaN(Number(t))&&n>0?n*100:""}`;return s+r+i}}let oe=null;function $s(){oe=_t.create({prefixUrl:l.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[e=>{const t=l.getSessionToken()||l.getApiKey();e.headers.set("Authorization",`Bearer ${t}`)}],afterResponse:[(e,t,s)=>s]},retry:{limit:2}})}function m(){return oe||$s(),oe}class js{async getById(t){return await m().get("intents/"+t).json()}async getForSender(t){return await m().get("intents/user/"+t).json()}async getForAddress(t){return await m().get("intents/address/"+t).json()}async getForSession(t){return await m().get("modal/sessions/intents/"+t).json()}async getAll(t){return await m().get("intents",{searchParams:t}).json()}async create(t){return await m().post("intents",{json:t}).json()}async createForSession(t){return await m().post("modal/sessions/intents",{json:t}).json()}async update(t,s){return await m().post("intents",{json:s}).json()}async triggerProcessing(t){return await m().post(`intents/${t}/trigger-processing`).json()}async triggerProcessingForSession(t){return await m().post(`modal/sessions/intents/${t}/process`).json()}}class Ls{async getFromSpecificBridge(t){return await m().get("quotes/single",{searchParams:t}).json()}async getFromAllBridges(t){return await m().get("quotes/multiple",{searchParams:t}).json()}async getBestAcrossBridges(t){return await m().get("quotes/best",{searchParams:t}).json()}async getAll(t){return await m().get("quotes/multi-source",{searchParams:t}).json()}async getAllForSession(t){return await m().get("modal/sessions/quotes",{searchParams:t}).json()}}class _s{async getOptimalRoutes(t){return await m().get("router/optimal-route",{searchParams:t}).json()}async getAllSupportedBridges(){return await m().get("router/supported-bridges/all").json()}async getSupportedBridges(t){return await m().get("router/supported-bridges/route",{searchParams:t}).json()}async getSupportedRoutes(t,s){return await m().get("router/supported-bridges/bridge/"+t,{searchParams:s}).json()}}class qs{async getSupported(t){return await m().get("chains",{searchParams:t}).json()}}class Fs{async getClientInfo(){return await m().get("client/auth/client-info").json()}async getClientInfoForSession(){return await m().get("modal/sessions/client").json()}}class Hs{getSessionToken(t){const s={recipient:t.recipient,tokenOut:Bs(_[t.destinationChain?.replace("_MAINNET","")],ne[t.token]),destinationChain:_[t.destinationChain?.replace("_MAINNET","")],amount:t.amount};return m().post("modal/sessions",{json:s}).json().then(n=>({...n,amount:s.amount}))}}const Ks={router:new _s,quotes:new Ls,intents:new js,chains:new qs,client:new Fs,auth:new Hs};function it(e){var t,s,n="";if(typeof e=="string"||typeof e=="number")n+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(s=it(e[t]))&&(n&&(n+=" "),n+=s)}else for(s in e)e[s]&&(n&&(n+=" "),n+=s);return n}function Ws(){for(var e,t,s=0,n="",r=arguments.length;s<r;s++)(e=arguments[s])&&(t=it(e))&&(n&&(n+=" "),n+=t);return n}function Vs(e){const{amount:t,styles:s,excludeChains:n,isOpen:r,isPending:i,open:o,close:a,onCancel:c,onSuccess:u,session_url:f,sessionToken:b}=e,[p,y]=g.useState(0),[E,me]=g.useState(""),h=g.useRef(null);l.config({api_key:"",env:e.env==="internal"?"internal":"production"}),g.useEffect(()=>{me(l.getPayModalUrl(t))},[t]),g.useEffect(()=>{const d=document.body.style.overflow;r?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=d||"";const T=k=>{k.data==="closed"&&(a(),c?.()),k.data==="completed"&&(window.setTimeout(a,2e3),u?.())};return window.addEventListener("message",T),()=>{document.body.style.overflow=d||"",window.removeEventListener("message",T)}},[r,c,u]),g.useEffect(()=>{if(!b)return;const d={type:"session",session_token:b,environment:l.getEnv()||re.PRODUCTION,styles:s,props:{excludeChains:n?.join(",")}};h.current?.contentWindow?.postMessage(d,"https://app.chainrails.io"),h.current?.contentWindow?.postMessage(d,"https://chainrails-frontend-git-staging-horus-labs.vercel.app"),window.setTimeout(()=>{h.current?.contentWindow?.postMessage(d,"https://app.chainrails.io"),h.current?.contentWindow?.postMessage(d,"https://chainrails-frontend-git-staging-horus-labs.vercel.app")},1e3)},[b,p,r,s]);function w(){y(Math.random())}return x.jsxs("div",{className:Ws("payment-modal-wrapper",p===0||i?"loading":"not-loading",r?"open":"closed"),children:[(p===0||i)&&x.jsx("div",{role:"status",className:"payment-modal-loader",children:x.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[x.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),x.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}),x.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:E||void 0,onLoad:w,className:`payment-modal ${p===0||i?"invisible":"visible"}`,"data-id":t,ref:h},t)]})}const Ys=Symbol(),ie=Symbol(),N="a",at="f",ct="p",ut="c",lt="t",ae="h",M="w",ce="o",ue="k";let Xs=(e,t)=>new Proxy(e,t);const le=Object.getPrototypeOf,fe=new WeakMap,ft=e=>e&&(fe.has(e)?fe.get(e):le(e)===Object.prototype||le(e)===Array.prototype),q=e=>typeof e=="object"&&e!==null,Js=e=>Object.values(Object.getOwnPropertyDescriptors(e)).some(t=>!t.configurable&&!t.writable),Gs=e=>{if(Array.isArray(e))return Array.from(e);const t=Object.getOwnPropertyDescriptors(e);return Object.values(t).forEach(s=>{s.configurable=!0}),Object.create(le(e),t)},Zs=(e,t)=>{const s={[at]:t};let n=!1;const r=(a,c)=>{if(!n){let u=s[N].get(e);if(u||(u={},s[N].set(e,u)),a===M)u[M]=!0;else{let f=u[a];f||(f=new Set,u[a]=f),f.add(c)}}},i=()=>{n=!0,s[N].delete(e)},o={get(a,c){return c===ie?e:(r(ue,c),ht(Reflect.get(a,c),s[N],s[ut],s[lt]))},has(a,c){return c===Ys?(i(),!0):(r(ae,c),Reflect.has(a,c))},getOwnPropertyDescriptor(a,c){return r(ce,c),Reflect.getOwnPropertyDescriptor(a,c)},ownKeys(a){return r(M),Reflect.ownKeys(a)}};return t&&(o.set=o.deleteProperty=()=>!1),[o,s]},he=e=>e[ie]||e,ht=(e,t,s,n)=>{if(!ft(e))return e;let r=n&&n.get(e);if(!r){const c=he(e);Js(c)?r=[c,Gs(c)]:r=[c],n?.set(e,r)}const[i,o]=r;let a=s&&s.get(i);return(!a||a[1][at]!==!!o)&&(a=Zs(i,!!o),a[1][ct]=Xs(o||i,a[0]),s&&s.set(i,a)),a[1][N]=t,a[1][ut]=s,a[1][lt]=n,a[1][ct]},Qs=(e,t)=>{const s=Reflect.ownKeys(e),n=Reflect.ownKeys(t);return s.length!==n.length||s.some((r,i)=>r!==n[i])},dt=(e,t,s,n,r=Object.is)=>{if(r(e,t))return!1;if(!q(e)||!q(t))return!0;const i=s.get(he(e));if(!i)return!0;if(n){if(n.get(e)===t)return!1;n.set(e,t)}let o=null;for(const a of i[ae]||[])if(o=Reflect.has(e,a)!==Reflect.has(t,a),o)return o;if(i[M]===!0){if(o=Qs(e,t),o)return o}else for(const a of i[ce]||[]){const c=!!Reflect.getOwnPropertyDescriptor(e,a),u=!!Reflect.getOwnPropertyDescriptor(t,a);if(o=c!==u,o)return o}for(const a of i[ue]||[])if(o=dt(e[a],t[a],s,n,r),o)return o;if(o===null)throw new Error("invalid used");return o},en=e=>ft(e)&&e[ie]||null,pt=(e,t=!0)=>{fe.set(e,t)},tn=(e,t,s)=>{const n=[],r=new WeakSet,i=(o,a)=>{var c,u,f;if(r.has(o))return;q(o)&&r.add(o);const b=q(o)&&t.get(he(o));if(b){if((c=b[ae])===null||c===void 0||c.forEach(p=>{const y=`:has(${String(p)})`;n.push(a?[...a,y]:[y])}),b[M]===!0){const p=":ownKeys";n.push(a?[...a,p]:[p])}else(u=b[ce])===null||u===void 0||u.forEach(p=>{const y=`:hasOwn(${String(p)})`;n.push(a?[...a,y]:[y])});(f=b[ue])===null||f===void 0||f.forEach(p=>{"value"in(Object.getOwnPropertyDescriptor(o,p)||{})&&i(o[p],a?[...a,p]:[p])})}else a&&n.push(a)};return i(e),n},F={},de=e=>typeof e=="object"&&e!==null,sn=e=>de(e)&&!pe.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)&&!(e instanceof Promise),gt=(e,t)=>{const s=mt.get(e);if(s?.[0]===t)return s[1];const n=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return pt(n,!0),mt.set(e,[t,n]),Reflect.ownKeys(e).forEach(r=>{if(Object.getOwnPropertyDescriptor(n,r))return;const i=Reflect.get(e,r),{enumerable:o}=Reflect.getOwnPropertyDescriptor(e,r),a={value:i,enumerable:o,configurable:!0};if(pe.has(i))pt(i,!1);else if(U.has(i)){const[c,u]=U.get(i);a.value=gt(c,u())}Object.defineProperty(n,r,a)}),Object.preventExtensions(n)},nn=(e,t,s,n)=>({deleteProperty(r,i){const o=Reflect.get(r,i);s(i);const a=Reflect.deleteProperty(r,i);return a&&n(["delete",[i],o]),a},set(r,i,o,a){const c=!e()&&Reflect.has(r,i),u=Reflect.get(r,i,a);if(c&&(yt(u,o)||H.has(o)&&yt(u,H.get(o))))return!0;s(i),de(o)&&(o=en(o)||o);const f=!U.has(o)&&on(o)?wt(o):o;return t(i,f),Reflect.set(r,i,f,a),n(["set",[i],o,u]),!0}}),U=new WeakMap,pe=new WeakSet,mt=new WeakMap,ge=[1],H=new WeakMap;let yt=Object.is,rn=(e,t)=>new Proxy(e,t),on=sn,an=gt,cn=nn;function wt(e={}){if(!de(e))throw new Error("object required");const t=H.get(e);if(t)return t;let s=ge[0];const n=new Set,r=(h,w=++ge[0])=>{s!==w&&(i=s=w,n.forEach(d=>d(h,w)))};let i=s;const o=(h=ge[0])=>(i!==h&&(i=h,c.forEach(([w])=>{const d=w[1](h);d>s&&(s=d)})),s),a=h=>(w,d)=>{const T=[...w];T[1]=[h,...T[1]],r(T,d)},c=new Map,u=(h,w)=>{const d=!pe.has(w)&&U.get(w);if(d){if((F?"production":void 0)!=="production"&&c.has(h))throw new Error("prop listener already exists");if(n.size){const T=d[2](a(h));c.set(h,[d,T])}else c.set(h,[d])}},f=h=>{var w;const d=c.get(h);d&&(c.delete(h),(w=d[1])==null||w.call(d))},b=h=>(n.add(h),n.size===1&&c.forEach(([d,T],k)=>{if((F?"production":void 0)!=="production"&&T)throw new Error("remove already exists");const mn=d[2](a(k));c.set(k,[d,mn])}),()=>{n.delete(h),n.size===0&&c.forEach(([d,T],k)=>{T&&(T(),c.set(k,[d]))})});let p=!0;const y=cn(()=>p,u,f,r),E=rn(e,y);H.set(e,E);const me=[e,o,b];return U.set(E,me),Reflect.ownKeys(e).forEach(h=>{const w=Object.getOwnPropertyDescriptor(e,h);"value"in w&&w.writable&&(E[h]=e[h])}),p=!1,E}function un(e,t,s){const n=U.get(e);(F?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let r;const i=[],o=n[2];let a=!1;const u=o(f=>{i.push(f),r||(r=Promise.resolve().then(()=>{r=void 0,a&&t(i.splice(0))}))});return a=!0,()=>{a=!1,u()}}function bt(e){const t=U.get(e);(F?"production":void 0)!=="production"&&!t&&console.warn("Please use proxy object");const[s,n]=t;return an(s,n())}const ln={},fn=(e,t)=>{const s=g.useRef(void 0);g.useEffect(()=>{s.current=tn(e,t)}),g.useDebugValue(s.current)},hn=new WeakMap;function dn(e,t){const n=g.useMemo(()=>e&&new WeakMap,[e]),r=g.useRef(void 0);let i=!0;const o=g.useSyncExternalStore(g.useCallback(c=>{const u=un(e,c);return c(),u},[e,void 0]),()=>{const c=bt(e);try{if(!i&&r.current&&!dt(r.current,c,n,new WeakMap))return r.current}catch{}return c},()=>bt(e));i=!1,g.useLayoutEffect(()=>{r.current=o}),(ln?"production":void 0)!=="production"&&fn(o,n);const a=g.useMemo(()=>new WeakMap,[]);return ht(o,n,a,hn)}const I=wt({data:null,isPending:!1,error:null});function pn({session_url:e,onCancel:t,onSuccess:s}){const n=dn(I),[r,i]=g.useState(!1),[o,a]=g.useState(Date.now()),c=n?.data?.sessionToken,u=n?.data?.amount;function f(){c||window.setTimeout(()=>{c&&i(!0)},200),i(!0)}function b(){i(!1)}const p=()=>{const y=Date.now();I.isPending=!0,I.error=null,I.data=null,fetch(e,{headers:{"Content-Type":"application/json"}}).then(E=>E.json()).then(E=>{y<o||(I.data=E,I.isPending=!1,a(y))}).catch(E=>{y<o||(I.error=E?.toString(),I.isPending=!1,a(y),setInterval(p,5e3))})};return g.useEffect(()=>{p()},[e]),{sessionToken:c,amount:u,isOpen:r,session_url:e,open:f,close:b,isPending:n.isPending,error:n.error,refetch:p,onSuccess:s,onCancel:t}}function gn({sessionToken:e,amount:t,onCancel:s,onSuccess:n}){const[r,i]=g.useState(!1),[o,a]=g.useState(e),[c,u]=g.useState(t);function f({sessionToken:y,amount:E}){a(y),u(E)}g.useEffect(()=>{a(e)},[e]);function b(){o||window.setTimeout(()=>{o&&i(!0)},200),i(!0)}function p(){i(!1)}return{sessionToken:o,updateSession:f,amount:c,isOpen:r,open:b,close:p,onSuccess:n,onCancel:s}}S.Chainrails=l,S.PaymentModal=Vs,S.chains=_,S.crapi=Ks,S.tokens=ne,S.usePaymentModal=gn,S.usePaymentSession=pn,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(R,p){typeof exports=="object"&&typeof module<"u"?p(exports,require("react"),require("react/jsx-runtime")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime"],p):(R=typeof globalThis<"u"?globalThis:R||self,p(R.Chainrails={},R.React,R.jsxRuntime))})(this,(function(R,p,N){"use strict";var be=document.createElement("style");be.textContent=`.payment-modal-wrapper{position:fixed;inset:0;z-index:10000;height:100dvh;width:100vw;transition:all .1s ease-in-out}.payment-modal-wrapper.loading{background-color:#0003;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px)}.payment-modal-wrapper.not-loading{background-color:#0008;-webkit-backdrop-filter:blur(4px);backdrop-filter:blur(4px)}.payment-modal-wrapper.open{visibility:visible}.payment-modal-wrapper.closed{visibility:hidden;opacity:0;pointer-events:none}.payment-modal-wrapper.closed *{pointer-events:none!important}.payment-modal-wrapper.open iframe{transform:translateY(0);transform:scale(1)}.payment-modal-wrapper.closed iframe{transform:translateY(50vh);transform:scale(1)}.payment-modal-loader{position:absolute;inset:0;z-index:10000;display:grid;height:100%;width:100%;place-content:center}.payment-modal-loader .icon{height:48px;width:48px;animation:cr-spin 1s linear infinite;fill:#2563eb;color:#475569}.payment-modal{position:absolute;inset:0;z-index:10000;height:100%;width:100%;transition:all .3s cubic-bezier(.25,1,.5,1)}.payment-modal.visible{opacity:1}.payment-modal.invisible{opacity:0}@keyframes cr-spin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}
2
+ /*$vite$:1*/`,document.head.appendChild(be);class W extends Error{response;request;options;constructor(e,s,n){const r=e.status||e.status===0?e.status:"",i=e.statusText??"",o=`${r} ${i}`.trim(),a=o?`status code ${o}`:"an unknown error";super(`Request failed with ${a}: ${s.method} ${s.url}`),this.name="HTTPError",this.response=e,this.request=s,this.options=n}}class Ee extends Error{name="NonError";value;constructor(e){let s="Non-error value was thrown";try{typeof e=="string"?s=e:e&&typeof e=="object"&&"message"in e&&typeof e.message=="string"&&(s=e.message)}catch{}super(s),this.value=e}}class Y extends Error{name="ForceRetryError";customDelay;code;customRequest;constructor(e){const s=e?.cause?e.cause instanceof Error?e.cause:new Ee(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:"Forced retry",s?{cause:s}:void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}}const Te=(()=>{let t=!1,e=!1;const s=typeof globalThis.ReadableStream=="function",n=typeof globalThis.Request=="function";if(s&&n)try{e=new globalThis.Request("https://empty.invalid",{body:new globalThis.ReadableStream,method:"POST",get duplex(){return t=!0,"half"}}).headers.has("Content-Type")}catch(r){if(r instanceof Error&&r.message==="unsupported BodyInit type")return!1;throw r}return t&&!e})(),dt=typeof globalThis.AbortController=="function",Se=typeof globalThis.AbortSignal=="function"&&typeof globalThis.AbortSignal.any=="function",ft=typeof globalThis.ReadableStream=="function",ht=typeof globalThis.FormData=="function",we=["get","post","put","patch","head","delete"],mt={json:"application/json",text:"text/*",formData:"multipart/form-data",arrayBuffer:"*/*",blob:"*/*",bytes:"*/*"},V=2147483647,gt=new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length,Ce=Symbol("stop");class Re{options;constructor(e){this.options=e}}const pt=t=>new Re(t),yt={json:!0,parseJson:!0,stringifyJson:!0,searchParams:!0,prefixUrl:!0,retry:!0,timeout:!0,hooks:!0,throwHttpErrors:!0,onDownloadProgress:!0,onUploadProgress:!0,fetch:!0,context:!0},bt={next:!0},Et={method:!0,headers:!0,body:!0,mode:!0,credentials:!0,cache:!0,redirect:!0,referrer:!0,referrerPolicy:!0,integrity:!0,keepalive:!0,signal:!0,window:!0,duplex:!0},Tt=t=>{if(!t)return 0;if(t instanceof FormData){let e=0;for(const[s,n]of t)e+=gt,e+=new TextEncoder().encode(`Content-Disposition: form-data; name="${s}"`).length,e+=typeof n=="string"?new TextEncoder().encode(n).length:n.size;return e}if(t instanceof Blob)return t.size;if(t instanceof ArrayBuffer)return t.byteLength;if(typeof t=="string")return new TextEncoder().encode(t).length;if(t instanceof URLSearchParams)return new TextEncoder().encode(t.toString()).length;if("byteLength"in t)return t.byteLength;if(typeof t=="object"&&t!==null)try{const e=JSON.stringify(t);return new TextEncoder().encode(e).length}catch{return 0}return 0},Ae=(t,e,s)=>{let n,r=0;return t.pipeThrough(new TransformStream({transform(i,o){if(o.enqueue(i),n){r+=n.byteLength;let a=e===0?0:r/e;a>=1&&(a=1-Number.EPSILON),s?.({percent:a,totalBytes:Math.max(e,r),transferredBytes:r},n)}n=i},flush(){n&&(r+=n.byteLength,s?.({percent:1,totalBytes:Math.max(e,r),transferredBytes:r},n))}}))},St=(t,e)=>{if(!t.body)return t;if(t.status===204)return new Response(null,{status:t.status,statusText:t.statusText,headers:t.headers});const s=Math.max(0,Number(t.headers.get("content-length"))||0);return new Response(Ae(t.body,s,e),{status:t.status,statusText:t.statusText,headers:t.headers})},wt=(t,e,s)=>{if(!t.body)return t;const n=Tt(s??t.body);return new Request(t,{duplex:"half",body:Ae(t.body,n,e)})},P=t=>t!==null&&typeof t=="object",_=(...t)=>{for(const e of t)if((!P(e)||Array.isArray(e))&&e!==void 0)throw new TypeError("The `options` argument must be an object");return G({},...t)},De=(t={},e={})=>{const s=new globalThis.Headers(t),n=e instanceof globalThis.Headers,r=new globalThis.Headers(e);for(const[i,o]of r.entries())n&&o==="undefined"||o===void 0?s.delete(i):s.set(i,o);return s};function F(t,e,s){return Object.hasOwn(e,s)&&e[s]===void 0?[]:G(t[s]??[],e[s]??[])}const Ue=(t={},e={})=>({beforeRequest:F(t,e,"beforeRequest"),beforeRetry:F(t,e,"beforeRetry"),afterResponse:F(t,e,"afterResponse"),beforeError:F(t,e,"beforeError")}),Ct=(t,e)=>{const s=new URLSearchParams;for(const n of[t,e])if(n!==void 0)if(n instanceof URLSearchParams)for(const[r,i]of n.entries())s.append(r,i);else if(Array.isArray(n))for(const r of n){if(!Array.isArray(r)||r.length!==2)throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");s.append(String(r[0]),String(r[1]))}else if(P(n))for(const[r,i]of Object.entries(n))i!==void 0&&s.append(r,String(i));else{const r=new URLSearchParams(n);for(const[i,o]of r.entries())s.append(i,o)}return s},G=(...t)=>{let e={},s={},n={},r;const i=[];for(const o of t)if(Array.isArray(o))Array.isArray(e)||(e=[]),e=[...e,...o];else if(P(o)){for(let[a,u]of Object.entries(o)){if(a==="signal"&&u instanceof globalThis.AbortSignal){i.push(u);continue}if(a==="context"){if(u!=null&&(!P(u)||Array.isArray(u)))throw new TypeError("The `context` option must be an object");e={...e,context:u==null?{}:{...e.context,...u}};continue}if(a==="searchParams"){u==null?r=void 0:r=r===void 0?u:Ct(r,u);continue}P(u)&&a in e&&(u=G(e[a],u)),e={...e,[a]:u}}P(o.hooks)&&(n=Ue(n,o.hooks),e.hooks=n),P(o.headers)&&(s=De(s,o.headers),e.headers=s)}return r!==void 0&&(e.searchParams=r),i.length>0&&(i.length===1?e.signal=i[0]:Se?e.signal=AbortSignal.any(i):e.signal=i.at(-1)),e.context===void 0&&(e.context={}),e},Rt=t=>we.includes(t)?t.toUpperCase():t,Ie={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:Number.POSITIVE_INFINITY,backoffLimit:Number.POSITIVE_INFINITY,delay:t=>.3*2**(t-1)*1e3,jitter:void 0,retryOnTimeout:!1},At=(t={})=>{if(typeof t=="number")return{...Ie,limit:t};if(t.methods&&!Array.isArray(t.methods))throw new Error("retry.methods must be an array");if(t.statusCodes&&!Array.isArray(t.statusCodes))throw new Error("retry.statusCodes must be an array");return{...Ie,...t}};class X extends Error{request;constructor(e){super(`Request timed out: ${e.method} ${e.url}`),this.name="TimeoutError",this.request=e}}async function Dt(t,e,s,n){return new Promise((r,i)=>{const o=setTimeout(()=>{s&&s.abort(),i(new X(t))},n.timeout);n.fetch(t,e).then(r).catch(i).then(()=>{clearTimeout(o)})})}async function Ut(t,{signal:e}){return new Promise((s,n)=>{e&&(e.throwIfAborted(),e.addEventListener("abort",r,{once:!0}));function r(){clearTimeout(i),n(e.reason)}const i=setTimeout(()=>{e?.removeEventListener("abort",r),s()},t)})}const It=(t,e)=>{const s={};for(const n in e)Object.hasOwn(e,n)&&!(n in Et)&&!(n in yt)&&(!(n in t)||n in bt)&&(s[n]=e[n]);return s},vt=t=>t===void 0?!1:Array.isArray(t)?t.length>0:t instanceof URLSearchParams?t.size>0:typeof t=="object"?Object.keys(t).length>0:typeof t=="string"?t.trim().length>0:!!t;function Pt(t){return t instanceof W||t?.name===W.name}function kt(t){return t instanceof X||t?.name===X.name}class O{static create(e,s){const n=new O(e,s),r=async()=>{if(typeof n.#e.timeout=="number"&&n.#e.timeout>V)throw new RangeError(`The \`timeout\` option cannot be greater than ${V}`);await Promise.resolve();let o=await n.#g();for(const a of n.#e.hooks.afterResponse){const u=n.#l(o.clone()),l=await a(n.request,n.#a(),u,{retryCount:n.#s});if(l instanceof globalThis.Response&&(o=l),l instanceof Re)throw await Promise.all([u.body?.cancel(),o.body?.cancel()]),new Y(l.options)}if(n.#l(o),!o.ok&&(typeof n.#e.throwHttpErrors=="function"?n.#e.throwHttpErrors(o.status):n.#e.throwHttpErrors)){let a=new W(o,n.request,n.#a());for(const u of n.#e.hooks.beforeError)a=await u(a,{retryCount:n.#s});throw a}if(n.#e.onDownloadProgress){if(typeof n.#e.onDownloadProgress!="function")throw new TypeError("The `onDownloadProgress` option must be a function");if(!ft)throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");return St(o.clone(),n.#e.onDownloadProgress)}return o},i=n.#d(r).finally(async()=>{const o=n.#o,a=[];o&&!o.bodyUsed&&a.push(o.body?.cancel()),n.request.bodyUsed||a.push(n.request.body?.cancel()),await Promise.all(a)});for(const[o,a]of Object.entries(mt))o==="bytes"&&typeof globalThis.Response?.prototype?.bytes!="function"||(i[o]=async()=>{n.request.headers.set("accept",n.request.headers.get("accept")||a);const u=await i;if(o==="json"){if(u.status===204)return"";const l=await u.text();return l===""?"":s.parseJson?s.parseJson(l):JSON.parse(l)}return u[o]()});return i}static#h(e){return e&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0)):e}request;#n;#s=0;#t;#e;#o;#r;#i;constructor(e,s={}){if(this.#t=e,this.#e={...s,headers:De(this.#t.headers,s.headers),hooks:Ue({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:Rt(s.method??this.#t.method??"GET"),prefixUrl:String(s.prefixUrl||""),retry:At(s.retry),throwHttpErrors:s.throwHttpErrors??!0,timeout:s.timeout??1e4,fetch:s.fetch??globalThis.fetch.bind(globalThis),context:s.context??{}},typeof this.#t!="string"&&!(this.#t instanceof URL||this.#t instanceof globalThis.Request))throw new TypeError("`input` must be a string, URL, or Request");if(this.#e.prefixUrl&&typeof this.#t=="string"){if(this.#t.startsWith("/"))throw new Error("`input` must not begin with a slash when using `prefixUrl`");this.#e.prefixUrl.endsWith("/")||(this.#e.prefixUrl+="/"),this.#t=this.#e.prefixUrl+this.#t}dt&&Se&&(this.#r=this.#e.signal??this.#t.signal,this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal),Te&&(this.#e.duplex="half"),this.#e.json!==void 0&&(this.#e.body=this.#e.stringifyJson?.(this.#e.json)??JSON.stringify(this.#e.json),this.#e.headers.set("content-type",this.#e.headers.get("content-type")??"application/json"));const n=s.headers&&new globalThis.Headers(s.headers).has("content-type");if(this.#t instanceof globalThis.Request&&(ht&&this.#e.body instanceof globalThis.FormData||this.#e.body instanceof URLSearchParams)&&!n&&this.#e.headers.delete("content-type"),this.request=new globalThis.Request(this.#t,this.#e),vt(this.#e.searchParams)){const i="?"+(typeof this.#e.searchParams=="string"?this.#e.searchParams.replace(/^\?/,""):new URLSearchParams(O.#h(this.#e.searchParams)).toString()),o=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,i);this.request=new globalThis.Request(o,this.#e)}if(this.#e.onUploadProgress){if(typeof this.#e.onUploadProgress!="function")throw new TypeError("The `onUploadProgress` option must be a function");if(!Te)throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=this.#f(this.request,this.#e.body??void 0)}}#c(){const e=this.#e.retry.delay(this.#s);let s=e;return this.#e.retry.jitter===!0?s=Math.random()*e:typeof this.#e.retry.jitter=="function"&&(s=this.#e.retry.jitter(e),(!Number.isFinite(s)||s<0)&&(s=e)),Math.min(this.#e.retry.backoffLimit,s)}async#m(e){if(this.#s++,this.#s>this.#e.retry.limit)throw e;const s=e instanceof Error?e:new Ee(e);if(s instanceof Y)return s.customDelay??this.#c();if(!this.#e.retry.methods.includes(this.request.method.toLowerCase()))throw e;if(this.#e.retry.shouldRetry!==void 0){const n=await this.#e.retry.shouldRetry({error:s,retryCount:this.#s});if(n===!1)throw e;if(n===!0)return this.#c()}if(kt(e)&&!this.#e.retry.retryOnTimeout)throw e;if(Pt(e)){if(!this.#e.retry.statusCodes.includes(e.response.status))throw e;const n=e.response.headers.get("Retry-After")??e.response.headers.get("RateLimit-Reset")??e.response.headers.get("X-RateLimit-Retry-After")??e.response.headers.get("X-RateLimit-Reset")??e.response.headers.get("X-Rate-Limit-Reset");if(n&&this.#e.retry.afterStatusCodes.includes(e.response.status)){let r=Number(n)*1e3;Number.isNaN(r)?r=Date.parse(n)-Date.now():r>=Date.parse("2024-01-01")&&(r-=Date.now());const i=this.#e.retry.maxRetryAfter??r;return r<i?r:i}if(e.response.status===413)throw e}return this.#c()}#l(e){return this.#e.parseJson&&(e.json=async()=>this.#e.parseJson(await e.text())),e}async#d(e){try{return await e()}catch(s){const n=Math.min(await this.#m(s),V);if(this.#s<1)throw s;if(await Ut(n,this.#r?{signal:this.#r}:{}),s instanceof Y&&s.customRequest){const r=this.#e.signal?new globalThis.Request(s.customRequest,{signal:this.#e.signal}):new globalThis.Request(s.customRequest);this.#u(r)}for(const r of this.#e.hooks.beforeRetry){const i=await r({request:this.request,options:this.#a(),error:s,retryCount:this.#s});if(i instanceof globalThis.Request){this.#u(i);break}if(i instanceof globalThis.Response)return i;if(i===Ce)return}return this.#d(e)}}async#g(){this.#n?.signal.aborted&&(this.#n=new globalThis.AbortController,this.#e.signal=this.#r?AbortSignal.any([this.#r,this.#n.signal]):this.#n.signal,this.request=new globalThis.Request(this.request,{signal:this.#e.signal}));for(const s of this.#e.hooks.beforeRequest){const n=await s(this.request,this.#a(),{retryCount:this.#s});if(n instanceof Response)return n;if(n instanceof globalThis.Request){this.#u(n);break}}const e=It(this.request,this.#e);return this.#o=this.request,this.request=this.#o.clone(),this.#e.timeout===!1?this.#e.fetch(this.#o,e):Dt(this.#o,e,this.#n,this.#e)}#a(){if(!this.#i){const{hooks:e,...s}=this.#e;this.#i=Object.freeze(s)}return this.#i}#u(e){this.#i=void 0,this.request=this.#f(e)}#f(e,s){return!this.#e.onUploadProgress||!e.body?e:wt(e,this.#e.onUploadProgress,s??this.#e.body??void 0)}}/*! MIT License © Sindre Sorhus */const J=t=>{const e=(s,n)=>O.create(s,_(t,n));for(const s of we)e[s]=(n,r)=>O.create(n,_(t,r,{method:s}));return e.create=s=>J(_(s)),e.extend=s=>(typeof s=="function"&&(s=s(t??{})),J(_(t,s))),e.stop=Ce,e.retry=pt,e},xt=J(),E={ARBITRUM:"ARBITRUM_MAINNET",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE_MAINNET",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE_MAINNET",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC_MAINNET",ETHEREUM:"ETHEREUM_MAINNET",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM_MAINNET",LISK:"LISK_MAINNET",MONAD:"MONAD_MAINNET",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM_MAINNET",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON_MAINNET",STARKNET:"STARKNET_MAINNET",STARKNET_TESTNET:"STARKNET_TESTNET"},Nt={ARBITRUM:"ARBITRUM",ARBITRUM_TESTNET:"ARBITRUM_TESTNET",AVALANCHE:"AVALANCHE",AVALANCHE_TESTNET:"AVALANCHE_TESTNET",BASE:"BASE",BASE_TESTNET:"BASE_TESTNET",BSC:"BSC",ETHEREUM:"ETHEREUM",ETHEREUM_TESTNET:"ETHEREUM_TESTNET",HYPEREVM:"HYPEREVM",LISK:"LISK",MONAD:"MONAD",MONAD_TESTNET:"MONAD_TESTNET",OPTIMISM:"OPTIMISM",OPTIMISM_TESTNET:"OPTIMISM_TESTNET",POLYGON:"POLYGON",STARKNET:"STARKNET",STARKNET_TESTNET:"STARKNET_TESTNET"};function Z(t,{strict:e=!0}={}){return!t||typeof t!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(t):t.startsWith("0x")}function ve(t){return Z(t,{strict:!1})?Math.ceil((t.length-2)/2):t.length}const Pe="2.43.4";let Q={getDocsUrl:({docsBaseUrl:t,docsPath:e="",docsSlug:s})=>e?`${t??"https://viem.sh"}${e}${s?`#${s}`:""}`:void 0,version:`viem@${Pe}`};class I extends Error{constructor(e,s={}){const n=s.cause instanceof I?s.cause.details:s.cause?.message?s.cause.message:s.details,r=s.cause instanceof I&&s.cause.docsPath||s.docsPath,i=Q.getDocsUrl?.({...s,docsPath:r}),o=[e||"An error occurred.","",...s.metaMessages?[...s.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...n?[`Details: ${n}`]:[],...Q.version?[`Version: ${Q.version}`]:[]].join(`
3
+ `);super(o,s.cause?{cause:s.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=r,this.metaMessages=s.metaMessages,this.name=s.name??this.name,this.shortMessage=e,this.version=Pe}walk(e){return ke(this,e)}}function ke(t,e){return e?.(t)?t:t&&typeof t=="object"&&"cause"in t&&t.cause!==void 0?ke(t.cause,e):e?null:t}class xe extends I{constructor({size:e,targetSize:s,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${e}) exceeds padding size (${s}).`,{name:"SizeExceedsPaddingSizeError"})}}function H(t,{dir:e,size:s=32}={}){return typeof t=="string"?Ot(t,{dir:e,size:s}):Bt(t,{dir:e,size:s})}function Ot(t,{dir:e,size:s=32}={}){if(s===null)return t;const n=t.replace("0x","");if(n.length>s*2)throw new xe({size:Math.ceil(n.length/2),targetSize:s,type:"hex"});return`0x${n[e==="right"?"padEnd":"padStart"](s*2,"0")}`}function Bt(t,{dir:e,size:s=32}={}){if(s===null)return t;if(t.length>s)throw new xe({size:t.length,targetSize:s,type:"bytes"});const n=new Uint8Array(s);for(let r=0;r<s;r++){const i=e==="right";n[i?r:s-r-1]=t[i?r:t.length-r-1]}return n}class Mt extends I{constructor({max:e,min:s,signed:n,size:r,value:i}){super(`Number "${i}" is not in safe ${r?`${r*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${e?`(${s} to ${e})`:`(above ${s})`}`,{name:"IntegerOutOfRangeError"})}}class Lt extends I{constructor({givenSize:e,maxSize:s}){super(`Size cannot exceed ${s} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function ee(t,{size:e}){if(ve(t)>e)throw new Lt({givenSize:ve(t),maxSize:e})}function _t(t,e={}){const{signed:s,size:n}=e,r=BigInt(t);let i;n?s?i=(1n<<BigInt(n)*8n-1n)-1n:i=2n**(BigInt(n)*8n)-1n:typeof t=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof i=="bigint"&&s?-i-1n:0;if(i&&r>i||r<o){const u=typeof t=="bigint"?"n":"";throw new Mt({max:i?`${i}${u}`:void 0,min:`${o}${u}`,signed:s,size:n,value:`${t}${u}`})}const a=`0x${(s&&r<0?(1n<<BigInt(n*8))+BigInt(r):r).toString(16)}`;return n?H(a,{size:n}):a}const Ft=new TextEncoder;function Ht(t,e={}){return typeof t=="number"||typeof t=="bigint"?zt(t,e):typeof t=="boolean"?$t(t,e):Z(t)?Oe(t,e):Be(t,e)}function $t(t,e={}){const s=new Uint8Array(1);return s[0]=Number(t),typeof e.size=="number"?(ee(s,{size:e.size}),H(s,{size:e.size})):s}const U={zero:48,nine:57,A:65,F:70,a:97,f:102};function Ne(t){if(t>=U.zero&&t<=U.nine)return t-U.zero;if(t>=U.A&&t<=U.F)return t-(U.A-10);if(t>=U.a&&t<=U.f)return t-(U.a-10)}function Oe(t,e={}){let s=t;e.size&&(ee(s,{size:e.size}),s=H(s,{dir:"right",size:e.size}));let n=s.slice(2);n.length%2&&(n=`0${n}`);const r=n.length/2,i=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const u=Ne(n.charCodeAt(a++)),l=Ne(n.charCodeAt(a++));if(u===void 0||l===void 0)throw new I(`Invalid byte sequence ("${n[a-2]}${n[a-1]}" in "${n}").`);i[o]=u*16+l}return i}function zt(t,e){const s=_t(t,e);return Oe(s)}function Be(t,e={}){const s=Ft.encode(t);return typeof e.size=="number"?(ee(s,{size:e.size}),H(s,{dir:"right",size:e.size})):s}const $=BigInt(2**32-1),Me=BigInt(32);function jt(t,e=!1){return e?{h:Number(t&$),l:Number(t>>Me&$)}:{h:Number(t>>Me&$)|0,l:Number(t&$)|0}}function qt(t,e=!1){const s=t.length;let n=new Uint32Array(s),r=new Uint32Array(s);for(let i=0;i<s;i++){const{h:o,l:a}=jt(t[i],e);[n[i],r[i]]=[o,a]}return[n,r]}const Kt=(t,e,s)=>t<<s|e>>>32-s,Wt=(t,e,s)=>e<<s|t>>>32-s,Yt=(t,e,s)=>e<<s-32|t>>>64-s,Vt=(t,e,s)=>t<<s-32|e>>>64-s;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Gt(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Le(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function z(t,...e){if(!Gt(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function _e(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Xt(t,e){z(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Jt(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Fe(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}const Zt=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Qt(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}function es(t){for(let e=0;e<t.length;e++)t[e]=Qt(t[e]);return t}const He=Zt?t=>t:es;function ts(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function $e(t){return typeof t=="string"&&(t=ts(t)),z(t),t}class ss{}function ns(t){const e=n=>t().update($e(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}const rs=BigInt(0),B=BigInt(1),os=BigInt(2),is=BigInt(7),as=BigInt(256),cs=BigInt(113),ze=[],je=[],qe=[];for(let t=0,e=B,s=1,n=0;t<24;t++){[s,n]=[n,(2*s+3*n)%5],ze.push(2*(5*n+s)),je.push((t+1)*(t+2)/2%64);let r=rs;for(let i=0;i<7;i++)e=(e<<B^(e>>is)*cs)%as,e&os&&(r^=B<<(B<<BigInt(i))-B);qe.push(r)}const Ke=qt(qe,!0),us=Ke[0],ls=Ke[1],We=(t,e,s)=>s>32?Yt(t,e,s):Kt(t,e,s),Ye=(t,e,s)=>s>32?Vt(t,e,s):Wt(t,e,s);function ds(t,e=24){const s=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,u=(o+2)%10,l=s[u],f=s[u+1],w=We(l,f,1)^s[a],g=Ye(l,f,1)^s[a+1];for(let b=0;b<50;b+=10)t[o+b]^=w,t[o+b+1]^=g}let r=t[2],i=t[3];for(let o=0;o<24;o++){const a=je[o],u=We(r,i,a),l=Ye(r,i,a),f=ze[o];r=t[f],i=t[f+1],t[f]=u,t[f+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=us[n],t[1]^=ls[n]}Fe(s)}class te extends ss{constructor(e,s,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=s,this.outputLen=n,this.enableXOF=r,this.rounds=i,Le(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Jt(this.state)}clone(){return this._cloneInto()}keccak(){He(this.state32),ds(this.state32,this.rounds),He(this.state32),this.posOut=0,this.pos=0}update(e){_e(this),e=$e(e),z(e);const{blockLen:s,state:n}=this,r=e.length;for(let i=0;i<r;){const o=Math.min(s-this.pos,r-i);for(let a=0;a<o;a++)n[this.pos++]^=e[i++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:n,blockLen:r}=this;e[n]^=s,(s&128)!==0&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){_e(this,!1),z(e),this.finish();const s=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-r);e.set(s.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Le(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Xt(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,Fe(this.state)}_cloneInto(e){const{blockLen:s,suffix:n,outputLen:r,rounds:i,enableXOF:o}=this;return e||(e=new te(s,n,r,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}}const fs=(t,e,s)=>ns(()=>new te(e,t,s)),hs=fs(1,136,256/8);function ms(t,e){return hs(Z(t,{strict:!1})?Ht(t):t)}class gs extends I{constructor({address:e}){super(`Address "${e}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class Ve extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const s=super.get(e);return super.has(e)&&s!==void 0&&(this.delete(e),super.set(e,s)),s}set(e,s){if(super.set(e,s),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const se=new Ve(8192);function Ge(t,e){if(se.has(`${t}.${e}`))return se.get(`${t}.${e}`);const s=t.substring(2).toLowerCase(),n=ms(Be(s)),r=s.split("");for(let o=0;o<40;o+=2)n[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(n[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const i=`0x${r.join("")}`;return se.set(`${t}.${e}`,i),i}function C(t,e){if(!ys(t,{strict:!1}))throw new gs({address:t});return Ge(t,e)}const ps=/^0x[a-fA-F0-9]{40}$/,ne=new Ve(8192);function ys(t,e){const{strict:s=!0}=e??{},n=`${t}.${s}`;if(ne.has(n))return ne.get(n);const r=ps.test(t)?t.toLowerCase()===t?!0:s?Ge(t)===t:!0:!1;return ne.set(n,r),r}const c={USDC:"USDC",USDT:"USDT",DAI:"DAI",BUSD:"BUSD",EURC:"EURC",ETH:"ETH",WETH:"WETH",STRK:"STRK",BNB:"BNB",LORDS:"LORDS"};c.USDC;const Xe={[E.ARBITRUM]:{[c.DAI]:{address:C("0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1"),symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png"},[c.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg"},[c.USDC]:{address:C("0xaf88d065e77c8cC2239327C5EDb3A432268e5831"),symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg"},[c.USDT]:{address:C("0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9"),symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png"},[c.WETH]:{address:C("0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"),symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png"}},[E.ARBITRUM_TESTNET]:{[c.USDC]:{address:C("0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"}},[E.AVALANCHE]:{[c.DAI]:{address:"0xd586E7F844cEa2F87f50152665BCbc2C279D8d70",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png"},[c.USDC]:{address:C("0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},[c.USDT]:{address:"0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7",symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png"},[c.WETH]:{address:"0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB",symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png"}},[E.AVALANCHE_TESTNET]:{[c.USDC]:{address:C("0x5425890298aed601595a70AB815c96711a31Bc65"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"}},[E.BASE]:{[c.DAI]:{address:"0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png"},[c.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg"},[c.EURC]:{address:"0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42",symbol:c.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png"},[c.USDC]:{address:C("0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},[c.WETH]:{address:C("0x4200000000000000000000000000000000000006"),symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png"}},[E.BASE_TESTNET]:{[c.USDC]:{address:C("0x036CbD53842c5426634e7929541eC2318f3dCF7e"),symbol:c.USDC,name:"USD Coin",fiatISO:"USD",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"}},[E.BSC]:{[c.BNB]:{address:"0x0000000000000000000000000000000000000000",symbol:c.BNB,name:"BNB",decimals:18,logoURI:"/images/chains/bsc.webp"},[c.BUSD]:{address:"0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56",symbol:c.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png"},[c.DAI]:{address:"0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png"},[c.ETH]:{address:"0x2170Ed0880ac9A755fd29B2688956BD959F933F8",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg"},[c.USDC]:{address:C("0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d"),symbol:c.USDC,decimals:18,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},[c.USDT]:{address:"0x55d398326f99059fF775485246999027B3197955",symbol:c.USDT,name:"Tether USD",decimals:18,logoURI:"/images/tokens/usdt.png"}},[E.ETHEREUM]:{[c.BUSD]:{address:"0x4Fabb145d64652a948d72533023f6E7A623C7C53",symbol:c.BUSD,name:"Binance USD",decimals:18,logoURI:"/images/tokens/busd.png"},[c.DAI]:{address:C("0x6B175474E89094C44Da98b954EedeAC495271d0F"),symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png"},[c.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg"},[c.EURC]:{address:"0x1aBaEA1f7C830bD89Acc67eC4af516284b1bC33c",symbol:c.EURC,name:"Euro Coin",decimals:6,logoURI:"/images/tokens/eurc.png"},[c.STRK]:{address:"0xCa14007Eff0dB1f8135f4C25B34De49AB0d42766",symbol:c.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg"},[c.USDC]:{address:C("0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"),symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},[c.USDT]:{address:C("0xdAC17F958D2ee523a2206206994597C13D831ec7"),symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png"},[c.WETH]:{address:C("0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"),symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png"}},[E.ETHEREUM_TESTNET]:{[c.USDC]:{address:C("0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238"),symbol:c.USDC,decimals:6,name:"USD Coin",logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"}},[E.HYPEREVM]:{[c.USDC]:{address:"0xb88339CB7199b77E23DB6E890353E22632Ba630f",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg"}},[E.LISK]:{[c.USDC]:{address:"0xF242275d3a6527d877f2c927a82D9b057609cc71",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg"}},[E.MONAD]:{[c.USDC]:{address:"0x754704Bc059F8C67012fEd69BC8A327a5aafb603",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg"}},[E.MONAD_TESTNET]:{[c.USDC]:{address:"0x534b2f3A21130d7a60830c2Df862319e593943A3",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg"}},[E.OPTIMISM]:{[c.DAI]:{address:"0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png"},[c.ETH]:{address:"0x0000000000000000000000000000000000000000",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg"},[c.USDC]:{address:"0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg"},[c.USDT]:{address:"0x94b008aA00579c1307B0EF2c499aD98a8ce58e58",symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png"},[c.WETH]:{address:"0x4200000000000000000000000000000000000006",symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png"}},[E.OPTIMISM_TESTNET]:{[c.USDC]:{address:"0x5fd84259d66Cd46123540766Be93DFE6D43130D7",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg"}},[E.POLYGON]:{[c.DAI]:{address:"0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png"},[c.USDC]:{address:"0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg"},[c.USDT]:{address:"0xc2132D05D31c914a87C6611C10748AEb04B58e8F",symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png"},[c.WETH]:{address:"0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619",symbol:c.WETH,name:"Wrapped Ether",decimals:18,logoURI:"/images/tokens/weth.png"}},[E.STARKNET]:{[c.DAI]:{address:"0x05574eb6b8789a91466f902c380d978e472db68170ff82a5b650b95a58ddf4ad",symbol:c.DAI,name:"Dai Stablecoin",decimals:18,logoURI:"/images/tokens/dai.png"},[c.ETH]:{address:"0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",symbol:c.ETH,name:"Ethereum",decimals:18,logoURI:"/images/chains/ethereum.svg"},[c.LORDS]:{address:"0x0124aeb495b947201f5faC96fD1138E326AD86195B98df6DEc9009158A533B49",symbol:c.LORDS,name:"LORDS Token",decimals:18,logoURI:"/images/tokens/lords.png"},[c.STRK]:{address:"0x04718f5a0Fc34cC1AF16A1cdee98fFB20C31f5cD61D6Ab07201858f4287c938D",symbol:c.STRK,name:"Starknet Token",decimals:18,logoURI:"/images/chains/starknet.svg"},[c.USDC]:{address:"0x033068F6539f8e6e6b131e6B2B814e6c34A5224bC66947c47DaB9dFeE93b35fb",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg",logoSourceURI:"https://pay.daimo.com/coin-logos/usdc.png"},[c.USDT]:{address:"0x068f5c6a61780768455de69077e07e89787839bf8166decfbf92b645209c0fb8",symbol:c.USDT,name:"Tether USD",decimals:6,logoURI:"/images/tokens/usdt.png"}},[E.STARKNET_TESTNET]:{[c.USDC]:{address:"0x0512feAc6339Ff7889822cb5aA2a86C848e9D392bB0E3E237C008674feeD8343",symbol:c.USDC,name:"USD Coin",decimals:6,logoURI:"/images/tokens/usdc.svg"}}},bs=new Set(Object.values(E));function S(t){if(Es(t))return t;const e=E[t];if(!e)throw new Error(`Invalid chain: ${t}. Chain must be a valid chain alias or internal chain value from Chains.`);return e}function Es(t){return bs.has(t)}function Ts(t,e){const s=e.toLowerCase().trim(),n=Xe[t];if(!n)throw new Error(`Chain not found: ${t}. The chain key must be a valid chain identifier.`);let r;for(const i in n){const o=n[i];if(o&&o.address.toLowerCase()===s.toLowerCase()){r=o;break}}if(!r)throw new Error(`Token address mismatch: address ${e} does not exist on chain ${t}. The token address must be a valid token address on the specified chain.`);return r}function re(t,e,s){const n=Ts(t,e);if(n.symbol!==s)throw new Error(`Token address and symbol mismatch: address ${e} on chain ${t} corresponds to token "${n.symbol}", but expected "${s}". The token address must correspond to a token with the expected symbol on the specified chain.`);return n}function Ss(t,e){return Xe[t]?.[e]}function ws(t,e){return Ss(t,e)?.address}var oe=(t=>(t.PRODUCTION="production",t.STAGING="staging",t))(oe||{});class d{constructor({api_key:e,env:s,seesion_token:n,props:r}){this.api_key=e||"",this.sessionToken=n||"",this.env=s??oe.PRODUCTION,this.props=r}static async config(e){if(!d.app){if(!e)throw new Error("Please provide an api_key");d.app=new d(e)}return e&&(e.api_key!==void 0&&(d.app.api_key=e.api_key),e.seesion_token!==void 0&&(d.app.sessionToken=e.seesion_token),e.env!==void 0&&(d.app.env=e.env),e.props!==void 0&&(d.app.props=e.props)),d.app}static getApiKey(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return d.app.api_key}static getSessionToken(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return d.app.sessionToken}static getProps(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return d.app.props}static getEnv(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");return d.app.env==="internal"?"staging":d.app.env}static getBaseUrl(){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");switch(d.app.env){case"production":return"https://api.chainrails.io/api/v1";case"staging":return"https://dev.chainrails.io/api/v1";case"internal":return"https://dev.chainrails.io/api/v1";default:return"https://api.chainrails.io/api/v1"}}static getPayModalUrl(e){if(!d.app)throw new Error("Chainrails SDK not configured. Please call Chainrails.config() first.");const s=d.app.env==="internal"?"https://chainrails-frontend-git-staging-horus-labs.vercel.app":"https://app.chainrails.io",n=Number(e),r=e&&!isNaN(Number(e))&&n>0?"/pay/":"/deposit/",i=`${e&&!isNaN(Number(e))&&n>0?n*100:""}`;return s+r+i}}let ie=null;function Cs(){ie=xt.create({prefixUrl:d.getBaseUrl(),headers:{"Content-Type":"application/json"},hooks:{beforeRequest:[t=>{const e=d.getSessionToken()||d.getApiKey();t.headers.set("Authorization",`Bearer ${e}`)}],afterResponse:[(t,e,s)=>s]},retry:{limit:2}})}function y(){return ie||Cs(),ie}class Rs{async getById(e){return await y().get("intents/"+e).json()}async getForSender(e){return await y().get("intents/user/"+e).json()}async getForAddress(e){return await y().get("intents/address/"+e).json()}async getForSession(e){return await y().get("modal/sessions/intents/"+e).json()}async getAll(e){return await y().get("intents",{searchParams:e}).json()}async create(e){const s=S(e.source_chain),n=S(e.destination_chain);return await y().post("intents",{json:{...e,source_chain:s,destination_chain:n}}).json()}async createForSession(e){const s=S(e.sourceChain);return await y().post("modal/sessions/intents",{json:{...e,sourceChain:s}}).json()}async update(e,s){return await y().post("intents",{json:s}).json()}async triggerProcessing(e){return await y().post(`intents/${e}/trigger-processing`).json()}async triggerProcessingForSession(e){return await y().post(`modal/sessions/intents/${e}/process`).json()}}class As{async getFromSpecificBridge(e){const s=S(e.sourceChain);re(s,e.tokenIn,e.amountSymbol);const n=S(e.destinationChain);return await y().get("quotes/single",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getFromAllBridges(e){const s=S(e.sourceChain);re(s,e.tokenIn,e.amountSymbol);const n=S(e.destinationChain);return await y().get("quotes/multiple",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getBestAcrossBridges(e){const s=S(e.sourceChain);re(s,e.tokenIn,e.amountSymbol);const n=S(e.destinationChain);return await y().get("quotes/best",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getAll(e){const s=S(e.destinationChain);return await y().get("quotes/multi-source",{searchParams:{...e,destinationChain:s}}).json()}async getAllForSession(e){return await y().get("modal/sessions/quotes",{searchParams:e}).json()}}class Ds{async getOptimalRoutes(e){const s=S(e.sourceChain),n=S(e.destinationChain);return await y().get("router/optimal-route",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getAllSupportedBridges(){return await y().get("router/supported-bridges/all").json()}async getSupportedBridges(e){const s=S(e.sourceChain),n=S(e.destinationChain);return await y().get("router/supported-bridges/route",{searchParams:{...e,sourceChain:s,destinationChain:n}}).json()}async getSupportedRoutes(e,s){const n=S(s.sourceChain),r=S(s.destinationChain);return await y().get("router/supported-routes/bridge/"+e,{searchParams:{...s,sourceChain:n,destinationChain:r}}).json()}}class Us{async getSupported(e){return await y().get("chains",{searchParams:e}).json()}async getBalance(e){return await y().get(`chains/balances/${e.address}`,{searchParams:e}).json()}}class Is{async getClientInfo(){return await y().get("client/auth/client-info").json()}async getClientInfoForSession(){return await y().get("modal/sessions/client").json()}}class vs{async getSessionToken(e){const s=S(e.destinationChain),n={recipient:e.recipient,tokenOut:ws(s,e.token),destinationChain:s,amount:e.amount};return y().post("modal/sessions",{json:n}).json().then(r=>({...r,amount:n.amount}))}}const Ps={router:new Ds,quotes:new As,intents:new Rs,chains:new Us,client:new Is,auth:new vs};function Je(t){var e,s,n="";if(typeof t=="string"||typeof t=="number")n+=t;else if(typeof t=="object")if(Array.isArray(t)){var r=t.length;for(e=0;e<r;e++)t[e]&&(s=Je(t[e]))&&(n&&(n+=" "),n+=s)}else for(s in t)t[s]&&(n&&(n+=" "),n+=s);return n}function ks(){for(var t,e,s=0,n="",r=arguments.length;s<r;s++)(t=arguments[s])&&(e=Je(t))&&(n&&(n+=" "),n+=e);return n}function xs(t){const{amount:e,styles:s,excludeChains:n,isOpen:r,isPending:i,open:o,close:a,onCancel:u,onSuccess:l,session_url:f,sessionToken:w}=t,[g,b]=p.useState(0),[A,ye]=p.useState(""),h=p.useRef(null);d.config({api_key:"",env:t.env==="internal"?"internal":"production"}),p.useEffect(()=>{ye(d.getPayModalUrl(e))},[e]),p.useEffect(()=>{const m=document.body.style.overflow;r?(document.body.style.overflow="hidden",document.body.style.overflow="hidden"):document.body.style.overflow=m||"";const D=x=>{x.data==="closed"&&(a(),u?.()),x.data==="completed"&&(window.setTimeout(a,2e3),l?.())};return window.addEventListener("message",D),()=>{document.body.style.overflow=m||"",window.removeEventListener("message",D)}},[r,u,l]),p.useEffect(()=>{if(!w)return;const m={type:"session",session_token:w,environment:d.getEnv()||oe.PRODUCTION,styles:s,props:{excludeChains:n?.join(",")}};h.current?.contentWindow?.postMessage(m,"https://app.chainrails.io"),h.current?.contentWindow?.postMessage(m,"https://chainrails-frontend-git-staging-horus-labs.vercel.app"),window.setTimeout(()=>{h.current?.contentWindow?.postMessage(m,"https://app.chainrails.io"),h.current?.contentWindow?.postMessage(m,"https://chainrails-frontend-git-staging-horus-labs.vercel.app")},1e3)},[w,g,r,s]);function T(){b(Math.random())}return N.jsxs("div",{className:ks("payment-modal-wrapper",g===0||i?"loading":"not-loading",r?"open":"closed"),children:[(g===0||i)&&N.jsx("div",{role:"status",className:"payment-modal-loader",children:N.jsxs("svg",{"aria-hidden":"true",className:"icon",viewBox:"0 0 100 101",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[N.jsx("path",{d:"M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z",fill:"currentColor"}),N.jsx("path",{d:"M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z",fill:"currentFill"})]})}),N.jsx("iframe",{allow:"clipboard-read *; clipboard-write *",src:A||void 0,onLoad:T,className:`payment-modal ${g===0||i?"invisible":"visible"}`,"data-id":e,ref:h},e)]})}const Ns=Symbol(),ae=Symbol(),M="a",Ze="f",Qe="p",et="c",tt="t",ce="h",L="w",ue="o",le="k";let Os=(t,e)=>new Proxy(t,e);const de=Object.getPrototypeOf,fe=new WeakMap,st=t=>t&&(fe.has(t)?fe.get(t):de(t)===Object.prototype||de(t)===Array.prototype),j=t=>typeof t=="object"&&t!==null,Bs=t=>Object.values(Object.getOwnPropertyDescriptors(t)).some(e=>!e.configurable&&!e.writable),Ms=t=>{if(Array.isArray(t))return Array.from(t);const e=Object.getOwnPropertyDescriptors(t);return Object.values(e).forEach(s=>{s.configurable=!0}),Object.create(de(t),e)},Ls=(t,e)=>{const s={[Ze]:e};let n=!1;const r=(a,u)=>{if(!n){let l=s[M].get(t);if(l||(l={},s[M].set(t,l)),a===L)l[L]=!0;else{let f=l[a];f||(f=new Set,l[a]=f),f.add(u)}}},i=()=>{n=!0,s[M].delete(t)},o={get(a,u){return u===ae?t:(r(le,u),nt(Reflect.get(a,u),s[M],s[et],s[tt]))},has(a,u){return u===Ns?(i(),!0):(r(ce,u),Reflect.has(a,u))},getOwnPropertyDescriptor(a,u){return r(ue,u),Reflect.getOwnPropertyDescriptor(a,u)},ownKeys(a){return r(L),Reflect.ownKeys(a)}};return e&&(o.set=o.deleteProperty=()=>!1),[o,s]},he=t=>t[ae]||t,nt=(t,e,s,n)=>{if(!st(t))return t;let r=n&&n.get(t);if(!r){const u=he(t);Bs(u)?r=[u,Ms(u)]:r=[u],n?.set(t,r)}const[i,o]=r;let a=s&&s.get(i);return(!a||a[1][Ze]!==!!o)&&(a=Ls(i,!!o),a[1][Qe]=Os(o||i,a[0]),s&&s.set(i,a)),a[1][M]=e,a[1][et]=s,a[1][tt]=n,a[1][Qe]},_s=(t,e)=>{const s=Reflect.ownKeys(t),n=Reflect.ownKeys(e);return s.length!==n.length||s.some((r,i)=>r!==n[i])},rt=(t,e,s,n,r=Object.is)=>{if(r(t,e))return!1;if(!j(t)||!j(e))return!0;const i=s.get(he(t));if(!i)return!0;if(n){if(n.get(t)===e)return!1;n.set(t,e)}let o=null;for(const a of i[ce]||[])if(o=Reflect.has(t,a)!==Reflect.has(e,a),o)return o;if(i[L]===!0){if(o=_s(t,e),o)return o}else for(const a of i[ue]||[]){const u=!!Reflect.getOwnPropertyDescriptor(t,a),l=!!Reflect.getOwnPropertyDescriptor(e,a);if(o=u!==l,o)return o}for(const a of i[le]||[])if(o=rt(t[a],e[a],s,n,r),o)return o;if(o===null)throw new Error("invalid used");return o},Fs=t=>st(t)&&t[ae]||null,ot=(t,e=!0)=>{fe.set(t,e)},Hs=(t,e,s)=>{const n=[],r=new WeakSet,i=(o,a)=>{var u,l,f;if(r.has(o))return;j(o)&&r.add(o);const w=j(o)&&e.get(he(o));if(w){if((u=w[ce])===null||u===void 0||u.forEach(g=>{const b=`:has(${String(g)})`;n.push(a?[...a,b]:[b])}),w[L]===!0){const g=":ownKeys";n.push(a?[...a,g]:[g])}else(l=w[ue])===null||l===void 0||l.forEach(g=>{const b=`:hasOwn(${String(g)})`;n.push(a?[...a,b]:[b])});(f=w[le])===null||f===void 0||f.forEach(g=>{"value"in(Object.getOwnPropertyDescriptor(o,g)||{})&&i(o[g],a?[...a,g]:[g])})}else a&&n.push(a)};return i(t),n},q={},me=t=>typeof t=="object"&&t!==null,$s=t=>me(t)&&!ge.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),it=(t,e)=>{const s=at.get(t);if(s?.[0]===e)return s[1];const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return ot(n,!0),at.set(t,[e,n]),Reflect.ownKeys(t).forEach(r=>{if(Object.getOwnPropertyDescriptor(n,r))return;const i=Reflect.get(t,r),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,r),a={value:i,enumerable:o,configurable:!0};if(ge.has(i))ot(i,!1);else if(k.has(i)){const[u,l]=k.get(i);a.value=it(u,l())}Object.defineProperty(n,r,a)}),Object.preventExtensions(n)},zs=(t,e,s,n)=>({deleteProperty(r,i){const o=Reflect.get(r,i);s(i);const a=Reflect.deleteProperty(r,i);return a&&n(["delete",[i],o]),a},set(r,i,o,a){const u=!t()&&Reflect.has(r,i),l=Reflect.get(r,i,a);if(u&&(ct(l,o)||K.has(o)&&ct(l,K.get(o))))return!0;s(i),me(o)&&(o=Fs(o)||o);const f=!k.has(o)&&qs(o)?ut(o):o;return e(i,f),Reflect.set(r,i,f,a),n(["set",[i],o,l]),!0}}),k=new WeakMap,ge=new WeakSet,at=new WeakMap,pe=[1],K=new WeakMap;let ct=Object.is,js=(t,e)=>new Proxy(t,e),qs=$s,Ks=it,Ws=zs;function ut(t={}){if(!me(t))throw new Error("object required");const e=K.get(t);if(e)return e;let s=pe[0];const n=new Set,r=(h,T=++pe[0])=>{s!==T&&(i=s=T,n.forEach(m=>m(h,T)))};let i=s;const o=(h=pe[0])=>(i!==h&&(i=h,u.forEach(([T])=>{const m=T[1](h);m>s&&(s=m)})),s),a=h=>(T,m)=>{const D=[...T];D[1]=[h,...D[1]],r(D,m)},u=new Map,l=(h,T)=>{const m=!ge.has(T)&&k.get(T);if(m){if((q?"production":void 0)!=="production"&&u.has(h))throw new Error("prop listener already exists");if(n.size){const D=m[2](a(h));u.set(h,[m,D])}else u.set(h,[m])}},f=h=>{var T;const m=u.get(h);m&&(u.delete(h),(T=m[1])==null||T.call(m))},w=h=>(n.add(h),n.size===1&&u.forEach(([m,D],x)=>{if((q?"production":void 0)!=="production"&&D)throw new Error("remove already exists");const en=m[2](a(x));u.set(x,[m,en])}),()=>{n.delete(h),n.size===0&&u.forEach(([m,D],x)=>{D&&(D(),u.set(x,[m]))})});let g=!0;const b=Ws(()=>g,l,f,r),A=js(t,b);K.set(t,A);const ye=[t,o,w];return k.set(A,ye),Reflect.ownKeys(t).forEach(h=>{const T=Object.getOwnPropertyDescriptor(t,h);"value"in T&&T.writable&&(A[h]=t[h])}),g=!1,A}function Ys(t,e,s){const n=k.get(t);(q?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let r;const i=[],o=n[2];let a=!1;const l=o(f=>{i.push(f),r||(r=Promise.resolve().then(()=>{r=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,l()}}function lt(t){const e=k.get(t);(q?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[s,n]=e;return Ks(s,n())}const Vs={},Gs=(t,e)=>{const s=p.useRef(void 0);p.useEffect(()=>{s.current=Hs(t,e)}),p.useDebugValue(s.current)},Xs=new WeakMap;function Js(t,e){const n=p.useMemo(()=>t&&new WeakMap,[t]),r=p.useRef(void 0);let i=!0;const o=p.useSyncExternalStore(p.useCallback(u=>{const l=Ys(t,u);return u(),l},[t,void 0]),()=>{const u=lt(t);try{if(!i&&r.current&&!rt(r.current,u,n,new WeakMap))return r.current}catch{}return u},()=>lt(t));i=!1,p.useLayoutEffect(()=>{r.current=o}),(Vs?"production":void 0)!=="production"&&Gs(o,n);const a=p.useMemo(()=>new WeakMap,[]);return nt(o,n,a,Xs)}const v=ut({data:null,isPending:!1,error:null});function Zs({session_url:t,onCancel:e,onSuccess:s}){const n=Js(v),[r,i]=p.useState(!1),[o,a]=p.useState(Date.now()),u=n?.data?.sessionToken,l=n?.data?.amount;function f(){u||window.setTimeout(()=>{u&&i(!0)},200),i(!0)}function w(){i(!1)}const g=()=>{const b=Date.now();v.isPending=!0,v.error=null,v.data=null,fetch(t,{headers:{"Content-Type":"application/json"}}).then(A=>A.json()).then(A=>{b<o||(v.data=A,v.isPending=!1,a(b))}).catch(A=>{b<o||(v.error=A?.toString(),v.isPending=!1,a(b),setInterval(g,5e3))})};return p.useEffect(()=>{g()},[t]),{sessionToken:u,amount:l,isOpen:r,session_url:t,open:f,close:w,isPending:n.isPending,error:n.error,refetch:g,onSuccess:s,onCancel:e}}function Qs({sessionToken:t,amount:e,onCancel:s,onSuccess:n}){const[r,i]=p.useState(!1),[o,a]=p.useState(t),[u,l]=p.useState(e);function f({sessionToken:b,amount:A}){a(b),l(A)}p.useEffect(()=>{a(t)},[t]);function w(){o||window.setTimeout(()=>{o&&i(!0)},200),i(!0)}function g(){i(!1)}return{sessionToken:o,updateSession:f,amount:u,isOpen:r,open:w,close:g,onSuccess:n,onCancel:s}}R.AmountSymbols=c,R.Chainrails=d,R.Chains=Nt,R.PaymentModal=xs,R.crapi=Ps,R.usePaymentModal=Qs,R.usePaymentSession=Zs,Object.defineProperty(R,Symbol.toStringTag,{value:"Module"})}));
@@ -1 +1 @@
1
- {"version":3,"file":"usePaymentSession.d.ts","sourceRoot":"","sources":["../../src/hooks/usePaymentSession.tsx"],"names":[],"mappings":"AAqBA,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,sBAAsB;;;;;;;;;;sBAH1E,IAAI;qBADL,IAAI;EAsEtB"}
1
+ {"version":3,"file":"usePaymentSession.d.ts","sourceRoot":"","sources":["../../src/hooks/usePaymentSession.tsx"],"names":[],"mappings":"AAoBA,UAAU,sBAAsB;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,wBAAgB,iBAAiB,CAAC,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,sBAAsB;;;;;;;;;;sBAH1E,IAAI;qBADL,IAAI;EAsEtB"}
package/dist/index.d.ts CHANGED
@@ -2,5 +2,6 @@ import "./PaymentModal/index.css";
2
2
  export { PaymentModal } from "./PaymentModal";
3
3
  export { usePaymentSession } from "./hooks/usePaymentSession";
4
4
  export { usePaymentModal } from "./hooks/usePaymentModal";
5
- export { crapi, chains, tokens, Chainrails } from "@chainrails/sdk";
5
+ export { crapi, Chains, AmountSymbols, Chainrails } from "@chainrails/sdk";
6
+ export type { AmountSymbol, Chain } from "@chainrails/sdk";
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,0BAA0B,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC3E,YAAY,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "sideEffects": [
4
4
  "**/*.css"
5
5
  ],
6
- "version": "0.2.27",
6
+ "version": "0.3.0",
7
7
  "description": "",
8
8
  "license": "MIT",
9
9
  "repository": {
@@ -54,7 +54,7 @@
54
54
  "vite-plugin-lib-inject-css": "^2.2.2"
55
55
  },
56
56
  "dependencies": {
57
- "@chainrails/sdk": "^0.2.6",
57
+ "@chainrails/sdk": "^0.3.0",
58
58
  "clsx": "^2.1.1",
59
59
  "dotenv": "^17.2.3",
60
60
  "react": "^19.2.0",