@builder.io/sdk-solid 0.7.1-1 → 0.7.2

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.
@@ -1,4 +1,4 @@
1
- // src/blocks/button/button.jsx
1
+ // src/blocks/button/button.tsx
2
2
  import { Show } from "solid-js";
3
3
  import { css } from "solid-styled-components";
4
4
  function Button(props) {
@@ -13,80 +13,57 @@ function Button(props) {
13
13
  >{props.text}</button>}
14
14
  when={props.link}
15
15
  ><a
16
- role="button"
17
16
  {...{}}
18
17
  {...props.attributes}
19
18
  href={props.link}
20
19
  target={props.openLinkInNewTab ? "_blank" : void 0}
20
+ role="button"
21
21
  >{props.text}</a></Show>;
22
22
  }
23
23
  var button_default = Button;
24
24
 
25
- // src/blocks/columns/columns.jsx
26
- import { Show as Show7, For as For4, createSignal as createSignal6 } from "solid-js";
25
+ // src/blocks/columns/columns.tsx
26
+ import { Show as Show7, For as For4, createSignal as createSignal5 } from "solid-js";
27
27
  import { css as css3 } from "solid-styled-components";
28
28
 
29
- // src/components/blocks/blocks.jsx
29
+ // src/components/blocks/blocks.tsx
30
30
  import { useContext, Show as Show6, For as For3 } from "solid-js";
31
31
 
32
- // src/components/block/components/block-styles.jsx
33
- import { Show as Show2, createSignal } from "solid-js";
32
+ // src/context/builder.context.ts
33
+ import { createContext } from "solid-js";
34
+ var builder_context_default = createContext({
35
+ content: null,
36
+ context: {},
37
+ localState: void 0,
38
+ rootSetState() {
39
+ },
40
+ rootState: {},
41
+ apiKey: null,
42
+ apiVersion: void 0,
43
+ componentInfos: {},
44
+ inheritedStyles: {}
45
+ });
34
46
 
35
- // src/functions/fast-clone.js
36
- var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
47
+ // src/context/components.context.ts
48
+ import { createContext as createContext2 } from "solid-js";
49
+ var components_context_default = createContext2({ registeredComponents: {} });
37
50
 
38
- // src/constants/device-sizes.js
39
- var SIZES = {
40
- small: {
41
- min: 320,
42
- default: 321,
43
- max: 640
44
- },
45
- medium: {
46
- min: 641,
47
- default: 642,
48
- max: 991
49
- },
50
- large: {
51
- min: 990,
52
- default: 991,
53
- max: 1200
54
- }
55
- };
56
- var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
57
- var getSizesForBreakpoints = ({
58
- small,
59
- medium
60
- }) => {
61
- const newSizes = fastClone(SIZES);
62
- if (!small || !medium) {
63
- return newSizes;
64
- }
65
- const smallMin = Math.floor(small / 2);
66
- newSizes.small = {
67
- max: small,
68
- min: smallMin,
69
- default: smallMin + 1
70
- };
71
- const mediumMin = newSizes.small.max + 1;
72
- newSizes.medium = {
73
- max: medium,
74
- min: mediumMin,
75
- default: mediumMin + 1
76
- };
77
- const largeMin = newSizes.medium.max + 1;
78
- newSizes.large = {
79
- max: 2e3,
80
- min: largeMin,
81
- default: largeMin + 1
82
- };
83
- return newSizes;
84
- };
51
+ // src/components/block/block.tsx
52
+ import { Show as Show5, For as For2, createSignal as createSignal4 } from "solid-js";
85
53
 
86
- // src/constants/target.js
87
- var TARGET = "solid";
54
+ // src/functions/get-block-component-options.ts
55
+ function getBlockComponentOptions(block) {
56
+ return {
57
+ ...block.component?.options,
58
+ ...block.options,
59
+ /**
60
+ * Our built-in components frequently make use of the block, so we provide all of it under `builderBlock`
61
+ */
62
+ builderBlock: block
63
+ };
64
+ }
88
65
 
