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 { MapToComponentField, MapToComponentMethod, VegaSlimmer } from 'vega-slimmer/core';
import { FORM_ELEMENT_VALUE_CHANGE } from '../../../../helpers/change-manager/subject/static-subject/static-subject-title';
import ChangeManager from '../../../../helpers/change-manager/change-manager';
/** The VegaImageUploaderValueController class is responsible for handling the value and change events of a VegaImageUploader component. */
export class VegaImageUploaderValueController extends VegaSlimmer {
  /** trigger a vegaChange event when component value change */
  handleValueChange() {
    if (!this.value) {
      this.inputController.resetInput();
    }
    this.changeEventEmitter.emit(this.value);
    ChangeManager.notify(FORM_ELEMENT_VALUE_CHANGE, {
      host: this.host,
      detail: this.value,
    });
  }
  /**
   * The function sets the value of a variable to either a VegaFile object or null.
   *
   * @param {VegaFile | null} value - The value parameter is of type VegaFile or null.
   */
  setValue(value) {
    this.value = value;
  }
}
__decorate([
  MapToComponentField({ writable: true })
], VegaImageUploaderValueController.prototype, "value", void 0);
__decorate([
  MapToComponentField()
], VegaImageUploaderValueController.prototype, "changeEventEmitter", void 0);
__decorate([
  MapToComponentField()
], VegaImageUploaderValueController.prototype, "host", void 0);
__decorate([
  MapToComponentField({ componentFieldName: 'vegaImageUploaderInputController' })
], VegaImageUploaderValueController.prototype, "inputController", void 0);
__decorate([
  MapToComponentMethod('watchValue')
], VegaImageUploaderValueController.prototype, "handleValueChange", null);
