'use strict';

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

const index = require('./index-58ea899e.js');
const component = require('./component-1e352960.js');
const globalSlimmerRegistry = require('./global-slimmer-registry-b3bce7e0.js');
const componentUsageRuntimeMetrics = require('./component-usage-runtime-metrics-4572c5b7.js');
const changeManager = require('./change-manager-a297e4d2.js');
const staticSubjectTitle = require('./static-subject-title-5829a298.js');

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;
};
/** The `VegaFieldErrorMessageController` class is a TypeScript class that extends `VegaSlimmer` and is responsible for handling error messages for a field in a Vega component. */
class VegaFieldErrorMessageController extends globalSlimmerRegistry.VegaSlimmer {
  /**
   * call the method when the component prop message change
   */
  handleMessageChange() {
    this.notifyMessageUpdate();
  }
  /**
   * call the method when componentDidLoad
   */
  handleComponentDidLoad() {
    this.notifyMessageUpdate();
  }
  /**
   * The function `notifyMessageUpdate` notifies the change manager about a field error message change, providing the host and message as parameters.
   */
  notifyMessageUpdate() {
    changeManager.ChangeManager.notify(staticSubjectTitle.FIELD_ERROR_MESSAGE_CHANGE, {
      host: this.host,
      message: this.message,
      isValid: !this.message,
    });
  }
}
__decorate$1([
  globalSlimmerRegistry.MapToComponentField()
], VegaFieldErrorMessageController.prototype, "host", void 0);
__decorate$1([
  globalSlimmerRegistry.MapToComponentField()
], VegaFieldErrorMessageController.prototype, "message", void 0);
__decorate$1([
  globalSlimmerRegistry.MapToComponentMethod('watchMessage')
], VegaFieldErrorMessageController.prototype, "handleMessageChange", null);
__decorate$1([
  globalSlimmerRegistry.MapToComponentMethod('componentDidLoad')
], VegaFieldErrorMessageController.prototype, "handleComponentDidLoad", null);

const vegaFieldErrorCss = ":host{display:block}";

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 VegaFieldError = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.globalSlimmers = {};
    this.messageController = new VegaFieldErrorMessageController();
    this.vegaComponentUsageRuntimeMetricsSlimmer = new componentUsageRuntimeMetrics.VegaComponentUsageRuntimeMetricsSlimmer();
    /**
     * Specifies the error message when the input field should display an error.
     *    The input field will clear the error status when the message is empty.
     *
     * @vegaVersion 1.45.0
     */
    this.message = '';
  }
  watchMessage() {
  }
  render() {
    return component.sanitizeVegaComponent(index.h(index.Host, null, index.h("slot", null)), this.host);
  }
  get host() { return index.getElement(this); }
  static get watchers() { return {
    "message": ["watchMessage"]
  }; }
};
__decorate([
  componentUsageRuntimeMetrics.InjectVegaGlobalSlimmer()
], VegaFieldError.prototype, "globalSlimmers", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaFieldError.prototype, "messageController", void 0);
__decorate([
  globalSlimmerRegistry.InjectVegaSlimmer()
], VegaFieldError.prototype, "vegaComponentUsageRuntimeMetricsSlimmer", void 0);
VegaFieldError.style = vegaFieldErrorCss;

exports.vega_field_error = VegaFieldError;
