'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-58ea899e.js');
const accessibility = require('./accessibility-a5ef2038.js');
const component = require('./component-1e352960.js');
const ui = require('./ui-3727d685.js');
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-4572c5b7.js');
const domNodeSubjectObserverFactory = require('./dom-node-subject-observer-factory-ba6a95f3.js');
const vegaEventId = require('./vega-event-id-d9994eb3.js');
require('./change-manager-a297e4d2.js');
require('./observer-f49483e8.js');

const vegaPageNotificationCss = ":host{display:inline-block;box-sizing:border-box;border-radius:12px;max-width:480px;box-shadow:0 4px 8px rgba(2, 2, 15, 0.1), 0 12px 20px rgba(2, 2, 15, 0.15);animation:fade-in-right 300ms ease-in-out}:host(.mobile){width:100%;max-width:100%;animation:fade-in-up 300ms ease-in-out}:host(.vega-page-notification-fade-out){opacity:0;animation:fade-out 300ms ease-in-out}:host vega-icon{color:rgba(var(--v-text-page-notification-content, 32, 54, 69, 1))}:host .vega-page-notification-prefix{display:flex}:host(.mobile) .vega-page-notification-prefix{padding-top:4px}:host .vega-page-notification-content{flex:1 1 0%;overflow:auto}:host .vega-page-notification-close-btn{cursor:pointer;display:inline-flex;margin-top:4px}:host(.mobile) .vega-page-notification-close-btn{padding:2px}:host .vega-page-notification-actions-container{display:flex;align-items:flex-end;flex-wrap:wrap;gap:16px;justify-content:flex-end;margin-top:24px}:host(.mobile) .vega-page-notification-actions-container{margin-top:16px}:host .vega-page-notification-title{color:rgba(var(--v-text-page-notification-content, 32, 54, 69, 1));font-family:\"Inter\", sans-serif;font-size:20px;font-weight:700;line-height:28px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-page-notification-title{font-family:\"Inter\", sans-serif;font-size:20px;font-weight:700;line-height:28px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-page-notification-title{font-family:\"Inter\", sans-serif;font-size:20px;font-weight:700;line-height:28px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-page-notification-title{font-family:\"Inter\", sans-serif;font-size:20px;font-weight:700;line-height:28px;letter-spacing:0px}}:host(.mobile) .vega-page-notification-title{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:25px;letter-spacing:0px;overflow-wrap:break-word}@media screen and (min-width: 768px) and (max-width: 1023px){:host(.mobile) .vega-page-notification-title{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:25px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host(.mobile) .vega-page-notification-title{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:25px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host(.mobile) .vega-page-notification-title{font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:25px;letter-spacing:0px}}:host .vega-page-notification-message{color:rgba(var(--v-text-page-notification-content, 32, 54, 69, 1));font-family:\"Inter\", sans-serif;font-size:18px;font-weight:500;line-height:28px;letter-spacing:0px;overflow-wrap:break-word;margin-top:2px}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-page-notification-message{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-page-notification-message{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-page-notification-message{font-family:\"Inter\", sans-serif;font-size:16px;font-weight:500;line-height:22px;letter-spacing:0px}}:host(.mobile) .vega-page-notification-message{font-family:\"Inter\", sans-serif;font-size:14px;font-weight:400;line-height:20px;letter-spacing:0px}@media screen and (min-width: 768px) and (max-width: 1023px){:host(.mobile) .vega-page-notification-message{font-family:\"Inter\", sans-serif;font-size:12px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host(.mobile) .vega-page-notification-message{font-family:\"Inter\", sans-serif;font-size:12px;font-weight:400;line-height:18px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host(.mobile) .vega-page-notification-message{font-family:\"Inter\", sans-serif;font-size:12px;font-weight:400;line-height:18px;letter-spacing:0px}}:host .vega-page-notification-actions-container vega-button::part(button):hover,:host .vega-page-notification-actions-container vega-button::part(button){font-family:\"Inter\", sans-serif;font-size:18px;font-weight:700;line-height:24px;letter-spacing:0px;background-color:rgba(var(--v-bg-transparent, 0, 0, 0, 0));color:rgba(var(--v-text-page-notification-content, 32, 54, 69, 1));border:2px solid rgba(var(--v-text-page-notification-content, 32, 54, 69, 1))}@media screen and (min-width: 768px) and (max-width: 1023px){:host .vega-page-notification-actions-container vega-button::part(button):hover,:host .vega-page-notification-actions-container vega-button::part(button){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:700;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1024px) and (max-width: 1439px){:host .vega-page-notification-actions-container vega-button::part(button):hover,:host .vega-page-notification-actions-container vega-button::part(button){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:700;line-height:24px;letter-spacing:0px}}@media screen and (min-width: 1440px) and (max-width: 9999px){:host .vega-page-notification-actions-container vega-button::part(button):hover,:host .vega-page-notification-actions-container vega-button::part(button){font-family:\"Inter\", sans-serif;font-size:16px;font-weight:700;line-height:24px;letter-spacing:0px}}:host(.success){background-color:rgba(var(--v-bg-status-success, 160, 233, 167, 1))}:host(.warning){background-color:rgba(var(--v-bg-status-warning, 255, 220, 131, 1))}:host(.error){background-color:rgba(var(--v-bg-status-error, 255, 110, 139, 1))}:host(.info){background-color:rgba(var(--v-bg-status-info, 205, 209, 211, 1))}.vega-page-notification-list{display:flex;flex-direction:column;align-items:flex-end;position:fixed}.vega-page-notification-list-topRight{top:24px;right:24px}.vega-page-notification-list-bottom{left:0px;right:0px;padding-left:16px;padding-right:16px;align-items:center;bottom:0px}@keyframes fade-in-right{from{opacity:0;transform:translateX(100%)}to{opacity:1;transform:none}}@keyframes fade-in-up{from{opacity:0;transform:translateY(100%)}to{opacity:1;transform:none}}@keyframes fade-out{from{opacity:1}to{opacity:0}}";

