function applyCSSProperties(cssProperties, options = {}) {
	// @TODO: clean up deprecated argument handling
	/** @type {HTMLElement} */
	let element;
	/** @type {boolean} */
	let recurseIntoIframes;
	if ("tagName" in options) {
		console.warn("deprecated: use options argument to applyCSSProperties, e.g. applyCSSProperties(cssProperties, { element: document.documentElement, recurseIntoIframes: true })");
		element = options;
		recurseIntoIframes = false;
	} else {
		({ element = document.documentElement, recurseIntoIframes = false } = options);
	}

	/**
	 * @param {string} propName 
	 * @returns {string}
	 */
	var getProp = (propName) => typeof cssProperties.getPropertyValue === "function" ? cssProperties.getPropertyValue(propName) : /** @type {Record<string, string>} */(cssProperties)[propName];
	for (var k in cssProperties) {
		element.style.setProperty(k, getProp(k));
	}
	// iframe theme propagation
	if (recurseIntoIframes) {
		var iframes = element.querySelectorAll("iframe");
		for (var i = 0; i < iframes.length; i++) {
			try {
				applyCSSProperties(cssProperties, { element: iframes[i].contentDocument?.documentElement, recurseIntoIframes: true });
			} catch (error) {
				// ignore
				// @TODO: share warning with $Window's iframe handling
			}
		}
	}
}
@param {Record<string, string> | CSSStyleDeclaration} cssProperties
@param {{ element?: HTMLElement, recurseIntoIframes?: boolean } | HTMLElement} [options]