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