@soma-vertical-web/multi-lib 0.0.73 → 0.0.75

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.
@@ -0,0 +1,18 @@
1
+ import { ErrorInfo, PropsWithChildren, ReactNode, Component } from 'react';
2
+
3
+ interface ErrorBoundaryCMSProps extends PropsWithChildren {
4
+ debugger?: boolean;
5
+ name: string;
6
+ fallback?: ReactNode | null;
7
+ }
8
+ interface ErrorBoundaryState {
9
+ hasError: boolean;
10
+ error: unknown | null;
11
+ }
12
+ declare class ErrorBoundary extends Component<ErrorBoundaryCMSProps, ErrorBoundaryState> {
13
+ state: ErrorBoundaryState;
14
+ static getDerivedStateFromError(): ErrorBoundaryState;
15
+ componentDidCatch(error: unknown, errorInfo: ErrorInfo): void;
16
+ render(): ReactNode;
17
+ }
18
+ export default ErrorBoundary;
@@ -1,6 +1,6 @@
1
1
  import { CartContextProps, CartProviderProps } from '../../../types/contexts/store/cart';
2
2
 
3
3
  declare const CartContext: import('react').Context<CartContextProps>;
4
- declare const CartProvider: ({ children, CARTPROVIDER_MESSAGE_PRODUCT_REMOVE, ...props }: CartProviderProps) => import("react/jsx-runtime").JSX.Element;
4
+ declare const CartProvider: ({ children, SELLER_CODE_VALIDATION_KEYS, CARTPROVIDER_MESSAGE_PRODUCT_REMOVE, ...props }: CartProviderProps) => import("react/jsx-runtime").JSX.Element;
5
5
  declare const useCartContext: () => CartContextProps;
6
6
  export { CartContext, CartProvider, useCartContext };
