@usethrottle/builder-react 0.3.1 → 0.4.1

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.
@@ -71,25 +71,197 @@ async function resolveBindings(bindings, registry, ctx, options) {
71
71
  return Object.fromEntries(settled.filter((entry) => entry !== null));
72
72
  }
73
73
 
74
+ // src/saved-section.tsx
75
+
76
+
77
+ // src/node-wrapper.tsx
78
+
79
+ var _jsxruntime = require('react/jsx-runtime');
80
+ var CUSTOM_WIDGET_CONTAINMENT = {
81
+ contain: "layout paint",
82
+ isolation: "isolate",
83
+ overflow: "clip"
84
+ };
85
+ var PART_NAME = {
86
+ section: "builder-section",
87
+ column: "builder-column",
88
+ widget: "builder-widget"
89
+ };
90
+ function NodeWrapper(props) {
91
+ const { id, part, type, className, anchor, copyAnchor, custom, missing, attributes, edit, entrance, children } = props;
92
+ const Tag = _nullishCoalesce(props.as, () => ( "div"));
93
+ const handlers = edit === void 0 ? {} : {
94
+ onClickCapture: (event) => {
95
+ const target = event.target;
96
+ if (_optionalChain([target, 'optionalAccess', _5 => _5.closest, 'optionalCall', _6 => _6("a[href]")]) != null) event.preventDefault();
97
+ },
98
+ onClick: (event) => {
99
+ event.stopPropagation();
100
+ edit.onSelect(id);
101
+ },
102
+ onMouseOver: (event) => {
103
+ event.stopPropagation();
104
+ edit.onHover(id);
105
+ },
106
+ onMouseLeave: () => edit.onHover(null)
107
+ };
108
+ const style = custom === true || entrance !== void 0 ? {
109
+ ...custom === true ? CUSTOM_WIDGET_CONTAINMENT : {},
110
+ ...entrance !== void 0 && entrance.delayMs > 0 ? { "--tb-ed": `${String(entrance.delayMs)}ms` } : {}
111
+ } : void 0;
112
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
113
+ Tag,
114
+ {
115
+ className,
116
+ "data-b-id": id,
117
+ "data-throttle-part": PART_NAME[part],
118
+ ...type === void 0 ? {} : { "data-b-type": type },
119
+ ...custom === true && type !== void 0 ? { "data-b-w": type } : {},
120
+ ...missing === true ? { "data-b-missing": "" } : {},
121
+ ...attributes,
122
+ ...typeof anchor === "string" && _builderschema.ANCHOR_RE.test(anchor) ? { id: anchor } : {},
123
+ ...typeof copyAnchor === "string" && _builderschema.ANCHOR_RE.test(copyAnchor) ? { "data-b-anchor": copyAnchor } : {},
124
+ ...entrance === void 0 ? {} : { "data-b-entrance": entrance.name },
125
+ ...style === void 0 || Object.keys(style).length === 0 ? {} : { style },
126
+ ...handlers,
127
+ children
128
+ }
129
+ );
130
+ }
131
+
132
+ // src/saved-section.tsx
133
+
134
+ var pid = (refId, id) => `${refId}-${id}`;
135
+ var MAX_EXPANDED_NODES = 2e4;
136
+ function prefixAnchor(refId, props) {
137
+ const anchor = props.anchor;
138
+ if (typeof anchor !== "string") return props;
139
+ const prefixed = pid(refId, anchor);
140
+ const { anchor: _drop, ...rest } = props;
141
+ void _drop;
142
+ return _builderschema.ANCHOR_RE.test(prefixed) ? { ...rest, anchor: prefixed } : rest;
143
+ }
144
+ function prefixColumn(refId, column) {
145
+ return {
146
+ ...column,
147
+ id: pid(refId, column.id),
148
+ props: prefixAnchor(refId, column.props),
149
+ children: column.children.map(
150
+ (child) => child.type === "inner-section" ? prefixSection(refId, child) : { ...child, id: pid(refId, child.id), props: prefixAnchor(refId, child.props) }
151
+ )
152
+ };
153
+ }
154
+ function prefixSection(refId, section) {
155
+ return {
156
+ ...section,
157
+ id: pid(refId, section.id),
158
+ props: prefixAnchor(refId, section.props),
159
+ columns: section.columns.map((column) => prefixColumn(refId, column))
160
+ };
161
+ }
162
+ var parsed = /* @__PURE__ */ new WeakMap();
163
+ function sectionOf(entry) {
164
+ const cached = parsed.get(entry);
165
+ if (cached !== void 0) return cached;
166
+ const result = _builderschema.sectionNodeSchema.safeParse(entry.section);
167
+ const section = result.success ? result.data : null;
168
+ parsed.set(entry, section);
169
+ return section;
170
+ }
171
+ var sized = /* @__PURE__ */ new WeakMap();
172
+ function sizeOf(section) {
173
+ const known = sized.get(section);
174
+ if (known !== void 0) return known;
175
+ let size = 0;
176
+ _builderschema.walkNodes.call(void 0, { sections: [section] }, () => {
177
+ size += 1;
178
+ });
179
+ sized.set(section, size);
180
+ return size;
181
+ }
182
+ var cache = /* @__PURE__ */ new WeakMap();
183
+ var NONE = {};
184
+ function expandSavedSections(source, answer) {
185
+ if (!source.sections.some((root) => root.type === "saved-section")) return { doc: source, roots: null };
186
+ let perAnswer = cache.get(source);
187
+ if (perAnswer === void 0) {
188
+ perAnswer = /* @__PURE__ */ new WeakMap();
189
+ cache.set(source, perAnswer);
190
+ }
191
+ const key = _nullishCoalesce(answer, () => ( NONE));
192
+ const known = perAnswer.get(key);
193
+ if (known !== void 0) return known;
194
+ const made = expand(source, answer);
195
+ perAnswer.set(key, made);
196
+ return made;
197
+ }
198
+ function expand(source, answer) {
199
+ const sections = [];
200
+ const roots = [];
201
+ const snapshots = {};
202
+ let nodes = 0;
203
+ _builderschema.walkNodes.call(void 0, { sections: source.sections.filter((root) => root.type === "section") }, () => {
204
+ nodes += 1;
205
+ });
206
+ for (const root of source.sections) {
207
+ if (root.type === "section") {
208
+ sections.push(root);
209
+ roots.push({ kind: "section", id: root.id });
210
+ continue;
211
+ }
212
+ const entry = answer !== void 0 && Object.hasOwn(answer, root.ref) ? answer[root.ref] : void 0;
213
+ const section = entry === void 0 ? null : sectionOf(entry);
214
+ if (entry !== void 0 && section !== null && nodes + sizeOf(section) > MAX_EXPANDED_NODES) {
215
+ warnOnce("saved-section-cap", `A page holds more than ${String(MAX_EXPANDED_NODES)} nodes with its saved sections; the rest are left out`);
216
+ roots.push({ kind: "ref", ref: root, sectionId: null });
217
+ continue;
218
+ }
219
+ if (entry === void 0 || section === null) {
220
+ roots.push({ kind: "ref", ref: root, sectionId: null });
221
+ continue;
222
+ }
223
+ nodes += sizeOf(section);
224
+ const prefixed = prefixSection(root.id, section);
225
+ const anchor = root.props.anchor;
226
+ const placed = anchor !== void 0 ? { ...prefixed, props: { ...prefixed.props, anchor } } : prefixed;
227
+ sections.push(placed);
228
+ roots.push({ kind: "ref", ref: root, sectionId: placed.id });
229
+ for (const [snapshotKey, snapshot] of Object.entries(_nullishCoalesce(entry.customWidgets, () => ( {})))) {
230
+ if (_builderschema.anyCustomWidgetSnapshotSchema.safeParse(snapshot).success) snapshots[snapshotKey] = snapshot;
231
+ }
232
+ }
233
+ const customWidgets = { ...snapshots, ...source.customWidgets };
234
+ return {
235
+ doc: { ...source, sections, ...Object.keys(customWidgets).length === 0 ? {} : { customWidgets } },
236
+ roots
237
+ };
238
+ }
239
+ function MissingSavedSection({ node }) {
240
+ warnOnce(`saved-section:${node.ref}`, `Saved section ${node.ref} has no published section; rendering nothing for it`);
241
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NodeWrapper, { id: node.id, part: "section", as: "section", className: "tb-section", missing: true });
242
+ }
243
+
74
244
  // src/load.ts
75
245
  function pageOf(raw, initialData) {
76
- const { document, id: _id, slug, title, path, generation, pageType: _type, updatedAt: _updated, ...meta } = raw;
246
+ const { document: document2, id: _id, slug, title, path, generation, pageType: _type, updatedAt: _updated, savedSections, code, ...meta } = raw;
77
247
  return {
78
248
  kind: "page",
79
249
  slug,
80
250
  title,
81
251
  path,
82
252
  generation,
83
- document,
84
- assets: _nullishCoalesce(document.assets, () => ( {})),
253
+ document: document2,
254
+ assets: _nullishCoalesce(document2.assets, () => ( {})),
85
255
  initialData,
86
- meta
256
+ meta,
257
+ ...savedSections === void 0 ? {} : { savedSections },
258
+ ...code === void 0 ? {} : { code }
87
259
  };
88
260
  }
89
261
  async function staticDataFor(documents, registry, locale, currency) {
90
262
  const bindings = /* @__PURE__ */ new Map();
91
- for (const document of documents) {
92
- for (const [key, binding] of collectBindings(document, registry)) bindings.set(key, binding);
263
+ for (const { document: document2, savedSections } of documents) {
264
+ for (const [key, binding] of collectBindings(expandSavedSections(document2, savedSections).doc, registry)) bindings.set(key, binding);
93
265
  }
94
266
  if (bindings.size === 0) return {};
95
267
  return resolveBindings(
@@ -99,16 +271,24 @@ async function staticDataFor(documents, registry, locale, currency) {
99
271
  { include: "static" }
100
272
  );
101
273
  }
102
- function partOf(loaded, initialData) {
103
- return { document: loaded.document, assets: _nullishCoalesce(loaded.document.assets, () => ( {})), initialData };
274
+ function partOf(loaded, initialData, shared = {}) {
275
+ const savedSections = _nullishCoalesce(loaded.savedSections, () => ( shared.savedSections));
276
+ const code = _nullishCoalesce(loaded.code, () => ( shared.code));
277
+ return {
278
+ document: loaded.document,
279
+ assets: _nullishCoalesce(loaded.document.assets, () => ( {})),
280
+ initialData,
281
+ ...savedSections === void 0 ? {} : { savedSections },
282
+ ...code === void 0 ? {} : { code }
283
+ };
104
284
  }
105
285
  var isRedirect = (raw) => typeof raw.redirectTo === "string";
106
286
 
107
287
  // src/server/bundle.ts
108
288
  var _react = require('react'); var React = _interopRequireWildcard(_react);
109
289
  var _builder = require('@usethrottle/builder');
110
- var cache2 = _nullishCoalesce(React.cache, () => ( ((fn) => fn)));
111
- var requestBatches = cache2(() => []);
290
+ var cache3 = _nullishCoalesce(React.cache, () => ( ((fn) => fn)));
291
+ var requestBatches = cache3(() => []);
112
292
  function getBundle(ask) {
113
293
  const batches = requestBatches();
114
294
  const slots = new Set(_nullishCoalesce(ask.slots, () => ( [])));
@@ -233,7 +413,7 @@ var BASICS_CSS = `@layer throttle{
233
413
  }`;
234
414
 
235
415
  // src/basics/util.tsx
236
- var _jsxruntime = require('react/jsx-runtime');
416
+
237
417
  function BasicStyles() {
238
418
  return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: "tb-basics", precedence: "throttle", children: BASICS_CSS });
239
419
  }
@@ -249,11 +429,11 @@ function hrefOf(link, mediaOrigin) {
249
429
  function Placeholder({ editMode, children }) {
250
430
  return editMode ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-empty", children }) : null;
251
431
  }
252
- var ID_RE = /^[a-z0-9]{8,24}$/;
432
+ var ID_RE = /^[a-z0-9]{8,24}(-[a-z0-9]{8,24})?$/;
253
433
  var DEVICES = ["desktop", "tablet", "phone"];
254
434
  function defaultOf(type, key) {
255
435
  const def = _builderschema.BASIC_WIDGET_DEFINITIONS.find((d) => d.type === type);
256
- return _nullishCoalesce(_optionalChain([def, 'optionalAccess', _5 => _5.settings, 'access', _6 => _6.find, 'call', _7 => _7((f) => f.key === key), 'optionalAccess', _8 => _8.default]), () => ( null));
436
+ return _nullishCoalesce(_optionalChain([def, 'optionalAccess', _7 => _7.settings, 'access', _8 => _8.find, 'call', _9 => _9((f) => f.key === key), 'optionalAccess', _10 => _10.default]), () => ( null));
257
437
  }
258
438
  function enumCss(node, rules) {
259
439
  if (!ID_RE.test(node.id)) return "";
@@ -294,7 +474,7 @@ function write(message) {
294
474
  }
295
475
  function Announcement({ props, mediaOrigin, editMode }) {
296
476
  const design = _ui.useSiteDesign.call(void 0, );
297
- const message = _optionalChain([design, 'optionalAccess', _9 => _9.announcement, 'optionalAccess', _10 => _10.message]);
477
+ const message = _optionalChain([design, 'optionalAccess', _11 => _11.announcement, 'optionalAccess', _12 => _12.message]);
298
478
  const [dismissed, setDismissed] = _react.useState.call(void 0, false);
299
479
  _react.useEffect.call(void 0, () => {
300
480
  if (message !== void 0 && read(message)) setDismissed(true);
@@ -306,8 +486,8 @@ function Announcement({ props, mediaOrigin, editMode }) {
306
486
  ] });
307
487
  }
308
488
  if (dismissed && !editMode) return null;
309
- const href = _builderschema.safeUrl.call(void 0, _optionalChain([design, 'optionalAccess', _11 => _11.announcement, 'optionalAccess', _12 => _12.href]), "href", { mediaOrigin });
310
- const strings = _optionalChain([design, 'optionalAccess', _13 => _13.strings]);
489
+ const href = _builderschema.safeUrl.call(void 0, _optionalChain([design, 'optionalAccess', _13 => _13.announcement, 'optionalAccess', _14 => _14.href]), "href", { mediaOrigin });
490
+ const strings = _optionalChain([design, 'optionalAccess', _15 => _15.strings]);
311
491
  const dismissLabel = _nullishCoalesce((strings !== void 0 && Object.hasOwn(strings, "announcement.dismiss") ? str(strings["announcement.dismiss"]) : void 0), () => ( _builderschema.SITE_STRING_DEFAULTS["announcement.dismiss"]));
312
492
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
313
493
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
@@ -336,7 +516,7 @@ var SIZES = ["s", "m", "l"];
336
516
  function Button({ props, mediaOrigin, inlineEdit }) {
337
517
  const href = hrefOf(props.link, mediaOrigin);
338
518
  const className = `tb-b-button tb-b-button--${oneOf(props.style, STYLES, "primary")} tb-b-button--${oneOf(props.size, SIZES, "m")}`;
339
- const label = _nullishCoalesce(_nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _14 => _14("label")]), () => ( str(props.label))), () => ( ""));
519
+ const label = _nullishCoalesce(_nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _16 => _16("label")]), () => ( str(props.label))), () => ( ""));
340
520
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
341
521
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
342
522
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-button-wrap", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { className, ...href === null ? {} : { href }, children: label }) })
@@ -349,15 +529,316 @@ function Button({ props, mediaOrigin, inlineEdit }) {
349
529
 
350
530
  function Copyright(_) {
351
531
  const design = _ui.useSiteDesign.call(void 0, );
352
- const strings = _optionalChain([design, 'optionalAccess', _15 => _15.strings]);
532
+ const strings = _optionalChain([design, 'optionalAccess', _17 => _17.strings]);
353
533
  const template = strings !== void 0 && Object.hasOwn(strings, "footer.copyright") ? str(strings["footer.copyright"]) : void 0;
354
- const line = (_nullishCoalesce(template, () => ( _builderschema.SITE_STRING_DEFAULTS["footer.copyright"]))).replace("{year}", () => String((/* @__PURE__ */ new Date()).getFullYear())).replace("{store}", () => _nullishCoalesce(str(_optionalChain([design, 'optionalAccess', _16 => _16.brand, 'optionalAccess', _17 => _17.storeName])), () => ( ""))).replace(/\s{2,}/g, " ").replace(/\s+([.,])/g, "$1");
534
+ const line = (_nullishCoalesce(template, () => ( _builderschema.SITE_STRING_DEFAULTS["footer.copyright"]))).replace("{year}", () => String((/* @__PURE__ */ new Date()).getFullYear())).replace("{store}", () => _nullishCoalesce(str(_optionalChain([design, 'optionalAccess', _18 => _18.brand, 'optionalAccess', _19 => _19.storeName])), () => ( ""))).replace(/\s{2,}/g, " ").replace(/\s+([.,])/g, "$1");
355
535
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
356
536
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
357
537
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "tb-b-copyright", children: line })
358
538
  ] });
