@builder.io/sdk-react-nextjs 0.7.0 → 0.7.1-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.
Files changed (43) hide show
  1. package/lib/browser/USE_CLIENT_BUNDLE-34ca6573.js +23 -0
  2. package/lib/browser/USE_CLIENT_BUNDLE-35cf57f2.mjs +657 -0
  3. package/lib/browser/USE_SERVER_BUNDLE-5f0752b4.mjs +11 -0
  4. package/lib/{edge/USE_SERVER_BUNDLE-105e9ef3.js → browser/USE_SERVER_BUNDLE-da1cf240.js} +1 -1
  5. package/lib/browser/{bundle-3b073b16.mjs → bundle-f0e86750.mjs} +680 -663
  6. package/lib/browser/bundle-fa4c07cb.js +76 -0
  7. package/lib/browser/index.cjs +1 -1
  8. package/lib/browser/index.mjs +7 -7
  9. package/lib/edge/USE_CLIENT_BUNDLE-2841cf29.js +23 -0
  10. package/lib/edge/USE_CLIENT_BUNDLE-aeac6d00.mjs +657 -0
  11. package/lib/edge/USE_SERVER_BUNDLE-015ab545.mjs +11 -0
  12. package/lib/{node/USE_SERVER_BUNDLE-d8c698c8.js → edge/USE_SERVER_BUNDLE-ef1618a6.js} +1 -1
  13. package/lib/edge/{bundle-ed178c62.mjs → bundle-3c711a0f.mjs} +2053 -2008
  14. package/lib/edge/bundle-bfbd5fa6.js +96 -0
  15. package/lib/edge/index.cjs +1 -1
  16. package/lib/edge/index.mjs +7 -7
  17. package/lib/node/USE_CLIENT_BUNDLE-a30d8b97.js +23 -0
  18. package/lib/node/USE_CLIENT_BUNDLE-fc82531c.mjs +657 -0
  19. package/lib/node/USE_SERVER_BUNDLE-25e36fa7.mjs +11 -0
  20. package/lib/{browser/USE_SERVER_BUNDLE-d8c698c8.js → node/USE_SERVER_BUNDLE-b26e79d4.js} +1 -1
  21. package/lib/node/bundle-23b73f20.js +116 -0
  22. package/lib/node/{bundle-3b073b16.mjs → bundle-4a8d8d92.mjs} +895 -781
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +7 -7
  25. package/package.json +4 -3
  26. package/types/blocks/image/image.d.ts +1 -1
  27. package/types/constants/sdk-version.d.ts +1 -1
  28. package/types/functions/evaluate/choose-eval.d.ts +6 -0
  29. package/types/functions/evaluate/evaluate.d.ts +1 -5
  30. package/types/functions/evaluate/helpers.d.ts +7 -1
  31. package/types/functions/get-content/types.d.ts +94 -3
  32. package/lib/browser/USE_CLIENT_BUNDLE-3a41b1ba.js +0 -23
  33. package/lib/browser/USE_CLIENT_BUNDLE-fc8c1bc0.mjs +0 -618
  34. package/lib/browser/USE_SERVER_BUNDLE-226a15ac.mjs +0 -11
  35. package/lib/browser/bundle-0fae602b.js +0 -76
  36. package/lib/edge/USE_CLIENT_BUNDLE-0e9f8e67.mjs +0 -618
  37. package/lib/edge/USE_CLIENT_BUNDLE-d48583e8.js +0 -23
  38. package/lib/edge/USE_SERVER_BUNDLE-f6a1e321.mjs +0 -11
  39. package/lib/edge/bundle-0c1d9099.js +0 -96
  40. package/lib/node/USE_CLIENT_BUNDLE-3a41b1ba.js +0 -23
  41. package/lib/node/USE_CLIENT_BUNDLE-fc8c1bc0.mjs +0 -618
  42. package/lib/node/USE_SERVER_BUNDLE-226a15ac.mjs +0 -11
  43. package/lib/node/bundle-0fae602b.js +0 -76
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./bundle-0fae602b.js"),t=require("./USE_CLIENT_BUNDLE-3a41b1ba.js");require("lru-cache");require("react/jsx-runtime");require("react");require("next/navigation");require("./USE_SERVER_BUNDLE-d8c698c8.js");exports.Blocks=e.Blocks;exports.Columns=e.Columns;exports.Content=e.ContentVariants;exports.RenderBlocks=e.RenderBlocks;exports.RenderContent=e.RenderContent;exports.Symbol=e.Symbol;exports.Text=e.Text;exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getAllContent=e.getAllContent;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.getContent=e.getContent;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.track=e.track;exports.Button=t.Button;exports.Fragment=t.FragmentComponent;exports.Image=t.Image;exports.Section=t.SectionComponent;exports.Video=t.Video;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./bundle-23b73f20.js"),t=require("./USE_CLIENT_BUNDLE-a30d8b97.js");require("lru-cache");require("react/jsx-runtime");require("react");require("next/navigation");require("./USE_SERVER_BUNDLE-b26e79d4.js");exports.Blocks=e.Blocks;exports.Columns=e.Columns;exports.Content=e.ContentVariants;exports.RenderBlocks=e.RenderBlocks;exports.RenderContent=e.RenderContent;exports.Symbol=e.Symbol;exports.Text=e.Text;exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getAllContent=e.getAllContent;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.getContent=e.getContent;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.track=e.track;exports.Button=t.Button;exports.Fragment=t.FragmentComponent;exports.Image=t.Image;exports.Section=t.SectionComponent;exports.Video=t.Video;
@@ -1,10 +1,10 @@
1
- import { B as i, p as m, C as c, R as g, o as p, S as l, T as C, z as d, e as u, E as B, v as S, w as f, x as E, A as R, y as h, i as x, q as k, t as y, u as P, D as b } from "./bundle-3b073b16.mjs";
2
- import { b as w, F as A, c as F, S as T, V } from "./USE_CLIENT_BUNDLE-fc8c1bc0.mjs";
1
+ import { B as i, t as m, C as c, R as g, q as p, S as l, T as C, z as d, m as f, E as u, w as B, n as S, x as E, A as R, y as h, i as x, f as k, u as y, v as P, D as b } from "./bundle-4a8d8d92.mjs";
2
+ import { b as w, F as A, c as F, S as T, V } from "./USE_CLIENT_BUNDLE-fc82531c.mjs";
3
3
  import "lru-cache";
