@dcl/shop 1.9.3-32728272723.commit-675c39d → 1.9.3-32743160136.commit-b84a6df

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 (255) hide show
  1. package/_assets/{Activity-wiQBOvJZ.js → Activity-QAKKW4Vj.js} +9 -9
  2. package/_assets/{AnimatedBackground-RthAgKMY.js → AnimatedBackground-RzTR5pnn.js} +6 -6
  3. package/_assets/{Assets-Cn69OQsu.js → Assets-DL6YgWYt.js} +21 -21
  4. package/_assets/{Authorizations-DQkwMniZ.js → Authorizations-fcwMQvEN.js} +2 -2
  5. package/_assets/Cart-D2KxXi3r.js +748 -0
  6. package/_assets/{Collection-DQS4BBsd.js → Collection-BbupMgKn.js} +9 -9
  7. package/_assets/CollectionCarousel-KtrjUFTp.js +834 -0
  8. package/_assets/{Confetti-CnwifU5L.js → Confetti-B_SGZDIW.js} +4 -4
  9. package/_assets/{ConstantsUtil-Cnnb7DY5.js → ConstantsUtil-BUQvDf5H.js} +2 -2
  10. package/_assets/{ContentClient-Z56PWhtK.js → ContentClient-BAcYQSIO.js} +2 -2
  11. package/_assets/{Creator-Z-kdGyX0.js → Creator-B02TUwGa.js} +11 -11
  12. package/_assets/{DeploymentBuilder-C1TR_QtL.js → DeploymentBuilder-B77L0L_H.js} +2 -2
  13. package/_assets/{EmotePlaybackBar-B4bFL84Q.js → EmotePlaybackBar-6-X8QjVO.js} +4 -4
  14. package/_assets/{ErrorNotice-DB0NutQX.js → ErrorNotice-BVVq2BBw.js} +2 -2
  15. package/_assets/{ExchangeController-DQsWu6kG.js → ExchangeController-BKu6gC8H.js} +2 -2
  16. package/_assets/{Faq-B-KjBhpt.js → Faq-D9k3ABvT.js} +2 -2
  17. package/_assets/{GetCredits-B7o-ahFl.js → GetCredits-Dpn8gB9T.js} +79 -34
  18. package/_assets/Grow-tHCcyL-r.js +2 -0
  19. package/_assets/{HelpersUtil-CDlApuwl.js → HelpersUtil-zX6_tyAi.js} +2 -2
  20. package/_assets/ItemDetail-D4i816QV.js +3671 -0
  21. package/_assets/{LoadMore-yHCzMVX9.js → LoadMore-BrnolAMt.js} +2 -2
  22. package/_assets/{ManaPricingBanner.styles-Bkk6IoAa.js → ManaPricingBanner.styles-CLIn26ZQ.js} +9 -9
  23. package/_assets/{MyAssets-DPBr4EqO.js → MyAssets-0hzzKkK-.js} +4 -4
  24. package/_assets/{MyFavorites-DIh3AJ72.js → MyFavorites-DI52kW4T.js} +6 -6
  25. package/_assets/{NetworkUtil-YfaeL3XJ.js → NetworkUtil-B_9c-U8Q.js} +2 -2
  26. package/_assets/{NotFound-EGQC517r.js → NotFound-OU0x4dCG.js} +2 -2
  27. package/_assets/NotificationsBell-B31uvOC8.js +142 -0
  28. package/_assets/{OutfitDetail-D2gRsLmD.js → OutfitDetail-U5OMt9MB.js} +10 -10
  29. package/_assets/{OutfitPreview-CFbrD7aI.js → OutfitPreview-fsnJyCY_.js} +3 -3
  30. package/_assets/{OutfitStudio-BkXEDStE.js → OutfitStudio-1fjhOirp.js} +10 -10
  31. package/_assets/{StoreSettings-BTzgYL0y.js → StoreSettings-Dtc2cFNu.js} +2 -2
  32. package/_assets/{Success-x2GWyHwZ.js → Success-DmniYPt7.js} +2 -2
  33. package/_assets/{SwapController-CmNQixyT.js → SwapController-DAEACGPq.js} +2 -2
  34. package/_assets/{TradeService-DNGia0OJ.js → TradeService-BcpRovgR.js} +2 -2
  35. package/_assets/{W3MFrameProviderSingleton-BT9sgsfW.js → W3MFrameProviderSingleton-BClgaXM6.js} +4 -4
  36. package/_assets/{WebCryptoP256-V66v1WyH.js → WebCryptoP256-Bzqct4AR.js} +2 -2
  37. package/_assets/authorizations-Bq00FRrP.js +2 -0
  38. package/_assets/{basic-S2U2MIXo.js → basic-v2yN93R9.js} +2 -2
  39. package/_assets/{biconomy-B3GclgM5.js → biconomy-BbyLh2rY.js} +2 -2
  40. package/_assets/{browseLayout.styles-DdoX94ao.js → browseLayout.styles-DsbssS1X.js} +8 -8
  41. package/_assets/{browser-Yr5YHIXb.js → browser-B3a9BIYV.js} +2 -2
  42. package/_assets/{browser-ponyfill-7e35X2wE.js → browser-ponyfill-Dukw0TjS.js} +2 -2
  43. package/_assets/{builder-ZuQFtHN7.js → builder-DysINipi.js} +2 -2
  44. package/_assets/buy-DZz-IuoV.js +2 -0
  45. package/_assets/{buy-gasless-C-8JY4JE.js → buy-gasless-B29llLau.js} +2 -2
  46. package/_assets/{categories-orB_QPDP.js → categories-ByT980ve.js} +2 -2
  47. package/_assets/{ccip-GIdsv8rm.js → ccip-BRPx_ZlG.js} +2 -2
  48. package/_assets/{ccip-BmDS_bTy.js → ccip-DYkZfgm6.js} +2 -2
  49. package/_assets/{chains-Ca51A7Ks.js → chains-DZroLyZV.js} +2 -2
  50. package/_assets/{collectionPage.styles-Dh90G62H.js → collectionPage.styles-Djchm0Nm.js} +6 -6
  51. package/_assets/{common-DQUwV3Gu.js → common-DYJHHIB9.js} +2 -2
  52. package/_assets/{controller-BJsJcDQe.js → controller-BOWAb87t.js} +3 -3
  53. package/_assets/{core-Ctn9qkOR.js → core-Bw4v_vQY.js} +5 -5
  54. package/_assets/createSvgIcon-CaKhLrQG.js +75 -0
  55. package/_assets/{custom-Do5QPS7e.js → custom-BzZXMtsn.js} +2 -2
  56. package/_assets/{data-capture-CgHHR5Aj.js → data-capture-BRuFpOfW.js} +2 -2
  57. package/_assets/{dcl-schemas-BrhDU8Ob.js → dcl-schemas-CN-1-wGb.js} +2 -2
  58. package/_assets/{decimals-CnKheYha.js → decimals-BPF9JuRG.js} +2 -2
  59. package/_assets/{decimals-BW_s4s-s.js → decimals-BlaBlIXg.js} +2 -2
  60. package/_assets/{detectExtension-Bfwwsutx.js → detectExtension-Cpjv7w9d.js} +2 -2
  61. package/_assets/{disposePreview-DqlQXFBW.js → disposePreview-DvbibLHk.js} +2 -2
  62. package/_assets/{email-DUmzs_tF.js → email-DRfEf-Gg.js} +2 -2
  63. package/_assets/{embedded-wallet-Bv1KSoBX.js → embedded-wallet-k-rK_Tzp.js} +2 -2
  64. package/_assets/emotion-styled.browser.esm-7mw60jip.js +2 -0
  65. package/_assets/{engine-DEYwEW_p.js → engine-Ds8WBhQq.js} +2 -2
  66. package/_assets/{errors-CHeQ52EG.js → errors-DUsd8eGX.js} +2 -2
  67. package/_assets/{estimate-l1-fee-DtiVNA82.js → estimate-l1-fee-BqWlqB6P.js} +2 -2
  68. package/_assets/{eth_estimateGas-C0J4pFj3.js → eth_estimateGas-Dj0RarmM.js} +2 -2
  69. package/_assets/{eth_getStorageAt-D_VuzNfo.js → eth_getStorageAt-C2kSbou7.js} +2 -2
  70. package/_assets/{eth_getTransactionCount-C9QdrrgN.js → eth_getTransactionCount-DxqQ7LF-.js} +2 -2
  71. package/_assets/{ethereum-D98YbqZW.js → ethereum-CMQLQ53m.js} +2 -2
  72. package/_assets/{ethers-13WTbgZT.js → ethers-3hUTVH_L.js} +2 -2
  73. package/_assets/{events-Bfmg7Rrt.js → events-BAvGtdFA.js} +2 -2
  74. package/_assets/{execute-BKduu7xa.js → execute-B-kQuKck.js} +3 -3
  75. package/_assets/{extractIPFS-BoSTMqtl.js → extractIPFS-C9V9S9Vx.js} +2 -2
  76. package/_assets/{features-CiOwD_FL.js → features-D9eM9k8d.js} +2 -2
  77. package/_assets/{fetchTokenMetadata-CYea_Ae0.js → fetchTokenMetadata-1AbceoZv.js} +3 -3
  78. package/_assets/{field.styles-1ph2By3r.js → field.styles-DwpKCezV.js} +2 -2
  79. package/_assets/{fortmatic-FXRUPZdn.js → fortmatic-CeTGzQ72.js} +2 -2
  80. package/_assets/{get-bytecode-DsFs5fZG.js → get-bytecode-B4ZUFLU7.js} +2 -2
  81. package/_assets/{get-ecosystem-wallet-info-CrXYfBwJ.js → get-ecosystem-wallet-info-Da9XiCOd.js} +2 -2
  82. package/_assets/{getBalance-CkyNP7Sk.js → getBalance-CJap-JGo.js} +3 -3
  83. package/_assets/{getInstalledModules-BJjlqPjw.js → getInstalledModules-Do6d5mXY.js} +2 -2
  84. package/_assets/getNFT-CAMw_8Xw.js +3 -0
  85. package/_assets/getNFT-CLshkBBY.js +2 -0
  86. package/_assets/{grid.styles-xN-7VEdz.js → grid.styles-C5Gu9fMU.js} +2 -2
  87. package/_assets/{hashTypedData-DKoi13N6.js → hashTypedData-BUtmFCdm.js} +2 -2
  88. package/_assets/{hashTypedData-Csm33HiU.js → hashTypedData-Vr7bI_tu.js} +2 -2
  89. package/_assets/{in-app-DiZ1z2bU.js → in-app-nwWqF9c8.js} +2 -2
  90. package/_assets/{in-app-wallet-calls-D_BXC_ak.js → in-app-wallet-calls-N7orXys6.js} +2 -2
  91. package/_assets/{index-_QehBQtS.js → index-7V82xXhB.js} +2 -2
  92. package/_assets/{index-BMZPGByj.js → index-8nD-GtHU.js} +2 -2
  93. package/_assets/{index-CONlhNBW.js → index-9Kw5Rztb.js} +2 -2
  94. package/_assets/{index-CjDgPW_g.js → index-Ardj6yky.js} +2 -2
  95. package/_assets/{index-D_MyRErw.js → index-B-dIqjhn.js} +13 -13
  96. package/_assets/{index-Lagqhz0D.js → index-B5BlLi8g.js} +2 -2
  97. package/_assets/{index-C66Uqb3h.js → index-BASnFl3W.js} +4 -4
  98. package/_assets/{index-BbfrgiQ2.js → index-BMDWzXEE.js} +3 -3
  99. package/_assets/{index-z50ayPbm.js → index-BQ9y6ZaA.js} +2 -2
  100. package/_assets/{index-FVl1HwRo.js → index-BQb3Wk5r.js} +2 -2
  101. package/_assets/index-BRQaaXvE.js +29 -0
  102. package/_assets/{index-DnFe-nlA.js → index-BRZfndrv.js} +5 -5
  103. package/_assets/{index-BvWdVY3S.js → index-BV9RyOEp.js} +2 -2
  104. package/_assets/{index-C1mRjPET.js → index-BYVFrjrb.js} +3 -3
  105. package/_assets/{index-CE_9QqpM.js → index-BaO4bMuZ.js} +2 -2
  106. package/_assets/{index-CoGsK86G.js → index-BdeCgajO.js} +2 -2
  107. package/_assets/{index-Ceh2dU74.js → index-Bk-sREBo.js} +3 -3
  108. package/_assets/{index-D3G8Fdkz.js → index-Bl1ek_ne.js} +8 -8
  109. package/_assets/{index-YXtOvMCg.js → index-BmpxmYmS.js} +6 -6
  110. package/_assets/{index-D12w4DAh.js → index-C24_ekJb.js} +3 -3
  111. package/_assets/{index-pU44WsoO.js → index-C5IAd4qq.js} +2 -2
  112. package/_assets/{index-FoEkr-Gx.js → index-C5ykZ17C.js} +4 -4
  113. package/_assets/{index-B-VnvrXk.js → index-C6yqnRel.js} +2 -2
  114. package/_assets/{index-BLCZsXPx.js → index-C7ZiEK10.js} +5 -5
  115. package/_assets/index-C7dG5MlC.js +2 -0
  116. package/_assets/{index-CaUZtRY4.js → index-C8CrTE0H.js} +4 -4
  117. package/_assets/{index-DK3Qx85d.js → index-CIonCZaH.js} +2 -2
  118. package/_assets/{index-DoiWiVM0.js → index-CKPrX-hd.js} +2 -2
  119. package/_assets/{index-1fc9icEt.js → index-CLkhQUQ6.js} +2 -2
  120. package/_assets/{index-jlD47_Vi.js → index-CPFt5W7a.js} +2 -2
  121. package/_assets/index-CTkFcWFW.js +31 -0
  122. package/_assets/{index-BiOg6MaL.js → index-CU8_wCvl.js} +2 -2
  123. package/_assets/{index-DHZrYG6U.js → index-CW_28RYg.js} +2 -2
  124. package/_assets/{index-ClWm5BzQ.js → index-Casvq6JB.js} +5 -5
  125. package/_assets/{index-C0UpQJ3R.js → index-CeMUz1Vt.js} +2 -2
  126. package/_assets/index-CoOoDCex.js +3 -0
  127. package/_assets/{index-Dnn6D-aI.js → index-CqtWNRv-.js} +4 -4
  128. package/_assets/{index-Cw7Ynnas.js → index-CyD5pQGT.js} +6 -6
  129. package/_assets/{index-CwJ5xwPT.js → index-CyMO1hqV.js} +2 -2
  130. package/_assets/{index-B9dxuRhp.js → index-CzJG485v.js} +4 -4
  131. package/_assets/index-D165_lhw.js +2 -0
  132. package/_assets/{index-Ch6rsL_B.js → index-D7jo6ksh.js} +3 -3
  133. package/_assets/{index-BIH4pLmB.js → index-DL9BGlLg.js} +9 -9
  134. package/_assets/{index-sUOR8hyr.js → index-DN4pkOIt.js} +2 -2
  135. package/_assets/{index-UB89SKfu.js → index-DUZQbok2.js} +2 -2
  136. package/_assets/{index-BIuwf8hd.js → index-DUiscdsk.js} +2 -2
  137. package/_assets/{index-C_ZwEBoo.js → index-DaYk4f8v.js} +4 -4
  138. package/_assets/{index-3lrmnEWw.js → index-DcHviZ_A.js} +2 -2
  139. package/_assets/{index-CWGgaCTU.js → index-DrBZNwIH.js} +9 -9
  140. package/_assets/{index-B_ujx6Xm.js → index-DxNecTCT.js} +3 -3
  141. package/_assets/{index-DOlrtt3M.js → index-DxcjAnEQ.js} +6 -6
  142. package/_assets/{index-BW-svIkd.js → index-DyxdGNpO.js} +2 -2
  143. package/_assets/{index-CHQCW37d.js → index-FcM585jS.js} +2 -2
  144. package/_assets/{index-Clnwiuqm.js → index-GpII3RQe.js} +7 -7
  145. package/_assets/{index-D3e9i18Z.js → index-N6bLRe9n.js} +2 -2
  146. package/_assets/{index-nbIX4Ytl.js → index-NxvojHai.js} +3 -3
  147. package/_assets/{index-Iy_1muGf.js → index-PD4xoiKM.js} +2 -2
  148. package/_assets/{index-DbYBtUCy.js → index-ZsDPPnJO.js} +2 -2
  149. package/_assets/{index-8ghXpAgH.js → index-_r_ufyIV.js} +5 -5
  150. package/_assets/{index-BurKCVaZ.js → index-arksk5Cj.js} +3 -3
  151. package/_assets/{index-VFfx8OgX.js → index-eBmw3fXZ.js} +3 -3
  152. package/_assets/{index-D7I_eFC7.js → index-eN8iGXCt.js} +2 -2
  153. package/_assets/{index-BBW9JwC1.js → index-hVKWyt40.js} +2 -2
  154. package/_assets/{index-DHDyWXF3.js → index-j4G49haZ.js} +2 -2
  155. package/_assets/{index-C4ca7Vt-.js → index-mJBnQ2Dj.js} +2 -2
  156. package/_assets/{index-crQcv9Ov.js → index-o602nshH.js} +2 -2
  157. package/_assets/{index-BqvS0YcJ.js → index-otS3prm0.js} +2 -2
  158. package/_assets/{index.es-CgnmJs4M.js → index.es-BYlgbFaR.js} +5 -5
  159. package/_assets/{index.es-BEhJZqhV.js → index.es-Cv5GXMGv.js} +2 -2
  160. package/_assets/{index.es-ro7appUX.js → index.es-D6r5jb9y.js} +2 -2
  161. package/_assets/{index.es-eBlnNE_8.js → index.es-N9rocrKW.js} +2 -2
  162. package/_assets/{items-empty-DO2UT8K2.js → items-empty-DHu8EAf0.js} +2 -2
  163. package/_assets/{jump-Bhj8Kohh.js → jump-CZr_KgFH.js} +2 -2
  164. package/_assets/{linkAccount-BRQ8Ev1P.js → linkAccount-DDn4BnMD.js} +2 -2
  165. package/_assets/{localBatchGatewayRequest-B4LC5KML.js → localBatchGatewayRequest-D-Y_ipMD.js} +2 -2
  166. package/_assets/{native-Bvt0W0jA.js → native-EhJtXu3y.js} +2 -2
  167. package/_assets/{networks-CaAL5XAk.js → networks-Bu5S3nZh.js} +2 -2
  168. package/_assets/{onramp-Cp8_0NX3.js → onramp-DafTmJEE.js} +2 -2
  169. package/_assets/{openzeppelin-DW0vhDwF.js → openzeppelin-DrjFStIu.js} +2 -2
  170. package/_assets/{ownerOf-DHZ-ngeW.js → ownerOf-C6L3B_bp.js} +2 -2
  171. package/_assets/{parseNft-CEwkovMr.js → parseNft-Blq_Sjtq.js} +3 -3
  172. package/_assets/{parseSignature-ifLHrMWV.js → parseSignature-GSnulywH.js} +4 -4
  173. package/_assets/{parseSignature-Duwa-2pX.js → parseSignature-Q7C9dXBW.js} +2 -2
  174. package/_assets/passkeys-BKUjWMsd.js +2 -0
  175. package/_assets/{pay-with-exchange-Yn92eb0n.js → pay-with-exchange-ChWZJZmh.js} +2 -2
  176. package/_assets/{prepare-contract-call-BZBDdYDD.js → prepare-contract-call-B2J2TZU4.js} +2 -2
  177. package/_assets/{qr-overlay-8DGBc2-N.js → qr-overlay-Dp5EKTi4.js} +4 -4
  178. package/_assets/{react-DjOKjwAj.js → react-DcSw8tCD.js} +2 -2
  179. package/_assets/{receive-CN3FejJq.js → receive-jGBB6R5D.js} +2 -2
  180. package/_assets/{resolveImplementation-Ckhnk_N2.js → resolveImplementation-mqgPq49O.js} +2 -2
  181. package/_assets/{resume-buy--hmhwjSU.js → resume-buy-CEzVJZQm.js} +2 -2
  182. package/_assets/{rpc-C6etA5rL.js → rpc-DYUIG9Ju.js} +2 -2
  183. package/_assets/{sales-empty-C0l-l75T.js → sales-empty-Vn4xVfP7.js} +2 -2
  184. package/_assets/{search-empty-BhlZHJF-.js → search-empty-PfWp7qfl.js} +2 -2
  185. package/_assets/{secp256k1-C4HGjRo8.js → secp256k1-Bh8CfHpQ.js} +2 -2
  186. package/_assets/{secp256k1-BvDOJrZj.js → secp256k1-Dse58ee0.js} +2 -2
  187. package/_assets/{secp256k1-BAAt2AsC.js → secp256k1-N8bNn80H.js} +2 -2
  188. package/_assets/{send-batch-transaction-0FOgO-ET.js → send-batch-transaction-BpqXJtGJ.js} +2 -2
  189. package/_assets/{send-eip712-transaction-BOK7YDZz.js → send-eip712-transaction-D2-3cTz5.js} +3 -3
  190. package/_assets/{send-gasless-transaction-Cu--gdaY.js → send-gasless-transaction-DvU-irYQ.js} +3 -3
  191. package/_assets/{send-BI0btOc6.js → send-h29mxUrF.js} +2 -2
  192. package/_assets/send-transaction-FUszabPU.js +3 -0
  193. package/_assets/sendMetaTransaction-CcfiyKVp.js +2 -0
  194. package/_assets/{sendRawTransaction-C3ZoitjG.js → sendRawTransaction-BQgltNSJ.js} +4 -4
  195. package/_assets/{sentry-BxdwO3pv.js → sentry-CAS3BNIy.js} +3 -3
  196. package/_assets/{serializeTransaction-pYtrV7RU.js → serializeTransaction-__k14-5R.js} +2 -2
  197. package/_assets/{session-proposal-Db_N4_Gn.js → session-proposal-C3dOHBpp.js} +2 -2
  198. package/_assets/{session-request-B7eT8WJX.js → session-request-La1Lz5pY.js} +3 -3
  199. package/_assets/{sha256-3PO3xhiT.js → sha256-CLzVl0-i.js} +2 -2
  200. package/_assets/{signing-wiPQ7Wvz.js → signing-ClZDdyWr.js} +4 -4
  201. package/_assets/{skeleton.styles-DTnZygMc.js → skeleton.styles-BideLusx.js} +2 -2
  202. package/_assets/{socials-bRUEtmju.js → socials-DU6TufzI.js} +2 -2
  203. package/_assets/{styled-DV3ca-sF.js → styled-lv29vbU7.js} +3 -3
  204. package/_assets/{swaps-B-elkyix.js → swaps-DsEkYfnN.js} +8 -8
  205. package/_assets/{thirdweb-U2M04SJR.js → thirdweb-ByxuX0DY.js} +4 -4
  206. package/_assets/{to-serializable-transaction-C460Jpwk.js → to-serializable-transaction-B9MSl050.js} +3 -3
  207. package/_assets/{totalSupply-Go9y-Ilv.js → totalSupply-DOU8z336.js} +2 -2
  208. package/_assets/{transaction-Dh6qJ7PN.js → transaction-CuK5IUGr.js} +2 -2
  209. package/_assets/{transactionReceipt-MlvCCpAz.js → transactionReceipt-jeQgFWvn.js} +2 -2
  210. package/_assets/transactions-C5_JA1NE.js +17 -0
  211. package/_assets/{useCreditPacks-CsOWjtuZ.js → useCreditPacks-CU0lRdPq.js} +2 -2
  212. package/_assets/{useInfiniteGrid-BRJtiYn-.js → useInfiniteGrid-BPtTRHIB.js} +2 -2
  213. package/_assets/{useStore-DvwWBFUP.js → useStore-rPC8Gwuv.js} +3 -3
  214. package/_assets/{useTheme-Clcy27dj.js → useTheme-C_44BN3j.js} +2 -2
  215. package/_assets/{utils-C47sFUWS.js → utils-BV4hvYlV.js} +2 -2
  216. package/_assets/{verifyHash-CgNpRrLI.js → verifyHash-qwpY3McX.js} +2 -2
  217. package/_assets/{w3m-modal-CsqnZdOv.js → w3m-modal-IH0P0x8g.js} +2 -2
  218. package/_assets/{w3m-modal-iB_Jyio2.js → w3m-modal-RWmLMEhq.js} +2 -2
  219. package/_assets/{wait-for-tx-receipt-CZmHSBIy.js → wait-for-tx-receipt-CfUmETfV.js} +2 -2
  220. package/_assets/{wallets-D0ayx2Ud.js → wallets-DBFKTZVz.js} +6 -6
  221. package/_assets/{web-connector-CoAY_9Ez.js → web-connector-5O3sqPuw.js} +4 -4
  222. package/_assets/{writeContract-CAHluxuL.js → writeContract-CwGPT4Iu.js} +2 -2
  223. package/_assets/{zora-sepolia-CwYmHh_e.js → zora-sepolia-CLbV2B8e.js} +2 -2
  224. package/_assets/{zoraTestnet-CYFRaB4W.js → zoraTestnet-wnoXWuLz.js} +2 -2
  225. package/index.html +11 -11
  226. package/package.json +2 -2
  227. package/_assets/Cart-BzK8CObO.js +0 -645
  228. package/_assets/CircularProgress-vVxuKRO3.js +0 -29
  229. package/_assets/CollectionCarousel-BAdWBmbr.js +0 -937
  230. package/_assets/Grow-CiHUKYJJ.js +0 -2
  231. package/_assets/ItemDetail-CnsFOTP0.js +0 -3655
  232. package/_assets/NotificationsBell-cEMFVXUQ.js +0 -142
  233. package/_assets/app-store-4P6uzW8u.svg +0 -34
  234. package/_assets/authorizations-DbYL1SFo.js +0 -2
  235. package/_assets/buy-VoaFL0gA.js +0 -2
  236. package/_assets/clsx-BEtG4eYu.js +0 -2
  237. package/_assets/createSvgIcon-DuQr81Ef.js +0 -75
  238. package/_assets/download-on-the-app-store-D7CmsZZO.svg +0 -25
  239. package/_assets/emotion-styled.browser.esm-Bmaw-B0u.js +0 -2
  240. package/_assets/get-in-on-google-play-Cqt13Ucn.svg +0 -23
  241. package/_assets/get-in-on-play-store-button-49Za7I2x.svg +0 -11
  242. package/_assets/getNFT-BK80hZpF.js +0 -3
  243. package/_assets/getNFT-CaFBE3dG.js +0 -2
  244. package/_assets/index-B6Acsbwr.js +0 -2
  245. package/_assets/index-CyPssfNz.js +0 -2
  246. package/_assets/index-D0CrRpvU.js +0 -3
  247. package/_assets/index-DM273JHq.js +0 -31
  248. package/_assets/index-DaMpIpZ6.js +0 -2
  249. package/_assets/logo-pattern-D4X-bvlg.webp +0 -0
  250. package/_assets/man-default1-BEO13leF.png +0 -0
  251. package/_assets/passkeys-FupWf6Qe.js +0 -2
  252. package/_assets/qr-android-MBrMPexN.svg +0 -1
  253. package/_assets/send-transaction-BRv4xPkp.js +0 -3
  254. package/_assets/sendMetaTransaction-kIltSLeV.js +0 -2
  255. package/_assets/transactions-Bkojvbe9.js +0 -17
