UNPKG

@builder.io/sdk-vue

Version:
1,816 lines 171 kB
import "./style.css"; import { defineComponent as y, openBlock as d, createElementBlock as h, Fragment as I, createBlock as S, resolveDynamicComponent as X, mergeProps as $, toHandlers as L, withCtx as O, renderSlot as N, resolveComponent as k, createTextVNode as Vt, toDisplayString as ce, defineAsyncComponent as Y, createVNode as E, renderList as F, createCommentVNode as C, h as ze, createElementVNode as z, normalizeStyle as M, normalizeClass as Z, markRaw as Nt } from "vue"; const xt = /* @__PURE__ */ new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"]), Wt = (e) => typeof e == "string" && xt.has(e.toLowerCase()); function x(e = {}, t, n) { const o = {}; for (const r in e) { if (!e[r] || n && !r.startsWith(t)) continue; const i = n ? r.replace(t, "") : r; o[i] = e[r]; } return o; } const Dt = y({ name: "dynamic-renderer", props: ["TagName", "attributes", "actionAttributes"], data() { return { isEmptyElement: Wt }; } }), v = (e, t) => { const n = e.__vccOpts || e; for (const [o, r] of t) n[o] = r; return n; }; function Ot(e, t, n, o, r, i) { return e.isEmptyElement(e.TagName) ? (d(), S(X(e.TagName), $({ key: 1 }, e.attributes, L(e.actionAttributes)), null, 16)) : (d(), h(I, { key: 0 }, [ typeof e.TagName == "string" ? (d(), S(X(e.TagName), $({ key: 0 }, e.attributes, L(e.actionAttributes)), { default: O(() => [ N(e.$slots, "default") ]), _: 3 }, 16)) : (d(), S(X(e.TagName), $({ key: 1 }, e.attributes, L(e.actionAttributes)), { default: O(() => [ N(e.$slots, "default") ]), _: 3 }, 16)) ], 64)); } const ke = /* @__PURE__ */ v(Dt, [["render", Ot]]), vs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: ke }, Symbol.toStringTag, { value: "Module" })), R = "vue", j = () => { switch (R) { case "react": case "reactNative": case "rsc": return "className"; case "svelte": case "vue": case "solid": case "qwik": case "angular": return "class"; } }, Ut = y({ name: "builder-button", components: { DynamicRenderer: ke }, props: [ "attributes", "link", "openLinkInNewTab", "builderLinkComponent", "text" ], data() { return { filterAttrs: x }; }, methods: { attrs() { return { ...x(this.attributes, "v-on:", !1), [j()]: `${this.link ? "" : "builder-button"} ${this.attributes[j()] || ""}`, ...this.link ? { href: this.link, target: this.openLinkInNewTab ? "_blank" : void 0, role: "link" } : { role: "button" } }; } } }); function Lt(e, t, n, o, r, i) { const s = k("DynamicRenderer"); return d(), S(s, { attributes: e.attrs(), TagName: e.link ? e.builderLinkComponent || "a" : "button", actionAttributes: e.filterAttrs(e.attributes, "v-on:", !0) }, { default: O(() => [ Vt(ce(e.text), 1) ]), _: 1 }, 8, ["attributes", "TagName", "actionAttributes"]); } const Ft = /* @__PURE__ */ v(Ut, [["render", Lt]]), Ht = Symbol(), be = { Builder: { content: null, context: {}, localState: void 0, rootSetState() { }, rootState: {}, apiKey: null, apiVersion: void 0, componentInfos: {}, inheritedStyles: {}, BlocksWrapper: "div", BlocksWrapperProps: {}, nonce: "", model: "" }, key: Ht }, Mt = Symbol(), Ge = { Components: { registeredComponents: {} }, key: Mt }, ne = "[Builder.io]: ", B = { log: (...e) => console.log(ne, ...e), error: (...e) => console.error(ne, ...e), warn: (...e) => console.warn(ne, ...e), debug: (...e) => console.debug(ne, ...e) }, Je = (e, t, n) => { const o = String.prototype.split.call(t, /[,[\].]+?/).filter(Boolean).reduce((r, i) => r != null ? r[i] : r, e); return o === void 0 || o === e ? n : o; }; function T() { return typeof window < "u" && typeof document < "u"; } const jt = (e) => { const t = {}; return e.forEach((n, o) => { t[o] = n; }), t; }, Qe = (e) => e instanceof URLSearchParams ? jt(e) : e, Ye = (e) => typeof e == "string" ? e : e instanceof URLSearchParams ? e.toString() : new URLSearchParams(e).toString(); function Kt() { return T() && window.self !== window.top; } function A(e) { return Kt() && // accessing window.location.search is safe here because `isIframe()` is only `true` if we're in a browser. Ye(e || window.location.search).indexOf("builder.frameEditing=") !== -1; } const qt = () => { if (T()) { 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; }, zt = () => typeof navigator == "object" && navigator.userAgent || "", Xe = () => { const e = zt(), 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() || R === "reactNative"; } }, n = e.match(/Tablet|iPad/i), o = qt(); return { urlPath: o == null ? void 0 : o.pathname, host: (o == null ? void 0 : o.host) || (o == null ? void 0 : o.hostname), device: n ? "tablet" : t.any() ? "mobile" : "desktop" }; }, Gt = ({ builder: e, context: t, event: n, state: o }) => Object.entries({ state: o, Builder: e, // legacy builder: e, context: t, event: n }), Jt = () => ({ isEditing: A(), isBrowser: T(), isServer: !T(), getUserAttributes: () => Xe() }), Qt = (e, { isExpression: t = !0 }) => /* we disable this for cases where we definitely don't want a return */ t && !(e.includes(";") || e.includes(" return ") || e.trim().startsWith("return ")) ? `return (${e});` : e; function _e({ rootState: e, localState: t, rootSetState: n }) { return new Proxy(e, { get: (o, r) => { if (t && r in t) return t[r]; const i = o[r]; return typeof i == "object" && i !== null ? _e({ rootState: i, localState: void 0, rootSetState: n ? (s) => { o[r] = s, n(o); } : void 0 }) : i; }, set: (o, r, i) => { if (t && r in t) throw new Error("Writing to local state is not allowed as it is read-only."); return o[r] = i, n == null || n(o), !0; } }); } const xe = ({ code: e, builder: t, context: n, event: o, localState: r, rootSetState: i, rootState: s }) => { const l = Gt({ builder: t, context: n, event: o, state: _e({ rootState: s, localState: r, rootSetState: i }) }); return new Function(...l.map(([a]) => a), e)(...l.map(([, a]) => a)); }, K = (e) => e != null; function Yt() { var e; return typeof process < "u" && K((e = process == null ? void 0 : process.versions) == null ? void 0 : e.node); } const Xt = ({ shouldLogWarning: e }) => { var r; if (!Yt()) return !1; const t = process.arch === "arm64", n = process.version.startsWith("v20"), o = (r = process.env.NODE_OPTIONS) == null ? void 0 : r.includes("--no-node-snapshot"); return t && n && !o ? (e && B.log("Skipping usage of `isolated-vm` to avoid crashes in Node v20 on an arm64 machine.\n If you would like to use the `isolated-vm` package on this machine, please provide the `NODE_OPTIONS=--no-node-snapshot` config to your Node process.\n See https://github.com/BuilderIO/builder/blob/main/packages/sdks/README.md#node-v20--m1-macs-apple-silicon-support for more information.\n "), !0) : !1; }, _t = (e) => (T() || Xt({ shouldLogWarning: !0 }), xe(e)), Zt = /^(return )?(\s*)?state(?<getPath>(\.\w+)+)(\s*);?$/, en = /(\s)*var(\s)+_virtual_index(\s)*=(\s)*state(?<getPath>(\.\w+)+)(\s*);?(\s)*return(\s)*_virtual_index(\s)*/, tn = (e) => { var t, n, o, r, i, s; return ((o = (n = (t = Zt.exec(e.trim())) == null ? void 0 : t.groups) == null ? void 0 : n.getPath) == null ? void 0 : o.slice(1)) || ((s = (i = (r = en.exec(e.trim())) == null ? void 0 : r.groups) == null ? void 0 : i.getPath) == null ? void 0 : s.slice(1)); }; function ee({ code: e, context: t, localState: n, rootState: o, rootSetState: r, event: i, isExpression: s = !0 }) { if (e.trim() === "") return; const l = tn(e.trim()); if (l) return Je({ ...o, ...n }, l); const a = { code: Qt(e, { isExpression: s }), builder: Jt(), context: t, event: i, rootSetState: r, rootState: o, localState: n }; try { return _t(a); } catch (u) { B.error("Failed code evaluation: " + u.message, { code: e }); return; } } function nn(e, t) { var n; return { ...(n = e.component) == null ? void 0 : n.options, ...e.options, ...on(e, t) }; } const on = (e, t) => { var n, o; if (((n = e.component) == null ? void 0 : n.name) === "Text" && ((o = e.component.options) != null && o.text) && typeof e.component.options.text == "string") return { ...e.component.options, text: e.component.options.text.replace(/{{([^}]+)}}/g, (r, i) => ee({ code: i, context: t, localState: t.localState, rootState: t.rootState, rootSetState: t.rootSetState })) }; }; function rn(e, ...t) { const n = Object.assign({}, e); for (const o of t) delete n[o]; return n; } function se(e, t, n = null, o = null, r = /* @__PURE__ */ new WeakSet()) { if (e == null || typeof e != "object") { t(e, (i) => { n !== null && o !== null && (n[o] = i); }); return; } r.has(e) || (r.add(e), Array.isArray(e) ? e.forEach((i, s) => { t(i, (a) => { e[s] = a; }), se(i, t, e, s, r); }) : Object.entries(e).forEach(([i, s]) => { t(s, (a) => { e[i] = a; }), se(s, t, e, i, r); })); } function Ze(e) { return e && typeof e == "object" && e["@type"] === "@builder.io/core:LocalizedValue"; } function sn(e) { if (!e || !Object.getOwnPropertyNames(e).length) return !1; let t = !1; return se(e, (n) => { if (Ze(n)) { t = !0; return; } }), t; } function an(e, t) { return !e || !Object.getOwnPropertyNames(e).length ? {} : (se(e, (n, o) => { Ze(n) && o(n[t] ?? void 0); }), e); } function ln(e, t) { var n, o; return (n = e.component) != null && n.options && sn((o = e.component) == null ? void 0 : o.options) && (t || console.warn("[Builder.io] In order to use localized fields in Builder, you must pass a locale prop to the BuilderComponent or to options object while fetching the content to resolve localized fields. Learn more: https://www.builder.io/c/docs/localization-inline#targeting-and-inline-localization"), e.component.options = an(e.component.options, t ?? "Default")), e; } const Ce = (e) => JSON.parse(JSON.stringify(e)), et = (e, t, n) => { if (Object(e) !== e) return e; const o = Array.isArray(t) ? t : t.toString().match(/[^.[\]]+/g); return o.slice(0, -1).reduce((r, i, s) => Object(r[i]) === r[i] ? r[i] : r[i] = Math.abs(Number(o[s + 1])) >> 0 === +o[s + 1] ? [] : {}, e)[o[o.length - 1]] = n, e; }; function ge(e) { if (e === null || typeof e != "object") return e; if (Array.isArray(e)) return e.map((n) => ge(n)); if (e["@type"] === "@builder.io/sdk:Element") return e; const t = {}; for (const n in e) n !== "meta" && Object.prototype.hasOwnProperty.call(e, n) && (t[n] = ge(e[n])); return t; } const cn = ["svelte", "vue", "angular", "qwik", "solid"].includes(R), dn = (e) => { if (cn) { const t = Ce(e); return { ...t, properties: { ...t.properties }, actions: { ...t.actions } }; } else { const t = ge(rn(e, "children", "meta")); return { ...t, properties: { ...t.properties }, actions: { ...t.actions }, children: e.children, meta: e.meta }; } }, un = ({ block: e, context: t, localState: n, rootState: o, rootSetState: r }) => { if (!e.bindings) return e; const i = dn(e); for (const s in e.bindings) { const l = e.bindings[s], a = ee({ code: l, localState: n, rootState: o, rootSetState: r, context: t }); et(i, s, a); } return i; }; function pn({ block: e, context: t, localState: n, rootState: o, rootSetState: r }) { let i = e; return i = un({ block: i, localState: n, rootState: o, rootSetState: r, context: t }), i = ln(i, o.locale), i; } function Te(e) { const t = e || (T() ? window.location.search : void 0); return t ? Ye(t).indexOf("builder.preview=") !== -1 : !1; } const mn = (e) => ({ type: "builder.registerComponent", data: ae(e) }), hn = (e) => { const t = e.toString().trim(), n = /^[a-zA-Z0-9_]+\s*=>/i.test(t); return `return (${!t.startsWith("function") && !t.startsWith("async") && !t.startsWith("(") && !n ? "function " : ""}${t}).apply(this, arguments)`; }; function ae(e) { return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? hn(n) : n)); } const We = {}; function Ss(e, t) { e === "plugin" && (t = ae(t)); let n = We[e]; if (n || (n = We[e] = []), n.push(t), T()) { const o = { type: "builder.register", data: { type: e, info: t } }; try { parent.postMessage(o, "*"), parent !== window && window.postMessage(o, "*"); } catch (r) { console.debug("Could not postmessage", r); } } } function ks(e) { var t; if (T()) { const n = JSON.parse(JSON.stringify(e)); e.action && (n.action = e.action.toString()), (t = window.parent) == null || t.postMessage({ type: "builder.registerAction", data: n }, "*"); } } const De = {}; function Cs(e) { if (T()) { Object.assign(De, e); const t = { type: "builder.settingsChange", data: De }; parent.postMessage(t, "*"); } } const Oe = "builder.", fn = "options.", tt = (e) => { if (!e) return {}; const t = Qe(e), n = {}; return Object.keys(t).forEach((o) => { if (o.startsWith(Oe)) { const r = o.replace(Oe, "").replace(fn, ""); n[r] = t[o]; } }), n; }, bn = () => { if (!T()) return {}; const e = new URLSearchParams(window.location.search); return tt(e); }, nt = "5.1.0", ot = () => ({ "X-Builder-SDK": R, "X-Builder-SDK-GEN": "2", "X-Builder-SDK-Version": nt }), gn = (e) => { if (e === "localhost" || e === "127.0.0.1") return e; const t = e.split("."); return t.length > 2 ? t.slice(1).join(".") : e; }, de = ({ name: e, canTrack: t }) => { var n; try { return t ? (n = document.cookie.split("; ").find((o) => o.startsWith(`${e}=`))) == null ? void 0 : n.split("=")[1] : void 0; } catch (o) { B.warn("[COOKIE] GET error: ", (o == null ? void 0 : o.message) || o); return; } }, rt = async (e) => de(e), yn = (e) => e.map(([t, n]) => n ? `${t}=${n}` : t).filter(K).join("; "), vn = [["secure", ""], ["SameSite", "None"]], Sn = ({ name: e, value: t, expires: n }) => { const r = (T() ? location.protocol === "https:" : !0) ? vn : [[]], i = n ? [["expires", n.toUTCString()]] : [[]], s = [[e, t], ...i, ["path", "/"], ["domain", gn(window.location.hostname)], ...r]; return yn(s); }, we = async ({ name: e, value: t, expires: n, canTrack: o }) => { try { if (!o) return; const r = Sn({ name: e, value: t, expires: n }); document.cookie = r; } catch (r) { B.warn("[COOKIE] SET error: ", (r == null ? void 0 : r.message) || r); } }; function kn() { 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 it() { return kn().replace(/-/g, ""); } const st = "builderSessionId", Cn = async ({ canTrack: e }) => { if (!e) return; const t = await rt({ name: st, canTrack: e }); if (K(t)) return t; { const n = Tn(); return wn({ id: n, canTrack: e }), n; } }, Tn = () => it(), wn = ({ id: e, canTrack: t }) => we({ name: st, value: e, canTrack: t }), at = () => T() && typeof localStorage < "u" ? localStorage : void 0, In = ({ key: e, canTrack: t }) => { var n; try { return t ? (n = at()) == null ? void 0 : n.getItem(e) : void 0; } catch (o) { console.debug("[LocalStorage] GET error: ", o); return; } }, $n = ({ key: e, canTrack: t, value: n }) => { var o; try { t && ((o = at()) == null || o.setItem(e, n)); } catch (r) { console.debug("[LocalStorage] SET error: ", r); } }, lt = "builderVisitorId", Rn = ({ canTrack: e }) => { if (!e) return; const t = In({ key: lt, canTrack: e }); if (K(t)) return t; { const n = En(); return An({ id: n, canTrack: e }), n; } }, En = () => it(), An = ({ id: e, canTrack: t }) => $n({ key: lt, value: e, canTrack: t }); function Ie(e) { var t; typeof process < "u" && ((t = process.env) != null && t.DEBUG) && String(process.env.DEBUG) == "true" && B.log(e); } const Pn = async ({ canTrack: e }) => { if (!e) return { visitorId: void 0, sessionId: void 0 }; const t = await Cn({ canTrack: e }), n = Rn({ canTrack: e }); return { sessionId: t, visitorId: n }; }, Bn = async ({ type: e, canTrack: t, apiKey: n, metadata: o, ...r }) => ({ type: e, data: { ...r, metadata: { url: location.href, ...o }, ...await Pn({ canTrack: t }), userAttributes: Xe(), ownerId: n } }); async function ye({ apiHost: e, ...t }) { if (!t.apiKey) { B.error("Missing API key for track call. Please provide your API key."); return; } if (!t.canTrack || A() || !(T() || R === "reactNative")) return; const o = `${e || "https://cdn.builder.io"}/api/v1/track`; return Ie(o), fetch(o, { method: "POST", body: JSON.stringify({ events: [await Bn(t)] }), headers: { "content-type": "application/json", ...ot() }, mode: "cors" }).catch((r) => { console.error("Failed to track: ", r); }); } const Ts = (e) => ye({ ...e, canTrack: !0 }), Vn = ["*.beta.builder.io", "beta.builder.io", "builder.io", "localhost", "qa.builder.io"]; function ct(e, t) { if (!t.origin.startsWith("http") && !t.origin.startsWith("https")) return !1; const n = new URL(t.origin), o = n.hostname; return (e || Vn).findIndex((r) => r.startsWith("*.") ? o.endsWith(r.slice(1)) : r === o) > -1; } let Ue = !1; const dt = (e) => { var t, n; Ue || (Ue = !0, T() && ((t = window.parent) == null || t.postMessage({ type: "builder.sdkInfo", data: { target: R, version: nt, supportsPatchUpdates: !1, // Supports builder-model="..." attribute which is needed to // scope our '+ add block' button styling supportsAddBlockScoping: !0, supportsCustomBreakpoints: !0, modelName: e.modelName, apiKey: e.apiKey, supportsXSmallBreakpoint: !0, blockLevelPersonalization: !0 } }, "*"), (n = window.parent) == null || n.postMessage({ type: "builder.updateContent", data: { options: e } }, "*"), window.addEventListener("message", (o) => { var i, s; if (!ct(e.trustedHosts, o)) return; const { data: r } = o; if (r != null && r.type) switch (r.type) { case "builder.evaluate": { const l = r.data.text, a = r.data.arguments || [], u = r.data.id, p = new Function(l); let f, c = null; try { f = p.apply(null, a); } catch (m) { c = m; } c ? (i = window.parent) == null || i.postMessage({ type: "builder.evaluateError", data: { id: u, error: c.message } }, "*") : f && typeof f.then == "function" ? f.then((m) => { var b; (b = window.parent) == null || b.postMessage({ type: "builder.evaluateResult", data: { id: u, result: m } }, "*"); }).catch(console.error) : (s = window.parent) == null || s.postMessage({ type: "builder.evaluateResult", data: { result: f, id: u } }, "*"); break; } } }))); }, ut = ({ model: e, trustedHosts: t, callbacks: n }) => (o) => { if (!ct(t, o)) return; const { data: r } = o; if (r) switch (r.type) { case "builder.configureSdk": { n.configureSdk(r.data); break; } case "builder.triggerAnimation": { n.animation(r.data); break; } case "builder.resetState": { const i = r.data, s = i.model, l = i == null ? void 0 : i.state, a = i.editType; s === e && l && n.stateUpdate(l, a); break; } case "builder.contentUpdate": { const i = r.data, s = i.key || i.alias || i.entry || i.modelName, l = i.data, a = i.editType; s === e && n.contentUpdate(l, a); break; } } }, ws = ({ model: e, apiKey: t, callback: n, trustedHosts: o }) => { if (!T) return B.warn("`subscribeToEditor` only works in the browser. It currently seems to be running on the server."), () => { }; dt({ modelName: e, apiKey: t }); const r = ut({ callbacks: { contentUpdate: n, animation: () => { }, configureSdk: () => { }, stateUpdate: () => { } }, model: e, trustedHosts: o }); return window.addEventListener("message", r), () => { window.removeEventListener("message", r); }; }, Nn = "builder.tests", $e = (e) => `${Nn}.${e}`, xn = ({ contentId: e }) => rt({ name: $e(e), canTrack: !0 }), Wn = ({ contentId: e }) => de({ name: $e(e), canTrack: !0 }), Dn = ({ contentId: e, value: t }) => we({ name: $e(e), value: t, canTrack: !0 }), pt = (e) => K(e.id) && K(e.variations) && Object.keys(e.variations).length > 0, On = ({ id: e, variations: t }) => { var r; let n = 0; const o = Math.random(); for (const i in t) { const s = (r = t[i]) == null ? void 0 : r.testRatio; if (n += s, o < n) return i; } return e; }, mt = (e) => { const t = On(e); return Dn({ contentId: e.id, value: t }).catch((n) => { B.error("could not store A/B test variation: ", n); }), t; }, ht = ({ item: e, testGroupId: t }) => { const n = e.variations[t]; return t === e.id || // handle edge-case where `testGroupId` points to non-existing variation !n ? { testVariationId: e.id, testVariationName: "Default" } : { data: n.data, testVariationId: n.id, testVariationName: n.name || (n.id === e.id ? "Default" : "") }; }, Un = ({ item: e, canTrack: t }) => { if (!t) return e; if (!e) return; if (!pt(e)) return e; const n = Wn({ contentId: e.id }) || mt({ variations: e.variations, id: e.id }), o = ht({ item: e, testGroupId: n }); return { ...e, ...o }; }, Ln = async ({ item: e, canTrack: t }) => { if (!t || !pt(e)) return e; const o = await xn({ contentId: e.id }) || mt({ variations: e.variations, id: e.id }), r = ht({ item: e, testGroupId: o }); return { ...e, ...r }; }; const Le = "builder.userAttributes"; function Fe() { let e = !0; const t = /* @__PURE__ */ new Set(); return { setUserAttributes(n) { if (!T()) return; const o = { ...this.getUserAttributes(), ...n }; we({ name: Le, value: JSON.stringify(o), canTrack: e }), t.forEach((r) => r(o)); }, getUserAttributes() { return T() ? JSON.parse(de({ name: Le, canTrack: e }) || "{}") : {}; }, subscribeOnUserAttributesChange(n, { fireImmediately: o } = {}) { return t.add(n), o && n(this.getUserAttributes()), function() { t.delete(n); }; }, setCanTrack(n) { e = n; } }; } let ve; T() && R === "qwik" ? (window.__BUILDER_USER_ATTRIBUTES_SERVICE__ || (window.__BUILDER_USER_ATTRIBUTES_SERVICE__ = Fe()), ve = window.__BUILDER_USER_ATTRIBUTES_SERVICE__) : ve = Fe(); const le = ve, Is = (e) => { le.setUserAttributes(e); }, G = (e) => { const t = K(e) ? e : !0; return le.setCanTrack(t), t; }; function Fn() { return typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : globalThis; } function Hn() { const e = Fn().fetch; if (typeof e > "u") throw console.warn(`Builder SDK could not find a global fetch function. Make sure you have a polyfill for fetch in your project. 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 Mn = Hn(); function Se(e, t = null, n = ".") { return Object.keys(e).reduce((o, r) => { const i = e[r], s = [t, r].filter(Boolean).join(n); return [typeof i == "object", i !== null, !(Array.isArray(i) && i.length === 0)].every(Boolean) ? { ...o, ...Se(i, s, n) } : { ...o, [s]: i }; }, {}); } function ft(e, t, n = {}) { for (const o in e) { const r = e[o], i = t ? t + "." + o : o; r && typeof r == "object" && !Array.isArray(r) && !Object.keys(r).find((s) => s.startsWith("$")) ? ft(r, i, n) : n[i] = r; } return n; } function jn(e) { const t = {}; for (const n in e) { const o = n.split("."); let r = t; for (let i = 0; i < o.length; i++) { const s = o[i]; i === o.length - 1 ? r[s] = e[n] : (r[s] = r[s] || {}, r = r[s]); } } return t; } const Kn = "v3", He = (e) => typeof e == "number" && !isNaN(e) && e >= 0, Re = (e) => { const { limit: t = 30, userAttributes: n, query: o, model: r, apiKey: i, enrich: s, locale: l, apiVersion: a = Kn, fields: u, omit: p, offset: f, cacheSeconds: c, staleCacheSeconds: m, sort: b, includeUnpublished: g, apiHost: P } = e; if (!i) throw new Error("Missing API key"); if (!["v3"].includes(a)) throw new Error(`Invalid apiVersion: expected 'v3', received '${a}'`); const U = t !== 1, V = P || "https://cdn.builder.io", w = new URL(`${V}/api/${a}/content/${r}`); w.searchParams.set("apiKey", i), w.searchParams.set("limit", String(t)), w.searchParams.set("noTraverse", String(U)), w.searchParams.set("includeRefs", String(!0)), l && w.searchParams.set("locale", l); let W = n || {}; if (s && w.searchParams.set("enrich", String(s)), w.searchParams.set("omit", p ?? "meta.componentsUsed"), u && w.searchParams.set("fields", u), Number.isFinite(f) && f > -1 && w.searchParams.set("offset", String(Math.floor(f))), typeof g == "boolean" && w.searchParams.set("includeUnpublished", String(g)), c && He(c) && w.searchParams.set("cacheSeconds", String(c)), m && He(m) && w.searchParams.set("staleCacheSeconds", String(m)), b) { const D = Se({ sort: b }); for (const H in D) w.searchParams.set(H, JSON.stringify(D[H])); } const J = { ...bn(), ...Qe(e.options || {}) }; W = { ...W, ...zn(J) }; const Q = Se(J); for (const D in Q) w.searchParams.set(D, String(Q[D])); if (Object.keys(W).length > 0 && w.searchParams.set("userAttributes", JSON.stringify(W)), o) { const D = ft({ query: o }); for (const H in D) w.searchParams.set(H, JSON.stringify(D[H])); } return w; }, qn = (e) => { const t = {}; for (const n in e) n.startsWith("userAttributes.") && (t[n] = e[n], delete e[n]); return t; }, zn = (e) => { if (T() && e.preview === "BUILDER_STUDIO") { e["userAttributes.urlPath"] = window.location.pathname, e["userAttributes.host"] = window.location.host; const t = qn(e), { userAttributes: n } = jn(t); return n; } return {}; }, Gn = (e) => "results" in e; async function Ee(e) { var o; const t = e.locale || ((o = e.userAttributes) == null ? void 0 : o.locale); t && (e.locale = t, e.userAttributes = { locale: t, ...e.userAttributes }); const n = await Yn({ ...e, limit: 1 }); return n && n[0] || null; } const Jn = async (e) => { var s; const t = Re(e), n = e.fetch ?? Mn, o = { ...e.fetchOptions, headers: { ...(s = e.fetchOptions) == null ? void 0 : s.headers, ...ot() } }; return await (await n(t.href, o)).json(); }, Qn = async (e, t, n = Re(e)) => { const o = G(e.canTrack); if (n.search.includes("preview="), !o || !(T() || R === "reactNative")) return t.results; try { const r = []; for (const i of t.results) r.push(await Ln({ item: i, canTrack: o })); t.results = r; } catch (r) { B.error("Could not process A/B tests. ", r); } return t.results; }; async function Yn(e) { const t = Re(e), n = await Jn(e); if (!Gn(n)) throw B.error("Error fetching data. ", { url: t, content: n, options: e }), n; return Qn(e, n); } const $s = async (e) => { var o, r, i; const t = e.path || ((o = e.url) == null ? void 0 : o.pathname) || ((r = e.userAttributes) == null ? void 0 : r.urlPath), n = { ...e, apiKey: e.apiKey, model: e.model || "page", userAttributes: { ...e.userAttributes, ...t ? { urlPath: t } : {} }, options: tt(e.searchParams || ((i = e.url) == null ? void 0 : i.searchParams) || e.options) }; return { apiKey: n.apiKey, model: n.model, content: await Ee(n) }; }, Ae = (e) => e ? e.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase() : ""; function Xn(e, t, n = {}) { let o, r, i, s = null, l = 0; const a = function() { l = n.leading === !1 ? 0 : Date.now(), s = null, i = e.apply(o, r), s || (o = r = null); }; return function() { const u = Date.now(); !l && n.leading === !1 && (l = u); const p = t - (u - l); return o = this, r = arguments, p <= 0 || p > t ? (s && (clearTimeout(s), s = null), l = u, i = e.apply(o, r), s || (o = r = null)) : !s && n.trailing !== !1 && (s = setTimeout(a, p)), i; }; } function _(e, ...t) { const n = Object(e); for (let o = 1; o < arguments.length; o++) { const r = arguments[o]; if (r != null) for (const i in r) Object.prototype.hasOwnProperty.call(r, i) && (n[i] = r[i]); } return n; } function _n(e) { for (const t of e) switch (t.trigger) { case "pageLoad": yt(t); break; case "scrollInView": eo(t); break; } } function bt(e) { console.warn(`Cannot animate element: element with ID ${e} not found!`); } function gt(e, t) { const n = Zn(e), o = getComputedStyle(t), r = e.steps[0].styles, i = e.steps[e.steps.length - 1].styles, s = [r, i]; for (const l of s) for (const a of n) a in l || (l[a] = o[a]); } function Zn(e) { const t = []; for (const n of e.steps) for (const o in n.styles) t.indexOf(o) === -1 && t.push(o); return t; } function yt(e) { const t = Array.prototype.slice.call(document.getElementsByClassName(e.elementId || e.id || "")); if (!t.length) { bt(e.elementId || e.id || ""); return; } Array.from(t).forEach((n) => { gt(e, n), n.style.transition = "none", n.style.transitionDelay = "0", _(n.style, e.steps[0].styles), setTimeout(() => { n.style.transition = `all ${e.duration}s ${Ae(e.easing)}`, e.delay && (n.style.transitionDelay = e.delay + "s"), _(n.style, e.steps[1].styles), setTimeout(() => { n.style.transition = "", n.style.transitionDelay = ""; }, (e.delay || 0) * 1e3 + e.duration * 1e3 + 100); }); }); } function eo(e) { const t = Array.prototype.slice.call(document.getElementsByClassName(e.elementId || e.id || "")); if (!t.length) { bt(e.elementId || e.id || ""); return; } Array.from(t).forEach((n) => { gt(e, n); let o = !1, r = !1; function i() { !o && l(n) ? (o = !0, r = !0, setTimeout(() => { _(n.style, e.steps[1].styles), e.repeat || document.removeEventListener("scroll", s), setTimeout(() => { r = !1, e.repeat || (n.style.transition = "", n.style.transitionDelay = ""); }, (e.duration + (e.delay || 0)) * 1e3 + 100); })) : e.repeat && o && !r && !l(n) && (o = !1, _(n.style, e.steps[0].styles)); } const s = Xn(i, 200, { leading: !1 }); function l(p) { const f = p.getBoundingClientRect(), c = window.innerHeight, b = (e.thresholdPercent || 0) / 100 * c; return f.bottom > b && f.top < c - b; } const a = e.steps[0].styles; function u() { _(n.style, a); } u(), setTimeout(() => { n.style.transition = `all ${e.duration}s ${Ae(e.easing)}`, e.delay && (n.style.transitionDelay = e.delay + "s"); }), document.addEventListener("scroll", s, { capture: !0, passive: !0 }), i(); }); } const vt = (e) => Object.entries(e).map(([n, o]) => { if (typeof o == "string") return `${Ae(n)}: ${o};`; }).filter(K), to = (e) => vt(e).join(` `), Rs = ({ mediaQuery: e, className: t, styles: n }) => { const o = `.${t} { ${to(n)} }`; return e ? `${e} { ${o} }` : o; }; function no({ style: e }) { return e; } const Es = ({ block: e, context: t }) => St(no({ style: e.style || {}, context: t, block: e })); function St(e) { switch (R) { case "svelte": case "vue": case "solid": case "angular": return vt(e).join(" "); case "qwik": case "reactNative": case "react": case "rsc": return e; } } const kt = (e, t) => e ? t ? e.models && e.models.length > 0 && !e.models.includes(t) : !1 : !0, oo = ({ block: e, registeredComponents: t, model: n }) => { var i; const o = (i = e.component) == null ? void 0 : i.name; if (!o) return null; const r = t[o]; if (!r || kt(r, n)) { console.warn(` Could not find a registered component named "${o}". If you registered it, is the file that registered it imported by the file that needs to render it?`); return; } else return r; }, ro = ({ block: e, context: t }) => { const { repeat: n, ...o } = e; if (!(n != null && n.collection)) return; const r = ee({ code: n.collection, localState: t.localState, rootState: t.rootState, rootSetState: t.rootSetState, context: t.context }); if (!Array.isArray(r)) return; const i = n.collection.split(".").pop(), s = n.itemName || (i ? i + "Item" : "item"); return r.map((a, u) => ({ context: { ...t, localState: { ...t.localState, $index: u, $item: a, [s]: a, [`$${s}Index`]: u } }, block: o })); }, io = (e, t) => { var n; return (n = e == null ? void 0 : e.shouldReceiveBuilderProps) != null && n.builderLinkComponent ? { builderLinkComponent: t } : {}; }, so = (e, t, n) => { var o; return (o = e == null ? void 0 : e.shouldReceiveBuilderProps) != null && o.builderComponents ? { builderComponents: Object.fromEntries(Object.entries(t).filter(([i, s]) => !kt(s, n))) } : {}; }, ao = (e, t) => { var n; return (n = e == null ? void 0 : e.shouldReceiveBuilderProps) != null && n.builderBlock ? { builderBlock: t } : {}; }, lo = (e, t) => { var n; return (n = e == null ? void 0 : e.shouldReceiveBuilderProps) != null && n.builderContext ? { builderContext: t } : {}; }, co = (e) => e.toString(), uo = () => Promise.resolve().then(() => Io).then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component DynamicDiv at ../dynamic-div.vue", e ), e; }), po = () => import("./block-wrapper-s3-0mqGr.js").then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component BlockWrapper at ./components/block-wrapper.vue", e ), e; }), mo = () => import("./component-ref-8g4g9kyF.js").then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component ComponentRef at ./components/component-ref/component-ref.vue", e ), e; }), ho = () => import("./repeated-block-kNj6mfjr.js").then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component RepeatedBlock at ./components/repeated-block.vue", e ), e; }), fo = () => import("./style-wrapper-CSSH3Epu.js").then((e) => e.default).catch((e) => { throw console.error( "Error while attempting to dynamically import component StyleWrapper at ./components/style-wrapper.vue", e ), e; }), bo = y({ name: "block", components: { StyleWrapper: Y(fo), RepeatedBlock: Y(ho), ComponentRef: Y(mo), BlockWrapper: Y(po), DynamicDiv: Y(uo) }, props: ["block", "context", "registeredComponents", "linkComponent"], data() { return { _processedBlock: { value: null, update: !1 }, generateKey: co }; }, mounted() { const e = this.processedBlock.id, t = this.processedBlock.animations; t && e && _n( t.map((n) => ({ ...n, elementId: e })) ); }, updated() { }, computed: { repeatItem() { return ro({ block: this.block, context: this.context }); }, processedBlock() { var t; return (t = this.block.repeat) != null && t.collection ? this.block : pn({ block: this.block, localState: this.context.localState, rootState: this.context.rootState, rootSetState: this.context.rootSetState, context: this.context.context }); }, blockComponent() { return oo({ block: this.processedBlock, registeredComponents: this.registeredComponents, model: this.context.model }); }, Tag() { var t; return this.block.tagName === "a" || ((t = this.processedBlock.properties) == null ? void 0 : t.href) || this.processedBlock.href ? this.linkComponent || "a" : this.block.tagName || "div"; }, canShowBlock() { var n, o; if ((n = this.block.repeat) != null && n.collection) return !!((o = this.repeatItem) != null && o.length); const e = "hide" in this.processedBlock ? this.processedBlock.hide : !1; return ("show" in this.processedBlock ? this.processedBlock.show : !0) && !e; }, childrenWithoutParentComponent() { var t; return !((t = this.blockComponent) != null && t.component) && !this.repeatItem ? this.processedBlock.children ?? [] : []; }, componentRefProps() { var e, t, n; return { blockChildren: this.processedBlock.children ?? [], componentRef: (e = this.blockComponent) == null ? void 0 : e.component, componentOptions: { ...nn(this.processedBlock, this.context), ...ao(this.blockComponent, this.processedBlock), ...lo(this.blockComponent, this.context), ...io(this.blockComponent, this.linkComponent), ...so( this.blockComponent, this.registeredComponents, this.context.model ) }, context: this.context, linkComponent: this.linkComponent, registeredComponents: this.registeredComponents, builderBlock: this.processedBlock, includeBlockProps: ((t = this.blockComponent) == null ? void 0 : t.noWrap) === !0, isInteractive: !((n = this.blockComponent) != null && n.isRSC && R === "rsc") }; } } }); function go(e, t, n, o, r, i) { var f; const s = k("StyleWrapper"), l = k("ComponentRef"), a = k("Block", !0), u = k("BlockWrapper"), p = k("RepeatedBlock"); return e.canShowBlock ? (d(), h(I, { key: 0 }, [ E(s, { block: e.processedBlock, context: e.context, id: e.block.id }, null, 8, ["block", "context", "id"]), (f = e.blockComponent) != null && f.noWrap ? (d(), h(I, { key: 1 }, [ e.repeatItem ? (d(!0), h(I, { key: 1 }, F(e.repeatItem, (c, m) => (d(), S(p, { key: e.generateKey(m), repeatContext: c.context, block: c.block, registeredComponents: e.registeredComponents, linkComponent: e.linkComponent }, null, 8, ["repeatContext", "block", "registeredComponents", "linkComponent"]))), 128)) : (d(), S(l, { key: 0, componentRef: e.componentRefProps.componentRef, componentOptions: e.componentRefProps.componentOptions, blockChildren: e.componentRefProps.blockChildren, context: e.componentRefProps.context, registeredComponents: e.componentRefProps.registeredComponents, linkComponent: e.componentRefProps.linkComponent, builderBlock: e.componentRefProps.builderBlock, includeBlockProps: e.componentRefProps.includeBlockProps, isInteractive: e.componentRefProps.isInteractive }, null, 8, ["componentRef", "componentOptions", "blockChildren", "context", "registeredComponents", "linkComponent", "builderBlock", "includeBlockProps", "isInteractive"])) ], 64)) : (d(), h(I, { key: 0 }, [ e.repeatItem ? (d(!0), h(I, { key: 1 }, F(e.repeatItem, (c, m) => (d(), S(p, { key: e.generateKey(m), repeatContext: c.context, block: c.block, registeredComponents: e.registeredComponents, linkComponent: e.linkComponent }, null, 8, ["repeatContext", "block", "registeredComponents", "linkComponent"]))), 128)) : (d(), S(u, { key: 0, Wrapper: e.Tag, block: e.processedBlock, context: e.context }, { default: O(() => [ E(l, { componentRef: e.componentRefProps.componentRef, componentOptions: e.componentRefProps.componentOptions, blockChildren: e.componentRefProps.blockChildren, context: e.componentRefProps.context, registeredComponents: e.componentRefProps.registeredComponents, linkComponent: e.componentRefProps.linkComponent, builderBlock: e.componentRefProps.builderBlock, includeBlockProps: e.componentRefProps.includeBlockProps, isInteractive: e.componentRefProps.isInteractive }, null, 8, ["componentRef", "componentOptions", "blockChildren", "context", "registeredComponents", "linkComponent", "builderBlock", "includeBlockProps", "isInteractive"]), (d(!0), h(I, null, F(e.childrenWithoutParentComponent, (c, m) => (d(), S(a, { key: c.id, block: c, registeredComponents: e.registeredComponents, linkComponent: e.linkComponent, context: e.context }, null, 8, ["block", "registeredComponents", "linkComponent", "context"]))), 128)) ]), _: 1 }, 8, ["Wrapper", "block", "context"])) ], 64)) ], 64)) : C("", !0); } const Ct = /* @__PURE__ */ v(bo, [["render", go]]), As = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: Ct }, Symbol.toStringTag, { value: "Module" })), yo = y({ name: "builder-blocks-wrapper", props: [ "blocks", "classNameProp", "path", "parent", "styleProp", "BlocksWrapperProps", "BlocksWrapper" ], data() { return { shouldUpdate: !1 }; }, mounted() { }, watch: { onUpdateHook0: { handler() { }, immediate: !0 } }, computed: { className() { var e; return [ "builder-blocks", (e = this.blocks) != null && e.length ? "" : "no-blocks", this.classNameProp ].filter(Boolean).join(" "); }, dataPath() { if (!this.path) return; const e = "this.", t = "component.options."; return this.path.startsWith(e) ? this.path.replace(e, "") : this.path.startsWith(t) ? this.path : `${t}${this.path || ""}`; }, onUpdateHook0() { return { 0: this.blocks }; } }, methods: { onClick() { var e, t; A() && !((e = this.blocks) != null && e.length) && ((t = window.parent) == null || t.postMessage( { type: "builder.clickEmptyBlocks", data: { parentElementId: this.parent, dataPath: this.dataPath } }, "*" )); }, onMouseEnter() { var e, t; A() && !((e = this.blocks) != null && e.length) && ((t = window.parent) == null || t.postMessage( { type: "builder.hoverEmptyBlocks", data: { parentElementId: this.parent, dataPath: this.dataPath } }, "*" )); } } }); function vo(e, t, n, o, r, i) { return d(), S(X(e.BlocksWrapper), $({ ref: "blocksWrapperRef", class: e.className + " component-5vz8uirn7sc", "builder-path": e.dataPath, "builder-parent-id": e.parent, style: e.styleProp, onClick: (s) => e.onClick(), onMouseEnter: (s) => e.onMouseEnter(), onKeyPress: (s) => e.onClick() }, { ...e.BlocksWrapperProps }), { default: O(() => [ N(e.$slots, "default", {}, void 0, !0) ]), _: 3 }, 16, ["class", "builder-path", "builder-parent-id", "style", "onClick", "onMouseEnter", "onKeyPress"]); } const So = /* @__PURE__ */ v(yo, [["render", vo], ["__scopeId", "data-v-82fc93d6"]]), ko = y({ name: "builder-blocks", components: { BlocksWrapper: So, Block: Ct }, props: [ "blocks", "parent", "path", "styleProp", "BlocksWrapperProps", "context", "className", "linkComponent", "registeredComponents" ], inject: { builderContext: be.key, componentsContext: Ge.key } }); function Co(e, t, n, o, r, i) { var a, u, p, f; const s = k("Block"), l = k("BlocksWrapper"); return d(), S(l, { blocks: e.blocks, parent: e.parent, path: e.path, styleProp: e.styleProp, BlocksWrapperProps: e.BlocksWrapperProps || ((a = e.context) == null ? void 0 : a.BlocksWrapperProps) || ((u = e.builderContext) == null ? void 0 : u.BlocksWrapperProps), classNameProp: e.className, BlocksWrapper: ((p = e.context) == null ? void 0 : p.BlocksWrapper) || ((f = e.builderContext) == null ? void 0 : f.BlocksWrapper) }, { default: O(() => [ N(e.$slots, "default"), e.blocks ? (d(!0), h(I, { key: 0 }, F(e.blocks, (c, m) => { var b; return d(), S(s, { key: c.id, block: c, linkComponent: e.linkComponent, context: e.context || e.builderContext, registeredComponents: e.registeredComponents || ((b = e.componentsContext) == null ? void 0 : b.registeredComponents) }, null, 8, ["block", "linkComponent", "context", "registeredComponents"]); }), 128)) : C("", !0) ]), _: 3 }, 8, ["blocks", "parent", "path", "styleProp", "BlocksWrapperProps", "classNameProp", "BlocksWrapper"]); } const q = /* @__PURE__ */ v(ko, [["render", Co]]), To = y({ name: "dynamic-div", props: [] }); function wo(e, t, n, o, r, i) { return d(), h("div", null, [ N(e.$slots, "default") ]); } const te = /* @__PURE__ */ v(To, [["render", wo]]), Io = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: te }, Symbol.toStringTag, { value: "Module" })), ue = y({ render() { return ze("style", { innerHTML: this.styles, "data-id": this.id, nonce: this.nonce }); }, name: "inlined-styles", props: ["styles", "id", "nonce"] }), Tt = { xsmall: { min: 0, default: 160, max: 320 }, small: { min: 321, default: 321, max: 640 }, medium: { min: 641, default: 642, max: 991 }, large: { min: 990, default: 991, max: 1200 } }, Ps = (e, t = Tt) => `@media (max-width: ${t[e].max}px)`, $o = (e) => { const t = Ce(Tt); if (!e) return t; const { xsmall: n, small: o, medium: r } = e; if (n) { const a = Math.floor(n / 2); t.xsmall = { max: n, min: a, default: a + 1 }; } if (!o || !r) return t; const i = n ? t.xsmall.max + 1 : Math.floor(o / 2); t.small = { max: o, min: i, default: i + 1 }; const s = t.small.max + 1; t.medium = { max: r, min: s, default: s + 1 }; const l = t.medium.max + 1; return t.large = { max: 2e3, // TODO: decide upper limit min: l, default: l + 1 }, t; }, Ro = (e) => `builder-columns ${e}-breakpoints`, Eo = y({ name: "builder-columns", components: { InlinedStyles: ue, DynamicRenderer: ke, Blocks: q, DynamicDiv: te }, props: [ "space", "columns", "stackColumnsAt", "builderLinkComponent", "reverseColumnsWhenStacked", "builderContext", "builderBlock", "builderComponents" ], data() { return { TARGET: R, getColumnsClass: Ro }; }, computed: { gutterSize() { return typeof this.space == "number" ? this.space || 0 : 20; }, cols() { return this.columns || []; }, stackAt() { return this.stackColumnsAt || "tablet"; }, flexDir() { return this.stackColumnsAt === "never" ? "row" : this.reverseColumnsWhenStacked ? "column-reverse" : "column"; } }, me