import { defineComponent as T, computed as i, unref as t, createVNode as m, Fragment as E, watch as F, watchEffect as I, openBlock as d, createElementBlock as u, withModifiers as W, normalizeClass as s, normalizeStyle as $, createBlock as j, renderSlot as M, createCommentVNode as f, createElementVNode as O } from "vue";
import { Skeleton as R } from "@aplus-frontend/antdv";
import { isFunction as U } from "lodash-unified";
import "../render/index.mjs";
import "../config-provider/index.mjs";
import "../hooks/index.mjs";
import q from "./checked.svg.mjs";
import { useInjectCheckCard as A } from "./context.mjs";
import D from "./style/index.mjs";
import { useNamespace as G } from "../config-provider/hooks/use-namespace.mjs";
import { useControllableValue as H } from "../hooks/useControllableValue.mjs";
import b from "../render/render.mjs";
const J = ["src"], ne = /* @__PURE__ */ T({
  name: "CheckCard",
  __name: "index",
  props: {
    bordered: {
      type: Boolean,
      default: !0
    },
    disabled: {
      type: Boolean
    },
    loading: {
      type: Boolean
    },
    size: {},
    stopPropagation: {
      type: [Boolean, Function],
      default: !1
    },
    indicatorSize: {
      default: void 0
    },
    style: {
      default: void 0
    },
    checked: {
      type: Boolean,
      default: void 0
    },
    "onUpdate:checked": {},
    defaultChecked: {
      type: Boolean
    },
    value: {
      type: [String, Number, Boolean]
    },
    title: {},
    content: {}
  },
  emits: ["update:checked"],
  setup(C, {
    emit: z
  }) {
    const l = C, {
      b: S,
      m: c,
      e: p,
      em: g
    } = G("check-card"), B = D("check-card"), P = z, n = A(), {
      value: r,
      updateValue: v
    } = H(l, P, {
      valuePropName: "checked",
      defaultValuePropName: "defaultChecked"
    }), a = i(() => {
      const e = {
        ...l
      }, o = t(n) || {};
      return o && (e.disabled = e.disabled ?? o.disabled, e.bordered = e.bordered ?? o.bordered, e.loading = e.loading ?? o.loading, e.size = e.size ?? o.size ?? "middle", e.indicatorSize = e.indicatorSize ?? o.indicatorSize, e.stopPropagation = e.stopPropagation ?? o.stopPropagation, e.style = e.style ? e.style : o.style), e;
    }), V = i(() => {
      const e = t(a);
      return [S(), c(e.size), t(r) ? c("checked") : null, e.bordered ? c("bordered") : null, e.disabled ? c("disabled") : null, B.value];
    }), _ = i(() => {
      const e = t(a);
      return {
        ...e.style || {},
        "--check-card-indicator-size": `${e.indicatorSize || 14}px`
      };
    });
    function k(e, o) {
      return e == null ? null : U(e) ? e(o) : m(E, null, [e]);
    }
    const h = i(() => k(l.title, t(r))), y = i(() => k(l.content, t(r)));
    function w(e) {
      const o = t(a).stopPropagation;
      return o ? o === !0 ? e.target !== e.currentTarget : o(e) : !1;
    }
    function N(e) {
      w(e) || a.value.loading || a.value.disabled || (n.value ? n.value?.toggleOption?.(l.value) : v(!t(r)));
    }
    return F(() => n.value, (e) => {
      if (!e)
        return;
      const o = e.multiple ? (e.value || []).includes(l.value) : e.value === l.value;
      v(o);
    }, {
      immediate: !0
    }), I((e) => {
      n.value?.registerValue?.(l.value), e(() => n.value?.cancelValue?.(l.value));
    }), (e, o) => (d(), u("div", {
      style: $(_.value),
      class: s(V.value),
      onClick: W(N, ["stop"])
    }, [a.value.loading ? (d(), j(t(R), {
      key: 0,
      active: ""
    })) : M(e.$slots, "default", {
      key: 1,
      checked: t(r)
    }, () => [h.value ? (d(), u("div", {
      key: 0,
      class: s([t(p)("title"), a.value.disabled ? t(g)("title", "disabled") : null])
    }, [m(t(b), {
      node: h.value
    }, null, 8, ["node"])], 2)) : f("", !0), y.value ? (d(), u("div", {
      key: 1,
      class: s([t(p)("content"), a.value.disabled ? t(g)("content", "disabled") : null])
    }, [m(t(b), {
      node: y.value
    }, null, 8, ["node"])], 2)) : f("", !0)]), t(r) ? (d(), u("div", {
      key: 2,
      class: s(t(p)("checked-icon"))
    }, [O("img", {
      src: t(q),
      alt: ""
    }, null, 8, J)], 2)) : f("", !0)], 6));
  }
});
export {
  ne as default
};