@@ -1,4 +1,4 @@
1
- import{r as u,L as W,d as re,j as e}from"./react-DjOKjwAj.js";import{a2 as H,l as U,a3 as le,a4 as de,a5 as ce,a6 as he,t as pe,s as i,I as L,a7 as ue,a8 as me,B as F,a9 as xe,o as V,aa as ge,n as fe,b as n,ab as G,ac as N,ad as be,ae as ye,af as ve,ag as je,ah as we,ai as $e,aj as ke,ak as Ie,al as Ce,am as Ee,an as ze,ao as Le,ap as Fe,aq as We,ar as Se,q as A,as as O,at as Ae,au as Oe,av as Te,aw as Pe,ax as Re,ay as Ne}from"./index-D_MyRErw.js";import{d as B}from"./dcl-schemas-BrhDU8Ob.js";import{E as Q}from"./ErrorNotice-DB0NutQX.js";import{E as Be}from"./EmotePlaybackBar-B4bFL84Q.js";import{O as Me}from"./OutfitPreview-CFbrD7aI.js";import"./sentry-BxdwO3pv.js";import"./ethers-13WTbgZT.js";import"./intl-AKLEHPeO.js";import"./disposePreview-DqlQXFBW.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="b2a312f5-8082-4088-a106-3b3faeecebe2",t._sentryDebugIdIdentifier="sentry-dbid-b2a312f5-8082-4088-a106-3b3faeecebe2")}catch{}})();function qe({address:t,outfitUrns:s,enabled:l=!0}){var b;const{data:r,isFetched:d}=H(t),m=((b=r==null?void 0:r.avatar)==null?void 0:b.wearables)??[],x=!!t&&!!r,p=m.join(","),c=l&&x&&m.length>0,{data:y,isLoading:v,isFetched:j}=U({queryKey:["wearable-rules",p],enabled:c,staleTime:30*6e4,retry:!1,queryFn:()=>he(m)}),k=s.join(",");return u.useMemo(()=>{const I=!!t&&!d||v||c&&!j;return x?{profile:"default",bodyShape:ce(r)??void 0,urns:[...de(y??[]),...s],...le(r),isLoading:I}:{profile:"default",urns:s,isLoading:I}},[t,x,r,d,y,v,j,c,k])}const{colors:o,radius:$,media:h,gradients:_e}=pe,J=i.div`
1
+ import{r as u,L as W,d as re,j as e}from"./react-DcSw8tCD.js";import{Z as H,l as U,$ as le,a0 as de,a1 as ce,a2 as he,t as pe,s as i,I as L,a3 as ue,a4 as me,B as F,a5 as xe,o as V,a6 as ge,n as fe,b as n,a7 as G,a8 as N,a9 as be,aa as ye,ab as ve,ac as je,ad as we,ae as $e,af as ke,ag as Ie,ah as Ce,ai as Ee,aj as ze,ak as Le,al as Fe,am as We,an as Se,q as A,ao as O,ap as Ae,aq as Oe,ar as Te,as as Pe,at as Re,au as Ne}from"./index-B-dIqjhn.js";import{d as B}from"./dcl-schemas-CN-1-wGb.js";import{E as Q}from"./ErrorNotice-BVVq2BBw.js";import{E as Be}from"./EmotePlaybackBar-6-X8QjVO.js";import{O as Me}from"./OutfitPreview-fsnJyCY_.js";import"./sentry-CAS3BNIy.js";import"./ethers-3hUTVH_L.js";import"./intl-AKLEHPeO.js";import"./disposePreview-DvbibLHk.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="f06a8be4-4119-4a68-9e7f-b9ea8f87f9c7",t._sentryDebugIdIdentifier="sentry-dbid-f06a8be4-4119-4a68-9e7f-b9ea8f87f9c7")}catch{}})();function qe({address:t,outfitUrns:s,enabled:l=!0}){var b;const{data:r,isFetched:d}=H(t),m=((b=r==null?void 0:r.avatar)==null?void 0:b.wearables)??[],x=!!t&&!!r,p=m.join(","),c=l&&x&&m.length>0,{data:y,isLoading:v,isFetched:j}=U({queryKey:["wearable-rules",p],enabled:c,staleTime:30*6e4,retry:!1,queryFn:()=>he(m)}),k=s.join(",");return u.useMemo(()=>{const I=!!t&&!d||v||c&&!j;return x?{profile:"default",bodyShape:ce(r)??void 0,urns:[...de(y??[]),...s],...le(r),isLoading:I}:{profile:"default",urns:s,isLoading:I}},[t,x,r,d,y,v,j,c,k])}const{colors:o,radius:$,media:h,gradients:_e}=pe,Z=i.div`
2
2
  max-width: 1721px;
3
3
  margin: 0 auto;
