@soma-vertical-web/multi-lib 0.0.51 → 0.0.53
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/constants.d.ts +0 -2
- package/contexts/contexts/plp/PLPContext.d.ts +1 -1
- package/contexts/contexts/search/Facets.d.ts +1 -1
- package/contexts/index.d.ts +2 -2
- package/contexts/store/wishlist.d.ts +12 -0
- package/data/api/wishlist/products/index.d.ts +3 -0
- package/index-DfnS9D5I.mjs +354 -0
- package/index-WV5Gjz3i.js +1 -0
- package/index.js +13 -13
- package/index.mjs +2721 -2723
- package/package.json +1 -1
- package/types/constants.d.ts +1 -0
- package/types/contexts/contexts/plp.d.ts +2 -0
- package/types/contexts/contexts/search.d.ts +3 -1
- package/types/contexts/store/wishlist.d.ts +17 -0
package/constants.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ export declare const PLP_FILTERS_SORT: {
|
|
|
12
12
|
discount_desc: string;
|
|
13
13
|
name_asc: string;
|
|
14
14
|
};
|
|
15
|
-
default_option: string;
|
|
16
15
|
};
|
|
17
16
|
export declare const PDPShelfType: readonly ["whosawalsosaw", "whosawalsobought", "whoboughtalsobought", "accessories", "similars", "showtogether", "suggestions"];
|
|
18
17
|
export declare const FACET_CROSS_SELLING_MAP: {
|
|
@@ -23,7 +22,6 @@ export declare const FACET_CROSS_SELLING_MAP: {
|
|
|
23
22
|
readonly accessories: "accessories";
|
|
24
23
|
readonly suggestions: "suggestions";
|
|
25
24
|
};
|
|
26
|
-
export declare const SORT_OPTIONS: string[];
|
|
27
25
|
export declare const ObjectFitsDefault: readonly ["contain", "cover", "fill", "none"];
|
|
28
26
|
export declare const SEARCH_PAGE_DEFAULT_PAGINATION: {
|
|
29
27
|
nextPage: boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PLPContextProps, PLPProviderProps } from '../../../types/contexts/contexts/plp';
|
|
2
2
|
|
|
3
3
|
declare const PLPContext: import('react').Context<PLPContextProps>;
|
|
4
|
-
declare const PLPProvider: ({ children, slug, searchParams, collectionId, brand, itemsPerPage }: PLPProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
|
+
declare const PLPProvider: ({ children, slug, searchParams, collectionId, brand, itemsPerPage, PLP_SORT_DEFAULT }: PLPProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
declare const usePLPContext: () => PLPContextProps;
|
|
6
6
|
export { PLPContext, PLPProvider, usePLPContext };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FacetsContextProps, FacetsProviderProps } from '../../../types/contexts/contexts/search';
|
|
2
2
|
|
|
3
|
-
declare const FacetsProvider: ({ children, searchParams, forceUpdate, }: FacetsProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
declare const FacetsProvider: ({ children, searchParams, forceUpdate, PLP_SORT_DEFAULT }: FacetsProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const useFacetsContext: () => FacetsContextProps;
|
|
5
5
|
export { FacetsProvider, useFacetsContext };
|
package/contexts/index.d.ts
CHANGED
|
@@ -82,7 +82,7 @@ export declare const contexts: {
|
|
|
82
82
|
};
|
|
83
83
|
};
|
|
84
84
|
plp: {
|
|
85
|
-
provider: ({ children, slug, searchParams, collectionId, brand, itemsPerPage }: import('../types/contexts/contexts/plp').PLPProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
85
|
+
provider: ({ children, slug, searchParams, collectionId, brand, itemsPerPage, PLP_SORT_DEFAULT }: import('../types/contexts/contexts/plp').PLPProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
86
86
|
hook: () => import('../types/contexts/contexts/plp').PLPContextProps;
|
|
87
87
|
};
|
|
88
88
|
plpFilter: {
|
|
@@ -103,7 +103,7 @@ export declare const contexts: {
|
|
|
103
103
|
};
|
|
104
104
|
searchFacets: {
|
|
105
105
|
hook: () => import('../types/contexts/contexts/search').FacetsContextProps;
|
|
106
|
-
provider: ({ children, searchParams, forceUpdate, }: import('../types/contexts/contexts/search').FacetsProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
106
|
+
provider: ({ children, searchParams, forceUpdate, PLP_SORT_DEFAULT }: import('../types/contexts/contexts/search').FacetsProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
107
107
|
};
|
|
108
108
|
searchProducts: {
|
|
109
109
|
hook: () => import('../types/contexts/contexts/search').ProductsContextProps;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const useGetWishlistStore: () => string[];
|
|
2
|
+
export declare const useGetWishlistFeedbackStore: () => {
|
|
3
|
+
active: boolean;
|
|
4
|
+
action: "add" | "remove" | "";
|
|
5
|
+
};
|
|
6
|
+
export declare const useActionsWishlistStore: () => {
|
|
7
|
+
reset: () => void;
|
|
8
|
+
setValue: (value: import('../../types/contexts/store/wishlist').WishListStateValue) => void;
|
|
9
|
+
toggleProduct: (productId: string) => void;
|
|
10
|
+
updateList: (list: string[]) => void;
|
|
11
|
+
resetFeedback: () => void;
|
|
12
|
+
};
|
|
@@ -0,0 +1,354 @@
|
|
|
1
|
+
import { jsxs as y, Fragment as w, jsx as f } from "react/jsx-runtime";
|
|
2
|
+
import { Utils as N } from "@soma-vertical-web/core-components";
|
|
3
|
+
const h = (e, t = !0) => Intl.NumberFormat("pt-BR", {
|
|
4
|
+
style: "currency",
|
|
5
|
+
currency: "BRL",
|
|
6
|
+
minimumFractionDigits: t ? 2 : 0
|
|
7
|
+
}).format(e), O = ({ valueInCents: e, hasFree: t, freeTaxMessage: n }) => e === 0 ? t ? n : h(0) : h(e / 100), I = (e, t) => {
|
|
8
|
+
const [n, s] = e.split(t);
|
|
9
|
+
return { name: n.trim(), size: s ? s.trim() : "" };
|
|
10
|
+
}, P = (e, t) => {
|
|
11
|
+
if (!e)
|
|
12
|
+
return {};
|
|
13
|
+
const [n, s] = e.split(t);
|
|
14
|
+
return { color: n == null ? void 0 : n.trim(), size: s == null ? void 0 : s.trim() };
|
|
15
|
+
}, R = (e, t = "tamanho") => {
|
|
16
|
+
if (e.additionalProperty) {
|
|
17
|
+
const [n] = e.additionalProperty;
|
|
18
|
+
return n != null && n.name ? n.name.toLocaleLowerCase() === t ? n.value : e.name : "";
|
|
19
|
+
}
|
|
20
|
+
return e.name;
|
|
21
|
+
}, F = (e, t) => e.replace(t, "").trim(), z = (e) => e.replace(/\//g, ""), C = ({ items: e, NAME_SPLIT_SYMBOL: t }) => {
|
|
22
|
+
const n = {
|
|
23
|
+
price: 0,
|
|
24
|
+
listPrice: 0,
|
|
25
|
+
installments: {
|
|
26
|
+
count: 0,
|
|
27
|
+
value: 0
|
|
28
|
+
}
|
|
29
|
+
}, s = (r, i) => {
|
|
30
|
+
var m;
|
|
31
|
+
i && (i.sellerId = r.sellerId, i.sellerName = r.sellerName, i.available = !0, i.isSellerDefault = r.sellerDefault);
|
|
32
|
+
const {
|
|
33
|
+
Price: c,
|
|
34
|
+
ListPrice: p,
|
|
35
|
+
PaymentOptions: { installmentOptions: d }
|
|
36
|
+
} = r.commertialOffer;
|
|
37
|
+
n.price = c, n.listPrice = p;
|
|
38
|
+
const l = (m = d == null ? void 0 : d[0]) == null ? void 0 : m.installments;
|
|
39
|
+
if (l) {
|
|
40
|
+
const { count: u, value: g } = l[l.length - 1];
|
|
41
|
+
n.installments = {
|
|
42
|
+
count: u,
|
|
43
|
+
value: g / 100
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
let a = !0;
|
|
48
|
+
const o = e.reduce((r, i) => {
|
|
49
|
+
var d;
|
|
50
|
+
const c = {
|
|
51
|
+
name: i.name,
|
|
52
|
+
sku: i.itemId,
|
|
53
|
+
value: ((d = i.Tamanho) == null ? void 0 : d[0]) ?? I(i.nameComplete ?? i.name, t).size,
|
|
54
|
+
available: !1,
|
|
55
|
+
sellerId: "",
|
|
56
|
+
sellerName: "",
|
|
57
|
+
isSellerDefault: !1
|
|
58
|
+
}, p = i.sellers.filter((l) => (l.sellerDefault && l.commertialOffer.IsAvailable && (c.available = !0, s(l, c)), l.commertialOffer.IsAvailable));
|
|
59
|
+
return !c.isSellerDefault && p.length > 0 && (c.available = !0, s(p[0], {
|
|
60
|
+
...c,
|
|
61
|
+
sellerId: p[0].sellerId,
|
|
62
|
+
sellerName: p[0].sellerName
|
|
63
|
+
})), c.available === !1 && (a = !1), r.push(c), r;
|
|
64
|
+
}, []);
|
|
65
|
+
return {
|
|
66
|
+
...n,
|
|
67
|
+
sizes: o,
|
|
68
|
+
allSizesAvailable: a
|
|
69
|
+
};
|
|
70
|
+
}, j = (e) => e ? !e.offers.offers.find(({ quantity: t = 0 }) => t > 0) : !1, T = (e, t) => {
|
|
71
|
+
const n = e.find(
|
|
72
|
+
(s) => s.availability.includes("InStock") && s.quantity && s.listPrice > 0 && s.seller.identifier === t
|
|
73
|
+
);
|
|
74
|
+
return n || e.find(
|
|
75
|
+
(s) => s.availability.includes("InStock") && s.quantity && s.listPrice > 0
|
|
76
|
+
);
|
|
77
|
+
}, A = ({ images: e, TEXTURE_IMAGE: t }) => e.find((n) => t.includes(n.imageLabel)) ?? e[0], D = (e, t) => {
|
|
78
|
+
const n = /\/ids\/(\d+)\//, s = e.match(n);
|
|
79
|
+
return s ? e.replace(
|
|
80
|
+
`/${s[1]}/`,
|
|
81
|
+
`/${s[1]}-${t.width}-${t.height}/`
|
|
82
|
+
) : e;
|
|
83
|
+
}, B = (e, t) => {
|
|
84
|
+
const n = /\/ids\/(\d+)-(\d+)-(\d+)\//, s = e.match(n);
|
|
85
|
+
return s ? e.replace(
|
|
86
|
+
`/${s[1]}-${s[2]}-${s[3]}/`,
|
|
87
|
+
`/${s[1]}-${t.width}-${t.height}/`
|
|
88
|
+
) : e;
|
|
89
|
+
}, x = ({
|
|
90
|
+
images: e,
|
|
91
|
+
label: t
|
|
92
|
+
}) => {
|
|
93
|
+
const n = e.filter(
|
|
94
|
+
(s) => s.keywords === t.first || s.keywords === t.second || s.alternateName === t.first || s.alternateName === t.second
|
|
95
|
+
);
|
|
96
|
+
return n.length === 0 ? [e[0]] : n;
|
|
97
|
+
}, E = (e) => {
|
|
98
|
+
const [t, n] = e.split("/").map(Number);
|
|
99
|
+
if (Number.isNaN(t) || Number.isNaN(n))
|
|
100
|
+
throw new Error("[ERROR ASPECT RATIO IMAGE]: Invalid aspect ratio format");
|
|
101
|
+
return n / t;
|
|
102
|
+
}, L = (e, t, n) => {
|
|
103
|
+
t && (e ? (t.getAttribute("src") || (t.src = n ?? ""), t.play()) : t.pause());
|
|
104
|
+
}, ee = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
105
|
+
__proto__: null,
|
|
106
|
+
disableSKU: j,
|
|
107
|
+
formatPriceToCurrency: h,
|
|
108
|
+
freightParsePrice: O,
|
|
109
|
+
getAspectRatio: E,
|
|
110
|
+
getColorAndSizeFromSkuName: P,
|
|
111
|
+
getFirstImages: x,
|
|
112
|
+
getProductNameWithoutSku: F,
|
|
113
|
+
getSKUName: R,
|
|
114
|
+
getSkuInfos: C,
|
|
115
|
+
getThumbImage: A,
|
|
116
|
+
getValidOffer: T,
|
|
117
|
+
removeSlashes: z,
|
|
118
|
+
resizingImg: D,
|
|
119
|
+
setVideoPlay: L,
|
|
120
|
+
splitNameAndSizeFromFullName: I,
|
|
121
|
+
updatedResizedImg: B
|
|
122
|
+
}, Symbol.toStringTag, { value: "Module" })), b = "fuzzy", _ = "operator", U = (e) => ({
|
|
123
|
+
isDepartment: e != null && e.length ? e[0].key === "category-1" : !1
|
|
124
|
+
}), te = (e, t) => {
|
|
125
|
+
const n = decodeURIComponent(t ?? "").slice(1).split("/");
|
|
126
|
+
return e.map((s) => {
|
|
127
|
+
if (s.key === "category-2" && s.__typename === "FacetBoolean") {
|
|
128
|
+
const a = s.values;
|
|
129
|
+
return {
|
|
130
|
+
...s,
|
|
131
|
+
values: a.filter(
|
|
132
|
+
(o) => !n.find(
|
|
133
|
+
(r) => r.toLowerCase() === o.value || r.toLowerCase() === o.name.toLowerCase()
|
|
134
|
+
)
|
|
135
|
+
)
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
return s;
|
|
139
|
+
});
|
|
140
|
+
}, S = (e, t) => t ? e === "category-1" : !1, M = (e) => e.key === "operator" && (e.value === "and" || e.value === "or"), q = (e) => e.type === "TEXT", K = (e) => e.key === "fuzzy" && (e.value === "0" || e.value === "1" || e.value === "auto"), V = (e) => {
|
|
141
|
+
const { key: t, name: n, values: s } = e;
|
|
142
|
+
return {
|
|
143
|
+
__typename: "FacetBoolean",
|
|
144
|
+
key: t,
|
|
145
|
+
label: n,
|
|
146
|
+
values: s.slice().sort((a, o) => a.name.localeCompare(o.name))
|
|
147
|
+
};
|
|
148
|
+
}, Y = ({ key: e, values: t }) => ({
|
|
149
|
+
__typename: "FacetRange",
|
|
150
|
+
key: e,
|
|
151
|
+
values: t
|
|
152
|
+
}), ne = (e, t, n) => {
|
|
153
|
+
if (!(e instanceof Object) || !("facets" in e))
|
|
154
|
+
return [];
|
|
155
|
+
const { facets: s = [] } = e, a = t != null && t.length ? t[0].key === "category-1" : !1;
|
|
156
|
+
return s.filter(
|
|
157
|
+
(r) => !n || !S(r.key, a)
|
|
158
|
+
).map(
|
|
159
|
+
(r) => q(r) ? V(r) : Y(r)
|
|
160
|
+
);
|
|
161
|
+
}, se = (e, t) => {
|
|
162
|
+
const n = e.find(({ key: a }) => a === b) ?? null, s = e.find(({ key: a }) => a === _) ?? null;
|
|
163
|
+
n && K(n) && t.append(b, n.value), s && M(s) && t.append(_, s.value);
|
|
164
|
+
}, J = (e) => e.map((t) => {
|
|
165
|
+
const [n, s] = t.split("/");
|
|
166
|
+
return { key: n, value: s };
|
|
167
|
+
}), re = (e, t) => {
|
|
168
|
+
const n = decodeURIComponent(t ?? "").slice(1).split("/"), s = e.filter(({ value: o }) => !n.includes(decodeURIComponent(o))).map((o) => ({
|
|
169
|
+
...o,
|
|
170
|
+
value: decodeURIComponent(o.value)
|
|
171
|
+
})), { isDepartment: a } = U(s);
|
|
172
|
+
return s == null ? void 0 : s.filter((o) => !S(o.key, a));
|
|
173
|
+
}, ae = ({ pathname: e, searchParams: t }, n) => {
|
|
174
|
+
const s = t.get("sort") ?? "", a = t.get("query") ?? null, o = parseInt(t.get("page") ?? "1", 10);
|
|
175
|
+
return {
|
|
176
|
+
sort: s,
|
|
177
|
+
facets: J(n),
|
|
178
|
+
term: a,
|
|
179
|
+
base: a ? "" : e,
|
|
180
|
+
page: o
|
|
181
|
+
};
|
|
182
|
+
}, oe = (e) => {
|
|
183
|
+
const t = new URLSearchParams();
|
|
184
|
+
return Object.entries(e).forEach(([n, s]) => {
|
|
185
|
+
Array.isArray(s) ? s.forEach((a) => t.append(n, a)) : s !== void 0 && t.append(n, s);
|
|
186
|
+
}), t;
|
|
187
|
+
}, v = {
|
|
188
|
+
"responsive-mobile-flex": "_responsive-mobile-flex_t5bry_2",
|
|
189
|
+
"responsive-desktop-flex": "_responsive-desktop-flex_t5bry_13",
|
|
190
|
+
"responsive-mobile-block": "_responsive-mobile-block_t5bry_24",
|
|
191
|
+
"responsive-desktop-block": "_responsive-desktop-block_t5bry_35"
|
|
192
|
+
}, $ = {}, ie = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
193
|
+
__proto__: null,
|
|
194
|
+
default: $
|
|
195
|
+
}, Symbol.toStringTag, { value: "Module" })), le = ({
|
|
196
|
+
children: e,
|
|
197
|
+
data: t,
|
|
198
|
+
SectionZone: n,
|
|
199
|
+
className: s
|
|
200
|
+
}) => {
|
|
201
|
+
var d, l;
|
|
202
|
+
const a = ((d = t == null ? void 0 : t.filter((m) => {
|
|
203
|
+
var u, g;
|
|
204
|
+
return ((g = (u = m.config) == null ? void 0 : u.responsive) == null ? void 0 : g.deviceType) === "mobile";
|
|
205
|
+
})[0]) == null ? void 0 : d.sections) || [], o = ((l = t == null ? void 0 : t.filter((m) => {
|
|
206
|
+
var u, g;
|
|
207
|
+
return ((g = (u = m.config) == null ? void 0 : u.responsive) == null ? void 0 : g.deviceType) === "desktop";
|
|
208
|
+
})[0]) == null ? void 0 : l.sections) || [], r = a.slice(0, 1), i = a.slice(1, a.length), c = o.slice(0, 1), p = o.slice(1, o.length);
|
|
209
|
+
return /* @__PURE__ */ y(w, { children: [
|
|
210
|
+
/* @__PURE__ */ y("div", { className: s, children: [
|
|
211
|
+
/* @__PURE__ */ f("div", { className: v["responsive-mobile-flex"], children: /* @__PURE__ */ f(n, { data: r ?? [] }) }),
|
|
212
|
+
/* @__PURE__ */ f("div", { className: v["responsive-desktop-flex"], children: /* @__PURE__ */ f(n, { data: c ?? [] }) })
|
|
213
|
+
] }),
|
|
214
|
+
e,
|
|
215
|
+
/* @__PURE__ */ f("div", { className: v["responsive-mobile-flex"], children: /* @__PURE__ */ f(n, { data: i ?? [] }) }),
|
|
216
|
+
/* @__PURE__ */ f("div", { className: v["responsive-desktop-flex"], children: /* @__PURE__ */ f(n, { data: p ?? [] }) }),
|
|
217
|
+
/* @__PURE__ */ f(N.Divider, {})
|
|
218
|
+
] });
|
|
219
|
+
};
|
|
220
|
+
async function W({ contentType: e, storeId: t, CMS_PROJECT_NAME: n, NextCookies: s }) {
|
|
221
|
+
const a = await k({
|
|
222
|
+
contentType: e,
|
|
223
|
+
storeId: t,
|
|
224
|
+
CMS_PROJECT_NAME: n,
|
|
225
|
+
NextCookies: s
|
|
226
|
+
});
|
|
227
|
+
if (a.status === 200) {
|
|
228
|
+
const o = {
|
|
229
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
230
|
+
contentType: e,
|
|
231
|
+
data: a.data
|
|
232
|
+
};
|
|
233
|
+
console.log("Resultado da chamada:", a);
|
|
234
|
+
const r = `backup-${e}-${Date.now()}.json`;
|
|
235
|
+
return await $.writeFile(
|
|
236
|
+
`./backups/${r}`,
|
|
237
|
+
JSON.stringify(o, null, 2),
|
|
238
|
+
"utf-8"
|
|
239
|
+
), { success: !0, fileName: r };
|
|
240
|
+
}
|
|
241
|
+
return { success: !1, error: a.error || "No data to backup" };
|
|
242
|
+
}
|
|
243
|
+
async function G(e) {
|
|
244
|
+
return W(e);
|
|
245
|
+
}
|
|
246
|
+
async function H({
|
|
247
|
+
contentType: e,
|
|
248
|
+
documentId: t,
|
|
249
|
+
versionId: n,
|
|
250
|
+
storeId: s,
|
|
251
|
+
CMS_PROJECT_NAME: a
|
|
252
|
+
}) {
|
|
253
|
+
const o = t && t.length ? `/${t}` : "", r = n && n.length ? `?versionId=${n}` : "";
|
|
254
|
+
return fetch(
|
|
255
|
+
`https://${s}.myvtex.com/_v/cms/api/${a}/${e}${o}${r}`,
|
|
256
|
+
{ cache: "no-cache" }
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
async function X({
|
|
260
|
+
contentType: e,
|
|
261
|
+
documents: t,
|
|
262
|
+
NextCookies: n,
|
|
263
|
+
previewId: s,
|
|
264
|
+
CMS_PROJECT_NAME: a,
|
|
265
|
+
storeId: o
|
|
266
|
+
}) {
|
|
267
|
+
var i;
|
|
268
|
+
const r = JSON.parse(
|
|
269
|
+
s ?? ((i = n == null ? void 0 : n().get("cms_preview_data")) == null ? void 0 : i.value) ?? "{}"
|
|
270
|
+
);
|
|
271
|
+
if (r && (r == null ? void 0 : r.contentType) === e) {
|
|
272
|
+
const c = r.documentId && r.documentId.length ? `/${r.documentId}` : "", p = r != null && r.versionId && (r != null && r.versionId.length) ? `?versionId=${r == null ? void 0 : r.versionId}` : "", l = await (await fetch(
|
|
273
|
+
`https://${o}.myvtex.com/_v/cms/api/${a}/${e}${c}${p}`,
|
|
274
|
+
{ cache: "no-store" }
|
|
275
|
+
)).json(), m = t.filter(
|
|
276
|
+
(u) => l.id !== u.documentId
|
|
277
|
+
);
|
|
278
|
+
return m.unshift(l), m;
|
|
279
|
+
}
|
|
280
|
+
return t;
|
|
281
|
+
}
|
|
282
|
+
async function k({
|
|
283
|
+
contentType: e,
|
|
284
|
+
NextCookies: t,
|
|
285
|
+
CMS_PROJECT_NAME: n,
|
|
286
|
+
storeId: s,
|
|
287
|
+
previewId: a
|
|
288
|
+
}) {
|
|
289
|
+
var d, l;
|
|
290
|
+
const o = JSON.parse(
|
|
291
|
+
a ?? ((d = t == null ? void 0 : t().get("cms_preview_data")) == null ? void 0 : d.value) ?? "{}"
|
|
292
|
+
), r = [];
|
|
293
|
+
let i = 1, c = 0, p = !0;
|
|
294
|
+
try {
|
|
295
|
+
do {
|
|
296
|
+
const u = await (await fetch(
|
|
297
|
+
`https://${s}.myvtex.com/_v/cms/api/${n}/${e}?page=${i}`
|
|
298
|
+
)).json();
|
|
299
|
+
i === 1 && (c = u.totalItems), (l = u == null ? void 0 : u.data) != null && l.length && r.push(...u.data), p = u.hasNextPage, i++;
|
|
300
|
+
} while (p && r.length < c);
|
|
301
|
+
if (o.previewMode && r.length) {
|
|
302
|
+
const m = await X({
|
|
303
|
+
contentType: e,
|
|
304
|
+
documents: r,
|
|
305
|
+
NextCookies: t,
|
|
306
|
+
CMS_PROJECT_NAME: n,
|
|
307
|
+
storeId: s
|
|
308
|
+
});
|
|
309
|
+
return {
|
|
310
|
+
status: m.length > 0 ? 200 : 404,
|
|
311
|
+
data: m ?? []
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
return {
|
|
315
|
+
status: r.length ? 200 : 404,
|
|
316
|
+
data: r
|
|
317
|
+
};
|
|
318
|
+
} catch (m) {
|
|
319
|
+
return { status: "error", data: [], error: m };
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
const ce = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
323
|
+
__proto__: null,
|
|
324
|
+
cmsBackup: G,
|
|
325
|
+
getCMSContentType: H,
|
|
326
|
+
getContentType: k
|
|
327
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
328
|
+
export {
|
|
329
|
+
le as S,
|
|
330
|
+
ie as _,
|
|
331
|
+
C as a,
|
|
332
|
+
A as b,
|
|
333
|
+
oe as c,
|
|
334
|
+
R as d,
|
|
335
|
+
j as e,
|
|
336
|
+
ee as f,
|
|
337
|
+
P as g,
|
|
338
|
+
h,
|
|
339
|
+
O as i,
|
|
340
|
+
T as j,
|
|
341
|
+
x as k,
|
|
342
|
+
L as l,
|
|
343
|
+
D as m,
|
|
344
|
+
k as n,
|
|
345
|
+
se as o,
|
|
346
|
+
ae as p,
|
|
347
|
+
ne as q,
|
|
348
|
+
v as r,
|
|
349
|
+
I as s,
|
|
350
|
+
te as t,
|
|
351
|
+
B as u,
|
|
352
|
+
re as v,
|
|
353
|
+
ce as w
|
|
354
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const f=require("react/jsx-runtime"),T=require("@soma-vertical-web/core-components"),v=(e,t=!0)=>Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:t?2:0}).format(e),_=({valueInCents:e,hasFree:t,freeTaxMessage:n})=>e===0?t?n:v(0):v(e/100),y=(e,t)=>{const[n,r]=e.split(t);return{name:n.trim(),size:r?r.trim():""}},$=(e,t)=>{if(!e)return{};const[n,r]=e.split(t);return{color:n==null?void 0:n.trim(),size:r==null?void 0:r.trim()}},k=(e,t="tamanho")=>{if(e.additionalProperty){const[n]=e.additionalProperty;return n!=null&&n.name?n.name.toLocaleLowerCase()===t?n.value:e.name:""}return e.name},A=(e,t)=>e.replace(t,"").trim(),B=e=>e.replace(/\//g,""),N=({items:e,NAME_SPLIT_SYMBOL:t})=>{const n={price:0,listPrice:0,installments:{count:0,value:0}},r=(s,i)=>{var m;i&&(i.sellerId=s.sellerId,i.sellerName=s.sellerName,i.available=!0,i.isSellerDefault=s.sellerDefault);const{Price:l,ListPrice:d,PaymentOptions:{installmentOptions:p}}=s.commertialOffer;n.price=l,n.listPrice=d;const c=(m=p==null?void 0:p[0])==null?void 0:m.installments;if(c){const{count:u,value:g}=c[c.length-1];n.installments={count:u,value:g/100}}};let o=!0;const a=e.reduce((s,i)=>{var p;const l={name:i.name,sku:i.itemId,value:((p=i.Tamanho)==null?void 0:p[0])??y(i.nameComplete??i.name,t).size,available:!1,sellerId:"",sellerName:"",isSellerDefault:!1},d=i.sellers.filter(c=>(c.sellerDefault&&c.commertialOffer.IsAvailable&&(l.available=!0,r(c,l)),c.commertialOffer.IsAvailable));return!l.isSellerDefault&&d.length>0&&(l.available=!0,r(d[0],{...l,sellerId:d[0].sellerId,sellerName:d[0].sellerName})),l.available===!1&&(o=!1),s.push(l),s},[]);return{...n,sizes:a,allSizesAvailable:o}},P=e=>e?!e.offers.offers.find(({quantity:t=0})=>t>0):!1,w=(e,t)=>{const n=e.find(r=>r.availability.includes("InStock")&&r.quantity&&r.listPrice>0&&r.seller.identifier===t);return n||e.find(r=>r.availability.includes("InStock")&&r.quantity&&r.listPrice>0)},F=({images:e,TEXTURE_IMAGE:t})=>e.find(n=>t.includes(n.imageLabel))??e[0],j=(e,t)=>{const n=/\/ids\/(\d+)\//,r=e.match(n);return r?e.replace(`/${r[1]}/`,`/${r[1]}-${t.width}-${t.height}/`):e},O=(e,t)=>{const n=/\/ids\/(\d+)-(\d+)-(\d+)\//,r=e.match(n);return r?e.replace(`/${r[1]}-${r[2]}-${r[3]}/`,`/${r[1]}-${t.width}-${t.height}/`):e},x=({images:e,label:t})=>{const n=e.filter(r=>r.keywords===t.first||r.keywords===t.second||r.alternateName===t.first||r.alternateName===t.second);return n.length===0?[e[0]]:n},D=e=>{const[t,n]=e.split("/").map(Number);if(Number.isNaN(t)||Number.isNaN(n))throw new Error("[ERROR ASPECT RATIO IMAGE]: Invalid aspect ratio format");return n/t},C=(e,t,n)=>{t&&(e?(t.getAttribute("src")||(t.src=n??""),t.play()):t.pause())},U=Object.freeze(Object.defineProperty({__proto__:null,disableSKU:P,formatPriceToCurrency:v,freightParsePrice:_,getAspectRatio:D,getColorAndSizeFromSkuName:$,getFirstImages:x,getProductNameWithoutSku:A,getSKUName:k,getSkuInfos:N,getThumbImage:F,getValidOffer:w,removeSlashes:B,resizingImg:j,setVideoPlay:C,splitNameAndSizeFromFullName:y,updatedResizedImg:O},Symbol.toStringTag,{value:"Module"})),S="fuzzy",I="operator",E=e=>({isDepartment:e!=null&&e.length?e[0].key==="category-1":!1}),L=(e,t)=>{const n=decodeURIComponent(t??"").slice(1).split("/");return e.map(r=>{if(r.key==="category-2"&&r.__typename==="FacetBoolean"){const o=r.values;return{...r,values:o.filter(a=>!n.find(s=>s.toLowerCase()===a.value||s.toLowerCase()===a.name.toLowerCase()))}}return r})},R=(e,t)=>t?e==="category-1":!1,M=e=>e.key==="operator"&&(e.value==="and"||e.value==="or"),K=e=>e.type==="TEXT",V=e=>e.key==="fuzzy"&&(e.value==="0"||e.value==="1"||e.value==="auto"),q=e=>{const{key:t,name:n,values:r}=e;return{__typename:"FacetBoolean",key:t,label:n,values:r.slice().sort((o,a)=>o.name.localeCompare(a.name))}},Y=({key:e,values:t})=>({__typename:"FacetRange",key:e,values:t}),H=(e,t,n)=>{if(!(e instanceof Object)||!("facets"in e))return[];const{facets:r=[]}=e,o=t!=null&&t.length?t[0].key==="category-1":!1;return r.filter(s=>!n||!R(s.key,o)).map(s=>K(s)?q(s):Y(s))},J=(e,t)=>{const n=e.find(({key:o})=>o===S)??null,r=e.find(({key:o})=>o===I)??null;n&&V(n)&&t.append(S,n.value),r&&M(r)&&t.append(I,r.value)},W=e=>e.map(t=>{const[n,r]=t.split("/");return{key:n,value:r}}),G=(e,t)=>{const n=decodeURIComponent(t??"").slice(1).split("/"),r=e.filter(({value:a})=>!n.includes(decodeURIComponent(a))).map(a=>({...a,value:decodeURIComponent(a.value)})),{isDepartment:o}=E(r);return r==null?void 0:r.filter(a=>!R(a.key,o))},X=({pathname:e,searchParams:t},n)=>{const r=t.get("sort")??"",o=t.get("query")??null,a=parseInt(t.get("page")??"1",10);return{sort:r,facets:W(n),term:o,base:o?"":e,page:a}},Q=e=>{const t=new URLSearchParams;return Object.entries(e).forEach(([n,r])=>{Array.isArray(r)?r.forEach(o=>t.append(n,o)):r!==void 0&&t.append(n,r)}),t},h={"responsive-mobile-flex":"_responsive-mobile-flex_t5bry_2","responsive-desktop-flex":"_responsive-desktop-flex_t5bry_13","responsive-mobile-block":"_responsive-mobile-block_t5bry_24","responsive-desktop-block":"_responsive-desktop-block_t5bry_35"},z={},Z=Object.freeze(Object.defineProperty({__proto__:null,default:z},Symbol.toStringTag,{value:"Module"})),ee=({children:e,data:t,SectionZone:n,className:r})=>{var p,c;const o=((p=t==null?void 0:t.filter(m=>{var u,g;return((g=(u=m.config)==null?void 0:u.responsive)==null?void 0:g.deviceType)==="mobile"})[0])==null?void 0:p.sections)||[],a=((c=t==null?void 0:t.filter(m=>{var u,g;return((g=(u=m.config)==null?void 0:u.responsive)==null?void 0:g.deviceType)==="desktop"})[0])==null?void 0:c.sections)||[],s=o.slice(0,1),i=o.slice(1,o.length),l=a.slice(0,1),d=a.slice(1,a.length);return f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:r,children:[f.jsx("div",{className:h["responsive-mobile-flex"],children:f.jsx(n,{data:s??[]})}),f.jsx("div",{className:h["responsive-desktop-flex"],children:f.jsx(n,{data:l??[]})})]}),e,f.jsx("div",{className:h["responsive-mobile-flex"],children:f.jsx(n,{data:i??[]})}),f.jsx("div",{className:h["responsive-desktop-flex"],children:f.jsx(n,{data:d??[]})}),f.jsx(T.Utils.Divider,{})]})};async function te({contentType:e,storeId:t,CMS_PROJECT_NAME:n,NextCookies:r}){const o=await b({contentType:e,storeId:t,CMS_PROJECT_NAME:n,NextCookies:r});if(o.status===200){const a={timestamp:new Date().toISOString(),contentType:e,data:o.data};console.log("Resultado da chamada:",o);const s=`backup-${e}-${Date.now()}.json`;return await z.writeFile(`./backups/${s}`,JSON.stringify(a,null,2),"utf-8"),{success:!0,fileName:s}}return{success:!1,error:o.error||"No data to backup"}}async function ne(e){return te(e)}async function re({contentType:e,documentId:t,versionId:n,storeId:r,CMS_PROJECT_NAME:o}){const a=t&&t.length?`/${t}`:"",s=n&&n.length?`?versionId=${n}`:"";return fetch(`https://${r}.myvtex.com/_v/cms/api/${o}/${e}${a}${s}`,{cache:"no-cache"})}async function se({contentType:e,documents:t,NextCookies:n,previewId:r,CMS_PROJECT_NAME:o,storeId:a}){var i;const s=JSON.parse(r??((i=n==null?void 0:n().get("cms_preview_data"))==null?void 0:i.value)??"{}");if(s&&(s==null?void 0:s.contentType)===e){const l=s.documentId&&s.documentId.length?`/${s.documentId}`:"",d=s!=null&&s.versionId&&(s!=null&&s.versionId.length)?`?versionId=${s==null?void 0:s.versionId}`:"",c=await(await fetch(`https://${a}.myvtex.com/_v/cms/api/${o}/${e}${l}${d}`,{cache:"no-store"})).json(),m=t.filter(u=>c.id!==u.documentId);return m.unshift(c),m}return t}async function b({contentType:e,NextCookies:t,CMS_PROJECT_NAME:n,storeId:r,previewId:o}){var p,c;const a=JSON.parse(o??((p=t==null?void 0:t().get("cms_preview_data"))==null?void 0:p.value)??"{}"),s=[];let i=1,l=0,d=!0;try{do{const u=await(await fetch(`https://${r}.myvtex.com/_v/cms/api/${n}/${e}?page=${i}`)).json();i===1&&(l=u.totalItems),(c=u==null?void 0:u.data)!=null&&c.length&&s.push(...u.data),d=u.hasNextPage,i++}while(d&&s.length<l);if(a.previewMode&&s.length){const m=await se({contentType:e,documents:s,NextCookies:t,CMS_PROJECT_NAME:n,storeId:r});return{status:m.length>0?200:404,data:m??[]}}return{status:s.length?200:404,data:s}}catch(m){return{status:"error",data:[],error:m}}}const oe=Object.freeze(Object.defineProperty({__proto__:null,cmsBackup:ne,getCMSContentType:re,getContentType:b},Symbol.toStringTag,{value:"Module"}));exports.SearchPageScreening=ee;exports.__viteBrowserExternal=Z;exports.addSearchParamsFacets=J;exports.cms=oe;exports.convertSearchParams=Q;exports.disableSKU=P;exports.filterNonCategorySelected=L;exports.filterNonRootFacets=G;exports.formatPriceToCurrency=v;exports.formattedFacets=H;exports.freightParsePrice=_;exports.getColorAndSizeFromSkuName=$;exports.getContentType=b;exports.getFirstImages=x;exports.getSKUName=k;exports.getSkuInfos=N;exports.getThumbImage=F;exports.getValidOffer=w;exports.parseSearchState=X;exports.productHelpers=U;exports.resizingImg=j;exports.responsive=h;exports.setVideoPlay=C;exports.splitNameAndSizeFromFullName=y;exports.updatedResizedImg=O;
|