@builder.io/sdk-react 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/browser/blocks-exports.cjs +92 -64
- package/lib/browser/blocks-exports.mjs +1765 -1650
- package/lib/browser/index.cjs +1 -1
- package/lib/browser/index.mjs +1 -1
- package/lib/browser/server-entry-6a0d3985.cjs +2 -0
- package/lib/{edge/server-entry-e9974799.js → browser/server-entry-a97b474c.js} +272 -265
- package/lib/browser/server-entry.cjs +1 -1
- package/lib/browser/server-entry.mjs +1 -1
- package/lib/edge/{accordion-8ef468e5.js → accordion-39aaa10f.js} +1 -1
- package/lib/edge/{accordion-94839d7d.cjs → accordion-f19408f1.cjs} +1 -1
- package/lib/edge/{blocks-548ec8c2.js → blocks-204bcb03.js} +179 -176
- package/lib/edge/{blocks-7e8837dc.cjs → blocks-bd4d19a4.cjs} +3 -3
- package/lib/edge/blocks-exports.cjs +1 -1
- package/lib/edge/blocks-exports.mjs +2 -2
- package/lib/edge/{button-66c37b9c.cjs → button-39adadab.cjs} +1 -1
- package/lib/edge/{button-09f38c2e.js → button-eb4a1fce.js} +2 -2
- package/lib/edge/{columns-67ded4b4.cjs → columns-3954e4e2.cjs} +3 -3
- package/lib/edge/{columns-42cbe467.js → columns-d3cef236.js} +9 -9
- package/lib/edge/content-variants-0c41aa3b.cjs +302 -0
- package/lib/edge/{content-variants-5a4eecaf.js → content-variants-68bbb30c.js} +650 -367
- package/lib/edge/{custom-code-ea534e98.cjs → custom-code-eded3b35.cjs} +1 -1
- package/lib/edge/{custom-code-cf216b27.js → custom-code-f8374f7b.js} +1 -1
- package/lib/edge/{embed-12b85639.js → embed-2b4ce9d5.js} +1 -1
- package/lib/edge/{embed-7ca4af6e.cjs → embed-44dee332.cjs} +1 -1
- package/lib/edge/form-1493caf1.cjs +1 -0
- package/lib/edge/form-9faf63c9.js +178 -0
- package/lib/edge/{get-class-prop-name-316a93c9.cjs → get-class-prop-name-a9265175.cjs} +1 -1
- package/lib/edge/{get-class-prop-name-90df5962.js → get-class-prop-name-cc48fc17.js} +1 -1
- package/lib/edge/{image-e38bd9e0.cjs → image-cce92f6c.cjs} +2 -2
- package/lib/edge/{image-acc1c00c.js → image-d87761af.js} +18 -18
- package/lib/edge/{img-ee2838af.js → img-58c08dd4.js} +1 -1
- package/lib/edge/{img-81a7f4d7.cjs → img-b8d85bad.cjs} +1 -1
- package/lib/edge/index.cjs +1 -1
- package/lib/edge/index.mjs +1 -1
- package/lib/edge/{input-b8907c7d.js → input-a7c01b3a.js} +1 -1
- package/lib/edge/{input-231ec63f.cjs → input-d988f887.cjs} +1 -1
- package/lib/edge/personalization-container-2f2bfa1b.cjs +1 -0
- package/lib/edge/personalization-container-9ae00624.js +208 -0
- package/lib/edge/{select-b1650a75.cjs → select-03b307f2.cjs} +1 -1
- package/lib/edge/{select-ffee7a69.js → select-4f03decc.js} +1 -1
- package/lib/{node/server-entry-2b91f2d9.js → edge/server-entry-0fe1fd76.js} +306 -303
- package/lib/edge/server-entry-e13b9b35.cjs +2 -0
- package/lib/edge/server-entry.cjs +1 -1
- package/lib/edge/server-entry.mjs +1 -1
- package/lib/edge/{slot-ddddba8d.cjs → slot-125b0593.cjs} +1 -1
- package/lib/edge/{slot-fe93ec42.js → slot-ff90c844.js} +3 -3
- package/lib/edge/{symbol-c266ba83.js → symbol-7558aa24.js} +2 -2
- package/lib/edge/{symbol-d9175a66.cjs → symbol-da3ec542.cjs} +1 -1
- package/lib/edge/{tabs-f76f757a.cjs → tabs-3cf7cfd3.cjs} +1 -1
- package/lib/edge/{tabs-3481a6f6.js → tabs-a9e56d82.js} +3 -3
- package/lib/node/blocks-exports.cjs +92 -64
- package/lib/node/blocks-exports.mjs +1675 -1560
- package/lib/node/index.cjs +1 -1
- package/lib/node/index.mjs +3 -3
- package/lib/node/init.cjs +1 -1
- package/lib/node/init.mjs +3 -3
- package/lib/{browser/server-entry-d0b98fb0.js → node/server-entry-23f9b44b.js} +205 -199
- package/lib/node/server-entry-ceef853b.cjs +2 -0
- package/lib/node/server-entry.cjs +1 -1
- package/lib/node/server-entry.mjs +1 -1
- package/lib/node/{setIvm-26e766c5.cjs → setIvm-71bce8c3.cjs} +1 -1
- package/lib/node/{setIvm-419a94e0.js → setIvm-b29cbc40.js} +1 -1
- package/lib/node/setIvm.cjs +1 -1
- package/lib/node/setIvm.mjs +2 -2
- package/lib/node/{should-force-browser-runtime-in-node-67506521.js → should-force-browser-runtime-in-node-5a2ea9eb.js} +1 -1
- package/lib/node/{should-force-browser-runtime-in-node-fe3d9cb0.cjs → should-force-browser-runtime-in-node-e0147364.cjs} +1 -1
- package/package.json +2 -2
- package/types/blocks/personalization-container/helpers/inlined-fns.d.ts +4 -1
- package/types/blocks/personalization-container/helpers.d.ts +24 -4
- package/types/blocks/personalization-container/personalization-container.types.d.ts +2 -2
- package/types/components/blocks/blocks-wrapper.d.ts +13 -1
- package/types/components/blocks/blocks.types.d.ts +1 -1
- package/types/constants/sdk-version.d.ts +1 -1
- package/types/helpers/no-serialize-wrapper.d.ts +1 -0
- package/types/helpers/user-attributes.d.ts +6 -2
- package/lib/browser/server-entry-8ea5d047.cjs +0 -2
- package/lib/edge/content-variants-cf107f82.cjs +0 -137
- package/lib/edge/form-85ea06df.cjs +0 -1
- package/lib/edge/form-f1188ad2.js +0 -166
- package/lib/edge/personalization-container-896a298a.js +0 -384
- package/lib/edge/personalization-container-95cba946.cjs +0 -138
- package/lib/edge/server-entry-1b560ddb.cjs +0 -2
- package/lib/node/server-entry-03fc1c6d.cjs +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";const m="react",v="[Builder.io]: ",d={log:(...e)=>console.log(v,...e),error:(...e)=>console.error(v,...e),warn:(...e)=>console.warn(v,...e),debug:(...e)=>console.debug(v,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const be=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},G=e=>e instanceof URLSearchParams?be(e):e,$=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function ye(){return c()&&window.self!==window.top}function z(e){return ye()&&$(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const we=()=>{if(c()){const e=new URL(location.href);return e.pathname===""&&(e.pathname="/"),e}else return console.warn("Cannot get location for tracking in non-browser environment"),null},Ee=()=>typeof navigator=="object"&&navigator.userAgent||"",J=()=>{const e=Ee(),t={Android(){return e.match(/Android/i)},BlackBerry(){return e.match(/BlackBerry/i)},iOS(){return e.match(/iPhone|iPod/i)},Opera(){return e.match(/Opera Mini/i)},Windows(){return e.match(/IEMobile/i)||e.match(/WPDesktop/i)},any(){return t.Android()||t.BlackBerry()||t.iOS()||t.Opera()||t.Windows()||m==="reactNative"}},n=e.match(/Tablet|iPad/i),r=we();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},p=e=>e!=null;function Ie(e){const t=e||(c()?window.location.search:void 0);return t?$(t).indexOf("builder.preview=")!==-1:!1}const ve=e=>({type:"builder.registerComponent",data:C(e)}),Ae=e=>{const t=e.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(t);return`return (${!t.startsWith("function")&&!t.startsWith("async")&&!t.startsWith("(")&&!n?"function ":""}${t}).apply(this, arguments)`};function C(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?Ae(n):n))}const V={};function X(e,t){e==="plugin"&&(t=C(t));let n=V[e];if(n||(n=V[e]=[]),n.push(t),c()){const r={type:"builder.register",data:{type:e,info:t}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}const D={};function ke(e){if(c()){Object.assign(D,e);const t={type:"builder.settingsChange",data:D};parent.postMessage(t,"*")}}const F="builder.",Ue="options.",O=e=>{if(!e)return{};const t=G(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(F)){const s=r.replace(F,"").replace(Ue,"");n[s]=t[r]}}),n},Te=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return O(e)},H="4.0.10",Q=()=>({"X-Builder-SDK":m,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":H}),Ce=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},A=({name:e,canTrack:t})=>{var n;try{return t?(n=document.cookie.split("; ").find(r=>r.startsWith(`${e}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},Y=async e=>A(e),Oe=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),Pe=[["secure",""],["SameSite","None"]],Re=({name:e,value:t,expires:n})=>{const s=(c()?location.protocol==="https:":!0)?Pe:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...o,["path","/"],["domain",Ce(window.location.hostname)],...s];return Oe(i)},P=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const s=Re({name:e,value:t,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}};function Be(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}function Z(){return Be().replace(/-/g,"")}const q="builderSessionId",xe=async({canTrack:e})=>{if(!e)return;const t=await Y({name:q,canTrack:e});if(p(t))return t;{const n=_e();return Le({id:n,canTrack:e}),n}},_e=()=>Z(),Le=({id:e,canTrack:t})=>P({name:q,value:e,canTrack:t}),ee=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Ne=({key:e,canTrack:t})=>{var n;try{return t?(n=ee())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ve=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=ee())==null||r.setItem(e,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},te="builderVisitorId",De=({canTrack:e})=>{if(!e)return;const t=Ne({key:te,canTrack:e});if(p(t))return t;{const n=Fe();return Me({id:n,canTrack:e}),n}},Fe=()=>Z(),Me=({id:e,canTrack:t})=>Ve({key:te,value:e,canTrack:t});function ne(e){var t;typeof process!="undefined"&&((t=process.env)!=null&&t.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(e)}const Ke=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await xe({canTrack:e}),n=De({canTrack:e});return{sessionId:t,visitorId:n}},We=async({type:e,canTrack:t,apiKey:n,metadata:r,...s})=>({type:e,data:{...s,metadata:{url:location.href,...r},...await Ke({canTrack:t}),userAttributes:J(),ownerId:n}});async function re({apiHost:e,...t}){if(!t.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!t.canTrack||z()||!(c()||m==="reactNative"))return;const r=`${e||"https://cdn.builder.io"}/api/v1/track`;return ne(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await We(t)]}),headers:{"content-type":"application/json",...Q()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const je=e=>re({...e,canTrack:!0}),Ge=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function se(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Ge).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}const $e=()=>{X("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let M=!1;const oe=e=>{var t,n;M||(M=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:m,version:H,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,modelName:e.modelName,apiKey:e.apiKey,supportsXSmallBreakpoint:!0,blockLevelPersonalization:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var o,i;if(!se(e.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,y=s.data.arguments||[],S=s.data.id,w=new Function(u);let l,g=null;try{l=w.apply(null,y)}catch(h){g=h}g?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:S,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var E;(E=window.parent)==null||E.postMessage({type:"builder.evaluateResult",data:{id:S,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:S}},"*");break}}})))},ie=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!se(t,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.resetState":{const o=s.data,i=o.model,u=o==null?void 0:o.state;i===e&&u&&n.stateUpdate(u);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===e&&n.contentUpdate(u);break}}},ze=({model:e,apiKey:t,callback:n,trustedHosts:r})=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};oe({modelName:e,apiKey:t});const s=ie({callbacks:{contentUpdate:n,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:e,trustedHosts:r});return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},Je="builder.tests",R=e=>`${Je}.${e}`,Xe=({contentId:e})=>Y({name:R(e),canTrack:!0}),He=({contentId:e})=>A({name:R(e),canTrack:!0}),Qe=({contentId:e,value:t})=>P({name:R(e),value:t,canTrack:!0}),ae=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,Ye=({id:e,variations:t})=>{var s;let n=0;const r=Math.random();for(const o in t){const i=(s=t[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return e},ce=e=>{const t=Ye(e);return Qe({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},ue=({item:e,testGroupId:t})=>{const n=e.variations[t];return t===e.id||!n?{testVariationId:e.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===e.id?"Default":"")}},Ze=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!ae(e))return e;const n=He({contentId:e.id})||ce({variations:e.variations,id:e.id}),r=ue({item:e,testGroupId:n});return{...e,...r}},qe=async({item:e,canTrack:t})=>{if(!t||!ae(e))return e;const r=await Xe({contentId:e.id})||ce({variations:e.variations,id:e.id}),s=ue({item:e,testGroupId:r});return{...e,...s}};const K="builder.userAttributes";function W(){let e=!0;const t=new Set;return{setUserAttributes(n){if(!c())return;const r={...this.getUserAttributes(),...n};P({name:K,value:JSON.stringify(r),canTrack:e}),t.forEach(s=>s(r))},getUserAttributes(){return c()?JSON.parse(A({name:K,canTrack:e})||"{}"):{}},subscribeOnUserAttributesChange(n,{fireImmediately:r}={}){return t.add(n),r&&n(this.getUserAttributes()),function(){t.delete(n)}},setCanTrack(n){e=n}}}let U;c()&&m==="qwik"?(window.__BUILDER_USER_ATTRIBUTES_SERVICE__||(window.__BUILDER_USER_ATTRIBUTES_SERVICE__=W()),U=window.__BUILDER_USER_ATTRIBUTES_SERVICE__):U=W();const B=U,et=e=>{B.setUserAttributes(e)},le=e=>{const t=p(e)?e:!0;return B.setCanTrack(t),t};function tt(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function nt(){const e=tt().fetch;if(typeof e=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
+
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return e}const rt=nt();function T(e,t=null,n="."){return Object.keys(e).reduce((r,s)=>{const o=e[s],i=[t,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...T(o,i,n)}:{...r,[i]:o}},{})}function de(e,t,n={}){for(const r in e){const s=e[r],o=t?t+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?de(s,o,n):n[o]=s}return n}function st(e){const t={};for(const n in e){const r=n.split(".");let s=t;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=e[n]:(s[i]=s[i]||{},s=s[i])}}return t}const ot="v3",j=e=>typeof e=="number"&&!isNaN(e)&&e>=0,x=e=>{const{limit:t=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:y=ot,fields:S,omit:w,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:E,includeUnpublished:_,apiHost:pe}=e;if(!o)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const me=t!==1,Se=pe||"https://cdn.builder.io",a=new URL(`${Se}/api/${y}/content/${s}`);a.searchParams.set("apiKey",o),a.searchParams.set("limit",String(t)),a.searchParams.set("noTraverse",String(me)),a.searchParams.set("includeRefs",String(!0));const k=u||(n==null?void 0:n.locale);let b=n||{};if(k&&(a.searchParams.set("locale",k),b={locale:k,...b}),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",w!=null?w:"meta.componentsUsed"),S&&a.searchParams.set("fields",S),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof _=="boolean"&&a.searchParams.set("includeUnpublished",String(_)),g&&j(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&j(h)&&a.searchParams.set("staleCacheSeconds",String(h)),E){const f=T({sort:E});for(const I in f)a.searchParams.set(I,JSON.stringify(f[I]))}const L={...Te(),...G(e.options||{})};b={...b,...at(L)};const N=T(L);for(const f in N)a.searchParams.set(f,String(N[f]));if(Object.keys(b).length>0&&a.searchParams.set("userAttributes",JSON.stringify(b)),r){const f=de({query:r});for(const I in f)a.searchParams.set(I,JSON.stringify(f[I]))}return a},it=e=>{const t={};for(const n in e)n.startsWith("userAttributes.")&&(t[n]=e[n],delete e[n]);return t},at=e=>{if(c()&&e.preview==="BUILDER_STUDIO"){e["userAttributes.urlPath"]=window.location.pathname,e["userAttributes.host"]=window.location.host;const t=it(e),{userAttributes:n}=st(t);return n}return{}},ct=e=>"results"in e;async function fe(e){const t=await he({...e,limit:1});return t&&t[0]||null}const ut=async e=>{var i,u;const t=x(e),n=(i=e.fetch)!=null?i:rt,r={...e.fetchOptions,headers:{...(u=e.fetchOptions)==null?void 0:u.headers,...Q()}};return await(await n(t.href,r)).json()},ge=async(e,t,n=x(e))=>{const r=le(e.canTrack);if(n.search.includes("preview="),!r||!(c()||m==="reactNative"))return t.results;try{const s=[];for(const o of t.results)s.push(await qe({item:o,canTrack:r}));t.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return t.results};async function he(e){const t=x(e),n=await ut(e);if(!ct(n))throw d.error("Error fetching data. ",{url:t,content:n,options:e}),n;return ge(e,n)}const lt=async e=>{var r,s,o;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((s=e.userAttributes)==null?void 0:s.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:O(e.searchParams||((o=e.url)==null?void 0:o.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await fe(n)}};exports.MSG_PREFIX=v;exports.TARGET=m;exports._processContentResult=ge;exports._track=re;exports.checkIsDefined=p;exports.createEditorListener=ie;exports.createRegisterComponentMessage=ve;exports.fetchBuilderProps=lt;exports.fetchEntries=he;exports.fetchOneEntry=fe;exports.getBuilderSearchParams=O;exports.getCookieSync=A;exports.getDefaultCanTrack=le;exports.getUserAttributes=J;exports.handleABTestingSync=Ze;exports.isBrowser=c;exports.isEditing=z;exports.isPreviewing=Ie;exports.logFetch=ne;exports.logger=d;exports.register=X;exports.registerInsertMenu=$e;exports.serializeIncludingFunctions=C;exports.setClientUserAttributes=et;exports.setEditorSettings=ke;exports.setupBrowserForEditing=oe;exports.subscribeToEditor=ze;exports.track=je;exports.userAttributesService=B;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-ceef853b.cjs");exports._processContentResult=e._processContentResult;exports.createRegisterComponentMessage=e.createRegisterComponentMessage;exports.fetchBuilderProps=e.fetchBuilderProps;exports.fetchEntries=e.fetchEntries;exports.fetchOneEntry=e.fetchOneEntry;exports.getBuilderSearchParams=e.getBuilderSearchParams;exports.isEditing=e.isEditing;exports.isPreviewing=e.isPreviewing;exports.register=e.register;exports.setEditorSettings=e.setEditorSettings;exports.subscribeToEditor=e.subscribeToEditor;exports.track=e.track;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-
|
|
1
|
+
import { _processContentResult as r, createRegisterComponentMessage as s, fetchBuilderProps as i, fetchEntries as n, fetchOneEntry as o, getBuilderSearchParams as c, isEditing as g, isPreviewing as a, register as d, setEditorSettings as E, subscribeToEditor as f, track as h } from "./server-entry-23f9b44b.js";
|
|
2
2
|
export {
|
|
3
3
|
r as _processContentResult,
|
|
4
4
|
s as createRegisterComponentMessage,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const serverEntry=require("./server-entry-
|
|
1
|
+
"use strict";const serverEntry=require("./server-entry-ceef853b.cjs"),getFunctionArguments=({builder:e,context:t,event:s,state:r})=>Object.entries({state:r,Builder:e,builder:e,context:t,event:s}),getBuilderGlobals=()=>({isEditing:serverEntry.isEditing(),isBrowser:serverEntry.isBrowser(),isServer:!serverEntry.isBrowser(),getUserAttributes:()=>serverEntry.getUserAttributes()}),parseCode=(e,{isExpression:t=!0})=>t&&!(e.includes(";")||e.includes(" return ")||e.trim().startsWith("return "))?`return (${e});`:e;function flattenState({rootState:e,localState:t,rootSetState:s}){return new Proxy(e,{get:(r,n)=>{if(t&&n in t)return t[n];const o=r[n];return typeof o=="object"&&o!==null?flattenState({rootState:o,localState:void 0,rootSetState:s?i=>{r[n]=i,s(r)}:void 0}):o},set:(r,n,o)=>{if(t&&n in t)throw new Error("Writing to local state is not allowed as it is read-only.");return r[n]=o,s==null||s(r),!0}})}const SDK_NAME_FOR_TARGET=(()=>{switch(serverEntry.TARGET){case"rsc":return"react-nextjs";case"reactNative":return"react-native";default:return serverEntry.TARGET}})(),SDK_NAME=`@builder.io/sdk-${SDK_NAME_FOR_TARGET}`,fastClone=e=>JSON.parse(JSON.stringify(e)),set=(e,t,s)=>{if(Object(e)!==e)return e;const r=Array.isArray(t)?t:t.toString().match(/[^.[\]]+/g);return r.slice(0,-1).reduce((n,o,i)=>Object(n[o])===n[o]?n[o]:n[o]=Math.abs(Number(r[i+1]))>>0===+r[i+1]?[]:{},e)[r[r.length-1]]=s,e},noop=()=>{};let safeDynamicRequire=noop;try{safeDynamicRequire=eval("require")}catch(e){}const getSyncValName=e=>`bldr_${e}_sync`,BUILDER_SET_STATE_NAME="BUILDER_SET_STATE",INJECTED_IVM_GLOBAL="BUILDER_IVM",REF_TO_PROXY_FN=`
|
|
2
2
|
var refToProxy = (obj) => {
|
|
3
3
|
if (typeof obj !== 'object' || obj === null) {
|
|
4
4
|
return obj;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isEditing, isBrowser, getUserAttributes, TARGET, logger, MSG_PREFIX } from "./server-entry-
|
|
1
|
+
import { isEditing, isBrowser, getUserAttributes, TARGET, logger, MSG_PREFIX } from "./server-entry-23f9b44b.js";
|
|
2
2
|
const getFunctionArguments = ({
|
|
3
3
|
builder: e,
|
|
4
4
|
context: t,
|
package/lib/node/setIvm.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./setIvm-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./setIvm-71bce8c3.cjs");require("./server-entry-ceef853b.cjs");exports.setIvm=e.setIvm;
|
package/lib/node/setIvm.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { checkIsDefined as i, logger as t } from "./server-entry-
|
|
1
|
+
import { checkIsDefined as i, logger as t } from "./server-entry-23f9b44b.js";
|
|
2
2
|
function a() {
|
|
3
3
|
var o;
|
|
4
4
|
return typeof process != "undefined" && i((o = process == null ? void 0 : process.versions) == null ? void 0 : o.node);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const s=require("./server-entry-
|
|
1
|
+
"use strict";const s=require("./server-entry-ceef853b.cjs");function t(){var e;return typeof process!="undefined"&&s.checkIsDefined((e=process==null?void 0:process.versions)==null?void 0:e.node)}const c=({shouldLogWarning:e})=>{var o;if(!t())return!1;const n=process.arch==="arm64",r=process.version.startsWith("v20"),i=(o=process.env.NODE_OPTIONS)==null?void 0:o.includes("--no-node-snapshot");return n&&r&&!i?(e&&s.logger.log("Skipping usage of `isolated-vm` to avoid crashes in Node v20 on an arm64 machine.\n If you would like to use the `isolated-vm` package on this machine, please provide the `NODE_OPTIONS=--no-node-snapshot` config to your Node process.\n See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.\n "),!0):!1};exports.shouldForceBrowserRuntimeInNode=c;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@builder.io/sdk-react",
|
|
3
3
|
"description": "Builder.io SDK for React",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.10",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/react",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -132,7 +132,7 @@
|
|
|
132
132
|
"react": "^18.2.0",
|
|
133
133
|
"recast": "^0.23.4",
|
|
134
134
|
"typescript": "^4.9.4",
|
|
135
|
-
"vite": "^4.5.
|
|
135
|
+
"vite": "^4.5.11"
|
|
136
136
|
},
|
|
137
137
|
"nx": {
|
|
138
138
|
"targets": {
|
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
* They cannot import anything.
|
|
4
4
|
*/
|
|
5
5
|
import type { Query, UserAttributes } from '../helpers';
|
|
6
|
+
import { type PersonalizationContainerProps } from '../personalization-container.types';
|
|
6
7
|
export declare function filterWithCustomTargeting(userAttributes: UserAttributes, query: Query[], startDate?: string, endDate?: string): boolean;
|
|
7
|
-
export declare
|
|
8
|
+
export declare function updateVisibilityStylesScript(variants: PersonalizationContainerProps['variants'], blockId: string, isHydrationTarget: boolean, locale?: string): void;
|
|
9
|
+
export declare const 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}";
|
|
8
10
|
export declare const 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}";
|
|
11
|
+
export declare const 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}";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BuilderBlock } from '../../types/builder-block';
|
|
2
|
+
import type { Target } from '../../types/targets';
|
|
2
3
|
import type { PersonalizationContainerProps } from './personalization-container.types';
|
|
4
|
+
export declare const DEFAULT_INDEX = "default";
|
|
3
5
|
export type UserAttributes = {
|
|
4
6
|
date?: string | Date;
|
|
5
7
|
urlPath?: string;
|
|
@@ -12,6 +14,25 @@ export type Query = {
|
|
|
12
14
|
operator: QueryOperator;
|
|
13
15
|
value: QueryValue;
|
|
14
16
|
};
|
|
17
|
+
type BlocksToRenderReturnType = {
|
|
18
|
+
blocks: BuilderBlock[];
|
|
19
|
+
path: string;
|
|
20
|
+
index: number | typeof DEFAULT_INDEX;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* SDKs that support Variant Containers
|
|
24
|
+
*/
|
|
25
|
+
export declare const SDKS_SUPPORTING_PERSONALIZATION: Target[];
|
|
26
|
+
/**
|
|
27
|
+
* After hydration, we reset the tree
|
|
28
|
+
* These SDKs handle Personalization Container in a special way:
|
|
29
|
+
* - first, the inlined script will help us add `display: none`, `aria-hidden: true` and `hidden: true` to the non-winning variants
|
|
30
|
+
* - then, on mount / when the component is hydrated - we reset the tree with only the winning variant and deleting the entire tree
|
|
31
|
+
*
|
|
32
|
+
* This helps us to avoid flicker and show the correct / winning variant initially and then once we've hydrated we show the winning variant
|
|
33
|
+
* and keep a track of the cookies to update to the correct variant dynamically when the cookie updates.
|
|
34
|
+
*/
|
|
35
|
+
export declare const SDKS_REQUIRING_RESET_APPROACH: Target[];
|
|
15
36
|
export declare function checkShouldRenderVariants(variants: PersonalizationContainerProps['variants'], canTrack: boolean): boolean;
|
|
16
37
|
export declare function getBlocksToRender({ variants, previewingIndex, isHydrated, filteredVariants, fallbackBlocks }: {
|
|
17
38
|
variants: PersonalizationContainerProps['variants'];
|
|
@@ -19,9 +40,8 @@ export declare function getBlocksToRender({ variants, previewingIndex, isHydrate
|
|
|
19
40
|
isHydrated: boolean;
|
|
20
41
|
filteredVariants: PersonalizationContainerProps['variants'];
|
|
21
42
|
fallbackBlocks?: BuilderBlock[];
|
|
22
|
-
}):
|
|
23
|
-
|
|
24
|
-
path: string | undefined;
|
|
25
|
-
};
|
|
43
|
+
}): BlocksToRenderReturnType;
|
|
44
|
+
export declare const getInitPersonalizationVariantsFnsScriptString: () => string;
|
|
26
45
|
export declare const getPersonalizationScript: (variants: PersonalizationContainerProps['variants'], blockId: string, locale?: string) => string;
|
|
46
|
+
export declare const getUpdateVisibilityStylesScript: (variants: PersonalizationContainerProps['variants'], blockId: string, locale?: string) => string;
|
|
27
47
|
export { filterWithCustomTargeting } from './helpers/inlined-fns';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BuilderBlock } from '../../types/builder-block';
|
|
2
|
-
import type { BuilderDataProps } from '../../types/builder-props';
|
|
2
|
+
import type { BuilderComponentsProp, BuilderDataProps } from '../../types/builder-props';
|
|
3
3
|
import type { Query } from './helpers';
|
|
4
4
|
export type PersonalizationContainerProps = {
|
|
5
5
|
children?: any;
|
|
@@ -11,4 +11,4 @@ export type PersonalizationContainerProps = {
|
|
|
11
11
|
startDate?: string;
|
|
12
12
|
endDate?: string;
|
|
13
13
|
}>;
|
|
14
|
-
} & BuilderDataProps;
|
|
14
|
+
} & BuilderDataProps & BuilderComponentsProp;
|
|
@@ -9,7 +9,19 @@ export type BlocksWrapperProps = {
|
|
|
9
9
|
*/
|
|
10
10
|
BlocksWrapper: any;
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Props to be applied to the wrapping element of blocks. Can be set in two ways:
|
|
13
|
+
* 1. Globally via `<Content blocksWrapperProps={{...}}/>` - applies to all blocks wrappers in the Content
|
|
14
|
+
* 2. Locally via `<Blocks BlocksWrapperProps={{...}}/>` - applies only to this specific blocks instance and overrides global props
|
|
15
|
+
*
|
|
16
|
+
* For merging both global and local props, spread the context props before adding your own:
|
|
17
|
+
* ```
|
|
18
|
+
* <Blocks
|
|
19
|
+
* BlocksWrapperProps={{
|
|
20
|
+
* ...builderContext.BlocksWrapperProps,
|
|
21
|
+
* 'data-test-id': 'my-test-id'
|
|
22
|
+
* }}
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
13
25
|
*/
|
|
14
26
|
BlocksWrapperProps: any;
|
|
15
27
|
children?: any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { BuilderContextInterface, RegisteredComponents } from '../../context/types';
|
|
2
2
|
import type { BlocksWrapperProps } from './blocks-wrapper';
|
|
3
|
-
export type BlocksProps = Partial<Omit<BlocksWrapperProps, 'BlocksWrapper' | '
|
|
3
|
+
export type BlocksProps = Partial<Omit<BlocksWrapperProps, 'BlocksWrapper' | 'classNameProp'>> & {
|
|
4
4
|
context?: BuilderContextInterface;
|
|
5
5
|
registeredComponents?: RegisteredComponents;
|
|
6
6
|
linkComponent?: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "4.0.
|
|
1
|
+
export declare const SDK_VERSION = "4.0.10";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function noSerializeWrapper(fn: () => void): () => void;
|
|
@@ -5,13 +5,17 @@ export declare const USER_ATTRIBUTES_COOKIE_NAME = "builder.userAttributes";
|
|
|
5
5
|
export declare function createUserAttributesService(): {
|
|
6
6
|
setUserAttributes(newAttrs: UserAttributes): void;
|
|
7
7
|
getUserAttributes(): any;
|
|
8
|
-
subscribeOnUserAttributesChange(callback: (attrs: UserAttributes) => void
|
|
8
|
+
subscribeOnUserAttributesChange(callback: (attrs: UserAttributes) => void, { fireImmediately }?: {
|
|
9
|
+
fireImmediately?: boolean;
|
|
10
|
+
}): () => void;
|
|
9
11
|
setCanTrack(value: boolean): void;
|
|
10
12
|
};
|
|
11
13
|
export declare const userAttributesService: {
|
|
12
14
|
setUserAttributes(newAttrs: UserAttributes): void;
|
|
13
15
|
getUserAttributes(): any;
|
|
14
|
-
subscribeOnUserAttributesChange(callback: (attrs: UserAttributes) => void
|
|
16
|
+
subscribeOnUserAttributesChange(callback: (attrs: UserAttributes) => void, { fireImmediately }?: {
|
|
17
|
+
fireImmediately?: boolean;
|
|
18
|
+
}): () => void;
|
|
15
19
|
setCanTrack(value: boolean): void;
|
|
16
20
|
};
|
|
17
21
|
export declare const setClientUserAttributes: (attributes: UserAttributes) => void;
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";const y="react",E="[Builder.io]: ",d={log:(...e)=>console.log(E,...e),error:(...e)=>console.error(E,...e),warn:(...e)=>console.warn(E,...e),debug:(...e)=>console.debug(E,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const me=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},j=e=>e instanceof URLSearchParams?me(e):e,W=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function be(){return c()&&window.self!==window.top}function $(e){return be()&&W(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const ye=()=>{if(c()){const e=new URL(location.href);return e.pathname===""&&(e.pathname="/"),e}else return console.warn("Cannot get location for tracking in non-browser environment"),null},Se=()=>typeof navigator=="object"&&navigator.userAgent||"",G=()=>{const e=Se(),t={Android(){return e.match(/Android/i)},BlackBerry(){return e.match(/BlackBerry/i)},iOS(){return e.match(/iPhone|iPod/i)},Opera(){return e.match(/Opera Mini/i)},Windows(){return e.match(/IEMobile/i)||e.match(/WPDesktop/i)},any(){return t.Android()||t.BlackBerry()||t.iOS()||t.Opera()||t.Windows()||y==="reactNative"}},n=e.match(/Tablet|iPad/i),r=ye();return{urlPath:r==null?void 0:r.pathname,host:(r==null?void 0:r.host)||(r==null?void 0:r.hostname),device:n?"tablet":t.any()?"mobile":"desktop"}},p=e=>e!=null;function we(e){const t=e||(c()?window.location.search:void 0);return t?W(t).indexOf("builder.preview=")!==-1:!1}const ve=e=>({type:"builder.registerComponent",data:C(e)}),ke=e=>{const t=e.toString().trim(),n=/^[a-zA-Z0-9_]+\s*=>/i.test(t);return`return (${!t.startsWith("function")&&!t.startsWith("async")&&!t.startsWith("(")&&!n?"function ":""}${t}).apply(this, arguments)`};function C(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?ke(n):n))}const F={};function J(e,t){e==="plugin"&&(t=C(t));let n=F[e];if(n||(n=F[e]=[]),n.push(t),c()){const r={type:"builder.register",data:{type:e,info:t}};try{parent.postMessage(r,"*"),parent!==window&&window.postMessage(r,"*")}catch(s){console.debug("Could not postmessage",s)}}}const V={};function Ee(e){if(c()){Object.assign(V,e);const t={type:"builder.settingsChange",data:V};parent.postMessage(t,"*")}}const D="builder.",Ie="options.",P=e=>{if(!e)return{};const t=j(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(D)){const s=r.replace(D,"").replace(Ie,"");n[s]=t[r]}}),n},Ae=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},z="4.0.8",X=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":z}),Oe=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},I=({name:e,canTrack:t})=>{var n;try{return t?(n=document.cookie.split("; ").find(r=>r.startsWith(`${e}=`)))==null?void 0:n.split("=")[1]:void 0}catch(r){d.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},H=async e=>I(e),Ce=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),Pe=[["secure",""],["SameSite","None"]],Ue=({name:e,value:t,expires:n})=>{const s=(c()?location.protocol==="https:":!0)?Pe:[[]],o=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...o,["path","/"],["domain",Oe(window.location.hostname)],...s];return Ce(i)},U=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const s=Ue({name:e,value:t,expires:n});document.cookie=s}catch(s){d.warn("[COOKIE] SET error: ",(s==null?void 0:s.message)||s)}};function Te(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e=="x"?t:t&3|8).toString(16)})}function Q(){return Te().replace(/-/g,"")}const Y="builderSessionId",Be=async({canTrack:e})=>{if(!e)return;const t=await H({name:Y,canTrack:e});if(p(t))return t;{const n=xe();return Re({id:n,canTrack:e}),n}},xe=()=>Q(),Re=({id:e,canTrack:t})=>U({name:Y,value:e,canTrack:t}),Z=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Le=({key:e,canTrack:t})=>{var n;try{return t?(n=Z())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ne=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=Z())==null||r.setItem(e,n))}catch(s){console.debug("[LocalStorage] SET error: ",s)}},q="builderVisitorId",Fe=({canTrack:e})=>{if(!e)return;const t=Le({key:q,canTrack:e});if(p(t))return t;{const n=Ve();return De({id:n,canTrack:e}),n}},Ve=()=>Q(),De=({id:e,canTrack:t})=>Ne({key:q,value:e,canTrack:t});function ee(e){var t;typeof process!="undefined"&&((t=process.env)!=null&&t.DEBUG)&&String(process.env.DEBUG)=="true"&&d.log(e)}const Me=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Be({canTrack:e}),n=Fe({canTrack:e});return{sessionId:t,visitorId:n}},Ke=async({type:e,canTrack:t,apiKey:n,metadata:r,...s})=>({type:e,data:{...s,metadata:{url:location.href,...r},...await Me({canTrack:t}),userAttributes:G(),ownerId:n}});async function te({apiHost:e,...t}){if(!t.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(!t.canTrack||$()||!(c()||y==="reactNative"))return;const r=`${e||"https://cdn.builder.io"}/api/v1/track`;return ee(r),fetch(r,{method:"POST",body:JSON.stringify({events:[await Ke(t)]}),headers:{"content-type":"application/json",...X()},mode:"cors"}).catch(s=>{console.error("Failed to track: ",s)})}const _e=e=>te({...e,canTrack:!0}),je=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function ne(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||je).findIndex(s=>s.startsWith("*.")?r.endsWith(s.slice(1)):s===r)>-1}const We=()=>{J("insertMenu",{name:"_default",default:!0,items:[{name:"Box"},{name:"Text"},{name:"Image"},{name:"Columns"},{name:"Core:Section"},{name:"Core:Button"},{name:"Embed"},{name:"Custom Code"}]})};let M=!1;const re=e=>{var t,n;M||(M=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:y,version:z,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0,modelName:e.modelName,apiKey:e.apiKey,supportsXSmallBreakpoint:!0,blockLevelPersonalization:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var o,i;if(!ne(e.trustedHosts,r))return;const{data:s}=r;if(s!=null&&s.type)switch(s.type){case"builder.evaluate":{const u=s.data.text,S=s.data.arguments||[],m=s.data.id,w=new Function(u);let l,g=null;try{l=w.apply(null,S)}catch(h){g=h}g?(o=window.parent)==null||o.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):l&&typeof l.then=="function"?l.then(h=>{var v;(v=window.parent)==null||v.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:l,id:m}},"*");break}}})))},se=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!ne(t,r))return;const{data:s}=r;if(s)switch(s.type){case"builder.configureSdk":{n.configureSdk(s.data);break}case"builder.triggerAnimation":{n.animation(s.data);break}case"builder.resetState":{const o=s.data,i=o.model,u=o==null?void 0:o.state;i===e&&u&&n.stateUpdate(u);break}case"builder.contentUpdate":{const o=s.data,i=o.key||o.alias||o.entry||o.modelName,u=o.data;i===e&&n.contentUpdate(u);break}}},$e=({model:e,apiKey:t,callback:n,trustedHosts:r})=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};re({modelName:e,apiKey:t});const s=se({callbacks:{contentUpdate:n,animation:()=>{},configureSdk:()=>{},stateUpdate:()=>{}},model:e,trustedHosts:r});return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}},Ge="builder.tests",T=e=>`${Ge}.${e}`,Je=({contentId:e})=>H({name:T(e),canTrack:!0}),ze=({contentId:e})=>I({name:T(e),canTrack:!0}),Xe=({contentId:e,value:t})=>U({name:T(e),value:t,canTrack:!0}),oe=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,He=({id:e,variations:t})=>{var s;let n=0;const r=Math.random();for(const o in t){const i=(s=t[o])==null?void 0:s.testRatio;if(n+=i,r<n)return o}return e},ie=e=>{const t=He(e);return Xe({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},ae=({item:e,testGroupId:t})=>{const n=e.variations[t];return t===e.id||!n?{testVariationId:e.id,testVariationName:"Default"}:{data:n.data,testVariationId:n.id,testVariationName:n.name||(n.id===e.id?"Default":"")}},Qe=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!oe(e))return e;const n=ze({contentId:e.id})||ie({variations:e.variations,id:e.id}),r=ae({item:e,testGroupId:n});return{...e,...r}},Ye=async({item:e,canTrack:t})=>{if(!t||!oe(e))return e;const r=await Je({contentId:e.id})||ie({variations:e.variations,id:e.id}),s=ae({item:e,testGroupId:r});return{...e,...s}},K="builder.userAttributes";function Ze(){let e=!0;const t=new Set;return{setUserAttributes(n){if(!c())return;const r={...this.getUserAttributes(),...n};U({name:K,value:JSON.stringify(r),canTrack:e}),t.forEach(s=>s(r))},getUserAttributes(){return c()?JSON.parse(I({name:K,canTrack:e})||"{}"):{}},subscribeOnUserAttributesChange(n){return t.add(n),()=>{t.delete(n)}},setCanTrack(n){e=n}}}const B=Ze(),qe=e=>{B.setUserAttributes(e)},ce=e=>{const t=p(e)?e:!0;return B.setCanTrack(t),t};function et(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function tt(){const e=et().fetch;if(typeof e=="undefined")throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project.
|
|
2
|
-
For more information, read https://github.com/BuilderIO/this-package-uses-fetch`),new Error("Builder SDK could not find a global `fetch` function");return e}const nt=tt();function O(e,t=null,n="."){return Object.keys(e).reduce((r,s)=>{const o=e[s],i=[t,s].filter(Boolean).join(n);return[typeof o=="object",o!==null,!(Array.isArray(o)&&o.length===0)].every(Boolean)?{...r,...O(o,i,n)}:{...r,[i]:o}},{})}function ue(e,t,n={}){for(const r in e){const s=e[r],o=t?t+"."+r:r;s&&typeof s=="object"&&!Array.isArray(s)&&!Object.keys(s).find(i=>i.startsWith("$"))?ue(s,o,n):n[o]=s}return n}function rt(e){const t={};for(const n in e){const r=n.split(".");let s=t;for(let o=0;o<r.length;o++){const i=r[o];o===r.length-1?s[i]=e[n]:(s[i]=s[i]||{},s=s[i])}}return t}const st="v3",_=e=>typeof e=="number"&&!isNaN(e)&&e>=0,x=e=>{const{limit:t=30,userAttributes:n,query:r,model:s,apiKey:o,enrich:i,locale:u,apiVersion:S=st,fields:m,omit:w,offset:l,cacheSeconds:g,staleCacheSeconds:h,sort:v,includeUnpublished:R,apiHost:ge}=e;if(!o)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const he=t!==1,pe=ge||"https://cdn.builder.io",a=new URL(`${pe}/api/${S}/content/${s}`);a.searchParams.set("apiKey",o),a.searchParams.set("limit",String(t)),a.searchParams.set("noTraverse",String(he)),a.searchParams.set("includeRefs",String(!0));const A=u||(n==null?void 0:n.locale);let b=n||{};if(A&&(a.searchParams.set("locale",A),b={locale:A,...b}),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",w!=null?w:"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(l)&&l>-1&&a.searchParams.set("offset",String(Math.floor(l))),typeof R=="boolean"&&a.searchParams.set("includeUnpublished",String(R)),g&&_(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&_(h)&&a.searchParams.set("staleCacheSeconds",String(h)),v){const f=O({sort:v});for(const k in f)a.searchParams.set(k,JSON.stringify(f[k]))}const L={...Ae(),...j(e.options||{})};b={...b,...it(L)};const N=O(L);for(const f in N)a.searchParams.set(f,String(N[f]));if(Object.keys(b).length>0&&a.searchParams.set("userAttributes",JSON.stringify(b)),r){const f=ue({query:r});for(const k in f)a.searchParams.set(k,JSON.stringify(f[k]))}return a},ot=e=>{const t={};for(const n in e)n.startsWith("userAttributes.")&&(t[n]=e[n],delete e[n]);return t},it=e=>{if(c()&&e.preview==="BUILDER_STUDIO"){e["userAttributes.urlPath"]=window.location.pathname,e["userAttributes.host"]=window.location.host;const t=ot(e),{userAttributes:n}=rt(t);return n}return{}},at=e=>"results"in e;async function le(e){const t=await fe({...e,limit:1});return t&&t[0]||null}const ct=async e=>{var i,u;const t=x(e),n=(i=e.fetch)!=null?i:nt,r={...e.fetchOptions,headers:{...(u=e.fetchOptions)==null?void 0:u.headers,...X()}};return await(await n(t.href,r)).json()},de=async(e,t,n=x(e))=>{const r=ce(e.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return t.results;try{const s=[];for(const o of t.results)s.push(await Ye({item:o,canTrack:r}));t.results=s}catch(s){d.error("Could not process A/B tests. ",s)}return t.results};async function fe(e){const t=x(e),n=await ct(e);if(!at(n))throw d.error("Error fetching data. ",{url:t,content:n,options:e}),n;return de(e,n)}const ut=async e=>{var r,s,o;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((s=e.userAttributes)==null?void 0:s.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:P(e.searchParams||((o=e.url)==null?void 0:o.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await le(n)}};exports.TARGET=y;exports._processContentResult=de;exports._track=te;exports.checkIsDefined=p;exports.createEditorListener=se;exports.createRegisterComponentMessage=ve;exports.fetchBuilderProps=ut;exports.fetchEntries=fe;exports.fetchOneEntry=le;exports.getBuilderSearchParams=P;exports.getCookieSync=I;exports.getDefaultCanTrack=ce;exports.getUserAttributes=G;exports.handleABTestingSync=Qe;exports.isBrowser=c;exports.isEditing=$;exports.isPreviewing=we;exports.logFetch=ee;exports.logger=d;exports.register=J;exports.registerInsertMenu=We;exports.serializeIncludingFunctions=C;exports.setClientUserAttributes=qe;exports.setEditorSettings=Ee;exports.setupBrowserForEditing=re;exports.subscribeToEditor=$e;exports.track=_e;exports.userAttributesService=B;
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
"use strict";const f=require("react/jsx-runtime"),o=require("react"),l=require("./server-entry-1b560ddb.cjs"),C=require("./blocks-exports.cjs"),R=require("./blocks-7e8837dc.cjs"),L={"@type":"@builder.io/sdk:Element",layerName:"Accordion item title",responsiveStyles:{large:{marginTop:"10px",position:"relative",display:"flex",alignItems:"stretch",flexDirection:"column",paddingBottom:"10px"}},children:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{textAlign:"left",display:"flex",flexDirection:"column"}},component:{name:"Text",options:{text:"I am an accordion title. Click me!"}}}]},N={"@type":"@builder.io/sdk:Element",layerName:"Accordion item detail",responsiveStyles:{large:{position:"relative",display:"flex",alignItems:"stretch",flexDirection:"column",marginTop:"10px",paddingBottom:"10px"}},children:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{paddingTop:"50px",textAlign:"left",display:"flex",flexDirection:"column",paddingBottom:"50px"}},component:{name:"Text",options:{text:"I am an accordion detail, hello!"}}}]},ee={name:"Builder:Accordion",canHaveChildren:!0,image:"https://cdn.builder.io/api/v1/image/assets%2FagZ9n5CUKRfbL9t6CaJOyVSK4Es2%2Ffab6c1fd3fe542408cbdec078bca7f35",defaultStyles:{display:"flex",flexDirection:"column",alignItems:"stretch"},inputs:[{name:"items",type:"list",broadcast:!0,subFields:[{name:"title",type:"uiBlocks",hideFromUI:!0,defaultValue:[L]},{name:"detail",type:"uiBlocks",hideFromUI:!0,defaultValue:[N]}],defaultValue:[{title:[L],detail:[N]},{title:[L],detail:[N]}],showIf:e=>!e.get("useChildrenForItems")},{name:"oneAtATime",helperText:"Only allow opening one at a time (collapse all others when new item openned)",type:"boolean",defaultValue:!1},{name:"grid",helperText:"Display as a grid",type:"boolean",defaultValue:!1},{name:"gridRowWidth",helperText:"Display as a grid",type:"string",showIf:e=>e.get("grid"),defaultValue:"25%"},{name:"useChildrenForItems",type:"boolean",helperText:"Use child elements for each slide, instead of the array. Useful for dynamically repeating items",advanced:!0,defaultValue:!1,onChange:e=>{e.get("useChildrenForItems")===!0&&e.set("items",[])}}],shouldReceiveBuilderProps:{builderBlock:!0,builderContext:!0,builderComponents:!0,builderLinkComponent:!0}},te=o.lazy(()=>Promise.resolve().then(()=>require("./accordion-94839d7d.cjs"))),ne={name:"Core:Button",image:"https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F81a15681c3e74df09677dfc57a615b13",defaultStyles:{appearance:"none",paddingTop:"15px",paddingBottom:"15px",paddingLeft:"25px",paddingRight:"25px",backgroundColor:"#000000",color:"white",borderRadius:"4px",textAlign:"center",cursor:"pointer"},inputs:[{name:"text",type:"text",defaultValue:"Click me!",bubble:!0},{name:"link",type:"url",bubble:!0},{name:"openLinkInNewTab",type:"boolean",defaultValue:!1,friendlyName:"Open link in new tab"}],static:!0,noWrap:!0,shouldReceiveBuilderProps:{builderLinkComponent:!0}},ae={name:"Columns",isRSC:!0,inputs:[{name:"columns",type:"array",broadcast:!0,subFields:[{name:"blocks",type:"array",hideFromUI:!0,defaultValue:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{display:"flex",flexDirection:"column",alignItems:"stretch",flexShrink:"0",position:"relative",marginTop:"30px",textAlign:"center",lineHeight:"normal",height:"auto",minHeight:"20px",minWidth:"20px",overflow:"hidden"}},component:{name:"Image",options:{image:"https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:.7004048582995948}}},{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{display:"flex",flexDirection:"column",alignItems:"stretch",flexShrink:"0",position:"relative",marginTop:"30px",textAlign:"center",lineHeight:"normal",height:"auto"}},component:{name:"Text",options:{text:"<p>Enter some text...</p>"}}}]},{name:"width",type:"number",hideFromUI:!0,helperText:"Width %, e.g. set to 50 to fill half of the space"},{name:"link",type:"url",helperText:"Optionally set a url that clicking this column will link to"}],defaultValue:[{blocks:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{display:"flex",flexDirection:"column",alignItems:"stretch",flexShrink:"0",position:"relative",marginTop:"30px",textAlign:"center",lineHeight:"normal",height:"auto",minHeight:"20px",minWidth:"20px",overflow:"hidden"}},component:{name:"Image",options:{image:"https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:.7004048582995948}}},{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{display:"flex",flexDirection:"column",alignItems:"stretch",flexShrink:"0",position:"relative",marginTop:"30px",textAlign:"center",lineHeight:"normal",height:"auto"}},component:{name:"Text",options:{text:"<p>Enter some text...</p>"}}}]},{blocks:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{display:"flex",flexDirection:"column",alignItems:"stretch",flexShrink:"0",position:"relative",marginTop:"30px",textAlign:"center",lineHeight:"normal",height:"auto",minHeight:"20px",minWidth:"20px",overflow:"hidden"}},component:{name:"Image",options:{image:"https://builder.io/api/v1/image/assets%2Fpwgjf0RoYWbdnJSbpBAjXNRMe9F2%2Ffb27a7c790324294af8be1c35fe30f4d",backgroundPosition:"center",backgroundSize:"cover",aspectRatio:.7004048582995948}}},{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{display:"flex",flexDirection:"column",alignItems:"stretch",flexShrink:"0",position:"relative",marginTop:"30px",textAlign:"center",lineHeight:"normal",height:"auto"}},component:{name:"Text",options:{text:"<p>Enter some text...</p>"}}}]}],onChange:e=>{function t(){n.forEach(i=>{i.delete("width")})}const n=e.get("columns");Array.isArray(n)&&n.find(s=>s.get("width"))&&(n.find(m=>!m.get("width"))||n.reduce((r,p)=>r+p.get("width"),0)!==100)&&t()}},{name:"space",type:"number",defaultValue:20,helperText:"Size of gap between columns",advanced:!0},{name:"stackColumnsAt",type:"string",defaultValue:"tablet",helperText:"Convert horizontal columns to vertical at what device size",enum:["tablet","mobile","never"],advanced:!0},{name:"reverseColumnsWhenStacked",type:"boolean",defaultValue:!1,helperText:"When stacking columns for mobile devices, reverse the ordering",advanced:!0}],shouldReceiveBuilderProps:{builderBlock:!0,builderContext:!0,builderComponents:!0,builderLinkComponent:!0}},ie={name:"Fragment",static:!0,hidden:!0,canHaveChildren:!0,noWrap:!0},z=["jpeg","jpg","png","svg","webp","gif","jfif","pjpeg","pjp","apng","avif","tif","tiff","heif","bmp","eps","raw","cr2","nef","orf","sr2","psd","heic","dib","ai"],oe=["mp4","webm","mkv","flv","vob","ogv","ogg","drc","gif","gifv","mng","avi","mov","qt","mts","m2ts","ts","wmv","yuv","rm","rmvb","viv","asf","amv","m4p","mpeg","mpe","m2v","m4v","svi","3gp","3g2","mxf","roq","nsv","f4v","f4p","f4a","f4b"],re={name:"Image",static:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",defaultStyles:{position:"relative",minHeight:"20px",minWidth:"20px",overflow:"hidden"},canHaveChildren:!0,inputs:[{name:"image",type:"file",bubble:!0,allowedFileTypes:z,required:!0,defaultValue:"https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F72c80f114dc149019051b6852a9e3b7a",onChange:e=>{e.delete("srcset"),e.delete("noWebp");function n(a,r=6e4){return new Promise((p,S)=>{const v=document.createElement("img");let P=!1;v.onload=()=>{P=!0,p(v)},v.addEventListener("error",w=>{console.warn("Image load failed",w.error),S(w.error)}),v.src=a,setTimeout(()=>{P||S(new Error("Image load timed out"))},r)})}function i(a){return Math.round(a*1e3)/1e3}const s=e.get("image"),m=e.get("aspectRatio");if(fetch(s).then(a=>a.blob()).then(a=>{a.type.includes("svg")&&e.set("noWebp",!0)}),s&&(!m||m===.7041))return n(s).then(a=>{const r=e.get("aspectRatio");e.get("image")===s&&(!r||r===.7041)&&a.width&&a.height&&(e.set("aspectRatio",i(a.height/a.width)),e.set("height",a.height),e.set("width",a.width))})}},{name:"backgroundSize",type:"text",defaultValue:"cover",enum:[{label:"contain",value:"contain",helperText:"The image should never get cropped"},{label:"cover",value:"cover",helperText:"The image should fill it's box, cropping when needed"}]},{name:"backgroundPosition",type:"text",defaultValue:"center",enum:["center","top","left","right","bottom","top left","top right","bottom left","bottom right"]},{name:"altText",type:"string",helperText:"Text to display when the user has images off"},{name:"title",type:"string",helperText:"Text to display when hovering over the asset"},{name:"height",type:"number",hideFromUI:!0},{name:"width",type:"number",hideFromUI:!0},{name:"sizes",type:"string",hideFromUI:!0},{name:"srcset",type:"string",hideFromUI:!0},{name:"lazy",type:"boolean",defaultValue:!0,hideFromUI:!0},{name:"fitContent",type:"boolean",helperText:"When child blocks are provided, fit to them instead of using the image's aspect ratio",defaultValue:!0},{name:"highPriority",type:"boolean",advanced:!0,helperText:"Mark this image as high priority compared to other images on the page. This prevents lazy loading of the image and tells the browser to load this image before others on the page."},{name:"aspectRatio",type:"number",helperText:"This is the ratio of height/width, e.g. set to 1.5 for a 300px wide and 200px tall photo. Set to 0 to not force the image to maintain it's aspect ratio",advanced:!0,defaultValue:.7041}],shouldReceiveBuilderProps:{builderBlock:!0}},le={name:"PersonalizationContainer",shouldReceiveBuilderProps:{builderBlock:!0,builderContext:!0},noWrap:!0,image:"https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F37229ed30d8c41dfb10b8cca1992053a",canHaveChildren:!0,inputs:[{name:"variants",defaultValue:[],behavior:"personalizationVariantList",type:"list",subFields:[{name:"name",type:"text"},{name:"query",friendlyName:"Targeting rules",type:"BuilderQuery",defaultValue:[]},{name:"startDate",type:"date"},{name:"endDate",type:"date"},{name:"blocks",type:"uiBlocks",hideFromUI:!0,defaultValue:[]}]}]},se=o.lazy(()=>Promise.resolve().then(()=>require("./personalization-container-95cba946.cjs"))),de={name:"Core:Section",static:!0,image:"https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F682efef23ace49afac61748dd305c70a",inputs:[{name:"maxWidth",type:"number",defaultValue:1200},{name:"lazyLoad",type:"boolean",defaultValue:!1,advanced:!0,description:"Only render this section when in view"}],defaultStyles:{paddingLeft:"20px",paddingRight:"20px",paddingTop:"50px",paddingBottom:"50px",marginTop:"0px",width:"100vw",marginLeft:"calc(50% - 50vw)"},canHaveChildren:!0,defaultChildren:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{textAlign:"center"}},component:{name:"Text",options:{text:"<p><b>I am a section! My content keeps from getting too wide, so that it's easy to read even on big screens.</b></p><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur</p>"}}}]},ue={name:"Slot",isRSC:!0,description:"Allow child blocks to be inserted into this content when used as a Symbol",docsLink:"https://www.builder.io/c/docs/symbols-with-blocks",image:"https://cdn.builder.io/api/v1/image/assets%2FYJIGb4i01jvw0SRdL5Bt%2F3aad6de36eae43b59b52c85190fdef56",inputs:[{name:"name",type:"string",required:!0,defaultValue:"children"}],shouldReceiveBuilderProps:{builderContext:!0,builderComponents:!0}},ce=o.lazy(()=>Promise.resolve().then(()=>require("./slot-ddddba8d.cjs"))),me={name:"Symbol",noWrap:!0,static:!0,isRSC:!0,inputs:[{name:"symbol",type:"uiSymbol"},{name:"dataOnly",helperText:"Make this a data symbol that doesn't display any UI",type:"boolean",defaultValue:!1,advanced:!0,hideFromUI:!0},{name:"inheritState",helperText:"Inherit the parent component state and data",type:"boolean",defaultValue:!1,advanced:!0},{name:"renderToLiquid",helperText:"Render this symbols contents to liquid. Turn off to fetch with javascript and use custom targeting",type:"boolean",defaultValue:!1,advanced:!0,hideFromUI:!0},{name:"useChildren",hideFromUI:!0,type:"boolean"}],shouldReceiveBuilderProps:{builderBlock:!0,builderContext:!0,builderComponents:!0,builderLinkComponent:!0}},$={"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{paddingLeft:"20px",paddingRight:"20px",paddingTop:"10px",paddingBottom:"10px",minWidth:"100px",textAlign:"center",display:"flex",flexDirection:"column",cursor:"pointer",userSelect:"none"}},component:{name:"Text",options:{text:"New tab"}}},_={"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{height:"200px",display:"flex",marginTop:"20px",flexDirection:"column"}},component:{name:"Text",options:{text:"New tab content "}}},pe={name:"Builder: Tabs",inputs:[{name:"tabs",type:"list",broadcast:!0,subFields:[{name:"label",type:"uiBlocks",hideFromUI:!0,defaultValue:[$]},{name:"content",type:"uiBlocks",hideFromUI:!0,defaultValue:[_]}],defaultValue:[{label:[{...$,component:{name:"Text",options:{text:"Tab 1"}}}],content:[{..._,component:{name:"Text",options:{text:"Tab 1 content"}}}]},{label:[{...$,component:{name:"Text",options:{text:"Tab 2"}}}],content:[{..._,component:{name:"Text",options:{text:"Tab 2 content"}}}]}]},{name:"activeTabStyle",type:"uiStyle",helperText:"CSS styles for the active tab",defaultValue:{backgroundColor:"rgba(0, 0, 0, 0.1)"}},{name:"defaultActiveTab",type:"number",helperText:'Default tab to open to. Set to "1" for the first tab, "2" for the second, or choose "0" for none',defaultValue:1,advanced:!0},{name:"collapsible",type:"boolean",helperText:"If on, clicking an open tab closes it so no tabs are active",defaultValue:!1,advanced:!0},{name:"tabHeaderLayout",type:"enum",helperText:"Change the layout of the tab headers (uses justify-content)",defaultValue:"flex-start",enum:[{label:"Center",value:"center"},{label:"Space between",value:"space-between"},{label:"Space around",value:"space-around"},{label:"Left",value:"flex-start"},{label:"Right",value:"flex-end"}]}],shouldReceiveBuilderProps:{builderBlock:!0,builderContext:!0,builderComponents:!0,builderLinkComponent:!0}},fe=o.lazy(()=>Promise.resolve().then(()=>require("./tabs-f76f757a.cjs"))),ge={shouldReceiveBuilderProps:{},name:"Text",static:!0,isRSC:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-text_fields-24px%20(1).svg?alt=media&token=12177b73-0ee3-42ca-98c6-0dd003de1929",inputs:[{name:"text",type:"html",required:!0,autoFocus:!0,bubble:!0,defaultValue:"Enter some text..."}],defaultStyles:{lineHeight:"normal",height:"auto",textAlign:"center"}},he={name:"Custom Code",static:!0,requiredPermissions:["editCode"],inputs:[{name:"code",type:"html",required:!0,defaultValue:"<p>Hello there, I am custom HTML code!</p>",code:!0},{name:"replaceNodes",type:"boolean",helperText:"Preserve server rendered dom nodes",advanced:!0},{name:"scriptsClientOnly",type:"boolean",defaultValue:!1,helperText:"Only print and run scripts on the client. Important when scripts influence DOM that could be replaced when client loads",advanced:!0}]},be=o.lazy(()=>Promise.resolve().then(()=>require("./custom-code-ea534e98.cjs"))),ye={name:"Embed",static:!0,inputs:[{name:"url",type:"url",required:!0,defaultValue:"",helperText:"e.g. enter a youtube url, google map, etc"},{name:"content",type:"html",defaultValue:'<div style="padding: 20px; text-align: center">(Choose an embed URL)<div>',hideFromUI:!0}]},xe=o.lazy(()=>Promise.resolve().then(()=>require("./embed-7ca4af6e.cjs"))),ve={name:"Form:Form",defaults:{responsiveStyles:{large:{marginTop:"15px",paddingBottom:"15px"}}},image:"https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fef36d2a846134910b64b88e6d18c5ca5",inputs:[{name:"sendSubmissionsTo",type:"string",enum:[{label:"Send to email",value:"email",helperText:"Send form submissions to the email address of your choosing"},{label:"Custom",value:"custom",helperText:"Handle where the form requests go manually with a little code, e.g. to your own custom backend"}],defaultValue:"email"},{name:"sendSubmissionsToEmail",type:"string",required:!0,defaultValue:"your@email.com",showIf:'options.get("sendSubmissionsTo") === "email"'},{name:"sendWithJs",type:"boolean",helperText:"Set to false to use basic html form action",defaultValue:!0,showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:"name",type:"string",defaultValue:"My form"},{name:"action",type:"string",helperText:"URL to send the form data to",showIf:'options.get("sendSubmissionsTo") === "custom"'},{name:"contentType",type:"string",defaultValue:"application/json",advanced:!0,enum:["application/json","multipart/form-data","application/x-www-form-urlencoded"],showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'},{name:"method",type:"string",showIf:'options.get("sendSubmissionsTo") === "custom"',defaultValue:"POST",advanced:!0},{name:"previewState",type:"string",enum:["unsubmitted","sending","success","error"],defaultValue:"unsubmitted",helperText:'Choose a state to edit, e.g. choose "success" to show what users see on success and edit the message',showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:"successUrl",type:"url",helperText:"Optional URL to redirect the user to on form submission success",showIf:'options.get("sendSubmissionsTo") !== "zapier" && options.get("sendWithJs") === true'},{name:"resetFormOnSubmit",type:"boolean",showIf:"options.get('sendSubmissionsTo') === 'custom' && options.get('sendWithJs') === true",advanced:!0},{name:"successMessage",type:"uiBlocks",hideFromUI:!0,defaultValue:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{marginTop:"10px"}},component:{name:"Text",options:{text:"<span>Thanks!</span>"}}}]},{name:"validate",type:"boolean",defaultValue:!0,advanced:!0},{name:"errorMessagePath",type:"text",advanced:!0,helperText:'Path to where to get the error message from in a JSON response to display to the user, e.g. "error.message" for a response like { "error": { "message": "this username is taken" }}'},{name:"errorMessage",type:"uiBlocks",hideFromUI:!0,defaultValue:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{marginTop:"10px"}},bindings:{"component.options.text":"state.formErrorMessage || block.component.options.text"},component:{name:"Text",options:{text:"<span>Form submission error :( Please check your answers and try again</span>"}}}]},{name:"sendingMessage",type:"uiBlocks",hideFromUI:!0,defaultValue:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{marginTop:"10px"}},component:{name:"Text",options:{text:"<span>Sending...</span>"}}}]},{name:"customHeaders",type:"map",valueType:{type:"string"},advanced:!0,showIf:'options.get("sendSubmissionsTo") === "custom" && options.get("sendWithJs") === true'}],noWrap:!0,canHaveChildren:!0,defaultChildren:[{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{marginTop:"10px"}},component:{name:"Text",options:{text:"<span>Enter your name</span>"}}},{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{marginTop:"10px"}},component:{name:"Form:Input",options:{name:"name",placeholder:"Jane Doe"}}},{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{marginTop:"10px"}},component:{name:"Text",options:{text:"<span>Enter your email</span>"}}},{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{marginTop:"10px"}},component:{name:"Form:Input",options:{name:"email",placeholder:"jane@doe.com"}}},{"@type":"@builder.io/sdk:Element",responsiveStyles:{large:{marginTop:"10px"}},component:{name:"Form:SubmitButton",options:{text:"Submit"}}}],shouldReceiveBuilderProps:{builderBlock:!0,builderContext:!0,builderComponents:!0,builderLinkComponent:!0}},Se=o.lazy(()=>Promise.resolve().then(()=>require("./form-85ea06df.cjs"))),Te={name:"Form:Input",image:"https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fad6f37889d9e40bbbbc72cdb5875d6ca",inputs:[{name:"type",type:"text",enum:["text","number","email","url","checkbox","radio","range","date","datetime-local","search","tel","time","file","month","week","password","color","hidden"],defaultValue:"text"},{name:"name",type:"string",required:!0,helperText:'Every input in a form needs a unique name describing what it takes, e.g. "email"'},{name:"placeholder",type:"string",defaultValue:"Hello there",helperText:"Text to display when there is no value"},{name:"defaultValue",type:"string"},{name:"value",type:"string",advanced:!0},{name:"required",type:"boolean",helperText:"Is this input required to be filled out to submit a form",defaultValue:!1}],noWrap:!0,static:!0,defaultStyles:{paddingTop:"10px",paddingBottom:"10px",paddingLeft:"10px",paddingRight:"10px",borderRadius:"3px",borderWidth:"1px",borderStyle:"solid",borderColor:"#ccc"}},Ie=o.lazy(()=>Promise.resolve().then(()=>require("./input-231ec63f.cjs"))),ke={name:"Form:Select",image:"https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2F83acca093fb24aaf94dee136e9a4b045",defaultStyles:{alignSelf:"flex-start"},inputs:[{name:"options",type:"list",required:!0,subFields:[{name:"value",type:"text",required:!0},{name:"name",type:"text"}],defaultValue:[{value:"option 1"},{value:"option 2"}]},{name:"name",type:"string",required:!0,helperText:'Every select in a form needs a unique name describing what it gets, e.g. "email"'},{name:"defaultValue",type:"string"},{name:"value",type:"string",advanced:!0},{name:"required",type:"boolean",defaultValue:!1}],static:!0,noWrap:!0},Ce=o.lazy(()=>Promise.resolve().then(()=>require("./select-b1650a75.cjs"))),we={name:"Form:SubmitButton",image:"https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Fdf2820ffed1f4349a94c40b3221f5b98",defaultStyles:{appearance:"none",paddingTop:"15px",paddingBottom:"15px",paddingLeft:"25px",paddingRight:"25px",backgroundColor:"#3898EC",color:"white",borderRadius:"4px",cursor:"pointer"},inputs:[{name:"text",type:"text",defaultValue:"Click me"}],static:!0,noWrap:!0},Ve=o.lazy(()=>Promise.resolve().then(()=>require("./submit-button-b363e0ed.cjs"))),Ee={name:"Form:TextArea",image:"https://cdn.builder.io/api/v1/image/assets%2FIsxPKMo2gPRRKeakUztj1D6uqed2%2Ff74a2f3de58c4c3e939204e5b6b8f6c3",inputs:[{advanced:!0,name:"value",type:"string"},{name:"name",type:"string",required:!0,helperText:'Every input in a form needs a unique name describing what it gets, e.g. "email"'},{name:"defaultValue",type:"string"},{name:"placeholder",type:"string",defaultValue:"Hello there"},{name:"required",type:"boolean",defaultValue:!1}],defaultStyles:{paddingTop:"10px",paddingBottom:"10px",paddingLeft:"10px",paddingRight:"10px",borderRadius:"3px",borderWidth:"1px",borderStyle:"solid",borderColor:"#ccc"},static:!0,noWrap:!0},Re=o.lazy(()=>Promise.resolve().then(()=>require("./textarea-56a875bc.cjs"))),Fe={name:"Raw:Img",hideFromInsertMenu:!0,image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-insert_photo-24px.svg?alt=media&token=4e5d0ef4-f5e8-4e57-b3a9-38d63a9b9dc4",inputs:[{name:"image",bubble:!0,type:"file",allowedFileTypes:z,required:!0}],noWrap:!0,static:!0},Pe=o.lazy(()=>Promise.resolve().then(()=>require("./img-81a7f4d7.cjs"))),Ae={name:"Video",canHaveChildren:!0,defaultStyles:{minHeight:"20px",minWidth:"20px"},image:"https://firebasestorage.googleapis.com/v0/b/builder-3b0a2.appspot.com/o/images%2Fbaseline-videocam-24px%20(1).svg?alt=media&token=49a84e4a-b20e-4977-a650-047f986874bb",inputs:[{name:"video",type:"file",allowedFileTypes:oe,bubble:!0,defaultValue:"https://cdn.builder.io/o/assets%2FYJIGb4i01jvw0SRdL5Bt%2Fd27731a526464deba0016216f5f9e570%2Fcompressed?apiKey=YJIGb4i01jvw0SRdL5Bt&token=d27731a526464deba0016216f5f9e570&alt=media&optimized=true",required:!0},{name:"posterImage",type:"file",allowedFileTypes:z,helperText:"Image to show before the video plays"},{name:"autoPlay",type:"boolean",defaultValue:!0},{name:"controls",type:"boolean",defaultValue:!1},{name:"muted",type:"boolean",defaultValue:!0},{name:"loop",type:"boolean",defaultValue:!0},{name:"playsInline",type:"boolean",defaultValue:!0},{name:"fit",type:"text",defaultValue:"cover",enum:["contain","cover","fill","auto"]},{name:"preload",type:"text",defaultValue:"metadata",enum:["auto","metadata","none"]},{name:"fitContent",type:"boolean",helperText:"When child blocks are provided, fit to them instead of using the aspect ratio",defaultValue:!0,advanced:!0},{name:"position",type:"text",defaultValue:"center",enum:["center","top","left","right","bottom","top left","top right","bottom left","bottom right"]},{name:"height",type:"number",advanced:!0},{name:"width",type:"number",advanced:!0},{name:"aspectRatio",type:"number",advanced:!0,defaultValue:.7004048582995948},{name:"lazyLoad",type:"boolean",helperText:'Load this video "lazily" - as in only when a user scrolls near the video. Recommended for optmized performance and bandwidth consumption',defaultValue:!0,advanced:!0}],shouldReceiveBuilderProps:{builderBlock:!0}},We=()=>[{component:be,...he},{component:xe,...ye},{component:Se,...ve},{component:Ie,...Te},{component:Ve,...we},{component:Ce,...ke},{component:Re,...Ee},{component:Pe,...Fe},{component:C.Video,...Ae}],O=()=>[{component:C.Button,...ne},{component:C.Columns,...ae},{component:C.Fragment,...ie},{component:C.Image,...re},{component:C.Section,...de},{component:ce,...ue},{component:C.Symbol,...me},{component:C.Text,...ge},{component:se,...le},{component:fe,...pe},{component:te,...ee},...We()],Be=`function updateCookiesAndStyles(contentId, variants, isHydrationTarget, isAngularSDK) {
|
|
2
|
-
function getAndSetVariantId() {
|
|
3
|
-
function setCookie(name, value, days) {
|
|
4
|
-
let expires = '';
|
|
5
|
-
if (days) {
|
|
6
|
-
const date = new Date();
|
|
7
|
-
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
|
|
8
|
-
expires = '; expires=' + date.toUTCString();
|
|
9
|
-
}
|
|
10
|
-
document.cookie = name + '=' + (value || '') + expires + '; path=/' + '; Secure; SameSite=None';
|
|
11
|
-
}
|
|
12
|
-
function getCookie(name) {
|
|
13
|
-
const nameEQ = name + '=';
|
|
14
|
-
const ca = document.cookie.split(';');
|
|
15
|
-
for (let i = 0; i < ca.length; i++) {
|
|
16
|
-
let c = ca[i];
|
|
17
|
-
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
|
|
18
|
-
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
|
|
19
|
-
}
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
const cookieName = \`builder.tests.\${contentId}\`;
|
|
23
|
-
const variantInCookie = getCookie(cookieName);
|
|
24
|
-
const availableIDs = variants.map(vr => vr.id).concat(contentId);
|
|
25
|
-
if (variantInCookie && availableIDs.includes(variantInCookie)) {
|
|
26
|
-
return variantInCookie;
|
|
27
|
-
}
|
|
28
|
-
let n = 0;
|
|
29
|
-
const random = Math.random();
|
|
30
|
-
for (let i = 0; i < variants.length; i++) {
|
|
31
|
-
const variant = variants[i];
|
|
32
|
-
const testRatio = variant.testRatio;
|
|
33
|
-
n += testRatio;
|
|
34
|
-
if (random < n) {
|
|
35
|
-
setCookie(cookieName, variant.id);
|
|
36
|
-
return variant.id;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
setCookie(cookieName, contentId);
|
|
40
|
-
return contentId;
|
|
41
|
-
}
|
|
42
|
-
const winningVariantId = getAndSetVariantId();
|
|
43
|
-
let styleEl = document.currentScript?.previousElementSibling;
|
|
44
|
-
if (isAngularSDK) {
|
|
45
|
-
styleEl = document.currentScript?.parentElement?.previousElementSibling?.querySelector('style');
|
|
46
|
-
}
|
|
47
|
-
if (isHydrationTarget) {
|
|
48
|
-
styleEl.remove();
|
|
49
|
-
const thisScriptEl = document.currentScript;
|
|
50
|
-
thisScriptEl?.remove();
|
|
51
|
-
} else {
|
|
52
|
-
const newStyleStr = variants.concat({
|
|
53
|
-
id: contentId
|
|
54
|
-
}).filter(variant => variant.id !== winningVariantId).map(value => {
|
|
55
|
-
return \`.variant-\${value.id} { display: none; }
|
|
56
|
-
\`;
|
|
57
|
-
}).join('');
|
|
58
|
-
styleEl.innerHTML = newStyleStr;
|
|
59
|
-
}
|
|
60
|
-
}`,De=`function updateVariantVisibility(variantContentId, defaultContentId, isHydrationTarget) {
|
|
61
|
-
if (!navigator.cookieEnabled) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
function getCookie(name) {
|
|
65
|
-
const nameEQ = name + '=';
|
|
66
|
-
const ca = document.cookie.split(';');
|
|
67
|
-
for (let i = 0; i < ca.length; i++) {
|
|
68
|
-
let c = ca[i];
|
|
69
|
-
while (c.charAt(0) === ' ') c = c.substring(1, c.length);
|
|
70
|
-
if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);
|
|
71
|
-
}
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
const cookieName = \`builder.tests.\${defaultContentId}\`;
|
|
75
|
-
const winningVariant = getCookie(cookieName);
|
|
76
|
-
const parentDiv = document.currentScript?.parentElement;
|
|
77
|
-
const isDefaultContent = variantContentId === defaultContentId;
|
|
78
|
-
const isWinningVariant = winningVariant === variantContentId;
|
|
79
|
-
if (isWinningVariant && !isDefaultContent) {
|
|
80
|
-
parentDiv?.removeAttribute('hidden');
|
|
81
|
-
parentDiv?.removeAttribute('aria-hidden');
|
|
82
|
-
} else if (!isWinningVariant && isDefaultContent) {
|
|
83
|
-
parentDiv?.setAttribute('hidden', 'true');
|
|
84
|
-
parentDiv?.setAttribute('aria-hidden', 'true');
|
|
85
|
-
}
|
|
86
|
-
if (isHydrationTarget) {
|
|
87
|
-
if (!isWinningVariant) {
|
|
88
|
-
parentDiv?.remove();
|
|
89
|
-
}
|
|
90
|
-
const thisScriptEl = document.currentScript;
|
|
91
|
-
thisScriptEl?.remove();
|
|
92
|
-
}
|
|
93
|
-
return;
|
|
94
|
-
}`,Q="builderIoAbTest",X="builderIoRenderContent",U=e=>Object.values((e==null?void 0:e.variations)||{}).map(t=>({...t,testVariationId:t.id,id:e==null?void 0:e.id})),qe=({canTrack:e,content:t})=>!(!(U(t).length>0)||!e||l.isBrowser()),Ue=e=>e==="react"||e==="reactNative",He=l.TARGET==="angular",Z=Ue(l.TARGET),je=()=>`
|
|
95
|
-
window.${Q} = ${Be}
|
|
96
|
-
window.${X} = ${De}
|
|
97
|
-
`,Le=(e,t)=>`
|
|
98
|
-
window.${Q}(
|
|
99
|
-
"${t}",${JSON.stringify(e)}, ${Z}, ${He}
|
|
100
|
-
)`,Ne=({contentId:e,variationId:t})=>`window.${X}(
|
|
101
|
-
"${t}", "${e}", ${Z}
|
|
102
|
-
)`;function H(e){return f.jsx("script",{dangerouslySetInnerHTML:{__html:e.scriptStr},"data-id":e.id,nonce:e.nonce||""})}function M(e){return Math.round(e*1e3)/1e3}const $e=(e,t,n=!0)=>{if(!(e instanceof HTMLElement))return null;let i=n?e:e.parentElement;do{if(!i)return null;if(t(i))return i}while(i=i.parentElement);return null},_e=e=>$e(e,t=>{const n=t.getAttribute("builder-id")||t.id;return(n==null?void 0:n.indexOf("builder-"))===0}),J=({event:e,target:t})=>{const n=t.getBoundingClientRect(),i=e.clientX-n.left,s=e.clientY-n.top,m=M(i/n.width),a=M(s/n.height);return{x:m,y:a}},ze=e=>{const t=e.target,n=t&&_e(t),i=(n==null?void 0:n.getAttribute("builder-id"))||(n==null?void 0:n.id);return{targetBuilderElement:i||void 0,metadata:{targetOffset:t?J({event:e,target:t}):void 0,builderTargetOffset:n?J({event:e,target:n}):void 0,builderElementIndex:n&&i?[].slice.call(document.getElementsByClassName(i)).indexOf(n):void 0}}},Ke=["svelte","qwik","vue"],Y=()=>Ke.includes(l.TARGET)&&(l.isEditing()||l.isPreviewing()),Oe=e=>{var m,a;const t=e.family+(e.kind&&!e.kind.includes("#")?", "+e.kind:""),n=t.split(",")[0],i=(a=e.fileUrl)!=null?a:(m=e==null?void 0:e.files)==null?void 0:m.regular;let s="";if(i&&t&&n&&(s+=`
|
|
103
|
-
@font-face {
|
|
104
|
-
font-family: "${t}";
|
|
105
|
-
src: local("${n}"), url('${i}') format('woff2');
|
|
106
|
-
font-display: fallback;
|
|
107
|
-
font-weight: 400;
|
|
108
|
-
}
|
|
109
|
-
`.trim()),e.files)for(const r in e.files){if(!(String(Number(r))===r))continue;const S=e.files[r];S&&S!==i&&(s+=`
|
|
110
|
-
@font-face {
|
|
111
|
-
font-family: "${t}";
|
|
112
|
-
src: url('${S}') format('woff2');
|
|
113
|
-
font-display: fallback;
|
|
114
|
-
font-weight: ${r};
|
|
115
|
-
}
|
|
116
|
-
`.trim())}return s},Me=({customFonts:e})=>{var t;return((t=e==null?void 0:e.map(n=>Oe(n)))==null?void 0:t.join(" "))||""},Je=({cssCode:e,contentId:t})=>e?t?(e==null?void 0:e.replace(/&/g,`div[builder-content-id="${t}"]`))||"":e:"",Ye=`
|
|
117
|
-
.builder-button {
|
|
118
|
-
all: unset;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
.builder-text > p:first-of-type, .builder-text > .builder-paragraph:first-of-type {
|
|
122
|
-
margin: 0;
|
|
123
|
-
}
|
|
124
|
-
.builder-text > p, .builder-text > .builder-paragraph {
|
|
125
|
-
color: inherit;
|
|
126
|
-
line-height: inherit;
|
|
127
|
-
letter-spacing: inherit;
|
|
128
|
-
font-weight: inherit;
|
|
129
|
-
font-size: inherit;
|
|
130
|
-
text-align: inherit;
|
|
131
|
-
font-family: inherit;
|
|
132
|
-
}
|
|
133
|
-
`,Ge=e=>e?"":Ye,Qe=e=>`variant-${e}`;function Xe(e){var b,x,V;const t=o.useRef(null);o.useState(()=>!1);function n(d){var g,h;const u={...e.builderContextSignal.rootState,...d};e.builderContextSignal.rootSetState?(h=(g=e.builderContextSignal).rootSetState)==null||h.call(g,u):e.setBuilderContextSignal(c=>({...c,rootState:u}))}function i(d){var g,h,c,E,I;const u={...e.builderContextSignal.content,...d,data:{...(g=e.builderContextSignal.content)==null?void 0:g.data,...d==null?void 0:d.data},meta:{...(h=e.builderContextSignal.content)==null?void 0:h.meta,...d==null?void 0:d.meta,breakpoints:((c=d==null?void 0:d.meta)==null?void 0:c.breakpoints)||((I=(E=e.builderContextSignal.content)==null?void 0:E.meta)==null?void 0:I.breakpoints)}};e.setBuilderContextSignal(T=>({...T,content:u}))}function s(){return e.showContent?{}:{hidden:!0,"aria-hidden":!0}}const[m,a]=o.useState(()=>e.contentWrapper||"div");function r(d){return l.createEditorListener({model:e.model,trustedHosts:e.trustedHosts,callbacks:{configureSdk:u=>{var c;const{breakpoints:g,contentId:h}=u;!h||h!==((c=e.builderContextSignal.content)==null?void 0:c.id)||g&&i({meta:{breakpoints:g}})},animation:u=>{R.triggerAnimation(u)},contentUpdate:u=>{i(u)},stateUpdate:u=>{n(u)}}})(d)}const[p,S]=o.useState(()=>({})),[v,P]=o.useState(()=>({})),[w,W]=o.useState(()=>!1);function B(d){var u,g;if(e.builderContextSignal.content){const h=(u=e.builderContextSignal.content)==null?void 0:u.testVariationId,c=(g=e.builderContextSignal.content)==null?void 0:g.id;l._track({apiHost:e.apiHost,type:"click",canTrack:l.getDefaultCanTrack(e.canTrack),contentId:c,apiKey:e.apiKey,variationId:h!==c?h:void 0,...ze(d),unique:!w})}w||W(!0)}function D(){var u,g,h;const d=(h=(g=(u=e.builderContextSignal.content)==null?void 0:u.data)==null?void 0:g.httpRequests)!=null?h:{};Object.entries(d).forEach(([c,E])=>{if(!E||v[c]||p[c]&&!l.isEditing())return;v[c]=!0;const I=E.replace(/{{([^}]+)}}/g,(T,y)=>String(R.evaluate({code:y,context:e.context||{},localState:void 0,rootState:e.builderContextSignal.rootState,rootSetState:e.builderContextSignal.rootSetState})));l.logFetch(I),fetch(I).then(T=>T.json()).then(T=>{n({[c]:T}),p[c]=!0}).catch(T=>{console.error("error fetching dynamic data",E,T)}).finally(()=>{v[c]=!1})})}function F(){l.isEditing()&&window.dispatchEvent(new CustomEvent("builder:component:stateChange",{detail:{state:R.fastClone(e.builderContextSignal.rootState),ref:{name:e.model}}}))}const A=o.useRef(!1);return A.current||(D(),F(),A.current=!0),o.useEffect(()=>{var d,u,g,h,c;if(l.isBrowser()){l.isEditing()&&!e.isNestedRender&&(window.addEventListener("message",r),l.registerInsertMenu(),l.setupBrowserForEditing({...e.locale?{locale:e.locale}:{},...e.enrich?{enrich:e.enrich}:{},...e.trustedHosts?{trustedHosts:e.trustedHosts}:{},modelName:(d=e.model)!=null?d:"",apiKey:e.apiKey}),Object.values(e.builderContextSignal.componentInfos).forEach(y=>{var k,q;if(!((k=y.models)!=null&&k.length)||y.models.includes(e.model)){const j=l.createRegisterComponentMessage(y);(q=window.parent)==null||q.postMessage(j,"*")}}),window.addEventListener("builder:component:stateChangeListenerActivated",F));const E=e.builderContextSignal.content&&l.getDefaultCanTrack(e.canTrack),I=l.getCookieSync({name:`builder.tests.${(u=e.builderContextSignal.content)==null?void 0:u.id}`,canTrack:!0}),T=(g=e.builderContextSignal.content)==null?void 0:g.testVariationId;if(E&&T===I){const y=(h=e.builderContextSignal.content)==null?void 0:h.id,k=e.apiKey;l._track({apiHost:e.apiHost,type:"impression",canTrack:!0,contentId:y,apiKey:k,variationId:I!==y?I:void 0})}if(l.isPreviewing()&&!l.isEditing()){const y=new URL(location.href).searchParams,k=y.get("builder.preview"),q=y.get(`builder.overrides.${k}`),j=y.get("apiKey")||y.get("builder.space");(k==="BUILDER_STUDIO"||k===e.model&&j===e.apiKey&&(!e.content||q===e.content.id))&&l.fetchOneEntry({model:e.model,apiKey:e.apiKey,apiVersion:e.builderContextSignal.apiVersion,...k==="BUILDER_STUDIO"&&((c=e.context)!=null&&c.symbolId)?{query:{id:e.context.symbolId}}:{}}).then(K=>{K&&i(K)})}}},[]),o.useEffect(()=>{e.content&&i(e.content)},[e.content]),o.useEffect(()=>{F()},[e.builderContextSignal.rootState]),o.useEffect(()=>{e.data&&n(e.data)},[e.data]),o.useEffect(()=>{e.locale&&n({locale:e.locale})},[e.locale]),o.useEffect(()=>()=>{l.isBrowser()&&(window.removeEventListener("message",r),window.removeEventListener("builder:component:stateChangeListenerActivated",F))},[]),f.jsx(C.BuilderContext.Provider,{value:e.builderContextSignal,children:e.builderContextSignal.content||Y()?f.jsx(m,{ref:t,onClick:d=>B(d),"builder-content-id":(b=e.builderContextSignal.content)==null?void 0:b.id,"builder-model":e.model,className:Qe(((x=e.content)==null?void 0:x.testVariationId)||((V=e.content)==null?void 0:V.id)),style:{display:!e.builderContextSignal.content&&Y()?"none":void 0},...s(),...e.contentWrapperProps,children:e.children}):null})}function Ze(e){const[t,n]=o.useState(()=>`
|
|
134
|
-
${Je({cssCode:e.cssCode,contentId:e.contentId})}
|
|
135
|
-
${Me({customFonts:e.customFonts})}
|
|
136
|
-
${Ge(e.isNestedRender)}
|
|
137
|
-
`.trim());return f.jsx(R.InlinedStyles,{id:"builderio-content",styles:t,nonce:e.nonce})}const et=({content:e,data:t,locale:n})=>{var m,a,r;const i={},s=((m=e==null?void 0:e.data)==null?void 0:m.state)||{};return(r=(a=e==null?void 0:e.data)==null?void 0:a.inputs)==null||r.forEach(p=>{p.name&&p.defaultValue!==void 0&&(i[p.name]=p.defaultValue)}),{...i,...s,...t,...n?{locale:n}:{}}},tt=({content:e,data:t})=>e?{...e,data:{...e==null?void 0:e.data,...t},meta:e==null?void 0:e.meta}:void 0;function G(e){var S,v,P,w,W,B,D,F,A;const[t,n]=o.useState(()=>{var b,x;return Ne({variationId:(b=e.content)==null?void 0:b.testVariationId,contentId:(x=e.content)==null?void 0:x.id})});function i(b){r(x=>({...x,rootState:b}))}const[s,m]=o.useState(()=>[...O(),...e.customComponents||[]].reduce((b,{component:x,...V})=>({...b,[V.name]:{component:x,...l.serializeIncludingFunctions(V)}}),{})),[a,r]=o.useState(()=>({content:tt({content:e.content,data:e.data}),localState:void 0,rootState:et({content:e.content,data:e.data,locale:e.locale}),rootSetState:i,context:e.context||{},canTrack:e.canTrack,apiKey:e.apiKey,apiVersion:e.apiVersion,componentInfos:[...O(),...e.customComponents||[]].reduce((b,{component:x,...V})=>({...b,[V.name]:l.serializeIncludingFunctions(V)}),{}),inheritedStyles:{},BlocksWrapper:e.blocksWrapper||"div",BlocksWrapperProps:e.blocksWrapperProps||{},nonce:e.nonce||"",model:e.model})),p=o.useRef(!1);if(!p.current){e.apiKey||l.logger.error("No API key provided to `Content` component. This can cause issues. Please provide an API key using the `apiKey` prop.");const b=(v=(S=a.content)==null?void 0:S.data)==null?void 0:v.jsCode;b&&R.evaluate({code:b,context:e.context||{},localState:void 0,rootState:a.rootState,rootSetState:x=>{Object.assign(a.rootState,x)},isExpression:!1}),p.current=!0}return f.jsx(R.ComponentsContext.Provider,{value:{registeredComponents:s},children:f.jsxs(Xe,{apiHost:e.apiHost,nonce:e.nonce,content:e.content,data:e.data,model:e.model,context:e.context,apiKey:e.apiKey,canTrack:e.canTrack,locale:e.locale,enrich:e.enrich,showContent:e.showContent,builderContextSignal:a,contentWrapper:e.contentWrapper,contentWrapperProps:e.contentWrapperProps,trustedHosts:e.trustedHosts,isNestedRender:e.isNestedRender,setBuilderContextSignal:r,children:[e.isSsrAbTest?f.jsx(H,{id:"builderio-variant-visibility",scriptStr:t,nonce:e.nonce||""}):null,f.jsx(Ze,{nonce:e.nonce||"",isNestedRender:e.isNestedRender,contentId:(P=a.content)==null?void 0:P.id,cssCode:(W=(w=a.content)==null?void 0:w.data)==null?void 0:W.cssCode,customFonts:(D=(B=a.content)==null?void 0:B.data)==null?void 0:D.customFonts}),f.jsx(R.Blocks,{blocks:(A=(F=a.content)==null?void 0:F.data)==null?void 0:A.blocks,context:a,registeredComponents:s,linkComponent:e.linkComponent})]})})}function nt(e){var a;const[t,n]=o.useState(()=>qe({canTrack:l.getDefaultCanTrack(e.canTrack),content:e.content}));function i(){var r;return Le(U(e.content).map(p=>({id:p.testVariationId,testRatio:p.testRatio})),((r=e.content)==null?void 0:r.id)||"")}function s(){return U(e.content).map(r=>`.variant-${r.testVariationId} { display: none; } `).join("")}function m(){var r;return t?{...e.content,testVariationId:(r=e.content)==null?void 0:r.id}:l.handleABTestingSync({item:e.content,canTrack:l.getDefaultCanTrack(e.canTrack)})}return o.useEffect(()=>{},[]),f.jsxs(f.Fragment,{children:[!e.isNestedRender&&l.TARGET!=="reactNative"?f.jsx(H,{id:"builderio-init-variants-fns",scriptStr:je(),nonce:e.nonce||""}):null,t?f.jsxs(f.Fragment,{children:[f.jsx(R.InlinedStyles,{id:"builderio-variants",styles:s(),nonce:e.nonce||""}),f.jsx(H,{id:"builderio-variants-visibility",scriptStr:i(),nonce:e.nonce||""}),(a=U(e.content))==null?void 0:a.map(r=>f.jsx(G,{apiHost:e.apiHost,isNestedRender:e.isNestedRender,nonce:e.nonce,content:r,showContent:!1,model:e.model,data:e.data,context:e.context,apiKey:e.apiKey,apiVersion:e.apiVersion,customComponents:e.customComponents,linkComponent:e.linkComponent,canTrack:e.canTrack,locale:e.locale,enrich:e.enrich,isSsrAbTest:t,blocksWrapper:e.blocksWrapper,blocksWrapperProps:e.blocksWrapperProps,contentWrapper:e.contentWrapper,contentWrapperProps:e.contentWrapperProps,trustedHosts:e.trustedHosts},r.testVariationId))]}):null,f.jsx(G,{apiHost:e.apiHost,nonce:e.nonce,isNestedRender:e.isNestedRender,content:m(),showContent:!0,model:e.model,data:e.data,context:e.context,apiKey:e.apiKey,apiVersion:e.apiVersion,customComponents:e.customComponents,linkComponent:e.linkComponent,canTrack:e.canTrack,locale:e.locale,enrich:e.enrich,isSsrAbTest:t,blocksWrapper:e.blocksWrapper,blocksWrapperProps:e.blocksWrapperProps,contentWrapper:e.contentWrapper,contentWrapperProps:e.contentWrapperProps,trustedHosts:e.trustedHosts})]})}const at=Object.freeze(Object.defineProperty({__proto__:null,default:nt},Symbol.toStringTag,{value:"Module"}));exports.InlinedScript=H;exports.contentVariants=at;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("react/jsx-runtime"),h=require("react"),f=require("./blocks-7e8837dc.cjs"),j=require("./server-entry-1b560ddb.cjs");require("./blocks-exports.cjs");require("./get-class-prop-name-316a93c9.cjs");require("./dynamic-renderer-b29b45ca.cjs");const P=["production","qa","test","development","dev","cdn-qa","cloud","fast","cdn2","cdn-prod"],D=()=>{const e=process.env.NODE_ENV||"production";return P.includes(e)?e:"production"};function A(e){const s=h.useRef(null),[M,g]=h.useState(()=>"unsubmitted"),[y,S]=h.useState(()=>null),[O,T]=h.useState(()=>"");function q(i){var l,d;const u={...e.builderContext.rootState,...i};e.builderContext.rootSetState?(d=(l=e.builderContext).rootSetState)==null||d.call(l,u):e.builderContext.rootState=u}function m(){return j.isEditing()&&e.previewState||M}function F(i){var l;const u=e.sendWithJs||e.sendSubmissionsTo==="email";if(e.sendSubmissionsTo==="zapier")i.preventDefault();else if(u){if(!(e.action||e.sendSubmissionsTo==="email")){i.preventDefault();return}i.preventDefault();const d=i.currentTarget||i.target,v=e.customHeaders||{};let b;const N=new FormData(d),x=Array.from(d.querySelectorAll("input,select,textarea")).filter(t=>!!t.name).map(t=>{let n;const a=t.name;if(t instanceof HTMLInputElement)if(t.type==="radio"){if(t.checked)return n=t.name,{key:a,value:n}}else if(t.type==="checkbox")n=t.checked;else if(t.type==="number"||t.type==="range"){const r=t.valueAsNumber;isNaN(r)||(n=r)}else t.type==="file"?n=t.files:n=t.value;else n=t.value;return{key:a,value:n}});let c=e.contentType;if(e.sendSubmissionsTo==="email"&&(c="multipart/form-data"),Array.from(x).forEach(({value:t})=>{(t instanceof File||Array.isArray(t)&&t[0]instanceof File||t instanceof FileList)&&(c="multipart/form-data")}),c!=="application/json")b=N;else{const t={};Array.from(x).forEach(({value:n,key:a})=>{f.set(t,a,n)}),b=JSON.stringify(t)}c&&c!=="multipart/form-data"&&(u&&((l=e.action)!=null&&l.includes("zapier.com"))||(v["content-type"]=c));const E=new CustomEvent("presubmit",{detail:{body:b}});if(s.current&&(s.current.dispatchEvent(E),E.defaultPrevented))return;g("sending");const w=`${D()==="dev"?"http://localhost:5000":"https://builder.io"}/api/v1/form-submit?apiKey=${e.builderContext.apiKey}&to=${btoa(e.sendSubmissionsToEmail||"")}&name=${encodeURIComponent(e.name||"")}`,C=e.sendSubmissionsTo==="email"?w:e.action;j.logFetch(C),fetch(C,{body:b,headers:v,method:e.method||"post"}).then(async t=>{let n;const a=t.headers.get("content-type");if(a&&a.indexOf("application/json")!==-1?n=await t.json():n=await t.text(),!t.ok&&e.errorMessagePath){let r=f.get(n,e.errorMessagePath);r&&(typeof r!="string"&&(r=JSON.stringify(r)),T(r),q({formErrorMessage:r}))}if(S(n),g(t.ok?"success":"error"),t.ok){const r=new CustomEvent("submit:success",{detail:{res:t,body:n}});if(s.current){if(s.current.dispatchEvent(r),r.defaultPrevented)return;e.resetFormOnSubmit!==!1&&s.current.reset()}if(e.successUrl)if(s.current){const k=new CustomEvent("route",{detail:{url:e.successUrl}});s.current.dispatchEvent(k),k.defaultPrevented||(location.href=e.successUrl)}else location.href=e.successUrl}},t=>{const n=new CustomEvent("submit:error",{detail:{error:t}});s.current&&(s.current.dispatchEvent(n),n.defaultPrevented)||(S(t),g("error"))})}}return o.jsxs(o.Fragment,{children:[" ",o.jsxs("form",{validate:e.validate,ref:s,action:!e.sendWithJs&&e.action,method:e.method,name:e.name,onSubmit:i=>F(i),...e.attributes,children:[e.children,m()==="error"?o.jsx(f.Blocks,{path:"errorMessage",blocks:e.errorMessage,context:e.builderContext}):null,m()==="sending"?o.jsx(f.Blocks,{path:"sendingMessage",blocks:e.sendingMessage,context:e.builderContext}):null,m()==="error"&&y?o.jsx("pre",{className:"builder-form-error-text pre-7acc3b46",children:JSON.stringify(y,null,2)}):null,m()==="success"?o.jsx(f.Blocks,{path:"successMessage",blocks:e.successMessage,context:e.builderContext}):null]})," ",o.jsx("style",{children:".pre-7acc3b46 { padding: 10px; color: red; text-align: center; }"})," "]})}exports.default=A;
|