@builder.io/sdk-qwik 0.5.2 → 0.5.3-0

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