@builder.io/sdk-react-nextjs 0.7.2 → 0.7.4

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 (42) hide show
  1. package/lib/browser/USE_CLIENT_BUNDLE-6b3887b7.js +711 -0
  2. package/lib/browser/USE_CLIENT_BUNDLE-f95a196a.cjs +23 -0
  3. package/lib/{edge/USE_SERVER_BUNDLE-e0effb0f.js → browser/USE_SERVER_BUNDLE-b314d0f7.js} +1 -1
  4. package/lib/{edge/USE_SERVER_BUNDLE-ea7c665e.cjs → browser/USE_SERVER_BUNDLE-eed7792a.cjs} +1 -1
  5. package/lib/browser/{bundle-fc27d227.cjs → bundle-df55c296.cjs} +111 -19
  6. package/lib/browser/{bundle-6f6b7d63.js → bundle-fc3e7377.js} +528 -514
  7. package/lib/browser/index.cjs +1 -1
  8. package/lib/browser/index.mjs +3 -3
  9. package/lib/edge/USE_CLIENT_BUNDLE-44225d7a.cjs +23 -0
  10. package/lib/edge/USE_CLIENT_BUNDLE-a32e462e.js +711 -0
  11. package/lib/{node/USE_SERVER_BUNDLE-787d0ec8.js → edge/USE_SERVER_BUNDLE-2c9d1a5d.js} +1 -1
  12. package/lib/{node/USE_SERVER_BUNDLE-842e66c9.cjs → edge/USE_SERVER_BUNDLE-e5ab43ec.cjs} +1 -1
  13. package/lib/edge/bundle-38f08fa1.cjs +188 -0
  14. package/lib/edge/{bundle-213a8bf7.js → bundle-bef73246.js} +1516 -1502
  15. package/lib/edge/index.cjs +1 -1
  16. package/lib/edge/index.mjs +3 -3
  17. package/lib/node/USE_CLIENT_BUNDLE-539be307.cjs +23 -0
  18. package/lib/node/USE_CLIENT_BUNDLE-a5c6399c.js +711 -0
  19. package/lib/{browser/USE_SERVER_BUNDLE-ea1618f4.js → node/USE_SERVER_BUNDLE-21bf3ffc.js} +1 -1
  20. package/lib/{browser/USE_SERVER_BUNDLE-4341bf5c.cjs → node/USE_SERVER_BUNDLE-7f4ba7e9.cjs} +1 -1
  21. package/lib/node/{bundle-fb3490a6.js → bundle-74479d5d.js} +297 -283
  22. package/lib/node/{bundle-df78531d.cjs → bundle-f7863fb3.cjs} +110 -18
  23. package/lib/node/index.cjs +1 -1
  24. package/lib/node/index.mjs +3 -3
  25. package/package.json +8 -1
  26. package/types/cjs/blocks/video/video.d.ts +4 -0
  27. package/types/cjs/components/content/content.types.d.ts +0 -4
  28. package/types/cjs/components/content-variants/helpers.d.ts +3 -3
  29. package/types/cjs/components/content-variants/inlined-fns.d.ts +14 -0
  30. package/types/cjs/constants/sdk-version.d.ts +1 -1
  31. package/types/esm/blocks/video/video.d.ts +4 -0
  32. package/types/esm/components/content/content.types.d.ts +0 -4
  33. package/types/esm/components/content-variants/helpers.d.ts +3 -3
  34. package/types/esm/components/content-variants/inlined-fns.d.ts +14 -0
  35. package/types/esm/constants/sdk-version.d.ts +1 -1
  36. package/lib/browser/USE_CLIENT_BUNDLE-0e3e24e7.js +0 -657
  37. package/lib/browser/USE_CLIENT_BUNDLE-727780ee.cjs +0 -23
  38. package/lib/edge/USE_CLIENT_BUNDLE-372b4c60.js +0 -657
  39. package/lib/edge/USE_CLIENT_BUNDLE-f1bfb292.cjs +0 -23
  40. package/lib/edge/bundle-0fb39c43.cjs +0 -96
  41. package/lib/node/USE_CLIENT_BUNDLE-bdbc178a.cjs +0 -23
  42. package/lib/node/USE_CLIENT_BUNDLE-c6d9e08c.js +0 -657
