import { defineComponent as f, watch as s, openBlock as h, createElementBlock as S, normalizeStyle as v, unref as a, toDisplayString as g, ref as _, onMounted as D, nextTick as b } from "vue";
import { cloneDeep as c, isEqual as d } from "lodash";
import { autoInstallFont as k, jsonToCssStyle as E } from "../../utils/json2css.mjs";
const C = ["ztitle"], j = f({ name: "zv-text-text-dynamic" }), A = /* @__PURE__ */ f({
  ...j,
  props: {
    basicOption: {},
    sources: {},
    useEvents: {},
    uuid: {}
  },
  setup(p, { expose: x }) {
    const n = p, m = () => {
      const t = _(""), o = (e) => {
        k(e.fontFamily);
        const i = {};
        e.color && e.color.includes("linear-gradient") && (i.backgroundImage = e.color, i["-webkit-background-clip"] = "text", i.color = "transparent");
        const y = {};
        return e.textAlign === "left" && (e.justifyContent = "flex-start"), e.textAlign === "center" && (e.justifyContent = "center"), e.textAlign === "right" && (e.justifyContent = "flex-end"), {
          ...E(e),
          ...i,
          ...y,
          ...e.textShadow.show ? { "--text-shadow": `${e.textShadow.x}px ${e.textShadow.y}px ${e.textShadow.value}px ${e.textShadow.color}` } : {}
        };
      }, u = () => {
        window.SHJDatasourceV2({
          tId: n.uuid,
          sources: n.sources,
          callback: ({ data: e }) => {
            try {
              window.SHJParseEvent(n.useEvents, "dataListener", e), t.value = e[0].data[0].value;
            } catch {
              window.SHJParseEvent(n.useEvents, "dataListener", null);
            }
          }
        });
      };
      return D(() => b(() => u())), { rendererDomStyle: o, init: u, value: t };
    }, { rendererDomStyle: w, init: r, value: l } = m();
    return s(() => c(n.basicOption), (t, o) => {
      d(t, o) || r();
    }, { deep: !0 }), s(() => c(n.sources), (t, o) => {
      d(t, o) || r();
    }, { deep: !0 }), x({
      refresh: () => r(),
      refreshView: () => r(),
      refreshData: () => r()
    }), (t, o) => (h(), S("p", {
      class: "zerov-widget-text",
      style: v(a(w)(t.basicOption.css)),
      ztitle: a(l)
    }, g(a(l)), 13, C));
  }
});
export {
  A as default
};
