@dcl/shop 1.3.0 → 1.3.1-31191272241.commit-33233c2
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.
- package/_assets/{Activity-ew3XpoT3.js → Activity-8i9FdngV.js} +5 -5
- package/_assets/{AnimatedBackground-D_nEuM-e.js → AnimatedBackground-B1iDviiG.js} +1 -1
- package/_assets/{Assets-cBlMqNjz.js → Assets-4IZmUsiz.js} +16 -16
- package/_assets/{Assets.styles-CLwfDCDf.js → Assets.styles-m0gk4Vwr.js} +1 -1
- package/_assets/{Authorizations-Cs0nL4Oz.js → Authorizations-BCttd8CW.js} +3 -3
- package/_assets/{Cart-BO4t_lkf.js → Cart-BgXGvv7s.js} +7 -7
- package/_assets/{CircularProgress-GqV7M35A.js → CircularProgress-DDm_y_cx.js} +4 -4
- package/_assets/{Collection-dJYcennk.js → Collection-CYz1Miau.js} +4 -4
- package/_assets/{CollectionCarousel-uJ5UjL8j.js → CollectionCarousel-DM6izEdE.js} +15 -15
- package/_assets/{Confetti-CFn9Pw72.js → Confetti-yVDYrpRF.js} +1 -1
- package/_assets/{Creator-CuGxdrmY.js → Creator-U2Odd2Xn.js} +11 -11
- package/_assets/{ErrorNotice-CJ7LbSaM.js → ErrorNotice-DXA2kUGn.js} +1 -1
- package/_assets/{ExchangeController-CwGAtelJ.js → ExchangeController-CUapamq4.js} +1 -1
- package/_assets/{Faq-CDhDmUOq.js → Faq-D3-Y7L_N.js} +1 -1
- package/_assets/{GetCredits-1I-xEtGF.js → GetCredits-BUPZ8nXe.js} +13 -13
- package/_assets/{Grow-CVnVH5HV.js → Grow-DWhKDYwn.js} +1 -1
- package/_assets/{HelpersUtil-DeEtn4Uv.js → HelpersUtil-BgHry1Zl.js} +1 -1
- package/_assets/{ItemDetail-R2KchS-D.js → ItemDetail-COQMwL0e.js} +1 -1
- package/_assets/LazyEmoteControls-Ds0pyaLH.js +2 -0
- package/_assets/{LoadMore-CRwBs35r.js → LoadMore-DJmWuNsx.js} +1 -1
- package/_assets/{ManaPricingBanner.styles-BlUs3NYz.js → ManaPricingBanner.styles-CqaMAdkf.js} +2 -2
- package/_assets/{MyAssets-Crv1OZqH.js → MyAssets-BJoMoNc-.js} +9 -9
- package/_assets/{MyFavorites-BsDoGy_0.js → MyFavorites-BproSyJE.js} +1 -1
- package/_assets/{NotFound-CTrYO3ch.js → NotFound-BUyr7vAo.js} +1 -1
- package/_assets/{NotificationsBell-DRGgz2iS.js → NotificationsBell-CNXI5jCf.js} +1 -1
- package/_assets/{OutfitDetail-PIgUTZD2.js → OutfitDetail-DFD_3PD6.js} +13 -13
- package/_assets/{OutfitPreview-B7Y1-68b.js → OutfitPreview-DzzGBlLq.js} +2 -2
- package/_assets/{OutfitStudio-Bsv8_JeA.js → OutfitStudio-CIKhRaRR.js} +11 -11
- package/_assets/{StoreSettings-BH1LqeM8.js → StoreSettings-BZvCZhkk.js} +10 -10
- package/_assets/{Success-C0JqrNNn.js → Success-BYEoVFfn.js} +4 -4
- package/_assets/{SwapController-B403gwlM.js → SwapController-RbFspCAC.js} +1 -1
- package/_assets/{Tooltip-Bb6q6TxX.js → Tooltip-Seun6IgZ.js} +1 -1
- package/_assets/{TradeService-BsjSuIVy.js → TradeService-C0kQQCMK.js} +1 -1
- package/_assets/{W3MFrameProviderSingleton-B6S06Y_H.js → W3MFrameProviderSingleton-DauKY4Ir.js} +3 -3
- package/_assets/{WebCryptoP256-CI6-qWGK.js → WebCryptoP256-C4hli3xD.js} +1 -1
- package/_assets/authorizations-DPF8ylip.js +1 -0
- package/_assets/{basic-DEn_IlUm.js → basic-CV-oM6kG.js} +1 -1
- package/_assets/{biconomy-DvPM-XBT.js → biconomy-DGVuVSLX.js} +1 -1
- package/_assets/{builder-Npez-0pQ.js → builder-BkQQQzE3.js} +1 -1
- package/_assets/{buy-CRR9-X2w.js → buy-DQop7Gap.js} +1 -1
- package/_assets/{buy-gasless-Cj1VGZpP.js → buy-gasless-CvDYoAre.js} +1 -1
- package/_assets/{categories-CMYRFP-3.js → categories-Dx4OHkSy.js} +4 -4
- package/_assets/{ccip-DFr4gxX6.js → ccip-BGiCuOiS.js} +1 -1
- package/_assets/{ccip-Bvp_nKL6.js → ccip-BcKisox8.js} +1 -1
- package/_assets/{collectionPage.styles-B4iEFMy_.js → collectionPage.styles-CqWYdmnF.js} +4 -4
- package/_assets/{controller-CgyRh-Bw.js → controller-CSLwfM9E.js} +2 -2
- package/_assets/{core-B7wRtbuZ.js → core-CPCg7oPm.js} +4 -4
- package/_assets/{createSvgIcon-Bo9WJgq_.js → createSvgIcon-CN-Kwds3.js} +3 -3
- package/_assets/{custom-CH6sSlIL.js → custom-BPA4R--i.js} +1 -1
- package/_assets/{data-capture-DreW3nks.js → data-capture-CGpBku4P.js} +1 -1
- package/_assets/{email-pIKOIyQR.js → email-BRIoa7rr.js} +1 -1
- package/_assets/{embedded-wallet-CLmF0Kdd.js → embedded-wallet-BAeEpv8n.js} +1 -1
- package/_assets/{emotion-styled.browser.esm-BqTQ5SYv.js → emotion-styled.browser.esm-GGMa6dTF.js} +1 -1
- package/_assets/{engine-D64OXa1r.js → engine-TZZ6iHT4.js} +1 -1
- package/_assets/{errors-BbwwHm_0.js → errors-CDyHuhIX.js} +1 -1
- package/_assets/{estimate-l1-fee-BU85AjOG.js → estimate-l1-fee-DBqnfEaD.js} +1 -1
- package/_assets/{execute-BozDg2yb.js → execute-B4Yh1llw.js} +2 -2
- package/_assets/{features-BDTF_ohu.js → features-BRxQunSh.js} +1 -1
- package/_assets/{fetchTokenMetadata-BT4wvs8u.js → fetchTokenMetadata-Dx8VaO9V.js} +2 -2
- package/_assets/{field.styles-C3qh-tZ2.js → field.styles-RvSTZ9zQ.js} +1 -1
- package/_assets/{get-ecosystem-wallet-info-BlqgcGd0.js → get-ecosystem-wallet-info-DCe0P2HA.js} +1 -1
- package/_assets/{getBalance-B89LWv-k.js → getBalance-yW2njh0W.js} +1 -1
- package/_assets/{getNFT-CMlAXi2W.js → getNFT-BOLZHVH5.js} +1 -1
- package/_assets/{getNFT-Cy5QJvSJ.js → getNFT-DuSRVcUI.js} +1 -1
- package/_assets/{grid.styles-B2Eu32l1.js → grid.styles-DTlMjoNy.js} +1 -1
- package/_assets/{hashTypedData-CVMcc6Hz.js → hashTypedData-BaZ-NVSh.js} +1 -1
- package/_assets/{hashTypedData-5hKkNljV.js → hashTypedData-Dn1doKj6.js} +1 -1
- package/_assets/{in-app-BiD_q7tQ.js → in-app-B3Zy_9Up.js} +1 -1
- package/_assets/{in-app-wallet-calls-BxK-hX9G.js → in-app-wallet-calls-BzgEl7Xp.js} +1 -1
- package/_assets/{index-BbAhN-VL.js → index-8G69XLE9.js} +1 -1
- package/_assets/{index-DmJfaFSK.js → index-8zod7QnL.js} +1 -1
- package/_assets/{index-D2gLfWlc.js → index-B5cMAKQz.js} +1 -1
- package/_assets/{index-GomvWLkv.js → index-B7hKU_9p.js} +1 -1
- package/_assets/{index-BvQGZppV.js → index-B8oAyIz8.js} +1 -1
- package/_assets/{index-D4mfZpjO.js → index-BBFb-GHY.js} +2 -2
- package/_assets/{index-bVwIZVq2.js → index-BEjN46BT.js} +1 -1
- package/_assets/{index-DsKwbNYL.js → index-BNetjvSn.js} +1 -1
- package/_assets/{index-DKDGLsyf.js → index-BX2bEUI-.js} +1 -1
- package/_assets/{index-CD88wagS.js → index-BYCN_-Lk.js} +1 -1
- package/_assets/{index-Baqe51s4.js → index-Baf3w05O.js} +1 -1
- package/_assets/{index-Xe0zG67j.js → index-BnBKCQ6R.js} +2 -2
- package/_assets/{index-DnZSYmpU.js → index-Bs5EVwuZ.js} +1 -1
- package/_assets/{index-CRNF_QU5.js → index-BzOkARHI.js} +1 -1
- package/_assets/{index-COl_MS2X.js → index-C1xP7rOI.js} +1 -1
- package/_assets/{index-BS9mRV4X.js → index-C3DZ04sJ.js} +1 -1
- package/_assets/{index-hnGTtZoN.js → index-C9n8rpAQ.js} +3 -3
- package/_assets/{index-Dy-uR3t4.js → index-CABfM9ed.js} +1 -1
- package/_assets/{index-DnhjRPd0.js → index-CCq36Q4n.js} +1 -1
- package/_assets/{index-BU93X1R1.js → index-CCvi817V.js} +1 -1
- package/_assets/{index-D6N8FICT.js → index-CDS3lHjJ.js} +2 -2
- package/_assets/{index-Brr2CMye.js → index-CE3AA7bo.js} +1 -1
- package/_assets/{index-CL_zZiR1.js → index-CFOh8-vc.js} +1 -1
- package/_assets/index-CHVlPVbz.js +3880 -0
- package/_assets/{index-Eas9yoRi.js → index-CKpYDU9O.js} +1 -1
- package/_assets/{index-BawFzGfz.js → index-CMeK1XVC.js} +1 -1
- package/_assets/{index-69aWe7LF.js → index-CPCeNa7L.js} +1 -1
- package/_assets/{index-DRZIPiLU.js → index-CQZJe9kU.js} +13 -13
- package/_assets/{index-tt5vpwow.js → index-CQimoWD2.js} +1 -1
- package/_assets/{index-2KdRKXEu.js → index-C_YJJre1.js} +1 -1
- package/_assets/{index-D7-5iUKs.js → index-Cdylf7p_.js} +1 -1
- package/_assets/{index-ByMxSKoO.js → index-CrL5_xYO.js} +1 -1
- package/_assets/{index-BNtwDdqR.js → index-Cx1mshgQ.js} +1 -1
- package/_assets/{index-E4Z_g959.js → index-D5bDG9XP.js} +3 -3
- package/_assets/{index-CU54HyHs.js → index-DBr4o1MH.js} +1 -1
- package/_assets/{index-BwVlQTGw.js → index-DE-MoPas.js} +1 -1
- package/_assets/{index-DnlLS_ys.js → index-DYM1B0LB.js} +1 -1
- package/_assets/{index-CgPj91Wh.js → index-Dc1SY2tl.js} +1 -1
- package/_assets/{index-BfrZo6vI.js → index-Dm0rNET3.js} +1 -1
- package/_assets/{index-CdmghwAv.js → index-DmtMKf7k.js} +1 -1
- package/_assets/{index-BLQrxn9F.js → index-DqxxfXkG.js} +1 -1
- package/_assets/{index-DRwratoB.js → index-DxZAhQ9S.js} +1 -1
- package/_assets/{index-CoC4ZTSB.js → index-EjOjm1WE.js} +3 -3
- package/_assets/{index-UWPTFHML.js → index-KMn0kKq6.js} +1 -1
- package/_assets/{index-CKJapgfm.js → index-VCROhFqu.js} +1 -1
- package/_assets/{index-Bj_Y4oBT.js → index-YOwv3ov2.js} +1 -1
- package/_assets/{index-DQT21rdJ.js → index-_IId9FPs.js} +1 -1
- package/_assets/{index-CGyHa-8V.js → index-_MeNrzH4.js} +1 -1
- package/_assets/{index-BCSwRUu3.js → index-tfg76WB4.js} +1 -1
- package/_assets/{index-C0Tjm6c2.js → index-vQeO65IH.js} +2 -2
- package/_assets/{index-C54j1-wd.js → index-wVpiAbCV.js} +1 -1
- package/_assets/{index-DxKuqcFg.js → index-zw3MxWrD.js} +1 -1
- package/_assets/{index.es-BYW_XSuo.js → index.es-BRe343gf.js} +4 -4
- package/_assets/{index.es-D0J6Rjn_.js → index.es-C50fJIvV.js} +1 -1
- package/_assets/{index.es-wL4nLZcl.js → index.es-RN4XS4d-.js} +1 -1
- package/_assets/{localBatchGatewayRequest-CBnpaR4-.js → localBatchGatewayRequest-mQE-Ofxj.js} +1 -1
- package/_assets/{networks-D41xdN6D.js → networks-YB7JUKsX.js} +1 -1
- package/_assets/{onramp-DR5Lm3nA.js → onramp-DcdCAuUZ.js} +1 -1
- package/_assets/{openzeppelin-B19X12pO.js → openzeppelin-dAP61G4J.js} +1 -1
- package/_assets/{parseNft-BHr3f8D7.js → parseNft-1wKuLSST.js} +2 -2
- package/_assets/{parseSignature-Cz1WFGnm.js → parseSignature-DToYlmjf.js} +3 -3
- package/_assets/{parseSignature-CRruTE7l.js → parseSignature-zHFOPkYU.js} +1 -1
- package/_assets/{passkeys-BAR54cJC.js → passkeys-BJEIePNG.js} +1 -1
- package/_assets/{pay-with-exchange-zDCz8UbG.js → pay-with-exchange-CyLwDARS.js} +1 -1
- package/_assets/{qr-overlay-DXWbTjg8.js → qr-overlay-D2bTeYBv.js} +1 -1
- package/_assets/{receive-B3ivhPV_.js → receive-W-LqtJ62.js} +1 -1
- package/_assets/{resolveImplementation-ASrjiSw-.js → resolveImplementation-BSqyzFFe.js} +1 -1
- package/_assets/{rpc-r3GlqTct.js → rpc-Dg74XPUL.js} +1 -1
- package/_assets/{secp256k1-ChcROQU5.js → secp256k1-B_xoHIxS.js} +1 -1
- package/_assets/{secp256k1-B5NNIaFX.js → secp256k1-CS73mfL3.js} +1 -1
- package/_assets/{secp256k1-Ch2QO1Jw.js → secp256k1-DadVk9CT.js} +1 -1
- package/_assets/{send-6dgb2b7F.js → send-Cg0sS_p7.js} +1 -1
- package/_assets/{send-batch-transaction-D_JGI6Rn.js → send-batch-transaction-DWWTS0gR.js} +1 -1
- package/_assets/{send-eip712-transaction-BAt6mbHJ.js → send-eip712-transaction-CcbYstq5.js} +2 -2
- package/_assets/{send-gasless-transaction-B6-du22J.js → send-gasless-transaction-B1NQvnVo.js} +2 -2
- package/_assets/{send-transaction-CWeSxAY3.js → send-transaction-C0UOEwny.js} +2 -2
- package/_assets/{sendMetaTransaction-Ds4_qSVu.js → sendMetaTransaction-DtXntIti.js} +1 -1
- package/_assets/{sendRawTransaction-lB8XtpQV.js → sendRawTransaction-BiRTWRI0.js} +3 -3
- package/_assets/{serializeTransaction-sBiqyBXY.js → serializeTransaction-Ba53L0KX.js} +1 -1
- package/_assets/{session-proposal-CtX3xmD3.js → session-proposal-CVkgVukc.js} +1 -1
- package/_assets/{session-request-TgRSx-rm.js → session-request-BwENbDXQ.js} +2 -2
- package/_assets/{signing-BLltMKaw.js → signing-5FpwvlDd.js} +3 -3
- package/_assets/{skeleton.styles-CHtcYOO2.js → skeleton.styles-h9G6h3Tc.js} +1 -1
- package/_assets/{socials-C-PWl5ol.js → socials-DorjGs6r.js} +1 -1
- package/_assets/{styled-ByfFVW_J.js → styled-B1tki3-6.js} +2 -2
- package/_assets/{swaps-cy6g7st6.js → swaps-CennN5F7.js} +1 -1
- package/_assets/{thirdweb-Dw1AnBJt.js → thirdweb-WI6Z07ev.js} +3 -3
- package/_assets/{to-serializable-transaction-BYNNGJgk.js → to-serializable-transaction-C9LYYgyI.js} +2 -2
- package/_assets/{transactionReceipt-D3t9P89G.js → transactionReceipt-DTe94rIE.js} +1 -1
- package/_assets/{transactions-Ci41fiMj.js → transactions-Dh3brWT9.js} +1 -1
- package/_assets/{useCreditPacks-DnkAdSB8.js → useCreditPacks-KSASUf3p.js} +1 -1
- package/_assets/{useImportable-DTHq6mob.js → useImportable-DRSc33Aj.js} +1 -1
- package/_assets/{useInfiniteGrid-C5_gVX8O.js → useInfiniteGrid-2uexVwwc.js} +1 -1
- package/_assets/useStore-DMEMsNdD.js +2 -0
- package/_assets/{useTheme-pA484HjF.js → useTheme-BeHCln35.js} +1 -1
- package/_assets/{verifyHash-Bwromxoc.js → verifyHash-A_t6GvG6.js} +1 -1
- package/_assets/{w3m-modal-yFiS_Jze.js → w3m-modal-kOpidGxt.js} +1 -1
- package/_assets/{w3m-modal-JLRA_T5o.js → w3m-modal-lKQJn3Hv.js} +1 -1
- package/_assets/{wait-for-tx-receipt-BXBtEFR-.js → wait-for-tx-receipt-s1aaFfaz.js} +1 -1
- package/_assets/{wallets-DB4fTO2e.js → wallets-3kLS0TAH.js} +5 -5
- package/_assets/{web-connector-CwHeziUM.js → web-connector-BXc53MpI.js} +3 -3
- package/_assets/{writeContract-lzu9ejzj.js → writeContract-7ZFesM-X.js} +1 -1
- package/_assets/{zoraTestnet-Bhmm9a22.js → zoraTestnet-DP_bnDZl.js} +1 -1
- package/email/credit-glyph.png +0 -0
- package/email/hero-credits.png +0 -0
- package/email/logo.png +0 -0
- package/email/social-discord.png +0 -0
- package/email/social-github.png +0 -0
- package/email/social-instagram.png +0 -0
- package/email/social-linkedin.png +0 -0
- package/email/social-tiktok.png +0 -0
- package/email/social-x.png +0 -0
- package/email/social-youtube.png +0 -0
- package/email/top-bar.png +0 -0
- package/index.html +11 -11
- package/package.json +2 -2
- package/_assets/LazyEmoteControls-C8q58ZLn.js +0 -2
- package/_assets/authorizations-CRcoV7f0.js +0 -1
- package/_assets/index-CKK-zMqi.js +0 -3880
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s as t,I as w,
|
|
1
|
+
import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s as t,I as w,O as se,P as ne,B as $,Q as oe,v as M,R as re,l as le,y as de,b as s,S as _,U as F,V as ce,W as he,X as pe,Y as me,Z as ue,$ as xe,a0 as ge,a1 as fe,a2 as be,a3 as ye,a4 as ve,a5 as je,a6 as we,a7 as $e,a8 as ke,a9 as Ce,A as z,aa as Ie,ab as Ee,ac as ze,ad as Le,ae as We,af as Oe}from"./index-CHVlPVbz.js";import{E as H}from"./ErrorNotice-DXA2kUGn.js";import{E as Se}from"./LazyEmoteControls-Ds0pyaLH.js";import{O as Ae}from"./OutfitPreview-DzzGBlLq.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./disposePreview-5vjiqVZ0.js";const{colors:n,radius:f,media:r,gradients:Fe}=ae,K=t.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.
|
|
@@ -17,13 +17,13 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
17
17
|
&:hover {
|
|
18
18
|
color: ${n.white};
|
|
19
19
|
}
|
|
20
|
-
`,
|
|
20
|
+
`,Pe=t.span`
|
|
21
21
|
color: ${n.softWhite};
|
|
22
22
|
font-weight: 600;
|
|
23
23
|
overflow: hidden;
|
|
24
24
|
white-space: nowrap;
|
|
25
25
|
text-overflow: ellipsis;
|
|
26
|
-
`,
|
|
26
|
+
`,q=t.div`
|
|
27
27
|
display: grid;
|
|
28
28
|
grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
|
|
29
29
|
gap: 40px;
|
|
@@ -63,7 +63,7 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
63
63
|
inset: 0;
|
|
64
64
|
pointer-events: none;
|
|
65
65
|
}
|
|
66
|
-
`,
|
|
66
|
+
`,Re=t.div`
|
|
67
67
|
position: absolute;
|
|
68
68
|
inset: 0;
|
|
69
69
|
pointer-events: none;
|
|
@@ -71,7 +71,7 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
71
71
|
& [class*='MuiBox'] {
|
|
72
72
|
pointer-events: auto;
|
|
73
73
|
}
|
|
74
|
-
`,
|
|
74
|
+
`,Be=t.img`
|
|
75
75
|
position: absolute;
|
|
76
76
|
inset: 0;
|
|
77
77
|
width: 100%;
|
|
@@ -82,7 +82,7 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
82
82
|
flex-direction: column;
|
|
83
83
|
gap: 15px;
|
|
84
84
|
min-height: 0;
|
|
85
|
-
`,
|
|
85
|
+
`,Ne=t.h1`
|
|
86
86
|
font-size: 28px;
|
|
87
87
|
font-weight: 600;
|
|
88
88
|
color: ${n.softWhite};
|
|
@@ -114,14 +114,14 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
114
114
|
padding: 0;
|
|
115
115
|
margin: 0;
|
|
116
116
|
}
|
|
117
|
-
`,
|
|
117
|
+
`,He=t.ul`
|
|
118
118
|
list-style: none;
|
|
119
119
|
margin: 0;
|
|
120
120
|
padding: 0;
|
|
121
121
|
display: flex;
|
|
122
122
|
flex-direction: column;
|
|
123
123
|
gap: 10px;
|
|
124
|
-
`,
|
|
124
|
+
`,Ke=t.li`
|
|
125
125
|
position: relative;
|
|
126
126
|
display: flex;
|
|
127
127
|
align-items: stretch;
|
|
@@ -177,7 +177,7 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
177
177
|
&[data-state='missing'] {
|
|
178
178
|
opacity: 0.55;
|
|
179
179
|
}
|
|
180
|
-
`,
|
|
180
|
+
`,qe=t(k)`
|
|
181
181
|
position: absolute;
|
|
182
182
|
inset: 0;
|
|
183
183
|
z-index: 1;
|
|
@@ -204,7 +204,7 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
204
204
|
width: 88px;
|
|
205
205
|
height: 88px;
|
|
206
206
|
}
|
|
207
|
-
`,
|
|
207
|
+
`,P=t.div`
|
|
208
208
|
flex: 1;
|
|
209
209
|
min-width: 0;
|
|
210
210
|
display: flex;
|
|
@@ -229,7 +229,7 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
229
229
|
color: ${n.softWhite};
|
|
230
230
|
text-decoration: underline;
|
|
231
231
|
}
|
|
232
|
-
`,
|
|
232
|
+
`,R=t.span`
|
|
233
233
|
display: flex;
|
|
234
234
|
align-items: center;
|
|
235
235
|
gap: 6px;
|
|
@@ -358,7 +358,7 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
358
358
|
gap: 5px;
|
|
359
359
|
font-size: 16px;
|
|
360
360
|
}
|
|
361
|
-
`,
|
|
361
|
+
`,B=t.div`
|
|
362
362
|
min-height: 52vh;
|
|
363
363
|
display: flex;
|
|
364
364
|
flex-direction: column;
|
|
@@ -374,4 +374,4 @@ import{L as k,d as ie,j as e,r as h}from"./react-BYHuwl8r.js";import{t as ae,s a
|
|
|
374
374
|
`,ot=t.p`
|
|
375
375
|
margin: 0;
|
|
376
376
|
color: ${n.gray4};
|
|
377
|
-
`,
|
|
377
|
+
`,N="outfit-detail-preview";function yt(){const{id:i}=ie(),o=M(y=>y.session),c=re(),b=c==="creator",{data:l,isError:C,refetch:m}=le({queryKey:["outfit",i,b],enabled:F()&&!!i,staleTime:6e4,queryFn:()=>Oe(i,b&&o?o.identity:void 0)}),d=!F()||!i||l===null&&c!=="pending";return de(d?{title:s("seo.outfit.notFoundTitle"),noindex:!0}:l?{title:l.name,image:_(l.thumbnailHash)??void 0}:{}),d?e.jsxs(B,{"data-testid":"outfit-notfound",children:[e.jsx(st,{name:"cart",size:44}),e.jsx(nt,{children:s("outfits.detail.notFoundTitle")}),e.jsx(ot,{children:s("outfits.detail.notFoundBody")}),e.jsx($,{as:k,to:"/items",variant:"purple",children:s("notFound.cta")})]}):C?e.jsxs(B,{"data-testid":"outfit-detail-error",children:[e.jsx(H,{message:s("outfits.errors.generic")}),e.jsx($,{variant:"purple",onClick:()=>void m(),children:s("outfits.detail.retry")})]}):l?e.jsx(lt,{outfit:l}):e.jsx(K,{"aria-busy":"true","data-testid":"outfit-detail-loading",children:e.jsxs(q,{children:[e.jsx(D,{children:e.jsx("span",{className:"skeleton",style:{position:"absolute",inset:0},"aria-hidden":!0})}),e.jsxs(U,{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 rt({item:i}){const o=Ie(i),c=Ee(i.gender);return e.jsxs(Ge,{children:[i.rarity?e.jsx(j,{"data-variant":"rarity",style:{background:We(i.rarity)},title:Le(i.rarity),children:ze(i.rarity)}):null,i.isSmart?e.jsxs(j,{"data-variant":"smart",children:[e.jsx(w,{name:"smart",size:13}),s("assetCard.smart")]}):null,o?e.jsx(j,{"data-variant":"icon",children:e.jsx(w,{name:o})}):null,c?e.jsx(j,{"data-variant":"icon",children:e.jsx(w,{name:c})}):null]})}function lt({outfit:i}){const o=ce(i),{split:c,availableCount:b,totalCredits:l,addOutfit:C,isAdding:m}=he(i,o),d=M(a=>{var g;return(g=a.session)==null?void 0:g.address}),y=pe(a=>a.items),W=h.useMemo(()=>new Set(y.map(me)),[y]),O=_(i.thumbnailHash),S=h.useRef(null);h.useEffect(()=>{S.current!==i.id&&(S.current=i.id,ue("Shop Outfit Viewed",{outfit_id:i.id,item_count:i.items.length}))},[i.id,i.items.length]);const I=h.useMemo(()=>i.items.map(a=>{const g=xe(a),E=o.byKey.get(g)??null;return{key:g,item:E,state:E?ge(E,{address:d,cartKeys:W}):"missing"}}),[i,o.byKey,d,W]),{data:V,isFetched:Q}=fe(d),G=!d||Q,X=!!d&&!!V,Y=i.bodyShape==="female"?be:i.bodyShape==="male"?ye:void 0,u=h.useMemo(()=>I.map(a=>a.item).filter(a=>!!a),[I]),A=h.useMemo(()=>ve(u),[u]),Z=h.useMemo(()=>!!je(u),[u]),J=h.useMemo(()=>u.map(a=>we(a)??"").filter(Boolean),[u]),p=$e({address:d,tryOnUrns:A,tryOnCategories:J}),ee=i.items.length,te=!o.isLoading&&!o.isError,x=c.purchasable.length;return e.jsxs(K,{"data-testid":"outfit-detail",children:[e.jsxs(Te,{"aria-label":s("outfits.detail.breadcrumbAria"),children:[e.jsx(T,{to:"/overview",children:s("nav.overview")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(T,{to:"/overview",children:s("outfits.detail.breadcrumbLooks")}),e.jsx("span",{"aria-hidden":!0,children:">"}),e.jsx(Pe,{children:i.name})]}),e.jsxs(q,{children:[e.jsx(D,{"data-testid":"outfit-detail-preview",style:{background:ke(i)},children:O&&!o.isLoading&&A.length===0?e.jsx(Be,{src:O,alt:i.name}):e.jsx(Ae,{id:N,profile:p.profile,bodyShape:p.bodyShape??(X?void 0:Y),urns:p.urns,skin:p.skin,hair:p.hair,eyes:p.eyes,enabled:G&&!p.isLoading&&!o.isLoading,controls:Z?e.jsx(Re,{"data-testid":"outfit-emote-controls",children:e.jsx(Se,{wearablePreviewId:N,hideFrameInput:!0})}):null})}),e.jsxs(U,{children:[e.jsx(Ne,{children:i.name}),e.jsx(Me,{"data-testid":"outfit-detail-meta",children:s("outfits.detail.itemsCount",{count:ee})}),o.isError?e.jsxs(Ye,{children:[e.jsx(H,{message:s("outfits.detail.resolveError"),testId:"outfit-detail-resolve-error"}),e.jsx($,{variant:"outline","data-testid":"outfit-detail-retry",onClick:o.retry,children:s("outfits.detail.retry")})]}):e.jsxs(e.Fragment,{children:[e.jsx(_e,{children:e.jsx(He,{children:I.map(a=>e.jsx(Ke,{"data-testid":"outfit-detail-item","data-state":a.state,children:a.item?e.jsxs(e.Fragment,{children:[e.jsx(qe,{to:`/item/${a.item.contractAddress}/${a.item.itemId}`,state:{item:a.item},"aria-label":a.item.name}),e.jsx(De,{src:a.item.thumbnail,alt:"",loading:"lazy"}),e.jsxs(P,{children:[e.jsx(L,{children:a.item.name}),a.item.creator?e.jsx(Ve,{to:`/items/creator/${a.item.creator}`,children:e.jsx(Ce,{address:a.item.creator})}):null,e.jsxs(R,{children:[a.state!=="unavailable"?e.jsxs(Qe,{children:[e.jsx(z,{size:15}),a.item.priceCredits.toLocaleString()]}):null,a.state==="unavailable"?e.jsx(v,{children:s("outfits.card.unavailable")}):a.state==="own_listing"?e.jsx(v,{children:s("outfits.detail.yourListing")}):a.state==="in_cart"?e.jsx(v,{children:s("outfits.detail.inCart")}):null,e.jsx(rt,{item:a.item})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ue,{className:o.isLoading?"skeleton":void 0,"aria-hidden":!0}),e.jsx(P,{children:o.isLoading?e.jsx(L,{children:e.jsx("span",{className:"skeleton",style:{display:"block",width:"70%",height:14}})}):e.jsxs(e.Fragment,{children:[e.jsx(L,{children:s("outfits.card.unavailable")}),e.jsx(R,{children:e.jsx(v,{children:s("outfits.card.unavailable")})})]})})]})},a.key))})}),e.jsxs(Ze,{"data-testid":"outfit-detail-ctabar",children:[te&&c.ownListing.length>0?e.jsx(Xe,{children:s("outfits.detail.yourListingHint")}):null,x>0&&e.jsxs(Je,{children:[e.jsx(et,{children:s("outfits.detail.totalPrice")}),o.isLoading?e.jsx("span",{className:"skeleton",style:{width:64,height:26},"aria-hidden":!0}):e.jsxs(tt,{children:[e.jsx(z,{size:22}),l.toLocaleString()]})]}),o.isLoading?e.jsx("span",{className:"skeleton",style:{width:"100%",height:52,borderRadius:26},"aria-hidden":!0}):e.jsxs(it,{variant:"purple","data-testid":"outfit-detail-cta",onClick:C,disabled:m||x===0,"aria-busy":m||void 0,children:[m?s("outfits.card.adding"):x>0?s("outfits.detail.addCount",{count:x}):b>0?s("outfits.detail.nothingToAdd"):s("outfits.card.unavailable"),!m&&x>0?e.jsxs(at,{children:[e.jsx(z,{size:16}),l.toLocaleString()]}):null]})]})]})]})]})]})}export{yt as OutfitDetail,yt as default};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{r,j as n}from"./react-BYHuwl8r.js";import{d as g}from"./dcl-schemas-CmtP3U6y.js";import{s as P,
|
|
1
|
+
import{r,j as n}from"./react-BYHuwl8r.js";import{d as g}from"./dcl-schemas-CmtP3U6y.js";import{s as P,X as R,ag as F,c as O,ah as S,b as B}from"./index-CHVlPVbz.js";import{d as W}from"./disposePreview-5vjiqVZ0.js";const H=P.div`
|
|
2
2
|
position: absolute;
|
|
3
3
|
inset: 0;
|
|
4
4
|
display: grid;
|
|
5
5
|
place-items: center;
|
|
6
|
-
`;function q({id:a,profile:i,bodyShape:v,urns:s,enabled:c=!0,skin:l,hair:f,eyes:d,controls:w}){const E=R(t=>t.fittingOpen),{ref:
|
|
6
|
+
`;function q({id:a,profile:i,bodyShape:v,urns:s,enabled:c=!0,skin:l,hair:f,eyes:d,controls:w}){const E=R(t=>t.fittingOpen),{ref:h,active:x}=F(),e=c&&s.length>0&&x&&!E,y=s.length>0?s[0].includes(":amoy:"):O.chainId===80002,[j,o]=r.useState(!1),A=s.join(",");r.useEffect(()=>{o(!1)},[A,i,l,f,d]),r.useEffect(()=>{e&&o(!1)},[e]);const[b,m]=r.useState(!1);r.useEffect(()=>{if(!e){m(!1);return}let t=0,I=0;const p=()=>{document.getElementById(a)?m(!0):I++<300&&(t=requestAnimationFrame(p))};return p(),()=>cancelAnimationFrame(t)},[e,a]);const u=r.useRef(null);return r.useEffect(()=>{if(e)return()=>{W(u.current),u.current=null}},[e]),n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:h,"data-preview-viewport":!0,"aria-hidden":!0}),e?n.jsx(S,{id:a,profile:i,bodyShape:v,urns:s,skin:l,hair:f,eyes:d,type:g.PreviewType.AVATAR,emote:g.PreviewEmote.FASHION,disableBackground:!0,disableFadeEffect:!0,dev:y,onLoad:()=>{var t;o(!0),u.current=((t=document.getElementById(a))==null?void 0:t.contentWindow)??null}},i):null,b?w:null,c&&s.length===0?null:!e||!j?n.jsx(H,{"aria-busy":"true","aria-label":B("spinner.loading"),children:n.jsx("span",{className:"spinner","aria-hidden":!0})}):null]})}export{q as O};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as d,j as t,L as F,d as Jt,a as
|
|
1
|
+
import{r as d,j as t,L as F,d as Jt,a as Xt,b as Yt}from"./react-BYHuwl8r.js";import{s,t as lt,I as K,aZ as Zt,b as e,A as ot,B as x,K as Ct,v as X,R as te,y as ee,D as It,l as Et,V as ie,$ as z,a_ as V,a$ as se,b0 as oe,b1 as J,a4 as re,a5 as ae,a2 as ne,a3 as de,S as Lt,a8 as le,b2 as rt,b3 as ue,b4 as ce,b5 as pe,F as N,b6 as Rt,b7 as zt,b8 as A,k as at,b9 as nt,ba as he,bb as fe,bc as xe,Z as me,bd as ge,be,af as ye}from"./index-CHVlPVbz.js";import{E as U}from"./ErrorNotice-DXA2kUGn.js";import{L as je}from"./LoadMore-DJmWuNsx.js";import{u as ve}from"./useInfiniteGrid-2uexVwwc.js";import{O as we}from"./OutfitPreview-DzzGBlLq.js";import{T as $e}from"./skeleton.styles-h9G6h3Tc.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./disposePreview-5vjiqVZ0.js";const{colors:m,radius:Y,media:ke}=lt,Se=s.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
gap: 12px;
|
|
@@ -7,7 +7,7 @@ import{r as d,j as t,L as F,d as Jt,a as Vt,b as Xt}from"./react-BYHuwl8r.js";im
|
|
|
7
7
|
align-items: center;
|
|
8
8
|
gap: 8px;
|
|
9
9
|
border: 1px solid rgba(255, 255, 255, 0.45);
|
|
10
|
-
border-radius: ${
|
|
10
|
+
border-radius: ${Y.pill};
|
|
11
11
|
padding: 0 14px;
|
|
12
12
|
height: 44px;
|
|
13
13
|
background: rgba(0, 0, 0, 0.25);
|
|
@@ -35,7 +35,7 @@ import{r as d,j as t,L as F,d as Jt,a as Vt,b as Xt}from"./react-BYHuwl8r.js";im
|
|
|
35
35
|
`,Ie=s.button`
|
|
36
36
|
min-height: 44px;
|
|
37
37
|
padding: 0 16px;
|
|
38
|
-
border-radius: ${
|
|
38
|
+
border-radius: ${Y.pill};
|
|
39
39
|
border: 1px solid rgba(255, 255, 255, 0.45);
|
|
40
40
|
background: none;
|
|
41
41
|
font: inherit;
|
|
@@ -58,7 +58,7 @@ import{r as d,j as t,L as F,d as Jt,a as Vt,b as Xt}from"./react-BYHuwl8r.js";im
|
|
|
58
58
|
}
|
|
59
59
|
`,Ee=s.span`
|
|
60
60
|
height: 190px;
|
|
61
|
-
border-radius: ${
|
|
61
|
+
border-radius: ${Y.card};
|
|
62
62
|
`,Le=s.button`
|
|
63
63
|
position: relative;
|
|
64
64
|
display: flex;
|
|
@@ -67,7 +67,7 @@ import{r as d,j as t,L as F,d as Jt,a as Vt,b as Xt}from"./react-BYHuwl8r.js";im
|
|
|
67
67
|
padding: 8px;
|
|
68
68
|
background: rgba(0, 0, 0, 0.4);
|
|
69
69
|
border: 1px solid transparent;
|
|
70
|
-
border-radius: ${
|
|
70
|
+
border-radius: ${Y.card};
|
|
71
71
|
text-align: left;
|
|
72
72
|
font: inherit;
|
|
73
73
|
color: ${m.softWhite};
|
|
@@ -201,10 +201,10 @@ import{r as d,j as t,L as F,d as Jt,a as Vt,b as Xt}from"./react-BYHuwl8r.js";im
|
|
|
201
201
|
object-fit: cover;
|
|
202
202
|
display: block;
|
|
203
203
|
}
|
|
204
|
-
`,
|
|
204
|
+
`,De=s.span`
|
|
205
205
|
${Ft};
|
|
206
206
|
display: inline-block;
|
|
207
|
-
`,
|
|
207
|
+
`,Ue=s.div`
|
|
208
208
|
flex: 1;
|
|
209
209
|
min-width: 0;
|
|
210
210
|
display: flex;
|
|
@@ -259,7 +259,7 @@ import{r as d,j as t,L as F,d as Jt,a as Vt,b as Xt}from"./react-BYHuwl8r.js";im
|
|
|
259
259
|
display: grid;
|
|
260
260
|
place-items: center;
|
|
261
261
|
padding: 16px;
|
|
262
|
-
`,
|
|
262
|
+
`,Ve=s.div`
|
|
263
263
|
position: absolute;
|
|
264
264
|
inset: 0;
|
|
265
265
|
background: rgba(22, 21, 24, 0.5);
|
|
@@ -273,10 +273,10 @@ import{r as d,j as t,L as F,d as Jt,a as Vt,b as Xt}from"./react-BYHuwl8r.js";im
|
|
|
273
273
|
display: flex;
|
|
274
274
|
flex-direction: column;
|
|
275
275
|
gap: 12px;
|
|
276
|
-
`,
|
|
276
|
+
`,Xe=s.h2`
|
|
277
277
|
font-size: 18px;
|
|
278
278
|
font-weight: 800;
|
|
279
|
-
`,
|
|
279
|
+
`,Ye=s.div`
|
|
280
280
|
display: flex;
|
|
281
281
|
flex-wrap: wrap;
|
|
282
282
|
gap: 10px;
|
|
@@ -553,4 +553,4 @@ import{r as d,j as t,L as F,d as Jt,a as Vt,b as Xt}from"./react-BYHuwl8r.js";im
|
|
|
553
553
|
display: flex;
|
|
554
554
|
flex-wrap: wrap;
|
|
555
555
|
gap: 10px;
|
|
556
|
-
`;function Ki(){const{id:n}=Jt(),{pathname:f}=Vt(),h=V(b=>b.session),c=V(b=>b.signIn),y=te();ee({title:e("outfits.studio.title"),noindex:!0});const j=f.endsWith("/new")?"new":n?"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($t,{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(Ii,{}):t.jsx(Ri,{outfitId:j==="edit"?n:null},n??"new"):t.jsxs(O,{"data-testid":"outfit-studio-signin",children:[t.jsx($t,{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:n}){const f=Lt(n.thumbnailHash);return f?t.jsx(Me,{style:{background:ce(n)},children:t.jsx("img",{src:f,alt:"",loading:"lazy"})}):t.jsx(Ue,{"aria-hidden":!0})}function Ii(){const n=V(u=>u.session),f=It(),[h,c]=d.useState(null),[y,j]=d.useState(null),{data:b=[],isLoading:o,isError:R,refetch:C}=Et({queryKey:["outfits-all"],enabled:!!n,staleTime:3e4,queryFn:()=>be(n.identity)});async function I(u,S){if(n){j(u.id);try{S==="delete"?(await pe(u.id,n.identity),N.success(e("outfits.studio.deleted"))):(await Rt({...dt(u),published:!1},n.identity,"update"),N.success(e("outfits.studio.unpublished"))),zt(f)}catch(E){E instanceof A||at(E,{flow:`outfit-${S}`}),N.error(e(E instanceof A?nt(E.code):"outfits.errors.generic"))}finally{j(null),c(null)}}}return t.jsxs(Pt,{"data-testid":"outfit-studio-list",children:[t.jsxs(Wt,{children:[t.jsx(Ot,{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(kt,{"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(D,{message:e("outfits.errors.generic")}),t.jsx(x,{variant:"white",onClick:()=>void C(),children:e("outfits.detail.retry")})]}):b.length===0?t.jsx(w,{children:e("outfits.studio.empty")}):t.jsx(kt,{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(De,{children:[t.jsx(Ke,{children:u.name||e("outfits.studio.untitled")}),t.jsxs(_e,{children:[t.jsx(At,{"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(K,{name:"trash",size:18})})]})]},u.id))}),h?t.jsxs(Qe,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Ye,{onClick:()=>c(null)}),t.jsxs(Je,{children:[t.jsx(Ve,{children:e("outfits.studio.deleteTitle")}),t.jsx("p",{className:"muted",children:e("outfits.studio.deleteBody")}),t.jsxs(Xe,{children:[h.published?t.jsx(x,{variant:"purple","data-testid":"outfit-studio-confirm-unpublish",disabled:y===h.id,onClick:()=>void I(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 I(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 Ei(){return{id:crypto.randomUUID(),name:"",thumbnailHash:"",items:[],bodyShape:"unisex",gradientFrom:rt.from,gradientTo:rt.to,published:!1}}function dt(n){return{id:n.id,name:n.name,thumbnailHash:n.thumbnailHash,items:n.items,bodyShape:n.bodyShape,gradientFrom:n.gradientFrom,gradientTo:n.gradientTo,published:n.published}}function Li(n){try{const f=sessionStorage.getItem(n);return f?JSON.parse(f):null}catch{return null}}function Ri({outfitId:n}){const f=n===null,h=`outfit-draft:${n??"new"}`,c=V(i=>i.session),y=It(),j=Xt(),[b]=d.useState(()=>Li(h)),[o,R]=d.useState(()=>b??(f?Ei():null)),[C,I]=d.useState(!!b),{data:u,isLoading:S,isError:E,refetch:Z}=Et({queryKey:["outfit",n,!0],enabled:!f&&!!c,staleTime:0,queryFn:()=>ye(n,c.identity)});d.useEffect(()=>{u&&R(i=>i??dt(u))},[u]);function k(i){R(r=>r&&{...r,...i}),I(!0)}d.useEffect(()=>{if(!(!o||!C))try{sessionStorage.setItem(h,JSON.stringify(o))}catch{}},[o,C,h]),d.useEffect(()=>{if(!C)return;const i=r=>r.preventDefault();return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[C]),d.useEffect(()=>()=>sessionStorage.removeItem(h),[h]);const g=ie(o??void 0),_=d.useMemo(()=>new Set(((o==null?void 0:o.items)??[]).map(z)),[o]),H=i=>ge((o==null?void 0:o.items)??[],i,g.byKey),l=i=>!!i.itemId&&H(i).length<=J;function v(i){!o||!l(i)||k({items:H(i)})}const[M,ut]=d.useState(null),L=d.useRef(null),tt=d.useRef(!0);d.useEffect(()=>(tt.current=!0,()=>{tt.current=!1}),[]);const[G,ct]=d.useState(!1),[Bt,q]=d.useState(null),[et,pt]=d.useState(""),[Ht,ht]=d.useState(null),[T,Mt]=d.useState();d.useEffect(()=>()=>{L.current&&URL.revokeObjectURL(L.current)},[]);function ft(){const i=xe(et);if(!i){ht(e("outfits.studio.importError"));return}ht(null),pt(""),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(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 r=URL.createObjectURL(i);L.current=r,ut(r),ct(!0);try{const p=await fe(i,c.identity);k({thumbnailHash:p})}catch(p){p instanceof A||at(p,{flow:"outfit-thumbnail"}),q(e(p instanceof A?nt(p.code):"outfits.errors.generic")),L.current&&(URL.revokeObjectURL(L.current),L.current=null),ut(null)}finally{ct(!1)}}const[U,xt]=d.useState(!1),[Dt,mt]=d.useState(null),it=!!o&&o.name.trim().length>0&&o.name.length<=60,Kt=!!o&&Y(o.gradientFrom)&&Y(o.gradientTo),gt=!!o&&o.items.some(i=>{const r=g.byKey.get(z(i));return!r||se(r)}),bt=!!o&&it&&!!o.thumbnailHash&&Kt&>&&o.items.length>=oe&&o.items.length<=J;async function st(i){if(!(!c||!o||U)){xt(!0),mt(null);try{const r=await Rt({...o,published:i},c.identity,f?"create":"update");if(!tt.current)return;sessionStorage.removeItem(h),R(dt(r)),I(!1),zt(y),i&&!o.published?(me("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||at(r,{flow:"outfit-save"}),mt(e(r instanceof A?nt(r.code):"outfits.errors.generic"))}finally{xt(!1)}}}const Q=d.useMemo(()=>((o==null?void 0:o.items)??[]).map(i=>g.byKey.get(z(i))).filter(i=>!!i),[o,g.byKey]),yt=d.useMemo(()=>re(Q),[Q]),_t=d.useMemo(()=>{const i=ae(Q);return i!=null&&i.itemId?z({contractAddress:i.contractAddress,itemId:i.itemId}):null},[Q]),Gt=(o==null?void 0:o.bodyShape)==="female"?ne:(o==null?void 0:o.bodyShape)==="male"?de:void 0;if(!c)return null;if(!o)return E?t.jsxs(O,{children:[t.jsx(D,{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 jt=M??Lt(o.thumbnailHash),qt={...o,authorAddress:(c==null?void 0:c.address)??"",createdAt:0,updatedAt:0},Qt=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(Pt,{"data-testid":"outfit-studio-editor",children:[t.jsxs(Wt,{children:[t.jsx(Ne,{to:"/outfits/manage","aria-label":e("outfits.studio.myOutfits"),"data-testid":"outfit-studio-back",children:t.jsx(K,{name:"arrow-left",size:18})}),t.jsx(Ot,{children:f?e("outfits.studio.new"):e("outfits.studio.editTitle")}),t.jsx(At,{"data-state":o.published?"published":"draft",children:o.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")})]}),t.jsxs(Ze,{children:[t.jsxs(ti,{children:[t.jsxs(ii,{"data-testid":"outfit-studio-preview",style:{background:le(o)},children:[t.jsx(we,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:Gt,urns:yt,skin:T==null?void 0:T.skin,hair:T==null?void 0:T.hair,eyes:T==null?void 0:T.eyes,enabled:!g.isLoading}),yt.length===0&&!g.isLoading?t.jsx(si,{children:e("outfits.studio.previewEmpty")}):null]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.bodyShape")}),t.jsx(oi,{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(ni,{children:["gradientFrom","gradientTo"].map(i=>t.jsxs(di,{children:[t.jsx(li,{type:"color",value:Y(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:r=>k({[i]:r.target.value.toLowerCase()})}),t.jsxs(ui,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(ci,{value:o[i],maxLength:7,spellCheck:!1,placeholder:"#000000","aria-label":e(i==="gradientFrom"?"outfits.studio.gradientTopHex":"outfits.studio.gradientBottomHex"),"data-invalid":!Y(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")}),jt?t.jsx(ai,{"data-busy":G||void 0,children:t.jsx("img",{src:jt,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 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(D,{message:Bt,testId:"outfit-studio-thumb-error"})]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.cardPreview")}),t.jsx(pi,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(ue,{outfit:qt,resolution:g})})]})]}),t.jsxs(ei,{children:[t.jsxs(P,{children:[t.jsx(W,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(fi,{children:[t.jsx(St,{id:"outfit-import",value:et,spellCheck:!1,placeholder:e("outfits.studio.importPlaceholder"),onChange:i=>pt(i.target.value),onKeyDown:i=>{i.key==="Enter"&&ft()},"data-testid":"outfit-studio-import"}),t.jsx(x,{variant:"outline",size:"sm",onClick:ft,disabled:et.trim()==="","data-testid":"outfit-studio-import-apply",children:e("outfits.studio.importApply")})]}),t.jsx(w,{children:e("outfits.studio.importHint")}),t.jsx(D,{message:Ht,testId:"outfit-studio-import-error"})]}),t.jsxs(P,{children:[t.jsx(W,{htmlFor:"outfit-name",children:e("outfits.studio.name")}),t.jsx(St,{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(xi,{children:o.items.map(i=>{const r=z(i),p=g.byKey.get(r);return t.jsxs(mi,{"data-testid":"outfit-studio-selected","data-missing":!p||void 0,children:[p?t.jsx(gi,{src:p.thumbnail,alt:""}):t.jsx(bi,{className:g.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(yi,{className:p?void 0:"muted",children:p?p.name:g.isLoading?t.jsx($e,{className:"skeleton",width:96,"aria-hidden":!0}):e("outfits.card.unavailable")}),r===_t?t.jsx(ji,{"data-testid":"outfit-studio-plays-in-preview",children:e("outfits.studio.playsInPreview")}):null,p?t.jsxs(vi,{children:[t.jsx(ot,{size:12}),p.priceCredits.toLocaleString()]}):null,t.jsx(ki,{type:"button","aria-label":e("outfits.studio.remove"),title:e("outfits.studio.remove"),onClick:()=>k({items:o.items.filter(Yt=>z(Yt)!==r)}),children:t.jsx(K,{name:"trash",size:16})})]},r)})}),o.items.length>0?t.jsxs(wi,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs($i,{children:[t.jsx(ot,{size:14}),Qt.toLocaleString()]})]}):null,o.items.length>=J?t.jsx(w,{children:e("outfits.studio.maxItems")}):null]}),t.jsx(Ae,{selectedKeys:_,onPick:v,canPick:l})]})]}),t.jsxs(Si,{"data-testid":"outfit-studio-savebar",children:[t.jsx(D,{message:Dt,testId:"outfit-studio-save-error"}),it?!bt&&!o.published?t.jsx(w,{"data-testid":"outfit-studio-publish-hint",children:!gt&&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:U||!it,onClick:()=>void st(o.published),children:U?e("outfits.studio.saving"):e("outfits.studio.saveDraft")}),o.published?t.jsx(x,{variant:"white","data-testid":"outfit-studio-unpublish",disabled:U,onClick:()=>void st(!1),children:e("outfits.studio.unpublish")}):t.jsx(x,{variant:"white","data-testid":"outfit-studio-publish",disabled:U||!bt,onClick:()=>void st(!0),children:e("outfits.studio.publish")})]})]})]})}export{Ki as OutfitStudio,Ki as default};
|
|
556
|
+
`;function Ki(){const{id:n}=Jt(),{pathname:f}=Xt(),h=X(b=>b.session),c=X(b=>b.signIn),y=te();ee({title:e("outfits.studio.title"),noindex:!0});const j=f.endsWith("/new")?"new":n?"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($t,{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(Ii,{}):t.jsx(Ri,{outfitId:j==="edit"?n:null},n??"new"):t.jsxs(O,{"data-testid":"outfit-studio-signin",children:[t.jsx($t,{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:n}){const f=Lt(n.thumbnailHash);return f?t.jsx(Me,{style:{background:ce(n)},children:t.jsx("img",{src:f,alt:"",loading:"lazy"})}):t.jsx(De,{"aria-hidden":!0})}function Ii(){const n=X(u=>u.session),f=It(),[h,c]=d.useState(null),[y,j]=d.useState(null),{data:b=[],isLoading:o,isError:R,refetch:C}=Et({queryKey:["outfits-all"],enabled:!!n,staleTime:3e4,queryFn:()=>be(n.identity)});async function I(u,S){if(n){j(u.id);try{S==="delete"?(await pe(u.id,n.identity),N.success(e("outfits.studio.deleted"))):(await Rt({...dt(u),published:!1},n.identity,"update"),N.success(e("outfits.studio.unpublished"))),zt(f)}catch(E){E instanceof A||at(E,{flow:`outfit-${S}`}),N.error(e(E instanceof A?nt(E.code):"outfits.errors.generic"))}finally{j(null),c(null)}}}return t.jsxs(Pt,{"data-testid":"outfit-studio-list",children:[t.jsxs(Wt,{children:[t.jsx(Ot,{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(kt,{"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 C(),children:e("outfits.detail.retry")})]}):b.length===0?t.jsx(w,{children:e("outfits.studio.empty")}):t.jsx(kt,{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(Ue,{children:[t.jsx(Ke,{children:u.name||e("outfits.studio.untitled")}),t.jsxs(_e,{children:[t.jsx(At,{"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(K,{name:"trash",size:18})})]})]},u.id))}),h?t.jsxs(Qe,{role:"dialog","aria-modal":"true","aria-label":e("outfits.studio.deleteTitle"),"data-testid":"outfit-studio-confirm",children:[t.jsx(Ve,{onClick:()=>c(null)}),t.jsxs(Je,{children:[t.jsx(Xe,{children:e("outfits.studio.deleteTitle")}),t.jsx("p",{className:"muted",children:e("outfits.studio.deleteBody")}),t.jsxs(Ye,{children:[h.published?t.jsx(x,{variant:"purple","data-testid":"outfit-studio-confirm-unpublish",disabled:y===h.id,onClick:()=>void I(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 I(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 Ei(){return{id:crypto.randomUUID(),name:"",thumbnailHash:"",items:[],bodyShape:"unisex",gradientFrom:rt.from,gradientTo:rt.to,published:!1}}function dt(n){return{id:n.id,name:n.name,thumbnailHash:n.thumbnailHash,items:n.items,bodyShape:n.bodyShape,gradientFrom:n.gradientFrom,gradientTo:n.gradientTo,published:n.published}}function Li(n){try{const f=sessionStorage.getItem(n);return f?JSON.parse(f):null}catch{return null}}function Ri({outfitId:n}){const f=n===null,h=`outfit-draft:${n??"new"}`,c=X(i=>i.session),y=It(),j=Yt(),[b]=d.useState(()=>Li(h)),[o,R]=d.useState(()=>b??(f?Ei():null)),[C,I]=d.useState(!!b),{data:u,isLoading:S,isError:E,refetch:Z}=Et({queryKey:["outfit",n,!0],enabled:!f&&!!c,staleTime:0,queryFn:()=>ye(n,c.identity)});d.useEffect(()=>{u&&R(i=>i??dt(u))},[u]);function k(i){R(r=>r&&{...r,...i}),I(!0)}d.useEffect(()=>{if(!(!o||!C))try{sessionStorage.setItem(h,JSON.stringify(o))}catch{}},[o,C,h]),d.useEffect(()=>{if(!C)return;const i=r=>r.preventDefault();return window.addEventListener("beforeunload",i),()=>window.removeEventListener("beforeunload",i)},[C]),d.useEffect(()=>()=>sessionStorage.removeItem(h),[h]);const g=ie(o??void 0),_=d.useMemo(()=>new Set(((o==null?void 0:o.items)??[]).map(z)),[o]),H=i=>ge((o==null?void 0:o.items)??[],i,g.byKey),l=i=>!!i.itemId&&H(i).length<=J;function v(i){!o||!l(i)||k({items:H(i)})}const[M,ut]=d.useState(null),L=d.useRef(null),tt=d.useRef(!0);d.useEffect(()=>(tt.current=!0,()=>{tt.current=!1}),[]);const[G,ct]=d.useState(!1),[Bt,q]=d.useState(null),[et,pt]=d.useState(""),[Ht,ht]=d.useState(null),[T,Mt]=d.useState();d.useEffect(()=>()=>{L.current&&URL.revokeObjectURL(L.current)},[]);function ft(){const i=xe(et);if(!i){ht(e("outfits.studio.importError"));return}ht(null),pt(""),Mt(i.colors),k({items:i.items,...i.bodyShape?{bodyShape:i.bodyShape}:{}}),N.success(e("outfits.studio.importSuccess",{count:i.items.length}))}async function Dt(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 r=URL.createObjectURL(i);L.current=r,ut(r),ct(!0);try{const p=await fe(i,c.identity);k({thumbnailHash:p})}catch(p){p instanceof A||at(p,{flow:"outfit-thumbnail"}),q(e(p instanceof A?nt(p.code):"outfits.errors.generic")),L.current&&(URL.revokeObjectURL(L.current),L.current=null),ut(null)}finally{ct(!1)}}const[D,xt]=d.useState(!1),[Ut,mt]=d.useState(null),it=!!o&&o.name.trim().length>0&&o.name.length<=60,Kt=!!o&&V(o.gradientFrom)&&V(o.gradientTo),gt=!!o&&o.items.some(i=>{const r=g.byKey.get(z(i));return!r||se(r)}),bt=!!o&&it&&!!o.thumbnailHash&&Kt&>&&o.items.length>=oe&&o.items.length<=J;async function st(i){if(!(!c||!o||D)){xt(!0),mt(null);try{const r=await Rt({...o,published:i},c.identity,f?"create":"update");if(!tt.current)return;sessionStorage.removeItem(h),R(dt(r)),I(!1),zt(y),i&&!o.published?(me("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||at(r,{flow:"outfit-save"}),mt(e(r instanceof A?nt(r.code):"outfits.errors.generic"))}finally{xt(!1)}}}const Q=d.useMemo(()=>((o==null?void 0:o.items)??[]).map(i=>g.byKey.get(z(i))).filter(i=>!!i),[o,g.byKey]),yt=d.useMemo(()=>re(Q),[Q]),_t=d.useMemo(()=>{const i=ae(Q);return i!=null&&i.itemId?z({contractAddress:i.contractAddress,itemId:i.itemId}):null},[Q]),Gt=(o==null?void 0:o.bodyShape)==="female"?ne:(o==null?void 0:o.bodyShape)==="male"?de: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 jt=M??Lt(o.thumbnailHash),qt={...o,authorAddress:(c==null?void 0:c.address)??"",createdAt:0,updatedAt:0},Qt=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(Pt,{"data-testid":"outfit-studio-editor",children:[t.jsxs(Wt,{children:[t.jsx(Ne,{to:"/outfits/manage","aria-label":e("outfits.studio.myOutfits"),"data-testid":"outfit-studio-back",children:t.jsx(K,{name:"arrow-left",size:18})}),t.jsx(Ot,{children:f?e("outfits.studio.new"):e("outfits.studio.editTitle")}),t.jsx(At,{"data-state":o.published?"published":"draft",children:o.published?e("outfits.studio.publishedState"):e("outfits.studio.draft")})]}),t.jsxs(Ze,{children:[t.jsxs(ti,{children:[t.jsxs(ii,{"data-testid":"outfit-studio-preview",style:{background:le(o)},children:[t.jsx(we,{id:"outfit-studio-preview-frame",profile:"default",bodyShape:Gt,urns:yt,skin:T==null?void 0:T.skin,hair:T==null?void 0:T.hair,eyes:T==null?void 0:T.eyes,enabled:!g.isLoading}),yt.length===0&&!g.isLoading?t.jsx(si,{children:e("outfits.studio.previewEmpty")}):null]}),t.jsxs(P,{children:[t.jsx(W,{as:"span",children:e("outfits.studio.bodyShape")}),t.jsx(oi,{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(ni,{children:["gradientFrom","gradientTo"].map(i=>t.jsxs(di,{children:[t.jsx(li,{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:r=>k({[i]:r.target.value.toLowerCase()})}),t.jsxs(ui,{children:[t.jsx("span",{children:e(i==="gradientFrom"?"outfits.studio.gradientTop":"outfits.studio.gradientBottom")}),t.jsx(ci,{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")}),jt?t.jsx(ai,{"data-busy":G||void 0,children:t.jsx("img",{src:jt,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 r;return void Dt((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(pi,{"data-testid":"outfit-studio-card-preview",onClickCapture:i=>{i.preventDefault(),i.stopPropagation()},children:t.jsx(ue,{outfit:qt,resolution:g})})]})]}),t.jsxs(ei,{children:[t.jsxs(P,{children:[t.jsx(W,{htmlFor:"outfit-import",children:e("outfits.studio.import")}),t.jsxs(fi,{children:[t.jsx(St,{id:"outfit-import",value:et,spellCheck:!1,placeholder:e("outfits.studio.importPlaceholder"),onChange:i=>pt(i.target.value),onKeyDown:i=>{i.key==="Enter"&&ft()},"data-testid":"outfit-studio-import"}),t.jsx(x,{variant:"outline",size:"sm",onClick:ft,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(St,{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(xi,{children:o.items.map(i=>{const r=z(i),p=g.byKey.get(r);return t.jsxs(mi,{"data-testid":"outfit-studio-selected","data-missing":!p||void 0,children:[p?t.jsx(gi,{src:p.thumbnail,alt:""}):t.jsx(bi,{className:g.isLoading?"skeleton":void 0,"aria-hidden":!0}),t.jsx(yi,{className:p?void 0:"muted",children:p?p.name:g.isLoading?t.jsx($e,{className:"skeleton",width:96,"aria-hidden":!0}):e("outfits.card.unavailable")}),r===_t?t.jsx(ji,{"data-testid":"outfit-studio-plays-in-preview",children:e("outfits.studio.playsInPreview")}):null,p?t.jsxs(vi,{children:[t.jsx(ot,{size:12}),p.priceCredits.toLocaleString()]}):null,t.jsx(ki,{type:"button","aria-label":e("outfits.studio.remove"),title:e("outfits.studio.remove"),onClick:()=>k({items:o.items.filter(Vt=>z(Vt)!==r)}),children:t.jsx(K,{name:"trash",size:16})})]},r)})}),o.items.length>0?t.jsxs(wi,{"data-testid":"outfit-studio-total",children:[t.jsx("span",{children:e("outfits.detail.totalPrice")}),t.jsxs($i,{children:[t.jsx(ot,{size:14}),Qt.toLocaleString()]})]}):null,o.items.length>=J?t.jsx(w,{children:e("outfits.studio.maxItems")}):null]}),t.jsx(Ae,{selectedKeys:_,onPick:v,canPick:l})]})]}),t.jsxs(Si,{"data-testid":"outfit-studio-savebar",children:[t.jsx(U,{message:Ut,testId:"outfit-studio-save-error"}),it?!bt&&!o.published?t.jsx(w,{"data-testid":"outfit-studio-publish-hint",children:!gt&&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:D||!it,onClick:()=>void st(o.published),children:D?e("outfits.studio.saving"):e("outfits.studio.saveDraft")}),o.published?t.jsx(x,{variant:"white","data-testid":"outfit-studio-unpublish",disabled:D,onClick:()=>void st(!1),children:e("outfits.studio.unpublish")}):t.jsx(x,{variant:"white","data-testid":"outfit-studio-publish",disabled:D||!bt,onClick:()=>void st(!0),children:e("outfits.studio.publish")})]})]})]})}export{Ki as OutfitStudio,Ki as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as
|
|
1
|
+
import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as r,t as j,s as a,x as ce,B as G,y as de,v as pe,D as ue,I as L,F as R}from"./index-CHVlPVbz.js";import{u as ge,d as me,t as xe,L as he,i as A,a as f,s as fe}from"./useStore-DMEMsNdD.js";import{E as D}from"./ErrorNotice-DXA2kUGn.js";import{F as w}from"./field.styles-RvSTZ9zQ.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";const ve="https://cdn.decentraland.org/@dcl/shop/1.3.1-31191272241.commit-33233c2/_assets/template-cover-1-BETekfHg.jpeg",be="https://cdn.decentraland.org/@dcl/shop/1.3.1-31191272241.commit-33233c2/_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(([n],[u])=>n.localeCompare(u)).map(([n,u])=>({name:n.split("/").pop(),url:u})),je=ce`
|
|
2
2
|
to {
|
|
3
3
|
transform: rotate(360deg);
|
|
4
4
|
}
|
|
@@ -46,7 +46,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as n,t a
|
|
|
46
46
|
`,$e=a.span`
|
|
47
47
|
font-size: 14px;
|
|
48
48
|
font-weight: 600;
|
|
49
|
-
`;function ye({label:
|
|
49
|
+
`;function ye({label:n,size:u="medium",direction:S="column",className:k}){return t.jsxs(Se,{className:k,"data-testid":"spinner-box","data-direction":S,role:"status","aria-live":"polite","aria-label":n?void 0:r("spinner.loading"),children:[t.jsx(ke,{"data-testid":"spinner-box-ring","data-size":u,"aria-hidden":!0}),n?t.jsx($e,{children:n}):null]})}const{colors:s,radius:_e,media:K}=j,Ee=a(ye)`
|
|
50
50
|
display: grid;
|
|
51
51
|
place-items: center;
|
|
52
52
|
min-height: 60vh;
|
|
@@ -54,7 +54,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as n,t a
|
|
|
54
54
|
align-self: center;
|
|
55
55
|
min-width: 200px;
|
|
56
56
|
margin-top: 8px;
|
|
57
|
-
`,
|
|
57
|
+
`,Le=a.p`
|
|
58
58
|
margin: 0;
|
|
59
59
|
color: ${s.gray4};
|
|
60
60
|
`,M=a.section`
|
|
@@ -94,7 +94,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as n,t a
|
|
|
94
94
|
justify-content: space-between;
|
|
95
95
|
gap: 16px;
|
|
96
96
|
flex-wrap: wrap;
|
|
97
|
-
`,
|
|
97
|
+
`,Ce=a.div`
|
|
98
98
|
display: flex;
|
|
99
99
|
align-items: center;
|
|
100
100
|
gap: 10px;
|
|
@@ -145,7 +145,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as n,t a
|
|
|
145
145
|
flex: 1;
|
|
146
146
|
min-width: 0;
|
|
147
147
|
}
|
|
148
|
-
`,
|
|
148
|
+
`,Pe=a.span`
|
|
149
149
|
display: flex;
|
|
150
150
|
align-items: center;
|
|
151
151
|
padding: 0 10px;
|
|
@@ -154,7 +154,7 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as n,t a
|
|
|
154
154
|
font-size: 13px;
|
|
155
155
|
white-space: nowrap;
|
|
156
156
|
border-right: 1px solid ${s.lineStrong};
|
|
157
|
-
`,
|
|
157
|
+
`,Be=a.div`
|
|
158
158
|
display: grid;
|
|
159
159
|
grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
|
|
160
160
|
gap: 12px;
|
|
@@ -223,21 +223,21 @@ import{j as t,L as oe,b as le,r as l}from"./react-BYHuwl8r.js";import{b as n,t a
|
|
|
223
223
|
&[data-variant='upload']:hover .ico {
|
|
224
224
|
background: ${s.accent};
|
|
225
225
|
}
|
|
226
|
-
`,
|
|
226
|
+
`,Fe=a.input`
|
|
227
227
|
position: absolute;
|
|
228
228
|
width: 1px;
|
|
229
229
|
height: 1px;
|
|
230
230
|
opacity: 0;
|
|
231
231
|
pointer-events: none;
|
|
232
|
-
`,
|
|
232
|
+
`,Re=a.div`
|
|
233
233
|
display: flex;
|
|
234
234
|
justify-content: flex-end;
|
|
235
235
|
gap: 12px;
|
|
236
236
|
margin-top: 8px;
|
|
237
|
-
`,
|
|
237
|
+
`,Ae=a(G)`
|
|
238
238
|
min-width: 180px;
|
|
239
239
|
|
|
240
240
|
${K.maxWidth("mobile")} {
|
|
241
241
|
width: 100%;
|
|
242
242
|
}
|
|
243
|
-
`,W=1e6,V={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function Y(
|
|
243
|
+
`,W=1e6,V={cover:"",coverName:"",coverHash:"",description:"",links:{website:"",twitter:"",discord:"",facebook:""}};function Y(n){return`${(n/1e6).toLocaleString(void 0,{maximumFractionDigits:2})}MB`}function Je(){de({title:r("seo.storeSettings.title"),noindex:!0});const{session:n,signIn:u}=pe(),S=le(),k=ue(),p=n==null?void 0:n.address,{data:$,isLoading:q}=ge(p),[o,g]=l.useState(V),[C,H]=l.useState(V),[y,x]=l.useState(),[h,I]=l.useState(!1),[c,_]=l.useState(null),[b,J]=l.useState({}),T=l.useRef(null);l.useEffect(()=>{if($){const e=me($);g(e),H(e),x(void 0),_(e.cover?{url:e.cover,name:e.coverName,hash:e.coverHash}:null)}},[$]),l.useEffect(()=>{let e=!1;return Promise.all(v.map(async i=>[i.name,await xe(i.url)])).then(i=>{e||J(Object.fromEntries(i))}).catch(()=>{}),()=>{e=!0}},[]);const E=l.useMemo(()=>{const e=v.find(d=>o.coverName===`cover/${d.name}`);if(e)return e.name;const i=o.coverHash?v.find(d=>b[d.name]===o.coverHash):void 0;return i==null?void 0:i.name},[o.coverName,o.coverHash,b]);l.useEffect(()=>{c!=null&&c.hash&&v.some(e=>b[e.name]===c.hash)&&_(null)},[b,c]);const P=y!==void 0&&y>W,Q=l.useMemo(()=>he.filter(e=>!A(e,o.links[e])),[o.links]),U=P||Q.length>0,z=l.useMemo(()=>JSON.stringify(o)!==JSON.stringify(C),[o,C]),X=z&&!U&&!h;if(l.useEffect(()=>{if(!z)return;const e=i=>{i.preventDefault()};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[z]),!n)return t.jsxs(M,{"data-signin":!0,"aria-label":r("storeSettings.title"),children:[t.jsx(O,{children:r("storeSettings.title")}),t.jsx(Le,{children:r("storeSettings.signInPrompt")}),t.jsx(ze,{variant:"white",onClick:u,children:r("storeSettings.signIn")})]});function Z(e,i){x(void 0),g(d=>({...d,cover:i,coverName:`cover/${e}`,coverHash:""}))}const ee=["image/png","image/jpeg","image/webp"];function te(e){var B;const i=(B=e.target.files)==null?void 0:B[0];if(!i||!ee.includes(i.type))return;x(i.size);const d=`cover/${i.name}`,m=new FileReader;m.onload=()=>{const F=m.result;_({url:F,name:d,hash:""}),g(ne=>({...ne,cover:F,coverName:d,coverHash:""}))},m.readAsDataURL(i)}function ie(){c&&(x(void 0),g(e=>({...e,cover:c.url,coverName:c.name,coverHash:c.hash})))}function se(e,i){const d=i?(f[e]+i).replace(/\s/g,""):"";g(m=>({...m,links:{...m.links,[e]:d}}))}function re(e){const i=o.links[e];return e==="website"?i:i.replace(f[e],"")}async function ae(){if(!(!p||!n)){I(!0);try{await fe(p,o,n.identity),H(o),x(void 0),await k.invalidateQueries({queryKey:["store",p.toLowerCase()]}),R.success(r("storeSettings.saved")),S(`/items/creator/${p}`)}catch{R.error(r("storeSettings.saveError"))}finally{I(!1)}}}return t.jsxs(M,{"aria-label":r("storeSettings.title"),children:[t.jsxs(Ne,{children:[t.jsxs(Ce,{children:[p?t.jsx(He,{to:`/items/creator/${p}`,title:r("storeSettings.back"),"aria-label":r("storeSettings.back"),children:t.jsx(L,{name:"arrow-left"})}):null,t.jsx(O,{children:r("storeSettings.title")})]}),p?t.jsxs(Ie,{href:`/items/creator/${p}`,target:"_blank",rel:"noopener noreferrer",children:[r("storeSettings.seeAsGuest"),t.jsx(L,{name:"external-link"})]}):null]}),q?t.jsx(Ee,{size:"large",label:r("storeSettings.loading")}):t.jsxs(t.Fragment,{children:[t.jsxs(w,{children:[t.jsx("span",{className:"field__label",children:r("storeSettings.cover")}),t.jsxs(Be,{role:"group","aria-label":r("storeSettings.cover"),children:[v.map(e=>{const i=E===e.name;return t.jsx(N,{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(N,{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(N,{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(L,{name:"upload"}),t.jsx("span",{children:r("storeSettings.upload")})]}),t.jsx(Fe,{ref:T,type:"file",accept:"image/png, image/jpeg, image/webp","data-testid":"cover-picker-input",onChange:te})]}),P?t.jsx(D,{message:r("storeSettings.sizeError",{max:Y(W),current:Y(y)})}):null]}),t.jsxs(w,{as:"label",children:[t.jsx("span",{className:"field__label",children:r("storeSettings.description")}),t.jsx("textarea",{value:o.description,rows:4,disabled:h,onChange:e=>g(i=>({...i,description:e.target.value}))})]}),t.jsxs(w,{as:"label",children:[t.jsx("span",{className:"field__label",children:r("storeSettings.website")}),t.jsx("input",{type:"url",value:o.links.website,placeholder:f.website,disabled:h,onChange:e=>g(i=>({...i,links:{...i.links,website:e.target.value.replace(/\s/g,"")}}))}),A("website",o.links.website)?null:t.jsx(D,{message:r("storeSettings.linkError",{value:f.website})})]}),["twitter","discord","facebook"].map(e=>t.jsxs(w,{as:"label",children:[t.jsx("span",{className:"field__label",children:r(`storeSettings.${e}`)}),t.jsxs(Te,{children:[t.jsx(Pe,{children:f[e]}),t.jsx("input",{type:"text",value:re(e),disabled:h,onChange:i=>se(e,i.target.value)})]})]},e)),t.jsx(Re,{children:t.jsx(Ae,{variant:"white","data-testid":"store-settings-save",onClick:()=>void ae(),disabled:!X,children:h?r("storeSettings.saving"):r("storeSettings.save")})})]})]})}export{Je as StoreSettings,Je as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as P,b as M,j as e,N as W,r as
|
|
1
|
+
import{a as P,b as M,j as e,N as W,r as I}from"./react-BYHuwl8r.js";import{t as J,s as t,A as N,J as O,K as _,v as q,y as H,b as n,z as U,C as X,L as D,M as G,c as E,B as K,N as Q}from"./index-CHVlPVbz.js";import{C as Y}from"./Confetti-yVDYrpRF.js";import{J as V}from"./JumpInIcon-CfzbSVBF.js";import{w as Z,S as ee}from"./buy-gasless-CvDYoAre.js";import"./dcl-schemas-CmtP3U6y.js";import"./sentry-Dx-KuLV3.js";import"./ethers-BDpbhgX6.js";import"./intl-CBcMB1D2.js";import"./authorizations-DPF8ylip.js";import"./sendMetaTransaction-DtXntIti.js";import"./buy-DQop7Gap.js";const{colors:i,radius:b}=J,c="@media (max-width: 600px)",S=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;
|
|
@@ -264,7 +264,7 @@ import{a as P,b as M,j as e,N as W,r as A}from"./react-BYHuwl8r.js";import{t as
|
|
|
264
264
|
font-weight: 600;
|
|
265
265
|
font-size: 13px;
|
|
266
266
|
color: ${i.muted};
|
|
267
|
-
`,ye=t(
|
|
267
|
+
`,ye=t(O)`
|
|
268
268
|
position: relative;
|
|
269
269
|
z-index: 1;
|
|
270
270
|
color: ${i.muted};
|
|
@@ -296,7 +296,7 @@ import{a as P,b as M,j as e,N as W,r as A}from"./react-BYHuwl8r.js";import{t as
|
|
|
296
296
|
align-items: center;
|
|
297
297
|
justify-content: flex-end;
|
|
298
298
|
margin-top: 4px;
|
|
299
|
-
`,F=
|
|
299
|
+
`,F=_`
|
|
300
300
|
flex: 1;
|
|
301
301
|
min-width: 0;
|
|
302
302
|
height: 48px;
|
|
@@ -350,4 +350,4 @@ import{a as P,b as M,j as e,N as W,r as A}from"./react-BYHuwl8r.js";import{t as
|
|
|
350
350
|
`,z=t(K)`
|
|
351
351
|
min-width: 160px;
|
|
352
352
|
text-align: center;
|
|
353
|
-
`;function
|
|
353
|
+
`;function Ae(p){return null}const Ie=p=>new Promise(d=>setTimeout(d,p)),L=()=>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(p,d){const[s,a]=I.useState(p?"pending":"confirmed"),x=d?`${d.owner}-${d.contractAddress}-${d.itemId}`:"";return I.useEffect(()=>{if(!p)return;let l=!1;return(async()=>{let f=!1;for(let r=0;r<20&&!l;r++)try{await Z(p,{timeoutMs:15e3}),f=!0;break}catch(y){if(y instanceof ee)continue;l||a("failed");return}if(!l){if(!f){a("timed-out");return}if(!d){a("confirmed");return}a("indexing");for(let r=0;r<40&&!l;r++){if(await Q(d.owner,d.contractAddress,d.itemId)){l||a("confirmed");return}await Ie(3e3)}l||a("timed-out")}})(),()=>{l=!0}},[p,x]),s}const Te=E.chainId===80002?"https://decentraland.zone/jump":"https://decentraland.org/jump",Be=E.chainId===80002?"https://amoy.polygonscan.com/tx/":"https://polygonscan.com/tx/";function Xe(){var A;const{state:p,search:d}=P(),s=p??Ae(),a=M(),{session:x}=q(),l=s==null?void 0:s.txHash,w=(s==null?void 0:s.items)??[],f=s!=null&&s.creditsAdded&&s.creditsAdded>0?s.creditsAdded:null,r=w[0],y=x!=null&&x.address&&(r!=null&&r.contractAddress)&&(r!=null&&r.itemId)?{owner:x.address,contractAddress:r.contractAddress,itemId:r.itemId}:null,g=Se(s!=null&&s.settled?void 0:l,y);H({title:n("seo.success.title"),noindex:!0});const h=w;if(h.length===0)return e.jsx(W,{to:"/items",replace:!0});const R=h[0],m=(A=s==null?void 0:s.txHashes)!=null&&A.length?s.txHashes:l?[l]:[],u=m.length>0&&U(x==null?void 0:x.providerType)?m.map((o,v)=>e.jsx(ie,{href:`${Be}${o}`,target:"_blank",rel:"noreferrer",children:m.length>1?n("success.viewTransactionNumbered",{n:v+1,total:m.length}):n("success.viewTransaction")},o)):null;return g!=="confirmed"?e.jsx(S,{children:e.jsx(te,{children:g==="pending"||g==="indexing"?e.jsxs(e.Fragment,{children:[e.jsx(ne,{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:R.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:R.name}):n("success.itemCount",{count:h.length})," ",n("success.confirmingAfter")]})}),u?e.jsx(j,{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(j,{children:u}):null,e.jsxs(T,{children:[e.jsx(z,{variant:"purple",onClick:()=>a("/activity"),children:n("success.viewActivity")}),e.jsx(z,{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(j,{children:u}):null,e.jsx(T,{children:e.jsx(z,{variant:"purple",onClick:()=>a("/items"),children:n("success.backToShop")})})]})})}):e.jsxs(S,{children:[e.jsx(Y,{}),e.jsxs(se,{children:[e.jsxs(re,{role:"status",children:[e.jsx(oe,{"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(ae,{children:[e.jsx("b",{children:n("success.bannerTitle")})," ",n("success.bannerBody")]})]}),e.jsxs(ce,{children:[f?e.jsxs(pe,{"data-testid":"success-credits",children:[e.jsx(B,{"aria-hidden":!0,children:e.jsx(L,{})}),e.jsx(xe,{}),e.jsxs(he,{children:[e.jsx(ue,{children:n("getCredits.creditsAmount",{credits:f,currency:X.name})})," ",e.jsx(ge,{children:n("getCredits.creditsAdded")})]})]}):null,h.map((o,v)=>{const k=o.quantity??1;return e.jsxs(de,{children:[v>0?e.jsx(le,{"aria-hidden":!0}):null,e.jsxs(fe,{children:[e.jsxs(me,{"data-thumb":!0,children:[o.thumbnail?e.jsx("img",{src:o.thumbnail,alt:""}):null,e.jsx(B,{"aria-hidden":!0,children:e.jsx(L,{})})]}),e.jsxs(je,{"data-info":!0,children:[e.jsxs(be,{title:o.name,children:[o.name||n("buyModal.itemFallback"),k>1?e.jsx(we,{children:n("cartCheckout.qty",{count:k})}):null]}),o.creator?e.jsx(ye,{address:o.creator,linkToProfile:!0}):null]}),e.jsxs(ve,{"data-price":!0,children:[e.jsx(ke,{}),e.jsx("span",{children:D(o.priceCredits*k)})]})]})]},o.id)})]}),u?e.jsx(j,{"data-receipt":!0,children:u}):null,e.jsxs($e,{children:[e.jsx(Ce,{"data-variant":"ghost",onClick:()=>a(G(h.map(o=>o.category))),children:n("success.myAssets")}),e.jsxs(ze,{"data-variant":"ruby",href:Te,target:"_blank",rel:"noreferrer",children:[n("success.tryInWorld"),e.jsx(Re,{"aria-hidden":!0,children:e.jsx(V,{})})]})]})]})]})}export{Xe as Success,Xe as default};
|
|
@@ -1 +1 @@
|
|
|
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 L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-B6S06Y_H.js";import{au as C}from"./NetworkUtil-DXqql1Wz.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.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,m={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:_.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=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.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)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.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===C.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=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.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=g.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=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.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:g.state.activeCaipNetwork,address:(s=g.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=g.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=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.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 C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.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=g.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=W.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 h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}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:C.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=g.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(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,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:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.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=g.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(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
|
|
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 L,C as g,B as N,b as W,m as E,A as O,n as z,d as _,g as R,o as H,e as V,i as q,p as $}from"./W3MFrameProviderSingleton-DauKY4Ir.js";import{au as C}from"./NetworkUtil-DXqql1Wz.js";const b={getGasPriceInEther(n,o){const t=o*n;return Number(t)/1e18},getGasPriceInUSD(n,o,t){const s=b.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,m={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:_.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=$({...m}),D={state:e,subscribe(n){return q(e,()=>n(e))},subscribeKey(n,o){return V(e,n,o)},getParams(){var i,u,p,w,h,y,A,S,P;const n=g.state.activeChain,o=((i=g.getAccountData(n))==null?void 0:i.caipAddress)??g.state.activeCaipAddress,t=W.getPlainAddress(o),s=R(),c=H.getConnectorId(g.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)||!((h=e.sourceToken)!=null&&h.decimals)||!T.bigNumber(e.sourceTokenAmount).gt(0),l=!e.sourceTokenAmount;return{networkAddress:s,fromAddress:t,fromCaipAddress:o,sourceTokenAddress:(y=e.sourceToken)==null?void 0:y.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===C.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=m.myTokensWithBalance,e.tokensPriceMap=m.tokensPriceMap,e.initialized=m.initialized,e.initializing=m.initializing,e.switchingTokens=m.switchingTokens,e.sourceToken=m.sourceToken,e.sourceTokenAmount=m.sourceTokenAmount,e.sourceTokenPriceInUSD=m.sourceTokenPriceInUSD,e.toToken=m.toToken,e.toTokenAmount=m.toTokenAmount,e.toTokenPriceInUSD=m.toTokenPriceInUSD,e.networkPrice=m.networkPrice,e.networkTokenSymbol=m.networkTokenSymbol,e.networkBalanceInUSD=m.networkBalanceInUSD,e.inputError=m.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=g.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=_.SUGGESTED_TOKENS_BY_CHAIN)==null?void 0:t[n])||[]).map(i=>s.find(u=>u.symbol===i)).filter(i=>!!i),l=(_.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:g.state.activeCaipNetwork,address:(s=g.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=g.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=g.state)==null?void 0:o.activeCaipNetwork)==null?void 0:t.chainNamespace){case C.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 C.CHAIN.EVM:default:const s=n.standard??"0",c=BigInt(s),r=BigInt(x),d=b.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=g.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=W.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 h=W.getPlainAddress(u.tx.to);if(!h)throw new Error("SwapController:createSwapTransaction - address is required");const y={data:u.tx.data,to:h,gas:p,gasPrice:w,value:BigInt(i?r??"0":"0"),toAmount:e.toTokenAmount};return e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,p,w),e.approvalTransaction=void 0,e.swapTransaction=y,y}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:C.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=g.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(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}})}},async sendTransactionForSwap(n){var d,l,i,u,p,w,h,y,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:C.CHAIN.EVM});return e.loadingTransaction=!1,f.showSuccess(r),M.sendEvent({type:"track",event:"SWAP_SUCCESS",properties:{network:((h=g.state.activeCaipNetwork)==null?void 0:h.caipNetworkId)||"",swapFromToken:((y=a.state.sourceToken)==null?void 0:y.symbol)||"",swapToToken:((A=a.state.toToken)==null?void 0:A.symbol)||"",swapFromAmount:a.state.sourceTokenAmount||"",swapToAmount:a.state.toTokenAmount||"",isSmartAccount:F(C.CHAIN.EVM)===L.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=g.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(C.CHAIN.EVM)===L.ACCOUNT_TYPES.SMART_ACCOUNT}});return}},hasInsufficientToken(n,o){return b.isInsufficientSourceTokenForSwap(n,o,e.myTokensWithBalance)},setTransactionDetails(){const{toTokenAddress:n,toTokenDecimals:o}=a.getParams();!n||!o||(e.gasPriceInUSD=b.getGasPriceInUSD(e.networkPrice,BigInt(e.gasFee),BigInt(x)),e.priceImpact=b.getPriceImpact({sourceTokenAmount:e.sourceTokenAmount,sourceTokenPriceInUSD:e.sourceTokenPriceInUSD,toTokenPriceInUSD:e.toTokenPriceInUSD,toTokenAmount:e.toTokenAmount}),e.maxSlippage=b.getMaxSlippage(e.slippage,e.toTokenAmount),e.providerFee=b.getProviderFee(e.sourceTokenAmount))}},a=G(D);export{a as S};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as o,j as C,e as T}from"./react-BYHuwl8r.js";import{s as P,t as i}from"./index-
|
|
1
|
+
import{r as o,j as C,e as T}from"./react-BYHuwl8r.js";import{s as P,t as i}from"./index-CHVlPVbz.js";const B=(...t)=>({shouldForwardProp:p=>!t.includes(p)}),A=P("span",B("block"))`
|
|
2
2
|
display: ${({block:t})=>t?"flex":"inline-flex"};
|
|
3
3
|
${({block:t})=>t?"width: 100%;":""}
|
|
4
4
|
`,I=P("span",B("placement"))`
|