359
539
  }
360
540
 
541
+ // src/interactions/entrance.tsx
542
+
543
+
544
+
545
+ // src/interactions/styles.ts
546
+ var INTERACTIONS_CSS = `@layer throttle{
547
+ .tb-panel>.tb-col,.tb-acc-body>.tb-col,.tb-slide>.tb-col{inline-size:100%}
548
+ .tb-tablist{display:none;flex-wrap:wrap;gap:var(--tb-space-xs);border-block-end:1px solid var(--tb-color-border,currentColor);margin-block-end:var(--tb-space-m)}
549
+ html[data-b-js] .tb-tablist{display:flex}
550
+ html[data-b-js] .tb-panel-title{display:none}
551
+ .tb-panel-title{margin:0 0 var(--tb-space-s);font-weight:600}
552
+ .tb-panel[hidden]{display:none}
553
+ .tb-tab{appearance:none;cursor:pointer;font:inherit;color:inherit;background:none;border:0;border-block-end:2px solid transparent;padding:var(--tb-space-s) var(--tb-space-m)}
554
+ .tb-tab[aria-selected=true]{border-block-end-color:var(--tb-color-primary,currentColor);font-weight:600}
555
+ .tb-tab:focus-visible,.tb-car-btn:focus-visible,.tb-acc-sum:focus-visible,.tb-toggle-sum:focus-visible,.tb-car-track:focus-visible{outline:2px solid var(--tb-color-primary,currentColor);outline-offset:2px}
556
+ .tb-acc-item{border-block-end:1px solid var(--tb-color-border,currentColor)}
557
+ .tb-acc-sum,.tb-toggle-sum{cursor:pointer;padding:var(--tb-space-s) 0;font-weight:600}
558
+ .tb-acc-body{padding-block-end:var(--tb-space-m)}
559
+ .tb-toggle-open,.tb-toggle[open] .tb-toggle-closed{display:none}
560
+ .tb-toggle[open] .tb-toggle-open{display:inline}
561
+ .tb-toggle .tb-row{margin-block-start:var(--tb-space-m)}
562
+ .tb-car{position:relative}
563
+ .tb-car-track{display:flex;overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:thin}
564
+ .tb-slide{flex:0 0 100%;min-inline-size:0;scroll-snap-align:start}
565
+ .tb-car-ctrl{display:none;justify-content:center;gap:var(--tb-space-s);margin-block-start:var(--tb-space-s)}
566
+ html[data-b-js] .tb-car-ctrl{display:flex}
567
+ .tb-car-btn{appearance:none;cursor:pointer;font:inherit;color:inherit;background:var(--tb-color-surface,transparent);border:1px solid var(--tb-color-border-control,currentColor);border-radius:999px;min-inline-size:2.5rem;min-block-size:2.5rem;padding:0 var(--tb-space-m)}
568
+ .tb-car-btn[hidden]{display:none}
569
+ @media (prefers-reduced-motion:no-preference){
570
+ html[data-b-js] [data-b-entrance]{transition:opacity .6s ease var(--tb-ed,0ms),transform .6s ease var(--tb-ed,0ms)}
571
+ html[data-b-js] [data-b-entrance]:not([data-b-in]){opacity:0}
572
+ html[data-b-js] [data-b-entrance=slide-up]:not([data-b-in]){transform:translateY(1.5rem)}
573
+ html[data-b-js] [data-b-entrance=slide-left]:not([data-b-in]){transform:translateX(-1.5rem)}
574
+ html[data-b-js] [data-b-entrance=zoom]:not([data-b-in]){transform:scale(.94)}
575
+ }
576
+ @media (prefers-reduced-motion:reduce){.tb-car-track{scroll-behavior:auto}}
577
+ }`;
578
+
579
+ // src/interactions/runtime.ts
580
+ var UNITS = [86400, 3600, 60, 1];
581
+ var KEYS = ["d", "h", "m", "s"];
582
+ var NAMES = ["days", "hours", "minutes", "seconds"];
583
+ var holds = 0;
584
+ var stop;
585
+ var seen2 = /* @__PURE__ */ new WeakSet();
586
+ var autoplay = /* @__PURE__ */ new Map();
587
+ var all = (selector) => Array.from(document.querySelectorAll(selector));
588
+ var reduced = () => _optionalChain([window, 'access', _20 => _20.matchMedia, 'optionalCall', _21 => _21("(prefers-reduced-motion: reduce)"), 'access', _22 => _22.matches]) === true;
589
+ function selectTab(list, index, focus = false) {
590
+ const tabs = Array.from(list.querySelectorAll("[role=tab]"));
591
+ tabs.forEach((tab, i) => {
592
+ const on = i === index;
593
+ tab.setAttribute("aria-selected", String(on));
594
+ tab.tabIndex = on ? 0 : -1;
595
+ const panel = document.getElementById(_nullishCoalesce(tab.getAttribute("aria-controls"), () => ( "")));
596
+ if (panel !== null) panel.hidden = !on;
597
+ if (on && focus) tab.focus();
598
+ });
599
+ }
600
+ function slideTo(root, step2) {
601
+ const track = root.querySelector(".tb-car-track");
602
+ if (track === null || track.clientWidth === 0) return;
603
+ const count = track.children.length;
604
+ const at = Math.round(track.scrollLeft / track.clientWidth) + step2;
605
+ const loop = root.hasAttribute("data-b-loop");
606
+ const to = at >= count ? loop ? 0 : count - 1 : at < 0 ? loop ? count - 1 : 0 : at;
607
+ _optionalChain([track, 'access', _23 => _23.scrollTo, 'optionalCall', _24 => _24({ left: to * track.clientWidth, behavior: reduced() ? "auto" : "smooth" })]);
608
+ }
609
+ var carousels = /* @__PURE__ */ new WeakMap();
610
+ function setupCarousel(root) {
611
+ const every = Number(root.getAttribute("data-b-autoplay"));
612
+ const pause = root.querySelector("[data-b-act=pause]");
613
+ if (!(every > 0) || reduced() || pause === null) return;
614
+ pause.hidden = false;
615
+ let state = carousels.get(root);
616
+ if (state === void 0) {
617
+ const own = state = { hold: 0 };
618
+ carousels.set(root, own);
619
+ const set = (bit, on) => void (own.hold = on ? own.hold | bit : own.hold & ~bit);
620
+ root.addEventListener("mouseenter", () => set(1, true));
621
+ root.addEventListener("mouseleave", () => set(1, false));
622
+ root.addEventListener("focusin", () => set(2, true));
623
+ root.addEventListener("focusout", () => set(2, false));
624
+ pause.addEventListener("click", () => {
625
+ set(4, (own.hold & 4) === 0);
626
+ pause.textContent = own.hold & 4 ? "Play" : "Pause";
627
+ });
628
+ }
629
+ const shared = state;
630
+ autoplay.set(root, window.setInterval(() => shared.hold === 0 && slideTo(root, 1), every));
631
+ }
632
+ function remaining(el) {
633
+ return Math.max(0, Math.floor((Number(el.getAttribute("data-b-cd")) - Date.now()) / 1e3));
634
+ }
635
+ function tick(el, minute) {
636
+ let left = remaining(el);
637
+ const parts = [];
638
+ KEYS.forEach((key, i) => {
639
+ const out = el.querySelector(`[data-u=${key}]`);
640
+ if (out === null) return;
641
+ const value = Math.floor(left / UNITS[i]);
642
+ left -= value * UNITS[i];
643
+ out.textContent = String(value).padStart(2, "0");
644
+ parts.push(`${String(value)} ${_optionalChain([out, 'access', _25 => _25.nextElementSibling, 'optionalAccess', _26 => _26.textContent]) || NAMES[i]}`);
645
+ });
646
+ const live = el.querySelector("[data-b-live]");
647
+ if (live !== null && minute) live.textContent = parts.join(", ");
648
+ if (remaining(el) === 0) {
649
+ el.setAttribute("data-b-ended", "");
650
+ const text2 = el.querySelector(".tb-b-cd-ended");
651
+ if (text2 !== null) text2.hidden = false;
652
+ if (el.getAttribute("data-b-expired") === "hide") el.hidden = true;
653
+ }
654
+ }
655
+ function scan() {
656
+ autoplay.forEach((id, root) => {
657
+ if (!root.isConnected) {
658
+ window.clearInterval(id);
659
+ autoplay.delete(root);
660
+ }
661
+ });
662
+ document.documentElement.setAttribute("data-b-js", "");
663
+ const fresh = (selector) => all(selector).filter((el) => !seen2.has(el) && seen2.add(el));
664
+ fresh("[data-b-tabs]").forEach((list) => selectTab(list, 0));
665
+ fresh("[data-b-car]").forEach((root) => setupCarousel(root));
666
+ const counts = fresh("[data-b-cd]");
667
+ counts.forEach((el) => tick(el, true));
668
+ const targets = fresh("[data-b-entrance]");
669
+ if (targets.length === 0) return;
670
+ if (typeof IntersectionObserver === "undefined") targets.forEach((el) => el.setAttribute("data-b-in", ""));
671
+ else {
672
+ const watch = new IntersectionObserver(
673
+ (entries) => entries.forEach((entry) => {
674
+ if (!entry.isIntersecting) return;
675
+ entry.target.setAttribute("data-b-in", "");
676
+ watch.unobserve(entry.target);
677
+ })
678
+ );
679
+ targets.forEach((el) => watch.observe(el));
680
+ }
681
+ }
682
+ var shown = (el) => el !== null && el.getClientRects().length > 0;
683
+ function goAnchor(name) {
684
+ if (name === "" || shown(document.getElementById(name))) return false;
685
+ const copy = all("[data-b-anchor]").find((el) => el.getAttribute("data-b-anchor") === name && shown(el));
686
+ _optionalChain([copy, 'optionalAccess', _27 => _27.scrollIntoView, 'call', _28 => _28()]);
687
+ return copy !== void 0;
688
+ }
689
+ var decoded = (hash) => {
690
+ try {
691
+ return decodeURIComponent(hash.slice(1));
692
+ } catch (e4) {
693
+ return "";
694
+ }
695
+ };
696
+ var onHash = () => void goAnchor(decoded(location.hash));
697
+ function onClick(event) {
698
+ const target = event.target;
699
+ const href = _optionalChain([target, 'optionalAccess', _29 => _29.closest, 'call', _30 => _30('a[href^="#"]'), 'optionalAccess', _31 => _31.getAttribute, 'call', _32 => _32("href")]);
700
+ if (href && !event.defaultPrevented && !event.button && !(event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) && goAnchor(decoded(href))) {
701
+ event.preventDefault();
702
+ history.pushState(null, "", href);
703
+ }
704
+ const tab = _optionalChain([target, 'optionalAccess', _33 => _33.closest, 'call', _34 => _34("[role=tab]")]);
705
+ const list = _optionalChain([tab, 'optionalAccess', _35 => _35.closest, 'call', _36 => _36("[data-b-tabs]")]);
706
+ if (tab && list) return selectTab(list, Array.from(list.querySelectorAll("[role=tab]")).indexOf(tab));
707
+ const button = _optionalChain([target, 'optionalAccess', _37 => _37.closest, 'call', _38 => _38("[data-b-act]")]);
708
+ const act = _optionalChain([button, 'optionalAccess', _39 => _39.getAttribute, 'call', _40 => _40("data-b-act")]);
709
+ const root = _optionalChain([button, 'optionalAccess', _41 => _41.closest, 'call', _42 => _42("[data-b-car]")]);
710
+ if (root && (act === "prev" || act === "next")) slideTo(root, act === "next" ? 1 : -1);
711
+ }
712
+ function onKey(event) {
713
+ const tab = _optionalChain([event, 'access', _43 => _43.target, 'optionalAccess', _44 => _44.closest, 'call', _45 => _45("[role=tab]")]);
714
+ const list = _optionalChain([tab, 'optionalAccess', _46 => _46.closest, 'call', _47 => _47("[data-b-tabs]")]);
715
+ if (!tab || !list) return;
716
+ const count = list.querySelectorAll("[role=tab]").length;
717
+ const at = Array.from(list.querySelectorAll("[role=tab]")).indexOf(tab);
718
+ 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
+ if (to < 0) return;
720
+ event.preventDefault();
721
+ selectTab(list, to, true);
722
+ }
723
+ function startRuntime() {
724
+ if (typeof document === "undefined") return () => void 0;
725
+ const first = holds++ === 0;
726
+ if (first) {
727
+ document.addEventListener("click", onClick);
728
+ document.addEventListener("keydown", onKey);
729
+ window.addEventListener("hashchange", onHash);
730
+ let beat = 0;
731
+ const clock = window.setInterval(() => {
732
+ const minute = ++beat % 60 === 0;
733
+ all("[data-b-cd]:not([data-b-ended])").forEach((el) => tick(el, minute));
734
+ }, 1e3);
735
+ let queued = false;
736
+ const watcher = new MutationObserver(() => {
737
+ if (queued) return;
738
+ queued = true;
739
+ void Promise.resolve().then(() => {
740
+ queued = false;
741
+ if (holds > 0) scan();
742
+ });
743
+ });
744
+ watcher.observe(document.documentElement, { childList: true, subtree: true });
745
+ stop = () => {
746
+ document.removeEventListener("click", onClick);
747
+ document.removeEventListener("keydown", onKey);
748
+ window.removeEventListener("hashchange", onHash);
749
+ window.clearInterval(clock);
750
+ watcher.disconnect();
751
+ autoplay.forEach((id) => window.clearInterval(id));
752
+ autoplay.clear();
753
+ seen2 = /* @__PURE__ */ new WeakSet();
754
+ };
755
+ }
756
+ scan();
757
+ if (first) onHash();
758
+ return () => {
759
+ if (--holds === 0) _optionalChain([stop, 'optionalCall', _48 => _48()]);
760
+ };
761
+ }
762
+
763
+ // src/interactions/entrance.tsx
764
+
765
+ function entranceOf(entrance, delayMs, interactive) {
766
+ if (!interactive || typeof entrance !== "string" || entrance === "none") return void 0;
767
+ if (!_builderschema.ENTRANCES.includes(entrance)) return void 0;
768
+ const delay = typeof delayMs === "number" && Number.isFinite(delayMs) ? Math.min(2e3, Math.max(0, Math.round(delayMs))) : 0;
769
+ return { name: entrance, delayMs: delay };
770
+ }
771
+ function InteractionRuntime() {
772
+ _react.useEffect.call(void 0, () => startRuntime(), []);
773
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: "tb-interactions", precedence: "throttle", children: INTERACTIONS_CSS });
774
+ }
775
+
776
+ // src/basics/countdown.tsx
777
+
778
+ var UNITS2 = [
779
+ { key: "d", show: "showDays", label: "labelDays", seconds: 86400 },
780
+ { key: "h", show: "showHours", label: "labelHours", seconds: 3600 },
781
+ { key: "m", show: "showMinutes", label: "labelMinutes", seconds: 60 },
782
+ { key: "s", show: "showSeconds", label: "labelSeconds", seconds: 1 }
783
+ ];
784
+ var COUNTDOWN_CSS = `@layer throttle{
785
+ .tb-b-cd{text-align:var(--b-align,center);color:var(--b-color,inherit);font-size:var(--b-size,var(--tb-text-l))}
786
+ .tb-b-cd-date{margin:0}
787
+ .tb-b-cd-units{display:none;justify-content:var(--b-align,center);gap:var(--tb-space-m);flex-wrap:wrap}
788
+ html[data-b-js] .tb-b-cd-units{display:flex}
789
+ html[data-b-js] .tb-b-cd-date{font-size:.5em;opacity:.7}
790
+ .tb-b-cd-unit{display:flex;flex-direction:column;align-items:center;min-inline-size:3ch}
791
+ .tb-b-cd-num{font-variant-numeric:tabular-nums;font-weight:700;line-height:1.1}
792
+ .tb-b-cd-label{font-size:.45em;opacity:.8}
793
+ .tb-b-cd-ended{margin:0}
794
+ .tb-b-cd[data-b-ended] .tb-b-cd-units,.tb-b-cd[data-b-ended] .tb-b-cd-date{display:none}
795
+ .tb-b-sr{position:absolute;inline-size:1px;block-size:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap}
796
+ }`;
797
+ var two = (n) => String(n).padStart(2, "0");
798
+ function targetText(date) {
799
+ return `${date.toISOString().slice(0, 10)} ${date.toISOString().slice(11, 16)} UTC`;
800
+ }
801
+ function Countdown({ props, editMode, interactive, locale }) {
802
+ void locale;
803
+ const target = str(props.target);
804
+ const when = target === void 0 ? null : new Date(target);
805
+ if (when === null || Number.isNaN(when.getTime())) {
806
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: "Set the date and time the countdown ends" });
807
+ }
808
+ const live = interactive !== false;
809
+ const behavior = oneOf(props.expiredBehavior, ["text", "hide"], "text");
810
+ const shown2 = UNITS2.filter((unit) => props[unit.show] !== false);
811
+ let left = live ? 0 : Math.max(0, Math.floor((when.getTime() - Date.now()) / 1e3));
812
+ const units = shown2.map((unit) => {
813
+ const value = live ? null : Math.floor(left / unit.seconds);
814
+ if (value !== null) left -= value * unit.seconds;
815
+ return { ...unit, text: value === null ? "--" : two(value), name: _nullishCoalesce(str(props[unit.label]), () => ( "")) };
816
+ });
817
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
818
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
819
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: "tb-countdown", precedence: "throttle", children: COUNTDOWN_CSS }),
820
+ live ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InteractionRuntime, {}) : null,
821
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
822
+ "div",
823
+ {
824
+ className: "tb-b-cd",
825
+ role: "timer",
826
+ "aria-live": "off",
827
+ ...live ? { "data-b-cd": String(when.getTime()), "data-b-expired": behavior } : {},
828
+ children: [
829
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "tb-b-cd-date", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "time", { dateTime: when.toISOString(), children: targetText(when) }) }),
830
+ units.length === 0 ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-cd-units", children: units.map((unit) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-b-cd-unit", children: [
831
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-cd-num", "data-u": unit.key, "aria-hidden": "true", children: unit.text }),
832
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-cd-label", children: unit.name })
833
+ ] }, unit.key)) }),
834
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "tb-b-cd-ended", hidden: live || when.getTime() > Date.now(), children: _nullishCoalesce(str(props.expiredText), () => ( "")) }),
835
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-b-sr", "data-b-live": "", "aria-live": "polite" })
836
+ ]
837
+ }
838
+ )
839
+ ] });
840
+ }
841
+
361
842
  // src/widget-style.tsx
