import HTMLStringTagsElement from "./string-tags.mjs";

/**
 * A custom HTMLElement used to render a tagged set of 2D grid offsets.
 */
export class HTMLGridOffset2DTagsElement extends HTMLStringTagsElement {

  /** @override */
  static tagName = "grid-offset-2d-tags";

  /** @override */
  static icons = {
    add: "fa-solid fa-square-plus",
    remove: "fa-solid fa-square-minus"
  };

  /** @override */
  static labels = {
    add: "ELEMENTS.TAGS.AddGridOffset",
    remove: "ELEMENTS.TAGS.RemoveGridOffset",
    placeholder: "i.j"
  };

  /* -------------------------------------------- */

  /** @override */
  _validateTag(tag) {
    if ( !/^(?:-?[1-9]\d*|0)\.(?:-?[1-9]\d*|0)$/.test(tag) ) throw new Error(_loc("ELEMENTS.TAGS.ErrorInvalidGridOffset2D"));
  }
}

/* -------------------------------------------- */

/**
 * A custom HTMLElement used to render a tagged set of 3D grid offsets.
 */
export class HTMLGridOffset3DTagsElement extends HTMLStringTagsElement {

  /** @override */
  static tagName = "grid-offset-3d-tags";

  /** @override */
  static icons = {
    add: "fa-solid fa-square-plus",
    remove: "fa-solid fa-square-minus"
  };

  /** @override */
  static labels = {
    add: "ELEMENTS.TAGS.AddGridOffset",
    remove: "ELEMENTS.TAGS.RemoveGridOffset",
    placeholder: "i.j.k"
  };

  /* -------------------------------------------- */

  /** @override */
  _validateTag(tag) {
    if ( !/^(?:-?[1-9]\d*|0)\.(?:-?[1-9]\d*|0)\.(?:-?[1-9]\d*|0)$/.test(tag) ) throw new Error(_loc("ELEMENTS.TAGS.ErrorInvalidGridOffset3D"));
  }
}

