@maily-to/render 0.2.2 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1428 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +230 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +194 -256
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1397 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +43 -49
- package/readme.md +20 -56
- package/LICENSE +0 -21
- package/dist/index.d.ts +0 -292
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +0 -1
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["meta: MetaDescriptors","meta","props: MetaDescriptor","meta: MetaDescriptor","maily: Maily","content: string | JSONContent","node: JSONContent","antialiased: CSSProperties","headings: Record<AllowedHeadings, CSSProperties>","logoSizes: Record<AllowedLogoSizes, string>","DEFAULT_META_TAGS: MetaDescriptors","DEFAULT_HTML_PROPS: HtmlProps","DEFAULT_RENDER_OPTIONS: RenderOptions","DEFAULT_THEME","content: JSONContent","preview?: string | JSONContent","theme: Partial<ThemeOptions>","formatter: VariableFormatter","variable: string","value: string","values: Record<string, string>","link: string","key: string","value: PayloadValue","values: Record<string, PayloadValue>","pixel?: string","shouldReplace: boolean","meta: MetaDescriptors","meta","props: HtmlProps","href: string","node: JSONContent","options: RenderOptions","nodeOptions: NodeOptions","fontOptions: FontProps","bodyStyles: CSSProperties","options?: NodeOptions","options: NodeOptions","_: MarkType","text: JSX.Element","mark: MarkType","fallback?: string","_: JSONContent","__?: NodeOptions","radius: string | undefined","content: JSONContent","config?: MailyConfig & RenderOptions"],"sources":["../../../node_modules/.pnpm/@antfu+utils@9.2.0/node_modules/@antfu/utils/dist/index.mjs","../src/utils.ts","../src/meta.tsx","../../shared/dist/index.mjs","../src/preheader.ts","../src/maily.tsx","../src/render.ts"],"sourcesContent":["function clamp(n, min, max) {\n return Math.min(max, Math.max(min, n));\n}\nfunction sum(...args) {\n return flattenArrayable(args).reduce((a, b) => a + b, 0);\n}\nfunction lerp(min, max, t) {\n const interpolation = clamp(t, 0, 1);\n return min + (max - min) * interpolation;\n}\nfunction remap(n, inMin, inMax, outMin, outMax) {\n const interpolation = (n - inMin) / (inMax - inMin);\n return lerp(outMin, outMax, interpolation);\n}\n\nfunction toArray(array) {\n array = array ?? [];\n return Array.isArray(array) ? array : [array];\n}\nfunction flattenArrayable(array) {\n return toArray(array).flat(1);\n}\nfunction mergeArrayable(...args) {\n return args.flatMap((i) => toArray(i));\n}\nfunction partition(array, ...filters) {\n const result = Array.from({ length: filters.length + 1 }).fill(null).map(() => []);\n array.forEach((e, idx, arr) => {\n let i = 0;\n for (const filter of filters) {\n if (filter(e, idx, arr)) {\n result[i].push(e);\n return;\n }\n i += 1;\n }\n result[i].push(e);\n });\n return result;\n}\nfunction uniq(array) {\n return Array.from(new Set(array));\n}\nfunction uniqueBy(array, equalFn) {\n return array.reduce((acc, cur) => {\n const index = acc.findIndex((item) => equalFn(cur, item));\n if (index === -1)\n acc.push(cur);\n return acc;\n }, []);\n}\nfunction last(array) {\n return at(array, -1);\n}\nfunction remove(array, value) {\n if (!array)\n return false;\n const index = array.indexOf(value);\n if (index >= 0) {\n array.splice(index, 1);\n return true;\n }\n return false;\n}\nfunction at(array, index) {\n const len = array.length;\n if (!len)\n return void 0;\n if (index < 0)\n index += len;\n return array[index];\n}\nfunction range(...args) {\n let start, stop, step;\n if (args.length === 1) {\n start = 0;\n step = 1;\n [stop] = args;\n } else {\n [start, stop, step = 1] = args;\n }\n const arr = [];\n let current = start;\n while (current < stop) {\n arr.push(current);\n current += step || 1;\n }\n return arr;\n}\nfunction move(arr, from, to) {\n arr.splice(to, 0, arr.splice(from, 1)[0]);\n return arr;\n}\nfunction clampArrayRange(n, arr) {\n return clamp(n, 0, arr.length - 1);\n}\nfunction sample(arr, quantity) {\n return Array.from({ length: quantity }, (_) => arr[Math.round(Math.random() * (arr.length - 1))]);\n}\nfunction shuffle(array) {\n for (let i = array.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1));\n [array[i], array[j]] = [array[j], array[i]];\n }\n return array;\n}\nfunction filterInPlace(array, predicate) {\n for (let i = array.length; i--; i >= 0) {\n if (!predicate(array[i], i, array))\n array.splice(i, 1);\n }\n return array;\n}\n\nfunction assert(condition, message) {\n if (!condition)\n throw new Error(message);\n}\nconst toString = (v) => Object.prototype.toString.call(v);\nfunction getTypeName(v) {\n if (v === null)\n return \"null\";\n const type = toString(v).slice(8, -1).toLowerCase();\n return typeof v === \"object\" || typeof v === \"function\" ? type : typeof v;\n}\nfunction noop() {\n}\n\nfunction isDeepEqual(value1, value2) {\n const type1 = getTypeName(value1);\n const type2 = getTypeName(value2);\n if (type1 !== type2)\n return false;\n if (type1 === \"array\") {\n if (value1.length !== value2.length)\n return false;\n return value1.every((item, i) => {\n return isDeepEqual(item, value2[i]);\n });\n }\n if (type1 === \"object\") {\n const keyArr = Object.keys(value1);\n if (keyArr.length !== Object.keys(value2).length)\n return false;\n return keyArr.every((key) => {\n return isDeepEqual(value1[key], value2[key]);\n });\n }\n return Object.is(value1, value2);\n}\n\nfunction batchInvoke(functions) {\n functions.forEach((fn) => fn && fn());\n}\nfunction invoke(fn) {\n return fn();\n}\nfunction tap(value, callback) {\n callback(value);\n return value;\n}\n\nfunction notNullish(v) {\n return v != null;\n}\nfunction noNull(v) {\n return v !== null;\n}\nfunction notUndefined(v) {\n return v !== void 0;\n}\nfunction isTruthy(v) {\n return Boolean(v);\n}\n\nconst isDef = (val) => typeof val !== \"undefined\";\nconst isBoolean = (val) => typeof val === \"boolean\";\nconst isFunction = (val) => typeof val === \"function\";\nconst isNumber = (val) => typeof val === \"number\";\nconst isString = (val) => typeof val === \"string\";\nconst isObject = (val) => toString(val) === \"[object Object]\";\nconst isUndefined = (val) => toString(val) === \"[object Undefined]\";\nconst isNull = (val) => toString(val) === \"[object Null]\";\nconst isRegExp = (val) => toString(val) === \"[object RegExp]\";\nconst isDate = (val) => toString(val) === \"[object Date]\";\nfunction isPrimitive(val) {\n return !val || Object(val) !== val;\n}\nconst isWindow = (val) => typeof window !== \"undefined\" && toString(val) === \"[object Window]\";\nconst isBrowser = typeof window !== \"undefined\";\n\nfunction slash(str) {\n return str.replace(/\\\\/g, \"/\");\n}\nfunction ensurePrefix(prefix, str) {\n if (!str.startsWith(prefix))\n return prefix + str;\n return str;\n}\nfunction ensureSuffix(suffix, str) {\n if (!str.endsWith(suffix))\n return str + suffix;\n return str;\n}\nfunction template(str, ...args) {\n const [firstArg, fallback] = args;\n if (isObject(firstArg)) {\n const vars = firstArg;\n return str.replace(/\\{(\\w+)\\}/g, (_, key) => vars[key] || ((typeof fallback === \"function\" ? fallback(key) : fallback) ?? key));\n } else {\n return str.replace(/\\{(\\d+)\\}/g, (_, key) => {\n const index = Number(key);\n if (Number.isNaN(index))\n return key;\n return args[index];\n });\n }\n}\nconst urlAlphabet = \"useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict\";\nfunction randomStr(size = 16, dict = urlAlphabet) {\n let id = \"\";\n let i = size;\n const len = dict.length;\n while (i--)\n id += dict[Math.random() * len | 0];\n return id;\n}\nfunction capitalize(str) {\n return str[0].toUpperCase() + str.slice(1).toLowerCase();\n}\nconst _reFullWs = /^\\s*$/;\nfunction unindent(str) {\n const lines = (typeof str === \"string\" ? str : str[0]).split(\"\\n\");\n const whitespaceLines = lines.map((line) => _reFullWs.test(line));\n const commonIndent = lines.reduce((min, line, idx) => {\n if (whitespaceLines[idx])\n return min;\n const indent = line.match(/^\\s*/)?.[0].length;\n return indent === void 0 ? min : Math.min(min, indent);\n }, Number.POSITIVE_INFINITY);\n let emptyLinesHead = 0;\n while (emptyLinesHead < lines.length && whitespaceLines[emptyLinesHead])\n emptyLinesHead++;\n let emptyLinesTail = 0;\n while (emptyLinesTail < lines.length && whitespaceLines[lines.length - emptyLinesTail - 1])\n emptyLinesTail++;\n return lines.slice(emptyLinesHead, lines.length - emptyLinesTail).map((line) => line.slice(commonIndent)).join(\"\\n\");\n}\n\nfunction objectMap(obj, fn) {\n return Object.fromEntries(\n Object.entries(obj).map(([k, v]) => fn(k, v)).filter(notNullish)\n );\n}\nfunction isKeyOf(obj, k) {\n return k in obj;\n}\nfunction objectKeys(obj) {\n return Object.keys(obj);\n}\nfunction objectEntries(obj) {\n return Object.entries(obj);\n}\nfunction deepMerge(target, ...sources) {\n if (!sources.length)\n return target;\n const source = sources.shift();\n if (source === void 0)\n return target;\n if (isMergableObject(target) && isMergableObject(source)) {\n objectKeys(source).forEach((key) => {\n if (key === \"__proto__\" || key === \"constructor\" || key === \"prototype\")\n return;\n if (isMergableObject(source[key])) {\n if (!target[key])\n target[key] = {};\n if (isMergableObject(target[key])) {\n deepMerge(target[key], source[key]);\n } else {\n target[key] = source[key];\n }\n } else {\n target[key] = source[key];\n }\n });\n }\n return deepMerge(target, ...sources);\n}\nfunction deepMergeWithArray(target, ...sources) {\n if (!sources.length)\n return target;\n const source = sources.shift();\n if (source === void 0)\n return target;\n if (Array.isArray(target) && Array.isArray(source))\n target.push(...source);\n if (isMergableObject(target) && isMergableObject(source)) {\n objectKeys(source).forEach((key) => {\n if (key === \"__proto__\" || key === \"constructor\" || key === \"prototype\")\n return;\n if (Array.isArray(source[key])) {\n if (!target[key])\n target[key] = [];\n deepMergeWithArray(target[key], source[key]);\n } else if (isMergableObject(source[key])) {\n if (!target[key])\n target[key] = {};\n deepMergeWithArray(target[key], source[key]);\n } else {\n target[key] = source[key];\n }\n });\n }\n return deepMergeWithArray(target, ...sources);\n}\nfunction isMergableObject(item) {\n return isObject(item) && !Array.isArray(item);\n}\nfunction objectPick(obj, keys, omitUndefined = false) {\n return keys.reduce((n, k) => {\n if (k in obj) {\n if (!omitUndefined || obj[k] !== void 0)\n n[k] = obj[k];\n }\n return n;\n }, {});\n}\nfunction clearUndefined(obj) {\n Object.keys(obj).forEach((key) => obj[key] === void 0 ? delete obj[key] : {});\n return obj;\n}\nfunction hasOwnProperty(obj, v) {\n if (obj == null)\n return false;\n return Object.prototype.hasOwnProperty.call(obj, v);\n}\nconst _objectIdMap = /* @__PURE__ */ new WeakMap();\nfunction objectId(obj) {\n if (isPrimitive(obj))\n return obj;\n if (!_objectIdMap.has(obj)) {\n _objectIdMap.set(obj, randomStr());\n }\n return _objectIdMap.get(obj);\n}\n\n/*\nHow it works:\n`this.#head` is an instance of `Node` which keeps track of its current value and nests another instance of `Node` that keeps the value that comes after it. When a value is provided to `.enqueue()`, the code needs to iterate through `this.#head`, going deeper and deeper to find the last value. However, iterating through every single item is slow. This problem is solved by saving a reference to the last value as `this.#tail` so that it can reference it to add a new value.\n*/\n\nclass Node {\n\tvalue;\n\tnext;\n\n\tconstructor(value) {\n\t\tthis.value = value;\n\t}\n}\n\nclass Queue {\n\t#head;\n\t#tail;\n\t#size;\n\n\tconstructor() {\n\t\tthis.clear();\n\t}\n\n\tenqueue(value) {\n\t\tconst node = new Node(value);\n\n\t\tif (this.#head) {\n\t\t\tthis.#tail.next = node;\n\t\t\tthis.#tail = node;\n\t\t} else {\n\t\t\tthis.#head = node;\n\t\t\tthis.#tail = node;\n\t\t}\n\n\t\tthis.#size++;\n\t}\n\n\tdequeue() {\n\t\tconst current = this.#head;\n\t\tif (!current) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis.#head = this.#head.next;\n\t\tthis.#size--;\n\t\treturn current.value;\n\t}\n\n\tpeek() {\n\t\tif (!this.#head) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn this.#head.value;\n\n\t\t// TODO: Node.js 18.\n\t\t// return this.#head?.value;\n\t}\n\n\tclear() {\n\t\tthis.#head = undefined;\n\t\tthis.#tail = undefined;\n\t\tthis.#size = 0;\n\t}\n\n\tget size() {\n\t\treturn this.#size;\n\t}\n\n\t* [Symbol.iterator]() {\n\t\tlet current = this.#head;\n\n\t\twhile (current) {\n\t\t\tyield current.value;\n\t\t\tcurrent = current.next;\n\t\t}\n\t}\n}\n\nfunction pLimit(concurrency) {\n\tvalidateConcurrency(concurrency);\n\n\tconst queue = new Queue();\n\tlet activeCount = 0;\n\n\tconst resumeNext = () => {\n\t\tif (activeCount < concurrency && queue.size > 0) {\n\t\t\tqueue.dequeue()();\n\t\t\t// Since `pendingCount` has been decreased by one, increase `activeCount` by one.\n\t\t\tactiveCount++;\n\t\t}\n\t};\n\n\tconst next = () => {\n\t\tactiveCount--;\n\n\t\tresumeNext();\n\t};\n\n\tconst run = async (function_, resolve, arguments_) => {\n\t\tconst result = (async () => function_(...arguments_))();\n\n\t\tresolve(result);\n\n\t\ttry {\n\t\t\tawait result;\n\t\t} catch {}\n\n\t\tnext();\n\t};\n\n\tconst enqueue = (function_, resolve, arguments_) => {\n\t\t// Queue `internalResolve` instead of the `run` function\n\t\t// to preserve asynchronous context.\n\t\tnew Promise(internalResolve => {\n\t\t\tqueue.enqueue(internalResolve);\n\t\t}).then(\n\t\t\trun.bind(undefined, function_, resolve, arguments_),\n\t\t);\n\n\t\t(async () => {\n\t\t\t// This function needs to wait until the next microtask before comparing\n\t\t\t// `activeCount` to `concurrency`, because `activeCount` is updated asynchronously\n\t\t\t// after the `internalResolve` function is dequeued and called. The comparison in the if-statement\n\t\t\t// needs to happen asynchronously as well to get an up-to-date value for `activeCount`.\n\t\t\tawait Promise.resolve();\n\n\t\t\tif (activeCount < concurrency) {\n\t\t\t\tresumeNext();\n\t\t\t}\n\t\t})();\n\t};\n\n\tconst generator = (function_, ...arguments_) => new Promise(resolve => {\n\t\tenqueue(function_, resolve, arguments_);\n\t});\n\n\tObject.defineProperties(generator, {\n\t\tactiveCount: {\n\t\t\tget: () => activeCount,\n\t\t},\n\t\tpendingCount: {\n\t\t\tget: () => queue.size,\n\t\t},\n\t\tclearQueue: {\n\t\t\tvalue() {\n\t\t\t\tqueue.clear();\n\t\t\t},\n\t\t},\n\t\tconcurrency: {\n\t\t\tget: () => concurrency,\n\n\t\t\tset(newConcurrency) {\n\t\t\t\tvalidateConcurrency(newConcurrency);\n\t\t\t\tconcurrency = newConcurrency;\n\n\t\t\t\tqueueMicrotask(() => {\n\t\t\t\t\t// eslint-disable-next-line no-unmodified-loop-condition\n\t\t\t\t\twhile (activeCount < concurrency && queue.size > 0) {\n\t\t\t\t\t\tresumeNext();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t},\n\t\t},\n\t});\n\n\treturn generator;\n}\n\nfunction validateConcurrency(concurrency) {\n\tif (!((Number.isInteger(concurrency) || concurrency === Number.POSITIVE_INFINITY) && concurrency > 0)) {\n\t\tthrow new TypeError('Expected `concurrency` to be a number from 1 and up');\n\t}\n}\n\nconst VOID = Symbol(\"p-void\");\nclass PInstance extends Promise {\n constructor(items = [], options) {\n super(() => {\n });\n this.items = items;\n this.options = options;\n }\n promises = /* @__PURE__ */ new Set();\n get promise() {\n let batch;\n const items = [...Array.from(this.items), ...Array.from(this.promises)];\n if (this.options?.concurrency) {\n const limit = pLimit(this.options.concurrency);\n batch = Promise.all(items.map((p2) => limit(() => p2)));\n } else {\n batch = Promise.all(items);\n }\n return batch.then((l) => l.filter((i) => i !== VOID));\n }\n add(...args) {\n args.forEach((i) => {\n this.promises.add(i);\n });\n }\n map(fn) {\n return new PInstance(\n Array.from(this.items).map(async (i, idx) => {\n const v = await i;\n if (v === VOID)\n return VOID;\n return fn(v, idx);\n }),\n this.options\n );\n }\n filter(fn) {\n return new PInstance(\n Array.from(this.items).map(async (i, idx) => {\n const v = await i;\n const r = await fn(v, idx);\n if (!r)\n return VOID;\n return v;\n }),\n this.options\n );\n }\n forEach(fn) {\n return this.map(fn).then();\n }\n reduce(fn, initialValue) {\n return this.promise.then((array) => array.reduce(fn, initialValue));\n }\n clear() {\n this.promises.clear();\n }\n then(onfulfilled, onrejected) {\n return this.promise.then(onfulfilled, onrejected);\n }\n catch(fn) {\n return this.promise.catch(fn);\n }\n finally(fn) {\n return this.promise.finally(fn);\n }\n}\nfunction p(items, options) {\n return new PInstance(items, options);\n}\n\nfunction createSingletonPromise(fn) {\n let _promise;\n function wrapper() {\n if (!_promise)\n _promise = fn();\n return _promise;\n }\n wrapper.reset = async () => {\n const _prev = _promise;\n _promise = void 0;\n if (_prev)\n await _prev;\n };\n return wrapper;\n}\nfunction sleep(ms, callback) {\n return new Promise(\n (resolve) => setTimeout(async () => {\n await callback?.();\n resolve();\n }, ms)\n );\n}\nfunction createPromiseLock() {\n const locks = [];\n return {\n async run(fn) {\n const p = fn();\n locks.push(p);\n try {\n return await p;\n } finally {\n remove(locks, p);\n }\n },\n async wait() {\n await Promise.allSettled(locks);\n },\n isWaiting() {\n return Boolean(locks.length);\n },\n clear() {\n locks.length = 0;\n }\n };\n}\nfunction createControlledPromise() {\n let resolve, reject;\n const promise = new Promise((_resolve, _reject) => {\n resolve = _resolve;\n reject = _reject;\n });\n promise.resolve = resolve;\n promise.reject = reject;\n return promise;\n}\n\nconst timestamp = () => +Date.now();\n\n/* eslint-disable no-undefined,no-param-reassign,no-shadow */\n\n/**\n * Throttle execution of a function. Especially useful for rate limiting\n * execution of handlers on events like resize and scroll.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher)\n * are most useful.\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through,\n * as-is, to `callback` when the throttled-function is executed.\n * @param {object} [options] - An object to configure options.\n * @param {boolean} [options.noTrailing] - Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds\n * while the throttled-function is being called. If noTrailing is false or unspecified, callback will be executed\n * one final time after the last throttled-function call. (After the throttled-function has not been called for\n * `delay` milliseconds, the internal counter is reset).\n * @param {boolean} [options.noLeading] - Optional, defaults to false. If noLeading is false, the first throttled-function call will execute callback\n * immediately. If noLeading is true, the first the callback execution will be skipped. It should be noted that\n * callback will never executed if both noLeading = true and noTrailing = true.\n * @param {boolean} [options.debounceMode] - If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is\n * false (at end), schedule `callback` to execute after `delay` ms.\n *\n * @returns {Function} A new, throttled, function.\n */\nfunction throttle$1 (delay, callback, options) {\n var _ref = options || {},\n _ref$noTrailing = _ref.noTrailing,\n noTrailing = _ref$noTrailing === void 0 ? false : _ref$noTrailing,\n _ref$noLeading = _ref.noLeading,\n noLeading = _ref$noLeading === void 0 ? false : _ref$noLeading,\n _ref$debounceMode = _ref.debounceMode,\n debounceMode = _ref$debounceMode === void 0 ? undefined : _ref$debounceMode;\n /*\n * After wrapper has stopped being called, this timeout ensures that\n * `callback` is executed at the proper times in `throttle` and `end`\n * debounce modes.\n */\n\n\n var timeoutID;\n var cancelled = false; // Keep track of the last time `callback` was executed.\n\n var lastExec = 0; // Function to clear existing timeout\n\n function clearExistingTimeout() {\n if (timeoutID) {\n clearTimeout(timeoutID);\n }\n } // Function to cancel next exec\n\n\n function cancel(options) {\n var _ref2 = options || {},\n _ref2$upcomingOnly = _ref2.upcomingOnly,\n upcomingOnly = _ref2$upcomingOnly === void 0 ? false : _ref2$upcomingOnly;\n\n clearExistingTimeout();\n cancelled = !upcomingOnly;\n }\n /*\n * The `wrapper` function encapsulates all of the throttling / debouncing\n * functionality and when executed will limit the rate at which `callback`\n * is executed.\n */\n\n\n function wrapper() {\n for (var _len = arguments.length, arguments_ = new Array(_len), _key = 0; _key < _len; _key++) {\n arguments_[_key] = arguments[_key];\n }\n\n var self = this;\n var elapsed = Date.now() - lastExec;\n\n if (cancelled) {\n return;\n } // Execute `callback` and update the `lastExec` timestamp.\n\n\n function exec() {\n lastExec = Date.now();\n callback.apply(self, arguments_);\n }\n /*\n * If `debounceMode` is true (at begin) this is used to clear the flag\n * to allow future `callback` executions.\n */\n\n\n function clear() {\n timeoutID = undefined;\n }\n\n if (!noLeading && debounceMode && !timeoutID) {\n /*\n * Since `wrapper` is being called for the first time and\n * `debounceMode` is true (at begin), execute `callback`\n * and noLeading != true.\n */\n exec();\n }\n\n clearExistingTimeout();\n\n if (debounceMode === undefined && elapsed > delay) {\n if (noLeading) {\n /*\n * In throttle mode with noLeading, if `delay` time has\n * been exceeded, update `lastExec` and schedule `callback`\n * to execute after `delay` ms.\n */\n lastExec = Date.now();\n\n if (!noTrailing) {\n timeoutID = setTimeout(debounceMode ? clear : exec, delay);\n }\n } else {\n /*\n * In throttle mode without noLeading, if `delay` time has been exceeded, execute\n * `callback`.\n */\n exec();\n }\n } else if (noTrailing !== true) {\n /*\n * In trailing throttle mode, since `delay` time has not been\n * exceeded, schedule `callback` to execute `delay` ms after most\n * recent execution.\n *\n * If `debounceMode` is true (at begin), schedule `clear` to execute\n * after `delay` ms.\n *\n * If `debounceMode` is false (at end), schedule `callback` to\n * execute after `delay` ms.\n */\n timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);\n }\n }\n\n wrapper.cancel = cancel; // Return the wrapper function.\n\n return wrapper;\n}\n\n/* eslint-disable no-undefined */\n/**\n * Debounce execution of a function. Debouncing, unlike throttling,\n * guarantees that a function is only executed a single time, either at the\n * very beginning of a series of calls, or at the very end.\n *\n * @param {number} delay - A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.\n * @param {Function} callback - A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,\n * to `callback` when the debounced-function is executed.\n * @param {object} [options] - An object to configure options.\n * @param {boolean} [options.atBegin] - Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds\n * after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.\n * (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).\n *\n * @returns {Function} A new, debounced function.\n */\n\nfunction debounce$1 (delay, callback, options) {\n var _ref = options || {},\n _ref$atBegin = _ref.atBegin,\n atBegin = _ref$atBegin === void 0 ? false : _ref$atBegin;\n\n return throttle$1(delay, callback, {\n debounceMode: atBegin !== false\n });\n}\n\nfunction throttle(...args) {\n return throttle$1(...args);\n}\nfunction debounce(...args) {\n return debounce$1(...args);\n}\n\nexport { assert, at, batchInvoke, capitalize, clamp, clampArrayRange, clearUndefined, createControlledPromise, createPromiseLock, createSingletonPromise, debounce, deepMerge, deepMergeWithArray, ensurePrefix, ensureSuffix, filterInPlace, flattenArrayable, getTypeName, hasOwnProperty, invoke, isBoolean, isBrowser, isDate, isDeepEqual, isDef, isFunction, isKeyOf, isNull, isNumber, isObject, isPrimitive, isRegExp, isString, isTruthy, isUndefined, isWindow, last, lerp, mergeArrayable, move, noNull, noop, notNullish, notUndefined, objectEntries, objectId, objectKeys, objectMap, objectPick, p, partition, randomStr, range, remap, remove, sample, shuffle, slash, sleep, sum, tap, template, throttle, timestamp, toArray, toString, unindent, uniq, uniqueBy };\n","export function generateKey() {\n // Length of 6 is enough to avoid collisions\n // for react keys\n return Math.random().toString(36).substr(2, 6);\n}\n","export type MetaDescriptor =\n | {\n charSet: 'utf-8';\n }\n | {\n title: string;\n }\n | {\n name: string;\n content: string;\n }\n | {\n property: string;\n content: string;\n }\n | {\n httpEquiv: string;\n content: string;\n }\n | {\n tagName: 'meta' | 'link';\n [attribute: string]: string;\n }\n | {\n [name: string]: string;\n };\n\nexport type MetaDescriptors = MetaDescriptor[];\n\nexport function meta(meta: MetaDescriptors) {\n return (\n meta\n // only filter unique meta tags\n // so that we don't have duplicate meta tags\n .filter((meta, index, self) => {\n const meta_hash = hash(meta);\n return (\n index ===\n self.findIndex((t) => {\n return hash(t) === meta_hash;\n })\n );\n })\n .map(process)\n .filter(Boolean) as JSX.Element[]\n );\n}\n\nfunction process(props: MetaDescriptor) {\n if ('tagName' in props) {\n const { tagName, ...attributes } = props;\n const Comp = tagName;\n return <Comp key={JSON.stringify(attributes)} {...attributes} />;\n }\n\n if ('title' in props) {\n return <title>{props.title}</title>;\n }\n\n if ('charSet' in props) {\n return <meta charSet={props.charSet} />;\n }\n\n return <meta key={JSON.stringify(props)} {...props} />;\n}\n\n/**\n * hash the meta object to string\n * so that we can filter out duplicates\n * for that we have to sort the object keys\n * and then stringify it and hash it\n */\nfunction hash(meta: MetaDescriptor) {\n const sortedMeta = Object.keys(meta)\n .sort()\n .reduce((acc, key) => {\n const _key = key as keyof MetaDescriptor;\n acc[_key] = meta[_key];\n return acc;\n }, {} as MetaDescriptor);\n\n return JSON.stringify(sortedMeta);\n}\n","//#region src/theme.ts\nconst allowedFallbackFonts = [\n\t\"Arial\",\n\t\"Helvetica\",\n\t\"Verdana\",\n\t\"Georgia\",\n\t\"Times New Roman\",\n\t\"serif\",\n\t\"sans-serif\",\n\t\"monospace\",\n\t\"cursive\",\n\t\"fantasy\"\n];\nconst allowedFontFormats = [\n\t\"woff\",\n\t\"woff2\",\n\t\"truetype\",\n\t\"opentype\",\n\t\"embedded-opentype\",\n\t\"svg\"\n];\nconst DEFAULT_FONT = {\n\tfallbackFontFamily: \"sans-serif\",\n\tfontFamily: \"Inter\",\n\twebFont: {\n\t\turl: \"https://rsms.me/inter/font-files/Inter-Regular.woff2?v=3.19\",\n\t\tformat: \"woff2\"\n\t}\n};\nconst DEFAULT_LINK_TEXT_COLOR = \"#111827\";\nconst DEFAULT_RENDERER_THEME = {\n\tcolors: {\n\t\theading: \"#111827\",\n\t\tparagraph: \"#374151\",\n\t\thorizontal: \"#EAEAEA\",\n\t\tfooter: \"#64748B\",\n\t\tblockquoteBorder: \"#D1D5DB\",\n\t\tcodeBackground: \"#EFEFEF\",\n\t\tcodeText: \"#111827\",\n\t\tlinkCardTitle: \"#111827\",\n\t\tlinkCardDescription: \"#6B7280\",\n\t\tlinkCardBadgeText: \"#111827\",\n\t\tlinkCardBadgeBackground: \"#FEF08A\",\n\t\tlinkCardSubTitle: \"#6B7280\"\n\t},\n\tfontSize: {\n\t\tparagraph: {\n\t\t\tsize: \"15px\",\n\t\t\tlineHeight: \"26.25px\"\n\t\t},\n\t\tfooter: {\n\t\t\tsize: \"14px\",\n\t\t\tlineHeight: \"24px\"\n\t\t}\n\t},\n\tcontainer: {\n\t\tbackgroundColor: \"#ffffff\",\n\t\tmaxWidth: \"600px\",\n\t\tminWidth: \"300px\",\n\t\tpaddingTop: \"0.5rem\",\n\t\tpaddingRight: \"0.5rem\",\n\t\tpaddingBottom: \"0.5rem\",\n\t\tpaddingLeft: \"0.5rem\",\n\t\tborderRadius: \"0px\",\n\t\tborderWidth: \"0px\",\n\t\tborderColor: \"transparent\"\n\t},\n\tbody: {\n\t\tbackgroundColor: \"#ffffff\",\n\t\tpaddingTop: \"0px\",\n\t\tpaddingRight: \"0px\",\n\t\tpaddingBottom: \"0px\",\n\t\tpaddingLeft: \"0px\"\n\t},\n\tbutton: {\n\t\tbackgroundColor: \"#000000\",\n\t\tcolor: \"#ffffff\",\n\t\tpaddingTop: \"10px\",\n\t\tpaddingRight: \"32px\",\n\t\tpaddingBottom: \"10px\",\n\t\tpaddingLeft: \"32px\"\n\t},\n\tlink: { color: DEFAULT_LINK_TEXT_COLOR },\n\tfont: DEFAULT_FONT\n};\nconst DEFAULT_EDITOR_THEME = {\n\tcontainer: {\n\t\tbackgroundColor: \"#ffffff\",\n\t\tmaxWidth: \"600px\",\n\t\tminWidth: \"300px\",\n\t\tpaddingTop: \"8px\",\n\t\tpaddingRight: \"8px\",\n\t\tpaddingBottom: \"8px\",\n\t\tpaddingLeft: \"8px\",\n\t\tborderRadius: \"0px\",\n\t\tborderWidth: \"0px\",\n\t\tborderColor: \"transparent\"\n\t},\n\tbody: {\n\t\tbackgroundColor: \"#ffffff\",\n\t\tpaddingTop: \"0px\",\n\t\tpaddingRight: \"0px\",\n\t\tpaddingBottom: \"0px\",\n\t\tpaddingLeft: \"0px\"\n\t},\n\tbutton: {\n\t\tbackgroundColor: \"#000000\",\n\t\tcolor: \"#ffffff\",\n\t\tpaddingTop: \"10px\",\n\t\tpaddingRight: \"32px\",\n\t\tpaddingBottom: \"10px\",\n\t\tpaddingLeft: \"32px\"\n\t},\n\tlink: { color: DEFAULT_LINK_TEXT_COLOR },\n\tfont: DEFAULT_FONT\n};\n\n//#endregion\n//#region src/css-variables.ts\n/**\n* if the value is undefined, it will return an empty object\n* so that we don't override the default value\n* @param name - The name of the CSS variable\n* @param value - The value of the CSS variable\n* @returns The CSS variable value\n*/\nfunction getVariableValue(name, value) {\n\tif (value === void 0 || value === null || value === \"\") return {};\n\treturn { [name]: value };\n}\n/**\n* Get the CSS variables for the theme\n* @param theme - The theme\n* @returns The CSS variables\n* @example\n* ```ts\n* const theme = {\n* body: {\n* backgroundColor: 'red',\n* },\n* };\n*\n* const cssVariables = getCssVariables(theme);\n*\n* console.log(cssVariables);\n* // { '--mly-body-background-color': 'red' }\n*/\nfunction getMailyCssVariables(theme) {\n\tconst font = theme.font || DEFAULT_FONT;\n\treturn {\n\t\t...getVariableValue(\"--mly-body-background-color\", theme.body?.backgroundColor),\n\t\t...getVariableValue(\"--mly-body-padding-top\", theme.body?.paddingTop),\n\t\t...getVariableValue(\"--mly-body-padding-right\", theme.body?.paddingRight),\n\t\t...getVariableValue(\"--mly-body-padding-bottom\", theme.body?.paddingBottom),\n\t\t...getVariableValue(\"--mly-body-padding-left\", theme.body?.paddingLeft),\n\t\t...getVariableValue(\"--mly-container-background-color\", theme.container?.backgroundColor),\n\t\t...getVariableValue(\"--mly-container-max-width\", theme.container?.maxWidth),\n\t\t...getVariableValue(\"--mly-container-min-width\", theme.container?.minWidth),\n\t\t...getVariableValue(\"--mly-container-padding-top\", theme.container?.paddingTop),\n\t\t...getVariableValue(\"--mly-container-padding-right\", theme.container?.paddingRight),\n\t\t...getVariableValue(\"--mly-container-padding-bottom\", theme.container?.paddingBottom),\n\t\t...getVariableValue(\"--mly-container-padding-left\", theme.container?.paddingLeft),\n\t\t...getVariableValue(\"--mly-container-border-radius\", theme.container?.borderRadius),\n\t\t...getVariableValue(\"--mly-container-border-width\", theme.container?.borderWidth),\n\t\t...getVariableValue(\"--mly-container-border-color\", theme.container?.borderColor),\n\t\t...getVariableValue(\"--mly-button-background-color\", theme.button?.backgroundColor),\n\t\t...getVariableValue(\"--mly-button-text-color\", theme.button?.color),\n\t\t...getVariableValue(\"--mly-button-padding-top\", theme.button?.paddingTop),\n\t\t...getVariableValue(\"--mly-button-padding-right\", theme.button?.paddingRight),\n\t\t...getVariableValue(\"--mly-button-padding-bottom\", theme.button?.paddingBottom),\n\t\t...getVariableValue(\"--mly-button-padding-left\", theme.button?.paddingLeft),\n\t\t...getVariableValue(\"--mly-link-color\", theme.link?.color),\n\t\t...getVariableValue(\"--mly-font-family\", font.fontFamily),\n\t\t...getVariableValue(\"--mly-font-fallback-family\", font.fallbackFontFamily),\n\t\t\"--mly-font\": `var(--mly-font-family), var(--mly-font-fallback-family)`\n\t};\n}\n\n//#endregion\n//#region src/font.ts\nfunction loadFont(font) {\n\tconst style = fontStyle(font);\n\tconst styleElement = document.createElement(\"style\");\n\tstyleElement.textContent = style;\n\tdocument.head.appendChild(styleElement);\n}\nfunction fontStyle(font) {\n\tconst { fontFamily, fallbackFontFamily, webFont } = font;\n\tconst src = webFont ? `src: url(${webFont.url}) format('${webFont.format}');` : \"\";\n\tconst style = `\n @font-face {\n font-family: '${fontFamily}';\n font-style: normal;\n font-weight: 400;\n mso-font-alt: '${fallbackFontFamily}';\n ${src}\n }`;\n\treturn style;\n}\n\n//#endregion\nexport { DEFAULT_EDITOR_THEME, DEFAULT_FONT, DEFAULT_LINK_TEXT_COLOR, DEFAULT_RENDERER_THEME, allowedFallbackFonts, allowedFontFormats, fontStyle, getMailyCssVariables, getVariableValue, loadFont };\n//# sourceMappingURL=index.mjs.map","import { JSONContent } from '@tiptap/core';\nimport { Maily } from './maily';\n\nexport class Preheader {\n constructor(private readonly maily: Maily) {}\n\n render(content: string | JSONContent): string {\n if (typeof content === 'string') {\n return content;\n }\n\n return this.renderNode(content);\n }\n\n private renderNode(node: JSONContent): string {\n const type = node.type || '';\n switch (type) {\n case 'doc':\n return this.doc(node);\n case 'paragraph':\n return this.paragraph(node);\n case 'text':\n return this.text(node);\n case 'variable':\n return this.variable(node);\n default:\n // it's fine to ignore unknown nodes\n // because we don't want to break the rendering process\n return '';\n }\n }\n\n private doc(node: JSONContent): string {\n const children = node.content || [];\n if (children.length === 0) {\n return '';\n }\n\n return children.map((child) => this.renderNode(child)).join('');\n }\n\n private paragraph(node: JSONContent): string {\n const children = node.content || [];\n if (children.length === 0) {\n return '';\n }\n\n return children.map((child) => this.renderNode(child)).join('');\n }\n\n private text(node: JSONContent): string {\n return node.text || '';\n }\n\n private variable(node: JSONContent): string {\n const { id: variable, fallback } = node.attrs || {};\n return this.maily.getVariableValue(variable, fallback);\n }\n}\n","import { Fragment, type CSSProperties } from 'react';\nimport {\n Text,\n Html,\n Head,\n Body,\n Font,\n Container,\n Link,\n Heading,\n Hr,\n Button,\n Img,\n Preview,\n Row,\n Column,\n Section,\n HtmlProps,\n} from '@react-email/components';\nimport { renderAsync as reactEmailRenderAsync } from '@react-email/render';\nimport type { JSONContent } from '@tiptap/core';\nimport { deepMerge } from '@antfu/utils';\nimport { generateKey } from './utils';\nimport type { MetaDescriptors } from './meta';\nimport { meta } from './meta';\nimport { parse } from 'node-html-parser';\nimport juice from 'juice';\nimport type {\n FontProps,\n RendererThemeOptions as ThemeOptions,\n} from '@maily-to/shared';\nimport {\n DEFAULT_RENDERER_THEME as DEFAULT_THEME,\n DEFAULT_FONT,\n DEFAULT_LINK_TEXT_COLOR,\n} from '@maily-to/shared';\nimport { Preheader } from './preheader';\n\ninterface NodeOptions {\n parent?: JSONContent;\n prev?: JSONContent;\n next?: JSONContent;\n\n payloadValue?: PayloadValue;\n}\n\nexport interface MarkType {\n [key: string]: any;\n type: string;\n attrs?: Record<string, any> | undefined;\n}\n\nconst antialiased: CSSProperties = {\n WebkitFontSmoothing: 'antialiased',\n MozOsxFontSmoothing: 'grayscale',\n};\n\nconst allowedHeadings = ['h1', 'h2', 'h3'] as const;\ntype AllowedHeadings = (typeof allowedHeadings)[number];\n\nconst headings: Record<AllowedHeadings, CSSProperties> = {\n h1: {\n fontSize: '36px',\n lineHeight: '40px',\n fontWeight: 800,\n },\n h2: {\n fontSize: '30px',\n lineHeight: '36px',\n fontWeight: 700,\n },\n h3: {\n fontSize: '24px',\n lineHeight: '38px',\n fontWeight: 600,\n },\n};\n\nconst allowedLogoSizes = ['sm', 'md', 'lg'] as const;\ntype AllowedLogoSizes = (typeof allowedLogoSizes)[number];\n\nconst logoSizes: Record<AllowedLogoSizes, string> = {\n sm: '40px',\n md: '48px',\n lg: '64px',\n};\n\nexport interface MailyConfig {\n /**\n * The preview text is the snippet of text that is pulled into the inbox\n * preview of an email client, usually right after the subject line.\n *\n * Default: `undefined`\n */\n preview?: string | JSONContent;\n /**\n * The theme object allows you to customize the colors and font sizes of the\n * rendered email.\n *\n * Default:\n * ```js\n * {\n * colors: {\n * heading: '#111827',\n * paragraph: '#374151',\n * horizontal: '#EAEAEA',\n * footer: '#64748B',\n * },\n * fontSize: {\n * paragraph: '15px',\n * footer: {\n * size: '14px',\n * lineHeight: '24px',\n * },\n * },\n * }\n * ```\n *\n * @example\n * ```js\n * const maily = new Maily(content, {\n * theme: {\n * colors: {\n * heading: '#111827',\n * },\n * fontSize: {\n * footer: {\n * size: '14px',\n * lineHeight: '24px',\n * },\n * },\n * },\n * });\n * ```\n */\n theme?: Partial<ThemeOptions>;\n}\n\nconst CODE_FONT_FAMILY =\n 'SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace';\nexport const DEFAULT_SECTION_BACKGROUND_COLOR = '#ffffff';\nexport const DEFAULT_SECTION_ALIGN = 'left';\nexport const DEFAULT_SECTION_BORDER_WIDTH = 1;\nexport const DEFAULT_SECTION_BORDER_COLOR = '#000000';\n\nexport const DEFAULT_SECTION_MARGIN_TOP = 0;\nexport const DEFAULT_SECTION_MARGIN_RIGHT = 0;\nexport const DEFAULT_SECTION_MARGIN_BOTTOM = 0;\nexport const DEFAULT_SECTION_MARGIN_LEFT = 0;\n\nexport const DEFAULT_SECTION_PADDING_TOP = 5;\nexport const DEFAULT_SECTION_PADDING_RIGHT = 5;\nexport const DEFAULT_SECTION_PADDING_BOTTOM = 5;\nexport const DEFAULT_SECTION_PADDING_LEFT = 5;\n\nexport const DEFAULT_COLUMNS_WIDTH = '100%';\nexport const DEFAULT_COLUMNS_GAP = 8;\n\nexport const DEFAULT_COLUMN_BACKGROUND_COLOR = 'transparent';\nexport const DEFAULT_COLUMN_BORDER_RADIUS = 0;\nexport const DEFAULT_COLUMN_BORDER_WIDTH = 0;\nexport const DEFAULT_COLUMN_BORDER_COLOR = 'transparent';\n\nexport const DEFAULT_COLUMN_PADDING_TOP = 0;\nexport const DEFAULT_COLUMN_PADDING_RIGHT = 0;\nexport const DEFAULT_COLUMN_PADDING_BOTTOM = 0;\nexport const DEFAULT_COLUMN_PADDING_LEFT = 0;\n\nexport const DEFAULT_INLINE_IMAGE_HEIGHT = 20;\nexport const DEFAULT_INLINE_IMAGE_WIDTH = 20;\n\nexport const LINK_PROTOCOL_REGEX = /https?:\\/\\//;\n\nexport const DEFAULT_META_TAGS: MetaDescriptors = [\n {\n name: 'viewport',\n content: 'width=device-width',\n },\n {\n httpEquiv: 'X-UA-Compatible',\n content: 'IE=edge',\n },\n {\n name: 'x-apple-disable-message-reformatting',\n },\n {\n // http://www.html-5.com/metatags/format-detection-meta-tag.html\n // It will prevent iOS from automatically detecting possible phone numbers in a block of text\n name: 'format-detection',\n content: 'telephone=no,address=no,email=no,date=no,url=no',\n },\n {\n name: 'color-scheme',\n content: 'light',\n },\n {\n name: 'supported-color-schemes',\n content: 'light',\n },\n];\n\nexport const DEFAULT_HTML_PROPS: HtmlProps = {\n lang: 'en',\n dir: 'ltr',\n};\n\nconst DEFAULT_RENDER_OPTIONS: RenderOptions = {\n pretty: false,\n plainText: false,\n};\n\nexport interface RenderOptions {\n /**\n * The options object allows you to customize the output of the rendered\n * email.\n * - `pretty` - If `true`, the output will be formatted with indentation and\n * line breaks.\n * - `plainText` - If `true`, the output will be plain text instead of HTML.\n * This is useful for testing purposes.\n *\n * Default: `pretty` - `false`, `plainText` - `false`\n */\n pretty?: boolean;\n plainText?: boolean;\n}\n\nexport type VariableFormatter = (options: {\n variable: string;\n fallback?: string;\n}) => string;\nexport type VariableValues = Map<string, string>;\nexport type LinkValues = Map<string, string>;\n\nexport type PayloadValue = Record<string, any> | boolean;\nexport type PayloadValues = Map<string, PayloadValue>;\n\nexport class Maily {\n readonly preheader = new Preheader(this);\n\n private readonly content: JSONContent;\n private config: MailyConfig = {\n theme: DEFAULT_THEME,\n };\n\n private variableFormatter: VariableFormatter = ({ variable, fallback }) => {\n return fallback\n ? `{{${variable},fallback=${fallback}}}`\n : `{{${variable}}}`;\n };\n\n private shouldReplaceVariableValues = false;\n private variableValues: VariableValues = new Map();\n private linkValues: LinkValues = new Map();\n private openTrackingPixel: string | undefined;\n private payloadValues: PayloadValues = new Map();\n private marksOrder = ['underline', 'bold', 'italic', 'textStyle', 'link'];\n private meta: MetaDescriptors = DEFAULT_META_TAGS;\n private htmlProps: HtmlProps = DEFAULT_HTML_PROPS;\n\n constructor(content: JSONContent = { type: 'doc', content: [] }) {\n this.content = content;\n }\n\n setPreviewText(preview?: string | JSONContent) {\n this.config.preview = preview;\n }\n\n setTheme(theme: Partial<ThemeOptions>) {\n this.config.theme = deepMerge(\n this.config.theme || DEFAULT_THEME,\n theme\n ) as ThemeOptions;\n }\n\n setVariableFormatter(formatter: VariableFormatter) {\n this.variableFormatter = formatter;\n }\n\n /**\n * `setVariableValue` will set the variable value.\n * It will also set `shouldReplaceVariableValues` to `true`.\n *\n * @param variable - The variable name\n * @param value - The variable value\n */\n setVariableValue(variable: string, value: string) {\n if (!this.shouldReplaceVariableValues) {\n this.shouldReplaceVariableValues = true;\n }\n\n this.variableValues.set(variable, value);\n }\n\n /**\n * `setVariableValues` will set the variable values.\n * It will also set `shouldReplaceVariableValues` to `true`.\n *\n * @param values - The variable values\n *\n * @example\n * ```js\n * const maily = new Maily(content);\n * maily.setVariableValues({\n * name: 'John Doe',\n * email: 'john@doe.com',\n * });\n * ```\n */\n setVariableValues(values: Record<string, string>) {\n if (!this.shouldReplaceVariableValues) {\n this.shouldReplaceVariableValues = true;\n }\n\n Object.entries(values).forEach(([variable, value]) => {\n this.setVariableValue(variable, value);\n });\n }\n\n setLinkValue(link: string, value: string) {\n this.linkValues.set(link, value);\n }\n\n setLinkValues(values: Record<string, string>) {\n Object.entries(values).forEach(([link, value]) => {\n this.setLinkValue(link, value);\n });\n }\n\n setPayloadValue(key: string, value: PayloadValue) {\n if (!this.shouldReplaceVariableValues) {\n this.shouldReplaceVariableValues = true;\n }\n\n this.payloadValues.set(key, value);\n }\n\n setPayloadValues(values: Record<string, PayloadValue>) {\n Object.entries(values).forEach(([key, value]) => {\n this.setPayloadValue(key, value);\n });\n }\n\n /**\n * `setOpenTrackingPixel` will set the open tracking pixel.\n *\n * @param pixel - The open tracking pixel\n */\n setOpenTrackingPixel(pixel?: string) {\n this.openTrackingPixel = pixel;\n }\n\n /**\n * `setShouldReplaceVariableValues` will determine whether to replace the\n * variable values or not. Otherwise, it will just return the formatted variable.\n *\n * Default: `false`\n */\n setShouldReplaceVariableValues(shouldReplace: boolean) {\n this.shouldReplaceVariableValues = shouldReplace;\n }\n\n /**\n * `setMetaTags` will add the meta tags.\n *\n * @param meta - The meta tags\n */\n setMetaTags(meta: MetaDescriptors) {\n this.meta.push(...meta);\n }\n\n /**\n * `setHtmlProps` will set the HTML props.\n *\n * @param props - The HTML props\n */\n setHtmlProps(props: HtmlProps) {\n this.htmlProps = {\n ...this.htmlProps,\n ...props,\n };\n }\n\n getAllLinks() {\n const nodes = this.content.content || [];\n const links = new Set<string>();\n\n const isValidLink = (href: string) => {\n return (\n href &&\n this.isValidUrl(href) &&\n !href.startsWith('#') &&\n !href.startsWith('mailto:') &&\n !href.startsWith('tel:') &&\n typeof href === 'string'\n );\n };\n\n const extractLinksFromNode = (node: JSONContent) => {\n if (node.type === 'button') {\n const originalLink = node.attrs?.url;\n if (isValidLink(originalLink) && originalLink) {\n links.add(originalLink);\n }\n } else if (node.content) {\n node.content.forEach((childNode) => {\n if (childNode.marks) {\n childNode.marks.forEach((mark) => {\n const originalLink = mark.attrs?.href;\n if (mark.type === 'link' && isValidLink(originalLink)) {\n links.add(originalLink);\n }\n });\n }\n if (childNode.content) {\n extractLinksFromNode(childNode);\n }\n });\n }\n };\n\n nodes.forEach((childNode) => {\n extractLinksFromNode(childNode);\n });\n\n return links;\n }\n\n private isValidUrl(href: string) {\n try {\n const _ = new URL(href);\n return true;\n } catch (err) {\n return false;\n }\n }\n\n async render(\n options: RenderOptions = DEFAULT_RENDER_OPTIONS\n ): Promise<string> {\n const markup = this.markup();\n\n return reactEmailRenderAsync(markup, options);\n }\n\n /**\n * `children` will return the children of the content.\n * this is useful for rendering the content in a custom component.\n *\n * @returns The children of the content as JSX elements\n */\n children() {\n const nodes = this.content.content || [];\n const jsxNodes = nodes.map((node, index) => {\n const nodeOptions: NodeOptions = {\n prev: nodes[index - 1],\n next: nodes[index + 1],\n parent: node,\n };\n\n const component = this.renderNode(node, nodeOptions);\n if (!component) {\n return null;\n }\n\n return <Fragment key={generateKey()}>{component}</Fragment>;\n });\n\n return jsxNodes;\n }\n\n /**\n * `markup` will render the JSON content into React Email markup.\n * and return the raw React Tree.\n */\n markup() {\n const jsxNodes = this.children();\n\n const { preview } = this.config;\n const tags = meta(this.meta);\n const htmlProps = this.htmlProps;\n const containerStyles = this.config.theme?.container;\n const fontOptions: FontProps = {\n ...(this.config.theme?.font || DEFAULT_FONT),\n fontStyle: 'normal',\n fontWeight: 400,\n };\n\n const bodyStyles: CSSProperties = {\n margin: '0px',\n ...this.config.theme?.body,\n };\n\n const preheader = preview ? this.preheader.render(preview) : null;\n\n const markup = (\n <Html {...htmlProps}>\n <Head>\n <Font {...fontOptions} />\n\n <style\n dangerouslySetInnerHTML={{\n __html: `blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}@media only screen and (max-width:425px){.tab-row-full{width:100%!important}.tab-col-full{display:block!important;width:100%!important}.tab-pad{padding:0!important}}`,\n }}\n />\n {tags}\n </Head>\n <Body style={bodyStyles}>\n {preheader ? <Preview>{preheader}</Preview> : null}\n <Container\n style={{\n width: '100%',\n marginLeft: 'auto',\n marginRight: 'auto',\n borderStyle: 'solid',\n ...containerStyles,\n }}\n >\n {jsxNodes}\n </Container>\n {this.openTrackingPixel ? (\n <Img\n alt=\"\"\n src={this.openTrackingPixel}\n style={{\n display: 'none',\n width: '1px',\n height: '1px',\n }}\n />\n ) : null}\n </Body>\n </Html>\n );\n\n return markup;\n }\n\n private getMarginOverrideConditions(\n node: JSONContent,\n options?: NodeOptions\n ) {\n const { parent, prev, next } = options || {};\n\n const isNextSpacer = next?.type === 'spacer';\n const isPrevSpacer = prev?.type === 'spacer';\n\n const isParentListItem = parent?.type === 'listItem';\n\n const isLastSectionElement = parent?.type === 'section' && !next;\n const isFirstSectionElement = parent?.type === 'section' && !prev;\n\n const isLastColumnElement = parent?.type === 'column' && !next;\n const isFirstColumnElement = parent?.type === 'column' && !prev;\n\n const isFirstRepeatElement = parent?.type === 'repeat' && !prev;\n const isLastRepeatElement = parent?.type === 'repeat' && !next;\n\n const isFirstShowElement = parent?.type === 'show' && !prev;\n const isLastShowElement = parent?.type === 'show' && !next;\n\n return {\n isNextSpacer,\n isPrevSpacer,\n isLastSectionElement,\n isFirstSectionElement,\n isParentListItem,\n isLastColumnElement,\n isFirstColumnElement,\n isFirstRepeatElement,\n isLastRepeatElement,\n isFirstShowElement,\n isLastShowElement,\n\n shouldRemoveTopMargin:\n isPrevSpacer ||\n isFirstSectionElement ||\n isFirstColumnElement ||\n isFirstRepeatElement ||\n isFirstShowElement,\n shouldRemoveBottomMargin:\n isNextSpacer ||\n isLastSectionElement ||\n isLastColumnElement ||\n isLastRepeatElement ||\n isLastShowElement,\n };\n }\n\n // `getMappedContent` will call corresponding node type\n // and return text content\n private getMappedContent(\n node: JSONContent,\n options?: NodeOptions\n ): JSX.Element[] {\n const allNodes = node.content || [];\n return allNodes\n .map((childNode, index) => {\n const component = this.renderNode(childNode, {\n ...options,\n next: allNodes[index + 1],\n prev: allNodes[index - 1],\n });\n if (!component) {\n return null;\n }\n\n return <Fragment key={generateKey()}>{component}</Fragment>;\n })\n .filter((n) => n !== null) as JSX.Element[];\n }\n\n // `renderNode` will call the method of the corresponding node type\n private renderNode(\n node: JSONContent,\n options: NodeOptions = {}\n ): JSX.Element | null {\n const type = node.type || '';\n\n if (type in this) {\n // @ts-expect-error - `this` is not assignable to type 'never'\n return this[type]?.(node, options) as JSX.Element;\n }\n\n throw new Error(`Node type \"${type}\" is not supported.`);\n }\n\n // `renderMark` will call the method of the corresponding mark type\n private renderMark(node: JSONContent, options?: NodeOptions): JSX.Element {\n // It will wrap the text with the corresponding mark type\n const text = node?.text || <> </>;\n let marks = node?.marks || [];\n // sort the marks by uderline, bold, italic, textStyle, link\n // so that the text will be wrapped in the correct order\n marks.sort((a, b) => {\n return this.marksOrder.indexOf(a.type) - this.marksOrder.indexOf(b.type);\n });\n\n return marks.reduce(\n (acc, mark) => {\n const type = mark.type;\n if (type in this) {\n // @ts-expect-error - `this` is not assignable to type 'never'\n return this[type]?.(mark, acc) as JSX.Element;\n }\n\n throw new Error(`Mark type \"${type}\" is not supported.`);\n },\n <>{text}</>\n );\n }\n\n private paragraph(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n const alignment = attrs?.textAlign || 'left';\n const { isParentListItem, shouldRemoveBottomMargin } =\n this.getMarginOverrideConditions(node, options);\n\n const show = this.shouldShow(node, options);\n if (!show) {\n return <></>;\n }\n\n const marginBottom = isParentListItem || shouldRemoveBottomMargin ? 0 : 20;\n\n return (\n <Text\n style={{\n ...(alignment !== 'left' ? { textAlign: alignment } : {}),\n ...antialiased,\n fontSize: this.config.theme?.fontSize?.paragraph?.size,\n lineHeight: this.config.theme?.fontSize?.paragraph?.lineHeight,\n color: this.config.theme?.colors?.paragraph,\n margin: `0 0 ${marginBottom}px 0`,\n }}\n >\n {node.content ? (\n this.getMappedContent(node, {\n ...options,\n parent: node,\n })\n ) : (\n <> </>\n )}\n </Text>\n );\n }\n\n private text(node: JSONContent, options?: NodeOptions): JSX.Element {\n if (node.marks) {\n return this.renderMark(node, options);\n }\n\n const text = node.text;\n // if it's all empty, return an invisible space length\n // of the text so that it doesn't look empty for inline-images\n const spaces = text?.match(/\\s/g);\n if (spaces && spaces.length === text?.length) {\n return (\n <>\n {spaces.map((_, index) => (\n <Fragment key={index}> </Fragment>\n ))}\n </>\n );\n }\n\n return text ? <>{text}</> : <> </>;\n }\n\n private bold(_: MarkType, text: JSX.Element): JSX.Element {\n return <strong>{text}</strong>;\n }\n\n private italic(_: MarkType, text: JSX.Element): JSX.Element {\n return <em>{text}</em>;\n }\n\n private underline(_: MarkType, text: JSX.Element): JSX.Element {\n return <u>{text}</u>;\n }\n\n private strike(_: MarkType, text: JSX.Element): JSX.Element {\n return <s style={{ textDecoration: 'line-through' }}>{text}</s>;\n }\n\n private textStyle(mark: MarkType, text: JSX.Element): JSX.Element {\n const { attrs } = mark;\n const { color = this.config.theme?.colors?.paragraph } = attrs || {};\n\n return (\n <span\n style={{\n color,\n }}\n >\n {text}\n </span>\n );\n }\n\n private link(\n mark: MarkType,\n text: JSX.Element,\n options?: NodeOptions\n ): JSX.Element {\n const { attrs } = mark;\n\n const linkTheme = this.config.theme?.link;\n\n let href = attrs?.href || '#';\n const target = attrs?.target || '_blank';\n const rel = attrs?.rel || 'noopener noreferrer nofollow';\n const isUrlVariable = attrs?.isUrlVariable ?? false;\n\n if (isUrlVariable) {\n const linkWithoutProtocol = this.removeLinkProtocol(href);\n href = this.variableUrlValue(linkWithoutProtocol, options);\n } else {\n href = this.linkValues.get(href) || href;\n }\n\n return (\n <Link\n href={href}\n rel={rel}\n style={{\n fontWeight: 500,\n textDecoration: 'none',\n color: linkTheme?.color || DEFAULT_LINK_TEXT_COLOR,\n }}\n target={target}\n >\n {text}\n </Link>\n );\n }\n\n private removeLinkProtocol(href: string) {\n return href.replace(LINK_PROTOCOL_REGEX, '');\n }\n\n private variableUrlValue(href: string, options?: NodeOptions) {\n const { payloadValue } = options || {};\n const linkWithoutProtocol = this.removeLinkProtocol(href);\n\n if (!this.shouldReplaceVariableValues) {\n return this.variableFormatter({\n variable: linkWithoutProtocol,\n });\n }\n\n return (\n (typeof payloadValue === 'object'\n ? payloadValue[linkWithoutProtocol]\n : payloadValue) ??\n this.variableValues.get(linkWithoutProtocol) ??\n href\n );\n }\n\n private heading(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n\n const level = `h${Number(attrs?.level) || 1}`;\n const alignment = attrs?.textAlign || 'left';\n const { shouldRemoveBottomMargin } = this.getMarginOverrideConditions(\n node,\n options\n );\n const { fontSize, lineHeight, fontWeight } =\n headings[level as AllowedHeadings];\n\n const show = this.shouldShow(node, options);\n if (!show) {\n return <></>;\n }\n\n return (\n <Heading\n // @ts-expect-error - `this` is not assignable to type 'never'\n as={level}\n style={{\n textAlign: alignment,\n color: this.config.theme?.colors?.heading,\n fontSize,\n lineHeight,\n fontWeight,\n }}\n mb={shouldRemoveBottomMargin ? 0 : 12}\n mt={0}\n mx={0}\n >\n {this.getMappedContent(node, {\n ...options,\n parent: node,\n })}\n </Heading>\n );\n }\n\n private variable(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { payloadValue } = options || {};\n const { id: variable, fallback } = node.attrs || {};\n\n const shouldShow = this.shouldShow(node, options);\n if (!shouldShow || !variable) {\n return <></>;\n }\n\n const formattedVariable = this.getVariableValue(\n variable,\n fallback,\n options\n );\n\n if (node?.marks) {\n return this.renderMark(\n {\n text: formattedVariable,\n marks: node.marks,\n },\n options\n );\n }\n\n return <>{formattedVariable}</>;\n }\n\n getVariableValue(variable: string, fallback?: string, options?: NodeOptions) {\n const { payloadValue } = options || {};\n\n let formattedVariable = this.variableFormatter({\n variable,\n fallback,\n });\n\n // If `shouldReplaceVariableValues` is true, replace the variable values\n // Otherwise, just return the formatted variable\n if (this.shouldReplaceVariableValues) {\n formattedVariable =\n (typeof payloadValue === 'object'\n ? payloadValue[variable]\n : payloadValue) ??\n this.variableValues.get(variable) ??\n fallback ??\n formattedVariable;\n }\n\n return formattedVariable;\n }\n\n private horizontalRule(_: JSONContent, __?: NodeOptions): JSX.Element {\n return (\n <Hr\n style={{\n marginTop: '32px',\n marginBottom: '32px',\n }}\n />\n );\n }\n\n private orderedList(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { shouldRemoveBottomMargin } = this.getMarginOverrideConditions(\n node,\n options\n );\n\n return (\n <Container\n style={{\n marginTop: '0px',\n marginBottom: shouldRemoveBottomMargin ? '0' : '20px',\n }}\n >\n <ol\n style={{\n paddingLeft: '26px',\n listStyleType: 'decimal',\n }}\n >\n {this.getMappedContent(node, {\n ...options,\n parent: node,\n })}\n </ol>\n </Container>\n );\n }\n\n private bulletList(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { parent, next } = options || {};\n const { shouldRemoveBottomMargin } = this.getMarginOverrideConditions(\n node,\n {\n parent,\n next,\n }\n );\n\n return (\n <Container\n style={{\n maxWidth: '100%',\n marginTop: '0px',\n marginBottom: shouldRemoveBottomMargin ? '0' : '20px',\n }}\n >\n <ul\n style={{\n paddingLeft: '26px',\n listStyleType: 'disc',\n }}\n >\n {this.getMappedContent(node, {\n ...options,\n parent: node,\n })}\n </ul>\n </Container>\n );\n }\n\n private listItem(node: JSONContent, options?: NodeOptions): JSX.Element {\n return (\n <li\n style={{\n marginBottom: '8px',\n marginTop: '8px',\n paddingLeft: '6px',\n ...antialiased,\n }}\n >\n {this.getMappedContent(node, { ...options, parent: node })}\n </li>\n );\n }\n\n private button(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n\n const buttonTheme = this.config.theme?.button;\n\n let {\n text: _text,\n isTextVariable,\n url,\n isUrlVariable,\n variant,\n buttonColor: _buttonColor,\n textColor: _textColor,\n borderRadius,\n // @TODO: Update the attribute to `textAlign`\n alignment = 'left',\n\n paddingTop: _paddingTop,\n paddingRight: _paddingRight,\n paddingBottom: _paddingBottom,\n paddingLeft: _paddingLeft,\n } = attrs || {};\n\n const buttonColor = _buttonColor || buttonTheme?.backgroundColor;\n const textColor = _textColor || buttonTheme?.color;\n\n let paddingTop =\n parseInt(String(_paddingTop || buttonTheme?.paddingTop)) || 0;\n const paddingRight =\n parseInt(String(_paddingRight || buttonTheme?.paddingRight)) || 0;\n let paddingBottom =\n parseInt(String(_paddingBottom || buttonTheme?.paddingBottom)) || 0;\n const paddingLeft =\n parseInt(String(_paddingLeft || buttonTheme?.paddingLeft)) || 0;\n\n const shouldShow = this.shouldShow(node, options);\n if (!shouldShow) {\n return <></>;\n }\n\n let radius: string | undefined = '0px';\n if (borderRadius === 'round') {\n radius = '9999px';\n } else if (borderRadius === 'smooth') {\n radius = '6px';\n }\n\n const { shouldRemoveBottomMargin } = this.getMarginOverrideConditions(\n node,\n options\n );\n\n const href = isUrlVariable\n ? this.variableUrlValue(url, options)\n : this.linkValues.get(url) || url;\n const text = isTextVariable ? this.variableUrlValue(_text, options) : _text;\n\n paddingTop += 2;\n paddingBottom += 2;\n\n return (\n <Container\n style={{\n textAlign: alignment,\n maxWidth: '100%',\n marginBottom: shouldRemoveBottomMargin ? '0px' : '20px',\n }}\n >\n <Button\n href={href}\n style={{\n color: String(textColor),\n backgroundColor:\n variant === 'filled' ? String(buttonColor) : 'transparent',\n borderColor: String(buttonColor),\n borderWidth: '2px',\n borderStyle: 'solid',\n textDecoration: 'none',\n fontSize: '14px',\n fontWeight: 500,\n borderRadius: radius,\n padding: `${paddingTop}px ${paddingRight}px ${paddingBottom}px ${paddingLeft}px`,\n }}\n >\n {text}\n </Button>\n </Container>\n );\n }\n\n private spacer(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n const { height } = attrs || {};\n\n const shouldShow = this.shouldShow(node, options);\n if (!shouldShow) {\n return <></>;\n }\n\n return (\n <Container\n style={{\n height: `${height}px`,\n }}\n />\n );\n }\n\n private hardBreak(_: JSONContent, __?: NodeOptions): JSX.Element {\n return <br />;\n }\n\n private logo(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n let {\n src,\n isSrcVariable,\n alt,\n title,\n size,\n // @TODO: Update the attribute to `textAlign`\n alignment = 'left',\n } = attrs || {};\n\n const shouldShow = this.shouldShow(node, options);\n if (!shouldShow) {\n return <></>;\n }\n\n src = isSrcVariable ? this.variableUrlValue(src, options) : src;\n\n const { shouldRemoveBottomMargin } = this.getMarginOverrideConditions(\n node,\n options\n );\n\n return (\n <Row\n style={{\n marginTop: '0px',\n marginBottom: shouldRemoveBottomMargin ? '0px' : '32px',\n }}\n >\n <Column align={alignment}>\n <Img\n alt={alt || title || 'Logo'}\n src={src}\n style={{\n width: logoSizes[size as AllowedLogoSizes] || size,\n height: logoSizes[size as AllowedLogoSizes] || size,\n }}\n title={title || alt || 'Logo'}\n />\n </Column>\n </Row>\n );\n }\n\n private image(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n let {\n src,\n isSrcVariable,\n alt,\n title,\n width = 'auto',\n height = 'auto',\n alignment = 'center',\n externalLink = '',\n isExternalLinkVariable,\n borderRadius = 0,\n } = attrs || {};\n\n const shouldShow = this.shouldShow(node, options);\n if (!shouldShow) {\n return <></>;\n }\n\n const { shouldRemoveBottomMargin } = this.getMarginOverrideConditions(\n node,\n options\n );\n\n src = isSrcVariable ? this.variableUrlValue(src, options) : src;\n externalLink = isExternalLinkVariable\n ? this.variableUrlValue(externalLink, options)\n : externalLink;\n\n // Handle width value\n const imageWidth = width === 'auto' ? 'auto' : Number(width);\n const widthStyle = imageWidth === 'auto' ? 'auto' : `${imageWidth}px`;\n\n // Handle height value\n const imageHeight = height === 'auto' ? 'auto' : Number(height);\n const heightStyle = imageHeight === 'auto' ? 'auto' : `${imageHeight}px`;\n\n const mainImage = (\n <Img\n alt={alt || title || 'Image'}\n src={src}\n style={{\n width: widthStyle, // Use the calculated width\n height: heightStyle, // Use the calculated height\n maxWidth: '100%', // Ensure image doesn't overflow container\n outline: 'none',\n border: 'none',\n textDecoration: 'none',\n display: 'block', // Prevent unwanted spacing\n borderRadius,\n }}\n title={title || alt || 'Image'}\n />\n );\n\n return (\n <Row\n style={{\n marginTop: '0px',\n marginBottom: shouldRemoveBottomMargin ? '0px' : '32px',\n }}\n >\n <Column align={alignment}>\n {externalLink ? (\n <a\n href={externalLink}\n rel=\"noopener noreferrer\"\n style={{\n display: 'block',\n maxWidth: '100%',\n textDecoration: 'none',\n }}\n target=\"_blank\"\n >\n {mainImage}\n </a>\n ) : (\n mainImage\n )}\n </Column>\n </Row>\n );\n }\n\n private footer(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n const { textAlign = 'left' } = attrs || {};\n\n const { shouldRemoveBottomMargin } = this.getMarginOverrideConditions(\n node,\n options\n );\n\n return (\n <Text\n style={{\n fontSize: this.config.theme?.fontSize?.footer?.size,\n lineHeight: this.config.theme?.fontSize?.footer?.lineHeight,\n color: this.config.theme?.colors?.footer,\n marginTop: '0px',\n marginBottom: shouldRemoveBottomMargin ? '0px' : '20px',\n textAlign,\n ...antialiased,\n }}\n >\n {this.getMappedContent(node, {\n ...options,\n parent: node,\n })}\n </Text>\n );\n }\n\n private blockquote(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { isPrevSpacer, shouldRemoveBottomMargin } =\n this.getMarginOverrideConditions(node, options);\n\n return (\n <blockquote\n style={{\n borderLeftWidth: '4px',\n borderLeftStyle: 'solid',\n borderLeftColor: this.config.theme?.colors?.blockquoteBorder,\n paddingLeft: '16px',\n marginLeft: '0px',\n marginRight: '0px',\n marginTop: isPrevSpacer ? '0px' : '20px',\n marginBottom: shouldRemoveBottomMargin ? '0px' : '20px',\n }}\n >\n {this.getMappedContent(node, {\n ...options,\n parent: node,\n })}\n </blockquote>\n );\n }\n private code(_: MarkType, text: JSX.Element): JSX.Element {\n return (\n <code\n style={{\n backgroundColor: this.config.theme?.colors?.codeBackground,\n color: this.config.theme?.colors?.codeText,\n padding: '2px 4px',\n borderRadius: '6px',\n fontFamily: CODE_FONT_FAMILY,\n fontWeight: 400,\n letterSpacing: 0,\n }}\n >\n {text}\n </code>\n );\n }\n private linkCard(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n const { shouldRemoveBottomMargin } = this.getMarginOverrideConditions(\n node,\n options\n );\n\n const { title, description, link, linkTitle, image, badgeText, subTitle } =\n attrs || {};\n const href =\n this.linkValues.get(link) || this.variableValues.get(link) || link || '#';\n\n return (\n <a\n href={href}\n rel=\"noopener noreferrer\"\n style={{\n border: '1px solid #eaeaea',\n borderRadius: '10px',\n textDecoration: 'none',\n color: 'inherit',\n display: 'block',\n marginBottom: shouldRemoveBottomMargin ? '0px' : '20px',\n }}\n target=\"_blank\"\n >\n {image ? (\n <Row\n style={{\n marginBottom: '6px',\n }}\n >\n <Column\n style={{\n width: '100%',\n height: '100%',\n }}\n >\n <Img\n alt={title || 'Link Card'}\n src={image}\n style={{\n borderRadius: '10px 10px 0 0',\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n }}\n title={title || 'Link Card'}\n />\n </Column>\n </Row>\n ) : null}\n\n <Row\n style={{\n padding: '15px',\n marginTop: 0,\n marginBottom: 0,\n }}\n >\n <Column\n style={{\n verticalAlign: 'top',\n }}\n >\n <Row\n align={undefined}\n style={{\n marginBottom: '8px',\n marginTop: '0px',\n }}\n width=\"auto\"\n >\n <Column>\n <Text\n style={{\n fontSize: '18px',\n fontWeight: 600,\n color: this.config.theme?.colors?.linkCardTitle,\n margin: '0px',\n ...antialiased,\n }}\n >\n {title}\n </Text>\n </Column>\n {badgeText || subTitle ? (\n <Column\n style={{\n paddingLeft: '6px',\n verticalAlign: 'middle',\n }}\n >\n {badgeText ? (\n <span\n style={{\n fontWeight: 600,\n color: this.config.theme?.colors?.linkCardBadgeText,\n padding: '4px 8px',\n borderRadius: '8px',\n backgroundColor:\n this.config.theme?.colors?.linkCardBadgeBackground,\n fontSize: '12px',\n lineHeight: '12px',\n }}\n >\n {badgeText}\n </span>\n ) : null}{' '}\n {subTitle && !badgeText ? (\n <span\n style={{\n fontWeight: 'normal',\n color: this.config.theme?.colors?.linkCardSubTitle,\n fontSize: '12px',\n lineHeight: '12px',\n }}\n >\n {subTitle}\n </span>\n ) : null}\n </Column>\n ) : null}\n </Row>\n <Text\n style={{\n fontSize: '16px',\n color: this.config.theme?.colors?.linkCardDescription,\n marginTop: '0px',\n marginBottom: '0px',\n ...antialiased,\n }}\n >\n {description}{' '}\n {linkTitle ? (\n <a\n href={href}\n rel=\"noopener noreferrer\"\n style={{\n color: this.config.theme?.colors?.linkCardTitle,\n fontSize: '14px',\n fontWeight: 600,\n textDecoration: 'underline',\n }}\n >\n {linkTitle}\n </a>\n ) : null}\n </Text>\n </Column>\n </Row>\n </a>\n );\n }\n\n private section(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n const {\n borderRadius = 0,\n backgroundColor = DEFAULT_SECTION_BACKGROUND_COLOR,\n align = DEFAULT_SECTION_ALIGN,\n borderWidth = DEFAULT_SECTION_BORDER_WIDTH,\n borderColor = DEFAULT_SECTION_BORDER_COLOR,\n\n marginTop = DEFAULT_SECTION_MARGIN_TOP,\n marginRight = DEFAULT_SECTION_MARGIN_RIGHT,\n marginBottom = DEFAULT_SECTION_MARGIN_BOTTOM,\n marginLeft = DEFAULT_SECTION_MARGIN_LEFT,\n\n paddingTop = DEFAULT_SECTION_PADDING_TOP,\n paddingRight = DEFAULT_SECTION_PADDING_RIGHT,\n paddingBottom = DEFAULT_SECTION_PADDING_BOTTOM,\n paddingLeft = DEFAULT_SECTION_PADDING_LEFT,\n } = attrs || {};\n\n const shouldShow = this.shouldShow(node, options);\n if (!shouldShow) {\n return <></>;\n }\n\n return (\n <Row\n style={{\n marginTop,\n marginRight,\n marginBottom,\n marginLeft,\n }}\n >\n <Column\n align={align}\n style={{\n borderColor,\n borderWidth,\n borderStyle: 'solid',\n backgroundColor,\n borderRadius,\n\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n }}\n >\n {this.getMappedContent(node, {\n ...options,\n parent: node,\n })}\n </Column>\n </Row>\n );\n }\n\n private columns(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n\n const shouldShow = this.shouldShow(node, options);\n if (!shouldShow) {\n return <></>;\n }\n\n const [newNode, totalWidth] = this.adjustColumnsContent(node);\n\n return (\n <Row\n width={`${totalWidth}%`}\n style={{\n margin: 0,\n padding: 0,\n width: `${totalWidth}%`,\n }}\n className=\"tab-row-full\"\n >\n {this.getMappedContent(newNode, {\n ...options,\n parent: newNode,\n })}\n </Row>\n );\n }\n\n private adjustColumnsContent(node: JSONContent): [JSONContent, number] {\n const { content = [] } = node;\n const totalWidth = 100;\n const columnsWithWidth = content.filter(\n (c) => c.type === 'column' && Boolean(Number(c.attrs?.width || 0))\n );\n const autoWidthColumns = content.filter(\n (c) =>\n c.type === 'column' && (c.attrs?.width === 'auto' || !c.attrs?.width)\n );\n\n const totalWidthUsed = columnsWithWidth.reduce(\n (acc, c) => acc + Number(c.attrs?.width),\n 0\n );\n\n const remainingWidth = totalWidth - totalWidthUsed;\n const measuredWidth = Math.round(remainingWidth / autoWidthColumns.length);\n\n const columnCount = content.filter((c) => c.type === 'column').length;\n const gap = node.attrs?.gap ?? DEFAULT_COLUMNS_GAP;\n\n return [\n {\n ...node,\n content: content.map((c, index) => {\n const isAutoWidthColumn =\n c.type === 'column' &&\n (c.attrs?.width === 'auto' || !c.attrs?.width);\n const isFirstColumn = index === 0;\n const isMiddleColumn = index > 0 && index < columnCount - 1;\n const isLastColumn = index === content.length - 1;\n\n let paddingLeft = 0;\n let paddingRight = 0;\n\n // For 2 columns, apply a simple gap logic\n if (columnCount < 3) {\n paddingLeft = isFirstColumn ? 0 : gap / 2;\n paddingRight = isLastColumn ? 0 : gap / 2;\n } else {\n // For more than 2 columns, apply more gap in the first and last columns\n // and less gap in the middle columns to make it look more balanced\n // because the first and last columns have more space to fill\n const leftAndRightPadding = (gap / 2) * 1.5;\n const middleColumnPadding = leftAndRightPadding / 2;\n\n paddingLeft = isFirstColumn\n ? 0\n : isMiddleColumn\n ? middleColumnPadding\n : leftAndRightPadding;\n paddingRight = isLastColumn\n ? 0\n : isMiddleColumn\n ? middleColumnPadding\n : leftAndRightPadding;\n }\n\n paddingLeft = Math.round(paddingLeft * 100) / 100;\n paddingRight = Math.round(paddingRight * 100) / 100;\n\n return {\n ...c,\n attrs: {\n ...c.attrs,\n width: isAutoWidthColumn ? measuredWidth : c.attrs?.width,\n\n isFirstColumn,\n isLastColumn,\n index,\n\n paddingLeft,\n paddingRight,\n },\n };\n }),\n },\n autoWidthColumns.length === 0\n ? Math.min(totalWidth, totalWidthUsed)\n : totalWidth,\n ];\n }\n\n private column(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n const {\n width,\n verticalAlign = 'top',\n paddingLeft = 0,\n paddingRight = 0,\n } = attrs || {};\n\n return (\n <Column\n width={`${Number(width)}%`}\n style={{\n width: `${Number(width)}%`,\n margin: 0,\n verticalAlign,\n }}\n className=\"tab-col-full\"\n >\n <Section\n style={{\n margin: 0,\n paddingLeft,\n paddingRight,\n }}\n className=\"tab-pad\"\n >\n {this.getMappedContent(node, {\n ...options,\n parent: node,\n })}\n </Section>\n </Column>\n );\n }\n\n private repeat(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n const { each = '' } = attrs || {};\n\n const shouldShow = this.shouldShow(node, options);\n if (!shouldShow) {\n return <></>;\n }\n\n let { payloadValue } = options || {};\n payloadValue = typeof payloadValue === 'object' ? payloadValue : {};\n\n const values = this.payloadValues.get(each) ?? payloadValue[each] ?? [];\n if (!Array.isArray(values)) {\n throw new Error(`Payload value for each \"${each}\" is not an array`);\n }\n\n return (\n <>\n {values.map((value) => {\n return (\n <Fragment key={generateKey()}>\n {this.getMappedContent(node, {\n ...options,\n parent: node,\n payloadValue: value,\n })}\n </Fragment>\n );\n })}\n </>\n );\n }\n\n /**\n * @deprecated\n * This for node is an alias for the repeat node\n * we will remove this in the future\n * @param node\n * @param options\n * @returns JSX.Element\n */\n private for(node: JSONContent, options?: NodeOptions): JSX.Element {\n return this.repeat(node, options);\n }\n\n private shouldShow(node: JSONContent, options?: NodeOptions): boolean {\n const showIfKey = node?.attrs?.showIfKey ?? '';\n if (!showIfKey) {\n return true;\n }\n\n let { payloadValue } = options || {};\n payloadValue = typeof payloadValue === 'object' ? payloadValue : {};\n return !!(this.payloadValues.get(showIfKey) ?? payloadValue[showIfKey]);\n }\n\n htmlCodeBlock(node: JSONContent, options?: NodeOptions): JSX.Element {\n const show = this.shouldShow(node, options);\n if (!show) {\n return <></>;\n }\n\n // the text can be a proper html code block\n // or only the body of the html\n // so we need to wrap it in a proper html tag\n const text =\n node.content?.reduce((acc, n) => {\n if (n?.type === 'text') {\n return acc + n?.text;\n } else if (n?.type === 'variable') {\n const value = this.getVariableValue(\n n?.attrs?.id,\n n?.attrs?.fallback,\n options\n );\n return acc + value;\n }\n\n return acc;\n }, '') || '';\n\n // we will inline the css in the html\n // so that it can be rendered properly\n const inlineCssHtml = juice(text);\n const doc = parse(inlineCssHtml);\n const head = doc?.querySelector('head');\n head?.remove();\n const html = doc.toString();\n\n return (\n <table\n align=\"left\"\n width=\"100%\"\n border={0}\n cellPadding=\"0\"\n cellSpacing=\"0\"\n role=\"presentation\"\n >\n <tbody>\n <tr style={{ width: '100%' }}>\n <td\n style={{ width: '100%' }}\n dangerouslySetInnerHTML={{\n __html: html,\n }}\n />\n </tr>\n </tbody>\n </table>\n );\n }\n\n private inlineImage(node: JSONContent, options?: NodeOptions): JSX.Element {\n const { attrs } = node;\n let {\n src,\n isSrcVariable,\n alt = '',\n title = '',\n height = DEFAULT_INLINE_IMAGE_HEIGHT,\n width = DEFAULT_INLINE_IMAGE_WIDTH,\n externalLink = '',\n isExternalLinkVariable,\n } = attrs || {};\n\n src = isSrcVariable ? this.variableUrlValue(src, options) : src;\n externalLink = isExternalLinkVariable\n ? this.variableUrlValue(externalLink, options)\n : externalLink;\n\n const image = (\n <img\n src={src}\n alt={alt}\n title={title}\n width={width}\n height={height}\n style={{\n display: 'inline',\n verticalAlign: 'middle',\n width: `${width}px`,\n height: `${height}px`,\n outline: 'none',\n border: 'none',\n textDecoration: 'none',\n }}\n />\n );\n\n if (!externalLink) {\n return image;\n }\n\n return (\n <a\n href={externalLink}\n rel=\"noopener noreferrer\"\n style={{\n display: 'inline',\n textDecoration: 'none',\n }}\n target=\"_blank\"\n >\n {image}\n </a>\n );\n }\n}\n","import type { JSONContent } from '@tiptap/core';\nimport { Maily } from './maily';\nimport type { MailyConfig, RenderOptions } from './maily';\n\nexport async function render(\n content: JSONContent,\n config?: MailyConfig & RenderOptions\n): Promise<string> {\n const { theme, preview, ...rest } = config || {};\n\n const maily = new Maily(content);\n maily.setPreviewText(preview);\n maily.setTheme(theme || {});\n\n return maily.render(rest);\n}\n"],"x_google_ignoreList":[0],"mappings":"0ZAoLA,MA9DM,EAAW,AAAC,GAAM,OAAO,UAAU,SAAS,KAAK,EAAE,CA8DnD,EAAW,AAAC,GAAQ,EAAS,EAAI,GAAK,kBA6E5C,SAAS,EAAW,EAAK,CACvB,MAAO,QAAO,KAAK,EAAI,AACxB,CAID,SAAS,EAAU,EAAQ,GAAG,EAAS,CACrC,IAAK,EAAQ,OACX,OAAO,EACT,IAAM,EAAS,EAAQ,OAAO,CAoB9B,OAnBI,QAAgB,GACX,GACL,EAAiB,EAAO,EAAI,EAAiB,EAAO,EACtD,EAAW,EAAO,CAAC,QAAQ,AAAC,GAAQ,CAC9B,IAAQ,aAAe,IAAQ,eAAiB,IAAQ,cAExD,EAAiB,EAAO,GAAK,EAC1B,EAAO,KACV,EAAO,GAAO,CAAE,GACd,EAAiB,EAAO,GAAK,CAC/B,EAAU,EAAO,GAAM,EAAO,GAAK,CAEnC,EAAO,GAAO,EAAO,IAGvB,EAAO,GAAO,EAAO,GAEx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E3B,MACE,GAAC,QAAA,CACC,MAAM,OACN,MAAM,OACN,OAAQ,EACR,YAAY,IACZ,YAAY,IACZ,KAAK,wBAEL,EAAC,QAAA,CAAA,SACC,EAAC,KAAA,CAAG,MAAO,CAAE,MAAO,MAAQ,WAC1B,EAAC,KAAA,CACC,MAAO,CAAE,MAAO,MAAQ,EACxB,wBAAyB,CACvB,OAAQ,CACT,GACD,EACC,EACC,EACF,AAEX,CAED,YAAoBL,EAAmBK,EAAoC,CAEzE,GADM,CAAE,QAAO,CAAG,EACd,CACF,MACA,gBACA,MAAM,GACN,QAAQ,GACR,SAAS,EACT,QAAQ,EACR,eAAe,GACf,yBACD,CAAG,GAAS,CAAE,EAGf,AADA,EAAM,EAAgB,KAAK,iBAAiB,EAAK,EAAQ,CAAG,EAC5D,EAAe,EACX,KAAK,iBAAiB,EAAc,EAAQ,CAC5C,EAEJ,IAAM,EACJ,EAAC,MAAA,CACM,MACA,MACE,QACA,QACC,SACR,MAAO,CACL,QAAS,SACT,cAAe,SACf,OAAQ,EAAE,EAAM,IAChB,QAAS,EAAE,EAAO,IAClB,QAAS,OACT,OAAQ,OACR,eAAgB,MACjB,GACD,CAOJ,OAJK,EAKH,EAAC,IAAA,CACC,KAAM,EACN,IAAI,sBACJ,MAAO,CACL,QAAS,SACT,eAAgB,MACjB,EACD,OAAO,kBAEN,GACC,CAdG,CAgBV,CACF,ECxxDD,eAAsB,GACpBS,EACAC,EACiB,CAGjB,GAFM,CAAE,QAAO,UAAS,GAAG,EAAM,CAAG,GAAU,CAAE,EAE1C,EAAQ,IAAI,GAAM,GAIxB,MAHA,GAAM,eAAe,EAAQ,CAC7B,EAAM,SAAS,GAAS,CAAE,EAAC,CAEpB,EAAM,OAAO,EAAK,AAC1B"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["EmailButton","EmailColumn","EmailColumn","preview","renderPreview","renderMeta","meta","render","reactEmailRender"],"sources":["../src/lib/font-face.ts","../src/lib/spacing.ts","../src/nodes/blockquote.tsx","../src/nodes/bullet-list.tsx","../src/lib/resolve-variable.ts","../src/lib/visibility.ts","../src/nodes/button.tsx","../src/nodes/column.tsx","../src/lib/columns.ts","../src/nodes/columns.tsx","../src/lib/meta.tsx","../src/lib/preview.ts","../src/lib/sizing.ts","../src/nodes/document.tsx","../src/lib/styles.ts","../src/nodes/footer.tsx","../src/nodes/hard-break.tsx","../src/nodes/heading.tsx","../src/nodes/horizontal-rule.tsx","../src/nodes/html-code-block.tsx","../src/nodes/image.tsx","../src/nodes/inline-image.tsx","../src/nodes/link-card.tsx","../src/nodes/list-item.tsx","../src/nodes/ordered-list.tsx","../src/nodes/paragraph.tsx","../src/nodes/repeat.tsx","../src/nodes/section.tsx","../src/nodes/spacer.tsx","../src/marks/bold.tsx","../src/marks/code.tsx","../src/marks/italic.tsx","../src/marks/link.tsx","../src/marks/strike.tsx","../src/marks/underline.tsx","../src/mark.tsx","../src/nodes/text.tsx","../src/nodes/variable.tsx","../src/node.tsx","../src/context.ts","../src/lib/link.ts","../src/config.ts","../src/render.tsx"],"sourcesContent":["import { DEFAULT_FONT } from '@maily-to/shared';\nimport type {\n FontProps,\n FontStyleAttributes,\n NodeFontStyleDefaults,\n} from '@maily-to/shared';\n\nimport type { RenderContext } from '../context';\n\n/**\n * Registers a font face in the context's shared font collector.\n * Deduplicates by family+style+weight+fallback so each variant\n * only appears once in the final `<style>` block.\n */\nexport function registerFontFace(ctx: RenderContext, font: FontProps): void {\n const {\n fontFamily,\n fontWeight = 400,\n fallbackFontFamily,\n fontStyle = 'normal',\n } = font;\n\n if (!fontFamily) {\n return;\n }\n\n const key = `${fontFamily}:${fontStyle}:${fontWeight}:${fallbackFontFamily}`;\n if (ctx.fonts.has(key)) {\n return;\n }\n\n ctx.font(key, font);\n}\n\n/**\n * Resolves a complete FontProps from a node's font style attributes\n * (falling back to the theme font and CDN entries) and registers it.\n * Called by node renderers that support per-node font overrides.\n */\nexport function prepareAndRegisterFontFaceFromAttrs(\n ctx: RenderContext,\n attrs: FontStyleAttributes,\n defaults?: Partial<NodeFontStyleDefaults>\n) {\n const primaryFont = ctx.config.theme.font ?? DEFAULT_FONT;\n if (!primaryFont) {\n return;\n }\n\n const { fontFamily, fontWeight, fontFallback, fontStyle } = attrs;\n const family = fontFamily ?? primaryFont.fontFamily;\n if (!family) {\n return;\n }\n\n const weight = fontWeight ?? defaults?.fontWeight ?? 400;\n const style = fontStyle ?? defaults?.fontStyle ?? 'normal';\n const fallback = fontFallback ?? primaryFont.fallbackFontFamily;\n\n const webFont = fontFamily\n ? ctx.config.fontFamilies.find((f) => f.fontFamily === fontFamily)?.webFont\n : primaryFont.webFont;\n\n registerFontFace(ctx, {\n fontFamily: family,\n fontWeight: weight,\n fallbackFontFamily: fallback,\n fontStyle: style,\n ...(webFont && { webFont }),\n });\n}\n","import { is, MAILY_NODE_TYPES } from '@maily-to/shared';\nimport type { MailyNodeType } from '@maily-to/shared';\n\nimport type { RenderContext } from '../context';\n\nconst BLOCK_CONTAINERS = new Set<MailyNodeType>([\n MAILY_NODE_TYPES.DOCUMENT,\n MAILY_NODE_TYPES.SECTION,\n MAILY_NODE_TYPES.COLUMN,\n MAILY_NODE_TYPES.REPEAT,\n]);\n\n/**\n * Returns true if this node's top margin should be collapsed — i.e. it's\n * the first child of a block container or follows a spacer node.\n */\nexport function shouldSuppressMarginTop(ctx: RenderContext): boolean {\n const { parent, siblingIndex } = ctx;\n\n if (!parent || !is.node(parent) || !is.parent(parent)) {\n return true;\n }\n\n if (!BLOCK_CONTAINERS.has(parent.type)) {\n return true;\n }\n\n const prev = parent.content[siblingIndex - 1];\n\n const isFirst = siblingIndex === 0;\n const isPrevSpacer = prev?.type === MAILY_NODE_TYPES.SPACER;\n\n return isFirst || isPrevSpacer;\n}\n\n/**\n * Returns true if this node's bottom margin should be collapsed — i.e. it's\n * the last child of a block container, or is followed by a spacer or hr.\n */\nexport function shouldSuppressMarginBottom(ctx: RenderContext): boolean {\n const { parent, siblingIndex } = ctx;\n\n if (!parent || !is.node(parent) || !is.parent(parent)) {\n return true;\n }\n\n if (parent.type === MAILY_NODE_TYPES.LIST_ITEM) {\n return true;\n }\n\n if (!BLOCK_CONTAINERS.has(parent.type)) {\n return true;\n }\n\n const content = parent.content;\n const next = content[siblingIndex + 1];\n\n const isLast = siblingIndex === content.length - 1;\n const isNextSpacer = next?.type === MAILY_NODE_TYPES.SPACER;\n const isNextHr = next?.type === MAILY_NODE_TYPES.HORIZONTAL_RULE;\n\n return isLast || isNextSpacer || isNextHr;\n}\n","import { getCssDirection, getFontStyle, is } from '@maily-to/shared';\n\nimport { prepareAndRegisterFontFaceFromAttrs } from '../lib/font-face';\nimport {\n shouldSuppressMarginBottom,\n shouldSuppressMarginTop,\n} from '../lib/spacing';\nimport type { NodeRenderer } from '../node';\n\nexport const blockquote: NodeRenderer = (node, ctx) => {\n if (!is.blockquote(node)) {\n return null;\n }\n\n const { dir } = node.attrs;\n const theme = ctx.config.theme;\n const fontStyle = getFontStyle(node.attrs, theme.blockquote);\n\n prepareAndRegisterFontFaceFromAttrs(ctx, node.attrs, theme.blockquote);\n\n return (\n <blockquote\n style={{\n borderLeftWidth: '4px',\n borderLeftStyle: 'solid',\n borderLeftColor: theme.blockquote?.borderColor,\n paddingLeft: '16px',\n marginLeft: '0px',\n marginRight: '0px',\n marginTop: shouldSuppressMarginTop(ctx) ? 0 : 20,\n marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 20,\n color: theme.blockquote?.color,\n ...getCssDirection(dir),\n ...fontStyle,\n }}\n >\n {ctx.children(node)}\n </blockquote>\n );\n};\n","import { getCssDirection, is } from '@maily-to/shared';\nimport { Container } from '@react-email/components';\n\nimport { shouldSuppressMarginBottom } from '../lib/spacing';\nimport type { NodeRenderer } from '../node';\n\nexport const bulletList: NodeRenderer = (node, ctx) => {\n if (!is.bulletList(node)) {\n return null;\n }\n\n const { dir } = node.attrs;\n\n return (\n <Container\n style={{ marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 20 }}\n >\n <ul\n style={{\n paddingLeft: 26,\n listStyleType: 'disc',\n margin: 0,\n ...getCssDirection(dir),\n }}\n >\n {ctx.children(node)}\n </ul>\n </Container>\n );\n};\n","import {\n buildDocFromVariableText,\n hasVariableInText,\n MAILY_NODE_TYPES,\n} from '@maily-to/shared';\n\nimport type { RenderContext } from '../context';\n\n/**\n * Resolves a single variable ID using the 3-stage lookup:\n * 1. item (current repeat iteration)\n * 2. variableValues map\n * 3. variableFormatter (fallback)\n */\nexport function resolveVariableId(\n id: string,\n fallback: string | null | undefined,\n ctx: RenderContext\n): string {\n const { config } = ctx;\n const item = ctx.get('item');\n\n if (item && id in item) {\n return String(item[id]);\n }\n\n const varValue = config.variableValues.get(id);\n if (varValue !== undefined) {\n if (typeof varValue === 'object') {\n return JSON.stringify(varValue);\n }\n return String(varValue);\n }\n\n return config.variableFormatter({\n variable: id,\n fallback: fallback ?? undefined,\n });\n}\n\n/**\n * Resolves a text string that may contain `{{variable}}` placeholders.\n * Returns the original string unchanged if no placeholders are present.\n */\nexport function resolveVariableText(text: string, ctx: RenderContext): string {\n if (!hasVariableInText(text)) {\n return text;\n }\n\n const doc = buildDocFromVariableText(text);\n const paragraph = doc.content.find(\n (node) => node.type === MAILY_NODE_TYPES.PARAGRAPH\n );\n if (!paragraph) {\n return text;\n }\n\n return paragraph.content\n .map((node) => {\n if (node.type === MAILY_NODE_TYPES.TEXT) {\n return node.text;\n }\n\n if (node.type === MAILY_NODE_TYPES.VARIABLE) {\n const { id, fallback } = node.attrs;\n if (!id) {\n return '';\n }\n\n return resolveVariableId(id, fallback, ctx);\n }\n\n return '';\n })\n .join('');\n}\n","import type { AllowedVisibilityOperator, AnyMailyNode } from '@maily-to/shared';\nimport { VISIBILITY_ACTIONS, VISIBILITY_OPERATORS } from '@maily-to/shared';\n\nimport type { RenderContext } from '../context';\n\n/**\n * Evaluates a node's visibility rule against the current variables.\n * Returns true (visible) when there's no rule, or when the rule\n * matches for \"show\" / doesn't match for \"hide\".\n */\nexport function shouldShow(node: AnyMailyNode, ctx: RenderContext): boolean {\n const rule = node.attrs?.visibilityRule;\n if (!rule || rule.action === VISIBILITY_ACTIONS.NONE) {\n return true;\n }\n\n const { action, variable, operator, value } = rule;\n const item = ctx.get('item');\n\n let resolvedValue: unknown;\n if (item && variable in item) {\n resolvedValue = item[variable];\n } else {\n resolvedValue = ctx.config.variableValues.get(variable);\n }\n\n const matched = evaluate(operator, resolvedValue, value);\n\n if (action === VISIBILITY_ACTIONS.SHOW) {\n return matched;\n }\n if (action === VISIBILITY_ACTIONS.HIDE) {\n return !matched;\n }\n\n return true;\n}\n\nfunction evaluate(\n operator: AllowedVisibilityOperator,\n resolvedValue: unknown,\n compareValue: string\n): boolean {\n switch (operator) {\n case VISIBILITY_OPERATORS.IS_TRUE:\n return Boolean(resolvedValue);\n case VISIBILITY_OPERATORS.IS_FALSE:\n return !resolvedValue;\n case VISIBILITY_OPERATORS.EQUALS:\n return String(resolvedValue) === compareValue;\n case VISIBILITY_OPERATORS.NOT_EQUALS:\n return String(resolvedValue) !== compareValue;\n case VISIBILITY_OPERATORS.CONTAINS:\n return String(resolvedValue).includes(compareValue);\n case VISIBILITY_OPERATORS.NOT_CONTAINS:\n return !String(resolvedValue).includes(compareValue);\n case VISIBILITY_OPERATORS.STARTS_WITH:\n return String(resolvedValue).startsWith(compareValue);\n case VISIBILITY_OPERATORS.ENDS_WITH:\n return String(resolvedValue).endsWith(compareValue);\n case VISIBILITY_OPERATORS.GREATER_THAN:\n return Number(resolvedValue) > Number(compareValue);\n case VISIBILITY_OPERATORS.LESS_THAN:\n return Number(resolvedValue) < Number(compareValue);\n default:\n return false;\n }\n}\n","import {\n BUTTON_KINDS,\n getBorderStyle,\n getCssDirection,\n getFontStyle,\n is,\n TEXT_ALIGNMENTS,\n} from '@maily-to/shared';\nimport { Button as EmailButton, Container } from '@react-email/components';\nimport type { CSSProperties } from 'react';\n\nimport { prepareAndRegisterFontFaceFromAttrs } from '../lib/font-face';\nimport { resolveVariableText } from '../lib/resolve-variable';\nimport { shouldSuppressMarginBottom } from '../lib/spacing';\nimport { shouldShow } from '../lib/visibility';\nimport type { NodeRenderer } from '../node';\n\nexport const button: NodeRenderer = (node, ctx) => {\n if (!is.button(node)) {\n return null;\n }\n\n if (!shouldShow(node, ctx)) {\n return null;\n }\n\n const attrs = node.attrs;\n const { dir } = attrs;\n const theme = ctx.config.theme;\n\n const backgroundColor =\n attrs.backgroundColor ?? theme.button?.backgroundColor;\n const color = attrs.color ?? theme.button?.color;\n const url = resolveVariableText(attrs.url ?? '', ctx);\n const kind = attrs.kind ?? BUTTON_KINDS.TIGHT;\n const alignment = attrs.alignment ?? TEXT_ALIGNMENTS.CENTER;\n const isFullWidth = kind === BUTTON_KINDS.FULL_WIDTH;\n\n const paddingTop = attrs.paddingTop ?? theme.button?.paddingTop ?? 10;\n const paddingRight = attrs.paddingRight ?? theme.button?.paddingRight ?? 32;\n const paddingBottom =\n attrs.paddingBottom ?? theme.button?.paddingBottom ?? 10;\n const paddingLeft = attrs.paddingLeft ?? theme.button?.paddingLeft ?? 32;\n\n const borderStyle = getBorderStyle(attrs);\n\n const fontStyle = getFontStyle(attrs, theme.button);\n prepareAndRegisterFontFaceFromAttrs(ctx, attrs, theme.button);\n\n const containerStyle: CSSProperties = {\n textAlign: alignment,\n marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 20,\n };\n\n if (isFullWidth) {\n return (\n <Container style={containerStyle}>\n <table\n width=\"100%\"\n cellPadding=\"0\"\n cellSpacing=\"0\"\n border={0}\n role=\"presentation\"\n >\n <tbody>\n <tr>\n <td\n align={alignment}\n style={{\n backgroundColor,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n ...borderStyle,\n ...getCssDirection(dir),\n }}\n >\n <a\n href={url}\n target=\"_blank\"\n style={{\n color,\n textDecoration: 'none',\n display: 'block',\n textAlign: alignment,\n ...fontStyle,\n }}\n >\n {ctx.children(node)}\n </a>\n </td>\n </tr>\n </tbody>\n </table>\n </Container>\n );\n }\n\n return (\n <Container style={containerStyle}>\n <EmailButton\n href={url}\n style={{\n backgroundColor,\n color,\n paddingTop,\n paddingRight,\n paddingBottom,\n paddingLeft,\n display: 'inline-block',\n ...borderStyle,\n ...getCssDirection(dir),\n ...fontStyle,\n }}\n >\n {ctx.children(node)}\n </EmailButton>\n </Container>\n );\n};\n","import { is } from '@maily-to/shared';\nimport { Column as EmailColumn } from '@react-email/components';\n\nimport type { NodeRenderer } from '../node';\n\nexport const column: NodeRenderer = (node, ctx) => {\n if (!is.column(node)) {\n return null;\n }\n\n const attrs = node.attrs;\n const width =\n ctx.get('columnTdWidth') ??\n (attrs.width === null ? undefined : `${attrs.width}%`);\n\n return (\n <EmailColumn\n width={width}\n className=\"tab-col-full\"\n style={{\n margin: 0,\n width,\n verticalAlign: attrs.verticalAlign,\n }}\n >\n {ctx.children(node)}\n </EmailColumn>\n );\n};\n","import { roundTo } from '@maily-to/shared';\nimport type { ColumnNode } from '@maily-to/shared';\n\ntype ColumnLayout = {\n node: ColumnNode;\n containerPercent: number;\n tdWidthPercent: number;\n};\n\ntype ColumnLayoutResult = {\n columns: ColumnLayout[];\n rowWidthPercent: number;\n gapTdWidthPercent: number;\n};\n\n/**\n * Simulates CSS `flexbox gap` using table-cell percentages.\n *\n * Since tables don't support `gap`, we create empty spacer `<td>` cells\n * between columns. This function calculates how wide each column and\n * spacer should be so the layout behaves similar to flexbox.\n *\n * How the gap affects the layout depends on the column configuration:\n *\n * 1. When there are auto-width columns\n * The row always fills 100% of the container.\n * Fixed columns keep their exact width, and auto columns divide\n * the remaining space after subtracting fixed widths and gaps.\n *\n * Example:\n * fixed 40% + auto column, gap 8px in a 600px container\n * → auto column becomes ~58.667%\n *\n * 2. When all columns have fixed widths and still fit\n * The row width becomes `fixed widths + gaps`, which may be\n * smaller than 100%. Columns keep their exact size.\n *\n * Example:\n * 20% + 20% columns, gap 8px in a 600px container\n * → row width becomes ~41.333%\n *\n * 3. When all columns are fixed but overflow\n * If `fixed widths + gaps` exceed 100%, everything is scaled\n * down proportionally so the row never exceeds the container.\n *\n * Example:\n * 50% + 50% columns with gap 8px\n * → both columns shrink to ~49.342%\n */\nexport function calculateColumnLayout(\n columnNodes: ColumnNode[],\n gap: number,\n containerBox: number\n): ColumnLayoutResult {\n const count = columnNodes.length;\n if (count === 0) {\n return { columns: [], rowWidthPercent: 0, gapTdWidthPercent: 0 };\n }\n\n // Step 1: Convert the gap from pixels into a percentage of the container\n const gapCount = count - 1;\n const gapPercent =\n gapCount > 0 && containerBox > 0\n ? roundTo((gap / containerBox) * 100, 3)\n : 0;\n const totalGapPercent = roundTo(gapCount * gapPercent, 3);\n\n // Step 2: Separate fixed-width and auto-width columns\n // Fixed columns keep their defined width.\n // Auto columns divide the remaining available space.\n const fixedSum = columnNodes.reduce(\n (sum, col) => sum + (col.attrs.width ?? 0),\n 0\n );\n const autoCount = columnNodes.filter(\n (col) => col.attrs.width === null\n ).length;\n\n const autoEach =\n autoCount > 0\n ? roundTo(Math.max(0, 100 - fixedSum - totalGapPercent) / autoCount, 3)\n : 0;\n let containerPercents = columnNodes.map((col) => col.attrs.width ?? autoEach);\n\n // Step 3: Calculate the row width\n //\n // If there are auto columns, the row fills the full container (100%).\n // If all columns are fixed, the row width is simply fixedSum + gaps.\n let rowWidthPercent =\n autoCount > 0 ? 100 : roundTo(fixedSum + totalGapPercent, 3);\n let effectiveGapPercent = gapPercent;\n\n // Step 4: Handle overflow when all columns are fixed\n //\n // If fixed widths + gaps exceed 100%, scale everything down\n // proportionally so the row still fits inside the container.\n if (autoCount === 0 && rowWidthPercent > 100) {\n const scale = 100 / rowWidthPercent;\n containerPercents = containerPercents.map((p) => roundTo(p * scale, 3));\n effectiveGapPercent = roundTo(gapPercent * scale, 3);\n rowWidthPercent = 100;\n }\n\n // Step 5: Convert container-relative percentages to row-relative ones\n //\n // Table `<td>` width values are relative to the row `<table>`,\n // not the container. If the row is smaller than 100%, the\n // percentages need to be adjusted accordingly.\n const gapTdWidthPercent =\n rowWidthPercent > 0\n ? roundTo((effectiveGapPercent / rowWidthPercent) * 100, 3)\n : 0;\n\n const columns: ColumnLayout[] = columnNodes.map((col, i) => {\n const containerPercent = containerPercents[i];\n const tdWidthPercent =\n rowWidthPercent > 0\n ? roundTo((containerPercent / rowWidthPercent) * 100, 3)\n : 0;\n\n return {\n node: {\n ...col,\n attrs: { ...col.attrs, width: col.attrs.width ?? containerPercent },\n },\n containerPercent,\n tdWidthPercent,\n };\n });\n\n return { columns, rowWidthPercent, gapTdWidthPercent };\n}\n","import { absoluteFromPercentage, is, TEXT_ALIGNMENTS } from '@maily-to/shared';\nimport { Column as EmailColumn, Row, Section } from '@react-email/components';\nimport { cloneElement, isValidElement } from 'react';\n\nimport { calculateColumnLayout } from '../lib/columns';\nimport type { NodeRenderer } from '../node';\n\nexport const COLUMNS_RESPONSIVE_CSS = /* css */ `@media only screen and (max-width:425px){.tab-row-full{width:100%!important}.tab-col-full{display:block!important;width:100%!important}.tab-gap{display:none!important}}`;\n\nexport const columns: NodeRenderer = (node, ctx) => {\n if (!is.columns(node)) {\n return null;\n }\n\n ctx.style(COLUMNS_RESPONSIVE_CSS);\n\n const { gap = 0 } = node.attrs;\n const nodes = node.content.filter(is.column);\n const { columns, rowWidthPercent, gapTdWidthPercent } = calculateColumnLayout(\n nodes,\n gap,\n ctx.box\n );\n\n if (columns.length === 0) {\n return null;\n }\n\n const width = `${rowWidthPercent}%`;\n\n return (\n <Section>\n <Row\n className=\"tab-row-full\"\n width={width}\n style={{ width }}\n align={TEXT_ALIGNMENTS.LEFT}\n >\n {columns.flatMap((item, index) => {\n const widthInPixels = absoluteFromPercentage(\n item.containerPercent,\n ctx.box\n );\n\n const childCtx = ctx.child({\n parent: node,\n siblingIndex: index,\n size: {\n totalWidth: widthInPixels,\n totalBorder: 0,\n totalPadding: 0,\n },\n });\n\n const tdWidth = `${item.tdWidthPercent}%`;\n childCtx.set('columnTdWidth', tdWidth);\n const el = childCtx.render(item.node);\n\n const colEl = isValidElement(el)\n ? cloneElement(el, { key: item.node.attrs.id })\n : null;\n\n const isNotLastColumn = index < columns.length - 1;\n const hasGap = gap > 0;\n const shouldRenderGap = isNotLastColumn && hasGap;\n if (shouldRenderGap) {\n const gapWidth = `${gapTdWidthPercent}%`;\n const gapKey = `gap-${item.node.attrs.id}`;\n\n return [\n colEl,\n <EmailColumn\n key={gapKey}\n className=\"tab-gap\"\n width={gapWidth}\n style={{ width: gapWidth }}\n />,\n ];\n }\n\n return [colEl];\n })}\n </Row>\n </Section>\n );\n};\n","/**\n * Descriptor for a single meta element to inject into the `<head>`.\n * Supports the same shapes as Remix/React-Router's MetaDescriptor:\n * charSet, title, name/content, property/content, httpEquiv/content,\n * tagName ('meta' | 'link'), and a catch-all for arbitrary attrs.\n */\nexport type MetaDescriptor =\n | { charSet: 'utf-8' }\n | { title: string }\n | { name: string; content: string }\n | { property: string; content: string }\n | { httpEquiv: string; content: string }\n | { tagName: 'meta' | 'link'; [attr: string]: string }\n | { [name: string]: string };\n\n/**\n * Deduplication key for a meta descriptor. Uses a sorted-key JSON hash\n * so `{ name: 'a', content: 'b' }` and `{ content: 'b', name: 'a' }`\n * produce the same key.\n */\nfunction hash(descriptor: MetaDescriptor): string {\n const sorted = Object.keys(descriptor)\n .sort()\n .reduce<Record<string, string>>((acc, key) => {\n acc[key] = (descriptor as Record<string, string>)[key];\n return acc;\n }, {});\n\n return JSON.stringify(sorted);\n}\n\n/**\n * Converts MetaDescriptor objects into React elements for the `<head>`.\n * Duplicates (by sorted-key JSON hash) are skipped.\n */\nexport function meta(descriptors: MetaDescriptor[]): React.ReactNode[] {\n const seen = new Set<string>();\n const elements: React.ReactNode[] = [];\n\n for (const descriptor of descriptors) {\n const key = hash(descriptor);\n if (seen.has(key)) {\n continue;\n }\n seen.add(key);\n\n const element = process(descriptor, key);\n if (element) {\n elements.push(element);\n }\n }\n\n return elements;\n}\n\nfunction process(descriptor: MetaDescriptor, key: string): React.ReactNode {\n if ('charSet' in descriptor) {\n return <meta key={key} charSet={descriptor.charSet} />;\n }\n\n if ('title' in descriptor) {\n return <title key={key}>{descriptor.title}</title>;\n }\n\n if ('tagName' in descriptor) {\n const { tagName, ...attrs } = descriptor;\n if (tagName === 'link') {\n return <link key={key} {...attrs} />;\n }\n\n return <meta key={key} {...attrs} />;\n }\n\n // name/content, property/content, httpEquiv/content, and catch-all\n const attrs = descriptor as Record<string, string>;\n\n if ('httpEquiv' in attrs) {\n const { httpEquiv, ...rest } = attrs;\n return <meta key={key} httpEquiv={httpEquiv} {...rest} />;\n }\n\n return <meta key={key} {...attrs} />;\n}\n","import { is } from '@maily-to/shared';\nimport type { AnyMailyNode } from '@maily-to/shared';\nimport type { JSONContent } from '@tiptap/core';\n\nimport type { RenderContext } from '../context';\nimport { resolveVariableId, resolveVariableText } from './resolve-variable';\n\n/**\n * Resolves a preview value to a plain string.\n *\n * - `string` → resolves `{{variable}}` placeholders\n * - `JSONContent` → walks the tree and resolves variable nodes\n */\nexport function preview(\n preview: string | JSONContent,\n ctx: RenderContext\n): string {\n if (typeof preview === 'string') {\n return resolveVariableText(preview, ctx);\n }\n\n return walk(preview, ctx);\n}\n\nfunction walk(doc: JSONContent, ctx: RenderContext): string {\n const parts: string[] = [];\n if (!is.node(doc)) {\n return parts.join('');\n }\n\n function visitor(node: AnyMailyNode) {\n if (is.text(node)) {\n parts.push(node.text ?? '');\n }\n\n if (is.variable(node)) {\n const { id, fallback } = node.attrs;\n if (!id) {\n return;\n }\n\n parts.push(resolveVariableId(id, fallback ?? undefined, ctx));\n }\n\n if (is.parent(node)) {\n node.content.forEach(visitor);\n }\n }\n\n visitor(doc);\n return parts.join('');\n}\n","import type { BoxModel } from '../context';\n\n/**\n * Extracts a numeric pixel value from a CSS string (e.g. \"12px\" → 12).\n * Returns 0 for undefined, non-px strings, or NaN results.\n */\nexport function parsePxValue(value: string | number | undefined): number {\n if (value === undefined || value === null) {\n return 0;\n }\n\n if (typeof value === 'number') {\n return value;\n }\n\n const trimmed = value.trim();\n if (trimmed.endsWith('px')) {\n const n = parseFloat(trimmed);\n return isNaN(n) ? 0 : n;\n }\n\n return 0;\n}\n\n/**\n * Creates a fresh BoxModel with the given total width and zero\n * border/padding. Used as the starting point for layout calculations.\n */\nexport function initSize(totalWidth: number): BoxModel {\n return { totalWidth, totalBorder: 0, totalPadding: 0 };\n}\n\ntype CssValue = string | number | undefined;\n\ntype InsetBoxSpacing = {\n paddingLeft: CssValue;\n paddingRight: CssValue;\n borderLeft: CssValue;\n borderRight: CssValue;\n};\n\n/**\n * Accumulates horizontal border and padding into a BoxModel.\n * The total width stays the same — the usable content area shrinks.\n */\nexport function insetBox(size: BoxModel, spacing: InsetBoxSpacing): BoxModel {\n const totalBorder =\n size.totalBorder +\n parsePxValue(spacing.borderLeft) +\n parsePxValue(spacing.borderRight);\n const totalPadding =\n size.totalPadding +\n parsePxValue(spacing.paddingLeft) +\n parsePxValue(spacing.paddingRight);\n return { totalWidth: size.totalWidth, totalBorder, totalPadding };\n}\n\n/**\n * Creates a narrower BoxModel for percentage-width children (columns).\n * Computes the child's total width from the parent's content area,\n * subtracting horizontal gap space.\n */\nexport function narrowBoxByPercent(\n size: BoxModel,\n widthPercent: number,\n gapH: number\n): BoxModel {\n const currentBox = size.totalWidth - size.totalBorder - size.totalPadding;\n const totalWidth = currentBox * (widthPercent / 100) - gapH;\n return { totalWidth, totalBorder: 0, totalPadding: 0 };\n}\n","import {\n DEFAULT_FONT,\n getFontFaceStyle,\n is,\n TEXT_DIRECTIONS,\n} from '@maily-to/shared';\nimport {\n Body,\n Container,\n Head,\n Html,\n Img,\n Preview,\n} from '@react-email/components';\n\nimport { registerFontFace } from '../lib/font-face';\nimport { meta as renderMeta } from '../lib/meta';\nimport { preview as renderPreview } from '../lib/preview';\nimport { initSize, insetBox, parsePxValue } from '../lib/sizing';\nimport type { NodeRenderer } from '../node';\n\nconst BASE_CSS = /* css */ `blockquote,h1,h2,h3,img,li,ol,p,ul{margin-top:0;margin-bottom:0}`;\n\nexport const document: NodeRenderer = (node, ctx) => {\n if (!is.doc(node)) {\n return null;\n }\n\n const { dir } = node.attrs;\n const { theme, preview, meta, htmlProps, openTrackingPixel } = ctx.config;\n\n const font = theme.font;\n const container = theme.container ?? {};\n const body = theme.body ?? {};\n\n const containerWidth = parsePxValue(container.maxWidth);\n const size = insetBox(initSize(containerWidth), {\n paddingLeft:\n parsePxValue(container.paddingLeft) + parsePxValue(body.paddingLeft),\n paddingRight:\n parsePxValue(container.paddingRight) + parsePxValue(body.paddingRight),\n borderLeft: container.borderWidth,\n borderRight: container.borderWidth,\n });\n\n const primaryFont = font === undefined ? DEFAULT_FONT : font;\n if (primaryFont) {\n registerFontFace(ctx, primaryFont);\n }\n\n const child = ctx.child({ size }).children(node);\n for (const fontEntry of ctx.fonts.values()) {\n ctx.style(getFontFaceStyle(fontEntry));\n }\n\n const css = BASE_CSS + Array.from(ctx.styles).join('');\n\n const bodyStyle = {\n ...body,\n ...(primaryFont && primaryFont.fontFamily\n ? {\n fontFamily: `'${primaryFont.fontFamily}', ${primaryFont.fallbackFontFamily}`,\n }\n : {}),\n };\n\n const resolvedPreview = preview\n ? renderPreview(preview, ctx.child({ size }))\n : null;\n\n return (\n <Html\n lang=\"en\"\n {...htmlProps}\n {...(dir && dir !== TEXT_DIRECTIONS.AUTO ? { dir } : {})}\n >\n <Head>\n <meta httpEquiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n <meta name=\"x-apple-disable-message-reformatting\" />\n <meta\n name=\"format-detection\"\n content=\"telephone=no,address=no,email=no,date=no,url=no\"\n />\n <meta name=\"color-scheme\" content=\"light\" />\n <meta name=\"supported-color-schemes\" content=\"light\" />\n {renderMeta(meta)}\n <style dangerouslySetInnerHTML={{ __html: css }} />\n </Head>\n <Body style={bodyStyle}>\n {resolvedPreview && <Preview>{resolvedPreview}</Preview>}\n <Container style={container}>\n {child}\n\n {openTrackingPixel && (\n <Img\n src={openTrackingPixel}\n width=\"1\"\n height=\"1\"\n alt=\"\"\n style={{ display: 'none' }}\n />\n )}\n </Container>\n </Body>\n </Html>\n );\n};\n","import type { CSSProperties } from 'react';\n\n/**\n * Cross-browser font smoothing properties. Applied to the document\n * root so all text renders with subpixel antialiasing disabled.\n */\nexport const ANTIALIASED: Pick<\n CSSProperties,\n 'WebkitFontSmoothing' | 'MozOsxFontSmoothing'\n> = {\n WebkitFontSmoothing: 'antialiased',\n MozOsxFontSmoothing: 'grayscale',\n};\n","import { getCssDirection, getFontStyle, is } from '@maily-to/shared';\nimport { Text } from '@react-email/components';\n\nimport { prepareAndRegisterFontFaceFromAttrs } from '../lib/font-face';\nimport { shouldSuppressMarginBottom } from '../lib/spacing';\nimport { ANTIALIASED } from '../lib/styles';\nimport type { NodeRenderer } from '../node';\n\nexport const footer: NodeRenderer = (node, ctx) => {\n if (!is.footer(node)) {\n return null;\n }\n\n const { textAlign, dir } = node.attrs;\n const theme = ctx.config.theme;\n const fontStyle = getFontStyle(node.attrs, theme.footer);\n prepareAndRegisterFontFaceFromAttrs(ctx, node.attrs, theme.footer);\n\n return (\n <Text\n style={{\n ...(textAlign ? { textAlign } : {}),\n ...getCssDirection(dir),\n color: theme.footer?.color,\n marginTop: 0,\n marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 20,\n ...ANTIALIASED,\n ...fontStyle,\n }}\n >\n {ctx.children(node)}\n </Text>\n );\n};\n","import type { NodeRenderer } from '../node';\n\nexport const hardBreak: NodeRenderer = () => {\n return <br />;\n};\n","import {\n getCssDirection,\n getFontStyle,\n is,\n TEXT_ALIGNMENTS,\n} from '@maily-to/shared';\nimport { Heading } from '@react-email/components';\n\nimport { prepareAndRegisterFontFaceFromAttrs } from '../lib/font-face';\nimport { shouldSuppressMarginBottom } from '../lib/spacing';\nimport type { NodeRenderer } from '../node';\n\nconst HEADING_LEVELS = {\n 1: 'h1',\n 2: 'h2',\n 3: 'h3',\n} as const;\n\nexport const heading: NodeRenderer = (node, ctx) => {\n if (!is.heading(node)) {\n return null;\n }\n\n const { level, textAlign, dir } = node.attrs;\n const theme = ctx.config.theme;\n\n const element = HEADING_LEVELS[level];\n const key = `h${level}` as 'h1' | 'h2' | 'h3';\n const defaults = theme.heading?.[key];\n const fontStyle = getFontStyle(node.attrs, defaults);\n\n prepareAndRegisterFontFaceFromAttrs(ctx, node.attrs, defaults);\n\n return (\n <Heading\n as={element}\n style={{\n textAlign: textAlign ?? TEXT_ALIGNMENTS.LEFT,\n ...getCssDirection(dir),\n color: theme.heading?.defaults?.color,\n marginTop: 0,\n marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 12,\n ...fontStyle,\n }}\n >\n {ctx.children(node)}\n </Heading>\n );\n};\n","import { is } from '@maily-to/shared';\nimport { Hr } from '@react-email/components';\n\nimport {\n shouldSuppressMarginBottom,\n shouldSuppressMarginTop,\n} from '../lib/spacing';\nimport type { NodeRenderer } from '../node';\n\nexport const horizontalRule: NodeRenderer = (node, ctx) => {\n if (!is.horizontalRule(node)) {\n return null;\n }\n\n const theme = ctx.config.theme;\n\n return (\n <Hr\n style={{\n borderColor: theme.horizontalRule?.color,\n marginTop: shouldSuppressMarginTop(ctx) ? 0 : 32,\n marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 32,\n }}\n />\n );\n};\n","import { is, MAILY_NODE_TYPES } from '@maily-to/shared';\nimport type { AnyMailyNode } from '@maily-to/shared';\nimport juice from 'juice';\nimport { parse } from 'node-html-parser';\n\nimport type { RenderContext } from '../context';\nimport { resolveVariableId } from '../lib/resolve-variable';\nimport { shouldSuppressMarginBottom } from '../lib/spacing';\nimport type { NodeRenderer } from '../node';\n\nfunction resolveText(node: AnyMailyNode, ctx: RenderContext): string {\n if (node.type === MAILY_NODE_TYPES.TEXT && 'text' in node) {\n return node.text;\n }\n\n if (node.type === MAILY_NODE_TYPES.VARIABLE && 'attrs' in node) {\n const { id, fallback } = node.attrs;\n if (!id) {\n return '';\n }\n\n return resolveVariableId(id, fallback, ctx);\n }\n\n if (node.content && Array.isArray(node.content)) {\n return node.content.map((child) => resolveText(child, ctx)).join('');\n }\n\n return '';\n}\n\nexport const htmlCodeBlock: NodeRenderer = (node, ctx) => {\n if (!is.htmlCodeBlock(node)) {\n return null;\n }\n\n const rawHtml = node.content\n ? node.content.reduce((acc, child) => acc + resolveText(child, ctx), '')\n : '';\n\n const inlined = juice(rawHtml);\n const doc = parse(inlined);\n doc.querySelector('head')?.remove();\n const html = doc.toString();\n\n return (\n <table\n align=\"left\"\n width=\"100%\"\n border={0}\n cellPadding=\"0\"\n cellSpacing=\"0\"\n role=\"presentation\"\n style={{ marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 32 }}\n >\n <tbody>\n <tr style={{ width: '100%' }}>\n <td\n style={{ width: '100%' }}\n dangerouslySetInnerHTML={{ __html: html }}\n />\n </tr>\n </tbody>\n </table>\n );\n};\n","import {\n getBorderStyle,\n is,\n parseWidthToPercentage,\n TEXT_ALIGNMENTS,\n} from '@maily-to/shared';\nimport { Column, Img, Row } from '@react-email/components';\n\nimport { resolveVariableText } from '../lib/resolve-variable';\nimport { shouldSuppressMarginBottom } from '../lib/spacing';\nimport type { NodeRenderer } from '../node';\n\nexport const image: NodeRenderer = (node, ctx) => {\n if (!is.image(node)) {\n return null;\n }\n\n const { src, alt, title, width, align, externalLink } = node.attrs;\n const resolvedSrc = resolveVariableText(src, ctx);\n const resolvedExternalLink = externalLink\n ? resolveVariableText(externalLink, ctx)\n : externalLink;\n const percent = parseWidthToPercentage(width, ctx.box);\n const absoluteWidth = Math.round((ctx.box * percent) / 100);\n\n const img = (\n <Img\n src={resolvedSrc}\n alt={alt}\n title={title}\n width={absoluteWidth}\n style={{\n width: width ?? '100%',\n maxWidth: absoluteWidth,\n height: 'auto',\n display: 'block',\n ...getBorderStyle(node.attrs),\n }}\n />\n );\n\n const content = resolvedExternalLink ? (\n <a\n href={resolvedExternalLink}\n target=\"_blank\"\n rel=\"noopener noreferrer nofollow\"\n style={{ display: 'block' }}\n >\n {img}\n </a>\n ) : (\n img\n );\n\n return (\n <Row style={{ marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 32 }}>\n <Column align={align ?? TEXT_ALIGNMENTS.LEFT}>{content}</Column>\n </Row>\n );\n};\n","import { is } from '@maily-to/shared';\n\nimport { resolveVariableText } from '../lib/resolve-variable';\nimport type { NodeRenderer } from '../node';\n\nexport const inlineImage: NodeRenderer = (node, ctx) => {\n if (!is.inlineImage(node)) {\n return null;\n }\n\n const { src, alt, width, height, externalLink } = node.attrs;\n const resolvedSrc = resolveVariableText(src, ctx);\n const resolvedExternalLink = externalLink\n ? resolveVariableText(externalLink, ctx)\n : externalLink;\n\n const img = (\n <img\n src={resolvedSrc}\n alt={alt ?? ''}\n width={width}\n height={height}\n style={{\n display: 'inline',\n verticalAlign: 'middle',\n width,\n height,\n outline: 'none',\n border: 'none',\n textDecoration: 'none',\n }}\n />\n );\n\n if (resolvedExternalLink) {\n return (\n <a\n href={resolvedExternalLink}\n target=\"_blank\"\n rel=\"noopener noreferrer nofollow\"\n style={{\n display: 'inline',\n textDecoration: 'none',\n }}\n >\n {img}\n </a>\n );\n }\n\n return img;\n};\n","import { is } from '@maily-to/shared';\nimport { Column, Img, Row, Text } from '@react-email/components';\n\nimport { resolveVariableText } from '../lib/resolve-variable';\nimport { shouldSuppressMarginBottom } from '../lib/spacing';\nimport { ANTIALIASED } from '../lib/styles';\nimport { shouldShow } from '../lib/visibility';\nimport type { NodeRenderer } from '../node';\n\nexport const linkCard: NodeRenderer = (node, ctx) => {\n if (!is.linkCard(node)) {\n return null;\n }\n\n if (!shouldShow(node, ctx)) {\n return null;\n }\n\n const { title, description, link, linkTitle, image, subTitle, badgeText } =\n node.attrs;\n const theme = ctx.config.theme.linkCard;\n\n const resolvedLink = link ? resolveVariableText(link, ctx) : '';\n const href = resolvedLink || '#';\n\n return (\n <a\n href={href}\n rel=\"noopener noreferrer\"\n style={{\n border: `1px solid ${theme?.borderColor ?? '#eaeaea'}`,\n borderRadius: 10,\n textDecoration: 'none',\n color: 'inherit',\n display: 'block',\n marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 20,\n }}\n target=\"_blank\"\n >\n {image ? (\n <Row style={{ marginBottom: 6 }}>\n <Column style={{ width: '100%', height: '100%' }}>\n <Img\n alt={title || 'Link Card'}\n src={image}\n style={{\n borderRadius: '10px 10px 0 0',\n width: '100%',\n height: '100%',\n objectFit: 'cover',\n }}\n title={title || 'Link Card'}\n />\n </Column>\n </Row>\n ) : null}\n\n <Row style={{ padding: 15, marginTop: 0, marginBottom: 0 }}>\n <Column style={{ verticalAlign: 'top' }}>\n <Row\n style={{ marginBottom: 8, marginTop: 0 }}\n width=\"100%\"\n align=\"left\"\n >\n <Column>\n <Text\n style={{\n fontSize: 18,\n fontWeight: 600,\n color: theme?.titleColor ?? '#111827',\n margin: 0,\n textAlign: 'left',\n ...ANTIALIASED,\n }}\n >\n {title}\n {badgeText && (\n <span\n style={{\n fontWeight: 600,\n color: theme?.badgeTextColor ?? '#6B7280',\n padding: '4px 8px',\n borderRadius: '8px',\n backgroundColor: theme?.badgeBackgroundColor ?? '#F3F4F6',\n fontSize: '12px',\n lineHeight: '12px',\n marginLeft: '6px',\n }}\n >\n {badgeText}\n </span>\n )}\n {subTitle && !badgeText && (\n <span\n style={{\n fontWeight: 'normal',\n color: theme?.subTitleColor ?? '#6B7280',\n fontSize: 12,\n lineHeight: '12px',\n marginLeft: '6px',\n }}\n >\n {subTitle}\n </span>\n )}\n </Text>\n </Column>\n </Row>\n <Text\n style={{\n fontSize: 16,\n color: theme?.descriptionColor ?? '#374151',\n marginTop: 0,\n marginBottom: 0,\n }}\n >\n {description}{' '}\n {linkTitle ? (\n <a\n href={href}\n rel=\"noopener noreferrer\"\n style={{\n color: theme?.titleColor ?? '#111827',\n fontSize: 14,\n fontWeight: 600,\n textDecoration: 'underline',\n }}\n >\n {linkTitle}\n </a>\n ) : null}\n </Text>\n </Column>\n </Row>\n </a>\n );\n};\n","import { getCssDirection, is } from '@maily-to/shared';\n\nimport { ANTIALIASED } from '../lib/styles';\nimport type { NodeRenderer } from '../node';\n\nexport const listItem: NodeRenderer = (node, ctx) => {\n if (!is.listItem(node)) {\n return null;\n }\n\n const { dir } = node.attrs;\n\n return (\n <li\n style={{\n color: ctx.config.theme.listMarker?.color,\n marginBottom: 8,\n marginTop: 8,\n paddingLeft: 6,\n ...ANTIALIASED,\n ...getCssDirection(dir),\n }}\n >\n {ctx.children(node)}\n </li>\n );\n};\n","import { getCssDirection, is } from '@maily-to/shared';\nimport { Container } from '@react-email/components';\n\nimport { shouldSuppressMarginBottom } from '../lib/spacing';\nimport type { NodeRenderer } from '../node';\n\nexport const orderedList: NodeRenderer = (node, ctx) => {\n if (!is.orderedList(node)) {\n return null;\n }\n\n const { dir } = node.attrs;\n\n return (\n <Container\n style={{ marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 20 }}\n >\n <ol\n style={{\n paddingLeft: 26,\n listStyleType: 'decimal',\n margin: 0,\n ...getCssDirection(dir),\n }}\n >\n {ctx.children(node)}\n </ol>\n </Container>\n );\n};\n","import { getCssDirection, getFontStyle, is } from '@maily-to/shared';\nimport { Text } from '@react-email/components';\n\nimport { prepareAndRegisterFontFaceFromAttrs } from '../lib/font-face';\nimport { shouldSuppressMarginBottom } from '../lib/spacing';\nimport { ANTIALIASED } from '../lib/styles';\nimport type { NodeRenderer } from '../node';\n\nexport const paragraph: NodeRenderer = (node, ctx) => {\n if (!is.paragraph(node)) {\n return null;\n }\n\n const { textAlign, dir } = node.attrs;\n const theme = ctx.config.theme;\n const fontStyle = getFontStyle(node.attrs, theme.paragraph);\n prepareAndRegisterFontFaceFromAttrs(ctx, node.attrs, theme.paragraph);\n\n return (\n <Text\n style={{\n ...(textAlign ? { textAlign } : {}),\n ...getCssDirection(dir),\n color: theme.paragraph?.color,\n marginTop: 0,\n marginBottom: shouldSuppressMarginBottom(ctx) ? 0 : 20,\n ...ANTIALIASED,\n ...fontStyle,\n }}\n >\n {ctx.children(node)}\n </Text>\n );\n};\n","import { is, isObject } from '@maily-to/shared';\nimport { Fragment } from 'react';\n\nimport type { NodeRenderer } from '../node';\n\nexport const repeat: NodeRenderer = (node, ctx) => {\n if (!is.repeat(node)) {\n return null;\n }\n\n const { each } = node.attrs;\n const payload = ctx.config.variableValues.get(each);\n\n // If no payload or not an array, render once with no item\n if (!Array.isArray(payload)) {\n return <>{ctx.children(node)}</>;\n }\n\n return (\n <>\n {payload.map((item, index) => {\n const childContext = ctx.child({ parent: node, siblingIndex: index });\n childContext.set(\n 'item',\n isObject(item) ? (item as Record<string, unknown>) : { value: item }\n );\n\n return <Fragment key={index}>{childContext.children(node)}</Fragment>;\n })}\n </>\n );\n};\n","import {\n getBorderStyle,\n getMarginStyle,\n getPaddingStyle,\n is,\n TEXT_ALIGNMENTS,\n} from '@maily-to/shared';\nimport { Column, Row } from '@react-email/components';\n\nimport { insetBox } from '../lib/sizing';\nimport { shouldShow } from '../lib/visibility';\nimport type { NodeRenderer } from '../node';\n\nexport const section: NodeRenderer = (node, ctx) => {\n if (!is.section(node)) {\n return null;\n }\n\n if (!shouldShow(node, ctx)) {\n return null;\n }\n\n const { backgroundColor, align } = node.attrs;\n\n const borderStyle = getBorderStyle(node.attrs);\n const paddingStyle = getPaddingStyle(node.attrs);\n const marginStyle = getMarginStyle(node.attrs);\n\n const size = insetBox(ctx.size, {\n paddingLeft: node.attrs.paddingLeft,\n paddingRight: node.attrs.paddingRight,\n borderLeft: node.attrs.borderLeftWidth,\n borderRight: node.attrs.borderRightWidth,\n });\n\n return (\n <Row style={marginStyle}>\n <Column\n align={align ?? TEXT_ALIGNMENTS.LEFT}\n style={{\n backgroundColor,\n ...borderStyle,\n ...paddingStyle,\n }}\n >\n {ctx.child({ size }).children(node)}\n </Column>\n </Row>\n );\n};\n","import { is } from '@maily-to/shared';\nimport { Container } from '@react-email/components';\n\nimport type { NodeRenderer } from '../node';\n\nexport const spacer: NodeRenderer = (node) => {\n if (!is.spacer(node)) {\n return null;\n }\n\n const { height } = node.attrs;\n\n return <Container style={{ height: `${height}px` }} />;\n};\n","import type { MarkRenderer } from '../mark';\n\nexport const bold: MarkRenderer = (_mark, text, _ctx) => {\n return <strong>{text}</strong>;\n};\n","import { ANTIALIASED } from '../lib/styles';\nimport type { MarkRenderer } from '../mark';\n\nconst CODE_FONT_FAMILY = 'ui-monospace, monospace';\n\nexport const code: MarkRenderer = (_mark, text, ctx) => {\n const theme = ctx.config.theme;\n\n return (\n <code\n style={{\n backgroundColor: theme.code?.backgroundColor,\n color: theme.code?.color,\n fontFamily: CODE_FONT_FAMILY,\n fontSize: '85%',\n padding: '2px 6px',\n borderRadius: 8,\n ...ANTIALIASED,\n }}\n >\n {text}\n </code>\n );\n};\n","import type { MarkRenderer } from '../mark';\n\nexport const italic: MarkRenderer = (_mark, text, _ctx) => {\n return <em>{text}</em>;\n};\n","import { is } from '@maily-to/shared';\n\nimport { resolveVariableText } from '../lib/resolve-variable';\nimport type { MarkRenderer } from '../mark';\n\nexport const link: MarkRenderer = (mark, text, ctx) => {\n if (!is.link(mark)) {\n return null;\n }\n\n const theme = ctx.config.theme;\n const linkOverride = ctx.config.variableValues.get(mark.attrs.href);\n const href =\n (typeof linkOverride === 'string' ? linkOverride : undefined) ??\n resolveVariableText(mark.attrs.href, ctx);\n const color = theme.link?.color;\n\n return (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noopener noreferrer nofollow\"\n style={color ? { color } : undefined}\n >\n {text}\n </a>\n );\n};\n","import type { MarkRenderer } from '../mark';\n\nexport const strike: MarkRenderer = (_mark, text, _ctx) => {\n return <s>{text}</s>;\n};\n","import type { MarkRenderer } from '../mark';\n\nexport const underline: MarkRenderer = (_mark, text, _ctx) => {\n return <u>{text}</u>;\n};\n","import type {\n AnyMailyMark,\n AnyMailyNode,\n MailyMarkType,\n} from '@maily-to/shared';\nimport { is, MAILY_MARK_TYPES } from '@maily-to/shared';\n\nimport type { RenderContext } from './context';\nimport { bold } from './marks/bold';\nimport { code } from './marks/code';\nimport { italic } from './marks/italic';\nimport { link } from './marks/link';\nimport { strike } from './marks/strike';\nimport { underline } from './marks/underline';\n\nconst MAILY_MARKS_ORDER = [\n MAILY_MARK_TYPES.UNDERLINE,\n MAILY_MARK_TYPES.BOLD,\n MAILY_MARK_TYPES.ITALIC,\n MAILY_MARK_TYPES.STRIKE,\n MAILY_MARK_TYPES.LINK,\n MAILY_MARK_TYPES.CODE,\n];\n\n/**\n * Function signature for a mark renderer. Each mark type (bold, link,\n * etc.) wraps the text node in its styled element.\n */\nexport type MarkRenderer = (\n mark: AnyMailyMark,\n text: React.ReactNode,\n ctx: RenderContext\n) => React.ReactNode;\n\nconst MAILY_MARK_RENDERERS: Partial<Record<MailyMarkType, MarkRenderer>> = {\n [MAILY_MARK_TYPES.UNDERLINE]: underline,\n [MAILY_MARK_TYPES.BOLD]: bold,\n [MAILY_MARK_TYPES.ITALIC]: italic,\n [MAILY_MARK_TYPES.STRIKE]: strike,\n [MAILY_MARK_TYPES.LINK]: link,\n [MAILY_MARK_TYPES.CODE]: code,\n};\n\nfunction render(mark: AnyMailyMark, text: React.ReactNode, ctx: RenderContext) {\n if (!is.mark(mark)) {\n return null;\n }\n\n const renderer = MAILY_MARK_RENDERERS[mark.type];\n if (!renderer) {\n return null;\n }\n\n return renderer(mark, text, ctx);\n}\n\ntype MergedTextStyle = {\n color?: string;\n backgroundColor?: string;\n};\n\n/**\n * Applies all marks on a text node. Merges textStyle and highlight\n * marks into a single span, then wraps with remaining marks in order.\n */\nexport function marks(node: AnyMailyNode, ctx: RenderContext) {\n if (!is.marked(node)) {\n return [];\n }\n\n const themeColor = ctx.config.theme.paragraph?.color;\n\n // Merge text styles so that we don't have to add multiple spans for each text style\n // This is done by reducing the marks to a single object with the text styles\n const textStyles = node.marks\n .filter((mark) => is.textStyle(mark) || is.highlight(mark))\n .reduce((acc, mark) => {\n if (is.textStyle(mark)) {\n acc.color = mark.attrs.color || themeColor;\n } else {\n acc.backgroundColor = mark.attrs.color;\n }\n\n return acc;\n }, {} as MergedTextStyle);\n\n const marks = node.marks\n .filter((mark) => !is.textStyle(mark) && !is.highlight(mark))\n .sort((a, b) => {\n const aIndex = MAILY_MARKS_ORDER.indexOf(a.type);\n const bIndex = MAILY_MARKS_ORDER.indexOf(b.type);\n return aIndex - bIndex;\n });\n\n const text = node?.text || <> </>;\n const baseText = isEmptyObject(textStyles) ? (\n <>{text}</>\n ) : (\n <span style={textStyles}>{text}</span>\n );\n\n return marks.reduce(\n (acc: React.ReactNode, mark: AnyMailyMark, index: number) => {\n const component = render(\n mark,\n acc,\n ctx.child({ parent: node, siblingIndex: index })\n );\n if (!component) {\n return acc;\n }\n\n return component;\n },\n baseText\n );\n}\n\nfunction isEmptyObject<T extends object>(obj: T): boolean {\n for (const _ in obj) {\n return false;\n }\n\n return true;\n}\n","import { is, isDef } from '@maily-to/shared';\n\nimport { marks } from '../mark';\nimport type { NodeRenderer } from '../node';\n\nexport const text: NodeRenderer = (node, ctx) => {\n if (!is.text(node)) {\n return null;\n }\n\n if (is.marked(node)) {\n return marks(node, ctx);\n }\n\n const { text } = node;\n if (!isDef(text)) {\n return <> </>;\n }\n\n return <>{text}</>;\n};\n","import { is } from '@maily-to/shared';\n\nimport { resolveVariableId } from '../lib/resolve-variable';\nimport type { NodeRenderer } from '../node';\n\nexport const variable: NodeRenderer = (node, ctx) => {\n if (!is.variable(node)) {\n return null;\n }\n\n const { id, fallback } = node.attrs;\n if (!id) {\n return <>{fallback ?? ''}</>;\n }\n\n return <>{resolveVariableId(id, fallback, ctx)}</>;\n};\n","import type { AnyMailyNode, MailyNodeType } from '@maily-to/shared';\nimport { is, MAILY_NODE_TYPES } from '@maily-to/shared';\nimport { Fragment } from 'react';\n\nimport type { RenderContext } from './context';\nimport { blockquote } from './nodes/blockquote';\nimport { bulletList } from './nodes/bullet-list';\nimport { button } from './nodes/button';\nimport { column } from './nodes/column';\nimport { columns } from './nodes/columns';\nimport { document } from './nodes/document';\nimport { footer } from './nodes/footer';\nimport { hardBreak } from './nodes/hard-break';\nimport { heading } from './nodes/heading';\nimport { horizontalRule } from './nodes/horizontal-rule';\nimport { htmlCodeBlock } from './nodes/html-code-block';\nimport { image } from './nodes/image';\nimport { inlineImage } from './nodes/inline-image';\nimport { linkCard } from './nodes/link-card';\nimport { listItem } from './nodes/list-item';\nimport { orderedList } from './nodes/ordered-list';\nimport { paragraph } from './nodes/paragraph';\nimport { repeat } from './nodes/repeat';\nimport { section } from './nodes/section';\nimport { spacer } from './nodes/spacer';\nimport { text } from './nodes/text';\nimport { variable } from './nodes/variable';\n\n/**\n * Function signature for a node renderer. Each node type (paragraph,\n * button, image, etc.) implements this to produce its React output.\n */\nexport type NodeRenderer = (\n node: AnyMailyNode,\n ctx: RenderContext\n) => React.ReactNode;\n\nconst MAILY_NODE_RENDERERS: Partial<Record<MailyNodeType, NodeRenderer>> = {\n [MAILY_NODE_TYPES.DOCUMENT]: document,\n [MAILY_NODE_TYPES.PARAGRAPH]: paragraph,\n [MAILY_NODE_TYPES.TEXT]: text,\n [MAILY_NODE_TYPES.HEADING]: heading,\n [MAILY_NODE_TYPES.VARIABLE]: variable,\n [MAILY_NODE_TYPES.IMAGE]: image,\n [MAILY_NODE_TYPES.INLINE_IMAGE]: inlineImage,\n [MAILY_NODE_TYPES.SPACER]: spacer,\n [MAILY_NODE_TYPES.SECTION]: section,\n [MAILY_NODE_TYPES.BUTTON]: button,\n [MAILY_NODE_TYPES.REPEAT]: repeat,\n [MAILY_NODE_TYPES.COLUMNS]: columns,\n [MAILY_NODE_TYPES.COLUMN]: column,\n [MAILY_NODE_TYPES.BULLET_LIST]: bulletList,\n [MAILY_NODE_TYPES.ORDERED_LIST]: orderedList,\n [MAILY_NODE_TYPES.LIST_ITEM]: listItem,\n [MAILY_NODE_TYPES.HORIZONTAL_RULE]: horizontalRule,\n [MAILY_NODE_TYPES.HTML_CODE_BLOCK]: htmlCodeBlock,\n [MAILY_NODE_TYPES.BLOCKQUOTE]: blockquote,\n [MAILY_NODE_TYPES.HARD_BREAK]: hardBreak,\n [MAILY_NODE_TYPES.FOOTER]: footer,\n [MAILY_NODE_TYPES.LINK_CARD]: linkCard,\n};\n\nexport function dispatch(\n node: AnyMailyNode,\n ctx: RenderContext\n): React.ReactNode {\n if (!is.node(node)) {\n return null;\n }\n\n const renderer = MAILY_NODE_RENDERERS[node.type];\n if (!renderer) {\n return null;\n }\n\n return renderer(node, ctx);\n}\n\nexport function children(\n parent: AnyMailyNode,\n ctx: RenderContext\n): React.ReactNode[] {\n if (!is.parent(parent)) {\n return [];\n }\n\n return parent.content\n .map((child: AnyMailyNode, index: number) => {\n const childCtx = ctx.child({ parent, siblingIndex: index });\n const component = childCtx.render(child);\n if (!component) {\n return null;\n }\n\n return <Fragment key={index}>{component}</Fragment>;\n })\n .filter(Boolean);\n}\n","import type { AnyMailyMark, AnyMailyNode, FontProps } from '@maily-to/shared';\n\nimport type { MailyRenderConfig } from './config';\nimport { dispatch, children } from './node';\n\n/**\n * Typed variable keys available on every RenderContext.\n *\n * Built-in keys:\n * - `item` — the current record during a repeat iteration. Set by repeat.tsx\n * when looping over an array variable. Each iteration gets its own copy so\n * sibling iterations are isolated. Variable/visibility lookups check `item`\n * first, then fall back to `config.variableValues`.\n * - `columnTdWidth` — the TD-relative percentage width string (e.g. `\"48.4%\"`)\n * set by columns.tsx and consumed by column.tsx.\n *\n * Extend via module augmentation to add custom keys:\n *\n * @example\n * ```ts\n * declare module '@maily-to/render' {\n * interface RenderVariableMap {\n * theme: 'light' | 'dark';\n * locale: string;\n * }\n * }\n * ```\n */\nexport interface RenderVariableMap {\n item?: Record<string, unknown>;\n columnTdWidth?: string;\n}\n\nexport type BoxModel = {\n totalWidth: number;\n totalBorder: number;\n totalPadding: number;\n};\n\n/**\n * Render-time context threaded through every node and mark renderer.\n *\n * State scoping:\n * - `config` — immutable, shared by the entire tree.\n * - `styles` / `fonts` — shared collectors that accumulate to the document root.\n * Use `style()` and `font()` from any depth; they all write to the same sets.\n * - `vars` — cloned per `child()` call. A child inherits the parent's vars at\n * creation time, but mutations in either direction are isolated. This is what\n * allows nested repeat iterations to each carry their own `item` without\n * leaking into siblings or parents.\n * - `parent`, `siblingIndex`, `size` — local to each context instance.\n */\nexport interface RenderContext<\n Variables extends RenderVariableMap = RenderVariableMap,\n> {\n readonly parent: AnyMailyNode | AnyMailyMark | undefined;\n readonly siblingIndex: number;\n readonly config: MailyRenderConfig;\n readonly size: Readonly<BoxModel>;\n /** Content width after subtracting border and padding from `size.totalWidth`. */\n readonly box: number;\n\n /** Render a single node using the registered node renderers. */\n render(node: AnyMailyNode): React.ReactNode;\n\n /** Render all child nodes of a parent, creating a child context for each. */\n children(parent: AnyMailyNode): React.ReactNode[];\n\n /**\n * Set a typed variable on this context.\n * Only affects this context — child contexts created via `child()` get\n * their own copy and won't see mutations made here after creation.\n */\n set<K extends keyof Variables>(key: K, value: Variables[K]): void;\n\n /** Get a typed variable from this context. */\n get<K extends keyof Variables>(key: K): Variables[K];\n\n /**\n * Access all variables as a readonly object. Creates a new object on\n * each access — prefer `get()` for individual lookups.\n */\n readonly var: Readonly<Variables>;\n\n /** Add a CSS rule to the shared document-level style collector. */\n style(css: string): void;\n /** Register a font face in the shared document-level font collector. */\n font(name: string, props: FontProps): void;\n\n /**\n * Derive a child context for rendering a child node.\n *\n * - `config`, `styles`, and `fonts` are shared by reference.\n * - `vars` are shallow-cloned so child `set()` calls don't affect the parent.\n * - `parent`, `siblingIndex`, and `size` can be overridden; unset fields\n * inherit from the current context.\n */\n child(opts: ChildContextOptions): RenderContext<Variables>;\n\n readonly styles: ReadonlySet<string>;\n readonly fonts: ReadonlyMap<string, FontProps>;\n}\n\nexport type ChildContextOptions = {\n parent?: AnyMailyNode | AnyMailyMark;\n siblingIndex?: number;\n size?: Partial<BoxModel>;\n};\n\ntype SharedState = {\n vars: Map<string, unknown>;\n styles: Set<string>;\n fonts: Map<string, FontProps>;\n};\n\nexport type CreateRenderContextOptions = {\n config: MailyRenderConfig;\n parent?: AnyMailyNode | AnyMailyMark;\n siblingIndex?: number;\n size?: Partial<BoxModel>;\n};\n\nconst DEFAULT_SIZE: BoxModel = {\n totalWidth: 600,\n totalBorder: 0,\n totalPadding: 0,\n};\n\n/**\n * Creates the root RenderContext for a render pass. Node renderers\n * derive child contexts via `ctx.child()` as they descend the tree.\n */\nexport function defineRenderContext<\n Variables extends RenderVariableMap = RenderVariableMap,\n>(opts: CreateRenderContextOptions): RenderContext<Variables> {\n const shared: SharedState = {\n vars: new Map(),\n styles: new Set(),\n fonts: new Map(),\n };\n\n const size = { ...DEFAULT_SIZE, ...opts.size };\n\n return defineContext(\n {\n config: opts.config,\n parent: opts.parent,\n siblingIndex: opts.siblingIndex ?? 0,\n size,\n },\n shared\n );\n}\n\ntype BuildContextOptions = {\n config: MailyRenderConfig;\n parent: AnyMailyNode | AnyMailyMark | undefined;\n siblingIndex: number;\n size: BoxModel;\n};\n\nfunction defineContext<Variables extends RenderVariableMap = RenderVariableMap>(\n opts: BuildContextOptions,\n shared: SharedState\n): RenderContext<Variables> {\n const { config, parent, siblingIndex, size } = opts;\n const { vars, styles, fonts } = shared;\n\n let varCache: Readonly<Variables> | null = null;\n\n const ctx: RenderContext<Variables> = {\n parent,\n siblingIndex,\n config,\n size,\n\n get box() {\n return size.totalWidth - size.totalBorder - size.totalPadding;\n },\n\n render(node: AnyMailyNode) {\n return dispatch(node, ctx);\n },\n\n children(parent: AnyMailyNode) {\n return children(parent, ctx);\n },\n\n set<K extends keyof Variables>(key: K, value: Variables[K]) {\n vars.set(key as string, value);\n varCache = null;\n },\n\n get<K extends keyof Variables>(key: K): Variables[K] {\n return vars.get(key as string) as Variables[K];\n },\n\n get var() {\n return (varCache ??= Object.fromEntries(vars) as Readonly<Variables>);\n },\n\n style(css: string) {\n styles.add(css);\n },\n\n font(name: string, props: FontProps) {\n fonts.set(name, props);\n },\n\n child(opts: ChildContextOptions): RenderContext<Variables> {\n const childSize: BoxModel = opts.size\n ? {\n totalWidth: opts.size.totalWidth ?? size.totalWidth,\n totalBorder: opts.size.totalBorder ?? size.totalBorder,\n totalPadding: opts.size.totalPadding ?? size.totalPadding,\n }\n : size;\n\n // Clone vars so child mutations don't leak to parent.\n // Styles and fonts remain shared (they accumulate to the document root).\n const childShared: SharedState = {\n vars: new Map(vars),\n styles,\n fonts,\n };\n\n return defineContext(\n {\n config,\n parent: opts.parent ?? parent,\n siblingIndex: opts.siblingIndex ?? siblingIndex,\n size: childSize,\n },\n childShared\n );\n },\n\n get styles() {\n return styles as ReadonlySet<string>;\n },\n get fonts() {\n return fonts as ReadonlyMap<string, FontProps>;\n },\n };\n\n return ctx;\n}\n","import type { AnyMailyNode } from '@maily-to/shared';\nimport { is } from '@maily-to/shared';\nimport type { JSONContent } from '@tiptap/core';\n\n/**\n * Extracts all valid URLs from link marks in a Maily document.\n * Returns a deduplicated Set of href strings.\n */\nexport function links(json: JSONContent): Set<string> {\n const links = new Set<string>();\n if (!is.node(json)) {\n return links;\n }\n\n function visitor(node: AnyMailyNode) {\n if (is.marked(node)) {\n for (const mark of node.marks) {\n if (!is.link(mark)) {\n continue;\n }\n\n const href = mark.attrs.href;\n if (!isValid(href)) {\n continue;\n }\n\n links.add(href);\n }\n }\n\n if (is.parent(node)) {\n node.content.forEach(visitor);\n }\n }\n\n visitor(json);\n return links;\n}\n\nfunction isValid(string: string) {\n try {\n new URL(string);\n return true;\n } catch {\n return false;\n }\n}\n","import {\n DEFAULT_FONT_FAMILIES,\n DEFAULT_RENDERER_THEME,\n} from '@maily-to/shared';\nimport type { FontFamilyItem, RendererThemeOptions } from '@maily-to/shared';\nimport type { HtmlProps } from '@react-email/components';\nimport type { JSONContent } from '@tiptap/core';\n\nimport type { MetaDescriptor } from './lib/meta';\n\n/**\n * Custom formatter called when a variable has no value in `variables`.\n * Return a placeholder string (e.g. `{{name}}` or `${name}`).\n */\nexport type VariableFormatter = (opts: {\n variable: string;\n fallback?: string;\n}) => string;\n\n/**\n * Any value that can be stored in the unified `variables` map.\n *\n * - `string` — text substitution (variable nodes, link href overrides)\n * - `number` — numeric comparisons in visibility rules\n * - `boolean` — truthy/falsy visibility checks\n * - `Record<string, unknown>` — nested object data\n * - `Array<Record<string, unknown>>` — arrays iterated by repeat nodes\n */\nexport type VariableValue =\n | string\n | number\n | boolean\n | Record<string, unknown>\n | Array<Record<string, unknown>>;\n\n/** Internal resolved config produced by buildConfig. */\nexport type MailyRenderConfig = {\n theme: RendererThemeOptions;\n fontFamilies: FontFamilyItem[];\n\n variableFormatter: VariableFormatter;\n variableValues: Map<string, VariableValue>;\n\n preview?: string | JSONContent;\n meta: MetaDescriptor[];\n htmlProps: HtmlProps;\n openTrackingPixel?: string;\n};\n\n/**\n * Public config passed to `render()`.\n *\n * All user-provided data lives under a single `variables` key:\n *\n * @example\n * ```ts\n * render(json, {\n * variables: {\n * name: 'Alice', // string → variable substitution\n * active: true, // boolean → visibility rules\n * items: [{ id: 1 }], // array → repeat iteration\n * cta: 'https://example.com', // string → link href override\n * },\n * });\n * ```\n *\n * Resolution priority (highest → lowest):\n * 1. `item` — per-iteration data set by repeat nodes (via context)\n * 2. `variables` — this map\n * 3. `variableFormatter` — fallback that produces a placeholder string\n */\nexport type MailyConfig = {\n preview?: string | JSONContent;\n theme?: Partial<RendererThemeOptions>;\n fontFamilies?: FontFamilyItem[];\n variables?: Record<string, VariableValue>;\n variableFormatter?: VariableFormatter;\n meta?: MetaDescriptor[];\n htmlProps?: HtmlProps;\n openTrackingPixel?: string;\n};\n\nconst DEFAULT_VARIABLE_FORMATTER: VariableFormatter = ({\n variable,\n fallback,\n}) => {\n return fallback ? `{{${variable}|${fallback}}}` : `{{${variable}}}`;\n};\n\n/**\n * Merges user-provided MailyConfig with defaults to produce the\n * internal MailyRenderConfig used throughout the render pass.\n */\nexport function buildConfig(config: MailyConfig = {}): MailyRenderConfig {\n const theme: RendererThemeOptions = {\n ...DEFAULT_RENDERER_THEME,\n ...config.theme,\n paragraph: {\n ...DEFAULT_RENDERER_THEME.paragraph,\n ...config.theme?.paragraph,\n },\n heading: {\n defaults: {\n ...DEFAULT_RENDERER_THEME.heading?.defaults,\n ...config.theme?.heading?.defaults,\n },\n h1: {\n ...DEFAULT_RENDERER_THEME.heading?.h1,\n ...config.theme?.heading?.h1,\n },\n h2: {\n ...DEFAULT_RENDERER_THEME.heading?.h2,\n ...config.theme?.heading?.h2,\n },\n h3: {\n ...DEFAULT_RENDERER_THEME.heading?.h3,\n ...config.theme?.heading?.h3,\n },\n },\n footer: {\n ...DEFAULT_RENDERER_THEME.footer,\n ...config.theme?.footer,\n },\n blockquote: {\n ...DEFAULT_RENDERER_THEME.blockquote,\n ...config.theme?.blockquote,\n },\n horizontalRule: {\n ...DEFAULT_RENDERER_THEME.horizontalRule,\n ...config.theme?.horizontalRule,\n },\n code: {\n ...DEFAULT_RENDERER_THEME.code,\n ...config.theme?.code,\n },\n linkCard: {\n ...DEFAULT_RENDERER_THEME.linkCard,\n ...config.theme?.linkCard,\n },\n container: {\n ...DEFAULT_RENDERER_THEME.container,\n ...config.theme?.container,\n },\n body: {\n ...DEFAULT_RENDERER_THEME.body,\n ...config.theme?.body,\n },\n button: {\n ...DEFAULT_RENDERER_THEME.button,\n ...config.theme?.button,\n },\n link: {\n ...DEFAULT_RENDERER_THEME.link,\n ...config.theme?.link,\n },\n font:\n config.theme?.font !== undefined\n ? config.theme.font\n : DEFAULT_RENDERER_THEME.font,\n listMarker: {\n ...DEFAULT_RENDERER_THEME.listMarker,\n ...config.theme?.listMarker,\n },\n };\n\n return {\n theme,\n fontFamilies: config.fontFamilies ?? DEFAULT_FONT_FAMILIES,\n variableValues: new Map(Object.entries(config.variables ?? {})),\n variableFormatter: config.variableFormatter ?? DEFAULT_VARIABLE_FORMATTER,\n preview: config.preview,\n meta: config.meta ?? [],\n htmlProps: config.htmlProps ?? {},\n openTrackingPixel: config.openTrackingPixel,\n };\n}\n","import { migrate } from '@maily-to/migration';\nimport { is } from '@maily-to/shared';\nimport { render as reactEmailRender } from '@react-email/render';\nimport type { JSONContent } from '@tiptap/core';\n\nimport { buildConfig } from './config';\nimport type { MailyConfig } from './config';\nimport { defineRenderContext } from './context';\nimport { document } from './nodes/document';\n\n/**\n * Converts a Maily JSON document into React elements. Returns null\n * if the input is not a valid Maily node.\n */\nexport function markup(json: JSONContent, config: MailyConfig = {}) {\n const { json: migrated } = migrate(json);\n if (!is.node(migrated)) {\n return null;\n }\n\n return document(\n migrated,\n defineRenderContext({ config: buildConfig(config) })\n );\n}\n\n/** Renders a Maily JSON document to an HTML string using @react-email/render. */\nexport async function render(json: JSONContent, config: MailyConfig = {}) {\n if (!is.node(json)) {\n return '';\n }\n\n return reactEmailRender(markup(json, config));\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,SAAgB,iBAAiB,KAAoB,MAAuB;CAC1E,MAAM,EACJ,YACA,aAAa,KACb,oBACA,YAAY,aACV;AAEJ,KAAI,CAAC,WACH;CAGF,MAAM,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,WAAW,GAAG;AACxD,KAAI,IAAI,MAAM,IAAI,IAAI,CACpB;AAGF,KAAI,KAAK,KAAK,KAAK;;;;;;;AAQrB,SAAgB,oCACd,KACA,OACA,UACA;CACA,MAAM,cAAc,IAAI,OAAO,MAAM,QAAQ;AAC7C,KAAI,CAAC,YACH;CAGF,MAAM,EAAE,YAAY,YAAY,cAAc,cAAc;CAC5D,MAAM,SAAS,cAAc,YAAY;AACzC,KAAI,CAAC,OACH;CAGF,MAAM,SAAS,cAAc,UAAU,cAAc;CACrD,MAAM,QAAQ,aAAa,UAAU,aAAa;CAClD,MAAM,WAAW,gBAAgB,YAAY;CAE7C,MAAM,UAAU,aACZ,IAAI,OAAO,aAAa,MAAM,MAAM,EAAE,eAAe,WAAW,EAAE,UAClE,YAAY;AAEhB,kBAAiB,KAAK;EACpB,YAAY;EACZ,YAAY;EACZ,oBAAoB;EACpB,WAAW;EACX,GAAI,WAAW,EAAE,SAAS;EAC3B,CAAC;;;;AChEJ,MAAM,mBAAm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