@tokenflight/swap 0.3.0-rc.3 → 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.
- package/dist/ReceiveComponent-YtkLLaLd.js +1 -0
- package/dist/SwapComponent-CBJpgat4.js +1 -0
- package/dist/bridge-BufC2_tK.js +1 -0
- package/dist/bridge.d.ts +30 -5
- package/dist/bridge.js +1 -1
- package/dist/browser-BONUFvML.js +8 -0
- package/dist/chunk-Dj_sP-dV.js +1 -0
- package/dist/classPrivateFieldSet2-DmR3eaHe.js +1 -0
- package/dist/dist-CsBuWseE.js +3 -0
- package/dist/en-US-BsEBXsff.js +1 -0
- package/dist/errors-DeB4WVzG.js +1 -0
- package/dist/iframe-entry.js +1 -1
- package/dist/{iframe-receiver-PfhKUIZW.js → iframe-receiver-i4RfQGg2.js} +1 -1
- package/dist/iframe.js +1 -1
- package/dist/ja-JP-DckpHLDh.js +1 -0
- package/dist/ko-KR-jzHfArkK.js +1 -0
- package/dist/rank-offers-4N4cmoQy.js +1 -0
- package/dist/{register-defaults-C_q7CG7x.js → register-defaults-BOb3wgfD.js} +1 -1
- package/dist/register-widget-D6m_f_gp.js +1 -0
- package/dist/shared.module-Bs-BN_nM.js +1 -0
- package/dist/swap.css +1 -1
- package/dist/tokenflight-swap.d.ts +2 -2
- package/dist/tokenflight-swap.js +1 -1
- package/dist/tokenflight-swap.umd.cjs +12 -5
- package/dist/usePageRouter-BI7v3BwA.js +1 -0
- package/dist/widget-B0OLriHf.js +2 -0
- package/dist/widget.d.ts +2 -2
- package/dist/widget.js +1 -1
- package/dist/zh-CN-Cm_ni5eM.js +1 -0
- package/dist/zh-TW-BnoGGI9_.js +1 -0
- package/package.json +4 -2
- package/dist/ReceiveComponent-4xwyN66k.js +0 -1
- package/dist/SwapComponent-CF2-MzB_.js +0 -1
- package/dist/bridge-Bq0QUltI.js +0 -1
- package/dist/en-US-CU2aSy93.js +0 -1
- package/dist/errors-DXq77OyE.js +0 -3
- package/dist/ja-JP-BoipV6-j.js +0 -1
- package/dist/ko-KR-DyFXZJsF.js +0 -1
- package/dist/rank-offers-CiA9Nw2C.js +0 -1
- package/dist/register-widget-DHNRTdAz.js +0 -1
- package/dist/shared.module-2EeBIMep.js +0 -1
- package/dist/usePageRouter-BUKTv1jC.js +0 -1
- package/dist/widget-eUE--Gt1.js +0 -2
- package/dist/zh-CN-epCUm9Io.js +0 -1
- package/dist/zh-TW-DSEboEJV.js +0 -1
- /package/dist/{active-bridge-V8lTJ2Js.js → active-bridge-hZx8_r6Y.js} +0 -0
- /package/dist/{defaults-loader-DfcaO9j5.js → defaults-loader-CUYh_qLj.js} +0 -0
- /package/dist/{protocol-CDxgudrl.js → protocol-B7S8LSlJ.js} +0 -0
- /package/dist/{solid-iWr5Czxc.js → solid-DqvEpdeb.js} +0 -0
- /package/dist/{theme-C9tsVWlo.js → theme-B6YtpkRW.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{C as e,S as t,a as n,b as r,c as i,h as a,l as o,m as s,o as c,p as l,s as u,u as d,v as f,x as p}from"./solid-DqvEpdeb.js";import{o as m,r as ee,t as te}from"./dist-CsBuWseE.js";import{t as h}from"./errors-DeB4WVzG.js";import{c as g,d as ne,g as re,h as _,l as v,m as ie,n as ae,o as y,s as b,t as x}from"./shared.module-Bs-BN_nM.js";import{A as S,C as oe,D as C,E as se,O as w,S as T,T as ce,_ as E,b as le,g as ue,h as de,i as fe,j as D,k as O,l as pe,p as k,s as me,t as he,w as ge}from"./rank-offers-4N4cmoQy.js";import{A as _e,B as ve,C as ye,D as be,E as xe,F as Se,G as Ce,H as we,I as Te,J as Ee,K as De,L as Oe,M as ke,N as Ae,O as je,P as Me,Q as Ne,R as Pe,S as A,T as Fe,V as Ie,W as Le,Y as Re,Z as ze,_t as Be,a as Ve,at as He,b as Ue,c as We,d as Ge,dt as Ke,et as qe,f as j,g as Je,h as Ye,ht as Xe,i as Ze,it as Qe,j as $e,l as et,m as tt,mt as nt,n as rt,nt as it,o as at,ot,q as st,r as M,rt as ct,s as lt,t as ut,tt as N,u as dt,v as ft,vt as pt,w as mt,x as ht,z as gt}from"./usePageRouter-BI7v3BwA.js";var _t=1.05;function vt(e,t){let n=e.chainId===t.chainId,r=C(e.symbol,t.symbol),i=S(e.symbol,t.symbol),a=D(e.symbol),o=D(t.symbol),s=w(e.symbol);return n&&r?1:r?2:i||a&&o?n?3:4:a&&!o?5:s?6:n?7:8}function yt(e){return+!!ce.has(e)}function bt(e){let t=new Map;for(let n of e){if(!O(n.address))continue;let e=n.extensions?.balance??`0`;if(e===`0`)continue;let r=Number(E(e,n.decimals)),i=Number(n.extensions?.price?.usd??`0`);if(i<=0)continue;let a=r*i,o=t.get(n.chainId)??0;t.set(n.chainId,o+a)}return t}function xt(e,t,n){return O(e)?!0:(n.get(t)??0)>=se}function St(e,t,n,r,i){if(e.length===0)return[];let a=bt(e),o={address:r,chainId:n},s=[];for(let r of e){if(T(r,o))continue;let e=r.extensions?.balance;if(!e||e===`0`)continue;let c=Number(r.extensions?.price?.usd??`0`);if(c<=0)continue;let l=Number(E(e,r.decimals))*c;if(l<1||i!==void 0&&l<i*_t||!xt(r.address,r.chainId,a))continue;let u=vt({symbol:r.symbol,chainId:r.chainId},{symbol:t,chainId:n});s.push({token:r,tier:u,gasCostScore:yt(r.chainId)})}return s.sort((e,t)=>e.tier===t.tier?e.gasCostScore-t.gasCostScore:e.tier-t.tier),s.map(e=>e.token)}function Ct(e){let t=M();return{trackingOrderId:t.trackingOrderId,trackingProviderName:t.trackingProviderName,trackingProviderIcon:t.trackingProviderIcon,trackingInputAmount:t.trackingInputAmount,executionError:t.executionError,failedExecPhase:t.failedExecPhase,handleConfirm:async()=>{let n=e.selectedPayToken(),r=n?e.payTokenQuotes().find(e=>T(e.token,n)):null,i=e.walletAddress();if(!r||!e.client()||!e.walletAdapter()||!i)return;if(e.needRecipient()&&!e.recipient()){e.setError(`Recipient address is required for cross-chain swaps`),e.setErrorCode(h.INVALID_CONFIG);return}let a=r.route.quote.validBefore;if(a&&Date.now()/1e3>a){e.setLoadingQuotes(!0);try{let t=e.targetToken();if(!t||typeof t.decimals!=`number`)return;let n=ue(e.configAmount(),t.decimals),a=await e.fetchSingleQuote(e.client(),r.token,n,i,t,e.recipient());if(a){let t=[...e.payTokenQuotes()],n=t.findIndex(e=>T(e.token,r.token));n>=0?t[n]=a:t.push(a),e.setPayTokenQuotes(t)}else{e.setError(`Quote expired and could not be refreshed`),e.setErrorCode(h.QUOTE_EXPIRED);return}}catch{e.setError(`Quote expired and could not be refreshed`),e.setErrorCode(h.QUOTE_EXPIRED);return}finally{e.setLoadingQuotes(!1)}}let o=e.selectedPayToken(),s=o?e.payTokenQuotes().find(e=>T(e.token,o)):null;if(!s)return;e.setFromToken({chainId:s.token.chainId,address:s.token.address,symbol:s.token.symbol,name:s.token.name,decimals:s.token.decimals,logoURI:s.token.logoURI}),t.setTrackingProviderName(s.route.routeId??null);let c=e.apiEndpoint()??`https://api.hyperstream.dev`;t.setTrackingProviderIcon(s.route.icon?`${c}${s.route.icon}`:null),t.setTrackingInputAmount(E(s.route.quote.amountIn,s.token.decimals)),t.setExecutionError(null),t.setFailedExecPhase(null),e.setExecPhase(`building`);try{let n=await e.client().buildDeposit({from:i,quoteId:s.quoteId,routeId:s.route.routeId});e.setExecPhase(`awaiting-wallet`);let r=await Ze(e.walletAdapter(),n,s.token.chainId);e.setExecPhase(`submitting`);let a=await lt(e.client(),s.quoteId,s.route.routeId,r);e.setExecPhase(`tracking`),t.setTrackingOrderId(a.orderId)}catch(n){let r=Ve(n,e.callbacks(),`deposit`);t.setExecutionError(r),t.setFailedExecPhase(e.execPhase())}},handleRetry:()=>{o(()=>{e.setExecPhase(null),e.storeClearError(),e.setPayTokenQuotes([])}),e.onRetry?.()},handleNewSwap:()=>{o(()=>{e.storeReset(),e.setPayTokenQuotes([])}),at(t,e.client().baseUrl),e.onReset?.()}}}var P={header:`tf-9b71d6`,section:`tf-4c9136`,sectionLabel:`tf-febe61`,backArrowEnter:`tf-0d09cf`,backArrowPush:`tf-398c5c`,backTextEnter:`tf-2368bf`,backTextPush:`tf-86d030`,backArrowExit:`tf-b31fd2`,backTextExit:`tf-f55867`,methodHeaderOverlay:`tf-74b90d`,methodHeaderLabel:`tf-f366fb`,methodHeaderBackButton:`tf-9ab299`,methodPaneSpacer:`tf-e1e5bc`,methodPaneSpacerCrypto:`tf-fbab4f`,target:`tf-a27aab`,targetContent:`tf-d62361`,targetIcon:`tf-f0b3f5`,targetChainDot:`tf-7a6fbc`,amount:`tf-e9e9a1`,symbol:`tf-f3baad`,fiat:`tf-0131e4`,amountInput:`tf-e8980b`,amountInputShell:`tf-3d3253`,paySelected:`tf-81181d`,paySelectedLeft:`tf-a274dd`,payIconWrap:`tf-0039f9`,payChainDot:`tf-2ee752`,paySelectedInfo:`tf-96714d`,paySelectedTopRow:`tf-619747`,payTokenSymbol:`tf-cd221a`,payBestBadge:`tf-2c683f`,payTokenChain:`tf-c839a0`,paySelectedRight:`tf-0b0d52`,paySelectedAmount:`tf-19df0d`,paySelectedAmountUsd:`tf-c7d33a`,paySelectedCaret:`tf-e51789`,payAmountSkeleton:`tf-8a3107`,paySelectedSkeleton:`tf-e255df`,paySkeletonIcon:`tf-fb2771`,paySkeletonInfo:`tf-1b1e61`,paySkeletonLine:`tf-18dcca`,paySkeletonSymbol:`tf-a5c85b`,paySkeletonChain:`tf-12a725`,paySkeletonRight:`tf-df9ebb`,paySkeletonAmount:`tf-3547fa`,paySkeletonUsd:`tf-a46696`,payEmpty:`tf-1d40de`,payEmptyText:`tf-5d25d7`},wt=_(`<div part=container><div part=accent-line data-testid=accent-line>`),Tt=_(`<img height=22>`),Et=_(`<button part=wallet-info><div data-testid=wallet-dot></div><span data-testid=wallet-address>`),Dt=_(`<div part=header><div><div data-testid=header-brand data-header-brand-state=idle><span data-testid=header-title>`),Ot=_(`<button part=recipient-badge data-testid=recipient-badge><span>`),kt=_(`<div>`),At=_(`<div style=display:flex;align-items:center;gap:10px><div data-testid=receive-target-icon></div><div style=display:flex;align-items:center;gap:4px><div style=display:flex;flex-direction:column><span data-testid=receive-symbol></span><span style=font-size:var(--tf-font-sm);color:var(--tf-text-tertiary);line-height:16px>`),jt=_(`<div data-testid=receive-amount-shell><input type=number inputmode=decimal placeholder=0 data-testid=receive-amount-input style=text-align:right>`),Mt=_(`<div><div part=target-token><div data-testid=receive-section-label style=display:flex;justify-content:space-between;align-items:center><span></span></div><div style=justify-content:space-between><div style=display:flex;flex-direction:column;align-items:flex-end><span style=margin-left:0>`),Nt=_(`<button data-testid=receive-method-back-button type=button><span></span><span>`),Pt=_(`<div style=flex:1;display:flex;flex-direction:column><div data-testid=receive-method-header>`),Ft=_(`<span>Flight`),It=_(`<button type=button style=display:flex;align-items:center;gap:4px;background:none;border:none;cursor:pointer;color:var(--tf-primary);font-size:var(--tf-font-lg);font-weight:600;font-family:var(--tf-font-family);padding:0>`),Lt=_(`<span data-testid=receive-amount>`),Rt=_(`<span data-testid=receive-method-label>`),zt=_(`<div data-testid=receive-method-pane-spacer>`),Bt=_(`<div part=payment-list style="padding:0 20px">`),Vt=_(`<div part=pay-token-error style="padding:8px 20px 0;color:var(--tf-error);font-size:var(--tf-font-xs)">`),Ht=_(`<div part=price-preview data-testid=quote>`),Ut=_(`<div style=min-height:186px;display:flex;flex-direction:column>`),Wt=_(`<button part=button-primary type=button>`),Gt=_(`<button disabled type=button><span><span>`),Kt=_(`<button disabled type=button style=opacity:0.6>`),qt=_(`<div part=cta-wrapper style=margin-top:auto>`),Jt=_(`<div style="display:flex;flex-direction:column;align-items:center;justify-content:center;min-height:186px;flex:1;gap:10px;margin:0 20px"><div><svg width=20 height=20 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round><circle cx=8 cy=8 r=6></circle><path d="M18.09 10.37A6 6 0 1 1 10.34 18"></path><path d="M7 6h1v4"></path><path d="m16.71 13.88.7.71-2.82 2.82"></path></svg></div><span></span><span>`),Yt=_(`<div style="padding:0 20px"><div><div><div></div><div><div></div><div></div></div></div><div><div></div><div>`),Xt=_(`<div><svg width=20 height=20 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round><circle cx=12 cy=12 r=10></circle><path d="M12 6v6l4 2">`),Zt=_(`<span data-testid=pay-empty-text>`),Qt=_(`<div data-testid=pay-empty>`),$t=_(`<div><svg width=20 height=20 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round><rect x=1 y=5 width=22 height=16 rx=2></rect><path d="M16 14h.01"></path><path d="M1 10h22">`),en=_(`<span data-testid=recommended-badge>`),tn=_(`<button data-testid=pay-selected><div><div data-testid=pay-token-icon-wrap><div data-testid=pay-token-chain-dot></div></div><div><div><span data-testid=pay-token-symbol></span></div><span data-testid=pay-token-chain-name></span></div></div><div></div><span data-testid=pay-selected-caret>`),nn=_(`<div data-testid=pay-selected-amount>`),rn=_(`<div part=no-offer><div><svg width=28 height=28 viewBox="0 0 24 24"fill=none stroke=currentColor stroke-width=1.5 stroke-linecap=round stroke-linejoin=round><circle cx=11 cy=11 r=8></circle><path d="m21 21-4.35-4.35"></path><path d="M8 11h6"></path></svg></div><span>`);function an(e,n){let[r,i]=f(!1);return l(p(e,e=>{if(!e)return;i(!1);let n=window.requestAnimationFrame(()=>i(!0));t(()=>window.cancelAnimationFrame(n))})),l(p(n,e=>{e||i(!1)})),r}function on(e){return d(j,{get children(){return d(sn,e)}})}function sn(_){let{t:S}=pt(),C=Je(),se=pt();e(()=>{_.config.locale&&se.setLocale(_.config.locale)});let w=s(()=>_.config.methods??[`crypto`]),ce=s(()=>w().includes(`crypto`)),D=s(()=>w().includes(`card`)),{page:O,setPage:Ve,backExiting:j,handleBack:Ze,onBackAnimEnd:at}=ut({methods:w}),M=De(),lt=s(()=>w().length>1&&O()!==`entry`),_t,vt=()=>{_t&&(clearTimeout(_t),_t=void 0)},yt=()=>{vt(),at()},bt=()=>{vt(),_t=setTimeout(yt,260)};t(vt);let xt=e=>{let t=O();if(t===e)return;let n=ui.begin(),r=()=>M.runForwardImmediate(t,e,()=>Ve(e));if(n){ui.scheduleCommit(r);return}r()},on=()=>{if(!j()){if(lt()){let e=O(),t=ui.begin();Ze(),bt();let n=()=>M.runBackImmediate(e,`entry`,()=>Ve(`entry`));if(t){ui.scheduleCommit(n);return}n();return}Ze()}},sn=()=>{yt()},[cn,ln]=f(_.config.amount??``),un=()=>!!_.config.amountEditable,F=()=>un()?cn():_.config.amount??``,I=ye(),L=ye(),dn=an(I.open,I.mounted),fn=an(L.open,L.mounted),R=ye(),[pn,mn]=f(null),[hn,gn]=f(null),[_n,vn]=f(null),[z,B]=f([]),[yn,bn]=f(!1),[xn,Sn]=f(!1),[Cn,wn]=f(!1),[V,H]=f(null),[Tn,En]=f(null),[Dn,U]=f(null),[On,kn]=f(null),[An,jn]=f(!1),Mn=(e,t)=>{t instanceof HTMLElement&&e(t)},Nn=e=>{window.setTimeout(()=>{e?.isConnected&&e.focus()},300)},Pn=e=>{Mn(mn,e),I.show()},Fn=()=>{I.hide(),Nn(pn())},In=e=>{Mn(gn,e),L.show()},Ln=()=>{L.hide(),Nn(hn())},Rn=e=>{if(e instanceof HTMLElement){e.blur();return}if(typeof document>`u`)return;let t=document.activeElement;if(!(t instanceof HTMLElement))return;let n=t.shadowRoot?.activeElement;if(n instanceof HTMLElement){n.blur();return}t.blur()},zn=e=>{Rn(e),X.show()},{isConnected:W,walletAddress:G,handleConnect:Bn}=Ge({walletAdapter:()=>_.walletAdapter,callbacks:()=>_.callbacks,onAddressChange:e=>C.setWalletAddress(e),onDisconnect:()=>{B([]),H(null),jn(!1),En(null),U(null)},onConnectError:(e,t)=>{C.setError(e),C.setErrorCode(t)}}),K=s(()=>new ee({baseUrl:_.config.apiEndpoint??`https://api.hyperstream.dev`})),Vn=()=>K().baseUrl,Hn=s(()=>D()?new m({baseUrl:_.config.fiatApiEndpoint??`https://fiat.hyperstream.dev`}):null),[Un,Wn]=f(_.config.fiatCurrency??`USD`),Gn=s(()=>!!_.config.fiatCurrency),Kn=s(()=>{let e=C.recipient();if(e)return e;let t=C.targetToken(),n=G();return W()&&n&&t&&pe(n,me(t.chainId))?n:null}),qn=s(()=>{if(O()!==`card`)return null;let e=C.targetToken(),t=F();return!e||typeof e.decimals!=`number`||!t?null:ue(t,e.decimals)}),q=rt({client:Hn,targetToken:C.targetToken,recipient:Kn,fiatCurrency:()=>Un(),callbacks:()=>_.callbacks,flowKind:`deposit`,cryptoAmount:qn}),[Jn,Yn]=f(null),Xn=e=>({orderStatus:e,fiatAmount:q.fiatAmount()||e.fiatAmount||``,fiatCurrency:Un(),targetToken:C.targetToken(),tokenDecimals:q.tokenDecimals(),provider:e.provider??`transak`}),J=s(()=>{let e=q.orderStatus();return e?Xn(e):Jn()});l(()=>{let e=q.orderStatus();q.phase()!==`success`||!e||Yn(Xn(e))});let Zn=dt({phase:q.phase,onExpired:()=>q.refetchQuote(),intervalSeconds:30}),Qn=$e(Hn,()=>D()&&!Gn()),$n=[`USD`,`EUR`,`GBP`,`JPY`,`KRW`,`CNY`,`AUD`,`CAD`,`INR`,`SGD`,`HKD`,`TWD`,`BRL`,`MXN`,`CHF`],er=s(()=>{let e=Qn.data;if(!e?.providers?.length)return $n;let t=new Set;for(let n of e.providers){let e=n.supportedCurrencies;if(Array.isArray(e))for(let n of e)typeof n==`string`?t.add(n):n&&typeof n.code==`string`&&t.add(n.code)}return t.size>0?[...t].sort():$n}),tr=s(()=>{let e=q.quote(),t=parseFloat(q.fiatAmount());return!e||!t?!1:!!(e.minFiatAmount&&t<parseFloat(String(e.minFiatAmount))||e.maxFiatAmount&&t>parseFloat(String(e.maxFiatAmount)))}),nr=s(()=>{let e=q.phase();return e===`awaiting-payment`||e===`payment-handoff`||e===`tracking`}),rr=s(()=>O()===`card`&&(q.phase()===`awaiting-payment`||q.phase()===`payment-handoff`)&&!!q.directWidgetUrl()),ir=s(()=>O()===`card`&&(q.phase()===`awaiting-payment`||q.phase()===`payment-handoff`)),ar=s(()=>{if(O()!==`card`||q.phase()!==`payment-handoff`)return null;let e=q.orderId(),t=q.directWidgetUrl();return e&&t?`${e}:${t}`:null}),or=s(()=>{let e=q.quote();return e?.providerName??Re(q.orderStatus()?.provider??e?.provider??`Transak`)}),sr=s(()=>q.fiatAmount()||q.orderStatus()?.fiatAmount||q.quote()?.fiatAmount||``),cr=()=>{rr()&&(R.open()?R.hide():R.show())};l(()=>{if(!rr()){q.orderId()||vn(null),R.hide();return}let e=ar();e&&_n()!==e&&(vn(e),R.show())});let lr=s(()=>{let e=q.phase();return e===`creating-order`||e===`quoting`}),ur=s(()=>{let e=q.phase();return e===`error`?S({id:`1w68n16`,message:`Try Again`})??`Try Again`:e===`creating-order`||e===`quoting`?S({id:`344av8`,message:`Processing...`}):e===`quoted`&&q.quote()?S({id:`13l4n4r`,message:`Continue via {provider}`},{provider:q.quote().providerName??Re(q.quote().provider)}):S({id:`119fv83`,message:`Enter amount`})}),dr=s(()=>q.phase()===`quoted`&&!!Kn()&&!tr()&&!q.isQuoteFetching()),fr=()=>{let e=q.phase();e===`error`?q.handleRetry():e===`quoted`&&dr()&&q.createOrder()},Y=s(()=>ft(C.execPhase(),C.error(),yn(),z().length)),pr=s(()=>{let e=Y();return e===`building`||e===`awaiting-wallet`||e===`submitting`||e===`tracking`}),mr=s(()=>O()===`card`&&(nr()||q.phase()===`success`)),hr=s(()=>O()===`card`?q.phase()===`success`&&q.orderStatus()?`success`:mr()?`tracking`:`form`:Y()===`success`&&C.order()?`success`:pr()?`tracking`:`form`),X=ye(),gr=s(()=>!!_.config.recipient&&_.config.recipientEditable!==!0),{needRecipient:_r,recipientDisplay:vr,handleRecipientChange:yr}=et({fromToken:V,toToken:C.targetToken,recipient:C.recipient,isConnected:W,walletAddress:G,walletAdapter:()=>_.walletAdapter,setRecipient:C.setRecipient}),br=s(()=>_.config.fromTokens?.length?tt(_.config.fromTokens):void 0),xr=Ae(K,G,()=>W()&&!!G(),()=>_.walletAdapter?.supportedChainIds);e(()=>{_.config.recipient&&C.setRecipient(_.config.recipient)});let Sr=_e(K,()=>!0),Z=s(()=>{let e=Sr.data;return e?Me(e):new Map});e(async()=>{let e=K();if(_.config.amount){let e=Number(_.config.amount);if(!Number.isFinite(e)||e<=0){C.setError(`Invalid amount: must be greater than zero`),C.setErrorCode(h.INVALID_AMOUNT);return}}try{if(_.config.target){let t=Ye(_.config.target),n=await le(t.chainId,t.address,_.config.apiEndpoint,e);if(typeof n.decimals!=`number`){C.setError(`Failed to resolve target token metadata`),C.setErrorCode(h.INVALID_CONFIG);return}C.setTargetToken(n),_.config.amount&&C.setTargetAmount(_.config.amount)}if(_.config.fromToken)try{let t=Ye(_.config.fromToken),n=await le(t.chainId,t.address,_.config.apiEndpoint,e);typeof n.decimals==`number`&&kn({address:n.address,chainId:n.chainId,symbol:n.symbol??n.address.slice(0,6),name:n.name??n.symbol??n.address,decimals:n.decimals,logoURI:n.logoURI,...n.priceUsd===void 0?{}:{extensions:{price:{usd:String(n.priceUsd)}}}})}catch(e){_.callbacks?.onDepositError?.({code:h.INVALID_TOKEN_IDENTIFIER,message:`Failed to resolve fromToken: ${e instanceof Error?e.message:String(e)}`})}}catch(e){C.setError(e instanceof Error?e.message:`Failed to resolve target token`),C.setErrorCode(h.INVALID_CONFIG)}});let Cr=s(()=>{let e=xr.data;if(!e||e.length===0)return[];let t=_.walletAdapter?.supportedChainIds,n=br();return e.filter(e=>!(t?.length&&!t.includes(e.chainId)||n&&!n.has(ge({chainId:e.chainId,address:e.address}))))}),Q=s(()=>{let e=Cr(),t=C.targetToken();if(!e||e.length===0||!t)return[];let n=t.priceUsd??1,r=Number(F()||`0`)*n;return St(e,t.symbol??``,t.chainId,t.address,r>0?r:void 0)});l(p([On,Q],([e,t])=>{let n=oe({defaultFromToken:e,balances:t,currentSelection:V(),userPicked:An()});if(!n)return;H(n);let r=Y();(r===`quoting`||r===`quoted`||r===`error`)&&$(t)})),l(p(Q,e=>{let t=Y();e.length>0&&(t===`idle`||t===`error`)&&O()===`crypto`&&$(e)})),l(p(()=>C.recipient(),()=>{let e=Q(),t=Y();e.length>0&&(t===`idle`||t===`quoted`||t===`error`)&&O()===`crypto`&&$(e)},{defer:!0})),l(p(()=>O(),e=>{if(e===`crypto`){let e=Q();e.length>0&&(Y()===`idle`||Y()===`error`)&&$(e)}},{defer:!0}));let wr=s(()=>{let e=V();if(!e)return null;let t=C.targetToken(),n=G(),r=C.recipient(),i=F();return!t||typeof t.decimals!=`number`||!n||!i||_r()&&!r?null:{tradeType:`EXACT_OUTPUT`,fromChainId:e.chainId,fromToken:e.address,toChainId:t.chainId,toToken:t.address,amount:ue(i,t.decimals),fromAddress:n,...r&&{recipient:r},..._.config.refundTo&&{refundTo:_.config.refundTo},..._.config.referrer&&{referrer:_.config.referrer},..._.config.referrerFeeBps!==void 0&&{referrerFeeBps:_.config.referrerFeeBps}}}),Tr=ke(K,wr,s(()=>!!wr()&&Y()===`quoted`)),Er=s(()=>O()===`crypto`&&(yn()||xn()||Y()===`quoted`&&Tr.isFetching));l(p(()=>Tr.data,e=>{if(e&&_.callbacks?.onQuoteReceived?.(e),!e||Y()!==`quoted`)return;let t=V();if(t&&e.routes.length>0){let n=fe(he(e.routes,`EXACT_OUTPUT`))[0],r=e.routes.find(e=>e.routeId===n)??e.routes[0],i=z(),a=i.findIndex(e=>e.token.address.toLowerCase()===t.address.toLowerCase()&&e.token.chainId===t.chainId);if(a>=0){let n=[...i];n[a]={token:t,route:r,quoteId:e.quoteId},B(n)}}}));let{countdownSeconds:Dr}=dt({phase:Y,onExpired:()=>{Tr.refetch()}}),Or=async(e,t,n,r,i,a,o)=>{try{let s={tradeType:`EXACT_OUTPUT`,fromChainId:t.chainId,fromToken:t.address,toChainId:i.chainId,toToken:i.address,amount:n,fromAddress:r,...a&&{recipient:a},..._.config.refundTo&&{refundTo:_.config.refundTo},..._.config.referrer&&{referrer:_.config.referrer},..._.config.referrerFeeBps!==void 0&&{referrerFeeBps:_.config.referrerFeeBps}},c=await ae.fetchQuery({queryKey:[`quote`,e.baseUrl,s],queryFn:({signal:t})=>e.getQuotes(s,{signal:o??t}),staleTime:15e3});if(c.routes.length>0){let e=fe(he(c.routes,`EXACT_OUTPUT`))[0];return{token:t,route:c.routes.find(t=>t.routeId===e)??c.routes[0],quoteId:c.quoteId}}}catch{}return null},kr=null,$=async e=>{let t=K(),n=G(),r=C.targetToken();if(!t||!n||!r||typeof r.decimals!=`number`||e.length===0)return;o(()=>{z().length>0&&B([]),C.error()&&C.clearError(),Dn()&&U(null),bn(!0)}),kr?.abort();let i=new AbortController;kr=i;try{let a=F();if(!a){bn(!1);return}let o=ue(a,r.decimals),s=V(),c=s?e.find(e=>T(e,s)):void 0,l=c?[c,...e.filter(e=>!T(e,c))]:e;for(let e of l){if(i.signal.aborted)return;let a=await Or(t,e,o,n,r,C.recipient(),i.signal);if(i.signal.aborted)return;if(a){B([a]),H(e),En(ge(e)),U(null),bn(!1);return}}i.signal.aborted||(B([]),En(null))}catch{}finally{bn(!1),wn(!0)}};t(()=>{kr?.abort()});let Ar=s(()=>{let e=Q(),t=Cr();if(e.length===0)return t;let n=[...e];for(let e of t)n.some(t=>T(t,e))||n.push(e);return n}),jr=s(()=>{let e=V(),t=Ar();if(!e||t.length===0)return 0;let n=t.findIndex(t=>T(t,e));return n>=0?n:0}),Mr=s(()=>{let e=Ar(),t=z(),n=C.targetToken(),r=Z();if(e.length===0||!n)return[];let i=new Map;for(let e of t)i.set(ge(e.token),e);let a=Tn();return e.map(e=>{let t=ge(e),n=i.get(t),o=r.get(e.chainId),s=e.decimals,c=Number(e.extensions?.price?.usd??`0`),l=e.extensions?.balance?E(e.extensions.balance,s):`0`,u=k(de(l,2)),d=``;if(c>0&&e.extensions?.balance){let e=Number(l)*c;d=e<.01?`<$0.01`:`$${k(e.toFixed(2).replace(/\.?0+$/,``))}`}let f=``,p=``,m=!0;if(n){let t=E(n.route.quote.amountIn,s);if(f=k(de(t,2)),c>0){let e=Number(t)*c;p=e<.01?`<$0.01`:`$${k(e.toFixed(2).replace(/\.?0+$/,``))}`}m=BigInt(e.extensions?.balance??`0`)>=BigInt(n.route.quote.amountIn||`0`)}return{symbol:e.symbol,chain:o?.name??`Chain ${e.chainId}`,color:`#888`,amount:f,amountUsd:p,balance:u,balanceUsd:d,recommended:a!==null&&t===a,disabled:!m,logoURI:e.logoURI,chainId:e.chainId,address:e.address}})}),Nr=s(()=>{let e={};for(let t of Mr())if(t.recommended&&t.chainId){let n=(t.address??`0x0000000000000000000000000000000000000000`).toLowerCase();e[`eip155:${t.chainId}:${n}`]=S({id:`xel5qk`,message:`Recommended`})}return e}),Pr=s(()=>{let e=V();return e?z().find(t=>T(t.token,e))??null:null}),Fr=s(()=>Pr()?.route??null),Ir=s(()=>{let e=Pr();return e?{chainId:e.token.chainId,address:e.token.address,symbol:e.token.symbol,name:e.token.name,decimals:e.token.decimals,logoURI:e.token.logoURI}:null}),{trackingOrderId:Lr,trackingProviderName:Rr,trackingProviderIcon:zr,trackingInputAmount:Br,executionError:Vr,failedExecPhase:Hr,handleConfirm:Ur,handleRetry:Wr,handleNewSwap:Gr}=Ct({client:K,walletAdapter:()=>_.walletAdapter,callbacks:()=>_.callbacks,apiEndpoint:()=>_.config.apiEndpoint,recipient:C.recipient,needRecipient:_r,walletAddress:G,targetToken:C.targetToken,selectedPayToken:V,payTokenQuotes:z,setPayTokenQuotes:B,setLoadingQuotes:bn,fetchSingleQuote:Or,configAmount:F,execPhase:C.execPhase,setExecPhase:C.setExecPhase,setFromToken:C.setFromToken,setError:C.setError,setErrorCode:C.setErrorCode,storeReset:C.reset,storeClearError:C.clearError,onRetry:()=>{H(null),jn(!1),En(null),U(null);let e=Q();e.length>0&&$(e)},onReset:()=>{H(null),jn(!1),En(null),U(null);let e=Q();e.length>0&&$(e)}});We({client:K,walletAddress:G,trackingOrderId:Lr,phase:Y,execPhase:C.execPhase,setOrder:C.setOrder,setExecPhase:C.setExecPhase,onOrderFilled:e=>{let t=V();_.callbacks?.onDepositSuccess?.({orderId:e.id,fromToken:t?.symbol??``,toToken:C.targetToken()?.symbol??``,fromAmount:e.srcAmount,toAmount:e.destAmount,txHash:e.depositTxHash??``})},onOrderFailed:e=>{_.callbacks?.onDepositError?.({code:h.ORDER_FAILED,message:`Order `+e.status})}});let Kr=async e=>{Sn(!0),U(null);try{let t=K(),n=G(),r=C.targetToken(),i=F();if(!t||!n||!r||typeof r.decimals!=`number`||!i)return!1;let a=await Or(t,e,ue(i,r.decimals),n,r,C.recipient());if(!a)return U(S({id:`wuxjl9`,message:`Selected token is unavailable for this purchase`})),!1;let o=z(),s=[...o],c=o.findIndex(t=>T(t.token,e));return c>=0?s[c]=a:s.push(a),B(s),H(e),jn(!0),!0}finally{Sn(!1)}},qr=e=>{I.hide(),e.address&&Kr(Ar().find(t=>T(t,{chainId:e.chainId,address:e.address}))||{chainId:e.chainId,address:e.address,symbol:e.symbol,name:e.name,decimals:e.decimals??18,logoURI:e.logoURI})},Jr=async()=>{_.walletAdapter?.openAccountModal?await _.walletAdapter.openAccountModal():_.callbacks?.onAccountModal?.()},Yr=()=>C.targetToken()?.symbol??``,Xr=()=>q.quote()?.token?.decimals??C.targetToken()?.decimals??18,Zr=e=>e?de(E(e,Xr()),6):`0`,Qr=()=>{if(O()===`card`&&q.quote()){let e=q.quote();if(e.swapStrategy===`jump`){let t=e.routes?.[0]?.estimatedOutputAmount??e.estimatedOutputAmount;if(t)return de(E(t,C.targetToken()?.decimals??18),6)}if(e.cryptoAmount)return Zr(e.cryptoAmount)}return C.targetAmount()||F()},$r=()=>{let e=Number(Qr()),t=C.targetToken()?.priceUsd??0;return!e||t<=0?``:S({id:`1ovj1tk`,message:"≈ ${addThousandsSeparator}"},{addThousandsSeparator:k((e*t).toFixed(2).replace(/\.?0+$/,``))})},ei=()=>{let e=Qr(),t=Yr();return!e||!t?S({id:`119fv83`,message:`Enter amount`}):S({id:`1cei180`,message:`Buy {amt} {sym}`},{amt:e,sym:t})},ti=()=>!!C.targetToken(),ni=()=>!!_.config.target,ri=s(()=>_.config.toTokens?.length?tt(_.config.toTokens):void 0),ii=e=>{if(o(()=>{ln(e),C.setTargetAmount(e),O()===`crypto`&&Q().length>0&&e&&bn(!0)}),O()===`crypto`){let t=Q();t.length>0&&e&&$(t)}},ai=s(()=>{let e=_.config.titleText?.trim();return e&&e.length>0?e:`TokenFlight`}),oi=s(()=>{let e=_.config.titleText?.trim();return!!e&&e.length>0}),si=s(()=>{let e=_.config.titleImageUrl?.trim();return e&&e.length>0?e:null}),ci=s(()=>w().length>1&&ce()&&D()),li,ui=Le({container:()=>li,observeKey:()=>[hr(),O(),M.state(),M.transitionPages()?.incoming??``,M.transitionPages()?.outgoing??``,mr(),mr()?q.phase():``,rr()?`fiat-payment-link`:``,_.config.hidePoweredBy].join(`|`)});return(()=>{var e=wt(),t=e.firstChild;return re(e=>{li=e},e),g(e,d(st,{get current(){return hr()},views:{form:()=>[(()=>{var e=Dt(),t=e.firstChild,n=t.firstChild,r=n.firstChild;return g(n,d(c,{get when(){return si()},get fallback(){return d(c,{get when(){return!_.config.hideTitle},get children(){return d(ct,{size:22})}})},get children(){var e=Tt();return a(t=>{var n=si(),r=ai(),i=`${A.headerLogoImage} ${_.config.hideTitle?A[`headerLogoImage--solo`]:``}`;return n!==t.e&&ne(e,`src`,t.e=n),r!==t.t&&ne(e,`alt`,t.t=r),i!==t.a&&b(e,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),r),g(r,d(c,{get when(){return oi()},get fallback(){return[`Token`,(()=>{var e=Ft();return a(()=>b(e,A.headerTitleAccent)),e})()]},get children(){return ai()}})),g(e,d(c,{get when(){return v(()=>!!W())()&&G()},get children(){var e=Et(),t=e.firstChild,n=t.nextSibling;return y(e,`click`,Jr),g(n,()=>ze(G())),a(r=>{var i=A.headerRight,a=S({id:`xphk5n`,message:`Wallet account`}),o=A.walletDot,s=A.walletAddress;return i!==r.e&&b(e,r.e=i),a!==r.t&&ne(e,`aria-label`,r.t=a),o!==r.a&&b(t,r.a=o),s!==r.o&&b(n,r.o=s),r},{e:void 0,t:void 0,a:void 0,o:void 0}),e}}),null),a(i=>{var a=P.header,o=A.headerLeft,s=`${A.headerBrand} ${A[`headerBrand--idle`]}`,c=`${A.headerTitle} ${_.config.hideTitle?A[`headerTitle--hidden`]:``}`;return a!==i.e&&b(e,i.e=a),o!==i.t&&b(t,i.t=o),s!==i.a&&b(n,i.a=s),c!==i.o&&b(r,i.o=c),i},{e:void 0,t:void 0,a:void 0,o:void 0}),e})(),(()=>{var e=Mt(),t=e.firstChild,n=t.firstChild,r=n.firstChild,i=n.nextSibling,o=i.firstChild,s=o.firstChild;return g(r,()=>Be(`youReceive`,S({id:`va18uh`,message:`You receive`}))),g(n,d(c,{get when(){return vr()||W()&&ti()&&!!F()},get children(){var e=Ot(),t=e.firstChild;return y(e,`click`,e=>!pr()&&!gr()&&zn(e.currentTarget)),g(t,(()=>{var e=v(()=>!!vr());return()=>e()?ze(vr()):S({id:`fpand1`,message:`Enter destination address`})})()),g(e,d(c,{get when(){return!gr()},get children(){return d(Ke,{size:10})}}),null),a(n=>{var r=`${x.recipientBadge} ${vr()?``:x.recipientBadgeEmpty}${gr()?` ${x.recipientBadgeLocked}`:``}`,i=gr(),a=x.recipientBadgeText;return r!==n.e&&b(e,n.e=r),i!==n.t&&(e.disabled=n.t=i),a!==n.a&&b(t,n.a=a),n},{e:void 0,t:void 0,a:void 0}),e}}),null),g(i,d(c,{get when(){return ti()},get fallback(){return(()=>{var e=It();return y(e,`click`,e=>In(e.currentTarget)),g(e,()=>S({id:`zz4mrw`,message:`Select token`}),null),g(e,d(Xe,{size:14}),null),e})()},get children(){var e=At(),t=e.firstChild,n=t.nextSibling,r=n.firstChild.firstChild,i=r.nextSibling;return y(e,`click`,e=>{ni()||In(e.currentTarget)}),g(t,d(ot,{get symbol(){return Yr()},color:`#0052FF`,size:32,get logoURI(){return C.targetToken()?.logoURI}}),null),g(t,d(c,{get when(){return C.targetToken()?.chainId},get children(){var e=kt();return g(e,d(Qe,{size:12,get iconUrl(){return te(Vn(),C.targetToken()?.chainId??0)}})),a(()=>b(e,P.targetChainDot)),e}}),null),g(r,Yr),g(i,()=>Z().get(C.targetToken()?.chainId??0)?.name??``),g(n,d(c,{get when(){return!ni()},get children(){return d(Xe,{size:14})}}),null),a(n=>{var i={...ni()?{}:{cursor:`pointer`}},a=P.targetIcon,o=P.symbol;return n.e=ie(e,i,n.e),a!==n.t&&b(t,n.t=a),o!==n.a&&b(r,n.a=o),n},{e:void 0,t:void 0,a:void 0}),e}}),o),g(o,d(c,{get when(){return un()},get fallback(){return(()=>{var e=Lt();return g(e,()=>k(Qr())),a(()=>b(e,P.amount)),e})()},get children(){var e=jt(),t=e.firstChild;return y(t,`input`,e=>ii(e.target.value)),a(n=>{var r=P.amountInputShell,i=P.amountInput;return r!==n.e&&b(e,n.e=r),i!==n.t&&b(t,n.t=i),n},{e:void 0,t:void 0}),a(()=>t.value=cn()),e}}),s),g(s,$r),a(r=>{var a=P.section,o=P.target,c=P.sectionLabel,l=P.targetContent,u=P.fiat;return a!==r.e&&b(e,r.e=a),o!==r.t&&b(t,r.t=o),c!==r.a&&b(n,r.a=c),l!==r.o&&b(i,r.o=l),u!==r.i&&b(s,r.i=u),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e})(),(()=>{var e=Pt(),t=e.firstChild;return g(t,d(c,{get when(){return lt()},get fallback(){return(()=>{var e=Rt();return g(e,()=>S({id:`cgzgvn`,message:`Pay with`})),a(()=>b(e,P.methodHeaderLabel)),e})()},get children(){var e=Nt(),t=e.firstChild,n=t.nextSibling;return y(e,`click`,on),y(t,`animationend`,j()?sn:void 0),g(t,d(nt,{size:14})),g(n,()=>S({id:`cgzgvn`,message:`Pay with`})),a(r=>{var i=`${x.backButton} ${P.methodHeaderBackButton}${j()?` ${x.backButtonExiting}`:``}`,a=j()?P.backArrowExit:P.backArrowEnter,o=j()?P.backTextExit:P.backTextEnter;return i!==r.e&&b(e,r.e=i),a!==r.t&&b(t,r.t=a),o!==r.a&&b(n,r.a=o),r},{e:void 0,t:void 0,a:void 0}),e}})),g(e,d(Ce,{get page(){return O()},get state(){return M.state()},get transitionPages(){return M.transitionPages()},renderPage:e=>[d(c,{when:e===`entry`,get children(){return[(()=>{var e=zt();return a(()=>b(e,P.methodPaneSpacer)),e})(),d(it,{get hasCrypto(){return ce()},get hasCard(){return D()},onSelectCrypto:()=>xt(`crypto`),onSelectCard:()=>xt(`card`)})]}}),d(c,{when:e===`crypto`,get children(){return[(()=>{var e=zt();return g(e,d(c,{get when(){return Y()===`quoted`},get children(){return d(Se,{secondsRemaining:Dr,totalSeconds:30,onRefresh:()=>{Tr.refetch()},isRefreshing:()=>Tr.isFetching})}})),a(()=>b(e,`${P.methodPaneSpacer} ${P.methodPaneSpacerCrypto}`)),e})(),(()=>{var e=Ut();return g(e,d(c,{get when(){return F()},get fallback(){return(()=>{var e=Jt(),t=e.firstChild,n=t.nextSibling,r=n.nextSibling;return g(n,()=>S({id:`1olegnl`,message:`Enter amount to get started`})),g(r,()=>S({id:`13i9oqu`,message:`We'll find the best rate for you`})),a(i=>{var a=Ie.quoteCardSlotCard,o=x.idleIcon,s=x.idleTitle,c=x.idleSub;return a!==i.e&&b(e,i.e=a),o!==i.t&&b(t,i.t=o),s!==i.a&&b(n,i.a=s),c!==i.o&&b(r,i.o=c),i},{e:void 0,t:void 0,a:void 0,o:void 0}),e})()},get children(){return[d(c,{get when(){return!yn()||z().length>0},get fallback(){return[(()=>{var e=Yt(),t=e.firstChild,n=t.firstChild,r=n.firstChild,i=r.nextSibling,o=i.firstChild,s=o.nextSibling,c=n.nextSibling,l=c.firstChild,u=l.nextSibling;return a(e=>{var a=P.paySelectedSkeleton,d=P.paySelectedLeft,f=`${x.skeleton} ${P.paySkeletonIcon}`,p=P.paySkeletonInfo,m=`${x.skeleton} ${P.paySkeletonLine} ${P.paySkeletonSymbol}`,ee=`${x.skeleton} ${P.paySkeletonLine} ${P.paySkeletonChain}`,te=P.paySkeletonRight,h=`${x.skeleton} ${P.paySkeletonLine} ${P.paySkeletonAmount}`,g=`${x.skeleton} ${P.paySkeletonLine} ${P.paySkeletonUsd}`;return a!==e.e&&b(t,e.e=a),d!==e.t&&b(n,e.t=d),f!==e.a&&b(r,e.a=f),p!==e.o&&b(i,e.o=p),m!==e.i&&b(o,e.i=m),ee!==e.n&&b(s,e.n=ee),te!==e.s&&b(c,e.s=te),h!==e.h&&b(l,e.h=h),g!==e.r&&b(u,e.r=g),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0}),e})(),d(Oe,{})]},get children(){return[(()=>{var e=Bt();return g(e,d(c,{get when(){return Mr().length>0},get fallback(){return(()=>{var e=Qt();return g(e,d(c,{get when(){return W()},get fallback(){return[(()=>{var e=$t();return a(()=>b(e,x.idleIcon)),e})(),(()=>{var e=Zt();return g(e,()=>S({id:`18y1lrp`,message:`Connect your wallet to see payment options`})),a(()=>b(e,P.payEmptyText)),e})()]},get children(){return[(()=>{var e=Xt();return a(()=>b(e,x.idleIcon)),e})(),(()=>{var e=Zt();return g(e,()=>S({id:`g7pjpv`,message:`No tokens available`})),a(()=>b(e,P.payEmptyText)),e})()]}})),a(()=>b(e,P.payEmpty)),e})()},get children(){return(()=>{let e=()=>Mr()[jr()]??Mr()[0];return(()=>{var t=tn(),n=t.firstChild,r=n.firstChild,i=r.firstChild,o=r.nextSibling,s=o.firstChild,l=s.firstChild,u=s.nextSibling,f=n.nextSibling,p=f.nextSibling;return y(t,`click`,e=>Pn(e.currentTarget)),g(r,d(ot,{get symbol(){return e().symbol},get color(){return e().color},size:32,get logoURI(){return e().logoURI}}),i),g(i,d(Qe,{color:null,size:12,get iconUrl(){return v(()=>e().chainId!==void 0)()?te(Vn(),e().chainId):void 0}})),g(l,()=>e().symbol),g(s,d(c,{get when(){return e().recommended},get children(){var e=en();return g(e,()=>S({id:`xel5qk`,message:`Recommended`})),a(()=>b(e,P.payBestBadge)),e}}),null),g(u,()=>e().chain),g(f,d(c,{get when(){return v(()=>!!yn())()&&!e().amount},get fallback(){return[(()=>{var t=nn();return g(t,()=>e().amount),a(()=>b(t,P.paySelectedAmount)),t})(),d(c,{get when(){return e().amountUsd},get children(){var t=kt();return g(t,()=>e().amountUsd),a(()=>b(t,P.paySelectedAmountUsd)),t}})]},get children(){var e=kt();return a(()=>b(e,`${x.skeleton} ${P.payAmountSkeleton}`)),e}})),g(p,d(Xe,{size:16})),a(e=>{var a=P.paySelected,c=S({id:`1t0r88u`,message:`Select payment token`}),d=P.paySelectedLeft,m=P.payIconWrap,ee=P.payChainDot,te=P.paySelectedInfo,h=P.paySelectedTopRow,g=P.payTokenSymbol,re=P.payTokenChain,_=P.paySelectedRight,v=P.paySelectedCaret;return a!==e.e&&b(t,e.e=a),c!==e.t&&ne(t,`aria-label`,e.t=c),d!==e.a&&b(n,e.a=d),m!==e.o&&b(r,e.o=m),ee!==e.i&&b(i,e.i=ee),te!==e.n&&b(o,e.n=te),h!==e.s&&b(s,e.s=h),g!==e.h&&b(l,e.h=g),re!==e.r&&b(u,e.r=re),_!==e.d&&b(f,e.d=_),v!==e.l&&b(p,e.l=v),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0}),t})()})()}})),e})(),d(c,{get when(){return Dn()},get children(){var e=Vt();return g(e,Dn),e}})]}}),d(c,{get when(){return v(()=>!!(Mr().some(e=>!e.disabled)&&Fr()&&Ir()))()&&C.targetToken()},get fallback(){return d(c,{get when(){return xn()},get fallback(){return d(c,{get when(){return v(()=>!!(Cn()&&!yn()&&F()&&Mr().some(e=>!e.disabled)))()&&!Fr()},get children(){var e=rn(),t=e.firstChild,n=t.nextSibling;return g(n,()=>S({id:`1ne9nkz`,message:`No offer available`})),a(r=>{var i=x.noOffer,a=x.noOfferIcon,o=x.noOfferText;return i!==r.e&&b(e,r.e=i),a!==r.t&&b(t,r.t=a),o!==r.a&&b(n,r.a=o),r},{e:void 0,t:void 0,a:void 0}),e}})},get children(){return d(Oe,{})}})},get children(){var e=Ht();return g(e,d(Te,{get route(){return Fr()},get fromToken(){return Ir()},get toToken(){return C.targetToken()},inline:!0})),a(()=>b(e,Pe.quote)),e}})]}})),e})()]}}),d(c,{when:e===`card`,get children(){return[(()=>{var e=zt();return g(e,d(Ue,{get currencies(){return er()},get selected(){return Un()},onSelect:Wn,get locked(){return Gn()},get locale(){return _.config.locale}})),a(()=>b(e,P.methodPaneSpacer)),e})(),d(ht,r({fiatCheckout:q,fiatCountdown:Zn,get targetToken(){return C.targetToken()??null},get fiatCurrency(){return Un()},get apiBase(){return Vn()},showPayAmount:!0},()=>F()&&!Kn()?{idleTitle:S({id:`pom1h2`,message:`Enter recipient address`}),idleSub:S({id:`7m2ht3`,message:`Required to receive your tokens`})}:{}))]}}),d(c,{when:e!==`entry`,get children(){var t=qt();return g(t,d(i,{get children(){return[d(n,{get when(){return!ti()},get children(){var e=Wt();return y(e,`click`,e=>In(e.currentTarget)),g(e,()=>S({id:`zz4mrw`,message:`Select token`})),a(()=>b(e,N.btnRecipient)),e}}),d(n,{when:e===`crypto`,get children(){return d(qe,{get phase(){return Y()},get isConnected(){return W()},get hasQuote(){return!!Fr()},get confirmDisabled(){return Er()},onConnect:Bn,onConfirm:Ur,onRetry:Wr,get needsRecipient(){return v(()=>!!_r())()&&!C.recipient()},onEnterRecipient:()=>zn(),get label(){return v(()=>!!pr())()?void 0:ei()}})}}),d(n,{when:e===`card`,get children(){return d(i,{get children(){return[d(n,{get when(){return q.phase()===`error`},get children(){var e=Wt();return y(e,`click`,fr),g(e,ur),a(()=>b(e,N.btnPrimary)),e}}),d(n,{get when(){return lr()},get children(){var e=Gt(),t=e.firstChild,n=t.firstChild;return g(t,ur,null),a(r=>{var i=`${N.btnPrimary} ${N.executing}`,a=N.btnInner,o=N.spinner;return i!==r.e&&b(e,r.e=i),a!==r.t&&b(t,r.t=a),o!==r.a&&b(n,r.a=o),r},{e:void 0,t:void 0,a:void 0}),e}}),d(n,{get when(){return!F()},get children(){var e=Kt();return g(e,()=>S({id:`119fv83`,message:`Enter amount`})),a(()=>b(e,N.btnPrimary)),e}}),d(n,{get when(){return!Kn()},get children(){var e=Wt();return y(e,`click`,e=>zn(e.currentTarget)),g(e,()=>S({id:`wx5bee`,message:`Enter Recipient Address`})),a(()=>b(e,N.btnRecipient)),e}}),d(n,{get when(){return dr()},get children(){var e=Wt();return y(e,`click`,fr),g(e,ur),a(()=>b(e,N.btnPrimary)),e}}),d(n,{when:!0,get children(){var e=Kt();return g(e,ur),a(()=>b(e,N.btnPrimary)),e}})]}})}})]}})),a(()=>b(t,x.ctaWrapperReceive)),t}})]}),null),a(()=>b(t,P.methodHeaderOverlay)),e})(),(()=>{var e=kt();return g(e,d(c,{get when(){return!_.config.hidePoweredBy},get children(){return d(He,{})}})),a(()=>b(e,x.footerSlot)),e})()],tracking:()=>d(i,{get children(){return[d(n,{get when(){return O()===`card`},get children(){return d(we,{get phase(){return q.phase()},get status(){return q.orderStatus()?.status??`pending_payment`},get strategy(){return q.strategy()??q.orderStatus()?.swapStrategy??`direct`},get fiatAmount(){return sr()},get fiatCurrency(){return Un()},get cryptoAmount(){let e=q.orderStatus()?.quotedCryptoAmount??q.quote()?.cryptoAmount,t=C.targetToken()?.decimals;return!e||t==null?e:E(e,t)},get targetToken(){return C.targetToken()},get provider(){return q.orderStatus()?.provider??q.quote()?.provider??`transak`},get hideProvider(){return _.config.hideProvider},get transferTxHash(){return q.orderStatus()?.fillTxHash??q.orderStatus()?.transferTxHash},get failedReason(){return q.orderStatus()?.failedReason??q.orderStatus()?.errorReason},get apiBase(){return Vn()},get chainMap(){return Z()},get paymentLinkAvailable(){return rr()},get paymentLinkOpen(){return R.open()},onPaymentLinkToggle:cr,get cancelAvailable(){return ir()},onCancelPayment:()=>q.cancelPayment(),onNewPurchase:()=>q.handleNewPurchase(),onRetry:()=>q.handleRetry(),onBack:()=>q.handleNewPurchase()})}}),d(n,{when:!0,get children(){return d(Ne,{get order(){return C.order()},get fromToken(){return C.fromToken()},get toToken(){return C.targetToken()},get providerName(){return Rr()},get providerIcon(){return zr()},get hideProvider(){return _.config.hideProvider},get apiEndpoint(){return _.config.apiEndpoint??`https://api.hyperstream.dev`},get inputAmount(){return Br()??``},get outputAmount(){return C.targetAmount()},onNewSwap:Gr,mode:`receive`,get executionError(){return Vr()},onRetry:Wr,get phase(){return Y()},get failedPhase(){return Hr()},get chainMap(){return Z()}})}})]}}),success:()=>d(i,{get children(){return[d(n,{get when(){return v(()=>O()===`card`)()&&J()},get children(){return d(gt,{get orderStatus(){return J().orderStatus},get fiatAmount(){return J().fiatAmount},get fiatCurrency(){return J().fiatCurrency},get targetToken(){return J().targetToken},get tokenDecimals(){return J().tokenDecimals},get provider(){return J().provider},get apiBase(){return Vn()},get chainMap(){return Z()},onNewPurchase:()=>q.handleNewPurchase()})}}),d(n,{when:!0,get children(){return d(Ee,{get order(){return C.order()},get fromToken(){return C.fromToken()},get toToken(){return C.targetToken()},onNewSwap:Gr,get apiEndpoint(){return _.config.apiEndpoint??`https://api.hyperstream.dev`},get providerName(){return Rr()},mode:`receive`,get chainMap(){return Z()}})}})]}})}}),null),g(e,d(c,{get when(){return v(()=>!!R.mounted())()&&q.directWidgetUrl()},get children(){return d(ve,{get url(){return q.directWidgetUrl()},get provider(){return or()},get dismissing(){return R.dismissing()},onClose:()=>R.hide()})}}),null),g(e,d(c,{get when(){return I.mounted()},get children(){return d(je,{selectingFor:`from`,onClose:Fn,get noBorder(){return _.config.noBorder},get dismissing(){return I.dismissing()},get children(){return d(c,{get when(){return dn()},get fallback(){return d(be,{selectingFor:`from`,onClose:Fn})},get children(){return d(u,{get fallback(){return d(be,{selectingFor:`from`,onClose:Fn})},get children(){return d(xe,{get client(){return K()},get walletAddress(){return G()},selectingFor:`from`,get tokenTags(){return Nr()},onSelect:qr,onClose:Fn,get supportedChainIds(){return _.walletAdapter?.supportedChainIds},get allowedTokens(){return br()},get noBorder(){return _.config.noBorder},get dismissing(){return I.dismissing()}})}})}})}})}}),null),g(e,d(c,{get when(){return L.mounted()},get children(){return d(je,{selectingFor:`to`,onClose:Ln,get noBorder(){return _.config.noBorder},get dismissing(){return L.dismissing()},get children(){return d(c,{get when(){return fn()},get fallback(){return d(be,{selectingFor:`to`,onClose:Ln})},get children(){return d(u,{get fallback(){return d(be,{selectingFor:`to`,onClose:Ln})},get children(){return d(xe,{get client(){return K()},walletAddress:null,selectingFor:`to`,onSelect:e=>{e.address&&typeof e.decimals==`number`&&C.setTargetToken({chainId:e.chainId,address:e.address,symbol:e.symbol,name:e.name,decimals:e.decimals,logoURI:e.logoURI,priceUsd:e.priceUsd}),L.hide()},onClose:Ln,get allowedTokens(){return ri()},get noBorder(){return _.config.noBorder},get dismissing(){return L.dismissing()}})}})}})}})}}),null),g(e,d(c,{get when(){return v(()=>!!X.mounted())()&&C.targetToken()},get children(){return d(Fe,{onClose:()=>X.hide(),get dismissing(){return X.dismissing()},get children(){return d(mt,{get initialValue(){return C.recipient()??``},get chainType(){return me(C.targetToken().chainId)},onConfirm:e=>{yr(e),X.hide()},onClose:()=>X.hide(),get dismissing(){return X.dismissing()}})}})}}),null),a(n=>{var r=`${x.container}${ci()?` ${x.receiveMethodStableContainer}`:``}${ui.state()===`animating`?` ${A.swapContainerAnimating}`:``}${_.config.noBackground?` ${x.noBg}`:``}${_.config.noBorder?` ${x.noBorder}`:``}`,i=ui.state(),a=x.accentLine;return r!==n.e&&b(e,n.e=r),i!==n.t&&ne(e,`data-height-transition-state`,n.t=i),a!==n.a&&b(t,n.a=a),n},{e:void 0,t:void 0,a:void 0}),e})()}export{on as ReceiveComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{S as e,a as t,c as n,h as r,l as i,m as a,o,p as s,r as c,s as l,u,v as d,x as f}from"./solid-DqvEpdeb.js";import{o as p,r as m,s as h,t as g}from"./dist-CsBuWseE.js";import{t as _}from"./errors-DeB4WVzG.js";import{c as v,d as y,f as ee,g as b,h as x,l as S,m as te,o as C,s as w,t as T}from"./shared.module-Bs-BN_nM.js";import{_ as E,b as ne,c as re,g as ie,h as ae,l as oe,p as se,r as ce,s as le,x as ue}from"./rank-offers-4N4cmoQy.js";import{$ as de,A as fe,B as pe,C as me,D as he,E as ge,F as _e,G as ve,H as ye,I as be,J as xe,K as Se,L as Ce,M as we,N as Te,O as Ee,P as De,Q as Oe,R as ke,S as D,T as Ae,U as je,V as O,W as Me,X as Ne,Y as Pe,_ as Fe,_t as Ie,a as Le,at as Re,b as ze,c as Be,ct as Ve,d as He,dt as Ue,et as We,f as k,ft as Ge,gt as Ke,h as qe,ht as Je,i as A,it as Ye,j as Xe,k as Ze,l as Qe,lt as $e,m as et,mt as tt,n as nt,nt as rt,o as j,ot as it,p as at,pt as ot,q as st,r as ct,rt as lt,s as ut,st as dt,t as ft,tt as M,u as pt,ut as mt,vt as ht,w as gt,x as _t,y as vt,z as yt}from"./usePageRouter-BI7v3BwA.js";var bt={shell:`tf-25b7d0`,amount:`tf-59b76a`,muted:`tf-a859d8`},N=x(`<div data-testid=amount-input-shell><input type=number inputmode=decimal part=input>`);function xt(e){let{t}=ht(),[n,i]=d(e.value);s(f(()=>e.value,e=>{i(e)}));let a=t=>{let n=t.target.value;n=n.replace(/[^0-9.]/g,``);let r=n.indexOf(`.`);r!==-1&&(n=n.slice(0,r+1)+n.slice(r+1).replace(/\./g,``)),i(n),e.onChange(n)};return(()=>{var i=N(),o=i.firstChild;return C(o,`input`,a),r(n=>{var r=bt.shell,a=bt.amount,s=e.disabled,c=e.placeholder??t({id:`epw9f3`,message:`0`});return r!==n.e&&w(i,n.e=r),a!==n.t&&w(o,n.t=a),s!==n.a&&(o.disabled=n.a=s),c!==n.o&&y(o,`placeholder`,n.o=c),n},{e:void 0,t:void 0,a:void 0,o:void 0}),r(()=>o.value=n()),i})()}var P={selector:`tf-28b876`,header:`tf-2aa545`,titleRow:`tf-bcba74`,title:`tf-a974e8`,headerRight:`tf-14447c`,close:`tf-527e42`,divider:`tf-a5a3ce`,providerList:`tf-211bfe`,providerItem:`tf-fd33c1`,providerItemSelected:`tf-a0382b`,providerLeft:`tf-2aece4`,providerIcon:`tf-949870`,providerIconFallback:`tf-13e09e`,providerInfo:`tf-2387c4`,providerName:`tf-74069b`,bestBadge:`tf-113a28`,providerFee:`tf-69fe0b`,providerRight:`tf-cb2799`,cryptoAmount:`tf-d4ce76`,checkmark:`tf-b3b747`},F=x(`<div role=dialog part=provider-selector data-testid=provider-selector><div><div><span data-testid=provider-selector-title></span><div><button data-testid=provider-selector-close></button></div></div></div><div></div><div>`),St=x(`<img>`),Ct=x(`<span>`),wt=x(`<button type=button data-testid=provider-list-item><div><div><span></span><span>: </span></div></div><div><span>≈ <!> `),Tt=x(`<div>`);function Et(e){if(e.swapStrategy===`jump`&&e.routes?.length){let t=e.routes[0]?.estimatedOutputAmount;if(t)return t}return e.cryptoAmount}function Dt(e){let{t}=ht(),n=()=>je(e.fiatCurrency.toUpperCase()),i=t=>e.selectedProviderId?t===e.selectedProviderId:e.quotes.length>0&&e.quotes[0].provider===t,a=t=>{t.key===`Escape`&&e.onClose()};return(()=>{var s=F(),l=s.firstChild,f=l.firstChild,p=f.firstChild,m=p.nextSibling,h=m.firstChild,g=l.nextSibling,_=g.nextSibling;return C(s,`keydown`,a),v(p,()=>t({id:`118a77s`,message:`Select Fiat Provider`})),v(m,u(_e,{get secondsRemaining(){return e.countdownSeconds},get totalSeconds(){return e.totalCountdownSeconds},get onRefresh(){return e.onRefresh},get isRefreshing(){return e.isRefreshing}}),h),C(h,`click`,()=>e.onClose()),v(h,u(Ge,{size:18})),v(_,u(c,{get each(){return[...e.quotes]},children:(a,s)=>{let[c,l]=d(!1),f=()=>i(a.provider),p=()=>s()===0,m=()=>a.providerIcon?`${e.apiBase}${a.providerIcon}`:null;return(()=>{var i=wt(),s=i.firstChild,d=s.firstChild,h=d.firstChild,g=h.nextSibling,_=g.firstChild,ee=s.nextSibling,b=ee.firstChild,x=b.firstChild.nextSibling;return x.nextSibling,C(i,`click`,()=>e.onSelect(a.provider)),v(s,u(o,{get when(){return S(()=>!!m())()&&!c()},get fallback(){return(()=>{var e=Tt();return v(e,()=>(a.providerName??a.provider).charAt(0).toUpperCase()),r(()=>w(e,P.providerIconFallback)),e})()},get children(){var e=St();return C(e,`error`,()=>l(!0)),r(t=>{var n=P.providerIcon,r=m(),i=a.provider;return n!==t.e&&w(e,t.e=n),r!==t.t&&y(e,`src`,t.t=r),i!==t.a&&y(e,`alt`,t.a=i),t},{e:void 0,t:void 0,a:void 0}),e}}),d),v(h,()=>a.providerName??a.provider,null),v(h,u(o,{get when(){return p()},get children(){var e=Ct();return v(e,()=>t({id:`r7v9s7`,message:`BEST RATE`})),r(()=>w(e,P.bestBadge)),e}}),null),v(g,()=>t({id:`1viukn9`,message:`Total fee`}),_),v(g,n,null),v(g,()=>parseFloat(String(a.totalFee)).toFixed(2),null),v(b,()=>ae(E(Et(a),e.tokenDecimals),4),x),v(b,()=>e.targetSymbol,null),v(ee,u(o,{get when(){return f()},get children(){var e=Ct();return v(e,u(ot,{size:16})),r(()=>w(e,P.checkmark)),e}}),null),r(e=>{var t=`${P.providerItem}${f()?` ${P.providerItemSelected}`:``}`,n=P.providerLeft,r=P.providerInfo,a=P.providerName,o=P.providerFee,c=P.providerRight,l=P.cryptoAmount;return t!==e.e&&w(i,e.e=t),n!==e.t&&w(s,e.t=n),r!==e.a&&w(d,e.a=r),a!==e.o&&w(h,e.o=a),o!==e.i&&w(g,e.i=o),c!==e.n&&w(ee,e.n=c),l!==e.s&&w(b,e.s=l),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0}),i})()}})),r(e=>{var n=P.selector,r=t({id:`118a77s`,message:`Select Fiat Provider`}),i=P.header,a=P.titleRow,o=P.title,c=P.headerRight,u=P.close,d=t({id:`1l0xxoj`,message:`Close`}),v=P.divider,ee=P.providerList;return n!==e.e&&w(s,e.e=n),r!==e.t&&y(s,`aria-label`,e.t=r),i!==e.a&&w(l,e.a=i),a!==e.o&&w(f,e.o=a),o!==e.i&&w(p,e.i=o),c!==e.n&&w(m,e.n=c),u!==e.s&&w(h,e.s=u),d!==e.h&&y(h,`aria-label`,e.h=d),v!==e.r&&w(g,e.r=v),ee!==e.d&&w(_,e.d=ee),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0}),s})()}function Ot(e){let t=ct();return{trackingOrderId:t.trackingOrderId,trackingAddress:t.trackingAddress,trackingProviderName:t.trackingProviderName,trackingProviderIcon:t.trackingProviderIcon,executionError:t.executionError,failedExecPhase:t.failedExecPhase,handleConfirm:async()=>{t.setTrackingOrderId(null),t.setTrackingAddress(null),t.setExecutionError(null),t.setFailedExecPhase(null);let n=e.routes(),r=e.quoteId(),i=n.find(t=>t.routeId===e.selectedRouteId())??n[0];if(!i||!r||!e.client()||!e.walletAdapter())return;if(e.needRecipient()&&!e.recipient()){e.setError(`Recipient address is required for cross-chain swaps`),e.setErrorCode(_.INVALID_CONFIG);return}let a=le(e.fromToken().chainId),o=e.walletAddress();if(!o){e.setError(`Wallet not connected`),e.setErrorCode(_.WALLET_CONNECTION_FAILED);return}if(!oe(o,a)){e.setError(at`Wallet doesn't match source chain`),e.setErrorCode(_.INVALID_CONFIG);return}t.setTrackingProviderName(i.routeId??null);let s=e.apiEndpoint()??`https://api.hyperstream.dev`;t.setTrackingProviderIcon(i.icon?`${s}${i.icon}`:null),t.setTrackingAddress(o),e.setExecPhase(`building`);try{let n=await e.client().buildDeposit({from:o,quoteId:r,routeId:i.routeId});e.setExecPhase(`awaiting-wallet`);let a=await A(e.walletAdapter(),n,e.fromToken().chainId);e.setExecPhase(`submitting`);let s=await ut(e.client(),r,i.routeId,a);e.setExecPhase(`tracking`),t.setTrackingOrderId(s.orderId)}catch(n){let r=Le(n,e.callbacks(),`swap`);t.setExecutionError(r),t.setFailedExecPhase(e.execPhase())}},handleRetry:()=>{t.setTrackingOrderId(null),t.setTrackingAddress(null),e.setExecPhase(null)},handleNewSwap:()=>{e.storeReset(),j(t,e.client().baseUrl),e.onReset?.()}}}var I=x(`<button type=button data-testid=quote-error-close>`),L=x(`<button type=button part=button-primary data-testid=quote-error-retry>`),kt=x(`<section part=quote-error data-testid=quote-error-panel><div><span></span><div><button type=button data-testid=quote-error-copy></button></div></div><div data-testid=quote-error-message>`),At=x(`<div><div><span></span><span>`),jt=x(`<div data-height-transition-ignore=true><div role=dialog data-testid=quote-details-sheet part=quote-details-sheet><button type=button data-testid=quote-details-close></button><div>`),Mt=x(`<div data-height-transition-ignore=true>`),Nt=x(`<div part=container><div part=accent-line>`),Pt=x(`<button type=button part=back-button><span>`),Ft=x(`<img height=22>`),It=x(`<button part=wallet-info><div></div><span>`),Lt=x(`<div part=header><div><div data-testid=header-brand><span>`),Rt=x(`<div data-testid=swap-method-frame><div data-testid=powered-footer-slot>`),zt=x(`<span>Flight`),Bt=x(`<div><span>`),Vt=x(`<div><span></span><button type=button>`),Ht=x(`<span>`),Ut=x(`<div><div><div></div></div><span>`),Wt=x(`<div>`),Gt=x(`<div><div data-testid=fiat-amount-shell><span></span><input type=number inputmode=decimal placeholder=0 part=fiat-amount-input data-testid=fiat-amount-input>`),Kt=x(`<button type=button part=swap-arrow>`),qt=x(`<button part=recipient-badge><span>`),Jt=x(`<span part=amount-display style=cursor:default>`),Yt=x(`<button type=button data-testid=quote-details-trigger>`),Xt=x(`<div style=position:relative><div><div part=panel-from><div><span></span></div></div><div></div><div part=panel-to><div><span></span></div><div></div><div><span></span><div>`),Zt=x(`<div part=price-preview>`),Qt=x(`<div part=no-offer><span>`),$t=x(`<div><div style=width:32px;height:32px></div><span>`),en=x(`<div><div></div><span></span><span>`),tn=x(`<button part=button-primary type=button>`),nn=x(`<button disabled type=button><span><span>`),rn=x(`<button disabled type=button style=opacity:0.6>`),an=x(`<div part=cta-wrapper>`),on=x(`<button><span>`),sn=x(`<span> `),cn=x(`<div style=width:120px;height:28px>`),ln=x(`<div><div><div style=margin-bottom:0>`);function un(t,n){let[r,i]=d(!1);return s(f(t,t=>{if(!t)return;i(!1);let n=window.requestAnimationFrame(()=>i(!0));e(()=>window.cancelAnimationFrame(n))})),s(f(n,e=>{e||i(!1)})),r}function dn(t){let{t:n}=ht(),[i,a]=d(!1),s,c=()=>{t.onCopy(t.message),a(!0),s&&clearTimeout(s),s=setTimeout(()=>{a(!1),s=void 0},1200)};return e(()=>{s&&clearTimeout(s)}),(()=>{var e=kt(),a=e.firstChild,s=a.firstChild,l=s.nextSibling,d=l.firstChild,f=a.nextSibling;return v(s,u(Ve,{size:15}),null),v(s,()=>n({id:`jf8ts4`,message:`Quote Failed`}),null),C(d,`click`,c),v(d,u(o,{get when(){return i()},get fallback(){return u(dt,{size:13})},get children(){return u(ot,{size:13})}})),v(l,u(o,{get when(){return t.onClose},get children(){var e=I();return C(e,`click`,()=>t.onClose?.()),v(e,u(Ge,{size:14})),r(t=>{var r=D.quoteErrorIconButton,i=n({id:`1l0xxoj`,message:`Close`});return r!==t.e&&w(e,t.e=r),i!==t.t&&y(e,`aria-label`,t.t=i),t},{e:void 0,t:void 0}),e}}),null),v(f,()=>t.message),v(e,u(o,{get when(){return t.onRetry},get children(){var e=L();return C(e,`click`,()=>{t.onRetry?.()}),v(e,()=>n({id:`1w68n16`,message:`Try Again`})),r(()=>w(e,`${M.btnError} ${D.quoteErrorCta}`)),e}}),null),r(r=>{var o=`${D.quoteErrorPanel} ${D[`quoteErrorPanel--${t.variant}`]}`,c=D.quoteErrorHeader,u=D.quoteErrorTitle,p=D.quoteErrorActions,m=`${D.quoteErrorIconButton}${i()?` ${D.quoteErrorIconButtonCopied}`:``}`,h=i()?n({id:`13bzcw5`,message:`Copied`}):n({id:`2mzna2`,message:`Copy error`}),g=i()?`true`:`false`,_=D.quoteErrorMessage;return o!==r.e&&w(e,r.e=o),c!==r.t&&w(a,r.t=c),u!==r.a&&w(s,r.a=u),p!==r.o&&w(l,r.o=p),m!==r.i&&w(d,r.i=m),h!==r.n&&y(d,`aria-label`,r.n=h),g!==r.s&&y(d,`data-copied`,r.s=g),_!==r.h&&w(f,r.h=_),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0}),e})()}function R(e){return u(k,{get children(){return u(fn,e)}})}function fn(e){let{t:c}=ht(),x=ht(),oe=a(()=>e.config.methods??[`crypto`]),Le=a(()=>oe().includes(`crypto`)),Ve=a(()=>oe().includes(`card`)),k=a(()=>!!e.config.lockFromToken||!!e.config.defaultPayMethod),A=a(()=>!!e.config.lockToToken),{page:j,setPage:at,showBack:ot,backExiting:ct,handleBack:ut,onBackAnimEnd:dt}=ft({methods:oe,defaultPage:()=>e.config.defaultPayMethod,onBack:e.onBack}),[N,P]=d(`idle`),F=Se(),St=a(()=>!e.config.defaultPayMethod&&oe().length>1&&j()!==`entry`),Ct=a(()=>N()===`enter`?`enter`:N()===`exit`?`exit`:ot()?`pushed`:`idle`),wt=e=>{let t=j();if(t===e)return;let n=$.begin(),r=()=>F.runForwardImmediate(t,e,()=>{P(t===`entry`?`enter`:`idle`),at(e)});if(n){$.scheduleCommit(r);return}r()},Tt=()=>{if(ct())return;let e=St();if(e){let e=j(),t=$.begin();P(`exit`),ut();let n=()=>F.runBackImmediate(e,`entry`,()=>at(`entry`));if(t){$.scheduleCommit(n);return}n();return}P(e?`exit`:`idle`),ut()},Et=()=>{if(N()===`enter`){P(`idle`);return}N()===`exit`&&(P(`idle`),dt())},I=Fe(),[L,kt]=d(`from`),R=me(),fn=un(R.open,R.mounted),z=me(),pn=me(),B=me(),V=me(),[mn,hn]=d(null),[gn,_n]=d(!1),[H,vn]=d(e.config.fiatCurrency??`USD`),[yn,bn]=d(null),[xn,Sn]=d(null),[Cn,wn]=d(null),Tn=()=>{i(()=>{I.clearError(),bn(null)})},{isConnected:U,walletAddress:W,handleConnect:En}=He({walletAdapter:()=>e.walletAdapter,callbacks:()=>e.callbacks,onAddressChange:e=>I.setWalletAddress(e),onConnectError:(e,t)=>{i(()=>{bn(`wallet-connect`),I.setError(e),I.setErrorCode(t)})}});s(f(U,e=>{e&&yn()===`wallet-connect`&&Tn()}));let Dn=e=>{e instanceof HTMLElement&&hn(e)},On=()=>{window.setTimeout(()=>{let e=mn();e?.isConnected&&e.focus()},300)},kn=()=>{R.hide(),On()},An=(e,t)=>{if(e===`to`&&j()===`card`){Dn(t),kt(`to`),R.show();return}if(!U()){En();return}Dn(t),kt(e),R.show()},jn=e=>{if(e instanceof HTMLElement){e.blur();return}if(typeof document>`u`)return;let t=document.activeElement;if(!(t instanceof HTMLElement))return;let n=t.shadowRoot?.activeElement;if(n instanceof HTMLElement){n.blur();return}t.blur()},Mn=e=>{jn(e),z.show()},G=a(()=>new m({baseUrl:e.config.apiEndpoint??`https://api.hyperstream.dev`})),Nn=a(()=>new p({baseUrl:e.config.fiatApiEndpoint??`https://fiat.hyperstream.dev`})),K=()=>G().baseUrl,Pn=a(()=>e.config.fromTokens?.length?et(e.config.fromTokens):void 0),Fn=a(()=>e.config.toTokens?.length?et(e.config.toTokens):void 0),[In,Ln]=d([]),Rn=fe(G,()=>!0),zn=a(()=>{let e=Rn.data;return e?De(e):new Map}),{needRecipient:Bn,effectiveRecipient:Vn,recipientDisplay:Hn,handleRecipientChange:Un}=Qe({fromToken:I.fromToken,toToken:I.toToken,recipient:I.recipient,isConnected:U,walletAddress:W,walletAdapter:()=>e.walletAdapter,setRecipient:I.setRecipient}),Wn=Te(G,W,()=>U()&&!!W(),()=>e.walletAdapter?.supportedChainIds),Gn=a(()=>{let e=I.fromToken(),t=Wn.data;return!e||!t?null:ue(t,e)}),Kn=a(()=>{let e=Gn();return e?.extensions?.balance?se(ae(E(e.extensions.balance,e.decimals),2)):e?`0`:null}),qn=a(()=>{let e=I.fromToken();return!e||typeof e.decimals!=`number`||!Wn.data?null:Gn()?.extensions?.balance??`0`}),Jn=a(()=>{let e=I.inputAmount(),t=I.fromToken(),n=qn();if(!t||typeof t.decimals!=`number`||!n||!e||e===`0`||e===``)return!1;try{return BigInt(ie(e,t.decimals))>BigInt(n)}catch{return!1}}),[Yn,Xn,Zn]=Ze(``,300),q=a(()=>e.config.tradeType===`EXACT_OUTPUT`),Qn=a(()=>e.config.quoteCard??(q()?`visible`:`hidden`)),J=a(()=>!q()&&Qn()===`hidden`),$n=a(()=>e.lockRecipient===void 0?!!e.config.recipient&&e.config.recipientEditable!==!0:e.lockRecipient),er=a(()=>{if(j()!==`crypto`)return null;let t=I.fromToken(),n=I.toToken(),r=Vn();if(!t||typeof t.decimals!=`number`||!n||typeof n.decimals!=`number`||!G()||Bn())return null;if(q()){let i=e.config.amount;return!i||parseFloat(i)<=0?null:{tradeType:`EXACT_OUTPUT`,fromChainId:t.chainId,fromToken:t.address,toChainId:n.chainId,toToken:n.address,amount:ie(i,n.decimals),fromAddress:W()??re(t.chainId),...r&&{recipient:r},...e.config.refundTo&&{refundTo:e.config.refundTo},...e.config.referrer&&{referrer:e.config.referrer},...e.config.referrerFeeBps!==void 0&&{referrerFeeBps:e.config.referrerFeeBps}}}let i=Yn();return!i||parseFloat(i)<=0?null:{tradeType:`EXACT_INPUT`,fromChainId:t.chainId,fromToken:t.address,toChainId:n.chainId,toToken:n.address,amount:ie(i,t.decimals),fromAddress:W()??re(t.chainId),...r&&{recipient:r},...e.config.refundTo&&{refundTo:e.config.refundTo},...e.config.referrer&&{referrer:e.config.referrer},...e.config.referrerFeeBps!==void 0&&{referrerFeeBps:e.config.referrerFeeBps}}}),Y=we(G,er,a(()=>!!er()&&!I.execPhase()&&U()&&!!W())),X=a(()=>{if(!I.fromToken()||!I.toToken())return[];if(!q()){let e=I.inputAmount();if(!e||parseFloat(e)<=0)return[]}return Y.data?.routes??[]}),tr=a(()=>Y.data?.quoteId??null),nr=a(()=>X().length>0?ce(X()):null),rr=a(()=>{let e=X(),t=nr();return e.find(e=>e.routeId===t)??e[0]??null}),ir=a(()=>{let e=rr(),t=I.toToken();return!e||!t||typeof t.decimals!=`number`?``:ae(E(e.quote.amountOut,t.decimals))}),ar=a(()=>{if(!q())return null;let e=rr(),t=I.fromToken();return!e||!t||typeof t.decimals!=`number`?null:ae(E(e.quote.amountIn,t.decimals))}),Z=a(()=>vt(I.execPhase(),I.error(),Y.isFetching,X().length,!!er())),or=a(()=>I.execPhase()||!er()?!1:!Y.isFetching&&Y.isSuccess&&X().length===0),sr=a(()=>{let e=Z();return e===`quoted`||e===`building`||e===`awaiting-wallet`||e===`submitting`||e===`tracking`||e===`success`}),cr=a(()=>{let e=Z();return e===`building`||e===`awaiting-wallet`||e===`submitting`||e===`tracking`}),lr=a(()=>!I.fromToken()||!I.toToken()?!1:Z()===`quoting`&&!!er()&&X().length===0),ur=a(()=>{let e=I.fromToken();if(!e)return null;if(typeof e.priceUsd==`number`&&Number.isFinite(e.priceUsd))return e.priceUsd;let t=Number(Gn()?.extensions?.price?.usd??``);return Number.isFinite(t)?t:null}),dr=a(()=>{let e=I.toToken();return e&&typeof e.priceUsd==`number`&&Number.isFinite(e.priceUsd)?e.priceUsd:null}),fr=a(()=>{let e=q()?ar()??`0`:I.inputAmount(),t=Number(e),n=ur();return!Number.isFinite(t)||t<=0||n===null?null:c({id:`188897k`,message:"≈ ${formatUsd}"},{formatUsd:Ne(t*n)})}),{trackingOrderId:pr,trackingAddress:mr,trackingProviderName:hr,trackingProviderIcon:gr,executionError:_r,failedExecPhase:vr,handleConfirm:yr,handleRetry:br,handleNewSwap:xr}=Ot({client:G,walletAdapter:()=>e.walletAdapter,callbacks:()=>e.callbacks,apiEndpoint:()=>e.config.apiEndpoint,fromToken:I.fromToken,recipient:Vn,needRecipient:Bn,walletAddress:W,routes:X,quoteId:tr,selectedRouteId:nr,execPhase:I.execPhase,setExecPhase:I.setExecPhase,setError:e=>{bn(`validation`),I.setError(e)},setErrorCode:e=>{bn(`validation`),I.setErrorCode(e)},storeReset:I.reset,onReset:()=>Zn(``)});Be({client:G,walletAddress:W,trackingAddress:mr,trackingOrderId:pr,phase:Z,execPhase:I.execPhase,setOrder:I.setOrder,setExecPhase:I.setExecPhase,onOrderFilled:t=>e.callbacks?.onSwapSuccess?.({orderId:t.id,fromToken:I.fromToken().symbol??I.fromToken().address,toToken:I.toToken().symbol??I.toToken().address,fromAmount:t.srcAmount,toAmount:t.destAmount,txHash:t.depositTxHash??``}),onOrderFailed:t=>e.callbacks?.onSwapError?.({code:_.ORDER_FAILED,message:`Order `+t.status})});let{countdownSeconds:Sr}=pt({phase:Z,onExpired:()=>Y.refetch()});s(f(()=>({isError:Y.isError,error:Y.error,data:Y.data}),({isError:e,error:t,data:n})=>{I.execPhase()||j()!==`crypto`||(e&&!n?i(()=>{bn(`quote`),t instanceof h?(I.setError(t.message),I.setErrorCode(t.code)):(I.setError(String(t)),I.setErrorCode(null))}):yn()===`quote`&&I.error()&&!e&&Tn())}));let Cr=async()=>{let e=yn();if(Tn(),e===`quote`){await Y.refetch();return}if(e===`wallet-connect`){await En();return}e!==`validation`&&br()};s(f(()=>Y.data,t=>{t&&e.callbacks?.onQuoteReceived?.(t)}));let wr=a(()=>Vn()),Tr=a(()=>{if(!q()||!e.config.amount)return null;let t=I.toToken();return!t||typeof t.decimals!=`number`?null:ie(e.config.amount,t.decimals)}),Q=nt({client:Nn,targetToken:I.toToken,recipient:wr,fiatCurrency:()=>H(),callbacks:()=>e.callbacks,flowKind:`swap`,cryptoAmount:Tr,requireRecipient:!0}),Er=pt({phase:Q.phase,onExpired:()=>Q.refetchQuote(),intervalSeconds:30}),Dr=a(()=>!!I.toToken()&&(q()?!!e.config.amount:!!Q.fiatAmount())),Or=a(()=>j()===`card`&&!wr()&&Dr()),kr=a(()=>Hn()??(U()?W():null)),Ar=a(()=>!!kr()||Dr()),jr=a(()=>!!e.config.fiatCurrency),Mr=Xe(Nn,()=>!jr()),Nr=a(()=>{if(jr())return[];let e=Mr.data;if(!e?.providers?.length)return[];let t=new Set;for(let n of e.providers){let e=n.supportedCurrencies;if(Array.isArray(e))for(let n of e)typeof n==`string`?t.add(n):n&&typeof n.code==`string`&&t.add(n.code)}return[...t].sort()}),Pr=[`USD`,`EUR`,`GBP`,`JPY`,`KRW`,`CNY`,`AUD`,`CAD`,`INR`,`SGD`,`HKD`,`TWD`,`BRL`,`MXN`,`CHF`],Fr=a(()=>{let e=Nr();return e.length>0?e:Pr}),Ir=a(()=>je(H())||H()),Lr=()=>Q.quote()?.token?.decimals??I.toToken()?.decimals??18,Rr=e=>e?ae(E(e,Lr()),6):`0`,zr=a(()=>{let e=Q.quote(),t=parseFloat(Q.fiatAmount());return!e||!t?!1:!!(e.minFiatAmount&&t<parseFloat(String(e.minFiatAmount))||e.maxFiatAmount&&t>parseFloat(String(e.maxFiatAmount)))}),Br=a(()=>{let e=Q.phase();return e===`awaiting-payment`||e===`payment-handoff`||e===`tracking`}),Vr=a(()=>j()===`card`&&(Q.phase()===`awaiting-payment`||Q.phase()===`payment-handoff`)&&!!Q.directWidgetUrl()),Hr=a(()=>j()===`card`&&(Q.phase()===`awaiting-payment`||Q.phase()===`payment-handoff`)),Ur=a(()=>{if(j()!==`card`||Q.phase()!==`payment-handoff`)return null;let e=Q.orderId(),t=Q.directWidgetUrl();return e&&t?`${e}:${t}`:null}),Wr=a(()=>{let e=Q.quote();return e?.providerName??Pe(Q.orderStatus()?.provider??e?.provider??`Transak`)}),Gr=a(()=>Q.fiatAmount()||Q.orderStatus()?.fiatAmount||Q.quote()?.fiatAmount||``),Kr=()=>{Vr()&&(V.open()?V.hide():V.show())};s(()=>{if(!Vr()){Q.orderId()||wn(null),V.hide();return}let e=Ur();e&&Cn()!==e&&(wn(e),V.show())});let qr=a(()=>{let e=Q.phase();return e===`creating-order`||e===`quoting`}),Jr=a(()=>{let e=Q.phase();return e===`error`?c({id:`1w68n16`,message:`Try Again`})??`Try Again`:e===`creating-order`||e===`quoting`?c({id:`344av8`,message:`Processing...`}):e===`quoted`&&Q.quote()?c({id:`13l4n4r`,message:`Continue via {provider}`},{provider:Q.quote().providerName??Pe(Q.quote().provider)}):c({id:`119fv83`,message:`Enter amount`})}),Yr=a(()=>Q.phase()===`quoted`&&!!wr()&&!zr()&&!Q.isQuoteFetching()),Xr=()=>{let e=Q.phase();e===`error`?Q.handleRetry():e===`quoted`&&Yr()&&Q.createOrder()},Zr=a(()=>{if(q()&&e.config.amount)return e.config.amount;if(j()===`crypto`)return ir();let t=Q.quote();if(!t)return``;if(t.swapStrategy===`jump`){let e=t.routes?.[0]?.estimatedOutputAmount??t.estimatedOutputAmount;if(e)return ae(E(e,I.toToken()?.decimals??18),6)}return Rr(t.cryptoAmount)}),Qr=a(()=>q()&&e.config.amount?!0:j()===`crypto`?sr()||Z()===`quoting`:!!Q.quote()||Q.phase()===`quoting`),$r=a(()=>{let e=Number(Zr()||`0`),t=dr();return!Qr()||!Number.isFinite(e)||e<=0||t===null?null:c({id:`188897k`,message:"≈ ${formatUsd}"},{formatUsd:Ne(e*t)})}),ei=e=>{let t=zn().get(e.chainId);return{symbol:e.symbol??``,name:e.name??e.symbol??``,chain:t?.name??`Chain ${e.chainId}`,chainId:e.chainId,color:`#888`,balance:null,usd:``,address:e.address,decimals:e.decimals,logoURI:e.logoURI,priceUsd:e.priceUsd}},ti=async t=>{try{let n=qe(t),r=await ne(n.chainId,n.address,e.config.apiEndpoint,G());return typeof r.decimals==`number`?r:null}catch{return null}};s(f(()=>e.config.locale,e=>{e&&x.setLocale(e)})),s(f(()=>e.config.recipient,e=>{I.setRecipient(e??null)})),s(f(()=>e.config.fiatCurrency,e=>{e&&vn(e)})),s(f([()=>e.config.amount,q],([e,t])=>{let n=e??``;I.setInputAmount(n),Zn(t?``:n)}));let ni=0;s(f([()=>e.config.fromToken,()=>e.config.apiEndpoint],async([e])=>{let t=++ni;if(!e){I.setFromToken(null);return}let n=await ti(e);t===ni&&I.setFromToken(n)}));let ri=0;s(f([()=>e.config.toToken,()=>e.config.apiEndpoint],async([e])=>{let t=++ri;if(!e){I.setToToken(null);return}let n=await ti(e);t===ri&&I.setToToken(n)}));let ii=0;s(f([()=>e.config.toTokens,()=>e.config.apiEndpoint,zn],async([e])=>{let t=++ii;if(!e?.length){Ln([]);return}let n=await Promise.all(e.map(ti));t===ii&&Ln(n.filter(e=>!!e).map(ei))}));let ai=t=>{I.setInputAmount(t),e.callbacks?.onAmountChanged?.({amount:t,direction:`from`}),I.error()&&Tn(),Xn(t)},oi=e=>{Un(e),I.error()&&Tn()},si=e=>{let t={chainId:e.chainId,address:e.address??``,symbol:e.symbol,name:e.name,decimals:e.decimals,logoURI:e.logoURI,priceUsd:e.priceUsd};L()===`from`?I.setFromToken(t):I.setToToken(t),R.hide()},ci=()=>{if(cr()||!I.fromToken()||!I.toToken())return;let e=I.fromToken(),t=I.toToken();i(()=>{I.setFromToken(t),I.setToToken(e),I.execPhase()===`success`&&I.setExecPhase(null)})},li=()=>{let e=I.fromToken(),t=qn();if(!e||typeof e.decimals!=`number`||!t||t===`0`)return;let n=E(t,e.decimals);n&&n!==`0`&&ai(n)},ui=e=>`${e.slice(0,6)}...${e.slice(-4)}`,di=a(()=>{let e=rr();return!e||!I.fromToken()||!I.toToken()?null:Z()===`quoting`||sr()?e:null}),fi=a(()=>yn()===`quote`?I.error():null),pi=a(()=>Q.errorSource()===`quote`?Q.error():null),mi=a(()=>Q.phase()===`error`&&Q.errorSource()!==`quote`?Q.error():null),hi=e=>e===`crypto`?fi():e===`card`?pi():null,gi=e=>{let t=hi(e);return t?`${e}:${t}`:null},_i=a(()=>gi(j())),vi=e=>{let t=gi(e);return!!t&&t===xn()},yi=e=>!J()&&!!hi(e)&&!vi(e),bi=a(()=>!!di()&&!!I.fromToken()&&!!I.toToken()),xi=a(()=>!!Q.quote()),Si=e=>J()&&(e===`crypto`&&bi()||e===`card`&&xi()||!!hi(e)),Ci=e=>{typeof navigator>`u`||!navigator.clipboard||navigator.clipboard.writeText(e).catch(()=>void 0)},wi=()=>{let e=_i();e&&Sn(e),B.hide()},Ti=e=>{e.target===e.currentTarget&&wi()},Ei=e=>{e.key===`Escape`&&wi()};s(()=>{B.open()&&!Si(j())&&B.hide()}),s(()=>{let e=_i();if(!e){Sn(null);return}!J()||xn()===e||B.open()||B.show()});let Di=a(()=>{let t=e.config.titleText?.trim();return t&&t.length>0?t:`TokenFlight`}),Oi=a(()=>{let t=e.config.titleText?.trim();return!!t&&t.length>0}),ki=a(()=>{let t=e.config.titleImageUrl?.trim();return t&&t.length>0?t:null}),Ai=a(()=>j()===`card`&&(Br()||Q.phase()===`success`)),ji=a(()=>Z()===`success`&&I.order()?`success`:cr()?`tracking`:`form`),Mi,$=Me({container:()=>Mi,observeKey:()=>[ji(),j(),F.state(),F.transitionPages()?.incoming??``,F.transitionPages()?.outgoing??``,Ai(),Ai()?Q.phase():``,Vr()?`fiat-payment-link`:``,J(),e.config.hidePoweredBy].join(`|`)});return(()=>{var i=Nt(),a=i.firstChild;return b(e=>{Mi=e},i),v(i,u(o,{get when(){return Ai()},get children(){return u(n,{get children(){return[u(t,{get when(){return S(()=>Q.phase()===`success`)()&&Q.orderStatus()},get children(){return u(yt,{get orderStatus(){return Q.orderStatus()},get fiatAmount(){return Gr()},get fiatCurrency(){return H()},get targetToken(){return I.toToken()},get tokenDecimals(){return Q.tokenDecimals()},get provider(){return Q.orderStatus()?.provider??`transak`},get apiBase(){return K()},get chainMap(){return zn()},onNewPurchase:()=>Q.handleNewPurchase()})}}),u(t,{when:!0,get children(){return u(ye,{get phase(){return Q.phase()},get status(){return Q.orderStatus()?.status??`pending_payment`},get strategy(){return Q.strategy()??Q.orderStatus()?.swapStrategy??`direct`},get fiatAmount(){return Gr()},get fiatCurrency(){return H()},get cryptoAmount(){return Rr(Q.orderStatus()?.quotedCryptoAmount??Q.quote()?.cryptoAmount)},get targetToken(){return I.toToken()},get provider(){return Q.orderStatus()?.provider??Q.quote()?.provider??`transak`},get hideProvider(){return e.config.hideProvider},get transferTxHash(){return Q.orderStatus()?.fillTxHash??Q.orderStatus()?.transferTxHash},get failedReason(){return Q.orderStatus()?.failedReason??Q.orderStatus()?.errorReason},get apiBase(){return K()},get chainMap(){return zn()},get paymentLinkAvailable(){return Vr()},get paymentLinkOpen(){return V.open()},onPaymentLinkToggle:Kr,get cancelAvailable(){return Hr()},onCancelPayment:()=>Q.cancelPayment(),onNewPurchase:()=>Q.handleNewPurchase(),onRetry:()=>Q.handleRetry()})}})]}})}}),null),v(i,u(o,{get when(){return!Ai()},get children(){return u(st,{get current(){return ji()},views:{form:()=>[(()=>{var t=Lt(),n=t.firstChild,i=n.firstChild,a=i.firstChild;return v(n,u(o,{get when(){return ot()},get children(){var e=Pt(),t=e.firstChild;return C(e,`click`,Tt),C(t,`animationend`,N()===`idle`?void 0:Et),v(t,u(tt,{size:16})),r(n=>{var r=`${T.backButton} ${D.headerBackButton}${ct()?` ${T.backButtonExiting}`:``}`,i=c({id:`1hzmxtu`,message:`Back`}),a=N()===`enter`?`${D.headerBackArrow} ${D[`headerBackArrow--enter`]}`:N()===`exit`?`${D.headerBackArrow} ${D[`headerBackArrow--exit`]}`:D.headerBackArrow,o=N()===`idle`?{display:`inline-flex`}:void 0,s=N();return r!==n.e&&w(e,n.e=r),i!==n.t&&y(e,`aria-label`,n.t=i),a!==n.a&&w(t,n.a=a),n.o=te(t,o,n.o),s!==n.i&&y(t,`data-nav-animation`,n.i=s),n},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),i),v(i,u(o,{get when(){return ki()},get fallback(){return u(o,{get when(){return!e.config.hideTitle},get children(){return u(lt,{size:22})}})},get children(){var t=Ft();return r(n=>{var r=ki(),i=Di(),a=`${D.headerLogoImage} ${e.config.hideTitle?D[`headerLogoImage--solo`]:``}`;return r!==n.e&&y(t,`src`,n.e=r),i!==n.t&&y(t,`alt`,n.t=i),a!==n.a&&w(t,n.a=a),n},{e:void 0,t:void 0,a:void 0}),t}}),a),v(a,u(o,{get when(){return Oi()},get fallback(){return[`Token`,(()=>{var e=zt();return r(()=>w(e,D.headerTitleAccent)),e})()]},get children(){return Di()}})),v(t,u(o,{get when(){return S(()=>!!U())()&&W()},get children(){var t=It(),n=t.firstChild,i=n.nextSibling;return C(t,`click`,async()=>{e.walletAdapter?.openAccountModal?await e.walletAdapter.openAccountModal():e.callbacks?.onAccountModal?.()}),v(i,()=>ui(W())),r(e=>{var r=D.headerRight,a=c({id:`xphk5n`,message:`Wallet account`}),o=D.walletDot,s=D.walletAddress;return r!==e.e&&w(t,e.e=r),a!==e.t&&y(t,`aria-label`,e.t=a),o!==e.a&&w(n,e.a=o),s!==e.o&&w(i,e.o=s),e},{e:void 0,t:void 0,a:void 0,o:void 0}),t}}),null),r(r=>{var o=D.header,s=D.headerLeft,c=`${D.headerBrand} ${D[`headerBrand--${Ct()}`]}`,l=Ct(),u=`${D.headerTitle} ${e.config.hideTitle?D[`headerTitle--hidden`]:``}`;return o!==r.e&&w(t,r.e=o),s!==r.t&&w(n,r.t=s),c!==r.a&&w(i,r.a=c),l!==r.o&&y(i,`data-header-brand-state`,r.o=l),u!==r.i&&w(a,r.i=u),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),t})(),(()=>{var i=Rt(),a=i.firstChild;return v(i,u(ve,{get page(){return j()},get state(){return F.state()},get transitionPages(){return F.transitionPages()},renderPage:i=>u(n,{get children(){return[u(t,{when:i===`entry`,get children(){return[(()=>{var e=Bt(),t=e.firstChild;return v(t,()=>c({id:`cgzgvn`,message:`Pay with`})),r(()=>w(e,D.payWithLabel)),e})(),u(rt,{get hasCrypto(){return Le()},get hasCard(){return Ve()},showExchange:!0,onSelectCrypto:()=>wt(`crypto`),onSelectCard:()=>wt(`card`)})]}}),u(t,{when:i!==`entry`,get children(){return[(()=>{var a=Xt(),s=a.firstChild,l=s.firstChild,d=l.firstChild,f=d.firstChild,p=l.nextSibling,m=p.nextSibling,h=m.firstChild,_=h.firstChild,b=h.nextSibling,x=b.nextSibling,te=x.firstChild,E=te.nextSibling;return v(f,()=>Ie(`youPay`,c({id:`17kq51m`,message:`You pay`}))),v(d,u(o,{get when(){return S(()=>!!(i===`crypto`&&U()))()&&Kn()},get children(){var e=Vt(),t=e.firstChild,n=t.nextSibling;return v(t,()=>c({id:`y6jqu9`,message:`Balance: {fromBalance}`},{fromBalance:Kn()})),C(n,`click`,li),v(n,()=>c({id:`7v6g6x`,message:`MAX`})),r(r=>{var i=D.panelHeaderRight,a=D.panelBalance,o=D.maxBtn;return i!==r.e&&w(e,r.e=i),a!==r.t&&w(t,r.t=a),o!==r.a&&w(n,r.a=o),r},{e:void 0,t:void 0,a:void 0}),e}}),null),v(l,u(n,{get children(){return[u(t,{when:i===`crypto`,get children(){return[(()=>{var e=Wt();return v(e,u(xt,{get value(){return S(()=>!!q())()?ar()??`0`:I.inputAmount()},onChange:ai,get disabled(){return cr()||q()}}),null),v(e,u(o,{get when(){return I.fromToken()},get fallback(){return(()=>{var e=on(),t=e.firstChild;return C(e,`click`,e=>{k()||An(`from`,e.currentTarget)}),v(t,()=>c({id:`zz4mrw`,message:`Select token`})),v(e,u(o,{get when(){return!k()},get children(){var e=Ht();return v(e,u(Je,{size:14})),r(()=>w(e,D.caret)),e}}),null),r(n=>{var r=`${D.tokenBtn} ${D[`tokenBtn--select`]}`,i=D.tokenNameAccent;return r!==n.e&&w(e,n.e=r),i!==n.t&&w(t,n.t=i),n},{e:void 0,t:void 0}),e})()},get children(){var e=Ut(),t=e.firstChild,n=t.firstChild,i=t.nextSibling;return C(e,`click`,e=>{k()||An(`from`,e.currentTarget)}),v(t,u(it,{get symbol(){return I.fromToken().symbol??`?`},color:`#2775CA`,size:24,get logoURI(){return I.fromToken().logoURI}}),n),v(n,u(Ye,{size:10,get iconUrl(){return g(K(),I.fromToken().chainId)}})),v(i,()=>I.fromToken().symbol),v(e,u(o,{get when(){return!k()},get children(){var e=Ht();return v(e,u(Je,{size:14})),r(()=>w(e,D.caret)),e}}),null),r(r=>{var a=`${D.tokenBtn}${k()?` ${D[`tokenBtn--locked`]}`:``}`,o=k()?void 0:`button`,s=D.tokenIconWrap,c=D.tokenChainDot,l=D.tokenName;return a!==r.e&&w(e,r.e=a),o!==r.t&&y(e,`role`,r.t=o),s!==r.a&&w(t,r.a=s),c!==r.o&&w(n,r.o=c),l!==r.i&&w(i,r.i=l),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),r(()=>w(e,D.panelRow)),e})(),(()=>{var e=Bt(),t=e.firstChild;return v(t,()=>fr()??` `),r(n=>{var r=D.panelFooter,i=`${D.fiat} ${fr()?``:D[`fiat--hidden`]}`;return r!==n.e&&w(e,n.e=r),i!==n.t&&w(t,n.t=i),n},{e:void 0,t:void 0}),e})()]}}),u(t,{when:i===`card`,get children(){return[(()=>{var t=Gt(),n=t.firstChild,a=n.firstChild,o=a.nextSibling;return v(a,Ir),C(o,`input`,e=>!q()&&Q.setFiatAmount(e.target.value)),v(t,u(ze,{get currencies(){return Fr()},get selected(){return H()},onSelect:vn,get locked(){return jr()},get locale(){return e.config.locale},get compactSafe(){return i===`card`&&J()},onOpenChange:e=>_n(e&&i===`card`&&J())}),null),r(e=>{var r=D.panelRow,i=O.fiatAmountWrap,s=O.fiatCurrencyPrefix,c=O.fiatAmountInput,l=q();return r!==e.e&&w(t,e.e=r),i!==e.t&&w(n,e.t=i),s!==e.a&&w(a,e.a=s),c!==e.o&&w(o,e.o=c),l!==e.i&&(o.disabled=e.i=l),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),r(()=>o.value=q()?Q.quote()?.fiatAmount??`0`:Q.fiatAmount()),t})(),(()=>{var e=Wt();return v(e,u(o,{get when(){return Q.quote()},get fallback(){return(()=>{var e=sn();return r(()=>w(e,`${D.fiat} ${D[`fiat--hidden`]}`)),e})()},children:e=>(()=>{var t=Ht();return v(t,u(o,{get when(){return e().minFiatAmount},get children(){return[S(()=>c({id:`cx9lh3`,message:`Min`})),`: `,S(()=>Ir()),S(()=>e().minFiatAmount)]}}),null),v(t,u(o,{get when(){return S(()=>!!e().minFiatAmount)()&&e().maxFiatAmount},children:` · `}),null),v(t,u(o,{get when(){return e().maxFiatAmount},get children(){return[S(()=>c({id:`gtvgs9`,message:`Max`})),`: `,S(()=>Ir()),S(()=>e().maxFiatAmount)]}}),null),r(()=>w(t,`${O.fiatLimitsText}${zr()?` ${O.fiatLimitsError}`:``}`)),t})()})),r(()=>w(e,D.panelFooter)),e})()]}})]}}),null),v(p,u(o,{get when(){return S(()=>!e.hideSwapArrow&&i===`crypto`)()&&!A()},get children(){var e=Kt();return C(e,`click`,ci),v(e,u(Ke,{size:13})),r(t=>{var n=D.swapArrowCircle,r=c({id:`2eikro`,message:`Swap tokens`});return n!==t.e&&w(e,t.e=n),r!==t.t&&y(e,`aria-label`,t.t=r),t},{e:void 0,t:void 0}),e}})),v(_,()=>Ie(`youReceive`,c({id:`va18uh`,message:`You receive`}))),v(h,u(o,{get when(){return i===`card`?Ar():I.toToken()&&U()},get children(){var e=qt(),t=e.firstChild;return C(e,`click`,e=>!$n()&&Mn(e.currentTarget)),v(t,(()=>{var e=S(()=>!!(i===`card`?kr():Hn()));return()=>e()?ui(i===`card`?kr():Hn()):c({id:`fpand1`,message:`Enter destination address`})})()),v(e,u(o,{get when(){return!$n()},get children(){return u(Ue,{size:10})}}),null),r(n=>{var r=`${T.recipientBadge} ${(i===`card`?kr():Hn())?``:T.recipientBadgeEmpty}${$n()?` ${T.recipientBadgeLocked}`:``}`,a=$n(),o=T.recipientBadgeText;return r!==n.e&&w(e,n.e=r),a!==n.t&&(e.disabled=n.t=a),o!==n.a&&w(t,n.a=o),n},{e:void 0,t:void 0,a:void 0}),e}}),null),v(b,u(o,{get when(){return!(i===`crypto`?lr():Q.phase()===`quoting`)},get fallback(){return(()=>{var e=cn();return r(()=>w(e,T.skeleton)),e})()},get children(){var e=Jt();return v(e,u(de,{get value(){return Zr()||`0`},digits:8})),r(()=>w(e,`${bt.amount} ${Qr()?``:bt.muted}`)),e}}),null),v(b,u(o,{get when(){return I.toToken()},get fallback(){return(()=>{var e=on(),t=e.firstChild;return C(e,`click`,e=>{A()||An(`to`,e.currentTarget)}),v(t,()=>c({id:`zz4mrw`,message:`Select token`})),v(e,u(o,{get when(){return!A()},get children(){var e=Ht();return v(e,u(Je,{size:14})),r(()=>w(e,D.caret)),e}}),null),r(n=>{var r=`${D.tokenBtn} ${D[`tokenBtn--select`]}`,i=D.tokenNameAccent;return r!==n.e&&w(e,n.e=r),i!==n.t&&w(t,n.t=i),n},{e:void 0,t:void 0}),e})()},get children(){var e=Ut(),t=e.firstChild,n=t.firstChild,i=t.nextSibling;return C(e,`click`,e=>{A()||An(`to`,e.currentTarget)}),v(t,u(it,{get symbol(){return I.toToken().symbol??`?`},color:`#0052FF`,size:24,get logoURI(){return I.toToken().logoURI}}),n),v(n,u(Ye,{size:10,get iconUrl(){return g(K(),I.toToken().chainId)}})),v(i,()=>I.toToken().symbol),v(e,u(o,{get when(){return!A()},get children(){var e=Ht();return v(e,u(Je,{size:14})),r(()=>w(e,D.caret)),e}}),null),r(r=>{var a=`${D.tokenBtn}${A()?` ${D[`tokenBtn--locked`]}`:``}`,o=A()?void 0:`button`,s=D.tokenIconWrap,c=D.tokenChainDot,l=D.tokenName;return a!==r.e&&w(e,r.e=a),o!==r.t&&y(e,`role`,r.t=o),s!==r.a&&w(t,r.a=s),c!==r.o&&w(n,r.o=c),l!==r.i&&w(i,r.i=l),r},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),e}}),null),v(te,()=>$r()??` `),v(E,u(o,{get when(){return i===`crypto`&&Z()===`quoted`},get children(){return u(_e,{secondsRemaining:Sr,totalSeconds:30,onRefresh:()=>Y.refetch(),isRefreshing:()=>Y.isFetching})}}),null),v(E,u(o,{get when(){return i===`card`&&Q.phase()===`quoted`},get children(){return u(_e,{get secondsRemaining(){return Er.countdownSeconds},totalSeconds:30,onRefresh:()=>{Q.refetchQuote(),Er.resetCountdown()},get isRefreshing(){return Q.isQuoteFetching}})}}),null),v(E,u(o,{get when(){return Si(i)},get children(){var e=Yt();return C(e,`click`,()=>B.show()),v(e,u($e,{size:13})),r(t=>{var n=D.quoteDetailsTrigger,r=c({id:`tbygoy`,message:`View quote details`});return n!==t.e&&w(e,t.e=n),r!==t.t&&y(e,`aria-label`,t.t=r),t},{e:void 0,t:void 0}),e}}),null),r(e=>{var t=D.panelWrapper,n=gn()?`40`:void 0,r=D.mergedPanel,i=D.mergedSection,o=D.panelHeader,c=D.panelLabel,u=D.panelDivider,g=D.mergedSection,v=D.panelHeader,y=D.panelLabel,S=D.panelRow,C=D.panelFiatRow,T=`${D.fiat} ${$r()?``:D[`fiat--hidden`]}`,ne=D.quotePanelActions;return t!==e.e&&w(a,e.e=t),n!==e.t&&ee(a,`z-index`,e.t=n),r!==e.a&&w(s,e.a=r),i!==e.o&&w(l,e.o=i),o!==e.i&&w(d,e.i=o),c!==e.n&&w(f,e.n=c),u!==e.s&&w(p,e.s=u),g!==e.h&&w(m,e.h=g),v!==e.r&&w(h,e.r=v),y!==e.d&&w(_,e.d=y),S!==e.l&&w(b,e.l=S),C!==e.u&&w(x,e.u=C),T!==e.c&&w(te,e.c=T),ne!==e.w&&w(E,e.w=ne),e},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0,s:void 0,h:void 0,r:void 0,d:void 0,l:void 0,u:void 0,c:void 0,w:void 0}),a})(),u(n,{get children(){return[u(t,{when:i===`crypto`,get children(){return[u(o,{get when(){return S(()=>!!yi(i))()&&fi()},children:e=>u(dn,{get message(){return e()},variant:`crypto`,onCopy:Ci})}),u(o,{get when(){return S(()=>!J())()&&lr()},get children(){var e=Wt();return v(e,u(Ce,{})),r(()=>w(e,T.fadeIn)),e}}),u(o,{get when(){return S(()=>!!(!J()&&di()&&I.fromToken()))()&&I.toToken()},get children(){var e=Zt();return v(e,u(be,{get route(){return di()},get fromToken(){return I.fromToken()},get toToken(){return I.toToken()},inline:!0})),r(()=>w(e,ke.quote)),e}}),u(o,{get when(){return S(()=>!!or())()&&!lr()},get children(){var e=Qt(),t=e.firstChild;return v(t,()=>c({id:`ln9xiv`,message:`No routes available`})),r(n=>{var r=`${J()?D.compactQuoteStatus:D.noRoutesCard} ${T.fadeIn}`,i=T.noOfferText;return r!==n.e&&w(e,n.e=r),i!==n.t&&w(t,n.t=i),n},{e:void 0,t:void 0}),e}}),u(o,{get when(){return S(()=>!J()&&!fi()&&!lr()&&!di())()&&!or()},get children(){var e=$t(),t=e.firstChild,n=t.nextSibling;return v(t,u(Ke,{size:16})),v(n,()=>c({id:`1olegnl`,message:`Enter amount to get started`})),r(r=>{var i=`${O.quoteCardSlotCard} ${D.idleCardInline} ${T.fadeIn}`,a=T.idleIcon,o=T.idleTitle;return i!==r.e&&w(e,r.e=i),a!==r.t&&w(t,r.t=a),o!==r.a&&w(n,r.a=o),r},{e:void 0,t:void 0,a:void 0}),e}})]}}),u(t,{get when(){return S(()=>!!(Or()&&!pi()))()&&!J()},get children(){var e=en(),t=e.firstChild,n=t.nextSibling,i=n.nextSibling;return v(t,u(mt,{size:20})),v(n,()=>c({id:`fpand1`,message:`Enter destination address`})),v(i,()=>c({id:`19ne1ha`,message:`Connect wallet or enter an address to get a quote`})),r(r=>{var a=`${O.quoteCardSlotCard} ${D.recipientGateCard} ${T.fadeIn}`,o=T.idleIcon,s=T.idleTitle,c=T.idleSub;return a!==r.e&&w(e,r.e=a),o!==r.t&&w(t,r.t=o),s!==r.a&&w(n,r.a=s),c!==r.o&&w(i,r.o=c),r},{e:void 0,t:void 0,a:void 0,o:void 0}),e}}),u(t,{get when(){return S(()=>!!(i===`card`&&yi(i)))()&&pi()},children:e=>u(dn,{get message(){return e()},variant:`card`,onCopy:Ci})}),u(t,{get when(){return S(()=>i===`card`&&Q.phase()!==`error`)()&&!J()},get children(){return u(_t,{fiatCheckout:Q,fiatCountdown:Er,get targetToken(){return I.toToken()??null},get fiatCurrency(){return H()},get apiBase(){return K()},get showPayAmount(){return q()},hideCountdown:!0,onCompareProviders:()=>pn.show()})}})]}}),u(o,{get when(){return i===`card`&&mi()},children:e=>(()=>{var t=ln(),n=t.firstChild,i=n.firstChild;return v(i,e),r(e=>{var r=O.errorSlot,a=O.errorArea,o=O.errorText;return r!==e.e&&w(t,e.e=r),a!==e.t&&w(n,e.t=a),o!==e.a&&w(i,e.a=o),e},{e:void 0,t:void 0,a:void 0}),t})()}),(()=>{var e=an();return v(e,u(n,{get children(){return[u(t,{when:i===`crypto`,get children(){return u(We,{get phase(){return Z()},get isConnected(){return U()},get hasQuote(){return sr()},onConnect:En,onConfirm:yr,onRetry:Cr,get errorLabel(){return S(()=>yn()===`quote`)()?c({id:`1w68n16`,message:`Try Again`}):I.error()??void 0},get needsRecipient(){return Bn()},onEnterRecipient:()=>Mn(),get insufficientBalance(){return Jn()}})}}),u(t,{when:i===`card`,get children(){return u(n,{get children(){return[u(t,{get when(){return Q.phase()===`error`},get children(){var e=tn();return C(e,`click`,Xr),v(e,Jr),r(()=>w(e,M.btnError)),e}}),u(t,{get when(){return qr()},get children(){var e=nn(),t=e.firstChild,n=t.firstChild;return v(t,Jr,null),r(r=>{var i=`${M.btnPrimary} ${M.executing}`,a=M.btnInner,o=M.spinner;return i!==r.e&&w(e,r.e=i),a!==r.t&&w(t,r.t=a),o!==r.a&&w(n,r.a=o),r},{e:void 0,t:void 0,a:void 0}),e}}),u(t,{get when(){return S(()=>!I.toToken())()&&(!!Q.fiatAmount()||q())},get children(){var e=tn();return C(e,`click`,e=>{Dn(e.currentTarget),kt(`to`),R.show()}),v(e,()=>c({id:`zz4mrw`,message:`Select token`})),r(()=>w(e,M.btnRecipient)),e}}),u(t,{get when(){return Or()},get children(){var e=tn();return C(e,`click`,e=>Mn(e.currentTarget)),v(e,()=>c({id:`wx5bee`,message:`Enter Recipient Address`})),r(()=>w(e,M.btnRecipient)),e}}),u(t,{get when(){return Yr()},get children(){var e=tn();return C(e,`click`,Xr),v(e,Jr),r(()=>w(e,M.btnPrimary)),e}}),u(t,{when:!0,get children(){var e=rn();return v(e,Jr),r(()=>w(e,M.btnPrimary)),e}})]}})}})]}})),r(()=>w(e,T.ctaWrapper)),e})()]}})]}})}),a),v(a,u(o,{get when(){return!e.config.hidePoweredBy},get children(){return u(Re,{})}})),r(t=>{var n=`${D.methodFrame}${J()?` ${D[`methodFrame--compact`]}`:``}${e.config.hidePoweredBy?` ${D[`methodFrame--footerHidden`]}`:``}`,r=J()?`hidden`:`visible`,o=e.config.hidePoweredBy?`hidden`:`visible`,s=`${T.footerSlot} ${D.methodFooterSlot}`,c=e.config.hidePoweredBy?`true`:`false`;return n!==t.e&&w(i,t.e=n),r!==t.t&&y(i,`data-quote-card-frame`,t.t=r),o!==t.a&&y(i,`data-powered-footer-frame`,t.a=o),s!==t.o&&w(a,t.o=s),c!==t.i&&y(a,`data-powered-footer-hidden`,t.i=c),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),i})()],tracking:()=>u(Oe,{get order(){return I.order()},get fromToken(){return I.fromToken()},get toToken(){return I.toToken()},get providerName(){return hr()},get providerIcon(){return gr()},get hideProvider(){return e.config.hideProvider},get apiEndpoint(){return e.config.apiEndpoint??`https://api.hyperstream.dev`},get inputAmount(){return I.inputAmount()},get outputAmount(){return ir()},onNewSwap:xr,onRetry:br,get executionError(){return _r()},mode:`swap`,get phase(){return Z()},get failedPhase(){return vr()},get chainMap(){return zn()}}),success:()=>u(xe,{get order(){return I.order()},get fromToken(){return I.fromToken()},get toToken(){return I.toToken()},onNewSwap:xr,get apiEndpoint(){return e.config.apiEndpoint??`https://api.hyperstream.dev`},get providerName(){return hr()},mode:`swap`,get chainMap(){return zn()}})}})}}),null),v(i,u(o,{get when(){return S(()=>!!V.mounted())()&&Q.directWidgetUrl()},get children(){return u(pe,{get url(){return Q.directWidgetUrl()},get provider(){return Wr()},get dismissing(){return V.dismissing()},onClose:()=>V.hide()})}}),null),v(i,u(o,{get when(){return R.mounted()},get children(){return u(Ee,{get selectingFor(){return L()},onClose:kn,get noBorder(){return e.config.noBorder},get dismissing(){return R.dismissing()},get children(){return u(o,{get when(){return fn()},get fallback(){return u(he,{get selectingFor(){return L()},onClose:kn})},get children(){return u(l,{get fallback(){return u(he,{get selectingFor(){return L()},onClose:kn})},get children(){return u(ge,{get client(){return G()},get walletAddress(){return W()},get selectingFor(){return L()},onSelect:si,onClose:kn,get supportedChainIds(){return e.walletAdapter?.supportedChainIds},get allowedTokens(){return S(()=>L()===`from`)()?Pn():Fn()},get tokens(){return S(()=>!!(L()===`to`&&In().length))()?In():void 0},get noBorder(){return e.config.noBorder},get dismissing(){return R.dismissing()}})}})}})}})}}),null),v(i,u(o,{get when(){return S(()=>!!z.mounted())()&&I.toToken()},get children(){return u(Ae,{onClose:()=>z.hide(),get dismissing(){return z.dismissing()},get children(){return u(gt,{get initialValue(){return I.recipient()??Vn()??``},get chainType(){return le(I.toToken().chainId)},onConfirm:e=>{oi(e),z.hide()},onClose:()=>z.hide(),get dismissing(){return z.dismissing()}})}})}}),null),v(i,u(o,{get when(){return B.mounted()},get children(){var e=jt(),i=e.firstChild,a=i.firstChild,o=a.nextSibling;return C(e,`keydown`,Ei),C(e,`click`,Ti),C(a,`click`,wi),v(a,u(Ge,{size:17})),v(o,u(n,{get children(){return[u(t,{get when(){return hi(j())},children:e=>u(dn,{get message(){return e()},variant:`sheet`,onCopy:Ci,get onRetry(){return S(()=>j()===`card`)()?Q.handleRetry:Cr}})}),u(t,{get when(){return S(()=>!!(j()===`crypto`&&di()&&I.fromToken()))()&&I.toToken()},get children(){var e=At(),t=e.firstChild,n=t.firstChild,i=n.nextSibling;return v(n,()=>c({id:`1nvxkfy`,message:`Route`})),v(i,()=>di().routeId),v(e,u(be,{get route(){return di()},get fromToken(){return I.fromToken()},get toToken(){return I.toToken()},inline:!0}),null),r(n=>{var r=D.quoteDetailsCard,a=D.quoteDetailsMetaRow,o=D.quoteDetailsMetaValue;return r!==n.e&&w(e,n.e=r),a!==n.t&&w(t,n.t=a),o!==n.a&&w(i,n.a=o),n},{e:void 0,t:void 0,a:void 0}),e}}),u(t,{get when(){return S(()=>j()===`card`)()&&Q.quote()},get children(){return u(_t,{fiatCheckout:Q,fiatCountdown:Er,get targetToken(){return I.toToken()??null},get fiatCurrency(){return H()},get apiBase(){return K()},get showPayAmount(){return q()},hideCountdown:!0,margin:`0`,height:`auto`,onCompareProviders:()=>pn.show()})}})]}})),r(t=>{var n=`${T.selectorOverlay}${B.dismissing()?` ${T.selectorOverlayDismissing}`:``}`,r=`${D.quoteDetailsSheet}${B.dismissing()?` ${D[`quoteDetailsSheet--dismissing`]}`:``}`,s=c({id:`1tn6f91`,message:`Quote details`}),l=D.quoteDetailsClose,u=c({id:`1l0xxoj`,message:`Close`}),d=D.quoteDetailsBody;return n!==t.e&&w(e,t.e=n),r!==t.t&&w(i,t.t=r),s!==t.a&&y(i,`aria-label`,t.a=s),l!==t.o&&w(a,t.o=l),u!==t.i&&y(a,`aria-label`,t.i=u),d!==t.n&&w(o,t.n=d),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0,n:void 0}),e}}),null),v(i,u(o,{get when(){return pn.mounted()},get children(){var e=Mt();return v(e,u(Dt,{get quotes(){return Q.allQuotes()},get selectedProviderId(){return Q.selectedProviderId()},get fiatCurrency(){return H()},get apiBase(){return K()},get tokenDecimals(){return Lr()},get targetSymbol(){return I.toToken()?.symbol??``},get countdownSeconds(){return Er.countdownSeconds},totalCountdownSeconds:30,onRefresh:()=>{Q.refetchQuote(),Er.resetCountdown()},get isRefreshing(){return Q.isQuoteFetching},onSelect:e=>{Q.setSelectedProvider(e),pn.hide()},onClose:()=>pn.hide()})),r(()=>w(e,`${T.selectorOverlay}${pn.dismissing()?` ${T.selectorOverlayDismissing}`:``}`)),e}}),null),r(t=>{var n=`${T.container}${J()?` ${D.quoteCardHiddenContainer}`:``}${$.state()===`animating`?` ${D.swapContainerAnimating}`:``}${e.config.noBackground?` ${T.noBg}`:``}${e.config.noBorder?` ${T.noBorder}`:``}`,r=$.state(),o=$.state(),s=J()?`hidden`:`visible`,c=T.accentLine;return n!==t.e&&w(i,t.e=n),r!==t.t&&y(i,`data-swap-container-transition`,t.t=r),o!==t.a&&y(i,`data-height-transition-state`,t.a=o),s!==t.o&&y(i,`data-quote-card`,t.o=s),c!==t.i&&w(a,t.i=c),t},{e:void 0,t:void 0,a:void 0,o:void 0,i:void 0}),i})()}export{R as SwapComponent};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./dist-CsBuWseE.js";import{a as e,n as t,o as n,s as r}from"./protocol-B7S8LSlJ.js";var i,a=`https://embed.tokenflight.ai/widget`,o=15e3,s=500;function c(e){return{...e,noBackground:!0,noBorder:!0}}var l=class i{constructor(t){if(this.listeners=new Map,this.ready=!1,this.destroyed=!1,this.readyTimer=null,this.popup=null,this.popupPollTimer=null,this.popupOrderId=null,this.popupMessageHandler=null,this.handleMessage=t=>{if(this.destroyed||t.origin!==this.widgetOrigin||t.source!==this.iframe.contentWindow)return;let r=n(t.data);r&&(e(r,`tf:ready`)?this.handleReady(r.payload.version,r.payload.protocolVersion):e(r,`tf:signRequest`)?this.handleSignRequest(r.payload.requestId,r.payload.action,r.payload.timeoutMs):e(r,`tf:connectWallet`)?this.handleConnectWallet(r.payload.chainType):e(r,`tf:disconnectWallet`)?this.handleDisconnectWallet():e(r,`tf:event`)?this.handleWidgetEvent(r.payload.name,r.payload.data):e(r,`tf:resize`)?this.handleResize(r.payload.height):e(r,`tf:preOpenPopup`)?this.handlePreOpenPopup():e(r,`tf:navigatePopup`)?this.navigatePopup(r.payload.url,r.payload.orderId):e(r,`tf:closeFiatPopup`)&&this.handleCloseFiatPopup(r.payload.orderId))},this.options=t,this.wallet=t.wallet,typeof t.container==`string`){let e=document.querySelector(t.container);if(!e&&!t.iframe)throw Error(`TokenFlightBridge: container "${t.container}" not found`);this.container=e??document.body}else this.container=t.container;let r=t.iframeSrc??a,i=typeof window<`u`?window.location.href:void 0;this.widgetOrigin=new URL(r,i).origin,t.iframe?(this.iframe=t.iframe,this.ownsIframe=!1,this.iframe.getAttribute(`src`)!==r&&(this.iframe.src=r)):(this.iframe=document.createElement(`iframe`),this.ownsIframe=!0,this.iframe.src=r,this.iframe.style.display=`block`,this.iframe.style.width=`100%`,this.iframe.style.height=`660px`,this.iframe.style.minWidth=`375px`,this.iframe.style.colorScheme=`normal`,this.iframe.style.border=`0`,this.iframe.style.background=`transparent`,this.iframe.setAttribute(`allow`,`camera;microphone;payment;clipboard-write`),this.iframe.setAttribute(`title`,`TokenFlight Widget`),this.container.appendChild(this.iframe)),window.addEventListener(`message`,this.handleMessage),this.walletHandler=e=>{this.sendWalletState(e.type)},this.subscribeWalletEvents();let s=t.readyTimeout??o;this.readyTimer=setTimeout(()=>{!this.ready&&!this.destroyed&&t.onLoadError?.(Error(`TokenFlightBridge: widget did not send tf:ready within timeout`))},s)}setConfig(e){this.postToIframe(t(`setConfig`,c(e)))}setStyle(e){this.postToIframe(t(`setStyle`,e))}setWallet(e){this.unsubscribeWalletEvents(),this.wallet=e,this.subscribeWalletEvents(),this.sendWalletState()}on(e,t){let n=this.listeners.get(e);n||(n=new Set,this.listeners.set(e,n)),n.add(t)}off(e,t){this.listeners.get(e)?.delete(t)}destroy(){this.destroyed||(this.destroyed=!0,this.readyTimer&&(clearTimeout(this.readyTimer),this.readyTimer=null),window.removeEventListener(`message`,this.handleMessage),this.unsubscribeWalletEvents(),this.closePopup(),this.ownsIframe&&this.iframe.remove(),this.listeners.clear())}async handleReady(e,n){if(n!==1){this.options.onLoadError?.(Error(`TokenFlightBridge: protocol version mismatch (bridge=1, widget=${n})`));return}this.ready=!0,this.readyTimer&&(clearTimeout(this.readyTimer),this.readyTimer=null);let r=this.wallet?.isConnected()??!1,i=null;if(r&&this.wallet)try{i=await this.wallet.getAddress()}catch{}this.postToIframe(t(`init`,{config:c(this.options.config),style:this.options.style,walletAddress:i,connected:r})),this.options.onReady?.(e),this.emit(`ready`,{version:e})}async handleSignRequest(e,n,i){if(!this.wallet){this.postToIframe(t(`signResult`,{requestId:e,error:{code:`ADAPTER_ERROR`,message:`No wallet adapter configured`}}));return}try{let r=await this.wallet.executeWalletAction(n);this.postToIframe(t(`signResult`,{requestId:e,result:r}))}catch(n){this.postToIframe(t(`signResult`,{requestId:e,error:r(n)}))}}async handleConnectWallet(e){if(this.wallet)try{await this.wallet.connect(e)}catch{}}async handleDisconnectWallet(){if(this.wallet)try{await this.wallet.disconnect()}catch{}}handleWidgetEvent(e,t){let n=u[e];n&&this.emit(n,t)}handleResize(e){this.iframe.style.height=`${e}px`,this.emit(`resize`,{height:e})}handlePreOpenPopup(){this.closePopup(),this.popup=window.open(`about:blank`,`tf-payment`,`width=500,height=700`)}navigatePopup(e,n){if(!this.popup||this.popup.closed){this.postToIframe(t(`fiatPopupBlocked`,{orderId:n}));return}try{let r=new URL(e);if(r.protocol!==`https:`&&r.protocol!==`http:`){this.postToIframe(t(`fiatPopupBlocked`,{orderId:n}));return}}catch{this.postToIframe(t(`fiatPopupBlocked`,{orderId:n}));return}this.popup.location.href=e,this.popupOrderId=n,this.installPopupMessageHandler(),this.popupPollTimer=setInterval(()=>{this.popup?.closed&&(this.closePopup(),this.postToIframe(t(`fiatPopupClosed`,{orderId:this.popupOrderId??n})),this.popupOrderId=null)},s)}installPopupMessageHandler(){if(this.popupMessageHandler)return;let e,n=this.options.config.fiatApiEndpoint??`https://fiat.hyperstream.dev`;try{e=new URL(n).origin}catch{return}let r=new Set([`widget_ready`,`order_completed`,`order_failed`,`widget_close`]);this.popupMessageHandler=n=>{if(this.destroyed||n.origin!==e)return;let i=n.data;if(!i||i.type!==`FIAT_WIDGET_EVENT`||typeof i.event!=`string`||!r.has(i.event))return;let a=this.popupOrderId;a&&(typeof i.orderId==`string`&&i.orderId!==a||this.postToIframe(t(`fiatProviderEvent`,{orderId:a,event:i.event,provider:typeof i.provider==`string`?i.provider:void 0,data:i.data??void 0})))},window.addEventListener(`message`,this.popupMessageHandler)}closePopup(){this.popupPollTimer&&(clearInterval(this.popupPollTimer),this.popupPollTimer=null),this.popupMessageHandler&&(window.removeEventListener(`message`,this.popupMessageHandler),this.popupMessageHandler=null),this.popup&&!this.popup.closed&&this.popup.close(),this.popup=null}handleCloseFiatPopup(e){if(e===null){if(this.popupOrderId)return;this.closePopup();return}this.popupOrderId&&this.popupOrderId!==e||(this.closePopup(),this.popupOrderId=null)}subscribeWalletEvents(){if(this.wallet)for(let e of i.WALLET_EVENTS)this.wallet.on(e,this.walletHandler)}unsubscribeWalletEvents(){if(this.wallet)for(let e of i.WALLET_EVENTS)this.wallet.off(e,this.walletHandler)}async sendWalletState(e){if(!this.wallet)return;let n=this.wallet.isConnected(),r=null;if(n)try{r=await this.wallet.getAddress()}catch{}this.postToIframe(t(`walletState`,{connected:n,address:r,event:e}))}postToIframe(e){this.destroyed||this.iframe.contentWindow?.postMessage(e,this.widgetOrigin)}emit(e,t){let n=this.listeners.get(e);if(n)for(let e of n)try{e(t)}catch{}}};i=l,i.WALLET_EVENTS=[`connect`,`disconnect`,`chainChanged`,`accountsChanged`];var u={swapComplete:`swapComplete`,error:`error`,fiatOrderCreated:`fiatOrderCreated`,fiatOrderCompleted:`fiatOrderCompleted`};function d(e){return new l(e)}export{d as n,l as t};
|
package/dist/bridge.d.ts
CHANGED
|
@@ -145,6 +145,8 @@ declare interface FiatIframeBridge {
|
|
|
145
145
|
requestPreOpenPopup: () => void;
|
|
146
146
|
/** Ask the host to navigate the pre-opened popup to the wrapper URL. */
|
|
147
147
|
requestNavigatePopup: (url: string, orderId: string) => void;
|
|
148
|
+
/** Ask the host to close the active fiat popup for this order, or the unbound pre-opened popup. */
|
|
149
|
+
requestClosePopup: (orderId: string | null) => void;
|
|
148
150
|
/**
|
|
149
151
|
* Subscribe to popup-closed notifications forwarded from the host bridge.
|
|
150
152
|
* Returns an unsubscribe function. The handler receives the orderId the host
|
|
@@ -152,6 +154,12 @@ declare interface FiatIframeBridge {
|
|
|
152
154
|
* against the current `orderId()` signal.
|
|
153
155
|
*/
|
|
154
156
|
onPopupClosed: (handler: (closedOrderId: string) => void) => () => void;
|
|
157
|
+
/**
|
|
158
|
+
* Subscribe to popup-blocked notifications forwarded from the host bridge.
|
|
159
|
+
* Blocked means the payment popup never opened, so checkout should show the
|
|
160
|
+
* manual payment handoff instead of treating it as user cancel.
|
|
161
|
+
*/
|
|
162
|
+
onPopupBlocked: (handler: (blockedOrderId: string) => void) => () => void;
|
|
155
163
|
/**
|
|
156
164
|
* Subscribe to provider terminal events forwarded from the host bridge.
|
|
157
165
|
* Returns an unsubscribe function. The host installs its own
|
|
@@ -185,7 +193,7 @@ declare interface ForwardedFiatProviderEvent {
|
|
|
185
193
|
export declare function getHostOrigin(): string | null;
|
|
186
194
|
|
|
187
195
|
/** Union of all Host → iframe messages. */
|
|
188
|
-
export declare type HostToIframeMessage = TfInitMessage | TfSetConfigMessage | TfSetStyleMessage | TfWalletStateMessage | TfSignResultMessage | TfFiatPopupClosedMessage | TfFiatProviderEventMessage;
|
|
196
|
+
export declare type HostToIframeMessage = TfInitMessage | TfSetConfigMessage | TfSetStyleMessage | TfWalletStateMessage | TfSignResultMessage | TfFiatPopupClosedMessage | TfFiatPopupBlockedMessage | TfFiatProviderEventMessage;
|
|
189
197
|
|
|
190
198
|
/**
|
|
191
199
|
* Wallet adapter that runs inside the widget iframe and proxies all
|
|
@@ -238,6 +246,8 @@ export declare class IframeReceiver {
|
|
|
238
246
|
private lastReportedHeight;
|
|
239
247
|
/** Subscribers to forwarded popup-closed events (set by useFiatCheckout in bridge mode). */
|
|
240
248
|
private readonly popupClosedHandlers;
|
|
249
|
+
/** Subscribers to forwarded popup-blocked events (set by useFiatCheckout in bridge mode). */
|
|
250
|
+
private readonly popupBlockedHandlers;
|
|
241
251
|
/** Subscribers to forwarded provider terminal events (also useFiatCheckout). */
|
|
242
252
|
private readonly providerEventHandlers;
|
|
243
253
|
constructor(hostOrigin: string, callbacks: IframeReceiverCallbacks);
|
|
@@ -254,6 +264,8 @@ export declare class IframeReceiver {
|
|
|
254
264
|
requestPreOpenPopup(): void;
|
|
255
265
|
/** Request the host to navigate the popup to a URL (fiat flow). */
|
|
256
266
|
requestNavigatePopup(url: string, orderId: string): void;
|
|
267
|
+
/** Request the host to close the active fiat popup for an order. */
|
|
268
|
+
requestClosePopup(orderId: string | null): void;
|
|
257
269
|
/** Clean up all listeners and observers. */
|
|
258
270
|
destroy(): void;
|
|
259
271
|
private handleMessage;
|
|
@@ -270,6 +282,8 @@ export declare interface IframeReceiverCallbacks {
|
|
|
270
282
|
onStyleUpdate: (style: StyleOverrides) => void;
|
|
271
283
|
/** Called on tf:fiatPopupClosed — used by fiat checkout in iframe mode. */
|
|
272
284
|
onFiatPopupClosed?: (orderId: string) => void;
|
|
285
|
+
/** Called on tf:fiatPopupBlocked — used by fiat checkout fallback in iframe mode. */
|
|
286
|
+
onFiatPopupBlocked?: (orderId: string) => void;
|
|
273
287
|
/**
|
|
274
288
|
* Called on tf:fiatProviderEvent — host bridge forwards a provider terminal
|
|
275
289
|
* event from the popup wrapper page so the widget can drive `paymentOutcome`.
|
|
@@ -278,7 +292,7 @@ export declare interface IframeReceiverCallbacks {
|
|
|
278
292
|
}
|
|
279
293
|
|
|
280
294
|
/** Union of all iframe → Host messages. */
|
|
281
|
-
export declare type IframeToHostMessage = TfReadyMessage | TfSignRequestMessage | TfConnectWalletMessage | TfDisconnectWalletMessage | TfEventMessage | TfResizeMessage | TfPreOpenPopupMessage | TfNavigatePopupMessage;
|
|
295
|
+
export declare type IframeToHostMessage = TfReadyMessage | TfSignRequestMessage | TfConnectWalletMessage | TfDisconnectWalletMessage | TfEventMessage | TfResizeMessage | TfPreOpenPopupMessage | TfNavigatePopupMessage | TfCloseFiatPopupMessage;
|
|
282
296
|
|
|
283
297
|
/** Check if the current window is running inside an iframe. */
|
|
284
298
|
export declare function isIframeMode(): boolean;
|
|
@@ -388,6 +402,11 @@ export declare const TF_PROTOCOL_VERSION = 1;
|
|
|
388
402
|
/** Union of all bridge messages (both directions). */
|
|
389
403
|
export declare type TfBridgeMessage = HostToIframeMessage | IframeToHostMessage;
|
|
390
404
|
|
|
405
|
+
/** Request host to close the active fiat payment popup for this order, or the unbound pre-opened popup. */
|
|
406
|
+
declare type TfCloseFiatPopupMessage = TfMessageEnvelope<"closeFiatPopup", {
|
|
407
|
+
orderId: string | null;
|
|
408
|
+
}>;
|
|
409
|
+
|
|
391
410
|
/** Request host to trigger wallet connection. */
|
|
392
411
|
export declare type TfConnectWalletMessage = TfMessageEnvelope<"connectWallet", {
|
|
393
412
|
chainType?: ChainType;
|
|
@@ -405,6 +424,11 @@ export declare type TfEventMessage = TfMessageEnvelope<"event", {
|
|
|
405
424
|
data: unknown;
|
|
406
425
|
}>;
|
|
407
426
|
|
|
427
|
+
/** Notify widget that the fiat popup could not be opened by the host browser. */
|
|
428
|
+
declare type TfFiatPopupBlockedMessage = TfMessageEnvelope<"fiatPopupBlocked", {
|
|
429
|
+
orderId: string;
|
|
430
|
+
}>;
|
|
431
|
+
|
|
408
432
|
/** Notify widget that the fiat popup was closed by the user. */
|
|
409
433
|
export declare type TfFiatPopupClosedMessage = TfMessageEnvelope<"fiatPopupClosed", {
|
|
410
434
|
orderId: string;
|
|
@@ -557,12 +581,13 @@ export declare class TokenFlightBridge {
|
|
|
557
581
|
private navigatePopup;
|
|
558
582
|
/**
|
|
559
583
|
* Subscribe to provider terminal events arriving on the host window from
|
|
560
|
-
* the popup's wrapper page. Origin-validated against the
|
|
561
|
-
* `fiatApiEndpoint`; filtered by the active `popupOrderId`. Drops
|
|
562
|
-
* that don't match the expected `FiatWidgetEvent` shape.
|
|
584
|
+
* the popup's wrapper page. Origin-validated against the configured or
|
|
585
|
+
* default `fiatApiEndpoint`; filtered by the active `popupOrderId`. Drops
|
|
586
|
+
* messages that don't match the expected `FiatWidgetEvent` shape.
|
|
563
587
|
*/
|
|
564
588
|
private installPopupMessageHandler;
|
|
565
589
|
private closePopup;
|
|
590
|
+
private handleCloseFiatPopup;
|
|
566
591
|
private static readonly WALLET_EVENTS;
|
|
567
592
|
private subscribeWalletEvents;
|
|
568
593
|
private unsubscribeWalletEvents;
|
package/dist/bridge.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./protocol-
|
|
1
|
+
import{a as e,c as t,i as n,n as r,o as i,r as a,s as o,t as s}from"./protocol-B7S8LSlJ.js";import{n as c,t as l}from"./bridge-BufC2_tK.js";import{i as u,n as d,r as f,t as p}from"./iframe-receiver-i4RfQGg2.js";export{u as IframeBridgeWalletAdapter,p as IframeReceiver,t as TF_PROTOCOL_VERSION,l as TokenFlightBridge,s as consumeRequestId,r as createMessage,a as createRequestId,c as createTokenFlightBridge,n as deserializeError,d as getHostOrigin,f as isIframeMode,e as isMessageType,i as parseMessage,o as serializeError};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{t as e}from"./chunk-Dj_sP-dV.js";var t=e(((e,t)=>{t.exports=function(){return typeof Promise==`function`&&Promise.prototype&&Promise.prototype.then}})),n=e((e=>{var t,n=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];e.getSymbolSize=function(e){if(!e)throw Error(`"version" cannot be null or undefined`);if(e<1||e>40)throw Error(`"version" should be in range from 1 to 40`);return e*4+17},e.getSymbolTotalCodewords=function(e){return n[e]},e.getBCHDigit=function(e){let t=0;for(;e!==0;)t++,e>>>=1;return t},e.setToSJISFunction=function(e){if(typeof e!=`function`)throw Error(`"toSJISFunc" is not a valid function.`);t=e},e.isKanjiModeEnabled=function(){return t!==void 0},e.toSJIS=function(e){return t(e)}})),r=e((e=>{e.L={bit:1},e.M={bit:0},e.Q={bit:3},e.H={bit:2};function t(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`l`:case`low`:return e.L;case`m`:case`medium`:return e.M;case`q`:case`quartile`:return e.Q;case`h`:case`high`:return e.H;default:throw Error(`Unknown EC Level: `+t)}}e.isValid=function(e){return e&&e.bit!==void 0&&e.bit>=0&&e.bit<4},e.from=function(n,r){if(e.isValid(n))return n;try{return t(n)}catch{return r}}})),i=e(((e,t)=>{function n(){this.buffer=[],this.length=0}n.prototype={get:function(e){let t=Math.floor(e/8);return(this.buffer[t]>>>7-e%8&1)==1},put:function(e,t){for(let n=0;n<t;n++)this.putBit((e>>>t-n-1&1)==1)},getLengthInBits:function(){return this.length},putBit:function(e){let t=Math.floor(this.length/8);this.buffer.length<=t&&this.buffer.push(0),e&&(this.buffer[t]|=128>>>this.length%8),this.length++}},t.exports=n})),a=e(((e,t)=>{function n(e){if(!e||e<1)throw Error(`BitMatrix size must be defined and greater than 0`);this.size=e,this.data=new Uint8Array(e*e),this.reservedBit=new Uint8Array(e*e)}n.prototype.set=function(e,t,n,r){let i=e*this.size+t;this.data[i]=n,r&&(this.reservedBit[i]=!0)},n.prototype.get=function(e,t){return this.data[e*this.size+t]},n.prototype.xor=function(e,t,n){this.data[e*this.size+t]^=n},n.prototype.isReserved=function(e,t){return this.reservedBit[e*this.size+t]},t.exports=n})),o=e((e=>{var t=n().getSymbolSize;e.getRowColCoords=function(e){if(e===1)return[];let n=Math.floor(e/7)+2,r=t(e),i=r===145?26:Math.ceil((r-13)/(2*n-2))*2,a=[r-7];for(let e=1;e<n-1;e++)a[e]=a[e-1]-i;return a.push(6),a.reverse()},e.getPositions=function(t){let n=[],r=e.getRowColCoords(t),i=r.length;for(let e=0;e<i;e++)for(let t=0;t<i;t++)e===0&&t===0||e===0&&t===i-1||e===i-1&&t===0||n.push([r[e],r[t]]);return n}})),s=e((e=>{var t=n().getSymbolSize,r=7;e.getPositions=function(e){let n=t(e);return[[0,0],[n-r,0],[0,n-r]]}})),c=e((e=>{e.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};var t={N1:3,N2:3,N3:40,N4:10};e.isValid=function(e){return e!=null&&e!==``&&!isNaN(e)&&e>=0&&e<=7},e.from=function(t){return e.isValid(t)?parseInt(t,10):void 0},e.getPenaltyN1=function(e){let n=e.size,r=0,i=0,a=0,o=null,s=null;for(let c=0;c<n;c++){i=a=0,o=s=null;for(let l=0;l<n;l++){let n=e.get(c,l);n===o?i++:(i>=5&&(r+=t.N1+(i-5)),o=n,i=1),n=e.get(l,c),n===s?a++:(a>=5&&(r+=t.N1+(a-5)),s=n,a=1)}i>=5&&(r+=t.N1+(i-5)),a>=5&&(r+=t.N1+(a-5))}return r},e.getPenaltyN2=function(e){let n=e.size,r=0;for(let t=0;t<n-1;t++)for(let i=0;i<n-1;i++){let n=e.get(t,i)+e.get(t,i+1)+e.get(t+1,i)+e.get(t+1,i+1);(n===4||n===0)&&r++}return r*t.N2},e.getPenaltyN3=function(e){let n=e.size,r=0,i=0,a=0;for(let t=0;t<n;t++){i=a=0;for(let o=0;o<n;o++)i=i<<1&2047|e.get(t,o),o>=10&&(i===1488||i===93)&&r++,a=a<<1&2047|e.get(o,t),o>=10&&(a===1488||a===93)&&r++}return r*t.N3},e.getPenaltyN4=function(e){let n=0,r=e.data.length;for(let t=0;t<r;t++)n+=e.data[t];return Math.abs(Math.ceil(n*100/r/5)-10)*t.N4};function n(t,n,r){switch(t){case e.Patterns.PATTERN000:return(n+r)%2==0;case e.Patterns.PATTERN001:return n%2==0;case e.Patterns.PATTERN010:return r%3==0;case e.Patterns.PATTERN011:return(n+r)%3==0;case e.Patterns.PATTERN100:return(Math.floor(n/2)+Math.floor(r/3))%2==0;case e.Patterns.PATTERN101:return n*r%2+n*r%3==0;case e.Patterns.PATTERN110:return(n*r%2+n*r%3)%2==0;case e.Patterns.PATTERN111:return(n*r%3+(n+r)%2)%2==0;default:throw Error(`bad maskPattern:`+t)}}e.applyMask=function(e,t){let r=t.size;for(let i=0;i<r;i++)for(let a=0;a<r;a++)t.isReserved(a,i)||t.xor(a,i,n(e,a,i))},e.getBestMask=function(t,n){let r=Object.keys(e.Patterns).length,i=0,a=1/0;for(let o=0;o<r;o++){n(o),e.applyMask(o,t);let r=e.getPenaltyN1(t)+e.getPenaltyN2(t)+e.getPenaltyN3(t)+e.getPenaltyN4(t);e.applyMask(o,t),r<a&&(a=r,i=o)}return i}})),l=e((e=>{var t=r(),n=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],i=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];e.getBlocksCount=function(e,r){switch(r){case t.L:return n[(e-1)*4+0];case t.M:return n[(e-1)*4+1];case t.Q:return n[(e-1)*4+2];case t.H:return n[(e-1)*4+3];default:return}},e.getTotalCodewordsCount=function(e,n){switch(n){case t.L:return i[(e-1)*4+0];case t.M:return i[(e-1)*4+1];case t.Q:return i[(e-1)*4+2];case t.H:return i[(e-1)*4+3];default:return}}})),u=e((e=>{var t=new Uint8Array(512),n=new Uint8Array(256);(function(){let e=1;for(let r=0;r<255;r++)t[r]=e,n[e]=r,e<<=1,e&256&&(e^=285);for(let e=255;e<512;e++)t[e]=t[e-255]})(),e.log=function(e){if(e<1)throw Error(`log(`+e+`)`);return n[e]},e.exp=function(e){return t[e]},e.mul=function(e,r){return e===0||r===0?0:t[n[e]+n[r]]}})),d=e((e=>{var t=u();e.mul=function(e,n){let r=new Uint8Array(e.length+n.length-1);for(let i=0;i<e.length;i++)for(let a=0;a<n.length;a++)r[i+a]^=t.mul(e[i],n[a]);return r},e.mod=function(e,n){let r=new Uint8Array(e);for(;r.length-n.length>=0;){let e=r[0];for(let i=0;i<n.length;i++)r[i]^=t.mul(n[i],e);let i=0;for(;i<r.length&&r[i]===0;)i++;r=r.slice(i)}return r},e.generateECPolynomial=function(n){let r=new Uint8Array([1]);for(let i=0;i<n;i++)r=e.mul(r,new Uint8Array([1,t.exp(i)]));return r}})),f=e(((e,t)=>{var n=d();function r(e){this.genPoly=void 0,this.degree=e,this.degree&&this.initialize(this.degree)}r.prototype.initialize=function(e){this.degree=e,this.genPoly=n.generateECPolynomial(this.degree)},r.prototype.encode=function(e){if(!this.genPoly)throw Error(`Encoder not initialized`);let t=new Uint8Array(e.length+this.degree);t.set(e);let r=n.mod(t,this.genPoly),i=this.degree-r.length;if(i>0){let e=new Uint8Array(this.degree);return e.set(r,i),e}return r},t.exports=r})),p=e((e=>{e.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40}})),m=e((e=>{var t=`[0-9]+`,n=`[A-Z $%*+\\-./:]+`,r=`(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+`;r=r.replace(/u/g,`\\u`);var i=`(?:(?![A-Z0-9 $%*+\\-./:]|`+r+`)(?:.|[\r
|
|
2
|
+
]))+`;e.KANJI=new RegExp(r,`g`),e.BYTE_KANJI=RegExp(`[^A-Z0-9 $%*+\\-./:]+`,`g`),e.BYTE=new RegExp(i,`g`),e.NUMERIC=new RegExp(t,`g`),e.ALPHANUMERIC=new RegExp(n,`g`);var a=RegExp(`^`+r+`$`),o=RegExp(`^`+t+`$`),s=RegExp(`^[A-Z0-9 $%*+\\-./:]+$`);e.testKanji=function(e){return a.test(e)},e.testNumeric=function(e){return o.test(e)},e.testAlphanumeric=function(e){return s.test(e)}})),h=e((e=>{var t=p(),n=m();e.NUMERIC={id:`Numeric`,bit:1,ccBits:[10,12,14]},e.ALPHANUMERIC={id:`Alphanumeric`,bit:2,ccBits:[9,11,13]},e.BYTE={id:`Byte`,bit:4,ccBits:[8,16,16]},e.KANJI={id:`Kanji`,bit:8,ccBits:[8,10,12]},e.MIXED={bit:-1},e.getCharCountIndicator=function(e,n){if(!e.ccBits)throw Error(`Invalid mode: `+e);if(!t.isValid(n))throw Error(`Invalid version: `+n);return n>=1&&n<10?e.ccBits[0]:n<27?e.ccBits[1]:e.ccBits[2]},e.getBestModeForData=function(t){return n.testNumeric(t)?e.NUMERIC:n.testAlphanumeric(t)?e.ALPHANUMERIC:n.testKanji(t)?e.KANJI:e.BYTE},e.toString=function(e){if(e&&e.id)return e.id;throw Error(`Invalid mode`)},e.isValid=function(e){return e&&e.bit&&e.ccBits};function r(t){if(typeof t!=`string`)throw Error(`Param is not a string`);switch(t.toLowerCase()){case`numeric`:return e.NUMERIC;case`alphanumeric`:return e.ALPHANUMERIC;case`kanji`:return e.KANJI;case`byte`:return e.BYTE;default:throw Error(`Unknown mode: `+t)}}e.from=function(t,n){if(e.isValid(t))return t;try{return r(t)}catch{return n}}})),g=e((e=>{var t=n(),i=l(),a=r(),o=h(),s=p(),c=7973,u=t.getBCHDigit(c);function d(t,n,r){for(let i=1;i<=40;i++)if(n<=e.getCapacity(i,r,t))return i}function f(e,t){return o.getCharCountIndicator(e,t)+4}function m(e,t){let n=0;return e.forEach(function(e){let r=f(e.mode,t);n+=r+e.getBitsLength()}),n}function g(t,n){for(let r=1;r<=40;r++)if(m(t,r)<=e.getCapacity(r,n,o.MIXED))return r}e.from=function(e,t){return s.isValid(e)?parseInt(e,10):t},e.getCapacity=function(e,n,r){if(!s.isValid(e))throw Error(`Invalid QR Code version`);r===void 0&&(r=o.BYTE);let a=(t.getSymbolTotalCodewords(e)-i.getTotalCodewordsCount(e,n))*8;if(r===o.MIXED)return a;let c=a-f(r,e);switch(r){case o.NUMERIC:return Math.floor(c/10*3);case o.ALPHANUMERIC:return Math.floor(c/11*2);case o.KANJI:return Math.floor(c/13);case o.BYTE:default:return Math.floor(c/8)}},e.getBestVersionForData=function(e,t){let n,r=a.from(t,a.M);if(Array.isArray(e)){if(e.length>1)return g(e,r);if(e.length===0)return 1;n=e[0]}else n=e;return d(n.mode,n.getLength(),r)},e.getEncodedBits=function(e){if(!s.isValid(e)||e<7)throw Error(`Invalid QR Code version`);let n=e<<12;for(;t.getBCHDigit(n)-u>=0;)n^=c<<t.getBCHDigit(n)-u;return e<<12|n}})),_=e((e=>{var t=n(),r=1335,i=21522,a=t.getBCHDigit(r);e.getEncodedBits=function(e,n){let o=e.bit<<3|n,s=o<<10;for(;t.getBCHDigit(s)-a>=0;)s^=r<<t.getBCHDigit(s)-a;return(o<<10|s)^i}})),v=e(((e,t)=>{var n=h();function r(e){this.mode=n.NUMERIC,this.data=e.toString()}r.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},r.prototype.getLength=function(){return this.data.length},r.prototype.getBitsLength=function(){return r.getBitsLength(this.data.length)},r.prototype.write=function(e){let t,n,r;for(t=0;t+3<=this.data.length;t+=3)n=this.data.substr(t,3),r=parseInt(n,10),e.put(r,10);let i=this.data.length-t;i>0&&(n=this.data.substr(t),r=parseInt(n,10),e.put(r,i*3+1))},t.exports=r})),y=e(((e,t)=>{var n=h(),r=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:`.split(``);function i(e){this.mode=n.ALPHANUMERIC,this.data=e}i.getBitsLength=function(e){return 11*Math.floor(e/2)+e%2*6},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let n=r.indexOf(this.data[t])*45;n+=r.indexOf(this.data[t+1]),e.put(n,11)}this.data.length%2&&e.put(r.indexOf(this.data[t]),6)},t.exports=i})),b=e(((e,t)=>{t.exports=function(e){for(var t=[],n=e.length,r=0;r<n;r++){var i=e.charCodeAt(r);if(i>=55296&&i<=56319&&n>r+1){var a=e.charCodeAt(r+1);a>=56320&&a<=57343&&(i=(i-55296)*1024+a-56320+65536,r+=1)}if(i<128){t.push(i);continue}if(i<2048){t.push(i>>6|192),t.push(i&63|128);continue}if(i<55296||i>=57344&&i<65536){t.push(i>>12|224),t.push(i>>6&63|128),t.push(i&63|128);continue}if(i>=65536&&i<=1114111){t.push(i>>18|240),t.push(i>>12&63|128),t.push(i>>6&63|128),t.push(i&63|128);continue}t.push(239,191,189)}return new Uint8Array(t).buffer}})),x=e(((e,t)=>{var n=b(),r=h();function i(e){this.mode=r.BYTE,typeof e==`string`&&(e=n(e)),this.data=new Uint8Array(e)}i.getBitsLength=function(e){return e*8},i.prototype.getLength=function(){return this.data.length},i.prototype.getBitsLength=function(){return i.getBitsLength(this.data.length)},i.prototype.write=function(e){for(let t=0,n=this.data.length;t<n;t++)e.put(this.data[t],8)},t.exports=i})),S=e(((e,t)=>{var r=h(),i=n();function a(e){this.mode=r.KANJI,this.data=e}a.getBitsLength=function(e){return e*13},a.prototype.getLength=function(){return this.data.length},a.prototype.getBitsLength=function(){return a.getBitsLength(this.data.length)},a.prototype.write=function(e){let t;for(t=0;t<this.data.length;t++){let n=i.toSJIS(this.data[t]);if(n>=33088&&n<=40956)n-=33088;else if(n>=57408&&n<=60351)n-=49472;else throw Error(`Invalid SJIS character: `+this.data[t]+`
|
|
3
|
+
Make sure your charset is UTF-8`);n=(n>>>8&255)*192+(n&255),e.put(n,13)}},t.exports=a})),C=e(((e,t)=>{var n={single_source_shortest_paths:function(e,t,r){var i={},a={};a[t]=0;var o=n.PriorityQueue.make();o.push(t,0);for(var s,c,l,u,d,f,p,m,h;!o.empty();)for(l in s=o.pop(),c=s.value,u=s.cost,d=e[c]||{},d)d.hasOwnProperty(l)&&(f=d[l],p=u+f,m=a[l],h=a[l]===void 0,(h||m>p)&&(a[l]=p,o.push(l,p),i[l]=c));if(r!==void 0&&a[r]===void 0){var g=[`Could not find a path from `,t,` to `,r,`.`].join(``);throw Error(g)}return i},extract_shortest_path_from_predecessor_list:function(e,t){for(var n=[],r=t;r;)n.push(r),e[r],r=e[r];return n.reverse(),n},find_path:function(e,t,r){var i=n.single_source_shortest_paths(e,t,r);return n.extract_shortest_path_from_predecessor_list(i,r)},PriorityQueue:{make:function(e){var t=n.PriorityQueue,r={},i;for(i in e=e||{},t)t.hasOwnProperty(i)&&(r[i]=t[i]);return r.queue=[],r.sorter=e.sorter||t.default_sorter,r},default_sorter:function(e,t){return e.cost-t.cost},push:function(e,t){var n={value:e,cost:t};this.queue.push(n),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};t!==void 0&&(t.exports=n)})),w=e((e=>{var t=h(),r=v(),i=y(),a=x(),o=S(),s=m(),c=n(),l=C();function u(e){return unescape(encodeURIComponent(e)).length}function d(e,t,n){let r=[],i;for(;(i=e.exec(n))!==null;)r.push({data:i[0],index:i.index,mode:t,length:i[0].length});return r}function f(e){let n=d(s.NUMERIC,t.NUMERIC,e),r=d(s.ALPHANUMERIC,t.ALPHANUMERIC,e),i,a;return c.isKanjiModeEnabled()?(i=d(s.BYTE,t.BYTE,e),a=d(s.KANJI,t.KANJI,e)):(i=d(s.BYTE_KANJI,t.BYTE,e),a=[]),n.concat(r,i,a).sort(function(e,t){return e.index-t.index}).map(function(e){return{data:e.data,mode:e.mode,length:e.length}})}function p(e,n){switch(n){case t.NUMERIC:return r.getBitsLength(e);case t.ALPHANUMERIC:return i.getBitsLength(e);case t.KANJI:return o.getBitsLength(e);case t.BYTE:return a.getBitsLength(e)}}function g(e){return e.reduce(function(e,t){let n=e.length-1>=0?e[e.length-1]:null;return n&&n.mode===t.mode?(e[e.length-1].data+=t.data,e):(e.push(t),e)},[])}function _(e){let n=[];for(let r=0;r<e.length;r++){let i=e[r];switch(i.mode){case t.NUMERIC:n.push([i,{data:i.data,mode:t.ALPHANUMERIC,length:i.length},{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.ALPHANUMERIC:n.push([i,{data:i.data,mode:t.BYTE,length:i.length}]);break;case t.KANJI:n.push([i,{data:i.data,mode:t.BYTE,length:u(i.data)}]);break;case t.BYTE:n.push([{data:i.data,mode:t.BYTE,length:u(i.data)}])}}return n}function b(e,n){let r={},i={start:{}},a=[`start`];for(let o=0;o<e.length;o++){let s=e[o],c=[];for(let e=0;e<s.length;e++){let l=s[e],u=``+o+e;c.push(u),r[u]={node:l,lastCount:0},i[u]={};for(let e=0;e<a.length;e++){let o=a[e];r[o]&&r[o].node.mode===l.mode?(i[o][u]=p(r[o].lastCount+l.length,l.mode)-p(r[o].lastCount,l.mode),r[o].lastCount+=l.length):(r[o]&&(r[o].lastCount=l.length),i[o][u]=p(l.length,l.mode)+4+t.getCharCountIndicator(l.mode,n))}}a=c}for(let e=0;e<a.length;e++)i[a[e]].end=0;return{map:i,table:r}}function w(e,n){let s,l=t.getBestModeForData(e);if(s=t.from(n,l),s!==t.BYTE&&s.bit<l.bit)throw Error(`"`+e+`" cannot be encoded with mode `+t.toString(s)+`.
|
|
4
|
+
Suggested mode is: `+t.toString(l));switch(s===t.KANJI&&!c.isKanjiModeEnabled()&&(s=t.BYTE),s){case t.NUMERIC:return new r(e);case t.ALPHANUMERIC:return new i(e);case t.KANJI:return new o(e);case t.BYTE:return new a(e)}}e.fromArray=function(e){return e.reduce(function(e,t){return typeof t==`string`?e.push(w(t,null)):t.data&&e.push(w(t.data,t.mode)),e},[])},e.fromString=function(t,n){let r=b(_(f(t,c.isKanjiModeEnabled())),n),i=l.find_path(r.map,`start`,`end`),a=[];for(let e=1;e<i.length-1;e++)a.push(r.table[i[e]].node);return e.fromArray(g(a))},e.rawSplit=function(t){return e.fromArray(f(t,c.isKanjiModeEnabled()))}})),T=e((e=>{var t=n(),u=r(),d=i(),p=a(),m=o(),v=s(),y=c(),b=l(),x=f(),S=g(),C=_(),T=h(),E=w();function D(e,t){let n=e.size,r=v.getPositions(t);for(let t=0;t<r.length;t++){let i=r[t][0],a=r[t][1];for(let t=-1;t<=7;t++)if(!(i+t<=-1||n<=i+t))for(let r=-1;r<=7;r++)a+r<=-1||n<=a+r||(t>=0&&t<=6&&(r===0||r===6)||r>=0&&r<=6&&(t===0||t===6)||t>=2&&t<=4&&r>=2&&r<=4?e.set(i+t,a+r,!0,!0):e.set(i+t,a+r,!1,!0))}}function O(e){let t=e.size;for(let n=8;n<t-8;n++){let t=n%2==0;e.set(n,6,t,!0),e.set(6,n,t,!0)}}function k(e,t){let n=m.getPositions(t);for(let t=0;t<n.length;t++){let r=n[t][0],i=n[t][1];for(let t=-2;t<=2;t++)for(let n=-2;n<=2;n++)t===-2||t===2||n===-2||n===2||t===0&&n===0?e.set(r+t,i+n,!0,!0):e.set(r+t,i+n,!1,!0)}}function A(e,t){let n=e.size,r=S.getEncodedBits(t),i,a,o;for(let t=0;t<18;t++)i=Math.floor(t/3),a=t%3+n-8-3,o=(r>>t&1)==1,e.set(i,a,o,!0),e.set(a,i,o,!0)}function j(e,t,n){let r=e.size,i=C.getEncodedBits(t,n),a,o;for(a=0;a<15;a++)o=(i>>a&1)==1,a<6?e.set(a,8,o,!0):a<8?e.set(a+1,8,o,!0):e.set(r-15+a,8,o,!0),a<8?e.set(8,r-a-1,o,!0):a<9?e.set(8,15-a-1+1,o,!0):e.set(8,15-a-1,o,!0);e.set(r-8,8,1,!0)}function M(e,t){let n=e.size,r=-1,i=n-1,a=7,o=0;for(let s=n-1;s>0;s-=2)for(s===6&&s--;;){for(let n=0;n<2;n++)if(!e.isReserved(i,s-n)){let r=!1;o<t.length&&(r=(t[o]>>>a&1)==1),e.set(i,s-n,r),a--,a===-1&&(o++,a=7)}if(i+=r,i<0||n<=i){i-=r,r=-r;break}}}function N(e,n,r){let i=new d;r.forEach(function(t){i.put(t.mode.bit,4),i.put(t.getLength(),T.getCharCountIndicator(t.mode,e)),t.write(i)});let a=(t.getSymbolTotalCodewords(e)-b.getTotalCodewordsCount(e,n))*8;for(i.getLengthInBits()+4<=a&&i.put(0,4);i.getLengthInBits()%8!=0;)i.putBit(0);let o=(a-i.getLengthInBits())/8;for(let e=0;e<o;e++)i.put(e%2?17:236,8);return P(i,e,n)}function P(e,n,r){let i=t.getSymbolTotalCodewords(n),a=i-b.getTotalCodewordsCount(n,r),o=b.getBlocksCount(n,r),s=o-i%o,c=Math.floor(i/o),l=Math.floor(a/o),u=l+1,d=c-l,f=new x(d),p=0,m=Array(o),h=Array(o),g=0,_=new Uint8Array(e.buffer);for(let e=0;e<o;e++){let t=e<s?l:u;m[e]=_.slice(p,p+t),h[e]=f.encode(m[e]),p+=t,g=Math.max(g,t)}let v=new Uint8Array(i),y=0,S,C;for(S=0;S<g;S++)for(C=0;C<o;C++)S<m[C].length&&(v[y++]=m[C][S]);for(S=0;S<d;S++)for(C=0;C<o;C++)v[y++]=h[C][S];return v}function F(e,n,r,i){let a;if(Array.isArray(e))a=E.fromArray(e);else if(typeof e==`string`){let t=n;if(!t){let n=E.rawSplit(e);t=S.getBestVersionForData(n,r)}a=E.fromString(e,t||40)}else throw Error(`Invalid data`);let o=S.getBestVersionForData(a,r);if(!o)throw Error(`The amount of data is too big to be stored in a QR Code`);if(!n)n=o;else if(n<o)throw Error(`
|
|
5
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
6
|
+
Minimum version required to store current data is: `+o+`.
|
|
7
|
+
`);let s=N(n,r,a),c=new p(t.getSymbolSize(n));return D(c,n),O(c),k(c,n),j(c,r,0),n>=7&&A(c,n),M(c,s),isNaN(i)&&(i=y.getBestMask(c,j.bind(null,c,r))),y.applyMask(i,c),j(c,r,i),{modules:c,version:n,errorCorrectionLevel:r,maskPattern:i,segments:a}}e.create=function(e,n){if(e===void 0||e===``)throw Error(`No input text`);let r=u.M,i,a;return n!==void 0&&(r=u.from(n.errorCorrectionLevel,u.M),i=S.from(n.version),a=y.from(n.maskPattern),n.toSJISFunc&&t.setToSJISFunction(n.toSJISFunc)),F(e,i,r,a)}})),E=e((e=>{function t(e){if(typeof e==`number`&&(e=e.toString()),typeof e!=`string`)throw Error(`Color should be defined as hex string`);let t=e.slice().replace(`#`,``).split(``);if(t.length<3||t.length===5||t.length>8)throw Error(`Invalid hex color: `+e);(t.length===3||t.length===4)&&(t=Array.prototype.concat.apply([],t.map(function(e){return[e,e]}))),t.length===6&&t.push(`F`,`F`);let n=parseInt(t.join(``),16);return{r:n>>24&255,g:n>>16&255,b:n>>8&255,a:n&255,hex:`#`+t.slice(0,6).join(``)}}e.getOptions=function(e){e||(e={}),e.color||(e.color={});let n=e.margin===void 0||e.margin===null||e.margin<0?4:e.margin,r=e.width&&e.width>=21?e.width:void 0,i=e.scale||4;return{width:r,scale:r?4:i,margin:n,color:{dark:t(e.color.dark||`#000000ff`),light:t(e.color.light||`#ffffffff`)},type:e.type,rendererOpts:e.rendererOpts||{}}},e.getScale=function(e,t){return t.width&&t.width>=e+t.margin*2?t.width/(e+t.margin*2):t.scale},e.getImageWidth=function(t,n){let r=e.getScale(t,n);return Math.floor((t+n.margin*2)*r)},e.qrToImageData=function(t,n,r){let i=n.modules.size,a=n.modules.data,o=e.getScale(i,r),s=Math.floor((i+r.margin*2)*o),c=r.margin*o,l=[r.color.light,r.color.dark];for(let e=0;e<s;e++)for(let n=0;n<s;n++){let u=(e*s+n)*4,d=r.color.light;if(e>=c&&n>=c&&e<s-c&&n<s-c){let t=Math.floor((e-c)/o),r=Math.floor((n-c)/o);d=l[+!!a[t*i+r]]}t[u++]=d.r,t[u++]=d.g,t[u++]=d.b,t[u]=d.a}}})),D=e((e=>{var t=E();function n(e,t,n){e.clearRect(0,0,t.width,t.height),t.style||(t.style={}),t.height=n,t.width=n,t.style.height=n+`px`,t.style.width=n+`px`}function r(){try{return document.createElement(`canvas`)}catch{throw Error(`You need to specify a canvas element`)}}e.render=function(e,i,a){let o=a,s=i;o===void 0&&(!i||!i.getContext)&&(o=i,i=void 0),i||(s=r()),o=t.getOptions(o);let c=t.getImageWidth(e.modules.size,o),l=s.getContext(`2d`),u=l.createImageData(c,c);return t.qrToImageData(u.data,e,o),n(l,s,c),l.putImageData(u,0,0),s},e.renderToDataURL=function(t,n,r){let i=r;i===void 0&&(!n||!n.getContext)&&(i=n,n=void 0),i||(i={});let a=e.render(t,n,i),o=i.type||`image/png`,s=i.rendererOpts||{};return a.toDataURL(o,s.quality)}})),O=e((e=>{var t=E();function n(e,t){let n=e.a/255,r=t+`="`+e.hex+`"`;return n<1?r+` `+t+`-opacity="`+n.toFixed(2).slice(1)+`"`:r}function r(e,t,n){let r=e+t;return n!==void 0&&(r+=` `+n),r}function i(e,t,n){let i=``,a=0,o=!1,s=0;for(let c=0;c<e.length;c++){let l=Math.floor(c%t),u=Math.floor(c/t);!l&&!o&&(o=!0),e[c]?(s++,c>0&&l>0&&e[c-1]||(i+=o?r(`M`,l+n,.5+u+n):r(`m`,a,0),a=0,o=!1),l+1<t&&e[c+1]||(i+=r(`h`,s),s=0)):a++}return i}e.render=function(e,r,a){let o=t.getOptions(r),s=e.modules.size,c=e.modules.data,l=s+o.margin*2,u=o.color.light.a?`<path `+n(o.color.light,`fill`)+` d="M0 0h`+l+`v`+l+`H0z"/>`:``,d=`<path `+n(o.color.dark,`stroke`)+` d="`+i(c,s,o.margin)+`"/>`,f=`viewBox="0 0 `+l+` `+l+`"`,p=`<svg xmlns="http://www.w3.org/2000/svg" `+(o.width?`width="`+o.width+`" height="`+o.width+`" `:``)+f+` shape-rendering="crispEdges">`+u+d+`</svg>
|
|
8
|
+
`;return typeof a==`function`&&a(null,p),p}})),k=e((e=>{var n=t(),r=T(),i=D(),a=O();function o(e,t,i,a,o){let s=[].slice.call(arguments,1),c=s.length,l=typeof s[c-1]==`function`;if(!l&&!n())throw Error(`Callback required as last argument`);if(l){if(c<2)throw Error(`Too few arguments provided`);c===2?(o=i,i=t,t=a=void 0):c===3&&(t.getContext&&o===void 0?(o=a,a=void 0):(o=a,a=i,i=t,t=void 0))}else{if(c<1)throw Error(`Too few arguments provided`);return c===1?(i=t,t=a=void 0):c===2&&!t.getContext&&(a=i,i=t,t=void 0),new Promise(function(n,o){try{n(e(r.create(i,a),t,a))}catch(e){o(e)}})}try{let n=r.create(i,a);o(null,e(n,t,a))}catch(e){o(e)}}e.create=r.create,e.toCanvas=o.bind(null,i.render),e.toDataURL=o.bind(null,i.renderToDataURL),e.toString=o.bind(null,function(e,t,n){return a.render(e,n)})}));export default k();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{c as n,o as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(e,t){if(t.has(e))throw TypeError(`Cannot initialize the same private elements twice on an object`)}function t(t,n){e(t,n),n.add(t)}function n(t,n,r){e(t,n),n.set(t,r)}function r(e,t,n){if(typeof e==`function`?e===t:e.has(t))return arguments.length<3?t:n;throw TypeError(`Private element is not present on this object`)}function i(e,t){return e.get(r(e,t))}function a(e,t,n){return e.set(r(e,t),n),n}export{t as a,n as i,i as n,r,a as t};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{a as e,i as t,n,r,t as i}from"./classPrivateFieldSet2-DmR3eaHe.js";function a(e){"@babel/helpers - typeof";return a=typeof Symbol==`function`&&typeof Symbol.iterator==`symbol`?function(e){return typeof e}:function(e){return e&&typeof Symbol==`function`&&e.constructor===Symbol&&e!==Symbol.prototype?`symbol`:typeof e},a(e)}function o(e,t){if(a(e)!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(a(r)!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function s(e){var t=o(e,`string`);return a(t)==`symbol`?t:t+``}function c(e,t,n){return(t=s(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var l=class extends Error{constructor(e,t,n){let r=`${e.status||e.status===0?e.status:``} ${e.statusText??``}`.trim(),i=r?`status code ${r}`:`an unknown error`;super(`Request failed with ${i}: ${t.method} ${t.url}`),c(this,`response`,void 0),c(this,`request`,void 0),c(this,`options`,void 0),this.name=`HTTPError`,this.response=e,this.request=t,this.options=n}},u=class extends Error{constructor(e){let t=`Non-error value was thrown`;try{typeof e==`string`?t=e:e&&typeof e==`object`&&`message`in e&&typeof e.message==`string`&&(t=e.message)}catch{}super(t),c(this,`name`,`NonError`),c(this,`value`,void 0),this.value=e}},d=class extends Error{constructor(e){let t=e?.cause?e.cause instanceof Error?e.cause:new u(e.cause):void 0;super(e?.code?`Forced retry: ${e.code}`:`Forced retry`,t?{cause:t}:void 0),c(this,`name`,`ForceRetryError`),c(this,`customDelay`,void 0),c(this,`code`,void 0),c(this,`customRequest`,void 0),this.customDelay=e?.delay,this.code=e?.code,this.customRequest=e?.request}},f=(()=>{let e=!1,t=!1,n=typeof globalThis.ReadableStream==`function`,r=typeof globalThis.Request==`function`;if(n&&r)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(e){if(e instanceof Error&&e.message===`unsupported BodyInit type`)return!1;throw e}return e&&!t})(),p=typeof globalThis.AbortController==`function`,m=typeof globalThis.AbortSignal==`function`&&typeof globalThis.AbortSignal.any==`function`,h=typeof globalThis.ReadableStream==`function`,g=typeof globalThis.FormData==`function`,_=[`get`,`post`,`put`,`patch`,`head`,`delete`],ee={json:`application/json`,text:`text/*`,formData:`multipart/form-data`,arrayBuffer:`*/*`,blob:`*/*`,bytes:`*/*`},v=2147483647,te=new TextEncoder().encode(`------WebKitFormBoundaryaxpyiPgbbPti10Rw`).length,y=Symbol(`stop`),b=class{constructor(e){c(this,`options`,void 0),this.options=e}},ne=e=>new b(e),re={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},ie={next:!0},ae={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},oe=e=>{if(!e)return 0;if(e instanceof FormData){let t=0;for(let[n,r]of e)t+=te,t+=new TextEncoder().encode(`Content-Disposition: form-data; name="${n}"`).length,t+=typeof r==`string`?new TextEncoder().encode(r).length:r.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)try{let t=JSON.stringify(e);return new TextEncoder().encode(t).length}catch{return 0}return 0},x=(e,t,n)=>{let r,i=0;return e.pipeThrough(new TransformStream({transform(e,a){if(a.enqueue(e),r){i+=r.byteLength;let e=t===0?0:i/t;e>=1&&(e=1-2**-52),n?.({percent:e,totalBytes:Math.max(t,i),transferredBytes:i},r)}r=e},flush(){r&&(i+=r.byteLength,n?.({percent:1,totalBytes:Math.max(t,i),transferredBytes:i},r))}}))},se=(e,t)=>{if(!e.body)return e;if(e.status===204)return new Response(null,{status:e.status,statusText:e.statusText,headers:e.headers});let n=Math.max(0,Number(e.headers.get(`content-length`))||0);return new Response(x(e.body,n,t),{status:e.status,statusText:e.statusText,headers:e.headers})},ce=(e,t,n)=>{if(!e.body)return e;let r=oe(n??e.body);return new Request(e,{duplex:`half`,body:x(e.body,r,t)})},S=e=>typeof e==`object`&&!!e,C=(...e)=>{for(let t of e)if((!S(t)||Array.isArray(t))&&t!==void 0)throw TypeError("The `options` argument must be an object");return D({},...e)},w=(e={},t={})=>{let n=new globalThis.Headers(e),r=t instanceof globalThis.Headers,i=new globalThis.Headers(t);for(let[e,t]of i.entries())r&&t===`undefined`||t===void 0?n.delete(e):n.set(e,t);return n};function T(e,t,n){return Object.hasOwn(t,n)&&t[n]===void 0?[]:D(e[n]??[],t[n]??[])}var E=(e={},t={})=>({beforeRequest:T(e,t,`beforeRequest`),beforeRetry:T(e,t,`beforeRetry`),afterResponse:T(e,t,`afterResponse`),beforeError:T(e,t,`beforeError`)}),le=(e,t)=>{let n=new URLSearchParams;for(let r of[e,t])if(r!==void 0)if(r instanceof URLSearchParams)for(let[e,t]of r.entries())n.append(e,t);else if(Array.isArray(r))for(let e of r){if(!Array.isArray(e)||e.length!==2)throw TypeError(`Array search parameters must be provided in [[key, value], ...] format`);n.append(String(e[0]),String(e[1]))}else if(S(r))for(let[e,t]of Object.entries(r))t!==void 0&&n.append(e,String(t));else{let e=new URLSearchParams(r);for(let[t,r]of e.entries())n.append(t,r)}return n},D=(...e)=>{let t={},n={},r={},i,a=[];for(let o of e)if(Array.isArray(o))Array.isArray(t)||(t=[]),t=[...t,...o];else if(S(o)){for(let[e,n]of Object.entries(o)){if(e===`signal`&&n instanceof globalThis.AbortSignal){a.push(n);continue}if(e===`context`){if(n!=null&&(!S(n)||Array.isArray(n)))throw TypeError("The `context` option must be an object");t={...t,context:n==null?{}:{...t.context,...n}};continue}if(e===`searchParams`){i=n==null?void 0:i===void 0?n:le(i,n);continue}S(n)&&e in t&&(n=D(t[e],n)),t={...t,[e]:n}}S(o.hooks)&&(r=E(r,o.hooks),t.hooks=r),S(o.headers)&&(n=w(n,o.headers),t.headers=n)}return i!==void 0&&(t.searchParams=i),a.length>0&&(a.length===1?t.signal=a[0]:m?t.signal=AbortSignal.any(a):t.signal=a.at(-1)),t},ue=e=>_.includes(e)?e.toUpperCase():e,O={limit:2,methods:[`get`,`put`,`head`,`delete`,`options`,`trace`],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:[413,429,503],maxRetryAfter:1/0,backoffLimit:1/0,delay:e=>.3*2**(e-1)*1e3,jitter:void 0,retryOnTimeout:!1},de=(e={})=>{if(typeof e==`number`)return{...O,limit:e};if(e.methods&&!Array.isArray(e.methods))throw Error(`retry.methods must be an array`);if(e.methods&&(e.methods=e.methods.map(e=>e.toLowerCase())),e.statusCodes&&!Array.isArray(e.statusCodes))throw Error(`retry.statusCodes must be an array`);let t=Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0));return{...O,...t}},k=class extends Error{constructor(e){super(`Request timed out: ${e.method} ${e.url}`),c(this,`request`,void 0),this.name=`TimeoutError`,this.request=e}};async function fe(e,t,n,r){return new Promise((i,a)=>{let o=setTimeout(()=>{n&&n.abort(),a(new k(e))},r.timeout);r.fetch(e,t).then(i).catch(a).then(()=>{clearTimeout(o)})})}async function pe(e,{signal:t}){return new Promise((n,r)=>{t&&(t.throwIfAborted(),t.addEventListener(`abort`,i,{once:!0}));function i(){clearTimeout(a),r(t.reason)}let a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e)})}var me=(e,t)=>{let n={};for(let r in t)Object.hasOwn(t,r)&&!(r in ae)&&!(r in re)&&(!(r in e)||r in ie)&&(n[r]=t[r]);return n},he=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 ge(e){return e instanceof l||e?.name===l.name}function _e(e){return e instanceof k||e?.name===k.name}var A=new WeakMap,j=new WeakMap,M=new WeakMap,N=new WeakMap,P=new WeakMap,F=new WeakMap,I=new WeakMap,L=new WeakSet,R=class a{static create(e,t){let i=new a(e,t),o=r(L,i,U).call(i,async()=>{if(typeof n(N,i).timeout==`number`&&n(N,i).timeout>2147483647)throw RangeError(`The \`timeout\` option cannot be greater than ${v}`);await Promise.resolve();let e=await r(L,i,be).call(i);for(let t of n(N,i).hooks.afterResponse){let a=r(L,i,B).call(i,e.clone()),o;try{o=await t(i.request,r(L,i,W).call(i),a,{retryCount:n(j,i)})}catch(t){throw r(L,i,H).call(i,a),r(L,i,H).call(i,e),t}if(o instanceof b)throw r(L,i,H).call(i,a),r(L,i,H).call(i,e),new d(o.options);let s=o instanceof globalThis.Response?o:e;a!==s&&r(L,i,H).call(i,a),e!==s&&r(L,i,H).call(i,e),e=s}if(r(L,i,B).call(i,e),!e.ok&&(typeof n(N,i).throwHttpErrors==`function`?n(N,i).throwHttpErrors(e.status):n(N,i).throwHttpErrors)){let t=new l(e,i.request,r(L,i,W).call(i));for(let e of n(N,i).hooks.beforeError)t=await e(t,{retryCount:n(j,i)});throw t}if(n(N,i).onDownloadProgress){if(typeof n(N,i).onDownloadProgress!=`function`)throw TypeError("The `onDownloadProgress` option must be a function");if(!h)throw Error("Streams are not supported in your environment. `ReadableStream` is missing.");let t=e.clone();return r(L,i,H).call(i,e),se(t,n(N,i).onDownloadProgress)}return e}).finally(()=>{let e=n(P,i);r(L,i,V).call(i,e?.body??void 0),r(L,i,V).call(i,i.request.body??void 0)});for(let[e,n]of Object.entries(ee))e===`bytes`&&typeof globalThis.Response?.prototype?.bytes!=`function`||(o[e]=async()=>{i.request.headers.set(`accept`,i.request.headers.get(`accept`)||n);let r=await o;if(e===`json`){if(r.status===204)return``;let e=await r.text();return e===``?``:t.parseJson?t.parseJson(e):JSON.parse(e)}return r[e]()});return o}constructor(o,s={}){if(e(this,L),c(this,`request`,void 0),t(this,A,void 0),t(this,j,0),t(this,M,void 0),t(this,N,void 0),t(this,P,void 0),t(this,F,void 0),t(this,I,void 0),i(M,this,o),i(N,this,{...s,headers:w(n(M,this).headers,s.headers),hooks:E({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},s.hooks),method:ue(s.method??n(M,this).method??`GET`),prefixUrl:String(s.prefixUrl||``),retry:de(s.retry),throwHttpErrors:s.throwHttpErrors??!0,timeout:s.timeout??1e4,fetch:s.fetch??globalThis.fetch.bind(globalThis),context:s.context??{}}),typeof n(M,this)!=`string`&&!(n(M,this)instanceof URL||n(M,this)instanceof globalThis.Request))throw TypeError("`input` must be a string, URL, or Request");if(n(N,this).prefixUrl&&typeof n(M,this)==`string`){if(n(M,this).startsWith(`/`))throw Error("`input` must not begin with a slash when using `prefixUrl`");n(N,this).prefixUrl.endsWith(`/`)||(n(N,this).prefixUrl+=`/`),i(M,this,n(N,this).prefixUrl+n(M,this))}p&&m&&(i(F,this,n(N,this).signal??n(M,this).signal),i(A,this,new globalThis.AbortController),n(N,this).signal=n(F,this)?AbortSignal.any([n(F,this),n(A,this).signal]):n(A,this).signal),f&&(n(N,this).duplex=`half`),n(N,this).json!==void 0&&(n(N,this).body=n(N,this).stringifyJson?.(n(N,this).json)??JSON.stringify(n(N,this).json),n(N,this).headers.set(`content-type`,n(N,this).headers.get(`content-type`)??`application/json`));let l=s.headers&&new globalThis.Headers(s.headers).has(`content-type`);if(n(M,this)instanceof globalThis.Request&&(g&&n(N,this).body instanceof globalThis.FormData||n(N,this).body instanceof URLSearchParams)&&!l&&n(N,this).headers.delete(`content-type`),this.request=new globalThis.Request(n(M,this),n(N,this)),he(n(N,this).searchParams)){let e=`?`+(typeof n(N,this).searchParams==`string`?n(N,this).searchParams.replace(/^\?/,``):new URLSearchParams(ve.call(a,n(N,this).searchParams)).toString()),t=this.request.url.replace(/(?:\?.*?)?(?=#|$)/,e);this.request=new globalThis.Request(t,n(N,this))}if(n(N,this).onUploadProgress){if(typeof n(N,this).onUploadProgress!=`function`)throw TypeError("The `onUploadProgress` option must be a function");if(!f)throw Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");this.request=r(L,this,K).call(this,this.request,n(N,this).body??void 0)}}};function ve(e){return e&&typeof e==`object`&&!Array.isArray(e)&&!(e instanceof URLSearchParams)?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0)):e}function z(){let e=n(N,this).retry.delay(n(j,this)),t=e;n(N,this).retry.jitter===!0?t=Math.random()*e:typeof n(N,this).retry.jitter==`function`&&(t=n(N,this).retry.jitter(e),(!Number.isFinite(t)||t<0)&&(t=e));let r=n(N,this).retry.backoffLimit??1/0;return Math.min(r,t)}async function ye(e){var t;if(i(j,this,(t=n(j,this),t++,t)),n(j,this)>n(N,this).retry.limit)throw e;let a=e instanceof Error?e:new u(e);if(a instanceof d)return a.customDelay??r(L,this,z).call(this);if(!n(N,this).retry.methods.includes(this.request.method.toLowerCase()))throw e;if(n(N,this).retry.shouldRetry!==void 0){let t=await n(N,this).retry.shouldRetry({error:a,retryCount:n(j,this)});if(t===!1)throw e;if(t===!0)return r(L,this,z).call(this)}if(_e(e)&&!n(N,this).retry.retryOnTimeout)throw e;if(ge(e)){if(!n(N,this).retry.statusCodes.includes(e.response.status))throw e;let t=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(t&&n(N,this).retry.afterStatusCodes.includes(e.response.status)){let e=Number(t)*1e3;Number.isNaN(e)?e=Date.parse(t)-Date.now():e>=Date.parse(`2024-01-01`)&&(e-=Date.now());let r=n(N,this).retry.maxRetryAfter??e;return e<r?e:r}if(e.response.status===413)throw e}return r(L,this,z).call(this)}function B(e){return n(N,this).parseJson&&(e.json=async()=>n(N,this).parseJson(await e.text())),e}function V(e){e&&e.cancel().catch(()=>void 0)}function H(e){r(L,this,V).call(this,e.body??void 0)}async function U(e){try{return await e()}catch(t){let i=Math.min(await r(L,this,ye).call(this,t),v);if(n(j,this)<1)throw t;if(await pe(i,n(F,this)?{signal:n(F,this)}:{}),t instanceof d&&t.customRequest){let e=n(N,this).signal?new globalThis.Request(t.customRequest,{signal:n(N,this).signal}):new globalThis.Request(t.customRequest);r(L,this,G).call(this,e)}for(let e of n(N,this).hooks.beforeRetry){let i=await e({request:this.request,options:r(L,this,W).call(this),error:t,retryCount:n(j,this)});if(i instanceof globalThis.Request){r(L,this,G).call(this,i);break}if(i instanceof globalThis.Response)return i;if(i===y)return}return r(L,this,U).call(this,e)}}async function be(){n(A,this)?.signal.aborted&&(i(A,this,new globalThis.AbortController),n(N,this).signal=n(F,this)?AbortSignal.any([n(F,this),n(A,this).signal]):n(A,this).signal,this.request=new globalThis.Request(this.request,{signal:n(N,this).signal}));for(let e of n(N,this).hooks.beforeRequest){let t=await e(this.request,r(L,this,W).call(this),{retryCount:n(j,this)});if(t instanceof Response)return t;if(t instanceof globalThis.Request){r(L,this,G).call(this,t);break}}let e=me(this.request,n(N,this));return i(P,this,this.request),this.request=n(P,this).clone(),n(N,this).timeout===!1?n(N,this).fetch(n(P,this),e):fe(n(P,this),e,n(A,this),n(N,this))}function W(){if(!n(I,this)){let{hooks:e,...t}=n(N,this);i(I,this,Object.freeze(t))}return n(I,this)}function G(e){i(I,this,void 0),this.request=r(L,this,K).call(this,e)}function K(e,t){return!n(N,this).onUploadProgress||!e.body?e:ce(e,n(N,this).onUploadProgress,t??n(N,this).body??void 0)}var q=e=>{let t=(t,n)=>R.create(t,C(e,n));for(let n of _)t[n]=(t,r)=>R.create(t,C(e,r,{method:n}));return t.create=e=>q(C(e)),t.extend=t=>(typeof t==`function`&&(t=t(e??{})),q(C(e,t))),t.stop=y,t.retry=ne,t},xe=q(),J={API_REQUEST_FAILED:`TF3001`,API_TIMEOUT:`TF3002`,API_INVALID_RESPONSE:`TF3003`,QUOTE_FAILED:`TF3004`,QUOTE_EXPIRED:`TF3005`,DEPOSIT_BUILD_FAILED:`TF3006`,DEPOSIT_SUBMIT_FAILED:`TF3007`,ORDER_FAILED:`TF3008`,API_ABORTED:`TF3009`,FIAT_QUOTE_FAILED:`TF6001`,FIAT_ORDER_FAILED:`TF6002`,FIAT_STATUS_FAILED:`TF6003`,FIAT_PROVIDER_ERROR:`TF6004`,FIAT_AMOUNT_OUT_OF_RANGE:`TF6005`,FIAT_POPUP_BLOCKED:`TF6006`,FIAT_CHECKOUT_UNAVAILABLE:`TF6007`},Y={[J.API_REQUEST_FAILED]:`API request failed`,[J.API_TIMEOUT]:`API request timed out`,[J.API_INVALID_RESPONSE]:`Invalid API response`,[J.QUOTE_FAILED]:`Failed to get quote`,[J.QUOTE_EXPIRED]:`Quote has expired`,[J.DEPOSIT_BUILD_FAILED]:`Failed to build deposit transaction`,[J.DEPOSIT_SUBMIT_FAILED]:`Failed to submit deposit`,[J.ORDER_FAILED]:`Order processing failed`,[J.API_ABORTED]:`Request was aborted`,[J.FIAT_QUOTE_FAILED]:`Failed to get fiat quote`,[J.FIAT_ORDER_FAILED]:`Failed to create fiat order`,[J.FIAT_STATUS_FAILED]:`Failed to get fiat order status`,[J.FIAT_PROVIDER_ERROR]:`Fiat provider error`,[J.FIAT_AMOUNT_OUT_OF_RANGE]:`Fiat amount is out of range`,[J.FIAT_POPUP_BLOCKED]:`Payment popup was blocked by the browser`,[J.FIAT_CHECKOUT_UNAVAILABLE]:`Fiat checkout requires a browser window`},X=class extends Error{constructor(e,t,n){let r=typeof t==`string`?t:t instanceof Error||typeof t==`object`&&t&&`message`in t&&typeof t.message==`string`?t.message:Y[e]??`Unknown error`;super(r),this.name=`TokenFlightError`,this.code=e,this.details=n}},Se=class extends X{constructor(e,t){super(J.API_TIMEOUT,e,t),this.name=`ApiTimeoutError`}},Z=class extends X{constructor(e,t){super(J.API_ABORTED,e,t),this.name=`ApiAbortedError`}},Q=class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`ApiValidationError`}},$={ValidationException:Q,ZodValidationException:Q,BadRequestException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`BadRequestError`}},QuoteNotFoundException:class extends X{constructor(e,t){super(J.QUOTE_FAILED,e,t),this.name=`QuoteNotFoundError`}},QuoteExpiredException:class extends X{constructor(e,t){super(J.QUOTE_EXPIRED,e,t),this.name=`QuoteExpiredError`}},CannotFillException:class extends X{constructor(e,t){super(J.QUOTE_FAILED,e,t),this.name=`CannotFillError`}},NotSupportedTokenException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`NotSupportedTokenError`}},NotSupportedChainException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`NotSupportedChainError`}},NotSupportedDepositMethodException:class extends X{constructor(e,t){super(J.DEPOSIT_BUILD_FAILED,e,t),this.name=`NotSupportedDepositMethodError`}},UnexpectedFromAddressException:class extends X{constructor(e,t){super(J.DEPOSIT_BUILD_FAILED,e,t),this.name=`UnexpectedFromAddressError`}},IntentNotFoundException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`IntentNotFoundError`}},DuplicateRecordException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`DuplicateRecordError`}},BroadcastException:class extends X{constructor(e,t){super(J.DEPOSIT_SUBMIT_FAILED,e,t),this.name=`BroadcastError`}},InternalErrorException:class extends X{constructor(e,t){super(J.API_REQUEST_FAILED,e,t),this.name=`InternalServerError`}}};function Ce(e,t,n){if(typeof e==`object`&&e){let r=e,i=typeof r.name==`string`?r.name:null,a=typeof r.message==`string`?r.message:t;if(i&&$[i]){let t=$[i];return new t(a,n??e)}return new X(J.API_REQUEST_FAILED,a,n??e)}return new X(J.API_REQUEST_FAILED,t,n)}function we(e){return xe.create({prefixUrl:e.baseUrl,timeout:e.timeout??15e3,retry:0,...e.fetch?{fetch:e.fetch}:{},headers:{"X-TF-SDK-Version":Ee(),...e.headers}})}function Te(e){return e.replace(/\/$/,``)}function Ee(){return`0.3.0`}async function De(e,t){try{return await e}catch(e){if(e instanceof X)throw e;if(e instanceof k)throw new Se(t.timeoutMessage,e);if(e instanceof DOMException&&e.name===`AbortError`)throw new Z(`Request was aborted`,e);if(e instanceof l){let n=``;try{n=await e.response.json()}catch{n=await e.response.text().catch(()=>``)}let r=`${t.failureMessage}: ${e.response.status} ${e.response.statusText}`;throw Ce(n,r,{status:e.response.status,body:n})}throw new X(J.API_REQUEST_FAILED,`${t.failureMessage}: ${String(e)}`,e)}}async function*Oe(e){if(!e.ok){let t=``;try{t=await e.json()}catch{t=await e.text().catch(()=>``)}throw Ce(t,`API request failed: ${e.status} ${e.statusText}`,{status:e.status,body:t})}if(!e.body)throw new X(J.API_INVALID_RESPONSE,`Streaming response has no body`);let t=e.body.getReader(),n=new TextDecoder(`utf-8`),r=``;try{for(;;){let{value:e,done:i}=await t.read();e&&(r+=n.decode(e,{stream:!0}));let a=r.indexOf(`
|
|
2
|
+
`);for(;a!==-1;){let e=r.slice(0,a).trim();r=r.slice(a+1),e&&(yield ke(e)),a=r.indexOf(`
|
|
3
|
+
`)}if(i){let e=r.trim();e&&(yield ke(e));return}}}finally{t.releaseLock()}}function ke(e){try{return JSON.parse(e)}catch(t){throw new X(J.API_INVALID_RESPONSE,`Failed to parse NDJSON frame: ${String(t)}`,{line:e})}}var Ae=`https://api.hyperstream.dev`,je=2e3,Me=500,Ne=5e3,Pe=class{constructor(e){this.baseUrl=Te(e.baseUrl),this.ky=we({baseUrl:this.baseUrl,timeout:e.timeout,fetch:e.fetch,headers:e.headers}),this.fetchImpl=e.fetch??globalThis.fetch.bind(globalThis),this.extraHeaders=e.headers??{}}request(e){return De(e,{timeoutMessage:`API request timed out`,failureMessage:`API request failed`})}getQuotes(e,t){return this.request(this.ky.post(`v1/quotes`,{json:e,signal:t?.signal}).json())}async*streamQuotes(e,t){yield*Oe(await this.fetchImpl(`${this.baseUrl}/v1/quotes?mode=stream`,{method:`POST`,headers:{"Content-Type":`application/json`,"X-TF-SDK-Version":Ee(),...this.extraHeaders},body:JSON.stringify(e),signal:t?.signal}))}buildDeposit(e,t){return this.request(this.ky.post(`v1/deposit/build`,{json:e,signal:t?.signal}).json())}submitDeposit(e,t){return this.request(this.ky.put(`v1/deposit/submit`,{json:e,signal:t?.signal}).json())}getOrdersByAddress(e,t){let n={};return t?.orderIds?.length&&(n.orderIds=t.orderIds.join(`,`)),t?.limit&&(n.limit=t.limit.toString()),t?.cursor&&(n.cursor=t.cursor.toString()),this.request(this.ky.get(`v1/orders/${e}`,{searchParams:n,signal:t?.signal}).json())}async getOrderById(e,t,n){return(await this.getOrdersByAddress(e,{orderIds:[t],signal:n?.signal})).data[0]??null}getOrder(e,t){return this.request(this.ky.get(`v1/orders/by-id/${e}`,{signal:t?.signal}).json())}trackOrder(e,t={}){let n=Math.max(Me,t.intervalMs??je);return new Promise((r,i)=>{let a=!1,o=null,s=()=>{o&&(clearTimeout(o),o=null),t.signal&&t.signal.removeEventListener(`abort`,c)},c=()=>{a||(a=!0,s(),i(new Z(`Order tracking was aborted`)))};if(t.signal){if(t.signal.aborted){c();return}t.signal.addEventListener(`abort`,c)}let l=async()=>{if(!a)try{let i=await this.getOrder(e,{signal:t.signal});if(a)return;if(t.onStatus?.(i),Fe.includes(i.status)){a=!0,s(),r(i);return}o=setTimeout(l,n)}catch(e){if(a)return;if(e instanceof Z){a=!0,s(),i(e);return}o=setTimeout(l,Ne)}};l()})}getTokens(e){let t={};return e?.q&&(t.q=e.q),e?.chainIds?.length&&(t.chainIds=e.chainIds.join(`,`)),e?.limit&&(t.limit=e.limit.toString()),e?.cursor&&(t.cursor=e.cursor.toString()),this.request(this.ky.get(`v1/tokens`,{searchParams:t,signal:e?.signal}).json())}searchTokens(e,t){let n={q:e};return t?.chainIds?.length&&(n.chainIds=t.chainIds.join(`,`)),this.request(this.ky.get(`v1/tokens/search`,{searchParams:n,signal:t?.signal}).json())}getTopTokens(e){let t={};return e?.chainIds?.length&&(t.chainIds=e.chainIds.join(`,`)),this.request(this.ky.get(`v1/tokens/top`,{searchParams:t,signal:e?.signal}).json())}getTokenBalances(e,t){let n={};return t?.chainIds?.length&&(n.chainIds=t.chainIds.join(`,`)),this.request(this.ky.get(`v1/tokens/balances/${e}`,{searchParams:n,signal:t?.signal}).json())}getTokenAutocomplete(e,t){let n={};return t?.chainIds?.length&&(n.chainIds=t.chainIds.join(`,`)),t?.limit&&(n.limit=t.limit.toString()),this.request(this.ky.get(`v1/tokens/autocomplete/${encodeURIComponent(e)}`,{searchParams:n,signal:t?.signal}).json())}getTokenAutocompleteSuggestions(e){return this.request(this.ky.get(`v1/tokens/autocomplete/suggestions`,{signal:e?.signal}).json())}getChains(e){return this.request(this.ky.get(`v1/chains`,{signal:e?.signal}).json())}getArcadiaConfig(e){return this.request(this.ky.get(`v1/config/arcadia`,{signal:e?.signal}).json())}getVaults(e){return this.request(this.ky.get(`v1/vaults`,{signal:e?.signal}).json())}getMTokens(e){return this.request(this.ky.get(`v1/mtokens`,{signal:e?.signal}).json())}getIntent(e,t){return this.request(this.ky.get(`v1/intent/${e}`,{signal:t?.signal}).json())}getIntentByDeposit(e,t){return this.request(this.ky.get(`v1/intent/deposit`,{searchParams:{chainId:e.chainId.toString(),txHash:e.txHash},signal:t?.signal}).json())}getIntentsByAuthor(e,t){let n={};return t?.limit&&(n.limit=t.limit.toString()),t?.cursor&&(n.cursor=t.cursor.toString()),t?.fromChainId&&(n.fromChainId=t.fromChainId.toString()),t?.toChainId&&(n.toChainId=t.toChainId.toString()),this.request(this.ky.get(`v1/intents/${e}`,{searchParams:n,signal:t?.signal}).json())}},Fe=[`filled`,`refunded`,`failed`],Ie=500,Le=700,Re=2e3,ze=500,Be=5e3;function Ve(e,t){let n=typeof window.outerWidth==`number`?window.outerWidth:0,r=typeof window.outerHeight==`number`?window.outerHeight:0,i=typeof window.screenX==`number`?window.screenX:0,a=typeof window.screenY==`number`?window.screenY:0,o=n>0?n:screen.width,s=r>0?r:screen.height,c=n>0?i:0,l=r>0?a:0;return`width=${e},height=${t},left=${Math.max(0,Math.round(c+(o-e)/2))},top=${Math.max(0,Math.round(l+(s-t)/2))}`}function He(e){return e===`completed`?`completed`:e===`canceled`?`canceled`:`failed`}function Ue(e,t,n={}){if(typeof window>`u`)return Promise.reject(new X(J.FIAT_CHECKOUT_UNAVAILABLE,`Fiat checkout requires a browser window`));let r=n.popup?.width??Ie,i=n.popup?.height??Le,a=n.minPollIntervalMs??Re,o=window.open(t.wrapperUrl,`tf-fiat-${t.orderId}`,Ve(r,i));if(!o||o.closed)return Promise.reject(new X(J.FIAT_POPUP_BLOCKED,`Payment popup was blocked by the browser`));let s;try{s=new URL(e.baseUrl).origin}catch{return o.close(),Promise.reject(new X(J.FIAT_CHECKOUT_UNAVAILABLE,`Fiat API base URL is malformed`))}return new Promise((r,i)=>{let c=!1,l=!1,u=null,d=null,f=()=>{window.removeEventListener(`message`,m),u&&(clearTimeout(u),u=null),d&&(clearInterval(d),d=null),n.signal&&n.signal.removeEventListener(`abort`,h)},p=async n=>{if(!c){c=!0,f();try{let i=await e.getStatus(t.orderId);o.closed||o.close(),r({orderId:t.orderId,finalStatus:i,outcome:n})}catch(e){o.closed||o.close(),i(e)}}},m=e=>{if(e.origin!==s)return;let r=e.data;if(!(!r||typeof r!=`object`||r.type!==`FIAT_WIDGET_EVENT`)&&!(r.orderId&&r.orderId!==t.orderId))switch(n.onEvent?.(r),r.event){case`widget_ready`:l=!0;break;case`order_completed`:p(`completed`);break;case`order_failed`:l&&p(`failed`);break;case`widget_close`:break}},h=()=>{o.closed||o.close(),p(`canceled`)};if(window.addEventListener(`message`,m),n.signal){if(n.signal.aborted){h();return}n.signal.addEventListener(`abort`,h)}d=setInterval(()=>{o.closed&&!c&&p(`canceled`)},ze);let g=async()=>{if(!c)try{let r=await e.getStatus(t.orderId);if(c)return;if(n.onStatus?.(r),r.polling.isTerminal){p(He(r.status));return}let i=Math.max(a,r.polling.suggestedIntervalMs);u=setTimeout(g,i)}catch{c||(u=setTimeout(g,Be))}};g()})}var We=`https://fiat.hyperstream.dev`,Ge=class{constructor(e){this.baseUrl=Te(e.baseUrl),this.ky=we({baseUrl:this.baseUrl,timeout:e.timeout,fetch:e.fetch,headers:e.headers})}request(e){return De(e,{timeoutMessage:`Fiat API request timed out`,failureMessage:`Fiat API request failed`})}getProviders(e){return this.request(this.ky.get(`v1/fiat/providers`,{signal:e?.signal}).json())}getQuote(e,t){return this.request(this.ky.post(`v1/fiat/quote`,{json:e,signal:t?.signal}).json())}createOrder(e,t){return this.request(this.ky.post(`v1/fiat/order`,{json:e,signal:t?.signal}).json())}getStatus(e,t){let n=t?.force?{force:`1`}:void 0;return this.request(this.ky.get(`v1/fiat/status/${e}`,{signal:t?.signal,searchParams:n}).json())}startCheckout(e,t){return Ue(this,e,t)}getOrdersByAddress(e,t){let n={};return t?.status&&(n.status=t.status),t?.limit&&(n.limit=t.limit.toString()),t?.cursor&&(n.cursor=t.cursor.toString()),this.request(this.ky.get(`v1/fiat/orders/${e}`,{searchParams:n,signal:t?.signal}).json())}};function Ke(e,t){if(e)return`${e.replace(/\/$/,``)}/v1/chain/${t}/icon`}var qe=new Set([`completed`,`failed`,`canceled`]);export{We as a,Y as c,c as d,Fe as i,Ae as l,qe as n,Ge as o,Pe as r,X as s,Ke as t,J as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=e=>`Pay ${e.amount}`,ee=`Waiting for confirmation...`,te=`View on Explorer`,t=`Delivery unsuccessful`,n=`Select Fiat Provider`,r=`Enter amount`,i=e=>`${e.count} more`,a=`Order expired`,o=e=>`Pay ${e.amount} via ${e.provider}`,s=`Copied`,c=`We'll find the best rate for you`,l=e=>`Continue via ${e.provider}`,u=`Try selecting a different chain or search for a specific token`,d=`Coming soon`,f=e=>`via ${e.provider}`,p=`Search results`,m=`Tokens delivered to your wallet`,h=`You pay`,g=`Your tokens have been delivered`,_=e=>`≈ $${e.formatUsd}`,v=`Recipient Address`,y=`Confirm`,b=`Connect your wallet to see payment options`,x=`No tokens found`,S=`Connect wallet or enter an address to get a quote`,C=`Confirm in your wallet...`,w=`Refund tx`,T=e=>`Buy ${e.amt} ${e.sym}`,E=`Exchange`,D=`Swapping via DEX...`,O=`Transaction failed — Retry`,k=`No filler accepted the order`,A=`Back`,ne=`Pay`,j=`Executing...`,M=`Select destination token`,N=e=>`Filled on ${e.chain}`,P=`Payment confirmed`,re=`Buy`,F=`Close`,I=`Payment QR code`,L=`No offer available`,R=`Refund in progress`,z=e=>`Deposit on ${e.chain}`,B=`Route`,V=`Crypto`,H=`Signed in wallet`,U=`Order failed`,W=`Enter amount to get started`,G=`Recipient`,K=e=>`≈ $${e.addThousandsSeparator}`,q=`Buy with credit or debit card`,J=`View All Chains`,Y=`Swap`,X=`Sender`,Z=`Processing your order...`,Q=`Select payment token`,ie=e=>`Via ${e.provider}`,ae=`Quote details`,oe=`Total fee`,se=`Paid`,ce=`Try Again`,le=`Review Swap`,ue=`Provider filling your order`,de=`Swapping tokens`,fe=`Your tokens`,pe=e=>`Returning tokens on ${e.chain}`,me=`Card`,he=`Swap tokens`,ge=`Copy error`,_e=`Fiat payment`,ve=`Processing...`,ye=`Purchase failed`,be=`New Purchase`,xe=`This browser cannot open the payment window. Scan the QR code or copy the link to continue.`,Se=`Pay with credit or debit card`,$=`Confirmed on-chain`,Ce=`Sign in wallet`,we=`From`,Te=`Required to receive your tokens`,Ee=`MAX`,De=`Fee`,Oe=`Could not be completed`,ke=`Copy link`,Ae=`Top tokens`,je=`Fill tx`,Me=e=>`Delivered in ${e.seconds}s`,Ne=`Pay with`,Pe=`Swap Successful`,Fe=`Tokens delivered`,Ie=`Receive`,Le=`Min`,Re=`Search by name or address`,ze=e=>`~${e.value}s`,Be=`0`,Ve=`Provider`,He=`Est. time`,Ue=`Insufficient balance`,We=`Invalid address for this chain`,Ge=`Enter destination address`,Ke=`No tokens available`,qe=`Open payment link`,Je=`Max`,Ye=`Transfer tx`,Xe=`Confirm Swap`,Ze=`This token is not directly available for card purchase. We buy USDC first, then swap it to your desired token automatically.`,Qe=`Quote Failed`,$e=e=>`Compare ${e.count} more providers`,et=e=>`Buy ${e.arg0} directly`,tt=e=>`on ${e.chain}`,nt=e=>`~${e.value}m`,rt=`No routes available`,it=`Tokens Landed!`,at=`Awaiting payment`,ot=e=>`Routed through ${e.token} for the best rate`,st=`New Swap`,ct=`Enter recipient address`,lt=`Wallet doesn't match source chain`,ut=`View`,dt=`BEST RATE`,ft=`Your order could not be completed.`,pt=e=>`Delivering ${e.symbol} to your wallet...`,mt=`Your funds have been returned to your wallet.`,ht=`View quote details`,gt=`Signature submitted`,_t=`Deposit tx`,vt=`Connect Wallet`,yt=`Pay with tokens from your wallet`,bt=`Cancel order`,xt=`You receive`,St=`Purchase Complete`,Ct=`Selected token is unavailable for this purchase`,wt=`Enter Recipient Address`,Tt=`Recommended`,Et=`Wallet account`,Dt=e=>`Balance: ${e.fromBalance}`,Ot=`Purchase complete`,kt=`Retry`,At=`Select token`,jt={"10189s3":e,"10ioi7e":ee,"10v0i5g":te,"115lknq":t,"118a77s":n,"119fv83":r,"11k1vkl":i,"12rrl0i":a,"132vna6":o,"13bzcw5":s,"13i9oqu":c,"13l4n4r":l,"13x5i2v":u,"14ho4vt":d,"14j1lze":f,"15bw477":p,"1685rko":m,"17kq51m":h,"17wtaao":g,"188897k":_,"18cmny0":v,"18tbqwf":y,"18y1lrp":b,"19is1h8":x,"19ne1ha":S,"1bze7sg":C,"1c5n7ll":w,"1cei180":T,"1dyojgg":E,"1g8tdk7":D,"1hb73om":O,"1hdpo6q":k,"1hzmxtu":A,"1i7coq1":`Pay`,"1ih47b3":j,"1ix1b7w":M,"1ixbbo7":N,"1jhuo24":P,"1ka8utn":`Buy`,"1l0xxoj":F,"1ndiott":I,"1ne9nkz":L,"1nhkl7x":R,"1nn0owb":z,"1nvxkfy":B,"1o1b4a8":V,"1o4ofyx":H,"1ok4m5g":U,"1olegnl":W,"1oncz6g":G,"1ovj1tk":K,"1q45kup":q,"1qbiehv":J,"1rkfalq":Y,"1rnxx1g":X,"1spu5st":Z,"1t0r88u":Q,"1t86tnu":ie,"1tn6f91":ae,"1viukn9":oe,"1w0n607":se,"1w68n16":ce,"1x5xdes":le,"1y28pgi":ue,"1y6hn5o":de,"1yijk6g":fe,"27fhcv":pe,"2b8ghr":me,"2eikro":he,"2mzna2":ge,"2zh3gr":_e,"344av8":ve,"3pklqf":ye,"3u5vqs":be,"53b4uu":xe,"6c0jc7":Se,"6c5l2f":$,"6gkge0":Ce,"6s9hn9":we,"7m2ht3":Te,"7v6g6x":`MAX`,"9l4mg3":`Fee`,"9p7amh":Oe,"9zccf0":ke,bdctly:Ae,bdo3n8:je,biwlqk:Me,cgzgvn:Ne,cjn1xs:Pe,cnwfg3:Fe,cwk7r6:Ie,cx9lh3:`Min`,dizog6:Re,ek03j3:ze,epw9f3:`0`,evz7q4:Ve,f45rwo:He,fcy4ey:Ue,fo0vw0:We,fpand1:Ge,g7pjpv:Ke,gnnylt:qe,gtvgs9:`Max`,hzq69q:Ye,ibrnk6:Xe,ifug2i:Ze,jf8ts4:Qe,jmpbi6:$e,jnzipx:et,k47stp:tt,knrcsh:nt,ln9xiv:rt,mnlddk:it,n9zkql:at,ofi1rq:ot,pmqvh0:st,pom1h2:ct,q4mqcd:lt,q5w460:ut,r7v9s7:dt,rvctng:ft,sykid7:pt,t1rvqg:mt,tbygoy:ht,tgp8yw:gt,tjg3i3:_t,u61kge:vt,udneg1:yt,uu5nf7:bt,va18uh:xt,vum0cd:St,wuxjl9:Ct,wx5bee:wt,xel5qk:Tt,xphk5n:Et,y6jqu9:Dt,yhtv6l:Ot,zkouah:kt,zz4mrw:At};export{Xe as _100907z,xt as _108j3sk,se as _10lgc56,X as _10n9ta8,h as _113vzpe,ct as _11ncipg,V as _11p3b1r,rt as _12qyh2x,R as _13ym6k2,me as _14oyo32,Ae as _15iyda3,S as _15vbpgm,xe as _15xhlup,s as _16j2pbi,Ze as _16ln1wz,Pe as _16pzx0g,Oe as _16rump9,M as _17g2rjk,_ as _18346vt,re as _1982g2x,Et as _1biskvr,D as _1bjtgx1,Fe as _1cmz8k7,yt as _1cpadi9,K as _1d7sodl,lt as _1e023il,u as _1e5aqjt,z as _1ea99j0,te as _1f4czmp,$ as _1f8nqa3,le as _1f8umlr,G as _1fe46d3,Te as _1fikhaa,st as _1fu9qvd,E as _1g7ofg0,Ne as _1gfjrn0,Me as _1gma9hv,pe as _1hs819x,gt as _1ht75o0,t as _1i8i0au,$e as _1i9sfkh,F as _1ib6ekl,q as _1ievltk,dt as _1in1gel,W as _1in9ocp,Ge as _1ju6xlj,T as _1jvje3y,De as _1kd3yrp,A as _1kez60s,de as _1krtsvx,ot as _1kvlpuf,Se as _1l1rqi2,Y as _1l2nmmx,ne as _1lra4kg,ht as _1mmcyfz,Ct as _1n1igys,O as _1na1vy4,ge as _1nd7gbf,o as _1nwhws6,ze as _1o0vi1j,Ye as _1o2h7a2,l as _1o8feo7,Ke as _1om32zr,w as _1oqs23j,ke as _1ovibcu,kt as _1popw3r,ee as _1qamgmj,B as _1rggu8s,nt as _1s54fdc,c as _1s9ryeq,Ce as _1t3gki9,i as _1ulsa90,m as _1urf8wf,n as _1w2bswr,N as _1wwy4yj,e as _1wx2fw2,pt as _1y7hba4,x as _1yv1ajq,wt as _3mtvnb,Ve as _3w8t28,Q as _41y3qp,J as _454sub,ut as _49235i,U as _4itr6p,H as _4opuqb,_e as _5af8qp,y as _5r87wo,b as _78b61s,we as _8edkty,je as _a5vz6z,Re as _al7a0k,Ee as _bii6w9,Be as _cnghfj,j as _czpegb,_t as _d7bf51,Qe as _doc1yy,bt as _ftpidr,L as _g3pfjv,at as _gkmqsa,f as _hyiyqa,d as _i9ury1,v as _ide9vv,vt as _ig1w2,Dt as _jpt8np,oe as _kmeu9o,ue as _kqdlbv,Tt as _l5s0fl,et as _l78r94,fe as _l800fy,g as _ly147p,Ie as _mdvri5,qe as _nb1pp5,Z as _np8jou,I as _nq4mpy,a as _nrzzox,tt as _o3um2w,P as _oj2fr8,St as _p5ybee,k as _pqml54,ye as _pr6lte,ve as _q0rsrj,mt as _qm85b2,p as _r3yix2,C as _sf0mgy,At as _si8n6l,Je as _swoaip,Ot as _t0vnn4,ie as _t91lwj,We as _ty2nen,ft as _u7tj7p,He as _uc0jju,r as _uu4paz,it as _vogk37,ae as _wa8i8c,ce as _xavgbs,he as _xkdtbf,be as _ystooe,Le as _z6jr7i,Ue as _zzusn5,jt as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as e,u as t}from"./dist-CsBuWseE.js";var n={...t,INVALID_CONFIG:`TF1001`,INVALID_TOKEN_IDENTIFIER:`TF1002`,INVALID_AMOUNT:`TF1003`,WALLET_CONNECTION_FAILED:`TF2002`,WALLET_ACTION_FAILED:`TF2003`,TRANSACTION_FAILED:`TF4001`,ELEMENT_NOT_FOUND:`TF5001`},r={[n.INVALID_CONFIG]:`Invalid configuration provided`,[n.INVALID_TOKEN_IDENTIFIER]:`Invalid token identifier format`,[n.INVALID_AMOUNT]:`Invalid amount value`,[n.WALLET_CONNECTION_FAILED]:`Failed to connect wallet`,[n.WALLET_ACTION_FAILED]:`Wallet action failed`,[n.TRANSACTION_FAILED]:`Transaction failed`,[n.ELEMENT_NOT_FOUND]:`Target DOM element not found`};({...e,...r});export{n as t};
|
package/dist/iframe-entry.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{S as e,m as t,o as n,p as r,u as i,v as a}from"./solid-
|
|
1
|
+
import{S as e,m as t,o as n,p as r,u as i,v as a}from"./solid-DqvEpdeb.js";import{h as o,l as s,n as c,r as l,u}from"./shared.module-Bs-BN_nM.js";import{i as d,o as f,r as p,t as m}from"./theme-B6YtpkRW.js";import{n as h,t as g}from"./widget-B0OLriHf.js";import{n as _,r as v,t as y}from"./iframe-receiver-i4RfQGg2.js";function b(e=document){return e.querySelector(`[data-widget-root="stable"]`)??e.querySelector(`[part="container"]`)}function x(e,t=document){let n=()=>{let n=b(t);return n?(e.observeResize(n),!0):!1};if(n())return;let r=new MutationObserver(()=>{n()&&r.disconnect()});r.observe(document.body,{childList:!0,subtree:!0})}var S=o(`<div style="position:fixed;top:12px;left:50%;transform:translateX(-50%);z-index:9999;padding:6px 12px;border-radius:999px;background:color-mix(in srgb, var(--tf-primary) 15%, transparent);color:var(--tf-primary);border:1px solid color-mix(in srgb, var(--tf-primary) 35%, transparent);font-family:'DM Sans', sans-serif;font-size:11px;font-weight:600;letter-spacing:0.03em;user-select:none;pointer-events:none">Standalone preview · embed via <tokenflight-iframe-widget>`),C=o(`<div style="color:#95a8c4;font-family:'DM Sans', sans-serif;font-size:13px;text-align:center;padding-top:60px">Waiting for host bridge…`);function w(e={}){if(typeof window>`u`)return()=>{};E(),D();let t=T(e.target);if(!t)return()=>{};let n=e.queryClient??c,r=u(()=>i(P,{queryClient:n}),t);return()=>r()}function T(e){return typeof e==`string`?document.querySelector(e):e||document.getElementById(`root`)}function E(){if(!g||document.querySelector(`style[data-tokenflight-widget]`))return;let e=document.createElement(`style`);e.setAttribute(`data-tokenflight-widget`,``),e.textContent=g,document.head.appendChild(e)}function D(){if(document.querySelector(`style[data-tokenflight-flat]`))return;let e=document.createElement(`style`);e.setAttribute(`data-tokenflight-flat`,``),e.textContent=`
|
|
2
2
|
html, body {
|
|
3
3
|
margin: 0;
|
|
4
4
|
padding: 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e,i as t,n,o as r,r as i}from"./protocol-
|
|
1
|
+
import{a as e,i as t,n,o as r,r as i}from"./protocol-B7S8LSlJ.js";import{n as a}from"./active-bridge-hZx8_r6Y.js";var o=12e4,s=6e4,c=class{constructor(t){this.name=`IframeBridge`,this.supportedActionTypes=[`eip1193_request`,`solana_signTransaction`,`solana_signAndSendTransaction`],this.connected=!1,this.address=null,this.lastWalletSeq=0,this.eventListeners=new Map,this.pendingRequests=new Map,this.pendingConnect=null,this.pendingDisconnect=null,this.destroyed=!1,this.handleMessage=t=>{if(this.destroyed||t.origin!==this.hostOrigin)return;let n=r(t.data);n&&(e(n,`tf:walletState`)?this.handleWalletState(n.payload,n.seq):e(n,`tf:signResult`)&&this.handleSignResult(n.payload.requestId,n.payload.result,n.payload.error))},this.hostOrigin=t,window.addEventListener(`message`,this.handleMessage)}async connect(e){return this.postToHost(n(`connectWallet`,{chainType:e})),new Promise((e,t)=>{this.pendingConnect={resolve:e,reject:t},setTimeout(()=>{this.pendingConnect&&(this.pendingConnect.reject(Error(`Wallet connection timed out`)),this.pendingConnect=null)},s)})}async disconnect(){return this.postToHost(n(`disconnectWallet`,{})),new Promise((e,t)=>{this.pendingDisconnect={resolve:e,reject:t},setTimeout(()=>{this.pendingDisconnect&&(this.pendingDisconnect.reject(Error(`Wallet disconnect timed out`)),this.pendingDisconnect=null)},s)})}isConnected(e){return this.connected}async getAddress(e){return this.address}async executeWalletAction(e){let t=i();return new Promise((r,i)=>{let a=setTimeout(()=>{this.pendingRequests.delete(t),i(Error(`Wallet action timed out`))},o);this.pendingRequests.set(t,{resolve:r,reject:i,timer:a}),this.postToHost(n(`signRequest`,{requestId:t,action:e}))})}on(e,t){let n=this.eventListeners.get(e);n||(n=new Set,this.eventListeners.set(e,n)),n.add(t)}off(e,t){this.eventListeners.get(e)?.delete(t)}destroy(){if(!this.destroyed){this.destroyed=!0,window.removeEventListener(`message`,this.handleMessage);for(let[,e]of this.pendingRequests)clearTimeout(e.timer),e.reject(Error(`Bridge destroyed`));this.pendingRequests.clear(),this.pendingConnect&&(this.pendingConnect.reject(Error(`Bridge destroyed`)),this.pendingConnect=null),this.pendingDisconnect&&(this.pendingDisconnect.reject(Error(`Bridge destroyed`)),this.pendingDisconnect=null),this.eventListeners.clear()}}setInitialState(e,t,n){this.connected=e,this.address=t,this.chainType=n}handleWalletState(e,t){if(t<=this.lastWalletSeq)return;this.lastWalletSeq=t;let n=this.connected;this.connected=e.connected,this.address=e.address,e.chainType&&(this.chainType=e.chainType),e.connected&&this.pendingConnect&&(this.pendingConnect.resolve(),this.pendingConnect=null),!e.connected&&this.pendingDisconnect&&(this.pendingDisconnect.resolve(),this.pendingDisconnect=null),e.event?this.emit(e.event,{type:e.event,data:e}):e.connected&&!n?this.emit(`connect`,{type:`connect`,data:e}):!e.connected&&n?this.emit(`disconnect`,{type:`disconnect`,data:e}):e.connected&&this.emit(`accountsChanged`,{type:`accountsChanged`,data:e})}handleSignResult(e,n,r){let i=this.pendingRequests.get(e);i&&(this.pendingRequests.delete(e),clearTimeout(i.timer),r?i.reject(t(r)):n?i.resolve(n):i.reject(Error(`Invalid sign result: missing both result and error`)))}postToHost(e){this.destroyed||typeof window>`u`||!window.parent||window.parent.postMessage(e,this.hostOrigin)}emit(e,t){let n=this.eventListeners.get(e);if(n)for(let e of n)try{e(t)}catch{}}},l=`__TF_VERSION__`,u=class{constructor(t,i){this.destroyed=!1,this.resizeObserver=null,this.lastReportedHeight=0,this.popupClosedHandlers=new Set,this.popupBlockedHandlers=new Set,this.providerEventHandlers=new Set,this.handleMessage=t=>{if(this.destroyed||t.origin!==this.hostOrigin)return;let n=r(t.data);if(n){if(e(n,`tf:init`))this.handleInit(n.payload);else if(e(n,`tf:setConfig`))this.callbacks.onConfigUpdate(n.payload);else if(e(n,`tf:setStyle`))this.callbacks.onStyleUpdate(n.payload);else if(e(n,`tf:fiatPopupClosed`)){let e=n.payload.orderId;this.callbacks.onFiatPopupClosed?.(e);for(let t of this.popupClosedHandlers)t(e)}else if(e(n,`tf:fiatPopupBlocked`)){let e=n.payload.orderId;this.callbacks.onFiatPopupBlocked?.(e);for(let t of this.popupBlockedHandlers)t(e)}else if(e(n,`tf:fiatProviderEvent`)){let e=n.payload;this.callbacks.onFiatProviderEvent?.(e);for(let t of this.providerEventHandlers)t(e)}}},this.hostOrigin=t,this.callbacks=i,this.walletAdapter=new c(t),window.addEventListener(`message`,this.handleMessage),a(this.getFiatBridge()),this.postToHost(n(`ready`,{version:l,protocolVersion:1}))}getFiatBridge(){return{requestPreOpenPopup:()=>this.requestPreOpenPopup(),requestNavigatePopup:(e,t)=>this.requestNavigatePopup(e,t),requestClosePopup:e=>this.requestClosePopup(e),onPopupClosed:e=>(this.popupClosedHandlers.add(e),()=>this.popupClosedHandlers.delete(e)),onPopupBlocked:e=>(this.popupBlockedHandlers.add(e),()=>this.popupBlockedHandlers.delete(e)),onProviderEvent:e=>(this.providerEventHandlers.add(e),()=>this.providerEventHandlers.delete(e))}}observeResize(e){this.resizeObserver=new ResizeObserver(e=>{let t=e[0];if(!t)return;let r=Math.ceil(t.borderBoxSize?.[0]?.blockSize??t.contentRect.height);Math.abs(r-this.lastReportedHeight)<2||(this.lastReportedHeight=r,this.postToHost(n(`resize`,{height:r})))}),this.resizeObserver.observe(e)}emitEvent(e,t){this.postToHost(n(`event`,{name:e,data:t}))}requestPreOpenPopup(){this.postToHost(n(`preOpenPopup`,{}))}requestNavigatePopup(e,t){this.postToHost(n(`navigatePopup`,{url:e,orderId:t}))}requestClosePopup(e){this.postToHost(n(`closeFiatPopup`,{orderId:e}))}destroy(){this.destroyed||(this.destroyed=!0,window.removeEventListener(`message`,this.handleMessage),this.walletAdapter.destroy(),this.popupClosedHandlers.clear(),this.popupBlockedHandlers.clear(),this.providerEventHandlers.clear(),a(null),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null))}handleInit(e){this.walletAdapter.setInitialState(e.connected??!1,e.walletAddress??null,e.chainType),this.callbacks.onInit(e.config,e.style)}postToHost(e){this.destroyed||window.parent.postMessage(e,this.hostOrigin)}};function d(){try{return window!==window.top}catch{return!0}}function f(){if(!d())return null;try{if(document.referrer)return new URL(document.referrer).origin}catch{}return null}export{c as i,f as n,d as r,u as t};
|