import { defineComponent as O, useAttrs as T, useSlots as _, computed as t, openBlock as s, createBlock as b, resolveDynamicComponent as w, mergeProps as R, unref as o, withCtx as m, createTextVNode as k, toDisplayString as r, createCommentVNode as y, renderSlot as x, createElementBlock as n } from "vue";
import { uniqueId as f } from "es-toolkit/compat";
import { _ as q } from "./Label.vue_vue_type_script_setup_true_lang-WIpehdiu.js";
const S = ["id"], D = {
  key: 2,
  class: "stash-field-hint mt-1 block whitespace-pre-line text-xs",
  "data-test": "stash-field-hint"
}, E = {
  key: 3,
  class: "stash-field-hint mt-1 whitespace-pre-line text-xs",
  "data-test": "stash-field-hint"
}, C = /* @__PURE__ */ O({
  inheritAttrs: !1,
  __name: "Field",
  props: {
    addBottomSpace: { type: Boolean, default: !1 },
    errorText: { default: void 0 },
    hintText: { default: void 0 },
    id: { default: void 0 },
    errorId: { default: void 0 },
    isReadOnly: { type: Boolean },
    isRequired: { type: Boolean, default: !1 },
    label: { default: void 0 },
    showOptionalInLabel: { type: Boolean, default: !1 },
    isLabelSrOnly: { type: Boolean, default: !1 },
    fieldset: { type: Boolean, default: !1 },
    isDisabled: { type: Boolean, default: !1 },
    disabled: { type: Boolean, default: !1 }
  },
  setup(l) {
    const e = l, v = T(), a = _(), h = t(() => e.id || f("stash-field-")), u = t(() => e.errorId || f("stash-field-error-")), c = t(() => f("stash-field-label-")), i = t(() => !!e.errorText), B = t(() => e.fieldset ? "fieldset" : "div"), I = t(() => {
      const { placeholder: d, ...p } = v;
      return p;
    });
    return (d, p) => (s(), b(w(B.value), R({
      "data-test": "stash-field",
      class: ["stash-field", [
        { "p-0": e.fieldset },
        { "mb-9": e.addBottomSpace && !e.errorText && !e.hintText && !o(a).hint },
        { "mb-4": e.addBottomSpace && (e.errorText || e.hintText || o(a).hint) },
        { "stash-field--disabled": e.isDisabled || e.disabled },
        { "stash-field--is-read-only": e.isReadOnly },
        { "stash-field--is-required": e.isRequired },
        { "stash-field--has-error": i.value }
      ]]
    }, I.value), {
      default: m(() => [
        e.label ? (s(), b(q, {
          key: 0,
          id: c.value,
          for: h.value,
          "has-error": i.value,
          "is-required": l.isRequired,
          "show-optional": e.showOptionalInLabel,
          "is-sr-only": e.isLabelSrOnly,
          legend: e.fieldset,
          disabled: e.isDisabled || e.disabled
        }, {
          default: m(() => [
            k(r(e.label), 1)
          ]),
          _: 1
        }, 8, ["id", "for", "has-error", "is-required", "show-optional", "is-sr-only", "legend", "disabled"])) : y("", !0),
        x(d.$slots, "default", {
          fieldId: h.value,
          fieldErrorId: u.value,
          hasError: i.value,
          isRequired: l.isRequired,
          isReadOnly: e.isReadOnly,
          disabled: e.isDisabled || e.disabled,
          labelId: c.value,
          showOptionalInLabel: e.showOptionalInLabel
        }),
        e.errorText ? (s(), n("span", {
          key: 1,
          id: u.value,
          class: "stash-field-error mt-1 block whitespace-pre-line text-xs text-red-500",
          "data-test": "stash-field-error"
        }, r(e.errorText), 9, S)) : e.hintText && !e.isReadOnly ? (s(), n("span", D, r(e.hintText), 1)) : o(a).hint && !e.isReadOnly ? (s(), n("div", E, [
          x(d.$slots, "hint")
        ])) : y("", !0)
      ]),
      _: 3
    }, 16, ["class"]));
  }
});
export {
  C as _
};
//# sourceMappingURL=Field.vue_vue_type_script_setup_true_lang-CJUQxQdh.js.map