362
843
 
363
844
  function WidgetStyle({ css }) {
@@ -383,7 +864,7 @@ function Heading({ props, inlineEdit }) {
383
864
  const Tag = oneOf(props.level, LEVELS, "h2");
384
865
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
385
866
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
386
- /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tag, { className: "tb-b-heading", children: _nullishCoalesce(_nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _18 => _18("text")]), () => ( str(props.text))), () => ( "")) })
867
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tag, { className: "tb-b-heading", children: _nullishCoalesce(_nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _49 => _49("text")]), () => ( str(props.text))), () => ( "")) })
387
868
  ] });
388
869
  }
389
870
 
@@ -436,11 +917,11 @@ function Image({ node, props, mediaOrigin, editMode }) {
436
917
  const alt = decorative ? "" : typeof props.alt === "string" ? props.alt : "";
437
918
  const asset = isFrozenAsset(props.image) ? props.image : void 0;
438
919
  const image = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AssetImage, { asset, mediaOrigin, alt, className: "tb-b-img", sizes: "(max-width: 767px) 100vw, 50vw" });
439
- const shown = asset !== void 0 && _builderschema.safeUrl.call(void 0, asset.url, "src", { mediaOrigin }) !== null;
920
+ const shown2 = asset !== void 0 && _builderschema.safeUrl.call(void 0, asset.url, "src", { mediaOrigin }) !== null;
440
921
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
441
922
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
442
923
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetStyle, { css: enumCss(node, RULES2) }),
443
- shown ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-image", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-image-box", children: href === null ? image : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href, children: image }) }) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: asset === void 0 ? "Choose an image" : "Image unavailable" })
924
+ shown2 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-image", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-b-image-box", children: href === null ? image : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href, children: image }) }) }) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Placeholder, { editMode, children: asset === void 0 ? "Choose an image" : "Image unavailable" })
444
925
  ] });
445
926
  }
446
927
 
