() => { const host = document.getElementById("script-input"); const field = host?.querySelector("textarea"); if (!field) return; // Gradio measures text before the final responsive width can settle. // Ask the native input handler to measure again when that width changes. let width = 0; const observer = new ResizeObserver(entries => { const next = entries[0].contentRect.width; if (Math.abs(next - width) < .5) return; width = next; requestAnimationFrame(() => { if (field.isConnected) field.dispatchEvent(new Event("input", {bubbles:true})); else observer.disconnect(); }); }); observer.observe(host); window.addEventListener("pagehide", () => observer.disconnect(), {once:true}); }