@dcl/shop 0.1.0-29486364190.commit-e3b7c10 → 0.1.0-29489010081.commit-c04e72d

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 (161) hide show
  1. package/assets/{AnimatedBackground-hgJbdv8o.js → AnimatedBackground-C3tCIt3_.js} +3 -3
  2. package/assets/{Assets-iFxuz5_V.js → Assets-DQEUXeMX.js} +1 -1
  3. package/assets/{Cart-BoZAV3Zy.js → Cart-lN_ulEt9.js} +1 -1
  4. package/assets/{CircularProgress-D2LB2Tot.js → CircularProgress-CFx6Tc-u.js} +1 -1
  5. package/assets/{Collection-BnxXZj1R.js → Collection-9eLs13RF.js} +1 -1
  6. package/assets/{Creator-BB-y4Ecj.js → Creator-DkWw07V0.js} +1 -1
  7. package/assets/{ExchangeController-ChlCwQw0.js → ExchangeController-BKVj-wUk.js} +1 -1
  8. package/assets/GetCredits-Cd2MM2_C.js +1 -0
  9. package/assets/{HelpersUtil-DWHamXXu.js → HelpersUtil-D3RJTtBW.js} +1 -1
  10. package/assets/{ImportListings-DiSHmEqQ.js → ImportListings-CCqLXiQR.js} +1 -1
  11. package/assets/{ItemDetail-CRHBr8SV.js → ItemDetail-kMMoE6GO.js} +2 -2
  12. package/assets/{MyAssets-BbfBsUnZ.js → MyAssets-Ds0g4zU7.js} +1 -1
  13. package/assets/{MyFavorites-Csfi_T9F.js → MyFavorites-CK5_WnC2.js} +1 -1
  14. package/assets/{MyPurchases-CnzVyMic.js → MyPurchases-CpT7mJeg.js} +1 -1
  15. package/assets/{NotFound-rWNtnYXU.js → NotFound-CwEJRJsv.js} +1 -1
  16. package/assets/{Success-CT_TCK5T.js → Success-BDL2iZK2.js} +1 -1
  17. package/assets/{SwapController-T2_7I9w9.js → SwapController-DdOdLkW2.js} +1 -1
  18. package/assets/{TradeService-CprqG9em.js → TradeService-B9iZ5DY4.js} +1 -1
  19. package/assets/{W3MFrameProviderSingleton-Dhy5L90S.js → W3MFrameProviderSingleton-ZaFH8iXi.js} +3 -3
  20. package/assets/{WebCryptoP256-CQO8V6dW.js → WebCryptoP256-H5nw1_R9.js} +1 -1
  21. package/assets/{basic-CUrKSXqx.js → basic-ajzFEC0k.js} +1 -1
  22. package/assets/{biconomy-BprwjyuM.js → biconomy-BthW3jTV.js} +1 -1
  23. package/assets/{buy-DK-hDYib.js → buy-DEy5oWx-.js} +1 -1
  24. package/assets/{buy-gasless-BqKKprU3.js → buy-gasless-VIo89iNM.js} +1 -1
  25. package/assets/{ccip-D9kLikPl.js → ccip-BkNQa8cV.js} +1 -1
  26. package/assets/{ccip-i3RPI9_7.js → ccip-YAHPm4lT.js} +1 -1
  27. package/assets/{collection-BGWAmfIC.js → collection-OLKHFYz-.js} +1 -1
  28. package/assets/{controller-Btue2UR6.js → controller-CbQsCzNl.js} +2 -2
  29. package/assets/{core-CuTrUx-L.js → core-CYiLxEzM.js} +4 -4
  30. package/assets/{custom-CUI9dLB8.js → custom-Dp9Dh7zL.js} +1 -1
  31. package/assets/{data-capture-5yvKgk9D.js → data-capture-BDOOE_ef.js} +1 -1
  32. package/assets/decimals-CTbYR1AE.js +1 -0
  33. package/assets/{decimals-BEIdKTQm.js → decimals-l9QqXFQS.js} +1 -1
  34. package/assets/{detectExtension-LiPeiloP.js → detectExtension-DbxURuLG.js} +1 -1
  35. package/assets/{email-dHJudH5P.js → email-COb083lm.js} +1 -1
  36. package/assets/{embedded-wallet-pLhtv_no.js → embedded-wallet-AiyWyM1t.js} +1 -1
  37. package/assets/{emotion-styled.browser.esm-Cuau_-ln.js → emotion-styled.browser.esm-B8upHOUh.js} +1 -1
  38. package/assets/{engine-DClcsFWb.js → engine-clsNVx05.js} +1 -1
  39. package/assets/{estimate-l1-fee-D1zggvjN.js → estimate-l1-fee-jUmzX2ld.js} +1 -1
  40. package/assets/{eth_estimateGas-BEfG-JZG.js → eth_estimateGas-iM3Zr91m.js} +1 -1
  41. package/assets/{eth_getStorageAt-CxVMb6OQ.js → eth_getStorageAt-CvLG1_Jo.js} +1 -1
  42. package/assets/{eth_getTransactionCount-Be3nPW6h.js → eth_getTransactionCount-jDyG_Ia6.js} +1 -1
  43. package/assets/{extractIPFS-BR5tloXr.js → extractIPFS-w7ac0ws4.js} +1 -1
  44. package/assets/{features-lwpfjaXd.js → features-CspU5qNv.js} +1 -1
  45. package/assets/{fetchTokenMetadata-BMgeeRkO.js → fetchTokenMetadata-BaEvnlSD.js} +2 -2
  46. package/assets/{get-ecosystem-wallet-info-CqKNn3RZ.js → get-ecosystem-wallet-info-MdgEA2Qu.js} +1 -1
  47. package/assets/{getBalance-DMIFpbol.js → getBalance-DQeLy4UX.js} +1 -1
  48. package/assets/{getInstalledModules-fpaoD92V.js → getInstalledModules-56AfvyZo.js} +1 -1
  49. package/assets/{getNFT-CiyopSgD.js → getNFT-Cuo1y-Dw.js} +1 -1
  50. package/assets/{getNFT-D86xBZpd.js → getNFT-DIM-F27_.js} +2 -2
  51. package/assets/{hashTypedData-CHW-4SjU.js → hashTypedData-BLO0uf-r.js} +1 -1
  52. package/assets/{hashTypedData-BqtZziXx.js → hashTypedData-CHOppTRC.js} +1 -1
  53. package/assets/{import-Cicp42pB.js → import-JBeySj3d.js} +1 -1
  54. package/assets/{in-app-wallet-calls-CcJhWWJI.js → in-app-wallet-calls-D-eIKfO6.js} +1 -1
  55. package/assets/{index-CgviKUZA.js → index--Cp_hd__.js} +1 -1
  56. package/assets/{index-CvXPL5ul.js → index-4CyAhAID.js} +1 -1
  57. package/assets/{index-OXYaaX81.js → index-BD4IJd4v.js} +1 -1
  58. package/assets/{index-C3PaD0tV.js → index-BEoWhDOy.js} +1 -1
  59. package/assets/{index-CfK4LG22.js → index-BF4WrGCQ.js} +1 -1
  60. package/assets/{index-klXc-d9l.js → index-BHjrNg9z.js} +1 -1
  61. package/assets/{index-BIiVsjKg.js → index-BIij5F98.js} +1 -1
  62. package/assets/{index-By3oDfDF.js → index-BKR9QEHq.js} +1 -1
  63. package/assets/{index-C7hEybuy.js → index-BPH4bq6L.js} +1 -1
  64. package/assets/{index-CDSbn3SW.js → index-BPa10U7S.js} +2 -2
  65. package/assets/{index-CijzbRBJ.js → index-BTbJkw2h.js} +1 -1
  66. package/assets/{index-BlSRcuid.js → index-BWWcY9Ui.js} +1 -1
  67. package/assets/{index-DjUJoQZC.js → index-BYFbS7nW.js} +1 -1
  68. package/assets/{index-C9hpF5Zb.js → index-BaVtOO6t.js} +1 -1
  69. package/assets/{index-DGCEPw6Q.js → index-Bc_XrzTG.js} +1 -1
  70. package/assets/{index-jmpN1CZn.js → index-BdXUoeDl.js} +1 -1
  71. package/assets/{index-CaeVk9Dy.js → index-BfMUWitg.js} +1 -1
  72. package/assets/{index-wUFVtYuu.js → index-Bmyk-e0Z.js} +1 -1
  73. package/assets/{index-CpnYRmXG.js → index-BqKiriHU.js} +1 -1
  74. package/assets/{index-SeURPzoq.js → index-BzBBEm1y.js} +1 -1
  75. package/assets/{index-BJ_QKI7g.js → index-C1zw_jvz.js} +28 -28
  76. package/assets/{index-D60X16p8.js → index-C3sRipyF.js} +1 -1
  77. package/assets/{index-BsQzSxCr.js → index-C5sIT0tb.js} +1 -1
  78. package/assets/{index-BBrMxcXw.js → index-CFX7-nql.js} +1 -1
  79. package/assets/{index--cPi4o8K.js → index-COTqPlSo.js} +1 -1
  80. package/assets/{index-BKKTIysr.js → index-CP8m1u84.js} +1 -1
  81. package/assets/{index-CkkiWu3m.js → index-CWJl0T5f.js} +1 -1
  82. package/assets/{index-f0ZcLHB4.js → index-CfKPHln4.js} +1 -1
  83. package/assets/{index-C340qDw7.js → index-CgFd602S.js} +1 -1
  84. package/assets/{index-D7Wyaha_.js → index-Ci_h9xYZ.js} +1 -1
  85. package/assets/{index-hpL8NPIy.js → index-Cq6p8O8N.js} +1 -1
  86. package/assets/{index-Xlg0S1xP.js → index-Cw0X2YFE.js} +1 -1
  87. package/assets/{index-D5nkWH4b.js → index-D4UBoQqv.js} +1 -1
  88. package/assets/{index-Bybrl6u1.js → index-D5-hMxEz.js} +1 -1
  89. package/assets/{index-UPHX7Pfh.js → index-D9Qz4bzh.js} +1 -1
  90. package/assets/{index-DLG2tqiB.js → index-D9vktHzl.js} +1 -1
  91. package/assets/{index-DmSIzgEH.js → index-DEu_mGCU.js} +1 -1
  92. package/assets/{index-BIxKztx0.js → index-DSsR20MG.js} +1 -1
  93. package/assets/{index-C3_zjZ8P.js → index-DYvtCH-a.js} +2 -2
  94. package/assets/{index-C7mvyx-2.js → index-DZdvpJR7.js} +1 -1
  95. package/assets/{index-BD56aksA.js → index-DpKiyVfQ.js} +1 -1
  96. package/assets/{index-BSJ2Bu7u.js → index-Drll3iZv.js} +1 -1
  97. package/assets/{index-qjYSTcyF.js → index-DsaI3D4d.js} +3 -3
  98. package/assets/{index-DQoqkX47.js → index-Du5uk45Q.js} +1 -1
  99. package/assets/{index-a9iM5Ppc.js → index-DwXY_0me.js} +3 -3
  100. package/assets/{index-CXl2e07e.js → index-GKORwvdA.js} +1 -1
  101. package/assets/{index-DDIGuWa_.js → index-LXawog8O.js} +1 -1
  102. package/assets/{index-BBm1Gh-y.js → index-NJd4P5K3.js} +1 -1
  103. package/assets/{index-Bho_nwZ6.js → index-ScgGQAhq.js} +1 -1
  104. package/assets/{index-D7xFuNJh.js → index-o6E9IjdT.js} +1 -1
  105. package/assets/{index-vw2pKkQA.js → index-pgfSp-jn.js} +2 -2
  106. package/assets/{index-CZ_Yva86.js → index-vd9YojnC.js} +1 -1
  107. package/assets/{index-DLvBdRwo.js → index-wNInR-jL.js} +1 -1
  108. package/assets/{index.es-Z-qK52rV.js → index.es-CCFOZERa.js} +1 -1
  109. package/assets/{index.es-DV1BuqVZ.js → index.es-DgJoRPHo.js} +4 -4
  110. package/assets/{index.es-lXpu4Zv4.js → index.es-_RJxIHwU.js} +1 -1
  111. package/assets/{localBatchGatewayRequest-BVr46Pdr.js → localBatchGatewayRequest-_AoYEiK7.js} +1 -1
  112. package/assets/{mana-rate-nE0eZdyC.js → mana-rate-C_85VLuc.js} +1 -1
  113. package/assets/network-Ce6LZqru.js +1 -0
  114. package/assets/{networks-CyKyAnnj.js → networks-Ddls1APy.js} +1 -1
  115. package/assets/{onramp-D-CVQK10.js → onramp-CbrZeS8x.js} +1 -1
  116. package/assets/{openzeppelin-CZBvYWQH.js → openzeppelin-Dc0QLeyv.js} +1 -1
  117. package/assets/{ownerOf-DpxlatB6.js → ownerOf-DCCyyTsB.js} +1 -1
  118. package/assets/{parseNft-BteugRHW.js → parseNft-yLNtdVoG.js} +2 -2
  119. package/assets/{parseSignature-XWyL3GOI.js → parseSignature-BXcK95O1.js} +3 -3
  120. package/assets/{parseSignature-7MLI5FFb.js → parseSignature-_XuTQKnp.js} +1 -1
  121. package/assets/{pay-with-exchange-Ct_mQI29.js → pay-with-exchange-DnGEPz-9.js} +1 -1
  122. package/assets/{qr-overlay-BqNftzdl.js → qr-overlay-D1woZopL.js} +1 -1
  123. package/assets/{receive-CDy6Z42p.js → receive-DxQFpvBx.js} +1 -1
  124. package/assets/{resolveImplementation-Bc0hVuIY.js → resolveImplementation-BhJMvZcE.js} +1 -1
  125. package/assets/{rpc-boAlAOZR.js → rpc-DgEEESUq.js} +1 -1
  126. package/assets/{secp256k1-D1h2lDQ6.js → secp256k1-BRibcqku.js} +1 -1
  127. package/assets/{secp256k1-By0xJ9f-.js → secp256k1-JL5K1b6W.js} +1 -1
  128. package/assets/{secp256k1-C4VLJ_Ul.js → secp256k1-c93U_qwn.js} +1 -1
  129. package/assets/{send-CiVTg7A8.js → send-DTIO_xKD.js} +1 -1
  130. package/assets/{send-batch-transaction-CqZ6goZh.js → send-batch-transaction-D_I1HvSE.js} +1 -1
  131. package/assets/{send-eip712-transaction-DJrgfOzh.js → send-eip712-transaction-CB6q4yTz.js} +2 -2
  132. package/assets/{send-gasless-transaction-lYt5N3_C.js → send-gasless-transaction-BjkKopST.js} +2 -2
  133. package/assets/{sendRawTransaction-DmHNTzdc.js → sendRawTransaction-Cl3fTy2r.js} +3 -3
  134. package/assets/{serializeTransaction-0eBlvpQK.js → serializeTransaction-B5MYVv86.js} +1 -1
  135. package/assets/{session-proposal-BSyh4SKk.js → session-proposal-DnoyWdz2.js} +1 -1
  136. package/assets/{session-request-DV94fpr9.js → session-request-83tzrKS9.js} +2 -2
  137. package/assets/{sha256-YU3Zqsfv.js → sha256-C4qHsWKZ.js} +1 -1
  138. package/assets/{signing-D24XEdbq.js → signing-CjtnBxxM.js} +4 -4
  139. package/assets/{socials-rQJycNz4.js → socials-DHKSWRNK.js} +1 -1
  140. package/assets/{swaps-BOwdKS6n.js → swaps-oR49jgCz.js} +1 -1
  141. package/assets/{thirdweb-DH7tH_YY.js → thirdweb-DLsVRg5B.js} +3 -3
  142. package/assets/{totalSupply-C0ZsfGnG.js → totalSupply-BbnfAQRL.js} +1 -1
  143. package/assets/{trade-encoding-ELuUTRbi.js → trade-encoding-gNFeXeFL.js} +1 -1
  144. package/assets/{transactionReceipt-Dn2q3Bhv.js → transactionReceipt-D2SEnNQ1.js} +1 -1
  145. package/assets/{transactions-BTj8wcwx.js → transactions-CmcaT-SG.js} +1 -1
  146. package/assets/{useInfiniteGrid-XR5F3f0o.js → useInfiniteGrid-BA1C5BmN.js} +1 -1
  147. package/assets/{verifyHash-BA1JKF0y.js → verifyHash-ZaW4iQ5U.js} +1 -1
  148. package/assets/{w3m-modal-CjQ_EDZs.js → w3m-modal-C7bXvOf6.js} +1 -1
  149. package/assets/{w3m-modal-DORychBC.js → w3m-modal-jjoiIHiM.js} +1 -1
  150. package/assets/{wait-for-tx-receipt-heRjFFnK.js → wait-for-tx-receipt-DztajESX.js} +1 -1
  151. package/assets/{wallet-kind-g2ENkqJ_.js → wallet-kind-BCHFSy95.js} +1 -1
  152. package/assets/{wallets-DHqgQa_5.js → wallets-CdPPQGkU.js} +6 -6
  153. package/assets/{web-connector-IkMDp4Rj.js → web-connector-C3v6OgPl.js} +3 -3
  154. package/assets/{writeContract-DKZmoUmz.js → writeContract-DNofglus.js} +1 -1
  155. package/assets/{zoraTestnet-B0fxbkay.js → zoraTestnet-IteRz7Y6.js} +1 -1
  156. package/index.html +8 -8
  157. package/package.json +2 -2
  158. package/assets/GetCredits-F9je0G_Y.js +0 -2
  159. package/assets/RealCheckout-CXz68lrR.js +0 -2
  160. package/assets/decimals-DyV7oW3h.js +0 -1
  161. package/assets/network-Cc4BxKcP.js +0 -1
@@ -1,11 +1,11 @@
1
- import{r as l,j as v}from"./react-iAgwec9M.js";const w="https://cdn.decentraland.org/@dcl/shop/0.1.0-29486364190.commit-e3b7c10/assets/custom-welcome-background-BxlFQma9.webp",S="https://cdn.decentraland.org/@dcl/shop/0.1.0-29486364190.commit-e3b7c10/assets/DCL_LogoPattern-BryBPc3d.png",b=`
1
+ import{r as l,j as v}from"./react-iAgwec9M.js";const w="https://cdn.decentraland.org/@dcl/shop/0.1.0-29489010081.commit-c04e72d/assets/custom-welcome-background-BxlFQma9.webp",S="https://cdn.decentraland.org/@dcl/shop/0.1.0-29489010081.commit-c04e72d/assets/DCL_LogoPattern-BryBPc3d.png",U=`
2
2
  attribute vec2 a_position;
3
3
  varying vec2 v_uv;
4
4
  void main() {
5
5
  v_uv = a_position * 0.5 + 0.5;
6
6
  gl_Position = vec4(a_position, 0.0, 1.0);
7
7
  }
8
- `,U=`
8
+ `,b=`
9
9
  precision highp float;
10
10
 
11
11
  uniform float u_time;
@@ -77,4 +77,4 @@ void main() {
77
77
 
78
78
  gl_FragColor = result;
79
79
  }