var __decorate$1 = (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;
};
const typeIconMap = {
  success: 'checkmark-circle',
  warning: 'warning-triangle-filled',
  error: 'help-filled',
  info: 'info-circle-filled',
};
const VegaPageNotification = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.globalSlimmers = {};
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.VegaComponentUsageRuntimeMetricsSlimmer();
    this.isMobileDevice = ui.getDeviceType() === ui.DeviceType.MOBILE;
    /**
     * Specifies the title text for the page notification.
     *
     * It provides users with a concise and informative message
     *    that communicates the purpose or nature of the notification.
     *
     * @vegaVersion 1.17.0
     */
    this.notificationTitle = '';
    /**
     * Specifies the content text for the page notification.
     *
     * It provides a detailed message or information that
     *    further explains the purpose or context of
     *    the notification.
     *
     * @vegaVersion 1.17.0
     */
    this.message = '';
    /**
     * Specifies the type of page notification,
     *    indicating the visual style or category of
     *    the notification.
     *
     * @vegaVersion 1.17.0
     */
    this.type = 'info';
    /**
     * Specifies the duration, in milliseconds, before the
     *    page notification automatically closes.
     *
     * If the duration is set to `0`, the notification will not
     *    close automatically.
     *
     * @vegaVersion 1.17.0
     */
    this.duration = 5000;
    /**
     * Specifies whether to display the close button for
     *    the page notification.
     *
     * @vegaVersion 1.17.0
     */
    this.showCloseButton = true;
    /**
     * Specifies the configuration array for the action buttons of
     *    the page notification.
     *
     * The action buttons provide interactive options for users to
     *    perform specific actions or operations related to
     *    the notification.
     *
     * @vegaVersion 1.17.0
     */
    this.actionButtons = [];
    this.renderPrefixIcon = () => {
      return (index.h("div", { class: "vega-page-notification-prefix" }, index.h("vega-icon", { icon: typeIconMap[this.type], size: this.isMobileDevice ? 'size-16' : 'size-24' })));
    };
    this.renderContent = () => {
      return (index.h("div", { class: "vega-page-notification-content" }, this.notificationTitle && (index.h("div", { class: "vega-page-notification-title" }, this.notificationTitle)), index.h("div", { class: "vega-page-notification-message" }, this.message)));
    };
    this.autoCloseAfterDuration = () => {
      if (this.duration > 0) {
        setTimeout(() => {
          void this.close();
        }, this.duration);
      }
    };
  }
  componentDidLoad() {
    this.autoCloseAfterDuration();
  }
  /**
   * Invoke this method to close the page notification.
   *
   * @vegaVersion 1.17.0
   */
  async close() {
    this.host.classList.add('vega-page-notification-fade-out');
    setTimeout(() => {
      this.host.remove();
    }, 300);
  }
  render() {
    const classNames = ui.arrayToClassString([this.type, this.isMobileDevice && 'mobile'].filter(Boolean));
    return component.sanitizeVegaComponent(index.h(index.Host, { class: classNames }, index.h("vega-box", { padding: this.isMobileDevice ? 'size-16' : 'size-24' }, index.h("vega-flex", { gap: "size-16" }, this.renderPrefixIcon(), this.renderContent(), this.renderCloseButtons()), this.renderActionButtons())), this.host);
  }
  renderCloseButtons() {
    if (!this.showCloseButton)
      return;
    return (index.h("div", { "aria-label": "Close Button", class: "vega-page-notification-close-btn",
      /* eslint-disable-next-line react/jsx-no-bind */
      onClick: () => this.close(), role: 'button', tabIndex: 0, onKeyDown: accessibility.createEnterKeyHandlerToTriggerClick() }, index.h("vega-icon", { icon: "close", size: this.isMobileDevice ? 'size-12' : 'size-16' })));
  }
  renderActionButtons() {
    if (!this.actionButtons || this.actionButtons.length === 0)
      return;
    return (index.h("div", { class: "vega-page-notification-actions-container" }, this.actionButtons.map((actionButton) => (index.h("vega-button", { size: this.isMobileDevice ? 'small' : 'default', label: actionButton.label, variant: "secondary", ref: (ref) => {
        domNodeSubjectObserverFactory.DomNodeSubjectObserverFactory.addUniqueObserverToNode(ref, vegaEventId.VegaClick, actionButton.onVegaClick);
      } })))));
  }
  get host() { return index.getElement(this); }
};
__decorate$1([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaPageNotification.prototype, "globalSlimmers", void 0);
__decorate$1([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaPageNotification.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaPageNotification.style = vegaPageNotificationCss;

const vegaPageNotificationListCss = ":host{position:fixed;display:flex;flex-direction:column;align-items:flex-end}:host(.vega-page-notification-list-topRight){top:24px;right:24px}:host(.vega-page-notification-list-bottom){align-items:center;padding-left:16px;padding-right:16px;left:0px;right:0px;bottom:0px}";

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;
};
const VegaPageNotificationList = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.globalSlimmers = {};
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.VegaComponentUsageRuntimeMetricsSlimmer();
  }
  render() {
    return (index.h(index.Host, null, index.h("slot", null)));
  }
  get host() { return index.getElement(this); }
};
__decorate([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaPageNotificationList.prototype, "globalSlimmers", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaPageNotificationList.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaPageNotificationList.style = vegaPageNotificationListCss;

exports.vega_page_notification = VegaPageNotification;
exports.vega_page_notification_list = VegaPageNotificationList;
