@dcl/shop 0.1.0-29734911263.commit-97d18ef → 0.1.0-29734914357.commit-8edd840

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 (175) hide show
  1. package/assets/{AnimatedBackground-Dc0wzLz1.js → AnimatedBackground-B3WHlX77.js} +1 -1
  2. package/assets/{Assets-DPWTLJJO.js → Assets--1H9fLCF.js} +1 -1
  3. package/assets/{Cart-C5IFRFSf.js → Cart-DmWaCrLQ.js} +1 -1
  4. package/assets/{CircularProgress-BDWVwtML.js → CircularProgress-BRXfk0cW.js} +1 -1
  5. package/assets/{Collection-M5DaYZlo.js → Collection-BNBBmA6K.js} +1 -1
  6. package/assets/{CollectionCarousel-_a53Z75p.js → CollectionCarousel-CUkjxu-O.js} +1 -1
  7. package/assets/Creator-CCrA6c1k.js +1 -0
  8. package/assets/{CssVarsProvider-CwWOpnL3.js → CssVarsProvider-BE4__NFs.js} +1 -1
  9. package/assets/{ExchangeController-nU1L87yP.js → ExchangeController-DhPdUt78.js} +1 -1
  10. package/assets/GetCredits-xWjPUPUO.js +1 -0
  11. package/assets/{HelpersUtil-CvduV3iF.js → HelpersUtil-CyyM2_TI.js} +1 -1
  12. package/assets/{ImportListings-BNQe3kWr.js → ImportListings-wTGv7IcM.js} +1 -1
  13. package/assets/{ItemDetail-Cei4y0nZ.js → ItemDetail-59tH149n.js} +2 -2
  14. package/assets/ItemDetail-Dkstj3oi.css +1 -0
  15. package/assets/{MarketCheckout-Do7I_hLx.js → MarketCheckout-CP6s5BFr.js} +1 -1
  16. package/assets/{MyAssets-Bxikz0O1.js → MyAssets-CKIY6xbZ.js} +1 -1
  17. package/assets/{MyFavorites-dmVn-jNs.js → MyFavorites-B_tnX5BB.js} +1 -1
  18. package/assets/{MyPurchases-62SCltGJ.js → MyPurchases-CdeIHOAU.js} +1 -1
  19. package/assets/NotFound-Bp_eP5mg.js +1 -0
  20. package/assets/{StoreSettings-DjI99hf0.js → StoreSettings-a0Os-pSs.js} +1 -1
  21. package/assets/{Success-KQj99-pf.js → Success-CfmwKaYB.js} +1 -1
  22. package/assets/{SwapController-rop7Cy13.js → SwapController-CtDCOae7.js} +1 -1
  23. package/assets/{TradeService-D1JN9Ta2.js → TradeService-B9js2HgZ.js} +1 -1
  24. package/assets/{W3MFrameProviderSingleton-igVJGnIP.js → W3MFrameProviderSingleton-Bk3c0gmH.js} +3 -3
  25. package/assets/{WebCryptoP256-DhJgbrxa.js → WebCryptoP256-CPWrk_dm.js} +1 -1
  26. package/assets/{basic-ClmBw3no.js → basic-BWj2hv9g.js} +1 -1
  27. package/assets/{biconomy-Bh94ZwGM.js → biconomy-D5wtybfS.js} +1 -1
  28. package/assets/{buy-qpkIddNt.js → buy-BuqGUyRC.js} +1 -1
  29. package/assets/{buy-gasless-COqF6TfJ.js → buy-gasless-D1dur72K.js} +1 -1
  30. package/assets/cart-checkout-rwvAvzgx.js +1 -0
  31. package/assets/{categories-Chd4fnsf.js → categories-B2btvTaV.js} +1 -1
  32. package/assets/{ccip-C1vfcfuy.js → ccip-CvNFQ17g.js} +1 -1
  33. package/assets/{ccip-DLAoDUFz.js → ccip-DzDcXB6O.js} +1 -1
  34. package/assets/{collection-s3UDaDJs.js → collection-AwsuEzzi.js} +1 -1
  35. package/assets/{controller-BTZuhR9-.js → controller-D183MxeO.js} +2 -2
  36. package/assets/{core-C_85sR5Z.js → core-Djo1YVjG.js} +4 -4
  37. package/assets/credit-coin-CmcTCd5i.webp +0 -0
  38. package/assets/{custom-H6a3SIvl.js → custom-QAYZpJri.js} +1 -1
  39. package/assets/{data-capture-BVpYsiYY.js → data-capture-CU2GVJSK.js} +1 -1
  40. package/assets/{decimals-CpjItqe-.js → decimals-Bz5i1WHx.js} +1 -1
  41. package/assets/{decimals-DhBB7VPD.js → decimals-Cli_fCtR.js} +1 -1
  42. package/assets/{detectExtension-DPopT1Kb.js → detectExtension-CmaNfrCA.js} +1 -1
  43. package/assets/{email-CCv85Jjp.js → email-BlPcB0YM.js} +1 -1
  44. package/assets/{embedded-wallet-C9sVH0T_.js → embedded-wallet-BKQynccz.js} +1 -1
  45. package/assets/{emotion-styled.browser.esm-7U6PLHlL.js → emotion-styled.browser.esm-BVgOpiFx.js} +1 -1
  46. package/assets/{engine-DPnRS4Vr.js → engine-in37aZAj.js} +1 -1
  47. package/assets/{estimate-l1-fee-0Ox9h9v8.js → estimate-l1-fee-CLAQ-kVd.js} +1 -1
  48. package/assets/{eth_estimateGas-B9zdAB24.js → eth_estimateGas-CtpUe28l.js} +1 -1
  49. package/assets/{eth_getStorageAt-Bp0VdFG_.js → eth_getStorageAt-C_Vek-yS.js} +1 -1
  50. package/assets/{eth_getTransactionCount-D3ux_Uy2.js → eth_getTransactionCount-DDMlHHZ1.js} +1 -1
  51. package/assets/{extractIPFS-DnEM7HGg.js → extractIPFS-B8bkKl83.js} +1 -1
  52. package/assets/{features-C3BsUywQ.js → features-BLsvLtOU.js} +1 -1
  53. package/assets/{fetchTokenMetadata-r_xnkq91.js → fetchTokenMetadata-BBDtMy0y.js} +2 -2
  54. package/assets/{get-ecosystem-wallet-info-rMoPuP61.js → get-ecosystem-wallet-info-DowvW6Wh.js} +1 -1
  55. package/assets/{getBalance-DxuNPttj.js → getBalance-D3uwYYaj.js} +1 -1
  56. package/assets/{getInstalledModules-BNrMQMSM.js → getInstalledModules-UdrVObo8.js} +1 -1
  57. package/assets/{getNFT-BlFsKfLP.js → getNFT-9P__5ihz.js} +2 -2
  58. package/assets/{getNFT-CU0p112E.js → getNFT-CtNGZK_f.js} +1 -1
  59. package/assets/{getOverlayAlpha-B57gNsKL.js → getOverlayAlpha-DlM2cE6a.js} +1 -1
  60. package/assets/{hashTypedData-DiQfP4ez.js → hashTypedData-BFJJ5q4M.js} +1 -1
  61. package/assets/{hashTypedData-C1FGwn-3.js → hashTypedData-CYBVIuTE.js} +1 -1
  62. package/assets/{import-DU_OhvUC.js → import-Cg6Yj2rh.js} +1 -1
  63. package/assets/{in-app-wallet-calls-BREibEL9.js → in-app-wallet-calls-e3GHFt75.js} +1 -1
  64. package/assets/{index-BKCbqIDV.js → index-2m_d1zB7.js} +2 -2
  65. package/assets/{index-C4CMYXNA.js → index-9BdnoiUc.js} +1 -1
  66. package/assets/{index-B29hZWU0.js → index-B51wZzeY.js} +3 -3
  67. package/assets/{index-DYCwB2y3.js → index-BI_EDMP9.js} +1 -1
  68. package/assets/index-BLIz_7l9.js +38 -0
  69. package/assets/{index-C3UC6Rs5.js → index-BQ5ge-Tm.js} +1 -1
  70. package/assets/{index-CuqC8d2-.js → index-BTWZP5iA.js} +2 -2
  71. package/assets/{index-BtMWp3zQ.js → index-BV7J2krB.js} +1 -1
  72. package/assets/{index-YhrkEkkQ.js → index-BWdPQT3i.js} +1 -1
  73. package/assets/{index-l4HYDe7V.js → index-BYADyNKo.js} +1 -1
  74. package/assets/{index-CvvKgwgx.js → index-BYFF2boi.js} +1 -1
  75. package/assets/{index-BdSETUQy.js → index-BbcVeePT.js} +1 -1
  76. package/assets/{index-DxzGOm1i.js → index-Bc8LK9Ol.js} +1 -1
  77. package/assets/{index-D4Qahz_H.js → index-Bd5HzOih.js} +1 -1
  78. package/assets/{index-BFflIlJl.js → index-BoJl0MEu.js} +1 -1
  79. package/assets/{index-B857ik7x.js → index-BpEM2es9.js} +1 -1
  80. package/assets/{index-B7Kupr-o.js → index-C1xjP172.js} +1 -1
  81. package/assets/{index-r1XpXEwi.js → index-C232P_tt.js} +1 -1
  82. package/assets/{index-D_bGCuiT.js → index-C4O-Vk3J.js} +1 -1
  83. package/assets/{index-C4TyPwon.js → index-CC8NVylF.js} +1 -1
  84. package/assets/{index-6Yrg17AO.js → index-CGyhL7yH.js} +1 -1
  85. package/assets/{index-h7-uke9P.js → index-CPkXQMIU.js} +1 -1
  86. package/assets/{index-HDuUFApJ.js → index-CY8WzS3h.js} +1 -1
  87. package/assets/{index-CPGmwqDl.js → index-CimjXt7J.js} +1 -1
  88. package/assets/{index-D4gUO6YF.js → index-CnuM4VLz.js} +1 -1
  89. package/assets/{index-CEy7C-8g.js → index-CokMOCIe.js} +1 -1
  90. package/assets/{index-BBeG1LQT.js → index-Cxrg3Lj0.js} +3 -3
  91. package/assets/{index-CONsWgTr.js → index-DCXTyr29.js} +1 -1
  92. package/assets/{index-DaX1PcgD.js → index-DDwSPSIB.js} +1 -1
  93. package/assets/{index-BLfwzasm.js → index-DHZvqL84.js} +1 -1
  94. package/assets/{index-CFOnfjiX.js → index-DM4LbLGg.js} +1 -1
  95. package/assets/{index-DVRw_gw9.js → index-DWeKOlH9.js} +1 -1
  96. package/assets/{index-BABdIN2I.js → index-DZy0_LxZ.js} +2 -2
  97. package/assets/{index-BvkmByTC.js → index-Dafl7b8S.js} +1 -1
  98. package/assets/{index-BhQRaolS.js → index-DbPN9eYi.js} +1 -1
  99. package/assets/{index-jbcqNek9.css → index-DgcUoaxa.css} +1 -1
  100. package/assets/{index-kSkl-zIU.js → index-DgpgwNeu.js} +1 -1
  101. package/assets/{index-DUvTWkbt.js → index-Dhvz3eMq.js} +1 -1
  102. package/assets/{index-BHgXtxHt.js → index-DjWTBSwD.js} +1 -1
  103. package/assets/{index-GPWVD-So.js → index-Dn_qk1hX.js} +1 -1
  104. package/assets/{index-CvEf0SP-.js → index-Dv_t30Fx.js} +1 -1
  105. package/assets/{index-Bu7y6WnQ.js → index-EiXStXto.js} +1 -1
  106. package/assets/{index-GCfy9KhE.js → index-GKEFv9yg.js} +1 -1
  107. package/assets/{index-Clrgbbm8.js → index-HNS3dqwM.js} +1 -1
  108. package/assets/{index-C_M9XsGM.js → index-QO_7_lhH.js} +1 -1
  109. package/assets/{index-BToZY4wT.js → index-WSrqh314.js} +1 -1
  110. package/assets/{index-CkdLU61h.js → index-X6oDiehz.js} +1 -1
  111. package/assets/{index-6A6nGPwX.js → index-_7H3L1ZP.js} +1 -1
  112. package/assets/{index-DAGAMRoL.js → index-f6fV1T8T.js} +2 -2
  113. package/assets/{index-DWwpSRi-.js → index-tMOEEL4R.js} +1 -1
  114. package/assets/{index-BxVm-10z.js → index-wJWAyLyG.js} +1 -1
  115. package/assets/{index-B1DKag9y.js → index-wix-m5kv.js} +1 -1
  116. package/assets/{index.es-BWh_1tnr.js → index.es-BMbRXqeO.js} +4 -4
  117. package/assets/{index.es-SxKlpBqs.js → index.es-BqzvGq7f.js} +1 -1
  118. package/assets/{index.es-DtmgeITt.js → index.es-CUUt-ANj.js} +1 -1
  119. package/assets/{localBatchGatewayRequest-Bisheu8W.js → localBatchGatewayRequest-CDAmzVtL.js} +1 -1
  120. package/assets/{mana-rate-CPIzN4Vi.js → mana-rate-B0IpO0Jf.js} +1 -1
  121. package/assets/{networks-2BN2k4cV.js → networks-BymyxGkz.js} +1 -1
  122. package/assets/{onramp-ezPwBLqh.js → onramp-CYTa2Tx4.js} +1 -1
  123. package/assets/{openzeppelin-DKT-fJnL.js → openzeppelin-COAmu6ot.js} +1 -1
  124. package/assets/{ownerOf-6bPfyUUB.js → ownerOf-DqKMKRi9.js} +1 -1
  125. package/assets/pack-chips--HnOpf5U.webp +0 -0
  126. package/assets/{parseNft-C64AqdIb.js → parseNft-DLpc5Yei.js} +2 -2
  127. package/assets/{parseSignature-C5pd7yT7.js → parseSignature-BbVWa74t.js} +3 -3
  128. package/assets/{parseSignature-7t7DXXbe.js → parseSignature-CQEIs6ej.js} +1 -1
  129. package/assets/{pay-with-exchange-Brk67N1Q.js → pay-with-exchange-B9ucX9mo.js} +1 -1
  130. package/assets/{payments-D1TsNJWo.js → payments-BQ7DJXcX.js} +1 -1
  131. package/assets/{qr-overlay-CLl0wVbt.js → qr-overlay-BzDjJxkl.js} +1 -1
  132. package/assets/{receive-Bt81cJu3.js → receive-CdB8wZew.js} +1 -1
  133. package/assets/{resolveImplementation-D-DhhnNB.js → resolveImplementation-By6ba-gT.js} +1 -1
  134. package/assets/{rpc-Bhmgfz1e.js → rpc-U-jASdu9.js} +1 -1
  135. package/assets/{secp256k1-B6MVDYDd.js → secp256k1-BmWXuOHo.js} +1 -1
  136. package/assets/{secp256k1-CdH-AER_.js → secp256k1-iIKLFLGj.js} +1 -1
  137. package/assets/{secp256k1-DcIYGay5.js → secp256k1-xEn2m9bZ.js} +1 -1
  138. package/assets/{send-Dzpx6XEO.js → send-DtVXzmyO.js} +1 -1
  139. package/assets/{send-batch-transaction-twz9plvu.js → send-batch-transaction-9qRwmlL2.js} +1 -1
  140. package/assets/{send-eip712-transaction-DuYMjY_7.js → send-eip712-transaction-ByJVcnYO.js} +2 -2
  141. package/assets/{send-gasless-transaction-RKoViIvt.js → send-gasless-transaction-D0RYhYAB.js} +2 -2
  142. package/assets/{sendRawTransaction-B5C16ilB.js → sendRawTransaction-CzSVySFj.js} +3 -3
  143. package/assets/{serializeTransaction-COuCzUc4.js → serializeTransaction-Cai1RcSa.js} +1 -1
  144. package/assets/{session-proposal-DKbxmMJ5.js → session-proposal-DMISmbXT.js} +1 -1
  145. package/assets/{session-request-DuILxTGu.js → session-request-B2p3uKhH.js} +2 -2
  146. package/assets/{sha256-Bj4vNOnb.js → sha256-DPzs4mu5.js} +1 -1
  147. package/assets/{signing-DW4tyFl0.js → signing-JS3aFRFl.js} +4 -4
  148. package/assets/{socials-CBCHs9Sz.js → socials-BiovW07p.js} +1 -1
  149. package/assets/{swaps-21QHpuMJ.js → swaps-CTTSrRMo.js} +1 -1
  150. package/assets/{thirdweb-C69j7iTG.js → thirdweb-1lCUQ6qm.js} +3 -3
  151. package/assets/{totalSupply-BjrHK1ZH.js → totalSupply-Noc7aMrB.js} +1 -1
  152. package/assets/{trade-encoding-BtlpyT8N.js → trade-encoding-BOIcOdJd.js} +1 -1
  153. package/assets/{transactionReceipt-CK-ZZNkd.js → transactionReceipt-Dt2k8fLQ.js} +1 -1
  154. package/assets/{transactions-DYJvsdj0.js → transactions-CxIQG9NN.js} +1 -1
  155. package/assets/{useInfiniteGrid-Bso7ZIlQ.js → useInfiniteGrid-B4_3J2Zt.js} +1 -1
  156. package/assets/{useStore-BomIn5qc.js → useStore-ByF6YxEU.js} +1 -1
  157. package/assets/useTheme-BWWP9qQ0.js +1 -0
  158. package/assets/{useTheme-qyEpY8zT.js → useTheme-dztiejOp.js} +1 -1
  159. package/assets/{verifyHash-DpeDDe0l.js → verifyHash-L5vlRUnm.js} +1 -1
  160. package/assets/{w3m-modal-BHGgG_1M.js → w3m-modal-B7QKvnW7.js} +1 -1
  161. package/assets/{w3m-modal-B5GRQ8Bk.js → w3m-modal-DGcZdnA7.js} +1 -1
  162. package/assets/{wait-for-tx-receipt-D9A_u2fN.js → wait-for-tx-receipt-B3gUpnn8.js} +1 -1
  163. package/assets/{wallets-DvzXHK5n.js → wallets-YFPhEThY.js} +6 -6
  164. package/assets/{web-connector-B4y564hP.js → web-connector-BPl3smRR.js} +3 -3
  165. package/assets/{writeContract-ChFbWN7V.js → writeContract-CSsBSjk9.js} +1 -1
  166. package/assets/{zoraTestnet-B1VFNgcm.js → zoraTestnet-CT6xPXO8.js} +1 -1
  167. package/index.html +11 -11
  168. package/package.json +2 -2
  169. package/assets/Creator-CTzdaC_3.js +0 -1
  170. package/assets/GetCredits-BpLPWa0W.js +0 -1
  171. package/assets/ItemDetail-Bu2_xAf0.css +0 -1
  172. package/assets/NotFound-CaztEVTk.js +0 -1
  173. package/assets/cart-checkout-0Ra3OSr3.js +0 -1
  174. package/assets/index-CNSWvtL0.js +0 -38
  175. package/assets/useTheme-gY3T76jp.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as l,j as v}from"./react-yytiy0wi.js";const w="https://cdn.decentraland.org/@dcl/shop/0.1.0-29734911263.commit-97d18ef/assets/custom-welcome-background-BxlFQma9.webp",S="https://cdn.decentraland.org/@dcl/shop/0.1.0-29734911263.commit-97d18ef/assets/DCL_LogoPattern-BryBPc3d.png",U=`
1
+ import{r as l,j as v}from"./react-yytiy0wi.js";const w="https://cdn.decentraland.org/@dcl/shop/0.1.0-29734914357.commit-8edd840/assets/custom-welcome-background-BxlFQma9.webp",S="https://cdn.decentraland.org/@dcl/shop/0.1.0-29734914357.commit-8edd840/assets/DCL_LogoPattern-BryBPc3d.png",U=`
2
2
  attribute vec2 a_position;
3
3
  varying vec2 v_uv;