80
- `;function g(t,a,r){const e=t.createShader(a);return e?(t.shaderSource(e,r),t.compileShader(e),t.getShaderParameter(e,t.COMPILE_STATUS)?e:(console.error("Shader compile error:",t.getShaderInfoLog(e)),t.deleteShader(e),null)):null}function P(t,a,r){const e=t.createProgram();return e?(t.attachShader(e,a),t.attachShader(e,r),t.linkProgram(e),t.getProgramParameter(e,t.LINK_STATUS)?e:(console.error("Program link error:",t.getProgramInfoLog(e)),t.deleteProgram(e),null)):null}function D(t,a,r){const e=t.createTexture();if(!e)return null;t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array([128,128,128,255]));const o=new Image;return o.crossOrigin="anonymous",o.onload=()=>{r!=null&&r()||(t.bindTexture(t.TEXTURE_2D,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.generateMipmap(t.TEXTURE_2D))},o.src=a,e}function L(){const t=l.useRef(null),a=l.useRef(0);return l.useEffect(()=>{var h;const r=t.current;if(!r||(h=window.matchMedia)!=null&&h.call(window,"(prefers-reduced-motion: reduce)").matches)return;const e=r.getContext("webgl",{alpha:!1,antialias:!1});if(!e)return;const o=g(e,e.VERTEX_SHADER,b),c=g(e,e.FRAGMENT_SHADER,U);if(!o||!c){o&&e.deleteShader(o),c&&e.deleteShader(c);return}const n=P(e,o,c);if(!n){e.deleteShader(o),e.deleteShader(c);return}const u=e.getAttribLocation(n,"a_position"),_=e.getUniformLocation(n,"u_time"),R=e.getUniformLocation(n,"u_resolution"),y=e.getUniformLocation(n,"u_overlayTex"),s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);let m=!1;const d=D(e,S,()=>m),A=()=>{const i=window.devicePixelRatio||1,x=r.clientWidth*i,E=r.clientHeight*i;(r.width!==x||r.height!==E)&&(r.width=x,r.height=E)},p=performance.now()/1e3,f=()=>{A(),e.viewport(0,0,r.width,r.height),e.useProgram(n),e.uniform1f(_,performance.now()/1e3-p),e.uniform2f(R,r.width,r.height),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,d),e.uniform1i(y,0),e.enableVertexAttribArray(u),e.bindBuffer(e.ARRAY_BUFFER,s),e.vertexAttribPointer(u,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLES,0,6),a.current=requestAnimationFrame(f)},T=i=>{i.preventDefault(),cancelAnimationFrame(a.current),r.style.opacity="0"};return r.addEventListener("webglcontextlost",T,!1),a.current=requestAnimationFrame(f),()=>{m=!0,cancelAnimationFrame(a.current),r.removeEventListener("webglcontextlost",T),e.deleteProgram(n),e.deleteShader(o),e.deleteShader(c),e.deleteBuffer(s),e.deleteTexture(d)}},[]),v.jsxs("div",{className:"AnimatedBackground","aria-hidden":!0,children:[v.jsx("div",{className:"AnimatedBackground__fallback",style:{backgroundImage:`url(${w})`}}),v.jsx("canvas",{ref:t,className:"AnimatedBackground__canvas"})]})}export{L as default};
80
+ `;function g(t,a,r){const e=t.createShader(a);return e?(t.shaderSource(e,r),t.compileShader(e),t.getShaderParameter(e,t.COMPILE_STATUS)?e:(console.error("Shader compile error:",t.getShaderInfoLog(e)),t.deleteShader(e),null)):null}function P(t,a,r){const e=t.createProgram();return e?(t.attachShader(e,a),t.attachShader(e,r),t.linkProgram(e),t.getProgramParameter(e,t.LINK_STATUS)?e:(console.error("Program link error:",t.getProgramInfoLog(e)),t.deleteProgram(e),null)):null}function D(t,a,r){const e=t.createTexture();if(!e)return null;t.bindTexture(t.TEXTURE_2D,e),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,1,1,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array([128,128,128,255]));const o=new Image;return o.crossOrigin="anonymous",o.onload=()=>{r!=null&&r()||(t.bindTexture(t.TEXTURE_2D,e),t.pixelStorei(t.UNPACK_FLIP_Y_WEBGL,!0),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,o),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.REPEAT),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR_MIPMAP_LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.generateMipmap(t.TEXTURE_2D))},o.src=a,e}function L(){const t=l.useRef(null),a=l.useRef(0);return l.useEffect(()=>{var h;const r=t.current;if(!r||(h=window.matchMedia)!=null&&h.call(window,"(prefers-reduced-motion: reduce)").matches)return;const e=r.getContext("webgl",{alpha:!1,antialias:!1});if(!e)return;const o=g(e,e.VERTEX_SHADER,U),c=g(e,e.FRAGMENT_SHADER,b);if(!o||!c){o&&e.deleteShader(o),c&&e.deleteShader(c);return}const n=P(e,o,c);if(!n){e.deleteShader(o),e.deleteShader(c);return}const u=e.getAttribLocation(n,"a_position"),_=e.getUniformLocation(n,"u_time"),R=e.getUniformLocation(n,"u_resolution"),y=e.getUniformLocation(n,"u_overlayTex"),s=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,s),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);let m=!1;const d=D(e,S,()=>m),A=()=>{const i=window.devicePixelRatio||1,x=r.clientWidth*i,E=r.clientHeight*i;(r.width!==x||r.height!==E)&&(r.width=x,r.height=E)},p=performance.now()/1e3,f=()=>{A(),e.viewport(0,0,r.width,r.height),e.useProgram(n),e.uniform1f(_,performance.now()/1e3-p),e.uniform2f(R,r.width,r.height),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,d),e.uniform1i(y,0),e.enableVertexAttribArray(u),e.bindBuffer(e.ARRAY_BUFFER,s),e.vertexAttribPointer(u,2,e.FLOAT,!1,0,0),e.drawArrays(e.TRIANGLES,0,6),a.current=requestAnimationFrame(f)},T=i=>{i.preventDefault(),cancelAnimationFrame(a.current),r.style.opacity="0"};return r.addEventListener("webglcontextlost",T,!1),a.current=requestAnimationFrame(f),()=>{m=!0,cancelAnimationFrame(a.current),r.removeEventListener("webglcontextlost",T),e.deleteProgram(n),e.deleteShader(o),e.deleteShader(c),e.deleteBuffer(s),e.deleteTexture(d)}},[]),v.jsxs("div",{className:"AnimatedBackground","aria-hidden":!0,children:[v.jsx("div",{className:"AnimatedBackground__fallback",style:{backgroundImage:`url(${w})`}}),v.jsx("canvas",{ref:t,className:"AnimatedBackground__canvas"})]})}export{L as default};
@@ -1 +1 @@
1
- import{r as l,j as e,a as fe,d as ye}from"./react-iAgwec9M.js";import{u as xe,i as z,c as ke,v as je,w as ae,h as Ne,q as ge,F as ve,J as A,z as R,I as D,H as V,e as E,aj as J,x as Ce,y as H,A as Z,am as we}from"./index-BJ_QKI7g.js";import{r as Se,a as U,m as Ee}from"./mana-rate-nE0eZdyC.js";import{S as X}from"./SkeletonCards-BhzQlTiQ.js";import{L as Ie}from"./LoadMore-8Dx5lULo.js";import{a as ee}from"./buy-DK-hDYib.js";import{g as Me,a as Fe,w as Pe,S as Ae,G as Re}from"./buy-gasless-BqKKprU3.js";import{u as $e}from"./useInfiniteGrid-XR5F3f0o.js";import"./ethers-D-4WUfRB.js";import"./index-CfK4LG22.js";import"./trade-encoding-ELuUTRbi.js";function Le(){return xe({queryKey:["mana-rate",z.chainId],queryFn:()=>Se(z.chainId),staleTime:6e4,refetchInterval:6e4,retry:1})}const Be=[{key:"all",label:"Shop All"},{key:"wearable",label:"Wearables",expandable:!0,subs:[{key:"Head",label:"Head",icon:"cat-head"},{key:"Upper Body",label:"Upper Body",icon:"cat-upper"},{key:"Handwear",label:"Handwear",icon:"cat-handwear"},{key:"Lower Body",label:"Lower Body",icon:"cat-lower"},{key:"Feet",label:"Feet",icon:"cat-feet"},{key:"Accessories",label:"Accessories",icon:"cat-accessories"},{key:"Skins",label:"Skins",icon:"cat-skins"}]},{key:"emote",label:"Emotes",expandable:!0,subs:[{key:"Dance",label:"Dance",icon:"emote-dance"},{key:"Stunt",label:"Stunt",icon:"emote-stunt"},{key:"Greetings",label:"Greetings",icon:"emote-greetings"},{key:"Fun",label:"Fun",icon:"emote-fun"},{key:"Poses",label:"Poses",icon:"emote-poses"},{key:"Reactions",label:"Reactions",icon:"emote-reactions"},{key:"Horror",label:"Horror",icon:"emote-horror"},{key:"Miscellaneous",label:"Miscellaneous",icon:"emote-misc"}]}];function qe({category:s,subCategory:c,onCategory:o,onSub:b}){const[t,d]=l.useState(()=>s==="wearable"?"wearable":null);function y(r){r.subs?d(m=>{const h=m!==r.key;return h&&o(r.key),h?r.key:null}):(o(r.key),d(null))}return e.jsx("div",{className:"catfilter",children:Be.map(r=>{const m=t===r.key&&!!r.subs,h=r.key===s;return e.jsxs("div",{className:"catfilter__group",children:[e.jsxs("button",{type:"button",className:`catfilter__cat${m?" is-expanded":""}${h?" is-selected":""}`,onClick:()=>y(r),children:[e.jsx("span",{className:"catfilter__cat-label",children:r.label}),r.expandable?e.jsx("span",{className:`ico ico-chevron catfilter__chev${m?" is-up":""}`,"aria-hidden":!0}):null]}),r.subs?e.jsx("div",{className:`catfilter__subs${m?" is-open":""}`,children:e.jsx("div",{className:"catfilter__subs-inner",children:r.subs.map(i=>e.jsx("button",{type:"button",className:`catfilter__sub${c===i.key?" is-active":""}`,onClick:()=>b(c===i.key?null:i.key),children:e.jsxs("span",{className:"catfilter__sub-left",children:[e.jsx("span",{className:`ico ico-${i.icon} catfilter__sub-ico`,"aria-hidden":!0}),e.jsx("span",{className:"catfilter__sub-label",children:i.label})]})},i.key))})}):null]},r.key)})})}const Te=["common","uncommon","rare","epic","legendary","mythic","unique","exotic"],K=[{key:"newest",label:"Newest",server:"newest"},{key:"price-asc",label:"Cheapest",server:"cheapest"},{key:"price-desc",label:"Most Expensive",server:"most_expensive"},{key:"name",label:"Name (A–Z)",server:"name"}];function We({panelKey:s,label:c,active:o,badge:b,align:t="left",panel:d,children:y}){const r=d.open===s,m=t==="right"?"filterbar__sort":"filterbar__trigger";return e.jsxs("div",{className:"filterbar__item",children:[e.jsxs("button",{className:`${m}${r?" is-open":""}${o?" is-active":""}`,onClick:()=>d.toggle(s),children:[c," ",b?e.jsx("span",{className:"filterbar__badge",children:b}):null," ",e.jsx("span",{className:`ico ico-chevron filterbar__chev${r?" is-up":""}`,"aria-hidden":!0})]}),r?y:null]})}function Ge({sort:s,onSort:c,sortOptions:o=K,total:b,loading:t,query:d,onOpenFilters:y}){const[r,m]=l.useState(null),h={open:r,toggle:i=>m(j=>j===i?null:i),close:()=>m(null)};return e.jsxs(e.Fragment,{children:[r?e.jsx("div",{className:"filterbar__scrim",onClick:h.close,"aria-hidden":!0}):null,e.jsxs("div",{className:"browse__toolbar",children:[e.jsxs("span",{className:"browse__count",children:[t?"…":`${b.toLocaleString()} Item${b===1?"":"s"}`,d?` for “${d}”`:""]}),e.jsxs("div",{className:"browse__dropdowns",children:[y?e.jsxs("button",{type:"button",className:"browse__filters-btn",onClick:y,children:[e.jsx("span",{className:"ico ico-filter","aria-hidden":!0}),"Filters"]}):null,e.jsx(We,{panelKey:"sort",label:"Sort By",align:"right",panel:h,children:e.jsx("div",{className:"filter-pop filter-pop--sort",children:o.map(i=>e.jsx("button",{className:`filter-pop__sort${i.key===s?" is-active":""}`,onClick:()=>{c(i.key),h.close()},children:i.label},i.key))})})]})]})]})}function se(s){const c=s,o=(c.message??"").toLowerCase();return c.code===4001||o.includes("reject")||o.includes("denied")||o.includes("cancel")?"You cancelled the request.":o.includes("insufficient")?`Not enough ${H.name} — get more first.`:o.includes("not found")||o.includes("no active listing")||o.includes("404")?"This item was just sold or removed. Refreshing the market…":o.includes("your own listing")?"You can't buy your own listing.":"Couldn't complete checkout — please try again."}function Oe(s){return{id:s.tradeId,tradeId:s.tradeId,name:s.name,creator:s.creator,contractAddress:s.contractAddress,itemId:s.itemId,category:s.category,wearableCategory:s.wearableCategory??void 0,rarity:s.rarity,network:s.network,chainId:s.chainId,thumbnail:s.thumbnail,priceCredits:0,gender:null}}function Ue({listing:s,rate:c,onClose:o,onSold:b}){const{session:t}=ke(),{data:d,isError:y}=je(t),r=ae(),m=fe(),[h,i]=l.useState("confirm"),[j,I]=l.useState("Locking today’s price…"),[C,M]=l.useState(null),[n,G]=l.useState(null),f=l.useRef(null),S=Math.ceil(U(s.manaWei,c)/10);l.useEffect(()=>{let v=!1;if(!t){i("error"),M("Sign in to check out.");return}return(async()=>{try{const u=await Ne(s.tradeId);if(!u)throw new Error("not found");if(ge(u,t.address))throw new Error("You can't buy your own listing.");const p=U(s.manaWei,c);if(!Number.isFinite(p)||p<=0)throw new Error("price unavailable");const{credit:x,maxCreditedValue:$,usdCents:N}=await ve(t.identity,p,s.tradeId);if(v){A(t.identity,[x.id]).catch(()=>{});return}f.current=x.id,G({trade:u,credit:x,maxCreditedValue:$,usdCents:N,credits:Math.ceil(N/10)}),I("")}catch(u){if(v)return;console.error("[market] authorize failed",u),R(V(u)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:D(u),value_usd:Math.round(U(s.manaWei,c))/100}),i("error"),M(se(u))}})(),()=>{v=!0,f.current&&t&&(A(t.identity,[f.current]).catch(()=>{}),f.current=null)}},[]);const F=!!n&&d!=null&&d.credits<n.credits;async function P(){if(!t||!n)return;if(F){A(t.identity,[n.credit.id]).catch(()=>{}),f.current=null,m("/credits");return}i("working"),M(null);let v=!1;try{I("Confirming your purchase…");const u={trade:n.trade,buyer:t.address,signer:t.signer,credits:[n.credit],maxCreditedValue:n.maxCreditedValue};let p;if(Me())try{p=await Fe(u),await Pe(p),v=!0}catch(x){if(x instanceof Ae)v=!0;else if(x instanceof Re)p=await ee(u);else throw x}else p=await ee(u);f.current=null,R("Shop Completed Purchase",{items:[{item_id:s.itemId??null,contract_address:s.contractAddress,token_id:null,price_usd:n.usdCents/100}],value_credits:n.credits,value_usd:n.usdCents/100,purchase_type:"item",is_primary:!0,payment_type:"credits",no_crypto_step:v,transaction_hash:p??null}),r.invalidateQueries({queryKey:["usd-balance"]}),m("/success",{state:{items:[Oe(s)],txHash:p}})}catch(u){console.error("[market] buy now failed",u),A(t.identity,[n.credit.id]).catch(()=>{}),f.current=null,R(V(u)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:D(u),value_usd:n.usdCents/100}),r.invalidateQueries({queryKey:["usd-balance"]});const p=se(u);M(p),i("error"),/sold or removed/i.test(p)&&b()}}function g(){t&&n&&A(t.identity,[n.credit.id]).catch(()=>{}),f.current=null,o()}const k=h==="working";return e.jsxs("div",{className:"mkt-modal",role:"dialog","aria-modal":"true","aria-label":`Buy ${s.name}`,children:[e.jsx("div",{className:"mkt-modal__scrim",onClick:k?void 0:g,"aria-hidden":!0}),e.jsxs("div",{className:"mkt-modal__card",children:[e.jsxs("div",{className:"mkt-modal__head",children:[e.jsx("div",{className:"mkt-modal__thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{children:[e.jsx("div",{className:"mkt-modal__name",title:s.name,children:s.name||"Item"}),e.jsx("span",{className:"chip chip--rarity",children:s.rarity})]})]}),e.jsx("div",{className:"mkt-modal__price",children:n?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mkt-modal__price-label",children:"Final price"}),e.jsxs("div",{className:"mkt-modal__price-value",children:[e.jsx(E,{className:"mkt-modal__diamond"}),J(n.credits)]}),e.jsxs("div",{className:"mkt-modal__price-sub muted",children:["Locked for this purchase · $",(n.usdCents/100).toFixed(2)]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mkt-modal__price-label",children:"Today’s price"}),e.jsxs("div",{className:"mkt-modal__price-value mkt-modal__price-value--approx",children:[e.jsx("span",{className:"mkt-modal__approx","aria-hidden":!0,children:"≈"}),e.jsx(E,{className:"mkt-modal__diamond"}),J(S)]}),e.jsx("div",{className:"mkt-modal__price-sub muted",children:j||"Locking today’s price…"})]})}),t?e.jsxs("div",{className:"mkt-modal__balance muted",children:["Your balance: ",e.jsx(E,{className:"ccy-mark"})," ",Ce(d,y)]}):null,F?e.jsxs("p",{className:"muted mkt-modal__note",children:["You’ll need a few more ",H.name," to buy this."]}):null,j&&h==="working"?e.jsx("p",{className:"muted mkt-modal__note",children:j}):null,C?e.jsx("p",{className:"error mkt-modal__note",children:C}):null,e.jsxs("div",{className:"mkt-modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:g,disabled:k,children:"Cancel"}),e.jsx("button",{className:"btn btn--purple",onClick:P,disabled:k||!n,children:k?"Buying…":F?`Get ${H.name}`:"Confirm purchase"})]})]})]})}const He=48,w=1e5,Ke={Head:["head","hat","hair","facial_hair","eyes","eyebrows","mouth","mask","helmet","tiara","top_head"],"Upper Body":["upper_body"],Handwear:["hands_wear"],"Lower Body":["lower_body"],Feet:["feet"],Accessories:["earring","eyewear"],Skins:["skin"],Dance:["dance"],Stunt:["stunt"],Greetings:["greetings"],Fun:["fun"],Poses:["poses"],Reactions:["reactions"],Horror:["horror"],Miscellaneous:["miscellaneous"]};function Ye(s){return{tradeId:s.tradeId??s.id,listingType:"primary",contractAddress:s.contractAddress,itemId:s.itemId??"",name:s.name,thumbnail:s.thumbnail,rarity:s.rarity,category:s.category,wearableCategory:s.wearableCategory??null,creator:s.creator,manaWei:s.manaWei??"0",available:1,network:s.network,chainId:s.chainId,createdAt:0}}function ts(){const[s]=ye(),c=(s.get("q")??"").trim().toLowerCase(),o=ae(),[b,t]=l.useState("wearable"),[d,y]=l.useState(null),[r,m]=l.useState([]),[h,i]=l.useState(""),[j,I]=l.useState(""),[C,M]=l.useState("newest"),[n,G]=l.useState(!1),[f,S]=l.useState(!1),[F,P]=l.useState(null);l.useEffect(()=>{if(!f)return;const a=_=>{_.key==="Escape"&&S(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[f]);const g=h&&!Number.isNaN(Number(h))?Number(h):void 0,k=j&&!Number.isNaN(Number(j))?Number(j):void 0,v=d?Ke[d]:void 0,u=(K.find(a=>a.key===C)??K[0]).server,p={category:b,rarities:r.length?r:void 0,wearableCategories:v,minPriceCredits:g,maxPriceCredits:k,search:c||void 0,sortBy:u},{items:x,total:$,isLoading:N,error:re,hasNextPage:te,isFetchingNextPage:Y,fetchNextPage:ie}=$e(["unified-listings",p],a=>we({...p,first:He,skip:a})),L=$,{data:B,isError:ne}=Le(),le=a=>B&&a.manaWei?Ee(a.manaWei,B):null,Q=l.useRef(null);l.useEffect(()=>{N||!c||Q.current===c||(Q.current=c,R("Shop Searched",{query:c,result_count:L}))},[c,N,L]);const q=l.useRef("__init__");l.useEffect(()=>{if(N)return;const a=JSON.stringify({category:b,subCategory:d,rarities:r,min:g,max:k,sort:C});if(q.current==="__init__"||q.current===a){q.current=a;return}q.current=a,R("Shop Applied Filter",{filters:{category:b,sub_category:d,rarities:r,min_price_credits:g??null,max_price_credits:k??null,sort:C},result_count:L})},[b,d,r,g,k,C,N,L]);function ce(a){t(a),y(null)}function oe(a){m(_=>_.includes(a)?_.filter(O=>O!==a):[..._,a])}function de(){t("wearable"),y(null),m([]),i(""),I("")}function ue(a){const _=x.find(O=>O.id===a.id);_&&_.source==="legacy"&&_.manaWei&&P(Ye(_))}function me(){o.invalidateQueries({queryKey:["unified-listings"]})}const T=g!=null?Math.min(g,w):0,W=k!=null?Math.min(k,w):w,he=T/w*100,pe=W/w*100;function _e(a){const _=Math.min(a,W);i(_<=0?"":String(_))}function be(a){const _=Math.max(a,T);I(_>=w?"":String(_))}return e.jsxs("div",{className:"browse browse--sidebar",children:[f?e.jsx("div",{className:"browse__scrim",onClick:()=>S(!1),"aria-hidden":!0}):null,e.jsxs("aside",{className:`browse__sidebar${f?" 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:()=>S(!1),"aria-label":"Close filters",children:"✕"})]}),e.jsx("div",{className:"sidebar__section-label",children:"Category"}),e.jsx(qe,{category:b,subCategory:d,onCategory:ce,onSub:y}),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(E,{className:"price-filter__coin"}),e.jsx("input",{type:"number",min:"0","aria-label":"Minimum price",placeholder:"0",value:h,onChange:a=>i(a.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(E,{className:"price-filter__coin"}),e.jsx("input",{type:"number",min:"0","aria-label":"Maximum price",placeholder:"0",value:j,onChange:a=>I(a.target.value)})]})]})]}),e.jsxs("div",{className:"price-filter__slider",style:{"--min-pct":`${he}%`,"--max-pct":`${pe}%`},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:w,value:T,"aria-label":"Minimum price slider",onChange:a=>_e(Number(a.target.value))}),e.jsx("input",{type:"range",min:0,max:w,value:W,"aria-label":"Maximum price slider",onChange:a=>be(Number(a.target.value))})]}),e.jsxs("div",{className:"price-filter__range",children:[e.jsxs("span",{className:"price-filter__range-val",children:[e.jsx(E,{className:"price-filter__coin"}),T.toLocaleString()]}),e.jsxs("span",{className:"price-filter__range-val",children:[e.jsx(E,{className:"price-filter__coin"}),W.toLocaleString()]})]})]}),e.jsx("div",{className:"sidebar__divider"}),e.jsxs("button",{type:"button",className:"sidebar__section-toggle","aria-expanded":n,onClick:()=>G(a=>!a),children:[e.jsx("span",{className:"sidebar__section-label",children:"Rarity"}),e.jsx("span",{className:`ico ico-chevron sidebar__section-chev${n?" is-up":""}`,"aria-hidden":!0})]}),n?e.jsx("div",{className:"rarity-filter",children:Te.map(a=>e.jsxs("label",{className:`rarity-filter__check${r.includes(a)?" is-on":""}`,children:[e.jsx("input",{type:"checkbox",checked:r.includes(a),onChange:()=>oe(a)}),e.jsx("span",{children:a})]},a))}):null,e.jsxs("div",{className:"browse__sidebar-foot",children:[e.jsx("button",{type:"button",className:"browse__clear",onClick:de,children:"Clear Filters"}),e.jsx("button",{type:"button",className:"browse__apply",onClick:()=>S(!1),children:"Apply"})]})]}),e.jsxs("div",{className:"browse__main",children:[e.jsx(Ge,{sort:C,onSort:M,total:$,loading:N,query:c,onOpenFilters:()=>S(!0)}),ne&&x.some(a=>a.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,re?e.jsx("p",{className:"error",children:"Couldn’t load items — please try again."}):null,e.jsx("div",{className:"grid",children:N?e.jsx(X,{count:15}):e.jsxs(e.Fragment,{children:[x.map(a=>a.source==="legacy"?e.jsx(Z,{item:a,mode:"market",marketPriceCredits:le(a),onBuyNow:ue},a.id):e.jsx(Z,{item:a},a.id)),Y?e.jsx(X,{count:6}):null]})}),e.jsx(Ie,{hasNextPage:te,isFetching:Y,onLoadMore:()=>ie()}),!N&&x.length===0?e.jsx("p",{className:"muted",children:"No items match your filters."}):null]}),F&&B?e.jsx(Ue,{listing:F,rate:B,onClose:()=>P(null),onSold:()=>{P(null),me()}}):null]})}export{ts as Assets};
1
+ import{r as l,j as e,a as fe,d as ye}from"./react-iAgwec9M.js";import{u as xe,i as z,c as ke,v as je,w as ae,h as Ne,q as ge,F as ve,J as A,z as R,I as D,H as V,e as E,aj as J,x as Ce,y as H,A as Z,am as we}from"./index-C1zw_jvz.js";import{r as Se,a as U,m as Ee}from"./mana-rate-C_85VLuc.js";import{S as X}from"./SkeletonCards-BhzQlTiQ.js";import{L as Ie}from"./LoadMore-8Dx5lULo.js";import{a as ee}from"./buy-DEy5oWx-.js";import{g as Me,a as Fe,w as Pe,S as Ae,G as Re}from"./buy-gasless-VIo89iNM.js";import{u as $e}from"./useInfiniteGrid-BA1C5BmN.js";import"./ethers-D-4WUfRB.js";import"./index-BF4WrGCQ.js";import"./trade-encoding-gNFeXeFL.js";function Le(){return xe({queryKey:["mana-rate",z.chainId],queryFn:()=>Se(z.chainId),staleTime:6e4,refetchInterval:6e4,retry:1})}const Be=[{key:"all",label:"Shop All"},{key:"wearable",label:"Wearables",expandable:!0,subs:[{key:"Head",label:"Head",icon:"cat-head"},{key:"Upper Body",label:"Upper Body",icon:"cat-upper"},{key:"Handwear",label:"Handwear",icon:"cat-handwear"},{key:"Lower Body",label:"Lower Body",icon:"cat-lower"},{key:"Feet",label:"Feet",icon:"cat-feet"},{key:"Accessories",label:"Accessories",icon:"cat-accessories"},{key:"Skins",label:"Skins",icon:"cat-skins"}]},{key:"emote",label:"Emotes",expandable:!0,subs:[{key:"Dance",label:"Dance",icon:"emote-dance"},{key:"Stunt",label:"Stunt",icon:"emote-stunt"},{key:"Greetings",label:"Greetings",icon:"emote-greetings"},{key:"Fun",label:"Fun",icon:"emote-fun"},{key:"Poses",label:"Poses",icon:"emote-poses"},{key:"Reactions",label:"Reactions",icon:"emote-reactions"},{key:"Horror",label:"Horror",icon:"emote-horror"},{key:"Miscellaneous",label:"Miscellaneous",icon:"emote-misc"}]}];function qe({category:s,subCategory:c,onCategory:o,onSub:b}){const[t,d]=l.useState(()=>s==="wearable"?"wearable":null);function y(r){r.subs?d(m=>{const h=m!==r.key;return h&&o(r.key),h?r.key:null}):(o(r.key),d(null))}return e.jsx("div",{className:"catfilter",children:Be.map(r=>{const m=t===r.key&&!!r.subs,h=r.key===s;return e.jsxs("div",{className:"catfilter__group",children:[e.jsxs("button",{type:"button",className:`catfilter__cat${m?" is-expanded":""}${h?" is-selected":""}`,onClick:()=>y(r),children:[e.jsx("span",{className:"catfilter__cat-label",children:r.label}),r.expandable?e.jsx("span",{className:`ico ico-chevron catfilter__chev${m?" is-up":""}`,"aria-hidden":!0}):null]}),r.subs?e.jsx("div",{className:`catfilter__subs${m?" is-open":""}`,children:e.jsx("div",{className:"catfilter__subs-inner",children:r.subs.map(i=>e.jsx("button",{type:"button",className:`catfilter__sub${c===i.key?" is-active":""}`,onClick:()=>b(c===i.key?null:i.key),children:e.jsxs("span",{className:"catfilter__sub-left",children:[e.jsx("span",{className:`ico ico-${i.icon} catfilter__sub-ico`,"aria-hidden":!0}),e.jsx("span",{className:"catfilter__sub-label",children:i.label})]})},i.key))})}):null]},r.key)})})}const Te=["common","uncommon","rare","epic","legendary","mythic","unique","exotic"],K=[{key:"newest",label:"Newest",server:"newest"},{key:"price-asc",label:"Cheapest",server:"cheapest"},{key:"price-desc",label:"Most Expensive",server:"most_expensive"},{key:"name",label:"Name (A–Z)",server:"name"}];function We({panelKey:s,label:c,active:o,badge:b,align:t="left",panel:d,children:y}){const r=d.open===s,m=t==="right"?"filterbar__sort":"filterbar__trigger";return e.jsxs("div",{className:"filterbar__item",children:[e.jsxs("button",{className:`${m}${r?" is-open":""}${o?" is-active":""}`,onClick:()=>d.toggle(s),children:[c," ",b?e.jsx("span",{className:"filterbar__badge",children:b}):null," ",e.jsx("span",{className:`ico ico-chevron filterbar__chev${r?" is-up":""}`,"aria-hidden":!0})]}),r?y:null]})}function Ge({sort:s,onSort:c,sortOptions:o=K,total:b,loading:t,query:d,onOpenFilters:y}){const[r,m]=l.useState(null),h={open:r,toggle:i=>m(j=>j===i?null:i),close:()=>m(null)};return e.jsxs(e.Fragment,{children:[r?e.jsx("div",{className:"filterbar__scrim",onClick:h.close,"aria-hidden":!0}):null,e.jsxs("div",{className:"browse__toolbar",children:[e.jsxs("span",{className:"browse__count",children:[t?"…":`${b.toLocaleString()} Item${b===1?"":"s"}`,d?` for “${d}”`:""]}),e.jsxs("div",{className:"browse__dropdowns",children:[y?e.jsxs("button",{type:"button",className:"browse__filters-btn",onClick:y,children:[e.jsx("span",{className:"ico ico-filter","aria-hidden":!0}),"Filters"]}):null,e.jsx(We,{panelKey:"sort",label:"Sort By",align:"right",panel:h,children:e.jsx("div",{className:"filter-pop filter-pop--sort",children:o.map(i=>e.jsx("button",{className:`filter-pop__sort${i.key===s?" is-active":""}`,onClick:()=>{c(i.key),h.close()},children:i.label},i.key))})})]})]})]})}function se(s){const c=s,o=(c.message??"").toLowerCase();return c.code===4001||o.includes("reject")||o.includes("denied")||o.includes("cancel")?"You cancelled the request.":o.includes("insufficient")?`Not enough ${H.name} — get more first.`:o.includes("not found")||o.includes("no active listing")||o.includes("404")?"This item was just sold or removed. Refreshing the market…":o.includes("your own listing")?"You can't buy your own listing.":"Couldn't complete checkout — please try again."}function Oe(s){return{id:s.tradeId,tradeId:s.tradeId,name:s.name,creator:s.creator,contractAddress:s.contractAddress,itemId:s.itemId,category:s.category,wearableCategory:s.wearableCategory??void 0,rarity:s.rarity,network:s.network,chainId:s.chainId,thumbnail:s.thumbnail,priceCredits:0,gender:null}}function Ue({listing:s,rate:c,onClose:o,onSold:b}){const{session:t}=ke(),{data:d,isError:y}=je(t),r=ae(),m=fe(),[h,i]=l.useState("confirm"),[j,I]=l.useState("Locking today’s price…"),[C,M]=l.useState(null),[n,G]=l.useState(null),f=l.useRef(null),S=Math.ceil(U(s.manaWei,c)/10);l.useEffect(()=>{let v=!1;if(!t){i("error"),M("Sign in to check out.");return}return(async()=>{try{const u=await Ne(s.tradeId);if(!u)throw new Error("not found");if(ge(u,t.address))throw new Error("You can't buy your own listing.");const p=U(s.manaWei,c);if(!Number.isFinite(p)||p<=0)throw new Error("price unavailable");const{credit:x,maxCreditedValue:$,usdCents:N}=await ve(t.identity,p,s.tradeId);if(v){A(t.identity,[x.id]).catch(()=>{});return}f.current=x.id,G({trade:u,credit:x,maxCreditedValue:$,usdCents:N,credits:Math.ceil(N/10)}),I("")}catch(u){if(v)return;console.error("[market] authorize failed",u),R(V(u)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"authorize",error_code:D(u),value_usd:Math.round(U(s.manaWei,c))/100}),i("error"),M(se(u))}})(),()=>{v=!0,f.current&&t&&(A(t.identity,[f.current]).catch(()=>{}),f.current=null)}},[]);const F=!!n&&d!=null&&d.credits<n.credits;async function P(){if(!t||!n)return;if(F){A(t.identity,[n.credit.id]).catch(()=>{}),f.current=null,m("/credits");return}i("working"),M(null);let v=!1;try{I("Confirming your purchase…");const u={trade:n.trade,buyer:t.address,signer:t.signer,credits:[n.credit],maxCreditedValue:n.maxCreditedValue};let p;if(Me())try{p=await Fe(u),await Pe(p),v=!0}catch(x){if(x instanceof Ae)v=!0;else if(x instanceof Re)p=await ee(u);else throw x}else p=await ee(u);f.current=null,R("Shop Completed Purchase",{items:[{item_id:s.itemId??null,contract_address:s.contractAddress,token_id:null,price_usd:n.usdCents/100}],value_credits:n.credits,value_usd:n.usdCents/100,purchase_type:"item",is_primary:!0,payment_type:"credits",no_crypto_step:v,transaction_hash:p??null}),r.invalidateQueries({queryKey:["usd-balance"]}),m("/success",{state:{items:[Oe(s)],txHash:p}})}catch(u){console.error("[market] buy now failed",u),A(t.identity,[n.credit.id]).catch(()=>{}),f.current=null,R(V(u)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:"submit",error_code:D(u),value_usd:n.usdCents/100}),r.invalidateQueries({queryKey:["usd-balance"]});const p=se(u);M(p),i("error"),/sold or removed/i.test(p)&&b()}}function g(){t&&n&&A(t.identity,[n.credit.id]).catch(()=>{}),f.current=null,o()}const k=h==="working";return e.jsxs("div",{className:"mkt-modal",role:"dialog","aria-modal":"true","aria-label":`Buy ${s.name}`,children:[e.jsx("div",{className:"mkt-modal__scrim",onClick:k?void 0:g,"aria-hidden":!0}),e.jsxs("div",{className:"mkt-modal__card",children:[e.jsxs("div",{className:"mkt-modal__head",children:[e.jsx("div",{className:"mkt-modal__thumb",children:s.thumbnail?e.jsx("img",{src:s.thumbnail,alt:""}):null}),e.jsxs("div",{children:[e.jsx("div",{className:"mkt-modal__name",title:s.name,children:s.name||"Item"}),e.jsx("span",{className:"chip chip--rarity",children:s.rarity})]})]}),e.jsx("div",{className:"mkt-modal__price",children:n?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mkt-modal__price-label",children:"Final price"}),e.jsxs("div",{className:"mkt-modal__price-value",children:[e.jsx(E,{className:"mkt-modal__diamond"}),J(n.credits)]}),e.jsxs("div",{className:"mkt-modal__price-sub muted",children:["Locked for this purchase · $",(n.usdCents/100).toFixed(2)]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mkt-modal__price-label",children:"Today’s price"}),e.jsxs("div",{className:"mkt-modal__price-value mkt-modal__price-value--approx",children:[e.jsx("span",{className:"mkt-modal__approx","aria-hidden":!0,children:"≈"}),e.jsx(E,{className:"mkt-modal__diamond"}),J(S)]}),e.jsx("div",{className:"mkt-modal__price-sub muted",children:j||"Locking today’s price…"})]})}),t?e.jsxs("div",{className:"mkt-modal__balance muted",children:["Your balance: ",e.jsx(E,{className:"ccy-mark"})," ",Ce(d,y)]}):null,F?e.jsxs("p",{className:"muted mkt-modal__note",children:["You’ll need a few more ",H.name," to buy this."]}):null,j&&h==="working"?e.jsx("p",{className:"muted mkt-modal__note",children:j}):null,C?e.jsx("p",{className:"error mkt-modal__note",children:C}):null,e.jsxs("div",{className:"mkt-modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:g,disabled:k,children:"Cancel"}),e.jsx("button",{className:"btn btn--purple",onClick:P,disabled:k||!n,children:k?"Buying…":F?`Get ${H.name}`:"Confirm purchase"})]})]})]})}const He=48,w=1e5,Ke={Head:["head","hat","hair","facial_hair","eyes","eyebrows","mouth","mask","helmet","tiara","top_head"],"Upper Body":["upper_body"],Handwear:["hands_wear"],"Lower Body":["lower_body"],Feet:["feet"],Accessories:["earring","eyewear"],Skins:["skin"],Dance:["dance"],Stunt:["stunt"],Greetings:["greetings"],Fun:["fun"],Poses:["poses"],Reactions:["reactions"],Horror:["horror"],Miscellaneous:["miscellaneous"]};function Ye(s){return{tradeId:s.tradeId??s.id,listingType:"primary",contractAddress:s.contractAddress,itemId:s.itemId??"",name:s.name,thumbnail:s.thumbnail,rarity:s.rarity,category:s.category,wearableCategory:s.wearableCategory??null,creator:s.creator,manaWei:s.manaWei??"0",available:1,network:s.network,chainId:s.chainId,createdAt:0}}function ts(){const[s]=ye(),c=(s.get("q")??"").trim().toLowerCase(),o=ae(),[b,t]=l.useState("wearable"),[d,y]=l.useState(null),[r,m]=l.useState([]),[h,i]=l.useState(""),[j,I]=l.useState(""),[C,M]=l.useState("newest"),[n,G]=l.useState(!1),[f,S]=l.useState(!1),[F,P]=l.useState(null);l.useEffect(()=>{if(!f)return;const a=_=>{_.key==="Escape"&&S(!1)};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[f]);const g=h&&!Number.isNaN(Number(h))?Number(h):void 0,k=j&&!Number.isNaN(Number(j))?Number(j):void 0,v=d?Ke[d]:void 0,u=(K.find(a=>a.key===C)??K[0]).server,p={category:b,rarities:r.length?r:void 0,wearableCategories:v,minPriceCredits:g,maxPriceCredits:k,search:c||void 0,sortBy:u},{items:x,total:$,isLoading:N,error:re,hasNextPage:te,isFetchingNextPage:Y,fetchNextPage:ie}=$e(["unified-listings",p],a=>we({...p,first:He,skip:a})),L=$,{data:B,isError:ne}=Le(),le=a=>B&&a.manaWei?Ee(a.manaWei,B):null,Q=l.useRef(null);l.useEffect(()=>{N||!c||Q.current===c||(Q.current=c,R("Shop Searched",{query:c,result_count:L}))},[c,N,L]);const q=l.useRef("__init__");l.useEffect(()=>{if(N)return;const a=JSON.stringify({category:b,subCategory:d,rarities:r,min:g,max:k,sort:C});if(q.current==="__init__"||q.current===a){q.current=a;return}q.current=a,R("Shop Applied Filter",{filters:{category:b,sub_category:d,rarities:r,min_price_credits:g??null,max_price_credits:k??null,sort:C},result_count:L})},[b,d,r,g,k,C,N,L]);function ce(a){t(a),y(null)}function oe(a){m(_=>_.includes(a)?_.filter(O=>O!==a):[..._,a])}function de(){t("wearable"),y(null),m([]),i(""),I("")}function ue(a){const _=x.find(O=>O.id===a.id);_&&_.source==="legacy"&&_.manaWei&&P(Ye(_))}function me(){o.invalidateQueries({queryKey:["unified-listings"]})}const T=g!=null?Math.min(g,w):0,W=k!=null?Math.min(k,w):w,he=T/w*100,pe=W/w*100;function _e(a){const _=Math.min(a,W);i(_<=0?"":String(_))}function be(a){const _=Math.max(a,T);I(_>=w?"":String(_))}return e.jsxs("div",{className:"browse browse--sidebar",children:[f?e.jsx("div",{className:"browse__scrim",onClick:()=>S(!1),"aria-hidden":!0}):null,e.jsxs("aside",{className:`browse__sidebar${f?" 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:()=>S(!1),"aria-label":"Close filters",children:"✕"})]}),e.jsx("div",{className:"sidebar__section-label",children:"Category"}),e.jsx(qe,{category:b,subCategory:d,onCategory:ce,onSub:y}),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(E,{className:"price-filter__coin"}),e.jsx("input",{type:"number",min:"0","aria-label":"Minimum price",placeholder:"0",value:h,onChange:a=>i(a.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(E,{className:"price-filter__coin"}),e.jsx("input",{type:"number",min:"0","aria-label":"Maximum price",placeholder:"0",value:j,onChange:a=>I(a.target.value)})]})]})]}),e.jsxs("div",{className:"price-filter__slider",style:{"--min-pct":`${he}%`,"--max-pct":`${pe}%`},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:w,value:T,"aria-label":"Minimum price slider",onChange:a=>_e(Number(a.target.value))}),e.jsx("input",{type:"range",min:0,max:w,value:W,"aria-label":"Maximum price slider",onChange:a=>be(Number(a.target.value))})]}),e.jsxs("div",{className:"price-filter__range",children:[e.jsxs("span",{className:"price-filter__range-val",children:[e.jsx(E,{className:"price-filter__coin"}),T.toLocaleString()]}),e.jsxs("span",{className:"price-filter__range-val",children:[e.jsx(E,{className:"price-filter__coin"}),W.toLocaleString()]})]})]}),e.jsx("div",{className:"sidebar__divider"}),e.jsxs("button",{type:"button",className:"sidebar__section-toggle","aria-expanded":n,onClick:()=>G(a=>!a),children:[e.jsx("span",{className:"sidebar__section-label",children:"Rarity"}),e.jsx("span",{className:`ico ico-chevron sidebar__section-chev${n?" is-up":""}`,"aria-hidden":!0})]}),n?e.jsx("div",{className:"rarity-filter",children:Te.map(a=>e.jsxs("label",{className:`rarity-filter__check${r.includes(a)?" is-on":""}`,children:[e.jsx("input",{type:"checkbox",checked:r.includes(a),onChange:()=>oe(a)}),e.jsx("span",{children:a})]},a))}):null,e.jsxs("div",{className:"browse__sidebar-foot",children:[e.jsx("button",{type:"button",className:"browse__clear",onClick:de,children:"Clear Filters"}),e.jsx("button",{type:"button",className:"browse__apply",onClick:()=>S(!1),children:"Apply"})]})]}),e.jsxs("div",{className:"browse__main",children:[e.jsx(Ge,{sort:C,onSort:M,total:$,loading:N,query:c,onOpenFilters:()=>S(!0)}),ne&&x.some(a=>a.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,re?e.jsx("p",{className:"error",children:"Couldn’t load items — please try again."}):null,e.jsx("div",{className:"grid",children:N?e.jsx(X,{count:15}):e.jsxs(e.Fragment,{children:[x.map(a=>a.source==="legacy"?e.jsx(Z,{item:a,mode:"market",marketPriceCredits:le(a),onBuyNow:ue},a.id):e.jsx(Z,{item:a},a.id)),Y?e.jsx(X,{count:6}):null]})}),e.jsx(Ie,{hasNextPage:te,isFetching:Y,onLoadMore:()=>ie()}),!N&&x.length===0?e.jsx("p",{className:"muted",children:"No items match your filters."}):null]}),F&&B?e.jsx(Ue,{listing:F,rate:B,onClose:()=>P(null),onSold:()=>{P(null),me()}}):null]})}export{ts as Assets};
@@ -1 +1 @@
1
- import{a as se,r as v,j as s,L as B}from"./react-iAgwec9M.js";import{q as te,s as ae,m as R,c as re,u as ne,v as ce,w as ie,t as I,C as le,e as F,x as oe,y as H,A as de,z as L,D,E as q,F as ue,G as he,H as K,I as me,J as pe,h as fe,K as _e,L as ye}from"./index-BJ_QKI7g.js";import{b as O}from"./buy-DK-hDYib.js";import{g as ge,b as be,w as xe,S as ve,G as je}from"./buy-gasless-BqKKprU3.js";import"./ethers-D-4WUfRB.js";import"./trade-encoding-ELuUTRbi.js";import"./index-CfK4LG22.js";function Ce(t){return Math.ceil(t/10)}async function Ne(t,n,o){var S;const g=[],a=[],j=[];for(const r of t)try{const h=await o(r);if(!h){a.push(r);continue}if(te(h,n)){j.push(r);continue}const _=ae((S=h.received[0])==null?void 0:S.amount);if(!Number.isFinite(_)||_<=0){a.push(r);continue}g.push({item:r,trade:h,usdCents:_,priceCredits:Ce(_)})}catch{a.push(r)}const C=g.reduce((r,h)=>r+h.priceCredits,0),b=a.length>0||j.length>0||g.some(r=>r.priceCredits!==r.item.priceCredits);return{buyable:g,unavailable:a,own:j,liveTotalCredits:C,orderChanged:b}}function Q(t){const n=t,o=(n.message??"").toLowerCase();return n.code===4001||o.includes("reject")||o.includes("denied")||o.includes("cancel")?"You cancelled the request.":o.includes("insufficient")?`You don't have enough ${H.name} — get more first.`:o.includes("no active listing")||o.includes("your own listing")?n.message:"Couldn't complete checkout — please try again."}const we=12e4;function ke(t){const n=[];return t.unavailable.length&&n.push(`${t.unavailable.length} no longer available`),t.own.length&&n.push(`${t.own.length} you can't buy (your own listing)`),`Removed ${n.join(" and ")} from your cart.`}function Le(){const t=R(e=>e.items),n=R(e=>e.remove),o=R(e=>e.clear),g=R(e=>e.setFittingOpen),{session:a}=re(),j=t.some(e=>e.category!=="emote"),{data:C}=ne({queryKey:["upsell-listings"],queryFn:()=>ye({first:40}),staleTime:6e4}),{data:b,isError:S}=ce(a),r=ie(),h=se(),[_,m]=v.useState(null),[z,p]=v.useState(null),[G,E]=v.useState(null),[N,T]=v.useState(!1),[d,w]=v.useState(null),M=v.useRef(0),P=t.reduce((e,c)=>e+c.priceCredits,0),V=d?d.liveTotalCredits:P,J=new Set(t.map(e=>e.id)),U=((C==null?void 0:C.items)??[]).filter(e=>!J.has(e.id)).slice(0,6),X=new Map(d==null?void 0:d.buyable.map(e=>[e.item.id,e])),Z=e=>e.tradeId?fe(e.tradeId):_e(e.contractAddress,e.itemId??"");function W(e){e(),w(null),E(null),p(null)}async function Y(e){if(!a||e.length===0)return;const c=e.map(i=>({...i.item,priceCredits:i.priceCredits})),y=[];let k="authorize",A=!1;try{m("Preparing your order…");const i=[];for(const l of e){const{credit:x,maxCreditedValue:f}=await ue(a.identity,l.usdCents,l.item.tradeId);y.push(x.id),i.push({trade:l.trade,credits:[x],maxCreditedValue:f})}m("Confirming your purchase…"),k="submit";let u=[];if(ge())try{u=await be({purchases:i,buyer:a.address,signer:a.signer});const x=(await Promise.allSettled(u.map(f=>xe(f)))).flatMap(f=>f.status==="rejected"?[f.reason]:[]);if(x.length&&!x.some(f=>f instanceof ve))throw x[0];A=!0}catch(l){if(!(l instanceof je))throw l;u=await O({purchases:i,buyer:a.address,signer:a.signer})}else u=await O({purchases:i,buyer:a.address,signer:a.signer});e.forEach(l=>n(l.item.id)),w(null),m("Purchased! 🎉"),L("Shop Completed Purchase",{...he(c),payment_type:"credits",no_crypto_step:A,transaction_hash:u[0]??null}),r.invalidateQueries({queryKey:["usd-balance"]}),h("/success",{state:{items:c,txHash:u[0]}})}catch(i){if(K(i)||q(i,{flow:"cart_checkout",step:k,cart_size:e.length}),L(K(i)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:k,error_code:me(i),value_usd:D(c.reduce((u,l)=>u+l.priceCredits,0)),cart_size:e.length}),y.length){try{await pe(a.identity,y)}catch(u){q(u,{flow:"cart_checkout",step:"release"})}r.invalidateQueries({queryKey:["usd-balance"]})}p(Q(i)),m(null)}}async function $(){if(!a){p("Sign in to check out.");return}p(null),E(null),T(!0),L("Shop Started Checkout",{cart_size:t.length,cart_value_credits:P,cart_value_usd:D(P),has_sufficient_credits:((b==null?void 0:b.credits)??0)>=P});try{m("Reviewing your cart…");const e=await Ne(t,a.address,Z),c=[...e.unavailable,...e.own];if(c.length&&(c.forEach(y=>n(y.id)),E(ke(e))),e.buyable.length===0){p("None of these items are available to buy right now."),w(null),m(null);return}if(e.orderChanged){w(e),M.current=Date.now(),m(null);return}await Y(e.buyable)}catch(e){q(e,{flow:"cart_checkout",step:"review",cart_size:t.length}),p(Q(e)),m(null)}finally{T(!1)}}async function ee(){if(d){if(!a){p("Sign in to check out.");return}if(Date.now()-M.current>we){w(null),E(null),await $();return}p(null),T(!0);try{await Y(d.buyable)}finally{T(!1)}}}return t.length===0?s.jsxs("div",{className:"cart cart--empty",children:[s.jsx("span",{className:"ico ico-cart cart-empty__ico","aria-hidden":!0}),s.jsx("p",{className:"cart-empty__title",children:I("cart.empty.title")}),s.jsx("p",{className:"muted",children:I("cart.empty.body")}),s.jsx(B,{className:"btn btn--purple",to:"/assets",children:I("cart.empty.cta")})]}):s.jsxs("div",{className:"cart",children:[s.jsxs("h1",{children:["Cart (",t.length,")"]}),s.jsxs("div",{className:"cart__body",children:[s.jsxs("div",{className:"cart__main",children:[s.jsx("div",{className:"cart__list",children:t.map(e=>{const c=X.get(e.id),y=c?c.priceCredits:e.priceCredits,k=!!c&&c.priceCredits!==e.priceCredits;return s.jsxs("div",{className:"cart__row",children:[s.jsx("div",{className:"cart__thumb",children:e.thumbnail?s.jsx("img",{src:e.thumbnail,alt:e.name}):null}),s.jsxs("div",{className:"cart__info",children:[s.jsx("div",{className:"cart__name",children:e.name}),e.creator?s.jsx(le,{address:e.creator,className:"cart__creator",linkToProfile:!0}):null]}),s.jsxs("div",{className:"cart__price",children:[s.jsx(F,{className:"ccy-mark"})," ",y,k?s.jsx("span",{className:"muted",style:{marginLeft:6,textDecoration:"line-through"},children:e.priceCredits}):null]}),s.jsx("button",{className:"cart__remove",onClick:()=>W(()=>n(e.id)),disabled:N,"aria-label":`Remove ${e.name}`,title:"Remove",children:s.jsx("span",{className:"ico ico-trash","aria-hidden":!0})})]},e.id)})}),s.jsxs("div",{className:"cart__utils",children:[s.jsx("button",{className:"link",onClick:()=>W(o),disabled:N,children:"Clear cart"}),null]})]}),s.jsxs("aside",{className:"cart__summary",children:[s.jsx("h2",{className:"cart__summary-title",children:"Order summary"}),s.jsxs("div",{className:"cart__total",children:[s.jsxs("div",{className:"cart__total-line",children:[s.jsx("span",{children:"Total"}),s.jsxs("strong",{children:[s.jsx(F,{className:"ccy-mark"})," ",V]})]}),a?s.jsxs("div",{className:"muted cart__balance",children:["Your balance: ",s.jsx(F,{className:"ccy-mark"})," ",oe(b,S)]}):null]}),s.jsxs("div",{className:"cart__actions",children:[s.jsx("button",{className:"btn btn--purple cart__checkout",onClick:d?ee:$,disabled:N,children:N?"Working…":d?"Confirm purchase":"Checkout"}),s.jsxs(B,{className:"btn btn--ghost",to:"/credits",children:["Get ",H.name]}),j?s.jsx("button",{className:"btn btn--ghost",onClick:()=>g(!0),disabled:N,children:"Try on outfit"}):null]}),d?s.jsx("p",{className:"muted cart__msg",children:"Prices or availability changed since you added these — review the updated total and confirm to buy."}):null,G?s.jsx("p",{className:"muted cart__msg",children:G}):null,_?s.jsx("p",{className:"muted cart__msg",children:_}):null,z?s.jsx("p",{className:"error cart__msg",children:z}):null]})]}),U.length>0?s.jsxs("section",{className:"row cart-upsell",children:[s.jsx("div",{className:"row__head",children:s.jsx("h2",{className:"row__title",children:"You might also like"})}),s.jsx("div",{className:"row__track",children:U.map(e=>s.jsx(de,{item:e},e.id))})]}):null]})}export{Le as Cart};
1
+ import{a as se,r as v,j as s,L as B}from"./react-iAgwec9M.js";import{q as te,s as ae,m as R,c as re,u as ne,v as ce,w as ie,t as I,C as le,e as F,x as oe,y as H,A as de,z as L,D,E as q,F as ue,G as he,H as K,I as me,J as pe,h as fe,K as _e,L as ye}from"./index-C1zw_jvz.js";import{b as O}from"./buy-DEy5oWx-.js";import{g as ge,b as be,w as xe,S as ve,G as je}from"./buy-gasless-VIo89iNM.js";import"./ethers-D-4WUfRB.js";import"./trade-encoding-gNFeXeFL.js";import"./index-BF4WrGCQ.js";function Ce(t){return Math.ceil(t/10)}async function Ne(t,n,o){var S;const g=[],a=[],j=[];for(const r of t)try{const h=await o(r);if(!h){a.push(r);continue}if(te(h,n)){j.push(r);continue}const _=ae((S=h.received[0])==null?void 0:S.amount);if(!Number.isFinite(_)||_<=0){a.push(r);continue}g.push({item:r,trade:h,usdCents:_,priceCredits:Ce(_)})}catch{a.push(r)}const C=g.reduce((r,h)=>r+h.priceCredits,0),b=a.length>0||j.length>0||g.some(r=>r.priceCredits!==r.item.priceCredits);return{buyable:g,unavailable:a,own:j,liveTotalCredits:C,orderChanged:b}}function Q(t){const n=t,o=(n.message??"").toLowerCase();return n.code===4001||o.includes("reject")||o.includes("denied")||o.includes("cancel")?"You cancelled the request.":o.includes("insufficient")?`You don't have enough ${H.name} — get more first.`:o.includes("no active listing")||o.includes("your own listing")?n.message:"Couldn't complete checkout — please try again."}const we=12e4;function ke(t){const n=[];return t.unavailable.length&&n.push(`${t.unavailable.length} no longer available`),t.own.length&&n.push(`${t.own.length} you can't buy (your own listing)`),`Removed ${n.join(" and ")} from your cart.`}function Le(){const t=R(e=>e.items),n=R(e=>e.remove),o=R(e=>e.clear),g=R(e=>e.setFittingOpen),{session:a}=re(),j=t.some(e=>e.category!=="emote"),{data:C}=ne({queryKey:["upsell-listings"],queryFn:()=>ye({first:40}),staleTime:6e4}),{data:b,isError:S}=ce(a),r=ie(),h=se(),[_,m]=v.useState(null),[z,p]=v.useState(null),[G,E]=v.useState(null),[N,T]=v.useState(!1),[d,w]=v.useState(null),M=v.useRef(0),P=t.reduce((e,c)=>e+c.priceCredits,0),V=d?d.liveTotalCredits:P,J=new Set(t.map(e=>e.id)),U=((C==null?void 0:C.items)??[]).filter(e=>!J.has(e.id)).slice(0,6),X=new Map(d==null?void 0:d.buyable.map(e=>[e.item.id,e])),Z=e=>e.tradeId?fe(e.tradeId):_e(e.contractAddress,e.itemId??"");function W(e){e(),w(null),E(null),p(null)}async function Y(e){if(!a||e.length===0)return;const c=e.map(i=>({...i.item,priceCredits:i.priceCredits})),y=[];let k="authorize",A=!1;try{m("Preparing your order…");const i=[];for(const l of e){const{credit:x,maxCreditedValue:f}=await ue(a.identity,l.usdCents,l.item.tradeId);y.push(x.id),i.push({trade:l.trade,credits:[x],maxCreditedValue:f})}m("Confirming your purchase…"),k="submit";let u=[];if(ge())try{u=await be({purchases:i,buyer:a.address,signer:a.signer});const x=(await Promise.allSettled(u.map(f=>xe(f)))).flatMap(f=>f.status==="rejected"?[f.reason]:[]);if(x.length&&!x.some(f=>f instanceof ve))throw x[0];A=!0}catch(l){if(!(l instanceof je))throw l;u=await O({purchases:i,buyer:a.address,signer:a.signer})}else u=await O({purchases:i,buyer:a.address,signer:a.signer});e.forEach(l=>n(l.item.id)),w(null),m("Purchased! 🎉"),L("Shop Completed Purchase",{...he(c),payment_type:"credits",no_crypto_step:A,transaction_hash:u[0]??null}),r.invalidateQueries({queryKey:["usd-balance"]}),h("/success",{state:{items:c,txHash:u[0]}})}catch(i){if(K(i)||q(i,{flow:"cart_checkout",step:k,cart_size:e.length}),L(K(i)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:k,error_code:me(i),value_usd:D(c.reduce((u,l)=>u+l.priceCredits,0)),cart_size:e.length}),y.length){try{await pe(a.identity,y)}catch(u){q(u,{flow:"cart_checkout",step:"release"})}r.invalidateQueries({queryKey:["usd-balance"]})}p(Q(i)),m(null)}}async function $(){if(!a){p("Sign in to check out.");return}p(null),E(null),T(!0),L("Shop Started Checkout",{cart_size:t.length,cart_value_credits:P,cart_value_usd:D(P),has_sufficient_credits:((b==null?void 0:b.credits)??0)>=P});try{m("Reviewing your cart…");const e=await Ne(t,a.address,Z),c=[...e.unavailable,...e.own];if(c.length&&(c.forEach(y=>n(y.id)),E(ke(e))),e.buyable.length===0){p("None of these items are available to buy right now."),w(null),m(null);return}if(e.orderChanged){w(e),M.current=Date.now(),m(null);return}await Y(e.buyable)}catch(e){q(e,{flow:"cart_checkout",step:"review",cart_size:t.length}),p(Q(e)),m(null)}finally{T(!1)}}async function ee(){if(d){if(!a){p("Sign in to check out.");return}if(Date.now()-M.current>we){w(null),E(null),await $();return}p(null),T(!0);try{await Y(d.buyable)}finally{T(!1)}}}return t.length===0?s.jsxs("div",{className:"cart cart--empty",children:[s.jsx("span",{className:"ico ico-cart cart-empty__ico","aria-hidden":!0}),s.jsx("p",{className:"cart-empty__title",children:I("cart.empty.title")}),s.jsx("p",{className:"muted",children:I("cart.empty.body")}),s.jsx(B,{className:"btn btn--purple",to:"/assets",children:I("cart.empty.cta")})]}):s.jsxs("div",{className:"cart",children:[s.jsxs("h1",{children:["Cart (",t.length,")"]}),s.jsxs("div",{className:"cart__body",children:[s.jsxs("div",{className:"cart__main",children:[s.jsx("div",{className:"cart__list",children:t.map(e=>{const c=X.get(e.id),y=c?c.priceCredits:e.priceCredits,k=!!c&&c.priceCredits!==e.priceCredits;return s.jsxs("div",{className:"cart__row",children:[s.jsx("div",{className:"cart__thumb",children:e.thumbnail?s.jsx("img",{src:e.thumbnail,alt:e.name}):null}),s.jsxs("div",{className:"cart__info",children:[s.jsx("div",{className:"cart__name",children:e.name}),e.creator?s.jsx(le,{address:e.creator,className:"cart__creator",linkToProfile:!0}):null]}),s.jsxs("div",{className:"cart__price",children:[s.jsx(F,{className:"ccy-mark"})," ",y,k?s.jsx("span",{className:"muted",style:{marginLeft:6,textDecoration:"line-through"},children:e.priceCredits}):null]}),s.jsx("button",{className:"cart__remove",onClick:()=>W(()=>n(e.id)),disabled:N,"aria-label":`Remove ${e.name}`,title:"Remove",children:s.jsx("span",{className:"ico ico-trash","aria-hidden":!0})})]},e.id)})}),s.jsxs("div",{className:"cart__utils",children:[s.jsx("button",{className:"link",onClick:()=>W(o),disabled:N,children:"Clear cart"}),null]})]}),s.jsxs("aside",{className:"cart__summary",children:[s.jsx("h2",{className:"cart__summary-title",children:"Order summary"}),s.jsxs("div",{className:"cart__total",children:[s.jsxs("div",{className:"cart__total-line",children:[s.jsx("span",{children:"Total"}),s.jsxs("strong",{children:[s.jsx(F,{className:"ccy-mark"})," ",V]})]}),a?s.jsxs("div",{className:"muted cart__balance",children:["Your balance: ",s.jsx(F,{className:"ccy-mark"})," ",oe(b,S)]}):null]}),s.jsxs("div",{className:"cart__actions",children:[s.jsx("button",{className:"btn btn--purple cart__checkout",onClick:d?ee:$,disabled:N,children:N?"Working…":d?"Confirm purchase":"Checkout"}),s.jsxs(B,{className:"btn btn--ghost",to:"/credits",children:["Get ",H.name]}),j?s.jsx("button",{className:"btn btn--ghost",onClick:()=>g(!0),disabled:N,children:"Try on outfit"}):null]}),d?s.jsx("p",{className:"muted cart__msg",children:"Prices or availability changed since you added these — review the updated total and confirm to buy."}):null,G?s.jsx("p",{className:"muted cart__msg",children:G}):null,_?s.jsx("p",{className:"muted cart__msg",children:_}):null,z?s.jsx("p",{className:"error cart__msg",children:z}):null]})]}),U.length>0?s.jsxs("section",{className:"row cart-upsell",children:[s.jsx("div",{className:"row__head",children:s.jsx("h2",{className:"row__title",children:"You might also like"})}),s.jsx("div",{className:"row__track",children:U.map(e=>s.jsx(de,{item:e},e.id))})]}):null]})}export{Le as Cart};
@@ -1,4 +1,4 @@
1
- import{T as N,U,V as w,X as z,Y as o,Z as E,$ as c,a0 as I,a1 as g,a2 as D,a3 as M}from"./index-BJ_QKI7g.js";import{r as F,j as v}from"./react-iAgwec9M.js";function K(r){return N("MuiCircularProgress",r)}U("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);const V=["className","color","disableShrink","size","style","thickness","value","variant"];let l=r=>r,P,S,b,$;const t=44,W=M(P||(P=l`
1
+ import{T as N,U,V as w,X as z,Y as o,Z as E,$ as c,a0 as I,a1 as g,a2 as D,a3 as M}from"./index-C1zw_jvz.js";import{r as F,j as v}from"./react-iAgwec9M.js";function K(r){return N("MuiCircularProgress",r)}U("MuiCircularProgress",["root","determinate","indeterminate","colorPrimary","colorSecondary","svg","circle","circleDeterminate","circleIndeterminate","circleDisableShrink"]);const V=["className","color","disableShrink","size","style","thickness","value","variant"];let l=r=>r,P,S,b,$;const t=44,W=M(P||(P=l`
2
2
  0% {
3
3
  transform: rotate(0deg);
4
4
  }
@@ -1 +1 @@
1
- import{u as j,a as _,j as e}from"./react-iAgwec9M.js";import{u as N,t as u,C as f,A as b,f as C,a as A}from"./index-BJ_QKI7g.js";import{A as v}from"./collection-BGWAmfIC.js";import{S as h}from"./SkeletonCards-BhzQlTiQ.js";import{L as y}from"./LoadMore-8Dx5lULo.js";import{u as L}from"./useInfiniteGrid-XR5F3f0o.js";import"./ethers-D-4WUfRB.js";const P=48;function B(){var d;const{contractAddress:a}=j(),p=_(),{items:t,total:o,isLoading:l,error:r,hasNextPage:g,isFetchingNextPage:n,fetchNextPage:x}=L(["collection-page",a],c=>C(a,{first:P,skip:c}),{enabled:!!a}),{data:s}=N({queryKey:["collection-meta",a],queryFn:()=>A(a),enabled:!!a,staleTime:5*6e4}),i=(s==null?void 0:s.name)||u("collection.fallbackTitle"),m=(s==null?void 0:s.creator)||((d=t[0])==null?void 0:d.creator);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:()=>p("/assets"),children:u("collection.breadcrumb")}),e.jsx("span",{className:"collection-page__crumb-sep",children:"/"}),e.jsx("span",{className:"collection-page__crumb-current",children:i})]}),e.jsxs("header",{className:"collection-page__head",children:[e.jsx("h1",{className:"collection-page__title",children:i}),m?e.jsx(f,{address:m,className:"collection-page__creator"}):null,e.jsx("span",{className:"muted collection-page__count",children:l?"…":`${o.toLocaleString()} item${o===1?"":"s"}`})]}),!l&&t.length>0?e.jsx(v,{items:t,source:"collection"}):null,r?e.jsx("p",{className:"error",children:"Couldn’t load this collection — please try again."}):null,e.jsx("div",{className:"grid",children:l?e.jsx(h,{count:12}):e.jsxs(e.Fragment,{children:[t.map(c=>e.jsx(b,{item:c},c.id)),n?e.jsx(h,{count:6}):null]})}),e.jsx(y,{hasNextPage:g,isFetching:n,onLoadMore:()=>x()}),!l&&!r&&t.length===0?e.jsx("p",{className:"muted",children:"This collection has no items to show."}):null]})}export{B as Collection,B as default};
1
+ import{u as j,a as _,j as e}from"./react-iAgwec9M.js";import{u as N,t as u,C as f,A as b,f as C,a as A}from"./index-C1zw_jvz.js";import{A as v}from"./collection-OLKHFYz-.js";import{S as h}from"./SkeletonCards-BhzQlTiQ.js";import{L as y}from"./LoadMore-8Dx5lULo.js";import{u as L}from"./useInfiniteGrid-BA1C5BmN.js";import"./ethers-D-4WUfRB.js";const P=48;function B(){var d;const{contractAddress:a}=j(),p=_(),{items:t,total:o,isLoading:l,error:r,hasNextPage:g,isFetchingNextPage:n,fetchNextPage:x}=L(["collection-page",a],c=>C(a,{first:P,skip:c}),{enabled:!!a}),{data:s}=N({queryKey:["collection-meta",a],queryFn:()=>A(a),enabled:!!a,staleTime:5*6e4}),i=(s==null?void 0:s.name)||u("collection.fallbackTitle"),m=(s==null?void 0:s.creator)||((d=t[0])==null?void 0:d.creator);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:()=>p("/assets"),children:u("collection.breadcrumb")}),e.jsx("span",{className:"collection-page__crumb-sep",children:"/"}),e.jsx("span",{className:"collection-page__crumb-current",children:i})]}),e.jsxs("header",{className:"collection-page__head",children:[e.jsx("h1",{className:"collection-page__title",children:i}),m?e.jsx(f,{address:m,className:"collection-page__creator"}):null,e.jsx("span",{className:"muted collection-page__count",children:l?"…":`${o.toLocaleString()} item${o===1?"":"s"}`})]}),!l&&t.length>0?e.jsx(v,{items:t,source:"collection"}):null,r?e.jsx("p",{className:"error",children:"Couldn’t load this collection — please try again."}):null,e.jsx("div",{className:"grid",children:l?e.jsx(h,{count:12}):e.jsxs(e.Fragment,{children:[t.map(c=>e.jsx(b,{item:c},c.id)),n?e.jsx(h,{count:6}):null]})}),e.jsx(y,{hasNextPage:g,isFetching:n,onLoadMore:()=>x()}),!l&&!r&&t.length===0?e.jsx("p",{className:"muted",children:"This collection has no items to show."}):null]})}export{B as Collection,B as default};
@@ -1 +1 @@
1
- import{j as e,u as g,a as p}from"./react-iAgwec9M.js";import{k as i,C as h,A as x,l as j}from"./index-BJ_QKI7g.js";import{A as f}from"./collection-BGWAmfIC.js";import{S as m}from"./SkeletonCards-BhzQlTiQ.js";import{L as N}from"./LoadMore-8Dx5lULo.js";import{u as b}from"./useInfiniteGrid-XR5F3f0o.js";import"./ethers-D-4WUfRB.js";function _({address:s,className:r=""}){const o=i(t=>t.followed.includes(s.toLowerCase())),a=i(t=>t.toggle);return s?e.jsx("button",{type:"button",className:`btn btn--sm ${o?"btn--ghost":"btn--outline"} ${r}`.trim(),"aria-pressed":o,title:o?"Unfollow creator":"Follow creator",onClick:()=>a(s),children:o?"Following":"Follow"}):null}const C=48;function S(){const{address:s}=g(),r=p(),{items:o,total:a,isLoading:t,error:n,hasNextPage:u,isFetchingNextPage:c,fetchNextPage:d}=b(["creator-page",s],l=>j(s,{first:C,skip:l}),{enabled:!!s});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:()=>r("/assets"),children:"Collectibles"}),e.jsx("span",{className:"collection-page__crumb-sep",children:"/"}),e.jsx("span",{className:"collection-page__crumb-current",children:"Creator"})]}),e.jsxs("header",{className:"collection-page__head",children:[s?e.jsx(h,{address:s,className:"collection-page__title-creator"}):null,s?e.jsx(_,{address:s}):null,e.jsx("span",{className:"muted collection-page__count",children:t?"…":`${a.toLocaleString()} item${a===1?"":"s"}`})]}),!t&&o.length>0?e.jsx(f,{items:o,source:"creator"}):null,n?e.jsx("p",{className:"error",children:"Couldn’t load this creator — please try again."}):null,e.jsx("div",{className:"grid",children:t?e.jsx(m,{count:12}):e.jsxs(e.Fragment,{children:[o.map(l=>e.jsx(x,{item:l},l.id)),c?e.jsx(m,{count:6}):null]})}),e.jsx(N,{hasNextPage:u,isFetching:c,onLoadMore:()=>d()}),!t&&!n&&o.length===0?e.jsx("p",{className:"muted",children:"This creator has no items to show yet."}):null]})}export{S as Creator,S as default};
1
+ import{j as e,u as g,a as p}from"./react-iAgwec9M.js";import{k as i,C as h,A as x,l as j}from"./index-C1zw_jvz.js";import{A as f}from"./collection-OLKHFYz-.js";import{S as m}from"./SkeletonCards-BhzQlTiQ.js";import{L as N}from"./LoadMore-8Dx5lULo.js";import{u as b}from"./useInfiniteGrid-BA1C5BmN.js";import"./ethers-D-4WUfRB.js";function _({address:s,className:r=""}){const o=i(t=>t.followed.includes(s.toLowerCase())),a=i(t=>t.toggle);return s?e.jsx("button",{type:"button",className:`btn btn--sm ${o?"btn--ghost":"btn--outline"} ${r}`.trim(),"aria-pressed":o,title:o?"Unfollow creator":"Follow creator",onClick:()=>a(s),children:o?"Following":"Follow"}):null}const C=48;function S(){const{address:s}=g(),r=p(),{items:o,total:a,isLoading:t,error:n,hasNextPage:u,isFetchingNextPage:c,fetchNextPage:d}=b(["creator-page",s],l=>j(s,{first:C,skip:l}),{enabled:!!s});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:()=>r("/assets"),children:"Collectibles"}),e.jsx("span",{className:"collection-page__crumb-sep",children:"/"}),e.jsx("span",{className:"collection-page__crumb-current",children:"Creator"})]}),e.jsxs("header",{className:"collection-page__head",children:[s?e.jsx(h,{address:s,className:"collection-page__title-creator"}):null,s?e.jsx(_,{address:s}):null,e.jsx("span",{className:"muted collection-page__count",children:t?"…":`${a.toLocaleString()} item${a===1?"":"s"}`})]}),!t&&o.length>0?e.jsx(f,{items:o,source:"creator"}):null,n?e.jsx("p",{className:"error",children:"Couldn’t load this creator — please try again."}):null,e.jsx("div",{className:"grid",children:t?e.jsx(m,{count:12}):e.jsxs(e.Fragment,{children:[o.map(l=>e.jsx(x,{item:l},l.id)),c?e.jsx(m,{count:6}):null]})}),e.jsx(N,{hasNextPage:u,isFetching:c,onLoadMore:()=>d()}),!t&&!n&&o.length===0?e.jsx("p",{className:"muted",children:"This creator has no items to show yet."}):null]})}export{S as Creator,S as default};
@@ -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-Dhy5L90S.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-a9iM5Ppc.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-ZaFH8iXi.js";import{g as T,a as W,f as b,b as _,c as v}from"./index-DwXY_0me.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 H,d as Q,r as l,j as e}from"./react-iAgwec9M.js";import{ah as T,i as j,ai as W,c as J,w as X,z as _,y as m,E as G,I as M,e as S,aj as D}from"./index-C1zw_jvz.js";import{C as A}from"./CircularProgress-CFx6Tc-u.js";import"./ethers-D-4WUfRB.js";function F(){return j.creditsServerUrl}async function Z(s,t){const r=await T(`${F()}/credits/checkout`,{method:"POST",identity:t,metadata:{},headers:{"Content-Type":"application/json"},body:JSON.stringify({packId:s})});if(!r.ok)throw new Error(`checkout ${r.status}: ${await r.text()}`);const{orderId:a,url:n}=await r.json();return{orderId:a,url:n,mock:!1}}async function ee(s,t,r={}){const{intervalMs:a=1500,timeoutMs:n=6e4,signal:o}=r,h=Date.now()+n;for(;;){if(o!=null&&o.aborted)throw new DOMException("Aborted","AbortError");const u=await te(s,t,o);if(u.status!=="processing")return u;if(Date.now()>h)return{status:"pending"};await se(a,o)}}async function te(s,t,r){const a=await T(`${F()}/credits/orders/${s}`,{method:"GET",identity:t,metadata:{},signal:r});if(!a.ok)throw new Error(`order status ${a.status}`);return a.json()}function se(s,t){return new Promise((r,a)=>{const n=setTimeout(r,s);t==null||t.addEventListener("abort",()=>{clearTimeout(n),a(new DOMException("Aborted","AbortError"))})})}const re=.1,U=[{id:"pack_5",usd:5,credits:x(5)},{id:"pack_10",usd:10,credits:x(10)},{id:"pack_25",usd:25,credits:x(25),bestValue:!0},{id:"pack_50",usd:50,credits:x(50)}];function x(s){return Math.round(s/re)}function O(s){return U.find(t=>t.id===s)}const b="mock_cs_",ae=new Set([80002,11155111,1337,31337]);function E(){const s=!j.stripePublishableKey;if(s&&!ae.has(j.chainId))throw new Error(`Stripe publishable key is missing on chainId=${j.chainId}, which is not a recognized test network. Refusing to fall back to mock payments in a real-money environment — configure STRIPE_PUBLISHABLE_KEY.`);return s}async function ne(s,t){const r=O(s);if(!r)throw new Error("Unknown pack");if(E())return ie(r);if(!(t!=null&&t.identity))throw new Error("Sign in to get credits.");return Z(s,t.identity)}async function ce(s,t={}){const{intervalMs:r,timeoutMs:a,signal:n,identity:o}=t;if(E()||s.startsWith(b))return oe(s,t);if(!o)throw new Error("Sign in to get credits.");return ee(s,o,{intervalMs:r,timeoutMs:a,signal:n})}function ie(s){const t=`${b}${s.id}_${Date.now()}`;return L(400).then(()=>({orderId:t,clientSecret:`${b}${s.id}`,mock:!0}))}async function oe(s,t={}){await L(t.intervalMs??900);const r=s.replace(b,"").replace(/_\d+$/,""),a=O(r),n=(a==null?void 0:a.credits)??0;if(t.address&&a)try{const o=await W(t.address,Math.round(a.usd*100));return{status:"credited",creditsGranted:n,newBalance:o.credits}}catch(o){return{status:"failed",error:o.message}}return{status:"credited",creditsGranted:n,newBalance:n}}function L(s,t){return new Promise((r,a)=>{setTimeout(r,s)})}const v=E()?"mock":"stripe";function B(s){const t=s;if((t==null?void 0:t.name)==="AbortError")return"You cancelled the request.";const r=((t==null?void 0:t.message)??"").toLowerCase();return r.includes("sign in")?`Sign in to get ${m.name}.`:r.includes("timed out")?`This is taking longer than usual — your ${m.name} will appear shortly.`:"Couldn't complete your purchase — please try again."}function ge(){const s=H(),{session:t,signIn:r}=J(),a=X(),[n,o]=Q(),[h,u]=l.useState("select"),[c,P]=l.useState(null),[y,$]=l.useState(null),[Y,R]=l.useState(null),[K,g]=l.useState(null),[V,k]=l.useState(!1),w=l.useRef(null);l.useEffect(()=>()=>{var i;return(i=w.current)==null?void 0:i.abort()},[]);const I=l.useCallback(()=>{o(i=>{const d=new URLSearchParams(i);return d.delete("order"),d.delete("canceled"),d},{replace:!0})},[o]),N=l.useCallback(async i=>{u("processing");const d=new AbortController;w.current=d;try{const p=await ce(i,{signal:d.signal,address:t==null?void 0:t.address,identity:t==null?void 0:t.identity});p.status==="credited"?(R(p.creditsGranted??(c==null?void 0:c.credits)??0),u("success"),_("Shop Completed Buy Credits",{order_id:i,pack_usd:(c==null?void 0:c.usd)??null,credits:p.creditsGranted??(c==null?void 0:c.credits)??0,provider:v}),a.invalidateQueries({queryKey:["usd-balance"]})):p.status==="pending"?(_("Shop Buy Credits Pending",{step:"grant",pack_usd:(c==null?void 0:c.usd)??null}),a.invalidateQueries({queryKey:["usd-balance"]}),u("pending")):(_("Shop Buy Credits Failed",{step:"grant",error_code:"grant_failed",pack_usd:(c==null?void 0:c.usd)??null}),g(p.error??`Couldn't add your ${m.name} — please try again.`),u("error"))}catch(p){G(p,{flow:"get_credits",step:"grant",order_id:i}),_("Shop Buy Credits Failed",{step:"grant",error_code:M(p),pack_usd:(c==null?void 0:c.usd)??null}),g(B(p)),u("error")}},[c,t,a]),q=l.useCallback(async i=>{if(!t){r();return}g(null),k(!1),P(i),u("paying"),_("Shop Started Buy Credits",{pack_usd:i.usd,credits:i.credits,provider:v});try{const d=await ne(i.id,{address:t.address,identity:t.identity});if(d.mock)$(d);else if(d.url)window.location.href=d.url;else throw new Error("Checkout did not return a redirect url")}catch(d){G(d,{flow:"get_credits",step:"checkout",provider:v}),_("Shop Buy Credits Failed",{step:"checkout",error_code:M(d),pack_usd:i.usd}),g(B(d)),u("error")}},[t,r]),z=l.useCallback(()=>{y&&N(y.orderId)},[y,N]),C=l.useRef(!1);l.useEffect(()=>{if(C.current)return;const i=n.get("order");if(n.get("canceled")!=null){C.current=!0,I(),k(!0),u("select");return}i&&(u("processing"),t&&(C.current=!0,I(),N(i)))},[n,t]);function f(){var i;(i=w.current)==null||i.abort(),u("select"),P(null),$(null),R(null),g(null),k(!1)}return e.jsxs("div",{className:"getcredits",children:[e.jsxs("header",{className:"getcredits__head",children:[e.jsxs("h1",{className:"getcredits__title",children:["Get ",m.name]}),e.jsxs("p",{className:"muted",children:["Add ",m.name," to your account to shop. Pay with any card."]})]}),t?e.jsxs(e.Fragment,{children:[h==="select"&&e.jsxs(e.Fragment,{children:[V&&e.jsx("p",{className:"getcredits__note muted",role:"status",children:"Payment canceled — no charge was made. Pick a pack whenever you’re ready."}),e.jsx(de,{onSelect:q})]}),h==="paying"&&c&&e.jsx(le,{pack:c,checkout:y,onPaid:z,onCancel:f}),h==="processing"&&e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsx(A,{size:40}),e.jsxs("p",{className:"getcredits__status-title",children:["Adding your ",m.name,"…"]}),e.jsx("p",{className:"muted",children:"Payment received. Just a moment while we top up your balance."})]}),h==="success"&&e.jsxs("div",{className:"getcredits__status getcredits__status--ok",role:"status","aria-live":"polite",children:[e.jsx("div",{className:"getcredits__confetti","aria-hidden":!0,children:"🎉"}),e.jsx("p",{className:"getcredits__status-title",children:"You’re all set!"}),e.jsxs("p",{className:"muted",children:[e.jsxs("strong",{children:[e.jsx(S,{className:"ccy-mark"})," ",Y]})," ",m.name," added to your account."]}),e.jsxs("div",{className:"getcredits__status-actions",children:[e.jsx("button",{className:"btn",onClick:()=>s("/cart"),children:"Back to cart"}),e.jsxs("button",{className:"btn btn--ghost",onClick:f,children:["Get more ",m.name]})]})]}),h==="pending"&&e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsxs("p",{className:"getcredits__status-title",children:["Your ",m.name," are on the way"]}),e.jsx("p",{className:"muted",children:"Your payment went through. It’s taking a little longer than usual to confirm — your balance will update automatically as soon as it lands, no need to pay again."}),e.jsxs("div",{className:"getcredits__status-actions",children:[e.jsx("button",{className:"btn",onClick:()=>s("/cart"),children:"Back to cart"}),e.jsx("button",{className:"btn btn--ghost",onClick:f,children:"Done"})]})]}),h==="error"&&e.jsxs("div",{className:"getcredits__status getcredits__status--err",role:"alert",children:[e.jsx("p",{className:"getcredits__status-title",children:"Something went wrong"}),e.jsx("p",{className:"error",children:K}),e.jsx("div",{className:"getcredits__status-actions",children:e.jsx("button",{className:"btn",onClick:f,children:"Try again"})})]})]}):e.jsxs("div",{className:"getcredits__status",role:"status",children:[e.jsxs("p",{className:"getcredits__status-title",children:["Sign in to get ",m.name]}),e.jsxs("p",{className:"muted",children:["Connect your account to buy ",m.name," and start shopping."]}),e.jsx("div",{className:"getcredits__status-actions",children:e.jsx("button",{className:"btn btn--purple",onClick:r,children:"Sign in"})})]})]})}function de({onSelect:s}){return e.jsx("div",{className:"packs",children:U.map(t=>e.jsxs("button",{type:"button",className:`pack${t.bestValue?" pack--best":""}`,onClick:()=>s(t),"aria-label":`Get ${D(t.credits)} for $${t.usd}`,children:[t.bestValue&&e.jsx("span",{className:"pack__ribbon",children:"Best value"}),e.jsxs("span",{className:"pack__credits",children:[e.jsx(S,{className:"pack__credits-ico"}),t.credits]}),e.jsx("span",{className:"pack__label",children:m.name}),e.jsxs("span",{className:"pack__price",children:["$",t.usd]}),e.jsxs("span",{className:"pack__cta",children:["Get ",m.name]})]},t.id))})}function le({pack:s,checkout:t,onPaid:r,onCancel:a}){return e.jsxs("div",{className:"pay",children:[e.jsxs("div",{className:"pay__summary",children:[e.jsx("button",{className:"link",onClick:a,children:"← Choose a different pack"}),e.jsxs("div",{className:"pay__summary-row",children:[e.jsx("span",{children:"You’ll get"}),e.jsxs("strong",{children:[e.jsx(S,{className:"ccy-mark"})," ",D(s.credits)]})]}),e.jsxs("div",{className:"pay__summary-row pay__summary-row--total",children:[e.jsx("span",{children:"You pay"}),e.jsxs("strong",{children:["$",s.usd]})]})]}),e.jsx("div",{className:"pay__form",children:t!=null&&t.mock?e.jsx(ue,{onPaid:r,amountUsd:s.usd}):e.jsxs("div",{className:"getcredits__status",role:"status","aria-live":"polite",children:[e.jsx(A,{size:32}),e.jsx("p",{className:"muted",children:"Getting the payment form ready…"})]})})]})}function ue({onPaid:s,amountUsd:t}){const[r,a]=l.useState("4242 4242 4242 4242"),[n,o]=l.useState(!1);function h(){o(!0),setTimeout(()=>s(),700)}return e.jsxs("div",{className:"card-form","aria-label":"Payment details",children:[e.jsx("p",{className:"muted small card-form__note",children:"Demo mode — no real charge is made."}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:"Card number"}),e.jsx("input",{value:r,onChange:u=>a(u.target.value),disabled:n,inputMode:"numeric"})]}),e.jsxs("div",{className:"card-form__row",children:[e.jsxs("label",{className:"field",children:[e.jsx("span",{children:"Expiry"}),e.jsx("input",{defaultValue:"12 / 34",disabled:n})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{children:"CVC"}),e.jsx("input",{defaultValue:"123",disabled:n,inputMode:"numeric"})]})]}),e.jsx("button",{className:"btn btn--purple card-form__pay",onClick:h,disabled:n,children:n?"Processing…":`Pay $${t}`})]})}export{ge as GetCredits,ge 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-SeURPzoq.js";import{d as g,r as v}from"./index-a9iM5Ppc.js";import{C as c}from"./ConstantsUtil-rB_9qX5U.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-Dhy5L90S.js";import{au as y}from"./NetworkUtil-Cm_KFCNa.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-BzBBEm1y.js";import{d as g,r as v}from"./index-DwXY_0me.js";import{C as c}from"./ConstantsUtil-rB_9qX5U.js";import{R as $,O as u}from"./W3MFrameProviderSingleton-ZaFH8iXi.js";import{au as y}from"./NetworkUtil-Cm_KFCNa.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 p,j as e,L as A}from"./react-iAgwec9M.js";import{z as Q,E as L,y as S,e as v,c as R,w as F,u as K,o as P}from"./index-BJ_QKI7g.js";import{i as W,R as Y,f as G}from"./import-Cicp42pB.js";import{s as O}from"./wallet-kind-g2ENkqJ_.js";import"./ethers-D-4WUfRB.js";import"./buy-DK-hDYib.js";import"./trade-encoding-ELuUTRbi.js";import"./index-CfK4LG22.js";import"./mana-rate-nE0eZdyC.js";function z({queue:n,session:I,onClose:g,onDone:h}){const x=E(),c=O(I.providerType),[d,j]=p.useState(()=>n.map(()=>"pending")),[b,C]=p.useState("running"),w=p.useRef(!1);p.useEffect(()=>{if(w.current)return;w.current=!0;let t=!1;return(async()=>{for(let s=0;s<n.length;s++){if(t)return;j(r=>r.map((m,o)=>o===s?"active":m));try{await W(n[s].item,n[s].priceCredits,I),Q("Shop Migrated Listing",{item_id:n[s].item.itemId??n[s].item.oldTradeId??null,contract_address:n[s].item.contractAddress,new_price_credits:n[s].priceCredits,new_price_usd:n[s].priceCredits/10}),t||j(r=>r.map((m,o)=>o===s?"done":m))}catch(r){if(r instanceof Y)L(r,{flow:"import_listing",step:"relist",itemId:n[s].item.itemId??n[s].item.oldTradeId}),t||j(m=>m.map((o,y)=>y===s?"unlisted":o));else{const m=r,o=m.code===4001||/reject|denied|cancel/i.test(m.message??"");o||L(r,{flow:"import_listing",itemId:n[s].item.itemId??n[s].item.oldTradeId}),t||j(y=>y.map((T,a)=>a===s?o?"skipped":"failed":T))}}}t||C("finished")})(),()=>{t=!0}},[]);const u=d.filter(t=>t==="done").length,N=d.findIndex(t=>t==="active"),_=Math.round(d.filter(t=>t!=="pending"&&t!=="active").length/n.length*100);function f(){h(),g()}if(b==="finished"){const t=d.filter(r=>r==="skipped"||r==="failed").length,s=d.filter(r=>r==="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:u>0?"You're in the Shop! 🎉":"Nothing listed"}),e.jsxs("p",{className:"muted",style:{margin:0},children:[u>0?`${u} ${u===1?"item is":"items are"} now for sale with ${S.name}.`:"No items were listed.",t>0?` ${t} skipped — you can try those again anytime.`:"",s>0?` ${s} ${s===1?"item was":"items were"} taken off the old marketplace but couldn't be re-listed — re-list ${s===1?"it":"them"} from My Assets.`:""]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:f,children:"Done"}),s>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{h(),g(),x("/my-assets")},children:"Go to My Assets"}):u>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{h(),g(),x("/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."," ",N>=0?`${N+1} of ${n.length}`:""]}),e.jsx("div",{className:"migrate__progress",children:e.jsx("div",{className:"migrate__bar",style:{width:`${_}%`}})}),e.jsx("ul",{className:"migrate__list",children:n.map((t,s)=>e.jsxs("li",{className:`migrate__row migrate__row--${d[s]}`,children:[e.jsx("span",{className:"migrate__thumb",children:t.item.thumbnail?e.jsx("img",{src:t.item.thumbnail,alt:""}):null}),e.jsx("span",{className:"migrate__name",title:t.item.name,children:t.item.name||"Item"}),e.jsxs("span",{className:"migrate__price",children:[e.jsx(v,{className:"ccy-mark"})," ",t.priceCredits.toLocaleString()]}),e.jsx("span",{className:"migrate__status",children:d[s]==="active"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner migrate__spin","aria-hidden":!0})," ",c?"Confirm…":"Adding…"]}):d[s]==="done"?e.jsx("span",{className:"migrate__tick",children:"✓"}):d[s]==="skipped"?e.jsx("span",{className:"migrate__skip",children:"Skipped"}):d[s]==="failed"?e.jsx("span",{className:"migrate__skip",children:"Failed"}):d[s]==="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"})})]},t.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 B=[{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 se(){const{session:n,signIn:I,restore:g}=R(),h=F(),x=n==null?void 0:n.address;p.useEffect(()=>{g()},[g]);const{data:c,isLoading:d}=K({queryKey:["importable",x],queryFn:()=>G(x),enabled:!!x}),[j,b]=p.useState({}),[C,w]=p.useState(new Set),[u,N]=p.useState(null),_=p.useMemo(()=>[...(c==null?void 0:c.creations)??[],...(c==null?void 0:c.owned)??[]],[c]);p.useEffect(()=>{_.length&&b(a=>{const l={...a};for(const i of _)l[i.oldTradeId]==null&&(l[i.oldTradeId]=i.suggestedCredits);return l})},[_]);const f=a=>!C.has(a),t=a=>j[a.oldTradeId]??a.suggestedCredits,s=_.filter(a=>f(a.oldTradeId)),r=s.reduce((a,l)=>a+t(l),0);function m(a,l){const i=l.replace(/[^\d]/g,"");b(k=>({...k,[a]:i===""?0:parseInt(i,10)}))}function o(a){w(l=>{const i=new Set(l);return i.has(a)?i.delete(a):i.add(a),i})}function y(a){return a.map(l=>({item:l,priceCredits:Math.max(1,t(l))}))}function T(){h.invalidateQueries({queryKey:["importable"]}),h.invalidateQueries({queryKey:["unified-listings"]}),h.invalidateQueries({queryKey:["my-assets"]}),h.invalidateQueries({queryKey:["collection-sale-state"]}),P.success("Your Shop is updated.")}return n?!d&&_.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 ",S.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(v,{className:"ccy-mark imp__diamond"})," 1 ",S.nameSingular," = $0.10 · prices rounded up"]}),d?e.jsx("div",{className:"imp__list",children:Array.from({length:4}).map((a,l)=>e.jsx("div",{className:"imp-row imp-row--skeleton"},l))}):B.map(a=>{const l=(c==null?void 0:c[a.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:a.title}),e.jsx("span",{className:"imp__section-sub",children:a.sub})]}),e.jsx("div",{className:"imp__list",children:l.map(i=>{const k=t(i),M=k!==i.suggestedCredits;return e.jsxs("article",{className:`imp-row${f(i.oldTradeId)?"":" is-off"}`,children:[e.jsx("input",{type:"checkbox",className:"imp-check",checked:f(i.oldTradeId),onChange:()=>o(i.oldTradeId),"aria-label":`Include ${i.name}`}),e.jsx("div",{className:"imp-thumb",children:i.thumbnail?e.jsx("img",{src:i.thumbnail,alt:""}):null}),e.jsxs("div",{className:"imp-meta",children:[e.jsx("div",{className:"imp-name",title:i.name,children:i.name||"Item"}),e.jsx("span",{className:"imp-chip",children:i.rarity})]}),e.jsxs("div",{className:"imp-price",children:[e.jsxs("div",{className:"imp-price__field",children:[e.jsx(v,{className:"ccy-mark imp-price__diamond"}),e.jsx("input",{className:"imp-price__input",inputMode:"numeric",value:k.toLocaleString(),onChange:$=>m(i.oldTradeId,$.target.value),"aria-label":`Price in ${S.name} for ${i.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($=>({...$,[i.oldTradeId]:i.suggestedCredits})),children:["Reset to ",e.jsx(v,{className:"ccy-mark"}),i.suggestedCredits.toLocaleString()]}):null]})]}),e.jsx("div",{className:"imp-action",children:e.jsx("button",{className:"btn btn--sm imp-row__list",disabled:!f(i.oldTradeId),onClick:()=>N(y([i])),children:"List"})})]},i.oldTradeId)})})]},a.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(v,{className:"ccy-mark imp__diamond"})," ",r.toLocaleString()]}),e.jsxs("div",{className:"imp-dock__sub",children:[s.length," item",s.length===1?"":"s"," selected · $",(r*.1).toFixed(2)]})]}),e.jsx("span",{className:"imp-dock__spacer"}),e.jsxs("button",{className:"btn btn--purple imp-dock__cta",disabled:s.length===0,onClick:()=>N(y(s)),children:["List all (",s.length,")"]})]})}),u&&n?e.jsx(z,{queue:u,session:n,onClose:()=>N(null),onDone:T}):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:()=>I(),children:"Sign in"})]})}export{se as ImportListings};
1
+ import{a as E,r as p,j as e,L as A}from"./react-iAgwec9M.js";import{z as Q,E as L,y as S,e as v,c as R,w as F,u as K,o as P}from"./index-C1zw_jvz.js";import{i as W,R as Y,f as G}from"./import-JBeySj3d.js";import{s as O}from"./wallet-kind-BCHFSy95.js";import"./ethers-D-4WUfRB.js";import"./buy-DEy5oWx-.js";import"./trade-encoding-gNFeXeFL.js";import"./index-BF4WrGCQ.js";import"./mana-rate-C_85VLuc.js";function z({queue:n,session:I,onClose:g,onDone:h}){const x=E(),c=O(I.providerType),[d,j]=p.useState(()=>n.map(()=>"pending")),[b,C]=p.useState("running"),w=p.useRef(!1);p.useEffect(()=>{if(w.current)return;w.current=!0;let t=!1;return(async()=>{for(let s=0;s<n.length;s++){if(t)return;j(r=>r.map((m,o)=>o===s?"active":m));try{await W(n[s].item,n[s].priceCredits,I),Q("Shop Migrated Listing",{item_id:n[s].item.itemId??n[s].item.oldTradeId??null,contract_address:n[s].item.contractAddress,new_price_credits:n[s].priceCredits,new_price_usd:n[s].priceCredits/10}),t||j(r=>r.map((m,o)=>o===s?"done":m))}catch(r){if(r instanceof Y)L(r,{flow:"import_listing",step:"relist",itemId:n[s].item.itemId??n[s].item.oldTradeId}),t||j(m=>m.map((o,y)=>y===s?"unlisted":o));else{const m=r,o=m.code===4001||/reject|denied|cancel/i.test(m.message??"");o||L(r,{flow:"import_listing",itemId:n[s].item.itemId??n[s].item.oldTradeId}),t||j(y=>y.map((T,a)=>a===s?o?"skipped":"failed":T))}}}t||C("finished")})(),()=>{t=!0}},[]);const u=d.filter(t=>t==="done").length,N=d.findIndex(t=>t==="active"),_=Math.round(d.filter(t=>t!=="pending"&&t!=="active").length/n.length*100);function f(){h(),g()}if(b==="finished"){const t=d.filter(r=>r==="skipped"||r==="failed").length,s=d.filter(r=>r==="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:u>0?"You're in the Shop! 🎉":"Nothing listed"}),e.jsxs("p",{className:"muted",style:{margin:0},children:[u>0?`${u} ${u===1?"item is":"items are"} now for sale with ${S.name}.`:"No items were listed.",t>0?` ${t} skipped — you can try those again anytime.`:"",s>0?` ${s} ${s===1?"item was":"items were"} taken off the old marketplace but couldn't be re-listed — re-list ${s===1?"it":"them"} from My Assets.`:""]}),e.jsxs("div",{className:"modal__actions",children:[e.jsx("button",{className:"btn btn--ghost",onClick:f,children:"Done"}),s>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{h(),g(),x("/my-assets")},children:"Go to My Assets"}):u>0?e.jsx("button",{className:"btn btn--purple",onClick:()=>{h(),g(),x("/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."," ",N>=0?`${N+1} of ${n.length}`:""]}),e.jsx("div",{className:"migrate__progress",children:e.jsx("div",{className:"migrate__bar",style:{width:`${_}%`}})}),e.jsx("ul",{className:"migrate__list",children:n.map((t,s)=>e.jsxs("li",{className:`migrate__row migrate__row--${d[s]}`,children:[e.jsx("span",{className:"migrate__thumb",children:t.item.thumbnail?e.jsx("img",{src:t.item.thumbnail,alt:""}):null}),e.jsx("span",{className:"migrate__name",title:t.item.name,children:t.item.name||"Item"}),e.jsxs("span",{className:"migrate__price",children:[e.jsx(v,{className:"ccy-mark"})," ",t.priceCredits.toLocaleString()]}),e.jsx("span",{className:"migrate__status",children:d[s]==="active"?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"spinner migrate__spin","aria-hidden":!0})," ",c?"Confirm…":"Adding…"]}):d[s]==="done"?e.jsx("span",{className:"migrate__tick",children:"✓"}):d[s]==="skipped"?e.jsx("span",{className:"migrate__skip",children:"Skipped"}):d[s]==="failed"?e.jsx("span",{className:"migrate__skip",children:"Failed"}):d[s]==="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"})})]},t.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 B=[{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 se(){const{session:n,signIn:I,restore:g}=R(),h=F(),x=n==null?void 0:n.address;p.useEffect(()=>{g()},[g]);const{data:c,isLoading:d}=K({queryKey:["importable",x],queryFn:()=>G(x),enabled:!!x}),[j,b]=p.useState({}),[C,w]=p.useState(new Set),[u,N]=p.useState(null),_=p.useMemo(()=>[...(c==null?void 0:c.creations)??[],...(c==null?void 0:c.owned)??[]],[c]);p.useEffect(()=>{_.length&&b(a=>{const l={...a};for(const i of _)l[i.oldTradeId]==null&&(l[i.oldTradeId]=i.suggestedCredits);return l})},[_]);const f=a=>!C.has(a),t=a=>j[a.oldTradeId]??a.suggestedCredits,s=_.filter(a=>f(a.oldTradeId)),r=s.reduce((a,l)=>a+t(l),0);function m(a,l){const i=l.replace(/[^\d]/g,"");b(k=>({...k,[a]:i===""?0:parseInt(i,10)}))}function o(a){w(l=>{const i=new Set(l);return i.has(a)?i.delete(a):i.add(a),i})}function y(a){return a.map(l=>({item:l,priceCredits:Math.max(1,t(l))}))}function T(){h.invalidateQueries({queryKey:["importable"]}),h.invalidateQueries({queryKey:["unified-listings"]}),h.invalidateQueries({queryKey:["my-assets"]}),h.invalidateQueries({queryKey:["collection-sale-state"]}),P.success("Your Shop is updated.")}return n?!d&&_.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 ",S.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(v,{className:"ccy-mark imp__diamond"})," 1 ",S.nameSingular," = $0.10 · prices rounded up"]}),d?e.jsx("div",{className:"imp__list",children:Array.from({length:4}).map((a,l)=>e.jsx("div",{className:"imp-row imp-row--skeleton"},l))}):B.map(a=>{const l=(c==null?void 0:c[a.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:a.title}),e.jsx("span",{className:"imp__section-sub",children:a.sub})]}),e.jsx("div",{className:"imp__list",children:l.map(i=>{const k=t(i),M=k!==i.suggestedCredits;return e.jsxs("article",{className:`imp-row${f(i.oldTradeId)?"":" is-off"}`,children:[e.jsx("input",{type:"checkbox",className:"imp-check",checked:f(i.oldTradeId),onChange:()=>o(i.oldTradeId),"aria-label":`Include ${i.name}`}),e.jsx("div",{className:"imp-thumb",children:i.thumbnail?e.jsx("img",{src:i.thumbnail,alt:""}):null}),e.jsxs("div",{className:"imp-meta",children:[e.jsx("div",{className:"imp-name",title:i.name,children:i.name||"Item"}),e.jsx("span",{className:"imp-chip",children:i.rarity})]}),e.jsxs("div",{className:"imp-price",children:[e.jsxs("div",{className:"imp-price__field",children:[e.jsx(v,{className:"ccy-mark imp-price__diamond"}),e.jsx("input",{className:"imp-price__input",inputMode:"numeric",value:k.toLocaleString(),onChange:$=>m(i.oldTradeId,$.target.value),"aria-label":`Price in ${S.name} for ${i.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($=>({...$,[i.oldTradeId]:i.suggestedCredits})),children:["Reset to ",e.jsx(v,{className:"ccy-mark"}),i.suggestedCredits.toLocaleString()]}):null]})]}),e.jsx("div",{className:"imp-action",children:e.jsx("button",{className:"btn btn--sm imp-row__list",disabled:!f(i.oldTradeId),onClick:()=>N(y([i])),children:"List"})})]},i.oldTradeId)})})]},a.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(v,{className:"ccy-mark imp__diamond"})," ",r.toLocaleString()]}),e.jsxs("div",{className:"imp-dock__sub",children:[s.length," item",s.length===1?"":"s"," selected · $",(r*.1).toFixed(2)]})]}),e.jsx("span",{className:"imp-dock__spacer"}),e.jsxs("button",{className:"btn btn--purple imp-dock__cta",disabled:s.length===0,onClick:()=>N(y(s)),children:["List all (",s.length,")"]})]})}),u&&n?e.jsx(z,{queue:u,session:n,onClose:()=>N(null),onDone:T}):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:()=>I(),children:"Sign in"})]})}export{se as ImportListings};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-Bybrl6u1.js","assets/react-iAgwec9M.js","assets/index-BJ_QKI7g.js","assets/ethers-D-4WUfRB.js","assets/index-Ctf6wteV.css","assets/emotion-styled.browser.esm-Cuau_-ln.js","assets/CircularProgress-D2LB2Tot.js"])))=>i.map(i=>d[i]);
2
- import{j as e,r,u as be,b as je,a as ge,L as ye}from"./react-iAgwec9M.js";import{_ as Ne,c as ie,M as we,P as Ie,O as Ce,an as Ae,W as ke,j as L,i as re,ao as Ee,A as Se,m as X,b as ee,v as Le,u as R,ap as Pe,z as D,aq as Te,ar as Re,as as Fe,at as $e,n as Be,au as Me,av as qe,C as We,e as F,aw as te,ax as Oe,x as ze,h as De,q as Ve,s as Ue,F as Ge,G as Ke,H as ae,E as Ye,J as He,D as Je,I as Qe,y as Ze,f as Xe,ay as et,az as tt,K as at}from"./index-BJ_QKI7g.js";import{a as se}from"./buy-DK-hDYib.js";import{g as st,a as it,w as rt,S as nt,G as lt}from"./buy-gasless-BqKKprU3.js";import"./ethers-D-4WUfRB.js";import"./trade-encoding-ELuUTRbi.js";import"./index-CfK4LG22.js";const ct=r.lazy(()=>Ne(()=>import("./index-Bybrl6u1.js").then(a=>a.i),__vite__mapDeps([0,1,2,3,4,5,6])).then(a=>({default:a.EmoteControls})));function dt(a){return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ct,{...a})})}function ot({item:a}){const l=ie(c=>{var n;return(n=c.session)==null?void 0:n.address}),{data:s,isLoading:m}=we(l),w=l&&s?l:"default",_=a.category==="emote",[p,d]=r.useState("avatar"),f=!_&&p==="item",[A,t]=r.useState(!0);r.useEffect(()=>{t(!0)},[a.id,f]);const g=!!l&&!!s,o=g&&Ie(a,Ce(s)),b=Ae(a)[0],I=g&&!o&&!_;return e.jsxs(e.Fragment,{children:[m?null:e.jsx(ke,{id:"shop-item-preview",contractAddress:a.contractAddress,tokenId:a.tokenId??void 0,itemId:a.tokenId?void 0:a.itemId??void 0,profile:f?void 0:o?w:"default",bodyShape:f||o?void 0:b,type:_?void 0:f?L.PreviewType.WEARABLE:L.PreviewType.AVATAR,emote:_||f?void 0:L.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:_?1.5:void 0,wheelStart:_?100:void 0,dev:re.chainId===80002,onLoad:()=>t(!1)},a.id),m||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,I&&!f?e.jsxs("p",{className:"item-preview__note",children:["Shown on a ",Ee(b)," body — this item isn’t made for your avatar’s shape."]}):null,_?e.jsx("div",{className:"item-preview__emote-controls",children:e.jsx(dt,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":"Preview mode",children:[e.jsx("button",{type:"button",className:p==="avatar"?"is-active":"","aria-pressed":p==="avatar",onClick:()=>d("avatar"),children:"On avatar"}),e.jsx("button",{type:"button",className:p==="item"?"is-active":"","aria-pressed":p==="item",onClick:()=>d("item"),children:"Item"})]})]})}function mt({title:a,items:l,onViewAll:s}){const m=r.useRef(null),[w,_]=r.useState(1),[p,d]=r.useState(0),[f,A]=r.useState(!0),[t,g]=r.useState(!1),o=r.useCallback(()=>{const c=m.current;if(!c)return;const{scrollLeft:n,scrollWidth:y,clientWidth:v}=c,P=Math.max(1,Math.ceil(y/v));_(P),d(Math.min(P-1,Math.round(n/v))),A(n<=1),g(n+v>=y-1)},[]);if(r.useEffect(()=>{o();const c=m.current;if(c)return c.addEventListener("scroll",o,{passive:!0}),window.addEventListener("resize",o),()=>{c.removeEventListener("scroll",o),window.removeEventListener("resize",o)}},[o,l.length]),l.length===0)return null;function b(c){const n=m.current;n&&n.scrollBy({left:c*n.clientWidth,behavior:"smooth"})}function I(c){const n=m.current;n&&n.scrollTo({left:c*n.clientWidth,behavior:"smooth"})}return e.jsxs("section",{className:"collection-carousel",children:[e.jsxs("div",{className:"collection-carousel__head",children:[e.jsx("h2",{className:"collection-carousel__title",children:a}),s?e.jsxs("button",{className:"collection-carousel__viewall",onClick:s,children:["View all",e.jsx("span",{className:"ico ico-chevron collection-carousel__viewall-ico","aria-hidden":!0})]}):null]}),e.jsxs("div",{className:"collection-carousel__viewport",children:[e.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--left",onClick:()=>b(-1),"aria-label":"Scroll left",disabled:f,children:"‹"}),e.jsx("div",{className:"collection-carousel__track",ref:m,children:l.map(c=>e.jsx(Se,{item:c},c.id))}),e.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--right",onClick:()=>b(1),"aria-label":"Scroll right",disabled:t,children:"›"})]}),w>1?e.jsx("div",{className:"collection-carousel__dots","aria-label":"Carousel pages",children:Array.from({length:w}).map((c,n)=>e.jsx("button",{className:`collection-carousel__dot${n===p?" is-active":""}`,"aria-label":`Go to page ${n+1}`,"aria-current":n===p?"true":void 0,onClick:()=>I(n)},n))}):null]})}function ut(a){return Object.values(L.Rarity).includes(a)}function ht(a){return a==="male"?"Male":a==="female"?"Female":a==="unisex"?"Unisex":null}function _t(a){return a.wearableCategory?a.wearableCategory.replace(/_/g," "):a.category==="emote"?"Emote":"Wearable"}function pt(a){const l=a,s=(l.message??"").toLowerCase();return l.code===4001||s.includes("reject")||s.includes("denied")||s.includes("cancel")?"You cancelled the request.":s.includes("insufficient")?`You don't have enough ${Ze.name} — get more first.`:s.includes("no active listing")||s.includes("not for sale")?"This item is not for sale right now.":"Couldn't complete checkout — please try again."}function Nt(){const{contractAddress:a,tokenId:l}=be(),{state:s}=je(),m=ge(),w=X(i=>i.add),_=X(i=>i.items),p=ee(i=>i.toggle),{session:d}=ie(),{data:f,isError:A}=Le(d),[t,g]=r.useState(()=>s!=null&&s.item?{...s.item,tradeId:s.tradeId??s.item.tradeId}:{id:`${a}-${l}`,name:"",creator:"",contractAddress:a??"",itemId:null,category:"wearable",rarity:"common",network:"MATIC",chainId:re.chainId,thumbnail:"",priceCredits:0,gender:null,tokenId:l??void 0,tradeId:s==null?void 0:s.tradeId}),[o,b]=r.useState(!1),[I,c]=r.useState(null),[n,y]=r.useState(null),{data:v=[],isFetched:P}=R({queryKey:["collection-items",t.contractAddress],enabled:!!t.contractAddress,queryFn:()=>Xe(t.contractAddress,{first:20}).then(i=>i.items)}),{data:$,isLoading:ne}=R({queryKey:["shop-item",t.contractAddress,l],enabled:!(s!=null&&s.item)&&!!t.contractAddress&&!!l,queryFn:()=>et(t.contractAddress,l)});r.useEffect(()=>{$&&g(i=>i.tradeId?i:{...$})},[$]);const[V,le]=r.useState(!1),{data:B=""}=R({queryKey:["item-desc",t.contractAddress,t.itemId],enabled:!!t.contractAddress&&!!t.itemId,staleTime:5*6e4,queryFn:()=>tt(t.contractAddress,t.itemId)});r.useEffect(()=>{if(t.name||v.length===0)return;const i=l&&v.find(u=>u.tokenId===l||u.itemId===l)||v.find(u=>u.contractAddress===t.contractAddress);i&&g(u=>({...i,tradeId:u.tradeId??i.tradeId}))},[v]);const ce=r.useMemo(()=>{const i=new Set,u=[];for(const h of v){if(h.id===t.id||t.itemId&&h.itemId===t.itemId||t.tokenId&&h.tokenId===t.tokenId)continue;const S=`${h.contractAddress}-${h.itemId??h.tokenId??h.id}`;i.has(S)||(i.add(S),u.push(h))}return u},[v,t.id,t.itemId,t.tokenId]),{data:de,isLoading:k}=R({queryKey:["detail-trade",t.id,t.tradeId,t.contractAddress,t.itemId],enabled:!!t.contractAddress,queryFn:async()=>{if(t.tradeId)return t.tradeId;if(t.itemId){const i=await at(t.contractAddress,t.itemId);return(i==null?void 0:i.id)??null}return null}}),N=t.tradeId??de??void 0,j=!!N,oe=Pe({priceCredits:t.priceCredits,compareAtCredits:t.compareAtCredits,saleEndsAt:t.saleEndsAt}),E=r.useMemo(()=>({...t,tradeId:N,id:N??t.id}),[t,N]),M=_.some(i=>i.id===E.id),q=ee(i=>!!i.items[t.id]);r.useEffect(()=>{c(null),y(null)},[t.id]);const U=r.useRef(null);r.useEffect(()=>{!t.name||k||U.current===t.id||(U.current=t.id,D("Shop Viewed Item",{...Te(t),for_sale:j}),Re(t))},[t.id,t.name,k,j]);const T=`${a}/${l}`,G=r.useRef(T);r.useEffect(()=>{G.current!==T&&(G.current=T,s!=null&&s.item&&g({...s.item,tradeId:s.tradeId??s.item.tradeId}),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))},[T]);function me(){!j||M||Q||w(E,"item_detail")}async function ue(){var S;if(!j||!N)return;if(!d){y("Sign in to check out.");return}y(null),b(!0);let i,u="authorize",h=!1;try{c(`Buying ${t.name||"item"}…`);const x=await De(N);if(!x)throw new Error("not for sale");if(Ve(x,d.address)){y("You can't buy your own listing."),c(null),b(!1);return}const W=(S=x.received)==null?void 0:S[0],ve=Ue(W==null?void 0:W.amount),{credit:Z,maxCreditedValue:xe}=await Ge(d.identity,ve,N);i=Z.id,u="submit";const O={trade:x,buyer:d.address,signer:d.signer,credits:[Z],maxCreditedValue:xe};let C;if(st())try{C=await it(O),await rt(C),h=!0}catch(z){if(z instanceof nt)h=!0;else if(z instanceof lt)C=await se(O);else throw z}else C=await se(O);i=void 0,D("Shop Completed Purchase",{...Ke([E]),payment_type:"credits",no_crypto_step:h,transaction_hash:C??null}),m("/success",{state:{items:[E],txHash:C}})}catch(x){ae(x)||Ye(x,{flow:"buy",step:u,gasless:h}),i&&He(d.identity,[i]).catch(()=>{}),D(ae(x)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:u,error_code:Qe(x),value_usd:Je(E.priceCredits)}),y(pt(x)),c(null)}finally{b(!1)}}const K=ut(t.rarity)?t.rarity:L.Rarity.COMMON,Y=ht(t.gender),H=Fe(t),J=$e(t.gender),he=j&&oe,_e="More from this collection",Q=Be(t,d==null?void 0:d.address),pe=j?M?"In cart":k?"Checking…":"Add to cart":"Not for sale",fe=ne||!!t.contractAddress&&!P;return!t.name&&!fe?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:()=>m("/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:()=>m("/assets"),children:"Collectibles"}),e.jsx("span",{className:"item-detail__crumb-sep",children:"/"}),e.jsx("span",{className:"item-detail__crumb-current",children:t.name||"Item"})]}),e.jsxs("div",{className:"item-detail__main",children:[e.jsx("div",{className:"item-detail__preview",children:t.name?e.jsx(ot,{item:t}):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.jsxs("div",{className:"item-detail__info",children:[e.jsxs("div",{className:"item-detail__info-head",children:[e.jsx("h1",{className:"item-detail__title",children:t.name||"Loading…"}),e.jsx("button",{className:`item-detail__fav${q?" is-on":""}`,onClick:()=>p(t),"aria-pressed":q,"aria-label":q?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:"ico ico-heart","aria-hidden":!0})})]}),e.jsxs("div",{className:"item-detail__chips",children:[e.jsx("span",{className:"chip chip--rarity",style:{background:qe(K),color:Me(K)},children:t.rarity}),e.jsxs("span",{className:"chip item-detail__chip",children:[H?e.jsx("span",{className:`ico ico-${H} item-detail__chip-ico`,"aria-hidden":!0}):null,_t(t)]}),Y?e.jsxs("span",{className:"chip item-detail__chip",children:[J?e.jsx("span",{className:`ico ico-${J} item-detail__chip-ico`,"aria-hidden":!0}):null,Y]}):null]}),B?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${V?" is-expanded":""}`,children:B}),B.length>140?e.jsx("button",{className:"link item-detail__desc-toggle",onClick:()=>le(i=>!i),children:V?"Show less":"Read more"}):null]}):null,t.creator?e.jsx("div",{className:"item-detail__meta",children:e.jsxs("div",{className:"item-detail__meta-col",children:[e.jsx("div",{className:"item-detail__label",children:"Creator"}),e.jsx(We,{address:t.creator,className:"item-detail__creator",linkToProfile:!0})]})}):null,e.jsx("hr",{className:"item-detail__divider"}),e.jsxs("div",{className:"item-detail__price-block",children:[e.jsx("div",{className:"item-detail__price-label",children:"Price"}),j?he?e.jsxs("div",{className:"item-detail__price item-detail__price--sale",children:[e.jsxs("span",{className:"item-detail__price",children:[e.jsx(F,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:t.priceCredits})]}),e.jsxs("span",{className:"item-detail__price-was",children:[e.jsx(F,{className:"item-detail__diamond item-detail__diamond--was"}),t.compareAtCredits]}),te(t.compareAtCredits,t.priceCredits)>0?e.jsxs("span",{className:"item-detail__sale-badge",children:["SALE -",te(t.compareAtCredits,t.priceCredits),"%"]}):null,e.jsx(Oe,{endsAt:t.saleEndsAt,className:"item-detail__countdown"})]}):e.jsxs("div",{className:"item-detail__price",children:[e.jsx(F,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:t.priceCredits})]}):e.jsx("div",{className:"item-detail__price item-detail__price--none",children:"Not for sale"}),d?e.jsxs("div",{className:"item-detail__balance muted",children:["Your balance: ",e.jsx(F,{className:"ccy-mark"})," ",ze(f,A)]}):null]}),e.jsx("div",{className:"item-detail__ctas",children:Q?e.jsxs("p",{className:"item-detail__own-note muted",children:["This is your item — manage it in ",e.jsx(ye,{to:"/my-assets",children:"My Assets"}),"."]}):e.jsxs(e.Fragment,{children:[j?e.jsx("button",{className:"btn btn--purple item-detail__cta",onClick:ue,disabled:o||k,children:o?"Buying…":"Buy now"}):null,e.jsxs("button",{className:"item-detail__addcart",onClick:me,disabled:!j||M||k||o,children:[e.jsx("span",{className:"ico ico-cart-solid item-detail__addcart-ico","aria-hidden":!0}),pe]})]})}),I?e.jsx("p",{className:"muted item-detail__status",children:I}):null,n?e.jsx("p",{className:"error item-detail__status",children:n}):null]})]}),e.jsx(mt,{title:_e,items:ce,onViewAll:t.contractAddress?()=>m(`/collection/${t.contractAddress}`):void 0})]})}export{Nt as ItemDetail,Nt as default};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-D5-hMxEz.js","assets/react-iAgwec9M.js","assets/index-C1zw_jvz.js","assets/ethers-D-4WUfRB.js","assets/index-Ctf6wteV.css","assets/emotion-styled.browser.esm-B8upHOUh.js","assets/CircularProgress-CFx6Tc-u.js"])))=>i.map(i=>d[i]);
2
+ import{j as e,r,u as be,b as je,a as ge,L as ye}from"./react-iAgwec9M.js";import{_ as Ne,c as ie,M as we,P as Ie,O as Ce,an as Ae,W as ke,j as L,i as re,ao as Ee,A as Se,m as X,b as ee,v as Le,u as R,ap as Pe,z as D,aq as Te,ar as Re,as as Fe,at as $e,n as Be,au as Me,av as qe,C as We,e as F,aw as te,ax as Oe,x as ze,h as De,q as Ve,s as Ue,F as Ge,G as Ke,H as ae,E as Ye,J as He,D as Je,I as Qe,y as Ze,f as Xe,ay as et,az as tt,K as at}from"./index-C1zw_jvz.js";import{a as se}from"./buy-DEy5oWx-.js";import{g as st,a as it,w as rt,S as nt,G as lt}from"./buy-gasless-VIo89iNM.js";import"./ethers-D-4WUfRB.js";import"./trade-encoding-gNFeXeFL.js";import"./index-BF4WrGCQ.js";const ct=r.lazy(()=>Ne(()=>import("./index-D5-hMxEz.js").then(a=>a.i),__vite__mapDeps([0,1,2,3,4,5,6])).then(a=>({default:a.EmoteControls})));function dt(a){return e.jsx(r.Suspense,{fallback:null,children:e.jsx(ct,{...a})})}function ot({item:a}){const l=ie(c=>{var n;return(n=c.session)==null?void 0:n.address}),{data:s,isLoading:m}=we(l),w=l&&s?l:"default",_=a.category==="emote",[p,d]=r.useState("avatar"),f=!_&&p==="item",[A,t]=r.useState(!0);r.useEffect(()=>{t(!0)},[a.id,f]);const g=!!l&&!!s,o=g&&Ie(a,Ce(s)),b=Ae(a)[0],I=g&&!o&&!_;return e.jsxs(e.Fragment,{children:[m?null:e.jsx(ke,{id:"shop-item-preview",contractAddress:a.contractAddress,tokenId:a.tokenId??void 0,itemId:a.tokenId?void 0:a.itemId??void 0,profile:f?void 0:o?w:"default",bodyShape:f||o?void 0:b,type:_?void 0:f?L.PreviewType.WEARABLE:L.PreviewType.AVATAR,emote:_||f?void 0:L.PreviewEmote.FASHION,disableBackground:!0,wheelZoom:_?1.5:void 0,wheelStart:_?100:void 0,dev:re.chainId===80002,onLoad:()=>t(!1)},a.id),m||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,I&&!f?e.jsxs("p",{className:"item-preview__note",children:["Shown on a ",Ee(b)," body — this item isn’t made for your avatar’s shape."]}):null,_?e.jsx("div",{className:"item-preview__emote-controls",children:e.jsx(dt,{wearablePreviewId:"shop-item-preview",hideFrameInput:!0})}):e.jsxs("div",{className:"item-preview__toggle",role:"group","aria-label":"Preview mode",children:[e.jsx("button",{type:"button",className:p==="avatar"?"is-active":"","aria-pressed":p==="avatar",onClick:()=>d("avatar"),children:"On avatar"}),e.jsx("button",{type:"button",className:p==="item"?"is-active":"","aria-pressed":p==="item",onClick:()=>d("item"),children:"Item"})]})]})}function mt({title:a,items:l,onViewAll:s}){const m=r.useRef(null),[w,_]=r.useState(1),[p,d]=r.useState(0),[f,A]=r.useState(!0),[t,g]=r.useState(!1),o=r.useCallback(()=>{const c=m.current;if(!c)return;const{scrollLeft:n,scrollWidth:y,clientWidth:v}=c,P=Math.max(1,Math.ceil(y/v));_(P),d(Math.min(P-1,Math.round(n/v))),A(n<=1),g(n+v>=y-1)},[]);if(r.useEffect(()=>{o();const c=m.current;if(c)return c.addEventListener("scroll",o,{passive:!0}),window.addEventListener("resize",o),()=>{c.removeEventListener("scroll",o),window.removeEventListener("resize",o)}},[o,l.length]),l.length===0)return null;function b(c){const n=m.current;n&&n.scrollBy({left:c*n.clientWidth,behavior:"smooth"})}function I(c){const n=m.current;n&&n.scrollTo({left:c*n.clientWidth,behavior:"smooth"})}return e.jsxs("section",{className:"collection-carousel",children:[e.jsxs("div",{className:"collection-carousel__head",children:[e.jsx("h2",{className:"collection-carousel__title",children:a}),s?e.jsxs("button",{className:"collection-carousel__viewall",onClick:s,children:["View all",e.jsx("span",{className:"ico ico-chevron collection-carousel__viewall-ico","aria-hidden":!0})]}):null]}),e.jsxs("div",{className:"collection-carousel__viewport",children:[e.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--left",onClick:()=>b(-1),"aria-label":"Scroll left",disabled:f,children:"‹"}),e.jsx("div",{className:"collection-carousel__track",ref:m,children:l.map(c=>e.jsx(Se,{item:c},c.id))}),e.jsx("button",{className:"collection-carousel__arrow collection-carousel__arrow--right",onClick:()=>b(1),"aria-label":"Scroll right",disabled:t,children:"›"})]}),w>1?e.jsx("div",{className:"collection-carousel__dots","aria-label":"Carousel pages",children:Array.from({length:w}).map((c,n)=>e.jsx("button",{className:`collection-carousel__dot${n===p?" is-active":""}`,"aria-label":`Go to page ${n+1}`,"aria-current":n===p?"true":void 0,onClick:()=>I(n)},n))}):null]})}function ut(a){return Object.values(L.Rarity).includes(a)}function ht(a){return a==="male"?"Male":a==="female"?"Female":a==="unisex"?"Unisex":null}function _t(a){return a.wearableCategory?a.wearableCategory.replace(/_/g," "):a.category==="emote"?"Emote":"Wearable"}function pt(a){const l=a,s=(l.message??"").toLowerCase();return l.code===4001||s.includes("reject")||s.includes("denied")||s.includes("cancel")?"You cancelled the request.":s.includes("insufficient")?`You don't have enough ${Ze.name} — get more first.`:s.includes("no active listing")||s.includes("not for sale")?"This item is not for sale right now.":"Couldn't complete checkout — please try again."}function Nt(){const{contractAddress:a,tokenId:l}=be(),{state:s}=je(),m=ge(),w=X(i=>i.add),_=X(i=>i.items),p=ee(i=>i.toggle),{session:d}=ie(),{data:f,isError:A}=Le(d),[t,g]=r.useState(()=>s!=null&&s.item?{...s.item,tradeId:s.tradeId??s.item.tradeId}:{id:`${a}-${l}`,name:"",creator:"",contractAddress:a??"",itemId:null,category:"wearable",rarity:"common",network:"MATIC",chainId:re.chainId,thumbnail:"",priceCredits:0,gender:null,tokenId:l??void 0,tradeId:s==null?void 0:s.tradeId}),[o,b]=r.useState(!1),[I,c]=r.useState(null),[n,y]=r.useState(null),{data:v=[],isFetched:P}=R({queryKey:["collection-items",t.contractAddress],enabled:!!t.contractAddress,queryFn:()=>Xe(t.contractAddress,{first:20}).then(i=>i.items)}),{data:$,isLoading:ne}=R({queryKey:["shop-item",t.contractAddress,l],enabled:!(s!=null&&s.item)&&!!t.contractAddress&&!!l,queryFn:()=>et(t.contractAddress,l)});r.useEffect(()=>{$&&g(i=>i.tradeId?i:{...$})},[$]);const[V,le]=r.useState(!1),{data:B=""}=R({queryKey:["item-desc",t.contractAddress,t.itemId],enabled:!!t.contractAddress&&!!t.itemId,staleTime:5*6e4,queryFn:()=>tt(t.contractAddress,t.itemId)});r.useEffect(()=>{if(t.name||v.length===0)return;const i=l&&v.find(u=>u.tokenId===l||u.itemId===l)||v.find(u=>u.contractAddress===t.contractAddress);i&&g(u=>({...i,tradeId:u.tradeId??i.tradeId}))},[v]);const ce=r.useMemo(()=>{const i=new Set,u=[];for(const h of v){if(h.id===t.id||t.itemId&&h.itemId===t.itemId||t.tokenId&&h.tokenId===t.tokenId)continue;const S=`${h.contractAddress}-${h.itemId??h.tokenId??h.id}`;i.has(S)||(i.add(S),u.push(h))}return u},[v,t.id,t.itemId,t.tokenId]),{data:de,isLoading:k}=R({queryKey:["detail-trade",t.id,t.tradeId,t.contractAddress,t.itemId],enabled:!!t.contractAddress,queryFn:async()=>{if(t.tradeId)return t.tradeId;if(t.itemId){const i=await at(t.contractAddress,t.itemId);return(i==null?void 0:i.id)??null}return null}}),N=t.tradeId??de??void 0,j=!!N,oe=Pe({priceCredits:t.priceCredits,compareAtCredits:t.compareAtCredits,saleEndsAt:t.saleEndsAt}),E=r.useMemo(()=>({...t,tradeId:N,id:N??t.id}),[t,N]),M=_.some(i=>i.id===E.id),q=ee(i=>!!i.items[t.id]);r.useEffect(()=>{c(null),y(null)},[t.id]);const U=r.useRef(null);r.useEffect(()=>{!t.name||k||U.current===t.id||(U.current=t.id,D("Shop Viewed Item",{...Te(t),for_sale:j}),Re(t))},[t.id,t.name,k,j]);const T=`${a}/${l}`,G=r.useRef(T);r.useEffect(()=>{G.current!==T&&(G.current=T,s!=null&&s.item&&g({...s.item,tradeId:s.tradeId??s.item.tradeId}),typeof window<"u"&&window.scrollTo({top:0,behavior:"smooth"}))},[T]);function me(){!j||M||Q||w(E,"item_detail")}async function ue(){var S;if(!j||!N)return;if(!d){y("Sign in to check out.");return}y(null),b(!0);let i,u="authorize",h=!1;try{c(`Buying ${t.name||"item"}…`);const x=await De(N);if(!x)throw new Error("not for sale");if(Ve(x,d.address)){y("You can't buy your own listing."),c(null),b(!1);return}const W=(S=x.received)==null?void 0:S[0],ve=Ue(W==null?void 0:W.amount),{credit:Z,maxCreditedValue:xe}=await Ge(d.identity,ve,N);i=Z.id,u="submit";const O={trade:x,buyer:d.address,signer:d.signer,credits:[Z],maxCreditedValue:xe};let C;if(st())try{C=await it(O),await rt(C),h=!0}catch(z){if(z instanceof nt)h=!0;else if(z instanceof lt)C=await se(O);else throw z}else C=await se(O);i=void 0,D("Shop Completed Purchase",{...Ke([E]),payment_type:"credits",no_crypto_step:h,transaction_hash:C??null}),m("/success",{state:{items:[E],txHash:C}})}catch(x){ae(x)||Ye(x,{flow:"buy",step:u,gasless:h}),i&&He(d.identity,[i]).catch(()=>{}),D(ae(x)?"Shop Purchase Cancelled":"Shop Purchase Failed",{step:u,error_code:Qe(x),value_usd:Je(E.priceCredits)}),y(pt(x)),c(null)}finally{b(!1)}}const K=ut(t.rarity)?t.rarity:L.Rarity.COMMON,Y=ht(t.gender),H=Fe(t),J=$e(t.gender),he=j&&oe,_e="More from this collection",Q=Be(t,d==null?void 0:d.address),pe=j?M?"In cart":k?"Checking…":"Add to cart":"Not for sale",fe=ne||!!t.contractAddress&&!P;return!t.name&&!fe?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:()=>m("/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:()=>m("/assets"),children:"Collectibles"}),e.jsx("span",{className:"item-detail__crumb-sep",children:"/"}),e.jsx("span",{className:"item-detail__crumb-current",children:t.name||"Item"})]}),e.jsxs("div",{className:"item-detail__main",children:[e.jsx("div",{className:"item-detail__preview",children:t.name?e.jsx(ot,{item:t}):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.jsxs("div",{className:"item-detail__info",children:[e.jsxs("div",{className:"item-detail__info-head",children:[e.jsx("h1",{className:"item-detail__title",children:t.name||"Loading…"}),e.jsx("button",{className:`item-detail__fav${q?" is-on":""}`,onClick:()=>p(t),"aria-pressed":q,"aria-label":q?"Remove from favorites":"Add to favorites",children:e.jsx("span",{className:"ico ico-heart","aria-hidden":!0})})]}),e.jsxs("div",{className:"item-detail__chips",children:[e.jsx("span",{className:"chip chip--rarity",style:{background:qe(K),color:Me(K)},children:t.rarity}),e.jsxs("span",{className:"chip item-detail__chip",children:[H?e.jsx("span",{className:`ico ico-${H} item-detail__chip-ico`,"aria-hidden":!0}):null,_t(t)]}),Y?e.jsxs("span",{className:"chip item-detail__chip",children:[J?e.jsx("span",{className:`ico ico-${J} item-detail__chip-ico`,"aria-hidden":!0}):null,Y]}):null]}),B?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${V?" is-expanded":""}`,children:B}),B.length>140?e.jsx("button",{className:"link item-detail__desc-toggle",onClick:()=>le(i=>!i),children:V?"Show less":"Read more"}):null]}):null,t.creator?e.jsx("div",{className:"item-detail__meta",children:e.jsxs("div",{className:"item-detail__meta-col",children:[e.jsx("div",{className:"item-detail__label",children:"Creator"}),e.jsx(We,{address:t.creator,className:"item-detail__creator",linkToProfile:!0})]})}):null,e.jsx("hr",{className:"item-detail__divider"}),e.jsxs("div",{className:"item-detail__price-block",children:[e.jsx("div",{className:"item-detail__price-label",children:"Price"}),j?he?e.jsxs("div",{className:"item-detail__price item-detail__price--sale",children:[e.jsxs("span",{className:"item-detail__price",children:[e.jsx(F,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:t.priceCredits})]}),e.jsxs("span",{className:"item-detail__price-was",children:[e.jsx(F,{className:"item-detail__diamond item-detail__diamond--was"}),t.compareAtCredits]}),te(t.compareAtCredits,t.priceCredits)>0?e.jsxs("span",{className:"item-detail__sale-badge",children:["SALE -",te(t.compareAtCredits,t.priceCredits),"%"]}):null,e.jsx(Oe,{endsAt:t.saleEndsAt,className:"item-detail__countdown"})]}):e.jsxs("div",{className:"item-detail__price",children:[e.jsx(F,{className:"item-detail__diamond"}),e.jsx("span",{className:"item-detail__price-value",children:t.priceCredits})]}):e.jsx("div",{className:"item-detail__price item-detail__price--none",children:"Not for sale"}),d?e.jsxs("div",{className:"item-detail__balance muted",children:["Your balance: ",e.jsx(F,{className:"ccy-mark"})," ",ze(f,A)]}):null]}),e.jsx("div",{className:"item-detail__ctas",children:Q?e.jsxs("p",{className:"item-detail__own-note muted",children:["This is your item — manage it in ",e.jsx(ye,{to:"/my-assets",children:"My Assets"}),"."]}):e.jsxs(e.Fragment,{children:[j?e.jsx("button",{className:"btn btn--purple item-detail__cta",onClick:ue,disabled:o||k,children:o?"Buying…":"Buy now"}):null,e.jsxs("button",{className:"item-detail__addcart",onClick:me,disabled:!j||M||k||o,children:[e.jsx("span",{className:"ico ico-cart-solid item-detail__addcart-ico","aria-hidden":!0}),pe]})]})}),I?e.jsx("p",{className:"muted item-detail__status",children:I}):null,n?e.jsx("p",{className:"error item-detail__status",children:n}):null]})]}),e.jsx(mt,{title:_e,items:ce,onViewAll:t.contractAddress?()=>m(`/collection/${t.contractAddress}`):void 0})]})}export{Nt as ItemDetail,Nt as default};
@@ -1 +1 @@
1
- import{a as U,r as d,j as s,L as re}from"./react-iAgwec9M.js";import{j as Z,i as V,ah as le,w as B,e as q,y as C,p as ee,z as P,o as G,E as W,I as se,c as ce,u as D,aA as oe,h as de,aB as me}from"./index-BJ_QKI7g.js";import{f as ue}from"./import-Cicp42pB.js";import{c as he}from"./buy-DK-hDYib.js";import{a as pe,b as ge,i as be,e as ye,c as xe}from"./trade-encoding-ELuUTRbi.js";import{s as je}from"./wallet-kind-g2ENkqJ_.js";import{L as _e}from"./LoadMore-8Dx5lULo.js";import{u as fe}from"./useInfiniteGrid-XR5F3f0o.js";import"./ethers-D-4WUfRB.js";import"./mana-rate-nE0eZdyC.js";import"./index-CfK4LG22.js";const F=()=>`${V.builderServerUrl}/v1`;function ae(e){return Array.isArray(e)?e:"results"in e&&Array.isArray(e.results)?e.results:"data"in e&&Array.isArray(e.data)?e.data:[]}async function ne(e,i){const n=await le(e,{method:"GET",identity:i,metadata:{}});if(!n.ok)throw new Error(`builder-server ${n.status}: ${await n.text()}`);const c=await n.json();return c.data??c}function Ne(e,i){const n=i-e;return n>0?n:0}function ve(e){var i,n,c,r,l;return((n=(i=e.data)==null?void 0:i.wearable)==null?void 0:n.category)??((r=(c=e.data)==null?void 0:c.emote)==null?void 0:r.category)??((l=e.data)==null?void 0:l.category)??e.type??"wearable"}function z(e){return`${F()}/storage/contents/${e}`}function $(e,i){if(!e)return"";if(/^https?:\/\//.test(e))return e;const n=i==null?void 0:i[e];return n?z(n):/^(ba|Qm)/.test(e)?z(e):""}async function Ie(e,i){try{const n=await fetch(`${F()}/items/${e}/${i}/contents`);if(!n.ok)return{};const c=await n.json();return c.data??c}catch{return{}}}async function ke(e,i,n){const c=$(e.thumbnail,e.contents)||$("thumbnail.png",e.contents);if(c)return c;if(i&&n){const r=await Ie(i,n);return $(e.thumbnail,r)||$("thumbnail.png",r)||$("image.png",r)}return""}async function we(e,i){const n=`${F()}/${e.toLowerCase()}/collections?is_published=true`,c=await ne(n,i);return ae(c).filter(r=>r.is_published&&!!r.contract_address).map(r=>({id:r.id,name:r.name,contractAddress:r.contract_address.toLowerCase(),isPublished:r.is_published,isApproved:r.is_approved,minters:(r.minters??[]).map(l=>l.toLowerCase())}))}async function Ce(e,i){const n=`${F()}/collections/${e.id}/items`,c=await ne(n,i);return(await Promise.all(ae(c).map(async l=>{const v=l.rarity??"common",_=Number(l.total_supply??0)||0;let m=0;try{m=Z.Rarity.getMaxSupply(v)}catch{m=0}const f=(l.contract_address??e.contractAddress).toLowerCase(),p=l.blockchain_item_id??"";return{id:l.id,collectionId:e.id,collectionName:e.name,contractAddress:f,blockchainItemId:p,name:l.name,category:ve(l),rarity:v,thumbnail:await ke(l,f,p),type:l.type??"wearable",isPublished:l.is_published??e.isPublished,isApproved:l.is_approved??e.isApproved,totalSupply:_,maxSupply:m,remainingSupply:Ne(_,m),minters:e.minters}}))).filter(Se)}function Se(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function Ae(e,i){const n=await we(e,i);return(await Promise.all(n.map(async r=>{try{return await Ce(r,i)}catch{return[]}}))).flat()}const Pe=1e3*60*60*24*182;function $e(e){const i=e,n=(i.message??"").toLowerCase();return i.code===4001||n.includes("reject")||n.includes("denied")||n.includes("cancel")?"You cancelled the request.":"Couldn't list your item — please try again."}function Le({asset:e,session:i,onClose:n}){const c=B(),r=U(),[l,v]=d.useState("10"),[_,m]=d.useState(null),[f,p]=d.useState(null),[g,k]=d.useState(!1),[j,I]=d.useState(null);async function S(){p(null);const o=Number(l);if(!Number.isInteger(o)||o<=0){p("Enter a whole number of credits");return}k(!0);try{m("Getting your item ready…"),await pe({signer:i.signer,contractAddress:e.contractAddress,chainId:e.chainId}),m("Listing your item…");const N=await ge({signer:i.signer,nft:{contractAddress:e.contractAddress,tokenId:e.tokenId,network:e.network,chainId:e.chainId},usdPrice:o/10,expiresAtMs:Date.now()+Pe});m("Publishing…"),await ee(N,i.identity),m(null),I(o),P("Shop Listed Item",{item_id:e.itemId??e.tokenId??null,contract_address:e.contractAddress,price_credits:o,price_usd:o/10,listing_type:"secondary",is_primary:!1}),G.success(`“${e.name}” is now on sale!`),c.invalidateQueries({queryKey:["my-assets",i.address]})}catch(N){W(N,{flow:"list_secondary"}),P("Shop Listing Failed",{listing_type:"secondary",error_code:se(N)}),p($e(N)),m(null)}finally{k(!1)}}function x(){n(),r(`/item/${e.contractAddress}/${e.tokenId}`)}return j!==null?s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:"It’s on sale! 🎉"}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:["Listed for ",s.jsxs("strong",{children:[s.jsx(q,{className:"ccy-mark"})," ",j]})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,children:"Done"}),s.jsx("button",{className:"btn btn--purple",onClick:x,children:"View in Shop"})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsxs("h2",{className:"modal__title",children:["List “",e.name,"”"]}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Price (",C.name,")"]}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:o=>v(o.target.value),disabled:g})]}),s.jsxs("p",{className:"muted small",children:["Priced in whole ",C.name," (1 ",C.nameSingular," = $0.10)."]}),_?s.jsx("p",{className:"muted",children:_}):null,f?s.jsx("p",{className:"error",children:f}):null,s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:g,children:"Cancel"}),s.jsx("button",{className:"btn",onClick:S,disabled:g,children:g?"Listing…":"Put on sale"})]})]})})}const Ee=1e3*60*60*24*182;function Me(e){const i=e,n=(i.message??"").toLowerCase();return i.code===4001||n.includes("reject")||n.includes("denied")||n.includes("cancel")?"You cancelled the request.":"Couldn't publish your item — please try again."}function qe({item:e,session:i,onClose:n}){const c=B(),r=U(),[l,v]=d.useState("10"),[_,m]=d.useState(null),[f,p]=d.useState(null),[g,k]=d.useState(!1),[j,I]=d.useState(null),[S,x]=d.useState(null),o=V.chainId,N=je(i.providerType);d.useEffect(()=>{let u=!1;return(async()=>{try{const b=await be({contractAddress:e.contractAddress,chainId:o});u||I(b)}catch{u||I(!1)}})(),()=>{u=!0}},[e.contractAddress,o]);async function T(){p(null);const u=Number(l);if(!Number.isInteger(u)||u<=0){p("Enter a whole number of credits");return}k(!0);try{j||(m("Enabling sales for this collection…"),await ye({signer:i.signer,contractAddress:e.contractAddress,chainId:o}),I(!0)),m("Publishing your item…");const b=await xe({signer:i.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:Z.Network.MATIC,chainId:o},usdPrice:u/10,uses:e.remainingSupply,expiresAtMs:Date.now()+Ee});m("Finishing up…"),await ee(b,i.identity),m(null),x(u),P("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:u,price_usd:u/10,listing_type:"primary",is_primary:!0}),G.success(`“${e.name}” is now on sale!`),c.invalidateQueries({queryKey:["publishable-items"]}),c.invalidateQueries({queryKey:["collection-sale-state"]})}catch(b){W(b,{flow:"list_primary"}),P("Shop Listing Failed",{listing_type:"primary",error_code:se(b)}),p(Me(b)),m(null)}finally{k(!1)}}function O(){n(),r(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const L=g?"Listing…":j===!1?"Enable & put on sale":"Put on sale";return S!==null?s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:"It’s on sale! 🎉"}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:["Listed for ",s.jsxs("strong",{children:[s.jsx(q,{className:"ccy-mark"})," ",S]})," · ",e.remainingSupply.toLocaleString()," available"]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,children:"Done"}),s.jsx("button",{className:"btn btn--purple",onClick:O,children:"View in Shop"})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsxs("h2",{className:"modal__title",children:["Publish “",e.name,"”"]}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsxs("p",{className:"muted small",children:["From your collection “",e.collectionName,"” · ",e.remainingSupply.toLocaleString()," available"]}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Price (",C.name,")"]}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:u=>v(u.target.value),disabled:g})]}),s.jsxs("p",{className:"muted small",children:["Priced in whole ",C.name," (1 ",C.nameSingular," = $0.10)."]}),j===!1&&!g?N?s.jsxs("p",{className:"muted small primary-note",children:["First time selling from “",e.collectionName,"”? It needs a one-time approval, then you’ll confirm the listing — two quick confirmations. After this, listing more items from this collection is a single step."]}):s.jsxs("p",{className:"muted small primary-note",children:["First time selling from “",e.collectionName,"”? Setting it up takes a moment — after that, listing more items from this collection is instant."]}):j===!0&&!g?N?s.jsx("p",{className:"muted small primary-note",children:"This collection is ready — publishing is a single confirmation."}):s.jsx("p",{className:"muted small primary-note",children:"This collection is ready — publishing is instant."}):null,_?s.jsx("p",{className:"muted",children:_}):null,f?s.jsx("p",{className:"error",children:f}):null,s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:g,children:"Cancel"}),s.jsx("button",{className:"btn",onClick:T,disabled:g||j===null,children:j===null?"Checking…":L})]})]})})}const Fe=48;function Te(e){return{id:e.id,name:e.name,creator:"",contractAddress:e.contractAddress,itemId:e.itemId,category:e.category,rarity:e.rarity??"common",network:e.network,chainId:e.chainId,thumbnail:e.image,priceCredits:e.listingPrice??0,gender:null,tokenId:e.tokenId}}function J(e){return{id:`${e.contractAddress}-${e.blockchainItemId}`,name:e.name,creator:"",contractAddress:e.contractAddress,itemId:e.blockchainItemId,category:e.category,rarity:e.rarity,network:"MATIC",chainId:V.chainId,thumbnail:e.thumbnail,priceCredits:0,gender:null}}function He(){const{session:e,error:i,signIn:n,restore:c}=ce(),r=U(),l=B(),[v,_]=d.useState(null),[m,f]=d.useState(null),[p,g]=d.useState(null),[k,j]=d.useState(null);function I(a){const t=a.tokenId??a.itemId??"";!a.contractAddress||!t||r(`/item/${a.contractAddress}/${t}`,{state:{item:a}})}async function S(a,t,h){if(e){j(null),g(h);try{const y=await de(a);await he({trade:y,signer:e.signer}),G.success(`“${t}” is no longer for sale.`),await l.invalidateQueries({queryKey:["my-assets",e.address]}),await l.invalidateQueries({queryKey:["collection-sale-state"]})}catch(y){const E=y,M=(E.message??"").toLowerCase(),X=E.code===4001||M.includes("reject")||M.includes("denied");X||W(y,{flow:"remove-listing",tradeId:a}),j(X?"You cancelled the request.":"Couldn't remove the listing — please try again.")}finally{g(null)}}}d.useEffect(()=>{c()},[c]);const x=e==null?void 0:e.address,{items:o,isLoading:N,error:T,hasNextPage:O,isFetchingNextPage:L,fetchNextPage:u}=fe(["my-assets",x],a=>oe(x,{first:Fe,skip:a}).then(t=>({items:t.assets,total:t.total})),{enabled:!!x}),{data:b}=D({queryKey:["importable",x],queryFn:()=>ue(x),enabled:!!x}),R=((b==null?void 0:b.creations.length)??0)+((b==null?void 0:b.owned.length)??0),{data:A,isLoading:te,isError:ie}=D({queryKey:["publishable-items",x],queryFn:()=>Ae(x,e.identity),enabled:!!e,retry:!1}),K=d.useMemo(()=>[...new Set((A??[]).map(a=>a.contractAddress))],[A]),{data:w}=D({queryKey:["collection-sale-state",x,K],enabled:K.length>0,queryFn:async()=>{const a=await Promise.all(K.map(async h=>[h,await me(h)])),t={};for(const[h,y]of a)for(const[E,M]of Object.entries(y))t[`${h}-${E}`]=M;return t}}),Q=a=>w==null?void 0:w[`${a.contractAddress}-${a.blockchainItemId}`],Y=d.useMemo(()=>(A??[]).filter(a=>{var t;return(t=Q(a))==null?void 0:t.isOnSale}),[A,w]),H=d.useMemo(()=>{var t;const a=new Map;for(const h of A??[]){if((t=w==null?void 0:w[`${h.contractAddress}-${h.blockchainItemId}`])!=null&&t.isOnSale)continue;const y=a.get(h.collectionId)??{id:h.collectionId,name:h.collectionName,items:[]};y.items.push(h),a.set(h.collectionId,y)}return[...a.values()]},[A,w]);return e?s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:"My Assets"}),R>0?s.jsxs(re,{className:"import-banner",to:"/import",children:[s.jsx("span",{className:"import-banner__ico","aria-hidden":!0,children:"📦"}),s.jsxs("span",{className:"import-banner__text",children:[s.jsx("strong",{children:"Import your listings"}),s.jsxs("span",{className:"import-banner__sub",children:["You have ",R," item",R===1?"":"s"," for sale elsewhere — bring them into the Shop."]})]}),s.jsx("span",{className:"import-banner__cta",children:"Import"})]}):null,s.jsxs("div",{className:"myassets__section",children:[s.jsxs("div",{className:"myassets__section-head",children:[s.jsx("h2",{className:"myassets__section-title",children:"Items you own"}),s.jsx("p",{className:"myassets__section-sub",children:"Wearables & emotes you’ve bought — resell them in the Shop."})]}),T?s.jsx("p",{className:"error",children:"Couldn’t load your items — please try again."}):null,k?s.jsx("p",{className:"error",children:k}):null,s.jsxs("div",{className:"asset-grid",children:[N?Array.from({length:8}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`sk-${t}`)):o.map(a=>s.jsxs("article",{className:"asset-card asset-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${a.name}`,onClick:()=>I(Te(a))}),s.jsx("div",{className:"asset-card__img",children:a.image?s.jsx("img",{src:a.image,alt:a.name}):null}),s.jsx("div",{className:"asset-card__name",title:a.name,children:a.name}),a.isOnSale?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"asset-card__listed",children:[s.jsxs("span",{className:"asset-card__price",children:[s.jsx(q,{className:"ccy-mark"})," ",a.listingPrice]}),s.jsx("span",{className:"badge",children:"On sale"})]}),s.jsx("button",{className:"btn btn--sm btn--ghost asset-card__remove",disabled:p===a.id||!a.tradeId,onClick:t=>{t.stopPropagation(),a.tradeId&&S(a.tradeId,a.name,a.id)},children:p===a.id?"Removing…":"Remove listing"})]}):s.jsx("button",{className:"btn btn--sm",onClick:t=>{t.stopPropagation(),P("Shop Started Listing",{listing_type:"secondary",item_id:a.itemId??a.tokenId??null}),_(a)},children:"Put on sale"})]},a.id)),L?Array.from({length:4}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`msk-${t}`)):null]}),s.jsx(_e,{hasNextPage:O,isFetching:L,onLoadMore:()=>u()}),!N&&o.length===0?s.jsx("p",{className:"muted",children:"No items in your wardrobe yet."}):null]}),s.jsxs("div",{className:"myassets__section",children:[s.jsxs("div",{className:"myassets__section-head",children:[s.jsx("h2",{className:"myassets__section-title",children:"Your creations"}),s.jsxs("p",{className:"myassets__section-sub",children:["Items you made. Put them on sale in the Shop — set a price in ",C.name," and buyers pay with ",C.name,"."]})]}),te?s.jsx("div",{className:"publish-grid",children:Array.from({length:4}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`pub-sk-${t}`))}):ie?s.jsx("p",{className:"publish-empty",children:"We couldn’t load your collections right now. Please try again in a moment."}):Y.length===0&&H.length===0?s.jsx("p",{className:"publish-empty",children:"You don’t have any items to publish yet."}):s.jsxs(s.Fragment,{children:[Y.length>0?s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:"On sale"}),s.jsx("div",{className:"publish-grid",children:Y.map(a=>{var t;return s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${a.name}`,onClick:()=>I(J(a))}),s.jsx("div",{className:"publish-card__img",children:a.thumbnail?s.jsx("img",{src:a.thumbnail,alt:a.name}):null}),s.jsx("div",{className:"publish-card__name",title:a.name,children:a.name}),s.jsxs("div",{className:"publish-card__listed",children:[s.jsxs("span",{className:"publish-card__price",children:[s.jsx(q,{className:"ccy-mark"})," ",((t=Q(a))==null?void 0:t.priceCredits)??0]}),s.jsx("span",{className:"badge",children:"On sale"})]}),s.jsx("button",{className:"btn btn--sm btn--ghost publish-card__cta",disabled:p===a.id,onClick:h=>{h.stopPropagation();const y=Q(a);y!=null&&y.tradeId&&S(y.tradeId,a.name,a.id)},children:p===a.id?"Removing…":"Remove listing"})]},`${a.contractAddress}-${a.blockchainItemId}`)})})]}):null,H.map(a=>s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:a.name}),s.jsx("div",{className:"publish-grid",children:a.items.map(t=>s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${t.name}`,onClick:()=>I(J(t))}),s.jsx("div",{className:"publish-card__img",children:t.thumbnail?s.jsx("img",{src:t.thumbnail,alt:t.name}):null}),s.jsx("div",{className:"publish-card__name",title:t.name,children:t.name}),s.jsxs("div",{className:"publish-card__meta",children:[s.jsx("span",{className:"publish-chip publish-chip--rarity",children:t.rarity}),s.jsxs("span",{className:"publish-card__supply",children:[t.remainingSupply.toLocaleString()," available"]})]}),s.jsx("button",{className:"btn btn--sm btn--purple publish-card__cta",onClick:h=>{h.stopPropagation(),P("Shop Started Listing",{listing_type:"primary",item_id:t.blockchainItemId}),f(t)},children:"Put on sale"})]},`${t.contractAddress}-${t.blockchainItemId}`))})]},a.id))]})]}),v?s.jsx(Le,{asset:v,session:e,onClose:()=>_(null)}):null,m?s.jsx(qe,{item:m,session:e,onClose:()=>f(null)}):null]}):s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:"My Assets"}),s.jsx("p",{className:"muted",children:"Sign in to sell your items."}),s.jsx("div",{className:"connect-row",children:s.jsx("button",{className:"btn btn--purple",onClick:()=>n(),children:"Sign in"})}),i?s.jsx("p",{className:"error",children:i}):null]})}export{He as MyAssets};
1
+ import{a as U,r as d,j as s,L as re}from"./react-iAgwec9M.js";import{j as Z,i as V,ah as le,w as B,e as q,y as C,p as ee,z as P,o as G,E as W,I as se,c as ce,u as D,aA as oe,h as de,aB as me}from"./index-C1zw_jvz.js";import{f as ue}from"./import-JBeySj3d.js";import{c as he}from"./buy-DEy5oWx-.js";import{a as pe,b as ge,i as be,e as ye,c as xe}from"./trade-encoding-gNFeXeFL.js";import{s as je}from"./wallet-kind-BCHFSy95.js";import{L as _e}from"./LoadMore-8Dx5lULo.js";import{u as fe}from"./useInfiniteGrid-BA1C5BmN.js";import"./ethers-D-4WUfRB.js";import"./mana-rate-C_85VLuc.js";import"./index-BF4WrGCQ.js";const F=()=>`${V.builderServerUrl}/v1`;function ae(e){return Array.isArray(e)?e:"results"in e&&Array.isArray(e.results)?e.results:"data"in e&&Array.isArray(e.data)?e.data:[]}async function ne(e,i){const n=await le(e,{method:"GET",identity:i,metadata:{}});if(!n.ok)throw new Error(`builder-server ${n.status}: ${await n.text()}`);const c=await n.json();return c.data??c}function Ne(e,i){const n=i-e;return n>0?n:0}function ve(e){var i,n,c,r,l;return((n=(i=e.data)==null?void 0:i.wearable)==null?void 0:n.category)??((r=(c=e.data)==null?void 0:c.emote)==null?void 0:r.category)??((l=e.data)==null?void 0:l.category)??e.type??"wearable"}function z(e){return`${F()}/storage/contents/${e}`}function $(e,i){if(!e)return"";if(/^https?:\/\//.test(e))return e;const n=i==null?void 0:i[e];return n?z(n):/^(ba|Qm)/.test(e)?z(e):""}async function Ie(e,i){try{const n=await fetch(`${F()}/items/${e}/${i}/contents`);if(!n.ok)return{};const c=await n.json();return c.data??c}catch{return{}}}async function ke(e,i,n){const c=$(e.thumbnail,e.contents)||$("thumbnail.png",e.contents);if(c)return c;if(i&&n){const r=await Ie(i,n);return $(e.thumbnail,r)||$("thumbnail.png",r)||$("image.png",r)}return""}async function we(e,i){const n=`${F()}/${e.toLowerCase()}/collections?is_published=true`,c=await ne(n,i);return ae(c).filter(r=>r.is_published&&!!r.contract_address).map(r=>({id:r.id,name:r.name,contractAddress:r.contract_address.toLowerCase(),isPublished:r.is_published,isApproved:r.is_approved,minters:(r.minters??[]).map(l=>l.toLowerCase())}))}async function Ce(e,i){const n=`${F()}/collections/${e.id}/items`,c=await ne(n,i);return(await Promise.all(ae(c).map(async l=>{const v=l.rarity??"common",_=Number(l.total_supply??0)||0;let m=0;try{m=Z.Rarity.getMaxSupply(v)}catch{m=0}const f=(l.contract_address??e.contractAddress).toLowerCase(),p=l.blockchain_item_id??"";return{id:l.id,collectionId:e.id,collectionName:e.name,contractAddress:f,blockchainItemId:p,name:l.name,category:ve(l),rarity:v,thumbnail:await ke(l,f,p),type:l.type??"wearable",isPublished:l.is_published??e.isPublished,isApproved:l.is_approved??e.isApproved,totalSupply:_,maxSupply:m,remainingSupply:Ne(_,m),minters:e.minters}}))).filter(Se)}function Se(e){return e.isPublished&&e.isApproved&&e.blockchainItemId!==""&&e.blockchainItemId!=null&&e.remainingSupply>0}async function Ae(e,i){const n=await we(e,i);return(await Promise.all(n.map(async r=>{try{return await Ce(r,i)}catch{return[]}}))).flat()}const Pe=1e3*60*60*24*182;function $e(e){const i=e,n=(i.message??"").toLowerCase();return i.code===4001||n.includes("reject")||n.includes("denied")||n.includes("cancel")?"You cancelled the request.":"Couldn't list your item — please try again."}function Le({asset:e,session:i,onClose:n}){const c=B(),r=U(),[l,v]=d.useState("10"),[_,m]=d.useState(null),[f,p]=d.useState(null),[g,k]=d.useState(!1),[j,I]=d.useState(null);async function S(){p(null);const o=Number(l);if(!Number.isInteger(o)||o<=0){p("Enter a whole number of credits");return}k(!0);try{m("Getting your item ready…"),await pe({signer:i.signer,contractAddress:e.contractAddress,chainId:e.chainId}),m("Listing your item…");const N=await ge({signer:i.signer,nft:{contractAddress:e.contractAddress,tokenId:e.tokenId,network:e.network,chainId:e.chainId},usdPrice:o/10,expiresAtMs:Date.now()+Pe});m("Publishing…"),await ee(N,i.identity),m(null),I(o),P("Shop Listed Item",{item_id:e.itemId??e.tokenId??null,contract_address:e.contractAddress,price_credits:o,price_usd:o/10,listing_type:"secondary",is_primary:!1}),G.success(`“${e.name}” is now on sale!`),c.invalidateQueries({queryKey:["my-assets",i.address]})}catch(N){W(N,{flow:"list_secondary"}),P("Shop Listing Failed",{listing_type:"secondary",error_code:se(N)}),p($e(N)),m(null)}finally{k(!1)}}function x(){n(),r(`/item/${e.contractAddress}/${e.tokenId}`)}return j!==null?s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:"It’s on sale! 🎉"}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:["Listed for ",s.jsxs("strong",{children:[s.jsx(q,{className:"ccy-mark"})," ",j]})]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,children:"Done"}),s.jsx("button",{className:"btn btn--purple",onClick:x,children:"View in Shop"})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsxs("h2",{className:"modal__title",children:["List “",e.name,"”"]}),e.image?s.jsx("img",{className:"modal__img",src:e.image,alt:e.name}):null,s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Price (",C.name,")"]}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:o=>v(o.target.value),disabled:g})]}),s.jsxs("p",{className:"muted small",children:["Priced in whole ",C.name," (1 ",C.nameSingular," = $0.10)."]}),_?s.jsx("p",{className:"muted",children:_}):null,f?s.jsx("p",{className:"error",children:f}):null,s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:g,children:"Cancel"}),s.jsx("button",{className:"btn",onClick:S,disabled:g,children:g?"Listing…":"Put on sale"})]})]})})}const Ee=1e3*60*60*24*182;function Me(e){const i=e,n=(i.message??"").toLowerCase();return i.code===4001||n.includes("reject")||n.includes("denied")||n.includes("cancel")?"You cancelled the request.":"Couldn't publish your item — please try again."}function qe({item:e,session:i,onClose:n}){const c=B(),r=U(),[l,v]=d.useState("10"),[_,m]=d.useState(null),[f,p]=d.useState(null),[g,k]=d.useState(!1),[j,I]=d.useState(null),[S,x]=d.useState(null),o=V.chainId,N=je(i.providerType);d.useEffect(()=>{let u=!1;return(async()=>{try{const b=await be({contractAddress:e.contractAddress,chainId:o});u||I(b)}catch{u||I(!1)}})(),()=>{u=!0}},[e.contractAddress,o]);async function T(){p(null);const u=Number(l);if(!Number.isInteger(u)||u<=0){p("Enter a whole number of credits");return}k(!0);try{j||(m("Enabling sales for this collection…"),await ye({signer:i.signer,contractAddress:e.contractAddress,chainId:o}),I(!0)),m("Publishing your item…");const b=await xe({signer:i.signer,item:{contractAddress:e.contractAddress,itemId:e.blockchainItemId,network:Z.Network.MATIC,chainId:o},usdPrice:u/10,uses:e.remainingSupply,expiresAtMs:Date.now()+Ee});m("Finishing up…"),await ee(b,i.identity),m(null),x(u),P("Shop Listed Item",{item_id:e.blockchainItemId,contract_address:e.contractAddress,price_credits:u,price_usd:u/10,listing_type:"primary",is_primary:!0}),G.success(`“${e.name}” is now on sale!`),c.invalidateQueries({queryKey:["publishable-items"]}),c.invalidateQueries({queryKey:["collection-sale-state"]})}catch(b){W(b,{flow:"list_primary"}),P("Shop Listing Failed",{listing_type:"primary",error_code:se(b)}),p(Me(b)),m(null)}finally{k(!1)}}function O(){n(),r(`/item/${e.contractAddress}/${e.blockchainItemId}`)}const L=g?"Listing…":j===!1?"Enable & put on sale":"Put on sale";return S!==null?s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal modal--success",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsx("div",{className:"modal-success__check","aria-hidden":!0,children:"✓"}),s.jsx("h2",{className:"modal__title",children:"It’s on sale! 🎉"}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsx("p",{className:"modal-success__name",children:e.name}),s.jsxs("p",{className:"muted small",children:["Listed for ",s.jsxs("strong",{children:[s.jsx(q,{className:"ccy-mark"})," ",S]})," · ",e.remainingSupply.toLocaleString()," available"]}),s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,children:"Done"}),s.jsx("button",{className:"btn btn--purple",onClick:O,children:"View in Shop"})]})]})}):s.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:s.jsxs("div",{className:"modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true",children:[s.jsxs("h2",{className:"modal__title",children:["Publish “",e.name,"”"]}),e.thumbnail?s.jsx("img",{className:"modal__img",src:e.thumbnail,alt:e.name}):null,s.jsxs("p",{className:"muted small",children:["From your collection “",e.collectionName,"” · ",e.remainingSupply.toLocaleString()," available"]}),s.jsxs("label",{className:"field",children:[s.jsxs("span",{children:["Price (",C.name,")"]}),s.jsx("input",{type:"number",min:"1",step:"1",value:l,onChange:u=>v(u.target.value),disabled:g})]}),s.jsxs("p",{className:"muted small",children:["Priced in whole ",C.name," (1 ",C.nameSingular," = $0.10)."]}),j===!1&&!g?N?s.jsxs("p",{className:"muted small primary-note",children:["First time selling from “",e.collectionName,"”? It needs a one-time approval, then you’ll confirm the listing — two quick confirmations. After this, listing more items from this collection is a single step."]}):s.jsxs("p",{className:"muted small primary-note",children:["First time selling from “",e.collectionName,"”? Setting it up takes a moment — after that, listing more items from this collection is instant."]}):j===!0&&!g?N?s.jsx("p",{className:"muted small primary-note",children:"This collection is ready — publishing is a single confirmation."}):s.jsx("p",{className:"muted small primary-note",children:"This collection is ready — publishing is instant."}):null,_?s.jsx("p",{className:"muted",children:_}):null,f?s.jsx("p",{className:"error",children:f}):null,s.jsxs("div",{className:"modal__actions",children:[s.jsx("button",{className:"btn btn--ghost",onClick:n,disabled:g,children:"Cancel"}),s.jsx("button",{className:"btn",onClick:T,disabled:g||j===null,children:j===null?"Checking…":L})]})]})})}const Fe=48;function Te(e){return{id:e.id,name:e.name,creator:"",contractAddress:e.contractAddress,itemId:e.itemId,category:e.category,rarity:e.rarity??"common",network:e.network,chainId:e.chainId,thumbnail:e.image,priceCredits:e.listingPrice??0,gender:null,tokenId:e.tokenId}}function J(e){return{id:`${e.contractAddress}-${e.blockchainItemId}`,name:e.name,creator:"",contractAddress:e.contractAddress,itemId:e.blockchainItemId,category:e.category,rarity:e.rarity,network:"MATIC",chainId:V.chainId,thumbnail:e.thumbnail,priceCredits:0,gender:null}}function He(){const{session:e,error:i,signIn:n,restore:c}=ce(),r=U(),l=B(),[v,_]=d.useState(null),[m,f]=d.useState(null),[p,g]=d.useState(null),[k,j]=d.useState(null);function I(a){const t=a.tokenId??a.itemId??"";!a.contractAddress||!t||r(`/item/${a.contractAddress}/${t}`,{state:{item:a}})}async function S(a,t,h){if(e){j(null),g(h);try{const y=await de(a);await he({trade:y,signer:e.signer}),G.success(`“${t}” is no longer for sale.`),await l.invalidateQueries({queryKey:["my-assets",e.address]}),await l.invalidateQueries({queryKey:["collection-sale-state"]})}catch(y){const E=y,M=(E.message??"").toLowerCase(),X=E.code===4001||M.includes("reject")||M.includes("denied");X||W(y,{flow:"remove-listing",tradeId:a}),j(X?"You cancelled the request.":"Couldn't remove the listing — please try again.")}finally{g(null)}}}d.useEffect(()=>{c()},[c]);const x=e==null?void 0:e.address,{items:o,isLoading:N,error:T,hasNextPage:O,isFetchingNextPage:L,fetchNextPage:u}=fe(["my-assets",x],a=>oe(x,{first:Fe,skip:a}).then(t=>({items:t.assets,total:t.total})),{enabled:!!x}),{data:b}=D({queryKey:["importable",x],queryFn:()=>ue(x),enabled:!!x}),R=((b==null?void 0:b.creations.length)??0)+((b==null?void 0:b.owned.length)??0),{data:A,isLoading:te,isError:ie}=D({queryKey:["publishable-items",x],queryFn:()=>Ae(x,e.identity),enabled:!!e,retry:!1}),K=d.useMemo(()=>[...new Set((A??[]).map(a=>a.contractAddress))],[A]),{data:w}=D({queryKey:["collection-sale-state",x,K],enabled:K.length>0,queryFn:async()=>{const a=await Promise.all(K.map(async h=>[h,await me(h)])),t={};for(const[h,y]of a)for(const[E,M]of Object.entries(y))t[`${h}-${E}`]=M;return t}}),Q=a=>w==null?void 0:w[`${a.contractAddress}-${a.blockchainItemId}`],Y=d.useMemo(()=>(A??[]).filter(a=>{var t;return(t=Q(a))==null?void 0:t.isOnSale}),[A,w]),H=d.useMemo(()=>{var t;const a=new Map;for(const h of A??[]){if((t=w==null?void 0:w[`${h.contractAddress}-${h.blockchainItemId}`])!=null&&t.isOnSale)continue;const y=a.get(h.collectionId)??{id:h.collectionId,name:h.collectionName,items:[]};y.items.push(h),a.set(h.collectionId,y)}return[...a.values()]},[A,w]);return e?s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:"My Assets"}),R>0?s.jsxs(re,{className:"import-banner",to:"/import",children:[s.jsx("span",{className:"import-banner__ico","aria-hidden":!0,children:"📦"}),s.jsxs("span",{className:"import-banner__text",children:[s.jsx("strong",{children:"Import your listings"}),s.jsxs("span",{className:"import-banner__sub",children:["You have ",R," item",R===1?"":"s"," for sale elsewhere — bring them into the Shop."]})]}),s.jsx("span",{className:"import-banner__cta",children:"Import"})]}):null,s.jsxs("div",{className:"myassets__section",children:[s.jsxs("div",{className:"myassets__section-head",children:[s.jsx("h2",{className:"myassets__section-title",children:"Items you own"}),s.jsx("p",{className:"myassets__section-sub",children:"Wearables & emotes you’ve bought — resell them in the Shop."})]}),T?s.jsx("p",{className:"error",children:"Couldn’t load your items — please try again."}):null,k?s.jsx("p",{className:"error",children:k}):null,s.jsxs("div",{className:"asset-grid",children:[N?Array.from({length:8}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`sk-${t}`)):o.map(a=>s.jsxs("article",{className:"asset-card asset-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${a.name}`,onClick:()=>I(Te(a))}),s.jsx("div",{className:"asset-card__img",children:a.image?s.jsx("img",{src:a.image,alt:a.name}):null}),s.jsx("div",{className:"asset-card__name",title:a.name,children:a.name}),a.isOnSale?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"asset-card__listed",children:[s.jsxs("span",{className:"asset-card__price",children:[s.jsx(q,{className:"ccy-mark"})," ",a.listingPrice]}),s.jsx("span",{className:"badge",children:"On sale"})]}),s.jsx("button",{className:"btn btn--sm btn--ghost asset-card__remove",disabled:p===a.id||!a.tradeId,onClick:t=>{t.stopPropagation(),a.tradeId&&S(a.tradeId,a.name,a.id)},children:p===a.id?"Removing…":"Remove listing"})]}):s.jsx("button",{className:"btn btn--sm",onClick:t=>{t.stopPropagation(),P("Shop Started Listing",{listing_type:"secondary",item_id:a.itemId??a.tokenId??null}),_(a)},children:"Put on sale"})]},a.id)),L?Array.from({length:4}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`msk-${t}`)):null]}),s.jsx(_e,{hasNextPage:O,isFetching:L,onLoadMore:()=>u()}),!N&&o.length===0?s.jsx("p",{className:"muted",children:"No items in your wardrobe yet."}):null]}),s.jsxs("div",{className:"myassets__section",children:[s.jsxs("div",{className:"myassets__section-head",children:[s.jsx("h2",{className:"myassets__section-title",children:"Your creations"}),s.jsxs("p",{className:"myassets__section-sub",children:["Items you made. Put them on sale in the Shop — set a price in ",C.name," and buyers pay with ",C.name,"."]})]}),te?s.jsx("div",{className:"publish-grid",children:Array.from({length:4}).map((a,t)=>s.jsx("div",{className:"asset-card asset-card--skeleton"},`pub-sk-${t}`))}):ie?s.jsx("p",{className:"publish-empty",children:"We couldn’t load your collections right now. Please try again in a moment."}):Y.length===0&&H.length===0?s.jsx("p",{className:"publish-empty",children:"You don’t have any items to publish yet."}):s.jsxs(s.Fragment,{children:[Y.length>0?s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:"On sale"}),s.jsx("div",{className:"publish-grid",children:Y.map(a=>{var t;return s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${a.name}`,onClick:()=>I(J(a))}),s.jsx("div",{className:"publish-card__img",children:a.thumbnail?s.jsx("img",{src:a.thumbnail,alt:a.name}):null}),s.jsx("div",{className:"publish-card__name",title:a.name,children:a.name}),s.jsxs("div",{className:"publish-card__listed",children:[s.jsxs("span",{className:"publish-card__price",children:[s.jsx(q,{className:"ccy-mark"})," ",((t=Q(a))==null?void 0:t.priceCredits)??0]}),s.jsx("span",{className:"badge",children:"On sale"})]}),s.jsx("button",{className:"btn btn--sm btn--ghost publish-card__cta",disabled:p===a.id,onClick:h=>{h.stopPropagation();const y=Q(a);y!=null&&y.tradeId&&S(y.tradeId,a.name,a.id)},children:p===a.id?"Removing…":"Remove listing"})]},`${a.contractAddress}-${a.blockchainItemId}`)})})]}):null,H.map(a=>s.jsxs("div",{className:"creations-collection",children:[s.jsx("h3",{className:"creations-collection__name",children:a.name}),s.jsx("div",{className:"publish-grid",children:a.items.map(t=>s.jsxs("article",{className:"publish-card publish-card--link",children:[s.jsx("button",{className:"card-link-overlay","aria-label":`View ${t.name}`,onClick:()=>I(J(t))}),s.jsx("div",{className:"publish-card__img",children:t.thumbnail?s.jsx("img",{src:t.thumbnail,alt:t.name}):null}),s.jsx("div",{className:"publish-card__name",title:t.name,children:t.name}),s.jsxs("div",{className:"publish-card__meta",children:[s.jsx("span",{className:"publish-chip publish-chip--rarity",children:t.rarity}),s.jsxs("span",{className:"publish-card__supply",children:[t.remainingSupply.toLocaleString()," available"]})]}),s.jsx("button",{className:"btn btn--sm btn--purple publish-card__cta",onClick:h=>{h.stopPropagation(),P("Shop Started Listing",{listing_type:"primary",item_id:t.blockchainItemId}),f(t)},children:"Put on sale"})]},`${t.contractAddress}-${t.blockchainItemId}`))})]},a.id))]})]}),v?s.jsx(Le,{asset:v,session:e,onClose:()=>_(null)}):null,m?s.jsx(qe,{item:m,session:e,onClose:()=>f(null)}):null]}):s.jsxs("section",{className:"myassets",children:[s.jsx("h1",{children:"My Assets"}),s.jsx("p",{className:"muted",children:"Sign in to sell your items."}),s.jsx("div",{className:"connect-row",children:s.jsx("button",{className:"btn btn--purple",onClick:()=>n(),children:"Sign in"})}),i?s.jsx("p",{className:"error",children:i}):null]})}export{He as MyAssets};
@@ -1 +1 @@
1
- import{r as o,j as s,L as n}from"./react-iAgwec9M.js";import{b as c,A as l}from"./index-BJ_QKI7g.js";import{L as m}from"./LoadMore-8Dx5lULo.js";import"./ethers-D-4WUfRB.js";const i=24;function v(){const t=c(e=>Object.values(e.items)),[a,r]=o.useState(i);return t.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx("span",{className:"ico ico-heart favorites-empty__ico","aria-hidden":!0}),s.jsx("p",{className:"favorites-empty__title",children:"No favorites yet"}),s.jsx("p",{className:"muted",children:"Tap the heart on any item to save it here."}),s.jsx(n,{className:"btn btn--purple",to:"/assets",children:"Browse Collectibles"})]}):s.jsxs("section",{className:"favorites",children:[s.jsxs("div",{className:"favorites__head",children:[s.jsx("h1",{children:"My Favorites"}),s.jsxs("span",{className:"favorites__count",children:[t.length," item",t.length>1?"s":""]})]}),s.jsx("div",{className:"grid",children:t.slice(0,a).map(e=>s.jsx(l,{item:e},e.id))}),s.jsx(m,{hasNextPage:a<t.length,isFetching:!1,onLoadMore:()=>r(e=>e+i)})]})}export{v as MyFavorites};
1
+ import{r as o,j as s,L as n}from"./react-iAgwec9M.js";import{b as c,A as l}from"./index-C1zw_jvz.js";import{L as m}from"./LoadMore-8Dx5lULo.js";import"./ethers-D-4WUfRB.js";const i=24;function v(){const t=c(e=>Object.values(e.items)),[a,r]=o.useState(i);return t.length===0?s.jsxs("div",{className:"favorites-empty",children:[s.jsx("span",{className:"ico ico-heart favorites-empty__ico","aria-hidden":!0}),s.jsx("p",{className:"favorites-empty__title",children:"No favorites yet"}),s.jsx("p",{className:"muted",children:"Tap the heart on any item to save it here."}),s.jsx(n,{className:"btn btn--purple",to:"/assets",children:"Browse Collectibles"})]}):s.jsxs("section",{className:"favorites",children:[s.jsxs("div",{className:"favorites__head",children:[s.jsx("h1",{children:"My Favorites"}),s.jsxs("span",{className:"favorites__count",children:[t.length," item",t.length>1?"s":""]})]}),s.jsx("div",{className:"grid",children:t.slice(0,a).map(e=>s.jsx(l,{item:e},e.id))}),s.jsx(m,{hasNextPage:a<t.length,isFetching:!1,onLoadMore:()=>r(e=>e+i)})]})}export{v as MyFavorites};