@medialane/ui 0.169.0 → 0.171.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/components/badge.d.cts +1 -1
  2. package/dist/components/badge.d.ts +1 -1
  3. package/dist/components/button.d.cts +2 -2
  4. package/dist/components/button.d.ts +2 -2
  5. package/dist/components/fast-mint/fast-mint.d.cts +2 -2
  6. package/dist/components/fast-mint/fast-mint.d.ts +2 -2
  7. package/dist/components/sheet.d.cts +1 -1
  8. package/dist/components/sheet.d.ts +1 -1
  9. package/dist/components/wallet/export-key-section.cjs +9 -14
  10. package/dist/components/wallet/export-key-section.cjs.map +1 -1
  11. package/dist/components/wallet/export-key-section.d.cts +1 -2
  12. package/dist/components/wallet/export-key-section.d.ts +1 -2
  13. package/dist/components/wallet/export-key-section.js +9 -14
  14. package/dist/components/wallet/export-key-section.js.map +1 -1
  15. package/dist/index.cjs +68 -0
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.cts +8 -0
  18. package/dist/index.d.ts +8 -0
  19. package/dist/index.js +63 -0
  20. package/dist/index.js.map +1 -1
  21. package/dist/utils/sitemap-data.cjs +55 -0
  22. package/dist/utils/sitemap-data.cjs.map +1 -0
  23. package/dist/utils/sitemap-data.d.cts +23 -0
  24. package/dist/utils/sitemap-data.d.ts +23 -0
  25. package/dist/utils/sitemap-data.js +31 -0
  26. package/dist/utils/sitemap-data.js.map +1 -0
  27. package/dist/utils/use-coin-price.cjs +88 -0
  28. package/dist/utils/use-coin-price.cjs.map +1 -0
  29. package/dist/utils/use-coin-price.d.cts +17 -0
  30. package/dist/utils/use-coin-price.d.ts +17 -0
  31. package/dist/utils/use-coin-price.js +53 -0
  32. package/dist/utils/use-coin-price.js.map +1 -0
  33. package/dist/utils/use-collections.cjs +2 -2
  34. package/dist/utils/use-collections.cjs.map +1 -1
  35. package/dist/utils/use-collections.js +2 -2
  36. package/dist/utils/use-collections.js.map +1 -1
  37. package/dist/utils/use-drops.cjs +94 -0
  38. package/dist/utils/use-drops.cjs.map +1 -0
  39. package/dist/utils/use-drops.d.cts +39 -0
  40. package/dist/utils/use-drops.d.ts +39 -0
  41. package/dist/utils/use-drops.js +56 -0
  42. package/dist/utils/use-drops.js.map +1 -0
  43. package/dist/utils/use-platform-stats.cjs +50 -0
  44. package/dist/utils/use-platform-stats.cjs.map +1 -0
  45. package/dist/utils/use-platform-stats.d.cts +9 -0
  46. package/dist/utils/use-platform-stats.d.ts +9 -0
  47. package/dist/utils/use-platform-stats.js +16 -0
  48. package/dist/utils/use-platform-stats.js.map +1 -0
  49. package/dist/utils/use-pop.cjs +72 -0
  50. package/dist/utils/use-pop.cjs.map +1 -0
  51. package/dist/utils/use-pop.d.cts +28 -0
  52. package/dist/utils/use-pop.d.ts +28 -0
  53. package/dist/utils/use-pop.js +36 -0
  54. package/dist/utils/use-pop.js.map +1 -0
  55. package/dist/utils/use-sponsorship.cjs +131 -0
  56. package/dist/utils/use-sponsorship.cjs.map +1 -0
  57. package/dist/utils/use-sponsorship.d.cts +70 -0
  58. package/dist/utils/use-sponsorship.d.ts +70 -0
  59. package/dist/utils/use-sponsorship.js +90 -0
  60. package/dist/utils/use-sponsorship.js.map +1 -0
  61. package/dist/utils/use-tiers.cjs +137 -0
  62. package/dist/utils/use-tiers.cjs.map +1 -0
  63. package/dist/utils/use-tiers.d.cts +60 -0
  64. package/dist/utils/use-tiers.d.ts +60 -0
  65. package/dist/utils/use-tiers.js +95 -0
  66. package/dist/utils/use-tiers.js.map +1 -0
  67. package/dist/utils/use-tokens-by-ip-type.cjs +50 -0
  68. package/dist/utils/use-tokens-by-ip-type.cjs.map +1 -0
  69. package/dist/utils/use-tokens-by-ip-type.d.cts +14 -0
  70. package/dist/utils/use-tokens-by-ip-type.d.ts +14 -0
  71. package/dist/utils/use-tokens-by-ip-type.js +16 -0
  72. package/dist/utils/use-tokens-by-ip-type.js.map +1 -0
  73. package/package.json +3 -3