89
- // src/helpers/logger.js
66
+ // src/helpers/logger.ts
90
67
  var logger = {
91
68
  log: (...message) => void 0,
92
69
  error: (...message) => void 0,
@@ -94,22 +71,25 @@ var logger = {
94
71
  debug: (...message) => void 0
95
72
  };
96
73
 
97
- // src/functions/is-browser.js
74
+ // src/functions/is-browser.ts
98
75
  function isBrowser() {
99
76
  return typeof window !== "undefined" && typeof document !== "undefined";
100
77
  }
101
78
 
102
- // src/functions/is-iframe.js
79
+ // src/constants/target.ts
80
+ var TARGET = "solid";
81
+
82
+ // src/functions/is-iframe.ts
103
83
  function isIframe() {
104
84
  return isBrowser() && window.self !== window.top;
105
85
  }
106
86
 
107
- // src/functions/is-editing.js
87
+ // src/functions/is-editing.ts
108
88
  function isEditing() {
109
89
  return isIframe() && (TARGET === "reactNative" || window.location.search.indexOf("builder.frameEditing=") !== -1);
110
90
  }
111
91
 
112
- // src/functions/track/helpers.js
92
+ // src/functions/track/helpers.ts
113
93
  var getLocation = () => {
114
94
  if (TARGET === "reactNative") {
115
95
  return null;
@@ -149,13 +129,13 @@ var getUserAttributes = () => {
149
129
  const isTablet = userAgent.match(/Tablet|iPad/i);
150
130
  const url = getLocation();
151
131
  return {
152
- urlPath: url == null ? void 0 : url.pathname,
153
- host: (url == null ? void 0 : url.host) || (url == null ? void 0 : url.hostname),
132
+ urlPath: url?.pathname,
133
+ host: url?.host || url?.hostname,
154
134
  device: isTablet ? "tablet" : isMobile.any() ? "mobile" : "desktop"
155
135
  };
156
136
  };
157
137
 
158
- // src/functions/evaluate/helpers.js
138
+ // src/functions/evaluate/helpers.ts
159
139
  var getFunctionArguments = ({
160
140
  builder,
161
141
  context,
@@ -165,6 +145,7 @@ var getFunctionArguments = ({
165
145
  return Object.entries({
166
146
  state,
167
147
  Builder: builder,
148
+ // legacy
168
149
  builder,
169
150
  context,
170
151
  event
@@ -179,12 +160,15 @@ var getBuilderGlobals = () => ({
179
160
  var parseCode = (code, {
180
161
  isExpression = true
181
162
  }) => {
182
- const useReturn = isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "));
163
+ const useReturn = (
164
+ // we disable this for cases where we definitely don't want a return
165
+ isExpression && !(code.includes(";") || code.includes(" return ") || code.trim().startsWith("return "))
166
+ );
183
167
  const useCode = useReturn ? `return (${code});` : code;
184
168
  return useCode;
185
169
  };
186
170
 
187
- // src/functions/evaluate/browser-runtime/browser.js
171
+ // src/functions/evaluate/browser-runtime/browser.ts
188
172
  var runInBrowser = ({
189
173
  code,
190
174
  builder,
@@ -218,21 +202,16 @@ function flattenState(rootState, localState, rootSetState) {
218
202
  throw new Error("Writing to local state is not allowed as it is read-only.");
219
203
  }
220
204
  rootState[prop] = value;
221
- rootSetState == null ? void 0 : rootSetState(rootState);
205
+ rootSetState?.(rootState);
222
206
  return true;
223
207
  }
224
208
  });
225
209
  }
226
210
 
227
- // src/functions/evaluate/node-runtime/safeDynamicRequire.js
228
- var noop = () => null;
229
- var safeDynamicRequire = noop;
230
- try {
231
- safeDynamicRequire = eval("require");
232
- } catch (error) {
233
- }
211
+ // src/functions/fast-clone.ts
212
+ var fastClone = (obj) => JSON.parse(JSON.stringify(obj));
234
213
 
235
- // src/functions/set.js
214
+ // src/functions/set.ts
236
215
  var set = (obj, _path, value) => {
237
216
  if (Object(obj) !== obj) {
238
217
  return obj;
@@ -242,31 +221,16 @@ var set = (obj, _path, value) => {
242
221
  return obj;
243
222
  };
244
223
 
245
- // src/functions/evaluate/node-runtime/node-runtime.js
246
- var __defProp = Object.defineProperty;
247
- var __defProps = Object.defineProperties;
248
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
249
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
250
- var __hasOwnProp = Object.prototype.hasOwnProperty;
251
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
252
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
253
- enumerable: true,
254
- configurable: true,
255
- writable: true,
256
- value
257
- }) : obj[key] = value;
258
- var __spreadValues = (a, b) => {
259
- for (var prop in b || (b = {}))
260
- if (__hasOwnProp.call(b, prop))
261
- __defNormalProp(a, prop, b[prop]);
262
- if (__getOwnPropSymbols)
263
- for (var prop of __getOwnPropSymbols(b)) {
264
- if (__propIsEnum.call(b, prop))
265
- __defNormalProp(a, prop, b[prop]);
266
- }
267
- return a;
268
- };
269
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
224
+ // src/functions/evaluate/node-runtime/safeDynamicRequire.ts
225
+ import { createRequire } from "node:module";
226
+ var noop = () => null;
227
+ var safeDynamicRequire = noop;
228
+ try {
229
+ safeDynamicRequire = createRequire(import.meta.url);
230
+ } catch (error) {
231
+ }
232
+
233
+ // src/functions/evaluate/node-runtime/node-runtime.ts
270
234
  var ivm = safeDynamicRequire("isolated-vm");
271
235
  var getSyncValName = (key) => `bldr_${key}_sync`;
272
236
  var BUILDER_SET_STATE_NAME = "BUILDER_SET_STATE";
@@ -334,7 +298,10 @@ var runInNode = ({
334
298
  rootSetState,
335
299
  rootState
336
300
  }) => {
337
- const state = fastClone(__spreadValues(__spreadValues({}, rootState), localState));
301
+ const state = fastClone({
302
+ ...rootState,
303
+ ...localState
304
+ });
338
305
  const args = getFunctionArguments({
339
306
  builder,
340
307
  context,
@@ -348,12 +315,16 @@ var runInNode = ({
348
315
  });
349
316
  jail.setSync(BUILDER_SET_STATE_NAME, function(key, value) {
350
317
  set(rootState, key, value);
351
- rootSetState == null ? void 0 : rootSetState(rootState);
318
+ rootSetState?.(rootState);
352
319
  });
353
320
  args.forEach(([key, arg]) => {
354
- const val = typeof arg === "object" ? new ivm.Reference(key === "builder" ? __spreadProps(__spreadValues({}, arg), {
355
- getUserAttributes: () => arg.getUserAttributes()
356
- }) : arg) : null;
321
+ const val = typeof arg === "object" ? new ivm.Reference(
322
+ // workaround: methods with default values for arguments is not being cloned over
323
+ key === "builder" ? {
324
+ ...arg,
325
+ getUserAttributes: () => arg.getUserAttributes()
326
+ } : arg
327
+ ) : null;
357
328
  jail.setSync(getSyncValName(key), val);
358
329
  });
359
330
  jail.setSync(INJECTED_IVM_GLOBAL, ivm);
@@ -370,10 +341,10 @@ var runInNode = ({
370
341
  }
371
342
  };
372
343
 
373
- // src/functions/evaluate/choose-eval.js
344
+ // src/functions/evaluate/choose-eval.ts
374
345
  var chooseBrowserOrServerEval = (args) => isBrowser() ? runInBrowser(args) : runInNode(args);
375
346
 
376
- // src/functions/evaluate/evaluate.js
347
+ // src/functions/evaluate/evaluate.ts
377
348
  function evaluate({
378
349
  code,
379
350
  context,
@@ -408,36 +379,12 @@ function evaluate({
408
379
  }
409
380
  }
410
381
 
411
- // src/functions/transform-block.js
382
+ // src/functions/transform-block.ts
412
383
  function transformBlock(block) {
413
384
  return block;
414
385
  }
415
386
 
416
- // src/functions/get-processed-block.js
417
- var __defProp2 = Object.defineProperty;
418
- var __defProps2 = Object.defineProperties;
419
- var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
420
- var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
421
- var __hasOwnProp2 = Object.prototype.hasOwnProperty;
422
- var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
423
- var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, {
424
- enumerable: true,
425
- configurable: true,
426
- writable: true,
427
- value
428
- }) : obj[key] = value;
429
- var __spreadValues2 = (a, b) => {
430
- for (var prop in b || (b = {}))
431
- if (__hasOwnProp2.call(b, prop))
432
- __defNormalProp2(a, prop, b[prop]);
433
- if (__getOwnPropSymbols2)
434
- for (var prop of __getOwnPropSymbols2(b)) {
435
- if (__propIsEnum2.call(b, prop))
436
- __defNormalProp2(a, prop, b[prop]);
437
- }
438
- return a;
439
- };
440
- var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
387
+ // src/functions/get-processed-block.ts
441
388
  var evaluateBindings = ({
442
389
  block,
443
390
  context,
@@ -449,10 +396,15 @@ var evaluateBindings = ({
449
396
  return block;
450
397
  }
451
398
  const copy = fastClone(block);
452
- const copied = __spreadProps2(__spreadValues2({}, copy), {
453
- properties: __spreadValues2({}, copy.properties),
454
- actions: __spreadValues2({}, copy.actions)
455
- });
399
+ const copied = {
400
+ ...copy,
401
+ properties: {
402
+ ...copy.properties
403
+ },
404
+ actions: {
405
+ ...copy.actions
406
+ }
407
+ };
456
408
  for (const binding in block.bindings) {
457
409
  const expression = block.bindings[binding];
458
410
  const value = evaluate({
@@ -488,13 +440,132 @@ function getProcessedBlock({
488
440
  }
489
441
  }
490
442
 
491
- // src/functions/camel-to-kebab-case.js
443
+ // src/components/block/block.helpers.ts
444
+ var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
445
+ var isEmptyHtmlElement = (tagName) => {
446
+ return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
447
+ };
448
+ var getComponent = ({
449
+ block,
450
+ context,
451
+ registeredComponents
452
+ }) => {
453
+ const componentName = getProcessedBlock({
454
+ block,
455
+ localState: context.localState,
456
+ rootState: context.rootState,
457
+ rootSetState: context.rootSetState,
458
+ context: context.context,
459
+ shouldEvaluateBindings: false
460
+ }).component?.name;
461
+ if (!componentName) {
462
+ return null;
463
+ }
464
+ const ref = registeredComponents[componentName];
465
+ if (!ref) {
466
+ return void 0;
467
+ } else {
468
+ return ref;
469
+ }
470
+ };
471
+ var getRepeatItemData = ({
472
+ block,
473
+ context
474
+ }) => {
475
+ const {
476
+ repeat,
477
+ ...blockWithoutRepeat
478
+ } = block;
479
+ if (!repeat?.collection) {
480
+ return void 0;
481
+ }
482
+ const itemsArray = evaluate({
483
+ code: repeat.collection,
484
+ localState: context.localState,
485
+ rootState: context.rootState,
486
+ rootSetState: context.rootSetState,
487
+ context: context.context
488
+ });
489
+ if (!Array.isArray(itemsArray)) {
490
+ return void 0;
491
+ }
492
+ const collectionName = repeat.collection.split(".").pop();
493
+ const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
494
+ const repeatArray = itemsArray.map((item, index) => ({
495
+ context: {
496
+ ...context,
497
+ localState: {
498
+ ...context.localState,
499
+ $index: index,
500
+ $item: item,
501
+ [itemNameToUse]: item,
502
+ [`$${itemNameToUse}Index`]: index
503
+ }
504
+ },
505
+ block: blockWithoutRepeat
506
+ }));
507
+ return repeatArray;
508
+ };
509
+
510
+ // src/components/block/components/block-styles.tsx
511
+ import { Show as Show2 } from "solid-js";
512
+
513
+ // src/constants/device-sizes.ts
514
+ var SIZES = {
515
+ small: {
516
+ min: 320,
517
+ default: 321,
518
+ max: 640
519
+ },
520
+ medium: {
521
+ min: 641,
522
+ default: 642,
523
+ max: 991
524
+ },
525
+ large: {
526
+ min: 990,
527
+ default: 991,
528
+ max: 1200
529
+ }
530
+ };
531
+ var getMaxWidthQueryForSize = (size, sizeValues = SIZES) => `@media (max-width: ${sizeValues[size].max}px)`;
532
+ var getSizesForBreakpoints = ({
533
+ small,
534
+ medium
535
+ }) => {
536
+ const newSizes = fastClone(SIZES);
537
+ if (!small || !medium) {
538
+ return newSizes;
539
+ }
540
+ const smallMin = Math.floor(small / 2);
541
+ newSizes.small = {
542
+ max: small,
543
+ min: smallMin,
544
+ default: smallMin + 1
545
+ };
546
+ const mediumMin = newSizes.small.max + 1;
547
+ newSizes.medium = {
548
+ max: medium,
549
+ min: mediumMin,
550
+ default: mediumMin + 1
551
+ };
552
+ const largeMin = newSizes.medium.max + 1;
553
+ newSizes.large = {
554
+ max: 2e3,
555
+ // TODO: decide upper limit
556
+ min: largeMin,
557
+ default: largeMin + 1
558
+ };
559
+ return newSizes;
560
+ };
561
+
562
+ // src/functions/camel-to-kebab-case.ts
492
563
  var camelToKebabCase = (string) => string.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
493
564
 
494
- // src/helpers/nullable.js
565
+ // src/helpers/nullable.ts
495
566
  var checkIsDefined = (maybeT) => maybeT !== null && maybeT !== void 0;
496
567
 
497
- // src/helpers/css.js
568
+ // src/helpers/css.ts
498
569
  var convertStyleMapToCSSArray = (style) => {
499
570
  const cssProps = Object.entries(style).map(([key, value]) => {
500
571
  if (typeof value === "string") {
@@ -523,13 +594,13 @@ var createCssClass = ({
523
594
  }
524
595
  };
525
596
 
526
- // src/components/inlined-styles.jsx
597
+ // src/components/inlined-styles.tsx
527
598
  function InlinedStyles(props) {
528
599
  return <style innerHTML={props.styles} id={props.id} />;
529
600
  }
530
601
  var Inlined_styles_default = InlinedStyles;
531
602
 
532
- // src/components/block/components/block-styles.jsx
603
+ // src/components/block/components/block-styles.tsx
533
604
  function BlockStyles(props) {
534
605
  function canShowBlock() {
535
606
  const processedBlock = getProcessedBlock({
@@ -595,66 +666,54 @@ function BlockStyles(props) {
595
666
  }
596
667
  var Block_styles_default = BlockStyles;
597
668
 
598
- // src/components/block/block.jsx
599
- import { Show as Show5, For as For2, createSignal as createSignal4 } from "solid-js";
669
+ // src/components/block/components/block-wrapper.tsx
670
+ import { Show as Show3 } from "solid-js";
671
+ import { Dynamic } from "solid-js/web";
600
672
 
601
- // src/functions/get-block-component-options.js
602
- var __defProp3 = Object.defineProperty;
603
- var __defProps3 = Object.defineProperties;
604
- var __getOwnPropDescs3 = Object.getOwnPropertyDescriptors;
605
- var __getOwnPropSymbols3 = Object.getOwnPropertySymbols;
606
- var __hasOwnProp3 = Object.prototype.hasOwnProperty;
607
- var __propIsEnum3 = Object.prototype.propertyIsEnumerable;
608
- var __defNormalProp3 = (obj, key, value) => key in obj ? __defProp3(obj, key, {
609
- enumerable: true,
610
- configurable: true,
611
- writable: true,
612
- value
613
- }) : obj[key] = value;
614
- var __spreadValues3 = (a, b) => {
615
- for (var prop in b || (b = {}))
616
- if (__hasOwnProp3.call(b, prop))
617
- __defNormalProp3(a, prop, b[prop]);
618
- if (__getOwnPropSymbols3)
619
- for (var prop of __getOwnPropSymbols3(b)) {
620
- if (__propIsEnum3.call(b, prop))
621
- __defNormalProp3(a, prop, b[prop]);
622
- }
623
- return a;
624
- };
625
- var __spreadProps3 = (a, b) => __defProps3(a, __getOwnPropDescs3(b));
626
- function getBlockComponentOptions(block) {
627
- var _a;
628
- return __spreadProps3(__spreadValues3(__spreadValues3({}, (_a = block.component) == null ? void 0 : _a.options), block.options), {
629
- builderBlock: block
630
- });
673
+ // src/functions/event-handler-name.ts
674
+ function capitalizeFirstLetter(string) {
675
+ return string.charAt(0).toUpperCase() + string.slice(1);
631
676
  }
677
+ var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
632
678
 
633
- // src/functions/sanitize-react-native-block-styles.js
634
- var __defProp4 = Object.defineProperty;
635
- var __defProps4 = Object.defineProperties;
636
- var __getOwnPropDescs4 = Object.getOwnPropertyDescriptors;
637
- var __getOwnPropSymbols4 = Object.getOwnPropertySymbols;
638
- var __hasOwnProp4 = Object.prototype.hasOwnProperty;
639
- var __propIsEnum4 = Object.prototype.propertyIsEnumerable;
640
- var __defNormalProp4 = (obj, key, value) => key in obj ? __defProp4(obj, key, {
641
- enumerable: true,
642
- configurable: true,
643
- writable: true,
644
- value
645
- }) : obj[key] = value;
646
- var __spreadValues4 = (a, b) => {
647
- for (var prop in b || (b = {}))
648
- if (__hasOwnProp4.call(b, prop))
649
- __defNormalProp4(a, prop, b[prop]);
650
- if (__getOwnPropSymbols4)
651
- for (var prop of __getOwnPropSymbols4(b)) {
652
- if (__propIsEnum4.call(b, prop))
653
- __defNormalProp4(a, prop, b[prop]);
679
+ // src/functions/get-block-actions-handler.ts
680
+ var createEventHandler = (value, options) => (event) => evaluate({
681
+ code: value,
682
+ context: options.context,
683
+ localState: options.localState,
684
+ rootState: options.rootState,
685
+ rootSetState: options.rootSetState,
686
+ event,
687
+ isExpression: false
688
+ });
689
+
690
+ // src/functions/get-block-actions.ts
691
+ function getBlockActions(options) {
692
+ const obj = {};
693
+ const optionActions = options.block.actions ?? {};
694
+ for (const key in optionActions) {
695
+ if (!optionActions.hasOwnProperty(key)) {
696
+ continue;
654
697
  }
655
- return a;
656
- };
657
- var __spreadProps4 = (a, b) => __defProps4(a, __getOwnPropDescs4(b));
698
+ const value = optionActions[key];
699
+ let eventHandlerName = getEventHandlerName(key);
700
+ if (options.stripPrefix) {
701
+ switch (TARGET) {
702
+ case "vue2":
703
+ case "vue3":
704
+ eventHandlerName = eventHandlerName.replace("v-on:", "");
705
+ break;
706
+ case "svelte":
707
+ eventHandlerName = eventHandlerName.replace("on:", "");
708
+ break;
709
+ }
710
+ }
711
+ obj[eventHandlerName] = createEventHandler(value, options);
712
+ }
713
+ return obj;
714
+ }
715
+
716
+ // src/functions/sanitize-react-native-block-styles.ts
658
717
  var propertiesThatMustBeNumber = /* @__PURE__ */ new Set(["lineHeight"]);
659
718
  var displayValues = /* @__PURE__ */ new Set(["flex", "none"]);
660
719
  var SHOW_WARNINGS = false;
@@ -686,46 +745,28 @@ var sanitizeReactNativeBlockStyles = (styles) => {
686
745
  const newValue = parseFloat(propertyValue);
687
746
  const normalizedValue = normalizeNumber(newValue);
688
747
  if (normalizedValue) {
689
- return __spreadProps4(__spreadValues4({}, acc), {
748
+ return {
749
+ ...acc,
690
750
  [key]: normalizedValue
691
- });
751
+ };
692
752
  } else {
693
753
  return acc;
694
754
  }
695
755
  } else if (propertyValue === "0") {
696
- return __spreadProps4(__spreadValues4({}, acc), {
756
+ return {
757
+ ...acc,
697
758
  [key]: 0
698
- });
759
+ };
699
760
  }
700
761
  }
701
- return __spreadProps4(__spreadValues4({}, acc), {
762
+ return {
763
+ ...acc,
702
764
  [key]: propertyValue
703
- });
765
+ };
704
766
  }, {});
705
767
  };
706
768
 
707
- // src/functions/get-react-native-block-styles.js
708
- var __defProp5 = Object.defineProperty;
709
- var __getOwnPropSymbols5 = Object.getOwnPropertySymbols;
710
- var __hasOwnProp5 = Object.prototype.hasOwnProperty;
711
- var __propIsEnum5 = Object.prototype.propertyIsEnumerable;
712
- var __defNormalProp5 = (obj, key, value) => key in obj ? __defProp5(obj, key, {
713
- enumerable: true,
714
- configurable: true,
715
- writable: true,
716
- value
717
- }) : obj[key] = value;
718
- var __spreadValues5 = (a, b) => {
719
- for (var prop in b || (b = {}))
720
- if (__hasOwnProp5.call(b, prop))
721
- __defNormalProp5(a, prop, b[prop]);
722
- if (__getOwnPropSymbols5)
723
- for (var prop of __getOwnPropSymbols5(b)) {
724
- if (__propIsEnum5.call(b, prop))
725
- __defNormalProp5(a, prop, b[prop]);
726
- }
727
- return a;
728
- };
769
+ // src/functions/get-react-native-block-styles.ts
729
770
  function getReactNativeBlockStyles({
730
771
  block,
731
772
  context,
@@ -735,41 +776,24 @@ function getReactNativeBlockStyles({
735
776
  if (!responsiveStyles) {
736
777
  return {};
737
778
  }
738
- const styles = __spreadValues5(__spreadValues5(__spreadValues5(__spreadValues5(__spreadValues5({}, context.inheritedStyles), responsiveStyles.large || {}), responsiveStyles.medium || {}), responsiveStyles.small || {}), blockStyles);
779
+ const styles = {
780
+ // recursively apply inherited styles so that they can be passed down to children `Text` blocks
781
+ ...context.inheritedStyles,
782
+ ...responsiveStyles.large || {},
783
+ ...responsiveStyles.medium || {},
784
+ ...responsiveStyles.small || {},
785
+ ...blockStyles
786
+ };
739
787
  const newStyles = sanitizeReactNativeBlockStyles(styles);
740
788
  return newStyles;
741
789
  }
742
790
 
743
- // src/functions/transform-block-properties.js
791
+ // src/functions/transform-block-properties.ts
744
792
  function transformBlockProperties(properties) {
745
793
  return properties;
746
794
  }
747
795
 
748
- // src/functions/get-block-properties.js
749
- var __defProp6 = Object.defineProperty;
750
- var __defProps5 = Object.defineProperties;
751
- var __getOwnPropDescs5 = Object.getOwnPropertyDescriptors;
752
- var __getOwnPropSymbols6 = Object.getOwnPropertySymbols;
753
- var __hasOwnProp6 = Object.prototype.hasOwnProperty;
754
- var __propIsEnum6 = Object.prototype.propertyIsEnumerable;
755
- var __defNormalProp6 = (obj, key, value) => key in obj ? __defProp6(obj, key, {
756
- enumerable: true,
757
- configurable: true,
758
- writable: true,
759
- value
760
- }) : obj[key] = value;
761
- var __spreadValues6 = (a, b) => {
762
- for (var prop in b || (b = {}))
763
- if (__hasOwnProp6.call(b, prop))
764
- __defNormalProp6(a, prop, b[prop]);
765
- if (__getOwnPropSymbols6)
766
- for (var prop of __getOwnPropSymbols6(b)) {
767
- if (__propIsEnum6.call(b, prop))
768
- __defNormalProp6(a, prop, b[prop]);
769
- }
770
- return a;
771
- };
772
- var __spreadProps5 = (a, b) => __defProps5(a, __getOwnPropDescs5(b));
796
+ // src/functions/get-block-properties.ts
773
797
  var extractRelevantRootBlockProperties = (block) => {
774
798
  return {
775
799
  href: block.href
@@ -779,12 +803,13 @@ function getBlockProperties({
779
803
  block,
780
804
  context
781
805
  }) {
782
- var _a;
783
- const properties = __spreadProps5(__spreadValues6(__spreadValues6({}, extractRelevantRootBlockProperties(block)), block.properties), {
806
+ const properties = {
807
+ ...extractRelevantRootBlockProperties(block),
808
+ ...block.properties,
784
809
  "builder-id": block.id,
785
810
  style: block.style ? getStyleAttribute(block.style) : void 0,
786
- class: [block.id, "builder-block", block.class, (_a = block.properties) == null ? void 0 : _a.class].filter(Boolean).join(" ")
787
- });
811
+ class: [block.id, "builder-block", block.class, block.properties?.class].filter(Boolean).join(" ")
812
+ };
788
813
  if (TARGET === "reactNative") {
789
814
  properties.style = getReactNativeBlockStyles({
790
815
  block,
@@ -809,190 +834,51 @@ function getStyleAttribute(style) {
809
834
  }
810
835
  }
811
836
 
812
- // src/components/block/block.helpers.js
813
- var __defProp7 = Object.defineProperty;
814
- var __defProps6 = Object.defineProperties;
815
- var __getOwnPropDescs6 = Object.getOwnPropertyDescriptors;
816
- var __getOwnPropSymbols7 = Object.getOwnPropertySymbols;
817
- var __hasOwnProp7 = Object.prototype.hasOwnProperty;
818
- var __propIsEnum7 = Object.prototype.propertyIsEnumerable;
819
- var __defNormalProp7 = (obj, key, value) => key in obj ? __defProp7(obj, key, {
820
- enumerable: true,
821
- configurable: true,
822
- writable: true,
823
- value
824
- }) : obj[key] = value;
825
- var __spreadValues7 = (a, b) => {
826
- for (var prop in b || (b = {}))
827
- if (__hasOwnProp7.call(b, prop))
828
- __defNormalProp7(a, prop, b[prop]);
829
- if (__getOwnPropSymbols7)
830
- for (var prop of __getOwnPropSymbols7(b)) {
831
- if (__propIsEnum7.call(b, prop))
832
- __defNormalProp7(a, prop, b[prop]);
833
- }
834
- return a;
835
- };
836
- var __spreadProps6 = (a, b) => __defProps6(a, __getOwnPropDescs6(b));
837
- var __objRest = (source, exclude) => {
838
- var target = {};
839
- for (var prop in source)
840
- if (__hasOwnProp7.call(source, prop) && exclude.indexOf(prop) < 0)
841
- target[prop] = source[prop];
842
- if (source != null && __getOwnPropSymbols7)
843
- for (var prop of __getOwnPropSymbols7(source)) {
844
- if (exclude.indexOf(prop) < 0 && __propIsEnum7.call(source, prop))
845
- target[prop] = source[prop];
846
- }
847
- return target;
848
- };
849
- var EMPTY_HTML_ELEMENTS = ["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
850
- var isEmptyHtmlElement = (tagName) => {
851
- return typeof tagName === "string" && EMPTY_HTML_ELEMENTS.includes(tagName.toLowerCase());
852
- };
853
- var getComponent = ({
854
- block,
855
- context,
856
- registeredComponents
857
- }) => {
858
- var _a;
859
- const componentName = (_a = getProcessedBlock({
860
- block,
861
- localState: context.localState,
862
- rootState: context.rootState,
863
- rootSetState: context.rootSetState,
864
- context: context.context,
865
- shouldEvaluateBindings: false
866
- }).component) == null ? void 0 : _a.name;
867
- if (!componentName) {
868
- return null;
869
- }
870
- const ref = registeredComponents[componentName];
871
- if (!ref) {
872
- return void 0;
873
- } else {
874
- return ref;
875
- }
876
- };
877
- var getRepeatItemData = ({
878
- block,
879
- context
880
- }) => {
881
- const _a = block, {
882
- repeat
883
- } = _a, blockWithoutRepeat = __objRest(_a, ["repeat"]);
884
- if (!(repeat == null ? void 0 : repeat.collection)) {
885
- return void 0;
886
- }
887
- const itemsArray = evaluate({
888
- code: repeat.collection,
889
- localState: context.localState,
890
- rootState: context.rootState,
891
- rootSetState: context.rootSetState,
892
- context: context.context
893
- });
894
- if (!Array.isArray(itemsArray)) {
895
- return void 0;
896
- }
897
- const collectionName = repeat.collection.split(".").pop();
898
- const itemNameToUse = repeat.itemName || (collectionName ? collectionName + "Item" : "item");
899
- const repeatArray = itemsArray.map((item, index) => ({
900
- context: __spreadProps6(__spreadValues7({}, context), {
901
- localState: __spreadProps6(__spreadValues7({}, context.localState), {
902
- $index: index,
903
- $item: item,
904
- [itemNameToUse]: item,
905
- [`$${itemNameToUse}Index`]: index
906
- })
907
- }),
908
- block: blockWithoutRepeat
909
- }));
910
- return repeatArray;
911
- };
912
-
913
- // src/components/block/components/repeated-block.jsx
914
- import { createSignal as createSignal2 } from "solid-js";
915
-
916
- // src/context/builder.context.js
917
- import { createContext } from "solid-js";
918
- var stdin_default = createContext({
919
- content: null,
920
- context: {},
921
- localState: void 0,
922
- rootSetState() {
923
- },
924
- rootState: {},
925
- apiKey: null,
926
- apiVersion: void 0,
927
- componentInfos: {},
928
- inheritedStyles: {}
929
- });
930
-
931
- // src/components/block/components/repeated-block.jsx
932
- function RepeatedBlock(props) {
933
- const [store, setStore] = createSignal2(props.repeatContext);
934
- return <stdin_default.Provider value={store()}><Block_default
935
- block={props.block}
936
- context={store()}
937
- registeredComponents={props.registeredComponents}
938
- /></stdin_default.Provider>;
939
- }
940
- var Repeated_block_default = RepeatedBlock;
941
-
942
- // src/components/block/components/component-ref/component-ref.jsx
943
- import { Show as Show3, For, createSignal as createSignal3 } from "solid-js";
944
- import { Dynamic as Dynamic2 } from "solid-js/web";
945
-
946
- // src/components/block/components/interactive-element.jsx
947
- import { Dynamic } from "solid-js/web";
948
-
949
- // src/functions/event-handler-name.js
950
- function capitalizeFirstLetter(string) {
951
- return string.charAt(0).toUpperCase() + string.slice(1);
837
+ // src/components/block/components/block-wrapper.tsx
838
+ function BlockWrapper(props) {
839
+ return <Show3
840
+ fallback={<Dynamic
841
+ {...getBlockProperties({
842
+ block: props.block,
843
+ context: props.context
844
+ })}
845
+ {...getBlockActions({
846
+ block: props.block,
847
+ rootState: props.context.rootState,
848
+ rootSetState: props.context.rootSetState,
849
+ localState: props.context.localState,
850
+ context: props.context.context,
851
+ stripPrefix: true
852
+ })}
853
+ component={props.Wrapper}
854
+ />}
855
+ when={props.hasChildren}
856
+ ><Dynamic
857
+ {...getBlockProperties({
858
+ block: props.block,
859
+ context: props.context
860
+ })}
861
+ {...getBlockActions({
862
+ block: props.block,
863
+ rootState: props.context.rootState,
864
+ rootSetState: props.context.rootSetState,
865
+ localState: props.context.localState,
866
+ context: props.context.context,
867
+ stripPrefix: true
868
+ })}
869
+ component={props.Wrapper}
870
+ >{props.children}</Dynamic></Show3>;
952
871
  }
953
- var getEventHandlerName = (key) => `on${capitalizeFirstLetter(key)}`;
954
-
955
- // src/functions/get-block-actions-handler.js
956
- var createEventHandler = (value, options) => (event) => evaluate({
957
- code: value,
958
- context: options.context,
959
- localState: options.localState,
960
- rootState: options.rootState,
961
- rootSetState: options.rootSetState,
962
- event,
963
- isExpression: false
964
- });
872
+ var Block_wrapper_default = BlockWrapper;
965
873
 
966
- // src/functions/get-block-actions.js
967
- function getBlockActions(options) {
968
- var _a;
969
- const obj = {};
970
- const optionActions = (_a = options.block.actions) != null ? _a : {};
971
- for (const key in optionActions) {
972
- if (!optionActions.hasOwnProperty(key)) {
973
- continue;
974
- }
975
- const value = optionActions[key];
976
- let eventHandlerName = getEventHandlerName(key);
977
- if (options.stripPrefix) {
978
- switch (TARGET) {
979
- case "vue2":
980
- case "vue3":
981
- eventHandlerName = eventHandlerName.replace("v-on:", "");
982
- break;
983
- case "svelte":
984
- eventHandlerName = eventHandlerName.replace("on:", "");
985
- break;
986
- }
987
- }
988
- obj[eventHandlerName] = createEventHandler(value, options);
989
- }
990
- return obj;
991
- }
874
+ // src/components/block/components/component-ref/component-ref.tsx
875
+ import { Show as Show4, For, createSignal as createSignal2 } from "solid-js";
876
+ import { Dynamic as Dynamic3 } from "solid-js/web";
992
877
 
993
- // src/components/block/components/interactive-element.jsx
878
+ // src/components/block/components/interactive-element.tsx
879
+ import { Dynamic as Dynamic2 } from "solid-js/web";
994
880
  function InteractiveElement(props) {
995
- return <Dynamic
881
+ return <Dynamic2
996
882
  {...props.wrapperProps}
997
883
  attributes={{
998
884
  ...getBlockProperties({
@@ -1008,32 +894,11 @@ function InteractiveElement(props) {
1008
894
  })
1009
895
  }}
1010
896
  component={props.Wrapper}
1011
- >{props.children}</Dynamic>;
897
+ >{props.children}</Dynamic2>;
1012
898
  }
1013
899
  var interactive_element_default = InteractiveElement;
1014
900
 
1015
- // src/components/block/components/component-ref/component-ref.helpers.js
1016
- var __defProp8 = Object.defineProperty;
1017
- var __getOwnPropSymbols8 = Object.getOwnPropertySymbols;
1018
- var __hasOwnProp8 = Object.prototype.hasOwnProperty;
1019
- var __propIsEnum8 = Object.prototype.propertyIsEnumerable;
1020
- var __defNormalProp8 = (obj, key, value) => key in obj ? __defProp8(obj, key, {
1021
- enumerable: true,
1022
- configurable: true,
1023
- writable: true,
1024
- value
1025
- }) : obj[key] = value;
1026
- var __spreadValues8 = (a, b) => {
1027
- for (var prop in b || (b = {}))
1028
- if (__hasOwnProp8.call(b, prop))
1029
- __defNormalProp8(a, prop, b[prop]);
1030
- if (__getOwnPropSymbols8)
1031
- for (var prop of __getOwnPropSymbols8(b)) {
1032
- if (__propIsEnum8.call(b, prop))
1033
- __defNormalProp8(a, prop, b[prop]);
1034
- }
1035
- return a;
1036
- };
901
+ // src/components/block/components/component-ref/component-ref.helpers.ts
1037
902
  var getWrapperProps = ({
1038
903
  componentOptions,
1039
904
  builderBlock,
@@ -1049,20 +914,27 @@ var getWrapperProps = ({
1049
914
  context,
1050
915
  wrapperProps: componentOptions
1051
916
  };
1052
- return isInteractive ? interactiveElementProps : __spreadValues8(__spreadValues8({}, componentOptions), includeBlockProps ? {
1053
- attributes: getBlockProperties({
1054
- block: builderBlock,
1055
- context: contextValue
1056
- })
1057
- } : {});
917
+ return isInteractive ? interactiveElementProps : {
918
+ ...componentOptions,
919
+ /**
920
+ * If `noWrap` is set to `true`, then the block's props/attributes are provided to the
921
+ * component itself directly. Otherwise, they are provided to the wrapper element.
922
+ */
923
+ ...includeBlockProps ? {
924
+ attributes: getBlockProperties({
925
+ block: builderBlock,
926
+ context: contextValue
927
+ })
928
+ } : {}
929
+ };
1058
930
  };
1059
931
 
1060
- // src/components/block/components/component-ref/component-ref.jsx
932
+ // src/components/block/components/component-ref/component-ref.tsx
1061
933
  function ComponentRef(props) {
1062
- const [Wrapper, setWrapper] = createSignal3(
934
+ const [Wrapper, setWrapper] = createSignal2(
1063
935
  props.isInteractive ? interactive_element_default : props.componentRef
1064
936
  );
1065
- return <Show3 when={props.componentRef}><Dynamic2
937
+ return <Show4 when={props.componentRef}><Dynamic3
1066
938
  {...getWrapperProps({
1067
939
  componentOptions: props.componentOptions,
1068
940
  builderBlock: props.builderBlock,
@@ -1091,50 +963,23 @@ function ComponentRef(props) {
1091
963
  context={props.context}
1092
964
  />;
1093
965
  }}</For>
1094
- </Dynamic2></Show3>;
966
+ </Dynamic3></Show4>;
1095
967
  }
1096
968
  var Component_ref_default = ComponentRef;
1097
969
 
1098
- // src/components/block/components/block-wrapper.jsx
1099
- import { Show as Show4 } from "solid-js";
1100
- import { Dynamic as Dynamic3 } from "solid-js/web";
1101
- function BlockWrapper(props) {
1102
- return <Show4
1103
- fallback={<Dynamic3
1104
- {...getBlockProperties({
1105
- block: props.block,
1106
- context: props.context
1107
- })}
1108
- {...getBlockActions({
1109
- block: props.block,
1110
- rootState: props.context.rootState,
1111
- rootSetState: props.context.rootSetState,
1112
- localState: props.context.localState,
1113
- context: props.context.context,
1114
- stripPrefix: true
1115
- })}
1116
- component={props.Wrapper}
1117
- />}
1118
- when={props.hasChildren}
1119
- ><Dynamic3
1120
- {...getBlockProperties({
1121
- block: props.block,
1122
- context: props.context
1123
- })}
1124
- {...getBlockActions({
1125
- block: props.block,
1126
- rootState: props.context.rootState,
1127
- rootSetState: props.context.rootSetState,
1128
- localState: props.context.localState,
1129
- context: props.context.context,
1130
- stripPrefix: true
1131
- })}
1132
- component={props.Wrapper}
1133
- >{props.children}</Dynamic3></Show4>;
970
+ // src/components/block/components/repeated-block.tsx
971
+ import { createSignal as createSignal3 } from "solid-js";
972
+ function RepeatedBlock(props) {
973
+ const [store, setStore] = createSignal3(props.repeatContext);
974
+ return <builder_context_default.Provider value={store()}><Block_default
975
+ block={props.block}
976
+ context={store()}
977
+ registeredComponents={props.registeredComponents}
978
+ /></builder_context_default.Provider>;
1134
979
  }
1135
- var Block_wrapper_default = BlockWrapper;
980
+ var Repeated_block_default = RepeatedBlock;
1136
981
 
1137
- // src/components/block/block.jsx
982
+ // src/components/block/block.tsx
1138
983
  function Block(props) {
1139
984
  const [childrenContext, setChildrenContext] = createSignal4(props.context);
1140
985
  function blockComponent() {
@@ -1195,7 +1040,16 @@ function Block(props) {
1195
1040
  };
1196
1041
  }
1197
1042
  return <Show5 when={canShowBlock()}><Show5
1198
- fallback={<Component_ref_default {...componentRefProps()} />}
1043
+ fallback={<Component_ref_default
1044
+ componentRef={componentRefProps().componentRef}
1045
+ componentOptions={componentRefProps().componentOptions}
1046
+ blockChildren={componentRefProps().blockChildren}
1047
+ context={componentRefProps().context}
1048
+ registeredComponents={componentRefProps().registeredComponents}
1049
+ builderBlock={componentRefProps().builderBlock}
1050
+ includeBlockProps={componentRefProps().includeBlockProps}
1051
+ isInteractive={componentRefProps().isInteractive}
1052
+ />}
1199
1053
  when={!blockComponent()?.noWrap}
1200
1054
  >
1201
1055
  <Show5 when={isEmptyHtmlElement(Tag())}><Block_wrapper_default
@@ -1219,7 +1073,16 @@ function Block(props) {
1219
1073
  context={props.context}
1220
1074
  hasChildren={true}
1221
1075
  >
1222
- <Component_ref_default {...componentRefProps()} />
1076
+ <Component_ref_default
1077
+ componentRef={componentRefProps().componentRef}
1078
+ componentOptions={componentRefProps().componentOptions}
1079
+ blockChildren={componentRefProps().blockChildren}
1080
+ context={componentRefProps().context}
1081
+ registeredComponents={componentRefProps().registeredComponents}
1082
+ builderBlock={componentRefProps().builderBlock}
1083
+ includeBlockProps={componentRefProps().includeBlockProps}
1084
+ isInteractive={componentRefProps().isInteractive}
1085
+ />
1223
1086
  <For2 each={childrenWithoutParentComponent()}>{(child, _index) => {
1224
1087
  const index = _index();
1225
1088
  return <Block
@@ -1242,8 +1105,7 @@ function Block(props) {
1242
1105
  }
1243
1106
  var Block_default = Block;
1244
1107
 
1245
- // src/components/blocks/blocks-wrapper.jsx
1246
- import { createSignal as createSignal5 } from "solid-js";
1108
+ // src/components/blocks/blocks-wrapper.tsx
1247
1109
  import { css as css2 } from "solid-styled-components";
1248
1110
  function BlocksWrapper(props) {
1249
1111
  function className() {
@@ -1294,14 +1156,10 @@ function BlocksWrapper(props) {
1294
1156
  }
1295
1157
  var Blocks_wrapper_default = BlocksWrapper;
1296
1158
 
1297
- // src/context/components.context.js
1298
- import { createContext as createContext2 } from "solid-js";
1299
- var stdin_default2 = createContext2({ registeredComponents: {} });
1300
-
1301
- // src/components/blocks/blocks.jsx
1159
+ // src/components/blocks/blocks.tsx
1302
1160
  function Blocks(props) {
1303
- const builderContext = useContext(stdin_default);
1304
- const componentsContext = useContext(stdin_default2);
1161
+ const builderContext = useContext(builder_context_default);
1162
+ const componentsContext = useContext(components_context_default);
1305
1163
  return <Blocks_wrapper_default
1306
1164
  blocks={props.blocks}
1307
1165
  parent={props.parent}
@@ -1329,14 +1187,14 @@ function Blocks(props) {
1329
1187
  }
1330
1188
  var Blocks_default = Blocks;
1331
1189
 
1332
- // src/blocks/columns/columns.jsx
1190
+ // src/blocks/columns/columns.tsx
1333
1191
  function Columns(props) {
1334
- const [gutterSize, setGutterSize] = createSignal6(
1192
+ const [gutterSize, setGutterSize] = createSignal5(
1335
1193
  typeof props.space === "number" ? props.space || 0 : 20
1336
1194
  );
1337
- const [cols, setCols] = createSignal6(props.columns || []);
1338
- const [stackAt, setStackAt] = createSignal6(props.stackColumnsAt || "tablet");
1339
- const [flexDir, setFlexDir] = createSignal6(
1195
+ const [cols, setCols] = createSignal5(props.columns || []);
1196
+ const [stackAt, setStackAt] = createSignal5(props.stackColumnsAt || "tablet");
1197
+ const [flexDir, setFlexDir] = createSignal5(
1340
1198
  props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column"
1341
1199
  );
1342
1200
  function getWidth(index) {
@@ -1346,10 +1204,16 @@ function Columns(props) {
1346
1204
  const subtractWidth = gutterSize() * (cols().length - 1) / cols().length;
1347
1205
  return `calc(${getWidth(index)}% - ${subtractWidth}px)`;
1348
1206
  }
1349
- function getTabletStyle({ stackedStyle, desktopStyle }) {
1207
+ function getTabletStyle({
1208
+ stackedStyle,
1209
+ desktopStyle
1210
+ }) {
1350
1211
  return stackAt() === "tablet" ? stackedStyle : desktopStyle;
1351
1212
  }
1352
- function getMobileStyle({ stackedStyle, desktopStyle }) {
1213
+ function getMobileStyle({
1214
+ stackedStyle,
1215
+ desktopStyle
1216
+ }) {
1353
1217
  return stackAt() === "never" ? desktopStyle : stackedStyle;
1354
1218
  }
1355
1219
  function columnsCssVars() {
@@ -1457,17 +1321,17 @@ function Columns(props) {
1457
1321
  }
1458
1322
  var columns_default = Columns;
1459
1323
 
1460
- // src/blocks/fragment/fragment.jsx
1324
+ // src/blocks/fragment/fragment.tsx
1461
1325
  function FragmentComponent(props) {
1462
1326
  return <span>{props.children}</span>;
1463
1327
  }
1464
1328
  var fragment_default = FragmentComponent;
1465
1329
 
1466
- // src/blocks/image/image.jsx
1467
- import { Show as Show8, createSignal as createSignal7 } from "solid-js";
1330
+ // src/blocks/image/image.tsx
1331
+ import { Show as Show8 } from "solid-js";
1468
1332
  import { css as css4 } from "solid-styled-components";
1469
1333
 
1470
- // src/blocks/image/image.helpers.js
1334
+ // src/blocks/image/image.helpers.ts
1471
1335
  function removeProtocol(path) {
1472
1336
  return path.replace(/http(s)?:/, "");
1473
1337
  }
@@ -1480,7 +1344,7 @@ function updateQueryParam(uri = "", key, value) {
1480
1344
  return uri + separator + key + "=" + encodeURIComponent(value);
1481
1345
  }
1482
1346
  function getShopifyImageUrl(src, size) {
1483
- if (!src || !(src == null ? void 0 : src.match(/cdn\.shopify\.com/)) || !size) {
1347
+ if (!src || !src?.match(/cdn\.shopify\.com/) || !size) {
1484
1348
  return src;
1485
1349
  }
1486
1350
  if (size === "master") {
@@ -1514,7 +1378,7 @@ function getSrcSet(url) {
1514
1378
  return url;
1515
1379
  }
1516
1380
 
1517
- // src/blocks/image/image.jsx
1381
+ // src/blocks/image/image.tsx
1518
1382
  function Image(props) {
1519
1383
  function srcSetToUse() {
1520
1384
  const imageToUse = props.image || props.src;
@@ -1601,7 +1465,7 @@ function Image(props) {
1601
1465
  }
1602
1466
  var image_default = Image;
1603
1467
 
1604
- // src/blocks/section/section.jsx
1468
+ // src/blocks/section/section.tsx
1605
1469
  function SectionComponent(props) {
1606
1470
  return <section
1607
1471
  {...{}}
@@ -1622,190 +1486,212 @@ function SectionComponent(props) {
1622
1486
  }
1623
1487
  var section_default = SectionComponent;
1624
1488
 
1625
- // src/blocks/symbol/symbol.jsx
1626
- import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as createSignal15 } from "solid-js";
1489
+ // src/blocks/symbol/symbol.tsx
1490
+ import { onMount as onMount4, on as on3, createEffect as createEffect3, createSignal as createSignal13 } from "solid-js";
1627
1491
 
1628
- // src/components/content-variants/content-variants.jsx
1629
- import { Show as Show11, For as For5, onMount as onMount3, createSignal as createSignal14 } from "solid-js";
1492
+ // src/components/content-variants/content-variants.tsx
1493
+ import { Show as Show11, For as For5, onMount as onMount3, createSignal as createSignal12 } from "solid-js";
1630
1494
 
1631
- // src/components/content-variants/helpers.js
1632
- var __defProp9 = Object.defineProperty;
1633
- var __defProps7 = Object.defineProperties;
1634
- var __getOwnPropDescs7 = Object.getOwnPropertyDescriptors;
1635
- var __getOwnPropSymbols9 = Object.getOwnPropertySymbols;
1636
- var __hasOwnProp9 = Object.prototype.hasOwnProperty;
1637
- var __propIsEnum9 = Object.prototype.propertyIsEnumerable;
1638
- var __defNormalProp9 = (obj, key, value) => key in obj ? __defProp9(obj, key, {
1639
- enumerable: true,
1640
- configurable: true,
1641
- writable: true,
1642
- value
1643
- }) : obj[key] = value;
1644
- var __spreadValues9 = (a, b) => {
1645
- for (var prop in b || (b = {}))
1646
- if (__hasOwnProp9.call(b, prop))
1647
- __defNormalProp9(a, prop, b[prop]);
1648
- if (__getOwnPropSymbols9)
1649
- for (var prop of __getOwnPropSymbols9(b)) {
1650
- if (__propIsEnum9.call(b, prop))
1651
- __defNormalProp9(a, prop, b[prop]);
1495
+ // src/helpers/url.ts
1496
+ var getTopLevelDomain = (host) => {
1497
+ if (host === "localhost" || host === "127.0.0.1") {
1498
+ return host;
1499
+ }
1500
+ const parts = host.split(".");
1501
+ if (parts.length > 2) {
1502
+ return parts.slice(1).join(".");
1503
+ }
1504
+ return host;
1505
+ };
1506
+
1507
+ // src/helpers/cookie.ts
1508
+ var getCookieSync = ({
1509
+ name,
1510
+ canTrack
1511
+ }) => {
1512
+ try {
1513
+ if (!canTrack) {
1514
+ return void 0;
1652
1515
  }
1653
- return a;
1516
+ return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
1517
+ } catch (err) {
1518
+ logger.warn("[COOKIE] GET error: ", err?.message || err);
1519
+ return void 0;
1520
+ }
1654
1521
  };
1655
- var __spreadProps7 = (a, b) => __defProps7(a, __getOwnPropDescs7(b));
1656
- var getVariants = (content) => Object.values((content == null ? void 0 : content.variations) || {}).map((variant) => __spreadProps7(__spreadValues9({}, variant), {
1657
- testVariationId: variant.id,
1658
- id: content == null ? void 0 : content.id
1659
- }));
1660
- var checkShouldRunVariants = ({
1661
- canTrack,
1662
- content
1522
+ var getCookie = async (args) => getCookieSync(args);
1523
+ var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
1524
+ var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
1525
+ var createCookieString = ({
1526
+ name,
1527
+ value,
1528
+ expires
1663
1529
  }) => {
1664
- const hasVariants = getVariants(content).length > 0;
1665
- if (TARGET === "reactNative")
1666
- return false;
1667
- if (!hasVariants)
1668
- return false;
1669
- if (!canTrack)
1670
- return false;
1671
- if (TARGET === "vue2" || TARGET === "vue3")
1672
- return true;
1673
- if (isBrowser())
1674
- return false;
1675
- return true;
1530
+ const secure = isBrowser() ? location.protocol === "https:" : true;
1531
+ const secureObj = secure ? SECURE_CONFIG : [[]];
1532
+ const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
1533
+ const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
1534
+ const cookie = stringifyCookie(cookieValue);
1535
+ return cookie;
1676
1536
  };
1677
- function bldrAbTest(contentId, variants, isHydrationTarget2) {
1678
- var _a;
1679
- function getAndSetVariantId2() {
1680
- function setCookie2(name, value, days) {
1681
- let expires = "";
1682
- if (days) {
1683
- const date = /* @__PURE__ */ new Date();
1684
- date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
1685
- expires = "; expires=" + date.toUTCString();
1686
- }
1687
- document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
1688
- }
1689
- function getCookie2(name) {
1690
- const nameEQ = name + "=";
1691
- const ca = document.cookie.split(";");
1692
- for (let i = 0; i < ca.length; i++) {
1693
- let c = ca[i];
1694
- while (c.charAt(0) === " ")
1695
- c = c.substring(1, c.length);
1696
- if (c.indexOf(nameEQ) === 0)
1697
- return c.substring(nameEQ.length, c.length);
1698
- }
1699
- return null;
1700
- }
1701
- const cookieName = `builder.tests.${contentId}`;
1702
- const variantInCookie = getCookie2(cookieName);
1703
- const availableIDs = variants.map((vr) => vr.id).concat(contentId);
1704
- if (variantInCookie && availableIDs.includes(variantInCookie)) {
1705
- return variantInCookie;
1537
+ var setCookie = async ({
1538
+ name,
1539
+ value,
1540
+ expires,
1541
+ canTrack
1542
+ }) => {
1543
+ try {
1544
+ if (!canTrack) {
1545
+ return;
1706
1546
  }
1707
- let n = 0;
1708
- const random = Math.random();
1709
- for (let i = 0; i < variants.length; i++) {
1710
- const variant = variants[i];
1711
- const testRatio = variant.testRatio;
1712
- n += testRatio;
1713
- if (random < n) {
1714
- setCookie2(cookieName, variant.id);
1715
- return variant.id;
1716
- }
1547
+ const cookie = createCookieString({
1548
+ name,
1549
+ value,
1550
+ expires
1551
+ });
1552
+ document.cookie = cookie;
1553
+ } catch (err) {
1554
+ logger.warn("[COOKIE] SET error: ", err?.message || err);
1555
+ }
1556
+ };
1557
+
1558
+ // src/helpers/ab-tests.ts
1559
+ var BUILDER_STORE_PREFIX = "builder.tests";
1560
+ var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
1561
+ var getContentVariationCookie = ({
1562
+ contentId
1563
+ }) => getCookie({
1564
+ name: getContentTestKey(contentId),
1565
+ canTrack: true
1566
+ });
1567
+ var getContentVariationCookieSync = ({
1568
+ contentId
1569
+ }) => getCookieSync({
1570
+ name: getContentTestKey(contentId),
1571
+ canTrack: true
1572
+ });
1573
+ var setContentVariationCookie = ({
1574
+ contentId,
1575
+ value
1576
+ }) => setCookie({
1577
+ name: getContentTestKey(contentId),
1578
+ value,
1579
+ canTrack: true
1580
+ });
1581
+ var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
1582
+ var getRandomVariationId = ({
1583
+ id,
1584
+ variations
1585
+ }) => {
1586
+ let n = 0;
1587
+ const random = Math.random();
1588
+ for (const id2 in variations) {
1589
+ const testRatio = variations[id2]?.testRatio;
1590
+ n += testRatio;
1591
+ if (random < n) {
1592
+ return id2;
1717
1593
  }
1718
- setCookie2(cookieName, contentId);
1719
- return contentId;
1720
1594
  }
1721
- const winningVariantId = getAndSetVariantId2();
1722
- const styleEl = (_a = document.currentScript) == null ? void 0 : _a.previousElementSibling;
1723
- if (isHydrationTarget2) {
1724
- styleEl.remove();
1725
- const thisScriptEl = document.currentScript;
1726
- thisScriptEl == null ? void 0 : thisScriptEl.remove();
1595
+ return id;
1596
+ };
1597
+ var getAndSetVariantId = (args) => {
1598
+ const randomVariationId = getRandomVariationId(args);
1599
+ setContentVariationCookie({
1600
+ contentId: args.id,
1601
+ value: randomVariationId
1602
+ }).catch((err) => {
1603
+ logger.error("could not store A/B test variation: ", err);
1604
+ });
1605
+ return randomVariationId;
1606
+ };
1607
+ var getTestFields = ({
1608
+ item,
1609
+ testGroupId
1610
+ }) => {
1611
+ const variationValue = item.variations[testGroupId];
1612
+ if (testGroupId === item.id || // handle edge-case where `testGroupId` points to non-existing variation
1613
+ !variationValue) {
1614
+ return {
1615
+ testVariationId: item.id,
1616
+ testVariationName: "Default"
1617
+ };
1727
1618
  } else {
1728
- const newStyleStr = variants.concat({
1729
- id: contentId
1730
- }).filter((variant) => variant.id !== winningVariantId).map((value) => {
1731
- return `.variant-${value.id} { display: none; }
1732
- `;
1733
- }).join("");
1734
- styleEl.innerHTML = newStyleStr;
1619
+ return {
1620
+ data: variationValue.data,
1621
+ testVariationId: variationValue.id,
1622
+ testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
1623
+ };
1735
1624
  }
1736
- }
1737
- function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
1738
- var _a;
1739
- if (!navigator.cookieEnabled) {
1740
- return;
1625
+ };
1626
+ var handleABTestingSync = ({
1627
+ item,
1628
+ canTrack
1629
+ }) => {
1630
+ if (TARGET === "reactNative")
1631
+ return item;
1632
+ if (!canTrack) {
1633
+ return item;
1741
1634
  }
1742
- function getCookie2(name) {
1743
- const nameEQ = name + "=";
1744
- const ca = document.cookie.split(";");
1745
- for (let i = 0; i < ca.length; i++) {
1746
- let c = ca[i];
1747
- while (c.charAt(0) === " ")
1748
- c = c.substring(1, c.length);
1749
- if (c.indexOf(nameEQ) === 0)
1750
- return c.substring(nameEQ.length, c.length);
1751
- }
1752
- return null;
1635
+ if (!item) {
1636
+ return void 0;
1753
1637
  }
1754
- const cookieName = `builder.tests.${defaultContentId}`;
1755
- const variantId = getCookie2(cookieName);
1756
- const parentDiv = (_a = document.currentScript) == null ? void 0 : _a.parentElement;
1757
- const variantIsDefaultContent = variantContentId === defaultContentId;
1758
- if (variantId === variantContentId) {
1759
- if (variantIsDefaultContent) {
1760
- return;
1761
- }
1762
- parentDiv == null ? void 0 : parentDiv.removeAttribute("hidden");
1763
- parentDiv == null ? void 0 : parentDiv.removeAttribute("aria-hidden");
1764
- } else {
1765
- if (variantIsDefaultContent) {
1766
- if (isHydrationTarget2) {
1767
- parentDiv == null ? void 0 : parentDiv.remove();
1768
- } else {
1769
- parentDiv == null ? void 0 : parentDiv.setAttribute("hidden", "true");
1770
- parentDiv == null ? void 0 : parentDiv.setAttribute("aria-hidden", "true");
1771
- }
1772
- }
1773
- return;
1638
+ if (!checkIsBuilderContentWithVariations(item)) {
1639
+ return item;
1774
1640
  }
1775
- return;
1776
- }
1777
- var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
1778
- var isHydrationTarget = getIsHydrationTarget(TARGET);
1779
- var AB_TEST_FN_NAME = "builderIoAbTest";
1780
- var CONTENT_FN_NAME = "builderIoRenderContent";
1781
- var getScriptString = () => {
1782
- const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
1783
- const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
1784
- return `
1785
- window.${AB_TEST_FN_NAME} = ${fnStr}
1786
- window.${CONTENT_FN_NAME} = ${fnStr2}
1787
- `;
1788
- };
1789
- var getVariantsScriptString = (variants, contentId) => {
1790
- return `
1791
- window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
1641
+ const testGroupId = getContentVariationCookieSync({
1642
+ contentId: item.id
1643
+ }) || getAndSetVariantId({
1644
+ variations: item.variations,
1645
+ id: item.id
1646
+ });
1647
+ const variationValue = getTestFields({
1648
+ item,
1649
+ testGroupId
1650
+ });
1651
+ return {
1652
+ ...item,
1653
+ ...variationValue
1654
+ };
1792
1655
  };
1793
- var getRenderContentScriptString = ({
1794
- contentId,
1795
- variationId
1656
+ var handleABTesting = async ({
1657
+ item,
1658
+ canTrack
1796
1659
  }) => {
1797
- return `
1798
- window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
1660
+ if (!canTrack) {
1661
+ return item;
1662
+ }
1663
+ if (!checkIsBuilderContentWithVariations(item)) {
1664
+ return item;
1665
+ }
1666
+ const cookieValue = await getContentVariationCookie({
1667
+ contentId: item.id
1668
+ });
1669
+ const testGroupId = cookieValue || getAndSetVariantId({
1670
+ variations: item.variations,
1671
+ id: item.id
1672
+ });
1673
+ const variationValue = getTestFields({
1674
+ item,
1675
+ testGroupId
1676
+ });
1677
+ return {
1678
+ ...item,
1679
+ ...variationValue
1680
+ };
1799
1681
  };
1800
1682
 
1801
- // src/components/content/content.jsx
1802
- import { Show as Show10, createSignal as createSignal13 } from "solid-js";
1683
+ // src/helpers/canTrack.ts
1684
+ var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
1685
+
1686
+ // src/components/content/content.tsx
1687
+ import { Show as Show10, createSignal as createSignal11 } from "solid-js";
1803
1688
 
1804
- // src/blocks/button/component-info.js
1689
+ // src/blocks/button/component-info.ts
1805
1690
  var componentInfo = {
1806
1691
  name: "Core:Button",
1807
1692
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
1808
1693
  defaultStyles: {
1694
+ // TODO: make min width more intuitive and set one
1809
1695
  appearance: "none",
1810
1696
  paddingTop: "15px",
1811
1697
  paddingBottom: "15px",
@@ -1836,8 +1722,9 @@ var componentInfo = {
1836
1722
  noWrap: true
1837
1723
  };
1838
1724
 
1839
- // src/blocks/columns/component-info.js
1725
+ // src/blocks/columns/component-info.ts
1840
1726
  var componentInfo2 = {
1727
+ // TODO: ways to statically preprocess JSON for references, functions, etc
1841
1728
  name: "Columns",
1842
1729
  isRSC: true,
1843
1730
  inputs: [{
@@ -2055,40 +1942,194 @@ var componentInfo2 = {
2055
1942
  }]
2056
1943
  };
2057
1944
 
2058
- // src/blocks/fragment/component-info.js
1945
+ // src/blocks/custom-code/component-info.ts
2059
1946
  var componentInfo3 = {
2060
- name: "Fragment",
2061
- static: true,
2062
- hidden: true,
2063
- canHaveChildren: true,
2064
- noWrap: true
2065
- };
2066
-
2067
- // src/blocks/image/component-info.js
2068
- var componentInfo4 = {
2069
- name: "Image",
1947
+ name: "Custom Code",
2070
1948
  static: true,
2071
- 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",
2072
- defaultStyles: {
2073
- position: "relative",
2074
- minHeight: "20px",
2075
- minWidth: "20px",
2076
- overflow: "hidden"
2077
- },
2078
- canHaveChildren: true,
1949
+ requiredPermissions: ["editCode"],
2079
1950
  inputs: [{
2080
- name: "image",
2081
- type: "file",
2082
- bubble: true,
2083
- allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
1951
+ name: "code",
1952
+ type: "html",
2084
1953
  required: true,
2085
- defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
2086
- onChange: (options) => {
2087
- const DEFAULT_ASPECT_RATIO = 0.7041;
2088
- options.delete("srcset");
2089
- options.delete("noWebp");
2090
- function loadImage(url, timeout = 6e4) {
2091
- return new Promise((resolve, reject) => {
1954
+ defaultValue: "<p>Hello there, I am custom HTML code!</p>",
1955
+ code: true
1956
+ }, {
1957
+ name: "replaceNodes",
1958
+ type: "boolean",
1959
+ helperText: "Preserve server rendered dom nodes",
1960
+ advanced: true
1961
+ }, {
1962
+ name: "scriptsClientOnly",
1963
+ type: "boolean",
1964
+ defaultValue: false,
1965
+ helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
1966
+ advanced: true
1967
+ }]
1968
+ };
1969
+
1970
+ // src/blocks/custom-code/custom-code.tsx
1971
+ import { onMount, createSignal as createSignal7 } from "solid-js";
1972
+ function CustomCode(props) {
1973
+ const [scriptsInserted, setScriptsInserted] = createSignal7([]);
1974
+ const [scriptsRun, setScriptsRun] = createSignal7([]);
1975
+ let elementRef;
1976
+ onMount(() => {
1977
+ if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
1978
+ return;
1979
+ }
1980
+ const scripts = elementRef.getElementsByTagName("script");
1981
+ for (let i = 0; i < scripts.length; i++) {
1982
+ const script = scripts[i];
1983
+ if (script.src) {
1984
+ if (scriptsInserted().includes(script.src)) {
1985
+ continue;
1986
+ }
1987
+ scriptsInserted().push(script.src);
1988
+ const newScript = document.createElement("script");
1989
+ newScript.async = true;
1990
+ newScript.src = script.src;
1991
+ document.head.appendChild(newScript);
1992
+ } else if (!script.type || [
1993
+ "text/javascript",
1994
+ "application/javascript",
1995
+ "application/ecmascript"
1996
+ ].includes(script.type)) {
1997
+ if (scriptsRun().includes(script.innerText)) {
1998
+ continue;
1999
+ }
2000
+ try {
2001
+ scriptsRun().push(script.innerText);
2002
+ new Function(script.innerText)();
2003
+ } catch (error) {
2004
+ }
2005
+ }
2006
+ }
2007
+ });
2008
+ return <div
2009
+ class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
2010
+ ref={elementRef}
2011
+ innerHTML={props.code}
2012
+ />;
2013
+ }
2014
+ var custom_code_default = CustomCode;
2015
+
2016
+ // src/blocks/embed/component-info.ts
2017
+ var componentInfo4 = {
2018
+ name: "Embed",
2019
+ static: true,
2020
+ inputs: [{
2021
+ name: "url",
2022
+ type: "url",
2023
+ required: true,
2024
+ defaultValue: "",
2025
+ helperText: "e.g. enter a youtube url, google map, etc",
2026
+ onChange: (options) => {
2027
+ const url = options.get("url");
2028
+ if (url) {
2029
+ options.set("content", "Loading...");
2030
+ const apiKey = "ae0e60e78201a3f2b0de4b";
2031
+ return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
2032
+ if (options.get("url") === url) {
2033
+ if (data.html) {
2034
+ options.set("content", data.html);
2035
+ } else {
2036
+ options.set("content", "Invalid url, please try another");
2037
+ }
2038
+ }
2039
+ }).catch((_err) => {
2040
+ options.set("content", "There was an error embedding this URL, please try again or another URL");
2041
+ });
2042
+ } else {
2043
+ options.delete("content");
2044
+ }
2045
+ }
2046
+ }, {
2047
+ name: "content",
2048
+ type: "html",
2049
+ defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
2050
+ hideFromUI: true
2051
+ }]
2052
+ };
2053
+
2054
+ // src/blocks/embed/embed.tsx
2055
+ import { on, createEffect, createSignal as createSignal8 } from "solid-js";
2056
+
2057
+ // src/blocks/embed/helpers.ts
2058
+ var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
2059
+ var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2060
+
2061
+ // src/blocks/embed/embed.tsx
2062
+ function Embed(props) {
2063
+ const [scriptsInserted, setScriptsInserted] = createSignal8([]);
2064
+ const [scriptsRun, setScriptsRun] = createSignal8([]);
2065
+ const [ranInitFn, setRanInitFn] = createSignal8(false);
2066
+ function findAndRunScripts() {
2067
+ if (!elem || !elem.getElementsByTagName)
2068
+ return;
2069
+ const scripts = elem.getElementsByTagName("script");
2070
+ for (let i = 0; i < scripts.length; i++) {
2071
+ const script = scripts[i];
2072
+ if (script.src && !scriptsInserted().includes(script.src)) {
2073
+ scriptsInserted().push(script.src);
2074
+ const newScript = document.createElement("script");
2075
+ newScript.async = true;
2076
+ newScript.src = script.src;
2077
+ document.head.appendChild(newScript);
2078
+ } else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
2079
+ try {
2080
+ scriptsRun().push(script.innerText);
2081
+ new Function(script.innerText)();
2082
+ } catch (error) {
2083
+ }
2084
+ }
2085
+ }
2086
+ }
2087
+ let elem;
2088
+ function onUpdateFn_0() {
2089
+ if (elem && !ranInitFn()) {
2090
+ setRanInitFn(true);
2091
+ findAndRunScripts();
2092
+ }
2093
+ }
2094
+ createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
2095
+ return <div class="builder-embed" ref={elem} innerHTML={props.content} />;
2096
+ }
2097
+ var embed_default = Embed;
2098
+
2099
+ // src/blocks/fragment/component-info.ts
2100
+ var componentInfo5 = {
2101
+ name: "Fragment",
2102
+ static: true,
2103
+ hidden: true,
2104
+ canHaveChildren: true,
2105
+ noWrap: true
2106
+ };
2107
+
2108
+ // src/blocks/image/component-info.ts
2109
+ var componentInfo6 = {
2110
+ name: "Image",
2111
+ static: true,
2112
+ 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",
2113
+ defaultStyles: {
2114
+ position: "relative",
2115
+ minHeight: "20px",
2116
+ minWidth: "20px",
2117
+ overflow: "hidden"
2118
+ },
2119
+ canHaveChildren: true,
2120
+ inputs: [{
2121
+ name: "image",
2122
+ type: "file",
2123
+ bubble: true,
2124
+ allowedFileTypes: ["jpeg", "jpg", "png", "svg"],
2125
+ required: true,
2126
+ defaultValue: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",
2127
+ onChange: (options) => {
2128
+ const DEFAULT_ASPECT_RATIO = 0.7041;
2129
+ options.delete("srcset");
2130
+ options.delete("noWebp");
2131
+ function loadImage(url, timeout = 6e4) {
2132
+ return new Promise((resolve, reject) => {
2092
2133
  const img = document.createElement("img");
2093
2134
  let loaded = false;
2094
2135
  img.onload = () => {
@@ -2186,8 +2227,41 @@ var componentInfo4 = {
2186
2227
  }]
2187
2228
  };
2188
2229
 
2189
- // src/blocks/section/component-info.js
2190
- var componentInfo5 = {
2230
+ // src/blocks/img/component-info.ts
2231
+ var componentInfo7 = {
2232
+ // friendlyName?
2233
+ name: "Raw:Img",
2234
+ hideFromInsertMenu: true,
2235
+ 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",
2236
+ inputs: [{
2237
+ name: "image",
2238
+ bubble: true,
2239
+ type: "file",
2240
+ allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
2241
+ required: true
2242
+ }],
2243
+ noWrap: true,
2244
+ static: true
2245
+ };
2246
+
2247
+ // src/blocks/img/img.tsx
2248
+ function ImgComponent(props) {
2249
+ return <img
2250
+ style={{
2251
+ "object-fit": props.backgroundSize || "cover",
2252
+ "object-position": props.backgroundPosition || "center"
2253
+ }}
2254
+ key={isEditing() && props.imgSrc || "default-key"}
2255
+ alt={props.altText}
2256
+ src={props.imgSrc || props.image}
2257
+ {...{}}
2258
+ {...props.attributes}
2259
+ />;
2260
+ }
2261
+ var img_default = ImgComponent;
2262
+
2263
+ // src/blocks/section/component-info.ts
2264
+ var componentInfo8 = {
2191
2265
  name: "Core:Section",
2192
2266
  static: true,
2193
2267
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",
@@ -2228,8 +2302,8 @@ var componentInfo5 = {
2228
2302
  }]
2229
2303
  };
2230
2304
 
2231
- // src/blocks/symbol/component-info.js
2232
- var componentInfo6 = {
2305
+ // src/blocks/symbol/component-info.ts
2306
+ var componentInfo9 = {
2233
2307
  name: "Symbol",
2234
2308
  noWrap: true,
2235
2309
  static: true,
@@ -2264,8 +2338,8 @@ var componentInfo6 = {
2264
2338
  }]
2265
2339
  };
2266
2340
 
2267
- // src/blocks/text/component-info.js
2268
- var componentInfo7 = {
2341
+ // src/blocks/text/component-info.ts
2342
+ var componentInfo10 = {
2269
2343
  name: "Text",
2270
2344
  static: true,
2271
2345
  isRSC: true,
@@ -2285,7 +2359,7 @@ var componentInfo7 = {
2285
2359
  }
2286
2360
  };
2287
2361
 
2288
- // src/blocks/text/text.jsx
2362
+ // src/blocks/text/text.tsx
2289
2363
  function Text(props) {
2290
2364
  return <div
2291
2365
  class="builder-text"
@@ -2297,8 +2371,8 @@ function Text(props) {
2297
2371
  }
2298
2372
  var text_default = Text;
2299
2373
 
2300
- // src/blocks/video/component-info.js
2301
- var componentInfo8 = {
2374
+ // src/blocks/video/component-info.ts
2375
+ var componentInfo11 = {
2302
2376
  name: "Video",
2303
2377
  canHaveChildren: true,
2304
2378
  defaultStyles: {
@@ -2381,8 +2455,7 @@ var componentInfo8 = {
2381
2455
  }]
2382
2456
  };
2383
2457
 
2384
- // src/blocks/video/video.jsx
2385
- import { createSignal as createSignal8 } from "solid-js";
2458
+ // src/blocks/video/video.tsx
2386
2459
  function Video(props) {
2387
2460
  function videoProps() {
2388
2461
  return {
@@ -2428,1210 +2501,271 @@ function Video(props) {
2428
2501
  }
2429
2502
  var video_default = Video;
2430
2503
 
2431
- // src/blocks/embed/component-info.js
2432
- var componentInfo9 = {
2433
- name: "Embed",
2434
- static: true,
2435
- inputs: [{
2436
- name: "url",
2437
- type: "url",
2438
- required: true,
2439
- defaultValue: "",
2440
- helperText: "e.g. enter a youtube url, google map, etc",
2441
- onChange: (options) => {
2442
- const url = options.get("url");
2443
- if (url) {
2444
- options.set("content", "Loading...");
2445
- const apiKey = "ae0e60e78201a3f2b0de4b";
2446
- return fetch(`https://iframe.ly/api/iframely?url=${url}&api_key=${apiKey}`).then((res) => res.json()).then((data) => {
2447
- if (options.get("url") === url) {
2448
- if (data.html) {
2449
- options.set("content", data.html);
2450
- } else {
2451
- options.set("content", "Invalid url, please try another");
2452
- }
2453
- }
2454
- }).catch((_err) => {
2455
- options.set("content", "There was an error embedding this URL, please try again or another URL");
2456
- });
2457
- } else {
2458
- options.delete("content");
2459
- }
2460
- }
2461
- }, {
2462
- name: "content",
2463
- type: "html",
2464
- defaultValue: '<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',
2465
- hideFromUI: true
2466
- }]
2504
+ // src/constants/builder-registered-components.ts
2505
+ var getDefaultRegisteredComponents = () => [{
2506
+ component: button_default,
2507
+ ...componentInfo
2508
+ }, {
2509
+ component: columns_default,
2510
+ ...componentInfo2
2511
+ }, {
2512
+ component: custom_code_default,
2513
+ ...componentInfo3
2514
+ }, {
2515
+ component: embed_default,
2516
+ ...componentInfo4
2517
+ }, {
2518
+ component: fragment_default,
2519
+ ...componentInfo5
2520
+ }, {
2521
+ component: image_default,
2522
+ ...componentInfo6
2523
+ }, {
2524
+ component: img_default,
2525
+ ...componentInfo7
2526
+ }, {
2527
+ component: section_default,
2528
+ ...componentInfo8
2529
+ }, {
2530
+ component: symbol_default,
2531
+ ...componentInfo9
2532
+ }, {
2533
+ component: text_default,
2534
+ ...componentInfo10
2535
+ }, {
2536
+ component: video_default,
2537
+ ...componentInfo11
2538
+ }];
2539
+
2540
+ // src/functions/register-component.ts
2541
+ var components = [];
2542
+ var createRegisterComponentMessage = (info) => ({
2543
+ type: "builder.registerComponent",
2544
+ data: serializeComponentInfo(info)
2545
+ });
2546
+ var serializeFn = (fnValue) => {
2547
+ const fnStr = fnValue.toString().trim();
2548
+ const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
2549
+ return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
2467
2550
  };
2551
+ var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
2552
+ var serializeComponentInfo = ({
2553
+ inputs,
2554
+ ...info
2555
+ }) => ({
2556
+ ...fastClone(info),
2557
+ inputs: inputs?.map((input) => Object.entries(input).reduce((acc, [key, value]) => ({
2558
+ ...acc,
2559
+ [key]: serializeValue(value)
2560
+ }), {}))
2561
+ });
2468
2562
 
2469
- // src/blocks/embed/embed.jsx
2470
- import { on, createEffect, createSignal as createSignal9 } from "solid-js";
2471
-
2472
- // src/blocks/embed/helpers.js
2473
- var SCRIPT_MIME_TYPES = ["text/javascript", "application/javascript", "application/ecmascript"];
2474
- var isJsScript = (script) => SCRIPT_MIME_TYPES.includes(script.type);
2475
-
2476
- // src/blocks/embed/embed.jsx
2477
- function Embed(props) {
2478
- const [scriptsInserted, setScriptsInserted] = createSignal9([]);
2479
- const [scriptsRun, setScriptsRun] = createSignal9([]);
2480
- const [ranInitFn, setRanInitFn] = createSignal9(false);
2481
- function findAndRunScripts() {
2482
- if (!elem || !elem.getElementsByTagName)
2483
- return;
2484
- const scripts = elem.getElementsByTagName("script");
2485
- for (let i = 0; i < scripts.length; i++) {
2486
- const script = scripts[i];
2487
- if (script.src && !scriptsInserted().includes(script.src)) {
2488
- scriptsInserted().push(script.src);
2489
- const newScript = document.createElement("script");
2490
- newScript.async = true;
2491
- newScript.src = script.src;
2492
- document.head.appendChild(newScript);
2493
- } else if (isJsScript(script) && !scriptsRun().includes(script.innerText)) {
2494
- try {
2495
- scriptsRun().push(script.innerText);
2496
- new Function(script.innerText)();
2497
- } catch (error) {
2498
- }
2499
- }
2500
- }
2501
- }
2502
- let elem;
2503
- function onUpdateFn_0() {
2504
- if (elem && !ranInitFn()) {
2505
- setRanInitFn(true);
2506
- findAndRunScripts();
2507
- }
2508
- }
2509
- createEffect(on(() => [elem, ranInitFn()], onUpdateFn_0));
2510
- return <div class="builder-embed" ref={elem} innerHTML={props.content} />;
2511
- }
2512
- var embed_default = Embed;
2513
-
2514
- // src/blocks/img/img.jsx
2515
- function ImgComponent(props) {
2516
- return <img
2517
- style={{
2518
- "object-fit": props.backgroundSize || "cover",
2519
- "object-position": props.backgroundPosition || "center"
2520
- }}
2521
- key={isEditing() && props.imgSrc || "default-key"}
2522
- alt={props.altText}
2523
- src={props.imgSrc || props.image}
2524
- {...{}}
2525
- {...props.attributes}
2526
- />;
2527
- }
2528
- var img_default = ImgComponent;
2529
-
2530
- // src/blocks/img/component-info.js
2531
- var componentInfo10 = {
2532
- name: "Raw:Img",
2533
- hideFromInsertMenu: true,
2534
- 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",
2535
- inputs: [{
2536
- name: "image",
2537
- bubble: true,
2538
- type: "file",
2539
- allowedFileTypes: ["jpeg", "jpg", "png", "svg", "gif", "webp"],
2540
- required: true
2541
- }],
2542
- noWrap: true,
2543
- static: true
2544
- };
2545
-
2546
- // src/blocks/custom-code/custom-code.jsx
2547
- import { onMount, createSignal as createSignal10 } from "solid-js";
2548
- function CustomCode(props) {
2549
- const [scriptsInserted, setScriptsInserted] = createSignal10([]);
2550
- const [scriptsRun, setScriptsRun] = createSignal10([]);
2551
- let elementRef;
2552
- onMount(() => {
2553
- if (!elementRef?.getElementsByTagName || typeof window === "undefined") {
2554
- return;
2555
- }
2556
- const scripts = elementRef.getElementsByTagName("script");
2557
- for (let i = 0; i < scripts.length; i++) {
2558
- const script = scripts[i];
2559
- if (script.src) {
2560
- if (scriptsInserted().includes(script.src)) {
2561
- continue;
2562
- }
2563
- scriptsInserted().push(script.src);
2564
- const newScript = document.createElement("script");
2565
- newScript.async = true;
2566
- newScript.src = script.src;
2567
- document.head.appendChild(newScript);
2568
- } else if (!script.type || [
2569
- "text/javascript",
2570
- "application/javascript",
2571
- "application/ecmascript"
2572
- ].includes(script.type)) {
2573
- if (scriptsRun().includes(script.innerText)) {
2574
- continue;
2575
- }
2576
- try {
2577
- scriptsRun().push(script.innerText);
2578
- new Function(script.innerText)();
2579
- } catch (error) {
2580
- }
2581
- }
2582
- }
2583
- });
2584
- return <div
2585
- class={"builder-custom-code" + (props.replaceNodes ? " replace-nodes" : "")}
2586
- ref={elementRef}
2587
- innerHTML={props.code}
2588
- />;
2589
- }
2590
- var custom_code_default = CustomCode;
2591
-
2592
- // src/blocks/custom-code/component-info.js
2593
- var componentInfo11 = {
2594
- name: "Custom Code",
2595
- static: true,
2596
- requiredPermissions: ["editCode"],
2597
- inputs: [{
2598
- name: "code",
2599
- type: "html",
2600
- required: true,
2601
- defaultValue: "<p>Hello there, I am custom HTML code!</p>",
2602
- code: true
2603
- }, {
2604
- name: "replaceNodes",
2605
- type: "boolean",
2606
- helperText: "Preserve server rendered dom nodes",
2607
- advanced: true
2608
- }, {
2609
- name: "scriptsClientOnly",
2610
- type: "boolean",
2611
- defaultValue: false,
2612
- helperText: "Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",
2613
- advanced: true
2614
- }]
2615
- };
2616
-
2617
- // src/constants/builder-registered-components.js
2618
- var __defProp10 = Object.defineProperty;
2619
- var __getOwnPropSymbols10 = Object.getOwnPropertySymbols;
2620
- var __hasOwnProp10 = Object.prototype.hasOwnProperty;
2621
- var __propIsEnum10 = Object.prototype.propertyIsEnumerable;
2622
- var __defNormalProp10 = (obj, key, value) => key in obj ? __defProp10(obj, key, {
2623
- enumerable: true,
2624
- configurable: true,
2625
- writable: true,
2626
- value
2627
- }) : obj[key] = value;
2628
- var __spreadValues10 = (a, b) => {
2629
- for (var prop in b || (b = {}))
2630
- if (__hasOwnProp10.call(b, prop))
2631
- __defNormalProp10(a, prop, b[prop]);
2632
- if (__getOwnPropSymbols10)
2633
- for (var prop of __getOwnPropSymbols10(b)) {
2634
- if (__propIsEnum10.call(b, prop))
2635
- __defNormalProp10(a, prop, b[prop]);
2636
- }
2637
- return a;
2638
- };
2639
- var getDefaultRegisteredComponents = () => [__spreadValues10({
2640
- component: button_default
2641
- }, componentInfo), __spreadValues10({
2642
- component: columns_default
2643
- }, componentInfo2), __spreadValues10({
2644
- component: custom_code_default
2645
- }, componentInfo11), __spreadValues10({
2646
- component: embed_default
2647
- }, componentInfo9), __spreadValues10({
2648
- component: fragment_default
2649
- }, componentInfo3), __spreadValues10({
2650
- component: image_default
2651
- }, componentInfo4), __spreadValues10({
2652
- component: img_default
2653
- }, componentInfo10), __spreadValues10({
2654
- component: section_default
2655
- }, componentInfo5), __spreadValues10({
2656
- component: symbol_default
2657
- }, componentInfo6), __spreadValues10({
2658
- component: text_default
2659
- }, componentInfo7), __spreadValues10({
2660
- component: video_default
2661
- }, componentInfo8)];
2662
-
2663
- // src/functions/register-component.js
2664
- var __defProp11 = Object.defineProperty;
2665
- var __defProps8 = Object.defineProperties;
2666
- var __getOwnPropDescs8 = Object.getOwnPropertyDescriptors;
2667
- var __getOwnPropSymbols11 = Object.getOwnPropertySymbols;
2668
- var __hasOwnProp11 = Object.prototype.hasOwnProperty;
2669
- var __propIsEnum11 = Object.prototype.propertyIsEnumerable;
2670
- var __defNormalProp11 = (obj, key, value) => key in obj ? __defProp11(obj, key, {
2671
- enumerable: true,
2672
- configurable: true,
2673
- writable: true,
2674
- value
2675
- }) : obj[key] = value;
2676
- var __spreadValues11 = (a, b) => {
2677
- for (var prop in b || (b = {}))
2678
- if (__hasOwnProp11.call(b, prop))
2679
- __defNormalProp11(a, prop, b[prop]);
2680
- if (__getOwnPropSymbols11)
2681
- for (var prop of __getOwnPropSymbols11(b)) {
2682
- if (__propIsEnum11.call(b, prop))
2683
- __defNormalProp11(a, prop, b[prop]);
2684
- }
2685
- return a;
2686
- };
2687
- var __spreadProps8 = (a, b) => __defProps8(a, __getOwnPropDescs8(b));
2688
- var __objRest2 = (source, exclude) => {
2689
- var target = {};
2690
- for (var prop in source)
2691
- if (__hasOwnProp11.call(source, prop) && exclude.indexOf(prop) < 0)
2692
- target[prop] = source[prop];
2693
- if (source != null && __getOwnPropSymbols11)
2694
- for (var prop of __getOwnPropSymbols11(source)) {
2695
- if (exclude.indexOf(prop) < 0 && __propIsEnum11.call(source, prop))
2696
- target[prop] = source[prop];
2697
- }
2698
- return target;
2699
- };
2700
- var components = [];
2701
- var createRegisterComponentMessage = (info) => ({
2702
- type: "builder.registerComponent",
2703
- data: serializeComponentInfo(info)
2704
- });
2705
- var serializeFn = (fnValue) => {
2706
- const fnStr = fnValue.toString().trim();
2707
- const appendFunction = !fnStr.startsWith("function") && !fnStr.startsWith("(");
2708
- return `return (${appendFunction ? "function " : ""}${fnStr}).apply(this, arguments)`;
2709
- };
2710
- var serializeValue = (value) => typeof value === "function" ? serializeFn(value) : fastClone(value);
2711
- var serializeComponentInfo = (_a) => {
2712
- var _b = _a, {
2713
- inputs
2714
- } = _b, info = __objRest2(_b, ["inputs"]);
2715
- return __spreadProps8(__spreadValues11({}, fastClone(info)), {
2716
- inputs: inputs == null ? void 0 : inputs.map((input) => Object.entries(input).reduce((acc, [key, value]) => __spreadProps8(__spreadValues11({}, acc), {
2717
- [key]: serializeValue(value)
2718
- }), {}))
2719
- });
2720
- };
2721
-
2722
- // src/components/content/components/styles.jsx
2723
- import { createSignal as createSignal11 } from "solid-js";
2724
-
2725
- // src/components/content/components/styles.helpers.js
2726
- var getCssFromFont = (font) => {
2727
- var _a, _b;
2728
- const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
2729
- const name = family.split(",")[0];
2730
- const url = (_b = font.fileUrl) != null ? _b : (_a = font == null ? void 0 : font.files) == null ? void 0 : _a.regular;
2731
- let str = "";
2732
- if (url && family && name) {
2733
- str += `
2734
- @font-face {
2735
- font-family: "${family}";
2736
- src: local("${name}"), url('${url}') format('woff2');
2737
- font-display: fallback;
2738
- font-weight: 400;
2739
- }
2740
- `.trim();
2741
- }
2742
- if (font.files) {
2743
- for (const weight in font.files) {
2744
- const isNumber = String(Number(weight)) === weight;
2745
- if (!isNumber) {
2746
- continue;
2747
- }
2748
- const weightUrl = font.files[weight];
2749
- if (weightUrl && weightUrl !== url) {
2750
- str += `
2751
- @font-face {
2752
- font-family: "${family}";
2753
- src: url('${weightUrl}') format('woff2');
2754
- font-display: fallback;
2755
- font-weight: ${weight};
2756
- }
2757
- `.trim();
2758
- }
2759
- }
2760
- }
2761
- return str;
2762
- };
2763
- var getFontCss = ({
2764
- customFonts
2765
- }) => {
2766
- var _a;
2767
- return ((_a = customFonts == null ? void 0 : customFonts.map((font) => getCssFromFont(font))) == null ? void 0 : _a.join(" ")) || "";
2768
- };
2769
- var getCss = ({
2770
- cssCode,
2771
- contentId
2772
- }) => {
2773
- if (!cssCode) {
2774
- return "";
2775
- }
2776
- if (!contentId) {
2777
- return cssCode;
2778
- }
2779
- return (cssCode == null ? void 0 : cssCode.replace(/&/g, `div[builder-content-id="${contentId}"]`)) || "";
2780
- };
2781
-
2782
- // src/components/content/components/styles.jsx
2783
- function ContentStyles(props) {
2784
- const [injectedStyles, setInjectedStyles] = createSignal11(
2785
- `
2786
- ${getCss({
2787
- cssCode: props.cssCode,
2788
- contentId: props.contentId
2789
- })}
2790
- ${getFontCss({
2791
- customFonts: props.customFonts
2792
- })}
2793
-
2794
- .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
2795
- margin: 0;
2796
- }
2797
- .builder-text > p, .builder-text > .builder-paragraph {
2798
- color: inherit;
2799
- line-height: inherit;
2800
- letter-spacing: inherit;
2801
- font-weight: inherit;
2802
- font-size: inherit;
2803
- text-align: inherit;
2804
- font-family: inherit;
2805
- }
2806
- `.trim()
2807
- );
2808
- return <Inlined_styles_default styles={injectedStyles()} />;
2809
- }
2810
- var Styles_default = ContentStyles;
2811
-
2812
- // src/components/content/content.helpers.js
2813
- var __defProp12 = Object.defineProperty;
2814
- var __defProps9 = Object.defineProperties;
2815
- var __getOwnPropDescs9 = Object.getOwnPropertyDescriptors;
2816
- var __getOwnPropSymbols12 = Object.getOwnPropertySymbols;
2817
- var __hasOwnProp12 = Object.prototype.hasOwnProperty;
2818
- var __propIsEnum12 = Object.prototype.propertyIsEnumerable;
2819
- var __defNormalProp12 = (obj, key, value) => key in obj ? __defProp12(obj, key, {
2820
- enumerable: true,
2821
- configurable: true,
2822
- writable: true,
2823
- value
2824
- }) : obj[key] = value;
2825
- var __spreadValues12 = (a, b) => {
2826
- for (var prop in b || (b = {}))
2827
- if (__hasOwnProp12.call(b, prop))
2828
- __defNormalProp12(a, prop, b[prop]);
2829
- if (__getOwnPropSymbols12)
2830
- for (var prop of __getOwnPropSymbols12(b)) {
2831
- if (__propIsEnum12.call(b, prop))
2832
- __defNormalProp12(a, prop, b[prop]);
2833
- }
2834
- return a;
2835
- };
2836
- var __spreadProps9 = (a, b) => __defProps9(a, __getOwnPropDescs9(b));
2837
- var getContextStateInitialValue = ({
2838
- content,
2839
- data,
2840
- locale
2841
- }) => {
2842
- var _a, _b, _c;
2843
- const defaultValues = {};
2844
- (_b = (_a = content == null ? void 0 : content.data) == null ? void 0 : _a.inputs) == null ? void 0 : _b.forEach((input) => {
2845
- var _a2;
2846
- if (input.name && input.defaultValue !== void 0 && ((_a2 = content == null ? void 0 : content.data) == null ? void 0 : _a2.state) && content.data.state[input.name] === void 0) {
2847
- defaultValues[input.name] = input.defaultValue;
2848
- }
2849
- });
2850
- const stateToUse = __spreadValues12(__spreadValues12(__spreadValues12({}, (_c = content == null ? void 0 : content.data) == null ? void 0 : _c.state), data), locale ? {
2851
- locale
2852
- } : {});
2853
- return __spreadValues12(__spreadValues12({}, defaultValues), stateToUse);
2854
- };
2855
- var getContentInitialValue = ({
2856
- content,
2857
- data
2858
- }) => {
2859
- return !content ? void 0 : __spreadProps9(__spreadValues12({}, content), {
2860
- data: __spreadValues12(__spreadValues12({}, content == null ? void 0 : content.data), data),
2861
- meta: content == null ? void 0 : content.meta
2862
- });
2863
- };
2864
-
2865
- // src/components/content/components/enable-editor.jsx
2866
- import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal12 } from "solid-js";
2867
-
2868
- // src/functions/get-global-this.js
2869
- function getGlobalThis() {
2870
- if (typeof globalThis !== "undefined") {
2871
- return globalThis;
2872
- }
2873
- if (typeof window !== "undefined") {
2874
- return window;
2875
- }
2876
- if (typeof global !== "undefined") {
2877
- return global;
2878
- }
2879
- if (typeof self !== "undefined") {
2880
- return self;
2881
- }
2882
- return globalThis;
2883
- }
2884
-
2885
- // src/functions/get-fetch.js
2886
- function getFetch() {
2887
- const globalFetch = getGlobalThis().fetch;
2888
- if (typeof globalFetch === "undefined") {
2889
- throw new Error("Builder SDK could not find a global `fetch` function");
2890
- }
2891
- return globalFetch;
2892
- }
2893
- var fetch2 = getFetch();
2894
-
2895
- // src/helpers/url.js
2896
- var getTopLevelDomain = (host) => {
2897
- if (host === "localhost" || host === "127.0.0.1") {
2898
- return host;
2899
- }
2900
- const parts = host.split(".");
2901
- if (parts.length > 2) {
2902
- return parts.slice(1).join(".");
2903
- }
2904
- return host;
2905
- };
2906
-
2907
- // src/helpers/cookie.js
2908
- var __async = (__this, __arguments, generator) => {
2909
- return new Promise((resolve, reject) => {
2910
- var fulfilled = (value) => {
2911
- try {
2912
- step(generator.next(value));
2913
- } catch (e) {
2914
- reject(e);
2915
- }
2916
- };
2917
- var rejected = (value) => {
2918
- try {
2919
- step(generator.throw(value));
2920
- } catch (e) {
2921
- reject(e);
2922
- }
2923
- };
2924
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
2925
- step((generator = generator.apply(__this, __arguments)).next());
2926
- });
2927
- };
2928
- var getCookieSync = ({
2929
- name,
2930
- canTrack
2931
- }) => {
2932
- var _a;
2933
- try {
2934
- if (!canTrack) {
2935
- return void 0;
2936
- }
2937
- return (_a = document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))) == null ? void 0 : _a.split("=")[1];
2938
- } catch (err) {
2939
- logger.warn("[COOKIE] GET error: ", (err == null ? void 0 : err.message) || err);
2940
- return void 0;
2941
- }
2942
- };
2943
- var getCookie = (args) => __async(void 0, null, function* () {
2944
- return getCookieSync(args);
2945
- });
2946
- var stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
2947
- var SECURE_CONFIG = [["secure", ""], ["SameSite", "None"]];
2948
- var createCookieString = ({
2949
- name,
2950
- value,
2951
- expires
2952
- }) => {
2953
- const secure = isBrowser() ? location.protocol === "https:" : true;
2954
- const secureObj = secure ? SECURE_CONFIG : [[]];
2955
- const expiresObj = expires ? [["expires", expires.toUTCString()]] : [[]];
2956
- const cookieValue = [[name, value], ...expiresObj, ["path", "/"], ["domain", getTopLevelDomain(window.location.hostname)], ...secureObj];
2957
- const cookie = stringifyCookie(cookieValue);
2958
- return cookie;
2959
- };
2960
- var setCookie = (_0) => __async(void 0, [_0], function* ({
2961
- name,
2962
- value,
2963
- expires,
2964
- canTrack
2965
- }) {
2966
- try {
2967
- if (!canTrack) {
2968
- return;
2969
- }
2970
- const cookie = createCookieString({
2971
- name,
2972
- value,
2973
- expires
2974
- });
2975
- document.cookie = cookie;
2976
- } catch (err) {
2977
- logger.warn("[COOKIE] SET error: ", (err == null ? void 0 : err.message) || err);
2978
- }
2979
- });
2980
-
2981
- // src/helpers/uuid.js
2982
- function uuidv4() {
2983
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
2984
- const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
2985
- return v.toString(16);
2986
- });
2987
- }
2988
- function uuid() {
2989
- return uuidv4().replace(/-/g, "");
2990
- }
2991
-
2992
- // src/helpers/sessionId.js
2993
- var __async2 = (__this, __arguments, generator) => {
2994
- return new Promise((resolve, reject) => {
2995
- var fulfilled = (value) => {
2996
- try {
2997
- step(generator.next(value));
2998
- } catch (e) {
2999
- reject(e);
3000
- }
3001
- };
3002
- var rejected = (value) => {
3003
- try {
3004
- step(generator.throw(value));
3005
- } catch (e) {
3006
- reject(e);
3007
- }
3008
- };
3009
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3010
- step((generator = generator.apply(__this, __arguments)).next());
3011
- });
3012
- };
3013
- var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
3014
- var getSessionId = (_0) => __async2(void 0, [_0], function* ({
3015
- canTrack
3016
- }) {
3017
- if (!canTrack) {
3018
- return void 0;
3019
- }
3020
- const sessionId = yield getCookie({
3021
- name: SESSION_LOCAL_STORAGE_KEY,
3022
- canTrack
3023
- });
3024
- if (checkIsDefined(sessionId)) {
3025
- return sessionId;
3026
- } else {
3027
- const newSessionId = createSessionId();
3028
- setSessionId({
3029
- id: newSessionId,
3030
- canTrack
3031
- });
3032
- return newSessionId;
3033
- }
3034
- });
3035
- var createSessionId = () => uuid();
3036
- var setSessionId = ({
3037
- id,
3038
- canTrack
3039
- }) => setCookie({
3040
- name: SESSION_LOCAL_STORAGE_KEY,
3041
- value: id,
3042
- canTrack
3043
- });
3044
-
3045
- // src/helpers/localStorage.js
3046
- var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
3047
- var getLocalStorageItem = ({
3048
- key,
3049
- canTrack
3050
- }) => {
3051
- var _a;
3052
- try {
3053
- if (canTrack) {
3054
- return (_a = getLocalStorage()) == null ? void 0 : _a.getItem(key);
3055
- }
3056
- return void 0;
3057
- } catch (err) {
3058
- return void 0;
3059
- }
3060
- };
3061
- var setLocalStorageItem = ({
3062
- key,
2563
+ // src/components/content-variants/helpers.ts
2564
+ var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
2565
+ ...variant,
2566
+ testVariationId: variant.id,
2567
+ id: content?.id
2568
+ }));
2569
+ var checkShouldRunVariants = ({
3063
2570
  canTrack,
3064
- value
3065
- }) => {
3066
- var _a;
3067
- try {
3068
- if (canTrack) {
3069
- (_a = getLocalStorage()) == null ? void 0 : _a.setItem(key, value);
3070
- }
3071
- } catch (err) {
3072
- }
3073
- };
3074
-
3075
- // src/helpers/visitorId.js
3076
- var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
3077
- var getVisitorId = ({
3078
- canTrack
2571
+ content
3079
2572
  }) => {
3080
- if (!canTrack) {
3081
- return void 0;
3082
- }
3083
- const visitorId = getLocalStorageItem({
3084
- key: VISITOR_LOCAL_STORAGE_KEY,
3085
- canTrack
3086
- });
3087
- if (checkIsDefined(visitorId)) {
3088
- return visitorId;
3089
- } else {
3090
- const newVisitorId = createVisitorId();
3091
- setVisitorId({
3092
- id: newVisitorId,
3093
- canTrack
3094
- });
3095
- return newVisitorId;
3096
- }
3097
- };
3098
- var createVisitorId = () => uuid();
3099
- var setVisitorId = ({
3100
- id,
3101
- canTrack
3102
- }) => setLocalStorageItem({
3103
- key: VISITOR_LOCAL_STORAGE_KEY,
3104
- value: id,
3105
- canTrack
3106
- });
3107
-
3108
- // src/functions/track/index.js
3109
- var __defProp13 = Object.defineProperty;
3110
- var __defProps10 = Object.defineProperties;
3111
- var __getOwnPropDescs10 = Object.getOwnPropertyDescriptors;
3112
- var __getOwnPropSymbols13 = Object.getOwnPropertySymbols;
3113
- var __hasOwnProp13 = Object.prototype.hasOwnProperty;
3114
- var __propIsEnum13 = Object.prototype.propertyIsEnumerable;
3115
- var __defNormalProp13 = (obj, key, value) => key in obj ? __defProp13(obj, key, {
3116
- enumerable: true,
3117
- configurable: true,
3118
- writable: true,
3119
- value
3120
- }) : obj[key] = value;
3121
- var __spreadValues13 = (a, b) => {
3122
- for (var prop in b || (b = {}))
3123
- if (__hasOwnProp13.call(b, prop))
3124
- __defNormalProp13(a, prop, b[prop]);
3125
- if (__getOwnPropSymbols13)
3126
- for (var prop of __getOwnPropSymbols13(b)) {
3127
- if (__propIsEnum13.call(b, prop))
3128
- __defNormalProp13(a, prop, b[prop]);
3129
- }
3130
- return a;
3131
- };
3132
- var __spreadProps10 = (a, b) => __defProps10(a, __getOwnPropDescs10(b));
3133
- var __objRest3 = (source, exclude) => {
3134
- var target = {};
3135
- for (var prop in source)
3136
- if (__hasOwnProp13.call(source, prop) && exclude.indexOf(prop) < 0)
3137
- target[prop] = source[prop];
3138
- if (source != null && __getOwnPropSymbols13)
3139
- for (var prop of __getOwnPropSymbols13(source)) {
3140
- if (exclude.indexOf(prop) < 0 && __propIsEnum13.call(source, prop))
3141
- target[prop] = source[prop];
3142
- }
3143
- return target;
2573
+ const hasVariants = getVariants(content).length > 0;
2574
+ if (TARGET === "reactNative")
2575
+ return false;
2576
+ if (!hasVariants)
2577
+ return false;
2578
+ if (!canTrack)
2579
+ return false;
2580
+ if (TARGET === "vue2" || TARGET === "vue3")
2581
+ return true;
2582
+ if (isBrowser())
2583
+ return false;
2584
+ return true;
3144
2585
  };
3145
- var __async3 = (__this, __arguments, generator) => {
3146
- return new Promise((resolve, reject) => {
3147
- var fulfilled = (value) => {
3148
- try {
3149
- step(generator.next(value));
3150
- } catch (e) {
3151
- reject(e);
3152
- }
3153
- };
3154
- var rejected = (value) => {
3155
- try {
3156
- step(generator.throw(value));
3157
- } catch (e) {
3158
- reject(e);
2586
+ function bldrAbTest(contentId, variants, isHydrationTarget2) {
2587
+ function getAndSetVariantId2() {
2588
+ function setCookie2(name, value, days) {
2589
+ let expires = "";
2590
+ if (days) {
2591
+ const date = /* @__PURE__ */ new Date();
2592
+ date.setTime(date.getTime() + days * 24 * 60 * 60 * 1e3);
2593
+ expires = "; expires=" + date.toUTCString();
3159
2594
  }
3160
- };
3161
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3162
- step((generator = generator.apply(__this, __arguments)).next());
3163
- });
3164
- };
3165
- var getTrackingEventData = (_0) => __async3(void 0, [_0], function* ({
3166
- canTrack
3167
- }) {
3168
- if (!canTrack) {
3169
- return {
3170
- visitorId: void 0,
3171
- sessionId: void 0
3172
- };
3173
- }
3174
- const sessionId = yield getSessionId({
3175
- canTrack
3176
- });
3177
- const visitorId = getVisitorId({
3178
- canTrack
3179
- });
3180
- return {
3181
- sessionId,
3182
- visitorId
3183
- };
3184
- });
3185
- var createEvent = (_a) => __async3(void 0, null, function* () {
3186
- var _b = _a, {
3187
- type: eventType,
3188
- canTrack,
3189
- apiKey,
3190
- metadata
3191
- } = _b, properties = __objRest3(_b, ["type", "canTrack", "apiKey", "metadata"]);
3192
- return {
3193
- type: eventType,
3194
- data: __spreadProps10(__spreadValues13(__spreadProps10(__spreadValues13({}, properties), {
3195
- metadata: __spreadValues13({
3196
- url: location.href
3197
- }, metadata)
3198
- }), yield getTrackingEventData({
3199
- canTrack
3200
- })), {
3201
- userAttributes: getUserAttributes(),
3202
- ownerId: apiKey
3203
- })
3204
- };
3205
- });
3206
- function _track(eventProps) {
3207
- return __async3(this, null, function* () {
3208
- if (!eventProps.apiKey) {
3209
- logger.error("Missing API key for track call. Please provide your API key.");
3210
- return;
3211
- }
3212
- if (!eventProps.canTrack) {
3213
- return;
3214
- }
3215
- if (isEditing()) {
3216
- return;
3217
- }
3218
- if (!(isBrowser() || TARGET === "reactNative")) {
3219
- return;
2595
+ document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
3220
2596
  }
3221
- return fetch(`https://cdn.builder.io/api/v1/track`, {
3222
- method: "POST",
3223
- body: JSON.stringify({
3224
- events: [yield createEvent(eventProps)]
3225
- }),
3226
- headers: {
3227
- "content-type": "application/json"
3228
- },
3229
- mode: "cors"
3230
- }).catch((err) => {
3231
- });
3232
- });
3233
- }
3234
- var track = (args) => _track(__spreadProps10(__spreadValues13({}, args), {
3235
- canTrack: true
3236
- }));
3237
-
3238
- // src/constants/sdk-version.js
3239
- var SDK_VERSION = "0.7.1-1";
3240
-
3241
- // src/functions/register.js
3242
- var registry = {};
3243
- function register(type, info) {
3244
- let typeList = registry[type];
3245
- if (!typeList) {
3246
- typeList = registry[type] = [];
3247
- }
3248
- typeList.push(info);
3249
- if (isBrowser()) {
3250
- const message = {
3251
- type: "builder.register",
3252
- data: {
3253
- type,
3254
- info
3255
- }
3256
- };
3257
- try {
3258
- parent.postMessage(message, "*");
3259
- if (parent !== window) {
3260
- window.postMessage(message, "*");
2597
+ function getCookie2(name) {
2598
+ const nameEQ = name + "=";
2599
+ const ca = document.cookie.split(";");
2600
+ for (let i = 0; i < ca.length; i++) {
2601
+ let c = ca[i];
2602
+ while (c.charAt(0) === " ")
2603
+ c = c.substring(1, c.length);
2604
+ if (c.indexOf(nameEQ) === 0)
2605
+ return c.substring(nameEQ.length, c.length);
3261
2606
  }
3262
- } catch (err) {
2607
+ return null;
3263
2608
  }
3264
- }
3265
- }
3266
-
3267
- // src/scripts/init-editing.js
3268
- var registerInsertMenu = () => {
3269
- register("insertMenu", {
3270
- name: "_default",
3271
- default: true,
3272
- items: [{
3273
- name: "Box"
3274
- }, {
3275
- name: "Text"
3276
- }, {
3277
- name: "Image"
3278
- }, {
3279
- name: "Columns"
3280
- }, ...TARGET === "reactNative" ? [] : [{
3281
- name: "Core:Section"
3282
- }, {
3283
- name: "Core:Button"
3284
- }, {
3285
- name: "Embed"
3286
- }, {
3287
- name: "Custom Code"
3288
- }]]
3289
- });
3290
- };
3291
- var isSetupForEditing = false;
3292
- var setupBrowserForEditing = (options = {}) => {
3293
- var _a, _b;
3294
- if (isSetupForEditing) {
3295
- return;
3296
- }
3297
- isSetupForEditing = true;
3298
- if (isBrowser()) {
3299
- (_a = window.parent) == null ? void 0 : _a.postMessage({
3300
- type: "builder.sdkInfo",
3301
- data: {
3302
- target: TARGET,
3303
- version: SDK_VERSION,
3304
- supportsPatchUpdates: false,
3305
- supportsAddBlockScoping: true,
3306
- supportsCustomBreakpoints: true
3307
- }
3308
- }, "*");
3309
- (_b = window.parent) == null ? void 0 : _b.postMessage({
3310
- type: "builder.updateContent",
3311
- data: {
3312
- options
3313
- }
3314
- }, "*");
3315
- window.addEventListener("message", ({
3316
- data
3317
- }) => {
3318
- var _a2, _b2;
3319
- if (!(data == null ? void 0 : data.type)) {
3320
- return;
3321
- }
3322
- switch (data.type) {
3323
- case "builder.evaluate": {
3324
- const text = data.data.text;
3325
- const args = data.data.arguments || [];
3326
- const id = data.data.id;
3327
- const fn = new Function(text);
3328
- let result;
3329
- let error = null;
3330
- try {
3331
- result = fn.apply(null, args);
3332
- } catch (err) {
3333
- error = err;
3334
- }
3335
- if (error) {
3336
- (_a2 = window.parent) == null ? void 0 : _a2.postMessage({
3337
- type: "builder.evaluateError",
3338
- data: {
3339
- id,
3340
- error: error.message
3341
- }
3342
- }, "*");
3343
- } else {
3344
- if (result && typeof result.then === "function") {
3345
- result.then((finalResult) => {
3346
- var _a3;
3347
- (_a3 = window.parent) == null ? void 0 : _a3.postMessage({
3348
- type: "builder.evaluateResult",
3349
- data: {
3350
- id,
3351
- result: finalResult
3352
- }
3353
- }, "*");
3354
- }).catch(console.error);
3355
- } else {
3356
- (_b2 = window.parent) == null ? void 0 : _b2.postMessage({
3357
- type: "builder.evaluateResult",
3358
- data: {
3359
- result,
3360
- id
3361
- }
3362
- }, "*");
3363
- }
3364
- }
3365
- break;
3366
- }
2609
+ const cookieName = `builder.tests.${contentId}`;
2610
+ const variantInCookie = getCookie2(cookieName);
2611
+ const availableIDs = variants.map((vr) => vr.id).concat(contentId);
2612
+ if (variantInCookie && availableIDs.includes(variantInCookie)) {
2613
+ return variantInCookie;
2614
+ }
2615
+ let n = 0;
2616
+ const random = Math.random();
2617
+ for (let i = 0; i < variants.length; i++) {
2618
+ const variant = variants[i];
2619
+ const testRatio = variant.testRatio;
2620
+ n += testRatio;
2621
+ if (random < n) {
2622
+ setCookie2(cookieName, variant.id);
2623
+ return variant.id;
3367
2624
  }
3368
- });
2625
+ }
2626
+ setCookie2(cookieName, contentId);
2627
+ return contentId;
2628
+ }
2629
+ const winningVariantId = getAndSetVariantId2();
2630
+ const styleEl = document.currentScript?.previousElementSibling;
2631
+ if (isHydrationTarget2) {
2632
+ styleEl.remove();
2633
+ const thisScriptEl = document.currentScript;
2634
+ thisScriptEl?.remove();
2635
+ } else {
2636
+ const newStyleStr = variants.concat({
2637
+ id: contentId
2638
+ }).filter((variant) => variant.id !== winningVariantId).map((value) => {
2639
+ return `.variant-${value.id} { display: none; }
2640
+ `;
2641
+ }).join("");
2642
+ styleEl.innerHTML = newStyleStr;
3369
2643
  }
3370
- };
3371
-
3372
- // src/functions/track/interaction.js
3373
- function round(num) {
3374
- return Math.round(num * 1e3) / 1e3;
3375
2644
  }
3376
- var findParentElement = (target, callback, checkElement = true) => {
3377
- if (!(target instanceof HTMLElement)) {
3378
- return null;
2645
+ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
2646
+ if (!navigator.cookieEnabled) {
2647
+ return;
3379
2648
  }
3380
- let parent2 = checkElement ? target : target.parentElement;
3381
- do {
3382
- if (!parent2) {
3383
- return null;
3384
- }
3385
- const matches = callback(parent2);
3386
- if (matches) {
3387
- return parent2;
3388
- }
3389
- } while (parent2 = parent2.parentElement);
3390
- return null;
3391
- };
3392
- var findBuilderParent = (target) => findParentElement(target, (el) => {
3393
- const id = el.getAttribute("builder-id") || el.id;
3394
- return Boolean((id == null ? void 0 : id.indexOf("builder-")) === 0);
3395
- });
3396
- var computeOffset = ({
3397
- event,
3398
- target
3399
- }) => {
3400
- const targetRect = target.getBoundingClientRect();
3401
- const xOffset = event.clientX - targetRect.left;
3402
- const yOffset = event.clientY - targetRect.top;
3403
- const xRatio = round(xOffset / targetRect.width);
3404
- const yRatio = round(yOffset / targetRect.height);
3405
- return {
3406
- x: xRatio,
3407
- y: yRatio
3408
- };
3409
- };
3410
- var getInteractionPropertiesForEvent = (event) => {
3411
- const target = event.target;
3412
- const targetBuilderElement = target && findBuilderParent(target);
3413
- const builderId = (targetBuilderElement == null ? void 0 : targetBuilderElement.getAttribute("builder-id")) || (targetBuilderElement == null ? void 0 : targetBuilderElement.id);
3414
- return {
3415
- targetBuilderElement: builderId || void 0,
3416
- metadata: {
3417
- targetOffset: target ? computeOffset({
3418
- event,
3419
- target
3420
- }) : void 0,
3421
- builderTargetOffset: targetBuilderElement ? computeOffset({
3422
- event,
3423
- target: targetBuilderElement
3424
- }) : void 0,
3425
- builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
2649
+ function getCookie2(name) {
2650
+ const nameEQ = name + "=";
2651
+ const ca = document.cookie.split(";");
2652
+ for (let i = 0; i < ca.length; i++) {
2653
+ let c = ca[i];
2654
+ while (c.charAt(0) === " ")
2655
+ c = c.substring(1, c.length);
2656
+ if (c.indexOf(nameEQ) === 0)
2657
+ return c.substring(nameEQ.length, c.length);
3426
2658
  }
3427
- };
3428
- };
3429
-
3430
- // src/helpers/ab-tests.js
3431
- var __defProp14 = Object.defineProperty;
3432
- var __getOwnPropSymbols14 = Object.getOwnPropertySymbols;
3433
- var __hasOwnProp14 = Object.prototype.hasOwnProperty;
3434
- var __propIsEnum14 = Object.prototype.propertyIsEnumerable;
3435
- var __defNormalProp14 = (obj, key, value) => key in obj ? __defProp14(obj, key, {
3436
- enumerable: true,
3437
- configurable: true,
3438
- writable: true,
3439
- value
3440
- }) : obj[key] = value;
3441
- var __spreadValues14 = (a, b) => {
3442
- for (var prop in b || (b = {}))
3443
- if (__hasOwnProp14.call(b, prop))
3444
- __defNormalProp14(a, prop, b[prop]);
3445
- if (__getOwnPropSymbols14)
3446
- for (var prop of __getOwnPropSymbols14(b)) {
3447
- if (__propIsEnum14.call(b, prop))
3448
- __defNormalProp14(a, prop, b[prop]);
2659
+ return null;
2660
+ }
2661
+ const cookieName = `builder.tests.${defaultContentId}`;
2662
+ const variantId = getCookie2(cookieName);
2663
+ const parentDiv = document.currentScript?.parentElement;
2664
+ const variantIsDefaultContent = variantContentId === defaultContentId;
2665
+ if (variantId === variantContentId) {
2666
+ if (variantIsDefaultContent) {
2667
+ return;
3449
2668
  }
3450
- return a;
3451
- };
3452
- var __async4 = (__this, __arguments, generator) => {
3453
- return new Promise((resolve, reject) => {
3454
- var fulfilled = (value) => {
3455
- try {
3456
- step(generator.next(value));
3457
- } catch (e) {
3458
- reject(e);
3459
- }
3460
- };
3461
- var rejected = (value) => {
3462
- try {
3463
- step(generator.throw(value));
3464
- } catch (e) {
3465
- reject(e);
2669
+ parentDiv?.removeAttribute("hidden");
2670
+ parentDiv?.removeAttribute("aria-hidden");
2671
+ } else {
2672
+ if (variantIsDefaultContent) {
2673
+ if (isHydrationTarget2) {
2674
+ parentDiv?.remove();
2675
+ } else {
2676
+ parentDiv?.setAttribute("hidden", "true");
2677
+ parentDiv?.setAttribute("aria-hidden", "true");
3466
2678
  }
3467
- };
3468
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3469
- step((generator = generator.apply(__this, __arguments)).next());
3470
- });
3471
- };
3472
- var BUILDER_STORE_PREFIX = "builder.tests";
3473
- var getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
3474
- var getContentVariationCookie = ({
3475
- contentId
3476
- }) => getCookie({
3477
- name: getContentTestKey(contentId),
3478
- canTrack: true
3479
- });
3480
- var getContentVariationCookieSync = ({
3481
- contentId
3482
- }) => getCookieSync({
3483
- name: getContentTestKey(contentId),
3484
- canTrack: true
3485
- });
3486
- var setContentVariationCookie = ({
3487
- contentId,
3488
- value
3489
- }) => setCookie({
3490
- name: getContentTestKey(contentId),
3491
- value,
3492
- canTrack: true
3493
- });
3494
- var checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
3495
- var getRandomVariationId = ({
3496
- id,
3497
- variations
3498
- }) => {
3499
- var _a;
3500
- let n = 0;
3501
- const random = Math.random();
3502
- for (const id2 in variations) {
3503
- const testRatio = (_a = variations[id2]) == null ? void 0 : _a.testRatio;
3504
- n += testRatio;
3505
- if (random < n) {
3506
- return id2;
3507
2679
  }
2680
+ return;
3508
2681
  }
3509
- return id;
2682
+ return;
2683
+ }
2684
+ var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
2685
+ var isHydrationTarget = getIsHydrationTarget(TARGET);
2686
+ var AB_TEST_FN_NAME = "builderIoAbTest";
2687
+ var CONTENT_FN_NAME = "builderIoRenderContent";
2688
+ var getScriptString = () => {
2689
+ const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
2690
+ const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
2691
+ return `
2692
+ window.${AB_TEST_FN_NAME} = ${fnStr}
2693
+ window.${CONTENT_FN_NAME} = ${fnStr2}
2694
+ `;
3510
2695
  };
3511
- var getAndSetVariantId = (args) => {
3512
- const randomVariationId = getRandomVariationId(args);
3513
- setContentVariationCookie({
3514
- contentId: args.id,
3515
- value: randomVariationId
3516
- }).catch((err) => {
3517
- logger.error("could not store A/B test variation: ", err);
3518
- });
3519
- return randomVariationId;
2696
+ var getVariantsScriptString = (variants, contentId) => {
2697
+ return `
2698
+ window.${AB_TEST_FN_NAME}("${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget})`;
3520
2699
  };
3521
- var getTestFields = ({
3522
- item,
3523
- testGroupId
2700
+ var getRenderContentScriptString = ({
2701
+ contentId,
2702
+ variationId
3524
2703
  }) => {
3525
- const variationValue = item.variations[testGroupId];
3526
- if (testGroupId === item.id || !variationValue) {
3527
- return {
3528
- testVariationId: item.id,
3529
- testVariationName: "Default"
3530
- };
3531
- } else {
3532
- return {
3533
- data: variationValue.data,
3534
- testVariationId: variationValue.id,
3535
- testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
3536
- };
3537
- }
2704
+ return `
2705
+ window.${CONTENT_FN_NAME}("${variationId}", "${contentId}", ${isHydrationTarget})`;
3538
2706
  };
3539
- var handleABTestingSync = ({
3540
- item,
3541
- canTrack
3542
- }) => {
3543
- if (TARGET === "reactNative")
3544
- return item;
3545
- if (!canTrack) {
3546
- return item;
3547
- }
3548
- if (!item) {
3549
- return void 0;
2707
+
2708
+ // src/components/inlined-script.tsx
2709
+ function InlinedScript(props) {
2710
+ return <script innerHTML={props.scriptStr} id={props.id} />;
2711
+ }
2712
+ var Inlined_script_default = InlinedScript;
2713
+
2714
+ // src/components/content/components/enable-editor.tsx
2715
+ import { Show as Show9, onMount as onMount2, on as on2, createEffect as createEffect2, createSignal as createSignal9 } from "solid-js";
2716
+
2717
+ // src/helpers/preview-lru-cache/get.ts
2718
+ function getPreviewContent(_searchParams) {
2719
+ return void 0;
2720
+ }
2721
+
2722
+ // src/functions/get-global-this.ts
2723
+ function getGlobalThis() {
2724
+ if (typeof globalThis !== "undefined") {
2725
+ return globalThis;
3550
2726
  }
3551
- if (!checkIsBuilderContentWithVariations(item)) {
3552
- return item;
2727
+ if (typeof window !== "undefined") {
2728
+ return window;
3553
2729
  }
3554
- const testGroupId = getContentVariationCookieSync({
3555
- contentId: item.id
3556
- }) || getAndSetVariantId({
3557
- variations: item.variations,
3558
- id: item.id
3559
- });
3560
- const variationValue = getTestFields({
3561
- item,
3562
- testGroupId
3563
- });
3564
- return __spreadValues14(__spreadValues14({}, item), variationValue);
3565
- };
3566
- var handleABTesting = (_0) => __async4(void 0, [_0], function* ({
3567
- item,
3568
- canTrack
3569
- }) {
3570
- if (!canTrack) {
3571
- return item;
2730
+ if (typeof global !== "undefined") {
2731
+ return global;
3572
2732
  }
3573
- if (!checkIsBuilderContentWithVariations(item)) {
3574
- return item;
2733
+ if (typeof self !== "undefined") {
2734
+ return self;
3575
2735
  }
3576
- const cookieValue = yield getContentVariationCookie({
3577
- contentId: item.id
3578
- });
3579
- const testGroupId = cookieValue || getAndSetVariantId({
3580
- variations: item.variations,
3581
- id: item.id
3582
- });
3583
- const variationValue = getTestFields({
3584
- item,
3585
- testGroupId
3586
- });
3587
- return __spreadValues14(__spreadValues14({}, item), variationValue);
3588
- });
3589
-
3590
- // src/helpers/canTrack.js
3591
- var getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
2736
+ return globalThis;
2737
+ }
3592
2738
 
3593
- // src/helpers/preview-lru-cache/get.js
3594
- function getPreviewContent(_searchParams) {
3595
- return void 0;
2739
+ // src/functions/get-fetch.ts
2740
+ function getFetch() {
2741
+ const globalFetch = getGlobalThis().fetch;
2742
+ if (typeof globalFetch === "undefined") {
2743
+ throw new Error("Builder SDK could not find a global `fetch` function");
2744
+ }
2745
+ return globalFetch;
3596
2746
  }
2747
+ var fetch2 = getFetch();
3597
2748
 
3598
- // src/helpers/flatten.js
3599
- var __defProp15 = Object.defineProperty;
3600
- var __defProps11 = Object.defineProperties;
3601
- var __getOwnPropDescs11 = Object.getOwnPropertyDescriptors;
3602
- var __getOwnPropSymbols15 = Object.getOwnPropertySymbols;
3603
- var __hasOwnProp15 = Object.prototype.hasOwnProperty;
3604
- var __propIsEnum15 = Object.prototype.propertyIsEnumerable;
3605
- var __defNormalProp15 = (obj, key, value) => key in obj ? __defProp15(obj, key, {
3606
- enumerable: true,
3607
- configurable: true,
3608
- writable: true,
3609
- value
3610
- }) : obj[key] = value;
3611
- var __spreadValues15 = (a, b) => {
3612
- for (var prop in b || (b = {}))
3613
- if (__hasOwnProp15.call(b, prop))
3614
- __defNormalProp15(a, prop, b[prop]);
3615
- if (__getOwnPropSymbols15)
3616
- for (var prop of __getOwnPropSymbols15(b)) {
3617
- if (__propIsEnum15.call(b, prop))
3618
- __defNormalProp15(a, prop, b[prop]);
3619
- }
3620
- return a;
3621
- };
3622
- var __spreadProps11 = (a, b) => __defProps11(a, __getOwnPropDescs11(b));
2749
+ // src/helpers/flatten.ts
3623
2750
  function flatten(object, path = null, separator = ".") {
3624
2751
  return Object.keys(object).reduce((acc, key) => {
3625
2752
  const value = object[key];
3626
2753
  const newPath = [path, key].filter(Boolean).join(separator);
3627
2754
  const isObject = [typeof value === "object", value !== null, !(Array.isArray(value) && value.length === 0)].every(Boolean);
3628
- return isObject ? __spreadValues15(__spreadValues15({}, acc), flatten(value, newPath, separator)) : __spreadProps11(__spreadValues15({}, acc), {
2755
+ return isObject ? {
2756
+ ...acc,
2757
+ ...flatten(value, newPath, separator)
2758
+ } : {
2759
+ ...acc,
3629
2760
  [newPath]: value
3630
- });
2761
+ };
3631
2762
  }, {});
3632
2763
  }
3633
2764
 
3634
- // src/functions/get-builder-search-params/index.js
2765
+ // src/types/api-version.ts
2766
+ var DEFAULT_API_VERSION = "v3";
2767
+
2768
+ // src/functions/get-builder-search-params/index.ts
3635
2769
  var BUILDER_SEARCHPARAMS_PREFIX = "builder.";
3636
2770
  var BUILDER_OPTIONS_PREFIX = "options.";
3637
2771
  var convertSearchParamsToQueryObject = (searchParams) => {
@@ -3664,31 +2798,7 @@ var getBuilderSearchParamsFromWindow = () => {
3664
2798
  };
3665
2799
  var normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
3666
2800
 
3667
- // src/types/api-version.js
3668
- var DEFAULT_API_VERSION = "v3";
3669
-
3670
- // src/functions/get-content/generate-content-url.js
3671
- var __defProp16 = Object.defineProperty;
3672
- var __getOwnPropSymbols16 = Object.getOwnPropertySymbols;
3673
- var __hasOwnProp16 = Object.prototype.hasOwnProperty;
3674
- var __propIsEnum16 = Object.prototype.propertyIsEnumerable;
3675
- var __defNormalProp16 = (obj, key, value) => key in obj ? __defProp16(obj, key, {
3676
- enumerable: true,
3677
- configurable: true,
3678
- writable: true,
3679
- value
3680
- }) : obj[key] = value;
3681
- var __spreadValues16 = (a, b) => {
3682
- for (var prop in b || (b = {}))
3683
- if (__hasOwnProp16.call(b, prop))
3684
- __defNormalProp16(a, prop, b[prop]);
3685
- if (__getOwnPropSymbols16)
3686
- for (var prop of __getOwnPropSymbols16(b)) {
3687
- if (__propIsEnum16.call(b, prop))
3688
- __defNormalProp16(a, prop, b[prop]);
3689
- }
3690
- return a;
3691
- };
2801
+ // src/functions/get-content/generate-content-url.ts
3692
2802
  var isPositiveNumber = (thing) => typeof thing === "number" && !isNaN(thing) && thing >= 0;
3693
2803
  var generateContentUrl = (options) => {
3694
2804
  let {
@@ -3746,7 +2856,10 @@ var generateContentUrl = (options) => {
3746
2856
  url.searchParams.set(key, JSON.stringify(flattened2[key]));
3747
2857
  }
3748
2858
  }
3749
- const queryOptions = __spreadValues16(__spreadValues16({}, getBuilderSearchParamsFromWindow()), normalizeSearchParams(options.options || {}));
2859
+ const queryOptions = {
2860
+ ...getBuilderSearchParamsFromWindow(),
2861
+ ...normalizeSearchParams(options.options || {})
2862
+ };
3750
2863
  const flattened = flatten(queryOptions);
3751
2864
  for (const key in flattened) {
3752
2865
  url.searchParams.set(key, String(flattened[key]));
@@ -3765,71 +2878,26 @@ var generateContentUrl = (options) => {
3765
2878
  return url;
3766
2879
  };
3767
2880
 
3768
- // src/functions/get-content/index.js
3769
- var __defProp17 = Object.defineProperty;
3770
- var __defProps12 = Object.defineProperties;
3771
- var __getOwnPropDescs12 = Object.getOwnPropertyDescriptors;
3772
- var __getOwnPropSymbols17 = Object.getOwnPropertySymbols;
3773
- var __hasOwnProp17 = Object.prototype.hasOwnProperty;
3774
- var __propIsEnum17 = Object.prototype.propertyIsEnumerable;
3775
- var __defNormalProp17 = (obj, key, value) => key in obj ? __defProp17(obj, key, {
3776
- enumerable: true,
3777
- configurable: true,
3778
- writable: true,
3779
- value
3780
- }) : obj[key] = value;
3781
- var __spreadValues17 = (a, b) => {
3782
- for (var prop in b || (b = {}))
3783
- if (__hasOwnProp17.call(b, prop))
3784
- __defNormalProp17(a, prop, b[prop]);
3785
- if (__getOwnPropSymbols17)
3786
- for (var prop of __getOwnPropSymbols17(b)) {
3787
- if (__propIsEnum17.call(b, prop))
3788
- __defNormalProp17(a, prop, b[prop]);
3789
- }
3790
- return a;
3791
- };
3792
- var __spreadProps12 = (a, b) => __defProps12(a, __getOwnPropDescs12(b));
3793
- var __async5 = (__this, __arguments, generator) => {
3794
- return new Promise((resolve, reject) => {
3795
- var fulfilled = (value) => {
3796
- try {
3797
- step(generator.next(value));
3798
- } catch (e) {
3799
- reject(e);
3800
- }
3801
- };
3802
- var rejected = (value) => {
3803
- try {
3804
- step(generator.throw(value));
3805
- } catch (e) {
3806
- reject(e);
3807
- }
3808
- };
3809
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
3810
- step((generator = generator.apply(__this, __arguments)).next());
3811
- });
3812
- };
2881
+ // src/functions/get-content/index.ts
3813
2882
  var checkContentHasResults = (content) => "results" in content;
3814
- function fetchOneEntry(options) {
3815
- return __async5(this, null, function* () {
3816
- const allContent = yield fetchEntries(__spreadProps12(__spreadValues17({}, options), {
3817
- limit: 1
3818
- }));
3819
- if (allContent) {
3820
- return allContent.results[0] || null;
3821
- }
3822
- return null;
2883
+ async function fetchOneEntry(options) {
2884
+ const allContent = await fetchEntries({
2885
+ ...options,
2886
+ limit: 1
3823
2887
  });
2888
+ if (allContent) {
2889
+ return allContent.results[0] || null;
2890
+ }
2891
+ return null;
3824
2892
  }
3825
2893
  var getContent = fetchOneEntry;
3826
- var _fetchContent = (options) => __async5(void 0, null, function* () {
2894
+ var _fetchContent = async (options) => {
3827
2895
  const url = generateContentUrl(options);
3828
- const res = yield fetch2(url.href);
3829
- const content = yield res.json();
2896
+ const res = await fetch2(url.href);
2897
+ const content = await res.json();
3830
2898
  return content;
3831
- });
3832
- var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2], function* (options, content, url = generateContentUrl(options)) {
2899
+ };
2900
+ var _processContentResult = async (options, content, url = generateContentUrl(options)) => {
3833
2901
  const canTrack = getDefaultCanTrack(options.canTrack);
3834
2902
  const isPreviewing2 = url.search.includes(`preview=`);
3835
2903
  if (TARGET === "rsc" && isPreviewing2) {
@@ -3847,7 +2915,7 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
3847
2915
  try {
3848
2916
  const newResults = [];
3849
2917
  for (const item of content.results) {
3850
- newResults.push(yield handleABTesting({
2918
+ newResults.push(await handleABTesting({
3851
2919
  item,
3852
2920
  canTrack
3853
2921
  }));
@@ -3856,48 +2924,415 @@ var _processContentResult = (_0, _1, ..._2) => __async5(void 0, [_0, _1, ..._2],
3856
2924
  } catch (e) {
3857
2925
  logger.error("Could not process A/B tests. ", e);
3858
2926
  }
3859
- return content;
3860
- });
3861
- function fetchEntries(options) {
3862
- return __async5(this, null, function* () {
2927
+ return content;
2928
+ };
2929
+ async function fetchEntries(options) {
2930
+ try {
2931
+ const url = generateContentUrl(options);
2932
+ const content = await _fetchContent(options);
2933
+ if (!checkContentHasResults(content)) {
2934
+ logger.error("Error fetching data. ", {
2935
+ url,
2936
+ content,
2937
+ options
2938
+ });
2939
+ return null;
2940
+ }
2941
+ return _processContentResult(options, content);
2942
+ } catch (error) {
2943
+ logger.error("Error fetching data. ", error);
2944
+ return null;
2945
+ }
2946
+ }
2947
+ var getAllContent = fetchEntries;
2948
+
2949
+ // src/functions/is-previewing.ts
2950
+ function isPreviewing() {
2951
+ if (!isBrowser()) {
2952
+ return false;
2953
+ }
2954
+ if (isEditing()) {
2955
+ return false;
2956
+ }
2957
+ return Boolean(location.search.indexOf("builder.preview=") !== -1);
2958
+ }
2959
+
2960
+ // src/helpers/uuid.ts
2961
+ function uuidv4() {
2962
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(c) {
2963
+ const r = Math.random() * 16 | 0, v = c == "x" ? r : r & 3 | 8;
2964
+ return v.toString(16);
2965
+ });
2966
+ }
2967
+ function uuid() {
2968
+ return uuidv4().replace(/-/g, "");
2969
+ }
2970
+
2971
+ // src/helpers/sessionId.ts
2972
+ var SESSION_LOCAL_STORAGE_KEY = "builderSessionId";
2973
+ var getSessionId = async ({
2974
+ canTrack
2975
+ }) => {
2976
+ if (!canTrack) {
2977
+ return void 0;
2978
+ }
2979
+ const sessionId = await getCookie({
2980
+ name: SESSION_LOCAL_STORAGE_KEY,
2981
+ canTrack
2982
+ });
2983
+ if (checkIsDefined(sessionId)) {
2984
+ return sessionId;
2985
+ } else {
2986
+ const newSessionId = createSessionId();
2987
+ setSessionId({
2988
+ id: newSessionId,
2989
+ canTrack
2990
+ });
2991
+ return newSessionId;
2992
+ }
2993
+ };
2994
+ var createSessionId = () => uuid();
2995
+ var setSessionId = ({
2996
+ id,
2997
+ canTrack
2998
+ }) => setCookie({
2999
+ name: SESSION_LOCAL_STORAGE_KEY,
3000
+ value: id,
3001
+ canTrack
3002
+ });
3003
+
3004
+ // src/helpers/localStorage.ts
3005
+ var getLocalStorage = () => isBrowser() && typeof localStorage !== "undefined" ? localStorage : void 0;
3006
+ var getLocalStorageItem = ({
3007
+ key,
3008
+ canTrack
3009
+ }) => {
3010
+ try {
3011
+ if (canTrack) {
3012
+ return getLocalStorage()?.getItem(key);
3013
+ }
3014
+ return void 0;
3015
+ } catch (err) {
3016
+ return void 0;
3017
+ }
3018
+ };
3019
+ var setLocalStorageItem = ({
3020
+ key,
3021
+ canTrack,
3022
+ value
3023
+ }) => {
3024
+ try {
3025
+ if (canTrack) {
3026
+ getLocalStorage()?.setItem(key, value);
3027
+ }
3028
+ } catch (err) {
3029
+ }
3030
+ };
3031
+
3032
+ // src/helpers/visitorId.ts
3033
+ var VISITOR_LOCAL_STORAGE_KEY = "builderVisitorId";
3034
+ var getVisitorId = ({
3035
+ canTrack
3036
+ }) => {
3037
+ if (!canTrack) {
3038
+ return void 0;
3039
+ }
3040
+ const visitorId = getLocalStorageItem({
3041
+ key: VISITOR_LOCAL_STORAGE_KEY,
3042
+ canTrack
3043
+ });
3044
+ if (checkIsDefined(visitorId)) {
3045
+ return visitorId;
3046
+ } else {
3047
+ const newVisitorId = createVisitorId();
3048
+ setVisitorId({
3049
+ id: newVisitorId,
3050
+ canTrack
3051
+ });
3052
+ return newVisitorId;
3053
+ }
3054
+ };
3055
+ var createVisitorId = () => uuid();
3056
+ var setVisitorId = ({
3057
+ id,
3058
+ canTrack
3059
+ }) => setLocalStorageItem({
3060
+ key: VISITOR_LOCAL_STORAGE_KEY,
3061
+ value: id,
3062
+ canTrack
3063
+ });
3064
+
3065
+ // src/functions/track/index.ts
3066
+ var getTrackingEventData = async ({
3067
+ canTrack
3068
+ }) => {
3069
+ if (!canTrack) {
3070
+ return {
3071
+ visitorId: void 0,
3072
+ sessionId: void 0
3073
+ };
3074
+ }
3075
+ const sessionId = await getSessionId({
3076
+ canTrack
3077
+ });
3078
+ const visitorId = getVisitorId({
3079
+ canTrack
3080
+ });
3081
+ return {
3082
+ sessionId,
3083
+ visitorId
3084
+ };
3085
+ };
3086
+ var createEvent = async ({
3087
+ type: eventType,
3088
+ canTrack,
3089
+ apiKey,
3090
+ metadata,
3091
+ ...properties
3092
+ }) => ({
3093
+ type: eventType,
3094
+ data: {
3095
+ ...properties,
3096
+ metadata: {
3097
+ url: location.href,
3098
+ ...metadata
3099
+ },
3100
+ ...await getTrackingEventData({
3101
+ canTrack
3102
+ }),
3103
+ userAttributes: getUserAttributes(),
3104
+ ownerId: apiKey
3105
+ }
3106
+ });
3107
+ async function _track(eventProps) {
3108
+ if (!eventProps.apiKey) {
3109
+ logger.error("Missing API key for track call. Please provide your API key.");
3110
+ return;
3111
+ }
3112
+ if (!eventProps.canTrack) {
3113
+ return;
3114
+ }
3115
+ if (isEditing()) {
3116
+ return;
3117
+ }
3118
+ if (!(isBrowser() || TARGET === "reactNative")) {
3119
+ return;
3120
+ }
3121
+ return fetch(`https://cdn.builder.io/api/v1/track`, {
3122
+ method: "POST",
3123
+ body: JSON.stringify({
3124
+ events: [await createEvent(eventProps)]
3125
+ }),
3126
+ headers: {
3127
+ "content-type": "application/json"
3128
+ },
3129
+ mode: "cors"
3130
+ }).catch((err) => {
3131
+ });
3132
+ }
3133
+ var track = (args) => _track({
3134
+ ...args,
3135
+ canTrack: true
3136
+ });
3137
+
3138
+ // src/functions/track/interaction.ts
3139
+ function round(num) {
3140
+ return Math.round(num * 1e3) / 1e3;
3141
+ }
3142
+ var findParentElement = (target, callback, checkElement = true) => {
3143
+ if (!(target instanceof HTMLElement)) {
3144
+ return null;
3145
+ }
3146
+ let parent2 = checkElement ? target : target.parentElement;
3147
+ do {
3148
+ if (!parent2) {
3149
+ return null;
3150
+ }
3151
+ const matches = callback(parent2);
3152
+ if (matches) {
3153
+ return parent2;
3154
+ }
3155
+ } while (parent2 = parent2.parentElement);
3156
+ return null;
3157
+ };
3158
+ var findBuilderParent = (target) => findParentElement(target, (el) => {
3159
+ const id = el.getAttribute("builder-id") || el.id;
3160
+ return Boolean(id?.indexOf("builder-") === 0);
3161
+ });
3162
+ var computeOffset = ({
3163
+ event,
3164
+ target
3165
+ }) => {
3166
+ const targetRect = target.getBoundingClientRect();
3167
+ const xOffset = event.clientX - targetRect.left;
3168
+ const yOffset = event.clientY - targetRect.top;
3169
+ const xRatio = round(xOffset / targetRect.width);
3170
+ const yRatio = round(yOffset / targetRect.height);
3171
+ return {
3172
+ x: xRatio,
3173
+ y: yRatio
3174
+ };
3175
+ };
3176
+ var getInteractionPropertiesForEvent = (event) => {
3177
+ const target = event.target;
3178
+ const targetBuilderElement = target && findBuilderParent(target);
3179
+ const builderId = targetBuilderElement?.getAttribute("builder-id") || targetBuilderElement?.id;
3180
+ return {
3181
+ targetBuilderElement: builderId || void 0,
3182
+ metadata: {
3183
+ targetOffset: target ? computeOffset({
3184
+ event,
3185
+ target
3186
+ }) : void 0,
3187
+ builderTargetOffset: targetBuilderElement ? computeOffset({
3188
+ event,
3189
+ target: targetBuilderElement
3190
+ }) : void 0,
3191
+ builderElementIndex: targetBuilderElement && builderId ? [].slice.call(document.getElementsByClassName(builderId)).indexOf(targetBuilderElement) : void 0
3192
+ }
3193
+ };
3194
+ };
3195
+
3196
+ // src/constants/sdk-version.ts
3197
+ var SDK_VERSION = "0.7.2";
3198
+
3199
+ // src/functions/register.ts
3200
+ var registry = {};
3201
+ function register(type, info) {
3202
+ let typeList = registry[type];
3203
+ if (!typeList) {
3204
+ typeList = registry[type] = [];
3205
+ }
3206
+ typeList.push(info);
3207
+ if (isBrowser()) {
3208
+ const message = {
3209
+ type: "builder.register",
3210
+ data: {
3211
+ type,
3212
+ info
3213
+ }
3214
+ };
3863
3215
  try {
3864
- const url = generateContentUrl(options);
3865
- const content = yield _fetchContent(options);
3866
- if (!checkContentHasResults(content)) {
3867
- logger.error("Error fetching data. ", {
3868
- url,
3869
- content,
3870
- options
3871
- });
3872
- return null;
3216
+ parent.postMessage(message, "*");
3217
+ if (parent !== window) {
3218
+ window.postMessage(message, "*");
3873
3219
  }
3874
- return _processContentResult(options, content);
3875
- } catch (error) {
3876
- logger.error("Error fetching data. ", error);
3877
- return null;
3220
+ } catch (err) {
3878
3221
  }
3879
- });
3222
+ }
3880
3223
  }
3881
- var getAllContent = fetchEntries;
3882
3224
 
3883
- // src/functions/is-previewing.js
3884
- function isPreviewing() {
3885
- if (!isBrowser()) {
3886
- return false;
3225
+ // src/scripts/init-editing.ts
3226
+ var registerInsertMenu = () => {
3227
+ register("insertMenu", {
3228
+ name: "_default",
3229
+ default: true,
3230
+ items: [{
3231
+ name: "Box"
3232
+ }, {
3233
+ name: "Text"
3234
+ }, {
3235
+ name: "Image"
3236
+ }, {
3237
+ name: "Columns"
3238
+ }, ...TARGET === "reactNative" ? [] : [{
3239
+ name: "Core:Section"
3240
+ }, {
3241
+ name: "Core:Button"
3242
+ }, {
3243
+ name: "Embed"
3244
+ }, {
3245
+ name: "Custom Code"
3246
+ }]]
3247
+ });
3248
+ };
3249
+ var isSetupForEditing = false;
3250
+ var setupBrowserForEditing = (options = {}) => {
3251
+ if (isSetupForEditing) {
3252
+ return;
3887
3253
  }
3888
- if (isEditing()) {
3889
- return false;
3254
+ isSetupForEditing = true;
3255
+ if (isBrowser()) {
3256
+ window.parent?.postMessage({
3257
+ type: "builder.sdkInfo",
3258
+ data: {
3259
+ target: TARGET,
3260
+ version: SDK_VERSION,
3261
+ supportsPatchUpdates: false,
3262
+ // Supports builder-model="..." attribute which is needed to
3263
+ // scope our '+ add block' button styling
3264
+ supportsAddBlockScoping: true,
3265
+ supportsCustomBreakpoints: true
3266
+ }
3267
+ }, "*");
3268
+ window.parent?.postMessage({
3269
+ type: "builder.updateContent",
3270
+ data: {
3271
+ options
3272
+ }
3273
+ }, "*");
3274
+ window.addEventListener("message", ({
3275
+ data
3276
+ }) => {
3277
+ if (!data?.type) {
3278
+ return;
3279
+ }
3280
+ switch (data.type) {
3281
+ case "builder.evaluate": {
3282
+ const text = data.data.text;
3283
+ const args = data.data.arguments || [];
3284
+ const id = data.data.id;
3285
+ const fn = new Function(text);
3286
+ let result;
3287
+ let error = null;
3288
+ try {
3289
+ result = fn.apply(null, args);
3290
+ } catch (err) {
3291
+ error = err;
3292
+ }
3293
+ if (error) {
3294
+ window.parent?.postMessage({
3295
+ type: "builder.evaluateError",
3296
+ data: {
3297
+ id,
3298
+ error: error.message
3299
+ }
3300
+ }, "*");
3301
+ } else {
3302
+ if (result && typeof result.then === "function") {
3303
+ result.then((finalResult) => {
3304
+ window.parent?.postMessage({
3305
+ type: "builder.evaluateResult",
3306
+ data: {
3307
+ id,
3308
+ result: finalResult
3309
+ }
3310
+ }, "*");
3311
+ }).catch(console.error);
3312
+ } else {
3313
+ window.parent?.postMessage({
3314
+ type: "builder.evaluateResult",
3315
+ data: {
3316
+ result,
3317
+ id
3318
+ }
3319
+ }, "*");
3320
+ }
3321
+ }
3322
+ break;
3323
+ }
3324
+ }
3325
+ });
3890
3326
  }
3891
- return Boolean(location.search.indexOf("builder.preview=") !== -1);
3892
- }
3327
+ };
3893
3328
 
3894
- // src/components/content/components/enable-editor.jsx
3329
+ // src/components/content/components/enable-editor.tsx
3895
3330
  function EnableEditor(props) {
3896
- const [forceReRenderCount, setForceReRenderCount] = createSignal12(0);
3897
- const [lastUpdated, setLastUpdated] = createSignal12(0);
3898
- const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal12(false);
3899
- const [httpReqsData, setHttpReqsData] = createSignal12({});
3900
- const [clicked, setClicked] = createSignal12(false);
3331
+ const [forceReRenderCount, setForceReRenderCount] = createSignal9(0);
3332
+ const [lastUpdated, setLastUpdated] = createSignal9(0);
3333
+ const [shouldSendResetCookie, setShouldSendResetCookie] = createSignal9(false);
3334
+ const [httpReqsData, setHttpReqsData] = createSignal9({});
3335
+ const [clicked, setClicked] = createSignal9(false);
3901
3336
  function mergeNewContent(newContent) {
3902
3337
  const newContentValue = {
3903
3338
  ...props.builderContextSignal.content,
@@ -4018,14 +3453,17 @@ function EnableEditor(props) {
4018
3453
  function emitStateUpdate() {
4019
3454
  if (isEditing()) {
4020
3455
  window.dispatchEvent(
4021
- new CustomEvent("builder:component:stateChange", {
4022
- detail: {
4023
- state: fastClone(props.builderContextSignal.rootState),
4024
- ref: {
4025
- name: props.model
3456
+ new CustomEvent(
3457
+ "builder:component:stateChange",
3458
+ {
3459
+ detail: {
3460
+ state: fastClone(props.builderContextSignal.rootState),
3461
+ ref: {
3462
+ name: props.model
3463
+ }
4026
3464
  }
4027
3465
  }
4028
- })
3466
+ )
4029
3467
  );
4030
3468
  }
4031
3469
  }
@@ -4047,12 +3485,12 @@ function EnableEditor(props) {
4047
3485
  enrich: props.enrich
4048
3486
  } : {}
4049
3487
  });
4050
- Object.values(props.builderContextSignal.componentInfos).forEach(
4051
- (registeredComponent) => {
4052
- const message = createRegisterComponentMessage(registeredComponent);
4053
- window.parent?.postMessage(message, "*");
4054
- }
4055
- );
3488
+ Object.values(
3489
+ props.builderContextSignal.componentInfos
3490
+ ).forEach((registeredComponent) => {
3491
+ const message = createRegisterComponentMessage(registeredComponent);
3492
+ window.parent?.postMessage(message, "*");
3493
+ });
4056
3494
  window.addEventListener(
4057
3495
  "builder:component:stateChangeListenerActivated",
4058
3496
  emitStateUpdate
@@ -4136,7 +3574,7 @@ function EnableEditor(props) {
4136
3574
  emitStateUpdate();
4137
3575
  }
4138
3576
  createEffect2(on2(() => [props.builderContextSignal.rootState], onUpdateFn_4));
4139
- return <stdin_default.Provider value={props.builderContextSignal}><Show9 when={props.builderContextSignal.content}><div
3577
+ return <builder_context_default.Provider value={props.builderContextSignal}><Show9 when={props.builderContextSignal.content}><div
4140
3578
  class={props.classNameProp}
4141
3579
  {...{}}
4142
3580
  key={forceReRenderCount()}
@@ -4149,19 +3587,139 @@ function EnableEditor(props) {
4149
3587
  hidden: true,
4150
3588
  "aria-hidden": true
4151
3589
  }}
4152
- >{props.children}</div></Show9></stdin_default.Provider>;
3590
+ >{props.children}</div></Show9></builder_context_default.Provider>;
4153
3591
  }
4154
3592
  var Enable_editor_default = EnableEditor;
4155
3593
 
4156
- // src/components/inlined-script.jsx
4157
- function InlinedScript(props) {
4158
- return <script innerHTML={props.scriptStr} id={props.id} />;
3594
+ // src/components/content/components/styles.tsx
3595
+ import { createSignal as createSignal10 } from "solid-js";
3596
+
3597
+ // src/components/content/components/styles.helpers.ts
3598
+ var getCssFromFont = (font) => {
3599
+ const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
3600
+ const name = family.split(",")[0];
3601
+ const url = font.fileUrl ?? font?.files?.regular;
3602
+ let str = "";
3603
+ if (url && family && name) {
3604
+ str += `
3605
+ @font-face {
3606
+ font-family: "${family}";
3607
+ src: local("${name}"), url('${url}') format('woff2');
3608
+ font-display: fallback;
3609
+ font-weight: 400;
4159
3610
  }
4160
- var Inlined_script_default = InlinedScript;
3611
+ `.trim();
3612
+ }
3613
+ if (font.files) {
3614
+ for (const weight in font.files) {
3615
+ const isNumber = String(Number(weight)) === weight;
3616
+ if (!isNumber) {
3617
+ continue;
3618
+ }
3619
+ const weightUrl = font.files[weight];
3620
+ if (weightUrl && weightUrl !== url) {
3621
+ str += `
3622
+ @font-face {
3623
+ font-family: "${family}";
3624
+ src: url('${weightUrl}') format('woff2');
3625
+ font-display: fallback;
3626
+ font-weight: ${weight};
3627
+ }
3628
+ `.trim();
3629
+ }
3630
+ }
3631
+ }
3632
+ return str;
3633
+ };
3634
+ var getFontCss = ({
3635
+ customFonts
3636
+ }) => {
3637
+ return customFonts?.map((font) => getCssFromFont(font))?.join(" ") || "";
3638
+ };
3639
+ var getCss = ({
3640
+ cssCode,
3641
+ contentId
3642
+ }) => {
3643
+ if (!cssCode) {
3644
+ return "";
3645
+ }
3646
+ if (!contentId) {
3647
+ return cssCode;
3648
+ }
3649
+ return cssCode?.replace(/&/g, `div[builder-content-id="${contentId}"]`) || "";
3650
+ };
3651
+
3652
+ // src/components/content/components/styles.tsx
3653
+ function ContentStyles(props) {
3654
+ const [injectedStyles, setInjectedStyles] = createSignal10(
3655
+ `
3656
+ ${getCss({
3657
+ cssCode: props.cssCode,
3658
+ contentId: props.contentId
3659
+ })}
3660
+ ${getFontCss({
3661
+ customFonts: props.customFonts
3662
+ })}
3663
+
3664
+ .builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
3665
+ margin: 0;
3666
+ }
3667
+ .builder-text > p, .builder-text > .builder-paragraph {
3668
+ color: inherit;
3669
+ line-height: inherit;
3670
+ letter-spacing: inherit;
3671
+ font-weight: inherit;
3672
+ font-size: inherit;
3673
+ text-align: inherit;
3674
+ font-family: inherit;
3675
+ }
3676
+ `.trim()
3677
+ );
3678
+ return <Inlined_styles_default styles={injectedStyles()} />;
3679
+ }
3680
+ var Styles_default = ContentStyles;
3681
+
3682
+ // src/components/content/content.helpers.ts
3683
+ var getContextStateInitialValue = ({
3684
+ content,
3685
+ data,
3686
+ locale
3687
+ }) => {
3688
+ const defaultValues = {};
3689
+ content?.data?.inputs?.forEach((input) => {
3690
+ if (input.name && input.defaultValue !== void 0 && content?.data?.state && content.data.state[input.name] === void 0) {
3691
+ defaultValues[input.name] = input.defaultValue;
3692
+ }
3693
+ });
3694
+ const stateToUse = {
3695
+ ...content?.data?.state,
3696
+ ...data,
3697
+ ...locale ? {
3698
+ locale
3699
+ } : {}
3700
+ };
3701
+ return {
3702
+ ...defaultValues,
3703
+ ...stateToUse
3704
+ };
3705
+ };
3706
+ var getContentInitialValue = ({
3707
+ content,
3708
+ data
3709
+ }) => {
3710
+ return !content ? void 0 : {
3711
+ ...content,
3712
+ data: {
3713
+ ...content?.data,
3714
+ ...data
3715
+ },
3716
+ meta: content?.meta
3717
+ };
3718
+ };
4161
3719
 
4162
- // src/components/content/content.jsx
3720
+ // src/components/content/content.tsx
4163
3721
  function ContentComponent(props) {
4164
- const [scriptStr, setScriptStr] = createSignal13(
3722
+ const [scriptStr, setScriptStr] = createSignal11(
4165
3723
  getRenderContentScriptString({
4166
3724
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion, @typescript-eslint/no-non-null-asserted-optional-chain
4167
3725
  variationId: props.content?.testVariationId,
@@ -4169,7 +3727,7 @@ function ContentComponent(props) {
4169
3727
  contentId: props.content?.id
4170
3728
  })
4171
3729
  );
4172
- const [registeredComponents, setRegisteredComponents] = createSignal13(
3730
+ const [registeredComponents, setRegisteredComponents] = createSignal11(
4173
3731
  [
4174
3732
  ...getDefaultRegisteredComponents(),
4175
3733
  // While this `components` object is deprecated, we must maintain support for it.
@@ -4190,7 +3748,7 @@ function ContentComponent(props) {
4190
3748
  {}
4191
3749
  )
4192
3750
  );
4193
- const [builderContextSignal, setBuilderContextSignal] = createSignal13({
3751
+ const [builderContextSignal, setBuilderContextSignal] = createSignal11({
4194
3752
  content: getContentInitialValue({
4195
3753
  content: props.content,
4196
3754
  data: props.data
@@ -4229,7 +3787,7 @@ function ContentComponent(props) {
4229
3787
  rootState: newRootState
4230
3788
  }));
4231
3789
  }
4232
- return <stdin_default2.Provider
3790
+ return <components_context_default.Provider
4233
3791
  value={{
4234
3792
  registeredComponents: registeredComponents()
4235
3793
  }}
@@ -4260,13 +3818,13 @@ function ContentComponent(props) {
4260
3818
  context={builderContextSignal()}
4261
3819
  registeredComponents={registeredComponents()}
4262
3820
  />
4263
- </Enable_editor_default></stdin_default2.Provider>;
3821
+ </Enable_editor_default></components_context_default.Provider>;
4264
3822
  }
4265
3823
  var Content_default = ContentComponent;
4266
3824
 
4267
- // src/components/content-variants/content-variants.jsx
3825
+ // src/components/content-variants/content-variants.tsx
4268
3826
  function ContentVariants(props) {
4269
- const [shouldRenderVariants, setShouldRenderVariants] = createSignal14(
3827
+ const [shouldRenderVariants, setShouldRenderVariants] = createSignal12(
4270
3828
  checkShouldRunVariants({
4271
3829
  canTrack: getDefaultCanTrack(props.canTrack),
4272
3830
  content: props.content
@@ -4294,6 +3852,7 @@ function ContentVariants(props) {
4294
3852
  });
4295
3853
  }
4296
3854
  onMount3(() => {
3855
+ setShouldRenderVariants(false);
4297
3856
  });
4298
3857
  return <>
4299
3858
  <Show11 when={!props.__isNestedRender && TARGET !== "reactNative"}><Inlined_script_default scriptStr={getScriptString()} /></Show11>
@@ -4345,72 +3904,33 @@ function ContentVariants(props) {
4345
3904
  }
4346
3905
  var Content_variants_default = ContentVariants;
4347
3906
 
4348
- // src/blocks/symbol/symbol.helpers.js
4349
- var __defProp18 = Object.defineProperty;
4350
- var __getOwnPropSymbols18 = Object.getOwnPropertySymbols;
4351
- var __hasOwnProp18 = Object.prototype.hasOwnProperty;
4352
- var __propIsEnum18 = Object.prototype.propertyIsEnumerable;
4353
- var __defNormalProp18 = (obj, key, value) => key in obj ? __defProp18(obj, key, {
4354
- enumerable: true,
4355
- configurable: true,
4356
- writable: true,
4357
- value
4358
- }) : obj[key] = value;
4359
- var __spreadValues18 = (a, b) => {
4360
- for (var prop in b || (b = {}))
4361
- if (__hasOwnProp18.call(b, prop))
4362
- __defNormalProp18(a, prop, b[prop]);
4363
- if (__getOwnPropSymbols18)
4364
- for (var prop of __getOwnPropSymbols18(b)) {
4365
- if (__propIsEnum18.call(b, prop))
4366
- __defNormalProp18(a, prop, b[prop]);
4367
- }
4368
- return a;
4369
- };
4370
- var __async6 = (__this, __arguments, generator) => {
4371
- return new Promise((resolve, reject) => {
4372
- var fulfilled = (value) => {
4373
- try {
4374
- step(generator.next(value));
4375
- } catch (e) {
4376
- reject(e);
4377
- }
4378
- };
4379
- var rejected = (value) => {
4380
- try {
4381
- step(generator.throw(value));
4382
- } catch (e) {
4383
- reject(e);
4384
- }
4385
- };
4386
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
4387
- step((generator = generator.apply(__this, __arguments)).next());
4388
- });
4389
- };
4390
- var fetchSymbolContent = (_0) => __async6(void 0, [_0], function* ({
3907
+ // src/blocks/symbol/symbol.helpers.ts
3908
+ var fetchSymbolContent = async ({
4391
3909
  builderContextValue,
4392
3910
  symbol
4393
- }) {
4394
- if ((symbol == null ? void 0 : symbol.model) && (builderContextValue == null ? void 0 : builderContextValue.apiKey)) {
4395
- return fetchOneEntry(__spreadValues18({
3911
+ }) => {
3912
+ if (symbol?.model && // This is a hack, we should not need to check for this, but it is needed for Svelte.
3913
+ builderContextValue?.apiKey) {
3914
+ return fetchOneEntry({
4396
3915
  model: symbol.model,
4397
3916
  apiKey: builderContextValue.apiKey,
4398
- apiVersion: builderContextValue.apiVersion
4399
- }, (symbol == null ? void 0 : symbol.entry) && {
4400
- query: {
4401
- id: symbol.entry
3917
+ apiVersion: builderContextValue.apiVersion,
3918
+ ...symbol?.entry && {
3919
+ query: {
3920
+ id: symbol.entry
3921
+ }
4402
3922
  }
4403
- })).catch((err) => {
3923
+ }).catch((err) => {
4404
3924
  logger.error("Could not fetch symbol content: ", err);
4405
3925
  return void 0;
4406
3926
  });
4407
3927
  }
4408
3928
  return void 0;
4409
- });
3929
+ };
4410
3930
 
4411
- // src/blocks/symbol/symbol.jsx
3931
+ // src/blocks/symbol/symbol.tsx
4412
3932
  function Symbol(props) {
4413
- const [contentToUse, setContentToUse] = createSignal15(props.symbol?.content);
3933
+ const [contentToUse, setContentToUse] = createSignal13(props.symbol?.content);
4414
3934
  function className() {
4415
3935
  return [
4416
3936
  ...[props.attributes.class],
@@ -4455,11 +3975,11 @@ function Symbol(props) {
4455
3975
  }
4456
3976
  var symbol_default = Symbol;
4457
3977
 
4458
- // src/index-helpers/blocks-exports.js
3978
+ // src/index-helpers/blocks-exports.ts
4459
3979
  var RenderBlocks = Blocks_default;
4460
3980
  var RenderContent = Content_variants_default;
4461
3981
 
4462
- // src/functions/set-editor-settings.js
3982
+ // src/functions/set-editor-settings.ts
4463
3983
  var settings = {};
4464
3984
  function setEditorSettings(newSettings) {
4465
3985
  if (isBrowser()) {
@@ -4472,68 +3992,27 @@ function setEditorSettings(newSettings) {
4472
3992
  }
4473
3993
  }
4474
3994
 
4475
- // src/functions/fetch-builder-props.js
4476
- var __defProp19 = Object.defineProperty;
4477
- var __defProps13 = Object.defineProperties;
4478
- var __getOwnPropDescs13 = Object.getOwnPropertyDescriptors;
4479
- var __getOwnPropSymbols19 = Object.getOwnPropertySymbols;
4480
- var __hasOwnProp19 = Object.prototype.hasOwnProperty;
4481
- var __propIsEnum19 = Object.prototype.propertyIsEnumerable;
4482
- var __defNormalProp19 = (obj, key, value) => key in obj ? __defProp19(obj, key, {
4483
- enumerable: true,
4484
- configurable: true,
4485
- writable: true,
4486
- value
4487
- }) : obj[key] = value;
4488
- var __spreadValues19 = (a, b) => {
4489
- for (var prop in b || (b = {}))
4490
- if (__hasOwnProp19.call(b, prop))
4491
- __defNormalProp19(a, prop, b[prop]);
4492
- if (__getOwnPropSymbols19)
4493
- for (var prop of __getOwnPropSymbols19(b)) {
4494
- if (__propIsEnum19.call(b, prop))
4495
- __defNormalProp19(a, prop, b[prop]);
4496
- }
4497
- return a;
4498
- };
4499
- var __spreadProps13 = (a, b) => __defProps13(a, __getOwnPropDescs13(b));
4500
- var __async7 = (__this, __arguments, generator) => {
4501
- return new Promise((resolve, reject) => {
4502
- var fulfilled = (value) => {
4503
- try {
4504
- step(generator.next(value));
4505
- } catch (e) {
4506
- reject(e);
4507
- }
4508
- };
4509
- var rejected = (value) => {
4510
- try {
4511
- step(generator.throw(value));
4512
- } catch (e) {
4513
- reject(e);
4514
- }
4515
- };
4516
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
4517
- step((generator = generator.apply(__this, __arguments)).next());
4518
- });
4519
- };
4520
- var fetchBuilderProps = (_args) => __async7(void 0, null, function* () {
4521
- var _a, _b, _c;
4522
- const urlPath = _args.path || ((_a = _args.url) == null ? void 0 : _a.pathname) || ((_b = _args.userAttributes) == null ? void 0 : _b.urlPath);
4523
- const getContentArgs = __spreadProps13(__spreadValues19({}, _args), {
3995
+ // src/functions/fetch-builder-props.ts
3996
+ var fetchBuilderProps = async (_args) => {
3997
+ const urlPath = _args.path || _args.url?.pathname || _args.userAttributes?.urlPath;
3998
+ const getContentArgs = {
3999
+ ..._args,
4524
4000
  apiKey: _args.apiKey,
4525
4001
  model: _args.model || "page",
4526
- userAttributes: __spreadValues19(__spreadValues19({}, _args.userAttributes), urlPath ? {
4527
- urlPath
4528
- } : {}),
4529
- options: getBuilderSearchParams(_args.searchParams || ((_c = _args.url) == null ? void 0 : _c.searchParams) || _args.options)
4530
- });
4002
+ userAttributes: {
4003
+ ..._args.userAttributes,
4004
+ ...urlPath ? {
4005
+ urlPath
4006
+ } : {}
4007
+ },
4008
+ options: getBuilderSearchParams(_args.searchParams || _args.url?.searchParams || _args.options)
4009
+ };
4531
4010
  return {
4532
4011
  apiKey: getContentArgs.apiKey,
4533
4012
  model: getContentArgs.model,
4534
- content: yield fetchOneEntry(getContentArgs)
4013
+ content: await fetchOneEntry(getContentArgs)
4535
4014
  };
4536
- });
4015
+ };
4537
4016
  export {
4538
4017
  Blocks_default as Blocks,
4539
4018
  button_default as Button,