/**
 * Copyright © Volker Schukai and all contributing authors, {{copyRightYear}}. All rights reserved.
 * Node module: @schukai/monster
 *
 * This source code is licensed under the GNU Affero General Public License version 3 (AGPLv3).
 * The full text of the license can be found at: https://www.gnu.org/licenses/agpl-3.0.en.html
 *
 * For those who do not wish to adhere to the AGPLv3, a commercial license is available.
 * Acquiring a commercial license allows you to use this software without complying with the AGPLv3 terms.
 * For more information about purchasing a commercial license, please contact Volker Schukai.
 *
 * SPDX-License-Identifier: AGPL-3.0
 */

import { instanceSymbol } from "../../constants.mjs";
import {
	assembleMethodSymbol,
	registerCustomElement,
} from "../../dom/customelement.mjs";
import { CustomElement } from "../../dom/customelement.mjs";
import { ControlBarSpacerStyleSheet } from "./stylesheet/control-bar-spacer.mjs";

export { ControlBarSpacer };

/**
 * A visual separator for monster-control-bar and monster-button-bar.
 *
 * @copyright Volker Schukai
 * @summary A non-interactive spacer that renders as a vertical separator in a control bar and as a horizontal separator in the overflow popper.
 */
class ControlBarSpacer extends CustomElement {
	/**
	 * This method is called by the `instanceof` operator.
	 * @return {symbol}
	 */
	static get [instanceSymbol]() {
		return Symbol.for(
			"@schukai/monster/components/form/control-bar-spacer@@instance",
		);
	}

	/**
	 * @return {Components.Form.ControlBarSpacer}
	 */
	[assembleMethodSymbol]() {
		super[assembleMethodSymbol]();
		this.setAttribute("aria-hidden", "true");
		return this;
	}

	/**
	 * @return {Object}
	 */
	get defaults() {
		return Object.assign({}, super.defaults, {
			templates: {
				main: getTemplate(),
			},
		});
	}

	/**
	 * @return {CSSStyleSheet[]}
	 */
	static getCSSStyleSheet() {
		return [ControlBarSpacerStyleSheet];
	}

	/**
	 * @return {string}
	 */
	static getTag() {
		return "monster-control-bar-spacer";
	}
}

/**
 * @private
 * @return {string}
 */
function getTemplate() {
	return `<div data-monster-role="separator" part="separator"></div>`;
}

registerCustomElement(ControlBarSpacer);
