@builder.io/sdk-qwik 0.3.1 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -34,7 +34,7 @@ const STYLES$3 = `
34
34
  all: unset;
35
35
  }
36
36
  `;
37
- const builderContext = qwik.createContextId("Builder");
37
+ const BuilderContext = qwik.createContextId("Builder");
38
38
  const TARGET = "qwik";
39
39
  function isBrowser() {
40
40
  return typeof window !== "undefined" && typeof document !== "undefined";
@@ -197,23 +197,14 @@ const createCssClass = ({ mediaQuery, className, styles }) => {
197
197
  return cssClass;
198
198
  };
199
199
  const RenderInlinedStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
200
- const tag = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
201
- return "style";
202
- }, "RenderInlinedStyles_component_tag_useComputed_S1nSc0C6qB4"));
203
- qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
204
- const [props2, tag2] = qwik.useLexicalScope();
205
- return `<${tag2.value}>${props2.styles}</${tag2.value}>`;
206
- }, "RenderInlinedStyles_component_injectedStyleScript_useComputed_CVKinNBYTxE", [
207
- props,
208
- tag
209
- ]));
210
- return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
211
- children: /* @__PURE__ */ qwik._jsxQ("style", null, {
212
- dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.styles, [
213
- props
214
- ], "p0.styles")
215
- }, null, 3, "zz_0")
216
- }, 1, "zz_2");
200
+ return /* @__PURE__ */ qwik._jsxQ("style", null, {
201
+ dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.styles, [
202
+ props
203
+ ], "p0.styles"),
204
+ id: qwik._fnSignal((p0) => p0.id, [
205
+ props
206
+ ], "p0.id")
207
+ }, null, 3, "zz_0");
217
208
  }, "RenderInlinedStyles_component_ejNQtXd1ahM"));
218
209
  const BlockStyles = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
219
210
  qwik._jsxBranch();
@@ -465,7 +456,7 @@ const RenderComponent = (props) => {
465
456
  }, 1, "R9_1");
466
457
  };
467
458
  const RenderRepeatedBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
