(function () {
	try {
		var cfg = window.thesplColorProbeFrontend || {};
		var ajaxUrl = String( cfg.ajaxUrl || '' );
		var nonce = String( cfg.nonce || '' );
		var sessionId = String( cfg.sessionId || '' );
		var token = String( cfg.token || '' );
		var returnUrl = String( cfg.returnUrl || '' );
		var algorithm = String( cfg.algorithm || 'auto' );
		if ( ! ajaxUrl || ! nonce || ! sessionId || ! token ) {
			return;
		}

		var safeHex = function (v) {
			var s = String( v || '' ).trim();
			if ( /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test( s ) ) {
				if ( s.length === 4 ) {
					return '#' + s[1] + s[1] + s[2] + s[2] + s[3] + s[3];
				}
				return s.toLowerCase();
			}
			return '';
		};

		var rgbToHex = function (rgb) {
			if ( ! rgb || rgb.length < 3 ) {
				return '';
			}
			var toHex = function (n) {
				var x = parseInt( n, 10 );
				if ( ! Number.isFinite( x ) ) {
					x = 0;
				}
				x = Math.max( 0, Math.min( 255, x ) );
				var h = x.toString( 16 );
				return h.length < 2 ? '0' + h : h;
			};
			return '#' + toHex( rgb[0] ) + toHex( rgb[1] ) + toHex( rgb[2] );
		};

		var hexToRgb = function (hex) {
			var h = safeHex( hex );
			if ( ! h || h.length !== 7 ) {
				return null;
			}
			return [
				parseInt( h.slice( 1, 3 ), 16 ),
				parseInt( h.slice( 3, 5 ), 16 ),
				parseInt( h.slice( 5, 7 ), 16 )
			];
		};

		var lumaHex = function (hex) {
			var rgb = hexToRgb( hex );
			if ( ! rgb ) {
				return 0;
			}
			return ( 0.2126 * rgb[0] + 0.7152 * rgb[1] + 0.0722 * rgb[2] ) / 255;
		};

		var contrastRatio = function (a, b) {
			var la = lumaHex( a );
			var lb = lumaHex( b );
			var high = Math.max( la, lb );
			var low = Math.min( la, lb );
			return ( high + 0.05 ) / ( low + 0.05 );
		};

		var normalizeCoreColor = function (hex) {
			var h = safeHex( hex );
			var rgb = hexToRgb( h );
			if ( ! h || ! rgb ) {
				return '';
			}
			var r = rgb[0];
			var g = rgb[1];
			var b = rgb[2];
			var max = Math.max( r, g, b );
			var min = Math.min( r, g, b );
			var spread = max - min;
			var avg = ( r + g + b ) / 3;
			if ( max <= 22 ) {
				return '#000000';
			}
			if ( min >= 233 ) {
				return '#ffffff';
			}
			if ( spread <= 10 ) {
				if ( avg <= 42 ) {
					return '#000000';
				}
				if ( avg >= 214 ) {
					return '#ffffff';
				}
			}
			return h;
		};

		var bestTextOnBackground = function (bg) {
			return lumaHex( bg ) > 0.56 ? '#000000' : '#ffffff';
		};

		var colorDistance = function (a, b) {
			var ra = hexToRgb( a );
			var rb = hexToRgb( b );
			if ( ! ra || ! rb ) {
				return 0;
			}
			return Math.abs( ra[0] - rb[0] ) + Math.abs( ra[1] - rb[1] ) + Math.abs( ra[2] - rb[2] );
		};

		var colorSpread = function (hex) {
			var rgb = hexToRgb( hex );
			if ( ! rgb ) {
				return 0;
			}
			return Math.max( rgb[0], rgb[1], rgb[2] ) - Math.min( rgb[0], rgb[1], rgb[2] );
		};

		var isNeutralColor = function (hex) {
			return colorSpread( hex ) <= 16;
		};

		var colorSaturation = function (hex) {
			var rgb = hexToRgb( hex );
			if ( ! rgb ) {
				return 0;
			}
			var r = rgb[0] / 255;
			var g = rgb[1] / 255;
			var b = rgb[2] / 255;
			var max = Math.max( r, g, b );
			var min = Math.min( r, g, b );
			if ( max <= 0 ) {
				return 0;
			}
			return ( max - min ) / max;
		};

		var isSafeReturnUrl = function (raw) {
			try {
				var u = new URL( String( raw || '' ), window.location.origin );
				return u.protocol === 'http:' || u.protocol === 'https:';
			} catch (e) {
				return false;
			}
		};

		var parseColor = function (v) {
			var s = String( v || '' ).trim();
			var hex = safeHex( s );
			if ( hex ) {
				return hex;
			}
			if ( s === 'transparent' || s === 'inherit' || s === 'initial' ) {
				return '';
			}
			var m = s.match( /rgba?\((\d+)[^\d]+(\d+)[^\d]+(\d+)(?:[^\d]+([0-9.]+))?/i );
			if ( ! m ) {
				return '';
			}
			var alpha = typeof m[4] !== 'undefined' ? parseFloat( m[4] ) : 1;
			if ( Number.isFinite( alpha ) && alpha <= 0 ) {
				return '';
			}
			return rgbToHex( [m[1], m[2], m[3]] );
		};

		var collectElements = function (selector, limit) {
			try {
				var list = document.querySelectorAll( selector );
				var out = [];
				for ( var i = 0; i < list.length && out.length < limit; i++ ) {
					out.push( list[i] );
				}
				return out;
			} catch (e) {
				return [];
			}
		};

		var mapInc = function (map, key, by) {
			if ( ! key ) {
				return;
			}
			if ( ! Object.prototype.hasOwnProperty.call( map, key ) ) {
				map[key] = 0;
			}
			map[key] += by;
		};

		var collectVariableColors = function (map) {
			if ( ! map || typeof map !== 'object' ) {
				return;
			}
			var root = document.documentElement;
			if ( ! root ) {
				return;
			}
			try {
				var cs = window.getComputedStyle( root );
				for ( var i = 0; i < cs.length; i++ ) {
					var prop = String( cs[i] || '' ).trim();
					if ( ! prop || prop.indexOf( '--' ) !== 0 ) {
						continue;
					}
					var propName = prop.toLowerCase();
					if ( propName.indexOf( '--thespl-' ) === 0 ) {
						continue;
					}
					var isWpPreset = propName.indexOf( '--wp--preset--color--' ) === 0;
					var isWpCustom = propName.indexOf( '--wp--custom--' ) === 0;
					var isBlockedWpColor = propName.indexOf( '--wp-admin-theme-color' ) === 0 || propName.indexOf( '--wp-block-synced-color' ) === 0 || propName.indexOf( '--wp-bound-block-color' ) === 0 || propName.indexOf( '--wp-editor-canvas-background' ) === 0;
					if ( isBlockedWpColor ) {
						continue;
					}
					var isAllowedWpColor = isWpPreset || isWpCustom;
					var hasColorSignal = propName.indexOf( 'color' ) >= 0 || propName.indexOf( 'accent' ) >= 0 || propName.indexOf( 'primary' ) >= 0 || propName.indexOf( 'link' ) >= 0;
					if ( ! isAllowedWpColor && ! hasColorSignal ) {
						continue;
					}
					if ( propName.indexOf( '--wp-' ) === 0 && ! isAllowedWpColor ) {
						continue;
					}
					var val = parseColor( cs.getPropertyValue( prop ) );
					if ( ! val ) {
						continue;
					}
					mapInc( map, val, isAllowedWpColor ? 6 : 3 );
				}
			} catch (eVars) {
			}
		};

		var isTspElement = function (el) {
			if ( ! el || typeof el.closest !== 'function' ) {
				return false;
			}
			try {
				return !! el.closest( '.thespl-player,.thespl-player-wrap,[class^="thespl-"],[class*=" thespl-"],[id^="thespl-"]' );
			} catch (eClosest) {
				return false;
			}
		};

		var isRectVisible = function (rect) {
			if ( ! rect || rect.width < 2 || rect.height < 2 ) {
				return false;
			}
			var vw = Math.max( document.documentElement ? document.documentElement.clientWidth : 0, window.innerWidth || 0 );
			var vh = Math.max( document.documentElement ? document.documentElement.clientHeight : 0, window.innerHeight || 0 );
			if ( rect.bottom <= 0 || rect.right <= 0 || rect.top >= vh || rect.left >= vw ) {
				return false;
			}
			return true;
		};

		var isElementVisible = function (el, rect, cs) {
			if ( ! el ) {
				return false;
			}
			if ( el.hidden || String( el.getAttribute( 'aria-hidden' ) || '' ).toLowerCase() === 'true' ) {
				return false;
			}
			if ( typeof el.closest === 'function' && el.closest( '[hidden],[aria-hidden="true"]' ) ) {
				return false;
			}
			var style = cs;
			if ( ! style ) {
				try {
					style = window.getComputedStyle( el );
				} catch (eStyle) {
					style = null;
				}
			}
			if ( ! style ) {
				return false;
			}
			if ( style.display === 'none' || style.visibility === 'hidden' || style.visibility === 'collapse' || style.contentVisibility === 'hidden' ) {
				return false;
			}
			var opacity = parseFloat( String( style.opacity || '1' ) );
			if ( Number.isFinite( opacity ) && opacity <= 0.01 ) {
				return false;
			}
			var box = rect;
			if ( ! box ) {
				try {
					box = el.getBoundingClientRect();
				} catch (eRect) {
					box = null;
				}
			}
			return isRectVisible( box );
		};

		var pickTopColor = function (map) {
			var bestColor = '';
			var bestScore = -1;
			for ( var k in map ) {
				if ( Object.prototype.hasOwnProperty.call( map, k ) ) {
					var score = map[k];
					if ( score > bestScore ) {
						bestScore = score;
						bestColor = k;
					}
				}
			}
			return bestColor;
		};

		var getTextColor = function () {
			var score = {};
			var roots = collectElements( 'main,.entry-content,article,.post,.wp-block-post-content,body', 8 );
			for ( var ri = 0; ri < roots.length; ri++ ) {
				var root = roots[ri];
				if ( ! root ) {
					continue;
				}
				var nodes = [];
				try {
					nodes = root.querySelectorAll( 'p,li,h1,h2,h3,h4,h5,h6,strong,em,blockquote,figcaption,td,th' );
				} catch (eNodes) {
					nodes = [];
				}
				for ( var ni = 0; ni < nodes.length; ni++ ) {
					var el = nodes[ni];
					try {
						var rect = el.getBoundingClientRect();
						var cs = window.getComputedStyle( el );
						if ( ! isElementVisible( el, rect, cs ) ) {
							continue;
						}
						var color = parseColor( cs ? cs.color : '' );
						if ( ! color ) {
							continue;
						}
						var textLen = String( el.textContent || '' ).trim().length;
						if ( textLen < 2 ) {
							continue;
						}
						var area = Math.max( 1, Math.round( rect.width * rect.height ) );
						var weight = Math.max( 1, Math.min( 220, Math.round( area / 140 ) ) ) + Math.min( 60, textLen );
						mapInc( score, color, weight );
					} catch (eEach) {
					}
				}
			}
			if ( ! pickTopColor( score ) ) {
				try {
					var bodyCs = window.getComputedStyle( document.body );
					return parseColor( bodyCs ? bodyCs.color : '' );
				} catch (e2) {
					return '';
				}
			}
			return pickTopColor( score );
		};

		var getBackgroundColor = function () {
			var score = {};
			var selectors = 'body,main,#page,#content,.site,.site-content,.wp-site-blocks,.entry-content,.container,.wrapper';
			var elements = collectElements( selectors, 120 );
			for ( var i = 0; i < elements.length; i++ ) {
				var el = elements[i];
				if ( isTspElement( el ) ) {
					continue;
				}
				try {
					var r = el.getBoundingClientRect();
					var cs = window.getComputedStyle( el );
					if ( ! isElementVisible( el, r, cs ) ) {
						continue;
					}
					var color = parseColor( cs ? cs.backgroundColor : '' );
					if ( ! color ) {
						continue;
					}
					var area = Math.max( 1, Math.round( r.width * r.height ) );
					mapInc( score, color, area );
				} catch (e) {
				}
			}
			var top = pickTopColor( score );
			if ( top ) {
				return top;
			}
			try {
				var body = window.getComputedStyle( document.body );
				return parseColor( body ? body.backgroundColor : '' );
			} catch (e2) {
				return '';
			}
		};

		var getAccentCandidates = function () {
			var score = {};
			var elements = collectElements( 'button,.button,.btn,.cta,.wp-element-button,a[role="button"],input[type="submit"],input[type="button"],a', 260 );
			for ( var i = 0; i < elements.length; i++ ) {
				var el = elements[i];
				if ( isTspElement( el ) ) {
					continue;
				}
				try {
					var rect = el.getBoundingClientRect();
					var cs = window.getComputedStyle( el );
					if ( ! isElementVisible( el, rect, cs ) ) {
						continue;
					}
					var bg = parseColor( cs ? cs.backgroundColor : '' );
					var tx = parseColor( cs ? cs.color : '' );
					var br = parseColor( cs ? cs.borderColor : '' );
					var area = Math.max( 1, Math.round( rect.width * Math.max( rect.height, 24 ) ) );
					if ( bg ) {
						mapInc( score, bg, area + 5 );
					}
					if ( tx ) {
						mapInc( score, tx, 4 );
					}
					if ( br ) {
						mapInc( score, br, 3 );
					}
				} catch (e) {
				}
			}
			var extra = collectElements( '[class*="accent"],[class*="primary"],[style*="color"],[style*="background"]', 220 );
			for ( var j = 0; j < extra.length; j++ ) {
				var ex = extra[j];
				if ( isTspElement( ex ) ) {
					continue;
				}
				try {
					var er = ex.getBoundingClientRect();
					var ecs = window.getComputedStyle( ex );
					if ( ! isElementVisible( ex, er, ecs ) ) {
						continue;
					}
					var ebg = parseColor( ecs ? ecs.backgroundColor : '' );
					var ecl = parseColor( ecs ? ecs.color : '' );
					var ebr = parseColor( ecs ? ecs.borderColor : '' );
					if ( ebg ) {
						mapInc( score, ebg, 14 );
					}
					if ( ecl ) {
						mapInc( score, ecl, 10 );
					}
					if ( ebr ) {
						mapInc( score, ebr, 8 );
					}
				} catch (eEx) {
				}
			}
			var links = collectElements( 'main a,.entry-content a,article a,.wp-block-post-content a', 260 );
			for ( var li = 0; li < links.length; li++ ) {
				var link = links[li];
				if ( isTspElement( link ) ) {
					continue;
				}
				try {
					var lr = link.getBoundingClientRect();
					var lcs = window.getComputedStyle( link );
					if ( ! isElementVisible( link, lr, lcs ) ) {
						continue;
					}
					var lc = parseColor( lcs ? lcs.color : '' );
					if ( ! lc ) {
						continue;
					}
					var lArea = Math.max( 1, Math.round( lr.width * Math.max( lr.height, 16 ) ) );
					mapInc( score, lc, Math.max( 6, Math.min( 24, Math.round( lArea / 200 ) ) ) );
				} catch (eLink) {
				}
			}
			var sorted = Object.keys( score ).sort( function (a, b) { return score[b] - score[a]; } );
			return sorted.slice( 0, 14 );
		};

		var pickAccentColors = function (background, textColor, candidates) {
			var bg = safeHex( background );
			var tx = safeHex( textColor );
			var list = Array.isArray( candidates ) ? candidates : [];
			var accent1 = '';
			var accent2 = '';
			var bestA1Score = -999999;
			for ( var i = 0; i < list.length; i++ ) {
				var c1 = safeHex( list[i] );
				if ( ! c1 ) {
					continue;
				}
				var distBg1 = bg ? colorDistance( c1, bg ) : 110;
				var distTx1 = tx ? colorDistance( c1, tx ) : 110;
				var sat1 = colorSaturation( c1 );
				var score1 = ( list.length - i ) * 16 + sat1 * 120 + Math.min( distBg1, 140 ) * 0.45 + Math.min( distTx1, 140 ) * 0.35;
				if ( isNeutralColor( c1 ) ) {
					score1 -= 90;
				}
				if ( distBg1 < 32 ) {
					score1 -= 80;
				}
				if ( distTx1 < 32 ) {
					score1 -= 80;
				}
				if ( score1 > bestA1Score ) {
					bestA1Score = score1;
					accent1 = c1;
				}
			}
			if ( ! accent1 && list.length > 0 ) {
				accent1 = safeHex( list[0] );
			}
			var bestA2Score = -999999;
			for ( var j = 0; j < list.length; j++ ) {
				var c2 = safeHex( list[j] );
				if ( ! c2 || c2 === accent1 ) {
					continue;
				}
				var distA1 = colorDistance( c2, accent1 );
				var distBg2 = bg ? colorDistance( c2, bg ) : 110;
				var distTx2 = tx ? colorDistance( c2, tx ) : 110;
				var sat2 = colorSaturation( c2 );
				var score2 = ( list.length - j ) * 14 + sat2 * 120 + Math.min( distA1, 180 ) * 0.75 + Math.min( distBg2, 140 ) * 0.22 + Math.min( distTx2, 140 ) * 0.2;
				if ( isNeutralColor( c2 ) ) {
					score2 -= 60;
				}
				if ( distA1 < 40 ) {
					score2 -= 140;
				}
				if ( distBg2 < 28 ) {
					score2 -= 60;
				}
				if ( distTx2 < 28 ) {
					score2 -= 60;
				}
				if ( score2 > bestA2Score ) {
					bestA2Score = score2;
					accent2 = c2;
				}
			}
			if ( ! accent2 ) {
				for ( var k = 0; k < list.length; k++ ) {
					var fallback = safeHex( list[k] );
					if ( ! fallback || fallback === accent1 ) {
						continue;
					}
					if ( colorDistance( fallback, accent1 ) >= 40 ) {
						accent2 = fallback;
						break;
					}
				}
			}
			if ( ! accent2 && accent1 ) {
				var brighter = shiftHex( accent1, 62 );
				var darker = shiftHex( accent1, -62 );
				var brightScore = Math.min( bg ? colorDistance( brighter, bg ) : 999, tx ? colorDistance( brighter, tx ) : 999 );
				var darkScore = Math.min( bg ? colorDistance( darker, bg ) : 999, tx ? colorDistance( darker, tx ) : 999 );
				accent2 = brightScore >= darkScore ? brighter : darker;
			}
			return {
				accent_1: safeHex( accent1 ),
				accent_2: safeHex( accent2 )
			};
		};

		var renderDoneOverlay = function () {
			var existing = document.getElementById( 'thespl-color-probe-done-modal' );
			if ( existing ) {
				return;
			}

			var backdrop = document.createElement( 'div' );
			backdrop.id = 'thespl-color-probe-done-modal';
			backdrop.style.position = 'fixed';
			backdrop.style.inset = '0';
			backdrop.style.zIndex = '2147483647';
			backdrop.style.background = 'rgba(0,0,0,0.56)';
			backdrop.style.display = 'flex';
			backdrop.style.alignItems = 'center';
			backdrop.style.justifyContent = 'center';
			backdrop.style.padding = '18px';
			backdrop.style.boxSizing = 'border-box';
			backdrop.style.fontFamily = 'system-ui,-apple-system,Segoe UI,Roboto,sans-serif';

			var card = document.createElement( 'div' );
			card.style.width = '100%';
			card.style.maxWidth = '460px';
			card.style.background = '#111111';
			card.style.color = '#ffffff';
			card.style.borderRadius = '12px';
			card.style.padding = '18px';
			card.style.boxShadow = '0 14px 40px rgba(0,0,0,0.44)';
			card.style.textAlign = 'center';

			var title = document.createElement( 'div' );
			title.textContent = 'Analysis Complete';
			title.style.fontSize = '20px';
			title.style.fontWeight = '700';
			title.style.marginBottom = '8px';
			card.appendChild( title );

			var text = document.createElement( 'div' );
			text.textContent = 'Colors were imported successfully. Continue in WordPress to generate your palette.';
			text.style.fontSize = '14px';
			text.style.lineHeight = '1.45';
			text.style.opacity = '0.96';
			card.appendChild( text );

			var primaryBtn = document.createElement( 'button' );
			primaryBtn.type = 'button';
			primaryBtn.textContent = 'Back to WordPress and close this tab';
			primaryBtn.style.cursor = 'pointer';
			primaryBtn.style.display = 'block';
			primaryBtn.style.width = '100%';
			primaryBtn.style.marginTop = '14px';
			primaryBtn.style.padding = '12px 14px';
			primaryBtn.style.border = '0';
			primaryBtn.style.borderRadius = '8px';
			primaryBtn.style.background = '#2271b1';
			primaryBtn.style.color = '#ffffff';
			primaryBtn.style.fontSize = '14px';
			primaryBtn.style.fontWeight = '700';
			primaryBtn.addEventListener( 'click', function () {
				try {
					if ( window.opener && ! window.opener.closed && typeof window.opener.focus === 'function' ) {
						window.opener.focus();
						window.close();
						return;
					}
				} catch (eMain) {
				}
				var isValid = isSafeReturnUrl( returnUrl );
				if ( isValid ) {
					try {
						window.focus();
					} catch (eFocusSelf) {
					}
				}
				try {
					window.close();
				} catch (eClose) {
				}
			} );
			card.appendChild( primaryBtn );

			backdrop.appendChild( card );
			document.body.appendChild( backdrop );
		};

		var shiftHex = function (hex, delta) {
			var h = safeHex( hex );
			if ( ! h || h.length !== 7 ) {
				return '';
			}
			var r = parseInt( h.slice( 1, 3 ), 16 );
			var g = parseInt( h.slice( 3, 5 ), 16 );
			var b = parseInt( h.slice( 5, 7 ), 16 );
			var clamp = function (n) {
				return Math.max( 0, Math.min( 255, n ) );
			};
			return rgbToHex( [clamp( r + delta ), clamp( g + delta ), clamp( b + delta )] );
		};

		var normalizedAlgorithm = function (mode) {
			var allowed = ['auto', 'surface_shift', 'vivid_contrast'];
			var key = String( mode || '' ).toLowerCase();
			return allowed.indexOf( key ) >= 0 ? key : 'auto';
		};

		var adjustBackgroundForMode = function (background, mode) {
			var bg = safeHex( background );
			if ( ! bg ) {
				return '';
			}
			var currentMode = normalizedAlgorithm( mode );
			var luma = lumaHex( bg );
			var delta = 0;
			if ( currentMode === 'surface_shift' ) {
				if ( luma <= 0.12 ) {
					delta = 24;
				} else if ( luma >= 0.88 ) {
					delta = -24;
				} else {
					delta = luma > 0.5 ? -16 : 16;
				}
			} else if ( currentMode === 'vivid_contrast' ) {
				if ( luma <= 0.12 ) {
					delta = 18;
				} else if ( luma >= 0.88 ) {
					delta = -18;
				} else {
					delta = luma > 0.5 ? -10 : 10;
				}
			} else if ( luma <= 0.08 ) {
				delta = 16;
			} else if ( luma >= 0.92 ) {
				delta = -16;
			} else {
				delta = luma > 0.5 ? -8 : 8;
			}
			var shifted = safeHex( shiftHex( bg, delta ) );
			return shifted || bg;
		};

		var adjustAccentsForMode = function (accent1, accent2, background, mode) {
			var currentMode = normalizedAlgorithm( mode );
			var a1 = safeHex( accent1 );
			var a2 = safeHex( accent2 );
			var bg = safeHex( background );
			if ( currentMode !== 'vivid_contrast' ) {
				return {
					accent_1: a1,
					accent_2: a2
				};
			}
			var bgLuma = lumaHex( bg );
			if ( ! a1 || isNeutralColor( a1 ) ) {
				a1 = bgLuma > 0.5 ? '#1d4ed8' : '#60a5fa';
			}
			if ( ! a2 || colorDistance( a1, a2 ) < 75 ) {
				a2 = bgLuma > 0.5 ? '#9333ea' : '#f59e0b';
			}
			return {
				accent_1: a1,
				accent_2: a2
			};
		};

		var extract = function () {
			var currentAlgorithm = normalizedAlgorithm( algorithm );
			var background = normalizeCoreColor( getBackgroundColor() );
			var textColor = normalizeCoreColor( getTextColor() );
			if ( background && textColor && contrastRatio( background, textColor ) < 3.6 ) {
				textColor = bestTextOnBackground( background );
			}
			if ( background && ! textColor ) {
				textColor = bestTextOnBackground( background );
			}
			background = adjustBackgroundForMode( background, currentAlgorithm );
			if ( background && textColor && contrastRatio( background, textColor ) < 3.6 ) {
				textColor = bestTextOnBackground( background );
			}
			var accents = getAccentCandidates();
			var pickedAccents = pickAccentColors( background, textColor, accents );
			var adjustedAccents = adjustAccentsForMode( pickedAccents.accent_1, pickedAccents.accent_2, background, currentAlgorithm );
			var accent1 = adjustedAccents.accent_1;
			var accent2 = adjustedAccents.accent_2;
			return {
				background: safeHex( background ),
				text_color: safeHex( textColor ),
				accent_1: safeHex( accent1 ),
				accent_2: safeHex( accent2 )
			};
		};

		var submit = function (colors) {
			var fd = new FormData();
			fd.append( 'action', 'thespl_color_probe_submit' );
			fd.append( 'nonce', nonce );
			fd.append( 'session_id', sessionId );
			fd.append( 'token', token );
			fd.append( 'background', String( colors.background || '' ) );
			fd.append( 'text_color', String( colors.text_color || '' ) );
			fd.append( 'accent_1', String( colors.accent_1 || '' ) );
			fd.append( 'accent_2', String( colors.accent_2 || '' ) );
			fetch( ajaxUrl, { method: 'POST', credentials: 'same-origin', body: fd } )
				.finally( function () {
					try {
						renderDoneOverlay();
					} catch (eOverlay) {
					}
				} )
				.catch( function () {} );
		};

		window.setTimeout( function () {
			submit( extract() );
		}, 180 );
	} catch (e) {
	}
})();
