@dcl/shop 0.5.1-30944558724.commit-19fdddf → 0.5.1-30947573582.commit-565f915

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 (173) hide show
  1. package/_assets/{Activity-tm1GZBBE.js → Activity-CfTMOs6_.js} +3 -3
  2. package/_assets/{AnimatedBackground-PdNi-WfR.js → AnimatedBackground-ddNb0RFM.js} +2 -2
  3. package/_assets/{Assets-DzU3XKtW.js → Assets-DMujzfAC.js} +2 -2
  4. package/_assets/{Assets.styles-ZM8Q2cFA.js → Assets.styles-BHyaJQ_u.js} +1 -1
  5. package/_assets/{Authorizations-BxBoJzQm.js → Authorizations-sA4551rB.js} +1 -1
  6. package/_assets/{Cart-CoA_J4Zn.js → Cart-D-gFbec1.js} +6 -6
  7. package/_assets/{CircularProgress-iDUU-7Dd.js → CircularProgress-BZLLIzF7.js} +1 -1
  8. package/_assets/{Collection-DUnvQ9xs.js → Collection-Bw6JlBWa.js} +1 -1
  9. package/_assets/{CollectionCarousel-nQamkKEm.js → CollectionCarousel-BuJHPo0X.js} +4 -4
  10. package/_assets/{Creator-Dgszo59r.js → Creator-GqqesGEK.js} +1 -1
  11. package/_assets/{ErrorNotice-CfA5EQ3B.js → ErrorNotice-C0VDjxD8.js} +1 -1
  12. package/_assets/{ExchangeController-CdHvmoRP.js → ExchangeController-hkXFMBqV.js} +1 -1
  13. package/_assets/{GetCredits-Dv4OnlPr.js → GetCredits-B0Ql1-g_.js} +1 -1
  14. package/_assets/{HelpersUtil-DL3ySOBk.js → HelpersUtil-D9KPKXcc.js} +1 -1
  15. package/_assets/ItemDetail-Cnl6tlR5.js +3375 -0
  16. package/_assets/{LoadMore-TnqPM5W_.js → LoadMore-qdo6Ikhu.js} +1 -1
  17. package/_assets/{ManaPricingBanner.styles-C7faS-HZ.js → ManaPricingBanner.styles-fmDpqtPl.js} +1 -1
  18. package/_assets/{MenuList-DLBo9vKa.js → MenuList-D1TrywmL.js} +1 -1
  19. package/_assets/{MyAssets-D-1HxNtf.js → MyAssets-BkkZtMdo.js} +1 -1
  20. package/_assets/{MyFavorites-27Kg0fu-.js → MyFavorites-CFjCtdDv.js} +1 -1
  21. package/_assets/{NotFound-CF-eOmVc.js → NotFound-BAeDLAeA.js} +1 -1
  22. package/_assets/{NotificationsBell-BADWC1wN.js → NotificationsBell-DNKWrtPQ.js} +1 -1
  23. package/_assets/{OutfitDetail-CdadHpaC.js → OutfitDetail-DpEFkAvI.js} +1 -1
  24. package/_assets/{OutfitPreview-JIaMYiWg.js → OutfitPreview-DWsSadbZ.js} +1 -1
  25. package/_assets/{OutfitStudio-D-Tn3MZ0.js → OutfitStudio-Bui1QMID.js} +1 -1
  26. package/_assets/{StoreSettings-5uZXoOvP.js → StoreSettings-C-I4kZXm.js} +1 -1
  27. package/_assets/{Success-C4laQ6DO.js → Success-BSxVxsGR.js} +1 -1
  28. package/_assets/{SwapController-h8IVGbcS.js → SwapController-Cnm5e_hT.js} +1 -1
  29. package/_assets/{Tooltip-ySlzdfvH.js → Tooltip-JQloj8Nt.js} +1 -1
  30. package/_assets/{TradeService-C_mQXbkZ.js → TradeService-DRH0o-kh.js} +1 -1
  31. package/_assets/{W3MFrameProviderSingleton-Be2imJ8Z.js → W3MFrameProviderSingleton-mBM8n0OL.js} +3 -3
  32. package/_assets/{WebCryptoP256-I4V1QbUv.js → WebCryptoP256-CyLBTsmz.js} +1 -1
  33. package/_assets/{authorizations-D7XuRQgn.js → authorizations-C4greZZh.js} +1 -1
  34. package/_assets/{basic-Cue7GVXe.js → basic-CyiK9J1r.js} +1 -1
  35. package/_assets/{biconomy-C-omatJP.js → biconomy-C9DUh0rz.js} +1 -1
  36. package/_assets/{builder-MQPY8ChB.js → builder-DpcoQGnj.js} +1 -1
  37. package/_assets/{buy-DGpUz8hz.js → buy-CvpQJoW5.js} +1 -1
  38. package/_assets/{buy-gasless-Bl-OulBV.js → buy-gasless-Brir4Yxd.js} +1 -1
  39. package/_assets/{categories-BQKh49D5.js → categories-BvyNQxRN.js} +1 -1
  40. package/_assets/{ccip-BC-JPxWw.js → ccip-B9IZwBA5.js} +1 -1
  41. package/_assets/{ccip-Yik4EQGY.js → ccip-BdISl-HW.js} +1 -1
  42. package/_assets/{clsx-Df3CFyaE.js → clsx-csE3gCud.js} +1 -1
  43. package/_assets/{collectionPage.styles-vmTcFGbQ.js → collectionPage.styles-9bHRQ1J-.js} +5 -5
  44. package/_assets/{controller-Bq2L0AX1.js → controller-GoKgW_fy.js} +2 -2
  45. package/_assets/{core-lz2OIs0H.js → core-CMZ6fKcA.js} +4 -4
  46. package/_assets/{createSvgIcon-bfaHZSjd.js → createSvgIcon-CUVJYCF2.js} +1 -1
  47. package/_assets/{custom-DYDi3MJe.js → custom-BReHyJ6N.js} +1 -1
  48. package/_assets/{data-capture-Y8xGExqA.js → data-capture-Dkmn3aLG.js} +1 -1
  49. package/_assets/{email-UTvBfzjL.js → email-D4QgHm8O.js} +1 -1
  50. package/_assets/{embedded-wallet-hF59IEhH.js → embedded-wallet-RbZRqVlP.js} +1 -1
  51. package/_assets/{emotion-styled.browser.esm-D23S089l.js → emotion-styled.browser.esm-h_auJPke.js} +1 -1
  52. package/_assets/{engine-CgRM_THA.js → engine-BxhOXYac.js} +1 -1
  53. package/_assets/{errors-Wm6SH4-v.js → errors-DFMf8rsi.js} +1 -1
  54. package/_assets/{estimate-l1-fee-DZHVdg7h.js → estimate-l1-fee-BRVjwAU9.js} +1 -1
  55. package/_assets/{execute-BPgoblAE.js → execute-CLnNbtEx.js} +2 -2
  56. package/_assets/{features-DYTS35jX.js → features-BaXXwf7C.js} +1 -1
  57. package/_assets/{fetchTokenMetadata-BxGNbM_2.js → fetchTokenMetadata-DfILnW1Z.js} +2 -2
  58. package/_assets/{field.styles-Bys6wE0V.js → field.styles-DhyHMuCv.js} +1 -1
  59. package/_assets/{get-ecosystem-wallet-info-xvSXu74j.js → get-ecosystem-wallet-info-BDylr3P5.js} +1 -1
  60. package/_assets/{getBalance-DLxh2RuD.js → getBalance-BMEo5rzT.js} +1 -1
  61. package/_assets/{getNFT-BOSh5H84.js → getNFT-DRPtbXuD.js} +1 -1
  62. package/_assets/{getNFT-K4qjxWNY.js → getNFT-DfgMefa1.js} +1 -1
  63. package/_assets/{getThemeProps-mxNIag6l.js → getThemeProps-DzmSMr6d.js} +1 -1
  64. package/_assets/{grid.styles-BaFKxOV8.js → grid.styles-BB_h06XI.js} +1 -1
  65. package/_assets/{hashTypedData-CCvvyerQ.js → hashTypedData-Bk8-lrpD.js} +1 -1
  66. package/_assets/{hashTypedData-Bje_1GNe.js → hashTypedData-CAnqj1ot.js} +1 -1
  67. package/_assets/{in-app-DBzemWmV.js → in-app-DqA-0trR.js} +1 -1
  68. package/_assets/{in-app-wallet-calls-CeM3dz7A.js → in-app-wallet-calls-BMxecDTD.js} +1 -1
  69. package/_assets/{index-CFUHl0Ma.js → index--9xDJi_N.js} +1 -1
  70. package/_assets/{index-BW-7rl1w.js → index-6x4qBvrl.js} +1 -1
  71. package/_assets/{index-D3a3O8EH.js → index-B0LQBX7D.js} +1 -1
  72. package/_assets/{index-MZdslMn6.js → index-B5ZWOI5H.js} +1 -1
  73. package/_assets/{index-Ypo9phAp.js → index-B73SXYzI.js} +2 -2
  74. package/_assets/{index-CJWQK5Lk.js → index-BDlT9zSc.js} +1 -1
  75. package/_assets/{index-DKr33OKQ.js → index-BFbJ5zYz.js} +1 -1
  76. package/_assets/{index-B4iL_Vxm.js → index-BGn8WCA2.js} +1 -1
  77. package/_assets/{index-D_9mpAb0.js → index-BLOLP73d.js} +2 -2
  78. package/_assets/{index-DFaB3PXW.js → index-BPRM84_k.js} +1 -1
  79. package/_assets/{index-BIXkfL0f.js → index-BS6-AqlH.js} +1 -1
  80. package/_assets/{index-DMSY746R.js → index-BV7OV0tm.js} +1 -1
  81. package/_assets/{index-D7A-L9p9.js → index-BZmuOqAg.js} +1 -1
  82. package/_assets/{index-COC826L7.js → index-BdU0memd.js} +1 -1
  83. package/_assets/{index-BCyVn8MQ.js → index-BdvG3vgW.js} +1 -1
  84. package/_assets/{index-BKSx9kmy.js → index-BfiJbiF8.js} +1 -1
  85. package/_assets/{index-cFnHRMx4.js → index-Bu99TL81.js} +2 -2
  86. package/_assets/{index-C_KycN_b.js → index-Bxk_1Isq.js} +1 -1
  87. package/_assets/{index-CW0DN1u5.js → index-C0J5eSm2.js} +1 -1
  88. package/_assets/{index-B1WnOG_n.js → index-C1RfshyX.js} +3 -3
  89. package/_assets/index-C3igEAQW.js +3343 -0
  90. package/_assets/{index-C8VruoUX.js → index-C6jSrZUP.js} +1 -1
  91. package/_assets/{index-CNwyt0TH.js → index-CECGziWF.js} +1 -1
  92. package/_assets/{index-Cj0IFSYI.js → index-CHfgeU_n.js} +1 -1
  93. package/_assets/{index-D1ncAmsg.js → index-CMS5DCUP.js} +1 -1
  94. package/_assets/{index-DRJlDsJB.js → index-CY7C2UYv.js} +1 -1
  95. package/_assets/{index-sofR0AzT.js → index-CYmzNUuE.js} +1 -1
  96. package/_assets/{index-C6jx_7vf.js → index-CiqgakIO.js} +1 -1
  97. package/_assets/{index-C1hTWDfF.js → index-CrxxzQ-o.js} +1 -1
  98. package/_assets/{index-D5drugU6.js → index-CukU3OXk.js} +1 -1
  99. package/_assets/{index-Cx-FPP2C.js → index-CykeWlmC.js} +1 -1
  100. package/_assets/{index-BT9bqwmo.js → index-CzTTtITz.js} +1 -1
  101. package/_assets/{index-BNbfWSl_.js → index-DAchiZy9.js} +3 -3
  102. package/_assets/{index-DZrXtOiH.js → index-DIxkUk_K.js} +1 -1
  103. package/_assets/{index-DvkKq-3d.js → index-DM5M5gc5.js} +1 -1
  104. package/_assets/{index-BY-2ttcm.js → index-DSrATsWq.js} +1 -1
  105. package/_assets/{index-vt25O9Am.js → index-DaKMz1tE.js} +3 -3
  106. package/_assets/{index-VpH-lUJq.js → index-DixjWy2z.js} +1 -1
  107. package/_assets/{index-CTSAk3HZ.js → index-DoqdJh90.js} +1 -1
  108. package/_assets/{index-Iqpx-phg.js → index-DvhgZ2cw.js} +1 -1
  109. package/_assets/{index-fzBQEY_W.js → index-Dx_Lg2Bd.js} +1 -1
  110. package/_assets/{index-DCdXL8QX.js → index-I8x4hauL.js} +1 -1
  111. package/_assets/{index-BwBZg-Cg.js → index-JXZ2CK3v.js} +1 -1
  112. package/_assets/{index-BhRssk62.js → index-K1n-BBnB.js} +1 -1
  113. package/_assets/{index-BgL4tnd6.js → index-Pk-ZBhMl.js} +1 -1
  114. package/_assets/{index-Cdnlri5M.js → index-ZRCuJPXW.js} +1 -1
  115. package/_assets/{index-B-PyHfEF.js → index-aQ3oi7mB.js} +1 -1
  116. package/_assets/{index-DGDemPnB.js → index-gDyyBNqa.js} +1 -1
  117. package/_assets/{index-TvUj9AoT.js → index-o1csInmg.js} +1 -1
  118. package/_assets/{index-WvEbTnHu.js → index-rUBrA0B0.js} +1 -1
  119. package/_assets/{index--BUBq145.js → index-z1pSRSEz.js} +1 -1
  120. package/_assets/{index-9pYsulOA.js → index-zChPbaAo.js} +1 -1
  121. package/_assets/{index.es-DuthVFnh.js → index.es-BuqKecQt.js} +1 -1
  122. package/_assets/{index.es-B9ErMvUj.js → index.es-C8naMbsL.js} +4 -4
  123. package/_assets/{index.es-rx-DH5wv.js → index.es-zVpc_Jfk.js} +1 -1
  124. package/_assets/{localBatchGatewayRequest-D_WhElUc.js → localBatchGatewayRequest-C32ohRlt.js} +1 -1
  125. package/_assets/{networks-CjrnWm_p.js → networks-vDLjYKcP.js} +1 -1
  126. package/_assets/{onramp-DTvBwKCe.js → onramp-B7T-_rpN.js} +1 -1
  127. package/_assets/{openzeppelin-C06zmVod.js → openzeppelin-HzCHwjWm.js} +1 -1
  128. package/_assets/{parseNft-CWL0AW1h.js → parseNft-CfK0bVHM.js} +2 -2
  129. package/_assets/{parseSignature-5VH_Alnl.js → parseSignature-DeiQBaVv.js} +1 -1
  130. package/_assets/{parseSignature-C5YgXtpR.js → parseSignature-bZvi-MCz.js} +3 -3
  131. package/_assets/{passkeys-DiZlNP-q.js → passkeys-BSt3L-Wp.js} +1 -1
  132. package/_assets/{pay-with-exchange-CNm1xvZ5.js → pay-with-exchange-m87yBZnk.js} +1 -1
  133. package/_assets/{qr-overlay-CpgjTugW.js → qr-overlay-DuWSgaZx.js} +1 -1
  134. package/_assets/{receive-CV4TgE-L.js → receive-B3FXEGXF.js} +1 -1
  135. package/_assets/{resolveImplementation-XYPJYD3T.js → resolveImplementation-CpW-99GK.js} +1 -1
  136. package/_assets/{rpc-tLuHrGBn.js → rpc-DAbjKP0j.js} +1 -1
  137. package/_assets/{secp256k1-CDI-iBc2.js → secp256k1-BQttSQKs.js} +1 -1
  138. package/_assets/{secp256k1-CYEZP9R3.js → secp256k1-DgIPDFge.js} +1 -1
  139. package/_assets/{secp256k1-CpiwnyMt.js → secp256k1-Dsyocgzf.js} +1 -1
  140. package/_assets/{send-batch-transaction-BfHXn227.js → send-batch-transaction-DohZEhWB.js} +1 -1
  141. package/_assets/{send-eip712-transaction-t0wYgXj7.js → send-eip712-transaction-DcJJeLCN.js} +2 -2
  142. package/_assets/{send-gasless-transaction-CgmsaSdY.js → send-gasless-transaction-Cn7wJ7fB.js} +2 -2
  143. package/_assets/{send-D5VuBzPD.js → send-lWFAna0k.js} +1 -1
  144. package/_assets/{send-transaction-CrLGC-De.js → send-transaction-B13qq_Ql.js} +2 -2
  145. package/_assets/{sendMetaTransaction-ef-RXWfu.js → sendMetaTransaction-CKo6PfMe.js} +1 -1
  146. package/_assets/{sendRawTransaction-pS6CHcTu.js → sendRawTransaction-DrdlTzO9.js} +3 -3
  147. package/_assets/{serializeTransaction-KCGr6qFd.js → serializeTransaction-CW2hixd6.js} +1 -1
  148. package/_assets/{session-proposal-sRmaUsXb.js → session-proposal-DYGugKsX.js} +1 -1
  149. package/_assets/{session-request-CfwKiBxF.js → session-request-thglP3qy.js} +2 -2
  150. package/_assets/{signing-DBbUwPle.js → signing-RUrxpKxl.js} +3 -3
  151. package/_assets/{socials-MOf37RiI.js → socials-Vp1xipb4.js} +1 -1
  152. package/_assets/{swaps-bmMgRWV4.js → swaps-gATnbUpo.js} +1 -1
  153. package/_assets/{thirdweb--zGmSCRq.js → thirdweb-D5kGBtDx.js} +3 -3
  154. package/_assets/{to-serializable-transaction-DjbT77eY.js → to-serializable-transaction-BU1SvqAL.js} +2 -2
  155. package/_assets/{trade-encoding-wpCgB2Av.js → trade-encoding-3zHfaY9t.js} +1 -1
  156. package/_assets/{transactionReceipt-CweRPSQa.js → transactionReceipt-BB1y9JP7.js} +1 -1
  157. package/_assets/{transactions-dtEdgAGt.js → transactions-pCrt6Jjn.js} +1 -1
  158. package/_assets/{useCreditPacks-CzOCruPU.js → useCreditPacks-C673G0mp.js} +1 -1
  159. package/_assets/{useImportable-rrKOGrr4.js → useImportable-DF1eCCB9.js} +1 -1
  160. package/_assets/{useInfiniteGrid-XDOQyPRq.js → useInfiniteGrid-DxWFUb-I.js} +1 -1
  161. package/_assets/{useTheme-DGv_oEh8.js → useTheme-IWgosMZc.js} +1 -1
  162. package/_assets/{verifyHash-CvfcirkG.js → verifyHash-Svm3Cpy-.js} +1 -1
  163. package/_assets/{w3m-modal-PufzUctO.js → w3m-modal-9XkSTk3b.js} +1 -1
  164. package/_assets/{w3m-modal-BGA4lQKq.js → w3m-modal-BliSnIOe.js} +1 -1
  165. package/_assets/{wait-for-tx-receipt-0VbbjxzA.js → wait-for-tx-receipt-DYHsT8LR.js} +1 -1
  166. package/_assets/{wallets-BopYfWq7.js → wallets-LuTSPwQx.js} +5 -5
  167. package/_assets/{web-connector-BSV6ourQ.js → web-connector-CvnkI1N_.js} +3 -3
  168. package/_assets/{writeContract-CCNcKbN2.js → writeContract-CWIGHnlf.js} +1 -1
  169. package/_assets/{zoraTestnet-DJdUGbFi.js → zoraTestnet-B0CyfonI.js} +1 -1
  170. package/index.html +11 -11
  171. package/package.json +2 -2
  172. package/_assets/ItemDetail-B2_NA3qK.js +0 -3324
  173. package/_assets/index-DaQaTpvn.js +0 -3315
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_assets/index-Iqpx-phg.js","_assets/react-DehiWSvs.js","_assets/index-DaQaTpvn.js","_assets/sentry-973sfbO9.js","_assets/dcl-schemas-Dr9BTjb7.js","_assets/ethers-CtNGBird.js","_assets/intl-CBcMB1D2.js","_assets/index-D-NhBWWr.css","_assets/useImportable-rrKOGrr4.js","_assets/buy-DGpUz8hz.js","_assets/authorizations-D7XuRQgn.js","_assets/sendMetaTransaction-ef-RXWfu.js","_assets/trade-encoding-wpCgB2Av.js","_assets/ManaPricingBanner.styles-C7faS-HZ.js","_assets/field.styles-Bys6wE0V.js"])))=>i.map(i=>d[i]);
2
- import{m as bt,bv as yt,s as h,t as s,q as vt,B as wt,l as jt,v as kt,d as c,o as $,b3 as It,I as j,bw as Z,bx as J,by as At,_ as $t,x as P,bz as Pt,b7 as z,av as Lt,bA as Tt,bB as H}from"./index-DaQaTpvn.js";import{r as y,e as Nt,j as e,L as et,a as Et}from"./react-DehiWSvs.js";import{u as Ct}from"./useImportable-rrKOGrr4.js";import{L as St}from"./LoadMore-TnqPM5W_.js";import{u as I}from"./useInfiniteGrid-XDOQyPRq.js";import{m as it}from"./mana-matic-C4e1sNO3.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./buy-DGpUz8hz.js";import"./authorizations-D7XuRQgn.js";import"./sendMetaTransaction-ef-RXWfu.js";import"./trade-encoding-wpCgB2Av.js";const Ft=15e3;function Mt(t,a){return t.txHash&&a.txHash?t.txHash===a.txHash:t.txHash||a.txHash?!1:t.status===a.status&&Math.abs(t.createdAt-a.createdAt)<=Ft}function Dt(t){const a=[...t].sort((i,d)=>d.createdAt-i.createdAt),n=[];for(const i of a){const d=n[n.length-1];d&&Mt(d[d.length-1],i)?d.push(i):n.push([i])}return n.map(i=>{var d;return{id:((d=i.find(r=>r.txHash))==null?void 0:d.txHash)??i[i.length-1].id,createdAt:Math.max(...i.map(r=>r.createdAt)),status:i.some(r=>r.status==="PENDING")?"PENDING":"SETTLED",totalCredits:i.reduce((r,u)=>r+u.credits,0),lines:i}})}function zt(t){return t.tradeId?`trade:${t.tradeId}`:t.contractAddress&&t.itemId?`item:${t.contractAddress.toLowerCase()}:${t.itemId}`:null}function Ht(t){const a=[],n=new Map;for(const i of t){const d=zt(i);if(!d){a.push({key:i.id,tradeId:null,contractAddress:i.contractAddress??null,itemId:i.itemId??null,quantity:1,credits:i.credits});continue}const r=n.get(d);if(r){r.quantity+=1,r.credits+=i.credits;continue}const u={key:d,tradeId:i.tradeId,contractAddress:i.contractAddress??null,itemId:i.itemId??null,quantity:1,credits:i.credits};n.set(d,u),a.push(u)}return a}function qt(t,a){return{id:t.id,contractAddress:t.contractAddress,tokenId:t.tokenId,itemId:t.itemId,counterparty:t.buyer,credits:a?bt(t.manaWei,a):null,manaWei:t.manaWei,createdAt:t.createdAt,txHash:t.txHash}}function Ot(t){const n=Dt(t.purchases.filter(o=>o.status!=="EXPIRED")).map(o=>({kind:"purchase",id:`purchase:${o.id}`,createdAt:o.createdAt,order:o})),i=t.sales.map(o=>{const p=qt(o,t.rate);return{kind:"sale",id:`sale:${p.id}`,createdAt:p.createdAt,sale:p}}),d=(t.creditOrders??[]).filter(o=>o.status!=="failed"&&o.status!=="abandoned").map(o=>({kind:"credit",id:`credit:${o.id}`,createdAt:o.createdAt,order:o})),r=new Set(t.purchases.filter(o=>o.txHash).map(o=>o.txHash.toLowerCase())),u=(t.manaPurchases??[]).filter(o=>!r.has(o.txHash.toLowerCase())).map(o=>({kind:"mana-purchase",id:`mana-purchase:${o.id}`,createdAt:o.createdAt,sale:o}));return[...n,...i,...d,...u].sort((o,p)=>p.createdAt-o.createdAt||(o.id<p.id?-1:1))}function Wt(t,a){return a==="all"?t:a==="sales"?t.filter(n=>n.kind==="sale"):t.filter(n=>n.kind==="purchase"||n.kind==="credit"||n.kind==="mana-purchase")}const at=t=>t.trim().toLowerCase();function Rt(t){const a=new Map;for(const n of t??[]){const i=at(n.txHash??"");if(!i)continue;const d=a.get(i);d?d.push(n):a.set(i,[n])}return a}function _t(t,a,n=Date.now()){const i=a.txHash?t.get(at(a.txHash)):void 0;if(!i||i.length===0)return{kind:"direct"};const d=i.length===1?Bt(i[0].netCents):null,r=i.filter(o=>!o.available&&o.availableAt>n);if(r.length===0)return{kind:"credited",credits:d};const u=r.reduce((o,p)=>Math.max(o,p.availableAt),0);return{kind:"pending",credits:d,availableAt:u}}function Bt(t){return yt(t)}const Gt="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/credits-product-vs4Q6u6l.svg",q=vt`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["_assets/index-DvhgZ2cw.js","_assets/react-DehiWSvs.js","_assets/index-C3igEAQW.js","_assets/sentry-973sfbO9.js","_assets/dcl-schemas-Dr9BTjb7.js","_assets/ethers-CtNGBird.js","_assets/intl-CBcMB1D2.js","_assets/index-D-NhBWWr.css","_assets/useImportable-DF1eCCB9.js","_assets/buy-CvpQJoW5.js","_assets/authorizations-C4greZZh.js","_assets/sendMetaTransaction-CKo6PfMe.js","_assets/trade-encoding-3zHfaY9t.js","_assets/ManaPricingBanner.styles-fmDpqtPl.js","_assets/field.styles-DhyHMuCv.js"])))=>i.map(i=>d[i]);
2
+ import{m as bt,bv as yt,s as h,t as s,q as vt,B as wt,l as jt,v as kt,d,o as $,b3 as It,I as j,bw as Z,bx as J,by as At,_ as $t,x as P,bz as Pt,b7 as z,av as Lt,bA as Tt,bB as H}from"./index-C3igEAQW.js";import{r as y,e as Nt,j as e,L as et,a as Et}from"./react-DehiWSvs.js";import{u as Ct}from"./useImportable-DF1eCCB9.js";import{L as St}from"./LoadMore-qdo6Ikhu.js";import{u as I}from"./useInfiniteGrid-DxWFUb-I.js";import{m as it}from"./mana-matic-C4e1sNO3.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./buy-CvpQJoW5.js";import"./authorizations-C4greZZh.js";import"./sendMetaTransaction-CKo6PfMe.js";import"./trade-encoding-3zHfaY9t.js";const Ft=15e3;function Mt(t,a){return t.txHash&&a.txHash?t.txHash===a.txHash:t.txHash||a.txHash?!1:t.status===a.status&&Math.abs(t.createdAt-a.createdAt)<=Ft}function Dt(t){const a=[...t].sort((i,c)=>c.createdAt-i.createdAt),n=[];for(const i of a){const c=n[n.length-1];c&&Mt(c[c.length-1],i)?c.push(i):n.push([i])}return n.map(i=>{var c;return{id:((c=i.find(r=>r.txHash))==null?void 0:c.txHash)??i[i.length-1].id,createdAt:Math.max(...i.map(r=>r.createdAt)),status:i.some(r=>r.status==="PENDING")?"PENDING":"SETTLED",totalCredits:i.reduce((r,u)=>r+u.credits,0),lines:i}})}function zt(t){return t.tradeId?`trade:${t.tradeId}`:t.contractAddress&&t.itemId?`item:${t.contractAddress.toLowerCase()}:${t.itemId}`:null}function Ht(t){const a=[],n=new Map;for(const i of t){const c=zt(i);if(!c){a.push({key:i.id,tradeId:null,contractAddress:i.contractAddress??null,itemId:i.itemId??null,quantity:1,credits:i.credits});continue}const r=n.get(c);if(r){r.quantity+=1,r.credits+=i.credits;continue}const u={key:c,tradeId:i.tradeId,contractAddress:i.contractAddress??null,itemId:i.itemId??null,quantity:1,credits:i.credits};n.set(c,u),a.push(u)}return a}function qt(t,a){return{id:t.id,contractAddress:t.contractAddress,tokenId:t.tokenId,itemId:t.itemId,counterparty:t.buyer,credits:a?bt(t.manaWei,a):null,manaWei:t.manaWei,createdAt:t.createdAt,txHash:t.txHash}}function Ot(t){const n=Dt(t.purchases.filter(o=>o.status!=="EXPIRED")).map(o=>({kind:"purchase",id:`purchase:${o.id}`,createdAt:o.createdAt,order:o})),i=t.sales.map(o=>{const p=qt(o,t.rate);return{kind:"sale",id:`sale:${p.id}`,createdAt:p.createdAt,sale:p}}),c=(t.creditOrders??[]).filter(o=>o.status!=="failed"&&o.status!=="abandoned").map(o=>({kind:"credit",id:`credit:${o.id}`,createdAt:o.createdAt,order:o})),r=new Set(t.purchases.filter(o=>o.txHash).map(o=>o.txHash.toLowerCase())),u=(t.manaPurchases??[]).filter(o=>!r.has(o.txHash.toLowerCase())).map(o=>({kind:"mana-purchase",id:`mana-purchase:${o.id}`,createdAt:o.createdAt,sale:o}));return[...n,...i,...c,...u].sort((o,p)=>p.createdAt-o.createdAt||(o.id<p.id?-1:1))}function Wt(t,a){return a==="all"?t:a==="sales"?t.filter(n=>n.kind==="sale"):t.filter(n=>n.kind==="purchase"||n.kind==="credit"||n.kind==="mana-purchase")}const at=t=>t.trim().toLowerCase();function Rt(t){const a=new Map;for(const n of t??[]){const i=at(n.txHash??"");if(!i)continue;const c=a.get(i);c?c.push(n):a.set(i,[n])}return a}function _t(t,a,n=Date.now()){const i=a.txHash?t.get(at(a.txHash)):void 0;if(!i||i.length===0)return{kind:"direct"};const c=i.length===1?Bt(i[0].netCents):null,r=i.filter(o=>!o.available&&o.availableAt>n);if(r.length===0)return{kind:"credited",credits:c};const u=r.reduce((o,p)=>Math.max(o,p.availableAt),0);return{kind:"pending",credits:c,availableAt:u}}function Bt(t){return yt(t)}const Gt="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/credits-product-vs4Q6u6l.svg",q=vt`
3
3
  0% { background-position: 200% 0; }
