import { g as generateUUID } from './misc-9fdbcfbb.js';
import './global-slimmer-registry-17c4efd4.js';
import { I as InjectVegaTelemetrySlimmer, c as createPublicAPIRuntimeMetricsSlimmer } from './create-public-api-runtime-metrics-slimmer-da6615bf.js';

const VegaDialogRuntimeMetricsPayloadDefinition = [
  {
    payloadKey: 'IS_OPEN_METHOD_CALLED',
    payloadDescription: 'Indicate if the method open of public API VegaDialogController is called',
    /**
     * Indicate whether the method is collected when the method been called .
     *
     * @param {string} scope - The class name of public api
     * @param {string} methodName - The method name called by the public api
     * @returns {boolean} A boolean value
     */
    canAccept: (scope, methodName) => scope === 'VegaDialogController' && methodName === 'open',
    /**
     * The function checks if the method name is open.
     *
     * @returns {boolean} A boolean value
     */
    payloadValue: () => {
      return true;
    },
  },
];

var __decorate = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __rest = (undefined && undefined.__rest) || function (s, e) {
  var t = {};
  for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
    t[p] = s[p];
  if (s != null && typeof Object.getOwnPropertySymbols === "function")
    for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
      if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
        t[p[i]] = s[p[i]];
    }
  return t;
};
/**
 * The dialog controller
 */
class VegaDialogController {
  constructor() {
    this.vegaPublicAPIRuntimeMetricsSlimmer = createPublicAPIRuntimeMetricsSlimmer(VegaDialogController, ['open'], VegaDialogRuntimeMetricsPayloadDefinition);
  }
  /**
   *
   * It creates a new `vega-dialog` element, sets its properties, appends it to the DOM, and opens it
   *
   * @param {VegaDialogOption} options - VegaDialogOption
   * @returns {HTMLVegaDialogElement} The dialog reference.
   * @vegaVersion 1.24.0
   */
  open(options) {
    // eslint-disable-next-line no-restricted-globals
    const dialog = document.createElement('vega-dialog');
    const { isVerticallyCenter, isVerticallyCentered, showCloseButton, size, title, handleClose } = options, dialogProps = __rest(options, ["isVerticallyCenter", "isVerticallyCentered", "showCloseButton", "size", "title", "handleClose"]);
    dialog.id = `vega-dialog-${generateUUID()}`;
    dialog.dialogTitle = title;
    dialog.modalProps = { isVerticallyCenter, isVerticallyCentered, showCloseButton, size, handleClose };
    Object.keys(dialogProps).forEach((propName) => {
      if (dialogProps[propName] !== undefined) {
        dialog[propName] = dialogProps[propName];
      }
    });
    // eslint-disable-next-line no-restricted-globals
    document.body.append(dialog);
    return dialog;
  }
}
__decorate([
  InjectVegaTelemetrySlimmer()
], VegaDialogController.prototype, "vegaPublicAPIRuntimeMetricsSlimmer", void 0);
const VegaDialog = new VegaDialogController();

export { VegaDialog as V };
