@commerce-blocks/sdk 1.0.0 → 1.2.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.
- package/dist/index.d.ts +39 -2
- package/dist/index.js +1344 -1215
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,79 +1,55 @@
|
|
|
1
|
-
import { signal as
|
|
2
|
-
import { batch as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
1
|
+
import { signal as $ } from "@preact/signals-core";
|
|
2
|
+
import { batch as Ir, computed as br, effect as vr, signal as Fr } from "@preact/signals-core";
|
|
3
|
+
const Qe = "2026-01", We = "https://app.uselayers.com/api/storefront/v1", Ke = 1e3, ke = 1e3, qe = 100, Xe = 300 * Ke, ze = "6.0.0", se = 250, H = 20, j = 250, ie = 250, ae = 250, ce = 1, le = 1, Y = 1, Z = 24, ue = 1, de = 1, fe = 100, Je = 20, Ye = 50, Ze = 300, et = "USD", tt = "en-US", rt = 1e3, Ce = /* @__PURE__ */ new Map();
|
|
4
|
+
function nt(e, t) {
|
|
5
|
+
const r = `${e}:${t}`;
|
|
6
|
+
let o = Ce.get(r);
|
|
7
|
+
return o || (o = new Intl.NumberFormat(tt, {
|
|
8
|
+
style: "currency",
|
|
9
|
+
currency: t
|
|
10
|
+
}).format(e), Ce.set(r, o)), o;
|
|
11
|
+
}
|
|
12
|
+
function M(e) {
|
|
5
13
|
return { data: e };
|
|
6
14
|
}
|
|
7
15
|
function m(e) {
|
|
8
16
|
return { error: e };
|
|
9
17
|
}
|
|
10
|
-
|
|
11
|
-
function Ze(e, t) {
|
|
12
|
-
return `gid://shopify/${e}/${t}`;
|
|
13
|
-
}
|
|
14
|
-
function et(e) {
|
|
15
|
-
return Ze("Product", e);
|
|
16
|
-
}
|
|
17
|
-
function tt(e) {
|
|
18
|
-
const t = e.match(Ye);
|
|
19
|
-
if (!t) return null;
|
|
20
|
-
const [, r, s] = t;
|
|
21
|
-
return nt(r) ? { type: r, numericId: parseInt(s, 10) } : null;
|
|
22
|
-
}
|
|
23
|
-
function rt(e) {
|
|
24
|
-
return tt(e)?.numericId ?? null;
|
|
25
|
-
}
|
|
26
|
-
function nt(e) {
|
|
27
|
-
return e === "Product" || e === "ProductVariant" || e === "Collection";
|
|
28
|
-
}
|
|
29
|
-
function xe({
|
|
30
|
-
type: e,
|
|
31
|
-
selectedOptions: t
|
|
32
|
-
}) {
|
|
33
|
-
const r = t.map(({ name: s, value: i }) => `${s}:${i}`).join("-");
|
|
34
|
-
return `${e}-${r}`;
|
|
35
|
-
}
|
|
36
|
-
function Ue(e) {
|
|
37
|
-
return e.product_id ?? e.id;
|
|
38
|
-
}
|
|
39
|
-
function ye(e) {
|
|
40
|
-
return et(Ue(e));
|
|
41
|
-
}
|
|
42
|
-
function ae() {
|
|
18
|
+
function ee() {
|
|
43
19
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
44
20
|
}
|
|
45
|
-
const
|
|
46
|
-
function
|
|
47
|
-
const t =
|
|
21
|
+
const ot = ["TIMEOUT", "CONNECTION_FAILED", "DNS_FAILED"];
|
|
22
|
+
function J(e) {
|
|
23
|
+
const t = ot.includes(e.code);
|
|
48
24
|
return {
|
|
49
25
|
_tag: "NetworkError",
|
|
50
26
|
code: e.code,
|
|
51
27
|
message: e.message,
|
|
52
|
-
timestamp:
|
|
28
|
+
timestamp: ee(),
|
|
53
29
|
request: e.request,
|
|
54
30
|
cause: e.cause,
|
|
55
31
|
retryable: t,
|
|
56
32
|
retryAfterMs: t ? 1e3 : void 0
|
|
57
33
|
};
|
|
58
34
|
}
|
|
59
|
-
function
|
|
35
|
+
function st(e) {
|
|
60
36
|
if (!e) return;
|
|
61
37
|
const t = e["retry-after"] ?? e["Retry-After"];
|
|
62
38
|
if (!t) return;
|
|
63
39
|
const r = parseInt(t, 10);
|
|
64
40
|
if (!isNaN(r)) return r * 1e3;
|
|
65
|
-
const
|
|
66
|
-
if (!isNaN(
|
|
67
|
-
return Math.max(0,
|
|
41
|
+
const o = new Date(t);
|
|
42
|
+
if (!isNaN(o.getTime()))
|
|
43
|
+
return Math.max(0, o.getTime() - Date.now());
|
|
68
44
|
}
|
|
69
|
-
function
|
|
70
|
-
const t = e.code === "RATE_LIMITED" || e.code === "SERVICE_UNAVAILABLE" || e.status !== void 0 && e.status >= 500, r = e.retryAfterMs ??
|
|
45
|
+
function O(e) {
|
|
46
|
+
const t = e.code === "RATE_LIMITED" || e.code === "SERVICE_UNAVAILABLE" || e.status !== void 0 && e.status >= 500, r = e.retryAfterMs ?? st(e.response?.headers) ?? (t ? 1e3 : void 0);
|
|
71
47
|
return {
|
|
72
48
|
_tag: "ApiError",
|
|
73
49
|
code: e.code,
|
|
74
50
|
source: e.source,
|
|
75
51
|
message: e.message,
|
|
76
|
-
timestamp:
|
|
52
|
+
timestamp: ee(),
|
|
77
53
|
status: e.status,
|
|
78
54
|
retryable: t,
|
|
79
55
|
retryAfterMs: r,
|
|
@@ -83,24 +59,24 @@ function L(e) {
|
|
|
83
59
|
details: e.details
|
|
84
60
|
};
|
|
85
61
|
}
|
|
86
|
-
function
|
|
62
|
+
function D(e) {
|
|
87
63
|
return {
|
|
88
64
|
_tag: "ValidationError",
|
|
89
65
|
code: "VALIDATION_FAILED",
|
|
90
66
|
message: e.fields.length === 1 ? `Validation failed: ${e.fields[0].message}` : `Validation failed with ${e.fields.length} errors`,
|
|
91
|
-
timestamp:
|
|
67
|
+
timestamp: ee(),
|
|
92
68
|
operation: e.operation,
|
|
93
69
|
fields: e.fields,
|
|
94
70
|
input: e.input
|
|
95
71
|
};
|
|
96
72
|
}
|
|
97
|
-
function
|
|
73
|
+
function R(e, t, r, o) {
|
|
98
74
|
return {
|
|
99
75
|
path: e.split("."),
|
|
100
76
|
field: e.split(".").pop() ?? e,
|
|
101
77
|
code: t,
|
|
102
78
|
message: r,
|
|
103
|
-
...
|
|
79
|
+
...o
|
|
104
80
|
};
|
|
105
81
|
}
|
|
106
82
|
function B(e) {
|
|
@@ -108,21 +84,21 @@ function B(e) {
|
|
|
108
84
|
_tag: "ConfigError",
|
|
109
85
|
code: e.code,
|
|
110
86
|
message: e.message,
|
|
111
|
-
timestamp:
|
|
87
|
+
timestamp: ee(),
|
|
112
88
|
field: e.field,
|
|
113
89
|
value: e.value,
|
|
114
90
|
expected: e.expected
|
|
115
91
|
};
|
|
116
92
|
}
|
|
117
|
-
function
|
|
93
|
+
function rr(e) {
|
|
118
94
|
return typeof e == "object" && e !== null && typeof e._tag == "string";
|
|
119
95
|
}
|
|
120
|
-
function
|
|
96
|
+
function nr(e) {
|
|
121
97
|
return "retryable" in e ? e.retryable : !1;
|
|
122
98
|
}
|
|
123
|
-
function
|
|
99
|
+
function it(e, t) {
|
|
124
100
|
const r = e === 401 ? "UNAUTHORIZED" : e === 403 ? "FORBIDDEN" : e === 429 ? "RATE_LIMITED" : e >= 500 ? "SERVICE_UNAVAILABLE" : "UNKNOWN";
|
|
125
|
-
return
|
|
101
|
+
return O({
|
|
126
102
|
code: r,
|
|
127
103
|
source: "layers",
|
|
128
104
|
message: t || `HTTP ${e}`,
|
|
@@ -132,13 +108,13 @@ function at(e, t) {
|
|
|
132
108
|
function Ee(e) {
|
|
133
109
|
if (e instanceof Error && (e.name === "AbortError" || e.name === "TimeoutError")) {
|
|
134
110
|
const t = e.name === "TimeoutError" || e.message.includes("timeout");
|
|
135
|
-
return
|
|
111
|
+
return J({
|
|
136
112
|
code: t ? "TIMEOUT" : "ABORTED",
|
|
137
113
|
message: t ? "Request timed out" : "Request was aborted",
|
|
138
114
|
cause: e
|
|
139
115
|
});
|
|
140
116
|
}
|
|
141
|
-
return
|
|
117
|
+
return J({
|
|
142
118
|
code: "CONNECTION_FAILED",
|
|
143
119
|
message: e instanceof Error ? e.message : "Network request failed",
|
|
144
120
|
cause: e
|
|
@@ -147,13 +123,13 @@ function Ee(e) {
|
|
|
147
123
|
async function _e(e) {
|
|
148
124
|
if (!e.ok) {
|
|
149
125
|
const t = await e.text().catch(() => "");
|
|
150
|
-
return m(
|
|
126
|
+
return m(it(e.status, t));
|
|
151
127
|
}
|
|
152
128
|
try {
|
|
153
|
-
return
|
|
129
|
+
return M(await e.json());
|
|
154
130
|
} catch (t) {
|
|
155
131
|
return m(
|
|
156
|
-
|
|
132
|
+
O({
|
|
157
133
|
code: "PARSE_ERROR",
|
|
158
134
|
source: "layers",
|
|
159
135
|
message: "Invalid JSON response",
|
|
@@ -162,27 +138,27 @@ async function _e(e) {
|
|
|
162
138
|
);
|
|
163
139
|
}
|
|
164
140
|
}
|
|
165
|
-
function
|
|
141
|
+
function Ie({
|
|
166
142
|
token: e,
|
|
167
143
|
json: t = !0
|
|
168
144
|
}) {
|
|
169
145
|
const r = {
|
|
170
146
|
Accept: "application/json",
|
|
171
147
|
"X-Storefront-Access-Token": e,
|
|
172
|
-
"X-SDK-Client": `commerce-blocks-sdk/${
|
|
148
|
+
"X-SDK-Client": `commerce-blocks-sdk/${ze}`
|
|
173
149
|
};
|
|
174
150
|
return t && (r["Content-Type"] = "application/json"), r;
|
|
175
151
|
}
|
|
176
|
-
function
|
|
177
|
-
const { layersBaseUrl: r =
|
|
152
|
+
function be({ config: e, endpoint: t }) {
|
|
153
|
+
const { layersBaseUrl: r = We } = e;
|
|
178
154
|
return `${r}${t}`;
|
|
179
155
|
}
|
|
180
|
-
async function
|
|
156
|
+
async function G(e) {
|
|
181
157
|
const t = e.config.fetch ?? fetch;
|
|
182
158
|
try {
|
|
183
|
-
const r = await t(
|
|
159
|
+
const r = await t(be({ config: e.config, endpoint: e.endpoint }), {
|
|
184
160
|
method: "POST",
|
|
185
|
-
headers:
|
|
161
|
+
headers: Ie({ token: e.config.layersPublicToken }),
|
|
186
162
|
body: JSON.stringify(e.body),
|
|
187
163
|
signal: e.signal
|
|
188
164
|
});
|
|
@@ -191,28 +167,28 @@ async function K(e) {
|
|
|
191
167
|
return m(Ee(r));
|
|
192
168
|
}
|
|
193
169
|
}
|
|
194
|
-
async function
|
|
170
|
+
async function at(e) {
|
|
195
171
|
const t = new URLSearchParams();
|
|
196
|
-
for (const [
|
|
197
|
-
|
|
198
|
-
const r = t.toString(),
|
|
172
|
+
for (const [s, i] of Object.entries(e.params))
|
|
173
|
+
i != null && t.append(s, typeof i == "object" ? JSON.stringify(i) : String(i));
|
|
174
|
+
const r = t.toString(), o = r ? `${e.endpoint}?${r}` : e.endpoint, n = e.config.fetch ?? fetch;
|
|
199
175
|
try {
|
|
200
|
-
const
|
|
176
|
+
const s = await n(be({ config: e.config, endpoint: o }), {
|
|
201
177
|
method: "GET",
|
|
202
|
-
headers:
|
|
178
|
+
headers: Ie({ token: e.config.layersPublicToken }),
|
|
203
179
|
signal: e.signal
|
|
204
180
|
});
|
|
205
|
-
return _e(
|
|
206
|
-
} catch (
|
|
207
|
-
return m(Ee(
|
|
181
|
+
return _e(s);
|
|
182
|
+
} catch (s) {
|
|
183
|
+
return m(Ee(s));
|
|
208
184
|
}
|
|
209
185
|
}
|
|
210
186
|
async function ct(e) {
|
|
211
187
|
const t = e.config.fetch ?? fetch;
|
|
212
188
|
try {
|
|
213
|
-
const r = await t(
|
|
189
|
+
const r = await t(be({ config: e.config, endpoint: e.endpoint }), {
|
|
214
190
|
method: "POST",
|
|
215
|
-
headers:
|
|
191
|
+
headers: Ie({ token: e.config.layersPublicToken, json: !1 }),
|
|
216
192
|
body: e.formData,
|
|
217
193
|
signal: e.signal
|
|
218
194
|
});
|
|
@@ -221,22 +197,48 @@ async function ct(e) {
|
|
|
221
197
|
return m(Ee(r));
|
|
222
198
|
}
|
|
223
199
|
}
|
|
224
|
-
function
|
|
200
|
+
function Q(e, t) {
|
|
225
201
|
if (!e) return null;
|
|
226
202
|
const r = [];
|
|
227
|
-
return e.page !== void 0 && e.page <
|
|
228
|
-
|
|
203
|
+
return e.page !== void 0 && e.page < ue && r.push(
|
|
204
|
+
R("pagination.page", "OUT_OF_RANGE", `page must be >= ${ue}`, {
|
|
229
205
|
value: e.page,
|
|
230
|
-
constraints: { min:
|
|
231
|
-
})
|
|
232
|
-
), e.limit !== void 0 && (e.limit < 1 || e.limit > 100) && r.push(
|
|
233
|
-
D("pagination.limit", "OUT_OF_RANGE", "limit must be between 1 and 100", {
|
|
234
|
-
value: e.limit,
|
|
235
|
-
constraints: { min: 1, max: 100 }
|
|
206
|
+
constraints: { min: ue }
|
|
236
207
|
})
|
|
237
|
-
),
|
|
238
|
-
|
|
239
|
-
|
|
208
|
+
), e.limit !== void 0 && (e.limit < de || e.limit > fe) && r.push(
|
|
209
|
+
R(
|
|
210
|
+
"pagination.limit",
|
|
211
|
+
"OUT_OF_RANGE",
|
|
212
|
+
`limit must be between ${de} and ${fe}`,
|
|
213
|
+
{
|
|
214
|
+
value: e.limit,
|
|
215
|
+
constraints: { min: de, max: fe }
|
|
216
|
+
}
|
|
217
|
+
)
|
|
218
|
+
), r.length > 0 ? D({ operation: t, fields: r }) : null;
|
|
219
|
+
}
|
|
220
|
+
const lt = [
|
|
221
|
+
"title",
|
|
222
|
+
"handle",
|
|
223
|
+
"body_html",
|
|
224
|
+
"vendor",
|
|
225
|
+
"product_type",
|
|
226
|
+
"available",
|
|
227
|
+
"is_gift_card",
|
|
228
|
+
"tags",
|
|
229
|
+
"images",
|
|
230
|
+
"price_range",
|
|
231
|
+
"options",
|
|
232
|
+
"options_v2",
|
|
233
|
+
"first_or_matched_variant",
|
|
234
|
+
"featured_media",
|
|
235
|
+
"variants",
|
|
236
|
+
"metafields",
|
|
237
|
+
"calculated",
|
|
238
|
+
"named_tags",
|
|
239
|
+
"category"
|
|
240
|
+
];
|
|
241
|
+
function ut(e) {
|
|
240
242
|
if (!e.layersPublicToken)
|
|
241
243
|
return m(
|
|
242
244
|
B({
|
|
@@ -255,222 +257,213 @@ function lt(e) {
|
|
|
255
257
|
expected: "non-empty array of Sort"
|
|
256
258
|
})
|
|
257
259
|
);
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
"handle",
|
|
261
|
-
"body_html",
|
|
262
|
-
"vendor",
|
|
263
|
-
"product_type",
|
|
264
|
-
"available",
|
|
265
|
-
"is_gift_card",
|
|
266
|
-
"tags",
|
|
267
|
-
"images",
|
|
268
|
-
"price_range",
|
|
269
|
-
"options",
|
|
270
|
-
"options_v2",
|
|
271
|
-
"first_or_matched_variant",
|
|
272
|
-
"featured_media",
|
|
273
|
-
"variants",
|
|
274
|
-
"metafields",
|
|
275
|
-
"calculated",
|
|
276
|
-
"named_tags",
|
|
277
|
-
"category"
|
|
278
|
-
];
|
|
279
|
-
function r(n) {
|
|
280
|
-
return [.../* @__PURE__ */ new Set([...t, ...e.attributes ?? [], ...n ?? []])];
|
|
260
|
+
function t(n) {
|
|
261
|
+
return [.../* @__PURE__ */ new Set([...lt, ...e.attributes ?? [], ...n ?? []])];
|
|
281
262
|
}
|
|
282
|
-
const
|
|
263
|
+
const r = {
|
|
283
264
|
layersPublicToken: e.layersPublicToken,
|
|
284
265
|
layersBaseUrl: e.layersBaseUrl,
|
|
285
266
|
fetch: e.fetch
|
|
286
267
|
};
|
|
287
|
-
return
|
|
288
|
-
browse: async (n,
|
|
268
|
+
return M({
|
|
269
|
+
browse: async (n, s) => {
|
|
289
270
|
if (!n.collectionHandle)
|
|
290
271
|
return m(
|
|
291
|
-
|
|
272
|
+
D({
|
|
292
273
|
operation: "browse",
|
|
293
274
|
fields: [
|
|
294
|
-
|
|
275
|
+
R("collectionHandle", "REQUIRED_FIELD", "collectionHandle is required")
|
|
295
276
|
]
|
|
296
277
|
})
|
|
297
278
|
);
|
|
298
279
|
if (!n.sort_order_code)
|
|
299
280
|
return m(
|
|
300
|
-
|
|
281
|
+
D({
|
|
301
282
|
operation: "browse",
|
|
302
283
|
fields: [
|
|
303
|
-
|
|
284
|
+
R("sort_order_code", "REQUIRED_FIELD", "sort_order_code is required")
|
|
304
285
|
]
|
|
305
286
|
})
|
|
306
287
|
);
|
|
307
|
-
const
|
|
308
|
-
if (
|
|
309
|
-
const { collectionHandle:
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
288
|
+
const i = Q(n.pagination, "browse");
|
|
289
|
+
if (i) return m(i);
|
|
290
|
+
const { collectionHandle: a, attributes: l, transformBody: u, ...g } = n;
|
|
291
|
+
let f = {
|
|
292
|
+
facets: e.facets,
|
|
293
|
+
attributes: t(l),
|
|
294
|
+
retrieveFacetCount: !0,
|
|
295
|
+
includeFacetRanges: !0,
|
|
296
|
+
...g
|
|
297
|
+
};
|
|
298
|
+
return u && (f = u(f)), G({
|
|
299
|
+
config: r,
|
|
300
|
+
endpoint: `/browse/${a}`,
|
|
301
|
+
body: f,
|
|
302
|
+
signal: s
|
|
321
303
|
});
|
|
322
304
|
},
|
|
323
|
-
predictiveSearch: async (n,
|
|
324
|
-
config:
|
|
305
|
+
predictiveSearch: async (n, s) => n ? at({
|
|
306
|
+
config: r,
|
|
325
307
|
endpoint: "/search/complete",
|
|
326
308
|
params: { query: n },
|
|
327
|
-
signal:
|
|
309
|
+
signal: s
|
|
328
310
|
}) : m(
|
|
329
|
-
|
|
311
|
+
D({
|
|
330
312
|
operation: "predictiveSearch",
|
|
331
|
-
fields: [
|
|
313
|
+
fields: [R("query", "REQUIRED_FIELD", "query is required")]
|
|
332
314
|
})
|
|
333
315
|
),
|
|
334
|
-
prepareSearch: async (n,
|
|
316
|
+
prepareSearch: async (n, s) => {
|
|
335
317
|
if (!n.query)
|
|
336
318
|
return m(
|
|
337
|
-
|
|
319
|
+
D({
|
|
338
320
|
operation: "prepareSearch",
|
|
339
|
-
fields: [
|
|
321
|
+
fields: [R("query", "REQUIRED_FIELD", "query is required")]
|
|
340
322
|
})
|
|
341
323
|
);
|
|
342
|
-
const { query:
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
324
|
+
const { query: i, transformBody: a, ...l } = n;
|
|
325
|
+
let u = { ...l };
|
|
326
|
+
return a && (u = a(u)), G({
|
|
327
|
+
config: r,
|
|
328
|
+
endpoint: `/search/${encodeURIComponent(i)}/prepare`,
|
|
329
|
+
body: u,
|
|
330
|
+
signal: s
|
|
348
331
|
});
|
|
349
332
|
},
|
|
350
|
-
search: async (n,
|
|
333
|
+
search: async (n, s) => {
|
|
351
334
|
if (!n.query)
|
|
352
335
|
return m(
|
|
353
|
-
|
|
336
|
+
D({
|
|
354
337
|
operation: "search",
|
|
355
|
-
fields: [
|
|
338
|
+
fields: [R("query", "REQUIRED_FIELD", "query is required")]
|
|
356
339
|
})
|
|
357
340
|
);
|
|
358
|
-
const
|
|
359
|
-
if (
|
|
360
|
-
const { query:
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
}
|
|
371
|
-
|
|
341
|
+
const i = Q(n.pagination, "search");
|
|
342
|
+
if (i) return m(i);
|
|
343
|
+
const { query: a, attributes: l, transformBody: u, ...g } = n;
|
|
344
|
+
let f = {
|
|
345
|
+
facets: e.facets,
|
|
346
|
+
attributes: t(l),
|
|
347
|
+
retrieveFacetCount: !0,
|
|
348
|
+
includeFacetRanges: !0,
|
|
349
|
+
...g
|
|
350
|
+
};
|
|
351
|
+
return u && (f = u(f)), G({
|
|
352
|
+
config: r,
|
|
353
|
+
endpoint: `/search/${encodeURIComponent(a)}/execute`,
|
|
354
|
+
body: f,
|
|
355
|
+
signal: s
|
|
372
356
|
});
|
|
373
357
|
},
|
|
374
|
-
imageSearch: async (n,
|
|
358
|
+
imageSearch: async (n, s) => {
|
|
375
359
|
if (!n.image_data && !n.image_id)
|
|
376
360
|
return m(
|
|
377
|
-
|
|
361
|
+
D({
|
|
378
362
|
operation: "imageSearch",
|
|
379
363
|
fields: [
|
|
380
|
-
|
|
364
|
+
R("image_data", "REQUIRED_FIELD", "image_data or image_id is required")
|
|
381
365
|
]
|
|
382
366
|
})
|
|
383
367
|
);
|
|
384
|
-
const
|
|
385
|
-
if (
|
|
386
|
-
const { attributes:
|
|
387
|
-
|
|
388
|
-
|
|
368
|
+
const i = Q(n.pagination, "imageSearch");
|
|
369
|
+
if (i) return m(i);
|
|
370
|
+
const { attributes: a, transformBody: l, ...u } = n;
|
|
371
|
+
let g = {
|
|
372
|
+
attributes: t(a),
|
|
373
|
+
...u
|
|
374
|
+
};
|
|
375
|
+
return l && (g = l(g)), G({
|
|
376
|
+
config: r,
|
|
389
377
|
endpoint: "/search/image",
|
|
390
|
-
body:
|
|
391
|
-
signal:
|
|
378
|
+
body: g,
|
|
379
|
+
signal: s
|
|
392
380
|
});
|
|
393
381
|
},
|
|
394
|
-
uploadImage: async (n,
|
|
395
|
-
const
|
|
396
|
-
return
|
|
397
|
-
config:
|
|
382
|
+
uploadImage: async (n, s) => {
|
|
383
|
+
const i = new FormData();
|
|
384
|
+
return i.append("image", n), ct({
|
|
385
|
+
config: r,
|
|
398
386
|
endpoint: "/images/upload",
|
|
399
|
-
formData:
|
|
400
|
-
signal:
|
|
387
|
+
formData: i,
|
|
388
|
+
signal: s
|
|
401
389
|
});
|
|
402
390
|
},
|
|
403
|
-
blocks: async (n,
|
|
391
|
+
blocks: async (n, s) => {
|
|
404
392
|
if (!n.blockId)
|
|
405
393
|
return m(
|
|
406
|
-
|
|
394
|
+
D({
|
|
407
395
|
operation: "block",
|
|
408
|
-
fields: [
|
|
396
|
+
fields: [R("blockId", "REQUIRED_FIELD", "blockId is required")]
|
|
409
397
|
})
|
|
410
398
|
);
|
|
411
|
-
const
|
|
412
|
-
if (
|
|
413
|
-
const { blockId:
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
}
|
|
424
|
-
|
|
399
|
+
const i = Q(n.pagination, "block");
|
|
400
|
+
if (i) return m(i);
|
|
401
|
+
const { blockId: a, attributes: l, transformBody: u, ...g } = n;
|
|
402
|
+
let f = {
|
|
403
|
+
facets: e.facets,
|
|
404
|
+
attributes: t(l),
|
|
405
|
+
retrieveFacetCount: !0,
|
|
406
|
+
includeFacetRanges: !0,
|
|
407
|
+
...g
|
|
408
|
+
};
|
|
409
|
+
return u && (f = u(f)), G({
|
|
410
|
+
config: r,
|
|
411
|
+
endpoint: `/blocks/${a}/products`,
|
|
412
|
+
body: f,
|
|
413
|
+
signal: s
|
|
425
414
|
});
|
|
426
415
|
},
|
|
427
|
-
similarProducts: async (n,
|
|
416
|
+
similarProducts: async (n, s) => {
|
|
428
417
|
if (!n.productId)
|
|
429
418
|
return m(
|
|
430
|
-
|
|
419
|
+
D({
|
|
431
420
|
operation: "similarProducts",
|
|
432
|
-
fields: [
|
|
421
|
+
fields: [R("productId", "REQUIRED_FIELD", "productId is required")]
|
|
433
422
|
})
|
|
434
423
|
);
|
|
435
|
-
const
|
|
436
|
-
if (
|
|
437
|
-
const { productId:
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
424
|
+
const i = Q(n.pagination, "similarProducts");
|
|
425
|
+
if (i) return m(i);
|
|
426
|
+
const { productId: a, attributes: l, transformBody: u, ...g } = n;
|
|
427
|
+
let f = {
|
|
428
|
+
attributes: t(l),
|
|
429
|
+
...g
|
|
430
|
+
};
|
|
431
|
+
return u && (f = u(f)), G({
|
|
432
|
+
config: r,
|
|
433
|
+
endpoint: `/search/product/${a}`,
|
|
434
|
+
body: f,
|
|
435
|
+
signal: s
|
|
443
436
|
});
|
|
444
437
|
}
|
|
445
438
|
});
|
|
446
439
|
}
|
|
447
|
-
const
|
|
440
|
+
const te = `
|
|
448
441
|
fragment SeoFields on SEO {
|
|
449
442
|
title
|
|
450
443
|
description
|
|
451
444
|
}
|
|
452
|
-
`,
|
|
445
|
+
`, $e = `
|
|
453
446
|
fragment FilterValueFields on FilterValue {
|
|
454
447
|
id
|
|
455
448
|
label
|
|
456
449
|
count
|
|
457
450
|
input
|
|
458
451
|
}
|
|
459
|
-
`,
|
|
452
|
+
`, Le = `
|
|
460
453
|
fragment FilterFields on Filter {
|
|
461
454
|
id
|
|
462
455
|
label
|
|
463
456
|
type
|
|
464
457
|
values { ...FilterValueFields }
|
|
465
458
|
}
|
|
466
|
-
`,
|
|
459
|
+
`, re = `
|
|
467
460
|
fragment ImageFields on Image {
|
|
468
461
|
url
|
|
469
462
|
altText
|
|
470
463
|
width
|
|
471
464
|
height
|
|
472
465
|
}
|
|
473
|
-
`,
|
|
466
|
+
`, ve = `
|
|
474
467
|
fragment MoneyFields on MoneyV2 {
|
|
475
468
|
amount
|
|
476
469
|
currencyCode
|
|
@@ -480,7 +473,7 @@ const ie = `
|
|
|
480
473
|
name
|
|
481
474
|
value
|
|
482
475
|
}
|
|
483
|
-
`,
|
|
476
|
+
`, Me = `
|
|
484
477
|
fragment PriceRangeFields on ProductPriceRange {
|
|
485
478
|
minVariantPrice { ...MoneyFields }
|
|
486
479
|
maxVariantPrice { ...MoneyFields }
|
|
@@ -500,7 +493,7 @@ const ie = `
|
|
|
500
493
|
}
|
|
501
494
|
}
|
|
502
495
|
}
|
|
503
|
-
`,
|
|
496
|
+
`, z = `
|
|
504
497
|
fragment MetafieldFields on Metafield {
|
|
505
498
|
namespace
|
|
506
499
|
key
|
|
@@ -508,7 +501,7 @@ const ie = `
|
|
|
508
501
|
type
|
|
509
502
|
}
|
|
510
503
|
`;
|
|
511
|
-
function
|
|
504
|
+
function Pe(e) {
|
|
512
505
|
return `
|
|
513
506
|
fragment VariantFields on ProductVariant {
|
|
514
507
|
id
|
|
@@ -529,8 +522,8 @@ function Re(e) {
|
|
|
529
522
|
}
|
|
530
523
|
`;
|
|
531
524
|
}
|
|
532
|
-
function
|
|
533
|
-
const { maxImages: t, maxVariants: r, includeProductMetafields:
|
|
525
|
+
function Re(e) {
|
|
526
|
+
const { maxImages: t, maxVariants: r, includeProductMetafields: o } = e;
|
|
534
527
|
return `
|
|
535
528
|
fragment ProductFields on Product {
|
|
536
529
|
id
|
|
@@ -552,11 +545,11 @@ function we(e) {
|
|
|
552
545
|
options { ...ProductOptionFields }
|
|
553
546
|
variants(first: ${r}) { nodes { ...VariantFields } }
|
|
554
547
|
selectedOrFirstAvailableVariant { ...VariantFields }
|
|
555
|
-
${
|
|
548
|
+
${o ? "metafields(identifiers: $productMetafields) { ...MetafieldFields }" : ""}
|
|
556
549
|
}
|
|
557
550
|
`;
|
|
558
551
|
}
|
|
559
|
-
function
|
|
552
|
+
function Ue(e) {
|
|
560
553
|
return `
|
|
561
554
|
fragment CollectionFields on Collection {
|
|
562
555
|
id
|
|
@@ -571,7 +564,7 @@ function Ge(e) {
|
|
|
571
564
|
}
|
|
572
565
|
`;
|
|
573
566
|
}
|
|
574
|
-
function
|
|
567
|
+
function Ve(e) {
|
|
575
568
|
return `
|
|
576
569
|
fragment PageFields on Page {
|
|
577
570
|
id
|
|
@@ -587,36 +580,36 @@ function He(e) {
|
|
|
587
580
|
}
|
|
588
581
|
`;
|
|
589
582
|
}
|
|
590
|
-
function
|
|
583
|
+
function dt(e) {
|
|
591
584
|
const { includeProductMetafields: t, includeVariantMetafields: r } = e;
|
|
592
585
|
return [
|
|
593
|
-
|
|
594
|
-
|
|
586
|
+
re,
|
|
587
|
+
ve,
|
|
595
588
|
Fe,
|
|
596
|
-
|
|
589
|
+
Me,
|
|
597
590
|
Se,
|
|
598
|
-
t || r ?
|
|
599
|
-
|
|
600
|
-
|
|
591
|
+
t || r ? z : "",
|
|
592
|
+
Pe(r),
|
|
593
|
+
Re(e)
|
|
601
594
|
].join(`
|
|
602
595
|
`);
|
|
603
596
|
}
|
|
604
|
-
function
|
|
597
|
+
function ft(e = {}) {
|
|
605
598
|
const {
|
|
606
|
-
maxImages: t =
|
|
607
|
-
maxVariants: r =
|
|
608
|
-
productMetafields:
|
|
609
|
-
variantMetafields:
|
|
610
|
-
} = e,
|
|
611
|
-
return
|
|
612
|
-
${
|
|
599
|
+
maxImages: t = H,
|
|
600
|
+
maxVariants: r = j,
|
|
601
|
+
productMetafields: o = [],
|
|
602
|
+
variantMetafields: n = []
|
|
603
|
+
} = e, s = o.length > 0, i = n.length > 0, a = ["$ids: [ID!]!"];
|
|
604
|
+
return s && a.push("$productMetafields: [HasMetafieldsIdentifier!]!"), i && a.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
605
|
+
${dt({
|
|
613
606
|
maxImages: t,
|
|
614
607
|
maxVariants: r,
|
|
615
|
-
includeProductMetafields:
|
|
616
|
-
includeVariantMetafields:
|
|
608
|
+
includeProductMetafields: s,
|
|
609
|
+
includeVariantMetafields: i
|
|
617
610
|
})}
|
|
618
611
|
|
|
619
|
-
query ProductsByIds(${
|
|
612
|
+
query ProductsByIds(${a.join(", ")}) {
|
|
620
613
|
nodes(ids: $ids) {
|
|
621
614
|
... on Product {
|
|
622
615
|
...ProductFields
|
|
@@ -625,40 +618,40 @@ function dt(e = {}) {
|
|
|
625
618
|
}
|
|
626
619
|
`;
|
|
627
620
|
}
|
|
628
|
-
function
|
|
621
|
+
function gt(e = {}) {
|
|
629
622
|
const {
|
|
630
|
-
maxImages: t =
|
|
631
|
-
maxVariants: r =
|
|
632
|
-
productMetafields:
|
|
633
|
-
variantMetafields:
|
|
634
|
-
collectionMetafields:
|
|
635
|
-
includeFilters:
|
|
636
|
-
} = e,
|
|
637
|
-
return
|
|
623
|
+
maxImages: t = H,
|
|
624
|
+
maxVariants: r = j,
|
|
625
|
+
productMetafields: o = [],
|
|
626
|
+
variantMetafields: n = [],
|
|
627
|
+
collectionMetafields: s = [],
|
|
628
|
+
includeFilters: i = !1
|
|
629
|
+
} = e, a = o.length > 0, l = n.length > 0, u = s.length > 0, g = a || l || u, f = ["$ids: [ID!]!", "$handle: String!"];
|
|
630
|
+
return a && f.push("$productMetafields: [HasMetafieldsIdentifier!]!"), l && f.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), u && f.push("$collectionMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
638
631
|
${[
|
|
639
|
-
|
|
640
|
-
|
|
632
|
+
re,
|
|
633
|
+
ve,
|
|
641
634
|
Fe,
|
|
642
|
-
|
|
635
|
+
Me,
|
|
643
636
|
Se,
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
637
|
+
te,
|
|
638
|
+
g ? z : "",
|
|
639
|
+
i ? $e : "",
|
|
640
|
+
i ? Le : "",
|
|
641
|
+
Pe(l),
|
|
642
|
+
Re({
|
|
650
643
|
maxImages: t,
|
|
651
644
|
maxVariants: r,
|
|
652
|
-
includeProductMetafields:
|
|
645
|
+
includeProductMetafields: a
|
|
653
646
|
}),
|
|
654
|
-
|
|
647
|
+
Ue(u)
|
|
655
648
|
].join(`
|
|
656
649
|
`)}
|
|
657
650
|
|
|
658
|
-
query CollectionWithProducts(${
|
|
651
|
+
query CollectionWithProducts(${f.join(", ")}) {
|
|
659
652
|
collection(handle: $handle) {
|
|
660
653
|
...CollectionFields
|
|
661
|
-
${
|
|
654
|
+
${i ? "products(first: 1) { filters { ...FilterFields } }" : ""}
|
|
662
655
|
}
|
|
663
656
|
nodes(ids: $ids) {
|
|
664
657
|
... on Product {
|
|
@@ -668,20 +661,20 @@ function ft(e = {}) {
|
|
|
668
661
|
}
|
|
669
662
|
`;
|
|
670
663
|
}
|
|
671
|
-
function
|
|
672
|
-
const { collectionMetafields: t = [], includeFilters: r = !1 } = e,
|
|
673
|
-
return
|
|
664
|
+
function mt(e = {}) {
|
|
665
|
+
const { collectionMetafields: t = [], includeFilters: r = !1 } = e, o = t.length > 0, n = ["$handle: String!"];
|
|
666
|
+
return o && n.push("$collectionMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
674
667
|
${[
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
668
|
+
re,
|
|
669
|
+
te,
|
|
670
|
+
o ? z : "",
|
|
671
|
+
r ? $e : "",
|
|
678
672
|
r ? Le : "",
|
|
679
|
-
|
|
680
|
-
Ge(s)
|
|
673
|
+
Ue(o)
|
|
681
674
|
].join(`
|
|
682
675
|
`)}
|
|
683
676
|
|
|
684
|
-
query Collection(${
|
|
677
|
+
query Collection(${n.join(", ")}) {
|
|
685
678
|
collection(handle: $handle) {
|
|
686
679
|
...CollectionFields
|
|
687
680
|
${r ? "products(first: 1) { filters { ...FilterFields } }" : ""}
|
|
@@ -690,50 +683,50 @@ function gt(e = {}) {
|
|
|
690
683
|
`;
|
|
691
684
|
}
|
|
692
685
|
function pt(e = {}) {
|
|
693
|
-
const { pageMetafields: t = [] } = e, r = t.length > 0,
|
|
694
|
-
return r &&
|
|
686
|
+
const { pageMetafields: t = [] } = e, r = t.length > 0, o = ["$handle: String!"];
|
|
687
|
+
return r && o.push("$pageMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
695
688
|
${[
|
|
696
|
-
|
|
697
|
-
r ?
|
|
698
|
-
|
|
689
|
+
te,
|
|
690
|
+
r ? z : "",
|
|
691
|
+
Ve(r)
|
|
699
692
|
].join(`
|
|
700
693
|
`)}
|
|
701
694
|
|
|
702
|
-
query Page(${
|
|
695
|
+
query Page(${o.join(", ")}) {
|
|
703
696
|
page(handle: $handle) {
|
|
704
697
|
...PageFields
|
|
705
698
|
}
|
|
706
699
|
}
|
|
707
700
|
`;
|
|
708
701
|
}
|
|
709
|
-
function
|
|
702
|
+
function ht(e = {}) {
|
|
710
703
|
const {
|
|
711
|
-
maxImages: t =
|
|
712
|
-
maxVariants: r =
|
|
713
|
-
productMetafields:
|
|
714
|
-
variantMetafields:
|
|
715
|
-
pageMetafields:
|
|
716
|
-
} = e,
|
|
717
|
-
return
|
|
704
|
+
maxImages: t = H,
|
|
705
|
+
maxVariants: r = j,
|
|
706
|
+
productMetafields: o = [],
|
|
707
|
+
variantMetafields: n = [],
|
|
708
|
+
pageMetafields: s = []
|
|
709
|
+
} = e, i = o.length > 0, a = n.length > 0, l = s.length > 0, u = i || a || l, g = ["$ids: [ID!]!", "$handle: String!"];
|
|
710
|
+
return i && g.push("$productMetafields: [HasMetafieldsIdentifier!]!"), a && g.push("$variantMetafields: [HasMetafieldsIdentifier!]!"), l && g.push("$pageMetafields: [HasMetafieldsIdentifier!]!"), `
|
|
718
711
|
${[
|
|
719
|
-
|
|
720
|
-
|
|
712
|
+
re,
|
|
713
|
+
ve,
|
|
721
714
|
Fe,
|
|
722
|
-
|
|
715
|
+
Me,
|
|
723
716
|
Se,
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
717
|
+
te,
|
|
718
|
+
u ? z : "",
|
|
719
|
+
Pe(a),
|
|
720
|
+
Re({
|
|
728
721
|
maxImages: t,
|
|
729
722
|
maxVariants: r,
|
|
730
|
-
includeProductMetafields:
|
|
723
|
+
includeProductMetafields: i
|
|
731
724
|
}),
|
|
732
|
-
|
|
725
|
+
Ve(l)
|
|
733
726
|
].join(`
|
|
734
727
|
`)}
|
|
735
728
|
|
|
736
|
-
query PageWithProducts(${
|
|
729
|
+
query PageWithProducts(${g.join(", ")}) {
|
|
737
730
|
page(handle: $handle) {
|
|
738
731
|
...PageFields
|
|
739
732
|
}
|
|
@@ -745,41 +738,41 @@ function mt(e = {}) {
|
|
|
745
738
|
}
|
|
746
739
|
`;
|
|
747
740
|
}
|
|
748
|
-
function
|
|
741
|
+
function yt({
|
|
749
742
|
shop: e,
|
|
750
743
|
token: t,
|
|
751
744
|
apiVersion: r,
|
|
752
|
-
customFetch:
|
|
745
|
+
customFetch: o = fetch
|
|
753
746
|
}) {
|
|
754
|
-
const
|
|
747
|
+
const n = `https://${e}/api/${r}/graphql.json`;
|
|
755
748
|
return {
|
|
756
|
-
async request(
|
|
757
|
-
const
|
|
749
|
+
async request(s, { variables: i, signal: a } = {}) {
|
|
750
|
+
const l = await o(n, {
|
|
758
751
|
method: "POST",
|
|
759
752
|
headers: {
|
|
760
753
|
"Content-Type": "application/json",
|
|
761
754
|
"X-Shopify-Storefront-Access-Token": t
|
|
762
755
|
},
|
|
763
|
-
body: JSON.stringify({ query:
|
|
764
|
-
signal:
|
|
756
|
+
body: JSON.stringify({ query: s, variables: i }),
|
|
757
|
+
signal: a
|
|
765
758
|
});
|
|
766
|
-
if (!
|
|
759
|
+
if (!l.ok)
|
|
767
760
|
return {
|
|
768
761
|
data: null,
|
|
769
|
-
errors: { message: `HTTP ${
|
|
762
|
+
errors: { message: `HTTP ${l.status}`, networkStatusCode: l.status }
|
|
770
763
|
};
|
|
771
|
-
const
|
|
772
|
-
return
|
|
764
|
+
const u = await l.json();
|
|
765
|
+
return u.errors ? { data: u.data, errors: { graphQLErrors: u.errors } } : { data: u.data };
|
|
773
766
|
}
|
|
774
767
|
};
|
|
775
768
|
}
|
|
776
|
-
function
|
|
769
|
+
function ge({ ids: e, maxSize: t }) {
|
|
777
770
|
const r = [];
|
|
778
|
-
for (let
|
|
779
|
-
r.push(e.slice(
|
|
771
|
+
for (let o = 0; o < e.length; o += t)
|
|
772
|
+
r.push(e.slice(o, o + t));
|
|
780
773
|
return r;
|
|
781
774
|
}
|
|
782
|
-
function
|
|
775
|
+
function Et(e) {
|
|
783
776
|
if (!e.storefrontPublicToken)
|
|
784
777
|
return m(
|
|
785
778
|
B({
|
|
@@ -798,225 +791,225 @@ function yt(e) {
|
|
|
798
791
|
expected: "non-empty string"
|
|
799
792
|
})
|
|
800
793
|
);
|
|
801
|
-
const { storefrontApiVersion: t =
|
|
794
|
+
const { storefrontApiVersion: t = Qe } = e, r = yt({
|
|
802
795
|
shop: e.shop,
|
|
803
796
|
token: e.storefrontPublicToken,
|
|
804
797
|
apiVersion: t,
|
|
805
798
|
customFetch: e.fetch
|
|
806
799
|
});
|
|
807
|
-
return
|
|
808
|
-
async getProducts(
|
|
800
|
+
return M({
|
|
801
|
+
async getProducts(n) {
|
|
809
802
|
const {
|
|
810
|
-
ids:
|
|
811
|
-
productMetafields:
|
|
812
|
-
variantMetafields:
|
|
813
|
-
maxImages:
|
|
814
|
-
maxVariants:
|
|
815
|
-
signal:
|
|
816
|
-
} =
|
|
817
|
-
if (
|
|
818
|
-
return m(
|
|
819
|
-
if (
|
|
820
|
-
return
|
|
821
|
-
const
|
|
822
|
-
maxImages:
|
|
823
|
-
maxVariants:
|
|
824
|
-
productMetafields:
|
|
825
|
-
variantMetafields:
|
|
826
|
-
}),
|
|
827
|
-
for (const
|
|
828
|
-
const
|
|
829
|
-
|
|
830
|
-
const
|
|
831
|
-
if (
|
|
832
|
-
return
|
|
833
|
-
|
|
803
|
+
ids: s,
|
|
804
|
+
productMetafields: i = [],
|
|
805
|
+
variantMetafields: a = [],
|
|
806
|
+
maxImages: l = H,
|
|
807
|
+
maxVariants: u = j,
|
|
808
|
+
signal: g
|
|
809
|
+
} = n, f = me(n);
|
|
810
|
+
if (f.length > 0)
|
|
811
|
+
return m(D({ operation: "getProducts", fields: f }));
|
|
812
|
+
if (s.length === 0)
|
|
813
|
+
return M([]);
|
|
814
|
+
const c = ft({
|
|
815
|
+
maxImages: l,
|
|
816
|
+
maxVariants: u,
|
|
817
|
+
productMetafields: i,
|
|
818
|
+
variantMetafields: a
|
|
819
|
+
}), d = ge({ ids: s, maxSize: se }), p = [];
|
|
820
|
+
for (const h of d) {
|
|
821
|
+
const y = { ids: h };
|
|
822
|
+
i.length > 0 && (y.productMetafields = i), a.length > 0 && (y.variantMetafields = a);
|
|
823
|
+
const I = await _t({ shopifyClient: r, query: c, variables: y, signal: g });
|
|
824
|
+
if (I.error)
|
|
825
|
+
return I;
|
|
826
|
+
p.push(...I.data);
|
|
834
827
|
}
|
|
835
|
-
return
|
|
828
|
+
return M(p);
|
|
836
829
|
},
|
|
837
|
-
async getCollection(
|
|
838
|
-
const { handle:
|
|
839
|
-
if (!
|
|
830
|
+
async getCollection(n) {
|
|
831
|
+
const { handle: s, collectionMetafields: i = [], includeFilters: a = !1, signal: l } = n;
|
|
832
|
+
if (!s)
|
|
840
833
|
return m(
|
|
841
|
-
|
|
834
|
+
D({
|
|
842
835
|
operation: "getCollection",
|
|
843
|
-
fields: [
|
|
836
|
+
fields: [R("handle", "REQUIRED_FIELD", "handle is required")]
|
|
844
837
|
})
|
|
845
838
|
);
|
|
846
|
-
const
|
|
847
|
-
|
|
839
|
+
const u = mt({ collectionMetafields: i, includeFilters: a }), g = { handle: s };
|
|
840
|
+
i.length > 0 && (g.collectionMetafields = i);
|
|
848
841
|
try {
|
|
849
|
-
const { data:
|
|
850
|
-
if (
|
|
851
|
-
return m(
|
|
852
|
-
const
|
|
853
|
-
return
|
|
854
|
-
|
|
842
|
+
const { data: f, errors: c } = await r.request(u, { variables: g, signal: l });
|
|
843
|
+
if (c)
|
|
844
|
+
return m(W(c));
|
|
845
|
+
const d = f;
|
|
846
|
+
return d.collection ? M(d.collection) : m(
|
|
847
|
+
O({
|
|
855
848
|
code: "NOT_FOUND",
|
|
856
849
|
source: "shopify",
|
|
857
|
-
message: `Collection not found: ${
|
|
850
|
+
message: `Collection not found: ${s}`
|
|
858
851
|
})
|
|
859
852
|
);
|
|
860
|
-
} catch (
|
|
861
|
-
return m(
|
|
853
|
+
} catch (f) {
|
|
854
|
+
return m(K(f));
|
|
862
855
|
}
|
|
863
856
|
},
|
|
864
|
-
async getCollectionWithProducts(
|
|
857
|
+
async getCollectionWithProducts(n) {
|
|
865
858
|
const {
|
|
866
|
-
handle:
|
|
867
|
-
ids:
|
|
868
|
-
productMetafields:
|
|
869
|
-
variantMetafields:
|
|
870
|
-
collectionMetafields:
|
|
871
|
-
includeFilters:
|
|
872
|
-
maxImages:
|
|
873
|
-
maxVariants:
|
|
874
|
-
signal:
|
|
875
|
-
} =
|
|
876
|
-
if (
|
|
859
|
+
handle: s,
|
|
860
|
+
ids: i,
|
|
861
|
+
productMetafields: a = [],
|
|
862
|
+
variantMetafields: l = [],
|
|
863
|
+
collectionMetafields: u = [],
|
|
864
|
+
includeFilters: g = !1,
|
|
865
|
+
maxImages: f = H,
|
|
866
|
+
maxVariants: c = j,
|
|
867
|
+
signal: d
|
|
868
|
+
} = n, p = me(n);
|
|
869
|
+
if (s || p.push(R("handle", "REQUIRED_FIELD", "handle is required")), p.length > 0)
|
|
877
870
|
return m(
|
|
878
|
-
|
|
871
|
+
D({
|
|
879
872
|
operation: "getCollectionWithProducts",
|
|
880
|
-
fields:
|
|
873
|
+
fields: p
|
|
881
874
|
})
|
|
882
875
|
);
|
|
883
|
-
const
|
|
884
|
-
maxImages:
|
|
885
|
-
maxVariants:
|
|
886
|
-
productMetafields:
|
|
887
|
-
variantMetafields:
|
|
888
|
-
collectionMetafields:
|
|
889
|
-
includeFilters:
|
|
890
|
-
}),
|
|
891
|
-
let
|
|
892
|
-
const
|
|
893
|
-
for (let v = 0; v <
|
|
894
|
-
const
|
|
895
|
-
|
|
876
|
+
const h = gt({
|
|
877
|
+
maxImages: f,
|
|
878
|
+
maxVariants: c,
|
|
879
|
+
productMetafields: a,
|
|
880
|
+
variantMetafields: l,
|
|
881
|
+
collectionMetafields: u,
|
|
882
|
+
includeFilters: g
|
|
883
|
+
}), y = i.length > 0 ? ge({ ids: i, maxSize: se }) : [[]];
|
|
884
|
+
let I = null;
|
|
885
|
+
const b = [];
|
|
886
|
+
for (let v = 0; v < y.length; v++) {
|
|
887
|
+
const E = { ids: y[v], handle: s };
|
|
888
|
+
a.length > 0 && (E.productMetafields = a), l.length > 0 && (E.variantMetafields = l), u.length > 0 && (E.collectionMetafields = u);
|
|
896
889
|
try {
|
|
897
|
-
const { data:
|
|
898
|
-
if (
|
|
899
|
-
return m(
|
|
900
|
-
const
|
|
901
|
-
if (v === 0 && (
|
|
890
|
+
const { data: F, errors: P } = await r.request(h, { variables: E, signal: d });
|
|
891
|
+
if (P)
|
|
892
|
+
return m(W(P));
|
|
893
|
+
const A = F;
|
|
894
|
+
if (v === 0 && (I = A.collection ?? null, !I))
|
|
902
895
|
return m(
|
|
903
|
-
|
|
896
|
+
O({
|
|
904
897
|
code: "NOT_FOUND",
|
|
905
898
|
source: "shopify",
|
|
906
|
-
message: `Collection not found: ${
|
|
899
|
+
message: `Collection not found: ${s}`
|
|
907
900
|
})
|
|
908
901
|
);
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
} catch (
|
|
912
|
-
return m(
|
|
902
|
+
const _ = (A.nodes ?? []).filter((C) => C !== null);
|
|
903
|
+
b.push(..._);
|
|
904
|
+
} catch (F) {
|
|
905
|
+
return m(K(F));
|
|
913
906
|
}
|
|
914
907
|
}
|
|
915
|
-
return
|
|
908
|
+
return M({ collection: I, products: b });
|
|
916
909
|
},
|
|
917
|
-
async getPage(
|
|
918
|
-
const { handle:
|
|
919
|
-
if (!
|
|
910
|
+
async getPage(n) {
|
|
911
|
+
const { handle: s, pageMetafields: i = [], signal: a } = n;
|
|
912
|
+
if (!s)
|
|
920
913
|
return m(
|
|
921
|
-
|
|
914
|
+
D({
|
|
922
915
|
operation: "getPage",
|
|
923
|
-
fields: [
|
|
916
|
+
fields: [R("handle", "REQUIRED_FIELD", "handle is required")]
|
|
924
917
|
})
|
|
925
918
|
);
|
|
926
|
-
const
|
|
927
|
-
|
|
919
|
+
const l = pt({ pageMetafields: i }), u = { handle: s };
|
|
920
|
+
i.length > 0 && (u.pageMetafields = i);
|
|
928
921
|
try {
|
|
929
|
-
const { data:
|
|
930
|
-
if (
|
|
931
|
-
return m(
|
|
932
|
-
const
|
|
933
|
-
return
|
|
934
|
-
|
|
922
|
+
const { data: g, errors: f } = await r.request(l, { variables: u, signal: a });
|
|
923
|
+
if (f)
|
|
924
|
+
return m(W(f));
|
|
925
|
+
const c = g;
|
|
926
|
+
return c.page ? M(c.page) : m(
|
|
927
|
+
O({
|
|
935
928
|
code: "NOT_FOUND",
|
|
936
929
|
source: "shopify",
|
|
937
|
-
message: `Page not found: ${
|
|
930
|
+
message: `Page not found: ${s}`
|
|
938
931
|
})
|
|
939
932
|
);
|
|
940
|
-
} catch (
|
|
941
|
-
return m(
|
|
933
|
+
} catch (g) {
|
|
934
|
+
return m(K(g));
|
|
942
935
|
}
|
|
943
936
|
},
|
|
944
|
-
async getPageWithProducts(
|
|
937
|
+
async getPageWithProducts(n) {
|
|
945
938
|
const {
|
|
946
|
-
handle:
|
|
947
|
-
ids:
|
|
948
|
-
productMetafields:
|
|
949
|
-
variantMetafields:
|
|
950
|
-
pageMetafields:
|
|
951
|
-
maxImages:
|
|
952
|
-
maxVariants:
|
|
953
|
-
signal:
|
|
954
|
-
} =
|
|
955
|
-
if (
|
|
939
|
+
handle: s,
|
|
940
|
+
ids: i,
|
|
941
|
+
productMetafields: a = [],
|
|
942
|
+
variantMetafields: l = [],
|
|
943
|
+
pageMetafields: u = [],
|
|
944
|
+
maxImages: g = H,
|
|
945
|
+
maxVariants: f = j,
|
|
946
|
+
signal: c
|
|
947
|
+
} = n, d = me(n);
|
|
948
|
+
if (s || d.push(R("handle", "REQUIRED_FIELD", "handle is required")), d.length > 0)
|
|
956
949
|
return m(
|
|
957
|
-
|
|
950
|
+
D({ operation: "getPageWithProducts", fields: d })
|
|
958
951
|
);
|
|
959
|
-
const
|
|
960
|
-
maxImages:
|
|
961
|
-
maxVariants:
|
|
962
|
-
productMetafields:
|
|
963
|
-
variantMetafields:
|
|
964
|
-
pageMetafields:
|
|
965
|
-
}),
|
|
966
|
-
let
|
|
967
|
-
const
|
|
968
|
-
for (let
|
|
969
|
-
const
|
|
970
|
-
|
|
952
|
+
const p = ht({
|
|
953
|
+
maxImages: g,
|
|
954
|
+
maxVariants: f,
|
|
955
|
+
productMetafields: a,
|
|
956
|
+
variantMetafields: l,
|
|
957
|
+
pageMetafields: u
|
|
958
|
+
}), h = i.length > 0 ? ge({ ids: i, maxSize: se }) : [[]];
|
|
959
|
+
let y = null;
|
|
960
|
+
const I = [];
|
|
961
|
+
for (let b = 0; b < h.length; b++) {
|
|
962
|
+
const S = { ids: h[b], handle: s };
|
|
963
|
+
a.length > 0 && (S.productMetafields = a), l.length > 0 && (S.variantMetafields = l), u.length > 0 && (S.pageMetafields = u);
|
|
971
964
|
try {
|
|
972
|
-
const { data:
|
|
973
|
-
if (
|
|
974
|
-
return m(
|
|
975
|
-
const
|
|
976
|
-
if (
|
|
965
|
+
const { data: E, errors: F } = await r.request(p, { variables: S, signal: c });
|
|
966
|
+
if (F)
|
|
967
|
+
return m(W(F));
|
|
968
|
+
const P = E;
|
|
969
|
+
if (b === 0 && (y = P.page ?? null, !y))
|
|
977
970
|
return m(
|
|
978
|
-
|
|
971
|
+
O({
|
|
979
972
|
code: "NOT_FOUND",
|
|
980
973
|
source: "shopify",
|
|
981
|
-
message: `Page not found: ${
|
|
974
|
+
message: `Page not found: ${s}`
|
|
982
975
|
})
|
|
983
976
|
);
|
|
984
|
-
const
|
|
985
|
-
|
|
986
|
-
} catch (
|
|
987
|
-
return m(
|
|
977
|
+
const A = (P.nodes ?? []).filter((_) => _ !== null);
|
|
978
|
+
I.push(...A);
|
|
979
|
+
} catch (E) {
|
|
980
|
+
return m(K(E));
|
|
988
981
|
}
|
|
989
982
|
}
|
|
990
|
-
return
|
|
983
|
+
return M({ page: y, products: I });
|
|
991
984
|
}
|
|
992
985
|
});
|
|
993
986
|
}
|
|
994
987
|
function me(e) {
|
|
995
988
|
const t = [];
|
|
996
|
-
e.maxImages !== void 0 && (e.maxImages <
|
|
997
|
-
|
|
989
|
+
e.maxImages !== void 0 && (e.maxImages < ce || e.maxImages > ie) && t.push(
|
|
990
|
+
R(
|
|
998
991
|
"maxImages",
|
|
999
992
|
"OUT_OF_RANGE",
|
|
1000
|
-
`maxImages must be between ${
|
|
993
|
+
`maxImages must be between ${ce} and ${ie}`,
|
|
1001
994
|
{
|
|
1002
995
|
value: e.maxImages,
|
|
1003
|
-
constraints: { min:
|
|
996
|
+
constraints: { min: ce, max: ie }
|
|
1004
997
|
}
|
|
1005
998
|
)
|
|
1006
|
-
), e.maxVariants !== void 0 && (e.maxVariants <
|
|
1007
|
-
|
|
999
|
+
), e.maxVariants !== void 0 && (e.maxVariants < le || e.maxVariants > ae) && t.push(
|
|
1000
|
+
R(
|
|
1008
1001
|
"maxVariants",
|
|
1009
1002
|
"OUT_OF_RANGE",
|
|
1010
|
-
`maxVariants must be between ${
|
|
1003
|
+
`maxVariants must be between ${le} and ${ae}`,
|
|
1011
1004
|
{
|
|
1012
1005
|
value: e.maxVariants,
|
|
1013
|
-
constraints: { min:
|
|
1006
|
+
constraints: { min: le, max: ae }
|
|
1014
1007
|
}
|
|
1015
1008
|
)
|
|
1016
1009
|
);
|
|
1017
1010
|
for (const r of e.productMetafields ?? [])
|
|
1018
1011
|
(!r.namespace || !r.key) && t.push(
|
|
1019
|
-
|
|
1012
|
+
R(
|
|
1020
1013
|
"productMetafields",
|
|
1021
1014
|
"REQUIRED_FIELD",
|
|
1022
1015
|
"Metafield identifier requires both namespace and key",
|
|
@@ -1028,7 +1021,7 @@ function me(e) {
|
|
|
1028
1021
|
);
|
|
1029
1022
|
for (const r of e.variantMetafields ?? [])
|
|
1030
1023
|
(!r.namespace || !r.key) && t.push(
|
|
1031
|
-
|
|
1024
|
+
R(
|
|
1032
1025
|
"variantMetafields",
|
|
1033
1026
|
"REQUIRED_FIELD",
|
|
1034
1027
|
"Metafield identifier requires both namespace and key",
|
|
@@ -1040,47 +1033,47 @@ function me(e) {
|
|
|
1040
1033
|
);
|
|
1041
1034
|
return t;
|
|
1042
1035
|
}
|
|
1043
|
-
async function
|
|
1036
|
+
async function _t({
|
|
1044
1037
|
shopifyClient: e,
|
|
1045
1038
|
query: t,
|
|
1046
1039
|
variables: r,
|
|
1047
|
-
signal:
|
|
1040
|
+
signal: o
|
|
1048
1041
|
}) {
|
|
1049
1042
|
try {
|
|
1050
|
-
const { data:
|
|
1051
|
-
if (
|
|
1052
|
-
return m(
|
|
1053
|
-
const
|
|
1054
|
-
(
|
|
1043
|
+
const { data: n, errors: s } = await e.request(t, { variables: r, signal: o });
|
|
1044
|
+
if (s)
|
|
1045
|
+
return m(W(s));
|
|
1046
|
+
const i = (n?.nodes ?? []).filter(
|
|
1047
|
+
(a) => a !== null
|
|
1055
1048
|
);
|
|
1056
|
-
return
|
|
1057
|
-
} catch (
|
|
1058
|
-
return m(
|
|
1049
|
+
return M(i);
|
|
1050
|
+
} catch (n) {
|
|
1051
|
+
return m(K(n));
|
|
1059
1052
|
}
|
|
1060
1053
|
}
|
|
1061
|
-
function
|
|
1054
|
+
function W(e) {
|
|
1062
1055
|
const t = e.networkStatusCode;
|
|
1063
|
-
return t === 401 ?
|
|
1056
|
+
return t === 401 ? O({
|
|
1064
1057
|
code: "UNAUTHORIZED",
|
|
1065
1058
|
source: "shopify",
|
|
1066
1059
|
message: "Unauthorized: Invalid or missing storefront access token",
|
|
1067
1060
|
status: t
|
|
1068
|
-
}) : t === 403 ?
|
|
1061
|
+
}) : t === 403 ? O({
|
|
1069
1062
|
code: "FORBIDDEN",
|
|
1070
1063
|
source: "shopify",
|
|
1071
1064
|
message: "Forbidden: Access denied to the requested resource",
|
|
1072
1065
|
status: t
|
|
1073
|
-
}) : t === 429 ?
|
|
1066
|
+
}) : t === 429 ? O({
|
|
1074
1067
|
code: "RATE_LIMITED",
|
|
1075
1068
|
source: "shopify",
|
|
1076
1069
|
message: "Rate limited: Too many requests to the Storefront API",
|
|
1077
1070
|
status: t
|
|
1078
|
-
}) : t !== void 0 && t >= 500 ?
|
|
1071
|
+
}) : t !== void 0 && t >= 500 ? O({
|
|
1079
1072
|
code: "SERVICE_UNAVAILABLE",
|
|
1080
1073
|
source: "shopify",
|
|
1081
1074
|
message: `Shopify service error: ${e.message ?? `HTTP ${t}`}`,
|
|
1082
1075
|
status: t
|
|
1083
|
-
}) :
|
|
1076
|
+
}) : O({
|
|
1084
1077
|
code: "GRAPHQL_ERROR",
|
|
1085
1078
|
source: "shopify",
|
|
1086
1079
|
message: e.message ?? "GraphQL request failed",
|
|
@@ -1094,269 +1087,329 @@ function Y(e) {
|
|
|
1094
1087
|
}
|
|
1095
1088
|
});
|
|
1096
1089
|
}
|
|
1097
|
-
function
|
|
1090
|
+
function K(e) {
|
|
1098
1091
|
if (e instanceof Error && (e.name === "AbortError" || e.name === "TimeoutError")) {
|
|
1099
1092
|
const t = e.name === "TimeoutError" || e.message.includes("timeout");
|
|
1100
|
-
return
|
|
1093
|
+
return J({
|
|
1101
1094
|
code: t ? "TIMEOUT" : "ABORTED",
|
|
1102
1095
|
message: t ? "Request timed out" : "Request was aborted",
|
|
1103
1096
|
cause: e
|
|
1104
1097
|
});
|
|
1105
1098
|
}
|
|
1106
|
-
return
|
|
1099
|
+
return J({
|
|
1107
1100
|
code: "CONNECTION_FAILED",
|
|
1108
1101
|
message: e instanceof Error ? e.message : "Network request failed",
|
|
1109
1102
|
cause: e
|
|
1110
1103
|
});
|
|
1111
1104
|
}
|
|
1112
|
-
const
|
|
1113
|
-
function
|
|
1105
|
+
const Oe = 1, It = "cb-sdk-store";
|
|
1106
|
+
function pe() {
|
|
1114
1107
|
return typeof window > "u" || !window.localStorage ? null : window.localStorage;
|
|
1115
1108
|
}
|
|
1116
|
-
function
|
|
1117
|
-
typeof requestIdleCallback == "function" ? requestIdleCallback(e, { timeout:
|
|
1109
|
+
function bt(e) {
|
|
1110
|
+
typeof requestIdleCallback == "function" ? requestIdleCallback(e, { timeout: rt }) : setTimeout(e, 0);
|
|
1118
1111
|
}
|
|
1119
|
-
function
|
|
1112
|
+
function Ne(e) {
|
|
1120
1113
|
return [...e].sort((t, r) => r[1].timestamp - t[1].timestamp);
|
|
1121
1114
|
}
|
|
1122
|
-
function
|
|
1123
|
-
storageKey: e =
|
|
1115
|
+
function vt({
|
|
1116
|
+
storageKey: e = It,
|
|
1124
1117
|
maxProducts: t = ke,
|
|
1125
|
-
maxQueries: r =
|
|
1118
|
+
maxQueries: r = qe
|
|
1126
1119
|
} = {}) {
|
|
1127
1120
|
return {
|
|
1128
|
-
save(
|
|
1129
|
-
const
|
|
1130
|
-
|
|
1121
|
+
save(o) {
|
|
1122
|
+
const n = pe();
|
|
1123
|
+
n && bt(() => {
|
|
1131
1124
|
try {
|
|
1132
|
-
const
|
|
1133
|
-
products:
|
|
1125
|
+
const s = {
|
|
1126
|
+
products: Ne(o.products).slice(
|
|
1134
1127
|
0,
|
|
1135
1128
|
t
|
|
1136
1129
|
),
|
|
1137
|
-
queries:
|
|
1138
|
-
collections:
|
|
1139
|
-
version:
|
|
1130
|
+
queries: Ne(o.queries).slice(0, r),
|
|
1131
|
+
collections: o.collections,
|
|
1132
|
+
version: Oe
|
|
1140
1133
|
};
|
|
1141
|
-
|
|
1134
|
+
n.setItem(e, JSON.stringify(s));
|
|
1142
1135
|
} catch {
|
|
1143
1136
|
}
|
|
1144
1137
|
});
|
|
1145
1138
|
},
|
|
1146
1139
|
restore() {
|
|
1147
|
-
const
|
|
1148
|
-
if (!
|
|
1140
|
+
const o = pe();
|
|
1141
|
+
if (!o) return null;
|
|
1149
1142
|
try {
|
|
1150
|
-
const
|
|
1151
|
-
if (!
|
|
1152
|
-
const
|
|
1153
|
-
return
|
|
1143
|
+
const n = o.getItem(e);
|
|
1144
|
+
if (!n) return null;
|
|
1145
|
+
const s = JSON.parse(n);
|
|
1146
|
+
return s.version !== Oe || !Array.isArray(s.products) || !Array.isArray(s.queries) ? (o.removeItem(e), null) : s;
|
|
1154
1147
|
} catch {
|
|
1155
|
-
return
|
|
1148
|
+
return o.removeItem(e), null;
|
|
1156
1149
|
}
|
|
1157
1150
|
},
|
|
1158
1151
|
clear() {
|
|
1159
|
-
|
|
1152
|
+
pe()?.removeItem(e);
|
|
1160
1153
|
}
|
|
1161
1154
|
};
|
|
1162
1155
|
}
|
|
1163
|
-
function
|
|
1156
|
+
function Ft(e, t) {
|
|
1164
1157
|
if (e.size <= t) return;
|
|
1165
|
-
const
|
|
1166
|
-
for (const [
|
|
1167
|
-
e.delete(
|
|
1158
|
+
const o = [...e.entries()].sort((n, s) => n[1].timestamp - s[1].timestamp).slice(0, e.size - t);
|
|
1159
|
+
for (const [n] of o)
|
|
1160
|
+
e.delete(n);
|
|
1168
1161
|
}
|
|
1169
1162
|
function Mt(e, t) {
|
|
1170
1163
|
if (e.size <= t) return;
|
|
1171
1164
|
const r = [];
|
|
1172
|
-
for (const [
|
|
1173
|
-
|
|
1174
|
-
r.sort((
|
|
1175
|
-
const
|
|
1176
|
-
for (const [
|
|
1177
|
-
const
|
|
1178
|
-
|
|
1165
|
+
for (const [n, s] of e)
|
|
1166
|
+
s.value && r.push([n, s.value.timestamp]);
|
|
1167
|
+
r.sort((n, s) => n[1] - s[1]);
|
|
1168
|
+
const o = r.slice(0, e.size - t);
|
|
1169
|
+
for (const [n] of o) {
|
|
1170
|
+
const s = e.get(n);
|
|
1171
|
+
s && (s.value = null), e.delete(n);
|
|
1179
1172
|
}
|
|
1180
1173
|
}
|
|
1181
|
-
function
|
|
1174
|
+
function St(e = {}) {
|
|
1182
1175
|
const {
|
|
1183
1176
|
ttl: t = Xe,
|
|
1184
1177
|
maxProducts: r = ke,
|
|
1185
|
-
maxQueries:
|
|
1186
|
-
storageKey:
|
|
1187
|
-
} = e,
|
|
1188
|
-
function
|
|
1189
|
-
return Date.now() -
|
|
1178
|
+
maxQueries: o = qe,
|
|
1179
|
+
storageKey: n
|
|
1180
|
+
} = e, s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), u = vt({ storageKey: n, maxProducts: r, maxQueries: o });
|
|
1181
|
+
function g(c) {
|
|
1182
|
+
return Date.now() - c > t;
|
|
1190
1183
|
}
|
|
1191
|
-
function
|
|
1192
|
-
let
|
|
1193
|
-
return
|
|
1184
|
+
function f(c) {
|
|
1185
|
+
let d = l.get(c);
|
|
1186
|
+
return d || (d = $(null), l.set(c, d)), d;
|
|
1194
1187
|
}
|
|
1195
1188
|
return {
|
|
1196
1189
|
products: {
|
|
1197
|
-
get(
|
|
1198
|
-
const
|
|
1199
|
-
if (
|
|
1200
|
-
if (
|
|
1201
|
-
|
|
1190
|
+
get(c) {
|
|
1191
|
+
const d = s.get(c);
|
|
1192
|
+
if (d) {
|
|
1193
|
+
if (g(d.timestamp)) {
|
|
1194
|
+
s.delete(c);
|
|
1202
1195
|
return;
|
|
1203
1196
|
}
|
|
1204
|
-
return
|
|
1197
|
+
return d.data;
|
|
1205
1198
|
}
|
|
1206
1199
|
},
|
|
1207
|
-
getMany(
|
|
1208
|
-
const
|
|
1209
|
-
for (const
|
|
1210
|
-
const
|
|
1211
|
-
|
|
1200
|
+
getMany(c) {
|
|
1201
|
+
const d = [], p = [];
|
|
1202
|
+
for (const h of c) {
|
|
1203
|
+
const y = s.get(h);
|
|
1204
|
+
y && !g(y.timestamp) ? d.push(y.data) : p.push(h);
|
|
1212
1205
|
}
|
|
1213
|
-
return { cached:
|
|
1206
|
+
return { cached: d, missing: p };
|
|
1214
1207
|
},
|
|
1215
|
-
set(
|
|
1216
|
-
const
|
|
1217
|
-
for (const
|
|
1218
|
-
|
|
1219
|
-
|
|
1208
|
+
set(c) {
|
|
1209
|
+
const d = Date.now();
|
|
1210
|
+
for (const p of c)
|
|
1211
|
+
s.set(p.gid, { data: p, timestamp: d });
|
|
1212
|
+
Ft(s, r);
|
|
1220
1213
|
},
|
|
1221
|
-
has(
|
|
1222
|
-
const
|
|
1223
|
-
return
|
|
1214
|
+
has(c) {
|
|
1215
|
+
const d = s.get(c);
|
|
1216
|
+
return d != null && !g(d.timestamp);
|
|
1224
1217
|
}
|
|
1225
1218
|
},
|
|
1226
1219
|
queries: {
|
|
1227
|
-
get(
|
|
1228
|
-
return
|
|
1220
|
+
get(c) {
|
|
1221
|
+
return f(c);
|
|
1229
1222
|
},
|
|
1230
|
-
set(
|
|
1231
|
-
const
|
|
1232
|
-
|
|
1223
|
+
set(c, d) {
|
|
1224
|
+
const p = f(c);
|
|
1225
|
+
p.value = { data: d, timestamp: Date.now() }, Mt(l, o);
|
|
1233
1226
|
},
|
|
1234
|
-
isExpired(
|
|
1235
|
-
const
|
|
1236
|
-
return
|
|
1227
|
+
isExpired(c) {
|
|
1228
|
+
const d = l.get(c);
|
|
1229
|
+
return d?.value ? g(d.value.timestamp) : !0;
|
|
1237
1230
|
},
|
|
1238
|
-
invalidate(
|
|
1239
|
-
for (const [
|
|
1240
|
-
|
|
1231
|
+
invalidate(c) {
|
|
1232
|
+
for (const [d, p] of l)
|
|
1233
|
+
d.includes(c) && (p.value = null);
|
|
1241
1234
|
}
|
|
1242
1235
|
},
|
|
1243
1236
|
collections: {
|
|
1244
|
-
get(
|
|
1245
|
-
return
|
|
1237
|
+
get(c) {
|
|
1238
|
+
return i.get(c);
|
|
1246
1239
|
},
|
|
1247
|
-
set(
|
|
1248
|
-
|
|
1240
|
+
set(c, d) {
|
|
1241
|
+
i.set(c, { ...d, handle: c });
|
|
1249
1242
|
},
|
|
1250
|
-
delete(
|
|
1251
|
-
|
|
1243
|
+
delete(c) {
|
|
1244
|
+
i.delete(c);
|
|
1252
1245
|
}
|
|
1253
1246
|
},
|
|
1254
1247
|
pages: {
|
|
1255
|
-
get(
|
|
1256
|
-
return
|
|
1248
|
+
get(c) {
|
|
1249
|
+
return a.get(c);
|
|
1257
1250
|
},
|
|
1258
|
-
set(
|
|
1259
|
-
|
|
1251
|
+
set(c, d) {
|
|
1252
|
+
a.set(c, { ...d, handle: c });
|
|
1260
1253
|
},
|
|
1261
|
-
delete(
|
|
1262
|
-
|
|
1254
|
+
delete(c) {
|
|
1255
|
+
a.delete(c);
|
|
1263
1256
|
}
|
|
1264
1257
|
},
|
|
1265
1258
|
persist() {
|
|
1266
|
-
const
|
|
1267
|
-
for (const [
|
|
1268
|
-
|
|
1269
|
-
for (const [
|
|
1270
|
-
|
|
1271
|
-
for (const [
|
|
1272
|
-
|
|
1273
|
-
|
|
1259
|
+
const c = [], d = [], p = [];
|
|
1260
|
+
for (const [h, y] of s)
|
|
1261
|
+
g(y.timestamp) || c.push([h, y]);
|
|
1262
|
+
for (const [h, y] of l)
|
|
1263
|
+
y.value && !g(y.value.timestamp) && d.push([h, y.value]);
|
|
1264
|
+
for (const [h, y] of i)
|
|
1265
|
+
p.push([h, y]);
|
|
1266
|
+
u.save({ products: c, queries: d, collections: p });
|
|
1274
1267
|
},
|
|
1275
1268
|
restore() {
|
|
1276
|
-
const
|
|
1277
|
-
if (
|
|
1278
|
-
for (const [
|
|
1279
|
-
|
|
1280
|
-
for (const [
|
|
1281
|
-
if (!
|
|
1282
|
-
const
|
|
1283
|
-
|
|
1269
|
+
const c = u.restore();
|
|
1270
|
+
if (c) {
|
|
1271
|
+
for (const [d, p] of c.products)
|
|
1272
|
+
g(p.timestamp) || s.set(d, p);
|
|
1273
|
+
for (const [d, p] of c.queries)
|
|
1274
|
+
if (!g(p.timestamp)) {
|
|
1275
|
+
const h = f(d);
|
|
1276
|
+
h.value = p;
|
|
1284
1277
|
}
|
|
1285
|
-
for (const [
|
|
1286
|
-
|
|
1278
|
+
for (const [d, p] of c.collections)
|
|
1279
|
+
i.set(d, p);
|
|
1287
1280
|
}
|
|
1288
1281
|
},
|
|
1289
1282
|
clear() {
|
|
1290
|
-
|
|
1291
|
-
for (const
|
|
1292
|
-
|
|
1283
|
+
s.clear();
|
|
1284
|
+
for (const c of l.values()) c.value = null;
|
|
1285
|
+
l.clear(), i.clear(), a.clear(), u.clear();
|
|
1293
1286
|
},
|
|
1294
1287
|
get stats() {
|
|
1295
1288
|
return {
|
|
1296
|
-
products:
|
|
1297
|
-
queries:
|
|
1298
|
-
collections:
|
|
1299
|
-
pages:
|
|
1289
|
+
products: s.size,
|
|
1290
|
+
queries: l.size,
|
|
1291
|
+
collections: i.size,
|
|
1292
|
+
pages: a.size
|
|
1300
1293
|
};
|
|
1301
1294
|
}
|
|
1302
1295
|
};
|
|
1303
1296
|
}
|
|
1304
|
-
function
|
|
1305
|
-
return Object.entries(e).filter(([r,
|
|
1306
|
-
([r,
|
|
1297
|
+
function Ae(e, t = []) {
|
|
1298
|
+
return Object.entries(e).filter(([r, o]) => o != null && !t.includes(r)).sort(([r], [o]) => r.localeCompare(o)).map(
|
|
1299
|
+
([r, o]) => `${encodeURIComponent(r)}=${encodeURIComponent(typeof o == "object" ? JSON.stringify(o) : String(o))}`
|
|
1307
1300
|
).join("&");
|
|
1308
1301
|
}
|
|
1309
1302
|
function Pt(e, t = {}) {
|
|
1310
1303
|
if (!e?.trim()) return;
|
|
1311
|
-
const r = `/browse/${encodeURIComponent(e)}`,
|
|
1312
|
-
return
|
|
1304
|
+
const r = `/browse/${encodeURIComponent(e)}`, o = Ae(t, ["collectionHandle", "signal"]);
|
|
1305
|
+
return o ? `${r}?${o}` : r;
|
|
1313
1306
|
}
|
|
1314
|
-
function
|
|
1307
|
+
function Rt(e, t = {}) {
|
|
1315
1308
|
if (!e?.trim()) return;
|
|
1316
|
-
const r = `/search/${encodeURIComponent(e)}`,
|
|
1317
|
-
return
|
|
1309
|
+
const r = `/search/${encodeURIComponent(e)}`, o = Ae(t, ["query", "signal"]);
|
|
1310
|
+
return o ? `${r}?${o}` : r;
|
|
1318
1311
|
}
|
|
1319
|
-
function
|
|
1312
|
+
function At(e, t = {}) {
|
|
1320
1313
|
if (!e?.trim()) return;
|
|
1321
|
-
const r = `/blocks/${encodeURIComponent(e)}`,
|
|
1322
|
-
return
|
|
1323
|
-
}
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1314
|
+
const r = `/blocks/${encodeURIComponent(e)}`, o = Ae(t, ["blockId", "signal"]);
|
|
1315
|
+
return o ? `${r}?${o}` : r;
|
|
1316
|
+
}
|
|
1317
|
+
var he = /* @__PURE__ */ ((e) => (e.Equal = "eq", e.NotEqual = "not_eq", e.In = "in", e.NotIn = "not_in", e.GreaterThan = "gt", e.GreaterThanOrEqual = "gte", e.LessThan = "lt", e.LessThanOrEqual = "lte", e.Exists = "exists", e.NotExists = "not_exists", e))(he || {}), Be = /* @__PURE__ */ ((e) => (e.And = "AND", e.Or = "OR", e))(Be || {});
|
|
1318
|
+
function or(e, t) {
|
|
1319
|
+
return { property: e, operator: "eq", values: [t] };
|
|
1320
|
+
}
|
|
1321
|
+
function sr(e, t) {
|
|
1322
|
+
return { property: e, operator: "not_eq", values: [t] };
|
|
1323
|
+
}
|
|
1324
|
+
function ir(e, t) {
|
|
1325
|
+
return { property: e, operator: "in", values: t };
|
|
1326
|
+
}
|
|
1327
|
+
function ar(e, t) {
|
|
1328
|
+
return { property: e, operator: "not_in", values: t };
|
|
1329
|
+
}
|
|
1330
|
+
function cr(e, t) {
|
|
1331
|
+
return { property: e, operator: "gt", values: [t] };
|
|
1332
|
+
}
|
|
1333
|
+
function lr(e, t) {
|
|
1334
|
+
return { property: e, operator: "gte", values: [t] };
|
|
1335
|
+
}
|
|
1336
|
+
function ur(e, t) {
|
|
1337
|
+
return { property: e, operator: "lt", values: [t] };
|
|
1338
|
+
}
|
|
1339
|
+
function dr(e, t) {
|
|
1340
|
+
return { property: e, operator: "lte", values: [t] };
|
|
1341
|
+
}
|
|
1342
|
+
function fr(e) {
|
|
1343
|
+
return { property: e, operator: "exists", values: [] };
|
|
1344
|
+
}
|
|
1345
|
+
function gr(e) {
|
|
1346
|
+
return { property: e, operator: "not_exists", values: [] };
|
|
1347
|
+
}
|
|
1348
|
+
function Tt(...e) {
|
|
1349
|
+
return { conditional: "AND", expressions: e };
|
|
1350
|
+
}
|
|
1351
|
+
function mr(...e) {
|
|
1352
|
+
return { conditional: "OR", expressions: e };
|
|
1353
|
+
}
|
|
1354
|
+
function wt(e) {
|
|
1355
|
+
return "conditional" in e;
|
|
1356
|
+
}
|
|
1357
|
+
function pr(e) {
|
|
1358
|
+
return { filter_group: wt(e) ? e : Tt(e) };
|
|
1359
|
+
}
|
|
1360
|
+
function Dt(e, t) {
|
|
1361
|
+
return `gid://shopify/${e}/${t}`;
|
|
1362
|
+
}
|
|
1363
|
+
function Ct(e) {
|
|
1364
|
+
return Dt("Product", e);
|
|
1365
|
+
}
|
|
1366
|
+
function xe({
|
|
1367
|
+
type: e,
|
|
1368
|
+
selectedOptions: t
|
|
1369
|
+
}) {
|
|
1370
|
+
const r = t.map(({ name: o, value: n }) => `${o}:${n}`).join("-");
|
|
1371
|
+
return `${e}-${r}`;
|
|
1372
|
+
}
|
|
1373
|
+
function Ge(e) {
|
|
1374
|
+
return e.product_id ?? e.id;
|
|
1375
|
+
}
|
|
1376
|
+
function ye(e) {
|
|
1377
|
+
return Ct(Ge(e));
|
|
1378
|
+
}
|
|
1379
|
+
function Ot(e, t = {}) {
|
|
1380
|
+
const {
|
|
1381
|
+
currencyCode: r = et,
|
|
1382
|
+
formatPrice: o = nt,
|
|
1383
|
+
swatches: n = []
|
|
1384
|
+
} = t, s = Ge(e), i = ye(e), a = e.title, l = e.handle ?? "", u = e.vendor ?? "", g = e.product_type ?? "", f = e.body_html ?? "", c = e.available ?? !1, d = e.is_gift_card ?? !1, p = Bt(e), h = e.tags ?? [], y = Nt(e), I = kt(e.price_range, r, o), b = qt(e, n), v = Lt(e, r, o), S = v.map((_) => _.compareAtPrice).filter((_) => _ !== null), E = S.length > 0 ? {
|
|
1385
|
+
min: S.reduce((_, C) => _.amount < C.amount ? _ : C),
|
|
1386
|
+
max: S.reduce((_, C) => _.amount > C.amount ? _ : C)
|
|
1387
|
+
} : void 0, F = e.first_or_matched_variant ? $t(e.first_or_matched_variant) : [], P = xe({ type: "Product", selectedOptions: F }), A = e.metafields ?? {};
|
|
1329
1388
|
return {
|
|
1330
|
-
id:
|
|
1331
|
-
gid:
|
|
1332
|
-
numericId:
|
|
1333
|
-
title:
|
|
1334
|
-
handle:
|
|
1335
|
-
type:
|
|
1336
|
-
vendor:
|
|
1337
|
-
description:
|
|
1338
|
-
availableForSale:
|
|
1339
|
-
images:
|
|
1340
|
-
priceRange:
|
|
1341
|
-
compareAtPriceRange:
|
|
1342
|
-
options:
|
|
1343
|
-
tags:
|
|
1389
|
+
id: P,
|
|
1390
|
+
gid: i,
|
|
1391
|
+
numericId: s,
|
|
1392
|
+
title: a,
|
|
1393
|
+
handle: l,
|
|
1394
|
+
type: g,
|
|
1395
|
+
vendor: u,
|
|
1396
|
+
description: f,
|
|
1397
|
+
availableForSale: c,
|
|
1398
|
+
images: y,
|
|
1399
|
+
priceRange: I,
|
|
1400
|
+
compareAtPriceRange: E,
|
|
1401
|
+
options: b,
|
|
1402
|
+
tags: h,
|
|
1344
1403
|
variants: v,
|
|
1345
|
-
selectedOptions:
|
|
1346
|
-
metafields:
|
|
1404
|
+
selectedOptions: F,
|
|
1405
|
+
metafields: A,
|
|
1347
1406
|
calculated: e.calculated,
|
|
1348
|
-
isGiftCard:
|
|
1407
|
+
isGiftCard: d,
|
|
1349
1408
|
onlineStoreUrl: null,
|
|
1350
|
-
totalInventory:
|
|
1409
|
+
totalInventory: p
|
|
1351
1410
|
};
|
|
1352
1411
|
}
|
|
1353
|
-
function
|
|
1354
|
-
return new Intl.NumberFormat("en-US", {
|
|
1355
|
-
style: "currency",
|
|
1356
|
-
currency: t
|
|
1357
|
-
}).format(e);
|
|
1358
|
-
}
|
|
1359
|
-
function At(e) {
|
|
1412
|
+
function Nt(e) {
|
|
1360
1413
|
return (e.images ?? []).map((t) => ({
|
|
1361
1414
|
url: t.src,
|
|
1362
1415
|
alt: t.alt ?? "",
|
|
@@ -1364,30 +1417,30 @@ function At(e) {
|
|
|
1364
1417
|
height: t.height
|
|
1365
1418
|
}));
|
|
1366
1419
|
}
|
|
1367
|
-
function
|
|
1368
|
-
const
|
|
1420
|
+
function kt(e, t, r) {
|
|
1421
|
+
const o = e?.from ?? 0, n = e?.to ?? o;
|
|
1369
1422
|
return {
|
|
1370
|
-
min: { amount:
|
|
1371
|
-
max: { amount:
|
|
1423
|
+
min: { amount: o, currencyCode: t, formatted: r(o, t) },
|
|
1424
|
+
max: { amount: n, currencyCode: t, formatted: r(n, t) }
|
|
1372
1425
|
};
|
|
1373
1426
|
}
|
|
1374
|
-
function
|
|
1375
|
-
const r = [],
|
|
1376
|
-
for (const [
|
|
1377
|
-
for (const
|
|
1378
|
-
const
|
|
1379
|
-
r.push({ name:
|
|
1427
|
+
function qt(e, t) {
|
|
1428
|
+
const r = [], o = e.options ?? {};
|
|
1429
|
+
for (const [n, s] of Object.entries(o))
|
|
1430
|
+
for (const i of s) {
|
|
1431
|
+
const a = t.find((l) => l.name === n && l.value === i);
|
|
1432
|
+
r.push({ name: n, value: i, swatch: a });
|
|
1380
1433
|
}
|
|
1381
1434
|
return r;
|
|
1382
1435
|
}
|
|
1383
|
-
function
|
|
1436
|
+
function $t(e) {
|
|
1384
1437
|
return e.selected_options.map((t) => ({ name: t.name, value: t.value }));
|
|
1385
1438
|
}
|
|
1386
|
-
function
|
|
1387
|
-
return (e.variants ?? []).map((
|
|
1439
|
+
function Lt(e, t, r) {
|
|
1440
|
+
return (e.variants ?? []).map((o) => Ut(o, t, r));
|
|
1388
1441
|
}
|
|
1389
|
-
function
|
|
1390
|
-
const
|
|
1442
|
+
function Ut(e, t, r) {
|
|
1443
|
+
const o = parseFloat(e.price), n = e.compare_at_price ? parseFloat(e.compare_at_price) : null;
|
|
1391
1444
|
return {
|
|
1392
1445
|
id: xe({ type: "ProductVariant", selectedOptions: e.selected_options }),
|
|
1393
1446
|
gid: `gid://shopify/ProductVariant/${e.id}`,
|
|
@@ -1401,11 +1454,11 @@ function Ct(e, t, r) {
|
|
|
1401
1454
|
weight: null,
|
|
1402
1455
|
weightUnit: null,
|
|
1403
1456
|
requiresShipping: !0,
|
|
1404
|
-
price: { amount:
|
|
1405
|
-
compareAtPrice:
|
|
1406
|
-
amount:
|
|
1457
|
+
price: { amount: o, currencyCode: t, formatted: r(o, t) },
|
|
1458
|
+
compareAtPrice: n != null ? {
|
|
1459
|
+
amount: n,
|
|
1407
1460
|
currencyCode: t,
|
|
1408
|
-
formatted: r(
|
|
1461
|
+
formatted: r(n, t)
|
|
1409
1462
|
} : null,
|
|
1410
1463
|
image: e.featured_media ? {
|
|
1411
1464
|
url: e.featured_media.src,
|
|
@@ -1413,11 +1466,12 @@ function Ct(e, t, r) {
|
|
|
1413
1466
|
width: e.featured_media.width,
|
|
1414
1467
|
height: e.featured_media.height
|
|
1415
1468
|
} : null,
|
|
1416
|
-
selectedOptions: e.selected_options.map((
|
|
1417
|
-
metafields:
|
|
1469
|
+
selectedOptions: e.selected_options.map((s) => ({ name: s.name, value: s.value })),
|
|
1470
|
+
metafields: Vt(e.metafields),
|
|
1471
|
+
inventoryLevels: e.inventory_levels ?? {}
|
|
1418
1472
|
};
|
|
1419
1473
|
}
|
|
1420
|
-
function
|
|
1474
|
+
function Vt(e) {
|
|
1421
1475
|
return e ? e.map((t) => ({
|
|
1422
1476
|
namespace: t.namespace,
|
|
1423
1477
|
key: t.key,
|
|
@@ -1425,62 +1479,19 @@ function kt(e) {
|
|
|
1425
1479
|
type: t.value_type
|
|
1426
1480
|
})) : [];
|
|
1427
1481
|
}
|
|
1428
|
-
function
|
|
1482
|
+
function Bt(e) {
|
|
1429
1483
|
const t = e.first_or_matched_variant;
|
|
1430
1484
|
return t?.inventory_quantity != null ? t.inventory_quantity : 0;
|
|
1431
1485
|
}
|
|
1432
|
-
|
|
1433
|
-
function Wt(e, t) {
|
|
1434
|
-
return { property: e, operator: "eq", values: [t] };
|
|
1435
|
-
}
|
|
1436
|
-
function Kt(e, t) {
|
|
1437
|
-
return { property: e, operator: "not_eq", values: [t] };
|
|
1438
|
-
}
|
|
1439
|
-
function zt(e, t) {
|
|
1440
|
-
return { property: e, operator: "in", values: t };
|
|
1441
|
-
}
|
|
1442
|
-
function Xt(e, t) {
|
|
1443
|
-
return { property: e, operator: "not_in", values: t };
|
|
1444
|
-
}
|
|
1445
|
-
function Jt(e, t) {
|
|
1446
|
-
return { property: e, operator: "gt", values: [t] };
|
|
1447
|
-
}
|
|
1448
|
-
function Yt(e, t) {
|
|
1449
|
-
return { property: e, operator: "gte", values: [t] };
|
|
1450
|
-
}
|
|
1451
|
-
function Zt(e, t) {
|
|
1452
|
-
return { property: e, operator: "lt", values: [t] };
|
|
1453
|
-
}
|
|
1454
|
-
function er(e, t) {
|
|
1455
|
-
return { property: e, operator: "lte", values: [t] };
|
|
1456
|
-
}
|
|
1457
|
-
function tr(e) {
|
|
1458
|
-
return { property: e, operator: "exists", values: [] };
|
|
1459
|
-
}
|
|
1460
|
-
function rr(e) {
|
|
1461
|
-
return { property: e, operator: "not_exists", values: [] };
|
|
1462
|
-
}
|
|
1463
|
-
function xt(...e) {
|
|
1464
|
-
return { conditional: "AND", expressions: e };
|
|
1465
|
-
}
|
|
1466
|
-
function nr(...e) {
|
|
1467
|
-
return { conditional: "OR", expressions: e };
|
|
1468
|
-
}
|
|
1469
|
-
function Ut(e) {
|
|
1470
|
-
return "conditional" in e;
|
|
1471
|
-
}
|
|
1472
|
-
function sr(e) {
|
|
1473
|
-
return { filter_group: Ut(e) ? e : xt(e) };
|
|
1474
|
-
}
|
|
1475
|
-
function je() {
|
|
1486
|
+
function He() {
|
|
1476
1487
|
return typeof window < "u" && typeof window.document < "u";
|
|
1477
1488
|
}
|
|
1478
|
-
const
|
|
1479
|
-
function
|
|
1480
|
-
|
|
1489
|
+
const je = "__COMMERCE_BLOCKS__";
|
|
1490
|
+
function xt(e) {
|
|
1491
|
+
He() && (window[je] = e);
|
|
1481
1492
|
}
|
|
1482
|
-
function
|
|
1483
|
-
if (!
|
|
1493
|
+
function Gt() {
|
|
1494
|
+
if (!He())
|
|
1484
1495
|
return m(
|
|
1485
1496
|
B({
|
|
1486
1497
|
code: "INVALID_CONFIG",
|
|
@@ -1489,8 +1500,8 @@ function Vt() {
|
|
|
1489
1500
|
expected: "browser"
|
|
1490
1501
|
})
|
|
1491
1502
|
);
|
|
1492
|
-
const e = window[
|
|
1493
|
-
return e ?
|
|
1503
|
+
const e = window[je];
|
|
1504
|
+
return e ? M(e) : m(
|
|
1494
1505
|
B({
|
|
1495
1506
|
code: "MISSING_CONFIG",
|
|
1496
1507
|
message: "SDK not initialized. Call createSdk() first.",
|
|
@@ -1498,33 +1509,22 @@ function Vt() {
|
|
|
1498
1509
|
})
|
|
1499
1510
|
);
|
|
1500
1511
|
}
|
|
1501
|
-
function
|
|
1502
|
-
return
|
|
1512
|
+
function hr() {
|
|
1513
|
+
return Gt().data !== void 0;
|
|
1503
1514
|
}
|
|
1504
|
-
function ne(
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
return {
|
|
1511
|
-
call(...s) {
|
|
1512
|
-
r && clearTimeout(r), r = setTimeout(() => e(...s), t);
|
|
1513
|
-
},
|
|
1514
|
-
cancel() {
|
|
1515
|
-
r && clearTimeout(r);
|
|
1516
|
-
}
|
|
1517
|
-
};
|
|
1518
|
-
}
|
|
1519
|
-
function se(e, t, r) {
|
|
1520
|
-
const s = {
|
|
1515
|
+
function ne({
|
|
1516
|
+
products: e,
|
|
1517
|
+
raw: t,
|
|
1518
|
+
extender: r
|
|
1519
|
+
}) {
|
|
1520
|
+
const o = {
|
|
1521
1521
|
products: e,
|
|
1522
1522
|
totalResults: t.totalResults,
|
|
1523
1523
|
totalPages: t.totalPages,
|
|
1524
1524
|
page: t.page,
|
|
1525
1525
|
facets: t.facets ?? {}
|
|
1526
1526
|
};
|
|
1527
|
-
return r ? r(
|
|
1527
|
+
return r ? r(o, t) : o;
|
|
1528
1528
|
}
|
|
1529
1529
|
function Ht(e) {
|
|
1530
1530
|
return {
|
|
@@ -1544,532 +1544,661 @@ function Ht(e) {
|
|
|
1544
1544
|
metafields: e.metafields
|
|
1545
1545
|
};
|
|
1546
1546
|
}
|
|
1547
|
-
function
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
layersBaseUrl: e.layersBaseUrl,
|
|
1551
|
-
sorts: e.sorts,
|
|
1552
|
-
facets: e.facets,
|
|
1553
|
-
attributes: e.attributes,
|
|
1554
|
-
fetch: e.fetch
|
|
1555
|
-
});
|
|
1556
|
-
if (t.error) return m(t.error);
|
|
1557
|
-
const r = t.data;
|
|
1558
|
-
let s, i = !1;
|
|
1559
|
-
if (e.enableStorefront) {
|
|
1560
|
-
if (!e.shop || !e.storefrontPublicToken)
|
|
1561
|
-
return m(
|
|
1562
|
-
B({
|
|
1563
|
-
code: "MISSING_CONFIG",
|
|
1564
|
-
message: "shop and storefrontPublicToken are required when enableStorefront is true",
|
|
1565
|
-
field: e.shop ? "storefrontPublicToken" : "shop",
|
|
1566
|
-
expected: "non-empty string"
|
|
1567
|
-
})
|
|
1568
|
-
);
|
|
1569
|
-
const o = yt({
|
|
1570
|
-
shop: e.shop,
|
|
1571
|
-
storefrontPublicToken: e.storefrontPublicToken,
|
|
1572
|
-
storefrontApiVersion: e.storefrontApiVersion,
|
|
1573
|
-
fetch: e.fetch
|
|
1574
|
-
});
|
|
1575
|
-
if (o.error) return m(o.error);
|
|
1576
|
-
s = o.data, i = !0;
|
|
1547
|
+
function jt({ ctx: e }) {
|
|
1548
|
+
function t(a) {
|
|
1549
|
+
return a.map(ye);
|
|
1577
1550
|
}
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
swatches: e.swatches
|
|
1586
|
-
};
|
|
1587
|
-
function u(o) {
|
|
1588
|
-
return o.map(ye);
|
|
1589
|
-
}
|
|
1590
|
-
function d(o, p) {
|
|
1591
|
-
const a = wt(o, c);
|
|
1592
|
-
return e.extendProduct ? { ...e.extendProduct({ base: a, raw: o, shopify: p }), _base: a } : a;
|
|
1551
|
+
function r(a, l) {
|
|
1552
|
+
const u = Ot(a, e.mergeConfig);
|
|
1553
|
+
return e.config.extendProduct ? { ...e.config.extendProduct({
|
|
1554
|
+
base: u,
|
|
1555
|
+
raw: a,
|
|
1556
|
+
shopify: l
|
|
1557
|
+
}), _base: u } : u;
|
|
1593
1558
|
}
|
|
1594
|
-
function
|
|
1595
|
-
return
|
|
1596
|
-
const
|
|
1597
|
-
return
|
|
1559
|
+
function o(a, l, u) {
|
|
1560
|
+
return a.map((g) => {
|
|
1561
|
+
const f = ye(g), c = u.get(f);
|
|
1562
|
+
return c || r(g, l.get(f) ?? null);
|
|
1598
1563
|
});
|
|
1599
1564
|
}
|
|
1600
|
-
async function
|
|
1601
|
-
const
|
|
1602
|
-
if (!
|
|
1603
|
-
const
|
|
1604
|
-
ids:
|
|
1605
|
-
productMetafields:
|
|
1606
|
-
variantMetafields:
|
|
1565
|
+
async function n(a, l = e.config.productMetafields, u = e.config.variantMetafields) {
|
|
1566
|
+
const g = /* @__PURE__ */ new Map();
|
|
1567
|
+
if (!e.storefrontEnabled || a.length === 0) return M(g);
|
|
1568
|
+
const f = await e.storefront.getProducts({
|
|
1569
|
+
ids: a,
|
|
1570
|
+
productMetafields: l,
|
|
1571
|
+
variantMetafields: u
|
|
1607
1572
|
});
|
|
1608
|
-
if (
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
return f;
|
|
1573
|
+
if (f.error) return m(f.error);
|
|
1574
|
+
for (const c of f.data)
|
|
1575
|
+
g.set(c.id, c);
|
|
1576
|
+
return M(g);
|
|
1613
1577
|
}
|
|
1614
|
-
async function
|
|
1615
|
-
const
|
|
1616
|
-
if (
|
|
1617
|
-
return
|
|
1618
|
-
const
|
|
1619
|
-
return
|
|
1578
|
+
async function s(a) {
|
|
1579
|
+
const l = t(a), { cached: u, missing: g } = e.store.products.getMany(l), f = new Map(u.map((d) => [d.gid, d]));
|
|
1580
|
+
if (g.length === 0)
|
|
1581
|
+
return M(l.map((d) => f.get(d)));
|
|
1582
|
+
const c = await n(g);
|
|
1583
|
+
return c.error ? m(c.error) : M(o(a, c.data, f));
|
|
1620
1584
|
}
|
|
1621
|
-
function
|
|
1622
|
-
if (
|
|
1623
|
-
if (e.transformFilters)
|
|
1624
|
-
return e.transformFilters(
|
|
1625
|
-
if (e.filterMap && typeof
|
|
1626
|
-
const
|
|
1627
|
-
for (const [
|
|
1628
|
-
if (
|
|
1629
|
-
const
|
|
1630
|
-
const
|
|
1631
|
-
return
|
|
1585
|
+
function i(a) {
|
|
1586
|
+
if (a) {
|
|
1587
|
+
if (e.config.transformFilters)
|
|
1588
|
+
return e.config.transformFilters(a);
|
|
1589
|
+
if (e.config.filterMap && typeof a == "object" && !Array.isArray(a)) {
|
|
1590
|
+
const l = a, u = [];
|
|
1591
|
+
for (const [g, f] of Object.entries(l)) {
|
|
1592
|
+
if (f == null) continue;
|
|
1593
|
+
const c = e.config.filterMap[g], d = typeof c == "string" ? c : c?.property ?? g, p = typeof c == "object" ? c.values : void 0, y = (Array.isArray(f) ? f : [f]).map((I) => {
|
|
1594
|
+
const b = String(I);
|
|
1595
|
+
return p?.[b] ?? b;
|
|
1632
1596
|
});
|
|
1633
|
-
|
|
1634
|
-
property:
|
|
1635
|
-
operator:
|
|
1636
|
-
values:
|
|
1597
|
+
u.push({
|
|
1598
|
+
property: d,
|
|
1599
|
+
operator: y.length > 1 ? he.In : he.Equal,
|
|
1600
|
+
values: y
|
|
1637
1601
|
});
|
|
1638
1602
|
}
|
|
1639
|
-
return
|
|
1640
|
-
conditional:
|
|
1641
|
-
expressions:
|
|
1603
|
+
return u.length === 0 ? void 0 : {
|
|
1604
|
+
conditional: Be.And,
|
|
1605
|
+
expressions: u
|
|
1642
1606
|
};
|
|
1643
1607
|
}
|
|
1644
|
-
return
|
|
1608
|
+
return a;
|
|
1645
1609
|
}
|
|
1646
1610
|
}
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
const
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1611
|
+
return {
|
|
1612
|
+
extractGids: t,
|
|
1613
|
+
buildSingleProduct: r,
|
|
1614
|
+
buildProductsWithCache: o,
|
|
1615
|
+
fetchStorefrontProductsMap: n,
|
|
1616
|
+
fetchAndBuildProducts: s,
|
|
1617
|
+
transformFilters: i
|
|
1618
|
+
};
|
|
1619
|
+
}
|
|
1620
|
+
function oe(e) {
|
|
1621
|
+
const t = new AbortController();
|
|
1622
|
+
return e && (e.aborted ? t.abort(e.reason) : e.addEventListener("abort", () => t.abort(e.reason), { once: !0 })), t;
|
|
1623
|
+
}
|
|
1624
|
+
function Qt({
|
|
1625
|
+
definitions: e
|
|
1626
|
+
}) {
|
|
1627
|
+
if (!e) return {};
|
|
1628
|
+
const t = {};
|
|
1629
|
+
for (const [r, o] of Object.entries(e)) {
|
|
1630
|
+
const n = o({ key: r });
|
|
1631
|
+
n != null && (t[r] = n);
|
|
1632
|
+
}
|
|
1633
|
+
return t;
|
|
1634
|
+
}
|
|
1635
|
+
function X({
|
|
1636
|
+
params: e,
|
|
1637
|
+
paramDefinitions: t,
|
|
1638
|
+
transformBody: r
|
|
1639
|
+
}) {
|
|
1640
|
+
const o = Qt({ definitions: t }), n = { ...e, ...o }, s = Object.keys(n).length > 0;
|
|
1641
|
+
if (!(!s && !r))
|
|
1642
|
+
return (i) => {
|
|
1643
|
+
const a = s ? { ...i, ...n } : i;
|
|
1644
|
+
return r ? r(a) : a;
|
|
1645
|
+
};
|
|
1646
|
+
}
|
|
1647
|
+
function Wt({
|
|
1648
|
+
ctx: e,
|
|
1649
|
+
helpers: t
|
|
1650
|
+
}) {
|
|
1651
|
+
return ({ handle: r, defaultSort: o }) => {
|
|
1652
|
+
const n = $({
|
|
1653
|
+
data: null,
|
|
1654
|
+
error: null,
|
|
1655
|
+
isFetching: !1
|
|
1656
|
+
});
|
|
1657
|
+
let s = null, i = o ?? e.config.sorts[0]?.code;
|
|
1658
|
+
return {
|
|
1659
|
+
state: n,
|
|
1660
|
+
async execute(a = {}) {
|
|
1661
|
+
const {
|
|
1662
|
+
page: l = Y,
|
|
1663
|
+
limit: u = Z,
|
|
1664
|
+
filters: g,
|
|
1665
|
+
sortOrderCode: f,
|
|
1666
|
+
signal: c,
|
|
1667
|
+
includeMeta: d = e.config.includeMeta ?? !1,
|
|
1668
|
+
collectionMetafields: p = e.config.collectionMetafields,
|
|
1669
|
+
includeFilters: h,
|
|
1670
|
+
dynamicLinking: y,
|
|
1671
|
+
params: I,
|
|
1672
|
+
paramDefinitions: b,
|
|
1673
|
+
transformBody: v
|
|
1674
|
+
} = a, S = f ?? i;
|
|
1675
|
+
i = S, s?.abort(), s = oe(c);
|
|
1676
|
+
const E = n.value.data;
|
|
1677
|
+
n.value = { data: E, error: null, isFetching: !0 };
|
|
1678
|
+
const { data: F, error: P } = await e.layers.browse(
|
|
1679
|
+
{
|
|
1680
|
+
collectionHandle: r,
|
|
1681
|
+
sort_order_code: S,
|
|
1682
|
+
pagination: { page: l, limit: u },
|
|
1683
|
+
filter_group: t.transformFilters(g),
|
|
1684
|
+
dynamicLinking: y,
|
|
1685
|
+
transformBody: X({ params: I, paramDefinitions: b, transformBody: v })
|
|
1686
|
+
},
|
|
1687
|
+
s.signal
|
|
1688
|
+
);
|
|
1689
|
+
if (P)
|
|
1690
|
+
return n.value = { data: E, error: P, isFetching: !1 }, m(P);
|
|
1691
|
+
const { results: A } = F, _ = A, C = t.extractGids(_), { cached: N, missing: k } = e.store.products.getMany(C), L = new Map(N.map((w) => [w.gid, w])), U = d && !p?.length ? e.store.collections.get(r) : void 0, Te = U?.title !== void 0;
|
|
1692
|
+
let x, T;
|
|
1693
|
+
if (k.length === 0)
|
|
1694
|
+
x = C.map((w) => L.get(w));
|
|
1695
|
+
else if (e.storefrontEnabled && d && !Te) {
|
|
1696
|
+
const w = await e.storefront.getCollectionWithProducts({
|
|
1697
|
+
handle: r,
|
|
1698
|
+
ids: k,
|
|
1699
|
+
productMetafields: e.config.productMetafields,
|
|
1700
|
+
variantMetafields: e.config.variantMetafields,
|
|
1701
|
+
collectionMetafields: p,
|
|
1702
|
+
includeFilters: h
|
|
1703
|
+
});
|
|
1704
|
+
if (w.data) {
|
|
1705
|
+
T = w.data.collection;
|
|
1706
|
+
const V = /* @__PURE__ */ new Map();
|
|
1707
|
+
for (const De of w.data.products)
|
|
1708
|
+
V.set(De.id, De);
|
|
1709
|
+
x = t.buildProductsWithCache(_, V, L);
|
|
1710
|
+
} else {
|
|
1711
|
+
const V = await t.fetchStorefrontProductsMap(k);
|
|
1712
|
+
if (V.error)
|
|
1713
|
+
return n.value = { data: E, error: V.error, isFetching: !1 }, m(V.error);
|
|
1714
|
+
x = t.buildProductsWithCache(
|
|
1715
|
+
_,
|
|
1716
|
+
V.data,
|
|
1717
|
+
L
|
|
1710
1718
|
);
|
|
1711
|
-
if (_.error)
|
|
1712
|
-
return o.value = { ...o.value, isFetching: !1, error: _.error }, m(_.error);
|
|
1713
|
-
T = _.data.search_id;
|
|
1714
1719
|
}
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
},
|
|
1724
|
-
p.signal
|
|
1720
|
+
} else {
|
|
1721
|
+
const w = await t.fetchStorefrontProductsMap(k);
|
|
1722
|
+
if (w.error)
|
|
1723
|
+
return n.value = { data: E, error: w.error, isFetching: !1 }, m(w.error);
|
|
1724
|
+
x = t.buildProductsWithCache(
|
|
1725
|
+
_,
|
|
1726
|
+
w.data,
|
|
1727
|
+
L
|
|
1725
1728
|
);
|
|
1726
|
-
for (let _ = 0; _ < A && P.error; _++) {
|
|
1727
|
-
const V = P.error;
|
|
1728
|
-
if (V._tag !== "ApiError" || V.status !== 425) break;
|
|
1729
|
-
let H = 50;
|
|
1730
|
-
try {
|
|
1731
|
-
const G = JSON.parse(V.message);
|
|
1732
|
-
G.retry_after_ms && (H = G.retry_after_ms);
|
|
1733
|
-
} catch {
|
|
1734
|
-
}
|
|
1735
|
-
await new Promise((G) => setTimeout(G, H)), P = await r.search(
|
|
1736
|
-
{
|
|
1737
|
-
query: h,
|
|
1738
|
-
search_id: T,
|
|
1739
|
-
pagination: { page: M, limit: b },
|
|
1740
|
-
filter_group: F,
|
|
1741
|
-
tuning: S
|
|
1742
|
-
},
|
|
1743
|
-
p.signal
|
|
1744
|
-
);
|
|
1745
|
-
}
|
|
1746
|
-
if (o.value = { ...o.value, isFetching: !1 }, P.error)
|
|
1747
|
-
return o.value = { ...o.value, error: P.error }, m(P.error);
|
|
1748
|
-
const { results: x } = P.data, $ = await R(x), O = se($, P.data, e.extendSearch);
|
|
1749
|
-
e.includeMeta && P.data._meta && (O._meta = P.data._meta), n.products.set($);
|
|
1750
|
-
const U = St(h, { page: M, limit: b, filters: E });
|
|
1751
|
-
return U && n.queries.set(U, O), o.value = { ...o.value, data: O }, N(O);
|
|
1752
|
-
},
|
|
1753
|
-
dispose() {
|
|
1754
|
-
p?.abort();
|
|
1755
1729
|
}
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
error: null,
|
|
1765
|
-
isFetching: !1
|
|
1766
|
-
});
|
|
1767
|
-
let f = null, h = p ?? e.sorts[0]?.code;
|
|
1768
|
-
return {
|
|
1769
|
-
state: a,
|
|
1770
|
-
async execute(v = {}) {
|
|
1771
|
-
const {
|
|
1772
|
-
page: M = 1,
|
|
1773
|
-
limit: b = 24,
|
|
1774
|
-
filters: E,
|
|
1775
|
-
sortOrderCode: S,
|
|
1776
|
-
signal: w,
|
|
1777
|
-
includeMeta: F = e.includeMeta ?? !1,
|
|
1778
|
-
collectionMetafields: T = e.collectionMetafields,
|
|
1779
|
-
includeFilters: A
|
|
1780
|
-
} = v, P = S ?? h;
|
|
1781
|
-
h = P, f?.abort(), f = ne(w);
|
|
1782
|
-
const x = a.value.data;
|
|
1783
|
-
a.value = { data: x, error: null, isFetching: !0 };
|
|
1784
|
-
const { data: $, error: O } = await r.browse(
|
|
1785
|
-
{
|
|
1786
|
-
collectionHandle: o,
|
|
1787
|
-
sort_order_code: P,
|
|
1788
|
-
pagination: { page: M, limit: b },
|
|
1789
|
-
filter_group: l(E)
|
|
1790
|
-
},
|
|
1791
|
-
f.signal
|
|
1792
|
-
);
|
|
1793
|
-
if (O)
|
|
1794
|
-
return a.value = { data: x, error: O, isFetching: !1 }, m(O);
|
|
1795
|
-
const { results: U } = $, _ = U, V = u(_), { cached: H, missing: G } = n.products.getMany(V), te = new Map(H.map((k) => [k.gid, k])), Ae = F && !T?.length ? n.collections.get(o) : void 0, De = Ae?.title !== void 0;
|
|
1796
|
-
let W, q;
|
|
1797
|
-
if (G.length === 0)
|
|
1798
|
-
W = V.map((k) => te.get(k));
|
|
1799
|
-
else if (i && F && !De) {
|
|
1800
|
-
const k = await s.getCollectionWithProducts({
|
|
1801
|
-
handle: o,
|
|
1802
|
-
ids: G,
|
|
1803
|
-
productMetafields: e.productMetafields,
|
|
1804
|
-
variantMetafields: e.variantMetafields,
|
|
1805
|
-
collectionMetafields: T,
|
|
1806
|
-
includeFilters: A
|
|
1730
|
+
if (e.storefrontEnabled && d && !T)
|
|
1731
|
+
if (Te)
|
|
1732
|
+
T = Ht(U);
|
|
1733
|
+
else {
|
|
1734
|
+
const w = await e.storefront.getCollection({
|
|
1735
|
+
handle: r,
|
|
1736
|
+
collectionMetafields: p,
|
|
1737
|
+
includeFilters: h
|
|
1807
1738
|
});
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1739
|
+
w.data && (T = w.data);
|
|
1740
|
+
}
|
|
1741
|
+
const q = ne({
|
|
1742
|
+
products: x,
|
|
1743
|
+
raw: F,
|
|
1744
|
+
extender: e.config.extendCollection
|
|
1745
|
+
});
|
|
1746
|
+
d && F._meta && (q._meta = F._meta), T && (q.collection = T);
|
|
1747
|
+
const we = Pt(r, { sortOrderCode: S, page: l, limit: u, filters: g });
|
|
1748
|
+
return we && e.store.queries.set(we, q), e.store.products.set(x), e.store.collections.set(r, {
|
|
1749
|
+
totalProducts: q.totalResults,
|
|
1750
|
+
totalPages: q.totalPages,
|
|
1751
|
+
lastPageFetched: l,
|
|
1752
|
+
facets: q.facets,
|
|
1753
|
+
lastFetched: Date.now(),
|
|
1754
|
+
...T && {
|
|
1755
|
+
title: T.title,
|
|
1756
|
+
description: T.description,
|
|
1757
|
+
descriptionHtml: T.descriptionHtml,
|
|
1758
|
+
image: T.image ? {
|
|
1759
|
+
url: T.image.url,
|
|
1760
|
+
alt: T.image.altText ?? void 0,
|
|
1761
|
+
width: T.image.width,
|
|
1762
|
+
height: T.image.height
|
|
1763
|
+
} : void 0,
|
|
1764
|
+
metafields: T.metafields
|
|
1821
1765
|
}
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1766
|
+
}), n.value = { data: q, error: null, isFetching: !1 }, M(q);
|
|
1767
|
+
},
|
|
1768
|
+
dispose() {
|
|
1769
|
+
s?.abort();
|
|
1770
|
+
}
|
|
1771
|
+
};
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
function Kt({
|
|
1775
|
+
ctx: e,
|
|
1776
|
+
helpers: t
|
|
1777
|
+
}) {
|
|
1778
|
+
return () => {
|
|
1779
|
+
const r = $({
|
|
1780
|
+
data: null,
|
|
1781
|
+
error: null,
|
|
1782
|
+
isFetching: !1
|
|
1783
|
+
});
|
|
1784
|
+
let o = null, n;
|
|
1785
|
+
return {
|
|
1786
|
+
state: r,
|
|
1787
|
+
async prepare(s) {
|
|
1788
|
+
const {
|
|
1789
|
+
query: i,
|
|
1790
|
+
filters: a,
|
|
1791
|
+
tuning: l,
|
|
1792
|
+
signal: u,
|
|
1793
|
+
dynamicLinking: g,
|
|
1794
|
+
params: f,
|
|
1795
|
+
paramDefinitions: c,
|
|
1796
|
+
transformBody: d
|
|
1797
|
+
} = s, p = t.transformFilters(a), h = await e.layers.prepareSearch(
|
|
1798
|
+
{
|
|
1799
|
+
query: i,
|
|
1800
|
+
filter_group: p,
|
|
1801
|
+
tuning: l,
|
|
1802
|
+
dynamicLinking: g,
|
|
1803
|
+
transformBody: X({ params: f, paramDefinitions: c, transformBody: d })
|
|
1804
|
+
},
|
|
1805
|
+
u
|
|
1806
|
+
);
|
|
1807
|
+
return h.error ? m(h.error) : (n = h.data.search_id, M({ searchId: h.data.search_id }));
|
|
1808
|
+
},
|
|
1809
|
+
async execute(s) {
|
|
1810
|
+
const {
|
|
1811
|
+
query: i,
|
|
1812
|
+
searchId: a,
|
|
1813
|
+
page: l = Y,
|
|
1814
|
+
limit: u = Z,
|
|
1815
|
+
filters: g,
|
|
1816
|
+
tuning: f,
|
|
1817
|
+
signal: c,
|
|
1818
|
+
dynamicLinking: d,
|
|
1819
|
+
params: p,
|
|
1820
|
+
paramDefinitions: h,
|
|
1821
|
+
transformBody: y
|
|
1822
|
+
} = s, I = t.transformFilters(g), b = X({ params: p, paramDefinitions: h, transformBody: y });
|
|
1823
|
+
o?.abort(), o = oe(c), r.value = { ...r.value, isFetching: !0, error: null };
|
|
1824
|
+
let v = a ?? n;
|
|
1825
|
+
if (n = void 0, !v) {
|
|
1826
|
+
const N = await e.layers.prepareSearch(
|
|
1827
|
+
{
|
|
1828
|
+
query: i,
|
|
1829
|
+
filter_group: I,
|
|
1830
|
+
tuning: f,
|
|
1831
|
+
dynamicLinking: d,
|
|
1832
|
+
transformBody: b
|
|
1833
|
+
},
|
|
1834
|
+
o.signal
|
|
1837
1835
|
);
|
|
1838
|
-
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
totalProducts: Q.totalResults,
|
|
1842
|
-
totalPages: Q.totalPages,
|
|
1843
|
-
lastPageFetched: M,
|
|
1844
|
-
facets: Q.facets,
|
|
1845
|
-
lastFetched: Date.now(),
|
|
1846
|
-
...q && {
|
|
1847
|
-
title: q.title,
|
|
1848
|
-
description: q.description,
|
|
1849
|
-
descriptionHtml: q.descriptionHtml,
|
|
1850
|
-
image: q.image ? {
|
|
1851
|
-
url: q.image.url,
|
|
1852
|
-
alt: q.image.altText ?? void 0,
|
|
1853
|
-
width: q.image.width,
|
|
1854
|
-
height: q.image.height
|
|
1855
|
-
} : void 0,
|
|
1856
|
-
metafields: q.metafields
|
|
1857
|
-
}
|
|
1858
|
-
}), a.value = { data: Q, error: null, isFetching: !1 }, N(Q);
|
|
1859
|
-
},
|
|
1860
|
-
dispose() {
|
|
1861
|
-
f?.abort();
|
|
1836
|
+
if (N.error)
|
|
1837
|
+
return r.value = { ...r.value, isFetching: !1, error: N.error }, m(N.error);
|
|
1838
|
+
v = N.data.search_id;
|
|
1862
1839
|
}
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
} = v;
|
|
1887
|
-
h?.abort(), h = ne(S);
|
|
1888
|
-
const T = f.value.data;
|
|
1889
|
-
f.value = { data: T, error: null, isFetching: !0 };
|
|
1890
|
-
const { data: A, error: P } = await r.blocks(
|
|
1840
|
+
const S = Je;
|
|
1841
|
+
let E = await e.layers.search(
|
|
1842
|
+
{
|
|
1843
|
+
query: i,
|
|
1844
|
+
search_id: v,
|
|
1845
|
+
pagination: { page: l, limit: u },
|
|
1846
|
+
filter_group: I,
|
|
1847
|
+
tuning: f,
|
|
1848
|
+
dynamicLinking: d,
|
|
1849
|
+
transformBody: b
|
|
1850
|
+
},
|
|
1851
|
+
o.signal
|
|
1852
|
+
);
|
|
1853
|
+
for (let N = 0; N < S && E.error; N++) {
|
|
1854
|
+
const k = E.error;
|
|
1855
|
+
if (k._tag !== "ApiError" || k.status !== 425) break;
|
|
1856
|
+
let L = Ye;
|
|
1857
|
+
try {
|
|
1858
|
+
const U = JSON.parse(k.message);
|
|
1859
|
+
U.retry_after_ms && (L = U.retry_after_ms);
|
|
1860
|
+
} catch {
|
|
1861
|
+
}
|
|
1862
|
+
await new Promise((U) => setTimeout(U, L)), E = await e.layers.search(
|
|
1891
1863
|
{
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1864
|
+
query: i,
|
|
1865
|
+
search_id: v,
|
|
1866
|
+
pagination: { page: l, limit: u },
|
|
1867
|
+
filter_group: I,
|
|
1868
|
+
tuning: f,
|
|
1869
|
+
dynamicLinking: d,
|
|
1870
|
+
transformBody: b
|
|
1899
1871
|
},
|
|
1900
|
-
|
|
1901
|
-
);
|
|
1902
|
-
if (P)
|
|
1903
|
-
return f.value = { data: T, error: P, isFetching: !1 }, m(P);
|
|
1904
|
-
const { results: x } = A, $ = await R(x), O = se(
|
|
1905
|
-
$,
|
|
1906
|
-
A,
|
|
1907
|
-
e.extendBlock
|
|
1872
|
+
o.signal
|
|
1908
1873
|
);
|
|
1909
|
-
e.includeMeta && A._meta && (O._meta = A._meta), A.block && (O.block = A.block);
|
|
1910
|
-
const U = Rt(o, { anchorId: p, anchorHandle: a, page: M, limit: b, filters: E });
|
|
1911
|
-
return U && n.queries.set(U, O), n.products.set($), f.value = { data: O, error: null, isFetching: !1 }, N(O);
|
|
1912
|
-
},
|
|
1913
|
-
dispose() {
|
|
1914
|
-
h?.abort();
|
|
1915
1874
|
}
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1875
|
+
if (E.error)
|
|
1876
|
+
return r.value = { data: r.value.data, error: E.error, isFetching: !1 }, m(E.error);
|
|
1877
|
+
const { results: F } = E.data, P = await t.fetchAndBuildProducts(F);
|
|
1878
|
+
if (P.error)
|
|
1879
|
+
return r.value = { data: r.value.data, error: P.error, isFetching: !1 }, m(P.error);
|
|
1880
|
+
const A = P.data, _ = ne({
|
|
1881
|
+
products: A,
|
|
1882
|
+
raw: E.data,
|
|
1883
|
+
extender: e.config.extendSearch
|
|
1884
|
+
});
|
|
1885
|
+
e.config.includeMeta && E.data._meta && (_._meta = E.data._meta), e.store.products.set(A);
|
|
1886
|
+
const C = Rt(i, { page: l, limit: u, filters: g });
|
|
1887
|
+
return C && e.store.queries.set(C, _), r.value = { data: _, error: null, isFetching: !1 }, M(_);
|
|
1888
|
+
},
|
|
1889
|
+
dispose() {
|
|
1890
|
+
o?.abort();
|
|
1891
|
+
}
|
|
1892
|
+
};
|
|
1893
|
+
};
|
|
1894
|
+
}
|
|
1895
|
+
function Xt({
|
|
1896
|
+
ctx: e,
|
|
1897
|
+
helpers: t
|
|
1898
|
+
}) {
|
|
1899
|
+
return ({ blockId: r, anchorId: o, anchorHandle: n }) => {
|
|
1900
|
+
const s = $({
|
|
1901
|
+
data: null,
|
|
1902
|
+
error: null,
|
|
1903
|
+
isFetching: !1
|
|
1904
|
+
});
|
|
1905
|
+
let i = null;
|
|
1906
|
+
return {
|
|
1907
|
+
state: s,
|
|
1908
|
+
async execute(a = {}) {
|
|
1909
|
+
const {
|
|
1910
|
+
page: l = Y,
|
|
1911
|
+
limit: u = Z,
|
|
1912
|
+
filters: g,
|
|
1913
|
+
signal: f,
|
|
1914
|
+
discountEntitlements: c,
|
|
1915
|
+
context: d,
|
|
1916
|
+
dynamicLinking: p,
|
|
1917
|
+
params: h,
|
|
1918
|
+
paramDefinitions: y,
|
|
1919
|
+
transformBody: I
|
|
1920
|
+
} = a;
|
|
1921
|
+
i?.abort(), i = oe(f);
|
|
1922
|
+
const b = s.value.data;
|
|
1923
|
+
s.value = { data: b, error: null, isFetching: !0 };
|
|
1924
|
+
const { data: v, error: S } = await e.layers.blocks(
|
|
1944
1925
|
{
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1926
|
+
blockId: r,
|
|
1927
|
+
anchor_id: o,
|
|
1928
|
+
anchor_handle: n,
|
|
1929
|
+
pagination: { page: l, limit: u },
|
|
1930
|
+
filter_group: t.transformFilters(g),
|
|
1931
|
+
discountEntitlements: c,
|
|
1932
|
+
context: d,
|
|
1933
|
+
dynamicLinking: p,
|
|
1934
|
+
transformBody: X({ params: h, paramDefinitions: y, transformBody: I })
|
|
1949
1935
|
},
|
|
1950
|
-
|
|
1936
|
+
i.signal
|
|
1951
1937
|
);
|
|
1952
|
-
if (
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1938
|
+
if (S)
|
|
1939
|
+
return s.value = { data: b, error: S, isFetching: !1 }, m(S);
|
|
1940
|
+
const { results: E } = v, F = await t.fetchAndBuildProducts(E);
|
|
1941
|
+
if (F.error)
|
|
1942
|
+
return s.value = { data: b, error: F.error, isFetching: !1 }, m(F.error);
|
|
1943
|
+
const P = F.data, A = ne({
|
|
1944
|
+
products: P,
|
|
1945
|
+
raw: v,
|
|
1946
|
+
extender: e.config.extendBlock
|
|
1947
|
+
});
|
|
1948
|
+
e.config.includeMeta && v._meta && (A._meta = v._meta), v.block && (A.block = v.block);
|
|
1949
|
+
const _ = At(r, { anchorId: o, anchorHandle: n, page: l, limit: u, filters: g });
|
|
1950
|
+
return _ && e.store.queries.set(_, A), e.store.products.set(P), s.value = { data: A, error: null, isFetching: !1 }, M(A);
|
|
1951
|
+
},
|
|
1952
|
+
dispose() {
|
|
1953
|
+
i?.abort();
|
|
1954
|
+
}
|
|
1955
|
+
};
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
function zt(e, t) {
|
|
1959
|
+
let r = null;
|
|
1960
|
+
return {
|
|
1961
|
+
call(...o) {
|
|
1962
|
+
r && clearTimeout(r), r = setTimeout(() => e(...o), t);
|
|
1959
1963
|
},
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1964
|
+
cancel() {
|
|
1965
|
+
r && clearTimeout(r);
|
|
1966
|
+
}
|
|
1967
|
+
};
|
|
1968
|
+
}
|
|
1969
|
+
function Jt({
|
|
1970
|
+
ctx: e
|
|
1971
|
+
}) {
|
|
1972
|
+
return (t = {}) => {
|
|
1973
|
+
const { debounceMs: r = Ze, signal: o } = t, n = $({
|
|
1974
|
+
data: null,
|
|
1975
|
+
error: null,
|
|
1976
|
+
isFetching: !1
|
|
1977
|
+
});
|
|
1978
|
+
let s = null;
|
|
1979
|
+
const i = /* @__PURE__ */ new Map();
|
|
1980
|
+
function a() {
|
|
1981
|
+
l.cancel(), s?.abort();
|
|
1982
|
+
}
|
|
1983
|
+
o?.addEventListener("abort", a, { once: !0 });
|
|
1984
|
+
const l = zt(async (u) => {
|
|
1985
|
+
if (!u.trim()) {
|
|
1986
|
+
n.value = { data: null, error: null, isFetching: !1 };
|
|
1987
|
+
return;
|
|
1980
1988
|
}
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1989
|
+
const g = u.trim().toLowerCase(), f = i.get(g);
|
|
1990
|
+
if (f) {
|
|
1991
|
+
n.value = { data: f, error: null, isFetching: !1 };
|
|
1992
|
+
return;
|
|
1984
1993
|
}
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2016
|
-
|
|
2017
|
-
|
|
2018
|
-
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
signal: b
|
|
2023
|
-
});
|
|
2024
|
-
if (_.error) {
|
|
2025
|
-
E.value = { data: null, error: _.error, isFetching: !1 };
|
|
2026
|
-
return;
|
|
2027
|
-
}
|
|
2028
|
-
A = _.data;
|
|
1994
|
+
s?.abort(), s = oe(o), n.value = { ...n.value, isFetching: !0 };
|
|
1995
|
+
const c = await e.layers.predictiveSearch(u.trim(), s.signal);
|
|
1996
|
+
c.error ? c.error._tag !== "NetworkError" || c.error.code !== "ABORTED" ? n.value = { data: null, error: c.error, isFetching: !1 } : n.value = { ...n.value, isFetching: !1 } : (i.set(g, c.data), n.value = { data: c.data, error: null, isFetching: !1 });
|
|
1997
|
+
}, r);
|
|
1998
|
+
return { state: n, execute: (u) => l.call(u), dispose: a };
|
|
1999
|
+
};
|
|
2000
|
+
}
|
|
2001
|
+
function Yt({
|
|
2002
|
+
ctx: e
|
|
2003
|
+
}) {
|
|
2004
|
+
return (t) => {
|
|
2005
|
+
const {
|
|
2006
|
+
ids: r,
|
|
2007
|
+
meta: o,
|
|
2008
|
+
collectionMetafields: n = e.config.collectionMetafields,
|
|
2009
|
+
pageMetafields: s = e.config.pageMetafields,
|
|
2010
|
+
signal: i
|
|
2011
|
+
} = t, a = $({
|
|
2012
|
+
data: null,
|
|
2013
|
+
error: null,
|
|
2014
|
+
isFetching: !1
|
|
2015
|
+
});
|
|
2016
|
+
if (r.length === 0)
|
|
2017
|
+
return a.value = { data: { products: [] }, error: null, isFetching: !1 }, a;
|
|
2018
|
+
const l = r, { cached: u } = e.store.products.getMany(l), g = new Map(u.map((c) => [c.gid, c])), f = l.map((c) => g.get(c)).filter((c) => c != null);
|
|
2019
|
+
return !o || !e.storefrontEnabled ? (a.value = { data: { products: f }, error: null, isFetching: !1 }, a) : (a.value = { data: null, error: null, isFetching: !0 }, (async () => {
|
|
2020
|
+
let c, d;
|
|
2021
|
+
if (o.collection) {
|
|
2022
|
+
const h = await e.storefront.getCollection({
|
|
2023
|
+
handle: o.collection,
|
|
2024
|
+
collectionMetafields: n,
|
|
2025
|
+
includeFilters: o.includeFilters,
|
|
2026
|
+
signal: i
|
|
2027
|
+
});
|
|
2028
|
+
if (h.error) {
|
|
2029
|
+
a.value = { data: null, error: h.error, isFetching: !1 };
|
|
2030
|
+
return;
|
|
2029
2031
|
}
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2035
|
-
|
|
2036
|
-
|
|
2032
|
+
c = h.data;
|
|
2033
|
+
}
|
|
2034
|
+
if (o.page) {
|
|
2035
|
+
const h = await e.storefront.getPage({
|
|
2036
|
+
handle: o.page,
|
|
2037
|
+
pageMetafields: s,
|
|
2038
|
+
signal: i
|
|
2039
|
+
});
|
|
2040
|
+
if (h.error) {
|
|
2041
|
+
a.value = { data: null, error: h.error, isFetching: !1 };
|
|
2042
|
+
return;
|
|
2037
2043
|
}
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2044
|
+
d = h.data;
|
|
2045
|
+
}
|
|
2046
|
+
const p = { products: f };
|
|
2047
|
+
c && (p.collection = c), d && (p.page = d), a.value = { data: p, error: null, isFetching: !1 };
|
|
2048
|
+
})(), a);
|
|
2049
|
+
};
|
|
2050
|
+
}
|
|
2051
|
+
function Zt({ ctx: e }) {
|
|
2052
|
+
return ({
|
|
2053
|
+
image: t,
|
|
2054
|
+
signal: r
|
|
2055
|
+
}) => {
|
|
2056
|
+
const o = $({
|
|
2057
|
+
data: null,
|
|
2058
|
+
error: null,
|
|
2059
|
+
isFetching: !0
|
|
2060
|
+
});
|
|
2061
|
+
return (async () => {
|
|
2062
|
+
const n = await e.layers.uploadImage(t, r);
|
|
2063
|
+
if (n.error) {
|
|
2064
|
+
o.value = { data: null, error: n.error, isFetching: !1 };
|
|
2065
|
+
return;
|
|
2066
|
+
}
|
|
2067
|
+
o.value = { data: { imageId: n.data.imageId }, error: null, isFetching: !1 };
|
|
2068
|
+
})(), o;
|
|
2069
|
+
};
|
|
2070
|
+
}
|
|
2071
|
+
function er({
|
|
2072
|
+
ctx: e,
|
|
2073
|
+
helpers: t
|
|
2074
|
+
}) {
|
|
2075
|
+
return (r) => {
|
|
2076
|
+
const {
|
|
2077
|
+
imageId: o,
|
|
2078
|
+
page: n = Y,
|
|
2079
|
+
limit: s = Z,
|
|
2080
|
+
filters: i,
|
|
2081
|
+
tuning: a,
|
|
2082
|
+
signal: l,
|
|
2083
|
+
dynamicLinking: u,
|
|
2084
|
+
params: g,
|
|
2085
|
+
paramDefinitions: f,
|
|
2086
|
+
transformBody: c
|
|
2087
|
+
} = r, d = $({
|
|
2088
|
+
data: null,
|
|
2089
|
+
error: null,
|
|
2090
|
+
isFetching: !0
|
|
2091
|
+
});
|
|
2092
|
+
return (async () => {
|
|
2093
|
+
const p = await e.layers.imageSearch(
|
|
2094
|
+
{
|
|
2095
|
+
image_id: o,
|
|
2096
|
+
pagination: { page: n, limit: s },
|
|
2097
|
+
filter_group: t.transformFilters(i),
|
|
2098
|
+
tuning: a,
|
|
2099
|
+
dynamicLinking: u,
|
|
2100
|
+
transformBody: X({ params: g, paramDefinitions: f, transformBody: c })
|
|
2101
|
+
},
|
|
2102
|
+
l
|
|
2103
|
+
);
|
|
2104
|
+
if (p.error) {
|
|
2105
|
+
d.value = { data: null, error: p.error, isFetching: !1 };
|
|
2106
|
+
return;
|
|
2107
|
+
}
|
|
2108
|
+
const { results: h } = p.data, y = await t.fetchAndBuildProducts(h);
|
|
2109
|
+
if (y.error) {
|
|
2110
|
+
d.value = { data: null, error: y.error, isFetching: !1 };
|
|
2111
|
+
return;
|
|
2112
|
+
}
|
|
2113
|
+
const I = y.data, b = ne({
|
|
2114
|
+
products: I,
|
|
2115
|
+
raw: p.data,
|
|
2116
|
+
extender: e.config.extendSearch
|
|
2117
|
+
});
|
|
2118
|
+
e.store.products.set(I), d.value = { data: b, error: null, isFetching: !1 };
|
|
2119
|
+
})(), d;
|
|
2120
|
+
};
|
|
2121
|
+
}
|
|
2122
|
+
function yr(e) {
|
|
2123
|
+
const t = ut({
|
|
2124
|
+
layersPublicToken: e.layersPublicToken,
|
|
2125
|
+
layersBaseUrl: e.layersBaseUrl,
|
|
2126
|
+
sorts: e.sorts,
|
|
2127
|
+
facets: e.facets,
|
|
2128
|
+
attributes: e.attributes,
|
|
2129
|
+
fetch: e.fetch
|
|
2130
|
+
});
|
|
2131
|
+
if (t.error) return m(t.error);
|
|
2132
|
+
const r = t.data;
|
|
2133
|
+
let o, n = !1;
|
|
2134
|
+
if (e.enableStorefront) {
|
|
2135
|
+
if (!e.shop || !e.storefrontPublicToken)
|
|
2136
|
+
return m(
|
|
2137
|
+
B({
|
|
2138
|
+
code: "MISSING_CONFIG",
|
|
2139
|
+
message: "shop and storefrontPublicToken are required when enableStorefront is true",
|
|
2140
|
+
field: e.shop ? "storefrontPublicToken" : "shop",
|
|
2141
|
+
expected: "non-empty string"
|
|
2142
|
+
})
|
|
2143
|
+
);
|
|
2144
|
+
const u = Et({
|
|
2145
|
+
shop: e.shop,
|
|
2146
|
+
storefrontPublicToken: e.storefrontPublicToken,
|
|
2147
|
+
storefrontApiVersion: e.storefrontApiVersion,
|
|
2148
|
+
fetch: e.fetch
|
|
2149
|
+
});
|
|
2150
|
+
if (u.error) return m(u.error);
|
|
2151
|
+
o = u.data, n = !0;
|
|
2152
|
+
}
|
|
2153
|
+
const s = St({
|
|
2154
|
+
maxProducts: e.cacheMaxProducts,
|
|
2155
|
+
maxQueries: e.cacheMaxEntries,
|
|
2156
|
+
ttl: e.cacheTtl
|
|
2157
|
+
}), i = {
|
|
2158
|
+
config: e,
|
|
2159
|
+
layers: r,
|
|
2160
|
+
storefront: o,
|
|
2161
|
+
storefrontEnabled: n,
|
|
2162
|
+
store: s,
|
|
2163
|
+
mergeConfig: {
|
|
2164
|
+
currencyCode: e.currencyCode,
|
|
2165
|
+
formatPrice: e.formatPrice,
|
|
2166
|
+
swatches: e.swatches
|
|
2048
2167
|
}
|
|
2168
|
+
}, a = jt({ ctx: i }), l = {
|
|
2169
|
+
config: e,
|
|
2170
|
+
store: s,
|
|
2171
|
+
collection: Wt({ ctx: i, helpers: a }),
|
|
2172
|
+
search: Kt({ ctx: i, helpers: a }),
|
|
2173
|
+
blocks: Xt({ ctx: i, helpers: a }),
|
|
2174
|
+
autocomplete: Jt({ ctx: i }),
|
|
2175
|
+
storefront: Yt({ ctx: i }),
|
|
2176
|
+
uploadImage: Zt({ ctx: i }),
|
|
2177
|
+
imageSearch: er({ ctx: i, helpers: a })
|
|
2049
2178
|
};
|
|
2050
|
-
return
|
|
2179
|
+
return xt(l), M(l);
|
|
2051
2180
|
}
|
|
2052
2181
|
export {
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
2057
|
-
|
|
2058
|
-
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2182
|
+
Tt as and,
|
|
2183
|
+
Ir as batch,
|
|
2184
|
+
br as computed,
|
|
2185
|
+
yr as createSdk,
|
|
2186
|
+
vr as effect,
|
|
2187
|
+
or as eq,
|
|
2188
|
+
fr as exists,
|
|
2189
|
+
pr as filter,
|
|
2190
|
+
Gt as getSdk,
|
|
2191
|
+
cr as gt,
|
|
2192
|
+
lr as gte,
|
|
2193
|
+
ir as inValues,
|
|
2194
|
+
hr as isInitialized,
|
|
2195
|
+
nr as isRetryable,
|
|
2196
|
+
rr as isSdkError,
|
|
2197
|
+
ur as lt,
|
|
2198
|
+
dr as lte,
|
|
2199
|
+
sr as notEq,
|
|
2200
|
+
gr as notExists,
|
|
2201
|
+
ar as notIn,
|
|
2202
|
+
mr as or,
|
|
2203
|
+
Fr as signal
|
|
2075
2204
|
};
|