4
4
  /* The page's bottom padding is 56px, but the phone CTA bar is sticky and has its own bottom padding for the safe area.
@@ -23,7 +23,7 @@ import{r as u,L as W,d as re,j as e}from"./react-DjOKjwAj.js";import{a2 as H,l a
23
23
  overflow: hidden;
24
24
  white-space: nowrap;
25
25
  text-overflow: ellipsis;
26
- `,X=i.div`
26
+ `,J=i.div`
27
27
  display: grid;
28
28
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
29
29
  gap: 40px;
@@ -37,7 +37,7 @@ import{r as u,L as W,d as re,j as e}from"./react-DjOKjwAj.js";import{a2 as H,l a
37
37
  height: auto;
38
38
  min-height: 0;
39
39
  }
40
- `,Y=i.div`
40
+ `,X=i.div`
41
41
  position: relative;
42
42
  border-radius: 24px;
43
43
  overflow: hidden;
@@ -69,7 +69,7 @@ import{r as u,L as W,d as re,j as e}from"./react-DjOKjwAj.js";import{a2 as H,l a
69
69
  width: 100%;
70
70
  height: 100%;
71
71
  object-fit: contain;
72
- `,Z=i.div`
72
+ `,Y=i.div`
73
73
  display: flex;
74
74
  flex-direction: column;
75
75
  gap: 15px;
@@ -114,7 +114,7 @@ import{r as u,L as W,d as re,j as e}from"./react-DjOKjwAj.js";import{a2 as H,l a
114
114
  display: flex;
115
115
  flex-direction: column;
116
116
  gap: 10px;
117
- `,Je=i.li`
117
+ `,Ze=i.li`
118
118
  position: relative;
119
119
  display: flex;
120
120
  align-items: stretch;
@@ -167,11 +167,11 @@ import{r as u,L as W,d as re,j as e}from"./react-DjOKjwAj.js";import{a2 as H,l a
167
167
  &[data-state='missing'] {
168
168
  opacity: 0.55;
169
169
  }
170
- `,Xe=i(W)`
170
+ `,Je=i(W)`
171
171
  position: absolute;
172
172
  inset: 0;
173
173
  z-index: 1;
174
- `,Ye=i.img`
174
+ `,Xe=i.img`
175
175
  width: 96px;
176
176
  height: 96px;
177
177
  object-fit: cover;
@@ -183,7 +183,7 @@ import{r as u,L as W,d as re,j as e}from"./react-DjOKjwAj.js";import{a2 as H,l a
183
183
  width: 88px;
184
184
  height: 88px;
185
185
  }
186
- `,Ze=i.span`
186
+ `,Ye=i.span`
187
187
  width: 96px;
188
188
  height: 96px;
189
189
  border-radius: ${$.card};
@@ -364,5 +364,5 @@ import{r as u,L as W,d as re,j as e}from"./react-DjOKjwAj.js";import{a2 as H,l a
364
364
  `,ut=i.p`
365
365
  margin: 0;
366
366
  color: ${o.gray4};
367
- `,K="outfit-detail-preview";function Et(){const{id:t}=re(),s=V(c=>c.session),l=ge(),r=l==="creator",{data:d,isError:m,refetch:x}=U({queryKey:["outfit",t,r],enabled:N()&&!!t,staleTime:6e4,queryFn:()=>Ne(t,r&&s?s.identity:void 0)}),p=!N()||!t||d===null&&l!=="pending";return fe(p?{title:n("seo.outfit.notFoundTitle"),noindex:!0}:d?{title:d.name,image:G(d.thumbnailHash)??void 0}:{}),p?e.jsxs(D,{"data-testid":"outfit-notfound",children:[e.jsx(ht,{name:"cart",size:44}),e.jsx(pt,{children:n("outfits.detail.notFoundTitle")}),e.jsx(ut,{children:n("outfits.detail.notFoundBody")}),e.jsx(F,{as:W,to:"/items",variant:"purple",children:n("notFound.cta")})]}):m?e.jsxs(D,{"data-testid":"outfit-detail-error",children:[e.jsx(Q,{message:n("outfits.errors.generic")}),e.jsx(F,{variant:"purple",onClick:()=>void x(),children:n("outfits.detail.retry")})]}):d?e.jsx(xt,{outfit:d}):e.jsx(J,{"aria-busy":"true","data-testid":"outfit-detail-loading",children:e.jsxs(X,{children:[e.jsx(Y,{children:e.jsx("span",{className:"skeleton",style:{position:"absolute",inset:0},"aria-hidden":!0})}),e.jsxs(Z,{children:[e.jsx("span",{className:"skeleton",style:{width:"60%",height:32},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"40%",height:16},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"100%",height:48},"aria-hidden":!0})]})]})})}function mt({item:t}){const s=Ae(t),l=Oe(t.gender);return e.jsxs(it,{children:[t.rarity?e.jsx(z,{"data-variant":"rarity",style:{background:Re(t.rarity)},title:Pe(t.rarity),children:Te(t.rarity)}):null,t.isSmart?e.jsxs(z,{"data-variant":"smart",children:[e.jsx(L,{name:"smart",size:13}),n("assetCard.smart")]}):null,s?e.jsx(z,{"data-variant":"icon",children:e.jsx(L,{name:s})}):null,l?e.jsx(z,{"data-variant":"icon",children:e.jsx(L,{name:l})}):null]})}function xt({outfit:t}){const s=be(t),{split:l,availableCount:r,totalCredits:d,outfitCredits:m,addOutfit:x,isAdding:p}=ye(t,s),c=V(a=>{var w;return(w=a.session)==null?void 0:w.address}),y=ve(a=>a.items),v=u.useMemo(()=>new Set(y.map(je)),[y]),j=G(t.thumbnailHash),k=u.useRef(null);u.useEffect(()=>{k.current!==t.id&&(k.current=t.id,we("Shop Outfit Viewed",{outfit_id:t.id,item_count:t.items.length}))},[t.id,t.items.length]);const b=u.useMemo(()=>t.items.map(a=>{const w=$e(a),S=s.byKey.get(w)??null;return{key:w,item:S,state:S?ke(S,{address:c,cartKeys:v}):"missing"}}),[t,s.byKey,c,v]),{isFetched:I}=H(c),ee=!c||I,te=t.bodyShape==="female"?Ie:t.bodyShape==="male"?Ce:void 0,g=u.useMemo(()=>b.map(a=>a.item).filter(a=>!!a),[b]),P=u.useMemo(()=>Ee(g),[g]),ie=u.useMemo(()=>ze(g),[g]),R=u.useMemo(()=>{const a=Le(g);return a?Fe(a):null},[g]),ae=R??B.PreviewEmote.FASHION,se=!!R,f=qe({address:c,outfitUrns:P}),ne=t.items.length,oe=!s.isLoading&&!s.isError,C=l.purchasable.length;return e.jsxs(J,{"data-testid":"outfit-detail",children:[e.jsxs(De,{"aria-label":n("outfits.detail.breadcrumbAria"),children:[e.jsx(M,{to:"/overview",children:n("nav.overview")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(M,{to:"/overview",children:n("outfits.detail.breadcrumbLooks")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(Ke,{children:t.name})]}),e.jsxs(X,{children:[e.jsx(Y,{"data-testid":"outfit-detail-preview",style:{background:We(t)},children:j&&!s.isLoading&&P.length===0?e.jsx(He,{src:j,alt:t.name}):e.jsx(Me,{id:K,profile:f.profile,bodyShape:ie??f.bodyShape??te,urns:f.urns,emote:ae,unityMode:B.PreviewUnityMode.BUILDER,skin:f.skin,hair:f.hair,eyes:f.eyes,enabled:ee&&!f.isLoading&&!s.isLoading,controls:se?e.jsx(Be,{previewId:K,testId:"outfit-emote-controls"}):null})}),e.jsxs(Z,{children:[e.jsx(Ue,{children:t.name}),e.jsx(Ve,{"data-testid":"outfit-detail-meta",children:n("outfits.detail.itemsCount",{count:ne})}),s.isError?e.jsxs(st,{children:[e.jsx(Q,{message:n("outfits.detail.resolveError"),testId:"outfit-detail-resolve-error"}),e.jsx(F,{variant:"outline","data-testid":"outfit-detail-retry",onClick:s.retry,children:n("outfits.detail.retry")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{children:e.jsx(Qe,{children:b.map(a=>e.jsx(Je,{"data-testid":"outfit-detail-item","data-state":a.state,children:a.item?e.jsxs(e.Fragment,{children:[e.jsx(Xe,{to:`/item/${a.item.contractAddress}/${a.item.itemId}`,state:{item:a.item},"aria-label":a.item.name}),e.jsx(Ye,{src:a.item.thumbnail,alt:"",loading:"lazy"}),e.jsxs(q,{children:[e.jsx(T,{children:a.item.name}),a.item.creator?e.jsx(et,{to:`/items/creator/${a.item.creator}`,children:e.jsx(Se,{address:a.item.creator})}):null,e.jsxs(_,{children:[a.state!=="unavailable"?e.jsxs(tt,{children:[e.jsx(A,{size:15}),e.jsx(O,{credits:a.item.priceCredits})]}):null,a.state==="unavailable"?e.jsx(E,{children:n("outfits.card.unavailable")}):a.state==="own_listing"?e.jsx(E,{children:n("outfits.detail.yourListing")}):a.state==="in_cart"?e.jsx(E,{children:n("outfits.detail.inCart")}):null,e.jsx(mt,{item:a.item})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ze,{className:s.isLoading?"skeleton":void 0,"aria-hidden":!0}),e.jsx(q,{children:s.isLoading?e.jsx(T,{children:e.jsx("span",{className:"skeleton",style:{display:"block",width:"70%",height:14}})}):e.jsxs(e.Fragment,{children:[e.jsx(T,{children:n("outfits.card.unavailable")}),e.jsx(_,{children:e.jsx(E,{children:n("outfits.card.unavailable")})})]})})]})},a.key))})}),e.jsxs(nt,{"data-testid":"outfit-detail-ctabar",children:[oe&&l.ownListing.length>0?e.jsx(at,{children:n("outfits.detail.yourListingHint")}):null,g.length>0&&e.jsxs(ot,{children:[e.jsx(rt,{children:n("outfits.detail.totalPrice")}),s.isLoading?e.jsx("span",{className:"skeleton",style:{width:64,height:26},"aria-hidden":!0}):e.jsxs(lt,{children:[e.jsx(A,{size:22}),e.jsx(O,{credits:m})]})]}),s.isLoading?e.jsx("span",{className:"skeleton",style:{width:"100%",height:52,borderRadius:26},"aria-hidden":!0}):e.jsxs(dt,{variant:"purple","data-testid":"outfit-detail-cta",onClick:x,disabled:p||C===0,"aria-busy":p||void 0,children:[p?n("outfits.card.adding"):C>0?n("outfits.detail.addCount",{count:C}):r>0?n("outfits.detail.nothingToAdd"):n("outfits.card.unavailable"),!p&&C>0?e.jsxs(ct,{children:[e.jsx(A,{size:16}),e.jsx(O,{credits:d})]}):null]})]})]})]})]})]})}export{Et as OutfitDetail,Et as default};
368
- //# sourceMappingURL=OutfitDetail-D2gRsLmD.js.map
367
+ `,K="outfit-detail-preview";function Et(){const{id:t}=re(),s=V(c=>c.session),l=ge(),r=l==="creator",{data:d,isError:m,refetch:x}=U({queryKey:["outfit",t,r],enabled:N()&&!!t,staleTime:6e4,queryFn:()=>Ne(t,r&&s?s.identity:void 0)}),p=!N()||!t||d===null&&l!=="pending";return fe(p?{title:n("seo.outfit.notFoundTitle"),noindex:!0}:d?{title:d.name,image:G(d.thumbnailHash)??void 0}:{}),p?e.jsxs(D,{"data-testid":"outfit-notfound",children:[e.jsx(ht,{name:"cart",size:44}),e.jsx(pt,{children:n("outfits.detail.notFoundTitle")}),e.jsx(ut,{children:n("outfits.detail.notFoundBody")}),e.jsx(F,{as:W,to:"/items",variant:"purple",children:n("notFound.cta")})]}):m?e.jsxs(D,{"data-testid":"outfit-detail-error",children:[e.jsx(Q,{message:n("outfits.errors.generic")}),e.jsx(F,{variant:"purple",onClick:()=>void x(),children:n("outfits.detail.retry")})]}):d?e.jsx(xt,{outfit:d}):e.jsx(Z,{"aria-busy":"true","data-testid":"outfit-detail-loading",children:e.jsxs(J,{children:[e.jsx(X,{children:e.jsx("span",{className:"skeleton",style:{position:"absolute",inset:0},"aria-hidden":!0})}),e.jsxs(Y,{children:[e.jsx("span",{className:"skeleton",style:{width:"60%",height:32},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"40%",height:16},"aria-hidden":!0}),e.jsx("span",{className:"skeleton",style:{width:"100%",height:48},"aria-hidden":!0})]})]})})}function mt({item:t}){const s=Ae(t),l=Oe(t.gender);return e.jsxs(it,{children:[t.rarity?e.jsx(z,{"data-variant":"rarity",style:{background:Re(t.rarity)},title:Pe(t.rarity),children:Te(t.rarity)}):null,t.isSmart?e.jsxs(z,{"data-variant":"smart",children:[e.jsx(L,{name:"smart",size:13}),n("assetCard.smart")]}):null,s?e.jsx(z,{"data-variant":"icon",children:e.jsx(L,{name:s})}):null,l?e.jsx(z,{"data-variant":"icon",children:e.jsx(L,{name:l})}):null]})}function xt({outfit:t}){const s=be(t),{split:l,availableCount:r,totalCredits:d,outfitCredits:m,addOutfit:x,isAdding:p}=ye(t,s),c=V(a=>{var w;return(w=a.session)==null?void 0:w.address}),y=ve(a=>a.items),v=u.useMemo(()=>new Set(y.map(je)),[y]),j=G(t.thumbnailHash),k=u.useRef(null);u.useEffect(()=>{k.current!==t.id&&(k.current=t.id,we("Shop Outfit Viewed",{outfit_id:t.id,item_count:t.items.length}))},[t.id,t.items.length]);const b=u.useMemo(()=>t.items.map(a=>{const w=$e(a),S=s.byKey.get(w)??null;return{key:w,item:S,state:S?ke(S,{address:c,cartKeys:v}):"missing"}}),[t,s.byKey,c,v]),{isFetched:I}=H(c),ee=!c||I,te=t.bodyShape==="female"?Ie:t.bodyShape==="male"?Ce:void 0,g=u.useMemo(()=>b.map(a=>a.item).filter(a=>!!a),[b]),P=u.useMemo(()=>Ee(g),[g]),ie=u.useMemo(()=>ze(g),[g]),R=u.useMemo(()=>{const a=Le(g);return a?Fe(a):null},[g]),ae=R??B.PreviewEmote.FASHION,se=!!R,f=qe({address:c,outfitUrns:P}),ne=t.items.length,oe=!s.isLoading&&!s.isError,C=l.purchasable.length;return e.jsxs(Z,{"data-testid":"outfit-detail",children:[e.jsxs(De,{"aria-label":n("outfits.detail.breadcrumbAria"),children:[e.jsx(M,{to:"/overview",children:n("nav.overview")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(M,{to:"/overview",children:n("outfits.detail.breadcrumbLooks")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(Ke,{children:t.name})]}),e.jsxs(J,{children:[e.jsx(X,{"data-testid":"outfit-detail-preview",style:{background:We(t)},children:j&&!s.isLoading&&P.length===0?e.jsx(He,{src:j,alt:t.name}):e.jsx(Me,{id:K,profile:f.profile,bodyShape:ie??f.bodyShape??te,urns:f.urns,emote:ae,unityMode:B.PreviewUnityMode.BUILDER,skin:f.skin,hair:f.hair,eyes:f.eyes,enabled:ee&&!f.isLoading&&!s.isLoading,controls:se?e.jsx(Be,{previewId:K,testId:"outfit-emote-controls"}):null})}),e.jsxs(Y,{children:[e.jsx(Ue,{children:t.name}),e.jsx(Ve,{"data-testid":"outfit-detail-meta",children:n("outfits.detail.itemsCount",{count:ne})}),s.isError?e.jsxs(st,{children:[e.jsx(Q,{message:n("outfits.detail.resolveError"),testId:"outfit-detail-resolve-error"}),e.jsx(F,{variant:"outline","data-testid":"outfit-detail-retry",onClick:s.retry,children:n("outfits.detail.retry")})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ge,{children:e.jsx(Qe,{children:b.map(a=>e.jsx(Ze,{"data-testid":"outfit-detail-item","data-state":a.state,children:a.item?e.jsxs(e.Fragment,{children:[e.jsx(Je,{to:`/item/${a.item.contractAddress}/${a.item.itemId}`,state:{item:a.item},"aria-label":a.item.name}),e.jsx(Xe,{src:a.item.thumbnail,alt:"",loading:"lazy"}),e.jsxs(q,{children:[e.jsx(T,{children:a.item.name}),a.item.creator?e.jsx(et,{to:`/items/creator/${a.item.creator}`,children:e.jsx(Se,{address:a.item.creator})}):null,e.jsxs(_,{children:[a.state!=="unavailable"?e.jsxs(tt,{children:[e.jsx(A,{size:15}),e.jsx(O,{credits:a.item.priceCredits})]}):null,a.state==="unavailable"?e.jsx(E,{children:n("outfits.card.unavailable")}):a.state==="own_listing"?e.jsx(E,{children:n("outfits.detail.yourListing")}):a.state==="in_cart"?e.jsx(E,{children:n("outfits.detail.inCart")}):null,e.jsx(mt,{item:a.item})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ye,{className:s.isLoading?"skeleton":void 0,"aria-hidden":!0}),e.jsx(q,{children:s.isLoading?e.jsx(T,{children:e.jsx("span",{className:"skeleton",style:{display:"block",width:"70%",height:14}})}):e.jsxs(e.Fragment,{children:[e.jsx(T,{children:n("outfits.card.unavailable")}),e.jsx(_,{children:e.jsx(E,{children:n("outfits.card.unavailable")})})]})})]})},a.key))})}),e.jsxs(nt,{"data-testid":"outfit-detail-ctabar",children:[oe&&l.ownListing.length>0?e.jsx(at,{children:n("outfits.detail.yourListingHint")}):null,g.length>0&&e.jsxs(ot,{children:[e.jsx(rt,{children:n("outfits.detail.totalPrice")}),s.isLoading?e.jsx("span",{className:"skeleton",style:{width:64,height:26},"aria-hidden":!0}):e.jsxs(lt,{children:[e.jsx(A,{size:22}),e.jsx(O,{credits:m})]})]}),s.isLoading?e.jsx("span",{className:"skeleton",style:{width:"100%",height:52,borderRadius:26},"aria-hidden":!0}):e.jsxs(dt,{variant:"purple","data-testid":"outfit-detail-cta",onClick:x,disabled:p||C===0,"aria-busy":p||void 0,children:[p?n("outfits.card.adding"):C>0?n("outfits.detail.addCount",{count:C}):r>0?n("outfits.detail.nothingToAdd"):n("outfits.card.unavailable"),!p&&C>0?e.jsxs(ct,{children:[e.jsx(A,{size:16}),e.jsx(O,{credits:d})]}):null]})]})]})]})]})]})}export{Et as OutfitDetail,Et as default};
368
+ //# sourceMappingURL=OutfitDetail-U5OMt9MB.js.map
@@ -1,7 +1,7 @@
1
- import{r as c,j as f}from"./react-DjOKjwAj.js";import{d as m}from"./dcl-schemas-BrhDU8Ob.js";import{bl as S,l as T,s as _,af as q,bm as M,bn as U,bo as W,b as k}from"./index-D_MyRErw.js";import{d as C}from"./disposePreview-DqlQXFBW.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e4184b30-2362-4503-8f3e-26d101201ffd",e._sentryDebugIdIdentifier="sentry-dbid-e4184b30-2362-4503-8f3e-26d101201ffd")}catch{}})();function h(e){return e.startsWith("urn:")}function $(e,n){var o,d;const s=(o=e.metadata)==null?void 0:o.emoteDataADR74;if(!((d=s==null?void 0:s.representations)!=null&&d.length))return null;const a=new Map((e.content??[]).map(r=>[r.file,r.hash])),t=s.representations.map(r=>({...r,contents:(r.contents??[]).filter(l=>a.has(l)).map(l=>({key:l,url:`${n}/content/contents/${a.get(l)}`}))}));return t.every(r=>r.contents.length===0)?null:{base64:H({...e.metadata,emoteDataADR74:{...s,representations:t}}),loop:!!s.loop}}function H(e){return btoa(JSON.stringify(e).replace(/[^\x20-\x7f]/g,""))}async function J(e,n=S([e]),s){var a;try{const t=await fetch(`${n}/content/entities/active`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pointers:[e]}),signal:s});if(!t.ok)return await((a=t.body)==null?void 0:a.cancel()),null;const[o]=await t.json();return o?$(o,n):null}catch{return null}}function K(e){var s,a;const n=T({queryKey:["emote-base64",e],enabled:!!e,staleTime:18e5,retry:!1,queryFn:({signal:t})=>J(e,void 0,t)});return{base64:((s=n.data)==null?void 0:s.base64)??null,loop:((a=n.data)==null?void 0:a.loop)??!1,isLoading:n.isLoading}}const Q=_.div`
1
+ import{r as c,j as f}from"./react-DcSw8tCD.js";import{d as m}from"./dcl-schemas-CN-1-wGb.js";import{a_ as S,l as _,s as T,ab as q,a$ as M,b0 as U,b1 as W,b as $}from"./index-B-dIqjhn.js";import{d as k}from"./disposePreview-DvbibLHk.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9b0fb41f-1605-4ee5-8583-0a2e945823c2",e._sentryDebugIdIdentifier="sentry-dbid-9b0fb41f-1605-4ee5-8583-0a2e945823c2")}catch{}})();function h(e){return e.startsWith("urn:")}function C(e,n){var o,d;const s=(o=e.metadata)==null?void 0:o.emoteDataADR74;if(!((d=s==null?void 0:s.representations)!=null&&d.length))return null;const a=new Map((e.content??[]).map(r=>[r.file,r.hash])),t=s.representations.map(r=>({...r,contents:(r.contents??[]).filter(l=>a.has(l)).map(l=>({key:l,url:`${n}/content/contents/${a.get(l)}`}))}));return t.every(r=>r.contents.length===0)?null:{base64:H({...e.metadata,emoteDataADR74:{...s,representations:t}}),loop:!!s.loop}}function H(e){return btoa(JSON.stringify(e).replace(/[^\x20-\x7f]/g,""))}async function J(e,n=S([e]),s){var a;try{const t=await fetch(`${n}/content/entities/active`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({pointers:[e]}),signal:s});if(!t.ok)return await((a=t.body)==null?void 0:a.cancel()),null;const[o]=await t.json();return o?C(o,n):null}catch{return null}}function K(e){var s,a;const n=_({queryKey:["emote-base64",e],enabled:!!e,staleTime:18e5,retry:!1,queryFn:({signal:t})=>J(e,void 0,t)});return{base64:((s=n.data)==null?void 0:s.base64)??null,loop:((a=n.data)==null?void 0:a.loop)??!1,isLoading:n.isLoading}}const Q=T.div`
2
2
  position: absolute;
3
3
  inset: 0;
4
4
  display: grid;
5
5
  place-items: center;
6
- `;function X({id:e,profile:n,bodyShape:s,urns:a,emote:t=m.PreviewEmote.FASHION,enabled:o=!0,skin:d,hair:r,eyes:l,unityMode:E=m.PreviewUnityMode.BUILDER,controls:x,onRenderer:I}){const A=q(u=>u.fittingOpen),{ref:j,active:D}=M(),g=t&&h(t)?t:null,{base64:p,loop:O,isLoading:R}=K(g),i=o&&a.length>0&&D&&!A&&!R,B=U(a)===m.ChainName.MATIC_AMOY,[L,b]=c.useState(!1),P=a.join(",");c.useEffect(()=>{b(!1)},[P,n,s,t,d,r,l]),c.useEffect(()=>{i&&b(!1)},[i]);const[F,v]=c.useState(!1);c.useEffect(()=>{if(!i){v(!1);return}let u=0,N=0;const w=()=>{document.getElementById(e)?v(!0):N++<300&&(u=requestAnimationFrame(w))};return w(),()=>cancelAnimationFrame(u)},[i,e]);const y=c.useRef(null);return c.useEffect(()=>{if(i)return()=>{C(y.current),y.current=null}},[i]),f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:j,"data-preview-viewport":!0,"aria-hidden":!0}),i?f.jsx(W,{id:e,profile:n,bodyShape:s,urns:a,skin:d,hair:r,eyes:l,type:m.PreviewType.AVATAR,emote:g?void 0:t&&!h(t)?t:void 0,base64s:p?[p]:void 0,disableDefaultEmotes:!!p&&!O,unityMode:E,disableBackground:!0,disableFadeEffect:!0,dev:B,onRenderer:I,onLoad:()=>{var u;b(!0),y.current=((u=document.getElementById(e))==null?void 0:u.contentWindow)??null}},n):null,F?x:null,o&&a.length===0?null:!i||!L?f.jsx(Q,{"aria-busy":"true","aria-label":k("spinner.loading"),children:f.jsx("span",{className:"spinner","aria-hidden":!0})}):null]})}export{X as O};
7
- //# sourceMappingURL=OutfitPreview-CFbrD7aI.js.map
6
+ `;function X({id:e,profile:n,bodyShape:s,urns:a,emote:t=m.PreviewEmote.FASHION,enabled:o=!0,skin:d,hair:r,eyes:l,unityMode:E=m.PreviewUnityMode.BUILDER,controls:x,onRenderer:I}){const A=q(u=>u.fittingOpen),{ref:j,active:D}=M(),g=t&&h(t)?t:null,{base64:p,loop:O,isLoading:R}=K(g),i=o&&a.length>0&&D&&!A&&!R,B=U(a)===m.ChainName.MATIC_AMOY,[L,b]=c.useState(!1),P=a.join(",");c.useEffect(()=>{b(!1)},[P,n,s,t,d,r,l]),c.useEffect(()=>{i&&b(!1)},[i]);const[F,v]=c.useState(!1);c.useEffect(()=>{if(!i){v(!1);return}let u=0,N=0;const w=()=>{document.getElementById(e)?v(!0):N++<300&&(u=requestAnimationFrame(w))};return w(),()=>cancelAnimationFrame(u)},[i,e]);const y=c.useRef(null);return c.useEffect(()=>{if(i)return()=>{k(y.current),y.current=null}},[i]),f.jsxs(f.Fragment,{children:[f.jsx("div",{ref:j,"data-preview-viewport":!0,"aria-hidden":!0}),i?f.jsx(W,{id:e,profile:n,bodyShape:s,urns:a,skin:d,hair:r,eyes:l,type:m.PreviewType.AVATAR,emote:g?void 0:t&&!h(t)?t:void 0,base64s:p?[p]:void 0,disableDefaultEmotes:!!p&&!O,unityMode:E,disableBackground:!0,disableFadeEffect:!0,dev:B,onRenderer:I,onLoad:()=>{var u;b(!0),y.current=((u=document.getElementById(e))==null?void 0:u.contentWindow)??null}},n):null,F?x:null,o&&a.length===0?null:!i||!L?f.jsx(Q,{"aria-busy":"true","aria-label":$("spinner.loading"),children:f.jsx("span",{className:"spinner","aria-hidden":!0})}):null]})}export{X as O};
7
+ //# sourceMappingURL=OutfitPreview-fsnJyCY_.js.map
@@ -1,4 +1,4 @@
1
- import{r as d,j as t,L as F,d as Xt,a as Yt,b as Zt}from"./react-DjOKjwAj.js";import{s,t as ut,I as _,b3 as te,b as e,q as ot,as as rt,B as x,A as Ct,o as X,aa as ee,n as ie,r as Et,l as Lt,ad as se,ai as z,b4 as V,b5 as oe,b6 as re,b7 as J,am as ae,ao as ne,ak as de,al as le,ab as Rt,aq as ue,b8 as at,b9 as ce,ba as pe,bb as fe,w as N,bc as zt,bd as Pt,be as A,h as nt,bf as dt,bg as he,bh as xe,bi as me,ah as ge,bj as be,bk as ye,ay as je}from"./index-D_MyRErw.js";import{E as U}from"./ErrorNotice-DB0NutQX.js";import{L as ve}from"./LoadMore-yHCzMVX9.js";import{u as we}from"./useInfiniteGrid-BRJtiYn-.js";import{O as $e}from"./OutfitPreview-CFbrD7aI.js";import{T as ke}from"./skeleton.styles-DTnZygMc.js";import"./dcl-schemas-BrhDU8Ob.js";import"./sentry-BxdwO3pv.js";import"./ethers-13WTbgZT.js";import"./intl-AKLEHPeO.js";import"./disposePreview-DqlQXFBW.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},f=new a.Error().stack;f&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[f]="781b8ec8-cfea-4818-a5b2-dee6e781c095",a._sentryDebugIdIdentifier="sentry-dbid-781b8ec8-cfea-4818-a5b2-dee6e781c095")}catch{}})();const{colors:m,radius:Y,media:Se}=ut,Ie=s.div`
1
+ import{r as d,j as t,L as F,d as Xt,a as Yt,b as Zt}from"./react-DcSw8tCD.js";import{s,t as ut,I as _,aI as te,b as e,q as ot,ao as at,B as x,A as Ct,o as X,a6 as ee,n as ie,r as Et,l as Lt,a9 as se,ae as z,aJ as V,aK as oe,aL as ae,aM as J,ai as re,ak as ne,ag as de,ah as le,a7 as Rt,am as ue,aN as rt,aO as ce,aP as pe,aQ as fe,w as N,aR as zt,aS as Pt,aT as A,h as nt,aU as dt,aV as he,aW as xe,aX as me,ad as ge,aY as be,aZ as ye,au as je}from"./index-B-dIqjhn.js";import{E as U}from"./ErrorNotice-BVVq2BBw.js";import{L as ve}from"./LoadMore-BrnolAMt.js";import{u as we}from"./useInfiniteGrid-BPtTRHIB.js";import{O as $e}from"./OutfitPreview-fsnJyCY_.js";import{T as ke}from"./skeleton.styles-BideLusx.js";import"./dcl-schemas-CN-1-wGb.js";import"./sentry-CAS3BNIy.js";import"./ethers-3hUTVH_L.js";import"./intl-AKLEHPeO.js";import"./disposePreview-DvbibLHk.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},f=new r.Error().stack;f&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[f]="6b13f580-a4f4-4796-826f-638e974a9c34",r._sentryDebugIdIdentifier="sentry-dbid-6b13f580-a4f4-4796-826f-638e974a9c34")}catch{}})();const{colors:m,radius:Y,media:Se}=ut,Ie=s.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  gap: 12px;
@@ -111,7 +111,7 @@ import{r as d,j as t,L as F,d as Xt,a as Yt,b as Zt}from"./react-DjOKjwAj.js";im
111
111
  color: ${m.accent};
112
112
  background: ${m.white};
113
113
  border-radius: 50%;
114
- `,Ae=[{key:"wearable",labelKey:"categories.wearables"},{key:"emote",labelKey:"categories.emotes"}];function Fe({selectedKeys:a,onPick:f,canPick:h}){const[c,y]=d.useState("wearable"),[j,b]=d.useState(""),[o,R]=d.useState("");d.useEffect(()=>{const l=setTimeout(()=>R(j.trim()),300);return()=>clearTimeout(l)},[j]);const{items:T,isLoading:C,isPlaceholderData:u,isError:S,hasNextPage:E,isFetchingNextPage:Z,fetchNextPage:k}=we(["outfit-picker",c,o],l=>te({search:o||void 0,category:c,onSale:!0,listingType:"primary",first:24,skip:l,sortBy:"cheapest"})),g=e(c==="emote"?"outfits.studio.searchEmotes":"outfits.studio.searchWearables"),K=new Set,B=T.filter(l=>{if(!l.itemId)return!1;const v=`${l.contractAddress.toLowerCase()}-${l.itemId}`;return K.has(v)?!1:(K.add(v),!0)});return t.jsxs(Ie,{"data-testid":"outfit-picker",children:[t.jsx(Ce,{role:"group","aria-label":e("outfits.studio.pickerCategory"),"data-testid":"outfit-picker-category",children:Ae.map(({key:l,labelKey:v})=>t.jsx(Ee,{type:"button","data-category":l,"data-selected":c===l||void 0,"aria-pressed":c===l,onClick:()=>{y(l),b("")},children:e(v)},l))}),t.jsxs(Te,{children:[t.jsx(_,{name:"search",color:ut.colors.muted}),t.jsx("input",{value:j,placeholder:g,"aria-label":g,onChange:l=>b(l.target.value),"data-testid":"outfit-picker-search"})]}),S?t.jsx(wt,{children:e("outfits.errors.generic")}):C||u?t.jsx($t,{"aria-busy":"true",children:Array.from({length:8},(l,v)=>t.jsx(Le,{className:"skeleton","aria-hidden":!0},v))}):B.length===0?t.jsx(wt,{children:e("outfits.studio.noResults")}):t.jsx($t,{children:B.map(l=>{const v=`${l.contractAddress.toLowerCase()}-${l.itemId}`,H=a.has(v);return t.jsxs(Re,{type:"button","data-testid":"outfit-picker-item","data-selected":H||void 0,disabled:!H&&!h(l),onClick:()=>f(l),title:l.name,children:[t.jsx(ze,{src:l.thumbnail,alt:"",loading:"lazy"}),t.jsx(Pe,{children:l.name}),t.jsxs(We,{children:[t.jsx(ot,{size:12}),t.jsx(rt,{credits:l.priceCredits})]}),H?t.jsx(Oe,{name:"check-rounded",size:18}):null]},v)})}),!S&&!C&&!u?t.jsx(ve,{auto:!1,hasNextPage:!!E,isFetching:Z,onLoadMore:()=>void k()}):null]})}const{colors:n,radius:$,media:D,z:Ne}=ut,Wt=s.div`
114
+ `,Ae=[{key:"wearable",labelKey:"categories.wearables"},{key:"emote",labelKey:"categories.emotes"}];function Fe({selectedKeys:r,onPick:f,canPick:h}){const[c,y]=d.useState("wearable"),[j,b]=d.useState(""),[o,R]=d.useState("");d.useEffect(()=>{const l=setTimeout(()=>R(j.trim()),300);return()=>clearTimeout(l)},[j]);const{items:T,isLoading:C,isPlaceholderData:u,isError:S,hasNextPage:E,isFetchingNextPage:Z,fetchNextPage:k}=we(["outfit-picker",c,o],l=>te({search:o||void 0,category:c,onSale:!0,listingType:"primary",first:24,skip:l,sortBy:"cheapest"})),g=e(c==="emote"?"outfits.studio.searchEmotes":"outfits.studio.searchWearables"),K=new Set,B=T.filter(l=>{if(!l.itemId)return!1;const v=`${l.contractAddress.toLowerCase()}-${l.itemId}`;return K.has(v)?!1:(K.add(v),!0)});return t.jsxs(Ie,{"data-testid":"outfit-picker",children:[t.jsx(Ce,{role:"group","aria-label":e("outfits.studio.pickerCategory"),"data-testid":"outfit-picker-category",children:Ae.map(({key:l,labelKey:v})=>t.jsx(Ee,{type:"button","data-category":l,"data-selected":c===l||void 0,"aria-pressed":c===l,onClick:()=>{y(l),b("")},children:e(v)},l))}),t.jsxs(Te,{children:[t.jsx(_,{name:"search",color:ut.colors.muted}),t.jsx("input",{value:j,placeholder:g,"aria-label":g,onChange:l=>b(l.target.value),"data-testid":"outfit-picker-search"})]}),S?t.jsx(wt,{children:e("outfits.errors.generic")}):C||u?t.jsx($t,{"aria-busy":"true",children:Array.from({length:8},(l,v)=>t.jsx(Le,{className:"skeleton","aria-hidden":!0},v))}):B.length===0?t.jsx(wt,{children:e("outfits.studio.noResults")}):t.jsx($t,{children:B.map(l=>{const v=`${l.contractAddress.toLowerCase()}-${l.itemId}`,M=r.has(v);return t.jsxs(Re,{type:"button","data-testid":"outfit-picker-item","data-selected":M||void 0,disabled:!M&&!h(l),onClick:()=>f(l),title:l.name,children:[t.jsx(ze,{src:l.thumbnail,alt:"",loading:"lazy"}),t.jsx(Pe,{children:l.name}),t.jsxs(We,{children:[t.jsx(ot,{size:12}),t.jsx(at,{credits:l.priceCredits})]}),M?t.jsx(Oe,{name:"check-rounded",size:18}):null]},v)})}),!S&&!C&&!u?t.jsx(ve,{auto:!1,hasNextPage:!!E,isFetching:Z,onLoadMore:()=>void k()}):null]})}const{colors:n,radius:$,media:D,z:Ne}=ut,Wt=s.div`
115
115
  max-width: 1200px;
116
116
  margin: 0 auto;
117
117
  display: flex;
@@ -174,7 +174,7 @@ import{r as d,j as t,L as F,d as Xt,a as Yt,b as Zt}from"./react-DjOKjwAj.js";im
174
174
  `,Be=s.span`
175
175
  height: 76px;
176
176
  border-radius: ${$.card};
177
- `,He=s.div`
177
+ `,Me=s.div`
178
178
  display: flex;
179
179
  align-items: center;
180
180
  gap: 14px;
@@ -191,7 +191,7 @@ import{r as d,j as t,L as F,d as Xt,a as Yt,b as Zt}from"./react-DjOKjwAj.js";im
191
191
  border-radius: 8px;
192
192
  background: ${n.media};
193
193
  flex-shrink: 0;
194
- `,Me=s.div`
194
+ `,He=s.div`
195
195
  ${Nt};
196
196
  overflow: hidden;
197
197
 
@@ -216,13 +216,13 @@ import{r as d,j as t,L as F,d as Xt,a as Yt,b as Zt}from"./react-DjOKjwAj.js";im
216
216
  white-space: nowrap;
217
217
  overflow: hidden;
218
218
  text-overflow: ellipsis;
219
- `,qe=s.span`
219
+ `,Ge=s.span`
220
220
  display: inline-flex;
221
221
  align-items: center;
222
222
  gap: 8px;
223
223
  font-size: 13px;
224
224
  color: ${n.gray4};
225
- `,Ge=s.div`
225
+ `,qe=s.div`
226
226
  display: flex;
227
227
  align-items: center;
228
228
  gap: 8px;
@@ -341,10 +341,10 @@ import{r as d,j as t,L as F,d as Xt,a as Yt,b as Zt}from"./react-DjOKjwAj.js";im
341
341
  letter-spacing: 0.04em;
342
342
  text-transform: uppercase;
343
343
  color: ${n.gray4};
344
- `,ri=s.div`
344
+ `,ai=s.div`
345
345
  display: flex;
346
346
  gap: 8px;
347
- `,ai=s.button`
347
+ `,ri=s.button`
348
348
  min-height: 44px;
349
349
  padding: 0 16px;
350
350
  border-radius: ${$.pill};
@@ -553,5 +553,5 @@ import{r as d,j as t,L as F,d as Xt,a as Yt,b as Zt}from"./react-DjOKjwAj.js";im
553
553
  display: flex;
554
554
  flex-wrap: wrap;
555
555
  gap: 10px;
556
- `;function Ki(){const{id:a}=Xt(),{pathname:f}=Yt(),h=X(b=>b.session),c=X(b=>b.signIn),y=ee();ie({title:e("outfits.studio.title"),noindex:!0});const j=f.endsWith("/new")?"new":a?"edit":"list";return y==="pending"?t.jsx(O,{"aria-busy":"true","data-testid":"outfit-studio-loading",children:t.jsx("span",{className:"spinner","aria-hidden":!0})}):h?y!=="creator"?t.jsxs(O,{"data-testid":"outfit-studio-unavailable",children:[t.jsx(kt,{children:e("outfits.studio.title")}),t.jsx(w,{children:e("outfits.studio.notAvailable")}),t.jsx(x,{as:F,to:"/overview",variant:"white",children:e("outfits.studio.backToShop")})]}):j==="list"?t.jsx(Ei,{}):t.jsx(zi,{outfitId:j==="edit"?a:null},a??"new"):t.jsxs(O,{"data-testid":"outfit-studio-signin",children:[t.jsx(kt,{children:e("outfits.studio.title")}),t.jsx(w,{children:e("outfits.studio.signInPrompt")}),t.jsx(x,{variant:"white",onClick:()=>c(),children:e("outfits.studio.signIn")})]})}function Ci({outfit:a}){const f=Rt(a.thumbnailHash);return f?t.jsx(Me,{style:{background:pe(a)},children:t.jsx("img",{src:f,alt:"",loading:"lazy"})}):t.jsx(Ue,{"aria-hidden":!0})}function Ei(){const a=X(u=>u.session),f=Et(),[h,c]=d.useState(null),[y,j]=d.useState(null),{data:b=[],isLoading:o,isError:R,refetch:T}=Lt({queryKey:["outfits-all"],enabled:!!a,staleTime:3e4,queryFn:()=>ye(a.identity)});async function C(u,S){if(a){j(u.id);try{S==="delete"?(await fe(u.id,a.identity),N.success(e("outfits.studio.deleted"))):(await zt({...lt(u),published:!1},a.identity,"update"),N.success(e("outfits.studio.unpublished"))),Pt(f)}catch(E){E instanceof A||nt(E,{flow:`outfit-${S}`}),N.error(e(E instanceof A?dt(E.code):"outfits.errors.generic"))}finally{j(null),c(null)}}}return t.jsxs(Wt,{"data-testid":"outfit-studio-list",children:[t.jsxs(Ot,{children:[t.jsx(At,{children:e("outfits.studio.myOutfits")}),t.jsx(x,{as:F,to:"/outfits/new",variant:"white","data-testid":"outfit-studio-new",children:e("outfits.studio.new")})]}),o?t.jsx(St,{"aria-busy":"true",children:Array.from({length:3},(u,S)=>t.jsx(Be,{className:"skeleton","aria-hidden":!0},S))}):R?t.jsxs(O,{children:[t.jsx(U,{message:e("outfits.errors.generic")}),t.jsx(x,{variant:"white",onClick:()=>void T(),children:e("outfits.detail.retry")})]}):b.length===0?t.jsx(w,{children:e("outfits.studio.empty")}):t.jsx(St,{children:b.map(u=>t.jsxs(He,{"data-testid":"outfit-studio-row","data-published":u.published||void 0,children:[t.jsx(Ci,{outfit:u}),t.jsxs(_e,{children:[t.jsx(Ke,{children:u.name||e("outfits.studio.untitled")}),t.jsxs(qe,{children:[t.jsx(Ft,{"data-state":u.published?"published":"draft",children:u.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")}),e("outfits.card.items",{count:u.items.length})]})]}),t.jsxs(Ge,{children:[u.published?t.jsx(x,{as:F,to:`/items/outfits/${u.id}`,variant:"ghost",size:"sm",children:e("outfits.studio.view")}):null,t.jsx(x,{as:F,to:`/outfits/${u.id}/edit`,variant:"outline",size:"sm","data-testid":"outfit-studio-edit",children:e("outfits.studio.edit")}),t.jsx(Qe,{type:"button","data-testid":"outfit-studio-delete","aria-label":e("outfits.studio.confirmDelete"),disabled:y===u.id,onClick:()=>c(u),children:t.jsx(_,{name:"trash",size:18})})]})]},u.id))}),h?t.jsxs(Ve,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Je,{onClick:()=>c(null)}),t.jsxs(Xe,{children:[t.jsx(Ye,{children:e("outfits.studio.deleteTitle")}),t.jsx("p",{className:"muted",children:e("outfits.studio.deleteBody")}),t.jsxs(Ze,{children:[h.published?t.jsx(x,{variant:"purple","data-testid":"outfit-studio-confirm-unpublish",disabled:y===h.id,onClick:()=>void C(h,"unpublish"),children:e("outfits.studio.unpublish")}):null,t.jsx(x,{variant:h.published?"outline":"purple","data-testid":"outfit-studio-confirm-delete",disabled:y===h.id,onClick:()=>void C(h,"delete"),children:e("outfits.studio.confirmDelete")}),t.jsx(x,{variant:"ghost",onClick:()=>c(null),children:e("outfits.studio.cancel")})]})]})]}):null]})}const Tt=["image/png","image/jpeg","image/webp"];function Li(){return{id:crypto.randomUUID(),name:"",thumbnailHash:"",items:[],bodyShape:"unisex",gradientFrom:at.from,gradientTo:at.to,published:!1}}function lt(a){return{id:a.id,name:a.name,thumbnailHash:a.thumbnailHash,items:a.items,bodyShape:a.bodyShape,gradientFrom:a.gradientFrom,gradientTo:a.gradientTo,published:a.published}}function Ri(a){try{const f=sessionStorage.getItem(a);return f?JSON.parse(f):null}catch{return null}}function zi({outfitId:a}){const f=a===null,h=`outfit-draft:${a??"new"}`,c=X(i=>i.session),y=Et(),j=Zt(),[b]=d.useState(()=>Ri(h)),[o,R]=d.useState(()=>b??(f?Li():null)),[T,C]=d.useState(!!b),{data:u,isLoading:S,isError:E,refetch:Z}=Lt({queryKey:["outfit",a,!0],enabled:!f&&!!c,staleTime:0,queryFn:()=>je(a,c.identity)});d.useEffect(()=>{u&&R(i=>i??lt(u))},[u]);function k(i){R(r=>r&&{...r,...i}),C(!0)}d.useEffect(()=>{if(!(!o||!T))try{sessionStorage.setItem(h,JSON.stringify(o))}catch{}},[o,T,h]),d.useEffect(()=>{if(!T)return;const i=r=>r.preventDefault();return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[T]),d.useEffect(()=>()=>sessionStorage.removeItem(h),[h]);const g=se(o??void 0),K=d.useMemo(()=>new Set(((o==null?void 0:o.items)??[]).map(z)),[o]),B=i=>be((o==null?void 0:o.items)??[],i,g.byKey),l=i=>!!i.itemId&&B(i).length<=J;function v(i){!o||!l(i)||k({items:B(i)})}const[H,ct]=d.useState(null),L=d.useRef(null),tt=d.useRef(!0);d.useEffect(()=>(tt.current=!0,()=>{tt.current=!1}),[]);const[q,pt]=d.useState(!1),[Bt,G]=d.useState(null),[et,ft]=d.useState(""),[Ht,ht]=d.useState(null),[I,Mt]=d.useState();d.useEffect(()=>()=>{L.current&&URL.revokeObjectURL(L.current)},[]);function xt(){const i=me(et);if(!i){ht(e("outfits.studio.importError"));return}ht(null),ft(""),Mt(i.colors),k({items:i.items,...i.bodyShape?{bodyShape:i.bodyShape}:{}}),N.success(e("outfits.studio.importSuccess",{count:i.items.length}))}async function Ut(i){if(!i||!c)return;if(G(null),!Tt.includes(i.type)){G(e("outfits.errors.unsupportedType"));return}if(i.size>he){G(e("outfits.errors.tooLarge"));return}L.current&&URL.revokeObjectURL(L.current);const r=URL.createObjectURL(i);L.current=r,ct(r),pt(!0);try{const p=await xe(i,c.identity);k({thumbnailHash:p})}catch(p){p instanceof A||nt(p,{flow:"outfit-thumbnail"}),G(e(p instanceof A?dt(p.code):"outfits.errors.generic")),L.current&&(URL.revokeObjectURL(L.current),L.current=null),ct(null)}finally{pt(!1)}}const[M,mt]=d.useState(!1),[_t,gt]=d.useState(null),it=!!o&&o.name.trim().length>0&&o.name.length<=60,Kt=!!o&&V(o.gradientFrom)&&V(o.gradientTo),bt=!!o&&o.items.some(i=>{const r=g.byKey.get(z(i));return!r||oe(r)}),yt=!!o&&it&&!!o.thumbnailHash&&Kt&&bt&&o.items.length>=re&&o.items.length<=J;async function st(i){if(!(!c||!o||M)){mt(!0),gt(null);try{const r=await zt({...o,published:i},c.identity,f?"create":"update");if(!tt.current)return;sessionStorage.removeItem(h),R(lt(r)),C(!1),Pt(y),i&&!o.published?(ge("Shop Outfit Published",{outfit_id:r.id,item_count:r.items.length}),N.success(e("outfits.studio.publishedToast"))):N.success(e("outfits.studio.saved")),f&&(y.setQueryData(["outfit",r.id,!0],r),j(`/outfits/${r.id}/edit`,{replace:!0}))}catch(r){r instanceof A||nt(r,{flow:"outfit-save"}),gt(e(r instanceof A?dt(r.code):"outfits.errors.generic"))}finally{mt(!1)}}}const Q=d.useMemo(()=>((o==null?void 0:o.items)??[]).map(i=>g.byKey.get(z(i))).filter(i=>!!i),[o,g.byKey]),jt=d.useMemo(()=>ae(Q),[Q]),qt=d.useMemo(()=>{const i=ne(Q);return i!=null&&i.itemId?z({contractAddress:i.contractAddress,itemId:i.itemId}):null},[Q]),Gt=(o==null?void 0:o.bodyShape)==="female"?de:(o==null?void 0:o.bodyShape)==="male"?le:void 0;if(!c)return null;if(!o)return E?t.jsxs(O,{children:[t.jsx(U,{message:e("outfits.errors.generic")}),t.jsx(x,{variant:"white",onClick:()=>void Z(),children:e("outfits.detail.retry")})]}):!S&&u===null?t.jsxs(O,{"data-testid":"outfit-studio-missing",children:[t.jsx(w,{children:e("outfits.errors.notFound")}),t.jsx(x,{as:F,to:"/outfits/manage",variant:"white",children:e("outfits.studio.myOutfits")})]}):t.jsx(O,{"aria-busy":"true",children:t.jsx("span",{className:"spinner","aria-hidden":!0})});const vt=H??Rt(o.thumbnailHash),Qt={...o,authorAddress:(c==null?void 0:c.address)??"",createdAt:0,updatedAt:0},Vt=o.items.reduce((i,r)=>{var p;return i+(((p=g.byKey.get(z(r)))==null?void 0:p.priceCredits)??0)},0);return t.jsxs(Wt,{"data-testid":"outfit-studio-editor",children:[t.jsxs(Ot,{children:[t.jsx(De,{to:"/outfits/manage","aria-label":e("outfits.studio.myOutfits"),"data-testid":"outfit-studio-back",children:t.jsx(_,{name:"arrow-left",size:18})}),t.jsx(At,{children:f?e("outfits.studio.new"):e("outfits.studio.editTitle")}),t.jsx(Ft,{"data-state":o.published?"published":"draft",children:o.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")})]}),t.jsxs(ti,{children:[t.jsxs(ei,{children:[t.jsxs(si,{"data-testid":"outfit-studio-preview",style:{background:ue(o)},children:[t.jsx($e,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:Gt,urns:jt,skin:I==null?void 0:I.skin,hair:I==null?void 0:I.hair,eyes:I==null?void 0:I.eyes,enabled:!g.isLoading}),jt.length===0&&!g.isLoading?t.jsx(oi,{children:e("outfits.studio.previewEmpty")}):null]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.bodyShape")}),t.jsx(ri,{role:"group","aria-label":e("outfits.studio.bodyShape"),children:["unisex","male","female"].map(i=>t.jsx(ai,{type:"button","data-selected":o.bodyShape===i||void 0,onClick:()=>k({bodyShape:i}),children:e(`outfits.studio.shape.${i}`)},i))})]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.gradient")}),t.jsx(di,{children:["gradientFrom","gradientTo"].map(i=>t.jsxs(li,{children:[t.jsx(ui,{type:"color",value:V(o[i])?o[i]:at.from,"aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom"),"data-testid":i==="gradientFrom"?"outfit-studio-gradient-from":"outfit-studio-gradient-to",onChange:r=>k({[i]:r.target.value.toLowerCase()})}),t.jsxs(ci,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(pi,{value:o[i],maxLength:7,spellCheck:!1,placeholder:"#000000","aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTopHex":"outfits.studio.gradientBottomHex"),"data-invalid":!V(o[i])||void 0,onChange:r=>{const p=r.target.value.trim().toLowerCase();k({[i]:p.startsWith("#")||p===""?p:`#${p}`})}})]})]},i))}),t.jsx(w,{children:e("outfits.studio.gradientHint")})]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.thumbnail")}),vt?t.jsx(ni,{"data-busy":q||void 0,children:t.jsx("img",{src:vt,alt:""})}):null,t.jsxs(hi,{as:"label",variant:"outline",size:"sm","data-busy":q||void 0,children:[q?e("outfits.studio.uploading"):e("outfits.studio.upload"),t.jsx("input",{type:"file",accept:Tt.join(","),hidden:!0,disabled:q,onChange:i=>{var r;return void Ut((r=i.target.files)==null?void 0:r[0])},"data-testid":"outfit-studio-thumb-input"})]}),t.jsx(w,{children:e("outfits.studio.thumbnailHint")}),t.jsx(U,{message:Bt,testId:"outfit-studio-thumb-error"})]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.cardPreview")}),t.jsx(fi,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(ce,{outfit:Qt,resolution:g})})]})]}),t.jsxs(ii,{children:[t.jsxs(P,{children:[t.jsx(W,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(xi,{children:[t.jsx(It,{id:"outfit-import",value:et,spellCheck:!1,placeholder:e("outfits.studio.importPlaceholder"),onChange:i=>ft(i.target.value),onKeyDown:i=>{i.key==="Enter"&&xt()},"data-testid":"outfit-studio-import"}),t.jsx(x,{variant:"outline",size:"sm",onClick:xt,disabled:et.trim()==="","data-testid":"outfit-studio-import-apply",children:e("outfits.studio.importApply")})]}),t.jsx(w,{children:e("outfits.studio.importHint")}),t.jsx(U,{message:Ht,testId:"outfit-studio-import-error"})]}),t.jsxs(P,{children:[t.jsx(W,{htmlFor:"outfit-name",children:e("outfits.studio.name")}),t.jsx(It,{id:"outfit-name",value:o.name,maxLength:60,placeholder:e("outfits.studio.namePlaceholder"),onChange:i=>k({name:i.target.value}),"data-testid":"outfit-studio-name"})]}),t.jsxs(P,{children:[t.jsxs(W,{as:"span",children:[e("outfits.studio.items")," (",o.items.length,"/",J,")"]}),o.items.length===0?t.jsx(w,{children:e("outfits.studio.noItems")}):t.jsx(mi,{children:o.items.map(i=>{const r=z(i),p=g.byKey.get(r);return t.jsxs(gi,{"data-testid":"outfit-studio-selected","data-missing":!p||void 0,children:[p?t.jsx(bi,{src:p.thumbnail,alt:""}):t.jsx(yi,{className:g.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(ji,{className:p?void 0:"muted",children:p?p.name:g.isLoading?t.jsx(ke,{className:"skeleton",width:96,"aria-hidden":!0}):e("outfits.card.unavailable")}),r===qt?t.jsx(vi,{"data-testid":"outfit-studio-plays-in-preview",children:e("outfits.studio.playsInPreview")}):null,p?t.jsxs(wi,{children:[t.jsx(ot,{size:12}),t.jsx(rt,{credits:p.priceCredits})]}):null,t.jsx(Si,{type:"button","aria-label":e("outfits.studio.remove"),title:e("outfits.studio.remove"),onClick:()=>k({items:o.items.filter(Jt=>z(Jt)!==r)}),children:t.jsx(_,{name:"trash",size:16})})]},r)})}),o.items.length>0?t.jsxs($i,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs(ki,{children:[t.jsx(ot,{size:14}),t.jsx(rt,{credits:Vt})]})]}):null,o.items.length>=J?t.jsx(w,{children:e("outfits.studio.maxItems")}):null]}),t.jsx(Fe,{selectedKeys:K,onPick:v,canPick:l})]})]}),t.jsxs(Ii,{"data-testid":"outfit-studio-savebar",children:[t.jsx(U,{message:_t,testId:"outfit-studio-save-error"}),it?!yt&&!o.published?t.jsx(w,{"data-testid":"outfit-studio-publish-hint",children:!bt&&o.items.length>0?e("outfits.studio.needsWearable"):e("outfits.errors.notPublishable")}):null:t.jsx(w,{children:e("outfits.studio.needName")}),t.jsxs(Ti,{children:[t.jsx(x,{variant:"outline","data-testid":"outfit-studio-save",disabled:M||!it,onClick:()=>void st(o.published),children:M?e("outfits.studio.saving"):e("outfits.studio.saveDraft")}),o.published?t.jsx(x,{variant:"white","data-testid":"outfit-studio-unpublish",disabled:M,onClick:()=>void st(!1),children:e("outfits.studio.unpublish")}):t.jsx(x,{variant:"white","data-testid":"outfit-studio-publish",disabled:M||!yt,onClick:()=>void st(!0),children:e("outfits.studio.publish")})]})]})]})}export{Ki as OutfitStudio,Ki as default};
557
- //# sourceMappingURL=OutfitStudio-BkXEDStE.js.map
556
+ `;function Ki(){const{id:r}=Xt(),{pathname:f}=Yt(),h=X(b=>b.session),c=X(b=>b.signIn),y=ee();ie({title:e("outfits.studio.title"),noindex:!0});const j=f.endsWith("/new")?"new":r?"edit":"list";return y==="pending"?t.jsx(O,{"aria-busy":"true","data-testid":"outfit-studio-loading",children:t.jsx("span",{className:"spinner","aria-hidden":!0})}):h?y!=="creator"?t.jsxs(O,{"data-testid":"outfit-studio-unavailable",children:[t.jsx(kt,{children:e("outfits.studio.title")}),t.jsx(w,{children:e("outfits.studio.notAvailable")}),t.jsx(x,{as:F,to:"/overview",variant:"white",children:e("outfits.studio.backToShop")})]}):j==="list"?t.jsx(Ei,{}):t.jsx(zi,{outfitId:j==="edit"?r:null},r??"new"):t.jsxs(O,{"data-testid":"outfit-studio-signin",children:[t.jsx(kt,{children:e("outfits.studio.title")}),t.jsx(w,{children:e("outfits.studio.signInPrompt")}),t.jsx(x,{variant:"white",onClick:()=>c(),children:e("outfits.studio.signIn")})]})}function Ci({outfit:r}){const f=Rt(r.thumbnailHash);return f?t.jsx(He,{style:{background:pe(r)},children:t.jsx("img",{src:f,alt:"",loading:"lazy"})}):t.jsx(Ue,{"aria-hidden":!0})}function Ei(){const r=X(u=>u.session),f=Et(),[h,c]=d.useState(null),[y,j]=d.useState(null),{data:b=[],isLoading:o,isError:R,refetch:T}=Lt({queryKey:["outfits-all"],enabled:!!r,staleTime:3e4,queryFn:()=>ye(r.identity)});async function C(u,S){if(r){j(u.id);try{S==="delete"?(await fe(u.id,r.identity),N.success(e("outfits.studio.deleted"))):(await zt({...lt(u),published:!1},r.identity,"update"),N.success(e("outfits.studio.unpublished"))),Pt(f)}catch(E){E instanceof A||nt(E,{flow:`outfit-${S}`}),N.error(e(E instanceof A?dt(E.code):"outfits.errors.generic"))}finally{j(null),c(null)}}}return t.jsxs(Wt,{"data-testid":"outfit-studio-list",children:[t.jsxs(Ot,{children:[t.jsx(At,{children:e("outfits.studio.myOutfits")}),t.jsx(x,{as:F,to:"/outfits/new",variant:"white","data-testid":"outfit-studio-new",children:e("outfits.studio.new")})]}),o?t.jsx(St,{"aria-busy":"true",children:Array.from({length:3},(u,S)=>t.jsx(Be,{className:"skeleton","aria-hidden":!0},S))}):R?t.jsxs(O,{children:[t.jsx(U,{message:e("outfits.errors.generic")}),t.jsx(x,{variant:"white",onClick:()=>void T(),children:e("outfits.detail.retry")})]}):b.length===0?t.jsx(w,{children:e("outfits.studio.empty")}):t.jsx(St,{children:b.map(u=>t.jsxs(Me,{"data-testid":"outfit-studio-row","data-published":u.published||void 0,children:[t.jsx(Ci,{outfit:u}),t.jsxs(_e,{children:[t.jsx(Ke,{children:u.name||e("outfits.studio.untitled")}),t.jsxs(Ge,{children:[t.jsx(Ft,{"data-state":u.published?"published":"draft",children:u.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")}),e("outfits.card.items",{count:u.items.length})]})]}),t.jsxs(qe,{children:[u.published?t.jsx(x,{as:F,to:`/items/outfits/${u.id}`,variant:"ghost",size:"sm",children:e("outfits.studio.view")}):null,t.jsx(x,{as:F,to:`/outfits/${u.id}/edit`,variant:"outline",size:"sm","data-testid":"outfit-studio-edit",children:e("outfits.studio.edit")}),t.jsx(Qe,{type:"button","data-testid":"outfit-studio-delete","aria-label":e("outfits.studio.confirmDelete"),disabled:y===u.id,onClick:()=>c(u),children:t.jsx(_,{name:"trash",size:18})})]})]},u.id))}),h?t.jsxs(Ve,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Je,{onClick:()=>c(null)}),t.jsxs(Xe,{children:[t.jsx(Ye,{children:e("outfits.studio.deleteTitle")}),t.jsx("p",{className:"muted",children:e("outfits.studio.deleteBody")}),t.jsxs(Ze,{children:[h.published?t.jsx(x,{variant:"purple","data-testid":"outfit-studio-confirm-unpublish",disabled:y===h.id,onClick:()=>void C(h,"unpublish"),children:e("outfits.studio.unpublish")}):null,t.jsx(x,{variant:h.published?"outline":"purple","data-testid":"outfit-studio-confirm-delete",disabled:y===h.id,onClick:()=>void C(h,"delete"),children:e("outfits.studio.confirmDelete")}),t.jsx(x,{variant:"ghost",onClick:()=>c(null),children:e("outfits.studio.cancel")})]})]})]}):null]})}const Tt=["image/png","image/jpeg","image/webp"];function Li(){return{id:crypto.randomUUID(),name:"",thumbnailHash:"",items:[],bodyShape:"unisex",gradientFrom:rt.from,gradientTo:rt.to,published:!1}}function lt(r){return{id:r.id,name:r.name,thumbnailHash:r.thumbnailHash,items:r.items,bodyShape:r.bodyShape,gradientFrom:r.gradientFrom,gradientTo:r.gradientTo,published:r.published}}function Ri(r){try{const f=sessionStorage.getItem(r);return f?JSON.parse(f):null}catch{return null}}function zi({outfitId:r}){const f=r===null,h=`outfit-draft:${r??"new"}`,c=X(i=>i.session),y=Et(),j=Zt(),[b]=d.useState(()=>Ri(h)),[o,R]=d.useState(()=>b??(f?Li():null)),[T,C]=d.useState(!!b),{data:u,isLoading:S,isError:E,refetch:Z}=Lt({queryKey:["outfit",r,!0],enabled:!f&&!!c,staleTime:0,queryFn:()=>je(r,c.identity)});d.useEffect(()=>{u&&R(i=>i??lt(u))},[u]);function k(i){R(a=>a&&{...a,...i}),C(!0)}d.useEffect(()=>{if(!(!o||!T))try{sessionStorage.setItem(h,JSON.stringify(o))}catch{}},[o,T,h]),d.useEffect(()=>{if(!T)return;const i=a=>a.preventDefault();return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[T]),d.useEffect(()=>()=>sessionStorage.removeItem(h),[h]);const g=se(o??void 0),K=d.useMemo(()=>new Set(((o==null?void 0:o.items)??[]).map(z)),[o]),B=i=>be((o==null?void 0:o.items)??[],i,g.byKey),l=i=>!!i.itemId&&B(i).length<=J;function v(i){!o||!l(i)||k({items:B(i)})}const[M,ct]=d.useState(null),L=d.useRef(null),tt=d.useRef(!0);d.useEffect(()=>(tt.current=!0,()=>{tt.current=!1}),[]);const[G,pt]=d.useState(!1),[Bt,q]=d.useState(null),[et,ft]=d.useState(""),[Mt,ht]=d.useState(null),[I,Ht]=d.useState();d.useEffect(()=>()=>{L.current&&URL.revokeObjectURL(L.current)},[]);function xt(){const i=me(et);if(!i){ht(e("outfits.studio.importError"));return}ht(null),ft(""),Ht(i.colors),k({items:i.items,...i.bodyShape?{bodyShape:i.bodyShape}:{}}),N.success(e("outfits.studio.importSuccess",{count:i.items.length}))}async function Ut(i){if(!i||!c)return;if(q(null),!Tt.includes(i.type)){q(e("outfits.errors.unsupportedType"));return}if(i.size>he){q(e("outfits.errors.tooLarge"));return}L.current&&URL.revokeObjectURL(L.current);const a=URL.createObjectURL(i);L.current=a,ct(a),pt(!0);try{const p=await xe(i,c.identity);k({thumbnailHash:p})}catch(p){p instanceof A||nt(p,{flow:"outfit-thumbnail"}),q(e(p instanceof A?dt(p.code):"outfits.errors.generic")),L.current&&(URL.revokeObjectURL(L.current),L.current=null),ct(null)}finally{pt(!1)}}const[H,mt]=d.useState(!1),[_t,gt]=d.useState(null),it=!!o&&o.name.trim().length>0&&o.name.length<=60,Kt=!!o&&V(o.gradientFrom)&&V(o.gradientTo),bt=!!o&&o.items.some(i=>{const a=g.byKey.get(z(i));return!a||oe(a)}),yt=!!o&&it&&!!o.thumbnailHash&&Kt&&bt&&o.items.length>=ae&&o.items.length<=J;async function st(i){if(!(!c||!o||H)){mt(!0),gt(null);try{const a=await zt({...o,published:i},c.identity,f?"create":"update");if(!tt.current)return;sessionStorage.removeItem(h),R(lt(a)),C(!1),Pt(y),i&&!o.published?(ge("Shop Outfit Published",{outfit_id:a.id,item_count:a.items.length}),N.success(e("outfits.studio.publishedToast"))):N.success(e("outfits.studio.saved")),f&&(y.setQueryData(["outfit",a.id,!0],a),j(`/outfits/${a.id}/edit`,{replace:!0}))}catch(a){a instanceof A||nt(a,{flow:"outfit-save"}),gt(e(a instanceof A?dt(a.code):"outfits.errors.generic"))}finally{mt(!1)}}}const Q=d.useMemo(()=>((o==null?void 0:o.items)??[]).map(i=>g.byKey.get(z(i))).filter(i=>!!i),[o,g.byKey]),jt=d.useMemo(()=>re(Q),[Q]),Gt=d.useMemo(()=>{const i=ne(Q);return i!=null&&i.itemId?z({contractAddress:i.contractAddress,itemId:i.itemId}):null},[Q]),qt=(o==null?void 0:o.bodyShape)==="female"?de:(o==null?void 0:o.bodyShape)==="male"?le:void 0;if(!c)return null;if(!o)return E?t.jsxs(O,{children:[t.jsx(U,{message:e("outfits.errors.generic")}),t.jsx(x,{variant:"white",onClick:()=>void Z(),children:e("outfits.detail.retry")})]}):!S&&u===null?t.jsxs(O,{"data-testid":"outfit-studio-missing",children:[t.jsx(w,{children:e("outfits.errors.notFound")}),t.jsx(x,{as:F,to:"/outfits/manage",variant:"white",children:e("outfits.studio.myOutfits")})]}):t.jsx(O,{"aria-busy":"true",children:t.jsx("span",{className:"spinner","aria-hidden":!0})});const vt=M??Rt(o.thumbnailHash),Qt={...o,authorAddress:(c==null?void 0:c.address)??"",createdAt:0,updatedAt:0},Vt=o.items.reduce((i,a)=>{var p;return i+(((p=g.byKey.get(z(a)))==null?void 0:p.priceCredits)??0)},0);return t.jsxs(Wt,{"data-testid":"outfit-studio-editor",children:[t.jsxs(Ot,{children:[t.jsx(De,{to:"/outfits/manage","aria-label":e("outfits.studio.myOutfits"),"data-testid":"outfit-studio-back",children:t.jsx(_,{name:"arrow-left",size:18})}),t.jsx(At,{children:f?e("outfits.studio.new"):e("outfits.studio.editTitle")}),t.jsx(Ft,{"data-state":o.published?"published":"draft",children:o.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")})]}),t.jsxs(ti,{children:[t.jsxs(ei,{children:[t.jsxs(si,{"data-testid":"outfit-studio-preview",style:{background:ue(o)},children:[t.jsx($e,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:qt,urns:jt,skin:I==null?void 0:I.skin,hair:I==null?void 0:I.hair,eyes:I==null?void 0:I.eyes,enabled:!g.isLoading}),jt.length===0&&!g.isLoading?t.jsx(oi,{children:e("outfits.studio.previewEmpty")}):null]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.bodyShape")}),t.jsx(ai,{role:"group","aria-label":e("outfits.studio.bodyShape"),children:["unisex","male","female"].map(i=>t.jsx(ri,{type:"button","data-selected":o.bodyShape===i||void 0,onClick:()=>k({bodyShape:i}),children:e(`outfits.studio.shape.${i}`)},i))})]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.gradient")}),t.jsx(di,{children:["gradientFrom","gradientTo"].map(i=>t.jsxs(li,{children:[t.jsx(ui,{type:"color",value:V(o[i])?o[i]:rt.from,"aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom"),"data-testid":i==="gradientFrom"?"outfit-studio-gradient-from":"outfit-studio-gradient-to",onChange:a=>k({[i]:a.target.value.toLowerCase()})}),t.jsxs(ci,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(pi,{value:o[i],maxLength:7,spellCheck:!1,placeholder:"#000000","aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTopHex":"outfits.studio.gradientBottomHex"),"data-invalid":!V(o[i])||void 0,onChange:a=>{const p=a.target.value.trim().toLowerCase();k({[i]:p.startsWith("#")||p===""?p:`#${p}`})}})]})]},i))}),t.jsx(w,{children:e("outfits.studio.gradientHint")})]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.thumbnail")}),vt?t.jsx(ni,{"data-busy":G||void 0,children:t.jsx("img",{src:vt,alt:""})}):null,t.jsxs(hi,{as:"label",variant:"outline",size:"sm","data-busy":G||void 0,children:[G?e("outfits.studio.uploading"):e("outfits.studio.upload"),t.jsx("input",{type:"file",accept:Tt.join(","),hidden:!0,disabled:G,onChange:i=>{var a;return void Ut((a=i.target.files)==null?void 0:a[0])},"data-testid":"outfit-studio-thumb-input"})]}),t.jsx(w,{children:e("outfits.studio.thumbnailHint")}),t.jsx(U,{message:Bt,testId:"outfit-studio-thumb-error"})]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.cardPreview")}),t.jsx(fi,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(ce,{outfit:Qt,resolution:g})})]})]}),t.jsxs(ii,{children:[t.jsxs(P,{children:[t.jsx(W,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(xi,{children:[t.jsx(It,{id:"outfit-import",value:et,spellCheck:!1,placeholder:e("outfits.studio.importPlaceholder"),onChange:i=>ft(i.target.value),onKeyDown:i=>{i.key==="Enter"&&xt()},"data-testid":"outfit-studio-import"}),t.jsx(x,{variant:"outline",size:"sm",onClick:xt,disabled:et.trim()==="","data-testid":"outfit-studio-import-apply",children:e("outfits.studio.importApply")})]}),t.jsx(w,{children:e("outfits.studio.importHint")}),t.jsx(U,{message:Mt,testId:"outfit-studio-import-error"})]}),t.jsxs(P,{children:[t.jsx(W,{htmlFor:"outfit-name",children:e("outfits.studio.name")}),t.jsx(It,{id:"outfit-name",value:o.name,maxLength:60,placeholder:e("outfits.studio.namePlaceholder"),onChange:i=>k({name:i.target.value}),"data-testid":"outfit-studio-name"})]}),t.jsxs(P,{children:[t.jsxs(W,{as:"span",children:[e("outfits.studio.items")," (",o.items.length,"/",J,")"]}),o.items.length===0?t.jsx(w,{children:e("outfits.studio.noItems")}):t.jsx(mi,{children:o.items.map(i=>{const a=z(i),p=g.byKey.get(a);return t.jsxs(gi,{"data-testid":"outfit-studio-selected","data-missing":!p||void 0,children:[p?t.jsx(bi,{src:p.thumbnail,alt:""}):t.jsx(yi,{className:g.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(ji,{className:p?void 0:"muted",children:p?p.name:g.isLoading?t.jsx(ke,{className:"skeleton",width:96,"aria-hidden":!0}):e("outfits.card.unavailable")}),a===Gt?t.jsx(vi,{"data-testid":"outfit-studio-plays-in-preview",children:e("outfits.studio.playsInPreview")}):null,p?t.jsxs(wi,{children:[t.jsx(ot,{size:12}),t.jsx(at,{credits:p.priceCredits})]}):null,t.jsx(Si,{type:"button","aria-label":e("outfits.studio.remove"),title:e("outfits.studio.remove"),onClick:()=>k({items:o.items.filter(Jt=>z(Jt)!==a)}),children:t.jsx(_,{name:"trash",size:16})})]},a)})}),o.items.length>0?t.jsxs($i,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs(ki,{children:[t.jsx(ot,{size:14}),t.jsx(at,{credits:Vt})]})]}):null,o.items.length>=J?t.jsx(w,{children:e("outfits.studio.maxItems")}):null]}),t.jsx(Fe,{selectedKeys:K,onPick:v,canPick:l})]})]}),t.jsxs(Ii,{"data-testid":"outfit-studio-savebar",children:[t.jsx(U,{message:_t,testId:"outfit-studio-save-error"}),it?!yt&&!o.published?t.jsx(w,{"data-testid":"outfit-studio-publish-hint",children:!bt&&o.items.length>0?e("outfits.studio.needsWearable"):e("outfits.errors.notPublishable")}):null:t.jsx(w,{children:e("outfits.studio.needName")}),t.jsxs(Ti,{children:[t.jsx(x,{variant:"outline","data-testid":"outfit-studio-save",disabled:H||!it,onClick:()=>void st(o.published),children:H?e("outfits.studio.saving"):e("outfits.studio.saveDraft")}),o.published?t.jsx(x,{variant:"white","data-testid":"outfit-studio-unpublish",disabled:H,onClick:()=>void st(!1),children:e("outfits.studio.unpublish")}):t.jsx(x,{variant:"white","data-testid":"outfit-studio-publish",disabled:H||!yt,onClick:()=>void st(!0),children:e("outfits.studio.publish")})]})]})]})}export{Ki as OutfitStudio,Ki as default};
557
+ //# sourceMappingURL=OutfitStudio-1fjhOirp.js.map
@@ -1,4 +1,4 @@
1
- import{j as t,L as oe,b as le,r as l}from"./react-DjOKjwAj.js";import{b as n,t as S,s as a,m as ce,B as G,n as de,o as pe,r as ue,I,w as R}from"./index-D_MyRErw.js";import{u as ge,d as me,t as he,L as xe,i as F,a as f,s as fe}from"./useStore-DvwWBFUP.js";import{E as A}from"./ErrorNotice-DB0NutQX.js";import{F as j}from"./field.styles-1ph2By3r.js";import"./dcl-schemas-BrhDU8Ob.js";import"./sentry-BxdwO3pv.js";import"./ethers-13WTbgZT.js";import"./intl-AKLEHPeO.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new r.Error().stack;d&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[d]="79f1308f-96c3-4bea-9cb2-9ce8e726d059",r._sentryDebugIdIdentifier="sentry-dbid-79f1308f-96c3-4bea-9cb2-9ce8e726d059")}catch{}})();const ve="https://cdn.decentraland.org/@dcl/shop/1.9.3-32728272723.commit-675c39d/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/1.9.3-32728272723.commit-675c39d/_assets/template-cover-2-Dni9s0i_.jpeg",we=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ve,"../assets/creator-covers/template-cover-2.jpeg":be}),v=Object.entries(we).sort(([r],[d])=>r.localeCompare(d)).map(([r,d])=>({name:r.split("/").pop(),url:d})),je=ce`
1
+ import{j as t,L as oe,b as le,r as l}from"./react-DcSw8tCD.js";import{b as n,t as S,s as a,m as ce,B as G,n as de,o as pe,r as ue,I,w as R}from"./index-B-dIqjhn.js";import{u as ge,d as me,t as he,L as xe,i as F,a as f,s as fe}from"./useStore-rPC8Gwuv.js";import{E as A}from"./ErrorNotice-BVVq2BBw.js";import{F as j}from"./field.styles-DwpKCezV.js";import"./dcl-schemas-CN-1-wGb.js";import"./sentry-CAS3BNIy.js";import"./ethers-3hUTVH_L.js";import"./intl-AKLEHPeO.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},d=new r.Error().stack;d&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[d]="c0929e07-14bb-4714-8d51-bf844a29f0f5",r._sentryDebugIdIdentifier="sentry-dbid-c0929e07-14bb-4714-8d51-bf844a29f0f5")}catch{}})();const ve="https://cdn.decentraland.org/@dcl/shop/1.9.3-32743160136.commit-b84a6df/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/1.9.3-32743160136.commit-b84a6df/_assets/template-cover-2-Dni9s0i_.jpeg",we=Object.assign({"../assets/creator-covers/template-cover-1.jpeg":ve,"../assets/creator-covers/template-cover-2.jpeg":be}),v=Object.entries(we).sort(([r],[d])=>r.localeCompare(d)).map(([r,d])=>({name:r.split("/").pop(),url:d})),je=ce`
2
2
  to {
3
3
  transform: rotate(360deg);
4
4
  }
@@ -241,4 +241,4 @@ import{j as t,L as oe,b as le,r as l}from"./react-DjOKjwAj.js";import{b as n,t a
241
241
  width: 100%;
242
242
  }
243
243
  `,W=1e6,V={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function Y(r){return`${(r/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function Je(){de({title:n("seo.storeSettings.title"),noindex:!0});const{session:r,signIn:d}=pe(),b=le(),k=ue(),u=r==null?void 0:r.address,{data:y,isLoading:q}=ge(u),[o,g]=l.useState(V),[N,C]=l.useState(V),[$,h]=l.useState(),[x,H]=l.useState(!1),[c,_]=l.useState(null),[w,J]=l.useState({}),T=l.useRef(null);l.useEffect(()=>{if(y){const e=me(y);g(e),C(e),h(void 0),_(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[y]),l.useEffect(()=>{let e=!1;return Promise.all(v.map(async i=>[i.name,await he(i.url)])).then(i=>{e||J(Object.fromEntries(i))}).catch(()=>{}),()=>{e=!0}},[]);const E=l.useMemo(()=>{const e=v.find(p=>o.coverName===`cover/${p.name}`);if(e)return e.name;const i=o.coverHash?v.find(p=>w[p.name]===o.coverHash):void 0;return i==null?void 0:i.name},[o.coverName,o.coverHash,w]);l.useEffect(()=>{c!=null&&c.hash&&v.some(e=>w[e.name]===c.hash)&&_(null)},[w,c]);const D=$!==void 0&&$>W,Q=l.useMemo(()=>xe.filter(e=>!F(e,o.links[e])),[o.links]),U=D||Q.length>0,z=l.useMemo(()=>JSON.stringify(o)!==JSON.stringify(N),[o,N]),X=z&&!U&&!x;if(l.useEffect(()=>{if(!z)return;const e=i=>{i.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[z]),!r)return t.jsxs(M,{"data-signin":!0,"aria-label":n("storeSettings.title"),children:[t.jsx(O,{children:n("storeSettings.title")}),t.jsx(Ie,{children:n("storeSettings.signInPrompt")}),t.jsx(ze,{variant:"white",onClick:d,children:n("storeSettings.signIn")})]});function Z(e,i){h(void 0),g(p=>({...p,cover:i,coverName:`cover/${e}`,coverHash:""}))}const ee=["image/png","image/jpeg","image/webp"];function te(e){var P;const i=(P=e.target.files)==null?void 0:P[0];if(!i||!ee.includes(i.type))return;h(i.size);const p=`cover/${i.name}`,m=new FileReader;m.onload=()=>{const B=m.result;_({url:B,name:p,hash:""}),g(ae=>({...ae,cover:B,coverName:p,coverHash:""}))},m.readAsDataURL(i)}function ie(){c&&(h(void 0),g(e=>({...e,cover:c.url,coverName:c.name,coverHash:c.hash})))}function se(e,i){const p=i?(f[e]+i).replace(/\s/g,""):"";g(m=>({...m,links:{...m.links,[e]:p}}))}function ne(e){const i=o.links[e];return e==="website"?i:i.replace(f[e],"")}async function re(){if(!(!u||!r)){H(!0);try{await fe(u,o,r.identity),C(o),h(void 0),await k.invalidateQueries({queryKey:["store",u.toLowerCase()]}),R.success(n("storeSettings.saved")),b(`/items/creator/${u}`)}catch{R.error(n("storeSettings.saveError"))}finally{H(!1)}}}return t.jsxs(M,{"aria-label":n("storeSettings.title"),children:[t.jsxs(Le,{children:[t.jsxs(Ne,{children:[u?t.jsx(Ce,{to:`/items/creator/${u}`,title:n("storeSettings.back"),"aria-label":n("storeSettings.back"),children:t.jsx(I,{name:"arrow-left"})}):null,t.jsx(O,{children:n("storeSettings.title")})]}),u?t.jsxs(He,{href:`/items/creator/${u}`,target:"_blank",rel:"noopener noreferrer",children:[n("storeSettings.seeAsGuest"),t.jsx(I,{name:"external-link"})]}):null]}),q?t.jsx(Ee,{size:"large",label:n("storeSettings.loading")}):t.jsxs(t.Fragment,{children:[t.jsxs(j,{children:[t.jsx("span",{className:"field__label",children:n("storeSettings.cover")}),t.jsxs(Pe,{role:"group","aria-label":n("storeSettings.cover"),children:[v.map(e=>{const i=E===e.name;return t.jsx(L,{type:"button","data-testid":"cover-picker-tile","data-selected":i,"aria-pressed":i,onClick:()=>Z(e.name,e.url),children:t.jsx("img",{src:e.url,alt:"",loading:"lazy"})},e.name)}),c?t.jsx(L,{type:"button","data-testid":"cover-picker-tile","data-variant":"custom","data-selected":!E,"aria-pressed":!E,onClick:ie,children:t.jsx("img",{src:c.url,alt:""})}):null,t.jsxs(L,{type:"button","data-testid":"cover-picker-tile","data-variant":"upload",onClick:()=>{var e;return(e=T.current)==null?void 0:e.click()},children:[t.jsx(I,{name:"upload"}),t.jsx("span",{children:n("storeSettings.upload")})]}),t.jsx(Be,{ref:T,type:"file",accept:"image/png, image/jpeg, image/webp","data-testid":"cover-picker-input",onChange:te})]}),D?t.jsx(A,{message:n("storeSettings.sizeError",{max:Y(W),current:Y($)})}):null]}),t.jsxs(j,{as:"label",children:[t.jsx("span",{className:"field__label",children:n("storeSettings.description")}),t.jsx("textarea",{value:o.description,rows:4,disabled:x,onChange:e=>g(i=>({...i,description:e.target.value}))})]}),t.jsxs(j,{as:"label",children:[t.jsx("span",{className:"field__label",children:n("storeSettings.website")}),t.jsx("input",{type:"url",value:o.links.website,placeholder:f.website,disabled:x,onChange:e=>g(i=>({...i,links:{...i.links,website:e.target.value.replace(/\s/g,"")}}))}),F("website",o.links.website)?null:t.jsx(A,{message:n("storeSettings.linkError",{value:f.website})})]}),["twitter","discord","facebook"].map(e=>t.jsxs(j,{as:"label",children:[t.jsx("span",{className:"field__label",children:n(`storeSettings.${e}`)}),t.jsxs(Te,{children:[t.jsx(De,{children:f[e]}),t.jsx("input",{type:"text",value:ne(e),disabled:x,onChange:i=>se(e,i.target.value)})]})]},e)),t.jsx(Re,{children:t.jsx(Fe,{variant:"white","data-testid":"store-settings-save",onClick:()=>void re(),disabled:!X,children:x?n("storeSettings.saving"):n("storeSettings.save")})})]})]})}export{Je as StoreSettings,Je as default};
244
- //# sourceMappingURL=StoreSettings-BTzgYL0y.js.map
244
+ //# sourceMappingURL=StoreSettings-Dtc2cFNu.js.map
@@ -1,4 +1,4 @@
1
- import{a as P,b as M,j as e,N as W,r as A}from"./react-DjOKjwAj.js";import{t as q,s as t,q as _,z as J,A as O,o as U,n as G,b as n,p as H,D as T,C as X,E as K,F as Q,c as Y,B as V,G as Z}from"./index-D_MyRErw.js";import{C as ee}from"./Confetti-CnwifU5L.js";import{J as te,a as ne}from"./jump-Bhj8Kohh.js";import{w as ie,S as se}from"./buy-gasless-C-8JY4JE.js";import"./dcl-schemas-BrhDU8Ob.js";import"./sentry-BxdwO3pv.js";import"./ethers-13WTbgZT.js";import"./intl-AKLEHPeO.js";import"./authorizations-DbYL1SFo.js";import"./sendMetaTransaction-kIltSLeV.js";import"./buy-VoaFL0gA.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new r.Error().stack;o&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[o]="0b20199c-ca88-4189-9f64-c29590ace2a7",r._sentryDebugIdIdentifier="sentry-dbid-0b20199c-ca88-4189-9f64-c29590ace2a7")}catch{}})();const{colors:i,radius:j}=q,l="@media (max-width: 600px)",B=t.div`
1
+ import{a as P,b as M,j as e,N as W,r as A}from"./react-DcSw8tCD.js";import{t as q,s as t,q as _,z as J,A as O,o as U,n as G,b as n,p as H,D as T,C as X,E as K,F as Q,c as Y,B as V,G as Z}from"./index-B-dIqjhn.js";import{C as ee}from"./Confetti-B_SGZDIW.js";import{J as te,a as ne}from"./jump-CZr_KgFH.js";import{w as ie,S as se}from"./buy-gasless-B29llLau.js";import"./dcl-schemas-CN-1-wGb.js";import"./sentry-CAS3BNIy.js";import"./ethers-3hUTVH_L.js";import"./intl-AKLEHPeO.js";import"./authorizations-Bq00FRrP.js";import"./sendMetaTransaction-CcfiyKVp.js";import"./buy-DZz-IuoV.js";(function(){try{var r=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new r.Error().stack;o&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[o]="0b20199c-ca88-4189-9f64-c29590ace2a7",r._sentryDebugIdIdentifier="sentry-dbid-0b20199c-ca88-4189-9f64-c29590ace2a7")}catch{}})();const{colors:i,radius:j}=q,l="@media (max-width: 600px)",B=t.div`
2
2
  /* Its own stacking context, above the confetti layer (z-index 0). Needed because z-index is inert without
3
3
  a position, so the content would otherwise sit below the burst regardless of order. */
