UNPKG

epic-designer-gold

Version:

基于vue3的设计器,可视化开发页面表单

1,758 lines 54.8 kB
import { ref as $, reactive as pe, defineComponent as me, openBlock as k, createBlock as le, unref as Z, mergeProps as $e, withCtx as Y, renderSlot as j, getCurrentInstance as we, inject as ie, watch as G, useAttrs as Ye, provide as ee, shallowRef as ze, computed as ae, watchEffect as Ee, onUnmounted as Je, resolveComponent as ke, createElementBlock as ye, Fragment as Le, createElementVNode as re, createStaticVNode as qe, toDisplayString as Xe, createCommentVNode as Ce, resolveDynamicComponent as je, createVNode as se, useSlots as et, Suspense as We, renderList as tt, nextTick as de, onMounted as Me, isRef as nt, readonly as ot, effectScope as at, getCurrentScope as rt, onScopeDispose as st, normalizeClass as lt, toRaw as Ue } from "vue";
import { i as it, p as q, e as he, d as te, j as Pe, k as ct, E as oe, l as fe, g as ut, m as dt } from "./pluginManager-BNLy8dPz.js";
import { a as ne, u as Re } from "./index-B1s67XDZ.js";
import { ElMessage as Ie } from "element-plus";
import "./markdownEditorPreview-bqI8KYYC.js";
import { a as ge } from "./index-BNoHh0sx.js";
import { _ as ft } from "./_plugin-vue_export-helper-CHgC5LLL.js";
function vn(e, n) {
  let o = null;
  return (...l) => {
    o && clearTimeout(o), o = setTimeout(() => {
      e(...l);
    }, n);
  };
}
function He() {
  const e = $({}), n = $({}), o = $(!1), l = $([]), f = pe({});
  function a(p) {
    return e.value[p];
  }
  function v(p, _) {
    e.value[p] = _;
  }
  function s(p) {
    delete e.value[p];
  }
  function w(p, _ = !1) {
    const F = Object.entries(q.publicMethods).reduce(
      (C, [g, Q]) => (C[g] = Q.handler, C),
      {}
    );
    try {
      new Function(`const epic = this;${p}`).bind({
        ...F,
        getComponent: a,
        find: a,
        defineExpose: O,
        publicMethods: F,
        pluginManager: q
      })();
    } catch (C) {
      _ && console.error("[epic:自定义函数]异常:", C);
    }
  }
  function O(p) {
    p != null && (n.value = p);
  }
  function A(p, ..._) {
    if (!p || p.length === 0) {
      console.warn("未提供任何动作");
      return;
    }
    p.forEach((F) => {
      const C = F.args ? JSON.parse(F.args) : _;
      switch (F.type) {
        case "public":
          m(F, C);
          break;
        case "custom":
          N(F, C);
          break;
        case "component":
          t(F, C);
          break;
        default:
          console.warn(`未知的动作类型: ${F.type}`);
          break;
      }
    });
  }
  function m(p, _) {
    var F;
    try {
      (F = q.publicMethods[p.methodName]) == null || F.handler(..._);
    } catch (C) {
      console.error(`[Epic:公共函数(${p.methodName})]执行异常:`, C);
    }
  }
  function N(p, _) {
    var F, C;
    try {
      (C = (F = n.value)[p.methodName]) == null || C.call(F, ..._);
    } catch (g) {
      console.error(`[Epic:自定义函数(${p.methodName})]执行异常:`, g);
    }
  }
  function t(p, _) {
    const F = p.componentId != null && a(p.componentId);
    if (!F) {
      console.warn(`[Epic:组件${p.componentId}]未找到`);
      return;
    }
    try {
      F[p.methodName](..._);
    } catch (C) {
      console.error(`[Epic:组件${p.componentId}函数(${p.methodName})]执行异常:`, C);
    }
  }
  function S(p = !0) {
    o.value = p;
  }
  function y(p) {
    const _ = it(p, () => !0);
    l.value = _.map((F) => F.id);
  }
  function D(p, _ = "default") {
    if (f[_]) {
      const F = f[_];
      he(p, F);
    }
    f[_] = p;
  }
  function T(p, _ = "default") {
    if (f[_]) {
      he(f[_], p, !1);
      return;
    }
    f[_] = p;
  }
  return {
    componentInstances: e,
    funcs: n,
    isDesignMode: o,
    defaultComponentIds: l,
    forms: f,
    addFormData: D,
    setFormData: T,
    getComponentInstance: a,
    // 简化查询函数, 推荐使用
    find: a,
    addComponentInstance: v,
    removeComponentInstance: s,
    setMethods: w,
    doActions: A,
    setDesignMode: S,
    setDefaultComponentIds: y
  };
}
function pt() {
  const e = $([]), n = $([]), o = $(null);
  let l = 0;
  function f(w, O = "插入组件") {
    const A = Date.now();
    l + 150 > A || (l = A, o.value != null && (e.value.push(o.value), n.value.splice(0, n.value.length)), o.value = {
      type: O,
      componentSchema: JSON.stringify(w)
    }, e.value.length > 60 && e.value.unshift());
  }
  function a() {
    if (e.value.length === 0)
      return !1;
    const w = e.value.pop();
    return o.value != null && n.value.push(o.value), o.value = w, JSON.parse(w.componentSchema);
  }
  function v() {
    if (n.value.length === 0)
      return !1;
    const w = n.value.pop();
    return o.value != null && e.value.push(o.value), o.value = w, JSON.parse(w.componentSchema);
  }
  function s() {
    e.value = [], n.value = [], o.value = null;
  }
  return {
    recordList: e,
    undoList: n,
    currentRecord: o,
    push: f,
    undo: a,
    redo: v,
    reset: s
  };
}
const mt = /* @__PURE__ */ me({
  __name: "dynamicFormItem",
  props: {
    hasFormItem: { type: Boolean },
    formItemProps: {}
  },
  emits: ["updateFormItemRef"],
  setup(e, { emit: n }) {
    const o = q.getComponent("form-item"), l = e, f = n, a = $(), v = () => {
      f("updateFormItemRef", a.value);
    };
    return (s, w) => l.hasFormItem ? (k(), le(Z(o), $e({
      key: 0,
      ref_key: "formItemRef",
      ref: a,
      onVnodeMounted: v
    }, l.formItemProps), {
      default: Y(() => [
        j(s.$slots, "default")
      ]),
      _: 3
    }, 16, ["onVnodeMounted"])) : j(s.$slots, "default", { key: 1 });
  }
}), ht = {
  key: 0,
  class: "epic-loading-box"
}, vt = { class: "epic-loading-content" }, gt = { class: "epic-loading-text" }, yt = /* @__PURE__ */ me({
  name: "ENode",
  __name: "node",
  props: {
    componentSchema: {},
    modelValue: {},
    ruleField: {},
    resetFormData: { type: Boolean },
    name: {},
    dynamicId: {},
    sourceDateUrl: {},
    id: {}
  },
  emits: ["update:modelValue", "change", "update:dynamicId"],
  setup(e, { emit: n }) {
    const o = $(!1), l = $("加载中"), { proxy: f } = we(), a = e, v = $(null);
    let s = ie("formData", pe({}));
    const w = ie("slots", {}), O = ie("pageManager", {}), A = ie("disabled", {
      value: !1
    }), m = ie("ruleFieldPrefix", null), N = ie("resetFormData", !1);
    let t = pe(te(a.componentSchema));
    _();
    const S = {};
    async function y(r) {
      var x;
      try {
        o.value = !0, l.value = "正在识别中...请稍等";
        const M = {
          url: r.callBackUrl,
          headers: {
            Authorization: "Bearer " + ne.get("Admin-Token"),
            lang: ne.get("saas-locale") || "zh-CN",
            zone: Intl.DateTimeFormat().resolvedOptions().timeZone
          }
        }, E = (r.callBackMethod || "").toLowerCase(), d = Array.isArray(r.url) ? r.url.filter((R) => typeof R == "string" && R.trim()) : [];
        if (d.length === 0) {
          Ie.warning("未获取到上传文件地址");
          return;
        }
        const J = { [r.callBackField]: d.join(",") };
        E === "get" ? (M.method = "get", M.params = J) : (M.method = E || "post", M.data = J);
        let H = await ge(M);
        if (((x = H.data) == null ? void 0 : x.code) === 403) {
          Ie.error(H.data.msg || "识别失败");
          return;
        }
        let L = {};
        r.callBackDataPath ? L = r.callBackDataPath.split(".").reduce((Ae, Qe) => Ae[Qe], H.data) || {} : L = H.data || {};
        const X = Object.keys(L), _e = te(s);
        r.validate && (r.validateParams.forEach((R) => {
          s.orcWarningInfo__copy_data && s.orcWarningInfo__copy_data[R.value] && (s[R.value] = s.orcWarningInfo__copy_data[R.value]);
        }), s[r.field + "-orcWarningInfo"] = "", r.validateParams.forEach((R) => {
          s[R.value] && L[R.value] && L[R.value] !== s[R.value] && (a.componentSchema.componentProps.validateStatus = !0, s[r.field + "-orcWarningInfo"] ? s[r.field + "-orcWarningInfo"] = s[r.field + "-orcWarningInfo"] + "," + R.label + "已从" + s[R.value] + "改为" + L[R.value] : s[r.field + "-orcWarningInfo"] = R.label + "已从" + s[R.value] + "改为" + L[R.value]);
        })), S[r.field] ? (Object.assign(s, S[r.field]), X.forEach((R) => {
          R in S[r.field] || (S[r.field][R] = s[R]);
        })) : (S[r.field] = {}, X.forEach((R) => {
          S[r.field][R] = s[R];
        })), Object.assign(s, L), Pe(_e, s) || (a != null && a.id ? oe.emit("updateformData" + (a == null ? void 0 : a.id), s) : oe.emit("updateformData", s));
      } catch (M) {
        Ie.error("OCR 识别回调处理失败:" + M.message);
      } finally {
        o.value = !1, l.value = "加载中";
      }
    }
    async function D({
      value: r,
      field: x,
      fillDataSource: M,
      fillDataParams: E
    }) {
      try {
        o.value = !0;
        const J = (await ge({
          url: a.sourceDateUrl,
          method: "get",
          params: {
            id: M ?? ""
          },
          headers: {
            Authorization: "Bearer " + ne.get("Admin-Token"),
            lang: ne.get("saas-locale") || "zh-CN",
            //语言
            zone: Intl.DateTimeFormat().resolvedOptions().timeZone
            //时区
          }
        })).data.data;
        let H = await ge({
          url: J.url,
          method: J.method,
          data: J.body ? JSON.parse(J.body) : {},
          params: J.params ? {
            ...JSON.parse(J.params),
            [x]: r
          } : { [x]: r },
          headers: {
            ...JSON.parse(J.headers),
            Authorization: "Bearer " + ne.get("Admin-Token"),
            lang: ne.get("saas-locale") || "zh-CN",
            //语言
            zone: Intl.DateTimeFormat().resolvedOptions().timeZone
            //时区
          }
        });
        if (J && (J != null && J.dataPath)) {
          let _e = J.dataPath.split(".").reduce((R, Ae) => R[Ae], H.data);
          E.split(",").forEach((R) => {
            s[R] = _e[R];
          });
        } else {
          let L = H.data;
          E.split(",").forEach((X) => {
            s[X] = L[X];
          });
        }
        s.orcWarningInfo__copy_data = JSON.parse(
          JSON.stringify(s)
        );
      } catch (d) {
        console.log(d);
      } finally {
        o.value = !1, l.value = "加载中";
      }
    }
    async function T(r) {
      if ([
        "cascader",
        "checkbox",
        "select",
        "radio",
        "ocr-select-page"
      ].includes(r.type) && r.componentProps.dynamicId && a.sourceDateUrl) {
        const E = (await ge({
          url: a.sourceDateUrl,
          method: "get",
          params: {
            id: r.componentProps.dynamicId ?? ""
          },
          headers: {
            Authorization: "Bearer " + ne.get("Admin-Token"),
            lang: ne.get("saas-locale") || "zh-CN",
            //语言
            zone: Intl.DateTimeFormat().resolvedOptions().timeZone
            //时区
          }
        })).data.data;
        let d = await ge({
          url: E.url,
          method: E.method,
          data: E.body ? JSON.parse(E.body) : {},
          params: E.params ? JSON.parse(E.params) : {},
          headers: {
            ...JSON.parse(E.headers),
            Authorization: "Bearer " + ne.get("Admin-Token"),
            lang: ne.get("saas-locale") || "zh-CN",
            //语言
            zone: Intl.DateTimeFormat().resolvedOptions().timeZone
            //时区
          }
        });
        if (E && (E != null && E.dataPath)) {
          const H = E.dataPath.split(".").reduce((L, X) => L[X], d.data);
          r.componentProps.options = p(
            H,
            E.dataKey,
            E.dataValue
          );
        } else
          r.componentProps.options = p(
            d.data,
            E.dataKey,
            E.dataValue
          );
        return r;
      }
      return r;
    }
    function p(r, x, M) {
      return r && Object.prototype.toString.call(r) === "[object Array]" ? r.map((E) => E.children && E.children.length ? {
        label: E[x],
        value: E[M] + "",
        children: p(E.children, x, M)
      } : {
        label: E[x],
        value: E[M] + ""
      }) : [];
    }
    G(
      () => a.componentSchema,
      (r) => {
        Pe(t, r, ["children"]) || (he(t, te(r)), _());
      },
      {
        deep: !0
      }
    );
    function _() {
      O.isDesignMode.value && typeof t.field == "string" && (t.field += "-design-mode");
    }
    (a.resetFormData || N) && (s = {});
    const F = n, C = $(), g = $(), Q = (r) => {
      g.value = r;
    }, K = Ye();
    Object.keys(K).length && ee("nodeAttrs", K);
    const b = ze(null), i = ae(() => {
      var r, x;
      return (r = t.componentProps) != null && r.hidden ? !1 : typeof t.show == "boolean" ? t.show : ((x = t.show) == null ? void 0 : x.call(t, { values: s })) ?? !0;
    }), B = ae(() => {
      var E;
      const r = i.value && ((E = t.rules) == null ? void 0 : E.map((d) => ({
        ...d,
        validator: d.validator && O.funcs.value[d.validator]
        // 自定义校验函数
      })));
      let x = t.field;
      a.ruleField ? x = a.ruleField : m && t.field && (x = te(m), x.push(t.field));
      const M = {
        ...t,
        rules: r,
        rule: r,
        field: x
      };
      return M.children && delete M.children, M;
    }), u = ae(() => {
      var M, E, d;
      const r = ((M = c.value) == null ? void 0 : M.bindModel) ?? "modelValue", x = {};
      return t.on && Object.keys(t.on).forEach((J) => {
        x[`on${ct(J)}`] = (...H) => O.doActions(t.on[J], ...H);
      }), t.type === "selectpage" && (t.componentProps.defaultData = {
        value: s[t.field],
        label: s[s[t.field]]
      }), {
        ...a,
        ...t.componentProps,
        sourceDateUrl: a.sourceDateUrl,
        // 为了避免禁用对超链接输入框点击的影响
        disabled: a.componentSchema.type === "input" && a.componentSchema.componentProps && ((E = a.componentSchema.componentProps) != null && E.isLink) ? !1 : (A == null ? void 0 : A.value) || ((d = t.componentProps) == null ? void 0 : d.disabled),
        bindModel: r,
        ...x
      };
    }), c = ae(() => q.getComponentConfingByType(t.type) ?? null);
    Ee(() => {
      v.value = a.modelValue ?? s[t.field ?? ""];
    }), G(
      () => v.value,
      () => {
        v.value !== (a.modelValue ?? s[t.field ?? ""]) && z(v.value);
      }
    ), G(
      () => C.value,
      () => {
        P();
      },
      { immediate: !0 }
    );
    function P() {
      var x;
      const r = C.value || f;
      t != null && t.id && r && ((t.input || t.type === "table" && t.field || t.type === "card" && t.field && t.multiple) && (r.setValue = z, r.getValue = () => s[t.field] || a.modelValue), r.setAttr = (M, E) => (t.componentProps || (t.componentProps = {}), t.componentProps[M] = E), r.getAttr = (M) => t.componentProps[M], O.addComponentInstance(t == null ? void 0 : t.id, r), (x = c.value) != null && x.defaultSchema.input && t.noFormItem !== !0 && g.value && O.addComponentInstance(
        (t == null ? void 0 : t.id) + "formItem",
        g.value
      ));
    }
    function V() {
      var r;
      t.id && (O.removeComponentInstance(t == null ? void 0 : t.id), (r = c.value) != null && r.defaultSchema.input && t.noFormItem !== !0 && O.removeComponentInstance((t == null ? void 0 : t.id) + "formItem"));
    }
    async function I() {
      var x, M, E;
      if (t = await T(t), typeof ((x = t.componentProps) == null ? void 0 : x.defaultValue) < "u") {
        const d = O.isDesignMode.value ? (M = t.componentProps) == null ? void 0 : M.defaultValue : s[t.field] ?? ((E = t.componentProps) == null ? void 0 : E.defaultValue);
        z(te(d));
      }
      if (t.type === "slot") {
        const d = t.slotName;
        if (!d) return;
        b.value = me({
          setup() {
            return () => j(w, d, {
              componentSchema: t,
              model: s
            });
          }
        });
        return;
      }
      const r = q.getComponent(t.type);
      if (!r) {
        console.error(`组件${t.type}未注册`);
        return;
      }
      if (typeof r == "function") {
        const d = await r();
        b.value = d.default ?? d;
      } else
        r && (b.value = r);
    }
    function h(r) {
      Object.prototype.toString.call(r) === "[object Array]" ? r.forEach((x) => {
        s[x.value] = x.label;
      }) : s[r.value] = r.label, a != null && a.id ? oe.emit("updateformData" + (a == null ? void 0 : a.id), s) : oe.emit("updateformData", s);
    }
    function z(r) {
      F("update:modelValue", r), F("change", r), t.field && (s[t.field] = r), a != null && a.id ? oe.emit("updateformData" + (a == null ? void 0 : a.id), s) : oe.emit("updateformData", s);
    }
    function U(r) {
      F("update:dynamicId", r);
    }
    let W = null;
    return G(
      () => t,
      async (r) => {
        const x = JSON.stringify({
          ...r,
          children: void 0,
          componentProps: {
            ...r.componentProps,
            options: null
          }
        });
        if (x === W)
          return !1;
        W = x, I();
      },
      {
        immediate: !0,
        deep: !0
      }
    ), Je(V), (r, x) => {
      var E;
      const M = ke("ENode");
      return k(), ye(Le, null, [
        o.value ? (k(), ye("div", ht, [
          re("div", vt, [
            x[1] || (x[1] = qe('<div class="epic-loading-wave" data-v-81923396><div class="wave" data-v-81923396></div><div class="wave" data-v-81923396></div><div class="wave" data-v-81923396></div><div class="wave" data-v-81923396></div><div class="wave" data-v-81923396></div></div>', 1)),
            re("span", gt, Xe(l.value), 1)
          ])
        ])) : Ce("", !0),
        b.value && i.value ? (k(), le(mt, {
          key: 1,
          hasFormItem: Z(t).noFormItem !== !0 && ((E = c.value) == null ? void 0 : E.defaultSchema.input),
          formItemProps: B.value,
          onUpdateFormItemRef: Q
        }, {
          default: Y(() => [
            (k(), le(je(b.value), $e({
              ref_key: "componentInstance",
              ref: C,
              onVnodeMounted: P,
              model: Z(s),
              sourceDateUrl: a.sourceDateUrl
            }, { ...u.value }, {
              [u.value.bindModel]: v.value,
              ["onUpdate:" + u.value.bindModel]: x[0] || (x[0] = (d) => v.value = d),
              [`onUpdate:${u.value.bindModel}` || ""]: z,
              "onUpdate:modelValueLabel": h,
              "onUpdate:dynamicId": U,
              "onUpdate:ocrData": y,
              "onUpdate:selectFillData": D
            }), {
              node: Y((d) => [
                se(M, $e({
                  id: a.id
                }, d, {
                  sourceDateUrl: a.sourceDateUrl
                }), null, 16, ["id", "sourceDateUrl"])
              ]),
              "edit-node": Y(() => [
                j(r.$slots, "edit-node", {}, void 0, !0)
              ]),
              _: 3
            }, 16, ["model", "sourceDateUrl"]))
          ]),
          _: 3
        }, 8, ["hasFormItem", "formItemProps"])) : Ce("", !0)
      ], 64);
    };
  }
}), wt = /* @__PURE__ */ ft(yt, [["__scopeId", "data-v-81923396"]]);
function St() {
  const e = $(!1), n = He(), o = $({});
  function l() {
    return new Promise((t) => {
      if (e.value)
        t();
      else {
        const S = G(e, () => {
          S(), t();
        });
      }
    });
  }
  async function f(t = "default") {
    var y;
    await l();
    const S = (y = o.value) == null ? void 0 : y[t];
    if (!S) throw new Error(`表单 [name=${t}] 不存在`);
    return S;
  }
  async function a(t, S) {
    const y = await f(t);
    return te(await S(y));
  }
  async function v(t = "default") {
    return await a(t, (S) => S.getData());
  }
  function s(t, S = "default", y = void 0) {
    var D, T;
    if (y && Object.keys(y).length) {
      let p = function(g) {
        let Q = [];
        return g.forEach((K) => {
          K.children && (Q = [...Q, ...p(K.children)]), Q.push(K);
        }), Q;
      }, F = function(g) {
        var K;
        let Q = p((K = y == null ? void 0 : y.schemas[0]) == null ? void 0 : K.children);
        return Object.keys(g).forEach((b) => {
          var u, c, P, V, I, h, z;
          const i = Q.find((U) => U.field === b), B = ["datetimerange", "daterange", "monthrange", "dates"];
          if ((i && (i == null ? void 0 : i.type) === "checkbox" || (i == null ? void 0 : i.type) === "select" && ((u = i == null ? void 0 : i.componentProps) != null && u.multiple) || (i == null ? void 0 : i.type) === "cascader" && !((P = (c = i == null ? void 0 : i.componentProps) == null ? void 0 : c.props) != null && P.multiple) || (i == null ? void 0 : i.type) === "date" && B.includes((V = i == null ? void 0 : i.componentProps) == null ? void 0 : V.type)) && typeof g[b] == "string")
            g[b] = (I = g[b]) == null ? void 0 : I.split(",");
          else if ((i == null ? void 0 : i.type) === "cascader" && ((z = (h = i == null ? void 0 : i.componentProps) == null ? void 0 : h.props) != null && z.multiple) && typeof g[b] == "string")
            g[b].indexOf(";") === -1 && g[b].indexOf(";") === -1 ? g[b][g[b]] : g[b].indexOf(";") > -1 ? g[b] = g[b].split(";").map((U) => U.split(",")) : g[b].indexOf(";") === -1 ? g[b] = g[b].split(",") : g[b].indexOf(";") > -1 ? g[b] = g[b].split(";").map((U) => U.split(",")) : g[b].indexOf(";") === -1 && (g[b] = g[b].split(","));
          else if (((i == null ? void 0 : i.type) === "upload-image" || (i == null ? void 0 : i.type) === "upload-file" || (i == null ? void 0 : i.type) === "ocr-upload") && typeof g[b] == "string") {
            let U = [];
            Object.entries(g).forEach(([W, r]) => {
              g[b] === r && W !== i.field && W.indexOf("@") > -1 && W.indexOf(b) > -1 && (U = W.split("@")[1].split(","));
            }), g[b] = g[b].split(",").map((W, r) => ({
              url: W,
              name: U[r] || W
              // 若无对应文件名,则使用 url 本身
            }));
          } else (i == null ? void 0 : i.type) === "number" || (i == null ? void 0 : i.type) === "slider" ? g[b] = Number(g[b]) : (i == null ? void 0 : i.type) === "switch" && (g[b] = typeof g[b] == "boolean" ? g[b] : g[b].indexOf("true") > -1);
        }), g;
      }(t);
      console.log("%c [ data1 ]-131", "font-size:13px; background:pink; color:#bf2c9f;", F), n.setFormData(F, S);
      const C = (D = o.value) == null ? void 0 : D[S];
      C == null || C.clearValidate();
    } else {
      n.setFormData(t, S);
      const p = (T = o.value) == null ? void 0 : T[S];
      p == null || p.clearValidate();
    }
  }
  async function w(t = "default") {
    return await a(t, async (S) => (await S.validate(), await S.getData()));
  }
  async function O(t) {
    await l();
    const S = {};
    for (const y in o.value) {
      const D = o.value[y];
      D && (S[y] = te(await t(D)));
    }
    return S;
  }
  async function A() {
    return await O((t) => t.getData());
  }
  function m(t) {
    for (const S in t)
      s(t[S], S);
  }
  async function N() {
    return await O(async (t) => (await t.validate(), await t.getData()));
  }
  return {
    ready: e,
    pageManager: n,
    forms: o,
    getData: v,
    setData: s,
    validate: w,
    getForms: A,
    setForms: m,
    validateAll: N,
    getFormInstance: f
  };
}
const Dt = {
  key: 0,
  class: "epic-loading-box"
}, bt = { class: "epic-builder-main" }, Et = { class: "epic-loading-box" }, Ot = /* @__PURE__ */ me({
  __name: "builder",
  props: {
    pageSchema: {},
    formData: {},
    disabled: { type: Boolean },
    sourceDateUrl: {},
    id: {}
  },
  emits: ["change", "ready"],
  setup(e, { expose: n, emit: o }) {
    const l = fe(() => import("./index-B5pPrBIF.js")), f = o, a = $([]), v = $({}), { ready: s, pageManager: w, forms: O, getData: A, setData: m, validate: N, getForms: t, setForms: S, validateAll: y, getFormInstance: D } = St(), T = e, p = pe({
      schemas: []
    });
    G(
      () => T.pageSchema,
      (u) => {
        he(p, u);
      },
      {
        immediate: !0,
        deep: !0
      }
    ), G(
      () => T.formData,
      (u) => {
        if (u) {
          let c = K(u);
          v.value = c, m(c);
        }
      },
      {
        immediate: !0,
        deep: !0
      }
    );
    function _(u) {
      let c = [];
      return u.forEach((P) => {
        P.children && (c = [...c, ..._(P.children)]), c.push(P);
      }), c;
    }
    function F(u, c) {
      function P(I) {
        return JSON.parse(JSON.stringify(I));
      }
      function V(I, h) {
        if (I.type === "card" && I.multiple && I.field && Array.isArray(h[I.field]))
          return h[I.field].map((U) => {
            var r;
            const W = P({ ...I, multiple: !0 });
            return W.children = (r = W.children) == null ? void 0 : r.map((x) => V(x, U)).flat(), W;
          });
        const z = P(I);
        return Array.isArray(z.children) && (z.children = z.children.map((U) => V(U, h)).flat()), z;
      }
      return u.map((I) => V(I, c)).flat();
    }
    function C(u, c = "", P = { root: 0 }) {
      const V = c || "root";
      return c || (P.root = 0), P[V] === void 0 && (P[V] = 0), u.map((I) => {
        I.field && (I.oldField = JSON.parse(JSON.stringify(I.field)));
        const h = { ...I };
        if (I.type === "card") {
          const z = I.field || "";
          I.multiple ? (h.field = c ? `${c}.${z}[${P[V]}]` : `${z}[${P[V]}]`, P[V]++) : I.field && c && (h.field = `${c}.${z}`);
          const U = h.field || c;
          P[U] = 0;
        } else I.field && c && (h.field = `${c}.${I.field}`);
        return I.children && (h.children = C(I.children, h.field || c, P)), h;
      });
    }
    function g(u, c, P = "", V = {}) {
      const I = P || "root";
      return V[I] === void 0 && (V[I] = 0), u.forEach((h) => {
        const z = h.field || "";
        let U = P ? `${P}.${z}` : `${z}`;
        h.type === "card" && h.multiple ? (typeof c[U][`${V[I]}`] == "object" ? Object.keys(c[U][`${V[I]}`]).forEach((W) => {
          c[`${U}[${V[I]}].${W}`] = c[U][`${V[I]}`][W];
        }) : c[`${U}[${V[I]}]`] = c[U][`${V[I]}`], h.children && (h.children = g(
          h.children,
          c,
          `${U}[${V[I]}]` || P,
          V
        )), V[I]++) : h.children && (h.children = g(h.children, c, P, V));
      }), V[I] = 0, c;
    }
    function Q(u, c, P) {
      let V = g(te(u), te(c));
      return {
        obj: C(u),
        dataObj: V
      };
    }
    function K(u) {
      let c = _(T.pageSchema.schemas[0].children);
      a.value = c.filter((h) => h.type === "card" && h.multiple);
      const P = F(T.pageSchema.schemas[0].children, u);
      let { obj: V, dataObj: I } = Q(P, u, a.value);
      return u = I, T.pageSchema.schemas[0].children = V, Object.keys(u).forEach((h) => {
        var z, U, W, r, x, M, E;
        if (h.indexOf("@") < 0) {
          const d = c.find((H) => H.field === h), J = ["datetimerange", "daterange", "monthrange", "dates"];
          if ((d && (d == null ? void 0 : d.type) === "checkbox" || (d == null ? void 0 : d.type) === "select" && ((z = d == null ? void 0 : d.componentProps) != null && z.multiple) || (d == null ? void 0 : d.type) === "cascader" && !((W = (U = d == null ? void 0 : d.componentProps) == null ? void 0 : U.props) != null && W.multiple) || (d == null ? void 0 : d.type) === "date" && J.includes((r = d == null ? void 0 : d.componentProps) == null ? void 0 : r.type)) && typeof u[h] == "string")
            u[h] = (x = u[h]) == null ? void 0 : x.split(",");
          else if ((d == null ? void 0 : d.type) === "cascader" && ((E = (M = d == null ? void 0 : d.componentProps) == null ? void 0 : M.props) != null && E.multiple) && typeof u[h] == "string")
            u[h].indexOf(";") > -1 ? u[h] = u[h].split(";").map((H) => H.split(",")) : u[h] = u[h].split(","), u[h].indexOf(";") > -1 ? u[h] = u[h].split(";").map((H) => H.split(",")) : u[h] = u[h].split(",");
          else if (((d == null ? void 0 : d.type) === "upload-image" || (d == null ? void 0 : d.type) === "upload-file" || (d == null ? void 0 : d.type) === "ocr-upload") && typeof u[h] == "string") {
            let H = [];
            Object.entries(u).forEach(([L, X]) => {
              u[h] === X && L !== d.field && L.indexOf("@") > -1 && L.indexOf(h) > -1 && (H = L.split("@")[1].split(","));
            }), u[h] = u[h].split(",").map((L, X) => ({
              url: L,
              name: H[X] || L
            }));
          } else (d == null ? void 0 : d.type) === "number" || (d == null ? void 0 : d.type) === "slider" ? u[h] = Number(u[h]) : (d == null ? void 0 : d.type) === "switch" && (u[h] = typeof u[h] == "boolean" ? u[h] : u[h].indexOf("true") > -1);
        }
      }), u;
    }
    G(
      () => p.script,
      (u) => {
        u && w.setMethods(u, !0);
      },
      {
        immediate: !0
      }
    ), ee("slots", et()), ee("pageManager", w), ee("forms", O), ee("pageSchema", p), ee(
      "disabled",
      ae(() => T.disabled)
    );
    const b = we(), i = b == null ? void 0 : b.proxy;
    function B() {
      de(() => {
        s.value = !0, f("ready", w), i && w.addComponentInstance("builder", i);
      });
    }
    return oe.on("updateformData" + (T.id ? T.id : ""), (u) => {
      f("change", u);
    }), n({
      ready: s,
      pageManager: w,
      getData: A,
      setData: m,
      validate: N,
      getForms: t,
      setForms: S,
      validateAll: y,
      getFormInstance: D
    }), (u, c) => Z(q).initialized.value ? (k(), le(We, {
      key: 1,
      onResolve: B
    }, {
      default: Y(() => [
        re("div", bt, [
          (k(!0), ye(Le, null, tt(p.schemas, (P, V) => (k(), le(Z(wt), {
            id: T.id,
            key: V,
            sourceDateUrl: T.sourceDateUrl,
            componentSchema: P
          }, null, 8, ["id", "sourceDateUrl", "componentSchema"]))), 128))
        ])
      ]),
      fallback: Y(() => [
        re("div", Et, [
          se(Z(l))
        ])
      ]),
      _: 1
    })) : (k(), ye("div", Dt));
  }
});
function Te(e) {
  return rt() ? (st(e), !0) : !1;
}
function _t(e) {
  let n = 0, o, l;
  const f = () => {
    n -= 1, l && n <= 0 && (l.stop(), o = void 0, l = void 0);
  };
  return (...a) => (n += 1, l || (l = at(!0), o = l.run(() => e(...a))), Te(f), o);
}
function ue(e) {
  return typeof e == "function" ? e() : Z(e);
}
const At = typeof window < "u" && typeof document < "u";
typeof WorkerGlobalScope < "u" && globalThis instanceof WorkerGlobalScope;
const It = (e) => typeof e < "u", xt = Object.prototype.toString, Nt = (e) => xt.call(e) === "[object Object]", Ft = () => {
};
function $t(e, n) {
  function o(...l) {
    return new Promise((f, a) => {
      Promise.resolve(e(() => n.apply(this, l), { fn: n, thisArg: this, args: l })).then(f).catch(a);
    });
  }
  return o;
}
const Ke = (e) => e();
function Ct(e = Ke) {
  const n = $(!0);
  function o() {
    n.value = !1;
  }
  function l() {
    n.value = !0;
  }
  const f = (...a) => {
    n.value && e(...a);
  };
  return { isActive: ot(n), pause: o, resume: l, eventFilter: f };
}
function Pt(e) {
  return we();
}
function Vt(e, n, o = {}) {
  const {
    eventFilter: l = Ke,
    ...f
  } = o;
  return G(
    e,
    $t(
      l,
      n
    ),
    f
  );
}
function Mt(e, n, o = {}) {
  const {
    eventFilter: l,
    ...f
  } = o, { eventFilter: a, pause: v, resume: s, isActive: w } = Ct(l);
  return { stop: Vt(
    e,
    n,
    {
      ...f,
      eventFilter: a
    }
  ), pause: v, resume: s, isActive: w };
}
function Ze(e, n = !0, o) {
  Pt() ? Me(e, o) : n ? e() : de(e);
}
function Rt(e = !1, n = {}) {
  const {
    truthyValue: o = !0,
    falsyValue: l = !1
  } = n, f = nt(e), a = $(e);
  function v(s) {
    if (arguments.length)
      return a.value = s, a.value;
    {
      const w = ue(o);
      return a.value = a.value === w ? ue(l) : w, a.value;
    }
  }
  return f ? v : [a, v];
}
function gn(e, n, o) {
  const l = G(e, (...f) => (de(() => l()), n(...f)), o);
  return l;
}
const ve = At ? window : void 0;
function ce(e) {
  var n;
  const o = ue(e);
  return (n = o == null ? void 0 : o.$el) != null ? n : o;
}
function Ve(...e) {
  let n, o, l, f;
  if (typeof e[0] == "string" || Array.isArray(e[0]) ? ([o, l, f] = e, n = ve) : [n, o, l, f] = e, !n)
    return Ft;
  Array.isArray(o) || (o = [o]), Array.isArray(l) || (l = [l]);
  const a = [], v = () => {
    a.forEach((A) => A()), a.length = 0;
  }, s = (A, m, N, t) => (A.addEventListener(m, N, t), () => A.removeEventListener(m, N, t)), w = G(
    () => [ce(n), ue(f)],
    ([A, m]) => {
      if (v(), !A)
        return;
      const N = Nt(m) ? { ...m } : m;
      a.push(
        ...o.flatMap((t) => l.map((S) => s(A, t, S, N)))
      );
    },
    { immediate: !0, flush: "post" }
  ), O = () => {
    w(), v();
  };
  return Te(O), O;
}
function Tt(e) {
  return typeof e == "function" ? e : typeof e == "string" ? (n) => n.key === e : Array.isArray(e) ? (n) => e.includes(n.key) : () => !0;
}
function Ge(...e) {
  let n, o, l = {};
  e.length === 3 ? (n = e[0], o = e[1], l = e[2]) : e.length === 2 ? typeof e[1] == "object" ? (n = !0, o = e[0], l = e[1]) : (n = e[0], o = e[1]) : (n = !0, o = e[0]);
  const {
    target: f = ve,
    eventName: a = "keydown",
    passive: v = !1,
    dedupe: s = !1
  } = l, w = Tt(n);
  return Ve(f, a, (A) => {
    A.repeat && ue(s) || w(A) && o(A);
  }, v);
}
function xe(e, n, o = {}) {
  return Ge(e, n, { ...o, eventName: "keydown" });
}
function Ne(e, n, o = {}) {
  return Ge(e, n, { ...o, eventName: "keyup" });
}
function Ut() {
  const e = $(!1), n = we();
  return n && Me(() => {
    e.value = !0;
  }, n), e;
}
function Bt(e) {
  const n = Ut();
  return ae(() => (n.value, !!e()));
}
function zt(e) {
  return JSON.parse(JSON.stringify(e));
}
const Se = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, De = "__vueuse_ssr_handlers__", Jt = /* @__PURE__ */ Lt();
function Lt() {
  return De in Se || (Se[De] = Se[De] || {}), Se[De];
}
function Wt(e, n) {
  return Jt[e] || n;
}
function Ht(e) {
  return e == null ? "any" : e instanceof Set ? "set" : e instanceof Map ? "map" : e instanceof Date ? "date" : typeof e == "boolean" ? "boolean" : typeof e == "string" ? "string" : typeof e == "object" ? "object" : Number.isNaN(e) ? "any" : "number";
}
const Kt = {
  boolean: {
    read: (e) => e === "true",
    write: (e) => String(e)
  },
  object: {
    read: (e) => JSON.parse(e),
    write: (e) => JSON.stringify(e)
  },
  number: {
    read: (e) => Number.parseFloat(e),
    write: (e) => String(e)
  },
  any: {
    read: (e) => e,
    write: (e) => String(e)
  },
  string: {
    read: (e) => e,
    write: (e) => String(e)
  },
  map: {
    read: (e) => new Map(JSON.parse(e)),
    write: (e) => JSON.stringify(Array.from(e.entries()))
  },
  set: {
    read: (e) => new Set(JSON.parse(e)),
    write: (e) => JSON.stringify(Array.from(e))
  },
  date: {
    read: (e) => new Date(e),
    write: (e) => e.toISOString()
  }
}, Be = "vueuse-storage";
function yn(e, n, o, l = {}) {
  var f;
  const {
    flush: a = "pre",
    deep: v = !0,
    listenToStorageChanges: s = !0,
    writeDefaults: w = !0,
    mergeDefaults: O = !1,
    shallow: A,
    window: m = ve,
    eventFilter: N,
    onError: t = (i) => {
      console.error(i);
    },
    initOnMounted: S
  } = l, y = (A ? ze : $)(typeof n == "function" ? n() : n);
  if (!o)
    try {
      o = Wt("getDefaultStorage", () => {
        var i;
        return (i = ve) == null ? void 0 : i.localStorage;
      })();
    } catch (i) {
      t(i);
    }
  if (!o)
    return y;
  const D = ue(n), T = Ht(D), p = (f = l.serializer) != null ? f : Kt[T], { pause: _, resume: F } = Mt(
    y,
    () => g(y.value),
    { flush: a, deep: v, eventFilter: N }
  );
  m && s && Ze(() => {
    o instanceof Storage ? Ve(m, "storage", K) : Ve(m, Be, b), S && K();
  }), S || K();
  function C(i, B) {
    if (m) {
      const u = {
        key: e,
        oldValue: i,
        newValue: B,
        storageArea: o
      };
      m.dispatchEvent(o instanceof Storage ? new StorageEvent("storage", u) : new CustomEvent(Be, {
        detail: u
      }));
    }
  }
  function g(i) {
    try {
      const B = o.getItem(e);
      if (i == null)
        C(B, null), o.removeItem(e);
      else {
        const u = p.write(i);
        B !== u && (o.setItem(e, u), C(B, u));
      }
    } catch (B) {
      t(B);
    }
  }
  function Q(i) {
    const B = i ? i.newValue : o.getItem(e);
    if (B == null)
      return w && D != null && o.setItem(e, p.write(D)), D;
    if (!i && O) {
      const u = p.read(B);
      return typeof O == "function" ? O(u, D) : T === "object" && !Array.isArray(u) ? { ...D, ...u } : u;
    } else return typeof B != "string" ? B : p.read(B);
  }
  function K(i) {
    if (!(i && i.storageArea !== o)) {
      if (i && i.key == null) {
        y.value = D;
        return;
      }
      if (!(i && i.key !== e)) {
        _();
        try {
          (i == null ? void 0 : i.newValue) !== p.write(y.value) && (y.value = Q(i));
        } catch (B) {
          t(B);
        } finally {
          i ? de(F) : F();
        }
      }
    }
  }
  function b(i) {
    K(i.detail);
  }
  return y;
}
function Zt(e, n, o = {}) {
  const { window: l = ve, ...f } = o;
  let a;
  const v = Bt(() => l && "ResizeObserver" in l), s = () => {
    a && (a.disconnect(), a = void 0);
  }, w = ae(() => {
    const m = ue(e);
    return Array.isArray(m) ? m.map((N) => ce(N)) : [ce(m)];
  }), O = G(
    w,
    (m) => {
      if (s(), v.value && l) {
        a = new ResizeObserver(n);
        for (const N of m)
          N && a.observe(N, f);
      }
    },
    { immediate: !0, flush: "post" }
  ), A = () => {
    s(), O();
  };
  return Te(A), {
    isSupported: v,
    stop: A
  };
}
function wn(e, n = { width: 0, height: 0 }, o = {}) {
  const { window: l = ve, box: f = "content-box" } = o, a = ae(() => {
    var m, N;
    return (N = (m = ce(e)) == null ? void 0 : m.namespaceURI) == null ? void 0 : N.includes("svg");
  }), v = $(n.width), s = $(n.height), { stop: w } = Zt(
    e,
    ([m]) => {
      const N = f === "border-box" ? m.borderBoxSize : f === "content-box" ? m.contentBoxSize : m.devicePixelContentBoxSize;
      if (l && a.value) {
        const t = ce(e);
        if (t) {
          const S = t.getBoundingClientRect();
          v.value = S.width, s.value = S.height;
        }
      } else if (N) {
        const t = Array.isArray(N) ? N : [N];
        v.value = t.reduce((S, { inlineSize: y }) => S + y, 0), s.value = t.reduce((S, { blockSize: y }) => S + y, 0);
      } else
        v.value = m.contentRect.width, s.value = m.contentRect.height;
    },
    o
  );
  Ze(() => {
    const m = ce(e);
    m && (v.value = "offsetWidth" in m ? m.offsetWidth : n.width, s.value = "offsetHeight" in m ? m.offsetHeight : n.height);
  });
  const O = G(
    () => ce(e),
    (m) => {
      v.value = m ? n.width : 0, s.value = m ? n.height : 0;
    }
  );
  function A() {
    w(), O();
  }
  return {
    width: v,
    height: s,
    stop: A
  };
}
function Sn(e, n, o, l = {}) {
  var f, a, v;
  const {
    clone: s = !1,
    passive: w = !1,
    eventName: O,
    deep: A = !1,
    defaultValue: m,
    shouldEmit: N
  } = l, t = we(), S = o || (t == null ? void 0 : t.emit) || ((f = t == null ? void 0 : t.$emit) == null ? void 0 : f.bind(t)) || ((v = (a = t == null ? void 0 : t.proxy) == null ? void 0 : a.$emit) == null ? void 0 : v.bind(t == null ? void 0 : t.proxy));
  let y = O;
  n || (n = "modelValue"), y = y || `update:${n.toString()}`;
  const D = (_) => s ? typeof s == "function" ? s(_) : zt(_) : _, T = () => It(e[n]) ? D(e[n]) : m, p = (_) => {
    N ? N(_) && S(y, _) : S(y, _);
  };
  if (w) {
    const _ = T(), F = $(_);
    let C = !1;
    return G(
      () => e[n],
      (g) => {
        C || (C = !0, F.value = D(g), de(() => C = !1));
      }
    ), G(
      F,
      (g) => {
        !C && (g !== e[n] || A) && p(g);
      },
      { deep: A }
    ), F;
  } else
    return ae({
      get() {
        return T();
      },
      set(_) {
        p(_);
      }
    });
}
function Dn() {
  const { isDark: e } = Oe(), n = Rt(e);
  return {
    isDark: e,
    toggleDark: n
  };
}
function Gt() {
  const e = $(!1);
  return Me(() => {
    Qt(e), Yt(e);
  }), G(
    () => e.value,
    () => {
      e.value ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark");
    }
  ), {
    isDark: e
  };
}
function Qt(e) {
  var n = document.documentElement;
  n && (n.classList.contains("dark") ? e.value = !0 : e.value = !1);
}
function Yt(e) {
  var n = document.querySelector("html"), o = new MutationObserver(function(l) {
    for (var f of l)
      if (f.type === "attributes" && f.attributeName === "class") {
        const a = f.target;
        new Array(...a.classList).includes("dark") ? e.value = !0 : e.value = !1;
      }
  });
  o.observe(n, {
    attributes: !0,
    attributeFilter: ["class"]
  }), Je(() => {
    o.disconnect();
  });
}
function kt() {
  const e = $(1), n = $(!1), { isDark: o } = Gt(), { pressSpace: l, pressShift: f, pressCtrl: a } = qt();
  return {
    canvasScale: e,
    pressSpace: l,
    pressShift: f,
    pressCtrl: a,
    disabledZoom: n,
    isDark: o
  };
}
const Oe = _t(kt);
function qt() {
  const e = $(!1), n = $(!1), o = $(!1);
  return xe(" ", () => {
    e.value = !0;
  }), Ne(" ", () => {
    e.value = !1;
  }), xe("Shift", (l) => {
    l.preventDefault(), n.value = !0;
  }), Ne("Shift", () => {
    n.value = !1;
  }), xe("Control", (l) => {
    l.preventDefault(), o.value = !0;
  }), Ne("Control", () => {
    o.value = !1;
  }), { pressSpace: e, pressShift: n, pressCtrl: o };
}
function bn(e) {
  const { pressSpace: n } = Oe(), o = new Image(1, 1);
  o.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg==";
  let l = 0, f = 0;
  function a(w) {
    var O;
    n.value && (l = w.x, f = w.y, (O = w.dataTransfer) == null || O.setDragImage(document.createElement("div"), 0, 0));
  }
  function v(w) {
    if (w.preventDefault(), !w.x || !w.y || !n.value)
      return;
    const O = w.x - l, A = w.y - f;
    l = w.x, f = w.y, e.value && (e.value.scrollTop -= A, e.value.scrollLeft -= O);
  }
  function s() {
    n.value = !1;
  }
  return { handleElementDragStart: a, handleElementDrag: v, handleElementDragEnd: s };
}
function En(e) {
  const { pressCtrl: n, canvasScale: o, disabledZoom: l } = Oe();
  function f(a) {
    if (!n.value || l.value)
      return;
    a.preventDefault();
    let v = 0;
    a.deltaY < 0 ? v = o.value + 0.05 : v = o.value - 0.05, !(v > 150 || v < 0.5) && (o.value = v);
  }
  return G(
    () => o.value,
    (a) => {
      e.value && !l.value && (e.value.style.transform = `scale(${a})`);
    }
  ), { handleZoom: f, canvasScale: o };
}
function On(e, n = 16.66) {
  let o;
  function l() {
    f(), o = window.setInterval(e, n);
  }
  function f() {
    window.clearInterval(o);
  }
  return {
    startTimedQuery: l,
    stopTimedQuery: f
  };
}
const Xt = { class: "min-w-750px rounded" }, jt = { class: "h-full rounded" }, en = /* @__PURE__ */ me({
  __name: "index",
  setup(e, { expose: n }) {
    const o = q.getComponent("monacoEditor"), l = q.getComponent("modal"), f = $(null), a = $(!1), v = $(!1), s = $({}), w = ie("pageSchema"), O = $(null), A = $("");
    function m() {
      v.value = !1;
    }
    function N() {
      a.value = !1;
    }
    function t() {
      a.value = !0, A.value = ut();
    }
    async function S() {
      try {
        let y = await O.value.validateAll();
        if (!Object.keys(y).length) {
          alert("请添加表单组件后再尝试!");
          return;
        }
        Object.keys(y).length === 1 && (y = y.default), s.value = JSON.stringify(y, null, 2), de(() => {
          var D;
          (D = f.value) == null || D.setValue(s.value);
        }), v.value = !0;
      } catch (y) {
        console.error(y);
      }
    }
    return n({
      handleOpen: t
    }), (y, D) => (k(), le(Z(l), {
      modelValue: a.value,
      "onUpdate:modelValue": D[1] || (D[1] = (T) => a.value = T),
      title: "预览",
      class: "w-900px",
      width: "900px",
      onClose: N,
      onOk: S,
      okText: "表单数据"
    }, {
      default: Y(() => [
        re("div", Xt, [
          (k(), le(Z(Ot), {
            key: A.value,
            ref_key: "kb",
            ref: O,
            "page-schema": Z(w)
          }, null, 8, ["page-schema"])),
          se(Z(l), {
            modelValue: v.value,
            "onUpdate:modelValue": D[0] || (D[0] = (T) => v.value = T),
            title: "表单数据",
            class: "w-860px",
            width: "860px",
            onClose: m,
            onOk: m
          }, {
            default: Y(() => [
              re("div", jt, [
                se(Z(o), {
                  ref_key: "monacoEditorRef",
                  ref: f,
                  autoToggleTheme: "",
                  readOnly: "",
                  class: "h-full editor",
                  "model-value": s.value
                }, null, 8, ["model-value"])
              ])
            ]),
            _: 1
          }, 8, ["modelValue"])
        ])
      ]),
      _: 1
    }, 8, ["modelValue"]));
  }
}), tn = {
  key: 0,
  class: "epic-loading-box"
}, nn = { class: "epic-designer-main" }, on = { class: "epic-header-container" }, an = { class: "epic-loading-box" }, _n = /* @__PURE__ */ me({
  __name: "designer",
  props: {
    disabledZoom: { type: Boolean, default: !1 },
    hiddenHeader: { type: Boolean, default: !1 },
    lockDefaultSchemaEdit: { type: Boolean, default: !1 },
    formMode: { type: Boolean, default: !1 },
    title: { default: "EpicDesigner默认项目" },
    defaultSchema: {},
    sourceCodeReadOnly: { type: Boolean },
    source: { default: [] },
    updateSourceId: {}
  },
  emits: [
    "ready",
    "save",
    "reset",
    "toggleDeviceMode",
    "saveSourceData",
    "deleteSourceData",
    "updateSourceData"
  ],
  setup(e, { expose: n, emit: o }) {
    const { t: l } = Re(), f = fe(() => import("./index-D4GbR8l1.js")), a = fe(() => import("./index-D7FrAFgH.js")), v = fe(() => import("./index-CLfIsZY1.js")), s = fe(() => import("./index-DdqQ7Qh_.js")), w = fe(() => import("./index-B5pPrBIF.js")), O = He(), A = pt(), m = e;
    let N = {
      schemas: [
        {
          type: "form",
          id: "root",
          label: l("page"),
          children: [],
          componentProps: {
            name: l("form"),
            style: {
              padding: "16px"
            }
          }
        }
        // {
        //   type: "form",
        //   id: "root",
        //   label: "表单",
        //   children: [],
        //   componentProps: {
        //     style: {
        //       margin: "0px",
        //     },
        //     name: "default",
        //     labelWidth: "100px",
        //     labelLayout: "fixed",
        //     labelCol: {
        //       span: 5,
        //     },
        //     wrapperCol: {
        //       span: 19,
        //     },
        //   },
        // },
      ],
      script: `const { defineExpose, find } = epic;

function test (){
    console.log('test')
}

// 通过defineExpose暴露的函数或者属性
defineExpose({
 test
})`
    };
    Ee(() => {
      if (m.defaultSchema) {
        N = m.defaultSchema;
        return;
      }
      m.source && q.setSourceData(m.source), m.formMode && (N.schemas = q.formSchemas);
    }), O.setDesignMode(), O.setDefaultComponentIds(N.schemas);
    const t = o, S = $(null), y = pe({
      checkedNode: null,
      hoverNode: null,
      disableHover: !1,
      matched: []
    }), D = pe({
      schemas: [],
      script: N.script
    }), { disabledZoom: T } = Oe();
    Ee(() => {
      T.value = m.disabledZoom;
    }), Ee(() => {
      const c = D.script;
      c && c !== "" && O.setMethods(c);
    }), ee("pageSchema", D), ee("revoke", A), ee("pageManager", O), ee(
      "designerProps",
      ae(() => m)
    ), ee("designer", {
      setCheckedNode: _,
      setHoverNode: F,
      setDisableHover: g,
      handleToggleDeviceMode: B,
      reset: b,
      state: y
    }), oe.on("saveSourceData", (c) => {
      t("saveSourceData", c);
    }), oe.on("deleteSourceData", (c) => {
      t("deleteSourceData", c);
    }), oe.on("updateSourceData", (c) => {
      t("updateSourceData", c);
    });
    function p() {
      D.schemas = te(N.schemas), _(D.schemas[0]), A.push(D.schemas, "初始化撤销功能");
    }
    async function _(c = D.schemas[0]) {
      y.checkedNode = c, y.matched = dt(D.schemas, c.id);
    }
    async function F(c = null) {
      var P;
      if (!c || y.disableHover)
        return y.hoverNode = null, !1;
      if ((c == null ? void 0 : c.id) === ((P = y.hoverNode) == null ? void 0 : P.id))
        return !1;
      y.hoverNode = c;
    }
    function C() {
      de(() => {
        t("ready", { pageManager: O });
      });
    }
    async function g(c = !1) {
      y.disableHover = c;
    }
    function Q(c) {
      he(D, te(c));
    }
    function K() {
      return Ue(D);
    }
    function b() {
      Pe(D.schemas, N.schemas) && D.script === N.script || (he(D.schemas, N.schemas), D.script = N.script, _(D.schemas[0]), A.push(D.schemas, "重置操作"), t("reset", D));
    }
    function i() {
      t("save", Ue(D));
    }
    function B(c) {
      t("toggleDeviceMode", c);
    }
    function u() {
      S.value.handleOpen();
    }
    return p(), n({
      revoke: A,
      setData: Q,
      getData: K,
      reset: b,
      preview: u
    }), (c, P) => Z(q).initialized.value ? (k(), le(We, {
      key: 1,
      onResolve: C
    }, {
      default: Y(() => [
        re("div", nn, [
          re("div", on, [
            j(c.$slots, "header", {}, () => [
              m.hiddenHeader ? Ce("", !0) : (k(), le(Z(f), {
                key: 0,
                onPreview: u,
                onSave: i
              }, {
                header: Y(() => [
                  j(c.$slots, "header-prefix")
                ]),
                prefix: Y(() => [
                  j(c.$slots, "header-prefix")
                ]),
                title: Y(() => [
                  j(c.$slots, "header-title")
                ]),
                "right-prefix": Y(() => [
                  j(c.$slots, "header-right-prefix")
                ]),
                "right-action": Y(() => [
                  j(c.$slots, "header-right-action")
                ]),
                "right-suffix": Y(() => [
                  j(c.$slots, "header-right-suffix")
                ]),
                _: 3
              }))
            ])
          ]),
          re("div", {
            class: lt(["epic-split-view-container", { "hidden-header": e.hiddenHeader }])
          }, [
            se(Z(a)),
            se(Z(v)),
            se(Z(s))
          ], 2),
          se(en, {
            ref_key: "previewRef",
            ref: S
          }, null, 512)
        ])
      ]),
      fallback: Y(() => [
        re("div", an, [
          se(Z(w))
        ])
      ]),
      _: 3
    })) : (k(), ye("div", tn));
  }
}), rn = {
  component: async () => await import("./index-DAd3MFcT.js"),
  defaultSchema: {
    label: "代码编辑器",
    type: "monacoEditor",
    field: "monacoEditor",
    icon: "epic-icon-write",
    input: !0
  },
  config: {
    attribute: [
      {
        label: "字段名",
        type: "input",
        field: "field"
      },
      {
        label: "标题",
        type: "input",
        field: "label"
      },
      {
        label: "默认值",
        type: "monacoEditor",
        field: "componentProps.defaultValue"
      }
    ]
  },
  bindModel: "model-value"
}, { t: Fe } = Re(), sn = {
  component: async () => await import("./index-DiDIFoTk.js"),
  defaultSchema: {
    label: Fe("page"),
    type: "page",
    componentProps: {},
    children: []
  },
  config: {
    attribute: [
      {
        label: Fe("pageName"),
        type: "input",
        componentProps: {
          placeholder: Fe("pleaseEnter")
        },
        field: "componentProps.name"
      }
    ]
  }
}, { t: be } = Re();
function ln(e) {
  e.component("EInputSize", async () => await import("./index-CE4TxSMc.js")), e.component("EColEditor", async () => await import("./index-BIKPuM5L.js")), e.component("EActionEditor", async () => await import("./index-EGQJEXtQ.js")), e.component("ERuleEditor", async () => await import("./index-C2v1y0Nl.js")), e.component("EOptionsEditor", async () => await import("./index-6GXffpPe.js")), e.component("ENode", async () => await import("./index-CdofDe1Q.js")), e.component("EDataSource", async () => await import("./index-DC5DXtxS.js")), e.component("EColumnEditor", async () => await import("./index-o1-cSrSX.js")), e.component("PaddingMarginControl", async () => await import("./index-BTCAAOYE.js")), e.component("ESourceDataSelect", async () => await import("./index-B26OaWwQ.js")), e.component("EValidateParam", async () => await import("./index-BP_y2P36.js")), e.component("EDescribe", async () => await import("./index-0QX0Iei9.js")), e.registerActivitybar({
    id: "component_view",
    title: be("component"),
    icon: "icon--epic--extension-outline",
    component: async () => await import("./index-BunXE_u_.js")
  }), e.registerActivitybar({
    id: "outline_view",
    title: be("outline"),
    icon: "icon--epic--account-tree-outline-rounded",
    component: async () => await import("./outline-XI5k60Hm.js")
  }), e.registerRightSidebar({
    id: "attribute_view",
    title: be("attribute"),
    component: async () => await import("./attributeView-CMMiXhrL.js")
  }), e.registerRightSidebar({
    id: "style_view",
    title: be("style"),
    component: async () => await import("./styleView-BTfVt0rn.js")
  }), e.registerRightSidebar({
    id: "event_view",
    title: "事件",
    component: async () => await import("./eventView-BIk8NM18.js")
  }), [rn, sn].forEach((o) => {
    e.registerComponent(o);
  });
}
ln(q);
export {
  wt as E,
  Ot as _,
  yn as a,
  Dn as b,
  Oe as c,
  On as d,
  Zt as e,
  bn as f,
  wn as g,
  En as h,
  vn as i,
  _n as j,
  Qt as k,
  kt as l,
  Gt as m,
  qt as n,
  He as o,
  pt as p,
  Sn as u,
  gn as w
};