@builder.io/sdk-solid 4.0.8 → 4.0.10

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.
package/lib/node/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { delegateEvents, createComponent, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic, memo } from 'solid-js/web';
1
+ import { delegateEvents, createComponent, memo, spread, mergeProps, insert, effect, setAttribute, className, style, template, use, Dynamic } from 'solid-js/web';
2
2
  import { createContext, useContext, Show, For, createMemo, onMount, createSignal, createEffect, on } from 'solid-js';
3
3
  import { createRequire } from 'node:module';
4
4
 
@@ -1828,7 +1828,7 @@ function Block(props) {
1828
1828
  });
1829
1829
  }
1830
1830
  var block_default = Block;
1831
- var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-023c60f2 {
1831
+ var _tmpl$2 = /* @__PURE__ */ template(`<style>.dynamic-450facf4 {
1832
1832
  display: flex;
1833
1833
  flex-direction: column;
1834
1834
  align-items: stretch;
@@ -1877,7 +1877,7 @@ function BlocksWrapper(props) {
1877
1877
  createEffect(on(() => [onUpdateFn_0_props_blocks()], onUpdateFn_0));
1878
1878
  return [createComponent(Dynamic, mergeProps({
1879
1879
  get ["class"]() {
1880
- return className() + " dynamic-023c60f2";
1880
+ return className() + " dynamic-450facf4";
1881
1881
  },
1882
1882
  ref(r$) {
1883
1883
  const _ref$ = blocksWrapperRef;
@@ -1924,17 +1924,17 @@ function Blocks(props) {
1924
1924
  get styleProp() {
1925
1925
  return props.styleProp;
1926
1926
  },
1927
+ get BlocksWrapperProps() {
1928
+ return props.BlocksWrapperProps || props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
1929
+ },
1927
1930
  get classNameProp() {
1928
1931
  return props.className;
1929
1932
  },
1930
1933
  get BlocksWrapper() {
1931
1934
  return props.context?.BlocksWrapper || builderContext?.BlocksWrapper;
1932
1935
  },
1933
- get BlocksWrapperProps() {
1934
- return props.context?.BlocksWrapperProps || builderContext?.BlocksWrapperProps;
1935
- },
1936
1936
  get children() {
1937
- return createComponent(Show, {
1937
+ return [memo(() => props.children), createComponent(Show, {
1938
1938
  get when() {
1939
1939
  return props.blocks;
1940
1940
  },
@@ -1963,7 +1963,7 @@ function Blocks(props) {
1963
1963
  }
1964
1964
  });
1965
1965
  }
1966
- });
1966
+ })];
1967
1967
  }
1968
1968
  });
1969
1969
  }
@@ -2387,6 +2387,166 @@ function SectionComponent(props) {
2387
2387
  }
2388
2388
  var section_default = SectionComponent;
2389
2389
 
2390
+ // src/blocks/personalization-container/helpers/inlined-fns.ts
2391
+ function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
2392
+ function isString(val) {
2393
+ return typeof val === "string";
2394
+ }
2395
+ function isNumber(val) {
2396
+ return typeof val === "number";
2397
+ }
2398
+ function objectMatchesQuery(userattr, query2) {
2399
+ const result = (() => {
2400
+ const property = query2.property;
2401
+ const operator = query2.operator;
2402
+ let testValue = query2.value;
2403
+ if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
2404
+ testValue = query2.value.slice(0, -1);
2405
+ }
2406
+ if (!(property && operator)) {
2407
+ return true;
2408
+ }
2409
+ if (Array.isArray(testValue)) {
2410
+ if (operator === "isNot") {
2411
+ return testValue.every((val) => objectMatchesQuery(userattr, {
2412
+ property,
2413
+ operator,
2414
+ value: val
2415
+ }));
2416
+ }
2417
+ return !!testValue.find((val) => objectMatchesQuery(userattr, {
2418
+ property,
2419
+ operator,
2420
+ value: val
2421
+ }));
2422
+ }
2423
+ const value = userattr[property];
2424
+ if (Array.isArray(value)) {
2425
+ return value.includes(testValue);
2426
+ }
2427
+ switch (operator) {
2428
+ case "is":
2429
+ return value === testValue;
2430
+ case "isNot":
2431
+ return value !== testValue;
2432
+ case "contains":
2433
+ return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
2434
+ case "startsWith":
2435
+ return isString(value) && value.startsWith(String(testValue));
2436
+ case "endsWith":
2437
+ return isString(value) && value.endsWith(String(testValue));
2438
+ case "greaterThan":
2439
+ return isNumber(value) && isNumber(testValue) && value > testValue;
2440
+ case "lessThan":
2441
+ return isNumber(value) && isNumber(testValue) && value < testValue;
2442
+ case "greaterThanOrEqualTo":
2443
+ return isNumber(value) && isNumber(testValue) && value >= testValue;
2444
+ case "lessThanOrEqualTo":
2445
+ return isNumber(value) && isNumber(testValue) && value <= testValue;
2446
+ default:
2447
+ return false;
2448
+ }
2449
+ })();
2450
+ return result;
2451
+ }
2452
+ const item = {
2453
+ query,
2454
+ startDate,
2455
+ endDate
2456
+ };
2457
+ const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
2458
+ if (item.startDate && new Date(item.startDate) > now) {
2459
+ return false;
2460
+ } else if (item.endDate && new Date(item.endDate) < now) {
2461
+ return false;
2462
+ }
2463
+ if (!item.query || !item.query.length) {
2464
+ return true;
2465
+ }
2466
+ return item.query.every((filter) => {
2467
+ return objectMatchesQuery(userAttributes, filter);
2468
+ });
2469
+ }
2470
+ var PERSONALIZATION_SCRIPT = "function getPersonalizedVariant(variants, blockId, isHydrationTarget, locale) {\n if (!navigator.cookieEnabled) {\n return;\n }\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) == ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return window.filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n const parentDiv = document.currentScript?.parentElement;\n const variantId = parentDiv?.getAttribute('data-variant-id');\n const isDefaultVariant = variantId === `${blockId}-default`;\n const isWinningVariant = winningVariantIndex !== -1 && variantId === `${blockId}-${winningVariantIndex}` || winningVariantIndex === -1 && isDefaultVariant;\n if (isWinningVariant && !isDefaultVariant) {\n parentDiv?.removeAttribute('hidden');\n parentDiv?.removeAttribute('aria-hidden');\n } else if (!isWinningVariant && isDefaultVariant) {\n parentDiv?.setAttribute('hidden', 'true');\n parentDiv?.setAttribute('aria-hidden', 'true');\n }\n if (isHydrationTarget) {\n if (!isWinningVariant) {\n const itsStyleEl = parentDiv?.previousElementSibling;\n if (itsStyleEl) {\n itsStyleEl.remove();\n }\n parentDiv?.remove();\n }\n const thisScript = document.currentScript;\n if (thisScript) {\n thisScript.remove();\n }\n }\n}";
2471
+ var FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
2472
+ var UPDATE_VISIBILITY_STYLES_SCRIPT = "function updateVisibilityStylesScript(variants, blockId, isHydrationTarget, locale) {\n function getCookie(name) {\n const nameEQ = name + '=';\n const ca = document.cookie.split(';');\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n while (c.charAt(0) == ' ') c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);\n }\n return null;\n }\n const visibilityStylesEl = document.currentScript?.previousElementSibling;\n if (!visibilityStylesEl) {\n return;\n }\n if (isHydrationTarget) {\n visibilityStylesEl.remove();\n const currentScript = document.currentScript;\n if (currentScript) {\n currentScript.remove();\n }\n } else {\n const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');\n if (locale) {\n attributes.locale = locale;\n }\n const winningVariantIndex = variants?.findIndex(function (variant) {\n return window.filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);\n });\n if (winningVariantIndex !== -1) {\n let newStyleStr = variants?.map((_, index) => {\n if (index === winningVariantIndex) return '';\n return `div[data-variant-id=\"${blockId}-${index}\"] { display: none !important; } `;\n }).join('') || '';\n newStyleStr += `div[data-variant-id=\"${blockId}-default\"] { display: none !important; } `;\n visibilityStylesEl.innerHTML = newStyleStr;\n }\n }\n}";
2473
+
2474
+ // src/blocks/personalization-container/helpers.ts
2475
+ var DEFAULT_INDEX = "default";
2476
+ var FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME = "filterWithCustomTargeting";
2477
+ var BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME = "builderIoPersonalization";
2478
+ var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "updateVisibilityStylesScript";
2479
+ var SDKS_SUPPORTING_PERSONALIZATION = ["react", "vue", "svelte", "qwik"];
2480
+ var SDKS_REQUIRING_RESET_APPROACH = ["vue", "svelte", "qwik"];
2481
+ function checkShouldRenderVariants(variants, canTrack) {
2482
+ const hasVariants = variants && variants.length > 0;
2483
+ if (TARGET === "reactNative")
2484
+ return false;
2485
+ if (!hasVariants)
2486
+ return false;
2487
+ if (!canTrack)
2488
+ return false;
2489
+ if (SDKS_REQUIRING_RESET_APPROACH.includes(TARGET))
2490
+ return true;
2491
+ if (isBrowser())
2492
+ return false;
2493
+ return true;
2494
+ }
2495
+ function getBlocksToRender({
2496
+ variants,
2497
+ previewingIndex,
2498
+ isHydrated,
2499
+ filteredVariants,
2500
+ fallbackBlocks
2501
+ }) {
2502
+ const fallback = {
2503
+ blocks: fallbackBlocks ?? [],
2504
+ path: "this.children",
2505
+ index: DEFAULT_INDEX
2506
+ };
2507
+ if (isHydrated && isEditing()) {
2508
+ if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
2509
+ const variant = variants?.[previewingIndex];
2510
+ if (variant) {
2511
+ return {
2512
+ blocks: variant.blocks,
2513
+ path: `variants.${previewingIndex}.blocks`,
2514
+ index: previewingIndex
2515
+ };
2516
+ }
2517
+ }
2518
+ return fallback;
2519
+ }
2520
+ if (isBrowser()) {
2521
+ const winningVariant = filteredVariants?.[0];
2522
+ if (winningVariant && variants) {
2523
+ const variantIndex = variants.indexOf(winningVariant);
2524
+ if (variantIndex !== -1) {
2525
+ return {
2526
+ blocks: winningVariant.blocks,
2527
+ path: `variants.${variantIndex}.blocks`,
2528
+ index: variantIndex
2529
+ };
2530
+ }
2531
+ }
2532
+ }
2533
+ return fallback;
2534
+ }
2535
+ var getInitPersonalizationVariantsFnsScriptString = () => {
2536
+ return `
2537
+ window.${FILTER_WITH_CUSTOM_TARGETING_SCRIPT_FN_NAME} = ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
2538
+ window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME} = ${PERSONALIZATION_SCRIPT}
2539
+ window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VISIBILITY_STYLES_SCRIPT}
2540
+ `;
2541
+ };
2542
+ var isHydrationTarget = TARGET === "react";
2543
+ var getPersonalizationScript = (variants, blockId, locale) => {
2544
+ return `window.${BUILDER_IO_PERSONALIZATION_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
2545
+ };
2546
+ var getUpdateVisibilityStylesScript = (variants, blockId, locale) => {
2547
+ return `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(${JSON.stringify(variants)}, "${blockId}", ${isHydrationTarget}${locale ? `, "${locale}"` : ""})`;
2548
+ };
2549
+
2390
2550
  // src/helpers/url.ts
2391
2551
  var getTopLevelDomain = (host) => {
2392
2552
  if (host === "localhost" || host === "127.0.0.1") {
@@ -2575,6 +2735,11 @@ var handleABTesting = async ({
2575
2735
  };
2576
2736
  };
2577
2737
 
2738
+ // src/helpers/no-serialize-wrapper.ts
2739
+ function noSerializeWrapper(fn) {
2740
+ return fn;
2741
+ }
2742
+
2578
2743
  // src/helpers/user-attributes.ts
2579
2744
  var USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
2580
2745
  function createUserAttributesService() {
@@ -2605,18 +2770,32 @@ function createUserAttributesService() {
2605
2770
  canTrack
2606
2771
  }) || "{}");
2607
2772
  },
2608
- subscribeOnUserAttributesChange(callback) {
2773
+ subscribeOnUserAttributesChange(callback, {
2774
+ fireImmediately
2775
+ } = {}) {
2609
2776
  subscribers.add(callback);
2610
- return () => {
2777
+ if (fireImmediately) {
2778
+ callback(this.getUserAttributes());
2779
+ }
2780
+ return noSerializeWrapper(function() {
2611
2781
  subscribers.delete(callback);
2612
- };
2782
+ });
2613
2783
  },
2614
2784
  setCanTrack(value) {
2615
2785
  canTrack = value;
2616
2786
  }
2617
2787
  };
2618
2788
  }
2619
- var userAttributesService = createUserAttributesService();
2789
+ var _userAttributesService;
2790
+ if (isBrowser() && TARGET === "qwik") {
2791
+ if (!window.__BUILDER_USER_ATTRIBUTES_SERVICE__) {
2792
+ window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = createUserAttributesService();
2793
+ }
2794
+ _userAttributesService = window.__BUILDER_USER_ATTRIBUTES_SERVICE__;
2795
+ } else {
2796
+ _userAttributesService = createUserAttributesService();
2797
+ }
2798
+ var userAttributesService = _userAttributesService;
2620
2799
  var setClientUserAttributes = (attributes) => {
2621
2800
  userAttributesService.setUserAttributes(attributes);
2622
2801
  };
@@ -3365,7 +3544,8 @@ var componentInfo6 = {
3365
3544
  name: "PersonalizationContainer",
3366
3545
  shouldReceiveBuilderProps: {
3367
3546
  builderBlock: true,
3368
- builderContext: true
3547
+ builderContext: true,
3548
+ builderComponents: true
3369
3549
  },
3370
3550
  noWrap: true,
3371
3551
  image: "https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",
@@ -3427,208 +3607,22 @@ function isPreviewing(_search) {
3427
3607
  return Boolean(normalizedSearch.indexOf("builder.preview=") !== -1);
3428
3608
  }
3429
3609
 
3430
- // src/blocks/personalization-container/helpers/inlined-fns.ts
3431
- function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {
3432
- function isString(val) {
3433
- return typeof val === "string";
3434
- }
3435
- function isNumber(val) {
3436
- return typeof val === "number";
3437
- }
3438
- function objectMatchesQuery(userattr, query2) {
3439
- const result = (() => {
3440
- const property = query2.property;
3441
- const operator = query2.operator;
3442
- let testValue = query2.value;
3443
- if (query2 && query2.property === "urlPath" && query2.value && typeof query2.value === "string" && query2.value !== "/" && query2.value.endsWith("/")) {
3444
- testValue = query2.value.slice(0, -1);
3445
- }
3446
- if (!(property && operator)) {
3447
- return true;
3448
- }
3449
- if (Array.isArray(testValue)) {
3450
- if (operator === "isNot") {
3451
- return testValue.every((val) => objectMatchesQuery(userattr, {
3452
- property,
3453
- operator,
3454
- value: val
3455
- }));
3456
- }
3457
- return !!testValue.find((val) => objectMatchesQuery(userattr, {
3458
- property,
3459
- operator,
3460
- value: val
3461
- }));
3462
- }
3463
- const value = userattr[property];
3464
- if (Array.isArray(value)) {
3465
- return value.includes(testValue);
3466
- }
3467
- switch (operator) {
3468
- case "is":
3469
- return value === testValue;
3470
- case "isNot":
3471
- return value !== testValue;
3472
- case "contains":
3473
- return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));
3474
- case "startsWith":
3475
- return isString(value) && value.startsWith(String(testValue));
3476
- case "endsWith":
3477
- return isString(value) && value.endsWith(String(testValue));
3478
- case "greaterThan":
3479
- return isNumber(value) && isNumber(testValue) && value > testValue;
3480
- case "lessThan":
3481
- return isNumber(value) && isNumber(testValue) && value < testValue;
3482
- case "greaterThanOrEqualTo":
3483
- return isNumber(value) && isNumber(testValue) && value >= testValue;
3484
- case "lessThanOrEqualTo":
3485
- return isNumber(value) && isNumber(testValue) && value <= testValue;
3486
- default:
3487
- return false;
3488
- }
3489
- })();
3490
- return result;
3491
- }
3492
- const item = {
3493
- query,
3494
- startDate,
3495
- endDate
3496
- };
3497
- const now = userAttributes.date && new Date(userAttributes.date) || /* @__PURE__ */ new Date();
3498
- if (item.startDate && new Date(item.startDate) > now) {
3499
- return false;
3500
- } else if (item.endDate && new Date(item.endDate) < now) {
3501
- return false;
3502
- }
3503
- if (!item.query || !item.query.length) {
3504
- return true;
3505
- }
3506
- return item.query.every((filter) => {
3507
- return objectMatchesQuery(userAttributes, filter);
3508
- });
3509
- }
3510
- var PERSONALIZATION_SCRIPT = `function getPersonalizedVariant(variants, blockId, locale) {
3511
- if (!navigator.cookieEnabled) {
3512
- return;
3513
- }
3514
- function getCookie(name) {
3515
- const nameEQ = name + '=';
3516
- const ca = document.cookie.split(';');
3517
- for (let i = 0; i < ca.length; i++) {
3518
- let c = ca[i];
3519
- while (c.charAt(0) == ' ') c = c.substring(1, c.length);
3520
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
3521
- }
3522
- return null;
3523
- }
3524
- function removeVariants() {
3525
- variants?.forEach(function (_, index) {
3526
- document.querySelector('template[data-variant-id="' + blockId + '-' + index + '"]')?.remove();
3527
- });
3528
- document.querySelector('script[data-id="variants-script-' + blockId + '"]')?.remove();
3529
- document.querySelector('style[data-id="variants-styles-' + blockId + '"]')?.remove();
3530
- }
3531
- const attributes = JSON.parse(getCookie('builder.userAttributes') || '{}');
3532
- if (locale) {
3533
- attributes.locale = locale;
3534
- }
3535
- const winningVariantIndex = variants?.findIndex(function (variant) {
3536
- return filterWithCustomTargeting(attributes, variant.query, variant.startDate, variant.endDate);
3537
- });
3538
- const isDebug = location.href.includes('builder.debug=true');
3539
- if (isDebug) {
3540
- console.debug('PersonalizationContainer', {
3541
- attributes,
3542
- variants,
3543
- winningVariantIndex
3544
- });
3545
- }
3546
- if (winningVariantIndex !== -1) {
3547
- const winningVariant = document.querySelector('template[data-variant-id="' + blockId + '-' + winningVariantIndex + '"]');
3548
- if (winningVariant) {
3549
- const parentNode = winningVariant.parentNode;
3550
- if (parentNode) {
3551
- const newParent = parentNode.cloneNode(false);
3552
- newParent.appendChild(winningVariant.content.firstChild);
3553
- newParent.appendChild(winningVariant.content.lastChild);
3554
- parentNode.parentNode?.replaceChild(newParent, parentNode);
3555
- }
3556
- if (isDebug) {
3557
- console.debug('PersonalizationContainer', 'Winning variant Replaced:', winningVariant);
3558
- }
3559
- }
3560
- } else if (variants && variants.length > 0) {
3561
- removeVariants();
3562
- }
3563
- }`;
3564
- var FILTER_WITH_CUSTOM_TARGETING_SCRIPT = "function filterWithCustomTargeting(userAttributes, query, startDate, endDate) {\n function isString(val) {\n return typeof val === 'string';\n }\n function isNumber(val) {\n return typeof val === 'number';\n }\n function objectMatchesQuery(userattr, query) {\n const result = (() => {\n const property = query.property;\n const operator = query.operator;\n let testValue = query.value;\n if (query && query.property === 'urlPath' && query.value && typeof query.value === 'string' && query.value !== '/' && query.value.endsWith('/')) {\n testValue = query.value.slice(0, -1);\n }\n if (!(property && operator)) {\n return true;\n }\n if (Array.isArray(testValue)) {\n if (operator === 'isNot') {\n return testValue.every(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n return !!testValue.find(val => objectMatchesQuery(userattr, {\n property,\n operator,\n value: val\n }));\n }\n const value = userattr[property];\n if (Array.isArray(value)) {\n return value.includes(testValue);\n }\n switch (operator) {\n case 'is':\n return value === testValue;\n case 'isNot':\n return value !== testValue;\n case 'contains':\n return (isString(value) || Array.isArray(value)) && value.includes(String(testValue));\n case 'startsWith':\n return isString(value) && value.startsWith(String(testValue));\n case 'endsWith':\n return isString(value) && value.endsWith(String(testValue));\n case 'greaterThan':\n return isNumber(value) && isNumber(testValue) && value > testValue;\n case 'lessThan':\n return isNumber(value) && isNumber(testValue) && value < testValue;\n case 'greaterThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value >= testValue;\n case 'lessThanOrEqualTo':\n return isNumber(value) && isNumber(testValue) && value <= testValue;\n default:\n return false;\n }\n })();\n return result;\n }\n const item = {\n query,\n startDate,\n endDate\n };\n const now = userAttributes.date && new Date(userAttributes.date) || new Date();\n if (item.startDate && new Date(item.startDate) > now) {\n return false;\n } else if (item.endDate && new Date(item.endDate) < now) {\n return false;\n }\n if (!item.query || !item.query.length) {\n return true;\n }\n return item.query.every(filter => {\n return objectMatchesQuery(userAttributes, filter);\n });\n}";
3565
-
3566
- // src/blocks/personalization-container/helpers.ts
3567
- function checkShouldRenderVariants(variants, canTrack) {
3568
- const hasVariants = variants && variants.length > 0;
3569
- if (TARGET === "reactNative")
3570
- return false;
3571
- if (!hasVariants)
3572
- return false;
3573
- if (!canTrack)
3574
- return false;
3575
- if (TARGET === "vue" || TARGET === "svelte")
3576
- return true;
3577
- if (isBrowser())
3578
- return false;
3579
- return true;
3580
- }
3581
- function getBlocksToRender({
3582
- variants,
3583
- previewingIndex,
3584
- isHydrated,
3585
- filteredVariants,
3586
- fallbackBlocks
3587
- }) {
3588
- const fallback = {
3589
- blocks: fallbackBlocks ?? [],
3590
- path: "this.children"
3591
- };
3592
- if (isHydrated && isEditing()) {
3593
- if (typeof previewingIndex === "number" && previewingIndex < (variants?.length ?? 0)) {
3594
- const variant = variants[previewingIndex];
3595
- return {
3596
- blocks: variant.blocks,
3597
- path: `component.options.variants.${previewingIndex}.blocks`
3598
- };
3599
- }
3600
- return fallback;
3601
- }
3602
- if (isBrowser()) {
3603
- const winningVariant = filteredVariants?.[0];
3604
- if (winningVariant) {
3605
- return {
3606
- blocks: winningVariant.blocks,
3607
- path: `component.options.variants.${variants?.indexOf(winningVariant)}.blocks`
3608
- };
3609
- }
3610
- }
3611
- return fallback;
3612
- }
3613
- var getPersonalizationScript = (variants, blockId, locale) => {
3614
- return `
3615
- (function() {
3616
- ${FILTER_WITH_CUSTOM_TARGETING_SCRIPT}
3617
- ${PERSONALIZATION_SCRIPT}
3618
- getPersonalizedVariant(${JSON.stringify(variants)}, "${blockId}"${locale ? `, "${locale}"` : ""})
3619
- })();
3620
- `;
3621
- };
3622
-
3623
3610
  // src/blocks/personalization-container/personalization-container.tsx
3624
3611
  var _tmpl$9 = /* @__PURE__ */ template(`<div>`);
3625
- var _tmpl$25 = /* @__PURE__ */ template(`<template>`);
3626
3612
  function PersonalizationContainer(props) {
3627
3613
  const [userAttributes, setUserAttributes] = createSignal(userAttributesService.getUserAttributes());
3628
3614
  const [scriptStr, setScriptStr] = createSignal(getPersonalizationScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
3615
+ const [updateVisibilityStylesScript, setUpdateVisibilityStylesScript] = createSignal(getUpdateVisibilityStylesScript(props.variants, props.builderBlock?.id || "none", props.builderContext?.rootState?.locale));
3629
3616
  const [unsubscribers, setUnsubscribers] = createSignal([]);
3630
3617
  const [shouldRenderVariants, setShouldRenderVariants] = createSignal(checkShouldRenderVariants(props.variants, getDefaultCanTrack(props.builderContext?.canTrack)));
3631
- const [isHydrated, setIsHydrated] = createSignal(false);
3618
+ const [shouldResetVariants, setShouldResetVariants] = createSignal(false);
3619
+ const attrs = createMemo(() => {
3620
+ return {
3621
+ ...props.attributes,
3622
+ ...{},
3623
+ [getClassPropName()]: `builder-personalization-container ${props.attributes[getClassPropName()] || ""}`
3624
+ };
3625
+ });
3632
3626
  const filteredVariants = createMemo(() => {
3633
3627
  return (props.variants || []).filter((variant) => {
3634
3628
  return filterWithCustomTargeting({
@@ -3643,26 +3637,28 @@ function PersonalizationContainer(props) {
3643
3637
  return getBlocksToRender({
3644
3638
  variants: props.variants,
3645
3639
  fallbackBlocks: props.builderBlock?.children,
3646
- isHydrated: isHydrated(),
3640
+ isHydrated: shouldResetVariants(),
3647
3641
  filteredVariants: filteredVariants(),
3648
3642
  previewingIndex: props.previewingIndex
3649
3643
  });
3650
3644
  });
3651
3645
  const hideVariantsStyleString = createMemo(() => {
3652
- return (props.variants || []).map((_, index) => `[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none; } `).join("");
3646
+ return (props.variants || []).map((_, index) => `div[data-variant-id="${props.builderBlock?.id}-${index}"] { display: none !important; } `).join("");
3653
3647
  });
3654
3648
  let rootRef;
3655
3649
  onMount(() => {
3656
- setIsHydrated(true);
3657
- const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs) => {
3658
- setUserAttributes(attrs);
3650
+ setShouldResetVariants(true);
3651
+ const unsub = userAttributesService.subscribeOnUserAttributesChange((attrs2) => {
3652
+ setUserAttributes(attrs2);
3653
+ }, {
3654
+ fireImmediately: TARGET === "qwik"
3659
3655
  });
3660
3656
  if (!(isEditing() || isPreviewing())) {
3661
3657
  const variant = filteredVariants()[0];
3662
3658
  if (rootRef) {
3663
3659
  rootRef.dispatchEvent(new CustomEvent("builder.variantLoaded", {
3664
3660
  detail: {
3665
- variant: variant || "default",
3661
+ variant: variant || DEFAULT_INDEX,
3666
3662
  content: props.builderContext?.content
3667
3663
  },
3668
3664
  bubbles: true
@@ -3672,7 +3668,7 @@ function PersonalizationContainer(props) {
3672
3668
  if (entry.isIntersecting && rootRef) {
3673
3669
  rootRef.dispatchEvent(new CustomEvent("builder.variantDisplayed", {
3674
3670
  detail: {
3675
- variant: variant || "default",
3671
+ variant: variant || DEFAULT_INDEX,
3676
3672
  content: props.builderContext?.content
3677
3673
  },
3678
3674
  bubbles: true
@@ -3689,70 +3685,158 @@ function PersonalizationContainer(props) {
3689
3685
  const _el$ = _tmpl$9();
3690
3686
  const _ref$ = rootRef;
3691
3687
  typeof _ref$ === "function" ? use(_ref$, _el$) : rootRef = _el$;
3692
- spread(_el$, mergeProps({
3693
- get ["class"]() {
3694
- return `builder-personalization-container ${props.attributes?.className || ""}`;
3695
- }
3696
- }, () => props.attributes), false, true);
3688
+ spread(_el$, mergeProps(attrs), false, true);
3697
3689
  insert(_el$, createComponent(Show, {
3698
3690
  get when() {
3699
- return shouldRenderVariants();
3691
+ return memo(() => !!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
3700
3692
  },
3701
3693
  get children() {
3702
- return [createComponent(For, {
3703
- get each() {
3704
- return props.variants;
3694
+ return createComponent(blocks_default, {
3695
+ get blocks() {
3696
+ return blocksToRender().blocks;
3705
3697
  },
3706
- children: (variant, _index) => {
3707
- const index = _index();
3708
- return (() => {
3709
- const _el$2 = _tmpl$25();
3710
- setAttribute(_el$2, "key", index);
3711
- insert(_el$2, createComponent(blocks_default, {
3712
- get blocks() {
3713
- return variant.blocks;
3714
- },
3715
- get parent() {
3716
- return props.builderBlock?.id;
3717
- },
3718
- path: `component.options.variants.${index}.blocks`
3719
- }));
3720
- effect(() => setAttribute(_el$2, "data-variant-id", `${props.builderBlock?.id}-${index}`));
3721
- return _el$2;
3722
- })();
3723
- }
3724
- }), createComponent(inlined_styles_default, {
3725
- get nonce() {
3726
- return props.builderContext?.nonce || "";
3698
+ get parent() {
3699
+ return props.builderBlock?.id;
3727
3700
  },
3728
- get styles() {
3729
- return hideVariantsStyleString();
3701
+ get path() {
3702
+ return blocksToRender().path;
3730
3703
  },
3731
- get id() {
3732
- return `variants-styles-${props.builderBlock?.id}`;
3733
- }
3734
- }), createComponent(inlined_script_default, {
3735
- get nonce() {
3736
- return props.builderContext?.nonce || "";
3704
+ get context() {
3705
+ return props.builderContext;
3737
3706
  },
3738
- get scriptStr() {
3739
- return scriptStr();
3707
+ get registeredComponents() {
3708
+ return props.builderComponents;
3740
3709
  },
3741
- get id() {
3742
- return `variants-script-${props.builderBlock?.id}`;
3710
+ get BlocksWrapperProps() {
3711
+ return {
3712
+ ...props.builderContext?.BlocksWrapperProps,
3713
+ "data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
3714
+ };
3743
3715
  }
3744
- })];
3716
+ });
3745
3717
  }
3746
3718
  }), null);
3747
- insert(_el$, createComponent(blocks_default, {
3748
- get blocks() {
3749
- return blocksToRender().blocks;
3750
- },
3751
- get parent() {
3752
- return props.builderBlock?.id;
3719
+ insert(_el$, createComponent(Show, {
3720
+ get when() {
3721
+ return memo(() => !!!shouldResetVariants())() && SDKS_REQUIRING_RESET_APPROACH.includes(TARGET) || !SDKS_REQUIRING_RESET_APPROACH.includes(TARGET);
3753
3722
  },
3754
- get path() {
3755
- return blocksToRender().path;
3723
+ get children() {
3724
+ return [createComponent(Show, {
3725
+ get when() {
3726
+ return shouldRenderVariants();
3727
+ },
3728
+ get children() {
3729
+ return [createComponent(inlined_styles_default, {
3730
+ get nonce() {
3731
+ return props.builderContext?.nonce || "";
3732
+ },
3733
+ get styles() {
3734
+ return hideVariantsStyleString();
3735
+ },
3736
+ get id() {
3737
+ return `variants-styles-${props.builderBlock?.id}`;
3738
+ }
3739
+ }), createComponent(inlined_script_default, {
3740
+ get nonce() {
3741
+ return props.builderContext?.nonce || "";
3742
+ },
3743
+ get scriptStr() {
3744
+ return updateVisibilityStylesScript();
3745
+ },
3746
+ get id() {
3747
+ return `variants-visibility-script-${props.builderBlock?.id}`;
3748
+ }
3749
+ }), createComponent(For, {
3750
+ get each() {
3751
+ return props.variants;
3752
+ },
3753
+ children: (variant, _index) => {
3754
+ const index = _index();
3755
+ return createComponent(blocks_default, {
3756
+ get key() {
3757
+ return `${props.builderBlock?.id}-${index}`;
3758
+ },
3759
+ get BlocksWrapperProps() {
3760
+ return {
3761
+ ...props.builderContext?.BlocksWrapperProps,
3762
+ "aria-hidden": true,
3763
+ hidden: true,
3764
+ "data-variant-id": `${props.builderBlock?.id}-${index}`
3765
+ };
3766
+ },
3767
+ get blocks() {
3768
+ return variant.blocks;
3769
+ },
3770
+ get parent() {
3771
+ return props.builderBlock?.id;
3772
+ },
3773
+ path: `component.options.variants.${index}.blocks`,
3774
+ get context() {
3775
+ return props.builderContext;
3776
+ },
3777
+ get registeredComponents() {
3778
+ return props.builderComponents;
3779
+ },
3780
+ get children() {
3781
+ return createComponent(inlined_script_default, {
3782
+ get nonce() {
3783
+ return props.builderContext?.nonce || "";
3784
+ },
3785
+ get scriptStr() {
3786
+ return scriptStr();
3787
+ },
3788
+ get id() {
3789
+ return `variants-script-${props.builderBlock?.id}-${index}`;
3790
+ }
3791
+ });
3792
+ }
3793
+ });
3794
+ }
3795
+ })];
3796
+ }
3797
+ }), createComponent(blocks_default, {
3798
+ get blocks() {
3799
+ return blocksToRender().blocks;
3800
+ },
3801
+ get parent() {
3802
+ return props.builderBlock?.id;
3803
+ },
3804
+ get path() {
3805
+ return blocksToRender().path;
3806
+ },
3807
+ get context() {
3808
+ return props.builderContext;
3809
+ },
3810
+ get registeredComponents() {
3811
+ return props.builderComponents;
3812
+ },
3813
+ get BlocksWrapperProps() {
3814
+ return {
3815
+ ...props.builderContext?.BlocksWrapperProps,
3816
+ "data-variant-id": `${props.builderBlock?.id}-${blocksToRender().index}`
3817
+ };
3818
+ },
3819
+ get children() {
3820
+ return createComponent(Show, {
3821
+ get when() {
3822
+ return shouldRenderVariants();
3823
+ },
3824
+ get children() {
3825
+ return createComponent(inlined_script_default, {
3826
+ get nonce() {
3827
+ return props.builderContext?.nonce || "";
3828
+ },
3829
+ get scriptStr() {
3830
+ return scriptStr();
3831
+ },
3832
+ get id() {
3833
+ return `variants-script-${props.builderBlock?.id}-${DEFAULT_INDEX}`;
3834
+ }
3835
+ });
3836
+ }
3837
+ });
3838
+ }
3839
+ })];
3756
3840
  }
3757
3841
  }), null);
3758
3842
  return _el$;
@@ -4039,7 +4123,7 @@ var componentInfo10 = {
4039
4123
  }
4040
4124
  };
4041
4125
  var _tmpl$11 = /* @__PURE__ */ template(`<div>`);
4042
- var _tmpl$26 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
4126
+ var _tmpl$25 = /* @__PURE__ */ template(`<div><div class=builder-tabs-wrap>`);
4043
4127
  var _tmpl$33 = /* @__PURE__ */ template(`<span>`);
4044
4128
  function Tabs(props) {
4045
4129
  const [activeTab, setActiveTab] = createSignal(props.defaultActiveTab ? props.defaultActiveTab - 1 : 0);
@@ -4054,7 +4138,7 @@ function Tabs(props) {
4054
4138
  }
4055
4139
  }
4056
4140
  return (() => {
4057
- const _el$ = _tmpl$26(), _el$2 = _el$.firstChild;
4141
+ const _el$ = _tmpl$25(), _el$2 = _el$.firstChild;
4058
4142
  _el$2.style.setProperty("display", "flex");
4059
4143
  _el$2.style.setProperty("flex-direction", "row");
4060
4144
  _el$2.style.setProperty("overflow", "auto");
@@ -4585,9 +4669,9 @@ function logFetch(url) {
4585
4669
  }
4586
4670
 
4587
4671
  // src/blocks/form/form/form.tsx
4588
- var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-04a43b72">`);
4589
- var _tmpl$27 = /* @__PURE__ */ template(`<form>`);
4590
- var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-04a43b72 {
4672
+ var _tmpl$15 = /* @__PURE__ */ template(`<pre class="builder-form-error-text pre-7430044e">`);
4673
+ var _tmpl$26 = /* @__PURE__ */ template(`<form>`);
4674
+ var _tmpl$34 = /* @__PURE__ */ template(`<style>.pre-7430044e {
4591
4675
  padding: 10px;
4592
4676
  color: red;
4593
4677
  text-align: center;
@@ -4699,6 +4783,14 @@ function FormComponent(props) {
4699
4783
  }
4700
4784
  }
4701
4785
  setFormState("sending");
4786
+ if (props.sendSubmissionsTo === "email" && (props.sendSubmissionsToEmail === "your@email.com" || !props.sendSubmissionsToEmail)) {
4787
+ const message = "SubmissionsToEmail is required when sendSubmissionsTo is set to email";
4788
+ setFormState("error");
4789
+ mergeNewRootState({
4790
+ formErrorMessage: message
4791
+ });
4792
+ return;
4793
+ }
4702
4794
  const formUrl = `${getEnv() === "dev" ? "http://localhost:5000" : "https://builder.io"}/api/v1/form-submit?apiKey=${props.builderContext.apiKey}&to=${btoa(props.sendSubmissionsToEmail || "")}&name=${encodeURIComponent(props.name || "")}`;
4703
4795
  const url = props.sendSubmissionsTo === "email" ? formUrl : props.action;
4704
4796
  logFetch(url);
@@ -4714,17 +4806,30 @@ function FormComponent(props) {
4714
4806
  } else {
4715
4807
  body2 = await res.text();
4716
4808
  }
4717
- if (!res.ok && props.errorMessagePath) {
4718
- let message = get(body2, props.errorMessagePath);
4719
- if (message) {
4720
- if (typeof message !== "string") {
4721
- message = JSON.stringify(message);
4809
+ if (!res.ok) {
4810
+ const submitErrorEvent = new CustomEvent("submit:error", {
4811
+ detail: {
4812
+ error: body2,
4813
+ status: res.status
4722
4814
  }
4723
- setFormErrorMessage(message);
4724
- mergeNewRootState({
4725
- formErrorMessage: message
4726
- });
4815
+ });
4816
+ if (formRef?.nativeElement) {
4817
+ formRef?.nativeElement.dispatchEvent(submitErrorEvent);
4818
+ if (submitErrorEvent.defaultPrevented) {
4819
+ return;
4820
+ }
4821
+ }
4822
+ setResponseData(body2);
4823
+ setFormState("error");
4824
+ let message = props.errorMessagePath ? get(body2, props.errorMessagePath) : body2.message || body2.error || body2;
4825
+ if (typeof message !== "string") {
4826
+ message = JSON.stringify(message);
4727
4827
  }
4828
+ setFormErrorMessage(message);
4829
+ mergeNewRootState({
4830
+ formErrorMessage: message
4831
+ });
4832
+ return;
4728
4833
  }
4729
4834
  setResponseData(body2);
4730
4835
  setFormState(res.ok ? "success" : "error");
@@ -4779,7 +4884,7 @@ function FormComponent(props) {
4779
4884
  }
4780
4885
  let formRef;
4781
4886
  return [(() => {
4782
- const _el$ = _tmpl$27();
4887
+ const _el$ = _tmpl$26();
4783
4888
  _el$.addEventListener("submit", (event) => onSubmit(event));
4784
4889
  const _ref$ = formRef;
4785
4890
  typeof _ref$ === "function" ? use(_ref$, _el$) : formRef = _el$;
@@ -4991,7 +5096,7 @@ var componentInfo16 = {
4991
5096
  noWrap: true
4992
5097
  };
4993
5098
  var _tmpl$17 = /* @__PURE__ */ template(`<select>`);
4994
- var _tmpl$28 = /* @__PURE__ */ template(`<option>`);
5099
+ var _tmpl$27 = /* @__PURE__ */ template(`<option>`);
4995
5100
  function SelectComponent(props) {
4996
5101
  return (() => {
4997
5102
  const _el$ = _tmpl$17();
@@ -5019,7 +5124,7 @@ function SelectComponent(props) {
5019
5124
  children: (option, _index) => {
5020
5125
  const index = _index();
5021
5126
  return (() => {
5022
- const _el$2 = _tmpl$28();
5127
+ const _el$2 = _tmpl$27();
5023
5128
  insert(_el$2, () => option.name || option.value);
5024
5129
  effect(() => setAttribute(_el$2, "key", `${option.name}-${index}`));
5025
5130
  effect(() => _el$2.value = option.value);
@@ -5263,7 +5368,7 @@ var componentInfo20 = {
5263
5368
  }
5264
5369
  };
5265
5370
  var _tmpl$21 = /* @__PURE__ */ template(`<div>`);
5266
- var _tmpl$29 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
5371
+ var _tmpl$28 = /* @__PURE__ */ template(`<div><video class=builder-video><source type=video/mp4>`);
5267
5372
  function Video(props) {
5268
5373
  const [lazyVideoObserver, setLazyVideoObserver] = createSignal(void 0);
5269
5374
  const videoProps = createMemo(() => {
@@ -5318,7 +5423,7 @@ function Video(props) {
5318
5423
  }
5319
5424
  });
5320
5425
  return (() => {
5321
- const _el$ = _tmpl$29(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
5426
+ const _el$ = _tmpl$28(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild;
5322
5427
  _el$.style.setProperty("position", "relative");
5323
5428
  const _ref$ = videoRef;
5324
5429
  typeof _ref$ === "function" ? use(_ref$, _el$2) : videoRef = _el$2;
@@ -5455,7 +5560,7 @@ var getDefaultRegisteredComponents = () => [{
5455
5560
  }, {
5456
5561
  component: text_default,
5457
5562
  ...componentInfo11
5458
- }, ...TARGET === "react" ? [{
5563
+ }, ...SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET) ? [{
5459
5564
  component: personalization_container_default,
5460
5565
  ...componentInfo6
5461
5566
  }] : [], ...TARGET === "rsc" ? [] : [{
@@ -5492,7 +5597,7 @@ var UPDATE_VARIANT_VISIBILITY_SCRIPT = "function updateVariantVisibility(variant
5492
5597
 
5493
5598
  // src/components/content-variants/helpers.ts
5494
5599
  var UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME = "builderIoAbTest";
5495
- var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME = "builderIoRenderContent";
5600
+ var UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2 = "builderIoRenderContent";
5496
5601
  var getVariants = (content) => Object.values(content?.variations || {}).map((variant) => ({
5497
5602
  ...variant,
5498
5603
  testVariationId: variant.id,
@@ -5517,20 +5622,20 @@ var checkShouldRenderVariants2 = ({
5517
5622
  };
5518
5623
  var getIsHydrationTarget = (target) => target === "react" || target === "reactNative";
5519
5624
  var isAngularSDK = TARGET === "angular";
5520
- var isHydrationTarget = getIsHydrationTarget(TARGET);
5625
+ var isHydrationTarget2 = getIsHydrationTarget(TARGET);
5521
5626
  var getInitVariantsFnsScriptString = () => `
5522
5627
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME} = ${UPDATE_COOKIES_AND_STYLES_SCRIPT}
5523
- window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
5628
+ window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2} = ${UPDATE_VARIANT_VISIBILITY_SCRIPT}
5524
5629
  `;
5525
5630
  var getUpdateCookieAndStylesScript = (variants, contentId) => `
5526
5631
  window.${UPDATE_COOKIES_AND_STYLES_SCRIPT_NAME}(
5527
- "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget}, ${isAngularSDK}
5632
+ "${contentId}",${JSON.stringify(variants)}, ${isHydrationTarget2}, ${isAngularSDK}
5528
5633
  )`;
5529
5634
  var getUpdateVariantVisibilityScript = ({
5530
5635
  contentId,
5531
5636
  variationId
5532
- }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME}(
5533
- "${variationId}", "${contentId}", ${isHydrationTarget}
5637
+ }) => `window.${UPDATE_VARIANT_VISIBILITY_SCRIPT_FN_NAME2}(
5638
+ "${variationId}", "${contentId}", ${isHydrationTarget2}
5534
5639
  )`;
5535
5640
 
5536
5641
  // src/helpers/preview-lru-cache/get.ts
@@ -5539,7 +5644,7 @@ function getPreviewContent(_searchParams) {
5539
5644
  }
5540
5645
 
5541
5646
  // src/constants/sdk-version.ts
5542
- var SDK_VERSION = "4.0.8";
5647
+ var SDK_VERSION = "4.0.10";
5543
5648
 
5544
5649
  // src/helpers/sdk-headers.ts
5545
5650
  var getSdkHeaders = () => ({
@@ -6955,7 +7060,7 @@ function ContentVariants(props) {
6955
7060
  return !props.isNestedRender && TARGET !== "reactNative";
6956
7061
  },
6957
7062
  get children() {
6958
- return createComponent(inlined_script_default, {
7063
+ return [createComponent(inlined_script_default, {
6959
7064
  id: "builderio-init-variants-fns",
6960
7065
  get scriptStr() {
6961
7066
  return getInitVariantsFnsScriptString();
@@ -6963,7 +7068,22 @@ function ContentVariants(props) {
6963
7068
  get nonce() {
6964
7069
  return props.nonce || "";
6965
7070
  }
6966
- });
7071
+ }), createComponent(Show, {
7072
+ get when() {
7073
+ return SDKS_SUPPORTING_PERSONALIZATION.includes(TARGET);
7074
+ },
7075
+ get children() {
7076
+ return createComponent(inlined_script_default, {
7077
+ id: "builderio-init-personalization-variants-fns",
7078
+ get nonce() {
7079
+ return props.nonce || "";
7080
+ },
7081
+ get scriptStr() {
7082
+ return getInitPersonalizationVariantsFnsScriptString();
7083
+ }
7084
+ });
7085
+ }
7086
+ })];
6967
7087
  }
6968
7088
  }), createComponent(Show, {
6969
7089
  get when() {
@@ -7151,7 +7271,7 @@ var fetchSymbolContent = async ({
7151
7271
  };
7152
7272
 
7153
7273
  // src/blocks/symbol/symbol.tsx
7154
- var _tmpl$30 = /* @__PURE__ */ template(`<div>`);
7274
+ var _tmpl$29 = /* @__PURE__ */ template(`<div>`);
7155
7275
  function Symbol(props) {
7156
7276
  const [contentToUse, setContentToUse] = createSignal(props.symbol?.content);
7157
7277
  const [symbolEntry, setSymbolEntry] = createSignal(props.symbol?.entry);
@@ -7185,7 +7305,7 @@ function Symbol(props) {
7185
7305
  }
7186
7306
  createEffect(on(() => [onUpdateFn_0_props_symbol()], onUpdateFn_0));
7187
7307
  return (() => {
7188
- const _el$ = _tmpl$30();
7308
+ const _el$ = _tmpl$29();
7189
7309
  spread(_el$, mergeProps({
7190
7310
  get ["class"]() {
7191
7311
  return className();