import { defineComponent as l, useCssVars as r, ref as d, watch as v, openBlock as b, createElementBlock as f, normalizeClass as h, withDirectives as O, createElementVNode as t, vModelCheckbox as m, pushScopeId as w, popScopeId as C } from "vue";
import { cloneDeep as S, isEqual as V } from "lodash";
const z = (n) => (w("data-v-ffeabca5"), n = n(), C(), n), E = ["true-value", "false-value"], _ = /* @__PURE__ */ z(() => /* @__PURE__ */ t("div", { class: "zv-switch__action" }, null, -1)), k = [
  _
], g = l({ name: "zv-interaction-switch" }), I = /* @__PURE__ */ l({
  ...g,
  props: {
    basicOption: {},
    useEvents: {},
    sceneOption: {}
  },
  emits: ["on-change", "on-open", "on-close"],
  setup(n, { emit: p }) {
    r((e) => ({
      "1b211f87": e.basicOption.css.onColor,
      "49c0465e": e.basicOption.css.offColor,
      "37d4f74e": e.basicOption.css.actionSize + "px",
      "2422c73c": e.basicOption.css.minWidth + "px",
      "4e456c10": e.basicOption.css.coreSize + "px",
      e5de6cda: e.basicOption.css.coreBorderRadius + "px",
      "04cc88dc": e.basicOption.css.actionBorderRadius + "px",
      "8456717c": e.basicOption.css.actionBackgroundColor
    }));
    const i = p, a = n, s = d(JSON.parse(a.basicOption.defaultValue)), u = (e) => {
      s.value = !s.value;
      const o = a.basicOption.trueValue === s.value ? "open" : "close";
      i("on-change", s.value), window.SHJParseEvent(a.useEvents, "on-change", {
        data: s.value
      }), i(`on-${o}`, s.value), window.SHJParseEvent(a.useEvents, `on-${o}`, {
        data: s.value
      });
    };
    return v(() => S(a.basicOption), (e, o) => {
      V(e, o) || (s.value = JSON.parse(a.basicOption.defaultValue));
    }, { deep: !0 }), (e, o) => (b(), f("div", {
      class: h(["zv-switch", {
        "is-checked": s.value
      }])
    }, [
      O(t("input", {
        "onUpdate:modelValue": o[0] || (o[0] = (c) => s.value = c),
        class: "zv-switch__input",
        type: "checkbox",
        "true-value": e.basicOption.trueValue,
        "false-value": e.basicOption.falseValue
      }, null, 8, E), [
        [m, s.value]
      ]),
      t("span", {
        class: "zv-switch__core",
        onClick: o[1] || (o[1] = (c) => u(s.value))
      }, k)
    ], 2));
  }
});
export {
  I as default
};
