@lucrex/storefront-blocks 0.0.0-stage → 0.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.cjs ADDED
@@ -0,0 +1,2561 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ BlockList: () => BlockList,
24
+ Breakpoints: () => Breakpoints,
25
+ FunnelTemplateIds: () => FunnelTemplateIds,
26
+ OnlineStorePageTypes: () => OnlineStorePageTypes,
27
+ OnlineStoreTemplateIds: () => OnlineStoreTemplateIds,
28
+ PageContent: () => PageContent,
29
+ PageDataProvider: () => PageDataProvider,
30
+ PageDocumentError: () => PageDocumentError,
31
+ StyleProperties: () => StyleProperties,
32
+ blockSelector: () => blockSelector,
33
+ blocks: () => blocks,
34
+ checkoutData: () => checkoutData,
35
+ countBlocks: () => countBlocks,
36
+ funnelTemplate: () => funnelTemplate,
37
+ moneyFormatter: () => moneyFormatter,
38
+ onlineStorePages: () => onlineStorePages,
39
+ onlineStoreTemplate: () => onlineStoreTemplate,
40
+ pageCss: () => pageCss,
41
+ pageFontStylesheets: () => pageFontStylesheets,
42
+ pageJsonSchema: () => pageJsonSchema,
43
+ pagePreloadImages: () => pagePreloadImages,
44
+ parsePageDocument: () => parsePageDocument,
45
+ storeData: () => storeData,
46
+ useCheckoutData: () => useCheckoutData,
47
+ usePageData: () => usePageData,
48
+ useStoreData: () => useStoreData,
49
+ walkBlocks: () => walkBlocks
50
+ });
51
+ module.exports = __toCommonJS(index_exports);
52
+
53
+ // src/document.ts
54
+ var PageDocumentError = class extends Error {
55
+ constructor(issues) {
56
+ super(
57
+ `Invalid page document: ${issues.map((issue) => `${issue.path || "document"}: ${issue.message}`).join("; ")}`
58
+ );
59
+ this.issues = issues;
60
+ this.name = "PageDocumentError";
61
+ }
62
+ };
63
+
64
+ // src/style.ts
65
+ var import_zod = require("zod");
66
+ var StyleProperties = [
67
+ "display",
68
+ "position",
69
+ "top",
70
+ "right",
71
+ "bottom",
72
+ "left",
73
+ "zIndex",
74
+ "width",
75
+ "minWidth",
76
+ "maxWidth",
77
+ "height",
78
+ "minHeight",
79
+ "maxHeight",
80
+ "margin",
81
+ "marginTop",
82
+ "marginRight",
83
+ "marginBottom",
84
+ "marginLeft",
85
+ "padding",
86
+ "paddingTop",
87
+ "paddingRight",
88
+ "paddingBottom",
89
+ "paddingLeft",
90
+ "flexDirection",
91
+ "flexWrap",
92
+ "alignItems",
93
+ "justifyContent",
94
+ "gap",
95
+ "gridTemplateColumns",
96
+ "color",
97
+ "background",
98
+ "backgroundColor",
99
+ "backgroundImage",
100
+ "backgroundSize",
101
+ "backgroundPosition",
102
+ "fontFamily",
103
+ "fontSize",
104
+ "fontWeight",
105
+ "fontStyle",
106
+ "lineHeight",
107
+ "letterSpacing",
108
+ "textAlign",
109
+ "textTransform",
110
+ "textDecoration",
111
+ "border",
112
+ "borderTop",
113
+ "borderBottom",
114
+ "borderColor",
115
+ "borderRadius",
116
+ "boxShadow",
117
+ "opacity",
118
+ "overflow",
119
+ "objectFit",
120
+ "aspectRatio",
121
+ "transition",
122
+ "transform"
123
+ ];
124
+ var Breakpoints = {
125
+ tablet: "(max-width: 1023px)",
126
+ mobile: "(max-width: 767px)"
127
+ };
128
+ var StyleValueSchema = import_zod.z.string().max(500).regex(/^[^;{}<]*$/, "A style value cannot contain ; { } or <").refine((value) => !/(expression\s*\(|javascript:|@import)/i.test(value), {
129
+ message: "A style value cannot contain expression(), javascript: or @import"
130
+ }).refine((value) => !findUrls(value).some((url) => !isAllowedUrl(url)), {
131
+ message: "A style url() must be https:// or a data: image"
132
+ });
133
+ var DeclarationsSchema = import_zod.z.object(
134
+ Object.fromEntries(
135
+ StyleProperties.map((property) => [property, StyleValueSchema.optional()])
136
+ )
137
+ );
138
+ var BlockStyleSchema = DeclarationsSchema.extend({
139
+ tablet: DeclarationsSchema.optional(),
140
+ mobile: DeclarationsSchema.optional()
141
+ });
142
+ var CssSchema = import_zod.z.string().max(2e4).refine((value) => !value.includes("<"), { message: "CSS cannot contain <" }).refine((value) => !/(@import|expression\s*\(|javascript:|behavior\s*:)/i.test(value), {
143
+ message: "CSS cannot contain @import, expression(), javascript: or behavior"
144
+ }).refine((value) => !findUrls(value).some((url) => !isAllowedUrl(url)), {
145
+ message: "CSS url() must be https:// or a data: image"
146
+ });
147
+ function styleToCss(selector, style) {
148
+ if (!style) return "";
149
+ const { tablet, mobile, ...base } = style;
150
+ return [
151
+ rule(selector, base),
152
+ media(Breakpoints.tablet, rule(selector, tablet)),
153
+ media(Breakpoints.mobile, rule(selector, mobile))
154
+ ].filter(Boolean).join("\n");
155
+ }
156
+ function rule(selector, declarations) {
157
+ const body = Object.entries(declarations != null ? declarations : {}).filter(([, value]) => typeof value === "string" && value.trim() !== "").map(([property, value]) => `${kebab(property)}: ${value};`).join(" ");
158
+ return body ? `${selector} { ${body} }` : "";
159
+ }
160
+ function media(query, body) {
161
+ return body ? `@media ${query} { ${body} }` : "";
162
+ }
163
+ function kebab(property) {
164
+ return property.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
165
+ }
166
+ function findUrls(value) {
167
+ return [...value.matchAll(/url\(\s*(['"]?)([^'")]*)\1\s*\)/gi)].map((match) => match[2].trim());
168
+ }
169
+ function isAllowedUrl(url) {
170
+ return /^https:\/\//i.test(url) || /^data:image\//i.test(url);
171
+ }
172
+
173
+ // src/blocks/layout.tsx
174
+ var import_react = require("react");
175
+ var import_zod3 = require("zod");
176
+
177
+ // src/block.ts
178
+ var import_zod2 = require("zod");
179
+ var BlockIdSchema = import_zod2.z.string().min(1).max(100).regex(/^[A-Za-z0-9_-]+$/, "A block id can only contain letters, digits, _ and -");
180
+ var ClassNameSchema = import_zod2.z.string().max(200).regex(/^[A-Za-z0-9_\- ]*$/, "A class name can only contain letters, digits, _, - and spaces");
181
+ var BlockNodeSchema = import_zod2.z.object({
182
+ type: import_zod2.z.string().min(1),
183
+ props: import_zod2.z.looseObject({ id: BlockIdSchema })
184
+ });
185
+ var BaseBlockPropsSchema = import_zod2.z.object({
186
+ id: BlockIdSchema,
187
+ className: ClassNameSchema.optional(),
188
+ style: BlockStyleSchema.optional(),
189
+ css: CssSchema.optional()
190
+ });
191
+ function defineBlock(definition) {
192
+ var _a;
193
+ const slots = (_a = definition.slots) != null ? _a : [];
194
+ return {
195
+ ...definition,
196
+ slots,
197
+ defaultProps: {
198
+ ...definition.schema.parse({}),
199
+ ...Object.fromEntries(slots.map((slot) => [slot, []]))
200
+ }
201
+ };
202
+ }
203
+ function blockRoot(props, ...classNames) {
204
+ const className = [...classNames, props.className].filter(Boolean).join(" ");
205
+ return { "data-block": props.id, className: className || void 0 };
206
+ }
207
+
208
+ // src/blocks/layout.tsx
209
+ var import_jsx_runtime = require("react/jsx-runtime");
210
+ var AnchorIdSchema = import_zod3.z.string().max(60).regex(/^[A-Za-z0-9_-]*$/, "An anchor id can only contain letters, digits, _ and -");
211
+ var Section = defineBlock({
212
+ type: "Section",
213
+ label: "Section",
214
+ description: "A full-width page section that holds other blocks. Give it an anchorId so buttons can link to it with #anchorId.",
215
+ category: "layout",
216
+ schema: import_zod3.z.object({
217
+ tag: import_zod3.z.enum(["section", "div", "header", "footer", "aside", "nav"]).default("section"),
218
+ anchorId: AnchorIdSchema.default("")
219
+ }),
220
+ slots: ["content"],
221
+ fields: {
222
+ tag: {
223
+ type: "select",
224
+ label: "HTML tag",
225
+ options: ["section", "div", "header", "footer", "aside", "nav"].map((tag) => ({
226
+ label: tag,
227
+ value: tag
228
+ }))
229
+ },
230
+ anchorId: { type: "text", label: "Anchor id" }
231
+ },
232
+ render: (props) => (0, import_react.createElement)(
233
+ props.tag,
234
+ { ...blockRoot(props), id: props.anchorId || void 0 },
235
+ props.slots.content
236
+ )
237
+ });
238
+ var Stack = defineBlock({
239
+ type: "Stack",
240
+ label: "Stack",
241
+ description: "A plain container that groups blocks. Use style (display, flexDirection, gap) to lay them out.",
242
+ category: "layout",
243
+ schema: import_zod3.z.object({}),
244
+ slots: ["content"],
245
+ fields: {},
246
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { ...blockRoot(props), children: props.slots.content })
247
+ });
248
+ var Columns = defineBlock({
249
+ type: "Columns",
250
+ label: "Columns",
251
+ description: "Puts up to four columns side by side on desktop and stacks them on mobile. Fill column1 to columnN, where N is count.",
252
+ category: "layout",
253
+ schema: import_zod3.z.object({
254
+ count: import_zod3.z.union([import_zod3.z.literal(2), import_zod3.z.literal(3), import_zod3.z.literal(4)]).default(2),
255
+ stackOnMobile: import_zod3.z.boolean().default(true)
256
+ }),
257
+ slots: ["column1", "column2", "column3", "column4"],
258
+ fields: {
259
+ count: {
260
+ type: "select",
261
+ label: "Columns",
262
+ options: [2, 3, 4].map((count) => ({ label: String(count), value: count }))
263
+ },
264
+ stackOnMobile: {
265
+ type: "radio",
266
+ label: "Stack on mobile",
267
+ options: [
268
+ { label: "Yes", value: true },
269
+ { label: "No", value: false }
270
+ ]
271
+ }
272
+ },
273
+ render: (props) => {
274
+ const columns = [
275
+ props.slots.column1,
276
+ props.slots.column2,
277
+ props.slots.column3,
278
+ props.slots.column4
279
+ ];
280
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
281
+ "div",
282
+ {
283
+ ...blockRoot(
284
+ props,
285
+ "lx-columns",
286
+ `lx-columns--${props.count}`,
287
+ props.stackOnMobile && "lx-columns--stack"
288
+ ),
289
+ children: columns.slice(0, props.count).map((column, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "lx-columns__column", children: column }, index))
290
+ }
291
+ );
292
+ },
293
+ baseCss: `
294
+ .lx-columns { display: grid; gap: 24px; }
295
+ .lx-columns--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
296
+ .lx-columns--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
297
+ .lx-columns--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
298
+ @media (max-width: 767px) { .lx-columns--stack { grid-template-columns: minmax(0, 1fr); } }
299
+ `
300
+ });
301
+
302
+ // src/blocks/content.tsx
303
+ var import_react2 = require("react");
304
+ var import_zod4 = require("zod");
305
+ var import_jsx_runtime2 = require("react/jsx-runtime");
306
+ var LinkSchema = import_zod4.z.string().max(2e3).regex(
307
+ /^(https?:\/\/|\/|#|tel:|mailto:)/,
308
+ "A link must start with https://, http://, /, #, tel: or mailto:"
309
+ );
310
+ var ImageSourceSchema = import_zod4.z.string().max(2e3).regex(/^(https:\/\/|\/|$)/, "An image must be an https:// or / url");
311
+ var Heading = defineBlock({
312
+ type: "Heading",
313
+ label: "Heading",
314
+ description: "A title. Use level h1 once per page.",
315
+ category: "content",
316
+ schema: import_zod4.z.object({
317
+ text: import_zod4.z.string().max(500).default("Heading"),
318
+ level: import_zod4.z.enum(["h1", "h2", "h3", "h4", "h5", "h6"]).default("h2")
319
+ }),
320
+ fields: {
321
+ text: { type: "text", label: "Text" },
322
+ level: {
323
+ type: "select",
324
+ label: "Level",
325
+ options: ["h1", "h2", "h3", "h4", "h5", "h6"].map((level) => ({
326
+ label: level.toUpperCase(),
327
+ value: level
328
+ }))
329
+ }
330
+ },
331
+ render: (props) => (0, import_react2.createElement)(props.level, blockRoot(props, "lx-heading"), props.text),
332
+ baseCss: `.lx-heading { margin: 0; }`
333
+ });
334
+ var Text = defineBlock({
335
+ type: "Text",
336
+ label: "Text",
337
+ description: "A paragraph. Line breaks in text are kept.",
338
+ category: "content",
339
+ schema: import_zod4.z.object({
340
+ text: import_zod4.z.string().max(1e4).default("Text")
341
+ }),
342
+ fields: {
343
+ text: { type: "textarea", label: "Text" }
344
+ },
345
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { ...blockRoot(props, "lx-text"), children: props.text }),
346
+ baseCss: `.lx-text { margin: 0; white-space: pre-line; }`
347
+ });
348
+ var Image = defineBlock({
349
+ type: "Image",
350
+ label: "Image",
351
+ description: "An image, optionally wrapped in a link. Set loading to eager for the first image a visitor sees.",
352
+ category: "content",
353
+ schema: import_zod4.z.object({
354
+ src: ImageSourceSchema.default(""),
355
+ alt: import_zod4.z.string().max(300).default(""),
356
+ href: LinkSchema.or(import_zod4.z.literal("")).default(""),
357
+ loading: import_zod4.z.enum(["lazy", "eager"]).default("lazy")
358
+ }),
359
+ fields: {
360
+ src: { type: "text", label: "Image url" },
361
+ alt: { type: "text", label: "Alternative text" },
362
+ href: { type: "text", label: "Link" },
363
+ loading: {
364
+ type: "radio",
365
+ label: "Loading",
366
+ options: [
367
+ { label: "Lazy", value: "lazy" },
368
+ { label: "Eager", value: "eager" }
369
+ ]
370
+ }
371
+ },
372
+ preload: (props) => props.loading === "eager" && props.src ? [props.src] : [],
373
+ render: (props) => {
374
+ if (!props.src) return null;
375
+ const image = /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
376
+ "img",
377
+ {
378
+ ...props.href ? {} : blockRoot(props, "lx-image"),
379
+ src: props.src,
380
+ alt: props.alt,
381
+ loading: props.loading === "lazy" ? "lazy" : void 0,
382
+ fetchPriority: props.loading === "eager" ? "high" : void 0,
383
+ decoding: "async"
384
+ }
385
+ );
386
+ return props.href ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("a", { ...blockRoot(props, "lx-image"), href: props.href, children: image }) : image;
387
+ },
388
+ baseCss: `.lx-image { display: block; max-width: 100%; }`
389
+ });
390
+ var Button = defineBlock({
391
+ type: "Button",
392
+ label: "Button",
393
+ description: "A call-to-action link styled as a button. Link to #order to scroll to the order form.",
394
+ category: "content",
395
+ schema: import_zod4.z.object({
396
+ label: import_zod4.z.string().max(200).default("Order now"),
397
+ href: LinkSchema.default("#order"),
398
+ newTab: import_zod4.z.boolean().default(false)
399
+ }),
400
+ fields: {
401
+ label: { type: "text", label: "Label" },
402
+ href: { type: "text", label: "Link" },
403
+ newTab: {
404
+ type: "radio",
405
+ label: "Open in a new tab",
406
+ options: [
407
+ { label: "Yes", value: true },
408
+ { label: "No", value: false }
409
+ ]
410
+ }
411
+ },
412
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
413
+ "a",
414
+ {
415
+ ...blockRoot(props, "lx-button"),
416
+ href: props.href,
417
+ target: props.newTab ? "_blank" : void 0,
418
+ rel: props.newTab ? "noopener noreferrer" : void 0,
419
+ children: props.label
420
+ }
421
+ ),
422
+ baseCss: `
423
+ .lx-button {
424
+ display: inline-flex;
425
+ align-items: center;
426
+ justify-content: center;
427
+ padding: 14px 24px;
428
+ border-radius: 12px;
429
+ background: var(--cs-accent);
430
+ color: var(--cs-accent-ink);
431
+ font-weight: 700;
432
+ text-decoration: none;
433
+ }
434
+ `
435
+ });
436
+ var Spacer = defineBlock({
437
+ type: "Spacer",
438
+ label: "Spacer",
439
+ description: "Empty vertical space. Set its height with style.height.",
440
+ category: "content",
441
+ schema: import_zod4.z.object({}),
442
+ fields: {},
443
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ...blockRoot(props, "lx-spacer"), "aria-hidden": "true" }),
444
+ baseCss: `.lx-spacer { height: 32px; }`
445
+ });
446
+
447
+ // src/blocks/product.tsx
448
+ var import_react4 = require("react");
449
+ var import_zod5 = require("zod");
450
+
451
+ // src/context.tsx
452
+ var import_react3 = require("react");
453
+ var import_jsx_runtime3 = require("react/jsx-runtime");
454
+ var PageDataContext = (0, import_react3.createContext)(null);
455
+ function PageDataProvider({ data, children }) {
456
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(PageDataContext.Provider, { value: data, children });
457
+ }
458
+ function usePageData() {
459
+ const data = (0, import_react3.useContext)(PageDataContext);
460
+ if (!data) {
461
+ throw new Error("Blocks must be rendered inside a PageDataProvider");
462
+ }
463
+ return data;
464
+ }
465
+ function checkoutData(data) {
466
+ if (!data.funnel || !data.product || !data.landingPage || !data.geo || !data.api) {
467
+ throw new Error("This block needs the product and checkout data of a product page");
468
+ }
469
+ return data;
470
+ }
471
+ function useCheckoutData() {
472
+ return checkoutData(usePageData());
473
+ }
474
+ function storeData(data) {
475
+ if (!data.store) {
476
+ throw new Error("This block needs the data of an online store page");
477
+ }
478
+ return data.store;
479
+ }
480
+ function useStoreData() {
481
+ return storeData(usePageData());
482
+ }
483
+
484
+ // src/blocks/product.tsx
485
+ var import_jsx_runtime4 = require("react/jsx-runtime");
486
+ function galleryImages(data) {
487
+ return data.landingPage.leadImages.length ? data.landingPage.leadImages : data.product.images;
488
+ }
489
+ var ProductTitle = defineBlock({
490
+ type: "ProductTitle",
491
+ label: "Product name",
492
+ description: "The product name, read from the product.",
493
+ category: "product",
494
+ schema: import_zod5.z.object({
495
+ level: import_zod5.z.enum(["h1", "h2", "h3"]).default("h1")
496
+ }),
497
+ fields: {
498
+ level: {
499
+ type: "select",
500
+ label: "Level",
501
+ options: ["h1", "h2", "h3"].map((level) => ({
502
+ label: level.toUpperCase(),
503
+ value: level
504
+ }))
505
+ }
506
+ },
507
+ render: function ProductTitle2(props) {
508
+ const data = useCheckoutData();
509
+ return (0, import_react4.createElement)(
510
+ props.level,
511
+ { ...blockRoot(props, "cs-title"), "data-funnel": "product-name" },
512
+ data.product.name
513
+ );
514
+ }
515
+ });
516
+ var ProductPrice = defineBlock({
517
+ type: "ProductPrice",
518
+ label: "Price",
519
+ description: "The live price and the compare-at price. The storefront script fills them from the selected offer or variant.",
520
+ category: "product",
521
+ schema: import_zod5.z.object({}),
522
+ fields: {},
523
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { ...blockRoot(props, "cs-price"), "data-funnel": "price", children: [
524
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "cs-price__current", "data-display-price": "" }),
525
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { className: "cs-price__compare", "data-compare-price": "" })
526
+ ] })
527
+ });
528
+ var ProductTagline = defineBlock({
529
+ type: "ProductTagline",
530
+ label: "Tagline",
531
+ description: "The product tagline. Renders nothing when the product has none.",
532
+ category: "product",
533
+ schema: import_zod5.z.object({}),
534
+ fields: {},
535
+ render: function ProductTagline2(props) {
536
+ const { product: product2 } = useCheckoutData();
537
+ if (!product2.tagline) return null;
538
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { ...blockRoot(props, "cs-tagline"), "data-funnel": "tagline", children: product2.tagline });
539
+ }
540
+ });
541
+ var ProductGallery = defineBlock({
542
+ type: "ProductGallery",
543
+ label: "Gallery",
544
+ description: "The main product image with clickable thumbnails. Uses the landing page lead images, or the product images when there are none.",
545
+ category: "product",
546
+ schema: import_zod5.z.object({}),
547
+ fields: {},
548
+ preload: (_props, data) => galleryImages(checkoutData(data)).slice(0, 1),
549
+ render: function ProductGallery2(props) {
550
+ const data = useCheckoutData();
551
+ const images = galleryImages(data);
552
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ...blockRoot(props, "cs-gallery"), "data-funnel": "lead-images", children: images.length ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
553
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
554
+ "img",
555
+ {
556
+ className: "cs-gallery__main",
557
+ "data-gallery-main": "",
558
+ src: images[0],
559
+ alt: data.product.name,
560
+ fetchPriority: "high",
561
+ decoding: "async"
562
+ }
563
+ ),
564
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { className: "cs-gallery__thumbs", children: images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
565
+ "img",
566
+ {
567
+ src: image,
568
+ alt: data.product.name,
569
+ "data-gallery-thumb": "",
570
+ className: index === 0 ? "is-active" : void 0,
571
+ loading: index === 0 ? void 0 : "lazy",
572
+ decoding: "async"
573
+ },
574
+ index
575
+ )) })
576
+ ] }) : null });
577
+ }
578
+ });
579
+ var LandingImages = defineBlock({
580
+ type: "LandingImages",
581
+ label: "Landing images",
582
+ description: "The landing page images stacked one under the other. Set eagerFirstImage when they are the first thing a visitor sees.",
583
+ category: "product",
584
+ schema: import_zod5.z.object({
585
+ eagerFirstImage: import_zod5.z.boolean().default(false)
586
+ }),
587
+ fields: {
588
+ eagerFirstImage: {
589
+ type: "radio",
590
+ label: "Load the first image first",
591
+ options: [
592
+ { label: "Yes", value: true },
593
+ { label: "No", value: false }
594
+ ]
595
+ }
596
+ },
597
+ preload: (props, data) => props.eagerFirstImage ? checkoutData(data).landingPage.images.slice(0, 1) : [],
598
+ render: function LandingImages2(props) {
599
+ const data = useCheckoutData();
600
+ const images = data.landingPage.images;
601
+ if (!images.length) return null;
602
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
603
+ "section",
604
+ {
605
+ ...blockRoot(props, "cs-landing-images", "cs-landing-images--flush"),
606
+ "data-funnel": "description",
607
+ children: images.map(
608
+ (image, index) => props.eagerFirstImage && index === 0 ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
609
+ "img",
610
+ {
611
+ src: image,
612
+ alt: data.product.name,
613
+ fetchPriority: "high",
614
+ decoding: "async"
615
+ },
616
+ index
617
+ ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
618
+ "img",
619
+ {
620
+ src: image,
621
+ alt: data.product.name,
622
+ loading: "lazy",
623
+ decoding: "async"
624
+ },
625
+ index
626
+ )
627
+ )
628
+ }
629
+ );
630
+ }
631
+ });
632
+ var ProductDescription = defineBlock({
633
+ type: "ProductDescription",
634
+ label: "Description",
635
+ description: "The product description text. With onlyWithoutLandingImages it shows only when the landing page has no images.",
636
+ category: "product",
637
+ schema: import_zod5.z.object({
638
+ onlyWithoutLandingImages: import_zod5.z.boolean().default(true)
639
+ }),
640
+ fields: {
641
+ onlyWithoutLandingImages: {
642
+ type: "radio",
643
+ label: "Only without landing images",
644
+ options: [
645
+ { label: "Yes", value: true },
646
+ { label: "No", value: false }
647
+ ]
648
+ }
649
+ },
650
+ render: function ProductDescription2(props) {
651
+ const data = useCheckoutData();
652
+ if (!data.product.description) return null;
653
+ if (props.onlyWithoutLandingImages && data.landingPage.images.length) return null;
654
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("section", { ...blockRoot(props, "cs-card", "cs-desc"), "data-funnel": "description", children: data.product.description });
655
+ }
656
+ });
657
+ var ProductFaq = defineBlock({
658
+ type: "ProductFaq",
659
+ label: "FAQ",
660
+ description: "The product questions and answers. Renders nothing when there are none.",
661
+ category: "product",
662
+ schema: import_zod5.z.object({}),
663
+ fields: {},
664
+ render: function ProductFaq2(props) {
665
+ const { product: product2 } = useCheckoutData();
666
+ if (!product2.faq.length) return null;
667
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("section", { ...blockRoot(props, "cs-card", "cs-faq"), "data-funnel": "faq", children: product2.faq.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("details", { children: [
668
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("summary", { children: item.question }),
669
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: item.answer })
670
+ ] }, index)) });
671
+ }
672
+ });
673
+
674
+ // src/blocks/checkout.tsx
675
+ var import_zod6 = require("zod");
676
+ var import_jsx_runtime5 = require("react/jsx-runtime");
677
+ function offerUnitCount(products2) {
678
+ return products2.reduce((sum, item) => sum + (item.quantity || 0), 0);
679
+ }
680
+ function offerUnitNumber(products2, productIndex, unitIndex) {
681
+ var _a;
682
+ let start = 0;
683
+ for (let i = 0; i < productIndex; i += 1) {
684
+ start += ((_a = products2[i]) == null ? void 0 : _a.quantity) || 0;
685
+ }
686
+ return start + unitIndex + 1;
687
+ }
688
+ function placeLabel(place) {
689
+ return place.name !== place.nameAr ? `${place.name} - ${place.nameAr}` : place.name;
690
+ }
691
+ function VariantSelects({ definitions: definitions2 }) {
692
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: definitions2.map((definition) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { className: "cs-offer__field", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("select", { "data-variant-def": definition.name, "aria-label": definition.name, children: definition.values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value, children: value }, value)) }) }, definition.name)) });
693
+ }
694
+ function VariantChips({ definitions: definitions2 }) {
695
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: definitions2.map((definition) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
696
+ "div",
697
+ {
698
+ className: "cs-variants",
699
+ "data-variant-def": definition.name,
700
+ children: [
701
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "cs-section-title", children: definition.name }),
702
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-chips", children: definition.values.map((value) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
703
+ "button",
704
+ {
705
+ type: "button",
706
+ className: "cs-chip",
707
+ "data-variant-value": value,
708
+ children: value
709
+ },
710
+ value
711
+ )) })
712
+ ]
713
+ },
714
+ definition.name
715
+ )) });
716
+ }
717
+ function OfferUnitVariants({ data, offer }) {
718
+ const { product: product2 } = data;
719
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-offer__variants", "data-offer-variants": "", children: offer.products.map(
720
+ (item, productIndex) => Array.from({ length: item.quantity }, (_unused, unit) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
721
+ "div",
722
+ {
723
+ className: "cs-offer__unit",
724
+ "data-offer-unit": "",
725
+ "data-product-id": item.trackingId,
726
+ "data-unit-index": unit,
727
+ children: [
728
+ offerUnitCount(offer.products) > 1 ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "cs-offer__unit-label", children: `#${offerUnitNumber(offer.products, productIndex, unit)}` }) : null,
729
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-offer__fields", children: product2.isBundle ? product2.bundleProducts.filter(
730
+ (bundleProduct) => bundleProduct.trackingId === item.trackingId
731
+ ).map((bundleProduct) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
732
+ VariantSelects,
733
+ {
734
+ definitions: bundleProduct.variantDefinitions
735
+ },
736
+ bundleProduct.trackingId
737
+ )) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VariantSelects, { definitions: product2.variantDefinitions }) })
738
+ ]
739
+ },
740
+ `${item.trackingId}-${productIndex}-${unit}`
741
+ ))
742
+ ) });
743
+ }
744
+ function Catalog({ data }) {
745
+ const { product: product2, offers } = data;
746
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
747
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: "cs-offers", "data-funnel": "offers", hidden: !offers.length, children: [
748
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "cs-section-title", "data-i18n": "offers" }),
749
+ offers.map((offer, index) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
750
+ "div",
751
+ {
752
+ className: [
753
+ "cs-offer",
754
+ index === 0 && "is-active",
755
+ offer.notes && "has-note"
756
+ ].filter(Boolean).join(" "),
757
+ "data-offer-id": offer.trackingId,
758
+ children: [
759
+ offer.notes ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "cs-offer__sticker", children: offer.notes }) : null,
760
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", className: "cs-offer__pick", "data-offer-pick": "", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-offer__head", children: [
761
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-offer__copy", children: [
762
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-offer__name", children: offer.name }),
763
+ offer.freeShipping ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "cs-offer__ship", "data-i18n": "freeShipping" }) : null
764
+ ] }),
765
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-offer__price", children: [
766
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
767
+ "span",
768
+ {
769
+ className: "cs-price__compare",
770
+ "data-offer-compare": "",
771
+ hidden: true
772
+ }
773
+ ),
774
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
775
+ "span",
776
+ {
777
+ className: "cs-offer__price-value",
778
+ "data-price": offer.price
779
+ }
780
+ )
781
+ ] })
782
+ ] }) }),
783
+ product2.isBundle || product2.variantDefinitions.length ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OfferUnitVariants, { data, offer }) : null
784
+ ]
785
+ },
786
+ offer.trackingId
787
+ ))
788
+ ] }),
789
+ offers.length ? null : /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
790
+ product2.isBundle ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("section", { "data-funnel": "bundle-products", children: product2.bundleProducts.map((item) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
791
+ "div",
792
+ {
793
+ className: "cs-bundle",
794
+ "data-bundle-product": item.trackingId,
795
+ children: [
796
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "cs-section-title", children: item.name }),
797
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VariantChips, { definitions: item.variantDefinitions })
798
+ ]
799
+ },
800
+ item.trackingId
801
+ )) }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("section", { "data-funnel": "variants", hidden: !product2.variantDefinitions.length, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VariantChips, { definitions: product2.variantDefinitions }) }),
802
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("section", { className: "cs-qty", "data-funnel": "qty", children: [
803
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", "data-qty": "-1", children: "-" }),
804
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { className: "cs-qty__value", "data-qty-value": "", children: "1" }),
805
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "button", "data-qty": "1", children: "+" })
806
+ ] })
807
+ ] })
808
+ ] });
809
+ }
810
+ function Totals() {
811
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-totals", "data-funnel": "totals", children: [
812
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("p", { className: "cs-section-title", "data-i18n": "orderSummary" }),
813
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-totals__row", children: [
814
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-i18n": "productsPrice" }),
815
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { "data-total": "products" })
816
+ ] }),
817
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-totals__row", children: [
818
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-i18n": "shippingPrice" }),
819
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { "data-total": "shipping" })
820
+ ] }),
821
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-totals__row cs-totals__row--total", children: [
822
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { "data-i18n": "total" }),
823
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("strong", { "data-total": "grand" })
824
+ ] })
825
+ ] });
826
+ }
827
+ function fieldAutocomplete(type) {
828
+ if (type === "phone") return "tel";
829
+ if (type === "name") return "name";
830
+ if (type === "address") return "street-address";
831
+ return "on";
832
+ }
833
+ function FormField({ data, type }) {
834
+ if (type === "state") {
835
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("select", { name: "state", "data-field": "state", children: [
836
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "" }),
837
+ data.geo.states.map((state) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
838
+ "option",
839
+ {
840
+ value: state.id,
841
+ "data-code": state.code,
842
+ "data-name": state.name,
843
+ "data-name-ar": state.nameAr,
844
+ children: placeLabel(state)
845
+ },
846
+ state.id
847
+ ))
848
+ ] });
849
+ }
850
+ if (type === "city") {
851
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("select", { name: "city", "data-field": "city", children: [
852
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "" }),
853
+ (data.lazyCities ? [] : data.geo.cities).map((city) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
854
+ "option",
855
+ {
856
+ value: city.id,
857
+ "data-code": city.code,
858
+ "data-state": city.stateId,
859
+ "data-name": city.name,
860
+ "data-name-ar": city.nameAr,
861
+ children: placeLabel(city)
862
+ },
863
+ city.id
864
+ ))
865
+ ] });
866
+ }
867
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
868
+ "input",
869
+ {
870
+ type: type === "phone" ? "tel" : "text",
871
+ name: type,
872
+ "data-field": type,
873
+ autoComplete: fieldAutocomplete(type)
874
+ }
875
+ );
876
+ }
877
+ var PrivacyLink = "https://policies.google.com/privacy";
878
+ var TermsLink = "https://policies.google.com/terms";
879
+ function RecaptchaNotice({ language }) {
880
+ const link = (href, label) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("a", { href, target: "_blank", rel: "noopener noreferrer", children: label });
881
+ if (language === "ar") {
882
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "cs-recaptcha", children: [
883
+ "\u0647\u0630\u0627 \u0627\u0644\u0645\u0648\u0642\u0639 \u0645\u062D\u0645\u064A \u0628\u0648\u0627\u0633\u0637\u0629 reCAPTCHA \u0648\u062A\u0633\u0631\u064A ",
884
+ link(PrivacyLink, "\u0633\u064A\u0627\u0633\u0629 \u0627\u0644\u062E\u0635\u0648\u0635\u064A\u0629"),
885
+ " \u0648",
886
+ " ",
887
+ link(TermsLink, "\u0634\u0631\u0648\u0637 \u0627\u0644\u062E\u062F\u0645\u0629"),
888
+ " \u0627\u0644\u062E\u0627\u0635\u0629 \u0628\u0640 Google."
889
+ ] });
890
+ }
891
+ if (language === "fr") {
892
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "cs-recaptcha", children: [
893
+ "Ce site est prot\xE9g\xE9 par reCAPTCHA et les",
894
+ " ",
895
+ link(PrivacyLink, "r\xE8gles de confidentialit\xE9"),
896
+ " et",
897
+ " ",
898
+ link(TermsLink, "conditions d'utilisation"),
899
+ " de Google s'appliquent."
900
+ ] });
901
+ }
902
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("p", { className: "cs-recaptcha", children: [
903
+ "This site is protected by reCAPTCHA and the Google ",
904
+ link(PrivacyLink, "Privacy Policy"),
905
+ " ",
906
+ "and ",
907
+ link(TermsLink, "Terms of Service"),
908
+ " apply."
909
+ ] });
910
+ }
911
+ function OrderFormView(props) {
912
+ var _a;
913
+ const data = useCheckoutData();
914
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { ...blockRoot(props, "cs-form"), "data-funnel": "form", children: [
915
+ props.includeCatalog ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Catalog, { data }) : null,
916
+ data.funnel.form.fields.filter((field) => field.enabled).map((field) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
917
+ "div",
918
+ {
919
+ className: "cs-field",
920
+ "data-funnel-field": field.type,
921
+ "data-required": String(field.required),
922
+ children: [
923
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("label", { "data-i18n": field.type }),
924
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FormField, { data, type: field.type }),
925
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { className: "cs-field__error", "data-error": "" })
926
+ ]
927
+ },
928
+ field.type
929
+ )),
930
+ ((_a = data.deliveryPrices) == null ? void 0 : _a.stopdeskEnabled) ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className: "cs-ship", "data-funnel": "shipping-method", children: [
931
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
932
+ "button",
933
+ {
934
+ type: "button",
935
+ className: "cs-chip is-active",
936
+ "data-ship": "home",
937
+ "data-i18n": "homeDelivery"
938
+ }
939
+ ),
940
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
941
+ "button",
942
+ {
943
+ type: "button",
944
+ className: "cs-chip",
945
+ "data-ship": "stopdesk",
946
+ "data-i18n": "stopDesk"
947
+ }
948
+ )
949
+ ] }) : null,
950
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Totals, {}),
951
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("button", { type: "submit", className: "cs-submit", "data-i18n": "orderNow" }),
952
+ data.api.recaptchaSiteKey ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(RecaptchaNotice, { language: data.funnel.language }) : null
953
+ ] });
954
+ }
955
+ var ProductCatalog = defineBlock({
956
+ type: "ProductCatalog",
957
+ label: "Offers and variants",
958
+ description: "The offer picker, or the variant chips and quantity when the product has no offers. Use it only when the order form does not include the catalog.",
959
+ category: "checkout",
960
+ schema: import_zod6.z.object({}),
961
+ fields: {},
962
+ render: function ProductCatalog2(props) {
963
+ const data = useCheckoutData();
964
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { ...blockRoot(props), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(Catalog, { data }) });
965
+ }
966
+ });
967
+ var OrderForm = defineBlock({
968
+ type: "OrderForm",
969
+ label: "Order form",
970
+ description: "The checkout form: customer fields, shipping method, totals and the order button. Every funnel page needs exactly one. Set includeCatalog to show the offers and variants inside the form.",
971
+ category: "checkout",
972
+ schema: import_zod6.z.object({
973
+ includeCatalog: import_zod6.z.boolean().default(true)
974
+ }),
975
+ fields: {
976
+ includeCatalog: {
977
+ type: "radio",
978
+ label: "Show offers and variants in the form",
979
+ options: [
980
+ { label: "Yes", value: true },
981
+ { label: "No", value: false }
982
+ ]
983
+ }
984
+ },
985
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(OrderFormView, { ...props })
986
+ });
987
+
988
+ // src/blocks/store.tsx
989
+ var import_zod7 = require("zod");
990
+
991
+ // src/money.ts
992
+ function moneyFormatter({
993
+ language,
994
+ iso2,
995
+ currency
996
+ }) {
997
+ const options = {
998
+ style: "currency",
999
+ currency,
1000
+ currencyDisplay: "symbol",
1001
+ minimumFractionDigits: 0,
1002
+ maximumFractionDigits: 2
1003
+ };
1004
+ const country = iso2.toUpperCase();
1005
+ const part = (locale2) => {
1006
+ var _a, _b;
1007
+ return (_b = (_a = new Intl.NumberFormat(locale2, options).formatToParts(0).find((p) => p.type === "currency")) == null ? void 0 : _a.value) != null ? _b : "";
1008
+ };
1009
+ const isCode = (symbol2) => symbol2.replace(/\./g, "").toUpperCase() === currency.toUpperCase();
1010
+ const locale = `${language}-${country}`;
1011
+ const formatter = new Intl.NumberFormat(locale, options);
1012
+ const symbol = [locale, `fr-${country}`, `ar-${country}`].map(part).find((item) => !isCode(item));
1013
+ return (value) => formatter.formatToParts(value).map((item) => item.type === "currency" ? symbol != null ? symbol : item.value : item.value).join("");
1014
+ }
1015
+
1016
+ // src/blocks/store.tsx
1017
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1018
+ var LabelKeys = [
1019
+ "bestSellers",
1020
+ "newArrivals",
1021
+ "shopByCategory",
1022
+ "youMayAlsoLike",
1023
+ "categories",
1024
+ "allProducts",
1025
+ "cod"
1026
+ ];
1027
+ var LabelKeySchema = import_zod7.z.enum(LabelKeys);
1028
+ var labelOptions = LabelKeys.map((key) => ({ label: key, value: key }));
1029
+ var TextSchema = import_zod7.z.string().max(300);
1030
+ function heading(store, text, label) {
1031
+ return text || store.labels[label];
1032
+ }
1033
+ var MenuIcon = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1034
+ "svg",
1035
+ {
1036
+ viewBox: "0 0 24 24",
1037
+ width: "22",
1038
+ height: "22",
1039
+ fill: "none",
1040
+ stroke: "currentColor",
1041
+ strokeWidth: "1.8",
1042
+ strokeLinecap: "round",
1043
+ "aria-hidden": "true",
1044
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M3 6h18M3 12h18M3 18h18" })
1045
+ }
1046
+ );
1047
+ var SearchIcon = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1048
+ "svg",
1049
+ {
1050
+ viewBox: "0 0 24 24",
1051
+ width: "22",
1052
+ height: "22",
1053
+ fill: "none",
1054
+ stroke: "currentColor",
1055
+ strokeWidth: "1.8",
1056
+ strokeLinecap: "round",
1057
+ "aria-hidden": "true",
1058
+ children: [
1059
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { cx: "11", cy: "11", r: "7" }),
1060
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "m20 20-3.5-3.5" })
1061
+ ]
1062
+ }
1063
+ );
1064
+ function ProductCard({
1065
+ item,
1066
+ position,
1067
+ list,
1068
+ money
1069
+ }) {
1070
+ var _a;
1071
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1072
+ "a",
1073
+ {
1074
+ className: "card",
1075
+ href: item.url,
1076
+ "data-product-card": "",
1077
+ "data-category": (_a = item.categoryId) != null ? _a : "",
1078
+ "data-price": item.fromPrice,
1079
+ "data-name": item.product.name,
1080
+ "data-position": position,
1081
+ "data-track": "product",
1082
+ "data-product-id": item.product.trackingId,
1083
+ "data-list": list,
1084
+ children: [
1085
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "card__media", children: [
1086
+ item.cardImage ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1087
+ "img",
1088
+ {
1089
+ className: "card__image",
1090
+ src: item.cardImage,
1091
+ alt: item.product.name,
1092
+ loading: "lazy",
1093
+ decoding: "async"
1094
+ }
1095
+ ) : null,
1096
+ item.cardHoverImage ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1097
+ "img",
1098
+ {
1099
+ className: "card__hover",
1100
+ src: item.cardHoverImage,
1101
+ alt: "",
1102
+ loading: "lazy",
1103
+ decoding: "async"
1104
+ }
1105
+ ) : null,
1106
+ item.discountPercent ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "card__badge", children: `-${item.discountPercent}%` }) : null
1107
+ ] }),
1108
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "card__body", children: [
1109
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h3", { className: "card__name", children: item.product.name }),
1110
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("p", { className: "card__price", children: [
1111
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: money(item.fromPrice) }),
1112
+ item.compareAtPrice ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("s", { children: money(item.compareAtPrice) }) : null
1113
+ ] })
1114
+ ] })
1115
+ ]
1116
+ }
1117
+ );
1118
+ }
1119
+ function SectionHead({ title, viewAll }) {
1120
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "section-head", children: [
1121
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { children: title }),
1122
+ viewAll ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: viewAll }) : null
1123
+ ] });
1124
+ }
1125
+ var CategoryItemStyles = ["card", "pill", "tag", "chip", "link", "room"];
1126
+ function CategoryItem({
1127
+ entry,
1128
+ itemStyle
1129
+ }) {
1130
+ const track = { "data-track": "category", "data-category-id": entry.trackingId };
1131
+ if (itemStyle === "card") {
1132
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "category", href: entry.url, ...track, children: [
1133
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "category__media", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: entry.imageUrl, alt: entry.name, loading: "lazy", decoding: "async" }) }),
1134
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "category__name", children: entry.name })
1135
+ ] });
1136
+ }
1137
+ if (itemStyle === "chip") {
1138
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "chip-link", href: entry.url, ...track, children: [
1139
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: entry.imageUrl, alt: "", loading: "lazy", decoding: "async" }),
1140
+ entry.name
1141
+ ] });
1142
+ }
1143
+ if (itemStyle === "room") {
1144
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("a", { className: "room", href: entry.url, ...track, children: [
1145
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: entry.imageUrl, alt: entry.name, loading: "lazy", decoding: "async" }),
1146
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: entry.name })
1147
+ ] });
1148
+ }
1149
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: itemStyle === "link" ? void 0 : itemStyle, href: entry.url, ...track, children: entry.name });
1150
+ }
1151
+ function trimmed(value, characters) {
1152
+ return (value != null ? value : "").split("").filter((character) => !characters.includes(character)).join("");
1153
+ }
1154
+ var AnnouncementBar = defineBlock({
1155
+ type: "AnnouncementBar",
1156
+ label: "Announcement bar",
1157
+ description: "The thin bar above the header with the announcement text from the store settings. Renders nothing when the announcement is off.",
1158
+ category: "store",
1159
+ schema: import_zod7.z.object({}),
1160
+ fields: {},
1161
+ render: function AnnouncementBar2(props) {
1162
+ const { onlineStore } = useStoreData();
1163
+ if (!onlineStore.announcementBarEnabled || !onlineStore.announcementBarText) return null;
1164
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, "announcement"), children: onlineStore.announcementBarText });
1165
+ }
1166
+ });
1167
+ var StoreHeader = defineBlock({
1168
+ type: "StoreHeader",
1169
+ label: "Header",
1170
+ description: "The store navbar: menu button, logo, links to home, all products, the first categories and contact, the search link, and the mobile menu.",
1171
+ category: "store",
1172
+ schema: import_zod7.z.object({
1173
+ navCategories: import_zod7.z.number().int().min(0).max(12).default(4)
1174
+ }),
1175
+ fields: {
1176
+ navCategories: { type: "number", label: "Categories in the navbar" }
1177
+ },
1178
+ render: function StoreHeader2(props) {
1179
+ const { labels: t, onlineStore, categories: categories2 } = useStoreData();
1180
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { ...blockRoot(props, "head"), children: [
1181
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "head__bar", children: [
1182
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1183
+ "button",
1184
+ {
1185
+ className: "head__icon head__menu",
1186
+ type: "button",
1187
+ "data-store": "menu-toggle",
1188
+ "aria-label": t.menu,
1189
+ "aria-expanded": "false",
1190
+ children: MenuIcon
1191
+ }
1192
+ ),
1193
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "logo", href: "/", children: onlineStore.logoUrl ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { src: onlineStore.logoUrl, alt: onlineStore.name }) : onlineStore.name }),
1194
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("nav", { className: "head__nav", "aria-label": t.menu, children: [
1195
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/", children: t.home }),
1196
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: t.allProducts }),
1197
+ categories2.slice(0, props.navCategories).map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: entry.url, children: entry.name }, entry.trackingId)),
1198
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/contact", children: t.contact })
1199
+ ] }),
1200
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "head__icon head__search", href: "/products", "aria-label": t.search, children: SearchIcon })
1201
+ ] }),
1202
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("nav", { className: "menu", "data-store": "menu", hidden: true, "aria-label": t.menu, children: [
1203
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/", children: t.home }),
1204
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: t.allProducts }),
1205
+ categories2.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: entry.url, children: entry.name }, entry.trackingId)),
1206
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/about", children: t.about }),
1207
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/contact", children: t.contact })
1208
+ ] })
1209
+ ] });
1210
+ }
1211
+ });
1212
+ var StoreFooter = defineBlock({
1213
+ type: "StoreFooter",
1214
+ label: "Footer",
1215
+ description: "The store footer: name and tagline, shop links with the first categories, help and policy links, social links, and the copyright line.",
1216
+ category: "store",
1217
+ schema: import_zod7.z.object({
1218
+ footerCategories: import_zod7.z.number().int().min(0).max(12).default(5)
1219
+ }),
1220
+ fields: {
1221
+ footerCategories: { type: "number", label: "Categories in the footer" }
1222
+ },
1223
+ render: function StoreFooter2(props) {
1224
+ const { labels: t, onlineStore, categories: categories2 } = useStoreData();
1225
+ const { contact: contact2 } = onlineStore;
1226
+ const social = { rel: "noopener noreferrer", target: "_blank" };
1227
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("footer", { ...blockRoot(props, "foot"), children: [
1228
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "foot__inner", children: [
1229
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "foot__brand", children: [
1230
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "logo", href: "/", children: onlineStore.name }),
1231
+ onlineStore.tagline ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: onlineStore.tagline }) : null
1232
+ ] }),
1233
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1234
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h4", { children: t.shop }),
1235
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: t.allProducts }),
1236
+ categories2.slice(0, props.footerCategories).map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: entry.url, children: entry.name }, entry.trackingId))
1237
+ ] }),
1238
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1239
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h4", { children: t.help }),
1240
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/about", children: t.about }),
1241
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/contact", children: t.contact }),
1242
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/privacy-policy", children: t.privacyPolicy }),
1243
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/refund-policy", children: t.refundPolicy }),
1244
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/terms-of-service", children: t.termsOfService })
1245
+ ] }),
1246
+ contact2.facebook || contact2.instagram || contact2.tiktok ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { children: [
1247
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h4", { children: t.followUs }),
1248
+ contact2.facebook ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: contact2.facebook, ...social, children: "Facebook" }) : null,
1249
+ contact2.instagram ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: contact2.instagram, ...social, children: "Instagram" }) : null,
1250
+ contact2.tiktok ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: contact2.tiktok, ...social, children: "TikTok" }) : null
1251
+ ] }) : null
1252
+ ] }),
1253
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "foot__legal", children: `\xA9 ${onlineStore.name}. ${t.rights}` })
1254
+ ] });
1255
+ }
1256
+ });
1257
+ var StoreHeroTitle = defineBlock({
1258
+ type: "StoreHeroTitle",
1259
+ label: "Hero title",
1260
+ description: "The home page headline. Uses text when set, otherwise the hero title from the store settings, otherwise a default for the store language.",
1261
+ category: "store",
1262
+ schema: import_zod7.z.object({ text: TextSchema.default("") }),
1263
+ fields: { text: { type: "text", label: "Text" } },
1264
+ render: function StoreHeroTitle2(props) {
1265
+ const { labels: t, onlineStore } = useStoreData();
1266
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { ...blockRoot(props, "hero__title"), children: props.text || onlineStore.hero.title || t.heroTitle });
1267
+ }
1268
+ });
1269
+ var StoreHeroSubtitle = defineBlock({
1270
+ type: "StoreHeroSubtitle",
1271
+ label: "Hero subtitle",
1272
+ description: "The line under the home page headline. Uses text when set, otherwise the hero subtitle from the store settings, otherwise a default.",
1273
+ category: "store",
1274
+ schema: import_zod7.z.object({ text: TextSchema.default("") }),
1275
+ fields: { text: { type: "textarea", label: "Text" } },
1276
+ render: function StoreHeroSubtitle2(props) {
1277
+ const { labels: t, onlineStore } = useStoreData();
1278
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { ...blockRoot(props, "hero__subtitle"), children: props.text || onlineStore.hero.subtitle || t.heroSubtitle });
1279
+ }
1280
+ });
1281
+ var StoreHeroButton = defineBlock({
1282
+ type: "StoreHeroButton",
1283
+ label: "Hero button",
1284
+ description: "The home page call to action. Links to all products. Uses label when set, otherwise the hero button label from the store settings.",
1285
+ category: "store",
1286
+ schema: import_zod7.z.object({
1287
+ label: TextSchema.default(""),
1288
+ href: import_zod7.z.string().max(500).regex(/^(https?:\/\/|\/|#)/, "A link must start with https://, / or #").default("/products")
1289
+ }),
1290
+ fields: {
1291
+ label: { type: "text", label: "Label" },
1292
+ href: { type: "text", label: "Link" }
1293
+ },
1294
+ render: function StoreHeroButton2(props) {
1295
+ const { labels: t, onlineStore } = useStoreData();
1296
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { ...blockRoot(props, "btn"), href: props.href, children: props.label || onlineStore.hero.ctaLabel || t.shopNow });
1297
+ }
1298
+ });
1299
+ var StoreHeroImage = defineBlock({
1300
+ type: "StoreHeroImage",
1301
+ label: "Hero image",
1302
+ description: "The hero image from the store settings, loaded first. Set frameClassName to wrap it in a div. Renders nothing when the store has no hero image.",
1303
+ category: "store",
1304
+ schema: import_zod7.z.object({ frameClassName: ClassNameSchema.default("") }),
1305
+ fields: { frameClassName: { type: "text", label: "Frame class" } },
1306
+ preload: (_props, data) => {
1307
+ const imageUrl = storeData(data).onlineStore.hero.imageUrl;
1308
+ return imageUrl ? [imageUrl] : [];
1309
+ },
1310
+ render: function StoreHeroImage2(props) {
1311
+ const { onlineStore } = useStoreData();
1312
+ if (!onlineStore.hero.imageUrl) return null;
1313
+ const image = (attributes) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1314
+ "img",
1315
+ {
1316
+ ...attributes,
1317
+ src: onlineStore.hero.imageUrl,
1318
+ alt: onlineStore.name,
1319
+ fetchPriority: "high",
1320
+ decoding: "async"
1321
+ }
1322
+ );
1323
+ if (props.frameClassName) {
1324
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, props.frameClassName), children: image({}) });
1325
+ }
1326
+ return image(blockRoot(props));
1327
+ }
1328
+ });
1329
+ var StoreCategories = defineBlock({
1330
+ type: "StoreCategories",
1331
+ label: "Categories",
1332
+ description: "The store categories as links. layout nav renders a nav list, layout section renders a titled section. Renders nothing when the store has no categories.",
1333
+ category: "store",
1334
+ schema: import_zod7.z.object({
1335
+ layout: import_zod7.z.enum(["nav", "section"]).default("section"),
1336
+ listClassName: ClassNameSchema.default("categories"),
1337
+ itemStyle: import_zod7.z.enum(CategoryItemStyles).default("card"),
1338
+ title: TextSchema.default(""),
1339
+ titleLabel: LabelKeySchema.default("shopByCategory")
1340
+ }),
1341
+ fields: {
1342
+ layout: {
1343
+ type: "radio",
1344
+ label: "Layout",
1345
+ options: [
1346
+ { label: "List", value: "nav" },
1347
+ { label: "Titled section", value: "section" }
1348
+ ]
1349
+ },
1350
+ listClassName: { type: "text", label: "List class" },
1351
+ itemStyle: {
1352
+ type: "select",
1353
+ label: "Item style",
1354
+ options: CategoryItemStyles.map((style) => ({ label: style, value: style }))
1355
+ },
1356
+ title: { type: "text", label: "Title" },
1357
+ titleLabel: { type: "select", label: "Default title", options: labelOptions }
1358
+ },
1359
+ render: function StoreCategories2(props) {
1360
+ const store = useStoreData();
1361
+ if (!store.categories.length) return null;
1362
+ const items = store.categories.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CategoryItem, { entry, itemStyle: props.itemStyle }, entry.trackingId));
1363
+ if (props.layout === "nav") {
1364
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1365
+ "nav",
1366
+ {
1367
+ ...blockRoot(props, props.listClassName),
1368
+ "aria-label": store.labels.categories,
1369
+ children: items
1370
+ }
1371
+ );
1372
+ }
1373
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { ...blockRoot(props, "section"), children: [
1374
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SectionHead, { title: heading(store, props.title, props.titleLabel), viewAll: null }),
1375
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: props.listClassName, children: items })
1376
+ ] });
1377
+ }
1378
+ });
1379
+ var StoreProductGrid = defineBlock({
1380
+ type: "StoreProductGrid",
1381
+ label: "Product grid",
1382
+ description: "A titled section of product cards. source home shows the featured products first, related shows products from the same category on a product page.",
1383
+ category: "store",
1384
+ schema: import_zod7.z.object({
1385
+ source: import_zod7.z.enum(["home", "related"]).default("home"),
1386
+ gridClassName: ClassNameSchema.default(""),
1387
+ title: TextSchema.default(""),
1388
+ titleLabel: LabelKeySchema.default("bestSellers"),
1389
+ viewAll: import_zod7.z.boolean().default(true),
1390
+ hideWhenEmpty: import_zod7.z.boolean().default(true)
1391
+ }),
1392
+ fields: {
1393
+ source: {
1394
+ type: "radio",
1395
+ label: "Products",
1396
+ options: [
1397
+ { label: "Home products", value: "home" },
1398
+ { label: "Related products", value: "related" }
1399
+ ]
1400
+ },
1401
+ gridClassName: { type: "text", label: "Grid class" },
1402
+ title: { type: "text", label: "Title" },
1403
+ titleLabel: { type: "select", label: "Default title", options: labelOptions },
1404
+ viewAll: {
1405
+ type: "radio",
1406
+ label: "View all link",
1407
+ options: [
1408
+ { label: "Yes", value: true },
1409
+ { label: "No", value: false }
1410
+ ]
1411
+ },
1412
+ hideWhenEmpty: {
1413
+ type: "radio",
1414
+ label: "Hide when empty",
1415
+ options: [
1416
+ { label: "Yes", value: true },
1417
+ { label: "No", value: false }
1418
+ ]
1419
+ }
1420
+ },
1421
+ render: function StoreProductGrid2(props) {
1422
+ var _a, _b;
1423
+ const store = useStoreData();
1424
+ const products2 = props.source === "related" ? (_b = (_a = store.productPage) == null ? void 0 : _a.related) != null ? _b : [] : store.homeProducts;
1425
+ if (props.hideWhenEmpty && !products2.length) return null;
1426
+ const money = moneyFormatter(store.money);
1427
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { ...blockRoot(props, "section"), children: [
1428
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1429
+ SectionHead,
1430
+ {
1431
+ title: heading(store, props.title, props.titleLabel),
1432
+ viewAll: props.viewAll ? store.labels.viewAll : null
1433
+ }
1434
+ ),
1435
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: `grid ${props.gridClassName}`, children: products2.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1436
+ ProductCard,
1437
+ {
1438
+ item,
1439
+ position: index,
1440
+ list: props.source,
1441
+ money
1442
+ },
1443
+ item.url
1444
+ )) })
1445
+ ] });
1446
+ }
1447
+ });
1448
+ var TrustItems = [
1449
+ ["cod", "codText"],
1450
+ ["fastDelivery", "fastDeliveryText"],
1451
+ ["confirmed", "confirmedText"],
1452
+ ["easyReturns", "easyReturnsText"]
1453
+ ];
1454
+ var StoreTrust = defineBlock({
1455
+ type: "StoreTrust",
1456
+ label: "Trust badges",
1457
+ description: "Cash on delivery, fast delivery, phone confirmation and easy returns, in the store language. variant bento shows them as tiles.",
1458
+ category: "store",
1459
+ schema: import_zod7.z.object({ variant: import_zod7.z.enum(["list", "bento"]).default("list") }),
1460
+ fields: {
1461
+ variant: {
1462
+ type: "radio",
1463
+ label: "Style",
1464
+ options: [
1465
+ { label: "List", value: "list" },
1466
+ { label: "Tiles", value: "bento" }
1467
+ ]
1468
+ }
1469
+ },
1470
+ render: function StoreTrust2(props) {
1471
+ const { labels: t } = useStoreData();
1472
+ if (props.variant === "bento") {
1473
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "bento"), style: { marginBlockStart: "8px" }, children: TrustItems.map(([title, text]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "bento__tile", children: [
1474
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: t[title] }),
1475
+ t[text]
1476
+ ] }, title)) });
1477
+ }
1478
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "trust"), children: TrustItems.map(([title, text]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "trust__item", children: [
1479
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: t[title] }),
1480
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t[text] })
1481
+ ] }, title)) });
1482
+ }
1483
+ });
1484
+ var StoreTagline = defineBlock({
1485
+ type: "StoreTagline",
1486
+ label: "Tagline",
1487
+ description: "The store tagline from the settings, as a quote section. Renders nothing when the store has no tagline.",
1488
+ category: "store",
1489
+ schema: import_zod7.z.object({}),
1490
+ fields: {},
1491
+ render: function StoreTagline2(props) {
1492
+ const { onlineStore } = useStoreData();
1493
+ if (!onlineStore.tagline) return null;
1494
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: onlineStore.tagline }) });
1495
+ }
1496
+ });
1497
+ var StoreTicker = defineBlock({
1498
+ type: "StoreTicker",
1499
+ label: "Ticker",
1500
+ description: "A scrolling strip that repeats the given labels.",
1501
+ category: "store",
1502
+ schema: import_zod7.z.object({
1503
+ labels: import_zod7.z.array(LabelKeySchema).max(4).default(["newArrivals", "cod"]),
1504
+ repeat: import_zod7.z.number().int().min(1).max(20).default(8)
1505
+ }),
1506
+ fields: {
1507
+ repeat: { type: "number", label: "Repeat" }
1508
+ },
1509
+ render: function StoreTicker2(props) {
1510
+ const { labels: t } = useStoreData();
1511
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, "ticker"), "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "ticker__track", children: Array.from(
1512
+ { length: props.repeat },
1513
+ (_, index) => props.labels.map((label) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t[label] }, `${index}-${label}`))
1514
+ ) }) });
1515
+ }
1516
+ });
1517
+ var StoreSearch = defineBlock({
1518
+ type: "StoreSearch",
1519
+ label: "Search box",
1520
+ description: "A search field that opens all products filtered by the query.",
1521
+ category: "store",
1522
+ schema: import_zod7.z.object({}),
1523
+ fields: {},
1524
+ render: function StoreSearch2(props) {
1525
+ const { labels: t } = useStoreData();
1526
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("form", { ...blockRoot(props, "home-search"), action: "/products", role: "search", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("input", { type: "search", name: "q", placeholder: t.search, "aria-label": t.search }) });
1527
+ }
1528
+ });
1529
+ var Ornament = defineBlock({
1530
+ type: "Ornament",
1531
+ label: "Ornament",
1532
+ description: "An empty decorative element, drawn by its class and css.",
1533
+ category: "store",
1534
+ schema: import_zod7.z.object({}),
1535
+ fields: {},
1536
+ render: (props) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", {}) })
1537
+ });
1538
+ var StorePageHeading = defineBlock({
1539
+ type: "StorePageHeading",
1540
+ label: "Page heading",
1541
+ description: "The page title. source listing shows the category or all products with the product count, contact shows the contact title and intro, article shows the page title.",
1542
+ category: "store",
1543
+ schema: import_zod7.z.object({
1544
+ source: import_zod7.z.enum(["listing", "contact", "article"]).default("listing"),
1545
+ title: TextSchema.default(""),
1546
+ text: TextSchema.default("")
1547
+ }),
1548
+ fields: {
1549
+ source: {
1550
+ type: "select",
1551
+ label: "Page",
1552
+ options: [
1553
+ { label: "Listing", value: "listing" },
1554
+ { label: "Contact", value: "contact" },
1555
+ { label: "Article", value: "article" }
1556
+ ]
1557
+ },
1558
+ title: { type: "text", label: "Title" },
1559
+ text: { type: "textarea", label: "Text" }
1560
+ },
1561
+ render: function StorePageHeading2(props) {
1562
+ var _a, _b;
1563
+ const store = useStoreData();
1564
+ const t = store.labels;
1565
+ if (props.source === "listing") {
1566
+ const listing2 = store.listing;
1567
+ const title = props.title || ((listing2 == null ? void 0 : listing2.category) ? listing2.category.name : t.allProducts);
1568
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { ...blockRoot(props, "page-head"), children: [
1569
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: title }),
1570
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text || `${(_a = listing2 == null ? void 0 : listing2.products.length) != null ? _a : 0} ${t.productsCount}` })
1571
+ ] });
1572
+ }
1573
+ if (props.source === "contact") {
1574
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { ...blockRoot(props, "page-head"), children: [
1575
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: props.title || t.contact }),
1576
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text || t.contactIntro })
1577
+ ] });
1578
+ }
1579
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("header", { ...blockRoot(props, "page-head"), children: [
1580
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: props.title || ((_b = store.article) == null ? void 0 : _b.title) }),
1581
+ props.text ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text }) : null
1582
+ ] });
1583
+ }
1584
+ });
1585
+ var ListingToolbar = defineBlock({
1586
+ type: "ListingToolbar",
1587
+ label: "Listing toolbar",
1588
+ description: "Category filters (on all products only), the search field and the sort menu of a product listing.",
1589
+ category: "store",
1590
+ schema: import_zod7.z.object({}),
1591
+ fields: {},
1592
+ render: function ListingToolbar2(props) {
1593
+ const { labels: t, categories: categories2, listing: listing2 } = useStoreData();
1594
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "toolbar"), children: [
1595
+ !(listing2 == null ? void 0 : listing2.category) && categories2.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "toolbar__filters", children: [
1596
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "chip is-active", "data-filter-category": "", children: t.all }),
1597
+ categories2.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1598
+ "button",
1599
+ {
1600
+ type: "button",
1601
+ className: "chip",
1602
+ "data-filter-category": entry.trackingId,
1603
+ children: entry.name
1604
+ },
1605
+ entry.trackingId
1606
+ ))
1607
+ ] }) : null,
1608
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1609
+ "input",
1610
+ {
1611
+ className: "search-input",
1612
+ type: "search",
1613
+ "data-store": "search",
1614
+ placeholder: t.search,
1615
+ "aria-label": t.search
1616
+ }
1617
+ ),
1618
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("select", { "data-store": "sort", "aria-label": t.sortBy, children: [
1619
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "position", children: t.sortFeatured }),
1620
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "price-asc", children: t.sortPriceAsc }),
1621
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "price-desc", children: t.sortPriceDesc })
1622
+ ] })
1623
+ ] });
1624
+ }
1625
+ });
1626
+ var ListingGrid = defineBlock({
1627
+ type: "ListingGrid",
1628
+ label: "Listing products",
1629
+ description: "The product cards of a listing page, filtered and sorted in the browser.",
1630
+ category: "store",
1631
+ schema: import_zod7.z.object({}),
1632
+ fields: {},
1633
+ render: function ListingGrid2(props) {
1634
+ var _a, _b;
1635
+ const store = useStoreData();
1636
+ const money = moneyFormatter(store.money);
1637
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, "grid"), "data-store": "listing", children: ((_b = (_a = store.listing) == null ? void 0 : _a.products) != null ? _b : []).map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1638
+ ProductCard,
1639
+ {
1640
+ item,
1641
+ position: index,
1642
+ list: "listing",
1643
+ money
1644
+ },
1645
+ item.url
1646
+ )) });
1647
+ }
1648
+ });
1649
+ var ListingEmpty = defineBlock({
1650
+ type: "ListingEmpty",
1651
+ label: "No results",
1652
+ description: "The message shown when the listing filters match no product.",
1653
+ category: "store",
1654
+ schema: import_zod7.z.object({ text: TextSchema.default("") }),
1655
+ fields: { text: { type: "text", label: "Text" } },
1656
+ render: function ListingEmpty2(props) {
1657
+ const { labels: t } = useStoreData();
1658
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { ...blockRoot(props, "empty"), "data-store": "empty", hidden: true, children: props.text || t.noProducts });
1659
+ }
1660
+ });
1661
+ var ListingLoadMore = defineBlock({
1662
+ type: "ListingLoadMore",
1663
+ label: "Load more",
1664
+ description: "The button that shows the next products of a long listing.",
1665
+ category: "store",
1666
+ schema: import_zod7.z.object({ label: TextSchema.default("") }),
1667
+ fields: { label: { type: "text", label: "Label" } },
1668
+ render: function ListingLoadMore2(props) {
1669
+ const { labels: t } = useStoreData();
1670
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { ...blockRoot(props, "more"), "data-store": "load-more", hidden: true, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { type: "button", className: "btn btn--ghost", children: props.label || t.loadMore }) });
1671
+ }
1672
+ });
1673
+ var StoreProductGallery = defineBlock({
1674
+ type: "StoreProductGallery",
1675
+ label: "Product gallery",
1676
+ description: "The product page images with thumbnails. The first image loads first.",
1677
+ category: "store",
1678
+ schema: import_zod7.z.object({}),
1679
+ fields: {},
1680
+ preload: (_props, data) => {
1681
+ var _a, _b;
1682
+ return ((_b = (_a = storeData(data).productPage) == null ? void 0 : _a.gallery) != null ? _b : []).slice(0, 1);
1683
+ },
1684
+ render: function StoreProductGallery2(props) {
1685
+ var _a, _b;
1686
+ const store = useStoreData();
1687
+ const { product: product2 } = useCheckoutData();
1688
+ const gallery = (_b = (_a = store.productPage) == null ? void 0 : _a.gallery) != null ? _b : [];
1689
+ const name = product2.name;
1690
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { ...blockRoot(props, "pdp__media"), "data-funnel": "lead-images", children: [
1691
+ gallery.length ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1692
+ "img",
1693
+ {
1694
+ className: "pdp__main",
1695
+ "data-gallery-main": "",
1696
+ src: gallery[0],
1697
+ alt: name,
1698
+ fetchPriority: "high",
1699
+ decoding: "async"
1700
+ }
1701
+ ) : null,
1702
+ gallery.length > 1 ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "pdp__thumbs", children: gallery.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1703
+ "img",
1704
+ {
1705
+ src: image,
1706
+ alt: name,
1707
+ "data-gallery-thumb": "",
1708
+ className: index === 0 ? "is-active" : void 0,
1709
+ loading: index === 0 ? void 0 : "lazy",
1710
+ decoding: "async"
1711
+ },
1712
+ `${index}-${image}`
1713
+ )) }) : null
1714
+ ] });
1715
+ }
1716
+ });
1717
+ var StoreBreadcrumbs = defineBlock({
1718
+ type: "StoreBreadcrumbs",
1719
+ label: "Breadcrumbs",
1720
+ description: "Home and the product category above the product name.",
1721
+ category: "store",
1722
+ schema: import_zod7.z.object({}),
1723
+ fields: {},
1724
+ render: function StoreBreadcrumbs2(props) {
1725
+ const { labels: t, productPage } = useStoreData();
1726
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("nav", { ...blockRoot(props, "crumbs"), "aria-label": t.menu, children: [
1727
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/", children: t.home }),
1728
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "/" }),
1729
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { href: "/products", children: (productPage == null ? void 0 : productPage.categoryName) || t.allProducts })
1730
+ ] });
1731
+ }
1732
+ });
1733
+ var StoreProductTitle = defineBlock({
1734
+ type: "StoreProductTitle",
1735
+ label: "Product name",
1736
+ description: "The product name on a store product page.",
1737
+ category: "store",
1738
+ schema: import_zod7.z.object({}),
1739
+ fields: {},
1740
+ render: function StoreProductTitle2(props) {
1741
+ const { product: product2 } = useCheckoutData();
1742
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { ...blockRoot(props, "pdp__title"), "data-funnel": "product-name", children: product2.name });
1743
+ }
1744
+ });
1745
+ var StoreProductPrice = defineBlock({
1746
+ type: "StoreProductPrice",
1747
+ label: "Product price",
1748
+ description: "The product price on a store product page. The checkout replaces it with the price of the chosen offer.",
1749
+ category: "store",
1750
+ schema: import_zod7.z.object({}),
1751
+ fields: {},
1752
+ render: function StoreProductPrice2(props) {
1753
+ var _a, _b;
1754
+ const store = useStoreData();
1755
+ const money = moneyFormatter(store.money);
1756
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "cs-price"), "data-funnel": "price", children: [
1757
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "cs-price__current", "data-display-price": "", children: money((_b = (_a = store.productPage) == null ? void 0 : _a.price) != null ? _b : 0) }),
1758
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { className: "cs-price__compare", "data-compare-price": "" })
1759
+ ] });
1760
+ }
1761
+ });
1762
+ var StoreProductDescription = defineBlock({
1763
+ type: "StoreProductDescription",
1764
+ label: "Product description",
1765
+ description: "The landing page images of the product, or its text description when it has no images. Renders nothing when it has neither.",
1766
+ category: "store",
1767
+ schema: import_zod7.z.object({}),
1768
+ fields: {},
1769
+ render: function StoreProductDescription2(props) {
1770
+ const { product: product2, landingPage } = useCheckoutData();
1771
+ if (landingPage.images.length) {
1772
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "pdp-images"), "data-funnel": "description", children: landingPage.images.map((image, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1773
+ "img",
1774
+ {
1775
+ src: image,
1776
+ alt: product2.name,
1777
+ loading: "lazy",
1778
+ decoding: "async"
1779
+ },
1780
+ `${index}-${image}`
1781
+ )) });
1782
+ }
1783
+ if (!product2.description) return null;
1784
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "pdp-text"), "data-funnel": "description", children: product2.description });
1785
+ }
1786
+ });
1787
+ var StoreProductFaq = defineBlock({
1788
+ type: "StoreProductFaq",
1789
+ label: "Product FAQ",
1790
+ description: "The product questions and answers. Renders nothing when there are none.",
1791
+ category: "store",
1792
+ schema: import_zod7.z.object({}),
1793
+ fields: {},
1794
+ render: function StoreProductFaq2(props) {
1795
+ const { product: product2 } = useCheckoutData();
1796
+ if (!product2.faq.length) return null;
1797
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("section", { ...blockRoot(props, "pdp-faq"), "data-funnel": "faq", children: product2.faq.map((entry, index) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("details", { children: [
1798
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("summary", { children: entry.question }),
1799
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: entry.answer })
1800
+ ] }, index)) });
1801
+ }
1802
+ });
1803
+ var ContactDetails = defineBlock({
1804
+ type: "ContactDetails",
1805
+ label: "Contact details",
1806
+ description: "WhatsApp, phone, email and address from the store settings, each when set.",
1807
+ category: "store",
1808
+ schema: import_zod7.z.object({}),
1809
+ fields: {},
1810
+ render: function ContactDetails2(props) {
1811
+ const { labels: t, onlineStore } = useStoreData();
1812
+ const { contact: contact2 } = onlineStore;
1813
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "contact__info"), children: [
1814
+ contact2.whatsapp ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "contact__row", children: [
1815
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.whatsapp }),
1816
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1817
+ "a",
1818
+ {
1819
+ dir: "ltr",
1820
+ href: `https://wa.me/${trimmed(contact2.whatsapp, ["+", " "])}`,
1821
+ rel: "noopener noreferrer",
1822
+ target: "_blank",
1823
+ "data-track": "contact",
1824
+ "data-channel": "whatsapp",
1825
+ children: contact2.whatsapp
1826
+ }
1827
+ )
1828
+ ] }) : null,
1829
+ contact2.phone ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "contact__row", children: [
1830
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.phone }),
1831
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1832
+ "a",
1833
+ {
1834
+ dir: "ltr",
1835
+ href: `tel:${trimmed(contact2.phone, [" "])}`,
1836
+ "data-track": "contact",
1837
+ "data-channel": "phone",
1838
+ children: contact2.phone
1839
+ }
1840
+ )
1841
+ ] }) : null,
1842
+ contact2.email ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "contact__row", children: [
1843
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.email }),
1844
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1845
+ "a",
1846
+ {
1847
+ href: `mailto:${contact2.email}`,
1848
+ "data-track": "contact",
1849
+ "data-channel": "email",
1850
+ children: contact2.email
1851
+ }
1852
+ )
1853
+ ] }) : null,
1854
+ contact2.address ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "contact__row", children: [
1855
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.address }),
1856
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: contact2.address })
1857
+ ] }) : null
1858
+ ] });
1859
+ }
1860
+ });
1861
+ var ContactFields = [
1862
+ { name: "name", label: "yourName", type: "text", autoComplete: "name" },
1863
+ { name: "phone", label: "yourPhone", type: "tel", autoComplete: "tel" },
1864
+ { name: "email", label: "yourEmail", type: "email", autoComplete: "email" }
1865
+ ];
1866
+ var ContactForm = defineBlock({
1867
+ type: "ContactForm",
1868
+ label: "Contact form",
1869
+ description: "The contact form (name, phone, optional email, message) with its success message. Messages reach the merchant inbox.",
1870
+ category: "store",
1871
+ schema: import_zod7.z.object({}),
1872
+ fields: {},
1873
+ render: function ContactForm2(props) {
1874
+ const { labels: t } = useStoreData();
1875
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props), children: [
1876
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { className: "form", "data-store": "contact-form", noValidate: true, children: [
1877
+ ContactFields.map((field) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "field", "data-contact-wrap": "", children: [
1878
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: `contact-${field.name}`, children: t[field.label] }),
1879
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1880
+ "input",
1881
+ {
1882
+ id: `contact-${field.name}`,
1883
+ name: field.name,
1884
+ type: field.type === "text" ? void 0 : field.type,
1885
+ autoComplete: field.autoComplete,
1886
+ "data-contact-field": field.name
1887
+ }
1888
+ ),
1889
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "field__error", "data-error": "" })
1890
+ ] }, field.name)),
1891
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "field", "data-contact-wrap": "", children: [
1892
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("label", { htmlFor: "contact-message", children: t.yourMessage }),
1893
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1894
+ "textarea",
1895
+ {
1896
+ id: "contact-message",
1897
+ name: "message",
1898
+ "data-contact-field": "message"
1899
+ }
1900
+ ),
1901
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "field__error", "data-error": "" })
1902
+ ] }),
1903
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { className: "form__error", "data-store": "contact-error", hidden: true }),
1904
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("button", { className: "btn", type: "submit", children: t.send })
1905
+ ] }),
1906
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "notice", "data-store": "contact-success", hidden: true, children: [
1907
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { children: t.messageSent }),
1908
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.messageSentText })
1909
+ ] })
1910
+ ] });
1911
+ }
1912
+ });
1913
+ var OrderRows = [
1914
+ ["offer", "offer", false],
1915
+ ["customer", "customer", false],
1916
+ ["phone", "phone", true],
1917
+ ["delivery", "state", false],
1918
+ ["city", "city", false],
1919
+ ["deliveryAddress", "address", false]
1920
+ ];
1921
+ var StoreThankYou = defineBlock({
1922
+ type: "StoreThankYou",
1923
+ label: "Thank you",
1924
+ description: "The thank-you message and the order summary the checkout fills in from the browser, with a link back to the products.",
1925
+ category: "store",
1926
+ schema: import_zod7.z.object({
1927
+ title: TextSchema.default(""),
1928
+ text: TextSchema.default("")
1929
+ }),
1930
+ fields: {
1931
+ title: { type: "text", label: "Title" },
1932
+ text: { type: "textarea", label: "Text" }
1933
+ },
1934
+ render: function StoreThankYou2(props) {
1935
+ const { labels: t } = useStoreData();
1936
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "wrap"), "data-store": "thank-you", children: [
1937
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "center", children: [
1938
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: props.title || t.thankYouTitle }),
1939
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text || t.thankYouText })
1940
+ ] }),
1941
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("section", { className: "order", "data-store": "order-details", hidden: true, children: [
1942
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h2", { children: t.orderDetails }),
1943
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__product", children: [
1944
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("img", { "data-order-image": "", alt: "", hidden: true }),
1945
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("strong", { "data-order": "product" })
1946
+ ] }),
1947
+ OrderRows.map(([label, field, ltr]) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__row", "data-order-row": "", children: [
1948
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t[label] }),
1949
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-order": field, dir: ltr ? "ltr" : void 0 })
1950
+ ] }, field)),
1951
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__row", children: [
1952
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.productsPrice }),
1953
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-order": "products" })
1954
+ ] }),
1955
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__row", children: [
1956
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.delivery }),
1957
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-order": "shipping" })
1958
+ ] }),
1959
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className: "order__row order__row--total", children: [
1960
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: t.total }),
1961
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { "data-order": "total" })
1962
+ ] })
1963
+ ] }),
1964
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { className: "center", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "btn", href: "/products", children: t.keepShopping }) })
1965
+ ] });
1966
+ }
1967
+ });
1968
+ var StoreNotFound = defineBlock({
1969
+ type: "StoreNotFound",
1970
+ label: "Not found",
1971
+ description: "The message of the 404 page with a link back home.",
1972
+ category: "store",
1973
+ schema: import_zod7.z.object({
1974
+ title: TextSchema.default(""),
1975
+ text: TextSchema.default("")
1976
+ }),
1977
+ fields: {
1978
+ title: { type: "text", label: "Title" },
1979
+ text: { type: "textarea", label: "Text" }
1980
+ },
1981
+ render: function StoreNotFound2(props) {
1982
+ const { labels: t } = useStoreData();
1983
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { ...blockRoot(props, "center"), children: [
1984
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("h1", { children: props.title || t.notFoundTitle }),
1985
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("p", { children: props.text || t.notFoundText }),
1986
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("a", { className: "btn", href: "/", children: t.backHome })
1987
+ ] });
1988
+ }
1989
+ });
1990
+ var StoreArticle = defineBlock({
1991
+ type: "StoreArticle",
1992
+ label: "Page text",
1993
+ description: "The text of an about or policy page, written in the store settings. Headings and lists come from the settings text.",
1994
+ category: "store",
1995
+ schema: import_zod7.z.object({}),
1996
+ fields: {},
1997
+ render: function StoreArticle2(props) {
1998
+ var _a;
1999
+ const { article: article2 } = useStoreData();
2000
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2001
+ "article",
2002
+ {
2003
+ ...blockRoot(props, "article"),
2004
+ dangerouslySetInnerHTML: { __html: (_a = article2 == null ? void 0 : article2.html) != null ? _a : "" }
2005
+ }
2006
+ );
2007
+ }
2008
+ });
2009
+
2010
+ // src/blocks/index.ts
2011
+ var definitions = [
2012
+ Section,
2013
+ Stack,
2014
+ Columns,
2015
+ Heading,
2016
+ Text,
2017
+ Image,
2018
+ Button,
2019
+ Spacer,
2020
+ ProductTitle,
2021
+ ProductPrice,
2022
+ ProductTagline,
2023
+ ProductGallery,
2024
+ LandingImages,
2025
+ ProductDescription,
2026
+ ProductFaq,
2027
+ ProductCatalog,
2028
+ OrderForm,
2029
+ AnnouncementBar,
2030
+ StoreHeader,
2031
+ StoreFooter,
2032
+ StoreHeroTitle,
2033
+ StoreHeroSubtitle,
2034
+ StoreHeroButton,
2035
+ StoreHeroImage,
2036
+ StoreCategories,
2037
+ StoreProductGrid,
2038
+ StoreTrust,
2039
+ StoreTagline,
2040
+ StoreTicker,
2041
+ StoreSearch,
2042
+ Ornament,
2043
+ StorePageHeading,
2044
+ ListingToolbar,
2045
+ ListingGrid,
2046
+ ListingEmpty,
2047
+ ListingLoadMore,
2048
+ StoreProductGallery,
2049
+ StoreBreadcrumbs,
2050
+ StoreProductTitle,
2051
+ StoreProductPrice,
2052
+ StoreProductDescription,
2053
+ StoreProductFaq,
2054
+ ContactDetails,
2055
+ ContactForm,
2056
+ StoreThankYou,
2057
+ StoreNotFound,
2058
+ StoreArticle
2059
+ ];
2060
+ var blocks = Object.fromEntries(
2061
+ definitions.map((definition) => [definition.type, definition])
2062
+ );
2063
+
2064
+ // src/page.ts
2065
+ var import_react5 = require("react");
2066
+
2067
+ // src/validate.ts
2068
+ var import_zod8 = require("zod");
2069
+ var FontSchema = import_zod8.z.object({
2070
+ family: import_zod8.z.string().min(1).max(60).regex(/^[A-Za-z0-9 ]+$/, "A font family can only contain letters, digits and spaces"),
2071
+ weights: import_zod8.z.array(import_zod8.z.number().int().min(100).max(900)).max(9).default([400, 700])
2072
+ });
2073
+ var PageRootPropsSchema = import_zod8.z.object({
2074
+ css: CssSchema.optional(),
2075
+ fonts: import_zod8.z.array(FontSchema).max(4).optional()
2076
+ });
2077
+ var DocumentShapeSchema = import_zod8.z.object({
2078
+ root: import_zod8.z.object({ props: import_zod8.z.unknown() }).default({ props: {} }),
2079
+ content: import_zod8.z.array(import_zod8.z.unknown())
2080
+ });
2081
+ function blockPropsSchema(definition) {
2082
+ return BaseBlockPropsSchema.extend(definition.schema.shape).extend(
2083
+ Object.fromEntries(
2084
+ definition.slots.map((slot) => [slot, import_zod8.z.array(BlockNodeSchema).default([])])
2085
+ )
2086
+ );
2087
+ }
2088
+ function parsePageDocument(input) {
2089
+ var _a;
2090
+ const issues = [];
2091
+ const shape = DocumentShapeSchema.safeParse(input);
2092
+ if (!shape.success) {
2093
+ throw new PageDocumentError(toIssues(shape.error, ""));
2094
+ }
2095
+ const root = PageRootPropsSchema.safeParse((_a = shape.data.root.props) != null ? _a : {});
2096
+ if (!root.success) {
2097
+ issues.push(...toIssues(root.error, "root.props"));
2098
+ }
2099
+ const ids = /* @__PURE__ */ new Set();
2100
+ const content = parseNodes(shape.data.content, "content", ids, issues);
2101
+ if (issues.length) {
2102
+ throw new PageDocumentError(issues);
2103
+ }
2104
+ return { root: { props: root.data }, content };
2105
+ }
2106
+ function parseNodes(nodes, path, ids, issues) {
2107
+ const parsed = [];
2108
+ nodes.forEach((raw, index) => {
2109
+ const nodePath = `${path}[${index}]`;
2110
+ const node = BlockNodeSchema.safeParse(raw);
2111
+ if (!node.success) {
2112
+ issues.push(...toIssues(node.error, nodePath));
2113
+ return;
2114
+ }
2115
+ const definition = blocks[node.data.type];
2116
+ if (!definition) {
2117
+ issues.push({
2118
+ path: `${nodePath}.type`,
2119
+ message: `Unknown block type ${node.data.type}`
2120
+ });
2121
+ return;
2122
+ }
2123
+ if (ids.has(node.data.props.id)) {
2124
+ issues.push({
2125
+ path: `${nodePath}.props.id`,
2126
+ message: `The block id ${node.data.props.id} is used more than once`
2127
+ });
2128
+ }
2129
+ ids.add(node.data.props.id);
2130
+ const props = blockPropsSchema(definition).safeParse(node.data.props);
2131
+ if (!props.success) {
2132
+ issues.push(...toIssues(props.error, `${nodePath}.props`));
2133
+ return;
2134
+ }
2135
+ const values = props.data;
2136
+ for (const slot of definition.slots) {
2137
+ values[slot] = parseNodes(
2138
+ values[slot],
2139
+ `${nodePath}.props.${slot}`,
2140
+ ids,
2141
+ issues
2142
+ );
2143
+ }
2144
+ parsed.push({ type: definition.type, props: values });
2145
+ });
2146
+ return parsed;
2147
+ }
2148
+ function toIssues(error, prefix) {
2149
+ return error.issues.map((issue) => ({
2150
+ path: [prefix, ...issue.path.map(String)].filter(Boolean).join("."),
2151
+ message: issue.message
2152
+ }));
2153
+ }
2154
+ function walkBlocks(nodes, visit) {
2155
+ var _a, _b, _c;
2156
+ for (const node of nodes) {
2157
+ visit(node);
2158
+ for (const slot of (_b = (_a = blocks[node.type]) == null ? void 0 : _a.slots) != null ? _b : []) {
2159
+ walkBlocks((_c = node.props[slot]) != null ? _c : [], visit);
2160
+ }
2161
+ }
2162
+ }
2163
+ function countBlocks(document, type) {
2164
+ let count = 0;
2165
+ walkBlocks(document.content, (node) => {
2166
+ if (node.type === type) count += 1;
2167
+ });
2168
+ return count;
2169
+ }
2170
+
2171
+ // src/page.ts
2172
+ function BlockList({ nodes }) {
2173
+ return (0, import_react5.createElement)(
2174
+ import_react5.Fragment,
2175
+ null,
2176
+ nodes.map((node) => (0, import_react5.createElement)(BlockView, { key: node.props.id, node }))
2177
+ );
2178
+ }
2179
+ function BlockView({ node }) {
2180
+ const definition = blocks[node.type];
2181
+ if (!definition) return null;
2182
+ const slots = Object.fromEntries(
2183
+ definition.slots.map((slot) => {
2184
+ var _a;
2185
+ return [
2186
+ slot,
2187
+ (0, import_react5.createElement)(BlockList, { nodes: (_a = node.props[slot]) != null ? _a : [] })
2188
+ ];
2189
+ })
2190
+ );
2191
+ return (0, import_react5.createElement)(definition.render, { ...definition.defaultProps, ...node.props, slots });
2192
+ }
2193
+ function PageContent({
2194
+ document,
2195
+ data
2196
+ }) {
2197
+ return (0, import_react5.createElement)(PageDataProvider, {
2198
+ data,
2199
+ children: (0, import_react5.createElement)(BlockList, { nodes: document.content })
2200
+ });
2201
+ }
2202
+ function blockSelector(id) {
2203
+ return `[data-block="${id}"]`;
2204
+ }
2205
+ function pageCss(document) {
2206
+ var _a;
2207
+ const base = /* @__PURE__ */ new Set();
2208
+ const scoped = [];
2209
+ walkBlocks(document.content, (node) => {
2210
+ const definition = blocks[node.type];
2211
+ if (definition == null ? void 0 : definition.baseCss) base.add(definition.baseCss);
2212
+ const selector = blockSelector(node.props.id);
2213
+ scoped.push(styleToCss(selector, node.props.style));
2214
+ if (typeof node.props.css === "string" && node.props.css.trim()) {
2215
+ scoped.push(`${selector} { ${node.props.css} }`);
2216
+ }
2217
+ });
2218
+ return [...base, (_a = document.root.props.css) != null ? _a : "", ...scoped].filter(Boolean).join("\n");
2219
+ }
2220
+ function pagePreloadImages(document, data) {
2221
+ const images = [];
2222
+ walkBlocks(document.content, (node) => {
2223
+ const definition = blocks[node.type];
2224
+ if (definition == null ? void 0 : definition.preload) {
2225
+ images.push(...definition.preload({ ...definition.defaultProps, ...node.props }, data));
2226
+ }
2227
+ });
2228
+ return [...new Set(images)];
2229
+ }
2230
+ function pageFontStylesheets(document) {
2231
+ var _a;
2232
+ return ((_a = document.root.props.fonts) != null ? _a : []).map((font) => {
2233
+ var _a2;
2234
+ const family = encodeURIComponent(font.family).replace(/%20/g, "+");
2235
+ const weights = [...new Set((_a2 = font.weights) != null ? _a2 : [400, 700])].sort((a, b) => a - b).join(";");
2236
+ return `https://fonts.googleapis.com/css2?family=${family}:wght@${weights}&display=swap`;
2237
+ });
2238
+ }
2239
+
2240
+ // src/json-schema.ts
2241
+ var import_zod9 = require("zod");
2242
+ function pageJsonSchema() {
2243
+ return {
2244
+ format: "A page is { root: { props }, content: Block[] }. A block is { type, props: { id, ...props } }. Ids are unique on the page. Slot props hold Block[]. Every block accepts style (CSS properties in camelCase, with tablet and mobile overrides) and css (CSS scoped to the block, nesting allowed, & is the block).",
2245
+ root: import_zod9.z.toJSONSchema(PageRootPropsSchema, { io: "input" }),
2246
+ blocks: Object.values(blocks).map((definition) => ({
2247
+ type: definition.type,
2248
+ label: definition.label,
2249
+ description: definition.description,
2250
+ category: definition.category,
2251
+ slots: definition.slots,
2252
+ props: import_zod9.z.toJSONSchema(blockPropsSchema(definition), { io: "input" })
2253
+ }))
2254
+ };
2255
+ }
2256
+
2257
+ // src/templates/funnels.ts
2258
+ var FunnelTemplateIds = ["classic-product", "classic-landing"];
2259
+ function block(type, id, props = {}) {
2260
+ return { type, props: { id, ...props } };
2261
+ }
2262
+ function page(content) {
2263
+ return { root: { props: {} }, content };
2264
+ }
2265
+ function classicProduct() {
2266
+ return page([
2267
+ block("Section", "hero", {
2268
+ tag: "section",
2269
+ className: "cs-hero",
2270
+ content: [
2271
+ block("ProductGallery", "gallery"),
2272
+ block("Stack", "buy-box", {
2273
+ content: [
2274
+ block("ProductTitle", "product-name", { level: "h1" }),
2275
+ block("ProductPrice", "price"),
2276
+ block("ProductTagline", "tagline"),
2277
+ block("ProductCatalog", "catalog"),
2278
+ block("OrderForm", "order-form", { includeCatalog: false })
2279
+ ]
2280
+ })
2281
+ ]
2282
+ }),
2283
+ block("LandingImages", "landing-images", { eagerFirstImage: false }),
2284
+ block("ProductDescription", "description", { onlyWithoutLandingImages: true }),
2285
+ block("ProductFaq", "faq")
2286
+ ]);
2287
+ }
2288
+ function classicLanding(options) {
2289
+ const formOnTop = options.formPosition === "top";
2290
+ const order = block("Section", "order", {
2291
+ tag: "section",
2292
+ className: "cs-card",
2293
+ anchorId: "order",
2294
+ content: [
2295
+ block("ProductTitle", "product-name", { level: "h1" }),
2296
+ block("ProductPrice", "price"),
2297
+ block("OrderForm", "order-form", { includeCatalog: true })
2298
+ ]
2299
+ });
2300
+ const images = block("LandingImages", "landing-images", { eagerFirstImage: !formOnTop });
2301
+ const description = block("ProductDescription", "description", {
2302
+ onlyWithoutLandingImages: true
2303
+ });
2304
+ return page(formOnTop ? [order, images, description] : [images, order, description]);
2305
+ }
2306
+ function funnelTemplate(templateId, options) {
2307
+ if (templateId === "classic-product") return classicProduct();
2308
+ if (templateId === "classic-landing") return classicLanding(options);
2309
+ throw new Error(`Unknown funnel template ${templateId}`);
2310
+ }
2311
+
2312
+ // src/templates/online-stores.ts
2313
+ var OnlineStoreTemplateIds = [
2314
+ "maison",
2315
+ "atelier",
2316
+ "noor",
2317
+ "block",
2318
+ "glow",
2319
+ "oud",
2320
+ "circuit",
2321
+ "hearth",
2322
+ "pebble",
2323
+ "souq"
2324
+ ];
2325
+ var OnlineStorePageTypes = [
2326
+ "header",
2327
+ "footer",
2328
+ "home",
2329
+ "all-products",
2330
+ "category",
2331
+ "product",
2332
+ "thank-you",
2333
+ "contact",
2334
+ "about",
2335
+ "privacy-policy",
2336
+ "refund-policy",
2337
+ "terms-of-service",
2338
+ "not-found"
2339
+ ];
2340
+ function block2(type, id, props = {}) {
2341
+ return { type, props: { id, ...props } };
2342
+ }
2343
+ function page2(content) {
2344
+ return { root: { props: {} }, content };
2345
+ }
2346
+ function stack(id, className, content) {
2347
+ return block2("Stack", id, { className, content });
2348
+ }
2349
+ function section(id, className, content) {
2350
+ return block2("Section", id, { tag: "section", className, content });
2351
+ }
2352
+ function heroText() {
2353
+ return [
2354
+ block2("StoreHeroTitle", "hero-title"),
2355
+ block2("StoreHeroSubtitle", "hero-subtitle"),
2356
+ block2("StoreHeroButton", "hero-button")
2357
+ ];
2358
+ }
2359
+ function heroImage(className = "") {
2360
+ return block2("StoreHeroImage", "hero-image", className ? { className } : {});
2361
+ }
2362
+ function categories(props = {}) {
2363
+ return block2("StoreCategories", "categories", props);
2364
+ }
2365
+ function categoryNav(listClassName, itemStyle) {
2366
+ return categories({ layout: "nav", listClassName, itemStyle });
2367
+ }
2368
+ function products(titleLabel, gridClassName = "") {
2369
+ return block2("StoreProductGrid", "products", {
2370
+ source: "home",
2371
+ titleLabel,
2372
+ gridClassName,
2373
+ hideWhenEmpty: false
2374
+ });
2375
+ }
2376
+ function trust() {
2377
+ return block2("StoreTrust", "trust");
2378
+ }
2379
+ var homes = {
2380
+ maison: () => [
2381
+ section("hero", "hero", [
2382
+ heroImage("hero__image"),
2383
+ stack("hero-text", "hero__text", heroText())
2384
+ ]),
2385
+ stack("main", "wrap", [
2386
+ categories(),
2387
+ block2("StoreTagline", "story", { className: "story" }),
2388
+ products("bestSellers"),
2389
+ trust()
2390
+ ])
2391
+ ],
2392
+ atelier: () => [
2393
+ section("hero", "split", [
2394
+ stack("hero-text", "split__text", heroText()),
2395
+ stack("hero-media", "split__media", [heroImage()])
2396
+ ]),
2397
+ stack("main", "wrap", [
2398
+ categoryNav("pills", "pill"),
2399
+ products("newArrivals", "editorial"),
2400
+ block2("StoreTagline", "quote", { className: "quote" }),
2401
+ trust()
2402
+ ])
2403
+ ],
2404
+ noor: () => [
2405
+ section("hero", "arch-hero", [
2406
+ stack("hero-media", "arch", [heroImage()]),
2407
+ stack("hero-text", "arch-hero__text", heroText())
2408
+ ]),
2409
+ stack("main", "wrap", [categories(), products("newArrivals"), trust()])
2410
+ ],
2411
+ block: () => [
2412
+ block2("StoreTicker", "ticker", { labels: ["newArrivals", "cod"], repeat: 8 }),
2413
+ section("hero", "poster", [heroImage(), stack("hero-text", "poster__text", heroText())]),
2414
+ categoryNav("tags", "tag"),
2415
+ products("newArrivals", "wall"),
2416
+ trust()
2417
+ ],
2418
+ glow: () => [
2419
+ section("hero", "glow-hero", [
2420
+ heroImage(),
2421
+ stack("hero-text", "glow-hero__text", heroText())
2422
+ ]),
2423
+ stack("main", "wrap", [categoryNav("chips", "chip"), products("bestSellers"), trust()])
2424
+ ],
2425
+ oud: () => [
2426
+ section("hero", "oud-hero", [
2427
+ block2("StoreHeroImage", "hero-image", { frameClassName: "oud-hero__frame" }),
2428
+ ...heroText()
2429
+ ]),
2430
+ block2("Ornament", "rule", { className: "oud-rule" }),
2431
+ stack("main", "wrap", [categories(), products("bestSellers"), trust()])
2432
+ ],
2433
+ circuit: () => [
2434
+ section("hero", "stage", [
2435
+ stack("hero-text", "stage__text", heroText()),
2436
+ stack("hero-media", "stage__media", [heroImage()])
2437
+ ]),
2438
+ block2("StoreTrust", "trust", { variant: "bento" }),
2439
+ stack("main", "wrap", [categoryNav("chip-row", "link"), products("bestSellers")])
2440
+ ],
2441
+ hearth: () => [
2442
+ section("hero", "room-hero", [
2443
+ heroImage(),
2444
+ stack("hero-text", "room-hero__card", heroText())
2445
+ ]),
2446
+ stack("main", "wrap", [
2447
+ categories({ listClassName: "rooms", itemStyle: "room" }),
2448
+ products("bestSellers"),
2449
+ trust()
2450
+ ])
2451
+ ],
2452
+ pebble: () => [
2453
+ section("hero", "play-hero", [
2454
+ stack("hero-text", "play-hero__text", heroText()),
2455
+ stack("hero-media", "play-hero__media", [heroImage()])
2456
+ ]),
2457
+ stack("main", "wrap", [categories(), products("bestSellers"), trust()])
2458
+ ],
2459
+ souq: () => [
2460
+ stack("main", "wrap", [
2461
+ block2("StoreSearch", "search"),
2462
+ categoryNav("rail", "card"),
2463
+ section("promo", "promo", [
2464
+ heroImage("promo__image"),
2465
+ stack("promo-text", "promo__text", heroText())
2466
+ ]),
2467
+ products("bestSellers"),
2468
+ trust()
2469
+ ])
2470
+ ]
2471
+ };
2472
+ function listing() {
2473
+ return page2([
2474
+ stack("main", "wrap", [
2475
+ block2("StorePageHeading", "heading", { source: "listing" }),
2476
+ block2("ListingToolbar", "toolbar"),
2477
+ block2("ListingGrid", "products"),
2478
+ block2("ListingEmpty", "empty"),
2479
+ block2("ListingLoadMore", "load-more")
2480
+ ])
2481
+ ]);
2482
+ }
2483
+ function product() {
2484
+ return page2([
2485
+ stack("main", "wrap", [
2486
+ stack("product", "pdp", [
2487
+ block2("StoreProductGallery", "gallery"),
2488
+ section("buy-box", "pdp__info", [
2489
+ block2("StoreBreadcrumbs", "breadcrumbs"),
2490
+ block2("StoreProductTitle", "product-name"),
2491
+ block2("StoreProductPrice", "price"),
2492
+ block2("ProductTagline", "tagline"),
2493
+ block2("ProductCatalog", "catalog"),
2494
+ block2("OrderForm", "order-form", { includeCatalog: false })
2495
+ ])
2496
+ ]),
2497
+ block2("StoreProductDescription", "description"),
2498
+ block2("StoreProductFaq", "faq"),
2499
+ block2("StoreProductGrid", "related", {
2500
+ source: "related",
2501
+ titleLabel: "youMayAlsoLike"
2502
+ })
2503
+ ])
2504
+ ]);
2505
+ }
2506
+ function contact() {
2507
+ return page2([
2508
+ stack("main", "wrap", [
2509
+ block2("StorePageHeading", "heading", { source: "contact" }),
2510
+ stack("contact", "contact", [
2511
+ block2("ContactDetails", "details"),
2512
+ block2("ContactForm", "form")
2513
+ ])
2514
+ ])
2515
+ ]);
2516
+ }
2517
+ function article() {
2518
+ return page2([
2519
+ stack("main", "wrap", [
2520
+ block2("StorePageHeading", "heading", { source: "article" }),
2521
+ block2("StoreArticle", "text")
2522
+ ])
2523
+ ]);
2524
+ }
2525
+ function onlineStoreTemplate(templateId, pageType) {
2526
+ if (!OnlineStoreTemplateIds.includes(templateId)) {
2527
+ throw new Error(`Unknown online store template: ${templateId}`);
2528
+ }
2529
+ switch (pageType) {
2530
+ case "header":
2531
+ return page2([block2("AnnouncementBar", "announcement"), block2("StoreHeader", "header")]);
2532
+ case "footer":
2533
+ return page2([block2("StoreFooter", "footer")]);
2534
+ case "home":
2535
+ return page2(homes[templateId]());
2536
+ case "all-products":
2537
+ case "category":
2538
+ return listing();
2539
+ case "product":
2540
+ return product();
2541
+ case "thank-you":
2542
+ return page2([block2("StoreThankYou", "thank-you")]);
2543
+ case "contact":
2544
+ return contact();
2545
+ case "about":
2546
+ case "privacy-policy":
2547
+ case "refund-policy":
2548
+ case "terms-of-service":
2549
+ return article();
2550
+ case "not-found":
2551
+ return page2([stack("main", "wrap", [block2("StoreNotFound", "not-found")])]);
2552
+ default:
2553
+ throw new Error(`Unknown online store page type: ${pageType}`);
2554
+ }
2555
+ }
2556
+ function onlineStorePages(templateId) {
2557
+ return OnlineStorePageTypes.map((pageType) => ({
2558
+ pageType,
2559
+ document: onlineStoreTemplate(templateId, pageType)
2560
+ }));
2561
+ }