@forgeroute/ui 0.5.33 → 0.5.35
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/fesm2022/{forgeroute-ui-core-ui-labels.es-BViJSCO-.mjs → forgeroute-ui-core-ui-labels.es-D_eDy5nx.mjs} +10 -1
- package/fesm2022/forgeroute-ui-core-ui-labels.es-D_eDy5nx.mjs.map +1 -0
- package/fesm2022/forgeroute-ui-core.mjs +10 -1
- package/fesm2022/forgeroute-ui-core.mjs.map +1 -1
- package/fesm2022/forgeroute-ui-editor.mjs +232 -21
- package/fesm2022/forgeroute-ui-editor.mjs.map +1 -1
- package/package.json +1 -1
- package/types/forgeroute-ui-core.d.ts +11 -2
- package/types/forgeroute-ui-editor.d.ts +81 -1
- package/types/forgeroute-ui-square.d.ts +1 -1
- package/types/forgeroute-ui-stripe.d.ts +1 -1
- package/fesm2022/forgeroute-ui-core-ui-labels.es-BViJSCO-.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forgeroute-ui-editor.mjs","names":[],"sources":["../../../projects/forgeroute-ui/editor/src/lib/rich-text-editor/rich-text-sanitizer.ts","../../../projects/forgeroute-ui/editor/src/lib/rich-text-editor/rich-text-editor.component.ts","../../../projects/forgeroute-ui/editor/src/lib/email-template-editor/email-template-editor.utils.ts","../../../projects/forgeroute-ui/editor/src/lib/email-template-editor/email-template-editor.component.ts","../../../projects/forgeroute-ui/editor/src/lib/inspection-template-print/inspection-template-print.ts"],"sourcesContent":["/**\n * Allow-list HTML sanitiser used by `ui-rich-text-editor`.\n *\n * The allow-list matches the markup the editor itself produces (and what a server-side allow-list\n * sanitiser for editor output typically keeps): bold/italic/underline/strike, paragraphs and line\n * breaks, headings, lists, block quotes (indent), links, and the inline styles used for alignment,\n * size, font, colour and highlight. Everything else is removed: scripts and styles with their\n * contents, event-handler attributes, `javascript:` and other unsafe URL schemes, and any style\n * property or value outside the lists below.\n *\n * Runs on an inert document (DOMParser), so nothing in the input is executed or fetched.\n */\n\nexport type RichTextSanitizeMode = 'content' | 'paste';\n\nexport interface RichTextSanitizeOptions {\n /** `content` keeps allow-listed inline styles; `paste` flattens them to plain semantic tags. */\n mode?: RichTextSanitizeMode;\n /** Tag names (upper-case) that must not appear in the output — they are replaced per `replace`/unwrapped. */\n blockedTags?: ReadonlySet<string>;\n /** Replacement tag (upper-case) for blocked tags; a blocked tag without an entry is unwrapped. */\n replace?: Readonly<Record<string, string>>;\n}\n\nconst ALLOWED_TAGS = new Set([\n 'P', 'DIV', 'SPAN', 'BR',\n 'B', 'STRONG', 'I', 'EM', 'U', 'S', 'STRIKE', 'DEL', 'SUB', 'SUP',\n 'UL', 'OL', 'LI', 'BLOCKQUOTE',\n 'H1', 'H2', 'H3', 'H4',\n 'A', 'FONT',\n]);\n\n/** Dropped together with their contents. */\nconst DROP_WITH_CONTENT = new Set([\n 'SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'OPTION', 'SELECT', 'IFRAME', 'OBJECT', 'EMBED',\n 'TEMPLATE', 'HEAD', 'TITLE', 'META', 'LINK', 'SVG', 'MATH', 'CANVAS', 'AUDIO', 'VIDEO',\n 'INPUT', 'BUTTON', 'FORM', 'IMG', 'APPLET', 'FRAME', 'FRAMESET',\n]);\n\n/** Unknown block-level tags become a `<div>` so their line breaks survive. */\nconst BLOCK_TO_DIV = new Set([\n 'SECTION', 'ARTICLE', 'HEADER', 'FOOTER', 'MAIN', 'ASIDE', 'NAV', 'PRE', 'H5', 'H6',\n 'CAPTION', 'FIGURE', 'DL', 'DT', 'DD', 'ADDRESS', 'FIELDSET', 'CENTER',\n]);\n\nconst COLOR = /^(#[0-9a-f]{3,8}|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\)|[a-z]{3,20})$/i;\nconst LENGTH = /^-?\\d+(\\.\\d+)?(px|pt|em|rem|%)?$/;\nconst MARGIN = /^(-?\\d+(\\.\\d+)?(px|pt|em|rem|%)?\\s*){1,4}$/;\n\nconst STYLE_RULES: Record<string, RegExp[]> = {\n 'text-align': [/^(left|right|center|justify)$/],\n 'font-size': [LENGTH, /^(x-small|small|medium|large|x-large|xx-large|xxx-large)$/],\n 'font-family': [/^[\\w\\s,'\"-]+$/],\n 'font-weight': [/^(normal|bold|[1-9]00)$/],\n 'font-style': [/^(normal|italic)$/],\n 'text-decoration': [/^(none|underline|line-through)( (none|underline|line-through))*$/],\n color: [COLOR],\n 'background-color': [COLOR],\n margin: [MARGIN],\n 'margin-left': [LENGTH],\n 'padding-left': [LENGTH],\n};\n\nconst ALLOWED_SCHEMES = /^(https?|mailto|tel):/i;\n\nfunction safeHref(raw: string): string | null {\n const cleaned = raw.replace(/[\\u0000- \\u007f-\\u009f]/g, '');\n if (!cleaned) return null;\n if (ALLOWED_SCHEMES.test(cleaned)) return raw.trim();\n if (/^[a-z][a-z0-9+.-]*:/i.test(cleaned) || /^[\\/\\\\]{2}/.test(cleaned)) return null;\n return raw.trim();\n}\n\n/** Parses an inline style attribute into `[property, value]` pairs (lower-cased property). */\nfunction parseStyle(style: string): [string, string][] {\n return style\n .split(';')\n .map(decl => {\n const i = decl.indexOf(':');\n return i < 0 ? null : ([decl.slice(0, i).trim().toLowerCase(), decl.slice(i + 1).trim()] as [string, string]);\n })\n .filter((d): d is [string, string] => !!d && !!d[0] && !!d[1]);\n}\n\nfunction filterStyle(style: string): string {\n return parseStyle(style)\n .filter(([prop, value]) => (STYLE_RULES[prop] ?? []).some(rule => rule.test(value)))\n .map(([prop, value]) => `${prop}: ${value}`)\n .join('; ');\n}\n\ninterface Ctx {\n doc: Document;\n mode: RichTextSanitizeMode;\n blocked: ReadonlySet<string>;\n replace: Readonly<Record<string, string>>;\n}\n\n/** Output tag for an input element, or `null` to unwrap it (keep only its children). */\nfunction resolveTag(el: Element, ctx: Ctx): string | null {\n let tag = el.tagName.toUpperCase();\n if (BLOCK_TO_DIV.has(tag)) tag = 'DIV';\n if (!ALLOWED_TAGS.has(tag)) return null;\n if (ctx.mode === 'paste' && (tag === 'SPAN' || tag === 'FONT')) return null;\n if (ctx.blocked.has(tag)) return ctx.replace[tag] ?? null;\n return tag;\n}\n\n/** Emphasis tags implied by inline styles — only used when pasting, where styles are flattened. */\nfunction impliedTags(el: Element, ctx: Ctx): string[] {\n const out: string[] = [];\n const decls = new Map(parseStyle(el.getAttribute('style') ?? ''));\n const weight = decls.get('font-weight');\n if (weight && (weight === 'bold' || (/^\\d+$/.test(weight) && Number(weight) >= 600))) out.push('B');\n if (decls.get('font-style') === 'italic') out.push('I');\n const deco = decls.get('text-decoration') ?? '';\n if (/\\bunderline\\b/.test(deco)) out.push('U');\n if (/\\bline-through\\b/.test(deco)) out.push('S');\n return out.filter(t => !ctx.blocked.has(t));\n}\n\nfunction copyAttributes(src: Element, dest: Element, tag: string, ctx: Ctx): void {\n if (ctx.mode === 'paste') {\n if (tag === 'A') setLinkAttributes(src, dest);\n return;\n }\n const style = filterStyle(src.getAttribute('style') ?? '');\n if (style) dest.setAttribute('style', style);\n const align = src.getAttribute('align')?.toLowerCase();\n if (align && /^(left|right|center|justify)$/.test(align)) dest.setAttribute('align', align);\n if (tag === 'A') setLinkAttributes(src, dest);\n if (tag === 'FONT') {\n const face = src.getAttribute('face');\n if (face && /^[\\w\\s,'\"-]+$/.test(face)) dest.setAttribute('face', face);\n const size = src.getAttribute('size');\n if (size && /^[+-]?\\d$/.test(size)) dest.setAttribute('size', size);\n const color = src.getAttribute('color');\n if (color && COLOR.test(color)) dest.setAttribute('color', color);\n }\n}\n\nfunction setLinkAttributes(src: Element, dest: Element): void {\n const href = safeHref(src.getAttribute('href') ?? '');\n if (href) {\n dest.setAttribute('href', href);\n dest.setAttribute('target', '_blank');\n dest.setAttribute('rel', 'noopener noreferrer');\n }\n}\n\nfunction walkChildren(src: Node, dest: Node, ctx: Ctx): void {\n for (const child of Array.from(src.childNodes)) {\n if (child.nodeType === Node.TEXT_NODE) {\n dest.appendChild(ctx.doc.createTextNode(child.nodeValue ?? ''));\n } else if (child.nodeType === Node.ELEMENT_NODE) {\n walkElement(child as Element, dest, ctx);\n }\n }\n}\n\n/**\n * Table handling: every `<tr>` becomes its own `<div>` and the cells of a row are separated by one normal space\n * (tabs would collapse in contenteditable), so a pasted sheet reads as lines. Cells are never emitted as elements and\n * `<table>`/`<thead>`/`<tbody>`/`<tfoot>` are unwrapped; `<caption>` becomes a block of its own. Empty or\n * whitespace-only cells add no separator (a separator only sits between cells that have content), so the output has no\n * leading, trailing or doubled spaces and sanitising it again changes nothing. A cell's own edge whitespace is trimmed.\n * Inline emphasis on a cell (paste mode: bold/italic styles) is kept; `<th>` is not bolded on its own.\n */\nfunction walkRow(el: Element, dest: Node, ctx: Ctx): void {\n const rowTag = ctx.blocked.has('DIV') ? (ctx.replace['DIV'] ?? null) : 'DIV';\n const row: Node = rowTag ? ctx.doc.createElement(rowTag) : ctx.doc.createDocumentFragment();\n let first = true;\n for (const cell of Array.from(el.children)) {\n const t = cell.tagName.toUpperCase();\n if (t !== 'TD' && t !== 'TH') { walkElement(cell, row, ctx); continue; }\n const holder = ctx.doc.createElement('div');\n let target: Node = holder;\n if (ctx.mode === 'paste') {\n for (const wrap of impliedTags(cell, ctx)) {\n const w = ctx.doc.createElement(wrap);\n target.appendChild(w);\n target = w;\n }\n }\n walkChildren(cell, target, ctx);\n if (holder.firstChild?.nodeType === Node.TEXT_NODE) holder.firstChild.nodeValue = (holder.firstChild.nodeValue ?? '').trimStart();\n if (holder.lastChild?.nodeType === Node.TEXT_NODE) holder.lastChild.nodeValue = (holder.lastChild.nodeValue ?? '').trimEnd();\n if (!(holder.textContent ?? '').trim()) continue;\n if (!first) row.appendChild(ctx.doc.createTextNode(' '));\n first = false;\n while (holder.firstChild) row.appendChild(holder.firstChild);\n }\n if (!row.firstChild) return;\n // With no block element available for rows, a <br> still keeps the rows on separate lines.\n if (!rowTag) row.appendChild(ctx.doc.createElement('br'));\n dest.appendChild(row);\n}\n\nfunction walkElement(el: Element, dest: Node, ctx: Ctx): void {\n const original = el.tagName.toUpperCase();\n if (DROP_WITH_CONTENT.has(original)) return;\n if (original === 'TR') { walkRow(el, dest, ctx); return; }\n\n let tag = resolveTag(el, ctx);\n // A list item whose own list type is blocked has no list left to live in.\n if (tag === 'LI' && el.parentElement) {\n const parent = el.parentElement.tagName.toUpperCase();\n if ((parent === 'UL' || parent === 'OL') && ctx.blocked.has(parent)) tag = 'DIV';\n }\n\n let target: Node = dest;\n if (ctx.mode === 'paste') {\n for (const wrap of impliedTags(el, ctx)) {\n const w = ctx.doc.createElement(wrap);\n target.appendChild(w);\n target = w;\n }\n }\n if (tag) {\n const out = ctx.doc.createElement(tag);\n copyAttributes(el, out, tag, ctx);\n target.appendChild(out);\n target = out;\n }\n if (tag === 'BR') return;\n walkChildren(el, target, ctx);\n}\n\n/** Returns `html` reduced to the allow-list. Empty input returns an empty string. */\nexport function sanitizeRichTextHtml(html: string | null | undefined, options: RichTextSanitizeOptions = {}): string {\n if (!html) return '';\n const parsed = new DOMParser().parseFromString(`<body>${html}</body>`, 'text/html');\n const ctx: Ctx = {\n doc: parsed,\n mode: options.mode ?? 'content',\n blocked: options.blockedTags ?? new Set<string>(),\n replace: options.replace ?? {},\n };\n const out = parsed.createElement('body');\n walkChildren(parsed.body, out, ctx);\n return out.innerHTML;\n}\n\n/**\n * A web address typed into a link box, made safe to link to: `example.com` becomes `https://example.com`; `http`, `https`, `mailto` and `tel`\n * addresses are kept. Anything else (`javascript:`, `data:`, an address with spaces, nothing) returns null.\n */\nexport function normalizeLinkUrl(raw: string | null | undefined): string | null {\n const text = (raw ?? '').trim();\n if (!text || /\\s/.test(text)) return null;\n if (/^(https?:\\/\\/|mailto:|tel:)\\S+$/i.test(text)) return text;\n if (/^[a-z][a-z0-9+.-]*:/i.test(text) || /^[\\/\\\\]{2}/.test(text)) return null;\n return /^[^\\s/@]+\\.[^\\s/@]+/.test(text) ? `https://${text}` : null;\n}\n\n/** Escapes plain text for HTML, turning line breaks into `<br>`. */\nexport function plainTextToHtml(text: string): string {\n return text\n .replace(/\\r\\n?/g, '\\n')\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\\n/g, '<br>');\n}\n","import {\n Component, ChangeDetectionStrategy, ElementRef, computed, forwardRef, input, signal, viewChild, afterNextRender, inject, } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { normalizeLinkUrl, plainTextToHtml, sanitizeRichTextHtml } from './rich-text-sanitizer';\nimport { UiLabelsService, UiLabelKey } from '@forgeroute/ui/core';\nimport { createFieldReveal } from '@forgeroute/ui/core';\n\n/**\n * Every toolbar control of `ui-rich-text-editor`. All are shown by default; pass any of them in\n * `hide` to remove just that control (a whole group, and its divider, disappears once all of its\n * controls are hidden).\n *\n * Groups, left to right: `bold italic underline strikethrough` | `heading fontSize fontFamily` |\n * `textColor highlight` | `align` | `bulletList numberedList indent outdent` | `clearFormat`.\n * `align` is the three alignment buttons (left, center, right) as one option.\n */\nexport type RichTextOption =\n | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'link'\n | 'heading' | 'fontSize' | 'fontFamily'\n | 'textColor' | 'highlight'\n | 'align'\n | 'bulletList' | 'numberedList' | 'indent' | 'outdent'\n | 'clearFormat';\n\n/** All option keys, in toolbar order. */\nexport const RICH_TEXT_OPTIONS: readonly RichTextOption[] = [\n 'bold', 'italic', 'underline', 'strikethrough', 'link',\n 'heading', 'fontSize', 'fontFamily',\n 'textColor', 'highlight',\n 'align',\n 'bulletList', 'numberedList', 'indent', 'outdent',\n 'clearFormat',\n];\n\ntype GroupId = 'inline' | 'text' | 'color' | 'align' | 'blocks' | 'clear';\ntype MenuId = 'heading' | 'size' | 'font' | 'link';\n\nconst GROUPS: { id: GroupId; options: RichTextOption[] }[] = [\n { id: 'inline', options: ['bold', 'italic', 'underline', 'strikethrough', 'link'] },\n { id: 'text', options: ['heading', 'fontSize', 'fontFamily'] },\n { id: 'color', options: ['textColor', 'highlight'] },\n { id: 'align', options: ['align'] },\n { id: 'blocks', options: ['bulletList', 'numberedList', 'indent', 'outdent'] },\n { id: 'clear', options: ['clearFormat'] },\n];\n\n/** Tags (upper-case) removed from pasted content when the matching option is hidden. */\nconst OPTION_TAGS: Partial<Record<RichTextOption, string[]>> = {\n bold: ['B', 'STRONG'],\n italic: ['I', 'EM'],\n underline: ['U'],\n strikethrough: ['S', 'STRIKE', 'DEL'],\n link: ['A'],\n heading: ['H1', 'H2', 'H3', 'H4'],\n bulletList: ['UL'],\n numberedList: ['OL'],\n indent: ['BLOCKQUOTE'],\n};\n/** Hidden block tags become a plain line instead of vanishing (keeps the text on its own line). */\nconst BLOCK_REPLACEMENT: Record<string, string> = { H1: 'DIV', H2: 'DIV', H3: 'DIV', H4: 'DIV', BLOCKQUOTE: 'DIV' };\n\nconst HEADINGS = [\n { tag: 'p', label: 'Normal', text: 'Normal', cls: '' },\n { tag: 'h1', label: 'H1', text: 'H1 — Heading 1', cls: 'di-h1' },\n { tag: 'h2', label: 'H2', text: 'H2 — Heading 2', cls: 'di-h2' },\n { tag: 'h3', label: 'H3', text: 'H3 — Heading 3', cls: 'di-h3' },\n];\n\nconst SIZES = [\n { value: '1', label: 'Small', px: 11 },\n { value: '3', label: 'Normal', px: 13 },\n { value: '4', label: 'Medium', px: 15 },\n { value: '5', label: 'Large', px: 18 },\n { value: '6', label: 'X-Large', px: 22 },\n { value: '7', label: 'Huge', px: 26 },\n];\n\nconst FONT_GROUPS = [\n { label: 'Default', fonts: [{ value: 'inherit', label: 'Default', preview: 'inherit' }] },\n { label: 'Serif', fonts: [\n { value: 'Lora, Georgia, serif', label: 'Lora', preview: 'Georgia, serif' },\n { value: 'Cormorant Garamond, serif', label: 'Cormorant Garamond', preview: 'Georgia, serif' },\n { value: 'Georgia, serif', label: 'Georgia', preview: 'Georgia, serif' },\n { value: 'Palatino Linotype, Palatino, serif', label: 'Palatino', preview: 'Palatino, serif' },\n { value: 'Times New Roman, Times, serif', label: 'Times New Roman', preview: \"'Times New Roman', serif\" },\n { value: 'Garamond, serif', label: 'Garamond', preview: 'Garamond, serif' },\n { value: 'Book Antiqua, Palatino, serif', label: 'Book Antiqua', preview: 'Palatino, serif' },\n ] },\n { label: 'Sans-Serif', fonts: [\n { value: 'Lato, sans-serif', label: 'Lato', preview: 'Arial, sans-serif' },\n { value: 'Inter, sans-serif', label: 'Inter', preview: 'Arial, sans-serif' },\n { value: 'Arial, Helvetica, sans-serif', label: 'Arial', preview: 'Arial, sans-serif' },\n { value: 'Helvetica Neue, Helvetica, sans-serif', label: 'Helvetica', preview: 'Helvetica, Arial, sans-serif' },\n { value: 'Open Sans, sans-serif', label: 'Open Sans', preview: 'Arial, sans-serif' },\n { value: 'Montserrat, sans-serif', label: 'Montserrat', preview: 'Arial, sans-serif' },\n { value: 'Raleway, sans-serif', label: 'Raleway', preview: 'Arial, sans-serif' },\n { value: 'Nunito, sans-serif', label: 'Nunito', preview: 'Arial, sans-serif' },\n { value: 'Poppins, sans-serif', label: 'Poppins', preview: 'Arial, sans-serif' },\n { value: 'Verdana, Geneva, sans-serif', label: 'Verdana', preview: 'Verdana, sans-serif' },\n { value: 'Tahoma, Geneva, sans-serif', label: 'Tahoma', preview: 'Tahoma, sans-serif' },\n { value: 'Trebuchet MS, Helvetica, sans-serif', label: 'Trebuchet MS', preview: \"'Trebuchet MS', sans-serif\" },\n ] },\n { label: 'Monospace', fonts: [\n { value: 'Courier New, Courier, monospace', label: 'Courier New', preview: \"'Courier New', monospace\" },\n { value: 'Lucida Console, Monaco, monospace', label: 'Lucida Console', preview: 'Monaco, monospace' },\n ] },\n { label: 'Display', fonts: [\n { value: 'Impact, Charcoal, sans-serif', label: 'Impact', preview: 'Impact, sans-serif' },\n { value: 'Comic Sans MS, cursive', label: 'Comic Sans', preview: \"'Comic Sans MS', cursive\" },\n ] },\n];\n\n/** Commands whose on/off state is mirrored with `aria-pressed`. */\nconst STATE_COMMANDS = [\n 'bold', 'italic', 'underline', 'strikeThrough',\n 'insertUnorderedList', 'insertOrderedList',\n 'justifyLeft', 'justifyCenter', 'justifyRight',\n] as const;\n\nlet nextId = 0;\n\n@Component({\n selector: 'ui-rich-text-editor',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [{\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => RichTextEditorComponent),\n multi: true,\n }],\n host: {\n '(document:click)': 'onDocumentClick()',\n '(document:selectionchange)': 'onSelectionChange()',\n },\n template: `\n <div class=\"rte-field\" [class.rte-error]=\"_activeError()\" [class.rte-disabled]=\"disabled()\">\n @if (label()) {\n <label class=\"rte-label\" [id]=\"_labelId\" (click)=\"focus()\">\n {{ label() }}\n @if (required()) { <span class=\"rte-required\" aria-hidden=\"true\">*</span> }\n @if (hint()) { <span class=\"rte-hint-inline\">({{ hint() }})</span> }\n </label>\n }\n\n <div class=\"rte-box\">\n @if (toolbarVisible()) {\n <div class=\"rte-toolbar\" role=\"toolbar\" [attr.aria-label]=\"labels.t('richTextEditor.textFormatting')\" [attr.aria-controls]=\"_editorId\"\n (mousedown)=\"onToolbarMouseDown($event)\">\n @if (show('bold') || show('italic') || show('underline') || show('strikethrough') || show('link')) {\n @if (show('bold')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"bold\" [class.active]=\"active()['bold']\"\n [attr.aria-pressed]=\"active()['bold']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.bold')\" [attr.title]=\"labels.t('richTextEditor.boldCtrlB')\" (click)=\"exec('bold')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"3\"><path d=\"M6 4h8a4 4 0 014 4 4 4 0 01-4 4H6z\"/><path d=\"M6 12h9a4 4 0 014 4 4 4 0 01-4 4H6z\"/></svg>\n </button>\n }\n @if (show('italic')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"italic\" [class.active]=\"active()['italic']\"\n [attr.aria-pressed]=\"active()['italic']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.italic')\" [attr.title]=\"labels.t('richTextEditor.italicCtrlI')\" (click)=\"exec('italic')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/></svg>\n </button>\n }\n @if (show('underline')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"underline\" [class.active]=\"active()['underline']\"\n [attr.aria-pressed]=\"active()['underline']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.underline')\" [attr.title]=\"labels.t('richTextEditor.underlineCtrlU')\" (click)=\"exec('underline')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M6 3v7a6 6 0 006 6 6 6 0 006-6V3\"/><line x1=\"4\" y1=\"21\" x2=\"20\" y2=\"21\"/></svg>\n </button>\n }\n @if (show('strikethrough')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"strikethrough\" [class.active]=\"active()['strikeThrough']\"\n [attr.aria-pressed]=\"active()['strikeThrough']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.strikethrough')\" [attr.title]=\"labels.t('richTextEditor.strikethrough')\" (click)=\"exec('strikeThrough')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\"/><path d=\"M6 4h8a4 4 0 010 8H6\"/><path d=\"M10 12v8\"/></svg>\n </button>\n }\n @if (show('link')) {\n <span class=\"rte-menu-wrap\" (click)=\"$event.stopPropagation()\">\n <button type=\"button\" class=\"rte-btn rte-menu-btn\" data-option=\"link\" [class.active]=\"openMenu() === 'link'\"\n [disabled]=\"inert()\" [attr.aria-label]=\"labels.t('common.link')\" [attr.title]=\"labels.t('common.link')\"\n aria-haspopup=\"dialog\" [attr.aria-expanded]=\"openMenu() === 'link'\" (click)=\"toggleLink()\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71\"/></svg>\n </button>\n @if (openMenu() === 'link') {\n <div class=\"rte-dropdown rte-link-panel\" role=\"dialog\" [attr.aria-label]=\"labels.t('common.link')\" (keydown.escape)=\"closeLink()\">\n <label class=\"rte-link-label\" [for]=\"_linkId\">{{ labels.t('richTextEditor.webAddress') }}</label>\n <input class=\"rte-link-input\" type=\"url\" inputmode=\"url\" autocomplete=\"off\" spellcheck=\"false\" placeholder=\"example.com\"\n [id]=\"_linkId\" [value]=\"linkUrl()\" [attr.aria-invalid]=\"linkError() ? 'true' : null\"\n [attr.aria-describedby]=\"linkError() ? _linkId + '-error' : null\"\n (input)=\"linkUrl.set($any($event.target).value); linkError.set('')\" (keydown.enter)=\"$event.preventDefault(); applyLink()\" />\n @if (linkError()) { <p class=\"rte-link-error\" role=\"alert\" [id]=\"_linkId + '-error'\">{{ linkError() }}</p> }\n <div class=\"rte-link-actions\">\n <button type=\"button\" class=\"rte-link-btn rte-link-apply\" data-testid=\"rte-link-apply\" (click)=\"applyLink()\">{{ labels.t('common.apply') }}</button>\n @if (hasLink()) { <button type=\"button\" class=\"rte-link-btn\" data-testid=\"rte-link-remove\" (click)=\"removeLink()\">{{ labels.t('richTextEditor.removeLink') }}</button> }\n </div>\n </div>\n }\n </span>\n }\n }\n\n @if (divider()['text']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('heading')) {\n <span class=\"rte-menu-wrap\" (click)=\"$event.stopPropagation()\">\n <button type=\"button\" class=\"rte-btn rte-menu-btn\" data-option=\"heading\" [class.active]=\"openMenu() === 'heading'\"\n [disabled]=\"inert()\" [attr.aria-label]=\"labels.t('richTextEditor.headingStyle')\" [attr.title]=\"labels.t('richTextEditor.headingStyle2')\"\n aria-haspopup=\"menu\" [attr.aria-expanded]=\"openMenu() === 'heading'\" (click)=\"toggleMenu('heading')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M4 6h16M4 12h16M4 18h10\"/></svg>\n <svg class=\"rte-chevron\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\"><polyline points=\"6 9 12 15 18 9\"/></svg>\n </button>\n @if (openMenu() === 'heading') {\n <div class=\"rte-dropdown\" role=\"menu\" [attr.aria-label]=\"labels.t('richTextEditor.headingStyle')\" style=\"min-width:130px\">\n @for (h of headings; track h.tag) {\n <button type=\"button\" role=\"menuitemradio\" class=\"rte-item\" [class]=\"h.cls\"\n [class.selected]=\"activeHeading() === h.label\" [attr.aria-checked]=\"activeHeading() === h.label\"\n (click)=\"selectHeading(h.tag, h.label)\">{{ headingText(h.tag) }}</button>\n }\n </div>\n }\n </span>\n }\n @if (show('fontSize')) {\n <span class=\"rte-menu-wrap\" (click)=\"$event.stopPropagation()\">\n <button type=\"button\" class=\"rte-btn rte-menu-btn\" data-option=\"fontSize\" [class.active]=\"openMenu() === 'size'\"\n [disabled]=\"inert()\" [attr.aria-label]=\"labels.t('richTextEditor.fontSize')\" [attr.title]=\"labels.t('richTextEditor.fontSize2')\"\n aria-haspopup=\"menu\" [attr.aria-expanded]=\"openMenu() === 'size'\" (click)=\"toggleMenu('size')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><text x=\"2\" y=\"17\" font-size=\"14\" fill=\"currentColor\" stroke=\"none\" font-weight=\"bold\">T</text><text x=\"13\" y=\"20\" font-size=\"9\" fill=\"currentColor\" stroke=\"none\">T</text></svg>\n <svg class=\"rte-chevron\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\"><polyline points=\"6 9 12 15 18 9\"/></svg>\n </button>\n @if (openMenu() === 'size') {\n <div class=\"rte-dropdown\" role=\"menu\" [attr.aria-label]=\"labels.t('richTextEditor.fontSize')\" style=\"min-width:110px\">\n @for (s of sizes; track s.value) {\n <button type=\"button\" role=\"menuitemradio\" class=\"rte-item\"\n [class.selected]=\"activeFontSize() === s.label\" [attr.aria-checked]=\"activeFontSize() === s.label\"\n (click)=\"selectSize(s.value, s.label)\"><span [style.font-size.px]=\"s.px\">{{ sizeText(s.value) }}</span></button>\n }\n </div>\n }\n </span>\n }\n @if (show('fontFamily')) {\n <span class=\"rte-menu-wrap\" (click)=\"$event.stopPropagation()\">\n <button type=\"button\" class=\"rte-btn rte-menu-btn\" data-option=\"fontFamily\" [class.active]=\"openMenu() === 'font'\"\n [disabled]=\"inert()\" [attr.aria-label]=\"labels.t('richTextEditor.fontFamily')\" [attr.title]=\"labels.t('richTextEditor.fontFamily2')\"\n aria-haspopup=\"menu\" [attr.aria-expanded]=\"openMenu() === 'font'\" (click)=\"toggleMenu('font')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><text x=\"1\" y=\"18\" font-size=\"18\" fill=\"currentColor\" stroke=\"none\" font-weight=\"600\" font-style=\"italic\">{{ labels.t('richTextEditor.aa') }}</text></svg>\n <svg class=\"rte-chevron\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\"><polyline points=\"6 9 12 15 18 9\"/></svg>\n </button>\n @if (openMenu() === 'font') {\n <div class=\"rte-dropdown rte-font-panel\" role=\"menu\" [attr.aria-label]=\"labels.t('richTextEditor.fontFamily')\">\n @for (g of fontGroups; track g.label) {\n <div class=\"rte-group-label\" role=\"presentation\">{{ fontGroupText(g.label) }}</div>\n @for (f of g.fonts; track f.label) {\n <button type=\"button\" role=\"menuitemradio\" class=\"rte-item\"\n [class.selected]=\"activeFont() === f.label\" [attr.aria-checked]=\"activeFont() === f.label\"\n [style.font-family]=\"f.preview\" (click)=\"selectFont(f.value, f.label)\">{{ fontText(f) }}</button>\n }\n }\n </div>\n }\n </span>\n }\n\n @if (divider()['color']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('textColor')) {\n <label class=\"rte-btn\" data-option=\"textColor\" [attr.title]=\"labels.t('richTextEditor.textColor')\" [class.rte-btn-disabled]=\"inert()\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M4 20h16M12 4L6 18M12 4l6 14M8.5 13h7\"/></svg>\n <input type=\"color\" class=\"rte-color\" [attr.aria-label]=\"labels.t('richTextEditor.textColor2')\" value=\"#000000\" [disabled]=\"inert()\"\n (input)=\"execWithArg('foreColor', $any($event.target).value)\" />\n </label>\n }\n @if (show('highlight')) {\n <label class=\"rte-btn\" data-option=\"highlight\" [attr.title]=\"labels.t('richTextEditor.highlightColor')\" [class.rte-btn-disabled]=\"inert()\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M15.24 2.58a1 1 0 00-1.41 0L5.59 10.82a2 2 0 000 2.83l4.24 4.24L8.41 19.3a1 1 0 001.42 1.41l1.41-1.41 1.06 1.06a1 1 0 001.42 0l8-8a1 1 0 000-1.42l-6.48-6.36zM7 13.65l3.54-3.54 3.54 3.54-3.54 3.53L7 13.65z\" opacity=\".4\"/><path d=\"M10.54 10.11l3.54-3.54 3.53 3.54-3.53 3.53-3.54-3.53z\"/></svg>\n <input type=\"color\" class=\"rte-color\" [attr.aria-label]=\"labels.t('richTextEditor.highlightColor2')\" value=\"#ffff00\" [disabled]=\"inert()\"\n (input)=\"execWithArg('hiliteColor', $any($event.target).value)\" />\n </label>\n }\n\n @if (divider()['align']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('align')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"align-left\" [class.active]=\"active()['justifyLeft']\"\n [attr.aria-pressed]=\"active()['justifyLeft']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.alignLeft')\" [attr.title]=\"labels.t('richTextEditor.alignLeft2')\" (click)=\"exec('justifyLeft')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"3\" y1=\"12\" x2=\"15\" y2=\"12\"/><line x1=\"3\" y1=\"18\" x2=\"18\" y2=\"18\"/></svg>\n </button>\n <button type=\"button\" class=\"rte-btn\" data-option=\"align-center\" [class.active]=\"active()['justifyCenter']\"\n [attr.aria-pressed]=\"active()['justifyCenter']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.alignCenter')\" [attr.title]=\"labels.t('richTextEditor.alignCenter2')\" (click)=\"exec('justifyCenter')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"6\" y1=\"12\" x2=\"18\" y2=\"12\"/><line x1=\"4\" y1=\"18\" x2=\"20\" y2=\"18\"/></svg>\n </button>\n <button type=\"button\" class=\"rte-btn\" data-option=\"align-right\" [class.active]=\"active()['justifyRight']\"\n [attr.aria-pressed]=\"active()['justifyRight']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.alignRight')\" [attr.title]=\"labels.t('richTextEditor.alignRight2')\" (click)=\"exec('justifyRight')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"9\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"6\" y1=\"18\" x2=\"21\" y2=\"18\"/></svg>\n </button>\n }\n\n @if (divider()['blocks']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('bulletList')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"bulletList\" [class.active]=\"active()['insertUnorderedList']\"\n [attr.aria-pressed]=\"active()['insertUnorderedList']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.bulletList')\" [attr.title]=\"labels.t('richTextEditor.bulletList2')\" (click)=\"exec('insertUnorderedList')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"9\" y1=\"6\" x2=\"20\" y2=\"6\"/><line x1=\"9\" y1=\"12\" x2=\"20\" y2=\"12\"/><line x1=\"9\" y1=\"18\" x2=\"20\" y2=\"18\"/><circle cx=\"5\" cy=\"6\" r=\"1.5\" fill=\"currentColor\"/><circle cx=\"5\" cy=\"12\" r=\"1.5\" fill=\"currentColor\"/><circle cx=\"5\" cy=\"18\" r=\"1.5\" fill=\"currentColor\"/></svg>\n </button>\n }\n @if (show('numberedList')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"numberedList\" [class.active]=\"active()['insertOrderedList']\"\n [attr.aria-pressed]=\"active()['insertOrderedList']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.numberedList')\" [attr.title]=\"labels.t('richTextEditor.numberedList2')\" (click)=\"exec('insertOrderedList')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"10\" y1=\"6\" x2=\"20\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"20\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"20\" y2=\"18\"/><text x=\"3\" y=\"8\" font-size=\"8\" fill=\"currentColor\" stroke=\"none\" font-weight=\"bold\">1</text><text x=\"3\" y=\"14\" font-size=\"8\" fill=\"currentColor\" stroke=\"none\" font-weight=\"bold\">2</text><text x=\"3\" y=\"20\" font-size=\"8\" fill=\"currentColor\" stroke=\"none\" font-weight=\"bold\">3</text></svg>\n </button>\n }\n @if (show('indent')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"indent\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.indent')\" [attr.title]=\"labels.t('richTextEditor.indent')\" (click)=\"exec('indent')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\"/><polyline points=\"9 8 13 12 9 16\"/><line x1=\"3\" y1=\"12\" x2=\"13\" y2=\"12\"/></svg>\n </button>\n }\n @if (show('outdent')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"outdent\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.outdent')\" [attr.title]=\"labels.t('richTextEditor.outdent')\" (click)=\"exec('outdent')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\"/><polyline points=\"7 8 3 12 7 16\"/><line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\"/></svg>\n </button>\n }\n\n @if (divider()['clear']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('clearFormat')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"clearFormat\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.clearFormatting')\" [attr.title]=\"labels.t('richTextEditor.clearFormatting2')\" (click)=\"exec('removeFormat')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M4 7h16M6 4h8a2 2 0 012 2v0a2 2 0 01-2 2H6\"/><line x1=\"4\" y1=\"20\" x2=\"20\" y2=\"4\" stroke-width=\"1.5\"/></svg>\n </button>\n }\n </div>\n }\n\n <div\n #editor\n class=\"rte-editor\"\n [id]=\"_editorId\"\n [attr.contenteditable]=\"inert() ? 'false' : 'true'\"\n role=\"textbox\"\n aria-multiline=\"true\"\n [attr.aria-label]=\"label() ? null : (ariaLabel() || placeholder() || labels.t('richTextEditor.editorName'))\"\n [attr.aria-labelledby]=\"label() ? _labelId : null\"\n [attr.aria-required]=\"required() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"_activeError() ? 'true' : null\"\n [attr.aria-describedby]=\"_activeError() ? _errorId : null\"\n [attr.data-placeholder]=\"placeholder()\"\n [attr.data-empty]=\"empty() ? 'true' : null\"\n [style.min-height.px]=\"minHeight()\"\n [style.max-height.px]=\"maxHeight()\"\n (input)=\"onInput()\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\"\n (keyup)=\"refreshActive()\"\n (mouseup)=\"refreshActive()\"\n (blur)=\"onBlur()\"\n ></div>\n </div>\n\n @if (_activeError()) {\n <p class=\"rte-desc rte-desc-error\" [id]=\"_errorId\" role=\"alert\">{{ _activeError() }}</p>\n }\n </div>\n `,\n styles: [`\n :host { display: block; }\n\n .rte-field { display: flex; flex-direction: column; gap: 6px; }\n\n .rte-label { font-size: 0.8125rem; font-weight: 600; color: #374151; line-height: 1; }\n .rte-required { color: #dc2626; margin-left: 2px; }\n .rte-hint-inline { font-size: 0.75rem; color: #94a3b8; font-weight: 400; margin-left: 4px; }\n\n .rte-box {\n border: 1px solid #7c8ba1; border-radius: 8px; background: #fff;\n transition: border-color 0.15s, box-shadow 0.15s;\n }\n .rte-box:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12); }\n .rte-error .rte-box { border-color: #ef4444; }\n .rte-error .rte-box:focus-within { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12); }\n .rte-disabled .rte-box { opacity: 0.5; cursor: not-allowed; }\n\n .rte-toolbar {\n display: flex; flex-wrap: wrap; align-items: center; gap: 2px;\n padding: 6px 8px; background: #f8fafc;\n border-bottom: 1px solid #e2e8f0; border-radius: 8px 8px 0 0;\n }\n .rte-divider { width: 1px; height: 20px; background: #cbd5e1; margin: 0 4px; }\n\n .rte-btn {\n position: relative;\n display: inline-flex; align-items: center; justify-content: center;\n width: 28px; height: 28px; padding: 0; border: none; border-radius: 4px;\n background: none; color: #64748b; cursor: pointer; transition: background 0.15s, color 0.15s;\n }\n .rte-btn svg { width: 16px; height: 16px; }\n .rte-btn:hover:not(:disabled) { background: #e2e8f0; color: #1e293b; }\n .rte-btn:focus-visible, .rte-btn:focus-within { outline: 2px solid #3b82f6; outline-offset: 1px; }\n .rte-btn.active { background: #dbeafe; color: #2563eb; }\n .rte-btn:disabled, .rte-btn-disabled { cursor: not-allowed; opacity: 0.5; }\n\n .rte-menu-wrap { position: relative; display: inline-flex; }\n .rte-menu-btn { width: auto; padding: 0 6px; gap: 3px; }\n .rte-menu-btn .rte-chevron { width: 10px; height: 10px; color: #64748b; flex-shrink: 0; }\n\n .rte-dropdown {\n position: absolute; top: calc(100% + 4px); left: 0; z-index: 100;\n background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); padding: 4px;\n overflow-y: auto; max-height: 260px;\n }\n .rte-font-panel { min-width: 180px; }\n .rte-link-panel { display: flex; flex-direction: column; gap: 6px; min-width: 240px; padding: 10px; overflow: visible; }\n .rte-link-label { font-size: 12px; font-weight: 600; color: #374151; }\n .rte-link-input { box-sizing: border-box; width: 100%; padding: 6px 8px; font: inherit; font-size: 14px; border: 1px solid #cbd5e1; border-radius: 6px; }\n .rte-link-input:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }\n .rte-link-error { margin: 0; font-size: 12px; color: #dc2626; }\n .rte-link-actions { display: flex; gap: 6px; }\n .rte-link-btn { padding: 5px 10px; font-size: 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #374151; cursor: pointer; }\n .rte-link-apply { background: #2563eb; border-color: #2563eb; color: #fff; }\n .rte-item {\n display: block; width: 100%; text-align: left; padding: 5px 10px;\n font-size: 12px; color: #374151; border: none; background: none;\n border-radius: 4px; cursor: pointer; white-space: nowrap;\n }\n .rte-item:hover { background: #f1f5f9; }\n .rte-item.selected { background: #dbeafe; color: #2563eb; font-weight: 600; }\n .rte-group-label {\n font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;\n color: #94a3b8; padding: 6px 10px 2px;\n }\n .di-h1 { font-size: 18px; font-weight: 700; }\n .di-h2 { font-size: 15px; font-weight: 600; }\n .di-h3 { font-size: 13px; font-weight: 600; }\n\n .rte-color { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }\n\n .rte-editor {\n padding: 12px; outline: none; overflow-y: auto; box-sizing: border-box;\n font-size: 0.875rem; line-height: 1.6; color: #1e293b; background: #fff;\n border-radius: 0 0 8px 8px; word-break: break-word;\n }\n .rte-editor[data-empty=\"true\"]::before {\n content: attr(data-placeholder); color: #64748b; pointer-events: none; float: left; height: 0;\n }\n .rte-editor ul, .rte-editor ol { padding-left: 1.5em; margin: 0.25em 0; }\n .rte-editor li { margin: 0.15em 0; }\n .rte-editor h1 { font-size: 1.75em; font-weight: 700; margin: 0.5em 0 0.25em; }\n .rte-editor h2 { font-size: 1.4em; font-weight: 600; margin: 0.5em 0 0.25em; }\n .rte-editor h3 { font-size: 1.15em; font-weight: 600; margin: 0.5em 0 0.25em; }\n .rte-editor a { color: #2563eb; text-decoration: underline; }\n\n .rte-desc { margin: 0; font-size: 0.75rem; line-height: 1.4; color: #64748b; }\n .rte-desc-error { color: #dc2626; }\n\n @media (max-width: 480px) { .rte-editor { font-size: 1rem; } }\n\n /* Touch targets: toolbar buttons are >= 44px on touch devices and phones (desktop unchanged). */\n @media (pointer: coarse), (max-width: 480px) {\n .rte-btn { width: 44px; height: 44px; }\n .rte-menu-btn { width: auto; min-width: 44px; }\n .rte-divider { height: 28px; }\n }\n `],\n})\nexport class RichTextEditorComponent implements ControlValueAccessor {\n protected readonly labels = inject(UiLabelsService);\n readonly label = input('');\n /** Accessible name for an editor with no visible label. */\n readonly ariaLabel = input('');\n readonly placeholder = input('');\n readonly required = input(false);\n readonly readonly = input(false);\n readonly hint = input('');\n /** Host error message. Shown (with the red state, aria-invalid and aria-describedby) after the user left the editor (blur) or while `showErrors` is true. */\n readonly error = input('');\n /** True once the user left the editor. */\n /** The host's \"tried to submit\" flag (e.g. after a failed Save click): `true` shows the host `error` at once, even before the user touched the field; switching it from true back to false forgets the interaction (closing the form leaves no red field). */\n readonly showErrors = input(false);\n private readonly _reveal = createFieldReveal(this.showErrors);\n protected readonly _touched = this._reveal.touched;\n protected readonly _activeError = computed(() => this._reveal.revealed() ? this.error() : '');\n /** Forgets that the user left the editor (call it when the host resets its form): a host `error` is hidden again until the next blur. Same method on ui-signature-pad and ui-multi-select. */\n resetTouched(): void { this._touched.set(false); }\n /** Minimum editor height in px. */\n readonly minHeight = input(200);\n /** Maximum editor height in px; taller content scrolls. */\n readonly maxHeight = input(600);\n /** Toolbar controls to remove. Everything is shown by default. */\n readonly hide = input<RichTextOption[]>([]);\n\n readonly _disabledInput = input(false, { alias: 'disabled' });\n private readonly _cvaDisabled = signal(false);\n protected readonly disabled = computed(() => this._disabledInput() || this._cvaDisabled());\n /** Disabled or read-only: the editor is not editable and every toolbar control is disabled. */\n protected readonly inert = computed(() => this.disabled() || this.readonly());\n\n private readonly editor = viewChild<ElementRef<HTMLDivElement>>('editor');\n\n protected readonly _id = ++nextId;\n protected readonly _editorId = `rte-${this._id}`;\n protected readonly _labelId = `rte-${this._id}-label`;\n protected readonly _errorId = `rte-${this._id}-error`;\n\n protected readonly headings = HEADINGS;\n protected readonly sizes = SIZES;\n protected readonly fontGroups = FONT_GROUPS;\n\n /** Display texts of the option menus (the English `label`s stay the stable identity of the choice). */\n protected headingText(tag: string): string { return this.labels.t(`richTextEditor.heading.${tag}` as UiLabelKey); }\n protected sizeText(value: string): string { return this.labels.t(`richTextEditor.size.${value}` as UiLabelKey); }\n protected fontGroupText(label: string): string { return this.labels.t(`richTextEditor.fontGroup.${label}` as UiLabelKey); }\n protected fontText(font: { value: string; label: string }): string { return font.value === 'inherit' ? this.labels.t('richTextEditor.fontDefault') : font.label; }\n\n protected readonly openMenu = signal<MenuId | null>(null);\n protected readonly activeHeading = signal('Normal');\n protected readonly activeFontSize = signal('Normal');\n protected readonly activeFont = signal('Default');\n protected readonly active = signal<Record<string, boolean>>(Object.fromEntries(STATE_COMMANDS.map(c => [c, false])));\n protected readonly empty = signal(true);\n protected readonly linkUrl = signal('');\n protected readonly linkError = signal('');\n protected readonly hasLink = signal(false);\n protected readonly _linkId = `rte-${++nextId}-link`;\n\n private readonly hidden = computed(() => new Set<RichTextOption>(this.hide()));\n\n /** Group id → at least one of its controls is shown. */\n private readonly groupVisible = computed(() => {\n const hidden = this.hidden();\n const out: Record<string, boolean> = {};\n for (const g of GROUPS) out[g.id] = g.options.some(o => !hidden.has(o));\n return out;\n });\n protected readonly toolbarVisible = computed(() => Object.values(this.groupVisible()).some(Boolean));\n /** Group id → a divider belongs in front of it (it is visible and an earlier group is too). */\n protected readonly divider = computed(() => {\n const visible = this.groupVisible();\n const out: Record<string, boolean> = {};\n let seen = false;\n for (const g of GROUPS) {\n out[g.id] = visible[g.id] && seen;\n seen = seen || visible[g.id];\n }\n return out;\n });\n\n private _lastEmitted = '';\n private _pending: string | null = null;\n private _savedRange: Range | null = null;\n\n private _onChange = (_: string) => {};\n private _onTouched = () => {};\n\n constructor() {\n afterNextRender(() => {\n if (this._pending !== null) {\n this._setHtml(this._pending);\n this._pending = null;\n }\n });\n }\n\n protected show(option: RichTextOption): boolean {\n return !this.hidden().has(option);\n }\n\n // ── ControlValueAccessor ────────────────────────────────────────────────\n\n writeValue(val: string | null): void {\n const html = val ?? '';\n if (html === this._lastEmitted) return; // our own change echoed back by ngModel — don't reset the caret\n this._lastEmitted = html;\n this._setHtml(html);\n }\n registerOnChange(fn: (v: string) => void): void { this._onChange = fn; }\n registerOnTouched(fn: () => void): void { this._onTouched = fn; }\n setDisabledState(d: boolean): void { this._cvaDisabled.set(d); }\n\n private _setHtml(html: string): void {\n const el = this.editor()?.nativeElement;\n if (!el) { this._pending = html; return; }\n const clean = sanitizeRichTextHtml(html);\n if (el.innerHTML !== clean) el.innerHTML = clean;\n this.empty.set(this._isEmpty(el));\n }\n\n private _isEmpty(el: HTMLElement): boolean {\n return !(el.textContent ?? '').trim() && !el.querySelector('li, hr, img');\n }\n\n // ── Public helpers ──────────────────────────────────────────────────────\n\n focus(): void {\n this.editor()?.nativeElement.focus();\n }\n\n // ── Events ──────────────────────────────────────────────────────────────\n\n protected onInput(): void {\n const el = this.editor()?.nativeElement;\n if (!el) return;\n const isEmpty = this._isEmpty(el);\n this.empty.set(isEmpty);\n // an emptied editor leaves a stray <br> behind — report it as an empty value\n const html = isEmpty ? '' : el.innerHTML;\n this._lastEmitted = html;\n this._onChange(html);\n }\n\n protected onBlur(): void {\n this._saveSelection();\n this._touched.set(true);\n this._onTouched();\n }\n\n protected onToolbarMouseDown(event: MouseEvent): void {\n // keep the editor's selection when a toolbar button is pressed (colour pickers need the click)\n const target = event.target as HTMLElement;\n if (target.closest('button')) event.preventDefault();\n }\n\n onDocumentClick(): void {\n if (this.openMenu()) this.openMenu.set(null);\n }\n\n onSelectionChange(): void {\n const el = this.editor()?.nativeElement;\n const sel = window.getSelection();\n if (!el || !sel || sel.rangeCount === 0 || !el.contains(sel.anchorNode)) return;\n this.refreshActive();\n }\n\n protected refreshActive(): void {\n if (this.inert()) return;\n const next: Record<string, boolean> = {};\n for (const cmd of STATE_COMMANDS) {\n try { next[cmd] = document.queryCommandState(cmd); } catch { next[cmd] = false; }\n }\n const prev = this.active();\n if (STATE_COMMANDS.some(c => prev[c] !== next[c])) this.active.set(next);\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (!(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey) return;\n const shortcut: Record<string, { option: RichTextOption; command: string }> = {\n b: { option: 'bold', command: 'bold' },\n i: { option: 'italic', command: 'italic' },\n u: { option: 'underline', command: 'underline' },\n };\n const hit = shortcut[event.key.toLowerCase()];\n if (!hit) return;\n // always swallow the browser's own shortcut so a hidden option can't be applied by keyboard\n event.preventDefault();\n if (this.show(hit.option) && !this.inert()) this.exec(hit.command);\n }\n\n protected onPaste(event: ClipboardEvent): void {\n event.preventDefault();\n if (this.inert()) return;\n const data = event.clipboardData;\n if (!data) return;\n const html = data.getData('text/html');\n const text = data.getData('text/plain');\n if (html) {\n const clean = sanitizeRichTextHtml(html, {\n mode: 'paste',\n blockedTags: this._blockedTags(),\n replace: BLOCK_REPLACEMENT,\n });\n document.execCommand('insertHTML', false, clean);\n } else if (text) {\n if (text.includes('\\n') || text.includes('\\r')) document.execCommand('insertHTML', false, plainTextToHtml(text));\n else document.execCommand('insertText', false, text);\n }\n this.onInput();\n }\n\n private _blockedTags(): Set<string> {\n const blocked = new Set<string>();\n for (const option of this.hidden()) for (const tag of OPTION_TAGS[option] ?? []) blocked.add(tag);\n return blocked;\n }\n\n // ── Selection ───────────────────────────────────────────────────────────\n\n private _saveSelection(): void {\n const el = this.editor()?.nativeElement;\n const sel = window.getSelection();\n if (el && sel && sel.rangeCount > 0 && el.contains(sel.anchorNode)) {\n this._savedRange = sel.getRangeAt(0).cloneRange();\n }\n }\n\n private _restoreSelection(): void {\n const el = this.editor()?.nativeElement;\n if (!el) return;\n const sel = window.getSelection();\n const inside = !!sel && sel.rangeCount > 0 && el.contains(sel.anchorNode);\n el.focus();\n if (!inside && this._savedRange && sel) {\n sel.removeAllRanges();\n sel.addRange(this._savedRange);\n }\n }\n\n // ── Commands ────────────────────────────────────────────────────────────\n\n protected toggleMenu(menu: MenuId): void {\n this.openMenu.set(this.openMenu() === menu ? null : menu);\n }\n\n protected selectHeading(tag: string, label: string): void {\n this.activeHeading.set(label);\n this.openMenu.set(null);\n this._restoreSelection();\n document.execCommand('formatBlock', false, tag);\n this.onInput();\n }\n\n protected selectSize(value: string, label: string): void {\n this.activeFontSize.set(label);\n this.openMenu.set(null);\n this.execWithArg('fontSize', value);\n }\n\n protected selectFont(value: string, label: string): void {\n this.activeFont.set(label);\n this.openMenu.set(null);\n this.execWithArg('fontName', value);\n }\n\n /** The `<a>` the saved (or current) selection sits in, if any. */\n private _anchorAtSelection(): HTMLAnchorElement | null {\n const el = this.editor()?.nativeElement;\n const sel = window.getSelection();\n const node = sel && sel.rangeCount > 0 && el?.contains(sel.anchorNode) ? sel.anchorNode : this._savedRange?.startContainer ?? null;\n const base = node && node.nodeType === Node.TEXT_NODE ? node.parentElement : (node as Element | null);\n const a = base?.closest('a') ?? null;\n return a && el?.contains(a) ? a as HTMLAnchorElement : null;\n }\n\n protected toggleLink(): void {\n if (this.openMenu() === 'link') { this.openMenu.set(null); return; }\n this._saveSelection();\n const a = this._anchorAtSelection();\n this.hasLink.set(!!a);\n this.linkUrl.set(a?.getAttribute('href') ?? '');\n this.linkError.set('');\n this.openMenu.set('link');\n }\n\n protected closeLink(): void {\n this.openMenu.set(null);\n this._restoreSelection();\n }\n\n protected applyLink(): void {\n if (this.inert()) return;\n const url = normalizeLinkUrl(this.linkUrl());\n if (!url) { this.linkError.set(this.labels.t('richTextEditor.linkNeedsAddress')); return; }\n this.openMenu.set(null);\n this._restoreSelection();\n const sel = window.getSelection();\n const existing = this._anchorAtSelection();\n if (existing) {\n existing.setAttribute('href', url);\n } else if (!sel || sel.isCollapsed) {\n const text = url.replace(/^(mailto:|tel:|https?:\\/\\/)/i, '');\n document.execCommand('insertHTML', false, `<a href=\"${url.replace(/&/g, '&').replace(/\"/g, '"')}\">${plainTextToHtml(text)}</a>`);\n } else {\n document.execCommand('createLink', false, url);\n }\n this.onInput();\n }\n\n protected removeLink(): void {\n if (this.inert()) return;\n this.openMenu.set(null);\n this._restoreSelection();\n const a = this._anchorAtSelection();\n if (a) {\n const range = document.createRange();\n range.selectNodeContents(a);\n const sel = window.getSelection();\n sel?.removeAllRanges();\n sel?.addRange(range);\n }\n document.execCommand('unlink', false);\n this.onInput();\n }\n\n protected exec(command: string): void {\n if (this.inert()) return;\n this._restoreSelection();\n document.execCommand(command, false);\n this.onInput();\n this.refreshActive();\n }\n\n protected execWithArg(command: string, value: string): void {\n if (!value || this.inert()) return;\n this._restoreSelection();\n document.execCommand(command, false, value);\n this.onInput();\n }\n}\n","import type { EmailTemplateBlockGroup, EmailTemplateVideo } from './email-template-editor.models';\nimport { UiLabelKey, uiText } from '@forgeroute/ui/core';\n\n/** The text a new template's first block starts with: it is a prompt, not content, so a template still holding only this has no message. */\nexport const EMAIL_TEMPLATE_START_TEXT = 'Start writing your email...';\n\n/** Longest message (serialised HTML) the editor accepts by default; hosts pass their own server limit through `maxBodyLength`. */\nexport const EMAIL_TEMPLATE_MAX_BODY = 9_000;\n/** Longest name / subject accepted by default. */\nexport const EMAIL_TEMPLATE_MAX_TEXT = 255;\n\n/** Longest single email address (server rule). */\nexport const MAX_EMAIL_ADDRESS_LENGTH = 254;\n/** One address: no spaces, no second `@`, none of `, ; < > \"`, and a dot in the domain. */\nconst EMAIL_RE = /^[^\\s@,;<>\"]+@[^\\s@,;<>\"]+\\.[^\\s@,;<>\"]+$/;\n/** True for a plausible single email address of at most 254 characters. */\nexport const isValidEmailAddress = (address: string): boolean => address.length <= MAX_EMAIL_ADDRESS_LENGTH && EMAIL_RE.test(address);\n\n/** An http(s) address with a real host: no spaces or quotes (the address is written into an HTML attribute) and a dot or `localhost`. */\nexport function isWebUrl(raw: string): boolean {\n if (/[\\s\"<>]/.test(raw)) return false;\n try {\n const u = new URL(raw);\n return (u.protocol === 'http:' || u.protocol === 'https:') && (u.hostname.includes('.') || u.hostname === 'localhost');\n } catch { return false; }\n}\n\n/**\n * How many characters typed text takes once it is saved, i.e. as `innerHTML` writes a TEXT node: `&`, `<` and `>` become entities and a\n * non-breaking space (what a browser types for a run of spaces) becomes ` `; quotes are not escaped in text, so each counts as one.\n */\nexport function serializedTextLength(text: string): number {\n // By UTF-16 unit, like `String.length` (the body limit is measured the same way): an emoji is two units.\n let n = 0;\n for (let i = 0; i < text.length; i++) { const ch = text[i]; n += ch === '&' ? 5 : ch === '<' || ch === '>' ? 4 : ch === '\\u00A0' ? 6 : 1; }\n return n;\n}\n\n/** Escapes text for HTML text and double-quoted attribute values. */\nexport function escapeHtml(value: string): string {\n return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"').replace(/'/g, ''');\n}\n\nconst CONTENT_MEMO = new Map<string, boolean>();\n\n/** True when a block's HTML shows something to a reader: an image or other media, or text once tags, non-breaking spaces and whitespace are gone. */\nexport function blockHasContent(html: string): boolean {\n const hit = CONTENT_MEMO.get(html);\n if (hit !== undefined) return hit;\n // DOMParser builds an inert document (all four browsers): images in it are never fetched and `onerror` handlers never run, unlike\n // `innerHTML` on a detached element. The answer is a pure function of the HTML, so it is remembered per block text.\n const doc = new DOMParser().parseFromString(html, 'text/html');\n let result: boolean;\n if (doc.querySelector('img, video, iframe')) result = true;\n else {\n const text = (doc.body.textContent ?? '').replace(/ /g, ' ').trim();\n result = text !== '' && text !== EMAIL_TEMPLATE_START_TEXT && text !== uiText('emailTemplateEditor.startWriting');\n }\n if (CONTENT_MEMO.size >= 200) CONTENT_MEMO.clear();\n CONTENT_MEMO.set(html, result);\n return result;\n}\n\n/**\n * The drag payload of a block (a palette item or a block being reordered). A custom type, never `text/plain`: a text drop onto a block's\n * contenteditable would insert the payload into the message in every engine. Firefox only starts a drag when some data is set (a custom\n * type counts); Safari lets a drop zone read `types` during dragover but not `getData`.\n */\nexport const EMAIL_BLOCK_DRAG_TYPE = 'application/x-tpl-block';\n\n/** True when the drag carries a block payload (`types` is an array in current engines, a DOMStringList in very old ones). */\nexport function isBlockDrag(event: { dataTransfer?: { types?: ArrayLike<string> | readonly string[] } | null }): boolean {\n const types = event.dataTransfer?.types;\n return !!types && Array.from(types as ArrayLike<string>).includes(EMAIL_BLOCK_DRAG_TYPE);\n}\n\n/** True when a node sits inside one of the editor's blocks (the only place a saved selection may point). */\nexport function insideEditorBlock(node: Node | null | undefined): boolean {\n const el = node instanceof Element ? node : node?.parentElement;\n return !!el?.closest('.block-content');\n}\n\n/** `m:ss` for a duration in seconds; '' when there is none. */\nexport function formatVideoDuration(seconds: number | null | undefined): string {\n if (!seconds) return '';\n const m = Math.floor(seconds / 60), s = seconds % 60;\n return `${m}:${s.toString().padStart(2, '0')}`;\n}\n\n/** `follow-up` → `Follow Up`. */\nexport function formatCategoryLabel(cat: string | null | undefined): string {\n return (cat ?? '').split('-').filter(Boolean).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');\n}\n\n/** The thumbnail address of a video: absolute as given, or relative to `origin`. */\nfunction thumbnailSrc(video: EmailTemplateVideo, origin: string): string | null {\n const t = video.thumbnailUrl;\n if (!t) return null;\n return t.startsWith('http') ? t : `${origin}${t}`;\n}\n\n/** The email block a video becomes: a thumbnail with a play overlay, linked to `link`, with the title and a caption. Every user value is escaped. */\nexport function buildVideoBlockHtml(video: EmailTemplateVideo, link: string, caption: string, origin: string): string {\n const title = escapeHtml(video.title);\n const href = escapeHtml(link);\n const thumb = thumbnailSrc(video, origin);\n const playOverlay = `<div style=\"position:absolute;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.25);\"><div style=\"width:64px;height:64px;background:rgba(0,0,0,0.65);border-radius:50%;display:flex;align-items:center;justify-content:center;box-shadow:0 2px 12px rgba(0,0,0,0.4);\"><div style=\"width:0;height:0;border-style:solid;border-width:12px 0 12px 22px;border-color:transparent transparent transparent #ffffff;margin-left:5px;\"></div></div></div>`;\n const thumbInner = thumb\n ? `<img src=\"${escapeHtml(thumb)}\" alt=\"${title}\" style=\"width:100%;height:200px;object-fit:cover;display:block;border-radius:0;\"/>`\n : `<div style=\"width:100%;height:200px;background:linear-gradient(135deg,#1e293b,#334155);display:flex;align-items:center;justify-content:center;\"></div>`;\n const thumbHtml = `<div style=\"position:relative;display:block;line-height:0;\">${thumbInner}${playOverlay}</div>`;\n return `<div style=\"max-width:560px;margin:16px auto;border:1px solid #e2e8f0;border-radius:12px;overflow:hidden;font-family:inherit\"><a href=\"${href}\" target=\"_blank\" style=\"display:block;text-decoration:none;\">${thumbHtml}<div style=\"padding:14px 16px;background:#fff;display:flex;align-items:center;gap:10px;\"><div style=\"width:32px;height:32px;background:#ef4444;border-radius:6px;flex-shrink:0;display:flex;align-items:center;justify-content:center;\"><div style=\"width:0;height:0;border-style:solid;border-width:6px 0 6px 11px;border-color:transparent transparent transparent #ffffff;margin-left:2px;\"></div></div><div><p style=\"font-size:14px;font-weight:600;color:#1e293b;margin:0 0 2px;\">${title}</p><p style=\"font-size:12px;color:#64748b;margin:0;\">${escapeHtml(caption)}</p></div></div></a></div>`;\n}\n\nconst TH = 'padding:8px 12px;text-align:left;background:#f8fafc;border:1px solid #e2e8f0';\nconst TD = 'padding:8px 12px;border:1px solid #e2e8f0';\n\n/** The content blocks every host gets unless it passes its own `blockGroups`. */\nexport const DEFAULT_EMAIL_TEMPLATE_BLOCK_GROUPS: EmailTemplateBlockGroup[] = [\n { name: 'Buttons', blocks: [\n { key: 'btn-primary', label: 'Primary Button', html: '<div style=\"text-align:center;margin:16px 0\"><a href=\"#\" style=\"display:inline-block;padding:12px 28px;background:#3B82F6;color:#fff;border-radius:6px;text-decoration:none;font-weight:600\">Button Text</a></div>' },\n { key: 'btn-secondary', label: 'Secondary Button', html: '<div style=\"text-align:center;margin:16px 0\"><a href=\"#\" style=\"display:inline-block;padding:12px 28px;background:#64748b;color:#fff;border-radius:6px;text-decoration:none;font-weight:600\">Button Text</a></div>' },\n { key: 'btn-outline', label: 'Outline Button', html: '<div style=\"text-align:center;margin:16px 0\"><a href=\"#\" style=\"display:inline-block;padding:12px 28px;border:2px solid #3B82F6;color:#3B82F6;border-radius:6px;text-decoration:none;font-weight:600\">Button Text</a></div>' },\n { key: 'btn-link', label: 'Link Button', html: '<div style=\"margin:8px 0\"><a href=\"#\" style=\"color:#3B82F6;text-decoration:underline\">Link Text</a></div>' },\n ]},\n { name: 'Spacing', blocks: [\n { key: 'spacer-sm', label: 'Small Spacer', html: '<div style=\"height:8px\"> </div>' },\n { key: 'spacer-md', label: 'Medium Spacer', html: '<div style=\"height:24px\"> </div>' },\n { key: 'spacer-lg', label: 'Large Spacer', html: '<div style=\"height:48px\"> </div>' },\n { key: 'divider', label: 'Divider Line', html: '<hr style=\"border:none;border-top:1px solid #e2e8f0;margin:16px 0\"/>' },\n ]},\n { name: 'Layout', blocks: [\n { key: 'layout-2col', label: 'Two Columns', html: '<table style=\"width:100%;border-collapse:collapse\"><tr><td style=\"width:50%;padding:8px;vertical-align:top\"><p>Left column</p></td><td style=\"width:50%;padding:8px;vertical-align:top\"><p>Right column</p></td></tr></table>' },\n { key: 'layout-3col', label: 'Three Columns', html: '<table style=\"width:100%;border-collapse:collapse\"><tr><td style=\"width:33%;padding:8px;vertical-align:top\"><p>Col 1</p></td><td style=\"width:33%;padding:8px;vertical-align:top\"><p>Col 2</p></td><td style=\"width:34%;padding:8px;vertical-align:top\"><p>Col 3</p></td></tr></table>' },\n ]},\n { name: 'Content', blocks: [\n { key: 'text-block', label: 'Text Block', html: '<p>Enter your text here...</p>' },\n { key: 'image-block', label: 'Image Block', html: '<div style=\"text-align:center;margin:8px 0\"><img src=\"https://placehold.co/600x200/e2e8f0/94a3b8?text=Image\" alt=\"Image\" style=\"max-width:100%;border-radius:8px\"/></div>' },\n ]},\n { name: 'Tables', blocks: [\n { key: 'table-2col', label: 'Two-Column Table', html: `<table style=\"width:100%;border-collapse:collapse;border:1px solid #e2e8f0\"><tr><th style=\"${TH}\">Header 1</th><th style=\"${TH}\">Header 2</th></tr><tr><td style=\"${TD}\">Data</td><td style=\"${TD}\">Data</td></tr></table>` },\n { key: 'table-3col', label: 'Three-Column Table', html: `<table style=\"width:100%;border-collapse:collapse;border:1px solid #e2e8f0\"><tr><th style=\"${TH}\">Header 1</th><th style=\"${TH}\">Header 2</th><th style=\"${TH}\">Header 3</th></tr><tr><td style=\"${TD}\">Data</td><td style=\"${TD}\">Data</td><td style=\"${TD}\">Data</td></tr></table>` },\n ]},\n];\n\nconst GROUP_KEYS: Record<string, string> = { Buttons: 'buttons', Spacing: 'spacing', Layout: 'layout', Content: 'content', Tables: 'tables' };\n\n/** The sample words inside a block's HTML (\"Button Text\", \"Header 1\" ...) in the app's active language. English HTML is returned unchanged. */\nfunction localizeBlockHtml(html: string): string {\n const pairs: [string, string][] = [\n ['>Button Text<', `>${uiText('emailTemplateEditor.sample.buttonText')}<`], ['>Link Text<', `>${uiText('emailTemplateEditor.sample.linkText')}<`],\n ['<p>Left column</p>', `<p>${uiText('emailTemplateEditor.sample.leftColumn')}</p>`], ['<p>Right column</p>', `<p>${uiText('emailTemplateEditor.sample.rightColumn')}</p>`],\n ['<p>Col 1</p>', `<p>${uiText('emailTemplateEditor.sample.column', { n: 1 })}</p>`], ['<p>Col 2</p>', `<p>${uiText('emailTemplateEditor.sample.column', { n: 2 })}</p>`],\n ['<p>Col 3</p>', `<p>${uiText('emailTemplateEditor.sample.column', { n: 3 })}</p>`],\n ['<p>Enter your text here...</p>', `<p>${uiText('emailTemplateEditor.sample.enterText')}</p>`],\n ['alt=\"Image\"', `alt=\"${uiText('emailTemplateEditor.sample.image')}\"`],\n ['>Header 1<', `>${uiText('emailTemplateEditor.sample.header', { n: 1 })}<`], ['>Header 2<', `>${uiText('emailTemplateEditor.sample.header', { n: 2 })}<`],\n ['>Header 3<', `>${uiText('emailTemplateEditor.sample.header', { n: 3 })}<`], ['>Data<', `>${uiText('emailTemplateEditor.sample.data')}<`],\n ];\n return pairs.reduce((out, [from, to]) => out.split(from).join(to), html);\n}\n\n/** The default content blocks with group names, block names and sample words in the app's active language. */\nexport function localizedEmailBlockGroups(): EmailTemplateBlockGroup[] {\n return DEFAULT_EMAIL_TEMPLATE_BLOCK_GROUPS.map(g => ({\n ...g,\n name: uiText(`emailTemplateEditor.group.${GROUP_KEYS[g.name] ?? g.name}` as UiLabelKey),\n blocks: g.blocks.map(b => ({ ...b, label: uiText(`emailTemplateEditor.block.${b.key}` as UiLabelKey), html: localizeBlockHtml(b.html) })),\n }));\n}\n\n/** Generic merge variables; a host passes its own `variableGroups` for the data its sender can fill in. */\nexport const DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS = [\n { name: 'Contact', variables: [\n { key: 'first_name', label: 'First Name', example: 'John' },\n { key: 'last_name', label: 'Last Name', example: 'Smith' },\n { key: 'full_name', label: 'Full Name', example: 'John Smith' },\n { key: 'email', label: 'Email', example: 'john@example.com' },\n { key: 'phone', label: 'Phone', example: '(512) 555-0100' },\n ]},\n];\n\n/**\n * The document the Preview / Mobile tabs show (inside a sandboxed iframe): the serialised message with the base look of a sent email. A\n * Content-Security-Policy meta blocks scripts and anything but images / inline styles, and links open nowhere (sandbox, no popups).\n */\nexport function buildPreviewDocument(bodyHtml: string): string {\n return '<!doctype html><html><head><meta charset=\"utf-8\">'\n + `<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; img-src * data:; style-src 'unsafe-inline'; font-src data:\">`\n + '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">'\n + '<style>html,body{margin:0}body{padding:24px 28px;font:15px/1.6 -apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif;color:#1e293b;overflow-wrap:anywhere}'\n + 'p{margin:0 0 8px}img{max-width:100%}table{max-width:100%}a{color:#3b82f6}</style></head>'\n + `<body>${bodyHtml}</body></html>`;\n}\n\n/** The default merge variables with names in the app's active language (the `key` and the example value stay as they are). */\nexport function localizedEmailVariableGroups() {\n const label: Record<string, UiLabelKey> = {\n first_name: 'emailTemplateEditor.variable.firstName', last_name: 'emailTemplateEditor.variable.lastName', full_name: 'emailTemplateEditor.variable.fullName',\n email: 'common.email', phone: 'common.phone',\n };\n return DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS.map(g => ({\n ...g, name: uiText('emailTemplateEditor.variableGroup.contact'),\n variables: g.variables.map(v => ({ ...v, label: label[v.key] ? uiText(label[v.key]) : v.label })),\n }));\n}\n","import {\n Component, ChangeDetectionStrategy, ElementRef, Injector, afterEveryRender, afterNextRender, computed, effect, inject, input, output, signal,\n untracked, viewChild, viewChildren,\n} from '@angular/core';\nimport { DomSanitizer, SafeHtml } from '@angular/platform-browser';\nimport { FormsModule } from '@angular/forms';\nimport { ButtonComponent } from '@forgeroute/ui/core';\nimport { CheckboxComponent } from '@forgeroute/ui/checkbox';\nimport { DividerComponent } from '@forgeroute/ui/divider';\nimport { DateInputComponent } from '@forgeroute/ui/date-input';\nimport { EmptyStateComponent } from '@forgeroute/ui/empty-state';\nimport { ErrorComponent } from '@forgeroute/ui/error';\nimport { PillTab, PillTabsComponent } from '@forgeroute/ui/pill-tabs';\nimport { RadioGroupComponent } from '@forgeroute/ui/radio';\nimport { SearchInputComponent } from '@forgeroute/ui/search-input';\nimport { SelectComponent, SelectOption } from '@forgeroute/ui/select';\nimport { SidePanelComponent } from '@forgeroute/ui/core';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { TextInputComponent } from '@forgeroute/ui/text-input';\nimport { TooltipDirective } from '@forgeroute/ui/tooltip';\nimport {\n EmailTemplateAssignmentOption, EmailTemplateBlock, EmailTemplateBlockGroup, EmailTemplateSavePayload,\n EmailTemplateValue, EmailTemplateVariable, EmailTemplateVariableGroup, EmailTemplateVideo, EmailTemplateVideoDefaults, EmailTemplateVideoLinkFn,\n} from './email-template-editor.models';\nimport {\n localizedEmailBlockGroups, localizedEmailVariableGroups, EMAIL_BLOCK_DRAG_TYPE, EMAIL_TEMPLATE_MAX_BODY, EMAIL_TEMPLATE_MAX_TEXT,\n EMAIL_TEMPLATE_START_TEXT, blockHasContent, buildPreviewDocument, serializedTextLength, buildVideoBlockHtml, escapeHtml, formatCategoryLabel, formatVideoDuration, insideEditorBlock, isBlockDrag,\n isValidEmailAddress, isWebUrl,\n} from './email-template-editor.utils';\nimport { UiLabelsService } from '@forgeroute/ui/core';\n\ninterface EmailBlock {\n id: string;\n html: string;\n spacing?: string;\n}\n\ninterface AssignmentView extends EmailTemplateAssignmentOption {\n assigned: boolean;\n}\n\ntype EditorTab = 'edit' | 'preview' | 'mobile';\ntype RightTab = 'blocks' | 'variables' | 'video';\n\nconst FONT_SIZE_OPTIONS: SelectOption<string>[] = ['10', '12', '14', '16', '18', '20', '24', '28', '32', '36'].map(n => ({ value: `${n}px`, label: `${n}px` }));\n/** The space above and below a block: the pill key is the CSS length (the stored value), 'none' = no extra space. */\n/** The block's own vertical padding in the editor (px); a block spacing is added to it so every step is visible, never replaces it. */\nconst BLOCK_BASE_PADDING_PX = 12;\n\n/** Shows a block spacing in the editor: extra space above and below the block's text (the sent email wraps the block in the same padding). */\nfunction setEditorSpacing(el: HTMLElement, spacing: string | undefined): void {\n el.style.paddingTop = spacing ? `calc(${BLOCK_BASE_PADDING_PX}px + ${spacing})` : '';\n el.style.paddingBottom = spacing ? `calc(${BLOCK_BASE_PADDING_PX}px + ${spacing})` : '';\n}\n\nconst DEFAULT_VIDEO_LINK: EmailTemplateVideoLinkFn = video => video.shareLink;\nconst EMPTY_VIDEO_DEFAULTS: EmailTemplateVideoDefaults = { autoplay: false, caption: '', ctaType: '', ctaUrl: '', ctaLabel: '', hideReactions: false };\n\n/**\n * `ui-email-template-editor` - the full-page, block-based email template editor (details, assignments, block canvas with drag and drop,\n * rich-text toolbar, preview / mobile preview, content blocks, merge variables, video library, test send).\n *\n * The component owns the editing behaviour and holds no HTTP: the host loads the template (`[template]`), supplies what differs per app\n * (`categories`, `assignmentOptions`, `variableGroups`, `blockGroups`, `videos`, `videoDefaults`, `maxBodyLength`, permissions) and reacts to\n * `(save)`, `(testSend)`, `(videosRequested)` and `(useAsMine)`. After a request the host calls back:\n * `markSaved(id)` (a create succeeded) and `closeTestSend()`.\n *\n * Message limit: `maxBodyLength` is measured on the serialised HTML. An untouched stored body that is already longer than the limit is\n * accepted unchanged (legacy rows), exactly as the server does.\n */\n@Component({\n selector: 'ui-email-template-editor',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n FormsModule, ButtonComponent, CheckboxComponent, DateInputComponent, DividerComponent, EmptyStateComponent, ErrorComponent, PillTabsComponent, RadioGroupComponent, SearchInputComponent,\n SelectComponent, SidePanelComponent, SkeletonComponent, TextInputComponent, TooltipDirective,\n ],\n template: `\n <div class=\"editor-page\">\n <!-- Actions (outside the white panels) -->\n <div class=\"editor-actions\">\n @if (heading()) {\n <h2 class=\"editor-heading\" data-testid=\"editor-heading\">{{ heading() }}</h2>\n }\n <div class=\"editor-actions-buttons\">\n @if (canWrite() && testSendEnabled()) {\n <ui-button variant=\"secondary\" size=\"sm\" (click)=\"openTestSendDialog()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"/><polygon points=\"22 2 15 22 11 13 2 9 22 2\"/></svg>{{ labels.t('emailTemplateEditor.testSend') }}</ui-button>\n }\n <span class=\"save-wrap\" [uiTooltip]=\"saveHint()\">\n <ui-button variant=\"primary\" size=\"sm\" [loading]=\"saving()\" [disabled]=\"saveDisabled()\" (click)=\"onSave()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z\"/><polyline points=\"17 21 17 13 7 13 7 21\"/><polyline points=\"7 3 7 8 15 8\"/></svg>{{ labels.t('emailTemplateEditor.saveTemplate') }}</ui-button>\n </span>\n </div>\n @if (saveHintVisible(); as hint) {\n <!-- A blocked Save explains itself in visible text, not only in the tooltip. -->\n <p class=\"save-hint\" role=\"status\" data-testid=\"save-hint\">{{ hint }}</p>\n }\n </div>\n <ui-divider />\n\n @if (systemTemplate()) {\n <div class=\"readonly-note system-note\" role=\"note\" data-testid=\"editor-system-note\">\n <span>{{ systemNote() }}</span>\n @if (canCopySystem()) {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"editor-use-as-mine\" (click)=\"useAsMine.emit()\">{{ labels.t('emailTemplateEditor.useAsMyTemplate') }}</ui-button>\n }\n </div>\n } @else if (!canWrite()) {\n <p class=\"readonly-note\" role=\"note\" data-testid=\"editor-readonly-note\">{{ readOnlyNote() }}</p>\n }\n\n <!-- 3-Column Layout -->\n <div class=\"editor-body\">\n <!-- LEFT PANEL: Details -->\n <aside class=\"panel-left\" [attr.aria-label]=\"labels.t('emailTemplateEditor.templateDetails')\">\n <h3 class=\"panel-title\">{{ labels.t('common.details') }}</h3>\n\n <div class=\"form-field\">\n <ui-text-input [label]=\"labels.t('common.name')\" [required]=\"true\" [(ngModel)]=\"name\" [readonly]=\"!canWrite()\" [maxlength]=\"maxTextLength()\"\n [placeholder]=\"namePlaceholder()\" [error]=\"nameErrorShown()\" [showErrors]=\"nameTouched()\" (blurred)=\"nameTouched.set(true)\" />\n </div>\n\n <div class=\"form-field\">\n <ui-text-input [label]=\"labels.t('common.subject')\" [required]=\"true\" [(ngModel)]=\"subject\" [readonly]=\"!canWrite()\" [maxlength]=\"maxTextLength()\"\n [placeholder]=\"subjectPlaceholder()\" [error]=\"subjectErrorShown()\" [showErrors]=\"subjectTouched()\" (blurred)=\"subjectTouched.set(true)\">\n </ui-text-input>\n </div>\n\n <div class=\"form-field\">\n <ui-select [label]=\"labels.t('emailTemplateEditor.category')\" [options]=\"categories()\" [placeholder]=\"categoryPlaceholder()\" [(ngModel)]=\"category\" [disabled]=\"!canWrite()\" />\n </div>\n\n <ui-checkbox [label]=\"labels.t('emailTemplateEditor.useThisTemplateAllYear')\" [(checked)]=\"useAllYear\" [disabled]=\"!canWrite()\" />\n\n @if (!useAllYear()) {\n <div class=\"form-row-dates\" (focusout)=\"datesTouched.set(true)\">\n <ui-date-input [label]=\"labels.t('emailTemplateEditor.activeFrom')\" [(ngModel)]=\"activeFrom\" [disabled]=\"!canWrite()\" />\n <ui-date-input [label]=\"labels.t('emailTemplateEditor.activeTo')\" [(ngModel)]=\"activeTo\" [disabled]=\"!canWrite()\" [min]=\"activeFrom()\" [error]=\"datesError()\" />\n </div>\n }\n\n <!-- Assignments -->\n @if (assignmentOptions().length > 0) {\n <div class=\"assignments-section\">\n <h4 class=\"section-title\">{{ labels.t('emailTemplateEditor.assignments') }}<span class=\"required\" aria-hidden=\"true\">*</span></h4>\n <p class=\"section-desc\">{{ assignmentsDescription() }}</p>\n <ui-error [errorId]=\"idPrefix() + '-assignments-error'\" [message]=\"assignmentErrorShown()\" />\n <ui-search-input [placeholder]=\"labels.t('common.searchellipsis')\" [ariaLabel]=\"labels.t('emailTemplateEditor.searchAssignments')\" [(value)]=\"assignmentSearch\" />\n @if (filteredAssignments().length === 0) {\n <ui-empty-state iconType=\"search\" [title]=\"labels.t('emailTemplateEditor.noAssignmentsFound')\" [message]=\"labels.t('emailTemplateEditor.noAssignmentsMatchYourSearch')\" />\n }\n <div class=\"assignment-list\" [hidden]=\"filteredAssignments().length === 0\" (focusout)=\"onAssignmentsFocusOut($event)\">\n @for (item of filteredAssignments(); track item.key) {\n <div class=\"assignment-item\" [class.assignment-readonly]=\"!canWrite()\" [attr.role]=\"canWrite() ? 'switch' : null\" [attr.tabindex]=\"canWrite() ? 0 : null\"\n [attr.aria-checked]=\"canWrite() ? item.assigned : null\" [attr.aria-label]=\"canWrite() ? item.name : null\"\n (click)=\"toggleAssignment(item)\" (keydown.enter)=\"toggleAssignment(item); $event.preventDefault()\" (keydown.space)=\"toggleAssignment(item); $event.preventDefault()\">\n <div class=\"assignment-text\">\n <strong>{{ item.name }}</strong>\n <span>{{ item.description }}</span>\n </div>\n <div class=\"assignment-channels\">\n <span class=\"channel-badge\" [class.active]=\"item.assigned\" role=\"img\" [attr.aria-label]=\"item.assigned ? labels.t('emailTemplateEditor.emailOn') : labels.t('emailTemplateEditor.emailOff')\">\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\"/><path d=\"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7\"/></svg>\n </span>\n </div>\n </div>\n }\n </div>\n </div>\n }\n </aside>\n\n <!-- CENTER: Editor -->\n <section class=\"panel-center\" [attr.aria-label]=\"labels.t('emailTemplateEditor.emailDesign')\">\n <div class=\"editor-tabs\" role=\"tablist\" [attr.aria-label]=\"labels.t('emailTemplateEditor.editorView')\">\n <button type=\"button\" class=\"editor-tab\" role=\"tab\" [class.active]=\"activeEditorTab() === 'edit'\" [attr.aria-selected]=\"activeEditorTab() === 'edit'\" (click)=\"setEditorTab('edit')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z\"/></svg>{{ labels.t('common.edit') }}</button>\n <button type=\"button\" class=\"editor-tab\" role=\"tab\" [class.active]=\"activeEditorTab() === 'preview'\" [attr.aria-selected]=\"activeEditorTab() === 'preview'\" (click)=\"setEditorTab('preview')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z\"/><circle cx=\"12\" cy=\"12\" r=\"3\"/></svg>{{ labels.t('common.preview') }}</button>\n <button type=\"button\" class=\"editor-tab\" role=\"tab\" [class.active]=\"activeEditorTab() === 'mobile'\" [attr.aria-selected]=\"activeEditorTab() === 'mobile'\" (click)=\"setEditorTab('mobile')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"5\" y=\"2\" width=\"14\" height=\"20\" rx=\"2\" ry=\"2\"/><line x1=\"12\" y1=\"18\" x2=\"12.01\" y2=\"18\"/></svg>{{ labels.t('common.mobile') }}</button>\n </div>\n\n @if (activeEditorTab() === 'edit') {\n @if (canWrite()) {\n <!-- Toolbar row 1: mousedown preventDefault keeps focus (and the selection) in the editor -->\n <div class=\"editor-toolbar\" role=\"toolbar\" [attr.aria-label]=\"labels.t('emailTemplateEditor.textFormatting')\" (mousedown)=\"preventFocusLoss($event)\">\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.bold')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipBold')\" (click)=\"execCommand('bold')\"><strong>B</strong></ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.italic')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipItalic')\" (click)=\"execCommand('italic')\"><em>I</em></ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.underline')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipUnderline')\" (click)=\"execCommand('underline')\"><u>U</u></ui-button>\n </div>\n <div class=\"toolbar-group\">\n @for (k of [headingKey()]; track k) {\n <ui-select class=\"toolbar-select\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.headingLevel')\" [options]=\"headingOptions\" ngModel=\"p\"\n (mousedown)=\"saveSelection()\" (ngModelChange)=\"onHeading($event)\" />\n }\n </div>\n <div class=\"toolbar-group\">\n @for (k of [sizeKey()]; track k) {\n <ui-select class=\"toolbar-select\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.fontSize')\" [placeholder]=\"labels.t('emailTemplateEditor.size')\" [options]=\"fontSizeOptions\" ngModel=\"\"\n (mousedown)=\"saveSelection()\" (ngModelChange)=\"onFontSize($event)\" />\n }\n </div>\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.alignLeft')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipAlignLeft')\" (click)=\"execCommand('justifyLeft')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"17\" y1=\"10\" x2=\"3\" y2=\"10\"/><line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"21\" y1=\"14\" x2=\"3\" y2=\"14\"/><line x1=\"17\" y1=\"18\" x2=\"3\" y2=\"18\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.alignCenter')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipAlignCenter')\" (click)=\"execCommand('justifyCenter')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"18\" y1=\"10\" x2=\"6\" y2=\"10\"/><line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"21\" y1=\"14\" x2=\"3\" y2=\"14\"/><line x1=\"18\" y1=\"18\" x2=\"6\" y2=\"18\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.alignRight')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipAlignRight')\" (click)=\"execCommand('justifyRight')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"21\" y1=\"10\" x2=\"7\" y2=\"10\"/><line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"21\" y1=\"14\" x2=\"3\" y2=\"14\"/><line x1=\"21\" y1=\"18\" x2=\"7\" y2=\"18\"/></svg>\n </ui-button>\n </div>\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.bulletedList')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipBulletedList')\" (click)=\"execCommand('insertUnorderedList')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"8\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"8\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"8\" y1=\"18\" x2=\"21\" y2=\"18\"/><line x1=\"3\" y1=\"6\" x2=\"3.01\" y2=\"6\"/><line x1=\"3\" y1=\"12\" x2=\"3.01\" y2=\"12\"/><line x1=\"3\" y1=\"18\" x2=\"3.01\" y2=\"18\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.numberedList')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipNumberedList')\" (click)=\"execCommand('insertOrderedList')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"10\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"21\" y2=\"18\"/><path d=\"M4 6h1v4\"/><path d=\"M4 10h2\"/><path d=\"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1\"/></svg>\n </ui-button>\n </div>\n <div class=\"toolbar-group\">\n <!-- The browser's own colour dialog is the picker; a button opens it so the toolbar keeps one look. -->\n <input #colorInput type=\"color\" class=\"hidden-color-input\" [attr.aria-label]=\"labels.t('emailTemplateEditor.textColor')\" tabindex=\"-1\" [value]=\"currentColor()\" (change)=\"applyTextColor($any($event.target).value)\" (mousedown)=\"$event.stopPropagation()\" />\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.textColor')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipTextColor')\" (mousedown)=\"openColorPicker()\">\n <span class=\"color-indicator\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\"><text y=\"20\" font-size=\"20\" font-weight=\"700\">A</text></svg>\n <span class=\"color-bar\" [style.background]=\"currentColor()\"></span>\n </span>\n </ui-button>\n </div>\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.insertLink')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipInsertLink')\" (mousedown)=\"saveSelection()\" (click)=\"openLinkDialog()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.insertImage')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipInsertImage')\" (mousedown)=\"saveSelection()\" (click)=\"openImageDialog()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"/><circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"/><polyline points=\"21 15 16 10 5 21\"/></svg>\n </ui-button>\n </div>\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.undo')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipUndo')\" (click)=\"execCommand('undo')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M3 7v6h6\"/><path d=\"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6.69 3L3 13\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.redo')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipRedo')\" (click)=\"execCommand('redo')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M21 7v6h-6\"/><path d=\"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6.69 3L21 13\"/></svg>\n </ui-button>\n </div>\n </div>\n\n <!-- Toolbar row 2: block spacing -->\n <div class=\"toolbar-row-2\">\n <div class=\"toolbar-group\" (mousedown)=\"preventFocusLoss($event)\">\n <span class=\"toolbar-label\" id=\"tpl-spacing-label\">{{ labels.t('emailTemplateEditor.blockSpacing') }}</span>\n <ui-pill-tabs [tabs]=\"spacingTabs\" [activeKey]=\"blockSpacing() || 'none'\" [ariaLabel]=\"labels.t('emailTemplateEditor.blockSpacing')\" (tabChange)=\"applySpacing($event === 'none' ? '' : $event)\" />\n </div>\n </div>\n }\n\n <!-- Link dialog (inline popover) -->\n @if (canWrite() && showLinkDialog()) {\n <div class=\"link-dialog\" role=\"group\" [attr.aria-label]=\"labels.t('emailTemplateEditor.insertLink')\">\n <div class=\"link-dialog-inner\">\n <span class=\"link-dialog-title\">{{ labels.t('emailTemplateEditor.insertLink2') }}</span>\n <ui-text-input class=\"link-dialog-input\" [ariaLabel]=\"labels.t('emailTemplateEditor.linkAddress')\" placeholder=\"https://example.com\" [(ngModel)]=\"linkUrl\" [error]=\"linkUrlError()\" (keydown.enter)=\"insertLink()\" />\n @if (!linkTextFromSelection()) {\n <ui-text-input class=\"link-dialog-input\" [ariaLabel]=\"labels.t('emailTemplateEditor.linkText')\" [placeholder]=\"labels.t('emailTemplateEditor.linkTextOptional')\" [(ngModel)]=\"linkText\" (keydown.enter)=\"insertLink()\" />\n }\n <div class=\"link-dialog-actions\">\n <ui-button variant=\"secondary\" size=\"sm\" (click)=\"showLinkDialog.set(false)\">{{ labels.t('common.cancel') }}</ui-button>\n <ui-button variant=\"primary\" size=\"sm\" [disabled]=\"!canInsertLink()\" (click)=\"insertLink()\">{{ labels.t('common.insert') }}</ui-button>\n </div>\n </div>\n </div>\n }\n\n <!-- Image URL dialog -->\n @if (canWrite() && showImageDialog()) {\n <div class=\"link-dialog\" role=\"group\" [attr.aria-label]=\"labels.t('emailTemplateEditor.insertImage')\">\n <div class=\"link-dialog-inner\">\n <span class=\"link-dialog-title\">{{ labels.t('emailTemplateEditor.insertImage2') }}</span>\n <ui-text-input class=\"link-dialog-input\" [ariaLabel]=\"labels.t('emailTemplateEditor.imageAddress')\" placeholder=\"https://example.com/image.jpg\" [(ngModel)]=\"imageUrl\" [error]=\"imageUrlError()\" (keydown.enter)=\"insertImageFromUrl()\" />\n <ui-text-input class=\"link-dialog-input\" [ariaLabel]=\"labels.t('emailTemplateEditor.imageAltText')\" [placeholder]=\"labels.t('emailTemplateEditor.altTextOptional')\" [(ngModel)]=\"imageAlt\" (keydown.enter)=\"insertImageFromUrl()\" />\n <div class=\"link-dialog-actions\">\n <ui-button variant=\"secondary\" size=\"sm\" (click)=\"showImageDialog.set(false)\">{{ labels.t('common.cancel') }}</ui-button>\n <ui-button variant=\"primary\" size=\"sm\" [disabled]=\"!canInsertImage()\" (click)=\"insertImageFromUrl()\">{{ labels.t('common.insert') }}</ui-button>\n </div>\n </div>\n </div>\n }\n\n <ui-error [errorId]=\"idPrefix() + '-body-error'\" [message]=\"bodyErrorShown()\" />\n\n <!-- Block Canvas with DnD -->\n <div class=\"blocks-canvas\" (dragover)=\"onCanvasDragOver($event)\" (drop)=\"onDropZoneDrop($event, blocks().length)\" (focusout)=\"onBodyFocusOut($event)\">\n <!-- Initial drop zone (before first block) -->\n <div class=\"drop-zone\" [class.active]=\"dragOverIndex() === 0\" (dragover)=\"onDropZoneDragOver($event, 0)\" (dragleave)=\"onDropZoneLeave()\" (drop)=\"onDropZoneDrop($event, 0)\">\n <span class=\"drop-zone-label\">{{ labels.t('emailTemplateEditor.dropHere') }}</span>\n </div>\n\n @for (block of blocks(); track block.id; let i = $index) {\n <div class=\"block-wrapper\" #blockWrapper [class.selected]=\"selectedBlockId() === block.id\" [class.dragging]=\"dragFromCanvas() === i\" (dragend)=\"onBlockDragEnd()\">\n @if (canWrite()) {\n <!-- Only the handle is draggable: a draggable ancestor of the contenteditable breaks text selection in Firefox / Safari. Move up / down below are the keyboard and touch alternative. -->\n <div class=\"block-drag-handle\" [attr.title]=\"labels.t('emailTemplateEditor.dragToReorder')\" draggable=\"true\" (dragstart)=\"onBlockDragStart($event, i, blockWrapper)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\"><circle cx=\"9\" cy=\"6\" r=\"1.5\"/><circle cx=\"15\" cy=\"6\" r=\"1.5\"/><circle cx=\"9\" cy=\"12\" r=\"1.5\"/><circle cx=\"15\" cy=\"12\" r=\"1.5\"/><circle cx=\"9\" cy=\"18\" r=\"1.5\"/><circle cx=\"15\" cy=\"18\" r=\"1.5\"/></svg>\n </div>\n }\n\n <!-- Block content (contenteditable, initialised ONCE after render so Angular never rewrites it and the caret never jumps) -->\n <div #blockEditor class=\"block-content\" role=\"textbox\" aria-multiline=\"true\" [attr.aria-label]=\"labels.t('emailTemplateEditor.emailBlockN', { n: i + 1 })\"\n [attr.data-block-id]=\"block.id\" [attr.data-placeholder]=\"i === 0 ? startPlaceholder() : labels.t('emailTemplateEditor.clickToEdit')\" [attr.contenteditable]=\"canWrite() ? 'true' : 'false'\"\n (input)=\"onBlockInput($event, block)\" (beforeinput)=\"onBlockBeforeInput($any($event))\" (focus)=\"onBlockFocus(block)\" (click)=\"selectedBlockId.set(block.id)\"></div>\n\n @if (canWrite()) {\n <div class=\"block-controls\">\n <ui-button variant=\"ghost\" size=\"xs\" [ariaLabel]=\"labels.t('emailTemplateEditor.moveBlockUp')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipMoveUp')\" [disabled]=\"i === 0\" (mousedown)=\"preventFocusLoss($event)\" (click)=\"moveBlock(i, -1)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" aria-hidden=\"true\"><path d=\"M18 15l-6-6-6 6\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"xs\" [ariaLabel]=\"labels.t('emailTemplateEditor.moveBlockDown')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipMoveDown')\" [disabled]=\"i === blocks().length - 1\" (mousedown)=\"preventFocusLoss($event)\" (click)=\"moveBlock(i, 1)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" aria-hidden=\"true\"><path d=\"M6 9l6 6 6-6\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"xs\" [ariaLabel]=\"labels.t('emailTemplateEditor.duplicateBlock')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipDuplicate')\" (mousedown)=\"preventFocusLoss($event)\" (click)=\"duplicateBlock(i)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\"/><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"/></svg>\n </ui-button>\n @if (blocks().length > 1) {\n <ui-button variant=\"ghost\" size=\"xs\" [ariaLabel]=\"labels.t('emailTemplateEditor.deleteBlock')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipDeleteBlock')\" (mousedown)=\"preventFocusLoss($event)\" (click)=\"deleteBlock(i)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><polyline points=\"3 6 5 6 21 6\"/><path d=\"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6\"/><path d=\"M10 11v6M14 11v6\"/></svg>\n </ui-button>\n }\n </div>\n }\n </div>\n\n <!-- Drop zone after each block -->\n <div class=\"drop-zone\" [class.active]=\"dragOverIndex() === i + 1\" (dragover)=\"onDropZoneDragOver($event, i + 1)\" (dragleave)=\"onDropZoneLeave()\" (drop)=\"onDropZoneDrop($event, i + 1)\">\n <span class=\"drop-zone-label\">{{ labels.t('emailTemplateEditor.dropHere') }}</span>\n </div>\n }\n\n @if (canWrite()) {\n <button type=\"button\" class=\"add-block-btn\" (click)=\"addBlock('text-block')\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>{{ labels.t('emailTemplateEditor.addBlock') }}</button>\n }\n </div>\n }\n\n @if (activeEditorTab() === 'preview') {\n <div class=\"preview-frame\">\n <iframe class=\"preview-content\" [attr.title]=\"labels.t('emailTemplateEditor.emailPreview')\" sandbox=\"\" referrerpolicy=\"no-referrer\" [srcdoc]=\"previewDoc()\"></iframe>\n </div>\n }\n\n @if (activeEditorTab() === 'mobile') {\n <div class=\"preview-frame mobile\">\n <div class=\"mobile-shell\">\n <iframe class=\"preview-content\" [attr.title]=\"labels.t('emailTemplateEditor.mobileEmailPreview')\" sandbox=\"\" referrerpolicy=\"no-referrer\" [srcdoc]=\"previewDoc()\"></iframe>\n </div>\n </div>\n }\n </section>\n\n <!-- RIGHT PANEL: Blocks, Variables, Video (the word video appears only while the Video tab is on) -->\n <aside class=\"panel-right\" [attr.aria-label]=\"videosEnabled() ? labels.t('emailTemplateEditor.rightPanelWithVideo') : labels.t('emailTemplateEditor.rightPanel')\">\n @if (!canWrite()) {\n <div class=\"right-panel-body\" data-testid=\"tpl-readonly-tools-note\">\n <h4 class=\"right-section-title\">{{ labels.t('emailTemplateEditor.readOnly') }}</h4>\n <p class=\"right-section-hint\">{{ videosEnabled() ? labels.t('emailTemplateEditor.readOnlyToolsWithVideo') : labels.t('emailTemplateEditor.readOnlyTools') }}</p>\n </div>\n } @else {\n <div class=\"right-tabs\" role=\"tablist\" [attr.aria-label]=\"labels.t('emailTemplateEditor.rightPanelSections')\">\n <button type=\"button\" class=\"right-tab\" role=\"tab\" [class.active]=\"activeRightTab() === 'blocks'\" [attr.aria-selected]=\"activeRightTab() === 'blocks'\" (click)=\"activeRightTab.set('blocks')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"3\" y=\"3\" width=\"7\" height=\"7\"/><rect x=\"14\" y=\"3\" width=\"7\" height=\"7\"/><rect x=\"14\" y=\"14\" width=\"7\" height=\"7\"/><rect x=\"3\" y=\"14\" width=\"7\" height=\"7\"/></svg>{{ labels.t('emailTemplateEditor.blocks') }}</button>\n <button type=\"button\" class=\"right-tab\" role=\"tab\" [class.active]=\"activeRightTab() === 'variables'\" [attr.aria-selected]=\"activeRightTab() === 'variables'\" (click)=\"activeRightTab.set('variables')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M12 3v18M3 12h18\"/></svg>{{ labels.t('emailTemplateEditor.variables') }}</button>\n @if (videosEnabled()) {\n <button type=\"button\" class=\"right-tab\" role=\"tab\" [class.active]=\"activeRightTab() === 'video'\" [attr.aria-selected]=\"activeRightTab() === 'video'\" (click)=\"openVideoTab()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><polygon points=\"23 7 16 12 23 17 23 7\"/><rect x=\"1\" y=\"5\" width=\"15\" height=\"14\" rx=\"2\" ry=\"2\"/></svg>{{ labels.t('common.video') }}</button>\n }\n </div>\n\n @if (activeRightTab() === 'blocks') {\n <div class=\"right-panel-body\">\n <h4 class=\"right-section-title\">{{ labels.t('emailTemplateEditor.contentBlocks') }}</h4>\n <p class=\"right-section-desc\">{{ labels.t('emailTemplateEditor.clickToInsertOrDrag') }}</p>\n <ui-search-input [placeholder]=\"labels.t('emailTemplateEditor.searchBlocks')\" [ariaLabel]=\"labels.t('emailTemplateEditor.searchBlocks2')\" [(value)]=\"blockSearch\" />\n\n @if (filteredBlockGroups().length === 0) {\n <ui-empty-state iconType=\"search\" [title]=\"labels.t('emailTemplateEditor.noBlocksFound')\" [message]=\"labels.t('emailTemplateEditor.noBlocksMatchYourSearch')\" />\n }\n @for (group of filteredBlockGroups(); track group.name) {\n <div class=\"block-group\">\n <button type=\"button\" class=\"block-group-header\" [attr.aria-expanded]=\"isOpen('b:' + group.name)\" (click)=\"toggleGroup('b:' + group.name)\">\n <svg class=\"chevron\" [class.expanded]=\"isOpen('b:' + group.name)\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M9 18l6-6-6-6\"/></svg>\n <span>{{ group.name }}</span>\n <span class=\"block-count\">{{ group.blocks.length }}</span>\n </button>\n @if (isOpen('b:' + group.name)) {\n <div class=\"block-list\">\n @for (block of group.blocks; track block.key) {\n <!-- A div, not a button: Firefox does not start a drag from a <button>. Role, tabindex and Enter / Space keep it a keyboard control; a click inserts the block. -->\n <div role=\"button\" tabindex=\"0\" class=\"block-item\" draggable=\"true\" [attr.aria-label]=\"labels.t('emailTemplateEditor.insertNamed', { name: block.label })\"\n (dragstart)=\"onPaletteDragStart($event, block)\" (dragend)=\"onBlockDragEnd()\" (click)=\"insertBlock(block)\"\n (keydown.enter)=\"insertBlock(block); $event.preventDefault()\" (keydown.space)=\"insertBlock(block); $event.preventDefault()\">\n <svg class=\"block-item-drag\" width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\"><circle cx=\"9\" cy=\"6\" r=\"1.5\"/><circle cx=\"15\" cy=\"6\" r=\"1.5\"/><circle cx=\"9\" cy=\"12\" r=\"1.5\"/><circle cx=\"15\" cy=\"12\" r=\"1.5\"/><circle cx=\"9\" cy=\"18\" r=\"1.5\"/><circle cx=\"15\" cy=\"18\" r=\"1.5\"/></svg>\n {{ block.label }}\n </div>\n }\n </div>\n }\n </div>\n }\n </div>\n }\n\n @if (activeRightTab() === 'variables') {\n <div class=\"right-panel-body\">\n <h4 class=\"right-section-title\">{{ labels.t('emailTemplateEditor.templateVariables') }}</h4>\n <p class=\"right-section-desc\">{{ labels.t('emailTemplateEditor.clickAVariableToInsert') }}</p>\n\n @for (group of variableGroups(); track group.name) {\n <div class=\"block-group\">\n <button type=\"button\" class=\"block-group-header\" [attr.aria-expanded]=\"isOpen('v:' + group.name)\" (click)=\"toggleGroup('v:' + group.name)\">\n <svg class=\"chevron\" [class.expanded]=\"isOpen('v:' + group.name)\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M9 18l6-6-6-6\"/></svg>\n <span>{{ group.name }}</span>\n <span class=\"block-count\">{{ group.variables.length }}</span>\n </button>\n @if (isOpen('v:' + group.name)) {\n <div class=\"variable-list\">\n @for (v of group.variables; track v.key) {\n <button type=\"button\" class=\"variable-item\" (mousedown)=\"saveSelection()\" (click)=\"insertVariable(v)\">\n <span class=\"var-tag\">{{ '{{' + v.key + '}}' }}</span>\n <span class=\"var-example\">{{ labels.t('emailTemplateEditor.example', { example: v.example }) }}</span>\n <!-- A very short explanation of what the variable is: the host's description, else its label. -->\n <span class=\"var-description\">{{ v.description || v.label }}</span>\n </button>\n }\n </div>\n }\n </div>\n }\n </div>\n }\n\n @if (activeRightTab() === 'video' && videosEnabled()) {\n <div class=\"right-panel-body video-library-panel\">\n <h4 class=\"right-section-title\">{{ labels.t('emailTemplateEditor.videoLibrary') }}</h4>\n <p class=\"right-section-hint\">{{ labels.t('emailTemplateEditor.clickAVideoToAdd') }}</p>\n\n <div class=\"video-config-section\">\n <ui-radio-group [label]=\"labels.t('emailTemplateEditor.playback')\" orientation=\"horizontal\" [options]=\"playbackOptions\" [ngModel]=\"videoAutoplay() ? 'autoplay' : 'click'\" (ngModelChange)=\"videoAutoplay.set($event === 'autoplay')\" />\n </div>\n <div class=\"video-config-section\">\n <ui-text-input [label]=\"labels.t('emailTemplateEditor.caption')\" [placeholder]=\"labels.t('emailTemplateEditor.eGClickToWatch')\" [maxlength]=\"200\" [(ngModel)]=\"videoCaption\" />\n </div>\n <div class=\"video-config-section\">\n <ui-select [label]=\"labels.t('emailTemplateEditor.callToAction')\" [options]=\"ctaTypeOptions\" [(ngModel)]=\"videoCtaType\" />\n @if (videoCtaType()) {\n <ui-text-input [ariaLabel]=\"labels.t('emailTemplateEditor.callToActionAddress')\" type=\"url\" placeholder=\"https://...\" [(ngModel)]=\"videoCtaUrl\" />\n <ui-text-input [ariaLabel]=\"labels.t('emailTemplateEditor.callToActionButtonLabel')\" [placeholder]=\"labels.t('emailTemplateEditor.buttonLabel')\" [maxlength]=\"100\" [(ngModel)]=\"videoCtaLabel\" />\n }\n </div>\n <div class=\"video-config-section\">\n <ui-checkbox [label]=\"labels.t('emailTemplateEditor.hideReactions')\" [(checked)]=\"videoHideReactions\" />\n </div>\n\n @if (videosLoading()) {\n <div class=\"video-lib-loading\" role=\"status\" aria-busy=\"true\" [attr.aria-label]=\"labels.t('emailTemplateEditor.loadingVideos')\">\n @for (n of [1, 2, 3]; track n) {\n <div class=\"video-lib-skeleton\">\n <ui-skeleton [height]=\"40\" width=\"56px\" [radius]=\"6\" />\n <div class=\"vls-info\"><ui-skeleton [height]=\"10\" width=\"75%\" [radius]=\"5\" /><ui-skeleton [height]=\"10\" width=\"45%\" [radius]=\"5\" /></div>\n </div>\n }\n </div>\n } @else if (videoList().length === 0) {\n <ui-empty-state iconType=\"video\" [title]=\"labels.t('emailTemplateEditor.noVideosCreated')\" [message]=\"noVideosHint()\" />\n } @else {\n <div class=\"video-lib-list\">\n @for (video of videoList(); track video.id) {\n <button type=\"button\" class=\"video-lib-item\" [class.selected]=\"video.id === videoId()\" [attr.aria-pressed]=\"video.id === videoId()\" (click)=\"insertVideo(video)\">\n <span class=\"vli-thumb\">\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#94a3b8\" stroke-width=\"1.5\" aria-hidden=\"true\"><polygon points=\"5 3 19 12 5 21 5 3\"/></svg>\n @if (video.durationSeconds) {\n <span class=\"vli-dur\">{{ formatDuration(video.durationSeconds) }}</span>\n }\n </span>\n <span class=\"vli-info\">\n <span class=\"vli-title\">{{ video.title }}</span>\n <span class=\"vli-cat\">{{ categoryLabel(video.category) }}</span>\n </span>\n @if (video.id === videoId()) {\n <svg class=\"vli-check\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#2563eb\" stroke-width=\"2.5\" aria-hidden=\"true\"><polyline points=\"20 6 9 17 4 12\"/></svg>\n }\n </button>\n }\n </div>\n }\n </div>\n }\n }\n </aside>\n </div>\n </div>\n\n <!-- Test Send -->\n <ui-side-panel [open]=\"showTestSendDialog()\" [title]=\"labels.t('emailTemplateEditor.sendTestEmail')\" [primaryLabel]=\"labels.t('emailTemplateEditor.sendTest')\" [primaryLoading]=\"testSending()\" [primaryDisabled]=\"!canSendTest()\"\n (closed)=\"showTestSendDialog.set(false)\" (primaryClick)=\"onTestSend()\">\n <p class=\"config-desc\">{{ labels.t('emailTemplateEditor.sendThisTemplateToAn') }}</p>\n @if (!editingId()) {\n <div class=\"test-save-note\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\"/></svg>{{ labels.t('emailTemplateEditor.saveTheTemplateFirstBefore') }}</div>\n }\n <div class=\"config-field config-field-mt\">\n <ui-text-input [label]=\"labels.t('emailTemplateEditor.recipientEmail')\" type=\"email\" placeholder=\"you@example.com\" [(ngModel)]=\"testSendEmail\" [error]=\"testEmailError()\" (keydown.enter)=\"onTestSend()\" />\n </div>\n @if (hasUnsavedChanges()) {\n <div class=\"test-save-note\" role=\"note\" data-testid=\"test-unsaved-note\">{{ labels.t('emailTemplateEditor.youHaveUnsavedChangesThe') }}</div>\n }\n </ui-side-panel>\n\n\n `,\n styles: [`\n /* The editor fills the height its parent gives it (in an app shell: the content area down to the bottom of the viewport), and the panels\n scroll inside it, so the page itself never scrolls. */\n :host { display: flex; flex-direction: column; flex: 1; min-height: 0; }\n .required { color: #ef4444; font-weight: 400; }\n\n .editor-page {\n display: flex; flex-direction: column; flex: 1; min-height: 0;\n background: #f8fafc; overflow: hidden;\n }\n\n /* ─── Actions row (on the page background, above the panels) ─── */\n .editor-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 0 0 12px; flex-shrink: 0; }\n .editor-heading { margin: 0; font-size: 1.25rem; font-weight: 700; color: #1e293b; line-height: 1.3; min-width: 0; }\n .save-wrap { display: inline-flex; }\n .save-hint { margin: 0; font-size: 12px; color: #475569; flex-basis: 100%; text-align: right; }\n .editor-actions-buttons { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-left: auto; }\n\n .readonly-note { margin: 0; padding: 8px 16px; font-size: 0.8125rem; color: #92400e; background: #fffbeb; border-bottom: 1px solid #fde68a; }\n .readonly-note.system-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }\n\n /* ─── 3-column body ─── */\n .editor-body { display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr); flex: 1; min-height: 0; overflow: hidden; }\n\n /* ─── Left panel ─── */\n .panel-left { background: #fff; border-right: 1px solid #e2e8f0; padding: 24px; overflow-y: auto; }\n .panel-title { font-size: 1.0625rem; font-weight: 700; color: #1e293b; margin: 0 0 20px; }\n .form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }\n .form-row-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }\n .assignments-section { border-top: 1px solid #e2e8f0; padding-top: 20px; margin-top: 16px; }\n .section-title { font-size: 0.9375rem; font-weight: 700; color: #1e293b; margin: 0 0 6px; }\n .section-desc { font-size: 0.8125rem; color: #64748b; line-height: 1.5; margin: 0 0 12px; }\n .assignment-list { max-height: 340px; overflow-y: auto; margin-top: 12px; border: 1px solid #e2e8f0; border-radius: 8px; }\n .assignment-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f1f5f9; transition: background 0.1s; }\n .assignment-item:last-child { border-bottom: none; }\n .assignment-item:hover { background: #f8fafc; }\n .assignment-item:focus-visible { outline: 2px solid #3b82f6; outline-offset: -2px; }\n .assignment-item.assignment-readonly { cursor: default; }\n .assignment-item.assignment-readonly:hover { background: transparent; }\n .assignment-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }\n .assignment-text strong { font-size: 0.8125rem; color: #1e293b; }\n .assignment-text span { font-size: 0.75rem; color: #64748b; }\n .assignment-channels { display: flex; gap: 4px; flex-shrink: 0; }\n .channel-badge { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 4px; background: #f1f5f9; color: #64748b; transition: all 0.15s; }\n .channel-badge.active { background: #3b82f6; color: #fff; }\n .channel-badge.disabled { opacity: 0.4; cursor: not-allowed; }\n\n /* ─── Side-panel content ─── */\n .config-desc { font-size: 0.875rem; color: #64748b; line-height: 1.5; margin: 0; }\n .config-divider { border: none; border-top: 1px solid #e2e8f0; margin: 20px 0; }\n .config-section { display: flex; flex-direction: column; gap: 12px; }\n .config-section-label { font-size: 0.6875rem; font-weight: 700; color: #3b82f6; text-transform: uppercase; letter-spacing: 0.04em; }\n .config-field { display: flex; flex-direction: column; gap: 6px; }\n .config-field-mt { margin-top: 16px; }\n .config-label { font-size: 0.8125rem; font-weight: 600; color: #1e293b; }\n .config-readonly { padding: 9px 12px; border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; font-size: 0.875rem; color: #1e293b; }\n .config-hint { font-size: 0.75rem; color: #64748b; }\n .test-save-note { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #fef3c7; border: 1px solid #fcd34d; border-radius: 8px; font-size: 0.8125rem; color: #92400e; margin-top: 12px; }\n .test-save-note svg { flex-shrink: 0; }\n\n /* ─── Center panel ─── */\n .panel-center { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }\n .editor-tabs { display: flex; gap: 2px; padding: 12px 20px 0; background: #fff; border-bottom: 1px solid #e2e8f0; overflow-x: auto; -webkit-overflow-scrolling: touch; }\n .editor-tab { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border: 1px solid #e2e8f0; border-bottom: none; border-radius: 8px 8px 0 0; background: #f8fafc; font-size: 0.8125rem; font-weight: 600; color: #64748b; cursor: pointer; font-family: inherit; white-space: nowrap; }\n .editor-tab:hover { background: #fff; color: #1e293b; }\n .editor-tab.active { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }\n .editor-tab:focus-visible, .right-tab:focus-visible, .block-group-header:focus-visible, .variable-item:focus-visible, .add-block-btn:focus-visible, .block-item:focus-visible, .video-lib-item:focus-visible { outline: 2px solid #3b82f6; outline-offset: -2px; }\n\n .editor-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 20px; background: #fff; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }\n .toolbar-row-2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 20px; background: #fff; border-bottom: 1px solid #e2e8f0; }\n .toolbar-group { display: flex; align-items: center; gap: 2px; padding-right: 8px; border-right: 1px solid #e2e8f0; }\n .toolbar-group:last-child { border-right: none; padding-right: 0; }\n .toolbar-select { display: block; min-width: 96px; }\n .toolbar-label { font-size: 0.75rem; font-weight: 600; color: #64748b; white-space: nowrap; margin-right: 6px; }\n .hidden-color-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; border: none; padding: 0; }\n .color-indicator { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #475569; }\n .color-bar { display: block; width: 16px; height: 3px; border-radius: 2px; border: 1px solid rgba(0,0,0,0.1); }\n\n .link-dialog { background: #fff; border-bottom: 1px solid #e2e8f0; padding: 12px 20px; }\n .link-dialog-inner { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }\n .link-dialog-title { font-size: 0.8125rem; font-weight: 700; color: #1e293b; white-space: nowrap; padding-top: 10px; }\n .link-dialog-input { display: block; width: 240px; max-width: 100%; }\n .link-dialog-actions { display: flex; gap: 6px; }\n\n /* ─── Preview ─── */\n .preview-frame { flex: 1; display: flex; justify-content: center; align-items: stretch; padding: 24px; overflow-y: auto; background: #f1f5f9; }\n .preview-frame.mobile { align-items: flex-start; }\n /* The preview is a sandboxed document (no scripts, no popups): the email's own inline styles show exactly as they will be sent. */\n .preview-content { display: block; flex: 1 1 auto; max-width: 600px; width: 100%; box-sizing: border-box; min-height: 400px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; }\n .mobile-shell { width: 375px; max-width: 100%; box-sizing: border-box; min-height: 600px; border: 2px solid #1e293b; border-radius: 24px; padding: 40px 12px 24px; background: #fff; box-shadow: 0 8px 32px rgba(0,0,0,0.12); }\n .mobile-shell .preview-content { border: none; border-radius: 0; max-width: 100%; height: 520px; min-height: 0; }\n\n /* ─── Block canvas ─── */\n .blocks-canvas { flex: 1 1 0; min-height: 0; padding: 16px 20px 24px 56px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: #f1f5f9; display: flex; flex-direction: column; }\n .block-wrapper { flex-shrink: 0; position: relative; display: flex; align-items: flex-start; background: #fff; border: 2px solid transparent; border-radius: 8px; transition: border-color 0.15s, box-shadow 0.15s; }\n .block-wrapper:hover, .block-wrapper.selected, .block-wrapper:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }\n .block-wrapper:hover .block-drag-handle, .block-wrapper.selected .block-drag-handle, .block-wrapper:focus-within .block-drag-handle { opacity: 1; }\n .block-wrapper:hover .block-controls, .block-wrapper.selected .block-controls, .block-wrapper:focus-within .block-controls { opacity: 1; pointer-events: all; }\n .block-wrapper.dragging { opacity: 0.4; }\n .block-drag-handle { flex-shrink: 0; width: 28px; display: flex; align-items: flex-start; justify-content: center; padding-top: 14px; opacity: 0; transition: opacity 0.15s; cursor: grab; color: #94a3b8; }\n .block-drag-handle:active { cursor: grabbing; }\n .block-content { flex: 1; min-width: 0; padding: 12px 16px; outline: none; font-size: 0.9375rem; color: #1e293b; line-height: 1.6; min-height: 48px; overflow-wrap: anywhere; }\n .block-content:empty::before { content: attr(data-placeholder); color: #64748b; font-style: italic; pointer-events: none; }\n .block-content p { margin: 0 0 8px; }\n .block-content p:last-child { margin: 0; }\n .block-content h1, .block-content h2, .block-content h3 { margin: 8px 0 6px; color: #1e293b; }\n .block-content a { color: #3b82f6; }\n .block-content img { max-width: 100%; border-radius: 6px; }\n .block-content ul, .block-content ol { padding-left: 20px; margin: 0 0 8px; }\n .block-controls { position: absolute; top: 0; left: -48px; flex-direction: column; display: flex; gap: 2px; opacity: 0; pointer-events: none; transition: opacity 0.15s; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 3px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }\n @media (pointer: coarse) { .editor-tab, .right-tab, .block-group-header { min-height: 44px; } }\n @media (hover: none) { .block-wrapper.selected .block-controls { opacity: 1; pointer-events: all; } }\n\n .drop-zone { flex-shrink: 0; height: 8px; display: flex; align-items: center; justify-content: center; border-radius: 4px; transition: height 0.15s, background 0.15s; position: relative; }\n .drop-zone-label { font-size: 0.75rem; font-weight: 600; color: #1d4ed8; opacity: 0; transition: opacity 0.1s; }\n .drop-zone.active { height: 40px; background: rgba(59,130,246,0.08); border: 2px dashed #3b82f6; }\n .drop-zone.active .drop-zone-label { opacity: 1; }\n .add-block-btn { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; padding: 12px; margin-top: 8px; border: 2px dashed #e2e8f0; border-radius: 8px; background: none; font-size: 0.875rem; font-weight: 600; color: #475569; cursor: pointer; font-family: inherit; transition: border-color 0.15s, color 0.15s, background 0.15s; }\n .add-block-btn:hover { border-color: #3b82f6; color: #3b82f6; background: rgba(59,130,246,0.04); }\n\n /* ─── Right panel ─── */\n .panel-right { background: #fff; border-left: 1px solid #e2e8f0; display: flex; flex-direction: column; min-height: 0; min-width: 0; }\n .right-tabs { display: flex; border-bottom: 1px solid #e2e8f0; }\n .right-tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; min-height: 44px; border: none; background: none; font-size: 0.8125rem; font-weight: 600; color: #64748b; cursor: pointer; font-family: inherit; border-bottom: 2px solid transparent; }\n .right-tab:hover { color: #1e293b; }\n .right-tab.active { color: #1d4ed8; background: #eff6ff; border-bottom-color: #3b82f6; }\n .right-panel-body { flex: 1; padding: 20px; overflow-y: auto; }\n .right-section-title { font-size: 0.9375rem; font-weight: 700; color: #1e293b; margin: 0 0 12px; }\n .right-section-desc { font-size: 0.8125rem; color: #64748b; margin: 0 0 16px; line-height: 1.5; }\n .right-section-hint { font-size: 0.8125rem; color: #64748b; margin: 0 0 12px; line-height: 1.5; }\n .block-group { border-bottom: 1px solid #f1f5f9; }\n .block-group-header { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 12px 0; border: none; background: none; font-size: 0.875rem; font-weight: 600; color: #1e293b; cursor: pointer; font-family: inherit; text-align: left; }\n .block-group-header .chevron { transition: transform 0.2s; color: #94a3b8; }\n .block-group-header .chevron.expanded { transform: rotate(90deg); }\n .block-group-header span:nth-of-type(1) { flex: 1; }\n .block-count { font-size: 0.75rem; font-weight: 600; color: #475569; background: #f1f5f9; padding: 2px 8px; border-radius: 10px; margin-left: auto; }\n .block-list { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; }\n .variable-list { display: flex; flex-direction: column; padding-bottom: 8px; }\n /* A divider between every variable. */\n .variable-item + .variable-item { border-top: 1px solid #f1f5f9; border-radius: 0; }\n .block-item { display: flex; align-items: center; gap: 6px; box-sizing: border-box; width: 100%; min-height: 44px; padding: 8px 0; font-size: 0.8125rem; color: #64748b; cursor: pointer; text-align: left; border-radius: 4px; font-family: inherit; -webkit-user-select: none; user-select: none; }\n .block-item:hover { background: #f8fafc; color: #1e293b; }\n .block-item-drag { color: #cbd5e1; flex-shrink: 0; cursor: grab; }\n .variable-item { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 44px; padding: 8px 0; min-width: 0; width: 100%; box-sizing: border-box; border: none; background: none; cursor: pointer; text-align: left; border-radius: 4px; font-family: inherit; }\n .variable-item:hover { background: #f8fafc; }\n .var-tag { max-width: 100%; overflow-wrap: anywhere; font-size: 0.75rem; font-weight: 600; color: #1d4ed8; background: rgba(59,130,246,0.08); padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }\n .var-example { font-size: 0.75rem; color: #64748b; overflow-wrap: anywhere; }\n .var-description { font-size: 0.75rem; color: #64748b; line-height: 1.4; overflow-wrap: anywhere; }\n\n /* ─── Video library ─── */\n .video-library-panel { padding: 0; }\n .video-library-panel .right-section-title, .video-library-panel .right-section-hint { padding: 0 16px; }\n .video-library-panel .right-section-title { padding-top: 16px; }\n .video-config-section { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; border-bottom: 1px solid #f1f5f9; }\n .video-config-section:last-of-type { border-bottom: none; }\n .video-lib-list { display: flex; flex-direction: column; gap: 2px; padding: 8px 8px 16px; }\n .video-lib-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px; border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; text-align: left; font-family: inherit; transition: background 0.15s, border-color 0.15s; }\n .video-lib-item:hover { background: #f8fafc; border-color: #e2e8f0; }\n .video-lib-item.selected { background: #eff6ff; border-color: #93c5fd; }\n .vli-thumb { position: relative; flex-shrink: 0; width: 56px; height: 40px; border-radius: 6px; background: linear-gradient(135deg, #f1f5f9, #e2e8f0); display: flex; align-items: center; justify-content: center; }\n .vli-dur { position: absolute; bottom: 2px; right: 3px; font-size: 0.625rem; font-weight: 600; color: #fff; background: rgba(0,0,0,0.65); padding: 1px 4px; border-radius: 3px; }\n .vli-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }\n .vli-title { font-size: 0.8125rem; font-weight: 600; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .vli-cat { font-size: 0.75rem; color: #475569; }\n .vli-check { flex-shrink: 0; }\n .video-lib-loading { padding: 8px; }\n .video-lib-skeleton { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 4px; }\n .vls-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }\n\n /* ─── Responsive ─── */\n @media (max-width: 1200px) { .editor-body { grid-template-columns: 280px minmax(0, 1fr) 260px; } }\n /* Phones and small tablets: one column, the page scrolls as a whole and every panel stays reachable (details, editor, blocks / variables / video). */\n @media (max-width: 900px) {\n :host { flex: none; }\n .editor-page { flex: none; min-height: 100vh; min-height: 100dvh; overflow: visible; }\n .editor-body { display: flex; flex-direction: column; flex: none; overflow: visible; }\n .panel-left { border-right: none; border-bottom: 1px solid #e2e8f0; overflow: visible; padding: 16px; }\n .panel-center { overflow: visible; min-height: 480px; }\n .blocks-canvas { overflow: visible; min-height: 320px; }\n .panel-right { border-left: none; border-top: 1px solid #e2e8f0; }\n .right-panel-body { overflow: visible; }\n .editor-toolbar, .toolbar-row-2, .link-dialog { padding-left: 12px; padding-right: 12px; }\n .editor-tabs { padding-left: 12px; padding-right: 12px; }\n .preview-frame { padding: 12px; }\n .form-row-dates { grid-template-columns: 1fr; }\n }\n @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }\n `],\n})\nexport class EmailTemplateEditorComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly injector = inject(Injector);\n\n // ── Inputs: the template and what differs per app ────────────────────────────\n /** The template to edit. `null` = a blank new template. An object without `id` is a new template that starts from those values (e.g. a copy). */\n readonly template = input<EmailTemplateValue | null>(null);\n readonly categories = input<SelectOption<string>[]>([]);\n readonly categoryPlaceholderInput = input<string | null>(null, { alias: 'categoryPlaceholder' });\n readonly categoryPlaceholder = computed(() => this.categoryPlaceholderInput() ?? this.labels.t('emailTemplateEditor.categoryPlaceholder'));\n readonly assignmentOptions = input<EmailTemplateAssignmentOption[]>([]);\n /** The assignment shown first (e.g. the trigger the user came from). */\n readonly featuredAssignmentKey = input<string | null>(null);\n readonly assignmentsDescriptionInput = input<string | null>(null, { alias: 'assignmentsDescription' });\n readonly assignmentsDescription = computed(() => this.assignmentsDescriptionInput() ?? this.labels.t('emailTemplateEditor.assignmentsDescription'));\n readonly variableGroupsInput = input<EmailTemplateVariableGroup[] | null>(null, { alias: 'variableGroups' });\n readonly variableGroups = computed((): EmailTemplateVariableGroup[] => this.variableGroupsInput() ?? localizedEmailVariableGroups());\n readonly blockGroupsInput = input<EmailTemplateBlockGroup[] | null>(null, { alias: 'blockGroups' });\n readonly blockGroups = computed((): EmailTemplateBlockGroup[] => this.blockGroupsInput() ?? localizedEmailBlockGroups());\n /** Page heading shown at the start of the actions row (e.g. \"Create Your Template\"). Empty (default) = no heading; the buttons stay right aligned. */\n readonly heading = input('');\n readonly namePlaceholderInput = input<string | null>(null, { alias: 'namePlaceholder' });\n readonly namePlaceholder = computed(() => this.namePlaceholderInput() ?? this.labels.t('emailTemplateEditor.namePlaceholder'));\n readonly subjectPlaceholderInput = input<string | null>(null, { alias: 'subjectPlaceholder' });\n readonly subjectPlaceholder = computed(() => this.subjectPlaceholderInput() ?? this.labels.t('emailTemplateEditor.subjectPlaceholder'));\n readonly systemNoteInput = input<string | null>(null, { alias: 'systemNote' });\n readonly systemNote = computed(() => this.systemNoteInput() ?? this.labels.t('emailTemplateEditor.systemNote'));\n readonly readOnlyNoteInput = input<string | null>(null, { alias: 'readOnlyNote' });\n readonly readOnlyNote = computed(() => this.readOnlyNoteInput() ?? this.labels.t('emailTemplateEditor.readOnlyNote'));\n /** Prefix of the ids of the field errors the editor renders (`<prefix>-body-error`). */\n readonly idPrefix = input('tpl');\n /** The longest message (serialised HTML) that can be saved. */\n readonly maxBodyLength = input(EMAIL_TEMPLATE_MAX_BODY);\n readonly maxTextLength = input(EMAIL_TEMPLATE_MAX_TEXT);\n\n // ── Inputs: permissions and feature switches ─────────────────────────────────\n /** The member may change templates (false = read-only: everything is shown, nothing can be edited). */\n readonly fullAccess = input(true);\n /** A built-in template: shown read-only; a member with full access can copy it ((useAsMine)). */\n readonly systemTemplate = input(false);\n readonly testSendEnabled = input(true);\n\n // ── Inputs: request state owned by the host ──────────────────────────────────\n readonly saving = input(false);\n readonly testSending = input(false);\n\n // ── Inputs: video library ────────────────────────────────────────────────────\n /**\n * The host's videos. `null` (the default) = this app has no videos: the Video tab is not shown at all. Any list - even an empty one while the\n * host loads it on demand (see `(videosRequested)`) - turns the Video tab on.\n */\n readonly videos = input<EmailTemplateVideo[] | null>(null);\n /** Hides the Video tab completely even when `videos` is passed. */\n readonly hideVideos = input(false);\n readonly videosEnabled = computed(() => this.videos() !== null && !this.hideVideos());\n protected readonly videoList = computed(() => this.videos() ?? []);\n readonly videosLoading = input(false);\n readonly videoDefaults = input<EmailTemplateVideoDefaults>(EMPTY_VIDEO_DEFAULTS);\n readonly videoLink = input<EmailTemplateVideoLinkFn>(DEFAULT_VIDEO_LINK);\n readonly noVideosHintInput = input<string | null>(null, { alias: 'noVideosHint' });\n readonly noVideosHint = computed(() => this.noVideosHintInput() ?? this.labels.t('emailTemplateEditor.noVideosHint'));\n\n // ── Outputs ──────────────────────────────────────────────────────────────────\n readonly save = output<EmailTemplateSavePayload>();\n readonly testSend = output<string>();\n /** The Video tab was opened (the host loads the library once). */\n readonly videosRequested = output<void>();\n readonly useAsMine = output<void>();\n\n // ── Form state ───────────────────────────────────────────────────────────────\n readonly editingId = signal<string | null>(null);\n readonly isNew = computed(() => !this.editingId());\n readonly name = signal('');\n readonly subject = signal('');\n readonly category = signal('');\n readonly useAllYear = signal(true);\n readonly activeFrom = signal('');\n readonly activeTo = signal('');\n readonly videoId = signal<string | null>(null);\n readonly videoTitle = signal<string | null>(null);\n /** The triggers this template is assigned to (an email template is only ever assigned for email); the rows shown are `assignmentOptions` with this applied. */\n private readonly assignedKeys = signal<string[]>([]);\n private readonly assignmentState = computed((): AssignmentView[] => this.assignmentOptions().map(o => ({ ...o, assigned: this.assignedKeys().includes(o.key) })));\n\n // ── Blocks ───────────────────────────────────────────────────────────────────\n readonly blocks = signal<EmailBlock[]>([]);\n readonly selectedBlockId = signal<string | null>(null);\n private initializedBlockIds = new Set<string>();\n private savedRange: Range | null = null;\n private readonly blockEditors = viewChildren<ElementRef<HTMLDivElement>>('blockEditor');\n private readonly colorInputRef = viewChild<ElementRef<HTMLInputElement>>('colorInput');\n /** The stored body of the template being edited; null for a new one. */\n private readonly loadedBody = signal<string | null>(null);\n /** True once the user really edited the message (typing, blocks, formatting, links...). */\n private readonly bodyEdited = signal(false);\n private savedSnapshot = signal<string | null>(null);\n\n // ── Drag and drop ────────────────────────────────────────────────────────────\n private dragFromPalette: EmailTemplateBlock | null = null;\n readonly dragFromCanvas = signal<number | null>(null);\n readonly dragOverIndex = signal<number | null>(null);\n\n // ── Toolbar ──────────────────────────────────────────────────────────────────\n readonly currentColor = signal('#1e293b');\n readonly blockSpacing = signal('');\n readonly headingKey = signal(0);\n readonly sizeKey = signal(0);\n private readonly _headingOptions = computed((): SelectOption<string>[] => [\n { value: 'p', label: this.labels.t('emailTemplateEditor.heading.normal') }, { value: 'h1', label: this.labels.t('emailTemplateEditor.heading.h1') },\n { value: 'h2', label: this.labels.t('emailTemplateEditor.heading.h2') }, { value: 'h3', label: this.labels.t('emailTemplateEditor.heading.h3') },\n ]);\n get headingOptions(): SelectOption<string>[] { return this._headingOptions(); }\n readonly fontSizeOptions = FONT_SIZE_OPTIONS;\n private readonly _spacingTabs = computed((): PillTab[] => [\n { key: 'none', label: this.labels.t('emailTemplateEditor.spacing.none') }, { key: '8px', label: this.labels.t('emailTemplateEditor.spacing.small') },\n { key: '16px', label: this.labels.t('emailTemplateEditor.spacing.medium') }, { key: '32px', label: this.labels.t('emailTemplateEditor.spacing.large') },\n ]);\n get spacingTabs(): PillTab[] { return this._spacingTabs(); }\n /** The grey hint shown in the empty first block. */\n protected readonly startPlaceholder = computed(() => this.labels.t('emailTemplateEditor.startWriting'));\n private readonly _ctaTypeOptions = computed((): SelectOption<string>[] => [\n { value: '', label: this.labels.t('emailTemplateEditor.cta.none') }, { value: 'schedule', label: this.labels.t('emailTemplateEditor.cta.schedule') },\n { value: 'contact', label: this.labels.t('emailTemplateEditor.cta.contact') }, { value: 'custom', label: this.labels.t('emailTemplateEditor.cta.custom') },\n ]);\n get ctaTypeOptions(): SelectOption<string>[] { return this._ctaTypeOptions(); }\n private readonly _playbackOptions = computed(() => [\n { value: 'click', label: this.labels.t('emailTemplateEditor.playback.click') }, { value: 'autoplay', label: this.labels.t('emailTemplateEditor.playback.autoplay') },\n ]);\n get playbackOptions() { return this._playbackOptions(); }\n\n // ── Dialogs ──────────────────────────────────────────────────────────────────\n readonly showLinkDialog = signal(false);\n readonly linkUrl = signal('');\n readonly linkText = signal('');\n /** True when the link is made from selected text (the text field is then not needed). */\n readonly linkTextFromSelection = signal(false);\n readonly showImageDialog = signal(false);\n readonly imageUrl = signal('');\n readonly imageAlt = signal('');\n readonly showTestSendDialog = signal(false);\n readonly testSendEmail = signal('');\n\n // ── Tabs / palette ───────────────────────────────────────────────────────────\n readonly activeEditorTab = signal<EditorTab>('edit');\n readonly activeRightTab = signal<RightTab>('blocks');\n readonly blockSearch = signal('');\n readonly assignmentSearch = signal('');\n /** Groups the user opened or closed; the first variable group starts open. */\n private readonly toggledGroups = signal<Set<string>>(new Set());\n\n // ── Video options ────────────────────────────────────────────────────────────\n readonly videoAutoplay = signal(false);\n readonly videoCaption = signal('');\n readonly videoCtaType = signal('');\n readonly videoCtaUrl = signal('');\n readonly videoCtaLabel = signal('');\n readonly videoHideReactions = signal(false);\n\n // ── Derived ──────────────────────────────────────────────────────────────────\n readonly canWrite = computed(() => this.fullAccess() && !this.systemTemplate());\n /** A system template can be copied into a new template of the company's own (full access). */\n readonly canCopySystem = computed(() => this.fullAccess() && this.systemTemplate() && !!this.editingId());\n\n readonly filteredAssignments = computed(() => {\n const featured = this.featuredAssignmentKey();\n const all = this.assignmentState();\n const ordered = featured ? [...all.filter(a => a.key === featured), ...all.filter(a => a.key !== featured)] : all;\n const q = this.assignmentSearch().trim().toLowerCase();\n return q ? ordered.filter(a => a.name.toLowerCase().includes(q) || a.description.toLowerCase().includes(q)) : ordered;\n });\n\n readonly filteredBlockGroups = computed(() => {\n const q = this.blockSearch().trim().toLowerCase();\n const groups = this.blockGroups();\n if (!q) return groups;\n return groups.map(g => ({ ...g, blocks: g.blocks.filter(b => b.label.toLowerCase().includes(q)) })).filter(g => g.blocks.length > 0);\n });\n\n private readonly serialized = computed(() => this.serialize(this.blocks()));\n readonly previewHtml = this.serialized;\n private readonly sanitizer = inject(DomSanitizer);\n /** The Preview / Mobile document: a full page with the email's own styles. It is shown in a sandboxed iframe (no scripts, no popups), so trusting the markup here cannot run anything. */\n readonly previewDoc = computed((): SafeHtml => this.sanitizer.bypassSecurityTrustHtml(buildPreviewDocument(this.serialized())));\n /** Characters in the body as it is saved. */\n readonly bodyLength = computed(() => this.serialized().trim().length);\n readonly bodyHasContent = computed(() => this.blocks().some(b => blockHasContent(b.html)));\n /** The body as the server stores it and as the editor serialises it right after loading: while they match the message has not been touched. */\n readonly bodyUnchanged = computed(() => this.loadedBody() !== null && !this.bodyEdited());\n\n readonly nameError = computed(() => {\n const v = this.name().trim();\n if (!v) return this.labels.t('emailTemplateEditor.nameRequired');\n return v.length > this.maxTextLength() ? this.labels.t('emailTemplateEditor.nameTooLong', { max: this.maxTextLength() }) : '';\n });\n readonly subjectError = computed(() => {\n const v = this.subject().trim();\n if (!v) return this.labels.t('emailTemplateEditor.subjectRequired');\n return v.length > this.maxTextLength() ? this.labels.t('emailTemplateEditor.subjectTooLong', { max: this.maxTextLength() }) : '';\n });\n readonly bodyError = computed(() => {\n if (!this.bodyHasContent()) return this.labels.t('emailTemplateEditor.bodyRequired');\n const n = this.bodyLength();\n const max = this.maxBodyLength();\n // A stored body longer than the limit that has not been touched is accepted by the server (legacy rows), so it is here.\n return n > max && !this.bodyUnchanged() ? this.labels.t('emailTemplateEditor.bodyTooLong', { max: this.labels.formatNumber(max), actual: this.labels.formatNumber(n) }) : '';\n });\n /** \"Active From / To\" only apply when the template is not \"all year\"; when both are given To may not be before From. */\n readonly datesError = computed(() => {\n if (this.useAllYear() || !this.activeFrom() || !this.activeTo()) return '';\n return this.activeTo() < this.activeFrom() ? this.labels.t('emailTemplateEditor.datesOrder') : '';\n });\n /** Errors are held back until the user has had a chance to act: a field is blurred, the message is edited or its blocks are left, or the assignments are changed or left. A failed Save (`submitAttempted`) reveals nothing on an untouched field. */\n readonly submitAttempted = signal(false);\n readonly nameTouched = signal(false);\n readonly subjectTouched = signal(false);\n readonly nameErrorShown = computed(() => this.nameTouched() ? this.nameError() : '');\n readonly subjectErrorShown = computed(() => this.subjectTouched() ? this.subjectError() : '');\n /** True once focus left the message blocks (the body error then shows). Editing the message also counts (`bodyEdited`). A failed Save never reveals it. */\n readonly bodyBlurred = signal(false);\n readonly bodyErrorShown = computed(() => this.bodyEdited() || this.bodyBlurred() ? this.bodyError() : '');\n /** A template must be assigned to at least one automation (only in an app that offers assignments at all). */\n readonly assignmentError = computed(() => this.assignmentOptions().length > 0 && !this.assignmentState().some(a => a.assigned) ? this.labels.t('emailTemplateEditor.assignmentRequired') : '');\n /** True once the user has changed an assignment or focus left the assignments list; a failed Save never sets it, so the message never shows on a control nobody has touched. */\n readonly assignmentsTouched = signal(false);\n readonly assignmentErrorShown = computed(() => this.assignmentsTouched() ? this.assignmentError() : '');\n readonly canSave = computed(() => !this.nameError() && !this.subjectError() && !this.bodyError() && !this.datesError() && !this.assignmentError());\n /** Save is offered to members who can write and stays disabled until every rule passes: a name, a subject, a message with some design (text or an image) and at least one assignment. */\n readonly saveDisabled = computed(() => !this.canWrite() || !this.canSave());\n /** What is still missing, shown as the tooltip of the disabled Save button ('' when Save is available or the member cannot write). */\n readonly saveHint = computed(() => {\n if (!this.canWrite() || this.canSave()) return '';\n const missing: string[] = [];\n if (this.nameError()) missing.push(this.name().trim() ? this.labels.t('emailTemplateEditor.missing.shorterName') : this.labels.t('emailTemplateEditor.missing.name'));\n if (this.subjectError()) missing.push(this.subject().trim() ? this.labels.t('emailTemplateEditor.missing.shorterSubject') : this.labels.t('emailTemplateEditor.missing.subject'));\n if (this.bodyError()) missing.push(this.bodyHasContent() ? this.labels.t('emailTemplateEditor.missing.shorterMessage') : this.labels.t('emailTemplateEditor.missing.message'));\n if (this.assignmentError()) missing.push(this.labels.t('emailTemplateEditor.missing.assignment'));\n return missing.length ? this.labels.t('emailTemplateEditor.saveHint', { items: missing.join(', ') }) : this.datesError();\n });\n\n /** True once the user left a date input; until then the visible hint does not print the dates message (the tooltip still carries it). */\n readonly datesTouched = signal(false);\n /** The visible line under Save: the generic \"Add a name, a subject, ...\" / \"Add a shorter name ...\" what-is-missing STATUS text of a disabled button (role=status), shown on an untouched form on purpose; it is never a field-specific error message (those wait for their field, and the dates message waits for `datesTouched`). The 'shorter ...' wording is the same generic status, not the field's own \"Too long (max N characters)\" error.\n * Details: a dates-only problem is printed only after the date inputs were touched. */\n readonly saveHintVisible = computed(() => {\n const hint = this.saveHint();\n return hint && hint === this.datesError() && !this.datesTouched() ? '' : hint;\n });\n\n private normalizedLink = computed(() => {\n const url = this.linkUrl().trim();\n if (!url) return '';\n return url.startsWith('http://') || url.startsWith('https://') || url.startsWith('mailto:') ? url : 'https://' + url;\n });\n /** Why Insert is disabled: nothing for an empty field, a message for an address that is not a link. */\n readonly linkUrlError = computed(() => {\n const url = this.normalizedLink();\n if (!url) return '';\n if (url.startsWith('mailto:')) return /^mailto:[^\\s@\"<>]+@[^\\s@\"<>]+\\.[^\\s@\"<>]+$/.test(url) ? '' : this.labels.t('emailTemplateEditor.validEmail');\n return isWebUrl(url) ? '' : this.labels.t('emailTemplateEditor.validWebAddress');\n });\n readonly canInsertLink = computed(() => !!this.linkUrl().trim() && !this.linkUrlError());\n readonly imageUrlError = computed(() => {\n const url = this.imageUrl().trim();\n return !url || isWebUrl(url) ? '' : this.labels.t('emailTemplateEditor.validImageAddress');\n });\n readonly canInsertImage = computed(() => !!this.imageUrl().trim() && !this.imageUrlError());\n readonly testEmailError = computed(() => {\n const email = this.testSendEmail().trim();\n return !email || isValidEmailAddress(email) ? '' : this.labels.t('emailTemplateEditor.validEmail');\n });\n readonly canSendTest = computed(() => this.canWrite() && !!this.editingId() && !!this.testSendEmail().trim() && !this.testEmailError() && !this.testSending());\n /** The test email is the SAVED template: true when the editor holds changes that were not saved yet. */\n readonly hasUnsavedChanges = computed(() => !!this.editingId() && this.savedSnapshot() !== null && this.savedSnapshot() !== this.snapshot());\n\n constructor() {\n effect(() => {\n const t = this.template();\n untracked(() => this.applyTemplate(t));\n });\n effect(() => {\n const d = this.videoDefaults();\n untracked(() => {\n this.videoAutoplay.set(d.autoplay);\n this.videoCaption.set(d.caption);\n this.videoCtaType.set(d.ctaType);\n this.videoCtaUrl.set(d.ctaUrl);\n this.videoCtaLabel.set(d.ctaLabel);\n this.videoHideReactions.set(d.hideReactions);\n });\n });\n // The Video tab can go away while it is open (the host passes no videos any more): fall back to Blocks so the panel never goes blank.\n effect(() => {\n if (!this.videosEnabled() && this.activeRightTab() === 'video') untracked(() => this.activeRightTab.set('blocks'));\n });\n // Focus the first field of an inline dialog when it opens.\n effect(() => {\n if (this.showLinkDialog() || this.showImageDialog()) {\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLInputElement>('.link-dialog input')?.focus(), { injector: this.injector });\n }\n });\n // New block editors get their HTML once, after render - never re-set, so Angular never moves the caret.\n afterEveryRender(() => {\n const current = this.blocks();\n for (const ref of this.blockEditors()) {\n const el = ref.nativeElement;\n const blockId = el.dataset['blockId'];\n if (blockId && !this.initializedBlockIds.has(blockId)) {\n const block = current.find(b => b.id === blockId);\n if (block !== undefined) {\n el.innerHTML = block.html;\n setEditorSpacing(el, block.spacing);\n this.initializedBlockIds.add(blockId);\n }\n }\n }\n });\n }\n\n // ── Host callbacks ───────────────────────────────────────────────────────────\n\n /** A create succeeded: the template now has an id (Test Send becomes available) and what is on screen is the saved version. */\n markSaved(id: string | null = this.editingId()): void {\n this.syncActiveBlockHtml();\n this.editingId.set(id);\n this.savedSnapshot.set(this.snapshot());\n }\n\n /** The test email was sent: close the dialog. */\n closeTestSend(): void { this.showTestSendDialog.set(false); }\n\n // ── Template load / save ─────────────────────────────────────────────────────\n\n private applyTemplate(t: EmailTemplateValue | null): void {\n this.initializedBlockIds = new Set();\n this.editingId.set(t?.id ?? null);\n this.name.set(t?.name ?? '');\n this.subject.set(t?.subject ?? '');\n this.category.set(t?.category ?? '');\n this.useAllYear.set(t?.useAllYear ?? true);\n this.activeFrom.set(t?.activeFrom ?? '');\n this.activeTo.set(t?.activeTo ?? '');\n this.videoId.set(t?.videoId ?? null);\n this.videoTitle.set(t?.videoTitle ?? null);\n // A template that is not stored yet and has no message starts with the prompt block; a stored one with an empty message gets an empty block.\n this.blocks.set(!t || (!t.id && !(t.body ?? '').trim())\n ? [{ id: this.genId(), html: '' }] // empty: the first block shows the grey \"Start writing your email...\" hint until something is typed\n : this.htmlToBlocks(t.body ?? ''));\n // The first block is selected from the start, so the toolbar (Block spacing) works on it without clicking into it first.\n this.selectedBlockId.set(this.blocks()[0]?.id ?? null);\n this.blockSpacing.set(this.blocks()[0]?.spacing ?? '');\n // Remember the stored body of the template being edited (not of a copy, which is a new template).\n this.loadedBody.set(t?.id ? (t.body ?? '') : null);\n this.bodyEdited.set(false);\n this.bodyBlurred.set(false);\n this.datesTouched.set(false);\n this.submitAttempted.set(false);\n this.nameTouched.set(false);\n this.subjectTouched.set(false);\n this.assignedKeys.set([...(t?.assignments ?? [])]);\n this.assignmentsTouched.set(false);\n this.savedSnapshot.set(t?.id ? this.snapshot() : null);\n }\n\n /** Focus left the message blocks for somewhere outside them: the body error may show now. */\n onBodyFocusOut(event: FocusEvent): void {\n const next = event.relatedTarget as Node | null;\n if (next && (event.currentTarget as HTMLElement).contains(next)) return;\n this.bodyBlurred.set(true);\n }\n\n /** Focus left the assignments list for somewhere outside it: the assignment error may show now. */\n onAssignmentsFocusOut(event: FocusEvent): void {\n const next = event.relatedTarget as Node | null;\n if (next && (event.currentTarget as HTMLElement).contains(next)) return;\n this.assignmentsTouched.set(true);\n }\n\n onSave(): void {\n if (this.saving() || !this.canWrite()) return; // the button is disabled in these cases; a defensive guard only\n if (!this.canSave()) { this.submitAttempted.set(true); return; } // the button is disabled while a rule fails; a defensive guard that only records the attempt (name / subject messages still wait for their field to be left; the body and assignment messages wait for the user to leave them)\n // Decided BEFORE the sync: syncing re-serialises the blocks, which can change the text of a legacy body that does not survive a parse / serialise round trip.\n const keepStoredBody = this.bodyUnchanged() && this.bodyLength() > this.maxBodyLength();\n this.syncActiveBlockHtml();\n this.save.emit({\n name: this.name(),\n subject: this.subject(),\n // An untouched legacy body over the limit goes back exactly as stored, so the server sees it unchanged.\n body: keepStoredBody ? (this.loadedBody() ?? '') : this.serialized(),\n category: this.category(),\n useAllYear: this.useAllYear(),\n activeFrom: !this.useAllYear() && this.activeFrom() ? this.activeFrom() : null,\n activeTo: !this.useAllYear() && this.activeTo() ? this.activeTo() : null,\n videoId: this.videoId(),\n assignments: this.assignmentState().filter(a => a.assigned).map(a => a.key),\n });\n }\n\n private snapshot(): string {\n return JSON.stringify([this.name(), this.subject(), this.category(), this.useAllYear(), this.activeFrom(), this.activeTo(), this.serialized()]);\n }\n\n // ── Block serialization ──────────────────────────────────────────────────────\n\n private serialize(blocks: EmailBlock[]): string {\n return blocks.map(b => {\n // Spacing is an inner wrapper div so it survives data-block stripping during email delivery.\n const content = b.spacing ? `<div data-spacing=\"true\" style=\"padding:${b.spacing} 0\">${b.html}</div>` : b.html;\n return `<div data-block=\"true\">${content}</div>`;\n }).join('');\n }\n\n private htmlToBlocks(html: string): EmailBlock[] {\n if (!html || !html.trim()) return [{ id: this.genId(), html: '<p></p>' }];\n const div = new DOMParser().parseFromString(html, 'text/html').body; // an inert document: stored HTML never loads images or runs handlers here\n const blockDivs = Array.from(div.querySelectorAll(':scope > [data-block]'));\n if (blockDivs.length > 0) {\n return blockDivs.map(el => {\n const spacingEl = (el as HTMLElement).querySelector(':scope > [data-spacing]') as HTMLElement | null;\n if (spacingEl) {\n const spacing = spacingEl.style.padding?.split(' ')[0] || undefined;\n return { id: this.genId(), html: spacingEl.innerHTML, spacing };\n }\n return { id: this.genId(), html: el.innerHTML };\n });\n }\n return [{ id: this.genId(), html }];\n }\n\n private genId(): string { return Math.random().toString(36).slice(2, 10); }\n\n private editorFor(id: string | null): ElementRef<HTMLDivElement> | undefined {\n return id ? this.blockEditors().find(r => r.nativeElement.dataset['blockId'] === id) : undefined;\n }\n\n /** Copies each block's HTML from its DOM element (before saving / preview). */\n syncActiveBlockHtml(): void {\n const dom = new Map<string, string>();\n for (const ref of this.blockEditors()) {\n const id = ref.nativeElement.dataset['blockId'];\n if (id) dom.set(id, ref.nativeElement.innerHTML);\n }\n if (dom.size === 0) return;\n this.blocks.update(list => list.map(b => dom.has(b.id) && dom.get(b.id) !== b.html ? { ...b, html: dom.get(b.id)! } : b));\n }\n\n private syncBlock(): void {\n const id = this.selectedBlockId();\n const ref = this.editorFor(id);\n if (!id || !ref) return;\n const html = ref.nativeElement.innerHTML;\n this.blocks.update(list => list.map(b => b.id === id ? { ...b, html } : b));\n }\n\n setEditorTab(tab: EditorTab): void {\n const previous = this.activeEditorTab();\n if (tab !== 'edit') this.syncActiveBlockHtml(); // the preview reads the blocks, so the DOM text goes in first\n // Leaving Edit destroys the block editors; coming back creates new elements that must be filled from the blocks again.\n if (tab === 'edit' && previous !== 'edit') this.initializedBlockIds = new Set();\n this.activeEditorTab.set(tab);\n }\n\n // ── Block operations ─────────────────────────────────────────────────────────\n\n addBlock(blockKey = 'text-block'): void {\n if (!this.canWrite()) return;\n this.addBlockHtml(this.blockHtml(blockKey));\n }\n\n private addBlockHtml(html: string, at?: number): EmailBlock {\n this.bodyEdited.set(true);\n const block: EmailBlock = { id: this.genId(), html };\n this.blocks.update(list => at === undefined ? [...list, block] : [...list.slice(0, at), block, ...list.slice(at)]);\n this.selectedBlockId.set(block.id);\n return block;\n }\n\n deleteBlock(index: number): void {\n if (!this.canWrite()) return;\n const list = this.blocks();\n if (index < 0 || index >= list.length) return; // nothing to delete: not an edit\n if (list.length === 1) return; // the only block cannot be deleted (the delete icon is not shown for it either); edit or replace its text instead\n this.bodyEdited.set(true);\n this.initializedBlockIds.delete(list[index].id);\n const next = list.filter((_, i) => i !== index);\n this.blocks.set(next);\n this.selectedBlockId.set(next[Math.min(index, next.length - 1)].id);\n }\n\n duplicateBlock(index: number): void {\n if (!this.canWrite()) return;\n const list = this.blocks();\n if (index < 0 || index >= list.length) return; // nothing to copy: not an edit\n this.bodyEdited.set(true);\n const src = list[index];\n // The DOM is read first so the copy holds what is on screen.\n const html = this.editorFor(src.id)?.nativeElement.innerHTML ?? src.html;\n const copy: EmailBlock = { id: this.genId(), html, spacing: src.spacing };\n this.blocks.set([...list.slice(0, index + 1), copy, ...list.slice(index + 1)]);\n this.selectedBlockId.set(copy.id);\n }\n\n moveBlock(index: number, direction: -1 | 1): void {\n if (!this.canWrite()) return;\n const list = this.blocks();\n const target = index + direction;\n if (index < 0 || index >= list.length || target < 0 || target >= list.length) return; // nothing moves: not an edit\n this.bodyEdited.set(true);\n const next = [...list];\n [next[index], next[target]] = [next[target], next[index]];\n this.blocks.set(next);\n }\n\n onBlockInput(event: Event, block: EmailBlock): void {\n if (!this.canWrite()) return;\n this.bodyEdited.set(true);\n const html = (event.target as HTMLElement).innerHTML;\n this.blocks.update(list => list.map(b => b.id === block.id ? { ...b, html } : b));\n }\n\n /**\n * Typing and pasting stop at the body limit: input that would push the saved HTML past it is refused before it reaches the block\n * (the disabled Save and the inline message cover everything else). Deleting is always allowed.\n */\n onBlockBeforeInput(event: InputEvent): void {\n if (!this.canWrite()) { event.preventDefault(); return; }\n if (event.inputType.startsWith('delete') || event.inputType.startsWith('history')) return;\n // A block being dragged must never land in the text as a character string.\n if (isBlockDrag(event)) { event.preventDefault(); return; }\n const incoming = event.data ?? event.dataTransfer?.getData('text/plain') ?? '';\n if (!incoming) return;\n // The estimate counts what is SAVED: `&`, `<`, `>` and a non-breaking space become entities (quotes in text stay one character each), and typing over a selection replaces it. `insertCompositionText`\n // (IME, many phone keyboards) is never cancelable: the text goes in and the disabled Save backstop stops the save.\n const sel = window.getSelection();\n const replaced = sel && !sel.isCollapsed && insideEditorBlock(sel.anchorNode) ? serializedTextLength(sel.toString()) : 0;\n if (this.bodyLength() - replaced + serializedTextLength(incoming) > this.maxBodyLength()) event.preventDefault();\n }\n\n onBlockFocus(block: EmailBlock): void {\n this.selectedBlockId.set(block.id);\n this.blockSpacing.set(block.spacing ?? '');\n }\n\n // ── Drag and drop ────────────────────────────────────────────────────────────\n\n onPaletteDragStart(event: DragEvent, block: EmailTemplateBlock): void {\n if (!this.canWrite()) { event.preventDefault(); return; }\n this.dragFromPalette = block;\n this.dragFromCanvas.set(null);\n event.dataTransfer!.effectAllowed = 'copy';\n event.dataTransfer!.setData(EMAIL_BLOCK_DRAG_TYPE, block.key); // custom type: see EMAIL_BLOCK_DRAG_TYPE\n }\n\n /**\n * Starts reordering a block. Only the block's drag HANDLE is draggable (not the whole block): a draggable ancestor of a contenteditable makes\n * Firefox and Safari hijack mouse text selection inside it. `wrapper` is the block, shown as the drag image instead of the small handle.\n */\n onBlockDragStart(event: DragEvent, index: number, wrapper?: HTMLElement): void {\n if (!this.canWrite()) { event.preventDefault(); return; }\n if (event.target !== event.currentTarget) return; // a text drag that bubbled up from inside a block is not a block drag\n this.dragFromCanvas.set(index);\n this.dragFromPalette = null;\n event.dataTransfer!.effectAllowed = 'move';\n event.dataTransfer!.setData(EMAIL_BLOCK_DRAG_TYPE, String(index));\n if (wrapper) event.dataTransfer!.setDragImage?.(wrapper, 0, 0);\n event.stopPropagation();\n }\n\n onBlockDragEnd(): void {\n this.dragFromCanvas.set(null);\n this.dragFromPalette = null;\n this.dragOverIndex.set(null);\n }\n\n /** The canvas as a whole accepts only a block drag; a text drag inside a block keeps the browser's own behaviour. */\n onCanvasDragOver(event: DragEvent): void {\n if (this.canWrite() && isBlockDrag(event)) event.preventDefault();\n }\n\n onDropZoneDragOver(event: DragEvent, index: number): void {\n if (!this.canWrite() || !isBlockDrag(event)) return; // `types` is readable during dragover in every engine (Safari hides `getData` there)\n event.preventDefault();\n event.dataTransfer!.dropEffect = this.dragFromPalette ? 'copy' : 'move';\n if (this.dragOverIndex() !== index) this.dragOverIndex.set(index);\n }\n\n onDropZoneLeave(): void { this.dragOverIndex.set(null); }\n\n onDropZoneDrop(event: DragEvent, insertBefore: number): void {\n if (!this.canWrite()) { event.preventDefault(); return; }\n const fromCanvas = this.dragFromCanvas();\n if (this.dragFromPalette === null && fromCanvas === null) return; // not a block drag (e.g. text): leave it to the browser / the beforeinput guard\n event.preventDefault();\n this.dragOverIndex.set(null);\n if (this.dragFromPalette) {\n const html = this.dragFromPalette.html;\n this.dragFromPalette = null;\n this.addBlockHtml(html, insertBefore);\n } else if (fromCanvas !== null) {\n const to = fromCanvas < insertBefore ? insertBefore - 1 : insertBefore;\n if (fromCanvas !== to) {\n const next = [...this.blocks()];\n const [moved] = next.splice(fromCanvas, 1);\n next.splice(to, 0, moved);\n this.blocks.set(next);\n this.bodyEdited.set(true);\n }\n this.dragFromCanvas.set(null);\n }\n }\n\n // ── Toolbar ──────────────────────────────────────────────────────────────────\n\n /**\n * Mousedown on the toolbar keeps the selection in the editor (a button click must not blur it). A `<select>` / `<input>` must be left alone:\n * preventing the default of its mousedown stops the dropdown from opening. Those controls take focus, so they save the selection first\n * (`(mousedown)=\"saveSelection()\"`) and the command restores it.\n */\n preventFocusLoss(event: MouseEvent): void {\n const target = event.target as Element | null;\n if (target?.closest?.('select, input')) return;\n event.preventDefault();\n }\n\n /** Remembers the selection before a control takes focus. Only a selection inside an editor block is kept; anything else clears an older one. */\n saveSelection(): void {\n const sel = window.getSelection();\n const range = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n this.savedRange = range && insideEditorBlock(range.commonAncestorContainer) ? range.cloneRange() : null;\n }\n\n /**\n * Puts the remembered selection back, once. A saved range is used only when focus really left the editor (a dialog, a select, the colour\n * picker): when the live selection is already inside a block (a toolbar button keeps it there) that live selection wins, and a range left over\n * from an earlier interaction is dropped instead of formatting the wrong block.\n */\n private restoreSelection(): void {\n const saved = this.savedRange;\n this.savedRange = null;\n const sel = window.getSelection();\n const live = !!sel && sel.rangeCount > 0 && insideEditorBlock(sel.getRangeAt(0).commonAncestorContainer);\n if (live || !saved || !saved.commonAncestorContainer.isConnected || !insideEditorBlock(saved.commonAncestorContainer)) return;\n sel?.removeAllRanges();\n sel?.addRange(saved);\n }\n\n /** The HTML of the block being edited, or null when its editor is not on screen. */\n private activeBlockHtml(): string | null {\n return this.editorFor(this.selectedBlockId())?.nativeElement.innerHTML ?? null;\n }\n\n /**\n * Runs one editing command and marks the body edited only when it can have changed it: it ran over a real (non-collapsed) selection, or the\n * block's HTML is different afterwards. A click on Bold with only a caret in an untouched legacy body is not an edit. When the block cannot be\n * read the command counts as an edit, so a real edit is never lost; typing always raises `(input)`, which marks it too.\n */\n private runEditCommand(run: () => void): void {\n this.restoreSelection();\n const sel = window.getSelection();\n const overSelection = !!sel && sel.rangeCount > 0 && !sel.isCollapsed && insideEditorBlock(sel.getRangeAt(0).commonAncestorContainer);\n const before = this.activeBlockHtml();\n run();\n if (overSelection || before === null || before !== this.activeBlockHtml()) this.bodyEdited.set(true);\n }\n\n execCommand(cmd: string, value?: string): void {\n if (!this.canWrite()) return;\n this.runEditCommand(() => { document.execCommand(cmd, false, value ?? undefined); });\n this.syncBlock();\n }\n\n onHeading(value: string): void {\n this.execCommand('formatBlock', value);\n this.headingKey.update(k => k + 1); // a fresh select shows \"Normal\" again\n }\n\n onFontSize(value: string): void {\n this.applyFontSize(value);\n this.sizeKey.update(k => k + 1); // a fresh select shows \"Size\" again\n }\n\n applyFontSize(size: string): void {\n if (!this.canWrite() || !size) return;\n this.restoreSelection();\n const sel = window.getSelection();\n if (!sel || sel.rangeCount === 0) return;\n const range = sel.getRangeAt(0);\n if (range.collapsed || !insideEditorBlock(range.commonAncestorContainer)) return; // text outside the editor is never wrapped\n this.bodyEdited.set(true);\n try {\n const fragment = range.extractContents();\n const span = document.createElement('span');\n span.style.fontSize = size;\n span.appendChild(fragment);\n range.insertNode(span);\n sel.collapse(span, 1);\n } catch {\n // Fallback when the range cannot be wrapped directly: the text and the size are escaped, never written into HTML as typed.\n document.execCommand('insertHTML', false, `<span style=\"font-size:${escapeHtml(size)}\">${escapeHtml(sel.toString())}</span>`);\n }\n this.syncBlock();\n }\n\n applyTextColor(color: string): void {\n if (!this.canWrite()) return;\n this.currentColor.set(color);\n this.runEditCommand(() => {\n document.execCommand('styleWithCSS', false, 'true');\n document.execCommand('foreColor', false, color);\n });\n this.syncBlock();\n }\n\n openColorPicker(): void {\n this.saveSelection();\n this.colorInputRef()?.nativeElement.click();\n }\n\n applySpacing(value: string): void {\n if (!this.canWrite()) return;\n this.blockSpacing.set(value);\n const id = this.selectedBlockId();\n if (!id) return;\n const ref = this.editorFor(id);\n if (ref) setEditorSpacing(ref.nativeElement, value);\n const block = this.blocks().find(b => b.id === id);\n if (!block) return;\n const changed = (block.spacing ?? '') !== (value ?? '');\n this.blocks.update(list => list.map(b => b.id === id ? { ...b, spacing: value || undefined } : b));\n if (changed) this.bodyEdited.set(true); // picking the spacing it already has is not an edit\n }\n\n // ── Link / image dialogs ─────────────────────────────────────────────────────\n\n openLinkDialog(): void {\n if (!this.canWrite()) return;\n this.saveSelection();\n const selected = window.getSelection()?.toString() || '';\n this.linkText.set(selected);\n this.linkTextFromSelection.set(!!selected);\n this.linkUrl.set('');\n this.showLinkDialog.set(true);\n }\n\n insertLink(): void {\n if (!this.canWrite() || !this.canInsertLink()) return; // the Insert button is disabled in this case; a defensive guard only\n this.bodyEdited.set(true);\n const url = this.normalizedLink();\n this.restoreSelection();\n const sel = window.getSelection();\n if (sel && sel.rangeCount > 0 && !sel.isCollapsed) {\n document.execCommand('createLink', false, url);\n // The link opens in a new tab. The links are looked up in the whole block being edited (after createLink on a whole selection the range's common\n // ancestor can be the text INSIDE the new <a>, which would skip it) and found by comparing the attribute (not an attribute selector built from the\n // address: a quote or bracket would throw).\n const range = sel.getRangeAt(0);\n const node = range.commonAncestorContainer;\n const scope = this.editorFor(this.selectedBlockId())?.nativeElement ?? (node instanceof Element ? node : node.parentElement)?.closest('.block-content') ?? null;\n scope?.querySelectorAll('a').forEach(l => { if (l.getAttribute('href') === url) l.setAttribute('target', '_blank'); });\n } else {\n // The new link is built as a DOM node and serialized: the text and the address can never be parsed as markup.\n const a = document.createElement('a');\n a.setAttribute('href', url);\n a.setAttribute('target', '_blank');\n a.textContent = this.linkText().trim() || url;\n document.execCommand('insertHTML', false, a.outerHTML);\n }\n this.syncBlock();\n this.showLinkDialog.set(false);\n this.linkUrl.set('');\n this.linkText.set('');\n }\n\n openImageDialog(): void {\n if (!this.canWrite()) return;\n this.saveSelection();\n this.imageUrl.set('');\n this.imageAlt.set('');\n this.showImageDialog.set(true);\n }\n\n insertImageFromUrl(): void {\n if (!this.canWrite() || !this.canInsertImage()) return; // the Insert button is disabled in this case; a defensive guard only\n this.bodyEdited.set(true);\n this.restoreSelection();\n // Built as a DOM node and serialized: the address and the alt text can never break out of their attributes.\n const img = document.createElement('img');\n img.setAttribute('src', this.imageUrl().trim());\n img.setAttribute('alt', this.imageAlt() || this.labels.t('emailTemplateEditor.imageAltDefault'));\n img.setAttribute('style', 'max-width:100%;border-radius:8px;display:block;margin:8px 0');\n document.execCommand('insertHTML', false, img.outerHTML);\n this.syncBlock();\n this.showImageDialog.set(false);\n this.imageUrl.set('');\n this.imageAlt.set('');\n }\n\n // ── Test send / AI ───────────────────────────────────────────────────────────\n\n openTestSendDialog(): void {\n if (!this.canWrite()) return;\n this.testSendEmail.set('');\n this.showTestSendDialog.set(true);\n }\n\n onTestSend(): void {\n if (!this.canSendTest()) return; // the Send Test button is disabled in these cases; a defensive guard only\n this.testSend.emit(this.testSendEmail().trim());\n }\n\n // ── Video ────────────────────────────────────────────────────────────────────\n\n openVideoTab(): void {\n this.activeRightTab.set('video');\n this.videosRequested.emit();\n }\n\n insertVideo(video: EmailTemplateVideo): void {\n if (!this.canWrite()) return;\n this.videoId.set(video.id);\n this.videoTitle.set(video.title);\n const link = this.videoLink()(video, {\n autoplay: this.videoAutoplay(), caption: this.videoCaption(), ctaType: this.videoCtaType(), ctaUrl: this.videoCtaUrl(),\n ctaLabel: this.videoCtaLabel(), hideReactions: this.videoHideReactions(),\n });\n const caption = this.videoCaption() || (this.videoAutoplay() ? this.labels.t('emailTemplateEditor.videoWillAutoplay') : this.labels.t('emailTemplateEditor.clickToWatchVideo'));\n this.addBlockHtml(buildVideoBlockHtml(video, link, caption, window.location.origin));\n this.activeRightTab.set('blocks');\n }\n\n formatDuration(seconds: number | null | undefined): string { return formatVideoDuration(seconds); }\n categoryLabel(cat: string | null | undefined): string { return formatCategoryLabel(cat); }\n\n // ── Assignments ──────────────────────────────────────────────────────────────\n\n /** Click / Enter / Space on a row: assign this template to that automation, or take it off again. */\n toggleAssignment(item: AssignmentView): void {\n if (!this.canWrite()) return;\n this.assignedKeys.update(keys => keys.includes(item.key) ? keys.filter(k => k !== item.key) : [...keys, item.key]);\n this.assignmentsTouched.set(true);\n }\n\n // ── Palette ──────────────────────────────────────────────────────────────────\n\n isOpen(id: string): boolean {\n const startsOpen = id === 'v:' + (this.variableGroups()[0]?.name ?? '');\n return startsOpen !== this.toggledGroups().has(id);\n }\n\n toggleGroup(id: string): void {\n this.toggledGroups.update(s => {\n const next = new Set(s);\n if (next.has(id)) next.delete(id); else next.add(id);\n return next;\n });\n }\n\n insertBlock(block: EmailTemplateBlock): void {\n if (!this.canWrite()) return;\n this.addBlockHtml(block.html);\n }\n\n insertVariable(variable: EmailTemplateVariable): void {\n if (!this.canWrite()) return;\n this.runEditCommand(() => { document.execCommand('insertText', false, `{{${variable.key}}}`); }); // nothing is inserted when no editor holds the caret\n this.syncBlock();\n }\n\n private blockHtml(key: string): string {\n for (const g of this.blockGroups()) {\n const found = g.blocks.find(b => b.key === key);\n if (found) return found.html;\n }\n return `<p>${this.labels.t('emailTemplateEditor.blockFallback')}</p>`;\n }\n}\n","import { Injectable, inject } from '@angular/core';\nimport { escapeHtml } from '../email-template-editor/email-template-editor.utils';\nimport { PrintService } from '@forgeroute/ui/print';\n\n/** An inspection checklist template, as the print sheet needs it. */\nexport interface PrintableInspectionTemplate {\n name: string;\n /** For example `MOVE_IN` (shown as \"Move In\"). */\n inspectionType: string;\n description?: string | null;\n defaultNotes?: string | null;\n defaultInspectorName?: string | null;\n /** Recurrence in days; absent or 0 = no recurrence line. */\n frequencyDays?: number | null;\n archived?: boolean;\n /** ACTIVE / INACTIVE / ARCHIVED; absent = derived from `archived` (Archived / Active). */\n status?: string;\n items: { itemName: string; required: boolean }[];\n}\n\nexport interface InspectionTemplatePrintOptions {\n /** The name in the footer (\"Generated from <appName> — <date>\"). Empty = the footer says only the date. */\n appName?: string;\n /** Colour of the heading and rule. Default `#1F3D2B`. */\n accentColor?: string;\n /** The date printed in the header and footer (tests and replays). Default: now. */\n now?: Date;\n /** Locale of the dates. Default `en-US`. */\n locale?: string;\n}\n\nconst formatEnumWords = (s: string): string => s.toLowerCase().replace(/_/g, ' ').replace(/\\b\\w/g, c => c.toUpperCase());\n\n/** The status shown on the sheet: the given `status` in sentence case, else Archived / Active from `archived`. */\nexport function inspectionTemplateStatusLabel(tpl: Pick<PrintableInspectionTemplate, 'status' | 'archived'>): string {\n if (tpl.status) return tpl.status.charAt(0).toUpperCase() + tpl.status.slice(1).toLowerCase();\n return tpl.archived ? 'Archived' : 'Active';\n}\n\n/**\n * The printable checklist sheet of an inspection template as a complete HTML document: heading with the date and the item count, a details box\n * (type, status, inspector, recurrence), description and default notes when present, the checklist table (number, item with a \"(Required)\" mark,\n * empty Pass and Fail boxes, a notes cell), four lines to fill in (unit number, inspection date, inspector name, signature) and a footer.\n * Every text is HTML-escaped. Pure: no DOM needed.\n */\nexport function buildInspectionTemplateHtml(tpl: PrintableInspectionTemplate, options: InspectionTemplatePrintOptions = {}): string {\n const accent = options.accentColor ?? '#1F3D2B';\n const today = (options.now ?? new Date()).toLocaleDateString(options.locale ?? 'en-US', { month: 'long', day: 'numeric', year: 'numeric' });\n const type = escapeHtml(formatEnumWords(tpl.inspectionType));\n const count = tpl.items.length;\n const box = '<span style=\"display:inline-block;width:18px;height:18px;border:2px solid #d1d5db;border-radius:4px;\"></span>';\n\n const rows = count\n ? tpl.items.map((item, idx) => `<tr>\n <td style=\"width:36px;text-align:center;font-weight:600;color:#6b7280;padding:10px 8px;\">${idx + 1}</td>\n <td style=\"padding:10px 8px;font-weight:500;\">${escapeHtml(item.itemName)}${item.required ? ' <span style=\"color:#d97706;font-size:0.75rem;font-weight:600;\">(Required)</span>' : ''}</td>\n <td style=\"width:60px;text-align:center;padding:10px 8px;\">${box}</td>\n <td style=\"width:60px;text-align:center;padding:10px 8px;\">${box}</td>\n <td style=\"width:140px;padding:10px 8px;border-bottom:1px dotted #e5e7eb;\"></td>\n </tr>`).join('')\n : '<tr><td colspan=\"5\" style=\"padding:16px;color:#9ca3af;font-style:italic;\">No checklist items defined.</td></tr>';\n\n const fill = (label: string) => `<div class=\"fill-field\"><p class=\"fill-label\">${label}</p><p style=\"min-height:20px;\"></p></div>`;\n const footer = options.appName ? `Generated from ${escapeHtml(options.appName)} — ${today}` : `Generated ${today}`;\n\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <title>${escapeHtml(tpl.name)} — Inspection Checklist</title>\n <style>\n * { margin: 0; padding: 0; box-sizing: border-box; }\n body { font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif; color: #1e293b; padding: 32px; max-width: 800px; margin: 0 auto; }\n .header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid ${accent}; }\n .header h1 { font-size: 1.5rem; font-weight: 700; color: ${accent}; }\n .header-meta { text-align: right; font-size: 0.8125rem; color: #6b7280; }\n .details { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; margin-bottom: 24px; padding: 16px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; }\n .detail-row { display: flex; gap: 8px; font-size: 0.875rem; }\n .detail-label { font-weight: 600; color: #64748b; min-width: 100px; }\n .detail-value { color: #1e293b; }\n .section-title { font-size: 0.875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: ${accent}; margin: 24px 0 12px; }\n .desc { font-size: 0.875rem; color: #475569; line-height: 1.6; margin-bottom: 16px; white-space: pre-wrap; }\n table { width: 100%; border-collapse: collapse; }\n thead th { text-align: left; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; padding: 8px; border-bottom: 2px solid #e2e8f0; }\n tbody td { border-bottom: 1px solid #f1f5f9; }\n .fill-fields { margin-top: 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }\n .fill-field { border-bottom: 1px solid #d1d5db; padding: 8px 0 4px; }\n .fill-label { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #64748b; }\n @media print {\n body { padding: 16px; }\n .no-print { display: none !important; }\n @page { margin: 0.5in; }\n }\n </style>\n</head>\n<body>\n <div class=\"header\">\n <div>\n <h1>${escapeHtml(tpl.name)}</h1>\n <p style=\"font-size:0.875rem;color:#64748b;margin-top:4px;\">${type} Inspection Template</p>\n </div>\n <div class=\"header-meta\">\n <p>Printed: ${today}</p>\n <p>${count} checklist item${count !== 1 ? 's' : ''}</p>\n </div>\n </div>\n\n <div class=\"details\">\n <div class=\"detail-row\"><span class=\"detail-label\">Type</span><span class=\"detail-value\">${type}</span></div>\n <div class=\"detail-row\"><span class=\"detail-label\">Status</span><span class=\"detail-value\">${escapeHtml(inspectionTemplateStatusLabel(tpl))}</span></div>\n ${tpl.defaultInspectorName ? `<div class=\"detail-row\"><span class=\"detail-label\">Inspector</span><span class=\"detail-value\">${escapeHtml(tpl.defaultInspectorName)}</span></div>` : ''}\n ${tpl.frequencyDays ? `<div class=\"detail-row\"><span class=\"detail-label\">Recurrence</span><span class=\"detail-value\">Every ${tpl.frequencyDays} days</span></div>` : ''}\n </div>\n\n ${tpl.description ? `<p class=\"section-title\">Description</p><p class=\"desc\">${escapeHtml(tpl.description)}</p>` : ''}\n ${tpl.defaultNotes ? `<p class=\"section-title\">Default Notes</p><p class=\"desc\">${escapeHtml(tpl.defaultNotes)}</p>` : ''}\n\n <p class=\"section-title\">Checklist</p>\n <table>\n <thead><tr><th style=\"width:36px;\">#</th><th>Item</th><th style=\"width:60px;text-align:center;\">Pass</th><th style=\"width:60px;text-align:center;\">Fail</th><th style=\"width:140px;\">Notes</th></tr></thead>\n <tbody>${rows}</tbody>\n </table>\n\n <div class=\"fill-fields\">\n ${fill('Unit Number')}\n ${fill('Inspection Date')}\n ${fill('Inspector Name')}\n ${fill('Inspector Signature')}\n </div>\n\n <p style=\"margin-top:32px;font-size:0.75rem;color:#9ca3af;text-align:center;\">${footer}</p>\n</body>\n</html>`;\n}\n\n/**\n * Prints and downloads inspection templates, the same in every app and every screen that offers it:\n *\n * const print = inject(InspectionTemplatePrintService);\n * print.configure({ appName: 'Parkstead' }); // once, optional\n * print.download(template); // hidden frame: the print dialog offers \"Save as PDF\"\n * if (!print.print(template)) toast.error('The print window was blocked. Allow pop-ups for this site.');\n */\n@Injectable({ providedIn: 'root' })\nexport class InspectionTemplatePrintService {\n private readonly printer = inject(PrintService);\n private options: InspectionTemplatePrintOptions = {};\n\n /** Sets the options of every sheet printed afterwards (app name in the footer, accent colour, locale). */\n configure(options: InspectionTemplatePrintOptions): void { this.options = { ...options }; }\n\n /** The sheet as HTML. */\n html(tpl: PrintableInspectionTemplate): string { return buildInspectionTemplateHtml(tpl, this.options); }\n\n /** Opens an empty print window. Call it straight from the click handler (Safari only allows a pop-up inside the user's gesture), fill it later with [print]. */\n openWindow(): Window | null { return this.printer.openWindow(); }\n\n /** Prints in a window (a new one, or `existing`). Returns false when the browser blocked the pop-up. */\n print(tpl: PrintableInspectionTemplate, existing?: Window | null): boolean { return this.printer.print(this.html(tpl), existing); }\n\n /** Prints through a hidden frame (no pop-up): the print dialog lets the user choose \"Save as PDF\". */\n download(tpl: PrintableInspectionTemplate): void { this.printer.printInFrame(this.html(tpl)); }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwBA,MAAM,+BAAe,IAAI,IAAI;CAC3B;CAAK;CAAO;CAAQ;CACpB;CAAK;CAAU;CAAK;CAAM;CAAK;CAAK;CAAU;CAAO;CAAO;CAC5D;CAAM;CAAM;CAAM;CAClB;CAAM;CAAM;CAAM;CAClB;CAAK;AACN,CAAA;AAGD,MAAM,oCAAoB,IAAI,IAAI;CAChC;CAAU;CAAS;CAAY;CAAY;CAAU;CAAU;CAAU;CAAU;CACnF;CAAY;CAAQ;CAAS;CAAQ;CAAQ;CAAO;CAAQ;CAAU;CAAS;CAC/E;CAAS;CAAU;CAAQ;CAAO;CAAU;CAAS;AACtD,CAAA;AAGD,MAAM,+BAAe,IAAI,IAAI;CAC3B;CAAW;CAAW;CAAU;CAAU;CAAQ;CAAS;CAAO;CAAO;CAAM;CAC/E;CAAW;CAAU;CAAM;CAAM;CAAM;CAAW;CAAY;AAC/D,CAAA;AAED,MAAM,QAAQ;AACd,MAAM,SAAS;AAGf,MAAM,cAAwC;CAC5C,cAAc,CAAC,+BAA+B;CAC9C,aAAa,CAAC,QAAQ,2DAA2D;CACjF,eAAe,CAAC,eAAe;CAC/B,eAAe,CAAC,yBAAyB;CACzC,cAAc,CAAC,mBAAmB;CAClC,mBAAmB,CA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CAG1F,KAAK,KAAgC;EAAY,OAAO,4BAA4B,KAAK,KAAK,OAAO;CAAG;CAGxG,aAAU;EAAoB,OAAO,KAAK,QAAQ,WAAU;CAAI;CAGhE,MAAM,KAAkC,UAAwB;EAAa,OAAO,KAAK,QAAQ,MAAM,KAAK,KAAK,GAAG,GAAG,QAAQ;CAAG;CAGlI,SAAS,KAAgC;EAAU,KAAK,QAAQ,aAAa,KAAK,KAAK,GAAG,CAAC;CAAG;CAjBnF;EAAA,KAAA,OAAA,GAAA,mBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAA8B,MAAA,CAAA;GAAA,QAAA,GAAA,gBAAA;EAAA,CAAA;CAAA;CAA9B;EAAA,KAAA,QAAA,GAAA,sBAAA;GAAA,YAAA;GAAA,SAAA;GAAA,UAAA;GAAA,MAAA;GAA8B,YADjB;EAAM,CAAA;CAAA;;AACnB,GAAA,yBAAA;CAAA,YAAA;CAAA,SAAA;CAAA,UAAA;CAAA,MAAA;CAA8B,YAAA,CAAA;EAD1C,MAAA;EAAW,MAAA,CAAA,EAAE,YAAY,OAAM,CAAE"}
|
|
1
|
+
{"version":3,"file":"forgeroute-ui-editor.mjs","names":[],"sources":["../../../projects/forgeroute-ui/editor/src/lib/rich-text-editor/rich-text-sanitizer.ts","../../../projects/forgeroute-ui/editor/src/lib/rich-text-editor/rich-text-editor.component.ts","../../../projects/forgeroute-ui/editor/src/lib/email-template-editor/email-template-editor.utils.ts","../../../projects/forgeroute-ui/editor/src/lib/email-template-editor/email-template-editor.component.ts","../../../projects/forgeroute-ui/editor/src/lib/inspection-template-print/inspection-template-print.ts"],"sourcesContent":["/**\n * Allow-list HTML sanitiser used by `ui-rich-text-editor`.\n *\n * The allow-list matches the markup the editor itself produces (and what a server-side allow-list\n * sanitiser for editor output typically keeps): bold/italic/underline/strike, paragraphs and line\n * breaks, headings, lists, block quotes (indent), links, and the inline styles used for alignment,\n * size, font, colour and highlight. Everything else is removed: scripts and styles with their\n * contents, event-handler attributes, `javascript:` and other unsafe URL schemes, and any style\n * property or value outside the lists below.\n *\n * Runs on an inert document (DOMParser), so nothing in the input is executed or fetched.\n */\n\nexport type RichTextSanitizeMode = 'content' | 'paste';\n\nexport interface RichTextSanitizeOptions {\n /** `content` keeps allow-listed inline styles; `paste` flattens them to plain semantic tags. */\n mode?: RichTextSanitizeMode;\n /** Tag names (upper-case) that must not appear in the output — they are replaced per `replace`/unwrapped. */\n blockedTags?: ReadonlySet<string>;\n /** Replacement tag (upper-case) for blocked tags; a blocked tag without an entry is unwrapped. */\n replace?: Readonly<Record<string, string>>;\n}\n\nconst ALLOWED_TAGS = new Set([\n 'P', 'DIV', 'SPAN', 'BR',\n 'B', 'STRONG', 'I', 'EM', 'U', 'S', 'STRIKE', 'DEL', 'SUB', 'SUP',\n 'UL', 'OL', 'LI', 'BLOCKQUOTE',\n 'H1', 'H2', 'H3', 'H4',\n 'A', 'FONT',\n]);\n\n/** Dropped together with their contents. */\nconst DROP_WITH_CONTENT = new Set([\n 'SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'OPTION', 'SELECT', 'IFRAME', 'OBJECT', 'EMBED',\n 'TEMPLATE', 'HEAD', 'TITLE', 'META', 'LINK', 'SVG', 'MATH', 'CANVAS', 'AUDIO', 'VIDEO',\n 'INPUT', 'BUTTON', 'FORM', 'IMG', 'APPLET', 'FRAME', 'FRAMESET',\n]);\n\n/** Unknown block-level tags become a `<div>` so their line breaks survive. */\nconst BLOCK_TO_DIV = new Set([\n 'SECTION', 'ARTICLE', 'HEADER', 'FOOTER', 'MAIN', 'ASIDE', 'NAV', 'PRE', 'H5', 'H6',\n 'CAPTION', 'FIGURE', 'DL', 'DT', 'DD', 'ADDRESS', 'FIELDSET', 'CENTER',\n]);\n\nconst COLOR = /^(#[0-9a-f]{3,8}|rgba?\\(\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*,\\s*\\d{1,3}\\s*(,\\s*(0|1|0?\\.\\d+)\\s*)?\\)|[a-z]{3,20})$/i;\nconst LENGTH = /^-?\\d+(\\.\\d+)?(px|pt|em|rem|%)?$/;\nconst MARGIN = /^(-?\\d+(\\.\\d+)?(px|pt|em|rem|%)?\\s*){1,4}$/;\n\nconst STYLE_RULES: Record<string, RegExp[]> = {\n 'text-align': [/^(left|right|center|justify)$/],\n 'font-size': [LENGTH, /^(x-small|small|medium|large|x-large|xx-large|xxx-large)$/],\n 'font-family': [/^[\\w\\s,'\"-]+$/],\n 'font-weight': [/^(normal|bold|[1-9]00)$/],\n 'font-style': [/^(normal|italic)$/],\n 'text-decoration': [/^(none|underline|line-through)( (none|underline|line-through))*$/],\n color: [COLOR],\n 'background-color': [COLOR],\n margin: [MARGIN],\n 'margin-left': [LENGTH],\n 'padding-left': [LENGTH],\n};\n\nconst ALLOWED_SCHEMES = /^(https?|mailto|tel):/i;\n\nfunction safeHref(raw: string): string | null {\n const cleaned = raw.replace(/[\\u0000- \\u007f-\\u009f]/g, '');\n if (!cleaned) return null;\n if (ALLOWED_SCHEMES.test(cleaned)) return raw.trim();\n if (/^[a-z][a-z0-9+.-]*:/i.test(cleaned) || /^[\\/\\\\]{2}/.test(cleaned)) return null;\n return raw.trim();\n}\n\n/** Parses an inline style attribute into `[property, value]` pairs (lower-cased property). */\nfunction parseStyle(style: string): [string, string][] {\n return style\n .split(';')\n .map(decl => {\n const i = decl.indexOf(':');\n return i < 0 ? null : ([decl.slice(0, i).trim().toLowerCase(), decl.slice(i + 1).trim()] as [string, string]);\n })\n .filter((d): d is [string, string] => !!d && !!d[0] && !!d[1]);\n}\n\nfunction filterStyle(style: string): string {\n return parseStyle(style)\n .filter(([prop, value]) => (STYLE_RULES[prop] ?? []).some(rule => rule.test(value)))\n .map(([prop, value]) => `${prop}: ${value}`)\n .join('; ');\n}\n\ninterface Ctx {\n doc: Document;\n mode: RichTextSanitizeMode;\n blocked: ReadonlySet<string>;\n replace: Readonly<Record<string, string>>;\n}\n\n/** Output tag for an input element, or `null` to unwrap it (keep only its children). */\nfunction resolveTag(el: Element, ctx: Ctx): string | null {\n let tag = el.tagName.toUpperCase();\n if (BLOCK_TO_DIV.has(tag)) tag = 'DIV';\n if (!ALLOWED_TAGS.has(tag)) return null;\n if (ctx.mode === 'paste' && (tag === 'SPAN' || tag === 'FONT')) return null;\n if (ctx.blocked.has(tag)) return ctx.replace[tag] ?? null;\n return tag;\n}\n\n/** Emphasis tags implied by inline styles — only used when pasting, where styles are flattened. */\nfunction impliedTags(el: Element, ctx: Ctx): string[] {\n const out: string[] = [];\n const decls = new Map(parseStyle(el.getAttribute('style') ?? ''));\n const weight = decls.get('font-weight');\n if (weight && (weight === 'bold' || (/^\\d+$/.test(weight) && Number(weight) >= 600))) out.push('B');\n if (decls.get('font-style') === 'italic') out.push('I');\n const deco = decls.get('text-decoration') ?? '';\n if (/\\bunderline\\b/.test(deco)) out.push('U');\n if (/\\bline-through\\b/.test(deco)) out.push('S');\n return out.filter(t => !ctx.blocked.has(t));\n}\n\nfunction copyAttributes(src: Element, dest: Element, tag: string, ctx: Ctx): void {\n if (ctx.mode === 'paste') {\n if (tag === 'A') setLinkAttributes(src, dest);\n return;\n }\n const style = filterStyle(src.getAttribute('style') ?? '');\n if (style) dest.setAttribute('style', style);\n const align = src.getAttribute('align')?.toLowerCase();\n if (align && /^(left|right|center|justify)$/.test(align)) dest.setAttribute('align', align);\n if (tag === 'A') setLinkAttributes(src, dest);\n if (tag === 'FONT') {\n const face = src.getAttribute('face');\n if (face && /^[\\w\\s,'\"-]+$/.test(face)) dest.setAttribute('face', face);\n const size = src.getAttribute('size');\n if (size && /^[+-]?\\d$/.test(size)) dest.setAttribute('size', size);\n const color = src.getAttribute('color');\n if (color && COLOR.test(color)) dest.setAttribute('color', color);\n }\n}\n\nfunction setLinkAttributes(src: Element, dest: Element): void {\n const href = safeHref(src.getAttribute('href') ?? '');\n if (href) {\n dest.setAttribute('href', href);\n dest.setAttribute('target', '_blank');\n dest.setAttribute('rel', 'noopener noreferrer');\n }\n}\n\nfunction walkChildren(src: Node, dest: Node, ctx: Ctx): void {\n for (const child of Array.from(src.childNodes)) {\n if (child.nodeType === Node.TEXT_NODE) {\n dest.appendChild(ctx.doc.createTextNode(child.nodeValue ?? ''));\n } else if (child.nodeType === Node.ELEMENT_NODE) {\n walkElement(child as Element, dest, ctx);\n }\n }\n}\n\n/**\n * Table handling: every `<tr>` becomes its own `<div>` and the cells of a row are separated by one normal space\n * (tabs would collapse in contenteditable), so a pasted sheet reads as lines. Cells are never emitted as elements and\n * `<table>`/`<thead>`/`<tbody>`/`<tfoot>` are unwrapped; `<caption>` becomes a block of its own. Empty or\n * whitespace-only cells add no separator (a separator only sits between cells that have content), so the output has no\n * leading, trailing or doubled spaces and sanitising it again changes nothing. A cell's own edge whitespace is trimmed.\n * Inline emphasis on a cell (paste mode: bold/italic styles) is kept; `<th>` is not bolded on its own.\n */\nfunction walkRow(el: Element, dest: Node, ctx: Ctx): void {\n const rowTag = ctx.blocked.has('DIV') ? (ctx.replace['DIV'] ?? null) : 'DIV';\n const row: Node = rowTag ? ctx.doc.createElement(rowTag) : ctx.doc.createDocumentFragment();\n let first = true;\n for (const cell of Array.from(el.children)) {\n const t = cell.tagName.toUpperCase();\n if (t !== 'TD' && t !== 'TH') { walkElement(cell, row, ctx); continue; }\n const holder = ctx.doc.createElement('div');\n let target: Node = holder;\n if (ctx.mode === 'paste') {\n for (const wrap of impliedTags(cell, ctx)) {\n const w = ctx.doc.createElement(wrap);\n target.appendChild(w);\n target = w;\n }\n }\n walkChildren(cell, target, ctx);\n if (holder.firstChild?.nodeType === Node.TEXT_NODE) holder.firstChild.nodeValue = (holder.firstChild.nodeValue ?? '').trimStart();\n if (holder.lastChild?.nodeType === Node.TEXT_NODE) holder.lastChild.nodeValue = (holder.lastChild.nodeValue ?? '').trimEnd();\n if (!(holder.textContent ?? '').trim()) continue;\n if (!first) row.appendChild(ctx.doc.createTextNode(' '));\n first = false;\n while (holder.firstChild) row.appendChild(holder.firstChild);\n }\n if (!row.firstChild) return;\n // With no block element available for rows, a <br> still keeps the rows on separate lines.\n if (!rowTag) row.appendChild(ctx.doc.createElement('br'));\n dest.appendChild(row);\n}\n\nfunction walkElement(el: Element, dest: Node, ctx: Ctx): void {\n const original = el.tagName.toUpperCase();\n if (DROP_WITH_CONTENT.has(original)) return;\n if (original === 'TR') { walkRow(el, dest, ctx); return; }\n\n let tag = resolveTag(el, ctx);\n // A list item whose own list type is blocked has no list left to live in.\n if (tag === 'LI' && el.parentElement) {\n const parent = el.parentElement.tagName.toUpperCase();\n if ((parent === 'UL' || parent === 'OL') && ctx.blocked.has(parent)) tag = 'DIV';\n }\n\n let target: Node = dest;\n if (ctx.mode === 'paste') {\n for (const wrap of impliedTags(el, ctx)) {\n const w = ctx.doc.createElement(wrap);\n target.appendChild(w);\n target = w;\n }\n }\n if (tag) {\n const out = ctx.doc.createElement(tag);\n copyAttributes(el, out, tag, ctx);\n target.appendChild(out);\n target = out;\n }\n if (tag === 'BR') return;\n walkChildren(el, target, ctx);\n}\n\n/** Returns `html` reduced to the allow-list. Empty input returns an empty string. */\nexport function sanitizeRichTextHtml(html: string | null | undefined, options: RichTextSanitizeOptions = {}): string {\n if (!html) return '';\n const parsed = new DOMParser().parseFromString(`<body>${html}</body>`, 'text/html');\n const ctx: Ctx = {\n doc: parsed,\n mode: options.mode ?? 'content',\n blocked: options.blockedTags ?? new Set<string>(),\n replace: options.replace ?? {},\n };\n const out = parsed.createElement('body');\n walkChildren(parsed.body, out, ctx);\n return out.innerHTML;\n}\n\n/**\n * A web address typed into a link box, made safe to link to: `example.com` becomes `https://example.com`; `http`, `https`, `mailto` and `tel`\n * addresses are kept. Anything else (`javascript:`, `data:`, an address with spaces, nothing) returns null.\n */\nexport function normalizeLinkUrl(raw: string | null | undefined): string | null {\n const text = (raw ?? '').trim();\n if (!text || /\\s/.test(text)) return null;\n if (/^(https?:\\/\\/|mailto:|tel:)\\S+$/i.test(text)) return text;\n if (/^[a-z][a-z0-9+.-]*:/i.test(text) || /^[\\/\\\\]{2}/.test(text)) return null;\n return /^[^\\s/@]+\\.[^\\s/@]+/.test(text) ? `https://${text}` : null;\n}\n\n/** Escapes plain text for HTML, turning line breaks into `<br>`. */\nexport function plainTextToHtml(text: string): string {\n return text\n .replace(/\\r\\n?/g, '\\n')\n .replace(/&/g, '&')\n .replace(/</g, '<')\n .replace(/>/g, '>')\n .replace(/\\n/g, '<br>');\n}\n","import {\n Component, ChangeDetectionStrategy, ElementRef, computed, forwardRef, input, signal, viewChild, afterNextRender, inject, } from '@angular/core';\nimport { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';\nimport { normalizeLinkUrl, plainTextToHtml, sanitizeRichTextHtml } from './rich-text-sanitizer';\nimport { UiLabelsService, UiLabelKey } from '@forgeroute/ui/core';\nimport { createFieldReveal } from '@forgeroute/ui/core';\n\n/**\n * Every toolbar control of `ui-rich-text-editor`. All are shown by default; pass any of them in\n * `hide` to remove just that control (a whole group, and its divider, disappears once all of its\n * controls are hidden).\n *\n * Groups, left to right: `bold italic underline strikethrough` | `heading fontSize fontFamily` |\n * `textColor highlight` | `align` | `bulletList numberedList indent outdent` | `clearFormat`.\n * `align` is the three alignment buttons (left, center, right) as one option.\n */\nexport type RichTextOption =\n | 'bold' | 'italic' | 'underline' | 'strikethrough' | 'link'\n | 'heading' | 'fontSize' | 'fontFamily'\n | 'textColor' | 'highlight'\n | 'align'\n | 'bulletList' | 'numberedList' | 'indent' | 'outdent'\n | 'clearFormat';\n\n/** All option keys, in toolbar order. */\nexport const RICH_TEXT_OPTIONS: readonly RichTextOption[] = [\n 'bold', 'italic', 'underline', 'strikethrough', 'link',\n 'heading', 'fontSize', 'fontFamily',\n 'textColor', 'highlight',\n 'align',\n 'bulletList', 'numberedList', 'indent', 'outdent',\n 'clearFormat',\n];\n\ntype GroupId = 'inline' | 'text' | 'color' | 'align' | 'blocks' | 'clear';\ntype MenuId = 'heading' | 'size' | 'font' | 'link';\n\nconst GROUPS: { id: GroupId; options: RichTextOption[] }[] = [\n { id: 'inline', options: ['bold', 'italic', 'underline', 'strikethrough', 'link'] },\n { id: 'text', options: ['heading', 'fontSize', 'fontFamily'] },\n { id: 'color', options: ['textColor', 'highlight'] },\n { id: 'align', options: ['align'] },\n { id: 'blocks', options: ['bulletList', 'numberedList', 'indent', 'outdent'] },\n { id: 'clear', options: ['clearFormat'] },\n];\n\n/** Tags (upper-case) removed from pasted content when the matching option is hidden. */\nconst OPTION_TAGS: Partial<Record<RichTextOption, string[]>> = {\n bold: ['B', 'STRONG'],\n italic: ['I', 'EM'],\n underline: ['U'],\n strikethrough: ['S', 'STRIKE', 'DEL'],\n link: ['A'],\n heading: ['H1', 'H2', 'H3', 'H4'],\n bulletList: ['UL'],\n numberedList: ['OL'],\n indent: ['BLOCKQUOTE'],\n};\n/** Hidden block tags become a plain line instead of vanishing (keeps the text on its own line). */\nconst BLOCK_REPLACEMENT: Record<string, string> = { H1: 'DIV', H2: 'DIV', H3: 'DIV', H4: 'DIV', BLOCKQUOTE: 'DIV' };\n\nconst HEADINGS = [\n { tag: 'p', label: 'Normal', text: 'Normal', cls: '' },\n { tag: 'h1', label: 'H1', text: 'H1 — Heading 1', cls: 'di-h1' },\n { tag: 'h2', label: 'H2', text: 'H2 — Heading 2', cls: 'di-h2' },\n { tag: 'h3', label: 'H3', text: 'H3 — Heading 3', cls: 'di-h3' },\n];\n\nconst SIZES = [\n { value: '1', label: 'Small', px: 11 },\n { value: '3', label: 'Normal', px: 13 },\n { value: '4', label: 'Medium', px: 15 },\n { value: '5', label: 'Large', px: 18 },\n { value: '6', label: 'X-Large', px: 22 },\n { value: '7', label: 'Huge', px: 26 },\n];\n\nconst FONT_GROUPS = [\n { label: 'Default', fonts: [{ value: 'inherit', label: 'Default', preview: 'inherit' }] },\n { label: 'Serif', fonts: [\n { value: 'Lora, Georgia, serif', label: 'Lora', preview: 'Georgia, serif' },\n { value: 'Cormorant Garamond, serif', label: 'Cormorant Garamond', preview: 'Georgia, serif' },\n { value: 'Georgia, serif', label: 'Georgia', preview: 'Georgia, serif' },\n { value: 'Palatino Linotype, Palatino, serif', label: 'Palatino', preview: 'Palatino, serif' },\n { value: 'Times New Roman, Times, serif', label: 'Times New Roman', preview: \"'Times New Roman', serif\" },\n { value: 'Garamond, serif', label: 'Garamond', preview: 'Garamond, serif' },\n { value: 'Book Antiqua, Palatino, serif', label: 'Book Antiqua', preview: 'Palatino, serif' },\n ] },\n { label: 'Sans-Serif', fonts: [\n { value: 'Lato, sans-serif', label: 'Lato', preview: 'Arial, sans-serif' },\n { value: 'Inter, sans-serif', label: 'Inter', preview: 'Arial, sans-serif' },\n { value: 'Arial, Helvetica, sans-serif', label: 'Arial', preview: 'Arial, sans-serif' },\n { value: 'Helvetica Neue, Helvetica, sans-serif', label: 'Helvetica', preview: 'Helvetica, Arial, sans-serif' },\n { value: 'Open Sans, sans-serif', label: 'Open Sans', preview: 'Arial, sans-serif' },\n { value: 'Montserrat, sans-serif', label: 'Montserrat', preview: 'Arial, sans-serif' },\n { value: 'Raleway, sans-serif', label: 'Raleway', preview: 'Arial, sans-serif' },\n { value: 'Nunito, sans-serif', label: 'Nunito', preview: 'Arial, sans-serif' },\n { value: 'Poppins, sans-serif', label: 'Poppins', preview: 'Arial, sans-serif' },\n { value: 'Verdana, Geneva, sans-serif', label: 'Verdana', preview: 'Verdana, sans-serif' },\n { value: 'Tahoma, Geneva, sans-serif', label: 'Tahoma', preview: 'Tahoma, sans-serif' },\n { value: 'Trebuchet MS, Helvetica, sans-serif', label: 'Trebuchet MS', preview: \"'Trebuchet MS', sans-serif\" },\n ] },\n { label: 'Monospace', fonts: [\n { value: 'Courier New, Courier, monospace', label: 'Courier New', preview: \"'Courier New', monospace\" },\n { value: 'Lucida Console, Monaco, monospace', label: 'Lucida Console', preview: 'Monaco, monospace' },\n ] },\n { label: 'Display', fonts: [\n { value: 'Impact, Charcoal, sans-serif', label: 'Impact', preview: 'Impact, sans-serif' },\n { value: 'Comic Sans MS, cursive', label: 'Comic Sans', preview: \"'Comic Sans MS', cursive\" },\n ] },\n];\n\n/** Commands whose on/off state is mirrored with `aria-pressed`. */\nconst STATE_COMMANDS = [\n 'bold', 'italic', 'underline', 'strikeThrough',\n 'insertUnorderedList', 'insertOrderedList',\n 'justifyLeft', 'justifyCenter', 'justifyRight',\n] as const;\n\nlet nextId = 0;\n\n@Component({\n selector: 'ui-rich-text-editor',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n providers: [{\n provide: NG_VALUE_ACCESSOR,\n useExisting: forwardRef(() => RichTextEditorComponent),\n multi: true,\n }],\n host: {\n '(document:click)': 'onDocumentClick()',\n '(document:selectionchange)': 'onSelectionChange()',\n },\n template: `\n <div class=\"rte-field\" [class.rte-error]=\"_activeError()\" [class.rte-disabled]=\"disabled()\">\n @if (label()) {\n <label class=\"rte-label\" [id]=\"_labelId\" (click)=\"focus()\">\n {{ label() }}\n @if (required()) { <span class=\"rte-required\" aria-hidden=\"true\">*</span> }\n @if (hint()) { <span class=\"rte-hint-inline\">({{ hint() }})</span> }\n </label>\n }\n\n <div class=\"rte-box\">\n @if (toolbarVisible()) {\n <div class=\"rte-toolbar\" role=\"toolbar\" [attr.aria-label]=\"labels.t('richTextEditor.textFormatting')\" [attr.aria-controls]=\"_editorId\"\n (mousedown)=\"onToolbarMouseDown($event)\">\n @if (show('bold') || show('italic') || show('underline') || show('strikethrough') || show('link')) {\n @if (show('bold')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"bold\" [class.active]=\"active()['bold']\"\n [attr.aria-pressed]=\"active()['bold']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.bold')\" [attr.title]=\"labels.t('richTextEditor.boldCtrlB')\" (click)=\"exec('bold')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"3\"><path d=\"M6 4h8a4 4 0 014 4 4 4 0 01-4 4H6z\"/><path d=\"M6 12h9a4 4 0 014 4 4 4 0 01-4 4H6z\"/></svg>\n </button>\n }\n @if (show('italic')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"italic\" [class.active]=\"active()['italic']\"\n [attr.aria-pressed]=\"active()['italic']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.italic')\" [attr.title]=\"labels.t('richTextEditor.italicCtrlI')\" (click)=\"exec('italic')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"19\" y1=\"4\" x2=\"10\" y2=\"4\"/><line x1=\"14\" y1=\"20\" x2=\"5\" y2=\"20\"/><line x1=\"15\" y1=\"4\" x2=\"9\" y2=\"20\"/></svg>\n </button>\n }\n @if (show('underline')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"underline\" [class.active]=\"active()['underline']\"\n [attr.aria-pressed]=\"active()['underline']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.underline')\" [attr.title]=\"labels.t('richTextEditor.underlineCtrlU')\" (click)=\"exec('underline')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M6 3v7a6 6 0 006 6 6 6 0 006-6V3\"/><line x1=\"4\" y1=\"21\" x2=\"20\" y2=\"21\"/></svg>\n </button>\n }\n @if (show('strikethrough')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"strikethrough\" [class.active]=\"active()['strikeThrough']\"\n [attr.aria-pressed]=\"active()['strikeThrough']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.strikethrough')\" [attr.title]=\"labels.t('richTextEditor.strikethrough')\" (click)=\"exec('strikeThrough')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"4\" y1=\"12\" x2=\"20\" y2=\"12\"/><path d=\"M6 4h8a4 4 0 010 8H6\"/><path d=\"M10 12v8\"/></svg>\n </button>\n }\n @if (show('link')) {\n <span class=\"rte-menu-wrap\" (click)=\"$event.stopPropagation()\">\n <button type=\"button\" class=\"rte-btn rte-menu-btn\" data-option=\"link\" [class.active]=\"openMenu() === 'link'\"\n [disabled]=\"inert()\" [attr.aria-label]=\"labels.t('common.link')\" [attr.title]=\"labels.t('common.link')\"\n aria-haspopup=\"dialog\" [attr.aria-expanded]=\"openMenu() === 'link'\" (click)=\"toggleLink()\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\"><path d=\"M10 13a5 5 0 007.54.54l3-3a5 5 0 00-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 00-7.54-.54l-3 3a5 5 0 007.07 7.07l1.71-1.71\"/></svg>\n </button>\n @if (openMenu() === 'link') {\n <div class=\"rte-dropdown rte-link-panel\" role=\"dialog\" [attr.aria-label]=\"labels.t('common.link')\" (keydown.escape)=\"closeLink()\">\n <label class=\"rte-link-label\" [for]=\"_linkId\">{{ labels.t('richTextEditor.webAddress') }}</label>\n <input class=\"rte-link-input\" type=\"url\" inputmode=\"url\" autocomplete=\"off\" spellcheck=\"false\" placeholder=\"example.com\"\n [id]=\"_linkId\" [value]=\"linkUrl()\" [attr.aria-invalid]=\"linkError() ? 'true' : null\"\n [attr.aria-describedby]=\"linkError() ? _linkId + '-error' : null\"\n (input)=\"linkUrl.set($any($event.target).value); linkError.set('')\" (keydown.enter)=\"$event.preventDefault(); applyLink()\" />\n @if (linkError()) { <p class=\"rte-link-error\" role=\"alert\" [id]=\"_linkId + '-error'\">{{ linkError() }}</p> }\n <div class=\"rte-link-actions\">\n <button type=\"button\" class=\"rte-link-btn rte-link-apply\" data-testid=\"rte-link-apply\" (click)=\"applyLink()\">{{ labels.t('common.apply') }}</button>\n @if (hasLink()) { <button type=\"button\" class=\"rte-link-btn\" data-testid=\"rte-link-remove\" (click)=\"removeLink()\">{{ labels.t('richTextEditor.removeLink') }}</button> }\n </div>\n </div>\n }\n </span>\n }\n }\n\n @if (divider()['text']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('heading')) {\n <span class=\"rte-menu-wrap\" (click)=\"$event.stopPropagation()\">\n <button type=\"button\" class=\"rte-btn rte-menu-btn\" data-option=\"heading\" [class.active]=\"openMenu() === 'heading'\"\n [disabled]=\"inert()\" [attr.aria-label]=\"labels.t('richTextEditor.headingStyle')\" [attr.title]=\"labels.t('richTextEditor.headingStyle2')\"\n aria-haspopup=\"menu\" [attr.aria-expanded]=\"openMenu() === 'heading'\" (click)=\"toggleMenu('heading')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M4 6h16M4 12h16M4 18h10\"/></svg>\n <svg class=\"rte-chevron\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\"><polyline points=\"6 9 12 15 18 9\"/></svg>\n </button>\n @if (openMenu() === 'heading') {\n <div class=\"rte-dropdown\" role=\"menu\" [attr.aria-label]=\"labels.t('richTextEditor.headingStyle')\" style=\"min-width:130px\">\n @for (h of headings; track h.tag) {\n <button type=\"button\" role=\"menuitemradio\" class=\"rte-item\" [class]=\"h.cls\"\n [class.selected]=\"activeHeading() === h.label\" [attr.aria-checked]=\"activeHeading() === h.label\"\n (click)=\"selectHeading(h.tag, h.label)\">{{ headingText(h.tag) }}</button>\n }\n </div>\n }\n </span>\n }\n @if (show('fontSize')) {\n <span class=\"rte-menu-wrap\" (click)=\"$event.stopPropagation()\">\n <button type=\"button\" class=\"rte-btn rte-menu-btn\" data-option=\"fontSize\" [class.active]=\"openMenu() === 'size'\"\n [disabled]=\"inert()\" [attr.aria-label]=\"labels.t('richTextEditor.fontSize')\" [attr.title]=\"labels.t('richTextEditor.fontSize2')\"\n aria-haspopup=\"menu\" [attr.aria-expanded]=\"openMenu() === 'size'\" (click)=\"toggleMenu('size')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><text x=\"2\" y=\"17\" font-size=\"14\" fill=\"currentColor\" stroke=\"none\" font-weight=\"bold\">T</text><text x=\"13\" y=\"20\" font-size=\"9\" fill=\"currentColor\" stroke=\"none\">T</text></svg>\n <svg class=\"rte-chevron\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\"><polyline points=\"6 9 12 15 18 9\"/></svg>\n </button>\n @if (openMenu() === 'size') {\n <div class=\"rte-dropdown\" role=\"menu\" [attr.aria-label]=\"labels.t('richTextEditor.fontSize')\" style=\"min-width:110px\">\n @for (s of sizes; track s.value) {\n <button type=\"button\" role=\"menuitemradio\" class=\"rte-item\"\n [class.selected]=\"activeFontSize() === s.label\" [attr.aria-checked]=\"activeFontSize() === s.label\"\n (click)=\"selectSize(s.value, s.label)\"><span [style.font-size.px]=\"s.px\">{{ sizeText(s.value) }}</span></button>\n }\n </div>\n }\n </span>\n }\n @if (show('fontFamily')) {\n <span class=\"rte-menu-wrap\" (click)=\"$event.stopPropagation()\">\n <button type=\"button\" class=\"rte-btn rte-menu-btn\" data-option=\"fontFamily\" [class.active]=\"openMenu() === 'font'\"\n [disabled]=\"inert()\" [attr.aria-label]=\"labels.t('richTextEditor.fontFamily')\" [attr.title]=\"labels.t('richTextEditor.fontFamily2')\"\n aria-haspopup=\"menu\" [attr.aria-expanded]=\"openMenu() === 'font'\" (click)=\"toggleMenu('font')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><text x=\"1\" y=\"18\" font-size=\"18\" fill=\"currentColor\" stroke=\"none\" font-weight=\"600\" font-style=\"italic\">{{ labels.t('richTextEditor.aa') }}</text></svg>\n <svg class=\"rte-chevron\" aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\"><polyline points=\"6 9 12 15 18 9\"/></svg>\n </button>\n @if (openMenu() === 'font') {\n <div class=\"rte-dropdown rte-font-panel\" role=\"menu\" [attr.aria-label]=\"labels.t('richTextEditor.fontFamily')\">\n @for (g of fontGroups; track g.label) {\n <div class=\"rte-group-label\" role=\"presentation\">{{ fontGroupText(g.label) }}</div>\n @for (f of g.fonts; track f.label) {\n <button type=\"button\" role=\"menuitemradio\" class=\"rte-item\"\n [class.selected]=\"activeFont() === f.label\" [attr.aria-checked]=\"activeFont() === f.label\"\n [style.font-family]=\"f.preview\" (click)=\"selectFont(f.value, f.label)\">{{ fontText(f) }}</button>\n }\n }\n </div>\n }\n </span>\n }\n\n @if (divider()['color']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('textColor')) {\n <label class=\"rte-btn\" data-option=\"textColor\" [attr.title]=\"labels.t('richTextEditor.textColor')\" [class.rte-btn-disabled]=\"inert()\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M4 20h16M12 4L6 18M12 4l6 14M8.5 13h7\"/></svg>\n <input type=\"color\" class=\"rte-color\" [attr.aria-label]=\"labels.t('richTextEditor.textColor2')\" value=\"#000000\" [disabled]=\"inert()\"\n (input)=\"execWithArg('foreColor', $any($event.target).value)\" />\n </label>\n }\n @if (show('highlight')) {\n <label class=\"rte-btn\" data-option=\"highlight\" [attr.title]=\"labels.t('richTextEditor.highlightColor')\" [class.rte-btn-disabled]=\"inert()\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"currentColor\"><path d=\"M15.24 2.58a1 1 0 00-1.41 0L5.59 10.82a2 2 0 000 2.83l4.24 4.24L8.41 19.3a1 1 0 001.42 1.41l1.41-1.41 1.06 1.06a1 1 0 001.42 0l8-8a1 1 0 000-1.42l-6.48-6.36zM7 13.65l3.54-3.54 3.54 3.54-3.54 3.53L7 13.65z\" opacity=\".4\"/><path d=\"M10.54 10.11l3.54-3.54 3.53 3.54-3.53 3.53-3.54-3.53z\"/></svg>\n <input type=\"color\" class=\"rte-color\" [attr.aria-label]=\"labels.t('richTextEditor.highlightColor2')\" value=\"#ffff00\" [disabled]=\"inert()\"\n (input)=\"execWithArg('hiliteColor', $any($event.target).value)\" />\n </label>\n }\n\n @if (divider()['align']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('align')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"align-left\" [class.active]=\"active()['justifyLeft']\"\n [attr.aria-pressed]=\"active()['justifyLeft']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.alignLeft')\" [attr.title]=\"labels.t('richTextEditor.alignLeft2')\" (click)=\"exec('justifyLeft')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"3\" y1=\"12\" x2=\"15\" y2=\"12\"/><line x1=\"3\" y1=\"18\" x2=\"18\" y2=\"18\"/></svg>\n </button>\n <button type=\"button\" class=\"rte-btn\" data-option=\"align-center\" [class.active]=\"active()['justifyCenter']\"\n [attr.aria-pressed]=\"active()['justifyCenter']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.alignCenter')\" [attr.title]=\"labels.t('richTextEditor.alignCenter2')\" (click)=\"exec('justifyCenter')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"6\" y1=\"12\" x2=\"18\" y2=\"12\"/><line x1=\"4\" y1=\"18\" x2=\"20\" y2=\"18\"/></svg>\n </button>\n <button type=\"button\" class=\"rte-btn\" data-option=\"align-right\" [class.active]=\"active()['justifyRight']\"\n [attr.aria-pressed]=\"active()['justifyRight']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.alignRight')\" [attr.title]=\"labels.t('richTextEditor.alignRight2')\" (click)=\"exec('justifyRight')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"9\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"6\" y1=\"18\" x2=\"21\" y2=\"18\"/></svg>\n </button>\n }\n\n @if (divider()['blocks']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('bulletList')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"bulletList\" [class.active]=\"active()['insertUnorderedList']\"\n [attr.aria-pressed]=\"active()['insertUnorderedList']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.bulletList')\" [attr.title]=\"labels.t('richTextEditor.bulletList2')\" (click)=\"exec('insertUnorderedList')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"9\" y1=\"6\" x2=\"20\" y2=\"6\"/><line x1=\"9\" y1=\"12\" x2=\"20\" y2=\"12\"/><line x1=\"9\" y1=\"18\" x2=\"20\" y2=\"18\"/><circle cx=\"5\" cy=\"6\" r=\"1.5\" fill=\"currentColor\"/><circle cx=\"5\" cy=\"12\" r=\"1.5\" fill=\"currentColor\"/><circle cx=\"5\" cy=\"18\" r=\"1.5\" fill=\"currentColor\"/></svg>\n </button>\n }\n @if (show('numberedList')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"numberedList\" [class.active]=\"active()['insertOrderedList']\"\n [attr.aria-pressed]=\"active()['insertOrderedList']\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.numberedList')\" [attr.title]=\"labels.t('richTextEditor.numberedList2')\" (click)=\"exec('insertOrderedList')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"10\" y1=\"6\" x2=\"20\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"20\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"20\" y2=\"18\"/><text x=\"3\" y=\"8\" font-size=\"8\" fill=\"currentColor\" stroke=\"none\" font-weight=\"bold\">1</text><text x=\"3\" y=\"14\" font-size=\"8\" fill=\"currentColor\" stroke=\"none\" font-weight=\"bold\">2</text><text x=\"3\" y=\"20\" font-size=\"8\" fill=\"currentColor\" stroke=\"none\" font-weight=\"bold\">3</text></svg>\n </button>\n }\n @if (show('indent')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"indent\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.indent')\" [attr.title]=\"labels.t('richTextEditor.indent')\" (click)=\"exec('indent')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\"/><polyline points=\"9 8 13 12 9 16\"/><line x1=\"3\" y1=\"12\" x2=\"13\" y2=\"12\"/></svg>\n </button>\n }\n @if (show('outdent')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"outdent\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.outdent')\" [attr.title]=\"labels.t('richTextEditor.outdent')\" (click)=\"exec('outdent')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><line x1=\"3\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"3\" y1=\"18\" x2=\"21\" y2=\"18\"/><polyline points=\"7 8 3 12 7 16\"/><line x1=\"3\" y1=\"12\" x2=\"21\" y2=\"12\"/></svg>\n </button>\n }\n\n @if (divider()['clear']) { <div class=\"rte-divider\" role=\"separator\" aria-orientation=\"vertical\"></div> }\n @if (show('clearFormat')) {\n <button type=\"button\" class=\"rte-btn\" data-option=\"clearFormat\" [disabled]=\"inert()\"\n [attr.aria-label]=\"labels.t('richTextEditor.clearFormatting')\" [attr.title]=\"labels.t('richTextEditor.clearFormatting2')\" (click)=\"exec('removeFormat')\">\n <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\"><path d=\"M4 7h16M6 4h8a2 2 0 012 2v0a2 2 0 01-2 2H6\"/><line x1=\"4\" y1=\"20\" x2=\"20\" y2=\"4\" stroke-width=\"1.5\"/></svg>\n </button>\n }\n </div>\n }\n\n <div\n #editor\n class=\"rte-editor\"\n [id]=\"_editorId\"\n [attr.contenteditable]=\"inert() ? 'false' : 'true'\"\n role=\"textbox\"\n aria-multiline=\"true\"\n [attr.aria-label]=\"label() ? null : (ariaLabel() || placeholder() || labels.t('richTextEditor.editorName'))\"\n [attr.aria-labelledby]=\"label() ? _labelId : null\"\n [attr.aria-required]=\"required() || null\"\n [attr.aria-readonly]=\"readonly() || null\"\n [attr.aria-disabled]=\"disabled() || null\"\n [attr.aria-invalid]=\"_activeError() ? 'true' : null\"\n [attr.aria-describedby]=\"_activeError() ? _errorId : null\"\n [attr.data-placeholder]=\"placeholder()\"\n [attr.data-empty]=\"empty() ? 'true' : null\"\n [style.min-height.px]=\"minHeight()\"\n [style.max-height.px]=\"maxHeight()\"\n (input)=\"onInput()\"\n (keydown)=\"onKeydown($event)\"\n (paste)=\"onPaste($event)\"\n (keyup)=\"refreshActive()\"\n (mouseup)=\"refreshActive()\"\n (blur)=\"onBlur()\"\n ></div>\n </div>\n\n @if (_activeError()) {\n <p class=\"rte-desc rte-desc-error\" [id]=\"_errorId\" role=\"alert\">{{ _activeError() }}</p>\n }\n </div>\n `,\n styles: [`\n :host { display: block; }\n\n .rte-field { display: flex; flex-direction: column; gap: 6px; }\n\n .rte-label { font-size: 0.8125rem; font-weight: 600; color: #374151; line-height: 1; }\n .rte-required { color: #dc2626; margin-left: 2px; }\n .rte-hint-inline { font-size: 0.75rem; color: #94a3b8; font-weight: 400; margin-left: 4px; }\n\n .rte-box {\n border: 1px solid #7c8ba1; border-radius: 8px; background: #fff;\n transition: border-color 0.15s, box-shadow 0.15s;\n }\n .rte-box:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12); }\n .rte-error .rte-box { border-color: #ef4444; }\n .rte-error .rte-box:focus-within { box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12); }\n .rte-disabled .rte-box { opacity: 0.5; cursor: not-allowed; }\n\n .rte-toolbar {\n display: flex; flex-wrap: wrap; align-items: center; gap: 2px;\n padding: 6px 8px; background: #f8fafc;\n border-bottom: 1px solid #e2e8f0; border-radius: 8px 8px 0 0;\n }\n .rte-divider { width: 1px; height: 20px; background: #cbd5e1; margin: 0 4px; }\n\n .rte-btn {\n position: relative;\n display: inline-flex; align-items: center; justify-content: center;\n width: 28px; height: 28px; padding: 0; border: none; border-radius: 4px;\n background: none; color: #64748b; cursor: pointer; transition: background 0.15s, color 0.15s;\n }\n .rte-btn svg { width: 16px; height: 16px; }\n .rte-btn:hover:not(:disabled) { background: #e2e8f0; color: #1e293b; }\n .rte-btn:focus-visible, .rte-btn:focus-within { outline: 2px solid #3b82f6; outline-offset: 1px; }\n .rte-btn.active { background: #dbeafe; color: #2563eb; }\n .rte-btn:disabled, .rte-btn-disabled { cursor: not-allowed; opacity: 0.5; }\n\n .rte-menu-wrap { position: relative; display: inline-flex; }\n .rte-menu-btn { width: auto; padding: 0 6px; gap: 3px; }\n .rte-menu-btn .rte-chevron { width: 10px; height: 10px; color: #64748b; flex-shrink: 0; }\n\n .rte-dropdown {\n position: absolute; top: calc(100% + 4px); left: 0; z-index: 100;\n background: #fff; border: 1px solid #e2e8f0; border-radius: 6px;\n box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12); padding: 4px;\n overflow-y: auto; max-height: 260px;\n }\n .rte-font-panel { min-width: 180px; }\n .rte-link-panel { display: flex; flex-direction: column; gap: 6px; min-width: 240px; padding: 10px; overflow: visible; }\n .rte-link-label { font-size: 12px; font-weight: 600; color: #374151; }\n .rte-link-input { box-sizing: border-box; width: 100%; padding: 6px 8px; font: inherit; font-size: 14px; border: 1px solid #cbd5e1; border-radius: 6px; }\n .rte-link-input:focus-visible { outline: 2px solid #2563eb; outline-offset: 1px; }\n .rte-link-error { margin: 0; font-size: 12px; color: #dc2626; }\n .rte-link-actions { display: flex; gap: 6px; }\n .rte-link-btn { padding: 5px 10px; font-size: 12px; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #374151; cursor: pointer; }\n .rte-link-apply { background: #2563eb; border-color: #2563eb; color: #fff; }\n .rte-item {\n display: block; width: 100%; text-align: left; padding: 5px 10px;\n font-size: 12px; color: #374151; border: none; background: none;\n border-radius: 4px; cursor: pointer; white-space: nowrap;\n }\n .rte-item:hover { background: #f1f5f9; }\n .rte-item.selected { background: #dbeafe; color: #2563eb; font-weight: 600; }\n .rte-group-label {\n font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;\n color: #94a3b8; padding: 6px 10px 2px;\n }\n .di-h1 { font-size: 18px; font-weight: 700; }\n .di-h2 { font-size: 15px; font-weight: 600; }\n .di-h3 { font-size: 13px; font-weight: 600; }\n\n .rte-color { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }\n\n .rte-editor {\n padding: 12px; outline: none; overflow-y: auto; box-sizing: border-box;\n font-size: 0.875rem; line-height: 1.6; color: #1e293b; background: #fff;\n border-radius: 0 0 8px 8px; word-break: break-word;\n }\n .rte-editor[data-empty=\"true\"]::before {\n content: attr(data-placeholder); color: #64748b; pointer-events: none; float: left; height: 0;\n }\n .rte-editor ul, .rte-editor ol { padding-left: 1.5em; margin: 0.25em 0; }\n .rte-editor li { margin: 0.15em 0; }\n .rte-editor h1 { font-size: 1.75em; font-weight: 700; margin: 0.5em 0 0.25em; }\n .rte-editor h2 { font-size: 1.4em; font-weight: 600; margin: 0.5em 0 0.25em; }\n .rte-editor h3 { font-size: 1.15em; font-weight: 600; margin: 0.5em 0 0.25em; }\n .rte-editor a { color: #2563eb; text-decoration: underline; }\n\n .rte-desc { margin: 0; font-size: 0.75rem; line-height: 1.4; color: #64748b; }\n .rte-desc-error { color: #dc2626; }\n\n @media (max-width: 480px) { .rte-editor { font-size: 1rem; } }\n\n /* Touch targets: toolbar buttons are >= 44px on touch devices and phones (desktop unchanged). */\n @media (pointer: coarse), (max-width: 480px) {\n .rte-btn { width: 44px; height: 44px; }\n .rte-menu-btn { width: auto; min-width: 44px; }\n .rte-divider { height: 28px; }\n }\n `],\n})\nexport class RichTextEditorComponent implements ControlValueAccessor {\n protected readonly labels = inject(UiLabelsService);\n readonly label = input('');\n /** Accessible name for an editor with no visible label. */\n readonly ariaLabel = input('');\n readonly placeholder = input('');\n readonly required = input(false);\n readonly readonly = input(false);\n readonly hint = input('');\n /** Host error message. Shown (with the red state, aria-invalid and aria-describedby) after the user left the editor (blur) or while `showErrors` is true. */\n readonly error = input('');\n /** True once the user left the editor. */\n /** The host's \"tried to submit\" flag (e.g. after a failed Save click): `true` shows the host `error` at once, even before the user touched the field; switching it from true back to false forgets the interaction (closing the form leaves no red field). */\n readonly showErrors = input(false);\n private readonly _reveal = createFieldReveal(this.showErrors);\n protected readonly _touched = this._reveal.touched;\n protected readonly _activeError = computed(() => this._reveal.revealed() ? this.error() : '');\n /** Forgets that the user left the editor (call it when the host resets its form): a host `error` is hidden again until the next blur. Same method on ui-signature-pad and ui-multi-select. */\n resetTouched(): void { this._touched.set(false); }\n /** Minimum editor height in px. */\n readonly minHeight = input(200);\n /** Maximum editor height in px; taller content scrolls. */\n readonly maxHeight = input(600);\n /** Toolbar controls to remove. Everything is shown by default. */\n readonly hide = input<RichTextOption[]>([]);\n\n readonly _disabledInput = input(false, { alias: 'disabled' });\n private readonly _cvaDisabled = signal(false);\n protected readonly disabled = computed(() => this._disabledInput() || this._cvaDisabled());\n /** Disabled or read-only: the editor is not editable and every toolbar control is disabled. */\n protected readonly inert = computed(() => this.disabled() || this.readonly());\n\n private readonly editor = viewChild<ElementRef<HTMLDivElement>>('editor');\n\n protected readonly _id = ++nextId;\n protected readonly _editorId = `rte-${this._id}`;\n protected readonly _labelId = `rte-${this._id}-label`;\n protected readonly _errorId = `rte-${this._id}-error`;\n\n protected readonly headings = HEADINGS;\n protected readonly sizes = SIZES;\n protected readonly fontGroups = FONT_GROUPS;\n\n /** Display texts of the option menus (the English `label`s stay the stable identity of the choice). */\n protected headingText(tag: string): string { return this.labels.t(`richTextEditor.heading.${tag}` as UiLabelKey); }\n protected sizeText(value: string): string { return this.labels.t(`richTextEditor.size.${value}` as UiLabelKey); }\n protected fontGroupText(label: string): string { return this.labels.t(`richTextEditor.fontGroup.${label}` as UiLabelKey); }\n protected fontText(font: { value: string; label: string }): string { return font.value === 'inherit' ? this.labels.t('richTextEditor.fontDefault') : font.label; }\n\n protected readonly openMenu = signal<MenuId | null>(null);\n protected readonly activeHeading = signal('Normal');\n protected readonly activeFontSize = signal('Normal');\n protected readonly activeFont = signal('Default');\n protected readonly active = signal<Record<string, boolean>>(Object.fromEntries(STATE_COMMANDS.map(c => [c, false])));\n protected readonly empty = signal(true);\n protected readonly linkUrl = signal('');\n protected readonly linkError = signal('');\n protected readonly hasLink = signal(false);\n protected readonly _linkId = `rte-${++nextId}-link`;\n\n private readonly hidden = computed(() => new Set<RichTextOption>(this.hide()));\n\n /** Group id → at least one of its controls is shown. */\n private readonly groupVisible = computed(() => {\n const hidden = this.hidden();\n const out: Record<string, boolean> = {};\n for (const g of GROUPS) out[g.id] = g.options.some(o => !hidden.has(o));\n return out;\n });\n protected readonly toolbarVisible = computed(() => Object.values(this.groupVisible()).some(Boolean));\n /** Group id → a divider belongs in front of it (it is visible and an earlier group is too). */\n protected readonly divider = computed(() => {\n const visible = this.groupVisible();\n const out: Record<string, boolean> = {};\n let seen = false;\n for (const g of GROUPS) {\n out[g.id] = visible[g.id] && seen;\n seen = seen || visible[g.id];\n }\n return out;\n });\n\n private _lastEmitted = '';\n private _pending: string | null = null;\n private _savedRange: Range | null = null;\n\n private _onChange = (_: string) => {};\n private _onTouched = () => {};\n\n constructor() {\n afterNextRender(() => {\n if (this._pending !== null) {\n this._setHtml(this._pending);\n this._pending = null;\n }\n });\n }\n\n protected show(option: RichTextOption): boolean {\n return !this.hidden().has(option);\n }\n\n // ── ControlValueAccessor ────────────────────────────────────────────────\n\n writeValue(val: string | null): void {\n const html = val ?? '';\n if (html === this._lastEmitted) return; // our own change echoed back by ngModel — don't reset the caret\n this._lastEmitted = html;\n this._setHtml(html);\n }\n registerOnChange(fn: (v: string) => void): void { this._onChange = fn; }\n registerOnTouched(fn: () => void): void { this._onTouched = fn; }\n setDisabledState(d: boolean): void { this._cvaDisabled.set(d); }\n\n private _setHtml(html: string): void {\n const el = this.editor()?.nativeElement;\n if (!el) { this._pending = html; return; }\n const clean = sanitizeRichTextHtml(html);\n if (el.innerHTML !== clean) el.innerHTML = clean;\n this.empty.set(this._isEmpty(el));\n }\n\n private _isEmpty(el: HTMLElement): boolean {\n return !(el.textContent ?? '').trim() && !el.querySelector('li, hr, img');\n }\n\n // ── Public helpers ──────────────────────────────────────────────────────\n\n focus(): void {\n this.editor()?.nativeElement.focus();\n }\n\n // ── Events ──────────────────────────────────────────────────────────────\n\n protected onInput(): void {\n const el = this.editor()?.nativeElement;\n if (!el) return;\n const isEmpty = this._isEmpty(el);\n this.empty.set(isEmpty);\n // an emptied editor leaves a stray <br> behind — report it as an empty value\n const html = isEmpty ? '' : el.innerHTML;\n this._lastEmitted = html;\n this._onChange(html);\n }\n\n protected onBlur(): void {\n this._saveSelection();\n this._touched.set(true);\n this._onTouched();\n }\n\n protected onToolbarMouseDown(event: MouseEvent): void {\n // keep the editor's selection when a toolbar button is pressed (colour pickers need the click)\n const target = event.target as HTMLElement;\n if (target.closest('button')) event.preventDefault();\n }\n\n onDocumentClick(): void {\n if (this.openMenu()) this.openMenu.set(null);\n }\n\n onSelectionChange(): void {\n const el = this.editor()?.nativeElement;\n const sel = window.getSelection();\n if (!el || !sel || sel.rangeCount === 0 || !el.contains(sel.anchorNode)) return;\n this.refreshActive();\n }\n\n protected refreshActive(): void {\n if (this.inert()) return;\n const next: Record<string, boolean> = {};\n for (const cmd of STATE_COMMANDS) {\n try { next[cmd] = document.queryCommandState(cmd); } catch { next[cmd] = false; }\n }\n const prev = this.active();\n if (STATE_COMMANDS.some(c => prev[c] !== next[c])) this.active.set(next);\n }\n\n protected onKeydown(event: KeyboardEvent): void {\n if (!(event.metaKey || event.ctrlKey) || event.altKey || event.shiftKey) return;\n const shortcut: Record<string, { option: RichTextOption; command: string }> = {\n b: { option: 'bold', command: 'bold' },\n i: { option: 'italic', command: 'italic' },\n u: { option: 'underline', command: 'underline' },\n };\n const hit = shortcut[event.key.toLowerCase()];\n if (!hit) return;\n // always swallow the browser's own shortcut so a hidden option can't be applied by keyboard\n event.preventDefault();\n if (this.show(hit.option) && !this.inert()) this.exec(hit.command);\n }\n\n protected onPaste(event: ClipboardEvent): void {\n event.preventDefault();\n if (this.inert()) return;\n const data = event.clipboardData;\n if (!data) return;\n const html = data.getData('text/html');\n const text = data.getData('text/plain');\n if (html) {\n const clean = sanitizeRichTextHtml(html, {\n mode: 'paste',\n blockedTags: this._blockedTags(),\n replace: BLOCK_REPLACEMENT,\n });\n document.execCommand('insertHTML', false, clean);\n } else if (text) {\n if (text.includes('\\n') || text.includes('\\r')) document.execCommand('insertHTML', false, plainTextToHtml(text));\n else document.execCommand('insertText', false, text);\n }\n this.onInput();\n }\n\n private _blockedTags(): Set<string> {\n const blocked = new Set<string>();\n for (const option of this.hidden()) for (const tag of OPTION_TAGS[option] ?? []) blocked.add(tag);\n return blocked;\n }\n\n // ── Selection ───────────────────────────────────────────────────────────\n\n private _saveSelection(): void {\n const el = this.editor()?.nativeElement;\n const sel = window.getSelection();\n if (el && sel && sel.rangeCount > 0 && el.contains(sel.anchorNode)) {\n this._savedRange = sel.getRangeAt(0).cloneRange();\n }\n }\n\n private _restoreSelection(): void {\n const el = this.editor()?.nativeElement;\n if (!el) return;\n const sel = window.getSelection();\n const inside = !!sel && sel.rangeCount > 0 && el.contains(sel.anchorNode);\n el.focus();\n if (!inside && this._savedRange && sel) {\n sel.removeAllRanges();\n sel.addRange(this._savedRange);\n }\n }\n\n // ── Commands ────────────────────────────────────────────────────────────\n\n protected toggleMenu(menu: MenuId): void {\n this.openMenu.set(this.openMenu() === menu ? null : menu);\n }\n\n protected selectHeading(tag: string, label: string): void {\n this.activeHeading.set(label);\n this.openMenu.set(null);\n this._restoreSelection();\n document.execCommand('formatBlock', false, tag);\n this.onInput();\n }\n\n protected selectSize(value: string, label: string): void {\n this.activeFontSize.set(label);\n this.openMenu.set(null);\n this.execWithArg('fontSize', value);\n }\n\n protected selectFont(value: string, label: string): void {\n this.activeFont.set(label);\n this.openMenu.set(null);\n this.execWithArg('fontName', value);\n }\n\n /** The `<a>` the saved (or current) selection sits in, if any. */\n private _anchorAtSelection(): HTMLAnchorElement | null {\n const el = this.editor()?.nativeElement;\n const sel = window.getSelection();\n const node = sel && sel.rangeCount > 0 && el?.contains(sel.anchorNode) ? sel.anchorNode : this._savedRange?.startContainer ?? null;\n const base = node && node.nodeType === Node.TEXT_NODE ? node.parentElement : (node as Element | null);\n const a = base?.closest('a') ?? null;\n return a && el?.contains(a) ? a as HTMLAnchorElement : null;\n }\n\n protected toggleLink(): void {\n if (this.openMenu() === 'link') { this.openMenu.set(null); return; }\n this._saveSelection();\n const a = this._anchorAtSelection();\n this.hasLink.set(!!a);\n this.linkUrl.set(a?.getAttribute('href') ?? '');\n this.linkError.set('');\n this.openMenu.set('link');\n }\n\n protected closeLink(): void {\n this.openMenu.set(null);\n this._restoreSelection();\n }\n\n protected applyLink(): void {\n if (this.inert()) return;\n const url = normalizeLinkUrl(this.linkUrl());\n if (!url) { this.linkError.set(this.labels.t('richTextEditor.linkNeedsAddress')); return; }\n this.openMenu.set(null);\n this._restoreSelection();\n const sel = window.getSelection();\n const existing = this._anchorAtSelection();\n if (existing) {\n existing.setAttribute('href', url);\n } else if (!sel || sel.isCollapsed) {\n const text = url.replace(/^(mailto:|tel:|https?:\\/\\/)/i, '');\n document.execCommand('insertHTML', false, `<a href=\"${url.replace(/&/g, '&').replace(/\"/g, '"')}\">${plainTextToHtml(text)}</a>`);\n } else {\n document.execCommand('createLink', false, url);\n }\n this.onInput();\n }\n\n protected removeLink(): void {\n if (this.inert()) return;\n this.openMenu.set(null);\n this._restoreSelection();\n const a = this._anchorAtSelection();\n if (a) {\n const range = document.createRange();\n range.selectNodeContents(a);\n const sel = window.getSelection();\n sel?.removeAllRanges();\n sel?.addRange(range);\n }\n document.execCommand('unlink', false);\n this.onInput();\n }\n\n protected exec(command: string): void {\n if (this.inert()) return;\n this._restoreSelection();\n document.execCommand(command, false);\n this.onInput();\n this.refreshActive();\n }\n\n protected execWithArg(command: string, value: string): void {\n if (!value || this.inert()) return;\n this._restoreSelection();\n document.execCommand(command, false, value);\n this.onInput();\n }\n}\n","import type { EmailTemplateBlockGroup, EmailTemplatePreviewBrand, EmailTemplateVariableGroup, EmailTemplateVideo } from './email-template-editor.models';\nimport { UiLabelKey, uiText } from '@forgeroute/ui/core';\n\n/** The text a new template's first block starts with: it is a prompt, not content, so a template still holding only this has no message. */\nexport const EMAIL_TEMPLATE_START_TEXT = 'Start writing your email...';\n\n/** Longest message (serialised HTML) the editor accepts by default; hosts pass their own server limit through `maxBodyLength`. */\nexport const EMAIL_TEMPLATE_MAX_BODY = 9_000;\n/** Longest name / subject accepted by default. */\nexport const EMAIL_TEMPLATE_MAX_TEXT = 255;\n\n/** Longest single email address (server rule). */\nexport const MAX_EMAIL_ADDRESS_LENGTH = 254;\n/** One address: no spaces, no second `@`, none of `, ; < > \"`, and a dot in the domain. */\nconst EMAIL_RE = /^[^\\s@,;<>\"]+@[^\\s@,;<>\"]+\\.[^\\s@,;<>\"]+$/;\n/** True for a plausible single email address of at most 254 characters. */\nexport const isValidEmailAddress = (address: string): boolean => address.length <= MAX_EMAIL_ADDRESS_LENGTH && EMAIL_RE.test(address);\n\n/** An http(s) address with a real host: no spaces or quotes (the address is written into an HTML attribute) and a dot or `localhost`. */\nexport function isWebUrl(raw: string): boolean {\n if (/[\\s\"<>]/.test(raw)) return false;\n try {\n const u = new URL(raw);\n return (u.protocol === 'http:' || u.protocol === 'https:') && (u.hostname.includes('.') || u.hostname === 'localhost');\n } catch { return false; }\n}\n\n/**\n * How many characters typed text takes once it is saved, i.e. as `innerHTML` writes a TEXT node: `&`, `<` and `>` become entities and a\n * non-breaking space (what a browser types for a run of spaces) becomes ` `; quotes are not escaped in text, so each counts as one.\n */\nexport function serializedTextLength(text: string): number {\n // By UTF-16 unit, like `String.length` (the body limit is measured the same way): an emoji is two units.\n let n = 0;\n for (let i = 0; i < text.length; i++) { const ch = text[i]; n += ch === '&' ? 5 : ch === '<' || ch === '>' ? 4 : ch === '\\u00A0' ? 6 : 1; }\n return n;\n}\n\n/** Escapes text for HTML text and double-quoted attribute values. */\nexport function escapeHtml(value: string): string {\n return value.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"').replace(/'/g, ''');\n}\n\nconst CONTENT_MEMO = new Map<string, boolean>();\n\n/** True when a block's HTML shows something to a reader: an image or other media, or text once tags, non-breaking spaces and whitespace are gone. */\nexport function blockHasContent(html: string): boolean {\n const hit = CONTENT_MEMO.get(html);\n if (hit !== undefined) return hit;\n // DOMParser builds an inert document (all four browsers): images in it are never fetched and `onerror` handlers never run, unlike\n // `innerHTML` on a detached element. The answer is a pure function of the HTML, so it is remembered per block text.\n const doc = new DOMParser().parseFromString(html, 'text/html');\n let result: boolean;\n if (doc.querySelector('img, video, iframe')) result = true;\n else {\n const text = (doc.body.textContent ?? '').replace(/ /g, ' ').trim();\n result = text !== '' && text !== EMAIL_TEMPLATE_START_TEXT && text !== uiText('emailTemplateEditor.startWriting');\n }\n if (CONTENT_MEMO.size >= 200) CONTENT_MEMO.clear();\n CONTENT_MEMO.set(html, result);\n return result;\n}\n\n/**\n * The drag payload of a block (a palette item or a block being reordered). A custom type, never `text/plain`: a text drop onto a block's\n * contenteditable would insert the payload into the message in every engine. Firefox only starts a drag when some data is set (a custom\n * type counts); Safari lets a drop zone read `types` during dragover but not `getData`.\n */\nexport const EMAIL_BLOCK_DRAG_TYPE = 'application/x-tpl-block';\n\n/** True when the drag carries a block payload (`types` is an array in current engines, a DOMStringList in very old ones). */\nexport function isBlockDrag(event: { dataTransfer?: { types?: ArrayLike<string> | readonly string[] } | null }): boolean {\n const types = event.dataTransfer?.types;\n return !!types && Array.from(types as ArrayLike<string>).includes(EMAIL_BLOCK_DRAG_TYPE);\n}\n\n/** True when a node sits inside one of the editor's blocks (the only place a saved selection may point). */\nexport function insideEditorBlock(node: Node | null | undefined): boolean {\n const el = node instanceof Element ? node : node?.parentElement;\n return !!el?.closest('.block-content');\n}\n\n/** `m:ss` for a duration in seconds; '' when there is none. */\nexport function formatVideoDuration(seconds: number | null | undefined): string {\n if (!seconds) return '';\n const m = Math.floor(seconds / 60), s = seconds % 60;\n return `${m}:${s.toString().padStart(2, '0')}`;\n}\n\n/** `follow-up` → `Follow Up`. */\nexport function formatCategoryLabel(cat: string | null | undefined): string {\n return (cat ?? '').split('-').filter(Boolean).map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' ');\n}\n\n/** The thumbnail address of a video: absolute as given, or relative to `origin`. */\nfunction thumbnailSrc(video: EmailTemplateVideo, origin: string): string | null {\n const t = video.thumbnailUrl;\n if (!t) return null;\n return t.startsWith('http') ? t : `${origin}${t}`;\n}\n\n/** The email block a video becomes: a thumbnail with a play overlay, linked to `link`, with the title and a caption. Every user value is escaped. */\nexport function buildVideoBlockHtml(video: EmailTemplateVideo, link: string, caption: string, origin: string): string {\n const title = escapeHtml(video.title);\n const href = escapeHtml(link);\n const thumb = thumbnailSrc(video, origin);\n const playOverlay = `<div style=\"position:absolute;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,0.25);\"><div style=\"width:64px;height:64px;background:rgba(0,0,0,0.65);border-radius:50%;display:flex;align-items:center;justify-content:center;box-shadow:0 2px 12px rgba(0,0,0,0.4);\"><div style=\"width:0;height:0;border-style:solid;border-width:12px 0 12px 22px;border-color:transparent transparent transparent #ffffff;margin-left:5px;\"></div></div></div>`;\n const thumbInner = thumb\n ? `<img src=\"${escapeHtml(thumb)}\" alt=\"${title}\" style=\"width:100%;height:200px;object-fit:cover;display:block;border-radius:0;\"/>`\n : `<div style=\"width:100%;height:200px;background:linear-gradient(135deg,#1e293b,#334155);display:flex;align-items:center;justify-content:center;\"></div>`;\n const thumbHtml = `<div style=\"position:relative;display:block;line-height:0;\">${thumbInner}${playOverlay}</div>`;\n return `<div style=\"max-width:560px;margin:16px auto;border:1px solid #e2e8f0;border-radius:12px;overflow:hidden;font-family:inherit\"><a href=\"${href}\" target=\"_blank\" style=\"display:block;text-decoration:none;\">${thumbHtml}<div style=\"padding:14px 16px;background:#fff;display:flex;align-items:center;gap:10px;\"><div style=\"width:32px;height:32px;background:#ef4444;border-radius:6px;flex-shrink:0;display:flex;align-items:center;justify-content:center;\"><div style=\"width:0;height:0;border-style:solid;border-width:6px 0 6px 11px;border-color:transparent transparent transparent #ffffff;margin-left:2px;\"></div></div><div><p style=\"font-size:14px;font-weight:600;color:#1e293b;margin:0 0 2px;\">${title}</p><p style=\"font-size:12px;color:#64748b;margin:0;\">${escapeHtml(caption)}</p></div></div></a></div>`;\n}\n\nconst TH = 'padding:8px 12px;text-align:left;background:#f8fafc;border:1px solid #e2e8f0';\nconst TD = 'padding:8px 12px;border:1px solid #e2e8f0';\n\n/** The content blocks every host gets unless it passes its own `blockGroups`. */\nexport const DEFAULT_EMAIL_TEMPLATE_BLOCK_GROUPS: EmailTemplateBlockGroup[] = [\n { name: 'Buttons', blocks: [\n { key: 'btn-primary', label: 'Primary Button', html: '<div style=\"text-align:center;margin:16px 0\"><a href=\"#\" style=\"display:inline-block;padding:12px 28px;background:#3B82F6;color:#fff;border-radius:6px;text-decoration:none;font-weight:600\">Button Text</a></div>' },\n { key: 'btn-secondary', label: 'Secondary Button', html: '<div style=\"text-align:center;margin:16px 0\"><a href=\"#\" style=\"display:inline-block;padding:12px 28px;background:#64748b;color:#fff;border-radius:6px;text-decoration:none;font-weight:600\">Button Text</a></div>' },\n { key: 'btn-outline', label: 'Outline Button', html: '<div style=\"text-align:center;margin:16px 0\"><a href=\"#\" style=\"display:inline-block;padding:12px 28px;border:2px solid #3B82F6;color:#3B82F6;border-radius:6px;text-decoration:none;font-weight:600\">Button Text</a></div>' },\n { key: 'btn-link', label: 'Link Button', html: '<div style=\"margin:8px 0\"><a href=\"#\" style=\"color:#3B82F6;text-decoration:underline\">Link Text</a></div>' },\n ]},\n { name: 'Spacing', blocks: [\n { key: 'spacer-sm', label: 'Small Spacer', html: '<div style=\"height:8px\"> </div>' },\n { key: 'spacer-md', label: 'Medium Spacer', html: '<div style=\"height:24px\"> </div>' },\n { key: 'spacer-lg', label: 'Large Spacer', html: '<div style=\"height:48px\"> </div>' },\n { key: 'divider', label: 'Divider Line', html: '<hr style=\"border:none;border-top:1px solid #e2e8f0;margin:16px 0\"/>' },\n ]},\n { name: 'Layout', blocks: [\n { key: 'layout-2col', label: 'Two Columns', html: '<table style=\"width:100%;border-collapse:collapse\"><tr><td style=\"width:50%;padding:8px;vertical-align:top\"><p>Left column</p></td><td style=\"width:50%;padding:8px;vertical-align:top\"><p>Right column</p></td></tr></table>' },\n { key: 'layout-3col', label: 'Three Columns', html: '<table style=\"width:100%;border-collapse:collapse\"><tr><td style=\"width:33%;padding:8px;vertical-align:top\"><p>Col 1</p></td><td style=\"width:33%;padding:8px;vertical-align:top\"><p>Col 2</p></td><td style=\"width:34%;padding:8px;vertical-align:top\"><p>Col 3</p></td></tr></table>' },\n ]},\n { name: 'Content', blocks: [\n { key: 'text-block', label: 'Text Block', html: '<p>Enter your text here...</p>' },\n { key: 'image-block', label: 'Image Block', html: '<div style=\"text-align:center;margin:8px 0\"><img src=\"https://placehold.co/600x200/e2e8f0/94a3b8?text=Image\" alt=\"Image\" style=\"max-width:100%;border-radius:8px\"/></div>' },\n ]},\n { name: 'Tables', blocks: [\n { key: 'table-2col', label: 'Two-Column Table', html: `<table style=\"width:100%;border-collapse:collapse;border:1px solid #e2e8f0\"><tr><th style=\"${TH}\">Header 1</th><th style=\"${TH}\">Header 2</th></tr><tr><td style=\"${TD}\">Data</td><td style=\"${TD}\">Data</td></tr></table>` },\n { key: 'table-3col', label: 'Three-Column Table', html: `<table style=\"width:100%;border-collapse:collapse;border:1px solid #e2e8f0\"><tr><th style=\"${TH}\">Header 1</th><th style=\"${TH}\">Header 2</th><th style=\"${TH}\">Header 3</th></tr><tr><td style=\"${TD}\">Data</td><td style=\"${TD}\">Data</td><td style=\"${TD}\">Data</td></tr></table>` },\n ]},\n];\n\nconst GROUP_KEYS: Record<string, string> = { Buttons: 'buttons', Spacing: 'spacing', Layout: 'layout', Content: 'content', Tables: 'tables' };\n\n/** The sample words inside a block's HTML (\"Button Text\", \"Header 1\" ...) in the app's active language. English HTML is returned unchanged. */\nfunction localizeBlockHtml(html: string): string {\n const pairs: [string, string][] = [\n ['>Button Text<', `>${uiText('emailTemplateEditor.sample.buttonText')}<`], ['>Link Text<', `>${uiText('emailTemplateEditor.sample.linkText')}<`],\n ['<p>Left column</p>', `<p>${uiText('emailTemplateEditor.sample.leftColumn')}</p>`], ['<p>Right column</p>', `<p>${uiText('emailTemplateEditor.sample.rightColumn')}</p>`],\n ['<p>Col 1</p>', `<p>${uiText('emailTemplateEditor.sample.column', { n: 1 })}</p>`], ['<p>Col 2</p>', `<p>${uiText('emailTemplateEditor.sample.column', { n: 2 })}</p>`],\n ['<p>Col 3</p>', `<p>${uiText('emailTemplateEditor.sample.column', { n: 3 })}</p>`],\n ['<p>Enter your text here...</p>', `<p>${uiText('emailTemplateEditor.sample.enterText')}</p>`],\n ['alt=\"Image\"', `alt=\"${uiText('emailTemplateEditor.sample.image')}\"`],\n ['>Header 1<', `>${uiText('emailTemplateEditor.sample.header', { n: 1 })}<`], ['>Header 2<', `>${uiText('emailTemplateEditor.sample.header', { n: 2 })}<`],\n ['>Header 3<', `>${uiText('emailTemplateEditor.sample.header', { n: 3 })}<`], ['>Data<', `>${uiText('emailTemplateEditor.sample.data')}<`],\n ];\n return pairs.reduce((out, [from, to]) => out.split(from).join(to), html);\n}\n\n/** The default content blocks with group names, block names and sample words in the app's active language. */\nexport function localizedEmailBlockGroups(): EmailTemplateBlockGroup[] {\n return DEFAULT_EMAIL_TEMPLATE_BLOCK_GROUPS.map(g => ({\n ...g,\n name: uiText(`emailTemplateEditor.group.${GROUP_KEYS[g.name] ?? g.name}` as UiLabelKey),\n blocks: g.blocks.map(b => ({ ...b, label: uiText(`emailTemplateEditor.block.${b.key}` as UiLabelKey), html: localizeBlockHtml(b.html) })),\n }));\n}\n\n/** Generic merge variables; a host passes its own `variableGroups` for the data its sender can fill in. */\nexport const DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS = [\n { name: 'Contact', variables: [\n { key: 'first_name', label: 'First Name', example: 'John' },\n { key: 'last_name', label: 'Last Name', example: 'Smith' },\n { key: 'full_name', label: 'Full Name', example: 'John Smith' },\n { key: 'email', label: 'Email', example: 'john@example.com' },\n { key: 'phone', label: 'Phone', example: '(512) 555-0100' },\n ]},\n];\n\n/**\n * The document the Preview / Mobile tabs show (inside a sandboxed iframe): the serialised message with the base look of a sent email. A\n * Content-Security-Policy meta blocks scripts and anything but images / inline styles, and links open nowhere (sandbox, no popups).\n */\nexport function buildPreviewDocument(bodyHtml: string, brand?: EmailTemplatePreviewBrand | null): string {\n const b = safePreviewBrand(brand);\n const font = b.fontFamily ?? '-apple-system,BlinkMacSystemFont,\"Segoe UI\",Roboto,Helvetica,Arial,sans-serif';\n const head = b.logoUrl || b.companyName\n ? '<div class=\"brand-head\">' + (b.logoUrl ? `<img src=\"${escapeHtml(b.logoUrl)}\" alt=\"\">` : '') + (b.companyName ? `<span>${escapeHtml(b.companyName)}</span>` : '') + '</div>'\n : '';\n const foot = b.footerText ? `<div class=\"brand-foot\">${escapeHtml(b.footerText).replace(/\\r?\\n/g, '<br>')}</div>` : '';\n return '<!doctype html><html><head><meta charset=\"utf-8\">'\n + `<meta http-equiv=\"Content-Security-Policy\" content=\"default-src 'none'; img-src * data:; style-src 'unsafe-inline'; font-src data:\">`\n + '<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">'\n + `<style>html,body{margin:0}body{padding:24px 28px;font:15px/1.6 ${font};color:${b.textColor ?? '#1e293b'};${b.backgroundColor ? `background:${b.backgroundColor};` : ''}overflow-wrap:anywhere}`\n + `p{margin:0 0 8px}img{max-width:100%}table{max-width:100%}a{color:${b.linkColor ?? '#3b82f6'}}`\n + '.brand-head{display:flex;align-items:center;gap:12px;margin:0 0 16px;font-weight:600}.brand-head img{max-height:48px;width:auto}'\n + '.brand-foot{margin:24px 0 0;padding-top:12px;border-top:1px solid rgba(100,116,139,.35);font-size:12px;line-height:1.5;color:#64748b}</style></head>'\n + `<body>${head}${bodyHtml}${foot}</body></html>`;\n}\n\nconst BRAND_COLOR = /^(#[0-9a-f]{3,8}|[a-z]{3,20})$/i;\nconst BRAND_FONT = /^[A-Za-z0-9 ,'_-]{1,200}$/;\nconst BRAND_TEXT_MAX = 500;\n\n/** Keeps only the brand values that are safe to write into the preview document (see `EmailTemplatePreviewBrand`); anything else is dropped. */\nexport function safePreviewBrand(brand?: EmailTemplatePreviewBrand | null): EmailTemplatePreviewBrand {\n if (!brand) return {};\n const out: EmailTemplatePreviewBrand = {};\n const color = (v: unknown) => (typeof v === 'string' && BRAND_COLOR.test(v.trim()) ? v.trim() : undefined);\n const text = (v: unknown) => (typeof v === 'string' && v.trim() ? v.trim().slice(0, BRAND_TEXT_MAX) : undefined);\n if (typeof brand.fontFamily === 'string' && BRAND_FONT.test(brand.fontFamily.trim())) out.fontFamily = brand.fontFamily.trim();\n out.textColor = color(brand.textColor);\n out.linkColor = color(brand.linkColor);\n out.backgroundColor = color(brand.backgroundColor);\n if (typeof brand.logoUrl === 'string' && isWebUrl(brand.logoUrl.trim())) out.logoUrl = brand.logoUrl.trim();\n out.companyName = text(brand.companyName);\n out.footerText = text(brand.footerText);\n for (const k of Object.keys(out) as (keyof EmailTemplatePreviewBrand)[]) if (out[k] === undefined) delete out[k];\n return out;\n}\n\nconst VARIABLE_TOKEN = /\\{\\{\\s*([A-Za-z0-9_]+)\\s*\\}\\}/g;\n\n/** The `{{key}}` merge variables written in the texts, each once, in the order they first appear. */\nexport function usedVariableKeys(...texts: string[]): string[] {\n const keys: string[] = [];\n for (const text of texts) for (const m of text.matchAll(VARIABLE_TOKEN)) if (!keys.includes(m[1])) keys.push(m[1]);\n return keys;\n}\n\n/** The message as the Preview shows it with sample data: every known `{{key}}` becomes the variable's (escaped) `example`; a key the host does not offer stays as written. */\nexport function fillSampleVariables(html: string, groups: readonly EmailTemplateVariableGroup[]): string {\n const examples = new Map<string, string>();\n for (const g of groups) for (const v of g.variables) examples.set(v.key, v.example);\n return html.replace(VARIABLE_TOKEN, (token, key: string) => (examples.has(key) ? escapeHtml(examples.get(key) ?? '') : token));\n}\n\n/** What the editor warns about before a template is saved: mistakes that turn into a broken email. */\nexport interface EmailChecks {\n /** Variables used in the subject or message that the host does not offer: they are sent as empty text. */\n unknownVariables: string[];\n /** Images with no alt text (what a screen reader and a blocked-image inbox show). */\n imagesWithoutAlt: number;\n /** Links with no address (empty or `#`): clicking them goes nowhere. */\n emptyLinks: number;\n}\n\nexport function findEmailChecks(subject: string, bodyHtml: string, knownKeys: readonly string[]): EmailChecks {\n const doc = new DOMParser().parseFromString(bodyHtml, 'text/html');\n const links = Array.from(doc.querySelectorAll('a')).filter(a => { const href = (a.getAttribute('href') ?? '').trim(); return href === '' || href === '#'; });\n return {\n unknownVariables: usedVariableKeys(subject, bodyHtml).filter(k => !knownKeys.includes(k)),\n imagesWithoutAlt: Array.from(doc.querySelectorAll('img')).filter(i => !(i.getAttribute('alt') ?? '').trim()).length,\n emptyLinks: links.length,\n };\n}\n\n/** The default merge variables with names in the app's active language (the `key` and the example value stay as they are). */\nexport function localizedEmailVariableGroups() {\n const label: Record<string, UiLabelKey> = {\n first_name: 'emailTemplateEditor.variable.firstName', last_name: 'emailTemplateEditor.variable.lastName', full_name: 'emailTemplateEditor.variable.fullName',\n email: 'common.email', phone: 'common.phone',\n };\n return DEFAULT_EMAIL_TEMPLATE_VARIABLE_GROUPS.map(g => ({\n ...g, name: uiText('emailTemplateEditor.variableGroup.contact'),\n variables: g.variables.map(v => ({ ...v, label: label[v.key] ? uiText(label[v.key]) : v.label })),\n }));\n}\n","import {\n Component, ChangeDetectionStrategy, ElementRef, Injector, afterEveryRender, afterNextRender, computed, effect, inject, input, output, signal,\n untracked, viewChild, viewChildren,\n} from '@angular/core';\nimport { DomSanitizer, SafeHtml } from '@angular/platform-browser';\nimport { FormsModule } from '@angular/forms';\nimport { AlertComponent } from '@forgeroute/ui/alert';\nimport { ButtonComponent } from '@forgeroute/ui/core';\nimport { CheckboxComponent } from '@forgeroute/ui/checkbox';\nimport { DividerComponent } from '@forgeroute/ui/divider';\nimport { DateInputComponent } from '@forgeroute/ui/date-input';\nimport { EmptyStateComponent } from '@forgeroute/ui/empty-state';\nimport { ErrorComponent } from '@forgeroute/ui/error';\nimport { PillTab, PillTabsComponent } from '@forgeroute/ui/pill-tabs';\nimport { RadioGroupComponent } from '@forgeroute/ui/radio';\nimport { SearchInputComponent } from '@forgeroute/ui/search-input';\nimport { SelectComponent, SelectOption } from '@forgeroute/ui/select';\nimport { SidePanelComponent } from '@forgeroute/ui/core';\nimport { SkeletonComponent } from '@forgeroute/ui/skeleton';\nimport { TextInputComponent } from '@forgeroute/ui/text-input';\nimport { TooltipDirective } from '@forgeroute/ui/tooltip';\nimport {\n EmailTemplateAssignmentOption, EmailTemplateBlock, EmailTemplateBlockGroup, EmailTemplatePreviewBrand, EmailTemplateSavePayload,\n EmailTemplateValue, EmailTemplateVariable, EmailTemplateVariableGroup, EmailTemplateVideo, EmailTemplateVideoDefaults, EmailTemplateVideoLinkFn,\n} from './email-template-editor.models';\nimport {\n localizedEmailBlockGroups, localizedEmailVariableGroups, EMAIL_BLOCK_DRAG_TYPE, EMAIL_TEMPLATE_MAX_BODY, EMAIL_TEMPLATE_MAX_TEXT,\n EMAIL_TEMPLATE_START_TEXT, blockHasContent, buildPreviewDocument, fillSampleVariables, findEmailChecks, serializedTextLength, buildVideoBlockHtml, escapeHtml, formatCategoryLabel, formatVideoDuration, insideEditorBlock, isBlockDrag,\n isValidEmailAddress, isWebUrl,\n} from './email-template-editor.utils';\nimport { UiLabelsService } from '@forgeroute/ui/core';\n\ninterface EmailBlock {\n id: string;\n html: string;\n spacing?: string;\n}\n\ninterface AssignmentView extends EmailTemplateAssignmentOption {\n assigned: boolean;\n}\n\ntype EditorTab = 'edit' | 'preview' | 'mobile';\ntype RightTab = 'blocks' | 'variables' | 'video';\n\nconst FONT_SIZE_OPTIONS: SelectOption<string>[] = ['10', '12', '14', '16', '18', '20', '24', '28', '32', '36'].map(n => ({ value: `${n}px`, label: `${n}px` }));\n/** The space above and below a block: the pill key is the CSS length (the stored value), 'none' = no extra space. */\n/** The block's own vertical padding in the editor (px); a block spacing is added to it so every step is visible, never replaces it. */\nconst BLOCK_BASE_PADDING_PX = 12;\n\n/** Shows a block spacing in the editor: extra space above and below the block's text (the sent email wraps the block in the same padding). */\nfunction setEditorSpacing(el: HTMLElement, spacing: string | undefined): void {\n el.style.paddingTop = spacing ? `calc(${BLOCK_BASE_PADDING_PX}px + ${spacing})` : '';\n el.style.paddingBottom = spacing ? `calc(${BLOCK_BASE_PADDING_PX}px + ${spacing})` : '';\n}\n\nconst DEFAULT_VIDEO_LINK: EmailTemplateVideoLinkFn = video => video.shareLink;\nconst EMPTY_VIDEO_DEFAULTS: EmailTemplateVideoDefaults = { autoplay: false, caption: '', ctaType: '', ctaUrl: '', ctaLabel: '', hideReactions: false };\n\n/**\n * `ui-email-template-editor` - the full-page, block-based email template editor (details, assignments, block canvas with drag and drop,\n * rich-text toolbar, preview / mobile preview, content blocks, merge variables, video library, test send).\n *\n * The component owns the editing behaviour and holds no HTTP: the host loads the template (`[template]`), supplies what differs per app\n * (`categories`, `assignmentOptions`, `variableGroups`, `blockGroups`, `videos`, `videoDefaults`, `maxBodyLength`, permissions) and reacts to\n * `(save)`, `(testSend)`, `(videosRequested)` and `(useAsMine)`. After a request the host calls back:\n * `markSaved(id)` (a create succeeded) and `closeTestSend()`.\n *\n * Message limit: `maxBodyLength` is measured on the serialised HTML. An untouched stored body that is already longer than the limit is\n * accepted unchanged (legacy rows), exactly as the server does.\n */\n@Component({\n selector: 'ui-email-template-editor',\n standalone: true,\n changeDetection: ChangeDetectionStrategy.OnPush,\n imports: [\n FormsModule, AlertComponent, ButtonComponent, CheckboxComponent, DateInputComponent, DividerComponent, EmptyStateComponent, ErrorComponent, PillTabsComponent, RadioGroupComponent, SearchInputComponent,\n SelectComponent, SidePanelComponent, SkeletonComponent, TextInputComponent, TooltipDirective,\n ],\n template: `\n <div class=\"editor-page\">\n <!-- Actions (outside the white panels) -->\n <div class=\"editor-actions\">\n @if (heading()) {\n <h2 class=\"editor-heading\" data-testid=\"editor-heading\">{{ heading() }}</h2>\n }\n <div class=\"editor-actions-buttons\">\n @if (canWrite() && testSendEnabled()) {\n <ui-button variant=\"secondary\" size=\"sm\" (click)=\"openTestSendDialog()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"22\" y1=\"2\" x2=\"11\" y2=\"13\"/><polygon points=\"22 2 15 22 11 13 2 9 22 2\"/></svg>{{ labels.t('emailTemplateEditor.testSend') }}</ui-button>\n }\n <span class=\"save-wrap\" [uiTooltip]=\"saveHint()\">\n <ui-button variant=\"primary\" size=\"sm\" [loading]=\"saving()\" [disabled]=\"saveDisabled()\" (click)=\"onSave()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z\"/><polyline points=\"17 21 17 13 7 13 7 21\"/><polyline points=\"7 3 7 8 15 8\"/></svg>{{ labels.t('emailTemplateEditor.saveTemplate') }}</ui-button>\n </span>\n </div>\n @if (saveHintVisible(); as hint) {\n <!-- A blocked Save explains itself in visible text, not only in the tooltip. -->\n <p class=\"save-hint\" role=\"status\" data-testid=\"save-hint\">{{ hint }}</p>\n }\n </div>\n <ui-divider />\n\n @if (systemTemplate()) {\n <div class=\"readonly-note system-note\" role=\"note\" data-testid=\"editor-system-note\">\n <span>{{ systemNote() }}</span>\n @if (canCopySystem()) {\n <ui-button variant=\"secondary\" size=\"sm\" data-testid=\"editor-use-as-mine\" (click)=\"useAsMine.emit()\">{{ labels.t('emailTemplateEditor.useAsMyTemplate') }}</ui-button>\n }\n </div>\n } @else if (!canWrite()) {\n <p class=\"readonly-note\" role=\"note\" data-testid=\"editor-readonly-note\">{{ readOnlyNote() }}</p>\n }\n\n <!-- 3-Column Layout -->\n <div class=\"editor-body\">\n <!-- LEFT PANEL: Details -->\n <aside class=\"panel-left\" [attr.aria-label]=\"labels.t('emailTemplateEditor.templateDetails')\">\n <h3 class=\"panel-title\">{{ labels.t('common.details') }}</h3>\n\n <div class=\"form-field\">\n <ui-text-input [label]=\"labels.t('common.name')\" [required]=\"true\" [(ngModel)]=\"name\" [readonly]=\"!canWrite()\" [maxlength]=\"maxTextLength()\"\n [placeholder]=\"namePlaceholder()\" [error]=\"nameErrorShown()\" [showErrors]=\"nameTouched()\" (blurred)=\"nameTouched.set(true)\" />\n </div>\n\n <div class=\"form-field\">\n <ui-text-input [label]=\"labels.t('common.subject')\" [required]=\"true\" [(ngModel)]=\"subject\" [readonly]=\"!canWrite()\" [maxlength]=\"maxTextLength()\"\n [placeholder]=\"subjectPlaceholder()\" [error]=\"subjectErrorShown()\" [showErrors]=\"subjectTouched()\" (blurred)=\"subjectTouched.set(true)\">\n </ui-text-input>\n </div>\n\n @if (showCategory()) {\n <div class=\"form-field\">\n <ui-select [label]=\"labels.t('emailTemplateEditor.category')\" [options]=\"categories()\" [placeholder]=\"categoryPlaceholder()\" [(ngModel)]=\"category\" [disabled]=\"!canWrite()\" />\n </div>\n }\n\n @if (showActiveRange()) {\n <ui-checkbox [label]=\"labels.t('emailTemplateEditor.useThisTemplateAllYear')\" [(checked)]=\"useAllYear\" [disabled]=\"!canWrite()\" />\n }\n\n @if (showActiveRange() && !useAllYear()) {\n <div class=\"form-row-dates\" (focusout)=\"datesTouched.set(true)\">\n <ui-date-input [label]=\"labels.t('emailTemplateEditor.activeFrom')\" [(ngModel)]=\"activeFrom\" [disabled]=\"!canWrite()\" />\n <ui-date-input [label]=\"labels.t('emailTemplateEditor.activeTo')\" [(ngModel)]=\"activeTo\" [disabled]=\"!canWrite()\" [min]=\"activeFrom()\" [error]=\"datesError()\" />\n </div>\n }\n\n <!-- Assignments -->\n @if (assignmentOptions().length > 0) {\n <div class=\"assignments-section\">\n <h4 class=\"section-title\">{{ labels.t('emailTemplateEditor.assignments') }}<span class=\"required\" aria-hidden=\"true\">*</span></h4>\n <p class=\"section-desc\">{{ assignmentsDescription() }}</p>\n <ui-error [errorId]=\"idPrefix() + '-assignments-error'\" [message]=\"assignmentErrorShown()\" />\n <ui-search-input [placeholder]=\"labels.t('common.searchellipsis')\" [ariaLabel]=\"labels.t('emailTemplateEditor.searchAssignments')\" [(value)]=\"assignmentSearch\" />\n @if (filteredAssignments().length === 0) {\n <ui-empty-state iconType=\"search\" [title]=\"labels.t('emailTemplateEditor.noAssignmentsFound')\" [message]=\"labels.t('emailTemplateEditor.noAssignmentsMatchYourSearch')\" />\n }\n <div class=\"assignment-list\" [hidden]=\"filteredAssignments().length === 0\" (focusout)=\"onAssignmentsFocusOut($event)\">\n @for (item of filteredAssignments(); track item.key) {\n <div class=\"assignment-item\" [class.assignment-readonly]=\"!canWrite()\" [attr.role]=\"canWrite() ? 'switch' : null\" [attr.tabindex]=\"canWrite() ? 0 : null\"\n [attr.aria-checked]=\"canWrite() ? item.assigned : null\" [attr.aria-label]=\"canWrite() ? item.name : null\"\n (click)=\"toggleAssignment(item)\" (keydown.enter)=\"toggleAssignment(item); $event.preventDefault()\" (keydown.space)=\"toggleAssignment(item); $event.preventDefault()\">\n <div class=\"assignment-text\">\n <strong>{{ item.name }}</strong>\n <span>{{ item.description }}</span>\n </div>\n <div class=\"assignment-channels\">\n <span class=\"channel-badge\" [class.active]=\"item.assigned\" role=\"img\" [attr.aria-label]=\"item.assigned ? labels.t('emailTemplateEditor.emailOn') : labels.t('emailTemplateEditor.emailOff')\">\n <svg width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"2\" y=\"4\" width=\"20\" height=\"16\" rx=\"2\"/><path d=\"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7\"/></svg>\n </span>\n </div>\n </div>\n }\n </div>\n </div>\n }\n </aside>\n\n <!-- CENTER: Editor -->\n <section class=\"panel-center\" [attr.aria-label]=\"labels.t('emailTemplateEditor.emailDesign')\">\n <div class=\"editor-tabs\" role=\"tablist\" [attr.aria-label]=\"labels.t('emailTemplateEditor.editorView')\">\n <button type=\"button\" class=\"editor-tab\" role=\"tab\" [class.active]=\"activeEditorTab() === 'edit'\" [attr.aria-selected]=\"activeEditorTab() === 'edit'\" (click)=\"setEditorTab('edit')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z\"/></svg>{{ labels.t('common.edit') }}</button>\n <button type=\"button\" class=\"editor-tab\" role=\"tab\" [class.active]=\"activeEditorTab() === 'preview'\" [attr.aria-selected]=\"activeEditorTab() === 'preview'\" (click)=\"setEditorTab('preview')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z\"/><circle cx=\"12\" cy=\"12\" r=\"3\"/></svg>{{ labels.t('common.preview') }}</button>\n <button type=\"button\" class=\"editor-tab\" role=\"tab\" [class.active]=\"activeEditorTab() === 'mobile'\" [attr.aria-selected]=\"activeEditorTab() === 'mobile'\" (click)=\"setEditorTab('mobile')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"5\" y=\"2\" width=\"14\" height=\"20\" rx=\"2\" ry=\"2\"/><line x1=\"12\" y1=\"18\" x2=\"12.01\" y2=\"18\"/></svg>{{ labels.t('common.mobile') }}</button>\n </div>\n\n @if (activeEditorTab() === 'edit') {\n @if (canWrite()) {\n <!-- Toolbar row 1: mousedown preventDefault keeps focus (and the selection) in the editor -->\n <div class=\"editor-toolbar\" role=\"toolbar\" [attr.aria-label]=\"labels.t('emailTemplateEditor.textFormatting')\" (mousedown)=\"preventFocusLoss($event)\">\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.bold')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipBold')\" (click)=\"execCommand('bold')\"><strong>B</strong></ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.italic')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipItalic')\" (click)=\"execCommand('italic')\"><em>I</em></ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.underline')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipUnderline')\" (click)=\"execCommand('underline')\"><u>U</u></ui-button>\n </div>\n <div class=\"toolbar-group\">\n @for (k of [headingKey()]; track k) {\n <ui-select class=\"toolbar-select\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.headingLevel')\" [options]=\"headingOptions\" ngModel=\"p\"\n (mousedown)=\"saveSelection()\" (ngModelChange)=\"onHeading($event)\" />\n }\n </div>\n <div class=\"toolbar-group\">\n @for (k of [sizeKey()]; track k) {\n <ui-select class=\"toolbar-select\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.fontSize')\" [placeholder]=\"labels.t('emailTemplateEditor.size')\" [options]=\"fontSizeOptions\" ngModel=\"\"\n (mousedown)=\"saveSelection()\" (ngModelChange)=\"onFontSize($event)\" />\n }\n </div>\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.alignLeft')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipAlignLeft')\" (click)=\"execCommand('justifyLeft')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"17\" y1=\"10\" x2=\"3\" y2=\"10\"/><line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"21\" y1=\"14\" x2=\"3\" y2=\"14\"/><line x1=\"17\" y1=\"18\" x2=\"3\" y2=\"18\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.alignCenter')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipAlignCenter')\" (click)=\"execCommand('justifyCenter')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"18\" y1=\"10\" x2=\"6\" y2=\"10\"/><line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"21\" y1=\"14\" x2=\"3\" y2=\"14\"/><line x1=\"18\" y1=\"18\" x2=\"6\" y2=\"18\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.alignRight')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipAlignRight')\" (click)=\"execCommand('justifyRight')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"21\" y1=\"10\" x2=\"7\" y2=\"10\"/><line x1=\"21\" y1=\"6\" x2=\"3\" y2=\"6\"/><line x1=\"21\" y1=\"14\" x2=\"3\" y2=\"14\"/><line x1=\"21\" y1=\"18\" x2=\"7\" y2=\"18\"/></svg>\n </ui-button>\n </div>\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.bulletedList')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipBulletedList')\" (click)=\"execCommand('insertUnorderedList')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"8\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"8\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"8\" y1=\"18\" x2=\"21\" y2=\"18\"/><line x1=\"3\" y1=\"6\" x2=\"3.01\" y2=\"6\"/><line x1=\"3\" y1=\"12\" x2=\"3.01\" y2=\"12\"/><line x1=\"3\" y1=\"18\" x2=\"3.01\" y2=\"18\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.numberedList')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipNumberedList')\" (click)=\"execCommand('insertOrderedList')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"10\" y1=\"6\" x2=\"21\" y2=\"6\"/><line x1=\"10\" y1=\"12\" x2=\"21\" y2=\"12\"/><line x1=\"10\" y1=\"18\" x2=\"21\" y2=\"18\"/><path d=\"M4 6h1v4\"/><path d=\"M4 10h2\"/><path d=\"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1\"/></svg>\n </ui-button>\n </div>\n <div class=\"toolbar-group\">\n <!-- The browser's own colour dialog is the picker; a button opens it so the toolbar keeps one look. -->\n <input #colorInput type=\"color\" class=\"hidden-color-input\" [attr.aria-label]=\"labels.t('emailTemplateEditor.textColor')\" tabindex=\"-1\" [value]=\"currentColor()\" (change)=\"applyTextColor($any($event.target).value)\" (mousedown)=\"$event.stopPropagation()\" />\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.textColor')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipTextColor')\" (mousedown)=\"openColorPicker()\">\n <span class=\"color-indicator\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\"><text y=\"20\" font-size=\"20\" font-weight=\"700\">A</text></svg>\n <span class=\"color-bar\" [style.background]=\"currentColor()\"></span>\n </span>\n </ui-button>\n </div>\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.insertLink')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipInsertLink')\" (mousedown)=\"saveSelection()\" (click)=\"openLinkDialog()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71\"/><path d=\"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.insertImage')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipInsertImage')\" (mousedown)=\"saveSelection()\" (click)=\"openImageDialog()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"3\" y=\"3\" width=\"18\" height=\"18\" rx=\"2\" ry=\"2\"/><circle cx=\"8.5\" cy=\"8.5\" r=\"1.5\"/><polyline points=\"21 15 16 10 5 21\"/></svg>\n </ui-button>\n </div>\n <div class=\"toolbar-group\">\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.undo')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipUndo')\" (click)=\"execCommand('undo')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M3 7v6h6\"/><path d=\"M21 17a9 9 0 0 0-9-9 9 9 0 0 0-6.69 3L3 13\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"sm\" [ariaLabel]=\"labels.t('emailTemplateEditor.redo')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipRedo')\" (click)=\"execCommand('redo')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M21 7v6h-6\"/><path d=\"M3 17a9 9 0 0 1 9-9 9 9 0 0 1 6.69 3L21 13\"/></svg>\n </ui-button>\n </div>\n </div>\n\n <!-- Toolbar row 2: block spacing -->\n <div class=\"toolbar-row-2\">\n <div class=\"toolbar-group\" (mousedown)=\"preventFocusLoss($event)\">\n <span class=\"toolbar-label\" id=\"tpl-spacing-label\">{{ labels.t('emailTemplateEditor.blockSpacing') }}</span>\n <ui-pill-tabs [tabs]=\"spacingTabs\" [activeKey]=\"blockSpacing() || 'none'\" [ariaLabel]=\"labels.t('emailTemplateEditor.blockSpacing')\" (tabChange)=\"applySpacing($event === 'none' ? '' : $event)\" />\n </div>\n </div>\n }\n\n <!-- Link dialog (inline popover) -->\n @if (canWrite() && showLinkDialog()) {\n <div class=\"link-dialog\" role=\"group\" [attr.aria-label]=\"labels.t('emailTemplateEditor.insertLink')\">\n <div class=\"link-dialog-inner\">\n <span class=\"link-dialog-title\">{{ labels.t('emailTemplateEditor.insertLink2') }}</span>\n <ui-text-input class=\"link-dialog-input\" [ariaLabel]=\"labels.t('emailTemplateEditor.linkAddress')\" placeholder=\"https://example.com\" [(ngModel)]=\"linkUrl\" [error]=\"linkUrlError()\" (keydown.enter)=\"insertLink()\" />\n @if (!linkTextFromSelection()) {\n <ui-text-input class=\"link-dialog-input\" [ariaLabel]=\"labels.t('emailTemplateEditor.linkText')\" [placeholder]=\"labels.t('emailTemplateEditor.linkTextOptional')\" [(ngModel)]=\"linkText\" (keydown.enter)=\"insertLink()\" />\n }\n <div class=\"link-dialog-actions\">\n <ui-button variant=\"secondary\" size=\"sm\" (click)=\"showLinkDialog.set(false)\">{{ labels.t('common.cancel') }}</ui-button>\n <ui-button variant=\"primary\" size=\"sm\" [disabled]=\"!canInsertLink()\" (click)=\"insertLink()\">{{ labels.t('common.insert') }}</ui-button>\n </div>\n </div>\n </div>\n }\n\n <!-- Image URL dialog -->\n @if (canWrite() && showImageDialog()) {\n <div class=\"link-dialog\" role=\"group\" [attr.aria-label]=\"labels.t('emailTemplateEditor.insertImage')\">\n <div class=\"link-dialog-inner\">\n <span class=\"link-dialog-title\">{{ labels.t('emailTemplateEditor.insertImage2') }}</span>\n @if (imageUpload()) {\n <input #imageFile type=\"file\" class=\"hidden-file-input\" accept=\"image/png,image/jpeg,image/webp,image/gif\" tabindex=\"-1\" [attr.aria-label]=\"labels.t('emailTemplateEditor.uploadImage')\" (change)=\"onImageFile($event)\" />\n <ui-button variant=\"secondary\" size=\"sm\" [loading]=\"imageUploading()\" (click)=\"imageFile.click()\">{{ imageUploading() ? labels.t('emailTemplateEditor.uploadingImage') : labels.t('emailTemplateEditor.uploadImage') }}</ui-button>\n <ui-error [errorId]=\"idPrefix() + '-image-upload-error'\" [message]=\"imageUploadError()\" />\n }\n <ui-text-input class=\"link-dialog-input\" [ariaLabel]=\"labels.t('emailTemplateEditor.imageAddress')\" placeholder=\"https://example.com/image.jpg\" [(ngModel)]=\"imageUrl\" [error]=\"imageUrlError()\" (keydown.enter)=\"insertImageFromUrl()\" />\n <ui-text-input class=\"link-dialog-input\" [ariaLabel]=\"labels.t('emailTemplateEditor.imageAltText')\" [placeholder]=\"labels.t('emailTemplateEditor.altTextOptional')\" [(ngModel)]=\"imageAlt\" (keydown.enter)=\"insertImageFromUrl()\" />\n <div class=\"link-dialog-actions\">\n <ui-button variant=\"secondary\" size=\"sm\" (click)=\"showImageDialog.set(false)\">{{ labels.t('common.cancel') }}</ui-button>\n <ui-button variant=\"primary\" size=\"sm\" [disabled]=\"!canInsertImage()\" (click)=\"insertImageFromUrl()\">{{ labels.t('common.insert') }}</ui-button>\n </div>\n </div>\n </div>\n }\n\n <ui-error [errorId]=\"idPrefix() + '-body-error'\" [message]=\"bodyErrorShown()\" />\n\n @if (canWrite() && checkMessages().length > 0) {\n <ui-alert class=\"email-checks\" variant=\"warning\" [compact]=\"true\" [title]=\"labels.t('emailTemplateEditor.checksTitle')\" data-testid=\"email-checks\">\n <ul class=\"email-checks-list\">\n @for (message of checkMessages(); track message) {\n <li>{{ message }}</li>\n }\n </ul>\n </ui-alert>\n }\n\n <!-- Block Canvas with DnD -->\n <div class=\"blocks-canvas\" (dragover)=\"onCanvasDragOver($event)\" (drop)=\"onDropZoneDrop($event, blocks().length)\" (focusout)=\"onBodyFocusOut($event)\">\n <!-- Initial drop zone (before first block) -->\n <div class=\"drop-zone\" [class.active]=\"dragOverIndex() === 0\" (dragover)=\"onDropZoneDragOver($event, 0)\" (dragleave)=\"onDropZoneLeave()\" (drop)=\"onDropZoneDrop($event, 0)\">\n <span class=\"drop-zone-label\">{{ labels.t('emailTemplateEditor.dropHere') }}</span>\n </div>\n\n @for (block of blocks(); track block.id; let i = $index) {\n <div class=\"block-wrapper\" #blockWrapper [class.selected]=\"selectedBlockId() === block.id\" [class.dragging]=\"dragFromCanvas() === i\" (dragend)=\"onBlockDragEnd()\">\n @if (canWrite()) {\n <!-- Only the handle is draggable: a draggable ancestor of the contenteditable breaks text selection in Firefox / Safari. Move up / down below are the keyboard and touch alternative. -->\n <div class=\"block-drag-handle\" [attr.title]=\"labels.t('emailTemplateEditor.dragToReorder')\" draggable=\"true\" (dragstart)=\"onBlockDragStart($event, i, blockWrapper)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\"><circle cx=\"9\" cy=\"6\" r=\"1.5\"/><circle cx=\"15\" cy=\"6\" r=\"1.5\"/><circle cx=\"9\" cy=\"12\" r=\"1.5\"/><circle cx=\"15\" cy=\"12\" r=\"1.5\"/><circle cx=\"9\" cy=\"18\" r=\"1.5\"/><circle cx=\"15\" cy=\"18\" r=\"1.5\"/></svg>\n </div>\n }\n\n <!-- Block content (contenteditable, initialised ONCE after render so Angular never rewrites it and the caret never jumps) -->\n <div #blockEditor class=\"block-content\" role=\"textbox\" aria-multiline=\"true\" [attr.aria-label]=\"labels.t('emailTemplateEditor.emailBlockN', { n: i + 1 })\"\n [attr.data-block-id]=\"block.id\" [attr.data-placeholder]=\"i === 0 ? startPlaceholder() : labels.t('emailTemplateEditor.clickToEdit')\" [attr.contenteditable]=\"canWrite() ? 'true' : 'false'\"\n (input)=\"onBlockInput($event, block)\" (beforeinput)=\"onBlockBeforeInput($any($event))\" (focus)=\"onBlockFocus(block)\" (click)=\"selectedBlockId.set(block.id)\"></div>\n\n @if (canWrite()) {\n <div class=\"block-controls\">\n <ui-button variant=\"ghost\" size=\"xs\" [ariaLabel]=\"labels.t('emailTemplateEditor.moveBlockUp')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipMoveUp')\" [disabled]=\"i === 0\" (mousedown)=\"preventFocusLoss($event)\" (click)=\"moveBlock(i, -1)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" aria-hidden=\"true\"><path d=\"M18 15l-6-6-6 6\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"xs\" [ariaLabel]=\"labels.t('emailTemplateEditor.moveBlockDown')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipMoveDown')\" [disabled]=\"i === blocks().length - 1\" (mousedown)=\"preventFocusLoss($event)\" (click)=\"moveBlock(i, 1)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2.5\" aria-hidden=\"true\"><path d=\"M6 9l6 6 6-6\"/></svg>\n </ui-button>\n <ui-button variant=\"ghost\" size=\"xs\" [ariaLabel]=\"labels.t('emailTemplateEditor.duplicateBlock')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipDuplicate')\" (mousedown)=\"preventFocusLoss($event)\" (click)=\"duplicateBlock(i)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"9\" y=\"9\" width=\"13\" height=\"13\" rx=\"2\"/><path d=\"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1\"/></svg>\n </ui-button>\n @if (blocks().length > 1) {\n <ui-button variant=\"ghost\" size=\"xs\" [ariaLabel]=\"labels.t('emailTemplateEditor.deleteBlock')\" [uiTooltip]=\"labels.t('emailTemplateEditor.tipDeleteBlock')\" (mousedown)=\"preventFocusLoss($event)\" (click)=\"deleteBlock(i)\">\n <svg width=\"12\" height=\"12\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><polyline points=\"3 6 5 6 21 6\"/><path d=\"M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6\"/><path d=\"M10 11v6M14 11v6\"/></svg>\n </ui-button>\n }\n </div>\n }\n </div>\n\n <!-- Drop zone after each block -->\n <div class=\"drop-zone\" [class.active]=\"dragOverIndex() === i + 1\" (dragover)=\"onDropZoneDragOver($event, i + 1)\" (dragleave)=\"onDropZoneLeave()\" (drop)=\"onDropZoneDrop($event, i + 1)\">\n <span class=\"drop-zone-label\">{{ labels.t('emailTemplateEditor.dropHere') }}</span>\n </div>\n }\n\n @if (canWrite()) {\n <button type=\"button\" class=\"add-block-btn\" (click)=\"addBlock('text-block')\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><line x1=\"12\" y1=\"5\" x2=\"12\" y2=\"19\"/><line x1=\"5\" y1=\"12\" x2=\"19\" y2=\"12\"/></svg>{{ labels.t('emailTemplateEditor.addBlock') }}</button>\n }\n </div>\n }\n\n @if (activeEditorTab() === 'preview') {\n <div class=\"preview-frame\">\n <iframe class=\"preview-content\" [attr.title]=\"labels.t('emailTemplateEditor.emailPreview')\" sandbox=\"\" referrerpolicy=\"no-referrer\" [srcdoc]=\"previewDoc()\"></iframe>\n </div>\n }\n\n @if (activeEditorTab() === 'mobile') {\n <div class=\"preview-frame mobile\">\n <div class=\"mobile-shell\">\n <iframe class=\"preview-content\" [attr.title]=\"labels.t('emailTemplateEditor.mobileEmailPreview')\" sandbox=\"\" referrerpolicy=\"no-referrer\" [srcdoc]=\"previewDoc()\"></iframe>\n </div>\n </div>\n }\n </section>\n\n <!-- RIGHT PANEL: Blocks, Variables, Video (the word video appears only while the Video tab is on) -->\n <aside class=\"panel-right\" [attr.aria-label]=\"videosEnabled() ? labels.t('emailTemplateEditor.rightPanelWithVideo') : labels.t('emailTemplateEditor.rightPanel')\">\n @if (!canWrite()) {\n <div class=\"right-panel-body\" data-testid=\"tpl-readonly-tools-note\">\n <h4 class=\"right-section-title\">{{ labels.t('emailTemplateEditor.readOnly') }}</h4>\n <p class=\"right-section-hint\">{{ videosEnabled() ? labels.t('emailTemplateEditor.readOnlyToolsWithVideo') : labels.t('emailTemplateEditor.readOnlyTools') }}</p>\n </div>\n } @else {\n <div class=\"right-tabs\" role=\"tablist\" [attr.aria-label]=\"labels.t('emailTemplateEditor.rightPanelSections')\">\n <button type=\"button\" class=\"right-tab\" role=\"tab\" [class.active]=\"activeRightTab() === 'blocks'\" [attr.aria-selected]=\"activeRightTab() === 'blocks'\" (click)=\"activeRightTab.set('blocks')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><rect x=\"3\" y=\"3\" width=\"7\" height=\"7\"/><rect x=\"14\" y=\"3\" width=\"7\" height=\"7\"/><rect x=\"14\" y=\"14\" width=\"7\" height=\"7\"/><rect x=\"3\" y=\"14\" width=\"7\" height=\"7\"/></svg>{{ labels.t('emailTemplateEditor.blocks') }}</button>\n <button type=\"button\" class=\"right-tab\" role=\"tab\" [class.active]=\"activeRightTab() === 'variables'\" [attr.aria-selected]=\"activeRightTab() === 'variables'\" (click)=\"activeRightTab.set('variables')\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M12 3v18M3 12h18\"/></svg>{{ labels.t('emailTemplateEditor.variables') }}</button>\n @if (videosEnabled()) {\n <button type=\"button\" class=\"right-tab\" role=\"tab\" [class.active]=\"activeRightTab() === 'video'\" [attr.aria-selected]=\"activeRightTab() === 'video'\" (click)=\"openVideoTab()\">\n <svg width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><polygon points=\"23 7 16 12 23 17 23 7\"/><rect x=\"1\" y=\"5\" width=\"15\" height=\"14\" rx=\"2\" ry=\"2\"/></svg>{{ labels.t('common.video') }}</button>\n }\n </div>\n\n @if (activeRightTab() === 'blocks') {\n <div class=\"right-panel-body\">\n <h4 class=\"right-section-title\">{{ labels.t('emailTemplateEditor.contentBlocks') }}</h4>\n <p class=\"right-section-desc\">{{ labels.t('emailTemplateEditor.clickToInsertOrDrag') }}</p>\n <ui-search-input [placeholder]=\"labels.t('emailTemplateEditor.searchBlocks')\" [ariaLabel]=\"labels.t('emailTemplateEditor.searchBlocks2')\" [(value)]=\"blockSearch\" />\n\n @if (filteredBlockGroups().length === 0) {\n <ui-empty-state iconType=\"search\" [title]=\"labels.t('emailTemplateEditor.noBlocksFound')\" [message]=\"labels.t('emailTemplateEditor.noBlocksMatchYourSearch')\" />\n }\n @for (group of filteredBlockGroups(); track group.name) {\n <div class=\"block-group\">\n <button type=\"button\" class=\"block-group-header\" [attr.aria-expanded]=\"isOpen('b:' + group.name)\" (click)=\"toggleGroup('b:' + group.name)\">\n <svg class=\"chevron\" [class.expanded]=\"isOpen('b:' + group.name)\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M9 18l6-6-6-6\"/></svg>\n <span>{{ group.name }}</span>\n <span class=\"block-count\">{{ group.blocks.length }}</span>\n </button>\n @if (isOpen('b:' + group.name)) {\n <div class=\"block-list\">\n @for (block of group.blocks; track block.key) {\n <!-- A div, not a button: Firefox does not start a drag from a <button>. Role, tabindex and Enter / Space keep it a keyboard control; a click inserts the block. -->\n <div role=\"button\" tabindex=\"0\" class=\"block-item\" draggable=\"true\" [attr.aria-label]=\"labels.t('emailTemplateEditor.insertNamed', { name: block.label })\"\n (dragstart)=\"onPaletteDragStart($event, block)\" (dragend)=\"onBlockDragEnd()\" (click)=\"insertBlock(block)\"\n (keydown.enter)=\"insertBlock(block); $event.preventDefault()\" (keydown.space)=\"insertBlock(block); $event.preventDefault()\">\n <svg class=\"block-item-drag\" width=\"10\" height=\"10\" viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden=\"true\"><circle cx=\"9\" cy=\"6\" r=\"1.5\"/><circle cx=\"15\" cy=\"6\" r=\"1.5\"/><circle cx=\"9\" cy=\"12\" r=\"1.5\"/><circle cx=\"15\" cy=\"12\" r=\"1.5\"/><circle cx=\"9\" cy=\"18\" r=\"1.5\"/><circle cx=\"15\" cy=\"18\" r=\"1.5\"/></svg>\n {{ block.label }}\n </div>\n }\n </div>\n }\n </div>\n }\n </div>\n }\n\n @if (activeRightTab() === 'variables') {\n <div class=\"right-panel-body\">\n <h4 class=\"right-section-title\">{{ labels.t('emailTemplateEditor.templateVariables') }}</h4>\n <p class=\"right-section-desc\">{{ labels.t('emailTemplateEditor.clickAVariableToInsert') }}</p>\n\n @for (group of variableGroups(); track group.name) {\n <div class=\"block-group\">\n <button type=\"button\" class=\"block-group-header\" [attr.aria-expanded]=\"isOpen('v:' + group.name)\" (click)=\"toggleGroup('v:' + group.name)\">\n <svg class=\"chevron\" [class.expanded]=\"isOpen('v:' + group.name)\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><path d=\"M9 18l6-6-6-6\"/></svg>\n <span>{{ group.name }}</span>\n <span class=\"block-count\">{{ group.variables.length }}</span>\n </button>\n @if (isOpen('v:' + group.name)) {\n <div class=\"variable-list\">\n @for (v of group.variables; track v.key) {\n <button type=\"button\" class=\"variable-item\" (mousedown)=\"saveSelection()\" (click)=\"insertVariable(v)\">\n <span class=\"var-tag\">{{ '{{' + v.key + '}}' }}</span>\n <span class=\"var-example\">{{ labels.t('emailTemplateEditor.example', { example: v.example }) }}</span>\n <!-- A very short explanation of what the variable is: the host's description, else its label. -->\n <span class=\"var-description\">{{ v.description || v.label }}</span>\n </button>\n }\n </div>\n }\n </div>\n }\n </div>\n }\n\n @if (activeRightTab() === 'video' && videosEnabled()) {\n <div class=\"right-panel-body video-library-panel\">\n <h4 class=\"right-section-title\">{{ labels.t('emailTemplateEditor.videoLibrary') }}</h4>\n <p class=\"right-section-hint\">{{ labels.t('emailTemplateEditor.clickAVideoToAdd') }}</p>\n\n <div class=\"video-config-section\">\n <ui-radio-group [label]=\"labels.t('emailTemplateEditor.playback')\" orientation=\"horizontal\" [options]=\"playbackOptions\" [ngModel]=\"videoAutoplay() ? 'autoplay' : 'click'\" (ngModelChange)=\"videoAutoplay.set($event === 'autoplay')\" />\n </div>\n <div class=\"video-config-section\">\n <ui-text-input [label]=\"labels.t('emailTemplateEditor.caption')\" [placeholder]=\"labels.t('emailTemplateEditor.eGClickToWatch')\" [maxlength]=\"200\" [(ngModel)]=\"videoCaption\" />\n </div>\n <div class=\"video-config-section\">\n <ui-select [label]=\"labels.t('emailTemplateEditor.callToAction')\" [options]=\"ctaTypeOptions\" [(ngModel)]=\"videoCtaType\" />\n @if (videoCtaType()) {\n <ui-text-input [ariaLabel]=\"labels.t('emailTemplateEditor.callToActionAddress')\" type=\"url\" placeholder=\"https://...\" [(ngModel)]=\"videoCtaUrl\" />\n <ui-text-input [ariaLabel]=\"labels.t('emailTemplateEditor.callToActionButtonLabel')\" [placeholder]=\"labels.t('emailTemplateEditor.buttonLabel')\" [maxlength]=\"100\" [(ngModel)]=\"videoCtaLabel\" />\n }\n </div>\n <div class=\"video-config-section\">\n <ui-checkbox [label]=\"labels.t('emailTemplateEditor.hideReactions')\" [(checked)]=\"videoHideReactions\" />\n </div>\n\n @if (videosLoading()) {\n <div class=\"video-lib-loading\" role=\"status\" aria-busy=\"true\" [attr.aria-label]=\"labels.t('emailTemplateEditor.loadingVideos')\">\n @for (n of [1, 2, 3]; track n) {\n <div class=\"video-lib-skeleton\">\n <ui-skeleton [height]=\"40\" width=\"56px\" [radius]=\"6\" />\n <div class=\"vls-info\"><ui-skeleton [height]=\"10\" width=\"75%\" [radius]=\"5\" /><ui-skeleton [height]=\"10\" width=\"45%\" [radius]=\"5\" /></div>\n </div>\n }\n </div>\n } @else if (videoList().length === 0) {\n <ui-empty-state iconType=\"video\" [title]=\"labels.t('emailTemplateEditor.noVideosCreated')\" [message]=\"noVideosHint()\" />\n } @else {\n <div class=\"video-lib-list\">\n @for (video of videoList(); track video.id) {\n <button type=\"button\" class=\"video-lib-item\" [class.selected]=\"video.id === videoId()\" [attr.aria-pressed]=\"video.id === videoId()\" (click)=\"insertVideo(video)\">\n <span class=\"vli-thumb\">\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#94a3b8\" stroke-width=\"1.5\" aria-hidden=\"true\"><polygon points=\"5 3 19 12 5 21 5 3\"/></svg>\n @if (video.durationSeconds) {\n <span class=\"vli-dur\">{{ formatDuration(video.durationSeconds) }}</span>\n }\n </span>\n <span class=\"vli-info\">\n <span class=\"vli-title\">{{ video.title }}</span>\n <span class=\"vli-cat\">{{ categoryLabel(video.category) }}</span>\n </span>\n @if (video.id === videoId()) {\n <svg class=\"vli-check\" width=\"14\" height=\"14\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"#2563eb\" stroke-width=\"2.5\" aria-hidden=\"true\"><polyline points=\"20 6 9 17 4 12\"/></svg>\n }\n </button>\n }\n </div>\n }\n </div>\n }\n }\n </aside>\n </div>\n </div>\n\n <!-- Test Send -->\n <ui-side-panel [open]=\"showTestSendDialog()\" [title]=\"labels.t('emailTemplateEditor.sendTestEmail')\" [primaryLabel]=\"labels.t('emailTemplateEditor.sendTest')\" [primaryLoading]=\"testSending()\" [primaryDisabled]=\"!canSendTest()\"\n (closed)=\"showTestSendDialog.set(false)\" (primaryClick)=\"onTestSend()\">\n <p class=\"config-desc\">{{ labels.t('emailTemplateEditor.sendThisTemplateToAn') }}</p>\n @if (!editingId()) {\n <div class=\"test-save-note\">\n <svg width=\"16\" height=\"16\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" aria-hidden=\"true\"><circle cx=\"12\" cy=\"12\" r=\"10\"/><line x1=\"12\" y1=\"8\" x2=\"12\" y2=\"12\"/><line x1=\"12\" y1=\"16\" x2=\"12.01\" y2=\"16\"/></svg>{{ labels.t('emailTemplateEditor.saveTheTemplateFirstBefore') }}</div>\n }\n <div class=\"config-field config-field-mt\">\n <ui-text-input [label]=\"labels.t('emailTemplateEditor.recipientEmail')\" type=\"email\" placeholder=\"you@example.com\" [(ngModel)]=\"testSendEmail\" [error]=\"testEmailError()\" (keydown.enter)=\"onTestSend()\" />\n </div>\n @if (hasUnsavedChanges()) {\n <div class=\"test-save-note\" role=\"note\" data-testid=\"test-unsaved-note\">{{ labels.t('emailTemplateEditor.youHaveUnsavedChangesThe') }}</div>\n }\n </ui-side-panel>\n\n\n `,\n styles: [`\n /* The editor fills the height its parent gives it (in an app shell: the content area down to the bottom of the viewport), and the panels\n scroll inside it, so the page itself never scrolls. */\n :host { display: flex; flex-direction: column; flex: 1; min-height: 0; }\n .required { color: #ef4444; font-weight: 400; }\n\n .editor-page {\n display: flex; flex-direction: column; flex: 1; min-height: 0;\n background: #f8fafc; overflow: hidden;\n }\n\n /* ─── Actions row (on the page background, above the panels) ─── */\n .editor-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; padding: 0 0 12px; flex-shrink: 0; }\n .editor-heading { margin: 0; font-size: 1.25rem; font-weight: 700; color: #1e293b; line-height: 1.3; min-width: 0; }\n .save-wrap { display: inline-flex; }\n .save-hint { margin: 0; font-size: 12px; color: #475569; flex-basis: 100%; text-align: right; }\n .editor-actions-buttons { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-left: auto; }\n\n .readonly-note { margin: 0; padding: 8px 16px; font-size: 0.8125rem; color: #92400e; background: #fffbeb; border-bottom: 1px solid #fde68a; }\n .readonly-note.system-note { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }\n\n /* ─── 3-column body ─── */\n .editor-body { display: grid; grid-template-columns: 340px minmax(0, 1fr) 300px; grid-template-rows: minmax(0, 1fr); flex: 1; min-height: 0; overflow: hidden; }\n\n /* ─── Left panel ─── */\n .panel-left { background: #fff; border-right: 1px solid #e2e8f0; padding: 24px; overflow-y: auto; }\n .panel-title { font-size: 1.0625rem; font-weight: 700; color: #1e293b; margin: 0 0 20px; }\n .form-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }\n .form-row-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 16px; }\n .email-checks { margin: 8px 12px 0; }\n .email-checks-list { margin: 0; padding-left: 18px; }\n .hidden-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }\n .assignments-section { border-top: 1px solid #e2e8f0; padding-top: 20px; margin-top: 16px; }\n .section-title { font-size: 0.9375rem; font-weight: 700; color: #1e293b; margin: 0 0 6px; }\n .section-desc { font-size: 0.8125rem; color: #64748b; line-height: 1.5; margin: 0 0 12px; }\n .assignment-list { max-height: 340px; overflow-y: auto; margin-top: 12px; border: 1px solid #e2e8f0; border-radius: 8px; }\n .assignment-item { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; cursor: pointer; border-bottom: 1px solid #f1f5f9; transition: background 0.1s; }\n .assignment-item:last-child { border-bottom: none; }\n .assignment-item:hover { background: #f8fafc; }\n .assignment-item:focus-visible { outline: 2px solid #3b82f6; outline-offset: -2px; }\n .assignment-item.assignment-readonly { cursor: default; }\n .assignment-item.assignment-readonly:hover { background: transparent; }\n .assignment-text { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }\n .assignment-text strong { font-size: 0.8125rem; color: #1e293b; }\n .assignment-text span { font-size: 0.75rem; color: #64748b; }\n .assignment-channels { display: flex; gap: 4px; flex-shrink: 0; }\n .channel-badge { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 4px; background: #f1f5f9; color: #64748b; transition: all 0.15s; }\n .channel-badge.active { background: #3b82f6; color: #fff; }\n .channel-badge.disabled { opacity: 0.4; cursor: not-allowed; }\n\n /* ─── Side-panel content ─── */\n .config-desc { font-size: 0.875rem; color: #64748b; line-height: 1.5; margin: 0; }\n .config-divider { border: none; border-top: 1px solid #e2e8f0; margin: 20px 0; }\n .config-section { display: flex; flex-direction: column; gap: 12px; }\n .config-section-label { font-size: 0.6875rem; font-weight: 700; color: #3b82f6; text-transform: uppercase; letter-spacing: 0.04em; }\n .config-field { display: flex; flex-direction: column; gap: 6px; }\n .config-field-mt { margin-top: 16px; }\n .config-label { font-size: 0.8125rem; font-weight: 600; color: #1e293b; }\n .config-readonly { padding: 9px 12px; border: 1px solid #e2e8f0; border-radius: 8px; background: #f8fafc; font-size: 0.875rem; color: #1e293b; }\n .config-hint { font-size: 0.75rem; color: #64748b; }\n .test-save-note { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: #fef3c7; border: 1px solid #fcd34d; border-radius: 8px; font-size: 0.8125rem; color: #92400e; margin-top: 12px; }\n .test-save-note svg { flex-shrink: 0; }\n\n /* ─── Center panel ─── */\n .panel-center { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; }\n .editor-tabs { display: flex; gap: 2px; padding: 12px 20px 0; background: #fff; border-bottom: 1px solid #e2e8f0; overflow-x: auto; -webkit-overflow-scrolling: touch; }\n .editor-tab { display: flex; align-items: center; gap: 6px; padding: 10px 16px; border: 1px solid #e2e8f0; border-bottom: none; border-radius: 8px 8px 0 0; background: #f8fafc; font-size: 0.8125rem; font-weight: 600; color: #64748b; cursor: pointer; font-family: inherit; white-space: nowrap; }\n .editor-tab:hover { background: #fff; color: #1e293b; }\n .editor-tab.active { background: #eff6ff; color: #1d4ed8; border-color: #93c5fd; }\n .editor-tab:focus-visible, .right-tab:focus-visible, .block-group-header:focus-visible, .variable-item:focus-visible, .add-block-btn:focus-visible, .block-item:focus-visible, .video-lib-item:focus-visible { outline: 2px solid #3b82f6; outline-offset: -2px; }\n\n .editor-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 20px; background: #fff; border-bottom: 1px solid #e2e8f0; flex-wrap: wrap; }\n .toolbar-row-2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 20px; background: #fff; border-bottom: 1px solid #e2e8f0; }\n .toolbar-group { display: flex; align-items: center; gap: 2px; padding-right: 8px; border-right: 1px solid #e2e8f0; }\n .toolbar-group:last-child { border-right: none; padding-right: 0; }\n .toolbar-select { display: block; min-width: 96px; }\n .toolbar-label { font-size: 0.75rem; font-weight: 600; color: #64748b; white-space: nowrap; margin-right: 6px; }\n .hidden-color-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; border: none; padding: 0; }\n .color-indicator { display: flex; flex-direction: column; align-items: center; gap: 2px; color: #475569; }\n .color-bar { display: block; width: 16px; height: 3px; border-radius: 2px; border: 1px solid rgba(0,0,0,0.1); }\n\n .link-dialog { background: #fff; border-bottom: 1px solid #e2e8f0; padding: 12px 20px; }\n .link-dialog-inner { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }\n .link-dialog-title { font-size: 0.8125rem; font-weight: 700; color: #1e293b; white-space: nowrap; padding-top: 10px; }\n .link-dialog-input { display: block; width: 240px; max-width: 100%; }\n .link-dialog-actions { display: flex; gap: 6px; }\n\n /* ─── Preview ─── */\n .preview-frame { flex: 1; display: flex; justify-content: center; align-items: stretch; padding: 24px; overflow-y: auto; background: #f1f5f9; }\n .preview-frame.mobile { align-items: flex-start; }\n /* The preview is a sandboxed document (no scripts, no popups): the email's own inline styles show exactly as they will be sent. */\n .preview-content { display: block; flex: 1 1 auto; max-width: 600px; width: 100%; box-sizing: border-box; min-height: 400px; background: #fff; border: 1px solid #e2e8f0; border-radius: 8px; }\n .mobile-shell { width: 375px; max-width: 100%; box-sizing: border-box; min-height: 600px; border: 2px solid #1e293b; border-radius: 24px; padding: 40px 12px 24px; background: #fff; box-shadow: 0 8px 32px rgba(0,0,0,0.12); }\n .mobile-shell .preview-content { border: none; border-radius: 0; max-width: 100%; height: 520px; min-height: 0; }\n\n /* ─── Block canvas ─── */\n .blocks-canvas { flex: 1 1 0; min-height: 0; padding: 16px 20px 24px 56px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; background: #f1f5f9; display: flex; flex-direction: column; }\n .block-wrapper { flex-shrink: 0; position: relative; display: flex; align-items: flex-start; background: #fff; border: 2px solid transparent; border-radius: 8px; transition: border-color 0.15s, box-shadow 0.15s; }\n .block-wrapper:hover, .block-wrapper.selected, .block-wrapper:focus-within { border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.1); }\n .block-wrapper:hover .block-drag-handle, .block-wrapper.selected .block-drag-handle, .block-wrapper:focus-within .block-drag-handle { opacity: 1; }\n .block-wrapper:hover .block-controls, .block-wrapper.selected .block-controls, .block-wrapper:focus-within .block-controls { opacity: 1; pointer-events: all; }\n .block-wrapper.dragging { opacity: 0.4; }\n .block-drag-handle { flex-shrink: 0; width: 28px; display: flex; align-items: flex-start; justify-content: center; padding-top: 14px; opacity: 0; transition: opacity 0.15s; cursor: grab; color: #94a3b8; }\n .block-drag-handle:active { cursor: grabbing; }\n .block-content { flex: 1; min-width: 0; padding: 12px 16px; outline: none; font-size: 0.9375rem; color: #1e293b; line-height: 1.6; min-height: 48px; overflow-wrap: anywhere; }\n .block-content:empty::before { content: attr(data-placeholder); color: #64748b; font-style: italic; pointer-events: none; }\n .block-content p { margin: 0 0 8px; }\n .block-content p:last-child { margin: 0; }\n .block-content h1, .block-content h2, .block-content h3 { margin: 8px 0 6px; color: #1e293b; }\n .block-content a { color: #3b82f6; }\n .block-content img { max-width: 100%; border-radius: 6px; }\n .block-content ul, .block-content ol { padding-left: 20px; margin: 0 0 8px; }\n .block-controls { position: absolute; top: 0; left: -48px; flex-direction: column; display: flex; gap: 2px; opacity: 0; pointer-events: none; transition: opacity 0.15s; background: #fff; border: 1px solid #e2e8f0; border-radius: 6px; padding: 3px; box-shadow: 0 2px 6px rgba(0,0,0,0.08); }\n @media (pointer: coarse) { .editor-tab, .right-tab, .block-group-header { min-height: 44px; } }\n @media (hover: none) { .block-wrapper.selected .block-controls { opacity: 1; pointer-events: all; } }\n\n .drop-zone { flex-shrink: 0; height: 8px; display: flex; align-items: center; justify-content: center; border-radius: 4px; transition: height 0.15s, background 0.15s; position: relative; }\n .drop-zone-label { font-size: 0.75rem; font-weight: 600; color: #1d4ed8; opacity: 0; transition: opacity 0.1s; }\n .drop-zone.active { height: 40px; background: rgba(59,130,246,0.08); border: 2px dashed #3b82f6; }\n .drop-zone.active .drop-zone-label { opacity: 1; }\n .add-block-btn { flex-shrink: 0; display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 44px; padding: 12px; margin-top: 8px; border: 2px dashed #e2e8f0; border-radius: 8px; background: none; font-size: 0.875rem; font-weight: 600; color: #475569; cursor: pointer; font-family: inherit; transition: border-color 0.15s, color 0.15s, background 0.15s; }\n .add-block-btn:hover { border-color: #3b82f6; color: #3b82f6; background: rgba(59,130,246,0.04); }\n\n /* ─── Right panel ─── */\n .panel-right { background: #fff; border-left: 1px solid #e2e8f0; display: flex; flex-direction: column; min-height: 0; min-width: 0; }\n .right-tabs { display: flex; border-bottom: 1px solid #e2e8f0; }\n .right-tab { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; min-height: 44px; border: none; background: none; font-size: 0.8125rem; font-weight: 600; color: #64748b; cursor: pointer; font-family: inherit; border-bottom: 2px solid transparent; }\n .right-tab:hover { color: #1e293b; }\n .right-tab.active { color: #1d4ed8; background: #eff6ff; border-bottom-color: #3b82f6; }\n .right-panel-body { flex: 1; padding: 20px; overflow-y: auto; }\n .right-section-title { font-size: 0.9375rem; font-weight: 700; color: #1e293b; margin: 0 0 12px; }\n .right-section-desc { font-size: 0.8125rem; color: #64748b; margin: 0 0 16px; line-height: 1.5; }\n .right-section-hint { font-size: 0.8125rem; color: #64748b; margin: 0 0 12px; line-height: 1.5; }\n .block-group { border-bottom: 1px solid #f1f5f9; }\n .block-group-header { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 44px; padding: 12px 0; border: none; background: none; font-size: 0.875rem; font-weight: 600; color: #1e293b; cursor: pointer; font-family: inherit; text-align: left; }\n .block-group-header .chevron { transition: transform 0.2s; color: #94a3b8; }\n .block-group-header .chevron.expanded { transform: rotate(90deg); }\n .block-group-header span:nth-of-type(1) { flex: 1; }\n .block-count { font-size: 0.75rem; font-weight: 600; color: #475569; background: #f1f5f9; padding: 2px 8px; border-radius: 10px; margin-left: auto; }\n .block-list { display: flex; flex-direction: column; gap: 2px; padding-bottom: 8px; }\n .variable-list { display: flex; flex-direction: column; padding-bottom: 8px; }\n /* A divider between every variable. */\n .variable-item + .variable-item { border-top: 1px solid #f1f5f9; border-radius: 0; }\n .block-item { display: flex; align-items: center; gap: 6px; box-sizing: border-box; width: 100%; min-height: 44px; padding: 8px 0; font-size: 0.8125rem; color: #64748b; cursor: pointer; text-align: left; border-radius: 4px; font-family: inherit; -webkit-user-select: none; user-select: none; }\n .block-item:hover { background: #f8fafc; color: #1e293b; }\n .block-item-drag { color: #cbd5e1; flex-shrink: 0; cursor: grab; }\n .variable-item { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 44px; padding: 8px 0; min-width: 0; width: 100%; box-sizing: border-box; border: none; background: none; cursor: pointer; text-align: left; border-radius: 4px; font-family: inherit; }\n .variable-item:hover { background: #f8fafc; }\n .var-tag { max-width: 100%; overflow-wrap: anywhere; font-size: 0.75rem; font-weight: 600; color: #1d4ed8; background: rgba(59,130,246,0.08); padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }\n .var-example { font-size: 0.75rem; color: #64748b; overflow-wrap: anywhere; }\n .var-description { font-size: 0.75rem; color: #64748b; line-height: 1.4; overflow-wrap: anywhere; }\n\n /* ─── Video library ─── */\n .video-library-panel { padding: 0; }\n .video-library-panel .right-section-title, .video-library-panel .right-section-hint { padding: 0 16px; }\n .video-library-panel .right-section-title { padding-top: 16px; }\n .video-config-section { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; border-bottom: 1px solid #f1f5f9; }\n .video-config-section:last-of-type { border-bottom: none; }\n .video-lib-list { display: flex; flex-direction: column; gap: 2px; padding: 8px 8px 16px; }\n .video-lib-item { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 8px; border: 1px solid transparent; border-radius: 8px; background: none; cursor: pointer; text-align: left; font-family: inherit; transition: background 0.15s, border-color 0.15s; }\n .video-lib-item:hover { background: #f8fafc; border-color: #e2e8f0; }\n .video-lib-item.selected { background: #eff6ff; border-color: #93c5fd; }\n .vli-thumb { position: relative; flex-shrink: 0; width: 56px; height: 40px; border-radius: 6px; background: linear-gradient(135deg, #f1f5f9, #e2e8f0); display: flex; align-items: center; justify-content: center; }\n .vli-dur { position: absolute; bottom: 2px; right: 3px; font-size: 0.625rem; font-weight: 600; color: #fff; background: rgba(0,0,0,0.65); padding: 1px 4px; border-radius: 3px; }\n .vli-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }\n .vli-title { font-size: 0.8125rem; font-weight: 600; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }\n .vli-cat { font-size: 0.75rem; color: #475569; }\n .vli-check { flex-shrink: 0; }\n .video-lib-loading { padding: 8px; }\n .video-lib-skeleton { display: flex; align-items: center; gap: 10px; padding: 8px; margin-bottom: 4px; }\n .vls-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }\n\n /* ─── Responsive ─── */\n @media (max-width: 1200px) { .editor-body { grid-template-columns: 280px minmax(0, 1fr) 260px; } }\n /* Phones and small tablets: one column, the page scrolls as a whole and every panel stays reachable (details, editor, blocks / variables / video). */\n @media (max-width: 900px) {\n :host { flex: none; }\n .editor-page { flex: none; min-height: 100vh; min-height: 100dvh; overflow: visible; }\n .editor-body { display: flex; flex-direction: column; flex: none; overflow: visible; }\n .panel-left { border-right: none; border-bottom: 1px solid #e2e8f0; overflow: visible; padding: 16px; }\n .panel-center { overflow: visible; min-height: 480px; }\n .blocks-canvas { overflow: visible; min-height: 320px; }\n .panel-right { border-left: none; border-top: 1px solid #e2e8f0; }\n .right-panel-body { overflow: visible; }\n .editor-toolbar, .toolbar-row-2, .link-dialog { padding-left: 12px; padding-right: 12px; }\n .editor-tabs { padding-left: 12px; padding-right: 12px; }\n .preview-frame { padding: 12px; }\n .form-row-dates { grid-template-columns: 1fr; }\n }\n @media (prefers-reduced-motion: reduce) { * { transition: none !important; } }\n `],\n})\nexport class EmailTemplateEditorComponent {\n protected readonly labels = inject(UiLabelsService);\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n private readonly injector = inject(Injector);\n\n // ── Inputs: the template and what differs per app ────────────────────────────\n /** The template to edit. `null` = a blank new template. An object without `id` is a new template that starts from those values (e.g. a copy). */\n readonly template = input<EmailTemplateValue | null>(null);\n readonly categories = input<SelectOption<string>[]>([]);\n /** Shows the Category field (default). An app without categories sets `false`; the saved `category` then stays whatever the template already had. */\n readonly showCategory = input(true);\n /** Shows \"Use this template all year\" and the Active From / To dates (default). An app whose templates are not seasonal sets `false`: nothing is shown and Save always emits `useAllYear: true` with no dates. */\n readonly showActiveRange = input(true);\n /** Styles the Preview and Mobile tabs like the app's real emails (font, colours, logo, company name, footer); see `EmailTemplatePreviewBrand`. `null` = the default look. */\n readonly previewBrand = input<EmailTemplatePreviewBrand | null>(null);\n /** The Preview and Mobile tabs fill every variable with its `example` (default off: they show the `{{key}}` tokens as written). The saved message is never changed. */\n readonly previewSampleData = input(false);\n /**\n * Lets the user pick an image file in the Insert Image dialog. The host uploads it and resolves the public http(s) address of the stored image; a rejection (or a value that is not\n * an http(s) address) shows the \"could not be uploaded\" message and the user can still paste an address. `null` (default) = no upload button, addresses only.\n */\n readonly imageUpload = input<((file: File) => Promise<string>) | null>(null);\n readonly categoryPlaceholderInput = input<string | null>(null, { alias: 'categoryPlaceholder' });\n readonly categoryPlaceholder = computed(() => this.categoryPlaceholderInput() ?? this.labels.t('emailTemplateEditor.categoryPlaceholder'));\n readonly assignmentOptions = input<EmailTemplateAssignmentOption[]>([]);\n /** The assignment shown first (e.g. the trigger the user came from). */\n readonly featuredAssignmentKey = input<string | null>(null);\n readonly assignmentsDescriptionInput = input<string | null>(null, { alias: 'assignmentsDescription' });\n readonly assignmentsDescription = computed(() => this.assignmentsDescriptionInput() ?? this.labels.t('emailTemplateEditor.assignmentsDescription'));\n readonly variableGroupsInput = input<EmailTemplateVariableGroup[] | null>(null, { alias: 'variableGroups' });\n readonly variableGroups = computed((): EmailTemplateVariableGroup[] => this.variableGroupsInput() ?? localizedEmailVariableGroups());\n readonly blockGroupsInput = input<EmailTemplateBlockGroup[] | null>(null, { alias: 'blockGroups' });\n readonly blockGroups = computed((): EmailTemplateBlockGroup[] => this.blockGroupsInput() ?? localizedEmailBlockGroups());\n /** Page heading shown at the start of the actions row (e.g. \"Create Your Template\"). Empty (default) = no heading; the buttons stay right aligned. */\n readonly heading = input('');\n readonly namePlaceholderInput = input<string | null>(null, { alias: 'namePlaceholder' });\n readonly namePlaceholder = computed(() => this.namePlaceholderInput() ?? this.labels.t('emailTemplateEditor.namePlaceholder'));\n readonly subjectPlaceholderInput = input<string | null>(null, { alias: 'subjectPlaceholder' });\n readonly subjectPlaceholder = computed(() => this.subjectPlaceholderInput() ?? this.labels.t('emailTemplateEditor.subjectPlaceholder'));\n readonly systemNoteInput = input<string | null>(null, { alias: 'systemNote' });\n readonly systemNote = computed(() => this.systemNoteInput() ?? this.labels.t('emailTemplateEditor.systemNote'));\n readonly readOnlyNoteInput = input<string | null>(null, { alias: 'readOnlyNote' });\n readonly readOnlyNote = computed(() => this.readOnlyNoteInput() ?? this.labels.t('emailTemplateEditor.readOnlyNote'));\n /** Prefix of the ids of the field errors the editor renders (`<prefix>-body-error`). */\n readonly idPrefix = input('tpl');\n /** The longest message (serialised HTML) that can be saved. */\n readonly maxBodyLength = input(EMAIL_TEMPLATE_MAX_BODY);\n readonly maxTextLength = input(EMAIL_TEMPLATE_MAX_TEXT);\n\n // ── Inputs: permissions and feature switches ─────────────────────────────────\n /** The member may change templates (false = read-only: everything is shown, nothing can be edited). */\n readonly fullAccess = input(true);\n /** A built-in template: shown read-only; a member with full access can copy it ((useAsMine)). */\n readonly systemTemplate = input(false);\n readonly testSendEnabled = input(true);\n\n // ── Inputs: request state owned by the host ──────────────────────────────────\n readonly saving = input(false);\n readonly testSending = input(false);\n\n // ── Inputs: video library ────────────────────────────────────────────────────\n /**\n * The host's videos. `null` (the default) = this app has no videos: the Video tab is not shown at all. Any list - even an empty one while the\n * host loads it on demand (see `(videosRequested)`) - turns the Video tab on.\n */\n readonly videos = input<EmailTemplateVideo[] | null>(null);\n /** Hides the Video tab completely even when `videos` is passed. */\n readonly hideVideos = input(false);\n readonly videosEnabled = computed(() => this.videos() !== null && !this.hideVideos());\n protected readonly videoList = computed(() => this.videos() ?? []);\n readonly videosLoading = input(false);\n readonly videoDefaults = input<EmailTemplateVideoDefaults>(EMPTY_VIDEO_DEFAULTS);\n readonly videoLink = input<EmailTemplateVideoLinkFn>(DEFAULT_VIDEO_LINK);\n readonly noVideosHintInput = input<string | null>(null, { alias: 'noVideosHint' });\n readonly noVideosHint = computed(() => this.noVideosHintInput() ?? this.labels.t('emailTemplateEditor.noVideosHint'));\n\n // ── Outputs ──────────────────────────────────────────────────────────────────\n readonly save = output<EmailTemplateSavePayload>();\n readonly testSend = output<string>();\n /** The Video tab was opened (the host loads the library once). */\n readonly videosRequested = output<void>();\n readonly useAsMine = output<void>();\n\n // ── Form state ───────────────────────────────────────────────────────────────\n readonly editingId = signal<string | null>(null);\n readonly isNew = computed(() => !this.editingId());\n readonly name = signal('');\n readonly subject = signal('');\n readonly category = signal('');\n readonly useAllYear = signal(true);\n readonly activeFrom = signal('');\n readonly activeTo = signal('');\n readonly videoId = signal<string | null>(null);\n readonly videoTitle = signal<string | null>(null);\n /** The triggers this template is assigned to (an email template is only ever assigned for email); the rows shown are `assignmentOptions` with this applied. */\n private readonly assignedKeys = signal<string[]>([]);\n private readonly assignmentState = computed((): AssignmentView[] => this.assignmentOptions().map(o => ({ ...o, assigned: this.assignedKeys().includes(o.key) })));\n\n // ── Blocks ───────────────────────────────────────────────────────────────────\n readonly blocks = signal<EmailBlock[]>([]);\n readonly selectedBlockId = signal<string | null>(null);\n private initializedBlockIds = new Set<string>();\n private savedRange: Range | null = null;\n private readonly blockEditors = viewChildren<ElementRef<HTMLDivElement>>('blockEditor');\n private readonly colorInputRef = viewChild<ElementRef<HTMLInputElement>>('colorInput');\n /** The stored body of the template being edited; null for a new one. */\n private readonly loadedBody = signal<string | null>(null);\n /** True once the user really edited the message (typing, blocks, formatting, links...). */\n private readonly bodyEdited = signal(false);\n private savedSnapshot = signal<string | null>(null);\n\n // ── Drag and drop ────────────────────────────────────────────────────────────\n private dragFromPalette: EmailTemplateBlock | null = null;\n readonly dragFromCanvas = signal<number | null>(null);\n readonly dragOverIndex = signal<number | null>(null);\n\n // ── Toolbar ──────────────────────────────────────────────────────────────────\n readonly currentColor = signal('#1e293b');\n readonly blockSpacing = signal('');\n readonly headingKey = signal(0);\n readonly sizeKey = signal(0);\n private readonly _headingOptions = computed((): SelectOption<string>[] => [\n { value: 'p', label: this.labels.t('emailTemplateEditor.heading.normal') }, { value: 'h1', label: this.labels.t('emailTemplateEditor.heading.h1') },\n { value: 'h2', label: this.labels.t('emailTemplateEditor.heading.h2') }, { value: 'h3', label: this.labels.t('emailTemplateEditor.heading.h3') },\n ]);\n get headingOptions(): SelectOption<string>[] { return this._headingOptions(); }\n readonly fontSizeOptions = FONT_SIZE_OPTIONS;\n private readonly _spacingTabs = computed((): PillTab[] => [\n { key: 'none', label: this.labels.t('emailTemplateEditor.spacing.none') }, { key: '8px', label: this.labels.t('emailTemplateEditor.spacing.small') },\n { key: '16px', label: this.labels.t('emailTemplateEditor.spacing.medium') }, { key: '32px', label: this.labels.t('emailTemplateEditor.spacing.large') },\n ]);\n get spacingTabs(): PillTab[] { return this._spacingTabs(); }\n /** The grey hint shown in the empty first block. */\n protected readonly startPlaceholder = computed(() => this.labels.t('emailTemplateEditor.startWriting'));\n private readonly _ctaTypeOptions = computed((): SelectOption<string>[] => [\n { value: '', label: this.labels.t('emailTemplateEditor.cta.none') }, { value: 'schedule', label: this.labels.t('emailTemplateEditor.cta.schedule') },\n { value: 'contact', label: this.labels.t('emailTemplateEditor.cta.contact') }, { value: 'custom', label: this.labels.t('emailTemplateEditor.cta.custom') },\n ]);\n get ctaTypeOptions(): SelectOption<string>[] { return this._ctaTypeOptions(); }\n private readonly _playbackOptions = computed(() => [\n { value: 'click', label: this.labels.t('emailTemplateEditor.playback.click') }, { value: 'autoplay', label: this.labels.t('emailTemplateEditor.playback.autoplay') },\n ]);\n get playbackOptions() { return this._playbackOptions(); }\n\n // ── Dialogs ──────────────────────────────────────────────────────────────────\n readonly showLinkDialog = signal(false);\n readonly linkUrl = signal('');\n readonly linkText = signal('');\n /** True when the link is made from selected text (the text field is then not needed). */\n readonly linkTextFromSelection = signal(false);\n readonly showImageDialog = signal(false);\n readonly imageUrl = signal('');\n readonly imageAlt = signal('');\n readonly imageUploading = signal(false);\n readonly imageUploadError = signal('');\n readonly showTestSendDialog = signal(false);\n readonly testSendEmail = signal('');\n\n // ── Tabs / palette ───────────────────────────────────────────────────────────\n readonly activeEditorTab = signal<EditorTab>('edit');\n readonly activeRightTab = signal<RightTab>('blocks');\n readonly blockSearch = signal('');\n readonly assignmentSearch = signal('');\n /** Groups the user opened or closed; the first variable group starts open. */\n private readonly toggledGroups = signal<Set<string>>(new Set());\n\n // ── Video options ────────────────────────────────────────────────────────────\n readonly videoAutoplay = signal(false);\n readonly videoCaption = signal('');\n readonly videoCtaType = signal('');\n readonly videoCtaUrl = signal('');\n readonly videoCtaLabel = signal('');\n readonly videoHideReactions = signal(false);\n\n // ── Derived ──────────────────────────────────────────────────────────────────\n readonly canWrite = computed(() => this.fullAccess() && !this.systemTemplate());\n /** A system template can be copied into a new template of the company's own (full access). */\n readonly canCopySystem = computed(() => this.fullAccess() && this.systemTemplate() && !!this.editingId());\n\n readonly filteredAssignments = computed(() => {\n const featured = this.featuredAssignmentKey();\n const all = this.assignmentState();\n const ordered = featured ? [...all.filter(a => a.key === featured), ...all.filter(a => a.key !== featured)] : all;\n const q = this.assignmentSearch().trim().toLowerCase();\n return q ? ordered.filter(a => a.name.toLowerCase().includes(q) || a.description.toLowerCase().includes(q)) : ordered;\n });\n\n readonly filteredBlockGroups = computed(() => {\n const q = this.blockSearch().trim().toLowerCase();\n const groups = this.blockGroups();\n if (!q) return groups;\n return groups.map(g => ({ ...g, blocks: g.blocks.filter(b => b.label.toLowerCase().includes(q)) })).filter(g => g.blocks.length > 0);\n });\n\n private readonly serialized = computed(() => this.serialize(this.blocks()));\n readonly previewHtml = this.serialized;\n private readonly sanitizer = inject(DomSanitizer);\n /** The Preview / Mobile document: a full page with the email's own styles. It is shown in a sandboxed iframe (no scripts, no popups), so trusting the markup here cannot run anything. */\n readonly previewDoc = computed((): SafeHtml => this.sanitizer.bypassSecurityTrustHtml(buildPreviewDocument(this.previewSampleData() ? fillSampleVariables(this.serialized(), this.variableGroups()) : this.serialized(), this.previewBrand())));\n /** Characters in the body as it is saved. */\n readonly bodyLength = computed(() => this.serialized().trim().length);\n readonly bodyHasContent = computed(() => this.blocks().some(b => blockHasContent(b.html)));\n /** The body as the server stores it and as the editor serialises it right after loading: while they match the message has not been touched. */\n readonly bodyUnchanged = computed(() => this.loadedBody() !== null && !this.bodyEdited());\n\n readonly nameError = computed(() => {\n const v = this.name().trim();\n if (!v) return this.labels.t('emailTemplateEditor.nameRequired');\n return v.length > this.maxTextLength() ? this.labels.t('emailTemplateEditor.nameTooLong', { max: this.maxTextLength() }) : '';\n });\n readonly subjectError = computed(() => {\n const v = this.subject().trim();\n if (!v) return this.labels.t('emailTemplateEditor.subjectRequired');\n return v.length > this.maxTextLength() ? this.labels.t('emailTemplateEditor.subjectTooLong', { max: this.maxTextLength() }) : '';\n });\n readonly bodyError = computed(() => {\n if (!this.bodyHasContent()) return this.labels.t('emailTemplateEditor.bodyRequired');\n const n = this.bodyLength();\n const max = this.maxBodyLength();\n // A stored body longer than the limit that has not been touched is accepted by the server (legacy rows), so it is here.\n return n > max && !this.bodyUnchanged() ? this.labels.t('emailTemplateEditor.bodyTooLong', { max: this.labels.formatNumber(max), actual: this.labels.formatNumber(n) }) : '';\n });\n /** \"Active From / To\" only apply when the template is not \"all year\"; when both are given To may not be before From. */\n readonly datesError = computed(() => {\n if (!this.showActiveRange() || this.useAllYear() || !this.activeFrom() || !this.activeTo()) return '';\n return this.activeTo() < this.activeFrom() ? this.labels.t('emailTemplateEditor.datesOrder') : '';\n });\n /** Errors are held back until the user has had a chance to act: a field is blurred, the message is edited or its blocks are left, or the assignments are changed or left. A failed Save (`submitAttempted`) reveals nothing on an untouched field. */\n readonly submitAttempted = signal(false);\n readonly nameTouched = signal(false);\n readonly subjectTouched = signal(false);\n readonly nameErrorShown = computed(() => this.nameTouched() ? this.nameError() : '');\n readonly subjectErrorShown = computed(() => this.subjectTouched() ? this.subjectError() : '');\n /** True once focus left the message blocks (the body error then shows). Editing the message also counts (`bodyEdited`). A failed Save never reveals it. */\n readonly bodyBlurred = signal(false);\n readonly bodyErrorShown = computed(() => this.bodyEdited() || this.bodyBlurred() ? this.bodyError() : '');\n /** A template must be assigned to at least one automation (only in an app that offers assignments at all). */\n readonly assignmentError = computed(() => this.assignmentOptions().length > 0 && !this.assignmentState().some(a => a.assigned) ? this.labels.t('emailTemplateEditor.assignmentRequired') : '');\n /** True once the user has changed an assignment or focus left the assignments list; a failed Save never sets it, so the message never shows on a control nobody has touched. */\n readonly assignmentsTouched = signal(false);\n readonly assignmentErrorShown = computed(() => this.assignmentsTouched() ? this.assignmentError() : '');\n readonly canSave = computed(() => !this.nameError() && !this.subjectError() && !this.bodyError() && !this.datesError() && !this.assignmentError());\n /** Save is offered to members who can write and stays disabled until every rule passes: a name, a subject, a message with some design (text or an image) and at least one assignment. */\n readonly saveDisabled = computed(() => !this.canWrite() || !this.canSave());\n /** What is still missing, shown as the tooltip of the disabled Save button ('' when Save is available or the member cannot write). */\n readonly saveHint = computed(() => {\n if (!this.canWrite() || this.canSave()) return '';\n const missing: string[] = [];\n if (this.nameError()) missing.push(this.name().trim() ? this.labels.t('emailTemplateEditor.missing.shorterName') : this.labels.t('emailTemplateEditor.missing.name'));\n if (this.subjectError()) missing.push(this.subject().trim() ? this.labels.t('emailTemplateEditor.missing.shorterSubject') : this.labels.t('emailTemplateEditor.missing.subject'));\n if (this.bodyError()) missing.push(this.bodyHasContent() ? this.labels.t('emailTemplateEditor.missing.shorterMessage') : this.labels.t('emailTemplateEditor.missing.message'));\n if (this.assignmentError()) missing.push(this.labels.t('emailTemplateEditor.missing.assignment'));\n return missing.length ? this.labels.t('emailTemplateEditor.saveHint', { items: missing.join(', ') }) : this.datesError();\n });\n\n /** True once the user left a date input; until then the visible hint does not print the dates message (the tooltip still carries it). */\n readonly datesTouched = signal(false);\n /** The visible line under Save: the generic \"Add a name, a subject, ...\" / \"Add a shorter name ...\" what-is-missing STATUS text of a disabled button (role=status), shown on an untouched form on purpose; it is never a field-specific error message (those wait for their field, and the dates message waits for `datesTouched`). The 'shorter ...' wording is the same generic status, not the field's own \"Too long (max N characters)\" error.\n * Details: a dates-only problem is printed only after the date inputs were touched. */\n readonly saveHintVisible = computed(() => {\n const hint = this.saveHint();\n return hint && hint === this.datesError() && !this.datesTouched() ? '' : hint;\n });\n\n private normalizedLink = computed(() => {\n const url = this.linkUrl().trim();\n if (!url) return '';\n return url.startsWith('http://') || url.startsWith('https://') || url.startsWith('mailto:') ? url : 'https://' + url;\n });\n /** Why Insert is disabled: nothing for an empty field, a message for an address that is not a link. */\n readonly linkUrlError = computed(() => {\n const url = this.normalizedLink();\n if (!url) return '';\n if (url.startsWith('mailto:')) return /^mailto:[^\\s@\"<>]+@[^\\s@\"<>]+\\.[^\\s@\"<>]+$/.test(url) ? '' : this.labels.t('emailTemplateEditor.validEmail');\n return isWebUrl(url) ? '' : this.labels.t('emailTemplateEditor.validWebAddress');\n });\n readonly canInsertLink = computed(() => !!this.linkUrl().trim() && !this.linkUrlError());\n readonly imageUrlError = computed(() => {\n const url = this.imageUrl().trim();\n return !url || isWebUrl(url) ? '' : this.labels.t('emailTemplateEditor.validImageAddress');\n });\n readonly canInsertImage = computed(() => !!this.imageUrl().trim() && !this.imageUrlError() && !this.imageUploading());\n /** Mistakes in the subject / message that turn into a broken email (see `findEmailChecks`); the sentences below list them. */\n private readonly emailChecks = computed(() => findEmailChecks(this.subject(), this.serialized(), this.variableGroups().flatMap(g => g.variables.map(v => v.key))));\n readonly checkMessages = computed((): string[] => {\n const c = this.emailChecks();\n return [\n ...c.unknownVariables.map(name => this.labels.t('emailTemplateEditor.checkUnknownVariable', { name: `{{${name}}}` })),\n ...(c.imagesWithoutAlt ? [this.labels.t(c.imagesWithoutAlt === 1 ? 'emailTemplateEditor.checkImageAlt_one' : 'emailTemplateEditor.checkImageAlt_other', { count: c.imagesWithoutAlt })] : []),\n ...(c.emptyLinks ? [this.labels.t(c.emptyLinks === 1 ? 'emailTemplateEditor.checkEmptyLink_one' : 'emailTemplateEditor.checkEmptyLink_other', { count: c.emptyLinks })] : []),\n ];\n });\n readonly testEmailError = computed(() => {\n const email = this.testSendEmail().trim();\n return !email || isValidEmailAddress(email) ? '' : this.labels.t('emailTemplateEditor.validEmail');\n });\n readonly canSendTest = computed(() => this.canWrite() && !!this.editingId() && !!this.testSendEmail().trim() && !this.testEmailError() && !this.testSending());\n /** The test email is the SAVED template: true when the editor holds changes that were not saved yet. */\n readonly hasUnsavedChanges = computed(() => !!this.editingId() && this.savedSnapshot() !== null && this.savedSnapshot() !== this.snapshot());\n\n constructor() {\n effect(() => {\n const t = this.template();\n untracked(() => this.applyTemplate(t));\n });\n effect(() => {\n const d = this.videoDefaults();\n untracked(() => {\n this.videoAutoplay.set(d.autoplay);\n this.videoCaption.set(d.caption);\n this.videoCtaType.set(d.ctaType);\n this.videoCtaUrl.set(d.ctaUrl);\n this.videoCtaLabel.set(d.ctaLabel);\n this.videoHideReactions.set(d.hideReactions);\n });\n });\n // The Video tab can go away while it is open (the host passes no videos any more): fall back to Blocks so the panel never goes blank.\n effect(() => {\n if (!this.videosEnabled() && this.activeRightTab() === 'video') untracked(() => this.activeRightTab.set('blocks'));\n });\n // Focus the first field of an inline dialog when it opens.\n effect(() => {\n if (this.showLinkDialog() || this.showImageDialog()) {\n afterNextRender(() => this.host.nativeElement.querySelector<HTMLInputElement>('.link-dialog input')?.focus(), { injector: this.injector });\n }\n });\n // New block editors get their HTML once, after render - never re-set, so Angular never moves the caret.\n afterEveryRender(() => {\n const current = this.blocks();\n for (const ref of this.blockEditors()) {\n const el = ref.nativeElement;\n const blockId = el.dataset['blockId'];\n if (blockId && !this.initializedBlockIds.has(blockId)) {\n const block = current.find(b => b.id === blockId);\n if (block !== undefined) {\n el.innerHTML = block.html;\n setEditorSpacing(el, block.spacing);\n this.initializedBlockIds.add(blockId);\n }\n }\n }\n });\n }\n\n // ── Host callbacks ───────────────────────────────────────────────────────────\n\n /** A create succeeded: the template now has an id (Test Send becomes available) and what is on screen is the saved version. */\n markSaved(id: string | null = this.editingId()): void {\n this.syncActiveBlockHtml();\n this.editingId.set(id);\n this.savedSnapshot.set(this.snapshot());\n }\n\n /** The test email was sent: close the dialog. */\n closeTestSend(): void { this.showTestSendDialog.set(false); }\n\n // ── Template load / save ─────────────────────────────────────────────────────\n\n private applyTemplate(t: EmailTemplateValue | null): void {\n this.initializedBlockIds = new Set();\n this.editingId.set(t?.id ?? null);\n this.name.set(t?.name ?? '');\n this.subject.set(t?.subject ?? '');\n this.category.set(t?.category ?? '');\n this.useAllYear.set(t?.useAllYear ?? true);\n this.activeFrom.set(t?.activeFrom ?? '');\n this.activeTo.set(t?.activeTo ?? '');\n this.videoId.set(t?.videoId ?? null);\n this.videoTitle.set(t?.videoTitle ?? null);\n // A template that is not stored yet and has no message starts with the prompt block; a stored one with an empty message gets an empty block.\n this.blocks.set(!t || (!t.id && !(t.body ?? '').trim())\n ? [{ id: this.genId(), html: '' }] // empty: the first block shows the grey \"Start writing your email...\" hint until something is typed\n : this.htmlToBlocks(t.body ?? ''));\n // The first block is selected from the start, so the toolbar (Block spacing) works on it without clicking into it first.\n this.selectedBlockId.set(this.blocks()[0]?.id ?? null);\n this.blockSpacing.set(this.blocks()[0]?.spacing ?? '');\n // Remember the stored body of the template being edited (not of a copy, which is a new template).\n this.loadedBody.set(t?.id ? (t.body ?? '') : null);\n this.bodyEdited.set(false);\n this.bodyBlurred.set(false);\n this.datesTouched.set(false);\n this.submitAttempted.set(false);\n this.nameTouched.set(false);\n this.subjectTouched.set(false);\n this.assignedKeys.set([...(t?.assignments ?? [])]);\n this.assignmentsTouched.set(false);\n this.savedSnapshot.set(t?.id ? this.snapshot() : null);\n }\n\n /** Focus left the message blocks for somewhere outside them: the body error may show now. */\n onBodyFocusOut(event: FocusEvent): void {\n const next = event.relatedTarget as Node | null;\n if (next && (event.currentTarget as HTMLElement).contains(next)) return;\n this.bodyBlurred.set(true);\n }\n\n /** Focus left the assignments list for somewhere outside it: the assignment error may show now. */\n onAssignmentsFocusOut(event: FocusEvent): void {\n const next = event.relatedTarget as Node | null;\n if (next && (event.currentTarget as HTMLElement).contains(next)) return;\n this.assignmentsTouched.set(true);\n }\n\n onSave(): void {\n if (this.saving() || !this.canWrite()) return; // the button is disabled in these cases; a defensive guard only\n if (!this.canSave()) { this.submitAttempted.set(true); return; } // the button is disabled while a rule fails; a defensive guard that only records the attempt (name / subject messages still wait for their field to be left; the body and assignment messages wait for the user to leave them)\n // Decided BEFORE the sync: syncing re-serialises the blocks, which can change the text of a legacy body that does not survive a parse / serialise round trip.\n const keepStoredBody = this.bodyUnchanged() && this.bodyLength() > this.maxBodyLength();\n this.syncActiveBlockHtml();\n this.save.emit({\n name: this.name(),\n subject: this.subject(),\n // An untouched legacy body over the limit goes back exactly as stored, so the server sees it unchanged.\n body: keepStoredBody ? (this.loadedBody() ?? '') : this.serialized(),\n category: this.category(),\n useAllYear: this.showActiveRange() ? this.useAllYear() : true,\n activeFrom: this.showActiveRange() && !this.useAllYear() && this.activeFrom() ? this.activeFrom() : null,\n activeTo: this.showActiveRange() && !this.useAllYear() && this.activeTo() ? this.activeTo() : null,\n videoId: this.videoId(),\n assignments: this.assignmentState().filter(a => a.assigned).map(a => a.key),\n });\n }\n\n private snapshot(): string {\n return JSON.stringify([this.name(), this.subject(), this.category(), this.useAllYear(), this.activeFrom(), this.activeTo(), this.serialized()]);\n }\n\n // ── Block serialization ──────────────────────────────────────────────────────\n\n private serialize(blocks: EmailBlock[]): string {\n return blocks.map(b => {\n // Spacing is an inner wrapper div so it survives data-block stripping during email delivery.\n const content = b.spacing ? `<div data-spacing=\"true\" style=\"padding:${b.spacing} 0\">${b.html}</div>` : b.html;\n return `<div data-block=\"true\">${content}</div>`;\n }).join('');\n }\n\n private htmlToBlocks(html: string): EmailBlock[] {\n if (!html || !html.trim()) return [{ id: this.genId(), html: '<p></p>' }];\n const div = new DOMParser().parseFromString(html, 'text/html').body; // an inert document: stored HTML never loads images or runs handlers here\n const blockDivs = Array.from(div.querySelectorAll(':scope > [data-block]'));\n if (blockDivs.length > 0) {\n return blockDivs.map(el => {\n const spacingEl = (el as HTMLElement).querySelector(':scope > [data-spacing]') as HTMLElement | null;\n if (spacingEl) {\n const spacing = spacingEl.style.padding?.split(' ')[0] || undefined;\n return { id: this.genId(), html: spacingEl.innerHTML, spacing };\n }\n return { id: this.genId(), html: el.innerHTML };\n });\n }\n return [{ id: this.genId(), html }];\n }\n\n private genId(): string { return Math.random().toString(36).slice(2, 10); }\n\n private editorFor(id: string | null): ElementRef<HTMLDivElement> | undefined {\n return id ? this.blockEditors().find(r => r.nativeElement.dataset['blockId'] === id) : undefined;\n }\n\n /** Copies each block's HTML from its DOM element (before saving / preview). */\n syncActiveBlockHtml(): void {\n const dom = new Map<string, string>();\n for (const ref of this.blockEditors()) {\n const id = ref.nativeElement.dataset['blockId'];\n if (id) dom.set(id, ref.nativeElement.innerHTML);\n }\n if (dom.size === 0) return;\n this.blocks.update(list => list.map(b => dom.has(b.id) && dom.get(b.id) !== b.html ? { ...b, html: dom.get(b.id)! } : b));\n }\n\n private syncBlock(): void {\n const id = this.selectedBlockId();\n const ref = this.editorFor(id);\n if (!id || !ref) return;\n const html = ref.nativeElement.innerHTML;\n this.blocks.update(list => list.map(b => b.id === id ? { ...b, html } : b));\n }\n\n setEditorTab(tab: EditorTab): void {\n const previous = this.activeEditorTab();\n if (tab !== 'edit') this.syncActiveBlockHtml(); // the preview reads the blocks, so the DOM text goes in first\n // Leaving Edit destroys the block editors; coming back creates new elements that must be filled from the blocks again.\n if (tab === 'edit' && previous !== 'edit') this.initializedBlockIds = new Set();\n this.activeEditorTab.set(tab);\n }\n\n // ── Block operations ─────────────────────────────────────────────────────────\n\n addBlock(blockKey = 'text-block'): void {\n if (!this.canWrite()) return;\n this.addBlockHtml(this.blockHtml(blockKey));\n }\n\n private addBlockHtml(html: string, at?: number): EmailBlock {\n this.bodyEdited.set(true);\n const block: EmailBlock = { id: this.genId(), html };\n this.blocks.update(list => at === undefined ? [...list, block] : [...list.slice(0, at), block, ...list.slice(at)]);\n this.selectedBlockId.set(block.id);\n return block;\n }\n\n deleteBlock(index: number): void {\n if (!this.canWrite()) return;\n const list = this.blocks();\n if (index < 0 || index >= list.length) return; // nothing to delete: not an edit\n if (list.length === 1) return; // the only block cannot be deleted (the delete icon is not shown for it either); edit or replace its text instead\n this.bodyEdited.set(true);\n this.initializedBlockIds.delete(list[index].id);\n const next = list.filter((_, i) => i !== index);\n this.blocks.set(next);\n this.selectedBlockId.set(next[Math.min(index, next.length - 1)].id);\n }\n\n duplicateBlock(index: number): void {\n if (!this.canWrite()) return;\n const list = this.blocks();\n if (index < 0 || index >= list.length) return; // nothing to copy: not an edit\n this.bodyEdited.set(true);\n const src = list[index];\n // The DOM is read first so the copy holds what is on screen.\n const html = this.editorFor(src.id)?.nativeElement.innerHTML ?? src.html;\n const copy: EmailBlock = { id: this.genId(), html, spacing: src.spacing };\n this.blocks.set([...list.slice(0, index + 1), copy, ...list.slice(index + 1)]);\n this.selectedBlockId.set(copy.id);\n }\n\n moveBlock(index: number, direction: -1 | 1): void {\n if (!this.canWrite()) return;\n const list = this.blocks();\n const target = index + direction;\n if (index < 0 || index >= list.length || target < 0 || target >= list.length) return; // nothing moves: not an edit\n this.bodyEdited.set(true);\n const next = [...list];\n [next[index], next[target]] = [next[target], next[index]];\n this.blocks.set(next);\n }\n\n onBlockInput(event: Event, block: EmailBlock): void {\n if (!this.canWrite()) return;\n this.bodyEdited.set(true);\n const html = (event.target as HTMLElement).innerHTML;\n this.blocks.update(list => list.map(b => b.id === block.id ? { ...b, html } : b));\n }\n\n /**\n * Typing and pasting stop at the body limit: input that would push the saved HTML past it is refused before it reaches the block\n * (the disabled Save and the inline message cover everything else). Deleting is always allowed.\n */\n onBlockBeforeInput(event: InputEvent): void {\n if (!this.canWrite()) { event.preventDefault(); return; }\n if (event.inputType.startsWith('delete') || event.inputType.startsWith('history')) return;\n // A block being dragged must never land in the text as a character string.\n if (isBlockDrag(event)) { event.preventDefault(); return; }\n const incoming = event.data ?? event.dataTransfer?.getData('text/plain') ?? '';\n if (!incoming) return;\n // The estimate counts what is SAVED: `&`, `<`, `>` and a non-breaking space become entities (quotes in text stay one character each), and typing over a selection replaces it. `insertCompositionText`\n // (IME, many phone keyboards) is never cancelable: the text goes in and the disabled Save backstop stops the save.\n const sel = window.getSelection();\n const replaced = sel && !sel.isCollapsed && insideEditorBlock(sel.anchorNode) ? serializedTextLength(sel.toString()) : 0;\n if (this.bodyLength() - replaced + serializedTextLength(incoming) > this.maxBodyLength()) event.preventDefault();\n }\n\n onBlockFocus(block: EmailBlock): void {\n this.selectedBlockId.set(block.id);\n this.blockSpacing.set(block.spacing ?? '');\n }\n\n // ── Drag and drop ────────────────────────────────────────────────────────────\n\n onPaletteDragStart(event: DragEvent, block: EmailTemplateBlock): void {\n if (!this.canWrite()) { event.preventDefault(); return; }\n this.dragFromPalette = block;\n this.dragFromCanvas.set(null);\n event.dataTransfer!.effectAllowed = 'copy';\n event.dataTransfer!.setData(EMAIL_BLOCK_DRAG_TYPE, block.key); // custom type: see EMAIL_BLOCK_DRAG_TYPE\n }\n\n /**\n * Starts reordering a block. Only the block's drag HANDLE is draggable (not the whole block): a draggable ancestor of a contenteditable makes\n * Firefox and Safari hijack mouse text selection inside it. `wrapper` is the block, shown as the drag image instead of the small handle.\n */\n onBlockDragStart(event: DragEvent, index: number, wrapper?: HTMLElement): void {\n if (!this.canWrite()) { event.preventDefault(); return; }\n if (event.target !== event.currentTarget) return; // a text drag that bubbled up from inside a block is not a block drag\n this.dragFromCanvas.set(index);\n this.dragFromPalette = null;\n event.dataTransfer!.effectAllowed = 'move';\n event.dataTransfer!.setData(EMAIL_BLOCK_DRAG_TYPE, String(index));\n if (wrapper) event.dataTransfer!.setDragImage?.(wrapper, 0, 0);\n event.stopPropagation();\n }\n\n onBlockDragEnd(): void {\n this.dragFromCanvas.set(null);\n this.dragFromPalette = null;\n this.dragOverIndex.set(null);\n }\n\n /** The canvas as a whole accepts only a block drag; a text drag inside a block keeps the browser's own behaviour. */\n onCanvasDragOver(event: DragEvent): void {\n if (this.canWrite() && isBlockDrag(event)) event.preventDefault();\n }\n\n onDropZoneDragOver(event: DragEvent, index: number): void {\n if (!this.canWrite() || !isBlockDrag(event)) return; // `types` is readable during dragover in every engine (Safari hides `getData` there)\n event.preventDefault();\n event.dataTransfer!.dropEffect = this.dragFromPalette ? 'copy' : 'move';\n if (this.dragOverIndex() !== index) this.dragOverIndex.set(index);\n }\n\n onDropZoneLeave(): void { this.dragOverIndex.set(null); }\n\n onDropZoneDrop(event: DragEvent, insertBefore: number): void {\n if (!this.canWrite()) { event.preventDefault(); return; }\n const fromCanvas = this.dragFromCanvas();\n if (this.dragFromPalette === null && fromCanvas === null) return; // not a block drag (e.g. text): leave it to the browser / the beforeinput guard\n event.preventDefault();\n this.dragOverIndex.set(null);\n if (this.dragFromPalette) {\n const html = this.dragFromPalette.html;\n this.dragFromPalette = null;\n this.addBlockHtml(html, insertBefore);\n } else if (fromCanvas !== null) {\n const to = fromCanvas < insertBefore ? insertBefore - 1 : insertBefore;\n if (fromCanvas !== to) {\n const next = [...this.blocks()];\n const [moved] = next.splice(fromCanvas, 1);\n next.splice(to, 0, moved);\n this.blocks.set(next);\n this.bodyEdited.set(true);\n }\n this.dragFromCanvas.set(null);\n }\n }\n\n // ── Toolbar ──────────────────────────────────────────────────────────────────\n\n /**\n * Mousedown on the toolbar keeps the selection in the editor (a button click must not blur it). A `<select>` / `<input>` must be left alone:\n * preventing the default of its mousedown stops the dropdown from opening. Those controls take focus, so they save the selection first\n * (`(mousedown)=\"saveSelection()\"`) and the command restores it.\n */\n preventFocusLoss(event: MouseEvent): void {\n const target = event.target as Element | null;\n if (target?.closest?.('select, input')) return;\n event.preventDefault();\n }\n\n /** Remembers the selection before a control takes focus. Only a selection inside an editor block is kept; anything else clears an older one. */\n saveSelection(): void {\n const sel = window.getSelection();\n const range = sel && sel.rangeCount > 0 ? sel.getRangeAt(0) : null;\n this.savedRange = range && insideEditorBlock(range.commonAncestorContainer) ? range.cloneRange() : null;\n }\n\n /**\n * Puts the remembered selection back, once. A saved range is used only when focus really left the editor (a dialog, a select, the colour\n * picker): when the live selection is already inside a block (a toolbar button keeps it there) that live selection wins, and a range left over\n * from an earlier interaction is dropped instead of formatting the wrong block.\n */\n private restoreSelection(): void {\n const saved = this.savedRange;\n this.savedRange = null;\n const sel = window.getSelection();\n const live = !!sel && sel.rangeCount > 0 && insideEditorBlock(sel.getRangeAt(0).commonAncestorContainer);\n if (live || !saved || !saved.commonAncestorContainer.isConnected || !insideEditorBlock(saved.commonAncestorContainer)) return;\n sel?.removeAllRanges();\n sel?.addRange(saved);\n }\n\n /** The HTML of the block being edited, or null when its editor is not on screen. */\n private activeBlockHtml(): string | null {\n return this.editorFor(this.selectedBlockId())?.nativeElement.innerHTML ?? null;\n }\n\n /**\n * Runs one editing command and marks the body edited only when it can have changed it: it ran over a real (non-collapsed) selection, or the\n * block's HTML is different afterwards. A click on Bold with only a caret in an untouched legacy body is not an edit. When the block cannot be\n * read the command counts as an edit, so a real edit is never lost; typing always raises `(input)`, which marks it too.\n */\n private runEditCommand(run: () => void): void {\n this.restoreSelection();\n const sel = window.getSelection();\n const overSelection = !!sel && sel.rangeCount > 0 && !sel.isCollapsed && insideEditorBlock(sel.getRangeAt(0).commonAncestorContainer);\n const before = this.activeBlockHtml();\n run();\n if (overSelection || before === null || before !== this.activeBlockHtml()) this.bodyEdited.set(true);\n }\n\n execCommand(cmd: string, value?: string): void {\n if (!this.canWrite()) return;\n this.runEditCommand(() => { document.execCommand(cmd, false, value ?? undefined); });\n this.syncBlock();\n }\n\n onHeading(value: string): void {\n this.execCommand('formatBlock', value);\n this.headingKey.update(k => k + 1); // a fresh select shows \"Normal\" again\n }\n\n onFontSize(value: string): void {\n this.applyFontSize(value);\n this.sizeKey.update(k => k + 1); // a fresh select shows \"Size\" again\n }\n\n applyFontSize(size: string): void {\n if (!this.canWrite() || !size) return;\n this.restoreSelection();\n const sel = window.getSelection();\n if (!sel || sel.rangeCount === 0) return;\n const range = sel.getRangeAt(0);\n if (range.collapsed || !insideEditorBlock(range.commonAncestorContainer)) return; // text outside the editor is never wrapped\n this.bodyEdited.set(true);\n try {\n const fragment = range.extractContents();\n const span = document.createElement('span');\n span.style.fontSize = size;\n span.appendChild(fragment);\n range.insertNode(span);\n sel.collapse(span, 1);\n } catch {\n // Fallback when the range cannot be wrapped directly: the text and the size are escaped, never written into HTML as typed.\n document.execCommand('insertHTML', false, `<span style=\"font-size:${escapeHtml(size)}\">${escapeHtml(sel.toString())}</span>`);\n }\n this.syncBlock();\n }\n\n applyTextColor(color: string): void {\n if (!this.canWrite()) return;\n this.currentColor.set(color);\n this.runEditCommand(() => {\n document.execCommand('styleWithCSS', false, 'true');\n document.execCommand('foreColor', false, color);\n });\n this.syncBlock();\n }\n\n openColorPicker(): void {\n this.saveSelection();\n this.colorInputRef()?.nativeElement.click();\n }\n\n applySpacing(value: string): void {\n if (!this.canWrite()) return;\n this.blockSpacing.set(value);\n const id = this.selectedBlockId();\n if (!id) return;\n const ref = this.editorFor(id);\n if (ref) setEditorSpacing(ref.nativeElement, value);\n const block = this.blocks().find(b => b.id === id);\n if (!block) return;\n const changed = (block.spacing ?? '') !== (value ?? '');\n this.blocks.update(list => list.map(b => b.id === id ? { ...b, spacing: value || undefined } : b));\n if (changed) this.bodyEdited.set(true); // picking the spacing it already has is not an edit\n }\n\n // ── Link / image dialogs ─────────────────────────────────────────────────────\n\n openLinkDialog(): void {\n if (!this.canWrite()) return;\n this.saveSelection();\n const selected = window.getSelection()?.toString() || '';\n this.linkText.set(selected);\n this.linkTextFromSelection.set(!!selected);\n this.linkUrl.set('');\n this.showLinkDialog.set(true);\n }\n\n insertLink(): void {\n if (!this.canWrite() || !this.canInsertLink()) return; // the Insert button is disabled in this case; a defensive guard only\n this.bodyEdited.set(true);\n const url = this.normalizedLink();\n this.restoreSelection();\n const sel = window.getSelection();\n if (sel && sel.rangeCount > 0 && !sel.isCollapsed) {\n document.execCommand('createLink', false, url);\n // The link opens in a new tab. The links are looked up in the whole block being edited (after createLink on a whole selection the range's common\n // ancestor can be the text INSIDE the new <a>, which would skip it) and found by comparing the attribute (not an attribute selector built from the\n // address: a quote or bracket would throw).\n const range = sel.getRangeAt(0);\n const node = range.commonAncestorContainer;\n const scope = this.editorFor(this.selectedBlockId())?.nativeElement ?? (node instanceof Element ? node : node.parentElement)?.closest('.block-content') ?? null;\n scope?.querySelectorAll('a').forEach(l => { if (l.getAttribute('href') === url) l.setAttribute('target', '_blank'); });\n } else {\n // The new link is built as a DOM node and serialized: the text and the address can never be parsed as markup.\n const a = document.createElement('a');\n a.setAttribute('href', url);\n a.setAttribute('target', '_blank');\n a.textContent = this.linkText().trim() || url;\n document.execCommand('insertHTML', false, a.outerHTML);\n }\n this.syncBlock();\n this.showLinkDialog.set(false);\n this.linkUrl.set('');\n this.linkText.set('');\n }\n\n openImageDialog(): void {\n if (!this.canWrite()) return;\n this.saveSelection();\n this.imageUrl.set('');\n this.imageAlt.set('');\n this.imageUploadError.set('');\n this.showImageDialog.set(true);\n }\n\n insertImageFromUrl(): void {\n if (!this.canWrite() || !this.canInsertImage()) return; // the Insert button is disabled in this case; a defensive guard only\n this.bodyEdited.set(true);\n this.restoreSelection();\n // Built as a DOM node and serialized: the address and the alt text can never break out of their attributes.\n const img = document.createElement('img');\n img.setAttribute('src', this.imageUrl().trim());\n img.setAttribute('alt', this.imageAlt() || this.labels.t('emailTemplateEditor.imageAltDefault'));\n img.setAttribute('style', 'max-width:100%;border-radius:8px;display:block;margin:8px 0');\n document.execCommand('insertHTML', false, img.outerHTML);\n this.syncBlock();\n this.showImageDialog.set(false);\n this.imageUrl.set('');\n this.imageAlt.set('');\n }\n\n /** The user picked a file in the Insert Image dialog: the host uploads it and the address it returns fills the address field (the user still adds alt text and presses Insert). */\n async onImageFile(event: Event): Promise<void> {\n const input = event.target as HTMLInputElement;\n const file = input.files?.[0];\n input.value = '';\n const upload = this.imageUpload();\n if (!file || !upload || !this.canWrite() || this.imageUploading()) return;\n this.imageUploadError.set('');\n this.imageUploading.set(true);\n try {\n const url = (await upload(file)).trim();\n if (isWebUrl(url)) this.imageUrl.set(url);\n else this.imageUploadError.set(this.labels.t('emailTemplateEditor.imageUploadFailed'));\n } catch {\n this.imageUploadError.set(this.labels.t('emailTemplateEditor.imageUploadFailed'));\n } finally {\n this.imageUploading.set(false);\n }\n }\n\n // ── Test send / AI ───────────────────────────────────────────────────────────\n\n openTestSendDialog(): void {\n if (!this.canWrite()) return;\n this.testSendEmail.set('');\n this.showTestSendDialog.set(true);\n }\n\n onTestSend(): void {\n if (!this.canSendTest()) return; // the Send Test button is disabled in these cases; a defensive guard only\n this.testSend.emit(this.testSendEmail().trim());\n }\n\n // ── Video ────────────────────────────────────────────────────────────────────\n\n openVideoTab(): void {\n this.activeRightTab.set('video');\n this.videosRequested.emit();\n }\n\n insertVideo(video: EmailTemplateVideo): void {\n if (!this.canWrite()) return;\n this.videoId.set(video.id);\n this.videoTitle.set(video.title);\n const link = this.videoLink()(video, {\n autoplay: this.videoAutoplay(), caption: this.videoCaption(), ctaType: this.videoCtaType(), ctaUrl: this.videoCtaUrl(),\n ctaLabel: this.videoCtaLabel(), hideReactions: this.videoHideReactions(),\n });\n const caption = this.videoCaption() || (this.videoAutoplay() ? this.labels.t('emailTemplateEditor.videoWillAutoplay') : this.labels.t('emailTemplateEditor.clickToWatchVideo'));\n this.addBlockHtml(buildVideoBlockHtml(video, link, caption, window.location.origin));\n this.activeRightTab.set('blocks');\n }\n\n formatDuration(seconds: number | null | undefined): string { return formatVideoDuration(seconds); }\n categoryLabel(cat: string | null | undefined): string { return formatCategoryLabel(cat); }\n\n // ── Assignments ──────────────────────────────────────────────────────────────\n\n /** Click / Enter / Space on a row: assign this template to that automation, or take it off again. */\n toggleAssignment(item: AssignmentView): void {\n if (!this.canWrite()) return;\n this.assignedKeys.update(keys => keys.includes(item.key) ? keys.filter(k => k !== item.key) : [...keys, item.key]);\n this.assignmentsTouched.set(true);\n }\n\n // ── Palette ──────────────────────────────────────────────────────────────────\n\n isOpen(id: string): boolean {\n const startsOpen = id === 'v:' + (this.variableGroups()[0]?.name ?? '');\n return startsOpen !== this.toggledGroups().has(id);\n }\n\n toggleGroup(id: string): void {\n this.toggledGroups.update(s => {\n const next = new Set(s);\n if (next.has(id)) next.delete(id); else next.add(id);\n return next;\n });\n }\n\n insertBlock(block: EmailTemplateBlock): void {\n if (!this.canWrite()) return;\n this.addBlockHtml(block.html);\n }\n\n insertVariable(variable: EmailTemplateVariable): void {\n if (!this.canWrite()) return;\n this.runEditCommand(() => { document.execCommand('insertText', false, `{{${variable.key}}}`); }); // nothing is inserted when no editor holds the caret\n this.syncBlock();\n }\n\n private blockHtml(key: string): string {\n for (const g of this.blockGroups()) {\n const found = g.blocks.find(b => b.key === key);\n if (found) return found.html;\n }\n return `<p>${this.labels.t('emailTemplateEditor.blockFallback')}</p>`;\n }\n}\n","import { Injectable, inject } from '@angular/core';\nimport { escapeHtml } from '../email-template-editor/email-template-editor.utils';\nimport { PrintService } from '@forgeroute/ui/print';\n\n/** An inspection checklist template, as the print sheet needs it. */\nexport interface PrintableInspectionTemplate {\n name: string;\n /** For example `MOVE_IN` (shown as \"Move In\"). */\n inspectionType: string;\n description?: string | null;\n defaultNotes?: string | null;\n defaultInspectorName?: string | null;\n /** Recurrence in days; absent or 0 = no recurrence line. */\n frequencyDays?: number | null;\n archived?: boolean;\n /** ACTIVE / INACTIVE / ARCHIVED; absent = derived from `archived` (Archived / Active). */\n status?: string;\n items: { itemName: string; required: boolean }[];\n}\n\nexport interface InspectionTemplatePrintOptions {\n /** The name in the footer (\"Generated from <appName> — <date>\"). Empty = the footer says only the date. */\n appName?: string;\n /** Colour of the heading and rule. Default `#1F3D2B`. */\n accentColor?: string;\n /** The date printed in the header and footer (tests and replays). Default: now. */\n now?: Date;\n /** Locale of the dates. Default `en-US`. */\n locale?: string;\n}\n\nconst formatEnumWords = (s: string): string => s.toLowerCase().replace(/_/g, ' ').replace(/\\b\\w/g, c => c.toUpperCase());\n\n/** The status shown on the sheet: the given `status` in sentence case, else Archived / Active from `archived`. */\nexport function inspectionTemplateStatusLabel(tpl: Pick<PrintableInspectionTemplate, 'status' | 'archived'>): string {\n if (tpl.status) return tpl.status.charAt(0).toUpperCase() + tpl.status.slice(1).toLowerCase();\n return tpl.archived ? 'Archived' : 'Active';\n}\n\n/**\n * The printable checklist sheet of an inspection template as a complete HTML document: heading with the date and the item count, a details box\n * (type, status, inspector, recurrence), description and default notes when present, the checklist table (number, item with a \"(Required)\" mark,\n * empty Pass and Fail boxes, a notes cell), four lines to fill in (unit number, inspection date, inspector name, signature) and a footer.\n * Every text is HTML-escaped. Pure: no DOM needed.\n */\nexport function buildInspectionTemplateHtml(tpl: PrintableInspectionTemplate, options: InspectionTemplatePrintOptions = {}): string {\n const accent = options.accentColor ?? '#1F3D2B';\n const today = (options.now ?? new Date()).toLocaleDateString(options.locale ?? 'en-US', { month: 'long', day: 'numeric', year: 'numeric' });\n const type = escapeHtml(formatEnumWords(tpl.inspectionType));\n const count = tpl.items.length;\n const box = '<span style=\"display:inline-block;width:18px;height:18px;border:2px solid #d1d5db;border-radius:4px;\"></span>';\n\n const rows = count\n ? tpl.items.map((item, idx) => `<tr>\n <td style=\"width:36px;text-align:center;font-weight:600;color:#6b7280;padding:10px 8px;\">${idx + 1}</td>\n <td style=\"padding:10px 8px;font-weight:500;\">${escapeHtml(item.itemName)}${item.required ? ' <span style=\"color:#d97706;font-size:0.75rem;font-weight:600;\">(Required)</span>' : ''}</td>\n <td style=\"width:60px;text-align:center;padding:10px 8px;\">${box}</td>\n <td style=\"width:60px;text-align:center;padding:10px 8px;\">${box}</td>\n <td style=\"width:140px;padding:10px 8px;border-bottom:1px dotted #e5e7eb;\"></td>\n </tr>`).join('')\n : '<tr><td colspan=\"5\" style=\"padding:16px;color:#9ca3af;font-style:italic;\">No checklist items defined.</td></tr>';\n\n const fill = (label: string) => `<div class=\"fill-field\"><p class=\"fill-label\">${label}</p><p style=\"min-height:20px;\"></p></div>`;\n const footer = options.appName ? `Generated from ${escapeHtml(options.appName)} — ${today}` : `Generated ${today}`;\n\n return `<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n <meta charset=\"utf-8\">\n <title>${escapeHtml(tpl.name)} — Inspection Checklist</title>\n <style>\n * { margin: 0; padding: 0; box-sizing: border-box; }\n body { font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, sans-serif; color: #1e293b; padding: 32px; max-width: 800px; margin: 0 auto; }\n .header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 2px solid ${accent}; }\n .header h1 { font-size: 1.5rem; font-weight: 700; color: ${accent}; }\n .header-meta { text-align: right; font-size: 0.8125rem; color: #6b7280; }\n .details { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; margin-bottom: 24px; padding: 16px; background: #f8fafc; border-radius: 8px; border: 1px solid #e2e8f0; }\n .detail-row { display: flex; gap: 8px; font-size: 0.875rem; }\n .detail-label { font-weight: 600; color: #64748b; min-width: 100px; }\n .detail-value { color: #1e293b; }\n .section-title { font-size: 0.875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: ${accent}; margin: 24px 0 12px; }\n .desc { font-size: 0.875rem; color: #475569; line-height: 1.6; margin-bottom: 16px; white-space: pre-wrap; }\n table { width: 100%; border-collapse: collapse; }\n thead th { text-align: left; font-size: 0.6875rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: #64748b; padding: 8px; border-bottom: 2px solid #e2e8f0; }\n tbody td { border-bottom: 1px solid #f1f5f9; }\n .fill-fields { margin-top: 32px; display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }\n .fill-field { border-bottom: 1px solid #d1d5db; padding: 8px 0 4px; }\n .fill-label { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: #64748b; }\n @media print {\n body { padding: 16px; }\n .no-print { display: none !important; }\n @page { margin: 0.5in; }\n }\n </style>\n</head>\n<body>\n <div class=\"header\">\n <div>\n <h1>${escapeHtml(tpl.name)}</h1>\n <p style=\"font-size:0.875rem;color:#64748b;margin-top:4px;\">${type} Inspection Template</p>\n </div>\n <div class=\"header-meta\">\n <p>Printed: ${today}</p>\n <p>${count} checklist item${count !== 1 ? 's' : ''}</p>\n </div>\n </div>\n\n <div class=\"details\">\n <div class=\"detail-row\"><span class=\"detail-label\">Type</span><span class=\"detail-value\">${type}</span></div>\n <div class=\"detail-row\"><span class=\"detail-label\">Status</span><span class=\"detail-value\">${escapeHtml(inspectionTemplateStatusLabel(tpl))}</span></div>\n ${tpl.defaultInspectorName ? `<div class=\"detail-row\"><span class=\"detail-label\">Inspector</span><span class=\"detail-value\">${escapeHtml(tpl.defaultInspectorName)}</span></div>` : ''}\n ${tpl.frequencyDays ? `<div class=\"detail-row\"><span class=\"detail-label\">Recurrence</span><span class=\"detail-value\">Every ${tpl.frequencyDays} days</span></div>` : ''}\n </div>\n\n ${tpl.description ? `<p class=\"section-title\">Description</p><p class=\"desc\">${escapeHtml(tpl.description)}</p>` : ''}\n ${tpl.defaultNotes ? `<p class=\"section-title\">Default Notes</p><p class=\"desc\">${escapeHtml(tpl.defaultNotes)}</p>` : ''}\n\n <p class=\"section-title\">Checklist</p>\n <table>\n <thead><tr><th style=\"width:36px;\">#</th><th>Item</th><th style=\"width:60px;text-align:center;\">Pass</th><th style=\"width:60px;text-align:center;\">Fail</th><th style=\"width:140px;\">Notes</th></tr></thead>\n <tbody>${rows}</tbody>\n </table>\n\n <div class=\"fill-fields\">\n ${fill('Unit Number')}\n ${fill('Inspection Date')}\n ${fill('Inspector Name')}\n ${fill('Inspector Signature')}\n </div>\n\n <p style=\"margin-top:32px;font-size:0.75rem;color:#9ca3af;text-align:center;\">${footer}</p>\n</body>\n</html>`;\n}\n\n/**\n * Prints and downloads inspection templates, the same in every app and every screen that offers it:\n *\n * const print = inject(InspectionTemplatePrintService);\n * print.configure({ appName: 'Parkstead' }); // once, optional\n * print.download(template); // hidden frame: the print dialog offers \"Save as PDF\"\n * if (!print.print(template)) toast.error('The print window was blocked. Allow pop-ups for this site.');\n */\n@Injectable({ providedIn: 'root' })\nexport class InspectionTemplatePrintService {\n private readonly printer = inject(PrintService);\n private options: InspectionTemplatePrintOptions = {};\n\n /** Sets the options of every sheet printed afterwards (app name in the footer, accent colour, locale). */\n configure(options: InspectionTemplatePrintOptions): void { this.options = { ...options }; }\n\n /** The sheet as HTML. */\n html(tpl: PrintableInspectionTemplate): string { return buildInspectionTemplateHtml(tpl, this.options); }\n\n /** Opens an empty print window. Call it straight from the click handler (Safari only allows a pop-up inside the user's gesture), fill it later with [print]. */\n openWindow(): Window | null { return this.printer.openWindow(); }\n\n /** Prints in a window (a new one, or `existing`). Returns false when the browser blocked the pop-up. */\n print(tpl: PrintableInspectionTemplate, existing?: Window | null): boolean { return this.printer.print(this.html(tpl), existing); }\n\n /** Prints through a hidden frame (no pop-up): the print dialog lets the user choose \"Save as PDF\". */\n download(tpl: PrintableInspectionTemplate): void { this.printer.printInFrame(this.html(tpl)); }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwBA,MAAM,+BAAe,IAAI,IAAI;CAC3B;CAAK;CAAO;CAAQ;CACpB;CAAK;CAAU;CAAK;CAAM;CAAK;CAAK;CAAU;CAAO;CAAO;CAC5D;CAAM;CAAM;CAAM;CAClB;CAAM;CAAM;CAAM;CAClB;CAAK;AACN,CAAA;AAGD,MAAM,oCAAoB,IAAI,IAAI;CAChC;CAAU;CAAS;CAAY;CAAY;CAAU;CAAU;CAAU;CAAU;CACnF;CAAY;CAAQ;CAAS;CAAQ;CAAQ;CAAO;CAAQ;CAAU;CAAS;CAC/E;CAAS;CAAU;CAAQ;CAAO;CAAU;CAAS;AACtD,CAAA;AAGD,MAAM,+BAAe,IAAI,IAAI;CAC3B;CAAW;CAAW;CAAU;CAAU;CAAQ;CAAS;CAAO;CAAO;CAAM;CAC/E;CAAW;CAAU;CAAM;CAAM;CAAM;CAAW;CAAY;AAC/D,CAAA;AAED,MAAM,QAAQ;AACd,MAAM,SAAS;AAGf,MAAM,cAAwC;CAC5C,cAAc,CAAC,+BAA+B;CAC9C,aAAa,CAAC,QAAQ,2DAA2D;CACjF,eAAe,CAAC,eAAe;CAC/B,eAAe,CAAC,yBAAyB;CACzC,cAAc,CAAC,m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