@@ -1,23 +0,0 @@
1
- "use client";"use strict";const t=require("react/jsx-runtime"),a=require("./bundle-fc27d227.cjs"),o=require("react"),_=require("./USE_SERVER_BUNDLE-4341bf5c.cjs"),M=require("next/navigation");function W(e){return t.jsxs(t.Fragment,{children:[e.link?t.jsx(t.Fragment,{children:t.jsx("a",{...e.attributes,href:e.link,target:e.openLinkInNewTab?"_blank":void 0,role:"button",children:e.text})}):t.jsx(t.Fragment,{children:t.jsx("button",{...e.attributes,style:e.attributes.style,className:e.attributes.className+" button-5294b10c",children:e.text})}),t.jsx("style",{children:`.button-5294b10c {
2
- all: unset;
3
- }`})]})}function A(e){return t.jsxs(t.Fragment,{children:[" ",e.hasChildren?t.jsx(t.Fragment,{children:t.jsxs(e.Wrapper,{...a.getBlockProperties({block:e.block,context:e.context}),...a.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,{...a.getBlockProperties({block:e.block,context:e.context}),...a.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context,stripPrefix:!0})})})," "]})}function V(e){return t.jsx(e.Wrapper,{...e.wrapperProps,attributes:{...a.getBlockProperties({block:e.block,context:e.context}),...a.getBlockActions({block:e.block,rootState:e.context.rootState,rootSetState:e.context.rootSetState,localState:e.context.localState,context:e.context.context})},children:e.children})}function z(e){function c(){var s;return"builder-blocks"+((s=e.blocks)!=null&&s.length?"":" no-blocks")}function g(){var s,x;a.isEditing()&&!((s=e.blocks)!=null&&s.length)&&((x=window.parent)==null||x.postMessage({type:"builder.clickEmptyBlocks",data:{parentElementId:e.parent,dataPath:e.path}},"*"))}function h(){var s,x;a.isEditing()&&!((s=e.blocks)!=null&&s.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-02c7a115","builder-path":e.path,"builder-parent-id":e.parent,style:e.styleProp,onClick:s=>g(),onMouseEnter:s=>h(),onKeyPress:s=>g(),children:e.children}),t.jsx("style",{children:`.div-02c7a115 {
4
- display: flex;
5
- flex-direction: column;
6
- align-items: stretch;
7
- }`})]})}function D(e){return t.jsx("span",{children:e.children})}function U(e){var s,x,k,S;function c(){var b;const d=e.image||e.src;if(!d||!(d.match(/builder\.io/)||d.match(/cdn\.shopify\.com/)))return e.srcset;if(e.srcset&&((b=e.image)!=null&&b.includes("builder.io/api/v1/image"))){if(!e.srcset.includes(e.image.split("?")[0]))return console.debug("Removed given srcset"),a.getSrcSet(d)}else if(e.image&&!e.srcset)return a.getSrcSet(d);return a.getSrcSet(d)}function g(){var f;return(f=c==null?void 0:c())!=null&&f.match(/builder\.io/)&&!e.noWebp?c().replace(/\?/g,"?format=webp&"):""}function h(){const f={position:"absolute",height:"100%",width:"100%",left:"0px",top:"0px"};return e.aspectRatio?f: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",...h()},className:"builder-image"+(e.className?" "+e.className:"")+" img-dbab4030",src:e.image,srcSet:c(),sizes:e.sizes})]}),e.aspectRatio&&!((x=(s=e.builderBlock)==null?void 0:s.children)!=null&&x.length&&e.fitContent)?t.jsx(t.Fragment,{children:t.jsx("div",{className:"builder-image-sizer div-dbab4030",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-dbab4030-2",children:e.children})}):null]}),t.jsx("style",{children:`.img-dbab4030 {
8
- opacity: 1;
9
- transition: opacity 0.2s ease-in-out;
10
- }.div-dbab4030 {
11
- width: 100%;
12
- pointer-events: none;
13
- font-size: 0;
14
- }.div-dbab4030-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 H(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 O(e){const c=o.useRef(null),[g,h]=o.useState(()=>[]),[s,x]=o.useState(()=>[]);return o.useEffect(()=>{var S;if(!((S=c.current)!=null&&S.getElementsByTagName)||typeof window>"u")return;const k=c.current.getElementsByTagName("script");for(let f=0;f<k.length;f++){const d=k[f];if(d.src){if(g.includes(d.src))continue;g.push(d.src);const b=document.createElement("script");b.async=!0,b.src=d.src,document.head.appendChild(b)}else if(!d.type||["text/javascript","application/javascript","application/ecmascript"].includes(d.type)){if(s.includes(d.innerText))continue;try{s.push(d.innerText),new Function(d.innerText)()}catch(b){console.warn("`CustomCode`: Error running script:",b)}}}},[]),t.jsx("div",{ref:c,className:"builder-custom-code"+(e.replaceNodes?" replace-nodes":""),dangerouslySetInnerHTML:{__html:e.code}})}function J(e){const c=o.useRef(null),[g,h]=o.useState(()=>[]),[s,x]=o.useState(()=>[]),[k,S]=o.useState(()=>!1);function f(){if(!c.current||!c.current.getElementsByTagName)return;const d=c.current.getElementsByTagName("script");for(let b=0;b<d.length;b++){const v=d[b];if(v.src&&!g.includes(v.src)){g.push(v.src);const y=document.createElement("script");y.async=!0,y.src=v.src,document.head.appendChild(y)}else if(a.isJsScript(v)&&!s.includes(v.innerText))try{s.push(v.innerText),new Function(v.innerText)()}catch(y){console.warn("`Embed`: Error running script:",y)}}}return o.useEffect(()=>{c.current&&!k&&(S(!0),f())},[c.current,k]),t.jsx("div",{className:"builder-embed",ref:c,dangerouslySetInnerHTML:{__html:e.content}})}function G(e){return t.jsx("img",{style:{objectFit:e.backgroundSize||"cover",objectPosition:e.backgroundPosition||"center"},alt:e.altText,src:e.imgSrc||e.image,...e.attributes},a.isEditing()&&e.imgSrc||"default-key")}function $(e){var h;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%",...(h=e.attributes)==null?void 0:h.style,objectFit:e.fit,objectPosition:e.position,borderRadius:1},src:e.video||"no-src",poster:e.posterImage})}const Q=o.createContext({content:null,context:{},localState:void 0,rootSetState(){},rootState:{},apiKey:null,apiVersion:void 0,componentInfos:{},inheritedStyles:{}});function X(e){var R,I,P,T,F;const c=o.useRef(null),[g,h]=o.useState(()=>0);function s(n){var r,l,u,m,B;const i={...e.builderContextSignal.content,...n,data:{...(r=e.builderContextSignal.content)==null?void 0:r.data,...n==null?void 0:n.data},meta:{...(l=e.builderContextSignal.content)==null?void 0:l.meta,...n==null?void 0:n.meta,breakpoints:((u=n==null?void 0:n.meta)==null?void 0:u.breakpoints)||((B=(m=e.builderContextSignal.content)==null?void 0:m.meta)==null?void 0:B.breakpoints)}};_.postPreviewContent({value:i,key:i.id}).then(()=>{q.refresh()})}o.useState(()=>0);const[x,k]=o.useState(()=>!1);function S(n){var r;const{data:i}=n;if(i)switch(i.type){case"builder.configureSdk":{const l=i.data,{breakpoints:u,contentId:m}=l;if(!m||m!==((r=e.builderContextSignal.content)==null?void 0:r.id))return;u&&s({meta:{breakpoints:u}}),h(g+1);break}case"builder.contentUpdate":{const l=i.data,u=l.key||l.alias||l.entry||l.modelName,m=l.data;u===e.model&&(s(m),h(g+1));break}}}function f(){var i,r;const n=(r=(i=e.builderContextSignal.content)==null?void 0:i.data)==null?void 0:r.jsCode;n&&a.evaluate({code:n,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})}const[d,b]=o.useState(()=>({})),[v,y]=o.useState(()=>!1);function N(n){var i,r;if(e.builderContextSignal.content){const l=(i=e.builderContextSignal.content)==null?void 0:i.testVariationId,u=(r=e.builderContextSignal.content)==null?void 0:r.id;a._track({type:"click",canTrack:a.getDefaultCanTrack(e.canTrack),contentId:u,apiKey:e.apiKey,variationId:l!==u?l:void 0,...a.getInteractionPropertiesForEvent(n),unique:!v})}v||y(!0)}function L(n){return n.replace(/{{([^}]+)}}/g,(i,r)=>a.evaluate({code:r,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState}))}function K({url:n,key:i}){a.fetch(n).then(r=>r.json()).then(r=>{var u,m;const l={...e.builderContextSignal.rootState,[i]:r};(m=(u=e.builderContextSignal).rootSetState)==null||m.call(u,l),d[i]=!0}).catch(r=>{console.error("error fetching dynamic data",n,r)})}function C(){var i,r;const n=((r=(i=e.builderContextSignal.content)==null?void 0:i.data)==null?void 0:r.httpRequests)??{};Object.entries(n).forEach(([l,u])=>{if(u&&(!d[l]||a.isEditing())){const m=L(u);K({url:m,key:l})}})}function E(){a.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:a.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}function j(n){h(g+1),window.addEventListener("message",S),a.registerInsertMenu(),a.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.includeRefs?{includeRefs:e.includeRefs}:{},...e.enrich?{enrich:e.enrich}:{}}),Object.values(e.builderContextSignal.componentInfos).forEach(i=>{var l;const r=a.createRegisterComponentMessage(i);(l=window.parent)==null||l.postMessage(r,"*")}),window.addEventListener("builder:component:stateChangeListenerActivated",E)}function w(n){const i=new URL(location.href).searchParams,r=i.get("builder.preview"),l=i.get(`builder.preview.${r}`),u=i.get("apiKey")||i.get("builder.space");r===e.model&&u===e.apiKey&&(!e.content||l===e.content.id)&&a.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion}).then(m=>{m&&s(m)})}const q=M.useRouter();return o.useEffect(()=>{var n;return(n=c.current)==null||n.addEventListener("initeditingbldr",j),()=>{var i;return(i=c.current)==null?void 0:i.removeEventListener("initeditingbldr",j)}},[]),o.useEffect(()=>{var n;return(n=c.current)==null||n.addEventListener("initpreviewingbldr",w),()=>{var i;return(i=c.current)==null?void 0:i.removeEventListener("initpreviewingbldr",w)}},[]),o.useEffect(()=>{var n,i;if(a.isBrowser()){if(a.isEditing()&&c.current&&c.current.dispatchEvent(new CustomEvent("initeditingbldr")),e.builderContextSignal.content&&a.getDefaultCanTrack(e.canTrack)){const l=(n=e.builderContextSignal.content)==null?void 0:n.testVariationId,u=(i=e.builderContextSignal.content)==null?void 0:i.id,m=e.apiKey;a._track({type:"impression",canTrack:!0,contentId:u,apiKey:m,variationId:l!==u?l:void 0})}a.isPreviewing()&&c.current}},[]),o.useEffect(()=>{e.apiKey||a.logger.error("No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."),f(),C(),E()},[]),o.useEffect(()=>{},[e.content]),o.useEffect(()=>{a.isBrowser()&&(window.removeEventListener("message",S),window.addEventListener("message",S))},[x]),o.useEffect(()=>{f()},[(I=(R=e.builderContextSignal.content)==null?void 0:R.data)==null?void 0:I.jsCode,e.builderContextSignal.rootState]),o.useEffect(()=>{C()},[(T=(P=e.builderContextSignal.content)==null?void 0:P.data)==null?void 0:T.httpRequests]),o.useEffect(()=>{E()},[e.builderContextSignal.rootState]),o.useEffect(()=>()=>{a.isBrowser()&&(window.removeEventListener("message",S),window.removeEventListener("builder:component:stateChangeListenerActivated",E))},[]),t.jsx(Q.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content?t.jsx(t.Fragment,{children:o.createElement("div",{key:g,ref:c,onClick:n=>N(n),"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},e.children)}):null})}exports.BlockWrapper=A;exports.BlocksWrapper=z;exports.Button=W;exports.CustomCode=O;exports.Embed=J;exports.EnableEditor=X;exports.FragmentComponent=D;exports.Image=U;exports.ImgComponent=G;exports.InteractiveElement=V;exports.SectionComponent=H;exports.Video=$;
@@ -1,657 +0,0 @@
1
- "use client";
2
- import { jsxs as w, Fragment as b, jsx as c } from "react/jsx-runtime";
3
- import { g as T, a as N, i as E, b as R, c as G, d as P, e as W, _ as A, f as $, l as Q, h as D, j as X, k as Y, r as Z, s as p, m as ee, n as te, o as ne } from "./bundle-213a8bf7.js";
4
- import { useRef as j, useState as y, useEffect as x, createContext as ie, createElement as ae } from "react";
5
- import { p as ce } from "./USE_SERVER_BUNDLE-e0effb0f.js";
6
- import { useRouter as re } from "next/navigation";
7
- function be(e) {
8
- return /* @__PURE__ */ w(b, { children: [
9
- e.link ? /* @__PURE__ */ c(b, { children: /* @__PURE__ */ c(
10
- "a",
11
- {
12
- ...e.attributes,
13
- href: e.link,
14
- target: e.openLinkInNewTab ? "_blank" : void 0,
15
- role: "button",
16
- children: e.text
17
- }
18
- ) }) : /* @__PURE__ */ c(b, { children: /* @__PURE__ */ c(
19
- "button",
20
- {
21
- ...e.attributes,
22
- style: e.attributes.style,
23
- className: e.attributes.className + " button-5294b10c",
24
- children: e.text
25
- }
26
- ) }),
27
- /* @__PURE__ */ c("style", { children: `.button-5294b10c {
28
- all: unset;
29
- }` })
30
- ] });
31
- }
32
- function ge(e) {
33
- return /* @__PURE__ */ w(b, { children: [
34
- " ",
35
- e.hasChildren ? /* @__PURE__ */ c(b, { children: /* @__PURE__ */ w(
36
- e.Wrapper,
37
- {
38
- ...T({
39
- block: e.block,
40
- context: e.context
41
- }),
42
- ...N({
43
- block: e.block,
44
- rootState: e.context.rootState,
45
- rootSetState: e.context.rootSetState,
46
- localState: e.context.localState,
47
- context: e.context.context,
48
- stripPrefix: !0
49
- }),
50
- children: [
51
- " ",
52
- e.children,
53
- " "
54
- ]
55
- }
56
- ) }) : /* @__PURE__ */ c(b, { children: /* @__PURE__ */ c(
57
- e.Wrapper,
58
- {
59
- ...T({
60
- block: e.block,
61
- context: e.context
62
- }),
63
- ...N({
64
- block: e.block,
65
- rootState: e.context.rootState,
66
- rootSetState: e.context.rootSetState,
67
- localState: e.context.localState,
68
- context: e.context.context,
69
- stripPrefix: !0
70
- })
71
- }
72
- ) }),
73
- " "
74
- ] });
75
- }
76
- function he(e) {
77
- return /* @__PURE__ */ c(
78
- e.Wrapper,
79
- {
80
- ...e.wrapperProps,
81
- attributes: {
82
- ...T({
83
- block: e.block,
84
- context: e.context
85
- }),
86
- ...N({
87
- block: e.block,
88
- rootState: e.context.rootState,
89
- rootSetState: e.context.rootSetState,
90
- localState: e.context.localState,
91
- context: e.context.context
92
- })
93
- },
94
- children: e.children
95
- }
96
- );
97
- }
98
- function fe(e) {
99
- function i() {
100
- var o;
101
- return "builder-blocks" + ((o = e.blocks) != null && o.length ? "" : " no-blocks");
102
- }
103
- function s() {
104
- var o, f;
105
- E() && !((o = e.blocks) != null && o.length) && ((f = window.parent) == null || f.postMessage(
106
- {
107
- type: "builder.clickEmptyBlocks",
108
- data: {
109
- parentElementId: e.parent,
110
- dataPath: e.path
111
- }
112
- },
113
- "*"
114
- ));
115
- }
116
- function h() {
117
- var o, f;
118
- E() && !((o = e.blocks) != null && o.length) && ((f = window.parent) == null || f.postMessage(
119
- {
120
- type: "builder.hoverEmptyBlocks",
121
- data: {
122
- parentElementId: e.parent,
123
- dataPath: e.path
124
- }
125
- },
126
- "*"
127
- ));
128
- }
129
- return /* @__PURE__ */ w(b, { children: [
130
- /* @__PURE__ */ c(
131
- "div",
132
- {
133
- className: i() + " div-02c7a115",
134
- "builder-path": e.path,
135
- "builder-parent-id": e.parent,
136
- style: e.styleProp,
137
- onClick: (o) => s(),
138
- onMouseEnter: (o) => h(),
139
- onKeyPress: (o) => s(),
140
- children: e.children
141
- }
142
- ),
143
- /* @__PURE__ */ c("style", { children: `.div-02c7a115 {
144
- display: flex;
145
- flex-direction: column;
146
- align-items: stretch;
147
- }` })
148
- ] });
149
- }
150
- function Se(e) {
151
- return /* @__PURE__ */ c("span", { children: e.children });
152
- }
153
- function xe(e) {
154
- var o, f, k, S;
155
- function i() {
156
- var g;
157
- const l = e.image || e.src;
158
- if (!l || // We can auto add srcset for cdn.builder.io and shopify
159
- // images, otherwise you can supply this prop manually
160
- !(l.match(/builder\.io/) || l.match(/cdn\.shopify\.com/)))
161
- return e.srcset;
162
- if (e.srcset && ((g = e.image) != null && g.includes("builder.io/api/v1/image"))) {
163
- if (!e.srcset.includes(e.image.split("?")[0]))
164
- return console.debug("Removed given srcset"), R(l);
165
- } else if (e.image && !e.srcset)
166
- return R(l);
167
- return R(l);
168
- }
169
- function s() {
170
- var m;
171
- return (m = i == null ? void 0 : i()) != null && m.match(/builder\.io/) && !e.noWebp ? i().replace(/\?/g, "?format=webp&") : "";
172
- }
173
- function h() {
174
- const m = {
175
- position: "absolute",
176
- height: "100%",
177
- width: "100%",
178
- left: "0px",
179
- top: "0px"
180
- };
181
- return e.aspectRatio ? m : void 0;
182
- }
183
- return /* @__PURE__ */ w(b, { children: [
184
- /* @__PURE__ */ w(b, { children: [
185
- /* @__PURE__ */ w("picture", { children: [
186
- s() ? /* @__PURE__ */ c(b, { children: /* @__PURE__ */ c("source", { type: "image/webp", srcSet: s() }) }) : null,
187
- /* @__PURE__ */ c(
188
- "img",
189
- {
190
- loading: "lazy",
191
- alt: e.altText,
192
- role: e.altText ? "presentation" : void 0,
193
- style: {
194
- objectPosition: e.backgroundPosition || "center",
195
- objectFit: e.backgroundSize || "cover",
196
- ...h()
197
- },
198
- className: "builder-image" + (e.className ? " " + e.className : "") + " img-dbab4030",
199
- src: e.image,
200
- srcSet: i(),
201
- sizes: e.sizes
202
- }
203
- )
204
- ] }),
205
- e.aspectRatio && !((f = (o = e.builderBlock) == null ? void 0 : o.children) != null && f.length && e.fitContent) ? /* @__PURE__ */ c(b, { children: /* @__PURE__ */ c(
206
- "div",
207
- {
208
- className: "builder-image-sizer div-dbab4030",
209
- style: {
210
- paddingTop: e.aspectRatio * 100 + "%"
211
- }
212
- }
213
- ) }) : null,
214
- (S = (k = e.builderBlock) == null ? void 0 : k.children) != null && S.length && e.fitContent ? /* @__PURE__ */ c(b, { children: e.children }) : null,
215
- !e.fitContent && e.children ? /* @__PURE__ */ c(b, { children: /* @__PURE__ */ c("div", { className: "div-dbab4030-2", children: e.children }) }) : null
216
- ] }),
217
- /* @__PURE__ */ c("style", { children: `.img-dbab4030 {
218
- opacity: 1;
219
- transition: opacity 0.2s ease-in-out;
220
- }.div-dbab4030 {
221
- width: 100%;
222
- pointer-events: none;
223
- font-size: 0;
224
- }.div-dbab4030-2 {
225
- display: flex;
226
- flex-direction: column;
227
- align-items: stretch;
228
- position: absolute;
229
- top: 0;
230
- left: 0;
231
- width: 100%;
232
- height: 100%;
233
- }` })
234
- ] });
235
- }
236
- function ve(e) {
237
- return /* @__PURE__ */ c(
238
- "section",
239
- {
240
- ...e.attributes,
241
- style: {
242
- width: "100%",
243
- alignSelf: "stretch",
244
- flexGrow: 1,
245
- boxSizing: "border-box",
246
- maxWidth: e.maxWidth || 1200,
247
- display: "flex",
248
- flexDirection: "column",
249
- alignItems: "stretch",
250
- marginLeft: "auto",
251
- marginRight: "auto"
252
- },
253
- children: e.children
254
- }
255
- );
256
- }
257
- function ye(e) {
258
- const i = j(null), [s, h] = y(() => []), [o, f] = y(() => []);
259
- return x(() => {
260
- var S;
261
- if (!((S = i.current) != null && S.getElementsByTagName) || typeof window > "u")
262
- return;
263
- const k = i.current.getElementsByTagName("script");
264
- for (let m = 0; m < k.length; m++) {
265
- const l = k[m];
266
- if (l.src) {
267
- if (s.includes(l.src))
268
- continue;
269
- s.push(l.src);
270
- const g = document.createElement("script");
271
- g.async = !0, g.src = l.src, document.head.appendChild(g);
272
- } else if (!l.type || [
273
- "text/javascript",
274
- "application/javascript",
275
- "application/ecmascript"
276
- ].includes(l.type)) {
277
- if (o.includes(l.innerText))
278
- continue;
279
- try {
280
- o.push(l.innerText), new Function(l.innerText)();
281
- } catch (g) {
282
- console.warn("`CustomCode`: Error running script:", g);
283
- }
284
- }
285
- }
286
- }, []), /* @__PURE__ */ c(
287
- "div",
288
- {
289
- ref: i,
290
- className: "builder-custom-code" + (e.replaceNodes ? " replace-nodes" : ""),
291
- dangerouslySetInnerHTML: { __html: e.code }
292
- }
293
- );
294
- }
295
- function ke(e) {
296
- const i = j(null), [s, h] = y(() => []), [o, f] = y(() => []), [k, S] = y(() => !1);
297
- function m() {
298
- if (!i.current || !i.current.getElementsByTagName)
299
- return;
300
- const l = i.current.getElementsByTagName("script");
301
- for (let g = 0; g < l.length; g++) {
302
- const v = l[g];
303
- if (v.src && !s.includes(v.src)) {
304
- s.push(v.src);
305
- const C = document.createElement("script");
306
- C.async = !0, C.src = v.src, document.head.appendChild(C);
307
- } else if (G(v) && !o.includes(v.innerText))
308
- try {
309
- o.push(v.innerText), new Function(v.innerText)();
310
- } catch (C) {
311
- console.warn("`Embed`: Error running script:", C);
312
- }
313
- }
314
- }
315
- return x(() => {
316
- i.current && !k && (S(!0), m());
317
- }, [i.current, k]), /* @__PURE__ */ c(
318
- "div",
319
- {
320
- className: "builder-embed",
321
- ref: i,
322
- dangerouslySetInnerHTML: { __html: e.content }
323
- }
324
- );
325
- }
326
- function Ce(e) {
327
- return /* @__PURE__ */ c(
328
- "img",
329
- {
330
- style: {
331
- objectFit: e.backgroundSize || "cover",
332
- objectPosition: e.backgroundPosition || "center"
333
- },
334
- alt: e.altText,
335
- src: e.imgSrc || e.image,
336
- ...e.attributes
337
- },
338
- E() && e.imgSrc || "default-key"
339
- );
340
- }
341
- function we(e) {
342
- var h;
343
- function i() {
344
- return {
345
- ...e.autoPlay === !0 ? {
346
- autoPlay: !0
347
- } : {},
348
- ...e.muted === !0 ? {
349
- muted: !0
350
- } : {},
351
- ...e.controls === !0 ? {
352
- controls: !0
353
- } : {},
354
- ...e.loop === !0 ? {
355
- loop: !0
356
- } : {},
357
- ...e.playsInline === !0 ? {
358
- playsInline: !0
359
- } : {}
360
- };
361
- }
362
- function s() {
363
- return {
364
- ...e.attributes,
365
- ...i()
366
- };
367
- }
368
- return /* @__PURE__ */ c(
369
- "video",
370
- {
371
- ...s(),
372
- preload: e.preload || "metadata",
373
- style: {
374
- width: "100%",
375
- height: "100%",
376
- ...(h = e.attributes) == null ? void 0 : h.style,
377
- objectFit: e.fit,
378
- objectPosition: e.position,
379
- // Hack to get object fit to work as expected and
380
- // not have the video overflow
381
- borderRadius: 1
382
- },
383
- src: e.video || "no-src",
384
- poster: e.posterImage
385
- }
386
- );
387
- }
388
- const oe = ie({
389
- content: null,
390
- context: {},
391
- localState: void 0,
392
- rootSetState() {
393
- },
394
- rootState: {},
395
- apiKey: null,
396
- apiVersion: void 0,
397
- componentInfos: {},
398
- inheritedStyles: {}
399
- });
400
- function Ee(e) {
401
- var F, M, _, q, z;
402
- const i = j(null), [s, h] = y(() => 0);
403
- function o(t) {
404
- var a, r, d, u, V;
405
- const n = {
406
- ...e.builderContextSignal.content,
407
- ...t,
408
- data: {
409
- ...(a = e.builderContextSignal.content) == null ? void 0 : a.data,
410
- ...t == null ? void 0 : t.data
411
- },
412
- meta: {
413
- ...(r = e.builderContextSignal.content) == null ? void 0 : r.meta,
414
- ...t == null ? void 0 : t.meta,
415
- breakpoints: ((d = t == null ? void 0 : t.meta) == null ? void 0 : d.breakpoints) || ((V = (u = e.builderContextSignal.content) == null ? void 0 : u.meta) == null ? void 0 : V.breakpoints)
416
- }
417
- };
418
- ce({
419
- value: n,
420
- key: n.id
421
- }).then(() => {
422
- J.refresh();
423
- });
424
- }
425
- y(() => 0);
426
- const [f, k] = y(
427
- () => !1
428
- );
429
- function S(t) {
430
- var a;
431
- const { data: n } = t;
432
- if (n)
433
- switch (n.type) {
434
- case "builder.configureSdk": {
435
- const r = n.data, { breakpoints: d, contentId: u } = r;
436
- if (!u || u !== ((a = e.builderContextSignal.content) == null ? void 0 : a.id))
437
- return;
438
- d && o({
439
- meta: {
440
- breakpoints: d
441
- }
442
- }), h(s + 1);
443
- break;
444
- }
445
- case "builder.contentUpdate": {
446
- const r = n.data, d = r.key || r.alias || r.entry || r.modelName, u = r.data;
447
- d === e.model && (o(u), h(s + 1));
448
- break;
449
- }
450
- }
451
- }
452
- function m() {
453
- var n, a;
454
- const t = (a = (n = e.builderContextSignal.content) == null ? void 0 : n.data) == null ? void 0 : a.jsCode;
455
- t && D({
456
- code: t,
457
- context: e.context || {},
458
- localState: void 0,
459
- rootState: e.builderContextSignal.rootState,
460
- rootSetState: e.builderContextSignal.rootSetState
461
- });
462
- }
463
- const [l, g] = y(() => ({})), [v, C] = y(() => !1);
464
- function U(t) {
465
- var n, a;
466
- if (e.builderContextSignal.content) {
467
- const r = (n = e.builderContextSignal.content) == null ? void 0 : n.testVariationId, d = (a = e.builderContextSignal.content) == null ? void 0 : a.id;
468
- A({
469
- type: "click",
470
- canTrack: W(e.canTrack),
471
- contentId: d,
472
- apiKey: e.apiKey,
473
- variationId: r !== d ? r : void 0,
474
- ...X(t),
475
- unique: !v
476
- });
477
- }
478
- v || C(!0);
479
- }
480
- function H(t) {
481
- return t.replace(
482
- /{{([^}]+)}}/g,
483
- (n, a) => D({
484
- code: a,
485
- context: e.context || {},
486
- localState: void 0,
487
- rootState: e.builderContextSignal.rootState,
488
- rootSetState: e.builderContextSignal.rootSetState
489
- })
490
- );
491
- }
492
- function O({ url: t, key: n }) {
493
- ne(t).then((a) => a.json()).then((a) => {
494
- var d, u;
495
- const r = {
496
- ...e.builderContextSignal.rootState,
497
- [n]: a
498
- };
499
- (u = (d = e.builderContextSignal).rootSetState) == null || u.call(d, r), l[n] = !0;
500
- }).catch((a) => {
501
- console.error("error fetching dynamic data", t, a);
502
- });
503
- }
504
- function L() {
505
- var n, a;
506
- const t = ((a = (n = e.builderContextSignal.content) == null ? void 0 : n.data) == null ? void 0 : a.httpRequests) ?? {};
507
- Object.entries(t).forEach(([r, d]) => {
508
- if (d && (!l[r] || E())) {
509
- const u = H(d);
510
- O({
511
- url: u,
512
- key: r
513
- });
514
- }
515
- });
516
- }
517
- function I() {
518
- E() && window.dispatchEvent(
519
- new CustomEvent(
520
- "builder:component:stateChange",
521
- {
522
- detail: {
523
- state: Y(e.builderContextSignal.rootState),
524
- ref: {
525
- name: e.model
526
- }
527
- }
528
- }
529
- )
530
- );
531
- }
532
- function B(t) {
533
- h(s + 1), window.addEventListener("message", S), Z(), p({
534
- ...e.locale ? {
535
- locale: e.locale
536
- } : {},
537
- ...e.includeRefs ? {
538
- includeRefs: e.includeRefs
539
- } : {},
540
- ...e.enrich ? {
541
- enrich: e.enrich
542
- } : {}
543
- }), Object.values(
544
- e.builderContextSignal.componentInfos
545
- ).forEach((n) => {
546
- var r;
547
- const a = ee(n);
548
- (r = window.parent) == null || r.postMessage(a, "*");
549
- }), window.addEventListener(
550
- "builder:component:stateChangeListenerActivated",
551
- I
552
- );
553
- }
554
- function K(t) {
555
- const n = new URL(location.href).searchParams, a = n.get("builder.preview"), r = n.get(
556
- `builder.preview.${a}`
557
- ), d = n.get("apiKey") || n.get("builder.space");
558
- a === e.model && d === e.apiKey && (!e.content || r === e.content.id) && te({
559
- model: e.model,
560
- apiKey: e.apiKey,
561
- apiVersion: e.builderContextSignal.apiVersion
562
- }).then((u) => {
563
- u && o(u);
564
- });
565
- }
566
- const J = re();
567
- return x(() => {
568
- var t;
569
- return (t = i.current) == null || t.addEventListener(
570
- "initeditingbldr",
571
- B
572
- ), () => {
573
- var n;
574
- return (n = i.current) == null ? void 0 : n.removeEventListener(
575
- "initeditingbldr",
576
- B
577
- );
578
- };
579
- }, []), x(() => {
580
- var t;
581
- return (t = i.current) == null || t.addEventListener(
582
- "initpreviewingbldr",
583
- K
584
- ), () => {
585
- var n;
586
- return (n = i.current) == null ? void 0 : n.removeEventListener(
587
- "initpreviewingbldr",
588
- K
589
- );
590
- };
591
- }, []), x(() => {
592
- var t, n;
593
- if (P()) {
594
- if (E() && i.current && i.current.dispatchEvent(new CustomEvent("initeditingbldr")), e.builderContextSignal.content && W(e.canTrack)) {
595
- const r = (t = e.builderContextSignal.content) == null ? void 0 : t.testVariationId, d = (n = e.builderContextSignal.content) == null ? void 0 : n.id, u = e.apiKey;
596
- A({
597
- type: "impression",
598
- canTrack: !0,
599
- contentId: d,
600
- apiKey: u,
601
- variationId: r !== d ? r : void 0
602
- });
603
- }
604
- $() && i.current;
605
- }
606
- }, []), x(() => {
607
- e.apiKey || Q.error(
608
- "No API key provided to `RenderContent` component. This can cause issues. Please provide an API key using the `apiKey` prop."
609
- ), m(), L(), I();
610
- }, []), x(() => {
611
- }, [e.content]), x(() => {
612
- P() && (window.removeEventListener("message", S), window.addEventListener("message", S));
613
- }, [f]), x(() => {
614
- m();
615
- }, [
616
- (M = (F = e.builderContextSignal.content) == null ? void 0 : F.data) == null ? void 0 : M.jsCode,
617
- e.builderContextSignal.rootState
618
- ]), x(() => {
619
- L();
620
- }, [(q = (_ = e.builderContextSignal.content) == null ? void 0 : _.data) == null ? void 0 : q.httpRequests]), x(() => {
621
- I();
622
- }, [e.builderContextSignal.rootState]), x(() => () => {
623
- P() && (window.removeEventListener("message", S), window.removeEventListener(
624
- "builder:component:stateChangeListenerActivated",
625
- I
626
- ));
627
- }, []), /* @__PURE__ */ c(oe.Provider, { value: e.builderContextSignal, children: e.builderContextSignal.content ? /* @__PURE__ */ c(b, { children: /* @__PURE__ */ ae(
628
- "div",
629
- {
630
- key: s,
631
- ref: i,
632
- onClick: (t) => U(t),
633
- "builder-content-id": (z = e.builderContextSignal.content) == null ? void 0 : z.id,
634
- "builder-model": e.model,
635
- ...e.showContent ? {} : {
636
- hidden: !0,
637
- "aria-hidden": !0
638
- },
639
- className: e.classNameProp
640
- },
641
- e.children
642
- ) }) : null });
643
- }
644
- export {
645
- ge as B,
646
- ye as C,
647
- ke as E,
648
- Se as F,
649
- he as I,
650
- ve as S,
651
- we as V,
652
- fe as a,
653
- be as b,
654
- xe as c,
655
- Ce as d,
656
- Ee as e
657
- };