import { I18nController as e } from "../internal/controllers/i18n.controller.js";
import { scopedRegistry as t } from "../internal/decorators/scoped-registry.js";
import { useStyles as n } from "../internal/styles/index.js";
import { __decorate as r } from "../_virtual/_@oxc-project_runtime@0.133.0/helpers/esm/decorate.js";
import { Icon as i } from "../icon/icon2.js";
import { Button as a } from "../button/button2.js";
import { Tooltip as o } from "../tooltip/tooltip2.js";
import { Toast as s } from "../toast/toast2.js";
import c from "./copy-button.js";
import { html as l, nothing as u } from "lit";
import { property as d } from "lit/decorators/property.js";
import { state as f } from "lit/decorators/state.js";
//#region src/copy-button/copy-button.ts
var p = class extends a {
	constructor(...t) {
		super(...t), this.copied = !1, this.showToast = !1, this.showTooltip = !1, this.#e = new e(this), this.i18n = this.#e.i18n, this.#t = () => {
			this.behaviorCopy && navigator.clipboard.writeText(this.value).then(() => {
				this.showToast = !0, this.copied = !0;
			}).catch((e) => {
				this.showToast = !1, console.error(e);
			});
		}, this.#r = () => {
			this.showTooltip = !0;
		}, this.#i = () => {
			this.showTooltip = !1;
		};
	}
	#e;
	static {
		this.styles = n([...a.styles, c]);
	}
	static {
		this.metadata = {
			tag: "nve-copy-button",
			version: "2.0.2"
		};
	}
	static {
		this.elementDefinitions = {
			[i.metadata.tag]: i,
			[s.metadata.tag]: s,
			[o.metadata.tag]: o
		};
	}
	render() {
		return l`<div id="btn" internal-host interaction-state focus-within><slot></slot>${this.copied ? l`<nve-icon part="icon" name="check" status="success" .size="${this.size}" aria-hidden="true"></nve-icon>` : l`<slot name="icon"><nve-icon part="icon" name="copy" .size="${this.size}" aria-hidden="true"></nve-icon></slot>`}</div>${this.showToast ? l`<nve-toast part="toast" @close="${this.#n}" status="success" anchor="btn" position="top" close-timeout="1500">${this.i18n.copied}</nve-toast>` : u} ${this.showTooltip && !this.showToast ? l`<nve-tooltip part="tooltip" exportparts="arrow:tooltip-arrow" anchor="btn">${this.ariaLabel ?? this.i18n.copy}</nve-tooltip>` : u}`;
	}
	connectedCallback() {
		super.connectedCallback(), this.addEventListener("click", this.#t), this.addEventListener("mouseenter", this.#r), this.addEventListener("mouseleave", this.#i);
	}
	disconnectedCallback() {
		super.disconnectedCallback(), this.removeEventListener("click", this.#t), this.removeEventListener("mouseenter", this.#r), this.removeEventListener("mouseleave", this.#i);
	}
	#t;
	#n() {
		this.showToast = !1, this.copied = !1, this.showTooltip = !1;
	}
	#r;
	#i;
};
r([f()], p.prototype, "copied", void 0), r([f()], p.prototype, "showToast", void 0), r([f()], p.prototype, "showTooltip", void 0), r([d({ type: Object })], p.prototype, "i18n", void 0), r([d({
	type: Boolean,
	reflect: !0,
	attribute: "behavior-copy"
})], p.prototype, "behaviorCopy", void 0), r([d({ type: String })], p.prototype, "value", void 0), p = r([t()], p);
//#endregion
export { p as CopyButton };

//# sourceMappingURL=copy-button2.js.map