/** * AI settings dialog. * * Holds the image-edit model, the AI agent (vision) model, and the opt-in * "Double-check AI edits" toggle. Opened from the Quick Edit gear button and * from the editor setup checklist; keeps the Quick Edit box itself uncluttered. */ export function createAiSettings({ container }) { const el = document.createElement('div'); el.className = 'ge-ai-settings'; el.hidden = true; el.setAttribute('role', 'dialog'); el.setAttribute('aria-modal', 'true'); el.setAttribute('aria-label', 'AI settings'); el.innerHTML = `

AI settings

Recommended, not required — the vision agent plans edits and can double-check results.

1.4×

How strongly named looks (Kodachrome, teal and orange, …) are graded.

`; function open(focusId) { el.hidden = false; if (focusId) { const target = document.getElementById(focusId); if (target) { try { target.focus({ preventScroll: true }); } catch (_) { target.focus(); } } } } function close() { el.hidden = true; } el.addEventListener('click', (e) => { if (e.target === el || e.target.closest('[data-ai-settings-close]')) { e.preventDefault(); close(); } }); const onKey = (e) => { if (e.key === 'Escape' && !el.hidden) close(); }; document.addEventListener('keydown', onKey); container.appendChild(el); const strengthInput = el.querySelector('#ge-look-strength'); const strengthVal = el.querySelector('#ge-look-strength-val'); if (strengthInput) { try { const saved = parseFloat(localStorage.getItem('ge-look-strength')); if (Number.isFinite(saved) && saved > 0) strengthInput.value = String(saved); } catch (_) {} if (strengthVal) strengthVal.textContent = Number(strengthInput.value).toFixed(1) + '×'; strengthInput.addEventListener('input', () => { const v = Number(strengthInput.value); if (strengthVal) strengthVal.textContent = v.toFixed(1) + '×'; try { localStorage.setItem('ge-look-strength', String(v)); } catch (_) {} }); } function destroy() { document.removeEventListener('keydown', onKey); el.remove(); } return { element: el, open, close, destroy }; }