@@ -14,6 +14,7 @@ export declare const useFlagsAndTags: () => {
14
14
  institucional: {
15
15
  items: import('../../../types/cms/ContentTypes/FlagsAndTags').FlagTagWithCluster[];
16
16
  };
17
+ flagDiscount: import('../../../types/cms/ContentTypes/FlagsAndTags').FlagDiscount;
17
18
  flagCart: {
18
19
  flagHeader: import('../../../types/cms/ContentTypes/FlagsAndTags').CommonFlagType;
19
20
  flagTotal: string;
@@ -4,7 +4,7 @@ import { ShippingOption, ShippingData } from '../../types/data/api/checkout/orde
4
4
  declare const useOperations: () => {
5
5
  addCoupon: (orderFormId: string, coupon: string) => Promise<any>;
6
6
  addItem: (orderFormId: string, items: CartItemStore[], item: AddToCart | AddToCart[]) => Promise<any>;
7
- addSellerCode: (orderFormId: string, code: string) => Promise<any>;
7
+ addSellerCode: (orderFormId: string, code: string, keys?: Record<string, string>) => Promise<any>;
8
8
  addMarketingData: (orderFormId: string, marketingData: any) => Promise<any>;
9
9
  giftItem: (orderFormId: string, id: string, itemIndex: number, remove?: boolean) => Promise<any>;
10
10
  emptyCart: (orderFormId: string) => Promise<any>;
@@ -13,7 +13,7 @@ export declare const contexts: {
13
13
  };
14
14
  cart: {
15
15
  hook: () => import('../types/contexts/store/cart').CartContextProps;
16
- provider: ({ children, CARTPROVIDER_MESSAGE_PRODUCT_REMOVE, ...props }: import('../types/contexts/store/cart').CartProviderProps) => import("react/jsx-runtime").JSX.Element;
16
+ provider: ({ children, SELLER_CODE_VALIDATION_KEYS, CARTPROVIDER_MESSAGE_PRODUCT_REMOVE, ...props }: import('../types/contexts/store/cart').CartProviderProps) => import("react/jsx-runtime").JSX.Element;
17
17
  };
18
18
  cms: {
19
19
  FlagsAndTags: {
@@ -28,6 +28,7 @@ export declare const contexts: {
28
28
  institucional: {
29
29
  items: import('../types/cms/ContentTypes/FlagsAndTags').FlagTagWithCluster[];
30
30
  };
31
+ flagDiscount: import('../types/cms/ContentTypes/FlagsAndTags').FlagDiscount;
31
32
  flagCart: {
32
33
  flagHeader: import('../types/cms/ContentTypes/FlagsAndTags').CommonFlagType;
33
34
  flagTotal: string;
@@ -2,3 +2,4 @@ import { ParsePriceProps } from '../../../types/data/helpers/index';
2
2
 
3
3
  export declare const formatPriceToCurrency: (value: number, hasDecimal?: boolean) => string;
4
4
  export declare const freightParsePrice: ({ valueInCents, hasFree, freeTaxMessage }: ParsePriceProps) => string;
5
+ export declare const getDiscountPercent: (listPrice: number, price: number) => number;
@@ -0,0 +1,421 @@
1
+ import { jsxs as g, Fragment as $, jsx as p } from "react/jsx-runtime";
2
+ import { Utils as S } from "@soma-vertical-web/core-components";
3
+ const b = (e, t = !0) => Intl.NumberFormat("pt-BR", {
4
+ style: "currency",
5
+ currency: "BRL",
6
+ minimumFractionDigits: t ? 2 : 0
7
+ }).format(e), R = ({ valueInCents: e, hasFree: t, freeTaxMessage: n }) => e === 0 ? t ? n : b(0) : b(e / 100), T = (e, t) => {
8
+ const s = (e - t) * 100 / e;
9
+ return Math.floor(s);
10
+ }, y = (e, t) => {
11
+ const [n, s] = e.split(t);
12
+ return { name: n.trim(), size: s ? s.trim() : "" };
13
+ }, C = (e, t) => {
14
+ if (!e)
15
+ return {};
16
+ const [n, s] = e.split(t);
17
+ return { color: n == null ? void 0 : n.trim(), size: s == null ? void 0 : s.trim() };
18
+ }, O = (e, t = "tamanho") => {
19
+ if (e.additionalProperty) {
20
+ const [n] = e.additionalProperty;
21
+ return n != null && n.name ? n.name.toLocaleLowerCase() === t ? n.value : e.name : "";
22
+ }
23
+ return e.name;
24
+ }, N = (e, t) => e.replace(t, "").trim(), z = (e) => e.replace(/\//g, ""), P = ({ items: e, NAME_SPLIT_SYMBOL: t }) => {
25
+ const n = {
26
+ price: 0,
27
+ listPrice: 0,
28
+ installments: {
29
+ count: 0,
30
+ value: 0
31
+ }
32
+ }, s = (a, i) => {
33
+ var _;
34
+ i && (i.sellerId = a.sellerId, i.sellerName = a.sellerName, i.available = !0, i.isSellerDefault = a.sellerDefault);
35
+ const {
36
+ Price: l,
37
+ ListPrice: u,
38
+ PaymentOptions: { installmentOptions: d }
39
+ } = a.commertialOffer;
40
+ n.price = l, n.listPrice = u;
41
+ const c = (_ = d == null ? void 0 : d[0]) == null ? void 0 : _.installments;
42
+ if (c) {
43
+ const { count: m, value: f } = c[c.length - 1];
44
+ n.installments = {
45
+ count: m,
46
+ value: f / 100
47
+ };
48
+ }
49
+ };
50
+ let r = !0;
51
+ const o = e.reduce((a, i) => {
52
+ var d;
53
+ const l = {
54
+ name: i.name,
55
+ sku: i.itemId,
56
+ value: ((d = i.Tamanho) == null ? void 0 : d[0]) ?? y(i.nameComplete ?? i.name, t).size,
57
+ available: !1,
58
+ sellerId: "",
59
+ sellerName: "",
60
+ isSellerDefault: !1
61
+ }, u = i.sellers.filter((c) => (c.sellerDefault && c.commertialOffer.IsAvailable && (l.available = !0, s(c, l)), c.commertialOffer.IsAvailable));
62
+ return !l.isSellerDefault && u.length > 0 && (l.available = !0, s(u[0], {
63
+ ...l,
64
+ sellerId: u[0].sellerId,
65
+ sellerName: u[0].sellerName
66
+ })), l.available === !1 && (r = !1), a.push(l), a;
67
+ }, []);
68
+ return {
69
+ ...n,
70
+ sizes: o,
71
+ allSizesAvailable: r
72
+ };
73
+ }, x = (e) => e ? !e.offers.offers.find(({ quantity: t = 0 }) => t > 0) : !1, F = (e, t) => {
74
+ const n = e.find(
75
+ (s) => s.availability.includes("InStock") && s.quantity && s.listPrice > 0 && s.seller.identifier === t
76
+ );
77
+ return n || e.find(
78
+ (s) => s.availability.includes("InStock") && s.quantity && s.listPrice > 0
79
+ );
80
+ }, j = ({ images: e, TEXTURE_IMAGE: t }) => e.find((n) => t.includes(n.imageLabel)) ?? e[0], A = (e, t) => {
81
+ const n = /\/ids\/(\d+)\//, s = e.match(n);
82
+ return s ? e.replace(
83
+ `/${s[1]}/`,
84
+ `/${s[1]}-${t.width}-${t.height}/`
85
+ ) : e;
86
+ }, D = (e, t) => {
87
+ const n = /\/ids\/(\d+)-(\d+)-(\d+)\//, s = e.match(n);
88
+ return s ? e.replace(
89
+ `/${s[1]}-${s[2]}-${s[3]}/`,
90
+ `/${s[1]}-${t.width}-${t.height}/`
91
+ ) : e;
92
+ }, B = ({
93
+ images: e,
94
+ label: t
95
+ }) => {
96
+ const n = e.filter(
97
+ (s) => s.keywords === t.first || s.keywords === t.second || s.alternateName === t.first || s.alternateName === t.second
98
+ );
99
+ return n.length === 0 ? e.slice(0, 2) : n;
100
+ }, E = (e) => {
101
+ const [t, n] = e.split("/").map(Number);
102
+ if (Number.isNaN(t) || Number.isNaN(n))
103
+ throw new Error("[ERROR ASPECT RATIO IMAGE]: Invalid aspect ratio format");
104
+ return n / t;
105
+ }, L = (e, t, n) => {
106
+ t && (e ? (t.getAttribute("src") || (t.src = n ?? ""), t.play()) : t.pause());
107
+ }, we = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
108
+ __proto__: null,
109
+ disableSKU: x,
110
+ formatPriceToCurrency: b,
111
+ freightParsePrice: R,
112
+ getAspectRatio: E,
113
+ getColorAndSizeFromSkuName: C,
114
+ getDiscountPercent: T,
115
+ getFirstImages: B,
116
+ getProductNameWithoutSku: N,
117
+ getSKUName: O,
118
+ getSkuInfos: P,
119
+ getThumbImage: j,
120
+ getValidOffer: F,
121
+ removeSlashes: z,
122
+ resizingImg: A,
123
+ setVideoPlay: L,
124
+ splitNameAndSizeFromFullName: y,
125
+ updatedResizedImg: D
126
+ }, Symbol.toStringTag, { value: "Module" })), k = "fuzzy", v = "operator", M = (e) => ({
127
+ isDepartment: e != null && e.length ? e[0].key === "category-1" : !1
128
+ }), $e = (e, t) => {
129
+ const n = decodeURIComponent(t ?? "").slice(1).split("/");
130
+ return e.map((s) => {
131
+ if (s.key === "category-2" && s.__typename === "FacetBoolean") {
132
+ const r = s.values;
133
+ return {
134
+ ...s,
135
+ values: r.filter(
136
+ (o) => !n.find(
137
+ (a) => a.toLowerCase() === o.value || a.toLowerCase() === o.name.toLowerCase()
138
+ )
139
+ )
140
+ };
141
+ }
142
+ return s;
143
+ });
144
+ }, q = (e, t) => t ? e === "category-1" : !1, U = (e) => e.key === "operator" && (e.value === "and" || e.value === "or"), H = (e) => e.type === "TEXT", K = (e) => e.key === "fuzzy" && (e.value === "0" || e.value === "1" || e.value === "auto"), V = (e) => {
145
+ const { key: t, name: n, values: s } = e;
146
+ return {
147
+ __typename: "FacetBoolean",
148
+ key: t,
149
+ label: n,
150
+ values: s.slice().sort((r, o) => r.name.localeCompare(o.name))
151
+ };
152
+ }, Y = ({ key: e, values: t }) => ({
153
+ __typename: "FacetRange",
154
+ key: e,
155
+ values: t
156
+ }), Se = (e, t, n) => {
157
+ if (!(e instanceof Object) || !("facets" in e))
158
+ return [];
159
+ const { facets: s = [] } = e, r = t != null && t.length ? t[0].key === "category-1" : !1;
160
+ return s.filter(
161
+ (a) => !n || !q(a.key, r)
162
+ ).map(
163
+ (a) => H(a) ? V(a) : Y(a)
164
+ );
165
+ }, Re = (e, t) => {
166
+ const n = e.find(({ key: r }) => r === k) ?? null, s = e.find(({ key: r }) => r === v) ?? null;
167
+ n && K(n) && t.append(k, n.value), s && U(s) && t.append(v, s.value);
168
+ }, J = (e) => e.map((t) => {
169
+ const [n, s] = t.split("/");
170
+ return { key: n, value: s };
171
+ }), Te = (e, t) => {
172
+ const n = decodeURIComponent(t ?? "").slice(1).split("/"), s = e.filter(({ value: o }) => !n.includes(decodeURIComponent(o))).map((o) => ({
173
+ ...o,
174
+ value: decodeURIComponent(o.value)
175
+ })), { isDepartment: r } = M(s);
176
+ return s == null ? void 0 : s.filter((o) => !q(o.key, r));
177
+ }, Ce = ({ pathname: e, searchParams: t }, n) => {
178
+ const s = t.get("sort") ?? "", r = t.get("query") ?? null, o = parseInt(t.get("page") ?? "1", 10);
179
+ return {
180
+ sort: s,
181
+ facets: J(n),
182
+ term: r,
183
+ base: r ? "" : e,
184
+ page: o
185
+ };
186
+ }, Oe = (e) => {
187
+ const t = new URLSearchParams();
188
+ return Object.entries(e).forEach(([n, s]) => {
189
+ Array.isArray(s) ? s.forEach((r) => t.append(n, r)) : s !== void 0 && t.append(n, s);
190
+ }), t;
191
+ }, Ne = (e, t, n = 24, s = 1, r) => {
192
+ const o = `/search?query=${t ?? ""}&count=${n}&page=${s}${r ? `&sort=${r.replace("_", ":")}` : ""}`;
193
+ e.push(o);
194
+ }, h = {
195
+ "responsive-mobile-flex": "_responsive-mobile-flex_t5bry_2",
196
+ "responsive-desktop-flex": "_responsive-desktop-flex_t5bry_13",
197
+ "responsive-mobile-block": "_responsive-mobile-block_t5bry_24",
198
+ "responsive-desktop-block": "_responsive-desktop-block_t5bry_35"
199
+ }, I = {}, ze = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
200
+ __proto__: null,
201
+ default: I
202
+ }, Symbol.toStringTag, { value: "Module" })), W = "_header_qh6ki_40", G = "_actions_qh6ki_61", X = "_breadcrumb_qh6ki_72", Q = "_credits_qh6ki_87", Z = "_pdplinks_qh6ki_115", ee = "_similars_qh6ki_142", te = "_sizes_qh6ki_181", ne = "_measurementTable_qh6ki_197", se = "_measurementHead_qh6ki_210", ae = "_measurementRows_qh6ki_215", re = "_measurementRowsTitle_qh6ki_232", oe = "_measurementRowsText_qh6ki_244", ie = "_measurementImage_qh6ki_255", ce = "_measurementImageContainer_qh6ki_258", le = "_measurementContent_qh6ki_267", me = "_measurementTitle_qh6ki_271", _e = "_measurementClose_qh6ki_282", ue = "_productref_qh6ki_347", de = "_slideOut_qh6ki_1", pe = "_slideIn_qh6ki_1", fe = "_content_qh6ki_327", he = "_pdp_qh6ki_115", be = "_divider_qh6ki_510", Pe = {
203
+ "bottom-navigation": "_bottom-navigation_qh6ki_1",
204
+ "bottom-navigation__credits-modifier": "_bottom-navigation__credits-modifier_qh6ki_18",
205
+ "bottom-navigation__header": "_bottom-navigation__header_qh6ki_21",
206
+ "bottom-navigation__price-and-promo": "_bottom-navigation__price-and-promo_qh6ki_31",
207
+ header: W,
208
+ actions: G,
209
+ "add-to-cart": "_add-to-cart_qh6ki_68",
210
+ breadcrumb: X,
211
+ "breadcrumb--active": "_breadcrumb--active_qh6ki_77",
212
+ credits: Q,
213
+ "gallery-carousel-modifier": "_gallery-carousel-modifier_qh6ki_92",
214
+ pdplinks: Z,
215
+ "links-wrapper": "_links-wrapper_qh6ki_125",
216
+ similars: ee,
217
+ "similars-info": "_similars-info_qh6ki_154",
218
+ "toggle-style-modifier": "_toggle-style-modifier_qh6ki_163",
219
+ "accessibility-info": "_accessibility-info_qh6ki_167",
220
+ sizes: te,
221
+ "price-wrapper": "_price-wrapper_qh6ki_193",
222
+ measurementTable: ne,
223
+ measurementHead: se,
224
+ measurementRows: ae,
225
+ measurementRowsTitle: re,
226
+ measurementRowsText: oe,
227
+ measurementImage: ie,
228
+ measurementImageContainer: ce,
229
+ measurementContent: le,
230
+ measurementTitle: me,
231
+ measurementClose: _e,
232
+ "tabs-root-modifier": "_tabs-root-modifier_qh6ki_288",
233
+ "tabs-list-modifier": "_tabs-list-modifier_qh6ki_306",
234
+ "tabs-item-modifier": "_tabs-item-modifier_qh6ki_323",
235
+ "content-wrapper": "_content-wrapper_qh6ki_327",
236
+ productref: ue,
237
+ "tabs-panel": "_tabs-panel_qh6ki_358",
238
+ "tabs-panel-exit": "_tabs-panel-exit_qh6ki_364",
239
+ slideOut: de,
240
+ "tabs-panel-enter": "_tabs-panel-enter_qh6ki_368",
241
+ slideIn: pe,
242
+ content: fe,
243
+ pdp: he,
244
+ "pdp-main": "_pdp-main_qh6ki_426",
245
+ "pdp-main__gallery-wrapper": "_pdp-main__gallery-wrapper_qh6ki_431",
246
+ "pdp-main__info": "_pdp-main__info_qh6ki_448",
247
+ "pdp-main__info-main-content": "_pdp-main__info-main-content_qh6ki_468",
248
+ "pdp-main__info-subsection": "_pdp-main__info-subsection_qh6ki_468",
249
+ "subsection-product-info": "_subsection-product-info_qh6ki_479",
250
+ "subsection-similars": "_subsection-similars_qh6ki_482",
251
+ "subsection-sizes": "_subsection-sizes_qh6ki_485",
252
+ "subsection-actions": "_subsection-actions_qh6ki_488",
253
+ "pdp-main__info-secondary-content": "_pdp-main__info-secondary-content_qh6ki_492",
254
+ "sections-title": "_sections-title_qh6ki_498",
255
+ divider: be,
256
+ "breadcrumbs-desktop": "_breadcrumbs-desktop_qh6ki_515",
257
+ "breadcrumbs-mobile": "_breadcrumbs-mobile_qh6ki_524"
258
+ }, xe = ({
259
+ children: e,
260
+ data: t,
261
+ SectionZone: n,
262
+ className: s
263
+ }) => {
264
+ var d, c;
265
+ const r = ((d = t == null ? void 0 : t.filter((_) => {
266
+ var m, f;
267
+ return ((f = (m = _.config) == null ? void 0 : m.responsive) == null ? void 0 : f.deviceType) === "mobile";
268
+ })[0]) == null ? void 0 : d.sections) || [], o = ((c = t == null ? void 0 : t.filter((_) => {
269
+ var m, f;
270
+ return ((f = (m = _.config) == null ? void 0 : m.responsive) == null ? void 0 : f.deviceType) === "desktop";
271
+ })[0]) == null ? void 0 : c.sections) || [], a = r.slice(0, 1), i = r.slice(1, r.length), l = o.slice(0, 1), u = o.slice(1, o.length);
272
+ return /* @__PURE__ */ g($, { children: [
273
+ /* @__PURE__ */ g("div", { className: s, children: [
274
+ /* @__PURE__ */ p("div", { className: h["responsive-mobile-flex"], children: /* @__PURE__ */ p(n, { data: a ?? [] }) }),
275
+ /* @__PURE__ */ p("div", { className: h["responsive-desktop-flex"], children: /* @__PURE__ */ p(n, { data: l ?? [] }) })
276
+ ] }),
277
+ e,
278
+ /* @__PURE__ */ p("div", { className: h["responsive-mobile-flex"], children: /* @__PURE__ */ p(n, { data: i ?? [] }) }),
279
+ /* @__PURE__ */ p("div", { className: h["responsive-desktop-flex"], children: /* @__PURE__ */ p(n, { data: u ?? [] }) }),
280
+ /* @__PURE__ */ p(S.Divider, {})
281
+ ] });
282
+ };
283
+ async function ge({ contentType: e, storeId: t, CMS_PROJECT_NAME: n, NextCookies: s }) {
284
+ const r = await w({
285
+ contentType: e,
286
+ storeId: t,
287
+ CMS_PROJECT_NAME: n,
288
+ NextCookies: s
289
+ });
290
+ if (r.status === 200) {
291
+ const o = {
292
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
293
+ contentType: e,
294
+ data: r.data
295
+ };
296
+ console.log("Resultado da chamada:", r);
297
+ const a = `backup-${e}-${Date.now()}.json`;
298
+ return await I.writeFile(
299
+ `./backups/${a}`,
300
+ JSON.stringify(o, null, 2),
301
+ "utf-8"
302
+ ), { success: !0, fileName: a };
303
+ }
304
+ return { success: !1, error: r.error || "No data to backup" };
305
+ }
306
+ async function ke(e) {
307
+ return ge(e);
308
+ }
309
+ async function ve({
310
+ contentType: e,
311
+ documentId: t,
312
+ versionId: n,
313
+ storeId: s,
314
+ CMS_PROJECT_NAME: r
315
+ }) {
316
+ const o = t && t.length ? `/${t}` : "", a = n && n.length ? `?versionId=${n}` : "";
317
+ return fetch(
318
+ `https://${s}.myvtex.com/_v/cms/api/${r}/${e}${o}${a}`,
319
+ { cache: "no-cache" }
320
+ );
321
+ }
322
+ async function ye({
323
+ contentType: e,
324
+ documents: t,
325
+ NextCookies: n,
326
+ previewId: s,
327
+ CMS_PROJECT_NAME: r,
328
+ storeId: o
329
+ }) {
330
+ var i;
331
+ const a = JSON.parse(
332
+ s ?? ((i = n == null ? void 0 : n().get("cms_preview_data")) == null ? void 0 : i.value) ?? "{}"
333
+ );
334
+ if (a && (a == null ? void 0 : a.contentType) === e) {
335
+ const l = a.documentId && a.documentId.length ? `/${a.documentId}` : "", u = a != null && a.versionId && (a != null && a.versionId.length) ? `?versionId=${a == null ? void 0 : a.versionId}` : "", c = await (await fetch(
336
+ `https://${o}.myvtex.com/_v/cms/api/${r}/${e}${l}${u}`,
337
+ { cache: "no-store" }
338
+ )).json(), _ = t.filter(
339
+ (m) => c.id !== m.documentId
340
+ );
341
+ return _.unshift(c), _;
342
+ }
343
+ return t;
344
+ }
345
+ async function w({
346
+ contentType: e,
347
+ NextCookies: t,
348
+ CMS_PROJECT_NAME: n,
349
+ storeId: s,
350
+ previewId: r
351
+ }) {
352
+ var d, c;
353
+ const o = JSON.parse(
354
+ r ?? ((d = t == null ? void 0 : t().get("cms_preview_data")) == null ? void 0 : d.value) ?? "{}"
355
+ ), a = [];
356
+ let i = 1, l = 0, u = !0;
357
+ try {
358
+ do {
359
+ const m = await (await fetch(
360
+ `https://${s}.myvtex.com/_v/cms/api/${n}/${e}?page=${i}`
361
+ )).json();
362
+ i === 1 && (l = m.totalItems), (c = m == null ? void 0 : m.data) != null && c.length && a.push(...m.data), u = m.hasNextPage, i++;
363
+ } while (u && a.length < l);
364
+ if (o.previewMode && a.length) {
365
+ const _ = await ye({
366
+ contentType: e,
367
+ documents: a,
368
+ NextCookies: t,
369
+ CMS_PROJECT_NAME: n,
370
+ storeId: s
371
+ });
372
+ return {
373
+ status: _.length > 0 ? 200 : 404,
374
+ data: _ ?? []
375
+ };
376
+ }
377
+ return {
378
+ status: a.length ? 200 : 404,
379
+ data: a
380
+ };
381
+ } catch (_) {
382
+ return { status: "error", data: [], error: _ };
383
+ }
384
+ }
385
+ const Fe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
386
+ __proto__: null,
387
+ cmsBackup: ke,
388
+ getCMSContentType: ve,
389
+ getContentType: w
390
+ }, Symbol.toStringTag, { value: "Module" }));
391
+ export {
392
+ Fe as A,
393
+ xe as S,
394
+ ze as _,
395
+ P as a,
396
+ j as b,
397
+ O as c,
398
+ x as d,
399
+ we as e,
400
+ b as f,
401
+ C as g,
402
+ R as h,
403
+ F as i,
404
+ T as j,
405
+ B as k,
406
+ L as l,
407
+ N as m,
408
+ Pe as n,
409
+ A as o,
410
+ Ce as p,
411
+ Te as q,
412
+ h as r,
413
+ y as s,
414
+ $e as t,
415
+ D as u,
416
+ Ne as v,
417
+ w,
418
+ Re as x,
419
+ Se as y,
420
+ Oe as z
421
+ };
@@ -0,0 +1 @@
1
+ "use strict";const p=require("react/jsx-runtime"),A=require("@soma-vertical-web/core-components"),g=(e,t=!0)=>Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL",minimumFractionDigits:t?2:0}).format(e),q=({valueInCents:e,hasFree:t,freeTaxMessage:n})=>e===0?t?n:g(0):g(e/100),I=(e,t)=>{const s=(e-t)*100/e;return Math.floor(s)},b=(e,t)=>{const[n,s]=e.split(t);return{name:n.trim(),size:s?s.trim():""}},S=(e,t)=>{if(!e)return{};const[n,s]=e.split(t);return{color:n==null?void 0:n.trim(),size:s==null?void 0:s.trim()}},w=(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},$=(e,t)=>e.replace(t,"").trim(),D=e=>e.replace(/\//g,""),T=({items:e,NAME_SPLIT_SYMBOL:t})=>{const n={price:0,listPrice:0,installments:{count:0,value:0}},s=(r,a)=>{var _;a&&(a.sellerId=r.sellerId,a.sellerName=r.sellerName,a.available=!0,a.isSellerDefault=r.sellerDefault);const{Price:l,ListPrice:u,PaymentOptions:{installmentOptions:d}}=r.commertialOffer;n.price=l,n.listPrice=u;const c=(_=d==null?void 0:d[0])==null?void 0:_.installments;if(c){const{count:m,value:f}=c[c.length-1];n.installments={count:m,value:f/100}}};let o=!0;const i=e.reduce((r,a)=>{var d;const l={name:a.name,sku:a.itemId,value:((d=a.Tamanho)==null?void 0:d[0])??b(a.nameComplete??a.name,t).size,available:!1,sellerId:"",sellerName:"",isSellerDefault:!1},u=a.sellers.filter(c=>(c.sellerDefault&&c.commertialOffer.IsAvailable&&(l.available=!0,s(c,l)),c.commertialOffer.IsAvailable));return!l.isSellerDefault&&u.length>0&&(l.available=!0,s(u[0],{...l,sellerId:u[0].sellerId,sellerName:u[0].sellerName})),l.available===!1&&(o=!1),r.push(l),r},[]);return{...n,sizes:i,allSizesAvailable:o}},C=e=>e?!e.offers.offers.find(({quantity:t=0})=>t>0):!1,N=(e,t)=>{const n=e.find(s=>s.availability.includes("InStock")&&s.quantity&&s.listPrice>0&&s.seller.identifier===t);return n||e.find(s=>s.availability.includes("InStock")&&s.quantity&&s.listPrice>0)},R=({images:e,TEXTURE_IMAGE:t})=>e.find(n=>t.includes(n.imageLabel))??e[0],P=(e,t)=>{const n=/\/ids\/(\d+)\//,s=e.match(n);return s?e.replace(`/${s[1]}/`,`/${s[1]}-${t.width}-${t.height}/`):e},x=(e,t)=>{const n=/\/ids\/(\d+)-(\d+)-(\d+)\//,s=e.match(n);return s?e.replace(`/${s[1]}-${s[2]}-${s[3]}/`,`/${s[1]}-${t.width}-${t.height}/`):e},z=({images:e,label:t})=>{const n=e.filter(s=>s.keywords===t.first||s.keywords===t.second||s.alternateName===t.first||s.alternateName===t.second);return n.length===0?e.slice(0,2):n},B=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},O=(e,t,n)=>{t&&(e?(t.getAttribute("src")||(t.src=n??""),t.play()):t.pause())},U=Object.freeze(Object.defineProperty({__proto__:null,disableSKU:C,formatPriceToCurrency:g,freightParsePrice:q,getAspectRatio:B,getColorAndSizeFromSkuName:S,getDiscountPercent:I,getFirstImages:z,getProductNameWithoutSku:$,getSKUName:w,getSkuInfos:T,getThumbImage:R,getValidOffer:N,removeSlashes:D,resizingImg:P,setVideoPlay:O,splitNameAndSizeFromFullName:b,updatedResizedImg:x},Symbol.toStringTag,{value:"Module"})),v="fuzzy",y="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(s=>{if(s.key==="category-2"&&s.__typename==="FacetBoolean"){const o=s.values;return{...s,values:o.filter(i=>!n.find(r=>r.toLowerCase()===i.value||r.toLowerCase()===i.name.toLowerCase()))}}return s})},F=(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"),H=e=>{const{key:t,name:n,values:s}=e;return{__typename:"FacetBoolean",key:t,label:n,values:s.slice().sort((o,i)=>o.name.localeCompare(i.name))}},W=({key:e,values:t})=>({__typename:"FacetRange",key:e,values:t}),Y=(e,t,n)=>{if(!(e instanceof Object)||!("facets"in e))return[];const{facets:s=[]}=e,o=t!=null&&t.length?t[0].key==="category-1":!1;return s.filter(r=>!n||!F(r.key,o)).map(r=>K(r)?H(r):W(r))},J=(e,t)=>{const n=e.find(({key:o})=>o===v)??null,s=e.find(({key:o})=>o===y)??null;n&&V(n)&&t.append(v,n.value),s&&M(s)&&t.append(y,s.value)},G=e=>e.map(t=>{const[n,s]=t.split("/");return{key:n,value:s}}),X=(e,t)=>{const n=decodeURIComponent(t??"").slice(1).split("/"),s=e.filter(({value:i})=>!n.includes(decodeURIComponent(i))).map(i=>({...i,value:decodeURIComponent(i.value)})),{isDepartment:o}=E(s);return s==null?void 0:s.filter(i=>!F(i.key,o))},Q=({pathname:e,searchParams:t},n)=>{const s=t.get("sort")??"",o=t.get("query")??null,i=parseInt(t.get("page")??"1",10);return{sort:s,facets:G(n),term:o,base:o?"":e,page:i}},Z=e=>{const t=new URLSearchParams;return Object.entries(e).forEach(([n,s])=>{Array.isArray(s)?s.forEach(o=>t.append(n,o)):s!==void 0&&t.append(n,s)}),t},ee=(e,t,n=24,s=1,o)=>{const i=`/search?query=${t??""}&count=${n}&page=${s}${o?`&sort=${o.replace("_",":")}`:""}`;e.push(i)},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"},j={},te=Object.freeze(Object.defineProperty({__proto__:null,default:j},Symbol.toStringTag,{value:"Module"})),ne="_header_qh6ki_40",se="_actions_qh6ki_61",re="_breadcrumb_qh6ki_72",oe="_credits_qh6ki_87",ie="_pdplinks_qh6ki_115",ae="_similars_qh6ki_142",ce="_sizes_qh6ki_181",le="_measurementTable_qh6ki_197",me="_measurementHead_qh6ki_210",_e="_measurementRows_qh6ki_215",ue="_measurementRowsTitle_qh6ki_232",de="_measurementRowsText_qh6ki_244",pe="_measurementImage_qh6ki_255",fe="_measurementImageContainer_qh6ki_258",he="_measurementContent_qh6ki_267",ge="_measurementTitle_qh6ki_271",be="_measurementClose_qh6ki_282",ke="_productref_qh6ki_347",ve="_slideOut_qh6ki_1",ye="_slideIn_qh6ki_1",qe="_content_qh6ki_327",Ie="_pdp_qh6ki_115",Se="_divider_qh6ki_510",we={"bottom-navigation":"_bottom-navigation_qh6ki_1","bottom-navigation__credits-modifier":"_bottom-navigation__credits-modifier_qh6ki_18","bottom-navigation__header":"_bottom-navigation__header_qh6ki_21","bottom-navigation__price-and-promo":"_bottom-navigation__price-and-promo_qh6ki_31",header:ne,actions:se,"add-to-cart":"_add-to-cart_qh6ki_68",breadcrumb:re,"breadcrumb--active":"_breadcrumb--active_qh6ki_77",credits:oe,"gallery-carousel-modifier":"_gallery-carousel-modifier_qh6ki_92",pdplinks:ie,"links-wrapper":"_links-wrapper_qh6ki_125",similars:ae,"similars-info":"_similars-info_qh6ki_154","toggle-style-modifier":"_toggle-style-modifier_qh6ki_163","accessibility-info":"_accessibility-info_qh6ki_167",sizes:ce,"price-wrapper":"_price-wrapper_qh6ki_193",measurementTable:le,measurementHead:me,measurementRows:_e,measurementRowsTitle:ue,measurementRowsText:de,measurementImage:pe,measurementImageContainer:fe,measurementContent:he,measurementTitle:ge,measurementClose:be,"tabs-root-modifier":"_tabs-root-modifier_qh6ki_288","tabs-list-modifier":"_tabs-list-modifier_qh6ki_306","tabs-item-modifier":"_tabs-item-modifier_qh6ki_323","content-wrapper":"_content-wrapper_qh6ki_327",productref:ke,"tabs-panel":"_tabs-panel_qh6ki_358","tabs-panel-exit":"_tabs-panel-exit_qh6ki_364",slideOut:ve,"tabs-panel-enter":"_tabs-panel-enter_qh6ki_368",slideIn:ye,content:qe,pdp:Ie,"pdp-main":"_pdp-main_qh6ki_426","pdp-main__gallery-wrapper":"_pdp-main__gallery-wrapper_qh6ki_431","pdp-main__info":"_pdp-main__info_qh6ki_448","pdp-main__info-main-content":"_pdp-main__info-main-content_qh6ki_468","pdp-main__info-subsection":"_pdp-main__info-subsection_qh6ki_468","subsection-product-info":"_subsection-product-info_qh6ki_479","subsection-similars":"_subsection-similars_qh6ki_482","subsection-sizes":"_subsection-sizes_qh6ki_485","subsection-actions":"_subsection-actions_qh6ki_488","pdp-main__info-secondary-content":"_pdp-main__info-secondary-content_qh6ki_492","sections-title":"_sections-title_qh6ki_498",divider:Se,"breadcrumbs-desktop":"_breadcrumbs-desktop_qh6ki_515","breadcrumbs-mobile":"_breadcrumbs-mobile_qh6ki_524"},$e=({children:e,data:t,SectionZone:n,className:s})=>{var d,c;const o=((d=t==null?void 0:t.filter(_=>{var m,f;return((f=(m=_.config)==null?void 0:m.responsive)==null?void 0:f.deviceType)==="mobile"})[0])==null?void 0:d.sections)||[],i=((c=t==null?void 0:t.filter(_=>{var m,f;return((f=(m=_.config)==null?void 0:m.responsive)==null?void 0:f.deviceType)==="desktop"})[0])==null?void 0:c.sections)||[],r=o.slice(0,1),a=o.slice(1,o.length),l=i.slice(0,1),u=i.slice(1,i.length);return p.jsxs(p.Fragment,{children:[p.jsxs("div",{className:s,children:[p.jsx("div",{className:h["responsive-mobile-flex"],children:p.jsx(n,{data:r??[]})}),p.jsx("div",{className:h["responsive-desktop-flex"],children:p.jsx(n,{data:l??[]})})]}),e,p.jsx("div",{className:h["responsive-mobile-flex"],children:p.jsx(n,{data:a??[]})}),p.jsx("div",{className:h["responsive-desktop-flex"],children:p.jsx(n,{data:u??[]})}),p.jsx(A.Utils.Divider,{})]})};async function Te({contentType:e,storeId:t,CMS_PROJECT_NAME:n,NextCookies:s}){const o=await k({contentType:e,storeId:t,CMS_PROJECT_NAME:n,NextCookies:s});if(o.status===200){const i={timestamp:new Date().toISOString(),contentType:e,data:o.data};console.log("Resultado da chamada:",o);const r=`backup-${e}-${Date.now()}.json`;return await j.writeFile(`./backups/${r}`,JSON.stringify(i,null,2),"utf-8"),{success:!0,fileName:r}}return{success:!1,error:o.error||"No data to backup"}}async function Ce(e){return Te(e)}async function Ne({contentType:e,documentId:t,versionId:n,storeId:s,CMS_PROJECT_NAME:o}){const i=t&&t.length?`/${t}`:"",r=n&&n.length?`?versionId=${n}`:"";return fetch(`https://${s}.myvtex.com/_v/cms/api/${o}/${e}${i}${r}`,{cache:"no-cache"})}async function Re({contentType:e,documents:t,NextCookies:n,previewId:s,CMS_PROJECT_NAME:o,storeId:i}){var a;const r=JSON.parse(s??((a=n==null?void 0:n().get("cms_preview_data"))==null?void 0:a.value)??"{}");if(r&&(r==null?void 0:r.contentType)===e){const l=r.documentId&&r.documentId.length?`/${r.documentId}`:"",u=r!=null&&r.versionId&&(r!=null&&r.versionId.length)?`?versionId=${r==null?void 0:r.versionId}`:"",c=await(await fetch(`https://${i}.myvtex.com/_v/cms/api/${o}/${e}${l}${u}`,{cache:"no-store"})).json(),_=t.filter(m=>c.id!==m.documentId);return _.unshift(c),_}return t}async function k({contentType:e,NextCookies:t,CMS_PROJECT_NAME:n,storeId:s,previewId:o}){var d,c;const i=JSON.parse(o??((d=t==null?void 0:t().get("cms_preview_data"))==null?void 0:d.value)??"{}"),r=[];let a=1,l=0,u=!0;try{do{const m=await(await fetch(`https://${s}.myvtex.com/_v/cms/api/${n}/${e}?page=${a}`)).json();a===1&&(l=m.totalItems),(c=m==null?void 0:m.data)!=null&&c.length&&r.push(...m.data),u=m.hasNextPage,a++}while(u&&r.length<l);if(i.previewMode&&r.length){const _=await Re({contentType:e,documents:r,NextCookies:t,CMS_PROJECT_NAME:n,storeId:s});return{status:_.length>0?200:404,data:_??[]}}return{status:r.length?200:404,data:r}}catch(_){return{status:"error",data:[],error:_}}}const Pe=Object.freeze(Object.defineProperty({__proto__:null,cmsBackup:Ce,getCMSContentType:Ne,getContentType:k},Symbol.toStringTag,{value:"Module"}));exports.SearchPageScreening=$e;exports.__viteBrowserExternal=te;exports.addSearchParamsFacets=J;exports.cms=Pe;exports.convertSearchParams=Z;exports.disableSKU=C;exports.filterNonCategorySelected=L;exports.filterNonRootFacets=X;exports.formatPriceToCurrency=g;exports.formattedFacets=Y;exports.freightParsePrice=q;exports.getColorAndSizeFromSkuName=S;exports.getContentType=k;exports.getDiscountPercent=I;exports.getFirstImages=z;exports.getProductNameWithoutSku=$;exports.getSKUName=w;exports.getSkuInfos=T;exports.getThumbImage=R;exports.getValidOffer=N;exports.navigateToSearchPage=ee;exports.parseSearchState=Q;exports.productHelpers=U;exports.resizingImg=P;exports.responsive=h;exports.setVideoPlay=O;exports.splitNameAndSizeFromFullName=b;exports.styles=we;exports.updatedResizedImg=x;