const ROOT_ID = 'ac-modal-root'; export function getModalRoot(): HTMLElement { let root = document.getElementById(ROOT_ID); if (!root) { root = document.createElement('div'); root.id = ROOT_ID; document.body.appendChild(root); } return root; } export function buildDialogHTML(options: { title?: string; showClose: boolean; size: string; className?: string; }): HTMLElement { const wrapper = document.createElement('div'); wrapper.className = 'ac-modal'; const sizeClass = `ac-modal__dialog--${options.size}`; const extraClass = options.className ? ` ${options.className}` : ''; let headerHTML = ''; if (options.title || options.showClose) { const titleHTML = options.title ? `

${escapeHTML(options.title)}

` : ''; const closeHTML = options.showClose ? `` : ''; headerHTML = `
${titleHTML}${closeHTML}
`; } wrapper.innerHTML = `
`; return wrapper; } function escapeHTML(str: string): string { const div = document.createElement('div'); div.textContent = str; return div.innerHTML; }