@builder.io/sdk-react 2.0.28 → 2.0.30

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 (70) hide show
  1. package/lib/browser/blocks-exports.cjs +18 -18
  2. package/lib/browser/blocks-exports.mjs +819 -814
  3. package/lib/browser/index.cjs +1 -1
  4. package/lib/browser/index.mjs +1 -1
  5. package/lib/browser/{server-entry-ffd47885.js → server-entry-d133a206.js} +104 -95
  6. package/lib/browser/server-entry-d4ea1a12.cjs +2 -0
  7. package/lib/browser/server-entry.cjs +1 -1
  8. package/lib/browser/server-entry.mjs +1 -1
  9. package/lib/edge/{accordion-616460c1.js → accordion-359367e6.js} +5 -3
  10. package/lib/edge/{accordion-7ef6a928.cjs → accordion-93512a19.cjs} +1 -1
  11. package/lib/edge/{blocks-896a56b0.cjs → blocks-44a0617b.cjs} +3 -3
  12. package/lib/edge/{blocks-dd91ae28.js → blocks-d7ba8f6a.js} +63 -57
  13. package/lib/edge/blocks-exports.cjs +1 -1
  14. package/lib/edge/blocks-exports.mjs +2 -2
  15. package/lib/edge/{button-1fa8b647.cjs → button-0ae65c1d.cjs} +1 -1
  16. package/lib/edge/{button-f917a1c0.js → button-ae26a553.js} +2 -2
  17. package/lib/edge/{columns-dacb342b.js → columns-957c0468.js} +20 -20
  18. package/lib/edge/{columns-5756d7b8.cjs → columns-f7da8908.cjs} +3 -3
  19. package/lib/edge/{content-variants-afc4a718.cjs → content-variants-9bb0b7e9.cjs} +4 -4
  20. package/lib/edge/{content-variants-cd80b703.js → content-variants-d8a859a2.js} +118 -118
  21. package/lib/edge/{evaluate-2fcda9ec.cjs → evaluate-21c48a1d.cjs} +1 -1
  22. package/lib/edge/{evaluate-17c2cadd.js → evaluate-8e8c9fec.js} +1 -1
  23. package/lib/edge/form-0b09120c.cjs +1 -0
  24. package/lib/edge/{form-dc7f56c9.js → form-68fc4d5a.js} +30 -33
  25. package/lib/edge/{get-class-prop-name-5437ca23.js → get-class-prop-name-a6f0f92d.js} +1 -1
  26. package/lib/edge/{get-class-prop-name-2ce20e98.cjs → get-class-prop-name-ffeda28e.cjs} +1 -1
  27. package/lib/edge/{img-35a1343f.cjs → img-89e32a84.cjs} +1 -1
  28. package/lib/edge/{img-d187da14.js → img-912b190b.js} +1 -1
  29. package/lib/edge/index.cjs +1 -1
  30. package/lib/edge/index.mjs +1 -1
  31. package/lib/edge/{input-9a6498fd.cjs → input-5ff8ae2e.cjs} +1 -1
  32. package/lib/edge/{input-38f565ce.js → input-96ba83eb.js} +1 -1
  33. package/lib/edge/{select-135b7397.cjs → select-5f5fed1c.cjs} +1 -1
  34. package/lib/edge/{select-6cb0b4b7.js → select-f66026e1.js} +1 -1
  35. package/lib/edge/{server-entry-216eb1bf.js → server-entry-e26008c1.js} +110 -101
  36. package/lib/edge/server-entry-f09ee4f4.cjs +2 -0
  37. package/lib/edge/server-entry.cjs +1 -1
  38. package/lib/edge/server-entry.mjs +1 -1
  39. package/lib/edge/{slot-d692126c.js → slot-d09faa0a.js} +4 -4
  40. package/lib/edge/{slot-b0728030.cjs → slot-d3473421.cjs} +1 -1
  41. package/lib/edge/{symbol-df30241a.js → symbol-285d196c.js} +2 -2
  42. package/lib/edge/{symbol-0ac2655e.cjs → symbol-ebccca9b.cjs} +1 -1
  43. package/lib/edge/{tabs-b925777d.js → tabs-39d86f86.js} +15 -15
  44. package/lib/edge/tabs-61c59e0f.cjs +1 -0
  45. package/lib/edge/{text-0f85a76c.cjs → text-40a616f5.cjs} +1 -1
  46. package/lib/edge/{text-337389ba.js → text-dce27428.js} +2 -2
  47. package/lib/node/blocks-exports.cjs +20 -20
  48. package/lib/node/blocks-exports.mjs +802 -797
  49. package/lib/node/index.cjs +1 -1
  50. package/lib/node/index.mjs +3 -3
  51. package/lib/node/init.cjs +1 -1
  52. package/lib/node/init.mjs +3 -3
  53. package/lib/node/server-entry-8e901e75.cjs +2 -0
  54. package/lib/node/{server-entry-ca0dcb45.js → server-entry-c7147616.js} +104 -95
  55. package/lib/node/server-entry.cjs +1 -1
  56. package/lib/node/server-entry.mjs +1 -1
  57. package/lib/node/{setIvm-2100f4f5.js → setIvm-5ab140ad.js} +1 -1
  58. package/lib/node/{setIvm-2d47478e.cjs → setIvm-a85e255e.cjs} +1 -1
  59. package/lib/node/setIvm.cjs +1 -1
  60. package/lib/node/setIvm.mjs +2 -2
  61. package/lib/node/{should-force-browser-runtime-in-node-fd3ca2a8.cjs → should-force-browser-runtime-in-node-16ceec99.cjs} +1 -1
  62. package/lib/node/{should-force-browser-runtime-in-node-a77d7cfc.js → should-force-browser-runtime-in-node-1d3a044a.js} +1 -1
  63. package/package.json +1 -1
  64. package/types/constants/sdk-version.d.ts +1 -1
  65. package/types/functions/log-fetch.d.ts +1 -0
  66. package/lib/browser/server-entry-7260e494.cjs +0 -2
  67. package/lib/edge/form-efce5c78.cjs +0 -1
  68. package/lib/edge/server-entry-3e6518b6.cjs +0 -2
  69. package/lib/edge/tabs-47ed7dde.cjs +0 -1
  70. package/lib/node/server-entry-3e017173.cjs +0 -2
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.28",
4
+ "version": "2.0.30",
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.28";
1
+ export declare const SDK_VERSION = "2.0.30";
@@ -0,0 +1 @@
1
+ export declare function logFetch(url: string): void;
@@ -1,2 +0,0 @@
1
- "use strict";const y="react",I="[Builder.io]: ",l={log:(...e)=>console.log(I,...e),error:(...e)=>console.error(I,...e),warn:(...e)=>console.warn(I,...e),debug:(...e)=>console.debug(I,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const le=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},V=e=>e instanceof URLSearchParams?le(e):e,M=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function fe(){return c()&&window.self!==window.top}function F(e){return fe()&&M(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const ge=()=>{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},he=()=>typeof navigator=="object"&&navigator.userAgent||"",N=()=>{const e=he(),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=ge();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 pe(e){const t=e||(c()?window.location.search:void 0);return t?M(t).indexOf("builder.preview=")!==-1:!1}const me=e=>({type:"builder.registerComponent",data:k(e)}),ye=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function k(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?ye(n):n))}const x={};function D(e,t){e==="plugin"&&(t=k(t));let n=x[e];if(n||(n=x[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 B={};function Se(e){if(c()){Object.assign(B,e);const t={type:"builder.settingsChange",data:B};parent.postMessage(t,"*")}}const R="builder.",we="options.",P=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(we,"");n[o]=t[r]}}),n},be=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},K="2.0.28",j=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":K}),Ie=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},W=({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){l.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},$=async e=>W(e),ve=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),Ee=[["secure",""],["SameSite","None"]],ke=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?Ee:[[]],s=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...s,["path","/"],["domain",Ie(window.location.hostname)],...o];return ve(i)},_=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=ke({name:e,value:t,expires:n});document.cookie=o}catch(o){l.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function Pe(){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 G(){return Pe().replace(/-/g,"")}const H="builderSessionId",Oe=async({canTrack:e})=>{if(!e)return;const t=await $({name:H,canTrack:e});if(p(t))return t;{const n=Ce();return Ae({id:n,canTrack:e}),n}},Ce=()=>G(),Ae=({id:e,canTrack:t})=>_({name:H,value:e,canTrack:t}),X=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Te=({key:e,canTrack:t})=>{var n;try{return t?(n=X())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},xe=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=X())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},z="builderVisitorId",Be=({canTrack:e})=>{if(!e)return;const t=Te({key:z,canTrack:e});if(p(t))return t;{const n=Re();return Le({id:n,canTrack:e}),n}},Re=()=>G(),Le=({id:e,canTrack:t})=>xe({key:z,value:e,canTrack:t}),Ue=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Oe({canTrack:e}),n=Be({canTrack:e});return{sessionId:t,visitorId:n}},Ve=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await Ue({canTrack:t}),userAttributes:N(),ownerId:n}});async function J({apiHost:e,...t}){if(!t.apiKey){l.error("Missing API key for track call. Please provide your API key.");return}return!t.canTrack||F()||!(c()||y==="reactNative")?void 0:fetch(`${e||"https://cdn.builder.io"}/api/v1/track`,{method:"POST",body:JSON.stringify({events:[await Ve(t)]}),headers:{"content-type":"application/json",...j()},mode:"cors"}).catch(r=>{console.error("Failed to track: ",r)})}const Me=e=>J({...e,canTrack:!0}),Fe=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function q(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Fe).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Ne=()=>{D("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 Q=(e={})=>{var t,n;L||(L=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:y,version:K,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,i;if(!q(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const u=o.data.text,S=o.data.arguments||[],m=o.data.id,v=new Function(u);let d,g=null;try{d=v.apply(null,S)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):d&&typeof d.then=="function"?d.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:d,id:m}},"*");break}}})))},Y=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!q(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,i=s.key||s.alias||s.entry||s.modelName,u=s.data;i===e&&n.contentUpdate(u);break}}},De=(e,t,n)=>{if(!c)return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};Q();const r=Y({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},Ke="builder.tests",O=e=>`${Ke}.${e}`,je=({contentId:e})=>$({name:O(e),canTrack:!0}),We=({contentId:e})=>W({name:O(e),canTrack:!0}),$e=({contentId:e,value:t})=>_({name:O(e),value:t,canTrack:!0}),Z=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 i=(o=t[s])==null?void 0:o.testRatio;if(n+=i,r<n)return s}return e},ee=e=>{const t=_e(e);return $e({contentId:e.id,value:t}).catch(n=>{l.error("could not store A/B test variation: ",n)}),t},te=({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":"")}},Ge=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!Z(e))return e;const n=We({contentId:e.id})||ee({variations:e.variations,id:e.id}),r=te({item:e,testGroupId:n});return{...e,...r}},He=async({item:e,canTrack:t})=>{if(!t||!Z(e))return e;const r=await je({contentId:e.id})||ee({variations:e.variations,id:e.id}),o=te({item:e,testGroupId:r});return{...e,...o}},ne=e=>p(e)?e:!0;function Xe(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ze(){const e=Xe().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 Je=ze();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],i=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,i,n)}:{...r,[i]:s}},{})}function re(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(i=>i.startsWith("$"))?re(o,s,n):n[s]=o}return n}const qe="v3",U=e=>typeof e=="number"&&!isNaN(e)&&e>=0,C=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:i,locale:u,apiVersion:S=qe,fields:m,omit:v,offset:d,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:A,apiHost:ae}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const ce=t!==1,ue=ae||"https://cdn.builder.io",a=new URL(`${ue}/api/${S}/content/${o}`);if(a.searchParams.set("apiKey",s),a.searchParams.set("limit",String(t)),a.searchParams.set("noTraverse",String(ce)),a.searchParams.set("includeRefs",String(!0)),u&&a.searchParams.set("locale",u),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",v||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(d)&&d>-1&&a.searchParams.set("offset",String(Math.floor(d))),typeof A=="boolean"&&a.searchParams.set("includeUnpublished",String(A)),g&&U(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&U(h)&&a.searchParams.set("staleCacheSeconds",String(h)),w){const f=E({sort:w});for(const b in f)a.searchParams.set(b,JSON.stringify(f[b]))}const de={...be(),...V(e.options||{})},T=E(de);for(const f in T)a.searchParams.set(f,String(T[f]));if(n&&a.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=re({query:r});for(const b in f)a.searchParams.set(b,JSON.stringify(f[b]))}return a},Qe=e=>"results"in e;async function oe(e){const t=await ie({...e,limit:1});return t&&t[0]||null}const Ye=async e=>{var i,u;const t=C(e),n=(i=e.fetch)!=null?i:Je,r={...e.fetchOptions,headers:{...(u=e.fetchOptions)==null?void 0:u.headers,...j()}};return await(await n(t.href,r)).json()},se=async(e,t,n=C(e))=>{const r=ne(e.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await He({item:s,canTrack:r}));t.results=o}catch(o){l.error("Could not process A/B tests. ",o)}return t.results};async function ie(e){try{const t=C(e),n=await Ye(e);return Qe(n)?se(e,n):(l.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return l.error("Error fetching data. ",t),null}}const Ze=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 oe(n)}};exports.TARGET=y;exports._processContentResult=se;exports._track=J;exports.checkIsDefined=p;exports.createEditorListener=Y;exports.createRegisterComponentMessage=me;exports.fetchBuilderProps=Ze;exports.fetchEntries=ie;exports.fetchOneEntry=oe;exports.getBuilderSearchParams=P;exports.getDefaultCanTrack=ne;exports.getUserAttributes=N;exports.handleABTestingSync=Ge;exports.isBrowser=c;exports.isEditing=F;exports.isPreviewing=pe;exports.logger=l;exports.register=D;exports.registerInsertMenu=Ne;exports.serializeIncludingFunctions=k;exports.setEditorSettings=Se;exports.setupBrowserForEditing=Q;exports.subscribeToEditor=De;exports.track=Me;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),h=require("react"),m=require("./blocks-896a56b0.cjs"),P=require("./evaluate-2fcda9ec.cjs"),D=require("./server-entry-3e6518b6.cjs");require("./blocks-exports.cjs");require("./get-class-prop-name-2ce20e98.cjs");require("./dynamic-renderer-b29b45ca.cjs");const A=["production","qa","test","development","dev","cdn-qa","cloud","fast","cdn2","cdn-prod"],B=()=>{const e=process.env.NODE_ENV||"production";return A.includes(e)?e:"production"};function O(e){var S,x;const o=h.useRef(null),[M,g]=h.useState(()=>"unsubmitted"),[v,y]=h.useState(()=>null),[J,T]=h.useState(()=>"");function q(r){var l,d;const a={...e.builderContext.rootState,...r};e.builderContext.rootSetState?(d=(l=e.builderContext).rootSetState)==null||d.call(l,a):e.builderContext.rootState=a}function f(){return D.isEditing()&&e.previewState||M}function F(r){var l;const a=e.sendWithJs||e.sendSubmissionsTo==="email";if(e.sendSubmissionsTo==="zapier")r.preventDefault();else if(a){if(!(e.action||e.sendSubmissionsTo==="email")){r.preventDefault();return}r.preventDefault();const d=r.currentTarget||r.target,E=e.customHeaders||{};let b;const N=new FormData(d),k=Array.from(d.querySelectorAll("input,select,textarea")).filter(t=>!!t.name).map(t=>{let n;const c=t.name;if(t instanceof HTMLInputElement)if(t.type==="radio"){if(t.checked)return n=t.name,{key:c,value:n}}else if(t.type==="checkbox")n=t.checked;else if(t.type==="number"||t.type==="range"){const i=t.valueAsNumber;isNaN(i)||(n=i)}else t.type==="file"?n=t.files:n=t.value;else n=t.value;return{key:c,value:n}});let u=e.contentType;if(e.sendSubmissionsTo==="email"&&(u="multipart/form-data"),Array.from(k).forEach(({value:t})=>{(t instanceof File||Array.isArray(t)&&t[0]instanceof File||t instanceof FileList)&&(u="multipart/form-data")}),u!=="application/json")b=N;else{const t={};Array.from(k).forEach(({value:n,key:c})=>{m.set(t,c,n)}),b=JSON.stringify(t)}u&&u!=="multipart/form-data"&&(a&&((l=e.action)!=null&&l.includes("zapier.com"))||(E["content-type"]=u));const C=new CustomEvent("presubmit",{detail:{body:b}});if(o.current&&(o.current.dispatchEvent(C),C.defaultPrevented))return;g("sending");const w=`${B()==="dev"?"http://localhost:5000":"https://builder.io"}/api/v1/form-submit?apiKey=${e.builderContext.apiKey}&to=${btoa(e.sendSubmissionsToEmail||"")}&name=${encodeURIComponent(e.name||"")}`;fetch(e.sendSubmissionsTo==="email"?w:e.action,{body:b,headers:E,method:e.method||"post"}).then(async t=>{let n;const c=t.headers.get("content-type");if(c&&c.indexOf("application/json")!==-1?n=await t.json():n=await t.text(),!t.ok&&e.errorMessagePath){let i=P.get(n,e.errorMessagePath);i&&(typeof i!="string"&&(i=JSON.stringify(i)),T(i),q({formErrorMessage:i}))}if(y(n),g(t.ok?"success":"error"),t.ok){const i=new CustomEvent("submit:success",{detail:{res:t,body:n}});if(o.current){if(o.current.dispatchEvent(i),i.defaultPrevented)return;e.resetFormOnSubmit!==!1&&o.current.reset()}if(e.successUrl)if(o.current){const j=new CustomEvent("route",{detail:{url:e.successUrl}});o.current.dispatchEvent(j),j.defaultPrevented||(location.href=e.successUrl)}else location.href=e.successUrl}},t=>{const n=new CustomEvent("submit:error",{detail:{error:t}});o.current&&(o.current.dispatchEvent(n),n.defaultPrevented)||(y(t),g("error"))})}}return s.jsxs(s.Fragment,{children:[" ",s.jsxs("form",{validate:e.validate,ref:o,action:!e.sendWithJs&&e.action,method:e.method,name:e.name,onSubmit:r=>F(r),...e.attributes,children:[e.builderBlock&&e.builderBlock.children?s.jsx(s.Fragment,{children:(x=(S=e.builderBlock)==null?void 0:S.children)==null?void 0:x.map((r,a)=>s.jsx(m.Block,{block:r,context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent},`form-block-${a}`))}):null,f()==="error"?s.jsx(m.Blocks,{path:"errorMessage",blocks:e.errorMessage,context:e.builderContext}):null,f()==="sending"?s.jsx(m.Blocks,{path:"sendingMessage",blocks:e.sendingMessage,context:e.builderContext}):null,f()==="error"&&v?s.jsx("pre",{className:"builder-form-error-text pre-3a20f614",children:JSON.stringify(v,null,2)}):null,f()==="success"?s.jsx(m.Blocks,{path:"successMessage",blocks:e.successMessage,context:e.builderContext}):null]})," ",s.jsx("style",{children:".pre-3a20f614 { padding: 10px; color: red; text-align: center; }"})," "]})}exports.default=O;
@@ -1,2 +0,0 @@
1
- "use strict";const y="react",le=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},V=e=>e instanceof URLSearchParams?le(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 fe(){return c()&&window.self!==window.top}function F(e){return fe()&&M(e||window.location.search).indexOf("builder.frameEditing=")!==-1}function ge(e){const t=e||(c()?window.location.search:void 0);return t?M(t).indexOf("builder.preview=")!==-1:!1}const he=e=>({type:"builder.registerComponent",data:k(e)}),pe=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function k(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?pe(n):n))}const x={};function N(e,t){e==="plugin"&&(t=k(t));let n=x[e];if(n||(n=x[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 B={};function me(e){if(c()){Object.assign(B,e);const t={type:"builder.settingsChange",data:B};parent.postMessage(t,"*")}}const R="builder.",ye="options.",P=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(ye,"");n[o]=t[r]}}),n},Se=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},I="[Builder.io]: ",l={log:(...e)=>console.log(I,...e),error:(...e)=>console.error(I,...e),warn:(...e)=>console.warn(I,...e),debug:(...e)=>console.debug(I,...e)},D="2.0.28",K=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":D}),p=e=>e!=null,we=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},j=({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){l.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},W=async e=>j(e),be=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),Ie=[["secure",""],["SameSite","None"]],ve=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?Ie:[[]],s=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...s,["path","/"],["domain",we(window.location.hostname)],...o];return be(i)},$=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=ve({name:e,value:t,expires:n});document.cookie=o}catch(o){l.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function Ee(){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 Ee().replace(/-/g,"")}const G="builderSessionId",ke=async({canTrack:e})=>{if(!e)return;const t=await W({name:G,canTrack:e});if(p(t))return t;{const n=Pe();return Oe({id:n,canTrack:e}),n}},Pe=()=>_(),Oe=({id:e,canTrack:t})=>$({name:G,value:e,canTrack:t}),H=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Ce=({key:e,canTrack:t})=>{var n;try{return t?(n=H())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},Ae=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=H())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},X="builderVisitorId",Te=({canTrack:e})=>{if(!e)return;const t=Ce({key:X,canTrack:e});if(p(t))return t;{const n=xe();return Be({id:n,canTrack:e}),n}},xe=()=>_(),Be=({id:e,canTrack:t})=>Ae({key:X,value:e,canTrack:t}),Re=()=>{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||"",z=()=>{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()||y==="reactNative"}},n=e.match(/Tablet|iPad/i),r=Re();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"}},Ue=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await ke({canTrack:e}),n=Te({canTrack:e});return{sessionId:t,visitorId:n}},Ve=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await Ue({canTrack:t}),userAttributes:z(),ownerId:n}});async function J({apiHost:e,...t}){if(!t.apiKey){l.error("Missing API key for track call. Please provide your API key.");return}return!t.canTrack||F()||!(c()||y==="reactNative")?void 0:fetch(`${e||"https://cdn.builder.io"}/api/v1/track`,{method:"POST",body:JSON.stringify({events:[await Ve(t)]}),headers:{"content-type":"application/json",...K()},mode:"cors"}).catch(r=>{console.error("Failed to track: ",r)})}const Me=e=>J({...e,canTrack:!0}),Fe=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function q(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Fe).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Ne=()=>{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 L=!1;const Q=(e={})=>{var t,n;L||(L=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:y,version:D,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,i;if(!q(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const u=o.data.text,S=o.data.arguments||[],m=o.data.id,v=new Function(u);let d,g=null;try{d=v.apply(null,S)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):d&&typeof d.then=="function"?d.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:d,id:m}},"*");break}}})))},Y=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!q(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,i=s.key||s.alias||s.entry||s.modelName,u=s.data;i===e&&n.contentUpdate(u);break}}},De=(e,t,n)=>{if(!c)return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};Q();const r=Y({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},Ke="builder.tests",O=e=>`${Ke}.${e}`,je=({contentId:e})=>W({name:O(e),canTrack:!0}),We=({contentId:e})=>j({name:O(e),canTrack:!0}),$e=({contentId:e,value:t})=>$({name:O(e),value:t,canTrack:!0}),Z=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 i=(o=t[s])==null?void 0:o.testRatio;if(n+=i,r<n)return s}return e},ee=e=>{const t=_e(e);return $e({contentId:e.id,value:t}).catch(n=>{l.error("could not store A/B test variation: ",n)}),t},te=({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":"")}},Ge=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!Z(e))return e;const n=We({contentId:e.id})||ee({variations:e.variations,id:e.id}),r=te({item:e,testGroupId:n});return{...e,...r}},He=async({item:e,canTrack:t})=>{if(!t||!Z(e))return e;const r=await je({contentId:e.id})||ee({variations:e.variations,id:e.id}),o=te({item:e,testGroupId:r});return{...e,...o}},ne=e=>p(e)?e:!0;function Xe(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ze(){const e=Xe().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 Je=ze();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],i=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,i,n)}:{...r,[i]:s}},{})}function re(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(i=>i.startsWith("$"))?re(o,s,n):n[s]=o}return n}const qe="v3",U=e=>typeof e=="number"&&!isNaN(e)&&e>=0,C=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:i,locale:u,apiVersion:S=qe,fields:m,omit:v,offset:d,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:A,apiHost:ae}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const ce=t!==1,ue=ae||"https://cdn.builder.io",a=new URL(`${ue}/api/${S}/content/${o}`);if(a.searchParams.set("apiKey",s),a.searchParams.set("limit",String(t)),a.searchParams.set("noTraverse",String(ce)),a.searchParams.set("includeRefs",String(!0)),u&&a.searchParams.set("locale",u),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",v||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(d)&&d>-1&&a.searchParams.set("offset",String(Math.floor(d))),typeof A=="boolean"&&a.searchParams.set("includeUnpublished",String(A)),g&&U(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&U(h)&&a.searchParams.set("staleCacheSeconds",String(h)),w){const f=E({sort:w});for(const b in f)a.searchParams.set(b,JSON.stringify(f[b]))}const de={...Se(),...V(e.options||{})},T=E(de);for(const f in T)a.searchParams.set(f,String(T[f]));if(n&&a.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=re({query:r});for(const b in f)a.searchParams.set(b,JSON.stringify(f[b]))}return a},Qe=e=>"results"in e;async function oe(e){const t=await ie({...e,limit:1});return t&&t[0]||null}const Ye=async e=>{var i,u;const t=C(e),n=(i=e.fetch)!=null?i:Je,r={...e.fetchOptions,headers:{...(u=e.fetchOptions)==null?void 0:u.headers,...K()}};return await(await n(t.href,r)).json()},se=async(e,t,n=C(e))=>{const r=ne(e.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await He({item:s,canTrack:r}));t.results=o}catch(o){l.error("Could not process A/B tests. ",o)}return t.results};async function ie(e){try{const t=C(e),n=await Ye(e);return Qe(n)?se(e,n):(l.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return l.error("Error fetching data. ",t),null}}const Ze=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 oe(n)}};exports.TARGET=y;exports._processContentResult=se;exports._track=J;exports.checkIsDefined=p;exports.createEditorListener=Y;exports.createRegisterComponentMessage=he;exports.fetchBuilderProps=Ze;exports.fetchEntries=ie;exports.fetchOneEntry=oe;exports.getBuilderSearchParams=P;exports.getDefaultCanTrack=ne;exports.getUserAttributes=z;exports.handleABTestingSync=Ge;exports.isBrowser=c;exports.isEditing=F;exports.isPreviewing=ge;exports.logger=l;exports.register=N;exports.registerInsertMenu=Ne;exports.serializeIncludingFunctions=k;exports.setEditorSettings=me;exports.setupBrowserForEditing=Q;exports.subscribeToEditor=De;exports.track=Me;
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("react/jsx-runtime"),b=require("react"),r=require("./blocks-896a56b0.cjs");require("./blocks-exports.cjs");require("./server-entry-3e6518b6.cjs");require("./evaluate-2fcda9ec.cjs");require("./get-class-prop-name-2ce20e98.cjs");require("./dynamic-renderer-b29b45ca.cjs");function s(e){var c;const[t,a]=b.useState(()=>e.defaultActiveTab?e.defaultActiveTab-1:0);function o(n){return e.tabs&&e.tabs[n].content}function u(n){n===t&&e.collapsible?a(-1):a(n)}return i.jsxs("div",{children:[i.jsx("div",{className:"builder-tabs-wrap",style:{display:"flex",flexDirection:"row",justifyContent:e.tabHeaderLayout||"flex-start",overflow:"auto"},children:(c=e.tabs)==null?void 0:c.map((n,l)=>i.jsx("span",{className:`builder-tab-wrap ${t===l?"builder-tab-active":""}`,style:{...t===l?e.activeTabStyle:{}},onClick:d=>u(l),children:i.jsx(r.Blocks,{parent:e.builderBlock.id,path:`component.options.tabs.${l}.label`,blocks:n.label,context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent})},l))}),o(t)?i.jsx("div",{children:i.jsx(r.Blocks,{parent:e.builderBlock.id,path:`component.options.tabs.${t}.content`,blocks:o(t),context:e.builderContext,registeredComponents:e.builderComponents,linkComponent:e.builderLinkComponent})}):null]})}exports.default=s;
@@ -1,2 +0,0 @@
1
- "use strict";const y="react",I="[Builder.io]: ",l={log:(...e)=>console.log(I,...e),error:(...e)=>console.error(I,...e),warn:(...e)=>console.warn(I,...e),debug:(...e)=>console.debug(I,...e)};function c(){return typeof window!="undefined"&&typeof document!="undefined"}const le=e=>{const t={};return e.forEach((n,r)=>{t[r]=n}),t},V=e=>e instanceof URLSearchParams?le(e):e,M=e=>typeof e=="string"?e:e instanceof URLSearchParams?e.toString():new URLSearchParams(e).toString();function fe(){return c()&&window.self!==window.top}function F(e){return fe()&&M(e||window.location.search).indexOf("builder.frameEditing=")!==-1}const ge=()=>{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},he=()=>typeof navigator=="object"&&navigator.userAgent||"",N=()=>{const e=he(),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=ge();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 pe(e){const t=e||(c()?window.location.search:void 0);return t?M(t).indexOf("builder.preview=")!==-1:!1}const me=e=>({type:"builder.registerComponent",data:k(e)}),ye=e=>{const t=e.toString().trim();return`return (${!t.startsWith("function")&&!t.startsWith("(")?"function ":""}${t}).apply(this, arguments)`};function k(e){return JSON.parse(JSON.stringify(e,(t,n)=>typeof n=="function"?ye(n):n))}const x={};function D(e,t){e==="plugin"&&(t=k(t));let n=x[e];if(n||(n=x[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 R={};function Se(e){if(c()){Object.assign(R,e);const t={type:"builder.settingsChange",data:R};parent.postMessage(t,"*")}}const B="builder.",we="options.",P=e=>{if(!e)return{};const t=V(e),n={};return Object.keys(t).forEach(r=>{if(r.startsWith(B)){const o=r.replace(B,"").replace(we,"");n[o]=t[r]}}),n},be=()=>{if(!c())return{};const e=new URLSearchParams(window.location.search);return P(e)},K="2.0.28",j=()=>({"X-Builder-SDK":y,"X-Builder-SDK-GEN":"2","X-Builder-SDK-Version":K}),Ie=e=>{if(e==="localhost"||e==="127.0.0.1")return e;const t=e.split(".");return t.length>2?t.slice(1).join("."):e},W=({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){l.warn("[COOKIE] GET error: ",(r==null?void 0:r.message)||r);return}},_=async e=>W(e),ve=e=>e.map(([t,n])=>n?`${t}=${n}`:t).filter(p).join("; "),Ee=[["secure",""],["SameSite","None"]],ke=({name:e,value:t,expires:n})=>{const o=(c()?location.protocol==="https:":!0)?Ee:[[]],s=n?[["expires",n.toUTCString()]]:[[]],i=[[e,t],...s,["path","/"],["domain",Ie(window.location.hostname)],...o];return ve(i)},$=async({name:e,value:t,expires:n,canTrack:r})=>{try{if(!r)return;const o=ke({name:e,value:t,expires:n});document.cookie=o}catch(o){l.warn("[COOKIE] SET error: ",(o==null?void 0:o.message)||o)}};function Pe(){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 G(){return Pe().replace(/-/g,"")}const X="builderSessionId",Oe=async({canTrack:e})=>{if(!e)return;const t=await _({name:X,canTrack:e});if(p(t))return t;{const n=Ce();return Ae({id:n,canTrack:e}),n}},Ce=()=>G(),Ae=({id:e,canTrack:t})=>$({name:X,value:e,canTrack:t}),H=()=>c()&&typeof localStorage!="undefined"?localStorage:void 0,Te=({key:e,canTrack:t})=>{var n;try{return t?(n=H())==null?void 0:n.getItem(e):void 0}catch(r){console.debug("[LocalStorage] GET error: ",r);return}},xe=({key:e,canTrack:t,value:n})=>{var r;try{t&&((r=H())==null||r.setItem(e,n))}catch(o){console.debug("[LocalStorage] SET error: ",o)}},z="builderVisitorId",Re=({canTrack:e})=>{if(!e)return;const t=Te({key:z,canTrack:e});if(p(t))return t;{const n=Be();return Le({id:n,canTrack:e}),n}},Be=()=>G(),Le=({id:e,canTrack:t})=>xe({key:z,value:e,canTrack:t}),Ue=async({canTrack:e})=>{if(!e)return{visitorId:void 0,sessionId:void 0};const t=await Oe({canTrack:e}),n=Re({canTrack:e});return{sessionId:t,visitorId:n}},Ve=async({type:e,canTrack:t,apiKey:n,metadata:r,...o})=>({type:e,data:{...o,metadata:{url:location.href,...r},...await Ue({canTrack:t}),userAttributes:N(),ownerId:n}});async function J({apiHost:e,...t}){if(!t.apiKey){l.error("Missing API key for track call. Please provide your API key.");return}return!t.canTrack||F()||!(c()||y==="reactNative")?void 0:fetch(`${e||"https://cdn.builder.io"}/api/v1/track`,{method:"POST",body:JSON.stringify({events:[await Ve(t)]}),headers:{"content-type":"application/json",...j()},mode:"cors"}).catch(r=>{console.error("Failed to track: ",r)})}const Me=e=>J({...e,canTrack:!0}),Fe=["*.beta.builder.io","beta.builder.io","builder.io","localhost","qa.builder.io"];function q(e,t){if(!t.origin.startsWith("http")&&!t.origin.startsWith("https"))return!1;const n=new URL(t.origin),r=n.hostname;return(e||Fe).findIndex(o=>o.startsWith("*.")?r.endsWith(o.slice(1)):o===r)>-1}const Ne=()=>{D("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 Q=(e={})=>{var t,n;L||(L=!0,c()&&((t=window.parent)==null||t.postMessage({type:"builder.sdkInfo",data:{target:y,version:K,supportsPatchUpdates:!1,supportsAddBlockScoping:!0,supportsCustomBreakpoints:!0}},"*"),(n=window.parent)==null||n.postMessage({type:"builder.updateContent",data:{options:e}},"*"),window.addEventListener("message",r=>{var s,i;if(!q(e.trustedHosts,r))return;const{data:o}=r;if(o!=null&&o.type)switch(o.type){case"builder.evaluate":{const u=o.data.text,S=o.data.arguments||[],m=o.data.id,v=new Function(u);let d,g=null;try{d=v.apply(null,S)}catch(h){g=h}g?(s=window.parent)==null||s.postMessage({type:"builder.evaluateError",data:{id:m,error:g.message}},"*"):d&&typeof d.then=="function"?d.then(h=>{var w;(w=window.parent)==null||w.postMessage({type:"builder.evaluateResult",data:{id:m,result:h}},"*")}).catch(console.error):(i=window.parent)==null||i.postMessage({type:"builder.evaluateResult",data:{result:d,id:m}},"*");break}}})))},Y=({model:e,trustedHosts:t,callbacks:n})=>r=>{if(!q(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,i=s.key||s.alias||s.entry||s.modelName,u=s.data;i===e&&n.contentUpdate(u);break}}},De=(e,t,n)=>{if(!c)return l.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."),()=>{};Q();const r=Y({callbacks:{contentUpdate:t,animation:()=>{},configureSdk:()=>{}},model:e,trustedHosts:n==null?void 0:n.trustedHosts});return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}},Ke="builder.tests",O=e=>`${Ke}.${e}`,je=({contentId:e})=>_({name:O(e),canTrack:!0}),We=({contentId:e})=>W({name:O(e),canTrack:!0}),_e=({contentId:e,value:t})=>$({name:O(e),value:t,canTrack:!0}),Z=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 i=(o=t[s])==null?void 0:o.testRatio;if(n+=i,r<n)return s}return e},ee=e=>{const t=$e(e);return _e({contentId:e.id,value:t}).catch(n=>{l.error("could not store A/B test variation: ",n)}),t},te=({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":"")}},Ge=({item:e,canTrack:t})=>{if(!t)return e;if(!e)return;if(!Z(e))return e;const n=We({contentId:e.id})||ee({variations:e.variations,id:e.id}),r=te({item:e,testGroupId:n});return{...e,...r}},Xe=async({item:e,canTrack:t})=>{if(!t||!Z(e))return e;const r=await je({contentId:e.id})||ee({variations:e.variations,id:e.id}),o=te({item:e,testGroupId:r});return{...e,...o}},ne=e=>p(e)?e:!0;function He(){return typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:globalThis}function ze(){const e=He().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 Je=ze();function E(e,t=null,n="."){return Object.keys(e).reduce((r,o)=>{const s=e[o],i=[t,o].filter(Boolean).join(n);return[typeof s=="object",s!==null,!(Array.isArray(s)&&s.length===0)].every(Boolean)?{...r,...E(s,i,n)}:{...r,[i]:s}},{})}function re(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(i=>i.startsWith("$"))?re(o,s,n):n[s]=o}return n}const qe="v3",U=e=>typeof e=="number"&&!isNaN(e)&&e>=0,C=e=>{const{limit:t=30,userAttributes:n,query:r,model:o,apiKey:s,enrich:i,locale:u,apiVersion:S=qe,fields:m,omit:v,offset:d,cacheSeconds:g,staleCacheSeconds:h,sort:w,includeUnpublished:A,apiHost:ae}=e;if(!s)throw new Error("Missing API key");if(!["v3"].includes(S))throw new Error(`Invalid apiVersion: expected 'v3', received '${S}'`);const ce=t!==1,ue=ae||"https://cdn.builder.io",a=new URL(`${ue}/api/${S}/content/${o}`);if(a.searchParams.set("apiKey",s),a.searchParams.set("limit",String(t)),a.searchParams.set("noTraverse",String(ce)),a.searchParams.set("includeRefs",String(!0)),u&&a.searchParams.set("locale",u),i&&a.searchParams.set("enrich",String(i)),a.searchParams.set("omit",v||"meta.componentsUsed"),m&&a.searchParams.set("fields",m),Number.isFinite(d)&&d>-1&&a.searchParams.set("offset",String(Math.floor(d))),typeof A=="boolean"&&a.searchParams.set("includeUnpublished",String(A)),g&&U(g)&&a.searchParams.set("cacheSeconds",String(g)),h&&U(h)&&a.searchParams.set("staleCacheSeconds",String(h)),w){const f=E({sort:w});for(const b in f)a.searchParams.set(b,JSON.stringify(f[b]))}const de={...be(),...V(e.options||{})},T=E(de);for(const f in T)a.searchParams.set(f,String(T[f]));if(n&&a.searchParams.set("userAttributes",JSON.stringify(n)),r){const f=re({query:r});for(const b in f)a.searchParams.set(b,JSON.stringify(f[b]))}return a},Qe=e=>"results"in e;async function oe(e){const t=await ie({...e,limit:1});return t&&t[0]||null}const Ye=async e=>{var i,u;const t=C(e),n=(i=e.fetch)!=null?i:Je,r={...e.fetchOptions,headers:{...(u=e.fetchOptions)==null?void 0:u.headers,...j()}};return await(await n(t.href,r)).json()},se=async(e,t,n=C(e))=>{const r=ne(e.canTrack);if(n.search.includes("preview="),!r||!(c()||y==="reactNative"))return t.results;try{const o=[];for(const s of t.results)o.push(await Xe({item:s,canTrack:r}));t.results=o}catch(o){l.error("Could not process A/B tests. ",o)}return t.results};async function ie(e){try{const t=C(e),n=await Ye(e);return Qe(n)?se(e,n):(l.error("Error fetching data. ",{url:t,content:n,options:e}),null)}catch(t){return l.error("Error fetching data. ",t),null}}const Ze=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 oe(n)}};exports.MSG_PREFIX=I;exports.TARGET=y;exports._processContentResult=se;exports._track=J;exports.checkIsDefined=p;exports.createEditorListener=Y;exports.createRegisterComponentMessage=me;exports.fetchBuilderProps=Ze;exports.fetchEntries=ie;exports.fetchOneEntry=oe;exports.getBuilderSearchParams=P;exports.getDefaultCanTrack=ne;exports.getUserAttributes=N;exports.handleABTestingSync=Ge;exports.isBrowser=c;exports.isEditing=F;exports.isPreviewing=pe;exports.logger=l;exports.register=D;exports.registerInsertMenu=Ne;exports.serializeIncludingFunctions=k;exports.setEditorSettings=Se;exports.setupBrowserForEditing=Q;exports.subscribeToEditor=De;exports.track=Me;