import { settings } from "../settings.js"; const styles = ["purple", "gray", "red", "green", "yellow", "blue"]; class DevToolbarToggle extends HTMLElement { shadowRoot; input; _toggleStyle = "gray"; get toggleStyle() { return this._toggleStyle; } set toggleStyle(value) { if (!styles.includes(value)) { settings.logger.error(`Invalid style: ${value}, expected one of ${styles.join(", ")}.`); return; } this._toggleStyle = value; this.updateStyle(); } static observedAttributes = ["toggle-style"]; constructor() { super(); this.shadowRoot = this.attachShadow({ mode: "open" }); this.shadowRoot.innerHTML = ` `; this.input = document.createElement("input"); } attributeChangedCallback() { if (this.hasAttribute("toggle-style")) this.toggleStyle = this.getAttribute("toggle-style"); } updateStyle() { const style = this.shadowRoot.querySelector("#selected-style"); if (style) { style.innerHTML = ` :host { --bg-on: var(--${this.toggleStyle}-bg-on); --border-off: var(--${this.toggleStyle}-border-off); --border-on: var(--${this.toggleStyle}-border-on); } `; } } connectedCallback() { this.input.type = "checkbox"; this.shadowRoot.append(this.input); this.updateStyle(); } get value() { return this.input.value; } set value(val) { this.input.value = val; } } export { DevToolbarToggle };