import { defineComponent as C, useAttrs as E, useSlots as A, useCssModule as V, computed as s, openBlock as i, createElementBlock as n, unref as o, normalizeClass as h, withDirectives as B, createElementVNode as p, mergeProps as M, vModelCheckbox as $, renderSlot as m, createTextVNode as v, toDisplayString as u, createCommentVNode as I } from "vue";
import N from "@leaflink/snitch";
import { uniqueId as f } from "es-toolkit/compat";
import { _ as S } from "./_plugin-vue_export-helper-CHgC5LLL.js";
const D = ["data-test"], q = ["id", "aria-invalid", "aria-errormessage", "disabled", "value"], z = ["for"], H = ["id"], J = /* @__PURE__ */ C({
  name: "ll-checkbox",
  inheritAttrs: !1,
  __name: "Checkbox",
  props: {
    checked: { type: [Boolean, Array] },
    hasError: { type: Boolean, default: !1 },
    id: { default: void 0 },
    label: { default: void 0 },
    errorText: { default: "" },
    hintText: { default: "" },
    modelValue: { type: [Boolean, Array], default: void 0 },
    value: { default: void 0 },
    disabled: { type: Boolean, default: !1 }
  },
  emits: ["update:checked"],
  setup(l, { emit: _ }) {
    const e = l, a = E(), g = A(), r = V(), y = _;
    if (e.modelValue !== void 0)
      throw new Error("ll-checkbox: use :checked or v-model:checked instead of :model-value and v-model.");
    if (typeof e.value == "boolean" && N.warn("ll-checkbox: use `checked` to toggle the state; `value` is what will be set if `checked` is true"), a.onChange)
      throw new Error("ll-checkbox: use the @update:checked event instead of @change.");
    const w = s(() => {
      const t = { ...a };
      return delete t["data-test"], delete t.class, t;
    }), c = s({
      get() {
        return e.checked;
      },
      set(t) {
        y("update:checked", t);
      }
    }), d = s(() => !!e.errorText || e.hasError), x = s(() => e.id || f("checkbox-")), b = s(() => e.errorText ? f("checkbox-error-") : void 0);
    return (t, k) => (i(), n("div", {
      class: h(["stash-checkbox relative m-0", [
        o(a).class,
        {
          "stash-checkbox--checked": !!c.value,
          [`stash-checkbox--has-error ${o(r)["has-error"]}`]: d.value
        }
      ]]),
      "data-test": o(a)["data-test"] || "stash-checkbox"
    }, [
      B(p("input", M({
        id: x.value,
        "onUpdate:modelValue": k[0] || (k[0] = (T) => c.value = T),
        "aria-invalid": !!e.errorText,
        "aria-errormessage": b.value,
        disabled: e.disabled,
        class: ["sr-only lg:m-0", o(r).input],
        type: "checkbox",
        value: l.value
      }, w.value), null, 16, q), [
        [$, c.value]
      ]),
      p("label", {
        "data-test": "stash-checkbox|label",
        class: h(["stash-checkbox__label relative inline-block min-h-9 cursor-pointer overflow-visible py-1.5 pl-8 align-top text-sm font-normal leading-6", [
          o(r).label,
          {
            "text-ice-900": !d.value && !e.disabled,
            "text-red-500": d.value,
            "text-ice-500": e.disabled
          }
        ]]),
        for: x.value
      }, [
        m(t.$slots, "default", {}, () => [
          v(u(l.label), 1)
        ])
      ], 10, z),
      e.errorText ? (i(), n("span", {
        key: 0,
        id: b.value,
        class: "stash-checkbox__error-text ml-8 block whitespace-pre-line text-xs text-red-500",
        "data-test": "stash-checkbox|error"
      }, u(e.errorText), 9, H)) : e.hintText || o(g).hint ? (i(), n("span", {
        key: 1,
        class: h(["stash-checkbox__hint-text ml-8 block whitespace-pre-line text-xs", { "text-ice-500": e.disabled }]),
        "data-test": "stash-checkbox|hint"
      }, [
        m(t.$slots, "hint", {}, () => [
          v(u(e.hintText), 1)
        ])
      ], 2)) : I("", !0)
    ], 10, D));
  }
}), K = "_input_2YCLK", L = "_label_ooTXg", P = {
  input: K,
  label: L,
  "has-error": "_has-error_-AedJ"
}, U = {
  $style: P
}, G = /* @__PURE__ */ S(J, [["__cssModules", U]]);
export {
  G as default
};
//# sourceMappingURL=Checkbox.js.map
