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, VegaSlimmer } from 'vega-slimmer/core';
import jqueryDelegatedStrategyController from '../../event-delegated/jquery-delegated-strategy-controller';
/** The `JqueryDelegatedEventEmitHandlerSlimmer` class is a TypeScript class that handles emitting delegated events using jQuery. */
export class JqueryDelegatedEventEmitHandlerSlimmer extends VegaSlimmer {
  constructor() {
    super(...arguments);
    /**
     * The function determines whether a jQuery delegated event should be emitted based on certain conditions.
     *
     * @param {EventSemantics} namespace the event semantics namespace
     * @returns {boolean} The function shouldEmitJqueryDelegatedEvent() returns a boolean value.
     */
    this.canHandle = ({ namespace, jqueryDelegatedEvent }) => {
      return (namespace === 'native' &&
        !!jqueryDelegatedEvent &&
        jqueryDelegatedStrategyController.isSupportDelegated(this.host, this.eventID));
    };
    /**
     * The function emits a delegated event with a given detail using a jQuery delegated event slimmer.
     *
     * @param {unknown} detail - The `detail` parameter is a generic type `T` that represents additional
     * information or data associated with the event. It can be any type of data that you want to pass
     * along with the event when it is emitted.
     * @param {Event} [e] the event object
     * @returns {Nullable<Event>} The emitted event.
     */
    this.handle = (detail, e) => {
      const strategy = jqueryDelegatedStrategyController.getStrategy(this.host, this.eventID);
      if (strategy) {
        if (e) {
          e.stopPropagation();
        }
        return strategy.handle(this.host, detail);
      }
    };
  }
  /**
   * The function "setEventID" sets the eventID property of the current object to the provided VegaEventID value.
   *
   * @param {VegaEventID} eventID - The eventID parameter is of type VegaEventID.
   */
  setEventID(eventID) {
    this.eventID = eventID;
  }
}
__decorate([
  MapToComponentField()
], JqueryDelegatedEventEmitHandlerSlimmer.prototype, "host", void 0);
