@builder.io/sdk-react 2.0.8 → 2.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/lib/browser/blocks-exports.cjs +16 -16
  2. package/lib/browser/blocks-exports.mjs +36 -36
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/browser/init.cjs +1 -1
  6. package/lib/browser/init.mjs +1 -1
  7. package/lib/browser/{server-entry-ba3e0524.cjs → server-entry-16fc27fe.cjs} +2 -2
  8. package/lib/{node/server-entry-f6ee5d92.js → browser/server-entry-8bf52a55.js} +74 -73
  9. package/lib/browser/server-entry.cjs +1 -1
  10. package/lib/browser/server-entry.mjs +1 -1
  11. package/lib/edge/{accordion-ef5e6161.js → accordion-589b3ac8.js} +1 -1
  12. package/lib/edge/{accordion-88007399.cjs → accordion-afed3bd3.cjs} +1 -1
  13. package/lib/edge/{blocks-dc478c97.cjs → blocks-854f4022.cjs} +1 -1
  14. package/lib/edge/blocks-exports.cjs +1 -1
  15. package/lib/edge/blocks-exports.mjs +2 -2
  16. package/lib/edge/{blocks-90fd2fd8.js → blocks-fdb24842.js} +3 -3
  17. package/lib/edge/{button-8d307faf.js → button-08412b69.js} +2 -2
  18. package/lib/edge/{button-228f448d.cjs → button-26b76a4a.cjs} +1 -1
  19. package/lib/edge/{columns-77b7011a.js → columns-bd2a004b.js} +4 -4
  20. package/lib/edge/{columns-3547be8c.cjs → columns-ccdafcc7.cjs} +1 -1
  21. package/lib/edge/{content-variants-4f7cad1a.js → content-variants-dd7ea0f9.js} +11 -11
  22. package/lib/edge/{content-variants-f0edf280.cjs → content-variants-fc207487.cjs} +4 -4
  23. package/lib/edge/{evaluate-39c2c786.cjs → evaluate-3991fda5.cjs} +1 -1
  24. package/lib/edge/{evaluate-384a03ed.js → evaluate-e2f692df.js} +1 -1
  25. package/lib/edge/{form-c6da17f5.cjs → form-5eb85abf.cjs} +1 -1
  26. package/lib/edge/{form-d40e9eca.js → form-b9148162.js} +4 -4
  27. package/lib/edge/{get-class-prop-name-767dbeb0.js → get-class-prop-name-0c783f8c.js} +1 -1
  28. package/lib/edge/{get-class-prop-name-4f8743e9.cjs → get-class-prop-name-2fa91d70.cjs} +1 -1
  29. package/lib/edge/{img-c50b3839.cjs → img-2f30658b.cjs} +1 -1
  30. package/lib/edge/{img-d650b796.js → img-602f7d3a.js} +1 -1
  31. package/lib/edge/index.cjs +1 -1
  32. package/lib/edge/index.mjs +1 -1
  33. package/lib/edge/init.cjs +1 -1
  34. package/lib/edge/init.mjs +1 -1
  35. package/lib/edge/{input-5646dcb2.js → input-4c791db9.js} +1 -1
  36. package/lib/edge/{input-aaba7df0.cjs → input-551362f3.cjs} +1 -1
  37. package/lib/edge/{select-d3905dcd.js → select-d1391d12.js} +1 -1
  38. package/lib/edge/{select-2e7bf7d0.cjs → select-eb26f837.cjs} +1 -1
  39. package/lib/edge/server-entry-7b4fa72f.cjs +2 -0
  40. package/lib/edge/{server-entry-29a170e3.js → server-entry-c537d834.js} +59 -58
  41. package/lib/edge/server-entry.cjs +1 -1
  42. package/lib/edge/server-entry.mjs +1 -1
  43. package/lib/edge/{slot-82c0b340.js → slot-d375d5eb.js} +4 -4
  44. package/lib/edge/{slot-695259cf.cjs → slot-d723d000.cjs} +1 -1
  45. package/lib/edge/{symbol-5a6a783f.cjs → symbol-6c18ca90.cjs} +1 -1
  46. package/lib/edge/{symbol-91897bd4.js → symbol-8b3a6b98.js} +2 -2
  47. package/lib/edge/{tabs-a191e7b1.js → tabs-1e47cfd4.js} +4 -4
  48. package/lib/edge/{tabs-4c4a6b19.cjs → tabs-8296bce7.cjs} +1 -1
  49. package/lib/edge/{text-7a00e2f8.cjs → text-9eac9e4d.cjs} +1 -1
  50. package/lib/edge/{text-ca974245.js → text-d3c86634.js} +2 -2
  51. package/lib/node/blocks-exports.cjs +2 -2
  52. package/lib/node/blocks-exports.mjs +2 -2
  53. package/lib/node/index.cjs +1 -1
  54. package/lib/node/index.mjs +2 -2
  55. package/lib/node/init.cjs +1 -1
  56. package/lib/node/init.mjs +2 -2
  57. package/lib/node/{node-runtime-a6fb6ac7.cjs → node-runtime-c7c85f6c.cjs} +1 -1
  58. package/lib/node/{node-runtime-d8e6d827.js → node-runtime-e41e9eb6.js} +1 -1
  59. package/lib/node/{server-entry-ba3e0524.cjs → server-entry-16fc27fe.cjs} +2 -2
  60. package/lib/{browser/server-entry-f6ee5d92.js → node/server-entry-8bf52a55.js} +74 -73
  61. package/lib/node/server-entry.cjs +1 -1
  62. package/lib/node/server-entry.mjs +1 -1
  63. package/package.json +1 -1
  64. package/types/constants/sdk-version.d.ts +1 -1
  65. package/types/functions/register-component.d.ts +1 -1
  66. package/lib/edge/server-entry-b0e7430b.cjs +0 -2
