import { defineComponent as h, watch as v, withDirectives as P, openBlock as V, createElementBlock as _, isRef as F, normalizeStyle as O, unref as d, withModifiers as s, vModelDynamic as R, ref as f, onMounted as k } from "vue";
import { cloneDeep as m, isEqual as w } from "lodash";
import { autoInstallFont as E, jsonToCssStyle as r } from "../../utils/json2css.mjs";
const B = ["type", "placeholder"], C = h({ name: "zv-interaction-input" }), q = /* @__PURE__ */ h({
  ...C,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  emits: ["on-blur", "on-focus", "on-input", "on-change"],
  setup(y, { emit: S }) {
    const t = y, a = S, b = () => {
      const e = f(""), o = f(), i = (u) => {
        if (E(u.fontFamily), E(u.focus.fontFamily), o.value)
          return {
            ...r(u),
            ...r(u.focus, "focus"),
            ...r(u.placeholder, "placeholder")
          };
      }, c = () => {
        window.SHJDatasourceV2({
          tId: t.uuid,
          sources: t.sources,
          callback: ({ data: u }) => {
            try {
              window.SHJParseEvent(t.useEvents, "dataListener", u), e.value = u[0].data[0].value;
            } catch {
              window.SHJParseEvent(t.useEvents, "dataListener", null);
            }
          }
        });
      };
      return k(() => c()), {
        init: c,
        rendererDomStyle: i,
        inputRef: o,
        inputValue: e
      };
    }, { init: p, rendererDomStyle: I, inputRef: n, inputValue: l } = b(), D = (e) => {
      n.value && (a("on-blur", e, n.value.value), window.SHJParseEvent(t.useEvents, "on-blur", {
        data: n.value.value,
        event: e
      }));
    }, H = (e) => {
      n.value && (a("on-focus", e, n.value.value), window.SHJParseEvent(t.useEvents, "on-focus", {
        data: n.value.value,
        event: e
      }));
    }, J = (e) => {
      n.value && (a("on-input", e, n.value.value), window.SHJParseEvent(t.useEvents, "on-input", {
        data: n.value.value,
        event: e
      }));
    }, g = (e) => {
      n.value && (a("on-change", e, n.value.value), window.SHJParseEvent(t.useEvents, "on-change", {
        data: n.value.value,
        event: e
      }));
    };
    return v(
      () => m(t.basicOption),
      (e, o) => {
        w(e, o) || p();
      },
      { deep: !0 }
    ), v(
      () => m(t.sources),
      (e, o) => {
        w(e, o) || p();
      },
      { deep: !0 }
    ), (e, o) => P((V(), _("input", {
      "onUpdate:modelValue": o[0] || (o[0] = (i) => F(l) ? l.value = i : null),
      ref_key: "inputRef",
      ref: n,
      type: e.basicOption.css.type || "text",
      class: "zerov-widget-input",
      placeholder: e.basicOption.placeholderValue,
      style: O(d(I)(e.basicOption.css)),
      onBlur: s(D, ["stop"]),
      onFocus: s(H, ["stop"]),
      onInput: s(J, ["stop"]),
      onChange: s(g, ["stop"])
    }, null, 44, B)), [
      [R, d(l)]
    ]);
  }
});
export {
  q as default
};