4
4
  void main() {
@@ -1 +1 @@
1
- import{u as le,r as i,j as e}from"./react-yytiy0wi.js";import{u as ce,t as W,C,A as T,f as oe}from"./index-CNSWvtL0.js";import{m as de}from"./mana-rate-CPIzN4Vi.js";import{u as ue,M as me}from"./MarketCheckout-Do7I_hLx.js";import{S as $,C as pe,R as _e,F as fe,a as B,b as xe}from"./categories-Chd4fnsf.js";import{L as he}from"./LoadMore-CiZkVzux.js";import{u as be}from"./useInfiniteGrid-Bso7ZIlQ.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";import"./index-HN6Rk25C.js";import"./buy-qpkIddNt.js";import"./trade-encoding-BtlpyT8N.js";import"./buy-gasless-COqF6TfJ.js";const ge=48,t=1e5;function Ne(r){return{tradeId:r.tradeId??r.id,listingType:"primary",contractAddress:r.contractAddress,itemId:r.itemId??"",name:r.name,thumbnail:r.thumbnail,rarity:r.rarity,category:r.category,wearableCategory:r.wearableCategory??null,creator:r.creator,manaWei:r.manaWei??"0",available:1,network:r.network,chainId:r.chainId,createdAt:0}}function Oe(){const[r]=le(),n=(r.get("q")??"").trim().toLowerCase(),G=ce(),[m,R]=i.useState("wearable"),[o,S]=i.useState(null),[l,A]=i.useState([]),[f,k]=i.useState(""),[x,M]=i.useState(""),[p,K]=i.useState("newest"),[w,Q]=i.useState(!1),[h,_]=i.useState(!1),[F,P]=i.useState(null);i.useEffect(()=>{if(!h)return;const s=a=>{a.key==="Escape"&&_(!1)};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[h]);const d=f&&!Number.isNaN(Number(f))?Number(f):void 0,u=x&&!Number.isNaN(Number(x))?Number(x):void 0,U=o?xe[o]:void 0,D=($.find(s=>s.key===p)??$[0]).server,I={category:m,rarities:l.length?l:void 0,wearableCategories:U,minPriceCredits:d,maxPriceCredits:u,search:n||void 0,sortBy:D},{items:b,total:L,isLoading:c,error:J,hasNextPage:X,isFetchingNextPage:O,fetchNextPage:Z}=be(["unified-listings",I],s=>oe({...I,first:ge,skip:s})),g=L,{data:N,isError:z}=ue(),H=s=>N&&s.manaWei?de(s.manaWei,N):null,q=i.useRef(null);i.useEffect(()=>{c||!n||q.current===n||(q.current=n,W("Shop Searched",{query:n,result_count:g}))},[n,c,g]);const j=i.useRef("__init__");i.useEffect(()=>{if(c)return;const s=JSON.stringify({category:m,subCategory:o,rarities:l,min:d,max:u,sort:p});if(j.current==="__init__"||j.current===s){j.current=s;return}j.current=s,W("Shop Applied Filter",{filters:{category:m,sub_category:o,rarities:l,min_price_credits:d??null,max_price_credits:u??null,sort:p},result_count:g})},[m,o,l,d,u,p,c,g]);function V(s){R(s),S(null)}function Y(s){A(a=>a.includes(s)?a.filter(E=>E!==s):[...a,s])}function ee(){R("wearable"),S(null),A([]),k(""),M("")}function se(s){const a=b.find(E=>E.id===s.id);a&&a.source==="legacy"&&a.manaWei&&P(Ne(a))}function ae(){G.invalidateQueries({queryKey:["unified-listings"]})}const y=d!=null?Math.min(d,t):0,v=u!=null?Math.min(u,t):t,re=y/t*100,ie=v/t*100;function te(s){const a=Math.min(s,v);k(a<=0?"":String(a))}function ne(s){const a=Math.max(s,y);M(a>=t?"":String(a))}return e.jsxs("div",{className:"browse browse--sidebar",children:[h?e.jsx("div",{className:"browse__scrim",onClick:()=>_(!1),"aria-hidden":!0}):null,e.jsxs("aside",{className:`browse__sidebar${h?" is-open":""}`,children:[e.jsxs("div",{className:"browse__sidebar-head",children:[e.jsx("span",{className:"browse__sidebar-title",children:"Filters"}),e.jsx("button",{className:"browse__sidebar-close",onClick:()=>_(!1),"aria-label":"Close filters",children:"✕"})]}),e.jsx("div",{className:"sidebar__section-label",children:"Category"}),e.jsx(pe,{category:m,subCategory:o,onCategory:V,onSub:S}),e.jsx("div",{className:"sidebar__divider"}),e.jsx("div",{className:"sidebar__section-label",children:"Price"}),e.jsxs("div",{className:"price-filter",children:[e.jsxs("div",{className:"price-filter__inputs",children:[e.jsxs("label",{className:"price-filter__field",children:[e.jsx("span",{className:"price-filter__field-label",children:"Min"}),e.jsxs("span",{className:"price-filter__box",children:[e.jsx(C,{className:"price-filter__coin"}),e.jsx("input",{type:"number",min:"0","aria-label":"Minimum price",placeholder:"0",value:f,onChange:s=>k(s.target.value)})]})]}),e.jsx("span",{className:"price-filter__to",children:"to"}),e.jsxs("label",{className:"price-filter__field",children:[e.jsx("span",{className:"price-filter__field-label",children:"Max"}),e.jsxs("span",{className:"price-filter__box",children:[e.jsx(C,{className:"price-filter__coin"}),e.jsx("input",{type:"number",min:"0","aria-label":"Maximum price",placeholder:"0",value:x,onChange:s=>M(s.target.value)})]})]})]}),e.jsxs("div",{className:"price-filter__slider",style:{"--min-pct":`${re}%`,"--max-pct":`${ie}%`},children:[e.jsx("div",{className:"price-filter__track","aria-hidden":!0}),e.jsx("div",{className:"price-filter__fill","aria-hidden":!0}),e.jsx("input",{type:"range",min:0,max:t,value:y,"aria-label":"Minimum price slider",onChange:s=>te(Number(s.target.value))}),e.jsx("input",{type:"range",min:0,max:t,value:v,"aria-label":"Maximum price slider",onChange:s=>ne(Number(s.target.value))})]}),e.jsxs("div",{className:"price-filter__range",children:[e.jsxs("span",{className:"price-filter__range-val",children:[e.jsx(C,{className:"price-filter__coin"}),y.toLocaleString()]}),e.jsxs("span",{className:"price-filter__range-val",children:[e.jsx(C,{className:"price-filter__coin"}),v.toLocaleString()]})]})]}),e.jsx("div",{className:"sidebar__divider"}),e.jsxs("button",{type:"button",className:"sidebar__section-toggle","aria-expanded":w,onClick:()=>Q(s=>!s),children:[e.jsx("span",{className:"sidebar__section-label",children:"Rarity"}),e.jsx("span",{className:`ico ico-chevron sidebar__section-chev${w?" is-up":""}`,"aria-hidden":!0})]}),w?e.jsx("div",{className:"rarity-filter",children:_e.map(s=>e.jsxs("label",{className:`rarity-filter__check${l.includes(s)?" is-on":""}`,children:[e.jsx("input",{type:"checkbox",checked:l.includes(s),onChange:()=>Y(s)}),e.jsx("span",{children:s})]},s))}):null,e.jsxs("div",{className:"browse__sidebar-foot",children:[e.jsx("button",{type:"button",className:"browse__clear",onClick:ee,children:"Clear Filters"}),e.jsx("button",{type:"button",className:"browse__apply",onClick:()=>_(!1),children:"Apply"})]})]}),e.jsxs("div",{className:"browse__main",children:[e.jsx(fe,{sort:p,onSort:K,total:L,loading:c,query:n,onOpenFilters:()=>_(!0)}),z&&b.some(s=>s.source==="legacy")?e.jsx("p",{className:"market-banner market-banner--warn",children:"Some market prices are temporarily unavailable — buying those items is paused for a moment. Please try again shortly."}):null,J?e.jsx("p",{className:"error",children:"Couldn’t load items — please try again."}):null,e.jsx("div",{className:"grid",children:c?e.jsx(B,{count:15}):e.jsxs(e.Fragment,{children:[b.map(s=>s.source==="legacy"?e.jsx(T,{item:s,mode:"market",marketPriceCredits:H(s),onBuyNow:se},s.id):e.jsx(T,{item:s},s.id)),O?e.jsx(B,{count:6}):null]})}),e.jsx(he,{hasNextPage:X,isFetching:O,onLoadMore:()=>void Z()}),!c&&b.length===0?e.jsx("p",{className:"muted",children:"No items match your filters."}):null]}),F&&N?e.jsx(me,{listing:F,rate:N,onClose:()=>P(null),onSold:()=>{P(null),ae()}}):null]})}export{Oe as Assets};
1
+ import{u as le,r as i,j as e}from"./react-yytiy0wi.js";import{u as ce,t as W,C,A as T,f as oe}from"./index-BLIz_7l9.js";import{m as de}from"./mana-rate-B0IpO0Jf.js";import{u as ue,M as me}from"./MarketCheckout-CP6s5BFr.js";import{S as $,C as pe,R as _e,F as fe,a as B,b as xe}from"./categories-B2btvTaV.js";import{L as he}from"./LoadMore-CiZkVzux.js";import{u as be}from"./useInfiniteGrid-B4_3J2Zt.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";import"./index-HN6Rk25C.js";import"./buy-BuqGUyRC.js";import"./trade-encoding-BOIcOdJd.js";import"./buy-gasless-D1dur72K.js";const ge=48,t=1e5;function Ne(r){return{tradeId:r.tradeId??r.id,listingType:"primary",contractAddress:r.contractAddress,itemId:r.itemId??"",name:r.name,thumbnail:r.thumbnail,rarity:r.rarity,category:r.category,wearableCategory:r.wearableCategory??null,creator:r.creator,manaWei:r.manaWei??"0",available:1,network:r.network,chainId:r.chainId,createdAt:0}}function Oe(){const[r]=le(),n=(r.get("q")??"").trim().toLowerCase(),G=ce(),[m,R]=i.useState("wearable"),[o,S]=i.useState(null),[l,A]=i.useState([]),[f,k]=i.useState(""),[x,M]=i.useState(""),[p,K]=i.useState("newest"),[w,Q]=i.useState(!1),[h,_]=i.useState(!1),[F,P]=i.useState(null);i.useEffect(()=>{if(!h)return;const s=a=>{a.key==="Escape"&&_(!1)};return document.addEventListener("keydown",s),()=>document.removeEventListener("keydown",s)},[h]);const d=f&&!Number.isNaN(Number(f))?Number(f):void 0,u=x&&!Number.isNaN(Number(x))?Number(x):void 0,U=o?xe[o]:void 0,D=($.find(s=>s.key===p)??$[0]).server,I={category:m,rarities:l.length?l:void 0,wearableCategories:U,minPriceCredits:d,maxPriceCredits:u,search:n||void 0,sortBy:D},{items:b,total:L,isLoading:c,error:J,hasNextPage:X,isFetchingNextPage:O,fetchNextPage:Z}=be(["unified-listings",I],s=>oe({...I,first:ge,skip:s})),g=L,{data:N,isError:z}=ue(),H=s=>N&&s.manaWei?de(s.manaWei,N):null,q=i.useRef(null);i.useEffect(()=>{c||!n||q.current===n||(q.current=n,W("Shop Searched",{query:n,result_count:g}))},[n,c,g]);const j=i.useRef("__init__");i.useEffect(()=>{if(c)return;const s=JSON.stringify({category:m,subCategory:o,rarities:l,min:d,max:u,sort:p});if(j.current==="__init__"||j.current===s){j.current=s;return}j.current=s,W("Shop Applied Filter",{filters:{category:m,sub_category:o,rarities:l,min_price_credits:d??null,max_price_credits:u??null,sort:p},result_count:g})},[m,o,l,d,u,p,c,g]);function V(s){R(s),S(null)}function Y(s){A(a=>a.includes(s)?a.filter(E=>E!==s):[...a,s])}function ee(){R("wearable"),S(null),A([]),k(""),M("")}function se(s){const a=b.find(E=>E.id===s.id);a&&a.source==="legacy"&&a.manaWei&&P(Ne(a))}function ae(){G.invalidateQueries({queryKey:["unified-listings"]})}const y=d!=null?Math.min(d,t):0,v=u!=null?Math.min(u,t):t,re=y/t*100,ie=v/t*100;function te(s){const a=Math.min(s,v);k(a<=0?"":String(a))}function ne(s){const a=Math.max(s,y);M(a>=t?"":String(a))}return e.jsxs("div",{className:"browse browse--sidebar",children:[h?e.jsx("div",{className:"browse__scrim",onClick:()=>_(!1),"aria-hidden":!0}):null,e.jsxs("aside",{className:`browse__sidebar${h?" is-open":""}`,children:[e.jsxs("div",{className:"browse__sidebar-head",children:[e.jsx("span",{className:"browse__sidebar-title",children:"Filters"}),e.jsx("button",{className:"browse__sidebar-close",onClick:()=>_(!1),"aria-label":"Close filters",children:"✕"})]}),e.jsx("div",{className:"sidebar__section-label",children:"Category"}),e.jsx(pe,{category:m,subCategory:o,onCategory:V,onSub:S}),e.jsx("div",{className:"sidebar__divider"}),e.jsx("div",{className:"sidebar__section-label",children:"Price"}),e.jsxs("div",{className:"price-filter",children:[e.jsxs("div",{className:"price-filter__inputs",children:[e.jsxs("label",{className:"price-filter__field",children:[e.jsx("span",{className:"price-filter__field-label",children:"Min"}),e.jsxs("span",{className:"price-filter__box",children:[e.jsx(C,{className:"price-filter__coin"}),e.jsx("input",{type:"number",min:"0","aria-label":"Minimum price",placeholder:"0",value:f,onChange:s=>k(s.target.value)})]})]}),e.jsx("span",{className:"price-filter__to",children:"to"}),e.jsxs("label",{className:"price-filter__field",children:[e.jsx("span",{className:"price-filter__field-label",children:"Max"}),e.jsxs("span",{className:"price-filter__box",children:[e.jsx(C,{className:"price-filter__coin"}),e.jsx("input",{type:"number",min:"0","aria-label":"Maximum price",placeholder:"0",value:x,onChange:s=>M(s.target.value)})]})]})]}),e.jsxs("div",{className:"price-filter__slider",style:{"--min-pct":`${re}%`,"--max-pct":`${ie}%`},children:[e.jsx("div",{className:"price-filter__track","aria-hidden":!0}),e.jsx("div",{className:"price-filter__fill","aria-hidden":!0}),e.jsx("input",{type:"range",min:0,max:t,value:y,"aria-label":"Minimum price slider",onChange:s=>te(Number(s.target.value))}),e.jsx("input",{type:"range",min:0,max:t,value:v,"aria-label":"Maximum price slider",onChange:s=>ne(Number(s.target.value))})]}),e.jsxs("div",{className:"price-filter__range",children:[e.jsxs("span",{className:"price-filter__range-val",children:[e.jsx(C,{className:"price-filter__coin"}),y.toLocaleString()]}),e.jsxs("span",{className:"price-filter__range-val",children:[e.jsx(C,{className:"price-filter__coin"}),v.toLocaleString()]})]})]}),e.jsx("div",{className:"sidebar__divider"}),e.jsxs("button",{type:"button",className:"sidebar__section-toggle","aria-expanded":w,onClick:()=>Q(s=>!s),children:[e.jsx("span",{className:"sidebar__section-label",children:"Rarity"}),e.jsx("span",{className:`ico ico-chevron sidebar__section-chev${w?" is-up":""}`,"aria-hidden":!0})]}),w?e.jsx("div",{className:"rarity-filter",children:_e.map(s=>e.jsxs("label",{className:`rarity-filter__check${l.includes(s)?" is-on":""}`,children:[e.jsx("input",{type:"checkbox",checked:l.includes(s),onChange:()=>Y(s)}),e.jsx("span",{children:s})]},s))}):null,e.jsxs("div",{className:"browse__sidebar-foot",children:[e.jsx("button",{type:"button",className:"browse__clear",onClick:ee,children:"Clear Filters"}),e.jsx("button",{type:"button",className:"browse__apply",onClick:()=>_(!1),children:"Apply"})]})]}),e.jsxs("div",{className:"browse__main",children:[e.jsx(fe,{sort:p,onSort:K,total:L,loading:c,query:n,onOpenFilters:()=>_(!0)}),z&&b.some(s=>s.source==="legacy")?e.jsx("p",{className:"market-banner market-banner--warn",children:"Some market prices are temporarily unavailable — buying those items is paused for a moment. Please try again shortly."}):null,J?e.jsx("p",{className:"error",children:"Couldn’t load items — please try again."}):null,e.jsx("div",{className:"grid",children:c?e.jsx(B,{count:15}):e.jsxs(e.Fragment,{children:[b.map(s=>s.source==="legacy"?e.jsx(T,{item:s,mode:"market",marketPriceCredits:H(s),onBuyNow:se},s.id):e.jsx(T,{item:s},s.id)),O?e.jsx(B,{count:6}):null]})}),e.jsx(he,{hasNextPage:X,isFetching:O,onLoadMore:()=>void Z()}),!c&&b.length===0?e.jsx("p",{className:"muted",children:"No items match your filters."}):null]}),F&&N?e.jsx(me,{listing:F,rate:N,onClose:()=>P(null),onSold:()=>{P(null),ae()}}):null]})}export{Oe as Assets};
@@ -1 +1 @@
1
- import{j as e,a as ke,b as ge,r as x,L as G}from"./react-yytiy0wi.js";import{C as v,ac as T,ad as g,a as ce,b as ve,d as Ne,r as Ce,u as we,o as D,ae as Se,t as q,af as re,ag as Ie,j as E,h as Me,i as Le,w as Pe,s as ne,ah as Be,x as ie,k as Re,ai as Ee}from"./index-CNSWvtL0.js";import{a as le}from"./buy-qpkIddNt.js";import{g as Te,a as We,w as Ae,S as $e,G as Fe}from"./buy-gasless-COqF6TfJ.js";import{R as U,r as qe}from"./cart-checkout-0Ra3OSr3.js";import{c as Ue,C as ze}from"./payments-D1TsNJWo.js";import{C as Ke}from"./CollectionCarousel-_a53Z75p.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-BtlpyT8N.js";import"./index-HN6Rk25C.js";function Ye(a){const{phase:c,balanceCredits:u,onClose:i}=a,N=c==="processing",I=c!=="complete",M=c==="nofunds"?"Buy Credits and Items":"Buy Assets",r=c==="processing";return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":"Check out your cart",children:[e.jsx("div",{className:"buy-modal__scrim",onClick:N?void 0:i,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${r?" buy-modal__card--tall":""}`,children:[I&&e.jsxs("div",{className:"buy-modal__head",children:[e.jsxs("div",{className:"buy-modal__head-row",children:[e.jsx("h2",{className:"buy-modal__title",children:M}),!N&&e.jsx("button",{className:"buy-modal__x",onClick:i,"aria-label":"Close",children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:c==="nofunds"?"DCL Balance:":"My Credits Balance:"}),e.jsx(v,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:T(u)})]})]}),c==="processing"&&e.jsx(Oe,{step:a.step??1,total:a.total??1}),c==="nofunds"&&e.jsx(Qe,{lines:a.lines??[],shortfallCredits:a.shortfallCredits??0,packs:a.packs??[],selectedPack:a.selectedPack??"",onSelectPack:a.onSelectPack??(()=>{}),onBuyPacks:a.onBuyPacks??(()=>{}),onCancel:i}),c==="complete"&&e.jsx(Ge,{purchased:a.purchased??[],onMyAssets:a.onMyAssets??i,onTryInWorld:a.onTryInWorld??i}),c==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx("p",{className:"buy-modal__error",children:a.message}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:i,children:"Close"})})]})]})]})}function Oe({step:a,total:c}){return e.jsxs("div",{className:"buy-modal__body buy-modal__processing",children:[e.jsx("img",{className:"buy-modal__logo",src:"/icon-192.png",alt:"",width:61,height:61}),e.jsx("div",{className:"buy-modal__processing-text",children:"Completing transaction…"}),e.jsxs("div",{className:"cart-checkout__progress-row",children:[e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})}),e.jsxs("span",{className:"cart-checkout__step",children:[a,"/",c]})]})]})}function Qe({lines:a,shortfallCredits:c,packs:u,selectedPack:i,onSelectPack:N,onBuyPacks:I,onCancel:M}){const r=u.find(l=>l.id===i);return e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__warning",children:[e.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":!0,className:"buy-modal__warning-ico",children:[e.jsx("path",{d:"M12 3L2 20h20L12 3z",fill:"none",stroke:"#691fa9",strokeWidth:"1.8",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 9v5",stroke:"#691fa9",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"17",r:"1.1",fill:"#691fa9"})]}),e.jsxs("p",{className:"buy-modal__warning-text",children:[e.jsx("b",{children:"Insufficient Funds."})," You will need to buy ",e.jsxs("b",{children:[Math.max(0,c)," Credits"]})," to purchase",a.length===1?" this item.":" these items."]})]}),e.jsx("div",{className:"cart-checkout__scroll",children:a.map(l=>e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:l.item.thumbnail?e.jsx("img",{src:l.item.thumbnail,alt:""}):null}),e.jsxs("div",{className:"buy-modal__asset-info",children:[e.jsxs("div",{children:[e.jsx("div",{className:"buy-modal__asset-name",title:l.item.name,children:l.item.name||"Item"}),l.item.creator?e.jsxs("div",{className:"buy-modal__asset-creator",children:["By ",l.item.creator]}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(v,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:T(l.priceCredits)})]})]})]},l.item.id))}),e.jsx("div",{className:"buy-modal__packs",children:u.map(l=>{const L=l.id===i;return e.jsxs("button",{className:`buy-modal__pack${L?" buy-modal__pack--on":""}`,onClick:()=>N(l.id),children:[e.jsx(v,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:T(l.credits)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",l.usd.toFixed(2),")"]})]},l.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(v,{className:"buy-modal__total-ico"}),e.jsx("span",{children:T((r==null?void 0:r.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",((r==null?void 0:r.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:M,children:"Cancel"}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:I,children:"Buy"})]})]})}function Ge({purchased:a,onMyAssets:c,onTryInWorld:u}){return e.jsxs("div",{className:"buy-modal__body cart-checkout__done-body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"60",height:"60","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce77"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:"Your purchase was successful!"})," You can find your item in the My Assets tab."]})]}),e.jsx("div",{className:"cart-checkout__done",children:e.jsx("div",{className:"cart-checkout__done-scroll",children:a.map(i=>e.jsxs("div",{className:"cart-checkout__done-row",children:[e.jsxs("div",{className:"cart-checkout__done-thumb",children:[i.thumbnail?e.jsx("img",{src:i.thumbnail,alt:""}):null,e.jsx("span",{className:"cart-checkout__done-check","aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:e.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{className:"cart-checkout__done-info",children:[e.jsx("div",{className:"cart-checkout__done-name",title:i.name,children:i.name||"Item"}),i.creator?e.jsxs("div",{className:"cart-checkout__done-creator",children:["By ",i.creator]}):null]}),e.jsxs("div",{className:"cart-checkout__done-price",children:[e.jsx(v,{className:"cart-checkout__done-price-ico"}),e.jsx("span",{children:T(i.priceCredits)})]})]},i.id))})}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:c,children:"My assets"}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:u,children:["Try in world",e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})}function oe(a){const c=a,u=(c.message??"").toLowerCase();return c.code===4001||u.includes("reject")||u.includes("denied")||u.includes("cancel")?"You cancelled the request.":u.includes("insufficient")?`You don't have enough ${Le.name} — get more first.`:u.includes("no active listing")||u.includes("your own listing")?c.message:"Couldn't complete checkout — please try again."}function De(a){const c=a;return c.code===402||c.status===402||(c.message??"").toLowerCase().includes("insufficient")}const Je=12e4,z=ze.slice(0,3),Ve=Me.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump";function He(a){const c=[];return a.unavailable.length&&c.push(`${a.unavailable.length} no longer available`),a.own.length&&c.push(`${a.own.length} you can't buy (your own listing)`),`Removed ${c.join(" and ")} from your cart.`}function us(){const a=g(s=>s.items),c=g(s=>s.remove),u=g(s=>s.clear),i=g(s=>s.restore),N=g(s=>s.setFittingOpen),I=ce(s=>s.items),M=ce(s=>s.toggle),{session:r}=ve(),l=a.some(s=>s.category!=="emote"),{data:L}=Ne({queryKey:["upsell-listings"],queryFn:()=>Ee({first:40}),staleTime:6e4}),{data:P}=Ce(r),W=we(),A=ke(),{state:C}=ge(),[J,B]=x.useState(null),[V,f]=x.useState(null),[H,$]=x.useState(null),[de,w]=x.useState(!1),[y,R]=x.useState(null),X=x.useRef(0),[o,j]=x.useState(null),[K,Z]=x.useState(""),ue=a.reduce((s,t)=>s+t.priceCredits,0),he=y?y.liveTotalCredits:ue,me=new Set(a.map(s=>s.id)),ee=((L==null?void 0:L.items)??[]).filter(s=>!me.has(s.id)).slice(0,12),_e=new Map(y==null?void 0:y.buyable.map(s=>[s.item.id,s])),F=(P==null?void 0:P.credits)??0,pe=Ie;function Y(s){s(),R(null),$(null),f(null)}function be(){j(null),w(!1)}function se(s){const t=s.reduce((h,d)=>h+d.priceCredits,0),n=Math.max(0,t-F),b=z.find(h=>h.credits>=n)??z[z.length-1];Z(b.id),q("Shop Buy Credits Prompted",{from:"cart_checkout",credits_needed:t,credits_balance:F,shortfall:n}),j({phase:"nofunds",lines:s.map(h=>({item:h.item,priceCredits:h.priceCredits})),shortfall:n}),w(!1)}async function ye(s){if(!r||s.length===0)return;const t=s.map(d=>({...d.item,priceCredits:d.priceCredits})),n=[];let b="authorize",h=!1;j({phase:"processing",step:1,total:s.length});try{const d=[];for(let _=0;_<s.length;_++){const k=s[_];j({phase:"processing",step:_+1,total:s.length});try{const{credit:p,maxCreditedValue:Q}=await Pe(r.identity,k.usdCents,k.trade.id);n.push(p.id),d.push({trade:k.trade,credits:[p],maxCreditedValue:Q})}catch(p){if(De(p)){if(n.length){try{await ne(r.identity,n)}catch(Q){E(Q,{flow:"cart_checkout",step:"release"})}W.invalidateQueries({queryKey:["usd-balance"]})}se(s);return}throw p}}b="submit";let m=[];if(Te())try{m=await We({purchases:d,buyer:r.address,signer:r.signer});const k=(await Promise.allSettled(m.map(p=>Ae(p)))).flatMap(p=>p.status==="rejected"?[p.reason]:[]);if(k.length&&!k.some(p=>p instanceof $e))throw k[0];h=!0}catch(_){if(!(_ instanceof Fe))throw _;m=await le({purchases:d,buyer:r.address,signer:r.signer})}else m=await le({purchases:d,buyer:r.address,signer:r.signer});s.forEach(_=>c(_.item.id)),R(null),q("Shop Completed Purchase",{...Be(t),payment_type:"credits",no_crypto_step:h,transaction_hash:m[0]??null}),W.invalidateQueries({queryKey:["usd-balance"]}),j({phase:"complete",purchased:t})}catch(d){if(ie(d)||E(d,{flow:"cart_checkout",step:b,cart_size:s.length}),q(ie(d)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:b,error_code:Re(d),value_usd:re(t.reduce((m,_)=>m+_.priceCredits,0)),cart_size:s.length}),n.length){try{await ne(r.identity,n)}catch(m){E(m,{flow:"cart_checkout",step:"release"})}W.invalidateQueries({queryKey:["usd-balance"]})}j({phase:"error",message:oe(d)})}}function ae(s){const t=s.reduce((n,b)=>n+b.priceCredits,0);if(P!=null&&P.credits<t){se(s);return}ye(s)}async function O(){if(!r){f("Sign in to check out.");return}const s=g.getState().items;if(s.length!==0){f(null),$(null),w(!0),q("Shop Started Checkout",{cart_size:s.length,cart_value_credits:s.reduce((t,n)=>t+n.priceCredits,0),cart_value_usd:re(s.reduce((t,n)=>t+n.priceCredits,0)),has_sufficient_credits:F>=s.reduce((t,n)=>t+n.priceCredits,0)});try{B("Reviewing your cart…");const t=await qe(s,r.address,pe),n=[...t.unavailable,...t.own];if(n.length&&(n.forEach(b=>c(b.id)),$(He(t))),t.buyable.length===0){f("None of these items are available to buy right now."),R(null),B(null);return}if(t.orderChanged){R(t),X.current=Date.now(),B(null);return}B(null),ae(t.buyable)}catch(t){E(t,{flow:"cart_checkout",step:"review",cart_size:s.length}),f(oe(t)),B(null)}finally{w(!1)}}}async function xe(){if(y){if(!r){f("Sign in to check out.");return}if(Date.now()-X.current>Je){R(null),$(null),await O();return}f(null),ae(y.buyable)}}async function fe(){if(K){try{sessionStorage.setItem(U,JSON.stringify(g.getState().items))}catch{}w(!0);try{const s=await Ue(K,r?{address:r.address,identity:r.identity}:void 0);if(s.url){window.location.href=s.url;return}A("/credits")}catch(s){try{sessionStorage.removeItem(U)}catch{}E(s,{flow:"cart_buy_credits"}),j({phase:"error",message:"Couldn't start the credits checkout — please try again."})}finally{w(!1)}}}const te=x.useRef(!1);x.useEffect(()=>{if(!(C!=null&&C.resumeCheckout)||te.current)return;te.current=!0;try{const t=sessionStorage.getItem(U);if(t){sessionStorage.removeItem(U);const n=JSON.parse(t);Array.isArray(n)&&n.length&&i(n)}}catch{}W.invalidateQueries({queryKey:["usd-balance"]});const s=setTimeout(()=>void O(),0);return()=>clearTimeout(s)},[C==null?void 0:C.resumeCheckout]);const S=de||(o==null?void 0:o.phase)==="processing";if(a.length===0&&!o)return e.jsxs("div",{className:"cart cart--empty",children:[e.jsx("span",{className:"ico ico-cart cart-empty__ico","aria-hidden":!0}),e.jsx("p",{className:"cart-empty__title",children:D("cart.empty.title")}),e.jsx("p",{className:"muted",children:D("cart.empty.body")}),e.jsx(G,{className:"btn btn--purple",to:"/assets",children:D("cart.empty.cta")})]});const je=a.length===1?"Item":"Items";return e.jsxs("div",{className:"checkout",children:[e.jsxs("button",{className:"checkout__back",onClick:()=>A(-1),type:"button",children:[e.jsx("span",{className:"ico ico-arrow-left","aria-hidden":!0}),"Cart"]}),e.jsxs("div",{className:"checkout__body",children:[e.jsxs("section",{className:"checkout__panel",children:[e.jsxs("div",{className:"checkout__panel-head",children:[e.jsx("button",{className:"checkout__panel-back",onClick:()=>A(-1),type:"button","aria-label":"Go back",children:e.jsx("span",{className:"ico ico-arrow-left","aria-hidden":!0})}),e.jsxs("h1",{className:"checkout__panel-title",children:["Cart: ",a.length," ",je]}),l?e.jsxs("button",{className:"checkout__fitting",onClick:()=>N(!0),disabled:S,children:[e.jsx("span",{className:"ico ico-fitting-room checkout__fitting-ico","aria-hidden":!0}),"Fitting Room"]}):null]}),e.jsx("div",{className:"checkout__list",children:a.map(s=>{const t=_e.get(s.id),n=t?t.priceCredits:s.priceCredits,b=!!t&&t.priceCredits!==s.priceCredits,h=!!I[s.id],d=s.tokenId??s.itemId,m=s.contractAddress&&d?`/item/${s.contractAddress}/${d}`:null;return e.jsxs("div",{className:"checkout__card",children:[e.jsxs("div",{className:"checkout__thumb",children:[m?e.jsx(G,{className:"checkout__thumb-link",to:m,state:{item:s,tradeId:s.tradeId},"aria-label":s.name,children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:s.name}):null}):s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:s.name}):null,e.jsx("span",{className:"checkout__thumb-check","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("div",{className:"checkout__info",children:[e.jsxs("div",{className:"checkout__desc",children:[m?e.jsx(G,{className:"checkout__name",to:m,state:{item:s,tradeId:s.tradeId},title:s.name,children:s.name}):e.jsx("div",{className:"checkout__name",title:s.name,children:s.name}),s.creator?e.jsx(Se,{address:s.creator,className:"checkout__creator",linkToProfile:!0}):null]}),e.jsxs("div",{className:"checkout__foot",children:[e.jsxs("div",{className:"checkout__stepper",children:[e.jsx("button",{className:"checkout__step",onClick:()=>Y(()=>c(s.id)),disabled:S,"aria-label":`Remove ${s.name} from cart`,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("span",{className:"checkout__qty",children:"1"}),e.jsx("button",{className:"checkout__step",disabled:!0,"aria-label":"Increase quantity",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"})})})]}),e.jsxs("div",{className:"checkout__price",children:[e.jsx(v,{className:"checkout__price-ico"})," ",n,b?e.jsx("span",{className:"checkout__price-was",children:s.priceCredits}):null]})]})]}),e.jsxs("div",{className:"checkout__actions",children:[e.jsx("button",{className:`checkout__fav${h?" is-on":""}`,onClick:()=>M(s),"aria-label":h?`Remove ${s.name} from favorites`:`Add ${s.name} to favorites`,title:h?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:`ico ${h?"ico-heart-solid":"ico-heart"}`,"aria-hidden":!0})}),e.jsx("button",{className:"checkout__remove",onClick:()=>Y(()=>c(s.id)),disabled:S,"aria-label":`Remove ${s.name}`,title:"Remove",children:e.jsx("span",{className:"ico ico-trash","aria-hidden":!0})})]})]},s.id)})}),e.jsxs("div",{className:"checkout__utils",children:[e.jsx("button",{className:"link",onClick:()=>Y(u),disabled:S,children:"Clear cart"}),null]})]}),e.jsxs("aside",{className:"checkout__summary",children:[e.jsx("h2",{className:"checkout__summary-title",children:"Purchase Summary"}),e.jsxs("div",{className:"checkout__summary-body",children:[e.jsxs("div",{className:"checkout__total-line",children:[e.jsxs("span",{className:"checkout__total-label",children:["Total: ",a.length," ",a.length===1?"item":"items"]}),e.jsxs("span",{className:"checkout__total-value",children:[e.jsx(v,{className:"checkout__total-ico"})," ",he]})]}),e.jsx("button",{className:"checkout__cta",onClick:y?xe:O,disabled:S,children:S?"Working…":y?"Confirm purchase":"Buy now"}),y?e.jsx("p",{className:"muted checkout__msg",children:"Prices or availability changed since you added these — review the updated total and confirm to buy."}):null,H?e.jsx("p",{className:"muted checkout__msg",children:H}):null,J?e.jsx("p",{className:"muted checkout__msg",children:J}):null,V?e.jsx("p",{className:"error checkout__msg",children:V}):null]})]})]}),ee.length>0?e.jsx("div",{className:"cart-upsell",children:e.jsx(Ke,{title:"You might also like",items:ee})}):null,o?e.jsx(Ye,{phase:o.phase,balanceCredits:F,onClose:be,step:o.phase==="processing"?o.step:void 0,total:o.phase==="processing"?o.total:void 0,lines:o.phase==="nofunds"?o.lines:void 0,shortfallCredits:o.phase==="nofunds"?o.shortfall:void 0,packs:z,selectedPack:K,onSelectPack:Z,onBuyPacks:fe,purchased:o.phase==="complete"?o.purchased:void 0,onMyAssets:()=>A("/assets?tab=mine"),onTryInWorld:()=>window.open(Ve,"_blank","noopener"),message:o.phase==="error"?o.message:void 0}):null]})}export{us as Cart};
1
+ import{j as e,a as ke,b as ge,r as x,L as G}from"./react-yytiy0wi.js";import{C as v,ac as T,ad as g,a as ce,b as ve,d as Ne,m as Ce,u as we,k as D,ae as Se,t as q,af as re,ag as Ie,y as E,h as Me,r as Le,s as Pe,n as ne,ah as Be,w as ie,v as Re,ai as Ee}from"./index-BLIz_7l9.js";import{a as le}from"./buy-BuqGUyRC.js";import{g as Te,a as We,w as Ae,S as $e,G as Fe}from"./buy-gasless-D1dur72K.js";import{R as U,r as qe}from"./cart-checkout-rwvAvzgx.js";import{c as Ue,C as ze}from"./payments-BQ7DJXcX.js";import{C as Ke}from"./CollectionCarousel-CUkjxu-O.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-BOIcOdJd.js";import"./index-HN6Rk25C.js";function Ye(a){const{phase:c,balanceCredits:u,onClose:i}=a,N=c==="processing",I=c!=="complete",M=c==="nofunds"?"Buy Credits and Items":"Buy Assets",r=c==="processing";return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":"Check out your cart",children:[e.jsx("div",{className:"buy-modal__scrim",onClick:N?void 0:i,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${r?" buy-modal__card--tall":""}`,children:[I&&e.jsxs("div",{className:"buy-modal__head",children:[e.jsxs("div",{className:"buy-modal__head-row",children:[e.jsx("h2",{className:"buy-modal__title",children:M}),!N&&e.jsx("button",{className:"buy-modal__x",onClick:i,"aria-label":"Close",children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:c==="nofunds"?"DCL Balance:":"My Credits Balance:"}),e.jsx(v,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:T(u)})]})]}),c==="processing"&&e.jsx(Oe,{step:a.step??1,total:a.total??1}),c==="nofunds"&&e.jsx(Qe,{lines:a.lines??[],shortfallCredits:a.shortfallCredits??0,packs:a.packs??[],selectedPack:a.selectedPack??"",onSelectPack:a.onSelectPack??(()=>{}),onBuyPacks:a.onBuyPacks??(()=>{}),onCancel:i}),c==="complete"&&e.jsx(Ge,{purchased:a.purchased??[],onMyAssets:a.onMyAssets??i,onTryInWorld:a.onTryInWorld??i}),c==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx("p",{className:"buy-modal__error",children:a.message}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:i,children:"Close"})})]})]})]})}function Oe({step:a,total:c}){return e.jsxs("div",{className:"buy-modal__body buy-modal__processing",children:[e.jsx("img",{className:"buy-modal__logo",src:"/icon-192.png",alt:"",width:61,height:61}),e.jsx("div",{className:"buy-modal__processing-text",children:"Completing transaction…"}),e.jsxs("div",{className:"cart-checkout__progress-row",children:[e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})}),e.jsxs("span",{className:"cart-checkout__step",children:[a,"/",c]})]})]})}function Qe({lines:a,shortfallCredits:c,packs:u,selectedPack:i,onSelectPack:N,onBuyPacks:I,onCancel:M}){const r=u.find(l=>l.id===i);return e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__warning",children:[e.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":!0,className:"buy-modal__warning-ico",children:[e.jsx("path",{d:"M12 3L2 20h20L12 3z",fill:"none",stroke:"#691fa9",strokeWidth:"1.8",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 9v5",stroke:"#691fa9",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"17",r:"1.1",fill:"#691fa9"})]}),e.jsxs("p",{className:"buy-modal__warning-text",children:[e.jsx("b",{children:"Insufficient Funds."})," You will need to buy ",e.jsxs("b",{children:[Math.max(0,c)," Credits"]})," to purchase",a.length===1?" this item.":" these items."]})]}),e.jsx("div",{className:"cart-checkout__scroll",children:a.map(l=>e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:l.item.thumbnail?e.jsx("img",{src:l.item.thumbnail,alt:""}):null}),e.jsxs("div",{className:"buy-modal__asset-info",children:[e.jsxs("div",{children:[e.jsx("div",{className:"buy-modal__asset-name",title:l.item.name,children:l.item.name||"Item"}),l.item.creator?e.jsxs("div",{className:"buy-modal__asset-creator",children:["By ",l.item.creator]}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(v,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:T(l.priceCredits)})]})]})]},l.item.id))}),e.jsx("div",{className:"buy-modal__packs",children:u.map(l=>{const L=l.id===i;return e.jsxs("button",{className:`buy-modal__pack${L?" buy-modal__pack--on":""}`,onClick:()=>N(l.id),children:[e.jsx(v,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:T(l.credits)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",l.usd.toFixed(2),")"]})]},l.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(v,{className:"buy-modal__total-ico"}),e.jsx("span",{children:T((r==null?void 0:r.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",((r==null?void 0:r.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:M,children:"Cancel"}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:I,children:"Buy"})]})]})}function Ge({purchased:a,onMyAssets:c,onTryInWorld:u}){return e.jsxs("div",{className:"buy-modal__body cart-checkout__done-body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"60",height:"60","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce77"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:"Your purchase was successful!"})," You can find your item in the My Assets tab."]})]}),e.jsx("div",{className:"cart-checkout__done",children:e.jsx("div",{className:"cart-checkout__done-scroll",children:a.map(i=>e.jsxs("div",{className:"cart-checkout__done-row",children:[e.jsxs("div",{className:"cart-checkout__done-thumb",children:[i.thumbnail?e.jsx("img",{src:i.thumbnail,alt:""}):null,e.jsx("span",{className:"cart-checkout__done-check","aria-hidden":!0,children:e.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:e.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.2",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),e.jsxs("div",{className:"cart-checkout__done-info",children:[e.jsx("div",{className:"cart-checkout__done-name",title:i.name,children:i.name||"Item"}),i.creator?e.jsxs("div",{className:"cart-checkout__done-creator",children:["By ",i.creator]}):null]}),e.jsxs("div",{className:"cart-checkout__done-price",children:[e.jsx(v,{className:"cart-checkout__done-price-ico"}),e.jsx("span",{children:T(i.priceCredits)})]})]},i.id))})}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:c,children:"My assets"}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:u,children:["Try in world",e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})}function oe(a){const c=a,u=(c.message??"").toLowerCase();return c.code===4001||u.includes("reject")||u.includes("denied")||u.includes("cancel")?"You cancelled the request.":u.includes("insufficient")?`You don't have enough ${Le.name} — get more first.`:u.includes("no active listing")||u.includes("your own listing")?c.message:"Couldn't complete checkout — please try again."}function De(a){const c=a;return c.code===402||c.status===402||(c.message??"").toLowerCase().includes("insufficient")}const Je=12e4,z=ze.slice(0,3),Ve=Me.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump";function He(a){const c=[];return a.unavailable.length&&c.push(`${a.unavailable.length} no longer available`),a.own.length&&c.push(`${a.own.length} you can't buy (your own listing)`),`Removed ${c.join(" and ")} from your cart.`}function us(){const a=g(s=>s.items),c=g(s=>s.remove),u=g(s=>s.clear),i=g(s=>s.restore),N=g(s=>s.setFittingOpen),I=ce(s=>s.items),M=ce(s=>s.toggle),{session:r}=ve(),l=a.some(s=>s.category!=="emote"),{data:L}=Ne({queryKey:["upsell-listings"],queryFn:()=>Ee({first:40}),staleTime:6e4}),{data:P}=Ce(r),W=we(),A=ke(),{state:C}=ge(),[J,B]=x.useState(null),[V,f]=x.useState(null),[H,$]=x.useState(null),[de,w]=x.useState(!1),[y,R]=x.useState(null),X=x.useRef(0),[o,j]=x.useState(null),[K,Z]=x.useState(""),ue=a.reduce((s,t)=>s+t.priceCredits,0),he=y?y.liveTotalCredits:ue,me=new Set(a.map(s=>s.id)),ee=((L==null?void 0:L.items)??[]).filter(s=>!me.has(s.id)).slice(0,12),_e=new Map(y==null?void 0:y.buyable.map(s=>[s.item.id,s])),F=(P==null?void 0:P.credits)??0,pe=Ie;function Y(s){s(),R(null),$(null),f(null)}function be(){j(null),w(!1)}function se(s){const t=s.reduce((h,d)=>h+d.priceCredits,0),n=Math.max(0,t-F),b=z.find(h=>h.credits>=n)??z[z.length-1];Z(b.id),q("Shop Buy Credits Prompted",{from:"cart_checkout",credits_needed:t,credits_balance:F,shortfall:n}),j({phase:"nofunds",lines:s.map(h=>({item:h.item,priceCredits:h.priceCredits})),shortfall:n}),w(!1)}async function ye(s){if(!r||s.length===0)return;const t=s.map(d=>({...d.item,priceCredits:d.priceCredits})),n=[];let b="authorize",h=!1;j({phase:"processing",step:1,total:s.length});try{const d=[];for(let _=0;_<s.length;_++){const k=s[_];j({phase:"processing",step:_+1,total:s.length});try{const{credit:p,maxCreditedValue:Q}=await Pe(r.identity,k.usdCents,k.trade.id);n.push(p.id),d.push({trade:k.trade,credits:[p],maxCreditedValue:Q})}catch(p){if(De(p)){if(n.length){try{await ne(r.identity,n)}catch(Q){E(Q,{flow:"cart_checkout",step:"release"})}W.invalidateQueries({queryKey:["usd-balance"]})}se(s);return}throw p}}b="submit";let m=[];if(Te())try{m=await We({purchases:d,buyer:r.address,signer:r.signer});const k=(await Promise.allSettled(m.map(p=>Ae(p)))).flatMap(p=>p.status==="rejected"?[p.reason]:[]);if(k.length&&!k.some(p=>p instanceof $e))throw k[0];h=!0}catch(_){if(!(_ instanceof Fe))throw _;m=await le({purchases:d,buyer:r.address,signer:r.signer})}else m=await le({purchases:d,buyer:r.address,signer:r.signer});s.forEach(_=>c(_.item.id)),R(null),q("Shop Completed Purchase",{...Be(t),payment_type:"credits",no_crypto_step:h,transaction_hash:m[0]??null}),W.invalidateQueries({queryKey:["usd-balance"]}),j({phase:"complete",purchased:t})}catch(d){if(ie(d)||E(d,{flow:"cart_checkout",step:b,cart_size:s.length}),q(ie(d)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:b,error_code:Re(d),value_usd:re(t.reduce((m,_)=>m+_.priceCredits,0)),cart_size:s.length}),n.length){try{await ne(r.identity,n)}catch(m){E(m,{flow:"cart_checkout",step:"release"})}W.invalidateQueries({queryKey:["usd-balance"]})}j({phase:"error",message:oe(d)})}}function ae(s){const t=s.reduce((n,b)=>n+b.priceCredits,0);if(P!=null&&P.credits<t){se(s);return}ye(s)}async function O(){if(!r){f("Sign in to check out.");return}const s=g.getState().items;if(s.length!==0){f(null),$(null),w(!0),q("Shop Started Checkout",{cart_size:s.length,cart_value_credits:s.reduce((t,n)=>t+n.priceCredits,0),cart_value_usd:re(s.reduce((t,n)=>t+n.priceCredits,0)),has_sufficient_credits:F>=s.reduce((t,n)=>t+n.priceCredits,0)});try{B("Reviewing your cart…");const t=await qe(s,r.address,pe),n=[...t.unavailable,...t.own];if(n.length&&(n.forEach(b=>c(b.id)),$(He(t))),t.buyable.length===0){f("None of these items are available to buy right now."),R(null),B(null);return}if(t.orderChanged){R(t),X.current=Date.now(),B(null);return}B(null),ae(t.buyable)}catch(t){E(t,{flow:"cart_checkout",step:"review",cart_size:s.length}),f(oe(t)),B(null)}finally{w(!1)}}}async function xe(){if(y){if(!r){f("Sign in to check out.");return}if(Date.now()-X.current>Je){R(null),$(null),await O();return}f(null),ae(y.buyable)}}async function fe(){if(K){try{sessionStorage.setItem(U,JSON.stringify(g.getState().items))}catch{}w(!0);try{const s=await Ue(K,r?{address:r.address,identity:r.identity}:void 0);if(s.url){window.location.href=s.url;return}A("/credits")}catch(s){try{sessionStorage.removeItem(U)}catch{}E(s,{flow:"cart_buy_credits"}),j({phase:"error",message:"Couldn't start the credits checkout — please try again."})}finally{w(!1)}}}const te=x.useRef(!1);x.useEffect(()=>{if(!(C!=null&&C.resumeCheckout)||te.current)return;te.current=!0;try{const t=sessionStorage.getItem(U);if(t){sessionStorage.removeItem(U);const n=JSON.parse(t);Array.isArray(n)&&n.length&&i(n)}}catch{}W.invalidateQueries({queryKey:["usd-balance"]});const s=setTimeout(()=>void O(),0);return()=>clearTimeout(s)},[C==null?void 0:C.resumeCheckout]);const S=de||(o==null?void 0:o.phase)==="processing";if(a.length===0&&!o)return e.jsxs("div",{className:"cart cart--empty",children:[e.jsx("span",{className:"ico ico-cart cart-empty__ico","aria-hidden":!0}),e.jsx("p",{className:"cart-empty__title",children:D("cart.empty.title")}),e.jsx("p",{className:"muted",children:D("cart.empty.body")}),e.jsx(G,{className:"btn btn--purple",to:"/assets",children:D("cart.empty.cta")})]});const je=a.length===1?"Item":"Items";return e.jsxs("div",{className:"checkout",children:[e.jsxs("button",{className:"checkout__back",onClick:()=>A(-1),type:"button",children:[e.jsx("span",{className:"ico ico-arrow-left","aria-hidden":!0}),"Cart"]}),e.jsxs("div",{className:"checkout__body",children:[e.jsxs("section",{className:"checkout__panel",children:[e.jsxs("div",{className:"checkout__panel-head",children:[e.jsx("button",{className:"checkout__panel-back",onClick:()=>A(-1),type:"button","aria-label":"Go back",children:e.jsx("span",{className:"ico ico-arrow-left","aria-hidden":!0})}),e.jsxs("h1",{className:"checkout__panel-title",children:["Cart: ",a.length," ",je]}),l?e.jsxs("button",{className:"checkout__fitting",onClick:()=>N(!0),disabled:S,children:[e.jsx("span",{className:"ico ico-fitting-room checkout__fitting-ico","aria-hidden":!0}),"Fitting Room"]}):null]}),e.jsx("div",{className:"checkout__list",children:a.map(s=>{const t=_e.get(s.id),n=t?t.priceCredits:s.priceCredits,b=!!t&&t.priceCredits!==s.priceCredits,h=!!I[s.id],d=s.tokenId??s.itemId,m=s.contractAddress&&d?`/item/${s.contractAddress}/${d}`:null;return e.jsxs("div",{className:"checkout__card",children:[e.jsxs("div",{className:"checkout__thumb",children:[m?e.jsx(G,{className:"checkout__thumb-link",to:m,state:{item:s,tradeId:s.tradeId},"aria-label":s.name,children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:s.name}):null}):s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:s.name}):null,e.jsx("span",{className:"checkout__thumb-check","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("div",{className:"checkout__info",children:[e.jsxs("div",{className:"checkout__desc",children:[m?e.jsx(G,{className:"checkout__name",to:m,state:{item:s,tradeId:s.tradeId},title:s.name,children:s.name}):e.jsx("div",{className:"checkout__name",title:s.name,children:s.name}),s.creator?e.jsx(Se,{address:s.creator,className:"checkout__creator",linkToProfile:!0}):null]}),e.jsxs("div",{className:"checkout__foot",children:[e.jsxs("div",{className:"checkout__stepper",children:[e.jsx("button",{className:"checkout__step",onClick:()=>Y(()=>c(s.id)),disabled:S,"aria-label":`Remove ${s.name} from cart`,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("span",{className:"checkout__qty",children:"1"}),e.jsx("button",{className:"checkout__step",disabled:!0,"aria-label":"Increase quantity",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"})})})]}),e.jsxs("div",{className:"checkout__price",children:[e.jsx(v,{className:"checkout__price-ico"})," ",n,b?e.jsx("span",{className:"checkout__price-was",children:s.priceCredits}):null]})]})]}),e.jsxs("div",{className:"checkout__actions",children:[e.jsx("button",{className:`checkout__fav${h?" is-on":""}`,onClick:()=>M(s),"aria-label":h?`Remove ${s.name} from favorites`:`Add ${s.name} to favorites`,title:h?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:`ico ${h?"ico-heart-solid":"ico-heart"}`,"aria-hidden":!0})}),e.jsx("button",{className:"checkout__remove",onClick:()=>Y(()=>c(s.id)),disabled:S,"aria-label":`Remove ${s.name}`,title:"Remove",children:e.jsx("span",{className:"ico ico-trash","aria-hidden":!0})})]})]},s.id)})}),e.jsxs("div",{className:"checkout__utils",children:[e.jsx("button",{className:"link",onClick:()=>Y(u),disabled:S,children:"Clear cart"}),null]})]}),e.jsxs("aside",{className:"checkout__summary",children:[e.jsx("h2",{className:"checkout__summary-title",children:"Purchase Summary"}),e.jsxs("div",{className:"checkout__summary-body",children:[e.jsxs("div",{className:"checkout__total-line",children:[e.jsxs("span",{className:"checkout__total-label",children:["Total: ",a.length," ",a.length===1?"item":"items"]}),e.jsxs("span",{className:"checkout__total-value",children:[e.jsx(v,{className:"checkout__total-ico"})," ",he]})]}),e.jsx("button",{className:"checkout__cta",onClick:y?xe:O,disabled:S,children:S?"Working…":y?"Confirm purchase":"Buy now"}),y?e.jsx("p",{className:"muted checkout__msg",children:"Prices or availability changed since you added these — review the updated total and confirm to buy."}):null,H?e.jsx("p",{className:"muted checkout__msg",children:H}):null,J?e.jsx("p",{className:"muted checkout__msg",children:J}):null,V?e.jsx("p",{className:"error checkout__msg",children:V}):null]})]})]}),ee.length>0?e.jsx("div",{className:"cart-upsell",children:e.jsx(Ke,{title:"You might also like",items:ee})}):null,o?e.jsx(Ye,{phase:o.phase,balanceCredits:F,onClose:be,step:o.phase==="processing"?o.step:void 0,total:o.phase==="processing"?o.total:void 0,lines:o.phase==="nofunds"?o.lines:void 0,shortfallCredits:o.phase==="nofunds"?o.shortfall:void 0,packs:z,selectedPack:K,onSelectPack:Z,onBuyPacks:fe,purchased:o.phase==="complete"?o.purchased:void 0,onMyAssets:()=>A("/assets?tab=mine"),onTryInWorld:()=>window.open(Ve,"_blank","noopener"),message:o.phase==="error"?o.message:void 0}):null]})}export{us as Cart};
@@ -1,4 +1,4 @@
1
- import{L as N,M as U,N as w,O as z,P as o,Q as E,R as c,S as I,U as g,V as D,X as M}from"./index-CNSWvtL0.js";import{r as F,j as v}from"./react-yytiy0wi.js";function K(r){return N("MuiCircularProgress",r)}U("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);const L=["className","color","disableShrink","size","style","thickness","value","variant"];let l=r=>r,P,S,b,$;const t=44,V=M(P||(P=l`
1
+ import{L as N,M as U,N as w,O as z,P as o,Q as E,R as c,S as I,U as g,V as D,X as M}from"./index-BLIz_7l9.js";import{r as F,j as v}from"./react-yytiy0wi.js";function K(r){return N("MuiCircularProgress",r)}U("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);const L=["className","color","disableShrink","size","style","thickness","value","variant"];let l=r=>r,P,S,b,$;const t=44,V=M(P||(P=l`
2
2
  0% {
3
3
  transform: rotate(0deg);
4
4
  }
@@ -1 +1 @@
1
- import{j as e,r as m,d as O,a as Q}from"./react-yytiy0wi.js";import{E as Y,o as t,h as Z,j as z,d as J,i as V,A as W,al as X,am as ee}from"./index-CNSWvtL0.js";import{d as ae,s as M,g as re,a as se,A as te}from"./collection-s3UDaDJs.js";import{u as ce}from"./useStore-BomIn5qc.js";import{S as T,C as oe,F as ie,c as le,a as F,b as ne}from"./categories-Chd4fnsf.js";import{L as de}from"./LoadMore-CiZkVzux.js";import{u as me}from"./useInfiniteGrid-Bso7ZIlQ.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";function ue({name:r,creator:a}){const{data:c}=ce(a),i=(c==null?void 0:c.cover)||ae;return e.jsxs("section",{className:"collection-hero","aria-label":r,children:[e.jsxs("div",{className:"collection-hero__cover",children:[e.jsx("img",{className:"collection-hero__cover-img",src:i,alt:"",loading:"eager"}),e.jsx("div",{className:"collection-hero__scrim","aria-hidden":!0})]}),e.jsx("h1",{className:"collection-hero__title",children:r})]})}function pe({address:r}){var x,o;const{data:a}=Y(r),[c,i]=m.useState(!1);if(!r)return null;const l=(a==null?void 0:a.name)||M(r),u=(o=(x=a==null?void 0:a.avatar)==null?void 0:x.snapshots)==null?void 0:o.face256,p=`${Z.profileUrl}/${r}`,g=re(se({name:a==null?void 0:a.name,hasClaimedName:a==null?void 0:a.hasClaimedName,ethAddress:(a==null?void 0:a.ethAddress)??r}));async function n(){try{await navigator.clipboard.writeText(r),i(!0),window.setTimeout(()=>i(!1),1500)}catch(_){z(_,{flow:"copy_creator_address"})}}return e.jsxs("div",{className:"creator-card",children:[u?e.jsx("img",{className:"creator-card__ava",src:u,alt:"",loading:"eager",style:{backgroundColor:g}}):e.jsx("span",{className:"creator-card__ava creator-card__ava--ph","aria-hidden":!0,style:{backgroundColor:g}}),e.jsx("h2",{className:"creator-card__name",title:l,children:l}),e.jsxs("button",{type:"button",className:"creator-card__account",onClick:()=>void n(),title:c?t("collection.copied"):t("collection.copyAddress"),"aria-label":c?t("collection.copied"):t("collection.copyAddress"),children:[e.jsx("span",{className:"creator-card__account-text",children:M(r)}),e.jsx("span",{className:"ico ico-copy creator-card__copy","aria-hidden":!0})]}),e.jsx("a",{className:"creator-card__view",href:p,target:"_blank",rel:"noopener noreferrer",children:t("collection.viewProfile")})]})}const he=48;function Ae(){var k;const{contractAddress:r}=O(),a=Q(),[c,i]=m.useState("wearable"),[l,u]=m.useState(null),[p,g]=m.useState([]),[n,x]=m.useState(""),[o,_]=m.useState(""),[v,E]=m.useState("newest"),f=n&&!Number.isNaN(Number(n))?Number(n):void 0,C=o&&!Number.isNaN(Number(o))?Number(o):void 0,R=l?ne[l]:void 0,B=(T.find(s=>s.key===v)??T[0]).server,y={category:c,rarities:p.length?p:void 0,wearableCategories:R,minPriceCredits:f,maxPriceCredits:C,sortBy:B},{items:b,total:L,isLoading:N,error:w,hasNextPage:U,isFetchingNextPage:A,fetchNextPage:$}=me(["collection-page",r,y],s=>X(r,{...y,first:he,skip:s}),{enabled:!!r}),{data:h}=J({queryKey:["collection-meta",r],queryFn:()=>ee(r),enabled:!!r,staleTime:5*6e4}),S=(h==null?void 0:h.name)||t("collection.fallbackTitle"),P=(h==null?void 0:h.creator)||((k=b[0])==null?void 0:k.creator);function I(s){i(s),u(null)}function q(s){g(d=>d.includes(s)?d.filter(H=>H!==s):[...d,s])}function G(){i("wearable"),u(null),g([]),x(""),_("")}const j=!!(f||C),K=j?`${n||"0"}–${o||"∞"}`:t("filter.price"),D=c!=="wearable"||!!l||p.length>0||j;return e.jsxs("div",{className:"collection-page",children:[e.jsxs("nav",{className:"collection-page__crumbs","aria-label":"Breadcrumb",children:[e.jsx("button",{className:"collection-page__crumb-link",onClick:()=>a("/assets"),children:t("collection.breadcrumb")}),e.jsx("span",{className:"collection-page__crumb-sep",children:"/"}),e.jsx("span",{className:"collection-page__crumb-current",children:S})]}),e.jsx(ue,{name:S,creator:P}),e.jsxs("div",{className:"browse browse--sidebar collection-page__browse",children:[e.jsxs("aside",{className:"browse__sidebar",children:[e.jsx(pe,{address:P}),e.jsx(oe,{category:c,subCategory:l,onCategory:I,onSub:u,title:t("collection.category"),flat:!0})]}),e.jsxs("div",{className:"browse__main",children:[!N&&b.length>0?e.jsx(te,{items:b,source:"collection"}):null,e.jsx(ie,{rarities:p,onToggleRarity:q,sort:v,onSort:E,total:L,loading:N,anyActive:D,onClear:G,renderTrailing:s=>e.jsx(le,{panelKey:"price",label:K,active:j,panel:s,children:e.jsxs("div",{className:"filter-pop filter-pop--price",children:[e.jsxs("div",{className:"filter-pop__price-row",children:[e.jsx("input",{type:"number",min:"0","aria-label":"Minimum price",placeholder:"Min",value:n,onChange:d=>x(d.target.value)}),e.jsx("span",{children:"–"}),e.jsx("input",{type:"number",min:"0","aria-label":"Maximum price",placeholder:"Max",value:o,onChange:d=>_(d.target.value)})]}),e.jsxs("p",{className:"filter-pop__hint",children:["Price in ",V.name]})]})})}),w?e.jsx("p",{className:"error",children:t("collection.error")}):null,e.jsx("div",{className:"grid",children:N?e.jsx(F,{count:15}):e.jsxs(e.Fragment,{children:[b.map(s=>e.jsx(W,{item:s},s.id)),A?e.jsx(F,{count:6}):null]})}),e.jsx(de,{hasNextPage:U,isFetching:A,onLoadMore:()=>void $()}),!N&&!w&&b.length===0?e.jsx("p",{className:"muted",children:t("collection.empty")}):null]})]})]})}export{Ae as Collection,Ae as default};
1
+ import{j as e,r as m,d as O,a as Q}from"./react-yytiy0wi.js";import{E as Y,k as t,h as Z,y as z,d as J,r as V,A as W,al as X,am as ee}from"./index-BLIz_7l9.js";import{d as ae,s as M,g as re,a as se,A as te}from"./collection-AwsuEzzi.js";import{u as ce}from"./useStore-ByF6YxEU.js";import{S as T,C as oe,F as ie,c as le,a as F,b as ne}from"./categories-B2btvTaV.js";import{L as de}from"./LoadMore-CiZkVzux.js";import{u as me}from"./useInfiniteGrid-B4_3J2Zt.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";function ue({name:r,creator:a}){const{data:c}=ce(a),i=(c==null?void 0:c.cover)||ae;return e.jsxs("section",{className:"collection-hero","aria-label":r,children:[e.jsxs("div",{className:"collection-hero__cover",children:[e.jsx("img",{className:"collection-hero__cover-img",src:i,alt:"",loading:"eager"}),e.jsx("div",{className:"collection-hero__scrim","aria-hidden":!0})]}),e.jsx("h1",{className:"collection-hero__title",children:r})]})}function pe({address:r}){var x,o;const{data:a}=Y(r),[c,i]=m.useState(!1);if(!r)return null;const l=(a==null?void 0:a.name)||M(r),u=(o=(x=a==null?void 0:a.avatar)==null?void 0:x.snapshots)==null?void 0:o.face256,p=`${Z.profileUrl}/${r}`,g=re(se({name:a==null?void 0:a.name,hasClaimedName:a==null?void 0:a.hasClaimedName,ethAddress:(a==null?void 0:a.ethAddress)??r}));async function n(){try{await navigator.clipboard.writeText(r),i(!0),window.setTimeout(()=>i(!1),1500)}catch(_){z(_,{flow:"copy_creator_address"})}}return e.jsxs("div",{className:"creator-card",children:[u?e.jsx("img",{className:"creator-card__ava",src:u,alt:"",loading:"eager",style:{backgroundColor:g}}):e.jsx("span",{className:"creator-card__ava creator-card__ava--ph","aria-hidden":!0,style:{backgroundColor:g}}),e.jsx("h2",{className:"creator-card__name",title:l,children:l}),e.jsxs("button",{type:"button",className:"creator-card__account",onClick:()=>void n(),title:c?t("collection.copied"):t("collection.copyAddress"),"aria-label":c?t("collection.copied"):t("collection.copyAddress"),children:[e.jsx("span",{className:"creator-card__account-text",children:M(r)}),e.jsx("span",{className:"ico ico-copy creator-card__copy","aria-hidden":!0})]}),e.jsx("a",{className:"creator-card__view",href:p,target:"_blank",rel:"noopener noreferrer",children:t("collection.viewProfile")})]})}const he=48;function Ae(){var k;const{contractAddress:r}=O(),a=Q(),[c,i]=m.useState("wearable"),[l,u]=m.useState(null),[p,g]=m.useState([]),[n,x]=m.useState(""),[o,_]=m.useState(""),[v,E]=m.useState("newest"),f=n&&!Number.isNaN(Number(n))?Number(n):void 0,C=o&&!Number.isNaN(Number(o))?Number(o):void 0,R=l?ne[l]:void 0,B=(T.find(s=>s.key===v)??T[0]).server,y={category:c,rarities:p.length?p:void 0,wearableCategories:R,minPriceCredits:f,maxPriceCredits:C,sortBy:B},{items:b,total:L,isLoading:N,error:w,hasNextPage:U,isFetchingNextPage:A,fetchNextPage:$}=me(["collection-page",r,y],s=>X(r,{...y,first:he,skip:s}),{enabled:!!r}),{data:h}=J({queryKey:["collection-meta",r],queryFn:()=>ee(r),enabled:!!r,staleTime:5*6e4}),S=(h==null?void 0:h.name)||t("collection.fallbackTitle"),P=(h==null?void 0:h.creator)||((k=b[0])==null?void 0:k.creator);function I(s){i(s),u(null)}function q(s){g(d=>d.includes(s)?d.filter(H=>H!==s):[...d,s])}function G(){i("wearable"),u(null),g([]),x(""),_("")}const j=!!(f||C),K=j?`${n||"0"}–${o||"∞"}`:t("filter.price"),D=c!=="wearable"||!!l||p.length>0||j;return e.jsxs("div",{className:"collection-page",children:[e.jsxs("nav",{className:"collection-page__crumbs","aria-label":"Breadcrumb",children:[e.jsx("button",{className:"collection-page__crumb-link",onClick:()=>a("/assets"),children:t("collection.breadcrumb")}),e.jsx("span",{className:"collection-page__crumb-sep",children:"/"}),e.jsx("span",{className:"collection-page__crumb-current",children:S})]}),e.jsx(ue,{name:S,creator:P}),e.jsxs("div",{className:"browse browse--sidebar collection-page__browse",children:[e.jsxs("aside",{className:"browse__sidebar",children:[e.jsx(pe,{address:P}),e.jsx(oe,{category:c,subCategory:l,onCategory:I,onSub:u,title:t("collection.category"),flat:!0})]}),e.jsxs("div",{className:"browse__main",children:[!N&&b.length>0?e.jsx(te,{items:b,source:"collection"}):null,e.jsx(ie,{rarities:p,onToggleRarity:q,sort:v,onSort:E,total:L,loading:N,anyActive:D,onClear:G,renderTrailing:s=>e.jsx(le,{panelKey:"price",label:K,active:j,panel:s,children:e.jsxs("div",{className:"filter-pop filter-pop--price",children:[e.jsxs("div",{className:"filter-pop__price-row",children:[e.jsx("input",{type:"number",min:"0","aria-label":"Minimum price",placeholder:"Min",value:n,onChange:d=>x(d.target.value)}),e.jsx("span",{children:"–"}),e.jsx("input",{type:"number",min:"0","aria-label":"Maximum price",placeholder:"Max",value:o,onChange:d=>_(d.target.value)})]}),e.jsxs("p",{className:"filter-pop__hint",children:["Price in ",V.name]})]})})}),w?e.jsx("p",{className:"error",children:t("collection.error")}):null,e.jsx("div",{className:"grid",children:N?e.jsx(F,{count:15}):e.jsxs(e.Fragment,{children:[b.map(s=>e.jsx(W,{item:s},s.id)),A?e.jsx(F,{count:6}):null]})}),e.jsx(de,{hasNextPage:U,isFetching:A,onLoadMore:()=>void $()}),!N&&!w&&b.length===0?e.jsx("p",{className:"muted",children:t("collection.empty")}):null]})]})]})}export{Ae as Collection,Ae as default};
@@ -1 +1 @@
1
- import{r,j as l}from"./react-yytiy0wi.js";import{z as _,A as k}from"./index-CNSWvtL0.js";function E({title:f,items:c,onViewAll:n}){const a=r.useRef(null),[i,v]=r.useState(1),[u,x]=r.useState(0),[j,g]=r.useState(!0),[p,b]=r.useState(!1),s=r.useCallback(()=>{const t=a.current;if(!t)return;const{scrollLeft:e,scrollWidth:h,clientWidth:o}=t,m=Math.max(1,Math.ceil(h/o));v(m),x(Math.min(m-1,Math.round(e/o))),g(e<=1),b(e+o>=h-1)},[]);if(r.useEffect(()=>{s();const t=a.current;if(t)return t.addEventListener("scroll",s,{passive:!0}),window.addEventListener("resize",s),()=>{t.removeEventListener("scroll",s),window.removeEventListener("resize",s)}},[s,c.length]),c.length===0)return null;function d(t){const e=a.current;e&&e.scrollBy({left:t*e.clientWidth,behavior:"smooth"})}function w(t){const e=a.current;e&&e.scrollTo({left:t*e.clientWidth,behavior:"smooth"})}return l.jsxs("section",{className:"collection-carousel",children:[l.jsxs("div",{className:"collection-carousel__head",children:[l.jsx("h2",{className:"collection-carousel__title",children:f}),n?l.jsxs("button",{className:"collection-carousel__viewall",onClick:n,children:["View all",l.jsx("span",{className:"ico ico-chevron collection-carousel__viewall-ico","aria-hidden":!0})]}):null]}),l.jsxs("div",{className:"collection-carousel__viewport",children:[l.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--left",onClick:()=>d(-1),"aria-label":"Scroll left",disabled:j,children:l.jsx("img",{src:_,alt:"","aria-hidden":!0})}),l.jsx("div",{className:"collection-carousel__track",ref:a,children:c.map(t=>l.jsx(k,{item:t},t.id))}),l.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--right",onClick:()=>d(1),"aria-label":"Scroll right",disabled:p,children:l.jsx("img",{src:_,alt:"","aria-hidden":!0})})]}),i>1?l.jsx("div",{className:"collection-carousel__dots","aria-label":"Carousel pages",children:Array.from({length:i}).map((t,e)=>l.jsx("button",{className:`collection-carousel__dot${e===u?" is-active":""}`,"aria-label":`Go to page ${e+1}`,"aria-current":e===u?"true":void 0,onClick:()=>w(e)},e))}):null]})}export{E as C};
1
+ import{r,j as l}from"./react-yytiy0wi.js";import{z as _,A as k}from"./index-BLIz_7l9.js";function E({title:f,items:c,onViewAll:n}){const a=r.useRef(null),[i,v]=r.useState(1),[u,x]=r.useState(0),[j,g]=r.useState(!0),[p,b]=r.useState(!1),s=r.useCallback(()=>{const t=a.current;if(!t)return;const{scrollLeft:e,scrollWidth:h,clientWidth:o}=t,m=Math.max(1,Math.ceil(h/o));v(m),x(Math.min(m-1,Math.round(e/o))),g(e<=1),b(e+o>=h-1)},[]);if(r.useEffect(()=>{s();const t=a.current;if(t)return t.addEventListener("scroll",s,{passive:!0}),window.addEventListener("resize",s),()=>{t.removeEventListener("scroll",s),window.removeEventListener("resize",s)}},[s,c.length]),c.length===0)return null;function d(t){const e=a.current;e&&e.scrollBy({left:t*e.clientWidth,behavior:"smooth"})}function w(t){const e=a.current;e&&e.scrollTo({left:t*e.clientWidth,behavior:"smooth"})}return l.jsxs("section",{className:"collection-carousel",children:[l.jsxs("div",{className:"collection-carousel__head",children:[l.jsx("h2",{className:"collection-carousel__title",children:f}),n?l.jsxs("button",{className:"collection-carousel__viewall",onClick:n,children:["View all",l.jsx("span",{className:"ico ico-chevron collection-carousel__viewall-ico","aria-hidden":!0})]}):null]}),l.jsxs("div",{className:"collection-carousel__viewport",children:[l.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--left",onClick:()=>d(-1),"aria-label":"Scroll left",disabled:j,children:l.jsx("img",{src:_,alt:"","aria-hidden":!0})}),l.jsx("div",{className:"collection-carousel__track",ref:a,children:c.map(t=>l.jsx(k,{item:t},t.id))}),l.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--right",onClick:()=>d(1),"aria-label":"Scroll right",disabled:p,children:l.jsx("img",{src:_,alt:"","aria-hidden":!0})})]}),i>1?l.jsx("div",{className:"collection-carousel__dots","aria-label":"Carousel pages",children:Array.from({length:i}).map((t,e)=>l.jsx("button",{className:`collection-carousel__dot${e===u?" is-active":""}`,"aria-label":`Go to page ${e+1}`,"aria-current":e===u?"true":void 0,onClick:()=>w(e)},e))}):null]})}export{E as C};
@@ -0,0 +1 @@
1
+ import{a as B,j as e,L as ee,d as ae,u as se,r as p}from"./react-yytiy0wi.js";import{aG as re,aH as te,ae as oe,k as o,aI as $,E as U,b as ce,h as le,r as ne,A as ie,ai as de,aJ as me}from"./index-BLIz_7l9.js";import{s as K,d as ue,g as he,a as ge,A as xe}from"./collection-AwsuEzzi.js";import{u as _e,L as Ne}from"./useStore-ByF6YxEU.js";import{S as E,C as je,a as w,F as pe,c as be,b as fe}from"./categories-B2btvTaV.js";import{L as I}from"./LoadMore-CiZkVzux.js";import{u as R}from"./useInfiniteGrid-B4_3J2Zt.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";function Ce({collection:r,cover:a,itemCount:t}){const n=B(),{contractAddress:m,name:N,creator:g}=r,j=a==null||t==null,{data:i}=re(m,j),_=a==null?(i==null?void 0:i.items)??[]:[],h=t??(i==null?void 0:i.total);function x(){n(`/collection/${m}`)}return e.jsxs("article",{className:"coll-card",role:"link",tabIndex:0,onClick:x,onKeyDown:d=>{(d.key==="Enter"||d.key===" ")&&(d.preventDefault(),x())},children:[e.jsx("div",{className:"coll-card__media",children:a?e.jsx("img",{className:"coll-card__img",src:a,alt:"",loading:"lazy"}):_.length>0?e.jsx(te,{items:_,className:"coll-card__cover"}):null}),e.jsxs("div",{className:"coll-card__body",children:[e.jsx("h3",{className:"coll-card__name",title:N,children:N}),e.jsxs("div",{className:"coll-card__meta",children:[g?e.jsx(oe,{address:g,className:"coll-card__creator",linkToProfile:!0}):e.jsx("span",{className:"coll-card__creator",children:" "}),e.jsx("span",{className:"coll-card__count",children:h==null?"…":o("collectionCard.itemCount",{count:h})})]}),e.jsx("button",{className:"coll-card__view",onClick:d=>{d.stopPropagation(),x()},tabIndex:-1,children:o("collectionCard.viewCollection")})]})]})}function ve({address:r,className:a=""}){const t=$(m=>m.followed.includes(r.toLowerCase())),n=$(m=>m.toggle);return r?e.jsx("button",{type:"button",className:`btn btn--sm ${t?"btn--ghost":"btn--outline"} ${a}`.trim(),"aria-pressed":t,title:t?o("creator.unfollowTitle"):o("creator.followTitle"),onClick:()=>n(r),children:t?o("creator.following"):o("creator.follow")}):null}const we={website:"ico-website",twitter:"ico-twitter",discord:"ico-discord",facebook:"ico-facebook"};function ke({address:r}){var d,b;const{data:a}=U(r),{data:t}=_e(r),n=ce(l=>{var f;return(f=l.session)==null?void 0:f.address}),m=!!n&&n.toLowerCase()===r.toLowerCase(),N=(a==null?void 0:a.name)||K(r),g=(b=(d=a==null?void 0:a.avatar)==null?void 0:d.snapshots)==null?void 0:b.face256,j=(t==null?void 0:t.cover)||ue,i=t==null?void 0:t.description,_=`${le.profileUrl}/${r}`,h=Ne.filter(l=>t==null?void 0:t.links[l]),x=he(ge({name:a==null?void 0:a.name,hasClaimedName:a==null?void 0:a.hasClaimedName,ethAddress:(a==null?void 0:a.ethAddress)??r}));return e.jsxs("section",{className:"creator-hero","aria-label":`${N} storefront`,children:[e.jsxs("div",{className:"creator-hero__cover",children:[e.jsx("img",{className:"creator-hero__cover-img",src:j,alt:"",loading:"eager"}),e.jsx("div",{className:"creator-hero__scrim","aria-hidden":!0})]}),(h.length>0||m)&&e.jsxs("div",{className:"creator-hero__links",children:[h.map(l=>e.jsx("a",{className:"creator-hero__link",href:(t==null?void 0:t.links[l])??"",target:"_blank",rel:"noopener noreferrer",title:o(`creator.link.${l}`),"aria-label":o(`creator.link.${l}`),children:e.jsx("span",{className:`ico ${we[l]}`,"aria-hidden":!0})},l)),m&&e.jsx(ee,{className:"creator-hero__link creator-hero__edit",to:"/store-settings",title:o("creator.editStore"),"aria-label":o("creator.editStore"),children:e.jsx("span",{className:"ico ico-pen","aria-hidden":!0})})]}),e.jsxs("div",{className:"creator-hero__body",children:[g?e.jsx("img",{className:"creator-hero__ava",src:g,alt:"",loading:"eager",style:{backgroundColor:x}}):e.jsx("span",{className:"creator-hero__ava creator-hero__ava--ph","aria-hidden":!0,style:{backgroundColor:x}}),e.jsxs("div",{children:[e.jsx("h2",{className:"creator-hero__name",children:N}),i?e.jsx("p",{className:"creator-hero__desc",children:i}):null]}),e.jsxs("div",{className:"creator-hero__actions",children:[e.jsx("a",{className:"creator-hero__view",href:_,target:"_blank",rel:"noopener noreferrer",children:o("creator.viewProfile")}),e.jsx(ve,{address:r,className:"creator-hero__follow"})]})]})]})}const T=48;function Te(){const{address:r}=ae(),a=B(),[t]=se(),n=t.has("collections"),{data:m}=U(r),N=(m==null?void 0:m.name)||(r?K(r):o("creator.fallbackName")),[g,j]=p.useState("wearable"),[i,_]=p.useState(null),[h,x]=p.useState([]),[d,b]=p.useState(""),[l,f]=p.useState(""),[P,D]=p.useState("newest"),S=d&&!Number.isNaN(Number(d))?Number(d):void 0,y=l&&!Number.isNaN(Number(l))?Number(l):void 0,G=i?fe[i]:void 0,O=(E.find(s=>s.key===P)??E[0]).server,L={creator:r,category:g,rarities:h.length?h:void 0,wearableCategories:G,minPriceCredits:S,maxPriceCredits:y,sortBy:O},{items:C,total:H,isLoading:v,error:A,hasNextPage:Y,isFetchingNextPage:F,fetchNextPage:z}=R(["creator-listings",L],s=>de({...L,first:T,skip:s}),{enabled:!!r&&!n}),u=R(["creator-collections",r],s=>me(r,{first:T,skip:s}).then(c=>({items:c.collections,total:c.total})),{enabled:!!r&&n});function J(s){j(s),_(null),n&&M()}function M(){const s=new URLSearchParams(t);s.delete("collections");const c=s.toString();a({search:c?`?${c}`:""},{replace:!0})}function W(){if(n){M();return}const s=new URLSearchParams(t);s.delete("collections");const c=s.toString();a({search:c?`?${c}&collections`:"?collections"},{replace:!0})}function Z(s){x(c=>c.includes(s)?c.filter(X=>X!==s):[...c,s])}function q(){j("wearable"),_(null),x([]),b(""),f("")}const k=!!(S||y),Q=k?`${d||"0"}–${l||"∞"}`:o("filter.price"),V=g!=="wearable"||!!i||h.length>0||k;return e.jsxs("div",{className:"collection-page",children:[e.jsxs("nav",{className:"collection-page__crumbs","aria-label":"Breadcrumb",children:[e.jsx("button",{className:"collection-page__crumb-link",onClick:()=>a("/assets"),children:o("creator.breadcrumb")}),e.jsx("span",{className:"collection-page__crumb-sep",children:"/"}),e.jsx("span",{className:"collection-page__crumb-current",children:N})]}),r?e.jsx(ke,{address:r}):null,!n&&!v&&C.length>0?e.jsx(xe,{items:C,source:"creator"}):null,e.jsxs("div",{className:"browse browse--sidebar",children:[e.jsx("aside",{className:"browse__sidebar",children:e.jsx(je,{category:g,subCategory:i,onCategory:J,onSub:_,title:o("creator.category"),flat:!0,collections:n,onCollections:W})}),e.jsx("div",{className:"browse__main",children:n?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"creator-collections__bar",children:e.jsx("span",{className:"assets__count",children:u.isLoading?"…":o("creator.collectionsCount",{count:u.total})})}),u.error?e.jsx("p",{className:"error",children:o("creator.error")}):null,e.jsx("div",{className:"grid grid--collections",children:u.isLoading?e.jsx(w,{count:9}):e.jsxs(e.Fragment,{children:[u.items.map(s=>e.jsx(Ce,{collection:s,itemCount:s.itemCount},s.contractAddress)),u.isFetchingNextPage?e.jsx(w,{count:6}):null]})}),e.jsx(I,{hasNextPage:u.hasNextPage,isFetching:u.isFetchingNextPage,onLoadMore:()=>void u.fetchNextPage()}),!u.isLoading&&!u.error&&u.items.length===0?e.jsx("p",{className:"muted",children:o("creator.collectionsEmpty")}):null]}):e.jsxs(e.Fragment,{children:[e.jsx(pe,{rarities:h,onToggleRarity:Z,sort:P,onSort:D,total:H,loading:v,anyActive:V,onClear:q,renderTrailing:s=>e.jsx(be,{panelKey:"price",label:Q,active:k,panel:s,children:e.jsxs("div",{className:"filter-pop filter-pop--price",children:[e.jsxs("div",{className:"filter-pop__price-row",children:[e.jsx("input",{type:"number",min:"0","aria-label":"Minimum price",placeholder:"Min",value:d,onChange:c=>b(c.target.value)}),e.jsx("span",{children:"–"}),e.jsx("input",{type:"number",min:"0","aria-label":"Maximum price",placeholder:"Max",value:l,onChange:c=>f(c.target.value)})]}),e.jsxs("p",{className:"filter-pop__hint",children:["Price in ",ne.name]})]})})}),A?e.jsx("p",{className:"error",children:o("creator.error")}):null,e.jsx("div",{className:"grid",children:v?e.jsx(w,{count:15}):e.jsxs(e.Fragment,{children:[C.map(s=>e.jsx(ie,{item:s},s.id)),F?e.jsx(w,{count:6}):null]})}),e.jsx(I,{hasNextPage:Y,isFetching:F,onLoadMore:()=>void z()}),!v&&!A&&C.length===0?e.jsx("p",{className:"muted",children:o("creator.empty")}):null]})})]})]})}export{Te as Creator,Te as default};
@@ -1,4 +1,4 @@
1
- import{a_ as U,a$ as Ue,P as C,b0 as qe,b1 as Ye,$ as Qe,b2 as Je,aN as Xe,O as W,aS as K,aR as Te,b3 as a,b4 as Ze,b5 as Le,T as et,aY as tt}from"./index-CNSWvtL0.js";import{R as rt,g as ot}from"./getOverlayAlpha-B57gNsKL.js";import{j as T,r as y}from"./react-yytiy0wi.js";import{u as nt,a as Be}from"./useTheme-qyEpY8zT.js";function ne(r){const o=Ue(r);return r!==o&&o.styles?(o.styles.match(/^@layer\s+[^{]*$/)||(o.styles=`@layer global{${o.styles}}`),o):r}function at({styles:r,themeId:o,defaultTheme:n={}}){const i=nt(n),s=o&&i[o]||i;let l=typeof r=="function"?r(s):r;return s.modularCssLayers&&(Array.isArray(l)?l=l.map(d=>ne(typeof d=="function"?d(s):d)):l=ne(l)),T.jsx(U,{styles:l})}const Ee=y.createContext(null);function se(){return y.useContext(Ee)}const it=typeof Symbol=="function"&&Symbol.for,st=it?Symbol.for("mui.nested"):"__THEME_NESTED__";function lt(r,o){return typeof o=="function"?o(r):C({},r,o)}function ct(r){const{children:o,theme:n}=r,i=se(),s=y.useMemo(()=>{const l=i===null?n:lt(i,n);return l!=null&&(l[st]=i!==null),l},[n,i]);return T.jsx(Ee.Provider,{value:s,children:o})}function dt(r){const o=Be(),n=qe()||"",{modularCssLayers:i}=r;let s="mui.global, mui.components, mui.theme, mui.custom, mui.sx";return!i||o!==null?s="":typeof i=="string"?s=i.replace(/mui(?!\.)/g,s):s=`@layer ${s};`,Ye(()=>{const l=document.querySelector("head");if(!l)return;const d=l.firstChild;if(s){var m;if(d&&(m=d.hasAttribute)!=null&&m.call(d,"data-mui-layer-order")&&d.getAttribute("data-mui-layer-order")===n)return;const S=document.createElement("style");S.setAttribute("data-mui-layer-order",n),S.textContent=s,l.prepend(S)}else{var f;(f=l.querySelector(`style[data-mui-layer-order="${n}"]`))==null||f.remove()}},[s,n]),s?T.jsx(at,{styles:s}):null}const $e={};function xe(r,o,n,i=!1){return y.useMemo(()=>{const s=r&&o[r]||o;if(typeof n=="function"){const l=n(s),d=r?C({},o,{[r]:l}):l;return i?()=>d:d}return r?C({},o,{[r]:n}):C({},o,n)},[r,o,n,i])}function ut(r){const{children:o,theme:n,themeId:i}=r,s=Be($e),l=se()||$e,d=xe(i,s,n),m=xe(i,l,n,!0),f=d.direction==="rtl",S=dt(d);return T.jsx(ct,{theme:m,children:T.jsx(Qe.Provider,{value:d,children:T.jsx(rt,{value:f,children:T.jsxs(Je,{value:d==null?void 0:d.components,children:[S,o]})})})})}const le="mode",ce="color-scheme",Ie="data-color-scheme";function mt(r){const{defaultMode:o="light",defaultLightColorScheme:n="light",defaultDarkColorScheme:i="dark",modeStorageKey:s=le,colorSchemeStorageKey:l=ce,attribute:d=Ie,colorSchemeNode:m="document.documentElement",nonce:f}=r||{};return T.jsx("script",{suppressHydrationWarning:!0,nonce:typeof window>"u"?f:"",dangerouslySetInnerHTML:{__html:`(function() {
1
+ import{a_ as U,a$ as Ue,P as C,b0 as qe,b1 as Ye,$ as Qe,b2 as Je,aN as Xe,O as W,aS as K,aR as Te,b3 as a,b4 as Ze,b5 as Le,T as et,aY as tt}from"./index-BLIz_7l9.js";import{R as rt,g as ot}from"./getOverlayAlpha-DlM2cE6a.js";import{j as T,r as y}from"./react-yytiy0wi.js";import{u as nt,a as Be}from"./useTheme-dztiejOp.js";function ne(r){const o=Ue(r);return r!==o&&o.styles?(o.styles.match(/^@layer\s+[^{]*$/)||(o.styles=`@layer global{${o.styles}}`),o):r}function at({styles:r,themeId:o,defaultTheme:n={}}){const i=nt(n),s=o&&i[o]||i;let l=typeof r=="function"?r(s):r;return s.modularCssLayers&&(Array.isArray(l)?l=l.map(d=>ne(typeof d=="function"?d(s):d)):l=ne(l)),T.jsx(U,{styles:l})}const Ee=y.createContext(null);function se(){return y.useContext(Ee)}const it=typeof Symbol=="function"&&Symbol.for,st=it?Symbol.for("mui.nested"):"__THEME_NESTED__";function lt(r,o){return typeof o=="function"?o(r):C({},r,o)}function ct(r){const{children:o,theme:n}=r,i=se(),s=y.useMemo(()=>{const l=i===null?n:lt(i,n);return l!=null&&(l[st]=i!==null),l},[n,i]);return T.jsx(Ee.Provider,{value:s,children:o})}function dt(r){const o=Be(),n=qe()||"",{modularCssLayers:i}=r;let s="mui.global, mui.components, mui.theme, mui.custom, mui.sx";return!i||o!==null?s="":typeof i=="string"?s=i.replace(/mui(?!\.)/g,s):s=`@layer ${s};`,Ye(()=>{const l=document.querySelector("head");if(!l)return;const d=l.firstChild;if(s){var m;if(d&&(m=d.hasAttribute)!=null&&m.call(d,"data-mui-layer-order")&&d.getAttribute("data-mui-layer-order")===n)return;const S=document.createElement("style");S.setAttribute("data-mui-layer-order",n),S.textContent=s,l.prepend(S)}else{var f;(f=l.querySelector(`style[data-mui-layer-order="${n}"]`))==null||f.remove()}},[s,n]),s?T.jsx(at,{styles:s}):null}const $e={};function xe(r,o,n,i=!1){return y.useMemo(()=>{const s=r&&o[r]||o;if(typeof n=="function"){const l=n(s),d=r?C({},o,{[r]:l}):l;return i?()=>d:d}return r?C({},o,{[r]:n}):C({},o,n)},[r,o,n,i])}function ut(r){const{children:o,theme:n,themeId:i}=r,s=Be($e),l=se()||$e,d=xe(i,s,n),m=xe(i,l,n,!0),f=d.direction==="rtl",S=dt(d);return T.jsx(ct,{theme:m,children:T.jsx(Qe.Provider,{value:d,children:T.jsx(rt,{value:f,children:T.jsxs(Je,{value:d==null?void 0:d.components,children:[S,o]})})})})}const le="mode",ce="color-scheme",Ie="data-color-scheme";function mt(r){const{defaultMode:o="light",defaultLightColorScheme:n="light",defaultDarkColorScheme:i="dark",modeStorageKey:s=le,colorSchemeStorageKey:l=ce,attribute:d=Ie,colorSchemeNode:m="document.documentElement",nonce:f}=r||{};return T.jsx("script",{suppressHydrationWarning:!0,nonce:typeof window>"u"?f:"",dangerouslySetInnerHTML:{__html:`(function() {
2
2
  try {
3
3
  var mode = localStorage.getItem('${s}') || '${o}';
4
4
  var colorScheme = '';
@@ -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-igVJGnIP.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-B29hZWU0.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-Bk3c0gmH.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-B51wZzeY.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};
@@ -0,0 +1 @@
1
+ import{a as I,u as V,r as i,j as e}from"./react-yytiy0wi.js";import{b as D,u as O,t as g,k as t,r as l,y as A,v as L,C as K,o as Y}from"./index-BLIz_7l9.js";import{R as G}from"./resume-buy-Bf0zIH7y.js";import{R as $}from"./cart-checkout-rwvAvzgx.js";import{p as q,c as Q,i as W,C as z}from"./payments-BQ7DJXcX.js";import{C as J}from"./CircularProgress-BRXfk0cW.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";const C="https://cdn.decentraland.org/@dcl/shop/0.1.0-29734914357.commit-8edd840/assets/pack-chips--HnOpf5U.webp",X="https://cdn.decentraland.org/@dcl/shop/0.1.0-29734914357.commit-8edd840/assets/credit-coin-CmcTCd5i.webp",ee="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="data:image/svg+xml,%3csvg%20width='61'%20height='61'%20viewBox='0%200%2061%2061'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cg%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M30.5%2061C47.3447%2061%2061%2047.3447%2061%2030.5C61%2013.6553%2047.3447%200%2030.5%200C13.6553%200%200%2013.6553%200%2030.5C0%2047.3447%2013.6553%2061%2030.5%2061Z'%20fill='url(%23gc_paint0)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M12.2001%2054.8997C17.2935%2058.7274%2023.6375%2060.9997%2030.5%2060.9997C37.3625%2060.9997%2043.7065%2058.7274%2048.8%2054.8997H12.2001Z'%20fill='%23FF2D55'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M6.10013%2048.7997C7.83863%2051.1024%209.89738%2053.1612%2012.2001%2054.8997H48.8001C51.1029%2053.1612%2053.1616%2051.1024%2054.9001%2048.7997H6.10013Z'%20fill='%23FFA25A'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M40.9158%2042.6998H2.5468C3.4923%2044.8805%204.69705%2046.924%206.10005%2048.7997H40.9311V42.6998H40.9158Z'%20fill='%23FFC95B'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M21.6094%2019.8247V42.6997H40.6719L21.6094%2019.8247Z'%20fill='url(%23gc_paint1)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M2.5468%2042.6997H21.6093V19.8248L2.5468%2042.6997Z'%20fill='%23FCFCFC'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M40.9158%2032.025V48.8H54.9L40.9158%2032.025Z'%20fill='url(%23gc_paint2)'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M26.9467%2048.8H40.9157V32.025L26.9467%2048.8Z'%20fill='%23FCFCFC'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M40.9158%2027.4497C45.127%2027.4497%2048.5408%2024.0359%2048.5408%2019.8247C48.5408%2015.6136%2045.127%2012.1998%2040.9158%2012.1998C36.7046%2012.1998%2033.2908%2015.6136%2033.2908%2019.8247C33.2908%2024.0359%2036.7046%2027.4497%2040.9158%2027.4497Z'%20fill='%23FFC95B'/%3e%3cpath%20fill-rule='evenodd'%20clip-rule='evenodd'%20d='M21.6092%2015.2497C23.7148%2015.2497%2025.4217%2013.5428%2025.4217%2011.4372C25.4217%209.33166%2023.7148%207.62475%2021.6092%207.62475C19.5036%207.62475%2017.7967%209.33166%2017.7967%2011.4372C17.7967%2013.5428%2019.5036%2015.2497%2021.6092%2015.2497Z'%20fill='%23FFC95B'/%3e%3c/g%3e%3cdefs%3e%3clinearGradient%20id='gc_paint0'%20x1='30.5'%20y1='-12.6335'%20x2='-12.6335'%20y2='30.5'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23FF2D55'/%3e%3cstop%20offset='1'%20stop-color='%23FFBC5B'/%3e%3c/linearGradient%3e%3clinearGradient%20id='gc_paint1'%20x1='21.6029'%20y1='19.8247'%20x2='21.6029'%20y2='42.6997'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23A524B3'/%3e%3cstop%20offset='1'%20stop-color='%23FF2D55'/%3e%3c/linearGradient%3e%3clinearGradient%20id='gc_paint2'%20x1='40.9111'%20y1='32.025'%20x2='40.9111'%20y2='48.8'%20gradientUnits='userSpaceOnUse'%3e%3cstop%20stop-color='%23A524B3'/%3e%3cstop%20offset='1'%20stop-color='%23FF2D55'/%3e%3c/linearGradient%3e%3c/defs%3e%3c/svg%3e",_=W()?"mock":"stripe",te={pack_5:C,pack_10:C,pack_25:C,pack_50:C},re="https://docs.decentraland.org";function P(o){const s=o;if((s==null?void 0:s.name)==="AbortError")return t("getCredits.errorCanceled");const h=((s==null?void 0:s.message)??"").toLowerCase();return h.includes("sign in")?t("getCredits.errorSignIn",{currency:l.name}):h.includes("timed out")?t("getCredits.errorTimeout",{currency:l.name}):t("getCredits.errorGeneric")}function me(){const o=I(),{session:s,signIn:h}=D(),f=O(),[v,w]=V(),[p,d]=i.useState("select"),[a,S]=i.useState(null),[F,E]=i.useState(null),[H,m]=i.useState(null),[U,j]=i.useState(!1),N=i.useRef(null);i.useEffect(()=>()=>{var r;return(r=N.current)==null?void 0:r.abort()},[]);const B=i.useCallback(()=>{w(r=>{const c=new URLSearchParams(r);return c.delete("order"),c.delete("canceled"),c},{replace:!0})},[w]),y=i.useCallback(async r=>{d("processing");const c=new AbortController;N.current=c;try{const u=await q(r,{signal:c.signal,address:s==null?void 0:s.address,identity:s==null?void 0:s.identity});if(u.status==="credited"){const x=u.creditsGranted??(a==null?void 0:a.credits)??0;E(x>0?x:null),d("success"),g("Shop Completed Buy Credits",{order_id:r,pack_usd:(a==null?void 0:a.usd)??null,credits:x>0?x:null,provider:_}),f.invalidateQueries({queryKey:["usd-balance"]});try{if(sessionStorage.getItem($)){o("/cart",{state:{resumeCheckout:!0}});return}}catch{}try{const R=sessionStorage.getItem(G);if(R){sessionStorage.removeItem(G);const n=JSON.parse(R),M=(n==null?void 0:n.tokenId)??(n==null?void 0:n.itemId);if(n!=null&&n.contractAddress&&M){o(`/item/${n.contractAddress}/${M}`,{state:{item:n,resumeBuy:!0}});return}}}catch{}}else u.status==="pending"?(g("Shop Buy Credits Pending",{step:"grant",pack_usd:(a==null?void 0:a.usd)??null}),f.invalidateQueries({queryKey:["usd-balance"]}),d("pending")):(g("Shop Buy Credits Failed",{step:"grant",error_code:"grant_failed",pack_usd:(a==null?void 0:a.usd)??null}),m(u.error??t("getCredits.errorGrant",{currency:l.name})),d("error"))}catch(u){A(u,{flow:"get_credits",step:"grant",order_id:r}),g("Shop Buy Credits Failed",{step:"grant",error_code:L(u),pack_usd:(a==null?void 0:a.usd)??null}),m(P(u)),d("error")}},[a,s,f,o]),Z=i.useCallback(async r=>{if(!s){h();return}m(null),j(!1),S(r),d(_==="mock"?"processing":"redirecting"),g("Shop Started Buy Credits",{pack_usd:r.usd,credits:r.credits,provider:_});try{const c=await Q(r.id,{address:s.address,identity:s.identity});if(c.mock)y(c.orderId);else if(c.url)g("Shop Redirected To Stripe",{order_id:c.orderId,pack_usd:r.usd,credits:r.credits}),window.location.href=c.url;else throw new Error("Checkout did not return a redirect url")}catch(c){A(c,{flow:"get_credits",step:"checkout",provider:_}),g("Shop Buy Credits Failed",{step:"checkout",error_code:L(c),pack_usd:r.usd}),m(P(c)),d("error")}},[s,h,y]),k=i.useRef(!1);i.useEffect(()=>{if(k.current)return;const r=v.get("order");if(v.get("canceled")!=null){k.current=!0,g("Shop Buy Credits Cancelled",{order_id:r,provider:_}),B(),j(!0),d("select");return}r&&(d("processing"),s&&(k.current=!0,B(),y(r)))},[v,s]);function b(){var r;(r=N.current)==null||r.abort(),d("select"),S(null),E(null),m(null),j(!1)}const T=p==="select";return e.jsxs("div",{className:"getcredits",children:[T&&e.jsxs("header",{className:"getcredits__head",children:[e.jsx("h1",{className:"getcredits__title",children:t("getCredits.title",{currency:l.name})}),e.jsxs("p",{className:"getcredits__sub",children:[t("getCredits.subtitle",{currency:l.name})," ",e.jsxs("a",{className:"getcredits__learn",href:re,target:"_blank",rel:"noreferrer",children:[t("getCredits.learnMore"),e.jsxs("svg",{className:"getcredits__learn-ico",viewBox:"0 0 13 13","aria-hidden":!0,fill:"none",children:[e.jsx("path",{d:"M4 2h7v7",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"}),e.jsx("path",{d:"M11 2 2 11",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round"})]})]})]})]}),p==="select"&&e.jsxs(e.Fragment,{children:[U&&e.jsx("p",{className:"getcredits__note muted",role:"status",children:t("getCredits.canceledNote")}),e.jsx(ce,{onSelect:r=>void Z(r)})]}),p==="redirecting"&&e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsx(J,{size:32}),e.jsx("p",{className:"muted",children:t("getCredits.redirecting")})]}),p==="processing"&&e.jsxs("div",{className:"gc-processing",role:"status","aria-live":"polite",children:[e.jsx("img",{className:"gc-processing__logo",src:se,alt:"",width:61,height:61}),e.jsxs("div",{className:"gc-processing__body",children:[e.jsxs("p",{className:"gc-processing__title",children:[e.jsx("strong",{children:t("getCredits.processing")}),"…"]}),e.jsxs("div",{className:"gc-progress","aria-hidden":!0,children:[e.jsx("span",{className:"gc-progress__track",children:e.jsx("span",{className:"gc-progress__fill"})}),e.jsx("span",{className:"gc-progress__count",children:"1/1"})]})]})]}),p==="success"&&e.jsxs("div",{className:"gc-success",role:"status","aria-live":"polite",children:[e.jsxs("div",{className:"gc-banner",children:[e.jsx("img",{className:"gc-banner__icon",src:ee,alt:"",width:60,height:60}),e.jsxs("p",{className:"gc-banner__text",children:[e.jsx("strong",{children:t("getCredits.successTitle")})," ",t("getCredits.successBody",{currency:l.name})]})]}),F!=null&&e.jsx("div",{className:"gc-credits",children:e.jsxs("div",{className:"gc-credits__row",children:[e.jsx("img",{className:"gc-credits__coin",src:X,alt:"",width:93,height:93}),e.jsxs("p",{className:"gc-credits__text",children:[e.jsx(K,{className:"gc-credits__diamond"}),e.jsxs("span",{children:[e.jsx("strong",{className:"gc-credits__amount",children:t("getCredits.creditsAmount",{credits:F,currency:l.name})})," ",e.jsx("span",{className:"gc-credits__added",children:t("getCredits.creditsAdded")})]})]})]})}),e.jsxs("div",{className:"gc-actions",children:[e.jsx("button",{className:"gc-actions__btn gc-actions__btn--outline",onClick:b,children:t("getCredits.buyMore",{currency:l.name})}),e.jsx("button",{className:"gc-actions__btn gc-actions__btn--solid",onClick:()=>o("/assets"),children:t("getCredits.startShopping")})]})]}),p==="pending"&&e.jsxs("div",{className:"gc-status",role:"status","aria-live":"polite",children:[e.jsx("p",{className:"gc-status__title",children:t("getCredits.pendingTitle",{currency:l.name})}),e.jsx("p",{className:"muted",children:t("getCredits.pendingBody")}),e.jsxs("div",{className:"gc-status__actions",children:[e.jsx("button",{className:"gc-actions__btn gc-actions__btn--solid",onClick:()=>o("/assets"),children:t("getCredits.startShopping")}),e.jsx("button",{className:"gc-actions__btn gc-actions__btn--outline",onClick:b,children:t("getCredits.done")})]})]}),p==="error"&&e.jsxs("div",{className:"gc-status gc-status--err",role:"alert",children:[e.jsx("p",{className:"gc-status__title",children:t("getCredits.errorTitle")}),e.jsx("p",{className:"error",children:H}),e.jsx("div",{className:"gc-status__actions",children:e.jsx("button",{className:"gc-actions__btn gc-actions__btn--solid",onClick:b,children:t("getCredits.tryAgain")})})]})]})}function ce({onSelect:o}){return e.jsx("div",{className:"packs",children:z.map(s=>e.jsxs("button",{type:"button",className:`pack${s.bestValue?" pack--best":""}`,onClick:()=>o(s),"aria-label":t("getCredits.packAria",{amount:Y(s.credits),usd:s.usd}),children:[s.bestValue&&e.jsx("span",{className:"pack__badge",children:t("getCredits.packBadge")}),e.jsxs("span",{className:"pack__inner",children:[e.jsx("span",{className:"pack__label",children:t("getCredits.creditsAmount",{credits:s.credits,currency:l.name})}),e.jsx("span",{className:"pack__art",children:e.jsx("img",{src:te[s.id]??C,alt:"",loading:"lazy"})}),e.jsx("span",{className:"pack__cta-wrap",children:e.jsxs("span",{className:"pack__cta",children:["$",s.usd.toFixed(2)]})})]})]},s.id))})}export{me as GetCredits,me as default};
@@ -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-l4HYDe7V.js";import{d as g,r as v}from"./index-B29hZWU0.js";import{C as c}from"./ConstantsUtil-BbIzv5xN.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-igVJGnIP.js";import{au as y}from"./NetworkUtil-CLSFaUe_.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-BYADyNKo.js";import{d as g,r as v}from"./index-B51wZzeY.js";import{C as c}from"./ConstantsUtil-BbIzv5xN.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-Bk3c0gmH.js";import{au as y}from"./NetworkUtil-CLSFaUe_.js";const b=g`
2
2
  :host {
3
3
  display: flex;
4
4
  justify-content: center;
@@ -1 +1 @@
1
- import{a as E,r as h,j as e,L as A}from"./react-yytiy0wi.js";import{i as C,C as I,t as Q,j as L,b as R,u as F,d as K,ab as P}from"./index-CNSWvtL0.js";import{i as W,R as Y,f as G}from"./import-DU_OhvUC.js";import{s as O}from"./wallet-kind-B9P1TeIH.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";import"./buy-qpkIddNt.js";import"./trade-encoding-BtlpyT8N.js";import"./index-HN6Rk25C.js";import"./mana-rate-CPIzN4Vi.js";function B({queue:n,session:w,onClose:x,onDone:u}){const j=E(),c=O(w.providerType),[d,N]=h.useState(()=>n.map(()=>"pending")),[b,T]=h.useState("running"),S=h.useRef(!1);h.useEffect(()=>{if(S.current)return;S.current=!0;let i=!1;return(async()=>{for(let a=0;a<n.length;a++){if(i)return;N(m=>m.map((p,o)=>o===a?"active":p));try{await W(n[a].item,n[a].priceCredits,w),Q("Shop Migrated Listing",{item_id:n[a].item.itemId??n[a].item.oldTradeId??null,contract_address:n[a].item.contractAddress,new_price_credits:n[a].priceCredits,new_price_usd:n[a].priceCredits/10}),i||N(m=>m.map((p,o)=>o===a?"done":p))}catch(m){if(m instanceof Y)L(m,{flow:"import_listing",step:"relist",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(p=>p.map((o,v)=>v===a?"unlisted":o));else{const p=m,o=p.code===4001||/reject|denied|cancel/i.test(p.message??"");o||L(m,{flow:"import_listing",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(v=>v.map((t,l)=>l===a?o?"skipped":"failed":t))}}}i||T("finished")})(),()=>{i=!0}},[]);const _=d.filter(i=>i==="done").length,f=d.findIndex(i=>i==="active"),g=Math.round(d.filter(i=>i!=="pending"&&i!=="active").length/n.length*100);function y(){u(),x()}if(b==="finished"){const i=d.filter(a=>a==="skipped"||a==="failed").length,r=d.filter(a=>a==="unlisted").length;return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal modal--success",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),e.jsx("h2",{className:"modal__title",children:_>0?"You're in the Shop! 🎉":"Nothing listed"}),e.jsxs("p",{className:"muted",style:{margin:0},children:[_>0?`${_} ${_===1?"item is":"items are"} now for sale with ${C.name}.`:"No items were listed.",i>0?` ${i} skipped — you can try those again anytime.`:"",r>0?` ${r} ${r===1?"item was":"items were"} taken off the old marketplace but couldn't be re-listed — re-list ${r===1?"it":"them"} from My Assets.`:""]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:y,children:"Done"}),r>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/my-assets")},children:"Go to My Assets"}):_>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/assets")},children:"View in Shop"}):null]})]})})}return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal migrate",role:"dialog","aria-modal":"true","aria-live":"polite",children:[e.jsx("h2",{className:"modal__title",children:"Listing your items"}),e.jsxs("p",{className:"muted small",style:{margin:"0 0 4px"},children:[c?"We take down each old listing and re-list it for credits — confirm each step.":"Moving your items to the Shop."," ",f>=0?`${f+1} of ${n.length}`:""]}),e.jsx("div",{className:"migrate__progress",children:e.jsx("div",{className:"migrate__bar",style:{width:`${g}%`}})}),e.jsx("ul",{className:"migrate__list",children:n.map((i,r)=>e.jsxs("li",{className:`migrate__row migrate__row--${d[r]}`,children:[e.jsx("span",{className:"migrate__thumb",children:i.item.thumbnail?e.jsx("img",{src:i.item.thumbnail,alt:""}):null}),e.jsx("span",{className:"migrate__name",title:i.item.name,children:i.item.name||"Item"}),e.jsxs("span",{className:"migrate__price",children:[e.jsx(I,{className:"ccy-mark"})," ",i.priceCredits.toLocaleString()]}),e.jsx("span",{className:"migrate__status",children:d[r]==="active"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner migrate__spin","aria-hidden":!0})," ",c?"Confirm…":"Adding…"]}):d[r]==="done"?e.jsx("span",{className:"migrate__tick",children:"✓"}):d[r]==="skipped"?e.jsx("span",{className:"migrate__skip",children:"Skipped"}):d[r]==="failed"?e.jsx("span",{className:"migrate__skip",children:"Failed"}):d[r]==="unlisted"?e.jsx("span",{className:"migrate__skip",title:"Removed from the old marketplace but not re-listed — re-list it from My Assets.",children:"Not listed"}):e.jsx("span",{className:"migrate__wait",children:"Waiting"})})]},i.item.oldTradeId))}),e.jsx("p",{className:"muted small migrate__hint",children:c?"A couple of quick confirmations pop up per item (take down + re-list). Keep this open.":"This only takes a moment — keep this open."})]})})}const U=[{key:"creations",title:"Your creations",sub:"Items you made. Put them on sale in the Shop."},{key:"owned",title:"Items you own",sub:"Things you've bought elsewhere — resell them in the Shop."}];function ae(){const{session:n,signIn:w,restore:x}=R(),u=F(),j=n==null?void 0:n.address;h.useEffect(()=>{x()},[x]);const{data:c,isLoading:d}=K({queryKey:["importable",j],queryFn:()=>G(j),enabled:!!j}),[N,b]=h.useState({}),[T,S]=h.useState(new Set),[_,f]=h.useState(null),g=h.useMemo(()=>[...(c==null?void 0:c.creations)??[],...(c==null?void 0:c.owned)??[]],[c]);h.useEffect(()=>{g.length&&b(t=>{const l={...t};for(const s of g)l[s.oldTradeId]==null&&(l[s.oldTradeId]=s.suggestedCredits);return l})},[g]);const y=t=>!T.has(t),i=t=>N[t.oldTradeId]??t.suggestedCredits,r=g.filter(t=>y(t.oldTradeId)),a=r.reduce((t,l)=>t+i(l),0);function m(t,l){const s=l.replace(/[^\d]/g,"");b(k=>({...k,[t]:s===""?0:parseInt(s,10)}))}function p(t){S(l=>{const s=new Set(l);return s.has(t)?s.delete(t):s.add(t),s})}function o(t){return t.map(l=>({item:l,priceCredits:Math.max(1,i(l))}))}function v(){u.invalidateQueries({queryKey:["importable"]}),u.invalidateQueries({queryKey:["unified-listings"]}),u.invalidateQueries({queryKey:["my-assets"]}),u.invalidateQueries({queryKey:["collection-sale-state"]}),P.success("Your Shop is updated.")}return n?!d&&g.length===0?e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"✨"}),e.jsx("h1",{className:"imp-empty__title",children:"You're all caught up"}),e.jsx("p",{className:"muted",children:"Everything you sell is already in the Shop — nothing to import."}),e.jsx(A,{className:"btn btn--purple",to:"/my-assets",children:"Go to My Assets"})]}):e.jsxs("div",{className:"imp",children:[e.jsxs("header",{className:"imp__head",children:[e.jsx("span",{className:"imp__eyebrow",children:"Import to the Shop"}),e.jsxs("h1",{className:"imp__title",children:["Bring your listings ",e.jsx("span",{className:"imp__grad",children:"into the Shop"})]}),e.jsxs("p",{className:"imp__lede",children:["These items are already for sale elsewhere. We suggested a price in ",C.name," for each — matched to today's rate and rounded up. Adjust anything, then list them."]})]}),e.jsxs("div",{className:"imp__ratebar",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," 1 ",C.nameSingular," = $0.10 · prices rounded up"]}),d?e.jsx("div",{className:"imp__list",children:Array.from({length:4}).map((t,l)=>e.jsx("div",{className:"imp-row imp-row--skeleton"},l))}):U.map(t=>{const l=(c==null?void 0:c[t.key])??[];return l.length===0?null:e.jsxs("section",{className:"imp__section",children:[e.jsxs("div",{className:"imp__section-head",children:[e.jsx("h2",{className:"imp__section-title",children:t.title}),e.jsx("span",{className:"imp__section-sub",children:t.sub})]}),e.jsx("div",{className:"imp__list",children:l.map(s=>{const k=i(s),M=k!==s.suggestedCredits;return e.jsxs("article",{className:`imp-row${y(s.oldTradeId)?"":" is-off"}`,children:[e.jsx("input",{type:"checkbox",className:"imp-check",checked:y(s.oldTradeId),onChange:()=>p(s.oldTradeId),"aria-label":`Include ${s.name}`}),e.jsx("div",{className:"imp-thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{className:"imp-meta",children:[e.jsx("div",{className:"imp-name",title:s.name,children:s.name||"Item"}),e.jsx("span",{className:"imp-chip",children:s.rarity})]}),e.jsxs("div",{className:"imp-price",children:[e.jsxs("div",{className:"imp-price__field",children:[e.jsx(I,{className:"ccy-mark imp-price__diamond"}),e.jsx("input",{className:"imp-price__input",inputMode:"numeric",value:k.toLocaleString(),onChange:$=>m(s.oldTradeId,$.target.value),"aria-label":`Price in ${C.name} for ${s.name}`})]}),e.jsxs("div",{className:"imp-price__sub",children:[e.jsxs("span",{children:["$",(k*.1).toFixed(2)]}),M?e.jsxs("button",{className:"imp-price__reset",onClick:()=>b($=>({...$,[s.oldTradeId]:s.suggestedCredits})),children:["Reset to ",e.jsx(I,{className:"ccy-mark"}),s.suggestedCredits.toLocaleString()]}):null]})]}),e.jsx("div",{className:"imp-action",children:e.jsx("button",{className:"btn btn--sm imp-row__list",disabled:!y(s.oldTradeId),onClick:()=>f(o([s])),children:"List"})})]},s.oldTradeId)})})]},t.key)}),e.jsx("div",{className:"imp-dock",children:e.jsxs("div",{className:"imp-dock__inner",children:[e.jsxs("div",{className:"imp-dock__summary",children:[e.jsxs("div",{className:"imp-dock__total",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," ",a.toLocaleString()]}),e.jsxs("div",{className:"imp-dock__sub",children:[r.length," item",r.length===1?"":"s"," selected · $",(a*.1).toFixed(2)]})]}),e.jsx("span",{className:"imp-dock__spacer"}),e.jsxs("button",{className:"btn btn--purple imp-dock__cta",disabled:r.length===0,onClick:()=>f(o(r)),children:["List all (",r.length,")"]})]})}),_&&n?e.jsx(B,{queue:_,session:n,onClose:()=>f(null),onDone:v}):null]}):e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"📦"}),e.jsx("h1",{className:"imp-empty__title",children:"Import your listings"}),e.jsx("p",{className:"muted",children:"Sign in to bring the items you already sell into the Shop."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>w(),children:"Sign in"})]})}export{ae as ImportListings};
1
+ import{a as E,r as h,j as e,L as A}from"./react-yytiy0wi.js";import{r as C,C as I,t as Q,y as L,b as R,u as F,d as K,ab as P}from"./index-BLIz_7l9.js";import{i as W,R as Y,f as G}from"./import-Cg6Yj2rh.js";import{s as O}from"./wallet-kind-B9P1TeIH.js";import"./dcl-schemas-BICTSpB5.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";import"./buy-BuqGUyRC.js";import"./trade-encoding-BOIcOdJd.js";import"./index-HN6Rk25C.js";import"./mana-rate-B0IpO0Jf.js";function B({queue:n,session:w,onClose:x,onDone:u}){const j=E(),c=O(w.providerType),[d,N]=h.useState(()=>n.map(()=>"pending")),[b,T]=h.useState("running"),S=h.useRef(!1);h.useEffect(()=>{if(S.current)return;S.current=!0;let i=!1;return(async()=>{for(let a=0;a<n.length;a++){if(i)return;N(m=>m.map((p,o)=>o===a?"active":p));try{await W(n[a].item,n[a].priceCredits,w),Q("Shop Migrated Listing",{item_id:n[a].item.itemId??n[a].item.oldTradeId??null,contract_address:n[a].item.contractAddress,new_price_credits:n[a].priceCredits,new_price_usd:n[a].priceCredits/10}),i||N(m=>m.map((p,o)=>o===a?"done":p))}catch(m){if(m instanceof Y)L(m,{flow:"import_listing",step:"relist",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(p=>p.map((o,v)=>v===a?"unlisted":o));else{const p=m,o=p.code===4001||/reject|denied|cancel/i.test(p.message??"");o||L(m,{flow:"import_listing",itemId:n[a].item.itemId??n[a].item.oldTradeId}),i||N(v=>v.map((t,l)=>l===a?o?"skipped":"failed":t))}}}i||T("finished")})(),()=>{i=!0}},[]);const _=d.filter(i=>i==="done").length,f=d.findIndex(i=>i==="active"),g=Math.round(d.filter(i=>i!=="pending"&&i!=="active").length/n.length*100);function y(){u(),x()}if(b==="finished"){const i=d.filter(a=>a==="skipped"||a==="failed").length,r=d.filter(a=>a==="unlisted").length;return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal modal--success",role:"dialog","aria-modal":"true",children:[e.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),e.jsx("h2",{className:"modal__title",children:_>0?"You're in the Shop! 🎉":"Nothing listed"}),e.jsxs("p",{className:"muted",style:{margin:0},children:[_>0?`${_} ${_===1?"item is":"items are"} now for sale with ${C.name}.`:"No items were listed.",i>0?` ${i} skipped — you can try those again anytime.`:"",r>0?` ${r} ${r===1?"item was":"items were"} taken off the old marketplace but couldn't be re-listed — re-list ${r===1?"it":"them"} from My Assets.`:""]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:y,children:"Done"}),r>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/my-assets")},children:"Go to My Assets"}):_>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{u(),x(),j("/assets")},children:"View in Shop"}):null]})]})})}return e.jsx("div",{className:"modal-backdrop",role:"presentation",children:e.jsxs("div",{className:"modal migrate",role:"dialog","aria-modal":"true","aria-live":"polite",children:[e.jsx("h2",{className:"modal__title",children:"Listing your items"}),e.jsxs("p",{className:"muted small",style:{margin:"0 0 4px"},children:[c?"We take down each old listing and re-list it for credits — confirm each step.":"Moving your items to the Shop."," ",f>=0?`${f+1} of ${n.length}`:""]}),e.jsx("div",{className:"migrate__progress",children:e.jsx("div",{className:"migrate__bar",style:{width:`${g}%`}})}),e.jsx("ul",{className:"migrate__list",children:n.map((i,r)=>e.jsxs("li",{className:`migrate__row migrate__row--${d[r]}`,children:[e.jsx("span",{className:"migrate__thumb",children:i.item.thumbnail?e.jsx("img",{src:i.item.thumbnail,alt:""}):null}),e.jsx("span",{className:"migrate__name",title:i.item.name,children:i.item.name||"Item"}),e.jsxs("span",{className:"migrate__price",children:[e.jsx(I,{className:"ccy-mark"})," ",i.priceCredits.toLocaleString()]}),e.jsx("span",{className:"migrate__status",children:d[r]==="active"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner migrate__spin","aria-hidden":!0})," ",c?"Confirm…":"Adding…"]}):d[r]==="done"?e.jsx("span",{className:"migrate__tick",children:"✓"}):d[r]==="skipped"?e.jsx("span",{className:"migrate__skip",children:"Skipped"}):d[r]==="failed"?e.jsx("span",{className:"migrate__skip",children:"Failed"}):d[r]==="unlisted"?e.jsx("span",{className:"migrate__skip",title:"Removed from the old marketplace but not re-listed — re-list it from My Assets.",children:"Not listed"}):e.jsx("span",{className:"migrate__wait",children:"Waiting"})})]},i.item.oldTradeId))}),e.jsx("p",{className:"muted small migrate__hint",children:c?"A couple of quick confirmations pop up per item (take down + re-list). Keep this open.":"This only takes a moment — keep this open."})]})})}const U=[{key:"creations",title:"Your creations",sub:"Items you made. Put them on sale in the Shop."},{key:"owned",title:"Items you own",sub:"Things you've bought elsewhere — resell them in the Shop."}];function ae(){const{session:n,signIn:w,restore:x}=R(),u=F(),j=n==null?void 0:n.address;h.useEffect(()=>{x()},[x]);const{data:c,isLoading:d}=K({queryKey:["importable",j],queryFn:()=>G(j),enabled:!!j}),[N,b]=h.useState({}),[T,S]=h.useState(new Set),[_,f]=h.useState(null),g=h.useMemo(()=>[...(c==null?void 0:c.creations)??[],...(c==null?void 0:c.owned)??[]],[c]);h.useEffect(()=>{g.length&&b(t=>{const l={...t};for(const s of g)l[s.oldTradeId]==null&&(l[s.oldTradeId]=s.suggestedCredits);return l})},[g]);const y=t=>!T.has(t),i=t=>N[t.oldTradeId]??t.suggestedCredits,r=g.filter(t=>y(t.oldTradeId)),a=r.reduce((t,l)=>t+i(l),0);function m(t,l){const s=l.replace(/[^\d]/g,"");b(k=>({...k,[t]:s===""?0:parseInt(s,10)}))}function p(t){S(l=>{const s=new Set(l);return s.has(t)?s.delete(t):s.add(t),s})}function o(t){return t.map(l=>({item:l,priceCredits:Math.max(1,i(l))}))}function v(){u.invalidateQueries({queryKey:["importable"]}),u.invalidateQueries({queryKey:["unified-listings"]}),u.invalidateQueries({queryKey:["my-assets"]}),u.invalidateQueries({queryKey:["collection-sale-state"]}),P.success("Your Shop is updated.")}return n?!d&&g.length===0?e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"✨"}),e.jsx("h1",{className:"imp-empty__title",children:"You're all caught up"}),e.jsx("p",{className:"muted",children:"Everything you sell is already in the Shop — nothing to import."}),e.jsx(A,{className:"btn btn--purple",to:"/my-assets",children:"Go to My Assets"})]}):e.jsxs("div",{className:"imp",children:[e.jsxs("header",{className:"imp__head",children:[e.jsx("span",{className:"imp__eyebrow",children:"Import to the Shop"}),e.jsxs("h1",{className:"imp__title",children:["Bring your listings ",e.jsx("span",{className:"imp__grad",children:"into the Shop"})]}),e.jsxs("p",{className:"imp__lede",children:["These items are already for sale elsewhere. We suggested a price in ",C.name," for each — matched to today's rate and rounded up. Adjust anything, then list them."]})]}),e.jsxs("div",{className:"imp__ratebar",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," 1 ",C.nameSingular," = $0.10 · prices rounded up"]}),d?e.jsx("div",{className:"imp__list",children:Array.from({length:4}).map((t,l)=>e.jsx("div",{className:"imp-row imp-row--skeleton"},l))}):U.map(t=>{const l=(c==null?void 0:c[t.key])??[];return l.length===0?null:e.jsxs("section",{className:"imp__section",children:[e.jsxs("div",{className:"imp__section-head",children:[e.jsx("h2",{className:"imp__section-title",children:t.title}),e.jsx("span",{className:"imp__section-sub",children:t.sub})]}),e.jsx("div",{className:"imp__list",children:l.map(s=>{const k=i(s),M=k!==s.suggestedCredits;return e.jsxs("article",{className:`imp-row${y(s.oldTradeId)?"":" is-off"}`,children:[e.jsx("input",{type:"checkbox",className:"imp-check",checked:y(s.oldTradeId),onChange:()=>p(s.oldTradeId),"aria-label":`Include ${s.name}`}),e.jsx("div",{className:"imp-thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{className:"imp-meta",children:[e.jsx("div",{className:"imp-name",title:s.name,children:s.name||"Item"}),e.jsx("span",{className:"imp-chip",children:s.rarity})]}),e.jsxs("div",{className:"imp-price",children:[e.jsxs("div",{className:"imp-price__field",children:[e.jsx(I,{className:"ccy-mark imp-price__diamond"}),e.jsx("input",{className:"imp-price__input",inputMode:"numeric",value:k.toLocaleString(),onChange:$=>m(s.oldTradeId,$.target.value),"aria-label":`Price in ${C.name} for ${s.name}`})]}),e.jsxs("div",{className:"imp-price__sub",children:[e.jsxs("span",{children:["$",(k*.1).toFixed(2)]}),M?e.jsxs("button",{className:"imp-price__reset",onClick:()=>b($=>({...$,[s.oldTradeId]:s.suggestedCredits})),children:["Reset to ",e.jsx(I,{className:"ccy-mark"}),s.suggestedCredits.toLocaleString()]}):null]})]}),e.jsx("div",{className:"imp-action",children:e.jsx("button",{className:"btn btn--sm imp-row__list",disabled:!y(s.oldTradeId),onClick:()=>f(o([s])),children:"List"})})]},s.oldTradeId)})})]},t.key)}),e.jsx("div",{className:"imp-dock",children:e.jsxs("div",{className:"imp-dock__inner",children:[e.jsxs("div",{className:"imp-dock__summary",children:[e.jsxs("div",{className:"imp-dock__total",children:[e.jsx(I,{className:"ccy-mark imp__diamond"})," ",a.toLocaleString()]}),e.jsxs("div",{className:"imp-dock__sub",children:[r.length," item",r.length===1?"":"s"," selected · $",(a*.1).toFixed(2)]})]}),e.jsx("span",{className:"imp-dock__spacer"}),e.jsxs("button",{className:"btn btn--purple imp-dock__cta",disabled:r.length===0,onClick:()=>f(o(r)),children:["List all (",r.length,")"]})]})}),_&&n?e.jsx(B,{queue:_,session:n,onClose:()=>f(null),onDone:v}):null]}):e.jsxs("div",{className:"imp-empty",children:[e.jsx("span",{className:"imp-empty__ico","aria-hidden":!0,children:"📦"}),e.jsx("h1",{className:"imp-empty__title",children:"Import your listings"}),e.jsx("p",{className:"muted",children:"Sign in to bring the items you already sell into the Shop."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>w(),children:"Sign in"})]})}export{ae as ImportListings};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-B857ik7x.js","assets/react-yytiy0wi.js","assets/dcl-schemas-BICTSpB5.js","assets/index-CNSWvtL0.js","assets/sentry-BPJvc5GU.js","assets/ethers-w2AslR0v.js","assets/intl-CBcMB1D2.js","assets/index-jbcqNek9.css","assets/emotion-styled.browser.esm-7U6PLHlL.js","assets/useTheme-qyEpY8zT.js","assets/CircularProgress-BDWVwtML.js","assets/index-BABdIN2I.js","assets/useTheme-gY3T76jp.js","assets/CssVarsProvider-CwWOpnL3.js","assets/getOverlayAlpha-B57gNsKL.js","assets/index-C3UC6Rs5.js","assets/colors-LINLm1ux.js"])))=>i.map(i=>d[i]);
2
- import{a as ae,r as o,j as e,d as ke,b as Ie,L as Ae}from"./react-yytiy0wi.js";import{b as se,r as Se,u as Ee,ag as Le,m as Pe,n as Be,w as Me,s as Q,t as D,k as ce,x as X,ah as Fe,j as oe,C as A,ac as J,_ as ee,E as Re,H as Te,G as $e,aq as qe,W as Ve,h as ye,ar as We,as as Oe,ad as me,a as ue,d as O,at as De,au as Ke,av as ze,aw as Ye,ax as Ue,an as Ge,ay as He,az as Qe,aA as Je,ae as Ze,aB as _e,aC as Xe,al as ea,aD as aa,aE as sa,am as ta,aF as ia}from"./index-CNSWvtL0.js";import{d as T}from"./dcl-schemas-BICTSpB5.js";import{b as he}from"./buy-qpkIddNt.js";import{g as ra,b as la,w as na,S as da,G as ca}from"./buy-gasless-COqF6TfJ.js";import{C as oa,c as ma}from"./payments-D1TsNJWo.js";import{R as pe}from"./resume-buy-Bf0zIH7y.js";import{C as ua}from"./CircularProgress-BDWVwtML.js";import{u as _a,M as ha}from"./MarketCheckout-Do7I_hLx.js";import{C as pa}from"./CollectionCarousel-_a53Z75p.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-BtlpyT8N.js";import"./index-HN6Rk25C.js";import"./mana-rate-CPIzN4Vi.js";function be(t){const r=t,s=(r.message??"").toLowerCase();return r.code===4001||s.includes("reject")||s.includes("denied")||s.includes("cancel")?"You cancelled the request.":s.includes("not for sale")||s.includes("not found")||s.includes("404")?"This item was just sold or removed.":s.includes("your own listing")?"You can't buy your own listing.":"Couldn't complete the purchase — please try again."}function ba(t){const r=t;return r.code===402||r.status===402||(r.message??"").toLowerCase().includes("insufficient")}const R=oa.slice(0,3);function xa({item:t,onClose:r,resume:s=!1}){var k,U;const{session:n}=se(),{data:d}=Se(n),h=Ee(),x=ae(),[u,l]=o.useState("loading"),[y,a]=o.useState(null),[f,E]=o.useState(""),[j,B]=o.useState(t.priceCredits),[w,g]=o.useState(null),v=o.useRef(null),$=(w==null?void 0:w.credits)??j,C=(d==null?void 0:d.credits)??0;o.useEffect(()=>{let c=!1;if(!n){l("error"),a("Sign in to check out.");return}const b=m=>{const _=m-((d==null?void 0:d.credits)??0),p=R.find(I=>I.credits>=_)??R[R.length-1];E(p.id),D("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:m,credits_balance:(d==null?void 0:d.credits)??0,shortfall:Math.max(0,_)}),l("nofunds")};return(async()=>{var m,_;try{const p=await Le(t);if(!p)throw new Error("not for sale");if(Pe(p,n.address))throw new Error("You can't buy your own listing.");const I=Be((_=(m=p.received)==null?void 0:m[0])==null?void 0:_.amount);if(!Number.isFinite(I)||I<=0)throw new Error("price unavailable");const M=Math.ceil(I/10);if(c)return;if(B(M),d!=null&&d.credits<M){b(M);return}try{const{credit:L,maxCreditedValue:V,usdCents:F}=await Me(n.identity,I,p.id);if(c){Q(n.identity,[L.id]).catch(()=>{});return}v.current=L.id;const N=Math.ceil(F/10);B(N);const W={trade:p,credit:L,maxCreditedValue:V,usdCents:F,credits:N};g(W),s?K(W):l("ready")}catch(L){if(c)return;if(ba(L)){b(M);return}throw L}}catch(p){if(c)return;D(X(p)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:ce(p)}),l("error"),a(be(p))}})(),()=>{c=!0,v.current&&n&&(Q(n.identity,[v.current]).catch(()=>{}),v.current=null)}},[]);async function K(c=w){if(!n||!c)return;l("processing"),a(null);let b=!1;try{const m={trade:c.trade,buyer:n.address,signer:n.signer,credits:[c.credit],maxCreditedValue:c.maxCreditedValue};let _;if(ra())try{_=await la(m),await na(_),b=!0}catch(p){if(p instanceof da)b=!0;else if(p instanceof ca)_=await he(m);else throw p}else _=await he(m);v.current=null,D("Shop Completed Purchase",{...Fe([t]),payment_type:"credits",no_crypto_step:b,transaction_hash:_??null}),h.invalidateQueries({queryKey:["usd-balance"]}),l("complete")}catch(m){X(m)||oe(m,{flow:"buy",step:"submit",gasless:b}),Q(n.identity,[c.credit.id]).catch(()=>{}),v.current=null,D(X(m)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:ce(m)}),h.invalidateQueries({queryKey:["usd-balance"]}),a(be(m)),l("error")}}async function z(){if(!(!f||!n)){try{sessionStorage.setItem(pe,JSON.stringify(t))}catch{}w&&Q(n.identity,[w.credit.id]).catch(()=>{}),v.current=null,l("loading");try{const c=await ma(f,{address:n.address,identity:n.identity});if(c.url){window.location.href=c.url;return}x("/credits")}catch(c){oe(c,{flow:"buy_credits_and_item"});try{sessionStorage.removeItem(pe)}catch{}a("Couldn't start the credits checkout — please try again."),l("error")}}}const Y=u==="processing",q=u==="complete"?"Purchase complete!":u==="nofunds"?"Buy Credits and Item":"Buy Asset";return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":`Buy ${t.name}`,children:[e.jsx("div",{className:"buy-modal__scrim",onClick:Y?void 0:r,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${u==="processing"||u==="loading"?" buy-modal__card--tall":""}`,children:[e.jsxs("div",{className:"buy-modal__head",children:[e.jsxs("div",{className:"buy-modal__head-row",children:[e.jsx("h2",{className:"buy-modal__title",children:q}),!Y&&e.jsx("button",{className:"buy-modal__x",onClick:r,"aria-label":"Close",children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:u==="nofunds"?"DCL Balance:":"My Credits Balance:"}),e.jsx(A,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:J(C)})]})]}),u==="loading"&&e.jsx("div",{className:"buy-modal__body buy-modal__processing",children:e.jsx(ua,{size:44})}),u==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx("p",{className:"buy-modal__error",children:y}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:r,children:"Close"})})]}),u==="nofunds"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__warning",children:[e.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":!0,className:"buy-modal__warning-ico",children:[e.jsx("path",{d:"M12 3L2 20h20L12 3z",fill:"none",stroke:"#691fa9",strokeWidth:"1.8",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 9v5",stroke:"#691fa9",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"17",r:"1.1",fill:"#691fa9"})]}),e.jsxs("p",{className:"buy-modal__warning-text",children:[e.jsx("b",{children:"Insufficient Funds."})," You will need to buy"," ",e.jsxs("b",{children:[Math.max(0,$-C)," Credits"]})," to purchase this item."]})]}),e.jsx(xe,{item:t,priceCredits:$}),e.jsx("div",{className:"buy-modal__packs",children:R.map(c=>{const b=c.credits,m=c.id===f;return e.jsxs("button",{className:`buy-modal__pack${m?" buy-modal__pack--on":""}`,onClick:()=>E(c.id),children:[e.jsx(A,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:J(b)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",c.usd.toFixed(2),")"]})]},c.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(A,{className:"buy-modal__total-ico"}),e.jsx("span",{children:J(((k=R.find(c=>c.id===f))==null?void 0:k.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",(((U=R.find(c=>c.id===f))==null?void 0:U.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:r,children:"Cancel"}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:z,children:"Buy"})]})]}),u==="ready"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(xe,{item:t,priceCredits:$}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient buy-modal__btn--full",onClick:()=>K(),children:"Buy"})})]}),u==="processing"&&e.jsxs("div",{className:"buy-modal__body buy-modal__processing",children:[e.jsx("img",{className:"buy-modal__logo",src:"/icon-192.png",alt:"",width:61,height:61}),e.jsx("div",{className:"buy-modal__processing-text",children:s?"Completing Purchase…":"Completing transaction…"}),e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})})]}),u==="complete"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"64",height:"64","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce74"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:"Your purchase was successful!"})," You can find your item in the My Assets tab."]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:()=>x("/assets?tab=mine"),children:"My assets"}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:r,children:["Try in world",e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]})]})}function xe({item:t,priceCredits:r}){return e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:""}):null}),e.jsxs("div",{className:"buy-modal__asset-info",children:[e.jsxs("div",{children:[e.jsx("div",{className:"buy-modal__asset-name",title:t.name,children:t.name||"Item"}),t.creator?e.jsxs("div",{className:"buy-modal__asset-creator",children:["By ",t.creator]}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(A,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:J(r)})]})]})]})}const ya=o.lazy(async()=>{const[{EmoteControls:t},{Experimental_CssVarsProvider:r},{light:s}]=await Promise.all([ee(()=>import("./index-B857ik7x.js").then(n=>n.i),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),ee(()=>import("./index-BABdIN2I.js"),__vite__mapDeps([11,3,1,2,4,5,6,7,12,9,13,14])),ee(()=>import("./index-C3UC6Rs5.js"),__vite__mapDeps([15,3,1,2,4,5,6,7,16,14,13,9]))]);return{default:n=>e.jsx(r,{theme:s,children:e.jsx(t,{...n})})}});function fa(t){return e.jsx(o.Suspense,{fallback:null,children:e.jsx(ya,{...t})})}function ja({item:t}){const r=se(g=>{var v;return(v=g.session)==null?void 0:v.address}),{data:s,isLoading:n}=Re(r),d=r&&s?r:"default",h=t.category==="emote",[x,u]=o.useState("item"),l=!h&&x==="item",y=l||!n,[a,f]=o.useState(!0);o.useEffect(()=>{f(!0)},[t.id,l]);const E=!!r&&!!s,j=E&&Te(t,$e(s)),B=qe(t)[0],w=E&&!j&&!h;return e.jsxs(e.Fragment,{children:[y?e.jsx(Ve,{id:"shop-item-preview",contractAddress:t.contractAddress,tokenId:t.tokenId??void 0,itemId:t.tokenId?void 0:t.itemId??void 0,profile:l?void 0:j?d:"default",bodyShape:l||j?void 0:B,type:h?void 0:l?T.PreviewType.WEARABLE:T.PreviewType.AVATAR,emote:h||l?void 0:T.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:h?1.5:void 0,wheelStart:h?100:void 0,dev:ye.chainId===80002,onLoad:()=>f(!1)}):null,!y||a?e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":"Loading preview",children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}):null,w&&!l?e.jsxs("p",{className:"item-preview__note",children:["Shown on a ",We(B)," body — this item isn’t made for your avatar’s shape."]}):null,h?e.jsx("div",{className:"item-preview__emote-controls",children:e.jsx(fa,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":"Preview mode",children:[e.jsxs("button",{type:"button",className:x==="avatar"?"is-active":"","aria-pressed":x==="avatar","aria-label":"On avatar",onClick:()=>u("avatar"),children:[e.jsxs("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"7.5",r:"4"}),e.jsx("path",{d:"M4 20c0-4.2 3.6-6.5 8-6.5s8 2.3 8 6.5v.5H4z"})]}),e.jsx("span",{className:"item-preview__toggle-label",children:"On avatar"})]}),e.jsxs("button",{type:"button",className:x==="item"?"is-active":"","aria-pressed":x==="item","aria-label":"Item",onClick:()=>u("item"),children:[e.jsx("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8.5 3 3 6l1.8 3.8 2.2-1V21h10V8.8l2.2 1L22 6l-5.5-3a2.6 2.6 0 0 1-4.5 1.4A2.6 2.6 0 0 1 8.5 3z"})}),e.jsx("span",{className:"item-preview__toggle-label",children:"Item"})]})]})]})}function va({contractAddress:t,name:r,items:s,className:n}){const d=ae();if(!t||!r)return null;const h=(s??[]).map(l=>l.thumbnail).filter(l=>!!l).slice(0,4),x=h.slice(0,2),u=h.slice(2,4);return e.jsxs("button",{className:`creator creator--link${n?` ${n}`:""}`,onClick:l=>{l.stopPropagation(),d(`/collection/${t}`)},children:[h.length>0?e.jsxs("span",{className:"creator__ava collection-collage","aria-hidden":!0,children:[e.jsx("span",{className:`collection-collage__row${u.length===0?" collection-collage__row--full":""}`,children:x.map((l,y)=>e.jsx("img",{src:l,alt:""},y))}),u.length>0?e.jsx("span",{className:"collection-collage__row",children:u.map((l,y)=>e.jsx("img",{src:l,alt:""},y))}):null]}):null,e.jsx("span",{className:"creator__name",children:Oe(r)})]})}function ga(t){return Object.values(T.Rarity).includes(t)}function Na(t){return t==="male"?"Male":t==="female"?"Female":t==="unisex"?"Unisex":null}function wa(t){return t.wearableCategory?t.wearableCategory.replace(/_/g," "):t.category==="emote"?"Emote":"Wearable"}function Wa(){const{contractAddress:t,tokenId:r}=ke(),{state:s}=Ie(),n=ae(),d=!!(s!=null&&s.market),h=(s==null?void 0:s.marketPriceCredits)??null,x=me(i=>i.add),u=me(i=>i.items),l=ue(i=>i.toggle),{session:y}=se(),[a,f]=o.useState(()=>s!=null&&s.item?{...s.item,tradeId:s.tradeId??s.item.tradeId}:{id:`${t}-${r}`,name:"",creator:"",contractAddress:t??"",itemId:null,category:"wearable",rarity:"common",network:"MATIC",chainId:ye.chainId,thumbnail:"",priceCredits:0,gender:null,isSmart:!1,tokenId:r??void 0,tradeId:s==null?void 0:s.tradeId}),[E,j]=o.useState(!1),[B,w]=o.useState(!!(s!=null&&s.resumeBuy));o.useEffect(()=>{s!=null&&s.resumeBuy&&j(!0)},[s==null?void 0:s.resumeBuy]);const{data:g=[],isFetched:v}=O({queryKey:["collection-items",a.contractAddress],enabled:!!a.contractAddress,queryFn:()=>ea(a.contractAddress,{first:20}).then(i=>i.items)}),$=a.available==null&&!a.tokenId,{data:C,isLoading:K}=O({queryKey:["shop-item",a.contractAddress,r],enabled:!d&&!!a.contractAddress&&!!r&&(!(s!=null&&s.item)||$),queryFn:()=>aa(a.contractAddress,r)});o.useEffect(()=>{C&&f(i=>i.tradeId?i.available!=null&&i.wearableCategory?i:{...i,available:i.available??C.available,wearableCategory:i.wearableCategory??C.wearableCategory}:{...C})},[C]);const[z,Y]=o.useState(!1),{data:q=""}=O({queryKey:["item-desc",a.contractAddress,a.itemId],enabled:!!a.contractAddress&&!!a.itemId,staleTime:5*6e4,queryFn:()=>sa(a.contractAddress,a.itemId)}),{data:k}=O({queryKey:["collection-meta",a.contractAddress],enabled:!!a.contractAddress,staleTime:5*6e4,queryFn:()=>ta(a.contractAddress)});o.useEffect(()=>{if(a.name||C||g.length===0)return;const i=r&&g.find(S=>S.tokenId===r||S.itemId===r)||g.find(S=>S.contractAddress===a.contractAddress);i&&f(S=>({...i,tradeId:S.tradeId??i.tradeId}))},[g,C]);const U=o.useMemo(()=>{const i=new Set,S=[];for(const P of g){if(P.id===a.id||a.itemId&&P.itemId===a.itemId||a.tokenId&&P.tokenId===a.tokenId)continue;const de=`${P.contractAddress}-${P.itemId??P.tokenId??P.id}`;i.has(de)||(i.add(de),S.push(P))}return S},[g,a.id,a.itemId,a.tokenId]),{data:c,isLoading:b}=O({queryKey:["detail-trade",a.id,a.tradeId,a.contractAddress,a.itemId],enabled:!!a.contractAddress,queryFn:async()=>{if(a.tradeId)return a.tradeId;if(a.itemId){const i=await ia(a.contractAddress,a.itemId);return(i==null?void 0:i.id)??null}return null}}),m=a.tradeId??c??void 0,_=!!m,{data:p}=_a(d),I=o.useMemo(()=>{if(!d||!(s!=null&&s.item))return null;const i=s.item;return i.manaWei?{tradeId:i.tradeId??i.id,listingType:"primary",contractAddress:i.contractAddress,itemId:i.itemId??"",name:i.name,thumbnail:i.thumbnail,rarity:i.rarity,category:i.category,wearableCategory:i.wearableCategory??null,creator:i.creator,manaWei:i.manaWei,available:1,network:i.network,chainId:i.chainId,createdAt:0}:null},[d,s==null?void 0:s.item]),M=d&&h!=null&&!!p&&!!I,L=De({priceCredits:a.priceCredits,compareAtCredits:a.compareAtCredits,saleEndsAt:a.saleEndsAt}),V=o.useMemo(()=>({...a,tradeId:m,id:m??a.id}),[a,m]),F=u.some(i=>i.id===V.id),N=ue(i=>!!i.items[a.id]),W=o.useRef(null);o.useEffect(()=>{!a.name||b||W.current===a.id||(W.current=a.id,D("Shop Viewed Item",{...Ke(a),for_sale:_}),ze(a))},[a.id,a.name,b,_]);const G=`${t}/${r}`,te=o.useRef(G);o.useEffect(()=>{te.current!==G&&(te.current=G,s!=null&&s.item&&f({...s.item,tradeId:s.tradeId??s.item.tradeId}),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))},[G]);function fe(){!_||F||H||x(V,"item_detail")}const Z=ga(a.rarity)?a.rarity:T.Rarity.COMMON,ie=Na(a.gender),re=Ye(a),le=Ue(a.gender),je=_&&L,ve="More from this collection",H=Ge(a,y==null?void 0:y.address),ne=_?F?"In cart":b?"Checking…":"Add to cart":"Not for sale",ge=typeof a.available=="number"&&a.available>0&&!a.tokenId&&!d,Ne=!H&&_&&!d,we=d||!H,Ce=K||!!a.contractAddress&&!v;return!a.name&&!Ce?e.jsxs("div",{className:"item-detail item-detail--notfound",children:[e.jsx("span",{className:"ico ico-cart item-detail__notfound-ico","aria-hidden":!0}),e.jsx("h1",{className:"item-detail__notfound-title",children:"This item isn’t available"}),e.jsx("p",{className:"muted",children:"It may have been delisted or moved. Browse Collectibles for something else."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>n("/assets"),children:"Browse Collectibles"})]}):e.jsxs("div",{className:"item-detail",children:[e.jsxs("nav",{className:"item-detail__crumbs","aria-label":"Breadcrumb",children:[e.jsx("button",{className:"item-detail__crumb-link",onClick:()=>n("/assets"),children:"Collectibles"}),e.jsx("span",{className:"item-detail__crumb-sep",children:"/"}),e.jsx("span",{className:"item-detail__crumb-current",children:a.name||"Item"})]}),e.jsxs("div",{className:"item-detail__main",children:[e.jsxs("div",{className:"item-detail__preview",children:[a.name?e.jsx(ja,{item:a}):e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":"Loading preview",children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}),e.jsx("button",{className:`item-detail__fav item-detail__fav--preview${N?" is-on":""}`,onClick:()=>l(a),"aria-pressed":N,"aria-label":N?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:`ico ${N?"ico-heart-solid":"ico-heart"}`,"aria-hidden":!0})})]}),e.jsxs("div",{className:"item-detail__info",children:[e.jsxs("div",{className:"item-detail__info-head",children:[e.jsx("h1",{className:"item-detail__title",children:a.name||"Loading…"}),e.jsx("button",{className:`item-detail__fav${N?" is-on":""}`,onClick:()=>l(a),"aria-pressed":N,"aria-label":N?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:`ico ${N?"ico-heart-solid":"ico-heart"}`,"aria-hidden":!0})})]}),e.jsxs("div",{className:"item-detail__chips",children:[e.jsx("span",{className:"chip chip--rarity",style:{background:Je(Z),color:Qe(Z)},title:He(a.rarity),children:a.rarity}),e.jsxs("span",{className:"chip item-detail__chip",children:[re?e.jsx("span",{className:`ico ico-${re} item-detail__chip-ico`,"aria-hidden":!0}):null,wa(a)]}),ie?e.jsxs("span",{className:"chip item-detail__chip",children:[le?e.jsx("span",{className:`ico ico-${le} item-detail__chip-ico`,"aria-hidden":!0}):null,ie]}):null]}),q?e.jsxs("div",{className:"item-detail__section item-detail__description",children:[e.jsx("div",{className:"item-detail__label",children:"Description"}),e.jsx("p",{className:`item-detail__desc-text${z?" is-expanded":""}`,children:q}),q.length>140?e.jsx("button",{className:"link item-detail__desc-toggle",onClick:()=>Y(i=>!i),children:z?"Show less":"Read more"}):null]}):null,a.creator||k!=null&&k.name?e.jsxs("div",{className:"item-detail__meta",children:[a.creator?e.jsxs("div",{className:"item-detail__meta-col",children:[e.jsx("div",{className:"item-detail__label",children:"Creator"}),e.jsx(Ze,{address:a.creator,className:"item-detail__creator",linkToProfile:!0,hidePrefix:!0})]}):null,k!=null&&k.name?e.jsxs("div",{className:"item-detail__meta-col item-detail__meta-col--collection",children:[e.jsx("div",{className:"item-detail__label",children:"Collection"}),e.jsx(va,{contractAddress:a.contractAddress,name:k.name,items:g,className:"item-detail__creator"})]}):null]}):null,e.jsx("hr",{className:"item-detail__divider"}),e.jsx("div",{className:"item-detail__price-block",children:e.jsxs("div",{className:"item-detail__price-row",children:[e.jsxs("div",{className:"item-detail__price-col",children:[e.jsx("div",{className:"item-detail__price-label",children:"Price"}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"item-detail__price item-detail__price--market",children:h==null?e.jsx("span",{className:"item-detail__price-value",children:"—"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"item-detail__approx","aria-hidden":!0,children:"≈"}),e.jsx(A,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:h})]})}),e.jsx("div",{className:"item-detail__market-note muted",children:"Market price"})]}):_?je?e.jsxs("div",{className:"item-detail__price item-detail__price--sale",children:[e.jsxs("span",{className:"item-detail__price",children:[e.jsx(A,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:a.priceCredits})]}),e.jsxs("span",{className:"item-detail__price-was",children:[e.jsx(A,{className:"item-detail__diamond item-detail__diamond--was"}),a.compareAtCredits]}),_e(a.compareAtCredits,a.priceCredits)>0?e.jsxs("span",{className:"item-detail__sale-badge",children:["SALE -",_e(a.compareAtCredits,a.priceCredits),"%"]}):null,e.jsx(Xe,{endsAt:a.saleEndsAt,className:"item-detail__countdown"})]}):e.jsxs("div",{className:"item-detail__price",children:[e.jsx(A,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:a.priceCredits})]}):e.jsx("div",{className:"item-detail__price item-detail__price--none",children:"Not for sale"})]}),ge?e.jsxs("div",{className:"item-detail__stock-col",children:[e.jsx("div",{className:"item-detail__price-label",children:"Stock"}),e.jsxs("div",{className:"item-detail__stock-value",children:[(a.available??0).toLocaleString(),"/",T.Rarity.getMaxSupply(Z).toLocaleString()]})]}):null]})}),e.jsx("div",{className:`item-detail__ctas${we?" item-detail__ctas--buttons":""}${Ne?" item-detail__ctas--dual":""}`,children:d?e.jsxs("button",{className:"btn btn--purple item-detail__cta",onClick:()=>j(!0),disabled:!M,children:[e.jsx("span",{className:"item-detail__cta-label",children:"Buy now"}),h!=null?e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(A,{className:"item-detail__cta-diamond"}),h]}):null]}):H?e.jsxs("p",{className:"item-detail__own-note muted",children:["This is your item — manage it in ",e.jsx(Ae,{to:"/my-assets",children:"My Assets"}),"."]}):e.jsxs(e.Fragment,{children:[_?e.jsxs("button",{className:"btn btn--purple item-detail__cta",onClick:()=>j(!0),disabled:b,children:[e.jsx("span",{className:"item-detail__cta-label",children:"Buy now"}),e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(A,{className:"item-detail__cta-diamond"}),a.priceCredits]})]}):null,e.jsxs("button",{className:"item-detail__addcart",onClick:fe,disabled:!_||F||b,"aria-label":ne,children:[e.jsx("span",{className:"ico ico-cart-solid item-detail__addcart-ico","aria-hidden":!0}),e.jsx("span",{className:"item-detail__addcart-label",children:ne})]})]})})]})]}),e.jsx(pa,{title:ve,items:U,onViewAll:a.contractAddress?()=>n(`/collection/${a.contractAddress}`):void 0}),E&&d&&I&&p?e.jsx(ha,{listing:I,rate:p,onClose:()=>j(!1),onSold:()=>j(!1)}):E&&!d?e.jsx(xa,{item:V,resume:B,onClose:()=>{j(!1),w(!1)}}):null]})}export{Wa as ItemDetail,Wa as default};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BpEM2es9.js","assets/react-yytiy0wi.js","assets/dcl-schemas-BICTSpB5.js","assets/index-BLIz_7l9.js","assets/sentry-BPJvc5GU.js","assets/ethers-w2AslR0v.js","assets/intl-CBcMB1D2.js","assets/index-DgcUoaxa.css","assets/emotion-styled.browser.esm-BVgOpiFx.js","assets/useTheme-dztiejOp.js","assets/CircularProgress-BRXfk0cW.js","assets/index-DZy0_LxZ.js","assets/useTheme-BWWP9qQ0.js","assets/CssVarsProvider-BE4__NFs.js","assets/getOverlayAlpha-DlM2cE6a.js","assets/index-BQ5ge-Tm.js","assets/colors-LINLm1ux.js"])))=>i.map(i=>d[i]);
2
+ import{a as ae,r as o,j as e,d as ke,b as Ie,L as Ae}from"./react-yytiy0wi.js";import{b as se,m as Se,u as Ee,ag as Le,i as Pe,j as Be,s as Me,n as Q,t as D,v as ce,w as X,ah as Fe,y as oe,C as A,ac as J,_ as ee,E as Re,H as Te,G as $e,aq as qe,W as Ve,h as ye,ar as We,as as Oe,ad as me,a as ue,d as O,at as De,au as Ke,av as ze,aw as Ye,ax as Ue,an as Ge,ay as He,az as Qe,aA as Je,ae as Ze,aB as _e,aC as Xe,al as ea,aD as aa,aE as sa,am as ta,aF as ia}from"./index-BLIz_7l9.js";import{d as T}from"./dcl-schemas-BICTSpB5.js";import{b as he}from"./buy-BuqGUyRC.js";import{g as ra,b as la,w as na,S as da,G as ca}from"./buy-gasless-D1dur72K.js";import{C as oa,c as ma}from"./payments-BQ7DJXcX.js";import{R as pe}from"./resume-buy-Bf0zIH7y.js";import{C as ua}from"./CircularProgress-BRXfk0cW.js";import{u as _a,M as ha}from"./MarketCheckout-CP6s5BFr.js";import{C as pa}from"./CollectionCarousel-CUkjxu-O.js";import"./sentry-BPJvc5GU.js";import"./ethers-w2AslR0v.js";import"./intl-CBcMB1D2.js";import"./trade-encoding-BOIcOdJd.js";import"./index-HN6Rk25C.js";import"./mana-rate-B0IpO0Jf.js";function be(t){const r=t,s=(r.message??"").toLowerCase();return r.code===4001||s.includes("reject")||s.includes("denied")||s.includes("cancel")?"You cancelled the request.":s.includes("not for sale")||s.includes("not found")||s.includes("404")?"This item was just sold or removed.":s.includes("your own listing")?"You can't buy your own listing.":"Couldn't complete the purchase — please try again."}function ba(t){const r=t;return r.code===402||r.status===402||(r.message??"").toLowerCase().includes("insufficient")}const R=oa.slice(0,3);function xa({item:t,onClose:r,resume:s=!1}){var k,U;const{session:n}=se(),{data:d}=Se(n),h=Ee(),x=ae(),[u,l]=o.useState("loading"),[y,a]=o.useState(null),[j,E]=o.useState(""),[f,B]=o.useState(t.priceCredits),[w,N]=o.useState(null),v=o.useRef(null),$=(w==null?void 0:w.credits)??f,C=(d==null?void 0:d.credits)??0;o.useEffect(()=>{let c=!1;if(!n){l("error"),a("Sign in to check out.");return}const b=m=>{const _=m-((d==null?void 0:d.credits)??0),p=R.find(I=>I.credits>=_)??R[R.length-1];E(p.id),D("Shop Buy Credits Prompted",{from:"item_checkout",credits_needed:m,credits_balance:(d==null?void 0:d.credits)??0,shortfall:Math.max(0,_)}),l("nofunds")};return(async()=>{var m,_;try{const p=await Le(t);if(!p)throw new Error("not for sale");if(Pe(p,n.address))throw new Error("You can't buy your own listing.");const I=Be((_=(m=p.received)==null?void 0:m[0])==null?void 0:_.amount);if(!Number.isFinite(I)||I<=0)throw new Error("price unavailable");const M=Math.ceil(I/10);if(c)return;if(B(M),d!=null&&d.credits<M){b(M);return}try{const{credit:L,maxCreditedValue:V,usdCents:F}=await Me(n.identity,I,p.id);if(c){Q(n.identity,[L.id]).catch(()=>{});return}v.current=L.id;const g=Math.ceil(F/10);B(g);const W={trade:p,credit:L,maxCreditedValue:V,usdCents:F,credits:g};N(W),s?K(W):l("ready")}catch(L){if(c)return;if(ba(L)){b(M);return}throw L}}catch(p){if(c)return;D(X(p)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:ce(p)}),l("error"),a(be(p))}})(),()=>{c=!0,v.current&&n&&(Q(n.identity,[v.current]).catch(()=>{}),v.current=null)}},[]);async function K(c=w){if(!n||!c)return;l("processing"),a(null);let b=!1;try{const m={trade:c.trade,buyer:n.address,signer:n.signer,credits:[c.credit],maxCreditedValue:c.maxCreditedValue};let _;if(ra())try{_=await la(m),await na(_),b=!0}catch(p){if(p instanceof da)b=!0;else if(p instanceof ca)_=await he(m);else throw p}else _=await he(m);v.current=null,D("Shop Completed Purchase",{...Fe([t]),payment_type:"credits",no_crypto_step:b,transaction_hash:_??null}),h.invalidateQueries({queryKey:["usd-balance"]}),l("complete")}catch(m){X(m)||oe(m,{flow:"buy",step:"submit",gasless:b}),Q(n.identity,[c.credit.id]).catch(()=>{}),v.current=null,D(X(m)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:ce(m)}),h.invalidateQueries({queryKey:["usd-balance"]}),a(be(m)),l("error")}}async function z(){if(!(!j||!n)){try{sessionStorage.setItem(pe,JSON.stringify(t))}catch{}w&&Q(n.identity,[w.credit.id]).catch(()=>{}),v.current=null,l("loading");try{const c=await ma(j,{address:n.address,identity:n.identity});if(c.url){window.location.href=c.url;return}x("/credits")}catch(c){oe(c,{flow:"buy_credits_and_item"});try{sessionStorage.removeItem(pe)}catch{}a("Couldn't start the credits checkout — please try again."),l("error")}}}const Y=u==="processing",q=u==="complete"?"Purchase complete!":u==="nofunds"?"Buy Credits and Item":"Buy Asset";return e.jsxs("div",{className:"buy-modal",role:"dialog","aria-modal":"true","aria-label":`Buy ${t.name}`,children:[e.jsx("div",{className:"buy-modal__scrim",onClick:Y?void 0:r,"aria-hidden":!0}),e.jsxs("div",{className:`buy-modal__card${u==="processing"||u==="loading"?" buy-modal__card--tall":""}`,children:[e.jsxs("div",{className:"buy-modal__head",children:[e.jsxs("div",{className:"buy-modal__head-row",children:[e.jsx("h2",{className:"buy-modal__title",children:q}),!Y&&e.jsx("button",{className:"buy-modal__x",onClick:r,"aria-label":"Close",children:e.jsx("svg",{viewBox:"0 0 18 18",width:"18",height:"18","aria-hidden":!0,children:e.jsx("path",{d:"M4 4l10 10M14 4L4 14",stroke:"#161518",strokeWidth:"1.8",strokeLinecap:"round"})})})]}),e.jsxs("div",{className:"buy-modal__balance",children:[e.jsx("span",{className:"buy-modal__balance-label",children:u==="nofunds"?"DCL Balance:":"My Credits Balance:"}),e.jsx(A,{className:"buy-modal__balance-ico"}),e.jsx("span",{className:"buy-modal__balance-value",children:J(C)})]})]}),u==="loading"&&e.jsx("div",{className:"buy-modal__body buy-modal__processing",children:e.jsx(ua,{size:44})}),u==="error"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx("p",{className:"buy-modal__error",children:y}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:r,children:"Close"})})]}),u==="nofunds"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__warning",children:[e.jsxs("svg",{viewBox:"0 0 24 24",width:"24",height:"24","aria-hidden":!0,className:"buy-modal__warning-ico",children:[e.jsx("path",{d:"M12 3L2 20h20L12 3z",fill:"none",stroke:"#691fa9",strokeWidth:"1.8",strokeLinejoin:"round"}),e.jsx("path",{d:"M12 9v5",stroke:"#691fa9",strokeWidth:"1.8",strokeLinecap:"round"}),e.jsx("circle",{cx:"12",cy:"17",r:"1.1",fill:"#691fa9"})]}),e.jsxs("p",{className:"buy-modal__warning-text",children:[e.jsx("b",{children:"Insufficient Funds."})," You will need to buy"," ",e.jsxs("b",{children:[Math.max(0,$-C)," Credits"]})," to purchase this item."]})]}),e.jsx(xe,{item:t,priceCredits:$}),e.jsx("div",{className:"buy-modal__packs",children:R.map(c=>{const b=c.credits,m=c.id===j;return e.jsxs("button",{className:`buy-modal__pack${m?" buy-modal__pack--on":""}`,onClick:()=>E(c.id),children:[e.jsx(A,{className:"buy-modal__pack-ico"}),e.jsx("span",{className:"buy-modal__pack-amount",children:J(b)}),e.jsxs("span",{className:"buy-modal__pack-usd",children:["($",c.usd.toFixed(2),")"]})]},c.id)})}),e.jsxs("div",{className:"buy-modal__total",children:[e.jsxs("div",{className:"buy-modal__total-credits",children:[e.jsx(A,{className:"buy-modal__total-ico"}),e.jsx("span",{children:J(((k=R.find(c=>c.id===j))==null?void 0:k.credits)??0)})]}),e.jsxs("span",{className:"buy-modal__total-usd",children:["$",(((U=R.find(c=>c.id===j))==null?void 0:U.usd)??0).toFixed(2)]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:r,children:"Cancel"}),e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient",onClick:z,children:"Buy"})]})]}),u==="ready"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsx(xe,{item:t,priceCredits:$}),e.jsx("div",{className:"buy-modal__ctas",children:e.jsx("button",{className:"buy-modal__btn buy-modal__btn--gradient buy-modal__btn--full",onClick:()=>K(),children:"Buy"})})]}),u==="processing"&&e.jsxs("div",{className:"buy-modal__body buy-modal__processing",children:[e.jsx("img",{className:"buy-modal__logo",src:"/icon-192.png",alt:"",width:61,height:61}),e.jsx("div",{className:"buy-modal__processing-text",children:s?"Completing Purchase…":"Completing transaction…"}),e.jsx("div",{className:"buy-modal__progress","aria-hidden":!0,children:e.jsx("span",{className:"buy-modal__progress-fill"})})]}),u==="complete"&&e.jsxs("div",{className:"buy-modal__body",children:[e.jsxs("div",{className:"buy-modal__success",children:[e.jsxs("svg",{viewBox:"0 0 64 64",width:"64",height:"64","aria-hidden":!0,children:[e.jsx("circle",{cx:"32",cy:"32",r:"32",fill:"#34ce74"}),e.jsx("path",{d:"M20 33l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"5",strokeLinecap:"round",strokeLinejoin:"round"})]}),e.jsxs("p",{className:"buy-modal__success-text",children:[e.jsx("b",{children:"Your purchase was successful!"})," You can find your item in the My Assets tab."]})]}),e.jsxs("div",{className:"buy-modal__ctas",children:[e.jsx("button",{className:"buy-modal__btn buy-modal__btn--outline",onClick:()=>x("/assets?tab=mine"),children:"My assets"}),e.jsxs("button",{className:"buy-modal__btn buy-modal__btn--ruby",onClick:r,children:["Try in world",e.jsx("svg",{viewBox:"0 0 24 24",width:"20",height:"20","aria-hidden":!0,children:e.jsx("path",{d:"M5 12h12M13 7l5 5-5 5",fill:"none",stroke:"#fcfcfc",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})]})]})]})]})]})}function xe({item:t,priceCredits:r}){return e.jsxs("div",{className:"buy-modal__asset",children:[e.jsx("div",{className:"buy-modal__asset-thumb",children:t.thumbnail?e.jsx("img",{src:t.thumbnail,alt:""}):null}),e.jsxs("div",{className:"buy-modal__asset-info",children:[e.jsxs("div",{children:[e.jsx("div",{className:"buy-modal__asset-name",title:t.name,children:t.name||"Item"}),t.creator?e.jsxs("div",{className:"buy-modal__asset-creator",children:["By ",t.creator]}):null]}),e.jsxs("div",{className:"buy-modal__asset-price",children:[e.jsx(A,{className:"buy-modal__asset-price-ico"}),e.jsx("span",{children:J(r)})]})]})]})}const ya=o.lazy(async()=>{const[{EmoteControls:t},{Experimental_CssVarsProvider:r},{light:s}]=await Promise.all([ee(()=>import("./index-BpEM2es9.js").then(n=>n.i),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10])),ee(()=>import("./index-DZy0_LxZ.js"),__vite__mapDeps([11,3,1,2,4,5,6,7,12,9,13,14])),ee(()=>import("./index-BQ5ge-Tm.js"),__vite__mapDeps([15,3,1,2,4,5,6,7,16,14,13,9]))]);return{default:n=>e.jsx(r,{theme:s,children:e.jsx(t,{...n})})}});function ja(t){return e.jsx(o.Suspense,{fallback:null,children:e.jsx(ya,{...t})})}function fa({item:t}){const r=se(N=>{var v;return(v=N.session)==null?void 0:v.address}),{data:s,isLoading:n}=Re(r),d=r&&s?r:"default",h=t.category==="emote",[x,u]=o.useState("item"),l=!h&&x==="item",y=l||!n,[a,j]=o.useState(!0);o.useEffect(()=>{j(!0)},[t.id,l]);const E=!!r&&!!s,f=E&&Te(t,$e(s)),B=qe(t)[0],w=E&&!f&&!h;return e.jsxs(e.Fragment,{children:[y?e.jsx(Ve,{id:"shop-item-preview",contractAddress:t.contractAddress,tokenId:t.tokenId??void 0,itemId:t.tokenId?void 0:t.itemId??void 0,profile:l?void 0:f?d:"default",bodyShape:l||f?void 0:B,type:h?void 0:l?T.PreviewType.WEARABLE:T.PreviewType.AVATAR,emote:h||l?void 0:T.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:h?1.5:void 0,wheelStart:h?100:void 0,dev:ye.chainId===80002,onLoad:()=>j(!1)}):null,!y||a?e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":"Loading preview",children:e.jsx("span",{className:"item-preview__spinner","aria-hidden":!0})}):null,w&&!l?e.jsxs("p",{className:"item-preview__note",children:["Shown on a ",We(B)," body — this item isn’t made for your avatar’s shape."]}):null,h?e.jsx("div",{className:"item-preview__emote-controls",children:e.jsx(ja,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":"Preview mode",children:[e.jsxs("button",{type:"button",className:x==="avatar"?"is-active":"","aria-pressed":x==="avatar","aria-label":"On avatar",onClick:()=>u("avatar"),children:[e.jsxs("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:[e.jsx("circle",{cx:"12",cy:"7.5",r:"4"}),e.jsx("path",{d:"M4 20c0-4.2 3.6-6.5 8-6.5s8 2.3 8 6.5v.5H4z"})]}),e.jsx("span",{className:"item-preview__toggle-label",children:"On avatar"})]}),e.jsxs("button",{type:"button",className:x==="item"?"is-active":"","aria-pressed":x==="item","aria-label":"Item",onClick:()=>u("item"),children:[e.jsx("svg",{className:"item-preview__toggle-ico",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":!0,children:e.jsx("path",{d:"M8.5 3 3 6l1.8 3.8 2.2-1V21h10V8.8l2.2 1L22 6l-5.5-3a2.6 2.6 0 0 1-4.5 1.4A2.6 2.6 0 0 1 8.5 3z"})}),e.jsx("span",{className:"item-preview__toggle-label",children:"Item"})]})]})]})}function va({contractAddress:t,name:r,items:s,className:n}){const d=ae();if(!t||!r)return null;const h=(s??[]).map(l=>l.thumbnail).filter(l=>!!l).slice(0,4),x=h.slice(0,2),u=h.slice(2,4);return e.jsxs("button",{className:`creator creator--link${n?` ${n}`:""}`,onClick:l=>{l.stopPropagation(),d(`/collection/${t}`)},children:[h.length>0?e.jsxs("span",{className:"creator__ava collection-collage","aria-hidden":!0,children:[e.jsx("span",{className:`collection-collage__row${u.length===0?" collection-collage__row--full":""}`,children:x.map((l,y)=>e.jsx("img",{src:l,alt:""},y))}),u.length>0?e.jsx("span",{className:"collection-collage__row",children:u.map((l,y)=>e.jsx("img",{src:l,alt:""},y))}):null]}):null,e.jsx("span",{className:"creator__name",children:Oe(r)})]})}function Na(t){return Object.values(T.Rarity).includes(t)}function ga(t){return t==="male"?"Male":t==="female"?"Female":t==="unisex"?"Unisex":null}function wa(t){return t.wearableCategory?t.wearableCategory.replace(/_/g," "):t.category==="emote"?"Emote":"Wearable"}function Oa(){const{contractAddress:t,tokenId:r}=ke(),{state:s}=Ie(),n=ae(),d=!!(s!=null&&s.market),h=(s==null?void 0:s.marketPriceCredits)??null,x=me(i=>i.add),u=me(i=>i.items),l=ue(i=>i.toggle),{session:y}=se(),[a,j]=o.useState(()=>s!=null&&s.item?{...s.item,tradeId:s.tradeId??s.item.tradeId}:{id:`${t}-${r}`,name:"",creator:"",contractAddress:t??"",itemId:null,category:"wearable",rarity:"common",network:"MATIC",chainId:ye.chainId,thumbnail:"",priceCredits:0,gender:null,isSmart:!1,tokenId:r??void 0,tradeId:s==null?void 0:s.tradeId}),[E,f]=o.useState(!1),[B,w]=o.useState(!!(s!=null&&s.resumeBuy));o.useEffect(()=>{s!=null&&s.resumeBuy&&f(!0)},[s==null?void 0:s.resumeBuy]);const{data:N=[],isFetched:v}=O({queryKey:["collection-items",a.contractAddress],enabled:!!a.contractAddress,queryFn:()=>ea(a.contractAddress,{first:20}).then(i=>i.items)}),$=a.available==null&&!a.tokenId,{data:C,isLoading:K}=O({queryKey:["shop-item",a.contractAddress,r],enabled:!d&&!!a.contractAddress&&!!r&&(!(s!=null&&s.item)||$),queryFn:()=>aa(a.contractAddress,r)});o.useEffect(()=>{C&&j(i=>i.tradeId?i.available!=null&&i.wearableCategory?i:{...i,available:i.available??C.available,wearableCategory:i.wearableCategory??C.wearableCategory}:{...C})},[C]);const[z,Y]=o.useState(!1),{data:q=""}=O({queryKey:["item-desc",a.contractAddress,a.itemId],enabled:!!a.contractAddress&&!!a.itemId,staleTime:5*6e4,queryFn:()=>sa(a.contractAddress,a.itemId)}),{data:k}=O({queryKey:["collection-meta",a.contractAddress],enabled:!!a.contractAddress,staleTime:5*6e4,queryFn:()=>ta(a.contractAddress)});o.useEffect(()=>{if(a.name||C||N.length===0)return;const i=r&&N.find(S=>S.tokenId===r||S.itemId===r)||N.find(S=>S.contractAddress===a.contractAddress);i&&j(S=>({...i,tradeId:S.tradeId??i.tradeId}))},[N,C]);const U=o.useMemo(()=>{const i=new Set,S=[];for(const P of N){if(P.id===a.id||a.itemId&&P.itemId===a.itemId||a.tokenId&&P.tokenId===a.tokenId)continue;const de=`${P.contractAddress}-${P.itemId??P.tokenId??P.id}`;i.has(de)||(i.add(de),S.push(P))}return S},[N,a.id,a.itemId,a.tokenId]),{data:c,isLoading:b}=O({queryKey:["detail-trade",a.id,a.tradeId,a.contractAddress,a.itemId],enabled:!!a.contractAddress,queryFn:async()=>{if(a.tradeId)return a.tradeId;if(a.itemId){const i=await ia(a.contractAddress,a.itemId);return(i==null?void 0:i.id)??null}return null}}),m=a.tradeId??c??void 0,_=!!m,{data:p}=_a(d),I=o.useMemo(()=>{if(!d||!(s!=null&&s.item))return null;const i=s.item;return i.manaWei?{tradeId:i.tradeId??i.id,listingType:"primary",contractAddress:i.contractAddress,itemId:i.itemId??"",name:i.name,thumbnail:i.thumbnail,rarity:i.rarity,category:i.category,wearableCategory:i.wearableCategory??null,creator:i.creator,manaWei:i.manaWei,available:1,network:i.network,chainId:i.chainId,createdAt:0}:null},[d,s==null?void 0:s.item]),M=d&&h!=null&&!!p&&!!I,L=De({priceCredits:a.priceCredits,compareAtCredits:a.compareAtCredits,saleEndsAt:a.saleEndsAt}),V=o.useMemo(()=>({...a,tradeId:m,id:m??a.id}),[a,m]),F=u.some(i=>i.id===V.id),g=ue(i=>!!i.items[a.id]),W=o.useRef(null);o.useEffect(()=>{!a.name||b||W.current===a.id||(W.current=a.id,D("Shop Viewed Item",{...Ke(a),for_sale:_}),ze(a))},[a.id,a.name,b,_]);const G=`${t}/${r}`,te=o.useRef(G);o.useEffect(()=>{te.current!==G&&(te.current=G,s!=null&&s.item&&j({...s.item,tradeId:s.tradeId??s.item.tradeId}),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))},[G]);function je(){!_||F||H||x(V,"item_detail")}const Z=Na(a.rarity)?a.rarity:T.Rarity.COMMON,ie=ga(a.gender),re=Ye(a),le=Ue(a.gender),fe=_&&L,ve="More from this collection",H=Ge(a,y==null?void 0:y.address),ne=_?F?"In cart":b?"Checking…":"Add to cart":"Not for sale",Ne=typeof a.available=="number"&&a.available>0&&!a.tokenId&&!d,ge=!H&&_&&!d,we=d||!H,Ce=K||!!a.contractAddress&&!v;return!a.name&&!Ce?e.jsxs("div",{className:"item-detail item-detail--notfound",children:[e.jsx("span",{className:"ico ico-cart item-detail__notfound-ico","aria-hidden":!0}),e.jsx("h1",{className:"item-detail__notfound-title",children:"This item isn’t available"}),e.jsx("p",{className:"muted",children:"It may have been delisted or moved. Browse Collectibles for something else."}),e.jsx("button",{className:"btn btn--purple",onClick:()=>n("/assets"),children:"Browse Collectibles"})]}):e.jsxs("div",{className:"item-detail",children:[e.jsxs("nav",{className:"item-detail__crumbs","aria-label":"Breadcrumb",children:[e.jsx("button",{className:"item-detail__crumb-link",onClick:()=>n("/assets"),children:"Collectibles"}),e.jsx("span",{className:"item-detail__crumb-sep",children:"/"}),e.jsx("span",{className:"item-detail__crumb-current",children:a.name||"Item"})]}),e.jsxs("div",{className:"item-detail__main",children:[e.jsxs("div",{className:"item-detail__preview",children:[a.name?e.jsx(fa,{item:a}):e.jsx("div",{className:"item-preview__loading","aria-busy":"true","aria-label":"Loading preview",children:e.jsx("span",{className:"skeleton item-preview__skeleton","aria-hidden":!0})}),e.jsx("button",{className:`item-detail__fav item-detail__fav--preview${g?" is-on":""}`,onClick:()=>l(a),"aria-pressed":g,"aria-label":g?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:`ico ${g?"ico-heart-solid":"ico-heart"}`,"aria-hidden":!0})})]}),e.jsx("div",{className:"item-detail__info",children:a.name?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"item-detail__info-head",children:[e.jsx("h1",{className:"item-detail__title",children:a.name}),e.jsx("button",{className:`item-detail__fav${g?" is-on":""}`,onClick:()=>l(a),"aria-pressed":g,"aria-label":g?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:`ico ${g?"ico-heart-solid":"ico-heart"}`,"aria-hidden":!0})})]}),e.jsxs("div",{className:"item-detail__chips",children:[e.jsx("span",{className:"chip chip--rarity",style:{background:Je(Z),color:Qe(Z)},title:He(a.rarity),children:a.rarity}),e.jsxs("span",{className:"chip item-detail__chip",children:[re?e.jsx("span",{className:`ico ico-${re} item-detail__chip-ico`,"aria-hidden":!0}):null,wa(a)]}),ie?e.jsxs("span",{className:"chip item-detail__chip",children:[le?e.jsx("span",{className:`ico ico-${le} item-detail__chip-ico`,"aria-hidden":!0}):null,ie]}):null]}),q?e.jsxs("div",{className:"item-detail__section item-detail__description",children:[e.jsx("div",{className:"item-detail__label",children:"Description"}),e.jsx("p",{className:`item-detail__desc-text${z?" is-expanded":""}`,children:q}),q.length>140?e.jsx("button",{className:"link item-detail__desc-toggle",onClick:()=>Y(i=>!i),children:z?"Show less":"Read more"}):null]}):null,a.creator||k!=null&&k.name?e.jsxs("div",{className:"item-detail__meta",children:[a.creator?e.jsxs("div",{className:"item-detail__meta-col",children:[e.jsx("div",{className:"item-detail__label",children:"Creator"}),e.jsx(Ze,{address:a.creator,className:"item-detail__creator",linkToProfile:!0,hidePrefix:!0})]}):null,k!=null&&k.name?e.jsxs("div",{className:"item-detail__meta-col item-detail__meta-col--collection",children:[e.jsx("div",{className:"item-detail__label",children:"Collection"}),e.jsx(va,{contractAddress:a.contractAddress,name:k.name,items:N,className:"item-detail__creator"})]}):null]}):null,e.jsx("hr",{className:"item-detail__divider"}),e.jsx("div",{className:"item-detail__price-block",children:e.jsxs("div",{className:"item-detail__price-row",children:[e.jsxs("div",{className:"item-detail__price-col",children:[e.jsx("div",{className:"item-detail__price-label",children:"Price"}),d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"item-detail__price item-detail__price--market",children:h==null?e.jsx("span",{className:"item-detail__price-value",children:"—"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"item-detail__approx","aria-hidden":!0,children:"≈"}),e.jsx(A,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:h})]})}),e.jsx("div",{className:"item-detail__market-note muted",children:"Market price"})]}):_?fe?e.jsxs("div",{className:"item-detail__price item-detail__price--sale",children:[e.jsxs("span",{className:"item-detail__price",children:[e.jsx(A,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:a.priceCredits})]}),e.jsxs("span",{className:"item-detail__price-was",children:[e.jsx(A,{className:"item-detail__diamond item-detail__diamond--was"}),a.compareAtCredits]}),_e(a.compareAtCredits,a.priceCredits)>0?e.jsxs("span",{className:"item-detail__sale-badge",children:["SALE -",_e(a.compareAtCredits,a.priceCredits),"%"]}):null,e.jsx(Xe,{endsAt:a.saleEndsAt,className:"item-detail__countdown"})]}):e.jsxs("div",{className:"item-detail__price",children:[e.jsx(A,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:a.priceCredits})]}):e.jsx("div",{className:"item-detail__price item-detail__price--none",children:"Not for sale"})]}),Ne?e.jsxs("div",{className:"item-detail__stock-col",children:[e.jsx("div",{className:"item-detail__price-label",children:"Stock"}),e.jsxs("div",{className:"item-detail__stock-value",children:[(a.available??0).toLocaleString(),"/",T.Rarity.getMaxSupply(Z).toLocaleString()]})]}):null]})}),e.jsx("div",{className:`item-detail__ctas${we?" item-detail__ctas--buttons":""}${ge?" item-detail__ctas--dual":""}`,children:d?e.jsxs("button",{className:"btn btn--purple item-detail__cta",onClick:()=>f(!0),disabled:!M,children:[e.jsx("span",{className:"item-detail__cta-label",children:"Buy now"}),h!=null?e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(A,{className:"item-detail__cta-diamond"}),h]}):null]}):H?e.jsxs("p",{className:"item-detail__own-note muted",children:["This is your item — manage it in ",e.jsx(Ae,{to:"/my-assets",children:"My Assets"}),"."]}):e.jsxs(e.Fragment,{children:[_?e.jsxs("button",{className:"btn btn--purple item-detail__cta",onClick:()=>f(!0),disabled:b,children:[e.jsx("span",{className:"item-detail__cta-label",children:"Buy now"}),e.jsxs("span",{className:"item-detail__cta-price","aria-hidden":!0,children:[e.jsx(A,{className:"item-detail__cta-diamond"}),a.priceCredits]})]}):null,e.jsxs("button",{className:"item-detail__addcart",onClick:je,disabled:!_||F||b,"aria-label":ne,children:[e.jsx("span",{className:"ico ico-cart-solid item-detail__addcart-ico","aria-hidden":!0}),e.jsx("span",{className:"item-detail__addcart-label",children:ne})]})]})})]}):e.jsx(Ca,{})})]}),e.jsx(pa,{title:ve,items:U,onViewAll:a.contractAddress?()=>n(`/collection/${a.contractAddress}`):void 0}),E&&d&&I&&p?e.jsx(ha,{listing:I,rate:p,onClose:()=>f(!1),onSold:()=>f(!1)}):E&&!d?e.jsx(xa,{item:V,resume:B,onClose:()=>{f(!1),w(!1)}}):null]})}function Ca(){return e.jsxs("div",{className:"item-detail__info-skel","aria-hidden":!0,children:[e.jsx("span",{className:"skeleton id-skel__title"}),e.jsxs("div",{className:"id-skel__chips",children:[e.jsx("span",{className:"skeleton id-skel__chip"}),e.jsx("span",{className:"skeleton id-skel__chip"})]}),e.jsx("span",{className:"skeleton id-skel__line"}),e.jsx("span",{className:"skeleton id-skel__line id-skel__line--short"}),e.jsx("hr",{className:"item-detail__divider"}),e.jsx("span",{className:"skeleton id-skel__price"}),e.jsx("span",{className:"skeleton id-skel__btn"})]})}export{Oa as ItemDetail,Oa as default};