4
4
  100% { background-position: -200% 0; }
5
5
  `,Ut=h.section`
@@ -354,4 +354,4 @@ import{m as bt,bv as yt,s as h,t as s,q as vt,B as wt,l as jt,v as kt,d as c,o a
354
354
  margin: 6px 0 0;
355
355
  `,ae=h(wt)`
356
356
  margin-top: 12px;
357
- `,K=M.withComponent(et),se=y.lazy(()=>$t(()=>import("./index-Iqpx-phg.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(t=>({default:t.ImportListings}))),A=24,ne=["all","purchases","sales"],D="migrate";function w(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function dt(t){return t.length>10?`${t.slice(0,6)}…${t.slice(-4)}`:t}function ct(t){const a=Number(t)/1e18;return Number.isFinite(a)?a.toLocaleString("en",{maximumFractionDigits:2}):"0"}function lt({children:t}){const a=y.useRef(null),[n,i]=y.useState(null),d=()=>{var u;const r=(u=a.current)==null?void 0:u.getBoundingClientRect();r&&i({top:r.bottom+8,left:r.left+r.width/2})};return e.jsxs(te,{ref:a,tabIndex:0,onMouseEnter:d,onMouseLeave:()=>i(null),onFocus:d,onBlur:()=>i(null),children:[t,n?Et.createPortal(e.jsx(ee,{style:{top:n.top,left:n.left},role:"tooltip",children:c("activity.polygonMana")}),document.body):null]})}function re({item:t}){const a=!!t.contractAddress&&!!t.itemId,n=!!t.tradeId||a,{data:i,isLoading:d}=$({queryKey:["order-line-display",t.tradeId,t.contractAddress,t.itemId],queryFn:()=>t.tradeId?Tt(t.tradeId):H(t.contractAddress,{itemId:t.itemId}),enabled:n,staleTime:5*6e4}),r=n&&d,u=(i==null?void 0:i.name)??c("activity.itemFallback"),o=(i==null?void 0:i.thumbnail)??"",p=z({contractAddress:i==null?void 0:i.contractAddress,tokenId:i==null?void 0:i.tokenId,itemId:i==null?void 0:i.itemId})??void 0,x=e.jsxs(e.Fragment,{children:[r?e.jsx(R,{}):e.jsx(W,{children:o?e.jsx("img",{src:o,alt:u}):e.jsx(j,{name:"cart",size:20})}),e.jsxs(_,{children:[r?e.jsx(G,{}):e.jsx(B,{title:u,children:u}),t.quantity>1?e.jsx(U,{children:c("activity.quantity",{count:t.quantity})}):null]}),e.jsxs(ie,{children:[e.jsx(P,{className:"ccy-mark"})," ",t.credits]})]});return p?e.jsx(K,{to:p,"data-link":"true",children:x}):e.jsx(M,{children:x})}function oe({order:t}){const a=Ht(t.lines),n=a.reduce((i,d)=>i+d.quantity,0);return e.jsxs(L,{"data-testid":"purchase-order",children:[e.jsxs(T,{children:[e.jsxs(N,{children:[e.jsx(E,{children:w(t.createdAt)}),e.jsxs(C,{children:[c("activity.purchaseLabel")," · ",c("activity.itemCount",{count:n})]})]}),e.jsxs(S,{children:[e.jsx(F,{"data-status":t.status,children:t.status==="PENDING"?c("activity.processing"):c("activity.completed")}),e.jsxs(v,{children:[e.jsx(P,{className:"ccy-mark"})," ",t.totalCredits]})]})]}),e.jsx(O,{children:a.map(i=>e.jsx(re,{item:i},i.key))})]})}function de({sale:t}){const{data:a,isLoading:n}=$({queryKey:["asset-display",t.contractAddress,t.tokenId,t.itemId],queryFn:()=>H(t.contractAddress,{tokenId:t.tokenId,itemId:t.itemId}),enabled:!!t.contractAddress,staleTime:3e5}),i=(a==null?void 0:a.name)??c("activity.itemFallback"),d=(a==null?void 0:a.thumbnail)??"",r=z({contractAddress:t.contractAddress,tokenId:t.tokenId,itemId:t.itemId})??void 0,u=e.jsxs(e.Fragment,{children:[n?e.jsx(R,{}):e.jsx(W,{children:d?e.jsx("img",{src:d,alt:i}):e.jsx(j,{name:"offer",size:20})}),e.jsxs(_,{children:[n?e.jsx(G,{}):e.jsx(B,{title:i,children:i}),e.jsx(U,{children:c("activity.boughtFrom",{account:dt(t.seller)})})]})]});return e.jsxs(L,{"data-testid":"activity-mana-purchase",children:[e.jsxs(T,{children:[e.jsxs(N,{children:[e.jsx(E,{children:w(t.createdAt)}),e.jsx(C,{children:c("activity.paidWithMana")})]}),e.jsxs(S,{children:[e.jsx(F,{"data-status":"SETTLED",children:c("activity.completed")}),e.jsxs(v,{children:[ct(t.manaWei)," ",e.jsx(lt,{children:e.jsx(nt,{src:it,alt:"MANA"})})]})]})]}),e.jsx(O,{children:r?e.jsx(K,{to:r,"data-link":"true",children:u}):e.jsx(M,{children:u})})]})}function ce({sale:t,payout:a}){const{data:n,isLoading:i}=$({queryKey:["asset-display",t.contractAddress,t.tokenId,t.itemId],queryFn:()=>H(t.contractAddress,{tokenId:t.tokenId,itemId:t.itemId}),enabled:!!t.contractAddress,staleTime:3e5}),d=(n==null?void 0:n.name)??c("activity.itemFallback"),r=(n==null?void 0:n.thumbnail)??"",u=z({contractAddress:t.contractAddress,tokenId:t.tokenId,itemId:t.itemId})??void 0,o=e.jsxs(e.Fragment,{children:[i?e.jsx(R,{}):e.jsx(W,{children:r?e.jsx("img",{src:r,alt:d}):e.jsx(j,{name:"offer",size:20})}),e.jsxs(_,{children:[i?e.jsx(G,{}):e.jsx(B,{title:d,children:d}),e.jsxs(U,{children:[c("activity.soldTo",{account:dt(t.counterparty)}),a.kind==="pending"?` · ${c("activity.payoutPendingOn",{date:w(a.availableAt)})}`:""]})]})]});return e.jsxs(L,{"data-testid":"activity-sale",children:[e.jsxs(T,{children:[e.jsxs(N,{children:[e.jsx(E,{children:w(t.createdAt)}),e.jsx(C,{children:c("activity.saleLabel")})]}),e.jsxs(S,{children:[e.jsx(F,{"data-status":a.kind==="pending"?"PENDING":"SOLD",children:a.kind==="pending"?c("activity.payoutPending"):c("activity.sold")}),a.kind==="direct"?e.jsxs(v,{"data-kind":"income",children:["+",ct(t.manaWei)," ",e.jsx(lt,{children:e.jsx(nt,{src:it,alt:"MANA"})})]}):a.credits!==null?e.jsxs(v,{"data-kind":"income",children:[e.jsx(P,{className:"ccy-mark"})," +",Lt(a.credits)]}):e.jsx(v,{"data-kind":"income",children:c("activity.payoutCredited")})]})]}),e.jsx(O,{children:u?e.jsx(K,{to:u,"data-link":"true",children:o}):e.jsx(M,{children:o})})]})}function le({order:t}){const a=`$${(t.usdCents/100).toFixed(2)}`,n=Pt(t.status),i=n==="SETTLED"?c("activity.completed"):n==="FAILED"?c("activity.failed"):c("activity.processing");return e.jsx(L,{"data-testid":"credit-order",children:e.jsxs(T,{children:[e.jsx(Yt,{children:e.jsx("img",{src:Gt,alt:"","aria-hidden":!0})}),e.jsxs(N,{children:[e.jsx(E,{children:w(t.createdAt)}),e.jsxs(C,{children:[c("activity.creditPurchaseLabel")," · ",c("activity.creditPaid",{usd:a})]})]}),e.jsxs(S,{children:[e.jsx(F,{"data-status":n,children:i}),e.jsxs(v,{"data-kind":"income",children:["+",e.jsx(P,{className:"ccy-mark"})," ",t.credits]})]})]})})}function he({filter:t}){const a={all:{icon:"clock",title:c("activity.emptyAllTitle"),body:c("activity.emptyAllBody")},purchases:{icon:"cart",title:c("activity.emptyPurchasesTitle"),body:c("activity.emptyPurchasesBody")},sales:{icon:"offer",title:c("activity.emptySalesTitle"),body:c("activity.emptySalesBody")}}[t];return e.jsxs(rt,{children:[e.jsx(j,{name:a.icon,size:40,color:s.colors.muted2}),e.jsx(ot,{children:a.title}),e.jsx("p",{className:"muted",children:a.body}),t!=="sales"?e.jsx(ae,{as:et,to:"/items",variant:"purple",children:c("notFound.cta")}):null]})}function $e(){const{session:t}=jt(),[a,n]=y.useState("all"),[i,d]=Nt(),r=i.get("view")===D;kt({title:r?c("seo.import.title"):c("nav.activity"),noindex:!0});const{count:u}=Ct(),o=u!==void 0&&(u>0||r),p=!!t&&!r&&a!=="sales",x=!!t&&!r&&a!=="purchases",m=I(["purchases",t==null?void 0:t.address],l=>At(t.address,t.identity,{first:A,skip:l}),{enabled:p}),g=I(["sales",t==null?void 0:t.address],l=>Z(t.address,{role:"seller",first:A,skip:l}),{enabled:x}),f=I(["credit-orders",t==null?void 0:t.address],l=>J(t.address,t.identity,{first:A,skip:l}),{enabled:p}),b=I(["mana-purchases",t==null?void 0:t.address],l=>Z(t.address,{role:"buyer",first:A,skip:l}),{enabled:p}),{data:V}=$({queryKey:["sale-payouts",t==null?void 0:t.address],queryFn:()=>J(t.address,t.identity,{first:200}).then(l=>l.payouts),enabled:x,staleTime:6e4}),ht=y.useMemo(()=>Rt(V),[V]),{data:ut}=It(x);if(!t)return e.jsxs(rt,{children:[e.jsx(j,{name:"clock",size:40,color:s.colors.muted2}),e.jsx(ot,{children:c("activity.signInTitle")}),e.jsx("p",{className:"muted",children:c("activity.signInBody")})]});const Q=Wt(Ot({purchases:p?m.items:[],sales:x?g.items:[],creditOrders:p?f.items:[],manaPurchases:p?b.items:[],rate:ut}),a),pt=p&&(m.isLoading||f.isLoading||b.isLoading)||x&&g.isLoading,X=p&&(m.isFetchingNextPage||f.isFetchingNextPage||b.isFetchingNextPage)||x&&g.isFetchingNextPage,xt=p&&(m.hasNextPage||f.hasNextPage||b.hasNextPage)||x&&g.hasNextPage;function mt(){p&&m.hasNextPage&&m.fetchNextPage(),p&&f.hasNextPage&&f.fetchNextPage(),p&&b.hasNextPage&&b.fetchNextPage(),x&&g.hasNextPage&&g.fetchNextPage()}function gt(l){if(n(l),!r)return;const k=new URLSearchParams(i);k.delete("view"),d(k,{replace:!0})}function ft(){const l=new URLSearchParams(i);l.set("view",D),d(l,{replace:!0})}return e.jsxs(Ut,{"data-view":r?D:"feed",children:[e.jsx(Kt,{children:e.jsx(Vt,{children:c("nav.activity")})}),e.jsxs(Qt,{role:"tablist","aria-label":c("nav.activity"),children:[ne.map(l=>e.jsx(st,{type:"button",role:"tab","aria-selected":!r&&a===l,"data-active":!r&&a===l,"data-testid":`activity-filter-${l}`,onClick:()=>gt(l),children:c(`activity.filter.${l}`)},l)),o?e.jsxs(Xt,{type:"button",role:"tab","aria-selected":r,"data-active":r,"data-testid":"activity-filter-migrate","aria-label":u?c("activity.migrate.chipAria",{count:u}):void 0,onClick:ft,children:[c("activity.migrate.chip"),u?e.jsx(Zt,{"data-testid":"activity-migrate-count","aria-hidden":!0,children:u}):null]}):null]}),r?e.jsx(y.Suspense,{fallback:e.jsx(Jt,{"aria-busy":"true"}),children:e.jsx(se,{})}):pt?e.jsx(Y,{children:Array.from({length:5}).map((l,k)=>e.jsx(tt,{},k))}):Q.length===0?e.jsx(he,{filter:a}):e.jsxs(e.Fragment,{children:[e.jsxs(Y,{children:[Q.map(l=>l.kind==="purchase"?e.jsx(oe,{order:l.order},l.id):l.kind==="credit"?e.jsx(le,{order:l.order},l.id):l.kind==="mana-purchase"?e.jsx(de,{sale:l.sale},l.id):e.jsx(ce,{sale:l.sale,payout:_t(ht,l.sale)},l.id)),X?e.jsx(tt,{}):null]}),e.jsx(St,{hasNextPage:xt,isFetching:X,onLoadMore:mt})]})]})}export{$e as Activity};
357
+ `,K=M.withComponent(et),se=y.lazy(()=>$t(()=>import("./index-DvhgZ2cw.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14])).then(t=>({default:t.ImportListings}))),A=24,ne=["all","purchases","sales"],D="migrate";function w(t){try{return new Date(t).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function ct(t){return t.length>10?`${t.slice(0,6)}…${t.slice(-4)}`:t}function dt(t){const a=Number(t)/1e18;return Number.isFinite(a)?a.toLocaleString("en",{maximumFractionDigits:2}):"0"}function lt({children:t}){const a=y.useRef(null),[n,i]=y.useState(null),c=()=>{var u;const r=(u=a.current)==null?void 0:u.getBoundingClientRect();r&&i({top:r.bottom+8,left:r.left+r.width/2})};return e.jsxs(te,{ref:a,tabIndex:0,onMouseEnter:c,onMouseLeave:()=>i(null),onFocus:c,onBlur:()=>i(null),children:[t,n?Et.createPortal(e.jsx(ee,{style:{top:n.top,left:n.left},role:"tooltip",children:d("activity.polygonMana")}),document.body):null]})}function re({item:t}){const a=!!t.contractAddress&&!!t.itemId,n=!!t.tradeId||a,{data:i,isLoading:c}=$({queryKey:["order-line-display",t.tradeId,t.contractAddress,t.itemId],queryFn:()=>t.tradeId?Tt(t.tradeId):H(t.contractAddress,{itemId:t.itemId}),enabled:n,staleTime:5*6e4}),r=n&&c,u=(i==null?void 0:i.name)??d("activity.itemFallback"),o=(i==null?void 0:i.thumbnail)??"",p=z({contractAddress:i==null?void 0:i.contractAddress,tokenId:i==null?void 0:i.tokenId,itemId:i==null?void 0:i.itemId})??void 0,x=e.jsxs(e.Fragment,{children:[r?e.jsx(R,{}):e.jsx(W,{children:o?e.jsx("img",{src:o,alt:u}):e.jsx(j,{name:"cart",size:20})}),e.jsxs(_,{children:[r?e.jsx(G,{}):e.jsx(B,{title:u,children:u}),t.quantity>1?e.jsx(U,{children:d("activity.quantity",{count:t.quantity})}):null]}),e.jsxs(ie,{children:[e.jsx(P,{className:"ccy-mark"})," ",t.credits]})]});return p?e.jsx(K,{to:p,"data-link":"true",children:x}):e.jsx(M,{children:x})}function oe({order:t}){const a=Ht(t.lines),n=a.reduce((i,c)=>i+c.quantity,0);return e.jsxs(L,{"data-testid":"purchase-order",children:[e.jsxs(T,{children:[e.jsxs(N,{children:[e.jsx(E,{children:w(t.createdAt)}),e.jsxs(C,{children:[d("activity.purchaseLabel")," · ",d("activity.itemCount",{count:n})]})]}),e.jsxs(S,{children:[e.jsx(F,{"data-status":t.status,children:t.status==="PENDING"?d("activity.processing"):d("activity.completed")}),e.jsxs(v,{children:[e.jsx(P,{className:"ccy-mark"})," ",t.totalCredits]})]})]}),e.jsx(O,{children:a.map(i=>e.jsx(re,{item:i},i.key))})]})}function ce({sale:t}){const{data:a,isLoading:n}=$({queryKey:["asset-display",t.contractAddress,t.tokenId,t.itemId],queryFn:()=>H(t.contractAddress,{tokenId:t.tokenId,itemId:t.itemId}),enabled:!!t.contractAddress,staleTime:3e5}),i=(a==null?void 0:a.name)??d("activity.itemFallback"),c=(a==null?void 0:a.thumbnail)??"",r=z({contractAddress:t.contractAddress,tokenId:t.tokenId,itemId:t.itemId})??void 0,u=e.jsxs(e.Fragment,{children:[n?e.jsx(R,{}):e.jsx(W,{children:c?e.jsx("img",{src:c,alt:i}):e.jsx(j,{name:"offer",size:20})}),e.jsxs(_,{children:[n?e.jsx(G,{}):e.jsx(B,{title:i,children:i}),e.jsx(U,{children:d("activity.boughtFrom",{account:ct(t.seller)})})]})]});return e.jsxs(L,{"data-testid":"activity-mana-purchase",children:[e.jsxs(T,{children:[e.jsxs(N,{children:[e.jsx(E,{children:w(t.createdAt)}),e.jsx(C,{children:d("activity.paidWithMana")})]}),e.jsxs(S,{children:[e.jsx(F,{"data-status":"SETTLED",children:d("activity.completed")}),e.jsxs(v,{children:[dt(t.manaWei)," ",e.jsx(lt,{children:e.jsx(nt,{src:it,alt:"MANA"})})]})]})]}),e.jsx(O,{children:r?e.jsx(K,{to:r,"data-link":"true",children:u}):e.jsx(M,{children:u})})]})}function de({sale:t,payout:a}){const{data:n,isLoading:i}=$({queryKey:["asset-display",t.contractAddress,t.tokenId,t.itemId],queryFn:()=>H(t.contractAddress,{tokenId:t.tokenId,itemId:t.itemId}),enabled:!!t.contractAddress,staleTime:3e5}),c=(n==null?void 0:n.name)??d("activity.itemFallback"),r=(n==null?void 0:n.thumbnail)??"",u=z({contractAddress:t.contractAddress,tokenId:t.tokenId,itemId:t.itemId})??void 0,o=e.jsxs(e.Fragment,{children:[i?e.jsx(R,{}):e.jsx(W,{children:r?e.jsx("img",{src:r,alt:c}):e.jsx(j,{name:"offer",size:20})}),e.jsxs(_,{children:[i?e.jsx(G,{}):e.jsx(B,{title:c,children:c}),e.jsxs(U,{children:[d("activity.soldTo",{account:ct(t.counterparty)}),a.kind==="pending"?` · ${d("activity.payoutPendingOn",{date:w(a.availableAt)})}`:""]})]})]});return e.jsxs(L,{"data-testid":"activity-sale",children:[e.jsxs(T,{children:[e.jsxs(N,{children:[e.jsx(E,{children:w(t.createdAt)}),e.jsx(C,{children:d("activity.saleLabel")})]}),e.jsxs(S,{children:[e.jsx(F,{"data-status":a.kind==="pending"?"PENDING":"SOLD",children:a.kind==="pending"?d("activity.payoutPending"):d("activity.sold")}),a.kind==="direct"?e.jsxs(v,{"data-kind":"income",children:["+",dt(t.manaWei)," ",e.jsx(lt,{children:e.jsx(nt,{src:it,alt:"MANA"})})]}):a.credits!==null?e.jsxs(v,{"data-kind":"income",children:[e.jsx(P,{className:"ccy-mark"})," +",Lt(a.credits)]}):e.jsx(v,{"data-kind":"income",children:d("activity.payoutCredited")})]})]}),e.jsx(O,{children:u?e.jsx(K,{to:u,"data-link":"true",children:o}):e.jsx(M,{children:o})})]})}function le({order:t}){const a=`$${(t.usdCents/100).toFixed(2)}`,n=Pt(t.status),i=n==="SETTLED"?d("activity.completed"):n==="FAILED"?d("activity.failed"):d("activity.processing");return e.jsx(L,{"data-testid":"credit-order",children:e.jsxs(T,{children:[e.jsx(Yt,{children:e.jsx("img",{src:Gt,alt:"","aria-hidden":!0})}),e.jsxs(N,{children:[e.jsx(E,{children:w(t.createdAt)}),e.jsxs(C,{children:[d("activity.creditPurchaseLabel")," · ",d("activity.creditPaid",{usd:a})]})]}),e.jsxs(S,{children:[e.jsx(F,{"data-status":n,children:i}),e.jsxs(v,{"data-kind":"income",children:["+",e.jsx(P,{className:"ccy-mark"})," ",t.credits]})]})]})})}function he({filter:t}){const a={all:{icon:"clock",title:d("activity.emptyAllTitle"),body:d("activity.emptyAllBody")},purchases:{icon:"cart",title:d("activity.emptyPurchasesTitle"),body:d("activity.emptyPurchasesBody")},sales:{icon:"offer",title:d("activity.emptySalesTitle"),body:d("activity.emptySalesBody")}}[t];return e.jsxs(rt,{children:[e.jsx(j,{name:a.icon,size:40,color:s.colors.muted2}),e.jsx(ot,{children:a.title}),e.jsx("p",{className:"muted",children:a.body}),t!=="sales"?e.jsx(ae,{as:et,to:"/items",variant:"purple",children:d("notFound.cta")}):null]})}function $e(){const{session:t}=jt(),[a,n]=y.useState("all"),[i,c]=Nt(),r=i.get("view")===D;kt({title:r?d("seo.import.title"):d("nav.activity"),noindex:!0});const{count:u}=Ct(),o=u!==void 0&&(u>0||r),p=!!t&&!r&&a!=="sales",x=!!t&&!r&&a!=="purchases",m=I(["purchases",t==null?void 0:t.address],l=>At(t.address,t.identity,{first:A,skip:l}),{enabled:p}),g=I(["sales",t==null?void 0:t.address],l=>Z(t.address,{role:"seller",first:A,skip:l}),{enabled:x}),f=I(["credit-orders",t==null?void 0:t.address],l=>J(t.address,t.identity,{first:A,skip:l}),{enabled:p}),b=I(["mana-purchases",t==null?void 0:t.address],l=>Z(t.address,{role:"buyer",first:A,skip:l}),{enabled:p}),{data:V}=$({queryKey:["sale-payouts",t==null?void 0:t.address],queryFn:()=>J(t.address,t.identity,{first:200}).then(l=>l.payouts),enabled:x,staleTime:6e4}),ht=y.useMemo(()=>Rt(V),[V]),{data:ut}=It(x);if(!t)return e.jsxs(rt,{children:[e.jsx(j,{name:"clock",size:40,color:s.colors.muted2}),e.jsx(ot,{children:d("activity.signInTitle")}),e.jsx("p",{className:"muted",children:d("activity.signInBody")})]});const Q=Wt(Ot({purchases:p?m.items:[],sales:x?g.items:[],creditOrders:p?f.items:[],manaPurchases:p?b.items:[],rate:ut}),a),pt=p&&(m.isLoading||f.isLoading||b.isLoading)||x&&g.isLoading,X=p&&(m.isFetchingNextPage||f.isFetchingNextPage||b.isFetchingNextPage)||x&&g.isFetchingNextPage,xt=p&&(m.hasNextPage||f.hasNextPage||b.hasNextPage)||x&&g.hasNextPage;function mt(){p&&m.hasNextPage&&m.fetchNextPage(),p&&f.hasNextPage&&f.fetchNextPage(),p&&b.hasNextPage&&b.fetchNextPage(),x&&g.hasNextPage&&g.fetchNextPage()}function gt(l){if(n(l),!r)return;const k=new URLSearchParams(i);k.delete("view"),c(k,{replace:!0})}function ft(){const l=new URLSearchParams(i);l.set("view",D),c(l,{replace:!0})}return e.jsxs(Ut,{"data-view":r?D:"feed",children:[e.jsx(Kt,{children:e.jsx(Vt,{children:d("nav.activity")})}),e.jsxs(Qt,{role:"tablist","aria-label":d("nav.activity"),children:[ne.map(l=>e.jsx(st,{type:"button",role:"tab","aria-selected":!r&&a===l,"data-active":!r&&a===l,"data-testid":`activity-filter-${l}`,onClick:()=>gt(l),children:d(`activity.filter.${l}`)},l)),o?e.jsxs(Xt,{type:"button",role:"tab","aria-selected":r,"data-active":r,"data-testid":"activity-filter-migrate","aria-label":u?d("activity.migrate.chipAria",{count:u}):void 0,onClick:ft,children:[d("activity.migrate.chip"),u?e.jsx(Zt,{"data-testid":"activity-migrate-count","aria-hidden":!0,children:u}):null]}):null]}),r?e.jsx(y.Suspense,{fallback:e.jsx(Jt,{"aria-busy":"true"}),children:e.jsx(se,{})}):pt?e.jsx(Y,{children:Array.from({length:5}).map((l,k)=>e.jsx(tt,{},k))}):Q.length===0?e.jsx(he,{filter:a}):e.jsxs(e.Fragment,{children:[e.jsxs(Y,{children:[Q.map(l=>l.kind==="purchase"?e.jsx(oe,{order:l.order},l.id):l.kind==="credit"?e.jsx(le,{order:l.order},l.id):l.kind==="mana-purchase"?e.jsx(ce,{sale:l.sale},l.id):e.jsx(de,{sale:l.sale,payout:_t(ht,l.sale)},l.id)),X?e.jsx(tt,{}):null]}),e.jsx(St,{hasNextPage:xt,isFetching:X,onLoadMore:mt})]})]})}export{$e as Activity};
@@ -1,4 +1,4 @@
1
- import{r as l,j as v}from"./react-DehiWSvs.js";import{s as u}from"./index-DaQaTpvn.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const S="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/custom-welcome-background-BxlFQma9.webp",b="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/DCL_LogoPattern-BryBPc3d.png",U=`
1
+ import{r as l,j as v}from"./react-DehiWSvs.js";import{s as u}from"./index-C3igEAQW.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const S="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/custom-welcome-background-BxlFQma9.webp",b="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/DCL_LogoPattern-BryBPc3d.png",U=`
2
2
  attribute vec2 a_position;
3
3
  varying vec2 v_uv;
4
4
  void main() {
@@ -94,4 +94,4 @@ void main() {
94
94
  inset: 0;
95
95
  width: 100%;
96
96
  height: 100%;
97
- `;function G(){const t=l.useRef(null),n=l.useRef(0);return l.useEffect(()=>{var x;const r=t.current;if(!r||(x=window.matchMedia)!=null&&x.call(window,"(prefers-reduced-motion: reduce)").matches)return;const e=r.getContext("webgl",{alpha:!1,antialias:!1});if(!e)return;const o=p(e,e.VERTEX_SHADER,U),i=p(e,e.FRAGMENT_SHADER,P);if(!o||!i){o&&e.deleteShader(o),i&&e.deleteShader(i);return}const a=D(e,o,i);if(!a){e.deleteShader(o),e.deleteShader(i);return}const d=e.getAttribLocation(a,"a_position"),R=e.getUniformLocation(a,"u_time"),_=e.getUniformLocation(a,"u_resolution"),y=e.getUniformLocation(a,"u_overlayTex"),s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);let m=!1;const f=L(e,b,()=>m),w=()=>{const c=window.devicePixelRatio||1,E=r.clientWidth*c,g=r.clientHeight*c;(r.width!==E||r.height!==g)&&(r.width=E,r.height=g)},A=performance.now()/1e3,h=()=>{w(),e.viewport(0,0,r.width,r.height),e.useProgram(a),e.uniform1f(R,performance.now()/1e3-A),e.uniform2f(_,r.width,r.height),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,f),e.uniform1i(y,0),e.enableVertexAttribArray(d),e.bindBuffer(e.ARRAY_BUFFER,s),e.vertexAttribPointer(d,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLES,0,6),n.current=requestAnimationFrame(h)},T=c=>{c.preventDefault(),cancelAnimationFrame(n.current),r.style.opacity="0"};return r.addEventListener("webglcontextlost",T,!1),n.current=requestAnimationFrame(h),()=>{m=!0,cancelAnimationFrame(n.current),r.removeEventListener("webglcontextlost",T),e.deleteProgram(a),e.deleteShader(o),e.deleteShader(i),e.deleteBuffer(s),e.deleteTexture(f)}},[]),v.jsxs(B,{"aria-hidden":!0,children:[v.jsx(F,{style:{backgroundImage:`url(${S})`}}),v.jsx(I,{ref:t})]})}export{G as default};
97
+ `;function G(){const t=l.useRef(null),n=l.useRef(0);return l.useEffect(()=>{var x;const r=t.current;if(!r||(x=window.matchMedia)!=null&&x.call(window,"(prefers-reduced-motion: reduce)").matches)return;const e=r.getContext("webgl",{alpha:!1,antialias:!1});if(!e)return;const o=p(e,e.VERTEX_SHADER,U),i=p(e,e.FRAGMENT_SHADER,P);if(!o||!i){o&&e.deleteShader(o),i&&e.deleteShader(i);return}const a=D(e,o,i);if(!a){e.deleteShader(o),e.deleteShader(i);return}const m=e.getAttribLocation(a,"a_position"),R=e.getUniformLocation(a,"u_time"),_=e.getUniformLocation(a,"u_resolution"),y=e.getUniformLocation(a,"u_overlayTex"),s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);let d=!1;const f=L(e,b,()=>d),w=()=>{const c=window.devicePixelRatio||1,E=r.clientWidth*c,g=r.clientHeight*c;(r.width!==E||r.height!==g)&&(r.width=E,r.height=g)},A=performance.now()/1e3,h=()=>{w(),e.viewport(0,0,r.width,r.height),e.useProgram(a),e.uniform1f(R,performance.now()/1e3-A),e.uniform2f(_,r.width,r.height),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,f),e.uniform1i(y,0),e.enableVertexAttribArray(m),e.bindBuffer(e.ARRAY_BUFFER,s),e.vertexAttribPointer(m,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLES,0,6),n.current=requestAnimationFrame(h)},T=c=>{c.preventDefault(),cancelAnimationFrame(n.current),r.style.opacity="0"};return r.addEventListener("webglcontextlost",T,!1),n.current=requestAnimationFrame(h),()=>{d=!0,cancelAnimationFrame(n.current),r.removeEventListener("webglcontextlost",T),e.deleteProgram(a),e.deleteShader(o),e.deleteShader(i),e.deleteBuffer(s),e.deleteTexture(f)}},[]),v.jsxs(B,{"aria-hidden":!0,children:[v.jsx(F,{style:{backgroundImage:`url(${S})`}}),v.jsx(I,{ref:t})]})}export{G as default};
@@ -1,4 +1,4 @@
1
- import{d as Le,r as u,j as e,e as et}from"./react-DehiWSvs.js";import{c as L,k as tt,bc as nt,bd as st,aq as ot,b as rt,s,t,l as Ue,b1 as it,y as at,av as be,d as n,w as lt,I as R,x as P,bK as se,b0 as ct,U as ee,bg as dt,bf as pt,v as He,b3 as Oe,m as Ge,n as ht,ae as xt,ag as Ie,ah as V,ax as ft,bH as mt}from"./index-DaQaTpvn.js";import{g as ut,h as gt,i as bt,j as yt,k as wt,C as jt,l as vt,o as $t,m as Ct,n as kt,M as St,u as Et,E as Rt,v as _t,p as Tt,q as zt,r as It,s as At,t as Nt}from"./Assets.styles-ZM8Q2cFA.js";import{S as Ae,R as Pt,F as Mt,e as Wt}from"./categories-BQKh49D5.js";import{L as Bt}from"./LoadMore-TnqPM5W_.js";import{u as Ft}from"./useInfiniteGrid-XDOQyPRq.js";import{E as Lt}from"./ErrorNotice-CfA5EQ3B.js";import{d as Ut}from"./dcl-schemas-Dr9BTjb7.js";import{s as Ht,G as Ot,w as Gt,S as Dt}from"./buy-gasless-Bl-OulBV.js";import{s as qt}from"./buy-DGpUz8hz.js";import{j as Vt}from"./trade-encoding-wpCgB2Av.js";import{f as Kt}from"./errors-Wm6SH4-v.js";import{J as Zt,C as Jt,B as ye}from"./ethers-CtNGBird.js";import{n as Qt}from"./Tooltip-ySlzdfvH.js";import{G as Xt}from"./grid.styles-BaFKxOV8.js";import"./sentry-973sfbO9.js";import"./intl-CBcMB1D2.js";import"./authorizations-D7XuRQgn.js";import"./sendMetaTransaction-ef-RXWfu.js";function K(o){const i=o.source??"item",h=o.tradeId||`${o.contractAddress}-${o.tokenId??o.itemId??""}`;return`${i}:${h}`}const U="100000000000000000000",De=2,te=15,Yt=/^[a-zA-Z0-9]+$/;function Ne(o){const i=o.trim();return i.length===0?{ok:!1,reason:"empty"}:Yt.test(i)?i.length<De?{ok:!1,reason:"too-short"}:i.length>te?{ok:!1,reason:"too-long"}:{ok:!0}:{ok:!1,reason:"invalid-chars"}}function en(o){return o.replace(/[^a-zA-Z0-9]/g,"").slice(0,te)}const tn=["function available(string _subdomain) view returns (bool)"],Pe={mainnet:{rpc:"https://rpc.decentraland.org/mainnet",address:"0x2a187453064356c898cae034eaed119e1663acb8"},sepolia:{rpc:"https://rpc.decentraland.org/sepolia",address:"0x7518456ae93eb98f3e64571b689c626616bb7f30"}};function nn(){return L.chainId===Number(Ut.ChainId.MATIC_MAINNET)?Pe.mainnet:Pe.sepolia}async function sn(o,i={}){var l;const{rpc:h,address:c}=nn(),d=new Zt(h),a=new Jt(c,tn,d);console.info(`[names] availability check → DCLRegistrar(${c}).available("${o}") on ${h}`);const f=await a.available(o);if((l=i.signal)!=null&&l.aborted)throw new DOMException("Aborted","AbortError");return console.info(`[names] "${o}" available=${f}`),f?"available":"taken"}const on="https://app.across.to/api";class we extends Error{constructor(){super("Name registration is temporarily unavailable due to high network costs"),this.name="NameRouteCostTooHighError"}}function rn(o){return ot(U,o)}async function an(o,i,h={}){var l;const c=h.chainId??L.chainId,d=h.provider??"across",a=`${L.creditsServerUrl}/credits-name-route?name=${encodeURIComponent(i)}&chainId=${c}&provider=${d}`,f=await rt(a,{method:"GET",identity:o,metadata:{}});if(!f.ok){let p;try{p=(l=await f.json())==null?void 0:l.code}catch{}throw p==="ROUTE_COST_TOO_HIGH"?new we:new Error(`fetchNameCreditRoute ${f.status}`)}return f.json()}function ln(o,i){const h=ye.from(o.availableAmount),d=ye.from(U).sub(h);return{credits:[{value:o.amount,expiresAt:Number(o.expiresAt),salt:Vt(o.id)}],creditsSignatures:[o.signature],externalCall:{target:i.externalCall.target,selector:i.externalCall.selector,data:i.externalCall.data,expiresAt:i.externalCall.expiresAt,salt:i.externalCall.salt},customExternalCallSignature:i.customExternalCallSignature,maxUncreditedValue:d.isNegative()?"0":d.toString(),maxCreditedValue:U}}async function cn(o,i={}){const h=on,c=i.intervalMs??1e4,d=i.maxAttempts??60;let a={status:"pending",destinationTxHash:null,actionsSucceeded:!1};for(let f=0;f<d;f++){try{const l=await fetch(`${h}/deposit/status?originChainId=137&depositTxHash=${o}`);if(l.ok){const p=await l.json(),x=(p.status??"pending").toLowerCase(),y=p.fillTx??p.fillTxnRef??null,m=p.actionsSucceeded!==!1;if(x==="filled")return{status:"filled",destinationTxHash:y,actionsSucceeded:m};if(x==="refunded"||x==="expired")return{status:x,destinationTxHash:null,actionsSucceeded:!1};a={status:"pending",destinationTxHash:y,actionsSucceeded:m}}}catch{}f<d-1&&await new Promise(l=>setTimeout(l,c))}return a}async function dn(o){const{name:i,identity:h,signer:c}=o,d=o.chainId??L.chainId,a=o.provider??"across",f=(o.beneficiary??await c.getAddress()).toLowerCase();let l=null,p=!1;console.info("[names] register start",{name:i,buyer:f,chainId:d,provider:a});try{const x=await tt(d),y=rn(x);console.info("[names] step 1/6 sized reservation",{usdCents:y,manaRate:x});const m=await an(h,i,{chainId:d,provider:a});console.info("[names] step 2/6 route fetched",{target:m.externalCall.target,selector:m.externalCall.selector,provider:m.provider,quoteId:m.quoteId});const C=await nt(h,y);if(l=C.credit.id,console.info("[names] step 3/6 credit authorized",{creditId:C.credit.id,maxCreditedValue:C.maxCreditedValue}),ye.from(C.maxCreditedValue).lt(U))throw new Error("Credit under-sized for the name price");const k=ln(C.credit,m);let g;try{g=await Ht({chainId:d,buyer:f,signer:c,args:k})}catch(b){if(!(b instanceof Ot))throw b;g=await qt(d,k,c)}if(console.info("[names] step 4/6 useCredits submitted (Polygon origin tx)",{originTxHash:g}),await Gt(g),p=!0,console.info("[names] step 5/6 origin tx confirmed",{originTxHash:g}),a==="across"){const b=await cn(g,o.acrossPoll);if(console.info("[names] step 6/6 across status",b),b.status==="pending")return{status:"pending",originTxHash:g};if(b.status!=="filled"||!b.actionsSucceeded)throw new Error("The name could not be registered on Ethereum; your funds were recovered.");return{status:"registered",originTxHash:g,destinationTxHash:b.destinationTxHash}}return{status:"pending",originTxHash:g}}catch(x){if(console.error("[names] register failed — raw error:",x,{name:i,buyer:f,originConfirmed:p}),x instanceof Dt)return{status:"pending",originTxHash:x.txHash};if(l&&!p&&await st(h,[l]).catch(()=>{}),x instanceof we)throw x;const y=new Error(Kt(x,"Couldn't register the name. Please try again.",{sale:!0}));throw y.cause=x,y}}const pn=s.div`
1
+ import{d as Le,r as u,j as e,e as et}from"./react-DehiWSvs.js";import{c as L,k as tt,bc as nt,bd as st,aq as ot,b as rt,s,t,l as Ue,b1 as it,y as at,av as be,d as n,w as lt,I as R,x as P,bK as se,b0 as ct,U as ee,bg as dt,bf as pt,v as He,b3 as Oe,m as Ge,n as ht,ae as xt,ag as Ie,ah as V,ax as ft,bH as mt}from"./index-C3igEAQW.js";import{g as ut,h as gt,i as bt,j as yt,k as wt,C as jt,l as vt,o as $t,m as Ct,n as kt,M as St,u as Et,E as Rt,v as _t,p as Tt,q as zt,r as It,s as At,t as Nt}from"./Assets.styles-BHyaJQ_u.js";import{S as Ae,R as Pt,F as Mt,e as Wt}from"./categories-BvyNQxRN.js";import{L as Bt}from"./LoadMore-qdo6Ikhu.js";import{u as Ft}from"./useInfiniteGrid-DxWFUb-I.js";import{E as Lt}from"./ErrorNotice-C0VDjxD8.js";import{d as Ut}from"./dcl-schemas-Dr9BTjb7.js";import{s as Ht,G as Ot,w as Gt,S as Dt}from"./buy-gasless-Brir4Yxd.js";import{s as qt}from"./buy-CvpQJoW5.js";import{j as Vt}from"./trade-encoding-3zHfaY9t.js";import{f as Kt}from"./errors-DFMf8rsi.js";import{J as Zt,C as Jt,B as ye}from"./ethers-CtNGBird.js";import{n as Qt}from"./Tooltip-JQloj8Nt.js";import{G as Xt}from"./grid.styles-BB_h06XI.js";import"./sentry-973sfbO9.js";import"./intl-CBcMB1D2.js";import"./authorizations-C4greZZh.js";import"./sendMetaTransaction-CKo6PfMe.js";function K(o){const i=o.source??"item",h=o.tradeId||`${o.contractAddress}-${o.tokenId??o.itemId??""}`;return`${i}:${h}`}const U="100000000000000000000",De=2,te=15,Yt=/^[a-zA-Z0-9]+$/;function Ne(o){const i=o.trim();return i.length===0?{ok:!1,reason:"empty"}:Yt.test(i)?i.length<De?{ok:!1,reason:"too-short"}:i.length>te?{ok:!1,reason:"too-long"}:{ok:!0}:{ok:!1,reason:"invalid-chars"}}function en(o){return o.replace(/[^a-zA-Z0-9]/g,"").slice(0,te)}const tn=["function available(string _subdomain) view returns (bool)"],Pe={mainnet:{rpc:"https://rpc.decentraland.org/mainnet",address:"0x2a187453064356c898cae034eaed119e1663acb8"},sepolia:{rpc:"https://rpc.decentraland.org/sepolia",address:"0x7518456ae93eb98f3e64571b689c626616bb7f30"}};function nn(){return L.chainId===Number(Ut.ChainId.MATIC_MAINNET)?Pe.mainnet:Pe.sepolia}async function sn(o,i={}){var l;const{rpc:h,address:c}=nn(),d=new Zt(h),a=new Jt(c,tn,d);console.info(`[names] availability check → DCLRegistrar(${c}).available("${o}") on ${h}`);const f=await a.available(o);if((l=i.signal)!=null&&l.aborted)throw new DOMException("Aborted","AbortError");return console.info(`[names] "${o}" available=${f}`),f?"available":"taken"}const on="https://app.across.to/api";class we extends Error{constructor(){super("Name registration is temporarily unavailable due to high network costs"),this.name="NameRouteCostTooHighError"}}function rn(o){return ot(U,o)}async function an(o,i,h={}){var l;const c=h.chainId??L.chainId,d=h.provider??"across",a=`${L.creditsServerUrl}/credits-name-route?name=${encodeURIComponent(i)}&chainId=${c}&provider=${d}`,f=await rt(a,{method:"GET",identity:o,metadata:{}});if(!f.ok){let p;try{p=(l=await f.json())==null?void 0:l.code}catch{}throw p==="ROUTE_COST_TOO_HIGH"?new we:new Error(`fetchNameCreditRoute ${f.status}`)}return f.json()}function ln(o,i){const h=ye.from(o.availableAmount),d=ye.from(U).sub(h);return{credits:[{value:o.amount,expiresAt:Number(o.expiresAt),salt:Vt(o.id)}],creditsSignatures:[o.signature],externalCall:{target:i.externalCall.target,selector:i.externalCall.selector,data:i.externalCall.data,expiresAt:i.externalCall.expiresAt,salt:i.externalCall.salt},customExternalCallSignature:i.customExternalCallSignature,maxUncreditedValue:d.isNegative()?"0":d.toString(),maxCreditedValue:U}}async function cn(o,i={}){const h=on,c=i.intervalMs??1e4,d=i.maxAttempts??60;let a={status:"pending",destinationTxHash:null,actionsSucceeded:!1};for(let f=0;f<d;f++){try{const l=await fetch(`${h}/deposit/status?originChainId=137&depositTxHash=${o}`);if(l.ok){const p=await l.json(),x=(p.status??"pending").toLowerCase(),y=p.fillTx??p.fillTxnRef??null,m=p.actionsSucceeded!==!1;if(x==="filled")return{status:"filled",destinationTxHash:y,actionsSucceeded:m};if(x==="refunded"||x==="expired")return{status:x,destinationTxHash:null,actionsSucceeded:!1};a={status:"pending",destinationTxHash:y,actionsSucceeded:m}}}catch{}f<d-1&&await new Promise(l=>setTimeout(l,c))}return a}async function dn(o){const{name:i,identity:h,signer:c}=o,d=o.chainId??L.chainId,a=o.provider??"across",f=(o.beneficiary??await c.getAddress()).toLowerCase();let l=null,p=!1;console.info("[names] register start",{name:i,buyer:f,chainId:d,provider:a});try{const x=await tt(d),y=rn(x);console.info("[names] step 1/6 sized reservation",{usdCents:y,manaRate:x});const m=await an(h,i,{chainId:d,provider:a});console.info("[names] step 2/6 route fetched",{target:m.externalCall.target,selector:m.externalCall.selector,provider:m.provider,quoteId:m.quoteId});const C=await nt(h,y);if(l=C.credit.id,console.info("[names] step 3/6 credit authorized",{creditId:C.credit.id,maxCreditedValue:C.maxCreditedValue}),ye.from(C.maxCreditedValue).lt(U))throw new Error("Credit under-sized for the name price");const k=ln(C.credit,m);let g;try{g=await Ht({chainId:d,buyer:f,signer:c,args:k})}catch(b){if(!(b instanceof Ot))throw b;g=await qt(d,k,c)}if(console.info("[names] step 4/6 useCredits submitted (Polygon origin tx)",{originTxHash:g}),await Gt(g),p=!0,console.info("[names] step 5/6 origin tx confirmed",{originTxHash:g}),a==="across"){const b=await cn(g,o.acrossPoll);if(console.info("[names] step 6/6 across status",b),b.status==="pending")return{status:"pending",originTxHash:g};if(b.status!=="filled"||!b.actionsSucceeded)throw new Error("The name could not be registered on Ethereum; your funds were recovered.");return{status:"registered",originTxHash:g,destinationTxHash:b.destinationTxHash}}return{status:"pending",originTxHash:g}}catch(x){if(console.error("[names] register failed — raw error:",x,{name:i,buyer:f,originConfirmed:p}),x instanceof Dt)return{status:"pending",originTxHash:x.txHash};if(l&&!p&&await st(h,[l]).catch(()=>{}),x instanceof we)throw x;const y=new Error(Kt(x,"Couldn't register the name. Please try again.",{sale:!0}));throw y.cause=x,y}}const pn=s.div`
2
2
  position: fixed;
3
3
  inset: 0;
4
4
  z-index: 10000;
@@ -379,7 +379,7 @@ import{d as Le,r as u,j as e,e as et}from"./react-DehiWSvs.js";import{c as L,k a
379
379
  color: ${t.colors.accent};
380
380
  }
381
381
  }
382
- `;function Tn({name:o,priceCredits:i,onClose:h}){const{session:c}=Ue(),{data:d,isError:a}=it(c),f=at(),l=Le(),[p,x]=u.useState("confirm"),[y,m]=u.useState(""),[C,k]=u.useState(null),g=u.useRef(!1),b=y.trim().toLowerCase()===o.toLowerCase(),S=p==="completing",v=i!=null?be(i):"—",_=i==null,E=d==null?void 0:d.credits,M=i!=null&&E!=null?i-E:0,$=M>0,T=_?n("names.priceUnavailable"):$?n("names.insufficientCredits",{credits:be(M)}):null;u.useEffect(()=>{const w=O=>{O.key==="Escape"&&!S&&h()};document.addEventListener("keydown",w);const H=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",w),document.body.style.overflow=H}},[S,h]);async function W(){if(!(!c||!b||_||$||g.current)){g.current=!0,x("completing"),k(null);try{const w=await dn({name:o,identity:c.identity,signer:c.signer});ee("Shop Completed Purchase",{purchase_type:"name",is_primary:!0,payment_type:"credits",value_credits:i??null,settlement:w.status}),f.invalidateQueries({queryKey:["usd-balance"]}),f.invalidateQueries({queryKey:["my-assets"]}),x(w.status==="registered"?"success":"pending")}catch(w){ee(pt(w)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:dt(w),purchase_type:"name"}),k(w instanceof we?n("names.errorRouteCost"):(w==null?void 0:w.message)||n("names.errorGeneric")),x("error")}finally{g.current=!1}}}const I=p!=="success"&&p!=="pending",A=lt(c==null?void 0:c.providerType);return e.jsx(pn,{onClick:S?void 0:h,role:"presentation",children:e.jsxs(hn,{role:"dialog","aria-modal":"true","aria-label":n("names.buyTitle"),onClick:w=>w.stopPropagation(),children:[I&&e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:p==="error"?n("names.errorTitle"):n("names.buyTitle")}),e.jsx(ie,{onClick:h,disabled:S,"aria-label":n("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(ae,{children:[n("names.myCreditsBalance")," ",e.jsx(P,{})," ",se(d,a)]}),e.jsx(le,{})]}),(p==="confirm"||p==="error")&&e.jsxs(e.Fragment,{children:[e.jsxs(ce,{children:[e.jsx(de,{"aria-hidden":!0,children:"@"}),e.jsxs(pe,{children:[e.jsxs(he,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(xe,{children:n("names.subtitle")})]}),e.jsxs(fe,{children:[e.jsx(P,{}),v]})]}),p==="error"?e.jsxs(e.Fragment,{children:[e.jsxs(me,{children:[e.jsx(R,{name:"info","aria-hidden":!0}),e.jsx("span",{children:C})]}),e.jsx(Me,{onClick:()=>x("confirm"),children:n("names.tryAgain")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(xn,{children:[e.jsx(fn,{children:n("names.confirmTitle")}),e.jsx(mn,{dangerouslySetInnerHTML:{__html:n("names.confirmBody",{name:`<b>@${zn(o)}</b>`})}}),e.jsxs(un,{children:[e.jsx(gn,{"aria-hidden":!0,children:"@"}),e.jsx(bn,{value:y,onChange:w=>m(w.target.value.replace(/[^a-zA-Z0-9]/g,"")),placeholder:"yourname","aria-label":n("names.reenterAria"),autoComplete:"off",spellCheck:!1,style:{width:`${Math.max(y.length,8)}ch`}}),e.jsx(yn,{children:".dcl.eth"})]})]}),T?e.jsxs(me,{"data-tone":"info","data-testid":"name-blocked-reason",children:[e.jsx(R,{name:"info","aria-hidden":!0}),e.jsx("span",{children:T})]}):null,e.jsx(Me,{onClick:()=>void W(),disabled:!b||!c||_||$,children:n("names.buyCta")})]})]}),p==="completing"&&e.jsxs(wn,{children:[e.jsx(jn,{src:ct,alt:"",width:56,height:56}),e.jsx(vn,{children:A?n("names.confirming"):n("names.completing")}),e.jsxs($n,{children:[e.jsx(Cn,{"aria-hidden":!0,children:e.jsx("span",{})}),e.jsx(kn,{children:"1/1"})]})]}),p==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:n("names.pendingHeaderTitle")}),e.jsx(ie,{onClick:h,"aria-label":n("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(ae,{children:[n("names.myCreditsBalance")," ",e.jsx(P,{})," ",se(d,a)]}),e.jsx(le,{}),e.jsxs(me,{"data-tone":"info",children:[e.jsx(R,{name:"info","aria-hidden":!0}),e.jsxs("span",{children:[e.jsx("b",{children:n("names.pendingBannerBold")})," ",n("names.pendingBannerRest")]})]}),e.jsxs(ce,{style:{marginTop:20},children:[e.jsx(de,{"aria-hidden":!0,children:"@"}),e.jsxs(pe,{children:[e.jsxs(he,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(xe,{children:n("names.subtitle")})]}),e.jsxs(fe,{children:[e.jsx(P,{}),v]})]}),e.jsx(We,{children:e.jsx(Be,{onClick:()=>{h(),l("/my-items")},children:n("names.myItems")})})]}),p==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:n("names.successHeaderTitle")}),e.jsx(ie,{onClick:h,"aria-label":n("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(ae,{children:[n("names.myCreditsBalance")," ",e.jsx(P,{})," ",se(d,a)]}),e.jsx(le,{}),e.jsxs(Sn,{children:[e.jsx(En,{"aria-hidden":!0,children:e.jsx(R,{name:"check"})}),e.jsxs(Rn,{children:[e.jsx("b",{children:n("names.successBannerBold")})," ",n("names.successBannerRest")]})]}),e.jsxs(ce,{style:{marginTop:20},children:[e.jsx(de,{"aria-hidden":!0,children:"@"}),e.jsxs(pe,{children:[e.jsxs(he,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(xe,{children:n("names.subtitle")})]}),e.jsxs(fe,{children:[e.jsx(P,{}),v]})]}),e.jsxs(We,{children:[e.jsx(Be,{onClick:()=>{h(),l("/my-items")},children:n("names.myItems")}),e.jsx(_n,{href:L.profileUrl,target:"_blank",rel:"noopener noreferrer",children:n("names.assignToAvatar")})]})]})]})})}function zn(o){return o.replace(/[&<>"']/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[i])}const In="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/identity-B4DXDuJP.webp",An="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/world-B-9aPlxu.webp",Nn="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/invite-BfwIhP2C.webp",Pn="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/governance-DnazlIjy.webp",Mn=s.div`
382
+ `;function Tn({name:o,priceCredits:i,onClose:h}){const{session:c}=Ue(),{data:d,isError:a}=it(c),f=at(),l=Le(),[p,x]=u.useState("confirm"),[y,m]=u.useState(""),[C,k]=u.useState(null),g=u.useRef(!1),b=y.trim().toLowerCase()===o.toLowerCase(),S=p==="completing",v=i!=null?be(i):"—",_=i==null,E=d==null?void 0:d.credits,M=i!=null&&E!=null?i-E:0,$=M>0,T=_?n("names.priceUnavailable"):$?n("names.insufficientCredits",{credits:be(M)}):null;u.useEffect(()=>{const w=O=>{O.key==="Escape"&&!S&&h()};document.addEventListener("keydown",w);const H=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{document.removeEventListener("keydown",w),document.body.style.overflow=H}},[S,h]);async function W(){if(!(!c||!b||_||$||g.current)){g.current=!0,x("completing"),k(null);try{const w=await dn({name:o,identity:c.identity,signer:c.signer});ee("Shop Completed Purchase",{purchase_type:"name",is_primary:!0,payment_type:"credits",value_credits:i??null,settlement:w.status}),f.invalidateQueries({queryKey:["usd-balance"]}),f.invalidateQueries({queryKey:["my-assets"]}),x(w.status==="registered"?"success":"pending")}catch(w){ee(pt(w)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:dt(w),purchase_type:"name"}),k(w instanceof we?n("names.errorRouteCost"):(w==null?void 0:w.message)||n("names.errorGeneric")),x("error")}finally{g.current=!1}}}const I=p!=="success"&&p!=="pending",A=lt(c==null?void 0:c.providerType);return e.jsx(pn,{onClick:S?void 0:h,role:"presentation",children:e.jsxs(hn,{role:"dialog","aria-modal":"true","aria-label":n("names.buyTitle"),onClick:w=>w.stopPropagation(),children:[I&&e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:p==="error"?n("names.errorTitle"):n("names.buyTitle")}),e.jsx(ie,{onClick:h,disabled:S,"aria-label":n("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(ae,{children:[n("names.myCreditsBalance")," ",e.jsx(P,{})," ",se(d,a)]}),e.jsx(le,{})]}),(p==="confirm"||p==="error")&&e.jsxs(e.Fragment,{children:[e.jsxs(ce,{children:[e.jsx(de,{"aria-hidden":!0,children:"@"}),e.jsxs(pe,{children:[e.jsxs(he,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(xe,{children:n("names.subtitle")})]}),e.jsxs(fe,{children:[e.jsx(P,{}),v]})]}),p==="error"?e.jsxs(e.Fragment,{children:[e.jsxs(me,{children:[e.jsx(R,{name:"info","aria-hidden":!0}),e.jsx("span",{children:C})]}),e.jsx(Me,{onClick:()=>x("confirm"),children:n("names.tryAgain")})]}):e.jsxs(e.Fragment,{children:[e.jsxs(xn,{children:[e.jsx(fn,{children:n("names.confirmTitle")}),e.jsx(mn,{dangerouslySetInnerHTML:{__html:n("names.confirmBody",{name:`<b>@${zn(o)}</b>`})}}),e.jsxs(un,{children:[e.jsx(gn,{"aria-hidden":!0,children:"@"}),e.jsx(bn,{value:y,onChange:w=>m(w.target.value.replace(/[^a-zA-Z0-9]/g,"")),placeholder:"yourname","aria-label":n("names.reenterAria"),autoComplete:"off",spellCheck:!1,style:{width:`${Math.max(y.length,8)}ch`}}),e.jsx(yn,{children:".dcl.eth"})]})]}),T?e.jsxs(me,{"data-tone":"info","data-testid":"name-blocked-reason",children:[e.jsx(R,{name:"info","aria-hidden":!0}),e.jsx("span",{children:T})]}):null,e.jsx(Me,{onClick:()=>void W(),disabled:!b||!c||_||$,children:n("names.buyCta")})]})]}),p==="completing"&&e.jsxs(wn,{children:[e.jsx(jn,{src:ct,alt:"",width:56,height:56}),e.jsx(vn,{children:A?n("names.confirming"):n("names.completing")}),e.jsxs($n,{children:[e.jsx(Cn,{"aria-hidden":!0,children:e.jsx("span",{})}),e.jsx(kn,{children:"1/1"})]})]}),p==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:n("names.pendingHeaderTitle")}),e.jsx(ie,{onClick:h,"aria-label":n("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(ae,{children:[n("names.myCreditsBalance")," ",e.jsx(P,{})," ",se(d,a)]}),e.jsx(le,{}),e.jsxs(me,{"data-tone":"info",children:[e.jsx(R,{name:"info","aria-hidden":!0}),e.jsxs("span",{children:[e.jsx("b",{children:n("names.pendingBannerBold")})," ",n("names.pendingBannerRest")]})]}),e.jsxs(ce,{style:{marginTop:20},children:[e.jsx(de,{"aria-hidden":!0,children:"@"}),e.jsxs(pe,{children:[e.jsxs(he,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(xe,{children:n("names.subtitle")})]}),e.jsxs(fe,{children:[e.jsx(P,{}),v]})]}),e.jsx(We,{children:e.jsx(Be,{onClick:()=>{h(),l("/my-items")},children:n("names.myItems")})})]}),p==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs(oe,{children:[e.jsx(re,{children:n("names.successHeaderTitle")}),e.jsx(ie,{onClick:h,"aria-label":n("buyModal.close"),children:e.jsx(R,{name:"close"})})]}),e.jsxs(ae,{children:[n("names.myCreditsBalance")," ",e.jsx(P,{})," ",se(d,a)]}),e.jsx(le,{}),e.jsxs(Sn,{children:[e.jsx(En,{"aria-hidden":!0,children:e.jsx(R,{name:"check"})}),e.jsxs(Rn,{children:[e.jsx("b",{children:n("names.successBannerBold")})," ",n("names.successBannerRest")]})]}),e.jsxs(ce,{style:{marginTop:20},children:[e.jsx(de,{"aria-hidden":!0,children:"@"}),e.jsxs(pe,{children:[e.jsxs(he,{children:[o,e.jsx("span",{children:".dcl.eth"})]}),e.jsx(xe,{children:n("names.subtitle")})]}),e.jsxs(fe,{children:[e.jsx(P,{}),v]})]}),e.jsxs(We,{children:[e.jsx(Be,{onClick:()=>{h(),l("/my-items")},children:n("names.myItems")}),e.jsx(_n,{href:L.profileUrl,target:"_blank",rel:"noopener noreferrer",children:n("names.assignToAvatar")})]})]})]})})}function zn(o){return o.replace(/[&<>"']/g,i=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"})[i])}const In="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/identity-B4DXDuJP.webp",An="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/world-B-9aPlxu.webp",Nn="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/invite-BfwIhP2C.webp",Pn="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/governance-DnazlIjy.webp",Mn=s.div`
383
383
  width: 100%;
384
384
  min-width: 0;
385
385
  `,Wn=s.nav`
@@ -1,4 +1,4 @@
1
- import{r as $,j as t}from"./react-DehiWSvs.js";import{R as T,C as se,a as ae,b as re}from"./categories-BQKh49D5.js";import{n as c,T as le}from"./Tooltip-ySlzdfvH.js";import{t as e,s as o,I as g,d as s,ae as ce,e as v}from"./index-DaQaTpvn.js";const de=o.div`
1
+ import{r as $,j as t}from"./react-DehiWSvs.js";import{R as T,C as se,a as ae,b as re}from"./categories-BvyNQxRN.js";import{n as c,T as le}from"./Tooltip-JQloj8Nt.js";import{t as e,s as o,I as g,d as s,ae as ce,e as v}from"./index-C3igEAQW.js";const de=o.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 12px;
@@ -1,4 +1,4 @@
1
- import{j as i,L as _,r as F}from"./react-DehiWSvs.js";import{s as n,B as P,t as a,q as D,v as W,d as e,l as G,w as O,I as b,x as B,o as w,y as K,c as Q,z as H,A,D as X,E as Z,F as E}from"./index-DaQaTpvn.js";import{d as J,f as U,b as V,h as Y,s as tt,a as it}from"./authorizations-D7XuRQgn.js";import{f as et}from"./builder-MQPY8ChB.js";import{m as ot}from"./mana-matic-C4e1sNO3.js";import{f as at}from"./errors-Wm6SH4-v.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./sendMetaTransaction-ef-RXWfu.js";const nt=D`
1
+ import{j as i,L as _,r as F}from"./react-DehiWSvs.js";import{s as n,B as P,t as a,q as D,v as W,d as e,l as G,w as O,I as b,x as B,o as w,y as K,c as Q,z as H,A,D as X,E as Z,F as E}from"./index-C3igEAQW.js";import{d as J,f as U,b as V,h as Y,s as tt,a as it}from"./authorizations-C4greZZh.js";import{f as et}from"./builder-DpcoQGnj.js";import{m as ot}from"./mana-matic-C4e1sNO3.js";import{f as at}from"./errors-DFMf8rsi.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./sendMetaTransaction-CKo6PfMe.js";const nt=D`
2
2
  to { transform: rotate(360deg); }
3
3
  `,st=D`
4
4
  to { background-position: -200% 0; }
@@ -1,4 +1,4 @@
1
- import{j as e,L as $e,r as P,d as ta,b as aa}from"./react-DehiWSvs.js";import{t as le,s as i,d as s,av as de,b0 as sa,au as na,I as H,x as Mt,ad as Qe,v as ia,Q as N,af as dt,l as ra,n as oa,o as ca,b1 as da,y as la,b2 as ua,b3 as ha,b4 as pa,b5 as lt,b6 as ga,b7 as xa,w as ma,b8 as ut,U as G,b9 as ht,ba as fa,D as ae,k as ya,c as pt,bb as ba,e as va,bc as gt,bd as _e,be as ye,bf as be,bg as xt,g as ve,a as wa,C as We,bh as Ca}from"./index-DaQaTpvn.js";import{M as ja,S as ka,C as Sa,H as $a,a as Ma,T as Ta,X as Ia,b as Pa,B as za,c as Aa,d as mt,e as Ea,f as ke,P as Tt,m as qa,g as Ba,h as Ra,i as _a,j as It,k as Se,L as Wa,l as Fa,n as ft,o as yt,W as La,p as Ua,q as Ka,A as Qa,r as Na,s as Ha,t as Oa,u as Va,v as Ga,w as Da,x as Ya,y as Ja,z as Xa,D as Za,E as es,F as ts,G as as,I as ss,J as ns,K as Fe,N as is,O as rs,Q as os,R as cs,U as bt,V as vt,Y as ds,Z as ls,_ as us}from"./CollectionCarousel-nQamkKEm.js";import{j as hs,k as ps,a as gs,n as xs,i as ms,A as fs}from"./authorizations-D7XuRQgn.js";import{g as ys,b as Le}from"./buy-DGpUz8hz.js";import{b as bs,w as vs,S as wt,G as ws}from"./buy-gasless-Bl-OulBV.js";import{u as Cs,M as js,R as we,r as ks,c as Ss,p as Ct}from"./useCreditPacks-CzOCruPU.js";import{i as $s,a as Ms}from"./errors-Wm6SH4-v.js";import{E as Ts}from"./ErrorNotice-CfA5EQ3B.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-wpCgB2Av.js";import"./sendMetaTransaction-ef-RXWfu.js";const{colors:se,radius:Is}=le,Ps=i.div`
1
+ import{j as e,L as $e,r as P,d as ta,b as aa}from"./react-DehiWSvs.js";import{t as ue,s as i,d as a,av as le,b0 as sa,au as na,I as H,x as Mt,ad as Qe,v as ia,Q as N,af as dt,l as ra,n as oa,o as ca,b1 as da,y as la,b2 as ua,b3 as ha,b4 as pa,b5 as lt,b6 as ga,b7 as xa,w as ma,b8 as ut,U as G,b9 as ht,ba as fa,D as ae,k as ya,c as pt,bb as ba,e as va,bc as gt,bd as _e,be as ye,bf as be,bg as xt,g as ve,a as wa,C as We,bh as Ca}from"./index-C3igEAQW.js";import{M as ja,S as ka,C as Sa,H as $a,a as Ma,T as Ta,X as Ia,b as Pa,B as za,c as Aa,d as mt,e as Ea,f as ke,P as Tt,m as qa,g as Ba,h as Ra,i as _a,j as It,k as Se,L as Wa,l as Fa,n as ft,o as yt,W as La,p as Ua,q as Ka,A as Qa,r as Na,s as Ha,t as Oa,u as Va,v as Ga,w as Da,x as Ya,y as Ja,z as Xa,D as Za,E as es,F as ts,G as as,I as ss,J as ns,K as Fe,N as is,O as rs,Q as os,R as cs,U as bt,V as vt,Y as ds,Z as ls,_ as us}from"./CollectionCarousel-BuJHPo0X.js";import{j as hs,k as ps,a as gs,n as xs,i as ms,A as fs}from"./authorizations-C4greZZh.js";import{g as ys,b as Le}from"./buy-CvpQJoW5.js";import{b as bs,w as vs,S as wt,G as ws}from"./buy-gasless-Brir4Yxd.js";import{u as Cs,M as js,R as we,r as ks,c as Ss,p as Ct}from"./useCreditPacks-C673G0mp.js";import{i as $s,a as Ms}from"./errors-DFMf8rsi.js";import{E as Ts}from"./ErrorNotice-C0VDjxD8.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-3zHfaY9t.js";import"./sendMetaTransaction-CKo6PfMe.js";const{colors:se,radius:Is}=ue,Ps=i.div`
2
2
  display: flex;
3
3
  align-items: center;
4
4
  justify-content: center;
@@ -58,7 +58,7 @@ import{j as e,L as $e,r as P,d as ta,b as aa}from"./react-DehiWSvs.js";import{t
58
58
  font-weight: 700;
59
59
  color: ${se.text};
60
60
  }
61
- `,Bs="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/buy-error-22UunaPC.png";function Rs(o){const{phase:l,balanceCredits:I,onClose:z}=o,W=l==="processing",D=l==="error"?s("cartCheckout.errorTitle"):l==="nofunds"?s("cartCheckout.titleNoFunds"):l==="choose"?s("buyModal.choosePayment"):s("cartCheckout.titleBuy"),Y=l==="processing";return e.jsxs(ja,{role:"dialog","aria-modal":"true","aria-label":s("cartCheckout.dialogAria"),children:[e.jsx(ka,{onClick:W?void 0:z,"aria-hidden":!0}),e.jsxs(Sa,{"data-tall":Y||void 0,children:[e.jsxs($a,{children:[e.jsxs(Ma,{children:[e.jsx(Ta,{children:D}),!W&&e.jsx(Ia,{onClick:z,"aria-label":s("buyModal.close"),children:e.jsx(Pa,{})})]}),e.jsxs(za,{children:[e.jsx(Aa,{children:l==="nofunds"?s("buyModal.dclBalance"):s("buyModal.myCreditsBalance")}),e.jsx(mt,{}),e.jsx(Ea,{children:de(I)})]})]}),l==="choose"&&e.jsxs(ke,{children:[e.jsxs(qs,{children:[e.jsx("span",{children:s("cart.purchaseSummary")}),e.jsxs("strong",{children:[e.jsx(mt,{}),de(o.totalCredits??0)]})]}),e.jsx(Tt,{options:o.options??[],totalCents:o.totalCents??0,onPay:o.onPay??(()=>{}),rateNote:(()=>{const A=qa(o.totalCents??0,o.totalManaWei??0n);return A!=null?s("buyModal.manaRate",{mana:A.toLocaleString("en",{maximumFractionDigits:2})}):null})()})]}),l==="processing"&&e.jsx(_s,{stage:o.stage??"reserving",step:o.step??1,total:o.total??1,isSelfCustody:!!o.isSelfCustody,signatures:o.signatures}),l==="nofunds"&&e.jsx(Ws,{lines:o.lines??[],shortfallCredits:o.shortfallCredits??0,packs:o.packs??[],selectedPack:o.selectedPack??"",onSelectPack:o.onSelectPack??(()=>{}),onBuyPacks:o.onBuyPacks??(()=>{}),onCancel:z}),l==="error"&&e.jsxs(ke,{children:[e.jsxs(Ba,{"data-testid":"buy-error",children:[e.jsx(Ra,{src:Bs,alt:"",width:64,height:80}),e.jsxs(_a,{children:[e.jsx("b",{children:s("cartCheckout.errorHeadline")})," ",o.message??s("cartCheckout.errorBody")]})]}),e.jsxs(It,{children:[e.jsx(Se,{"data-variant":"outline",onClick:z,children:s("buyModal.cancel")}),e.jsx(Se,{"data-variant":"purple",onClick:o.onRetry??z,children:s("cartCheckout.tryAgain")})]})]})]})]})}function _s({stage:o,step:l,total:I,isSelfCustody:z,signatures:W}){const D=o==="reserving",Y=I>0?Math.min(100,Math.round(l/I*100)):0,A=z&&W&&W.total>1,ne=o==="awaiting-signature"?z?A?s("cartCheckout.confirmMultiple",{current:W.current,total:W.total}):s("buyModal.confirmToContinue"):s("buyModal.completingTransaction"):o==="settling"?s("buyModal.completingTransaction"):s("cartCheckout.preparing");return e.jsxs(ke,{"data-processing":!0,children:[e.jsx(Wa,{src:sa,alt:"",width:61,height:61}),e.jsx(Fa,{children:ne}),D?e.jsxs(Ps,{children:[e.jsx(ft,{"aria-hidden":!0,children:e.jsx(yt,{"data-step":!0,style:{width:`${Y}%`}})}),I>1?e.jsxs(zs,{children:[l,"/",I]}):null]}):e.jsx(ft,{"aria-hidden":!0,children:e.jsx(yt,{})})]})}function Ws({lines:o,shortfallCredits:l,packs:I,selectedPack:z,onSelectPack:W,onBuyPacks:D,onCancel:Y}){const A=I.find(n=>n.id===z),ne=o.reduce((n,L)=>n+(L.quantity??1),0);return e.jsxs(ke,{children:[e.jsxs(La,{"data-testid":"nofunds-warning",children:[e.jsx(Ua,{}),e.jsxs(Ka,{children:[e.jsx("b",{children:s("buyModal.insufficientFunds")})," ",s("buyModal.warningNeedToBuy")," ",e.jsx("b",{children:s("buyModal.warningCreditsAmount",{count:Math.max(0,l)})})," ",s("buyModal.warningToPurchase",{count:ne})]})]}),e.jsx(As,{children:o.map(n=>{const L=n.quantity??1;return e.jsxs(Qa,{children:[e.jsx(Na,{children:n.item.thumbnail?e.jsx("img",{src:n.item.thumbnail,alt:""}):null}),e.jsxs(Ha,{children:[e.jsxs("div",{children:[e.jsxs(Oa,{title:n.item.name,children:[n.item.name||s("buyModal.itemFallback"),L>1?e.jsx(Es,{children:s("cartCheckout.qty",{count:L})}):null]}),n.item.creator?e.jsx(Va,{address:n.item.creator}):null]}),e.jsxs(Ga,{children:[e.jsx(Da,{}),e.jsx("span",{children:de(n.priceCredits*L)})]})]})]},n.item.id)})}),e.jsx(Ya,{children:I.map(n=>{const L=n.id===z;return e.jsxs(Ja,{"data-testid":"credit-pack","data-on":L||void 0,onClick:()=>W(n.id),children:[e.jsx(Xa,{}),e.jsx(Za,{children:de(n.credits)}),e.jsxs(es,{children:["($",n.usd.toFixed(2),")"]})]},n.id)})}),e.jsxs(ts,{children:[e.jsxs(as,{children:[e.jsx(ss,{}),e.jsx("span",{children:de((A==null?void 0:A.credits)??0)})]}),e.jsxs(ns,{children:["$",((A==null?void 0:A.usd)??0).toFixed(2)]})]}),e.jsxs(It,{children:[e.jsx(Se,{"data-variant":"outline",onClick:Y,children:s("buyModal.cancel")}),e.jsx(Se,{"data-variant":"gradient",onClick:D,children:s("buyModal.buy")})]})]})}const{colors:r,gradients:Pt,radius:Z}=le,zt="@media (max-width: 1080px)",T="@media (max-width: 880px)",jt=i.div`
61
+ `,Bs="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/buy-error-22UunaPC.png";function Rs(o){const{phase:l,balanceCredits:I,onClose:z}=o,W=l==="processing",D=l==="error"?a("cartCheckout.errorTitle"):l==="nofunds"?a("cartCheckout.titleNoFunds"):l==="choose"?a("buyModal.choosePayment"):a("cartCheckout.titleBuy"),Y=l==="processing";return e.jsxs(ja,{role:"dialog","aria-modal":"true","aria-label":a("cartCheckout.dialogAria"),children:[e.jsx(ka,{onClick:W?void 0:z,"aria-hidden":!0}),e.jsxs(Sa,{"data-tall":Y||void 0,children:[e.jsxs($a,{children:[e.jsxs(Ma,{children:[e.jsx(Ta,{children:D}),!W&&e.jsx(Ia,{onClick:z,"aria-label":a("buyModal.close"),children:e.jsx(Pa,{})})]}),e.jsxs(za,{children:[e.jsx(Aa,{children:l==="nofunds"?a("buyModal.dclBalance"):a("buyModal.myCreditsBalance")}),e.jsx(mt,{}),e.jsx(Ea,{children:le(I)})]})]}),l==="choose"&&e.jsxs(ke,{children:[e.jsxs(qs,{children:[e.jsx("span",{children:a("cart.purchaseSummary")}),e.jsxs("strong",{children:[e.jsx(mt,{}),le(o.totalCredits??0)]})]}),e.jsx(Tt,{options:o.options??[],totalCents:o.totalCents??0,onPay:o.onPay??(()=>{}),rateNote:(()=>{const A=qa(o.totalCents??0,o.totalManaWei??0n);return A!=null?a("buyModal.manaRate",{mana:A.toLocaleString("en",{maximumFractionDigits:2})}):null})()})]}),l==="processing"&&e.jsx(_s,{stage:o.stage??"reserving",step:o.step??1,total:o.total??1,isSelfCustody:!!o.isSelfCustody,signatures:o.signatures}),l==="nofunds"&&e.jsx(Ws,{lines:o.lines??[],shortfallCredits:o.shortfallCredits??0,packs:o.packs??[],selectedPack:o.selectedPack??"",onSelectPack:o.onSelectPack??(()=>{}),onBuyPacks:o.onBuyPacks??(()=>{}),onCancel:z}),l==="error"&&e.jsxs(ke,{children:[e.jsxs(Ba,{"data-testid":"buy-error",children:[e.jsx(Ra,{src:Bs,alt:"",width:64,height:80}),e.jsxs(_a,{children:[e.jsx("b",{children:a("cartCheckout.errorHeadline")})," ",o.message??a("cartCheckout.errorBody")]})]}),e.jsxs(It,{children:[e.jsx(Se,{"data-variant":"outline",onClick:z,children:a("buyModal.cancel")}),e.jsx(Se,{"data-variant":"purple",onClick:o.onRetry??z,children:a("cartCheckout.tryAgain")})]})]})]})]})}function _s({stage:o,step:l,total:I,isSelfCustody:z,signatures:W}){const D=o==="reserving",Y=I>0?Math.min(100,Math.round(l/I*100)):0,A=z&&W&&W.total>1,ne=o==="awaiting-signature"?z?A?a("cartCheckout.confirmMultiple",{current:W.current,total:W.total}):a("buyModal.confirmToContinue"):a("buyModal.completingTransaction"):o==="settling"?a("buyModal.completingTransaction"):a("cartCheckout.preparing");return e.jsxs(ke,{"data-processing":!0,children:[e.jsx(Wa,{src:sa,alt:"",width:61,height:61}),e.jsx(Fa,{children:ne}),D?e.jsxs(Ps,{children:[e.jsx(ft,{"aria-hidden":!0,children:e.jsx(yt,{"data-step":!0,style:{width:`${Y}%`}})}),I>1?e.jsxs(zs,{children:[l,"/",I]}):null]}):e.jsx(ft,{"aria-hidden":!0,children:e.jsx(yt,{})})]})}function Ws({lines:o,shortfallCredits:l,packs:I,selectedPack:z,onSelectPack:W,onBuyPacks:D,onCancel:Y}){const A=I.find(n=>n.id===z),ne=o.reduce((n,L)=>n+(L.quantity??1),0);return e.jsxs(ke,{children:[e.jsxs(La,{"data-testid":"nofunds-warning",children:[e.jsx(Ua,{}),e.jsxs(Ka,{children:[e.jsx("b",{children:a("buyModal.insufficientFunds")})," ",a("buyModal.warningNeedToBuy")," ",e.jsx("b",{children:a("buyModal.warningCreditsAmount",{count:Math.max(0,l)})})," ",a("buyModal.warningToPurchase",{count:ne})]})]}),e.jsx(As,{children:o.map(n=>{const L=n.quantity??1;return e.jsxs(Qa,{children:[e.jsx(Na,{children:n.item.thumbnail?e.jsx("img",{src:n.item.thumbnail,alt:""}):null}),e.jsxs(Ha,{children:[e.jsxs("div",{children:[e.jsxs(Oa,{title:n.item.name,children:[n.item.name||a("buyModal.itemFallback"),L>1?e.jsx(Es,{children:a("cartCheckout.qty",{count:L})}):null]}),n.item.creator?e.jsx(Va,{address:n.item.creator}):null]}),e.jsxs(Ga,{children:[e.jsx(Da,{}),e.jsx("span",{children:le(n.priceCredits*L)})]})]})]},n.item.id)})}),e.jsx(Ya,{children:I.map(n=>{const L=n.id===z;return e.jsxs(Ja,{"data-testid":"credit-pack","data-on":L||void 0,onClick:()=>W(n.id),children:[e.jsx(Xa,{}),e.jsx(Za,{children:le(n.credits)}),e.jsxs(es,{children:["($",n.usd.toFixed(2),")"]})]},n.id)})}),e.jsxs(ts,{children:[e.jsxs(as,{children:[e.jsx(ss,{}),e.jsx("span",{children:le((A==null?void 0:A.credits)??0)})]}),e.jsxs(ns,{children:["$",((A==null?void 0:A.usd)??0).toFixed(2)]})]}),e.jsxs(It,{children:[e.jsx(Se,{"data-variant":"outline",onClick:Y,children:a("buyModal.cancel")}),e.jsx(Se,{"data-variant":"gradient",onClick:D,children:a("buyModal.buy")})]})]})}const{colors:r,gradients:Pt,radius:Z}=ue,zt="@media (max-width: 1080px)",T="@media (max-width: 880px)",jt=i.div`
62
62
  max-width: 1510px;
63
63
  margin: 0 auto;
64
64
  /* Grows into the page's leftover height and passes it down to Upsell, so the white cross-sell band ends at
@@ -158,7 +158,7 @@ import{j as e,L as $e,r as P,d as ta,b as aa}from"./react-DehiWSvs.js";import{t
158
158
  text-align: center;
159
159
  color: ${r.text};
160
160
 
161
- ${le.media.maxWidth("mobile")} {
161
+ ${ue.media.maxWidth("mobile")} {
162
162
  min-height: 320px;
163
163
  padding: 32px 16px;
164
164
  }
@@ -174,7 +174,7 @@ import{j as e,L as $e,r as P,d as ta,b as aa}from"./react-DehiWSvs.js";import{t
174
174
  font-weight: 700;
175
175
  line-height: 1.6;
176
176
 
177
- ${le.media.maxWidth("mobile")} {
177
+ ${ue.media.maxWidth("mobile")} {
178
178
  font-size: 20px;
179
179
  }
180
180
  `,Hs=i.p`
@@ -183,7 +183,7 @@ import{j as e,L as $e,r as P,d as ta,b as aa}from"./react-DehiWSvs.js";import{t
183
183
  font-weight: 400;
184
184
  line-height: 1.6;
185
185
 
186
- ${le.media.maxWidth("mobile")} {
186
+ ${ue.media.maxWidth("mobile")} {
187
187
  font-size: 16px;
188
188
  }
189
189
  `,Os=i($e)`
@@ -692,4 +692,4 @@ import{j as e,L as $e,r as P,d as ta,b as aa}from"./react-DehiWSvs.js";import{t
692
692
  & section {
693
693
  margin-top: 0;
694
694
  }
695
- `;function Ue(o){if($s(o))return s("errors.rejected");const l=(o.message??"").toLowerCase();return l.includes("insufficient")?s("cart.error.insufficient",{currency:va.name}):l.includes("no active listing")||l.includes("your own listing")?s("cart.error.listingChanged"):s("marketCheckout.error.generic")}const En=12e4;function qn(o){const l=[];return o.unavailable.length&&l.push(s("cart.drop.unavailable",{count:o.unavailable.length})),o.own.length&&l.push(s("cart.drop.own",{count:o.own.length})),s("cart.drop.removed",{items:l.join(` ${s("cart.drop.and")} `)})}const Ke=o=>o.reduce((l,I)=>l+I.priceCredits*I.quantity,0),je=o=>o.flatMap(l=>Array.from({length:l.quantity},()=>({...l,quantity:1})));function Yn(){ia({title:s("nav.cart"),noindex:!0});const o=N(t=>t.items),l=N(t=>t.remove),I=N(t=>t.increment),z=N(t=>t.decrement),W=N(t=>t.clear),D=N(t=>t.restore),Y=N(t=>t.setFittingOpen),A=dt(t=>t.items),ne=dt(t=>t.toggle),{session:n,signIn:L}=ra(),Rt=oa(),ue=Cs().packs.slice(0,js);P.useEffect(()=>(document.body.classList.add("shop-cart-bg"),()=>document.body.classList.remove("shop-cart-bg")),[]);const _t=o.some(t=>t.category!=="emote"),{data:Me}=ca({queryKey:["upsell-listings"],queryFn:()=>Ca({first:40}),staleTime:6e4}),{data:S}=da(n),b=la(),ee=ta(),{state:J}=aa(),[Wt,ie]=P.useState(null),[Ne,he]=P.useState(null),[Ft,B]=P.useState(!1),[R,O]=P.useState(null),He=P.useRef(0),[p,j]=P.useState(null),{data:pe}=ua(n),{data:re}=ha(!0),[Te,Oe]=P.useState(""),oe=P.useRef(null),Ve=pa(o),Ge=t=>ut(Ve[t.id]),Ie=o.filter(Ge),Pe=o.length>0&&Ie.length===0,Lt=Ie.reduce((t,a)=>t+a.priceCredits*a.quantity,0),Ut=o.reduce((t,a)=>t+a.quantity,0),Kt=Ie.reduce((t,a)=>t+a.quantity,0),De=R?R.liveTotalCredits:Lt,Qt=new Set(o.map(t=>t.id)),Ye=((Me==null?void 0:Me.items)??[]).filter(t=>!Qt.has(t.id)).slice(0,12),Nt=new Map(R==null?void 0:R.buyable.map(t=>[t.item.id,t])),ge=(S==null?void 0:S.credits)??0,ze=De*10,Ht=re?lt(ze,re):0n,xe=Fe({priceCents:ze,priceManaWei:Ht,balanceCents:(S==null?void 0:S.balanceCents)??0,manaBalanceWei:pe??0n}),Ot=t=>t.some(a=>a.acquisition==="store"),Ae=t=>t.flatMap(a=>a.acquisition==="trade"?[a]:[]),Vt=fa,Gt=t=>ba(t.contractAddress,String(t.itemId));function me(t){t(),O(null),he(null),ie(null)}function Dt(){j(null),B(!1)}function Je(t){const a=Ke(t),d=Math.max(0,a-ge),c=ue.find(u=>u.credits>=d)??ue[ue.length-1];Oe(c.id),G("Shop Buy Credits Prompted",{from:"cart_checkout",credits_needed:a,credits_balance:ge,shortfall:d}),j({phase:"nofunds",lines:t.map(u=>({item:u.item,priceCredits:u.priceCredits,quantity:u.quantity})),shortfall:d}),B(!1)}async function Ee(t){if(!n||t.length===0)return;const a=je(t),d=a.map(y=>({...y.item,priceCredits:y.priceCredits})),c=t.map(y=>({...y.item,priceCredits:y.priceCredits,quantity:y.quantity})),u=[];let h="authorize";const w=new Set,$=new Set,_=new Set,E=[];let q=!1;j({phase:"processing",stage:"reserving",step:1,total:a.length});try{const y=[];for(let m=0;m<a.length;m++){const x=a[m];j({phase:"processing",stage:"reserving",step:m+1,total:a.length});try{const M=x.acquisition==="trade"?x.trade.id:void 0,C=x.item.contractAddress&&x.item.itemId!=null?{contractAddress:x.item.contractAddress,itemId:String(x.item.itemId)}:void 0,{credit:Q,maxCreditedValue:X}=await gt(n.identity,x.usdCents,M,C);u.push({salt:Q.id,itemId:x.item.id}),y.push(x.acquisition==="store"?{kind:"store",item:{collection:x.item.contractAddress,itemId:String(x.item.itemId),priceWei:x.priceWei},credits:[Q],maxCreditedValue:X,chainId:x.item.chainId}:{kind:"trade",trade:x.trade,credits:[Q],maxCreditedValue:X})}catch(M){if(Ms(M)){if(u.length){try{await _e(n.identity,u.map(C=>C.salt))}catch(C){ae(C,{flow:"cart_checkout",step:"release"})}b.invalidateQueries({queryKey:["usd-balance"]})}Je(t);return}throw M}}h="submit";const g=ys(y).length,k=m=>g>1?{current:m,total:g}:void 0,F=(m,x)=>j({phase:"processing",stage:m,step:a.length,total:a.length,signatures:k(x)}),U=m=>m<g?F("awaiting-signature",m+1):F("settling",g);F("awaiting-signature",1);let f=[];const v=y.some(m=>m.kind==="store"),K=y.flatMap(m=>m.kind==="trade"?[m]:[]);if(hs()&&!v)try{const m=new Map;f=await bs({purchases:K,buyer:n.address,signer:n.signer,onSigned:()=>U(g),onBroadcast:({txHash:C,salts:Q})=>{m.set(C,Q),Q.forEach(X=>w.add(X))}});const x=await Promise.allSettled(f.map(C=>vs(C)));x.forEach((C,Q)=>{const X=m.get(f[Q])??[];C.status==="fulfilled"?(X.forEach(Re=>$.add(Re)),E.push(f[Q])):C.reason instanceof wt||X.forEach(Re=>_.add(Re))});const M=x.flatMap(C=>C.status==="rejected"?[C.reason]:[]);if(M.length&&!M.some(C=>C instanceof wt))throw M[0];q=!0}catch(m){if(!(m instanceof ws))throw m;f=await Le({purchases:y,buyer:n.address,signer:n.signer,onSigned:U,onBroadcast:({salts:x})=>x.forEach(M=>w.add(M)),onSettled:({txHash:x,salts:M})=>{M.forEach(C=>$.add(C)),E.push(x)},onReverted:({salts:x})=>x.forEach(M=>_.add(M))})}else f=await Le({purchases:y,buyer:n.address,signer:n.signer,onSigned:U,onBroadcast:({salts:m})=>m.forEach(x=>w.add(x)),onSettled:({txHash:m,salts:x})=>{x.forEach(M=>$.add(M)),E.push(m)},onReverted:({salts:m})=>m.forEach(x=>_.add(x))});t.forEach(m=>l(m.item.id)),O(null),G("Shop Completed Purchase",{...ye(d),payment_type:"credits",no_crypto_step:q,transaction_hash:f[0]??null}),vt(b);const ce=oe.current;oe.current=null,j(null),B(!1);const Be={items:c,txHash:f[0]??void 0,txHashes:f,settled:!0,...ce?{creditsAdded:ce}:{}};ee("/success",{state:Be,replace:!0})}catch(y){be(y)||ae(y,{flow:"cart_checkout",step:h,cart_size:t.length});const g=new Set([...w].filter(v=>!_.has(v))),{toRelease:k,boughtItemIds:F}=Ct({reservations:u,spent:g,settled:$}),U=d.filter(v=>F.includes(v.id)),f=d.filter(v=>!F.includes(v.id));if(G(be(y)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:h,error_code:xt(y),value_usd:ht(f.reduce((v,K)=>v+K.priceCredits,0)),cart_size:a.length,partial:U.length>0}),k.length)try{await _e(n.identity,k)}catch(v){ae(v,{flow:"cart_checkout",step:"release"})}if(b.invalidateQueries({queryKey:["usd-balance"]}),U.length>0){F.forEach(v=>l(v)),O(null),vt(b),G("Shop Completed Purchase",{...ye(U),payment_type:"credits",no_crypto_step:q,transaction_hash:E[0]??null,partial:!0}),j({phase:"error",message:s("cart.error.partiallyBought")}),B(!1);return}j({phase:"error",message:Ue(y)})}}function Xe(t,a){b.invalidateQueries({queryKey:["usd-balance"]}),b.invalidateQueries({queryKey:["detail-trade"]}),b.invalidateQueries({queryKey:["shop-item"]}),b.invalidateQueries({queryKey:["owned-token"]}),b.invalidateQueries({queryKey:["public-token"]}),b.invalidateQueries({queryKey:["item-resales"]}),b.invalidateQueries({queryKey:["shop-items"]}),b.invalidateQueries({queryKey:["catalog-items"]}),b.invalidateQueries({queryKey:["my-assets"]}),b.invalidateQueries({queryKey:["purchases"]}),b.invalidateQueries({queryKey:["owned-item-count"]}),b.invalidateQueries({queryKey:["overview-listings"]}),b.invalidateQueries({queryKey:["upsell-listings"]});const d=oe.current;oe.current=null,j(null),B(!1);const c={items:t,txHash:a[0]??void 0,txHashes:a,settled:!0,...d?{creditsAdded:d}:{}};ee("/success",{state:c,replace:!0})}function Ze(t,a){be(t)||ae(t,{flow:a,step:"submit"}),G(be(t)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:xt(t)}),j({phase:"error",message:Ue(t)}),B(!1)}async function Yt(t,a){const d=ve(We.MANAToken,a),c=ve(We.CreditsManager,a);await ms({auth:{kind:fs.Allowance,contractAddress:d.address,spenderAddress:c.address,chainId:a},signer:t})}async function et(){if(re)return re;try{return await b.fetchQuery({queryKey:["mana-rate",pt.chainId],queryFn:()=>ya(pt.chainId),staleTime:6e4})}catch{return}}async function Jt(t){const a=je(t).reduce((h,w)=>h+w.usdCents,0),c=(pe??0n)>0n?await et():re,u=c?lt(a,c):0n;return{totalCents:a,manaWei:u}}async function tt(t,a){const d=Ke(t),{totalCents:c,manaWei:u}=await Jt(t),h=Fe({priceCents:c,priceManaWei:u,balanceCents:(S==null?void 0:S.balanceCents)??0,manaBalanceWei:pe??0n}),w=Ot(t)?{...h,options:h.options.filter($=>$.method==="credits")}:h;if(a&&w.options.some($=>$.method===a)){if(a==="credits"){Ee(t);return}const{spender:$,chainId:_}=at(a,t);await st($,_,()=>a==="mana"?void nt(t):void it(t,c,u));return}if(w.options.some($=>$.method==="mana"||$.method==="combined")){j({phase:"choose",lines:t,totalCents:c,manaWei:u}),B(!1);return}if(S!=null&&S.credits<d){Je(t);return}Ee(t)}function Xt(t){return Fe({priceCents:t.totalCents,priceManaWei:t.manaWei,balanceCents:(S==null?void 0:S.balanceCents)??0,manaBalanceWei:pe??0n})}const[qe,fe]=P.useState(null);function at(t,a){const d=Ae(a)[0].trade;return{spender:t==="mana"?ve(wa(d.contract),d.chainId).address:ve(We.CreditsManager,d.chainId).address,chainId:d.chainId}}async function st(t,a,d){const c=ps(a,t),u=n?await gs(c,n.address).catch(()=>!0):!0;if(xs(n==null?void 0:n.providerType,u)){B(!1),fe({auth:c,run:d});return}d()}function Zt(t){if((p==null?void 0:p.phase)!=="choose")return;const{lines:a,totalCents:d,manaWei:c}=p;if(t==="credits"){Ee(a);return}const{spender:u,chainId:h}=at(t,a);st(u,h,()=>t==="mana"?void nt(a):void it(a,d,c))}async function nt(t){if(!n||t.length===0)return;const a=je(t),d=a.map(h=>({...h.item,priceCredits:h.priceCredits})),c=t.map(h=>({...h.item,priceCredits:h.priceCredits,quantity:h.quantity})),u=()=>j({phase:"processing",stage:"settling",step:a.length,total:a.length});j({phase:"processing",stage:"awaiting-signature",step:a.length,total:a.length});try{const h=await ds({trades:Ae(a).map(w=>w.trade),buyer:n.address,signer:n.signer,onSigned:u});t.forEach(w=>l(w.item.id)),O(null),G("Shop Completed Purchase",{...ye(d),payment_type:"mana",transaction_hash:h[0]??null}),b.invalidateQueries({queryKey:["mana-balance"]}),Xe(c,h)}catch(h){Ze(h,"buy_cart_mana")}}async function it(t,a,d){if(!n||t.length===0)return;const c=je(t),u=c.map(g=>({...g.item,priceCredits:g.priceCredits})),h=t.map(g=>({...g.item,priceCredits:g.priceCredits,quantity:g.quantity})),w=ls(c.map(g=>g.usdCents),(S==null?void 0:S.balanceCents)??0),$=w.reduce((g,k)=>g+k,0),_=us(Math.max(0,a-$),a,d),E=[],q=new Set,y=new Set;j({phase:"processing",stage:"reserving",step:1,total:c.length});try{const g=Ae(c),k=[];for(let f=0;f<g.length;f++){const v=w[f];if(v<=0)continue;j({phase:"processing",stage:"reserving",step:f+1,total:g.length});const K=g[f].item,{credit:ce,maxCreditedValue:Be}=await gt(n.identity,v,g[f].trade.id,K.contractAddress&&K.itemId!=null?{contractAddress:K.contractAddress,itemId:String(K.itemId)}:void 0);E.push({salt:ce.id,itemId:K.id}),k.push({kind:"trade",trade:g[f].trade,credits:[ce],maxCreditedValue:Be})}g.forEach((f,v)=>{w[v]<=0&&k.push({kind:"trade",trade:f.trade,credits:[],maxCreditedValue:"0"})}),k[0]={...k[0],maxCreditedValue:(BigInt(k[0].maxCreditedValue)+_).toString()},await Yt(n.signer,g[0].trade.chainId);const F=()=>j({phase:"processing",stage:"settling",step:c.length,total:c.length});j({phase:"processing",stage:"awaiting-signature",step:c.length,total:c.length});const U=await Le({purchases:k,buyer:n.address,signer:n.signer,onSigned:F,onBroadcast:({salts:f})=>f.forEach(v=>q.add(v)),onReverted:({salts:f})=>f.forEach(v=>y.add(v))});t.forEach(f=>l(f.item.id)),O(null),G("Shop Completed Purchase",{...ye(u),payment_type:"credits_and_mana",transaction_hash:U[0]??null}),b.invalidateQueries({queryKey:["mana-balance"]}),Xe(h,U)}catch(g){const{toRelease:k}=Ct({reservations:E,spent:new Set([...q].filter(F=>!y.has(F))),settled:new Set});k.length&&_e(n.identity,k).catch(()=>{}),E.length&&b.invalidateQueries({queryKey:["usd-balance"]}),Ze(g,"buy_cart_combined")}}async function te(t){if(!n){bt({type:"cart-checkout"}),L();return}const a=N.getState().items.filter(Ge);if(a.length===0)return;ie(null),he(null),B(!0);const d=a.reduce((c,u)=>c+u.priceCredits*u.quantity,0);G("Shop Started Checkout",{cart_size:a.length,cart_value_credits:d,cart_value_usd:ht(d),has_sufficient_credits:ge>=d});try{const c=await ks(a,n.address,Vt,await et(),Gt),u=[...c.unavailable,...c.own];if(u.length&&(u.forEach(h=>l(h.id)),he(qn(c))),c.buyable.length===0){ie(s("cart.error.noneAvailable")),O(null);return}if(c.orderChanged){O(c),He.current=Date.now();return}await tt(c.buyable,t)}catch(c){ae(c,{flow:"cart_checkout",step:"review",cart_size:a.length}),ie(Ue(c))}finally{B(!1)}}async function rt(){if(R){if(!n){bt({type:"cart-checkout"}),L();return}if(Date.now()-He.current>En){O(null),he(null),await te();return}ie(null),tt(R.buyable)}}async function ea(){if(Te){try{sessionStorage.setItem(we,JSON.stringify(N.getState().items))}catch{}B(!0);try{const t=await Ss(Te,n?{address:n.address,identity:n.identity}:void 0);if(t.url){window.location.href=t.url;return}ee("/credits")}catch(t){try{sessionStorage.removeItem(we)}catch{}ae(t,{flow:"cart_buy_credits"}),j({phase:"error",message:s("buyModal.error.creditsCheckout")})}finally{B(!1)}}}const ot=P.useRef(!1);P.useEffect(()=>{if(!n||ot.current||!is("cart-checkout"))return;ot.current=!0;const t=setTimeout(()=>void te(),0);return()=>clearTimeout(t)},[n]);const ct=P.useRef(!1);P.useEffect(()=>{if(!(J!=null&&J.resumeCheckout)||ct.current)return;ct.current=!0,oe.current=J.creditsAdded??null;try{const a=sessionStorage.getItem(we);if(a){sessionStorage.removeItem(we);const d=JSON.parse(a);Array.isArray(d)&&d.length&&D(d)}}catch{}b.invalidateQueries({queryKey:["usd-balance"]});const t=setTimeout(()=>void te(),0);return()=>clearTimeout(t)},[J==null?void 0:J.resumeCheckout]);const V=Ft||(p==null?void 0:p.phase)==="processing";return o.length===0&&!p?e.jsx(jt,{children:e.jsxs(St,{children:[e.jsxs(kt,{onClick:()=>ee(-1),type:"button",children:[e.jsx(H,{name:"arrow-left"}),s("nav.cart")]}),e.jsxs(Ks,{"data-testid":"cart-empty",children:[e.jsx(H,{name:"cart-plus",size:110}),e.jsxs(Qs,{children:[e.jsx(Ns,{children:s("cart.empty.title")}),e.jsx(Hs,{children:s("cart.empty.body")})]}),e.jsx(Os,{to:"/items",children:s("cart.empty.cta")})]})]})}):e.jsxs(jt,{children:[e.jsxs(St,{children:[e.jsxs(kt,{onClick:()=>ee(-1),type:"button",children:[e.jsx(H,{name:"arrow-left"}),s("nav.cart")]}),e.jsxs(Fs,{children:[e.jsxs(Ls,{children:[e.jsxs(Us,{children:[e.jsx(Vs,{onClick:()=>ee(-1),type:"button","aria-label":s("cart.goBack"),children:e.jsx(H,{name:"arrow-left"})}),e.jsx(Gs,{children:s("cart.panelTitle",{count:Ut})}),_t?e.jsxs(Ds,{onClick:()=>Y(!0),disabled:V,children:[e.jsx(H,{name:"fitting-room"}),s("cart.fittingRoom")]}):null]}),e.jsxs(At,{children:[e.jsx(Ys,{children:o.map(t=>{const a=Nt.get(t.id),d=a?a.priceCredits:t.priceCredits,c=!!a&&a.priceCredits!==t.priceCredits,u=!t.tokenId,h=t.quantity,w=typeof t.available=="number"&&h>=t.available,$=d*h,_=ga(t),E=!!_&&!!A[_],q=xa(t),y=Ve[t.id],g=!ut(y),k=y==="sold-out"?s("cart.availability.soldOut"):s("cart.availability.unavailable");return e.jsxs(Js,{"data-unavailable":g||void 0,children:[e.jsxs(Xs,{"data-thumb":!0,children:[q?e.jsx(Zs,{to:q,state:{item:t,tradeId:t.tradeId},"aria-label":t.name,children:t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:t.name}):null}):t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:t.name}):null,e.jsx(en,{"data-check":!0,"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 20 20",width:"12",height:"12",children:e.jsx("path",{d:"M5 10.5l3 3 7-7.5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs(tn,{children:[e.jsxs(an,{"data-desc":!0,children:[q?e.jsx(nn,{to:q,state:{item:t,tradeId:t.tradeId},title:t.name,children:t.name}):e.jsx(sn,{title:t.name,children:t.name}),t.creator?e.jsx(rn,{address:t.creator,linkToProfile:!0}):null,Rt&&u?e.jsxs(fn,{"data-testid":"cart-creator-tag",children:[e.jsx(yn,{name:"buy-from-creator"}),s("cart.creatorTag")]}):null]}),e.jsx(on,{children:g?e.jsxs(e.Fragment,{children:[e.jsxs(gn,{children:[e.jsx(xn,{name:"warning-fill",size:24}),k]}),q?e.jsx(mn,{to:q,state:{item:t,tradeId:t.tradeId},children:s("cart.availability.viewResales")}):null]}):e.jsxs(e.Fragment,{children:[u?e.jsxs(cn,{children:[e.jsx($t,{onClick:()=>me(()=>z(t.id)),disabled:V||h<=1,"aria-label":s("cart.decreaseQuantity",{name:t.name}),children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),e.jsx(dn,{children:h}),e.jsx($t,{onClick:()=>me(()=>I(t.id)),disabled:V||w,"aria-label":s("cart.increaseQuantity"),children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M8 3.5v9M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}):null,e.jsxs(ln,{children:[e.jsx(un,{})," ",$,c?e.jsx(hn,{children:t.priceCredits*h}):null]})]})})]}),e.jsxs(pn,{children:[_?e.jsx(bn,{"data-on":E||void 0,onClick:()=>ne(t),"aria-label":E?s("cart.removeFromFavorites",{name:t.name}):s("cart.addToFavorites",{name:t.name}),title:E?s("assetCard.removeFromFavorites"):s("assetCard.addToFavorites"),children:e.jsx(H,{name:E?"heart-solid":"heart"})}):null,e.jsx(vn,{onClick:()=>me(()=>l(t.id)),disabled:V,"aria-label":s("cart.remove",{name:t.name}),title:s("cart.removeTitle"),children:e.jsx(H,{name:"trash",size:24})})]})]},t.id)})}),e.jsx(wn,{children:e.jsx("button",{className:"link",onClick:()=>me(W),disabled:V,children:s("cart.clearCart")})})]})]}),e.jsxs(Cn,{children:[e.jsx(jn,{children:s("cart.purchaseSummary")}),e.jsxs(kn,{children:[e.jsxs(Sn,{children:[e.jsx($n,{children:s("cart.totalItems",{count:Kt})}),e.jsx(Tn,{children:e.jsxs(Mn,{children:[e.jsx(In,{})," ",De]})})]}),xe.options.length>0||xe.manaShortfall?e.jsx(Tt,{options:xe.options,totalCents:ze,shortfall:xe.manaShortfall,creditsLabel:R?s("marketCheckout.confirmPurchase"):s("cart.buyWithCredits"),busy:V||Pe,onPay:t=>void(R?rt():te(t))}):e.jsx(Pn,{onClick:()=>void(R?rt():te()),disabled:V||Pe,children:V?s("cart.working"):R?s("marketCheckout.confirmPurchase"):s("cart.checkout")}),Pe?e.jsx(Ce,{className:"muted",children:s("cart.allUnavailable")}):null,n?null:e.jsx(Ce,{className:"muted",children:s("cart.signInHint")}),R?e.jsx(Ce,{className:"muted",children:s("cart.priceChanged")}):null,Ne?e.jsx(Ce,{className:"muted",children:Ne}):null,e.jsx(zn,{message:Wt})]})]})]})]}),Ye.length>0?e.jsx(An,{children:e.jsx(rs,{title:s("cart.youMightAlsoLike"),items:Ye})}):null,qe&&n?e.jsx(os,{auth:qe.auth,signer:n.signer,title:s("authorizeStep.manaTitle"),name:s("authorizeStep.manaName"),reason:s("authorizeStep.manaReason"),icon:e.jsx("img",{src:cs,width:24,height:24,alt:"","aria-hidden":!0}),onAuthorized:()=>{const{run:t}=qe;fe(null),t()},onCancel:()=>fe(null),onClose:()=>fe(null)}):null,p?e.jsx(Rs,{phase:p.phase,balanceCredits:ge,onClose:Dt,stage:p.phase==="processing"?p.stage:void 0,step:p.phase==="processing"?p.step:void 0,total:p.phase==="processing"?p.total:void 0,isSelfCustody:ma(n==null?void 0:n.providerType),signatures:p.phase==="processing"?p.signatures:void 0,options:p.phase==="choose"?Xt(p).options:void 0,onPay:Zt,totalCents:p.phase==="choose"?p.totalCents:void 0,totalManaWei:p.phase==="choose"?p.manaWei:void 0,totalCredits:p.phase==="choose"?Ke(p.lines):void 0,lines:p.phase==="nofunds"?p.lines:void 0,shortfallCredits:p.phase==="nofunds"?p.shortfall:void 0,packs:ue,selectedPack:Te,onSelectPack:Oe,onBuyPacks:()=>void ea(),message:p.phase==="error"?p.message:void 0,onRetry:()=>void te()}):null]})}export{Yn as Cart};
695
+ `;function Ue(o){if($s(o))return a("errors.rejected");const l=(o.message??"").toLowerCase();return l.includes("insufficient")?a("cart.error.insufficient",{currency:va.name}):l.includes("no active listing")||l.includes("your own listing")?a("cart.error.listingChanged"):a("marketCheckout.error.generic")}const En=12e4;function qn(o){const l=[];return o.unavailable.length&&l.push(a("cart.drop.unavailable",{count:o.unavailable.length})),o.own.length&&l.push(a("cart.drop.own",{count:o.own.length})),a("cart.drop.removed",{items:l.join(` ${a("cart.drop.and")} `)})}const Ke=o=>o.reduce((l,I)=>l+I.priceCredits*I.quantity,0),je=o=>o.flatMap(l=>Array.from({length:l.quantity},()=>({...l,quantity:1})));function Yn(){ia({title:a("nav.cart"),noindex:!0});const o=N(t=>t.items),l=N(t=>t.remove),I=N(t=>t.increment),z=N(t=>t.decrement),W=N(t=>t.clear),D=N(t=>t.restore),Y=N(t=>t.setFittingOpen),A=dt(t=>t.items),ne=dt(t=>t.toggle),{session:n,signIn:L}=ra(),Rt=oa(),he=Cs().packs.slice(0,js);P.useEffect(()=>(document.body.classList.add("shop-cart-bg"),()=>document.body.classList.remove("shop-cart-bg")),[]);const _t=o.some(t=>t.category!=="emote"),{data:Me}=ca({queryKey:["upsell-listings"],queryFn:()=>Ca({first:40}),staleTime:6e4}),{data:S}=da(n),b=la(),ee=ta(),{state:J}=aa(),[Wt,ie]=P.useState(null),[Ne,pe]=P.useState(null),[Ft,B]=P.useState(!1),[R,O]=P.useState(null),He=P.useRef(0),[p,j]=P.useState(null),{data:ge}=ua(n),{data:re}=ha(!0),[Te,Oe]=P.useState(""),oe=P.useRef(null),Ve=pa(o),Ge=t=>ut(Ve[t.id]),Ie=o.filter(Ge),Pe=o.length>0&&Ie.length===0,Lt=Ie.reduce((t,s)=>t+s.priceCredits*s.quantity,0),Ut=o.reduce((t,s)=>t+s.quantity,0),Kt=Ie.reduce((t,s)=>t+s.quantity,0),De=R?R.liveTotalCredits:Lt,Qt=new Set(o.map(t=>t.id)),Ye=((Me==null?void 0:Me.items)??[]).filter(t=>!Qt.has(t.id)).slice(0,12),Nt=new Map(R==null?void 0:R.buyable.map(t=>[t.item.id,t])),xe=(S==null?void 0:S.credits)??0,ze=De*10,Ht=re?lt(ze,re):0n,ce=Fe({priceCents:ze,priceManaWei:Ht,balanceCents:(S==null?void 0:S.balanceCents)??0,manaBalanceWei:ge??0n}),Ot=t=>t.some(s=>s.acquisition==="store"),Ae=t=>t.flatMap(s=>s.acquisition==="trade"?[s]:[]),Vt=fa,Gt=t=>ba(t.contractAddress,String(t.itemId));function me(t){t(),O(null),pe(null),ie(null)}function Dt(){j(null),B(!1)}function Je(t){const s=Ke(t),d=Math.max(0,s-xe),c=he.find(u=>u.credits>=d)??he[he.length-1];Oe(c.id),G("Shop Buy Credits Prompted",{from:"cart_checkout",credits_needed:s,credits_balance:xe,shortfall:d}),j({phase:"nofunds",lines:t.map(u=>({item:u.item,priceCredits:u.priceCredits,quantity:u.quantity})),shortfall:d}),B(!1)}async function Ee(t){if(!n||t.length===0)return;const s=je(t),d=s.map(y=>({...y.item,priceCredits:y.priceCredits})),c=t.map(y=>({...y.item,priceCredits:y.priceCredits,quantity:y.quantity})),u=[];let h="authorize";const w=new Set,$=new Set,_=new Set,E=[];let q=!1;j({phase:"processing",stage:"reserving",step:1,total:s.length});try{const y=[];for(let m=0;m<s.length;m++){const x=s[m];j({phase:"processing",stage:"reserving",step:m+1,total:s.length});try{const M=x.acquisition==="trade"?x.trade.id:void 0,C=x.item.contractAddress&&x.item.itemId!=null?{contractAddress:x.item.contractAddress,itemId:String(x.item.itemId)}:void 0,{credit:Q,maxCreditedValue:X}=await gt(n.identity,x.usdCents,M,C);u.push({salt:Q.id,itemId:x.item.id}),y.push(x.acquisition==="store"?{kind:"store",item:{collection:x.item.contractAddress,itemId:String(x.item.itemId),priceWei:x.priceWei},credits:[Q],maxCreditedValue:X,chainId:x.item.chainId}:{kind:"trade",trade:x.trade,credits:[Q],maxCreditedValue:X})}catch(M){if(Ms(M)){if(u.length){try{await _e(n.identity,u.map(C=>C.salt))}catch(C){ae(C,{flow:"cart_checkout",step:"release"})}b.invalidateQueries({queryKey:["usd-balance"]})}Je(t);return}throw M}}h="submit";const g=ys(y).length,k=m=>g>1?{current:m,total:g}:void 0,F=(m,x)=>j({phase:"processing",stage:m,step:s.length,total:s.length,signatures:k(x)}),U=m=>m<g?F("awaiting-signature",m+1):F("settling",g);F("awaiting-signature",1);let f=[];const v=y.some(m=>m.kind==="store"),K=y.flatMap(m=>m.kind==="trade"?[m]:[]);if(hs()&&!v)try{const m=new Map;f=await bs({purchases:K,buyer:n.address,signer:n.signer,onSigned:()=>U(g),onBroadcast:({txHash:C,salts:Q})=>{m.set(C,Q),Q.forEach(X=>w.add(X))}});const x=await Promise.allSettled(f.map(C=>vs(C)));x.forEach((C,Q)=>{const X=m.get(f[Q])??[];C.status==="fulfilled"?(X.forEach(Re=>$.add(Re)),E.push(f[Q])):C.reason instanceof wt||X.forEach(Re=>_.add(Re))});const M=x.flatMap(C=>C.status==="rejected"?[C.reason]:[]);if(M.length&&!M.some(C=>C instanceof wt))throw M[0];q=!0}catch(m){if(!(m instanceof ws))throw m;f=await Le({purchases:y,buyer:n.address,signer:n.signer,onSigned:U,onBroadcast:({salts:x})=>x.forEach(M=>w.add(M)),onSettled:({txHash:x,salts:M})=>{M.forEach(C=>$.add(C)),E.push(x)},onReverted:({salts:x})=>x.forEach(M=>_.add(M))})}else f=await Le({purchases:y,buyer:n.address,signer:n.signer,onSigned:U,onBroadcast:({salts:m})=>m.forEach(x=>w.add(x)),onSettled:({txHash:m,salts:x})=>{x.forEach(M=>$.add(M)),E.push(m)},onReverted:({salts:m})=>m.forEach(x=>_.add(x))});t.forEach(m=>l(m.item.id)),O(null),G("Shop Completed Purchase",{...ye(d),payment_type:"credits",no_crypto_step:q,transaction_hash:f[0]??null}),vt(b);const de=oe.current;oe.current=null,j(null),B(!1);const Be={items:c,txHash:f[0]??void 0,txHashes:f,settled:!0,...de?{creditsAdded:de}:{}};ee("/success",{state:Be,replace:!0})}catch(y){be(y)||ae(y,{flow:"cart_checkout",step:h,cart_size:t.length});const g=new Set([...w].filter(v=>!_.has(v))),{toRelease:k,boughtItemIds:F}=Ct({reservations:u,spent:g,settled:$}),U=d.filter(v=>F.includes(v.id)),f=d.filter(v=>!F.includes(v.id));if(G(be(y)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:h,error_code:xt(y),value_usd:ht(f.reduce((v,K)=>v+K.priceCredits,0)),cart_size:s.length,partial:U.length>0}),k.length)try{await _e(n.identity,k)}catch(v){ae(v,{flow:"cart_checkout",step:"release"})}if(b.invalidateQueries({queryKey:["usd-balance"]}),U.length>0){F.forEach(v=>l(v)),O(null),vt(b),G("Shop Completed Purchase",{...ye(U),payment_type:"credits",no_crypto_step:q,transaction_hash:E[0]??null,partial:!0}),j({phase:"error",message:a("cart.error.partiallyBought")}),B(!1);return}j({phase:"error",message:Ue(y)})}}function Xe(t,s){b.invalidateQueries({queryKey:["usd-balance"]}),b.invalidateQueries({queryKey:["detail-trade"]}),b.invalidateQueries({queryKey:["shop-item"]}),b.invalidateQueries({queryKey:["owned-token"]}),b.invalidateQueries({queryKey:["public-token"]}),b.invalidateQueries({queryKey:["item-resales"]}),b.invalidateQueries({queryKey:["shop-items"]}),b.invalidateQueries({queryKey:["catalog-items"]}),b.invalidateQueries({queryKey:["my-assets"]}),b.invalidateQueries({queryKey:["purchases"]}),b.invalidateQueries({queryKey:["owned-item-count"]}),b.invalidateQueries({queryKey:["overview-listings"]}),b.invalidateQueries({queryKey:["upsell-listings"]});const d=oe.current;oe.current=null,j(null),B(!1);const c={items:t,txHash:s[0]??void 0,txHashes:s,settled:!0,...d?{creditsAdded:d}:{}};ee("/success",{state:c,replace:!0})}function Ze(t,s){be(t)||ae(t,{flow:s,step:"submit"}),G(be(t)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:xt(t)}),j({phase:"error",message:Ue(t)}),B(!1)}async function Yt(t,s){const d=ve(We.MANAToken,s),c=ve(We.CreditsManager,s);await ms({auth:{kind:fs.Allowance,contractAddress:d.address,spenderAddress:c.address,chainId:s},signer:t})}async function et(){if(re)return re;try{return await b.fetchQuery({queryKey:["mana-rate",pt.chainId],queryFn:()=>ya(pt.chainId),staleTime:6e4})}catch{return}}async function Jt(t){const s=je(t).reduce((h,w)=>h+w.usdCents,0),c=(ge??0n)>0n?await et():re,u=c?lt(s,c):0n;return{totalCents:s,manaWei:u}}async function tt(t,s){const d=Ke(t),{totalCents:c,manaWei:u}=await Jt(t),h=Fe({priceCents:c,priceManaWei:u,balanceCents:(S==null?void 0:S.balanceCents)??0,manaBalanceWei:ge??0n}),w=Ot(t)?{...h,options:h.options.filter($=>$.method==="credits")}:h;if(s&&w.options.some($=>$.method===s)){if(s==="credits"){Ee(t);return}const{spender:$,chainId:_}=at(s,t);await st($,_,()=>s==="mana"?void nt(t):void it(t,c,u));return}if(w.options.some($=>$.method==="mana"||$.method==="combined")){j({phase:"choose",lines:t,totalCents:c,manaWei:u}),B(!1);return}if(S!=null&&S.credits<d){Je(t);return}Ee(t)}function Xt(t){return Fe({priceCents:t.totalCents,priceManaWei:t.manaWei,balanceCents:(S==null?void 0:S.balanceCents)??0,manaBalanceWei:ge??0n})}const[qe,fe]=P.useState(null);function at(t,s){const d=Ae(s)[0].trade;return{spender:t==="mana"?ve(wa(d.contract),d.chainId).address:ve(We.CreditsManager,d.chainId).address,chainId:d.chainId}}async function st(t,s,d){const c=ps(s,t),u=n?await gs(c,n.address).catch(()=>!0):!0;if(xs(n==null?void 0:n.providerType,u)){B(!1),fe({auth:c,run:d});return}d()}function Zt(t){if((p==null?void 0:p.phase)!=="choose")return;const{lines:s,totalCents:d,manaWei:c}=p;if(t==="credits"){Ee(s);return}const{spender:u,chainId:h}=at(t,s);st(u,h,()=>t==="mana"?void nt(s):void it(s,d,c))}async function nt(t){if(!n||t.length===0)return;const s=je(t),d=s.map(h=>({...h.item,priceCredits:h.priceCredits})),c=t.map(h=>({...h.item,priceCredits:h.priceCredits,quantity:h.quantity})),u=()=>j({phase:"processing",stage:"settling",step:s.length,total:s.length});j({phase:"processing",stage:"awaiting-signature",step:s.length,total:s.length});try{const h=await ds({trades:Ae(s).map(w=>w.trade),buyer:n.address,signer:n.signer,onSigned:u});t.forEach(w=>l(w.item.id)),O(null),G("Shop Completed Purchase",{...ye(d),payment_type:"mana",transaction_hash:h[0]??null}),b.invalidateQueries({queryKey:["mana-balance"]}),Xe(c,h)}catch(h){Ze(h,"buy_cart_mana")}}async function it(t,s,d){if(!n||t.length===0)return;const c=je(t),u=c.map(g=>({...g.item,priceCredits:g.priceCredits})),h=t.map(g=>({...g.item,priceCredits:g.priceCredits,quantity:g.quantity})),w=ls(c.map(g=>g.usdCents),(S==null?void 0:S.balanceCents)??0),$=w.reduce((g,k)=>g+k,0),_=us(Math.max(0,s-$),s,d),E=[],q=new Set,y=new Set;j({phase:"processing",stage:"reserving",step:1,total:c.length});try{const g=Ae(c),k=[];for(let f=0;f<g.length;f++){const v=w[f];if(v<=0)continue;j({phase:"processing",stage:"reserving",step:f+1,total:g.length});const K=g[f].item,{credit:de,maxCreditedValue:Be}=await gt(n.identity,v,g[f].trade.id,K.contractAddress&&K.itemId!=null?{contractAddress:K.contractAddress,itemId:String(K.itemId)}:void 0);E.push({salt:de.id,itemId:K.id}),k.push({kind:"trade",trade:g[f].trade,credits:[de],maxCreditedValue:Be})}g.forEach((f,v)=>{w[v]<=0&&k.push({kind:"trade",trade:f.trade,credits:[],maxCreditedValue:"0"})}),k[0]={...k[0],maxCreditedValue:(BigInt(k[0].maxCreditedValue)+_).toString()},await Yt(n.signer,g[0].trade.chainId);const F=()=>j({phase:"processing",stage:"settling",step:c.length,total:c.length});j({phase:"processing",stage:"awaiting-signature",step:c.length,total:c.length});const U=await Le({purchases:k,buyer:n.address,signer:n.signer,onSigned:F,onBroadcast:({salts:f})=>f.forEach(v=>q.add(v)),onReverted:({salts:f})=>f.forEach(v=>y.add(v))});t.forEach(f=>l(f.item.id)),O(null),G("Shop Completed Purchase",{...ye(u),payment_type:"credits_and_mana",transaction_hash:U[0]??null}),b.invalidateQueries({queryKey:["mana-balance"]}),Xe(h,U)}catch(g){const{toRelease:k}=Ct({reservations:E,spent:new Set([...q].filter(F=>!y.has(F))),settled:new Set});k.length&&_e(n.identity,k).catch(()=>{}),E.length&&b.invalidateQueries({queryKey:["usd-balance"]}),Ze(g,"buy_cart_combined")}}async function te(t){if(!n){bt({type:"cart-checkout"}),L();return}const s=N.getState().items.filter(Ge);if(s.length===0)return;ie(null),pe(null),B(!0);const d=s.reduce((c,u)=>c+u.priceCredits*u.quantity,0);G("Shop Started Checkout",{cart_size:s.length,cart_value_credits:d,cart_value_usd:ht(d),has_sufficient_credits:xe>=d});try{const c=await ks(s,n.address,Vt,await et(),Gt),u=[...c.unavailable,...c.own];if(u.length&&(u.forEach(h=>l(h.id)),pe(qn(c))),c.buyable.length===0){ie(a("cart.error.noneAvailable")),O(null);return}if(c.orderChanged){O(c),He.current=Date.now();return}await tt(c.buyable,t)}catch(c){ae(c,{flow:"cart_checkout",step:"review",cart_size:s.length}),ie(Ue(c))}finally{B(!1)}}async function rt(){if(R){if(!n){bt({type:"cart-checkout"}),L();return}if(Date.now()-He.current>En){O(null),pe(null),await te();return}ie(null),tt(R.buyable)}}async function ea(){if(Te){try{sessionStorage.setItem(we,JSON.stringify(N.getState().items))}catch{}B(!0);try{const t=await Ss(Te,n?{address:n.address,identity:n.identity}:void 0);if(t.url){window.location.href=t.url;return}ee("/credits")}catch(t){try{sessionStorage.removeItem(we)}catch{}ae(t,{flow:"cart_buy_credits"}),j({phase:"error",message:a("buyModal.error.creditsCheckout")})}finally{B(!1)}}}const ot=P.useRef(!1);P.useEffect(()=>{if(!n||ot.current||!is("cart-checkout"))return;ot.current=!0;const t=setTimeout(()=>void te(),0);return()=>clearTimeout(t)},[n]);const ct=P.useRef(!1);P.useEffect(()=>{if(!(J!=null&&J.resumeCheckout)||ct.current)return;ct.current=!0,oe.current=J.creditsAdded??null;try{const s=sessionStorage.getItem(we);if(s){sessionStorage.removeItem(we);const d=JSON.parse(s);Array.isArray(d)&&d.length&&D(d)}}catch{}b.invalidateQueries({queryKey:["usd-balance"]});const t=setTimeout(()=>void te(),0);return()=>clearTimeout(t)},[J==null?void 0:J.resumeCheckout]);const V=Ft||(p==null?void 0:p.phase)==="processing";return o.length===0&&!p?e.jsx(jt,{children:e.jsxs(St,{children:[e.jsxs(kt,{onClick:()=>ee(-1),type:"button",children:[e.jsx(H,{name:"arrow-left"}),a("nav.cart")]}),e.jsxs(Ks,{"data-testid":"cart-empty",children:[e.jsx(H,{name:"cart-plus",size:110}),e.jsxs(Qs,{children:[e.jsx(Ns,{children:a("cart.empty.title")}),e.jsx(Hs,{children:a("cart.empty.body")})]}),e.jsx(Os,{to:"/items",children:a("cart.empty.cta")})]})]})}):e.jsxs(jt,{children:[e.jsxs(St,{children:[e.jsxs(kt,{onClick:()=>ee(-1),type:"button",children:[e.jsx(H,{name:"arrow-left"}),a("nav.cart")]}),e.jsxs(Fs,{children:[e.jsxs(Ls,{children:[e.jsxs(Us,{children:[e.jsx(Vs,{onClick:()=>ee(-1),type:"button","aria-label":a("cart.goBack"),children:e.jsx(H,{name:"arrow-left"})}),e.jsx(Gs,{children:a("cart.panelTitle",{count:Ut})}),_t?e.jsxs(Ds,{onClick:()=>Y(!0),disabled:V,children:[e.jsx(H,{name:"fitting-room"}),a("cart.fittingRoom")]}):null]}),e.jsxs(At,{children:[e.jsx(Ys,{children:o.map(t=>{const s=Nt.get(t.id),d=s?s.priceCredits:t.priceCredits,c=!!s&&s.priceCredits!==t.priceCredits,u=!t.tokenId,h=t.quantity,w=typeof t.available=="number"&&h>=t.available,$=d*h,_=ga(t),E=!!_&&!!A[_],q=xa(t),y=Ve[t.id],g=!ut(y),k=y==="sold-out"?a("cart.availability.soldOut"):a("cart.availability.unavailable");return e.jsxs(Js,{"data-unavailable":g||void 0,children:[e.jsxs(Xs,{"data-thumb":!0,children:[q?e.jsx(Zs,{to:q,state:{item:t,tradeId:t.tradeId},"aria-label":t.name,children:t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:t.name}):null}):t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:t.name}):null,e.jsx(en,{"data-check":!0,"aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 20 20",width:"12",height:"12",children:e.jsx("path",{d:"M5 10.5l3 3 7-7.5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs(tn,{children:[e.jsxs(an,{"data-desc":!0,children:[q?e.jsx(nn,{to:q,state:{item:t,tradeId:t.tradeId},title:t.name,children:t.name}):e.jsx(sn,{title:t.name,children:t.name}),t.creator?e.jsx(rn,{address:t.creator,linkToProfile:!0}):null,Rt&&u?e.jsxs(fn,{"data-testid":"cart-creator-tag",children:[e.jsx(yn,{name:"buy-from-creator"}),a("cart.creatorTag")]}):null]}),e.jsx(on,{children:g?e.jsxs(e.Fragment,{children:[e.jsxs(gn,{children:[e.jsx(xn,{name:"warning-fill",size:24}),k]}),q?e.jsx(mn,{to:q,state:{item:t,tradeId:t.tradeId},children:a("cart.availability.viewResales")}):null]}):e.jsxs(e.Fragment,{children:[u?e.jsxs(cn,{children:[e.jsx($t,{onClick:()=>me(()=>z(t.id)),disabled:V||h<=1,"aria-label":a("cart.decreaseQuantity",{name:t.name}),children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})}),e.jsx(dn,{children:h}),e.jsx($t,{onClick:()=>me(()=>I(t.id)),disabled:V||w,"aria-label":a("cart.increaseQuantity"),children:e.jsx("svg",{viewBox:"0 0 16 16",fill:"none","aria-hidden":!0,focusable:"false",children:e.jsx("path",{d:"M8 3.5v9M3.5 8h9",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})})})]}):null,e.jsxs(ln,{children:[e.jsx(un,{})," ",$,c?e.jsx(hn,{children:t.priceCredits*h}):null]})]})})]}),e.jsxs(pn,{children:[_?e.jsx(bn,{"data-on":E||void 0,onClick:()=>ne(t),"aria-label":E?a("cart.removeFromFavorites",{name:t.name}):a("cart.addToFavorites",{name:t.name}),title:E?a("assetCard.removeFromFavorites"):a("assetCard.addToFavorites"),children:e.jsx(H,{name:E?"heart-solid":"heart"})}):null,e.jsx(vn,{onClick:()=>me(()=>l(t.id)),disabled:V,"aria-label":a("cart.remove",{name:t.name}),title:a("cart.removeTitle"),children:e.jsx(H,{name:"trash",size:24})})]})]},t.id)})}),e.jsx(wn,{children:e.jsx("button",{className:"link",onClick:()=>me(W),disabled:V,children:a("cart.clearCart")})})]})]}),e.jsxs(Cn,{children:[e.jsx(jn,{children:a("cart.purchaseSummary")}),e.jsxs(kn,{children:[e.jsxs(Sn,{children:[e.jsx($n,{children:a("cart.totalItems",{count:Kt})}),e.jsx(Tn,{children:e.jsxs(Mn,{children:[e.jsx(In,{})," ",De]})})]}),ce.options.length>0||ce.manaShortfall?e.jsx(Tt,{options:ce.options,totalCents:ze,shortfall:ce.manaShortfall,showCreditsAmount:!1,creditsLabel:R?a("marketCheckout.confirmPurchase"):ce.options.length>1?a("cart.buyWithCredits"):a("cart.checkout"),busy:V||Pe,onPay:t=>void(R?rt():te(t))}):e.jsx(Pn,{onClick:()=>void(R?rt():te()),disabled:V||Pe,children:V?a("cart.working"):R?a("marketCheckout.confirmPurchase"):a("cart.checkout")}),Pe?e.jsx(Ce,{className:"muted",children:a("cart.allUnavailable")}):null,n?null:e.jsx(Ce,{className:"muted",children:a("cart.signInHint")}),R?e.jsx(Ce,{className:"muted",children:a("cart.priceChanged")}):null,Ne?e.jsx(Ce,{className:"muted",children:Ne}):null,e.jsx(zn,{message:Wt})]})]})]})]}),Ye.length>0?e.jsx(An,{children:e.jsx(rs,{title:a("cart.youMightAlsoLike"),items:Ye})}):null,qe&&n?e.jsx(os,{auth:qe.auth,signer:n.signer,title:a("authorizeStep.manaTitle"),name:a("authorizeStep.manaName"),reason:a("authorizeStep.manaReason"),icon:e.jsx("img",{src:cs,width:24,height:24,alt:"","aria-hidden":!0}),onAuthorized:()=>{const{run:t}=qe;fe(null),t()},onCancel:()=>fe(null),onClose:()=>fe(null)}):null,p?e.jsx(Rs,{phase:p.phase,balanceCredits:xe,onClose:Dt,stage:p.phase==="processing"?p.stage:void 0,step:p.phase==="processing"?p.step:void 0,total:p.phase==="processing"?p.total:void 0,isSelfCustody:ma(n==null?void 0:n.providerType),signatures:p.phase==="processing"?p.signatures:void 0,options:p.phase==="choose"?Xt(p).options:void 0,onPay:Zt,totalCents:p.phase==="choose"?p.totalCents:void 0,totalManaWei:p.phase==="choose"?p.manaWei:void 0,totalCredits:p.phase==="choose"?Ke(p.lines):void 0,lines:p.phase==="nofunds"?p.lines:void 0,shortfallCredits:p.phase==="nofunds"?p.shortfall:void 0,packs:he,selectedPack:Te,onSelectPack:Oe,onBuyPacks:()=>void ea(),message:p.phase==="error"?p.message:void 0,onRetry:()=>void te()}):null]})}export{Yn as Cart};
@@ -1,4 +1,4 @@
1
- import{a9 as N,aa as U,ab as o,ac as n,ad as D,q as M}from"./index-DaQaTpvn.js";import{r as w,j as g}from"./react-DehiWSvs.js";import{g as z,a as E,c as I,b as F,s as v}from"./clsx-Df3CFyaE.js";function K(r){return z("MuiCircularProgress",r)}E("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);const W=["className","color","disableShrink","size","style","thickness","value","variant"];let l=r=>r,P,b,S,$;const a=44,q=M(P||(P=l`
1
+ import{a9 as N,aa as U,ab as o,ac as n,ad as D,q as M}from"./index-C3igEAQW.js";import{r as w,j as g}from"./react-DehiWSvs.js";import{g as z,a as E,c as I,b as F,s as v}from"./clsx-csE3gCud.js";function K(r){return z("MuiCircularProgress",r)}E("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);const W=["className","color","disableShrink","size","style","thickness","value","variant"];let l=r=>r,P,b,S,$;const a=44,q=M(P||(P=l`
2
2
  0% {
3
3
  transform: rotate(0deg);
4
4
  }
@@ -1,4 +1,4 @@
1
- import{j as e,r as h,u as Z,d as J}from"./react-DehiWSvs.js";import{t as b,s,bi as ee,X as te,z as T,bj as ae,bk as oe,I as ie,d as a,c as re,D as se,o as ne,v as ce,e as le,ag as F,ah as de,bl as pe,bm as xe}from"./index-DaQaTpvn.js";import{E as me}from"./ErrorNotice-CfA5EQ3B.js";import{d as he,P as ue,C as ge,a as be,b as fe,A as ve}from"./collectionPage.styles-vmTcFGbQ.js";import{S as L,C as je,F as ye,c as we,P as Ce,d as $e,H as ke,e as Ne}from"./categories-BQKh49D5.js";import{L as Pe}from"./LoadMore-TnqPM5W_.js";import{u as Se}from"./useInfiniteGrid-XDOQyPRq.js";import{G as Ae}from"./grid.styles-BaFKxOV8.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const Me=s.section`
1
+ import{j as e,r as h,u as Z,d as J}from"./react-DehiWSvs.js";import{t as b,s,bi as ee,X as te,z as T,bj as ae,bk as oe,I as ie,d as a,c as re,D as se,o as ne,v as ce,e as le,ag as F,ah as de,bl as pe,bm as xe}from"./index-C3igEAQW.js";import{E as me}from"./ErrorNotice-C0VDjxD8.js";import{d as he,P as ue,C as ge,a as be,b as fe,A as ve}from"./collectionPage.styles-9bHRQ1J-.js";import{S as L,C as je,F as ye,c as we,P as Ce,d as $e,H as ke,e as Ne}from"./categories-BvyNQxRN.js";import{L as Pe}from"./LoadMore-qdo6Ikhu.js";import{u as Se}from"./useInfiniteGrid-DxWFUb-I.js";import{G as Ae}from"./grid.styles-BB_h06XI.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const Me=s.section`
2
2
  position: relative;
3
3
  border-radius: ${b.radius.card};
4
4
  overflow: hidden;
@@ -1,4 +1,4 @@
1
- import{j as t,r as v}from"./react-DehiWSvs.js";import{s as e,t as o,d as g,x as k,av as j,bC as C,e as G,q as Y,I as Q,D as X,g as W,C as B,a as Z,a1 as q,c3 as F,ah as J}from"./index-DaQaTpvn.js";import{s as ee,i as U,A as H,g as D,r as te,m as ne,c as ae,M as ie,e as oe}from"./authorizations-D7XuRQgn.js";import{i as se}from"./errors-Wm6SH4-v.js";import{E as re}from"./ErrorNotice-CfA5EQ3B.js";import{a as ce}from"./buy-DGpUz8hz.js";import{g as de,a as le}from"./trade-encoding-wpCgB2Av.js";import{s as pe,M as he,E as ue}from"./sendMetaTransaction-ef-RXWfu.js";import{I as xe,C as ge}from"./ethers-CtNGBird.js";const R="shop:resume_after_signin",fe=900*1e3;function dt(a){try{sessionStorage.setItem(R,JSON.stringify({...a,at:Date.now()}))}catch{}}function lt(a){let n;try{n=sessionStorage.getItem(R)}catch{return null}if(!n)return null;try{sessionStorage.removeItem(R)}catch{}let i;try{i=JSON.parse(n)}catch{return null}return!i||i.type!==a||typeof i.at!="number"||Date.now()-i.at>fe?null:i.type==="cart-checkout"?{type:"cart-checkout"}:{type:"item-buy",path:i.path}}function me(a,n){return(a+n-1n)/n}function be(a,n,i){return a<=0||n<=0?0n:a>=n?i:me(i*BigInt(a),BigInt(n))}function pt(a){var b,y,w;const n=Number.isFinite(a.priceCents)?Math.max(0,Math.trunc(a.priceCents)):0,i=Number.isFinite(a.balanceCents)?Math.max(0,Math.trunc(a.balanceCents)):0,s=a.priceManaWei>0n?a.priceManaWei:0n,l=a.manaBalanceWei>0n?a.manaBalanceWei:0n;if(n<=0)return{options:[],preferred:null,manaShortfall:null};const c=[];if(i>=n&&c.push({method:"credits",creditsCents:n,manaWei:0n}),s>0n&&i>0&&i<n){const d=n-i,f=be(d,n,s);l>=f&&c.push({method:"combined",creditsCents:i,manaWei:f})}s>0n&&l>=s&&c.push({method:"mana",creditsCents:0,manaWei:s});const p=((b=c.find(d=>d.method==="credits"))==null?void 0:b.method)??((y=c.find(d=>d.method==="combined"))==null?void 0:y.method)??((w=c.find(d=>d.method==="mana"))==null?void 0:w.method)??null,m=!c.some(d=>d.method==="mana"||d.method==="combined")&&s>0n&&l>0n?{manaWei:l,manaCents:ye(l,n,s),priceCents:n}:null;return{options:c,preferred:p,manaShortfall:m}}function ye(a,n,i){return Number(a*BigInt(n)/i)}function ht(a,n){let i=Number.isFinite(n)?Math.max(0,Math.trunc(n)):0;return a.map(s=>{const l=Number.isFinite(s)?Math.max(0,Math.trunc(s)):0,c=Math.min(l,i);return i-=c,c})}function M(a){return Number.isFinite(a)?Math.max(0,a)/10:0}function ut(a,n){return a.options.find(i=>i.method===n)??null}function xt(a,n){if(!Number.isFinite(a)||a<=0||n<=0n)return null;const i=a/10;return Number(n)/1e18/i}const T="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Group%201'%3e%3cpath%20id='Vector'%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12%202L22%2012L12%2022L2%2012L12%202ZM12%204.8L19.2%2012L12%2019.2L4.8%2012L12%204.8ZM12%2015.6C12.9548%2015.6001%2013.8705%2015.2209%2014.5457%2014.5459C15.2209%2013.8708%2015.6003%2012.9552%2015.6004%2012.0004C15.6005%2011.0456%2015.2213%2010.1299%2014.5463%209.45471C13.8712%208.7795%2012.9556%208.40011%2012.0008%208.4C11.0461%208.4%2010.1304%208.77928%209.45525%209.45442C8.78012%2010.1295%208.40083%2011.0452%208.40083%2012C8.40083%2012.9548%208.78012%2013.8705%209.45525%2014.5456C10.1304%2015.2207%2011.0461%2015.6%2012.0008%2015.6H12Z'%20fill='white'/%3e%3cg%20id='Rectangle%201'%3e%3c/g%3e%3c/g%3e%3c/svg%3e",we=e.div`
1
+ import{j as t,r as v}from"./react-DehiWSvs.js";import{s as e,t as o,d as f,x as k,av as j,bC as C,e as G,q as Y,I as Q,D as X,g as W,C as B,a as Z,a1 as q,c3 as F,ah as J}from"./index-C3igEAQW.js";import{s as ee,i as U,A as H,g as D,r as te,m as ne,c as ae,M as ie,e as oe}from"./authorizations-C4greZZh.js";import{i as se}from"./errors-DFMf8rsi.js";import{E as re}from"./ErrorNotice-C0VDjxD8.js";import{a as ce}from"./buy-CvpQJoW5.js";import{g as de,a as le}from"./trade-encoding-3zHfaY9t.js";import{s as pe,M as he,E as ue}from"./sendMetaTransaction-CKo6PfMe.js";import{I as xe,C as ge}from"./ethers-CtNGBird.js";const R="shop:resume_after_signin",fe=900*1e3;function dt(a){try{sessionStorage.setItem(R,JSON.stringify({...a,at:Date.now()}))}catch{}}function lt(a){let n;try{n=sessionStorage.getItem(R)}catch{return null}if(!n)return null;try{sessionStorage.removeItem(R)}catch{}let i;try{i=JSON.parse(n)}catch{return null}return!i||i.type!==a||typeof i.at!="number"||Date.now()-i.at>fe?null:i.type==="cart-checkout"?{type:"cart-checkout"}:{type:"item-buy",path:i.path}}function me(a,n){return(a+n-1n)/n}function be(a,n,i){return a<=0||n<=0?0n:a>=n?i:me(i*BigInt(a),BigInt(n))}function pt(a){var b,y,w;const n=Number.isFinite(a.priceCents)?Math.max(0,Math.trunc(a.priceCents)):0,i=Number.isFinite(a.balanceCents)?Math.max(0,Math.trunc(a.balanceCents)):0,s=a.priceManaWei>0n?a.priceManaWei:0n,l=a.manaBalanceWei>0n?a.manaBalanceWei:0n;if(n<=0)return{options:[],preferred:null,manaShortfall:null};const c=[];if(i>=n&&c.push({method:"credits",creditsCents:n,manaWei:0n}),s>0n&&i>0&&i<n){const d=n-i,m=be(d,n,s);l>=m&&c.push({method:"combined",creditsCents:i,manaWei:m})}s>0n&&l>=s&&c.push({method:"mana",creditsCents:0,manaWei:s});const p=((b=c.find(d=>d.method==="credits"))==null?void 0:b.method)??((y=c.find(d=>d.method==="combined"))==null?void 0:y.method)??((w=c.find(d=>d.method==="mana"))==null?void 0:w.method)??null,u=!c.some(d=>d.method==="mana"||d.method==="combined")&&s>0n&&l>0n?{manaWei:l,manaCents:ye(l,n,s),priceCents:n}:null;return{options:c,preferred:p,manaShortfall:u}}function ye(a,n,i){return Number(a*BigInt(n)/i)}function ht(a,n){let i=Number.isFinite(n)?Math.max(0,Math.trunc(n)):0;return a.map(s=>{const l=Number.isFinite(s)?Math.max(0,Math.trunc(s)):0,c=Math.min(l,i);return i-=c,c})}function M(a){return Number.isFinite(a)?Math.max(0,a)/10:0}function ut(a,n){return a.options.find(i=>i.method===n)??null}function xt(a,n){if(!Number.isFinite(a)||a<=0||n<=0n)return null;const i=a/10;return Number(n)/1e18/i}const T="data:image/svg+xml,%3csvg%20width='24'%20height='24'%20viewBox='0%200%2024%2024'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%20id='Group%201'%3e%3cpath%20id='Vector'%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12%202L22%2012L12%2022L2%2012L12%202ZM12%204.8L19.2%2012L12%2019.2L4.8%2012L12%204.8ZM12%2015.6C12.9548%2015.6001%2013.8705%2015.2209%2014.5457%2014.5459C15.2209%2013.8708%2015.6003%2012.9552%2015.6004%2012.0004C15.6005%2011.0456%2015.2213%2010.1299%2014.5463%209.45471C13.8712%208.7795%2012.9556%208.40011%2012.0008%208.4C11.0461%208.4%2010.1304%208.77928%209.45525%209.45442C8.78012%2010.1295%208.40083%2011.0452%208.40083%2012C8.40083%2012.9548%208.78012%2013.8705%209.45525%2014.5456C10.1304%2015.2207%2011.0461%2015.6%2012.0008%2015.6H12Z'%20fill='white'/%3e%3cg%20id='Rectangle%201'%3e%3c/g%3e%3c/g%3e%3c/svg%3e",we=e.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 12px;
@@ -109,7 +109,7 @@ import{j as t,r as v}from"./react-DehiWSvs.js";import{s as e,t as o,d as g,x as
109
109
  line-height: 1.4;
110
110
  color: ${o.colors.muted};
111
111
  text-align: center;
112
- `;function gt({options:a,totalCents:n,onPay:i,busy:s=!1,rateNote:l,creditsLabel:c,shortfall:p}){return t.jsxs(we,{children:[a.map(h=>h.method==="credits"?t.jsxs(ve,{type:"button","data-testid":"pay-with-credits",onClick:()=>i("credits"),disabled:s,children:[t.jsx("span",{children:c??g("buyModal.buy")}),t.jsxs(z,{children:[t.jsx(k,{}),t.jsx("span",{children:j(M(h.creditsCents))})]})]},"credits"):h.method==="mana"?t.jsxs(N,{type:"button","data-testid":"pay-with-mana",onClick:()=>i("mana"),disabled:s,children:[t.jsx("span",{children:g("buyModal.buyWithMana")}),t.jsxs(z,{children:[t.jsx(E,{children:t.jsx("img",{src:T,alt:"","aria-hidden":!0})}),t.jsx("span",{children:C(h.manaWei)})]})]},"mana"):t.jsxs(N,{type:"button","data-testid":"pay-with-combined",onClick:()=>i("combined"),disabled:s,children:[t.jsx("span",{children:g("buyModal.buyWith")}),t.jsxs(z,{children:[t.jsx(k,{}),t.jsx("span",{children:j(M(h.creditsCents))}),t.jsx($e,{children:"+"}),t.jsx(E,{children:t.jsx("img",{src:T,alt:"","aria-hidden":!0})}),t.jsx("span",{children:C(h.manaWei)}),t.jsx(ke,{children:"MANA"})]})]},"combined")),p?t.jsxs(t.Fragment,{children:[t.jsxs(N,{type:"button","data-testid":"pay-with-mana-disabled",disabled:!0,children:[t.jsx("span",{children:g("buyModal.buyWithMana")}),t.jsxs(z,{children:[t.jsx(E,{children:t.jsx("img",{src:T,alt:"","aria-hidden":!0})}),t.jsx("span",{children:C(p.manaWei)})]})]},"mana-short"),t.jsx(Ce,{"data-testid":"mana-shortfall-note",children:g("buyModal.manaWorth",{mana:C(p.manaWei),credits:j(M(p.manaCents)),price:j(M(p.priceCents)),currency:G.name})})]}):null,l?t.jsx(je,{"data-testid":"mana-rate-note",children:l}):null,t.jsx("span",{hidden:!0,"data-testid":"pay-total-cents",children:n})]})}function ft(a,n){const i=(s,...l)=>void a.invalidateQueries({queryKey:n?[s,...l]:[s]});a.invalidateQueries({queryKey:["usd-balance"]}),a.invalidateQueries({queryKey:["detail-trade"]}),a.invalidateQueries({queryKey:["shop-item"]}),i("owned-token",n==null?void 0:n.contractAddress,n==null?void 0:n.tokenId),i("public-token",n==null?void 0:n.contractAddress,n==null?void 0:n.tokenId),i("item-resales",n==null?void 0:n.contractAddress,n==null?void 0:n.itemId),a.invalidateQueries({queryKey:["shop-items"]}),a.invalidateQueries({queryKey:["catalog-items"]}),a.invalidateQueries({queryKey:["overview-listings"]}),a.invalidateQueries({queryKey:["upsell-listings"]}),a.invalidateQueries({queryKey:["my-assets"]}),a.invalidateQueries({queryKey:["purchases"]}),a.invalidateQueries({queryKey:["owned-item-count"]})}const Me=Y`
112
+ `;function gt({options:a,totalCents:n,onPay:i,busy:s=!1,rateNote:l,creditsLabel:c,shortfall:p,showCreditsAmount:x=!0}){return t.jsxs(we,{children:[a.map(u=>u.method==="credits"?t.jsxs(ve,{type:"button","data-testid":"pay-with-credits",onClick:()=>i("credits"),disabled:s,children:[t.jsx("span",{children:c??f("buyModal.buy")}),x?t.jsxs(z,{children:[t.jsx(k,{}),t.jsx("span",{children:j(M(u.creditsCents))})]}):null]},"credits"):u.method==="mana"?t.jsxs(N,{type:"button","data-testid":"pay-with-mana",onClick:()=>i("mana"),disabled:s,children:[t.jsx("span",{children:f("buyModal.buyWithMana")}),t.jsxs(z,{children:[t.jsx(E,{children:t.jsx("img",{src:T,alt:"","aria-hidden":!0})}),t.jsx("span",{children:C(u.manaWei)})]})]},"mana"):t.jsxs(N,{type:"button","data-testid":"pay-with-combined",onClick:()=>i("combined"),disabled:s,children:[t.jsx("span",{children:f("buyModal.buyWith")}),t.jsxs(z,{children:[t.jsx(k,{}),t.jsx("span",{children:j(M(u.creditsCents))}),t.jsx($e,{children:"+"}),t.jsx(E,{children:t.jsx("img",{src:T,alt:"","aria-hidden":!0})}),t.jsx("span",{children:C(u.manaWei)}),t.jsx(ke,{children:"MANA"})]})]},"combined")),p?t.jsxs(t.Fragment,{children:[t.jsxs(N,{type:"button","data-testid":"pay-with-mana-disabled",disabled:!0,children:[t.jsx("span",{children:f("buyModal.buyWithMana")}),t.jsxs(z,{children:[t.jsx(E,{children:t.jsx("img",{src:T,alt:"","aria-hidden":!0})}),t.jsx("span",{children:C(p.manaWei)})]})]},"mana-short"),t.jsx(Ce,{"data-testid":"mana-shortfall-note",children:f("buyModal.manaWorth",{mana:C(p.manaWei),credits:j(M(p.manaCents)),price:j(M(p.priceCents)),currency:G.name})})]}):null,l?t.jsx(je,{"data-testid":"mana-rate-note",children:l}):null,t.jsx("span",{hidden:!0,"data-testid":"pay-total-cents",children:n})]})}function ft(a,n){const i=(s,...l)=>void a.invalidateQueries({queryKey:n?[s,...l]:[s]});a.invalidateQueries({queryKey:["usd-balance"]}),a.invalidateQueries({queryKey:["detail-trade"]}),a.invalidateQueries({queryKey:["shop-item"]}),i("owned-token",n==null?void 0:n.contractAddress,n==null?void 0:n.tokenId),i("public-token",n==null?void 0:n.contractAddress,n==null?void 0:n.tokenId),i("item-resales",n==null?void 0:n.contractAddress,n==null?void 0:n.itemId),a.invalidateQueries({queryKey:["shop-items"]}),a.invalidateQueries({queryKey:["catalog-items"]}),a.invalidateQueries({queryKey:["overview-listings"]}),a.invalidateQueries({queryKey:["upsell-listings"]}),a.invalidateQueries({queryKey:["my-assets"]}),a.invalidateQueries({queryKey:["purchases"]}),a.invalidateQueries({queryKey:["owned-item-count"]})}const Me=Y`
113
113
  to { transform: rotate(360deg); }
114
114
  `,ze=e.div`
115
115
  position: fixed;
@@ -289,7 +289,7 @@ import{j as t,r as v}from"./react-DehiWSvs.js";import{s as e,t as o,d as g,x as
289
289
  @media (prefers-reduced-motion: reduce) {
290
290
  animation: none;
291
291
  }
292
- `;function mt({auth:a,signer:n,title:i,reason:s,name:l,image:c,icon:p,onAuthorized:h,onCancel:m,onClose:b}){const[y,w]=v.useState(!1),[d,f]=v.useState(null);async function $(){w(!0),f(null);try{await ee({auth:a,signer:n,active:!0}),h()}catch(u){se(u)?f(g("authorizeStep.errorRejected")):(X(u,{flow:"authorize_step",kind:a.kind}),f(g("authorizeStep.errorGeneric"))),w(!1)}}return t.jsx(ze,{onClick:y?void 0:b,role:"presentation",children:t.jsxs(Ae,{onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":i,children:[t.jsxs(We,{children:[t.jsx(Ie,{children:i}),t.jsx(Se,{onClick:b,disabled:y,"aria-label":g("authorizeStep.close"),children:t.jsx(Q,{name:"close",className:"ico"})})]}),t.jsxs(Te,{"data-testid":"authorize-step-row",children:[t.jsx(Ne,{children:c?t.jsx("img",{src:c,alt:""}):p}),t.jsxs(Ee,{children:[t.jsx(Be,{title:l,children:l}),t.jsx(Re,{children:s})]})]}),t.jsx(Le,{children:g("authorizeStep.note")}),t.jsx(re,{message:d}),t.jsxs(Pe,{children:[t.jsx(Fe,{type:"button",onClick:m,disabled:y,children:g("authorizeStep.cancel")}),t.jsx(De,{type:"button","data-testid":"authorize-step-action",onClick:()=>void $(),disabled:y,children:y?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{"aria-hidden":!0}),g("authorizeStep.authorizing")]}):g("authorizeStep.authorize")})]})]})})}async function bt(a){const[n]=await Qe({...a,trades:[a.trade]});return n}async function Qe(a){const{trades:n,buyer:i,signer:s,onSigned:l}=a;if(n.length===0)throw new Error("No items to buy");const c=new Map;for(const h of n){const m=`${h.chainId}:${h.contract.toLowerCase()}`,b=c.get(m);b?b.push(h):c.set(m,[h])}const p=[];for(const h of c.values())p.push(await Ue({trades:h,buyer:i,signer:s,onSigned:l}));return p}async function Ue(a){const{trades:n,buyer:i,signer:s,onSigned:l}=a,c=n[0],p=W(Z(c.contract),c.chainId),h=W(B.MANAToken,c.chainId);await U({auth:{kind:H.Allowance,contractAddress:h.address,spenderAddress:p.address,chainId:c.chainId},signer:s});const m=n.map(d=>de(d,i));if(D.enabled)try{const d=new xe(p.abi).encodeFunctionData("accept",[m]),f=te(),$=ne(s.provider,f),u=await pe($,f,d,p,{serverURL:D.relayerUrl});return l==null||l(),await ae(u,"the MANA purchase"),u}catch(d){if(d instanceof he&&d.code===ue.USER_DENIED||d instanceof ie)throw d;console.warn("[buyWithMana] gasless meta-tx failed, falling back to a direct tx:",d)}await oe(s.provider,c.chainId);const y=await new ge(p.address,p.abi,s).accept(m,le(c.chainId));return l==null||l(),(await y.wait()).transactionHash}async function yt(a){const{trade:n,buyer:i,signer:s,credits:l,manaGapWei:c,onBroadcast:p,onReverted:h}=a;if(l.length===0)throw new Error("No credits to spend — use buyWithMana for a MANA-only purchase");if(c<=0n)throw new Error("No MANA gap to cover — use buyWithCredits for a credits-only purchase");const m=W(B.MANAToken,n.chainId),b=W(B.CreditsManager,n.chainId);await U({auth:{kind:H.Allowance,contractAddress:m.address,spenderAddress:b.address,chainId:n.chainId},signer:s});const w=(l.reduce((d,f)=>d+BigInt(f.availableAmount),0n)+c).toString();return ce({trade:n,buyer:i,signer:s,credits:l,maxCreditedValue:w,onBroadcast:p,onReverted:h})}function wt(a){return t.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,...a,children:t.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})}function vt(a){return t.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":!0,...a,children:[t.jsx("path",{d:"M12 3L2 20h20L12 3z",fill:"none",stroke:"#691fa9",strokeWidth:"1.8",strokeLinejoin:"round"}),t.jsx("path",{d:"M12 9v5",stroke:"#691fa9",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("circle",{cx:"12",cy:"17",r:"1.1",fill:"#691fa9"})]})}const{colors:r,gradients:O,radius:V,z:He}=o,kt=e.div`
292
+ `;function mt({auth:a,signer:n,title:i,reason:s,name:l,image:c,icon:p,onAuthorized:x,onCancel:u,onClose:b}){const[y,w]=v.useState(!1),[d,m]=v.useState(null);async function $(){w(!0),m(null);try{await ee({auth:a,signer:n,active:!0}),x()}catch(h){se(h)?m(f("authorizeStep.errorRejected")):(X(h,{flow:"authorize_step",kind:a.kind}),m(f("authorizeStep.errorGeneric"))),w(!1)}}return t.jsx(ze,{onClick:y?void 0:b,role:"presentation",children:t.jsxs(Ae,{onClick:h=>h.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":i,children:[t.jsxs(We,{children:[t.jsx(Ie,{children:i}),t.jsx(Se,{onClick:b,disabled:y,"aria-label":f("authorizeStep.close"),children:t.jsx(Q,{name:"close",className:"ico"})})]}),t.jsxs(Te,{"data-testid":"authorize-step-row",children:[t.jsx(Ne,{children:c?t.jsx("img",{src:c,alt:""}):p}),t.jsxs(Ee,{children:[t.jsx(Be,{title:l,children:l}),t.jsx(Re,{children:s})]})]}),t.jsx(Le,{children:f("authorizeStep.note")}),t.jsx(re,{message:d}),t.jsxs(Pe,{children:[t.jsx(Fe,{type:"button",onClick:u,disabled:y,children:f("authorizeStep.cancel")}),t.jsx(De,{type:"button","data-testid":"authorize-step-action",onClick:()=>void $(),disabled:y,children:y?t.jsxs(t.Fragment,{children:[t.jsx(Ke,{"aria-hidden":!0}),f("authorizeStep.authorizing")]}):f("authorizeStep.authorize")})]})]})})}async function bt(a){const[n]=await Qe({...a,trades:[a.trade]});return n}async function Qe(a){const{trades:n,buyer:i,signer:s,onSigned:l}=a;if(n.length===0)throw new Error("No items to buy");const c=new Map;for(const x of n){const u=`${x.chainId}:${x.contract.toLowerCase()}`,b=c.get(u);b?b.push(x):c.set(u,[x])}const p=[];for(const x of c.values())p.push(await Ue({trades:x,buyer:i,signer:s,onSigned:l}));return p}async function Ue(a){const{trades:n,buyer:i,signer:s,onSigned:l}=a,c=n[0],p=W(Z(c.contract),c.chainId),x=W(B.MANAToken,c.chainId);await U({auth:{kind:H.Allowance,contractAddress:x.address,spenderAddress:p.address,chainId:c.chainId},signer:s});const u=n.map(d=>de(d,i));if(D.enabled)try{const d=new xe(p.abi).encodeFunctionData("accept",[u]),m=te(),$=ne(s.provider,m),h=await pe($,m,d,p,{serverURL:D.relayerUrl});return l==null||l(),await ae(h,"the MANA purchase"),h}catch(d){if(d instanceof he&&d.code===ue.USER_DENIED||d instanceof ie)throw d;console.warn("[buyWithMana] gasless meta-tx failed, falling back to a direct tx:",d)}await oe(s.provider,c.chainId);const y=await new ge(p.address,p.abi,s).accept(u,le(c.chainId));return l==null||l(),(await y.wait()).transactionHash}async function yt(a){const{trade:n,buyer:i,signer:s,credits:l,manaGapWei:c,onBroadcast:p,onReverted:x}=a;if(l.length===0)throw new Error("No credits to spend — use buyWithMana for a MANA-only purchase");if(c<=0n)throw new Error("No MANA gap to cover — use buyWithCredits for a credits-only purchase");const u=W(B.MANAToken,n.chainId),b=W(B.CreditsManager,n.chainId);await U({auth:{kind:H.Allowance,contractAddress:u.address,spenderAddress:b.address,chainId:n.chainId},signer:s});const w=(l.reduce((d,m)=>d+BigInt(m.availableAmount),0n)+c).toString();return ce({trade:n,buyer:i,signer:s,credits:l,maxCreditedValue:w,onBroadcast:p,onReverted:x})}function wt(a){return t.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,...a,children:t.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})}function vt(a){return t.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":!0,...a,children:[t.jsx("path",{d:"M12 3L2 20h20L12 3z",fill:"none",stroke:"#691fa9",strokeWidth:"1.8",strokeLinejoin:"round"}),t.jsx("path",{d:"M12 9v5",stroke:"#691fa9",strokeWidth:"1.8",strokeLinecap:"round"}),t.jsx("circle",{cx:"12",cy:"17",r:"1.1",fill:"#691fa9"})]})}const{colors:r,gradients:O,radius:V,z:He}=o,kt=e.div`
293
293
  position: fixed;
294
294
  inset: 0;
295
295
  z-index: ${He.overlay};
@@ -801,4 +801,4 @@ import{j as t,r as v}from"./react-DehiWSvs.js";import{s as e,t as o,d as g,x as
801
801
  opacity: 1;
802
802
  transform: scale(1.1);
803
803
  }
804
- `;function ln({title:a,items:n,onViewAll:i}){const s=v.useRef(null),[l,c]=v.useState(1),[p,h]=v.useState(0),[m,b]=v.useState(!0),[y,w]=v.useState(!1),d=v.useCallback(()=>{const u=s.current;if(!u)return;const{scrollLeft:x,scrollWidth:L,clientWidth:S}=u,P=Math.max(1,Math.ceil(L/S));c(P),h(Math.min(P-1,Math.round(x/S))),b(x<=1),w(x+S>=L-1)},[]);if(v.useEffect(()=>{d();const u=s.current;if(u)return u.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",d),()=>{u.removeEventListener("scroll",d),window.removeEventListener("resize",d)}},[d,n.length]),n.length===0)return null;function f(u){const x=s.current;x&&x.scrollBy({left:u*x.clientWidth,behavior:"smooth"})}function $(u){const x=s.current;x&&x.scrollTo({left:u*x.clientWidth,behavior:"smooth"})}return t.jsxs(_e,{children:[t.jsxs(Oe,{children:[t.jsx(Ve,{children:a}),i?t.jsxs(Ge,{onClick:i,children:[g("collectionCarousel.viewAll"),t.jsx(Ye,{name:"chevron-down",size:16})]}):null]}),t.jsxs(Xe,{children:[t.jsx(K,{"data-side":"left",onClick:()=>f(-1),"aria-label":g("collectionCarousel.scrollLeft"),disabled:m,children:t.jsx("img",{src:F,alt:"","aria-hidden":!0})}),t.jsx(Ze,{ref:s,children:n.map(u=>t.jsx(J,{item:u},u.id))}),t.jsx(K,{"data-side":"right",onClick:()=>f(1),"aria-label":g("collectionCarousel.scrollRight"),disabled:y,children:t.jsx("img",{src:F,alt:"","aria-hidden":!0})})]}),l>1?t.jsx(qe,{"aria-label":g("collectionCarousel.pages"),children:Array.from({length:l}).map((u,x)=>t.jsx(Je,{"data-active":x===p||void 0,"aria-label":g("collectionCarousel.goToPage",{page:x+1}),"aria-current":x===p?"true":void 0,onClick:()=>$(x)},x))}):null]})}export{M as $,Et as A,Wt as B,jt as C,Ot as D,Vt as E,Gt as F,Yt as G,Ct as H,Xt as I,Zt as J,pt as K,en as L,kt as M,lt as N,ln as O,gt as P,mt as Q,T as R,$t as S,zt as T,dt as U,ft as V,Kt as W,At as X,Qe as Y,ht as Z,be as _,Mt as a,cn as a0,dn as a1,bt as a2,ut as a3,yt as a4,wt as b,It as c,St as d,Tt as e,Nt as f,tn as g,nn as h,an as i,qt as j,Jt as k,on as l,xt as m,sn as n,rn as o,vt as p,Qt as q,Bt as r,Rt as s,Lt as t,Pt as u,Ft as v,Dt as w,Ut as x,Ht as y,_t as z};
804
+ `;function ln({title:a,items:n,onViewAll:i}){const s=v.useRef(null),[l,c]=v.useState(1),[p,x]=v.useState(0),[u,b]=v.useState(!0),[y,w]=v.useState(!1),d=v.useCallback(()=>{const h=s.current;if(!h)return;const{scrollLeft:g,scrollWidth:L,clientWidth:S}=h,P=Math.max(1,Math.ceil(L/S));c(P),x(Math.min(P-1,Math.round(g/S))),b(g<=1),w(g+S>=L-1)},[]);if(v.useEffect(()=>{d();const h=s.current;if(h)return h.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",d),()=>{h.removeEventListener("scroll",d),window.removeEventListener("resize",d)}},[d,n.length]),n.length===0)return null;function m(h){const g=s.current;g&&g.scrollBy({left:h*g.clientWidth,behavior:"smooth"})}function $(h){const g=s.current;g&&g.scrollTo({left:h*g.clientWidth,behavior:"smooth"})}return t.jsxs(_e,{children:[t.jsxs(Oe,{children:[t.jsx(Ve,{children:a}),i?t.jsxs(Ge,{onClick:i,children:[f("collectionCarousel.viewAll"),t.jsx(Ye,{name:"chevron-down",size:16})]}):null]}),t.jsxs(Xe,{children:[t.jsx(K,{"data-side":"left",onClick:()=>m(-1),"aria-label":f("collectionCarousel.scrollLeft"),disabled:u,children:t.jsx("img",{src:F,alt:"","aria-hidden":!0})}),t.jsx(Ze,{ref:s,children:n.map(h=>t.jsx(J,{item:h},h.id))}),t.jsx(K,{"data-side":"right",onClick:()=>m(1),"aria-label":f("collectionCarousel.scrollRight"),disabled:y,children:t.jsx("img",{src:F,alt:"","aria-hidden":!0})})]}),l>1?t.jsx(qe,{"aria-label":f("collectionCarousel.pages"),children:Array.from({length:l}).map((h,g)=>t.jsx(Je,{"data-active":g===p||void 0,"aria-label":f("collectionCarousel.goToPage",{page:g+1}),"aria-current":g===p?"true":void 0,onClick:()=>$(g)},g))}):null]})}export{M as $,Et as A,Wt as B,jt as C,Ot as D,Vt as E,Gt as F,Yt as G,Ct as H,Xt as I,Zt as J,pt as K,en as L,kt as M,lt as N,ln as O,gt as P,mt as Q,T as R,$t as S,zt as T,dt as U,ft as V,Kt as W,At as X,Qe as Y,ht as Z,be as _,Mt as a,cn as a0,dn as a1,bt as a2,ut as a3,yt as a4,wt as b,It as c,St as d,Tt as e,Nt as f,tn as g,nn as h,an as i,qt as j,Jt as k,on as l,xt as m,sn as n,rn as o,vt as p,Qt as q,Bt as r,Rt as s,Lt as t,Pt as u,Ft as v,Dt as w,Ut as x,Ht as y,_t as z};
@@ -1,4 +1,4 @@
1
- import{d as de,j as e,L as Pe,u as Fe,e as Le,r as f}from"./react-DehiWSvs.js";import{t as he,H as Ae,K as Y,J as Z,s,bD as Ie,au as Re,bE as ze,d as o,bF as Be,bG as ee,B as Me,ad as me,X as xe,bi as _e,l as Te,z as ue,bp as We,bj as De,bk as Ge,I as te,c as Oe,v as Ke,o as He,ae as Ue,ag as A,ah as oe,bH as re,bI as qe}from"./index-DaQaTpvn.js";import{d as Ve,P as Je,C as Qe,a as Xe,b as Ye,A as Ze,c as et,e as tt}from"./collectionPage.styles-vmTcFGbQ.js";import{g as ot,h as rt,i as it,j as st,k as at,C as nt,l as lt,o as ct,m as dt,n as ht,M as mt,E as xt,p as ut,q as pt,r as gt,s as ft,t as bt}from"./Assets.styles-ZM8Q2cFA.js";import{S as ie,R as wt,F as jt,e as vt}from"./categories-BQKh49D5.js";import{L as se}from"./LoadMore-TnqPM5W_.js";import{u as ae}from"./useInfiniteGrid-XDOQyPRq.js";import{E as W}from"./ErrorNotice-CfA5EQ3B.js";import{G as ne}from"./grid.styles-BaFKxOV8.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./Tooltip-ySlzdfvH.js";function yt(r){const{gridLoading:i,gridError:a,gridCount:n,baselinePending:h,baselineError:l,baselineCount:m}=r;return i?"skeletons":a?"error":n>0?"items":h?"skeletons":l?"error":m===0?"no-creations":"filters"}const{colors:b,radius:pe,media:Ct}=he,kt=s.article`
1
+ import{d as de,j as e,L as Pe,u as Fe,e as Le,r as f}from"./react-DehiWSvs.js";import{t as he,H as Ae,K as Y,J as Z,s,bD as Ie,au as Re,bE as ze,d as o,bF as Be,bG as ee,B as Me,ad as me,X as xe,bi as _e,l as Te,z as ue,bp as We,bj as De,bk as Ge,I as te,c as Oe,v as Ke,o as He,ae as Ue,ag as A,ah as oe,bH as re,bI as qe}from"./index-C3igEAQW.js";import{d as Ve,P as Je,C as Qe,a as Xe,b as Ye,A as Ze,c as et,e as tt}from"./collectionPage.styles-9bHRQ1J-.js";import{g as ot,h as rt,i as it,j as st,k as at,C as nt,l as lt,o as ct,m as dt,n as ht,M as mt,E as xt,p as ut,q as pt,r as gt,s as ft,t as bt}from"./Assets.styles-BHyaJQ_u.js";import{S as ie,R as wt,F as jt,e as vt}from"./categories-BvyNQxRN.js";import{L as se}from"./LoadMore-qdo6Ikhu.js";import{u as ae}from"./useInfiniteGrid-DxWFUb-I.js";import{E as W}from"./ErrorNotice-C0VDjxD8.js";import{G as ne}from"./grid.styles-BB_h06XI.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";import"./Tooltip-JQloj8Nt.js";function yt(r){const{gridLoading:i,gridError:a,gridCount:n,baselinePending:h,baselineError:l,baselineCount:m}=r;return i?"skeletons":a?"error":n>0?"items":h?"skeletons":l?"error":m===0?"no-creations":"filters"}const{colors:b,radius:pe,media:Ct}=he,kt=s.article`
2
2
  height: 300px;
3
3
  background: ${b.bg};
4
4
  border-radius: ${pe.card};
@@ -1 +1 @@
1
- import{j as r}from"./react-DehiWSvs.js";import{I as i}from"./index-DaQaTpvn.js";function a({message:e,className:o,testId:t}){return e?r.jsxs("p",{className:o?`error-notice ${o}`:"error-notice","data-testid":t,role:"alert",children:[r.jsx(i,{name:"alert",className:"error-notice__ico",size:18}),r.jsx("span",{className:"error-notice__msg",children:e})]}):null}export{a as E};
1
+ import{j as r}from"./react-DehiWSvs.js";import{I as i}from"./index-C3igEAQW.js";function a({message:e,className:o,testId:t}){return e?r.jsxs("p",{className:o?`error-notice ${o}`:"error-notice","data-testid":t,role:"alert",children:[r.jsx(i,{name:"alert",className:"error-notice__ico",size:18}),r.jsx("span",{className:"error-notice__msg",children:e})]}):null}export{a as E};
@@ -1 +1 @@
1
- import{C as l,E as w,b as E,S as A,d as k,O as U,N as P,g as f,B as x,e as N,i as I,p as L}from"./W3MFrameProviderSingleton-Be2imJ8Z.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-vt25O9Am.js";const D=0,C={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=L(C),m={state:e,subscribe(t){return I(e,()=>t(e))},subscribeKey(t,n){return N(e,t,n)},resetState(){Object.assign(e,{...C})},async getAssetsForNetwork(t){const n=v(t),s=await m.getAssetsImageAndPrice(n),r=n.map(a=>{var c,o,p,y;const u=a.asset==="native"?f():`${a.network}:${a.asset}`,i=s.find(S=>{var g,d,h;return((h=(d=(g=S.fungibles)==null?void 0:g[0])==null?void 0:d.address)==null?void 0:h.toLowerCase())===u.toLowerCase()});return{...a,price:((o=(c=i==null?void 0:i.fungibles)==null?void 0:c[0])==null?void 0:o.price)||1,metadata:{...a.metadata,iconUrl:(y=(p=i==null?void 0:i.fungibles)==null?void 0:p[0])==null?void 0:y.iconUrl}}});return e.assets=r,r},async getAssetsImageAndPrice(t){const n=t.map(r=>r.asset==="native"?f():`${r.network}:${r.asset}`);return await Promise.all(n.map(r=>x.fetchTokenPrice({addresses:[r]})))},getTokenAmount(){var s;if(!((s=e==null?void 0:e.paymentAsset)!=null&&s.price))throw new Error("Cannot get token price");const t=P.bigNumber(e.amount??0).round(8),n=P.bigNumber(e.paymentAsset.price).round(8);return t.div(n).round(8).toNumber()},setAmount(t){var n;e.amount=t,(n=e.paymentAsset)!=null&&n.price&&(e.tokenAmount=m.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){var t;return(t=U.state.remoteFeatures)==null?void 0:t.payWithExchange},isPayWithExchangeSupported(){return m.isPayWithExchangeEnabled()&&l.state.activeCaipNetwork&&k.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(l.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){var t;try{const n=m.isPayWithExchangeSupported();if(!e.paymentAsset||!n){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await _({page:D,asset:b(e.paymentAsset.network,e.paymentAsset.asset),amount:((t=e.amount)==null?void 0:t.toString())??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw A.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,n){try{const s=Number(n.amount),r=await W({exchangeId:t,asset:b(n.network,n.asset),amount:s.toString(),recipient:`${n.network}:${n.recipient}`});return w.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:n.network,asset:n.asset,recipient:n.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),r}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new Error("Asset not supported"):new Error(s.message)}},async handlePayWithExchange(t){var n;try{const s=(n=l.getAccountData())==null?void 0:n.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=E.returnOpenHref("","popupWindow","scrollbar=yes,width=480,height=720");if(!r)throw new Error("Could not create popup window");e.isPaymentInProgress=!0,e.paymentId=crypto.randomUUID(),e.currentPayment={type:"exchange",exchangeId:t};const{network:a,asset:u}=e.paymentAsset,i={network:a,asset:u,amount:e.tokenAmount,recipient:s},c=await m.getPayUrl(t,i);if(!c){try{r.close()}catch(o){console.error("Unable to close popup window",o)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=c.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=c.url}catch{e.error="Unable to initiate payment",A.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r=20}){const a=await m.getBuyStatus(t,n,s);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(r===0)throw new Error("Unable to get deposit status");return await new Promise(u=>{setTimeout(u,5e3)}),m.waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r-1})},async getBuyStatus(t,n,s){var r,a,u,i,c;try{if(!e.currentPayment)throw new Error("No current payment");const o=await T({sessionId:n,exchangeId:t});if(e.currentPayment.status=o.status,o.status==="SUCCESS"||o.status==="FAILED"){const p=(r=l.getAccountData())==null?void 0:r.address;e.currentPayment.result=o.txHash,e.isPaymentInProgress=!1,w.sendEvent({type:"track",event:o.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:o.status==="FAILED"?E.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:s,configuration:{network:((a=e.paymentAsset)==null?void 0:a.network)||"",asset:((u=e.paymentAsset)==null?void 0:u.asset)||"",recipient:p||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:(i=e.currentPayment)==null?void 0:i.exchangeId,sessionId:(c=e.currentPayment)==null?void 0:c.sessionId,result:o.txHash}}})}return o}catch{return{status:"UNKNOWN",txHash:""}}},reset(){e.currentPayment=void 0,e.isPaymentInProgress=!1,e.paymentId="",e.paymentAsset=null,e.amount=0,e.tokenAmount=0,e.priceLoading=!1,e.error=null,e.exchanges=[],e.isLoading=!1}};export{m as E};
1
+ import{C as l,E as w,b as E,S as A,d as k,O as U,N as P,g as f,B as x,e as N,i as I,p as L}from"./W3MFrameProviderSingleton-mBM8n0OL.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-DaKMz1tE.js";const D=0,C={paymentAsset:null,amount:null,tokenAmount:0,priceLoading:!1,error:null,exchanges:[],isLoading:!1,currentPayment:void 0,isPaymentInProgress:!1,paymentId:"",assets:[]},e=L(C),m={state:e,subscribe(t){return I(e,()=>t(e))},subscribeKey(t,n){return N(e,t,n)},resetState(){Object.assign(e,{...C})},async getAssetsForNetwork(t){const n=v(t),s=await m.getAssetsImageAndPrice(n),r=n.map(a=>{var c,o,p,y;const u=a.asset==="native"?f():`${a.network}:${a.asset}`,i=s.find(S=>{var g,d,h;return((h=(d=(g=S.fungibles)==null?void 0:g[0])==null?void 0:d.address)==null?void 0:h.toLowerCase())===u.toLowerCase()});return{...a,price:((o=(c=i==null?void 0:i.fungibles)==null?void 0:c[0])==null?void 0:o.price)||1,metadata:{...a.metadata,iconUrl:(y=(p=i==null?void 0:i.fungibles)==null?void 0:p[0])==null?void 0:y.iconUrl}}});return e.assets=r,r},async getAssetsImageAndPrice(t){const n=t.map(r=>r.asset==="native"?f():`${r.network}:${r.asset}`);return await Promise.all(n.map(r=>x.fetchTokenPrice({addresses:[r]})))},getTokenAmount(){var s;if(!((s=e==null?void 0:e.paymentAsset)!=null&&s.price))throw new Error("Cannot get token price");const t=P.bigNumber(e.amount??0).round(8),n=P.bigNumber(e.paymentAsset.price).round(8);return t.div(n).round(8).toNumber()},setAmount(t){var n;e.amount=t,(n=e.paymentAsset)!=null&&n.price&&(e.tokenAmount=m.getTokenAmount())},setPaymentAsset(t){e.paymentAsset=t},isPayWithExchangeEnabled(){var t;return(t=U.state.remoteFeatures)==null?void 0:t.payWithExchange},isPayWithExchangeSupported(){return m.isPayWithExchangeEnabled()&&l.state.activeCaipNetwork&&k.PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES.includes(l.state.activeCaipNetwork.chainNamespace)},async fetchExchanges(){var t;try{const n=m.isPayWithExchangeSupported();if(!e.paymentAsset||!n){e.exchanges=[],e.isLoading=!1;return}e.isLoading=!0;const s=await _({page:D,asset:b(e.paymentAsset.network,e.paymentAsset.asset),amount:((t=e.amount)==null?void 0:t.toString())??"0"});e.exchanges=s.exchanges.slice(0,2)}catch{throw A.showError("Unable to get exchanges"),new Error("Unable to get exchanges")}finally{e.isLoading=!1}},async getPayUrl(t,n){try{const s=Number(n.amount),r=await W({exchangeId:t,asset:b(n.network,n.asset),amount:s.toString(),recipient:`${n.network}:${n.recipient}`});return w.sendEvent({type:"track",event:"PAY_EXCHANGE_SELECTED",properties:{exchange:{id:t},configuration:{network:n.network,asset:n.asset,recipient:n.recipient,amount:s},currentPayment:{type:"exchange",exchangeId:t},source:"fund-from-exchange",headless:!1}}),r}catch(s){throw s instanceof Error&&s.message.includes("is not supported")?new Error("Asset not supported"):new Error(s.message)}},async handlePayWithExchange(t){var n;try{const s=(n=l.getAccountData())==null?void 0:n.address;if(!s)throw new Error("No account connected");if(!e.paymentAsset)throw new Error("No payment asset selected");const r=E.returnOpenHref("","popupWindow","scrollbar=yes,width=480,height=720");if(!r)throw new Error("Could not create popup window");e.isPaymentInProgress=!0,e.paymentId=crypto.randomUUID(),e.currentPayment={type:"exchange",exchangeId:t};const{network:a,asset:u}=e.paymentAsset,i={network:a,asset:u,amount:e.tokenAmount,recipient:s},c=await m.getPayUrl(t,i);if(!c){try{r.close()}catch(o){console.error("Unable to close popup window",o)}throw new Error("Unable to initiate payment")}e.currentPayment.sessionId=c.sessionId,e.currentPayment.status="IN_PROGRESS",e.currentPayment.exchangeId=t,r.location.href=c.url}catch{e.error="Unable to initiate payment",A.showError(e.error)}},async waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r=20}){const a=await m.getBuyStatus(t,n,s);if(a.status==="SUCCESS"||a.status==="FAILED")return a;if(r===0)throw new Error("Unable to get deposit status");return await new Promise(u=>{setTimeout(u,5e3)}),m.waitUntilComplete({exchangeId:t,sessionId:n,paymentId:s,retries:r-1})},async getBuyStatus(t,n,s){var r,a,u,i,c;try{if(!e.currentPayment)throw new Error("No current payment");const o=await T({sessionId:n,exchangeId:t});if(e.currentPayment.status=o.status,o.status==="SUCCESS"||o.status==="FAILED"){const p=(r=l.getAccountData())==null?void 0:r.address;e.currentPayment.result=o.txHash,e.isPaymentInProgress=!1,w.sendEvent({type:"track",event:o.status==="SUCCESS"?"PAY_SUCCESS":"PAY_ERROR",properties:{message:o.status==="FAILED"?E.parseError(e.error):void 0,source:"fund-from-exchange",paymentId:s,configuration:{network:((a=e.paymentAsset)==null?void 0:a.network)||"",asset:((u=e.paymentAsset)==null?void 0:u.asset)||"",recipient:p||"",amount:e.amount??0},currentPayment:{type:"exchange",exchangeId:(i=e.currentPayment)==null?void 0:i.exchangeId,sessionId:(c=e.currentPayment)==null?void 0:c.sessionId,result:o.txHash}}})}return o}catch{return{status:"UNKNOWN",txHash:""}}},reset(){e.currentPayment=void 0,e.isPaymentInProgress=!1,e.paymentId="",e.paymentAsset=null,e.amount=0,e.tokenAmount=0,e.priceLoading=!1,e.error=null,e.exchanges=[],e.isLoading=!1}};export{m as E};
@@ -1,4 +1,4 @@
1
- import{d as he,e as xe,r as l,j as t}from"./react-DehiWSvs.js";import{s as i,t as e,q as B,v as ge,d as r,e as p,l as ue,y as fe,U as u,b7 as me,D as N,bg as U,I as ie,b0 as D,x as re,bJ as H}from"./index-DaQaTpvn.js";import{R as K}from"./resume-buy-Bf0zIH7y.js";import{u as be,a as we,R as ye,c as ke,i as Ce,b as ve}from"./useCreditPacks-CzOCruPU.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const P="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/pack-coins-BDh1ZDbh.webp",ne="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/pack-stacks-D-V2jSHW.webp",oe="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/pack-chest-BX_j84xW.webp",$e="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/credit-coin-CmcTCd5i.webp",je="data:image/svg+xml,%3csvg%20width='60'%20height='60'%20viewBox='0%200%2060%2060'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='60'%20height='60'%20rx='30'%20fill='%2334CE77'/%3e%3cpath%20d='M21.6583%2046.1067L11.4656%2036.0591C10.1688%2034.829%2010.1905%2032.7207%2011.4769%2031.4622L13.6868%2029.3591C14.9732%2028.1006%2017.1615%2028.1058%2018.4582%2029.3359L23.8747%2034.6197L41.9704%2015.6527C43.2568%2014.3942%2045.4291%2014.2093%2046.7258%2015.4394L48.8765%2017.3628C50.1732%2018.5929%2050.3491%2020.6844%2049.0626%2021.9429L26.6112%2045.8766C25.1433%2047.342%2022.955%2047.3368%2021.6583%2046.1067Z'%20fill='%23FCFCFC'/%3e%3c/svg%3e",Se="https://cdn.decentraland.org/@dcl/shop/0.5.1-30944558724.commit-19fdddf/_assets/packs-backdrop-BcXiUPeP.webp",O="linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)",Pe=i.div`
1
+ import{d as he,e as xe,r as l,j as t}from"./react-DehiWSvs.js";import{s as i,t as e,q as B,v as ge,d as r,e as p,l as ue,y as fe,U as u,b7 as me,D as N,bg as U,I as ie,b0 as D,x as re,bJ as H}from"./index-C3igEAQW.js";import{R as K}from"./resume-buy-Bf0zIH7y.js";import{u as be,a as we,R as ye,c as ke,i as Ce,b as ve}from"./useCreditPacks-C673G0mp.js";import"./sentry-973sfbO9.js";import"./dcl-schemas-Dr9BTjb7.js";import"./ethers-CtNGBird.js";import"./intl-CBcMB1D2.js";const P="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/pack-coins-BDh1ZDbh.webp",ne="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/pack-stacks-D-V2jSHW.webp",oe="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/pack-chest-BX_j84xW.webp",$e="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/credit-coin-CmcTCd5i.webp",je="data:image/svg+xml,%3csvg%20width='60'%20height='60'%20viewBox='0%200%2060%2060'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3crect%20width='60'%20height='60'%20rx='30'%20fill='%2334CE77'/%3e%3cpath%20d='M21.6583%2046.1067L11.4656%2036.0591C10.1688%2034.829%2010.1905%2032.7207%2011.4769%2031.4622L13.6868%2029.3591C14.9732%2028.1006%2017.1615%2028.1058%2018.4582%2029.3359L23.8747%2034.6197L41.9704%2015.6527C43.2568%2014.3942%2045.4291%2014.2093%2046.7258%2015.4394L48.8765%2017.3628C50.1732%2018.5929%2050.3491%2020.6844%2049.0626%2021.9429L26.6112%2045.8766C25.1433%2047.342%2022.955%2047.3368%2021.6583%2046.1067Z'%20fill='%23FCFCFC'/%3e%3c/svg%3e",Se="https://cdn.decentraland.org/@dcl/shop/0.5.1-30947573582.commit-565f915/_assets/packs-backdrop-BcXiUPeP.webp",O="linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0)",Pe=i.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 24px;
@@ -1,4 +1,4 @@
1
- import{i as f,b as h}from"./lit-element-B3y9oplH.js";import{n as m}from"./class-map-CxwNmq0D.js";import{c as p}from"./index-BCyVn8MQ.js";import{d as g,r as v}from"./index-vt25O9Am.js";import{C as c}from"./ConstantsUtil-Di3dRDAF.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-Be2imJ8Z.js";import{au as y}from"./NetworkUtil-EoWQDMpU.js";const b=g`
1
+ import{i as f,b as h}from"./lit-element-B3y9oplH.js";import{n as m}from"./class-map-CxwNmq0D.js";import{c as p}from"./index-BdvG3vgW.js";import{d as g,r as v}from"./index-DaKMz1tE.js";import{C as c}from"./ConstantsUtil-Di3dRDAF.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-mBM8n0OL.js";import{au as y}from"./NetworkUtil-EoWQDMpU.js";const b=g`
2
2
  :host {
3
3
  display: flex;
4
4
  justify-content: center;