var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: !0 });
import { u as uuidv4 } from "./chunk.dcf-utility.js?v=6.1.1";
import { D as DCFButtonToggles } from "./chunk.dcf-button-toggle.js?v=6.1.1";
class DCFFigcaptionToggles {
  static {
    __name(this, "DCFFigcaptionToggles");
  }
  uuid = uuidv4();
  figcaption = null;
  figure = null;
  toggleButton = null;
  toggleButtonInnerHTML = `<svg class="dcf-h-4 dcf-w-4 dcf-fill-current"
        width="24" height="24" viewBox="0 0 24 24" focusable="false" aria-hidden="true">
    <path class="dcf-btn-toggle-figcaption-icon-open"
        d="M1,3h19c0.6,0,1-0.4,1-1c0-0.6-0.4-1-1-1H1C0.4,1,0,1.4,0,2C0,2.6,0.4,3,1,3z"/>
        '<path class="dcf-btn-toggle-figcaption-icon-open"
        d="M1,8h15c0.6,0,1-0.4,1-1c0-0.6-0.4-1-1-1H1C0.4,6,0,6.4,0,7C0,7.6,0.4,8,1,8z"/>
    <path class="dcf-btn-toggle-figcaption-icon-close-1"
        d="M1,13h22c0.6,0,1-0.4,1-1c0-0.6-0.4-1-1-1H1c-0.6,0-1,0.4-1,1C0,12.6,0.4,13,1,13z"/>
    <path class="dcf-btn-toggle-figcaption-icon-close-2"
        d="M1,13h22c0.6,0,1-0.4,1-1c0-0.6-0.4-1-1-1H1c-0.6,0-1,0.4-1,1C0,12.6,0.4,13,1,13z"/>
    <path class="dcf-btn-toggle-figcaption-icon-open"
        d="M1,18h18c0.6,0,1-0.4,1-1c0-0.6-0.4-1-1-1H1c-0.6,0-1,0.4-1,1C0,17.6,0.4,18,1,18z"/>
    <path class="dcf-btn-toggle-figcaption-icon-open"
        d="M1,23h15c0.6,0,1-0.4,1-1c0-0.6-0.4-1-1-1H1c-0.6,0-1,0.4-1,1C0,22.6,0.4,23,1,23z"/>
</svg>`;
  toggleButtonClassList = [
    "dcf-btn",
    "dcf-btn-inverse-tertiary",
    "dcf-absolute",
    "dcf-z-1",
    "dcf-d-flex",
    "dcf-ai-center",
    "dcf-white",
    "dcf-btn-toggle-figcaption"
  ];
  figcaptionClassList = [
    "dcf-absolute",
    "dcf-left-0",
    "dcf-top-0",
    "dcf-h-100%",
    "dcf-w-100%",
    "dcf-z-1",
    "dcf-figcaption-toggle"
  ];
  toggleKeys = [];
  onKeys = [];
  offKeys = [];
  // Set up the button
  constructor(figcaption, options = {}) {
    if (Array.isArray(options.toggleKeys) ? this.toggleKeys = [...options.toggleKeys] : options.toggleKeys !== null && options.toggleKeys !== void 0 && options.toggleKeys !== "" && this.toggleKeys.push(options.toggleKeys), Array.isArray(options.onKeys) ? this.onKeys = [...options.onKeys] : options.onKeys !== null && options.onKeys !== void 0 && options.onKeys !== "" && this.onKeys.push(options.onKeys), Array.isArray(options.offKeys) ? this.offKeys = [...options.offKeys] : options.offKeys !== null && options.offKeys !== void 0 && options.offKeys !== "" && this.offKeys.push(options.offKeys), "toggleButtonInnerHTML" in options && typeof options.toggleButtonInnerHTML == "string" && (this.toggleButtonInnerHTML = options.toggleButtonInnerHTML), "toggleButtonClassList" in options && Array.isArray(options.toggleButtonClassList) && (this.toggleButtonClassList = options.toggleButtonClassList), "figcaptionClassList" in options && Array.isArray(options.figcaptionClassList) && (this.figcaptionClassList = options.figcaptionClassList), this.figcaption = figcaption, this.figure = this.figcaption.parentElement, this.figure !== null && this.figure.tagName !== "FIGURE")
      throw new Error("Figcaption-Toggle Missing Figure Tag Parent");
    this.figure.classList.add("dcf-relative"), (this.figcaption.getAttribute("id") === "" || this.figcaption.getAttribute("id") === null) && this.figcaption.setAttribute("id", this.uuid.concat("-figcaption-toggle")), this.figcaptionClassList && this.figcaptionClassList.forEach((cssClass) => {
      this.figcaption.classList.add(cssClass);
    }), this.toggleButton = document.createElement("button"), this.toggleButton.dataset.controls = this.figcaption.getAttribute("id"), this.toggleButton.dataset.labelOn = "Show caption", this.toggleButton.dataset.labelOff = "Hide caption", this.toggleButton.dataset.startExpanded = "false", this.toggleButton.innerHTML = this.toggleButtonInnerHTML, this.toggleButtonClassList && this.toggleButtonClassList.forEach((cssClass) => {
      this.toggleButton.classList.add(cssClass);
    }), this.figure.appendChild(this.toggleButton), new DCFButtonToggles(this.toggleButton, {
      toggleKeys: this.toggleKeys,
      onKeys: this.onKeys,
      offKeys: this.offKeys
    }), this.figcaption.classList.add("dcf-figcaption-toggle-initialized"), this.figcaption.removeAttribute("hidden"), this.figcaption.dispatchEvent(new CustomEvent(DCFFigcaptionToggles.events("figcaptionToggleReady"), {
      detail: {
        classInstance: this
      }
    }));
  }
  // The names of the events to be used easily
  static events(name) {
    const events = {
      figcaptionToggleReady: "figcaptionToggleReady"
    };
    return Object.freeze(events), DCFButtonToggles.events(name) !== void 0 ? DCFButtonToggles.events(name) : name in events ? events[name] : void 0;
  }
}
export {
  DCFFigcaptionToggles as D
};
//# sourceMappingURL=chunk.dcf-figcaption-toggle.js.map
