@imtbl/sdk 1.20.3-alpha → 1.20.4

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.
Files changed (37) hide show
  1. package/dist/blockchain_data.js +2 -2
  2. package/dist/browser/checkout/{BridgeWidget-e433c650.js → BridgeWidget-764186df.js} +1 -1
  3. package/dist/browser/checkout/{HorizontalMenu-actual-c339d259.js → HorizontalMenu-actual-f804d6c1.js} +1 -1
  4. package/dist/browser/checkout/{OnRampWidget-791b2c23.js → OnRampWidget-d202910b.js} +1 -1
  5. package/dist/browser/checkout/{SaleWidget-b8d7781a.js → SaleWidget-21a0da95.js} +1 -1
  6. package/dist/browser/checkout/{SpendingCapHero-dd5b1386.js → SpendingCapHero-4cf86bc9.js} +1 -1
  7. package/dist/browser/checkout/{SwapWidget-a77d1670.js → SwapWidget-fa573621.js} +1 -1
  8. package/dist/browser/checkout/{TopUpView-dbf35ba5.js → TopUpView-20c59619.js} +1 -1
  9. package/dist/browser/checkout/{WalletWidget-2705fff8.js → WalletWidget-a7dae882.js} +1 -1
  10. package/dist/browser/checkout/{auto-track-236dc818.js → auto-track-47f8ae7b.js} +1 -1
  11. package/dist/browser/checkout/{balance-643231e9.js → balance-13198af0.js} +1 -1
  12. package/dist/browser/checkout/{index-e3a0f33f.js → index-394d516d.js} +2 -2
  13. package/dist/browser/checkout/{index-d7add53c.js → index-6707b5f0.js} +1 -1
  14. package/dist/browser/checkout/{index-e906b328.js → index-760c2a62.js} +1 -1
  15. package/dist/browser/checkout/{index-6e098a9e.js → index-761d51ab.js} +1 -1
  16. package/dist/browser/checkout/{index-b9730d0c.js → index-800f3b79.js} +1 -1
  17. package/dist/browser/checkout/{index-c8393089.js → index-8b5981fa.js} +1 -1
  18. package/dist/browser/checkout/{index-69e9466c.js → index-9daeacd3.js} +1 -1
  19. package/dist/browser/checkout/index-c8504cfe.js +1 -0
  20. package/dist/browser/checkout/{index.umd-b2990cfb.js → index.umd-cbd7b2eb.js} +1 -1
  21. package/dist/browser/checkout/{retry-c8740b81.js → retry-ce6e6559.js} +1 -1
  22. package/dist/browser/checkout/sdk.js +4 -4
  23. package/dist/browser/checkout/widgets-esm.js +1 -1
  24. package/dist/browser/checkout/widgets.js +1 -1
  25. package/dist/checkout.d.ts +4 -2
  26. package/dist/checkout.js +4 -4
  27. package/dist/config.js +1 -1
  28. package/dist/index.browser.js +5 -5
  29. package/dist/index.browser.js.map +1 -1
  30. package/dist/index.cjs +41 -32
  31. package/dist/index.d.ts +4 -2
  32. package/dist/index.js +42 -33
  33. package/dist/orderbook.js +1 -1
  34. package/dist/passport.js +40 -31
  35. package/dist/x.js +3 -3
  36. package/package.json +1 -1
  37. package/dist/browser/checkout/index-01833964.js +0 -1