@@ -450,12 +931,12 @@ function Image({ node, props, mediaOrigin, editMode }) {
450
931
 
451
932
  function Logo({ props, mediaOrigin, editMode }) {
452
933
  const design = _ui.useSiteDesign.call(void 0, );
453
- const scheme = _nullishCoalesce(_optionalChain([design, 'optionalAccess', _19 => _19.theme, 'optionalAccess', _20 => _20.colorScheme]), () => ( "auto"));
934
+ const scheme = _nullishCoalesce(_optionalChain([design, 'optionalAccess', _50 => _50.theme, 'optionalAccess', _51 => _51.colorScheme]), () => ( "auto"));
454
935
  const src = (url) => url === void 0 ? void 0 : _nullishCoalesce(_builderschema.safeUrl.call(void 0, url, "src", { mediaOrigin }), () => ( void 0));
455
- const light = src(_optionalChain([design, 'optionalAccess', _21 => _21.brand, 'optionalAccess', _22 => _22.logo, 'optionalAccess', _23 => _23.light]));
456
- const dark = src(_optionalChain([design, 'optionalAccess', _24 => _24.brand, 'optionalAccess', _25 => _25.logo, 'optionalAccess', _26 => _26.dark]));
936
+ const light = src(_optionalChain([design, 'optionalAccess', _52 => _52.brand, 'optionalAccess', _53 => _53.logo, 'optionalAccess', _54 => _54.light]));
937
+ const dark = src(_optionalChain([design, 'optionalAccess', _55 => _55.brand, 'optionalAccess', _56 => _56.logo, 'optionalAccess', _57 => _57.dark]));
457
938
  const main = scheme === "dark" ? _nullishCoalesce(dark, () => ( light)) : _nullishCoalesce(light, () => ( dark));
458
- const name = str(_optionalChain([design, 'optionalAccess', _27 => _27.brand, 'optionalAccess', _28 => _28.storeName]));
939
+ const name = str(_optionalChain([design, 'optionalAccess', _58 => _58.brand, 'optionalAccess', _59 => _59.storeName]));
459
940
  const href = _nullishCoalesce(hrefOf(props.link, mediaOrigin), () => ( "/"));
460
941
  const alt = _nullishCoalesce(name, () => ( ""));
461
942
  let content = null;
@@ -482,12 +963,12 @@ function Logo({ props, mediaOrigin, editMode }) {
482
963
  var LAYOUTS = ["horizontal", "vertical", "drawer-on-phone"];
483
964
  var MAX_DEPTH = 3;
484
965
  function List({ items, mediaOrigin, depth = 0, id, onNavigate }) {
485
- const shown = items.flatMap((item) => {
966
+ const shown2 = items.flatMap((item) => {
486
967
  const href = _builderschema.safeUrl.call(void 0, item.href, "href", { mediaOrigin });
487
968
  return href === null ? [] : [{ item, href }];
488
969
  });
489
- if (shown.length === 0) return null;
490
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...id === void 0 ? {} : { id }, ...onNavigate === void 0 ? {} : { onClick: onNavigate }, children: shown.map(({ item, href }, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { children: [
970
+ if (shown2.length === 0) return null;
971
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "ul", { ...id === void 0 ? {} : { id }, ...onNavigate === void 0 ? {} : { onClick: onNavigate }, children: shown2.map(({ item, href }, index) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "li", { children: [
491
972
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "a", { href, children: item.label }),
492
973
  depth + 1 < MAX_DEPTH && item.children !== void 0 && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, List, { items: item.children, mediaOrigin, depth: depth + 1 })
493
974
  ] }, `${String(index)}:${href}`)) });
@@ -499,9 +980,9 @@ function Menu({ props, mediaOrigin, editMode }) {
499
980
  const [open, setOpen] = _react.useState.call(void 0, false);
500
981
  const name = _nullishCoalesce(str(props.menu), () => ( "header"));
501
982
  const layout = oneOf(props.layout, LAYOUTS, "horizontal");
502
- const menus = _optionalChain([design, 'optionalAccess', _29 => _29.menus]);
983
+ const menus = _optionalChain([design, 'optionalAccess', _60 => _60.menus]);
503
984
  const items = menus !== void 0 && Object.hasOwn(menus, name) ? menus[name] : void 0;
504
- const strings = _optionalChain([design, 'optionalAccess', _30 => _30.strings]);
985
+ const strings = _optionalChain([design, 'optionalAccess', _61 => _61.strings]);
505
986
  const label = _nullishCoalesce((strings !== void 0 && Object.hasOwn(strings, "nav.menu") ? str(strings["nav.menu"]) : void 0), () => ( _builderschema.SITE_STRING_DEFAULTS["nav.menu"]));
506
987
  if (items === void 0 || items.length === 0) {
507
988
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
@@ -513,7 +994,7 @@ function Menu({ props, mediaOrigin, editMode }) {
513
994
  const onKeyDown = (event) => {
514
995
  if (event.key === "Escape" && open) {
515
996
  setOpen(false);
516
- _optionalChain([toggle, 'access', _31 => _31.current, 'optionalAccess', _32 => _32.focus, 'call', _33 => _33()]);
997
+ _optionalChain([toggle, 'access', _62 => _62.current, 'optionalAccess', _63 => _63.focus, 'call', _64 => _64()]);
517
998
  }
518
999
  };
519
1000
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
@@ -675,7 +1156,7 @@ function parseRichText(source, mediaOrigin) {
675
1156
  const closing = html[i + 1] === "/";
676
1157
  const nameStart = i + (closing ? 2 : 1);
677
1158
  TAG_NAME.lastIndex = nameStart;
678
- const raw = _optionalChain([TAG_NAME, 'access', _34 => _34.exec, 'call', _35 => _35(html), 'optionalAccess', _36 => _36[0], 'optionalAccess', _37 => _37.toLowerCase, 'call', _38 => _38()]);
1159
+ const raw = _optionalChain([TAG_NAME, 'access', _65 => _65.exec, 'call', _66 => _66(html), 'optionalAccess', _67 => _67[0], 'optionalAccess', _68 => _68.toLowerCase, 'call', _69 => _69()]);
679
1160
  if (raw === void 0) {
680
1161
  if (html[i + 1] === "!" || html[i + 1] === "?") {
681
1162
  const close = html.indexOf(">", i);
@@ -760,7 +1241,7 @@ function RichText({
760
1241
  // src/basics/text.tsx
761
1242
 
762
1243
  function Text({ props, mediaOrigin, editMode, inlineEdit }) {
763
- const editor = _nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _39 => _39("html")]), () => ( null));
1244
+ const editor = _nullishCoalesce(_optionalChain([inlineEdit, 'optionalCall', _70 => _70("html")]), () => ( null));
764
1245
  return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
765
1246
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, BasicStyles, {}),
766
1247
  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 })
@@ -782,7 +1263,7 @@ function parseVideoUrl(input) {
782
1263
  let url;
783
1264
  try {
784
1265
  url = new URL(input.trim());
785
- } catch (e4) {
1266
+ } catch (e5) {
786
1267
  return null;
787
1268
  }
788
1269
  if (url.protocol !== "https:" || url.username !== "" || url.password !== "" || url.port !== "" && url.port !== "443") return null;
@@ -840,7 +1321,8 @@ var BASIC_COMPONENTS = {
840
1321
  "basic.logo": Logo,
841
1322
  "basic.menu": Menu,
842
1323
  "basic.announcement": Announcement,
843
- "basic.copyright": Copyright
1324
+ "basic.copyright": Copyright,
1325
+ "basic.countdown": Countdown
844
1326
  };
845
1327
  var widgets = _builderschema.BASIC_WIDGET_DEFINITIONS.flatMap(
846
1328
  (definition) => Object.hasOwn(BASIC_COMPONENTS, definition.type) ? [{ ...definition, Component: BASIC_COMPONENTS[definition.type] }] : []
@@ -891,101 +1373,560 @@ var fitsBudget = (ast, limit = MAX_RENDERED_NODES) => _builderschema.templateWei
891
1373
 
892
1374
 
893
1375
 
894
- // src/css-compiler.ts
895
1376
 
896
1377
 
897
1378
 
898
1379
 
1380
+ // src/code/code-widget.tsx
899
1381
 
900
1382
 
901
1383
 
1384
+ // src/custom/custom-css.tsx
902
1385
 
903
1386
 
904
- var TABLET_QUERY = "(max-width:1024px)";
905
- var PHONE_QUERY = "(max-width:767px)";
906
- var SAFE_VALUE = /^[A-Za-z0-9#%.,()\-+*/_: ]{1,200}$/;
907
- var URL_QUOTE_SAFE = /^[^\s"'\\()<>{};]+$/;
908
- var ID_RE2 = /^[a-z0-9]{8,24}$/;
909
- var PROPERTY_RE = /^--(?:b|w|tb)-[A-Za-z][A-Za-z0-9-]{0,39}$/;
910
- var COLOR_TOKEN = /* @__PURE__ */ new Set([
911
- "primary",
912
- "primary-foreground",
913
- "background",
914
- "surface",
915
- "foreground",
916
- "muted",
917
- "muted-foreground",
918
- "border",
919
- "border-control",
920
- "accent",
921
- "sale",
922
- "success",
923
- "warning",
924
- "danger"
925
- ]);
926
- var SPACING_TOKEN = /* @__PURE__ */ new Set(["xs", "s", "m", "l", "xl", "2xl"]);
927
- var SIZE_TOKEN = /* @__PURE__ */ new Set(["xs", "s", "m", "l", "xl", "2xl", "3xl"]);
928
- var ALIGN = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]);
929
- var SELECT_OPTION = /^[a-z0-9][a-z0-9:-]{0,39}$/;
930
- var px = (value) => `${String(Math.round(value * 100) / 100)}px`;
931
- function colour(value) {
932
- if (typeof value !== "string") return null;
933
- if (value.startsWith("token:")) {
934
- const name = value.slice(6);
935
- return COLOR_TOKEN.has(name) ? `var(--tb-color-${name})` : null;
936
- }
937
- return /^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/.test(value) ? value : null;
1387
+ function scopedCss(source, type) {
1388
+ if (source === void 0 || source === "") return "";
1389
+ if (typeof source !== "string") return null;
1390
+ const result = _builderschema.sanitizeWidgetCss.call(void 0, source, type);
1391
+ return result.ok ? result.css : null;
938
1392
  }
939
- function spacing(value) {
940
- if (value === "none") return "0px";
941
- if (typeof value === "string") return SPACING_TOKEN.has(value) ? `var(--tb-space-${value})` : null;
942
- return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 400 ? px(value) : null;
1393
+ function CustomCss({ css }) {
1394
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetStyle, { css });
943
1395
  }
944
- function fontSize(value) {
945
- if (typeof value === "string") return SIZE_TOKEN.has(value) ? `var(--tb-text-${value})` : null;
946
- return typeof value === "number" && Number.isFinite(value) && value >= 8 && value <= 200 ? px(value) : null;
1396
+
1397
+ // src/custom/interpreter.tsx
1398
+
1399
+
1400
+
1401
+
1402
+
1403
+
1404
+
1405
+
1406
+
1407
+
1408
+
1409
+
1410
+
1411
+
1412
+ var MAX_OUTPUT_CHARS = 1e6;
1413
+ var MAX_ATTR_CHARS = 2e3;
1414
+ var MAX_DEPTH3 = 24;
1415
+ function newEnv(env) {
1416
+ return { ...env, charsLeft: MAX_OUTPUT_CHARS, stopped: false };
947
1417
  }
948
- function cssValue(control, value) {
949
- switch (control) {
950
- case "color":
951
- return colour(value);
952
- case "spacing":
953
- return spacing(value);
954
- case "font-size":
955
- return fontSize(value);
956
- case "alignment":
957
- return typeof value === "string" && ALIGN.has(value) ? value : null;
958
- case "number":
959
- return typeof value === "number" && Number.isFinite(value) ? String(value) : null;
960
- case "toggle":
961
- return typeof value === "boolean" ? value ? "1" : "0" : null;
962
- case "select":
963
- return typeof value === "string" && SELECT_OPTION.test(value) ? value : null;
964
- default:
965
- return null;
966
- }
1418
+ var BLOCKED = /* @__PURE__ */ new Set([
1419
+ "__proto__",
1420
+ "constructor",
1421
+ "prototype",
1422
+ ...Object.getOwnPropertyNames(Object.prototype)
1423
+ ]);
1424
+ var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1425
+ function step(value, key) {
1426
+ if (BLOCKED.has(key) || !isPlainObject(value) || !Object.hasOwn(value, key)) return void 0;
1427
+ return value[key];
967
1428
  }
968
- function put(out, property, value) {
969
- if (value === null) return;
970
- if (!PROPERTY_RE.test(property) || !SAFE_VALUE.test(value)) {
971
- if (isDevelopment()) warnOnce(`css:${property}`, `Dropped an unsafe value for ${property}`);
972
- return;
1429
+ function lookup(path, env, scope) {
1430
+ const [root, ...rest] = path;
1431
+ if (root === void 0) return void 0;
1432
+ if (root === "locale") return rest.length === 0 ? env.locale : void 0;
1433
+ let value;
1434
+ if (root === "settings") value = rest.length === 0 ? void 0 : env.settings;
1435
+ else if (root === "data") value = rest.length === 0 ? void 0 : env.data;
1436
+ else if (scope.has(root)) value = scope.get(root);
1437
+ else return void 0;
1438
+ for (const key of rest) {
1439
+ value = step(value, key);
1440
+ if (value === void 0) return void 0;
973
1441
  }
974
- out.set(property, value);
1442
+ return value;
975
1443
  }
976
- var COMMON_BY_KEY = new Map(_builderschema.COMMON_WIDGET_SETTINGS.map((field) => [field.key, field]));
977
- function widgetDecls(node, device, registry) {
978
- const out = /* @__PURE__ */ new Map();
979
- const def = registry.widget(node.type, node.v);
980
- if (def === void 0) return out;
981
- const fields = new Map([...COMMON_BY_KEY, ...def.settings.map((f) => [f.key, f])]);
982
- const defaults = {};
983
- for (const field of fields.values()) if (field.output === "css") defaults[field.key] = field.default;
984
- const resolved = _builderschema.resolveResponsive.call(void 0, { ...defaults, ...node.props }, node.responsive, device);
985
- const prefix = node.type.startsWith("custom.") ? "--w-" : "--b-";
986
- for (const field of fields.values()) {
987
- if (field.output !== "css") continue;
988
- const raw = resolved[field.key];
1444
+ function truthy(value) {
1445
+ if (value === null || value === void 0 || value === false || value === "") return false;
1446
+ if (typeof value === "number") return value !== 0 && !Number.isNaN(value);
1447
+ if (Array.isArray(value)) return value.length > 0;
1448
+ return true;
1449
+ }
1450
+ function asText(value) {
1451
+ if (typeof value === "string") return value;
1452
+ if (typeof value === "number" && Number.isFinite(value)) return String(value);
1453
+ return "";
1454
+ }
1455
+ function filtered(value, filters) {
1456
+ let text2 = asText(value);
1457
+ for (const filter of filters) {
1458
+ switch (filter.name) {
1459
+ case "upper":
1460
+ text2 = text2.toUpperCase();
1461
+ break;
1462
+ case "lower":
1463
+ text2 = text2.toLowerCase();
1464
+ break;
1465
+ case "truncate": {
1466
+ const chars = Array.from(text2);
1467
+ if (chars.length > filter.n) text2 = `${chars.slice(0, filter.n).join("")}\u2026`;
1468
+ break;
1469
+ }
1470
+ case "default":
1471
+ if (text2 === "") text2 = filter.text;
1472
+ break;
1473
+ }
1474
+ }
1475
+ return text2;
1476
+ }
1477
+ function spend(env, count) {
1478
+ if (count > env.charsLeft) {
1479
+ env.stopped = true;
1480
+ return false;
1481
+ }
1482
+ env.charsLeft -= count;
1483
+ return true;
1484
+ }
1485
+ var ELEMENTS = new Set(_builderschema.ALLOWED_ELEMENTS);
1486
+ var VOIDS = new Set(_builderschema.VOID_ELEMENTS);
1487
+ var ROLES = new Set(_builderschema.ALLOWED_ROLES);
1488
+ function attrAllowed(tag, name) {
1489
+ if (_builderschema.DATA_ATTR_RE.test(name)) return !name.startsWith(_builderschema.RESERVED_DATA_PREFIX);
1490
+ const own = Object.hasOwn(_builderschema.ALLOWED_ATTRS, tag) ? _builderschema.ALLOWED_ATTRS[tag] : void 0;
1491
+ return (_nullishCoalesce(_optionalChain([_builderschema.ALLOWED_ATTRS, 'access', _71 => _71["*"], 'optionalAccess', _72 => _72.includes, 'call', _73 => _73(name)]), () => ( false))) || (_nullishCoalesce(_optionalChain([own, 'optionalAccess', _74 => _74.includes, 'call', _75 => _75(name)]), () => ( false)));
1492
+ }
1493
+ function attrText(attr, env, scope) {
1494
+ return attr.value.map((part) => part.type === "text" ? part.value : filtered(lookup(part.path, env, scope), part.filters)).join("");
1495
+ }
1496
+ function urlSource(attr, env, scope) {
1497
+ const [only] = attr.value;
1498
+ if (attr.value.length !== 1 || only === void 0 || only.type !== "output") return attrText(attr, env, scope);
1499
+ const value = lookup(only.path, env, scope);
1500
+ if (isPlainObject(value)) {
1501
+ if (typeof value.href === "string") return value.href;
1502
+ if (typeof value.url === "string") return value.url;
1503
+ return null;
1504
+ }
1505
+ return value;
1506
+ }
1507
+ function attrProp(tag, attr, env, scope) {
1508
+ const { name } = attr;
1509
+ if (!attrAllowed(tag, name)) return null;
1510
+ if (name === "href" || name === "src") {
1511
+ const safe = _builderschema.safeUrl.call(void 0, urlSource(attr, env, scope), name, { mediaOrigin: env.mediaOrigin });
1512
+ return safe === null || !spend(env, safe.length) ? null : [name, safe];
1513
+ }
1514
+ const text2 = attrText(attr, env, scope);
1515
+ if (text2 === "" || text2.length > MAX_ATTR_CHARS) return null;
1516
+ let value = text2;
1517
+ if (name === "class") {
1518
+ const tokens = text2.split(/\s+/).filter((token) => _builderschema.CLASS_TOKEN_RE.test(token) && !_builderschema.isReservedClass.call(void 0, token));
1519
+ if (tokens.length === 0) return null;
1520
+ value = tokens.join(" ");
1521
+ } else if (name === "role") {
1522
+ if (!ROLES.has(text2)) return null;
1523
+ } else if (name === "aria-hidden") {
1524
+ if (text2 !== "true" && text2 !== "false") return null;
1525
+ }
1526
+ if (!spend(env, value.length)) return null;
1527
+ return [name === "class" ? "className" : name, value];
1528
+ }
1529
+ function renderElement(node, env, scope, depth, key) {
1530
+ const tag = node.tag;
1531
+ if (!ELEMENTS.has(tag)) return null;
1532
+ const props = { key };
1533
+ for (const attr of node.attrs) {
1534
+ const prop = attrProp(tag, attr, env, scope);
1535
+ if (prop !== null) props[prop[0]] = prop[1];
1536
+ }
1537
+ if (VOIDS.has(tag)) return _react.createElement.call(void 0, tag, props);
1538
+ return _react.createElement.call(void 0, tag, props, renderNodes(node.children, env, scope, depth + 1));
1539
+ }
1540
+ function renderNodes(nodes, env, scope, depth) {
1541
+ const out = [];
1542
+ if (depth > MAX_DEPTH3) return out;
1543
+ for (const node of nodes) {
1544
+ if (env.stopped) break;
1545
+ if (!env.budget.take(1) || node.type === "element" && !env.budget.take(node.attrs.reduce((n, a) => n + a.value.length, 0))) {
1546
+ env.stopped = true;
1547
+ break;
1548
+ }
1549
+ switch (node.type) {
1550
+ case "text":
1551
+ if (spend(env, node.value.length)) out.push(node.value);
1552
+ break;
1553
+ case "output": {
1554
+ const text2 = filtered(lookup(node.path, env, scope), node.filters);
1555
+ if (text2 !== "" && spend(env, text2.length)) out.push(text2);
1556
+ break;
1557
+ }
1558
+ case "if": {
1559
+ const branch = truthy(lookup(node.path, env, scope)) ? node.then : node.else;
1560
+ out.push(/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderNodes(branch, env, scope, depth + 1) }, out.length));
1561
+ break;
1562
+ }
1563
+ case "unless":
1564
+ if (!truthy(lookup(node.path, env, scope))) {
1565
+ out.push(/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderNodes(node.body, env, scope, depth + 1) }, out.length));
1566
+ }
1567
+ break;
1568
+ case "each": {
1569
+ const list = lookup(node.path, env, scope);
1570
+ if (!Array.isArray(list)) break;
1571
+ const count = Math.min(list.length, _builderschema.EACH_ITERATION_CAP);
1572
+ for (let i = 0; i < count && !env.stopped; i += 1) {
1573
+ const inner = new Map(scope).set(node.as, list[i]);
1574
+ out.push(/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderNodes(node.body, env, inner, depth + 1) }, out.length));
1575
+ }
1576
+ break;
1577
+ }
1578
+ case "element":
1579
+ out.push(renderElement(node, env, scope, depth, out.length));
1580
+ break;
1581
+ }
1582
+ }
1583
+ return out;
1584
+ }
1585
+ function renderTemplate(ast, env) {
1586
+ return renderNodes(ast, env, /* @__PURE__ */ new Map(), 0);
1587
+ }
1588
+
1589
+ // src/custom/template-widget.tsx
1590
+
1591
+
1592
+
1593
+ var componentWeights = /* @__PURE__ */ new WeakMap();
1594
+ var compiled = /* @__PURE__ */ new WeakMap();
1595
+ function compileTemplate(snapshot, registry) {
1596
+ let perRegistry = compiled.get(snapshot);
1597
+ if (perRegistry === void 0) {
1598
+ perRegistry = /* @__PURE__ */ new WeakMap();
1599
+ compiled.set(snapshot, perRegistry);
1600
+ }
1601
+ if (perRegistry.has(registry)) return _nullishCoalesce(perRegistry.get(registry), () => ( null));
1602
+ const result = compile(snapshot, registry);
1603
+ perRegistry.set(registry, result);
1604
+ return result;
1605
+ }
1606
+ function compile(snapshot, registry) {
1607
+ const label = `${snapshot.type}@${String(snapshot.v)}`;
1608
+ const refuse = (why) => {
1609
+ warnOnce(`template:${label}`, `${label} was refused (${why}); rendering nothing for it`);
1610
+ return null;
1611
+ };
1612
+ if (snapshot.kind !== "template") return refuse("not a template widget");
1613
+ const source = snapshot.template;
1614
+ if (typeof source !== "string") return refuse("no template source");
1615
+ const parsed2 = _builderschema.parseTemplate.call(void 0, source);
1616
+ if (!parsed2.ok) return refuse(`template does not parse: ${_nullishCoalesce(_optionalChain([parsed2, 'access', _76 => _76.issues, 'access', _77 => _77[0], 'optionalAccess', _78 => _78.message]), () => ( "invalid"))}`);
1617
+ const data = snapshot.data;
1618
+ const issues = _builderschema.validateTemplate.call(void 0, parsed2.ast, {
1619
+ settings: snapshot.settings,
1620
+ data: typeof data === "object" && data !== null ? data : {},
1621
+ sources: registry.sources()
1622
+ });
1623
+ if (issues.length > 0) return refuse(`template does not validate: ${_nullishCoalesce(_optionalChain([issues, 'access', _79 => _79[0], 'optionalAccess', _80 => _80.message]), () => ( "invalid"))}`);
1624
+ if (!fitsBudget(parsed2.ast)) return refuse(`it can render more than ${String(_builderschema.MAX_TEMPLATE_WEIGHT)} nodes`);
1625
+ const css = scopedCss(snapshot.css, snapshot.type);
1626
+ if (css === null) return refuse("its css does not pass the sanitiser");
1627
+ return { ast: parsed2.ast, css, weight: _builderschema.templateWeight.call(void 0, parsed2.ast) };
1628
+ }
1629
+ function TemplateBody({ snapshot, registry, props, data, locale, mediaOrigin, budget }) {
1630
+ const template = compileTemplate(snapshot, registry);
1631
+ if (template === null) return null;
1632
+ const env = newEnv({ settings: props, data, locale, mediaOrigin, budget: _nullishCoalesce(budget, () => ( new RenderBudget())) });
1633
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1634
+ template.css === "" ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomCss, { css: template.css }),
1635
+ renderTemplate(template.ast, env)
1636
+ ] });
1637
+ }
1638
+ function TemplateWidget(props) {
1639
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PartBoundary, { label: `${props.snapshot.type}@${String(props.snapshot.v)}`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TemplateBody, { ...props }) }) });
1640
+ }
1641
+
1642
+ // src/code/leave.ts
1643
+
1644
+
1645
+ // src/code/routes.ts
1646
+ 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;
1647
+ var DEFAULT_CATALOG_ROUTES = [
1648
+ "/p/{handle}",
1649
+ "/c/{handle}",
1650
+ "/collections/{handle}",
1651
+ "/tags/{tag}",
1652
+ "/search",
1653
+ "/shop"
1654
+ ];
1655
+ function normalizePath(pathname) {
1656
+ const bare = _nullishCoalesce(pathname.split(/[?#]/, 1)[0], () => ( ""));
1657
+ let decoded2 = bare;
1658
+ try {
1659
+ for (let i = 0; i < 3; i++) {
1660
+ let next;
1661
+ try {
1662
+ next = decodeURIComponent(decoded2);
1663
+ } catch (error) {
1664
+ if (i === 0) throw error;
1665
+ break;
1666
+ }
1667
+ if (next === decoded2) break;
1668
+ decoded2 = next;
1669
+ }
1670
+ } catch (e6) {
1671
+ return null;
1672
+ }
1673
+ if (decoded2.includes("\0")) return null;
1674
+ const flat = decoded2.replace(/\\/g, "/");
1675
+ if (!flat.startsWith("/")) return null;
1676
+ const out = [];
1677
+ for (const segment of flat.split("/")) {
1678
+ if (segment === "" || segment === ".") continue;
1679
+ if (segment === "..") out.pop();
1680
+ else out.push(segment);
1681
+ }
1682
+ return `/${out.join("/")}`;
1683
+ }
1684
+ var escapeRegExp = (text2) => text2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1685
+ var compiled2 = /* @__PURE__ */ new Map();
1686
+ var MAX_COMPILED = 64;
1687
+ function matcherOf(template) {
1688
+ const known = compiled2.get(template);
1689
+ if (known !== void 0) return known;
1690
+ let regex = null;
1691
+ if (template.startsWith("/")) {
1692
+ const pattern = template.split(/(\{[A-Za-z][A-Za-z0-9]*\})/).map((part) => /^\{[A-Za-z][A-Za-z0-9]*\}$/.test(part) ? "[^/]+" : escapeRegExp(part)).join("").replace(/\/+$/, "");
1693
+ regex = new RegExp(`^${pattern === "" ? "/" : pattern}$`);
1694
+ }
1695
+ if (compiled2.size >= MAX_COMPILED) compiled2.clear();
1696
+ compiled2.set(template, regex);
1697
+ return regex;
1698
+ }
1699
+ var matchesTemplate = (path, template) => _nullishCoalesce(_optionalChain([matcherOf, 'call', _81 => _81(template), 'optionalAccess', _82 => _82.test, 'call', _83 => _83(path)]), () => ( false));
1700
+ function isCodeRoute(pathname, routes) {
1701
+ if (pathname === void 0) return false;
1702
+ const path = normalizePath(pathname);
1703
+ if (path === null) return false;
1704
+ if (path.split("/").some((segment) => CODE_ROUTE_DENY.test(segment))) return false;
1705
+ if (path === "/") return true;
1706
+ return [routes.page, ..._nullishCoalesce(routes.catalog, () => ( DEFAULT_CATALOG_ROUTES))].some(
1707
+ (template) => matchesTemplate(path, template)
1708
+ );
1709
+ }
1710
+
1711
+ // src/code/leave.ts
1712
+ var emitted = false;
1713
+ function markCodeEmitted() {
1714
+ emitted = true;
1715
+ }
1716
+
1717
+ // src/code/code-widget.tsx
1718
+
1719
+ var SHA256_HEX = /^[0-9a-f]{64}$/;
1720
+ var CUSTOM_TYPE = /^custom\.[a-z][a-z0-9-]{0,63}$/;
1721
+ var SCRIPT_ORIGIN = /^https:\/\/[a-z0-9]([a-z0-9.-]*[a-z0-9])?(:[0-9]{1,5})?$/i;
1722
+ var SITE_ID = /^[A-Za-z0-9_-]{1,64}$/;
1723
+ var MAX_INPUT_CHARS = 2e5;
1724
+ var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
1725
+ var checked = /* @__PURE__ */ new WeakMap();
1726
+ function check(raw, registry) {
1727
+ let perRegistry = checked.get(raw);
1728
+ if (perRegistry === void 0) {
1729
+ perRegistry = /* @__PURE__ */ new WeakMap();
1730
+ checked.set(raw, perRegistry);
1731
+ }
1732
+ const known = perRegistry.get(registry);
1733
+ if (known !== void 0) return known;
1734
+ const result = verify(raw, registry);
1735
+ perRegistry.set(registry, result);
1736
+ return result;
1737
+ }
1738
+ function verify(raw, registry) {
1739
+ const snapshot = raw;
1740
+ const label = `${String(snapshot.type)}@${String(snapshot.v)}`;
1741
+ if (snapshot.disabled === true) return { status: "disabled" };
1742
+ const refuse = (why) => {
1743
+ warnOnce(`code:${label}`, `Code widget ${label} was refused (${why}); rendering nothing for it`);
1744
+ return { status: "invalid" };
1745
+ };
1746
+ if (snapshot.kind !== "code") return refuse("not a code widget");
1747
+ if (typeof snapshot.type !== "string" || !CUSTOM_TYPE.test(snapshot.type)) return refuse("bad type");
1748
+ if (snapshot.disabled !== void 0) return refuse("bad disabled flag");
1749
+ if ("js" in snapshot) return refuse("it carries a script");
1750
+ if (typeof snapshot.jsHash !== "string" || !SHA256_HEX.test(snapshot.jsHash)) return refuse("bad script hash");
1751
+ if (typeof snapshot.html !== "string" || snapshot.html.length > _builderschema.LIMITS.codeHtmlBytes) return refuse("bad html");
1752
+ if (typeof snapshot.css !== "string" || snapshot.css.length > _builderschema.LIMITS.codeCssBytes) return refuse("bad css");
1753
+ const template = { ...snapshot, kind: "template", template: snapshot.html };
1754
+ if (compileTemplate(template, registry) === null) return refuse("its markup or css does not validate");
1755
+ return { status: "ok", snapshot: raw, template };
1756
+ }
1757
+ function codeScriptUrl(runtime, jsHash) {
1758
+ if (!isRecord2(runtime) || runtime.enabled !== true) return null;
1759
+ const { scriptOrigin, codeSiteId } = runtime;
1760
+ if (typeof scriptOrigin !== "string" || !SCRIPT_ORIGIN.test(scriptOrigin)) return null;
1761
+ if (typeof codeSiteId !== "string" || !SITE_ID.test(codeSiteId)) return null;
1762
+ if (!SHA256_HEX.test(jsHash)) return null;
1763
+ return `${scriptOrigin}/v1/code/${codeSiteId}/${jsHash}.js`;
1764
+ }
1765
+ function jsonForScript(value) {
1766
+ return JSON.stringify(value).replace(/[<>&\u2028\u2029]/g, (c) => `\\u${c.charCodeAt(0).toString(16).padStart(4, "0")}`);
1767
+ }
1768
+ var BADGE = {
1769
+ display: "inline-block",
1770
+ margin: 4,
1771
+ padding: "2px 8px",
1772
+ borderRadius: 4,
1773
+ font: "600 11px/1.5 system-ui, sans-serif",
1774
+ letterSpacing: "0.02em",
1775
+ background: "#1f2937",
1776
+ color: "#fff"
1777
+ };
1778
+ function runs(props, jsHash) {
1779
+ const { code, edit, interactive } = props;
1780
+ if (edit !== void 0 || interactive === false || code === void 0 || code.preview === true) return null;
1781
+ if (!isCodeRoute(code.pathname, code.routes)) return null;
1782
+ return codeScriptUrl(code.runtime, jsHash);
1783
+ }
1784
+ function CodeWidget(props) {
1785
+ const { node, snapshot, registry, edit, anchor, copyAnchor, entrance } = props;
1786
+ const result = check(snapshot, registry);
1787
+ if (result.status !== "ok") {
1788
+ return result.status === "disabled" && edit !== void 0 ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, NodeWrapper, { id: node.id, part: "widget", type: node.type, className: "tb-w", edit, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-missing", children: "This code widget is disabled" }) }) : null;
1789
+ }
1790
+ const template = compileTemplate(result.template, registry);
1791
+ const src = runs(props, result.snapshot.jsHash);
1792
+ if (src !== null) markCodeEmitted();
1793
+ const env = newEnv({ settings: props.props, data: props.data, locale: props.locale, mediaOrigin: props.mediaOrigin, budget: new RenderBudget() });
1794
+ const label = `${node.type}@${String(node.v)}`;
1795
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
1796
+ NodeWrapper,
1797
+ {
1798
+ id: node.id,
1799
+ part: "widget",
1800
+ type: node.type,
1801
+ custom: true,
1802
+ edit,
1803
+ className: "tb-w",
1804
+ anchor,
1805
+ copyAnchor,
1806
+ entrance,
1807
+ attributes: src === null ? { "data-b-code-inert": "" } : { "data-b-code": result.snapshot.jsHash },
1808
+ children: [
1809
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PartBoundary, { label, children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.Suspense, { fallback: null, children: [
1810
+ template.css === "" ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomCss, { css: template.css }),
1811
+ renderTemplate(template.ast, env)
1812
+ ] }) }),
1813
+ src === null && (edit !== void 0 || _optionalChain([props, 'access', _84 => _84.code, 'optionalAccess', _85 => _85.preview]) === true) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { "data-b-code-badge": "", style: BADGE, children: "Runs on your store" }) : null,
1814
+ src === null ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CodeInput, { props: props.props, data: props.data, label }),
1815
+ src === null ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "script", { async: true, src })
1816
+ ]
1817
+ }
1818
+ );
1819
+ }
1820
+ function CodeInput({ props, data, label }) {
1821
+ let json = "";
1822
+ try {
1823
+ json = jsonForScript({ props, data });
1824
+ if (json.length > MAX_INPUT_CHARS) {
1825
+ warnOnce(`code-input:${label}`, `The data of ${label} is too large for its code input; it gets its props only`);
1826
+ json = jsonForScript({ props, data: {} });
1827
+ }
1828
+ } catch (e7) {
1829
+ warnOnce(`code-input:${label}`, `The input of ${label} cannot be written as JSON; it gets none`);
1830
+ json = jsonForScript({ props: {}, data: {} });
1831
+ }
1832
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "script", { type: "application/json", "data-b-code-input": "", children: json });
1833
+ }
1834
+
1835
+ // src/css-compiler.ts
1836
+
1837
+
1838
+
1839
+
1840
+
1841
+
1842
+
1843
+
1844
+
1845
+ var TABLET_QUERY = "(max-width:1024px)";
1846
+ var PHONE_QUERY = "(max-width:767px)";
1847
+ var SAFE_VALUE = /^[A-Za-z0-9#%.,()\-+*/_: ]{1,200}$/;
1848
+ var URL_QUOTE_SAFE = /^[^\s"'\\()<>{};]+$/;
1849
+ var ID_RE2 = /^[a-z0-9]{8,24}(-[a-z0-9]{8,24})?$/;
1850
+ var PROPERTY_RE = /^--(?:b|w|tb)-[A-Za-z][A-Za-z0-9-]{0,39}$/;
1851
+ var COLOR_TOKEN = /* @__PURE__ */ new Set([
1852
+ "primary",
1853
+ "primary-foreground",
1854
+ "background",
1855
+ "surface",
1856
+ "foreground",
1857
+ "muted",
1858
+ "muted-foreground",
1859
+ "border",
1860
+ "border-control",
1861
+ "accent",
1862
+ "sale",
1863
+ "success",
1864
+ "warning",
1865
+ "danger"
1866
+ ]);
1867
+ var SPACING_TOKEN = /* @__PURE__ */ new Set(["xs", "s", "m", "l", "xl", "2xl"]);
1868
+ var SIZE_TOKEN = /* @__PURE__ */ new Set(["xs", "s", "m", "l", "xl", "2xl", "3xl"]);
1869
+ var ALIGN = /* @__PURE__ */ new Set(["left", "center", "right", "justify"]);
1870
+ var SELECT_OPTION = /^[a-z0-9][a-z0-9:-]{0,39}$/;
1871
+ var px = (value) => `${String(Math.round(value * 100) / 100)}px`;
1872
+ function colour(value) {
1873
+ if (typeof value !== "string") return null;
1874
+ if (value.startsWith("token:")) {
1875
+ const name = value.slice(6);
1876
+ return COLOR_TOKEN.has(name) ? `var(--tb-color-${name})` : null;
1877
+ }
1878
+ return /^#[0-9a-fA-F]{6}(?:[0-9a-fA-F]{2})?$/.test(value) ? value : null;
1879
+ }
1880
+ function spacing(value) {
1881
+ if (value === "none") return "0px";
1882
+ if (typeof value === "string") return SPACING_TOKEN.has(value) ? `var(--tb-space-${value})` : null;
1883
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 && value <= 400 ? px(value) : null;
1884
+ }
1885
+ function fontSize(value) {
1886
+ if (typeof value === "string") return SIZE_TOKEN.has(value) ? `var(--tb-text-${value})` : null;
1887
+ return typeof value === "number" && Number.isFinite(value) && value >= 8 && value <= 200 ? px(value) : null;
1888
+ }
1889
+ function cssValue(control, value) {
1890
+ switch (control) {
1891
+ case "color":
1892
+ return colour(value);
1893
+ case "spacing":
1894
+ return spacing(value);
1895
+ case "font-size":
1896
+ return fontSize(value);
1897
+ case "alignment":
1898
+ return typeof value === "string" && ALIGN.has(value) ? value : null;
1899
+ case "number":
1900
+ return typeof value === "number" && Number.isFinite(value) ? String(value) : null;
1901
+ case "toggle":
1902
+ return typeof value === "boolean" ? value ? "1" : "0" : null;
1903
+ case "select":
1904
+ return typeof value === "string" && SELECT_OPTION.test(value) ? value : null;
1905
+ default:
1906
+ return null;
1907
+ }
1908
+ }
1909
+ function put(out, property, value) {
1910
+ if (value === null) return;
1911
+ if (!PROPERTY_RE.test(property) || !SAFE_VALUE.test(value)) {
1912
+ if (isDevelopment()) warnOnce(`css:${property}`, `Dropped an unsafe value for ${property}`);
1913
+ return;
1914
+ }
1915
+ out.set(property, value);
1916
+ }
1917
+ var COMMON_BY_KEY = new Map(_builderschema.COMMON_WIDGET_SETTINGS.map((field) => [field.key, field]));
1918
+ function widgetDecls(node, device, registry) {
1919
+ const out = /* @__PURE__ */ new Map();
1920
+ const def = registry.widget(node.type, node.v);
1921
+ if (def === void 0) return out;
1922
+ const fields = new Map([...COMMON_BY_KEY, ...def.settings.map((f) => [f.key, f])]);
1923
+ const defaults = {};
1924
+ for (const field of fields.values()) if (field.output === "css") defaults[field.key] = field.default;
1925
+ const resolved = _builderschema.resolveResponsive.call(void 0, { ...defaults, ...node.props }, node.responsive, device);
1926
+ const prefix = node.type.startsWith("custom.") ? "--w-" : "--b-";
1927
+ for (const field of fields.values()) {
1928
+ if (field.output !== "css") continue;
1929
+ const raw = resolved[field.key];
989
1930
  const value = raw === void 0 || _builderschema.validateSettingValue.call(void 0, field, raw) === null ? raw : field.default;
990
1931
  if (value === null || value === void 0) continue;
991
1932
  if (field.key === "hidden") {
@@ -1113,54 +2054,121 @@ function compileResponsiveCss(doc, registry, assets = doc.assets, mediaOrigin =
1113
2054
  return base + (tablet === "" ? "" : `@media ${TABLET_QUERY}{${tablet}}`) + (phone === "" ? "" : `@media ${PHONE_QUERY}{${phone}}`);
1114
2055
  }
1115
2056
 
1116
- // src/node-wrapper.tsx
1117
-
2057
+ // src/interactions/accordion.tsx
1118
2058
 
1119
- var CUSTOM_WIDGET_CONTAINMENT = {
1120
- contain: "layout paint",
1121
- isolation: "isolate",
1122
- overflow: "clip"
1123
- };
1124
- var PART_NAME = {
1125
- section: "builder-section",
1126
- column: "builder-column",
1127
- widget: "builder-widget"
1128
- };
1129
- function NodeWrapper(props) {
1130
- const { id, part, type, className, anchor, custom, missing, edit, children } = props;
1131
- const Tag = _nullishCoalesce(props.as, () => ( "div"));
1132
- const handlers = edit === void 0 ? {} : {
1133
- onClickCapture: (event) => {
1134
- const target = event.target;
1135
- if (_optionalChain([target, 'optionalAccess', _40 => _40.closest, 'optionalCall', _41 => _41("a[href]")]) != null) event.preventDefault();
1136
- },
1137
- onClick: (event) => {
1138
- event.stopPropagation();
1139
- edit.onSelect(id);
1140
- },
1141
- onMouseOver: (event) => {
1142
- event.stopPropagation();
1143
- edit.onHover(id);
2059
+ function Accordion({
2060
+ id,
2061
+ panels,
2062
+ multiple,
2063
+ openFirst
2064
+ }) {
2065
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-accordion", children: panels.map((panel, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2066
+ "details",
2067
+ {
2068
+ className: "tb-acc-item",
2069
+ ...multiple ? {} : { name: `${id}-acc` },
2070
+ ...openFirst && i === 0 ? { open: true } : {},
2071
+ children: [
2072
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "summary", { className: "tb-acc-sum", children: panel.title }),
2073
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-acc-body", children: panel.node })
2074
+ ]
1144
2075
  },
1145
- onMouseLeave: () => edit.onHover(null)
1146
- };
1147
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1148
- Tag,
2076
+ panel.key
2077
+ )) });
2078
+ }
2079
+
2080
+ // src/interactions/carousel.tsx
2081
+
2082
+ function Carousel({
2083
+ panels,
2084
+ autoplayMs,
2085
+ loop
2086
+ }) {
2087
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2088
+ "div",
1149
2089
  {
1150
- className,
1151
- "data-b-id": id,
1152
- "data-throttle-part": PART_NAME[part],
1153
- ...type === void 0 ? {} : { "data-b-type": type },
1154
- ...custom === true && type !== void 0 ? { "data-b-w": type } : {},
1155
- ...missing === true ? { "data-b-missing": "" } : {},
1156
- ...typeof anchor === "string" && _builderschema.ANCHOR_RE.test(anchor) ? { id: anchor } : {},
1157
- ...custom === true ? { style: CUSTOM_WIDGET_CONTAINMENT } : {},
1158
- ...handlers,
1159
- children
2090
+ className: "tb-car",
2091
+ role: "region",
2092
+ "aria-roledescription": "carousel",
2093
+ "aria-label": "Carousel",
2094
+ "data-b-car": "",
2095
+ ...loop ? { "data-b-loop": "" } : {},
2096
+ ...autoplayMs === null ? {} : { "data-b-autoplay": String(autoplayMs) },
2097
+ children: [
2098
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-car-track", tabIndex: 0, children: panels.map((panel, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2099
+ "div",
2100
+ {
2101
+ className: "tb-slide",
2102
+ role: "group",
2103
+ "aria-roledescription": "slide",
2104
+ "aria-label": panel.title === "" ? `${String(i + 1)} of ${String(panels.length)}` : panel.title,
2105
+ children: panel.node
2106
+ },
2107
+ panel.key
2108
+ )) }),
2109
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-car-ctrl", children: [
2110
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-car-btn", "data-b-act": "prev", "aria-label": "Previous slide", children: "\u2039" }),
2111
+ autoplayMs === null ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-car-btn tb-car-pause", "data-b-act": "pause", hidden: true, children: "Pause" }),
2112
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "button", { type: "button", className: "tb-car-btn", "data-b-act": "next", "aria-label": "Next slide", children: "\u203A" })
2113
+ ] })
2114
+ ]
1160
2115
  }
