text: "use strict";
  /**
   * dd-elements.ts 4.2.7-dev
   * Copyright (c) 2021 Alain Dumesny - see GridStack root license
   */
  Object.defineProperty(exports, "__esModule", { value: true });
  exports.DDElement = void 0;
  const dd_resizable_1 = require("./dd-resizable");
  const dd_draggable_1 = require("./dd-draggable");
  const dd_droppable_1 = require("./dd-droppable");
  class DDElement {
      constructor(el) {
          this.el = el;
      }
      static init(el) {
          if (!el.ddElement) {
              el.ddElement = new DDElement(el);
          }
          return el.ddElement;
      }
      on(eventName, callback) {
          if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {
              this.ddDraggable.on(eventName, callback);
          }
          else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {
              this.ddDroppable.on(eventName, callback);
          }
          else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {
              this.ddResizable.on(eventName, callback);
          }
          return this;
      }
      off(eventName) {
          if (this.ddDraggable && ['drag', 'dragstart', 'dragstop'].indexOf(eventName) > -1) {
              this.ddDraggable.off(eventName);
          }
          else if (this.ddDroppable && ['drop', 'dropover', 'dropout'].indexOf(eventName) > -1) {
              this.ddDroppable.off(eventName);
          }
          else if (this.ddResizable && ['resizestart', 'resize', 'resizestop'].indexOf(eventName) > -1) {
              this.ddResizable.off(eventName);
          }
          return this;
      }
      setupDraggable(opts) {
          if (!this.ddDraggable) {
              this.ddDraggable = new dd_draggable_1.DDDraggable(this.el, opts);
          }
          else {
              this.ddDraggable.updateOption(opts);
          }
          return this;
      }
      cleanDraggable() {
          if (this.ddDraggable) {
              this.ddDraggable.destroy();
              delete this.ddDraggable;
          }
          return this;
      }
      setupResizable(opts) {
          if (!this.ddResizable) {
              this.ddResizable = new dd_resizable_1.DDResizable(this.el, opts);
          }
          else {
              this.ddResizable.updateOption(opts);
          }
          return this;
      }
      cleanResizable() {
          if (this.ddResizable) {
              this.ddResizable.destroy();
              delete this.ddResizable;
          }
          return this;
      }
      setupDroppable(opts) {
          if (!this.ddDroppable) {
              this.ddDroppable = new dd_droppable_1.DDDroppable(this.el, opts);
          }
          else {
              this.ddDroppable.updateOption(opts);
          }
          return this;
      }
      cleanDroppable() {
          if (this.ddDroppable) {
              this.ddDroppable.destroy();
              delete this.ddDroppable;
          }
          return this;
      }
  }
  exports.DDElement = DDElement;
  //# sourceMappingURL=dd-element.js.map