@@ -1,2 +1,2 @@
1
- import{a2 as e,a3 as t,a4 as n,a5 as a,a6 as s,r as i,a as r,a7 as o,a8 as d,j as l,a9 as c,aa as u,B as _,ab as h,b as f,ac as m,ad as p,c as g,p as E,ae as w,af as T,ag as b,ah as y,ai as v,aj as A,ak as k,y as C,al as I,V as S,d as R,am as x,u as O,C as N,an as D,ao as U,h as L,g as F,I as M,ap as z,a0 as P,aq as B,ar as W,as as H,E as K,at as V,au as Z,av as G,aw as Y,ax as X,M as j,H as $,t as q,ay as J,az as Q,aA as ee,z as te,G as ne,J as ae,e as se,U as ie,aB as re,aC as oe,aD as de,aE as le,aF as ce,aG as ue,aH as _e,Y as he,S as fe,aI as me,aJ as pe,aK as ge,_ as Ee,$ as we,aL as Te}from"./index-e3a0f33f.js";import be from"./BridgeWidget-e433c650.js";import{O as ye,u as ve}from"./OnRampWidget-791b2c23.js";import Ae from"./SwapWidget-a77d1670.js";import{C as ke,a as Ce,T as Ie,b as Se}from"./TopUpView-dbf35ba5.js";import{H as Re}from"./HorizontalMenu-actual-c339d259.js";import"./retry-c8740b81.js";import"./balance-643231e9.js";import"./SpendingCapHero-dd5b1386.js";var xe={d:"flex",flexWrap:"wrap",justifyContent:"flex-start",alignItems:"center",width:"100%",minHeight:"base.spacing.x16",p:"base.spacing.x4",columnGap:"base.spacing.x2",rowGap:"base.spacing.x4",paddingLeft:"base.spacing.x14",position:"relative",boxShadow:"base.shadow.300",brad:"base.borderRadius.x6"},Oe={display:"flex",gap:"base.spacing.x2",ml:"auto"},Ne=function(e){switch(e){case"success":case"fatal":case"guidance":case"attention":case"destructive":return{bg:"base.color.status.".concat(e,".dim")};default:return{bg:"base.color.neutral.500"}}},De=function(e,t){return"lightOnDark"===t.base.colorMode&&!("standard"===e)},Ue="standard",Le=["children","size","weight","variant","className","sx"];function Fe(n){var a=n.children,s=n.size,i=void 0===s?"medium":s,d=n.weight,l=n.variant,u=void 0===l?Ue:l,_=n.className,h=n.sx,m=void 0===h?{}:h,p=e(n,Le),g=t(),E=De(u,g),w=o({c:E?"base.color.text.body.inverse.primary":"base.color.text.body.primary"},m);return r(f,c(c({},p),{},{size:i,weight:d,sx:w,className:"".concat(null!=_?_:""," BannerCaption"),children:a}))}Fe.displayName="Banner.Caption";var Me=["sx","variant","iconVariant","className"];function ze(t){var n=t.sx,a=void 0===n?{}:n,s=t.variant,i=void 0===s?Ue:s,d=t.iconVariant,l=t.className,u=e(t,Me),_=m(),h=De(i,_);return r(p,c(c({},u),{},{variant:d,className:"".concat(null!=l?l:""," BannerIcon"),sx:o({position:"absolute",top:"base.spacing.x4",left:"base.spacing.x4",width:"base.icon.size.300",fill:h?"base.color.text.body.inverse.primary":"base.color.text.body.primary"},a)}))}ze.displayName="Banner.Icon";var Pe=["variant","bannerVariant","className"];function Be(n){var a=n.variant,s=void 0===a?"tertiary":a,i=n.bannerVariant,o=void 0===i?Ue:i,d=n.className,l=e(n,Pe),u=t(),_=De(o,u);return r(g,c(c({},l),{},{size:"small",variant:_?"".concat(s,"/inverse"):s,className:"".concat(null!=d?d:""," BannerRightButtCon")}))}Be.displayName="Banner.RightButtCon";var We=["variant","bannerVariant","className"];function He(n){var a=n.variant,s=void 0===a?"tertiary":a,i=n.bannerVariant,o=void 0===i?Ue:i,d=n.className,l=e(n,We),u=t(),_=De(o,u);return r(E,c(c({},l),{},{size:"small",variant:_?"".concat(s,"/inverse"):s,className:"".concat(null!=d?d:""," BannerRightButton")}))}He.displayName="Banner.RightButton";var Ke=["children","size","weight","variant","className","sx"];function Ve(n){var a=n.children,s=n.size,i=void 0===s?"medium":s,d=n.weight,l=void 0===d?"bold":d,u=n.variant,_=void 0===u?Ue:u,h=n.className,m=n.sx,p=void 0===m?{}:m,g=e(n,Ke),E=t(),w=De(_,E),T=o({color:w?"base.color.text.body.inverse.primary":"base.color.text.body.primary"},p);return r(f,c(c({},g),{},{size:i,weight:l,sx:T,className:"".concat(null!=h?h:""," BannerTitle"),children:a}))}var Ze,Ge,Ye,Xe,je,$e=["children","variant","sx","testId","forceMultilineText","domRef","className"];function qe(f){var m,p=f.children,g=f.variant,E=void 0===g?Ue:g,w=f.sx,T=void 0===w?{}:w,b=f.testId,y=void 0===b?"banner":b,v=f.forceMultilineText,A=f.domRef,k=void 0===A?{current:null}:A,C=f.className,I=e(f,$e),S=t(),R=n(k),x=a(p,ze),O=a(p,Ve),N=a(p,Fe),D=s(p,[ze,Ve,Fe]).otherChildren,U=i.useMemo((function(){switch(E){case"fatal":return r(ze,{icon:"CloseWithCircle",iconVariant:"bold"});case"attention":case"destructive":return r(ze,{icon:"Alert",iconVariant:"bold"});case"guidance":return r(ze,{icon:"InformationCircle",iconVariant:"bold"});case"success":return r(ze,{icon:"TickWithCircle",iconVariant:"bold"});default:return x||r(ze,{icon:"InformationCircle",iconVariant:"bold"})}}),[x,E]),L=i.useMemo((function(){var e,t;return o(xe,Ne(E),null!==(e=null===(t=S.components)||void 0===t||null===(t=t.Banner)||void 0===t?void 0:t.sxOverride)&&void 0!==e?e:{},T)}),[T,null===(m=S.components)||void 0===m||null===(m=m.Banner)||void 0===m?void 0:m.sxOverride,E]),F={top:d(R).height>64?"16px":"19px"};return l(_,c(c({},I),{},{sx:L,testId:y,domRef:R,className:"".concat(null!=C?C:""," Banner Banner--").concat(E),children:[r(u,{variant:E,testId:U.props.testId?U.props.testId:"".concat(y,"__icon"),sx:U.props.sx?o(F,U.props.sx):F,children:U}),l(_,{sx:c({d:"flex"},v?{flexDirection:"column"}:{flexWrap:"wrap",columnGap:"base.spacing.x2"}),className:"innerTextContainer",children:[r(u,{variant:E,testId:"".concat(y,"__title"),children:O}),r(u,{variant:E,testId:"".concat(y,"__caption"),children:N})]}),D||Array.isArray(D)&&D.length?r(_,{className:"rightButtonsContainer",testId:"".concat(y,"__rightHandButtons"),sx:Oe,children:i.Children.map(D,(function(e){var t=h(e,Be);return h(e,He)||t?r(u,{bannerVariant:E,testId:"".concat(y,t?"__rightButtCon":"__rightButton"),children:e}):e}))}):null]}))}qe.displayName="Banner",qe.Icon=ze,qe.Title=Ve,qe.Caption=Fe,qe.RightButton=He,qe.RightButtCon=Be,function(e){e.PAYMENT_METHODS="PAYMENT_METHODS",e.PAY_WITH_COINS="PAY_WITH_COINS",e.PAY_WITH_CARD="PAY_WITH_CARD",e.FUND_WITH_SMART_CHECKOUT="FUND_WITH_SMART_CHECKOUT",e.SALE_SUCCESS="SALE_SUCCESS",e.SALE_FAIL="SALE_FAIL"}(Ze||(Ze={})),function(e){e.INIT="INIT",e.LOADING="LOADING",e.FUNDING_ROUTE_SELECT="FUNDING_ROUTE_SELECT",e.FUNDING_ROUTE_EXECUTE="FUNDING_ROUTE_EXECUTE"}(Ge||(Ge={})),function(e){e.DEFAULT="DEFAULT_ERROR",e.INVALID_PARAMETERS="INVALID_PARAMETERS",e.TRANSACTION_FAILED="TRANSACTION_FAILED",e.SERVICE_BREAKDOWN="SERVICE_BREAKDOWN",e.PRODUCT_NOT_FOUND="PRODUCT_NOT_FOUND",e.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",e.TRANSAK_FAILED="TRANSAK_FAILED",e.WALLET_FAILED="WALLET_FAILED",e.WALLET_REJECTED="WALLET_REJECTED",e.WALLET_REJECTED_NO_FUNDS="WALLET_REJECTED_NO_FUNDS",e.WALLET_POPUP_BLOCKED="WALLET_POPUP_BLOCKED",e.SMART_CHECKOUT_ERROR="SMART_CHECKOUT_ERROR",e.SMART_CHECKOUT_EXECUTE_ERROR="SMART_CHECKOUT_EXECUTE_ERROR"}(Ye||(Ye={})),function(e){e.FRACTIONAL_BALANCE_BLOCKED="FRACTIONAL_BALANCE_BLOCKED"}(Xe||(Xe={})),function(e){e.CRYPTO="crypto",e.FIAT="fiat"}(je||(je={}));const Je={[w.SANDBOX]:"https://api.sandbox.immutable.com/v1/primary-sales",[w.PRODUCTION]:"https://api.immutable.com/v1/primary-sales"};var Qe;!function(e){e.CONTRACT_ADDRESS="contract_address",e.CURRENCY_SYMBOL="currency_symbol"}(Qe||(Qe={}));const et=e=>{const{provider:t,items:n,recipientAddress:a,environment:s,environmentId:r}=e,[o,d]=i.useState(void 0),[l,c]=i.useState(void 0),[u,_]=i.useState({done:!1,transactions:[]}),[h,f]=i.useState([]),m=()=>_((e=>({...e,done:!0}))),p=()=>_({done:!1,transactions:[]}),g=i.useCallback((async(e,n,a,s,i)=>{let r;try{const d=t?.getSigner(),l=await(t?.getGasPrice()),c=await(d?.sendTransaction({to:e,data:n,gasPrice:l,gasLimit:a}));return o={method:s,hash:c?.hash},_((e=>({...e,transactions:[...e.transactions,o]}))),i&&await(c?.wait()),r=c?.hash||"",[r,void 0]}catch(e){const t=`${e?.reason||e?.message||""}`.toLowerCase();r=e?.transactionHash;let n=Ye.WALLET_FAILED;return t.includes("failed")&&t.includes("open confirmation")&&(n=Ye.WALLET_POPUP_BLOCKED),t.includes("rejected")&&t.includes("user")&&(n=Ye.WALLET_REJECTED),t.includes("failed to submit")&&t.includes("highest gas limit")&&(n=Ye.WALLET_REJECTED_NO_FUNDS),(t.includes("status failed")||t.includes("transaction failed"))&&(n=Ye.TRANSACTION_FAILED),d({type:n,data:{error:e}}),[void 0,e]}var o}),[t]);return{sign:i.useCallback((async(e,t)=>{try{const i={recipient_address:a,payment_type:e,currency_filter:Qe.CONTRACT_ADDRESS,currency_value:t,products:n.map((e=>({product_id:e.productId,quantity:e.qty})))},o=`${Je[s]}/${r}/order/sign`,l=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),{ok:u,status:_}=l;if(!u){const{code:e}=await l.json();let t;switch(_){case 400:t=Ye.SERVICE_BREAKDOWN;break;case 404:t="insufficient_stock"===e?Ye.INSUFFICIENT_STOCK:Ye.PRODUCT_NOT_FOUND;break;case 429:case 500:t=Ye.DEFAULT;break;default:throw new Error("Unknown error")}return void d({type:t})}const h=await l.json(),m=h.order.products.map((e=>e.detail.map((({token_id:e})=>e)))).flat(),p=((e,t)=>{const{order:n,transactions:a}=e;return{order:{currency:{name:n.currency.name,erc20Address:n.currency.erc20_address},products:n.products.map((e=>((e,t,n)=>({productId:e.product_id,image:n?.image||"",qty:n?.qty||1,name:n?.name||"",description:n?.description||"",currency:t,contractType:e.contract_type,collectionAddress:e.collection_address,amount:e.detail.map((({amount:e})=>e)),tokenId:e.detail.map((({token_id:e})=>e))}))(e,n.currency.name,t.find((t=>t.productId===e.product_id))))).reduce(((e,t)=>{const n=e.findIndex((e=>e.name===t.name));return-1===n&&e.push({...t}),n>-1&&(e[n].amount=[...e[n].amount,...t.amount],e[n].tokenId=[...e[n].tokenId,...t.tokenId]),e}),[]),totalAmount:Number(n.total_amount)},transactions:a.map((e=>({tokenAddress:e.contract_address,gasEstimate:e.gas_estimate,methodCall:e.method_call,params:{reference:e.params.reference||"",amount:e.params.amount||0,spender:e.params.spender||""},rawData:e.raw_data}))),transactionId:a.find((e=>e.method_call.startsWith("execute")))?.params.reference||""}})(h,n);return f(m),c(p),p}catch(e){d({type:Ye.DEFAULT,data:{error:e}})}}),[n,a,r,s,t]),signResponse:l,signError:o,execute:async(e,t,n,a)=>{if(!e)return d({type:Ye.DEFAULT,data:{reason:"No sign data"}}),[];let s=!0;const i=[];for(const r of e.transactions){const{tokenAddress:e,rawData:o,methodCall:d,gasEstimate:l}=r,[c,u]=await g(e,o,l,d,t);if(u||!c){s=!1,a(u,i);break}i.push({method:d,hash:c}),n({method:d,hash:c})}return(s?m:p)(),i},executeResponse:u,tokenIds:h}},tt=(e,t)=>{const n=[];for(const t of e.steps)switch(t.type){case k.BRIDGE:n.push(t.fees.approvalGasFee),n.push(...t.fees.bridgeFees),n.push(t.fees.bridgeGasFee);break;case k.SWAP:n.push(t.fees.approvalGasFee),n.push(...t.fees.swapFees),n.push(t.fees.swapGasFee)}let a=0;for(const e of n)if(e.token){const n=C(e.formattedAmount,e.token.symbol,t);a+=parseFloat(n)}return I(a)},nt=e=>{if(e.sufficient||e.router.routingOutcome.type!==T.ROUTES_FOUND)return[];const t=[];for(const n of e.transactionRequirements){const{token:e}=n.current;t.includes(e.symbol)||t.push(e.symbol)}for(const n of e.router.routingOutcome.fundingRoutes)for(const e of n.steps)t.includes(e.fundingItem.token.symbol)||t.push(e.fundingItem.token.symbol);return t},at=({checkout:e,provider:t,items:n,amount:a,tokenAddress:s})=>{const[r,o]=i.useState(void 0),[d,l]=i.useState(void 0),c=i.useCallback((async()=>{let n;try{const i=t?.getSigner(),r=await(i?.getAddress())||"",d=((e,t,n)=>[{type:b.ERC20,tokenAddress:n,spenderAddress:t,amount:e}])(a,r,s),l={type:y.GAS,gasToken:{type:v.NATIVE,limit:A.from("30000000")}},c=await(e?.smartCheckout({provider:t,itemRequirements:d,transactionOrGasAmount:l}));if(!c)throw new Error;if(n=((e,t)=>{const n={...e};if(!!t?.provider?.isPassport&&(n.transactionRequirements=e.transactionRequirements.map((e=>e.type===b.NATIVE?{...e,sufficient:!0}:e)),n.sufficient=n.transactionRequirements.every((e=>e.sufficient))),n.sufficient||n.router.routingOutcome.type!==T.ROUTES_FOUND)return n;const a=[],s=n.router.routingOutcome.fundingRoutes.filter((e=>!e.steps.some((e=>a.includes(e.type)))));let i;return i=0===s.length?{type:T.NO_ROUTES_FOUND,message:"Smart Checkout did not find any routes to fulfill the transaction"}:{type:T.ROUTES_FOUND,fundingRoutes:s},{...n,router:{...n.router,routingOutcome:i}}})({...c},t),!n.sufficient)throw new Error(Xe.FRACTIONAL_BALANCE_BLOCKED);return o(n),c}catch(e){const t=(e=>{if(e)return e.transactionRequirements.reduce(((e,t)=>({...e,[t.type]:t.sufficient})),{})})(n);l({type:Ye.SMART_CHECKOUT_ERROR,data:{error:e,fractionalBalance:t}})}}),[e,t,n,a,s]);return{smartCheckout:c,smartCheckoutResult:r,smartCheckoutError:d}},st={contractId:"",currencies:[]},it=({environment:e,environmentId:t,defaultCurrency:n})=>{const[a,s]=i.useState(),[r,o]=i.useState(st);return i.useEffect((()=>{e&&t&&(async()=>{const n=`${Je[e]}/${t}/client-config`;try{const e=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw new Error(`${e.status} - ${e.statusText}`);const t=await e.json();o((e=>({contractId:e.contract_id,currencies:e.currencies.map((e=>({...e,erc20Address:e.erc20_address})))}))(t))}catch(e){console.warn("Error fetching client config",e)}})()}),[e,t]),i.useEffect((()=>{if(0===r.currencies.length)return;const e=r.currencies.find((e=>e.name===n))||r.currencies[0];s(e)}),[n,r]),{clientConfig:r,currency:a}},rt=i.createContext({items:[],amount:"",collectionName:"",provider:void 0,checkout:void 0,environmentId:"",environment:w.SANDBOX,recipientAddress:"",recipientEmail:"",sign:()=>Promise.resolve(void 0),execute:()=>Promise.resolve([]),signResponse:void 0,signError:void 0,executeResponse:void 0,passport:void 0,isPassportWallet:!1,paymentMethod:void 0,setPaymentMethod:()=>{},goBackToPaymentMethods:()=>{},goToErrorView:()=>{},goToSuccessView:()=>{},config:{},querySmartCheckout:()=>Promise.resolve(void 0),smartCheckoutResult:void 0,smartCheckoutError:void 0,fundingRoutes:[],disabledPaymentTypes:[],invalidParameters:!1,fromTokenAddress:"",clientConfig:st,signTokenIds:[]});rt.displayName="SaleSaleContext";const ot=1;function dt(e){const{children:t,value:{config:n,environment:a,environmentId:s,items:o,amount:d,provider:l,checkout:c,passport:u,collectionName:_}}=e,h=i.useRef(0),{viewDispatch:f}=i.useContext(S),[{recipientEmail:m,recipientAddress:p},g]=i.useState({recipientEmail:"",recipientAddress:""}),[E,w]=i.useState(void 0),[b,y]=i.useState([]),[v,A]=i.useState([]),[k,C]=i.useState(!1),{currency:I,clientConfig:O}=it({environmentId:s,environment:n.environment}),N=I?.erc20Address||"",D=i.useCallback(((e,t)=>{w(e),f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.PAYMENT_METHODS,data:t}}})}),[]);i.useEffect((()=>{(async()=>{const e=l?.getSigner(),t=await(e?.getAddress())||"",n=(await(u?.getUserInfo()))?.email||"";g({recipientEmail:n,recipientAddress:t})})()}),[l]);const{sign:U,execute:L,signResponse:F,signError:M,executeResponse:z,tokenIds:P}=et({items:o,provider:l,fromTokenAddress:N,recipientAddress:p,environmentId:s,environment:a}),B=i.useCallback((async(e,t)=>{if(!N||!N.startsWith("0x"))return void C(!0);const n=await U(e,N);return n?(t?.(n),n):void 0}),[U,N]),W=i.useCallback(((e,t={})=>{h.current+=1,h.current>ot&&(h.current=0,w(void 0)),f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.SALE_FAIL,data:{...t,errorType:e,paymentMethod:E,transactions:z.transactions}}}})}),[E,w,z]),H=i.useCallback((e=>{f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.SALE_SUCCESS,data:{paymentMethod:E,transactions:z.transactions,tokenIds:P,...e}}}})}),[[E,z,P]]);i.useEffect((()=>{M&&W(M.type,M.data)}),[M]);const{smartCheckout:K,smartCheckoutResult:V,smartCheckoutError:Z}=at({provider:l,checkout:c,items:o,amount:d,tokenAddress:N});i.useEffect((()=>{if(Z)return Z.data?.error?.message===Xe.FRACTIONAL_BALANCE_BLOCKED?(A([x.CRYPTO]),void D(void 0)):void W(Z.type,Z.data)}),[Z]);const G=i.useCallback((async e=>{const t=await K();return e?.(t),t}),[K]);i.useEffect((()=>{if(V&&(V.sufficient&&(B(je.CRYPTO),f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.PAY_WITH_COINS}}})),!V.sufficient))switch(V.router.routingOutcome.type){case T.ROUTES_FOUND:y(V.router.routingOutcome.fundingRoutes),f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.FUND_WITH_SMART_CHECKOUT,subView:Ge.FUNDING_ROUTE_SELECT}}});break;case T.NO_ROUTES_FOUND:case T.NO_ROUTE_OPTIONS:default:y([]),w(void 0),A([x.CRYPTO]),D(void 0)}}),[V]),i.useEffect((()=>{!(!o||0===o.length)&&!(!d||"0"===d)&&_&&s||C(!0)}),[o,d,_,s]);const Y=i.useMemo((()=>({config:n,items:o,amount:d,fromTokenAddress:N,sign:B,signResponse:F,signError:M,execute:L,executeResponse:z,environmentId:s,collectionName:_,environment:a,provider:l,checkout:c,recipientAddress:p,recipientEmail:m,paymentMethod:E,setPaymentMethod:w,goBackToPaymentMethods:D,goToErrorView:W,goToSuccessView:H,isPassportWallet:!!l?.provider?.isPassport,querySmartCheckout:G,smartCheckoutResult:V,smartCheckoutError:Z,fundingRoutes:b,disabledPaymentTypes:v,invalidParameters:k,clientConfig:O,signTokenIds:P})),[n,a,s,o,d,N,_,l,c,p,m,F,M,z,E,D,W,H,B,G,V,Z,b,v,k,O,P]);return r(rt.Provider,{value:Y,children:t})}function lt(){return i.useContext(rt)}var ct;function ut({fundingRouteStep:e,onFundingRouteExecuted:t}){const{t:n}=O(),{config:a,provider:s,checkout:o,fromTokenAddress:d}=lt(),{viewDispatch:c}=i.useContext(S),{connectLoaderDispatch:u}=i.useContext(N),[_,h]=i.useState(void 0),[f,m]=i.useState(void 0),[p,g]=i.useState(void 0),[E,w]=i.useState(ct.LOADING),T=i.useRef(!1),b=i.useRef(void 0),y=i.useRef(void 0),[v,A]=i.useReducer(D,U),C=i.useMemo((()=>({eventTargetState:v,eventTargetDispatch:A})),[v,A]),I=new EventTarget,x=e=>{c({payload:{type:R.UPDATE_VIEW,view:{type:Ze.SALE_FAIL,data:{errorType:Ye.SMART_CHECKOUT_EXECUTE_ERROR,errorData:e}}}})},j=i.useCallback((async e=>{if(!o||!s)throw new Error("checkout or provider not available.");const t=await o.getNetworkInfo({provider:s});if(e.type===k.BRIDGE){if(m({tokenAddress:e.fundingItem.token.address,amount:e.fundingItem.fundsRequired.formattedAmount}),t.chainId===L(o.config))return void w(ct.EXECUTE_BRIDGE);T.current=ct.EXECUTE_BRIDGE,w(ct.SWITCH_NETWORK_ETH)}if(e.type===k.SWAP){if(h({amount:e.fundingItem.fundsRequired.formattedAmount,fromTokenAddress:e.fundingItem.token.address,toTokenAddress:d}),t.chainId===F(o.config))return void w(ct.EXECUTE_SWAP);T.current=ct.EXECUTE_SWAP,w(ct.SWITCH_NETWORK_ZKEVM)}e.type===k.ONRAMP&&(g({amount:e.fundingItem.fundsRequired.formattedAmount,tokenAddress:e.fundingItem.token.address}),w(ct.EXECUTE_ON_RAMP))}),[s,o]);i.useEffect((()=>{if(e)try{j(e)}catch(e){x(e)}}),[e]);const $=()=>{b.current?(b.current=void 0,y.current=void 0,t()):x(y.current)},q=e=>{switch(e.detail.type){case G.TRANSACTION_SENT:case V.SUCCESS:case Z.SUCCESS:{const t=e.detail.data;b.current=t;break}case G.FAILURE:case V.FAILURE:case Z.FAILURE:{const t=e.detail.data;y.current=t;break}case G.CLOSE_WIDGET:case V.CLOSE_WIDGET:case Z.CLOSE_WIDGET:$();case V.REJECTED:}},J=e=>{switch(e.detail.type){case Y.SUCCESS:{const t=e.detail.data;u({payload:{type:X.SET_PROVIDER,provider:t.provider}}),!1!==T.current&&(w(T.current),T.current=!1);break}case Y.FAILURE:case Y.CLOSE_WIDGET:default:$()}};return i.useEffect((()=>(I.addEventListener(M.IMTBL_CONNECT_WIDGET_EVENT,J),I.addEventListener(M.IMTBL_BRIDGE_WIDGET_EVENT,q),I.addEventListener(M.IMTBL_SWAP_WIDGET_EVENT,q),()=>{I.removeEventListener(M.IMTBL_CONNECT_WIDGET_EVENT,J),I.removeEventListener(M.IMTBL_BRIDGE_WIDGET_EVENT,q),I.removeEventListener(M.IMTBL_SWAP_WIDGET_EVENT,q)})),[]),i.useEffect((()=>{A({payload:{type:z.SET_EVENT_TARGET,eventTarget:I}})}),[o]),l(K.Provider,{value:C,children:[E===ct.LOADING&&r(P,{loadingText:n("views.FUND_WITH_SMART_CHECKOUT.loading.checkingBalances")}),E===ct.EXECUTE_BRIDGE&&r(be,{...f,config:a,checkout:o}),E===ct.EXECUTE_SWAP&&r(Ae,{..._,config:a}),E===ct.EXECUTE_ON_RAMP&&r(ye,{config:a,...p}),E===ct.SWITCH_NETWORK_ETH&&r(H,{config:a,targetChainId:o.config.isProduction?B.ETHEREUM:B.SEPOLIA,web3Provider:s,checkout:o,deepLink:W.SWITCH_NETWORK}),E===ct.SWITCH_NETWORK_ZKEVM&&r(H,{config:a,targetChainId:o.config.isProduction?B.IMTBL_ZKEVM_MAINNET:B.IMTBL_ZKEVM_TESTNET,web3Provider:s,checkout:o,deepLink:W.SWITCH_NETWORK})]})}!function(e){e.LOADING="LOADING",e.EXECUTE_SWAP="EXECUTE_SWAP",e.EXECUTE_BRIDGE="EXECUTE_BRIDGE",e.EXECUTE_ON_RAMP="EXECUTE_ON_RAMP",e.SWITCH_NETWORK_ETH="SWITCH_NETWORK_ETH",e.SWITCH_NETWORK_ZKEVM="SWITCH_NETWORK_ZKEVM"}(ct||(ct={}));const _t={[B.IMTBL_ZKEVM_DEVNET]:"Immutable",[B.IMTBL_ZKEVM_MAINNET]:"Immutable",[B.IMTBL_ZKEVM_TESTNET]:"Immutable",[B.ETHEREUM]:"EthToken",[B.SEPOLIA]:"EthToken"},ht={[B.IMTBL_ZKEVM_DEVNET]:"base.color.text.link.primary",[B.IMTBL_ZKEVM_TESTNET]:"base.color.text.link.primary",[B.IMTBL_ZKEVM_MAINNET]:"base.color.text.link.primary",[B.ETHEREUM]:"base.color.accent.5",[B.SEPOLIA]:"base.color.accent.5"};function ft({onClick:e,fundingRoute:t,toggleVisible:n,selected:a,size:s="small"}){const{t:o}=O(),d=t.steps[0],{cryptoFiatState:c}=i.useContext(ke),{isPassportWallet:u}=lt(),[_,h]=i.useState(void 0),[f,m]=i.useState(void 0);i.useEffect((()=>{if(c.conversions)try{h(tt(t,c.conversions)),m(C(d.fundingItem.userBalance.formattedBalance,d.fundingItem.token.symbol,c.conversions))}catch{h(void 0),m(void 0)}}),[c,t]);return l(j,{emphasized:!0,testId:"funding-route-menu-item",onClick:e,selected:a,size:s,children:[n&&r(j.IntentIcon,{icon:"ChevronExpand"}),r(j.FramedIcon,{icon:"Coins",circularFrame:!0}),r(j.PriceDisplay,{use:r($,{size:"xSmall"}),fiatAmount:`${o("views.FUND_WITH_SMART_CHECKOUT.currency.usdEstimate")}${f}`,price:q(d.fundingItem.userBalance.formattedBalance)}),l(j.Label,{sx:{display:"flex",wordBreak:"default"},children:[d.fundingItem.token.symbol,u?null:l(Re.Button,{rc:r("a",{}),sx:{pointerEvents:"none",cursor:"default",height:"100%",marginLeft:"base.spacing.x2",fontSize:"base.text.body.xxSmall.regular.fontSize",fontWeight:"base.text.body.xxSmall.regular.fontWeight",color:"base.color.brand.4",paddingLeft:"base.spacing.x2",paddingRight:"base.spacing.x2"},size:"small",children:[r(E.Icon,{icon:_t[d.chainId],sx:{width:"14px",fill:ht[d.chainId]}}),J(d.chainId)]})]}),l(j.Caption,{children:["Fees ≈ USD $",_]})]})}function mt({visible:e,onCloseDrawer:t,fundingRoutes:n,activeFundingRouteIndex:a}){const{t:s}=O();return r(Q,{size:"full",onCloseDrawer:()=>t(a),visible:e,showHeaderBar:!0,headerBarTitle:s("views.FUND_WITH_SMART_CHECKOUT.fundingRouteDrawer.header"),children:r(Q.Content,{children:n.map(((e,n)=>r(ft,{onClick:()=>{t(n)},fundingRoute:e,selected:a===n,size:"medium"},e.steps[0].fundingItem.type+e.steps[0].fundingItem.token)))})})}function pt({fundingRoute:e,collectionName:t}){const{t:n}=O(),{items:a}=lt(),s=a[0],o=e.steps[0],{cryptoFiatState:d}=i.useContext(ke),[c,u]=i.useState(void 0);return i.useEffect((()=>{if(d.conversions)try{u(C(o.fundingItem.fundsRequired.formattedAmount,o.fundingItem.token.symbol,d.conversions))}catch{u(void 0)}}),[d,e]),l(j,{emphasized:!0,testId:"funding-route-purchase-item",size:"medium",children:[r(j.FramedImage,{imageUrl:s?.image}),r(j.PriceDisplay,{use:r($,{size:"xSmall"}),price:`${o?.fundingItem.token.symbol} \n ${q(o.fundingItem.fundsRequired.formattedAmount)}`,fiatAmount:`${n("views.FUND_WITH_SMART_CHECKOUT.currency.usdEstimate")}${c}`}),l(j.Label,{children:[s?.name,s?.qty>1?` x${s.qty}`:null]}),r(j.Caption,{children:t})]},s?.name)}function gt({fundingRoutes:e,collectionName:t,onFundingRouteSelected:n}){const{t:a}=O(),[s,o]=i.useState(!1),[d,c]=i.useState(0),{viewDispatch:u}=i.useContext(S),{eventTargetState:{eventTarget:h}}=i.useContext(K),{goBackToPaymentMethods:m}=lt();return l(ae,{testId:"funding-route-select",header:r(te,{onCloseButtonClick:()=>ee(h)}),footer:r(ne,{}),children:[l(_,{sx:{display:"flex",flexDirection:"column",paddingX:"base.spacing.x2",paddingY:"base.spacing.x8",rowGap:"base.spacing.x4",height:"100%"},children:[r($,{size:"small",children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.heading")}),0===e.length?[r(f,{size:"small",children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.noRoutesAvailable")},"noRoutesAvailableText"),r(E,{variant:"tertiary",children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.payWithCard")},"payWithCardButton")]:[r(ft,{"data-testid":"funding-route-select-selected-route",onClick:e.length>1?()=>{o(!0)}:()=>{},fundingRoute:e[d],selected:!0,toggleVisible:e.length>1},"selectedFundingRouteMenuItem"),r(pt,{fundingRoute:e[d],collectionName:t},"purchaseMenuItem"),r(E,{sx:{mt:"auto"},variant:"primary",onClick:()=>{n(e[d]),u({payload:{type:R.UPDATE_VIEW,view:{type:Ze.FUND_WITH_SMART_CHECKOUT,subView:Ge.FUNDING_ROUTE_EXECUTE}}})},children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.continue")},"continueButton"),r(E,{variant:"tertiary",onClick:()=>m(),children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.payWithCardInstead")},"payWithCardButton")]]}),r(mt,{visible:s,onCloseDrawer:e=>{c(e),o(!1)},fundingRoutes:e,activeFundingRouteIndex:d})]})}const Et=e=>e.map((({method:e,hash:t})=>`${e}: ${t}`)).join(" | "),wt=e=>e.split("_").map((e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join(""),Tt=e=>e.replace(/[^\u0000-\u00FF]/g,""),bt=()=>{const{track:e,page:t}=se(),{recipientAddress:n,recipientEmail:a,signResponse:s,paymentMethod:r}=lt(),{eventTargetState:{eventTarget:o}}=i.useContext(K),d=Ze.PAYMENT_METHODS,l={location:"web",userJourney:ie.SALE},c={email:a,userId:n,paymentMethod:r},u={amount:s?.order.totalAmount,currency:s?.order.currency.name};return{track:e,page:t,sendPageView:(e,n)=>{t({...l,screen:wt(e),action:"Viewed",...n})},sendCloseEvent:(t=d,n="Button",a="Pressed")=>{e({...l,screen:wt(t),control:"Close",controlType:n,action:a,extras:{...c}}),ee(o)},sendSuccessEvent:(t=d,n=[],a=[],s={})=>{e({...l,screen:wt(t),control:"Success",controlType:"Event",action:"Succeeded",extras:{...s,...c,transactions:Et(n),...u,paymentMethod:r,tokenIds:a}}),re(o,r,n,a,s.transactionId)},sendFailedEvent:(t,n,a=[],s=d,i={})=>{e({...l,screen:wt(s||d),control:"Fail",controlType:"Event",action:"Failed",extras:{...i,transactions:Et(a),...n,...u,...c,paymentMethod:r,reason:t}}),oe(o,t,n,r,a,i.transactionId)},sendTransactionSuccessEvent:e=>{de(o,r,[e])},sendOrderCreated:(t,n)=>{e({...l,screen:wt(t),control:"OrderCreated",controlType:"Event",extras:{...n}})},sendSelectedPaymentMethod:(t,n)=>{e({...l,screen:wt(n),control:"Select",controlType:"MenuItem",extras:{paymentMethod:t}}),le(o,t)}}};function yt({subView:e}){const{t:t}=O(),{sendPageView:n}=bt(),{viewDispatch:a}=i.useContext(S),[s,o]=i.useState(void 0),[d,c]=i.useState(0),{querySmartCheckout:u,fundingRoutes:h,smartCheckoutResult:f,collectionName:m,fromTokenAddress:p}=lt(),{cryptoFiatDispatch:g}=i.useContext(ke);i.useEffect((()=>{e===Ge.INIT&&p&&u()}),[e,p]),i.useEffect((()=>{if(!g||!f)return;const e=nt(f);g({payload:{type:Ce.SET_TOKEN_SYMBOLS,tokenSymbols:e}})}),[g,f]);const E=i.useMemo((()=>{if(s)return s.steps[d]}),[s,d]);return i.useEffect((()=>n(Ze.FUND_WITH_SMART_CHECKOUT,{subView:e,...!!E&&{fundingStep:E.type}})),[]),l(_,{children:[e===Ge.INIT&&r(P,{loadingText:t("views.FUND_WITH_SMART_CHECKOUT.loading.checkingBalances")}),e===Ge.FUNDING_ROUTE_SELECT&&r(gt,{fundingRoutes:h,collectionName:m,onFundingRouteSelected:e=>{o(e)}}),e===Ge.FUNDING_ROUTE_EXECUTE&&r(ut,{onFundingRouteExecuted:()=>{s&&(d===s.steps.length-1?(c(0),o(void 0),a({payload:{type:R.UPDATE_VIEW,view:{type:Ze.FUND_WITH_SMART_CHECKOUT,subView:Ge.INIT}}})):c(d+1))},fundingRouteStep:E})]})}
1
+ import{a2 as e,a3 as t,a4 as n,a5 as a,a6 as s,r as i,a as r,a7 as o,a8 as d,j as l,a9 as c,aa as u,B as _,ab as h,b as f,ac as m,ad as p,c as g,p as E,ae as w,af as T,ag as b,ah as y,ai as v,aj as A,ak as k,y as C,al as I,V as S,d as R,am as x,u as O,C as N,an as D,ao as U,h as L,g as F,I as M,ap as z,a0 as P,aq as B,ar as W,as as H,E as K,at as V,au as Z,av as G,aw as Y,ax as X,M as j,H as $,t as q,ay as J,az as Q,aA as ee,z as te,G as ne,J as ae,e as se,U as ie,aB as re,aC as oe,aD as de,aE as le,aF as ce,aG as ue,aH as _e,Y as he,S as fe,aI as me,aJ as pe,aK as ge,_ as Ee,$ as we,aL as Te}from"./index-394d516d.js";import be from"./BridgeWidget-764186df.js";import{O as ye,u as ve}from"./OnRampWidget-d202910b.js";import Ae from"./SwapWidget-fa573621.js";import{C as ke,a as Ce,T as Ie,b as Se}from"./TopUpView-20c59619.js";import{H as Re}from"./HorizontalMenu-actual-f804d6c1.js";import"./retry-ce6e6559.js";import"./balance-13198af0.js";import"./SpendingCapHero-4cf86bc9.js";var xe={d:"flex",flexWrap:"wrap",justifyContent:"flex-start",alignItems:"center",width:"100%",minHeight:"base.spacing.x16",p:"base.spacing.x4",columnGap:"base.spacing.x2",rowGap:"base.spacing.x4",paddingLeft:"base.spacing.x14",position:"relative",boxShadow:"base.shadow.300",brad:"base.borderRadius.x6"},Oe={display:"flex",gap:"base.spacing.x2",ml:"auto"},Ne=function(e){switch(e){case"success":case"fatal":case"guidance":case"attention":case"destructive":return{bg:"base.color.status.".concat(e,".dim")};default:return{bg:"base.color.neutral.500"}}},De=function(e,t){return"lightOnDark"===t.base.colorMode&&!("standard"===e)},Ue="standard",Le=["children","size","weight","variant","className","sx"];function Fe(n){var a=n.children,s=n.size,i=void 0===s?"medium":s,d=n.weight,l=n.variant,u=void 0===l?Ue:l,_=n.className,h=n.sx,m=void 0===h?{}:h,p=e(n,Le),g=t(),E=De(u,g),w=o({c:E?"base.color.text.body.inverse.primary":"base.color.text.body.primary"},m);return r(f,c(c({},p),{},{size:i,weight:d,sx:w,className:"".concat(null!=_?_:""," BannerCaption"),children:a}))}Fe.displayName="Banner.Caption";var Me=["sx","variant","iconVariant","className"];function ze(t){var n=t.sx,a=void 0===n?{}:n,s=t.variant,i=void 0===s?Ue:s,d=t.iconVariant,l=t.className,u=e(t,Me),_=m(),h=De(i,_);return r(p,c(c({},u),{},{variant:d,className:"".concat(null!=l?l:""," BannerIcon"),sx:o({position:"absolute",top:"base.spacing.x4",left:"base.spacing.x4",width:"base.icon.size.300",fill:h?"base.color.text.body.inverse.primary":"base.color.text.body.primary"},a)}))}ze.displayName="Banner.Icon";var Pe=["variant","bannerVariant","className"];function Be(n){var a=n.variant,s=void 0===a?"tertiary":a,i=n.bannerVariant,o=void 0===i?Ue:i,d=n.className,l=e(n,Pe),u=t(),_=De(o,u);return r(g,c(c({},l),{},{size:"small",variant:_?"".concat(s,"/inverse"):s,className:"".concat(null!=d?d:""," BannerRightButtCon")}))}Be.displayName="Banner.RightButtCon";var We=["variant","bannerVariant","className"];function He(n){var a=n.variant,s=void 0===a?"tertiary":a,i=n.bannerVariant,o=void 0===i?Ue:i,d=n.className,l=e(n,We),u=t(),_=De(o,u);return r(E,c(c({},l),{},{size:"small",variant:_?"".concat(s,"/inverse"):s,className:"".concat(null!=d?d:""," BannerRightButton")}))}He.displayName="Banner.RightButton";var Ke=["children","size","weight","variant","className","sx"];function Ve(n){var a=n.children,s=n.size,i=void 0===s?"medium":s,d=n.weight,l=void 0===d?"bold":d,u=n.variant,_=void 0===u?Ue:u,h=n.className,m=n.sx,p=void 0===m?{}:m,g=e(n,Ke),E=t(),w=De(_,E),T=o({color:w?"base.color.text.body.inverse.primary":"base.color.text.body.primary"},p);return r(f,c(c({},g),{},{size:i,weight:l,sx:T,className:"".concat(null!=h?h:""," BannerTitle"),children:a}))}var Ze,Ge,Ye,Xe,je,$e=["children","variant","sx","testId","forceMultilineText","domRef","className"];function qe(f){var m,p=f.children,g=f.variant,E=void 0===g?Ue:g,w=f.sx,T=void 0===w?{}:w,b=f.testId,y=void 0===b?"banner":b,v=f.forceMultilineText,A=f.domRef,k=void 0===A?{current:null}:A,C=f.className,I=e(f,$e),S=t(),R=n(k),x=a(p,ze),O=a(p,Ve),N=a(p,Fe),D=s(p,[ze,Ve,Fe]).otherChildren,U=i.useMemo((function(){switch(E){case"fatal":return r(ze,{icon:"CloseWithCircle",iconVariant:"bold"});case"attention":case"destructive":return r(ze,{icon:"Alert",iconVariant:"bold"});case"guidance":return r(ze,{icon:"InformationCircle",iconVariant:"bold"});case"success":return r(ze,{icon:"TickWithCircle",iconVariant:"bold"});default:return x||r(ze,{icon:"InformationCircle",iconVariant:"bold"})}}),[x,E]),L=i.useMemo((function(){var e,t;return o(xe,Ne(E),null!==(e=null===(t=S.components)||void 0===t||null===(t=t.Banner)||void 0===t?void 0:t.sxOverride)&&void 0!==e?e:{},T)}),[T,null===(m=S.components)||void 0===m||null===(m=m.Banner)||void 0===m?void 0:m.sxOverride,E]),F={top:d(R).height>64?"16px":"19px"};return l(_,c(c({},I),{},{sx:L,testId:y,domRef:R,className:"".concat(null!=C?C:""," Banner Banner--").concat(E),children:[r(u,{variant:E,testId:U.props.testId?U.props.testId:"".concat(y,"__icon"),sx:U.props.sx?o(F,U.props.sx):F,children:U}),l(_,{sx:c({d:"flex"},v?{flexDirection:"column"}:{flexWrap:"wrap",columnGap:"base.spacing.x2"}),className:"innerTextContainer",children:[r(u,{variant:E,testId:"".concat(y,"__title"),children:O}),r(u,{variant:E,testId:"".concat(y,"__caption"),children:N})]}),D||Array.isArray(D)&&D.length?r(_,{className:"rightButtonsContainer",testId:"".concat(y,"__rightHandButtons"),sx:Oe,children:i.Children.map(D,(function(e){var t=h(e,Be);return h(e,He)||t?r(u,{bannerVariant:E,testId:"".concat(y,t?"__rightButtCon":"__rightButton"),children:e}):e}))}):null]}))}qe.displayName="Banner",qe.Icon=ze,qe.Title=Ve,qe.Caption=Fe,qe.RightButton=He,qe.RightButtCon=Be,function(e){e.PAYMENT_METHODS="PAYMENT_METHODS",e.PAY_WITH_COINS="PAY_WITH_COINS",e.PAY_WITH_CARD="PAY_WITH_CARD",e.FUND_WITH_SMART_CHECKOUT="FUND_WITH_SMART_CHECKOUT",e.SALE_SUCCESS="SALE_SUCCESS",e.SALE_FAIL="SALE_FAIL"}(Ze||(Ze={})),function(e){e.INIT="INIT",e.LOADING="LOADING",e.FUNDING_ROUTE_SELECT="FUNDING_ROUTE_SELECT",e.FUNDING_ROUTE_EXECUTE="FUNDING_ROUTE_EXECUTE"}(Ge||(Ge={})),function(e){e.DEFAULT="DEFAULT_ERROR",e.INVALID_PARAMETERS="INVALID_PARAMETERS",e.TRANSACTION_FAILED="TRANSACTION_FAILED",e.SERVICE_BREAKDOWN="SERVICE_BREAKDOWN",e.PRODUCT_NOT_FOUND="PRODUCT_NOT_FOUND",e.INSUFFICIENT_STOCK="INSUFFICIENT_STOCK",e.TRANSAK_FAILED="TRANSAK_FAILED",e.WALLET_FAILED="WALLET_FAILED",e.WALLET_REJECTED="WALLET_REJECTED",e.WALLET_REJECTED_NO_FUNDS="WALLET_REJECTED_NO_FUNDS",e.WALLET_POPUP_BLOCKED="WALLET_POPUP_BLOCKED",e.SMART_CHECKOUT_ERROR="SMART_CHECKOUT_ERROR",e.SMART_CHECKOUT_EXECUTE_ERROR="SMART_CHECKOUT_EXECUTE_ERROR"}(Ye||(Ye={})),function(e){e.FRACTIONAL_BALANCE_BLOCKED="FRACTIONAL_BALANCE_BLOCKED"}(Xe||(Xe={})),function(e){e.CRYPTO="crypto",e.FIAT="fiat"}(je||(je={}));const Je={[w.SANDBOX]:"https://api.sandbox.immutable.com/v1/primary-sales",[w.PRODUCTION]:"https://api.immutable.com/v1/primary-sales"};var Qe;!function(e){e.CONTRACT_ADDRESS="contract_address",e.CURRENCY_SYMBOL="currency_symbol"}(Qe||(Qe={}));const et=e=>{const{provider:t,items:n,recipientAddress:a,environment:s,environmentId:r}=e,[o,d]=i.useState(void 0),[l,c]=i.useState(void 0),[u,_]=i.useState({done:!1,transactions:[]}),[h,f]=i.useState([]),m=()=>_((e=>({...e,done:!0}))),p=()=>_({done:!1,transactions:[]}),g=i.useCallback((async(e,n,a,s,i)=>{let r;try{const d=t?.getSigner(),l=await(t?.getGasPrice()),c=await(d?.sendTransaction({to:e,data:n,gasPrice:l,gasLimit:a}));return o={method:s,hash:c?.hash},_((e=>({...e,transactions:[...e.transactions,o]}))),i&&await(c?.wait()),r=c?.hash||"",[r,void 0]}catch(e){const t=`${e?.reason||e?.message||""}`.toLowerCase();r=e?.transactionHash;let n=Ye.WALLET_FAILED;return t.includes("failed")&&t.includes("open confirmation")&&(n=Ye.WALLET_POPUP_BLOCKED),t.includes("rejected")&&t.includes("user")&&(n=Ye.WALLET_REJECTED),t.includes("failed to submit")&&t.includes("highest gas limit")&&(n=Ye.WALLET_REJECTED_NO_FUNDS),(t.includes("status failed")||t.includes("transaction failed"))&&(n=Ye.TRANSACTION_FAILED),d({type:n,data:{error:e}}),[void 0,e]}var o}),[t]);return{sign:i.useCallback((async(e,t)=>{try{const i={recipient_address:a,payment_type:e,currency_filter:Qe.CONTRACT_ADDRESS,currency_value:t,products:n.map((e=>({product_id:e.productId,quantity:e.qty})))},o=`${Je[s]}/${r}/order/sign`,l=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}),{ok:u,status:_}=l;if(!u){const{code:e}=await l.json();let t;switch(_){case 400:t=Ye.SERVICE_BREAKDOWN;break;case 404:t="insufficient_stock"===e?Ye.INSUFFICIENT_STOCK:Ye.PRODUCT_NOT_FOUND;break;case 429:case 500:t=Ye.DEFAULT;break;default:throw new Error("Unknown error")}return void d({type:t})}const h=await l.json(),m=h.order.products.map((e=>e.detail.map((({token_id:e})=>e)))).flat(),p=((e,t)=>{const{order:n,transactions:a}=e;return{order:{currency:{name:n.currency.name,erc20Address:n.currency.erc20_address},products:n.products.map((e=>((e,t,n)=>({productId:e.product_id,image:n?.image||"",qty:n?.qty||1,name:n?.name||"",description:n?.description||"",currency:t,contractType:e.contract_type,collectionAddress:e.collection_address,amount:e.detail.map((({amount:e})=>e)),tokenId:e.detail.map((({token_id:e})=>e))}))(e,n.currency.name,t.find((t=>t.productId===e.product_id))))).reduce(((e,t)=>{const n=e.findIndex((e=>e.name===t.name));return-1===n&&e.push({...t}),n>-1&&(e[n].amount=[...e[n].amount,...t.amount],e[n].tokenId=[...e[n].tokenId,...t.tokenId]),e}),[]),totalAmount:Number(n.total_amount)},transactions:a.map((e=>({tokenAddress:e.contract_address,gasEstimate:e.gas_estimate,methodCall:e.method_call,params:{reference:e.params.reference||"",amount:e.params.amount||0,spender:e.params.spender||""},rawData:e.raw_data}))),transactionId:a.find((e=>e.method_call.startsWith("execute")))?.params.reference||""}})(h,n);return f(m),c(p),p}catch(e){d({type:Ye.DEFAULT,data:{error:e}})}}),[n,a,r,s,t]),signResponse:l,signError:o,execute:async(e,t,n,a)=>{if(!e)return d({type:Ye.DEFAULT,data:{reason:"No sign data"}}),[];let s=!0;const i=[];for(const r of e.transactions){const{tokenAddress:e,rawData:o,methodCall:d,gasEstimate:l}=r,[c,u]=await g(e,o,l,d,t);if(u||!c){s=!1,a(u,i);break}i.push({method:d,hash:c}),n({method:d,hash:c})}return(s?m:p)(),i},executeResponse:u,tokenIds:h}},tt=(e,t)=>{const n=[];for(const t of e.steps)switch(t.type){case k.BRIDGE:n.push(t.fees.approvalGasFee),n.push(...t.fees.bridgeFees),n.push(t.fees.bridgeGasFee);break;case k.SWAP:n.push(t.fees.approvalGasFee),n.push(...t.fees.swapFees),n.push(t.fees.swapGasFee)}let a=0;for(const e of n)if(e.token){const n=C(e.formattedAmount,e.token.symbol,t);a+=parseFloat(n)}return I(a)},nt=e=>{if(e.sufficient||e.router.routingOutcome.type!==T.ROUTES_FOUND)return[];const t=[];for(const n of e.transactionRequirements){const{token:e}=n.current;t.includes(e.symbol)||t.push(e.symbol)}for(const n of e.router.routingOutcome.fundingRoutes)for(const e of n.steps)t.includes(e.fundingItem.token.symbol)||t.push(e.fundingItem.token.symbol);return t},at=({checkout:e,provider:t,items:n,amount:a,tokenAddress:s})=>{const[r,o]=i.useState(void 0),[d,l]=i.useState(void 0),c=i.useCallback((async()=>{let n;try{const i=t?.getSigner(),r=await(i?.getAddress())||"",d=((e,t,n)=>[{type:b.ERC20,tokenAddress:n,spenderAddress:t,amount:e}])(a,r,s),l={type:y.GAS,gasToken:{type:v.NATIVE,limit:A.from("30000000")}},c=await(e?.smartCheckout({provider:t,itemRequirements:d,transactionOrGasAmount:l}));if(!c)throw new Error;if(n=((e,t)=>{const n=t?.provider?.isPassport?e.transactionRequirements.map((e=>e.type===b.NATIVE?{...e,sufficient:!0}:e)):e.transactionRequirements;if(e.sufficient||e.router.routingOutcome.type!==T.ROUTES_FOUND)return{...e,transactionRequirements:n};const a=[],s=e.router.routingOutcome.fundingRoutes.filter((e=>!e.steps.some((e=>a.includes(e.type)))));let i;return i=0===s.length?{type:T.NO_ROUTES_FOUND,message:"Smart Checkout did not find any routes to fulfill the transaction"}:{type:T.ROUTES_FOUND,fundingRoutes:s},{...e,transactionRequirements:n,router:{...e.router,routingOutcome:i}}})({...c},t),!n.sufficient)throw new Error(Xe.FRACTIONAL_BALANCE_BLOCKED);return o(n),c}catch(e){const t=(e=>{if(e)return e.transactionRequirements.reduce(((e,t)=>({...e,[t.type]:t.sufficient})),{})})(n);l({type:Ye.SMART_CHECKOUT_ERROR,data:{error:e,fractionalBalance:t}})}}),[e,t,n,a,s]);return{smartCheckout:c,smartCheckoutResult:r,smartCheckoutError:d}},st={contractId:"",currencies:[]},it=({environment:e,environmentId:t,defaultCurrency:n})=>{const[a,s]=i.useState(),[r,o]=i.useState(st);return i.useEffect((()=>{e&&t&&(async()=>{const n=`${Je[e]}/${t}/client-config`;try{const e=await fetch(n,{method:"GET",headers:{"Content-Type":"application/json"}});if(!e.ok)throw new Error(`${e.status} - ${e.statusText}`);const t=await e.json();o((e=>({contractId:e.contract_id,currencies:e.currencies.map((e=>({...e,erc20Address:e.erc20_address})))}))(t))}catch(e){console.warn("Error fetching client config",e)}})()}),[e,t]),i.useEffect((()=>{if(0===r.currencies.length)return;const e=r.currencies.find((e=>e.name===n))||r.currencies[0];s(e)}),[n,r]),{clientConfig:r,currency:a}},rt=i.createContext({items:[],amount:"",collectionName:"",provider:void 0,checkout:void 0,environmentId:"",environment:w.SANDBOX,recipientAddress:"",recipientEmail:"",sign:()=>Promise.resolve(void 0),execute:()=>Promise.resolve([]),signResponse:void 0,signError:void 0,executeResponse:void 0,passport:void 0,isPassportWallet:!1,paymentMethod:void 0,setPaymentMethod:()=>{},goBackToPaymentMethods:()=>{},goToErrorView:()=>{},goToSuccessView:()=>{},config:{},querySmartCheckout:()=>Promise.resolve(void 0),smartCheckoutResult:void 0,smartCheckoutError:void 0,fundingRoutes:[],disabledPaymentTypes:[],invalidParameters:!1,fromTokenAddress:"",clientConfig:st,signTokenIds:[]});rt.displayName="SaleSaleContext";const ot=1;function dt(e){const{children:t,value:{config:n,environment:a,environmentId:s,items:o,amount:d,provider:l,checkout:c,passport:u,collectionName:_}}=e,h=i.useRef(0),{viewDispatch:f}=i.useContext(S),[{recipientEmail:m,recipientAddress:p},g]=i.useState({recipientEmail:"",recipientAddress:""}),[E,w]=i.useState(void 0),[b,y]=i.useState([]),[v,A]=i.useState([]),[k,C]=i.useState(!1),{currency:I,clientConfig:O}=it({environmentId:s,environment:n.environment}),N=I?.erc20Address||"",D=i.useCallback(((e,t)=>{w(e),f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.PAYMENT_METHODS,data:t}}})}),[]);i.useEffect((()=>{(async()=>{const e=l?.getSigner(),t=await(e?.getAddress())||"",n=(await(u?.getUserInfo()))?.email||"";g({recipientEmail:n,recipientAddress:t})})()}),[l]);const{sign:U,execute:L,signResponse:F,signError:M,executeResponse:z,tokenIds:P}=et({items:o,provider:l,fromTokenAddress:N,recipientAddress:p,environmentId:s,environment:a}),B=i.useCallback((async(e,t)=>{if(!N||!N.startsWith("0x"))return void C(!0);const n=await U(e,N);return n?(t?.(n),n):void 0}),[U,N]),W=i.useCallback(((e,t={})=>{h.current+=1,h.current>ot&&(h.current=0,w(void 0)),f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.SALE_FAIL,data:{...t,errorType:e,paymentMethod:E,transactions:z.transactions}}}})}),[E,w,z]),H=i.useCallback((e=>{f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.SALE_SUCCESS,data:{paymentMethod:E,transactions:z.transactions,tokenIds:P,...e}}}})}),[[E,z,P]]);i.useEffect((()=>{M&&W(M.type,M.data)}),[M]);const{smartCheckout:K,smartCheckoutResult:V,smartCheckoutError:Z}=at({provider:l,checkout:c,items:o,amount:d,tokenAddress:N});i.useEffect((()=>{if(Z)return Z.data?.error?.message===Xe.FRACTIONAL_BALANCE_BLOCKED?(A([x.CRYPTO]),void D(void 0)):void W(Z.type,Z.data)}),[Z]);const G=i.useCallback((async e=>{const t=await K();return e?.(t),t}),[K]);i.useEffect((()=>{if(V&&(V.sufficient&&(B(je.CRYPTO),f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.PAY_WITH_COINS}}})),!V.sufficient))switch(V.router.routingOutcome.type){case T.ROUTES_FOUND:y(V.router.routingOutcome.fundingRoutes),f({payload:{type:R.UPDATE_VIEW,view:{type:Ze.FUND_WITH_SMART_CHECKOUT,subView:Ge.FUNDING_ROUTE_SELECT}}});break;case T.NO_ROUTES_FOUND:case T.NO_ROUTE_OPTIONS:default:y([]),w(void 0),A([x.CRYPTO]),D(void 0)}}),[V]),i.useEffect((()=>{!(!o||0===o.length)&&!(!d||"0"===d)&&_&&s||C(!0)}),[o,d,_,s]);const Y=i.useMemo((()=>({config:n,items:o,amount:d,fromTokenAddress:N,sign:B,signResponse:F,signError:M,execute:L,executeResponse:z,environmentId:s,collectionName:_,environment:a,provider:l,checkout:c,recipientAddress:p,recipientEmail:m,paymentMethod:E,setPaymentMethod:w,goBackToPaymentMethods:D,goToErrorView:W,goToSuccessView:H,isPassportWallet:!!l?.provider?.isPassport,querySmartCheckout:G,smartCheckoutResult:V,smartCheckoutError:Z,fundingRoutes:b,disabledPaymentTypes:v,invalidParameters:k,clientConfig:O,signTokenIds:P})),[n,a,s,o,d,N,_,l,c,p,m,F,M,z,E,D,W,H,B,G,V,Z,b,v,k,O,P]);return r(rt.Provider,{value:Y,children:t})}function lt(){return i.useContext(rt)}var ct;function ut({fundingRouteStep:e,onFundingRouteExecuted:t}){const{t:n}=O(),{config:a,provider:s,checkout:o,fromTokenAddress:d}=lt(),{viewDispatch:c}=i.useContext(S),{connectLoaderDispatch:u}=i.useContext(N),[_,h]=i.useState(void 0),[f,m]=i.useState(void 0),[p,g]=i.useState(void 0),[E,w]=i.useState(ct.LOADING),T=i.useRef(!1),b=i.useRef(void 0),y=i.useRef(void 0),[v,A]=i.useReducer(D,U),C=i.useMemo((()=>({eventTargetState:v,eventTargetDispatch:A})),[v,A]),I=new EventTarget,x=e=>{c({payload:{type:R.UPDATE_VIEW,view:{type:Ze.SALE_FAIL,data:{errorType:Ye.SMART_CHECKOUT_EXECUTE_ERROR,errorData:e}}}})},j=i.useCallback((async e=>{if(!o||!s)throw new Error("checkout or provider not available.");const t=await o.getNetworkInfo({provider:s});if(e.type===k.BRIDGE){if(m({tokenAddress:e.fundingItem.token.address,amount:e.fundingItem.fundsRequired.formattedAmount}),t.chainId===L(o.config))return void w(ct.EXECUTE_BRIDGE);T.current=ct.EXECUTE_BRIDGE,w(ct.SWITCH_NETWORK_ETH)}if(e.type===k.SWAP){if(h({amount:e.fundingItem.fundsRequired.formattedAmount,fromTokenAddress:e.fundingItem.token.address,toTokenAddress:d}),t.chainId===F(o.config))return void w(ct.EXECUTE_SWAP);T.current=ct.EXECUTE_SWAP,w(ct.SWITCH_NETWORK_ZKEVM)}e.type===k.ONRAMP&&(g({amount:e.fundingItem.fundsRequired.formattedAmount,tokenAddress:e.fundingItem.token.address}),w(ct.EXECUTE_ON_RAMP))}),[s,o]);i.useEffect((()=>{if(e)try{j(e)}catch(e){x(e)}}),[e]);const $=()=>{b.current?(b.current=void 0,y.current=void 0,t()):x(y.current)},q=e=>{switch(e.detail.type){case G.TRANSACTION_SENT:case V.SUCCESS:case Z.SUCCESS:{const t=e.detail.data;b.current=t;break}case G.FAILURE:case V.FAILURE:case Z.FAILURE:{const t=e.detail.data;y.current=t;break}case G.CLOSE_WIDGET:case V.CLOSE_WIDGET:case Z.CLOSE_WIDGET:$();case V.REJECTED:}},J=e=>{switch(e.detail.type){case Y.SUCCESS:{const t=e.detail.data;u({payload:{type:X.SET_PROVIDER,provider:t.provider}}),!1!==T.current&&(w(T.current),T.current=!1);break}case Y.FAILURE:case Y.CLOSE_WIDGET:default:$()}};return i.useEffect((()=>(I.addEventListener(M.IMTBL_CONNECT_WIDGET_EVENT,J),I.addEventListener(M.IMTBL_BRIDGE_WIDGET_EVENT,q),I.addEventListener(M.IMTBL_SWAP_WIDGET_EVENT,q),()=>{I.removeEventListener(M.IMTBL_CONNECT_WIDGET_EVENT,J),I.removeEventListener(M.IMTBL_BRIDGE_WIDGET_EVENT,q),I.removeEventListener(M.IMTBL_SWAP_WIDGET_EVENT,q)})),[]),i.useEffect((()=>{A({payload:{type:z.SET_EVENT_TARGET,eventTarget:I}})}),[o]),l(K.Provider,{value:C,children:[E===ct.LOADING&&r(P,{loadingText:n("views.FUND_WITH_SMART_CHECKOUT.loading.checkingBalances")}),E===ct.EXECUTE_BRIDGE&&r(be,{...f,config:a,checkout:o}),E===ct.EXECUTE_SWAP&&r(Ae,{..._,config:a}),E===ct.EXECUTE_ON_RAMP&&r(ye,{config:a,...p}),E===ct.SWITCH_NETWORK_ETH&&r(H,{config:a,targetChainId:o.config.isProduction?B.ETHEREUM:B.SEPOLIA,web3Provider:s,checkout:o,deepLink:W.SWITCH_NETWORK}),E===ct.SWITCH_NETWORK_ZKEVM&&r(H,{config:a,targetChainId:o.config.isProduction?B.IMTBL_ZKEVM_MAINNET:B.IMTBL_ZKEVM_TESTNET,web3Provider:s,checkout:o,deepLink:W.SWITCH_NETWORK})]})}!function(e){e.LOADING="LOADING",e.EXECUTE_SWAP="EXECUTE_SWAP",e.EXECUTE_BRIDGE="EXECUTE_BRIDGE",e.EXECUTE_ON_RAMP="EXECUTE_ON_RAMP",e.SWITCH_NETWORK_ETH="SWITCH_NETWORK_ETH",e.SWITCH_NETWORK_ZKEVM="SWITCH_NETWORK_ZKEVM"}(ct||(ct={}));const _t={[B.IMTBL_ZKEVM_DEVNET]:"Immutable",[B.IMTBL_ZKEVM_MAINNET]:"Immutable",[B.IMTBL_ZKEVM_TESTNET]:"Immutable",[B.ETHEREUM]:"EthToken",[B.SEPOLIA]:"EthToken"},ht={[B.IMTBL_ZKEVM_DEVNET]:"base.color.text.link.primary",[B.IMTBL_ZKEVM_TESTNET]:"base.color.text.link.primary",[B.IMTBL_ZKEVM_MAINNET]:"base.color.text.link.primary",[B.ETHEREUM]:"base.color.accent.5",[B.SEPOLIA]:"base.color.accent.5"};function ft({onClick:e,fundingRoute:t,toggleVisible:n,selected:a,size:s="small"}){const{t:o}=O(),d=t.steps[0],{cryptoFiatState:c}=i.useContext(ke),{isPassportWallet:u}=lt(),[_,h]=i.useState(void 0),[f,m]=i.useState(void 0);i.useEffect((()=>{if(c.conversions)try{h(tt(t,c.conversions)),m(C(d.fundingItem.userBalance.formattedBalance,d.fundingItem.token.symbol,c.conversions))}catch{h(void 0),m(void 0)}}),[c,t]);return l(j,{emphasized:!0,testId:"funding-route-menu-item",onClick:e,selected:a,size:s,children:[n&&r(j.IntentIcon,{icon:"ChevronExpand"}),r(j.FramedIcon,{icon:"Coins",circularFrame:!0}),r(j.PriceDisplay,{use:r($,{size:"xSmall"}),fiatAmount:`${o("views.FUND_WITH_SMART_CHECKOUT.currency.usdEstimate")}${f}`,price:q(d.fundingItem.userBalance.formattedBalance)}),l(j.Label,{sx:{display:"flex",wordBreak:"default"},children:[d.fundingItem.token.symbol,u?null:l(Re.Button,{rc:r("a",{}),sx:{pointerEvents:"none",cursor:"default",height:"100%",marginLeft:"base.spacing.x2",fontSize:"base.text.body.xxSmall.regular.fontSize",fontWeight:"base.text.body.xxSmall.regular.fontWeight",color:"base.color.brand.4",paddingLeft:"base.spacing.x2",paddingRight:"base.spacing.x2"},size:"small",children:[r(E.Icon,{icon:_t[d.chainId],sx:{width:"14px",fill:ht[d.chainId]}}),J(d.chainId)]})]}),l(j.Caption,{children:["Fees ≈ USD $",_]})]})}function mt({visible:e,onCloseDrawer:t,fundingRoutes:n,activeFundingRouteIndex:a}){const{t:s}=O();return r(Q,{size:"full",onCloseDrawer:()=>t(a),visible:e,showHeaderBar:!0,headerBarTitle:s("views.FUND_WITH_SMART_CHECKOUT.fundingRouteDrawer.header"),children:r(Q.Content,{children:n.map(((e,n)=>r(ft,{onClick:()=>{t(n)},fundingRoute:e,selected:a===n,size:"medium"},e.steps[0].fundingItem.type+e.steps[0].fundingItem.token)))})})}function pt({fundingRoute:e,collectionName:t}){const{t:n}=O(),{items:a}=lt(),s=a[0],o=e.steps[0],{cryptoFiatState:d}=i.useContext(ke),[c,u]=i.useState(void 0);return i.useEffect((()=>{if(d.conversions)try{u(C(o.fundingItem.fundsRequired.formattedAmount,o.fundingItem.token.symbol,d.conversions))}catch{u(void 0)}}),[d,e]),l(j,{emphasized:!0,testId:"funding-route-purchase-item",size:"medium",children:[r(j.FramedImage,{imageUrl:s?.image}),r(j.PriceDisplay,{use:r($,{size:"xSmall"}),price:`${o?.fundingItem.token.symbol} \n ${q(o.fundingItem.fundsRequired.formattedAmount)}`,fiatAmount:`${n("views.FUND_WITH_SMART_CHECKOUT.currency.usdEstimate")}${c}`}),l(j.Label,{children:[s?.name,s?.qty>1?` x${s.qty}`:null]}),r(j.Caption,{children:t})]},s?.name)}function gt({fundingRoutes:e,collectionName:t,onFundingRouteSelected:n}){const{t:a}=O(),[s,o]=i.useState(!1),[d,c]=i.useState(0),{viewDispatch:u}=i.useContext(S),{eventTargetState:{eventTarget:h}}=i.useContext(K),{goBackToPaymentMethods:m}=lt();return l(ae,{testId:"funding-route-select",header:r(te,{onCloseButtonClick:()=>ee(h)}),footer:r(ne,{}),children:[l(_,{sx:{display:"flex",flexDirection:"column",paddingX:"base.spacing.x2",paddingY:"base.spacing.x8",rowGap:"base.spacing.x4",height:"100%"},children:[r($,{size:"small",children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.heading")}),0===e.length?[r(f,{size:"small",children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.noRoutesAvailable")},"noRoutesAvailableText"),r(E,{variant:"tertiary",children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.payWithCard")},"payWithCardButton")]:[r(ft,{"data-testid":"funding-route-select-selected-route",onClick:e.length>1?()=>{o(!0)}:()=>{},fundingRoute:e[d],selected:!0,toggleVisible:e.length>1},"selectedFundingRouteMenuItem"),r(pt,{fundingRoute:e[d],collectionName:t},"purchaseMenuItem"),r(E,{sx:{mt:"auto"},variant:"primary",onClick:()=>{n(e[d]),u({payload:{type:R.UPDATE_VIEW,view:{type:Ze.FUND_WITH_SMART_CHECKOUT,subView:Ge.FUNDING_ROUTE_EXECUTE}}})},children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.continue")},"continueButton"),r(E,{variant:"tertiary",onClick:()=>m(),children:a("views.FUND_WITH_SMART_CHECKOUT.fundingRouteSelect.payWithCardInstead")},"payWithCardButton")]]}),r(mt,{visible:s,onCloseDrawer:e=>{c(e),o(!1)},fundingRoutes:e,activeFundingRouteIndex:d})]})}const Et=e=>e.map((({method:e,hash:t})=>`${e}: ${t}`)).join(" | "),wt=e=>e.split("_").map((e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase())).join(""),Tt=e=>e.replace(/[^\u0000-\u00FF]/g,""),bt=()=>{const{track:e,page:t}=se(),{recipientAddress:n,recipientEmail:a,signResponse:s,paymentMethod:r}=lt(),{eventTargetState:{eventTarget:o}}=i.useContext(K),d=Ze.PAYMENT_METHODS,l={location:"web",userJourney:ie.SALE},c={email:a,userId:n,paymentMethod:r},u={amount:s?.order.totalAmount,currency:s?.order.currency.name};return{track:e,page:t,sendPageView:(e,n)=>{t({...l,screen:wt(e),action:"Viewed",...n})},sendCloseEvent:(t=d,n="Button",a="Pressed")=>{e({...l,screen:wt(t),control:"Close",controlType:n,action:a,extras:{...c}}),ee(o)},sendSuccessEvent:(t=d,n=[],a=[],s={})=>{e({...l,screen:wt(t),control:"Success",controlType:"Event",action:"Succeeded",extras:{...s,...c,transactions:Et(n),...u,paymentMethod:r,tokenIds:a}}),re(o,r,n,a,s.transactionId)},sendFailedEvent:(t,n,a=[],s=d,i={})=>{e({...l,screen:wt(s||d),control:"Fail",controlType:"Event",action:"Failed",extras:{...i,transactions:Et(a),...n,...u,...c,paymentMethod:r,reason:t}}),oe(o,t,n,r,a,i.transactionId)},sendTransactionSuccessEvent:e=>{de(o,r,[e])},sendOrderCreated:(t,n)=>{e({...l,screen:wt(t),control:"OrderCreated",controlType:"Event",extras:{...n}})},sendSelectedPaymentMethod:(t,n)=>{e({...l,screen:wt(n),control:"Select",controlType:"MenuItem",extras:{paymentMethod:t}}),le(o,t)}}};function yt({subView:e}){const{t:t}=O(),{sendPageView:n}=bt(),{viewDispatch:a}=i.useContext(S),[s,o]=i.useState(void 0),[d,c]=i.useState(0),{querySmartCheckout:u,fundingRoutes:h,smartCheckoutResult:f,collectionName:m}=lt(),{cryptoFiatDispatch:p}=i.useContext(ke);i.useEffect((()=>{e===Ge.INIT&&u()}),[e]),i.useEffect((()=>{if(!p||!f)return;const e=nt(f);p({payload:{type:Ce.SET_TOKEN_SYMBOLS,tokenSymbols:e}})}),[p,f]);const g=i.useMemo((()=>{if(s)return s.steps[d]}),[s,d]);return i.useEffect((()=>n(Ze.FUND_WITH_SMART_CHECKOUT,{subView:e,...!!g&&{fundingStep:g.type}})),[]),l(_,{children:[e===Ge.INIT&&r(P,{loadingText:t("views.FUND_WITH_SMART_CHECKOUT.loading.checkingBalances")}),e===Ge.FUNDING_ROUTE_SELECT&&r(gt,{fundingRoutes:h,collectionName:m,onFundingRouteSelected:e=>{o(e)}}),e===Ge.FUNDING_ROUTE_EXECUTE&&r(ut,{onFundingRouteExecuted:()=>{s&&(d===s.steps.length-1?(c(0),o(void 0),a({payload:{type:R.UPDATE_VIEW,view:{type:Ze.FUND_WITH_SMART_CHECKOUT,subView:Ge.INIT}}})):c(d+1))},fundingRouteStep:g})]})}
2
2
  /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */function vt(e){let t=e.length;for(;--t>=0;)e[t]=0}const At=256,kt=286,Ct=30,It=15,St=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),Rt=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),xt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),Ot=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Nt=new Array(576);vt(Nt);const Dt=new Array(60);vt(Dt);const Ut=new Array(512);vt(Ut);const Lt=new Array(256);vt(Lt);const Ft=new Array(29);vt(Ft);const Mt=new Array(Ct);function zt(e,t,n,a,s){this.static_tree=e,this.extra_bits=t,this.extra_base=n,this.elems=a,this.max_length=s,this.has_stree=e&&e.length}let Pt,Bt,Wt;function Ht(e,t){this.dyn_tree=e,this.max_code=0,this.stat_desc=t}vt(Mt);const Kt=e=>e<256?Ut[e]:Ut[256+(e>>>7)],Vt=(e,t)=>{e.pending_buf[e.pending++]=255&t,e.pending_buf[e.pending++]=t>>>8&255},Zt=(e,t,n)=>{e.bi_valid>16-n?(e.bi_buf|=t<<e.bi_valid&65535,Vt(e,e.bi_buf),e.bi_buf=t>>16-e.bi_valid,e.bi_valid+=n-16):(e.bi_buf|=t<<e.bi_valid&65535,e.bi_valid+=n)},Gt=(e,t,n)=>{Zt(e,n[2*t],n[2*t+1])},Yt=(e,t)=>{let n=0;do{n|=1&e,e>>>=1,n<<=1}while(--t>0);return n>>>1},Xt=(e,t,n)=>{const a=new Array(16);let s,i,r=0;for(s=1;s<=It;s++)r=r+n[s-1]<<1,a[s]=r;for(i=0;i<=t;i++){let t=e[2*i+1];0!==t&&(e[2*i]=Yt(a[t]++,t))}},jt=e=>{let t;for(t=0;t<kt;t++)e.dyn_ltree[2*t]=0;for(t=0;t<Ct;t++)e.dyn_dtree[2*t]=0;for(t=0;t<19;t++)e.bl_tree[2*t]=0;e.dyn_ltree[512]=1,e.opt_len=e.static_len=0,e.sym_next=e.matches=0},$t=e=>{e.bi_valid>8?Vt(e,e.bi_buf):e.bi_valid>0&&(e.pending_buf[e.pending++]=e.bi_buf),e.bi_buf=0,e.bi_valid=0},qt=(e,t,n,a)=>{const s=2*t,i=2*n;return e[s]<e[i]||e[s]===e[i]&&a[t]<=a[n]},Jt=(e,t,n)=>{const a=e.heap[n];let s=n<<1;for(;s<=e.heap_len&&(s<e.heap_len&&qt(t,e.heap[s+1],e.heap[s],e.depth)&&s++,!qt(t,a,e.heap[s],e.depth));)e.heap[n]=e.heap[s],n=s,s<<=1;e.heap[n]=a},Qt=(e,t,n)=>{let a,s,i,r,o=0;if(0!==e.sym_next)do{a=255&e.pending_buf[e.sym_buf+o++],a+=(255&e.pending_buf[e.sym_buf+o++])<<8,s=e.pending_buf[e.sym_buf+o++],0===a?Gt(e,s,t):(i=Lt[s],Gt(e,i+At+1,t),r=St[i],0!==r&&(s-=Ft[i],Zt(e,s,r)),a--,i=Kt(a),Gt(e,i,n),r=Rt[i],0!==r&&(a-=Mt[i],Zt(e,a,r)))}while(o<e.sym_next);Gt(e,256,t)},en=(e,t)=>{const n=t.dyn_tree,a=t.stat_desc.static_tree,s=t.stat_desc.has_stree,i=t.stat_desc.elems;let r,o,d,l=-1;for(e.heap_len=0,e.heap_max=573,r=0;r<i;r++)0!==n[2*r]?(e.heap[++e.heap_len]=l=r,e.depth[r]=0):n[2*r+1]=0;for(;e.heap_len<2;)d=e.heap[++e.heap_len]=l<2?++l:0,n[2*d]=1,e.depth[d]=0,e.opt_len--,s&&(e.static_len-=a[2*d+1]);for(t.max_code=l,r=e.heap_len>>1;r>=1;r--)Jt(e,n,r);d=i;do{r=e.heap[1],e.heap[1]=e.heap[e.heap_len--],Jt(e,n,1),o=e.heap[1],e.heap[--e.heap_max]=r,e.heap[--e.heap_max]=o,n[2*d]=n[2*r]+n[2*o],e.depth[d]=(e.depth[r]>=e.depth[o]?e.depth[r]:e.depth[o])+1,n[2*r+1]=n[2*o+1]=d,e.heap[1]=d++,Jt(e,n,1)}while(e.heap_len>=2);e.heap[--e.heap_max]=e.heap[1],((e,t)=>{const n=t.dyn_tree,a=t.max_code,s=t.stat_desc.static_tree,i=t.stat_desc.has_stree,r=t.stat_desc.extra_bits,o=t.stat_desc.extra_base,d=t.stat_desc.max_length;let l,c,u,_,h,f,m=0;for(_=0;_<=It;_++)e.bl_count[_]=0;for(n[2*e.heap[e.heap_max]+1]=0,l=e.heap_max+1;l<573;l++)c=e.heap[l],_=n[2*n[2*c+1]+1]+1,_>d&&(_=d,m++),n[2*c+1]=_,c>a||(e.bl_count[_]++,h=0,c>=o&&(h=r[c-o]),f=n[2*c],e.opt_len+=f*(_+h),i&&(e.static_len+=f*(s[2*c+1]+h)));if(0!==m){do{for(_=d-1;0===e.bl_count[_];)_--;e.bl_count[_]--,e.bl_count[_+1]+=2,e.bl_count[d]--,m-=2}while(m>0);for(_=d;0!==_;_--)for(c=e.bl_count[_];0!==c;)u=e.heap[--l],u>a||(n[2*u+1]!==_&&(e.opt_len+=(_-n[2*u+1])*n[2*u],n[2*u+1]=_),c--)}})(e,t),Xt(n,l,e.bl_count)},tn=(e,t,n)=>{let a,s,i=-1,r=t[1],o=0,d=7,l=4;for(0===r&&(d=138,l=3),t[2*(n+1)+1]=65535,a=0;a<=n;a++)s=r,r=t[2*(a+1)+1],++o<d&&s===r||(o<l?e.bl_tree[2*s]+=o:0!==s?(s!==i&&e.bl_tree[2*s]++,e.bl_tree[32]++):o<=10?e.bl_tree[34]++:e.bl_tree[36]++,o=0,i=s,0===r?(d=138,l=3):s===r?(d=6,l=3):(d=7,l=4))},nn=(e,t,n)=>{let a,s,i=-1,r=t[1],o=0,d=7,l=4;for(0===r&&(d=138,l=3),a=0;a<=n;a++)if(s=r,r=t[2*(a+1)+1],!(++o<d&&s===r)){if(o<l)do{Gt(e,s,e.bl_tree)}while(0!=--o);else 0!==s?(s!==i&&(Gt(e,s,e.bl_tree),o--),Gt(e,16,e.bl_tree),Zt(e,o-3,2)):o<=10?(Gt(e,17,e.bl_tree),Zt(e,o-3,3)):(Gt(e,18,e.bl_tree),Zt(e,o-11,7));o=0,i=s,0===r?(d=138,l=3):s===r?(d=6,l=3):(d=7,l=4)}};let an=!1;const sn=(e,t,n,a)=>{Zt(e,0+(a?1:0),3),$t(e),Vt(e,n),Vt(e,~n),n&&e.pending_buf.set(e.window.subarray(t,t+n),e.pending),e.pending+=n};var rn=(e,t,n,a)=>{let s,i,r=0;e.level>0?(2===e.strm.data_type&&(e.strm.data_type=(e=>{let t,n=4093624447;for(t=0;t<=31;t++,n>>>=1)if(1&n&&0!==e.dyn_ltree[2*t])return 0;if(0!==e.dyn_ltree[18]||0!==e.dyn_ltree[20]||0!==e.dyn_ltree[26])return 1;for(t=32;t<At;t++)if(0!==e.dyn_ltree[2*t])return 1;return 0})(e)),en(e,e.l_desc),en(e,e.d_desc),r=(e=>{let t;for(tn(e,e.dyn_ltree,e.l_desc.max_code),tn(e,e.dyn_dtree,e.d_desc.max_code),en(e,e.bl_desc),t=18;t>=3&&0===e.bl_tree[2*Ot[t]+1];t--);return e.opt_len+=3*(t+1)+5+5+4,t})(e),s=e.opt_len+3+7>>>3,i=e.static_len+3+7>>>3,i<=s&&(s=i)):s=i=n+5,n+4<=s&&-1!==t?sn(e,t,n,a):4===e.strategy||i===s?(Zt(e,2+(a?1:0),3),Qt(e,Nt,Dt)):(Zt(e,4+(a?1:0),3),((e,t,n,a)=>{let s;for(Zt(e,t-257,5),Zt(e,n-1,5),Zt(e,a-4,4),s=0;s<a;s++)Zt(e,e.bl_tree[2*Ot[s]+1],3);nn(e,e.dyn_ltree,t-1),nn(e,e.dyn_dtree,n-1)})(e,e.l_desc.max_code+1,e.d_desc.max_code+1,r+1),Qt(e,e.dyn_ltree,e.dyn_dtree)),jt(e),a&&$t(e)},on={_tr_init:e=>{an||((()=>{let e,t,n,a,s;const i=new Array(16);for(n=0,a=0;a<28;a++)for(Ft[a]=n,e=0;e<1<<St[a];e++)Lt[n++]=a;for(Lt[n-1]=a,s=0,a=0;a<16;a++)for(Mt[a]=s,e=0;e<1<<Rt[a];e++)Ut[s++]=a;for(s>>=7;a<Ct;a++)for(Mt[a]=s<<7,e=0;e<1<<Rt[a]-7;e++)Ut[256+s++]=a;for(t=0;t<=It;t++)i[t]=0;for(e=0;e<=143;)Nt[2*e+1]=8,e++,i[8]++;for(;e<=255;)Nt[2*e+1]=9,e++,i[9]++;for(;e<=279;)Nt[2*e+1]=7,e++,i[7]++;for(;e<=287;)Nt[2*e+1]=8,e++,i[8]++;for(Xt(Nt,287,i),e=0;e<Ct;e++)Dt[2*e+1]=5,Dt[2*e]=Yt(e,5);Pt=new zt(Nt,St,257,kt,It),Bt=new zt(Dt,Rt,0,Ct,It),Wt=new zt(new Array(0),xt,0,19,7)})(),an=!0),e.l_desc=new Ht(e.dyn_ltree,Pt),e.d_desc=new Ht(e.dyn_dtree,Bt),e.bl_desc=new Ht(e.bl_tree,Wt),e.bi_buf=0,e.bi_valid=0,jt(e)},_tr_stored_block:sn,_tr_flush_block:rn,_tr_tally:(e,t,n)=>(e.pending_buf[e.sym_buf+e.sym_next++]=t,e.pending_buf[e.sym_buf+e.sym_next++]=t>>8,e.pending_buf[e.sym_buf+e.sym_next++]=n,0===t?e.dyn_ltree[2*n]++:(e.matches++,t--,e.dyn_ltree[2*(Lt[n]+At+1)]++,e.dyn_dtree[2*Kt(t)]++),e.sym_next===e.sym_end),_tr_align:e=>{Zt(e,2,3),Gt(e,256,Nt),(e=>{16===e.bi_valid?(Vt(e,e.bi_buf),e.bi_buf=0,e.bi_valid=0):e.bi_valid>=8&&(e.pending_buf[e.pending++]=255&e.bi_buf,e.bi_buf>>=8,e.bi_valid-=8)})(e)}};var dn=(e,t,n,a)=>{let s=65535&e|0,i=e>>>16&65535|0,r=0;for(;0!==n;){r=n>2e3?2e3:n,n-=r;do{s=s+t[a++]|0,i=i+s|0}while(--r);s%=65521,i%=65521}return s|i<<16|0};const ln=new Uint32Array((()=>{let e,t=[];for(var n=0;n<256;n++){e=n;for(var a=0;a<8;a++)e=1&e?3988292384^e>>>1:e>>>1;t[n]=e}return t})());var cn=(e,t,n,a)=>{const s=ln,i=a+n;e^=-1;for(let n=a;n<i;n++)e=e>>>8^s[255&(e^t[n])];return-1^e},un={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},_n={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:hn,_tr_stored_block:fn,_tr_flush_block:mn,_tr_tally:pn,_tr_align:gn}=on,{Z_NO_FLUSH:En,Z_PARTIAL_FLUSH:wn,Z_FULL_FLUSH:Tn,Z_FINISH:bn,Z_BLOCK:yn,Z_OK:vn,Z_STREAM_END:An,Z_STREAM_ERROR:kn,Z_DATA_ERROR:Cn,Z_BUF_ERROR:In,Z_DEFAULT_COMPRESSION:Sn,Z_FILTERED:Rn,Z_HUFFMAN_ONLY:xn,Z_RLE:On,Z_FIXED:Nn,Z_DEFAULT_STRATEGY:Dn,Z_UNKNOWN:Un,Z_DEFLATED:Ln}=_n,Fn=258,Mn=262,zn=42,Pn=113,Bn=666,Wn=(e,t)=>(e.msg=un[t],t),Hn=e=>2*e-(e>4?9:0),Kn=e=>{let t=e.length;for(;--t>=0;)e[t]=0},Vn=e=>{let t,n,a,s=e.w_size;t=e.hash_size,a=t;do{n=e.head[--a],e.head[a]=n>=s?n-s:0}while(--t);t=s,a=t;do{n=e.prev[--a],e.prev[a]=n>=s?n-s:0}while(--t)};let Zn=(e,t,n)=>(t<<e.hash_shift^n)&e.hash_mask;const Gn=e=>{const t=e.state;let n=t.pending;n>e.avail_out&&(n=e.avail_out),0!==n&&(e.output.set(t.pending_buf.subarray(t.pending_out,t.pending_out+n),e.next_out),e.next_out+=n,t.pending_out+=n,e.total_out+=n,e.avail_out-=n,t.pending-=n,0===t.pending&&(t.pending_out=0))},Yn=(e,t)=>{mn(e,e.block_start>=0?e.block_start:-1,e.strstart-e.block_start,t),e.block_start=e.strstart,Gn(e.strm)},Xn=(e,t)=>{e.pending_buf[e.pending++]=t},jn=(e,t)=>{e.pending_buf[e.pending++]=t>>>8&255,e.pending_buf[e.pending++]=255&t},$n=(e,t,n,a)=>{let s=e.avail_in;return s>a&&(s=a),0===s?0:(e.avail_in-=s,t.set(e.input.subarray(e.next_in,e.next_in+s),n),1===e.state.wrap?e.adler=dn(e.adler,t,s,n):2===e.state.wrap&&(e.adler=cn(e.adler,t,s,n)),e.next_in+=s,e.total_in+=s,s)},qn=(e,t)=>{let n,a,s=e.max_chain_length,i=e.strstart,r=e.prev_length,o=e.nice_match;const d=e.strstart>e.w_size-Mn?e.strstart-(e.w_size-Mn):0,l=e.window,c=e.w_mask,u=e.prev,_=e.strstart+Fn;let h=l[i+r-1],f=l[i+r];e.prev_length>=e.good_match&&(s>>=2),o>e.lookahead&&(o=e.lookahead);do{if(n=t,l[n+r]===f&&l[n+r-1]===h&&l[n]===l[i]&&l[++n]===l[i+1]){i+=2,n++;do{}while(l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&l[++i]===l[++n]&&i<_);if(a=Fn-(_-i),i=_-Fn,a>r){if(e.match_start=t,r=a,a>=o)break;h=l[i+r-1],f=l[i+r]}}}while((t=u[t&c])>d&&0!=--s);return r<=e.lookahead?r:e.lookahead},Jn=e=>{const t=e.w_size;let n,a,s;do{if(a=e.window_size-e.lookahead-e.strstart,e.strstart>=t+(t-Mn)&&(e.window.set(e.window.subarray(t,t+t-a),0),e.match_start-=t,e.strstart-=t,e.block_start-=t,e.insert>e.strstart&&(e.insert=e.strstart),Vn(e),a+=t),0===e.strm.avail_in)break;if(n=$n(e.strm,e.window,e.strstart+e.lookahead,a),e.lookahead+=n,e.lookahead+e.insert>=3)for(s=e.strstart-e.insert,e.ins_h=e.window[s],e.ins_h=Zn(e,e.ins_h,e.window[s+1]);e.insert&&(e.ins_h=Zn(e,e.ins_h,e.window[s+3-1]),e.prev[s&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=s,s++,e.insert--,!(e.lookahead+e.insert<3)););}while(e.lookahead<Mn&&0!==e.strm.avail_in)},Qn=(e,t)=>{let n,a,s,i=e.pending_buf_size-5>e.w_size?e.w_size:e.pending_buf_size-5,r=0,o=e.strm.avail_in;do{if(n=65535,s=e.bi_valid+42>>3,e.strm.avail_out<s)break;if(s=e.strm.avail_out-s,a=e.strstart-e.block_start,n>a+e.strm.avail_in&&(n=a+e.strm.avail_in),n>s&&(n=s),n<i&&(0===n&&t!==bn||t===En||n!==a+e.strm.avail_in))break;r=t===bn&&n===a+e.strm.avail_in?1:0,fn(e,0,0,r),e.pending_buf[e.pending-4]=n,e.pending_buf[e.pending-3]=n>>8,e.pending_buf[e.pending-2]=~n,e.pending_buf[e.pending-1]=~n>>8,Gn(e.strm),a&&(a>n&&(a=n),e.strm.output.set(e.window.subarray(e.block_start,e.block_start+a),e.strm.next_out),e.strm.next_out+=a,e.strm.avail_out-=a,e.strm.total_out+=a,e.block_start+=a,n-=a),n&&($n(e.strm,e.strm.output,e.strm.next_out,n),e.strm.next_out+=n,e.strm.avail_out-=n,e.strm.total_out+=n)}while(0===r);return o-=e.strm.avail_in,o&&(o>=e.w_size?(e.matches=2,e.window.set(e.strm.input.subarray(e.strm.next_in-e.w_size,e.strm.next_in),0),e.strstart=e.w_size,e.insert=e.strstart):(e.window_size-e.strstart<=o&&(e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,e.insert>e.strstart&&(e.insert=e.strstart)),e.window.set(e.strm.input.subarray(e.strm.next_in-o,e.strm.next_in),e.strstart),e.strstart+=o,e.insert+=o>e.w_size-e.insert?e.w_size-e.insert:o),e.block_start=e.strstart),e.high_water<e.strstart&&(e.high_water=e.strstart),r?4:t!==En&&t!==bn&&0===e.strm.avail_in&&e.strstart===e.block_start?2:(s=e.window_size-e.strstart,e.strm.avail_in>s&&e.block_start>=e.w_size&&(e.block_start-=e.w_size,e.strstart-=e.w_size,e.window.set(e.window.subarray(e.w_size,e.w_size+e.strstart),0),e.matches<2&&e.matches++,s+=e.w_size,e.insert>e.strstart&&(e.insert=e.strstart)),s>e.strm.avail_in&&(s=e.strm.avail_in),s&&($n(e.strm,e.window,e.strstart,s),e.strstart+=s,e.insert+=s>e.w_size-e.insert?e.w_size-e.insert:s),e.high_water<e.strstart&&(e.high_water=e.strstart),s=e.bi_valid+42>>3,s=e.pending_buf_size-s>65535?65535:e.pending_buf_size-s,i=s>e.w_size?e.w_size:s,a=e.strstart-e.block_start,(a>=i||(a||t===bn)&&t!==En&&0===e.strm.avail_in&&a<=s)&&(n=a>s?s:a,r=t===bn&&0===e.strm.avail_in&&n===a?1:0,fn(e,e.block_start,n,r),e.block_start+=n,Gn(e.strm)),r?3:1)},ea=(e,t)=>{let n,a;for(;;){if(e.lookahead<Mn){if(Jn(e),e.lookahead<Mn&&t===En)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=Zn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),0!==n&&e.strstart-n<=e.w_size-Mn&&(e.match_length=qn(e,n)),e.match_length>=3)if(a=pn(e,e.strstart-e.match_start,e.match_length-3),e.lookahead-=e.match_length,e.match_length<=e.max_lazy_match&&e.lookahead>=3){e.match_length--;do{e.strstart++,e.ins_h=Zn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart}while(0!=--e.match_length);e.strstart++}else e.strstart+=e.match_length,e.match_length=0,e.ins_h=e.window[e.strstart],e.ins_h=Zn(e,e.ins_h,e.window[e.strstart+1]);else a=pn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++;if(a&&(Yn(e,!1),0===e.strm.avail_out))return 1}return e.insert=e.strstart<2?e.strstart:2,t===bn?(Yn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Yn(e,!1),0===e.strm.avail_out)?1:2},ta=(e,t)=>{let n,a,s;for(;;){if(e.lookahead<Mn){if(Jn(e),e.lookahead<Mn&&t===En)return 1;if(0===e.lookahead)break}if(n=0,e.lookahead>=3&&(e.ins_h=Zn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart),e.prev_length=e.match_length,e.prev_match=e.match_start,e.match_length=2,0!==n&&e.prev_length<e.max_lazy_match&&e.strstart-n<=e.w_size-Mn&&(e.match_length=qn(e,n),e.match_length<=5&&(e.strategy===Rn||3===e.match_length&&e.strstart-e.match_start>4096)&&(e.match_length=2)),e.prev_length>=3&&e.match_length<=e.prev_length){s=e.strstart+e.lookahead-3,a=pn(e,e.strstart-1-e.prev_match,e.prev_length-3),e.lookahead-=e.prev_length-1,e.prev_length-=2;do{++e.strstart<=s&&(e.ins_h=Zn(e,e.ins_h,e.window[e.strstart+3-1]),n=e.prev[e.strstart&e.w_mask]=e.head[e.ins_h],e.head[e.ins_h]=e.strstart)}while(0!=--e.prev_length);if(e.match_available=0,e.match_length=2,e.strstart++,a&&(Yn(e,!1),0===e.strm.avail_out))return 1}else if(e.match_available){if(a=pn(e,0,e.window[e.strstart-1]),a&&Yn(e,!1),e.strstart++,e.lookahead--,0===e.strm.avail_out)return 1}else e.match_available=1,e.strstart++,e.lookahead--}return e.match_available&&(a=pn(e,0,e.window[e.strstart-1]),e.match_available=0),e.insert=e.strstart<2?e.strstart:2,t===bn?(Yn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Yn(e,!1),0===e.strm.avail_out)?1:2};function na(e,t,n,a,s){this.good_length=e,this.max_lazy=t,this.nice_length=n,this.max_chain=a,this.func=s}const aa=[new na(0,0,0,0,Qn),new na(4,4,8,4,ea),new na(4,5,16,8,ea),new na(4,6,32,32,ea),new na(4,4,16,16,ta),new na(8,16,32,32,ta),new na(8,16,128,128,ta),new na(8,32,128,256,ta),new na(32,128,258,1024,ta),new na(32,258,258,4096,ta)];function sa(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=Ln,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),Kn(this.dyn_ltree),Kn(this.dyn_dtree),Kn(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),Kn(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),Kn(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const ia=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.status!==zn&&57!==t.status&&69!==t.status&&73!==t.status&&91!==t.status&&103!==t.status&&t.status!==Pn&&t.status!==Bn?1:0},ra=e=>{if(ia(e))return Wn(e,kn);e.total_in=e.total_out=0,e.data_type=Un;const t=e.state;return t.pending=0,t.pending_out=0,t.wrap<0&&(t.wrap=-t.wrap),t.status=2===t.wrap?57:t.wrap?zn:Pn,e.adler=2===t.wrap?0:1,t.last_flush=-2,hn(t),vn},oa=e=>{const t=ra(e);var n;return t===vn&&((n=e.state).window_size=2*n.w_size,Kn(n.head),n.max_lazy_match=aa[n.level].max_lazy,n.good_match=aa[n.level].good_length,n.nice_match=aa[n.level].nice_length,n.max_chain_length=aa[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),t},da=(e,t,n,a,s,i)=>{if(!e)return kn;let r=1;if(t===Sn&&(t=6),a<0?(r=0,a=-a):a>15&&(r=2,a-=16),s<1||s>9||n!==Ln||a<8||a>15||t<0||t>9||i<0||i>Nn||8===a&&1!==r)return Wn(e,kn);8===a&&(a=9);const o=new sa;return e.state=o,o.strm=e,o.status=zn,o.wrap=r,o.gzhead=null,o.w_bits=a,o.w_size=1<<o.w_bits,o.w_mask=o.w_size-1,o.hash_bits=s+7,o.hash_size=1<<o.hash_bits,o.hash_mask=o.hash_size-1,o.hash_shift=~~((o.hash_bits+3-1)/3),o.window=new Uint8Array(2*o.w_size),o.head=new Uint16Array(o.hash_size),o.prev=new Uint16Array(o.w_size),o.lit_bufsize=1<<s+6,o.pending_buf_size=4*o.lit_bufsize,o.pending_buf=new Uint8Array(o.pending_buf_size),o.sym_buf=o.lit_bufsize,o.sym_end=3*(o.lit_bufsize-1),o.level=t,o.strategy=i,o.method=n,oa(e)};var la={deflateInit:(e,t)=>da(e,t,Ln,15,8,Dn),deflateInit2:da,deflateReset:oa,deflateResetKeep:ra,deflateSetHeader:(e,t)=>ia(e)||2!==e.state.wrap?kn:(e.state.gzhead=t,vn),deflate:(e,t)=>{if(ia(e)||t>yn||t<0)return e?Wn(e,kn):kn;const n=e.state;if(!e.output||0!==e.avail_in&&!e.input||n.status===Bn&&t!==bn)return Wn(e,0===e.avail_out?In:kn);const a=n.last_flush;if(n.last_flush=t,0!==n.pending){if(Gn(e),0===e.avail_out)return n.last_flush=-1,vn}else if(0===e.avail_in&&Hn(t)<=Hn(a)&&t!==bn)return Wn(e,In);if(n.status===Bn&&0!==e.avail_in)return Wn(e,In);if(n.status===zn&&0===n.wrap&&(n.status=Pn),n.status===zn){let t=Ln+(n.w_bits-8<<4)<<8,a=-1;if(a=n.strategy>=xn||n.level<2?0:n.level<6?1:6===n.level?2:3,t|=a<<6,0!==n.strstart&&(t|=32),t+=31-t%31,jn(n,t),0!==n.strstart&&(jn(n,e.adler>>>16),jn(n,65535&e.adler)),e.adler=1,n.status=Pn,Gn(e),0!==n.pending)return n.last_flush=-1,vn}if(57===n.status)if(e.adler=0,Xn(n,31),Xn(n,139),Xn(n,8),n.gzhead)Xn(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),Xn(n,255&n.gzhead.time),Xn(n,n.gzhead.time>>8&255),Xn(n,n.gzhead.time>>16&255),Xn(n,n.gzhead.time>>24&255),Xn(n,9===n.level?2:n.strategy>=xn||n.level<2?4:0),Xn(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(Xn(n,255&n.gzhead.extra.length),Xn(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(e.adler=cn(e.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(Xn(n,0),Xn(n,0),Xn(n,0),Xn(n,0),Xn(n,0),Xn(n,9===n.level?2:n.strategy>=xn||n.level<2?4:0),Xn(n,3),n.status=Pn,Gn(e),0!==n.pending)return n.last_flush=-1,vn;if(69===n.status){if(n.gzhead.extra){let t=n.pending,a=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+a>n.pending_buf_size;){let s=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+s),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>t&&(e.adler=cn(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex+=s,Gn(e),0!==n.pending)return n.last_flush=-1,vn;t=0,a-=s}let s=new Uint8Array(n.gzhead.extra);n.pending_buf.set(s.subarray(n.gzindex,n.gzindex+a),n.pending),n.pending+=a,n.gzhead.hcrc&&n.pending>t&&(e.adler=cn(e.adler,n.pending_buf,n.pending-t,t)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let t,a=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>a&&(e.adler=cn(e.adler,n.pending_buf,n.pending-a,a)),Gn(e),0!==n.pending)return n.last_flush=-1,vn;a=0}t=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,Xn(n,t)}while(0!==t);n.gzhead.hcrc&&n.pending>a&&(e.adler=cn(e.adler,n.pending_buf,n.pending-a,a)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let t,a=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>a&&(e.adler=cn(e.adler,n.pending_buf,n.pending-a,a)),Gn(e),0!==n.pending)return n.last_flush=-1,vn;a=0}t=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,Xn(n,t)}while(0!==t);n.gzhead.hcrc&&n.pending>a&&(e.adler=cn(e.adler,n.pending_buf,n.pending-a,a))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(Gn(e),0!==n.pending))return n.last_flush=-1,vn;Xn(n,255&e.adler),Xn(n,e.adler>>8&255),e.adler=0}if(n.status=Pn,Gn(e),0!==n.pending)return n.last_flush=-1,vn}if(0!==e.avail_in||0!==n.lookahead||t!==En&&n.status!==Bn){let a=0===n.level?Qn(n,t):n.strategy===xn?((e,t)=>{let n;for(;;){if(0===e.lookahead&&(Jn(e),0===e.lookahead)){if(t===En)return 1;break}if(e.match_length=0,n=pn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++,n&&(Yn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===bn?(Yn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Yn(e,!1),0===e.strm.avail_out)?1:2})(n,t):n.strategy===On?((e,t)=>{let n,a,s,i;const r=e.window;for(;;){if(e.lookahead<=Fn){if(Jn(e),e.lookahead<=Fn&&t===En)return 1;if(0===e.lookahead)break}if(e.match_length=0,e.lookahead>=3&&e.strstart>0&&(s=e.strstart-1,a=r[s],a===r[++s]&&a===r[++s]&&a===r[++s])){i=e.strstart+Fn;do{}while(a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&a===r[++s]&&s<i);e.match_length=Fn-(i-s),e.match_length>e.lookahead&&(e.match_length=e.lookahead)}if(e.match_length>=3?(n=pn(e,1,e.match_length-3),e.lookahead-=e.match_length,e.strstart+=e.match_length,e.match_length=0):(n=pn(e,0,e.window[e.strstart]),e.lookahead--,e.strstart++),n&&(Yn(e,!1),0===e.strm.avail_out))return 1}return e.insert=0,t===bn?(Yn(e,!0),0===e.strm.avail_out?3:4):e.sym_next&&(Yn(e,!1),0===e.strm.avail_out)?1:2})(n,t):aa[n.level].func(n,t);if(3!==a&&4!==a||(n.status=Bn),1===a||3===a)return 0===e.avail_out&&(n.last_flush=-1),vn;if(2===a&&(t===wn?gn(n):t!==yn&&(fn(n,0,0,!1),t===Tn&&(Kn(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),Gn(e),0===e.avail_out))return n.last_flush=-1,vn}return t!==bn?vn:n.wrap<=0?An:(2===n.wrap?(Xn(n,255&e.adler),Xn(n,e.adler>>8&255),Xn(n,e.adler>>16&255),Xn(n,e.adler>>24&255),Xn(n,255&e.total_in),Xn(n,e.total_in>>8&255),Xn(n,e.total_in>>16&255),Xn(n,e.total_in>>24&255)):(jn(n,e.adler>>>16),jn(n,65535&e.adler)),Gn(e),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?vn:An)},deflateEnd:e=>{if(ia(e))return kn;const t=e.state.status;return e.state=null,t===Pn?Wn(e,Cn):vn},deflateSetDictionary:(e,t)=>{let n=t.length;if(ia(e))return kn;const a=e.state,s=a.wrap;if(2===s||1===s&&a.status!==zn||a.lookahead)return kn;if(1===s&&(e.adler=dn(e.adler,t,n,0)),a.wrap=0,n>=a.w_size){0===s&&(Kn(a.head),a.strstart=0,a.block_start=0,a.insert=0);let e=new Uint8Array(a.w_size);e.set(t.subarray(n-a.w_size,n),0),t=e,n=a.w_size}const i=e.avail_in,r=e.next_in,o=e.input;for(e.avail_in=n,e.next_in=0,e.input=t,Jn(a);a.lookahead>=3;){let e=a.strstart,t=a.lookahead-2;do{a.ins_h=Zn(a,a.ins_h,a.window[e+3-1]),a.prev[e&a.w_mask]=a.head[a.ins_h],a.head[a.ins_h]=e,e++}while(--t);a.strstart=e,a.lookahead=2,Jn(a)}return a.strstart+=a.lookahead,a.block_start=a.strstart,a.insert=a.lookahead,a.lookahead=0,a.match_length=a.prev_length=2,a.match_available=0,e.next_in=r,e.input=o,e.avail_in=i,a.wrap=s,vn},deflateInfo:"pako deflate (from Nodeca project)"};const ca=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var ua={assign:function(e){const t=Array.prototype.slice.call(arguments,1);for(;t.length;){const n=t.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const t in n)ca(n,t)&&(e[t]=n[t])}}return e},flattenChunks:e=>{let t=0;for(let n=0,a=e.length;n<a;n++)t+=e[n].length;const n=new Uint8Array(t);for(let t=0,a=0,s=e.length;t<s;t++){let s=e[t];n.set(s,a),a+=s.length}return n}};let _a=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(e){_a=!1}const ha=new Uint8Array(256);for(let e=0;e<256;e++)ha[e]=e>=252?6:e>=248?5:e>=240?4:e>=224?3:e>=192?2:1;ha[254]=ha[254]=1;var fa={string2buf:e=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(e);let t,n,a,s,i,r=e.length,o=0;for(s=0;s<r;s++)n=e.charCodeAt(s),55296==(64512&n)&&s+1<r&&(a=e.charCodeAt(s+1),56320==(64512&a)&&(n=65536+(n-55296<<10)+(a-56320),s++)),o+=n<128?1:n<2048?2:n<65536?3:4;for(t=new Uint8Array(o),i=0,s=0;i<o;s++)n=e.charCodeAt(s),55296==(64512&n)&&s+1<r&&(a=e.charCodeAt(s+1),56320==(64512&a)&&(n=65536+(n-55296<<10)+(a-56320),s++)),n<128?t[i++]=n:n<2048?(t[i++]=192|n>>>6,t[i++]=128|63&n):n<65536?(t[i++]=224|n>>>12,t[i++]=128|n>>>6&63,t[i++]=128|63&n):(t[i++]=240|n>>>18,t[i++]=128|n>>>12&63,t[i++]=128|n>>>6&63,t[i++]=128|63&n);return t},buf2string:(e,t)=>{const n=t||e.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(e.subarray(0,t));let a,s;const i=new Array(2*n);for(s=0,a=0;a<n;){let t=e[a++];if(t<128){i[s++]=t;continue}let r=ha[t];if(r>4)i[s++]=65533,a+=r-1;else{for(t&=2===r?31:3===r?15:7;r>1&&a<n;)t=t<<6|63&e[a++],r--;r>1?i[s++]=65533:t<65536?i[s++]=t:(t-=65536,i[s++]=55296|t>>10&1023,i[s++]=56320|1023&t)}}return((e,t)=>{if(t<65534&&e.subarray&&_a)return String.fromCharCode.apply(null,e.length===t?e:e.subarray(0,t));let n="";for(let a=0;a<t;a++)n+=String.fromCharCode(e[a]);return n})(i,s)},utf8border:(e,t)=>{(t=t||e.length)>e.length&&(t=e.length);let n=t-1;for(;n>=0&&128==(192&e[n]);)n--;return n<0||0===n?t:n+ha[e[n]]>t?n:t}};var ma=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const pa=Object.prototype.toString,{Z_NO_FLUSH:ga,Z_SYNC_FLUSH:Ea,Z_FULL_FLUSH:wa,Z_FINISH:Ta,Z_OK:ba,Z_STREAM_END:ya,Z_DEFAULT_COMPRESSION:va,Z_DEFAULT_STRATEGY:Aa,Z_DEFLATED:ka}=_n;function Ca(e){this.options=ua.assign({level:va,method:ka,chunkSize:16384,windowBits:15,memLevel:8,strategy:Aa},e||{});let t=this.options;t.raw&&t.windowBits>0?t.windowBits=-t.windowBits:t.gzip&&t.windowBits>0&&t.windowBits<16&&(t.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ma,this.strm.avail_out=0;let n=la.deflateInit2(this.strm,t.level,t.method,t.windowBits,t.memLevel,t.strategy);if(n!==ba)throw new Error(un[n]);if(t.header&&la.deflateSetHeader(this.strm,t.header),t.dictionary){let e;if(e="string"==typeof t.dictionary?fa.string2buf(t.dictionary):"[object ArrayBuffer]"===pa.call(t.dictionary)?new Uint8Array(t.dictionary):t.dictionary,n=la.deflateSetDictionary(this.strm,e),n!==ba)throw new Error(un[n]);this._dict_set=!0}}function Ia(e,t){const n=new Ca(t);if(n.push(e,!0),n.err)throw n.msg||un[n.err];return n.result}Ca.prototype.push=function(e,t){const n=this.strm,a=this.options.chunkSize;let s,i;if(this.ended)return!1;for(i=t===~~t?t:!0===t?Ta:ga,"string"==typeof e?n.input=fa.string2buf(e):"[object ArrayBuffer]"===pa.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(a),n.next_out=0,n.avail_out=a),(i===Ea||i===wa)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(s=la.deflate(n,i),s===ya)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),s=la.deflateEnd(this.strm),this.onEnd(s),this.ended=!0,s===ba;if(0!==n.avail_out){if(i>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},Ca.prototype.onData=function(e){this.chunks.push(e)},Ca.prototype.onEnd=function(e){e===ba&&(this.result=ua.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Sa={Deflate:Ca,deflate:Ia,deflateRaw:function(e,t){return(t=t||{}).raw=!0,Ia(e,t)},gzip:function(e,t){return(t=t||{}).gzip=!0,Ia(e,t)},constants:_n};const Ra=16209;var xa=function(e,t){let n,a,s,i,r,o,d,l,c,u,_,h,f,m,p,g,E,w,T,b,y,v,A,k;const C=e.state;n=e.next_in,A=e.input,a=n+(e.avail_in-5),s=e.next_out,k=e.output,i=s-(t-e.avail_out),r=s+(e.avail_out-257),o=C.dmax,d=C.wsize,l=C.whave,c=C.wnext,u=C.window,_=C.hold,h=C.bits,f=C.lencode,m=C.distcode,p=(1<<C.lenbits)-1,g=(1<<C.distbits)-1;e:do{h<15&&(_+=A[n++]<<h,h+=8,_+=A[n++]<<h,h+=8),E=f[_&p];t:for(;;){if(w=E>>>24,_>>>=w,h-=w,w=E>>>16&255,0===w)k[s++]=65535&E;else{if(!(16&w)){if(0==(64&w)){E=f[(65535&E)+(_&(1<<w)-1)];continue t}if(32&w){C.mode=16191;break e}e.msg="invalid literal/length code",C.mode=Ra;break e}T=65535&E,w&=15,w&&(h<w&&(_+=A[n++]<<h,h+=8),T+=_&(1<<w)-1,_>>>=w,h-=w),h<15&&(_+=A[n++]<<h,h+=8,_+=A[n++]<<h,h+=8),E=m[_&g];n:for(;;){if(w=E>>>24,_>>>=w,h-=w,w=E>>>16&255,!(16&w)){if(0==(64&w)){E=m[(65535&E)+(_&(1<<w)-1)];continue n}e.msg="invalid distance code",C.mode=Ra;break e}if(b=65535&E,w&=15,h<w&&(_+=A[n++]<<h,h+=8,h<w&&(_+=A[n++]<<h,h+=8)),b+=_&(1<<w)-1,b>o){e.msg="invalid distance too far back",C.mode=Ra;break e}if(_>>>=w,h-=w,w=s-i,b>w){if(w=b-w,w>l&&C.sane){e.msg="invalid distance too far back",C.mode=Ra;break e}if(y=0,v=u,0===c){if(y+=d-w,w<T){T-=w;do{k[s++]=u[y++]}while(--w);y=s-b,v=k}}else if(c<w){if(y+=d+c-w,w-=c,w<T){T-=w;do{k[s++]=u[y++]}while(--w);if(y=0,c<T){w=c,T-=w;do{k[s++]=u[y++]}while(--w);y=s-b,v=k}}}else if(y+=c-w,w<T){T-=w;do{k[s++]=u[y++]}while(--w);y=s-b,v=k}for(;T>2;)k[s++]=v[y++],k[s++]=v[y++],k[s++]=v[y++],T-=3;T&&(k[s++]=v[y++],T>1&&(k[s++]=v[y++]))}else{y=s-b;do{k[s++]=k[y++],k[s++]=k[y++],k[s++]=k[y++],T-=3}while(T>2);T&&(k[s++]=k[y++],T>1&&(k[s++]=k[y++]))}break}}break}}while(n<a&&s<r);T=h>>3,n-=T,h-=T<<3,_&=(1<<h)-1,e.next_in=n,e.next_out=s,e.avail_in=n<a?a-n+5:5-(n-a),e.avail_out=s<r?r-s+257:257-(s-r),C.hold=_,C.bits=h};const Oa=15,Na=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Da=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),Ua=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),La=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var Fa=(e,t,n,a,s,i,r,o)=>{const d=o.bits;let l,c,u,_,h,f,m=0,p=0,g=0,E=0,w=0,T=0,b=0,y=0,v=0,A=0,k=null;const C=new Uint16Array(16),I=new Uint16Array(16);let S,R,x,O=null;for(m=0;m<=Oa;m++)C[m]=0;for(p=0;p<a;p++)C[t[n+p]]++;for(w=d,E=Oa;E>=1&&0===C[E];E--);if(w>E&&(w=E),0===E)return s[i++]=20971520,s[i++]=20971520,o.bits=1,0;for(g=1;g<E&&0===C[g];g++);for(w<g&&(w=g),y=1,m=1;m<=Oa;m++)if(y<<=1,y-=C[m],y<0)return-1;if(y>0&&(0===e||1!==E))return-1;for(I[1]=0,m=1;m<Oa;m++)I[m+1]=I[m]+C[m];for(p=0;p<a;p++)0!==t[n+p]&&(r[I[t[n+p]]++]=p);if(0===e?(k=O=r,f=20):1===e?(k=Na,O=Da,f=257):(k=Ua,O=La,f=0),A=0,p=0,m=g,h=i,T=w,b=0,u=-1,v=1<<w,_=v-1,1===e&&v>852||2===e&&v>592)return 1;for(;;){S=m-b,r[p]+1<f?(R=0,x=r[p]):r[p]>=f?(R=O[r[p]-f],x=k[r[p]-f]):(R=96,x=0),l=1<<m-b,c=1<<T,g=c;do{c-=l,s[h+(A>>b)+c]=S<<24|R<<16|x|0}while(0!==c);for(l=1<<m-1;A&l;)l>>=1;if(0!==l?(A&=l-1,A+=l):A=0,p++,0==--C[m]){if(m===E)break;m=t[n+r[p]]}if(m>w&&(A&_)!==u){for(0===b&&(b=w),h+=g,T=m-b,y=1<<T;T+b<E&&(y-=C[T+b],!(y<=0));)T++,y<<=1;if(v+=1<<T,1===e&&v>852||2===e&&v>592)return 1;u=A&_,s[u]=w<<24|T<<16|h-i|0}}return 0!==A&&(s[h+A]=m-b<<24|64<<16|0),o.bits=w,0};const{Z_FINISH:Ma,Z_BLOCK:za,Z_TREES:Pa,Z_OK:Ba,Z_STREAM_END:Wa,Z_NEED_DICT:Ha,Z_STREAM_ERROR:Ka,Z_DATA_ERROR:Va,Z_MEM_ERROR:Za,Z_BUF_ERROR:Ga,Z_DEFLATED:Ya}=_n,Xa=16180,ja=16190,$a=16191,qa=16192,Ja=16194,Qa=16199,es=16200,ts=16206,ns=16209,as=e=>(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24);function ss(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const is=e=>{if(!e)return 1;const t=e.state;return!t||t.strm!==e||t.mode<Xa||t.mode>16211?1:0},rs=e=>{if(is(e))return Ka;const t=e.state;return e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Xa,t.last=0,t.havedict=0,t.flags=-1,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(852),t.distcode=t.distdyn=new Int32Array(592),t.sane=1,t.back=-1,Ba},os=e=>{if(is(e))return Ka;const t=e.state;return t.wsize=0,t.whave=0,t.wnext=0,rs(e)},ds=(e,t)=>{let n;if(is(e))return Ka;const a=e.state;return t<0?(n=0,t=-t):(n=5+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Ka:(null!==a.window&&a.wbits!==t&&(a.window=null),a.wrap=n,a.wbits=t,os(e))},ls=(e,t)=>{if(!e)return Ka;const n=new ss;e.state=n,n.strm=e,n.window=null,n.mode=Xa;const a=ds(e,t);return a!==Ba&&(e.state=null),a};let cs,us,_s=!0;const hs=e=>{if(_s){cs=new Int32Array(512),us=new Int32Array(32);let t=0;for(;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Fa(1,e.lens,0,288,cs,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Fa(2,e.lens,0,32,us,0,e.work,{bits:5}),_s=!1}e.lencode=cs,e.lenbits=9,e.distcode=us,e.distbits=5},fs=(e,t,n,a)=>{let s;const i=e.state;return null===i.window&&(i.wsize=1<<i.wbits,i.wnext=0,i.whave=0,i.window=new Uint8Array(i.wsize)),a>=i.wsize?(i.window.set(t.subarray(n-i.wsize,n),0),i.wnext=0,i.whave=i.wsize):(s=i.wsize-i.wnext,s>a&&(s=a),i.window.set(t.subarray(n-a,n-a+s),i.wnext),(a-=s)?(i.window.set(t.subarray(n-a,n),0),i.wnext=a,i.whave=i.wsize):(i.wnext+=s,i.wnext===i.wsize&&(i.wnext=0),i.whave<i.wsize&&(i.whave+=s))),0};var ms={inflateReset:os,inflateReset2:ds,inflateResetKeep:rs,inflateInit:e=>ls(e,15),inflateInit2:ls,inflate:(e,t)=>{let n,a,s,i,r,o,d,l,c,u,_,h,f,m,p,g,E,w,T,b,y,v,A=0;const k=new Uint8Array(4);let C,I;const S=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(is(e)||!e.output||!e.input&&0!==e.avail_in)return Ka;n=e.state,n.mode===$a&&(n.mode=qa),r=e.next_out,s=e.output,d=e.avail_out,i=e.next_in,a=e.input,o=e.avail_in,l=n.hold,c=n.bits,u=o,_=d,v=Ba;e:for(;;)switch(n.mode){case Xa:if(0===n.wrap){n.mode=qa;break}for(;c<16;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if(2&n.wrap&&35615===l){0===n.wbits&&(n.wbits=15),n.check=0,k[0]=255&l,k[1]=l>>>8&255,n.check=cn(n.check,k,2,0),l=0,c=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",n.mode=ns;break}if((15&l)!==Ya){e.msg="unknown compression method",n.mode=ns;break}if(l>>>=4,c-=4,y=8+(15&l),0===n.wbits&&(n.wbits=y),y>15||y>n.wbits){e.msg="invalid window size",n.mode=ns;break}n.dmax=1<<n.wbits,n.flags=0,e.adler=n.check=1,n.mode=512&l?16189:$a,l=0,c=0;break;case 16181:for(;c<16;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if(n.flags=l,(255&n.flags)!==Ya){e.msg="unknown compression method",n.mode=ns;break}if(57344&n.flags){e.msg="unknown header flags set",n.mode=ns;break}n.head&&(n.head.text=l>>8&1),512&n.flags&&4&n.wrap&&(k[0]=255&l,k[1]=l>>>8&255,n.check=cn(n.check,k,2,0)),l=0,c=0,n.mode=16182;case 16182:for(;c<32;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}n.head&&(n.head.time=l),512&n.flags&&4&n.wrap&&(k[0]=255&l,k[1]=l>>>8&255,k[2]=l>>>16&255,k[3]=l>>>24&255,n.check=cn(n.check,k,4,0)),l=0,c=0,n.mode=16183;case 16183:for(;c<16;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}n.head&&(n.head.xflags=255&l,n.head.os=l>>8),512&n.flags&&4&n.wrap&&(k[0]=255&l,k[1]=l>>>8&255,n.check=cn(n.check,k,2,0)),l=0,c=0,n.mode=16184;case 16184:if(1024&n.flags){for(;c<16;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}n.length=l,n.head&&(n.head.extra_len=l),512&n.flags&&4&n.wrap&&(k[0]=255&l,k[1]=l>>>8&255,n.check=cn(n.check,k,2,0)),l=0,c=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(h=n.length,h>o&&(h=o),h&&(n.head&&(y=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(a.subarray(i,i+h),y)),512&n.flags&&4&n.wrap&&(n.check=cn(n.check,a,h,i)),o-=h,i+=h,n.length-=h),n.length))break e;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===o)break e;h=0;do{y=a[i+h++],n.head&&y&&n.length<65536&&(n.head.name+=String.fromCharCode(y))}while(y&&h<o);if(512&n.flags&&4&n.wrap&&(n.check=cn(n.check,a,h,i)),o-=h,i+=h,y)break e}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===o)break e;h=0;do{y=a[i+h++],n.head&&y&&n.length<65536&&(n.head.comment+=String.fromCharCode(y))}while(y&&h<o);if(512&n.flags&&4&n.wrap&&(n.check=cn(n.check,a,h,i)),o-=h,i+=h,y)break e}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;c<16;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if(4&n.wrap&&l!==(65535&n.check)){e.msg="header crc mismatch",n.mode=ns;break}l=0,c=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),e.adler=n.check=0,n.mode=$a;break;case 16189:for(;c<32;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}e.adler=n.check=as(l),l=0,c=0,n.mode=ja;case ja:if(0===n.havedict)return e.next_out=r,e.avail_out=d,e.next_in=i,e.avail_in=o,n.hold=l,n.bits=c,Ha;e.adler=n.check=1,n.mode=$a;case $a:if(t===za||t===Pa)break e;case qa:if(n.last){l>>>=7&c,c-=7&c,n.mode=ts;break}for(;c<3;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}switch(n.last=1&l,l>>>=1,c-=1,3&l){case 0:n.mode=16193;break;case 1:if(hs(n),n.mode=Qa,t===Pa){l>>>=2,c-=2;break e}break;case 2:n.mode=16196;break;case 3:e.msg="invalid block type",n.mode=ns}l>>>=2,c-=2;break;case 16193:for(l>>>=7&c,c-=7&c;c<32;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if((65535&l)!=(l>>>16^65535)){e.msg="invalid stored block lengths",n.mode=ns;break}if(n.length=65535&l,l=0,c=0,n.mode=Ja,t===Pa)break e;case Ja:n.mode=16195;case 16195:if(h=n.length,h){if(h>o&&(h=o),h>d&&(h=d),0===h)break e;s.set(a.subarray(i,i+h),r),o-=h,i+=h,d-=h,r+=h,n.length-=h;break}n.mode=$a;break;case 16196:for(;c<14;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if(n.nlen=257+(31&l),l>>>=5,c-=5,n.ndist=1+(31&l),l>>>=5,c-=5,n.ncode=4+(15&l),l>>>=4,c-=4,n.nlen>286||n.ndist>30){e.msg="too many length or distance symbols",n.mode=ns;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;c<3;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}n.lens[S[n.have++]]=7&l,l>>>=3,c-=3}for(;n.have<19;)n.lens[S[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,C={bits:n.lenbits},v=Fa(0,n.lens,0,19,n.lencode,0,n.work,C),n.lenbits=C.bits,v){e.msg="invalid code lengths set",n.mode=ns;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;A=n.lencode[l&(1<<n.lenbits)-1],p=A>>>24,g=A>>>16&255,E=65535&A,!(p<=c);){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if(E<16)l>>>=p,c-=p,n.lens[n.have++]=E;else{if(16===E){for(I=p+2;c<I;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if(l>>>=p,c-=p,0===n.have){e.msg="invalid bit length repeat",n.mode=ns;break}y=n.lens[n.have-1],h=3+(3&l),l>>>=2,c-=2}else if(17===E){for(I=p+3;c<I;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}l>>>=p,c-=p,y=0,h=3+(7&l),l>>>=3,c-=3}else{for(I=p+7;c<I;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}l>>>=p,c-=p,y=0,h=11+(127&l),l>>>=7,c-=7}if(n.have+h>n.nlen+n.ndist){e.msg="invalid bit length repeat",n.mode=ns;break}for(;h--;)n.lens[n.have++]=y}}if(n.mode===ns)break;if(0===n.lens[256]){e.msg="invalid code -- missing end-of-block",n.mode=ns;break}if(n.lenbits=9,C={bits:n.lenbits},v=Fa(1,n.lens,0,n.nlen,n.lencode,0,n.work,C),n.lenbits=C.bits,v){e.msg="invalid literal/lengths set",n.mode=ns;break}if(n.distbits=6,n.distcode=n.distdyn,C={bits:n.distbits},v=Fa(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,C),n.distbits=C.bits,v){e.msg="invalid distances set",n.mode=ns;break}if(n.mode=Qa,t===Pa)break e;case Qa:n.mode=es;case es:if(o>=6&&d>=258){e.next_out=r,e.avail_out=d,e.next_in=i,e.avail_in=o,n.hold=l,n.bits=c,xa(e,_),r=e.next_out,s=e.output,d=e.avail_out,i=e.next_in,a=e.input,o=e.avail_in,l=n.hold,c=n.bits,n.mode===$a&&(n.back=-1);break}for(n.back=0;A=n.lencode[l&(1<<n.lenbits)-1],p=A>>>24,g=A>>>16&255,E=65535&A,!(p<=c);){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if(g&&0==(240&g)){for(w=p,T=g,b=E;A=n.lencode[b+((l&(1<<w+T)-1)>>w)],p=A>>>24,g=A>>>16&255,E=65535&A,!(w+p<=c);){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}l>>>=w,c-=w,n.back+=w}if(l>>>=p,c-=p,n.back+=p,n.length=E,0===g){n.mode=16205;break}if(32&g){n.back=-1,n.mode=$a;break}if(64&g){e.msg="invalid literal/length code",n.mode=ns;break}n.extra=15&g,n.mode=16201;case 16201:if(n.extra){for(I=n.extra;c<I;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}n.length+=l&(1<<n.extra)-1,l>>>=n.extra,c-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;A=n.distcode[l&(1<<n.distbits)-1],p=A>>>24,g=A>>>16&255,E=65535&A,!(p<=c);){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if(0==(240&g)){for(w=p,T=g,b=E;A=n.distcode[b+((l&(1<<w+T)-1)>>w)],p=A>>>24,g=A>>>16&255,E=65535&A,!(w+p<=c);){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}l>>>=w,c-=w,n.back+=w}if(l>>>=p,c-=p,n.back+=p,64&g){e.msg="invalid distance code",n.mode=ns;break}n.offset=E,n.extra=15&g,n.mode=16203;case 16203:if(n.extra){for(I=n.extra;c<I;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}n.offset+=l&(1<<n.extra)-1,l>>>=n.extra,c-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){e.msg="invalid distance too far back",n.mode=ns;break}n.mode=16204;case 16204:if(0===d)break e;if(h=_-d,n.offset>h){if(h=n.offset-h,h>n.whave&&n.sane){e.msg="invalid distance too far back",n.mode=ns;break}h>n.wnext?(h-=n.wnext,f=n.wsize-h):f=n.wnext-h,h>n.length&&(h=n.length),m=n.window}else m=s,f=r-n.offset,h=n.length;h>d&&(h=d),d-=h,n.length-=h;do{s[r++]=m[f++]}while(--h);0===n.length&&(n.mode=es);break;case 16205:if(0===d)break e;s[r++]=n.length,d--,n.mode=es;break;case ts:if(n.wrap){for(;c<32;){if(0===o)break e;o--,l|=a[i++]<<c,c+=8}if(_-=d,e.total_out+=_,n.total+=_,4&n.wrap&&_&&(e.adler=n.check=n.flags?cn(n.check,s,_,r-_):dn(n.check,s,_,r-_)),_=d,4&n.wrap&&(n.flags?l:as(l))!==n.check){e.msg="incorrect data check",n.mode=ns;break}l=0,c=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;c<32;){if(0===o)break e;o--,l+=a[i++]<<c,c+=8}if(4&n.wrap&&l!==(4294967295&n.total)){e.msg="incorrect length check",n.mode=ns;break}l=0,c=0}n.mode=16208;case 16208:v=Wa;break e;case ns:v=Va;break e;case 16210:return Za;default:return Ka}return e.next_out=r,e.avail_out=d,e.next_in=i,e.avail_in=o,n.hold=l,n.bits=c,(n.wsize||_!==e.avail_out&&n.mode<ns&&(n.mode<ts||t!==Ma))&&fs(e,e.output,e.next_out,_-e.avail_out),u-=e.avail_in,_-=e.avail_out,e.total_in+=u,e.total_out+=_,n.total+=_,4&n.wrap&&_&&(e.adler=n.check=n.flags?cn(n.check,s,_,e.next_out-_):dn(n.check,s,_,e.next_out-_)),e.data_type=n.bits+(n.last?64:0)+(n.mode===$a?128:0)+(n.mode===Qa||n.mode===Ja?256:0),(0===u&&0===_||t===Ma)&&v===Ba&&(v=Ga),v},inflateEnd:e=>{if(is(e))return Ka;let t=e.state;return t.window&&(t.window=null),e.state=null,Ba},inflateGetHeader:(e,t)=>{if(is(e))return Ka;const n=e.state;return 0==(2&n.wrap)?Ka:(n.head=t,t.done=!1,Ba)},inflateSetDictionary:(e,t)=>{const n=t.length;let a,s,i;return is(e)?Ka:(a=e.state,0!==a.wrap&&a.mode!==ja?Ka:a.mode===ja&&(s=1,s=dn(s,t,n,0),s!==a.check)?Va:(i=fs(e,t,n,n),i?(a.mode=16210,Za):(a.havedict=1,Ba)))},inflateInfo:"pako inflate (from Nodeca project)"};var ps=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const gs=Object.prototype.toString,{Z_NO_FLUSH:Es,Z_FINISH:ws,Z_OK:Ts,Z_STREAM_END:bs,Z_NEED_DICT:ys,Z_STREAM_ERROR:vs,Z_DATA_ERROR:As,Z_MEM_ERROR:ks}=_n;function Cs(e){this.options=ua.assign({chunkSize:65536,windowBits:15,to:""},e||{});const t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new ma,this.strm.avail_out=0;let n=ms.inflateInit2(this.strm,t.windowBits);if(n!==Ts)throw new Error(un[n]);if(this.header=new ps,ms.inflateGetHeader(this.strm,this.header),t.dictionary&&("string"==typeof t.dictionary?t.dictionary=fa.string2buf(t.dictionary):"[object ArrayBuffer]"===gs.call(t.dictionary)&&(t.dictionary=new Uint8Array(t.dictionary)),t.raw&&(n=ms.inflateSetDictionary(this.strm,t.dictionary),n!==Ts)))throw new Error(un[n])}function Is(e,t){const n=new Cs(t);if(n.push(e),n.err)throw n.msg||un[n.err];return n.result}Cs.prototype.push=function(e,t){const n=this.strm,a=this.options.chunkSize,s=this.options.dictionary;let i,r,o;if(this.ended)return!1;for(r=t===~~t?t:!0===t?ws:Es,"[object ArrayBuffer]"===gs.call(e)?n.input=new Uint8Array(e):n.input=e,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(a),n.next_out=0,n.avail_out=a),i=ms.inflate(n,r),i===ys&&s&&(i=ms.inflateSetDictionary(n,s),i===Ts?i=ms.inflate(n,r):i===As&&(i=ys));n.avail_in>0&&i===bs&&n.state.wrap>0&&0!==e[n.next_in];)ms.inflateReset(n),i=ms.inflate(n,r);switch(i){case vs:case As:case ys:case ks:return this.onEnd(i),this.ended=!0,!1}if(o=n.avail_out,n.next_out&&(0===n.avail_out||i===bs))if("string"===this.options.to){let e=fa.utf8border(n.output,n.next_out),t=n.next_out-e,s=fa.buf2string(n.output,e);n.next_out=t,n.avail_out=a-t,t&&n.output.set(n.output.subarray(e,e+t),0),this.onData(s)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(i!==Ts||0!==o){if(i===bs)return i=ms.inflateEnd(this.strm),this.onEnd(i),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Cs.prototype.onData=function(e){this.chunks.push(e)},Cs.prototype.onEnd=function(e){e===Ts&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=ua.flattenChunks(this.chunks)),this.chunks=[],this.err=e,this.msg=this.strm.msg};var Ss={Inflate:Cs,inflate:Is,inflateRaw:function(e,t){return(t=t||{}).raw=!0,Is(e,t)},ungzip:Is,constants:_n};const{Deflate:Rs,deflate:xs,deflateRaw:Os,gzip:Ns}=Sa,{Inflate:Ds,inflate:Us,inflateRaw:Ls,ungzip:Fs}=Ss;var Ms={Deflate:Rs,deflate:xs,deflateRaw:Os,gzip:Ns,Inflate:Ds,inflate:Us,inflateRaw:Ls,ungzip:Fs,constants:_n};const zs={[w.SANDBOX]:"https://global-stg.transak.com",[w.PRODUCTION]:"https://global.transak.com/"},Ps={[w.SANDBOX]:"STAGING",[w.PRODUCTION]:"PRODUCTION"},Bs={[w.SANDBOX]:"d14b44fb-0f84-4db5-affb-e044040d724b",[w.PRODUCTION]:"ad1bca70-d917-4628-bb0f-5609537498bc"},Ws=e=>{const{contractId:t,environment:n,transakParams:a}=e,[s,r]=i.useState(""),o=i.useCallback((()=>{const{calldata:e,nftData:s,estimatedGasLimit:i,...r}=a,o=s?.slice(0,1).map((e=>({...e,imageURL:Tt(e.imageURL),nftName:Tt(e.nftName)}))),d=i>0?i:"30000000",l={apiKey:Bs[n],isNFT:"true",disableWalletAddressForm:"true",contractId:t,environment:Ps[n],calldata:btoa(String.fromCharCode.apply(null,Ms.deflate(e))),nftData:btoa(JSON.stringify(o)),estimatedGasLimit:d.toString(),...r,themeColor:"0D0D0D"};return`${`${zs[n]}?`}${new URLSearchParams(l).toString()}`}),[e]);return i.useEffect((()=>{r(o())}),[e]),{iframeSrc:s}};function Hs(e){const{id:t,type:n,email:a,walletAddress:s,isPassportWallet:o,nftData:d,calldata:l,cryptoCurrencyCode:c,estimatedGasLimit:u,exchangeScreenTitle:_,partnerOrderId:h,onOpen:f,onInit:m,onOrderCreated:p,onOrderProcessing:g,onOrderCompleted:E,onOrderFailed:w,onFailedToLoad:T,failedToLoadTimeoutInMs:b,environment:y,contractId:v}=e,A=i.useRef(null),{onLoad:k,initialised:C}=ve({userJourney:ie.SALE,ref:A,email:a,userId:s,isPassportWallet:o,onOpen:f,onOrderCreated:p,onOrderProcessing:g,onOrderCompleted:E,onOrderFailed:w,onInit:m,failedToLoadTimeoutInMs:b,onFailedToLoad:T}),{iframeSrc:I}=Ws({type:n,contractId:v,environment:y,transakParams:{nftData:d,calldata:l,cryptoCurrencyCode:c,estimatedGasLimit:u,exchangeScreenTitle:_,email:a,walletAddress:s,partnerOrderId:h}});return r("iframe",{id:t,ref:A,src:I,title:"Transak-Iframe",allow:"camera;microphone;fullscreen;payment",style:{height:"100%",width:"100%",border:"none",position:"absolute",top:0,left:0,opacity:C?1:0,transition:"opacity 0.5s ease-out"},onLoad:k,onError:()=>T?.()})}function Ks(e){const{t:t}=O(),{onInit:n,onOpen:a,onOrderCreated:s,onOrderProcessing:o,onOrderCompleted:d,onOrderFailed:l}=e,{recipientEmail:c,recipientAddress:u,isPassportWallet:_,signResponse:h,goToErrorView:f,environment:m,clientConfig:p}=lt(),g=h?.transactions.find((e=>e.methodCall.startsWith("execute")));if(!h||!g)return null;const E=i.useMemo((()=>h.order.products.map((e=>({collectionAddress:e.collectionAddress,imageURL:e.image,nftName:e.name,price:e.amount,quantity:e.qty,tokenID:e.tokenId,nftType:e.contractType||"ERC721"})))),[h]);return r(Hs,{id:"transak-iframe",type:"nft-checkout",email:c,walletAddress:u,isPassportWallet:_,exchangeScreenTitle:t("views.PAY_WITH_CARD.screenTitle"),nftData:E,calldata:g.rawData,cryptoCurrencyCode:h.order.currency.name,estimatedGasLimit:g.gasEstimate,partnerOrderId:g.params.reference,onInit:n,onOpen:a,onOrderCreated:s,onOrderProcessing:o,onOrderCompleted:d,onOrderFailed:l,onFailedToLoad:()=>{f(Ye.TRANSACTION_FAILED)},environment:m,contractId:p.contractId})}function Vs(){const{sendPageView:e}=bt(),[t,n]=i.useState(!1),{goBackToPaymentMethods:a,goToErrorView:s,signResponse:o,signTokenIds:d}=lt(),{sendOrderCreated:c,sendCloseEvent:u,sendSuccessEvent:h}=bt(),{t:f}=O(),m=(e={})=>{const{id:t,status:n,cryptoAmount:a,cryptoCurrency:s,fiatAmount:i,fiatAmountInUsd:r,amountPaid:l,totalFeeInFiat:c,paymentOptionId:_,userId:f,userKycType:m,walletAddress:p,nftAssetInfo:g}=e,{nftDataBase64:E,quantity:w}=g||{},T={orderId:t,orderStatus:n,cryptoAmount:a,cryptoCurrency:s,fiatAmount:i,fiatAmountInUsd:r,amountPaid:l,totalFeeInFiat:c,paymentOption:_,userId:f,userKycType:m,walletAddress:p,nftDataBase64:E,quantity:w,signData:o,transactionId:o?.transactionId};h(Ze.SALE_SUCCESS,[],d,T),u(Ze.SALE_SUCCESS)};return i.useEffect((()=>e(Ze.PAY_WITH_CARD)),[]),r(ae,{header:t&&r(te,{onCloseButtonClick:()=>a()}),children:l(ue,{children:[r(ce,{visible:!t,children:r(ce.Content,{children:r(ce.Content.LoopingText,{text:[f("views.PAY_WITH_CARD.loading")]})})}),r(_,{style:{display:"block",position:"relative",maxWidth:"420px",height:"565px",borderRadius:"1%",overflow:"hidden",margin:"0 auto",width:"100%"},children:r(Ks,{onInit:()=>n(!0),onOrderFailed:()=>{s(Ye.TRANSAK_FAILED)},onOrderCompleted:m,onOrderCreated:(e={})=>{const{id:t,status:n,cryptoAmount:a,cryptoCurrency:s,fiatAmount:i,fiatAmountInUsd:r,amountPaid:d,totalFeeInFiat:l,paymentOptionId:u,userId:_,userKycType:h,walletAddress:f,nftAssetInfo:m}=e,{nftDataBase64:p,quantity:g}=m||{};c(Ze.PAY_WITH_CARD,{orderId:t,orderStatus:n,cryptoAmount:a,cryptoCurrency:s,fiatAmount:i,fiatAmountInUsd:r,amountPaid:d,totalFeeInFiat:l,paymentOption:u,userId:_,userKycType:h,walletAddress:f,nftDataBase64:p,quantity:g,signData:o,transactionId:o?.transactionId})},onOrderProcessing:m})})]})})}function Zs(){const{t:e}=O(),t=i.useRef(!1),{sendPageView:n,sendTransactionSuccessEvent:a,sendFailedEvent:s,sendCloseEvent:o,sendSuccessEvent:d}=bt(),{execute:l,signResponse:c,executeResponse:u,signTokenIds:_,provider:h}=lt(),f=u?.transactions.length||0;let m=[e("views.PAYMENT_METHODS.loading.ready1"),e("views.PAYMENT_METHODS.loading.ready2"),e("views.PAYMENT_METHODS.loading.ready3")];f>=1&&(m=[e("views.PAYMENT_METHODS.loading.processing1"),e("views.PAYMENT_METHODS.loading.processing2"),e("views.PAYMENT_METHODS.loading.processing3")]);return i.useEffect((()=>{void 0!==c&&!1===t.current&&(t.current=!0,(async()=>{const e=!("isMetaMask"in h?.provider&&h?.provider.isMetaMask);l(c,e,(e=>{a(e)}),((e,t)=>{const n={transactionId:c?.transactionId};s(e.toString(),e,t,void 0,n)}))})())}),[c]),i.useEffect((()=>{if(!0===u?.done){const e={transactionId:c?.transactionId};d(Ze.SALE_SUCCESS,u?.transactions,_,e),o(Ze.SALE_SUCCESS)}}),[u]),i.useEffect((()=>n(Ze.PAY_WITH_COINS)),[]),r(P,{loadingText:m})}function Gs(e){const{t:t}=O(),{type:n,onClick:a,disabled:s}=e,i={[x.CRYPTO]:"Coins",[x.DEBIT]:"BankCard",[x.CREDIT]:"BankCard"};return l(j,{size:"medium",emphasized:!0,onClick:s?void 0:()=>a(n),sx:{...s&&{opacity:"0.5",cursor:"not-allowed"},marginBottom:"base.spacing.x1"},disabled:s,children:[r(j.FramedIcon,{icon:i[n]}),r(j.Label,{size:"medium",children:t(`views.PAYMENT_METHODS.options.${n}.heading`)}),!s&&r(j.IntentIcon,{}),r(j.Caption,{children:t(`views.PAYMENT_METHODS.options.${n}.${s?"disabledCaption":"caption"}`)})]})}const Ys=[x.CRYPTO,x.DEBIT,x.CREDIT];function Xs(e){const{disabledOptions:t=[],onClick:n}=e;return r(_,{testId:"payment-options-list",sx:{width:"100%",display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"flex-start"},children:Ys.map((e=>r(Gs,{disabled:t.includes(e),onClick:n,type:e},`${Math.random()}-${e}`)))})}function js(){const{t:e}=O(),{viewDispatch:t}=i.useContext(S),{smartCheckoutError:n,fromTokenAddress:a,amount:s}=lt();if(n?.data?.error?.message!==Xe.FRACTIONAL_BALANCE_BLOCKED)return null;const o=n?.data?.fractionalBalance||{};let d=e("views.PAYMENT_METHODS.insufficientCoinsBanner.caption");return!o[b.NATIVE]&&o[b.ERC20]&&(d=e("views.PAYMENT_METHODS.insufficientCoinsBanner.gasCaption")),r(_,{sx:{paddingX:"base.spacing.x2"},children:l(qe,{children:[r(qe.Icon,{icon:"InformationCircle"}),r(qe.Caption,{children:r(_e,{i18nKey:d,components:{cta:r(he,{sx:{mx:"base.spacing.x1"},onClick:()=>{t({payload:{type:R.UPDATE_VIEW,view:{type:fe.TOP_UP_VIEW,data:{tokenAddress:a,amount:s}}}})}})}})})]})})}function $s(){const{t:e}=O(),{viewDispatch:t}=i.useContext(S),{sign:n,goToErrorView:a,paymentMethod:s,setPaymentMethod:o,disabledPaymentTypes:d,invalidParameters:c}=lt(),{sendPageView:u,sendCloseEvent:h,sendSelectedPaymentMethod:f}=bt();return i.useEffect((()=>{s&&f(s,Ze.PAYMENT_METHODS),s&&[x.DEBIT,x.CREDIT].includes(s)&&(n(je.FIAT,(()=>{t({payload:{type:R.UPDATE_VIEW,view:{type:Ze.PAY_WITH_CARD}}})})),t({payload:{type:R.UPDATE_VIEW,view:{type:fe.LOADING_VIEW,data:{loadingText:e("views.PAYMENT_METHODS.loading.ready1")}}}})),s&&s===x.CRYPTO&&t({payload:{type:R.UPDATE_VIEW,view:{type:Ze.FUND_WITH_SMART_CHECKOUT,subView:Ge.INIT}}})}),[s]),i.useEffect((()=>u(Ze.PAYMENT_METHODS)),[]),i.useEffect((()=>{c&&a(Ye.INVALID_PARAMETERS)}),[c]),r(ae,{testId:"payment-methods",header:r(te,{onCloseButtonClick:()=>h(Ze.PAYMENT_METHODS)}),footer:r(ne,{}),children:l(_,{sx:{display:"flex",flexDirection:"column",paddingX:"base.spacing.x2",paddingY:"base.spacing.x8",rowGap:"base.spacing.x4"},children:[r($,{size:"small",sx:{paddingX:"base.spacing.x4"},children:e("views.PAYMENT_METHODS.header.heading")}),r(_,{sx:{paddingX:"base.spacing.x2"},children:r(Xs,{disabledOptions:d,onClick:e=>o(e)})}),r(js,{})]})})}function qs({errorType:e=Ye.DEFAULT,transactionHash:t,blockExplorerLink:n,biomeTheme:a}){const{t:s}=O(),{goBackToPaymentMethods:o}=lt(),{eventTargetState:{eventTarget:d}}=i.useContext(K),l=()=>{ee(d)},c={[Ye.TRANSACTION_FAILED]:{onActionClick:o,onSecondaryActionClick:t?()=>{window.open(n)}:l,statusType:me.FAILURE,statusIconStyles:{fill:a.color.status.destructive.dim}},[Ye.SERVICE_BREAKDOWN]:{onSecondaryActionClick:l,statusType:me.INFORMATION,statusIconStyles:{fill:a.color.status.fatal.dim}},[Ye.PRODUCT_NOT_FOUND]:{onSecondaryActionClick:l,statusType:me.INFORMATION,statusIconStyles:{fill:a.color.status.fatal.dim}},[Ye.INSUFFICIENT_STOCK]:{onSecondaryActionClick:l,statusType:me.INFORMATION,statusIconStyles:{fill:a.color.status.fatal.dim}},[Ye.TRANSAK_FAILED]:{onActionClick:o,onSecondaryActionClick:l,statusType:me.INFORMATION},[Ye.WALLET_FAILED]:{onActionClick:o,onSecondaryActionClick:l,statusType:me.INFORMATION,statusIconStyles:{fill:a.color.status.fatal.dim}},[Ye.WALLET_REJECTED_NO_FUNDS]:{onActionClick:o,onSecondaryActionClick:l,statusType:me.INFORMATION},[Ye.WALLET_REJECTED]:{onActionClick:()=>{o(x.CRYPTO)},onSecondaryActionClick:l,statusType:me.INFORMATION},[Ye.WALLET_POPUP_BLOCKED]:{onActionClick:()=>{o(x.CRYPTO)},onSecondaryActionClick:l,statusType:me.INFORMATION},[Ye.SMART_CHECKOUT_ERROR]:{onActionClick:o,onSecondaryActionClick:l,statusType:me.INFORMATION},[Ye.SMART_CHECKOUT_EXECUTE_ERROR]:{onActionClick:o,onSecondaryActionClick:l,statusType:me.INFORMATION},[Ye.INVALID_PARAMETERS]:{onSecondaryActionClick:l,statusType:me.ALERT,statusIconStyles:{fill:a.color.status.attention.dim,transform:"none"}},[Ye.DEFAULT]:{onActionClick:o,onSecondaryActionClick:l,statusType:me.INFORMATION}};return r(pe,{...(()=>{const n=c[e]||{},i=e===Ye.TRANSACTION_FAILED&&t?s(`views.SALE_FAIL.errors.${Ye.DEFAULT}.secondaryAction`):s(`views.SALE_FAIL.errors.${e}.secondaryAction`);return{testId:"fail-view",statusText:s(`views.SALE_FAIL.errors.${e}.description`),actionText:s(`views.SALE_FAIL.errors.${e}.primaryAction`),onActionClick:n?.onActionClick,secondaryActionText:i,onSecondaryActionClick:n?.onSecondaryActionClick,onCloseClick:l,statusType:n.statusType,statusIconStyles:{transform:"rotate(180deg)",fill:a.color.status.guidance.dim,...n.statusIconStyles}}})()})}function Js({data:e}){const{t:t}=O(),{sendCloseEvent:n,sendSuccessEvent:a}=bt();return r(pe,{statusText:t("views.SALE_SUCCESS.text"),actionText:t("views.SALE_SUCCESS.actionText"),onRenderEvent:()=>{const{transactions:t,tokenIds:n,...s}=e;a(Ze.SALE_SUCCESS,t,n,s)},onActionClick:()=>{n(Ze.SALE_SUCCESS)},statusType:me.SUCCESS,testId:"success-view"})}function Qs(e){const{t:t}=O(),{config:n,amount:a,items:s,environmentId:o,collectionName:d}=e,{connectLoaderState:c}=i.useContext(N),{checkout:u,provider:_}=c,h=i.useRef(),{eventTargetState:{eventTarget:f}}=i.useContext(K),{theme:m}=n,p=i.useMemo((()=>ge(m)),[m]),[g,E]=i.useReducer(Ee,we),w=i.useMemo((()=>({viewState:g,viewDispatch:E})),[g,E]),T=g.view.data?.loadingText||t("views.LOADING_VIEW.text");i.useEffect((()=>{u&&_&&(async()=>{const e=await u.getNetworkInfo({provider:_});h.current=e.chainId})()}),[u,_]);const b=i.useRef(!1),y=i.useCallback((()=>{u&&_&&(b.current||(b.current=!0,E({payload:{type:R.UPDATE_VIEW,view:{type:Ze.PAYMENT_METHODS}}})))}),[u,_]);return i.useEffect((()=>{u&&_&&y()}),[u,_]),r(S.Provider,{value:w,children:r(dt,{value:{config:n,items:s,amount:a,environment:n.environment,environmentId:o,provider:_,checkout:u,passport:u?.passport,collectionName:d},children:l(Se,{environment:n.environment,children:[g.view.type===fe.LOADING_VIEW&&r(P,{loadingText:T}),g.view.type===Ze.PAYMENT_METHODS&&r($s,{}),g.view.type===Ze.PAY_WITH_CARD&&r(Vs,{}),g.view.type===Ze.PAY_WITH_COINS&&r(Zs,{}),g.view.type===Ze.SALE_FAIL&&r(qs,{biomeTheme:p,errorType:g.view.data?.errorType,transactionHash:g.view.data?.transactionHash,blockExplorerLink:Te.getTransactionLink(h.current,g.view.data?.transactionHash)}),g.view.type===Ze.SALE_SUCCESS&&_&&r(Js,{data:g.view.data}),g.view.type===Ze.FUND_WITH_SMART_CHECKOUT&&r(yt,{subView:g.view.subView}),g.view.type===fe.TOP_UP_VIEW&&r(Ie,{analytics:{userJourney:ie.SALE},widgetEvent:M.IMTBL_SALE_WIDGET_EVENT,checkout:u,provider:_,showOnrampOption:n.isOnRampEnabled,showSwapOption:n.isSwapEnabled,showBridgeOption:n.isBridgeEnabled,onCloseButtonClick:()=>ee(f),amount:g.view.data?.amount,tokenAddress:g.view.data?.tokenAddress})]})})})}export{Qs as default};
@@ -1 +1 @@
1
- import{a as o,P as e,B as t,Q as n,R as r,j as i}from"./index-e3a0f33f.js";function C(){return o(t,{sx:{...e,background:"base.color.translucent.emphasis.100"},children:o(t,{sx:{...n,...r},children:i("svg",{width:"430",height:"305",viewBox:"0 0 430 305",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o("path",{d:"M94.0614 105.632L93.6321 104L92 104.429L92.4292 106.061L94.0614 105.632Z",fill:"white"}),o("path",{d:"M63.6531 193.101L63.1006 191L60.9996 191.553L61.5521 193.654L63.6531 193.101Z",fill:"white"}),o("path",{d:"M344.489 224.345L342.345 224L342 226.145L344.144 226.49L344.489 224.345Z",fill:"white"}),o("path",{d:"M372.286 139.905L372.905 138.619L371.619 138L371 139.286L372.286 139.905Z",fill:"white"}),o("path",{d:"M341.653 78.101L341.101 76L339 76.5525L339.552 78.6535L341.653 78.101Z",fill:"white"}),o("path",{d:"M359.286 242.905L359.905 241.619L358.619 241L358 242.286L359.286 242.905Z",fill:"white"}),o("path",{d:"M87.0123 112.087L86.0869 111L85.0002 111.925L85.9256 113.012L87.0123 112.087Z",fill:"white"}),o("path",{d:"M84.2862 248.905L84.9053 247.619L83.6192 247L83.0001 248.286L84.2862 248.905Z",fill:"white"}),o("path",{d:"M215.496 262.992C268.237 262.992 310.993 220.237 310.993 167.496C310.993 114.755 268.237 72 215.496 72C162.755 72 120 114.755 120 167.496C120 220.237 162.755 262.992 215.496 262.992Z",fill:"white",fillOpacity:"0.24",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M159.82 95.1695C179.975 79.6536 204.651 73.1506 227.89 77.0665C261.089 82.6606 253.281 101.028 199.197 121.314C151.934 139.037 123.49 136.348 143.823 110.95C148.422 105.208 153.721 99.8623 159.82 95.1695Z",fill:"white",fillOpacity:"0.08"}),o("path",{d:"M215.497 227.183C171.451 227.183 135.159 219.871 130.194 210.462H130.187C145.912 241.626 178.21 263.001 215.497 263.001C252.705 263.001 284.942 241.719 300.706 210.664C295.33 219.98 259.232 227.183 215.505 227.183H215.497Z",fill:"#36E0F8",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M284.219 219.607L283.978 219.84C281.275 222.482 256.583 215.986 253.172 218.418C222.389 240.36 182.779 269.061 146.099 219.397C146.099 219.397 140.761 217.641 138.609 216.686C139.425 217.96 140.279 219.226 141.165 220.469C170.425 261.516 227.423 271.073 268.47 241.813C276.97 235.752 284.118 228.503 289.852 220.454L292.424 216.841L288.252 218.302C287.086 218.713 285.851 219.11 284.553 219.498L284.227 219.599L284.219 219.607Z",fill:"black"}),o("path",{d:"M215.496 241.4C262.183 241.4 300.03 226.557 300.03 208.248C300.03 189.938 262.183 175.095 215.496 175.095C168.81 175.095 130.963 189.938 130.963 208.248C130.963 226.557 168.81 241.4 215.496 241.4Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M300.705 210.659C300.705 210.659 300.705 210.65 300.705 210.641C300.705 210.641 300.705 210.65 300.705 210.659Z",fill:"#EBE9E9",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 204.511C208.952 204.511 221.377 199.638 221.377 193.626C221.377 187.614 208.952 182.741 193.624 182.741C178.297 182.741 165.871 187.614 165.871 193.626C165.871 199.638 178.297 204.511 193.624 204.511Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 204.511C208.954 204.511 221.377 199.64 221.377 193.626V201.349C221.377 207.363 208.954 212.234 193.624 212.234C178.295 212.234 165.871 207.363 165.871 201.349V193.626C165.871 199.64 178.295 204.511 193.624 204.511Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 204.41C199.49 204.294 201.573 204.084 203.546 203.789V211.512C201.573 211.807 199.49 212.017 197.33 212.133V204.41Z",fill:"#D0F500"}),o("path",{d:"M206.398 203.291C211.246 202.304 215.255 200.774 217.905 198.901V206.624C215.255 208.497 211.246 210.027 206.398 211.014V203.291Z",fill:"black"}),o("path",{d:"M193.624 204.511C208.954 204.511 221.377 199.64 221.377 193.626V201.349C221.377 207.363 208.954 212.234 193.624 212.234C178.295 212.234 165.871 207.363 165.871 201.349V193.626C165.871 199.64 178.295 204.511 193.624 204.511Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 211.015C211.246 210.028 215.255 208.497 217.905 206.625",stroke:"#A66CFF",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 196.788C208.952 196.788 221.377 191.914 221.377 185.903C221.377 179.891 208.952 175.017 193.624 175.017C178.297 175.017 165.871 179.891 165.871 185.903C165.871 191.914 178.297 196.788 193.624 196.788Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 196.788C208.954 196.788 221.377 191.917 221.377 185.903V193.626C221.377 199.639 208.954 204.511 193.624 204.511C178.295 204.511 165.871 199.639 165.871 193.626V185.903C165.871 191.917 178.295 196.788 193.624 196.788Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 196.687C199.49 196.57 201.573 196.361 203.546 196.065V203.788C201.573 204.084 199.49 204.293 197.33 204.41V196.687Z",fill:"#36E0F8"}),o("path",{d:"M206.398 195.568C211.246 194.581 215.255 193.051 217.905 191.178V198.901C215.255 200.774 211.246 202.304 206.398 203.291V195.568Z",fill:"black"}),o("path",{d:"M193.624 196.788C208.954 196.788 221.377 191.917 221.377 185.903V193.626C221.377 199.639 208.954 204.511 193.624 204.511C178.295 204.511 165.871 199.639 165.871 193.626V185.903C165.871 191.917 178.295 196.788 193.624 196.788Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 203.291C211.246 202.304 215.255 200.774 217.905 198.901",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 189.065C208.952 189.065 221.377 184.192 221.377 178.18C221.377 172.168 208.952 167.294 193.624 167.294C178.297 167.294 165.871 172.168 165.871 178.18C165.871 184.192 178.297 189.065 193.624 189.065Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 189.065C208.954 189.065 221.377 184.194 221.377 178.18V185.903C221.377 191.917 208.954 196.788 193.624 196.788C178.295 196.788 165.871 191.917 165.871 185.903V178.18C165.871 184.194 178.295 189.065 193.624 189.065Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 188.965C199.49 188.849 201.573 188.639 203.546 188.343V196.067C201.573 196.362 199.49 196.571 197.33 196.688V188.965Z",fill:"#F191FA"}),o("path",{d:"M206.398 187.845C211.246 186.858 215.255 185.327 217.905 183.455V191.178C215.255 193.05 211.246 194.581 206.398 195.568V187.845Z",fill:"black"}),o("path",{d:"M193.624 189.065C208.954 189.065 221.377 184.194 221.377 178.18V185.903C221.377 191.917 208.954 196.788 193.624 196.788C178.295 196.788 165.871 191.917 165.871 185.903V178.18C165.871 184.194 178.295 189.065 193.624 189.065Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 195.569C211.246 194.582 215.255 193.052 217.905 191.179",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 212.934C253.929 212.934 266.354 208.06 266.354 202.049C266.354 196.037 253.929 191.164 238.601 191.164C223.274 191.164 210.848 196.037 210.848 202.049C210.848 208.06 223.274 212.934 238.601 212.934Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 212.935C253.931 212.935 266.354 208.063 266.354 202.049V209.772C266.354 215.786 253.931 220.658 238.601 220.658C223.272 220.658 210.848 215.786 210.848 209.772V202.049C210.848 208.063 223.272 212.935 238.601 212.935Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 212.833C244.467 212.717 246.55 212.507 248.523 212.212V219.935C246.55 220.23 244.467 220.44 242.307 220.556V212.833Z",fill:"#F191FA"}),o("path",{d:"M251.375 211.713C256.223 210.727 260.232 209.196 262.882 207.324V215.047C260.232 216.919 256.223 218.45 251.375 219.436V211.713Z",fill:"black"}),o("path",{d:"M238.601 212.935C253.931 212.935 266.354 208.063 266.354 202.049V209.772C266.354 215.786 253.931 220.658 238.601 220.658C223.272 220.658 210.848 215.786 210.848 209.772V202.049C210.848 208.063 223.272 212.935 238.601 212.935Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 219.437C256.223 218.45 260.232 216.919 262.882 215.047",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 205.21C253.929 205.21 266.354 200.336 266.354 194.324C266.354 188.313 253.929 183.439 238.601 183.439C223.274 183.439 210.848 188.313 210.848 194.324C210.848 200.336 223.274 205.21 238.601 205.21Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 205.21C253.931 205.21 266.354 200.339 266.354 194.325V202.048C266.354 208.062 253.931 212.934 238.601 212.934C223.272 212.934 210.848 208.062 210.848 202.048V194.325C210.848 200.339 223.272 205.21 238.601 205.21Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 205.109C244.467 204.993 246.55 204.783 248.523 204.488V212.211C246.55 212.506 244.467 212.716 242.307 212.832V205.109Z",fill:"#36E0F8"}),o("path",{d:"M251.375 203.989C256.223 203.003 260.232 201.472 262.882 199.6V207.323C260.232 209.195 256.223 210.726 251.375 211.712V203.989Z",fill:"black"}),o("path",{d:"M238.601 205.21C253.931 205.21 266.354 200.339 266.354 194.325V202.048C266.354 208.062 253.931 212.934 238.601 212.934C223.272 212.934 210.848 208.062 210.848 202.048V194.325C210.848 200.339 223.272 205.21 238.601 205.21Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 211.713C256.223 210.726 260.232 209.195 262.882 207.323",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 197.487C253.929 197.487 266.354 192.613 266.354 186.602C266.354 180.59 253.929 175.716 238.601 175.716C223.274 175.716 210.848 180.59 210.848 186.602C210.848 192.613 223.274 197.487 238.601 197.487Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 197.487C253.931 197.487 266.354 192.616 266.354 186.602V194.325C266.354 200.339 253.931 205.21 238.601 205.21C223.272 205.21 210.848 200.339 210.848 194.325V186.602C210.848 192.616 223.272 197.487 238.601 197.487Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 197.386C244.467 197.27 246.55 197.06 248.523 196.765V204.488C246.55 204.783 244.467 204.992 242.307 205.109V197.386Z",fill:"#F191FA"}),o("path",{d:"M251.375 196.267C256.223 195.28 260.232 193.75 262.882 191.877V199.6C260.232 201.473 256.223 203.003 251.375 203.99V196.267Z",fill:"#9AEFFB"}),o("path",{d:"M238.601 197.487C253.931 197.487 266.354 192.616 266.354 186.602V194.325C266.354 200.339 253.931 205.21 238.601 205.21C223.272 205.21 210.848 200.339 210.848 194.325V186.602C210.848 192.616 223.272 197.487 238.601 197.487Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 203.99C256.223 203.004 260.232 201.473 262.882 199.601",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M232.652 189.678C247.979 189.678 260.405 184.804 260.405 178.793C260.405 172.781 247.979 167.908 232.652 167.908C217.324 167.908 204.899 172.781 204.899 178.793C204.899 184.804 217.324 189.678 232.652 189.678Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M232.652 189.678C247.981 189.678 260.405 184.807 260.405 178.793V186.516C260.405 192.53 247.981 197.401 232.652 197.401C217.323 197.401 204.899 192.53 204.899 186.516V178.793C204.899 184.807 217.323 189.678 232.652 189.678Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M236.358 189.578C238.518 189.461 240.6 189.251 242.574 188.956V196.679C240.6 196.974 238.518 197.184 236.358 197.301V189.578Z",fill:"#F191FA"}),o("path",{d:"M245.426 188.458C250.274 187.471 254.283 185.94 256.932 184.067V191.791C254.283 193.663 250.274 195.194 245.426 196.18V188.458Z",fill:"black"}),o("path",{d:"M232.652 189.678C247.981 189.678 260.405 184.807 260.405 178.793V186.516C260.405 192.53 247.981 197.401 232.652 197.401C217.323 197.401 204.899 192.53 204.899 186.516V178.793C204.899 184.807 217.323 189.678 232.652 189.678Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M245.426 196.182C250.274 195.195 254.283 193.664 256.932 191.792",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M240.99 180.021C256.317 180.021 268.743 175.148 268.743 169.136C268.743 163.124 256.317 158.25 240.99 158.25C225.662 158.25 213.237 163.124 213.237 169.136C213.237 175.148 225.662 180.021 240.99 180.021Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M240.99 180.021C256.319 180.021 268.743 175.15 268.743 169.136V176.859C268.743 182.873 256.319 187.744 240.99 187.744C225.66 187.744 213.237 182.873 213.237 176.859V169.136C213.237 175.15 225.66 180.021 240.99 180.021Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M244.696 179.92C246.856 179.804 248.938 179.594 250.911 179.299V187.022C248.938 187.317 246.856 187.527 244.696 187.643V179.92Z",fill:"#9AEFFB"}),o("path",{d:"M253.763 178.801C258.612 177.815 262.621 176.284 265.27 174.412V182.135C262.621 184.007 258.612 185.538 253.763 186.524V178.801Z",fill:"black"}),o("path",{d:"M240.99 180.021C256.319 180.021 268.743 175.15 268.743 169.136V176.859C268.743 182.873 256.319 187.744 240.99 187.744C225.66 187.744 213.237 182.873 213.237 176.859V169.136C213.237 175.15 225.66 180.021 240.99 180.021Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M253.763 186.525C258.612 185.538 262.621 184.007 265.27 182.135",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M189.911 223.803C205.238 223.803 217.664 218.929 217.664 212.918C217.664 206.906 205.238 202.032 189.911 202.032C174.583 202.032 162.158 206.906 162.158 212.918C162.158 218.929 174.583 223.803 189.911 223.803Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M189.911 223.803C205.24 223.803 217.664 218.932 217.664 212.918V220.641C217.664 226.655 205.24 231.526 189.911 231.526C174.581 231.526 162.158 226.655 162.158 220.641V212.918C162.158 218.932 174.581 223.803 189.911 223.803Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.625 223.71C195.785 223.593 197.867 223.384 199.84 223.088V230.811C197.867 231.107 195.785 231.316 193.625 231.433V223.71Z",fill:"#F191FA"}),o("path",{d:"M202.685 222.583C207.533 221.596 211.542 220.066 214.191 218.193V225.916C211.542 227.789 207.533 229.319 202.685 230.306V222.583Z",fill:"#9AEFFB"}),o("path",{d:"M189.911 223.803C205.24 223.803 217.664 218.932 217.664 212.918V220.641C217.664 226.655 205.24 231.526 189.911 231.526C174.581 231.526 162.158 226.655 162.158 220.641V212.918C162.158 218.932 174.581 223.803 189.911 223.803Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M202.685 230.306C207.533 229.32 211.542 227.789 214.191 225.917",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M300.705 210.658C300.705 210.658 300.705 210.649 300.705 210.641C300.705 210.641 300.705 210.649 300.705 210.658Z",fill:"#A66CFF",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"})]})})})}export{C as S};
1
+ import{a as o,P as e,B as t,Q as n,R as r,j as i}from"./index-394d516d.js";function C(){return o(t,{sx:{...e,background:"base.color.translucent.emphasis.100"},children:o(t,{sx:{...n,...r},children:i("svg",{width:"430",height:"305",viewBox:"0 0 430 305",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[o("path",{d:"M94.0614 105.632L93.6321 104L92 104.429L92.4292 106.061L94.0614 105.632Z",fill:"white"}),o("path",{d:"M63.6531 193.101L63.1006 191L60.9996 191.553L61.5521 193.654L63.6531 193.101Z",fill:"white"}),o("path",{d:"M344.489 224.345L342.345 224L342 226.145L344.144 226.49L344.489 224.345Z",fill:"white"}),o("path",{d:"M372.286 139.905L372.905 138.619L371.619 138L371 139.286L372.286 139.905Z",fill:"white"}),o("path",{d:"M341.653 78.101L341.101 76L339 76.5525L339.552 78.6535L341.653 78.101Z",fill:"white"}),o("path",{d:"M359.286 242.905L359.905 241.619L358.619 241L358 242.286L359.286 242.905Z",fill:"white"}),o("path",{d:"M87.0123 112.087L86.0869 111L85.0002 111.925L85.9256 113.012L87.0123 112.087Z",fill:"white"}),o("path",{d:"M84.2862 248.905L84.9053 247.619L83.6192 247L83.0001 248.286L84.2862 248.905Z",fill:"white"}),o("path",{d:"M215.496 262.992C268.237 262.992 310.993 220.237 310.993 167.496C310.993 114.755 268.237 72 215.496 72C162.755 72 120 114.755 120 167.496C120 220.237 162.755 262.992 215.496 262.992Z",fill:"white",fillOpacity:"0.24",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M159.82 95.1695C179.975 79.6536 204.651 73.1506 227.89 77.0665C261.089 82.6606 253.281 101.028 199.197 121.314C151.934 139.037 123.49 136.348 143.823 110.95C148.422 105.208 153.721 99.8623 159.82 95.1695Z",fill:"white",fillOpacity:"0.08"}),o("path",{d:"M215.497 227.183C171.451 227.183 135.159 219.871 130.194 210.462H130.187C145.912 241.626 178.21 263.001 215.497 263.001C252.705 263.001 284.942 241.719 300.706 210.664C295.33 219.98 259.232 227.183 215.505 227.183H215.497Z",fill:"#36E0F8",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M284.219 219.607L283.978 219.84C281.275 222.482 256.583 215.986 253.172 218.418C222.389 240.36 182.779 269.061 146.099 219.397C146.099 219.397 140.761 217.641 138.609 216.686C139.425 217.96 140.279 219.226 141.165 220.469C170.425 261.516 227.423 271.073 268.47 241.813C276.97 235.752 284.118 228.503 289.852 220.454L292.424 216.841L288.252 218.302C287.086 218.713 285.851 219.11 284.553 219.498L284.227 219.599L284.219 219.607Z",fill:"black"}),o("path",{d:"M215.496 241.4C262.183 241.4 300.03 226.557 300.03 208.248C300.03 189.938 262.183 175.095 215.496 175.095C168.81 175.095 130.963 189.938 130.963 208.248C130.963 226.557 168.81 241.4 215.496 241.4Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M300.705 210.659C300.705 210.659 300.705 210.65 300.705 210.641C300.705 210.641 300.705 210.65 300.705 210.659Z",fill:"#EBE9E9",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 204.511C208.952 204.511 221.377 199.638 221.377 193.626C221.377 187.614 208.952 182.741 193.624 182.741C178.297 182.741 165.871 187.614 165.871 193.626C165.871 199.638 178.297 204.511 193.624 204.511Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 204.511C208.954 204.511 221.377 199.64 221.377 193.626V201.349C221.377 207.363 208.954 212.234 193.624 212.234C178.295 212.234 165.871 207.363 165.871 201.349V193.626C165.871 199.64 178.295 204.511 193.624 204.511Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 204.41C199.49 204.294 201.573 204.084 203.546 203.789V211.512C201.573 211.807 199.49 212.017 197.33 212.133V204.41Z",fill:"#D0F500"}),o("path",{d:"M206.398 203.291C211.246 202.304 215.255 200.774 217.905 198.901V206.624C215.255 208.497 211.246 210.027 206.398 211.014V203.291Z",fill:"black"}),o("path",{d:"M193.624 204.511C208.954 204.511 221.377 199.64 221.377 193.626V201.349C221.377 207.363 208.954 212.234 193.624 212.234C178.295 212.234 165.871 207.363 165.871 201.349V193.626C165.871 199.64 178.295 204.511 193.624 204.511Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 211.015C211.246 210.028 215.255 208.497 217.905 206.625",stroke:"#A66CFF",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 196.788C208.952 196.788 221.377 191.914 221.377 185.903C221.377 179.891 208.952 175.017 193.624 175.017C178.297 175.017 165.871 179.891 165.871 185.903C165.871 191.914 178.297 196.788 193.624 196.788Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 196.788C208.954 196.788 221.377 191.917 221.377 185.903V193.626C221.377 199.639 208.954 204.511 193.624 204.511C178.295 204.511 165.871 199.639 165.871 193.626V185.903C165.871 191.917 178.295 196.788 193.624 196.788Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 196.687C199.49 196.57 201.573 196.361 203.546 196.065V203.788C201.573 204.084 199.49 204.293 197.33 204.41V196.687Z",fill:"#36E0F8"}),o("path",{d:"M206.398 195.568C211.246 194.581 215.255 193.051 217.905 191.178V198.901C215.255 200.774 211.246 202.304 206.398 203.291V195.568Z",fill:"black"}),o("path",{d:"M193.624 196.788C208.954 196.788 221.377 191.917 221.377 185.903V193.626C221.377 199.639 208.954 204.511 193.624 204.511C178.295 204.511 165.871 199.639 165.871 193.626V185.903C165.871 191.917 178.295 196.788 193.624 196.788Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 203.291C211.246 202.304 215.255 200.774 217.905 198.901",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 189.065C208.952 189.065 221.377 184.192 221.377 178.18C221.377 172.168 208.952 167.294 193.624 167.294C178.297 167.294 165.871 172.168 165.871 178.18C165.871 184.192 178.297 189.065 193.624 189.065Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.624 189.065C208.954 189.065 221.377 184.194 221.377 178.18V185.903C221.377 191.917 208.954 196.788 193.624 196.788C178.295 196.788 165.871 191.917 165.871 185.903V178.18C165.871 184.194 178.295 189.065 193.624 189.065Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M197.33 188.965C199.49 188.849 201.573 188.639 203.546 188.343V196.067C201.573 196.362 199.49 196.571 197.33 196.688V188.965Z",fill:"#F191FA"}),o("path",{d:"M206.398 187.845C211.246 186.858 215.255 185.327 217.905 183.455V191.178C215.255 193.05 211.246 194.581 206.398 195.568V187.845Z",fill:"black"}),o("path",{d:"M193.624 189.065C208.954 189.065 221.377 184.194 221.377 178.18V185.903C221.377 191.917 208.954 196.788 193.624 196.788C178.295 196.788 165.871 191.917 165.871 185.903V178.18C165.871 184.194 178.295 189.065 193.624 189.065Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M206.398 195.569C211.246 194.582 215.255 193.052 217.905 191.179",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 212.934C253.929 212.934 266.354 208.06 266.354 202.049C266.354 196.037 253.929 191.164 238.601 191.164C223.274 191.164 210.848 196.037 210.848 202.049C210.848 208.06 223.274 212.934 238.601 212.934Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 212.935C253.931 212.935 266.354 208.063 266.354 202.049V209.772C266.354 215.786 253.931 220.658 238.601 220.658C223.272 220.658 210.848 215.786 210.848 209.772V202.049C210.848 208.063 223.272 212.935 238.601 212.935Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 212.833C244.467 212.717 246.55 212.507 248.523 212.212V219.935C246.55 220.23 244.467 220.44 242.307 220.556V212.833Z",fill:"#F191FA"}),o("path",{d:"M251.375 211.713C256.223 210.727 260.232 209.196 262.882 207.324V215.047C260.232 216.919 256.223 218.45 251.375 219.436V211.713Z",fill:"black"}),o("path",{d:"M238.601 212.935C253.931 212.935 266.354 208.063 266.354 202.049V209.772C266.354 215.786 253.931 220.658 238.601 220.658C223.272 220.658 210.848 215.786 210.848 209.772V202.049C210.848 208.063 223.272 212.935 238.601 212.935Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 219.437C256.223 218.45 260.232 216.919 262.882 215.047",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 205.21C253.929 205.21 266.354 200.336 266.354 194.324C266.354 188.313 253.929 183.439 238.601 183.439C223.274 183.439 210.848 188.313 210.848 194.324C210.848 200.336 223.274 205.21 238.601 205.21Z",fill:"#D0F500",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 205.21C253.931 205.21 266.354 200.339 266.354 194.325V202.048C266.354 208.062 253.931 212.934 238.601 212.934C223.272 212.934 210.848 208.062 210.848 202.048V194.325C210.848 200.339 223.272 205.21 238.601 205.21Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 205.109C244.467 204.993 246.55 204.783 248.523 204.488V212.211C246.55 212.506 244.467 212.716 242.307 212.832V205.109Z",fill:"#36E0F8"}),o("path",{d:"M251.375 203.989C256.223 203.003 260.232 201.472 262.882 199.6V207.323C260.232 209.195 256.223 210.726 251.375 211.712V203.989Z",fill:"black"}),o("path",{d:"M238.601 205.21C253.931 205.21 266.354 200.339 266.354 194.325V202.048C266.354 208.062 253.931 212.934 238.601 212.934C223.272 212.934 210.848 208.062 210.848 202.048V194.325C210.848 200.339 223.272 205.21 238.601 205.21Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 211.713C256.223 210.726 260.232 209.195 262.882 207.323",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 197.487C253.929 197.487 266.354 192.613 266.354 186.602C266.354 180.59 253.929 175.716 238.601 175.716C223.274 175.716 210.848 180.59 210.848 186.602C210.848 192.613 223.274 197.487 238.601 197.487Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M238.601 197.487C253.931 197.487 266.354 192.616 266.354 186.602V194.325C266.354 200.339 253.931 205.21 238.601 205.21C223.272 205.21 210.848 200.339 210.848 194.325V186.602C210.848 192.616 223.272 197.487 238.601 197.487Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M242.307 197.386C244.467 197.27 246.55 197.06 248.523 196.765V204.488C246.55 204.783 244.467 204.992 242.307 205.109V197.386Z",fill:"#F191FA"}),o("path",{d:"M251.375 196.267C256.223 195.28 260.232 193.75 262.882 191.877V199.6C260.232 201.473 256.223 203.003 251.375 203.99V196.267Z",fill:"#9AEFFB"}),o("path",{d:"M238.601 197.487C253.931 197.487 266.354 192.616 266.354 186.602V194.325C266.354 200.339 253.931 205.21 238.601 205.21C223.272 205.21 210.848 200.339 210.848 194.325V186.602C210.848 192.616 223.272 197.487 238.601 197.487Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M251.375 203.99C256.223 203.004 260.232 201.473 262.882 199.601",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M232.652 189.678C247.979 189.678 260.405 184.804 260.405 178.793C260.405 172.781 247.979 167.908 232.652 167.908C217.324 167.908 204.899 172.781 204.899 178.793C204.899 184.804 217.324 189.678 232.652 189.678Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M232.652 189.678C247.981 189.678 260.405 184.807 260.405 178.793V186.516C260.405 192.53 247.981 197.401 232.652 197.401C217.323 197.401 204.899 192.53 204.899 186.516V178.793C204.899 184.807 217.323 189.678 232.652 189.678Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M236.358 189.578C238.518 189.461 240.6 189.251 242.574 188.956V196.679C240.6 196.974 238.518 197.184 236.358 197.301V189.578Z",fill:"#F191FA"}),o("path",{d:"M245.426 188.458C250.274 187.471 254.283 185.94 256.932 184.067V191.791C254.283 193.663 250.274 195.194 245.426 196.18V188.458Z",fill:"black"}),o("path",{d:"M232.652 189.678C247.981 189.678 260.405 184.807 260.405 178.793V186.516C260.405 192.53 247.981 197.401 232.652 197.401C217.323 197.401 204.899 192.53 204.899 186.516V178.793C204.899 184.807 217.323 189.678 232.652 189.678Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M245.426 196.182C250.274 195.195 254.283 193.664 256.932 191.792",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M240.99 180.021C256.317 180.021 268.743 175.148 268.743 169.136C268.743 163.124 256.317 158.25 240.99 158.25C225.662 158.25 213.237 163.124 213.237 169.136C213.237 175.148 225.662 180.021 240.99 180.021Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M240.99 180.021C256.319 180.021 268.743 175.15 268.743 169.136V176.859C268.743 182.873 256.319 187.744 240.99 187.744C225.66 187.744 213.237 182.873 213.237 176.859V169.136C213.237 175.15 225.66 180.021 240.99 180.021Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M244.696 179.92C246.856 179.804 248.938 179.594 250.911 179.299V187.022C248.938 187.317 246.856 187.527 244.696 187.643V179.92Z",fill:"#9AEFFB"}),o("path",{d:"M253.763 178.801C258.612 177.815 262.621 176.284 265.27 174.412V182.135C262.621 184.007 258.612 185.538 253.763 186.524V178.801Z",fill:"black"}),o("path",{d:"M240.99 180.021C256.319 180.021 268.743 175.15 268.743 169.136V176.859C268.743 182.873 256.319 187.744 240.99 187.744C225.66 187.744 213.237 182.873 213.237 176.859V169.136C213.237 175.15 225.66 180.021 240.99 180.021Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M253.763 186.525C258.612 185.538 262.621 184.007 265.27 182.135",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M189.911 223.803C205.238 223.803 217.664 218.929 217.664 212.918C217.664 206.906 205.238 202.032 189.911 202.032C174.583 202.032 162.158 206.906 162.158 212.918C162.158 218.929 174.583 223.803 189.911 223.803Z",fill:"#F191FA",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M189.911 223.803C205.24 223.803 217.664 218.932 217.664 212.918V220.641C217.664 226.655 205.24 231.526 189.911 231.526C174.581 231.526 162.158 226.655 162.158 220.641V212.918C162.158 218.932 174.581 223.803 189.911 223.803Z",fill:"#E4F4F7",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M193.625 223.71C195.785 223.593 197.867 223.384 199.84 223.088V230.811C197.867 231.107 195.785 231.316 193.625 231.433V223.71Z",fill:"#F191FA"}),o("path",{d:"M202.685 222.583C207.533 221.596 211.542 220.066 214.191 218.193V225.916C211.542 227.789 207.533 229.319 202.685 230.306V222.583Z",fill:"#9AEFFB"}),o("path",{d:"M189.911 223.803C205.24 223.803 217.664 218.932 217.664 212.918V220.641C217.664 226.655 205.24 231.526 189.911 231.526C174.581 231.526 162.158 226.655 162.158 220.641V212.918C162.158 218.932 174.581 223.803 189.911 223.803Z",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M202.685 230.306C207.533 229.32 211.542 227.789 214.191 225.917",stroke:"white",strokeLinecap:"round",strokeLinejoin:"round"}),o("path",{d:"M300.705 210.658C300.705 210.658 300.705 210.649 300.705 210.641C300.705 210.641 300.705 210.649 300.705 210.658Z",fill:"#A66CFF",stroke:"black",strokeLinecap:"round",strokeLinejoin:"round"})]})})})}export{C as S};
@@ -1 +1 @@
1
- import{u as e,aM as t,aN as o,j as a,aO as n,B as s,aP as r,a as i,b as d,aQ as c,r as l,aj as p,aR as u,V as m,C as w,e as f,p as T,U as y,g as A,d as E,m as S,S as v,aS as g,az as x,aT as h,H as I,aU as b,ad as C,k,l as P,aV as R,t as _,f as F,y as O,aW as W,aX as D,aY as N,ae as L,aG as V,aZ as U,a_ as B,a$ as M,b0 as j,E as G,z as $,b1 as z,J as H,b2 as J,a0 as q,i as K,W as X,b3 as Q,_ as Z,$ as Y,T as ee,D as te,b4 as oe,b5 as ae,aJ as ne,b6 as se,aI as re,b7 as ie,b8 as de,a1 as ce,I as le}from"./index-e3a0f33f.js";import{S as pe,T as ue,a as me,F as we,N as fe,W as Te,g as ye}from"./balance-643231e9.js";import{S as Ae,C as Ee,a as Se,T as ve,b as ge}from"./TopUpView-dbf35ba5.js";import{u as xe}from"./retry-c8740b81.js";import{S as he}from"./SpendingCapHero-dd5b1386.js";function Ie({theme:l,environment:p}){const{t:u}=e(),m=l===t.DARK?o(p,"/quickswapdark.webp"):o(p,"/quickswaplight.webp");return a(s,{testId:"quickswap-footer-container",sx:n,children:[a(s,{testId:"quickswap-logo",sx:r,children:[i(d,{size:"xSmall",sx:{paddingRight:"base.spacing.x1"},children:"By"}),i("img",{style:{height:"26px"},alt:"Quickswap logo",src:m})]}),i(d,{testId:"quickswap-footer-disclaimer-text",size:"xSmall",sx:c,children:u("footers.quickswapFooter.disclaimerText")})]})}const be={exchange:null,walletProviderName:null,network:null,tokenBalances:[],supportedTopUps:null,allowedTokens:[]};var Ce;!function(e){e.SET_EXCHANGE="SET_EXCHANGE",e.SET_WALLET_PROVIDER_NAME="SET_WALLET_PROVIDER_NAME",e.SET_NETWORK="SET_NETWORK",e.SET_SUPPORTED_TOP_UPS="SET_SUPPORTED_TOP_UPS",e.SET_TOKEN_BALANCES="SET_TOKEN_BALANCES",e.SET_ALLOWED_TOKENS="SET_ALLOWED_TOKENS"}(Ce||(Ce={}));const ke=l.createContext({swapState:be,swapDispatch:()=>{}});ke.displayName="SwapContext";const Pe=(e,t)=>{switch(t.payload.type){case Ce.SET_EXCHANGE:return{...e,exchange:t.payload.exchange};case Ce.SET_WALLET_PROVIDER_NAME:return{...e,walletProviderName:t.payload.walletProviderName};case Ce.SET_NETWORK:return{...e,network:t.payload.network};case Ce.SET_SUPPORTED_TOP_UPS:return{...e,supportedTopUps:{isSwapEnabled:t.payload.supportedTopUps.isSwapEnabled??!0,isOnRampEnabled:t.payload.supportedTopUps.isOnRampEnabled??!0,isBridgeEnabled:t.payload.supportedTopUps.isBridgeEnabled??!0}};case Ce.SET_TOKEN_BALANCES:return{...e,tokenBalances:t.payload.tokenBalances};case Ce.SET_ALLOWED_TOKENS:return{...e,allowedTokens:t.payload.allowedTokens};default:return e}},Re={fromAmountIn:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountIn(s,o.address,n.address,p.from(u(a,o.decimals)))},fromAmountOut:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountOut(s,n.address,o.address,p.from(u(a,o.decimals)))}},_e={display:"flex",flexDirection:"row",justifyContent:"space-between",columnGap:"base.spacing.x1"},Fe={flex:1},Oe={flex:2};function We({testId:e,options:t,textInputValue:o,textInputPlaceholder:n,textInputValidator:r,textInputType:d,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,textInputTextAlign:u,textInputSubtext:m,textInputErrorMessage:w,selectTextAlign:f,selectSubtext:T,selectErrorMessage:y,textInputMaxButtonClick:A,onSelectChange:E,textInputDisabled:S,selectInputDisabled:v,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h}){return a(s,{sx:_e,children:[i(s,{sx:Fe,children:i(pe,{testId:`${e}-select-form`,options:t,subtext:T,textAlign:f,errorMessage:y,onSelectChange:E,disabled:v,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h})}),i(s,{sx:Oe,children:i(ue,{type:d,testId:`${e}-text-form`,value:o,placeholder:n,subtext:m,textAlign:u,errorMessage:w,validator:r,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,maxButtonClick:A,disabled:S})})]})}const De={display:"flex",flexDirection:"column",paddingY:"base.spacing.x6",paddingX:"base.spacing.x4"},Ne={width:"base.icon.size.400"};function Le({loading:t,updateLoading:o,validator:n,transaction:r,data:d,insufficientFundsForGas:c,openNotEnoughImxDrawer:p,openNetworkSwitchDrawer:u}){const{t:g}=e(),[x,h]=l.useState(!1),{viewDispatch:I}=l.useContext(m),{connectLoaderState:b}=l.useContext(w),{checkout:C,provider:k}=b,{track:P}=f(),R=async()=>{const e=n();if(P({userJourney:y.SWAP,screen:"SwapCoins",control:"Swap",controlType:"Button",extras:{swapFromAddress:d?.fromTokenAddress,swapFromAmount:d?.fromAmount,swapFromTokenSymbol:d?.fromTokenSymbol,swapToAddress:d?.toTokenAddress,swapToAmount:d?.toAmount,swapToTokenSymbol:d?.toTokenSymbol,isSwapFormValid:e,hasFundsForGas:!c}}),e&&C&&k&&r)if(c)p();else{try{const e=await k.provider.request({method:"eth_chainId",params:[]});if(parseInt(e.toString())!==A(C.config))return void u()}catch(e){console.error("Current network check failed",e)}if(r)try{o(!0);const e={fromAmount:d?.fromAmount||"",fromTokenAddress:d?.fromTokenAddress||"",toTokenAddress:d?.toTokenAddress||"",toAmount:d?.toAmount||""};if(r.approval)return void I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.APPROVE_ERC20,data:{approveTransaction:r.approval.transaction,transaction:r.swap.transaction,info:r.quote,swapFormInfo:e}}}});const t=await C.sendTransaction({provider:k,transaction:r.swap.transaction});I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.IN_PROGRESS,data:{transactionResponse:t.transactionResponse,swapForm:e}}}})}catch(e){if(console.error(e),o(!1),e.type===S.USER_REJECTED_REQUEST_ERROR)return void h(!0);if(e.type===S.UNPREDICTABLE_GAS_LIMIT)return void I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.PRICE_SURGE,data:d}}});if(e.type===S.TRANSACTION_FAILED||e.type===S.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status)return void I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,reason:"Transaction failed",data:d}}});I({payload:{type:E.UPDATE_VIEW,view:{type:v.ERROR_VIEW,error:e}}})}}};return a(s,{sx:De,children:[i(T,{testId:"swap-button",disabled:t,variant:"primary",onClick:R,size:"large",children:t?i(T.Icon,{icon:"Loading",sx:Ne}):g("views.SWAP.swapForm.buttonText")}),i(me,{visible:x,showHeaderBar:!1,onCloseDrawer:()=>h(!1),onRetry:()=>{R(),h(!1)}})]})}const Ve={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x1",height:"100%"},Ue={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},Be={display:"flex",flexDirection:"column",justifyContent:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},Me={width:"100%",height:"base.spacing.x16"},je={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"};function Ge({environment:t,visible:o,showAdjustAmount:n,hasZeroImx:r,onCloseDrawer:c,onAddCoinsClick:l}){const{t:p}=e(),u=g(t);return i(x,{size:"full",onCloseDrawer:c,visible:o,showHeaderBar:!1,children:i(x.Content,{children:a(s,{testId:"not-enough-gas-bottom-sheet",sx:Ve,children:[i(h,{imageUrl:u,sx:{w:"base.icon.size.600",h:"base.icon.size.600"}}),i(I,{size:"small",sx:Ue,testId:"not-enough-gas-heading",children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.heading`)}),i(d,{sx:Ue,children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.body`)}),a(s,{sx:Be,children:[n&&i(T,{testId:"not-enough-gas-adjust-amount-button",sx:Me,variant:"tertiary",onClick:c,children:p("drawers.notEnoughImx.buttons.adjustAmount")}),i(T,{testId:"not-enough-gas-add-imx-button",sx:Me,variant:"tertiary",onClick:l,children:p("drawers.notEnoughImx.buttons.addMoreImx")}),i(T,{sx:Me,variant:"tertiary",onClick:c,testId:"not-enough-gas-cancel-button",children:p("drawers.notEnoughImx.buttons.cancel")})]}),i(s,{sx:je,children:i(b,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const $e={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x4",paddingX:"base.spacing.x4",height:"100%"},ze={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},He={display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},Je={width:"100%",height:"base.spacing.x16",marginBottom:"base.spacing.x16"},qe={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"},Ke={width:"base.icon.size.600",fill:"base.color.status.fatal.bright"};function Xe({visible:t,onCloseDrawer:o}){const{t:n}=e();return i(x,{size:"full",onCloseDrawer:o,visible:t,showHeaderBar:!1,children:i(x.Content,{children:a(s,{testId:"unable-to-swap-bottom-sheet",sx:$e,children:[i(C,{icon:"Alert",testId:"unable-to-swap-icon",variant:"bold",sx:Ke}),i(I,{size:"small",sx:ze,testId:"unable-to-swap-heading",children:n("drawers.unableToSwap.heading")}),i(d,{sx:ze,children:n("drawers.unableToSwap.body")}),i(s,{sx:He,children:i(T,{sx:Je,variant:"tertiary",onClick:o,testId:"unable-to-swap-cancel-button",children:n("drawers.unableToSwap.buttons.cancel")})}),i(s,{sx:qe,children:i(b,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const Qe=(e,t=500)=>{const[o,a]=l.useState(e);return l.useEffect((()=>{const o=setTimeout((()=>{a(e)}),t);return()=>{clearTimeout(o)}}),[e,t]),o};class Ze{static id=0;promiseId=0;promise;isCancelled=!1;onCancel=null;rejectPromise=()=>{};constructor(e){Ze.id+=1,this.promiseId=Ze.id,this.promise=new Promise(((t,o)=>{this.rejectPromise=o,e((e=>{this.isCancelled?o({cancelled:!0}):t(e)}),(e=>{this.isCancelled?o({cancelled:!0}):o(e)}))}))}static all(e){return new Ze(((t,o)=>{Promise.all(e.map((e=>e instanceof Ze?e.promise:e))).then(t,o)}))}then(e,t){return new Ze(((o,a)=>{this.promise.then((t=>o(e?e(t):t)),(e=>t?o(t(e)):a(e)))}))}catch(e){return this.then(void 0,e)}finally(e){return new Ze(((t,o)=>{this.promise.then(t,o).finally((()=>{e&&e()}))}))}cancel(){this.isCancelled||(this.isCancelled=!0,this.onCancel&&this.onCancel(),this.rejectPromise({cancelled:!0}))}onCancelled(e){this.onCancel=e}get cancelled(){return this.isCancelled}}var Ye;!function(e){e.FROM="FROM",e.TO="TO"}(Ye||(Ye={}));const et=({swapFromToken:e,swapToToken:t,swapFromAmount:o,swapToAmount:a,conversion:n})=>{const s={fromToConversion:"",swapToAmount:""};if(!a)return s;if(s.swapToAmount=_(a),o&&e&&t){const o=F(_(U(n,t.decimals)),!0);s.fromToConversion=`1 ${e.symbol} ≈ ${o} ${t.symbol}`}return s},tt=(e,t)=>void 0!==e&&(""!==e&&t!==e);let ot;function at({data:t,theme:o}){const{t:n}=e(),{swapState:{allowedTokens:r,exchange:c,tokenBalances:T,network:S}}=l.useContext(ke),{connectLoaderState:g}=l.useContext(w),{checkout:x,provider:h}=g,b=k(x?.config.environment,o),C=l.useCallback(((e,t)=>P(t)?`${e.toLowerCase()}-${R}`:`${e.toLowerCase()}-${t.toLowerCase()}`),[]),{cryptoFiatState:G,cryptoFiatDispatch:$}=l.useContext(Ee),{viewDispatch:z}=l.useContext(m),[H,J]=l.useState(Ye.FROM),[q,K]=l.useState(!1),[X,Q]=l.useState(p.from(0)),[Z,Y]=l.useState(""),ee=l.useRef(!1),{track:te}=f(),[oe,ae]=l.useState(t?.fromAmount||""),[ne,se]=l.useState(""),re=Qe(oe,B),[ie,de]=l.useState(),[ce,le]=l.useState(""),[pe,ue]=l.useState(""),[me,Te]=l.useState(t?.toAmount||""),[ye,Ae]=l.useState(""),ve=Qe(me,B),[ge,he]=l.useState(),[Ie,be]=l.useState(""),[Ce,Pe]=l.useState(""),[_e,Fe]=l.useState(null),[Oe,De]=l.useState(""),[Ne,Ve]=l.useState(void 0),[Ue,Be]=l.useState(""),[Me,je]=l.useState([]),[$e,ze]=l.useState(!1),[He,Je]=l.useState(!1),[qe,Ke]=l.useState(!1);l.useEffect((()=>{if(0===T.length)return;if(!S)return;const e=T.filter((e=>e.balance.gt(0))).map((e=>({id:C(e.token.symbol,e.token.address),name:e.token.name,symbol:e.token.symbol,icon:e.token.icon,balance:{formattedAmount:_(e.formattedBalance),formattedFiatAmount:0===G.conversions.size?F(""):O(e.formattedBalance,e.token.symbol||"",G.conversions)}})));je(e),ee.current||(ee.current=!0,t?.fromTokenAddress&&(de(r.find((e=>P(e.address)&&t?.fromTokenAddress?.toLowerCase()===R||e.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))),le(T.find((e=>P(e.token.address)&&t?.fromTokenAddress?.toLowerCase()===R||e.token.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))?.formattedBalance??"")),tt(t?.toTokenAddress,t?.fromTokenAddress)&&he(r.find((e=>P(e.address)&&t?.toTokenAddress?.toLowerCase()===R||e.address?.toLowerCase()===t?.toTokenAddress?.toLowerCase()))))}),[T,r,G.conversions,t?.fromTokenAddress,t?.toTokenAddress,ee.current,de,le,he,je,C,F,S]);const at=l.useMemo((()=>r.map((e=>({id:C(e.symbol,e.address),name:e.name,symbol:e.symbol,icon:e.icon})))),[r,ie]);l.useEffect((()=>{$({payload:{type:Se.SET_TOKEN_SYMBOLS,tokenSymbols:r.map((e=>e.symbol))}})}),[$,r]);const nt=()=>{se(""),ue(""),Ae(""),be("")},st=()=>{ot&&ot.cancel(),Y(""),Be(""),Fe(null)},rt=e=>!Number.isNaN(parseFloat(oe))&&(!(parseFloat(oe)<=0)&&(!!ie&&(!!ge&&(!e||!q)))),it=async(e=!1)=>{rt(e)&&(ot&&ot.cancel(),e||K(!0),await(async(e=!1)=>{if(h&&c&&ie&&ge){try{e||Y("");const t=Re.fromAmountIn(c,h,ie,oe,ge),o=Re.fromAmountIn(c,h,ie,"1",ge),a=Ze.all([t,o]);ot=a;const n=await a,s=n[0],i=n[1];Q(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=U(l,j),m=d?.token,w=r.find((e=>e.address?.toLocaleLowerCase()===m?.address?.toLocaleLowerCase()));Fe(s),De(u),Ve({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),Be(O(u,w?.symbol||"",G.conversions)),Te(F(_(U(s.quote.amount.value,s.quote.amount.token.decimals),s.quote.amount.token.decimals))),nt()}catch(e){e.cancelled||(st(),ze(!1),Je(!0))}e||K(!1)}})(e))},dt=e=>!Number.isNaN(parseFloat(me))&&(!(parseFloat(me)<=0)&&(!!ie&&(!!ge&&(!e||!q)))),ct=async(e=!1)=>{dt(e)&&(ot&&ot.cancel(),e||K(!0),await(async(e=!1)=>{if(h&&c&&ie&&ge){try{e||Y("");const t=Re.fromAmountOut(c,h,ge,me,ie),o=Re.fromAmountIn(c,h,ie,"1",ge),a=Ze.all([t,o]);ot=a;const n=await a,s=n[0],i=n[1];Q(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=U(l,j),m=d?.token,w=r.find((e=>e.symbol===m?.symbol));Fe(s),De(u),Ve({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),Be(O(u,w?.symbol||"",G.conversions)),ae(F(_(U(s.quote.amount.value,s.quote.amount.token.decimals)))),nt()}catch(e){e.cancelled||(st(),ze(!1),Je(!0))}e||K(!1)}})(e))},lt=async(e=!1)=>{H===Ye.FROM?await it(e):await ct(e)};xe((()=>lt(!0)),W),l.useEffect((()=>{if(H===Ye.FROM){if(re<=0)return K(!1),void st();(async()=>{await lt()})()}}),[re,ie,ge]),l.useEffect((()=>{if(H===Ye.TO){if(ve<=0)return K(!1),void st();(async()=>{await lt()})()}}),[ve,ge,ie]);const pt=l.useMemo((()=>{const e=T.find((e=>e.token.address?.toLowerCase()===R));if(!e)return!0;const t=ie?.address?.toLowerCase()===R,o=D(0!==Oe.length?Oe:"0"),a=t&&!Number.isNaN(parseFloat(oe))?u(oe,ie?.decimals||18):p.from("0");return o.add(a).gt(e.balance)}),[Oe,T,ie,oe]);l.useEffect((()=>{oe&&ie&&Pe(O(oe,ie.symbol,G.conversions))}),[oe,ie]);const ut=l.useCallback((e=>{const t=T.find((t=>e===C(t.token.symbol,t.token.address)));t&&(ge&&e===C(ge.symbol,ge?.address)&&he(void 0),de(t.token),le(t.formattedBalance),ue(""))}),[ge]),mt=l.useCallback((e=>{const t=r.find((t=>e===C(t.symbol,t.address)));t&&(ie&&e===C(ie.symbol,ie?.address)&&de(void 0),he(t),be(""))}),[ie]);return l.useEffect((()=>{_e&&X&&Y(et({swapFromToken:ie,swapFromAmount:oe,swapToToken:ge,swapToAmount:me,conversion:X}).fromToConversion)}),[_e,X]),a(V,{children:[a(s,{sx:{paddingX:"base.spacing.x4",marginBottom:"base.spacing.x2"},children:[i(I,{size:"small",weight:"regular",sx:{paddingBottom:"base.spacing.x4"},children:n("views.SWAP.content.title")}),a(s,{sx:{display:"flex",flexDirection:"column",rowGap:"base.spacing.x6",paddingBottom:"base.spacing.x2"},children:[a(s,{children:[i(I,{size:"xSmall",sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:n("views.SWAP.swapForm.from.label")}),i(We,{testId:"fromTokenInputs",options:Me,selectSubtext:ie?`${n("views.SWAP.content.availableBalancePrefix")} ${_(ce)}`:"",selectTextAlign:"left",textInputType:"number",textInputValue:oe,textInputPlaceholder:n("views.SWAP.swapForm.from.inputPlaceholder"),textInputSubtext:`${n("views.SWAP.content.fiatPricePrefix")} \n $${F(Ce,!0)}`,textInputTextAlign:"right",textInputValidator:N,onTextInputChange:e=>{return t=e,nt(),st(),Te(""),rt(!1)&&K(!0),void ae(t);var t},onTextInputFocus:()=>{J(Ye.FROM)},textInputMaxButtonClick:()=>{if(!ce)return;const e=ce.slice(0,ce.indexOf(".")+M+1);nt(),st(),Te(""),J(Ye.FROM),ae(e),te({userJourney:y.SWAP,screen:"SwapCoins",control:"MaxFrom",controlType:"Button",extras:{fromBalance:ce,fromBalanceTruncated:e}})},onSelectChange:ut,textInputErrorMessage:n(ne),selectErrorMessage:n(pe),selectedOption:ie?C(ie.symbol,ie.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.from.selectorTitle"),defaultTokenImage:b})]}),a(s,{children:[a(s,{sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:[i(I,{size:"xSmall",children:n("views.SWAP.swapForm.to.label")}),i(d,{sx:{color:"base.color.brand.4"},size:"small",children:Z})]}),i(We,{testId:"toTokenInputs",options:at,selectTextAlign:"left",textInputType:"number",textInputValue:me,textInputPlaceholder:n("views.SWAP.swapForm.to.inputPlaceholder"),textInputTextAlign:"right",textInputValidator:N,onTextInputChange:e=>{return t=e,nt(),st(),Pe(""),ae(""),dt(!1)&&K(!0),void Te(t);var t},onTextInputFocus:()=>{J(Ye.TO)},onSelectChange:mt,textInputErrorMessage:n(ye),selectErrorMessage:n(Ie),selectedOption:ge?C(ge.symbol,ge.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.to.selectorTitle"),defaultTokenImage:b})]})]}),i(we,{gasFeeFiatValue:Ue,gasFeeToken:Ne,gasFeeValue:Oe,fees:[{label:n("drawers.feesBreakdown.fees.gasFeeSwap.label"),fiatAmount:`~ ${n("drawers.feesBreakdown.fees.fiatPricePrefix")}${Ue}`,amount:_(Oe),prefix:"~"}],onFeesClick:()=>{te({userJourney:y.SWAP,screen:"SwapCoins",control:"ViewFees",controlType:"Button"})},sx:{paddingBottom:"0"},loading:q})]}),i(Le,{validator:()=>{const e=function(e){return e?"":"views.SWAP.validation.noFromTokenSelected"}(ie),t=(a=ce,(o=oe)&&0!==parseFloat(o)?a&&Number(o)>Number(a)?"views.SWAP.validation.insufficientBalance":"":"views.SWAP.validation.noAmountInputted");var o,a;const n=function(e){return e?"":"views.SWAP.validation.noToTokenSelected"}(ge),s=function(e){return e&&0!==parseFloat(e)?"":"views.SWAP.validation.noAmountInputted"}(me);H===Ye.FROM?(Ae(""),t&&se(t)):H===Ye.TO&&(se(""),s&&Ae(s)),e&&ue(e),n&&be(n);let r=!0;return(e||n||t&&H===Ye.FROM||s&&H===Ye.TO)&&(r=!1),te({userJourney:y.SWAP,screen:"SwapCoins",control:"FormValid",controlType:"Button",extras:{isSwapFormValid:r,swapFromAddress:ie?.address,swapFromAmount:oe,swapFromTokenSymbol:ie?.symbol,swapToAddress:ge?.address,swapToAmount:me,swapToTokenSymbol:ge?.symbol}}),r},updateLoading:e=>{K(e)},loading:q,transaction:_e,data:{fromAmount:oe,toAmount:me,fromTokenSymbol:ie?.symbol,fromTokenAddress:ie?.address,toTokenSymbol:ge?.symbol,toTokenAddress:ge?.address},insufficientFundsForGas:pt,openNotEnoughImxDrawer:()=>{Je(!1),ze(!0)},openNetworkSwitchDrawer:()=>Ke(!0)}),i(Ge,{environment:x?.config.environment??L.PRODUCTION,visible:$e,showAdjustAmount:ie?.address===R,hasZeroImx:!1,onAddCoinsClick:()=>{z({payload:{type:E.UPDATE_VIEW,view:{type:v.TOP_UP_VIEW},currentViewData:{fromTokenAddress:ie?.address??"",fromAmount:oe,toTokenAddress:ge?.address??""}}})},onCloseDrawer:()=>ze(!1)}),i(Xe,{visible:He,onCloseDrawer:()=>{Je(!1),de(void 0),ae(""),he(void 0),Te("")}}),i(fe,{visible:qe,targetChainId:A(x?.config),provider:h,checkout:x,onCloseDrawer:()=>Ke(!1)})]})}const nt=(e,t)=>{if(0===e.length)return!0;let o=!1;return e.forEach((e=>{e.token.symbol===t&&e.balance.eq(0)&&(o=!0)})),o};function st({theme:t,fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}){const{t:c}=e(),{viewDispatch:p}=l.useContext(m),{eventTargetState:{eventTarget:u}}=l.useContext(G),{swapState:{tokenBalances:T}}=l.useContext(ke),{connectLoaderState:{checkout:A}}=l.useContext(w),[S,g]=l.useState(!1),{page:x}=f();return l.useEffect((()=>{x({userJourney:y.SWAP,screen:"SwapCoins",extras:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}})}),[]),l.useEffect((()=>{nt(T,J)&&g(!0)}),[T]),i(H,{header:i($,{title:c("views.SWAP.header.title"),onCloseButtonClick:()=>z(u)}),footer:i(Ie,{environment:A?.config.environment,theme:t}),children:a(s,{sx:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[i(at,{data:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d},theme:t}),i(Ge,{environment:A?.config.environment??L.PRODUCTION,visible:S,showAdjustAmount:!1,hasZeroImx:!0,onAddCoinsClick:()=>{p({payload:{type:E.UPDATE_VIEW,view:{type:v.TOP_UP_VIEW}}})},onCloseDrawer:()=>{g(!1)}})]})})}function rt({transactionResponse:t,swapForm:o}){const{t:a}=e(),{viewDispatch:n}=l.useContext(m),{page:s}=f();return l.useEffect((()=>{s({userJourney:y.SWAP,screen:"SwapInProgress",extras:{swapFormInfo:o}})}),[]),l.useEffect((()=>{(async()=>{try{const e=await t.wait();if(1===e.status)return void n({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SUCCESS,data:{fromTokenAddress:o.fromTokenAddress,fromAmount:o.fromAmount,toTokenAddress:o.toTokenAddress,toAmount:o.toAmount||"",transactionHash:e.transactionHash}}}});n({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,data:o,reason:"Transaction failed"}}})}catch{n({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,data:o,reason:"Transaction failed"}}})}})()}),[t]),i(q,{loadingText:a("views.SWAP.IN_PROGRESS.loading.text")})}function it({data:t}){const{t:o}=e(),{swapState:{allowedTokens:n}}=l.useContext(ke),{connectLoaderState:r}=l.useContext(w),{checkout:d,provider:c}=r,{viewDispatch:p}=l.useContext(m),{eventTargetState:{eventTarget:u}}=l.useContext(G),T=K(c),[A,g]=l.useState(!1),[x,h]=l.useState(!1),[I,b]=l.useState(!1),[C,k]=l.useState(!1),[P,R]=l.useState(!1),[_,F]=l.useState(!1),{page:O,track:W}=f();l.useEffect((()=>{O({userJourney:y.SWAP,screen:"ApproveERC20",extras:{swapFormInfo:t.swapFormInfo}})}),[]);const D=l.useMemo((()=>n.find((e=>e.address===t.swapFormInfo.fromTokenAddress))),[n,t.swapFormInfo.fromTokenAddress]),N=l.useCallback((()=>{p({payload:{type:E.UPDATE_VIEW,view:{type:v.ERROR_VIEW,error:new Error("No checkout object or no provider object found")}}})}),[p]),L=l.useCallback((()=>{p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SWAP,data:t.swapFormInfo}}})}),[p]),U=(e,t)=>{e.type!==S.UNPREDICTABLE_GAS_LIMIT?e.type===S.TRANSACTION_FAILED||e.type===S.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status?p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,reason:"Transaction failed",data:t}}}):p({payload:{type:E.UPDATE_VIEW,view:{type:v.ERROR_VIEW,error:e}}}):p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.PRICE_SURGE,data:t}}})},B=l.useCallback((async()=>{if(!C)if(W({userJourney:y.SWAP,screen:"ApproveERC20",control:"ApproveSpending",controlType:"Button"}),k(!0),d&&c){if(!A){g(!0);try{const e=await d.sendTransaction({provider:c,transaction:t.approveTransaction});h(!0);if(1!==(await e.transactionResponse.wait()).status)return void p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,data:t.swapFormInfo}}});h(!1),g(!1),b(!0)}catch(e){if(h(!1),g(!1),e.type===S.USER_REJECTED_REQUEST_ERROR)return void R(!0);U(e,t.swapFormInfo)}finally{k(!1)}}}else N()}),[d,c,N,p,F,t.approveTransaction,t.swapFormInfo,A,g,h]),M=l.useMemo((()=>a(X,{heading:o(`views.APPROVE_ERC20.approveSpending.content.${T?"passport":"metamask"}.heading`),children:[T&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.passport.body")}),!T&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.metamask.body",{amount:`${t.swapFormInfo.fromAmount} ${D?.symbol||""}`})})]})),[t.swapFormInfo,D,T]),j=l.useMemo((()=>i(Q,{loading:C,actionText:o(P?"views.APPROVE_ERC20.approveSpending.footer.retryText":"views.APPROVE_ERC20.approveSpending.footer.buttonText"),onActionClick:B})),[P,B,C]),J=l.useCallback((async()=>{if(!C)if(W({userJourney:y.SWAP,screen:"ApproveERC20",control:"ApproveSwap",controlType:"Button"}),k(!0),d&&c){if(!A){g(!0);try{const e=await d.sendTransaction({provider:c,transaction:t.transaction});g(!1),p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.IN_PROGRESS,data:{transactionResponse:e.transactionResponse,swapForm:t.swapFormInfo}}}})}catch(e){if(g(!1),e.type===S.USER_REJECTED_REQUEST_ERROR)return void F(!0);U(e,t.swapFormInfo)}finally{k(!1)}}}else N()}),[d,c,N,p,F,t.transaction,t.swapFormInfo,A,g]),Z=i(X,{heading:o("views.APPROVE_ERC20.approveSwap.content.heading"),children:i(s,{children:o("views.APPROVE_ERC20.approveSwap.content.body")})}),Y=l.useMemo((()=>i(Q,{loading:C,actionText:o(_?"views.APPROVE_ERC20.approveSwap.footer.retryText":"views.APPROVE_ERC20.approveSwap.footer.buttonText"),onActionClick:J})),[_,J,C]);return a(V,{children:[x&&i(q,{loadingText:o("views.APPROVE_ERC20.approveSpending.loading.text")}),!x&&i(H,{header:i($,{transparent:!0,showBack:!0,onCloseButtonClick:()=>z(u),onBackButtonClick:L}),floatHeader:!0,heroContent:i(I?Te:he,{}),footer:I?Y:j,children:I?Z:M})]})}function dt({amount:t,fromTokenAddress:o,toTokenAddress:n,config:s}){const{t:r}=e(),{eventTargetState:{eventTarget:d}}=l.useContext(G),{environment:c,theme:p,isOnRampEnabled:u,isSwapEnabled:T,isBridgeEnabled:S}=s,{connectLoaderState:{checkout:g,provider:x}}=l.useContext(w),[h,I]=l.useReducer(Z,{...Y,history:[]}),[b,C]=l.useReducer(Pe,be),{page:k}=f(),[P,R]=l.useState(!1),_=l.useMemo((()=>({swapState:b,swapDispatch:C})),[b,C]),F=l.useMemo((()=>({viewState:h,viewDispatch:I})),[h,I]),O=l.useCallback(((e,t)=>{I({payload:{type:E.UPDATE_VIEW,view:{type:v.ERROR_VIEW,tryAgain:t,error:e}}})}),[I]),W=l.useCallback((()=>{I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SWAP}}})}),[I]),D=l.useCallback((async()=>{if(!g)throw new Error("loadBalances: missing checkout");if(!x)throw new Error("loadBalances: missing provider");try{const e=await ye({checkout:g,provider:x,allowTokenListType:ee.SWAP});if(void 0===e)return!1;C({payload:{type:Ce.SET_ALLOWED_TOKENS,allowedTokens:e.allowList.tokens}}),C({payload:{type:Ce.SET_TOKEN_BALANCES,tokenBalances:e.allowedBalances}})}catch(e){if(te.nonRetryable(e))return O(e,D),!1}return!0}),[g,x]);return l.useEffect((()=>{(async()=>{if(!g||!x)return;const e=await g.getNetworkInfo({provider:x});if(e.chainId!==A(g.config))return;let t;try{t=await g.config.remote.getConfig("dex")}catch(e){return void O(e)}const o=new oe({chainId:e.chainId,baseConfig:new ae({environment:c}),secondaryFees:t.secondaryFees,overrides:t.overrides});C({payload:{type:Ce.SET_EXCHANGE,exchange:o}}),C({payload:{type:Ce.SET_NETWORK,network:e}}),await D()&&h.view.type===v.LOADING_VIEW&&W()})()}),[g,x]),i(m.Provider,{value:F,children:i(ke.Provider,{value:_,children:a(ge,{environment:c,children:[h.view.type===v.LOADING_VIEW&&i(q,{loadingText:r("views.LOADING_VIEW.text")}),h.view.type===Ae.SWAP&&i(st,{theme:p,fromAmount:h.view.data?.fromAmount??t,fromTokenAddress:h.view.data?.fromTokenAddress??o,toTokenAddress:h.view.data?.toTokenAddress??n}),h.view.type===Ae.IN_PROGRESS&&i(rt,{transactionResponse:h.view.data.transactionResponse,swapForm:h.view.data.swapForm}),h.view.type===Ae.APPROVE_ERC20&&i(it,{data:h.view.data}),h.view.type===Ae.SUCCESS&&i(ne,{statusText:r("views.SWAP.success.text"),actionText:r("views.SWAP.success.actionText"),onRenderEvent:()=>{k({userJourney:y.SWAP,screen:"SwapSuccess",extras:{fromTokenAddress:h.view.data?.fromTokenAddress,fromAmount:h.view.data?.fromAmount,toTokenAddress:h.view.data?.toTokenAddress,toAmount:h.view.data?.toAmount}}),se(d,h.view.data.transactionHash)},onActionClick:()=>z(d),statusType:re.SUCCESS,testId:"success-view"}),h.view.type===Ae.FAIL&&i(ne,{statusText:r("views.SWAP.failed.text"),actionText:r("views.SWAP.failed.actionText"),onRenderEvent:()=>{k({userJourney:y.SWAP,screen:"SwapFailed"}),ie(d,"Transaction failed")},onActionClick:()=>{h.view.type===Ae.FAIL&&I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SWAP,data:h.view.data}}})},statusType:re.FAILURE,onCloseClick:()=>z(d),testId:"fail-view"}),h.view.type===Ae.PRICE_SURGE&&i(ne,{statusText:r("views.SWAP.rejected.text"),actionText:r("views.SWAP.rejected.actionText"),onRenderEvent:()=>{k({userJourney:y.SWAP,screen:"PriceSurge"}),de(d,"Price surge")},onActionClick:()=>{h.view.type===Ae.PRICE_SURGE&&I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SWAP,data:h.view.data}}})},statusType:re.WARNING,onCloseClick:()=>z(d),testId:"price-surge-view"}),h.view.type===v.ERROR_VIEW&&i(ce,{actionText:r("views.ERROR_VIEW.actionText"),onActionClick:async()=>{R(!0);const e=h.view;if(!e.tryAgain)return W(),void R(!1);await e.tryAgain()&&W(),R(!1)},onCloseClick:()=>z(d),errorEventActionLoading:P}),h.view.type===v.TOP_UP_VIEW&&i(ve,{analytics:{userJourney:y.SWAP},checkout:g,provider:x,widgetEvent:le.IMTBL_SWAP_WIDGET_EVENT,showOnrampOption:u,showSwapOption:T,showBridgeOption:S,onCloseButtonClick:()=>z(d)})]})})})}export{dt as default};
1
+ import{u as e,aM as t,aN as o,j as a,aO as n,B as s,aP as r,a as i,b as d,aQ as c,r as l,aj as p,aR as u,V as m,C as w,e as f,p as T,U as y,g as A,d as E,m as S,S as v,aS as g,az as x,aT as h,H as I,aU as b,ad as C,k,l as P,aV as R,t as _,f as F,y as O,aW as W,aX as D,aY as N,ae as L,aG as V,aZ as U,a_ as B,a$ as M,b0 as j,E as G,z as $,b1 as z,J as H,b2 as J,a0 as q,i as K,W as X,b3 as Q,_ as Z,$ as Y,T as ee,D as te,b4 as oe,b5 as ae,aJ as ne,b6 as se,aI as re,b7 as ie,b8 as de,a1 as ce,I as le}from"./index-394d516d.js";import{S as pe,T as ue,a as me,F as we,N as fe,W as Te,g as ye}from"./balance-13198af0.js";import{S as Ae,C as Ee,a as Se,T as ve,b as ge}from"./TopUpView-20c59619.js";import{u as xe}from"./retry-ce6e6559.js";import{S as he}from"./SpendingCapHero-4cf86bc9.js";function Ie({theme:l,environment:p}){const{t:u}=e(),m=l===t.DARK?o(p,"/quickswapdark.webp"):o(p,"/quickswaplight.webp");return a(s,{testId:"quickswap-footer-container",sx:n,children:[a(s,{testId:"quickswap-logo",sx:r,children:[i(d,{size:"xSmall",sx:{paddingRight:"base.spacing.x1"},children:"By"}),i("img",{style:{height:"26px"},alt:"Quickswap logo",src:m})]}),i(d,{testId:"quickswap-footer-disclaimer-text",size:"xSmall",sx:c,children:u("footers.quickswapFooter.disclaimerText")})]})}const be={exchange:null,walletProviderName:null,network:null,tokenBalances:[],supportedTopUps:null,allowedTokens:[]};var Ce;!function(e){e.SET_EXCHANGE="SET_EXCHANGE",e.SET_WALLET_PROVIDER_NAME="SET_WALLET_PROVIDER_NAME",e.SET_NETWORK="SET_NETWORK",e.SET_SUPPORTED_TOP_UPS="SET_SUPPORTED_TOP_UPS",e.SET_TOKEN_BALANCES="SET_TOKEN_BALANCES",e.SET_ALLOWED_TOKENS="SET_ALLOWED_TOKENS"}(Ce||(Ce={}));const ke=l.createContext({swapState:be,swapDispatch:()=>{}});ke.displayName="SwapContext";const Pe=(e,t)=>{switch(t.payload.type){case Ce.SET_EXCHANGE:return{...e,exchange:t.payload.exchange};case Ce.SET_WALLET_PROVIDER_NAME:return{...e,walletProviderName:t.payload.walletProviderName};case Ce.SET_NETWORK:return{...e,network:t.payload.network};case Ce.SET_SUPPORTED_TOP_UPS:return{...e,supportedTopUps:{isSwapEnabled:t.payload.supportedTopUps.isSwapEnabled??!0,isOnRampEnabled:t.payload.supportedTopUps.isOnRampEnabled??!0,isBridgeEnabled:t.payload.supportedTopUps.isBridgeEnabled??!0}};case Ce.SET_TOKEN_BALANCES:return{...e,tokenBalances:t.payload.tokenBalances};case Ce.SET_ALLOWED_TOKENS:return{...e,allowedTokens:t.payload.allowedTokens};default:return e}},Re={fromAmountIn:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountIn(s,o.address,n.address,p.from(u(a,o.decimals)))},fromAmountOut:async(e,t,o,a,n)=>{const s=await t.getSigner().getAddress();return e.getUnsignedSwapTxFromAmountOut(s,n.address,o.address,p.from(u(a,o.decimals)))}},_e={display:"flex",flexDirection:"row",justifyContent:"space-between",columnGap:"base.spacing.x1"},Fe={flex:1},Oe={flex:2};function We({testId:e,options:t,textInputValue:o,textInputPlaceholder:n,textInputValidator:r,textInputType:d,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,textInputTextAlign:u,textInputSubtext:m,textInputErrorMessage:w,selectTextAlign:f,selectSubtext:T,selectErrorMessage:y,textInputMaxButtonClick:A,onSelectChange:E,textInputDisabled:S,selectInputDisabled:v,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h}){return a(s,{sx:_e,children:[i(s,{sx:Fe,children:i(pe,{testId:`${e}-select-form`,options:t,subtext:T,textAlign:f,errorMessage:y,onSelectChange:E,disabled:v,selectedOption:g,coinSelectorHeading:x,defaultTokenImage:h})}),i(s,{sx:Oe,children:i(ue,{type:d,testId:`${e}-text-form`,value:o,placeholder:n,subtext:m,textAlign:u,errorMessage:w,validator:r,onTextInputChange:c,onTextInputBlur:l,onTextInputFocus:p,maxButtonClick:A,disabled:S})})]})}const De={display:"flex",flexDirection:"column",paddingY:"base.spacing.x6",paddingX:"base.spacing.x4"},Ne={width:"base.icon.size.400"};function Le({loading:t,updateLoading:o,validator:n,transaction:r,data:d,insufficientFundsForGas:c,openNotEnoughImxDrawer:p,openNetworkSwitchDrawer:u}){const{t:g}=e(),[x,h]=l.useState(!1),{viewDispatch:I}=l.useContext(m),{connectLoaderState:b}=l.useContext(w),{checkout:C,provider:k}=b,{track:P}=f(),R=async()=>{const e=n();if(P({userJourney:y.SWAP,screen:"SwapCoins",control:"Swap",controlType:"Button",extras:{swapFromAddress:d?.fromTokenAddress,swapFromAmount:d?.fromAmount,swapFromTokenSymbol:d?.fromTokenSymbol,swapToAddress:d?.toTokenAddress,swapToAmount:d?.toAmount,swapToTokenSymbol:d?.toTokenSymbol,isSwapFormValid:e,hasFundsForGas:!c}}),e&&C&&k&&r)if(c)p();else{try{const e=await k.provider.request({method:"eth_chainId",params:[]});if(parseInt(e.toString())!==A(C.config))return void u()}catch(e){console.error("Current network check failed",e)}if(r)try{o(!0);const e={fromAmount:d?.fromAmount||"",fromTokenAddress:d?.fromTokenAddress||"",toTokenAddress:d?.toTokenAddress||"",toAmount:d?.toAmount||""};if(r.approval)return void I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.APPROVE_ERC20,data:{approveTransaction:r.approval.transaction,transaction:r.swap.transaction,info:r.quote,swapFormInfo:e}}}});const t=await C.sendTransaction({provider:k,transaction:r.swap.transaction});I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.IN_PROGRESS,data:{transactionResponse:t.transactionResponse,swapForm:e}}}})}catch(e){if(console.error(e),o(!1),e.type===S.USER_REJECTED_REQUEST_ERROR)return void h(!0);if(e.type===S.UNPREDICTABLE_GAS_LIMIT)return void I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.PRICE_SURGE,data:d}}});if(e.type===S.TRANSACTION_FAILED||e.type===S.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status)return void I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,reason:"Transaction failed",data:d}}});I({payload:{type:E.UPDATE_VIEW,view:{type:v.ERROR_VIEW,error:e}}})}}};return a(s,{sx:De,children:[i(T,{testId:"swap-button",disabled:t,variant:"primary",onClick:R,size:"large",children:t?i(T.Icon,{icon:"Loading",sx:Ne}):g("views.SWAP.swapForm.buttonText")}),i(me,{visible:x,showHeaderBar:!1,onCloseDrawer:()=>h(!1),onRetry:()=>{R(),h(!1)}})]})}const Ve={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x1",height:"100%"},Ue={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},Be={display:"flex",flexDirection:"column",justifyContent:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},Me={width:"100%",height:"base.spacing.x16"},je={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"};function Ge({environment:t,visible:o,showAdjustAmount:n,hasZeroImx:r,onCloseDrawer:c,onAddCoinsClick:l}){const{t:p}=e(),u=g(t);return i(x,{size:"full",onCloseDrawer:c,visible:o,showHeaderBar:!1,children:i(x.Content,{children:a(s,{testId:"not-enough-gas-bottom-sheet",sx:Ve,children:[i(h,{imageUrl:u,sx:{w:"base.icon.size.600",h:"base.icon.size.600"}}),i(I,{size:"small",sx:Ue,testId:"not-enough-gas-heading",children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.heading`)}),i(d,{sx:Ue,children:p(`drawers.notEnoughImx.content.${r?"noImx":"insufficientImx"}.body`)}),a(s,{sx:Be,children:[n&&i(T,{testId:"not-enough-gas-adjust-amount-button",sx:Me,variant:"tertiary",onClick:c,children:p("drawers.notEnoughImx.buttons.adjustAmount")}),i(T,{testId:"not-enough-gas-add-imx-button",sx:Me,variant:"tertiary",onClick:l,children:p("drawers.notEnoughImx.buttons.addMoreImx")}),i(T,{sx:Me,variant:"tertiary",onClick:c,testId:"not-enough-gas-cancel-button",children:p("drawers.notEnoughImx.buttons.cancel")})]}),i(s,{sx:je,children:i(b,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const $e={display:"flex",flexDirection:"column",alignItems:"center",paddingTop:"base.spacing.x6",paddingBottom:"base.spacing.x4",paddingX:"base.spacing.x4",height:"100%"},ze={color:"base.color.text.body.secondary",fontFamily:"base.font.family.heading.secondary",textAlign:"center",marginTop:"base.spacing.x4"},He={display:"flex",flexDirection:"column",justifyContent:"flex-end",alignItems:"center",gap:"base.spacing.x2",height:"100%",width:"100%"},Je={width:"100%",height:"base.spacing.x16",marginBottom:"base.spacing.x16"},qe={display:"flex",flexDirection:"column",justifyContent:"center",alignItems:"center",paddingTop:"base.spacing.x6"},Ke={width:"base.icon.size.600",fill:"base.color.status.fatal.bright"};function Xe({visible:t,onCloseDrawer:o}){const{t:n}=e();return i(x,{size:"full",onCloseDrawer:o,visible:t,showHeaderBar:!1,children:i(x.Content,{children:a(s,{testId:"unable-to-swap-bottom-sheet",sx:$e,children:[i(C,{icon:"Alert",testId:"unable-to-swap-icon",variant:"bold",sx:Ke}),i(I,{size:"small",sx:ze,testId:"unable-to-swap-heading",children:n("drawers.unableToSwap.heading")}),i(d,{sx:ze,children:n("drawers.unableToSwap.body")}),i(s,{sx:He,children:i(T,{sx:Je,variant:"tertiary",onClick:o,testId:"unable-to-swap-cancel-button",children:n("drawers.unableToSwap.buttons.cancel")})}),i(s,{sx:qe,children:i(b,{testId:"footer-logo-image",logo:"ImmutableHorizontalLockup",sx:{width:"base.spacing.x25"}})})]})})})}const Qe=(e,t=500)=>{const[o,a]=l.useState(e);return l.useEffect((()=>{const o=setTimeout((()=>{a(e)}),t);return()=>{clearTimeout(o)}}),[e,t]),o};class Ze{static id=0;promiseId=0;promise;isCancelled=!1;onCancel=null;rejectPromise=()=>{};constructor(e){Ze.id+=1,this.promiseId=Ze.id,this.promise=new Promise(((t,o)=>{this.rejectPromise=o,e((e=>{this.isCancelled?o({cancelled:!0}):t(e)}),(e=>{this.isCancelled?o({cancelled:!0}):o(e)}))}))}static all(e){return new Ze(((t,o)=>{Promise.all(e.map((e=>e instanceof Ze?e.promise:e))).then(t,o)}))}then(e,t){return new Ze(((o,a)=>{this.promise.then((t=>o(e?e(t):t)),(e=>t?o(t(e)):a(e)))}))}catch(e){return this.then(void 0,e)}finally(e){return new Ze(((t,o)=>{this.promise.then(t,o).finally((()=>{e&&e()}))}))}cancel(){this.isCancelled||(this.isCancelled=!0,this.onCancel&&this.onCancel(),this.rejectPromise({cancelled:!0}))}onCancelled(e){this.onCancel=e}get cancelled(){return this.isCancelled}}var Ye;!function(e){e.FROM="FROM",e.TO="TO"}(Ye||(Ye={}));const et=({swapFromToken:e,swapToToken:t,swapFromAmount:o,swapToAmount:a,conversion:n})=>{const s={fromToConversion:"",swapToAmount:""};if(!a)return s;if(s.swapToAmount=_(a),o&&e&&t){const o=F(_(U(n,t.decimals)),!0);s.fromToConversion=`1 ${e.symbol} ≈ ${o} ${t.symbol}`}return s},tt=(e,t)=>void 0!==e&&(""!==e&&t!==e);let ot;function at({data:t,theme:o}){const{t:n}=e(),{swapState:{allowedTokens:r,exchange:c,tokenBalances:T,network:S}}=l.useContext(ke),{connectLoaderState:g}=l.useContext(w),{checkout:x,provider:h}=g,b=k(x?.config.environment,o),C=l.useCallback(((e,t)=>P(t)?`${e.toLowerCase()}-${R}`:`${e.toLowerCase()}-${t.toLowerCase()}`),[]),{cryptoFiatState:G,cryptoFiatDispatch:$}=l.useContext(Ee),{viewDispatch:z}=l.useContext(m),[H,J]=l.useState(Ye.FROM),[q,K]=l.useState(!1),[X,Q]=l.useState(p.from(0)),[Z,Y]=l.useState(""),ee=l.useRef(!1),{track:te}=f(),[oe,ae]=l.useState(t?.fromAmount||""),[ne,se]=l.useState(""),re=Qe(oe,B),[ie,de]=l.useState(),[ce,le]=l.useState(""),[pe,ue]=l.useState(""),[me,Te]=l.useState(t?.toAmount||""),[ye,Ae]=l.useState(""),ve=Qe(me,B),[ge,he]=l.useState(),[Ie,be]=l.useState(""),[Ce,Pe]=l.useState(""),[_e,Fe]=l.useState(null),[Oe,De]=l.useState(""),[Ne,Ve]=l.useState(void 0),[Ue,Be]=l.useState(""),[Me,je]=l.useState([]),[$e,ze]=l.useState(!1),[He,Je]=l.useState(!1),[qe,Ke]=l.useState(!1);l.useEffect((()=>{if(0===T.length)return;if(!S)return;const e=T.filter((e=>e.balance.gt(0))).map((e=>({id:C(e.token.symbol,e.token.address),name:e.token.name,symbol:e.token.symbol,icon:e.token.icon,balance:{formattedAmount:_(e.formattedBalance),formattedFiatAmount:0===G.conversions.size?F(""):O(e.formattedBalance,e.token.symbol||"",G.conversions)}})));je(e),ee.current||(ee.current=!0,t?.fromTokenAddress&&(de(r.find((e=>P(e.address)&&t?.fromTokenAddress?.toLowerCase()===R||e.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))),le(T.find((e=>P(e.token.address)&&t?.fromTokenAddress?.toLowerCase()===R||e.token.address?.toLowerCase()===t?.fromTokenAddress?.toLowerCase()))?.formattedBalance??"")),tt(t?.toTokenAddress,t?.fromTokenAddress)&&he(r.find((e=>P(e.address)&&t?.toTokenAddress?.toLowerCase()===R||e.address?.toLowerCase()===t?.toTokenAddress?.toLowerCase()))))}),[T,r,G.conversions,t?.fromTokenAddress,t?.toTokenAddress,ee.current,de,le,he,je,C,F,S]);const at=l.useMemo((()=>r.map((e=>({id:C(e.symbol,e.address),name:e.name,symbol:e.symbol,icon:e.icon})))),[r,ie]);l.useEffect((()=>{$({payload:{type:Se.SET_TOKEN_SYMBOLS,tokenSymbols:r.map((e=>e.symbol))}})}),[$,r]);const nt=()=>{se(""),ue(""),Ae(""),be("")},st=()=>{ot&&ot.cancel(),Y(""),Be(""),Fe(null)},rt=e=>!Number.isNaN(parseFloat(oe))&&(!(parseFloat(oe)<=0)&&(!!ie&&(!!ge&&(!e||!q)))),it=async(e=!1)=>{rt(e)&&(ot&&ot.cancel(),e||K(!0),await(async(e=!1)=>{if(h&&c&&ie&&ge){try{e||Y("");const t=Re.fromAmountIn(c,h,ie,oe,ge),o=Re.fromAmountIn(c,h,ie,"1",ge),a=Ze.all([t,o]);ot=a;const n=await a,s=n[0],i=n[1];Q(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=U(l,j),m=d?.token,w=r.find((e=>e.address?.toLocaleLowerCase()===m?.address?.toLocaleLowerCase()));Fe(s),De(u),Ve({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),Be(O(u,w?.symbol||"",G.conversions)),Te(F(_(U(s.quote.amount.value,s.quote.amount.token.decimals),s.quote.amount.token.decimals))),nt()}catch(e){e.cancelled||(st(),ze(!1),Je(!0))}e||K(!1)}})(e))},dt=e=>!Number.isNaN(parseFloat(me))&&(!(parseFloat(me)<=0)&&(!!ie&&(!!ge&&(!e||!q)))),ct=async(e=!1)=>{dt(e)&&(ot&&ot.cancel(),e||K(!0),await(async(e=!1)=>{if(h&&c&&ie&&ge){try{e||Y("");const t=Re.fromAmountOut(c,h,ge,me,ie),o=Re.fromAmountIn(c,h,ie,"1",ge),a=Ze.all([t,o]);ot=a;const n=await a,s=n[0],i=n[1];Q(i.quote.amount.value);const d=s.swap.gasFeeEstimate;let l=p.from(d?.value||0);s.approval?.gasFeeEstimate&&(l=l.add(s.approval.gasFeeEstimate.value));const u=U(l,j),m=d?.token,w=r.find((e=>e.symbol===m?.symbol));Fe(s),De(u),Ve({name:w?.name||"",symbol:w?.symbol||"",decimals:w?.decimals||0,address:w?.address,icon:w?.icon}),Be(O(u,w?.symbol||"",G.conversions)),ae(F(_(U(s.quote.amount.value,s.quote.amount.token.decimals)))),nt()}catch(e){e.cancelled||(st(),ze(!1),Je(!0))}e||K(!1)}})(e))},lt=async(e=!1)=>{H===Ye.FROM?await it(e):await ct(e)};xe((()=>lt(!0)),W),l.useEffect((()=>{if(H===Ye.FROM){if(re<=0)return K(!1),void st();(async()=>{await lt()})()}}),[re,ie,ge]),l.useEffect((()=>{if(H===Ye.TO){if(ve<=0)return K(!1),void st();(async()=>{await lt()})()}}),[ve,ge,ie]);const pt=l.useMemo((()=>{const e=T.find((e=>e.token.address?.toLowerCase()===R));if(!e)return!0;const t=ie?.address?.toLowerCase()===R,o=D(0!==Oe.length?Oe:"0"),a=t&&!Number.isNaN(parseFloat(oe))?u(oe,ie?.decimals||18):p.from("0");return o.add(a).gt(e.balance)}),[Oe,T,ie,oe]);l.useEffect((()=>{oe&&ie&&Pe(O(oe,ie.symbol,G.conversions))}),[oe,ie]);const ut=l.useCallback((e=>{const t=T.find((t=>e===C(t.token.symbol,t.token.address)));t&&(ge&&e===C(ge.symbol,ge?.address)&&he(void 0),de(t.token),le(t.formattedBalance),ue(""))}),[ge]),mt=l.useCallback((e=>{const t=r.find((t=>e===C(t.symbol,t.address)));t&&(ie&&e===C(ie.symbol,ie?.address)&&de(void 0),he(t),be(""))}),[ie]);return l.useEffect((()=>{_e&&X&&Y(et({swapFromToken:ie,swapFromAmount:oe,swapToToken:ge,swapToAmount:me,conversion:X}).fromToConversion)}),[_e,X]),a(V,{children:[a(s,{sx:{paddingX:"base.spacing.x4",marginBottom:"base.spacing.x2"},children:[i(I,{size:"small",weight:"regular",sx:{paddingBottom:"base.spacing.x4"},children:n("views.SWAP.content.title")}),a(s,{sx:{display:"flex",flexDirection:"column",rowGap:"base.spacing.x6",paddingBottom:"base.spacing.x2"},children:[a(s,{children:[i(I,{size:"xSmall",sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:n("views.SWAP.swapForm.from.label")}),i(We,{testId:"fromTokenInputs",options:Me,selectSubtext:ie?`${n("views.SWAP.content.availableBalancePrefix")} ${_(ce)}`:"",selectTextAlign:"left",textInputType:"number",textInputValue:oe,textInputPlaceholder:n("views.SWAP.swapForm.from.inputPlaceholder"),textInputSubtext:`${n("views.SWAP.content.fiatPricePrefix")} \n $${F(Ce,!0)}`,textInputTextAlign:"right",textInputValidator:N,onTextInputChange:e=>{return t=e,nt(),st(),Te(""),rt(!1)&&K(!0),void ae(t);var t},onTextInputFocus:()=>{J(Ye.FROM)},textInputMaxButtonClick:()=>{if(!ce)return;const e=ce.slice(0,ce.indexOf(".")+M+1);nt(),st(),Te(""),J(Ye.FROM),ae(e),te({userJourney:y.SWAP,screen:"SwapCoins",control:"MaxFrom",controlType:"Button",extras:{fromBalance:ce,fromBalanceTruncated:e}})},onSelectChange:ut,textInputErrorMessage:n(ne),selectErrorMessage:n(pe),selectedOption:ie?C(ie.symbol,ie.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.from.selectorTitle"),defaultTokenImage:b})]}),a(s,{children:[a(s,{sx:{display:"flex",justifyContent:"space-between",paddingBottom:"base.spacing.x1"},children:[i(I,{size:"xSmall",children:n("views.SWAP.swapForm.to.label")}),i(d,{sx:{color:"base.color.brand.4"},size:"small",children:Z})]}),i(We,{testId:"toTokenInputs",options:at,selectTextAlign:"left",textInputType:"number",textInputValue:me,textInputPlaceholder:n("views.SWAP.swapForm.to.inputPlaceholder"),textInputTextAlign:"right",textInputValidator:N,onTextInputChange:e=>{return t=e,nt(),st(),Pe(""),ae(""),dt(!1)&&K(!0),void Te(t);var t},onTextInputFocus:()=>{J(Ye.TO)},onSelectChange:mt,textInputErrorMessage:n(ye),selectErrorMessage:n(Ie),selectedOption:ge?C(ge.symbol,ge.address):void 0,coinSelectorHeading:n("views.SWAP.swapForm.to.selectorTitle"),defaultTokenImage:b})]})]}),i(we,{gasFeeFiatValue:Ue,gasFeeToken:Ne,gasFeeValue:Oe,fees:[{label:n("drawers.feesBreakdown.fees.gasFeeSwap.label"),fiatAmount:`~ ${n("drawers.feesBreakdown.fees.fiatPricePrefix")}${Ue}`,amount:_(Oe),prefix:"~"}],onFeesClick:()=>{te({userJourney:y.SWAP,screen:"SwapCoins",control:"ViewFees",controlType:"Button"})},sx:{paddingBottom:"0"},loading:q})]}),i(Le,{validator:()=>{const e=function(e){return e?"":"views.SWAP.validation.noFromTokenSelected"}(ie),t=(a=ce,(o=oe)&&0!==parseFloat(o)?a&&Number(o)>Number(a)?"views.SWAP.validation.insufficientBalance":"":"views.SWAP.validation.noAmountInputted");var o,a;const n=function(e){return e?"":"views.SWAP.validation.noToTokenSelected"}(ge),s=function(e){return e&&0!==parseFloat(e)?"":"views.SWAP.validation.noAmountInputted"}(me);H===Ye.FROM?(Ae(""),t&&se(t)):H===Ye.TO&&(se(""),s&&Ae(s)),e&&ue(e),n&&be(n);let r=!0;return(e||n||t&&H===Ye.FROM||s&&H===Ye.TO)&&(r=!1),te({userJourney:y.SWAP,screen:"SwapCoins",control:"FormValid",controlType:"Button",extras:{isSwapFormValid:r,swapFromAddress:ie?.address,swapFromAmount:oe,swapFromTokenSymbol:ie?.symbol,swapToAddress:ge?.address,swapToAmount:me,swapToTokenSymbol:ge?.symbol}}),r},updateLoading:e=>{K(e)},loading:q,transaction:_e,data:{fromAmount:oe,toAmount:me,fromTokenSymbol:ie?.symbol,fromTokenAddress:ie?.address,toTokenSymbol:ge?.symbol,toTokenAddress:ge?.address},insufficientFundsForGas:pt,openNotEnoughImxDrawer:()=>{Je(!1),ze(!0)},openNetworkSwitchDrawer:()=>Ke(!0)}),i(Ge,{environment:x?.config.environment??L.PRODUCTION,visible:$e,showAdjustAmount:ie?.address===R,hasZeroImx:!1,onAddCoinsClick:()=>{z({payload:{type:E.UPDATE_VIEW,view:{type:v.TOP_UP_VIEW},currentViewData:{fromTokenAddress:ie?.address??"",fromAmount:oe,toTokenAddress:ge?.address??""}}})},onCloseDrawer:()=>ze(!1)}),i(Xe,{visible:He,onCloseDrawer:()=>{Je(!1),de(void 0),ae(""),he(void 0),Te("")}}),i(fe,{visible:qe,targetChainId:A(x?.config),provider:h,checkout:x,onCloseDrawer:()=>Ke(!1)})]})}const nt=(e,t)=>{if(0===e.length)return!0;let o=!1;return e.forEach((e=>{e.token.symbol===t&&e.balance.eq(0)&&(o=!0)})),o};function st({theme:t,fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}){const{t:c}=e(),{viewDispatch:p}=l.useContext(m),{eventTargetState:{eventTarget:u}}=l.useContext(G),{swapState:{tokenBalances:T}}=l.useContext(ke),{connectLoaderState:{checkout:A}}=l.useContext(w),[S,g]=l.useState(!1),{page:x}=f();return l.useEffect((()=>{x({userJourney:y.SWAP,screen:"SwapCoins",extras:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d}})}),[]),l.useEffect((()=>{nt(T,J)&&g(!0)}),[T]),i(H,{header:i($,{title:c("views.SWAP.header.title"),onCloseButtonClick:()=>z(u)}),footer:i(Ie,{environment:A?.config.environment,theme:t}),children:a(s,{sx:{height:"100%",display:"flex",flexDirection:"column",justifyContent:"space-between"},children:[i(at,{data:{fromAmount:o,toAmount:n,fromTokenAddress:r,toTokenAddress:d},theme:t}),i(Ge,{environment:A?.config.environment??L.PRODUCTION,visible:S,showAdjustAmount:!1,hasZeroImx:!0,onAddCoinsClick:()=>{p({payload:{type:E.UPDATE_VIEW,view:{type:v.TOP_UP_VIEW}}})},onCloseDrawer:()=>{g(!1)}})]})})}function rt({transactionResponse:t,swapForm:o}){const{t:a}=e(),{viewDispatch:n}=l.useContext(m),{page:s}=f();return l.useEffect((()=>{s({userJourney:y.SWAP,screen:"SwapInProgress",extras:{swapFormInfo:o}})}),[]),l.useEffect((()=>{(async()=>{try{const e=await t.wait();if(1===e.status)return void n({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SUCCESS,data:{fromTokenAddress:o.fromTokenAddress,fromAmount:o.fromAmount,toTokenAddress:o.toTokenAddress,toAmount:o.toAmount||"",transactionHash:e.transactionHash}}}});n({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,data:o,reason:"Transaction failed"}}})}catch{n({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,data:o,reason:"Transaction failed"}}})}})()}),[t]),i(q,{loadingText:a("views.SWAP.IN_PROGRESS.loading.text")})}function it({data:t}){const{t:o}=e(),{swapState:{allowedTokens:n}}=l.useContext(ke),{connectLoaderState:r}=l.useContext(w),{checkout:d,provider:c}=r,{viewDispatch:p}=l.useContext(m),{eventTargetState:{eventTarget:u}}=l.useContext(G),T=K(c),[A,g]=l.useState(!1),[x,h]=l.useState(!1),[I,b]=l.useState(!1),[C,k]=l.useState(!1),[P,R]=l.useState(!1),[_,F]=l.useState(!1),{page:O,track:W}=f();l.useEffect((()=>{O({userJourney:y.SWAP,screen:"ApproveERC20",extras:{swapFormInfo:t.swapFormInfo}})}),[]);const D=l.useMemo((()=>n.find((e=>e.address===t.swapFormInfo.fromTokenAddress))),[n,t.swapFormInfo.fromTokenAddress]),N=l.useCallback((()=>{p({payload:{type:E.UPDATE_VIEW,view:{type:v.ERROR_VIEW,error:new Error("No checkout object or no provider object found")}}})}),[p]),L=l.useCallback((()=>{p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SWAP,data:t.swapFormInfo}}})}),[p]),U=(e,t)=>{e.type!==S.UNPREDICTABLE_GAS_LIMIT?e.type===S.TRANSACTION_FAILED||e.type===S.INSUFFICIENT_FUNDS||e.receipt&&0===e.receipt.status?p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,reason:"Transaction failed",data:t}}}):p({payload:{type:E.UPDATE_VIEW,view:{type:v.ERROR_VIEW,error:e}}}):p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.PRICE_SURGE,data:t}}})},B=l.useCallback((async()=>{if(!C)if(W({userJourney:y.SWAP,screen:"ApproveERC20",control:"ApproveSpending",controlType:"Button"}),k(!0),d&&c){if(!A){g(!0);try{const e=await d.sendTransaction({provider:c,transaction:t.approveTransaction});h(!0);if(1!==(await e.transactionResponse.wait()).status)return void p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.FAIL,data:t.swapFormInfo}}});h(!1),g(!1),b(!0)}catch(e){if(h(!1),g(!1),e.type===S.USER_REJECTED_REQUEST_ERROR)return void R(!0);U(e,t.swapFormInfo)}finally{k(!1)}}}else N()}),[d,c,N,p,F,t.approveTransaction,t.swapFormInfo,A,g,h]),M=l.useMemo((()=>a(X,{heading:o(`views.APPROVE_ERC20.approveSpending.content.${T?"passport":"metamask"}.heading`),children:[T&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.passport.body")}),!T&&i(s,{children:o("views.APPROVE_ERC20.approveSpending.content.metamask.body",{amount:`${t.swapFormInfo.fromAmount} ${D?.symbol||""}`})})]})),[t.swapFormInfo,D,T]),j=l.useMemo((()=>i(Q,{loading:C,actionText:o(P?"views.APPROVE_ERC20.approveSpending.footer.retryText":"views.APPROVE_ERC20.approveSpending.footer.buttonText"),onActionClick:B})),[P,B,C]),J=l.useCallback((async()=>{if(!C)if(W({userJourney:y.SWAP,screen:"ApproveERC20",control:"ApproveSwap",controlType:"Button"}),k(!0),d&&c){if(!A){g(!0);try{const e=await d.sendTransaction({provider:c,transaction:t.transaction});g(!1),p({payload:{type:E.UPDATE_VIEW,view:{type:Ae.IN_PROGRESS,data:{transactionResponse:e.transactionResponse,swapForm:t.swapFormInfo}}}})}catch(e){if(g(!1),e.type===S.USER_REJECTED_REQUEST_ERROR)return void F(!0);U(e,t.swapFormInfo)}finally{k(!1)}}}else N()}),[d,c,N,p,F,t.transaction,t.swapFormInfo,A,g]),Z=i(X,{heading:o("views.APPROVE_ERC20.approveSwap.content.heading"),children:i(s,{children:o("views.APPROVE_ERC20.approveSwap.content.body")})}),Y=l.useMemo((()=>i(Q,{loading:C,actionText:o(_?"views.APPROVE_ERC20.approveSwap.footer.retryText":"views.APPROVE_ERC20.approveSwap.footer.buttonText"),onActionClick:J})),[_,J,C]);return a(V,{children:[x&&i(q,{loadingText:o("views.APPROVE_ERC20.approveSpending.loading.text")}),!x&&i(H,{header:i($,{transparent:!0,showBack:!0,onCloseButtonClick:()=>z(u),onBackButtonClick:L}),floatHeader:!0,heroContent:i(I?Te:he,{}),footer:I?Y:j,children:I?Z:M})]})}function dt({amount:t,fromTokenAddress:o,toTokenAddress:n,config:s}){const{t:r}=e(),{eventTargetState:{eventTarget:d}}=l.useContext(G),{environment:c,theme:p,isOnRampEnabled:u,isSwapEnabled:T,isBridgeEnabled:S}=s,{connectLoaderState:{checkout:g,provider:x}}=l.useContext(w),[h,I]=l.useReducer(Z,{...Y,history:[]}),[b,C]=l.useReducer(Pe,be),{page:k}=f(),[P,R]=l.useState(!1),_=l.useMemo((()=>({swapState:b,swapDispatch:C})),[b,C]),F=l.useMemo((()=>({viewState:h,viewDispatch:I})),[h,I]),O=l.useCallback(((e,t)=>{I({payload:{type:E.UPDATE_VIEW,view:{type:v.ERROR_VIEW,tryAgain:t,error:e}}})}),[I]),W=l.useCallback((()=>{I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SWAP}}})}),[I]),D=l.useCallback((async()=>{if(!g)throw new Error("loadBalances: missing checkout");if(!x)throw new Error("loadBalances: missing provider");try{const e=await ye({checkout:g,provider:x,allowTokenListType:ee.SWAP});if(void 0===e)return!1;C({payload:{type:Ce.SET_ALLOWED_TOKENS,allowedTokens:e.allowList.tokens}}),C({payload:{type:Ce.SET_TOKEN_BALANCES,tokenBalances:e.allowedBalances}})}catch(e){if(te.nonRetryable(e))return O(e,D),!1}return!0}),[g,x]);return l.useEffect((()=>{(async()=>{if(!g||!x)return;const e=await g.getNetworkInfo({provider:x});if(e.chainId!==A(g.config))return;let t;try{t=await g.config.remote.getConfig("dex")}catch(e){return void O(e)}const o=new oe({chainId:e.chainId,baseConfig:new ae({environment:c}),secondaryFees:t.secondaryFees,overrides:t.overrides});C({payload:{type:Ce.SET_EXCHANGE,exchange:o}}),C({payload:{type:Ce.SET_NETWORK,network:e}}),await D()&&h.view.type===v.LOADING_VIEW&&W()})()}),[g,x]),i(m.Provider,{value:F,children:i(ke.Provider,{value:_,children:a(ge,{environment:c,children:[h.view.type===v.LOADING_VIEW&&i(q,{loadingText:r("views.LOADING_VIEW.text")}),h.view.type===Ae.SWAP&&i(st,{theme:p,fromAmount:h.view.data?.fromAmount??t,fromTokenAddress:h.view.data?.fromTokenAddress??o,toTokenAddress:h.view.data?.toTokenAddress??n}),h.view.type===Ae.IN_PROGRESS&&i(rt,{transactionResponse:h.view.data.transactionResponse,swapForm:h.view.data.swapForm}),h.view.type===Ae.APPROVE_ERC20&&i(it,{data:h.view.data}),h.view.type===Ae.SUCCESS&&i(ne,{statusText:r("views.SWAP.success.text"),actionText:r("views.SWAP.success.actionText"),onRenderEvent:()=>{k({userJourney:y.SWAP,screen:"SwapSuccess",extras:{fromTokenAddress:h.view.data?.fromTokenAddress,fromAmount:h.view.data?.fromAmount,toTokenAddress:h.view.data?.toTokenAddress,toAmount:h.view.data?.toAmount}}),se(d,h.view.data.transactionHash)},onActionClick:()=>z(d),statusType:re.SUCCESS,testId:"success-view"}),h.view.type===Ae.FAIL&&i(ne,{statusText:r("views.SWAP.failed.text"),actionText:r("views.SWAP.failed.actionText"),onRenderEvent:()=>{k({userJourney:y.SWAP,screen:"SwapFailed"}),ie(d,"Transaction failed")},onActionClick:()=>{h.view.type===Ae.FAIL&&I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SWAP,data:h.view.data}}})},statusType:re.FAILURE,onCloseClick:()=>z(d),testId:"fail-view"}),h.view.type===Ae.PRICE_SURGE&&i(ne,{statusText:r("views.SWAP.rejected.text"),actionText:r("views.SWAP.rejected.actionText"),onRenderEvent:()=>{k({userJourney:y.SWAP,screen:"PriceSurge"}),de(d,"Price surge")},onActionClick:()=>{h.view.type===Ae.PRICE_SURGE&&I({payload:{type:E.UPDATE_VIEW,view:{type:Ae.SWAP,data:h.view.data}}})},statusType:re.WARNING,onCloseClick:()=>z(d),testId:"price-surge-view"}),h.view.type===v.ERROR_VIEW&&i(ce,{actionText:r("views.ERROR_VIEW.actionText"),onActionClick:async()=>{R(!0);const e=h.view;if(!e.tryAgain)return W(),void R(!1);await e.tryAgain()&&W(),R(!1)},onCloseClick:()=>z(d),errorEventActionLoading:P}),h.view.type===v.TOP_UP_VIEW&&i(ve,{analytics:{userJourney:y.SWAP},checkout:g,provider:x,widgetEvent:le.IMTBL_SWAP_WIDGET_EVENT,showOnrampOption:u,showSwapOption:T,showBridgeOption:S,onCloseButtonClick:()=>z(d)})]})})})}export{dt as default};
@@ -1 +1 @@
1
- import{r as t,ae as e,bt as n,a as o,aZ as s,j as i,M as a,B as r,u as c,V as d,E,e as l,bR as p,z as u,G as S,H as _,J as f,I as C,d as I,o as T}from"./index-e3a0f33f.js";var h;!function(t){t.USD="usd"}(h||(h={}));const A={cryptoFiat:null,fiatSymbol:h.USD,tokenSymbols:[],conversions:new Map};var O;!function(t){t.SET_CRYPTO_FIAT="SET_CRYPTO_FIAT",t.SET_FIAT_SYMBOL="SET_FIAT_SYMBOL",t.SET_TOKEN_SYMBOLS="SET_TOKEN_SYMBOLS",t.SET_CONVERSIONS="SET_CONVERSIONS"}(O||(O={}));const v=t.createContext({cryptoFiatState:A,cryptoFiatDispatch:()=>{}}),R=(t,e)=>{switch(e.payload.type){case O.SET_CRYPTO_FIAT:return{...t,cryptoFiat:e.payload.cryptoFiat};case O.SET_FIAT_SYMBOL:return{...t,fiatSymbol:e.payload.fiatSymbol};case O.SET_TOKEN_SYMBOLS:return{...t,tokenSymbols:e.payload.tokenSymbols};case O.SET_CONVERSIONS:return{...t,conversions:e.payload.conversions};default:return t}};var y;!function(t){t.SWAP="SWAP",t.IN_PROGRESS="IN_PROGRESS",t.SUCCESS="SUCCESS",t.FAIL="FAIL",t.PRICE_SURGE="PRICE_SURGE",t.APPROVE_ERC20="APPROVE_ERC20_SWAP"}(y||(y={}));class m{baseConfig;constructor({baseConfig:t}){this.baseConfig=t}}const w={[e.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[e.PRODUCTION]:"https://checkout-api.immutable.com"};class g{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig}urlWithPath(t){return w[this.config.environment]+t}async fetchOverrides(){if(null!==this.overridesCache)return;const t=this.urlWithPath("/v1/fiat/coins/overrides"),e=await n.get(t);if(200!==e.status)throw new Error(`Error fetching coins overrides: ${e.status} ${e.statusText}`);this.overridesCache=new Map(Object.entries(e.data))}async fetchCoins(){if(null!==this.coinsCache)return;await this.fetchOverrides();const t=this.urlWithPath("/v1/fiat/coins/all"),e=await n.get(t);if(200!==e.status)throw new Error(`Error fetching coins list: ${e.status} ${e.statusText}`);const{data:o}=e;this.coinsCache=new Map;for(const t of o){const e=this.overridesCache.get(t.symbol.toLowerCase());this.coinsCache.set(t.symbol.toLowerCase(),e||t.id.toLowerCase())}}async convert({tokenSymbols:t,fiatSymbols:e=[]}){if(!t||0===t.length)throw new Error("Error missing token symbols to convert");const o=e.filter((t=>""!==t));0===o.length&&o.push("usd"),await this.fetchCoins();const s=t.map((t=>this.coinsCache.get(t.toLowerCase()))).filter((t=>""!==t&&void 0!==t)).join(","),i=o.join(",").toLowerCase(),a=this.urlWithPath(`/v1/fiat/conversion?ids=${s}&currencies=${i}`),r=await n.get(a);if(200!==r.status)throw new Error(`Error fetching prices: ${r.status} ${r.statusText}`);const{data:c}=r,d={};for(const e of t){const t=e.toLowerCase(),n=this.coinsCache.get(t);d[t]={},n&&(d[t]=c[n]||{})}return d}}const b=async(t,e,n)=>{try{if(0===n.length)return new Map;return((t,e)=>{const n=new Map;for(const o in t){const s=t[o][e];void 0!==s&&n.set(o,s)}return n})(await t.convert({tokenSymbols:n,fiatSymbol:e}),e)}catch(t){return new Map}},P=["ETH","IMX"];function L({environment:e,children:n}){const[s,i]=t.useReducer(R,A),{cryptoFiat:a,fiatSymbol:r,tokenSymbols:c}=s;return t.useEffect((()=>{i({payload:{type:O.SET_CRYPTO_FIAT,cryptoFiat:new g(new m({baseConfig:{environment:e}}))}})}),[]),t.useEffect((()=>{a&&r&&(async()=>{const t=await b(a,r,[...new Set([...c,...P])]);i({payload:{type:O.SET_CONVERSIONS,conversions:t}})})()}),[a,c,r]),o(v.Provider,{value:{cryptoFiatState:s,cryptoFiatDispatch:i},children:n})}var N;!function(t){t.WALLET_NETWORK_SELECTION="WALLET_NETWORK_SELECTION",t.BRIDGE_FORM="BRIDGE_FORM",t.BRIDGE_REVIEW="BRIDGE_REVIEW",t.IN_PROGRESS="IN_PROGRESS",t.BRIDGE_FAILURE="BRIDGE_FAILURE",t.APPROVE_TRANSACTION="APPROVE_TRANSACTION",t.TRANSACTIONS="TRANSACTIONS",t.CLAIM_WITHDRAWAL="CLAIM_WITHDRAWAL",t.CLAIM_WITHDRAWAL_IN_PROGRESS="CLAIM_WITHDRAWAL_IN_PROGRESS",t.CLAIM_WITHDRAWAL_SUCCESS="CLAIM_WITHDRAWAL_SUCCESS",t.CLAIM_WITHDRAWAL_FAILURE="CLAIM_WITHDRAWAL_FAILURE"}(N||(N={}));const W=(t,e)=>{const{fees:n,token:o}=t;if(void 0===n.totalFees)return"-.--";if(void 0===o)return"-.--";const i=((t,e,n)=>{let o=-1;if(t&&e){const i=s(t,e.decimals),a=n.get(e.symbol.toLocaleLowerCase());if(a){const t=parseFloat(i);if(Number.isNaN(t))return o;o=t*a}}return o})(n.totalFees,o,e);return i<0?"-.--":function(t){if(t<0)return"-.--";const e=t.toString();if(e.includes("e")||0===t)return"0.00";if(t<.01)for(let n=0;n<e.length;n++)if("0"!==e[n]&&"."!==e[n])return t.toFixed(n-1);return t.toFixed(2)}(i)};var F;function k({testId:t,icon:e,heading:n,caption:s,onClick:c,renderFeeFunction:d,isDisabled:E}){return o(r,{testId:"top-up-view",sx:{paddingY:"1px"},children:i(a,{testId:`menu-item-${t}`,size:"medium",emphasized:!0,onClick:E?void 0:c,sx:E?{opacity:"0.5",cursor:"not-allowed"}:{},children:[o(a.Icon,{icon:e}),o(a.Label,{size:"medium",children:n}),o(a.IntentIcon,{}),i(a.Caption,{testId:`menu-item-caption-${t}`,children:[s,o("br",{}),E?"":d("-.--",!1)]})]})})}function U({widgetEvent:e,checkout:n,provider:s,showOnrampOption:a,showSwapOption:h,showBridgeOption:A,tokenAddress:R,amount:m,analytics:w,onCloseButtonClick:g,onBackButtonClick:b}){const{t:L}=c(),{userJourney:U}=w,{viewDispatch:B}=t.useContext(d),{cryptoFiatState:D,cryptoFiatDispatch:M}=t.useContext(v),{conversions:x,fiatSymbol:G}=D,{eventTargetState:{eventTarget:$}}=t.useContext(E),[V,K]=t.useState("-.--"),[Y,H]=t.useState("-.--"),[z,j]=t.useState(!0),{page:J,track:q}=l();t.useEffect((()=>{J({userJourney:U,screen:"TopUp"})}),[]),t.useEffect((()=>{M&&M({payload:{type:O.SET_TOKEN_SYMBOLS,tokenSymbols:P}})}),[M]),t.useEffect((()=>{n&&(async()=>{const t=await n.gasEstimate({gasEstimateType:p.BRIDGE_TO_L2}),e=await W(t,x);H(e)})()}),[void 0!==n]),t.useEffect((()=>{n&&(async()=>{const t=(t=>{const{minPercentage:e,maxPercentage:n}=t;return void 0===e||void 0===n?"-.--":`${e}% to ${n}`})(await n.getExchangeFeeEstimate());K(t)})()}),[void 0!==n]),t.useEffect((()=>{n&&(async()=>{j(await n.isSwapAvailable())})()}),[void 0!==n]);const X=(t,e,n="Button")=>{q({userJourney:U,screen:"TopUp",control:t,controlType:n,extras:e})},Z=t=>o(r,{sx:{fontSize:"base.text.caption.small.regular.fontSize",c:"base.color.translucent.standard.600"},children:t}),Q=[{testId:"onramp",icon:"BankCard",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.onramp",onClickEvent:()=>{if(e===C.IMTBL_ONRAMP_WIDGET_EVENT){const t={tokenAddress:"",amount:""};return B({payload:{type:I.UPDATE_VIEW,view:{type:F.ONRAMP,data:t}}}),void X("OnRamp",{...t,widgetEvent:e})}const t={tokenAddress:R??"",amount:m??""};T.sendRequestOnrampEvent($,e,t),X("OnRamp",{...t,widgetEvent:e})},fee:()=>Z(`${L("views.TOP_UP_VIEW.topUpOptions.onramp.subcaption")} ≈ ${V}%`),isAvailable:!0,isEnabled:a},{testId:"swap",icon:"Swap",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.swap",onClickEvent:()=>{if(e===C.IMTBL_SWAP_WIDGET_EVENT){const t={toTokenAddress:"",fromAmount:"",fromTokenAddress:""};return B({payload:{type:I.UPDATE_VIEW,view:{type:y.SWAP,data:t}}}),void X("Swap",{...t,widgetEvent:e})}const t={fromTokenAddress:"",toTokenAddress:R??"",amount:""};T.sendRequestSwapEvent($,e,t),X("Swap",{...t,widgetEvent:e})},fee:()=>Z(`${L("views.TOP_UP_VIEW.topUpOptions.swap.subcaption")} ≈ $0.05 ${G.toUpperCase()}`),isAvailable:z,isEnabled:h},{testId:"bridge",icon:"Minting",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.bridge",onClickEvent:()=>{if(e===C.IMTBL_BRIDGE_WIDGET_EVENT){const t={fromTokenAddress:"",fromAmount:""};return B({payload:{type:I.UPDATE_VIEW,view:{type:N.WALLET_NETWORK_SELECTION,data:t}}}),void X("Bridge",{...t,widgetEvent:e})}const t={tokenAddress:"",amount:""};T.sendRequestBridgeEvent($,e,t),X("Bridge",{...t,widgetEvent:e})},fee:()=>Z(`${L("views.TOP_UP_VIEW.topUpOptions.bridge.subcaption")} ≈ $${Y} ${G.toUpperCase()}`),isAvailable:!0,isEnabled:A}];return o(f,{header:o(u,{onBackButtonClick:b,onCloseButtonClick:g,showBack:!0}),footer:o(S,{}),children:i(r,{sx:{paddingX:"base.spacing.x4",paddingY:"base.spacing.x4"},children:[o(_,{size:"small",children:L("views.TOP_UP_VIEW.header.title")}),o(r,{sx:{paddingY:"base.spacing.x4"},children:Q.sort(((t,e)=>Number(e.isAvailable)-Number(t.isAvailable))).map((t=>t.isEnabled&&o(k,{testId:t.testId,icon:t.icon,heading:L(`${t.textConfigKey}.heading`),caption:t.isAvailable?L(`${t.textConfigKey}.caption`):L(`${t.textConfigKey}.disabledCaption`),onClick:t.onClickEvent,renderFeeFunction:t.fee,isDisabled:!t.isAvailable},L(`${t.textConfigKey}.heading`).toLowerCase())))})]})})}!function(t){t.ONRAMP="ONRAMP",t.IN_PROGRESS_LOADING="IN_PROGRESS_LOADING",t.IN_PROGRESS="IN_PROGRESS",t.SUCCESS="SUCCESS",t.FAIL="FAIL"}(F||(F={}));export{N as B,v as C,F as O,y as S,U as T,O as a,L as b};
1
+ import{r as t,ae as e,bt as n,a as o,aZ as s,j as i,M as a,B as r,u as c,V as d,E,e as l,bR as p,z as u,G as S,H as _,J as f,I as C,d as I,o as T}from"./index-394d516d.js";var h;!function(t){t.USD="usd"}(h||(h={}));const A={cryptoFiat:null,fiatSymbol:h.USD,tokenSymbols:[],conversions:new Map};var O;!function(t){t.SET_CRYPTO_FIAT="SET_CRYPTO_FIAT",t.SET_FIAT_SYMBOL="SET_FIAT_SYMBOL",t.SET_TOKEN_SYMBOLS="SET_TOKEN_SYMBOLS",t.SET_CONVERSIONS="SET_CONVERSIONS"}(O||(O={}));const v=t.createContext({cryptoFiatState:A,cryptoFiatDispatch:()=>{}}),R=(t,e)=>{switch(e.payload.type){case O.SET_CRYPTO_FIAT:return{...t,cryptoFiat:e.payload.cryptoFiat};case O.SET_FIAT_SYMBOL:return{...t,fiatSymbol:e.payload.fiatSymbol};case O.SET_TOKEN_SYMBOLS:return{...t,tokenSymbols:e.payload.tokenSymbols};case O.SET_CONVERSIONS:return{...t,conversions:e.payload.conversions};default:return t}};var y;!function(t){t.SWAP="SWAP",t.IN_PROGRESS="IN_PROGRESS",t.SUCCESS="SUCCESS",t.FAIL="FAIL",t.PRICE_SURGE="PRICE_SURGE",t.APPROVE_ERC20="APPROVE_ERC20_SWAP"}(y||(y={}));class m{baseConfig;constructor({baseConfig:t}){this.baseConfig=t}}const w={[e.SANDBOX]:"https://checkout-api.sandbox.immutable.com",[e.PRODUCTION]:"https://checkout-api.immutable.com"};class g{coinsCache;overridesCache;config;constructor(t){this.coinsCache=null,this.overridesCache=null,this.config=t.baseConfig}urlWithPath(t){return w[this.config.environment]+t}async fetchOverrides(){if(null!==this.overridesCache)return;const t=this.urlWithPath("/v1/fiat/coins/overrides"),e=await n.get(t);if(200!==e.status)throw new Error(`Error fetching coins overrides: ${e.status} ${e.statusText}`);this.overridesCache=new Map(Object.entries(e.data))}async fetchCoins(){if(null!==this.coinsCache)return;await this.fetchOverrides();const t=this.urlWithPath("/v1/fiat/coins/all"),e=await n.get(t);if(200!==e.status)throw new Error(`Error fetching coins list: ${e.status} ${e.statusText}`);const{data:o}=e;this.coinsCache=new Map;for(const t of o){const e=this.overridesCache.get(t.symbol.toLowerCase());this.coinsCache.set(t.symbol.toLowerCase(),e||t.id.toLowerCase())}}async convert({tokenSymbols:t,fiatSymbols:e=[]}){if(!t||0===t.length)throw new Error("Error missing token symbols to convert");const o=e.filter((t=>""!==t));0===o.length&&o.push("usd"),await this.fetchCoins();const s=t.map((t=>this.coinsCache.get(t.toLowerCase()))).filter((t=>""!==t&&void 0!==t)).join(","),i=o.join(",").toLowerCase(),a=this.urlWithPath(`/v1/fiat/conversion?ids=${s}&currencies=${i}`),r=await n.get(a);if(200!==r.status)throw new Error(`Error fetching prices: ${r.status} ${r.statusText}`);const{data:c}=r,d={};for(const e of t){const t=e.toLowerCase(),n=this.coinsCache.get(t);d[t]={},n&&(d[t]=c[n]||{})}return d}}const b=async(t,e,n)=>{try{if(0===n.length)return new Map;return((t,e)=>{const n=new Map;for(const o in t){const s=t[o][e];void 0!==s&&n.set(o,s)}return n})(await t.convert({tokenSymbols:n,fiatSymbol:e}),e)}catch(t){return new Map}},P=["ETH","IMX"];function L({environment:e,children:n}){const[s,i]=t.useReducer(R,A),{cryptoFiat:a,fiatSymbol:r,tokenSymbols:c}=s;return t.useEffect((()=>{i({payload:{type:O.SET_CRYPTO_FIAT,cryptoFiat:new g(new m({baseConfig:{environment:e}}))}})}),[]),t.useEffect((()=>{a&&r&&(async()=>{const t=await b(a,r,[...new Set([...c,...P])]);i({payload:{type:O.SET_CONVERSIONS,conversions:t}})})()}),[a,c,r]),o(v.Provider,{value:{cryptoFiatState:s,cryptoFiatDispatch:i},children:n})}var N;!function(t){t.WALLET_NETWORK_SELECTION="WALLET_NETWORK_SELECTION",t.BRIDGE_FORM="BRIDGE_FORM",t.BRIDGE_REVIEW="BRIDGE_REVIEW",t.IN_PROGRESS="IN_PROGRESS",t.BRIDGE_FAILURE="BRIDGE_FAILURE",t.APPROVE_TRANSACTION="APPROVE_TRANSACTION",t.TRANSACTIONS="TRANSACTIONS",t.CLAIM_WITHDRAWAL="CLAIM_WITHDRAWAL",t.CLAIM_WITHDRAWAL_IN_PROGRESS="CLAIM_WITHDRAWAL_IN_PROGRESS",t.CLAIM_WITHDRAWAL_SUCCESS="CLAIM_WITHDRAWAL_SUCCESS",t.CLAIM_WITHDRAWAL_FAILURE="CLAIM_WITHDRAWAL_FAILURE"}(N||(N={}));const W=(t,e)=>{const{fees:n,token:o}=t;if(void 0===n.totalFees)return"-.--";if(void 0===o)return"-.--";const i=((t,e,n)=>{let o=-1;if(t&&e){const i=s(t,e.decimals),a=n.get(e.symbol.toLocaleLowerCase());if(a){const t=parseFloat(i);if(Number.isNaN(t))return o;o=t*a}}return o})(n.totalFees,o,e);return i<0?"-.--":function(t){if(t<0)return"-.--";const e=t.toString();if(e.includes("e")||0===t)return"0.00";if(t<.01)for(let n=0;n<e.length;n++)if("0"!==e[n]&&"."!==e[n])return t.toFixed(n-1);return t.toFixed(2)}(i)};var F;function k({testId:t,icon:e,heading:n,caption:s,onClick:c,renderFeeFunction:d,isDisabled:E}){return o(r,{testId:"top-up-view",sx:{paddingY:"1px"},children:i(a,{testId:`menu-item-${t}`,size:"medium",emphasized:!0,onClick:E?void 0:c,sx:E?{opacity:"0.5",cursor:"not-allowed"}:{},children:[o(a.Icon,{icon:e}),o(a.Label,{size:"medium",children:n}),o(a.IntentIcon,{}),i(a.Caption,{testId:`menu-item-caption-${t}`,children:[s,o("br",{}),E?"":d("-.--",!1)]})]})})}function U({widgetEvent:e,checkout:n,provider:s,showOnrampOption:a,showSwapOption:h,showBridgeOption:A,tokenAddress:R,amount:m,analytics:w,onCloseButtonClick:g,onBackButtonClick:b}){const{t:L}=c(),{userJourney:U}=w,{viewDispatch:B}=t.useContext(d),{cryptoFiatState:D,cryptoFiatDispatch:M}=t.useContext(v),{conversions:x,fiatSymbol:G}=D,{eventTargetState:{eventTarget:$}}=t.useContext(E),[V,K]=t.useState("-.--"),[Y,H]=t.useState("-.--"),[z,j]=t.useState(!0),{page:J,track:q}=l();t.useEffect((()=>{J({userJourney:U,screen:"TopUp"})}),[]),t.useEffect((()=>{M&&M({payload:{type:O.SET_TOKEN_SYMBOLS,tokenSymbols:P}})}),[M]),t.useEffect((()=>{n&&(async()=>{const t=await n.gasEstimate({gasEstimateType:p.BRIDGE_TO_L2}),e=await W(t,x);H(e)})()}),[void 0!==n]),t.useEffect((()=>{n&&(async()=>{const t=(t=>{const{minPercentage:e,maxPercentage:n}=t;return void 0===e||void 0===n?"-.--":`${e}% to ${n}`})(await n.getExchangeFeeEstimate());K(t)})()}),[void 0!==n]),t.useEffect((()=>{n&&(async()=>{j(await n.isSwapAvailable())})()}),[void 0!==n]);const X=(t,e,n="Button")=>{q({userJourney:U,screen:"TopUp",control:t,controlType:n,extras:e})},Z=t=>o(r,{sx:{fontSize:"base.text.caption.small.regular.fontSize",c:"base.color.translucent.standard.600"},children:t}),Q=[{testId:"onramp",icon:"BankCard",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.onramp",onClickEvent:()=>{if(e===C.IMTBL_ONRAMP_WIDGET_EVENT){const t={tokenAddress:"",amount:""};return B({payload:{type:I.UPDATE_VIEW,view:{type:F.ONRAMP,data:t}}}),void X("OnRamp",{...t,widgetEvent:e})}const t={tokenAddress:R??"",amount:m??""};T.sendRequestOnrampEvent($,e,t),X("OnRamp",{...t,widgetEvent:e})},fee:()=>Z(`${L("views.TOP_UP_VIEW.topUpOptions.onramp.subcaption")} ≈ ${V}%`),isAvailable:!0,isEnabled:a},{testId:"swap",icon:"Swap",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.swap",onClickEvent:()=>{if(e===C.IMTBL_SWAP_WIDGET_EVENT){const t={toTokenAddress:"",fromAmount:"",fromTokenAddress:""};return B({payload:{type:I.UPDATE_VIEW,view:{type:y.SWAP,data:t}}}),void X("Swap",{...t,widgetEvent:e})}const t={fromTokenAddress:"",toTokenAddress:R??"",amount:""};T.sendRequestSwapEvent($,e,t),X("Swap",{...t,widgetEvent:e})},fee:()=>Z(`${L("views.TOP_UP_VIEW.topUpOptions.swap.subcaption")} ≈ $0.05 ${G.toUpperCase()}`),isAvailable:z,isEnabled:h},{testId:"bridge",icon:"Minting",textConfigKey:"views.TOP_UP_VIEW.topUpOptions.bridge",onClickEvent:()=>{if(e===C.IMTBL_BRIDGE_WIDGET_EVENT){const t={fromTokenAddress:"",fromAmount:""};return B({payload:{type:I.UPDATE_VIEW,view:{type:N.WALLET_NETWORK_SELECTION,data:t}}}),void X("Bridge",{...t,widgetEvent:e})}const t={tokenAddress:"",amount:""};T.sendRequestBridgeEvent($,e,t),X("Bridge",{...t,widgetEvent:e})},fee:()=>Z(`${L("views.TOP_UP_VIEW.topUpOptions.bridge.subcaption")} ≈ $${Y} ${G.toUpperCase()}`),isAvailable:!0,isEnabled:A}];return o(f,{header:o(u,{onBackButtonClick:b,onCloseButtonClick:g,showBack:!0}),footer:o(S,{}),children:i(r,{sx:{paddingX:"base.spacing.x4",paddingY:"base.spacing.x4"},children:[o(_,{size:"small",children:L("views.TOP_UP_VIEW.header.title")}),o(r,{sx:{paddingY:"base.spacing.x4"},children:Q.sort(((t,e)=>Number(e.isAvailable)-Number(t.isAvailable))).map((t=>t.isEnabled&&o(k,{testId:t.testId,icon:t.icon,heading:L(`${t.textConfigKey}.heading`),caption:t.isAvailable?L(`${t.textConfigKey}.caption`):L(`${t.textConfigKey}.disabledCaption`),onClick:t.onClickEvent,renderFeeFunction:t.fee,isDisabled:!t.isAvailable},L(`${t.textConfigKey}.heading`).toLowerCase())))})]})})}!function(t){t.ONRAMP="ONRAMP",t.IN_PROGRESS_LOADING="IN_PROGRESS_LOADING",t.IN_PROGRESS="IN_PROGRESS",t.SUCCESS="SUCCESS",t.FAIL="FAIL"}(F||(F={}));export{N as B,v as C,F as O,y as S,U as T,O as a,L as b};