@usethrottle/builder-react 0.4.3 → 0.5.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/CLAUDE.md +23 -2
- package/dist/{chunk-C57AQKJI.js → chunk-G6I4RIXU.js} +2122 -393
- package/dist/{chunk-E7SRVAFV.cjs → chunk-UNL4JWZS.cjs} +1992 -263
- package/dist/index.cjs +2251 -603
- package/dist/index.d.cts +186 -61
- package/dist/index.d.ts +186 -61
- package/dist/index.js +2218 -569
- package/dist/next.cjs +383 -13
- package/dist/next.d.cts +92 -3
- package/dist/next.d.ts +92 -3
- package/dist/next.js +385 -15
- package/dist/{seo-BYBk3Sya.d.cts → seo-iX2POfOp.d.cts} +39 -2
- package/dist/{seo-BYBk3Sya.d.ts → seo-iX2POfOp.d.ts} +39 -2
- package/dist/server.cjs +191 -24
- package/dist/server.d.cts +172 -8
- package/dist/server.d.ts +172 -8
- package/dist/server.js +174 -7
- package/package.json +4 -4
|
@@ -2,6 +2,76 @@
|
|
|
2
2
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
|
|
5
|
+
// src/server/jsonld.ts
|
|
6
|
+
var CONTEXT = "https://schema.org";
|
|
7
|
+
var isHttp = (value) => typeof value === "string" && /^https?:\/\/[^\s]+$/iu.test(value);
|
|
8
|
+
function organizationJsonLd(input) {
|
|
9
|
+
const sameAs = (_nullishCoalesce(input.sameAs, () => ( []))).filter(isHttp).slice(0, 10);
|
|
10
|
+
return {
|
|
11
|
+
"@context": CONTEXT,
|
|
12
|
+
"@type": "Organization",
|
|
13
|
+
name: input.name,
|
|
14
|
+
url: input.url,
|
|
15
|
+
...isHttp(input.logo) ? { logo: input.logo } : {},
|
|
16
|
+
...sameAs.length === 0 ? {} : { sameAs }
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function webSiteJsonLd(input) {
|
|
20
|
+
const base = input.url.replace(/\/+$/u, "");
|
|
21
|
+
return {
|
|
22
|
+
"@context": CONTEXT,
|
|
23
|
+
"@type": "WebSite",
|
|
24
|
+
name: input.name,
|
|
25
|
+
url: input.url,
|
|
26
|
+
potentialAction: {
|
|
27
|
+
"@type": "SearchAction",
|
|
28
|
+
target: {
|
|
29
|
+
"@type": "EntryPoint",
|
|
30
|
+
urlTemplate: `${base}${_nullishCoalesce(input.searchPath, () => ( "/search"))}?q={search_term_string}`
|
|
31
|
+
},
|
|
32
|
+
"query-input": "required name=search_term_string"
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function breadcrumbJsonLd(items) {
|
|
37
|
+
return {
|
|
38
|
+
"@context": CONTEXT,
|
|
39
|
+
"@type": "BreadcrumbList",
|
|
40
|
+
itemListElement: items.map((item, index) => ({
|
|
41
|
+
"@type": "ListItem",
|
|
42
|
+
position: index + 1,
|
|
43
|
+
name: item.name,
|
|
44
|
+
item: item.url
|
|
45
|
+
}))
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function faqJsonLd(items) {
|
|
49
|
+
return {
|
|
50
|
+
"@context": CONTEXT,
|
|
51
|
+
"@type": "FAQPage",
|
|
52
|
+
mainEntity: items.map((item) => ({
|
|
53
|
+
"@type": "Question",
|
|
54
|
+
name: item.question,
|
|
55
|
+
acceptedAnswer: { "@type": "Answer", text: item.answer }
|
|
56
|
+
}))
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function localBusinessJsonLd(input) {
|
|
60
|
+
const hours = (_nullishCoalesce(input.openingHours, () => ( []))).filter((line) => line !== "");
|
|
61
|
+
return {
|
|
62
|
+
"@context": CONTEXT,
|
|
63
|
+
"@type": _nullishCoalesce(input.type, () => ( "LocalBusiness")),
|
|
64
|
+
name: input.name,
|
|
65
|
+
url: input.url,
|
|
66
|
+
address: input.address,
|
|
67
|
+
...input.phone === void 0 || input.phone === "" ? {} : { telephone: input.phone },
|
|
68
|
+
...hours.length === 0 ? {} : { openingHours: hours }
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function jsonLdString(value) {
|
|
72
|
+
return JSON.stringify(value).replaceAll("<", "\\u003c");
|
|
73
|
+
}
|
|
74
|
+
|
|
5
75
|
// src/data.ts
|
|
6
76
|
var _builderschema = require('@usethrottle/builder-schema');
|
|
7
77
|
|
|
@@ -88,12 +158,14 @@ var PART_NAME = {
|
|
|
88
158
|
widget: "builder-widget"
|
|
89
159
|
};
|
|
90
160
|
function NodeWrapper(props) {
|
|
91
|
-
const { id, part, type,
|
|
161
|
+
const { id, part: part2, type, anchor, copyAnchor, custom, missing, attributes, edit, entrance, children } = props;
|
|
92
162
|
const Tag = _nullishCoalesce(props.as, () => ( "div"));
|
|
163
|
+
const tokens = props.cssClass !== void 0 && _builderschema.cssClassSchema.safeParse(props.cssClass).success ? props.cssClass : [];
|
|
164
|
+
const className = tokens.length === 0 ? props.className : `${props.className} ${tokens.join(" ")}`;
|
|
93
165
|
const handlers = edit === void 0 ? {} : {
|
|
94
166
|
onClickCapture: (event) => {
|
|
95
|
-
const
|
|
96
|
-
if (_optionalChain([
|
|
167
|
+
const target2 = event.target;
|
|
168
|
+
if (_optionalChain([target2, 'optionalAccess', _5 => _5.closest, 'optionalCall', _6 => _6("a[href]")]) != null) event.preventDefault();
|
|
97
169
|
},
|
|
98
170
|
onClick: (event) => {
|
|
99
171
|
event.stopPropagation();
|
|
@@ -114,7 +186,7 @@ function NodeWrapper(props) {
|
|
|
114
186
|
{
|
|
115
187
|
className,
|
|
116
188
|
"data-b-id": id,
|
|
117
|
-
"data-throttle-part": PART_NAME[
|
|
189
|
+
"data-throttle-part": PART_NAME[part2],
|
|
118
190
|
...type === void 0 ? {} : { "data-b-type": type },
|
|
119
191
|
...custom === true && type !== void 0 ? { "data-b-w": type } : {},
|
|
120
192
|
...missing === true ? { "data-b-missing": "" } : {},
|
|
@@ -243,10 +315,10 @@ function MissingSavedSection({ node }) {
|
|
|
243
315
|
|
|
244
316
|
// src/load.ts
|
|
245
317
|
function pageOf(raw, initialData) {
|
|
246
|
-
const { document: document2, id: _id, slug, title, path, generation, pageType: _type, updatedAt: _updated, savedSections, code, ...meta } = raw;
|
|
318
|
+
const { document: document2, id: _id, slug: slug2, title, path, generation, pageType: _type, updatedAt: _updated, savedSections, code, ...meta } = raw;
|
|
247
319
|
return {
|
|
248
320
|
kind: "page",
|
|
249
|
-
slug,
|
|
321
|
+
slug: slug2,
|
|
250
322
|
title,
|
|
251
323
|
path,
|
|
252
324
|
generation,
|
|
@@ -432,7 +504,7 @@ function Placeholder({ editMode, children }) {
|
|
|
432
504
|
var ID_RE = /^[a-z0-9]{8,24}(-[a-z0-9]{8,24})?$/;
|
|
433
505
|
var DEVICES = ["desktop", "tablet", "phone"];
|
|
434
506
|
function defaultOf(type, key) {
|
|
435
|
-
const def = _builderschema.BASIC_WIDGET_DEFINITIONS.
|
|
507
|
+
const def = _builderschema.BASIC_WIDGET_DEFINITIONS.filter((d) => d.type === type).sort((a, b) => b.v - a.v)[0];
|
|
436
508
|
return _nullishCoalesce(_optionalChain([def, 'optionalAccess', _7 => _7.settings, 'access', _8 => _8.find, 'call', _9 => _9((f) => f.key === key), 'optionalAccess', _10 => _10.default]), () => ( null));
|
|
437
509
|
}
|
|
438
510
|
function enumCss(node, rules) {
|
|
@@ -586,8 +658,8 @@ var seen2 = /* @__PURE__ */ new WeakSet();
|
|
|
586
658
|
var autoplay = /* @__PURE__ */ new Map();
|
|
587
659
|
var all = (selector) => Array.from(document.querySelectorAll(selector));
|
|
588
660
|
var reduced = () => _optionalChain([window, 'access', _20 => _20.matchMedia, 'optionalCall', _21 => _21("(prefers-reduced-motion: reduce)"), 'access', _22 => _22.matches]) === true;
|
|
589
|
-
function selectTab(
|
|
590
|
-
const tabs = Array.from(
|
|
661
|
+
function selectTab(list2, index, focus = false) {
|
|
662
|
+
const tabs = Array.from(list2.querySelectorAll("[role=tab]"));
|
|
591
663
|
tabs.forEach((tab, i) => {
|
|
592
664
|
const on = i === index;
|
|
593
665
|
tab.setAttribute("aria-selected", String(on));
|
|
@@ -661,7 +733,7 @@ function scan() {
|
|
|
661
733
|
});
|
|
662
734
|
document.documentElement.setAttribute("data-b-js", "");
|
|
663
735
|
const fresh = (selector) => all(selector).filter((el) => !seen2.has(el) && seen2.add(el));
|
|
664
|
-
fresh("[data-b-tabs]").forEach((
|
|
736
|
+
fresh("[data-b-tabs]").forEach((list2) => selectTab(list2, 0));
|
|
665
737
|
fresh("[data-b-car]").forEach((root) => setupCarousel(root));
|
|
666
738
|
const counts = fresh("[data-b-cd]");
|
|
667
739
|
counts.forEach((el) => tick(el, true));
|
|
@@ -695,30 +767,30 @@ var decoded = (hash) => {
|
|
|
695
767
|
};
|
|
696
768
|
var onHash = () => void goAnchor(decoded(location.hash));
|
|
697
769
|
function onClick(event) {
|
|
698
|
-
const
|
|
699
|
-
const href = _optionalChain([
|
|
770
|
+
const target2 = event.target;
|
|
771
|
+
const href = _optionalChain([target2, 'optionalAccess', _29 => _29.closest, 'call', _30 => _30('a[href^="#"]'), 'optionalAccess', _31 => _31.getAttribute, 'call', _32 => _32("href")]);
|
|
700
772
|
if (href && !event.defaultPrevented && !event.button && !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) && goAnchor(decoded(href))) {
|
|
701
773
|
event.preventDefault();
|
|
702
774
|
history.pushState(null, "", href);
|
|
703
775
|
}
|
|
704
|
-
const tab = _optionalChain([
|
|
705
|
-
const
|
|
706
|
-
if (tab &&
|
|
707
|
-
const button = _optionalChain([
|
|
776
|
+
const tab = _optionalChain([target2, 'optionalAccess', _33 => _33.closest, 'call', _34 => _34("[role=tab]")]);
|
|
777
|
+
const list2 = _optionalChain([tab, 'optionalAccess', _35 => _35.closest, 'call', _36 => _36("[data-b-tabs]")]);
|
|
778
|
+
if (tab && list2) return selectTab(list2, Array.from(list2.querySelectorAll("[role=tab]")).indexOf(tab));
|
|
779
|
+
const button = _optionalChain([target2, 'optionalAccess', _37 => _37.closest, 'call', _38 => _38("[data-b-act]")]);
|
|
708
780
|
const act = _optionalChain([button, 'optionalAccess', _39 => _39.getAttribute, 'call', _40 => _40("data-b-act")]);
|
|
709
781
|
const root = _optionalChain([button, 'optionalAccess', _41 => _41.closest, 'call', _42 => _42("[data-b-car]")]);
|
|
710
782
|
if (root && (act === "prev" || act === "next")) slideTo(root, act === "next" ? 1 : -1);
|
|
711
783
|
}
|
|
712
784
|
function onKey(event) {
|
|
713
785
|
const tab = _optionalChain([event, 'access', _43 => _43.target, 'optionalAccess', _44 => _44.closest, 'call', _45 => _45("[role=tab]")]);
|
|
714
|
-
const
|
|
715
|
-
if (!tab || !
|
|
716
|
-
const count =
|
|
717
|
-
const at = Array.from(
|
|
786
|
+
const list2 = _optionalChain([tab, 'optionalAccess', _46 => _46.closest, 'call', _47 => _47("[data-b-tabs]")]);
|
|
787
|
+
if (!tab || !list2) return;
|
|
788
|
+
const count = list2.querySelectorAll("[role=tab]").length;
|
|
789
|
+
const at = Array.from(list2.querySelectorAll("[role=tab]")).indexOf(tab);
|
|
718
790
|
const to = event.key === "ArrowRight" ? (at + 1) % count : event.key === "ArrowLeft" ? (at + count - 1) % count : event.key === "Home" ? 0 : event.key === "End" ? count - 1 : -1;
|
|
719
791
|
if (to < 0) return;
|
|
720
792
|
event.preventDefault();
|
|
721
|
-
selectTab(
|
|
793
|
+
selectTab(list2, to, true);
|
|
722
794
|
}
|
|
723
795
|
function startRuntime() {
|
|
724
796
|
if (typeof document === "undefined") return () => void 0;
|
|
@@ -800,8 +872,8 @@ function targetText(date) {
|
|
|
800
872
|
}
|
|
801
873
|
function Countdown({ props, editMode, interactive, locale }) {
|
|
802
874
|
void locale;
|
|
803
|
-
const
|
|
804
|
-
const when =
|
|
875
|
+
const target2 = str(props.target);
|
|
876
|
+
const when = target2 === void 0 ? null : new Date(target2);
|
|
805
877
|
if (when === null || Number.isNaN(when.getTime())) {
|
|
806
878
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "Set the date and time the countdown ends" });
|
|
807
879
|
}
|
|
@@ -857,14 +929,87 @@ function Divider({ node }) {
|
|
|
857
929
|
] });
|
|
858
930
|
}
|
|
859
931
|
|
|
932
|
+
// src/basics/v2/styles.tsx
|
|
933
|
+
|
|
934
|
+
var BASICS_V2_CSS = `@layer throttle{
|
|
935
|
+
.tb-b-faq{color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.6}
|
|
936
|
+
.tb-b-faq-item{border-block-end:1px solid var(--tb-color-border,currentColor)}
|
|
937
|
+
.tb-b-faq-q{margin:0;padding:var(--tb-space-s) 0;font-weight:600;cursor:pointer}
|
|
938
|
+
h3.tb-b-faq-q{cursor:auto;font-size:inherit}
|
|
939
|
+
.tb-b-faq-a{padding-block-end:var(--tb-space-s)}
|
|
940
|
+
.tb-b-faq-a>:first-child{margin-block-start:0}
|
|
941
|
+
.tb-b-faq-all{margin-block-end:var(--tb-space-s);padding:.4rem .9rem;border:1px solid var(--tb-color-border-control,currentColor);border-radius:var(--throttle-radius,8px);background:transparent;color:inherit;font:inherit;cursor:pointer}
|
|
942
|
+
.tb-b-faq summary:focus-visible,.tb-b-faq-all:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
943
|
+
.tb-b-rich{text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.7;overflow-wrap:anywhere}
|
|
944
|
+
.tb-b-rich>:first-child{margin-block-start:0}
|
|
945
|
+
.tb-b-rich h1,.tb-b-rich h2,.tb-b-rich h3,.tb-b-rich h4,.tb-b-rich h5,.tb-b-rich h6{font-family:var(--throttle-font-family-heading,inherit);line-height:1.25;scroll-margin-block-start:var(--tb-space-l)}
|
|
946
|
+
.tb-b-rich table{border-collapse:collapse;max-inline-size:100%;display:block;overflow-x:auto}
|
|
947
|
+
.tb-b-rich th,.tb-b-rich td{padding:var(--tb-space-xs) var(--tb-space-s);border:1px solid var(--tb-color-border,currentColor);text-align:start}
|
|
948
|
+
.tb-b-rich figure{margin-inline:0}
|
|
949
|
+
.tb-b-rich img{max-inline-size:100%;block-size:auto}
|
|
950
|
+
.tb-b-rich pre{overflow-x:auto;padding:var(--tb-space-s);background:var(--tb-color-muted,#eee)}
|
|
951
|
+
.tb-b-rich code{font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.9em}
|
|
952
|
+
.tb-b-rich blockquote{margin-inline:0;padding-inline-start:var(--tb-space-m);border-inline-start:3px solid var(--tb-color-border,currentColor)}
|
|
953
|
+
.tb-b-toc{margin-block-end:var(--tb-space-m);padding:var(--tb-space-s) var(--tb-space-m);border:1px solid var(--tb-color-border,currentColor);border-radius:var(--throttle-radius,8px)}
|
|
954
|
+
.tb-b-toc-title{margin:0 0 var(--tb-space-xs);font-weight:600}
|
|
955
|
+
.tb-b-toc ol{margin:0;padding:0;list-style:none}
|
|
956
|
+
.tb-b-toc-l3{padding-inline-start:var(--tb-space-m)}
|
|
957
|
+
.tb-b-toc a{color:inherit}
|
|
958
|
+
.tb-b-svg{display:block;text-align:var(--b-align,left);color:var(--b-color,inherit);line-height:0}
|
|
959
|
+
.tb-b-svg>svg,.tb-b-svg>img{display:inline-block;max-inline-size:100%;block-size:auto;inline-size:calc(var(--b-width)*1px)}
|
|
960
|
+
.tb-b-icons{margin:0;padding:0;list-style:none;color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));line-height:1.5}
|
|
961
|
+
.tb-b-icons li{display:flex;gap:var(--tb-space-s);align-items:flex-start;padding-block:var(--tb-space-xs)}
|
|
962
|
+
.tb-b-icons-icon{flex:0 0 auto;display:inline-flex;color:var(--b-iconColor,var(--tb-color-primary,currentColor))}
|
|
963
|
+
.tb-b-icons-icon svg,.tb-b-icons-icon img{inline-size:calc(var(--b-iconSize,20)*1px);block-size:calc(var(--b-iconSize,20)*1px)}
|
|
964
|
+
.tb-b-quote{margin:0;text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l))}
|
|
965
|
+
.tb-b-quote blockquote{margin:0;font-family:var(--throttle-font-family-heading,inherit);line-height:1.4}
|
|
966
|
+
.tb-b-quote figcaption{display:flex;align-items:center;gap:var(--tb-space-s);margin-block-start:var(--tb-space-s);font-size:var(--tb-text-s)}
|
|
967
|
+
.tb-b-quote-photo{inline-size:48px;block-size:48px;border-radius:50%;object-fit:cover}
|
|
968
|
+
.tb-b-quote-by{display:flex;flex-direction:column}
|
|
969
|
+
.tb-b-quote-name{font-weight:600}
|
|
970
|
+
.tb-b-quote-role{color:var(--tb-color-muted-foreground,inherit)}
|
|
971
|
+
.tb-b-heading-wrap{text-align:var(--b-align,left)}
|
|
972
|
+
.tb-b-kicker{display:flex;align-items:center;gap:var(--tb-space-s);margin:0 0 var(--tb-space-xs);justify-content:var(--b-align,flex-start);font-size:var(--tb-text-s);letter-spacing:.08em;text-transform:uppercase;color:var(--b-color,var(--tb-color-muted-foreground,inherit))}
|
|
973
|
+
.tb-b-kicker-rule{flex:0 0 auto;inline-size:2rem;block-size:1px;background:currentColor}
|
|
974
|
+
.tb-b-crumbs{text-align:var(--b-align,left);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-s))}
|
|
975
|
+
.tb-b-crumbs ol{display:flex;flex-wrap:wrap;gap:var(--tb-space-xs);margin:0;padding:0;list-style:none}
|
|
976
|
+
.tb-b-crumbs li{display:inline-flex;align-items:center;gap:var(--tb-space-xs)}
|
|
977
|
+
.tb-b-crumbs a{color:inherit;text-decoration:none}
|
|
978
|
+
.tb-b-crumbs a:hover{text-decoration:underline}
|
|
979
|
+
.tb-b-crumbs a:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
980
|
+
.tb-b-crumbs [aria-current]{font-weight:600}
|
|
981
|
+
}`;
|
|
982
|
+
function BasicV2Styles() {
|
|
983
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
984
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
|
|
985
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: "tb-basics-v2", precedence: "throttle", children: BASICS_V2_CSS })
|
|
986
|
+
] });
|
|
987
|
+
}
|
|
988
|
+
|
|
860
989
|
// src/basics/heading.tsx
|
|
861
990
|
|
|
862
991
|
var LEVELS = ["h1", "h2", "h3", "h4", "h5", "h6"];
|
|
863
992
|
function Heading({ props, inlineEdit }) {
|
|
864
993
|
const Tag = oneOf(props.level, LEVELS, "h2");
|
|
994
|
+
const heading = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tag, { className: "tb-b-heading", children: _nullishCoalesce(_nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _49 => _49("text")]), () => ( str(props.text))), () => ( "")) });
|
|
995
|
+
const kicker = _nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _50 => _50("kicker")]), () => ( str(props.kicker)));
|
|
996
|
+
const rule = props.rule === true;
|
|
997
|
+
if (kicker === void 0 && !rule) {
|
|
998
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
999
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
|
|
1000
|
+
heading
|
|
1001
|
+
] });
|
|
1002
|
+
}
|
|
865
1003
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
866
1004
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
|
|
867
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
1005
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
1006
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-b-heading-wrap", children: [
|
|
1007
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "p", { className: "tb-b-kicker", children: [
|
|
1008
|
+
rule && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-kicker-rule", "aria-hidden": "true" }),
|
|
1009
|
+
kicker
|
|
1010
|
+
] }),
|
|
1011
|
+
heading
|
|
1012
|
+
] })
|
|
868
1013
|
] });
|
|
869
1014
|
}
|
|
870
1015
|
|
|
@@ -931,12 +1076,12 @@ function Image({ node, props, mediaOrigin, editMode }) {
|
|
|
931
1076
|
|
|
932
1077
|
function Logo({ props, mediaOrigin, editMode }) {
|
|
933
1078
|
const design = _ui.useSiteDesign.call(void 0, );
|
|
934
|
-
const scheme = _nullishCoalesce(_optionalChain([design, 'optionalAccess',
|
|
1079
|
+
const scheme = _nullishCoalesce(_optionalChain([design, 'optionalAccess', _51 => _51.theme, 'optionalAccess', _52 => _52.colorScheme]), () => ( "auto"));
|
|
935
1080
|
const src = (url) => url === void 0 ? void 0 : _nullishCoalesce(_builderschema.safeUrl.call(void 0, url, "src", { mediaOrigin }), () => ( void 0));
|
|
936
|
-
const light = src(_optionalChain([design, 'optionalAccess',
|
|
937
|
-
const dark = src(_optionalChain([design, 'optionalAccess',
|
|
1081
|
+
const light = src(_optionalChain([design, 'optionalAccess', _53 => _53.brand, 'optionalAccess', _54 => _54.logo, 'optionalAccess', _55 => _55.light]));
|
|
1082
|
+
const dark = src(_optionalChain([design, 'optionalAccess', _56 => _56.brand, 'optionalAccess', _57 => _57.logo, 'optionalAccess', _58 => _58.dark]));
|
|
938
1083
|
const main = scheme === "dark" ? _nullishCoalesce(dark, () => ( light)) : _nullishCoalesce(light, () => ( dark));
|
|
939
|
-
const name = str(_optionalChain([design, 'optionalAccess',
|
|
1084
|
+
const name = str(_optionalChain([design, 'optionalAccess', _59 => _59.brand, 'optionalAccess', _60 => _60.storeName]));
|
|
940
1085
|
const href = _nullishCoalesce(hrefOf(props.link, mediaOrigin), () => ( "/"));
|
|
941
1086
|
const alt = _nullishCoalesce(name, () => ( ""));
|
|
942
1087
|
let content = null;
|
|
@@ -977,12 +1122,12 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
977
1122
|
const design = _ui.useSiteDesign.call(void 0, );
|
|
978
1123
|
const listId = _react.useId.call(void 0, );
|
|
979
1124
|
const toggle = _react.useRef.call(void 0, null);
|
|
980
|
-
const [open,
|
|
1125
|
+
const [open, setOpen2] = _react.useState.call(void 0, false);
|
|
981
1126
|
const name = _nullishCoalesce(str(props.menu), () => ( "header"));
|
|
982
1127
|
const layout = oneOf(props.layout, LAYOUTS, "horizontal");
|
|
983
|
-
const menus = _optionalChain([design, 'optionalAccess',
|
|
1128
|
+
const menus = _optionalChain([design, 'optionalAccess', _61 => _61.menus]);
|
|
984
1129
|
const items = menus !== void 0 && Object.hasOwn(menus, name) ? menus[name] : void 0;
|
|
985
|
-
const strings = _optionalChain([design, 'optionalAccess',
|
|
1130
|
+
const strings = _optionalChain([design, 'optionalAccess', _62 => _62.strings]);
|
|
986
1131
|
const label = _nullishCoalesce((strings !== void 0 && Object.hasOwn(strings, "nav.menu") ? str(strings["nav.menu"]) : void 0), () => ( _builderschema.SITE_STRING_DEFAULTS["nav.menu"]));
|
|
987
1132
|
if (items === void 0 || items.length === 0) {
|
|
988
1133
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
@@ -993,8 +1138,8 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
993
1138
|
const drawer = layout === "drawer-on-phone";
|
|
994
1139
|
const onKeyDown = (event) => {
|
|
995
1140
|
if (event.key === "Escape" && open) {
|
|
996
|
-
|
|
997
|
-
_optionalChain([toggle, 'access',
|
|
1141
|
+
setOpen2(false);
|
|
1142
|
+
_optionalChain([toggle, 'access', _63 => _63.current, 'optionalAccess', _64 => _64.focus, 'call', _65 => _65()]);
|
|
998
1143
|
}
|
|
999
1144
|
};
|
|
1000
1145
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
@@ -1015,11 +1160,11 @@ function Menu({ props, mediaOrigin, editMode }) {
|
|
|
1015
1160
|
className: "tb-b-menu-toggle",
|
|
1016
1161
|
"aria-expanded": open,
|
|
1017
1162
|
"aria-controls": listId,
|
|
1018
|
-
onClick: () =>
|
|
1163
|
+
onClick: () => setOpen2((value) => !value),
|
|
1019
1164
|
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: open ? "close" : "menu", size: 24, label })
|
|
1020
1165
|
}
|
|
1021
1166
|
),
|
|
1022
|
-
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, List, { items, mediaOrigin, id: listId, ...drawer ? { onNavigate: () =>
|
|
1167
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, List, { items, mediaOrigin, id: listId, ...drawer ? { onNavigate: () => setOpen2(false) } : {} })
|
|
1023
1168
|
]
|
|
1024
1169
|
}
|
|
1025
1170
|
)
|
|
@@ -1156,7 +1301,7 @@ function parseRichText(source, mediaOrigin) {
|
|
|
1156
1301
|
const closing = html[i + 1] === "/";
|
|
1157
1302
|
const nameStart = i + (closing ? 2 : 1);
|
|
1158
1303
|
TAG_NAME.lastIndex = nameStart;
|
|
1159
|
-
const raw = _optionalChain([TAG_NAME, 'access',
|
|
1304
|
+
const raw = _optionalChain([TAG_NAME, 'access', _66 => _66.exec, 'call', _67 => _67(html), 'optionalAccess', _68 => _68[0], 'optionalAccess', _69 => _69.toLowerCase, 'call', _70 => _70()]);
|
|
1160
1305
|
if (raw === void 0) {
|
|
1161
1306
|
if (html[i + 1] === "!" || html[i + 1] === "?") {
|
|
1162
1307
|
const close = html.indexOf(">", i);
|
|
@@ -1197,11 +1342,11 @@ function parseRichText(source, mediaOrigin) {
|
|
|
1197
1342
|
}
|
|
1198
1343
|
}
|
|
1199
1344
|
if (name === "li") {
|
|
1200
|
-
let
|
|
1201
|
-
while (
|
|
1202
|
-
if (
|
|
1203
|
-
if (
|
|
1204
|
-
stack.length =
|
|
1345
|
+
let list2 = stack.length - 1;
|
|
1346
|
+
while (list2 > 0 && stack[list2].tag !== "ul" && stack[list2].tag !== "ol") list2 -= 1;
|
|
1347
|
+
if (list2 === 0) list2 = -1;
|
|
1348
|
+
if (list2 === -1) continue;
|
|
1349
|
+
stack.length = list2 + 1;
|
|
1205
1350
|
}
|
|
1206
1351
|
if (name === "a") closeTo("a");
|
|
1207
1352
|
const el = { tag: name, children: [] };
|
|
@@ -1241,7 +1386,7 @@ function RichText({
|
|
|
1241
1386
|
// src/basics/text.tsx
|
|
1242
1387
|
|
|
1243
1388
|
function Text({ props, mediaOrigin, editMode, inlineEdit }) {
|
|
1244
|
-
const editor = _nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall',
|
|
1389
|
+
const editor = _nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _71 => _71("html")]), () => ( null));
|
|
1245
1390
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
1246
1391
|
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
|
|
1247
1392
|
editor === null ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, RichText, { html: _nullishCoalesce(str(props.html), () => ( "")), mediaOrigin, className: "tb-b-text", editMode }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-text", children: editor })
|
|
@@ -1268,7 +1413,7 @@ function parseVideoUrl(input) {
|
|
|
1268
1413
|
}
|
|
1269
1414
|
if (url.protocol !== "https:" || url.username !== "" || url.password !== "" || url.port !== "" && url.port !== "443") return null;
|
|
1270
1415
|
const host = url.hostname.toLowerCase();
|
|
1271
|
-
const parts = url.pathname.split("/").filter((
|
|
1416
|
+
const parts = url.pathname.split("/").filter((part2) => part2 !== "");
|
|
1272
1417
|
if (host === "youtu.be") {
|
|
1273
1418
|
const id = parts[0];
|
|
1274
1419
|
return parts.length === 1 && id !== void 0 && YOUTUBE_ID.test(id) ? { provider: "youtube", id } : null;
|
|
@@ -1310,77 +1455,261 @@ function Video({ node, props, editMode }) {
|
|
|
1310
1455
|
}
|
|
1311
1456
|
|
|
1312
1457
|
// src/basics/v2/announcement-v2.tsx
|
|
1313
|
-
var announcementV2Widgets = [];
|
|
1314
1458
|
|
|
1315
|
-
// src/basics/v2/breadcrumbs.tsx
|
|
1316
|
-
var breadcrumbsWidgets = [];
|
|
1317
1459
|
|
|
1318
|
-
// src/basics/v2/faq.tsx
|
|
1319
|
-
var faqWidgets = [];
|
|
1320
1460
|
|
|
1321
|
-
// src/basics/v2/icon-list.tsx
|
|
1322
|
-
var iconListWidgets = [];
|
|
1323
1461
|
|
|
1324
|
-
// src/
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1462
|
+
// src/context.ts
|
|
1463
|
+
|
|
1464
|
+
var BuilderContext = typeof _react.createContext === "function" ? _react.createContext.call(void 0, null) : null;
|
|
1465
|
+
var useBuilder = () => _react.useContext.call(void 0, BuilderContext);
|
|
1466
|
+
|
|
1467
|
+
// src/theme.ts
|
|
1468
|
+
|
|
1469
|
+
var _presets = require('@usethrottle/ui/presets');
|
|
1470
|
+
var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1471
|
+
var str2 = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
1472
|
+
var PALETTE_KEYS = Object.keys(_presets.PRESET_TOKENS.clean.light);
|
|
1473
|
+
var DEVICES2 = ["desktop", "tablet", "phone"];
|
|
1474
|
+
function normalizeMessages(messages) {
|
|
1475
|
+
const out = [];
|
|
1476
|
+
messages.forEach((m, index) => {
|
|
1477
|
+
if (!isRecord2(m)) return;
|
|
1478
|
+
const pages = isRecord2(m.pages) ? m.pages : {};
|
|
1479
|
+
out.push({
|
|
1480
|
+
...m,
|
|
1481
|
+
id: _nullishCoalesce(str2(m.id), () => ( `m${String(index)}`)),
|
|
1482
|
+
target: isRecord2(m.target) ? m.target : null,
|
|
1483
|
+
startsAt: _nullishCoalesce(str2(m.startsAt), () => ( null)),
|
|
1484
|
+
endsAt: _nullishCoalesce(str2(m.endsAt), () => ( null)),
|
|
1485
|
+
audience: m.audience === "guest" || m.audience === "signed-in" ? m.audience : "all",
|
|
1486
|
+
devices: Array.isArray(m.devices) ? m.devices.filter((d) => DEVICES2.some((x) => x === d)) : [...DEVICES2],
|
|
1487
|
+
pages: {
|
|
1488
|
+
mode: pages.mode === "include" || pages.mode === "exclude" ? pages.mode : "all",
|
|
1489
|
+
list: Array.isArray(pages.list) ? pages.list.filter((p) => typeof p === "string") : []
|
|
1490
|
+
}
|
|
1491
|
+
});
|
|
1492
|
+
});
|
|
1493
|
+
return out;
|
|
1336
1494
|
}
|
|
1495
|
+
function eligibleOnAnyDevice(messages, now, audience, page) {
|
|
1496
|
+
const ids = /* @__PURE__ */ new Set();
|
|
1497
|
+
for (const device of DEVICES2) for (const m of _builderschema.eligibleMessages.call(void 0, messages, { now, device, audience, page })) ids.add(m.id);
|
|
1498
|
+
return messages.filter((m) => ids.has(m.id));
|
|
1499
|
+
}
|
|
1500
|
+
|
|
1501
|
+
// src/viewer.ts
|
|
1502
|
+
|
|
1503
|
+
var ViewerContext = typeof _react.createContext === "function" ? _react.createContext.call(void 0, void 0) : null;
|
|
1504
|
+
var useViewer = () => _react.useContext.call(void 0, ViewerContext);
|
|
1337
1505
|
|
|
1338
1506
|
// src/basics/v2/menu-v2.tsx
|
|
1339
|
-
var menuV2Widgets = [];
|
|
1340
1507
|
|
|
1341
|
-
// src/basics/v2/quote.tsx
|
|
1342
|
-
var quoteWidgets = [];
|
|
1343
1508
|
|
|
1344
|
-
// src/basics/v2/rich-content.tsx
|
|
1345
|
-
var richContentWidgets = [];
|
|
1346
1509
|
|
|
1347
|
-
// src/basics/v2/svg.tsx
|
|
1348
|
-
var svgWidgets = [];
|
|
1349
1510
|
|
|
1350
|
-
// src/
|
|
1351
|
-
var
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
}
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
);
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
]);
|
|
1378
|
-
|
|
1511
|
+
// src/interactions/focus-trap.ts
|
|
1512
|
+
var FOCUSABLE = 'a[href],button:not([disabled]),input:not([disabled]),select:not([disabled]),textarea:not([disabled]),[tabindex]:not([tabindex="-1"])';
|
|
1513
|
+
var focusablesOf = (root) => Array.from(root.querySelectorAll(FOCUSABLE));
|
|
1514
|
+
function trapTab(event, items) {
|
|
1515
|
+
if (event.key !== "Tab") return false;
|
|
1516
|
+
const first = items[0];
|
|
1517
|
+
const last = items[items.length - 1];
|
|
1518
|
+
if (first === void 0 || last === void 0) return false;
|
|
1519
|
+
const active = document.activeElement;
|
|
1520
|
+
const inside = active !== null && items.includes(active);
|
|
1521
|
+
if (event.shiftKey && (active === first || !inside)) {
|
|
1522
|
+
event.preventDefault();
|
|
1523
|
+
last.focus();
|
|
1524
|
+
return true;
|
|
1525
|
+
}
|
|
1526
|
+
if (!event.shiftKey && (active === last || !inside)) {
|
|
1527
|
+
event.preventDefault();
|
|
1528
|
+
first.focus();
|
|
1529
|
+
return true;
|
|
1530
|
+
}
|
|
1531
|
+
return false;
|
|
1532
|
+
}
|
|
1533
|
+
|
|
1534
|
+
// src/interactions/menu-runtime.ts
|
|
1535
|
+
var holds2 = 0;
|
|
1536
|
+
var release;
|
|
1537
|
+
var ITEM = "[data-tb-i]";
|
|
1538
|
+
var hovers = () => _optionalChain([window, 'access', _72 => _72.matchMedia, 'optionalCall', _73 => _73("(hover:none)"), 'access', _74 => _74.matches]) !== true;
|
|
1539
|
+
function toggleOf(item) {
|
|
1540
|
+
return item.querySelector(":scope > [data-tb-t]");
|
|
1541
|
+
}
|
|
1542
|
+
function setItem(item, open) {
|
|
1543
|
+
if (open) item.setAttribute("data-open", "true");
|
|
1544
|
+
else item.removeAttribute("data-open");
|
|
1545
|
+
_optionalChain([toggleOf, 'call', _75 => _75(item), 'optionalAccess', _76 => _76.setAttribute, 'call', _77 => _77("aria-expanded", String(open))]);
|
|
1546
|
+
_optionalChain([item, 'access', _78 => _78.querySelector, 'call', _79 => _79(":scope > [data-nav-panel]"), 'optionalAccess', _80 => _80.toggleAttribute, 'call', _81 => _81("hidden", !open)]);
|
|
1547
|
+
}
|
|
1548
|
+
function closeOthers(keep) {
|
|
1549
|
+
for (const item of document.querySelectorAll(`${ITEM}[data-open]`)) {
|
|
1550
|
+
if (keep === null || !item.contains(keep)) setItem(item, false);
|
|
1551
|
+
}
|
|
1552
|
+
}
|
|
1553
|
+
var NAV_TOP = "[data-nav-top]";
|
|
1554
|
+
var PANEL = "[data-nav-panel]";
|
|
1555
|
+
function navKey(event, el) {
|
|
1556
|
+
const entry = el.closest(NAV_TOP);
|
|
1557
|
+
if (entry === null) return false;
|
|
1558
|
+
const focus = (links, at2) => _optionalChain([links, 'access', _82 => _82[(at2 + links.length) % links.length], 'optionalAccess', _83 => _83.focus, 'call', _84 => _84()]);
|
|
1559
|
+
const top = entry.querySelector(":scope > a");
|
|
1560
|
+
if (event.key === "Escape" && entry.hasAttribute("data-open")) {
|
|
1561
|
+
event.preventDefault();
|
|
1562
|
+
setItem(entry, false);
|
|
1563
|
+
_optionalChain([top, 'optionalAccess', _85 => _85.focus, 'call', _86 => _86()]);
|
|
1564
|
+
return true;
|
|
1565
|
+
}
|
|
1566
|
+
const panel = el.closest(PANEL);
|
|
1567
|
+
if (panel !== null) {
|
|
1568
|
+
if (event.key !== "ArrowDown" && event.key !== "ArrowUp") return false;
|
|
1569
|
+
event.preventDefault();
|
|
1570
|
+
const links = [...panel.querySelectorAll("a")];
|
|
1571
|
+
focus(links, links.indexOf(el) + (event.key === "ArrowDown" ? 1 : -1));
|
|
1572
|
+
return true;
|
|
1573
|
+
}
|
|
1574
|
+
if (el !== top) return false;
|
|
1575
|
+
const list2 = entry.parentElement;
|
|
1576
|
+
const tops = [..._nullishCoalesce(_optionalChain([list2, 'optionalAccess', _87 => _87.querySelectorAll, 'call', _88 => _88(":scope > li > a")]), () => ( []))];
|
|
1577
|
+
const at = tops.indexOf(el);
|
|
1578
|
+
const rtl = list2 !== null && getComputedStyle(list2).direction === "rtl";
|
|
1579
|
+
const forward = rtl ? "ArrowLeft" : "ArrowRight";
|
|
1580
|
+
const back = rtl ? "ArrowRight" : "ArrowLeft";
|
|
1581
|
+
if (event.key === forward || event.key === back) focus(tops, at + (event.key === forward ? 1 : -1));
|
|
1582
|
+
else if (event.key === "Home") focus(tops, 0);
|
|
1583
|
+
else if (event.key === "End") focus(tops, -1);
|
|
1584
|
+
else if (event.key === "ArrowDown" && entry.querySelector(":scope > " + PANEL) !== null) {
|
|
1585
|
+
if (!entry.hasAttribute("data-open")) setItem(entry, true);
|
|
1586
|
+
_optionalChain([entry, 'access', _89 => _89.querySelector, 'call', _90 => _90(":scope > " + PANEL + " a"), 'optionalAccess', _91 => _91.focus, 'call', _92 => _92()]);
|
|
1587
|
+
} else return false;
|
|
1588
|
+
event.preventDefault();
|
|
1589
|
+
return true;
|
|
1590
|
+
}
|
|
1591
|
+
var drawerToggle = (nav) => nav.querySelector(":scope > [data-tb-drawer]");
|
|
1592
|
+
function setDrawer(nav, open) {
|
|
1593
|
+
nav.setAttribute("data-open", String(open));
|
|
1594
|
+
_optionalChain([drawerToggle, 'call', _93 => _93(nav), 'optionalAccess', _94 => _94.setAttribute, 'call', _95 => _95("aria-expanded", String(open))]);
|
|
1595
|
+
const list2 = nav.querySelector(":scope > ul");
|
|
1596
|
+
if (list2 === null) return;
|
|
1597
|
+
if (open) {
|
|
1598
|
+
list2.setAttribute("role", "dialog");
|
|
1599
|
+
list2.setAttribute("aria-modal", "true");
|
|
1600
|
+
const label = nav.getAttribute("aria-label");
|
|
1601
|
+
if (label !== null) list2.setAttribute("aria-label", label);
|
|
1602
|
+
_optionalChain([focusablesOf, 'call', _96 => _96(list2), 'access', _97 => _97[0], 'optionalAccess', _98 => _98.focus, 'call', _99 => _99()]);
|
|
1603
|
+
} else {
|
|
1604
|
+
list2.removeAttribute("role");
|
|
1605
|
+
list2.removeAttribute("aria-modal");
|
|
1606
|
+
list2.removeAttribute("aria-label");
|
|
1607
|
+
}
|
|
1608
|
+
}
|
|
1609
|
+
var target = (event) => event.target instanceof Element ? event.target : null;
|
|
1610
|
+
function install() {
|
|
1611
|
+
const over = (event) => {
|
|
1612
|
+
const el = target(event);
|
|
1613
|
+
if (el === null || !hovers()) return;
|
|
1614
|
+
closeOthers(el);
|
|
1615
|
+
for (let item = el.closest(ITEM); item !== null; item = _nullishCoalesce(_optionalChain([item, 'access', _100 => _100.parentElement, 'optionalAccess', _101 => _101.closest, 'call', _102 => _102(ITEM)]), () => ( null))) setItem(item, true);
|
|
1616
|
+
};
|
|
1617
|
+
const out = (event) => {
|
|
1618
|
+
if (!hovers()) return;
|
|
1619
|
+
const to = event.relatedTarget instanceof Node ? event.relatedTarget : null;
|
|
1620
|
+
closeOthers(to);
|
|
1621
|
+
};
|
|
1622
|
+
const focusin = (event) => {
|
|
1623
|
+
const el = target(event);
|
|
1624
|
+
if (el === null) return;
|
|
1625
|
+
closeOthers(el);
|
|
1626
|
+
if (el.closest("[data-tb-t]") !== null || el.closest(NAV_TOP) !== null) return;
|
|
1627
|
+
for (let item = el.closest(ITEM); item !== null; item = _nullishCoalesce(_optionalChain([item, 'access', _103 => _103.parentElement, 'optionalAccess', _104 => _104.closest, 'call', _105 => _105(ITEM)]), () => ( null))) setItem(item, true);
|
|
1628
|
+
};
|
|
1629
|
+
const click = (event) => {
|
|
1630
|
+
const el = target(event);
|
|
1631
|
+
if (el === null) return;
|
|
1632
|
+
const opener = el.closest("[data-tb-drawer]");
|
|
1633
|
+
if (opener !== null) {
|
|
1634
|
+
const nav2 = opener.closest("nav");
|
|
1635
|
+
if (nav2 !== null) setDrawer(nav2, nav2.getAttribute("data-open") !== "true");
|
|
1636
|
+
return;
|
|
1637
|
+
}
|
|
1638
|
+
const toggle = el.closest("[data-tb-t]");
|
|
1639
|
+
const item = _nullishCoalesce(_optionalChain([toggle, 'optionalAccess', _106 => _106.closest, 'call', _107 => _107(ITEM)]), () => ( null));
|
|
1640
|
+
if (item !== null) {
|
|
1641
|
+
closeOthers(item);
|
|
1642
|
+
setItem(item, item.getAttribute("data-open") !== "true");
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
closeOthers(el);
|
|
1646
|
+
const nav = el.closest("nav[data-open=true]");
|
|
1647
|
+
if (nav !== null && el.closest("a") !== null) setDrawer(nav, false);
|
|
1648
|
+
};
|
|
1649
|
+
const keydown = (event) => {
|
|
1650
|
+
const el = target(event);
|
|
1651
|
+
const drawer = document.querySelector("nav[data-open=true]");
|
|
1652
|
+
if (event.key === "Tab" && drawer !== null) {
|
|
1653
|
+
const toggle = drawerToggle(drawer);
|
|
1654
|
+
const list2 = drawer.querySelector(":scope > ul");
|
|
1655
|
+
if (list2 !== null) trapTab(event, [...toggle === null ? [] : [toggle], ...focusablesOf(list2)]);
|
|
1656
|
+
return;
|
|
1657
|
+
}
|
|
1658
|
+
if (drawer === null && el !== null && navKey(event, el)) return;
|
|
1659
|
+
if (event.key !== "Escape") return;
|
|
1660
|
+
if (drawer !== null) {
|
|
1661
|
+
closeOthers(null);
|
|
1662
|
+
setDrawer(drawer, false);
|
|
1663
|
+
_optionalChain([drawerToggle, 'call', _108 => _108(drawer), 'optionalAccess', _109 => _109.focus, 'call', _110 => _110()]);
|
|
1664
|
+
return;
|
|
1665
|
+
}
|
|
1666
|
+
const open = document.querySelector(`${ITEM}[data-open]`);
|
|
1667
|
+
if (open !== null) {
|
|
1668
|
+
const focusInside = el !== null && open.contains(el);
|
|
1669
|
+
const back = toggleOf(open);
|
|
1670
|
+
closeOthers(null);
|
|
1671
|
+
if (focusInside) _optionalChain([back, 'optionalAccess', _111 => _111.focus, 'call', _112 => _112()]);
|
|
1672
|
+
}
|
|
1673
|
+
};
|
|
1674
|
+
document.addEventListener("mouseover", over);
|
|
1675
|
+
document.addEventListener("mouseout", out);
|
|
1676
|
+
document.addEventListener("focusin", focusin);
|
|
1677
|
+
document.addEventListener("click", click);
|
|
1678
|
+
document.addEventListener("keydown", keydown);
|
|
1679
|
+
return () => {
|
|
1680
|
+
document.removeEventListener("mouseover", over);
|
|
1681
|
+
document.removeEventListener("mouseout", out);
|
|
1682
|
+
document.removeEventListener("focusin", focusin);
|
|
1683
|
+
document.removeEventListener("click", click);
|
|
1684
|
+
document.removeEventListener("keydown", keydown);
|
|
1685
|
+
};
|
|
1686
|
+
}
|
|
1687
|
+
function startMenuRuntime() {
|
|
1688
|
+
if (holds2++ === 0) release = install();
|
|
1689
|
+
let done = false;
|
|
1690
|
+
return () => {
|
|
1691
|
+
if (done) return;
|
|
1692
|
+
done = true;
|
|
1693
|
+
if (--holds2 === 0) {
|
|
1694
|
+
_optionalChain([release, 'optionalCall', _113 => _113()]);
|
|
1695
|
+
release = void 0;
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1698
|
+
}
|
|
1699
|
+
|
|
1700
|
+
// src/renderer.tsx
|
|
1701
|
+
|
|
1702
|
+
|
|
1703
|
+
|
|
1704
|
+
|
|
1705
|
+
|
|
1706
|
+
|
|
1707
|
+
|
|
1708
|
+
|
|
1709
|
+
|
|
1379
1710
|
|
|
1380
|
-
// src/custom/factory.ts
|
|
1381
1711
|
|
|
1382
1712
|
|
|
1383
|
-
// src/custom/composite-widget.tsx
|
|
1384
1713
|
|
|
1385
1714
|
|
|
1386
1715
|
|
|
@@ -1407,24 +1736,6 @@ var RenderBudget = class {
|
|
|
1407
1736
|
};
|
|
1408
1737
|
var fitsBudget = (ast, limit = MAX_RENDERED_NODES) => _builderschema.templateWeight.call(void 0, ast) <= limit;
|
|
1409
1738
|
|
|
1410
|
-
// src/part-view.tsx
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
// src/renderer.tsx
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
1739
|
// src/code/code-widget.tsx
|
|
1429
1740
|
|
|
1430
1741
|
|
|
@@ -1536,10 +1847,10 @@ var ROLES = new Set(_builderschema.ALLOWED_ROLES);
|
|
|
1536
1847
|
function attrAllowed(tag, name) {
|
|
1537
1848
|
if (_builderschema.DATA_ATTR_RE.test(name)) return !name.startsWith(_builderschema.RESERVED_DATA_PREFIX);
|
|
1538
1849
|
const own = Object.hasOwn(_builderschema.ALLOWED_ATTRS, tag) ? _builderschema.ALLOWED_ATTRS[tag] : void 0;
|
|
1539
|
-
return (_nullishCoalesce(_optionalChain([_builderschema.ALLOWED_ATTRS, 'access',
|
|
1850
|
+
return (_nullishCoalesce(_optionalChain([_builderschema.ALLOWED_ATTRS, 'access', _114 => _114["*"], 'optionalAccess', _115 => _115.includes, 'call', _116 => _116(name)]), () => ( false))) || (_nullishCoalesce(_optionalChain([own, 'optionalAccess', _117 => _117.includes, 'call', _118 => _118(name)]), () => ( false)));
|
|
1540
1851
|
}
|
|
1541
1852
|
function attrText(attr, env, scope) {
|
|
1542
|
-
return attr.value.map((
|
|
1853
|
+
return attr.value.map((part2) => part2.type === "text" ? part2.value : filtered(lookup(part2.path, env, scope), part2.filters)).join("");
|
|
1543
1854
|
}
|
|
1544
1855
|
function urlSource(attr, env, scope) {
|
|
1545
1856
|
const [only] = attr.value;
|
|
@@ -1614,11 +1925,11 @@ function renderNodes(nodes, env, scope, depth) {
|
|
|
1614
1925
|
}
|
|
1615
1926
|
break;
|
|
1616
1927
|
case "each": {
|
|
1617
|
-
const
|
|
1618
|
-
if (!Array.isArray(
|
|
1619
|
-
const count = Math.min(
|
|
1928
|
+
const list2 = lookup(node.path, env, scope);
|
|
1929
|
+
if (!Array.isArray(list2)) break;
|
|
1930
|
+
const count = Math.min(list2.length, _builderschema.EACH_ITERATION_CAP);
|
|
1620
1931
|
for (let i = 0; i < count && !env.stopped; i += 1) {
|
|
1621
|
-
const inner = new Map(scope).set(node.as,
|
|
1932
|
+
const inner = new Map(scope).set(node.as, list2[i]);
|
|
1622
1933
|
out.push(/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderNodes(node.body, env, inner, depth + 1) }, out.length));
|
|
1623
1934
|
}
|
|
1624
1935
|
break;
|
|
@@ -1638,6 +1949,45 @@ function renderTemplate(ast, env) {
|
|
|
1638
1949
|
|
|
1639
1950
|
|
|
1640
1951
|
|
|
1952
|
+
// src/part-view.tsx
|
|
1953
|
+
|
|
1954
|
+
|
|
1955
|
+
var BoundaryBase = _nullishCoalesce(_react.Component, () => ( class {
|
|
1956
|
+
}));
|
|
1957
|
+
var Boundary = class extends BoundaryBase {
|
|
1958
|
+
constructor() {
|
|
1959
|
+
super(...arguments);
|
|
1960
|
+
__publicField(this, "state", { failed: false });
|
|
1961
|
+
}
|
|
1962
|
+
static getDerivedStateFromError() {
|
|
1963
|
+
return { failed: true };
|
|
1964
|
+
}
|
|
1965
|
+
componentDidCatch(error, _info) {
|
|
1966
|
+
warnOnce(`part:${this.props.label}`, `${this.props.label} failed to render (${String(error)}); rendering nothing for it`);
|
|
1967
|
+
try {
|
|
1968
|
+
_optionalChain([this, 'access', _119 => _119.props, 'access', _120 => _120.onError, 'optionalCall', _121 => _121(error, { part: this.props.label })]);
|
|
1969
|
+
} catch (e6) {
|
|
1970
|
+
}
|
|
1971
|
+
}
|
|
1972
|
+
componentDidUpdate(previous) {
|
|
1973
|
+
const moved = previous.resetKeys.length !== this.props.resetKeys.length || previous.resetKeys.some((key, i) => !Object.is(key, this.props.resetKeys[i]));
|
|
1974
|
+
if (moved && this.state.failed) this.setState({ failed: false });
|
|
1975
|
+
}
|
|
1976
|
+
render() {
|
|
1977
|
+
return this.state.failed ? null : this.props.children;
|
|
1978
|
+
}
|
|
1979
|
+
};
|
|
1980
|
+
function PartBoundary({
|
|
1981
|
+
label,
|
|
1982
|
+
resetKey,
|
|
1983
|
+
children
|
|
1984
|
+
}) {
|
|
1985
|
+
const builder = useBuilder();
|
|
1986
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Boundary, { label, resetKeys: [_optionalChain([builder, 'optionalAccess', _122 => _122.site]), resetKey], onError: _optionalChain([builder, 'optionalAccess', _123 => _123.onError]), children });
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
// src/custom/template-widget.tsx
|
|
1990
|
+
|
|
1641
1991
|
var componentWeights = /* @__PURE__ */ new WeakMap();
|
|
1642
1992
|
var compiled = /* @__PURE__ */ new WeakMap();
|
|
1643
1993
|
function compileTemplate(snapshot, registry) {
|
|
@@ -1661,14 +2011,14 @@ function compile(snapshot, registry) {
|
|
|
1661
2011
|
const source = snapshot.template;
|
|
1662
2012
|
if (typeof source !== "string") return refuse("no template source");
|
|
1663
2013
|
const parsed2 = _builderschema.parseTemplate.call(void 0, source);
|
|
1664
|
-
if (!parsed2.ok) return refuse(`template does not parse: ${_nullishCoalesce(_optionalChain([parsed2, 'access',
|
|
2014
|
+
if (!parsed2.ok) return refuse(`template does not parse: ${_nullishCoalesce(_optionalChain([parsed2, 'access', _124 => _124.issues, 'access', _125 => _125[0], 'optionalAccess', _126 => _126.message]), () => ( "invalid"))}`);
|
|
1665
2015
|
const data = snapshot.data;
|
|
1666
2016
|
const issues = _builderschema.validateTemplate.call(void 0, parsed2.ast, {
|
|
1667
2017
|
settings: snapshot.settings,
|
|
1668
2018
|
data: typeof data === "object" && data !== null ? data : {},
|
|
1669
2019
|
sources: registry.sources()
|
|
1670
2020
|
});
|
|
1671
|
-
if (issues.length > 0) return refuse(`template does not validate: ${_nullishCoalesce(_optionalChain([issues, 'access',
|
|
2021
|
+
if (issues.length > 0) return refuse(`template does not validate: ${_nullishCoalesce(_optionalChain([issues, 'access', _127 => _127[0], 'optionalAccess', _128 => _128.message]), () => ( "invalid"))}`);
|
|
1672
2022
|
if (!fitsBudget(parsed2.ast)) return refuse(`it can render more than ${String(_builderschema.MAX_TEMPLATE_WEIGHT)} nodes`);
|
|
1673
2023
|
const css = scopedCss(snapshot.css, snapshot.type);
|
|
1674
2024
|
if (css === null) return refuse("its css does not pass the sanitiser");
|
|
@@ -1691,6 +2041,7 @@ function TemplateWidget(props) {
|
|
|
1691
2041
|
|
|
1692
2042
|
|
|
1693
2043
|
// src/code/routes.ts
|
|
2044
|
+
|
|
1694
2045
|
var CODE_ROUTE_DENY = /^(checkout|cart|basket|bag|account|my-?account|sign[-_]?in|sign[-_]?up|log[-_]?in|log[-_]?out|register|orders?|pay|payments?|password|wallet)([;.\s].*)?$|^(confirm|thank|receipt|invoice|quote).*$|^order[-_].*$/i;
|
|
1695
2046
|
var DEFAULT_CATALOG_ROUTES = [
|
|
1696
2047
|
"/p/{handle}",
|
|
@@ -1715,7 +2066,7 @@ function normalizePath(pathname) {
|
|
|
1715
2066
|
if (next === decoded2) break;
|
|
1716
2067
|
decoded2 = next;
|
|
1717
2068
|
}
|
|
1718
|
-
} catch (
|
|
2069
|
+
} catch (e7) {
|
|
1719
2070
|
return null;
|
|
1720
2071
|
}
|
|
1721
2072
|
if (decoded2.includes("\0")) return null;
|
|
@@ -1737,21 +2088,35 @@ function matcherOf(template) {
|
|
|
1737
2088
|
if (known !== void 0) return known;
|
|
1738
2089
|
let regex = null;
|
|
1739
2090
|
if (template.startsWith("/")) {
|
|
1740
|
-
const pattern = template.split(/(\{[A-Za-z][A-Za-z0-9]*\})/).map((
|
|
2091
|
+
const pattern = template.split(/(\{[A-Za-z][A-Za-z0-9]*\})/).map((part2) => /^\{[A-Za-z][A-Za-z0-9]*\}$/.test(part2) ? "[^/]+" : escapeRegExp(part2)).join("").replace(/\/+$/, "");
|
|
1741
2092
|
regex = new RegExp(`^${pattern === "" ? "/" : pattern}$`);
|
|
1742
2093
|
}
|
|
1743
2094
|
if (compiled2.size >= MAX_COMPILED) compiled2.clear();
|
|
1744
2095
|
compiled2.set(template, regex);
|
|
1745
2096
|
return regex;
|
|
1746
2097
|
}
|
|
1747
|
-
var matchesTemplate = (path, template) => _nullishCoalesce(_optionalChain([matcherOf, 'call',
|
|
2098
|
+
var matchesTemplate = (path, template) => _nullishCoalesce(_optionalChain([matcherOf, 'call', _129 => _129(template), 'optionalAccess', _130 => _130.test, 'call', _131 => _131(path)]), () => ( false));
|
|
2099
|
+
function buildRouteTable(store, catalog = {}) {
|
|
2100
|
+
return { ...catalog, ...store };
|
|
2101
|
+
}
|
|
2102
|
+
var isDeniedTemplate = (name) => _builderschema.CODE_TEMPLATE_DENY.includes(name);
|
|
2103
|
+
function isDeniedByRouteTable(path, routeTable) {
|
|
2104
|
+
if (routeTable === void 0) return false;
|
|
2105
|
+
return Object.entries(routeTable).some(([name, template]) => {
|
|
2106
|
+
if (!isDeniedTemplate(name) || typeof template !== "string") return false;
|
|
2107
|
+
const base = template.replace(/\/+$/, "");
|
|
2108
|
+
return matchesTemplate(path, template) || path.startsWith(`${base}/`);
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
1748
2111
|
function isCodeRoute(pathname, routes) {
|
|
1749
2112
|
if (pathname === void 0) return false;
|
|
2113
|
+
if (routes.templateName !== void 0 && isDeniedTemplate(routes.templateName)) return false;
|
|
1750
2114
|
const path = normalizePath(pathname);
|
|
1751
2115
|
if (path === null) return false;
|
|
2116
|
+
if (isDeniedByRouteTable(path, routes.routeTable)) return false;
|
|
1752
2117
|
if (path.split("/").some((segment) => CODE_ROUTE_DENY.test(segment))) return false;
|
|
1753
2118
|
if (path === "/") return true;
|
|
1754
|
-
return [routes.page, ..._nullishCoalesce(routes.catalog, () => ( DEFAULT_CATALOG_ROUTES))].some(
|
|
2119
|
+
return [routes.page, ..._nullishCoalesce(routes.catalog, () => ( DEFAULT_CATALOG_ROUTES)), ..._nullishCoalesce(routes.allow, () => ( []))].some(
|
|
1755
2120
|
(template) => matchesTemplate(path, template)
|
|
1756
2121
|
);
|
|
1757
2122
|
}
|
|
@@ -1769,7 +2134,7 @@ var CUSTOM_TYPE = /^custom\.[a-z][a-z0-9-]{0,63}$/;
|
|
|
1769
2134
|
var SCRIPT_ORIGIN = /^https:\/\/[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[0-9]{1,5})?$/i;
|
|
1770
2135
|
var SITE_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
1771
2136
|
var MAX_INPUT_CHARS = 2e5;
|
|
1772
|
-
var
|
|
2137
|
+
var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
1773
2138
|
var checked = /* @__PURE__ */ new WeakMap();
|
|
1774
2139
|
function check(raw, registry) {
|
|
1775
2140
|
let perRegistry = checked.get(raw);
|
|
@@ -1803,7 +2168,7 @@ function verify(raw, registry) {
|
|
|
1803
2168
|
return { status: "ok", snapshot: raw, template };
|
|
1804
2169
|
}
|
|
1805
2170
|
function codeScriptUrl(runtime, jsHash) {
|
|
1806
|
-
if (!
|
|
2171
|
+
if (!isRecord3(runtime) || runtime.enabled !== true) return null;
|
|
1807
2172
|
const { scriptOrigin, codeSiteId } = runtime;
|
|
1808
2173
|
if (typeof scriptOrigin !== "string" || !SCRIPT_ORIGIN.test(scriptOrigin)) return null;
|
|
1809
2174
|
if (typeof codeSiteId !== "string" || !SITE_ID.test(codeSiteId)) return null;
|
|
@@ -1826,7 +2191,7 @@ var BADGE = {
|
|
|
1826
2191
|
function runs(props, jsHash) {
|
|
1827
2192
|
const { code, edit, interactive } = props;
|
|
1828
2193
|
if (edit !== void 0 || interactive === false || code === void 0 || code.preview === true) return null;
|
|
1829
|
-
if (!isCodeRoute(code.pathname, code.routes)) return null;
|
|
2194
|
+
if (!isCodeRoute(code.pathname, { ...code.routes, templateName: code.templateName })) return null;
|
|
1830
2195
|
return codeScriptUrl(code.runtime, jsHash);
|
|
1831
2196
|
}
|
|
1832
2197
|
function CodeWidget(props) {
|
|
@@ -1858,7 +2223,7 @@ function CodeWidget(props) {
|
|
|
1858
2223
|
template.css === "" ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomCss, { css: template.css }),
|
|
1859
2224
|
renderTemplate(template.ast, env)
|
|
1860
2225
|
] }) }),
|
|
1861
|
-
src === null && (edit !== void 0 || _optionalChain([props, 'access',
|
|
2226
|
+
src === null && (edit !== void 0 || _optionalChain([props, 'access', _132 => _132.code, 'optionalAccess', _133 => _133.preview]) === true) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-b-code-badge": "", style: BADGE, children: "Runs on your store" }) : null,
|
|
1862
2227
|
src === null ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CodeInput, { props: props.props, data: props.data, label }),
|
|
1863
2228
|
src === null ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "script", { async: true, src })
|
|
1864
2229
|
]
|
|
@@ -1873,7 +2238,7 @@ function CodeInput({ props, data, label }) {
|
|
|
1873
2238
|
warnOnce(`code-input:${label}`, `The data of ${label} is too large for its code input; it gets its props only`);
|
|
1874
2239
|
json = jsonForScript({ props, data: {} });
|
|
1875
2240
|
}
|
|
1876
|
-
} catch (
|
|
2241
|
+
} catch (e8) {
|
|
1877
2242
|
warnOnce(`code-input:${label}`, `The input of ${label} cannot be written as JSON; it gets none`);
|
|
1878
2243
|
json = jsonForScript({ props: {}, data: {} });
|
|
1879
2244
|
}
|
|
@@ -2164,6 +2529,122 @@ function Carousel({
|
|
|
2164
2529
|
);
|
|
2165
2530
|
}
|
|
2166
2531
|
|
|
2532
|
+
// src/interactions/frame.tsx
|
|
2533
|
+
|
|
2534
|
+
|
|
2535
|
+
// src/interactions/drawer.ts
|
|
2536
|
+
var holds3 = 0;
|
|
2537
|
+
var release2;
|
|
2538
|
+
var rootOf = (el) => _nullishCoalesce(_optionalChain([el, 'optionalAccess', _134 => _134.closest, 'call', _135 => _135("[data-tb-collapse]")]), () => ( null));
|
|
2539
|
+
function setOpen(root, open) {
|
|
2540
|
+
const opener = root.querySelector("[data-tb-drawer-open]");
|
|
2541
|
+
const body = root.querySelector(".tb-fr-body");
|
|
2542
|
+
if (open) root.setAttribute("data-open", "true");
|
|
2543
|
+
else root.removeAttribute("data-open");
|
|
2544
|
+
_optionalChain([opener, 'optionalAccess', _136 => _136.setAttribute, 'call', _137 => _137("aria-expanded", String(open))]);
|
|
2545
|
+
if (body !== null) {
|
|
2546
|
+
if (open) {
|
|
2547
|
+
body.setAttribute("role", "dialog");
|
|
2548
|
+
body.setAttribute("aria-modal", "true");
|
|
2549
|
+
const name = _optionalChain([opener, 'optionalAccess', _138 => _138.textContent, 'optionalAccess', _139 => _139.trim, 'call', _140 => _140()]);
|
|
2550
|
+
if (name !== void 0 && name !== "") body.setAttribute("aria-label", name);
|
|
2551
|
+
} else {
|
|
2552
|
+
body.removeAttribute("role");
|
|
2553
|
+
body.removeAttribute("aria-modal");
|
|
2554
|
+
body.removeAttribute("aria-label");
|
|
2555
|
+
}
|
|
2556
|
+
}
|
|
2557
|
+
if (open) _optionalChain([root, 'access', _141 => _141.querySelector, 'call', _142 => _142("[data-tb-drawer-close]"), 'optionalAccess', _143 => _143.focus, 'call', _144 => _144()]);
|
|
2558
|
+
else _optionalChain([opener, 'optionalAccess', _145 => _145.focus, 'call', _146 => _146()]);
|
|
2559
|
+
}
|
|
2560
|
+
var openRoot = () => document.querySelector("[data-tb-collapse][data-open=true]");
|
|
2561
|
+
function install2() {
|
|
2562
|
+
const click = (event) => {
|
|
2563
|
+
const el = event.target instanceof Element ? event.target : null;
|
|
2564
|
+
if (el === null) return;
|
|
2565
|
+
const root = rootOf(el);
|
|
2566
|
+
if (root === null) return;
|
|
2567
|
+
if (el.closest("[data-tb-drawer-open]") !== null) setOpen(root, root.getAttribute("data-open") !== "true");
|
|
2568
|
+
else if (el.closest("[data-tb-drawer-close]") !== null) setOpen(root, false);
|
|
2569
|
+
else if (root.getAttribute("data-open") === "true" && el.closest(".tb-fr-body a[href]") !== null) setOpen(root, false);
|
|
2570
|
+
};
|
|
2571
|
+
const keydown = (event) => {
|
|
2572
|
+
const root = openRoot();
|
|
2573
|
+
if (root === null) return;
|
|
2574
|
+
if (event.key === "Escape") {
|
|
2575
|
+
setOpen(root, false);
|
|
2576
|
+
return;
|
|
2577
|
+
}
|
|
2578
|
+
const body = root.querySelector(".tb-fr-body");
|
|
2579
|
+
if (body !== null) trapTab(event, focusablesOf(body));
|
|
2580
|
+
};
|
|
2581
|
+
document.addEventListener("click", click);
|
|
2582
|
+
document.addEventListener("keydown", keydown);
|
|
2583
|
+
return () => {
|
|
2584
|
+
document.removeEventListener("click", click);
|
|
2585
|
+
document.removeEventListener("keydown", keydown);
|
|
2586
|
+
};
|
|
2587
|
+
}
|
|
2588
|
+
function startDrawer() {
|
|
2589
|
+
if (holds3++ === 0) release2 = install2();
|
|
2590
|
+
let done = false;
|
|
2591
|
+
return () => {
|
|
2592
|
+
if (done) return;
|
|
2593
|
+
done = true;
|
|
2594
|
+
if (--holds3 === 0) {
|
|
2595
|
+
_optionalChain([release2, 'optionalCall', _147 => _147()]);
|
|
2596
|
+
release2 = void 0;
|
|
2597
|
+
}
|
|
2598
|
+
};
|
|
2599
|
+
}
|
|
2600
|
+
|
|
2601
|
+
// src/interactions/frame.tsx
|
|
2602
|
+
|
|
2603
|
+
var SECTION_ID_RE = /^[A-Za-z0-9_-]{1,64}$/;
|
|
2604
|
+
var TABLET_PX = 1024;
|
|
2605
|
+
var PHONE_PX = 768;
|
|
2606
|
+
var isRecord4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2607
|
+
function frameOf(section) {
|
|
2608
|
+
const raw = section.frame;
|
|
2609
|
+
if (!isRecord4(raw)) return null;
|
|
2610
|
+
const sticky = raw.sticky === "top";
|
|
2611
|
+
const c = raw.collapse;
|
|
2612
|
+
let collapse = null;
|
|
2613
|
+
if (isRecord4(c) && SECTION_ID_RE.test(section.id)) {
|
|
2614
|
+
const at = typeof c.belowPx === "number" && Number.isInteger(c.belowPx) && c.belowPx >= 768 && c.belowPx <= 1280 ? c.belowPx : c.below === "tablet" ? TABLET_PX : c.below === "phone" ? PHONE_PX : null;
|
|
2615
|
+
if (at !== null) collapse = { px: (at - 0.02).toFixed(2), label: isRecord4(c.label) ? c.label : {} };
|
|
2616
|
+
}
|
|
2617
|
+
return sticky || collapse !== null ? { sticky, collapse } : null;
|
|
2618
|
+
}
|
|
2619
|
+
var FRAME_CSS = `@layer throttle{
|
|
2620
|
+
.tb-sticky{position:sticky;inset-block-start:0;z-index:40}
|
|
2621
|
+
[data-throttle-part=builder-header]:has(.tb-sticky){position:sticky;inset-block-start:0;z-index:40}
|
|
2622
|
+
.tb-fr-open,.tb-fr-close{display:none;align-items:center;justify-content:center;min-inline-size:44px;min-block-size:44px;padding:0 var(--tb-space-s);border:0;background:transparent;color:inherit;font:inherit;cursor:pointer}
|
|
2623
|
+
.tb-fr-open:focus-visible,.tb-fr-close:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
2624
|
+
}`;
|
|
2625
|
+
function collapseCss(sectionId, px2) {
|
|
2626
|
+
const s = `[data-b-id="${sectionId}"]`;
|
|
2627
|
+
return `@layer throttle{@media (max-width: ${px2}px){@media (scripting: enabled){${s} .tb-fr-open{display:inline-flex}${s} .tb-fr-body{display:none}${s} .tb-fr[data-open=true] .tb-fr-body{display:block;position:fixed;inset:0;z-index:60;overflow:auto;padding:4.5rem var(--tb-space-m) var(--tb-space-m);background:var(--tb-color-background,#fff);color:var(--tb-color-foreground,#111)}${s} .tb-fr[data-open=true] .tb-fr-close{display:inline-flex;position:fixed;inset-block-start:var(--tb-space-s);inset-inline-end:var(--tb-space-s);z-index:61}}}}`;
|
|
2628
|
+
}
|
|
2629
|
+
function DrawerRuntime() {
|
|
2630
|
+
_react.useEffect.call(void 0, () => startDrawer(), []);
|
|
2631
|
+
return null;
|
|
2632
|
+
}
|
|
2633
|
+
function Collapse(props) {
|
|
2634
|
+
const { sectionId, id, px: px2, label, children } = props;
|
|
2635
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2636
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: `tb-fr-${sectionId}`, precedence: "throttle", children: collapseCss(sectionId, px2) }),
|
|
2637
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-fr", "data-tb-collapse": "", children: [
|
|
2638
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-fr-open", "data-tb-drawer-open": "", "aria-expanded": "false", "aria-controls": id, children: label }),
|
|
2639
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { id, className: "tb-fr-body", children: [
|
|
2640
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-fr-close", "data-tb-drawer-close": "", "aria-label": "Close", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-hidden": "true", children: "\xD7" }) }),
|
|
2641
|
+
children
|
|
2642
|
+
] }),
|
|
2643
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, DrawerRuntime, {})
|
|
2644
|
+
] })
|
|
2645
|
+
] });
|
|
2646
|
+
}
|
|
2647
|
+
|
|
2167
2648
|
// src/interactions/tabs.tsx
|
|
2168
2649
|
|
|
2169
2650
|
function Tabs({ id, panels }) {
|
|
@@ -2217,6 +2698,81 @@ function Toggle({
|
|
|
2217
2698
|
] });
|
|
2218
2699
|
}
|
|
2219
2700
|
|
|
2701
|
+
// src/show-when.tsx
|
|
2702
|
+
|
|
2703
|
+
|
|
2704
|
+
|
|
2705
|
+
function parseShowWhen(value) {
|
|
2706
|
+
if (value === void 0) return null;
|
|
2707
|
+
const parsed2 = _builderschema.showWhenSchema.safeParse(value);
|
|
2708
|
+
if (!parsed2.success) return null;
|
|
2709
|
+
return parsed2.data.audience === "all" && parsed2.data.cart === "any" ? null : parsed2.data;
|
|
2710
|
+
}
|
|
2711
|
+
function showWhenState(when, viewer, mounted) {
|
|
2712
|
+
if (!mounted) return when.audience === "signed-in" || when.cart === "has-items" ? "placeholder" : "show";
|
|
2713
|
+
const known = viewer === null ? { signedIn: null, cartItemCount: null } : _nullishCoalesce(viewer, () => ( { signedIn: false, cartItemCount: 0 }));
|
|
2714
|
+
let pending = false;
|
|
2715
|
+
if (when.audience !== "all") {
|
|
2716
|
+
if (known.signedIn === null) pending = pending || when.audience === "signed-in";
|
|
2717
|
+
else if ((known.signedIn ? "signed-in" : "guest") !== when.audience) return "hide";
|
|
2718
|
+
}
|
|
2719
|
+
if (when.cart !== "any") {
|
|
2720
|
+
if (known.cartItemCount === null) pending = pending || when.cart === "has-items";
|
|
2721
|
+
else if ((known.cartItemCount > 0 ? "has-items" : "empty") !== when.cart) return "hide";
|
|
2722
|
+
}
|
|
2723
|
+
return pending ? "placeholder" : "show";
|
|
2724
|
+
}
|
|
2725
|
+
var DEVICES3 = ["desktop", "tablet", "phone"];
|
|
2726
|
+
var isRec = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2727
|
+
var list = (v) => Array.isArray(v) ? v.filter(isRec) : [];
|
|
2728
|
+
function lengthOf(value) {
|
|
2729
|
+
if (typeof value === "number") return Number.isFinite(value) && value > 0 ? `${String(Math.min(Math.round(value), 2e3))}px` : null;
|
|
2730
|
+
if (typeof value === "string" && value !== "none" && _builderschema.SPACING_TOKENS.includes(value)) return `var(--tb-space-${value})`;
|
|
2731
|
+
return null;
|
|
2732
|
+
}
|
|
2733
|
+
function heightAt(node, device) {
|
|
2734
|
+
const resolved = _builderschema.resolveResponsive.call(void 0, isRec(node.props) ? node.props : {}, node.responsive, device);
|
|
2735
|
+
if (resolved.hidden === true) return null;
|
|
2736
|
+
const own = _nullishCoalesce(lengthOf(resolved.minHeight), () => ( lengthOf(resolved.height)));
|
|
2737
|
+
if (own !== null) return own;
|
|
2738
|
+
const columns = list(node.columns).map((c) => heightAt(c, device)).filter((h) => h !== null);
|
|
2739
|
+
if (columns.length > 0) return columns.length === 1 ? columns[0] : `max(${columns.join(",")})`;
|
|
2740
|
+
const stacked = list(node.children).map((c) => heightAt(c, device)).filter((h) => h !== null);
|
|
2741
|
+
if (stacked.length > 0) return stacked.length === 1 ? stacked[0] : `calc(${stacked.join(" + ")})`;
|
|
2742
|
+
return null;
|
|
2743
|
+
}
|
|
2744
|
+
function reservedHeights(node) {
|
|
2745
|
+
const found = DEVICES3.map((device) => [device, heightAt(node, device)]);
|
|
2746
|
+
if (found.every(([, h]) => h === null)) return {};
|
|
2747
|
+
return Object.fromEntries(found.map(([device, h]) => [device, _nullishCoalesce(h, () => ( "0px"))]));
|
|
2748
|
+
}
|
|
2749
|
+
var SHOW_WHEN_CSS = "@layer throttle{.tb-sw{visibility:hidden;pointer-events:none;min-block-size:var(--tb-sw-h,0)}@media (max-width:1024px){.tb-sw{min-block-size:var(--tb-sw-ht,var(--tb-sw-h,0))}}@media (max-width:767px){.tb-sw{min-block-size:var(--tb-sw-hp,var(--tb-sw-ht,var(--tb-sw-h,0)))}}}";
|
|
2750
|
+
function ShowWhen({ when, heights, children }) {
|
|
2751
|
+
const viewer = useViewer();
|
|
2752
|
+
const [mounted, setMounted] = _react.useState.call(void 0, false);
|
|
2753
|
+
_react.useEffect.call(void 0, () => setMounted(true), []);
|
|
2754
|
+
const state = showWhenState(when, viewer, mounted);
|
|
2755
|
+
if (state === "show") return children;
|
|
2756
|
+
if (state === "hide") return null;
|
|
2757
|
+
const style = {
|
|
2758
|
+
...heights.desktop === void 0 ? {} : { "--tb-sw-h": heights.desktop },
|
|
2759
|
+
...heights.tablet === void 0 ? {} : { "--tb-sw-ht": heights.tablet },
|
|
2760
|
+
...heights.phone === void 0 ? {} : { "--tb-sw-hp": heights.phone }
|
|
2761
|
+
};
|
|
2762
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
2763
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: "tb-showwhen", precedence: "throttle", children: SHOW_WHEN_CSS }),
|
|
2764
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2765
|
+
"div",
|
|
2766
|
+
{
|
|
2767
|
+
className: "tb-sw",
|
|
2768
|
+
"aria-hidden": "true",
|
|
2769
|
+
"data-b-showwhen": when.audience === "signed-in" ? "signed-in" : "has-items",
|
|
2770
|
+
...Object.keys(style).length === 0 ? {} : { style }
|
|
2771
|
+
}
|
|
2772
|
+
)
|
|
2773
|
+
] });
|
|
2774
|
+
}
|
|
2775
|
+
|
|
2220
2776
|
// src/styles.ts
|
|
2221
2777
|
var BASE_CSS = `@layer throttle{
|
|
2222
2778
|
:root{--tb-scale:1;--tb-space-xs:calc(.25rem*var(--tb-scale));--tb-space-s:calc(.5rem*var(--tb-scale));--tb-space-m:calc(1rem*var(--tb-scale));--tb-space-l:calc(1.5rem*var(--tb-scale));--tb-space-xl:calc(2.5rem*var(--tb-scale));--tb-space-2xl:calc(4rem*var(--tb-scale));
|
|
@@ -2240,7 +2796,7 @@ var BASE_CSS = `@layer throttle{
|
|
|
2240
2796
|
|
|
2241
2797
|
// src/renderer.tsx
|
|
2242
2798
|
|
|
2243
|
-
var
|
|
2799
|
+
var DEVICES4 = ["desktop", "tablet", "phone"];
|
|
2244
2800
|
var COMMON_BY_KEY2 = new Map(_builderschema.COMMON_WIDGET_SETTINGS.map((f) => [f.key, f]));
|
|
2245
2801
|
var withCustomCache = /* @__PURE__ */ new WeakMap();
|
|
2246
2802
|
function registryFor(doc, base) {
|
|
@@ -2267,7 +2823,7 @@ function registryFor(doc, base) {
|
|
|
2267
2823
|
}
|
|
2268
2824
|
return registry;
|
|
2269
2825
|
}
|
|
2270
|
-
var
|
|
2826
|
+
var isRecord5 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
2271
2827
|
function pickLocale(value, locale) {
|
|
2272
2828
|
const lang = _nullishCoalesce(locale.split("-")[0], () => ( locale));
|
|
2273
2829
|
for (const key of [locale, lang, "en"]) {
|
|
@@ -2281,22 +2837,33 @@ function onOrigin(asset, mediaOrigin) {
|
|
|
2281
2837
|
if (_builderschema.safeUrl.call(void 0, asset.url, "src", { mediaOrigin }) === null) return null;
|
|
2282
2838
|
return { ...asset, variants: asset.variants.filter((v) => _builderschema.safeUrl.call(void 0, v.url, "src", { mediaOrigin }) !== null) };
|
|
2283
2839
|
}
|
|
2284
|
-
function
|
|
2285
|
-
if (
|
|
2286
|
-
|
|
2840
|
+
function prepareItem(field, item, ctx) {
|
|
2841
|
+
if (!isRecord5(item)) return item;
|
|
2842
|
+
const out = { ...item };
|
|
2843
|
+
for (const itemField of _nullishCoalesce(field.itemFields, () => ( []))) {
|
|
2844
|
+
if (!Object.hasOwn(out, itemField.key)) continue;
|
|
2845
|
+
const prepared = prepare(itemField, out[itemField.key], ctx);
|
|
2846
|
+
out[itemField.key] = prepared;
|
|
2847
|
+
}
|
|
2848
|
+
return out;
|
|
2849
|
+
}
|
|
2850
|
+
function prepare(field, value, ctx) {
|
|
2851
|
+
if (field === void 0 || value === null) return value;
|
|
2852
|
+
if (field.control === "list" && Array.isArray(value)) return value.map((item) => prepareItem(field, item, ctx));
|
|
2853
|
+
if (field.translatable === true && isRecord5(value)) return pickLocale(value, ctx.locale);
|
|
2287
2854
|
if (field.control === "image" && typeof value === "string") {
|
|
2288
2855
|
const asset = Object.hasOwn(ctx.assets, value) ? ctx.assets[value] : void 0;
|
|
2289
2856
|
return asset === void 0 ? null : onOrigin(asset, ctx.mediaOrigin);
|
|
2290
2857
|
}
|
|
2291
|
-
if (field.control === "link" &&
|
|
2292
|
-
const
|
|
2293
|
-
const raw = _nullishCoalesce(_optionalChain([ctx, 'access',
|
|
2858
|
+
if (field.control === "link" && isRecord5(value) && typeof value.kind === "string") {
|
|
2859
|
+
const target2 = value;
|
|
2860
|
+
const raw = _nullishCoalesce(_optionalChain([ctx, 'access', _148 => _148.resolveLink, 'optionalCall', _149 => _149(target2)]), () => ( (target2.kind === "url" ? target2.href : null)));
|
|
2294
2861
|
return { ...value, href: _builderschema.safeUrl.call(void 0, raw, "href", { mediaOrigin: ctx.mediaOrigin }) };
|
|
2295
2862
|
}
|
|
2296
2863
|
return value;
|
|
2297
2864
|
}
|
|
2298
2865
|
function storedLinkPart(value) {
|
|
2299
|
-
if (!
|
|
2866
|
+
if (!isRecord5(value) || value.kind !== "page") return value;
|
|
2300
2867
|
const { slug: _slug, href: _href, ...stored } = value;
|
|
2301
2868
|
void _slug;
|
|
2302
2869
|
void _href;
|
|
@@ -2309,8 +2876,8 @@ function settingsAt(node, fields, device, ctx) {
|
|
|
2309
2876
|
const out = {};
|
|
2310
2877
|
for (const [key, value] of Object.entries(resolved)) {
|
|
2311
2878
|
const field = fields.get(key);
|
|
2312
|
-
const freeText = _optionalChain([field, 'optionalAccess',
|
|
2313
|
-
const checked2 = _optionalChain([field, 'optionalAccess',
|
|
2879
|
+
const freeText = _optionalChain([field, 'optionalAccess', _150 => _150.control]) === "text" || _optionalChain([field, 'optionalAccess', _151 => _151.control]) === "richtext";
|
|
2880
|
+
const checked2 = _optionalChain([field, 'optionalAccess', _152 => _152.control]) === "link" ? storedLinkPart(value) : value;
|
|
2314
2881
|
const usable = field === void 0 || (freeText ? value !== null : _builderschema.validateSettingValue.call(void 0, field, checked2) === null) ? value : field.default;
|
|
2315
2882
|
out[key] = prepare(field, usable, ctx);
|
|
2316
2883
|
}
|
|
@@ -2319,7 +2886,7 @@ function settingsAt(node, fields, device, ctx) {
|
|
|
2319
2886
|
function variantsOf(node, def, fields, ctx) {
|
|
2320
2887
|
const markup = [...fields.values()].filter((f) => f.output === "markup").map((f) => f.key);
|
|
2321
2888
|
const groups = /* @__PURE__ */ new Map();
|
|
2322
|
-
for (const device of
|
|
2889
|
+
for (const device of DEVICES4) {
|
|
2323
2890
|
const props = settingsAt(node, fields, device, ctx);
|
|
2324
2891
|
const signature = stable(markup.map((key) => _nullishCoalesce(props[key], () => ( null))));
|
|
2325
2892
|
const group = groups.get(signature);
|
|
@@ -2330,7 +2897,7 @@ function variantsOf(node, def, fields, ctx) {
|
|
|
2330
2897
|
return [...groups.values()];
|
|
2331
2898
|
}
|
|
2332
2899
|
function hiddenEverywhere(props, responsive) {
|
|
2333
|
-
return
|
|
2900
|
+
return DEVICES4.every(
|
|
2334
2901
|
(device) => _builderschema.resolveResponsive.call(void 0, { hidden: _nullishCoalesce(props.hidden, () => ( false)) }, responsive, device).hidden === true
|
|
2335
2902
|
);
|
|
2336
2903
|
}
|
|
@@ -2338,7 +2905,7 @@ var variantClass = (variant) => `tb-v ${variant.devices.map((d) => `tb-only-${d}
|
|
|
2338
2905
|
function renderCodeWidget(node, snapshot, ctx, registry) {
|
|
2339
2906
|
if (ctx.edit === void 0 && hiddenEverywhere(node.props, node.responsive)) return null;
|
|
2340
2907
|
const def = registry.widget(node.type, node.v);
|
|
2341
|
-
const fields = new Map([...COMMON_BY_KEY2, ...(_nullishCoalesce(_optionalChain([def, 'optionalAccess',
|
|
2908
|
+
const fields = new Map([...COMMON_BY_KEY2, ...(_nullishCoalesce(_optionalChain([def, 'optionalAccess', _153 => _153.settings]), () => ( []))).map((f) => [f.key, f])]);
|
|
2342
2909
|
const data = {};
|
|
2343
2910
|
for (const [name, binding] of Object.entries(bindingsOf(node, registry))) {
|
|
2344
2911
|
const key = bindingKey(binding);
|
|
@@ -2369,7 +2936,7 @@ function renderCodeWidget(node, snapshot, ctx, registry) {
|
|
|
2369
2936
|
function renderWidget(node, ctx, registry) {
|
|
2370
2937
|
const key = `${node.type}@${String(node.v)}`;
|
|
2371
2938
|
const frozen = ctx.snapshots !== void 0 && Object.hasOwn(ctx.snapshots, key) ? ctx.snapshots[key] : void 0;
|
|
2372
|
-
if (_optionalChain([frozen, 'optionalAccess',
|
|
2939
|
+
if (_optionalChain([frozen, 'optionalAccess', _154 => _154.kind]) === "code") return renderCodeWidget(node, frozen, ctx, registry);
|
|
2373
2940
|
const def = registry.widget(node.type, node.v);
|
|
2374
2941
|
const Component2 = def === void 0 ? void 0 : registry.component(node);
|
|
2375
2942
|
if (def === void 0 || Component2 === void 0) {
|
|
@@ -2389,7 +2956,7 @@ function renderWidget(node, ctx, registry) {
|
|
|
2389
2956
|
}
|
|
2390
2957
|
const custom = node.type.startsWith("custom.");
|
|
2391
2958
|
const edit = ctx.edit;
|
|
2392
|
-
|
|
2959
|
+
const copies = variants.map((variant, index) => {
|
|
2393
2960
|
const anchor = variant.props.anchor;
|
|
2394
2961
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2395
2962
|
NodeWrapper,
|
|
@@ -2398,6 +2965,7 @@ function renderWidget(node, ctx, registry) {
|
|
|
2398
2965
|
part: "widget",
|
|
2399
2966
|
type: node.type,
|
|
2400
2967
|
custom,
|
|
2968
|
+
cssClass: node.cssClass,
|
|
2401
2969
|
edit,
|
|
2402
2970
|
className: variants.length > 1 ? `tb-w ${variantClass(variant)}` : "tb-w",
|
|
2403
2971
|
anchor: index === 0 && !ctx.dupe && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
|
|
@@ -2423,15 +2991,23 @@ function renderWidget(node, ctx, registry) {
|
|
|
2423
2991
|
variant.devices.join("-")
|
|
2424
2992
|
);
|
|
2425
2993
|
});
|
|
2994
|
+
return gated(node, ctx, copies);
|
|
2995
|
+
}
|
|
2996
|
+
function gated(node, ctx, content) {
|
|
2997
|
+
if (ctx.edit !== void 0) return content;
|
|
2998
|
+
const when = parseShowWhen(node.showWhen);
|
|
2999
|
+
if (when === null) return content;
|
|
3000
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, ShowWhen, { when, heights: reservedHeights(node), children: content });
|
|
2426
3001
|
}
|
|
2427
3002
|
function renderColumn(column, ctx, registry) {
|
|
2428
3003
|
if (ctx.edit === void 0 && hiddenEverywhere(column.props, column.responsive)) return null;
|
|
2429
|
-
|
|
3004
|
+
const drawn = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
2430
3005
|
NodeWrapper,
|
|
2431
3006
|
{
|
|
2432
3007
|
id: column.id,
|
|
2433
3008
|
part: "column",
|
|
2434
3009
|
className: "tb-col",
|
|
3010
|
+
cssClass: column.cssClass,
|
|
2435
3011
|
anchor: ctx.dupe ? void 0 : column.props.anchor,
|
|
2436
3012
|
copyAnchor: ctx.vpath === "" ? void 0 : column.props.anchor,
|
|
2437
3013
|
edit: ctx.edit,
|
|
@@ -2446,11 +3022,12 @@ function renderColumn(column, ctx, registry) {
|
|
|
2446
3022
|
},
|
|
2447
3023
|
column.id
|
|
2448
3024
|
);
|
|
3025
|
+
return gated(column, ctx, drawn);
|
|
2449
3026
|
}
|
|
2450
3027
|
var PLAIN = _builderschema.resolveInteraction.call(void 0, { props: {}, responsive: void 0 }, "desktop");
|
|
2451
3028
|
function sectionVariants(section, ctx) {
|
|
2452
3029
|
const groups = /* @__PURE__ */ new Map();
|
|
2453
|
-
for (const device of
|
|
3030
|
+
for (const device of DEVICES4) {
|
|
2454
3031
|
const interaction = ctx.interactive ? _builderschema.resolveInteraction.call(void 0, section, device) : PLAIN;
|
|
2455
3032
|
const entrance = ctx.interactive ? _builderschema.resolveEntrance.call(void 0, section, device) : { entrance: "none", entranceDelayMs: 0 };
|
|
2456
3033
|
const signature = stable([interaction, entrance]);
|
|
@@ -2470,6 +3047,7 @@ function panelsOf(section, ctx, registry, fallback) {
|
|
|
2470
3047
|
function renderSection(section, ctx, registry, nested = false) {
|
|
2471
3048
|
if (ctx.edit === void 0 && hiddenEverywhere(section.props, section.responsive)) return null;
|
|
2472
3049
|
const variants = sectionVariants(section, ctx);
|
|
3050
|
+
const frame = nested || !ctx.interactive || ctx.edit !== void 0 ? null : frameOf(section);
|
|
2473
3051
|
const marker = variants.length > 1 && !ctx.dupe && section.props.anchor !== void 0 && _builderschema.ANCHOR_RE.test(section.props.anchor) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { id: section.props.anchor, className: "tb-anchor" }, "anchor") : null;
|
|
2474
3052
|
const copies = variants.map((variant, index) => {
|
|
2475
3053
|
const { interaction } = variant;
|
|
@@ -2511,36 +3089,52 @@ function renderSection(section, ctx, registry, nested = false) {
|
|
|
2511
3089
|
} else {
|
|
2512
3090
|
body = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-row", children: columns() });
|
|
2513
3091
|
}
|
|
2514
|
-
|
|
3092
|
+
if (_optionalChain([frame, 'optionalAccess', _155 => _155.collapse]) != null) {
|
|
3093
|
+
body = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3094
|
+
Collapse,
|
|
3095
|
+
{
|
|
3096
|
+
sectionId: section.id,
|
|
3097
|
+
id: `fr-${section.id}-${ctx.vpath}${String(index)}`,
|
|
3098
|
+
px: frame.collapse.px,
|
|
3099
|
+
label: pickLocale(frame.collapse.label, ctx.locale) || _builderschema.SITE_STRING_DEFAULTS["nav.menu"],
|
|
3100
|
+
children: body
|
|
3101
|
+
}
|
|
3102
|
+
);
|
|
3103
|
+
}
|
|
3104
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
2515
3105
|
NodeWrapper,
|
|
2516
3106
|
{
|
|
2517
3107
|
id: section.id,
|
|
2518
3108
|
part: "section",
|
|
3109
|
+
cssClass: section.cssClass,
|
|
2519
3110
|
as: nested ? "div" : "section",
|
|
2520
|
-
className: `${nested ? "tb-section tb-nested" : "tb-section"}${variants.length > 1 ? ` ${variantClass({ devices: variant.devices, props: {} })}` : ""}`,
|
|
3111
|
+
className: `${nested ? "tb-section tb-nested" : "tb-section"}${_optionalChain([frame, 'optionalAccess', _156 => _156.sticky]) === true ? " tb-sticky" : ""}${variants.length > 1 ? ` ${variantClass({ devices: variant.devices, props: {} })}` : ""}`,
|
|
2521
3112
|
anchor: variants.length === 1 && !ctx.dupe ? section.props.anchor : void 0,
|
|
2522
3113
|
copyAnchor: variants.length > 1 || ctx.vpath !== "" ? section.props.anchor : void 0,
|
|
2523
3114
|
edit: ctx.edit,
|
|
2524
3115
|
entrance: entranceOf(variant.entrance.entrance, variant.entrance.entranceDelayMs, ctx.interactive),
|
|
2525
|
-
children:
|
|
3116
|
+
children: [
|
|
3117
|
+
frame !== null ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: "tb-frame", precedence: "throttle", children: FRAME_CSS }) : null,
|
|
3118
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-inner", children: body })
|
|
3119
|
+
]
|
|
2526
3120
|
},
|
|
2527
3121
|
variant.devices.join("-")
|
|
2528
3122
|
);
|
|
2529
3123
|
});
|
|
2530
|
-
return marker === null ? copies : [marker, ...copies];
|
|
3124
|
+
return gated(section, ctx, marker === null ? copies : [marker, ...copies]);
|
|
2531
3125
|
}
|
|
2532
3126
|
function needsRuntime(doc) {
|
|
2533
3127
|
let found = false;
|
|
2534
3128
|
_builderschema.walkNodes.call(void 0, doc, (node) => {
|
|
2535
3129
|
if (found || node.type === "saved-section") return;
|
|
2536
3130
|
if (node.type === "section" || node.type === "inner-section") {
|
|
2537
|
-
found =
|
|
3131
|
+
found = DEVICES4.some(
|
|
2538
3132
|
(device) => _builderschema.resolveInteraction.call(void 0, node, device).interaction !== "none" || _builderschema.resolveEntrance.call(void 0, node, device).entrance !== "none"
|
|
2539
3133
|
);
|
|
2540
3134
|
} else if (node.type === "column") {
|
|
2541
|
-
found =
|
|
3135
|
+
found = DEVICES4.some((device) => _builderschema.resolveEntrance.call(void 0, node, device).entrance !== "none");
|
|
2542
3136
|
} else {
|
|
2543
|
-
found =
|
|
3137
|
+
found = DEVICES4.some((device) => {
|
|
2544
3138
|
const entrance = _builderschema.resolveResponsive.call(void 0, node.props, node.responsive, device).entrance;
|
|
2545
3139
|
return entrance !== void 0 && entrance !== "none";
|
|
2546
3140
|
});
|
|
@@ -2556,7 +3150,7 @@ function BuilderRenderer(props) {
|
|
|
2556
3150
|
const { doc } = _builderschema.upgradeNodes.call(void 0, source, registry);
|
|
2557
3151
|
const mediaOrigin = _nullishCoalesce(props.mediaOrigin, () => ( ""));
|
|
2558
3152
|
const interactive = props.interactive !== false;
|
|
2559
|
-
const ctx = { registry, data, locale, assets, mediaOrigin, resolveLink, code, edit: editMode, interactive, vpath: _nullishCoalesce(_optionalChain([props, 'access',
|
|
3153
|
+
const ctx = { registry, data, locale, assets, mediaOrigin, resolveLink, code, edit: editMode, interactive, vpath: _nullishCoalesce(_optionalChain([props, 'access', _157 => _157.idScope, 'optionalAccess', _158 => _158.vpath]), () => ( "")), dupe: _nullishCoalesce(_optionalChain([props, 'access', _159 => _159.idScope, 'optionalAccess', _160 => _160.dupe]), () => ( false)), snapshots: source.customWidgets };
|
|
2560
3154
|
const css = compileResponsiveCss(doc, registry, assets, mediaOrigin);
|
|
2561
3155
|
const upgraded = new Map(doc.sections.map((section) => [section.id, section]));
|
|
2562
3156
|
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-root", "data-throttle-part": "builder-root", ...props.scopeCustomCss === true ? { "data-b-root": "" } : {}, children: [
|
|
@@ -2566,10 +3160,10 @@ function BuilderRenderer(props) {
|
|
|
2566
3160
|
(_nullishCoalesce(expansion.roots, () => ( doc.sections.map((section) => ({ kind: "section", id: section.id }))))).map((root) => {
|
|
2567
3161
|
if (root.kind === "section") {
|
|
2568
3162
|
const section2 = upgraded.get(root.id);
|
|
2569
|
-
return _optionalChain([section2, 'optionalAccess',
|
|
3163
|
+
return _optionalChain([section2, 'optionalAccess', _161 => _161.type]) === "section" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderSection(section2, ctx, registry) }, root.id) : null;
|
|
2570
3164
|
}
|
|
2571
3165
|
const section = root.sectionId === null ? void 0 : upgraded.get(root.sectionId);
|
|
2572
|
-
if (_optionalChain([section, 'optionalAccess',
|
|
3166
|
+
if (_optionalChain([section, 'optionalAccess', _162 => _162.type]) === "section") {
|
|
2573
3167
|
return root.ref.props.hidden === true && ctx.edit === void 0 ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderSection(section, ctx, registry) }, root.ref.id);
|
|
2574
3168
|
}
|
|
2575
3169
|
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MissingSavedSection, { node: root.ref }, root.ref.id);
|
|
@@ -2577,71 +3171,1076 @@ function BuilderRenderer(props) {
|
|
|
2577
3171
|
] });
|
|
2578
3172
|
}
|
|
2579
3173
|
|
|
2580
|
-
// src/
|
|
3174
|
+
// src/basics/v2/menu-v2.tsx
|
|
2581
3175
|
|
|
2582
|
-
var
|
|
2583
|
-
var
|
|
3176
|
+
var MODES = ["horizontal", "vertical", "drawer", "mega"];
|
|
3177
|
+
var MAX_LEVEL = 3;
|
|
3178
|
+
var CLASS_RE = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;
|
|
3179
|
+
var SUBMENU_DEFAULT = "Show submenu for {label}";
|
|
3180
|
+
function localized(value, locale) {
|
|
3181
|
+
if (!isRecord(value)) return str(value);
|
|
3182
|
+
for (const key of [locale, "en"]) {
|
|
3183
|
+
if (Object.hasOwn(value, key)) {
|
|
3184
|
+
const own = str(value[key]);
|
|
3185
|
+
if (own !== void 0) return own;
|
|
3186
|
+
}
|
|
3187
|
+
}
|
|
3188
|
+
return Object.values(value).map(str).find((s) => s !== void 0);
|
|
3189
|
+
}
|
|
3190
|
+
function makeLink(builder, own, mediaOrigin) {
|
|
3191
|
+
const targets = _optionalChain([builder, 'optionalAccess', _163 => _163.linkTargets]);
|
|
3192
|
+
const fallback = _nullishCoalesce(own, () => ( _optionalChain([builder, 'optionalAccess', _164 => _164.resolveLink])));
|
|
3193
|
+
return (target2) => {
|
|
3194
|
+
if (target2.kind === "url") return _builderschema.safeUrl.call(void 0, target2.href, "href", { mediaOrigin });
|
|
3195
|
+
if (targets !== void 0 && typeof target2.id === "string") {
|
|
3196
|
+
const key = `${String(target2.kind)}:${target2.id}`;
|
|
3197
|
+
if (Object.hasOwn(targets, key)) {
|
|
3198
|
+
const known = targets[key];
|
|
3199
|
+
return typeof known === "string" ? _builderschema.safeUrl.call(void 0, known, "href", { mediaOrigin }) : null;
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
const raw = _nullishCoalesce(_optionalChain([fallback, 'optionalCall', _165 => _165(target2)]), () => ( null));
|
|
3203
|
+
return raw === null ? null : _builderschema.safeUrl.call(void 0, raw, "href", { mediaOrigin });
|
|
3204
|
+
};
|
|
3205
|
+
}
|
|
3206
|
+
function megaOf(value, locale) {
|
|
3207
|
+
if (!isRecord(value) || value.enabled !== true) return void 0;
|
|
3208
|
+
const columns = typeof value.columns === "number" ? Math.min(6, Math.max(2, Math.round(value.columns))) : 3;
|
|
3209
|
+
const f = value.featured;
|
|
3210
|
+
let featured = null;
|
|
3211
|
+
if (isRecord(f) && f.kind === "section" && typeof f.id === "string") featured = { kind: "section", id: f.id };
|
|
3212
|
+
else if (isRecord(f) && f.kind === "image" && typeof f.asset === "string") {
|
|
3213
|
+
featured = { kind: "image", asset: f.asset, link: isRecord(f.link) ? f.link : null, caption: _nullishCoalesce(localized(f.caption, locale), () => ( "")) };
|
|
3214
|
+
}
|
|
3215
|
+
return { columns, featured };
|
|
3216
|
+
}
|
|
3217
|
+
function build(raw, level, b) {
|
|
3218
|
+
if (!Array.isArray(raw)) return [];
|
|
3219
|
+
const out = [];
|
|
3220
|
+
raw.forEach((entry, index) => {
|
|
3221
|
+
if (!isRecord(entry) || !isRecord(entry.target)) return;
|
|
3222
|
+
const target2 = entry.target;
|
|
3223
|
+
const label = localized(entry.label, b.r.locale);
|
|
3224
|
+
if (label === void 0) return;
|
|
3225
|
+
out.push({
|
|
3226
|
+
key: typeof entry.id === "string" ? entry.id : String(index),
|
|
3227
|
+
label,
|
|
3228
|
+
href: target2.kind === "category" && typeof entry.url === "string" ? _builderschema.safeUrl.call(void 0, entry.url, "href", { mediaOrigin: b.r.mediaOrigin }) : b.r.link(target2),
|
|
3229
|
+
newTab: entry.newTab === true,
|
|
3230
|
+
classes: Array.isArray(entry.cssClass) ? entry.cssClass.filter((c) => typeof c === "string" && CLASS_RE.test(c)) : [],
|
|
3231
|
+
description: localized(entry.description, b.r.locale),
|
|
3232
|
+
badge: localized(entry.badge, b.r.locale),
|
|
3233
|
+
// Mega is only for a top-level item of the header menu, in mega mode.
|
|
3234
|
+
mega: b.mega && level === 1 && b.menu === "header" ? megaOf(entry.mega, b.r.locale) : void 0,
|
|
3235
|
+
children: level < MAX_LEVEL ? build(entry.children, level + 1, b) : [],
|
|
3236
|
+
...target2.kind === "category" && typeof entry.handle === "string" ? { handle: entry.handle } : {}
|
|
3237
|
+
});
|
|
3238
|
+
});
|
|
3239
|
+
return out;
|
|
3240
|
+
}
|
|
3241
|
+
function fromDesign(items, level, r) {
|
|
3242
|
+
return items.map((item, index) => ({
|
|
3243
|
+
key: String(index),
|
|
3244
|
+
label: item.label,
|
|
3245
|
+
href: _builderschema.safeUrl.call(void 0, item.href, "href", { mediaOrigin: r.mediaOrigin }),
|
|
3246
|
+
newTab: false,
|
|
3247
|
+
classes: [],
|
|
3248
|
+
description: void 0,
|
|
3249
|
+
badge: void 0,
|
|
3250
|
+
mega: void 0,
|
|
3251
|
+
children: level < MAX_LEVEL && item.children !== void 0 ? fromDesign(item.children, level + 1, r) : []
|
|
3252
|
+
}));
|
|
3253
|
+
}
|
|
3254
|
+
function Anchor({ item }) {
|
|
3255
|
+
return item.href === null ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-mm-text", children: item.label }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href: item.href, ...item.newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}, children: item.label });
|
|
3256
|
+
}
|
|
3257
|
+
var Extras = ({ item, describe }) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3258
|
+
item.badge === void 0 ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-mm-badge", children: item.badge }),
|
|
3259
|
+
describe && item.description !== void 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-mm-desc", children: item.description }) : null
|
|
3260
|
+
] });
|
|
3261
|
+
function FeaturedPanel({ featured, label, ctx }) {
|
|
3262
|
+
const { builder, props } = ctx;
|
|
3263
|
+
const site = _optionalChain([builder, 'optionalAccess', _166 => _166.site]);
|
|
3264
|
+
if (builder === null || site === void 0 || site.status !== "ok") return null;
|
|
3265
|
+
const parts = [site.header, site.footer];
|
|
3266
|
+
if (featured.kind === "section") {
|
|
3267
|
+
let answer;
|
|
3268
|
+
for (const part2 of parts) {
|
|
3269
|
+
const all2 = part2.savedSections;
|
|
3270
|
+
if (answer === void 0 && all2 !== void 0 && Object.hasOwn(all2, featured.id)) answer = all2[featured.id];
|
|
3271
|
+
}
|
|
3272
|
+
const parsed2 = answer === void 0 ? null : _builderschema.sectionNodeSchema.safeParse(answer.section);
|
|
3273
|
+
if (answer === void 0 || parsed2 === null || !parsed2.success) return null;
|
|
3274
|
+
const assets = { ...site.footer.assets, ...site.header.assets };
|
|
3275
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-mm-feat", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3276
|
+
BuilderRenderer,
|
|
3277
|
+
{
|
|
3278
|
+
document: { schemaVersion: 1, sections: [parsed2.data] },
|
|
3279
|
+
registry: builder.registry,
|
|
3280
|
+
data: {},
|
|
3281
|
+
locale: props.locale,
|
|
3282
|
+
assets,
|
|
3283
|
+
mediaOrigin: props.mediaOrigin,
|
|
3284
|
+
interactive: props.interactive,
|
|
3285
|
+
resolveLink: _nullishCoalesce(props.resolveLink, () => ( builder.resolveLink))
|
|
3286
|
+
}
|
|
3287
|
+
) });
|
|
3288
|
+
}
|
|
3289
|
+
let asset;
|
|
3290
|
+
for (const part2 of parts) {
|
|
3291
|
+
if (asset === void 0 && Object.hasOwn(part2.assets, featured.asset)) asset = part2.assets[featured.asset];
|
|
3292
|
+
}
|
|
3293
|
+
if (!isFrozenAsset(asset)) return null;
|
|
3294
|
+
const href = featured.link === null ? null : makeLink(builder, props.resolveLink, props.mediaOrigin)(featured.link);
|
|
3295
|
+
const image = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssetImage, { asset, mediaOrigin: props.mediaOrigin, alt: href === null ? featured.caption : featured.caption || label });
|
|
3296
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "figure", { className: "tb-mm-feat", children: [
|
|
3297
|
+
href === null ? image : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href, children: image }),
|
|
3298
|
+
featured.caption === "" ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "figcaption", { children: featured.caption })
|
|
3299
|
+
] });
|
|
3300
|
+
}
|
|
3301
|
+
function List2({ items, top, ctx }) {
|
|
3302
|
+
if (items.length === 0) return null;
|
|
3303
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...top === void 0 ? { className: "tb-mm-sub" } : { id: top.id, className: "tb-mm-list" }, children: items.map((item) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Entry, { item, level: top === void 0 ? 2 : 1, ctx }, item.key)) });
|
|
3304
|
+
}
|
|
3305
|
+
function Entry({ item, level, ctx }) {
|
|
3306
|
+
const hasPanel = item.mega !== void 0 && (item.children.length > 0 || item.mega.featured !== null);
|
|
3307
|
+
const sub = item.children.length > 0 || hasPanel;
|
|
3308
|
+
const toggle = sub && level === 1 && ctx.mode !== "vertical";
|
|
3309
|
+
const cls = ["tb-mm-i", ...item.classes].join(" ");
|
|
3310
|
+
const subId = `${ctx.listId}-${item.key.replace(/[^A-Za-z0-9_-]/g, "_")}`;
|
|
3311
|
+
let below = null;
|
|
3312
|
+
if (hasPanel && item.mega !== void 0) {
|
|
3313
|
+
below = /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { id: subId, className: "tb-mm-panel", style: { "--tb-mm-cols": item.mega.columns }, children: [
|
|
3314
|
+
item.children.length === 0 ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "tb-mm-cols", children: item.children.map((child) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: "tb-mm-col", children: [
|
|
3315
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Anchor, { item: child }),
|
|
3316
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Extras, { item: child, describe: true }),
|
|
3317
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, List2, { items: child.children, ctx })
|
|
3318
|
+
] }, child.key)) }),
|
|
3319
|
+
item.mega.featured === null ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, FeaturedPanel, { featured: item.mega.featured, label: item.label, ctx })
|
|
3320
|
+
] });
|
|
3321
|
+
} else if (sub) {
|
|
3322
|
+
below = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { id: subId, className: "tb-mm-sub", children: item.children.map((child) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Entry, { item: child, level: 2, ctx }, child.key)) });
|
|
3323
|
+
}
|
|
3324
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { className: cls, ...sub && level === 1 ? { "data-tb-i": "" } : {}, children: [
|
|
3325
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Anchor, { item }),
|
|
3326
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Extras, { item, describe: false }),
|
|
3327
|
+
toggle ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3328
|
+
"button",
|
|
3329
|
+
{
|
|
3330
|
+
type: "button",
|
|
3331
|
+
className: "tb-mm-t",
|
|
3332
|
+
"data-tb-t": "",
|
|
3333
|
+
"aria-expanded": "false",
|
|
3334
|
+
"aria-controls": subId,
|
|
3335
|
+
"aria-label": ctx.submenu.replace("{label}", () => item.label),
|
|
3336
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "svg", { viewBox: "0 0 24 24", width: "16", height: "16", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "path", { d: "M6 9l6 6 6-6", fill: "none", stroke: "currentColor", strokeWidth: "2" }) })
|
|
3337
|
+
}
|
|
3338
|
+
) : null,
|
|
3339
|
+
below
|
|
3340
|
+
] });
|
|
3341
|
+
}
|
|
3342
|
+
function MenuRuntime() {
|
|
3343
|
+
_react.useEffect.call(void 0, () => startMenuRuntime(), []);
|
|
3344
|
+
return null;
|
|
3345
|
+
}
|
|
3346
|
+
var part = (key, extra) => ({
|
|
3347
|
+
className: [`tsf-${key}`, extra].filter(Boolean).join(" "),
|
|
3348
|
+
"data-throttle-part": key
|
|
3349
|
+
});
|
|
3350
|
+
function StorefrontNav({ items, label, listId, ctx, className, menu }) {
|
|
3351
|
+
const categories = items.some((item) => item.handle !== void 0);
|
|
3352
|
+
const handle = (item, parent) => item.handle === void 0 ? {} : { "data-category-handle": item.handle, ...categories ? { "data-category-parent": parent } : {} };
|
|
3353
|
+
const link = (item) => item.href === null ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { ...part("category-nav-link", "tb-mm-text"), children: item.label }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { ...part("category-nav-link"), href: item.href, ...item.newTab ? { target: "_blank", rel: "noopener noreferrer" } : {}, children: item.label });
|
|
3354
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "nav", { ...part("category-nav", className), "aria-label": label, ...categories ? {} : { "data-menu": menu }, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...part("category-nav-list"), children: items.map((item) => {
|
|
3355
|
+
const sub = item.children.length > 0;
|
|
3356
|
+
const panelId = `${listId}-${item.key.replace(/[^A-Za-z0-9_-]/g, "_")}`;
|
|
3357
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { ...part("category-nav-item", item.classes.join(" ")), "data-nav-top": "", ...sub ? { "data-tb-i": "" } : {}, ...handle(item, ""), children: [
|
|
3358
|
+
link(item),
|
|
3359
|
+
sub ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
3360
|
+
"button",
|
|
3361
|
+
{
|
|
3362
|
+
type: "button",
|
|
3363
|
+
...part("category-nav-toggle"),
|
|
3364
|
+
"data-tb-t": "",
|
|
3365
|
+
"aria-expanded": "false",
|
|
3366
|
+
"aria-controls": panelId,
|
|
3367
|
+
"aria-label": ctx.submenu.replace("{label}", () => item.label),
|
|
3368
|
+
children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: "chevron-down", size: 14 })
|
|
3369
|
+
}
|
|
3370
|
+
) : null,
|
|
3371
|
+
sub ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...part("category-nav-panel"), id: panelId, "data-nav-panel": "", hidden: true, children: item.children.map((child) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { ...part("category-nav-child", child.classes.join(" ")), ...handle(child, _nullishCoalesce(item.handle, () => ( ""))), children: link(child) }, child.key)) }) : null
|
|
3372
|
+
] }, item.key);
|
|
3373
|
+
}) }) });
|
|
3374
|
+
}
|
|
3375
|
+
function Nav({ items, label, listId, ctx, className, menu }) {
|
|
3376
|
+
if (ctx.variant === "storefront") return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, StorefrontNav, { items, label, listId, ctx, menu, ...className === void 0 ? {} : { className } });
|
|
3377
|
+
const full = { ...ctx, listId };
|
|
3378
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "nav", { className: `tb-mm tb-mm--${ctx.mode}${className === void 0 ? "" : ` ${className}`}`, "aria-label": label, children: [
|
|
3379
|
+
ctx.mode === "drawer" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-mm-drawer", "data-tb-drawer": "", "aria-expanded": "false", "aria-controls": listId, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: "menu", size: 24, label }) }),
|
|
3380
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, List2, { items, top: { id: listId }, ctx: full })
|
|
3381
|
+
] });
|
|
3382
|
+
}
|
|
3383
|
+
function MenuV2(props) {
|
|
3384
|
+
const { props: settings, data, mediaOrigin, editMode, locale } = props;
|
|
3385
|
+
const builder = useBuilder();
|
|
3386
|
+
const design = _ui.useSiteDesign.call(void 0, );
|
|
3387
|
+
const listId = _react.useId.call(void 0, );
|
|
3388
|
+
const mobileId = _react.useId.call(void 0, );
|
|
3389
|
+
const name = _nullishCoalesce(str(settings.menu), () => ( "header"));
|
|
3390
|
+
const mode = oneOf(settings.mode, MODES, "horizontal");
|
|
3391
|
+
const r = { mediaOrigin, locale, link: makeLink(builder, props.resolveLink, mediaOrigin) };
|
|
3392
|
+
const categories = Array.isArray(data.categories) ? data.categories : [];
|
|
3393
|
+
const forMenu = (menu, raw) => build(_builderschema.expandMenu.call(void 0, Array.isArray(raw) ? raw : [], categories).menu, 1, { r, menu, mega: mode === "mega" });
|
|
3394
|
+
let items = [];
|
|
3395
|
+
let mobile = [];
|
|
3396
|
+
const site = _optionalChain([builder, 'optionalAccess', _167 => _167.site]);
|
|
3397
|
+
const menus = _optionalChain([site, 'optionalAccess', _168 => _168.status]) === "ok" && isRecord(site.settings.menus) ? site.settings.menus : void 0;
|
|
3398
|
+
if (menus !== void 0) {
|
|
3399
|
+
items = Object.hasOwn(menus, name) ? forMenu(name, menus[name]) : [];
|
|
3400
|
+
if (name === "header" && Object.hasOwn(menus, "mobile")) mobile = forMenu("mobile", menus.mobile);
|
|
3401
|
+
} else if (_optionalChain([design, 'optionalAccess', _169 => _169.menus]) !== void 0 && Object.hasOwn(design.menus, name)) {
|
|
3402
|
+
items = fromDesign(_nullishCoalesce(design.menus[name], () => ( [])), 1, r);
|
|
3403
|
+
}
|
|
3404
|
+
const word = (key, fallback) => {
|
|
3405
|
+
for (const strings of [_optionalChain([site, 'optionalAccess', _170 => _170.status]) === "ok" ? site.settings.strings : void 0, _optionalChain([design, 'optionalAccess', _171 => _171.strings])]) {
|
|
3406
|
+
if (isRecord(strings) && Object.hasOwn(strings, key) && str(strings[key]) !== void 0) return strings[key];
|
|
3407
|
+
}
|
|
3408
|
+
return fallback;
|
|
3409
|
+
};
|
|
3410
|
+
const label = word("nav.menu", _builderschema.SITE_STRING_DEFAULTS["nav.menu"]);
|
|
3411
|
+
if (items.length === 0 && mobile.length === 0) {
|
|
3412
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3413
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
|
|
3414
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: `Menu "${name}" is empty: add links in Site settings` })
|
|
3415
|
+
] });
|
|
3416
|
+
}
|
|
3417
|
+
const ctx = { builder, props, mode, variant: oneOf(settings.variant, ["default", "storefront"], "default"), submenu: word("nav.submenu", SUBMENU_DEFAULT) };
|
|
3418
|
+
const nameOf = (menu) => menu === "header" ? label : `${label} (${menu})`;
|
|
3419
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3420
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
|
|
3421
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: "tb-menu-v2", precedence: "throttle", children: MENU_V2_CSS }),
|
|
3422
|
+
items.length === 0 ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Nav, { items, menu: name, label: nameOf(name), listId, ctx, ...mobile.length > 0 ? { className: "tb-mm-hide-phone" } : {} }),
|
|
3423
|
+
mobile.length === 0 ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Nav, { items: mobile, menu: "mobile", label: nameOf("mobile"), listId: mobileId, ctx, className: "tb-mm-only-phone" }),
|
|
3424
|
+
props.interactive === false ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MenuRuntime, {})
|
|
3425
|
+
] });
|
|
3426
|
+
}
|
|
3427
|
+
var MENU_V2_CSS = `@layer throttle{
|
|
3428
|
+
.tb-mm{position:relative;color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-m));text-align:var(--b-align,start)}
|
|
3429
|
+
.tb-mm ul{margin:0;padding:0;list-style:none}
|
|
3430
|
+
.tb-mm li{position:relative;min-inline-size:0}
|
|
3431
|
+
.tb-mm a,.tb-mm-text{display:block;min-inline-size:0;padding:var(--tb-space-xs) var(--tb-space-s);color:inherit;text-decoration:none;overflow-wrap:anywhere}
|
|
3432
|
+
.tb-mm a:hover{text-decoration:underline}
|
|
3433
|
+
.tb-mm a:focus-visible,.tb-mm-t:focus-visible,.tb-mm-drawer:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
|
|
3434
|
+
.tb-mm-badge{display:inline-block;margin-inline-start:var(--tb-space-xs);padding-inline:.5em;border-radius:99px;font-size:.75em;background:var(--tb-color-primary,#111);color:var(--tb-color-primary-foreground,#fff)}
|
|
3435
|
+
.tb-mm-desc{display:block;padding-inline:var(--tb-space-s);font-size:.85em;opacity:.75;overflow-wrap:anywhere}
|
|
3436
|
+
.tb-mm-t{display:inline-flex;align-items:center;justify-content:center;min-inline-size:32px;min-block-size:32px;padding:0;border:0;background:transparent;color:inherit;cursor:pointer}
|
|
3437
|
+
.tb-mm-t svg{transition:transform .15s}
|
|
3438
|
+
.tb-mm-i[data-open]>.tb-mm-t svg{transform:rotate(180deg)}
|
|
3439
|
+
.tb-mm-drawer{display:none;align-items:center;justify-content:center;min-inline-size:44px;min-block-size:44px;padding:0;border:0;background:transparent;color:inherit;cursor:pointer}
|
|
3440
|
+
.tb-mm-only-phone{display:none}
|
|
3441
|
+
.tb-mm--horizontal>ul,.tb-mm--drawer>ul,.tb-mm--mega>ul{display:flex;flex-wrap:wrap;align-items:center}
|
|
3442
|
+
.tb-mm--horizontal>ul>li,.tb-mm--drawer>ul>li,.tb-mm--mega>ul>li{display:inline-flex;align-items:center}
|
|
3443
|
+
.tb-mm-sub,.tb-mm-panel{display:none}
|
|
3444
|
+
.tb-mm-i>.tb-mm-sub{position:absolute;inset-block-start:100%;inset-inline-start:0;z-index:20;min-inline-size:12rem;padding:var(--tb-space-xs);text-align:start;background:var(--tb-color-background,#fff);color:var(--tb-color-foreground,#111);border:1px solid var(--tb-color-border,#ddd);border-radius:var(--throttle-radius,8px)}
|
|
3445
|
+
.tb-mm-sub .tb-mm-sub{position:static;min-inline-size:0;padding:0;padding-inline-start:var(--tb-space-m);border:0}
|
|
3446
|
+
.tb-mm-sub>li{display:block}
|
|
3447
|
+
.tb-mm-i[data-open]>.tb-mm-sub{display:block}
|
|
3448
|
+
.tb-mm-sub .tb-mm-sub{display:block}
|
|
3449
|
+
.tb-mm--vertical .tb-mm-t{display:none}
|
|
3450
|
+
.tb-mm--vertical .tb-mm-sub{display:block;position:static;min-inline-size:0;padding:0;padding-inline-start:var(--tb-space-m);border:0}
|
|
3451
|
+
.tb-mm--mega>ul>li{position:static}
|
|
3452
|
+
.tb-mm--mega>ul>li>.tb-mm-panel{position:absolute;inset-inline:0;inset-block-start:100%;z-index:20;padding:var(--tb-space-m);text-align:start;background:var(--tb-color-background,#fff);color:var(--tb-color-foreground,#111);border:1px solid var(--tb-color-border,#ddd);border-radius:var(--throttle-radius,8px)}
|
|
3453
|
+
.tb-mm-i[data-open]>.tb-mm-panel{display:flex;gap:var(--tb-space-m)}
|
|
3454
|
+
.tb-mm-cols{display:grid;grid-template-columns:repeat(var(--tb-mm-cols,3),minmax(0,1fr));gap:var(--tb-space-m);flex:1 1 0;min-inline-size:0}
|
|
3455
|
+
.tb-mm-col>.tb-mm-sub{display:block;position:static;min-inline-size:0;padding:0;border:0}
|
|
3456
|
+
.tb-mm-feat{flex:0 1 16rem;min-inline-size:0;margin:0}
|
|
3457
|
+
.tb-mm-feat img{display:block;max-inline-size:100%;block-size:auto}
|
|
3458
|
+
@media (max-width:767.98px){
|
|
3459
|
+
.tb-mm-hide-phone{display:none}
|
|
3460
|
+
.tb-mm-only-phone{display:block}
|
|
3461
|
+
.tb-mm--mega>ul{display:block}
|
|
3462
|
+
.tb-mm--mega>ul>li{display:flex;flex-wrap:wrap;align-items:center}
|
|
3463
|
+
.tb-mm--mega>ul>li>a,.tb-mm--mega>ul>li>.tb-mm-text{flex:1 1 0}
|
|
3464
|
+
.tb-mm--mega>ul>li>.tb-mm-sub,.tb-mm--mega>ul>li>.tb-mm-panel{flex:1 0 100%}
|
|
3465
|
+
.tb-mm-panel{position:static;inset:auto;border:0;padding:0;background:transparent}
|
|
3466
|
+
.tb-mm-cols{display:block}
|
|
3467
|
+
.tb-mm-feat{display:none}
|
|
3468
|
+
.tb-mm--mega>ul>li>.tb-mm-panel{position:static;border:0;padding:0}
|
|
3469
|
+
.tb-mm-i>.tb-mm-sub{position:static;min-inline-size:0;border:0;padding:0;padding-inline-start:var(--tb-space-m)}
|
|
3470
|
+
.tb-mm--drawer>.tb-mm-drawer{display:inline-flex;position:relative;z-index:61}
|
|
3471
|
+
.tb-mm--drawer[data-open=true]>.tb-mm-drawer{position:fixed;inset-block-start:var(--tb-space-s);inset-inline-end:var(--tb-space-s)}
|
|
3472
|
+
.tb-mm--drawer>ul{display:none}
|
|
3473
|
+
.tb-mm--drawer[data-open=true]>ul{display:block;position:fixed;inset:0;z-index:60;overflow:auto;padding:4.5rem var(--tb-space-m) var(--tb-space-m);text-align:start;background:var(--tb-color-background,#fff);color:var(--tb-color-foreground,#111);font-size:var(--tb-text-l)}
|
|
3474
|
+
.tb-mm--drawer[data-open=true]>ul>li{display:flex;flex-wrap:wrap}
|
|
3475
|
+
.tb-mm--drawer[data-open=true] .tb-mm-sub{display:block;position:static;border:0}
|
|
3476
|
+
}
|
|
3477
|
+
@media (scripting: none){
|
|
3478
|
+
.tb-mm-t{display:none}
|
|
3479
|
+
.tb-mm-i:hover>.tb-mm-sub,.tb-mm-i:focus-within>.tb-mm-sub{display:block}
|
|
3480
|
+
.tb-mm-i:hover>.tb-mm-panel,.tb-mm-i:focus-within>.tb-mm-panel{display:flex;gap:var(--tb-space-m)}
|
|
3481
|
+
@media (max-width:767.98px){
|
|
3482
|
+
.tb-mm-sub,.tb-mm-panel{display:block}
|
|
3483
|
+
.tb-mm--drawer>.tb-mm-drawer{display:none}
|
|
3484
|
+
.tb-mm--drawer>ul{display:block}
|
|
3485
|
+
}
|
|
3486
|
+
}
|
|
3487
|
+
}`;
|
|
3488
|
+
var definition = _builderschema.MB_BASIC_WIDGET_DEFINITIONS.find((d) => d.type === "basic.menu" && d.v === 2);
|
|
3489
|
+
if (definition === void 0) throw new Error("builder-schema has no basic.menu v2 definition");
|
|
3490
|
+
var menuV2Widgets = [{ ...definition, Component: MenuV2 }];
|
|
2584
3491
|
|
|
2585
|
-
// src/
|
|
3492
|
+
// src/basics/v2/announcement-v2.tsx
|
|
2586
3493
|
|
|
2587
|
-
var
|
|
2588
|
-
|
|
2589
|
-
var
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
3494
|
+
var DEVICES5 = ["desktop", "tablet", "phone"];
|
|
3495
|
+
var DISMISS_PREFIX = "tb-an-dismissed:";
|
|
3496
|
+
var COLOR_HEX = /^#(?:[0-9a-fA-F]{3,4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/;
|
|
3497
|
+
var COLOR_TOKEN2 = /^token:([a-z][a-z-]{0,30})$/;
|
|
3498
|
+
var REDUCED = "(prefers-reduced-motion: reduce)";
|
|
3499
|
+
function readDismissed(ids) {
|
|
3500
|
+
const out = [];
|
|
3501
|
+
for (const id of ids) {
|
|
3502
|
+
try {
|
|
3503
|
+
if (window.localStorage.getItem(`${DISMISS_PREFIX}${id}`) === "1") out.push(id);
|
|
3504
|
+
} catch (e9) {
|
|
3505
|
+
}
|
|
2593
3506
|
}
|
|
2594
|
-
|
|
2595
|
-
|
|
3507
|
+
return out;
|
|
3508
|
+
}
|
|
3509
|
+
function writeDismissed(id) {
|
|
3510
|
+
try {
|
|
3511
|
+
window.localStorage.setItem(`${DISMISS_PREFIX}${id}`, "1");
|
|
3512
|
+
} catch (e10) {
|
|
2596
3513
|
}
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
3514
|
+
}
|
|
3515
|
+
var matches = (query) => _optionalChain([window, 'access', _172 => _172.matchMedia, 'optionalCall', _173 => _173(query), 'access', _174 => _174.matches]) === true;
|
|
3516
|
+
function deviceNow() {
|
|
3517
|
+
return matches("(max-width:767.98px)") ? "phone" : matches("(max-width:1024.98px)") ? "tablet" : "desktop";
|
|
3518
|
+
}
|
|
3519
|
+
function colorOf(value) {
|
|
3520
|
+
if (typeof value !== "string") return void 0;
|
|
3521
|
+
if (COLOR_HEX.test(value)) return value;
|
|
3522
|
+
const token = COLOR_TOKEN2.exec(value);
|
|
3523
|
+
return token === null ? void 0 : `var(--tb-color-${token[1]})`;
|
|
3524
|
+
}
|
|
3525
|
+
var textOf = (tree) => tree.children.map((child) => typeof child === "string" ? child : textOf(child)).join("");
|
|
3526
|
+
function inline(children) {
|
|
3527
|
+
return children.map((child, index) => {
|
|
3528
|
+
if (typeof child === "string") return child;
|
|
3529
|
+
const inner = inline(child.children);
|
|
3530
|
+
if (child.tag === "strong" || child.tag === "em") return _react.createElement.call(void 0, child.tag, { key: index }, ...inner);
|
|
3531
|
+
if (child.tag === "a" && typeof child.href === "string") {
|
|
3532
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href: child.href, rel: "noopener noreferrer", children: inner }, index);
|
|
2602
3533
|
}
|
|
3534
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: inner }, index);
|
|
3535
|
+
});
|
|
3536
|
+
}
|
|
3537
|
+
function MessageText({ message, locale, mediaOrigin, href }) {
|
|
3538
|
+
const tree = parseRichText(_nullishCoalesce(localized(message.text, locale), () => ( "")), mediaOrigin);
|
|
3539
|
+
if (href !== null) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href, children: textOf(tree) });
|
|
3540
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-an-text", children: inline(tree.children) });
|
|
3541
|
+
}
|
|
3542
|
+
function pageOf2(builder) {
|
|
3543
|
+
const given = _optionalChain([builder, 'optionalAccess', _175 => _175.page]);
|
|
3544
|
+
if (given !== void 0) return given;
|
|
3545
|
+
return { home: _optionalChain([builder, 'optionalAccess', _176 => _176.pathname]) === "/" };
|
|
3546
|
+
}
|
|
3547
|
+
function audienceOf(ready, viewer) {
|
|
3548
|
+
if (!ready || viewer === null || _optionalChain([viewer, 'optionalAccess', _177 => _177.signedIn]) === null) return "all";
|
|
3549
|
+
return _optionalChain([viewer, 'optionalAccess', _178 => _178.signedIn]) === true ? "signed-in" : "guest";
|
|
3550
|
+
}
|
|
3551
|
+
function Bar({ raw, props, builder }) {
|
|
3552
|
+
const { props: settings, mediaOrigin, locale, editMode } = props;
|
|
3553
|
+
const design = _ui.useSiteDesign.call(void 0, );
|
|
3554
|
+
const viewer = useViewer();
|
|
3555
|
+
const all2 = _react.useMemo.call(void 0, () => normalizeMessages(Array.isArray(raw.messages) ? raw.messages : []), [raw]);
|
|
3556
|
+
const style = isRecord(raw.style) ? raw.style : {};
|
|
3557
|
+
const rotate = isRecord(raw.rotate) ? raw.rotate : {};
|
|
3558
|
+
const [ready, setReady] = _react.useState.call(void 0, false);
|
|
3559
|
+
const [dismissed, setDismissed] = _react.useState.call(void 0, () => /* @__PURE__ */ new Set());
|
|
3560
|
+
const [at, setAt] = _react.useState.call(void 0, 0);
|
|
3561
|
+
const [hover, setHover] = _react.useState.call(void 0, false);
|
|
3562
|
+
const [focus, setFocus] = _react.useState.call(void 0, false);
|
|
3563
|
+
const [reduced2, setReduced] = _react.useState.call(void 0, false);
|
|
3564
|
+
const site = _optionalChain([builder, 'optionalAccess', _179 => _179.site]);
|
|
3565
|
+
const loadedAt = _optionalChain([site, 'optionalAccess', _180 => _180.status]) === "ok" && site.loadedAt !== void 0 ? Date.parse(site.loadedAt) : Number.NaN;
|
|
3566
|
+
const now = ready || Number.isNaN(loadedAt) ? Date.now() : loadedAt;
|
|
3567
|
+
const page = pageOf2(builder);
|
|
3568
|
+
const eligible = eligibleOnAnyDevice(all2, now, audienceOf(ready, viewer), page);
|
|
3569
|
+
const shown2 = eligible.filter((m) => editMode || !dismissed.has(m.id));
|
|
3570
|
+
const forEveryone = new Set(eligibleOnAnyDevice(all2, now, "all", page).map((m) => m.id));
|
|
3571
|
+
const waiting = [...eligibleOnAnyDevice(all2, now, "guest", page), ...eligibleOnAnyDevice(all2, now, "signed-in", page)].some(
|
|
3572
|
+
(m) => !forEveryone.has(m.id)
|
|
3573
|
+
);
|
|
3574
|
+
const interactive = props.interactive !== false && !editMode;
|
|
3575
|
+
const rotating = interactive && rotate.enabled === true && shown2.length > 1;
|
|
3576
|
+
const current = Math.min(at, Math.max(0, shown2.length - 1));
|
|
3577
|
+
const intervalS = typeof rotate.intervalS === "number" ? Math.min(15, Math.max(3, rotate.intervalS)) : 6;
|
|
3578
|
+
const shownRef = _react.useRef.call(void 0, shown2);
|
|
3579
|
+
shownRef.current = shown2;
|
|
3580
|
+
_react.useEffect.call(void 0, () => {
|
|
3581
|
+
setReady(true);
|
|
3582
|
+
setDismissed(new Set(readDismissed(all2.map((m) => m.id))));
|
|
3583
|
+
}, [all2]);
|
|
3584
|
+
_react.useEffect.call(void 0, () => {
|
|
3585
|
+
const query = _optionalChain([window, 'access', _181 => _181.matchMedia, 'optionalCall', _182 => _182(REDUCED)]);
|
|
3586
|
+
if (query === void 0) return void 0;
|
|
3587
|
+
const sync = () => setReduced(query.matches);
|
|
3588
|
+
sync();
|
|
3589
|
+
_optionalChain([query, 'access', _183 => _183.addEventListener, 'optionalCall', _184 => _184("change", sync)]);
|
|
3590
|
+
return () => _optionalChain([query, 'access', _185 => _185.removeEventListener, 'optionalCall', _186 => _186("change", sync)]);
|
|
3591
|
+
}, []);
|
|
3592
|
+
const step2 = (direction) => setAt((from) => {
|
|
3593
|
+
const list2 = shownRef.current;
|
|
3594
|
+
const device = deviceNow();
|
|
3595
|
+
let i = Math.min(from, list2.length - 1);
|
|
3596
|
+
for (let tries = 0; tries < list2.length; tries += 1) {
|
|
3597
|
+
i = (i + direction + list2.length) % list2.length;
|
|
3598
|
+
if (list2[i].devices.includes(device)) return i;
|
|
3599
|
+
}
|
|
3600
|
+
return from;
|
|
3601
|
+
});
|
|
3602
|
+
_react.useEffect.call(void 0, () => {
|
|
3603
|
+
const list2 = shownRef.current;
|
|
3604
|
+
if (list2.length > 1 && list2[0] !== void 0 && !list2[0].devices.includes(deviceNow())) step2(1);
|
|
3605
|
+
}, [ready]);
|
|
3606
|
+
_react.useEffect.call(void 0, () => {
|
|
3607
|
+
if (!rotating || hover || focus || reduced2) return void 0;
|
|
3608
|
+
const timer = setInterval(() => step2(1), intervalS * 1e3);
|
|
3609
|
+
return () => clearInterval(timer);
|
|
3610
|
+
}, [rotating, hover, focus, reduced2, intervalS]);
|
|
3611
|
+
if (raw.enabled !== true) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "No announcement: turn one on in Site settings" });
|
|
3612
|
+
const reserve = eligible.length === 0 && waiting;
|
|
3613
|
+
if (shown2.length === 0 && !reserve) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "No announcement is showing now" });
|
|
3614
|
+
const link = makeLink(builder, props.resolveLink, mediaOrigin);
|
|
3615
|
+
const word = (key, fallback) => {
|
|
3616
|
+
for (const strings of [_optionalChain([site, 'optionalAccess', _187 => _187.status]) === "ok" ? site.settings.strings : void 0, _optionalChain([design, 'optionalAccess', _188 => _188.strings])]) {
|
|
3617
|
+
if (isRecord(strings) && Object.hasOwn(strings, key) && str(strings[key]) !== void 0) return strings[key];
|
|
3618
|
+
}
|
|
3619
|
+
return fallback;
|
|
3620
|
+
};
|
|
3621
|
+
const dismissLabel = word("announcement.dismiss", _builderschema.SITE_STRING_DEFAULTS["announcement.dismiss"]);
|
|
3622
|
+
const dismissible = interactive && style.dismissible === true && settings.dismissible !== false;
|
|
3623
|
+
const dismiss = (id) => {
|
|
3624
|
+
writeDismissed(id);
|
|
3625
|
+
setDismissed((previous) => new Set(previous).add(id));
|
|
3626
|
+
};
|
|
3627
|
+
const height = isRecord(style.height) ? style.height : {};
|
|
3628
|
+
const vars = {};
|
|
3629
|
+
for (const [device, key] of [["desktop", "--tb-an-hd"], ["tablet", "--tb-an-ht"], ["phone", "--tb-an-hp"]]) {
|
|
3630
|
+
const value = Object.hasOwn(height, device) ? height[device] : null;
|
|
3631
|
+
if (typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= 200) vars[key] = `${String(value)}px`;
|
|
2603
3632
|
}
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
3633
|
+
const background = colorOf(style.background);
|
|
3634
|
+
const foreground = colorOf(style.text);
|
|
3635
|
+
if (background !== void 0) vars["--tb-an-bg"] = background;
|
|
3636
|
+
if (foreground !== void 0) vars["--tb-an-fg"] = foreground;
|
|
3637
|
+
const align = style.align === "left" || style.align === "right" ? style.align : "center";
|
|
3638
|
+
const size = style.size === "m" ? "m" : "s";
|
|
3639
|
+
const transition = rotate.transition === "slide" ? "slide" : "fade";
|
|
3640
|
+
const activeMessage = shown2[current];
|
|
3641
|
+
const live = rotating && !hover && !focus && !reduced2 ? "off" : "polite";
|
|
3642
|
+
const dismissButton = (id) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-b-dismiss", onClick: () => dismiss(id), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: "close", size: 16, label: dismissLabel }) });
|
|
3643
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3644
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
|
|
3645
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: "tb-an", precedence: "throttle", children: ANNOUNCEMENT_V2_CSS }),
|
|
3646
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3647
|
+
"div",
|
|
3648
|
+
{
|
|
3649
|
+
className: `tb-an tb-an--${size} tb-an--${transition}${rotating ? " tb-an--rot" : ""}${reserve ? " tb-an--reserve" : ""}`,
|
|
3650
|
+
role: "region",
|
|
3651
|
+
"aria-label": word("announcement.label", "Announcement"),
|
|
3652
|
+
"data-align": align,
|
|
3653
|
+
style: vars,
|
|
3654
|
+
onMouseEnter: () => setHover(true),
|
|
3655
|
+
onMouseLeave: () => setHover(false),
|
|
3656
|
+
onFocus: () => setFocus(true),
|
|
3657
|
+
onBlur: () => setFocus(false),
|
|
3658
|
+
children: [
|
|
3659
|
+
rotating && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-an-step", "data-tb-an-prev": "", "aria-label": word("announcement.previous", "Previous announcement"), onClick: () => step2(-1), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-hidden": "true", children: "\u2039" }) }),
|
|
3660
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-an-track", ...rotating ? { "aria-live": live } : {}, children: shown2.map((m, index) => {
|
|
3661
|
+
const target2 = isRecord(m.target) ? m.target : null;
|
|
3662
|
+
const hidden = DEVICES5.filter((d) => !m.devices.includes(d)).map((d) => ` tb-an-hide-${d}`).join("");
|
|
3663
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
|
|
3664
|
+
"div",
|
|
3665
|
+
{
|
|
3666
|
+
className: `tb-b-announcement tb-an-msg${hidden}`,
|
|
3667
|
+
...rotating && index === current ? { "data-active": "" } : {},
|
|
3668
|
+
children: [
|
|
3669
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-announcement-text", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MessageText, { message: m, locale, mediaOrigin, href: target2 === null ? null : link(target2) }) }),
|
|
3670
|
+
!rotating && dismissible && dismissButton(m.id)
|
|
3671
|
+
]
|
|
3672
|
+
},
|
|
3673
|
+
m.id
|
|
3674
|
+
);
|
|
3675
|
+
}) }),
|
|
3676
|
+
rotating && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-an-step", "data-tb-an-next": "", "aria-label": word("announcement.next", "Next announcement"), onClick: () => step2(1), children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-hidden": "true", children: "\u203A" }) }),
|
|
3677
|
+
rotating && dismissible && activeMessage !== void 0 && dismissButton(activeMessage.id)
|
|
3678
|
+
]
|
|
3679
|
+
}
|
|
3680
|
+
)
|
|
3681
|
+
] });
|
|
3682
|
+
}
|
|
3683
|
+
function AnnouncementV2(props) {
|
|
3684
|
+
const builder = useBuilder();
|
|
3685
|
+
const site = _optionalChain([builder, 'optionalAccess', _189 => _189.site]);
|
|
3686
|
+
const raw = _optionalChain([site, 'optionalAccess', _190 => _190.status]) === "ok" && isRecord(site.settings.announcement) ? site.settings.announcement : null;
|
|
3687
|
+
if (raw === null || !Array.isArray(raw.messages)) return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Announcement, { ...props });
|
|
3688
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Bar, { raw, props, builder });
|
|
3689
|
+
}
|
|
3690
|
+
var ANNOUNCEMENT_V2_CSS = `@layer throttle{
|
|
3691
|
+
.tb-an{--tb-an-rf:0px;display:flex;align-items:stretch;box-sizing:border-box;min-block-size:var(--tb-an-hd,var(--tb-an-rf));background:var(--b-background,var(--tb-an-bg,var(--tb-color-primary,#111)))}
|
|
3692
|
+
.tb-an--reserve,.tb-an--rot{--tb-an-rf:2.5rem}
|
|
3693
|
+
.tb-an-track{flex:1 1 auto;min-inline-size:0}
|
|
3694
|
+
.tb-an .tb-b-announcement{background:var(--b-background,var(--tb-an-bg,var(--tb-color-primary,#111)));color:var(--b-color,var(--tb-an-fg,var(--tb-color-primary-foreground,#fff)));text-align:var(--b-align,center);overflow-wrap:anywhere}
|
|
3695
|
+
.tb-an[data-align=left] .tb-b-announcement{text-align:var(--b-align,start);justify-content:flex-start}
|
|
3696
|
+
.tb-an[data-align=right] .tb-b-announcement{text-align:var(--b-align,end);justify-content:flex-end}
|
|
3697
|
+
.tb-an--m .tb-b-announcement{font-size:var(--tb-text-m)}
|
|
3698
|
+
.tb-an-text{display:inline}
|
|
3699
|
+
.tb-an-step{flex:0 0 auto;min-inline-size:32px;padding:0;border:0;background:transparent;color:var(--b-color,var(--tb-an-fg,var(--tb-color-primary-foreground,#fff)));font:inherit;cursor:pointer}
|
|
3700
|
+
.tb-an-step:focus-visible{outline:2px solid currentColor;outline-offset:-2px}
|
|
3701
|
+
[dir=rtl] .tb-an-step span{display:inline-block;transform:scaleX(-1)}
|
|
3702
|
+
.tb-an--rot .tb-an-track{display:grid}
|
|
3703
|
+
.tb-an--rot .tb-an-msg{grid-area:1/1}
|
|
3704
|
+
.tb-an--rot .tb-an-msg:not([data-active]){visibility:hidden}
|
|
3705
|
+
@media (prefers-reduced-motion:no-preference){.tb-an--fade .tb-an-msg[data-active]{animation:tb-an-fade .4s ease}.tb-an--slide .tb-an-msg[data-active]{animation:tb-an-slide .4s ease}}
|
|
3706
|
+
@keyframes tb-an-fade{from{opacity:0}to{opacity:1}}
|
|
3707
|
+
@keyframes tb-an-slide{from{opacity:0;transform:translateY(-.75rem)}to{opacity:1;transform:none}}
|
|
3708
|
+
@media (max-width:1024.98px){.tb-an{min-block-size:var(--tb-an-ht,var(--tb-an-hd,var(--tb-an-rf)))}}
|
|
3709
|
+
@media (max-width:767.98px){.tb-an{min-block-size:var(--tb-an-hp,var(--tb-an-ht,var(--tb-an-hd,var(--tb-an-rf))))}}
|
|
3710
|
+
@media (min-width:1024.99px){.tb-an-hide-desktop{display:none}}
|
|
3711
|
+
@media (min-width:767.99px) and (max-width:1024.98px){.tb-an-hide-tablet{display:none}}
|
|
3712
|
+
@media (max-width:767.98px){.tb-an-hide-phone{display:none}}
|
|
3713
|
+
}`;
|
|
3714
|
+
var definition2 = _builderschema.BASIC_WIDGET_DEFINITIONS.find((d) => d.type === "basic.announcement");
|
|
3715
|
+
if (definition2 === void 0) throw new Error("builder-schema has no basic.announcement definition");
|
|
3716
|
+
var announcementV2Widgets = [{ ...definition2, Component: AnnouncementV2 }];
|
|
3717
|
+
|
|
3718
|
+
// src/basics/v2/breadcrumbs.tsx
|
|
3719
|
+
|
|
3720
|
+
|
|
3721
|
+
|
|
3722
|
+
// src/basics/v2/definitions.ts
|
|
3723
|
+
|
|
3724
|
+
function mbDefinition(type) {
|
|
3725
|
+
const found = _builderschema.MB_BASIC_WIDGET_DEFINITIONS.filter((d) => d.type === type).sort((a, b) => b.v - a.v)[0];
|
|
3726
|
+
if (found === void 0) throw new Error(`No MB definition of ${type}`);
|
|
3727
|
+
return found;
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3730
|
+
// src/basics/v2/breadcrumbs.tsx
|
|
3731
|
+
|
|
3732
|
+
var SEPARATORS = { slash: "/", chevron: "\u203A", dot: "\xB7", arrow: "\u2192" };
|
|
3733
|
+
function jsonLdOn(settings) {
|
|
3734
|
+
if (!isRecord(settings) || !isRecord(settings.seo) || !isRecord(settings.seo.structuredData)) return false;
|
|
3735
|
+
return settings.seo.structuredData.breadcrumbs === true;
|
|
3736
|
+
}
|
|
3737
|
+
function Breadcrumbs({ props, data, mediaOrigin, resolveLink, editMode }) {
|
|
3738
|
+
const design = _ui.useSiteDesign.call(void 0, );
|
|
3739
|
+
const builder = useBuilder();
|
|
3740
|
+
const product = isRecord(data.product) ? data.product : null;
|
|
3741
|
+
const title = product === null ? void 0 : _nullishCoalesce(str(product.title), () => ( str(product.handle)));
|
|
3742
|
+
if (product === null || title === void 0) {
|
|
3743
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3744
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
3745
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "The trail appears on a product page" })
|
|
3746
|
+
] });
|
|
2607
3747
|
}
|
|
2608
|
-
|
|
2609
|
-
|
|
3748
|
+
const href = (target2) => _builderschema.safeUrl.call(void 0, _optionalChain([resolveLink, 'optionalCall', _191 => _191(target2)]), "href", { mediaOrigin });
|
|
3749
|
+
const trail = [{ name: _nullishCoalesce(str(_optionalChain([design, 'optionalAccess', _192 => _192.brand, 'optionalAccess', _193 => _193.storeName, 'optionalAccess', _194 => _194.trim, 'call', _195 => _195()])), () => ( "Home")), href: "/" }];
|
|
3750
|
+
for (const step2 of Array.isArray(product.breadcrumbs) ? product.breadcrumbs : []) {
|
|
3751
|
+
if (!isRecord(step2) || str(step2.name) === void 0) continue;
|
|
3752
|
+
const handle2 = str(step2.handle);
|
|
3753
|
+
trail.push({ name: step2.name, href: handle2 === void 0 ? null : href({ kind: "category", handle: handle2 }) });
|
|
3754
|
+
}
|
|
3755
|
+
const handle = str(product.handle);
|
|
3756
|
+
const current = { name: title, href: handle === void 0 ? null : href({ kind: "product", handle }) };
|
|
3757
|
+
const shown2 = props.showCurrent === false ? trail : [...trail, current];
|
|
3758
|
+
const separator = SEPARATORS[oneOf(props.separator, ["slash", "chevron", "dot", "arrow"], "slash")];
|
|
3759
|
+
const jsonLd = builder !== null && builder.site.status === "ok" && jsonLdOn(builder.site.settings) ? jsonLdString(breadcrumbJsonLd(shown2.flatMap((crumb) => crumb.href === null ? [] : [{ name: crumb.name, url: crumb.href }]))) : null;
|
|
3760
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
3761
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
3762
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "nav", { className: "tb-b-crumbs", "aria-label": "Breadcrumb", children: [
|
|
3763
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { children: shown2.map((crumb, index) => {
|
|
3764
|
+
const last = index === shown2.length - 1 && props.showCurrent !== false;
|
|
3765
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { children: [
|
|
3766
|
+
index > 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-crumbs-sep", "aria-hidden": "true", children: separator }),
|
|
3767
|
+
last ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { "aria-current": "page", children: crumb.name }) : crumb.href === null ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { children: crumb.name }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href: crumb.href, children: crumb.name })
|
|
3768
|
+
] }, `${String(index)}:${crumb.name}`);
|
|
3769
|
+
}) }),
|
|
3770
|
+
jsonLd !== null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "script", { type: "application/ld+json", children: jsonLd })
|
|
3771
|
+
] })
|
|
3772
|
+
] });
|
|
3773
|
+
}
|
|
3774
|
+
var breadcrumbsWidgets = [{ ...mbDefinition("basic.breadcrumbs"), Component: Breadcrumbs }];
|
|
3775
|
+
|
|
3776
|
+
// src/basics/v2/faq.tsx
|
|
3777
|
+
|
|
3778
|
+
|
|
3779
|
+
|
|
3780
|
+
// src/basics/v2/markup.tsx
|
|
3781
|
+
|
|
3782
|
+
|
|
3783
|
+
|
|
3784
|
+
var RICH = new Set(_builderschema.RICH_CONTENT_ALLOWED_TAGS);
|
|
3785
|
+
var SVG = new Set(_builderschema.SVG_ALLOWED_TAGS);
|
|
3786
|
+
var VOID2 = /* @__PURE__ */ new Set(["br", "hr", "img"]);
|
|
3787
|
+
var MAX_DEPTH4 = 24;
|
|
3788
|
+
var TOKEN = /<(\/?)([A-Za-z][A-Za-z0-9]*)((?:\s+[^\s="'<>/]+(?:="[^"]*")?)*)\s*(\/?)>|([^<]+)|</gu;
|
|
3789
|
+
var ATTR = /\s+([^\s="'<>/]+)(?:="([^"]*)")?/gu;
|
|
3790
|
+
var ENTITIES = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\xA0" };
|
|
3791
|
+
function decode2(value) {
|
|
3792
|
+
return value.replace(/&(?:#x([0-9a-f]{1,6})|#(\d{1,7})|([a-z]{2,6}));/giu, (whole, hex, dec, name) => {
|
|
3793
|
+
if (name !== void 0) return Object.hasOwn(ENTITIES, name.toLowerCase()) ? ENTITIES[name.toLowerCase()] : whole;
|
|
3794
|
+
const code = hex !== void 0 ? Number.parseInt(hex, 16) : Number.parseInt(_nullishCoalesce(dec, () => ( "")), 10);
|
|
3795
|
+
return code > 0 && code <= 1114111 && !(code >= 55296 && code <= 57343) ? String.fromCodePoint(code) : "";
|
|
3796
|
+
});
|
|
3797
|
+
}
|
|
3798
|
+
function parseMarkup(markup, kind) {
|
|
3799
|
+
const allowed = kind === "rich" ? RICH : SVG;
|
|
3800
|
+
const root = { tag: "#root", attrs: [], children: [] };
|
|
3801
|
+
const stack = [root];
|
|
3802
|
+
let skipping = 0;
|
|
3803
|
+
for (const match of markup.matchAll(TOKEN)) {
|
|
3804
|
+
const [, closing, name, attrText2, selfClose, text2] = match;
|
|
3805
|
+
const top = stack[stack.length - 1];
|
|
3806
|
+
if (name === void 0) {
|
|
3807
|
+
if (skipping === 0 && text2 !== void 0) top.children.push(decode2(text2));
|
|
3808
|
+
continue;
|
|
3809
|
+
}
|
|
3810
|
+
const tag = [...allowed].find((candidate) => candidate.toLowerCase() === name.toLowerCase());
|
|
3811
|
+
if (closing === "/") {
|
|
3812
|
+
if (skipping > 0) skipping -= 1;
|
|
3813
|
+
else if (tag !== void 0 && stack.length > 1 && top.tag === tag) stack.pop();
|
|
3814
|
+
continue;
|
|
3815
|
+
}
|
|
3816
|
+
const isVoid = VOID2.has(name.toLowerCase());
|
|
3817
|
+
if (tag === void 0 || stack.length > MAX_DEPTH4) {
|
|
3818
|
+
if (selfClose !== "/" && !isVoid) skipping += 1;
|
|
3819
|
+
continue;
|
|
3820
|
+
}
|
|
3821
|
+
if (skipping > 0) {
|
|
3822
|
+
if (selfClose !== "/" && !isVoid) skipping += 1;
|
|
3823
|
+
continue;
|
|
3824
|
+
}
|
|
3825
|
+
const attrs = [];
|
|
3826
|
+
for (const a of (_nullishCoalesce(attrText2, () => ( ""))).matchAll(ATTR)) attrs.push([a[1], decode2(_nullishCoalesce(a[2], () => ( "")))]);
|
|
3827
|
+
const element = { tag, attrs, children: [] };
|
|
3828
|
+
top.children.push(element);
|
|
3829
|
+
if (selfClose !== "/" && !isVoid) stack.push(element);
|
|
2610
3830
|
}
|
|
3831
|
+
return root.children;
|
|
3832
|
+
}
|
|
3833
|
+
function textOf2(nodes) {
|
|
3834
|
+
return nodes.map((n) => typeof n === "string" ? n : n.tag === "br" ? " " : textOf2(n.children)).join("");
|
|
3835
|
+
}
|
|
3836
|
+
var SPECIAL = {
|
|
3837
|
+
class: "className",
|
|
3838
|
+
colspan: "colSpan",
|
|
3839
|
+
rowspan: "rowSpan",
|
|
3840
|
+
"xlink:href": "xlinkHref",
|
|
3841
|
+
"xml:space": "xmlSpace",
|
|
3842
|
+
"xmlns:xlink": "xmlnsXlink"
|
|
2611
3843
|
};
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
3844
|
+
var camel = (name) => name.replace(/-([a-z])/gu, (_m, c) => c.toUpperCase());
|
|
3845
|
+
function styleOf(value) {
|
|
3846
|
+
const out = {};
|
|
3847
|
+
for (const declaration of value.split(";")) {
|
|
3848
|
+
const colon = declaration.indexOf(":");
|
|
3849
|
+
if (colon === -1) continue;
|
|
3850
|
+
const property = declaration.slice(0, colon).trim();
|
|
3851
|
+
const v = declaration.slice(colon + 1).trim();
|
|
3852
|
+
if (/^[a-z][a-z-]*$/u.test(property) && v !== "") out[camel(property)] = v;
|
|
3853
|
+
}
|
|
3854
|
+
return out;
|
|
3855
|
+
}
|
|
3856
|
+
var HYPHENATED = /* @__PURE__ */ new Set([
|
|
3857
|
+
"alignment-baseline",
|
|
3858
|
+
"baseline-shift",
|
|
3859
|
+
"clip-path",
|
|
3860
|
+
"clip-rule",
|
|
3861
|
+
"color-interpolation",
|
|
3862
|
+
"color-interpolation-filters",
|
|
3863
|
+
"dominant-baseline",
|
|
3864
|
+
"fill-opacity",
|
|
3865
|
+
"fill-rule",
|
|
3866
|
+
"flood-color",
|
|
3867
|
+
"flood-opacity",
|
|
3868
|
+
"font-family",
|
|
3869
|
+
"font-size",
|
|
3870
|
+
"font-size-adjust",
|
|
3871
|
+
"font-stretch",
|
|
3872
|
+
"font-style",
|
|
3873
|
+
"font-variant",
|
|
3874
|
+
"font-weight",
|
|
3875
|
+
"letter-spacing",
|
|
3876
|
+
"lighting-color",
|
|
3877
|
+
"marker-end",
|
|
3878
|
+
"marker-mid",
|
|
3879
|
+
"marker-start",
|
|
3880
|
+
"paint-order",
|
|
3881
|
+
"shape-rendering",
|
|
3882
|
+
"stop-color",
|
|
3883
|
+
"stop-opacity",
|
|
3884
|
+
"stroke-dasharray",
|
|
3885
|
+
"stroke-dashoffset",
|
|
3886
|
+
"stroke-linecap",
|
|
3887
|
+
"stroke-linejoin",
|
|
3888
|
+
"stroke-miterlimit",
|
|
3889
|
+
"stroke-opacity",
|
|
3890
|
+
"stroke-width",
|
|
3891
|
+
"text-anchor",
|
|
3892
|
+
"text-decoration",
|
|
3893
|
+
"text-rendering",
|
|
3894
|
+
"vector-effect",
|
|
3895
|
+
"word-spacing",
|
|
3896
|
+
"writing-mode"
|
|
3897
|
+
]);
|
|
3898
|
+
var DENIED_PROP = /^(?:children|key|ref|dangerously|innerhtml|outerhtml|suppress|on)/iu;
|
|
3899
|
+
function propName(name) {
|
|
3900
|
+
if (Object.hasOwn(SPECIAL, name)) return SPECIAL[name];
|
|
3901
|
+
if (/^(?:aria|data)-[a-z0-9-]{1,60}$/u.test(name)) return name;
|
|
3902
|
+
const prop = HYPHENATED.has(name) ? camel(name) : name;
|
|
3903
|
+
if (!/^[a-z][a-zA-Z0-9]*$/u.test(prop) || DENIED_PROP.test(prop)) return null;
|
|
3904
|
+
return prop;
|
|
3905
|
+
}
|
|
3906
|
+
function propsOf(element, key) {
|
|
3907
|
+
const props = { key };
|
|
3908
|
+
for (const [name, value] of element.attrs) {
|
|
3909
|
+
if (name === "style") {
|
|
3910
|
+
props.style = styleOf(value);
|
|
3911
|
+
continue;
|
|
3912
|
+
}
|
|
3913
|
+
const prop = propName(name);
|
|
3914
|
+
if (prop !== null) props[prop] = value;
|
|
3915
|
+
}
|
|
3916
|
+
return props;
|
|
3917
|
+
}
|
|
3918
|
+
var FRAGMENT = /^#[A-Za-z_][\w:.-]{0,99}$/u;
|
|
3919
|
+
function checkUrls(tag, props, mediaOrigin) {
|
|
3920
|
+
for (const key of ["href", "xlinkHref", "src"]) {
|
|
3921
|
+
if (!Object.hasOwn(props, key)) continue;
|
|
3922
|
+
const value = props[key];
|
|
3923
|
+
const safe = SVG.has(tag) ? typeof value === "string" && FRAGMENT.test(value) ? value : null : _builderschema.safeUrl.call(void 0, value, key === "src" ? "src" : "href", { mediaOrigin });
|
|
3924
|
+
if (safe !== null) {
|
|
3925
|
+
props[key] = safe;
|
|
3926
|
+
continue;
|
|
3927
|
+
}
|
|
3928
|
+
if (tag === "a" || tag === "img") return false;
|
|
3929
|
+
delete props[key];
|
|
3930
|
+
}
|
|
3931
|
+
return true;
|
|
3932
|
+
}
|
|
3933
|
+
function renderMarkup(nodes, options = {}) {
|
|
3934
|
+
return nodes.map((node, index) => {
|
|
3935
|
+
if (typeof node === "string") return node;
|
|
3936
|
+
const props = { ...propsOf(node, index), ..._nullishCoalesce(_optionalChain([options, 'access', _196 => _196.extra, 'optionalCall', _197 => _197(node)]), () => ( {})) };
|
|
3937
|
+
if (!checkUrls(node.tag, props, _nullishCoalesce(options.mediaOrigin, () => ( "")))) return null;
|
|
3938
|
+
if (VOID2.has(node.tag)) return _react.createElement.call(void 0, node.tag, props);
|
|
3939
|
+
return _react.createElement.call(void 0, node.tag, props, ...renderMarkup(node.children, options));
|
|
3940
|
+
});
|
|
3941
|
+
}
|
|
3942
|
+
function svgElement(svg) {
|
|
3943
|
+
const clean = _builderschema.sanitizeSvg.call(void 0, svg).svg;
|
|
3944
|
+
if (clean === "") return null;
|
|
3945
|
+
const root = parseMarkup(clean, "svg")[0];
|
|
3946
|
+
if (root === void 0 || typeof root === "string" || root.tag !== "svg") return null;
|
|
3947
|
+
const withFill = root.attrs.some(([name]) => name === "fill") ? root : { ...root, attrs: [...root.attrs, ["fill", "currentColor"]] };
|
|
3948
|
+
return _nullishCoalesce(renderMarkup([withFill])[0], () => ( null));
|
|
3949
|
+
}
|
|
3950
|
+
async function readSvg(response, mediaOrigin) {
|
|
3951
|
+
if (!response.ok || _builderschema.safeUrl.call(void 0, response.url, "src", { mediaOrigin }) === null) return null;
|
|
3952
|
+
if (!/^image\/svg\+xml(?:\s*;|$)/iu.test(_nullishCoalesce(response.headers.get("content-type"), () => ( "")))) return null;
|
|
3953
|
+
const reader = _optionalChain([response, 'access', _198 => _198.body, 'optionalAccess', _199 => _199.getReader, 'call', _200 => _200()]);
|
|
3954
|
+
if (reader === void 0) {
|
|
3955
|
+
const text3 = await response.text();
|
|
3956
|
+
return new TextEncoder().encode(text3).length > _builderschema.SVG_MAX_BYTES ? null : text3;
|
|
3957
|
+
}
|
|
3958
|
+
const decoder = new TextDecoder();
|
|
3959
|
+
let total = 0;
|
|
3960
|
+
let text2 = "";
|
|
3961
|
+
for (; ; ) {
|
|
3962
|
+
const { done, value } = await reader.read();
|
|
3963
|
+
if (done) return text2 + decoder.decode();
|
|
3964
|
+
total += value.length;
|
|
3965
|
+
if (total > _builderschema.SVG_MAX_BYTES) {
|
|
3966
|
+
await reader.cancel();
|
|
3967
|
+
return null;
|
|
3968
|
+
}
|
|
3969
|
+
text2 += decoder.decode(value, { stream: true });
|
|
3970
|
+
}
|
|
3971
|
+
}
|
|
3972
|
+
function SvgFromAsset({ asset, mediaOrigin, label }) {
|
|
3973
|
+
const src = isFrozenAsset(asset) ? _builderschema.safeUrl.call(void 0, asset.url, "src", { mediaOrigin }) : null;
|
|
3974
|
+
const [source, setSource] = _react.useState.call(void 0, null);
|
|
3975
|
+
_react.useEffect.call(void 0, () => {
|
|
3976
|
+
if (src === null) return;
|
|
3977
|
+
const controller = new AbortController();
|
|
3978
|
+
fetch(src, { credentials: "omit", redirect: "error", signal: controller.signal }).then((response) => readSvg(response, mediaOrigin)).then((text2) => {
|
|
3979
|
+
if (text2 !== null && !controller.signal.aborted) setSource(text2);
|
|
3980
|
+
}).catch(() => void 0);
|
|
3981
|
+
return () => controller.abort();
|
|
3982
|
+
}, [src]);
|
|
3983
|
+
if (src === null) return null;
|
|
3984
|
+
const inline2 = source === null ? null : svgElement(source);
|
|
3985
|
+
if (inline2 !== null) return inline2;
|
|
3986
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssetImage, { asset, mediaOrigin, alt: _nullishCoalesce(label, () => ( "")), loading: "eager" });
|
|
3987
|
+
}
|
|
3988
|
+
|
|
3989
|
+
// src/basics/v2/faq.tsx
|
|
3990
|
+
|
|
3991
|
+
function itemsOf(value) {
|
|
3992
|
+
if (!Array.isArray(value)) return [];
|
|
3993
|
+
return value.flatMap((row) => {
|
|
3994
|
+
if (!isRecord(row)) return [];
|
|
3995
|
+
const question = str(row.question);
|
|
3996
|
+
return question === void 0 ? [] : [{ question, answer: typeof row.answer === "string" ? row.answer : "" }];
|
|
3997
|
+
});
|
|
3998
|
+
}
|
|
3999
|
+
function faqJsonLdOn(settings) {
|
|
4000
|
+
if (!isRecord(settings) || !isRecord(settings.seo) || !isRecord(settings.seo.structuredData)) return false;
|
|
4001
|
+
return settings.seo.structuredData.faq === true;
|
|
4002
|
+
}
|
|
4003
|
+
function Faq({ props, mediaOrigin, editMode }) {
|
|
2617
4004
|
const builder = useBuilder();
|
|
2618
|
-
|
|
4005
|
+
const group = _react.useId.call(void 0, );
|
|
4006
|
+
const root = _react.useRef.call(void 0, null);
|
|
4007
|
+
const [all2, setAll] = _react.useState.call(void 0, false);
|
|
4008
|
+
const items = itemsOf(props.items);
|
|
4009
|
+
if (items.length === 0) {
|
|
4010
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4011
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4012
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "Add questions in the settings" })
|
|
4013
|
+
] });
|
|
4014
|
+
}
|
|
4015
|
+
const answers = items.map((item) => parseMarkup(_builderschema.sanitizeRichContent.call(void 0, item.answer, mediaOrigin).html, "rich"));
|
|
4016
|
+
const open = props.mode === "open";
|
|
4017
|
+
const oneOpen = props.oneOpen === true;
|
|
4018
|
+
const showAll = !open && props.expandAll === true && !oneOpen;
|
|
4019
|
+
const jsonLd = builder !== null && builder.site.status === "ok" && faqJsonLdOn(builder.site.settings) ? jsonLdString(faqJsonLd(items.map((item, index) => ({ question: item.question, answer: textOf2(_nullishCoalesce(answers[index], () => ( []))).trim() })))) : null;
|
|
4020
|
+
const toggleAll = () => {
|
|
4021
|
+
const next = !all2;
|
|
4022
|
+
for (const details of _nullishCoalesce(_optionalChain([root, 'access', _201 => _201.current, 'optionalAccess', _202 => _202.querySelectorAll, 'call', _203 => _203("details")]), () => ( []))) details.open = next;
|
|
4023
|
+
setAll(next);
|
|
4024
|
+
};
|
|
4025
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4026
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4027
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-b-faq", ref: root, children: [
|
|
4028
|
+
showAll && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-b-faq-all", "aria-expanded": all2, onClick: toggleAll, children: all2 ? "Collapse all" : "Expand all" }),
|
|
4029
|
+
items.map(
|
|
4030
|
+
(item, index) => open ? /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-b-faq-item", children: [
|
|
4031
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "h3", { className: "tb-b-faq-q", children: item.question }),
|
|
4032
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-faq-a", children: renderMarkup(_nullishCoalesce(answers[index], () => ( [])), { mediaOrigin }) })
|
|
4033
|
+
] }, `${String(index)}:${item.question}`) : /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "details", { className: "tb-b-faq-item", ...oneOpen ? { name: `faq-${group}` } : {}, children: [
|
|
4034
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "summary", { className: "tb-b-faq-q", children: item.question }),
|
|
4035
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-faq-a", children: renderMarkup(_nullishCoalesce(answers[index], () => ( [])), { mediaOrigin }) })
|
|
4036
|
+
] }, `${String(index)}:${item.question}`)
|
|
4037
|
+
),
|
|
4038
|
+
jsonLd !== null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "script", { type: "application/ld+json", children: jsonLd })
|
|
4039
|
+
] })
|
|
4040
|
+
] });
|
|
4041
|
+
}
|
|
4042
|
+
var faqWidgets = [{ ...mbDefinition("basic.faq"), Component: Faq }];
|
|
4043
|
+
|
|
4044
|
+
// src/basics/v2/heading-v2.tsx
|
|
4045
|
+
var headingV2Widgets = [{ ...mbDefinition("basic.heading"), Component: Heading }];
|
|
4046
|
+
|
|
4047
|
+
// src/basics/v2/icon-list.tsx
|
|
4048
|
+
|
|
4049
|
+
|
|
4050
|
+
var isIconName = (name) => typeof name === "string" && _ui.ICON_NAMES.includes(name);
|
|
4051
|
+
function IconList({ props, mediaOrigin, editMode }) {
|
|
4052
|
+
const rows = Array.isArray(props.items) ? props.items.flatMap((row) => isRecord(row) ? [row] : []) : [];
|
|
4053
|
+
if (rows.length === 0) {
|
|
4054
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4055
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4056
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "Add rows in the settings" })
|
|
4057
|
+
] });
|
|
4058
|
+
}
|
|
4059
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4060
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4061
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { className: "tb-b-icons", children: rows.map((row, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { children: [
|
|
4062
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-icons-icon", "aria-hidden": "true", children: isFrozenAsset(row.svgAsset) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgFromAsset, { asset: row.svgAsset, mediaOrigin }) : isIconName(row.icon) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _ui.Icon, { name: row.icon }) : null }),
|
|
4063
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-icons-text", children: _nullishCoalesce(str(row.text), () => ( "")) })
|
|
4064
|
+
] }, `${String(index)}:${_nullishCoalesce(str(row.text), () => ( ""))}`)) })
|
|
4065
|
+
] });
|
|
4066
|
+
}
|
|
4067
|
+
var iconListWidgets = [{ ...mbDefinition("basic.icon-list"), Component: IconList }];
|
|
4068
|
+
|
|
4069
|
+
// src/basics/v2/merge.ts
|
|
4070
|
+
function mergeV2Widgets(v1, v2) {
|
|
4071
|
+
const replacement = /* @__PURE__ */ new Map();
|
|
4072
|
+
for (const widget of v2) {
|
|
4073
|
+
if (replacement.has(widget.type)) throw new Error(`Two v2 widgets of type ${widget.type}`);
|
|
4074
|
+
replacement.set(widget.type, widget);
|
|
4075
|
+
}
|
|
4076
|
+
const v1Types = new Set(v1.map((widget) => widget.type));
|
|
4077
|
+
return [
|
|
4078
|
+
...v1.map((widget) => _nullishCoalesce(replacement.get(widget.type), () => ( widget))),
|
|
4079
|
+
...[...replacement.values()].filter((widget) => !v1Types.has(widget.type))
|
|
4080
|
+
];
|
|
4081
|
+
}
|
|
4082
|
+
|
|
4083
|
+
// src/basics/v2/quote.tsx
|
|
4084
|
+
|
|
4085
|
+
function Quote({ props, mediaOrigin, editMode, inlineEdit }) {
|
|
4086
|
+
const quote = _nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _204 => _204("quote")]), () => ( str(props.quote)));
|
|
4087
|
+
if (quote === void 0) {
|
|
4088
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4089
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4090
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "Write the quote in the settings" })
|
|
4091
|
+
] });
|
|
4092
|
+
}
|
|
4093
|
+
const name = str(props.name);
|
|
4094
|
+
const role = str(props.role);
|
|
4095
|
+
const image = isFrozenAsset(props.image) ? props.image : null;
|
|
4096
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4097
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4098
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "figure", { className: "tb-b-quote", children: [
|
|
4099
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "blockquote", { children: quote }),
|
|
4100
|
+
(name !== void 0 || role !== void 0 || image !== null) && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "figcaption", { children: [
|
|
4101
|
+
image !== null && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssetImage, { asset: image, mediaOrigin, alt: "", className: "tb-b-quote-photo" }),
|
|
4102
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "span", { className: "tb-b-quote-by", children: [
|
|
4103
|
+
name !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-quote-name", children: name }),
|
|
4104
|
+
role !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-quote-role", children: role })
|
|
4105
|
+
] })
|
|
4106
|
+
] })
|
|
4107
|
+
] })
|
|
4108
|
+
] });
|
|
4109
|
+
}
|
|
4110
|
+
var quoteWidgets = [{ ...mbDefinition("basic.quote"), Component: Quote }];
|
|
4111
|
+
|
|
4112
|
+
// src/basics/v2/rich-content.tsx
|
|
4113
|
+
|
|
4114
|
+
|
|
4115
|
+
var slug = (text2) => text2.toLowerCase().normalize("NFKD").replace(/[^a-z0-9]+/gu, "-").replace(/^-+|-+$/gu, "").slice(0, 40);
|
|
4116
|
+
function headings(nodes, nodeId) {
|
|
4117
|
+
const found = /* @__PURE__ */ new Map();
|
|
4118
|
+
const visit = (list2) => {
|
|
4119
|
+
for (const node of list2) {
|
|
4120
|
+
if (typeof node === "string") continue;
|
|
4121
|
+
if (node.tag === "h2" || node.tag === "h3") {
|
|
4122
|
+
const label = textOf2(node.children).replace(/\s+/gu, " ").trim();
|
|
4123
|
+
const n = found.size + 1;
|
|
4124
|
+
found.set(node, { id: `${nodeId}-${String(n)}${slug(label) === "" ? "" : `-${slug(label)}`}`, level: node.tag === "h2" ? 2 : 3, label });
|
|
4125
|
+
}
|
|
4126
|
+
visit(node.children);
|
|
4127
|
+
}
|
|
4128
|
+
};
|
|
4129
|
+
visit(nodes);
|
|
4130
|
+
return found;
|
|
4131
|
+
}
|
|
4132
|
+
function RichContent({ node, props, mediaOrigin, editMode }) {
|
|
4133
|
+
const html = str(props.html);
|
|
4134
|
+
if (html === void 0) {
|
|
4135
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4136
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4137
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "Add content in the settings" })
|
|
4138
|
+
] });
|
|
4139
|
+
}
|
|
4140
|
+
const tree = parseMarkup(_builderschema.sanitizeRichContent.call(void 0, html, mediaOrigin).html, "rich");
|
|
4141
|
+
const entries = headings(tree, node.id);
|
|
4142
|
+
const toc = props.toc === true ? [...entries.values()].filter((e) => e.label !== "") : [];
|
|
4143
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4144
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4145
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-b-rich", children: [
|
|
4146
|
+
toc.length > 0 && /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "nav", { className: "tb-b-toc", "aria-label": _nullishCoalesce(str(props.tocTitle), () => ( "Contents")), children: [
|
|
4147
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "tb-b-toc-title", children: _nullishCoalesce(str(props.tocTitle), () => ( "Contents")) }),
|
|
4148
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ol", { children: toc.map((entry) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "li", { className: `tb-b-toc-l${String(entry.level)}`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href: `#${entry.id}`, children: entry.label }) }, entry.id)) })
|
|
4149
|
+
] }),
|
|
4150
|
+
renderMarkup(tree, {
|
|
4151
|
+
mediaOrigin,
|
|
4152
|
+
extra: (element) => {
|
|
4153
|
+
const entry = entries.get(element);
|
|
4154
|
+
return entry === void 0 ? void 0 : { id: entry.id };
|
|
4155
|
+
}
|
|
4156
|
+
})
|
|
4157
|
+
] })
|
|
4158
|
+
] });
|
|
4159
|
+
}
|
|
4160
|
+
var richContentWidgets = [{ ...mbDefinition("basic.rich-content"), Component: RichContent }];
|
|
4161
|
+
|
|
4162
|
+
// src/basics/v2/svg.tsx
|
|
4163
|
+
|
|
4164
|
+
function Svg({ props, mediaOrigin, editMode }) {
|
|
4165
|
+
const pasted = str(props.svg);
|
|
4166
|
+
const label = str(props.label);
|
|
4167
|
+
const inline2 = pasted === void 0 ? null : svgElement(pasted);
|
|
4168
|
+
const asset = pasted === void 0 && props.asset !== null && props.asset !== void 0 ? props.asset : null;
|
|
4169
|
+
if (inline2 === null && asset === null) {
|
|
4170
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4171
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4172
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "Paste an SVG or pick one from the media library" })
|
|
4173
|
+
] });
|
|
4174
|
+
}
|
|
4175
|
+
const decorative = props.decorative !== false;
|
|
4176
|
+
const access = decorative ? { "aria-hidden": true } : label === void 0 ? {} : { role: "img", "aria-label": label };
|
|
4177
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
4178
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicV2Styles, {}),
|
|
4179
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-svg", ...access, children: _nullishCoalesce(inline2, () => ( /* @__PURE__ */ _jsxruntime.jsx.call(void 0, SvgFromAsset, { asset, mediaOrigin, ...label === void 0 || decorative ? {} : { label } }))) })
|
|
4180
|
+
] });
|
|
2619
4181
|
}
|
|
4182
|
+
var svgWidgets = [{ ...mbDefinition("basic.svg"), Component: Svg }];
|
|
4183
|
+
|
|
4184
|
+
// src/basics/index.ts
|
|
4185
|
+
var BASIC_COMPONENTS = {
|
|
4186
|
+
"basic.heading": Heading,
|
|
4187
|
+
"basic.text": Text,
|
|
4188
|
+
"basic.image": Image,
|
|
4189
|
+
"basic.button": Button,
|
|
4190
|
+
"basic.spacer": Spacer,
|
|
4191
|
+
"basic.divider": Divider,
|
|
4192
|
+
"basic.video": Video,
|
|
4193
|
+
"basic.logo": Logo,
|
|
4194
|
+
"basic.menu": Menu,
|
|
4195
|
+
"basic.announcement": Announcement,
|
|
4196
|
+
"basic.copyright": Copyright,
|
|
4197
|
+
"basic.countdown": Countdown
|
|
4198
|
+
};
|
|
4199
|
+
var v1Widgets = _builderschema.BASIC_WIDGET_DEFINITIONS.flatMap(
|
|
4200
|
+
(definition3) => definition3.v === 1 && Object.hasOwn(BASIC_COMPONENTS, definition3.type) ? [{ ...definition3, Component: BASIC_COMPONENTS[definition3.type] }] : []
|
|
4201
|
+
);
|
|
4202
|
+
var widgets = mergeV2Widgets(v1Widgets, [
|
|
4203
|
+
...faqWidgets,
|
|
4204
|
+
...richContentWidgets,
|
|
4205
|
+
...breadcrumbsWidgets,
|
|
4206
|
+
...svgWidgets,
|
|
4207
|
+
...iconListWidgets,
|
|
4208
|
+
...quoteWidgets,
|
|
4209
|
+
...menuV2Widgets,
|
|
4210
|
+
...announcementV2Widgets,
|
|
4211
|
+
...headingV2Widgets
|
|
4212
|
+
]);
|
|
4213
|
+
var basicPack = { id: "basic", version: "0.0.0", widgets, dataSources: [] };
|
|
4214
|
+
|
|
4215
|
+
// src/custom/factory.ts
|
|
4216
|
+
|
|
2620
4217
|
|
|
2621
4218
|
// src/custom/composite-widget.tsx
|
|
2622
4219
|
|
|
4220
|
+
|
|
4221
|
+
|
|
2623
4222
|
var SETTING_KEY_RE = /^[a-z][A-Za-z0-9]{0,39}$/;
|
|
2624
4223
|
var NODE_ID_RE = /^[a-z0-9]{8,24}$/;
|
|
2625
4224
|
var WRAP = { section: "zzcompsec001", column: "zzcompcol001", inner: "zzcompinr001" };
|
|
2626
|
-
var
|
|
4225
|
+
var isRecord6 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2627
4226
|
var compiled3 = /* @__PURE__ */ new WeakMap();
|
|
2628
4227
|
function parseBody(raw) {
|
|
2629
|
-
if (!
|
|
4228
|
+
if (!isRecord6(raw)) return null;
|
|
2630
4229
|
const columns = Array.isArray(raw.columns) ? raw.columns : void 0;
|
|
2631
4230
|
const stack = Array.isArray(raw.stack) ? raw.stack : void 0;
|
|
2632
4231
|
if (columns === void 0 === (stack === void 0)) return null;
|
|
2633
4232
|
const children = columns !== void 0 ? [{ id: WRAP.inner, type: "inner-section", props: {}, columns }] : _nullishCoalesce(stack, () => ( []));
|
|
2634
|
-
if (_optionalChain([stack, 'optionalAccess',
|
|
4233
|
+
if (_optionalChain([stack, 'optionalAccess', _205 => _205.some, 'call', _206 => _206((node) => isRecord6(node) && node.type === "inner-section")])) return null;
|
|
2635
4234
|
const parsed2 = _builderschema.pageDocumentSchema.safeParse({
|
|
2636
4235
|
schemaVersion: 1,
|
|
2637
4236
|
sections: [{ id: WRAP.section, type: "section", props: {}, columns: [{ id: WRAP.column, type: "column", props: { width: 100 }, children }] }]
|
|
2638
4237
|
});
|
|
2639
4238
|
if (!parsed2.success) return null;
|
|
2640
4239
|
const wrapper = parsed2.data.sections[0];
|
|
2641
|
-
const first = _nullishCoalesce((_optionalChain([wrapper, 'optionalAccess',
|
|
4240
|
+
const first = _nullishCoalesce((_optionalChain([wrapper, 'optionalAccess', _207 => _207.type]) === "section" ? _optionalChain([wrapper, 'access', _208 => _208.columns, 'access', _209 => _209[0], 'optionalAccess', _210 => _210.children]) : void 0), () => ( []));
|
|
2642
4241
|
if (columns !== void 0) {
|
|
2643
4242
|
const inner = first[0];
|
|
2644
|
-
return _optionalChain([inner, 'optionalAccess',
|
|
4243
|
+
return _optionalChain([inner, 'optionalAccess', _211 => _211.type]) === "inner-section" ? { columns: inner.columns } : null;
|
|
2645
4244
|
}
|
|
2646
4245
|
return { stack: first.filter((node) => node.type !== "inner-section") };
|
|
2647
4246
|
}
|
|
@@ -2664,38 +4263,38 @@ function compile2(snapshot) {
|
|
|
2664
4263
|
const bindings = [];
|
|
2665
4264
|
if (extra.bindings !== void 0 && !Array.isArray(extra.bindings)) return refuse("bindings is not a list");
|
|
2666
4265
|
for (const raw of _nullishCoalesce(extra.bindings, () => ( []))) {
|
|
2667
|
-
if (!
|
|
4266
|
+
if (!isRecord6(raw) || typeof raw.setting !== "string" || !SETTING_KEY_RE.test(raw.setting) || !Array.isArray(raw.targets)) {
|
|
2668
4267
|
return refuse("a binding is malformed");
|
|
2669
4268
|
}
|
|
2670
4269
|
const targets = [];
|
|
2671
|
-
for (const
|
|
2672
|
-
if (!
|
|
4270
|
+
for (const target2 of raw.targets) {
|
|
4271
|
+
if (!isRecord6(target2) || typeof target2.node !== "string" || !NODE_ID_RE.test(target2.node) || typeof target2.prop !== "string" || !SETTING_KEY_RE.test(target2.prop)) {
|
|
2673
4272
|
return refuse("a binding target is malformed");
|
|
2674
4273
|
}
|
|
2675
|
-
targets.push({ node:
|
|
4274
|
+
targets.push({ node: target2.node, prop: target2.prop });
|
|
2676
4275
|
}
|
|
2677
4276
|
bindings.push({ setting: raw.setting, targets });
|
|
2678
4277
|
}
|
|
2679
4278
|
const data = [];
|
|
2680
|
-
if (extra.data !== void 0 && !
|
|
4279
|
+
if (extra.data !== void 0 && !isRecord6(extra.data)) return refuse("data is not a record");
|
|
2681
4280
|
for (const [name, raw] of Object.entries(_nullishCoalesce(extra.data, () => ( {})))) {
|
|
2682
|
-
if (!SETTING_KEY_RE.test(name) || !
|
|
4281
|
+
if (!SETTING_KEY_RE.test(name) || !isRecord6(raw) || !Array.isArray(raw.targets)) return refuse("a data input is malformed");
|
|
2683
4282
|
const targets = [];
|
|
2684
|
-
for (const
|
|
2685
|
-
if (!
|
|
4283
|
+
for (const target2 of raw.targets) {
|
|
4284
|
+
if (!isRecord6(target2) || typeof target2.node !== "string" || !NODE_ID_RE.test(target2.node) || typeof target2.input !== "string" || !SETTING_KEY_RE.test(target2.input)) {
|
|
2686
4285
|
return refuse("a data target is malformed");
|
|
2687
4286
|
}
|
|
2688
|
-
targets.push({ node:
|
|
4287
|
+
targets.push({ node: target2.node, input: target2.input });
|
|
2689
4288
|
}
|
|
2690
4289
|
data.push([name, { targets }]);
|
|
2691
4290
|
}
|
|
2692
4291
|
return { body, bindings, data };
|
|
2693
4292
|
}
|
|
2694
|
-
var
|
|
4293
|
+
var DEVICES6 = ["tablet", "phone"];
|
|
2695
4294
|
function withoutAnchor(node) {
|
|
2696
4295
|
delete node.props.anchor;
|
|
2697
4296
|
const responsive = node.responsive;
|
|
2698
|
-
for (const device of
|
|
4297
|
+
for (const device of DEVICES6) if (_optionalChain([responsive, 'optionalAccess', _212 => _212[device]]) !== void 0) delete responsive[device].anchor;
|
|
2699
4298
|
}
|
|
2700
4299
|
function instanceId(outer, inner) {
|
|
2701
4300
|
let a = 3735928559;
|
|
@@ -2709,15 +4308,15 @@ function instanceId(outer, inner) {
|
|
|
2709
4308
|
b = Math.imul(b ^ b >>> 16, 2246822507) ^ Math.imul(a ^ a >>> 13, 3266489909);
|
|
2710
4309
|
return `i${(a >>> 0).toString(36).padStart(7, "0")}${(b >>> 0).toString(36).padStart(7, "0")}${(outer.length + inner.length).toString(36)}`;
|
|
2711
4310
|
}
|
|
2712
|
-
function
|
|
4311
|
+
function build2(input) {
|
|
2713
4312
|
const { snapshot, registry, node: outer, props, data } = input;
|
|
2714
4313
|
const body = structuredClone(input.compiled.body);
|
|
2715
4314
|
const assets = {};
|
|
2716
4315
|
const hrefs = /* @__PURE__ */ new Map();
|
|
2717
4316
|
const innerData = {};
|
|
2718
|
-
const keep = (child) => _optionalChain([registry, 'access',
|
|
2719
|
-
const columns = _optionalChain([body, 'access',
|
|
2720
|
-
const stack = _optionalChain([body, 'access',
|
|
4317
|
+
const keep = (child) => _optionalChain([registry, 'access', _213 => _213.widget, 'call', _214 => _214(child.type, child.v), 'optionalAccess', _215 => _215.kind]) !== "composite";
|
|
4318
|
+
const columns = _optionalChain([body, 'access', _216 => _216.columns, 'optionalAccess', _217 => _217.map, 'call', _218 => _218((column2) => ({ ...column2, children: column2.children.filter(keep) }))]);
|
|
4319
|
+
const stack = _optionalChain([body, 'access', _219 => _219.stack, 'optionalAccess', _220 => _220.filter, 'call', _221 => _221(keep)]);
|
|
2721
4320
|
const widgets2 = columns !== void 0 ? columns.flatMap((column2) => column2.children) : _nullishCoalesce(stack, () => ( []));
|
|
2722
4321
|
for (const widget of widgets2) {
|
|
2723
4322
|
withoutAnchor(widget);
|
|
@@ -2738,11 +4337,11 @@ function build(input) {
|
|
|
2738
4337
|
return id;
|
|
2739
4338
|
}
|
|
2740
4339
|
if (field.control === "link") {
|
|
2741
|
-
if (!
|
|
2742
|
-
const { href, ...
|
|
2743
|
-
if (
|
|
2744
|
-
hrefs.set(JSON.stringify(
|
|
2745
|
-
return
|
|
4340
|
+
if (!isRecord6(value) || typeof value.kind !== "string") return null;
|
|
4341
|
+
const { href, ...target2 } = value;
|
|
4342
|
+
if (target2.kind === "url") return typeof href === "string" ? { kind: "url", href } : null;
|
|
4343
|
+
hrefs.set(JSON.stringify(target2), typeof href === "string" ? href : null);
|
|
4344
|
+
return target2;
|
|
2746
4345
|
}
|
|
2747
4346
|
return value;
|
|
2748
4347
|
};
|
|
@@ -2750,21 +4349,21 @@ function build(input) {
|
|
|
2750
4349
|
const field = fields.get(binding.setting);
|
|
2751
4350
|
if (field === void 0 || !Object.hasOwn(props, binding.setting)) continue;
|
|
2752
4351
|
const value = props[binding.setting];
|
|
2753
|
-
for (const
|
|
2754
|
-
const inner = byId.get(
|
|
2755
|
-
const innerField = inner === void 0 ? void 0 : _optionalChain([registry, 'access',
|
|
4352
|
+
for (const target2 of binding.targets) {
|
|
4353
|
+
const inner = byId.get(target2.node);
|
|
4354
|
+
const innerField = inner === void 0 ? void 0 : _optionalChain([registry, 'access', _222 => _222.widget, 'call', _223 => _223(inner.type, inner.v), 'optionalAccess', _224 => _224.settings, 'access', _225 => _225.find, 'call', _226 => _226((f) => f.key === target2.prop)]);
|
|
2756
4355
|
if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
|
|
2757
4356
|
const converted = convert(field, value);
|
|
2758
4357
|
if (_builderschema.validateSettingValue.call(void 0, innerField, converted) !== null) continue;
|
|
2759
|
-
inner.props[
|
|
4358
|
+
inner.props[target2.prop] = converted;
|
|
2760
4359
|
const responsive = inner.responsive;
|
|
2761
|
-
for (const device of
|
|
2762
|
-
if (_optionalChain([responsive, 'optionalAccess',
|
|
2763
|
-
const raw = _optionalChain([outer, 'access',
|
|
4360
|
+
for (const device of DEVICES6) {
|
|
4361
|
+
if (_optionalChain([responsive, 'optionalAccess', _227 => _227[device]]) !== void 0) delete responsive[device][target2.prop];
|
|
4362
|
+
const raw = _optionalChain([outer, 'access', _228 => _228.responsive, 'optionalAccess', _229 => _229[device]]);
|
|
2764
4363
|
const plain = field.output === "css" && field.translatable !== true && field.control !== "image" && field.control !== "link";
|
|
2765
4364
|
if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && _builderschema.validateSettingValue.call(void 0, innerField, raw[binding.setting]) === null) {
|
|
2766
4365
|
const target$ = _nullishCoalesce(inner.responsive, () => ( (inner.responsive = {})));
|
|
2767
|
-
(_nullishCoalesce(target$[device], () => ( (target$[device] = {}))))[
|
|
4366
|
+
(_nullishCoalesce(target$[device], () => ( (target$[device] = {}))))[target2.prop] = raw[binding.setting];
|
|
2768
4367
|
}
|
|
2769
4368
|
}
|
|
2770
4369
|
}
|
|
@@ -2772,11 +4371,11 @@ function build(input) {
|
|
|
2772
4371
|
for (const [name, input$] of input.compiled.data) {
|
|
2773
4372
|
if (!Object.hasOwn(data, name) || data[name] === void 0) continue;
|
|
2774
4373
|
const key = `composite.${name}`;
|
|
2775
|
-
for (const
|
|
2776
|
-
const inner = byId.get(
|
|
4374
|
+
for (const target2 of input$.targets) {
|
|
4375
|
+
const inner = byId.get(target2.node);
|
|
2777
4376
|
const def = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v);
|
|
2778
|
-
if (inner === void 0 || _optionalChain([def, 'optionalAccess',
|
|
2779
|
-
inner.data = { ..._nullishCoalesce(inner.data, () => ( {})), [
|
|
4377
|
+
if (inner === void 0 || _optionalChain([def, 'optionalAccess', _230 => _230.data]) === void 0 || !Object.hasOwn(def.data, target2.input)) continue;
|
|
4378
|
+
inner.data = { ..._nullishCoalesce(inner.data, () => ( {})), [target2.input]: { source: key } };
|
|
2780
4379
|
innerData[key] = data[name];
|
|
2781
4380
|
}
|
|
2782
4381
|
}
|
|
@@ -2793,7 +4392,7 @@ function build(input) {
|
|
|
2793
4392
|
schemaVersion: 1,
|
|
2794
4393
|
sections: [{ id: ids.section, type: "section", props: { width: "full" }, columns: [column] }]
|
|
2795
4394
|
};
|
|
2796
|
-
let weight = 2 + (_nullishCoalesce(_optionalChain([columns, 'optionalAccess',
|
|
4395
|
+
let weight = 2 + (_nullishCoalesce(_optionalChain([columns, 'optionalAccess', _231 => _231.length]), () => ( 0))) + (columns === void 0 ? 0 : 1);
|
|
2797
4396
|
for (const widget of widgets2) {
|
|
2798
4397
|
const component = registry.component(widget);
|
|
2799
4398
|
weight += 1 + (component === void 0 ? 0 : _nullishCoalesce(componentWeights.get(component), () => ( 0)));
|
|
@@ -2804,7 +4403,7 @@ function CompositeBody(props) {
|
|
|
2804
4403
|
const { snapshot, registry, node, data, locale, mediaOrigin, budget, resolveLink, interactive, idScope } = props;
|
|
2805
4404
|
const composite = compileComposite(snapshot);
|
|
2806
4405
|
if (composite === null) return null;
|
|
2807
|
-
const built =
|
|
4406
|
+
const built = build2({ snapshot, compiled: composite, registry, node, props: props.props, data });
|
|
2808
4407
|
if (!(_nullishCoalesce(budget, () => ( new RenderBudget()))).take(built.weight)) {
|
|
2809
4408
|
warnOnce(`composite-weight:${snapshot.type}@${String(snapshot.v)}`, `${snapshot.type} would render too many nodes; rendering nothing for it`);
|
|
2810
4409
|
return null;
|
|
@@ -2820,7 +4419,7 @@ function CompositeBody(props) {
|
|
|
2820
4419
|
mediaOrigin,
|
|
2821
4420
|
interactive,
|
|
2822
4421
|
idScope,
|
|
2823
|
-
resolveLink: (
|
|
4422
|
+
resolveLink: (target2) => _nullishCoalesce(_nullishCoalesce(built.hrefs.get(JSON.stringify(target2)), () => ( _optionalChain([resolveLink, 'optionalCall', _232 => _232(target2)]))), () => ( null))
|
|
2824
4423
|
}
|
|
2825
4424
|
);
|
|
2826
4425
|
}
|
|
@@ -2855,11 +4454,11 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
2855
4454
|
const sources = [];
|
|
2856
4455
|
const resolvers = /* @__PURE__ */ new Map();
|
|
2857
4456
|
for (const pack of all2) {
|
|
2858
|
-
for (const { Component: Component2, ...
|
|
2859
|
-
const key = customKey(
|
|
4457
|
+
for (const { Component: Component2, ...definition3 } of pack.widgets) {
|
|
4458
|
+
const key = customKey(definition3.type, definition3.v);
|
|
2860
4459
|
if (components.has(key)) continue;
|
|
2861
4460
|
components.set(key, Component2);
|
|
2862
|
-
definitions.push(
|
|
4461
|
+
definitions.push(definition3);
|
|
2863
4462
|
}
|
|
2864
4463
|
for (const { resolve, ...descriptor } of pack.dataSources) {
|
|
2865
4464
|
if (resolvers.has(descriptor.id)) continue;
|
|
@@ -2868,7 +4467,7 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
2868
4467
|
}
|
|
2869
4468
|
}
|
|
2870
4469
|
const factory = _nullishCoalesce(options.customWidget, () => ( DEFAULT_CUSTOM_WIDGET));
|
|
2871
|
-
const
|
|
4470
|
+
const build3 = (custom) => {
|
|
2872
4471
|
const schema = _builderschema.createRegistry.call(void 0, definitions, sources, custom);
|
|
2873
4472
|
const snapshots = new Map(custom.map((snapshot) => [customKey(snapshot.type, snapshot.v), snapshot]));
|
|
2874
4473
|
const built = /* @__PURE__ */ new Map();
|
|
@@ -2889,49 +4488,102 @@ function createRendererRegistry(packs, options = {}) {
|
|
|
2889
4488
|
if (!built.has(key)) built.set(key, factory(snapshot, registry));
|
|
2890
4489
|
return _nullishCoalesce(built.get(key), () => ( void 0));
|
|
2891
4490
|
},
|
|
2892
|
-
withCustom: (more) =>
|
|
4491
|
+
withCustom: (more) => build3([...custom, ...more])
|
|
2893
4492
|
};
|
|
2894
4493
|
return registry;
|
|
2895
4494
|
};
|
|
2896
|
-
return
|
|
4495
|
+
return build3([]);
|
|
2897
4496
|
}
|
|
2898
4497
|
|
|
2899
4498
|
// src/server/load-page.ts
|
|
2900
4499
|
|
|
4500
|
+
var isOwnPath = (path) => typeof path === "string" && path !== "/" && path.startsWith("/") && !path.startsWith("/pages/");
|
|
4501
|
+
async function loadBuilderPageByPath(options) {
|
|
4502
|
+
const { path, locale } = options;
|
|
4503
|
+
const client = clientOf(options);
|
|
4504
|
+
if (client.pages.getByPath !== void 0) {
|
|
4505
|
+
const found = await client.pages.getByPath(path, { locale });
|
|
4506
|
+
if (isRedirect(found)) return { kind: "redirect", redirectTo: found.redirectTo };
|
|
4507
|
+
return loadBuilderPage({ ...options, slug: found.slug });
|
|
4508
|
+
}
|
|
4509
|
+
const summaries = await client.pages.list();
|
|
4510
|
+
const summary = summaries.find((entry) => entry.path === path && isOwnPath(entry.path));
|
|
4511
|
+
if (summary !== void 0) return loadBuilderPage({ ...options, slug: summary.slug });
|
|
4512
|
+
const bySlug = summaries.find((entry) => `/${entry.slug}` === path);
|
|
4513
|
+
if (bySlug !== void 0 && isOwnPath(bySlug.path) && bySlug.path !== path)
|
|
4514
|
+
return { kind: "redirect", redirectTo: bySlug.path };
|
|
4515
|
+
throw new (0, _builder.BuilderNotFoundError)(path);
|
|
4516
|
+
}
|
|
4517
|
+
async function loadOwnPagePaths(options) {
|
|
4518
|
+
return (await clientOf(options).pages.list()).map((entry) => entry.path).filter(isOwnPath);
|
|
4519
|
+
}
|
|
2901
4520
|
async function loadBuilderPage(options) {
|
|
2902
|
-
const { slug, locale, packs = [], slots, currency } = options;
|
|
2903
|
-
const bundle = await getBundle({ client: clientOf(options), locale, page:
|
|
4521
|
+
const { slug: slug2, locale, packs = [], slots, currency } = options;
|
|
4522
|
+
const bundle = await getBundle({ client: clientOf(options), locale, page: slug2, slots });
|
|
2904
4523
|
const found = bundle.page;
|
|
2905
|
-
if (found === void 0) throw new (0, _builder.BuilderNotFoundError)(
|
|
4524
|
+
if (found === void 0) throw new (0, _builder.BuilderNotFoundError)(slug2);
|
|
2906
4525
|
if (isRedirect(found)) return { kind: "redirect", redirectTo: found.redirectTo };
|
|
2907
4526
|
const shared = { ...found, savedSections: _nullishCoalesce(found.savedSections, () => ( bundle.savedSections)), code: _nullishCoalesce(found.code, () => ( bundle.code)) };
|
|
2908
4527
|
const data = await staticDataFor([shared], createRendererRegistry(packs), locale, currency);
|
|
2909
4528
|
return pageOf(shared, data);
|
|
2910
4529
|
}
|
|
2911
4530
|
|
|
4531
|
+
// src/server/load-template.ts
|
|
4532
|
+
function templateRootOf(packs, name) {
|
|
4533
|
+
for (const pack of _nullishCoalesce(packs, () => ( []))) {
|
|
4534
|
+
const found = _optionalChain([pack, 'access', _233 => _233.templates, 'optionalAccess', _234 => _234.find, 'call', _235 => _235((entry) => entry.name === name)]);
|
|
4535
|
+
if (found !== void 0) return found.Root;
|
|
4536
|
+
}
|
|
4537
|
+
return void 0;
|
|
4538
|
+
}
|
|
4539
|
+
async function loadBuilderTemplate(options) {
|
|
4540
|
+
const { name, locale, packs = [], currency, shared } = options;
|
|
4541
|
+
const answer = await clientOf(options).getTemplate(name, { locale });
|
|
4542
|
+
const document2 = answer.customWidgets === void 0 ? answer.document : {
|
|
4543
|
+
...answer.document,
|
|
4544
|
+
customWidgets: { ...answer.customWidgets, ...answer.document.customWidgets }
|
|
4545
|
+
};
|
|
4546
|
+
const loaded = { ...answer, generation: _nullishCoalesce(answer.generation, () => ( 0)), document: document2 };
|
|
4547
|
+
const data = await staticDataFor([loaded], createRendererRegistry(packs), locale, currency);
|
|
4548
|
+
return { part: partOf(loaded, data, shared), meta: answer.meta };
|
|
4549
|
+
}
|
|
4550
|
+
|
|
2912
4551
|
// src/next/seo.ts
|
|
2913
4552
|
|
|
2914
|
-
var
|
|
4553
|
+
var isRec2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2915
4554
|
var text = (value) => typeof value === "string" && value.trim() !== "" ? value : void 0;
|
|
2916
4555
|
var ORIGIN_RE = /^https?:\/\/[^\s/\\]+$/iu;
|
|
2917
4556
|
var DEFAULT_PAGE_ROUTE = "/pages/{handle}";
|
|
2918
4557
|
var LOCALE_SEGMENT_RE = /^[A-Za-z0-9-]+$/u;
|
|
2919
4558
|
function pageSeoOf(page) {
|
|
2920
|
-
const seo =
|
|
4559
|
+
const seo = isRec2(page.seo) ? page.seo : {};
|
|
2921
4560
|
const title = text(seo.title);
|
|
2922
4561
|
const description = text(seo.description);
|
|
4562
|
+
const canonical = text(seo.canonical);
|
|
2923
4563
|
return {
|
|
2924
4564
|
...title === void 0 ? {} : { title },
|
|
2925
4565
|
...description === void 0 ? {} : { description },
|
|
4566
|
+
...canonical === void 0 ? {} : { canonical },
|
|
2926
4567
|
shareImage: seo.shareImage,
|
|
2927
4568
|
noindex: seo.noindex === true
|
|
2928
4569
|
};
|
|
2929
4570
|
}
|
|
4571
|
+
function canonicalOverrideOf(value) {
|
|
4572
|
+
return value !== void 0 && /^https?:\/\/[^\s\\]+$/iu.test(value) ? value : void 0;
|
|
4573
|
+
}
|
|
4574
|
+
function canonicalFor(url, kind) {
|
|
4575
|
+
const parsed2 = new URL(url);
|
|
4576
|
+
const page = kind === "listing" ? parsed2.searchParams.get("page") : null;
|
|
4577
|
+
parsed2.hash = "";
|
|
4578
|
+
parsed2.search = "";
|
|
4579
|
+
if (page !== null && /^\d{1,6}$/u.test(page)) parsed2.searchParams.set("page", page);
|
|
4580
|
+
return parsed2.toString();
|
|
4581
|
+
}
|
|
2930
4582
|
function imageOf(value, mediaOrigin) {
|
|
2931
|
-
const raw =
|
|
4583
|
+
const raw = isRec2(value) ? value.url : value;
|
|
2932
4584
|
const url = _builderschema.safeUrl.call(void 0, raw, "src", { mediaOrigin });
|
|
2933
4585
|
if (url === null) return void 0;
|
|
2934
|
-
const frozen =
|
|
4586
|
+
const frozen = isRec2(value) ? value : {};
|
|
2935
4587
|
return {
|
|
2936
4588
|
url,
|
|
2937
4589
|
...typeof frozen.width === "number" ? { width: frozen.width } : {},
|
|
@@ -2939,51 +4591,113 @@ function imageOf(value, mediaOrigin) {
|
|
|
2939
4591
|
};
|
|
2940
4592
|
}
|
|
2941
4593
|
function pagePathOf(settings, page, resolve) {
|
|
2942
|
-
const routes =
|
|
4594
|
+
const routes = isRec2(settings.routes) ? settings.routes : {};
|
|
2943
4595
|
const pattern = _nullishCoalesce(text(routes.page), () => ( DEFAULT_PAGE_ROUTE));
|
|
2944
|
-
const
|
|
4596
|
+
const own = page.path !== void 0 && page.path !== "/" && !page.path.startsWith("/pages/") ? _builderschema.safeUrl.call(void 0, page.path, "href", { mediaOrigin: "" }) : null;
|
|
4597
|
+
const path = _nullishCoalesce(own, () => ( _builderschema.safeUrl.call(void 0, pattern.replaceAll("{handle}", () => page.slug), "href", { mediaOrigin: "" })));
|
|
2945
4598
|
if (path === null || resolve === void 0) return path;
|
|
2946
4599
|
return _nullishCoalesce(_builderschema.safeUrl.call(void 0, resolve({ ...page, path }), "href", { mediaOrigin: "" }), () => ( path));
|
|
2947
4600
|
}
|
|
2948
4601
|
function originOf(storeUrl) {
|
|
2949
|
-
const origin = _optionalChain([storeUrl, 'optionalAccess',
|
|
4602
|
+
const origin = _optionalChain([storeUrl, 'optionalAccess', _236 => _236.replace, 'call', _237 => _237(/\/+$/u, "")]);
|
|
2950
4603
|
return origin !== void 0 && ORIGIN_RE.test(origin) ? origin : void 0;
|
|
2951
4604
|
}
|
|
2952
4605
|
function siteLocales(settings) {
|
|
2953
|
-
const locales =
|
|
2954
|
-
const
|
|
2955
|
-
return { list, fallback: typeof locales.default === "string" &&
|
|
4606
|
+
const locales = isRec2(settings.locales) ? settings.locales : {};
|
|
4607
|
+
const list2 = Array.isArray(locales.list) ? locales.list.filter((locale) => typeof locale === "string" && LOCALE_SEGMENT_RE.test(locale)) : [];
|
|
4608
|
+
return { list: list2, fallback: typeof locales.default === "string" && list2.includes(locales.default) ? locales.default : void 0 };
|
|
4609
|
+
}
|
|
4610
|
+
var localized2 = (path, locale) => locale === void 0 ? path : path === "/" ? `/${locale}` : `/${locale}${path}`;
|
|
4611
|
+
var LISTING_TEMPLATES = ["shop", "collection", "category", "tag"];
|
|
4612
|
+
var DEFAULT_TITLE = {
|
|
4613
|
+
product: "{product.title} \u2013 {store}",
|
|
4614
|
+
shop: "{listing.title} \u2013 {store}",
|
|
4615
|
+
collection: "{listing.title} \u2013 {store}",
|
|
4616
|
+
category: "{listing.title} \u2013 {store}",
|
|
4617
|
+
tag: "{listing.title} \u2013 {store}"
|
|
4618
|
+
};
|
|
4619
|
+
var titleOf = (value) => isRec2(value) ? _nullishCoalesce(text(value.title), () => ( "")) : "";
|
|
4620
|
+
function localizedOf(value) {
|
|
4621
|
+
if (typeof value === "string") return text(value);
|
|
4622
|
+
if (!isRec2(value)) return void 0;
|
|
4623
|
+
return _nullishCoalesce(text(value.en), () => ( Object.values(value).map(text).find((entry) => entry !== void 0)));
|
|
4624
|
+
}
|
|
4625
|
+
function templateMetadataOf(name, input) {
|
|
4626
|
+
const { settings, context } = input;
|
|
4627
|
+
const site = isRec2(settings.seo) ? settings.seo : {};
|
|
4628
|
+
const brand = isRec2(settings.brand) ? settings.brand : {};
|
|
4629
|
+
const store = _nullishCoalesce(text(brand.storeName), () => ( ""));
|
|
4630
|
+
const query = _optionalChain([context, 'optionalAccess', _238 => _238.route, 'optionalAccess', _239 => _239.query, 'optionalAccess', _240 => _240.q]);
|
|
4631
|
+
const tokens = {
|
|
4632
|
+
"{product.title}": titleOf(_optionalChain([context, 'optionalAccess', _241 => _241.product])),
|
|
4633
|
+
"{listing.title}": titleOf(_optionalChain([context, 'optionalAccess', _242 => _242.listing])),
|
|
4634
|
+
"{query}": _nullishCoalesce((Array.isArray(query) ? query[0] : query), () => ( "")),
|
|
4635
|
+
"{store}": store
|
|
4636
|
+
};
|
|
4637
|
+
const pattern = _nullishCoalesce(_nullishCoalesce(text(_optionalChain([input, 'access', _243 => _243.meta, 'optionalAccess', _244 => _244.seo, 'optionalAccess', _245 => _245.titleTemplate])), () => ( DEFAULT_TITLE[name])), () => ( "{store}"));
|
|
4638
|
+
let title = pattern;
|
|
4639
|
+
for (const [token, value] of Object.entries(tokens)) title = title.replaceAll(token, () => value);
|
|
4640
|
+
title = title.replace(/^[\s–—|·:-]+|[\s–—|·:-]+$/gu, "");
|
|
4641
|
+
if (title === "") title = store;
|
|
4642
|
+
const description = _nullishCoalesce(localizedOf(_optionalChain([input, 'access', _246 => _246.meta, 'optionalAccess', _247 => _247.seo, 'optionalAccess', _248 => _248.description])), () => ( localizedOf(site.defaultDescription)));
|
|
4643
|
+
const mediaOrigin = _nullishCoalesce(input.mediaOrigin, () => ( ""));
|
|
4644
|
+
const image = _nullishCoalesce(imageOf(_optionalChain([input, 'access', _249 => _249.meta, 'optionalAccess', _250 => _250.seo, 'optionalAccess', _251 => _251.shareImage]), mediaOrigin), () => ( imageOf(site.shareImage, mediaOrigin)));
|
|
4645
|
+
const noindex = input.noindex === true || name === "search" || (_nullishCoalesce(_optionalChain([input, 'access', _252 => _252.meta, 'optionalAccess', _253 => _253.noindex]), () => ( _builderschema.TEMPLATE_NOINDEX_DEFAULT[name]))) || site.noindex === true;
|
|
4646
|
+
const origin = _nullishCoalesce(originOf(text(site.canonicalBase)), () => ( originOf(input.storeUrl)));
|
|
4647
|
+
const kind = name === "product" ? "product" : name === "search" ? "search" : LISTING_TEMPLATES.includes(name) ? "listing" : "page";
|
|
4648
|
+
const canonical = noindex || origin === void 0 ? void 0 : canonicalFor(`${origin}${input.path}${_nullishCoalesce(input.search, () => ( ""))}`, kind);
|
|
4649
|
+
return {
|
|
4650
|
+
title,
|
|
4651
|
+
...description === void 0 ? {} : { description },
|
|
4652
|
+
...noindex ? { robots: name === "search" ? { index: false, follow: true } : { index: false } } : {},
|
|
4653
|
+
...canonical === void 0 ? {} : { alternates: { canonical } },
|
|
4654
|
+
openGraph: {
|
|
4655
|
+
type: "website",
|
|
4656
|
+
...store === "" ? {} : { siteName: store },
|
|
4657
|
+
title,
|
|
4658
|
+
...description === void 0 ? {} : { description },
|
|
4659
|
+
...image === void 0 ? {} : { images: [image] }
|
|
4660
|
+
},
|
|
4661
|
+
twitter: {
|
|
4662
|
+
card: image === void 0 ? "summary" : "summary_large_image",
|
|
4663
|
+
title,
|
|
4664
|
+
...description === void 0 ? {} : { description },
|
|
4665
|
+
...image === void 0 ? {} : { images: [image.url] }
|
|
4666
|
+
}
|
|
4667
|
+
};
|
|
2956
4668
|
}
|
|
2957
|
-
var localized = (path, locale) => locale === void 0 ? path : path === "/" ? `/${locale}` : `/${locale}${path}`;
|
|
2958
4669
|
function metadataOf(page, context) {
|
|
2959
4670
|
const { settings, mediaOrigin, routeLocale } = context;
|
|
2960
|
-
const site =
|
|
2961
|
-
const brand =
|
|
4671
|
+
const site = isRec2(settings.seo) ? settings.seo : {};
|
|
4672
|
+
const brand = isRec2(settings.brand) ? settings.brand : {};
|
|
2962
4673
|
const own = pageSeoOf(page);
|
|
2963
4674
|
const template = _nullishCoalesce(text(site.titleTemplate), () => ( "{page}"));
|
|
2964
4675
|
const store = _nullishCoalesce(text(brand.storeName), () => ( ""));
|
|
2965
4676
|
const title = template.replaceAll("{page}", () => _nullishCoalesce(own.title, () => ( page.title))).replaceAll("{store}", () => store);
|
|
2966
4677
|
const description = _nullishCoalesce(own.description, () => ( text(site.defaultDescription)));
|
|
2967
4678
|
const image = _nullishCoalesce(imageOf(own.shareImage, mediaOrigin), () => ( imageOf(site.shareImage, mediaOrigin)));
|
|
2968
|
-
if (image === void 0 && mediaOrigin === "" && (
|
|
4679
|
+
if (image === void 0 && mediaOrigin === "" && (isRec2(own.shareImage) || isRec2(site.shareImage)))
|
|
2969
4680
|
warnOnce("share-image-origin", "A share image is set but createBuilderPage has no mediaOrigin, so the page has no og:image: pass the same mediaOrigin as loadSite");
|
|
2970
|
-
const origin = originOf(context.storeUrl);
|
|
4681
|
+
const origin = _nullishCoalesce(originOf(text(site.canonicalBase)), () => ( originOf(context.storeUrl)));
|
|
2971
4682
|
if (origin === void 0)
|
|
2972
4683
|
warnOnce("canonical-origin", "No canonical link: pass storeUrl (https://shop.example.com) to createBuilderPage. The Builder does not publish the store URL.");
|
|
2973
|
-
const path = pagePathOf(settings, { slug: page.slug, pageType: page.pageType }, context.pagePath);
|
|
2974
|
-
const
|
|
2975
|
-
const
|
|
2976
|
-
const
|
|
2977
|
-
|
|
2978
|
-
...
|
|
4684
|
+
const path = pagePathOf(settings, { slug: page.slug, pageType: page.pageType, path: text(page.path) }, context.pagePath);
|
|
4685
|
+
const override = canonicalOverrideOf(own.canonical);
|
|
4686
|
+
const canonical = _nullishCoalesce(override, () => ( (origin === void 0 || path === null ? void 0 : `${origin}${localized2(path, routeLocale)}`)));
|
|
4687
|
+
const { list: list2, fallback } = siteLocales(settings);
|
|
4688
|
+
const languages = origin !== void 0 && path !== null && routeLocale !== void 0 && list2.length > 1 ? {
|
|
4689
|
+
...Object.fromEntries(list2.map((locale) => [locale, `${origin}${localized2(path, locale)}`])),
|
|
4690
|
+
...fallback === void 0 ? {} : { "x-default": `${origin}${localized2(path, fallback)}` }
|
|
2979
4691
|
} : void 0;
|
|
2980
4692
|
return {
|
|
2981
4693
|
title,
|
|
2982
4694
|
...description === void 0 ? {} : { description },
|
|
2983
|
-
|
|
4695
|
+
// Site-wide noindex (v2 `seo.noindex`, for staging) is on every page, as the page's own is.
|
|
4696
|
+
...own.noindex || site.noindex === true ? { robots: { index: false } } : {},
|
|
2984
4697
|
...canonical === void 0 ? {} : { alternates: { canonical, ...languages === void 0 ? {} : { languages } } },
|
|
2985
4698
|
openGraph: {
|
|
2986
4699
|
type: "website",
|
|
4700
|
+
...store === "" ? {} : { siteName: store },
|
|
2987
4701
|
title,
|
|
2988
4702
|
...description === void 0 ? {} : { description },
|
|
2989
4703
|
...canonical === void 0 ? {} : { url: canonical },
|
|
@@ -3013,4 +4727,19 @@ function metadataOf(page, context) {
|
|
|
3013
4727
|
|
|
3014
4728
|
|
|
3015
4729
|
|
|
3016
|
-
|
|
4730
|
+
|
|
4731
|
+
|
|
4732
|
+
|
|
4733
|
+
|
|
4734
|
+
|
|
4735
|
+
|
|
4736
|
+
|
|
4737
|
+
|
|
4738
|
+
|
|
4739
|
+
|
|
4740
|
+
|
|
4741
|
+
|
|
4742
|
+
|
|
4743
|
+
|
|
4744
|
+
|
|
4745
|
+
exports.__publicField = __publicField; exports.warnOnce = warnOnce; exports.buildRouteTable = buildRouteTable; exports.organizationJsonLd = organizationJsonLd; exports.webSiteJsonLd = webSiteJsonLd; exports.breadcrumbJsonLd = breadcrumbJsonLd; exports.faqJsonLd = faqJsonLd; exports.localBusinessJsonLd = localBusinessJsonLd; exports.jsonLdString = jsonLdString; exports.createRendererRegistry = createRendererRegistry; exports.staticDataFor = staticDataFor; exports.partOf = partOf; exports.isRedirect = isRedirect; exports.getBundle = getBundle; exports.clientOf = clientOf; exports.isOwnPath = isOwnPath; exports.loadBuilderPageByPath = loadBuilderPageByPath; exports.loadOwnPagePaths = loadOwnPagePaths; exports.loadBuilderPage = loadBuilderPage; exports.templateRootOf = templateRootOf; exports.loadBuilderTemplate = loadBuilderTemplate; exports.pageSeoOf = pageSeoOf; exports.canonicalFor = canonicalFor; exports.pagePathOf = pagePathOf; exports.originOf = originOf; exports.siteLocales = siteLocales; exports.localized = localized2; exports.templateMetadataOf = templateMetadataOf; exports.metadataOf = metadataOf;
|