4
4
  import "react/jsx-runtime";
5
5
  import "react";
6
6
  import "next/navigation";
7
- import "./USE_SERVER_BUNDLE-226a15ac.mjs";
7
+ import "./USE_SERVER_BUNDLE-25e36fa7.mjs";
8
8
  export {
9
9
  i as Blocks,
10
10
  w as Button,
@@ -19,10 +19,10 @@ export {
19
19
  C as Text,
20
20
  V as Video,
21
21
  d as _processContentResult,
22
- u as createRegisterComponentMessage,
23
- B as fetchBuilderProps,
24
- S as fetchEntries,
25
- f as fetchOneEntry,
22
+ f as createRegisterComponentMessage,
23
+ u as fetchBuilderProps,
24
+ B as fetchEntries,
25
+ S as fetchOneEntry,
26
26
  E as getAllContent,
27
27
  R as getBuilderSearchParams,
28
28
  h as getContent,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@builder.io/sdk-react-nextjs",
3
3
  "description": "Builder.io RSC SDK for NextJS App Directory",
4
- "version": "0.7.0",
4
+ "version": "0.7.1-1",
5
5
  "files": [
6
6
  "lib",
7
7
  "types"
@@ -97,14 +97,15 @@
97
97
  "build:browser": "SDK_ENV=browser vite build --mode lib"
98
98
  },
99
99
  "peerDependencies": {
100
- "next": "^13.4.20-canary.10 || ^13.4.20",
100
+ "isolated-vm": "^4.6.0",
101
+ "next": "^13.4.20",
101
102
  "react": "^18.2.0",
102
103
  "react-dom": "^18.2.0"
103
104
  },
104
105
  "devDependencies": {
105
106
  "@builder.io/sdks": "workspace:*",
106
107
  "@vitejs/plugin-react": "^4.0.4",
107
- "next": "13.4.20-canary.10",
108
+ "next": "^13.4.20",
108
109
  "nx": "^16.6.0",
109
110
  "nx-cloud": "^16.2.0",
110
111
  "react": "^18.2.0",
@@ -11,7 +11,7 @@ export interface ImageProps {
11
11
  backgroundPosition?: string;
12
12
  srcset?: string;
13
13
  aspectRatio?: number;
14
- children?: JSX.Element;
14
+ children?: any;
15
15
  fitContent?: boolean;
16
16
  builderBlock?: BuilderBlock;
17
17
  noWebp?: boolean;
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "0.7.0";
1
+ export declare const SDK_VERSION = "0.7.1-0";
@@ -0,0 +1,6 @@
1
+ import type { ExecutorArgs } from './helpers.js';
2
+ /**
3
+ * Even though we have separate runtimes for browser/node/edge, sometimes frameworks will
4
+ * end up sending the server runtime code to the browser (most notably in dev mode).
5
+ */
6
+ export declare const chooseBrowserOrServerEval: (args: ExecutorArgs) => any;
@@ -1,6 +1,2 @@
1
- import type { ExecutorArgs } from './helpers.js';
2
- export type EvaluatorArgs = Omit<ExecutorArgs, 'builder' | 'event'> & {
3
- event?: Event;
4
- isExpression?: boolean;
5
- };
1
+ import type { EvaluatorArgs } from './helpers.js';
6
2
  export declare function evaluate({ code, context, localState, rootState, rootSetState, event, isExpression }: EvaluatorArgs): any;
@@ -1,5 +1,9 @@
1
1
  import type { BuilderContextInterface, BuilderRenderState } from '../../context/types.js';
2
- import type { getUserAttributes } from '../track/helpers.js';
2
+ import { getUserAttributes } from '../track/helpers.js';
3
+ export type EvaluatorArgs = Omit<ExecutorArgs, 'builder' | 'event'> & {
4
+ event?: Event;
5
+ isExpression?: boolean;
6
+ };
3
7
  export type BuilderGlobals = {
4
8
  isEditing: boolean | undefined;
5
9
  isBrowser: boolean | undefined;
@@ -16,3 +20,5 @@ export type FunctionArguments = ReturnType<typeof getFunctionArguments>;
16
20
  export declare const getFunctionArguments: ({ builder, context, event, state }: Pick<ExecutorArgs, "context" | "builder" | "event"> & {
17
21
  state: BuilderRenderState;
18
22
  }) => [string, Event | BuilderRenderState | import("../../context/types.js").BuilderRenderContext | BuilderGlobals][];
23
+ export declare const getBuilderGlobals: () => BuilderGlobals;
24
+ export declare const parseCode: (code: string, { isExpression }: Pick<EvaluatorArgs, 'isExpression'>) => string;
@@ -5,11 +5,42 @@ export interface GetContentOptions {
5
5
  apiKey: string;
6
6
  /** Number of items to fetch. Default is 1 */
7
7
  limit?: number;
8
- /** User attributes to target on, such as { urlPath: '/foo', device: 'mobile', ...etc } */
8
+ /**
9
+ * Use to specify an offset for pagination of results. The default is 0.
10
+ */
11
+ offset?: number;
12
+ /**
13
+ * User attribute key value pairs to be used for targeting
14
+ * https://www.builder.io/c/docs/custom-targeting-attributes
15
+ *
16
+ * e.g.
17
+ * ```js
18
+ * userAttributes: {
19
+ * urlPath: '/',
20
+ * returnVisitor: true,
21
+ * device: 'mobile'
22
+ * }
23
+ * ```
24
+ */
9
25
  userAttributes?: (Record<string, string> & {
10
26
  urlPath?: string;
11
27
  }) | null;
12
- /** Custom query */
28
+ /**
29
+ * Mongodb style query of your data. E.g.:
30
+ *
31
+ * ```js
32
+ * query: {
33
+ * id: 'abc123',
34
+ * data: {
35
+ * myCustomField: { $gt: 20 },
36
+ * }
37
+ * }
38
+ * ```
39
+ *
40
+ * See more info on MongoDB's query operators and format.
41
+ *
42
+ * @see {@link https://docs.mongodb.com/manual/reference/operator/query/}
43
+ */
13
44
  query?: Record<string, any>;
14
45
  /**
15
46
  * Any other API options.
@@ -30,7 +61,7 @@ export interface GetContentOptions {
30
61
  */
31
62
  canTrack?: boolean;
32
63
  /**
33
- * Include references in the response. Defaults to `true`.
64
+ * Include content of references in the response. Defaults to `true`.
34
65
  * @deprecated use `enrich` instead
35
66
  */
36
67
  includeRefs?: boolean;
@@ -48,4 +79,64 @@ export interface GetContentOptions {
48
79
  * Defaults to `v3`.
49
80
  */
50
81
  apiVersion?: 'v2' | 'v3';
82
+ /**
83
+ * Only include these fields.
84
+ * Note: 'omit' takes precedence over 'fields'
85
+ *
86
+ * @example
87
+ * ```
88
+ * fields: 'id, name, data.customField'
89
+ * ```
90
+ */
91
+ fields?: string;
92
+ /**
93
+ * Omit only these fields.
94
+ * Note: 'omit' takes precedence over 'fields'
95
+ *
96
+ * @example
97
+ * ```
98
+ * omit: 'data.bigField,data.blocks'
99
+ * ```
100
+ */
101
+ omit?: string;
102
+ /**
103
+ * Seconds to cache content. Sets the max-age of the cache-control header
104
+ * response header.
105
+ *
106
+ * Use a higher value for better performance, lower for content that will change more frequently
107
+ *
108
+ * @see {@link https://www.builder.io/c/docs/query-api#__next:~:text=%26includeRefs%3Dtrue-,cacheSeconds,-No}
109
+ */
110
+ cacheSeconds?: number;
111
+ /**
112
+ * Builder.io uses stale-while-revalidate caching at the CDN level. This means we always serve
113
+ * from edge cache and update caches in the background for maximum possible performance. This also
114
+ * means that the more frequently content is requested, the more fresh it will be. The longest we
115
+ * will ever hold something in stale cache is 1 day by default, and you can set this to be shorter
116
+ * yourself as well. We suggest keeping this high unless you have content that must change rapidly
117
+ * and gets very little traffic.
118
+ *
119
+ * @see {@link https://www.fastly.com/blog/prevent-application-network-instability-serve-stale-content}
120
+ */
121
+ staleCacheSeconds?: number;
122
+ /**
123
+ * Property to order results by.
124
+ * Use 1 for ascending and -1 for descending.
125
+ *
126
+ * The key is what you're sorting on, so the following example sorts by createdDate
127
+ * and because the value is 1, the sort is ascending.
128
+ *
129
+ * @example
130
+ * ```
131
+ * createdDate: 1
132
+ * ```
133
+ */
134
+ sort?: {
135
+ [key: string]: 1 | -1;
136
+ };
137
+ /**
138
+ * Include content entries in a response that are still in
139
+ * draft mode and un-archived. Default is false.
140
+ */
141
+ includeUnpublished?: boolean;
51
142
  }
@@ -1,23 +0,0 @@
1
- "use client";"use strict";const t=require("react/jsx-runtime"),n=require("./bundle-0fae602b.js"),d=require("react"),L=require("./USE_SERVER_BUNDLE-d8c698c8.js"),M=require("next/navigation");function W(e){return t.jsxs(t.Fragment,{children:[e.link?t.jsx(t.Fragment,{children:t.jsx("a",{role:"button",...e.attributes,href:e.link,target:e.openLinkInNewTab?"_blank":void 0,children:e.text})}):t.jsx(t.Fragment,{children:t.jsx("button",{...e.attributes,style:e.attributes.style,className:e.attributes.className+" button-3e7bc8b2",children:e.text})}),t.jsx("style",{children:`.button-3e7bc8b2 {
2
- all: unset;
3
- }`})]})}function _(e){return t.jsx(e.Wrapper,{...e.wrapperProps,attributes:{...n.getBlockProperties({block:e.block,context:e.context}),...n.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context})},children:e.children})}function A(e){return t.jsxs(t.Fragment,{children:[" ",e.hasChildren?t.jsx(t.Fragment,{children:t.jsxs(e.Wrapper,{...n.getBlockProperties({block:e.block,context:e.context}),...n.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0}),children:[" ",e.children," "]})}):t.jsx(t.Fragment,{children:t.jsx(e.Wrapper,{...n.getBlockProperties({block:e.block,context:e.context}),...n.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0})})})," "]})}function z(e){function c(){var o;return"builder-blocks"+((o=e.blocks)!=null&&o.length?"":" no-blocks")}function g(){var o,x;n.isEditing()&&!((o=e.blocks)!=null&&o.length)&&((x=window.parent)==null||x.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}function b(){var o,x;n.isEditing()&&!((o=e.blocks)!=null&&o.length)&&((x=window.parent)==null||x.postMessage({type:"builder.hoverEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:c()+" div-5821bd52","builder-path":e.path,"builder-parent-id":e.parent,style:e.styleProp,onClick:o=>g(),onMouseEnter:o=>b(),onKeyPress:o=>g(),children:e.children}),t.jsx("style",{children:`.div-5821bd52 {
4
- display: flex;
5
- flex-direction: column;
6
- align-items: stretch;
7
- }`})]})}function K(e){return t.jsx("span",{children:e.children})}function D(e){var o,x,k,S;function c(){var f;const r=e.image||e.src;if(!r||!(r.match(/builder\.io/)||r.match(/cdn\.shopify\.com/)))return e.srcset;if(e.srcset&&((f=e.image)!=null&&f.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),n.getSrcSet(r)}else if(e.image&&!e.srcset)return n.getSrcSet(r);return n.getSrcSet(r)}function g(){var m;return(m=c==null?void 0:c())!=null&&m.match(/builder\.io/)&&!e.noWebp?c().replace(/\?/g,"?format=webp&"):""}function b(){const m={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?m:void 0}return t.jsxs(t.Fragment,{children:[t.jsxs(t.Fragment,{children:[t.jsxs("picture",{children:[g()?t.jsx(t.Fragment,{children:t.jsx("source",{type:"image/webp",srcSet:g()})}):null,t.jsx("img",{loading:"lazy",alt:e.altText,role:e.altText?"presentation":void 0,style:{objectPosition:e.backgroundPosition||"center",objectFit:e.backgroundSize||"cover",...b()},className:"builder-image"+(e.className?" "+e.className:"")+" img-ef11a6be",src:e.image,srcSet:c(),sizes:e.sizes})]}),e.aspectRatio&&!((x=(o=e.builderBlock)==null?void 0:o.children)!=null&&x.length&&e.fitContent)?t.jsx(t.Fragment,{children:t.jsx("div",{className:"builder-image-sizer div-ef11a6be",style:{paddingTop:e.aspectRatio*100+"%"}})}):null,(S=(k=e.builderBlock)==null?void 0:k.children)!=null&&S.length&&e.fitContent?t.jsx(t.Fragment,{children:e.children}):null,!e.fitContent&&e.children?t.jsx(t.Fragment,{children:t.jsx("div",{className:"div-ef11a6be-2",children:e.children})}):null]}),t.jsx("style",{children:`.img-ef11a6be {
8
- opacity: 1;
9
- transition: opacity 0.2s ease-in-out;
10
- }.div-ef11a6be {
11
- width: 100%;
12
- pointer-events: none;
13
- font-size: 0;
14
- }.div-ef11a6be-2 {
15
- display: flex;
16
- flex-direction: column;
17
- align-items: stretch;
18
- position: absolute;
19
- top: 0;
20
- left: 0;
21
- width: 100%;
22
- height: 100%;
23
- }`})]})}function V(e){return t.jsx("section",{...e.attributes,style:{width:"100%",alignSelf:"stretch",flexGrow:1,boxSizing:"border-box",maxWidth:e.maxWidth||1200,display:"flex",flexDirection:"column",alignItems:"stretch",marginLeft:"auto",marginRight:"auto"},children:e.children})}function U(e){var b;function c(){return{...e.autoPlay===!0?{autoPlay:!0}:{},...e.muted===!0?{muted:!0}:{},...e.controls===!0?{controls:!0}:{},...e.loop===!0?{loop:!0}:{},...e.playsInline===!0?{playsInline:!0}:{}}}function g(){return{...e.attributes,...c()}}return t.jsx("video",{...g(),preload:e.preload||"metadata",style:{width:"100%",height:"100%",...(b=e.attributes)==null?void 0:b.style,objectFit:e.fit,objectPosition:e.position,borderRadius:1},src:e.video||"no-src",poster:e.posterImage})}function H(e){const c=d.useRef(null),[g,b]=d.useState(()=>[]),[o,x]=d.useState(()=>[]),[k,S]=d.useState(()=>!1);function m(){if(!c.current||!c.current.getElementsByTagName)return;const r=c.current.getElementsByTagName("script");for(let f=0;f<r.length;f++){const v=r[f];if(v.src&&!g.includes(v.src)){g.push(v.src);const C=document.createElement("script");C.async=!0,C.src=v.src,document.head.appendChild(C)}else if(n.isJsScript(v)&&!o.includes(v.innerText))try{o.push(v.innerText),new Function(v.innerText)()}catch(C){console.warn("`Embed`: Error running script:",C)}}}return d.useEffect(()=>{c.current&&!k&&(S(!0),m())},[c.current,k]),t.jsx("div",{className:"builder-embed",ref:c,dangerouslySetInnerHTML:{__html:e.content}})}function J(e){return t.jsx("img",{style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,...e.attributes},n.isEditing()&&e.imgSrc||"default-key")}function O(e){const c=d.useRef(null),[g,b]=d.useState(()=>[]),[o,x]=d.useState(()=>[]);function k(){if(c.current&&c.current.getElementsByTagName&&typeof window<"u"){const S=c.current.getElementsByTagName("script");for(let m=0;m<S.length;m++){const r=S[m];if(r.src){if(g.includes(r.src))continue;g.push(r.src);const f=document.createElement("script");f.async=!0,f.src=r.src,document.head.appendChild(f)}else if(!r.type||["text/javascript","application/javascript","application/ecmascript"].includes(r.type)){if(o.includes(r.innerText))continue;try{o.push(r.innerText),new Function(r.innerText)()}catch(f){console.warn("`CustomCode`: Error running script:",f)}}}}}return d.useEffect(()=>{k()},[]),t.jsx("div",{ref:c,className:"builder-custom-code"+(e.replaceNodes?" replace-nodes":""),dangerouslySetInnerHTML:{__html:e.code}})}const G=d.createContext({content:null,context:{},localState:void 0,rootSetState(){},rootState:{},apiKey:null,apiVersion:void 0,componentInfos:{},inheritedStyles:{}});function Q(e){var j,R,I,w,F;const c=d.useRef(null),[g,b]=d.useState(()=>0);function o(i){var a,s,u,h,P;const l={...e.builderContextSignal.content,...i,data:{...(a=e.builderContextSignal.content)==null?void 0:a.data,...i==null?void 0:i.data},meta:{...(s=e.builderContextSignal.content)==null?void 0:s.meta,...i==null?void 0:i.meta,breakpoints:((u=i==null?void 0:i.meta)==null?void 0:u.breakpoints)||((P=(h=e.builderContextSignal.content)==null?void 0:h.meta)==null?void 0:P.breakpoints)}};L.postPreviewContent({value:l,key:l.id}).then(()=>{q.refresh()})}d.useState(()=>0);const[x,k]=d.useState(()=>!1);function S(i){var a;const{data:l}=i;if(l)switch(l.type){case"builder.configureSdk":{const s=l.data,{breakpoints:u,contentId:h}=s;if(!h||h!==((a=e.builderContextSignal.content)==null?void 0:a.id))return;u&&o({meta:{breakpoints:u}}),b(g+1);break}case"builder.contentUpdate":{const s=l.data,u=s.key||s.alias||s.entry||s.modelName,h=s.data;u===e.model&&(o(h),b(g+1));break}}}function m(){var l,a;const i=(a=(l=e.builderContextSignal.content)==null?void 0:l.data)==null?void 0:a.jsCode;i&&n.evaluate({code:i,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})}const[r,f]=d.useState(()=>({})),[v,C]=d.useState(()=>!1);function B(i){var l,a;if(e.builderContextSignal.content){const s=(l=e.builderContextSignal.content)==null?void 0:l.testVariationId,u=(a=e.builderContextSignal.content)==null?void 0:a.id;n._track({type:"click",canTrack:n.getDefaultCanTrack(e.canTrack),contentId:u,apiKey:e.apiKey,variationId:s!==u?s:void 0,...n.getInteractionPropertiesForEvent(i),unique:!v})}v||C(!0)}function T(i){return i.replace(/{{([^}]+)}}/g,(l,a)=>n.evaluate({code:a,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState}))}function N({url:i,key:l}){n.fetch(i).then(a=>a.json()).then(a=>{var u,h;const s={...e.builderContextSignal.rootState,[l]:a};(h=(u=e.builderContextSignal).rootSetState)==null||h.call(u,s),r[l]=!0}).catch(a=>{console.error("error fetching dynamic data",i,a)})}function E(){var l,a;const i=((a=(l=e.builderContextSignal.content)==null?void 0:l.data)==null?void 0:a.httpRequests)??{};Object.entries(i).forEach(([s,u])=>{if(u&&(!r[s]||n.isEditing())){const h=T(u);N({url:h,key:s})}})}function y(){n.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:n.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}const q=M.useRouter();return d.useEffect(()=>{var i,l;if(e.apiKey||n.logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."),n.isBrowser()){if(n.isEditing()&&(b(g+1),window.addEventListener("message",S),n.registerInsertMenu(),n.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.includeRefs?{includeRefs:e.includeRefs}:{},...e.enrich?{enrich:e.enrich}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(a=>{var u;const s=n.createRegisterComponentMessage(a);(u=window.parent)==null||u.postMessage(s,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",y)),e.builderContextSignal.content){const a=(i=e.builderContextSignal.content)==null?void 0:i.testVariationId,s=(l=e.builderContextSignal.content)==null?void 0:l.id;n._track({type:"impression",canTrack:n.getDefaultCanTrack(e.canTrack),contentId:s,apiKey:e.apiKey,variationId:a!==s?a:void 0})}m(),E(),y()}},[]),d.useEffect(()=>{},[e.content]),d.useEffect(()=>{n.isBrowser()&&(window.removeEventListener("message",S),window.addEventListener("message",S))},[x]),d.useEffect(()=>{m()},[(R=(j=e.builderContextSignal.content)==null?void 0:j.data)==null?void 0:R.jsCode,e.builderContextSignal.rootState]),d.useEffect(()=>{E()},[(w=(I=e.builderContextSignal.content)==null?void 0:I.data)==null?void 0:w.httpRequests]),d.useEffect(()=>{y()},[e.builderContextSignal.rootState]),d.useEffect(()=>()=>{n.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",y))},[]),t.jsx(G.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?t.jsx(t.Fragment,{children:t.jsx("div",{ref:c,onClick:i=>B(i),"builder-content-id":(F=e.builderContextSignal.content)==null?void 0:F.id,"builder-model":e.model,...e.showContent?{}:{hidden:!0,"aria-hidden":!0},className:e.classNameProp,children:e.children},g)}):null})}exports.BlockWrapper=A;exports.BlocksWrapper=z;exports.Button=W;exports.CustomCode=O;exports.Embed=H;exports.EnableEditor=Q;exports.FragmentComponent=K;exports.Image=D;exports.ImgComponent=J;exports.InteractiveElement=_;exports.SectionComponent=V;exports.Video=U;