@builder.io/sdk-qwik 0.7.1-4 → 0.7.1-5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4403 @@
1
+ import { componentQrl, inlinedQrl, useStylesScopedQrl, _jsxC, _jsxS, _fnSignal, createContextId, _jsxQ, _jsxBranch, useComputedQrl, useLexicalScope, _IMMUTABLE, Slot, useStore, useContextProvider, _wrapProp, useContext, createElement, Fragment as Fragment$1, useSignal, useTaskQrl, useOn } from "@builder.io/qwik";
2
+ import { Fragment } from "@builder.io/qwik/jsx-runtime";
3
+ import { s as safeDynamicRequire } from "./node-evaluate-15fe5e77.js";
4
+ import { isServer } from "@builder.io/qwik/build";
5
+ import "node:module";
6
+ const Button = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
7
+ useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(STYLES$3, "Button_component_useStylesScoped_a1JZ0Q0Q2Oc"));
8
+ return /* @__PURE__ */ _jsxC(Fragment, {
9
+ children: props.link ? /* @__PURE__ */ _jsxS("a", {
10
+ ...props.attributes,
11
+ children: _fnSignal((p0) => p0.text, [
12
+ props
13
+ ], "p0.text")
14
+ }, {
15
+ href: _fnSignal((p0) => p0.link, [
16
+ props
17
+ ], "p0.link"),
18
+ role: "button",
19
+ target: _fnSignal((p0) => p0.openLinkInNewTab ? "_blank" : void 0, [
20
+ props
21
+ ], 'p0.openLinkInNewTab?"_blank":undefined')
22
+ }, 0, "jc_0") : /* @__PURE__ */ _jsxS("button", {
23
+ ...props.attributes,
24
+ children: _fnSignal((p0) => p0.text, [
25
+ props
26
+ ], "p0.text")
27
+ }, {
28
+ class: _fnSignal((p0) => p0.attributes.class + " button-Button", [
29
+ props
30
+ ], 'p0.attributes.class+" button-Button"'),
31
+ style: _fnSignal((p0) => p0.attributes.style, [
32
+ props
33
+ ], "p0.attributes.style")
34
+ }, 0, null)
35
+ }, 1, "jc_1");
36
+ }, "Button_component_gJoMUICXoUQ"));
37
+ const STYLES$3 = `
38
+ .button-Button {
39
+ all: unset;
40
+ }
41
+ `;
42
+ const builderContext = createContextId("Builder");
43
+ const ComponentsContext = createContextId("Components");
44
+ function getBlockComponentOptions(block) {
45
+ var _a;
46
+ return {
47
+ ...(_a = block.component) == null ? void 0 : _a.options,
48
+ ...block.options,
49
+ /**
50
+ * Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
51
+ */
52
+ builderBlock: block
53
+ };
54
+ }
55
+ const MSG_PREFIX = "[Builder.io]: ";
56
+ const logger = {
57
+ log: (...message) => console.log(MSG_PREFIX, ...message),
58
+ error: (...message) => console.error(MSG_PREFIX, ...message),
59
+ warn: (...message) => console.warn(MSG_PREFIX, ...message),
60
+ debug: (...message) => console.debug(MSG_PREFIX, ...message)
61
+ };
62
+ function isBrowser() {
63
+ return typeof window !== "undefined" && typeof document !== "undefined";
64
+ }
65
+ const TARGET = "qwik";
66
+ function isIframe() {
67
+ return isBrowser() && window.self !== window.top;
68
+ }
69
+ function isEditing() {
70
+ return isIframe() && window.location.search.indexOf("builder.frameEditing=") !== -1;
71
+ }
72
+ const getLocation = () => {
73
+ if (isBrowser()) {
74
+ const parsedLocation = new URL(location.href);
75
+ if (parsedLocation.pathname === "")
76
+ parsedLocation.pathname = "/";
77
+ return parsedLocation;
78
+ } else {
79
+ console.warn("Cannot get location for tracking in non-browser environment");
80
+ return null;
81
+ }
82
+ };
83
+ const getUserAgent = () => typeof navigator === "object" && navigator.userAgent || "";
84
+ const getUserAttributes = () => {
85
+ const userAgent = getUserAgent();
86
+ const isMobile = {
87
+ Android() {
88
+ return userAgent.match(/Android/i);
89
+ },
90
+ BlackBerry() {
91
+ return userAgent.match(/BlackBerry/i);
92
+ },
93
+ iOS() {
94
+ return userAgent.match(/iPhone|iPod/i);
95
+ },
96
+ Opera() {
97
+ return userAgent.match(/Opera Mini/i);
98
+ },
99
+ Windows() {
100
+ return userAgent.match(/IEMobile/i) || userAgent.match(/WPDesktop/i);
101
+ },
102
+ any() {
103
+ return isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows() || TARGET === "reactNative";
104
+ }
105
+ };
106
+ const isTablet = userAgent.match(/Tablet|iPad/i);
107
+ const url = getLocation();
108
+ return {
109
+ urlPath: url == null ? void 0 : url.pathname,
110
+ host: (url == null ? void 0 : url.host) || (url == null ? void 0 : url.hostname),
111
+ device: isTablet ? "tablet" : isMobile.any() ? "mobile" : "desktop"
112
+ };
113
+ };
114
+ const getFunctionArguments = ({ builder, context, event, state }) => {
115
+ return Object.entries({
116
+ state,
117
+ Builder: builder,
118
+ // legacy
119
+ builder,
120
+ context,
121
+ event
122
+ });
123
+ };
124
+ const getBuilderGlobals = () => ({
125
+ isEditing: isEditing(),
126
+ isBrowser: isBrowser(),
127
+ isServer: !isBrowser(),
128
+ getUserAttributes: () => getUserAttributes()
129
+ });
130
+ const parseCode = (code, { isExpression = true }) => {
131
+ const useReturn = (
132
+ // we disable this for cases where we definitely don't want a return
133
+ isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "))
134
+ );
135
+ const useCode = useReturn ? `return (${code});` : code;
136
+ return useCode;
137
+ };
138
+ const fastClone = (obj) => JSON.parse(JSON.stringify(obj));
139
+ const set = (obj, _path, value) => {
140
+ if (Object(obj) !== obj)
141
+ return obj;
142
+ const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
143
+ path.slice(0, -1).reduce((a, c, i) => Object(a[c]) === a[c] ? a[c] : a[c] = Math.abs(Number(path[i + 1])) >> 0 === +path[i + 1] ? [] : {}, obj)[path[path.length - 1]] = value;
144
+ return obj;
145
+ };
146
+ const ivm = safeDynamicRequire("isolated-vm");
147
+ const getSyncValName = (key) => `bldr_${key}_sync`;
148
+ const BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE";
149
+ const INJECTED_IVM_GLOBAL = "BUILDER_IVM";
150
+ const REF_TO_PROXY_FN = `
151
+ var refToProxy = (obj) => {
152
+ if (typeof obj !== 'object' || obj === null) {
153
+ return obj;
154
+ }
155
+ return new Proxy({}, {
156
+ get(target, key) {
157
+ if (key === 'copySync') {
158
+ return () => obj.copySync();
159
+ }
160
+ const val = obj.getSync(key);
161
+ if (typeof val?.getSync === 'function') {
162
+ return refToProxy(val);
163
+ }
164
+ return val;
165
+ },
166
+ set(target, key, value) {
167
+ const v = typeof value === 'object' ? new ${INJECTED_IVM_GLOBAL}.Reference(value) : value;
168
+ obj.setSync(key, v);
169
+ ${BUILDER_SET_STATE_NAME}(key, value)
170
+ },
171
+ deleteProperty(target, key) {
172
+ obj.deleteSync(key);
173
+ }
174
+ })
175
+ }
176
+ `;
177
+ const processCode = ({ code, args }) => {
178
+ const fnArgs = args.map(([name]) => `var ${name} = refToProxy(${getSyncValName(name)}); `).join("");
179
+ return `
180
+ ${REF_TO_PROXY_FN}
181
+ ${fnArgs}
182
+ function theFunction() {
183
+ ${code}
184
+ }
185
+
186
+ let output = theFunction()
187
+
188
+ if (typeof output === 'object' && output !== null) {
189
+ output = JSON.stringify(output.copySync ? output.copySync() : output);
190
+ }
191
+
192
+ output;
193
+ `;
194
+ };
195
+ const getIsolateContext = () => {
196
+ const isolate = new ivm.Isolate({
197
+ memoryLimit: 128
198
+ });
199
+ return isolate.createContextSync();
200
+ };
201
+ const runInNode = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
202
+ const state = fastClone({
203
+ ...rootState,
204
+ ...localState
205
+ });
206
+ const args = getFunctionArguments({
207
+ builder,
208
+ context,
209
+ event,
210
+ state
211
+ });
212
+ const isolateContext = getIsolateContext();
213
+ const jail = isolateContext.global;
214
+ jail.setSync("global", jail.derefInto());
215
+ jail.setSync("log", function(...logArgs) {
216
+ console.log(...logArgs);
217
+ });
218
+ jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
219
+ set(rootState, key, value);
220
+ rootSetState == null ? void 0 : rootSetState(rootState);
221
+ });
222
+ args.forEach(([key, arg]) => {
223
+ const val = typeof arg === "object" ? new ivm.Reference(
224
+ // workaround: methods with default values for arguments is not being cloned over
225
+ key === "builder" ? {
226
+ ...arg,
227
+ getUserAttributes: () => arg.getUserAttributes()
228
+ } : arg
229
+ ) : null;
230
+ jail.setSync(getSyncValName(key), val);
231
+ });
232
+ jail.setSync(INJECTED_IVM_GLOBAL, ivm);
233
+ const evalStr = processCode({
234
+ code,
235
+ args
236
+ });
237
+ const resultStr = isolateContext.evalSync(evalStr);
238
+ try {
239
+ const res = JSON.parse(resultStr);
240
+ return res;
241
+ } catch (_error) {
242
+ return resultStr;
243
+ }
244
+ };
245
+ const runInBrowser = ({ code, builder, context, event, localState, rootSetState, rootState }) => {
246
+ const functionArgs = getFunctionArguments({
247
+ builder,
248
+ context,
249
+ event,
250
+ state: flattenState(rootState, localState, rootSetState)
251
+ });
252
+ return new Function(...functionArgs.map(([name]) => name), code)(...functionArgs.map(([, value]) => value));
253
+ };
254
+ function flattenState(rootState, localState, rootSetState) {
255
+ if (rootState === localState)
256
+ throw new Error("rootState === localState");
257
+ return new Proxy(rootState, {
258
+ get: (_, prop) => {
259
+ if (localState && prop in localState)
260
+ return localState[prop];
261
+ return rootState[prop];
262
+ },
263
+ set: (_, prop, value) => {
264
+ if (localState && prop in localState)
265
+ throw new Error("Writing to local state is not allowed as it is read-only.");
266
+ rootState[prop] = value;
267
+ rootSetState == null ? void 0 : rootSetState(rootState);
268
+ return true;
269
+ }
270
+ });
271
+ }
272
+ const chooseBrowserOrServerEval = (args) => !isServer ? runInBrowser(args) : runInNode(args);
273
+ function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression = true }) {
274
+ if (code === "") {
275
+ logger.warn("Skipping evaluation of empty code block.");
276
+ return;
277
+ }
278
+ const args = {
279
+ code: parseCode(code, {
280
+ isExpression
281
+ }),
282
+ builder: getBuilderGlobals(),
283
+ context,
284
+ event,
285
+ rootSetState,
286
+ rootState,
287
+ localState
288
+ };
289
+ try {
290
+ return chooseBrowserOrServerEval(args);
291
+ } catch (e) {
292
+ logger.error("Failed code evaluation: " + e.message, {
293
+ code
294
+ });
295
+ return void 0;
296
+ }
297
+ }
298
+ function transformBlock(block) {
299
+ return block;
300
+ }
301
+ const evaluateBindings = ({ block, context, localState, rootState, rootSetState }) => {
302
+ if (!block.bindings)
303
+ return block;
304
+ const copy = fastClone(block);
305
+ const copied = {
306
+ ...copy,
307
+ properties: {
308
+ ...copy.properties
309
+ },
310
+ actions: {
311
+ ...copy.actions
312
+ }
313
+ };
314
+ for (const binding in block.bindings) {
315
+ const expression = block.bindings[binding];
316
+ const value = evaluate({
317
+ code: expression,
318
+ localState,
319
+ rootState,
320
+ rootSetState,
321
+ context
322
+ });
323
+ set(copied, binding, value);
324
+ }
325
+ return copied;
326
+ };
327
+ function getProcessedBlock({ block, context, shouldEvaluateBindings, localState, rootState, rootSetState }) {
328
+ const transformedBlock = transformBlock(block);
329
+ if (shouldEvaluateBindings)
330
+ return evaluateBindings({
331
+ block: transformedBlock,
332
+ localState,
333
+ rootState,
334
+ rootSetState,
335
+ context
336
+ });
337
+ else
338
+ return transformedBlock;
339
+ }
340
+ const EMPTY_HTML_ELEMENTS = [
341
+ "area",
342
+ "base",
343
+ "br",
344
+ "col",
345
+ "embed",
346
+ "hr",
347
+ "img",
348
+ "input",
349
+ "keygen",
350
+ "link",
351
+ "meta",
352
+ "param",
353
+ "source",
354
+ "track",
355
+ "wbr"
356
+ ];
357
+ const isEmptyHtmlElement = (tagName) => {
358
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
359
+ };
360
+ const getComponent = ({ block, context, registeredComponents }) => {
361
+ var _a;
362
+ const componentName = (_a = getProcessedBlock({
363
+ block,
364
+ localState: context.localState,
365
+ rootState: context.rootState,
366
+ rootSetState: context.rootSetState,
367
+ context: context.context,
368
+ shouldEvaluateBindings: false
369
+ }).component) == null ? void 0 : _a.name;
370
+ if (!componentName)
371
+ return null;
372
+ const ref = registeredComponents[componentName];
373
+ if (!ref) {
374
+ console.warn(`
375
+ Could not find a registered component named "${componentName}".
376
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
377
+ return void 0;
378
+ } else
379
+ return ref;
380
+ };
381
+ const getRepeatItemData = ({ block, context }) => {
382
+ const { repeat, ...blockWithoutRepeat } = block;
383
+ if (!(repeat == null ? void 0 : repeat.collection))
384
+ return void 0;
385
+ const itemsArray = evaluate({
386
+ code: repeat.collection,
387
+ localState: context.localState,
388
+ rootState: context.rootState,
389
+ rootSetState: context.rootSetState,
390
+ context: context.context
391
+ });
392
+ if (!Array.isArray(itemsArray))
393
+ return void 0;
394
+ const collectionName = repeat.collection.split(".").pop();
395
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
396
+ const repeatArray = itemsArray.map((item, index) => ({
397
+ context: {
398
+ ...context,
399
+ localState: {
400
+ ...context.localState,
401
+ $index: index,
402
+ $item: item,
403
+ [itemNameToUse]: item,
404
+ [`$${itemNameToUse}Index`]: index
405
+ }
406
+ },
407
+ block: blockWithoutRepeat
408
+ }));
409
+ return repeatArray;
410
+ };
411
+ const SIZES = {
412
+ small: {
413
+ min: 320,
414
+ default: 321,
415
+ max: 640
416
+ },
417
+ medium: {
418
+ min: 641,
419
+ default: 642,
420
+ max: 991
421
+ },
422
+ large: {
423
+ min: 990,
424
+ default: 991,
425
+ max: 1200
426
+ }
427
+ };
428
+ const getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
429
+ const getSizesForBreakpoints = ({ small, medium }) => {
430
+ const newSizes = fastClone(SIZES);
431
+ if (!small || !medium)
432
+ return newSizes;
433
+ const smallMin = Math.floor(small / 2);
434
+ newSizes.small = {
435
+ max: small,
436
+ min: smallMin,
437
+ default: smallMin + 1
438
+ };
439
+ const mediumMin = newSizes.small.max + 1;
440
+ newSizes.medium = {
441
+ max: medium,
442
+ min: mediumMin,
443
+ default: mediumMin + 1
444
+ };
445
+ const largeMin = newSizes.medium.max + 1;
446
+ newSizes.large = {
447
+ max: 2e3,
448
+ // TODO: decide upper limit
449
+ min: largeMin,
450
+ default: largeMin + 1
451
+ };
452
+ return newSizes;
453
+ };
454
+ const camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
455
+ const checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
456
+ const convertStyleMapToCSSArray = (style) => {
457
+ const cssProps = Object.entries(style).map(([key, value]) => {
458
+ if (typeof value === "string")
459
+ return `${camelToKebabCase(key)}: ${value};`;
460
+ else
461
+ return void 0;
462
+ });
463
+ return cssProps.filter(checkIsDefined);
464
+ };
465
+ const convertStyleMapToCSS = (style) => convertStyleMapToCSSArray(style).join("\n");
466
+ const createCssClass = ({ mediaQuery, className, styles }) => {
467
+ const cssClass = `.${className} {
468
+ ${convertStyleMapToCSS(styles)}
469
+ }`;
470
+ if (mediaQuery)
471
+ return `${mediaQuery} {
472
+ ${cssClass}
473
+ }`;
474
+ else
475
+ return cssClass;
476
+ };
477
+ const InlinedStyles = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
478
+ return /* @__PURE__ */ _jsxQ("style", null, {
479
+ dangerouslySetInnerHTML: _fnSignal((p0) => p0.styles, [
480
+ props
481
+ ], "p0.styles"),
482
+ id: _fnSignal((p0) => p0.id, [
483
+ props
484
+ ], "p0.id")
485
+ }, null, 3, "NG_0");
486
+ }, "InlinedStyles_component_IOsg46hMexk"));
487
+ const BlockStyles = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
488
+ _jsxBranch();
489
+ const canShowBlock = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
490
+ const [props2] = useLexicalScope();
491
+ const processedBlock = getProcessedBlock({
492
+ block: props2.block,
493
+ localState: props2.context.localState,
494
+ rootState: props2.context.rootState,
495
+ rootSetState: props2.context.rootSetState,
496
+ context: props2.context.context,
497
+ shouldEvaluateBindings: true
498
+ });
499
+ if (checkIsDefined(processedBlock.hide))
500
+ return !processedBlock.hide;
501
+ if (checkIsDefined(processedBlock.show))
502
+ return processedBlock.show;
503
+ return true;
504
+ }, "BlockStyles_component_canShowBlock_useComputed_YHoS9Lak9z4", [
505
+ props
506
+ ]));
507
+ const css = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
508
+ var _a;
509
+ const [props2] = useLexicalScope();
510
+ const processedBlock = getProcessedBlock({
511
+ block: props2.block,
512
+ localState: props2.context.localState,
513
+ rootState: props2.context.rootState,
514
+ rootSetState: props2.context.rootSetState,
515
+ context: props2.context.context,
516
+ shouldEvaluateBindings: true
517
+ });
518
+ const styles = processedBlock.responsiveStyles;
519
+ const content = props2.context.content;
520
+ const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(((_a = content == null ? void 0 : content.meta) == null ? void 0 : _a.breakpoints) || {});
521
+ const largeStyles = styles == null ? void 0 : styles.large;
522
+ const mediumStyles = styles == null ? void 0 : styles.medium;
523
+ const smallStyles = styles == null ? void 0 : styles.small;
524
+ const className = processedBlock.id;
525
+ if (!className)
526
+ return "";
527
+ const largeStylesClass = largeStyles ? createCssClass({
528
+ className,
529
+ styles: largeStyles
530
+ }) : "";
531
+ const mediumStylesClass = mediumStyles ? createCssClass({
532
+ className,
533
+ styles: mediumStyles,
534
+ mediaQuery: getMaxWidthQueryForSize("medium", sizesWithUpdatedBreakpoints)
535
+ }) : "";
536
+ const smallStylesClass = smallStyles ? createCssClass({
537
+ className,
538
+ styles: smallStyles,
539
+ mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
540
+ }) : "";
541
+ return [
542
+ largeStylesClass,
543
+ mediumStylesClass,
544
+ smallStylesClass
545
+ ].join(" ");
546
+ }, "BlockStyles_component_css_useComputed_b9Ru8qTcNik", [
547
+ props
548
+ ]));
549
+ return /* @__PURE__ */ _jsxC(Fragment, {
550
+ children: css.value && canShowBlock.value ? /* @__PURE__ */ _jsxC(InlinedStyles, {
551
+ get styles() {
552
+ return css.value;
553
+ },
554
+ [_IMMUTABLE]: {
555
+ styles: _fnSignal((p0) => p0.value, [
556
+ css
557
+ ], "p0.value")
558
+ }
559
+ }, 3, "8B_0") : null
560
+ }, 1, "8B_1");
561
+ }, "BlockStyles_component_0lZeirBI638"));
562
+ function capitalizeFirstLetter(string) {
563
+ return string.charAt(0).toUpperCase() + string.slice(1);
564
+ }
565
+ const getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}$`;
566
+ function createEventHandler(value, options) {
567
+ return /* @__PURE__ */ inlinedQrl((event) => {
568
+ const [options2, value2] = useLexicalScope();
569
+ return evaluate({
570
+ code: value2,
571
+ context: options2.context,
572
+ localState: options2.localState,
573
+ rootState: options2.rootState,
574
+ rootSetState: options2.rootSetState,
575
+ event
576
+ });
577
+ }, "createEventHandler_7wCAiJVliNE", [
578
+ options,
579
+ value
580
+ ]);
581
+ }
582
+ function getBlockActions(options) {
583
+ const obj = {};
584
+ const optionActions = options.block.actions ?? {};
585
+ for (const key in optionActions) {
586
+ if (!optionActions.hasOwnProperty(key))
587
+ continue;
588
+ const value = optionActions[key];
589
+ let eventHandlerName = getEventHandlerName(key);
590
+ if (options.stripPrefix)
591
+ switch (TARGET) {
592
+ case "vue2":
593
+ case "vue3":
594
+ eventHandlerName = eventHandlerName.replace("v-on:", "");
595
+ break;
596
+ case "svelte":
597
+ eventHandlerName = eventHandlerName.replace("on:", "");
598
+ break;
599
+ }
600
+ obj[eventHandlerName] = createEventHandler(value, options);
601
+ }
602
+ return obj;
603
+ }
604
+ function transformBlockProperties(properties) {
605
+ return properties;
606
+ }
607
+ const extractRelevantRootBlockProperties = (block) => {
608
+ return {
609
+ href: block.href
610
+ };
611
+ };
612
+ function getBlockProperties({ block, context }) {
613
+ var _a;
614
+ const properties = {
615
+ ...extractRelevantRootBlockProperties(block),
616
+ ...block.properties,
617
+ "builder-id": block.id,
618
+ style: block.style ? getStyleAttribute(block.style) : void 0,
619
+ class: [
620
+ block.id,
621
+ "builder-block",
622
+ block.class,
623
+ (_a = block.properties) == null ? void 0 : _a.class
624
+ ].filter(Boolean).join(" ")
625
+ };
626
+ return transformBlockProperties(properties);
627
+ }
628
+ function getStyleAttribute(style) {
629
+ switch (TARGET) {
630
+ case "svelte":
631
+ case "vue2":
632
+ case "vue3":
633
+ case "solid":
634
+ return convertStyleMapToCSSArray(style).join(" ");
635
+ case "qwik":
636
+ case "reactNative":
637
+ case "react":
638
+ case "rsc":
639
+ return style;
640
+ }
641
+ }
642
+ const BlockWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
643
+ _jsxBranch();
644
+ return /* @__PURE__ */ _jsxC(Fragment, {
645
+ children: props.hasChildren ? /* @__PURE__ */ _jsxC(props.Wrapper, {
646
+ ...getBlockProperties({
647
+ block: props.block,
648
+ context: props.context
649
+ }),
650
+ ...getBlockActions({
651
+ block: props.block,
652
+ rootState: props.context.rootState,
653
+ rootSetState: props.context.rootSetState,
654
+ localState: props.context.localState,
655
+ context: props.context.context,
656
+ stripPrefix: true
657
+ }),
658
+ children: /* @__PURE__ */ _jsxC(Slot, null, 3, "87_0")
659
+ }, 0, "87_1") : /* @__PURE__ */ _jsxC(props.Wrapper, {
660
+ ...getBlockProperties({
661
+ block: props.block,
662
+ context: props.context
663
+ }),
664
+ ...getBlockActions({
665
+ block: props.block,
666
+ rootState: props.context.rootState,
667
+ rootSetState: props.context.rootSetState,
668
+ localState: props.context.localState,
669
+ context: props.context.context,
670
+ stripPrefix: true
671
+ })
672
+ }, 0, "87_2")
673
+ }, 1, "87_3");
674
+ }, "BlockWrapper_component_kOI0j0aW8Nw"));
675
+ const InteractiveElement = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
676
+ return /* @__PURE__ */ _jsxC(props.Wrapper, {
677
+ ...props.wrapperProps,
678
+ attributes: {
679
+ ...getBlockProperties({
680
+ block: props.block,
681
+ context: props.context
682
+ }),
683
+ ...getBlockActions({
684
+ block: props.block,
685
+ rootState: props.context.rootState,
686
+ rootSetState: props.context.rootSetState,
687
+ localState: props.context.localState,
688
+ context: props.context.context
689
+ })
690
+ },
691
+ children: /* @__PURE__ */ _jsxC(Slot, null, 3, "q0_0")
692
+ }, 0, "q0_1");
693
+ }, "InteractiveElement_component_0UqfJpjhn0g"));
694
+ const getWrapperProps = ({ componentOptions, builderBlock, context, componentRef, includeBlockProps, isInteractive, contextValue }) => {
695
+ const interactiveElementProps = {
696
+ Wrapper: componentRef,
697
+ block: builderBlock,
698
+ context,
699
+ wrapperProps: componentOptions
700
+ };
701
+ return isInteractive ? interactiveElementProps : {
702
+ ...componentOptions,
703
+ /**
704
+ * If `noWrap` is set to `true`, then the block's props/attributes are provided to the
705
+ * component itself directly. Otherwise, they are provided to the wrapper element.
706
+ */
707
+ ...includeBlockProps ? {
708
+ attributes: getBlockProperties({
709
+ block: builderBlock,
710
+ context: contextValue
711
+ })
712
+ } : {}
713
+ };
714
+ };
715
+ const ComponentRef = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
716
+ const state = useStore({
717
+ Wrapper: props.isInteractive ? InteractiveElement : props.componentRef
718
+ });
719
+ return /* @__PURE__ */ _jsxC(Fragment, {
720
+ children: props.componentRef ? /* @__PURE__ */ _jsxC(state.Wrapper, {
721
+ ...getWrapperProps({
722
+ componentOptions: props.componentOptions,
723
+ builderBlock: props.builderBlock,
724
+ context: props.context,
725
+ componentRef: props.componentRef,
726
+ includeBlockProps: props.includeBlockProps,
727
+ isInteractive: props.isInteractive,
728
+ contextValue: props.context
729
+ }),
730
+ children: [
731
+ (props.blockChildren || []).map((child) => {
732
+ return /* @__PURE__ */ _jsxC(Block, {
733
+ block: child,
734
+ get context() {
735
+ return props.context;
736
+ },
737
+ get registeredComponents() {
738
+ return props.registeredComponents;
739
+ },
740
+ [_IMMUTABLE]: {
741
+ context: _fnSignal((p0) => p0.context, [
742
+ props
743
+ ], "p0.context"),
744
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
745
+ props
746
+ ], "p0.registeredComponents")
747
+ }
748
+ }, 3, "block-" + child.id);
749
+ }),
750
+ (props.blockChildren || []).map((child) => {
751
+ return /* @__PURE__ */ _jsxC(BlockStyles, {
752
+ block: child,
753
+ get context() {
754
+ return props.context;
755
+ },
756
+ [_IMMUTABLE]: {
757
+ context: _fnSignal((p0) => p0.context, [
758
+ props
759
+ ], "p0.context")
760
+ }
761
+ }, 3, "block-style-" + child.id);
762
+ })
763
+ ]
764
+ }, 0, "z6_0") : null
765
+ }, 1, "z6_1");
766
+ }, "ComponentRef_component_tFQoBV6UFdc"));
767
+ const RepeatedBlock = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
768
+ const state = useStore({
769
+ store: props.repeatContext
770
+ });
771
+ useContextProvider(builderContext, state.store);
772
+ return /* @__PURE__ */ _jsxC(Block, {
773
+ get block() {
774
+ return props.block;
775
+ },
776
+ get context() {
777
+ return state.store;
778
+ },
779
+ get registeredComponents() {
780
+ return props.registeredComponents;
781
+ },
782
+ [_IMMUTABLE]: {
783
+ block: _fnSignal((p0) => p0.block, [
784
+ props
785
+ ], "p0.block"),
786
+ context: _fnSignal((p0) => p0.store, [
787
+ state
788
+ ], "p0.store"),
789
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
790
+ props
791
+ ], "p0.registeredComponents")
792
+ }
793
+ }, 3, "GO_0");
794
+ }, "RepeatedBlock_component_JK1l2jKcfwA"));
795
+ const Block = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
796
+ var _a;
797
+ _jsxBranch();
798
+ const state = useStore({
799
+ childrenContext: props.context
800
+ });
801
+ const blockComponent = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
802
+ const [props2] = useLexicalScope();
803
+ return getComponent({
804
+ block: props2.block,
805
+ context: props2.context,
806
+ registeredComponents: props2.registeredComponents
807
+ });
808
+ }, "Block_component_blockComponent_useComputed_83sGy9Xlsi0", [
809
+ props
810
+ ]));
811
+ const repeatItem = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
812
+ const [props2] = useLexicalScope();
813
+ return getRepeatItemData({
814
+ block: props2.block,
815
+ context: props2.context
816
+ });
817
+ }, "Block_component_repeatItem_useComputed_j31Y3wFqSCM", [
818
+ props
819
+ ]));
820
+ const processedBlock = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
821
+ const [props2, repeatItem2] = useLexicalScope();
822
+ return repeatItem2.value ? props2.block : getProcessedBlock({
823
+ block: props2.block,
824
+ localState: props2.context.localState,
825
+ rootState: props2.context.rootState,
826
+ rootSetState: props2.context.rootSetState,
827
+ context: props2.context.context,
828
+ shouldEvaluateBindings: true
829
+ });
830
+ }, "Block_component_processedBlock_useComputed_ESKw0l5FcBc", [
831
+ props,
832
+ repeatItem
833
+ ]));
834
+ const Tag = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
835
+ const [props2] = useLexicalScope();
836
+ return props2.block.tagName || "div";
837
+ }, "Block_component_Tag_useComputed_eQnDgbcBW2A", [
838
+ props
839
+ ]));
840
+ const canShowBlock = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
841
+ const [processedBlock2] = useLexicalScope();
842
+ if ("hide" in processedBlock2.value)
843
+ return !processedBlock2.value.hide;
844
+ if ("show" in processedBlock2.value)
845
+ return processedBlock2.value.show;
846
+ return true;
847
+ }, "Block_component_canShowBlock_useComputed_NJEFz8ICF08", [
848
+ processedBlock
849
+ ]));
850
+ const childrenWithoutParentComponent = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
851
+ var _a2;
852
+ const [blockComponent2, processedBlock2, repeatItem2] = useLexicalScope();
853
+ const shouldRenderChildrenOutsideRef = !((_a2 = blockComponent2.value) == null ? void 0 : _a2.component) && !repeatItem2.value;
854
+ return shouldRenderChildrenOutsideRef ? processedBlock2.value.children ?? [] : [];
855
+ }, "Block_component_childrenWithoutParentComponent_useComputed_0WENYGElWnc", [
856
+ blockComponent,
857
+ processedBlock,
858
+ repeatItem
859
+ ]));
860
+ const componentRefProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
861
+ var _a2, _b, _c, _d, _e;
862
+ const [blockComponent2, processedBlock2, props2, state2] = useLexicalScope();
863
+ return {
864
+ blockChildren: processedBlock2.value.children ?? [],
865
+ componentRef: (_a2 = blockComponent2.value) == null ? void 0 : _a2.component,
866
+ componentOptions: {
867
+ ...getBlockComponentOptions(processedBlock2.value),
868
+ builderContext: props2.context,
869
+ ...((_b = blockComponent2.value) == null ? void 0 : _b.name) === "Symbol" || ((_c = blockComponent2.value) == null ? void 0 : _c.name) === "Columns" ? {
870
+ builderComponents: props2.registeredComponents
871
+ } : {}
872
+ },
873
+ context: state2.childrenContext,
874
+ registeredComponents: props2.registeredComponents,
875
+ builderBlock: processedBlock2.value,
876
+ includeBlockProps: ((_d = blockComponent2.value) == null ? void 0 : _d.noWrap) === true,
877
+ isInteractive: !((_e = blockComponent2.value) == null ? void 0 : _e.isRSC)
878
+ };
879
+ }, "Block_component_componentRefProps_useComputed_Ikbl8VO04ho", [
880
+ blockComponent,
881
+ processedBlock,
882
+ props,
883
+ state
884
+ ]));
885
+ return /* @__PURE__ */ _jsxC(Fragment, {
886
+ children: canShowBlock.value ? !((_a = blockComponent.value) == null ? void 0 : _a.noWrap) ? /* @__PURE__ */ _jsxC(Fragment, {
887
+ children: [
888
+ isEmptyHtmlElement(Tag.value) ? /* @__PURE__ */ _jsxC(BlockWrapper, {
889
+ get Wrapper() {
890
+ return Tag.value;
891
+ },
892
+ get block() {
893
+ return processedBlock.value;
894
+ },
895
+ get context() {
896
+ return props.context;
897
+ },
898
+ hasChildren: false,
899
+ [_IMMUTABLE]: {
900
+ Wrapper: _fnSignal((p0) => p0.value, [
901
+ Tag
902
+ ], "p0.value"),
903
+ block: _fnSignal((p0) => p0.value, [
904
+ processedBlock
905
+ ], "p0.value"),
906
+ context: _fnSignal((p0) => p0.context, [
907
+ props
908
+ ], "p0.context"),
909
+ hasChildren: _IMMUTABLE
910
+ }
911
+ }, 3, "jN_0") : null,
912
+ !isEmptyHtmlElement(Tag.value) && repeatItem.value ? (repeatItem.value || []).map((data, index) => {
913
+ return /* @__PURE__ */ _jsxC(RepeatedBlock, {
914
+ get repeatContext() {
915
+ return data.context;
916
+ },
917
+ get block() {
918
+ return data.block;
919
+ },
920
+ get registeredComponents() {
921
+ return props.registeredComponents;
922
+ },
923
+ [_IMMUTABLE]: {
924
+ block: _wrapProp(data, "block"),
925
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
926
+ props
927
+ ], "p0.registeredComponents"),
928
+ repeatContext: _wrapProp(data, "context")
929
+ }
930
+ }, 3, index);
931
+ }) : null,
932
+ !isEmptyHtmlElement(Tag.value) && !repeatItem.value ? /* @__PURE__ */ _jsxC(BlockWrapper, {
933
+ get Wrapper() {
934
+ return Tag.value;
935
+ },
936
+ get block() {
937
+ return processedBlock.value;
938
+ },
939
+ get context() {
940
+ return props.context;
941
+ },
942
+ children: [
943
+ /* @__PURE__ */ _jsxC(ComponentRef, {
944
+ ...componentRefProps.value
945
+ }, 0, "jN_1"),
946
+ (childrenWithoutParentComponent.value || []).map((child) => {
947
+ return /* @__PURE__ */ _jsxC(Block, {
948
+ block: child,
949
+ get context() {
950
+ return state.childrenContext;
951
+ },
952
+ get registeredComponents() {
953
+ return props.registeredComponents;
954
+ },
955
+ [_IMMUTABLE]: {
956
+ context: _fnSignal((p0) => p0.childrenContext, [
957
+ state
958
+ ], "p0.childrenContext"),
959
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
960
+ props
961
+ ], "p0.registeredComponents")
962
+ }
963
+ }, 3, "block-" + child.id);
964
+ }),
965
+ (childrenWithoutParentComponent.value || []).map((child) => {
966
+ return /* @__PURE__ */ _jsxC(BlockStyles, {
967
+ block: child,
968
+ get context() {
969
+ return state.childrenContext;
970
+ },
971
+ [_IMMUTABLE]: {
972
+ context: _fnSignal((p0) => p0.childrenContext, [
973
+ state
974
+ ], "p0.childrenContext")
975
+ }
976
+ }, 3, "block-style-" + child.id);
977
+ })
978
+ ],
979
+ hasChildren: true,
980
+ [_IMMUTABLE]: {
981
+ Wrapper: _fnSignal((p0) => p0.value, [
982
+ Tag
983
+ ], "p0.value"),
984
+ block: _fnSignal((p0) => p0.value, [
985
+ processedBlock
986
+ ], "p0.value"),
987
+ context: _fnSignal((p0) => p0.context, [
988
+ props
989
+ ], "p0.context"),
990
+ hasChildren: _IMMUTABLE
991
+ }
992
+ }, 1, "jN_2") : null
993
+ ]
994
+ }, 1, "jN_3") : /* @__PURE__ */ _jsxC(ComponentRef, {
995
+ ...componentRefProps.value
996
+ }, 0, "jN_4") : null
997
+ }, 1, "jN_5");
998
+ }, "Block_component_nnPv0RY0U0k"));
999
+ const onClick$1 = function onClick2(props, state) {
1000
+ var _a, _b;
1001
+ if (isEditing() && !((_a = props.blocks) == null ? void 0 : _a.length))
1002
+ (_b = window.parent) == null ? void 0 : _b.postMessage({
1003
+ type: "builder.clickEmptyBlocks",
1004
+ data: {
1005
+ parentElementId: props.parent,
1006
+ dataPath: props.path
1007
+ }
1008
+ }, "*");
1009
+ };
1010
+ const onMouseEnter = function onMouseEnter2(props, state) {
1011
+ var _a, _b;
1012
+ if (isEditing() && !((_a = props.blocks) == null ? void 0 : _a.length))
1013
+ (_b = window.parent) == null ? void 0 : _b.postMessage({
1014
+ type: "builder.hoverEmptyBlocks",
1015
+ data: {
1016
+ parentElementId: props.parent,
1017
+ dataPath: props.path
1018
+ }
1019
+ }, "*");
1020
+ };
1021
+ const BlocksWrapper = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1022
+ useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(STYLES$2, "BlocksWrapper_component_useStylesScoped_Kj0S9AOXQ0o"));
1023
+ const className = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1024
+ var _a;
1025
+ const [props2] = useLexicalScope();
1026
+ return "builder-blocks" + (!((_a = props2.blocks) == null ? void 0 : _a.length) ? " no-blocks" : "");
1027
+ }, "BlocksWrapper_component_className_useComputed_J5SSSH2Xf08", [
1028
+ props
1029
+ ]));
1030
+ const state = {};
1031
+ return /* @__PURE__ */ _jsxQ("div", {
1032
+ onClick$: /* @__PURE__ */ inlinedQrl((event) => {
1033
+ const [props2, state2] = useLexicalScope();
1034
+ return onClick$1(props2);
1035
+ }, "BlocksWrapper_component_div_onClick_1NkidSBS3D0", [
1036
+ props,
1037
+ state
1038
+ ]),
1039
+ onKeyPress$: /* @__PURE__ */ inlinedQrl((event) => {
1040
+ const [props2, state2] = useLexicalScope();
1041
+ return onClick$1(props2);
1042
+ }, "BlocksWrapper_component_div_onKeyPress_Aaf0oNYOi80", [
1043
+ props,
1044
+ state
1045
+ ]),
1046
+ onMouseEnter$: /* @__PURE__ */ inlinedQrl((event) => {
1047
+ const [props2, state2] = useLexicalScope();
1048
+ return onMouseEnter(props2);
1049
+ }, "BlocksWrapper_component_div_onMouseEnter_TxzAP5tI9Zc", [
1050
+ props,
1051
+ state
1052
+ ])
1053
+ }, {
1054
+ "builder-parent-id": _fnSignal((p0) => p0.parent, [
1055
+ props
1056
+ ], "p0.parent"),
1057
+ "builder-path": _fnSignal((p0) => p0.path, [
1058
+ props
1059
+ ], "p0.path"),
1060
+ class: _fnSignal((p0) => p0.value + " div-BlocksWrapper", [
1061
+ className
1062
+ ], 'p0.value+" div-BlocksWrapper"'),
1063
+ style: _fnSignal((p0) => p0.styleProp, [
1064
+ props
1065
+ ], "p0.styleProp")
1066
+ }, /* @__PURE__ */ _jsxC(Slot, null, 3, "3u_0"), 0, "3u_1");
1067
+ }, "BlocksWrapper_component_45hR0o6abzg"));
1068
+ const STYLES$2 = `
1069
+ .div-BlocksWrapper {
1070
+ display: flex;
1071
+ flex-direction: column;
1072
+ align-items: stretch;
1073
+ }
1074
+ `;
1075
+ const Blocks = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1076
+ const builderContext$1 = useContext(builderContext);
1077
+ const componentsContext = useContext(ComponentsContext);
1078
+ return /* @__PURE__ */ _jsxC(BlocksWrapper, {
1079
+ get blocks() {
1080
+ return props.blocks;
1081
+ },
1082
+ get parent() {
1083
+ return props.parent;
1084
+ },
1085
+ get path() {
1086
+ return props.path;
1087
+ },
1088
+ get styleProp() {
1089
+ return props.styleProp;
1090
+ },
1091
+ children: [
1092
+ props.blocks ? (props.blocks || []).map((block) => {
1093
+ return /* @__PURE__ */ _jsxC(Block, {
1094
+ block,
1095
+ get context() {
1096
+ return props.context || builderContext$1;
1097
+ },
1098
+ get registeredComponents() {
1099
+ return props.registeredComponents || componentsContext.registeredComponents;
1100
+ },
1101
+ [_IMMUTABLE]: {
1102
+ context: _fnSignal((p0, p1) => p1.context || p0, [
1103
+ builderContext$1,
1104
+ props
1105
+ ], "p1.context||p0"),
1106
+ registeredComponents: _fnSignal((p0, p1) => p1.registeredComponents || p0.registeredComponents, [
1107
+ componentsContext,
1108
+ props
1109
+ ], "p1.registeredComponents||p0.registeredComponents")
1110
+ }
1111
+ }, 3, "render-block-" + block.id);
1112
+ }) : null,
1113
+ props.blocks ? (props.blocks || []).map((block) => {
1114
+ return /* @__PURE__ */ _jsxC(BlockStyles, {
1115
+ block,
1116
+ get context() {
1117
+ return props.context || builderContext$1;
1118
+ },
1119
+ [_IMMUTABLE]: {
1120
+ context: _fnSignal((p0, p1) => p1.context || p0, [
1121
+ builderContext$1,
1122
+ props
1123
+ ], "p1.context||p0")
1124
+ }
1125
+ }, 3, "block-style-" + block.id);
1126
+ }) : null
1127
+ ],
1128
+ [_IMMUTABLE]: {
1129
+ blocks: _fnSignal((p0) => p0.blocks, [
1130
+ props
1131
+ ], "p0.blocks"),
1132
+ parent: _fnSignal((p0) => p0.parent, [
1133
+ props
1134
+ ], "p0.parent"),
1135
+ path: _fnSignal((p0) => p0.path, [
1136
+ props
1137
+ ], "p0.path"),
1138
+ styleProp: _fnSignal((p0) => p0.styleProp, [
1139
+ props
1140
+ ], "p0.styleProp")
1141
+ }
1142
+ }, 1, "0n_0");
1143
+ }, "Blocks_component_PI1ErWPzPEg"));
1144
+ function deoptSignal(value) {
1145
+ return value;
1146
+ }
1147
+ const getWidth = function getWidth2(props, state, index) {
1148
+ var _a;
1149
+ return ((_a = state.cols[index]) == null ? void 0 : _a.width) || 100 / state.cols.length;
1150
+ };
1151
+ const getColumnCssWidth = function getColumnCssWidth2(props, state, index) {
1152
+ const subtractWidth = state.gutterSize * (state.cols.length - 1) / state.cols.length;
1153
+ return `calc(${getWidth(props, state, index)}% - ${subtractWidth}px)`;
1154
+ };
1155
+ const getTabletStyle = function getTabletStyle2(props, state, { stackedStyle, desktopStyle }) {
1156
+ return state.stackAt === "tablet" ? stackedStyle : desktopStyle;
1157
+ };
1158
+ const getMobileStyle = function getMobileStyle2(props, state, { stackedStyle, desktopStyle }) {
1159
+ return state.stackAt === "never" ? desktopStyle : stackedStyle;
1160
+ };
1161
+ const columnCssVars = function columnCssVars2(props, state, index) {
1162
+ const gutter = index === 0 ? 0 : state.gutterSize;
1163
+ const width = getColumnCssWidth(props, state, index);
1164
+ const gutterPixels = `${gutter}px`;
1165
+ const mobileWidth = "100%";
1166
+ const mobileMarginLeft = 0;
1167
+ const marginLeftKey = "margin-left";
1168
+ return {
1169
+ width,
1170
+ [marginLeftKey]: gutterPixels,
1171
+ "--column-width-mobile": getMobileStyle(props, state, {
1172
+ stackedStyle: mobileWidth,
1173
+ desktopStyle: width
1174
+ }),
1175
+ "--column-margin-left-mobile": getMobileStyle(props, state, {
1176
+ stackedStyle: mobileMarginLeft,
1177
+ desktopStyle: gutterPixels
1178
+ }),
1179
+ "--column-width-tablet": getTabletStyle(props, state, {
1180
+ stackedStyle: mobileWidth,
1181
+ desktopStyle: width
1182
+ }),
1183
+ "--column-margin-left-tablet": getTabletStyle(props, state, {
1184
+ stackedStyle: mobileMarginLeft,
1185
+ desktopStyle: gutterPixels
1186
+ })
1187
+ };
1188
+ };
1189
+ const getWidthForBreakpointSize = function getWidthForBreakpointSize2(props, state, size) {
1190
+ var _a, _b;
1191
+ const breakpointSizes = getSizesForBreakpoints(((_b = (_a = props.builderContext.content) == null ? void 0 : _a.meta) == null ? void 0 : _b.breakpoints) || {});
1192
+ return breakpointSizes[size].max;
1193
+ };
1194
+ const Columns = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1195
+ _jsxBranch();
1196
+ const state = useStore({
1197
+ cols: props.columns || [],
1198
+ flexDir: props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column",
1199
+ gutterSize: typeof props.space === "number" ? props.space || 0 : 20,
1200
+ stackAt: props.stackColumnsAt || "tablet"
1201
+ });
1202
+ useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(STYLES$1, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
1203
+ const columnsCssVars = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1204
+ const [props2, state2] = useLexicalScope();
1205
+ return {
1206
+ "--flex-dir": state2.flexDir,
1207
+ "--flex-dir-tablet": getTabletStyle(props2, state2, {
1208
+ stackedStyle: state2.flexDir,
1209
+ desktopStyle: "row"
1210
+ })
1211
+ };
1212
+ }, "Columns_component_columnsCssVars_useComputed_adFEq2RWT9s", [
1213
+ props,
1214
+ state
1215
+ ]));
1216
+ const columnsStyles = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1217
+ const [props2, state2] = useLexicalScope();
1218
+ return `
1219
+ @media (max-width: ${getWidthForBreakpointSize(props2, state2, "medium")}px) {
1220
+ .${props2.builderBlock.id}-breakpoints {
1221
+ flex-direction: var(--flex-dir-tablet);
1222
+ align-items: stretch;
1223
+ }
1224
+
1225
+ .${props2.builderBlock.id}-breakpoints > .builder-column {
1226
+ width: var(--column-width-tablet) !important;
1227
+ margin-left: var(--column-margin-left-tablet) !important;
1228
+ }
1229
+ }
1230
+
1231
+ @media (max-width: ${getWidthForBreakpointSize(props2, state2, "small")}px) {
1232
+ .${props2.builderBlock.id}-breakpoints {
1233
+ flex-direction: var(--flex-dir);
1234
+ align-items: stretch;
1235
+ }
1236
+
1237
+ .${props2.builderBlock.id}-breakpoints > .builder-column {
1238
+ width: var(--column-width-mobile) !important;
1239
+ margin-left: var(--column-margin-left-mobile) !important;
1240
+ }
1241
+ },
1242
+ `;
1243
+ }, "Columns_component_columnsStyles_useComputed_nBtMPbzd1Wc", [
1244
+ props,
1245
+ state
1246
+ ]));
1247
+ return /* @__PURE__ */ _jsxQ("div", null, {
1248
+ class: _fnSignal((p0) => `builder-columns ${p0.builderBlock.id}-breakpoints div-Columns`, [
1249
+ props
1250
+ ], '`builder-columns ${p0.builderBlock.id}-breakpoints`+" div-Columns"'),
1251
+ style: _fnSignal((p0) => p0.value, [
1252
+ columnsCssVars
1253
+ ], "p0.value")
1254
+ }, [
1255
+ /* @__PURE__ */ _jsxC(InlinedStyles, {
1256
+ get styles() {
1257
+ return columnsStyles.value;
1258
+ },
1259
+ [_IMMUTABLE]: {
1260
+ styles: _fnSignal((p0) => p0.value, [
1261
+ columnsStyles
1262
+ ], "p0.value")
1263
+ }
1264
+ }, 3, "c0_0"),
1265
+ (props.columns || []).map((column, index) => {
1266
+ return /* @__PURE__ */ createElement("div", {
1267
+ class: "builder-column div-Columns-2",
1268
+ style: columnCssVars(props, state, index),
1269
+ key: index
1270
+ }, /* @__PURE__ */ _jsxC(Blocks, {
1271
+ path: `component.options.columns.${index}.blocks`,
1272
+ get parent() {
1273
+ return props.builderBlock.id;
1274
+ },
1275
+ get styleProp() {
1276
+ return {
1277
+ flexGrow: "1"
1278
+ };
1279
+ },
1280
+ get context() {
1281
+ return props.builderContext;
1282
+ },
1283
+ get registeredComponents() {
1284
+ return props.builderComponents;
1285
+ },
1286
+ blocks: deoptSignal(column.blocks),
1287
+ [_IMMUTABLE]: {
1288
+ context: _fnSignal((p0) => p0.builderContext, [
1289
+ props
1290
+ ], "p0.builderContext"),
1291
+ parent: _fnSignal((p0) => p0.builderBlock.id, [
1292
+ props
1293
+ ], "p0.builderBlock.id"),
1294
+ registeredComponents: _fnSignal((p0) => p0.builderComponents, [
1295
+ props
1296
+ ], "p0.builderComponents"),
1297
+ styleProp: _IMMUTABLE
1298
+ }
1299
+ }, 3, "c0_1"));
1300
+ })
1301
+ ], 1, "c0_2");
1302
+ }, "Columns_component_7yLj4bxdI6c"));
1303
+ const STYLES$1 = `
1304
+ .div-Columns {
1305
+ display: flex;
1306
+ line-height: normal;
1307
+ }
1308
+ .div-Columns-2 {
1309
+ display: flex;
1310
+ flex-direction: column;
1311
+ align-items: stretch;
1312
+ }
1313
+ `;
1314
+ const FragmentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1315
+ return /* @__PURE__ */ _jsxQ("span", null, null, /* @__PURE__ */ _jsxC(Slot, null, 3, "oj_0"), 1, "oj_1");
1316
+ }, "FragmentComponent_component_T0AypnadAK0"));
1317
+ function removeProtocol(path) {
1318
+ return path.replace(/http(s)?:/, "");
1319
+ }
1320
+ function updateQueryParam(uri = "", key, value) {
1321
+ const re = new RegExp("([?&])" + key + "=.*?(&|$)", "i");
1322
+ const separator = uri.indexOf("?") !== -1 ? "&" : "?";
1323
+ if (uri.match(re))
1324
+ return uri.replace(re, "$1" + key + "=" + encodeURIComponent(value) + "$2");
1325
+ return uri + separator + key + "=" + encodeURIComponent(value);
1326
+ }
1327
+ function getShopifyImageUrl(src, size) {
1328
+ if (!src || !(src == null ? void 0 : src.match(/cdn\.shopify\.com/)) || !size)
1329
+ return src;
1330
+ if (size === "master")
1331
+ return removeProtocol(src);
1332
+ const match = src.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
1333
+ if (match) {
1334
+ const prefix = src.split(match[0]);
1335
+ const suffix = match[3];
1336
+ const useSize = size.match("x") ? size : `${size}x`;
1337
+ return removeProtocol(`${prefix[0]}_${useSize}${suffix}`);
1338
+ }
1339
+ return null;
1340
+ }
1341
+ function getSrcSet(url) {
1342
+ if (!url)
1343
+ return url;
1344
+ const sizes = [
1345
+ 100,
1346
+ 200,
1347
+ 400,
1348
+ 800,
1349
+ 1200,
1350
+ 1600,
1351
+ 2e3
1352
+ ];
1353
+ if (url.match(/builder\.io/)) {
1354
+ let srcUrl = url;
1355
+ const widthInSrc = Number(url.split("?width=")[1]);
1356
+ if (!isNaN(widthInSrc))
1357
+ srcUrl = `${srcUrl} ${widthInSrc}w`;
1358
+ return sizes.filter((size) => size !== widthInSrc).map((size) => `${updateQueryParam(url, "width", size)} ${size}w`).concat([
1359
+ srcUrl
1360
+ ]).join(", ");
1361
+ }
1362
+ if (url.match(/cdn\.shopify\.com/))
1363
+ return sizes.map((size) => [
1364
+ getShopifyImageUrl(url, `${size}x${size}`),
1365
+ size
1366
+ ]).filter(([sizeUrl]) => !!sizeUrl).map(([sizeUrl, size]) => `${sizeUrl} ${size}w`).concat([
1367
+ url
1368
+ ]).join(", ");
1369
+ return url;
1370
+ }
1371
+ const Image = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1372
+ var _a, _b, _c, _d;
1373
+ _jsxBranch();
1374
+ useStylesScopedQrl(/* @__PURE__ */ inlinedQrl(STYLES, "Image_component_useStylesScoped_fBMYiVf9fuU"));
1375
+ const srcSetToUse = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1376
+ var _a2;
1377
+ const [props2] = useLexicalScope();
1378
+ const imageToUse = props2.image || props2.src;
1379
+ const url = imageToUse;
1380
+ if (!url || // We can auto add srcset for cdn.builder.io and shopify
1381
+ // images, otherwise you can supply this prop manually
1382
+ !(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/)))
1383
+ return props2.srcset;
1384
+ if (props2.srcset && ((_a2 = props2.image) == null ? void 0 : _a2.includes("builder.io/api/v1/image"))) {
1385
+ if (!props2.srcset.includes(props2.image.split("?")[0])) {
1386
+ console.debug("Removed given srcset");
1387
+ return getSrcSet(url);
1388
+ }
1389
+ } else if (props2.image && !props2.srcset)
1390
+ return getSrcSet(url);
1391
+ return getSrcSet(url);
1392
+ }, "Image_component_srcSetToUse_useComputed_TZMibf9Gpvw", [
1393
+ props
1394
+ ]));
1395
+ const webpSrcSet = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1396
+ var _a2;
1397
+ const [props2, srcSetToUse2] = useLexicalScope();
1398
+ if (((_a2 = srcSetToUse2.value) == null ? void 0 : _a2.match(/builder\.io/)) && !props2.noWebp)
1399
+ return srcSetToUse2.value.replace(/\?/g, "?format=webp&");
1400
+ else
1401
+ return "";
1402
+ }, "Image_component_webpSrcSet_useComputed_01YCu72BBtA", [
1403
+ props,
1404
+ srcSetToUse
1405
+ ]));
1406
+ const aspectRatioCss = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
1407
+ const [props2] = useLexicalScope();
1408
+ const aspectRatioStyles = {
1409
+ position: "absolute",
1410
+ height: "100%",
1411
+ width: "100%",
1412
+ left: "0px",
1413
+ top: "0px"
1414
+ };
1415
+ const out = props2.aspectRatio ? aspectRatioStyles : void 0;
1416
+ return out;
1417
+ }, "Image_component_aspectRatioCss_useComputed_yJ1jG0g5fbw", [
1418
+ props
1419
+ ]));
1420
+ return /* @__PURE__ */ _jsxC(Fragment$1, {
1421
+ children: [
1422
+ /* @__PURE__ */ _jsxQ("picture", null, null, [
1423
+ webpSrcSet.value ? /* @__PURE__ */ _jsxQ("source", null, {
1424
+ srcSet: _fnSignal((p0) => p0.value, [
1425
+ webpSrcSet
1426
+ ], "p0.value"),
1427
+ type: "image/webp"
1428
+ }, null, 3, "0A_0") : null,
1429
+ /* @__PURE__ */ _jsxQ("img", null, {
1430
+ alt: _fnSignal((p0) => p0.altText, [
1431
+ props
1432
+ ], "p0.altText"),
1433
+ class: _fnSignal((p0) => "builder-image" + (p0.className ? " " + p0.className : "") + " img-Image", [
1434
+ props
1435
+ ], '"builder-image"+(p0.className?" "+p0.className:"")+" img-Image"'),
1436
+ loading: "lazy",
1437
+ role: _fnSignal((p0) => p0.altText ? "presentation" : void 0, [
1438
+ props
1439
+ ], 'p0.altText?"presentation":undefined'),
1440
+ sizes: _fnSignal((p0) => p0.sizes, [
1441
+ props
1442
+ ], "p0.sizes"),
1443
+ src: _fnSignal((p0) => p0.image, [
1444
+ props
1445
+ ], "p0.image"),
1446
+ srcSet: _fnSignal((p0) => p0.value, [
1447
+ srcSetToUse
1448
+ ], "p0.value"),
1449
+ style: _fnSignal((p0, p1) => ({
1450
+ objectPosition: p1.backgroundPosition || "center",
1451
+ objectFit: p1.backgroundSize || "cover",
1452
+ ...p0.value
1453
+ }), [
1454
+ aspectRatioCss,
1455
+ props
1456
+ ], '{objectPosition:p1.backgroundPosition||"center",objectFit:p1.backgroundSize||"cover",...p0.value}')
1457
+ }, null, 3, null)
1458
+ ], 1, null),
1459
+ props.aspectRatio && !(((_b = (_a = props.builderBlock) == null ? void 0 : _a.children) == null ? void 0 : _b.length) && props.fitContent) ? /* @__PURE__ */ _jsxQ("div", null, {
1460
+ class: "builder-image-sizer div-Image",
1461
+ style: _fnSignal((p0) => ({
1462
+ paddingTop: p0.aspectRatio * 100 + "%"
1463
+ }), [
1464
+ props
1465
+ ], '{paddingTop:p0.aspectRatio*100+"%"}')
1466
+ }, null, 3, "0A_1") : null,
1467
+ ((_d = (_c = props.builderBlock) == null ? void 0 : _c.children) == null ? void 0 : _d.length) && props.fitContent ? /* @__PURE__ */ _jsxC(Slot, null, 3, "0A_2") : null,
1468
+ !props.fitContent && props.children ? /* @__PURE__ */ _jsxQ("div", null, {
1469
+ class: "div-Image-2"
1470
+ }, /* @__PURE__ */ _jsxC(Slot, null, 3, "0A_3"), 1, "0A_4") : null
1471
+ ]
1472
+ }, 1, "0A_5");
1473
+ }, "Image_component_LRxDkFa1EfU"));
1474
+ const STYLES = `
1475
+ .img-Image {
1476
+ opacity: 1;
1477
+ transition: opacity 0.2s ease-in-out;
1478
+ }
1479
+ .div-Image {
1480
+ width: 100%;
1481
+ pointer-events: none;
1482
+ font-size: 0;
1483
+ }
1484
+ .div-Image-2 {
1485
+ display: flex;
1486
+ flex-direction: column;
1487
+ align-items: stretch;
1488
+ position: absolute;
1489
+ top: 0;
1490
+ left: 0;
1491
+ width: 100%;
1492
+ height: 100%;
1493
+ }
1494
+ `;
1495
+ const SectionComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
1496
+ return /* @__PURE__ */ _jsxS("section", {
1497
+ ...props.attributes,
1498
+ children: /* @__PURE__ */ _jsxC(Slot, null, 3, "2Y_0"),
1499
+ style: {
1500
+ width: "100%",
1501
+ alignSelf: "stretch",
1502
+ flexGrow: 1,
1503
+ boxSizing: "border-box",
1504
+ maxWidth: props.maxWidth || 1200,
1505
+ display: "flex",
1506
+ flexDirection: "column",
1507
+ alignItems: "stretch",
1508
+ marginLeft: "auto",
1509
+ marginRight: "auto"
1510
+ }
1511
+ }, null, 0, "2Y_1");
1512
+ }, "SectionComponent_component_ZWF9iD5WeLg"));
1513
+ const getTopLevelDomain = (host) => {
1514
+ if (host === "localhost" || host === "127.0.0.1")
1515
+ return host;
1516
+ const parts = host.split(".");
1517
+ if (parts.length > 2)
1518
+ return parts.slice(1).join(".");
1519
+ return host;
1520
+ };
1521
+ const getCookieSync = ({ name, canTrack }) => {
1522
+ var _a;
1523
+ try {
1524
+ if (!canTrack)
1525
+ return void 0;
1526
+ return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
1527
+ } catch (err) {
1528
+ logger.warn("[COOKIE] GET error: ", (err == null ? void 0 : err.message) || err);
1529
+ return void 0;
1530
+ }
1531
+ };
1532
+ const getCookie = async (args) => getCookieSync(args);
1533
+ const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
1534
+ const SECURE_CONFIG = [
1535
+ [
1536
+ "secure",
1537
+ ""
1538
+ ],
1539
+ [
1540
+ "SameSite",
1541
+ "None"
1542
+ ]
1543
+ ];
1544
+ const createCookieString = ({ name, value, expires }) => {
1545
+ const secure = isBrowser() ? location.protocol === "https:" : true;
1546
+ const secureObj = secure ? SECURE_CONFIG : [
1547
+ []
1548
+ ];
1549
+ const expiresObj = expires ? [
1550
+ [
1551
+ "expires",
1552
+ expires.toUTCString()
1553
+ ]
1554
+ ] : [
1555
+ []
1556
+ ];
1557
+ const cookieValue = [
1558
+ [
1559
+ name,
1560
+ value
1561
+ ],
1562
+ ...expiresObj,
1563
+ [
1564
+ "path",
1565
+ "/"
1566
+ ],
1567
+ [
1568
+ "domain",
1569
+ getTopLevelDomain(window.location.hostname)
1570
+ ],
1571
+ ...secureObj
1572
+ ];
1573
+ const cookie = stringifyCookie(cookieValue);
1574
+ return cookie;
1575
+ };
1576
+ const setCookie = async ({ name, value, expires, canTrack }) => {
1577
+ try {
1578
+ if (!canTrack)
1579
+ return;
1580
+ const cookie = createCookieString({
1581
+ name,
1582
+ value,
1583
+ expires
1584
+ });
1585
+ document.cookie = cookie;
1586
+ } catch (err) {
1587
+ logger.warn("[COOKIE] SET error: ", (err == null ? void 0 : err.message) || err);
1588
+ }
1589
+ };
1590
+ const BUILDER_STORE_PREFIX = "builder.tests";
1591
+ const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
1592
+ const getContentVariationCookie = ({ contentId }) => getCookie({
1593
+ name: getContentTestKey(contentId),
1594
+ canTrack: true
1595
+ });
1596
+ const getContentVariationCookieSync = ({ contentId }) => getCookieSync({
1597
+ name: getContentTestKey(contentId),
1598
+ canTrack: true
1599
+ });
1600
+ const setContentVariationCookie = ({ contentId, value }) => setCookie({
1601
+ name: getContentTestKey(contentId),
1602
+ value,
1603
+ canTrack: true
1604
+ });
1605
+ const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
1606
+ const getRandomVariationId = ({ id, variations }) => {
1607
+ var _a;
1608
+ let n = 0;
1609
+ const random = Math.random();
1610
+ for (const id2 in variations) {
1611
+ const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
1612
+ n += testRatio;
1613
+ if (random < n)
1614
+ return id2;
1615
+ }
1616
+ return id;
1617
+ };
1618
+ const getAndSetVariantId = (args) => {
1619
+ const randomVariationId = getRandomVariationId(args);
1620
+ setContentVariationCookie({
1621
+ contentId: args.id,
1622
+ value: randomVariationId
1623
+ }).catch((err) => {
1624
+ logger.error("could not store A/B test variation: ", err);
1625
+ });
1626
+ return randomVariationId;
1627
+ };
1628
+ const getTestFields = ({ item, testGroupId }) => {
1629
+ const variationValue = item.variations[testGroupId];
1630
+ if (testGroupId === item.id || // handle edge-case where `testGroupId` points to non-existing variation
1631
+ !variationValue)
1632
+ return {
1633
+ testVariationId: item.id,
1634
+ testVariationName: "Default"
1635
+ };
1636
+ else
1637
+ return {
1638
+ data: variationValue.data,
1639
+ testVariationId: variationValue.id,
1640
+ testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
1641
+ };
1642
+ };
1643
+ const handleABTestingSync = ({ item, canTrack }) => {
1644
+ if (!canTrack)
1645
+ return item;
1646
+ if (!item)
1647
+ return void 0;
1648
+ if (!checkIsBuilderContentWithVariations(item))
1649
+ return item;
1650
+ const testGroupId = getContentVariationCookieSync({
1651
+ contentId: item.id
1652
+ }) || getAndSetVariantId({
1653
+ variations: item.variations,
1654
+ id: item.id
1655
+ });
1656
+ const variationValue = getTestFields({
1657
+ item,
1658
+ testGroupId
1659
+ });
1660
+ return {
1661
+ ...item,
1662
+ ...variationValue
1663
+ };
1664
+ };
1665
+ const handleABTesting = async ({ item, canTrack }) => {
1666
+ if (!canTrack)
1667
+ return item;
1668
+ if (!checkIsBuilderContentWithVariations(item))
1669
+ return item;
1670
+ const cookieValue = await getContentVariationCookie({
1671
+ contentId: item.id
1672
+ });
1673
+ const testGroupId = cookieValue || getAndSetVariantId({
1674
+ variations: item.variations,
1675
+ id: item.id
1676
+ });
1677
+ const variationValue = getTestFields({
1678
+ item,
1679
+ testGroupId
1680
+ });
1681
+ return {
1682
+ ...item,
1683
+ ...variationValue
1684
+ };
1685
+ };
1686
+ const getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
1687
+ const componentInfo$a = {
1688
+ name: "Core:Button",
1689
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
1690
+ defaultStyles: {
1691
+ // TODO: make min width more intuitive and set one
1692
+ appearance: "none",
1693
+ paddingTop: "15px",
1694
+ paddingBottom: "15px",
1695
+ paddingLeft: "25px",
1696
+ paddingRight: "25px",
1697
+ backgroundColor: "#000000",
1698
+ color: "white",
1699
+ borderRadius: "4px",
1700
+ textAlign: "center",
1701
+ cursor: "pointer"
1702
+ },
1703
+ inputs: [
1704
+ {
1705
+ name: "text",
1706
+ type: "text",
1707
+ defaultValue: "Click me!",
1708
+ bubble: true
1709
+ },
1710
+ {
1711
+ name: "link",
1712
+ type: "url",
1713
+ bubble: true
1714
+ },
1715
+ {
1716
+ name: "openLinkInNewTab",
1717
+ type: "boolean",
1718
+ defaultValue: false,
1719
+ friendlyName: "Open link in new tab"
1720
+ }
1721
+ ],
1722
+ static: true,
1723
+ noWrap: true
1724
+ };
1725
+ const componentInfo$9 = {
1726
+ // TODO: ways to statically preprocess JSON for references, functions, etc
1727
+ name: "Columns",
1728
+ isRSC: true,
1729
+ inputs: [
1730
+ {
1731
+ name: "columns",
1732
+ type: "array",
1733
+ broadcast: true,
1734
+ subFields: [
1735
+ {
1736
+ name: "blocks",
1737
+ type: "array",
1738
+ hideFromUI: true,
1739
+ defaultValue: [
1740
+ {
1741
+ "@type": "@builder.io/sdk:Element",
1742
+ responsiveStyles: {
1743
+ large: {
1744
+ display: "flex",
1745
+ flexDirection: "column",
1746
+ alignItems: "stretch",
1747
+ flexShrink: "0",
1748
+ position: "relative",
1749
+ marginTop: "30px",
1750
+ textAlign: "center",
1751
+ lineHeight: "normal",
1752
+ height: "auto",
1753
+ minHeight: "20px",
1754
+ minWidth: "20px",
1755
+ overflow: "hidden"
1756
+ }
1757
+ },
1758
+ component: {
1759
+ name: "Image",
1760
+ options: {
1761
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1762
+ backgroundPosition: "center",
1763
+ backgroundSize: "cover",
1764
+ aspectRatio: 0.7004048582995948
1765
+ }
1766
+ }
1767
+ },
1768
+ {
1769
+ "@type": "@builder.io/sdk:Element",
1770
+ responsiveStyles: {
1771
+ large: {
1772
+ display: "flex",
1773
+ flexDirection: "column",
1774
+ alignItems: "stretch",
1775
+ flexShrink: "0",
1776
+ position: "relative",
1777
+ marginTop: "30px",
1778
+ textAlign: "center",
1779
+ lineHeight: "normal",
1780
+ height: "auto"
1781
+ }
1782
+ },
1783
+ component: {
1784
+ name: "Text",
1785
+ options: {
1786
+ text: "<p>Enter some text...</p>"
1787
+ }
1788
+ }
1789
+ }
1790
+ ]
1791
+ },
1792
+ {
1793
+ name: "width",
1794
+ type: "number",
1795
+ hideFromUI: true,
1796
+ helperText: "Width %, e.g. set to 50 to fill half of the space"
1797
+ },
1798
+ {
1799
+ name: "link",
1800
+ type: "url",
1801
+ helperText: "Optionally set a url that clicking this column will link to"
1802
+ }
1803
+ ],
1804
+ defaultValue: [
1805
+ {
1806
+ blocks: [
1807
+ {
1808
+ "@type": "@builder.io/sdk:Element",
1809
+ responsiveStyles: {
1810
+ large: {
1811
+ display: "flex",
1812
+ flexDirection: "column",
1813
+ alignItems: "stretch",
1814
+ flexShrink: "0",
1815
+ position: "relative",
1816
+ marginTop: "30px",
1817
+ textAlign: "center",
1818
+ lineHeight: "normal",
1819
+ height: "auto",
1820
+ minHeight: "20px",
1821
+ minWidth: "20px",
1822
+ overflow: "hidden"
1823
+ }
1824
+ },
1825
+ component: {
1826
+ name: "Image",
1827
+ options: {
1828
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1829
+ backgroundPosition: "center",
1830
+ backgroundSize: "cover",
1831
+ aspectRatio: 0.7004048582995948
1832
+ }
1833
+ }
1834
+ },
1835
+ {
1836
+ "@type": "@builder.io/sdk:Element",
1837
+ responsiveStyles: {
1838
+ large: {
1839
+ display: "flex",
1840
+ flexDirection: "column",
1841
+ alignItems: "stretch",
1842
+ flexShrink: "0",
1843
+ position: "relative",
1844
+ marginTop: "30px",
1845
+ textAlign: "center",
1846
+ lineHeight: "normal",
1847
+ height: "auto"
1848
+ }
1849
+ },
1850
+ component: {
1851
+ name: "Text",
1852
+ options: {
1853
+ text: "<p>Enter some text...</p>"
1854
+ }
1855
+ }
1856
+ }
1857
+ ]
1858
+ },
1859
+ {
1860
+ blocks: [
1861
+ {
1862
+ "@type": "@builder.io/sdk:Element",
1863
+ responsiveStyles: {
1864
+ large: {
1865
+ display: "flex",
1866
+ flexDirection: "column",
1867
+ alignItems: "stretch",
1868
+ flexShrink: "0",
1869
+ position: "relative",
1870
+ marginTop: "30px",
1871
+ textAlign: "center",
1872
+ lineHeight: "normal",
1873
+ height: "auto",
1874
+ minHeight: "20px",
1875
+ minWidth: "20px",
1876
+ overflow: "hidden"
1877
+ }
1878
+ },
1879
+ component: {
1880
+ name: "Image",
1881
+ options: {
1882
+ image: "https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",
1883
+ backgroundPosition: "center",
1884
+ backgroundSize: "cover",
1885
+ aspectRatio: 0.7004048582995948
1886
+ }
1887
+ }
1888
+ },
1889
+ {
1890
+ "@type": "@builder.io/sdk:Element",
1891
+ responsiveStyles: {
1892
+ large: {
1893
+ display: "flex",
1894
+ flexDirection: "column",
1895
+ alignItems: "stretch",
1896
+ flexShrink: "0",
1897
+ position: "relative",
1898
+ marginTop: "30px",
1899
+ textAlign: "center",
1900
+ lineHeight: "normal",
1901
+ height: "auto"
1902
+ }
1903
+ },
1904
+ component: {
1905
+ name: "Text",
1906
+ options: {
1907
+ text: "<p>Enter some text...</p>"
1908
+ }
1909
+ }
1910
+ }
1911
+ ]
1912
+ }
1913
+ ],
1914
+ onChange: (options) => {
1915
+ function clearWidths() {
1916
+ columns.forEach((col) => {
1917
+ col.delete("width");
1918
+ });
1919
+ }
1920
+ const columns = options.get("columns");
1921
+ if (Array.isArray(columns)) {
1922
+ const containsColumnWithWidth = !!columns.find((col) => col.get("width"));
1923
+ if (containsColumnWithWidth) {
1924
+ const containsColumnWithoutWidth = !!columns.find((col) => !col.get("width"));
1925
+ if (containsColumnWithoutWidth)
1926
+ clearWidths();
1927
+ else {
1928
+ const sumWidths = columns.reduce((memo, col) => {
1929
+ return memo + col.get("width");
1930
+ }, 0);
1931
+ const widthsDontAddUp = sumWidths !== 100;
1932
+ if (widthsDontAddUp)
1933
+ clearWidths();
1934
+ }
1935
+ }
1936
+ }
1937
+ }
1938
+ },
1939
+ {
1940
+ name: "space",
1941
+ type: "number",
1942
+ defaultValue: 20,
1943
+ helperText: "Size of gap between columns",
1944
+ advanced: true
1945
+ },
1946
+ {
1947
+ name: "stackColumnsAt",
1948
+ type: "string",
1949
+ defaultValue: "tablet",
1950
+ helperText: "Convert horizontal columns to vertical at what device size",
1951
+ enum: [
1952
+ "tablet",
1953
+ "mobile",
1954
+ "never"
1955
+ ],
1956
+ advanced: true
1957
+ },
1958
+ {
1959
+ name: "reverseColumnsWhenStacked",
1960
+ type: "boolean",
1961
+ defaultValue: false,
1962
+ helperText: "When stacking columns for mobile devices, reverse the ordering",
1963
+ advanced: true
1964
+ }
1965
+ ]
1966
+ };
1967
+ const componentInfo$8 = {
1968
+ name: "Fragment",
1969
+ static: true,
1970
+ hidden: true,
1971
+ canHaveChildren: true,
1972
+ noWrap: true
1973
+ };
1974
+ const componentInfo$7 = {
1975
+ name: "Image",
1976
+ static: true,
1977
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
1978
+ defaultStyles: {
1979
+ position: "relative",
1980
+ minHeight: "20px",
1981
+ minWidth: "20px",
1982
+ overflow: "hidden"
1983
+ },
1984
+ canHaveChildren: true,
1985
+ inputs: [
1986
+ {
1987
+ name: "image",
1988
+ type: "file",
1989
+ bubble: true,
1990
+ allowedFileTypes: [
1991
+ "jpeg",
1992
+ "jpg",
1993
+ "png",
1994
+ "svg"
1995
+ ],
1996
+ required: true,
1997
+ defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
1998
+ onChange: (options) => {
1999
+ const DEFAULT_ASPECT_RATIO = 0.7041;
2000
+ options.delete("srcset");
2001
+ options.delete("noWebp");
2002
+ function loadImage(url, timeout = 6e4) {
2003
+ return new Promise((resolve, reject) => {
2004
+ const img = document.createElement("img");
2005
+ let loaded = false;
2006
+ img.onload = () => {
2007
+ loaded = true;
2008
+ resolve(img);
2009
+ };
2010
+ img.addEventListener("error", (event) => {
2011
+ console.warn("Image load failed", event.error);
2012
+ reject(event.error);
2013
+ });
2014
+ img.src = url;
2015
+ setTimeout(() => {
2016
+ if (!loaded)
2017
+ reject(new Error("Image load timed out"));
2018
+ }, timeout);
2019
+ });
2020
+ }
2021
+ function round2(num) {
2022
+ return Math.round(num * 1e3) / 1e3;
2023
+ }
2024
+ const value = options.get("image");
2025
+ const aspectRatio = options.get("aspectRatio");
2026
+ fetch(value).then((res) => res.blob()).then((blob) => {
2027
+ if (blob.type.includes("svg"))
2028
+ options.set("noWebp", true);
2029
+ });
2030
+ if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO))
2031
+ return loadImage(value).then((img) => {
2032
+ const possiblyUpdatedAspectRatio = options.get("aspectRatio");
2033
+ if (options.get("image") === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
2034
+ if (img.width && img.height) {
2035
+ options.set("aspectRatio", round2(img.height / img.width));
2036
+ options.set("height", img.height);
2037
+ options.set("width", img.width);
2038
+ }
2039
+ }
2040
+ });
2041
+ }
2042
+ },
2043
+ {
2044
+ name: "backgroundSize",
2045
+ type: "text",
2046
+ defaultValue: "cover",
2047
+ enum: [
2048
+ {
2049
+ label: "contain",
2050
+ value: "contain",
2051
+ helperText: "The image should never get cropped"
2052
+ },
2053
+ {
2054
+ label: "cover",
2055
+ value: "cover",
2056
+ helperText: "The image should fill it's box, cropping when needed"
2057
+ }
2058
+ ]
2059
+ },
2060
+ {
2061
+ name: "backgroundPosition",
2062
+ type: "text",
2063
+ defaultValue: "center",
2064
+ enum: [
2065
+ "center",
2066
+ "top",
2067
+ "left",
2068
+ "right",
2069
+ "bottom",
2070
+ "top left",
2071
+ "top right",
2072
+ "bottom left",
2073
+ "bottom right"
2074
+ ]
2075
+ },
2076
+ {
2077
+ name: "altText",
2078
+ type: "string",
2079
+ helperText: "Text to display when the user has images off"
2080
+ },
2081
+ {
2082
+ name: "height",
2083
+ type: "number",
2084
+ hideFromUI: true
2085
+ },
2086
+ {
2087
+ name: "width",
2088
+ type: "number",
2089
+ hideFromUI: true
2090
+ },
2091
+ {
2092
+ name: "sizes",
2093
+ type: "string",
2094
+ hideFromUI: true
2095
+ },
2096
+ {
2097
+ name: "srcset",
2098
+ type: "string",
2099
+ hideFromUI: true
2100
+ },
2101
+ {
2102
+ name: "lazy",
2103
+ type: "boolean",
2104
+ defaultValue: true,
2105
+ hideFromUI: true
2106
+ },
2107
+ {
2108
+ name: "fitContent",
2109
+ type: "boolean",
2110
+ helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
2111
+ defaultValue: true
2112
+ },
2113
+ {
2114
+ name: "aspectRatio",
2115
+ type: "number",
2116
+ helperText: "This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",
2117
+ advanced: true,
2118
+ defaultValue: 0.7041
2119
+ }
2120
+ ]
2121
+ };
2122
+ const componentInfo$6 = {
2123
+ name: "Core:Section",
2124
+ static: true,
2125
+ image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
2126
+ inputs: [
2127
+ {
2128
+ name: "maxWidth",
2129
+ type: "number",
2130
+ defaultValue: 1200
2131
+ },
2132
+ {
2133
+ name: "lazyLoad",
2134
+ type: "boolean",
2135
+ defaultValue: false,
2136
+ advanced: true,
2137
+ description: "Only render this section when in view"
2138
+ }
2139
+ ],
2140
+ defaultStyles: {
2141
+ paddingLeft: "20px",
2142
+ paddingRight: "20px",
2143
+ paddingTop: "50px",
2144
+ paddingBottom: "50px",
2145
+ marginTop: "0px",
2146
+ width: "100vw",
2147
+ marginLeft: "calc(50% - 50vw)"
2148
+ },
2149
+ canHaveChildren: true,
2150
+ defaultChildren: [
2151
+ {
2152
+ "@type": "@builder.io/sdk:Element",
2153
+ responsiveStyles: {
2154
+ large: {
2155
+ textAlign: "center"
2156
+ }
2157
+ },
2158
+ component: {
2159
+ name: "Text",
2160
+ options: {
2161
+ text: "<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"
2162
+ }
2163
+ }
2164
+ }
2165
+ ]
2166
+ };
2167
+ const componentInfo$5 = {
2168
+ name: "Symbol",
2169
+ noWrap: true,
2170
+ static: true,
2171
+ isRSC: true,
2172
+ inputs: [
2173
+ {
2174
+ name: "symbol",
2175
+ type: "uiSymbol"
2176
+ },
2177
+ {
2178
+ name: "dataOnly",
2179
+ helperText: "Make this a data symbol that doesn't display any UI",
2180
+ type: "boolean",
2181
+ defaultValue: false,
2182
+ advanced: true,
2183
+ hideFromUI: true
2184
+ },
2185
+ {
2186
+ name: "inheritState",
2187
+ helperText: "Inherit the parent component state and data",
2188
+ type: "boolean",
2189
+ defaultValue: false,
2190
+ advanced: true
2191
+ },
2192
+ {
2193
+ name: "renderToLiquid",
2194
+ helperText: "Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting",
2195
+ type: "boolean",
2196
+ defaultValue: false,
2197
+ advanced: true,
2198
+ hideFromUI: true
2199
+ },
2200
+ {
2201
+ name: "useChildren",
2202
+ hideFromUI: true,
2203
+ type: "boolean"
2204
+ }
2205
+ ]
2206
+ };
2207
+ const componentInfo$4 = {
2208
+ name: "Text",
2209
+ static: true,
2210
+ isRSC: true,
2211
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
2212
+ inputs: [
2213
+ {
2214
+ name: "text",
2215
+ type: "html",
2216
+ required: true,
2217
+ autoFocus: true,
2218
+ bubble: true,
2219
+ defaultValue: "Enter some text..."
2220
+ }
2221
+ ],
2222
+ defaultStyles: {
2223
+ lineHeight: "normal",
2224
+ height: "auto",
2225
+ textAlign: "center"
2226
+ }
2227
+ };
2228
+ const Text = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2229
+ return /* @__PURE__ */ _jsxQ("div", null, {
2230
+ class: "builder-text",
2231
+ dangerouslySetInnerHTML: _fnSignal((p0) => {
2232
+ var _a;
2233
+ return ((_a = p0.text) == null ? void 0 : _a.toString()) || "";
2234
+ }, [
2235
+ props
2236
+ ], 'p0.text?.toString()||""'),
2237
+ style: {
2238
+ outline: "none"
2239
+ }
2240
+ }, null, 3, "yO_0");
2241
+ }, "Text_component_15p0cKUxgIE"));
2242
+ const componentInfo$3 = {
2243
+ name: "Video",
2244
+ canHaveChildren: true,
2245
+ defaultStyles: {
2246
+ minHeight: "20px",
2247
+ minWidth: "20px"
2248
+ },
2249
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",
2250
+ inputs: [
2251
+ {
2252
+ name: "video",
2253
+ type: "file",
2254
+ allowedFileTypes: [
2255
+ "mp4"
2256
+ ],
2257
+ bubble: true,
2258
+ defaultValue: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f",
2259
+ required: true
2260
+ },
2261
+ {
2262
+ name: "posterImage",
2263
+ type: "file",
2264
+ allowedFileTypes: [
2265
+ "jpeg",
2266
+ "png"
2267
+ ],
2268
+ helperText: "Image to show before the video plays"
2269
+ },
2270
+ {
2271
+ name: "autoPlay",
2272
+ type: "boolean",
2273
+ defaultValue: true
2274
+ },
2275
+ {
2276
+ name: "controls",
2277
+ type: "boolean",
2278
+ defaultValue: false
2279
+ },
2280
+ {
2281
+ name: "muted",
2282
+ type: "boolean",
2283
+ defaultValue: true
2284
+ },
2285
+ {
2286
+ name: "loop",
2287
+ type: "boolean",
2288
+ defaultValue: true
2289
+ },
2290
+ {
2291
+ name: "playsInline",
2292
+ type: "boolean",
2293
+ defaultValue: true
2294
+ },
2295
+ {
2296
+ name: "fit",
2297
+ type: "text",
2298
+ defaultValue: "cover",
2299
+ enum: [
2300
+ "contain",
2301
+ "cover",
2302
+ "fill",
2303
+ "auto"
2304
+ ]
2305
+ },
2306
+ {
2307
+ name: "preload",
2308
+ type: "text",
2309
+ defaultValue: "metadata",
2310
+ enum: [
2311
+ "auto",
2312
+ "metadata",
2313
+ "none"
2314
+ ]
2315
+ },
2316
+ {
2317
+ name: "fitContent",
2318
+ type: "boolean",
2319
+ helperText: "When child blocks are provided, fit to them instead of using the aspect ratio",
2320
+ defaultValue: true,
2321
+ advanced: true
2322
+ },
2323
+ {
2324
+ name: "position",
2325
+ type: "text",
2326
+ defaultValue: "center",
2327
+ enum: [
2328
+ "center",
2329
+ "top",
2330
+ "left",
2331
+ "right",
2332
+ "bottom",
2333
+ "top left",
2334
+ "top right",
2335
+ "bottom left",
2336
+ "bottom right"
2337
+ ]
2338
+ },
2339
+ {
2340
+ name: "height",
2341
+ type: "number",
2342
+ advanced: true
2343
+ },
2344
+ {
2345
+ name: "width",
2346
+ type: "number",
2347
+ advanced: true
2348
+ },
2349
+ {
2350
+ name: "aspectRatio",
2351
+ type: "number",
2352
+ advanced: true,
2353
+ defaultValue: 0.7004048582995948
2354
+ },
2355
+ {
2356
+ name: "lazyLoad",
2357
+ type: "boolean",
2358
+ helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
2359
+ defaultValue: true,
2360
+ advanced: true
2361
+ }
2362
+ ]
2363
+ };
2364
+ const Video = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2365
+ const videoProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
2366
+ const [props2] = useLexicalScope();
2367
+ return {
2368
+ ...props2.autoPlay === true ? {
2369
+ autoPlay: true
2370
+ } : {},
2371
+ ...props2.muted === true ? {
2372
+ muted: true
2373
+ } : {},
2374
+ ...props2.controls === true ? {
2375
+ controls: true
2376
+ } : {},
2377
+ ...props2.loop === true ? {
2378
+ loop: true
2379
+ } : {},
2380
+ ...props2.playsInline === true ? {
2381
+ playsInline: true
2382
+ } : {}
2383
+ };
2384
+ }, "Video_component_videoProps_useComputed_60AadUGY06E", [
2385
+ props
2386
+ ]));
2387
+ const spreadProps = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
2388
+ const [props2, videoProps2] = useLexicalScope();
2389
+ return {
2390
+ ...props2.attributes,
2391
+ ...videoProps2.value
2392
+ };
2393
+ }, "Video_component_spreadProps_useComputed_ZdLsx18NYH4", [
2394
+ props,
2395
+ videoProps
2396
+ ]));
2397
+ return /* @__PURE__ */ _jsxS("video", {
2398
+ ...spreadProps.value
2399
+ }, {
2400
+ poster: _fnSignal((p0) => p0.posterImage, [
2401
+ props
2402
+ ], "p0.posterImage"),
2403
+ preload: _fnSignal((p0) => p0.preload || "metadata", [
2404
+ props
2405
+ ], 'p0.preload||"metadata"'),
2406
+ src: _fnSignal((p0) => p0.video || "no-src", [
2407
+ props
2408
+ ], 'p0.video||"no-src"'),
2409
+ style: _fnSignal((p0) => {
2410
+ var _a;
2411
+ return {
2412
+ width: "100%",
2413
+ height: "100%",
2414
+ ...(_a = p0.attributes) == null ? void 0 : _a.style,
2415
+ objectFit: p0.fit,
2416
+ objectPosition: p0.position,
2417
+ // Hack to get object fit to work as expected and
2418
+ // not have the video overflow
2419
+ borderRadius: 1
2420
+ };
2421
+ }, [
2422
+ props
2423
+ ], '{width:"100%",height:"100%",...p0.attributes?.style,objectFit:p0.fit,objectPosition:p0.position,borderRadius:1}')
2424
+ }, 0, "j7_0");
2425
+ }, "Video_component_qdcTZflYyoQ"));
2426
+ const componentInfo$2 = {
2427
+ name: "Embed",
2428
+ static: true,
2429
+ inputs: [
2430
+ {
2431
+ name: "url",
2432
+ type: "url",
2433
+ required: true,
2434
+ defaultValue: "",
2435
+ helperText: "e.g. enter a youtube url, google map, etc",
2436
+ onChange: (options) => {
2437
+ const url = options.get("url");
2438
+ if (url) {
2439
+ options.set("content", "Loading...");
2440
+ const apiKey = "ae0e60e78201a3f2b0de4b";
2441
+ return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
2442
+ if (options.get("url") === url) {
2443
+ if (data.html)
2444
+ options.set("content", data.html);
2445
+ else
2446
+ options.set("content", "Invalid url, please try another");
2447
+ }
2448
+ }).catch((_err) => {
2449
+ options.set("content", "There was an error embedding this URL, please try again or another URL");
2450
+ });
2451
+ } else
2452
+ options.delete("content");
2453
+ }
2454
+ },
2455
+ {
2456
+ name: "content",
2457
+ type: "html",
2458
+ defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
2459
+ hideFromUI: true
2460
+ }
2461
+ ]
2462
+ };
2463
+ const SCRIPT_MIME_TYPES = [
2464
+ "text/javascript",
2465
+ "application/javascript",
2466
+ "application/ecmascript"
2467
+ ];
2468
+ const isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2469
+ const findAndRunScripts = function findAndRunScripts2(props, state, elem) {
2470
+ if (!elem.value || !elem.value.getElementsByTagName)
2471
+ return;
2472
+ const scripts = elem.value.getElementsByTagName("script");
2473
+ for (let i = 0; i < scripts.length; i++) {
2474
+ const script = scripts[i];
2475
+ if (script.src && !state.scriptsInserted.includes(script.src)) {
2476
+ state.scriptsInserted.push(script.src);
2477
+ const newScript = document.createElement("script");
2478
+ newScript.async = true;
2479
+ newScript.src = script.src;
2480
+ document.head.appendChild(newScript);
2481
+ } else if (isJsScript(script) && !state.scriptsRun.includes(script.innerText))
2482
+ try {
2483
+ state.scriptsRun.push(script.innerText);
2484
+ new Function(script.innerText)();
2485
+ } catch (error) {
2486
+ console.warn("`Embed`: Error running script:", error);
2487
+ }
2488
+ }
2489
+ };
2490
+ const Embed = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2491
+ const elem = useSignal();
2492
+ const state = useStore({
2493
+ ranInitFn: false,
2494
+ scriptsInserted: [],
2495
+ scriptsRun: []
2496
+ });
2497
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
2498
+ const [elem2, props2, state2] = useLexicalScope();
2499
+ track2(() => elem2.value);
2500
+ track2(() => state2.ranInitFn);
2501
+ if (elem2.value && !state2.ranInitFn) {
2502
+ state2.ranInitFn = true;
2503
+ findAndRunScripts(props2, state2, elem2);
2504
+ }
2505
+ }, "Embed_component_useTask_bg7ez0XUtiM", [
2506
+ elem,
2507
+ props,
2508
+ state
2509
+ ]));
2510
+ return /* @__PURE__ */ _jsxQ("div", {
2511
+ ref: elem
2512
+ }, {
2513
+ class: "builder-embed",
2514
+ dangerouslySetInnerHTML: _fnSignal((p0) => p0.content, [
2515
+ props
2516
+ ], "p0.content")
2517
+ }, null, 3, "9r_0");
2518
+ }, "Embed_component_Uji08ORjXbE"));
2519
+ const ImgComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2520
+ return /* @__PURE__ */ _jsxS("img", {
2521
+ ...props.attributes
2522
+ }, {
2523
+ alt: _fnSignal((p0) => p0.altText, [
2524
+ props
2525
+ ], "p0.altText"),
2526
+ src: _fnSignal((p0) => p0.imgSrc || p0.image, [
2527
+ props
2528
+ ], "p0.imgSrc||p0.image"),
2529
+ style: _fnSignal((p0) => ({
2530
+ objectFit: p0.backgroundSize || "cover",
2531
+ objectPosition: p0.backgroundPosition || "center"
2532
+ }), [
2533
+ props
2534
+ ], '{objectFit:p0.backgroundSize||"cover",objectPosition:p0.backgroundPosition||"center"}')
2535
+ }, 0, isEditing() && props.imgSrc || "default-key");
2536
+ }, "ImgComponent_component_FXvIDBSffO8"));
2537
+ const componentInfo$1 = {
2538
+ // friendlyName?
2539
+ name: "Raw:Img",
2540
+ hideFromInsertMenu: true,
2541
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",
2542
+ inputs: [
2543
+ {
2544
+ name: "image",
2545
+ bubble: true,
2546
+ type: "file",
2547
+ allowedFileTypes: [
2548
+ "jpeg",
2549
+ "jpg",
2550
+ "png",
2551
+ "svg",
2552
+ "gif",
2553
+ "webp"
2554
+ ],
2555
+ required: true
2556
+ }
2557
+ ],
2558
+ noWrap: true,
2559
+ static: true
2560
+ };
2561
+ const CustomCode = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2562
+ const elementRef = useSignal();
2563
+ const state = useStore({
2564
+ scriptsInserted: [],
2565
+ scriptsRun: []
2566
+ });
2567
+ useOn("qvisible", /* @__PURE__ */ inlinedQrl((event, element) => {
2568
+ const [state2] = useLexicalScope();
2569
+ if (!(element == null ? void 0 : element.getElementsByTagName) || typeof window === "undefined")
2570
+ return;
2571
+ const scripts = element.getElementsByTagName("script");
2572
+ for (let i = 0; i < scripts.length; i++) {
2573
+ const script = scripts[i];
2574
+ if (script.src) {
2575
+ if (state2.scriptsInserted.includes(script.src))
2576
+ continue;
2577
+ state2.scriptsInserted.push(script.src);
2578
+ const newScript = document.createElement("script");
2579
+ newScript.async = true;
2580
+ newScript.src = script.src;
2581
+ document.head.appendChild(newScript);
2582
+ } else if (!script.type || [
2583
+ "text/javascript",
2584
+ "application/javascript",
2585
+ "application/ecmascript"
2586
+ ].includes(script.type)) {
2587
+ if (state2.scriptsRun.includes(script.innerText))
2588
+ continue;
2589
+ try {
2590
+ state2.scriptsRun.push(script.innerText);
2591
+ new Function(script.innerText)();
2592
+ } catch (error) {
2593
+ console.warn("`CustomCode`: Error running script:", error);
2594
+ }
2595
+ }
2596
+ }
2597
+ }, "CustomCode_component_useOn_zjAgBhFOiCs", [
2598
+ state
2599
+ ]));
2600
+ return /* @__PURE__ */ _jsxQ("div", {
2601
+ ref: elementRef
2602
+ }, {
2603
+ class: _fnSignal((p0) => "builder-custom-code" + (p0.replaceNodes ? " replace-nodes" : ""), [
2604
+ props
2605
+ ], '"builder-custom-code"+(p0.replaceNodes?" replace-nodes":"")'),
2606
+ dangerouslySetInnerHTML: _fnSignal((p0) => p0.code, [
2607
+ props
2608
+ ], "p0.code")
2609
+ }, null, 3, "bY_0");
2610
+ }, "CustomCode_component_uYOSy7w7Zqw"));
2611
+ const componentInfo = {
2612
+ name: "Custom Code",
2613
+ static: true,
2614
+ requiredPermissions: [
2615
+ "editCode"
2616
+ ],
2617
+ inputs: [
2618
+ {
2619
+ name: "code",
2620
+ type: "html",
2621
+ required: true,
2622
+ defaultValue: "<p>Hello there, I am custom HTML code!</p>",
2623
+ code: true
2624
+ },
2625
+ {
2626
+ name: "replaceNodes",
2627
+ type: "boolean",
2628
+ helperText: "Preserve server rendered dom nodes",
2629
+ advanced: true
2630
+ },
2631
+ {
2632
+ name: "scriptsClientOnly",
2633
+ type: "boolean",
2634
+ defaultValue: false,
2635
+ helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
2636
+ advanced: true
2637
+ }
2638
+ ]
2639
+ };
2640
+ const getDefaultRegisteredComponents = () => [
2641
+ {
2642
+ component: Button,
2643
+ ...componentInfo$a
2644
+ },
2645
+ {
2646
+ component: Columns,
2647
+ ...componentInfo$9
2648
+ },
2649
+ {
2650
+ component: CustomCode,
2651
+ ...componentInfo
2652
+ },
2653
+ {
2654
+ component: Embed,
2655
+ ...componentInfo$2
2656
+ },
2657
+ {
2658
+ component: FragmentComponent,
2659
+ ...componentInfo$8
2660
+ },
2661
+ {
2662
+ component: Image,
2663
+ ...componentInfo$7
2664
+ },
2665
+ {
2666
+ component: ImgComponent,
2667
+ ...componentInfo$1
2668
+ },
2669
+ {
2670
+ component: SectionComponent,
2671
+ ...componentInfo$6
2672
+ },
2673
+ {
2674
+ component: Symbol$1,
2675
+ ...componentInfo$5
2676
+ },
2677
+ {
2678
+ component: Text,
2679
+ ...componentInfo$4
2680
+ },
2681
+ {
2682
+ component: Video,
2683
+ ...componentInfo$3
2684
+ }
2685
+ ];
2686
+ const components = [];
2687
+ const createRegisterComponentMessage = (info) => ({
2688
+ type: "builder.registerComponent",
2689
+ data: serializeComponentInfo(info)
2690
+ });
2691
+ const serializeFn = (fnValue) => {
2692
+ const fnStr = fnValue.toString().trim();
2693
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
2694
+ return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
2695
+ };
2696
+ const serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
2697
+ const serializeComponentInfo = ({ inputs, ...info }) => ({
2698
+ ...fastClone(info),
2699
+ inputs: inputs == null ? void 0 : inputs.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
2700
+ ...acc,
2701
+ [key]: serializeValue(value)
2702
+ }), {}))
2703
+ });
2704
+ const getVariants = (content) => Object.values((content == null ? void 0 : content.variations) || {}).map((variant) => ({
2705
+ ...variant,
2706
+ testVariationId: variant.id,
2707
+ id: content == null ? void 0 : content.id
2708
+ }));
2709
+ const checkShouldRunVariants = ({ canTrack, content }) => {
2710
+ const hasVariants = getVariants(content).length > 0;
2711
+ if (!hasVariants)
2712
+ return false;
2713
+ if (!canTrack)
2714
+ return false;
2715
+ if (isBrowser())
2716
+ return false;
2717
+ return true;
2718
+ };
2719
+ function bldrAbTest(contentId, variants, isHydrationTarget2) {
2720
+ var _a;
2721
+ function getAndSetVariantId2() {
2722
+ function setCookie2(name, value, days) {
2723
+ let expires = "";
2724
+ if (days) {
2725
+ const date = /* @__PURE__ */ new Date();
2726
+ date.setTime(date.getTime() + days * 864e5);
2727
+ expires = "; expires=" + date.toUTCString();
2728
+ }
2729
+ document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
2730
+ }
2731
+ function getCookie2(name) {
2732
+ const nameEQ = name + "=";
2733
+ const ca = document.cookie.split(";");
2734
+ for (let i = 0; i < ca.length; i++) {
2735
+ let c = ca[i];
2736
+ while (c.charAt(0) === " ")
2737
+ c = c.substring(1, c.length);
2738
+ if (c.indexOf(nameEQ) === 0)
2739
+ return c.substring(nameEQ.length, c.length);
2740
+ }
2741
+ return null;
2742
+ }
2743
+ const cookieName = `builder.tests.${contentId}`;
2744
+ const variantInCookie = getCookie2(cookieName);
2745
+ const availableIDs = variants.map((vr) => vr.id).concat(contentId);
2746
+ if (variantInCookie && availableIDs.includes(variantInCookie))
2747
+ return variantInCookie;
2748
+ let n = 0;
2749
+ const random = Math.random();
2750
+ for (let i = 0; i < variants.length; i++) {
2751
+ const variant = variants[i];
2752
+ const testRatio = variant.testRatio;
2753
+ n += testRatio;
2754
+ if (random < n) {
2755
+ setCookie2(cookieName, variant.id);
2756
+ return variant.id;
2757
+ }
2758
+ }
2759
+ setCookie2(cookieName, contentId);
2760
+ return contentId;
2761
+ }
2762
+ const winningVariantId = getAndSetVariantId2();
2763
+ const styleEl = (_a = document.currentScript) == null ? void 0 : _a.previousElementSibling;
2764
+ if (isHydrationTarget2) {
2765
+ styleEl.remove();
2766
+ const thisScriptEl = document.currentScript;
2767
+ thisScriptEl == null ? void 0 : thisScriptEl.remove();
2768
+ } else {
2769
+ const newStyleStr = variants.concat({
2770
+ id: contentId
2771
+ }).filter((variant) => variant.id !== winningVariantId).map((value) => {
2772
+ return `.variant-${value.id} { display: none; }
2773
+ `;
2774
+ }).join("");
2775
+ styleEl.innerHTML = newStyleStr;
2776
+ }
2777
+ }
2778
+ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
2779
+ var _a;
2780
+ if (!navigator.cookieEnabled)
2781
+ return;
2782
+ function getCookie2(name) {
2783
+ const nameEQ = name + "=";
2784
+ const ca = document.cookie.split(";");
2785
+ for (let i = 0; i < ca.length; i++) {
2786
+ let c = ca[i];
2787
+ while (c.charAt(0) === " ")
2788
+ c = c.substring(1, c.length);
2789
+ if (c.indexOf(nameEQ) === 0)
2790
+ return c.substring(nameEQ.length, c.length);
2791
+ }
2792
+ return null;
2793
+ }
2794
+ const cookieName = `builder.tests.${defaultContentId}`;
2795
+ const variantId = getCookie2(cookieName);
2796
+ const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
2797
+ const variantIsDefaultContent = variantContentId === defaultContentId;
2798
+ if (variantId === variantContentId) {
2799
+ if (variantIsDefaultContent)
2800
+ return;
2801
+ parentDiv == null ? void 0 : parentDiv.removeAttribute("hidden");
2802
+ parentDiv == null ? void 0 : parentDiv.removeAttribute("aria-hidden");
2803
+ } else {
2804
+ if (variantIsDefaultContent) {
2805
+ if (isHydrationTarget2)
2806
+ parentDiv == null ? void 0 : parentDiv.remove();
2807
+ else {
2808
+ parentDiv == null ? void 0 : parentDiv.setAttribute("hidden", "true");
2809
+ parentDiv == null ? void 0 : parentDiv.setAttribute("aria-hidden", "true");
2810
+ }
2811
+ }
2812
+ return;
2813
+ }
2814
+ return;
2815
+ }
2816
+ const getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
2817
+ const isHydrationTarget = getIsHydrationTarget(TARGET);
2818
+ const AB_TEST_FN_NAME = "builderIoAbTest";
2819
+ const CONTENT_FN_NAME = "builderIoRenderContent";
2820
+ const getScriptString = () => {
2821
+ const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
2822
+ const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
2823
+ return `
2824
+ window.${AB_TEST_FN_NAME} = ${fnStr}
2825
+ window.${CONTENT_FN_NAME} = ${fnStr2}
2826
+ `;
2827
+ };
2828
+ const getVariantsScriptString = (variants, contentId) => {
2829
+ return `
2830
+ window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
2831
+ };
2832
+ const getRenderContentScriptString = ({ contentId, variationId }) => {
2833
+ return `
2834
+ window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
2835
+ };
2836
+ const InlinedScript = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
2837
+ return /* @__PURE__ */ _jsxQ("script", null, {
2838
+ dangerouslySetInnerHTML: _fnSignal((p0) => p0.scriptStr, [
2839
+ props
2840
+ ], "p0.scriptStr"),
2841
+ id: _fnSignal((p0) => p0.id, [
2842
+ props
2843
+ ], "p0.id")
2844
+ }, null, 3, "WO_0");
2845
+ }, "InlinedScript_component_hwThBdhA8rw"));
2846
+ function getGlobalThis() {
2847
+ if (typeof globalThis !== "undefined")
2848
+ return globalThis;
2849
+ if (typeof window !== "undefined")
2850
+ return window;
2851
+ if (typeof global !== "undefined")
2852
+ return global;
2853
+ if (typeof self !== "undefined")
2854
+ return self;
2855
+ return globalThis;
2856
+ }
2857
+ function getFetch() {
2858
+ const globalFetch = getGlobalThis().fetch;
2859
+ if (typeof globalFetch === "undefined") {
2860
+ console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2861
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
2862
+ throw new Error("Builder SDK could not find a global `fetch` function");
2863
+ }
2864
+ return globalFetch;
2865
+ }
2866
+ const fetch$1 = getFetch();
2867
+ function flatten(object, path = null, separator = ".") {
2868
+ return Object.keys(object).reduce((acc, key) => {
2869
+ const value = object[key];
2870
+ const newPath = [
2871
+ path,
2872
+ key
2873
+ ].filter(Boolean).join(separator);
2874
+ const isObject = [
2875
+ typeof value === "object",
2876
+ value !== null,
2877
+ !(Array.isArray(value) && value.length === 0)
2878
+ ].every(Boolean);
2879
+ return isObject ? {
2880
+ ...acc,
2881
+ ...flatten(value, newPath, separator)
2882
+ } : {
2883
+ ...acc,
2884
+ [newPath]: value
2885
+ };
2886
+ }, {});
2887
+ }
2888
+ const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
2889
+ const BUILDER_OPTIONS_PREFIX = "options.";
2890
+ const convertSearchParamsToQueryObject = (searchParams) => {
2891
+ const options = {};
2892
+ searchParams.forEach((value, key) => {
2893
+ options[key] = value;
2894
+ });
2895
+ return options;
2896
+ };
2897
+ const getBuilderSearchParams = (_options) => {
2898
+ if (!_options)
2899
+ return {};
2900
+ const options = normalizeSearchParams(_options);
2901
+ const newOptions = {};
2902
+ Object.keys(options).forEach((key) => {
2903
+ if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2904
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
2905
+ newOptions[trimmedKey] = options[key];
2906
+ }
2907
+ });
2908
+ return newOptions;
2909
+ };
2910
+ const getBuilderSearchParamsFromWindow = () => {
2911
+ if (!isBrowser())
2912
+ return {};
2913
+ const searchParams = new URLSearchParams(window.location.search);
2914
+ return getBuilderSearchParams(searchParams);
2915
+ };
2916
+ const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
2917
+ const DEFAULT_API_VERSION = "v3";
2918
+ const isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
2919
+ const generateContentUrl = (options) => {
2920
+ let { noTraverse = false } = options;
2921
+ const { limit = 30, userAttributes, query, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION, fields, omit, offset, cacheSeconds, staleCacheSeconds, sort, includeUnpublished } = options;
2922
+ if (!apiKey)
2923
+ throw new Error("Missing API key");
2924
+ if (![
2925
+ "v2",
2926
+ "v3"
2927
+ ].includes(apiVersion))
2928
+ throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
2929
+ if ((options.limit === void 0 || options.limit > 1) && !("noTraverse" in options))
2930
+ noTraverse = true;
2931
+ const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}${enrich ? `&enrich=${enrich}` : ""}`);
2932
+ url.searchParams.set("omit", omit || "meta.componentsUsed");
2933
+ if (fields)
2934
+ url.searchParams.set("fields", fields);
2935
+ if (Number.isFinite(offset) && offset > -1)
2936
+ url.searchParams.set("offset", String(Math.floor(offset)));
2937
+ if (typeof includeUnpublished === "boolean")
2938
+ url.searchParams.set("includeUnpublished", String(includeUnpublished));
2939
+ if (cacheSeconds && isPositiveNumber(cacheSeconds))
2940
+ url.searchParams.set("cacheSeconds", String(cacheSeconds));
2941
+ if (staleCacheSeconds && isPositiveNumber(staleCacheSeconds))
2942
+ url.searchParams.set("staleCacheSeconds", String(staleCacheSeconds));
2943
+ if (sort) {
2944
+ const flattened2 = flatten({
2945
+ sort
2946
+ });
2947
+ for (const key in flattened2)
2948
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
2949
+ }
2950
+ const queryOptions = {
2951
+ ...getBuilderSearchParamsFromWindow(),
2952
+ ...normalizeSearchParams(options.options || {})
2953
+ };
2954
+ const flattened = flatten(queryOptions);
2955
+ for (const key in flattened)
2956
+ url.searchParams.set(key, String(flattened[key]));
2957
+ if (userAttributes)
2958
+ url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
2959
+ if (query) {
2960
+ const flattened2 = flatten({
2961
+ query
2962
+ });
2963
+ for (const key in flattened2)
2964
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
2965
+ }
2966
+ return url;
2967
+ };
2968
+ const checkContentHasResults = (content) => "results" in content;
2969
+ async function fetchOneEntry(options) {
2970
+ const allContent = await fetchEntries({
2971
+ ...options,
2972
+ limit: 1
2973
+ });
2974
+ if (allContent)
2975
+ return allContent.results[0] || null;
2976
+ return null;
2977
+ }
2978
+ const getContent = fetchOneEntry;
2979
+ const _fetchContent = async (options) => {
2980
+ const url = generateContentUrl(options);
2981
+ const res = await fetch$1(url.href);
2982
+ const content = await res.json();
2983
+ return content;
2984
+ };
2985
+ const _processContentResult = async (options, content, url = generateContentUrl(options)) => {
2986
+ const canTrack = getDefaultCanTrack(options.canTrack);
2987
+ url.search.includes(`preview=`);
2988
+ if (!canTrack)
2989
+ return content;
2990
+ if (!(isBrowser() || TARGET === "reactNative"))
2991
+ return content;
2992
+ try {
2993
+ const newResults = [];
2994
+ for (const item of content.results)
2995
+ newResults.push(await handleABTesting({
2996
+ item,
2997
+ canTrack
2998
+ }));
2999
+ content.results = newResults;
3000
+ } catch (e) {
3001
+ logger.error("Could not process A/B tests. ", e);
3002
+ }
3003
+ return content;
3004
+ };
3005
+ async function fetchEntries(options) {
3006
+ try {
3007
+ const url = generateContentUrl(options);
3008
+ const content = await _fetchContent(options);
3009
+ if (!checkContentHasResults(content)) {
3010
+ logger.error("Error fetching data. ", {
3011
+ url,
3012
+ content,
3013
+ options
3014
+ });
3015
+ return null;
3016
+ }
3017
+ return _processContentResult(options, content);
3018
+ } catch (error) {
3019
+ logger.error("Error fetching data. ", error);
3020
+ return null;
3021
+ }
3022
+ }
3023
+ const getAllContent = fetchEntries;
3024
+ function isPreviewing() {
3025
+ if (!isBrowser())
3026
+ return false;
3027
+ if (isEditing())
3028
+ return false;
3029
+ return Boolean(location.search.indexOf("builder.preview=") !== -1);
3030
+ }
3031
+ function uuidv4() {
3032
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
3033
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
3034
+ return v.toString(16);
3035
+ });
3036
+ }
3037
+ function uuid() {
3038
+ return uuidv4().replace(/-/g, "");
3039
+ }
3040
+ const SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
3041
+ const getSessionId = async ({ canTrack }) => {
3042
+ if (!canTrack)
3043
+ return void 0;
3044
+ const sessionId = await getCookie({
3045
+ name: SESSION_LOCAL_STORAGE_KEY,
3046
+ canTrack
3047
+ });
3048
+ if (checkIsDefined(sessionId))
3049
+ return sessionId;
3050
+ else {
3051
+ const newSessionId = createSessionId();
3052
+ setSessionId({
3053
+ id: newSessionId,
3054
+ canTrack
3055
+ });
3056
+ return newSessionId;
3057
+ }
3058
+ };
3059
+ const createSessionId = () => uuid();
3060
+ const setSessionId = ({ id, canTrack }) => setCookie({
3061
+ name: SESSION_LOCAL_STORAGE_KEY,
3062
+ value: id,
3063
+ canTrack
3064
+ });
3065
+ const getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
3066
+ const getLocalStorageItem = ({ key, canTrack }) => {
3067
+ var _a;
3068
+ try {
3069
+ if (canTrack)
3070
+ return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
3071
+ return void 0;
3072
+ } catch (err) {
3073
+ console.debug("[LocalStorage] GET error: ", err);
3074
+ return void 0;
3075
+ }
3076
+ };
3077
+ const setLocalStorageItem = ({ key, canTrack, value }) => {
3078
+ var _a;
3079
+ try {
3080
+ if (canTrack)
3081
+ (_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
3082
+ } catch (err) {
3083
+ console.debug("[LocalStorage] SET error: ", err);
3084
+ }
3085
+ };
3086
+ const VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
3087
+ const getVisitorId = ({ canTrack }) => {
3088
+ if (!canTrack)
3089
+ return void 0;
3090
+ const visitorId = getLocalStorageItem({
3091
+ key: VISITOR_LOCAL_STORAGE_KEY,
3092
+ canTrack
3093
+ });
3094
+ if (checkIsDefined(visitorId))
3095
+ return visitorId;
3096
+ else {
3097
+ const newVisitorId = createVisitorId();
3098
+ setVisitorId({
3099
+ id: newVisitorId,
3100
+ canTrack
3101
+ });
3102
+ return newVisitorId;
3103
+ }
3104
+ };
3105
+ const createVisitorId = () => uuid();
3106
+ const setVisitorId = ({ id, canTrack }) => setLocalStorageItem({
3107
+ key: VISITOR_LOCAL_STORAGE_KEY,
3108
+ value: id,
3109
+ canTrack
3110
+ });
3111
+ const getTrackingEventData = async ({ canTrack }) => {
3112
+ if (!canTrack)
3113
+ return {
3114
+ visitorId: void 0,
3115
+ sessionId: void 0
3116
+ };
3117
+ const sessionId = await getSessionId({
3118
+ canTrack
3119
+ });
3120
+ const visitorId = getVisitorId({
3121
+ canTrack
3122
+ });
3123
+ return {
3124
+ sessionId,
3125
+ visitorId
3126
+ };
3127
+ };
3128
+ const createEvent = async ({ type: eventType, canTrack, apiKey, metadata, ...properties }) => ({
3129
+ type: eventType,
3130
+ data: {
3131
+ ...properties,
3132
+ metadata: {
3133
+ url: location.href,
3134
+ ...metadata
3135
+ },
3136
+ ...await getTrackingEventData({
3137
+ canTrack
3138
+ }),
3139
+ userAttributes: getUserAttributes(),
3140
+ ownerId: apiKey
3141
+ }
3142
+ });
3143
+ async function _track(eventProps) {
3144
+ if (!eventProps.apiKey) {
3145
+ logger.error("Missing API key for track call. Please provide your API key.");
3146
+ return;
3147
+ }
3148
+ if (!eventProps.canTrack)
3149
+ return;
3150
+ if (isEditing())
3151
+ return;
3152
+ if (!(isBrowser() || TARGET === "reactNative"))
3153
+ return;
3154
+ return fetch(`https://cdn.builder.io/api/v1/track`, {
3155
+ method: "POST",
3156
+ body: JSON.stringify({
3157
+ events: [
3158
+ await createEvent(eventProps)
3159
+ ]
3160
+ }),
3161
+ headers: {
3162
+ "content-type": "application/json"
3163
+ },
3164
+ mode: "cors"
3165
+ }).catch((err) => {
3166
+ console.error("Failed to track: ", err);
3167
+ });
3168
+ }
3169
+ const track = (args) => _track({
3170
+ ...args,
3171
+ canTrack: true
3172
+ });
3173
+ function round(num) {
3174
+ return Math.round(num * 1e3) / 1e3;
3175
+ }
3176
+ const findParentElement = (target, callback, checkElement = true) => {
3177
+ if (!(target instanceof HTMLElement))
3178
+ return null;
3179
+ let parent2 = checkElement ? target : target.parentElement;
3180
+ do {
3181
+ if (!parent2)
3182
+ return null;
3183
+ const matches = callback(parent2);
3184
+ if (matches)
3185
+ return parent2;
3186
+ } while (parent2 = parent2.parentElement);
3187
+ return null;
3188
+ };
3189
+ const findBuilderParent = (target) => findParentElement(target, (el) => {
3190
+ const id = el.getAttribute("builder-id") || el.id;
3191
+ return Boolean((id == null ? void 0 : id.indexOf("builder-")) === 0);
3192
+ });
3193
+ const computeOffset = ({ event, target }) => {
3194
+ const targetRect = target.getBoundingClientRect();
3195
+ const xOffset = event.clientX - targetRect.left;
3196
+ const yOffset = event.clientY - targetRect.top;
3197
+ const xRatio = round(xOffset / targetRect.width);
3198
+ const yRatio = round(yOffset / targetRect.height);
3199
+ return {
3200
+ x: xRatio,
3201
+ y: yRatio
3202
+ };
3203
+ };
3204
+ const getInteractionPropertiesForEvent = (event) => {
3205
+ const target = event.target;
3206
+ const targetBuilderElement = target && findBuilderParent(target);
3207
+ const builderId = (targetBuilderElement == null ? void 0 : targetBuilderElement.getAttribute("builder-id")) || (targetBuilderElement == null ? void 0 : targetBuilderElement.id);
3208
+ return {
3209
+ targetBuilderElement: builderId || void 0,
3210
+ metadata: {
3211
+ targetOffset: target ? computeOffset({
3212
+ event,
3213
+ target
3214
+ }) : void 0,
3215
+ builderTargetOffset: targetBuilderElement ? computeOffset({
3216
+ event,
3217
+ target: targetBuilderElement
3218
+ }) : void 0,
3219
+ builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
3220
+ }
3221
+ };
3222
+ };
3223
+ const SDK_VERSION = "0.7.1-4";
3224
+ const registry = {};
3225
+ function register(type, info) {
3226
+ let typeList = registry[type];
3227
+ if (!typeList)
3228
+ typeList = registry[type] = [];
3229
+ typeList.push(info);
3230
+ if (isBrowser()) {
3231
+ const message = {
3232
+ type: "builder.register",
3233
+ data: {
3234
+ type,
3235
+ info
3236
+ }
3237
+ };
3238
+ try {
3239
+ parent.postMessage(message, "*");
3240
+ if (parent !== window)
3241
+ window.postMessage(message, "*");
3242
+ } catch (err) {
3243
+ console.debug("Could not postmessage", err);
3244
+ }
3245
+ }
3246
+ }
3247
+ const registerInsertMenu = () => {
3248
+ register("insertMenu", {
3249
+ name: "_default",
3250
+ default: true,
3251
+ items: [
3252
+ {
3253
+ name: "Box"
3254
+ },
3255
+ {
3256
+ name: "Text"
3257
+ },
3258
+ {
3259
+ name: "Image"
3260
+ },
3261
+ {
3262
+ name: "Columns"
3263
+ },
3264
+ ...[
3265
+ {
3266
+ name: "Core:Section"
3267
+ },
3268
+ {
3269
+ name: "Core:Button"
3270
+ },
3271
+ {
3272
+ name: "Embed"
3273
+ },
3274
+ {
3275
+ name: "Custom Code"
3276
+ }
3277
+ ]
3278
+ ]
3279
+ });
3280
+ };
3281
+ let isSetupForEditing = false;
3282
+ const setupBrowserForEditing = (options = {}) => {
3283
+ var _a, _b;
3284
+ if (isSetupForEditing)
3285
+ return;
3286
+ isSetupForEditing = true;
3287
+ if (isBrowser()) {
3288
+ (_a = window.parent) == null ? void 0 : _a.postMessage({
3289
+ type: "builder.sdkInfo",
3290
+ data: {
3291
+ target: TARGET,
3292
+ version: SDK_VERSION,
3293
+ supportsPatchUpdates: false,
3294
+ // Supports builder-model="..." attribute which is needed to
3295
+ // scope our '+ add block' button styling
3296
+ supportsAddBlockScoping: true,
3297
+ supportsCustomBreakpoints: true
3298
+ }
3299
+ }, "*");
3300
+ (_b = window.parent) == null ? void 0 : _b.postMessage({
3301
+ type: "builder.updateContent",
3302
+ data: {
3303
+ options
3304
+ }
3305
+ }, "*");
3306
+ window.addEventListener("message", ({ data }) => {
3307
+ var _a2, _b2;
3308
+ if (!(data == null ? void 0 : data.type))
3309
+ return;
3310
+ switch (data.type) {
3311
+ case "builder.evaluate": {
3312
+ const text = data.data.text;
3313
+ const args = data.data.arguments || [];
3314
+ const id = data.data.id;
3315
+ const fn = new Function(text);
3316
+ let result;
3317
+ let error = null;
3318
+ try {
3319
+ result = fn.apply(null, args);
3320
+ } catch (err) {
3321
+ error = err;
3322
+ }
3323
+ if (error)
3324
+ (_a2 = window.parent) == null ? void 0 : _a2.postMessage({
3325
+ type: "builder.evaluateError",
3326
+ data: {
3327
+ id,
3328
+ error: error.message
3329
+ }
3330
+ }, "*");
3331
+ else if (result && typeof result.then === "function")
3332
+ result.then((finalResult) => {
3333
+ var _a3;
3334
+ (_a3 = window.parent) == null ? void 0 : _a3.postMessage({
3335
+ type: "builder.evaluateResult",
3336
+ data: {
3337
+ id,
3338
+ result: finalResult
3339
+ }
3340
+ }, "*");
3341
+ }).catch(console.error);
3342
+ else
3343
+ (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
3344
+ type: "builder.evaluateResult",
3345
+ data: {
3346
+ result,
3347
+ id
3348
+ }
3349
+ }, "*");
3350
+ break;
3351
+ }
3352
+ }
3353
+ });
3354
+ }
3355
+ };
3356
+ const mergeNewContent = function mergeNewContent2(props, state, elementRef, newContent) {
3357
+ var _a, _b, _c, _d, _e;
3358
+ const newContentValue = {
3359
+ ...props.builderContextSignal.content,
3360
+ ...newContent,
3361
+ data: {
3362
+ ...(_a = props.builderContextSignal.content) == null ? void 0 : _a.data,
3363
+ ...newContent == null ? void 0 : newContent.data
3364
+ },
3365
+ meta: {
3366
+ ...(_b = props.builderContextSignal.content) == null ? void 0 : _b.meta,
3367
+ ...newContent == null ? void 0 : newContent.meta,
3368
+ breakpoints: ((_c = newContent == null ? void 0 : newContent.meta) == null ? void 0 : _c.breakpoints) || ((_e = (_d = props.builderContextSignal.content) == null ? void 0 : _d.meta) == null ? void 0 : _e.breakpoints)
3369
+ }
3370
+ };
3371
+ props.builderContextSignal.content = newContentValue;
3372
+ };
3373
+ const processMessage = function processMessage2(props, state, elementRef, event) {
3374
+ var _a;
3375
+ const { data } = event;
3376
+ if (data)
3377
+ switch (data.type) {
3378
+ case "builder.configureSdk": {
3379
+ const messageContent = data.data;
3380
+ const { breakpoints, contentId } = messageContent;
3381
+ if (!contentId || contentId !== ((_a = props.builderContextSignal.content) == null ? void 0 : _a.id))
3382
+ return;
3383
+ if (breakpoints)
3384
+ mergeNewContent(props, state, elementRef, {
3385
+ meta: {
3386
+ breakpoints
3387
+ }
3388
+ });
3389
+ state.forceReRenderCount = state.forceReRenderCount + 1;
3390
+ break;
3391
+ }
3392
+ case "builder.contentUpdate": {
3393
+ const messageContent = data.data;
3394
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
3395
+ const contentData = messageContent.data;
3396
+ if (key === props.model) {
3397
+ mergeNewContent(props, state, elementRef, contentData);
3398
+ state.forceReRenderCount = state.forceReRenderCount + 1;
3399
+ }
3400
+ break;
3401
+ }
3402
+ }
3403
+ };
3404
+ const evaluateJsCode = function evaluateJsCode2(props, state, elementRef) {
3405
+ var _a, _b;
3406
+ const jsCode = (_b = (_a = props.builderContextSignal.content) == null ? void 0 : _a.data) == null ? void 0 : _b.jsCode;
3407
+ if (jsCode)
3408
+ evaluate({
3409
+ code: jsCode,
3410
+ context: props.context || {},
3411
+ localState: void 0,
3412
+ rootState: props.builderContextSignal.rootState,
3413
+ rootSetState: props.builderContextSignal.rootSetState
3414
+ });
3415
+ };
3416
+ const onClick = function onClick22(props, state, elementRef, event) {
3417
+ var _a, _b;
3418
+ if (props.builderContextSignal.content) {
3419
+ const variationId = (_a = props.builderContextSignal.content) == null ? void 0 : _a.testVariationId;
3420
+ const contentId = (_b = props.builderContextSignal.content) == null ? void 0 : _b.id;
3421
+ _track({
3422
+ type: "click",
3423
+ canTrack: getDefaultCanTrack(props.canTrack),
3424
+ contentId,
3425
+ apiKey: props.apiKey,
3426
+ variationId: variationId !== contentId ? variationId : void 0,
3427
+ ...getInteractionPropertiesForEvent(event),
3428
+ unique: !state.clicked
3429
+ });
3430
+ }
3431
+ if (!state.clicked)
3432
+ state.clicked = true;
3433
+ };
3434
+ const evalExpression = function evalExpression2(props, state, elementRef, expression) {
3435
+ return expression.replace(/{{([^}]+)}}/g, (_match, group) => evaluate({
3436
+ code: group,
3437
+ context: props.context || {},
3438
+ localState: void 0,
3439
+ rootState: props.builderContextSignal.rootState,
3440
+ rootSetState: props.builderContextSignal.rootSetState
3441
+ }));
3442
+ };
3443
+ const handleRequest = function handleRequest2(props, state, elementRef, { url, key }) {
3444
+ fetch$1(url).then((response) => response.json()).then((json) => {
3445
+ var _a, _b;
3446
+ const newState = {
3447
+ ...props.builderContextSignal.rootState,
3448
+ [key]: json
3449
+ };
3450
+ (_b = (_a = props.builderContextSignal).rootSetState) == null ? void 0 : _b.call(_a, newState);
3451
+ state.httpReqsData[key] = true;
3452
+ }).catch((err) => {
3453
+ console.error("error fetching dynamic data", url, err);
3454
+ });
3455
+ };
3456
+ const runHttpRequests = function runHttpRequests2(props, state, elementRef) {
3457
+ var _a, _b;
3458
+ const requests = ((_b = (_a = props.builderContextSignal.content) == null ? void 0 : _a.data) == null ? void 0 : _b.httpRequests) ?? {};
3459
+ Object.entries(requests).forEach(([key, url]) => {
3460
+ if (url && (!state.httpReqsData[key] || isEditing())) {
3461
+ const evaluatedUrl = evalExpression(props, state, elementRef, url);
3462
+ handleRequest(props, state, elementRef, {
3463
+ url: evaluatedUrl,
3464
+ key
3465
+ });
3466
+ }
3467
+ });
3468
+ };
3469
+ const emitStateUpdate = function emitStateUpdate2(props, state, elementRef) {
3470
+ if (isEditing())
3471
+ window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
3472
+ detail: {
3473
+ state: fastClone(props.builderContextSignal.rootState),
3474
+ ref: {
3475
+ name: props.model
3476
+ }
3477
+ }
3478
+ }));
3479
+ };
3480
+ const EnableEditor = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3481
+ var _a, _b, _c;
3482
+ _jsxBranch();
3483
+ const elementRef = useSignal();
3484
+ const state = useStore({
3485
+ clicked: false,
3486
+ forceReRenderCount: 0,
3487
+ httpReqsData: {},
3488
+ lastUpdated: 0,
3489
+ shouldSendResetCookie: false
3490
+ }, {
3491
+ deep: true
3492
+ });
3493
+ useOn("initeditingbldr", /* @__PURE__ */ inlinedQrl((event, element) => {
3494
+ const [elementRef2, props2, state2] = useLexicalScope();
3495
+ state2.forceReRenderCount = state2.forceReRenderCount + 1;
3496
+ window.addEventListener("message", processMessage.bind(null, props2, state2, elementRef2));
3497
+ registerInsertMenu();
3498
+ setupBrowserForEditing({
3499
+ ...props2.locale ? {
3500
+ locale: props2.locale
3501
+ } : {},
3502
+ ...props2.includeRefs ? {
3503
+ includeRefs: props2.includeRefs
3504
+ } : {},
3505
+ ...props2.enrich ? {
3506
+ enrich: props2.enrich
3507
+ } : {}
3508
+ });
3509
+ Object.values(props2.builderContextSignal.componentInfos).forEach((registeredComponent) => {
3510
+ var _a2;
3511
+ const message = createRegisterComponentMessage(registeredComponent);
3512
+ (_a2 = window.parent) == null ? void 0 : _a2.postMessage(message, "*");
3513
+ });
3514
+ window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate.bind(null, props2, state2, elementRef2));
3515
+ }, "EnableEditor_component_useOn_Qs8c0yql2i0", [
3516
+ elementRef,
3517
+ props,
3518
+ state
3519
+ ]));
3520
+ useOn("initpreviewingbldr", /* @__PURE__ */ inlinedQrl((event, element) => {
3521
+ const [elementRef2, props2, state2] = useLexicalScope();
3522
+ const searchParams = new URL(location.href).searchParams;
3523
+ const searchParamPreviewModel = searchParams.get("builder.preview");
3524
+ const searchParamPreviewId = searchParams.get(`builder.preview.${searchParamPreviewModel}`);
3525
+ const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
3526
+ if (searchParamPreviewModel === props2.model && previewApiKey === props2.apiKey && (!props2.content || searchParamPreviewId === props2.content.id))
3527
+ fetchOneEntry({
3528
+ model: props2.model,
3529
+ apiKey: props2.apiKey,
3530
+ apiVersion: props2.builderContextSignal.apiVersion
3531
+ }).then((content) => {
3532
+ if (content)
3533
+ mergeNewContent(props2, state2, elementRef2, content);
3534
+ });
3535
+ }, "EnableEditor_component_useOn_1_F94YipmknvI", [
3536
+ elementRef,
3537
+ props,
3538
+ state
3539
+ ]));
3540
+ useOn("qvisible", /* @__PURE__ */ inlinedQrl((event, element) => {
3541
+ var _a2, _b2, _c2, _d;
3542
+ if (isBrowser()) {
3543
+ if (isEditing() && element)
3544
+ element.dispatchEvent(new CustomEvent("initeditingbldr"));
3545
+ const shouldTrackImpression = ((_a2 = element.attributes.getNamedItem("shouldTrack")) == null ? void 0 : _a2.value) === "true";
3546
+ if (shouldTrackImpression) {
3547
+ const variationId = (_b2 = element.attributes.getNamedItem("variationId")) == null ? void 0 : _b2.value;
3548
+ const contentId = (_c2 = element.attributes.getNamedItem("contentId")) == null ? void 0 : _c2.value;
3549
+ const apiKeyProp = (_d = element.attributes.getNamedItem("apiKey")) == null ? void 0 : _d.value;
3550
+ _track({
3551
+ type: "impression",
3552
+ canTrack: true,
3553
+ contentId,
3554
+ apiKey: apiKeyProp,
3555
+ variationId: variationId !== contentId ? variationId : void 0
3556
+ });
3557
+ }
3558
+ if (isPreviewing() && element)
3559
+ element.dispatchEvent(new CustomEvent("initpreviewingbldr"));
3560
+ }
3561
+ }, "EnableEditor_component_useOn_2_FyR0YPSlJlw"));
3562
+ useContextProvider(builderContext, props.builderContextSignal);
3563
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(() => {
3564
+ const [elementRef2, props2, state2] = useLexicalScope();
3565
+ if (!props2.apiKey)
3566
+ logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop.");
3567
+ evaluateJsCode(props2);
3568
+ runHttpRequests(props2, state2, elementRef2);
3569
+ emitStateUpdate(props2);
3570
+ }, "EnableEditor_component_useTask_Nb2VI04qp0M", [
3571
+ elementRef,
3572
+ props,
3573
+ state
3574
+ ]));
3575
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3576
+ const [elementRef2, props2, state2] = useLexicalScope();
3577
+ track2(() => props2.content);
3578
+ if (props2.content)
3579
+ mergeNewContent(props2, state2, elementRef2, props2.content);
3580
+ }, "EnableEditor_component_useTask_1_m0y1Z9vk4eQ", [
3581
+ elementRef,
3582
+ props,
3583
+ state
3584
+ ]));
3585
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3586
+ const [state2] = useLexicalScope();
3587
+ track2(() => state2.shouldSendResetCookie);
3588
+ }, "EnableEditor_component_useTask_2_xVyv0tDqZLs", [
3589
+ state
3590
+ ]));
3591
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3592
+ const [elementRef2, props2, state2] = useLexicalScope();
3593
+ track2(() => {
3594
+ var _a2, _b2;
3595
+ return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.jsCode;
3596
+ });
3597
+ track2(() => props2.builderContextSignal.rootState);
3598
+ evaluateJsCode(props2);
3599
+ }, "EnableEditor_component_useTask_3_bQ0e5LHZwWE", [
3600
+ elementRef,
3601
+ props,
3602
+ state
3603
+ ]));
3604
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3605
+ const [elementRef2, props2, state2] = useLexicalScope();
3606
+ track2(() => {
3607
+ var _a2, _b2;
3608
+ return (_b2 = (_a2 = props2.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.httpRequests;
3609
+ });
3610
+ runHttpRequests(props2, state2, elementRef2);
3611
+ }, "EnableEditor_component_useTask_4_moHYZG8uNVU", [
3612
+ elementRef,
3613
+ props,
3614
+ state
3615
+ ]));
3616
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
3617
+ const [elementRef2, props2, state2] = useLexicalScope();
3618
+ track2(() => props2.builderContextSignal.rootState);
3619
+ emitStateUpdate(props2);
3620
+ }, "EnableEditor_component_useTask_5_24QxS0r0KF8", [
3621
+ elementRef,
3622
+ props,
3623
+ state
3624
+ ]));
3625
+ return /* @__PURE__ */ _jsxC(Fragment, {
3626
+ children: props.builderContextSignal.content ? /* @__PURE__ */ createElement("div", {
3627
+ apiKey: props.apiKey,
3628
+ contentId: (_a = props.builderContextSignal.content) == null ? void 0 : _a.id,
3629
+ variationId: (_b = props.builderContextSignal.content) == null ? void 0 : _b.testVariationId,
3630
+ shouldTrack: String(props.builderContextSignal.content && getDefaultCanTrack(props.canTrack)),
3631
+ key: state.forceReRenderCount,
3632
+ ref: elementRef,
3633
+ onClick$: /* @__PURE__ */ inlinedQrl((event) => {
3634
+ const [elementRef2, props2, state2] = useLexicalScope();
3635
+ return onClick(props2, state2, elementRef2, event);
3636
+ }, "EnableEditor_component__Fragment__createElement_PT7eU9x80Lw", [
3637
+ elementRef,
3638
+ props,
3639
+ state
3640
+ ]),
3641
+ "builder-content-id": (_c = props.builderContextSignal.content) == null ? void 0 : _c.id,
3642
+ "builder-model": props.model,
3643
+ ...props.showContent ? {} : {
3644
+ hidden: true,
3645
+ "aria-hidden": true
3646
+ },
3647
+ class: props.classNameProp
3648
+ }, /* @__PURE__ */ _jsxC(Slot, null, 3, "06_0")) : null
3649
+ }, 1, "06_1");
3650
+ }, "EnableEditor_component_ko1mO8oaj8k"));
3651
+ const getCssFromFont = (font) => {
3652
+ var _a;
3653
+ const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
3654
+ const name = family.split(",")[0];
3655
+ const url = font.fileUrl ?? ((_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular);
3656
+ let str = "";
3657
+ if (url && family && name)
3658
+ str += `
3659
+ @font-face {
3660
+ font-family: "${family}";
3661
+ src: local("${name}"), url('${url}') format('woff2');
3662
+ font-display: fallback;
3663
+ font-weight: 400;
3664
+ }
3665
+ `.trim();
3666
+ if (font.files)
3667
+ for (const weight in font.files) {
3668
+ const isNumber = String(Number(weight)) === weight;
3669
+ if (!isNumber)
3670
+ continue;
3671
+ const weightUrl = font.files[weight];
3672
+ if (weightUrl && weightUrl !== url)
3673
+ str += `
3674
+ @font-face {
3675
+ font-family: "${family}";
3676
+ src: url('${weightUrl}') format('woff2');
3677
+ font-display: fallback;
3678
+ font-weight: ${weight};
3679
+ }
3680
+ `.trim();
3681
+ }
3682
+ return str;
3683
+ };
3684
+ const getFontCss = ({ customFonts }) => {
3685
+ var _a;
3686
+ return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
3687
+ };
3688
+ const getCss = ({ cssCode, contentId }) => {
3689
+ if (!cssCode)
3690
+ return "";
3691
+ if (!contentId)
3692
+ return cssCode;
3693
+ return (cssCode == null ? void 0 : cssCode.replace(/&/g, `div[builder-content-id="${contentId}"]`)) || "";
3694
+ };
3695
+ const ContentStyles = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3696
+ const state = useStore({
3697
+ injectedStyles: `
3698
+ ${getCss({
3699
+ cssCode: props.cssCode,
3700
+ contentId: props.contentId
3701
+ })}
3702
+ ${getFontCss({
3703
+ customFonts: props.customFonts
3704
+ })}
3705
+
3706
+ .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
3707
+ margin: 0;
3708
+ }
3709
+ .builder-text > p, .builder-text > .builder-paragraph {
3710
+ color: inherit;
3711
+ line-height: inherit;
3712
+ letter-spacing: inherit;
3713
+ font-weight: inherit;
3714
+ font-size: inherit;
3715
+ text-align: inherit;
3716
+ font-family: inherit;
3717
+ }
3718
+ `.trim()
3719
+ });
3720
+ return /* @__PURE__ */ _jsxC(InlinedStyles, {
3721
+ get styles() {
3722
+ return state.injectedStyles;
3723
+ },
3724
+ [_IMMUTABLE]: {
3725
+ styles: _fnSignal((p0) => p0.injectedStyles, [
3726
+ state
3727
+ ], "p0.injectedStyles")
3728
+ }
3729
+ }, 3, "8O_0");
3730
+ }, "ContentStyles_component_Qbhu1myPWm0"));
3731
+ const getContextStateInitialValue = ({ content, data, locale }) => {
3732
+ var _a, _b, _c;
3733
+ const defaultValues = {};
3734
+ (_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach((input) => {
3735
+ var _a2;
3736
+ if (input.name && input.defaultValue !== void 0 && ((_a2 = content == null ? void 0 : content.data) == null ? void 0 : _a2.state) && content.data.state[input.name] === void 0)
3737
+ defaultValues[input.name] = input.defaultValue;
3738
+ });
3739
+ const stateToUse = {
3740
+ ...(_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state,
3741
+ ...data,
3742
+ ...locale ? {
3743
+ locale
3744
+ } : {}
3745
+ };
3746
+ return {
3747
+ ...defaultValues,
3748
+ ...stateToUse
3749
+ };
3750
+ };
3751
+ const getContentInitialValue = ({ content, data }) => {
3752
+ return !content ? void 0 : {
3753
+ ...content,
3754
+ data: {
3755
+ ...content == null ? void 0 : content.data,
3756
+ ...data
3757
+ },
3758
+ meta: content == null ? void 0 : content.meta
3759
+ };
3760
+ };
3761
+ const ContentComponent = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3762
+ var _a, _b;
3763
+ _jsxBranch();
3764
+ const state = useStore({
3765
+ builderContextSignal: {
3766
+ content: getContentInitialValue({
3767
+ content: JSON.parse(JSON.stringify(props.content || {})),
3768
+ data: props.data
3769
+ }),
3770
+ localState: void 0,
3771
+ rootState: getContextStateInitialValue({
3772
+ content: props.content,
3773
+ data: props.data,
3774
+ locale: props.locale
3775
+ }),
3776
+ rootSetState: void 0,
3777
+ context: props.context || {},
3778
+ apiKey: props.apiKey,
3779
+ apiVersion: props.apiVersion,
3780
+ componentInfos: [
3781
+ ...getDefaultRegisteredComponents(),
3782
+ // While this `components` object is deprecated, we must maintain support for it.
3783
+ // Since users are able to override our default components, we need to make sure that we do not break such
3784
+ // existing usage.
3785
+ // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
3786
+ // which is the new standard way of providing custom components, and must therefore take precedence.
3787
+ ...components,
3788
+ ...props.customComponents || []
3789
+ ].reduce((acc, { component: _, ...info }) => ({
3790
+ ...acc,
3791
+ [info.name]: serializeComponentInfo(info)
3792
+ }), {}),
3793
+ inheritedStyles: {}
3794
+ },
3795
+ registeredComponents: [
3796
+ ...getDefaultRegisteredComponents(),
3797
+ // While this `components` object is deprecated, we must maintain support for it.
3798
+ // Since users are able to override our default components, we need to make sure that we do not break such
3799
+ // existing usage.
3800
+ // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
3801
+ // which is the new standard way of providing custom components, and must therefore take precedence.
3802
+ ...components,
3803
+ ...props.customComponents || []
3804
+ ].reduce((acc, { component, ...info }) => ({
3805
+ ...acc,
3806
+ [info.name]: {
3807
+ component,
3808
+ ...serializeComponentInfo(info)
3809
+ }
3810
+ }), {}),
3811
+ scriptStr: getRenderContentScriptString({
3812
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
3813
+ variationId: (_a = props.content) == null ? void 0 : _a.testVariationId,
3814
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
3815
+ contentId: (_b = props.content) == null ? void 0 : _b.id
3816
+ })
3817
+ }, {
3818
+ deep: true
3819
+ });
3820
+ useContextProvider(ComponentsContext, useStore({
3821
+ registeredComponents: state.registeredComponents
3822
+ }));
3823
+ return /* @__PURE__ */ _jsxC(EnableEditor, {
3824
+ get content() {
3825
+ return props.content;
3826
+ },
3827
+ get model() {
3828
+ return props.model;
3829
+ },
3830
+ get context() {
3831
+ return props.context;
3832
+ },
3833
+ get apiKey() {
3834
+ return props.apiKey;
3835
+ },
3836
+ get canTrack() {
3837
+ return props.canTrack;
3838
+ },
3839
+ get locale() {
3840
+ return props.locale;
3841
+ },
3842
+ get includeRefs() {
3843
+ return props.includeRefs;
3844
+ },
3845
+ get enrich() {
3846
+ return props.enrich;
3847
+ },
3848
+ get classNameProp() {
3849
+ return props.classNameProp;
3850
+ },
3851
+ get showContent() {
3852
+ return props.showContent;
3853
+ },
3854
+ get builderContextSignal() {
3855
+ return state.builderContextSignal;
3856
+ },
3857
+ children: [
3858
+ props.isSsrAbTest ? /* @__PURE__ */ _jsxC(InlinedScript, {
3859
+ get scriptStr() {
3860
+ return state.scriptStr;
3861
+ },
3862
+ [_IMMUTABLE]: {
3863
+ scriptStr: _fnSignal((p0) => p0.scriptStr, [
3864
+ state
3865
+ ], "p0.scriptStr")
3866
+ }
3867
+ }, 3, "LQ_0") : null,
3868
+ /* @__PURE__ */ _jsxC(ContentStyles, {
3869
+ get contentId() {
3870
+ var _a2;
3871
+ return (_a2 = state.builderContextSignal.content) == null ? void 0 : _a2.id;
3872
+ },
3873
+ get cssCode() {
3874
+ var _a2, _b2;
3875
+ return (_b2 = (_a2 = state.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.cssCode;
3876
+ },
3877
+ get customFonts() {
3878
+ var _a2, _b2;
3879
+ return (_b2 = (_a2 = state.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.customFonts;
3880
+ },
3881
+ [_IMMUTABLE]: {
3882
+ contentId: _fnSignal((p0) => {
3883
+ var _a2;
3884
+ return (_a2 = p0.builderContextSignal.content) == null ? void 0 : _a2.id;
3885
+ }, [
3886
+ state
3887
+ ], "p0.builderContextSignal.content?.id"),
3888
+ cssCode: _fnSignal((p0) => {
3889
+ var _a2, _b2;
3890
+ return (_b2 = (_a2 = p0.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.cssCode;
3891
+ }, [
3892
+ state
3893
+ ], "p0.builderContextSignal.content?.data?.cssCode"),
3894
+ customFonts: _fnSignal((p0) => {
3895
+ var _a2, _b2;
3896
+ return (_b2 = (_a2 = p0.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.customFonts;
3897
+ }, [
3898
+ state
3899
+ ], "p0.builderContextSignal.content?.data?.customFonts")
3900
+ }
3901
+ }, 3, "LQ_1"),
3902
+ /* @__PURE__ */ _jsxC(Blocks, {
3903
+ get blocks() {
3904
+ var _a2, _b2;
3905
+ return (_b2 = (_a2 = state.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.blocks;
3906
+ },
3907
+ get context() {
3908
+ return state.builderContextSignal;
3909
+ },
3910
+ get registeredComponents() {
3911
+ return state.registeredComponents;
3912
+ },
3913
+ [_IMMUTABLE]: {
3914
+ blocks: _fnSignal((p0) => {
3915
+ var _a2, _b2;
3916
+ return (_b2 = (_a2 = p0.builderContextSignal.content) == null ? void 0 : _a2.data) == null ? void 0 : _b2.blocks;
3917
+ }, [
3918
+ state
3919
+ ], "p0.builderContextSignal.content?.data?.blocks"),
3920
+ context: _fnSignal((p0) => p0.builderContextSignal, [
3921
+ state
3922
+ ], "p0.builderContextSignal"),
3923
+ registeredComponents: _fnSignal((p0) => p0.registeredComponents, [
3924
+ state
3925
+ ], "p0.registeredComponents")
3926
+ }
3927
+ }, 3, "LQ_2")
3928
+ ],
3929
+ [_IMMUTABLE]: {
3930
+ apiKey: _fnSignal((p0) => p0.apiKey, [
3931
+ props
3932
+ ], "p0.apiKey"),
3933
+ builderContextSignal: _fnSignal((p0) => p0.builderContextSignal, [
3934
+ state
3935
+ ], "p0.builderContextSignal"),
3936
+ canTrack: _fnSignal((p0) => p0.canTrack, [
3937
+ props
3938
+ ], "p0.canTrack"),
3939
+ classNameProp: _fnSignal((p0) => p0.classNameProp, [
3940
+ props
3941
+ ], "p0.classNameProp"),
3942
+ content: _fnSignal((p0) => p0.content, [
3943
+ props
3944
+ ], "p0.content"),
3945
+ context: _fnSignal((p0) => p0.context, [
3946
+ props
3947
+ ], "p0.context"),
3948
+ enrich: _fnSignal((p0) => p0.enrich, [
3949
+ props
3950
+ ], "p0.enrich"),
3951
+ includeRefs: _fnSignal((p0) => p0.includeRefs, [
3952
+ props
3953
+ ], "p0.includeRefs"),
3954
+ locale: _fnSignal((p0) => p0.locale, [
3955
+ props
3956
+ ], "p0.locale"),
3957
+ model: _fnSignal((p0) => p0.model, [
3958
+ props
3959
+ ], "p0.model"),
3960
+ showContent: _fnSignal((p0) => p0.showContent, [
3961
+ props
3962
+ ], "p0.showContent")
3963
+ }
3964
+ }, 1, "LQ_3");
3965
+ }, "ContentComponent_component_HIsczUcxjCE"));
3966
+ const ContentVariants = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
3967
+ _jsxBranch();
3968
+ const state = useStore({
3969
+ shouldRenderVariants: checkShouldRunVariants({
3970
+ canTrack: getDefaultCanTrack(props.canTrack),
3971
+ content: props.content
3972
+ })
3973
+ });
3974
+ const variantScriptStr = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
3975
+ var _a;
3976
+ const [props2] = useLexicalScope();
3977
+ return getVariantsScriptString(getVariants(props2.content).map((value) => ({
3978
+ id: value.testVariationId,
3979
+ testRatio: value.testRatio
3980
+ })), ((_a = props2.content) == null ? void 0 : _a.id) || "");
3981
+ }, "ContentVariants_component_variantScriptStr_useComputed_ldWqWafT8Ww", [
3982
+ props
3983
+ ]));
3984
+ const hideVariantsStyleString = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
3985
+ const [props2] = useLexicalScope();
3986
+ return getVariants(props2.content).map((value) => `.variant-${value.testVariationId} { display: none; } `).join("");
3987
+ }, "ContentVariants_component_hideVariantsStyleString_useComputed_fQIC0fJqAl4", [
3988
+ props
3989
+ ]));
3990
+ const defaultContent = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
3991
+ var _a;
3992
+ const [props2, state2] = useLexicalScope();
3993
+ return state2.shouldRenderVariants ? {
3994
+ ...props2.content,
3995
+ testVariationId: (_a = props2.content) == null ? void 0 : _a.id
3996
+ } : handleABTestingSync({
3997
+ item: props2.content,
3998
+ canTrack: getDefaultCanTrack(props2.canTrack)
3999
+ });
4000
+ }, "ContentVariants_component_defaultContent_useComputed_00q2HQsQPYc", [
4001
+ props,
4002
+ state
4003
+ ]));
4004
+ return /* @__PURE__ */ _jsxC(Fragment$1, {
4005
+ children: [
4006
+ !props.__isNestedRender && TARGET !== "reactNative" ? /* @__PURE__ */ _jsxC(InlinedScript, {
4007
+ get scriptStr() {
4008
+ return getScriptString();
4009
+ },
4010
+ [_IMMUTABLE]: {
4011
+ scriptStr: _IMMUTABLE
4012
+ }
4013
+ }, 3, "XM_0") : null,
4014
+ state.shouldRenderVariants ? /* @__PURE__ */ _jsxC(Fragment, {
4015
+ children: [
4016
+ /* @__PURE__ */ _jsxC(InlinedStyles, {
4017
+ get id() {
4018
+ var _a;
4019
+ return `variants-styles-${(_a = props.content) == null ? void 0 : _a.id}`;
4020
+ },
4021
+ get styles() {
4022
+ return hideVariantsStyleString.value;
4023
+ },
4024
+ [_IMMUTABLE]: {
4025
+ id: _fnSignal((p0) => {
4026
+ var _a;
4027
+ return `variants-styles-${(_a = p0.content) == null ? void 0 : _a.id}`;
4028
+ }, [
4029
+ props
4030
+ ], "`variants-styles-${p0.content?.id}`"),
4031
+ styles: _fnSignal((p0) => p0.value, [
4032
+ hideVariantsStyleString
4033
+ ], "p0.value")
4034
+ }
4035
+ }, 3, "XM_1"),
4036
+ /* @__PURE__ */ _jsxC(InlinedScript, {
4037
+ get scriptStr() {
4038
+ return variantScriptStr.value;
4039
+ },
4040
+ [_IMMUTABLE]: {
4041
+ scriptStr: _fnSignal((p0) => p0.value, [
4042
+ variantScriptStr
4043
+ ], "p0.value")
4044
+ }
4045
+ }, 3, "XM_2"),
4046
+ (getVariants(props.content) || []).map((variant) => {
4047
+ return /* @__PURE__ */ _jsxC(ContentComponent, {
4048
+ content: variant,
4049
+ showContent: false,
4050
+ get classNameProp() {
4051
+ return void 0;
4052
+ },
4053
+ get model() {
4054
+ return props.model;
4055
+ },
4056
+ get data() {
4057
+ return props.data;
4058
+ },
4059
+ get context() {
4060
+ return props.context;
4061
+ },
4062
+ get apiKey() {
4063
+ return props.apiKey;
4064
+ },
4065
+ get apiVersion() {
4066
+ return props.apiVersion;
4067
+ },
4068
+ get customComponents() {
4069
+ return props.customComponents;
4070
+ },
4071
+ get canTrack() {
4072
+ return props.canTrack;
4073
+ },
4074
+ get locale() {
4075
+ return props.locale;
4076
+ },
4077
+ get includeRefs() {
4078
+ return props.includeRefs;
4079
+ },
4080
+ get enrich() {
4081
+ return props.enrich;
4082
+ },
4083
+ get isSsrAbTest() {
4084
+ return state.shouldRenderVariants;
4085
+ },
4086
+ [_IMMUTABLE]: {
4087
+ apiKey: _fnSignal((p0) => p0.apiKey, [
4088
+ props
4089
+ ], "p0.apiKey"),
4090
+ apiVersion: _fnSignal((p0) => p0.apiVersion, [
4091
+ props
4092
+ ], "p0.apiVersion"),
4093
+ canTrack: _fnSignal((p0) => p0.canTrack, [
4094
+ props
4095
+ ], "p0.canTrack"),
4096
+ classNameProp: _IMMUTABLE,
4097
+ context: _fnSignal((p0) => p0.context, [
4098
+ props
4099
+ ], "p0.context"),
4100
+ customComponents: _fnSignal((p0) => p0.customComponents, [
4101
+ props
4102
+ ], "p0.customComponents"),
4103
+ data: _fnSignal((p0) => p0.data, [
4104
+ props
4105
+ ], "p0.data"),
4106
+ enrich: _fnSignal((p0) => p0.enrich, [
4107
+ props
4108
+ ], "p0.enrich"),
4109
+ includeRefs: _fnSignal((p0) => p0.includeRefs, [
4110
+ props
4111
+ ], "p0.includeRefs"),
4112
+ isSsrAbTest: _fnSignal((p0) => p0.shouldRenderVariants, [
4113
+ state
4114
+ ], "p0.shouldRenderVariants"),
4115
+ locale: _fnSignal((p0) => p0.locale, [
4116
+ props
4117
+ ], "p0.locale"),
4118
+ model: _fnSignal((p0) => p0.model, [
4119
+ props
4120
+ ], "p0.model"),
4121
+ showContent: _IMMUTABLE
4122
+ }
4123
+ }, 3, variant.testVariationId);
4124
+ })
4125
+ ]
4126
+ }, 1, "XM_3") : null,
4127
+ /* @__PURE__ */ _jsxC(ContentComponent, {
4128
+ get content() {
4129
+ return defaultContent.value;
4130
+ },
4131
+ get classNameProp() {
4132
+ var _a;
4133
+ return `variant-${(_a = props.content) == null ? void 0 : _a.id}`;
4134
+ },
4135
+ showContent: true,
4136
+ get model() {
4137
+ return props.model;
4138
+ },
4139
+ get data() {
4140
+ return props.data;
4141
+ },
4142
+ get context() {
4143
+ return props.context;
4144
+ },
4145
+ get apiKey() {
4146
+ return props.apiKey;
4147
+ },
4148
+ get apiVersion() {
4149
+ return props.apiVersion;
4150
+ },
4151
+ get customComponents() {
4152
+ return props.customComponents;
4153
+ },
4154
+ get canTrack() {
4155
+ return props.canTrack;
4156
+ },
4157
+ get locale() {
4158
+ return props.locale;
4159
+ },
4160
+ get includeRefs() {
4161
+ return props.includeRefs;
4162
+ },
4163
+ get enrich() {
4164
+ return props.enrich;
4165
+ },
4166
+ get isSsrAbTest() {
4167
+ return state.shouldRenderVariants;
4168
+ },
4169
+ [_IMMUTABLE]: {
4170
+ apiKey: _fnSignal((p0) => p0.apiKey, [
4171
+ props
4172
+ ], "p0.apiKey"),
4173
+ apiVersion: _fnSignal((p0) => p0.apiVersion, [
4174
+ props
4175
+ ], "p0.apiVersion"),
4176
+ canTrack: _fnSignal((p0) => p0.canTrack, [
4177
+ props
4178
+ ], "p0.canTrack"),
4179
+ classNameProp: _fnSignal((p0) => {
4180
+ var _a;
4181
+ return `variant-${(_a = p0.content) == null ? void 0 : _a.id}`;
4182
+ }, [
4183
+ props
4184
+ ], "`variant-${p0.content?.id}`"),
4185
+ content: _fnSignal((p0) => p0.value, [
4186
+ defaultContent
4187
+ ], "p0.value"),
4188
+ context: _fnSignal((p0) => p0.context, [
4189
+ props
4190
+ ], "p0.context"),
4191
+ customComponents: _fnSignal((p0) => p0.customComponents, [
4192
+ props
4193
+ ], "p0.customComponents"),
4194
+ data: _fnSignal((p0) => p0.data, [
4195
+ props
4196
+ ], "p0.data"),
4197
+ enrich: _fnSignal((p0) => p0.enrich, [
4198
+ props
4199
+ ], "p0.enrich"),
4200
+ includeRefs: _fnSignal((p0) => p0.includeRefs, [
4201
+ props
4202
+ ], "p0.includeRefs"),
4203
+ isSsrAbTest: _fnSignal((p0) => p0.shouldRenderVariants, [
4204
+ state
4205
+ ], "p0.shouldRenderVariants"),
4206
+ locale: _fnSignal((p0) => p0.locale, [
4207
+ props
4208
+ ], "p0.locale"),
4209
+ model: _fnSignal((p0) => p0.model, [
4210
+ props
4211
+ ], "p0.model"),
4212
+ showContent: _IMMUTABLE
4213
+ }
4214
+ }, 3, "XM_4")
4215
+ ]
4216
+ }, 1, "XM_5");
4217
+ }, "ContentVariants_component_4tFRiQMMEfM"));
4218
+ const fetchSymbolContent = async ({ builderContextValue, symbol }) => {
4219
+ if ((symbol == null ? void 0 : symbol.model) && // This is a hack, we should not need to check for this, but it is needed for Svelte.
4220
+ (builderContextValue == null ? void 0 : builderContextValue.apiKey))
4221
+ return fetchOneEntry({
4222
+ model: symbol.model,
4223
+ apiKey: builderContextValue.apiKey,
4224
+ apiVersion: builderContextValue.apiVersion,
4225
+ ...(symbol == null ? void 0 : symbol.entry) && {
4226
+ query: {
4227
+ id: symbol.entry
4228
+ }
4229
+ }
4230
+ }).catch((err) => {
4231
+ logger.error("Could not fetch symbol content: ", err);
4232
+ return void 0;
4233
+ });
4234
+ return void 0;
4235
+ };
4236
+ const setContent = function setContent2(props, state) {
4237
+ if (state.contentToUse)
4238
+ return;
4239
+ fetchSymbolContent({
4240
+ symbol: props.symbol,
4241
+ builderContextValue: props.builderContext
4242
+ }).then((newContent) => {
4243
+ if (newContent)
4244
+ state.contentToUse = newContent;
4245
+ });
4246
+ };
4247
+ const Symbol$1 = /* @__PURE__ */ componentQrl(/* @__PURE__ */ inlinedQrl((props) => {
4248
+ var _a;
4249
+ const className = useComputedQrl(/* @__PURE__ */ inlinedQrl(() => {
4250
+ var _a2, _b;
4251
+ const [props2] = useLexicalScope();
4252
+ return [
4253
+ props2.attributes.class,
4254
+ "builder-symbol",
4255
+ ((_a2 = props2.symbol) == null ? void 0 : _a2.inline) ? "builder-inline-symbol" : void 0,
4256
+ ((_b = props2.symbol) == null ? void 0 : _b.dynamic) || props2.dynamic ? "builder-dynamic-symbol" : void 0
4257
+ ].filter(Boolean).join(" ");
4258
+ }, "Symbol_component_className_useComputed_Wb6GqgtDHpE", [
4259
+ props
4260
+ ]));
4261
+ const state = useStore({
4262
+ contentToUse: (_a = props.symbol) == null ? void 0 : _a.content
4263
+ });
4264
+ useTaskQrl(/* @__PURE__ */ inlinedQrl(({ track: track2 }) => {
4265
+ const [props2, state2] = useLexicalScope();
4266
+ track2(() => props2.symbol);
4267
+ setContent(props2, state2);
4268
+ }, "Symbol_component_useTask_NIAWAC1bMBo", [
4269
+ props,
4270
+ state
4271
+ ]));
4272
+ return /* @__PURE__ */ _jsxS("div", {
4273
+ ...props.attributes,
4274
+ children: /* @__PURE__ */ _jsxC(ContentVariants, {
4275
+ get apiVersion() {
4276
+ return props.builderContext.apiVersion;
4277
+ },
4278
+ get apiKey() {
4279
+ return props.builderContext.apiKey;
4280
+ },
4281
+ get context() {
4282
+ return props.builderContext.context;
4283
+ },
4284
+ get customComponents() {
4285
+ return Object.values(props.builderComponents);
4286
+ },
4287
+ get data() {
4288
+ var _a2, _b, _c;
4289
+ return {
4290
+ ...(_a2 = props.symbol) == null ? void 0 : _a2.data,
4291
+ ...props.builderContext.localState,
4292
+ ...(_c = (_b = state.contentToUse) == null ? void 0 : _b.data) == null ? void 0 : _c.state
4293
+ };
4294
+ },
4295
+ get model() {
4296
+ var _a2;
4297
+ return (_a2 = props.symbol) == null ? void 0 : _a2.model;
4298
+ },
4299
+ get content() {
4300
+ return state.contentToUse;
4301
+ },
4302
+ [_IMMUTABLE]: {
4303
+ apiKey: _fnSignal((p0) => p0.builderContext.apiKey, [
4304
+ props
4305
+ ], "p0.builderContext.apiKey"),
4306
+ apiVersion: _fnSignal((p0) => p0.builderContext.apiVersion, [
4307
+ props
4308
+ ], "p0.builderContext.apiVersion"),
4309
+ content: _fnSignal((p0) => p0.contentToUse, [
4310
+ state
4311
+ ], "p0.contentToUse"),
4312
+ context: _fnSignal((p0) => p0.builderContext.context, [
4313
+ props
4314
+ ], "p0.builderContext.context"),
4315
+ customComponents: _fnSignal((p0) => Object.values(p0.builderComponents), [
4316
+ props
4317
+ ], "Object.values(p0.builderComponents)"),
4318
+ data: _fnSignal((p0, p1) => {
4319
+ var _a2, _b, _c;
4320
+ return {
4321
+ ...(_a2 = p0.symbol) == null ? void 0 : _a2.data,
4322
+ ...p0.builderContext.localState,
4323
+ ...(_c = (_b = p1.contentToUse) == null ? void 0 : _b.data) == null ? void 0 : _c.state
4324
+ };
4325
+ }, [
4326
+ props,
4327
+ state
4328
+ ], "{...p0.symbol?.data,...p0.builderContext.localState,...p1.contentToUse?.data?.state}"),
4329
+ model: _fnSignal((p0) => {
4330
+ var _a2;
4331
+ return (_a2 = p0.symbol) == null ? void 0 : _a2.model;
4332
+ }, [
4333
+ props
4334
+ ], "p0.symbol?.model")
4335
+ }
4336
+ }, 3, "Wt_0")
4337
+ }, {
4338
+ class: _fnSignal((p0) => p0.value, [
4339
+ className
4340
+ ], "p0.value")
4341
+ }, 0, "Wt_1");
4342
+ }, "Symbol_component_WVvggdkUPdk"));
4343
+ const RenderBlocks = Blocks;
4344
+ const RenderContent = ContentVariants;
4345
+ const settings = {};
4346
+ function setEditorSettings(newSettings) {
4347
+ if (isBrowser()) {
4348
+ Object.assign(settings, newSettings);
4349
+ const message = {
4350
+ type: "builder.settingsChange",
4351
+ data: settings
4352
+ };
4353
+ parent.postMessage(message, "*");
4354
+ }
4355
+ }
4356
+ const fetchBuilderProps = async (_args) => {
4357
+ var _a, _b, _c;
4358
+ const urlPath = _args.path || ((_a = _args.url) == null ? void 0 : _a.pathname) || ((_b = _args.userAttributes) == null ? void 0 : _b.urlPath);
4359
+ const getContentArgs = {
4360
+ ..._args,
4361
+ apiKey: _args.apiKey,
4362
+ model: _args.model || "page",
4363
+ userAttributes: {
4364
+ ..._args.userAttributes,
4365
+ ...urlPath ? {
4366
+ urlPath
4367
+ } : {}
4368
+ },
4369
+ options: getBuilderSearchParams(_args.searchParams || ((_c = _args.url) == null ? void 0 : _c.searchParams) || _args.options)
4370
+ };
4371
+ return {
4372
+ apiKey: getContentArgs.apiKey,
4373
+ model: getContentArgs.model,
4374
+ content: await fetchOneEntry(getContentArgs)
4375
+ };
4376
+ };
4377
+ export {
4378
+ Blocks,
4379
+ Button,
4380
+ Columns,
4381
+ ContentVariants as Content,
4382
+ FragmentComponent as Fragment,
4383
+ Image,
4384
+ RenderBlocks,
4385
+ RenderContent,
4386
+ SectionComponent as Section,
4387
+ Symbol$1 as Symbol,
4388
+ Text,
4389
+ Video,
4390
+ _processContentResult,
4391
+ createRegisterComponentMessage,
4392
+ fetchBuilderProps,
4393
+ fetchEntries,
4394
+ fetchOneEntry,
4395
+ getAllContent,
4396
+ getBuilderSearchParams,
4397
+ getContent,
4398
+ isEditing,
4399
+ isPreviewing,
4400
+ register,
4401
+ setEditorSettings,
4402
+ track
4403
+ };