@@ -1,2 +1,2 @@
1
- "use strict";const I="react",b="[Builder.io]: ",d={log:(...e)=>console.log(b,...e),error:(...e)=>console.error(b,...e),warn:(...e)=>console.warn(b,...e),debug:(...e)=>console.debug(b,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const ce=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},V=e=>e instanceof URLSearchParams?ce(e):e,M=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function ue(){return c()&&window.self!==window.top}function U(e){return ue()&&M(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const de=()=>{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},le=()=>typeof navigator=="object"&&navigator.userAgent||"",F=()=>{const e=le(),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()||I==="reactNative"}},n=e.match(/Tablet|iPad/i),r=de();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,fe=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},N=({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}},D=async e=>N(e),ge=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),he=[["secure",""],["SameSite","None"]],pe=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?he:[[]],s=n?[["expires",n.toUTCString()]]:[[]],a=[[e,t],...s,["path","/"],["domain",fe(window.location.hostname)],...o];return ge(a)},j=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=pe({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}},me="builder.tests",k=e=>`${me}.${e}`,ye=({contentId:e})=>D({name:k(e),canTrack:!0}),Se=({contentId:e})=>N({name:k(e),canTrack:!0}),we=({contentId:e,value:t})=>j({name:k(e),value:t,canTrack:!0}),K=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,be=({id:e,variations:t})=>{var o;let n=0;const r=Math.random();for(const s in t){const a=(o=t[s])==null?void 0:o.testRatio;if(n+=a,r<n)return s}return e},_=e=>{const t=be(e);return we({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},W=({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":"")}},Ie=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!K(e))return e;const n=Se({contentId:e.id})||_({variations:e.variations,id:e.id}),r=W({item:e,testGroupId:n});return{...e,...r}},ve=async({item:e,canTrack:t})=>{if(!t||!K(e))return e;const r=await ye({contentId:e.id})||_({variations:e.variations,id:e.id}),o=W({item:e,testGroupId:r});return{...e,...o}},$=e=>p(e)?e:!0,Ee=e=>({type:"builder.registerComponent",data:G(e)}),ke=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function G(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?ke(n):n))}function Pe(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function Ce(){const e=Pe().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 z=Ce();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],a=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,a,n)}:{...r,[a]:s}},{})}function J(e,t,n={}){for(const r in e){const o=e[r],s=t?t+"."+r:r;o&&typeof o=="object"&&!Array.isArray(o)&&!Object.keys(o).find(a=>a.startsWith("$"))?J(o,s,n):n[s]=o}return n}const Oe="v3",T="builder.",Ae="options.",P=e=>{if(!e)return{};const t=V(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(T)){const o=r.replace(T,"").replace(Ae,"");n[o]=t[r]}}),n},Te=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},x=e=>typeof e=="number"&&!isNaN(e)&&e>=0,C=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:a,locale:l,apiVersion:y=Oe,fields:m,omit:v,offset:u,cacheSeconds:g,staleCacheSeconds:h,sort:S,includeUnpublished:O}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const ie=t!==1,i=new URL(`https://cdn.builder.io/api/${y}/content/${o}`);if(i.searchParams.set("apiKey",s),i.searchParams.set("limit",String(t)),i.searchParams.set("noTraverse",String(ie)),i.searchParams.set("includeRefs",String(!0)),l&&i.searchParams.set("locale",l),a&&i.searchParams.set("enrich",String(a)),i.searchParams.set("omit",v||"meta.componentsUsed"),m&&i.searchParams.set("fields",m),Number.isFinite(u)&&u>-1&&i.searchParams.set("offset",String(Math.floor(u))),typeof O=="boolean"&&i.searchParams.set("includeUnpublished",String(O)),g&&x(g)&&i.searchParams.set("cacheSeconds",String(g)),h&&x(h)&&i.searchParams.set("staleCacheSeconds",String(h)),S){const f=E({sort:S});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}const ae={...Te(),...V(e.options||{})},A=E(ae);for(const f in A)i.searchParams.set(f,String(A[f]));if(n&&i.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=J({query:r});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}return i},xe=e=>"results"in e;async function H(e){const t=await q({...e,limit:1});return t&&t[0]||null}const Re=async e=>{var s;const t=C(e);return await(await((s=e.fetch)!=null?s:z)(t.href,e.fetchOptions)).json()},X=async(e,t,n=C(e))=>{const r=$(e.canTrack);if(n.search.includes("preview="),!r||!(c()||I==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await ve({item:s,canTrack:r}));t.results=o}catch(o){d.error("Could not process A/B tests. ",o)}return t.results};async function q(e){try{const t=C(e),n=await Re(e);return xe(n)?X(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}function Be(e){const t=e||(c()?window.location.search:void 0);return t?M(t).indexOf("builder.preview=")!==-1:!1}function Le(){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 Le().replace(/-/g,"")}const Y="builderSessionId",Ve=async({canTrack:e})=>{if(!e)return;const t=await D({name:Y,canTrack:e});if(p(t))return t;{const n=Me();return Ue({id:n,canTrack:e}),n}},Me=()=>Q(),Ue=({id:e,canTrack:t})=>j({name:Y,value:e,canTrack:t}),Z=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Fe=({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(o){console.debug("[LocalStorage] SET error: ",o)}},ee="builderVisitorId",De=({canTrack:e})=>{if(!e)return;const t=Fe({key:ee,canTrack:e});if(p(t))return t;{const n=je();return Ke({id:n,canTrack:e}),n}},je=()=>Q(),Ke=({id:e,canTrack:t})=>Ne({key:ee,value:e,canTrack:t}),_e=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ve({canTrack:e}),n=De({canTrack:e});return{sessionId:t,visitorId:n}},We=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await _e({canTrack:t}),userAttributes:F(),ownerId:n}});async function te(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!U()&&(c()||I==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await We(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const $e=e=>te({...e,canTrack:!0}),Ge=["*.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||Ge).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const ze="2.0.8",R={};function re(e,t){let n=R[e];if(n||(n=R[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(o){console.debug("Could not postmessage",o)}}}const Je=()=>{re("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 B=!1;const oe=(e={})=>{var t,n;B||(B=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:I,version:ze,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,a;if(!ne(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const l=o.data.text,y=o.data.arguments||[],m=o.data.id,v=new Function(l);let u,g=null;try{u=v.apply(null,y)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):u&&typeof u.then=="function"?u.then(h=>{var S;(S=window.parent)==null||S.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(a=window.parent)==null||a.postMessage({type:"builder.evaluateResult",data:{result:u,id:m}},"*");break}}})))},se=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!ne(t,r))return;const{data:o}=r;if(o)switch(o.type){case"builder.configureSdk":{n.configureSdk(o.data);break}case"builder.triggerAnimation":{n.animation(o.data);break}case"builder.contentUpdate":{const s=o.data,a=s.key||s.alias||s.entry||s.modelName,l=s.data;a===e&&n.contentUpdate(l);break}}},He=(e,t,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};oe();const r=se({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},L={};function Xe(e){if(c()){Object.assign(L,e);const t={type:"builder.settingsChange",data:L};parent.postMessage(t,"*")}}const qe=async e=>{var r,o,s;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((o=e.userAttributes)==null?void 0:o.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:P(e.searchParams||((s=e.url)==null?void 0:s.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await H(n)}};exports.MSG_PREFIX=b;exports.TARGET=I;exports._processContentResult=X;exports._track=te;exports.checkIsDefined=p;exports.createEditorListener=se;exports.createRegisterComponentMessage=Ee;exports.fetch=z;exports.fetchBuilderProps=qe;exports.fetchEntries=q;exports.fetchOneEntry=H;exports.getBuilderSearchParams=P;exports.getDefaultCanTrack=$;exports.getUserAttributes=F;exports.handleABTestingSync=Ie;exports.isBrowser=c;exports.isEditing=U;exports.isPreviewing=Be;exports.logger=d;exports.register=re;exports.registerInsertMenu=Je;exports.serializeComponentInfo=G;exports.setEditorSettings=Xe;exports.setupBrowserForEditing=oe;exports.subscribeToEditor=He;exports.track=$e;
1
+ "use strict";const I="react",b="[Builder.io]: ",d={log:(...e)=>console.log(b,...e),error:(...e)=>console.error(b,...e),warn:(...e)=>console.warn(b,...e),debug:(...e)=>console.debug(b,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const ce=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},M=e=>e instanceof URLSearchParams?ce(e):e,U=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function ue(){return c()&&window.self!==window.top}function F(e){return ue()&&U(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const de=()=>{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},le=()=>typeof navigator=="object"&&navigator.userAgent||"",N=()=>{const e=le(),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()||I==="reactNative"}},n=e.match(/Tablet|iPad/i),r=de();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,fe=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},D=({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}},j=async e=>D(e),ge=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),he=[["secure",""],["SameSite","None"]],pe=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?he:[[]],s=n?[["expires",n.toUTCString()]]:[[]],a=[[e,t],...s,["path","/"],["domain",fe(window.location.hostname)],...o];return ge(a)},K=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=pe({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}},me="builder.tests",k=e=>`${me}.${e}`,ye=({contentId:e})=>j({name:k(e),canTrack:!0}),Se=({contentId:e})=>D({name:k(e),canTrack:!0}),we=({contentId:e,value:t})=>K({name:k(e),value:t,canTrack:!0}),_=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,be=({id:e,variations:t})=>{var o;let n=0;const r=Math.random();for(const s in t){const a=(o=t[s])==null?void 0:o.testRatio;if(n+=a,r<n)return s}return e},W=e=>{const t=be(e);return we({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},$=({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":"")}},Ie=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!_(e))return e;const n=Se({contentId:e.id})||W({variations:e.variations,id:e.id}),r=$({item:e,testGroupId:n});return{...e,...r}},ve=async({item:e,canTrack:t})=>{if(!t||!_(e))return e;const r=await ye({contentId:e.id})||W({variations:e.variations,id:e.id}),o=$({item:e,testGroupId:r});return{...e,...o}},G=e=>p(e)?e:!0,Ee=e=>({type:"builder.registerComponent",data:P(e)}),ke=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function P(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?ke(n):n))}function Pe(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function Ce(){const e=Pe().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 z=Ce();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],a=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,a,n)}:{...r,[a]:s}},{})}function J(e,t,n={}){for(const r in e){const o=e[r],s=t?t+"."+r:r;o&&typeof o=="object"&&!Array.isArray(o)&&!Object.keys(o).find(a=>a.startsWith("$"))?J(o,s,n):n[s]=o}return n}const Oe="v3",x="builder.",Ae="options.",C=e=>{if(!e)return{};const t=M(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(x)){const o=r.replace(x,"").replace(Ae,"");n[o]=t[r]}}),n},Te=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return C(e)},R=e=>typeof e=="number"&&!isNaN(e)&&e>=0,O=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:a,locale:l,apiVersion:y=Oe,fields:m,omit:v,offset:u,cacheSeconds:g,staleCacheSeconds:h,sort:S,includeUnpublished:A}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const ie=t!==1,i=new URL(`https://cdn.builder.io/api/${y}/content/${o}`);if(i.searchParams.set("apiKey",s),i.searchParams.set("limit",String(t)),i.searchParams.set("noTraverse",String(ie)),i.searchParams.set("includeRefs",String(!0)),l&&i.searchParams.set("locale",l),a&&i.searchParams.set("enrich",String(a)),i.searchParams.set("omit",v||"meta.componentsUsed"),m&&i.searchParams.set("fields",m),Number.isFinite(u)&&u>-1&&i.searchParams.set("offset",String(Math.floor(u))),typeof A=="boolean"&&i.searchParams.set("includeUnpublished",String(A)),g&&R(g)&&i.searchParams.set("cacheSeconds",String(g)),h&&R(h)&&i.searchParams.set("staleCacheSeconds",String(h)),S){const f=E({sort:S});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}const ae={...Te(),...M(e.options||{})},T=E(ae);for(const f in T)i.searchParams.set(f,String(T[f]));if(n&&i.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=J({query:r});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}return i},xe=e=>"results"in e;async function H(e){const t=await q({...e,limit:1});return t&&t[0]||null}const Re=async e=>{var s;const t=O(e);return await(await((s=e.fetch)!=null?s:z)(t.href,e.fetchOptions)).json()},X=async(e,t,n=O(e))=>{const r=G(e.canTrack);if(n.search.includes("preview="),!r||!(c()||I==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await ve({item:s,canTrack:r}));t.results=o}catch(o){d.error("Could not process A/B tests. ",o)}return t.results};async function q(e){try{const t=O(e),n=await Re(e);return xe(n)?X(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}function Be(e){const t=e||(c()?window.location.search:void 0);return t?U(t).indexOf("builder.preview=")!==-1:!1}function Le(){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 Le().replace(/-/g,"")}const Y="builderSessionId",Ve=async({canTrack:e})=>{if(!e)return;const t=await j({name:Y,canTrack:e});if(p(t))return t;{const n=Me();return Ue({id:n,canTrack:e}),n}},Me=()=>Q(),Ue=({id:e,canTrack:t})=>K({name:Y,value:e,canTrack:t}),Z=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Fe=({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(o){console.debug("[LocalStorage] SET error: ",o)}},ee="builderVisitorId",De=({canTrack:e})=>{if(!e)return;const t=Fe({key:ee,canTrack:e});if(p(t))return t;{const n=je();return Ke({id:n,canTrack:e}),n}},je=()=>Q(),Ke=({id:e,canTrack:t})=>Ne({key:ee,value:e,canTrack:t}),_e=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ve({canTrack:e}),n=De({canTrack:e});return{sessionId:t,visitorId:n}},We=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await _e({canTrack:t}),userAttributes:N(),ownerId:n}});async function te(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!F()&&(c()||I==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await We(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const $e=e=>te({...e,canTrack:!0}),Ge=["*.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||Ge).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const ze="2.0.9",B={};function re(e,t){e==="plugin"&&(t=P(t));let n=B[e];if(n||(n=B[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(o){console.debug("Could not postmessage",o)}}}const Je=()=>{re("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 L=!1;const oe=(e={})=>{var t,n;L||(L=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:I,version:ze,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,a;if(!ne(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const l=o.data.text,y=o.data.arguments||[],m=o.data.id,v=new Function(l);let u,g=null;try{u=v.apply(null,y)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):u&&typeof u.then=="function"?u.then(h=>{var S;(S=window.parent)==null||S.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(a=window.parent)==null||a.postMessage({type:"builder.evaluateResult",data:{result:u,id:m}},"*");break}}})))},se=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!ne(t,r))return;const{data:o}=r;if(o)switch(o.type){case"builder.configureSdk":{n.configureSdk(o.data);break}case"builder.triggerAnimation":{n.animation(o.data);break}case"builder.contentUpdate":{const s=o.data,a=s.key||s.alias||s.entry||s.modelName,l=s.data;a===e&&n.contentUpdate(l);break}}},He=(e,t,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};oe();const r=se({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},V={};function Xe(e){if(c()){Object.assign(V,e);const t={type:"builder.settingsChange",data:V};parent.postMessage(t,"*")}}const qe=async e=>{var r,o,s;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((o=e.userAttributes)==null?void 0:o.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:C(e.searchParams||((s=e.url)==null?void 0:s.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await H(n)}};exports.MSG_PREFIX=b;exports.TARGET=I;exports._processContentResult=X;exports._track=te;exports.checkIsDefined=p;exports.createEditorListener=se;exports.createRegisterComponentMessage=Ee;exports.fetch=z;exports.fetchBuilderProps=qe;exports.fetchEntries=q;exports.fetchOneEntry=H;exports.getBuilderSearchParams=C;exports.getDefaultCanTrack=G;exports.getUserAttributes=N;exports.handleABTestingSync=Ie;exports.isBrowser=c;exports.isEditing=F;exports.isPreviewing=Be;exports.logger=d;exports.register=re;exports.registerInsertMenu=Je;exports.serializeIncludingFunctions=P;exports.setEditorSettings=Xe;exports.setupBrowserForEditing=oe;exports.subscribeToEditor=He;exports.track=$e;
@@ -7,27 +7,27 @@ const v = "react", b = "[Builder.io]: ", f = {
7
7
  function c() {
8
8
  return typeof window != "undefined" && typeof document != "undefined";
9
9
  }
10
- const q = (t) => {
10
+ const Q = (t) => {
11
11
  const e = {};
12
12
  return t.forEach((n, r) => {
13
13
  e[r] = n;
14
14
  }), e;
15
- }, L = (t) => t instanceof URLSearchParams ? q(t) : t, V = (t) => typeof t == "string" ? t : t instanceof URLSearchParams ? t.toString() : new URLSearchParams(t).toString();
16
- function Q() {
15
+ }, L = (t) => t instanceof URLSearchParams ? Q(t) : t, V = (t) => typeof t == "string" ? t : t instanceof URLSearchParams ? t.toString() : new URLSearchParams(t).toString();
16
+ function Y() {
17
17
  return c() && window.self !== window.top;
18
18
  }
19
- function Y(t) {
20
- return Q() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
19
+ function Z(t) {
20
+ return Y() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser.
21
21
  V(t || window.location.search).indexOf("builder.frameEditing=") !== -1;
22
22
  }
23
- const Z = () => {
23
+ const tt = () => {
24
24
  if (c()) {
25
25
  const t = new URL(location.href);
26
26
  return t.pathname === "" && (t.pathname = "/"), t;
27
27
  } else
28
28
  return console.warn("Cannot get location for tracking in non-browser environment"), null;
29
- }, tt = () => typeof navigator == "object" && navigator.userAgent || "", et = () => {
30
- const t = tt(), e = {
29
+ }, et = () => typeof navigator == "object" && navigator.userAgent || "", nt = () => {
30
+ const t = et(), e = {
31
31
  Android() {
32
32
  return t.match(/Android/i);
33
33
  },
@@ -46,13 +46,13 @@ const Z = () => {
46
46
  any() {
47
47
  return e.Android() || e.BlackBerry() || e.iOS() || e.Opera() || e.Windows() || v === "reactNative";
48
48
  }
49
- }, n = t.match(/Tablet|iPad/i), r = Z();
49
+ }, n = t.match(/Tablet|iPad/i), r = tt();
50
50
  return {
51
51
  urlPath: r == null ? void 0 : r.pathname,
52
52
  host: (r == null ? void 0 : r.host) || (r == null ? void 0 : r.hostname),
53
53
  device: n ? "tablet" : e.any() ? "mobile" : "desktop"
54
54
  };
55
- }, m = (t) => t != null, nt = (t) => {
55
+ }, m = (t) => t != null, rt = (t) => {
56
56
  if (t === "localhost" || t === "127.0.0.1")
57
57
  return t;
58
58
  const e = t.split(".");
@@ -68,14 +68,14 @@ const Z = () => {
68
68
  f.warn("[COOKIE] GET error: ", (r == null ? void 0 : r.message) || r);
69
69
  return;
70
70
  }
71
- }, M = async (t) => U(t), rt = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(m).join("; "), ot = [["secure", ""], ["SameSite", "None"]], st = ({
71
+ }, M = async (t) => U(t), ot = (t) => t.map(([e, n]) => n ? `${e}=${n}` : e).filter(m).join("; "), st = [["secure", ""], ["SameSite", "None"]], it = ({
72
72
  name: t,
73
73
  value: e,
74
74
  expires: n
75
75
  }) => {
76
- const o = (c() ? location.protocol === "https:" : !0) ? ot : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[t, e], ...s, ["path", "/"], ["domain", nt(window.location.hostname)], ...o];
77
- return rt(a);
78
- }, N = async ({
76
+ const o = (c() ? location.protocol === "https:" : !0) ? st : [[]], s = n ? [["expires", n.toUTCString()]] : [[]], a = [[t, e], ...s, ["path", "/"], ["domain", rt(window.location.hostname)], ...o];
77
+ return ot(a);
78
+ }, F = async ({
79
79
  name: t,
80
80
  value: e,
81
81
  expires: n,
@@ -84,7 +84,7 @@ const Z = () => {
84
84
  try {
85
85
  if (!r)
86
86
  return;
87
- const o = st({
87
+ const o = it({
88
88
  name: t,
89
89
  value: e,
90
90
  expires: n
@@ -93,24 +93,24 @@ const Z = () => {
93
93
  } catch (o) {
94
94
  f.warn("[COOKIE] SET error: ", (o == null ? void 0 : o.message) || o);
95
95
  }
96
- }, it = "builder.tests", E = (t) => `${it}.${t}`, at = ({
96
+ }, at = "builder.tests", E = (t) => `${at}.${t}`, ct = ({
97
97
  contentId: t
98
98
  }) => M({
99
99
  name: E(t),
100
100
  canTrack: !0
101
- }), ct = ({
101
+ }), ut = ({
102
102
  contentId: t
103
103
  }) => U({
104
104
  name: E(t),
105
105
  canTrack: !0
106
- }), ut = ({
106
+ }), dt = ({
107
107
  contentId: t,
108
108
  value: e
109
- }) => N({
109
+ }) => F({
110
110
  name: E(t),
111
111
  value: e,
112
112
  canTrack: !0
113
- }), F = (t) => m(t.id) && m(t.variations) && Object.keys(t.variations).length > 0, dt = ({
113
+ }), N = (t) => m(t.id) && m(t.variations) && Object.keys(t.variations).length > 0, lt = ({
114
114
  id: t,
115
115
  variations: e
116
116
  }) => {
@@ -124,8 +124,8 @@ const Z = () => {
124
124
  }
125
125
  return t;
126
126
  }, j = (t) => {
127
- const e = dt(t);
128
- return ut({
127
+ const e = lt(t);
128
+ return dt({
129
129
  contentId: t.id,
130
130
  value: e
131
131
  }).catch((n) => {
@@ -153,9 +153,9 @@ const Z = () => {
153
153
  return t;
154
154
  if (!t)
155
155
  return;
156
- if (!F(t))
156
+ if (!N(t))
157
157
  return t;
158
- const n = ct({
158
+ const n = ut({
159
159
  contentId: t.id
160
160
  }) || j({
161
161
  variations: t.variations,
@@ -168,13 +168,13 @@ const Z = () => {
168
168
  ...t,
169
169
  ...r
170
170
  };
171
- }, lt = async ({
171
+ }, ft = async ({
172
172
  item: t,
173
173
  canTrack: e
174
174
  }) => {
175
- if (!e || !F(t))
175
+ if (!e || !N(t))
176
176
  return t;
177
- const r = await at({
177
+ const r = await ct({
178
178
  contentId: t.id
179
179
  }) || j({
180
180
  variations: t.variations,
@@ -187,15 +187,15 @@ const Z = () => {
187
187
  ...t,
188
188
  ...o
189
189
  };
190
- }, ft = (t) => m(t) ? t : !0, $t = (t) => ({
190
+ }, ht = (t) => m(t) ? t : !0, $t = (t) => ({
191
191
  type: "builder.registerComponent",
192
- data: gt(t)
193
- }), ht = (t) => {
192
+ data: K(t)
193
+ }), gt = (t) => {
194
194
  const e = t.toString().trim();
195
195
  return `return (${!e.startsWith("function") && !e.startsWith("(") ? "function " : ""}${e}).apply(this, arguments)`;
196
196
  };
197
- function gt(t) {
198
- return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? ht(n) : n));
197
+ function K(t) {
198
+ return JSON.parse(JSON.stringify(t, (e, n) => typeof n == "function" ? gt(n) : n));
199
199
  }
200
200
  function pt() {
201
201
  return typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : globalThis;
@@ -220,14 +220,14 @@ function k(t, e = null, n = ".") {
220
220
  };
221
221
  }, {});
222
222
  }
223
- function K(t, e, n = {}) {
223
+ function W(t, e, n = {}) {
224
224
  for (const r in t) {
225
225
  const o = t[r], s = e ? e + "." + r : r;
226
- o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? K(o, s, n) : n[s] = o;
226
+ o && typeof o == "object" && !Array.isArray(o) && !Object.keys(o).find((a) => a.startsWith("$")) ? W(o, s, n) : n[s] = o;
227
227
  }
228
228
  return n;
229
229
  }
230
- const wt = "v3", x = "builder.", St = "options.", W = (t) => {
230
+ const wt = "v3", x = "builder.", St = "options.", _ = (t) => {
231
231
  if (!t)
232
232
  return {};
233
233
  const e = L(t), n = {};
@@ -241,7 +241,7 @@ const wt = "v3", x = "builder.", St = "options.", W = (t) => {
241
241
  if (!c())
242
242
  return {};
243
243
  const t = new URLSearchParams(window.location.search);
244
- return W(t);
244
+ return _(t);
245
245
  }, A = (t) => typeof t == "number" && !isNaN(t) && t >= 0, P = (t) => {
246
246
  const {
247
247
  limit: e = 30,
@@ -264,22 +264,22 @@ const wt = "v3", x = "builder.", St = "options.", W = (t) => {
264
264
  throw new Error("Missing API key");
265
265
  if (!["v3"].includes(y))
266
266
  throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);
267
- const H = e !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
268
- if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(e)), i.searchParams.set("noTraverse", String(H)), i.searchParams.set("includeRefs", String(!0)), d && i.searchParams.set("locale", d), a && i.searchParams.set("enrich", String(a)), i.searchParams.set("omit", I || "meta.componentsUsed"), p && i.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && i.searchParams.set("offset", String(Math.floor(u))), typeof O == "boolean" && i.searchParams.set("includeUnpublished", String(O)), h && A(h) && i.searchParams.set("cacheSeconds", String(h)), g && A(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
267
+ const X = e !== 1, i = new URL(`https://cdn.builder.io/api/${y}/content/${o}`);
268
+ if (i.searchParams.set("apiKey", s), i.searchParams.set("limit", String(e)), i.searchParams.set("noTraverse", String(X)), i.searchParams.set("includeRefs", String(!0)), d && i.searchParams.set("locale", d), a && i.searchParams.set("enrich", String(a)), i.searchParams.set("omit", I || "meta.componentsUsed"), p && i.searchParams.set("fields", p), Number.isFinite(u) && u > -1 && i.searchParams.set("offset", String(Math.floor(u))), typeof O == "boolean" && i.searchParams.set("includeUnpublished", String(O)), h && A(h) && i.searchParams.set("cacheSeconds", String(h)), g && A(g) && i.searchParams.set("staleCacheSeconds", String(g)), w) {
269
269
  const l = k({
270
270
  sort: w
271
271
  });
272
272
  for (const S in l)
273
273
  i.searchParams.set(S, JSON.stringify(l[S]));
274
274
  }
275
- const X = {
275
+ const q = {
276
276
  ...bt(),
277
277
  ...L(t.options || {})
278
- }, C = k(X);
278
+ }, C = k(q);
279
279
  for (const l in C)
280
280
  i.searchParams.set(l, String(C[l]));
281
281
  if (n && i.searchParams.set("userAttributes", JSON.stringify(n)), r) {
282
- const l = K({
282
+ const l = W({
283
283
  query: r
284
284
  });
285
285
  for (const S in l)
@@ -299,13 +299,13 @@ const kt = async (t) => {
299
299
  const e = P(t);
300
300
  return await (await ((s = t.fetch) != null ? s : yt)(e.href, t.fetchOptions)).json();
301
301
  }, Et = async (t, e, n = P(t)) => {
302
- const r = ft(t.canTrack);
302
+ const r = ht(t.canTrack);
303
303
  if (n.search.includes("preview="), !r || !(c() || v === "reactNative"))
304
304
  return e.results;
305
305
  try {
306
306
  const o = [];
307
307
  for (const s of e.results)
308
- o.push(await lt({
308
+ o.push(await ft({
309
309
  item: s,
310
310
  canTrack: r
311
311
  }));
@@ -337,16 +337,16 @@ function Ot() {
337
337
  return (t == "x" ? e : e & 3 | 8).toString(16);
338
338
  });
339
339
  }
340
- function _() {
340
+ function $() {
341
341
  return Ot().replace(/-/g, "");
342
342
  }
343
- const $ = "builderSessionId", Ct = async ({
343
+ const G = "builderSessionId", Ct = async ({
344
344
  canTrack: t
345
345
  }) => {
346
346
  if (!t)
347
347
  return;
348
348
  const e = await M({
349
- name: $,
349
+ name: G,
350
350
  canTrack: t
351
351
  });
352
352
  if (m(e))
@@ -358,20 +358,20 @@ const $ = "builderSessionId", Ct = async ({
358
358
  canTrack: t
359
359
  }), n;
360
360
  }
361
- }, xt = () => _(), At = ({
361
+ }, xt = () => $(), At = ({
362
362
  id: t,
363
363
  canTrack: e
364
- }) => N({
365
- name: $,
364
+ }) => F({
365
+ name: G,
366
366
  value: t,
367
367
  canTrack: e
368
- }), G = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, Tt = ({
368
+ }), J = () => c() && typeof localStorage != "undefined" ? localStorage : void 0, Tt = ({
369
369
  key: t,
370
370
  canTrack: e
371
371
  }) => {
372
372
  var n;
373
373
  try {
374
- return e ? (n = G()) == null ? void 0 : n.getItem(t) : void 0;
374
+ return e ? (n = J()) == null ? void 0 : n.getItem(t) : void 0;
375
375
  } catch (r) {
376
376
  console.debug("[LocalStorage] GET error: ", r);
377
377
  return;
@@ -383,17 +383,17 @@ const $ = "builderSessionId", Ct = async ({
383
383
  }) => {
384
384
  var r;
385
385
  try {
386
- e && ((r = G()) == null || r.setItem(t, n));
386
+ e && ((r = J()) == null || r.setItem(t, n));
387
387
  } catch (o) {
388
388
  console.debug("[LocalStorage] SET error: ", o);
389
389
  }
390
- }, J = "builderVisitorId", Bt = ({
390
+ }, z = "builderVisitorId", Bt = ({
391
391
  canTrack: t
392
392
  }) => {
393
393
  if (!t)
394
394
  return;
395
395
  const e = Tt({
396
- key: J,
396
+ key: z,
397
397
  canTrack: t
398
398
  });
399
399
  if (m(e))
@@ -405,11 +405,11 @@ const $ = "builderSessionId", Ct = async ({
405
405
  canTrack: t
406
406
  }), n;
407
407
  }
408
- }, Lt = () => _(), Vt = ({
408
+ }, Lt = () => $(), Vt = ({
409
409
  id: t,
410
410
  canTrack: e
411
411
  }) => Rt({
412
- key: J,
412
+ key: z,
413
413
  value: t,
414
414
  canTrack: e
415
415
  }), Ut = async ({
@@ -446,16 +446,16 @@ const $ = "builderSessionId", Ct = async ({
446
446
  ...await Ut({
447
447
  canTrack: e
448
448
  }),
449
- userAttributes: et(),
449
+ userAttributes: nt(),
450
450
  ownerId: n
451
451
  }
452
452
  });
453
- async function Nt(t) {
453
+ async function Ft(t) {
454
454
  if (!t.apiKey) {
455
455
  f.error("Missing API key for track call. Please provide your API key.");
456
456
  return;
457
457
  }
458
- if (t.canTrack && !Y() && (c() || v === "reactNative"))
458
+ if (t.canTrack && !Z() && (c() || v === "reactNative"))
459
459
  return fetch("https://cdn.builder.io/api/v1/track", {
460
460
  method: "POST",
461
461
  body: JSON.stringify({
@@ -469,18 +469,19 @@ async function Nt(t) {
469
469
  console.error("Failed to track: ", e);
470
470
  });
471
471
  }
472
- const Jt = (t) => Nt({
472
+ const Jt = (t) => Ft({
473
473
  ...t,
474
474
  canTrack: !0
475
- }), Ft = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
476
- function z(t, e) {
475
+ }), Nt = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"];
476
+ function H(t, e) {
477
477
  if (!e.origin.startsWith("http") && !e.origin.startsWith("https"))
478
478
  return !1;
479
479
  const n = new URL(e.origin), r = n.hostname;
480
- return (t || Ft).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
480
+ return (t || Nt).findIndex((o) => o.startsWith("*.") ? r.endsWith(o.slice(1)) : o === r) > -1;
481
481
  }
482
- const jt = "2.0.8", T = {};
482
+ const jt = "2.0.9", T = {};
483
483
  function Dt(t, e) {
484
+ t === "plugin" && (e = K(e));
484
485
  let n = T[t];
485
486
  if (n || (n = T[t] = []), n.push(e), c()) {
486
487
  const r = {
@@ -541,7 +542,7 @@ const Kt = (t = {}) => {
541
542
  }
542
543
  }, "*"), window.addEventListener("message", (r) => {
543
544
  var s, a;
544
- if (!z(t.trustedHosts, r))
545
+ if (!H(t.trustedHosts, r))
545
546
  return;
546
547
  const {
547
548
  data: o
@@ -587,7 +588,7 @@ const Kt = (t = {}) => {
587
588
  trustedHosts: e,
588
589
  callbacks: n
589
590
  }) => (r) => {
590
- if (!z(e, r))
591
+ if (!H(e, r))
591
592
  return;
592
593
  const {
593
594
  data: o
@@ -650,7 +651,7 @@ const qt = async (t) => {
650
651
  urlPath: e
651
652
  } : {}
652
653
  },
653
- options: W(t.searchParams || ((s = t.url) == null ? void 0 : s.searchParams) || t.options)
654
+ options: _(t.searchParams || ((s = t.url) == null ? void 0 : s.searchParams) || t.options)
654
655
  };
655
656
  return {
656
657
  apiKey: n.apiKey,
@@ -662,7 +663,7 @@ export {
662
663
  b as MSG_PREFIX,
663
664
  v as TARGET,
664
665
  Et as _processContentResult,
665
- Nt as _track,
666
+ Ft as _track,
666
667
  m as checkIsDefined,
667
668
  Wt as createEditorListener,
668
669
  $t as createRegisterComponentMessage,
@@ -670,17 +671,17 @@ export {
670
671
  qt as fetchBuilderProps,
671
672
  Pt as fetchEntries,
672
673
  It as fetchOneEntry,
673
- W as getBuilderSearchParams,
674
- ft as getDefaultCanTrack,
675
- et as getUserAttributes,
674
+ _ as getBuilderSearchParams,
675
+ ht as getDefaultCanTrack,
676
+ nt as getUserAttributes,
676
677
  _t as handleABTestingSync,
677
678
  c as isBrowser,
678
- Y as isEditing,
679
+ Z as isEditing,
679
680
  Gt as isPreviewing,
680
681
  f as logger,
681
682
  Dt as register,
682
683
  zt as registerInsertMenu,
683
- gt as serializeComponentInfo,
684
+ K as serializeIncludingFunctions,
684
685
  Xt as setEditorSettings,
685
686
  Kt as setupBrowserForEditing,
686
687
  Ht as subscribeToEditor,
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-ba3e0524.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
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./server-entry-16fc27fe.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-f6ee5d92.js";
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-8bf52a55.js";
2
2
  export {
3
3
  r as _processContentResult,
4
4
  s as createRegisterComponentMessage,
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": "2.0.8",
4
+ "version": "2.0.9",
5
5
  "homepage": "https://github.com/BuilderIO/builder/tree/main/packages/sdks/output/react",
6
6
  "type": "module",
7
7
  "repository": {
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.0.8";
1
+ export declare const SDK_VERSION = "2.0.9";
@@ -3,4 +3,4 @@ export declare const createRegisterComponentMessage: (info: ComponentInfo) => {
3
3
  type: string;
4
4
  data: any;
5
5
  };
6
- export declare function serializeComponentInfo(info: ComponentInfo): any;
6
+ export declare function serializeIncludingFunctions(info: ComponentInfo): any;
@@ -1,2 +0,0 @@
1
- "use strict";const I="react",ce=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},V=e=>e instanceof URLSearchParams?ce(e):e,M=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function c(){return typeof window!="undefined"&&typeof document!="undefined"}function ue(){return c()&&window.self!==window.top}function U(e){return ue()&&M(e||window.location.search).indexOf("builder.frameEditing=")!==-1}function de(e){const t=e||(c()?window.location.search:void 0);return t?M(t).indexOf("builder.preview=")!==-1:!1}const le=e=>({type:"builder.registerComponent",data:F(e)}),fe=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function F(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?fe(n):n))}const T={};function N(e,t){let n=T[e];if(n||(n=T[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(o){console.debug("Could not postmessage",o)}}}const x={};function ge(e){if(c()){Object.assign(x,e);const t={type:"builder.settingsChange",data:x};parent.postMessage(t,"*")}}const R="builder.",he="options.",k=e=>{if(!e)return{};const t=V(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(R)){const o=r.replace(R,"").replace(he,"");n[o]=t[r]}}),n},pe=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return k(e)},b="[Builder.io]: ",d={log:(...e)=>console.log(b,...e),error:(...e)=>console.error(b,...e),warn:(...e)=>console.warn(b,...e),debug:(...e)=>console.debug(b,...e)},p=e=>e!=null,me=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},D=({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}},j=async e=>D(e),ye=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),Se=[["secure",""],["SameSite","None"]],we=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?Se:[[]],s=n?[["expires",n.toUTCString()]]:[[]],a=[[e,t],...s,["path","/"],["domain",me(window.location.hostname)],...o];return ye(a)},K=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=we({name:e,value:t,expires:n});document.cookie=o}catch(o){d.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};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 _(){return be().replace(/-/g,"")}const W="builderSessionId",Ie=async({canTrack:e})=>{if(!e)return;const t=await j({name:W,canTrack:e});if(p(t))return t;{const n=ve();return Ee({id:n,canTrack:e}),n}},ve=()=>_(),Ee=({id:e,canTrack:t})=>K({name:W,value:e,canTrack:t}),$=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,ke=({key:e,canTrack:t})=>{var n;try{return t?(n=$())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Pe=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=$())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},G="builderVisitorId",Ce=({canTrack:e})=>{if(!e)return;const t=ke({key:G,canTrack:e});if(p(t))return t;{const n=Oe();return Ae({id:n,canTrack:e}),n}},Oe=()=>_(),Ae=({id:e,canTrack:t})=>Pe({key:G,value:e,canTrack:t}),Te=()=>{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},xe=()=>typeof navigator=="object"&&navigator.userAgent||"",z=()=>{const e=xe(),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()||I==="reactNative"}},n=e.match(/Tablet|iPad/i),r=Te();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"}},Re=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Ie({canTrack:e}),n=Ce({canTrack:e});return{sessionId:t,visitorId:n}},Be=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await Re({canTrack:t}),userAttributes:z(),ownerId:n}});async function J(e){if(!e.apiKey){d.error("Missing API key for track call. Please provide your API key.");return}if(e.canTrack&&!U()&&(c()||I==="reactNative"))return fetch("https://cdn.builder.io/api/v1/track",{method:"POST",body:JSON.stringify({events:[await Be(e)]}),headers:{"content-type":"application/json"},mode:"cors"}).catch(t=>{console.error("Failed to track: ",t)})}const Le=e=>J({...e,canTrack:!0}),Ve=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function H(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Ve).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Me="2.0.8",Ue=()=>{N("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 B=!1;const X=(e={})=>{var t,n;B||(B=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:I,version:Me,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,a;if(!H(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const l=o.data.text,y=o.data.arguments||[],m=o.data.id,v=new Function(l);let u,g=null;try{u=v.apply(null,y)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):u&&typeof u.then=="function"?u.then(h=>{var S;(S=window.parent)==null||S.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(a=window.parent)==null||a.postMessage({type:"builder.evaluateResult",data:{result:u,id:m}},"*");break}}})))},q=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!H(t,r))return;const{data:o}=r;if(o)switch(o.type){case"builder.configureSdk":{n.configureSdk(o.data);break}case"builder.triggerAnimation":{n.animation(o.data);break}case"builder.contentUpdate":{const s=o.data,a=s.key||s.alias||s.entry||s.modelName,l=s.data;a===e&&n.contentUpdate(l);break}}},Fe=(e,t,n)=>{if(!c)return d.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};X();const r=q({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},Ne="builder.tests",P=e=>`${Ne}.${e}`,De=({contentId:e})=>j({name:P(e),canTrack:!0}),je=({contentId:e})=>D({name:P(e),canTrack:!0}),Ke=({contentId:e,value:t})=>K({name:P(e),value:t,canTrack:!0}),Q=e=>p(e.id)&&p(e.variations)&&Object.keys(e.variations).length>0,_e=({id:e,variations:t})=>{var o;let n=0;const r=Math.random();for(const s in t){const a=(o=t[s])==null?void 0:o.testRatio;if(n+=a,r<n)return s}return e},Y=e=>{const t=_e(e);return Ke({contentId:e.id,value:t}).catch(n=>{d.error("could not store A/B test variation: ",n)}),t},Z=({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":"")}},We=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!Q(e))return e;const n=je({contentId:e.id})||Y({variations:e.variations,id:e.id}),r=Z({item:e,testGroupId:n});return{...e,...r}},$e=async({item:e,canTrack:t})=>{if(!t||!Q(e))return e;const r=await De({contentId:e.id})||Y({variations:e.variations,id:e.id}),o=Z({item:e,testGroupId:r});return{...e,...o}},ee=e=>p(e)?e:!0;function Ge(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ze(){const e=Ge().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 te=ze();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],a=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,a,n)}:{...r,[a]:s}},{})}function ne(e,t,n={}){for(const r in e){const o=e[r],s=t?t+"."+r:r;o&&typeof o=="object"&&!Array.isArray(o)&&!Object.keys(o).find(a=>a.startsWith("$"))?ne(o,s,n):n[s]=o}return n}const Je="v3",L=e=>typeof e=="number"&&!isNaN(e)&&e>=0,C=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:a,locale:l,apiVersion:y=Je,fields:m,omit:v,offset:u,cacheSeconds:g,staleCacheSeconds:h,sort:S,includeUnpublished:O}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(y))throw new Error(`Invalid apiVersion: expected 'v3', received '${y}'`);const ie=t!==1,i=new URL(`https://cdn.builder.io/api/${y}/content/${o}`);if(i.searchParams.set("apiKey",s),i.searchParams.set("limit",String(t)),i.searchParams.set("noTraverse",String(ie)),i.searchParams.set("includeRefs",String(!0)),l&&i.searchParams.set("locale",l),a&&i.searchParams.set("enrich",String(a)),i.searchParams.set("omit",v||"meta.componentsUsed"),m&&i.searchParams.set("fields",m),Number.isFinite(u)&&u>-1&&i.searchParams.set("offset",String(Math.floor(u))),typeof O=="boolean"&&i.searchParams.set("includeUnpublished",String(O)),g&&L(g)&&i.searchParams.set("cacheSeconds",String(g)),h&&L(h)&&i.searchParams.set("staleCacheSeconds",String(h)),S){const f=E({sort:S});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}const ae={...pe(),...V(e.options||{})},A=E(ae);for(const f in A)i.searchParams.set(f,String(A[f]));if(n&&i.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=ne({query:r});for(const w in f)i.searchParams.set(w,JSON.stringify(f[w]))}return i},He=e=>"results"in e;async function re(e){const t=await se({...e,limit:1});return t&&t[0]||null}const Xe=async e=>{var s;const t=C(e);return await(await((s=e.fetch)!=null?s:te)(t.href,e.fetchOptions)).json()},oe=async(e,t,n=C(e))=>{const r=ee(e.canTrack);if(n.search.includes("preview="),!r||!(c()||I==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await $e({item:s,canTrack:r}));t.results=o}catch(o){d.error("Could not process A/B tests. ",o)}return t.results};async function se(e){try{const t=C(e),n=await Xe(e);return He(n)?oe(e,n):(d.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return d.error("Error fetching data. ",t),null}}const qe=async e=>{var r,o,s;const t=e.path||((r=e.url)==null?void 0:r.pathname)||((o=e.userAttributes)==null?void 0:o.urlPath),n={...e,apiKey:e.apiKey,model:e.model||"page",userAttributes:{...e.userAttributes,...t?{urlPath:t}:{}},options:k(e.searchParams||((s=e.url)==null?void 0:s.searchParams)||e.options)};return{apiKey:n.apiKey,model:n.model,content:await re(n)}};exports.MSG_PREFIX=b;exports.TARGET=I;exports._processContentResult=oe;exports._track=J;exports.checkIsDefined=p;exports.createEditorListener=q;exports.createRegisterComponentMessage=le;exports.fetch=te;exports.fetchBuilderProps=qe;exports.fetchEntries=se;exports.fetchOneEntry=re;exports.getBuilderSearchParams=k;exports.getDefaultCanTrack=ee;exports.getUserAttributes=z;exports.handleABTestingSync=We;exports.isBrowser=c;exports.isEditing=U;exports.isPreviewing=de;exports.logger=d;exports.register=N;exports.registerInsertMenu=Ue;exports.serializeComponentInfo=F;exports.setEditorSettings=ge;exports.setupBrowserForEditing=X;exports.subscribeToEditor=Fe;exports.track=Le;