@@ -0,0 +1,31 @@
1
+ const DEFAULT_LIMITS = { collections: 500, tokens: 2e3, creators: 500 };
2
+ async function pages(max, pageSize, read) {
3
+ const rows = [];
4
+ for (let page = 1; rows.length < max; page++) {
5
+ let batch;
6
+ try {
7
+ batch = await read(page);
8
+ } catch {
9
+ break;
10
+ }
11
+ rows.push(...batch);
12
+ if (batch.length < pageSize) break;
13
+ }
14
+ return rows.slice(0, max);
15
+ }
16
+ async function collectSitemapData(api, limits = DEFAULT_LIMITS) {
17
+ const [collections, tokens, creators] = await Promise.all([
18
+ pages(limits.collections, 100, async (page) => (await api.listCollections({ page, limit: 100 })).data ?? []),
19
+ pages(limits.tokens, 48, async (page) => (await api.getTokens({ page, limit: 48 })).data ?? []),
20
+ pages(limits.creators, 50, async (page) => (await api.getCreators({ page, limit: 50 })).creators ?? [])
21
+ ]);
22
+ return {
23
+ collections,
24
+ tokens,
25
+ creatorUsernames: creators.map((c) => c.username).filter((u) => Boolean(u))
26
+ };
27
+ }
28
+ export {
29
+ collectSitemapData
30
+ };
31
+ //# sourceMappingURL=sitemap-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/sitemap-data.ts"],"sourcesContent":["import type { ApiClient } from \"@medialane/sdk\";\n\nexport interface SitemapData {\n collections: { contractAddress: string; updatedAt?: string }[];\n tokens: { contractAddress: string; tokenId: string; updatedAt?: string }[];\n creatorUsernames: string[];\n}\n\nexport interface SitemapLimits {\n collections: number;\n tokens: number;\n creators: number;\n}\n\nconst DEFAULT_LIMITS: SitemapLimits = { collections: 500, tokens: 2000, creators: 500 };\n\n/** Reads pages until a short page or `max` rows; a failed page ends the list with what was read so far. */\nasync function pages<T>(max: number, pageSize: number, read: (page: number) => Promise<T[]>): Promise<T[]> {\n const rows: T[] = [];\n for (let page = 1; rows.length < max; page++) {\n let batch: T[];\n try {\n batch = await read(page);\n } catch {\n break;\n }\n rows.push(...batch);\n if (batch.length < pageSize) break;\n }\n return rows.slice(0, max);\n}\n\n/** Everything a sitemap lists, paged through the backend's list caps. */\nexport async function collectSitemapData(api: ApiClient, limits: SitemapLimits = DEFAULT_LIMITS): Promise<SitemapData> {\n const [collections, tokens, creators] = await Promise.all([\n pages(limits.collections, 100, async (page) => (await api.listCollections({ page, limit: 100 })).data ?? []),\n pages(limits.tokens, 48, async (page) => (await api.getTokens({ page, limit: 48 })).data ?? []),\n pages(limits.creators, 50, async (page) => (await api.getCreators({ page, limit: 50 })).creators ?? []),\n ]);\n return {\n collections,\n tokens,\n creatorUsernames: creators.map((c) => c.username).filter((u): u is string => Boolean(u)),\n };\n}\n"],"mappings":"AAcA,MAAM,iBAAgC,EAAE,aAAa,KAAK,QAAQ,KAAM,UAAU,IAAI;AAGtF,eAAe,MAAS,KAAa,UAAkB,MAAoD;AACzG,QAAM,OAAY,CAAC;AACnB,WAAS,OAAO,GAAG,KAAK,SAAS,KAAK,QAAQ;AAC5C,QAAI;AACJ,QAAI;AACF,cAAQ,MAAM,KAAK,IAAI;AAAA,IACzB,QAAQ;AACN;AAAA,IACF;AACA,SAAK,KAAK,GAAG,KAAK;AAClB,QAAI,MAAM,SAAS,SAAU;AAAA,EAC/B;AACA,SAAO,KAAK,MAAM,GAAG,GAAG;AAC1B;AAGA,eAAsB,mBAAmB,KAAgB,SAAwB,gBAAsC;AACrH,QAAM,CAAC,aAAa,QAAQ,QAAQ,IAAI,MAAM,QAAQ,IAAI;AAAA,IACxD,MAAM,OAAO,aAAa,KAAK,OAAO,UAAU,MAAM,IAAI,gBAAgB,EAAE,MAAM,OAAO,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;AAAA,IAC3G,MAAM,OAAO,QAAQ,IAAI,OAAO,UAAU,MAAM,IAAI,UAAU,EAAE,MAAM,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC,CAAC;AAAA,IAC9F,MAAM,OAAO,UAAU,IAAI,OAAO,UAAU,MAAM,IAAI,YAAY,EAAE,MAAM,OAAO,GAAG,CAAC,GAAG,YAAY,CAAC,CAAC;AAAA,EACxG,CAAC;AACD,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,kBAAkB,SAAS,IAAI,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAmB,QAAQ,CAAC,CAAC;AAAA,EACzF;AACF;","names":[]}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ "use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var use_coin_price_exports = {};
31
+ __export(use_coin_price_exports, {
32
+ useCoinPrice: () => useCoinPrice,
33
+ usePriceMap: () => usePriceMap
34
+ });
35
+ module.exports = __toCommonJS(use_coin_price_exports);
36
+ var import_swr = __toESM(require("swr"), 1);
37
+ var import_sdk = require("@medialane/sdk");
38
+ var import_use_medialane_client = require("./use-medialane-client.js");
39
+ var import_sdk2 = require("@medialane/sdk");
40
+ const REFRESH_MS = 6e4;
41
+ function useAllCoinPrices(getClient) {
42
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
43
+ const { data, isLoading } = (0, import_swr.default)(
44
+ "coin-prices",
45
+ async () => (await client.api.getCoinPrices()).data,
46
+ { revalidateOnFocus: false, refreshInterval: REFRESH_MS, shouldRetryOnError: false }
47
+ );
48
+ return { prices: data ?? null, isLoading };
49
+ }
50
+ function usePriceMap(getClient) {
51
+ const { prices, isLoading } = useAllCoinPrices(getClient);
52
+ const map = {};
53
+ if (prices) {
54
+ for (const [address, entry] of Object.entries(prices)) {
55
+ map[address] = entry?.usdc ?? null;
56
+ }
57
+ }
58
+ return { prices: map, isLoading };
59
+ }
60
+ function useCoinPrice(getClient, coin) {
61
+ const { prices, isLoading } = useAllCoinPrices(getClient);
62
+ if (isLoading || !prices) return { price: null, status: "unavailable", isLoading };
63
+ const usdc = prices[(0, import_sdk2.normalizeAddress)("STARKNET", coin.contractAddress)]?.usdc ?? null;
64
+ if (usdc == null) {
65
+ return {
66
+ price: null,
67
+ status: coin.isLaunched === false ? "pre-launch" : "unavailable",
68
+ isLoading: false
69
+ };
70
+ }
71
+ const strk = (0, import_sdk.getTokenBySymbol)("STRK");
72
+ const strkUsdc = strk ? prices[(0, import_sdk2.normalizeAddress)("STARKNET", strk.address)]?.usdc ?? null : null;
73
+ return {
74
+ price: {
75
+ quotePerCoin: strkUsdc ? usdc / strkUsdc : usdc,
76
+ quoteSymbol: strkUsdc ? "STRK" : "USDC",
77
+ quoteUsdRate: strkUsdc ?? 1
78
+ },
79
+ status: "live",
80
+ isLoading: false
81
+ };
82
+ }
83
+ // Annotate the CommonJS export names for ESM import in node:
84
+ 0 && (module.exports = {
85
+ useCoinPrice,
86
+ usePriceMap
87
+ });
88
+ //# sourceMappingURL=use-coin-price.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/use-coin-price.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { getTokenBySymbol, type ApiCoinPrices } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { CoinMarketStatus } from \"../components/coin-row.js\";\nimport type { CoinCollectionLike, CoinPriceLike } from \"../data/coins.js\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { normalizeAddress } from \"@medialane/sdk\";\n\nconst REFRESH_MS = 60_000;\n\nfunction useAllCoinPrices(getClient: () => MedialaneClient) {\n const client = useMedialaneClient(getClient);\n const { data, isLoading } = useSWR<ApiCoinPrices>(\n \"coin-prices\",\n async () => (await client.api.getCoinPrices()).data,\n { revalidateOnFocus: false, refreshInterval: REFRESH_MS, shouldRetryOnError: false }\n );\n return { prices: data ?? null, isLoading };\n}\n\nexport function usePriceMap(getClient: () => MedialaneClient) {\n const { prices, isLoading } = useAllCoinPrices(getClient);\n const map: Record<string, number | null> = {};\n if (prices) {\n for (const [address, entry] of Object.entries(prices)) {\n map[address] = entry?.usdc ?? null;\n }\n }\n return { prices: map, isLoading };\n}\n\nexport function useCoinPrice(getClient: () => MedialaneClient, coin: CoinCollectionLike): {\n price: CoinPriceLike | null;\n status: CoinMarketStatus;\n isLoading: boolean;\n} {\n const { prices, isLoading } = useAllCoinPrices(getClient);\n\n if (isLoading || !prices) return { price: null, status: \"unavailable\", isLoading };\n\n const usdc = prices[normalizeAddress(\"STARKNET\", coin.contractAddress)]?.usdc ?? null;\n\n if (usdc == null) {\n return {\n price: null,\n status: coin.isLaunched === false ? \"pre-launch\" : \"unavailable\",\n isLoading: false,\n };\n }\n\n const strk = getTokenBySymbol(\"STRK\");\n const strkUsdc = strk ? (prices[normalizeAddress(\"STARKNET\", strk.address)]?.usdc ?? null) : null;\n\n return {\n price: {\n quotePerCoin: strkUsdc ? usdc / strkUsdc : usdc,\n quoteSymbol: strkUsdc ? \"STRK\" : \"USDC\",\n quoteUsdR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,YAAY,KAAK,OAAO,CAAC,GAAG,QAAQ,OAAQ;AAE7F,SAAO;AAAA,IACL,OAAO;AAAA,MACL,cAAc,WAAW,OAAO,WAAW;AAAA,MAC3C,aAAa,WAAW,SAAS;AAAA,MACjC,cAAc,YAAY;AAAA,IAC5B;AAAA,IACA,QAAQ;AAAA,IACR,WAAW;AAAA,EACb;AACF;","names":["import_sdk","useSWR"]}
@@ -0,0 +1,17 @@
1
+ import { MedialaneClient } from '@medialane/sdk/starknet';
2
+ import { CoinMarketStatus } from '../components/coin-row.cjs';
3
+ import { CoinCollectionLike, CoinPriceLike } from '../data/coins.cjs';
4
+ import 'react/jsx-runtime';
5
+ import '@medialane/sdk';
6
+
7
+ declare function usePriceMap(getClient: () => MedialaneClient): {
8
+ prices: Record<string, number | null>;
9
+ isLoading: boolean;
10
+ };
11
+ declare function useCoinPrice(getClient: () => MedialaneClient, coin: CoinCollectionLike): {
12
+ price: CoinPriceLike | null;
13
+ status: CoinMarketStatus;
14
+ isLoading: boolean;
15
+ };
16
+
17
+ export { useCoinPrice, usePriceMap };
@@ -0,0 +1,17 @@
1
+ import { MedialaneClient } from '@medialane/sdk/starknet';
2
+ import { CoinMarketStatus } from '../components/coin-row.js';
3
+ import { CoinCollectionLike, CoinPriceLike } from '../data/coins.js';
4
+ import 'react/jsx-runtime';
5
+ import '@medialane/sdk';
6
+
7
+ declare function usePriceMap(getClient: () => MedialaneClient): {
8
+ prices: Record<string, number | null>;
9
+ isLoading: boolean;
10
+ };
11
+ declare function useCoinPrice(getClient: () => MedialaneClient, coin: CoinCollectionLike): {
12
+ price: CoinPriceLike | null;
13
+ status: CoinMarketStatus;
14
+ isLoading: boolean;
15
+ };
16
+
17
+ export { useCoinPrice, usePriceMap };
@@ -0,0 +1,53 @@
1
+ "use client";
2
+ import useSWR from "swr";
3
+ import { getTokenBySymbol } from "@medialane/sdk";
4
+ import { useMedialaneClient } from "./use-medialane-client.js";
5
+ import { normalizeAddress } from "@medialane/sdk";
6
+ const REFRESH_MS = 6e4;
7
+ function useAllCoinPrices(getClient) {
8
+ const client = useMedialaneClient(getClient);
9
+ const { data, isLoading } = useSWR(
10
+ "coin-prices",
11
+ async () => (await client.api.getCoinPrices()).data,
12
+ { revalidateOnFocus: false, refreshInterval: REFRESH_MS, shouldRetryOnError: false }
13
+ );
14
+ return { prices: data ?? null, isLoading };
15
+ }
16
+ function usePriceMap(getClient) {
17
+ const { prices, isLoading } = useAllCoinPrices(getClient);
18
+ const map = {};
19
+ if (prices) {
20
+ for (const [address, entry] of Object.entries(prices)) {
21
+ map[address] = entry?.usdc ?? null;
22
+ }
23
+ }
24
+ return { prices: map, isLoading };
25
+ }
26
+ function useCoinPrice(getClient, coin) {
27
+ const { prices, isLoading } = useAllCoinPrices(getClient);
28
+ if (isLoading || !prices) return { price: null, status: "unavailable", isLoading };
29
+ const usdc = prices[normalizeAddress("STARKNET", coin.contractAddress)]?.usdc ?? null;
30
+ if (usdc == null) {
31
+ return {
32
+ price: null,
33
+ status: coin.isLaunched === false ? "pre-launch" : "unavailable",
34
+ isLoading: false
35
+ };
36
+ }
37
+ const strk = getTokenBySymbol("STRK");
38
+ const strkUsdc = strk ? prices[normalizeAddress("STARKNET", strk.address)]?.usdc ?? null : null;
39
+ return {
40
+ price: {
41
+ quotePerCoin: strkUsdc ? usdc / strkUsdc : usdc,
42
+ quoteSymbol: strkUsdc ? "STRK" : "USDC",
43
+ quoteUsdRate: strkUsdc ?? 1
44
+ },
45
+ status: "live",
46
+ isLoading: false
47
+ };
48
+ }
49
+ export {
50
+ useCoinPrice,
51
+ usePriceMap
52
+ };
53
+ //# sourceMappingURL=use-coin-price.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/use-coin-price.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { getTokenBySymbol, type ApiCoinPrices } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { CoinMarketStatus } from \"../components/coin-row.js\";\nimport type { CoinCollectionLike, CoinPriceLike } from \"../data/coins.js\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport { normalizeAddress } from \"@medialane/sdk\";\n\nconst REFRESH_MS = 60_000;\n\nfunction useAllCoinPrices(getClient: () => MedialaneClient) {\n const client = useMedialaneClient(getClient);\n const { data, isLoading } = useSWR<ApiCoinPrices>(\n \"coin-prices\",\n async () => (await client.api.getCoinPrices()).data,\n { revalidateOnFocus: false, refreshInterval: REFRESH_MS, shouldRetryOnError: false }\n );\n return { prices: data ?? null, isLoading };\n}\n\nexport function usePriceMap(getClient: () => MedialaneClient) {\n const { prices, isLoading } = useAllCoinPrices(getClient);\n const map: Record<string, number | null> = {};\n if (prices) {\n for (const [address, entry] of Object.entries(prices)) {\n map[address] = entry?.usdc ?? null;\n }\n }\n return { prices: map, isLoading };\n}\n\nexport function useCoinPrice(getClient: () => MedialaneClient, coin: CoinCollectionLike): {\n price: CoinPriceLike | null;\n status: CoinMarketStatus;\n isLoading: boolean;\n} {\n const { prices, isLoading } = useAllCoinPrices(getClient);\n\n if (isLoading || !prices) return { price: null, status: \"unavailable\", isLoading };\n\n const usdc = prices[normalizeAddress(\"STARKNET\", coin.contractAddress)]?.usdc ?? null;\n\n if (usdc == null) {\n return {\n price: null,\n status: coin.isLaunched === false ? \"pre-launch\" : \"unavailable\",\n isLoading: false,\n };\n }\n\n const strk = getTokenBySymbol(\"STRK\");\n const strkUsdc = strk ? (prices[normalizeAddress(\"STARKNET\", strk.address)]?.usdc ?? null) : null;\n\n return {\n price: {\n quotePerCoin: strkUsdc ? usdc / strkUsdc : usdc,\n quoteSymbol: strkUsdc ? \"STRK\" : \"USDC\",\n quoteUsdRate: strkUsdc ?? 1,\n },\n status: \"live\",\n isLoading: false,\n };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AACnB,SAAS,wBAA4C;AAIrD,SAAS,0BAA0B;AACnC,SAAS,wBAAwB;AAEjC,MAAM,aAAa;AAEnB,SAAS,i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
@@ -45,7 +45,7 @@ function useCollections(getClient, page = 1, limit = 20, isFeatured, sort = "rec
45
45
  const { data, error, isLoading, mutate } = (0, import_swr.default)(
46
46
  key,
47
47
  async () => {
48
- const res = await client.api.getCollections(page, limit, isFeatured, sort, service, void 0, standard);
48
+ const res = await client.api.listCollections({ page, limit, isFeatured, sort, service, standard });
49
49
  return hideEmpty ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) } : res;
50
50
  },