468
- qwik.useContextProvider(builderContext, qwik.useStore({
459
+ qwik.useContextProvider(BuilderContext, qwik.useStore({
469
460
  content: props.repeatContext.content,
470
461
  localState: props.repeatContext.localState,
471
462
  rootState: props.repeatContext.rootState,
@@ -496,7 +487,7 @@ const RenderRepeatedBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qw
496
487
  const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
497
488
  qwik._jsxBranch();
498
489
  const state = qwik.useStore({
499
- tag: props.block.tagName || "div"
490
+ Tag: props.block.tagName || "div"
500
491
  });
501
492
  const component = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
502
493
  const [props2] = qwik.useLexicalScope();
@@ -620,11 +611,11 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
620
611
  return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
621
612
  children: canShowBlock.value ? !component.value?.noWrap ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
622
613
  children: [
623
- isEmptyHtmlElement(state.tag) ? /* @__PURE__ */ qwik._jsxC(state.tag, {
614
+ isEmptyHtmlElement(state.Tag) ? /* @__PURE__ */ qwik._jsxC(state.Tag, {
624
615
  ...attributes.value,
625
616
  ...actions.value
626
617
  }, 0, "9d_0") : null,
627
- !isEmptyHtmlElement(state.tag) && repeatItem.value ? (repeatItem.value || []).map(function(data, index) {
618
+ !isEmptyHtmlElement(state.Tag) && repeatItem.value ? (repeatItem.value || []).map(function(data, index) {
628
619
  return /* @__PURE__ */ qwik._jsxC(RenderRepeatedBlock, {
629
620
  get repeatContext() {
630
621
  return data.context;
@@ -638,7 +629,7 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
638
629
  }
639
630
  }, 3, index);
640
631
  }) : null,
641
- !isEmptyHtmlElement(state.tag) && !repeatItem.value ? /* @__PURE__ */ qwik._jsxC(state.tag, {
632
+ !isEmptyHtmlElement(state.Tag) && !repeatItem.value ? /* @__PURE__ */ qwik._jsxC(state.Tag, {
642
633
  ...attributes.value,
643
634
  ...actions.value,
644
635
  children: [
@@ -679,7 +670,7 @@ const RenderBlock = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlin
679
670
  }, 0, "9d_4") : null
680
671
  }, 1, "9d_5");
681
672
  }, "RenderBlock_component_m0hg0zT573Q"));
682
- const onClick$1 = function onClick2(props, state, builderContext2) {
673
+ const onClick$1 = function onClick2(props, state, builderContext) {
683
674
  if (isEditing() && !props.blocks?.length)
684
675
  window.parent?.postMessage({
685
676
  type: "builder.clickEmptyBlocks",
@@ -689,7 +680,7 @@ const onClick$1 = function onClick2(props, state, builderContext2) {
689
680
  }
690
681
  }, "*");
691
682
  };
692
- const onMouseEnter = function onMouseEnter2(props, state, builderContext2) {
683
+ const onMouseEnter = function onMouseEnter2(props, state, builderContext) {
693
684
  if (isEditing() && !props.blocks?.length)
694
685
  window.parent?.postMessage({
695
686
  type: "builder.hoverEmptyBlocks",
@@ -701,7 +692,7 @@ const onMouseEnter = function onMouseEnter2(props, state, builderContext2) {
701
692
  };
702
693
  const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
703
694
  qwik.useStylesScopedQrl(/* @__PURE__ */ qwik.inlinedQrl(STYLES$2, "RenderBlocks_component_useStylesScoped_0XKYzaR059E"));
704
- const builderContext$1 = qwik.useContext(builderContext);
695
+ const builderContext = qwik.useContext(BuilderContext);
705
696
  const state = {};
706
697
  const className = qwik.useComputedQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
707
698
  const [props2] = qwik.useLexicalScope();
@@ -714,7 +705,7 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
714
705
  const [builderContext2, props2, state2] = qwik.useLexicalScope();
715
706
  return onClick$1(props2);
716
707
  }, "RenderBlocks_component_div_onClick_RzhhZa265Yg", [
717
- builderContext$1,
708
+ builderContext,
718
709
  props,
719
710
  state
720
711
  ]),
@@ -722,7 +713,7 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
722
713
  const [builderContext2, props2, state2] = qwik.useLexicalScope();
723
714
  return onMouseEnter(props2);
724
715
  }, "RenderBlocks_component_div_onMouseEnter_nG7I7RYG3JQ", [
725
- builderContext$1,
716
+ builderContext,
726
717
  props,
727
718
  state
728
719
  ])
@@ -743,7 +734,7 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
743
734
  props.blocks ? (props.blocks || []).map(function(block) {
744
735
  return /* @__PURE__ */ qwik._jsxC(RenderBlock, {
745
736
  block,
746
- context: builderContext$1,
737
+ context: builderContext,
747
738
  [qwik._IMMUTABLE]: {
748
739
  context: qwik._IMMUTABLE
749
740
  }
@@ -752,7 +743,7 @@ const RenderBlocks = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inli
752
743
  props.blocks ? (props.blocks || []).map(function(block) {
753
744
  return /* @__PURE__ */ qwik._jsxC(BlockStyles, {
754
745
  block,
755
- context: builderContext$1,
746
+ context: builderContext,
756
747
  [qwik._IMMUTABLE]: {
757
748
  context: qwik._IMMUTABLE
758
749
  }
@@ -767,54 +758,54 @@ const STYLES$2 = `
767
758
  align-items: stretch;
768
759
  }
769
760
  `;
770
- const getWidth = function getWidth2(props, state, builderContext2, index) {
761
+ const getWidth = function getWidth2(props, state, builderContext, index) {
771
762
  return state.cols[index]?.width || 100 / state.cols.length;
772
763
  };
773
- const getColumnCssWidth = function getColumnCssWidth2(props, state, builderContext2, index) {
764
+ const getColumnCssWidth = function getColumnCssWidth2(props, state, builderContext, index) {
774
765
  const subtractWidth = state.gutterSize * (state.cols.length - 1) / state.cols.length;
775
- return `calc(${getWidth(props, state, builderContext2, index)}% - ${subtractWidth}px)`;
766
+ return `calc(${getWidth(props, state, builderContext, index)}% - ${subtractWidth}px)`;
776
767
  };
777
- const getTabletStyle = function getTabletStyle2(props, state, builderContext2, { stackedStyle, desktopStyle }) {
768
+ const getTabletStyle = function getTabletStyle2(props, state, builderContext, { stackedStyle, desktopStyle }) {
778
769
  return state.stackAt === "tablet" ? stackedStyle : desktopStyle;
779
770
  };
780
- const getMobileStyle = function getMobileStyle2(props, state, builderContext2, { stackedStyle, desktopStyle }) {
771
+ const getMobileStyle = function getMobileStyle2(props, state, builderContext, { stackedStyle, desktopStyle }) {
781
772
  return state.stackAt === "never" ? desktopStyle : stackedStyle;
782
773
  };
783
- const columnCssVars = function columnCssVars2(props, state, builderContext2, index) {
774
+ const columnCssVars = function columnCssVars2(props, state, builderContext, index) {
784
775
  const gutter = index === 0 ? 0 : state.gutterSize;
785
- const width = getColumnCssWidth(props, state, builderContext2, index);
776
+ const width = getColumnCssWidth(props, state, builderContext, index);
786
777
  const gutterPixels = `${gutter}px`;
787
778
  const mobileWidth = "100%";
788
779
  const mobileMarginLeft = 0;
789
780
  return {
790
781
  width,
791
782
  "margin-left": gutterPixels,
792
- "--column-width-mobile": getMobileStyle(props, state, builderContext2, {
783
+ "--column-width-mobile": getMobileStyle(props, state, builderContext, {
793
784
  stackedStyle: mobileWidth,
794
785
  desktopStyle: width
795
786
  }),
796
- "--column-margin-left-mobile": getMobileStyle(props, state, builderContext2, {
787
+ "--column-margin-left-mobile": getMobileStyle(props, state, builderContext, {
797
788
  stackedStyle: mobileMarginLeft,
798
789
  desktopStyle: gutterPixels
799
790
  }),
800
- "--column-width-tablet": getTabletStyle(props, state, builderContext2, {
791
+ "--column-width-tablet": getTabletStyle(props, state, builderContext, {
801
792
  stackedStyle: mobileWidth,
802
793
  desktopStyle: width
803
794
  }),
804
- "--column-margin-left-tablet": getTabletStyle(props, state, builderContext2, {
795
+ "--column-margin-left-tablet": getTabletStyle(props, state, builderContext, {
805
796
  stackedStyle: mobileMarginLeft,
806
797
  desktopStyle: gutterPixels
807
798
  })
808
799
  };
809
800
  };
810
- const getWidthForBreakpointSize = function getWidthForBreakpointSize2(props, state, builderContext2, size) {
811
- const breakpointSizes = getSizesForBreakpoints(builderContext2.content?.meta?.breakpoints || {});
801
+ const getWidthForBreakpointSize = function getWidthForBreakpointSize2(props, state, builderContext, size) {
802
+ const breakpointSizes = getSizesForBreakpoints(builderContext.content?.meta?.breakpoints || {});
812
803
  return breakpointSizes[size].max;
813
804
  };
814
805
  const Columns = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
815
806
  qwik._jsxBranch();
816
807
  qwik.useStylesScopedQrl(/* @__PURE__ */ qwik.inlinedQrl(STYLES$1, "Columns_component_useStylesScoped_s7JLZz7MCCQ"));
817
- const builderContext$1 = qwik.useContext(builderContext);
808
+ const builderContext = qwik.useContext(BuilderContext);
818
809
  const state = qwik.useStore({
819
810
  cols: props.columns || [],
820
811
  flexDir: props.stackColumnsAt === "never" ? "row" : props.reverseColumnsWhenStacked ? "column-reverse" : "column",
@@ -831,7 +822,7 @@ const Columns = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQr
831
822
  })
832
823
  };
833
824
  }, "Columns_component_columnsCssVars_useComputed_adFEq2RWT9s", [
834
- builderContext$1,
825
+ builderContext,
835
826
  props,
836
827
  state
837
828
  ]));
@@ -863,7 +854,7 @@ const Columns = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQr
863
854
  },
864
855
  `;
865
856
  }, "Columns_component_columnsStyles_useComputed_nBtMPbzd1Wc", [
866
- builderContext$1,
857
+ builderContext,
867
858
  props,
868
859
  state
869
860
  ]));
@@ -887,7 +878,7 @@ const Columns = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQr
887
878
  }, 3, "c0_0"),
888
879
  (props.columns || []).map(function(column, index) {
889
880
  return /* @__PURE__ */ qwik._jsxQ("div", {
890
- style: columnCssVars(props, state, builderContext$1, index)
881
+ style: columnCssVars(props, state, builderContext, index)
891
882
  }, {
892
883
  class: "builder-column div-Columns-2"
893
884
  }, /* @__PURE__ */ qwik._jsxC(RenderBlocks, {
@@ -1098,6 +1089,24 @@ const STYLES = `
1098
1089
  height: 100%;
1099
1090
  }
1100
1091
  `;
1092
+ const SectionComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1093
+ return /* @__PURE__ */ qwik._jsxS("section", {
1094
+ ...props.attributes,
1095
+ style: {
1096
+ width: "100%",
1097
+ alignSelf: "stretch",
1098
+ flexGrow: 1,
1099
+ boxSizing: "border-box",
1100
+ maxWidth: props.maxWidth || 1200,
1101
+ display: "flex",
1102
+ flexDirection: "column",
1103
+ alignItems: "stretch",
1104
+ marginLeft: "auto",
1105
+ marginRight: "auto"
1106
+ },
1107
+ children: /* @__PURE__ */ qwik._jsxC(qwik.Slot, null, 3, "2Y_0")
1108
+ }, null, 0, "2Y_1");
1109
+ }, "SectionComponent_component_ZWF9iD5WeLg"));
1101
1110
  const componentInfo$a = {
1102
1111
  name: "Core:Button",
1103
1112
  image: "https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",
@@ -1580,24 +1589,6 @@ const componentInfo$6 = {
1580
1589
  }
1581
1590
  ]
1582
1591
  };
1583
- const SectionComponent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1584
- return /* @__PURE__ */ qwik._jsxS("section", {
1585
- ...props.attributes,
1586
- style: {
1587
- width: "100%",
1588
- alignSelf: "stretch",
1589
- flexGrow: 1,
1590
- boxSizing: "border-box",
1591
- maxWidth: props.maxWidth || 1200,
1592
- display: "flex",
1593
- flexDirection: "column",
1594
- alignItems: "stretch",
1595
- marginLeft: "auto",
1596
- marginRight: "auto"
1597
- },
1598
- children: /* @__PURE__ */ qwik._jsxC(qwik.Slot, null, 3, "2Y_0")
1599
- }, null, 0, "2Y_1");
1600
- }, "SectionComponent_component_ZWF9iD5WeLg"));
1601
1592
  const componentInfo$5 = {
1602
1593
  name: "Symbol",
1603
1594
  noWrap: true,
@@ -1637,435 +1628,30 @@ const componentInfo$5 = {
1637
1628
  }
1638
1629
  ]
1639
1630
  };
1640
- const MSG_PREFIX = "[Builder.io]: ";
1641
- const logger = {
1642
- log: (...message) => console.log(MSG_PREFIX, ...message),
1643
- error: (...message) => console.error(MSG_PREFIX, ...message),
1644
- warn: (...message) => console.warn(MSG_PREFIX, ...message)
1645
- };
1646
- function getGlobalThis() {
1647
- if (typeof globalThis !== "undefined")
1648
- return globalThis;
1649
- if (typeof window !== "undefined")
1650
- return window;
1651
- if (typeof global !== "undefined")
1652
- return global;
1653
- if (typeof self !== "undefined")
1654
- return self;
1655
- return globalThis;
1656
- }
1657
- function getFetch() {
1658
- const globalFetch = getGlobalThis().fetch;
1659
- if (typeof globalFetch === "undefined") {
1660
- console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
1661
- For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
1662
- throw new Error("Builder SDK could not find a global `fetch` function");
1663
- }
1664
- return globalFetch;
1665
- }
1666
- const fetch$1 = getFetch();
1667
- const getTopLevelDomain = (host) => {
1668
- if (host === "localhost" || host === "127.0.0.1")
1669
- return host;
1670
- const parts = host.split(".");
1671
- if (parts.length > 2)
1672
- return parts.slice(1).join(".");
1673
- return host;
1674
- };
1675
- const getCookie = async ({ name, canTrack }) => {
1676
- try {
1677
- if (!canTrack)
1678
- return void 0;
1679
- return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
1680
- } catch (err) {
1681
- console.debug("[COOKIE] GET error: ", err);
1682
- return void 0;
1683
- }
1684
- };
1685
- const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
1686
- const SECURE_CONFIG = [
1687
- [
1688
- "secure",
1689
- ""
1631
+ const componentInfo$4 = {
1632
+ name: "Text",
1633
+ static: true,
1634
+ image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
1635
+ inputs: [
1636
+ {
1637
+ name: "text",
1638
+ type: "html",
1639
+ required: true,
1640
+ autoFocus: true,
1641
+ bubble: true,
1642
+ defaultValue: "Enter some text..."
1643
+ }
1690
1644
  ],
1691
- [
1692
- "SameSite",
1693
- "None"
1694
- ]
1695
- ];
1696
- const createCookieString = ({ name, value, expires }) => {
1697
- const secure = isBrowser() ? location.protocol === "https:" : true;
1698
- const secureObj = secure ? SECURE_CONFIG : [
1699
- []
1700
- ];
1701
- const expiresObj = expires ? [
1702
- [
1703
- "expires",
1704
- expires.toUTCString()
1705
- ]
1706
- ] : [
1707
- []
1708
- ];
1709
- const cookieValue = [
1710
- [
1711
- name,
1712
- value
1713
- ],
1714
- ...expiresObj,
1715
- [
1716
- "path",
1717
- "/"
1718
- ],
1719
- [
1720
- "domain",
1721
- getTopLevelDomain(window.location.hostname)
1722
- ],
1723
- ...secureObj
1724
- ];
1725
- const cookie = stringifyCookie(cookieValue);
1726
- return cookie;
1727
- };
1728
- const setCookie = async ({ name, value, expires, canTrack }) => {
1729
- try {
1730
- if (!canTrack)
1731
- return;
1732
- const cookie = createCookieString({
1733
- name,
1734
- value,
1735
- expires
1736
- });
1737
- document.cookie = cookie;
1738
- } catch (err) {
1739
- console.warn("[COOKIE] SET error: ", err);
1740
- }
1741
- };
1742
- const BUILDER_STORE_PREFIX = "builderio.variations";
1743
- const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
1744
- const getContentVariationCookie = ({ contentId, canTrack }) => getCookie({
1745
- name: getContentTestKey(contentId),
1746
- canTrack
1747
- });
1748
- const setContentVariationCookie = ({ contentId, canTrack, value }) => setCookie({
1749
- name: getContentTestKey(contentId),
1750
- value,
1751
- canTrack
1752
- });
1753
- const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
1754
- const getRandomVariationId = ({ id, variations }) => {
1755
- let n = 0;
1756
- const random = Math.random();
1757
- for (const id2 in variations) {
1758
- const testRatio = variations[id2]?.testRatio;
1759
- n += testRatio;
1760
- if (random < n)
1761
- return id2;
1762
- }
1763
- return id;
1764
- };
1765
- const getTestFields = ({ item, testGroupId }) => {
1766
- const variationValue = item.variations[testGroupId];
1767
- if (testGroupId === item.id || !variationValue)
1768
- return {
1769
- testVariationId: item.id,
1770
- testVariationName: "Default"
1771
- };
1772
- else
1773
- return {
1774
- data: variationValue.data,
1775
- testVariationId: variationValue.id,
1776
- testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
1777
- };
1778
- };
1779
- const getContentVariation = async ({ item, canTrack }) => {
1780
- const testGroupId = await getContentVariationCookie({
1781
- canTrack,
1782
- contentId: item.id
1783
- });
1784
- const testFields = testGroupId ? getTestFields({
1785
- item,
1786
- testGroupId
1787
- }) : void 0;
1788
- if (testFields)
1789
- return testFields;
1790
- else {
1791
- const randomVariationId = getRandomVariationId({
1792
- variations: item.variations,
1793
- id: item.id
1794
- });
1795
- setContentVariationCookie({
1796
- contentId: item.id,
1797
- value: randomVariationId,
1798
- canTrack
1799
- }).catch((err) => {
1800
- console.error("could not store A/B test variation: ", err);
1801
- });
1802
- return getTestFields({
1803
- item,
1804
- testGroupId: randomVariationId
1805
- });
1645
+ defaultStyles: {
1646
+ lineHeight: "normal",
1647
+ height: "auto",
1648
+ textAlign: "center"
1806
1649
  }
1807
1650
  };
1808
- const handleABTesting = async ({ item, canTrack }) => {
1809
- if (!checkIsBuilderContentWithVariations(item))
1810
- return;
1811
- const variationValue = await getContentVariation({
1812
- item,
1813
- canTrack
1814
- });
1815
- Object.assign(item, variationValue);
1816
- };
1817
- function flatten(object, path = null, separator = ".") {
1818
- return Object.keys(object).reduce((acc, key) => {
1819
- const value = object[key];
1820
- const newPath = [
1821
- path,
1822
- key
1823
- ].filter(Boolean).join(separator);
1824
- const isObject = [
1825
- typeof value === "object",
1826
- value !== null,
1827
- !(Array.isArray(value) && value.length === 0)
1828
- ].every(Boolean);
1829
- return isObject ? {
1830
- ...acc,
1831
- ...flatten(value, newPath, separator)
1832
- } : {
1833
- ...acc,
1834
- [newPath]: value
1835
- };
1836
- }, {});
1837
- }
1838
- const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
1839
- const BUILDER_OPTIONS_PREFIX = "options.";
1840
- const convertSearchParamsToQueryObject = (searchParams) => {
1841
- const options = {};
1842
- searchParams.forEach((value, key) => {
1843
- options[key] = value;
1844
- });
1845
- return options;
1846
- };
1847
- const getBuilderSearchParams = (_options) => {
1848
- if (!_options)
1849
- return {};
1850
- const options = normalizeSearchParams(_options);
1851
- const newOptions = {};
1852
- Object.keys(options).forEach((key) => {
1853
- if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
1854
- const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
1855
- newOptions[trimmedKey] = options[key];
1856
- }
1857
- });
1858
- return newOptions;
1859
- };
1860
- const getBuilderSearchParamsFromWindow = () => {
1861
- if (!isBrowser())
1862
- return {};
1863
- const searchParams = new URLSearchParams(window.location.search);
1864
- return getBuilderSearchParams(searchParams);
1865
- };
1866
- const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
1867
- const DEFAULT_API_VERSION = "v3";
1868
- const generateContentUrl = (options) => {
1869
- const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, locale, apiVersion = DEFAULT_API_VERSION } = options;
1870
- if (!apiKey)
1871
- throw new Error("Missing API key");
1872
- if (![
1873
- "v2",
1874
- "v3"
1875
- ].includes(apiVersion))
1876
- throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
1877
- const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}`);
1878
- const queryOptions = {
1879
- ...getBuilderSearchParamsFromWindow(),
1880
- ...normalizeSearchParams(options.options || {})
1881
- };
1882
- const flattened = flatten(queryOptions);
1883
- for (const key in flattened)
1884
- url.searchParams.set(key, String(flattened[key]));
1885
- if (userAttributes)
1886
- url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
1887
- if (query) {
1888
- const flattened2 = flatten({
1889
- query
1890
- });
1891
- for (const key in flattened2)
1892
- url.searchParams.set(key, JSON.stringify(flattened2[key]));
1893
- }
1894
- return url;
1895
- };
1896
- async function getContent(options) {
1897
- const allContent = await getAllContent({
1898
- ...options,
1899
- limit: 1
1900
- });
1901
- if (allContent && "results" in allContent)
1902
- return allContent?.results[0] || null;
1903
- return null;
1904
- }
1905
- async function getAllContent(options) {
1906
- try {
1907
- const url = generateContentUrl(options);
1908
- const res = await fetch$1(url.href);
1909
- const content = await res.json();
1910
- if ("status" in content && !("results" in content)) {
1911
- logger.error("Error fetching data. ", {
1912
- url,
1913
- content,
1914
- options
1915
- });
1916
- return content;
1917
- }
1918
- const canTrack = options.canTrack !== false;
1919
- try {
1920
- if (canTrack && Array.isArray(content.results))
1921
- for (const item of content.results)
1922
- await handleABTesting({
1923
- item,
1924
- canTrack
1925
- });
1926
- } catch (e) {
1927
- logger.error("Could not setup A/B testing. ", e);
1928
- }
1929
- return content;
1930
- } catch (error) {
1931
- logger.error("Error fetching data. ", error);
1932
- return null;
1933
- }
1934
- }
1935
- const fetchContent = function fetchContent2(props, state, builderContext2) {
1936
- if (!state.contentToUse && props.symbol?.model && builderContext2?.apiKey)
1937
- getContent({
1938
- model: props.symbol.model,
1939
- apiKey: builderContext2.apiKey,
1940
- apiVersion: builderContext2.apiVersion,
1941
- query: {
1942
- id: props.symbol.entry
1943
- }
1944
- }).then((response) => {
1945
- if (response)
1946
- state.contentToUse = response;
1947
- }).catch((err) => {
1948
- logger.error("Could not fetch symbol content: ", err);
1949
- });
1950
- };
1951
- const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1952
- const builderContext$1 = qwik.useContext(builderContext);
1953
- const state = qwik.useStore({
1954
- className: [
1955
- ...[
1956
- props.attributes.class
1957
- ],
1958
- "builder-symbol",
1959
- props.symbol?.inline ? "builder-inline-symbol" : void 0,
1960
- props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0
1961
- ].filter(Boolean).join(" "),
1962
- contentToUse: props.symbol?.content
1963
- });
1964
- qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
1965
- const [builderContext2, props2, state2] = qwik.useLexicalScope();
1966
- fetchContent(props2, state2, builderContext2);
1967
- }, "Symbol_component_useVisibleTask_oMPs8W5ZhwE", [
1968
- builderContext$1,
1969
- props,
1970
- state
1971
- ]));
1972
- qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(({ track: track2 }) => {
1973
- const [builderContext2, props2, state2] = qwik.useLexicalScope();
1974
- track2(() => props2.symbol);
1975
- fetchContent(props2, state2, builderContext2);
1976
- }, "Symbol_component_useTask_NIAWAC1bMBo", [
1977
- builderContext$1,
1978
- props,
1979
- state
1980
- ]));
1981
- return /* @__PURE__ */ qwik._jsxS("div", {
1982
- ...props.attributes,
1983
- children: /* @__PURE__ */ qwik._jsxC(RenderContent, {
1984
- get apiVersion() {
1985
- return builderContext$1.apiVersion;
1986
- },
1987
- get apiKey() {
1988
- return builderContext$1.apiKey;
1989
- },
1990
- get context() {
1991
- return builderContext$1.context;
1992
- },
1993
- get customComponents() {
1994
- return Object.values(builderContext$1.registeredComponents);
1995
- },
1996
- get data() {
1997
- return {
1998
- ...props.symbol?.data,
1999
- ...builderContext$1.localState,
2000
- ...state.contentToUse?.data?.state
2001
- };
2002
- },
2003
- get model() {
2004
- return props.symbol?.model;
2005
- },
2006
- get content() {
2007
- return state.contentToUse;
2008
- },
2009
- [qwik._IMMUTABLE]: {
2010
- apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
2011
- builderContext$1
2012
- ], "p0.apiVersion"),
2013
- apiKey: qwik._fnSignal((p0) => p0.apiKey, [
2014
- builderContext$1
2015
- ], "p0.apiKey"),
2016
- context: qwik._fnSignal((p0) => p0.context, [
2017
- builderContext$1
2018
- ], "p0.context"),
2019
- customComponents: qwik._fnSignal((p0) => Object.values(p0.registeredComponents), [
2020
- builderContext$1
2021
- ], "Object.values(p0.registeredComponents)"),
2022
- data: qwik._fnSignal((p0, p1, p2) => ({
2023
- ...p1.symbol?.data,
2024
- ...p0.localState,
2025
- ...p2.contentToUse?.data?.state
2026
- }), [
2027
- builderContext$1,
2028
- props,
2029
- state
2030
- ], "{...p1.symbol?.data,...p0.localState,...p2.contentToUse?.data?.state}"),
2031
- model: qwik._fnSignal((p0) => p0.symbol?.model, [
2032
- props
2033
- ], "p0.symbol?.model"),
2034
- content: qwik._fnSignal((p0) => p0.contentToUse, [
2035
- state
2036
- ], "p0.contentToUse")
2037
- }
2038
- }, 3, "Wt_0")
2039
- }, {
2040
- class: qwik._fnSignal((p0) => p0.className, [
2041
- state
2042
- ], "p0.className")
2043
- }, 0, "Wt_1");
2044
- }, "Symbol_component_WVvggdkUPdk"));
2045
- const componentInfo$4 = {
2046
- name: "Text",
2047
- static: true,
2048
- image: "https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",
2049
- inputs: [
2050
- {
2051
- name: "text",
2052
- type: "html",
2053
- required: true,
2054
- autoFocus: true,
2055
- bubble: true,
2056
- defaultValue: "Enter some text..."
2057
- }
2058
- ],
2059
- defaultStyles: {
2060
- lineHeight: "normal",
2061
- height: "auto",
2062
- textAlign: "center"
2063
- }
2064
- };
2065
- const Text = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
2066
- return /* @__PURE__ */ qwik._jsxQ("span", {
2067
- style: {
2068
- outline: "none"
1651
+ const Text = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
1652
+ return /* @__PURE__ */ qwik._jsxQ("span", {
1653
+ style: {
1654
+ outline: "none"
2069
1655
  }
2070
1656
  }, {
2071
1657
  class: "builder-text",
@@ -2456,52 +2042,383 @@ const componentInfo = {
2456
2042
  }
2457
2043
  ]
2458
2044
  };
2459
- const getDefaultRegisteredComponents = () => [
2460
- {
2461
- component: Button,
2462
- ...componentInfo$a
2463
- },
2464
- {
2465
- component: Columns,
2466
- ...componentInfo$9
2467
- },
2468
- {
2469
- component: CustomCode,
2470
- ...componentInfo
2471
- },
2472
- {
2473
- component: Embed,
2474
- ...componentInfo$2
2475
- },
2476
- {
2477
- component: FragmentComponent,
2478
- ...componentInfo$8
2479
- },
2480
- {
2481
- component: Image,
2482
- ...componentInfo$7
2483
- },
2484
- {
2485
- component: ImgComponent,
2486
- ...componentInfo$1
2487
- },
2488
- {
2489
- component: SectionComponent,
2490
- ...componentInfo$6
2491
- },
2492
- {
2493
- component: Symbol$1,
2494
- ...componentInfo$5
2495
- },
2496
- {
2497
- component: Text,
2498
- ...componentInfo$4
2499
- },
2500
- {
2501
- component: Video,
2502
- ...componentInfo$3
2045
+ const getDefaultRegisteredComponents = () => [
2046
+ {
2047
+ component: Button,
2048
+ ...componentInfo$a
2049
+ },
2050
+ {
2051
+ component: Columns,
2052
+ ...componentInfo$9
2053
+ },
2054
+ {
2055
+ component: CustomCode,
2056
+ ...componentInfo
2057
+ },
2058
+ {
2059
+ component: Embed,
2060
+ ...componentInfo$2
2061
+ },
2062
+ {
2063
+ component: FragmentComponent,
2064
+ ...componentInfo$8
2065
+ },
2066
+ {
2067
+ component: Image,
2068
+ ...componentInfo$7
2069
+ },
2070
+ {
2071
+ component: ImgComponent,
2072
+ ...componentInfo$1
2073
+ },
2074
+ {
2075
+ component: SectionComponent,
2076
+ ...componentInfo$6
2077
+ },
2078
+ {
2079
+ component: Symbol$1,
2080
+ ...componentInfo$5
2081
+ },
2082
+ {
2083
+ component: Text,
2084
+ ...componentInfo$4
2085
+ },
2086
+ {
2087
+ component: Video,
2088
+ ...componentInfo$3
2089
+ }
2090
+ ];
2091
+ const MSG_PREFIX = "[Builder.io]: ";
2092
+ const logger = {
2093
+ log: (...message) => console.log(MSG_PREFIX, ...message),
2094
+ error: (...message) => console.error(MSG_PREFIX, ...message),
2095
+ warn: (...message) => console.warn(MSG_PREFIX, ...message),
2096
+ debug: (...message) => console.debug(MSG_PREFIX, ...message)
2097
+ };
2098
+ const getTopLevelDomain = (host) => {
2099
+ if (host === "localhost" || host === "127.0.0.1")
2100
+ return host;
2101
+ const parts = host.split(".");
2102
+ if (parts.length > 2)
2103
+ return parts.slice(1).join(".");
2104
+ return host;
2105
+ };
2106
+ const getCookieSync = ({ name, canTrack }) => {
2107
+ try {
2108
+ if (!canTrack)
2109
+ return void 0;
2110
+ return document.cookie.split("; ").find((row) => row.startsWith(`${name}=`))?.split("=")[1];
2111
+ } catch (err) {
2112
+ logger.warn("[COOKIE] GET error: ", err?.message || err);
2113
+ return void 0;
2114
+ }
2115
+ };
2116
+ const getCookie = async (args) => getCookieSync(args);
2117
+ const stringifyCookie = (cookie) => cookie.map(([key, value]) => value ? `${key}=${value}` : key).filter(checkIsDefined).join("; ");
2118
+ const SECURE_CONFIG = [
2119
+ [
2120
+ "secure",
2121
+ ""
2122
+ ],
2123
+ [
2124
+ "SameSite",
2125
+ "None"
2126
+ ]
2127
+ ];
2128
+ const createCookieString = ({ name, value, expires }) => {
2129
+ const secure = isBrowser() ? location.protocol === "https:" : true;
2130
+ const secureObj = secure ? SECURE_CONFIG : [
2131
+ []
2132
+ ];
2133
+ const expiresObj = expires ? [
2134
+ [
2135
+ "expires",
2136
+ expires.toUTCString()
2137
+ ]
2138
+ ] : [
2139
+ []
2140
+ ];
2141
+ const cookieValue = [
2142
+ [
2143
+ name,
2144
+ value
2145
+ ],
2146
+ ...expiresObj,
2147
+ [
2148
+ "path",
2149
+ "/"
2150
+ ],
2151
+ [
2152
+ "domain",
2153
+ getTopLevelDomain(window.location.hostname)
2154
+ ],
2155
+ ...secureObj
2156
+ ];
2157
+ const cookie = stringifyCookie(cookieValue);
2158
+ return cookie;
2159
+ };
2160
+ const setCookie = async ({ name, value, expires, canTrack }) => {
2161
+ try {
2162
+ if (!canTrack)
2163
+ return;
2164
+ const cookie = createCookieString({
2165
+ name,
2166
+ value,
2167
+ expires
2168
+ });
2169
+ document.cookie = cookie;
2170
+ } catch (err) {
2171
+ logger.warn("[COOKIE] SET error: ", err?.message || err);
2172
+ }
2173
+ };
2174
+ const BUILDER_STORE_PREFIX = "builder.tests";
2175
+ const getContentTestKey = (id) => `${BUILDER_STORE_PREFIX}.${id}`;
2176
+ const getContentVariationCookie = ({ contentId }) => getCookie({
2177
+ name: getContentTestKey(contentId),
2178
+ canTrack: true
2179
+ });
2180
+ const getContentVariationCookieSync = ({ contentId }) => getCookieSync({
2181
+ name: getContentTestKey(contentId),
2182
+ canTrack: true
2183
+ });
2184
+ const setContentVariationCookie = ({ contentId, value }) => setCookie({
2185
+ name: getContentTestKey(contentId),
2186
+ value,
2187
+ canTrack: true
2188
+ });
2189
+ const checkIsBuilderContentWithVariations = (item) => checkIsDefined(item.id) && checkIsDefined(item.variations) && Object.keys(item.variations).length > 0;
2190
+ const getRandomVariationId = ({ id, variations }) => {
2191
+ let n = 0;
2192
+ const random = Math.random();
2193
+ for (const id2 in variations) {
2194
+ const testRatio = variations[id2]?.testRatio;
2195
+ n += testRatio;
2196
+ if (random < n)
2197
+ return id2;
2198
+ }
2199
+ return id;
2200
+ };
2201
+ const getAndSetVariantId = (args) => {
2202
+ const randomVariationId = getRandomVariationId(args);
2203
+ setContentVariationCookie({
2204
+ contentId: args.id,
2205
+ value: randomVariationId
2206
+ }).catch((err) => {
2207
+ logger.error("could not store A/B test variation: ", err);
2208
+ });
2209
+ return randomVariationId;
2210
+ };
2211
+ const getTestFields = ({ item, testGroupId }) => {
2212
+ const variationValue = item.variations[testGroupId];
2213
+ if (testGroupId === item.id || !variationValue)
2214
+ return {
2215
+ testVariationId: item.id,
2216
+ testVariationName: "Default"
2217
+ };
2218
+ else
2219
+ return {
2220
+ data: variationValue.data,
2221
+ testVariationId: variationValue.id,
2222
+ testVariationName: variationValue.name || (variationValue.id === item.id ? "Default" : "")
2223
+ };
2224
+ };
2225
+ const handleABTestingSync = ({ item, canTrack }) => {
2226
+ if (!canTrack)
2227
+ return item;
2228
+ if (!item)
2229
+ return void 0;
2230
+ if (!checkIsBuilderContentWithVariations(item))
2231
+ return item;
2232
+ const testGroupId = getContentVariationCookieSync({
2233
+ contentId: item.id
2234
+ }) || getAndSetVariantId({
2235
+ variations: item.variations,
2236
+ id: item.id
2237
+ });
2238
+ const variationValue = getTestFields({
2239
+ item,
2240
+ testGroupId
2241
+ });
2242
+ return {
2243
+ ...item,
2244
+ ...variationValue
2245
+ };
2246
+ };
2247
+ const handleABTesting = async ({ item, canTrack }) => {
2248
+ if (!canTrack)
2249
+ return item;
2250
+ if (!checkIsBuilderContentWithVariations(item))
2251
+ return item;
2252
+ const cookieValue = await getContentVariationCookie({
2253
+ contentId: item.id
2254
+ });
2255
+ const testGroupId = cookieValue || getAndSetVariantId({
2256
+ variations: item.variations,
2257
+ id: item.id
2258
+ });
2259
+ const variationValue = getTestFields({
2260
+ item,
2261
+ testGroupId
2262
+ });
2263
+ return {
2264
+ ...item,
2265
+ ...variationValue
2266
+ };
2267
+ };
2268
+ const getDefaultCanTrack = (canTrack) => checkIsDefined(canTrack) ? canTrack : true;
2269
+ function getGlobalThis() {
2270
+ if (typeof globalThis !== "undefined")
2271
+ return globalThis;
2272
+ if (typeof window !== "undefined")
2273
+ return window;
2274
+ if (typeof global !== "undefined")
2275
+ return global;
2276
+ if (typeof self !== "undefined")
2277
+ return self;
2278
+ return globalThis;
2279
+ }
2280
+ function getFetch() {
2281
+ const globalFetch = getGlobalThis().fetch;
2282
+ if (typeof globalFetch === "undefined") {
2283
+ console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
2284
+ For more information, read https://github.com/BuilderIO/this-package-uses-fetch`);
2285
+ throw new Error("Builder SDK could not find a global `fetch` function");
2286
+ }
2287
+ return globalFetch;
2288
+ }
2289
+ const fetch$1 = getFetch();
2290
+ function flatten(object, path = null, separator = ".") {
2291
+ return Object.keys(object).reduce((acc, key) => {
2292
+ const value = object[key];
2293
+ const newPath = [
2294
+ path,
2295
+ key
2296
+ ].filter(Boolean).join(separator);
2297
+ const isObject = [
2298
+ typeof value === "object",
2299
+ value !== null,
2300
+ !(Array.isArray(value) && value.length === 0)
2301
+ ].every(Boolean);
2302
+ return isObject ? {
2303
+ ...acc,
2304
+ ...flatten(value, newPath, separator)
2305
+ } : {
2306
+ ...acc,
2307
+ [newPath]: value
2308
+ };
2309
+ }, {});
2310
+ }
2311
+ const BUILDER_SEARCHPARAMS_PREFIX = "builder.";
2312
+ const BUILDER_OPTIONS_PREFIX = "options.";
2313
+ const convertSearchParamsToQueryObject = (searchParams) => {
2314
+ const options = {};
2315
+ searchParams.forEach((value, key) => {
2316
+ options[key] = value;
2317
+ });
2318
+ return options;
2319
+ };
2320
+ const getBuilderSearchParams = (_options) => {
2321
+ if (!_options)
2322
+ return {};
2323
+ const options = normalizeSearchParams(_options);
2324
+ const newOptions = {};
2325
+ Object.keys(options).forEach((key) => {
2326
+ if (key.startsWith(BUILDER_SEARCHPARAMS_PREFIX)) {
2327
+ const trimmedKey = key.replace(BUILDER_SEARCHPARAMS_PREFIX, "").replace(BUILDER_OPTIONS_PREFIX, "");
2328
+ newOptions[trimmedKey] = options[key];
2329
+ }
2330
+ });
2331
+ return newOptions;
2332
+ };
2333
+ const getBuilderSearchParamsFromWindow = () => {
2334
+ if (!isBrowser())
2335
+ return {};
2336
+ const searchParams = new URLSearchParams(window.location.search);
2337
+ return getBuilderSearchParams(searchParams);
2338
+ };
2339
+ const normalizeSearchParams = (searchParams) => searchParams instanceof URLSearchParams ? convertSearchParamsToQueryObject(searchParams) : searchParams;
2340
+ const DEFAULT_API_VERSION = "v3";
2341
+ const generateContentUrl = (options) => {
2342
+ const { limit = 30, userAttributes, query, noTraverse = false, model, apiKey, includeRefs = true, enrich, locale, apiVersion = DEFAULT_API_VERSION } = options;
2343
+ if (!apiKey)
2344
+ throw new Error("Missing API key");
2345
+ if (![
2346
+ "v2",
2347
+ "v3"
2348
+ ].includes(apiVersion))
2349
+ throw new Error(`Invalid apiVersion: expected 'v2' or 'v3', received '${apiVersion}'`);
2350
+ const url = new URL(`https://cdn.builder.io/api/${apiVersion}/content/${model}?apiKey=${apiKey}&limit=${limit}&noTraverse=${noTraverse}&includeRefs=${includeRefs}${locale ? `&locale=${locale}` : ""}${enrich ? `&enrich=${enrich}` : ""}`);
2351
+ const queryOptions = {
2352
+ ...getBuilderSearchParamsFromWindow(),
2353
+ ...normalizeSearchParams(options.options || {})
2354
+ };
2355
+ const flattened = flatten(queryOptions);
2356
+ for (const key in flattened)
2357
+ url.searchParams.set(key, String(flattened[key]));
2358
+ if (userAttributes)
2359
+ url.searchParams.set("userAttributes", JSON.stringify(userAttributes));
2360
+ if (query) {
2361
+ const flattened2 = flatten({
2362
+ query
2363
+ });
2364
+ for (const key in flattened2)
2365
+ url.searchParams.set(key, JSON.stringify(flattened2[key]));
2366
+ }
2367
+ return url;
2368
+ };
2369
+ const checkContentHasResults = (content) => "results" in content;
2370
+ async function getContent(options) {
2371
+ const allContent = await getAllContent({
2372
+ ...options,
2373
+ limit: 1
2374
+ });
2375
+ if (allContent && checkContentHasResults(allContent))
2376
+ return allContent.results[0] || null;
2377
+ return null;
2378
+ }
2379
+ const fetchContent$1 = async (options) => {
2380
+ const url = generateContentUrl(options);
2381
+ const res = await fetch$1(url.href);
2382
+ const content = await res.json();
2383
+ return content;
2384
+ };
2385
+ const processContentResult = async (options, content) => {
2386
+ const canTrack = getDefaultCanTrack(options.canTrack);
2387
+ if (!canTrack)
2388
+ return content;
2389
+ if (!(isBrowser() || TARGET === "reactNative"))
2390
+ return content;
2391
+ try {
2392
+ const newResults = [];
2393
+ for (const item of content.results)
2394
+ newResults.push(await handleABTesting({
2395
+ item,
2396
+ canTrack
2397
+ }));
2398
+ content.results = newResults;
2399
+ } catch (e) {
2400
+ logger.error("Could not process A/B tests. ", e);
2401
+ }
2402
+ return content;
2403
+ };
2404
+ async function getAllContent(options) {
2405
+ try {
2406
+ const url = generateContentUrl(options);
2407
+ const content = await fetchContent$1(options);
2408
+ if (!checkContentHasResults(content)) {
2409
+ logger.error("Error fetching data. ", {
2410
+ url,
2411
+ content,
2412
+ options
2413
+ });
2414
+ return content;
2415
+ }
2416
+ return processContentResult(options, content);
2417
+ } catch (error) {
2418
+ logger.error("Error fetching data. ", error);
2419
+ return null;
2503
2420
  }
2504
- ];
2421
+ }
2505
2422
  function isPreviewing() {
2506
2423
  if (!isBrowser())
2507
2424
  return false;
@@ -2510,14 +2427,6 @@ function isPreviewing() {
2510
2427
  return Boolean(location.search.indexOf("builder.preview=") !== -1);
2511
2428
  }
2512
2429
  const components = [];
2513
- function registerComponent(component, info) {
2514
- components.push({
2515
- component,
2516
- ...info
2517
- });
2518
- console.warn("registerComponent is deprecated. Use the `customComponents` prop in RenderContent instead to provide your custom components to the builder SDK.");
2519
- return component;
2520
- }
2521
2430
  const createRegisterComponentMessage = ({ component: _, ...info }) => ({
2522
2431
  type: "builder.registerComponent",
2523
2432
  data: prepareComponentInfoToSend(info)
@@ -2762,7 +2671,7 @@ const getInteractionPropertiesForEvent = (event) => {
2762
2671
  }
2763
2672
  };
2764
2673
  };
2765
- const SDK_VERSION = "0.3.1";
2674
+ const SDK_VERSION = "0.4.1";
2766
2675
  const registry = {};
2767
2676
  function register(type, info) {
2768
2677
  let typeList = registry[type];
@@ -2890,6 +2799,128 @@ const setupBrowserForEditing = (options = {}) => {
2890
2799
  });
2891
2800
  }
2892
2801
  };
2802
+ const getVariants = (content) => Object.values(content?.variations || {});
2803
+ const checkShouldRunVariants = ({ canTrack, content }) => {
2804
+ const hasVariants = getVariants(content).length > 0;
2805
+ if (!hasVariants)
2806
+ return false;
2807
+ if (!canTrack)
2808
+ return false;
2809
+ if (isBrowser())
2810
+ return false;
2811
+ return true;
2812
+ };
2813
+ function bldrAbTest(contentId, variants, isHydrationTarget2) {
2814
+ function getAndSetVariantId2() {
2815
+ function setCookie2(name, value, days) {
2816
+ let expires = "";
2817
+ if (days) {
2818
+ const date = new Date();
2819
+ date.setTime(date.getTime() + days * 864e5);
2820
+ expires = "; expires=" + date.toUTCString();
2821
+ }
2822
+ document.cookie = name + "=" + (value || "") + expires + "; path=/; Secure; SameSite=None";
2823
+ }
2824
+ function getCookie2(name) {
2825
+ const nameEQ = name + "=";
2826
+ const ca = document.cookie.split(";");
2827
+ for (let i = 0; i < ca.length; i++) {
2828
+ let c = ca[i];
2829
+ while (c.charAt(0) === " ")
2830
+ c = c.substring(1, c.length);
2831
+ if (c.indexOf(nameEQ) === 0)
2832
+ return c.substring(nameEQ.length, c.length);
2833
+ }
2834
+ return null;
2835
+ }
2836
+ const cookieName = `builder.tests.${contentId}`;
2837
+ const variantInCookie = getCookie2(cookieName);
2838
+ const availableIDs = variants.map((vr) => vr.id).concat(contentId);
2839
+ if (variantInCookie && availableIDs.includes(variantInCookie))
2840
+ return variantInCookie;
2841
+ let n = 0;
2842
+ const random = Math.random();
2843
+ for (let i = 0; i < variants.length; i++) {
2844
+ const variant = variants[i];
2845
+ const testRatio = variant.testRatio;
2846
+ n += testRatio;
2847
+ if (random < n) {
2848
+ setCookie2(cookieName, variant.id);
2849
+ return variant.id;
2850
+ }
2851
+ }
2852
+ setCookie2(cookieName, contentId);
2853
+ return contentId;
2854
+ }
2855
+ const winningVariantId = getAndSetVariantId2();
2856
+ const styleEl = document.getElementById(`variants-styles-${contentId}`);
2857
+ if (isHydrationTarget2) {
2858
+ styleEl.remove();
2859
+ const thisScriptEl = document.getElementById(`variants-script-${contentId}`);
2860
+ thisScriptEl?.remove();
2861
+ } else {
2862
+ const newStyleStr = variants.concat({
2863
+ id: contentId
2864
+ }).filter((variant) => variant.id !== winningVariantId).map((value) => {
2865
+ return `.variant-${value.id} { display: none; }
2866
+ `;
2867
+ }).join("");
2868
+ styleEl.innerHTML = newStyleStr;
2869
+ }
2870
+ }
2871
+ function bldrCntntScrpt(variantContentId, defaultContentId, isHydrationTarget2) {
2872
+ if (!navigator.cookieEnabled)
2873
+ return;
2874
+ function getCookie2(name) {
2875
+ const nameEQ = name + "=";
2876
+ const ca = document.cookie.split(";");
2877
+ for (let i = 0; i < ca.length; i++) {
2878
+ let c = ca[i];
2879
+ while (c.charAt(0) === " ")
2880
+ c = c.substring(1, c.length);
2881
+ if (c.indexOf(nameEQ) === 0)
2882
+ return c.substring(nameEQ.length, c.length);
2883
+ }
2884
+ return null;
2885
+ }
2886
+ const cookieName = `builder.tests.${defaultContentId}`;
2887
+ const variantId = getCookie2(cookieName);
2888
+ const parentDiv = document.querySelector(`[builder-content-id="${variantContentId}"]`);
2889
+ const variantIsDefaultContent = variantContentId === defaultContentId;
2890
+ if (variantId === variantContentId) {
2891
+ if (variantIsDefaultContent)
2892
+ return;
2893
+ parentDiv?.removeAttribute("hidden");
2894
+ parentDiv?.removeAttribute("aria-hidden");
2895
+ } else {
2896
+ if (variantIsDefaultContent) {
2897
+ if (isHydrationTarget2)
2898
+ parentDiv?.remove();
2899
+ else {
2900
+ parentDiv?.setAttribute("hidden", "true");
2901
+ parentDiv?.setAttribute("aria-hidden", "true");
2902
+ }
2903
+ }
2904
+ return;
2905
+ }
2906
+ return;
2907
+ }
2908
+ const isHydrationTarget = (target) => target === "react" || target === "reactNative" || target === "vue3" || target === "vue2";
2909
+ const AB_TEST_FN_NAME = "bldrAbTest";
2910
+ const CONTENT_FN_NAME = "bldrCntntScrpt";
2911
+ const getVariantsScriptString = (variants, contentId) => {
2912
+ const fnStr = bldrAbTest.toString().replace(/\s+/g, " ");
2913
+ const fnStr2 = bldrCntntScrpt.toString().replace(/\s+/g, " ");
2914
+ return `
2915
+ const ${AB_TEST_FN_NAME} = ${fnStr}
2916
+ const ${CONTENT_FN_NAME} = ${fnStr2}
2917
+ ${AB_TEST_FN_NAME}("${contentId}", ${JSON.stringify(variants)}, ${isHydrationTarget})
2918
+ `;
2919
+ };
2920
+ const getRenderContentScriptString = ({ parentContentId, contentId }) => {
2921
+ return `
2922
+ ${CONTENT_FN_NAME}("${contentId}", "${parentContentId}", ${isHydrationTarget})`;
2923
+ };
2893
2924
  const getCssFromFont = (font) => {
2894
2925
  const family = font.family + (font.kind && !font.kind.includes("#") ? ", " + font.kind : "");
2895
2926
  const name = family.split(",")[0];
@@ -2955,7 +2986,7 @@ ${getFontCss({
2955
2986
  text-align: inherit;
2956
2987
  font-family: inherit;
2957
2988
  }
2958
- `
2989
+ `.trim()
2959
2990
  });
2960
2991
  return /* @__PURE__ */ qwik._jsxC(RenderInlinedStyles, {
2961
2992
  get styles() {
@@ -3128,9 +3159,12 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3128
3159
  ...getDefaultRegisteredComponents(),
3129
3160
  ...components,
3130
3161
  ...props.customComponents || []
3131
- ].reduce((acc, curr) => ({
3162
+ ].reduce((acc, { component, ...curr }) => ({
3132
3163
  ...acc,
3133
- [curr.name]: curr
3164
+ [curr.name]: {
3165
+ component,
3166
+ ...curr
3167
+ }
3134
3168
  }), {}),
3135
3169
  canTrackToUse: checkIsDefined(props.canTrack) ? props.canTrack : true,
3136
3170
  clicked: false,
@@ -3142,6 +3176,10 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3142
3176
  forceReRenderCount: 0,
3143
3177
  httpReqsData: {},
3144
3178
  overrideContent: null,
3179
+ scriptStr: getRenderContentScriptString({
3180
+ contentId: props.content?.id,
3181
+ parentContentId: props.parentContentId
3182
+ }),
3145
3183
  update: 0,
3146
3184
  useContent: getContentInitialValue({
3147
3185
  content: props.content,
@@ -3150,7 +3188,7 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3150
3188
  }, {
3151
3189
  deep: true
3152
3190
  });
3153
- qwik.useContextProvider(builderContext, qwik.useStore({
3191
+ qwik.useContextProvider(BuilderContext, qwik.useStore({
3154
3192
  content: state.useContent,
3155
3193
  localState: void 0,
3156
3194
  rootState: state.contentState,
@@ -3175,6 +3213,9 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3175
3213
  } : {},
3176
3214
  ...props2.includeRefs ? {
3177
3215
  includeRefs: props2.includeRefs
3216
+ } : {},
3217
+ ...props2.enrich ? {
3218
+ enrich: props2.enrich
3178
3219
  } : {}
3179
3220
  });
3180
3221
  Object.values(state2.allRegisteredComponents).forEach((registeredComponent) => {
@@ -3258,15 +3299,52 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3258
3299
  state
3259
3300
  ]));
3260
3301
  return /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
3261
- children: state.useContent ? /* @__PURE__ */ qwik._jsxQ("div", {
3262
- ref: elementRef
3263
- }, {
3264
- "builder-content-id": qwik._fnSignal((p0) => p0.useContent?.id, [
3265
- state
3266
- ], "p0.useContent?.id"),
3267
- "builder-model": qwik._fnSignal((p0) => p0.model, [
3268
- props
3269
- ], "p0.model"),
3302
+ children: state.useContent ? /* @__PURE__ */ qwik._jsxS("div", {
3303
+ ref: elementRef,
3304
+ ...{},
3305
+ ...props.hideContent ? {
3306
+ hidden: true,
3307
+ "aria-hidden": true
3308
+ } : {},
3309
+ children: [
3310
+ props.isSsrAbTest ? /* @__PURE__ */ qwik._jsxQ("script", null, {
3311
+ dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.scriptStr, [
3312
+ state
3313
+ ], "p0.scriptStr")
3314
+ }, null, 3, "03_0") : null,
3315
+ /* @__PURE__ */ qwik._jsxC(RenderContentStyles, {
3316
+ get contentId() {
3317
+ return state.useContent?.id;
3318
+ },
3319
+ get cssCode() {
3320
+ return state.useContent?.data?.cssCode;
3321
+ },
3322
+ get customFonts() {
3323
+ return state.useContent?.data?.customFonts;
3324
+ },
3325
+ [qwik._IMMUTABLE]: {
3326
+ contentId: qwik._fnSignal((p0) => p0.useContent?.id, [
3327
+ state
3328
+ ], "p0.useContent?.id"),
3329
+ cssCode: qwik._fnSignal((p0) => p0.useContent?.data?.cssCode, [
3330
+ state
3331
+ ], "p0.useContent?.data?.cssCode"),
3332
+ customFonts: qwik._fnSignal((p0) => p0.useContent?.data?.customFonts, [
3333
+ state
3334
+ ], "p0.useContent?.data?.customFonts")
3335
+ }
3336
+ }, 3, "03_1"),
3337
+ /* @__PURE__ */ qwik._jsxC(RenderBlocks, {
3338
+ get blocks() {
3339
+ return state.useContent?.data?.blocks;
3340
+ },
3341
+ [qwik._IMMUTABLE]: {
3342
+ blocks: qwik._fnSignal((p0) => p0.useContent?.data?.blocks, [
3343
+ state
3344
+ ], "p0.useContent?.data?.blocks")
3345
+ }
3346
+ }, 3, state.forceReRenderCount)
3347
+ ],
3270
3348
  onClick$: /* @__PURE__ */ qwik.inlinedQrl((event) => {
3271
3349
  const [elementRef2, props2, state2] = qwik.useLexicalScope();
3272
3350
  return onClick(props2, state2, elementRef2, event);
@@ -3275,42 +3353,285 @@ const RenderContent = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inl
3275
3353
  props,
3276
3354
  state
3277
3355
  ])
3278
- }, [
3279
- /* @__PURE__ */ qwik._jsxC(RenderContentStyles, {
3280
- get contentId() {
3281
- return state.useContent?.id;
3356
+ }, {
3357
+ "builder-content-id": qwik._fnSignal((p0) => p0.useContent?.id, [
3358
+ state
3359
+ ], "p0.useContent?.id"),
3360
+ "builder-model": qwik._fnSignal((p0) => p0.model, [
3361
+ props
3362
+ ], "p0.model"),
3363
+ class: qwik._fnSignal((p0) => p0.classNameProp, [
3364
+ props
3365
+ ], "p0.classNameProp")
3366
+ }, 0, "03_2") : null
3367
+ }, 1, "03_3");
3368
+ }, "RenderContent_component_hEAI0ahViXM"));
3369
+ const fetchContent = function fetchContent2(props, state, builderContext) {
3370
+ if (!state.contentToUse && props.symbol?.model && builderContext?.apiKey)
3371
+ getContent({
3372
+ model: props.symbol.model,
3373
+ apiKey: builderContext.apiKey,
3374
+ apiVersion: builderContext.apiVersion,
3375
+ query: {
3376
+ id: props.symbol.entry
3377
+ }
3378
+ }).then((response) => {
3379
+ if (response)
3380
+ state.contentToUse = response;
3381
+ }).catch((err) => {
3382
+ logger.error("Could not fetch symbol content: ", err);
3383
+ });
3384
+ };
3385
+ const Symbol$1 = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
3386
+ const builderContext = qwik.useContext(BuilderContext);
3387
+ const state = qwik.useStore({
3388
+ className: [
3389
+ ...[
3390
+ props.attributes.class
3391
+ ],
3392
+ "builder-symbol",
3393
+ props.symbol?.inline ? "builder-inline-symbol" : void 0,
3394
+ props.symbol?.dynamic || props.dynamic ? "builder-dynamic-symbol" : void 0
3395
+ ].filter(Boolean).join(" "),
3396
+ contentToUse: props.symbol?.content
3397
+ });
3398
+ qwik.useVisibleTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(() => {
3399
+ const [builderContext2, props2, state2] = qwik.useLexicalScope();
3400
+ fetchContent(props2, state2, builderContext2);
3401
+ }, "Symbol_component_useVisibleTask_oMPs8W5ZhwE", [
3402
+ builderContext,
3403
+ props,
3404
+ state
3405
+ ]));
3406
+ qwik.useTaskQrl(/* @__PURE__ */ qwik.inlinedQrl(({ track: track2 }) => {
3407
+ const [builderContext2, props2, state2] = qwik.useLexicalScope();
3408
+ track2(() => props2.symbol);
3409
+ fetchContent(props2, state2, builderContext2);
3410
+ }, "Symbol_component_useTask_NIAWAC1bMBo", [
3411
+ builderContext,
3412
+ props,
3413
+ state
3414
+ ]));
3415
+ return /* @__PURE__ */ qwik._jsxS("div", {
3416
+ ...props.attributes,
3417
+ children: /* @__PURE__ */ qwik._jsxC(RenderContent, {
3418
+ get apiVersion() {
3419
+ return builderContext.apiVersion;
3420
+ },
3421
+ get apiKey() {
3422
+ return builderContext.apiKey;
3423
+ },
3424
+ get context() {
3425
+ return builderContext.context;
3426
+ },
3427
+ get customComponents() {
3428
+ return Object.values(builderContext.registeredComponents);
3429
+ },
3430
+ get data() {
3431
+ return {
3432
+ ...props.symbol?.data,
3433
+ ...builderContext.localState,
3434
+ ...state.contentToUse?.data?.state
3435
+ };
3436
+ },
3437
+ get model() {
3438
+ return props.symbol?.model;
3439
+ },
3440
+ get content() {
3441
+ return state.contentToUse;
3442
+ },
3443
+ [qwik._IMMUTABLE]: {
3444
+ apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3445
+ builderContext
3446
+ ], "p0.apiVersion"),
3447
+ apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3448
+ builderContext
3449
+ ], "p0.apiKey"),
3450
+ context: qwik._fnSignal((p0) => p0.context, [
3451
+ builderContext
3452
+ ], "p0.context"),
3453
+ customComponents: qwik._fnSignal((p0) => Object.values(p0.registeredComponents), [
3454
+ builderContext
3455
+ ], "Object.values(p0.registeredComponents)"),
3456
+ data: qwik._fnSignal((p0, p1, p2) => ({
3457
+ ...p1.symbol?.data,
3458
+ ...p0.localState,
3459
+ ...p2.contentToUse?.data?.state
3460
+ }), [
3461
+ builderContext,
3462
+ props,
3463
+ state
3464
+ ], "{...p1.symbol?.data,...p0.localState,...p2.contentToUse?.data?.state}"),
3465
+ model: qwik._fnSignal((p0) => p0.symbol?.model, [
3466
+ props
3467
+ ], "p0.symbol?.model"),
3468
+ content: qwik._fnSignal((p0) => p0.contentToUse, [
3469
+ state
3470
+ ], "p0.contentToUse")
3471
+ }
3472
+ }, 3, "Wt_0")
3473
+ }, {
3474
+ class: qwik._fnSignal((p0) => p0.className, [
3475
+ state
3476
+ ], "p0.className")
3477
+ }, 0, "Wt_1");
3478
+ }, "Symbol_component_WVvggdkUPdk"));
3479
+ const RenderContentVariants = /* @__PURE__ */ qwik.componentQrl(/* @__PURE__ */ qwik.inlinedQrl((props) => {
3480
+ qwik._jsxBranch();
3481
+ const state = qwik.useStore({
3482
+ contentToRender: checkShouldRunVariants({
3483
+ canTrack: getDefaultCanTrack(props.canTrack),
3484
+ content: props.content
3485
+ }) ? props.content : handleABTestingSync({
3486
+ item: props.content,
3487
+ canTrack: getDefaultCanTrack(props.canTrack)
3488
+ }),
3489
+ hideVariantsStyleString: getVariants(props.content).map((value) => `.variant-${value.id} { display: none; } `).join(""),
3490
+ shouldRenderVariants: checkShouldRunVariants({
3491
+ canTrack: getDefaultCanTrack(props.canTrack),
3492
+ content: props.content
3493
+ }),
3494
+ variantScriptStr: getVariantsScriptString(getVariants(props.content).map((value) => ({
3495
+ id: value.id,
3496
+ testRatio: value.testRatio
3497
+ })), props.content?.id || "")
3498
+ });
3499
+ return /* @__PURE__ */ qwik._jsxC(qwik.Fragment, {
3500
+ children: [
3501
+ state.shouldRenderVariants ? /* @__PURE__ */ qwik._jsxC(jsxRuntime.Fragment, {
3502
+ children: [
3503
+ /* @__PURE__ */ qwik._jsxC(RenderInlinedStyles, {
3504
+ get id() {
3505
+ return `variants-styles-${props.content?.id}`;
3506
+ },
3507
+ get styles() {
3508
+ return state.hideVariantsStyleString;
3509
+ },
3510
+ [qwik._IMMUTABLE]: {
3511
+ id: qwik._fnSignal((p0) => `variants-styles-${p0.content?.id}`, [
3512
+ props
3513
+ ], "`variants-styles-${p0.content?.id}`"),
3514
+ styles: qwik._fnSignal((p0) => p0.hideVariantsStyleString, [
3515
+ state
3516
+ ], "p0.hideVariantsStyleString")
3517
+ }
3518
+ }, 3, "Bz_0"),
3519
+ /* @__PURE__ */ qwik._jsxQ("script", null, {
3520
+ id: qwik._fnSignal((p0) => `variants-script-${p0.content?.id}`, [
3521
+ props
3522
+ ], "`variants-script-${p0.content?.id}`"),
3523
+ dangerouslySetInnerHTML: qwik._fnSignal((p0) => p0.variantScriptStr, [
3524
+ state
3525
+ ], "p0.variantScriptStr")
3526
+ }, null, 3, null),
3527
+ (getVariants(props.content) || []).map(function(variant) {
3528
+ return /* @__PURE__ */ qwik._jsxC(RenderContent, {
3529
+ content: variant,
3530
+ get apiKey() {
3531
+ return props.apiKey;
3532
+ },
3533
+ get apiVersion() {
3534
+ return props.apiVersion;
3535
+ },
3536
+ get canTrack() {
3537
+ return props.canTrack;
3538
+ },
3539
+ get customComponents() {
3540
+ return props.customComponents;
3541
+ },
3542
+ hideContent: true,
3543
+ get parentContentId() {
3544
+ return props.content?.id;
3545
+ },
3546
+ get isSsrAbTest() {
3547
+ return state.shouldRenderVariants;
3548
+ },
3549
+ [qwik._IMMUTABLE]: {
3550
+ apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3551
+ props
3552
+ ], "p0.apiKey"),
3553
+ apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3554
+ props
3555
+ ], "p0.apiVersion"),
3556
+ canTrack: qwik._fnSignal((p0) => p0.canTrack, [
3557
+ props
3558
+ ], "p0.canTrack"),
3559
+ customComponents: qwik._fnSignal((p0) => p0.customComponents, [
3560
+ props
3561
+ ], "p0.customComponents"),
3562
+ hideContent: qwik._IMMUTABLE,
3563
+ parentContentId: qwik._fnSignal((p0) => p0.content?.id, [
3564
+ props
3565
+ ], "p0.content?.id"),
3566
+ isSsrAbTest: qwik._fnSignal((p0) => p0.shouldRenderVariants, [
3567
+ state
3568
+ ], "p0.shouldRenderVariants")
3569
+ }
3570
+ }, 3, variant.id);
3571
+ })
3572
+ ]
3573
+ }, 1, "Bz_1") : null,
3574
+ /* @__PURE__ */ qwik._jsxC(RenderContent, {
3575
+ get model() {
3576
+ return props.model;
3282
3577
  },
3283
- get cssCode() {
3284
- return state.useContent?.data?.cssCode;
3578
+ get content() {
3579
+ return state.contentToRender;
3285
3580
  },
3286
- get customFonts() {
3287
- return state.useContent?.data?.customFonts;
3581
+ get apiKey() {
3582
+ return props.apiKey;
3288
3583
  },
3289
- [qwik._IMMUTABLE]: {
3290
- contentId: qwik._fnSignal((p0) => p0.useContent?.id, [
3291
- state
3292
- ], "p0.useContent?.id"),
3293
- cssCode: qwik._fnSignal((p0) => p0.useContent?.data?.cssCode, [
3294
- state
3295
- ], "p0.useContent?.data?.cssCode"),
3296
- customFonts: qwik._fnSignal((p0) => p0.useContent?.data?.customFonts, [
3297
- state
3298
- ], "p0.useContent?.data?.customFonts")
3299
- }
3300
- }, 3, "03_0"),
3301
- /* @__PURE__ */ qwik._jsxC(RenderBlocks, {
3302
- get blocks() {
3303
- return state.useContent?.data?.blocks;
3584
+ get apiVersion() {
3585
+ return props.apiVersion;
3586
+ },
3587
+ get canTrack() {
3588
+ return props.canTrack;
3589
+ },
3590
+ get customComponents() {
3591
+ return props.customComponents;
3592
+ },
3593
+ get classNameProp() {
3594
+ return `variant-${props.content?.id}`;
3595
+ },
3596
+ get parentContentId() {
3597
+ return props.content?.id;
3598
+ },
3599
+ get isSsrAbTest() {
3600
+ return state.shouldRenderVariants;
3304
3601
  },
3305
3602
  [qwik._IMMUTABLE]: {
3306
- blocks: qwik._fnSignal((p0) => p0.useContent?.data?.blocks, [
3603
+ model: qwik._fnSignal((p0) => p0.model, [
3604
+ props
3605
+ ], "p0.model"),
3606
+ content: qwik._fnSignal((p0) => p0.contentToRender, [
3607
+ state
3608
+ ], "p0.contentToRender"),
3609
+ apiKey: qwik._fnSignal((p0) => p0.apiKey, [
3610
+ props
3611
+ ], "p0.apiKey"),
3612
+ apiVersion: qwik._fnSignal((p0) => p0.apiVersion, [
3613
+ props
3614
+ ], "p0.apiVersion"),
3615
+ canTrack: qwik._fnSignal((p0) => p0.canTrack, [
3616
+ props
3617
+ ], "p0.canTrack"),
3618
+ customComponents: qwik._fnSignal((p0) => p0.customComponents, [
3619
+ props
3620
+ ], "p0.customComponents"),
3621
+ classNameProp: qwik._fnSignal((p0) => `variant-${p0.content?.id}`, [
3622
+ props
3623
+ ], "`variant-${p0.content?.id}`"),
3624
+ parentContentId: qwik._fnSignal((p0) => p0.content?.id, [
3625
+ props
3626
+ ], "p0.content?.id"),
3627
+ isSsrAbTest: qwik._fnSignal((p0) => p0.shouldRenderVariants, [
3307
3628
  state
3308
- ], "p0.useContent?.data?.blocks")
3629
+ ], "p0.shouldRenderVariants")
3309
3630
  }
3310
- }, 3, state.forceReRenderCount)
3311
- ], 1, "03_1") : null
3312
- }, 1, "03_2");
3313
- }, "RenderContent_component_hEAI0ahViXM"));
3631
+ }, 3, "Bz_2")
3632
+ ]
3633
+ }, 1, "Bz_3");
3634
+ }, "RenderContentVariants_component_OMvvre8Ofjw"));
3314
3635
  const settings = {};
3315
3636
  function setEditorSettings(newSettings) {
3316
3637
  if (isBrowser()) {
@@ -3327,22 +3648,18 @@ exports.Columns = Columns;
3327
3648
  exports.Fragment = FragmentComponent;
3328
3649
  exports.Image = Image;
3329
3650
  exports.RenderBlocks = RenderBlocks;
3330
- exports.RenderContent = RenderContent;
3651
+ exports.RenderContent = RenderContentVariants;
3331
3652
  exports.Section = SectionComponent;
3332
3653
  exports.Symbol = Symbol$1;
3333
3654
  exports.Text = Text;
3334
3655
  exports.Video = Video;
3335
- exports.components = components;
3336
- exports.convertSearchParamsToQueryObject = convertSearchParamsToQueryObject;
3337
3656
  exports.createRegisterComponentMessage = createRegisterComponentMessage;
3338
3657
  exports.getAllContent = getAllContent;
3339
3658
  exports.getBuilderSearchParams = getBuilderSearchParams;
3340
- exports.getBuilderSearchParamsFromWindow = getBuilderSearchParamsFromWindow;
3341
3659
  exports.getContent = getContent;
3342
3660
  exports.isEditing = isEditing;
3343
3661
  exports.isPreviewing = isPreviewing;
3344
- exports.normalizeSearchParams = normalizeSearchParams;
3662
+ exports.processContentResult = processContentResult;
3345
3663
  exports.register = register;
3346
- exports.registerComponent = registerComponent;
3347
3664
  exports.setEditorSettings = setEditorSettings;
3348
3665
  exports.track = track;