4
4
  position: relative;
@@ -351,4 +351,4 @@ import{a as P,b as M,j as e,N as W,r as A}from"./react-DjOKjwAj.js";import{t as
351
351
  min-width: 160px;
352
352
  text-align: center;
353
353
  `;function Te(r){return null}const Be=r=>new Promise(o=>setTimeout(o,r)),N=()=>e.jsx("svg",{viewBox:"0 0 18 18",width:"12",height:"12",children:e.jsx("path",{d:"M4 9l3.5 3.5L14 5",fill:"none",stroke:"#fff",strokeWidth:"2.4",strokeLinecap:"round",strokeLinejoin:"round"})});function Se(r,o){const[s,a]=A.useState(r?"pending":"confirmed"),x=o?`${o.owner}-${o.contractAddress}-${o.itemId}`:"";return A.useEffect(()=>{if(!r)return;let p=!1;return(async()=>{let f=!1;for(let c=0;c<20&&!p;c++)try{await ie(r,{timeoutMs:15e3}),f=!0;break}catch(y){if(y instanceof se)continue;p||a("failed");return}if(!p){if(!f){a("timed-out");return}if(!o){a("confirmed");return}a("indexing");for(let c=0;c<40&&!p;c++){if(await Z(o.owner,o.contractAddress,o.itemId)){p||a("confirmed");return}await Be(3e3)}p||a("timed-out")}})(),()=>{p=!0}},[r,x]),s}const Le=Y.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Ee(r){var s;const o=(s=r.find(a=>a.urn))==null?void 0:s.urn;return`decentraland://open?iap_enabled=true${o?`&urn=${encodeURIComponent(o)}`:""}`}function Xe(){var R;const{state:r,search:o}=P(),s=r??Te(),a=M(),{session:x}=U(),p=s==null?void 0:s.txHash,w=(s==null?void 0:s.items)??[],f=s!=null&&s.creditsAdded&&s.creditsAdded>0?s.creditsAdded:null,c=w[0],y=x!=null&&x.address&&(c!=null&&c.contractAddress)&&(c!=null&&c.itemId)?{owner:x.address,contractAddress:c.contractAddress,itemId:c.itemId}:null,g=Se(s!=null&&s.settled?void 0:p,y);G({title:n("seo.success.title"),noindex:!0});const h=w;if(h.length===0)return e.jsx(W,{to:"/items",replace:!0});const z=h[0],m=(R=s==null?void 0:s.txHashes)!=null&&R.length?s.txHashes:p?[p]:[],u=m.length>0&&H(x==null?void 0:x.providerType)?m.map((d,v)=>e.jsx(ae,{href:`${Le}${d}`,target:"_blank",rel:"noreferrer",children:m.length>1?n("success.viewTransactionNumbered",{n:v+1,total:m.length}):n("success.viewTransaction")},d)):null;return g!=="confirmed"?e.jsx(B,{children:e.jsx(re,{children:g==="pending"||g==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(oe,{className:"spinner","aria-hidden":!0}),e.jsx($,{children:g==="indexing"?n("success.finalizing"):n("success.processing")}),e.jsx(C,{children:g==="indexing"?e.jsxs(e.Fragment,{children:[n("success.indexingBefore")," ",h.length===1?e.jsx("strong",{children:z.name}):n("success.itemCount",{count:h.length})," ",n("success.indexingAfter")]}):e.jsxs(e.Fragment,{children:[n("success.confirmingBefore")," ",h.length===1?e.jsx("strong",{children:z.name}):n("success.itemCount",{count:h.length})," ",n("success.confirmingAfter")]})}),u?e.jsx(b,{children:u}):null]}):g==="timed-out"?e.jsxs(e.Fragment,{children:[e.jsx($,{children:n("success.stillProcessingTitle")}),e.jsxs(C,{children:[n("success.timedOutBefore")," ",e.jsx("button",{className:"link",onClick:()=>a("/activity"),children:n("nav.activity")})," ",n("success.timedOutAfter")]}),u?e.jsx(b,{children:u}):null,e.jsxs(S,{children:[e.jsx(I,{variant:"purple",onClick:()=>a("/activity"),children:n("success.viewActivity")}),e.jsx(I,{variant:"ghost",onClick:()=>a("/items"),children:n("success.keepShopping")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx($,{children:n("success.failedTitle")}),e.jsx(C,{children:n("success.failedBody")}),u?e.jsx(b,{children:u}):null,e.jsx(S,{children:e.jsx(I,{variant:"purple",onClick:()=>a("/items"),children:n("success.backToShop")})})]})})}):e.jsxs(B,{children:[e.jsx(ee,{}),e.jsxs(ce,{children:[e.jsxs(de,{role:"status",children:[e.jsx(le,{"aria-hidden":!0,children:e.jsxs("svg",{viewBox:"0 0 60 60",width:"60",height:"60",children:[e.jsx("circle",{cx:"30",cy:"30",r:"30",fill:"#34ce77"}),e.jsx("path",{d:"M18 31l8 8 16-18",fill:"none",stroke:"#fff",strokeWidth:"4.5",strokeLinecap:"round",strokeLinejoin:"round"})]})}),e.jsxs(pe,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",T()?n("success.bannerBodyIap"):n("success.bannerBody")]})]}),e.jsxs(xe,{children:[f?e.jsxs(ge,{"data-testid":"success-credits",children:[e.jsx(L,{"aria-hidden":!0,children:e.jsx(N,{})}),e.jsx(fe,{}),e.jsxs(me,{children:[e.jsx(be,{children:n("getCredits.creditsAmount",{credits:f,currency:X.name})})," ",e.jsx(je,{children:n("getCredits.creditsAdded")})]})]}):null,h.map((d,v)=>{const k=d.quantity??1;return e.jsxs(he,{children:[v>0?e.jsx(ue,{"aria-hidden":!0}):null,e.jsxs(we,{children:[e.jsxs(ye,{"data-thumb":!0,children:[d.thumbnail?e.jsx("img",{src:d.thumbnail,alt:""}):null,e.jsx(L,{"aria-hidden":!0,children:e.jsx(N,{})})]}),e.jsxs(ve,{"data-info":!0,children:[e.jsxs(ke,{title:d.name,children:[d.name||n("buyModal.itemFallback"),k>1?e.jsx($e,{children:n("cartCheckout.qty",{count:k})}):null]}),d.creator?e.jsx(Ce,{address:d.creator,linkToProfile:!0}):null]}),e.jsxs(Ie,{"data-price":!0,children:[e.jsx(ze,{}),e.jsx("span",{children:K(d.priceCredits*k)})]})]})]},d.id)})]}),u?e.jsx(b,{"data-receipt":!0,children:u}):null,e.jsx(Re,{children:T()?e.jsxs(e.Fragment,{children:[e.jsx(E,{"data-variant":"ghost",onClick:()=>a("/overview"),children:n("success.done")}),e.jsx(F,{"data-variant":"ruby",href:Ee(h),children:n("success.goToBackpack")})]}):e.jsxs(e.Fragment,{children:[e.jsx(E,{"data-variant":"ghost",onClick:()=>a(Q(h.map(d=>d.category))),children:n("success.myAssets")}),e.jsxs(F,{"data-variant":"ruby",href:te,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(Ae,{"aria-hidden":!0,children:e.jsx(ne,{})})]})]})})]})]})}export{Xe as Success,Xe as default};
354
- //# sourceMappingURL=Success-x2GWyHwZ.js.map
354
+ //# sourceMappingURL=Success-DmniYPt7.js.map
@@ -1,2 +1,2 @@
1
- import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as _,C as m,B as N,b as L,m as E,A as O,n as z,d as W,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-BT9sgsfW.js";import{au as b}from"./NetworkUtil-YfaeL3XJ.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new n.Error().stack;o&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[o]="d5bf39f8-0096-4633-a71d-e79393a73741",n._sentryDebugIdIdentifier="sentry-dbid-d5bf39f8-0096-4633-a71d-e79393a73741")}catch{}})();const C={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=C.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,g={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:W.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...g}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,y,h,A,S,P;const n=m.state.activeChain,o=((i=m.getAccountData(n))==null?void 0:i.caipAddress)??m.state.activeCaipAddress,t=L.getPlainAddress(o),s=R(),c=H.getConnectorId(m.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((y=e.sourceToken)!=null&&y.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(h=e.sourceToken)==null?void 0:h.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===b.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=g.myTokensWithBalance,e.tokensPriceMap=g.tokensPriceMap,e.initialized=g.initialized,e.initializing=g.initializing,e.switchingTokens=g.switchingTokens,e.sourceToken=g.sourceToken,e.sourceTokenAmount=g.sourceTokenAmount,e.sourceTokenPriceInUSD=g.sourceTokenPriceInUSD,e.toToken=g.toToken,e.toTokenAmount=g.toTokenAmount,e.toTokenPriceInUSD=g.toTokenPriceInUSD,e.networkPrice=g.networkPrice,e.networkTokenSymbol=g.networkTokenSymbol,e.networkBalanceInUSD=g.networkBalanceInUSD,e.inputError=g.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=m.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=W.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(W.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:m.state.activeCaipNetwork,address:(s=m.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=m.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=m.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case b.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case b.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=C.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=m.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=L.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const y=L.getPlainAddress(u.tx.to);if(!y)throw new Error("SwapController:createSwapTransaction - address is required");const h={data:u.tx.data,to:y,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=C.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=h,h}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:b.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=m.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(b.CHAIN.EVM)===_.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,y,h,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:b.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((y=m.state.activeCaipNetwork)==null?void 0:y.caipNetworkId)||"",swapFromToken:((h=a.state.sourceToken)==null?void 0:h.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(b.CHAIN.EVM)===_.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=m.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(b.CHAIN.EVM)===_.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return C.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=C.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=C.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=C.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=C.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
2
- //# sourceMappingURL=SwapController-CmNQixyT.js.map
1
+ import{N as T,j as G,R as I,S as f,k as B,E as M,l as F,W as _,C as m,B as N,b as L,m as E,A as O,n as z,d as W,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-BClgaXM6.js";import{au as b}from"./NetworkUtil-B_9c-U8Q.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},o=new n.Error().stack;o&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[o]="d5bf39f8-0096-4633-a71d-e79393a73741",n._sentryDebugIdIdentifier="sentry-dbid-d5bf39f8-0096-4633-a71d-e79393a73741")}catch{}})();const C={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=C.getGasPriceInEther(o,t);return T.bigNumber(n).times(s).toNumber()},getPriceImpact({sourceTokenAmount:n,sourceTokenPriceInUSD:o,toTokenPriceInUSD:t,toTokenAmount:s}){const c=T.bigNumber(n).times(o),r=T.bigNumber(s).times(t);return c.minus(r).div(c).times(100).toNumber()},getMaxSlippage(n,o){const t=T.bigNumber(n).div(100);return T.multiply(o,t).toNumber()},getProviderFee(n,o=.0085){return T.bigNumber(n).times(o).toString()},isInsufficientNetworkTokenForGas(n,o){const t=o||"0";return T.bigNumber(n).eq(0)?!0:T.bigNumber(T.bigNumber(t)).gt(n)},isInsufficientSourceTokenForSwap(n,o,t){var r,d;const s=(d=(r=t==null?void 0:t.find(l=>l.address===o))==null?void 0:r.quantity)==null?void 0:d.numeric;return T.bigNumber(s||"0").lt(n)}},x=15e4,Q=6,g={initializing:!1,initialized:!1,loadingPrices:!1,loadingQuote:!1,loadingApprovalTransaction:!1,loadingBuildTransaction:!1,loadingTransaction:!1,switchingTokens:!1,fetchError:!1,approvalTransaction:void 0,swapTransaction:void 0,transactionError:void 0,sourceToken:void 0,sourceTokenAmount:"",sourceTokenPriceInUSD:0,toToken:void 0,toTokenAmount:"",toTokenPriceInUSD:0,networkPrice:"0",networkBalanceInUSD:"0",networkTokenSymbol:"",inputError:void 0,slippage:W.CONVERT_SLIPPAGE_TOLERANCE,tokens:void 0,popularTokens:void 0,suggestedTokens:void 0,foundTokens:void 0,myTokensWithBalance:void 0,tokensPriceMap:{},gasFee:"0",gasPriceInUSD:0,priceImpact:void 0,maxSlippage:void 0,providerFee:void 0},e=$({...g}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,y,h,A,S,P;const n=m.state.activeChain,o=((i=m.getAccountData(n))==null?void 0:i.caipAddress)??m.state.activeCaipAddress,t=L.getPlainAddress(o),s=R(),c=H.getConnectorId(m.state.activeChain);if(!t)throw new Error("No address found to swap the tokens from.");const r=!((u=e.toToken)!=null&&u.address)||!((p=e.toToken)!=null&&p.decimals),d=!((w=e.sourceToken)!=null&&w.address)||!((y=e.sourceToken)!=null&&y.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(h=e.sourceToken)==null?void 0:h.address,toTokenAddress:(A=e.toToken)==null?void 0:A.address,toTokenAmount:e.toTokenAmount,toTokenDecimals:(S=e.toToken)==null?void 0:S.decimals,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:(P=e.sourceToken)==null?void 0:P.decimals,invalidToToken:r,invalidSourceToken:d,invalidSourceTokenAmount:l,availableToSwap:o&&!r&&!d&&!l,isAuthConnector:c===b.CONNECTOR_ID.AUTH}},async setSourceToken(n){if(!n){e.sourceToken=n,e.sourceTokenAmount="",e.sourceTokenPriceInUSD=0;return}e.sourceToken=n,await a.setTokenPrice(n.address,"sourceToken")},setSourceTokenAmount(n){e.sourceTokenAmount=n},async setToToken(n){if(!n){e.toToken=n,e.toTokenAmount="",e.toTokenPriceInUSD=0;return}e.toToken=n,await a.setTokenPrice(n.address,"toToken")},setToTokenAmount(n){e.toTokenAmount=n?T.toFixed(n,Q):""},async setTokenPrice(n,o){let t=e.tokensPriceMap[n]||0;t||(e.loadingPrices=!0,t=await a.getAddressPrice(n)),o==="sourceToken"?e.sourceTokenPriceInUSD=t:o==="toToken"&&(e.toTokenPriceInUSD=t),e.loadingPrices&&(e.loadingPrices=!1),a.getParams().availableToSwap&&!e.switchingTokens&&a.swapTokens()},async switchTokens(){if(!(e.initializing||!e.initialized||e.switchingTokens)){e.switchingTokens=!0;try{const n=e.toToken?{...e.toToken}:void 0,o=e.sourceToken?{...e.sourceToken}:void 0,t=n&&e.toTokenAmount===""?"1":e.toTokenAmount;a.setSourceTokenAmount(t),a.setToTokenAmount(""),await a.setSourceToken(n),await a.setToToken(o),e.switchingTokens=!1,a.swapTokens()}catch(n){throw e.switchingTokens=!1,n}}},resetState(){e.myTokensWithBalance=g.myTokensWithBalance,e.tokensPriceMap=g.tokensPriceMap,e.initialized=g.initialized,e.initializing=g.initializing,e.switchingTokens=g.switchingTokens,e.sourceToken=g.sourceToken,e.sourceTokenAmount=g.sourceTokenAmount,e.sourceTokenPriceInUSD=g.sourceTokenPriceInUSD,e.toToken=g.toToken,e.toTokenAmount=g.toTokenAmount,e.toTokenPriceInUSD=g.toTokenPriceInUSD,e.networkPrice=g.networkPrice,e.networkTokenSymbol=g.networkTokenSymbol,e.networkBalanceInUSD=g.networkBalanceInUSD,e.inputError=g.inputError},resetValues(){var t;const{networkAddress:n}=a.getParams(),o=(t=e.tokens)==null?void 0:t.find(s=>s.address===n);a.setSourceToken(o),a.setToToken(void 0)},getApprovalLoadingState(){return e.loadingApprovalTransaction},clearError(){e.transactionError=void 0},async initializeState(){if(!e.initializing){if(e.initializing=!0,!e.initialized)try{await a.fetchTokens(),e.initialized=!0}catch{e.initialized=!1,f.showError("Failed to initialize swap"),I.goBack()}e.initializing=!1}},async fetchTokens(){var t;const{networkAddress:n}=a.getParams();await a.getNetworkTokenPrice(),await a.getMyTokensWithBalance();const o=(t=e.myTokensWithBalance)==null?void 0:t.find(s=>s.address===n);o&&(e.networkTokenSymbol=o.symbol,a.setSourceToken(o),a.setSourceTokenAmount("0"))},async getTokenList(){var o,t;const n=(o=m.state.activeCaipNetwork)==null?void 0:o.caipNetworkId;if(!(e.caipNetworkId===n&&e.tokens))try{e.tokensLoading=!0;const s=await E.getTokenList(n);e.tokens=s,e.caipNetworkId=n,e.popularTokens=s.sort((i,u)=>i.symbol<u.symbol?-1:i.symbol>u.symbol?1:0);const r=(n&&((t=W.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(W.SWAP_SUGGESTED_TOKENS||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i).filter(i=>!r.some(u=>u.address===i.address));e.suggestedTokens=[...r,...l]}catch{e.tokens=[],e.popularTokens=[],e.suggestedTokens=[]}finally{e.tokensLoading=!1}},async getAddressPrice(n){var i,u;const o=e.tokensPriceMap[n];if(o)return o;const t=await N.fetchTokenPrice({addresses:[n]}),s=(t==null?void 0:t.fungibles)||[],c=[...e.tokens||[],...e.myTokensWithBalance||[]],r=(i=c==null?void 0:c.find(p=>p.address===n))==null?void 0:i.symbol,d=((u=s.find(p=>p.symbol.toLowerCase()===(r==null?void 0:r.toLowerCase())))==null?void 0:u.price)||0,l=parseFloat(d.toString());return e.tokensPriceMap[n]=l,l},async getNetworkTokenPrice(){var c;const{networkAddress:n}=a.getParams(),t=(c=(await N.fetchTokenPrice({addresses:[n]}).catch(()=>(f.showError("Failed to fetch network token price"),{fungibles:[]}))).fungibles)==null?void 0:c[0],s=(t==null?void 0:t.price.toString())||"0";e.tokensPriceMap[n]=parseFloat(s),e.networkTokenSymbol=(t==null?void 0:t.symbol)||"",e.networkPrice=s},async getMyTokensWithBalance(n){var s;const o=await z.getMyTokensWithBalance({forceUpdate:n,caipNetwork:m.state.activeCaipNetwork,address:(s=m.getAccountData())==null?void 0:s.address}),t=E.mapBalancesToSwapTokens(o);t&&(await a.getInitialGasPrice(),a.setBalances(t))},setBalances(n){const{networkAddress:o}=a.getParams(),t=m.state.activeCaipNetwork;if(!t)return;const s=n.find(c=>c.address===o);n.forEach(c=>{e.tokensPriceMap[c.address]=c.price||0}),e.myTokensWithBalance=n.filter(c=>c.address.startsWith(t.caipNetworkId)),e.networkBalanceInUSD=s?T.multiply(s.quantity.numeric,s.price).toString():"0"},async getInitialGasPrice(){var o,t;const n=await E.fetchGasPrice();if(!n)return{gasPrice:null,gasPriceInUSD:null};switch((t=(o=m.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case b.CHAIN.SOLANA:return e.gasFee=n.standard??"0",e.gasPriceInUSD=T.multiply(n.standard,e.networkPrice).div(1e9).toNumber(),{gasPrice:BigInt(e.gasFee),gasPriceInUSD:Number(e.gasPriceInUSD)};case b.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=C.getGasPriceInUSD(e.networkPrice,r,c);return e.gasFee=s,e.gasPriceInUSD=d,{gasPrice:c,gasPriceInUSD:d}}},async swapTokens(){var r,d,l;const n=(r=m.getAccountData())==null?void 0:r.address,o=e.sourceToken,t=e.toToken,s=T.bigNumber(e.sourceTokenAmount).gt(0);if(s||a.setToTokenAmount(""),!t||!o||e.loadingPrices||!s||!n)return;e.loadingQuote=!0;const c=T.bigNumber(e.sourceTokenAmount).times(10**o.decimals).round(0).toFixed(0);try{const i=await N.fetchSwapQuote({userAddress:n,from:o.address,to:t.address,gasPrice:e.gasFee,amount:c.toString()});e.loadingQuote=!1;const u=(l=(d=i==null?void 0:i.quotes)==null?void 0:d[0])==null?void 0:l.toAmount;if(!u){O.open({displayMessage:"Incorrect amount",debugMessage:"Please enter a valid amount"},"error");return}const p=T.bigNumber(u).div(10**t.decimals).toString();a.setToTokenAmount(p),a.hasInsufficientToken(e.sourceTokenAmount,o.address)?e.inputError="Insufficient balance":(e.inputError=void 0,a.setTransactionDetails())}catch(i){const u=await E.handleSwapError(i);e.loadingQuote=!1,e.inputError=u||"Insufficient balance"}},async getTransaction(){const{fromCaipAddress:n,availableToSwap:o}=a.getParams(),t=e.sourceToken,s=e.toToken;if(!(!n||!o||!t||!s||e.loadingQuote))try{e.loadingBuildTransaction=!0;const c=await E.fetchSwapAllowance({userAddress:n,tokenAddress:t.address,sourceTokenAmount:e.sourceTokenAmount,sourceTokenDecimals:t.decimals});let r;return c?r=await a.createSwapTransaction():r=await a.createAllowanceTransaction(),e.loadingBuildTransaction=!1,e.fetchError=!1,r}catch{I.goBack(),f.showError("Failed to check allowance"),e.loadingBuildTransaction=!1,e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},async createAllowanceTransaction(){const{fromCaipAddress:n,sourceTokenAddress:o,toTokenAddress:t}=a.getParams();if(!(!n||!t)){if(!o)throw new Error("createAllowanceTransaction - No source token address found.");try{const s=await N.generateApproveCalldata({from:o,to:t,userAddress:n}),c=L.getPlainAddress(s.tx.from);if(!c)throw new Error("SwapController:createAllowanceTransaction - address is required");const r={data:s.tx.data,to:c,gasPrice:BigInt(s.tx.eip155.gasPrice),value:BigInt(s.tx.value),toAmount:e.toTokenAmount};return e.swapTransaction=void 0,e.approvalTransaction={data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount},{data:r.data,to:r.to,gasPrice:r.gasPrice,value:r.value,toAmount:r.toAmount}}catch{I.goBack(),f.showError("Failed to create approval transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}}},async createSwapTransaction(){var d,l;const{networkAddress:n,fromCaipAddress:o,sourceTokenAmount:t}=a.getParams(),s=e.sourceToken,c=e.toToken;if(!o||!t||!s||!c)return;let r=(d=B.parseUnits(t,s.decimals))==null?void 0:d.toString();try{const i=s.address===n;let u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:r,disableEstimate:!0}),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice);if(i&&r){const A=(l=e.myTokensWithBalance)==null?void 0:l.find(S=>S.address===n);if(A){const S=parseInt(A.quantity.decimals,10),P=B.parseUnits(A.quantity.numeric,S)??0n,v=p*w;if(BigInt(r)+v>P){const k=P>v?P-v:0n;k>0n&&(u=await N.generateSwapCalldata({userAddress:o,from:s.address,to:c.address,amount:k.toString(),disableEstimate:!0}),r=k.toString(),p=BigInt(u.tx.eip155.gas),w=BigInt(u.tx.eip155.gasPrice))}}}const y=L.getPlainAddress(u.tx.to);if(!y)throw new Error("SwapController:createSwapTransaction - address is required");const h={data:u.tx.data,to:y,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=C.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=h,h}catch{I.goBack(),f.showError("Failed to create transaction"),e.approvalTransaction=void 0,e.swapTransaction=void 0,e.fetchError=!0;return}},onEmbeddedWalletApprovalSuccess(){f.showLoading("Approve limit increase in your wallet"),I.replace("SwapPreview")},async sendTransactionForApproval(n){var c,r,d;const{fromAddress:o,isAuthConnector:t}=a.getParams();e.loadingApprovalTransaction=!0,t?I.pushTransactionStack({onSuccess:a.onEmbeddedWalletApprovalSuccess}):f.showLoading("Approve limit increase in your wallet");try{await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:b.CHAIN.EVM}),await a.swapTokens(),await a.getTransaction(),e.approvalTransaction=void 0,e.loadingApprovalTransaction=!1}catch(l){const i=l;e.transactionError=i==null?void 0:i.displayMessage,e.loadingApprovalTransaction=!1,f.showError((i==null?void 0:i.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_APPROVAL_ERROR",properties:{message:(i==null?void 0:i.displayMessage)||(i==null?void 0:i.message)||"Unknown",network:((c=m.state.activeCaipNetwork)==null?void 0:c.caipNetworkId)||"",swapFromToken:((r=a.state.sourceToken)==null?void 0:r.symbol)||"",swapToToken:((d=a.state.toToken)==null?void 0:d.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(b.CHAIN.EVM)===_.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,y,h,A,S,P,v;if(!n)return;const{fromAddress:o,toTokenAmount:t,isAuthConnector:s}=a.getParams();e.loadingTransaction=!0;const c=`Swapping ${(d=e.sourceToken)==null?void 0:d.symbol} to ${T.formatNumberToLocalString(t,3)} ${(l=e.toToken)==null?void 0:l.symbol}`,r=`Swapped ${(i=e.sourceToken)==null?void 0:i.symbol} to ${T.formatNumberToLocalString(t,3)} ${(u=e.toToken)==null?void 0:u.symbol}`;s?I.pushTransactionStack({onSuccess(){I.replace("Account"),f.showLoading(c),D.resetState()}}):f.showLoading("Confirm transaction in your wallet");try{const U=[(p=e.sourceToken)==null?void 0:p.address,(w=e.toToken)==null?void 0:w.address].join(","),k=await B.sendTransaction({address:o,to:n.to,data:n.data,value:n.value,chainNamespace:b.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((y=m.state.activeCaipNetwork)==null?void 0:y.caipNetworkId)||"",swapFromToken:((h=a.state.sourceToken)==null?void 0:h.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(b.CHAIN.EVM)===_.ACCOUNT_TYPES.SMART_ACCOUNT}}),D.resetState(),s||I.replace("Account"),D.getMyTokensWithBalance(U),k}catch(U){const k=U;e.transactionError=k==null?void 0:k.displayMessage,e.loadingTransaction=!1,f.showError((k==null?void 0:k.displayMessage)||"Transaction error"),M.sendEvent({type:"track",event:"SWAP_ERROR",properties:{message:(k==null?void 0:k.displayMessage)||(k==null?void 0:k.message)||"Unknown",network:((S=m.state.activeCaipNetwork)==null?void 0:S.caipNetworkId)||"",swapFromToken:((P=a.state.sourceToken)==null?void 0:P.symbol)||"",swapToToken:((v=a.state.toToken)==null?void 0:v.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(b.CHAIN.EVM)===_.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return C.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=C.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=C.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=C.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=C.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
2
+ //# sourceMappingURL=SwapController-DAEACGPq.js.map
@@ -1,2 +1,2 @@
1
- var ve=Object.defineProperty;var me=(t,r,e)=>r in t?ve(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var p=(t,r,e)=>me(t,typeof r!="symbol"?r+"":r,e);import{W as ue,a as Q,C as xe,B as be,f as X}from"./ethers-13WTbgZT.js";import{a as Ce,d as B}from"./dcl-schemas-BrhDU8Ob.js";import{c as ee}from"./react-DjOKjwAj.js";import{cx as Ie,b2 as te,g as re}from"./index-D_MyRErw.js";import{c as q,e as Ee}from"./index-nbIX4Ytl.js";import{s as Re}from"./sendMetaTransaction-kIltSLeV.js";import"./sentry-BxdwO3pv.js";import"./intl-AKLEHPeO.js";import"./events-Bfmg7Rrt.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new t.Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="8273e4bf-e3af-4157-af0a-4627bfe6eb14",t._sentryDebugIdIdentifier="sentry-dbid-8273e4bf-e3af-4157-af0a-4627bfe6eb14")}catch{}})();async function Pe(t){const r=await de();if(r){const e=await new ue(r).getSigner().getChainId();if(t===e)return r}return q.createProvider(Ce.ProviderType.NETWORK,t)}async function de(){try{return await q.getProvider()}catch{try{const{provider:t}=await q.tryPreviousConnection();return t}catch{return null}}}function ne(t){return Math.floor(t/1e3)}function ae(t){switch(t.assetType){case B.TradeAssetType.ERC721:return t.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return t.itemId;case B.TradeAssetType.ERC20:return t.amount;default:return console.error("Invalid asset type:",t),""}}function Ae(t){var r;return{checks:{uses:t.checks.uses,expiration:ne(t.checks.expiration),effective:ne(t.checks.effective),salt:Q(t.checks.salt,32),contractSignatureIndex:t.checks.contractSignatureIndex,signerSignatureIndex:t.checks.signerSignatureIndex,allowedRoot:Q(t.checks.allowedRoot,32),externalChecks:(r=t.checks.externalChecks)==null?void 0:r.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:t.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:t.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(t,r){const e=Ae(t);return{signer:t.signer,signature:t.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:r}))}}async function Se(t){const r=await t.request({method:"eth_chainId",params:[]});let e;return typeof r=="string"?e=parseInt(r,16):e=r,e}async function Fe(t){const r=await Pe(t);return new ue(r)}const S=new Ee.EventEmitter;var b;(function(t){t.ERROR="error",t.SUCCESS="success",t.PROMPT="prompt",t.ACCEPT="accept",t.REJECT="reject"})(b||(b={}));let _e="https://transactions-api.decentraland.org/v1";const ke=()=>_e,Le=()=>new Promise((t,r)=>{const e=()=>{S.removeAllListeners(b.REJECT),t(!0)},i=()=>{S.removeAllListeners(b.ACCEPT),r(new Error("User rejected transaction"))};S.addListener(b.ACCEPT,e),S.addListener(b.REJECT,i)});async function oe(...t){const[r,e,...i]=t;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(r.chainId),E=new xe(r.address,r.abi,l),w=await(typeof e=="function"?e(E.populateTransaction):E.populateTransaction[e](...i));if(c===r.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let L=be.from(0);try{const U=await v.getGasPrice(),k=await v.estimateGas(w);L=U.mul(k)}catch{}if(!L.isZero()){const U=Le(),k=await v.getBalance();S.emit(b.PROMPT,{transactionGasPrice:X(L),userBalance:X(k),chainId:r.chainId}),await U}}const P=await v.sendTransaction(w);return S.emit(b.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Re(s,l,w.data,r,{serverURL:ke()});return S.emit(b.SUCCESS,{txHash:v}),v}}catch(s){const c={type:b.ERROR,error:s};throw S.emit(b.ERROR,c),s}}var D={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var Ue=D.exports,ie;function Oe(){return ie||(ie=1,(function(t,r){(function(e){var i=r&&!r.nodeType&&r,s=t&&!t.nodeType&&t,c=typeof ee=="object"&&ee;(c.global===c||c.window===c||c.self===c)&&(e=c);var l,E=2147483647,w=36,v=1,P=26,L=38,U=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},N=w-v,C=Math.floor,O=String.fromCharCode,M;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function V(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function H(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function we(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:w}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?C(n/U):n>>1,n+=C(n/a);n>N*P>>1;u+=w)n=C(n/N);return C(u+(N+1)*n/(n+L))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,T,m,I,R,f,g,x,A,_;for(T=n.lastIndexOf(J),T<0&&(T=0),m=0;m<T;++m)n.charCodeAt(m)>=128&&F("not-basic"),a.push(n.charCodeAt(m));for(I=T>0?T+1:0;I<o;){for(R=d,f=1,g=w;I>=o&&F("invalid-input"),x=we(n.charCodeAt(I++)),(x>=w||x>C((E-d)/f))&&F("overflow"),d+=x*f,A=g<=h?v:g>=h+P?P:g-h,!(x<A);g+=w)_=w-A,f>C(E/_)&&F("overflow"),f*=_;u=a.length+1,h=Z(d-R,u,R==0),C(d/u)>E-y&&F("overflow"),y+=C(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,T,m,I,R,f,g=[],x,A,_,j;for(n=H(n),x=n.length,a=G,o=0,y=k,h=0;h<x;++h)f=n[h],f<128&&g.push(O(f));for(u=d=g.length,d&&g.push(J);u<x;){for(T=E,h=0;h<x;++h)f=n[h],f>=a&&f<T&&(T=f);for(A=u+1,T-a>C((E-o)/A)&&F("overflow"),o+=(T-a)*A,a=T,h=0;h<x;++h)if(f=n[h],f<a&&++o>E&&F("overflow"),f==a){for(m=o,I=w;R=I<=y?v:I>=y+P?P:I-y,!(m<R);I+=w)j=m-R,_=w-R,g.push(O(Y(R+j%_,0))),m=C(j/_);g.push(O(Y(m,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return g.join("")}function Te(n){return V(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function ge(n){return V(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:H,encode:W},decode:K,encode:z,toASCII:ge,toUnicode:Te},i&&s)if(t.exports==i)s.exports=l;else for(M in l)l.hasOwnProperty(M)&&(i[M]=l[M]);else e.punycode=l})(Ue)})(D,D.exports)),D.exports}Oe();var le=(function(t){function r(){var i=this||self;return delete t.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return r();t.defineProperty(t.prototype,"__magic__",{configurable:!0,get:r});var e=__magic__;return e})(Object),De=le.URL;le.URLSearchParams;var Me={URL:De};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const Ne=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Me.URL;class Ge{constructor(r,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",r=>new Promise(e=>{setTimeout(e,r)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(r,e)=>{const i=new qe(r,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return Ie.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(r,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(r,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=r,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??Ne,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class et{constructor(r,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(r,e,{identity:i,retries:0})}async addTrade(r){return this.tradesAPI.addTrade(r)}async fetchTrade(r){return this.tradesAPI.fetchTrade(r)}async accept(r,e){const i=te(r.contract),s=re(i,r.chainId),c=se(r,e);return oe(s,"accept",[c])}async cancel(r,e){const i=te(r.contract),s=re(i,r.chainId),c=se(r,e);return oe(s,"cancelSignature",[c])}}export{et as TradeService};
2
- //# sourceMappingURL=TradeService-DNGia0OJ.js.map
1
+ var ve=Object.defineProperty;var me=(t,r,e)=>r in t?ve(t,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):t[r]=e;var p=(t,r,e)=>me(t,typeof r!="symbol"?r+"":r,e);import{W as ue,a as Q,C as xe,B as be,f as X}from"./ethers-3hUTVH_L.js";import{a as Ce,d as B}from"./dcl-schemas-CN-1-wGb.js";import{c as ee}from"./react-DcSw8tCD.js";import{cx as Ie,aH as te,g as re}from"./index-B-dIqjhn.js";import{c as q,e as Ee}from"./index-NxvojHai.js";import{s as Re}from"./sendMetaTransaction-CcfiyKVp.js";import"./sentry-CAS3BNIy.js";import"./intl-AKLEHPeO.js";import"./events-BAvGtdFA.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},r=new t.Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="ce5c393c-f593-46f8-998a-cbb2e173744a",t._sentryDebugIdIdentifier="sentry-dbid-ce5c393c-f593-46f8-998a-cbb2e173744a")}catch{}})();async function Pe(t){const r=await de();if(r){const e=await new ue(r).getSigner().getChainId();if(t===e)return r}return q.createProvider(Ce.ProviderType.NETWORK,t)}async function de(){try{return await q.getProvider()}catch{try{const{provider:t}=await q.tryPreviousConnection();return t}catch{return null}}}function ne(t){return Math.floor(t/1e3)}function ae(t){switch(t.assetType){case B.TradeAssetType.ERC721:return t.tokenId;case B.TradeAssetType.COLLECTION_ITEM:return t.itemId;case B.TradeAssetType.ERC20:return t.amount;default:return console.error("Invalid asset type:",t),""}}function Ae(t){var r;return{checks:{uses:t.checks.uses,expiration:ne(t.checks.expiration),effective:ne(t.checks.effective),salt:Q(t.checks.salt,32),contractSignatureIndex:t.checks.contractSignatureIndex,signerSignatureIndex:t.checks.signerSignatureIndex,allowedRoot:Q(t.checks.allowedRoot,32),externalChecks:(r=t.checks.externalChecks)==null?void 0:r.map(e=>({contractAddress:e.contractAddress,selector:e.selector,value:e.value?e.value:"0x",required:e.required}))},sent:t.sent.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x"})),received:t.received.map(e=>({assetType:e.assetType,contractAddress:e.contractAddress,value:ae(e),extra:e.extra?e.extra:"0x",beneficiary:e.beneficiary}))}}function se(t,r){const e=Ae(t);return{signer:t.signer,signature:t.signature,...e,checks:{...e.checks,allowedProof:[]},sent:e.sent.map(i=>({...i,beneficiary:r}))}}async function Se(t){const r=await t.request({method:"eth_chainId",params:[]});let e;return typeof r=="string"?e=parseInt(r,16):e=r,e}async function Fe(t){const r=await Pe(t);return new ue(r)}const S=new Ee.EventEmitter;var b;(function(t){t.ERROR="error",t.SUCCESS="success",t.PROMPT="prompt",t.ACCEPT="accept",t.REJECT="reject"})(b||(b={}));let _e="https://transactions-api.decentraland.org/v1";const ke=()=>_e,Le=()=>new Promise((t,r)=>{const e=()=>{S.removeAllListeners(b.REJECT),t(!0)},i=()=>{S.removeAllListeners(b.ACCEPT),r(new Error("User rejected transaction"))};S.addListener(b.ACCEPT,e),S.addListener(b.REJECT,i)});async function oe(...t){const[r,e,...i]=t;try{const s=await de();if(!s)throw new Error("Provider not connected");const c=await Se(s),l=await Fe(r.chainId),E=new xe(r.address,r.abi,l),w=await(typeof e=="function"?e(E.populateTransaction):E.populateTransaction[e](...i));if(c===r.chainId){const v=l.getSigner();if(s.isMagic||s.isThirdweb){let L=be.from(0);try{const U=await v.getGasPrice(),k=await v.estimateGas(w);L=U.mul(k)}catch{}if(!L.isZero()){const U=Le(),k=await v.getBalance();S.emit(b.PROMPT,{transactionGasPrice:X(L),userBalance:X(k),chainId:r.chainId}),await U}}const P=await v.sendTransaction(w);return S.emit(b.SUCCESS,{txHash:P.hash}),P.hash}else{const v=await Re(s,l,w.data,r,{serverURL:ke()});return S.emit(b.SUCCESS,{txHash:v}),v}}catch(s){const c={type:b.ERROR,error:s};throw S.emit(b.ERROR,c),s}}var D={exports:{}};/*! https://mths.be/punycode v1.4.1 by @mathias */var Ue=D.exports,ie;function Oe(){return ie||(ie=1,(function(t,r){(function(e){var i=r&&!r.nodeType&&r,s=t&&!t.nodeType&&t,c=typeof ee=="object"&&ee;(c.global===c||c.window===c||c.self===c)&&(e=c);var l,E=2147483647,w=36,v=1,P=26,L=38,U=700,k=72,G=128,J="-",he=/^xn--/,fe=/[^\x20-\x7E]/,pe=/[\x2E\u3002\uFF0E\uFF61]/g,ye={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},N=w-v,C=Math.floor,O=String.fromCharCode,M;function F(n){throw new RangeError(ye[n])}function $(n,a){for(var o=n.length,u=[];o--;)u[o]=a(n[o]);return u}function H(n,a){var o=n.split("@"),u="";o.length>1&&(u=o[0]+"@",n=o[1]),n=n.replace(pe,".");var d=n.split("."),y=$(d,a).join(".");return u+y}function V(n){for(var a=[],o=0,u=n.length,d,y;o<u;)d=n.charCodeAt(o++),d>=55296&&d<=56319&&o<u?(y=n.charCodeAt(o++),(y&64512)==56320?a.push(((d&1023)<<10)+(y&1023)+65536):(a.push(d),o--)):a.push(d);return a}function W(n){return $(n,function(a){var o="";return a>65535&&(a-=65536,o+=O(a>>>10&1023|55296),a=56320|a&1023),o+=O(a),o}).join("")}function we(n){return n-48<10?n-22:n-65<26?n-65:n-97<26?n-97:w}function Y(n,a){return n+22+75*(n<26)-((a!=0)<<5)}function Z(n,a,o){var u=0;for(n=o?C(n/U):n>>1,n+=C(n/a);n>N*P>>1;u+=w)n=C(n/N);return C(u+(N+1)*n/(n+L))}function K(n){var a=[],o=n.length,u,d=0,y=G,h=k,T,m,I,R,f,g,x,A,_;for(T=n.lastIndexOf(J),T<0&&(T=0),m=0;m<T;++m)n.charCodeAt(m)>=128&&F("not-basic"),a.push(n.charCodeAt(m));for(I=T>0?T+1:0;I<o;){for(R=d,f=1,g=w;I>=o&&F("invalid-input"),x=we(n.charCodeAt(I++)),(x>=w||x>C((E-d)/f))&&F("overflow"),d+=x*f,A=g<=h?v:g>=h+P?P:g-h,!(x<A);g+=w)_=w-A,f>C(E/_)&&F("overflow"),f*=_;u=a.length+1,h=Z(d-R,u,R==0),C(d/u)>E-y&&F("overflow"),y+=C(d/u),d%=u,a.splice(d++,0,y)}return W(a)}function z(n){var a,o,u,d,y,h,T,m,I,R,f,g=[],x,A,_,j;for(n=V(n),x=n.length,a=G,o=0,y=k,h=0;h<x;++h)f=n[h],f<128&&g.push(O(f));for(u=d=g.length,d&&g.push(J);u<x;){for(T=E,h=0;h<x;++h)f=n[h],f>=a&&f<T&&(T=f);for(A=u+1,T-a>C((E-o)/A)&&F("overflow"),o+=(T-a)*A,a=T,h=0;h<x;++h)if(f=n[h],f<a&&++o>E&&F("overflow"),f==a){for(m=o,I=w;R=I<=y?v:I>=y+P?P:I-y,!(m<R);I+=w)j=m-R,_=w-R,g.push(O(Y(R+j%_,0))),m=C(j/_);g.push(O(Y(m,0))),y=Z(o,A,u==d),o=0,++u}++o,++a}return g.join("")}function Te(n){return H(n,function(a){return he.test(a)?K(a.slice(4).toLowerCase()):a})}function ge(n){return H(n,function(a){return fe.test(a)?"xn--"+z(a):a})}if(l={version:"1.4.1",ucs2:{decode:V,encode:W},decode:K,encode:z,toASCII:ge,toUnicode:Te},i&&s)if(t.exports==i)s.exports=l;else for(M in l)l.hasOwnProperty(M)&&(i[M]=l[M]);else e.punycode=l})(Ue)})(D,D.exports)),D.exports}Oe();var le=(function(t){function r(){var i=this||self;return delete t.prototype.__magic__,i}if(typeof globalThis=="object")return globalThis;if(this)return r();t.defineProperty(t.prototype,"__magic__",{configurable:!0,get:r});var e=__magic__;return e})(Object),De=le.URL;le.URLSearchParams;var Me={URL:De};class ce extends Error{constructor(e,i,s){super(e);p(this,"status");p(this,"data");this.status=i,this.data=s}}const Ne=3,je=1e3,Be=[400,401,403,404,409,422],qe=(globalThis==null?void 0:globalThis.URL)??Me.URL;class Ge{constructor(r,e){p(this,"baseUrl");p(this,"retries");p(this,"retryDelay");p(this,"nonRetryableStatuses");p(this,"identity");p(this,"sleep",r=>new Promise(e=>{setTimeout(e,r)}));p(this,"getIdentity",()=>this.identity instanceof Function?this.identity():this.identity);p(this,"rawFetch",(r,e)=>{const i=new qe(r,this.baseUrl),s=(e==null?void 0:e.identity)??this.getIdentity();return Ie.signedFetchFactory()(i.toString(),{...e,identity:s})});p(this,"fetch",async(r,e)=>{for(let i=0;i<=this.retries;i++)try{let s,c;try{s=await this.rawFetch(r,e);const l=await s.text();l.length===0?c={ok:!0,data:null}:c=JSON.parse(l)}catch(l){throw new ce(l.message,void 0,null)}if(!s.ok||c.ok===!1){const l=c.message??c.error;throw new ce(l??`Request failed with status code ${s.status}`,s.status,c.data)}return c.ok===!0?c.data:c}catch(s){if(console.error(`[API] HTTP request failed: ${s.message||""}`,s),this.retries===i||s.status&&this.nonRetryableStatuses.includes(s.status))throw s;await this.sleep(this.retryDelay)}throw new Error("Unreachable code")});this.baseUrl=r,this.identity=e==null?void 0:e.identity,this.retries=(e==null?void 0:e.retries)??Ne,this.retryDelay=(e==null?void 0:e.retryDelay)??je,this.nonRetryableStatuses=(e==null?void 0:e.nonRetryableStatuses)??Be}}class Je extends Ge{constructor(e,i,s){super(i,s);p(this,"signer");p(this,"addTrade",async e=>this.fetch("/v1/trades",{method:"POST",body:JSON.stringify(e),metadata:{signer:this.signer,intent:"dcl:create-trade"},headers:{"Content-Type":"application/json"}}));p(this,"fetchTrade",async e=>this.fetch(`/v1/trades/${e}`,{method:"GET"}));this.signer=e}}class et{constructor(r,e,i){p(this,"tradesAPI");this.tradesAPI=new Je(r,e,{identity:i,retries:0})}async addTrade(r){return this.tradesAPI.addTrade(r)}async fetchTrade(r){return this.tradesAPI.fetchTrade(r)}async accept(r,e){const i=te(r.contract),s=re(i,r.chainId),c=se(r,e);return oe(s,"accept",[c])}async cancel(r,e){const i=te(r.contract),s=re(i,r.chainId),c=se(r,e);return oe(s,"cancelSignature",[c])}}export{et as TradeService};
2
+ //# sourceMappingURL=TradeService-BcpRovgR.js.map