//#region ../types/dist/index.js
var e = {
	1: 36,
	2: 28,
	3: 22,
	4: 18
};
function t(e) {
	return e.type === "custom";
}
var n = {
	content: "<p>Enter your title</p>",
	level: 2,
	color: "#1a1a1a",
	textAlign: "left"
}, r = { content: "<p>Enter your text here</p>" }, i = {
	src: "",
	alt: "",
	width: "full",
	align: "center"
}, a = {
	text: "Click Here",
	url: "",
	backgroundColor: "#333333",
	textColor: "#ffffff",
	borderRadius: 6,
	fontSize: 15,
	buttonPadding: {
		top: 12,
		right: 24,
		bottom: 12,
		left: 24
	}
}, o = {
	lineStyle: "solid",
	color: "#e0e0e0",
	thickness: 1,
	width: "full"
}, s = { columns: "1" }, c = {
	url: "",
	thumbnailUrl: "",
	alt: "Video",
	width: "full",
	align: "center"
}, l = {
	iconStyle: "solid",
	iconSize: "medium",
	spacing: 10,
	align: "center"
}, u = { height: 24 }, d = { content: "" }, f = {
	fontSize: 15,
	color: "#1a1a1a",
	textAlign: "center",
	separator: "|",
	separatorColor: "#e0e0e0",
	spacing: 10
}, p = {
	hasHeaderRow: !0,
	borderColor: "#e0e0e0",
	borderWidth: 1,
	cellPadding: 8,
	fontSize: 15,
	color: "#1a1a1a",
	textAlign: "left"
}, m = {
	targetDate: "",
	timezone: "UTC",
	showDays: !0,
	showHours: !0,
	showMinutes: !0,
	showSeconds: !0,
	separator: ":",
	digitFontSize: 32,
	digitColor: "#1a1a1a",
	labelColor: "#6b7280",
	labelFontSize: 12,
	backgroundColor: "#ffffff",
	labelDays: "Days",
	labelHours: "Hours",
	labelMinutes: "Minutes",
	labelSeconds: "Seconds",
	expiredMessage: "This offer has expired",
	expiredImageUrl: "",
	hideOnExpiry: !1
}, h = {
	width: 600,
	backgroundColor: "#ffffff",
	fontFamily: "Arial",
	locale: "en"
};
function g(e) {
	return typeof e == "object" && !!e && !Array.isArray(e) && Object.getPrototypeOf(e) === Object.prototype;
}
function _(e, t) {
	let n = { ...e };
	for (let r of Object.keys(t)) {
		let i = e[r], a = t[r];
		a !== void 0 && (g(i) && g(a) ? n[r] = _(i, a) : n[r] = a);
	}
	return n;
}
function v(e = "Arial", t) {
	return {
		blocks: [],
		settings: {
			...h,
			fontFamily: e,
			...t
		}
	};
}
function y(e, t) {
	return !t || Object.keys(t).length === 0 ? e : _(e, t);
}
function b() {
	return crypto.randomUUID();
}
function x(e = 0) {
	return {
		top: e,
		right: e,
		bottom: e,
		left: e
	};
}
function S(e = 10) {
	return {
		padding: x(e),
		margin: x(0)
	};
}
function C(e = {}) {
	return y({
		id: b(),
		type: "title",
		...n,
		styles: S()
	}, e);
}
function w(e = {}) {
	return y({
		id: b(),
		type: "paragraph",
		...r,
		styles: S()
	}, e);
}
function T(e = {}) {
	return y({
		id: b(),
		type: "image",
		...i,
		styles: S()
	}, e);
}
function E(e = {}) {
	return y({
		id: b(),
		type: "button",
		...a,
		styles: S()
	}, e);
}
function D(e = {}) {
	return y({
		id: b(),
		type: "divider",
		...o,
		styles: S(20)
	}, e);
}
function O(e = {}) {
	return y({
		id: b(),
		type: "section",
		...s,
		children: [[]],
		styles: S(20)
	}, e);
}
function k(e = {}) {
	return y({
		id: b(),
		type: "video",
		...c,
		styles: S()
	}, e);
}
function A(e = {}) {
	return y({
		id: b(),
		type: "social",
		icons: [],
		...l,
		styles: S()
	}, e);
}
function j(e = {}) {
	return y({
		id: b(),
		type: "spacer",
		...u,
		styles: S(0)
	}, e);
}
function M(e = {}) {
	return y({
		id: b(),
		type: "html",
		...d,
		styles: S()
	}, e);
}
function N(e = {}) {
	return y({
		id: b(),
		type: "menu",
		items: [],
		...f,
		styles: S()
	}, e);
}
function P(e, t) {
	return Array.from({ length: t }, () => ({
		id: b(),
		cells: Array.from({ length: e }, () => ({
			id: b(),
			content: ""
		}))
	}));
}
function F(e = {}) {
	return y({
		id: b(),
		type: "table",
		rows: P(3, 3),
		...p,
		styles: S()
	}, e);
}
function I(e = {}) {
	return y({
		id: b(),
		type: "countdown",
		...m,
		styles: S()
	}, e);
}
function L(e) {
	return e.type === "repeatable" ? e.default ?? [] : e.type === "boolean" ? e.default ?? !1 : e.type === "number" ? e.default ?? 0 : e.default ?? "";
}
function R(e) {
	let t = {};
	for (let n of e.fields) t[n.key] = L(n);
	return {
		id: b(),
		type: "custom",
		customType: e.type,
		fieldValues: t,
		styles: S(),
		...e.dataSource ? { dataSourceFetched: !1 } : {}
	};
}
function z(e, t) {
	switch (e) {
		case "section": return O(t?.section);
		case "title": return C(t?.title);
		case "paragraph": return w(t?.paragraph);
		case "image": return T(t?.image);
		case "button": return E(t?.button);
		case "divider": return D(t?.divider);
		case "video": return k(t?.video);
		case "social": return A(t?.social);
		case "spacer": return j(t?.spacer);
		case "html": return M(t?.html);
		case "menu": return N(t?.menu);
		case "table": return F(t?.table);
		case "countdown": return I(t?.countdown);
		default: throw Error(`Unknown block type: ${e}`);
	}
}
function B(e) {
	let t = JSON.parse(JSON.stringify(e));
	return t.id = b(), t.type === "section" && (t.children = t.children.map((e) => e.map((e) => B(e)))), t;
}
var V = {
	liquid: {
		value: /\{\{.+?\}\}/g,
		logic: /\{%-?\s*(\w+).*?-?%\}/g
	},
	handlebars: {
		value: /\{\{\{?.+?\}?\}\}/g,
		logic: /\{\{[#/](\w+).*?\}\}/g
	},
	mailchimp: {
		value: /\*\|\w+\|\*/g,
		logic: /\*\|(\w+)[:|].*?\|\*/g
	},
	ampscript: {
		value: /%%=.+?=%%/g,
		logic: /%%\[\s*(\w+).*?\]%%/g
	}
}, H = {
	liquid: "{{",
	handlebars: "{{",
	mailchimp: "*|",
	ampscript: "%%="
};
function U(e) {
	for (let t of Object.keys(V)) if (V[t].value.source === e.value.source) return H[t];
	return null;
}
function W(e) {
	return e ? typeof e == "string" ? V[e] ?? V.liquid : e : V.liquid;
}
function G(e) {
	let t = e.source, n = e.flags.replace("g", "");
	return RegExp(`^${t}$`, n);
}
function K(e, t) {
	let n = e?.trim() || "";
	return G(t.logic).test(n) ? !1 : G(t.value).test(n);
}
function q(e, t) {
	let n = t.find((t) => t.value === e);
	return n ? n.label : e;
}
function J(e, t) {
	return e.replace(/(<span[^>]*\sdata-merge-tag="([^"]*)"[^>]*>)(.*?)(<\/span>)/g, (e, n, r, i, a) => `${n}${q(r, t)}${a}`);
}
function Y(e, t) {
	if (!e) return !1;
	let n = new RegExp(t.value.source, t.value.flags), r = new RegExp(t.logic.source, t.logic.flags);
	return n.test(e) || r.test(e);
}
function X(e, t) {
	return G(t.logic).test(e?.trim() || "");
}
function Z(e, t) {
	let n = new RegExp(t.logic.source, t.logic.flags.replace("g", "")), r = e.match(n);
	return r && r[1] ? r[1].toUpperCase() : e;
}
function Q(e, t) {
	return e.replace(/(<span[^>]*\sdata-logic-merge-tag="([^"]*)"[^>]*>)(.*?)(<\/span>)/g, (e, n, r, i, a) => `${n}${Z(r, t)}${a}`);
}
var $ = class extends Error {
	constructor(e, t) {
		super(e), this.statusCode = t, this.name = "SdkError";
	}
	statusCode;
	get isNotFound() {
		return this.statusCode === 404;
	}
	get isUnauthorized() {
		return this.statusCode === 401;
	}
	get isServerError() {
		return this.statusCode !== void 0 && this.statusCode >= 500;
	}
};
//#endregion
export { J as A, Z as C, X as D, t as E, K as O, b as S, U as T, A as _, Y as a, C as b, I as c, D as d, M as f, O as g, w as h, B as i, W as j, Q as k, R as l, N as m, V as n, z as o, T as p, $ as r, E as s, e as t, v as u, j as v, q as w, k as x, F as y };
