var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __decorateClass = (decorators, target, key, kind) => {
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
  for (var i = decorators.length - 1, decorator; i >= 0; i--)
    if (decorator = decorators[i])
      result = (kind ? decorator(target, key, result) : decorator(result)) || result;
  if (kind && result) __defProp(target, key, result);
  return result;
};
/**
 * @license
 * Copyright 2025-2026 Open Home Foundation
 * SPDX-License-Identifier: Apache-2.0
 */
import "@material/web/button/text-button";
import "@material/web/dialog/dialog";
import { css, html, LitElement } from "lit";
import { customElement, property } from "lit/decorators.js";
import { preventDefault } from "../../util/prevent_default.js";
let DialogBox = class extends LitElement {
  render() {
    const params = this.params;
    return html`
            <md-dialog open @cancel=${preventDefault} @closed=${this._handleClosed}>
                ${params.title ? html`<div slot="headline">${params.title}</div>` : ""}
                ${params.text ? html`<div slot="content">
                          ${params.asCodeBlock && typeof params.text === "string" ? html`<code>${params.text}</code>` : params.text}
                      </div>` : ""}
                <div slot="actions">
                    ${this.type === "prompt" ? html`
                              <md-text-button @click=${this._cancel}>${params.cancelText ?? "Cancel"}</md-text-button>
                          ` : ""}
                    <md-text-button @click=${this._confirm}>${params.confirmText ?? "OK"}</md-text-button>
                </div>
            </md-dialog>
        `;
  }
  _cancel() {
    this._setResult(false);
  }
  _confirm() {
    this._setResult(true);
  }
  _setResult(result) {
    this.dialogResult(result);
    this.shadowRoot.querySelector("md-dialog").close();
  }
  _handleClosed() {
    this.parentElement.removeChild(this);
  }
};
DialogBox.styles = css`
        code {
            display: block;
            white-space: pre-wrap;
            word-break: break-all;
            overflow-y: auto;
            max-height: 60vh;
            font-size: 0.8rem;
            line-height: 1.4;
            padding: 8px;
            background-color: var(--md-sys-color-surface-container-highest);
            border-radius: 4px;
        }
    `;
__decorateClass([
  property({ attribute: false })
], DialogBox.prototype, "params", 2);
__decorateClass([
  property({ attribute: false })
], DialogBox.prototype, "dialogResult", 2);
__decorateClass([
  property()
], DialogBox.prototype, "type", 2);
DialogBox = __decorateClass([
  customElement("dialog-box")
], DialogBox);
export {
  DialogBox
};
//# sourceMappingURL=dialog-box.js.map
