import { createElement as $el, getClosestOrSelf, setAttributes } from "./utils_dom.js"; export class RgthreeDialog extends EventTarget { constructor(options) { super(); this.options = options; let container = $el("div.rgthree-dialog-container"); this.element = $el("dialog", { classes: ["rgthree-dialog", options.class || ""], child: container, parent: document.body, events: { click: (event) => { if (!this.element.open || event.target === container || getClosestOrSelf(event.target, `.rgthree-dialog-container`) === container) { return; } return this.close(); }, }, }); this.element.addEventListener("close", (event) => { this.onDialogElementClose(); }); this.titleElement = $el("div.rgthree-dialog-container-title", { parent: container, children: !options.title ? null : options.title instanceof Element || Array.isArray(options.title) ? options.title : typeof options.title === "string" ? !options.title.includes(" { var _a; (_a = button.callback) === null || _a === void 0 ? void 0 : _a.call(button, e); }, }, }); } if (options.closeButtonLabel !== false) { $el("button", { text: options.closeButtonLabel || "Close", className: "rgthree-button", parent: footerEl, events: { click: (e) => { this.close(e); }, }, }); } } setTitle(content) { const title = typeof content !== "string" || content.includes("by rgthree"); const options = Object.assign({}, opts, { class: "-iconed -help", title, content, }); super(options); } }