1161
2116
  );
1162
2117
  }
1163
2118
 
2119
+ // src/interactions/tabs.tsx
2120
+
2121
+ function Tabs({ id, panels }) {
2122
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-tabs", children: [
2123
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { role: "tablist", className: "tb-tablist", "data-b-tabs": "", children: panels.map((panel, i) => /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2124
+ "button",
2125
+ {
2126
+ type: "button",
2127
+ role: "tab",
2128
+ className: "tb-tab",
2129
+ id: `${id}-t${String(i)}`,
2130
+ "aria-controls": `${id}-p${String(i)}`,
2131
+ "aria-selected": i === 0,
2132
+ tabIndex: i === 0 ? 0 : -1,
2133
+ children: panel.title
2134
+ },
2135
+ panel.key
2136
+ )) }),
2137
+ panels.map((panel, i) => /* @__PURE__ */ _jsxruntime.jsxs.call(void 0,
2138
+ "div",
2139
+ {
2140
+ role: "tabpanel",
2141
+ className: "tb-panel",
2142
+ id: `${id}-p${String(i)}`,
2143
+ "aria-labelledby": `${id}-t${String(i)}`,
2144
+ tabIndex: 0,
2145
+ children: [
2146
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "p", { className: "tb-panel-title", children: panel.title }),
2147
+ panel.node
2148
+ ]
2149
+ },
2150
+ panel.key
2151
+ ))
2152
+ ] });
2153
+ }
2154
+
2155
+ // src/interactions/toggle.tsx
2156
+
2157
+ function Toggle({
2158
+ labelOpen,
2159
+ labelClosed,
2160
+ startOpen,
2161
+ children
2162
+ }) {
2163
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "details", { className: "tb-toggle", ...startOpen ? { open: true } : {}, children: [
2164
+ /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "summary", { className: "tb-toggle-sum", children: [
2165
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-toggle-closed", children: labelClosed }),
2166
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "span", { className: "tb-toggle-open", children: labelOpen })
2167
+ ] }),
2168
+ /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-row", children })
2169
+ ] });
2170
+ }
2171
+
1164
2172
  // src/styles.ts
