@builder.io/sdk-qwik 0.0.28 → 0.0.30

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,2928 @@
1
+ import { createContext, _wrapSignal, inlinedQrl, useLexicalScope, _IMMUTABLE, componentQrl, useContextProvider, useStore, useStylesScopedQrl, useContext, Fragment as Fragment$2, Slot, useRef, useWatchQrl, useClientEffectQrl, useCleanupQrl } from '@builder.io/qwik';
2
+ import { jsx, Fragment as Fragment$1, jsxs } from '@builder.io/qwik/jsx-runtime';
3
+
4
+ /** This file should be overriden for each framework. Ideally this would be implemented in Mitosis. */ const TARGET = 'qwik';
5
+
6
+ function isBrowser() {
7
+ return typeof window !== 'undefined' && typeof document !== 'undefined';
8
+ }
9
+
10
+ const registry = {};
11
+ function register(type, info) {
12
+ let typeList = registry[type];
13
+ if (!typeList) typeList = registry[type] = [];
14
+ typeList.push(info);
15
+ if (isBrowser()) {
16
+ const message = {
17
+ type: 'builder.register',
18
+ data: {
19
+ type,
20
+ info
21
+ }
22
+ };
23
+ try {
24
+ parent.postMessage(message, '*');
25
+ if (parent !== window) window.postMessage(message, '*');
26
+ } catch (err) {
27
+ console.debug('Could not postmessage', err);
28
+ }
29
+ }
30
+ }
31
+
32
+ const registerInsertMenu = ()=>{
33
+ register('insertMenu', {
34
+ name: '_default',
35
+ default: true,
36
+ items: [
37
+ {
38
+ name: 'Box'
39
+ },
40
+ {
41
+ name: 'Text'
42
+ },
43
+ {
44
+ name: 'Image'
45
+ },
46
+ {
47
+ name: 'Columns'
48
+ },
49
+ ...TARGET === 'reactNative' ? [] : [
50
+ {
51
+ name: 'Core:Section'
52
+ },
53
+ {
54
+ name: 'Core:Button'
55
+ },
56
+ {
57
+ name: 'Embed'
58
+ },
59
+ {
60
+ name: 'Custom Code'
61
+ }
62
+ ]
63
+ ]
64
+ });
65
+ };
66
+ let isSetupForEditing = false;
67
+ const setupBrowserForEditing = ()=>{
68
+ if (isSetupForEditing) return;
69
+ isSetupForEditing = true;
70
+ if (isBrowser()) {
71
+ window.parent?.postMessage({
72
+ type: 'builder.sdkInfo',
73
+ data: {
74
+ target: TARGET,
75
+ // TODO: compile these in
76
+ // type: process.env.SDK_TYPE,
77
+ // version: process.env.SDK_VERSION,
78
+ supportsPatchUpdates: false,
79
+ // Supports builder-model="..." attribute which is needed to
80
+ // scope our '+ add block' button styling
81
+ supportsAddBlockScoping: true,
82
+ supportsCustomBreakpoints: true
83
+ }
84
+ }, '*');
85
+ window.addEventListener('message', ({ data })=>{
86
+ if (!data?.type) return;
87
+ switch(data.type){
88
+ case 'builder.evaluate':
89
+ {
90
+ const text = data.data.text;
91
+ const args = data.data.arguments || [];
92
+ const id = data.data.id;
93
+ // tslint:disable-next-line:no-function-constructor-with-string-args
94
+ const fn = new Function(text);
95
+ let result;
96
+ let error = null;
97
+ try {
98
+ // eslint-disable-next-line prefer-spread
99
+ result = fn.apply(null, args);
100
+ } catch (err) {
101
+ error = err;
102
+ }
103
+ if (error) window.parent?.postMessage({
104
+ type: 'builder.evaluateError',
105
+ data: {
106
+ id,
107
+ error: error.message
108
+ }
109
+ }, '*');
110
+ else if (result && typeof result.then === 'function') result.then((finalResult)=>{
111
+ window.parent?.postMessage({
112
+ type: 'builder.evaluateResult',
113
+ data: {
114
+ id,
115
+ result: finalResult
116
+ }
117
+ }, '*');
118
+ }).catch(console.error);
119
+ else window.parent?.postMessage({
120
+ type: 'builder.evaluateResult',
121
+ data: {
122
+ result,
123
+ id
124
+ }
125
+ }, '*');
126
+ break;
127
+ }
128
+ }
129
+ });
130
+ }
131
+ };
132
+
133
+ const BuilderContext = createContext("Builder");
134
+
135
+ function isIframe() {
136
+ return isBrowser() && window.self !== window.top;
137
+ }
138
+
139
+ function isEditing() {
140
+ return isIframe() && window.location.search.indexOf('builder.frameEditing=') !== -1;
141
+ }
142
+
143
+ /**
144
+ * We need to serialize values to a string in case there are Proxy values, as is the case with SolidJS etc.
145
+ */ const fastClone = (obj)=>JSON.parse(JSON.stringify(obj));
146
+
147
+ const SIZES = {
148
+ small: {
149
+ min: 320,
150
+ default: 321,
151
+ max: 640
152
+ },
153
+ medium: {
154
+ min: 641,
155
+ default: 642,
156
+ max: 991
157
+ },
158
+ large: {
159
+ min: 990,
160
+ default: 991,
161
+ max: 1200
162
+ }
163
+ };
164
+ const getMaxWidthQueryForSize = (size, sizeValues = SIZES)=>`@media (max-width: ${sizeValues[size].max}px)`;
165
+ const getSizesForBreakpoints = ({ small , medium })=>{
166
+ const newSizes = fastClone(SIZES); // Note: this helps to get a deep clone of fields like small, medium etc
167
+ if (!small || !medium) return newSizes;
168
+ const smallMin = Math.floor(small / 2);
169
+ newSizes.small = {
170
+ max: small,
171
+ min: smallMin,
172
+ default: smallMin + 1
173
+ };
174
+ const mediumMin = newSizes.small.max + 1;
175
+ newSizes.medium = {
176
+ max: medium,
177
+ min: mediumMin,
178
+ default: mediumMin + 1
179
+ };
180
+ const largeMin = newSizes.medium.max + 1;
181
+ newSizes.large = {
182
+ max: 2000,
183
+ min: largeMin,
184
+ default: largeMin + 1
185
+ };
186
+ return newSizes;
187
+ };
188
+
189
+ function evaluate({ code , context , state , event }) {
190
+ if (code === '') {
191
+ console.warn('Skipping evaluation of empty code block.');
192
+ return;
193
+ }
194
+ const builder = {
195
+ isEditing: isEditing(),
196
+ isBrowser: isBrowser(),
197
+ isServer: !isBrowser()
198
+ };
199
+ // Be able to handle simple expressions like "state.foo" or "1 + 1"
200
+ // as well as full blocks like "var foo = "bar"; return foo"
201
+ const useReturn = !(code.includes(';') || code.includes(' return ') || code.trim().startsWith('return '));
202
+ const useCode = useReturn ? `return (${code});` : code;
203
+ try {
204
+ return new Function('builder', 'Builder' /* <- legacy */ , 'state', 'context', 'event', useCode)(builder, builder, state, context, event);
205
+ } catch (e) {
206
+ console.warn('Builder custom code error: \n While Evaluating: \n ', useCode, '\n', e.message || e);
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Minimal implementation of lodash's _.set
212
+ * https://lodash.com/docs/4.17.15#set
213
+ *
214
+ * See ./set.test.ts for usage examples
215
+ */ const set = (obj, _path, value)=>{
216
+ if (Object(obj) !== obj) return obj;
217
+ const path = Array.isArray(_path) ? _path : _path.toString().match(/[^.[\]]+/g);
218
+ 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;
219
+ return obj;
220
+ };
221
+
222
+ // Noope way for targets to make modifications to the block object if/as needed
223
+ function transformBlock(block) {
224
+ return block;
225
+ }
226
+
227
+ const evaluateBindings = ({ block , context , state })=>{
228
+ if (!block.bindings) return block;
229
+ const copy = fastClone(block);
230
+ const copied = {
231
+ ...copy,
232
+ properties: {
233
+ ...copy.properties
234
+ },
235
+ actions: {
236
+ ...copy.actions
237
+ }
238
+ };
239
+ for(const binding in block.bindings){
240
+ const expression = block.bindings[binding];
241
+ const value = evaluate({
242
+ code: expression,
243
+ state,
244
+ context
245
+ });
246
+ set(copied, binding, value);
247
+ }
248
+ return copied;
249
+ };
250
+ function getProcessedBlock({ block , context , shouldEvaluateBindings , state }) {
251
+ const transformedBlock = transformBlock(block);
252
+ if (shouldEvaluateBindings) return evaluateBindings({
253
+ block: transformedBlock,
254
+ state,
255
+ context
256
+ });
257
+ else return transformedBlock;
258
+ }
259
+
260
+ const camelToKebabCase = (string)=>string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, '$1-$2').toLowerCase();
261
+
262
+ const convertStyleMaptoCSS = (style)=>{
263
+ const cssProps = Object.entries(style).map(([key, value])=>{
264
+ if (typeof value === 'string') return `${camelToKebabCase(key)}: ${value};`;
265
+ });
266
+ return cssProps.join('\n');
267
+ };
268
+ const createCssClass = ({ mediaQuery , className , styles })=>{
269
+ const cssClass = `.${className} {
270
+ ${convertStyleMaptoCSS(styles)}
271
+ }`;
272
+ if (mediaQuery) return `${mediaQuery} {
273
+ ${cssClass}
274
+ }`;
275
+ else return cssClass;
276
+ };
277
+
278
+ // GENERATED BY MITOSIS
279
+ const tag$1 = function tag(props, state) {
280
+ // NOTE: we have to obfusctate the name of the tag due to a limitation in the svelte-preprocessor plugin.
281
+ // https://github.com/sveltejs/vite-plugin-svelte/issues/315#issuecomment-1109000027
282
+ return "style";
283
+ };
284
+ const RenderInlinedStyles = (props)=>{
285
+ const state = {};
286
+ state.tag = tag$1();
287
+ return /*#__PURE__*/ jsx(Fragment$1, {
288
+ children: /*#__PURE__*/ jsx(state.tag, {
289
+ children: _wrapSignal(props, "styles")
290
+ })
291
+ });
292
+ };
293
+ const RenderInlinedStyles$1 = RenderInlinedStyles;
294
+
295
+ // GENERATED BY MITOSIS
296
+ const useBlock$1 = function useBlock(props, state) {
297
+ return getProcessedBlock({
298
+ block: props.block,
299
+ state: props.context.state,
300
+ context: props.context.context,
301
+ shouldEvaluateBindings: true
302
+ });
303
+ };
304
+ const css = function css(props, state) {
305
+ const styles = useBlock$1(props).responsiveStyles;
306
+ const content = props.context.content;
307
+ const sizesWithUpdatedBreakpoints = getSizesForBreakpoints(content?.meta?.breakpoints || {});
308
+ const largeStyles = styles?.large;
309
+ const mediumStyles = styles?.medium;
310
+ const smallStyles = styles?.small;
311
+ const className = useBlock$1(props).id;
312
+ const largeStylesClass = largeStyles ? createCssClass({
313
+ className,
314
+ styles: largeStyles
315
+ }) : "";
316
+ const mediumStylesClass = mediumStyles ? createCssClass({
317
+ className,
318
+ styles: mediumStyles,
319
+ mediaQuery: getMaxWidthQueryForSize("medium", sizesWithUpdatedBreakpoints)
320
+ }) : "";
321
+ const smallStylesClass = smallStyles ? createCssClass({
322
+ className,
323
+ styles: smallStyles,
324
+ mediaQuery: getMaxWidthQueryForSize("small", sizesWithUpdatedBreakpoints)
325
+ }) : "";
326
+ return [
327
+ largeStylesClass,
328
+ mediumStylesClass,
329
+ smallStylesClass
330
+ ].join(" ");
331
+ };
332
+ const BlockStyles = (props)=>{
333
+ return /*#__PURE__*/ jsx(Fragment$1, {
334
+ children: TARGET !== "reactNative" && css(props) ? /*#__PURE__*/ jsx(RenderInlinedStyles$1, {
335
+ styles: css(props)
336
+ }) : null
337
+ });
338
+ };
339
+ const BlockStyles$1 = BlockStyles;
340
+
341
+ function capitalizeFirstLetter(string) {
342
+ return string.charAt(0).toUpperCase() + string.slice(1);
343
+ }
344
+ const getEventHandlerName = (key)=>`on${capitalizeFirstLetter(key)}$`;
345
+
346
+ function crateEventHandler(value, options) {
347
+ return inlinedQrl((event)=>{
348
+ const [options, value] = useLexicalScope();
349
+ return evaluate({
350
+ code: value,
351
+ context: options.context,
352
+ state: options.state,
353
+ event
354
+ });
355
+ }, "crateEventHandler_wgxT8Hlq4s8", [
356
+ options,
357
+ value
358
+ ]);
359
+ }
360
+
361
+ function getBlockActions(options) {
362
+ const obj = {};
363
+ const optionActions = options.block.actions ?? {};
364
+ for(const key in optionActions){
365
+ // eslint-disable-next-line no-prototype-builtins
366
+ if (!optionActions.hasOwnProperty(key)) continue;
367
+ const value = optionActions[key];
368
+ obj[getEventHandlerName(key)] = crateEventHandler(value, options);
369
+ }
370
+ return obj;
371
+ }
372
+
373
+ function getBlockComponentOptions(block) {
374
+ return {
375
+ ...block.component?.options,
376
+ ...block.options,
377
+ /**
378
+ * Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
379
+ */ builderBlock: block
380
+ };
381
+ }
382
+
383
+ function getBlockProperties(block) {
384
+ return {
385
+ ...block.properties,
386
+ 'builder-id': block.id,
387
+ class: [
388
+ block.id,
389
+ 'builder-block',
390
+ block.class,
391
+ block.properties?.class
392
+ ].filter(Boolean).join(' ')
393
+ };
394
+ }
395
+
396
+ function getBlockTag(block) {
397
+ return block.tagName || 'div';
398
+ }
399
+
400
+ /**
401
+ * https://developer.mozilla.org/en-US/docs/Glossary/Empty_element
402
+ */ const EMPTY_HTML_ELEMENTS = [
403
+ 'area',
404
+ 'base',
405
+ 'br',
406
+ 'col',
407
+ 'embed',
408
+ 'hr',
409
+ 'img',
410
+ 'input',
411
+ 'keygen',
412
+ 'link',
413
+ 'meta',
414
+ 'param',
415
+ 'source',
416
+ 'track',
417
+ 'wbr'
418
+ ];
419
+ const isEmptyHtmlElement = (tagName)=>{
420
+ return typeof tagName === 'string' && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
421
+ };
422
+
423
+ // GENERATED BY MITOSIS
424
+ const RenderComponent = (props)=>{
425
+ return /*#__PURE__*/ jsx(Fragment$1, {
426
+ children: props.componentRef ? /*#__PURE__*/ jsxs(props.componentRef, {
427
+ ...props.componentOptions,
428
+ children: [
429
+ (props.blockChildren || []).map(function(child) {
430
+ return /*#__PURE__*/ jsx(RenderBlock$1, {
431
+ block: child,
432
+ get context () {
433
+ return props.context;
434
+ },
435
+ [_IMMUTABLE]: {
436
+ context: _wrapSignal(props, "context")
437
+ }
438
+ }, "render-block-" + child.id);
439
+ }),
440
+ (props.blockChildren || []).map(function(child) {
441
+ return /*#__PURE__*/ jsx(BlockStyles$1, {
442
+ block: child,
443
+ get context () {
444
+ return props.context;
445
+ },
446
+ [_IMMUTABLE]: {
447
+ context: _wrapSignal(props, "context")
448
+ }
449
+ }, "block-style-" + child.id);
450
+ })
451
+ ]
452
+ }) : null
453
+ });
454
+ };
455
+ const RenderComponent$1 = RenderComponent;
456
+
457
+ // GENERATED BY MITOSIS
458
+ const RenderComponentWithContext = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
459
+ useContextProvider(BuilderContext, useStore({
460
+ content: (()=>{
461
+ return props.context.content;
462
+ })(),
463
+ state: (()=>{
464
+ return props.context.state;
465
+ })(),
466
+ context: (()=>{
467
+ return props.context.context;
468
+ })(),
469
+ apiKey: (()=>{
470
+ return props.context.apiKey;
471
+ })(),
472
+ registeredComponents: (()=>{
473
+ return props.context.registeredComponents;
474
+ })(),
475
+ inheritedStyles: (()=>{
476
+ return props.context.inheritedStyles;
477
+ })()
478
+ }));
479
+ return /*#__PURE__*/ jsx(RenderComponent$1, {
480
+ get componentRef () {
481
+ return props.componentRef;
482
+ },
483
+ get componentOptions () {
484
+ return props.componentOptions;
485
+ },
486
+ get blockChildren () {
487
+ return props.blockChildren;
488
+ },
489
+ get context () {
490
+ return props.context;
491
+ },
492
+ [_IMMUTABLE]: {
493
+ componentRef: _wrapSignal(props, "componentRef"),
494
+ componentOptions: _wrapSignal(props, "componentOptions"),
495
+ blockChildren: _wrapSignal(props, "blockChildren"),
496
+ context: _wrapSignal(props, "context")
497
+ }
498
+ });
499
+ }, "RenderComponentWithContext_component_nXOUbUnjTAo"));
500
+ const RenderComponentWithContext$1 = RenderComponentWithContext;
501
+
502
+ // GENERATED BY MITOSIS
503
+ /**
504
+ * We can't make this a generic `ProvideContext` function because Vue 2 won't support root slots, e.g.
505
+ *
506
+ * ```vue
507
+ * <template>
508
+ * <slot></slot>
509
+ * </template>
510
+ * ```
511
+ */ const RenderRepeatedBlock = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
512
+ useContextProvider(BuilderContext, useStore({
513
+ content: (()=>{
514
+ return props.repeatContext.content;
515
+ })(),
516
+ state: (()=>{
517
+ return props.repeatContext.state;
518
+ })(),
519
+ context: (()=>{
520
+ return props.repeatContext.context;
521
+ })(),
522
+ apiKey: (()=>{
523
+ return props.repeatContext.apiKey;
524
+ })(),
525
+ registeredComponents: (()=>{
526
+ return props.repeatContext.registeredComponents;
527
+ })(),
528
+ inheritedStyles: (()=>{
529
+ return props.repeatContext.inheritedStyles;
530
+ })()
531
+ }));
532
+ return /*#__PURE__*/ jsx(RenderBlock$1, {
533
+ get block () {
534
+ return props.block;
535
+ },
536
+ get context () {
537
+ return props.repeatContext;
538
+ },
539
+ [_IMMUTABLE]: {
540
+ block: _wrapSignal(props, "block"),
541
+ context: _wrapSignal(props, "repeatContext")
542
+ }
543
+ });
544
+ }, "RenderRepeatedBlock_component_nRyVBtbGKc8"));
545
+ const RenderRepeatedBlock$1 = RenderRepeatedBlock;
546
+
547
+ // GENERATED BY MITOSIS
548
+ const component = function component(props, state) {
549
+ const componentName = getProcessedBlock({
550
+ block: props.block,
551
+ state: props.context.state,
552
+ context: props.context.context,
553
+ shouldEvaluateBindings: false
554
+ }).component?.name;
555
+ if (!componentName) return null;
556
+ const ref = props.context.registeredComponents[componentName];
557
+ if (!ref) {
558
+ // TODO: Public doc page with more info about this message
559
+ console.warn(`
560
+ Could not find a registered component named "${componentName}".
561
+ If you registered it, is the file that registered it imported by the file that needs to render it?`);
562
+ return undefined;
563
+ } else return ref;
564
+ };
565
+ const tag = function tag(props, state) {
566
+ return getBlockTag(useBlock(props));
567
+ };
568
+ const useBlock = function useBlock(props, state) {
569
+ return repeatItemData(props) ? props.block : getProcessedBlock({
570
+ block: props.block,
571
+ state: props.context.state,
572
+ context: props.context.context,
573
+ shouldEvaluateBindings: true
574
+ });
575
+ };
576
+ const attributes = function attributes(props, state) {
577
+ return {
578
+ ...getBlockProperties(useBlock(props)),
579
+ ...getBlockActions({
580
+ block: useBlock(props),
581
+ state: props.context.state,
582
+ context: props.context.context
583
+ }),
584
+ ...{}
585
+ };
586
+ };
587
+ const shouldWrap = function shouldWrap(props, state) {
588
+ return !component(props)?.noWrap;
589
+ };
590
+ const renderComponentProps = function renderComponentProps(props, state) {
591
+ return {
592
+ blockChildren: useChildren(props),
593
+ componentRef: component(props)?.component,
594
+ componentOptions: {
595
+ ...getBlockComponentOptions(useBlock(props)),
596
+ /**
597
+ * These attributes are passed to the wrapper element when there is one. If `noWrap` is set to true, then
598
+ * they are provided to the component itself directly.
599
+ */ ...shouldWrap(props) ? {} : {
600
+ attributes: attributes(props)
601
+ }
602
+ },
603
+ context: childrenContext(props)
604
+ };
605
+ };
606
+ const useChildren = function useChildren(props, state) {
607
+ // TO-DO: When should `canHaveChildren` dictate rendering?
608
+ // This is currently commented out because some Builder components (e.g. Box) do not have `canHaveChildren: true`,
609
+ // but still receive and need to render children.
610
+ // return state.componentInfo?.canHaveChildren ? state.useBlock.children : [];
611
+ return useBlock(props).children ?? [];
612
+ };
613
+ const childrenWithoutParentComponent = function childrenWithoutParentComponent(props, state) {
614
+ /**
615
+ * When there is no `componentRef`, there might still be children that need to be rendered. In this case,
616
+ * we render them outside of `componentRef`.
617
+ * NOTE: We make sure not to render this if `repeatItemData` is non-null, because that means we are rendering an array of
618
+ * blocks, and the children will be repeated within those blocks.
619
+ */ const shouldRenderChildrenOutsideRef = !component(props)?.component && !repeatItemData(props);
620
+ return shouldRenderChildrenOutsideRef ? useChildren(props) : [];
621
+ };
622
+ const repeatItemData = function repeatItemData(props, state) {
623
+ /**
624
+ * we don't use `state.useBlock` here because the processing done within its logic includes evaluating the block's bindings,
625
+ * which will not work if there is a repeat.
626
+ */ const { repeat , ...blockWithoutRepeat } = props.block;
627
+ if (!repeat?.collection) return undefined;
628
+ const itemsArray = evaluate({
629
+ code: repeat.collection,
630
+ state: props.context.state,
631
+ context: props.context.context
632
+ });
633
+ if (!Array.isArray(itemsArray)) return undefined;
634
+ const collectionName = repeat.collection.split(".").pop();
635
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
636
+ const repeatArray = itemsArray.map((item, index)=>({
637
+ context: {
638
+ ...props.context,
639
+ state: {
640
+ ...props.context.state,
641
+ $index: index,
642
+ $item: item,
643
+ [itemNameToUse]: item,
644
+ [`$${itemNameToUse}Index`]: index
645
+ }
646
+ },
647
+ block: blockWithoutRepeat
648
+ }));
649
+ return repeatArray;
650
+ };
651
+ const inheritedTextStyles = function inheritedTextStyles(props, state) {
652
+ return {};
653
+ };
654
+ const childrenContext = function childrenContext(props, state) {
655
+ return {
656
+ apiKey: props.context.apiKey,
657
+ state: props.context.state,
658
+ content: props.context.content,
659
+ context: props.context.context,
660
+ registeredComponents: props.context.registeredComponents,
661
+ inheritedStyles: inheritedTextStyles()
662
+ };
663
+ };
664
+ const renderComponentTag = function renderComponentTag(props, state) {
665
+ if (TARGET === "reactNative") return RenderComponentWithContext$1;
666
+ else return RenderComponent$1;
667
+ };
668
+ const RenderBlock = (props)=>{
669
+ const state = {};
670
+ state.tag = tag(props);
671
+ state.renderComponentTag = renderComponentTag();
672
+ return /*#__PURE__*/ jsx(Fragment$1, {
673
+ children: shouldWrap(props) ? /*#__PURE__*/ jsxs(Fragment$1, {
674
+ children: [
675
+ isEmptyHtmlElement(tag(props)) ? /*#__PURE__*/ jsx(state.tag, {
676
+ ...attributes(props)
677
+ }) : null,
678
+ !isEmptyHtmlElement(tag(props)) && repeatItemData(props) ? (repeatItemData(props) || []).map(function(data, index) {
679
+ return /*#__PURE__*/ jsx(RenderRepeatedBlock$1, {
680
+ get repeatContext () {
681
+ return data.context;
682
+ },
683
+ get block () {
684
+ return data.block;
685
+ },
686
+ [_IMMUTABLE]: {
687
+ repeatContext: _wrapSignal(data, "context"),
688
+ block: _wrapSignal(data, "block")
689
+ }
690
+ }, index);
691
+ }) : null,
692
+ !isEmptyHtmlElement(tag(props)) && !repeatItemData(props) ? /*#__PURE__*/ jsxs(state.tag, {
693
+ ...attributes(props),
694
+ children: [
695
+ /*#__PURE__*/ jsx(state.renderComponentTag, {
696
+ ...renderComponentProps(props)
697
+ }),
698
+ (childrenWithoutParentComponent(props) || []).map(function(child) {
699
+ return /*#__PURE__*/ jsx(RenderBlock, {
700
+ block: child,
701
+ context: childrenContext(props)
702
+ }, "render-block-" + child.id);
703
+ }),
704
+ (childrenWithoutParentComponent(props) || []).map(function(child) {
705
+ return /*#__PURE__*/ jsx(BlockStyles$1, {
706
+ block: child,
707
+ context: childrenContext(props)
708
+ }, "block-style-" + child.id);
709
+ })
710
+ ]
711
+ }) : null
712
+ ]
713
+ }) : /*#__PURE__*/ jsx(state.renderComponentTag, {
714
+ ...renderComponentProps(props)
715
+ })
716
+ });
717
+ };
718
+ const RenderBlock$1 = RenderBlock;
719
+
720
+ // GENERATED BY MITOSIS
721
+ const className = function className(props, state, builderContext) {
722
+ return "builder-blocks" + (!props.blocks?.length ? " no-blocks" : "");
723
+ };
724
+ const onClick$1 = function onClick(props, state, builderContext) {
725
+ if (isEditing() && !props.blocks?.length) window.parent?.postMessage({
726
+ type: "builder.clickEmptyBlocks",
727
+ data: {
728
+ parentElementId: props.parent,
729
+ dataPath: props.path
730
+ }
731
+ }, "*");
732
+ };
733
+ const onMouseEnter = function onMouseEnter(props, state, builderContext) {
734
+ if (isEditing() && !props.blocks?.length) window.parent?.postMessage({
735
+ type: "builder.hoverEmptyBlocks",
736
+ data: {
737
+ parentElementId: props.parent,
738
+ dataPath: props.path
739
+ }
740
+ }, "*");
741
+ };
742
+ const RenderBlocks = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
743
+ useStylesScopedQrl(inlinedQrl(STYLES$3, "RenderBlocks_component_useStylesScoped_0XKYzaR059E"));
744
+ const builderContext = useContext(BuilderContext);
745
+ const state = {};
746
+ return /*#__PURE__*/ jsxs("div", {
747
+ class: className(props) + " div-RenderBlocks",
748
+ get "builder-path" () {
749
+ return props.path;
750
+ },
751
+ get "builder-parent-id" () {
752
+ return props.parent;
753
+ },
754
+ get style () {
755
+ return props.styleProp;
756
+ },
757
+ onClick$: inlinedQrl((event)=>{
758
+ const [builderContext, props, state] = useLexicalScope();
759
+ return onClick$1(props);
760
+ }, "RenderBlocks_component_div_onClick_RzhhZa265Yg", [
761
+ builderContext,
762
+ props,
763
+ state
764
+ ]),
765
+ onMouseEnter$: inlinedQrl((event)=>{
766
+ const [builderContext, props, state] = useLexicalScope();
767
+ return onMouseEnter(props);
768
+ }, "RenderBlocks_component_div_onMouseEnter_nG7I7RYG3JQ", [
769
+ builderContext,
770
+ props,
771
+ state
772
+ ]),
773
+ children: [
774
+ props.blocks ? (props.blocks || []).map(function(block) {
775
+ return /*#__PURE__*/ jsx(RenderBlock$1, {
776
+ block: block,
777
+ context: builderContext
778
+ }, "render-block-" + block.id);
779
+ }) : null,
780
+ props.blocks ? (props.blocks || []).map(function(block) {
781
+ return /*#__PURE__*/ jsx(BlockStyles$1, {
782
+ block: block,
783
+ context: builderContext
784
+ }, "block-style-" + block.id);
785
+ }) : null
786
+ ],
787
+ [_IMMUTABLE]: {
788
+ "builder-path": _wrapSignal(props, "path"),
789
+ "builder-parent-id": _wrapSignal(props, "parent"),
790
+ style: _wrapSignal(props, "styleProp")
791
+ }
792
+ });
793
+ }, "RenderBlocks_component_MYUZ0j1uLsw"));
794
+ const RenderBlocks$1 = RenderBlocks;
795
+ const STYLES$3 = `.div-RenderBlocks {
796
+ display: flex;
797
+ flex-direction: column;
798
+ align-items: stretch; }`;
799
+
800
+ // GENERATED BY MITOSIS
801
+ const getGutterSize = function getGutterSize(props, state) {
802
+ return typeof props.space === "number" ? props.space || 0 : 20;
803
+ };
804
+ const getColumns = function getColumns(props, state) {
805
+ return props.columns || [];
806
+ };
807
+ const getWidth = function getWidth(props, state, index) {
808
+ const columns = getColumns(props);
809
+ return columns[index]?.width || 100 / columns.length;
810
+ };
811
+ const getColumnCssWidth = function getColumnCssWidth(props, state, index) {
812
+ const columns = getColumns(props);
813
+ const gutterSize = getGutterSize(props);
814
+ const subtractWidth = gutterSize * (columns.length - 1) / columns.length;
815
+ return `calc(${getWidth(props, state, index)}% - ${subtractWidth}px)`;
816
+ };
817
+ const maybeApplyForTablet = function maybeApplyForTablet(props, state, prop) {
818
+ const _stackColumnsAt = props.stackColumnsAt || "tablet";
819
+ return _stackColumnsAt === "tablet" ? prop : "inherit";
820
+ };
821
+ const columnsCssVars = function columnsCssVars(props, state) {
822
+ const flexDir = props.stackColumnsAt === "never" ? "inherit" : props.reverseColumnsWhenStacked ? "column-reverse" : "column";
823
+ return {
824
+ "--flex-dir": flexDir,
825
+ "--flex-dir-tablet": maybeApplyForTablet(props, state, flexDir)
826
+ };
827
+ };
828
+ const columnCssVars = function columnCssVars(props, state) {
829
+ const width = "100%";
830
+ const marginLeft = "0";
831
+ return {
832
+ "--column-width": width,
833
+ "--column-margin-left": marginLeft,
834
+ "--column-width-tablet": maybeApplyForTablet(props, state, width),
835
+ "--column-margin-left-tablet": maybeApplyForTablet(props, state, marginLeft)
836
+ };
837
+ };
838
+ const Columns = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
839
+ useStylesScopedQrl(inlinedQrl(STYLES$2, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
840
+ const state = {};
841
+ return /*#__PURE__*/ jsx("div", {
842
+ class: "builder-columns div-Columns",
843
+ style: columnsCssVars(props, state),
844
+ children: (props.columns || []).map(function(column, index) {
845
+ return /*#__PURE__*/ jsx("div", {
846
+ class: "builder-column div-Columns-2",
847
+ style: {
848
+ width: getColumnCssWidth(props, state, index),
849
+ marginLeft: `${index === 0 ? 0 : getGutterSize(props)}px`,
850
+ ...columnCssVars(props, state)
851
+ },
852
+ children: /*#__PURE__*/ jsx(RenderBlocks$1, {
853
+ get blocks () {
854
+ return column.blocks;
855
+ },
856
+ path: `component.options.columns.${index}.blocks`,
857
+ get parent () {
858
+ return props.builderBlock.id;
859
+ },
860
+ styleProp: {
861
+ flexGrow: "1"
862
+ },
863
+ [_IMMUTABLE]: {
864
+ blocks: _wrapSignal(column, "blocks"),
865
+ parent: _wrapSignal(props.builderBlock, "id")
866
+ }
867
+ })
868
+ }, index);
869
+ })
870
+ });
871
+ }, "Columns_component_7yLj4bxdI6c"));
872
+ const Columns$1 = Columns;
873
+ const STYLES$2 = `.div-Columns {
874
+ display: flex;
875
+ align-items: stretch;
876
+ line-height: normal; }@media (max-width: 991px) { .div-Columns {
877
+ flex-direction: var(--flex-dir-tablet); } }@media (max-width: 639px) { .div-Columns {
878
+ flex-direction: var(--flex-dir); } }.div-Columns-2 {
879
+ display: flex;
880
+ flex-direction: column;
881
+ align-items: stretch; }@media (max-width: 991px) { .div-Columns-2 {
882
+ width: var(--column-width-tablet) !important;
883
+ margin-left: var(--column-margin-left-tablet) !important; } }@media (max-width: 639px) { .div-Columns-2 {
884
+ width: var(--column-width) !important;
885
+ margin-left: var(--column-margin-left) !important; } }`;
886
+
887
+ // Taken from (and modified) the shopify theme script repo
888
+ // https://github.com/Shopify/theme-scripts/blob/bcfb471f2a57d439e2f964a1bb65b67708cc90c3/packages/theme-images/images.js#L59
889
+ function removeProtocol(path) {
890
+ return path.replace(/http(s)?:/, '');
891
+ }
892
+ function updateQueryParam(uri = '', key, value) {
893
+ const re = new RegExp('([?&])' + key + '=.*?(&|$)', 'i');
894
+ const separator = uri.indexOf('?') !== -1 ? '&' : '?';
895
+ if (uri.match(re)) return uri.replace(re, '$1' + key + '=' + encodeURIComponent(value) + '$2');
896
+ return uri + separator + key + '=' + encodeURIComponent(value);
897
+ }
898
+ function getShopifyImageUrl(src, size) {
899
+ if (!src || !src?.match(/cdn\.shopify\.com/) || !size) return src;
900
+ if (size === 'master') return removeProtocol(src);
901
+ const match = src.match(/(_\d+x(\d+)?)?(\.(jpg|jpeg|gif|png|bmp|bitmap|tiff|tif)(\?v=\d+)?)/i);
902
+ if (match) {
903
+ const prefix = src.split(match[0]);
904
+ const suffix = match[3];
905
+ const useSize = size.match('x') ? size : `${size}x`;
906
+ return removeProtocol(`${prefix[0]}_${useSize}${suffix}`);
907
+ }
908
+ return null;
909
+ }
910
+ function getSrcSet(url) {
911
+ if (!url) return url;
912
+ const sizes = [
913
+ 100,
914
+ 200,
915
+ 400,
916
+ 800,
917
+ 1200,
918
+ 1600,
919
+ 2000
920
+ ];
921
+ if (url.match(/builder\.io/)) {
922
+ let srcUrl = url;
923
+ const widthInSrc = Number(url.split('?width=')[1]);
924
+ if (!isNaN(widthInSrc)) srcUrl = `${srcUrl} ${widthInSrc}w`;
925
+ return sizes.filter((size)=>size !== widthInSrc).map((size)=>`${updateQueryParam(url, 'width', size)} ${size}w`).concat([
926
+ srcUrl
927
+ ]).join(', ');
928
+ }
929
+ if (url.match(/cdn\.shopify\.com/)) return sizes.map((size)=>[
930
+ getShopifyImageUrl(url, `${size}x${size}`),
931
+ size
932
+ ]).filter(([sizeUrl])=>!!sizeUrl).map(([sizeUrl, size])=>`${sizeUrl} ${size}w`).concat([
933
+ url
934
+ ]).join(', ');
935
+ return url;
936
+ }
937
+
938
+ // GENERATED BY MITOSIS
939
+ const srcSetToUse = function srcSetToUse(props, state) {
940
+ const imageToUse = props.image || props.src;
941
+ const url = imageToUse;
942
+ if (!url || // We can auto add srcset for cdn.builder.io and shopify
943
+ // images, otherwise you can supply this prop manually
944
+ !(url.match(/builder\.io/) || url.match(/cdn\.shopify\.com/))) return props.srcset;
945
+ if (props.srcset && props.image?.includes("builder.io/api/v1/image")) {
946
+ if (!props.srcset.includes(props.image.split("?")[0])) {
947
+ console.debug("Removed given srcset");
948
+ return getSrcSet(url);
949
+ }
950
+ } else if (props.image && !props.srcset) return getSrcSet(url);
951
+ return getSrcSet(url);
952
+ };
953
+ const webpSrcSet = function webpSrcSet(props, state) {
954
+ if (srcSetToUse(props)?.match(/builder\.io/) && !props.noWebp) return srcSetToUse(props).replace(/\?/g, "?format=webp&");
955
+ else return "";
956
+ };
957
+ const Image = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
958
+ useStylesScopedQrl(inlinedQrl(STYLES$1, "Image_component_useStylesScoped_fBMYiVf9fuU"));
959
+ return /*#__PURE__*/ jsxs(Fragment$2, {
960
+ children: [
961
+ /*#__PURE__*/ jsxs("picture", {
962
+ children: [
963
+ webpSrcSet(props) ? /*#__PURE__*/ jsx("source", {
964
+ type: "image/webp",
965
+ srcSet: webpSrcSet(props)
966
+ }) : null,
967
+ /*#__PURE__*/ jsx("img", {
968
+ loading: "lazy",
969
+ get alt () {
970
+ return props.altText;
971
+ },
972
+ role: props.altText ? "presentation" : undefined,
973
+ style: {
974
+ objectPosition: props.backgroundSize || "center",
975
+ objectFit: props.backgroundSize || "cover"
976
+ },
977
+ class: "builder-image" + (props.className ? " " + props.className : "") + " img-Image",
978
+ get src () {
979
+ return props.image;
980
+ },
981
+ srcSet: srcSetToUse(props),
982
+ get sizes () {
983
+ return props.sizes;
984
+ },
985
+ [_IMMUTABLE]: {
986
+ alt: _wrapSignal(props, "altText"),
987
+ src: _wrapSignal(props, "image"),
988
+ sizes: _wrapSignal(props, "sizes")
989
+ }
990
+ }),
991
+ /*#__PURE__*/ jsx("source", {
992
+ srcSet: srcSetToUse(props)
993
+ })
994
+ ]
995
+ }),
996
+ props.aspectRatio && !(props.builderBlock?.children?.length && props.fitContent) ? /*#__PURE__*/ jsx("div", {
997
+ class: "builder-image-sizer div-Image",
998
+ style: {
999
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
1000
+ paddingTop: props.aspectRatio * 100 + "%"
1001
+ }
1002
+ }) : null,
1003
+ props.builderBlock?.children?.length && props.fitContent ? /*#__PURE__*/ jsx(Slot, {}) : null,
1004
+ !props.fitContent && props.children ? /*#__PURE__*/ jsx("div", {
1005
+ class: "div-Image-2",
1006
+ children: /*#__PURE__*/ jsx(Slot, {})
1007
+ }) : null
1008
+ ]
1009
+ });
1010
+ }, "Image_component_LRxDkFa1EfU"));
1011
+ const Image$1 = Image;
1012
+ const STYLES$1 = `.img-Image {
1013
+ opacity: 1;
1014
+ transition: opacity 0.2s ease-in-out;
1015
+ position: absolute;
1016
+ height: 100%;
1017
+ width: 100%;
1018
+ top: 0px;
1019
+ left: 0px; }.div-Image {
1020
+ width: 100%;
1021
+ pointer-events: none;
1022
+ font-size: 0; }.div-Image-2 {
1023
+ display: flex;
1024
+ flex-direction: column;
1025
+ align-items: stretch;
1026
+ position: absolute;
1027
+ top: 0;
1028
+ left: 0;
1029
+ width: 100%;
1030
+ height: 100%; }`;
1031
+
1032
+ // GENERATED BY MITOSIS
1033
+ const Text = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1034
+ return /*#__PURE__*/ jsx("span", {
1035
+ class: "builder-text",
1036
+ get dangerouslySetInnerHTML () {
1037
+ return props.text;
1038
+ },
1039
+ [_IMMUTABLE]: {
1040
+ dangerouslySetInnerHTML: _wrapSignal(props, "text")
1041
+ }
1042
+ });
1043
+ }, "Text_component_15p0cKUxgIE"));
1044
+ const Text$1 = Text;
1045
+
1046
+ // GENERATED BY MITOSIS
1047
+ const videoProps = function videoProps(props, state) {
1048
+ return {
1049
+ ...props.autoPlay === true ? {
1050
+ autoPlay: true
1051
+ } : {},
1052
+ ...props.muted === true ? {
1053
+ muted: true
1054
+ } : {},
1055
+ ...props.controls === true ? {
1056
+ controls: true
1057
+ } : {},
1058
+ ...props.loop === true ? {
1059
+ loop: true
1060
+ } : {},
1061
+ ...props.playsInline === true ? {
1062
+ playsInline: true
1063
+ } : {}
1064
+ };
1065
+ };
1066
+ const spreadProps = function spreadProps(props, state) {
1067
+ return {
1068
+ ...props.attributes,
1069
+ ...videoProps(props)
1070
+ };
1071
+ };
1072
+ const Video = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1073
+ return /*#__PURE__*/ jsx("video", {
1074
+ ...spreadProps(props),
1075
+ style: {
1076
+ width: "100%",
1077
+ height: "100%",
1078
+ ...props.attributes?.style,
1079
+ objectFit: props.fit,
1080
+ objectPosition: props.position,
1081
+ // Hack to get object fit to work as expected and
1082
+ // not have the video overflow
1083
+ borderRadius: 1
1084
+ },
1085
+ src: props.video || "no-src",
1086
+ get poster () {
1087
+ return props.posterImage;
1088
+ },
1089
+ [_IMMUTABLE]: {
1090
+ poster: _wrapSignal(props, "posterImage")
1091
+ }
1092
+ });
1093
+ }, "Video_component_qdcTZflYyoQ"));
1094
+ const Video$1 = Video;
1095
+
1096
+ // GENERATED BY MITOSIS
1097
+ const Button = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1098
+ useStylesScopedQrl(inlinedQrl(STYLES, "Button_component_useStylesScoped_a1JZ0Q0Q2Oc"));
1099
+ return /*#__PURE__*/ jsx(Fragment$1, {
1100
+ children: props.link ? /*#__PURE__*/ jsx("a", {
1101
+ role: "button",
1102
+ ...props.attributes,
1103
+ get href () {
1104
+ return props.link;
1105
+ },
1106
+ target: props.openLinkInNewTab ? "_blank" : undefined,
1107
+ children: _wrapSignal(props, "text"),
1108
+ [_IMMUTABLE]: {
1109
+ href: _wrapSignal(props, "link")
1110
+ }
1111
+ }) : /*#__PURE__*/ jsx("button", {
1112
+ class: "button-Button",
1113
+ ...props.attributes,
1114
+ children: _wrapSignal(props, "text")
1115
+ })
1116
+ });
1117
+ }, "Button_component_gJoMUICXoUQ"));
1118
+ const Button$1 = Button;
1119
+ const STYLES = `.button-Button {
1120
+ all: unset; }`;
1121
+
1122
+ const componentInfo$a = {
1123
+ name: 'Core:Button',
1124
+ builtIn: true,
1125
+ image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13',
1126
+ defaultStyles: {
1127
+ // TODO: make min width more intuitive and set one
1128
+ appearance: 'none',
1129
+ paddingTop: '15px',
1130
+ paddingBottom: '15px',
1131
+ paddingLeft: '25px',
1132
+ paddingRight: '25px',
1133
+ backgroundColor: '#000000',
1134
+ color: 'white',
1135
+ borderRadius: '4px',
1136
+ textAlign: 'center',
1137
+ cursor: 'pointer'
1138
+ },
1139
+ inputs: [
1140
+ {
1141
+ name: 'text',
1142
+ type: 'text',
1143
+ defaultValue: 'Click me!',
1144
+ bubble: true
1145
+ },
1146
+ {
1147
+ name: 'link',
1148
+ type: 'url',
1149
+ bubble: true
1150
+ },
1151
+ {
1152
+ name: 'openLinkInNewTab',
1153
+ type: 'boolean',
1154
+ defaultValue: false,
1155
+ friendlyName: 'Open link in new tab'
1156
+ }
1157
+ ],
1158
+ static: true,
1159
+ noWrap: true
1160
+ };
1161
+
1162
+ /**
1163
+ * Input attributes that are functions must be converted to strings before being serialized to JSON.
1164
+ */ // eslint-disable-next-line @typescript-eslint/ban-types
1165
+ const serializeFn = (fnValue)=>{
1166
+ const fnStr = fnValue.toString().trim();
1167
+ // we need to account for a few different fn syntaxes:
1168
+ // 1. `function name(args) => {code}`
1169
+ // 2. `name(args) => {code}`
1170
+ // 3. `(args) => {}`
1171
+ const appendFunction = !fnStr.startsWith('function') && !fnStr.startsWith('(');
1172
+ return `return (${appendFunction ? 'function ' : ''}${fnStr}).apply(this, arguments)`;
1173
+ };
1174
+
1175
+ const componentInfo$9 = {
1176
+ // TODO: ways to statically preprocess JSON for references, functions, etc
1177
+ name: 'Columns',
1178
+ builtIn: true,
1179
+ inputs: [
1180
+ {
1181
+ name: 'columns',
1182
+ type: 'array',
1183
+ broadcast: true,
1184
+ subFields: [
1185
+ {
1186
+ name: 'blocks',
1187
+ type: 'array',
1188
+ hideFromUI: true,
1189
+ defaultValue: [
1190
+ {
1191
+ '@type': '@builder.io/sdk:Element',
1192
+ responsiveStyles: {
1193
+ large: {
1194
+ display: 'flex',
1195
+ flexDirection: 'column',
1196
+ alignItems: 'stretch',
1197
+ flexShrink: '0',
1198
+ position: 'relative',
1199
+ marginTop: '30px',
1200
+ textAlign: 'center',
1201
+ lineHeight: 'normal',
1202
+ height: 'auto',
1203
+ minHeight: '20px',
1204
+ minWidth: '20px',
1205
+ overflow: 'hidden'
1206
+ }
1207
+ },
1208
+ component: {
1209
+ name: 'Image',
1210
+ options: {
1211
+ image: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
1212
+ backgroundPosition: 'center',
1213
+ backgroundSize: 'cover',
1214
+ aspectRatio: 0.7004048582995948
1215
+ }
1216
+ }
1217
+ },
1218
+ {
1219
+ '@type': '@builder.io/sdk:Element',
1220
+ responsiveStyles: {
1221
+ large: {
1222
+ display: 'flex',
1223
+ flexDirection: 'column',
1224
+ alignItems: 'stretch',
1225
+ flexShrink: '0',
1226
+ position: 'relative',
1227
+ marginTop: '30px',
1228
+ textAlign: 'center',
1229
+ lineHeight: 'normal',
1230
+ height: 'auto'
1231
+ }
1232
+ },
1233
+ component: {
1234
+ name: 'Text',
1235
+ options: {
1236
+ text: '<p>Enter some text...</p>'
1237
+ }
1238
+ }
1239
+ }
1240
+ ]
1241
+ },
1242
+ {
1243
+ name: 'width',
1244
+ type: 'number',
1245
+ hideFromUI: true,
1246
+ helperText: 'Width %, e.g. set to 50 to fill half of the space'
1247
+ },
1248
+ {
1249
+ name: 'link',
1250
+ type: 'url',
1251
+ helperText: 'Optionally set a url that clicking this column will link to'
1252
+ }
1253
+ ],
1254
+ defaultValue: [
1255
+ {
1256
+ blocks: [
1257
+ {
1258
+ '@type': '@builder.io/sdk:Element',
1259
+ responsiveStyles: {
1260
+ large: {
1261
+ display: 'flex',
1262
+ flexDirection: 'column',
1263
+ alignItems: 'stretch',
1264
+ flexShrink: '0',
1265
+ position: 'relative',
1266
+ marginTop: '30px',
1267
+ textAlign: 'center',
1268
+ lineHeight: 'normal',
1269
+ height: 'auto',
1270
+ minHeight: '20px',
1271
+ minWidth: '20px',
1272
+ overflow: 'hidden'
1273
+ }
1274
+ },
1275
+ component: {
1276
+ name: 'Image',
1277
+ options: {
1278
+ image: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
1279
+ backgroundPosition: 'center',
1280
+ backgroundSize: 'cover',
1281
+ aspectRatio: 0.7004048582995948
1282
+ }
1283
+ }
1284
+ },
1285
+ {
1286
+ '@type': '@builder.io/sdk:Element',
1287
+ responsiveStyles: {
1288
+ large: {
1289
+ display: 'flex',
1290
+ flexDirection: 'column',
1291
+ alignItems: 'stretch',
1292
+ flexShrink: '0',
1293
+ position: 'relative',
1294
+ marginTop: '30px',
1295
+ textAlign: 'center',
1296
+ lineHeight: 'normal',
1297
+ height: 'auto'
1298
+ }
1299
+ },
1300
+ component: {
1301
+ name: 'Text',
1302
+ options: {
1303
+ text: '<p>Enter some text...</p>'
1304
+ }
1305
+ }
1306
+ }
1307
+ ]
1308
+ },
1309
+ {
1310
+ blocks: [
1311
+ {
1312
+ '@type': '@builder.io/sdk:Element',
1313
+ responsiveStyles: {
1314
+ large: {
1315
+ display: 'flex',
1316
+ flexDirection: 'column',
1317
+ alignItems: 'stretch',
1318
+ flexShrink: '0',
1319
+ position: 'relative',
1320
+ marginTop: '30px',
1321
+ textAlign: 'center',
1322
+ lineHeight: 'normal',
1323
+ height: 'auto',
1324
+ minHeight: '20px',
1325
+ minWidth: '20px',
1326
+ overflow: 'hidden'
1327
+ }
1328
+ },
1329
+ component: {
1330
+ name: 'Image',
1331
+ options: {
1332
+ image: 'https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
1333
+ backgroundPosition: 'center',
1334
+ backgroundSize: 'cover',
1335
+ aspectRatio: 0.7004048582995948
1336
+ }
1337
+ }
1338
+ },
1339
+ {
1340
+ '@type': '@builder.io/sdk:Element',
1341
+ responsiveStyles: {
1342
+ large: {
1343
+ display: 'flex',
1344
+ flexDirection: 'column',
1345
+ alignItems: 'stretch',
1346
+ flexShrink: '0',
1347
+ position: 'relative',
1348
+ marginTop: '30px',
1349
+ textAlign: 'center',
1350
+ lineHeight: 'normal',
1351
+ height: 'auto'
1352
+ }
1353
+ },
1354
+ component: {
1355
+ name: 'Text',
1356
+ options: {
1357
+ text: '<p>Enter some text...</p>'
1358
+ }
1359
+ }
1360
+ }
1361
+ ]
1362
+ }
1363
+ ],
1364
+ onChange: serializeFn((options)=>{
1365
+ function clearWidths() {
1366
+ columns.forEach((col)=>{
1367
+ col.delete('width');
1368
+ });
1369
+ }
1370
+ const columns = options.get('columns');
1371
+ if (Array.isArray(columns)) {
1372
+ const containsColumnWithWidth = !!columns.find((col)=>col.get('width'));
1373
+ if (containsColumnWithWidth) {
1374
+ const containsColumnWithoutWidth = !!columns.find((col)=>!col.get('width'));
1375
+ if (containsColumnWithoutWidth) clearWidths();
1376
+ else {
1377
+ const sumWidths = columns.reduce((memo, col)=>{
1378
+ return memo + col.get('width');
1379
+ }, 0);
1380
+ const widthsDontAddUp = sumWidths !== 100;
1381
+ if (widthsDontAddUp) clearWidths();
1382
+ }
1383
+ }
1384
+ }
1385
+ })
1386
+ },
1387
+ {
1388
+ name: 'space',
1389
+ type: 'number',
1390
+ defaultValue: 20,
1391
+ helperText: 'Size of gap between columns',
1392
+ advanced: true
1393
+ },
1394
+ {
1395
+ name: 'stackColumnsAt',
1396
+ type: 'string',
1397
+ defaultValue: 'tablet',
1398
+ helperText: 'Convert horizontal columns to vertical at what device size',
1399
+ enum: [
1400
+ 'tablet',
1401
+ 'mobile',
1402
+ 'never'
1403
+ ],
1404
+ advanced: true
1405
+ },
1406
+ {
1407
+ name: 'reverseColumnsWhenStacked',
1408
+ type: 'boolean',
1409
+ defaultValue: false,
1410
+ helperText: 'When stacking columns for mobile devices, reverse the ordering',
1411
+ advanced: true
1412
+ }
1413
+ ]
1414
+ };
1415
+
1416
+ const componentInfo$8 = {
1417
+ name: 'Fragment',
1418
+ static: true,
1419
+ hidden: true,
1420
+ builtIn: true,
1421
+ canHaveChildren: true,
1422
+ noWrap: true
1423
+ };
1424
+
1425
+ // GENERATED BY MITOSIS
1426
+ const FragmentComponent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1427
+ return /*#__PURE__*/ jsx("span", {
1428
+ children: /*#__PURE__*/ jsx(Slot, {})
1429
+ });
1430
+ }, "FragmentComponent_component_T0AypnadAK0"));
1431
+ const Fragment = FragmentComponent;
1432
+
1433
+ const componentInfo$7 = {
1434
+ name: 'Image',
1435
+ static: true,
1436
+ builtIn: true,
1437
+ 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',
1438
+ defaultStyles: {
1439
+ position: 'relative',
1440
+ minHeight: '20px',
1441
+ minWidth: '20px',
1442
+ overflow: 'hidden'
1443
+ },
1444
+ canHaveChildren: true,
1445
+ inputs: [
1446
+ {
1447
+ name: 'image',
1448
+ type: 'file',
1449
+ bubble: true,
1450
+ allowedFileTypes: [
1451
+ 'jpeg',
1452
+ 'jpg',
1453
+ 'png',
1454
+ 'svg'
1455
+ ],
1456
+ required: true,
1457
+ defaultValue: 'https://cdn.builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d',
1458
+ onChange: serializeFn((options)=>{
1459
+ const DEFAULT_ASPECT_RATIO = 0.7041;
1460
+ options.delete('srcset');
1461
+ options.delete('noWebp');
1462
+ function loadImage(url, timeout = 60000) {
1463
+ return new Promise((resolve, reject)=>{
1464
+ const img = document.createElement('img');
1465
+ let loaded = false;
1466
+ img.onload = ()=>{
1467
+ loaded = true;
1468
+ resolve(img);
1469
+ };
1470
+ img.addEventListener('error', (event)=>{
1471
+ console.warn('Image load failed', event.error);
1472
+ reject(event.error);
1473
+ });
1474
+ img.src = url;
1475
+ setTimeout(()=>{
1476
+ if (!loaded) reject(new Error('Image load timed out'));
1477
+ }, timeout);
1478
+ });
1479
+ }
1480
+ function round(num) {
1481
+ return Math.round(num * 1000) / 1000;
1482
+ }
1483
+ const value = options.get('image');
1484
+ const aspectRatio = options.get('aspectRatio');
1485
+ // For SVG images - don't render as webp, keep them as SVG
1486
+ fetch(value).then((res)=>res.blob()).then((blob)=>{
1487
+ if (blob.type.includes('svg')) options.set('noWebp', true);
1488
+ });
1489
+ if (value && (!aspectRatio || aspectRatio === DEFAULT_ASPECT_RATIO)) return loadImage(value).then((img)=>{
1490
+ const possiblyUpdatedAspectRatio = options.get('aspectRatio');
1491
+ if (options.get('image') === value && (!possiblyUpdatedAspectRatio || possiblyUpdatedAspectRatio === DEFAULT_ASPECT_RATIO)) {
1492
+ if (img.width && img.height) {
1493
+ options.set('aspectRatio', round(img.height / img.width));
1494
+ options.set('height', img.height);
1495
+ options.set('width', img.width);
1496
+ }
1497
+ }
1498
+ });
1499
+ })
1500
+ },
1501
+ {
1502
+ name: 'backgroundSize',
1503
+ type: 'text',
1504
+ defaultValue: 'cover',
1505
+ enum: [
1506
+ {
1507
+ label: 'contain',
1508
+ value: 'contain',
1509
+ helperText: 'The image should never get cropped'
1510
+ },
1511
+ {
1512
+ label: 'cover',
1513
+ value: 'cover',
1514
+ helperText: "The image should fill it's box, cropping when needed"
1515
+ }
1516
+ ]
1517
+ },
1518
+ {
1519
+ name: 'backgroundPosition',
1520
+ type: 'text',
1521
+ defaultValue: 'center',
1522
+ enum: [
1523
+ 'center',
1524
+ 'top',
1525
+ 'left',
1526
+ 'right',
1527
+ 'bottom',
1528
+ 'top left',
1529
+ 'top right',
1530
+ 'bottom left',
1531
+ 'bottom right'
1532
+ ]
1533
+ },
1534
+ {
1535
+ name: 'altText',
1536
+ type: 'string',
1537
+ helperText: 'Text to display when the user has images off'
1538
+ },
1539
+ {
1540
+ name: 'height',
1541
+ type: 'number',
1542
+ hideFromUI: true
1543
+ },
1544
+ {
1545
+ name: 'width',
1546
+ type: 'number',
1547
+ hideFromUI: true
1548
+ },
1549
+ {
1550
+ name: 'sizes',
1551
+ type: 'string',
1552
+ hideFromUI: true
1553
+ },
1554
+ {
1555
+ name: 'srcset',
1556
+ type: 'string',
1557
+ hideFromUI: true
1558
+ },
1559
+ {
1560
+ name: 'lazy',
1561
+ type: 'boolean',
1562
+ defaultValue: true,
1563
+ hideFromUI: true
1564
+ },
1565
+ {
1566
+ name: 'fitContent',
1567
+ type: 'boolean',
1568
+ helperText: "When child blocks are provided, fit to them instead of using the image's aspect ratio",
1569
+ defaultValue: true
1570
+ },
1571
+ {
1572
+ name: 'aspectRatio',
1573
+ type: 'number',
1574
+ 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",
1575
+ advanced: true,
1576
+ defaultValue: 0.7041
1577
+ }
1578
+ ]
1579
+ };
1580
+
1581
+ const componentInfo$6 = {
1582
+ name: 'Core:Section',
1583
+ static: true,
1584
+ builtIn: true,
1585
+ image: 'https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a',
1586
+ inputs: [
1587
+ {
1588
+ name: 'maxWidth',
1589
+ type: 'number',
1590
+ defaultValue: 1200
1591
+ },
1592
+ {
1593
+ name: 'lazyLoad',
1594
+ type: 'boolean',
1595
+ defaultValue: false,
1596
+ advanced: true,
1597
+ description: 'Only render this section when in view'
1598
+ }
1599
+ ],
1600
+ defaultStyles: {
1601
+ paddingLeft: '20px',
1602
+ paddingRight: '20px',
1603
+ paddingTop: '50px',
1604
+ paddingBottom: '50px',
1605
+ marginTop: '0px',
1606
+ width: '100vw',
1607
+ marginLeft: 'calc(50% - 50vw)'
1608
+ },
1609
+ canHaveChildren: true,
1610
+ defaultChildren: [
1611
+ {
1612
+ '@type': '@builder.io/sdk:Element',
1613
+ responsiveStyles: {
1614
+ large: {
1615
+ textAlign: 'center'
1616
+ }
1617
+ },
1618
+ component: {
1619
+ name: 'Text',
1620
+ options: {
1621
+ 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>"
1622
+ }
1623
+ }
1624
+ }
1625
+ ]
1626
+ };
1627
+
1628
+ // GENERATED BY MITOSIS
1629
+ const SectionComponent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1630
+ return /*#__PURE__*/ jsx("section", {
1631
+ ...props.attributes,
1632
+ style: (()=>{
1633
+ props.maxWidth && typeof props.maxWidth === "number" ? props.maxWidth : undefined;
1634
+ })(),
1635
+ children: /*#__PURE__*/ jsx(Slot, {})
1636
+ });
1637
+ }, "SectionComponent_component_ZWF9iD5WeLg"));
1638
+ const Section = SectionComponent;
1639
+
1640
+ const componentInfo$5 = {
1641
+ name: 'Symbol',
1642
+ noWrap: true,
1643
+ static: true,
1644
+ builtIn: true,
1645
+ inputs: [
1646
+ {
1647
+ name: 'symbol',
1648
+ type: 'uiSymbol'
1649
+ },
1650
+ {
1651
+ name: 'dataOnly',
1652
+ helperText: "Make this a data symbol that doesn't display any UI",
1653
+ type: 'boolean',
1654
+ defaultValue: false,
1655
+ advanced: true,
1656
+ hideFromUI: true
1657
+ },
1658
+ {
1659
+ name: 'inheritState',
1660
+ helperText: 'Inherit the parent component state and data',
1661
+ type: 'boolean',
1662
+ defaultValue: false,
1663
+ advanced: true
1664
+ },
1665
+ {
1666
+ name: 'renderToLiquid',
1667
+ helperText: 'Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting',
1668
+ type: 'boolean',
1669
+ defaultValue: false,
1670
+ advanced: true,
1671
+ hideFromUI: true
1672
+ },
1673
+ {
1674
+ name: 'useChildren',
1675
+ hideFromUI: true,
1676
+ type: 'boolean'
1677
+ }
1678
+ ]
1679
+ };
1680
+
1681
+ const componentInfo$4 = {
1682
+ name: 'Text',
1683
+ static: true,
1684
+ builtIn: true,
1685
+ 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',
1686
+ inputs: [
1687
+ {
1688
+ name: 'text',
1689
+ type: 'html',
1690
+ required: true,
1691
+ autoFocus: true,
1692
+ bubble: true,
1693
+ defaultValue: 'Enter some text...'
1694
+ }
1695
+ ],
1696
+ defaultStyles: {
1697
+ lineHeight: 'normal',
1698
+ height: 'auto',
1699
+ textAlign: 'center'
1700
+ }
1701
+ };
1702
+
1703
+ const componentInfo$3 = {
1704
+ name: 'Video',
1705
+ canHaveChildren: true,
1706
+ builtIn: true,
1707
+ defaultStyles: {
1708
+ minHeight: '20px',
1709
+ minWidth: '20px'
1710
+ },
1711
+ 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',
1712
+ inputs: [
1713
+ {
1714
+ name: 'video',
1715
+ type: 'file',
1716
+ allowedFileTypes: [
1717
+ 'mp4'
1718
+ ],
1719
+ bubble: true,
1720
+ defaultValue: 'https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/assets%2FKQlEmWDxA0coC3PK6UvkrjwkIGI2%2F28cb070609f546cdbe5efa20e931aa4b?alt=media&token=912e9551-7a7c-4dfb-86b6-3da1537d1a7f',
1721
+ required: true
1722
+ },
1723
+ {
1724
+ name: 'posterImage',
1725
+ type: 'file',
1726
+ allowedFileTypes: [
1727
+ 'jpeg',
1728
+ 'png'
1729
+ ],
1730
+ helperText: 'Image to show before the video plays'
1731
+ },
1732
+ {
1733
+ name: 'autoPlay',
1734
+ type: 'boolean',
1735
+ defaultValue: true
1736
+ },
1737
+ {
1738
+ name: 'controls',
1739
+ type: 'boolean',
1740
+ defaultValue: false
1741
+ },
1742
+ {
1743
+ name: 'muted',
1744
+ type: 'boolean',
1745
+ defaultValue: true
1746
+ },
1747
+ {
1748
+ name: 'loop',
1749
+ type: 'boolean',
1750
+ defaultValue: true
1751
+ },
1752
+ {
1753
+ name: 'playsInline',
1754
+ type: 'boolean',
1755
+ defaultValue: true
1756
+ },
1757
+ {
1758
+ name: 'fit',
1759
+ type: 'text',
1760
+ defaultValue: 'cover',
1761
+ enum: [
1762
+ 'contain',
1763
+ 'cover',
1764
+ 'fill',
1765
+ 'auto'
1766
+ ]
1767
+ },
1768
+ {
1769
+ name: 'fitContent',
1770
+ type: 'boolean',
1771
+ helperText: 'When child blocks are provided, fit to them instead of using the aspect ratio',
1772
+ defaultValue: true,
1773
+ advanced: true
1774
+ },
1775
+ {
1776
+ name: 'position',
1777
+ type: 'text',
1778
+ defaultValue: 'center',
1779
+ enum: [
1780
+ 'center',
1781
+ 'top',
1782
+ 'left',
1783
+ 'right',
1784
+ 'bottom',
1785
+ 'top left',
1786
+ 'top right',
1787
+ 'bottom left',
1788
+ 'bottom right'
1789
+ ]
1790
+ },
1791
+ {
1792
+ name: 'height',
1793
+ type: 'number',
1794
+ advanced: true
1795
+ },
1796
+ {
1797
+ name: 'width',
1798
+ type: 'number',
1799
+ advanced: true
1800
+ },
1801
+ {
1802
+ name: 'aspectRatio',
1803
+ type: 'number',
1804
+ advanced: true,
1805
+ defaultValue: 0.7004048582995948
1806
+ },
1807
+ {
1808
+ name: 'lazyLoad',
1809
+ type: 'boolean',
1810
+ helperText: 'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',
1811
+ defaultValue: true,
1812
+ advanced: true
1813
+ }
1814
+ ]
1815
+ };
1816
+
1817
+ const componentInfo$2 = {
1818
+ name: 'Embed',
1819
+ static: true,
1820
+ builtIn: true,
1821
+ inputs: [
1822
+ {
1823
+ name: 'url',
1824
+ type: 'url',
1825
+ required: true,
1826
+ defaultValue: '',
1827
+ helperText: 'e.g. enter a youtube url, google map, etc',
1828
+ onChange: serializeFn((options)=>{
1829
+ const url = options.get('url');
1830
+ if (url) {
1831
+ options.set('content', 'Loading...');
1832
+ // TODO: get this out of here!
1833
+ const apiKey = 'ae0e60e78201a3f2b0de4b';
1834
+ return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res)=>res.json()).then((data)=>{
1835
+ if (options.get('url') === url) {
1836
+ if (data.html) options.set('content', data.html);
1837
+ else options.set('content', 'Invalid url, please try another');
1838
+ }
1839
+ }).catch((_err)=>{
1840
+ options.set('content', 'There was an error embedding this URL, please try again or another URL');
1841
+ });
1842
+ } else options.delete('content');
1843
+ })
1844
+ },
1845
+ {
1846
+ name: 'content',
1847
+ type: 'html',
1848
+ defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
1849
+ hideFromUI: true
1850
+ }
1851
+ ]
1852
+ };
1853
+
1854
+ const SCRIPT_MIME_TYPES = [
1855
+ 'text/javascript',
1856
+ 'application/javascript',
1857
+ 'application/ecmascript'
1858
+ ];
1859
+ const isJsScript = (script)=>SCRIPT_MIME_TYPES.includes(script.type);
1860
+
1861
+ // GENERATED BY MITOSIS
1862
+ const findAndRunScripts$1 = function findAndRunScripts(props, state, elem) {
1863
+ if (!elem || !elem.getElementsByTagName) return;
1864
+ const scripts = elem.getElementsByTagName("script");
1865
+ for(let i = 0; i < scripts.length; i++){
1866
+ const script = scripts[i];
1867
+ if (script.src && !state.scriptsInserted.includes(script.src)) {
1868
+ state.scriptsInserted.push(script.src);
1869
+ const newScript = document.createElement("script");
1870
+ newScript.async = true;
1871
+ newScript.src = script.src;
1872
+ document.head.appendChild(newScript);
1873
+ } else if (isJsScript(script) && !state.scriptsRun.includes(script.innerText)) try {
1874
+ state.scriptsRun.push(script.innerText);
1875
+ new Function(script.innerText)();
1876
+ } catch (error) {
1877
+ console.warn("`Embed`: Error running script:", error);
1878
+ }
1879
+ }
1880
+ };
1881
+ const Embed = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1882
+ const elem = useRef();
1883
+ const state = useStore({
1884
+ ranInitFn: false,
1885
+ scriptsInserted: [],
1886
+ scriptsRun: []
1887
+ });
1888
+ useWatchQrl(inlinedQrl(({ track })=>{
1889
+ const [elem, props, state] = useLexicalScope();
1890
+ state && track(state, "ranInitFn");
1891
+ if (elem && !state.ranInitFn) {
1892
+ state.ranInitFn = true;
1893
+ findAndRunScripts$1(props, state, elem);
1894
+ }
1895
+ }, "Embed_component_useWatch_AxgWjrHdlAI", [
1896
+ elem,
1897
+ props,
1898
+ state
1899
+ ]));
1900
+ return /*#__PURE__*/ jsx("div", {
1901
+ class: "builder-embed",
1902
+ ref: elem,
1903
+ get dangerouslySetInnerHTML () {
1904
+ return props.content;
1905
+ },
1906
+ [_IMMUTABLE]: {
1907
+ dangerouslySetInnerHTML: _wrapSignal(props, "content")
1908
+ }
1909
+ });
1910
+ }, "Embed_component_Uji08ORjXbE"));
1911
+ const embed = Embed;
1912
+
1913
+ // GENERATED BY MITOSIS
1914
+ const ImgComponent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1915
+ return /*#__PURE__*/ jsx("img", {
1916
+ style: {
1917
+ objectFit: props.backgroundSize || "cover",
1918
+ objectPosition: props.backgroundPosition || "center"
1919
+ },
1920
+ get alt () {
1921
+ return props.altText;
1922
+ },
1923
+ src: props.imgSrc || props.image,
1924
+ ...props.attributes,
1925
+ [_IMMUTABLE]: {
1926
+ alt: _wrapSignal(props, "altText")
1927
+ }
1928
+ }, isEditing() && props.imgSrc || "default-key");
1929
+ }, "ImgComponent_component_FXvIDBSffO8"));
1930
+ const Img = ImgComponent;
1931
+
1932
+ const componentInfo$1 = {
1933
+ // friendlyName?
1934
+ name: 'Raw:Img',
1935
+ hideFromInsertMenu: true,
1936
+ builtIn: true,
1937
+ 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',
1938
+ inputs: [
1939
+ {
1940
+ name: 'image',
1941
+ bubble: true,
1942
+ type: 'file',
1943
+ allowedFileTypes: [
1944
+ 'jpeg',
1945
+ 'jpg',
1946
+ 'png',
1947
+ 'svg'
1948
+ ],
1949
+ required: true
1950
+ }
1951
+ ],
1952
+ noWrap: true,
1953
+ static: true
1954
+ };
1955
+
1956
+ // GENERATED BY MITOSIS
1957
+ const findAndRunScripts = function findAndRunScripts(props, state, elem) {
1958
+ // TODO: Move this function to standalone one in '@builder.io/utils'
1959
+ if (elem && elem.getElementsByTagName && typeof window !== "undefined") {
1960
+ const scripts = elem.getElementsByTagName("script");
1961
+ for(let i = 0; i < scripts.length; i++){
1962
+ const script = scripts[i];
1963
+ if (script.src) {
1964
+ if (state.scriptsInserted.includes(script.src)) continue;
1965
+ state.scriptsInserted.push(script.src);
1966
+ const newScript = document.createElement("script");
1967
+ newScript.async = true;
1968
+ newScript.src = script.src;
1969
+ document.head.appendChild(newScript);
1970
+ } else if (!script.type || [
1971
+ "text/javascript",
1972
+ "application/javascript",
1973
+ "application/ecmascript"
1974
+ ].includes(script.type)) {
1975
+ if (state.scriptsRun.includes(script.innerText)) continue;
1976
+ try {
1977
+ state.scriptsRun.push(script.innerText);
1978
+ new Function(script.innerText)();
1979
+ } catch (error) {
1980
+ console.warn("`CustomCode`: Error running script:", error);
1981
+ }
1982
+ }
1983
+ }
1984
+ }
1985
+ };
1986
+ const CustomCode = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
1987
+ const elem = useRef();
1988
+ const state = useStore({
1989
+ scriptsInserted: [],
1990
+ scriptsRun: []
1991
+ });
1992
+ useClientEffectQrl(inlinedQrl(()=>{
1993
+ const [elem, props, state] = useLexicalScope();
1994
+ findAndRunScripts(props, state, elem);
1995
+ }, "CustomCode_component_useClientEffect_4w4c951ufB4", [
1996
+ elem,
1997
+ props,
1998
+ state
1999
+ ]));
2000
+ return /*#__PURE__*/ jsx("div", {
2001
+ ref: elem,
2002
+ class: "builder-custom-code" + (props.replaceNodes ? " replace-nodes" : ""),
2003
+ get dangerouslySetInnerHTML () {
2004
+ return props.code;
2005
+ },
2006
+ [_IMMUTABLE]: {
2007
+ dangerouslySetInnerHTML: _wrapSignal(props, "code")
2008
+ }
2009
+ });
2010
+ }, "CustomCode_component_uYOSy7w7Zqw"));
2011
+ const customCode = CustomCode;
2012
+
2013
+ const componentInfo = {
2014
+ name: 'Custom Code',
2015
+ static: true,
2016
+ builtIn: true,
2017
+ requiredPermissions: [
2018
+ 'editCode'
2019
+ ],
2020
+ inputs: [
2021
+ {
2022
+ name: 'code',
2023
+ type: 'html',
2024
+ required: true,
2025
+ defaultValue: '<p>Hello there, I am custom HTML code!</p>',
2026
+ code: true
2027
+ },
2028
+ {
2029
+ name: 'replaceNodes',
2030
+ type: 'boolean',
2031
+ helperText: 'Preserve server rendered dom nodes',
2032
+ advanced: true
2033
+ },
2034
+ {
2035
+ name: 'scriptsClientOnly',
2036
+ type: 'boolean',
2037
+ defaultValue: false,
2038
+ helperText: 'Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads',
2039
+ advanced: true
2040
+ }
2041
+ ]
2042
+ };
2043
+
2044
+ /**
2045
+ * Returns a list of all registered components.
2046
+ * NOTE: This needs to be a function to work around ESM circular dependencies.
2047
+ */ const getDefaultRegisteredComponents = ()=>[
2048
+ {
2049
+ component: Columns$1,
2050
+ ...componentInfo$9
2051
+ },
2052
+ {
2053
+ component: Image$1,
2054
+ ...componentInfo$7
2055
+ },
2056
+ {
2057
+ component: Img,
2058
+ ...componentInfo$1
2059
+ },
2060
+ {
2061
+ component: Text$1,
2062
+ ...componentInfo$4
2063
+ },
2064
+ {
2065
+ component: Video$1,
2066
+ ...componentInfo$3
2067
+ },
2068
+ {
2069
+ component: Symbol$2,
2070
+ ...componentInfo$5
2071
+ },
2072
+ {
2073
+ component: Button$1,
2074
+ ...componentInfo$a
2075
+ },
2076
+ {
2077
+ component: Section,
2078
+ ...componentInfo$6
2079
+ },
2080
+ {
2081
+ component: Fragment,
2082
+ ...componentInfo$8
2083
+ },
2084
+ {
2085
+ component: embed,
2086
+ ...componentInfo$2
2087
+ },
2088
+ {
2089
+ component: customCode,
2090
+ ...componentInfo
2091
+ }
2092
+ ];
2093
+
2094
+ /**
2095
+ * Convert deep object to a flat object with dots
2096
+ *
2097
+ * { foo: { bar: 'baz' }} -> { 'foo.bar': 'baz' }
2098
+ */ function flatten(object, path = null, separator = '.') {
2099
+ return Object.keys(object).reduce((acc, key)=>{
2100
+ const value = object[key];
2101
+ const newPath = [
2102
+ path,
2103
+ key
2104
+ ].filter(Boolean).join(separator);
2105
+ const isObject = [
2106
+ typeof value === 'object',
2107
+ value !== null,
2108
+ !(Array.isArray(value) && value.length === 0)
2109
+ ].every(Boolean);
2110
+ return isObject ? {
2111
+ ...acc,
2112
+ ...flatten(value, newPath, separator)
2113
+ } : {
2114
+ ...acc,
2115
+ [newPath]: value
2116
+ };
2117
+ }, {});
2118
+ }
2119
+
2120
+ const BUILDER_SEARCHPARAMS_PREFIX = 'builder.';
2121
+ const convertSearchParamsToQueryObject = (searchParams)=>{
2122
+ const options = {};
2123
+ searchParams.forEach((value, key)=>{
2124
+ options[key] = value;
2125
+ });
2126
+ return options;
2127
+ };
2128
+ const getBuilderSearchParams = (_options)=>{
2129
+ if (!_options) return {};
2130
+ const options = normalizeSearchParams(_options);
2131
+ const newOptions = {};
2132
+ Object.keys(options).forEach((key)=>{
2133
+ if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2134
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, '');
2135
+ newOptions[trimmedKey] = options[key];
2136
+ }
2137
+ });
2138
+ return newOptions;
2139
+ };
2140
+ const getBuilderSearchParamsFromWindow = ()=>{
2141
+ if (!isBrowser()) return {};
2142
+ const searchParams = new URLSearchParams(window.location.search);
2143
+ return getBuilderSearchParams(searchParams);
2144
+ };
2145
+ const normalizeSearchParams = (searchParams)=>searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
2146
+
2147
+ function getGlobalThis() {
2148
+ if (typeof globalThis !== 'undefined') return globalThis;
2149
+ if (typeof window !== 'undefined') return window;
2150
+ if (typeof global !== 'undefined') return global;
2151
+ if (typeof self !== 'undefined') return self;
2152
+ return null;
2153
+ }
2154
+
2155
+ async function getFetch() {
2156
+ const globalFetch = getGlobalThis().fetch;
2157
+ if (typeof globalFetch === 'undefined' && typeof global !== 'undefined') throw new Error('`fetch()` not found, ensure you have it as part of your polyfills.');
2158
+ return globalFetch.default || globalFetch;
2159
+ }
2160
+
2161
+ /**
2162
+ * Only gets one level up from hostname
2163
+ * wwww.example.com -> example.com
2164
+ * www.example.co.uk -> example.co.uk
2165
+ */ const getTopLevelDomain = (host)=>{
2166
+ const parts = host.split('.');
2167
+ if (parts.length > 2) return parts.slice(1).join('.');
2168
+ return host;
2169
+ };
2170
+
2171
+ /**
2172
+ * NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
2173
+ */ const getCookie = async ({ name , canTrack })=>{
2174
+ try {
2175
+ if (!canTrack) return undefined;
2176
+ /**
2177
+ * Extracted from MDN docs
2178
+ * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie#example_2_get_a_sample_cookie_named_test2
2179
+ */ return document.cookie.split('; ').find((row)=>row.startsWith(`${name}=`))?.split('=')[1];
2180
+ } catch (err) {
2181
+ console.debug('[COOKIE] GET error: ', err);
2182
+ }
2183
+ };
2184
+ const stringifyCookie = (cookie)=>cookie.map(([key, value])=>value ? `${key}=${value}` : key).join('; ');
2185
+ const SECURE_CONFIG = [
2186
+ [
2187
+ 'secure',
2188
+ ''
2189
+ ],
2190
+ [
2191
+ 'SameSite',
2192
+ 'None'
2193
+ ]
2194
+ ];
2195
+ const createCookieString = ({ name , value , expires })=>{
2196
+ const secure = isBrowser() ? location.protocol === 'https:' : true;
2197
+ const secureObj = secure ? SECURE_CONFIG : [
2198
+ []
2199
+ ];
2200
+ // TODO: need to know if secure server side
2201
+ const expiresObj = expires ? [
2202
+ [
2203
+ 'expires',
2204
+ expires.toUTCString()
2205
+ ]
2206
+ ] : [
2207
+ []
2208
+ ];
2209
+ const cookieValue = [
2210
+ [
2211
+ name,
2212
+ value
2213
+ ],
2214
+ ...expiresObj,
2215
+ [
2216
+ 'path',
2217
+ '/'
2218
+ ],
2219
+ [
2220
+ 'domain',
2221
+ getTopLevelDomain(window.location.hostname)
2222
+ ],
2223
+ ...secureObj
2224
+ ];
2225
+ const cookie = stringifyCookie(cookieValue);
2226
+ return cookie;
2227
+ };
2228
+ /**
2229
+ * NOTE: This function is `async` because its react-native override is async. Do not remove the `async` keyword!
2230
+ */ const setCookie = async ({ name , value , expires , canTrack })=>{
2231
+ try {
2232
+ if (!canTrack) return undefined;
2233
+ const cookie = createCookieString({
2234
+ name,
2235
+ value,
2236
+ expires
2237
+ });
2238
+ document.cookie = cookie;
2239
+ } catch (err) {
2240
+ console.warn('[COOKIE] SET error: ', err);
2241
+ }
2242
+ };
2243
+
2244
+ const BUILDER_STORE_PREFIX = 'builderio.variations';
2245
+ const getContentTestKey = (id)=>`${BUILDER_STORE_PREFIX}.${id}`;
2246
+ const getContentVariationCookie = ({ contentId , canTrack })=>getCookie({
2247
+ name: getContentTestKey(contentId),
2248
+ canTrack
2249
+ });
2250
+ const setContentVariationCookie = ({ contentId , canTrack , value })=>setCookie({
2251
+ name: getContentTestKey(contentId),
2252
+ value,
2253
+ canTrack
2254
+ });
2255
+
2256
+ const checkIsDefined = (maybeT)=>maybeT !== null && maybeT !== undefined;
2257
+
2258
+ const checkIsBuilderContentWithVariations = (item)=>checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
2259
+ /**
2260
+ * Randomly assign a variation to this user and store it in cookies/storage
2261
+ */ const getRandomVariationId = ({ id , variations })=>{
2262
+ let n = 0;
2263
+ const random = Math.random();
2264
+ // loop over variations test ratios, incrementing a counter,
2265
+ // until we find the variation that this user should be assigned to
2266
+ for(const id1 in variations){
2267
+ const testRatio = variations[id1]?.testRatio;
2268
+ n += testRatio;
2269
+ if (random < n) return id1;
2270
+ }
2271
+ // `item.variations` does not include the default variation
2272
+ // if we arrive here, then it means that the random number fits in the default variation bucket
2273
+ return id;
2274
+ };
2275
+ const getTestFields = ({ item , testGroupId })=>{
2276
+ const variationValue = item.variations[testGroupId];
2277
+ if (testGroupId === item.id || // handle edge-case where `testGroupId` points to non-existing variation
2278
+ !variationValue) return {
2279
+ testVariationId: item.id,
2280
+ testVariationName: 'Default'
2281
+ };
2282
+ else return {
2283
+ data: variationValue.data,
2284
+ testVariationId: variationValue.id,
2285
+ testVariationName: variationValue.name || (variationValue.id === item.id ? 'Default' : '')
2286
+ };
2287
+ };
2288
+ const getContentVariation = async ({ item , canTrack })=>{
2289
+ // try to find test variation in cookies/storage
2290
+ const testGroupId = await getContentVariationCookie({
2291
+ canTrack,
2292
+ contentId: item.id
2293
+ });
2294
+ const testFields = testGroupId ? getTestFields({
2295
+ item,
2296
+ testGroupId
2297
+ }) : undefined;
2298
+ if (testFields) return testFields;
2299
+ else {
2300
+ // if variation not found in storage, assign a random variation to this user
2301
+ const randomVariationId = getRandomVariationId({
2302
+ variations: item.variations,
2303
+ id: item.id
2304
+ });
2305
+ // store variation in cookies/storage
2306
+ setContentVariationCookie({
2307
+ contentId: item.id,
2308
+ value: randomVariationId,
2309
+ canTrack
2310
+ }).catch((err)=>{
2311
+ console.error('could not store A/B test variation: ', err);
2312
+ });
2313
+ return getTestFields({
2314
+ item,
2315
+ testGroupId: randomVariationId
2316
+ });
2317
+ }
2318
+ };
2319
+ const handleABTesting = async ({ item , canTrack })=>{
2320
+ if (!checkIsBuilderContentWithVariations(item)) return;
2321
+ const variationValue = await getContentVariation({
2322
+ item,
2323
+ canTrack
2324
+ });
2325
+ Object.assign(item, variationValue);
2326
+ };
2327
+
2328
+ async function getContent(options) {
2329
+ return (await getAllContent({
2330
+ ...options,
2331
+ limit: 1
2332
+ })).results[0] || null;
2333
+ }
2334
+ const generateContentUrl = (options)=>{
2335
+ const { limit =30 , userAttributes , query , noTraverse =false , model , apiKey , includeRefs =true , } = options;
2336
+ if (!apiKey) throw new Error('Missing API key');
2337
+ const url = new URL(`https://cdn.builder.io/api/v2/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}`);
2338
+ const queryOptions = {
2339
+ ...getBuilderSearchParamsFromWindow(),
2340
+ ...normalizeSearchParams(options.options || {})
2341
+ };
2342
+ const flattened = flatten(queryOptions);
2343
+ for(const key in flattened)url.searchParams.set(key, String(flattened[key]));
2344
+ if (userAttributes) url.searchParams.set('userAttributes', JSON.stringify(userAttributes));
2345
+ if (query) {
2346
+ const flattened1 = flatten({
2347
+ query
2348
+ });
2349
+ for(const key1 in flattened1)url.searchParams.set(key1, JSON.stringify(flattened1[key1]));
2350
+ }
2351
+ return url;
2352
+ };
2353
+ async function getAllContent(options) {
2354
+ const url = generateContentUrl(options);
2355
+ const fetch = await getFetch();
2356
+ const content = await fetch(url.href).then((res)=>res.json());
2357
+ const canTrack = options.canTrack !== false;
2358
+ if (canTrack) for (const item of content.results)await handleABTesting({
2359
+ item,
2360
+ canTrack
2361
+ });
2362
+ return content;
2363
+ }
2364
+
2365
+ function isPreviewing() {
2366
+ if (!isBrowser()) return false;
2367
+ if (isEditing()) return false;
2368
+ return Boolean(location.search.indexOf('builder.preview=') !== -1);
2369
+ }
2370
+
2371
+ /**
2372
+ * @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
2373
+ */ const components = [];
2374
+ /**
2375
+ * @deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.
2376
+ */ function registerComponent(component, info) {
2377
+ components.push({
2378
+ component,
2379
+ ...info
2380
+ });
2381
+ console.warn('registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.');
2382
+ return component;
2383
+ }
2384
+ const createRegisterComponentMessage = ({ component: _ , ...info })=>({
2385
+ type: 'builder.registerComponent',
2386
+ data: prepareComponentInfoToSend(info)
2387
+ });
2388
+ const serializeValue = (value)=>typeof value === 'function' ? serializeFn(value) : fastClone(value);
2389
+ const prepareComponentInfoToSend = ({ inputs , ...info })=>({
2390
+ ...fastClone(info),
2391
+ inputs: inputs?.map((input)=>Object.entries(input).reduce((acc, [key, value])=>({
2392
+ ...acc,
2393
+ [key]: serializeValue(value)
2394
+ }), {}))
2395
+ });
2396
+
2397
+ /**
2398
+ * @credit https://stackoverflow.com/a/2117523
2399
+ */ function uuidv4() {
2400
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
2401
+ const r = Math.random() * 16 | 0, v = c == 'x' ? r : r & 0x3 | 0x8;
2402
+ return v.toString(16);
2403
+ });
2404
+ }
2405
+ /**
2406
+ * Slightly cleaner and smaller UUIDs
2407
+ */ function uuid() {
2408
+ return uuidv4().replace(/-/g, '');
2409
+ }
2410
+
2411
+ const SESSION_LOCAL_STORAGE_KEY = 'builderSessionId';
2412
+ const getSessionId = async ({ canTrack })=>{
2413
+ if (!canTrack) return undefined;
2414
+ const sessionId = await getCookie({
2415
+ name: SESSION_LOCAL_STORAGE_KEY,
2416
+ canTrack
2417
+ });
2418
+ if (checkIsDefined(sessionId)) return sessionId;
2419
+ else {
2420
+ const newSessionId = createSessionId();
2421
+ setSessionId({
2422
+ id: newSessionId,
2423
+ canTrack
2424
+ });
2425
+ }
2426
+ };
2427
+ const createSessionId = ()=>uuid();
2428
+ const setSessionId = ({ id , canTrack })=>setCookie({
2429
+ name: SESSION_LOCAL_STORAGE_KEY,
2430
+ value: id,
2431
+ canTrack
2432
+ });
2433
+
2434
+ const getLocalStorage = ()=>isBrowser() && typeof localStorage !== 'undefined' ? localStorage : undefined;
2435
+ const getLocalStorageItem = ({ key , canTrack })=>{
2436
+ try {
2437
+ if (canTrack) return getLocalStorage()?.getItem(key);
2438
+ return undefined;
2439
+ } catch (err) {
2440
+ console.debug('[LocalStorage] GET error: ', err);
2441
+ }
2442
+ };
2443
+ const setLocalStorageItem = ({ key , canTrack , value })=>{
2444
+ try {
2445
+ if (canTrack) getLocalStorage()?.setItem(key, value);
2446
+ } catch (err) {
2447
+ console.debug('[LocalStorage] SET error: ', err);
2448
+ }
2449
+ };
2450
+
2451
+ const VISITOR_LOCAL_STORAGE_KEY = 'builderVisitorId';
2452
+ const getVisitorId = ({ canTrack })=>{
2453
+ if (!canTrack) return undefined;
2454
+ const visitorId = getLocalStorageItem({
2455
+ key: VISITOR_LOCAL_STORAGE_KEY,
2456
+ canTrack
2457
+ });
2458
+ if (checkIsDefined(visitorId)) return visitorId;
2459
+ else {
2460
+ const newVisitorId = createVisitorId();
2461
+ setVisitorId({
2462
+ id: newVisitorId,
2463
+ canTrack
2464
+ });
2465
+ }
2466
+ };
2467
+ const createVisitorId = ()=>uuid();
2468
+ const setVisitorId = ({ id , canTrack })=>setLocalStorageItem({
2469
+ key: VISITOR_LOCAL_STORAGE_KEY,
2470
+ value: id,
2471
+ canTrack
2472
+ });
2473
+
2474
+ const getTrackingEventData = async ({ canTrack })=>{
2475
+ if (!canTrack) return {
2476
+ visitorId: undefined,
2477
+ sessionId: undefined
2478
+ };
2479
+ const sessionId = await getSessionId({
2480
+ canTrack
2481
+ });
2482
+ const visitorId = getVisitorId({
2483
+ canTrack
2484
+ });
2485
+ return {
2486
+ sessionId,
2487
+ visitorId
2488
+ };
2489
+ };
2490
+ const createEvent = async ({ type: eventType , canTrack , apiKey , metadata , ...properties })=>({
2491
+ type: eventType,
2492
+ data: {
2493
+ ...properties,
2494
+ metadata: JSON.stringify(metadata),
2495
+ ...await getTrackingEventData({
2496
+ canTrack
2497
+ }),
2498
+ ownerId: apiKey
2499
+ }
2500
+ });
2501
+ async function _track(eventProps) {
2502
+ if (!eventProps.canTrack) return;
2503
+ if (isEditing()) return;
2504
+ if (!(isBrowser() || TARGET === 'reactNative')) return;
2505
+ return fetch(`https://builder.io/api/v1/track`, {
2506
+ method: 'POST',
2507
+ body: JSON.stringify({
2508
+ events: [
2509
+ await createEvent(eventProps)
2510
+ ]
2511
+ }),
2512
+ headers: {
2513
+ 'content-type': 'application/json'
2514
+ },
2515
+ mode: 'cors'
2516
+ }).catch((err)=>{
2517
+ console.error('Failed to track: ', err);
2518
+ });
2519
+ }
2520
+ const track = (args)=>_track({
2521
+ ...args,
2522
+ canTrack: true
2523
+ });
2524
+
2525
+ // GENERATED BY MITOSIS
2526
+ const getCssFromFont = function getCssFromFont(props, state, font) {
2527
+ // TODO: compute what font sizes are used and only load those.......
2528
+ const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
2529
+ const name = family.split(",")[0];
2530
+ const url = font.fileUrl ?? font?.files?.regular;
2531
+ let str = "";
2532
+ if (url && family && name) str += `
2533
+ @font-face {
2534
+ font-family: "${family}";
2535
+ src: local("${name}"), url('${url}') format('woff2');
2536
+ font-display: fallback;
2537
+ font-weight: 400;
2538
+ }
2539
+ `.trim();
2540
+ if (font.files) for(const weight in font.files){
2541
+ const isNumber = String(Number(weight)) === weight;
2542
+ if (!isNumber) continue;
2543
+ // TODO: maybe limit number loaded
2544
+ const weightUrl = font.files[weight];
2545
+ if (weightUrl && weightUrl !== url) str += `
2546
+ @font-face {
2547
+ font-family: "${family}";
2548
+ src: url('${weightUrl}') format('woff2');
2549
+ font-display: fallback;
2550
+ font-weight: ${weight};
2551
+ }
2552
+ `.trim();
2553
+ }
2554
+ return str;
2555
+ };
2556
+ const getFontCss = function getFontCss(props, state, { customFonts }) {
2557
+ // TODO: flag for this
2558
+ // if (!this.builder.allowCustomFonts) {
2559
+ // return '';
2560
+ // }
2561
+ // TODO: separate internal data from external
2562
+ return customFonts?.map((font)=>getCssFromFont(props, state, font))?.join(" ") || "";
2563
+ };
2564
+ const injectedStyles = function injectedStyles(props, state) {
2565
+ return `
2566
+ ${props.cssCode || ""}
2567
+ ${getFontCss(props, state, {
2568
+ customFonts: props.customFonts
2569
+ })}`;
2570
+ };
2571
+ const RenderContentStyles = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2572
+ const state = {};
2573
+ return /*#__PURE__*/ jsx(RenderInlinedStyles$1, {
2574
+ styles: injectedStyles(props, state)
2575
+ });
2576
+ }, "RenderContentStyles_component_Og0xL34Zbvc"));
2577
+ const RenderContentStyles$1 = RenderContentStyles;
2578
+
2579
+ // GENERATED BY MITOSIS
2580
+ const useContent = function useContent(props, state, elementRef) {
2581
+ if (!props.content && !state.overrideContent) return undefined;
2582
+ const mergedContent = {
2583
+ ...props.content,
2584
+ ...state.overrideContent,
2585
+ data: {
2586
+ ...props.content?.data,
2587
+ ...props.data,
2588
+ ...state.overrideContent?.data
2589
+ }
2590
+ };
2591
+ return mergedContent;
2592
+ };
2593
+ const canTrackToUse = function canTrackToUse(props, state, elementRef) {
2594
+ return props.canTrack || true;
2595
+ };
2596
+ const contentState = function contentState(props, state, elementRef) {
2597
+ return {
2598
+ ...props.content?.data?.state,
2599
+ ...props.data,
2600
+ ...state.overrideState
2601
+ };
2602
+ };
2603
+ const contextContext = function contextContext(props, state, elementRef) {
2604
+ return props.context || {};
2605
+ };
2606
+ const allRegisteredComponents = function allRegisteredComponents(props, state, elementRef) {
2607
+ const allComponentsArray = [
2608
+ ...getDefaultRegisteredComponents(),
2609
+ // Since users are able to override our default components, we need to make sure that we do not break such
2610
+ // existing usage.
2611
+ // This is why we spread `components` after the default Builder.io components, but before the `props.customComponents`,
2612
+ // which is the new standard way of providing custom components, and must therefore take precedence.
2613
+ ...components,
2614
+ ...props.customComponents || []
2615
+ ];
2616
+ const allComponents = allComponentsArray.reduce((acc, curr)=>({
2617
+ ...acc,
2618
+ [curr.name]: curr
2619
+ }), {});
2620
+ return allComponents;
2621
+ };
2622
+ const processMessage = function processMessage(props, state, elementRef, event) {
2623
+ const { data } = event;
2624
+ if (data) switch(data.type){
2625
+ case "builder.contentUpdate":
2626
+ {
2627
+ const messageContent = data.data;
2628
+ const key = messageContent.key || messageContent.alias || messageContent.entry || messageContent.modelName;
2629
+ const contentData = messageContent.data;
2630
+ if (key === props.model) {
2631
+ state.overrideContent = contentData;
2632
+ state.forceReRenderCount = state.forceReRenderCount + 1; // This is a hack to force Qwik to re-render.
2633
+ }
2634
+ break;
2635
+ }
2636
+ }
2637
+ };
2638
+ const evaluateJsCode = function evaluateJsCode(props, state, elementRef) {
2639
+ // run any dynamic JS code attached to content
2640
+ const jsCode = useContent(props, state)?.data?.jsCode;
2641
+ if (jsCode) evaluate({
2642
+ code: jsCode,
2643
+ context: contextContext(props),
2644
+ state: contentState(props, state)
2645
+ });
2646
+ };
2647
+ const httpReqsData = function httpReqsData(props, state, elementRef) {
2648
+ return {};
2649
+ };
2650
+ const onClick = function onClick(props, state, elementRef, _event) {
2651
+ if (useContent(props, state)) {
2652
+ const variationId = useContent(props, state)?.testVariationId;
2653
+ const contentId = useContent(props, state)?.id;
2654
+ _track({
2655
+ type: "click",
2656
+ canTrack: canTrackToUse(props),
2657
+ contentId,
2658
+ apiKey: props.apiKey,
2659
+ variationId: variationId !== contentId ? variationId : undefined
2660
+ });
2661
+ }
2662
+ };
2663
+ const evalExpression = function evalExpression(props, state, elementRef, expression) {
2664
+ return expression.replace(/{{([^}]+)}}/g, (_match, group)=>evaluate({
2665
+ code: group,
2666
+ context: contextContext(props),
2667
+ state: contentState(props, state)
2668
+ }));
2669
+ };
2670
+ const handleRequest = function handleRequest(props, state, elementRef, { url , key }) {
2671
+ getFetch().then((fetch)=>fetch(url)).then((response)=>response.json()).then((json)=>{
2672
+ const newOverrideState = {
2673
+ ...state.overrideState,
2674
+ [key]: json
2675
+ };
2676
+ state.overrideState = newOverrideState;
2677
+ }).catch((err)=>{
2678
+ console.log("error fetching dynamic data", url, err);
2679
+ });
2680
+ };
2681
+ const runHttpRequests = function runHttpRequests(props, state, elementRef) {
2682
+ const requests = useContent(props, state)?.data?.httpRequests ?? {};
2683
+ Object.entries(requests).forEach(([key, url])=>{
2684
+ if (url && (!httpReqsData()[key] || isEditing())) {
2685
+ const evaluatedUrl = evalExpression(props, state, elementRef, url);
2686
+ handleRequest(props, state, elementRef, {
2687
+ url: evaluatedUrl,
2688
+ key
2689
+ });
2690
+ }
2691
+ });
2692
+ };
2693
+ const emitStateUpdate = function emitStateUpdate(props, state, elementRef) {
2694
+ if (isEditing()) window.dispatchEvent(new CustomEvent("builder:component:stateChange", {
2695
+ detail: {
2696
+ state: contentState(props, state),
2697
+ ref: {
2698
+ name: props.model
2699
+ }
2700
+ }
2701
+ }));
2702
+ };
2703
+ const shouldRenderContentStyles = function shouldRenderContentStyles(props, state, elementRef) {
2704
+ return Boolean((useContent(props, state)?.data?.cssCode || useContent(props, state)?.data?.customFonts?.length) && TARGET !== "reactNative");
2705
+ };
2706
+ const RenderContent = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2707
+ const elementRef = useRef();
2708
+ const state = useStore({
2709
+ forceReRenderCount: 0,
2710
+ overrideContent: null,
2711
+ overrideState: {},
2712
+ update: 0
2713
+ });
2714
+ useContextProvider(BuilderContext, useStore({
2715
+ content: (()=>{
2716
+ return useContent(props, state);
2717
+ })(),
2718
+ state: (()=>{
2719
+ return contentState(props, state);
2720
+ })(),
2721
+ context: (()=>{
2722
+ return contextContext(props);
2723
+ })(),
2724
+ apiKey: (()=>{
2725
+ return props.apiKey;
2726
+ })(),
2727
+ registeredComponents: (()=>{
2728
+ return allRegisteredComponents(props);
2729
+ })()
2730
+ }));
2731
+ useClientEffectQrl(inlinedQrl(()=>{
2732
+ const [elementRef, props, state] = useLexicalScope();
2733
+ if (isBrowser()) {
2734
+ if (isEditing()) {
2735
+ state.forceReRenderCount = state.forceReRenderCount + 1;
2736
+ registerInsertMenu();
2737
+ setupBrowserForEditing();
2738
+ Object.values(allRegisteredComponents(props)).forEach((registeredComponent)=>{
2739
+ const message = createRegisterComponentMessage(registeredComponent);
2740
+ window.parent?.postMessage(message, "*");
2741
+ });
2742
+ window.addEventListener("message", processMessage.bind(null, props, state, elementRef));
2743
+ window.addEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate.bind(null, props, state, elementRef));
2744
+ }
2745
+ if (useContent(props, state)) {
2746
+ const variationId = useContent(props, state)?.testVariationId;
2747
+ const contentId = useContent(props, state)?.id;
2748
+ _track({
2749
+ type: "impression",
2750
+ canTrack: canTrackToUse(props),
2751
+ contentId,
2752
+ apiKey: props.apiKey,
2753
+ variationId: variationId !== contentId ? variationId : undefined
2754
+ });
2755
+ } // override normal content in preview mode
2756
+ if (isPreviewing()) {
2757
+ const searchParams = new URL(location.href).searchParams;
2758
+ if (props.model && searchParams.get("builder.preview") === props.model) {
2759
+ const previewApiKey = searchParams.get("apiKey") || searchParams.get("builder.space");
2760
+ if (previewApiKey) getContent({
2761
+ model: props.model,
2762
+ apiKey: previewApiKey
2763
+ }).then((content)=>{
2764
+ if (content) state.overrideContent = content;
2765
+ });
2766
+ }
2767
+ }
2768
+ evaluateJsCode(props, state);
2769
+ runHttpRequests(props, state, elementRef);
2770
+ emitStateUpdate(props, state);
2771
+ }
2772
+ }, "RenderContent_component_useClientEffect_cA0sVHIkr5g", [
2773
+ elementRef,
2774
+ props,
2775
+ state
2776
+ ]));
2777
+ useWatchQrl(inlinedQrl(({ track })=>{
2778
+ const [elementRef, props, state] = useLexicalScope();
2779
+ state.useContent?.data && track(state.useContent?.data, "jsCode");
2780
+ evaluateJsCode(props, state);
2781
+ }, "RenderContent_component_useWatch_OIBatobA0hE", [
2782
+ elementRef,
2783
+ props,
2784
+ state
2785
+ ]));
2786
+ useWatchQrl(inlinedQrl(({ track })=>{
2787
+ const [elementRef, props, state] = useLexicalScope();
2788
+ state.useContent?.data && track(state.useContent?.data, "httpRequests");
2789
+ runHttpRequests(props, state, elementRef);
2790
+ }, "RenderContent_component_useWatch_1_LQM67VNl14k", [
2791
+ elementRef,
2792
+ props,
2793
+ state
2794
+ ]));
2795
+ useWatchQrl(inlinedQrl(({ track })=>{
2796
+ const [elementRef, props, state] = useLexicalScope();
2797
+ state && track(state, "contentState");
2798
+ emitStateUpdate(props, state);
2799
+ }, "RenderContent_component_useWatch_2_aGi0RpYNBO0", [
2800
+ elementRef,
2801
+ props,
2802
+ state
2803
+ ]));
2804
+ useCleanupQrl(inlinedQrl(()=>{
2805
+ const [elementRef, props, state] = useLexicalScope();
2806
+ if (isBrowser()) {
2807
+ window.removeEventListener("message", processMessage.bind(null, props, state, elementRef));
2808
+ window.removeEventListener("builder:component:stateChangeListenerActivated", emitStateUpdate.bind(null, props, state, elementRef));
2809
+ }
2810
+ }, "RenderContent_component_useCleanup_FwcO310HVAI", [
2811
+ elementRef,
2812
+ props,
2813
+ state
2814
+ ]));
2815
+ return /*#__PURE__*/ jsx(Fragment$1, {
2816
+ children: useContent(props, state) ? /*#__PURE__*/ jsxs("div", {
2817
+ ref: elementRef,
2818
+ onClick$: inlinedQrl((event)=>{
2819
+ const [elementRef, props, state] = useLexicalScope();
2820
+ return onClick(props, state);
2821
+ }, "RenderContent_component__Fragment_div_onClick_wLg5o3ZkpC0", [
2822
+ elementRef,
2823
+ props,
2824
+ state
2825
+ ]),
2826
+ "builder-content-id": useContent(props, state)?.id,
2827
+ get "builder-model" () {
2828
+ return props.model;
2829
+ },
2830
+ children: [
2831
+ shouldRenderContentStyles(props, state) ? /*#__PURE__*/ jsx(RenderContentStyles$1, {
2832
+ cssCode: useContent(props, state)?.data?.cssCode,
2833
+ customFonts: useContent(props, state)?.data?.customFonts
2834
+ }) : null,
2835
+ /*#__PURE__*/ jsx(RenderBlocks$1, {
2836
+ blocks: useContent(props, state)?.data?.blocks
2837
+ }, state.forceReRenderCount)
2838
+ ],
2839
+ [_IMMUTABLE]: {
2840
+ "builder-model": _wrapSignal(props, "model")
2841
+ }
2842
+ }) : null
2843
+ });
2844
+ }, "RenderContent_component_hEAI0ahViXM"));
2845
+ const RenderContent$1 = RenderContent;
2846
+
2847
+ // GENERATED BY MITOSIS
2848
+ const contentToUse = function contentToUse(props, state, builderContext) {
2849
+ return props.symbol?.content || state.fetchedContent;
2850
+ };
2851
+ const Symbol$1 = /*#__PURE__*/ componentQrl(inlinedQrl((props)=>{
2852
+ const builderContext = useContext(BuilderContext);
2853
+ const state = useStore({
2854
+ className: "builder-symbol",
2855
+ fetchedContent: null
2856
+ });
2857
+ useWatchQrl(inlinedQrl(({ track })=>{
2858
+ const [builderContext, props, state] = useLexicalScope();
2859
+ props && track(props, "symbol");
2860
+ state && track(state, "fetchedContent");
2861
+ const symbolToUse = props.symbol;
2862
+ /**
2863
+ * If:
2864
+ * - we have a symbol prop
2865
+ * - yet it does not have any content
2866
+ * - and we have not already stored content from before
2867
+ * - and it has a model name
2868
+ *
2869
+ * then we want to re-fetch the symbol content.
2870
+ */ if (symbolToUse && !symbolToUse.content && !state.fetchedContent && symbolToUse.model) getContent({
2871
+ model: symbolToUse.model,
2872
+ apiKey: builderContext.apiKey,
2873
+ query: {
2874
+ id: symbolToUse.entry
2875
+ }
2876
+ }).then((response)=>{
2877
+ state.fetchedContent = response;
2878
+ });
2879
+ }, "Symbol_component_useWatch_9HNT04zd0Dk", [
2880
+ builderContext,
2881
+ props,
2882
+ state
2883
+ ]));
2884
+ return /*#__PURE__*/ jsx("div", {
2885
+ ...props.attributes,
2886
+ get class () {
2887
+ return state.className;
2888
+ },
2889
+ children: /*#__PURE__*/ jsx(RenderContent$1, {
2890
+ get apiKey () {
2891
+ return builderContext.apiKey;
2892
+ },
2893
+ get context () {
2894
+ return builderContext.context;
2895
+ },
2896
+ customComponents: Object.values(builderContext.registeredComponents),
2897
+ data: {
2898
+ ...props.symbol?.data,
2899
+ ...builderContext.state,
2900
+ ...props.symbol?.content?.data?.state
2901
+ },
2902
+ model: props.symbol?.model,
2903
+ content: contentToUse(props, state),
2904
+ [_IMMUTABLE]: {
2905
+ apiKey: _wrapSignal(builderContext, "apiKey"),
2906
+ context: _wrapSignal(builderContext, "context")
2907
+ }
2908
+ }),
2909
+ [_IMMUTABLE]: {
2910
+ class: _wrapSignal(state, "className")
2911
+ }
2912
+ });
2913
+ }, "Symbol_component_WVvggdkUPdk"));
2914
+ const Symbol$2 = Symbol$1;
2915
+
2916
+ const settings = {};
2917
+ function setEditorSettings(newSettings) {
2918
+ if (isBrowser()) {
2919
+ Object.assign(settings, newSettings);
2920
+ const message = {
2921
+ type: 'builder.settingsChange',
2922
+ data: settings
2923
+ };
2924
+ parent.postMessage(message, '*');
2925
+ }
2926
+ }
2927
+
2928
+ export { Button$1 as Button, Columns$1 as Columns, Fragment, Image$1 as Image, RenderBlocks$1 as RenderBlocks, RenderContent$1 as RenderContent, Section, Symbol$2 as Symbol, Text$1 as Text, Video$1 as Video, components, convertSearchParamsToQueryObject, createRegisterComponentMessage, generateContentUrl, getAllContent, getBuilderSearchParams, getBuilderSearchParamsFromWindow, getContent, isEditing, isPreviewing, normalizeSearchParams, register, registerComponent, setEditorSettings, track };