var __decorate = (this && this.__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;
};
import { h } from '@stencil/core';
import { VegaSlimmer, MapToComponentField } from 'vega-slimmer/core';
import { DomNodeSubjectObserverFactory } from '../../../../helpers/change-manager/subject/dom-node-subject/dom-node-subject-observer-factory';
import { VegaClick } from '../../../../helpers/event-manager/event-id/vega-event-id';
import { FeatureFlag } from '../../../../helpers/feature-control/feature-flag-controller';
/** The `VegaBannerActionButtonRenderer` class in TypeScript React renders action buttons within a banner component. */
export class VegaBannerActionButtonRenderer extends VegaSlimmer {
  /**
   * rendering the action buttons within the banner component.
   *
   * @returns {Nullable<HTMLElement>} the action button element
   */
  render() {
    var _a;
    if (((_a = this.actionButtons) === null || _a === void 0 ? void 0 : _a.length) > 0) {
      return (h("div", { class: "banner-buttons" }, this.actionButtons.map((buttonProps, index) => {
        return this.renderButtonItem(buttonProps, `${buttonProps.label}${index}`);
      })));
    }
  }
  /**
   * This function renders a button component with specific properties and a click event handler.
   *
   * @param {VegaBannerActionButtonType} buttonProps button label and click callback
   * @param {string} key - unique key string
   * @returns {HTMLVegaButtonElement} vega button element
   */
  renderButtonItem(buttonProps, key) {
    return (h("vega-button", { key: key, size: "small", variant: "secondary", ref: (node) => {
        DomNodeSubjectObserverFactory.addUniqueObserverToNode(node, VegaClick, () => {
          if (!FeatureFlag.isEnabled('VEGA_BANNER_DEPRECATED_ACTION_BUTTON_PROP_VEGA_CLICK') &&
            typeof buttonProps.vegaClick === 'function') {
            buttonProps.vegaClick(buttonProps);
          }
          this.actionButtonClickEventEmitter.emit(buttonProps);
        });
      } }, buttonProps.label));
  }
}
__decorate([
  MapToComponentField()
], VegaBannerActionButtonRenderer.prototype, "actionButtons", void 0);
__decorate([
  MapToComponentField()
], VegaBannerActionButtonRenderer.prototype, "actionButtonClickEventEmitter", void 0);