1165
2173
  var BASE_CSS = `@layer throttle{
1166
2174
  :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));
@@ -1200,7 +2208,7 @@ function registryFor(doc, base) {
1200
2208
  try {
1201
2209
  registry = base.withCustom(
1202
2210
  Object.values(snapshots).filter(
1203
- (snapshot) => snapshot.kind !== "code"
2211
+ (snapshot) => snapshot.kind !== "code" || _builderschema.codeWidgetSnapshotSchema.safeParse(snapshot).success
1204
2212
  )
1205
2213
  );
1206
2214
  } catch (error) {
@@ -1211,7 +2219,7 @@ function registryFor(doc, base) {
1211
2219
  }
1212
2220
  return registry;
1213
2221
  }
1214
- var isRecord2 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
2222
+ var isRecord3 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
1215
2223
  function pickLocale(value, locale) {
1216
2224
  const lang = _nullishCoalesce(locale.split("-")[0], () => ( locale));
1217
2225
  for (const key of [locale, lang, "en"]) {
@@ -1227,20 +2235,20 @@ function onOrigin(asset, mediaOrigin) {
1227
2235
  }
1228
2236
  function prepare(field, value, ctx) {
1229
2237
  if (field === void 0 || value === null) return value;
1230
- if (field.translatable === true && isRecord2(value)) return pickLocale(value, ctx.locale);
2238
+ if (field.translatable === true && isRecord3(value)) return pickLocale(value, ctx.locale);
1231
2239
  if (field.control === "image" && typeof value === "string") {
1232
2240
  const asset = Object.hasOwn(ctx.assets, value) ? ctx.assets[value] : void 0;
1233
2241
  return asset === void 0 ? null : onOrigin(asset, ctx.mediaOrigin);
1234
2242
  }
1235
- if (field.control === "link" && isRecord2(value) && typeof value.kind === "string") {
2243
+ if (field.control === "link" && isRecord3(value) && typeof value.kind === "string") {
1236
2244
  const target = value;
1237
- const raw = _nullishCoalesce(_optionalChain([ctx, 'access', _42 => _42.resolveLink, 'optionalCall', _43 => _43(target)]), () => ( (target.kind === "url" ? target.href : null)));
2245
+ const raw = _nullishCoalesce(_optionalChain([ctx, 'access', _86 => _86.resolveLink, 'optionalCall', _87 => _87(target)]), () => ( (target.kind === "url" ? target.href : null)));
1238
2246
  return { ...value, href: _builderschema.safeUrl.call(void 0, raw, "href", { mediaOrigin: ctx.mediaOrigin }) };
1239
2247
  }
1240
2248
  return value;
1241
2249
  }
1242
2250
  function storedLinkPart(value) {
1243
- if (!isRecord2(value) || value.kind !== "page") return value;
2251
+ if (!isRecord3(value) || value.kind !== "page") return value;
1244
2252
  const { slug: _slug, href: _href, ...stored } = value;
1245
2253
  void _slug;
1246
2254
  void _href;
@@ -1253,9 +2261,9 @@ function settingsAt(node, fields, device, ctx) {
1253
2261
  const out = {};
1254
2262
  for (const [key, value] of Object.entries(resolved)) {
1255
2263
  const field = fields.get(key);
1256
- const freeText = _optionalChain([field, 'optionalAccess', _44 => _44.control]) === "text" || _optionalChain([field, 'optionalAccess', _45 => _45.control]) === "richtext";
1257
- const checked = _optionalChain([field, 'optionalAccess', _46 => _46.control]) === "link" ? storedLinkPart(value) : value;
1258
- const usable = field === void 0 || (freeText ? value !== null : _builderschema.validateSettingValue.call(void 0, field, checked) === null) ? value : field.default;
2264
+ const freeText = _optionalChain([field, 'optionalAccess', _88 => _88.control]) === "text" || _optionalChain([field, 'optionalAccess', _89 => _89.control]) === "richtext";
2265
+ const checked2 = _optionalChain([field, 'optionalAccess', _90 => _90.control]) === "link" ? storedLinkPart(value) : value;
2266
+ const usable = field === void 0 || (freeText ? value !== null : _builderschema.validateSettingValue.call(void 0, field, checked2) === null) ? value : field.default;
1259
2267
  out[key] = prepare(field, usable, ctx);
1260
2268
  }
1261
2269
  return out;
@@ -1279,7 +2287,41 @@ function hiddenEverywhere(props, responsive) {
1279
2287
  );
1280
2288
  }
1281
2289
  var variantClass = (variant) => `tb-v ${variant.devices.map((d) => `tb-only-${d}`).join(" ")}`;
2290
+ function renderCodeWidget(node, snapshot, ctx, registry) {
2291
+ if (ctx.edit === void 0 && hiddenEverywhere(node.props, node.responsive)) return null;
2292
+ const def = registry.widget(node.type, node.v);
2293
+ const fields = new Map([...COMMON_BY_KEY2, ...(_nullishCoalesce(_optionalChain([def, 'optionalAccess', _91 => _91.settings]), () => ( []))).map((f) => [f.key, f])]);
2294
+ const data = {};
2295
+ for (const [name, binding] of Object.entries(bindingsOf(node, registry))) {
2296
+ const key = bindingKey(binding);
2297
+ const value = Object.hasOwn(ctx.data, key) ? ctx.data[key] : void 0;
2298
+ if (value !== void 0) data[name] = value;
2299
+ }
2300
+ const props = settingsAt(node, fields, "desktop", ctx);
2301
+ const anchor = props.anchor;
2302
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2303
+ CodeWidget,
2304
+ {
2305
+ node,
2306
+ snapshot,
2307
+ registry,
2308
+ props,
2309
+ data,
2310
+ locale: ctx.locale,
2311
+ mediaOrigin: ctx.mediaOrigin,
2312
+ edit: ctx.edit,
2313
+ code: ctx.code,
2314
+ interactive: ctx.interactive,
2315
+ anchor: !ctx.dupe && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
2316
+ copyAnchor: ctx.vpath !== "" && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
2317
+ entrance: entranceOf(props.entrance, props.entranceDelayMs, ctx.interactive)
2318
+ }
2319
+ );
2320
+ }
1282
2321
  function renderWidget(node, ctx, registry) {
2322
+ const key = `${node.type}@${String(node.v)}`;
2323
+ const frozen = ctx.snapshots !== void 0 && Object.hasOwn(ctx.snapshots, key) ? ctx.snapshots[key] : void 0;
2324
+ if (_optionalChain([frozen, 'optionalAccess', _92 => _92.kind]) === "code") return renderCodeWidget(node, frozen, ctx, registry);
1283
2325
  const def = registry.widget(node.type, node.v);
1284
2326
  const Component2 = def === void 0 ? void 0 : registry.component(node);
1285
2327
  if (def === void 0 || Component2 === void 0) {
@@ -1293,8 +2335,8 @@ function renderWidget(node, ctx, registry) {
1293
2335
  const variants = variantsOf(node, def, fields, ctx);
1294
2336
  const data = {};
1295
2337
  for (const [name, binding] of Object.entries(bindingsOf(node, registry))) {
1296
- const key = bindingKey(binding);
1297
- const value = Object.hasOwn(ctx.data, key) ? ctx.data[key] : void 0;
2338
+ const key2 = bindingKey(binding);
2339
+ const value = Object.hasOwn(ctx.data, key2) ? ctx.data[key2] : void 0;
1298
2340
  if (value !== void 0) data[name] = value;
1299
2341
  }
1300
2342
  const custom = node.type.startsWith("custom.");
@@ -1310,7 +2352,9 @@ function renderWidget(node, ctx, registry) {
1310
2352
  custom,
1311
2353
  edit,
1312
2354
  className: variants.length > 1 ? `tb-w ${variantClass(variant)}` : "tb-w",
1313
- anchor: index === 0 && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
2355
+ anchor: index === 0 && !ctx.dupe && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
2356
+ copyAnchor: ctx.vpath !== "" && typeof anchor === "string" && anchor !== "" ? anchor : void 0,
2357
+ entrance: entranceOf(variant.props.entrance, variant.props.entranceDelayMs, ctx.interactive),
1314
2358
  children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1315
2359
  Component2,
1316
2360
  {
@@ -1318,10 +2362,12 @@ function renderWidget(node, ctx, registry) {
1318
2362
  props: variant.props,
1319
2363
  data,
1320
2364
  editMode: edit !== void 0,
2365
+ interactive: ctx.interactive,
2366
+ idScope: ctx.vpath === "" && !ctx.dupe ? void 0 : { vpath: ctx.vpath, dupe: ctx.dupe },
1321
2367
  locale: ctx.locale,
1322
2368
  mediaOrigin: ctx.mediaOrigin,
1323
2369
  resolveLink: ctx.resolveLink,
1324
- inlineEdit: edit === void 0 ? void 0 : (key) => edit.inlineEdit(node.id, key),
2370
+ inlineEdit: edit === void 0 ? void 0 : (key2) => edit.inlineEdit(node.id, key2),
1325
2371
  budget: custom ? new RenderBudget() : void 0
1326
2372
  }
1327
2373
  )
@@ -1338,8 +2384,14 @@ function renderColumn(column, ctx, registry) {
1338
2384
  id: column.id,
1339
2385
  part: "column",
1340
2386
  className: "tb-col",
1341
- anchor: column.props.anchor,
2387
+ anchor: ctx.dupe ? void 0 : column.props.anchor,
2388
+ copyAnchor: ctx.vpath === "" ? void 0 : column.props.anchor,
1342
2389
  edit: ctx.edit,
2390
+ entrance: entranceOf(
2391
+ _builderschema.resolveEntrance.call(void 0, column, "desktop").entrance,
2392
+ _builderschema.resolveEntrance.call(void 0, column, "desktop").entranceDelayMs,
2393
+ ctx.interactive
2394
+ ),
1343
2395
  children: column.children.map(
1344
2396
  (child) => child.type === "inner-section" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderSection(child, ctx, registry, true) }, child.id) : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderWidget(child, ctx, registry) }, child.id)
1345
2397
  )
@@ -1347,34 +2399,133 @@ function renderColumn(column, ctx, registry) {
1347
2399
  column.id
1348
2400
  );
1349
2401
  }
2402
+ var PLAIN = _builderschema.resolveInteraction.call(void 0, { props: {}, responsive: void 0 }, "desktop");
2403
+ function sectionVariants(section, ctx) {
2404
+ const groups = /* @__PURE__ */ new Map();
2405
+ for (const device of DEVICES2) {
2406
+ const interaction = ctx.interactive ? _builderschema.resolveInteraction.call(void 0, section, device) : PLAIN;
2407
+ const entrance = ctx.interactive ? _builderschema.resolveEntrance.call(void 0, section, device) : { entrance: "none", entranceDelayMs: 0 };
2408
+ const signature = stable([interaction, entrance]);
2409
+ const group = groups.get(signature);
2410
+ if (group === void 0) groups.set(signature, { devices: [device], interaction, entrance });
2411
+ else group.devices.push(device);
2412
+ }
2413
+ return [...groups.values()];
2414
+ }
2415
+ function panelsOf(section, ctx, registry, fallback) {
2416
+ const rendered = section.columns.map((column) => ({ column, node: renderColumn(column, ctx, registry) })).filter((entry) => entry.node !== null);
2417
+ return rendered.map(({ column, node }, i) => {
2418
+ const title = pickLocale(_nullishCoalesce(column.props.panelTitle, () => ( {})), ctx.locale).trim();
2419
+ return { key: column.id, title: title === "" ? fallback(i + 1, rendered.length) : title, node };
2420
+ });
2421
+ }
1350
2422
  function renderSection(section, ctx, registry, nested = false) {
1351
2423
  if (ctx.edit === void 0 && hiddenEverywhere(section.props, section.responsive)) return null;
1352
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
1353
- NodeWrapper,
1354
- {
1355
- id: section.id,
1356
- part: "section",
1357
- as: nested ? "div" : "section",
1358
- className: nested ? "tb-section tb-nested" : "tb-section",
1359
- anchor: section.props.anchor,
1360
- edit: ctx.edit,
1361
- children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-inner", children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-row", children: section.columns.map((column) => renderColumn(column, ctx, registry)) }) })
2424
+ const variants = sectionVariants(section, ctx);
2425
+ 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;
2426
+ const copies = variants.map((variant, index) => {
2427
+ const { interaction } = variant;
2428
+ const id = `ix-${section.id}-${ctx.vpath}${String(index)}`;
2429
+ const own = variants.length > 1 ? { ...ctx, vpath: `${ctx.vpath}${String(index)}-`, dupe: ctx.dupe || index > 0 } : ctx;
2430
+ const columns = () => section.columns.map((column) => renderColumn(column, own, registry));
2431
+ let body;
2432
+ if (interaction.interaction === "tabs") {
2433
+ body = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Tabs, { id, panels: panelsOf(section, own, registry, (n) => `Tab ${String(n)}`) });
2434
+ } else if (interaction.interaction === "accordion") {
2435
+ body = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2436
+ Accordion,
2437
+ {
2438
+ id,
2439
+ panels: panelsOf(section, own, registry, (n) => `Section ${String(n)}`),
2440
+ multiple: interaction.accordionMultiple,
2441
+ openFirst: interaction.accordionOpenFirst
2442
+ }
2443
+ );
2444
+ } else if (interaction.interaction === "carousel") {
2445
+ body = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2446
+ Carousel,
2447
+ {
2448
+ panels: panelsOf(section, own, registry, () => ""),
2449
+ autoplayMs: interaction.carouselAutoplay ? interaction.carouselIntervalMs : null,
2450
+ loop: interaction.carouselLoop
2451
+ }
2452
+ );
2453
+ } else if (interaction.interaction === "toggle") {
2454
+ body = /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2455
+ Toggle,
2456
+ {
2457
+ labelOpen: pickLocale(interaction.toggleLabelOpen, ctx.locale),
2458
+ labelClosed: pickLocale(interaction.toggleLabelClosed, ctx.locale),
2459
+ startOpen: interaction.toggleStartOpen,
2460
+ children: columns()
2461
+ }
2462
+ );
2463
+ } else {
2464
+ body = /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-row", children: columns() });
1362
2465
  }
1363
- );
2466
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
2467
+ NodeWrapper,
2468
+ {
2469
+ id: section.id,
2470
+ part: "section",
2471
+ as: nested ? "div" : "section",
2472
+ className: `${nested ? "tb-section tb-nested" : "tb-section"}${variants.length > 1 ? ` ${variantClass({ devices: variant.devices, props: {} })}` : ""}`,
2473
+ anchor: variants.length === 1 && !ctx.dupe ? section.props.anchor : void 0,
2474
+ copyAnchor: variants.length > 1 || ctx.vpath !== "" ? section.props.anchor : void 0,
2475
+ edit: ctx.edit,
2476
+ entrance: entranceOf(variant.entrance.entrance, variant.entrance.entranceDelayMs, ctx.interactive),
2477
+ children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "div", { className: "tb-inner", children: body })
2478
+ },
2479
+ variant.devices.join("-")
2480
+ );
2481
+ });
2482
+ return marker === null ? copies : [marker, ...copies];
2483
+ }
2484
+ function needsRuntime(doc) {
2485
+ let found = false;
2486
+ _builderschema.walkNodes.call(void 0, doc, (node) => {
2487
+ if (found || node.type === "saved-section") return;
2488
+ if (node.type === "section" || node.type === "inner-section") {
2489
+ found = DEVICES2.some(
2490
+ (device) => _builderschema.resolveInteraction.call(void 0, node, device).interaction !== "none" || _builderschema.resolveEntrance.call(void 0, node, device).entrance !== "none"
2491
+ );
2492
+ } else if (node.type === "column") {
2493
+ found = DEVICES2.some((device) => _builderschema.resolveEntrance.call(void 0, node, device).entrance !== "none");
2494
+ } else {
2495
+ found = DEVICES2.some((device) => {
2496
+ const entrance = _builderschema.resolveResponsive.call(void 0, node.props, node.responsive, device).entrance;
2497
+ return entrance !== void 0 && entrance !== "none";
2498
+ });
2499
+ }
2500
+ });
2501
+ return found;
1364
2502
  }
1365
2503
  function BuilderRenderer(props) {
1366
- const { document: source, registry: base, data, editMode, locale, assets, resolveLink } = props;
2504
+ const { document: raw, registry: base, data, editMode, locale, assets, resolveLink, code } = props;
2505
+ const expansion = expandSavedSections(raw, props.savedSections);
2506
+ const source = expansion.doc;
1367
2507
  const registry = registryFor(source, base);
1368
2508
  const { doc } = _builderschema.upgradeNodes.call(void 0, source, registry);
1369
2509
  const mediaOrigin = _nullishCoalesce(props.mediaOrigin, () => ( ""));
1370
- const ctx = { registry, data, locale, assets, mediaOrigin, resolveLink, edit: editMode };
2510
+ const interactive = props.interactive !== false;
2511
+ const ctx = { registry, data, locale, assets, mediaOrigin, resolveLink, code, edit: editMode, interactive, vpath: _nullishCoalesce(_optionalChain([props, 'access', _93 => _93.idScope, 'optionalAccess', _94 => _94.vpath]), () => ( "")), dupe: _nullishCoalesce(_optionalChain([props, 'access', _95 => _95.idScope, 'optionalAccess', _96 => _96.dupe]), () => ( false)), snapshots: source.customWidgets };
1371
2512
  const css = compileResponsiveCss(doc, registry, assets, mediaOrigin);
1372
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-root", "data-throttle-part": "builder-root", children: [
2513
+ const upgraded = new Map(doc.sections.map((section) => [section.id, section]));
2514
+ return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, "div", { className: "tb-root", "data-throttle-part": "builder-root", ...props.scopeCustomCss === true ? { "data-b-root": "" } : {}, children: [
2515
+ interactive && needsRuntime(doc) ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, InteractionRuntime, {}) : null,
1373
2516
  /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { href: "tb-base", precedence: "throttle", children: BASE_CSS }),
1374
2517
  css === "" ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "style", { children: css }),
1375
- doc.sections.map(
1376
- (section) => section.type === "section" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderSection(section, ctx, registry) }, section.id) : null
1377
- )
2518
+ (_nullishCoalesce(expansion.roots, () => ( doc.sections.map((section) => ({ kind: "section", id: section.id }))))).map((root) => {
2519
+ if (root.kind === "section") {
2520
+ const section2 = upgraded.get(root.id);
2521
+ return _optionalChain([section2, 'optionalAccess', _97 => _97.type]) === "section" ? /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderSection(section2, ctx, registry) }, root.id) : null;
2522
+ }
2523
+ const section = root.sectionId === null ? void 0 : upgraded.get(root.sectionId);
2524
+ if (_optionalChain([section, 'optionalAccess', _98 => _98.type]) === "section") {
2525
+ 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);
2526
+ }
2527
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, MissingSavedSection, { node: root.ref }, root.ref.id);
2528
+ })
1378
2529
  ] });
1379
2530
  }
1380
2531
 
@@ -1398,8 +2549,8 @@ var Boundary = class extends BoundaryBase {
1398
2549
  componentDidCatch(error, _info) {
1399
2550
  warnOnce(`part:${this.props.label}`, `${this.props.label} failed to render (${String(error)}); rendering nothing for it`);
1400
2551
  try {
1401
- _optionalChain([this, 'access', _47 => _47.props, 'access', _48 => _48.onError, 'optionalCall', _49 => _49(error, { part: this.props.label })]);
1402
- } catch (e5) {
2552
+ _optionalChain([this, 'access', _99 => _99.props, 'access', _100 => _100.onError, 'optionalCall', _101 => _101(error, { part: this.props.label })]);
2553
+ } catch (e8) {
1403
2554
  }
1404
2555
  }
1405
2556
  componentDidUpdate(previous) {
@@ -1416,267 +2567,7 @@ function PartBoundary({
1416
2567
  children
1417
2568
  }) {
1418
2569
  const builder = useBuilder();
1419
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Boundary, { label, resetKeys: [_optionalChain([builder, 'optionalAccess', _50 => _50.site]), resetKey], onError: _optionalChain([builder, 'optionalAccess', _51 => _51.onError]), children });
1420
- }
1421
-
1422
- // src/custom/template-widget.tsx
1423
-
1424
-
1425
-
1426
- // src/custom/custom-css.tsx
1427
-
1428
-
1429
- function scopedCss(source, type) {
1430
- if (source === void 0 || source === "") return "";
1431
- if (typeof source !== "string") return null;
1432
- const result = _builderschema.sanitizeWidgetCss.call(void 0, source, type);
1433
- return result.ok ? result.css : null;
1434
- }
1435
- function CustomCss({ css }) {
1436
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, WidgetStyle, { css });
1437
- }
1438
-
1439
- // src/custom/interpreter.tsx
1440
-
1441
-
1442
-
1443
-
1444
-
1445
-
1446
-
1447
-
1448
-
1449
-
1450
-
1451
-
1452
-
1453
-
1454
- var MAX_OUTPUT_CHARS = 1e6;
1455
- var MAX_ATTR_CHARS = 2e3;
1456
- var MAX_DEPTH3 = 24;
1457
- function newEnv(env) {
1458
- return { ...env, charsLeft: MAX_OUTPUT_CHARS, stopped: false };
1459
- }
1460
- var BLOCKED = /* @__PURE__ */ new Set([
1461
- "__proto__",
1462
- "constructor",
1463
- "prototype",
1464
- ...Object.getOwnPropertyNames(Object.prototype)
1465
- ]);
1466
- var isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1467
- function step(value, key) {
1468
- if (BLOCKED.has(key) || !isPlainObject(value) || !Object.hasOwn(value, key)) return void 0;
1469
- return value[key];
1470
- }
1471
- function lookup(path, env, scope) {
1472
- const [root, ...rest] = path;
1473
- if (root === void 0) return void 0;
1474
- if (root === "locale") return rest.length === 0 ? env.locale : void 0;
1475
- let value;
1476
- if (root === "settings") value = rest.length === 0 ? void 0 : env.settings;
1477
- else if (root === "data") value = rest.length === 0 ? void 0 : env.data;
1478
- else if (scope.has(root)) value = scope.get(root);
1479
- else return void 0;
1480
- for (const key of rest) {
1481
- value = step(value, key);
1482
- if (value === void 0) return void 0;
1483
- }
1484
- return value;
1485
- }
1486
- function truthy(value) {
1487
- if (value === null || value === void 0 || value === false || value === "") return false;
1488
- if (typeof value === "number") return value !== 0 && !Number.isNaN(value);
1489
- if (Array.isArray(value)) return value.length > 0;
1490
- return true;
1491
- }
1492
- function asText(value) {
1493
- if (typeof value === "string") return value;
1494
- if (typeof value === "number" && Number.isFinite(value)) return String(value);
1495
- return "";
1496
- }
1497
- function filtered(value, filters) {
1498
- let text2 = asText(value);
1499
- for (const filter of filters) {
1500
- switch (filter.name) {
1501
- case "upper":
1502
- text2 = text2.toUpperCase();
1503
- break;
1504
- case "lower":
1505
- text2 = text2.toLowerCase();
1506
- break;
1507
- case "truncate": {
1508
- const chars = Array.from(text2);
1509
- if (chars.length > filter.n) text2 = `${chars.slice(0, filter.n).join("")}\u2026`;
1510
- break;
1511
- }
1512
- case "default":
1513
- if (text2 === "") text2 = filter.text;
1514
- break;
1515
- }
1516
- }
1517
- return text2;
1518
- }
1519
- function spend(env, count) {
1520
- if (count > env.charsLeft) {
1521
- env.stopped = true;
1522
- return false;
1523
- }
1524
- env.charsLeft -= count;
1525
- return true;
1526
- }
1527
- var ELEMENTS = new Set(_builderschema.ALLOWED_ELEMENTS);
1528
- var VOIDS = new Set(_builderschema.VOID_ELEMENTS);
1529
- var ROLES = new Set(_builderschema.ALLOWED_ROLES);
1530
- function attrAllowed(tag, name) {
1531
- if (_builderschema.DATA_ATTR_RE.test(name)) return !name.startsWith(_builderschema.RESERVED_DATA_PREFIX);
1532
- const own = Object.hasOwn(_builderschema.ALLOWED_ATTRS, tag) ? _builderschema.ALLOWED_ATTRS[tag] : void 0;
1533
- return (_nullishCoalesce(_optionalChain([_builderschema.ALLOWED_ATTRS, 'access', _52 => _52["*"], 'optionalAccess', _53 => _53.includes, 'call', _54 => _54(name)]), () => ( false))) || (_nullishCoalesce(_optionalChain([own, 'optionalAccess', _55 => _55.includes, 'call', _56 => _56(name)]), () => ( false)));
1534
- }
1535
- function attrText(attr, env, scope) {
1536
- return attr.value.map((part) => part.type === "text" ? part.value : filtered(lookup(part.path, env, scope), part.filters)).join("");
1537
- }
1538
- function urlSource(attr, env, scope) {
1539
- const [only] = attr.value;
1540
- if (attr.value.length !== 1 || only === void 0 || only.type !== "output") return attrText(attr, env, scope);
1541
- const value = lookup(only.path, env, scope);
1542
- if (isPlainObject(value)) {
1543
- if (typeof value.href === "string") return value.href;
1544
- if (typeof value.url === "string") return value.url;
1545
- return null;
1546
- }
1547
- return value;
1548
- }
1549
- function attrProp(tag, attr, env, scope) {
1550
- const { name } = attr;
1551
- if (!attrAllowed(tag, name)) return null;
1552
- if (name === "href" || name === "src") {
1553
- const safe = _builderschema.safeUrl.call(void 0, urlSource(attr, env, scope), name, { mediaOrigin: env.mediaOrigin });
1554
- return safe === null || !spend(env, safe.length) ? null : [name, safe];
1555
- }
1556
- const text2 = attrText(attr, env, scope);
1557
- if (text2 === "" || text2.length > MAX_ATTR_CHARS) return null;
1558
- let value = text2;
1559
- if (name === "class") {
1560
- const tokens = text2.split(/\s+/).filter((token) => _builderschema.CLASS_TOKEN_RE.test(token) && !_builderschema.isReservedClass.call(void 0, token));
1561
- if (tokens.length === 0) return null;
1562
- value = tokens.join(" ");
1563
- } else if (name === "role") {
1564
- if (!ROLES.has(text2)) return null;
1565
- } else if (name === "aria-hidden") {
1566
- if (text2 !== "true" && text2 !== "false") return null;
1567
- }
1568
- if (!spend(env, value.length)) return null;
1569
- return [name === "class" ? "className" : name, value];
1570
- }
1571
- function renderElement(node, env, scope, depth, key) {
1572
- const tag = node.tag;
1573
- if (!ELEMENTS.has(tag)) return null;
1574
- const props = { key };
1575
- for (const attr of node.attrs) {
1576
- const prop = attrProp(tag, attr, env, scope);
1577
- if (prop !== null) props[prop[0]] = prop[1];
1578
- }
1579
- if (VOIDS.has(tag)) return _react.createElement.call(void 0, tag, props);
1580
- return _react.createElement.call(void 0, tag, props, renderNodes(node.children, env, scope, depth + 1));
1581
- }
1582
- function renderNodes(nodes, env, scope, depth) {
1583
- const out = [];
1584
- if (depth > MAX_DEPTH3) return out;
1585
- for (const node of nodes) {
1586
- if (env.stopped) break;
1587
- if (!env.budget.take(1) || node.type === "element" && !env.budget.take(node.attrs.reduce((n, a) => n + a.value.length, 0))) {
1588
- env.stopped = true;
1589
- break;
1590
- }
1591
- switch (node.type) {
1592
- case "text":
1593
- if (spend(env, node.value.length)) out.push(node.value);
1594
- break;
1595
- case "output": {
1596
- const text2 = filtered(lookup(node.path, env, scope), node.filters);
1597
- if (text2 !== "" && spend(env, text2.length)) out.push(text2);
1598
- break;
1599
- }
1600
- case "if": {
1601
- const branch = truthy(lookup(node.path, env, scope)) ? node.then : node.else;
1602
- out.push(/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderNodes(branch, env, scope, depth + 1) }, out.length));
1603
- break;
1604
- }
1605
- case "unless":
1606
- if (!truthy(lookup(node.path, env, scope))) {
1607
- out.push(/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderNodes(node.body, env, scope, depth + 1) }, out.length));
1608
- }
1609
- break;
1610
- case "each": {
1611
- const list = lookup(node.path, env, scope);
1612
- if (!Array.isArray(list)) break;
1613
- const count = Math.min(list.length, _builderschema.EACH_ITERATION_CAP);
1614
- for (let i = 0; i < count && !env.stopped; i += 1) {
1615
- const inner = new Map(scope).set(node.as, list[i]);
1616
- out.push(/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Fragment, { children: renderNodes(node.body, env, inner, depth + 1) }, out.length));
1617
- }
1618
- break;
1619
- }
1620
- case "element":
1621
- out.push(renderElement(node, env, scope, depth, out.length));
1622
- break;
1623
- }
1624
- }
1625
- return out;
1626
- }
1627
- function renderTemplate(ast, env) {
1628
- return renderNodes(ast, env, /* @__PURE__ */ new Map(), 0);
1629
- }
1630
-
1631
- // src/custom/template-widget.tsx
1632
-
1633
- var componentWeights = /* @__PURE__ */ new WeakMap();
1634
- var compiled = /* @__PURE__ */ new WeakMap();
1635
- function compileTemplate(snapshot, registry) {
1636
- let perRegistry = compiled.get(snapshot);
1637
- if (perRegistry === void 0) {
1638
- perRegistry = /* @__PURE__ */ new WeakMap();
1639
- compiled.set(snapshot, perRegistry);
1640
- }
1641
- if (perRegistry.has(registry)) return _nullishCoalesce(perRegistry.get(registry), () => ( null));
1642
- const result = compile(snapshot, registry);
1643
- perRegistry.set(registry, result);
1644
- return result;
1645
- }
1646
- function compile(snapshot, registry) {
1647
- const label = `${snapshot.type}@${String(snapshot.v)}`;
1648
- const refuse = (why) => {
1649
- warnOnce(`template:${label}`, `${label} was refused (${why}); rendering nothing for it`);
1650
- return null;
1651
- };
1652
- if (snapshot.kind !== "template") return refuse("not a template widget");
1653
- const source = snapshot.template;
1654
- if (typeof source !== "string") return refuse("no template source");
1655
- const parsed = _builderschema.parseTemplate.call(void 0, source);
1656
- if (!parsed.ok) return refuse(`template does not parse: ${_nullishCoalesce(_optionalChain([parsed, 'access', _57 => _57.issues, 'access', _58 => _58[0], 'optionalAccess', _59 => _59.message]), () => ( "invalid"))}`);
1657
- const data = snapshot.data;
1658
- const issues = _builderschema.validateTemplate.call(void 0, parsed.ast, {
1659
- settings: snapshot.settings,
1660
- data: typeof data === "object" && data !== null ? data : {},
1661
- sources: registry.sources()
1662
- });
1663
- if (issues.length > 0) return refuse(`template does not validate: ${_nullishCoalesce(_optionalChain([issues, 'access', _60 => _60[0], 'optionalAccess', _61 => _61.message]), () => ( "invalid"))}`);
1664
- if (!fitsBudget(parsed.ast)) return refuse(`it can render more than ${String(_builderschema.MAX_TEMPLATE_WEIGHT)} nodes`);
1665
- const css = scopedCss(snapshot.css, snapshot.type);
1666
- if (css === null) return refuse("its css does not pass the sanitiser");
1667
- return { ast: parsed.ast, css, weight: _builderschema.templateWeight.call(void 0, parsed.ast) };
1668
- }
1669
- function TemplateBody({ snapshot, registry, props, data, locale, mediaOrigin, budget }) {
1670
- const template = compileTemplate(snapshot, registry);
1671
- if (template === null) return null;
1672
- const env = newEnv({ settings: props, data, locale, mediaOrigin, budget: _nullishCoalesce(budget, () => ( new RenderBudget())) });
1673
- return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
1674
- template.css === "" ? null : /* @__PURE__ */ _jsxruntime.jsx.call(void 0, CustomCss, { css: template.css }),
1675
- renderTemplate(template.ast, env)
1676
- ] });
1677
- }
1678
- function TemplateWidget(props) {
1679
- return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, PartBoundary, { label: `${props.snapshot.type}@${String(props.snapshot.v)}`, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Suspense, { fallback: null, children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, TemplateBody, { ...props }) }) });
2570
+ return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Boundary, { label, resetKeys: [_optionalChain([builder, 'optionalAccess', _102 => _102.site]), resetKey], onError: _optionalChain([builder, 'optionalAccess', _103 => _103.onError]), children });
1680
2571
  }
1681
2572
 
1682
2573
  // src/custom/composite-widget.tsx
@@ -1684,32 +2575,32 @@ function TemplateWidget(props) {
1684
2575
  var SETTING_KEY_RE = /^[a-z][A-Za-z0-9]{0,39}$/;
1685
2576
  var NODE_ID_RE = /^[a-z0-9]{8,24}$/;
1686
2577
  var WRAP = { section: "zzcompsec001", column: "zzcompcol001", inner: "zzcompinr001" };
1687
- var isRecord3 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
1688
- var compiled2 = /* @__PURE__ */ new WeakMap();
2578
+ var isRecord4 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
2579
+ var compiled3 = /* @__PURE__ */ new WeakMap();
1689
2580
  function parseBody(raw) {
1690
- if (!isRecord3(raw)) return null;
2581
+ if (!isRecord4(raw)) return null;
1691
2582
  const columns = Array.isArray(raw.columns) ? raw.columns : void 0;
1692
2583
  const stack = Array.isArray(raw.stack) ? raw.stack : void 0;
1693
2584
  if (columns === void 0 === (stack === void 0)) return null;
1694
2585
  const children = columns !== void 0 ? [{ id: WRAP.inner, type: "inner-section", props: {}, columns }] : _nullishCoalesce(stack, () => ( []));
1695
- if (_optionalChain([stack, 'optionalAccess', _62 => _62.some, 'call', _63 => _63((node) => isRecord3(node) && node.type === "inner-section")])) return null;
1696
- const parsed = _builderschema.pageDocumentSchema.safeParse({
2586
+ if (_optionalChain([stack, 'optionalAccess', _104 => _104.some, 'call', _105 => _105((node) => isRecord4(node) && node.type === "inner-section")])) return null;
2587
+ const parsed2 = _builderschema.pageDocumentSchema.safeParse({
1697
2588
  schemaVersion: 1,
1698
2589
  sections: [{ id: WRAP.section, type: "section", props: {}, columns: [{ id: WRAP.column, type: "column", props: { width: 100 }, children }] }]
1699
2590
  });
1700
- if (!parsed.success) return null;
1701
- const wrapper = parsed.data.sections[0];
1702
- const first = _nullishCoalesce((_optionalChain([wrapper, 'optionalAccess', _64 => _64.type]) === "section" ? _optionalChain([wrapper, 'access', _65 => _65.columns, 'access', _66 => _66[0], 'optionalAccess', _67 => _67.children]) : void 0), () => ( []));
2591
+ if (!parsed2.success) return null;
2592
+ const wrapper = parsed2.data.sections[0];
2593
+ const first = _nullishCoalesce((_optionalChain([wrapper, 'optionalAccess', _106 => _106.type]) === "section" ? _optionalChain([wrapper, 'access', _107 => _107.columns, 'access', _108 => _108[0], 'optionalAccess', _109 => _109.children]) : void 0), () => ( []));
1703
2594
  if (columns !== void 0) {
1704
2595
  const inner = first[0];
1705
- return _optionalChain([inner, 'optionalAccess', _68 => _68.type]) === "inner-section" ? { columns: inner.columns } : null;
2596
+ return _optionalChain([inner, 'optionalAccess', _110 => _110.type]) === "inner-section" ? { columns: inner.columns } : null;
1706
2597
  }
1707
2598
  return { stack: first.filter((node) => node.type !== "inner-section") };
1708
2599
  }
1709
2600
  function compileComposite(snapshot) {
1710
- if (compiled2.has(snapshot)) return _nullishCoalesce(compiled2.get(snapshot), () => ( null));
2601
+ if (compiled3.has(snapshot)) return _nullishCoalesce(compiled3.get(snapshot), () => ( null));
1711
2602
  const result = compile2(snapshot);
1712
- compiled2.set(snapshot, result);
2603
+ compiled3.set(snapshot, result);
1713
2604
  return result;
1714
2605
  }
1715
2606
  function compile2(snapshot) {
@@ -1725,12 +2616,12 @@ function compile2(snapshot) {
1725
2616
  const bindings = [];
1726
2617
  if (extra.bindings !== void 0 && !Array.isArray(extra.bindings)) return refuse("bindings is not a list");
1727
2618
  for (const raw of _nullishCoalesce(extra.bindings, () => ( []))) {
1728
- if (!isRecord3(raw) || typeof raw.setting !== "string" || !SETTING_KEY_RE.test(raw.setting) || !Array.isArray(raw.targets)) {
2619
+ if (!isRecord4(raw) || typeof raw.setting !== "string" || !SETTING_KEY_RE.test(raw.setting) || !Array.isArray(raw.targets)) {
1729
2620
  return refuse("a binding is malformed");
1730
2621
  }
1731
2622
  const targets = [];
1732
2623
  for (const target of raw.targets) {
1733
- if (!isRecord3(target) || typeof target.node !== "string" || !NODE_ID_RE.test(target.node) || typeof target.prop !== "string" || !SETTING_KEY_RE.test(target.prop)) {
2624
+ if (!isRecord4(target) || typeof target.node !== "string" || !NODE_ID_RE.test(target.node) || typeof target.prop !== "string" || !SETTING_KEY_RE.test(target.prop)) {
1734
2625
  return refuse("a binding target is malformed");
1735
2626
  }
1736
2627
  targets.push({ node: target.node, prop: target.prop });
@@ -1738,12 +2629,12 @@ function compile2(snapshot) {
1738
2629
  bindings.push({ setting: raw.setting, targets });
1739
2630
  }
1740
2631
  const data = [];
1741
- if (extra.data !== void 0 && !isRecord3(extra.data)) return refuse("data is not a record");
2632
+ if (extra.data !== void 0 && !isRecord4(extra.data)) return refuse("data is not a record");
1742
2633
  for (const [name, raw] of Object.entries(_nullishCoalesce(extra.data, () => ( {})))) {
1743
- if (!SETTING_KEY_RE.test(name) || !isRecord3(raw) || !Array.isArray(raw.targets)) return refuse("a data input is malformed");
2634
+ if (!SETTING_KEY_RE.test(name) || !isRecord4(raw) || !Array.isArray(raw.targets)) return refuse("a data input is malformed");
1744
2635
  const targets = [];
1745
2636
  for (const target of raw.targets) {
1746
- if (!isRecord3(target) || typeof target.node !== "string" || !NODE_ID_RE.test(target.node) || typeof target.input !== "string" || !SETTING_KEY_RE.test(target.input)) {
2637
+ if (!isRecord4(target) || typeof target.node !== "string" || !NODE_ID_RE.test(target.node) || typeof target.input !== "string" || !SETTING_KEY_RE.test(target.input)) {
1747
2638
  return refuse("a data target is malformed");
1748
2639
  }
1749
2640
  targets.push({ node: target.node, input: target.input });
@@ -1756,7 +2647,7 @@ var DEVICES3 = ["tablet", "phone"];
1756
2647
  function withoutAnchor(node) {
1757
2648
  delete node.props.anchor;
1758
2649
  const responsive = node.responsive;
1759
- for (const device of DEVICES3) if (_optionalChain([responsive, 'optionalAccess', _69 => _69[device]]) !== void 0) delete responsive[device].anchor;
2650
+ for (const device of DEVICES3) if (_optionalChain([responsive, 'optionalAccess', _111 => _111[device]]) !== void 0) delete responsive[device].anchor;
1760
2651
  }
1761
2652
  function instanceId(outer, inner) {
1762
2653
  let a = 3735928559;
@@ -1776,9 +2667,9 @@ function build(input) {
1776
2667
  const assets = {};
1777
2668
  const hrefs = /* @__PURE__ */ new Map();
1778
2669
  const innerData = {};
1779
- const keep = (child) => _optionalChain([registry, 'access', _70 => _70.widget, 'call', _71 => _71(child.type, child.v), 'optionalAccess', _72 => _72.kind]) !== "composite";
1780
- const columns = _optionalChain([body, 'access', _73 => _73.columns, 'optionalAccess', _74 => _74.map, 'call', _75 => _75((column2) => ({ ...column2, children: column2.children.filter(keep) }))]);
1781
- const stack = _optionalChain([body, 'access', _76 => _76.stack, 'optionalAccess', _77 => _77.filter, 'call', _78 => _78(keep)]);
2670
+ const keep = (child) => _optionalChain([registry, 'access', _112 => _112.widget, 'call', _113 => _113(child.type, child.v), 'optionalAccess', _114 => _114.kind]) !== "composite";
2671
+ const columns = _optionalChain([body, 'access', _115 => _115.columns, 'optionalAccess', _116 => _116.map, 'call', _117 => _117((column2) => ({ ...column2, children: column2.children.filter(keep) }))]);
2672
+ const stack = _optionalChain([body, 'access', _118 => _118.stack, 'optionalAccess', _119 => _119.filter, 'call', _120 => _120(keep)]);
1782
2673
  const widgets2 = columns !== void 0 ? columns.flatMap((column2) => column2.children) : _nullishCoalesce(stack, () => ( []));
1783
2674
  for (const widget of widgets2) {
1784
2675
  withoutAnchor(widget);
@@ -1799,7 +2690,7 @@ function build(input) {
1799
2690
  return id;
1800
2691
  }
1801
2692
  if (field.control === "link") {
1802
- if (!isRecord3(value) || typeof value.kind !== "string") return null;
2693
+ if (!isRecord4(value) || typeof value.kind !== "string") return null;
1803
2694
  const { href, ...target } = value;
1804
2695
  if (target.kind === "url") return typeof href === "string" ? { kind: "url", href } : null;
1805
2696
  hrefs.set(JSON.stringify(target), typeof href === "string" ? href : null);
@@ -1813,15 +2704,15 @@ function build(input) {
1813
2704
  const value = props[binding.setting];
1814
2705
  for (const target of binding.targets) {
1815
2706
  const inner = byId.get(target.node);
1816
- const innerField = inner === void 0 ? void 0 : _optionalChain([registry, 'access', _79 => _79.widget, 'call', _80 => _80(inner.type, inner.v), 'optionalAccess', _81 => _81.settings, 'access', _82 => _82.find, 'call', _83 => _83((f) => f.key === target.prop)]);
2707
+ const innerField = inner === void 0 ? void 0 : _optionalChain([registry, 'access', _121 => _121.widget, 'call', _122 => _122(inner.type, inner.v), 'optionalAccess', _123 => _123.settings, 'access', _124 => _124.find, 'call', _125 => _125((f) => f.key === target.prop)]);
1817
2708
  if (inner === void 0 || innerField === void 0 || innerField.control !== field.control) continue;
1818
2709
  const converted = convert(field, value);
1819
2710
  if (_builderschema.validateSettingValue.call(void 0, innerField, converted) !== null) continue;
1820
2711
  inner.props[target.prop] = converted;
1821
2712
  const responsive = inner.responsive;
1822
2713
  for (const device of DEVICES3) {
1823
- if (_optionalChain([responsive, 'optionalAccess', _84 => _84[device]]) !== void 0) delete responsive[device][target.prop];
1824
- const raw = _optionalChain([outer, 'access', _85 => _85.responsive, 'optionalAccess', _86 => _86[device]]);
2714
+ if (_optionalChain([responsive, 'optionalAccess', _126 => _126[device]]) !== void 0) delete responsive[device][target.prop];
2715
+ const raw = _optionalChain([outer, 'access', _127 => _127.responsive, 'optionalAccess', _128 => _128[device]]);
1825
2716
  const plain = field.output === "css" && field.translatable !== true && field.control !== "image" && field.control !== "link";
1826
2717
  if (plain && raw !== void 0 && Object.hasOwn(raw, binding.setting) && _builderschema.validateSettingValue.call(void 0, innerField, raw[binding.setting]) === null) {
1827
2718
  const target$ = _nullishCoalesce(inner.responsive, () => ( (inner.responsive = {})));
@@ -1836,7 +2727,7 @@ function build(input) {
1836
2727
  for (const target of input$.targets) {
1837
2728
  const inner = byId.get(target.node);
1838
2729
  const def = inner === void 0 ? void 0 : registry.widget(inner.type, inner.v);
1839
- if (inner === void 0 || _optionalChain([def, 'optionalAccess', _87 => _87.data]) === void 0 || !Object.hasOwn(def.data, target.input)) continue;
2730
+ if (inner === void 0 || _optionalChain([def, 'optionalAccess', _129 => _129.data]) === void 0 || !Object.hasOwn(def.data, target.input)) continue;
1840
2731
  inner.data = { ..._nullishCoalesce(inner.data, () => ( {})), [target.input]: { source: key } };
1841
2732
  innerData[key] = data[name];
1842
2733
  }
@@ -1850,19 +2741,19 @@ function build(input) {
1850
2741
  props: { width: 100 },
1851
2742
  children: columns !== void 0 ? [{ id: ids.inner, type: "inner-section", props: { width: "full" }, columns }] : _nullishCoalesce(stack, () => ( []))
1852
2743
  };
1853
- const document = {
2744
+ const document2 = {
1854
2745
  schemaVersion: 1,
1855
2746
  sections: [{ id: ids.section, type: "section", props: { width: "full" }, columns: [column] }]
1856
2747
  };
1857
- let weight = 2 + (_nullishCoalesce(_optionalChain([columns, 'optionalAccess', _88 => _88.length]), () => ( 0))) + (columns === void 0 ? 0 : 1);
2748
+ let weight = 2 + (_nullishCoalesce(_optionalChain([columns, 'optionalAccess', _130 => _130.length]), () => ( 0))) + (columns === void 0 ? 0 : 1);
1858
2749
  for (const widget of widgets2) {
1859
2750
  const component = registry.component(widget);
1860
2751
  weight += 1 + (component === void 0 ? 0 : _nullishCoalesce(componentWeights.get(component), () => ( 0)));
1861
2752
  }
1862
- return { document, assets, data: innerData, hrefs, weight };
2753
+ return { document: document2, assets, data: innerData, hrefs, weight };
1863
2754
  }
1864
2755
  function CompositeBody(props) {
1865
- const { snapshot, registry, node, data, locale, mediaOrigin, budget, resolveLink } = props;
2756
+ const { snapshot, registry, node, data, locale, mediaOrigin, budget, resolveLink, interactive, idScope } = props;
1866
2757
  const composite = compileComposite(snapshot);
1867
2758
  if (composite === null) return null;
1868
2759
  const built = build({ snapshot, compiled: composite, registry, node, props: props.props, data });
@@ -1879,7 +2770,9 @@ function CompositeBody(props) {
1879
2770
  locale,
1880
2771
  assets: built.assets,
1881
2772
  mediaOrigin,
1882
- resolveLink: (target) => _nullishCoalesce(_nullishCoalesce(built.hrefs.get(JSON.stringify(target)), () => ( _optionalChain([resolveLink, 'optionalCall', _89 => _89(target)]))), () => ( null))
2773
+ interactive,
2774
+ idScope,
2775
+ resolveLink: (target) => _nullishCoalesce(_nullishCoalesce(built.hrefs.get(JSON.stringify(target)), () => ( _optionalChain([resolveLink, 'optionalCall', _131 => _131(target)]))), () => ( null))
1883
2776
  }
1884
2777
  );
1885
2778
  }
@@ -1908,12 +2801,12 @@ var BUILTIN_PACKS = [basicPack];
1908
2801
  var DEFAULT_CUSTOM_WIDGET = customWidgetFactory;
1909
2802
  var customKey = (type, v) => `${type}@${String(v)}`;
1910
2803
  function createRendererRegistry(packs, options = {}) {
1911
- const all = [...BUILTIN_PACKS, ...packs];
2804
+ const all2 = [...BUILTIN_PACKS, ...packs];
1912
2805
  const components = /* @__PURE__ */ new Map();
1913
2806
  const definitions = [];
1914
2807
  const sources = [];
1915
2808
  const resolvers = /* @__PURE__ */ new Map();
1916
- for (const pack of all) {
2809
+ for (const pack of all2) {
1917
2810
  for (const { Component: Component2, ...definition } of pack.widgets) {
1918
2811
  const key = customKey(definition.type, definition.v);
1919
2812
  if (components.has(key)) continue;
@@ -1944,7 +2837,7 @@ function createRendererRegistry(packs, options = {}) {
1944
2837
  if (own !== void 0) return own;
1945
2838
  if (!node.type.startsWith("custom.") || factory === void 0) return void 0;
1946
2839
  const snapshot = snapshots.get(key);
1947
- if (snapshot === void 0) return void 0;
2840
+ if (snapshot === void 0 || snapshot.kind === "code") return void 0;
1948
2841
  if (!built.has(key)) built.set(key, factory(snapshot, registry));
1949
2842
  return _nullishCoalesce(built.get(key), () => ( void 0));
1950
2843
  },
@@ -1963,8 +2856,9 @@ async function loadBuilderPage(options) {
1963
2856
  const found = bundle.page;
1964
2857
  if (found === void 0) throw new (0, _builder.BuilderNotFoundError)(slug);
1965
2858
  if (isRedirect(found)) return { kind: "redirect", redirectTo: found.redirectTo };
1966
- const data = await staticDataFor([found.document], createRendererRegistry(packs), locale, currency);
1967
- return pageOf(found, data);
2859
+ const shared = { ...found, savedSections: _nullishCoalesce(found.savedSections, () => ( bundle.savedSections)), code: _nullishCoalesce(found.code, () => ( bundle.code)) };
2860
+ const data = await staticDataFor([shared], createRendererRegistry(packs), locale, currency);
2861
+ return pageOf(shared, data);
1968
2862
  }
1969
2863
 
1970
2864
  // src/next/seo.ts
@@ -2004,7 +2898,7 @@ function pagePathOf(settings, page, resolve) {
2004
2898
  return _nullishCoalesce(_builderschema.safeUrl.call(void 0, resolve({ ...page, path }), "href", { mediaOrigin: "" }), () => ( path));
2005
2899
  }
2006
2900
  function originOf(storeUrl) {
2007
- const origin = _optionalChain([storeUrl, 'optionalAccess', _90 => _90.replace, 'call', _91 => _91(/\/+$/u, "")]);
2901
+ const origin = _optionalChain([storeUrl, 'optionalAccess', _132 => _132.replace, 'call', _133 => _133(/\/+$/u, "")]);
2008
2902
  return origin !== void 0 && ORIGIN_RE.test(origin) ? origin : void 0;
2009
2903
  }
2010
2904
  function siteLocales(settings) {