// busy.mjs — the busy rule (650ms) for a button the editor posts from // itself: estilo's spinner in the button, aria-busy, and at least // HOLD_MS before the answer is shown, so a quick save reads as a // deliberate beat (busy.js does the same for the forms it sends). export const HOLD_MS = 650 export async function held (button, work) { const spin = document.createElement('span') spin.setAttribute('rst-spin', '') spin.setAttribute('aria-hidden', 'true') button.append(spin) button.setAttribute('aria-busy', 'true') button.disabled = true try { const [result] = await Promise.all([work(), new Promise(resolve => setTimeout(resolve, HOLD_MS))]) return result } finally { spin.remove() button.removeAttribute('aria-busy') button.disabled = false } }