/* BackReload OAuth popup result handler. Reads the outcome from data-* attributes
   on #backreload-oauth (set server-side), notifies the opener window, then closes.
   Bundled file loaded via <script src> — the page is a standalone REST HTML
   response outside the wp_head pipeline, so it cannot be wp_enqueue'd. */
( function () {
	var el = document.getElementById( 'backreload-oauth' );
	if ( ! el || ! window.opener ) {
		return;
	}
	var ok = el.getAttribute( 'data-ok' ) === '1';
	var message = el.getAttribute( 'data-message' ) || '';
	try {
		window.opener.postMessage(
			{ backreloadOauth: ok, message: message },
			window.opener.location.origin
		);
	} catch ( e ) {}
	setTimeout( function () { window.close(); }, 1500 );
} )();
