import { MediaElement } from "../media-element.js";
import { alertDialogContext } from "./context.js";
import { applyElementProps, applyStateDataAttrs, createButton } from "@videojs/core/dom";
import { ContextConsumer } from "@videojs/element/context";

//#region src/ui/alert-dialog/alert-dialog-close-element.ts
var AlertDialogCloseElement = class extends MediaElement {
	constructor(..._args) {
		super(..._args);
		this.disabled = false;
	}
	static {
		this.tagName = "media-alert-dialog-close";
	}
	static {
		this.properties = { disabled: { type: Boolean } };
	}
	#ctx = new ContextConsumer(this, {
		context: alertDialogContext,
		subscribe: true
	});
	#disconnect = null;
	connectedCallback() {
		super.connectedCallback();
		this.#disconnect = new AbortController();
		const buttonProps = createButton({
			onActivate: () => this.#ctx.value?.close(),
			isDisabled: () => this.disabled
		});
		applyElementProps(this, buttonProps, { signal: this.#disconnect.signal });
	}
	disconnectedCallback() {
		super.disconnectedCallback();
		this.#disconnect?.abort();
		this.#disconnect = null;
	}
	update(_changed) {
		super.update(_changed);
		const ctx = this.#ctx.value;
		if (ctx) applyStateDataAttrs(this, ctx.state, ctx.stateAttrMap);
	}
};

//#endregion
export { AlertDialogCloseElement };
//# sourceMappingURL=alert-dialog-close-element.js.map