/**
 * Copyright IBM Corp. 2026
 *
 * This source code is licensed under the Apache-2.0 license found in the
 * LICENSE file in the root directory of this source tree.
 */

import "../../globals/settings.js";
import { carbonElement } from "../../globals/decorators/carbon-element.js";
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.126.0/helpers/decorate.js";
import { POPOVER_ALIGNMENT } from "../popover/defs.js";
import popover_default from "../popover/popover.scss.js";
import tooltip_default from "./tooltip.scss.js";
import "../popover/index.js";
import { LitElement, adoptStyles, html } from "lit";
import { property, state } from "lit/decorators.js";
//#region src/components/tooltip/definition-tooltip.ts
/**
* Copyright IBM Corp. 2019, 2024
*
* This source code is licensed under the Apache-2.0 license found in the
* LICENSE file in the root directory of this source tree.
*/
/**
* Definition tooltip.
*
* @element cds-definition-tooltip
*/
let CDSDefinitionTooltip = class CDSDefinitionTooltip extends LitElement {
	constructor(..._args) {
		super(..._args);
		this.align = "bottom";
		this.autoalign = false;
		this.defaultOpen = false;
		this.openOnHover = false;
		this.open = false;
	}
	connectedCallback() {
		super.connectedCallback();
		adoptStyles(this.renderRoot, [popover_default, tooltip_default]);
		if (this.hasAttribute("default-open")) this.open = true;
	}
	_handleBlur() {
		this.open = false;
	}
	_handleMouseDown() {
		this.open = !this.open;
	}
	_handleKeyDown(event) {
		const { key } = event;
		if (this.open && (key === "Esc" || key === "Escape")) {
			event.stopPropagation();
			this.open = false;
		}
	}
	_handleHover() {
		if (this.openOnHover && !this.open) this.open = true;
		else this.open = false;
	}
	_handleFocus() {
		this.open = true;
	}
	render() {
		const { align, open } = this;
		return html`
      <cds-popover
        @mouseenter=${this._handleHover}
        @mouseleave=${this._handleHover}
        highContrast
        dropShadow=${false}
        align=${align}
        .open=${open}>
        <button
          @focus=${this._handleFocus}
          @blur=${this._handleBlur}
          @mousedown=${this._handleMouseDown}
          @keydown=${this._handleKeyDown}
          aria-expanded=${open}
          part="definition-term"
          class="${"cds"}--definition-term">
          <slot></slot>
        </button>
        <cds-popover-content>
          <slot name="definition"></slot>
        </cds-popover-content>
      </cds-popover>
    `;
	}
	static {
		this.styles = tooltip_default;
	}
};
__decorate([property({
	reflect: true,
	type: POPOVER_ALIGNMENT
})], CDSDefinitionTooltip.prototype, "align", void 0);
__decorate([property({
	type: Boolean,
	reflect: true
})], CDSDefinitionTooltip.prototype, "autoalign", void 0);
__decorate([property({
	type: Boolean,
	reflect: true,
	attribute: "default-open"
})], CDSDefinitionTooltip.prototype, "defaultOpen", void 0);
__decorate([property({
	reflect: true,
	type: Boolean,
	attribute: "open-on-hover"
})], CDSDefinitionTooltip.prototype, "openOnHover", void 0);
__decorate([state()], CDSDefinitionTooltip.prototype, "open", void 0);
CDSDefinitionTooltip = __decorate([carbonElement(`cds-definition-tooltip`)], CDSDefinitionTooltip);
var definition_tooltip_default = CDSDefinitionTooltip;
//#endregion
export { definition_tooltip_default as default };

//# sourceMappingURL=definition-tooltip.js.map