var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
import { u as uuidv4 } from "../chunks/chunk.dcf-utility.js?v=6.1.1";
class DCFCardAsLink {
  static {
    __name(this, "DCFCardAsLink");
  }
  uuid = uuidv4();
  card = null;
  link = null;
  mouseDown = 0;
  mouseUp = 0;
  cursorStyle = "pointer";
  clickThresholdMs = 200;
  // Set up the Card as Link component
  constructor(card) {
    this.card = card, (this.card.getAttribute("id") === "" || this.card.getAttribute("id") === null) && this.card.setAttribute("id", this.uuid.concat("-card-as-link")), this.link = card.querySelector(".dcf-card-link"), (this.link.getAttribute("id") === "" || this.link.getAttribute("id") === null) && this.link.setAttribute("id", this.uuid.concat("-card-as-link-link")), this.link && (this.card.addEventListener("mousedown", (event) => {
      event.button === 0 && (this.mouseDown = Number(/* @__PURE__ */ new Date()));
    }), this.card.addEventListener("mouseup", (event) => {
      event.button === 0 && (this.mouseUp = Number(/* @__PURE__ */ new Date()), this.mouseUp - this.mouseDown < this.clickThresholdMs && this.link.click());
    }), this.card.style.cursor = this.cursorStyle), this.card.classList.add("dcf-card-as-link-initialized"), this.card.removeAttribute("hidden"), this.card.dispatchEvent(new CustomEvent(DCFCardAsLink.events("cardAsLinkReady"), {
      detail: {
        classInstance: this
      }
    }));
  }
  // The names of the events to be used easily
  static events(name) {
    const events = {
      cardAsLinkReady: "cardAsLinkReady"
    };
    return Object.freeze(events), name in events ? events[name] : void 0;
  }
}
class UNLCardAsLink extends DCFCardAsLink {
  static {
    __name(this, "UNLCardAsLink");
  }
  constructor(card, options = {}) {
    super(card, options), window.UNL = window.UNL || {}, window.UNL.classes = window.UNL.classes || {}, window.UNL.classes[this.card.getAttribute("id")] = this, window.UNL.classes[this.link.getAttribute("id")] = this, this.card.dispatchEvent(new Event("UNLClassReady")), this.link.dispatchEvent(new Event("UNLClassReady"));
  }
}
export {
  UNLCardAsLink as default
};
//# sourceMappingURL=component.card-as-link.js.map