51
51
  {
@@ -74,7 +74,7 @@ function useCollectionsByOwner(getClient, owner) {
74
74
  const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
75
75
  const { data, error, isLoading, mutate } = (0, import_swr.default)(
76
76
  owner ? import_query_keys.queryKeys.collectionsOwner(owner) : null,
77
- () => client.api.getCollectionsByOwner(owner),
77
+ () => client.api.listCollections({ owner, limit: 50 }),
78
78
  { revalidateOnFocus: false, refreshInterval: 6e4 }
79
79
  );
80
80
  return { collections: data?.data ?? [], isLoading, error, mutate };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/use-collections.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { ApiCollection, ApiResponse, CollectionTokensSort } from \"@medialane/sdk\";\nimport { queryKeys } from \"./query-keys.js\";\n\nexport type CollectionSort = \"recent\" | \"supply\" | \"floor\" | \"volume\" | \"name\";\n\nexport function useCollections(\n getClient: () => MedialaneClient,\n page = 1,\n limit = 20,\n isFeatured?: boolean,\n sort: CollectionSort = \"recent\",\n hideEmpty = true,\n service?: string,\n\n standard?: string,\n\n fallback?: ApiCollection[]\n) {\n const client = useMedialaneClient(getClient);\n const key = `${queryKeys.collections(page, limit, isFeatured, sort, hideEmpty, service)}-${standard ?? \"\"}`;\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiCollection[]>>(\n key,\n async () => {\n const res = await client.api.getCollections(page, limit, isFeatured, sort, service, undefined, standard);\n return hideEmpty\n ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) }\n : res;\n },\n {\n revalidateOnFocus: false,\n ...(fallback ? { fallbackData: { data: fallback } as ApiResponse<ApiCollection[]> } : {}),\n }\n );\n\n return {\n collections: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useCollection(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading } = useSWR(\n contract ? queryKeys.collection(contract) : null,\n () => client.api.getCollection(contract!),\n { revalidateOnFocus: false }\n );\n\n return { collection: data?.data ?? null, isLoading, error };\n}\n\nexport function useCollectionsByOwner(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n owner ? queryKeys.collectionsOwner(owner) : null,\n () => client.api.getCollectionsByOwner(owner!),\n { revalidateOnFocus: false, refreshInterval: 60_000 }\n );\n\n return { collections: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n page = 1,\n limit = 24,\n sort: CollectionTokensSort = \"recent\"\n) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n contract ? queryKeys.collectionTokens(contract, page, limit, sort) : null,\n () => client.api.getCollectionTokens(contract!, page, limit, sort),\n { revalidateOnFocus: false }\n );\n\n return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nfunction pickNearbyTokens<T extends { tokenId: string }>(\n tokens: T[],\n currentTokenId: string | null,\n count: number\n): T[] {\n if (!currentTokenId) return tokens.slice(0, count);\n const idx = tokens.findIndex((t) => String(t.tokenId) === String(currentTokenId));\n if (idx === -1) return tokens.slice(0, count);\n\n const picked: T[] = [];\n let after = idx + 1;\n let before = idx - 1;\n while (picked.length < count && (after < tokens.length || before >= 0)) {\n if (after < tokens.length) picked.push(tokens[after++]);\n if (picked.length < count && before >= 0) picked.push(tokens[before--]);\n }\n return picked.sort((a, b) => Number(a.tokenId) - Number(b.tokenId));\n}\n\nexport function useNearbyCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n currentTokenId: string | null,\n count = 4,\n poolSize = 60\n) {\n const { tokens, isLoading, error } = useCollectionTokens(getClient, contract, 1, poolSize, \"oldest\");\n return { tokens: pickNearbyTokens(tokens, currentTokenId, count), isLoading, error };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AACnB,kCAAmC;AAGnC,wBAA0B;AAInB,SAAS,eACd,WACA,OAAO,GACP,QAAQ,IACR,YACA,OAAuB,UACvB,YAAY,MACZ,SAEA,UAEA,UACA;AACA,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,MAAM,GAAG,4BAAU,YAAY,MAAM,OAAO,YAAY,MAAM,WAAW,OAAO,CAAC,IAAI,YAAY,EAAE;AAEzG,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC;AAAA,IACA,YAAY;AACV,YAAM,MAAM,MAAM,OAAO,IAAI,eAAe,MAAM,OAAO,YAAY,MAAM,SAAS,QAAW,QAAQ;AACvG,aAAO,YACH,EAAE,GAAG,KAAK,MAAM,IAAI,KAAK,OAAO,CAAC,gBAAgB,WAAW,eAAe,KAAK,CAAC,EAAE,IACnF;AAAA,IACN;AAAA,IACA;AAAA,MACE,mBAAmB;AAAA,MACnB,GAAI,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,EAAkC,IAAI,CAAC;AAAA,IACzF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,aAAa,MAAM,QAAQ,CAAC;AAAA,IAC5B,MAAM,MAAM;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,cAAc,WAAk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ChF,MAAI,QAAQ,GAAI,QAAO,OAAO,MAAM,GAAG,KAAK;AAE5C,QAAM,SAAc,CAAC;AACrB,MAAI,QAAQ,MAAM;AAClB,MAAI,SAAS,MAAM;AACnB,SAAO,OAAO,SAAS,UAAU,QAAQ,OAAO,UAAU,UAAU,IAAI;AACtE,QAAI,QAAQ,OAAO,OAAQ,QAAO,KAAK,OAAO,OAAO,CAAC;AACtD,QAAI,OAAO,SAAS,SAAS,UAAU,EAAG,QAAO,KAAK,OAAO,QAAQ,CAAC;AAAA,EACxE;AACA,SAAO,OAAO,KAAK,CAAC,GAAG,MAAM,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,OAAO,CAAC;AACpE;AAEO,SAAS,0BACd,WACA,UACA,gBACA,QAAQ,GACR,WAAW,IACX;AACA,QAAM,EAAE,QAAQ,WAAW,MAAM,IAAI,oBAAoB,WAAW,UAAU,GAAG,UAAU,QAAQ;AACnG,SAAO,EAAE,QAAQ,iBAAiB,QAAQ,gBAAgB,KAAK,GAAG,WAAW,MAAM;AACrF;","names":["useSWR"]}
1
+ {"version":3,"sources":["../../src/utils/use-collections.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { ApiCollection, ApiResponse, CollectionTokensSort } from \"@medialane/sdk\";\nimport { queryKeys } from \"./query-keys.js\";\n\nexport type CollectionSort = \"recent\" | \"supply\" | \"floor\" | \"volume\" | \"name\";\n\nexport function useCollections(\n getClient: () => MedialaneClient,\n page = 1,\n limit = 20,\n isFeatured?: boolean,\n sort: CollectionSort = \"recent\",\n hideEmpty = true,\n service?: string,\n\n standard?: string,\n\n fallback?: ApiCollection[]\n) {\n const client = useMedialaneClient(getClient);\n const key = `${queryKeys.collections(page, limit, isFeatured, sort, hideEmpty, service)}-${standard ?? \"\"}`;\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiCollection[]>>(\n key,\n async () => {\n const res = await client.api.listCollections({ page, limit, isFeatured, sort, service, standard });\n return hideEmpty\n ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) }\n : res;\n },\n {\n revalidateOnFocus: false,\n ...(fallback ? { fallbackData: { data: fallback } as ApiResponse<ApiCollection[]> } : {}),\n }\n );\n\n return {\n collections: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useCollection(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading } = useSWR(\n contract ? queryKeys.collection(contract) : null,\n () => client.api.getCollection(contract!),\n { revalidateOnFocus: false }\n );\n\n return { collection: data?.data ?? null, isLoading, error };\n}\n\nexport function useCollectionsByOwner(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n owner ? queryKeys.collectionsOwner(owner) : null,\n () => client.api.listCollections({ owner: owner!, limit: 50 }),\n { revalidateOnFocus: false, refreshInterval: 60_000 }\n );\n\n return { collections: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n page = 1,\n limit = 24,\n sort: CollectionTokensSort = \"recent\"\n) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n contract ? queryKeys.collectionTokens(contract, page, limit, sort) : null,\n () => client.api.getCollectionTokens(contract!, page, limit, sort),\n { revalidateOnFocus: false }\n );\n\n return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nfunction pickNearbyTokens<T extends { tokenId: string }>(\n tokens: T[],\n currentTokenId: string | null,\n count: number\n): T[] {\n if (!currentTokenId) return tokens.slice(0, count);\n const idx = tokens.findIndex((t) => String(t.tokenId) === String(currentTokenId));\n if (idx === -1) return tokens.slice(0, count);\n\n const picked: T[] = [];\n let after = idx + 1;\n let before = idx - 1;\n while (picked.length < count && (after < tokens.length || before >= 0)) {\n if (after < tokens.length) picked.push(tokens[after++]);\n if (picked.length < count && before >= 0) picked.push(tokens[before--]);\n }\n return picked.sort((a, b) => Number(a.tokenId) - Number(b.tokenId));\n}\n\nexport function useNearbyCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n currentTokenId: string | null,\n count = 4,\n poolSize = 60\n) {\n const { tokens, isLoading, error } = useCollectionTokens(getClient, contract, 1, poolSize, \"oldest\");\n return { tokens: pickNearbyTokens(tokens, currentTokenId, count), isLoading, error };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AACnB,kCAAmC;AAGnC,wBAA0B;AAInB,SAAS,eACd,WACA,OAAO,GACP,QAAQ,IACR,YACA,OAAuB,UACvB,YAAY,MACZ,SAEA,UAEA,UACA;AACA,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,MAAM,GAAG,4BAAU,YAAY,MAAM,OAAO,YAAY,MAAM,WAAW,OAAO,CAAC,IAAI,YAAY,EAAE;AAEzG,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC;AAAA,IACA,YAAY;AACV,YAAM,MAAM,MAAM,OAAO,IAAI,gBAAgB,EAAE,MAAM,OAAO,YAAY,MAAM,SAAS,SAAS,CAAC;AACjG,aAAO,YACH,EAAE,GAAG,KAAK,MAAM,IAAI,KAAK,OAAO,CAAC,gBAAgB,WAAW,eAAe,KAAK,CAAC,EAAE,IACnF;AAAA,IACN;AAAA,IACA;AAAA,MACE,mBAAmB;AAAA,MACnB,GAAI,WAAW,EAAE,cAAc,EAAE,MAAM,SAAS,EAAkC,IAAI,CAAC;AAAA,IACzF;AAAA,EACF;AAEA,SAAO;AAAA,IACL,aAAa,MAAM,QAAQ,CAAC;AAAA,IAC5B,MAAM,MAAM;AAAA,IACZ;AAAA,IACA;AAAA,I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AO,UAAU,CAAC,MAAM,OAAO,EAAE,OAAO,MAAM,OAAO,cAAc,CAAC;AAChF,MAAI,QAAQ,GAAI,QAAO,OAAO,MAAM,GAAG,KAAK;AAE5C,QAAM,SAAc,CAAC;AACrB,MAAI,QAAQ,MAAM;AAClB,MAAI,SAAS,MAAM;AACnB,SAAO,OAAO,SAAS,UAAU,QAAQ,OAAO,UAAU,UAAU,IAAI;AACtE,QAAI,QAAQ,OAAO,OAAQ,QAAO,KAAK,OAAO,OAAO,CAAC;AACtD,QAAI,OAAO,SAAS,SAAS,UAAU,EAAG,QAAO,KAAK,OAAO,QAAQ,CAAC;AAAA,EACxE;AACA,SAAO,OAAO,KAAK,CAAC,GAAG,MAAM,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,OAAO,CAAC;AACpE;AAEO,SAAS,0BACd,WACA,UACA,gBACA,QAAQ,GACR,WAAW,IACX;AACA,QAAM,EAAE,QAAQ,WAAW,MAAM,IAAI,oBAAoB,WAAW,UAAU,GAAG,UAAU,QAAQ;AACnG,SAAO,EAAE,QAAQ,iBAAiB,QAAQ,gBAAgB,KAAK,GAAG,WAAW,MAAM;AACrF;","names":["useSWR"]}
@@ -8,7 +8,7 @@ function useCollections(getClient, page = 1, limit = 20, isFeatured, sort = "rec
8
8
  const { data, error, isLoading, mutate } = useSWR(
9
9
  key,
10
10
  async () => {
11
- const res = await client.api.getCollections(page, limit, isFeatured, sort, service, void 0, standard);
11
+ const res = await client.api.listCollections({ page, limit, isFeatured, sort, service, standard });
12
12
  return hideEmpty ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) } : res;
13
13
  },
14
14
  {
@@ -37,7 +37,7 @@ function useCollectionsByOwner(getClient, owner) {
37
37
  const client = useMedialaneClient(getClient);
38
38
  const { data, error, isLoading, mutate } = useSWR(
39
39
  owner ? queryKeys.collectionsOwner(owner) : null,
40
- () => client.api.getCollectionsByOwner(owner),
40
+ () => client.api.listCollections({ owner, limit: 50 }),
41
41
  { revalidateOnFocus: false, refreshInterval: 6e4 }
42
42
  );
43
43
  return { collections: data?.data ?? [], isLoading, error, mutate };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/utils/use-collections.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { ApiCollection, ApiResponse, CollectionTokensSort } from \"@medialane/sdk\";\nimport { queryKeys } from \"./query-keys.js\";\n\nexport type CollectionSort = \"recent\" | \"supply\" | \"floor\" | \"volume\" | \"name\";\n\nexport function useCollections(\n getClient: () => MedialaneClient,\n page = 1,\n limit = 20,\n isFeatured?: boolean,\n sort: CollectionSort = \"recent\",\n hideEmpty = true,\n service?: string,\n\n standard?: string,\n\n fallback?: ApiCollection[]\n) {\n const client = useMedialaneClient(getClient);\n const key = `${queryKeys.collections(page, limit, isFeatured, sort, hideEmpty, service)}-${standard ?? \"\"}`;\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiCollection[]>>(\n key,\n async () => {\n const res = await client.api.getCollections(page, limit, isFeatured, sort, service, undefined, standard);\n return hideEmpty\n ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) }\n : res;\n },\n {\n revalidateOnFocus: false,\n ...(fallback ? { fallbackData: { data: fallback } as ApiResponse<ApiCollection[]> } : {}),\n }\n );\n\n return {\n collections: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useCollection(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading } = useSWR(\n contract ? queryKeys.collection(contract) : null,\n () => client.api.getCollection(contract!),\n { revalidateOnFocus: false }\n );\n\n return { collection: data?.data ?? null, isLoading, error };\n}\n\nexport function useCollectionsByOwner(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n owner ? queryKeys.collectionsOwner(owner) : null,\n () => client.api.getCollectionsByOwner(owner!),\n { revalidateOnFocus: false, refreshInterval: 60_000 }\n );\n\n return { collections: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n page = 1,\n limit = 24,\n sort: CollectionTokensSort = \"recent\"\n) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n contract ? queryKeys.collectionTokens(contract, page, limit, sort) : null,\n () => client.api.getCollectionTokens(contract!, page, limit, sort),\n { revalidateOnFocus: false }\n );\n\n return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nfunction pickNearbyTokens<T extends { tokenId: string }>(\n tokens: T[],\n currentTokenId: string | null,\n count: number\n): T[] {\n if (!currentTokenId) return tokens.slice(0, count);\n const idx = tokens.findIndex((t) => String(t.tokenId) === String(currentTokenId));\n if (idx === -1) return tokens.slice(0, count);\n\n const picked: T[] = [];\n let after = idx + 1;\n let before = idx - 1;\n while (picked.length < count && (after < tokens.length || before >= 0)) {\n if (after < tokens.length) picked.push(tokens[after++]);\n if (picked.length < count && before >= 0) picked.push(tokens[before--]);\n }\n return picked.sort((a, b) => Number(a.tokenId) - Number(b.tokenId));\n}\n\nexport function useNearbyCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n currentTokenId: string | null,\n count = 4,\n poolSize = 60\n) {\n const { tokens, isLoading, error } = useCollectionTokens(getClient, contract, 1, poolSize, \"oldest\");\n return { tokens: pickNearbyTokens(tokens, currentTokenId, count), isLoading, error };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AACnB,SAAS,0BAA0B;AAGnC,SAAS,iBAAiB;AAInB,SAAS,eACd,WACA,OAAO,GACP,QAAQ,IACR,YACA,OAAuB,UACvB,YAAY,MACZ,SAEA,UAEA,UACA;AACA,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,MAAM,GAAG,UAAU,YAAY,MAAM,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;","names":[]}
1
+ {"version":3,"sources":["../../src/utils/use-collections.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport type { ApiCollection, ApiResponse, CollectionTokensSort } from \"@medialane/sdk\";\nimport { queryKeys } from \"./query-keys.js\";\n\nexport type CollectionSort = \"recent\" | \"supply\" | \"floor\" | \"volume\" | \"name\";\n\nexport function useCollections(\n getClient: () => MedialaneClient,\n page = 1,\n limit = 20,\n isFeatured?: boolean,\n sort: CollectionSort = \"recent\",\n hideEmpty = true,\n service?: string,\n\n standard?: string,\n\n fallback?: ApiCollection[]\n) {\n const client = useMedialaneClient(getClient);\n const key = `${queryKeys.collections(page, limit, isFeatured, sort, hideEmpty, service)}-${standard ?? \"\"}`;\n\n const { data, error, isLoading, mutate } = useSWR<ApiResponse<ApiCollection[]>>(\n key,\n async () => {\n const res = await client.api.listCollections({ page, limit, isFeatured, sort, service, standard });\n return hideEmpty\n ? { ...res, data: res.data.filter((collection) => (collection.totalSupply ?? 0) > 0) }\n : res;\n },\n {\n revalidateOnFocus: false,\n ...(fallback ? { fallbackData: { data: fallback } as ApiResponse<ApiCollection[]> } : {}),\n }\n );\n\n return {\n collections: data?.data ?? [],\n meta: data?.meta,\n isLoading,\n error,\n mutate,\n };\n}\n\nexport function useCollection(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading } = useSWR(\n contract ? queryKeys.collection(contract) : null,\n () => client.api.getCollection(contract!),\n { revalidateOnFocus: false }\n );\n\n return { collection: data?.data ?? null, isLoading, error };\n}\n\nexport function useCollectionsByOwner(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n owner ? queryKeys.collectionsOwner(owner) : null,\n () => client.api.listCollections({ owner: owner!, limit: 50 }),\n { revalidateOnFocus: false, refreshInterval: 60_000 }\n );\n\n return { collections: data?.data ?? [], isLoading, error, mutate };\n}\n\nexport function useCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n page = 1,\n limit = 24,\n sort: CollectionTokensSort = \"recent\"\n) {\n const client = useMedialaneClient(getClient);\n\n const { data, error, isLoading, mutate } = useSWR(\n contract ? queryKeys.collectionTokens(contract, page, limit, sort) : null,\n () => client.api.getCollectionTokens(contract!, page, limit, sort),\n { revalidateOnFocus: false }\n );\n\n return { tokens: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nfunction pickNearbyTokens<T extends { tokenId: string }>(\n tokens: T[],\n currentTokenId: string | null,\n count: number\n): T[] {\n if (!currentTokenId) return tokens.slice(0, count);\n const idx = tokens.findIndex((t) => String(t.tokenId) === String(currentTokenId));\n if (idx === -1) return tokens.slice(0, count);\n\n const picked: T[] = [];\n let after = idx + 1;\n let before = idx - 1;\n while (picked.length < count && (after < tokens.length || before >= 0)) {\n if (after < tokens.length) picked.push(tokens[after++]);\n if (picked.length < count && before >= 0) picked.push(tokens[before--]);\n }\n return picked.sort((a, b) => Number(a.tokenId) - Number(b.tokenId));\n}\n\nexport function useNearbyCollectionTokens(\n getClient: () => MedialaneClient,\n contract: string | null,\n currentTokenId: string | null,\n count = 4,\n poolSize = 60\n) {\n const { tokens, isLoading, error } = useCollectionTokens(getClient, contract, 1, poolSize, \"oldest\");\n return { tokens: pickNearbyTokens(tokens, currentTokenId, count), isLoading, error };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AACnB,SAAS,0BAA0B;AAGnC,SAAS,iBAAiB;AAInB,SAAS,eACd,WACA,OAAO,GACP,QAAQ,IACR,YACA,OAAuB,UACvB,YAAY,MACZ,SAEA,UAEA,UACA;AACA,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,MAAM,GAAG,UAAU,YAAY,MAAM,OAAO,YAAY,MAAM,WAAW,OAAO,CAAC,IAAI,YAAY,EAAE;AAEzG,QAAM,EAAE,MAA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"use client";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+ var use_drops_exports = {};
31
+ __export(use_drops_exports, {
32
+ useDropCollections: () => useDropCollections,
33
+ useDropInfo: () => useDropInfo,
34
+ useDropMintStatus: () => useDropMintStatus,
35
+ useMyDrops: () => useMyDrops,
36
+ useOnChainDropState: () => useOnChainDropState
37
+ });
38
+ module.exports = __toCommonJS(use_drops_exports);
39
+ var import_swr = __toESM(require("swr"), 1);
40
+ var import_use_medialane_client = require("./use-medialane-client.js");
41
+ function useDropCollections(getClient) {
42
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
43
+ const { data, error, isLoading, mutate } = (0, import_swr.default)(
44
+ "drop-collections",
45
+ () => client.api.listCollections({ service: "drop-collection", hideEmpty: false, limit: 50 }),
46
+ { revalidateOnFocus: false }
47
+ );
48
+ return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };
49
+ }
50
+ function useMyDrops(getClient, owner) {
51
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
52
+ const { data, error, isLoading, mutate } = (0, import_swr.default)(
53
+ owner ? `my-drops-${owner}` : null,
54
+ async () => (await client.api.listCollections({ service: "drop-collection", owner, limit: 50 })).data ?? [],
55
+ { revalidateOnFocus: false }
56
+ );
57
+ return { drops: data ?? [], isLoading, error, mutate };
58
+ }
59
+ function useDropMintStatus(getClient, collection, wallet) {
60
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
61
+ const { data, error, isLoading, mutate } = (0, import_swr.default)(
62
+ collection && wallet ? `drop-mint-status-${collection}-${wallet}` : null,
63
+ () => client.api.getDropMintStatus(collection, wallet),
64
+ { revalidateOnFocus: false, shouldRetryOnError: false }
65
+ );
66
+ return { mintStatus: data ?? null, isLoading, error, mutate };
67
+ }
68
+ function useDropInfo(getClient, contract) {
69
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
70
+ const { data, error, isLoading } = (0, import_swr.default)(
71
+ contract ? `drop-info-${contract}` : null,
72
+ () => client.api.getDropInfo(contract),
73
+ { revalidateOnFocus: false, shouldRetryOnError: false }
74
+ );
75
+ return { dropInfo: data ?? null, isLoading, error };
76
+ }
77
+ function useOnChainDropState(getClient, contract) {
78
+ const client = (0, import_use_medialane_client.useMedialaneClient)(getClient);
79
+ const { data, error, isLoading, mutate } = (0, import_swr.default)(
80
+ contract ? `drop-onchain-${contract}` : null,
81
+ () => client.api.getDropState(contract),
82
+ { revalidateOnFocus: false, refreshInterval: 3e4, shouldRetryOnError: false }
83
+ );
84
+ return { state: data ?? null, isLoading, error, mutate };
85
+ }
86
+ // Annotate the CommonJS export names for ESM import in node:
87
+ 0 && (module.exports = {
88
+ useDropCollections,
89
+ useDropInfo,
90
+ useDropMintStatus,
91
+ useMyDrops,
92
+ useOnChainDropState
93
+ });
94
+ //# sourceMappingURL=use-drops.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/use-drops.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiCollection, ApiDropInfo, ApiDropState, ApiMeta, DropMintStatus } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function useDropCollections(getClient: () => MedialaneClient) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<{ data: ApiCollection[]; meta?: ApiMeta }>(\n \"drop-collections\",\n () => client.api.listCollections({ service: \"drop-collection\", hideEmpty: false, limit: 50 }),\n { revalidateOnFocus: false }\n );\n return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nexport function useMyDrops(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiCollection[]>(\n owner ? `my-drops-${owner}` : null,\n async () => (await client.api.listCollections({ service: \"drop-collection\", owner: owner!, limit: 50 })).data ?? [],\n { revalidateOnFocus: false }\n );\n return { drops: data ?? [], isLoading, error, mutate };\n}\n\nexport function useDropMintStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<DropMintStatus>(\n collection && wallet ? `drop-mint-status-${collection}-${wallet}` : null,\n () => client.api.getDropMintStatus(collection!, wallet!),\n { revalidateOnFocus: false, shouldRetryOnError: false }\n );\n return { mintStatus: data ?? null, isLoading, error, mutate };\n}\n\nexport function useDropInfo(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR<ApiDropInfo | null>(\n contract ? `drop-info-${contract}` : null,\n () => client.api.getDropInfo(contract!),\n { revalidateOnFocus: false, shouldRetryOnError: false }\n );\n return { dropInfo: data ?? null, isLoading, error };\n}\n\nexport function useOnChainDropState(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiDropState>(\n contract ? `drop-onchain-${contract}` : null,\n () => client.api.getDropState(contract!),\n { revalidateOnFocus: false, refreshInterval: 30_000, shouldRetryOnError: false }\n );\n return { state: data ?? null, isLoading, error, mutate };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,iBAAmB;AAGnB,kCAAmC;AAE5B,SAAS,mBAAmB,WAAkC;AACnE,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC;AAAA,IACA,MAAM,OAAO,IAAI,gBAAgB,EAAE,SAAS,mBAAmB,WAAW,OAAO,OAAO,GAAG,CAAC;AAAA,IAC5F,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,aAAa,MAAM,QAAQ,CAAC,GAAG,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO;AACrF;AAEO,SAAS,WAAW,WAAkC,OAAsB;AACjF,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,QAAQ,YAAY,KAAK,KAAK;AAAA,IAC9B,aAAa,MAAM,OAAO,IAAI,gBAAgB,EAAE,SAAS,mBAAmB,OAAe,OAAO,GAAG,CAAC,GAAG,QAAQ,CAAC;AAAA,IAClH,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,OAAO,QAAQ,CAAC,GAAG,WAAW,OAAO,OAAO;AACvD;AAEO,SAAS,kBAAkB,WAAkC,YAA2B,QAAuB;AACpH,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,cAAc,SAAS,oBAAoB,UAAU,IAAI,MAAM,KAAK;AAAA,IACpE,MAAM,OAAO,IAAI,kBAAkB,YAAa,MAAO;AAAA,IACvD,EAAE,mBAAmB,OAAO,oBAAoB,MAAM;AAAA,EACxD;AACA,SAAO,EAAE,YAAY,QAAQ,MAAM,WAAW,OAAO,OAAO;AAC9D;AAEO,SAAS,YAAY,WAAkC,UAAyB;AACrF,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,UAAU,QAAI,WAAAA;AAAA,IACjC,WAAW,aAAa,QAAQ,KAAK;AAAA,IACrC,MAAM,OAAO,IAAI,YAAY,QAAS;AAAA,IACtC,EAAE,mBAAmB,OAAO,oBAAoB,MAAM;AAAA,EACxD;AACA,SAAO,EAAE,UAAU,QAAQ,MAAM,WAAW,MAAM;AACpD;AAEO,SAAS,oBAAoB,WAAkC,UAAyB;AAC7F,QAAM,aAAS,gDAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,QAAI,WAAAA;AAAA,IACzC,WAAW,gBAAgB,QAAQ,KAAK;AAAA,IACxC,MAAM,OAAO,IAAI,aAAa,QAAS;AAAA,IACvC,EAAE,mBAAmB,OAAO,iBAAiB,KAAQ,oBAAoB,MAAM;AAAA,EACjF;AACA,SAAO,EAAE,OAAO,QAAQ,MAAM,WAAW,OAAO,OAAO;AACzD;","names":["useSWR"]}
@@ -0,0 +1,39 @@
1
+ import * as swr from 'swr';
2
+ import { ApiCollection, ApiMeta, ApiDropInfo, DropMintStatus, ApiDropState } from '@medialane/sdk';
3
+ import { MedialaneClient } from '@medialane/sdk/starknet';
4
+
5
+ declare function useDropCollections(getClient: () => MedialaneClient): {
6
+ collections: ApiCollection[];
7
+ meta: ApiMeta | undefined;
8
+ isLoading: boolean;
9
+ error: any;
10
+ mutate: swr.KeyedMutator<{
11
+ data: ApiCollection[];
12
+ meta?: ApiMeta;
13
+ }>;
14
+ };
15
+ declare function useMyDrops(getClient: () => MedialaneClient, owner: string | null): {
16
+ drops: ApiCollection[];
17
+ isLoading: boolean;
18
+ error: any;
19
+ mutate: swr.KeyedMutator<ApiCollection[]>;
20
+ };
21
+ declare function useDropMintStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null): {
22
+ mintStatus: DropMintStatus | null;
23
+ isLoading: boolean;
24
+ error: any;
25
+ mutate: swr.KeyedMutator<DropMintStatus>;
26
+ };
27
+ declare function useDropInfo(getClient: () => MedialaneClient, contract: string | null): {
28
+ dropInfo: ApiDropInfo | null;
29
+ isLoading: boolean;
30
+ error: any;
31
+ };
32
+ declare function useOnChainDropState(getClient: () => MedialaneClient, contract: string | null): {
33
+ state: ApiDropState | null;
34
+ isLoading: boolean;
35
+ error: any;
36
+ mutate: swr.KeyedMutator<ApiDropState>;
37
+ };
38
+
39
+ export { useDropCollections, useDropInfo, useDropMintStatus, useMyDrops, useOnChainDropState };
@@ -0,0 +1,39 @@
1
+ import * as swr from 'swr';
2
+ import { ApiCollection, ApiMeta, ApiDropInfo, DropMintStatus, ApiDropState } from '@medialane/sdk';
3
+ import { MedialaneClient } from '@medialane/sdk/starknet';
4
+
5
+ declare function useDropCollections(getClient: () => MedialaneClient): {
6
+ collections: ApiCollection[];
7
+ meta: ApiMeta | undefined;
8
+ isLoading: boolean;
9
+ error: any;
10
+ mutate: swr.KeyedMutator<{
11
+ data: ApiCollection[];
12
+ meta?: ApiMeta;
13
+ }>;
14
+ };
15
+ declare function useMyDrops(getClient: () => MedialaneClient, owner: string | null): {
16
+ drops: ApiCollection[];
17
+ isLoading: boolean;
18
+ error: any;
19
+ mutate: swr.KeyedMutator<ApiCollection[]>;
20
+ };
21
+ declare function useDropMintStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null): {
22
+ mintStatus: DropMintStatus | null;
23
+ isLoading: boolean;
24
+ error: any;
25
+ mutate: swr.KeyedMutator<DropMintStatus>;
26
+ };
27
+ declare function useDropInfo(getClient: () => MedialaneClient, contract: string | null): {
28
+ dropInfo: ApiDropInfo | null;
29
+ isLoading: boolean;
30
+ error: any;
31
+ };
32
+ declare function useOnChainDropState(getClient: () => MedialaneClient, contract: string | null): {
33
+ state: ApiDropState | null;
34
+ isLoading: boolean;
35
+ error: any;
36
+ mutate: swr.KeyedMutator<ApiDropState>;
37
+ };
38
+
39
+ export { useDropCollections, useDropInfo, useDropMintStatus, useMyDrops, useOnChainDropState };
@@ -0,0 +1,56 @@
1
+ "use client";
2
+ import useSWR from "swr";
3
+ import { useMedialaneClient } from "./use-medialane-client.js";
4
+ function useDropCollections(getClient) {
5
+ const client = useMedialaneClient(getClient);
6
+ const { data, error, isLoading, mutate } = useSWR(
7
+ "drop-collections",
8
+ () => client.api.listCollections({ service: "drop-collection", hideEmpty: false, limit: 50 }),
9
+ { revalidateOnFocus: false }
10
+ );
11
+ return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };
12
+ }
13
+ function useMyDrops(getClient, owner) {
14
+ const client = useMedialaneClient(getClient);
15
+ const { data, error, isLoading, mutate } = useSWR(
16
+ owner ? `my-drops-${owner}` : null,
17
+ async () => (await client.api.listCollections({ service: "drop-collection", owner, limit: 50 })).data ?? [],
18
+ { revalidateOnFocus: false }
19
+ );
20
+ return { drops: data ?? [], isLoading, error, mutate };
21
+ }
22
+ function useDropMintStatus(getClient, collection, wallet) {
23
+ const client = useMedialaneClient(getClient);
24
+ const { data, error, isLoading, mutate } = useSWR(
25
+ collection && wallet ? `drop-mint-status-${collection}-${wallet}` : null,
26
+ () => client.api.getDropMintStatus(collection, wallet),
27
+ { revalidateOnFocus: false, shouldRetryOnError: false }
28
+ );
29
+ return { mintStatus: data ?? null, isLoading, error, mutate };
30
+ }
31
+ function useDropInfo(getClient, contract) {
32
+ const client = useMedialaneClient(getClient);
33
+ const { data, error, isLoading } = useSWR(
34
+ contract ? `drop-info-${contract}` : null,
35
+ () => client.api.getDropInfo(contract),
36
+ { revalidateOnFocus: false, shouldRetryOnError: false }
37
+ );
38
+ return { dropInfo: data ?? null, isLoading, error };
39
+ }
40
+ function useOnChainDropState(getClient, contract) {
41
+ const client = useMedialaneClient(getClient);
42
+ const { data, error, isLoading, mutate } = useSWR(
43
+ contract ? `drop-onchain-${contract}` : null,
44
+ () => client.api.getDropState(contract),
45
+ { revalidateOnFocus: false, refreshInterval: 3e4, shouldRetryOnError: false }
46
+ );
47
+ return { state: data ?? null, isLoading, error, mutate };
48
+ }
49
+ export {
50
+ useDropCollections,
51
+ useDropInfo,
52
+ useDropMintStatus,
53
+ useMyDrops,
54
+ useOnChainDropState
55
+ };
56
+ //# sourceMappingURL=use-drops.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/use-drops.ts"],"sourcesContent":["\"use client\";\n\nimport useSWR from \"swr\";\nimport type { ApiCollection, ApiDropInfo, ApiDropState, ApiMeta, DropMintStatus } from \"@medialane/sdk\";\nimport type { MedialaneClient } from \"@medialane/sdk/starknet\";\nimport { useMedialaneClient } from \"./use-medialane-client.js\";\n\nexport function useDropCollections(getClient: () => MedialaneClient) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<{ data: ApiCollection[]; meta?: ApiMeta }>(\n \"drop-collections\",\n () => client.api.listCollections({ service: \"drop-collection\", hideEmpty: false, limit: 50 }),\n { revalidateOnFocus: false }\n );\n return { collections: data?.data ?? [], meta: data?.meta, isLoading, error, mutate };\n}\n\nexport function useMyDrops(getClient: () => MedialaneClient, owner: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiCollection[]>(\n owner ? `my-drops-${owner}` : null,\n async () => (await client.api.listCollections({ service: \"drop-collection\", owner: owner!, limit: 50 })).data ?? [],\n { revalidateOnFocus: false }\n );\n return { drops: data ?? [], isLoading, error, mutate };\n}\n\nexport function useDropMintStatus(getClient: () => MedialaneClient, collection: string | null, wallet: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<DropMintStatus>(\n collection && wallet ? `drop-mint-status-${collection}-${wallet}` : null,\n () => client.api.getDropMintStatus(collection!, wallet!),\n { revalidateOnFocus: false, shouldRetryOnError: false }\n );\n return { mintStatus: data ?? null, isLoading, error, mutate };\n}\n\nexport function useDropInfo(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading } = useSWR<ApiDropInfo | null>(\n contract ? `drop-info-${contract}` : null,\n () => client.api.getDropInfo(contract!),\n { revalidateOnFocus: false, shouldRetryOnError: false }\n );\n return { dropInfo: data ?? null, isLoading, error };\n}\n\nexport function useOnChainDropState(getClient: () => MedialaneClient, contract: string | null) {\n const client = useMedialaneClient(getClient);\n const { data, error, isLoading, mutate } = useSWR<ApiDropState>(\n contract ? `drop-onchain-${contract}` : null,\n () => client.api.getDropState(contract!),\n { revalidateOnFocus: false, refreshInterval: 30_000, shouldRetryOnError: false }\n );\n return { state: data ?? null, isLoading, error, mutate };\n}\n"],"mappings":";AAEA,OAAO,YAAY;AAGnB,SAAS,0BAA0B;AAE5B,SAAS,mBAAmB,WAAkC;AACnE,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC;AAAA,IACA,MAAM,OAAO,IAAI,gBAAgB,EAAE,SAAS,mBAAmB,WAAW,OAAO,OAAO,GAAG,CAAC;AAAA,IAC5F,EAAE,mBAAmB,MAAM;AAAA,EAC7B;AACA,SAAO,EAAE,aAAa,MAAM,QAAQ,CAAC,GAAG,MAAM,MAAM,MAAM,WAAW,OAAO,OAAO;AACrF;AAEO,SAAS,WAAW,WAAkC,OAAsB;AACjF,QAAM,SAAS,mBAAmB,SAAS;AAC3C,QAAM,EAAE,MAAM,OAAO,WAAW,OAAO,IAAI;AAAA,IACzC,QAAQ,YAAY,KAAK,KAAK;AAAA,IAC9B,aAAa,MAAM,OAAO,IAAI,gBA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