UNPKG

epic-designer-gold

Version:

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

1,763 lines 55 kB
import { ref as $, reactive as pe, defineComponent as me, openBlock as k, createBlock as le, unref as K, mergeProps as $e, withCtx as Q, renderSlot as ee, getCurrentInstance as we, inject as ie, watch as X, useAttrs as Qe, provide as te, shallowRef as ze, computed as ae, watchEffect as Ee, onUnmounted as Je, resolveComponent as Ye, createElementBlock as ye, Fragment as Le, createElementVNode as re, createStaticVNode as ke, toDisplayString as qe, createCommentVNode as Ce, resolveDynamicComponent as je, createVNode as se, useSlots as et, Suspense as We, renderList as tt, nextTick as de, onMounted as Ve, 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 ne, 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 Y, u as Me } from "./index-B1s67XDZ.js";
import { ElMessage as Ie } from "element-plus";
import "./markdownEditorPreview-CG36ecpC.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 Ge() {
  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, Z]) => (C[g] = Z.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 b(p, _ = "default") {
    if (f[_]) {
      const F = f[_];
      he(p, F);
    }
    f[_] = p;
  }
  function R(p, _ = "default") {
    if (f[_]) {
      he(f[_], p, !1);
      return;
    }
    f[_] = p;
  }
  return {
    componentInstances: e,
    funcs: n,
    isDesignMode: o,
    defaultComponentIds: l,
    forms: f,
    addFormData: b,
    setFormData: R,
    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(K(o), $e({
      key: 0,
      ref_key: "formItemRef",
      ref: a,
      onVnodeMounted: v
    }, l.formItemProps), {
      default: Q(() => [
        ee(s.$slots, "default")
      ]),
      _: 3
    }, 16, ["onVnodeMounted"])) : ee(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(ne(a.componentSchema));
    _();
    const S = {};
    async function y(r) {
      var x;
      try {
        o.value = !0, l.value = "正在识别中...请稍等";
        const V = {
          url: r.callBackUrl,
          headers: {
            Authorization: "Bearer " + Y.get("Admin-Token"),
            "X-Tenant-Gray": Y.get("X-Tenant-Gray"),
            lang: Y.get("saas-locale") || "zh-CN",
            zone: Intl.DateTimeFormat().resolvedOptions().timeZone
          }
        }, E = (r.callBackMethod || "").toLowerCase(), d = Array.isArray(r.url) ? r.url.filter((M) => typeof M == "string" && M.trim()) : [];
        if (d.length === 0) {
          Ie.warning("未获取到上传文件地址");
          return;
        }
        const J = { [r.callBackField]: d.join(",") };
        E === "get" ? (V.method = "get", V.params = J) : (V.method = E || "post", V.data = J);
        let G = await ge(V);
        if (((x = G.data) == null ? void 0 : x.code) === 403) {
          Ie.error(G.data.msg || "识别失败");
          return;
        }
        let L = {};
        r.callBackDataPath ? L = r.callBackDataPath.split(".").reduce((Ae, Ze) => Ae[Ze], G.data) || {} : L = G.data || {};
        const j = Object.keys(L), _e = ne(s);
        r.validate && (r.validateParams.forEach((M) => {
          s.orcWarningInfo__copy_data && s.orcWarningInfo__copy_data[M.value] && (s[M.value] = s.orcWarningInfo__copy_data[M.value]);
        }), s[r.field + "-orcWarningInfo"] = "", r.validateParams.forEach((M) => {
          s[M.value] && L[M.value] && L[M.value] !== s[M.value] && (a.componentSchema.componentProps.validateStatus = !0, s[r.field + "-orcWarningInfo"] ? s[r.field + "-orcWarningInfo"] = s[r.field + "-orcWarningInfo"] + "," + M.label + "已从" + s[M.value] + "改为" + L[M.value] : s[r.field + "-orcWarningInfo"] = M.label + "已从" + s[M.value] + "改为" + L[M.value]);
        })), S[r.field] ? (Object.assign(s, S[r.field]), j.forEach((M) => {
          M in S[r.field] || (S[r.field][M] = s[M]);
        })) : (S[r.field] = {}, j.forEach((M) => {
          S[r.field][M] = s[M];
        })), 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 (V) {
        Ie.error("OCR 识别回调处理失败:" + V.message);
      } finally {
        o.value = !1, l.value = "加载中";
      }
    }
    async function b({
      value: r,
      field: x,
      fillDataSource: V,
      fillDataParams: E
    }) {
      try {
        o.value = !0;
        const J = (await ge({
          url: a.sourceDateUrl,
          method: "get",
          params: {
            id: V ?? ""
          },
          headers: {
            Authorization: "Bearer " + Y.get("Admin-Token"),
            "X-Tenant-Gray": Y.get("X-Tenant-Gray"),
            lang: Y.get("saas-locale") || "zh-CN",
            //语言
            zone: Intl.DateTimeFormat().resolvedOptions().timeZone
            //时区
          }
        })).data.data;
        let G = 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 " + Y.get("Admin-Token"),
            "X-Tenant-Gray": Y.get("X-Tenant-Gray"),
            lang: Y.get("saas-locale") || "zh-CN",
            //语言
            zone: Intl.DateTimeFormat().resolvedOptions().timeZone
            //时区
          }
        });
        if (J && (J != null && J.dataPath)) {
          let _e = J.dataPath.split(".").reduce((M, Ae) => M[Ae], G.data);
          E.split(",").forEach((M) => {
            s[M] = _e[M];
          });
        } else {
          let L = G.data;
          E.split(",").forEach((j) => {
            s[j] = L[j];
          });
        }
        s.orcWarningInfo__copy_data = JSON.parse(
          JSON.stringify(s)
        );
      } catch (d) {
        console.log(d);
      } finally {
        o.value = !1, l.value = "加载中";
      }
    }
    async function R(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 " + Y.get("Admin-Token"),
            "X-Tenant-Gray": Y.get("X-Tenant-Gray"),
            lang: Y.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 " + Y.get("Admin-Token"),
            "X-Tenant-Gray": Y.get("X-Tenant-Gray"),
            lang: Y.get("saas-locale") || "zh-CN",
            //语言
            zone: Intl.DateTimeFormat().resolvedOptions().timeZone
            //时区
          }
        });
        if (E && (E != null && E.dataPath)) {
          const G = E.dataPath.split(".").reduce((L, j) => L[j], d.data);
          r.componentProps.options = p(
            G,
            E.dataKey,
            E.dataValue
          );
        } else
          r.componentProps.options = p(
            d.data,
            E.dataKey,
            E.dataValue
          );
        return r;
      }
      return r;
    }
    function p(r, x, V) {
      return r && Object.prototype.toString.call(r) === "[object Array]" ? r.map((E) => E.children && E.children.length ? {
        label: E[x],
        value: E[V] + "",
        children: p(E.children, x, V)
      } : {
        label: E[x],
        value: E[V] + ""
      }) : [];
    }
    X(
      () => a.componentSchema,
      (r) => {
        Pe(t, r, ["children"]) || (he(t, ne(r)), _());
      },
      {
        deep: !0
      }
    );
    function _() {
      O.isDesignMode.value && typeof t.field == "string" && (t.field += "-design-mode");
    }
    (a.resetFormData || N) && (s = {});
    const F = n, C = $(), g = $(), Z = (r) => {
      g.value = r;
    }, H = Qe();
    Object.keys(H).length && te("nodeAttrs", H);
    const D = 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 = ne(m), x.push(t.field));
      const V = {
        ...t,
        rules: r,
        rule: r,
        field: x
      };
      return V.children && delete V.children, V;
    }), u = ae(() => {
      var V, E, d;
      const r = ((V = c.value) == null ? void 0 : V.bindModel) ?? "modelValue", x = {};
      return t.on && Object.keys(t.on).forEach((J) => {
        x[`on${ct(J)}`] = (...G) => O.doActions(t.on[J], ...G);
      }), 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 ?? ""];
    }), X(
      () => v.value,
      () => {
        v.value !== (a.modelValue ?? s[t.field ?? ""]) && z(v.value);
      }
    ), X(
      () => 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 = (V, E) => (t.componentProps || (t.componentProps = {}), t.componentProps[V] = E), r.getAttr = (V) => t.componentProps[V], 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 T() {
      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, V, E;
      if (t = await R(t), typeof ((x = t.componentProps) == null ? void 0 : x.defaultValue) < "u") {
        const d = O.isDesignMode.value ? (V = t.componentProps) == null ? void 0 : V.defaultValue : s[t.field] ?? ((E = t.componentProps) == null ? void 0 : E.defaultValue);
        z(ne(d));
      }
      if (t.type === "slot") {
        const d = t.slotName;
        if (!d) return;
        D.value = me({
          setup() {
            return () => ee(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();
        D.value = d.default ?? d;
      } else
        r && (D.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 X(
      () => 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(T), (r, x) => {
      var E;
      const V = Ye("ENode");
      return k(), ye(Le, null, [
        o.value ? (k(), ye("div", ht, [
          re("div", vt, [
            x[1] || (x[1] = ke('<div class="epic-loading-wave" data-v-bfeeeff4><div class="wave" data-v-bfeeeff4></div><div class="wave" data-v-bfeeeff4></div><div class="wave" data-v-bfeeeff4></div><div class="wave" data-v-bfeeeff4></div><div class="wave" data-v-bfeeeff4></div></div>', 1)),
            re("span", gt, qe(l.value), 1)
          ])
        ])) : Ce("", !0),
        D.value && i.value ? (k(), le(mt, {
          key: 1,
          hasFormItem: K(t).noFormItem !== !0 && ((E = c.value) == null ? void 0 : E.defaultSchema.input),
          formItemProps: B.value,
          onUpdateFormItemRef: Z
        }, {
          default: Q(() => [
            (k(), le(je(D.value), $e({
              ref_key: "componentInstance",
              ref: C,
              onVnodeMounted: P,
              model: K(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": b
            }), {
              node: Q((d) => [
                se(V, $e({
                  id: a.id
                }, d, {
                  sourceDateUrl: a.sourceDateUrl
                }), null, 16, ["id", "sourceDateUrl"])
              ]),
              "edit-node": Q(() => [
                ee(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-bfeeeff4"]]);
function St() {
  const e = $(!1), n = Ge(), o = $({});
  function l() {
    return new Promise((t) => {
      if (e.value)
        t();
      else {
        const S = X(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 ne(await S(y));
  }
  async function v(t = "default") {
    return await a(t, (S) => S.getData());
  }
  function s(t, S = "default", y = void 0) {
    var b, R;
    if (y && Object.keys(y).length) {
      let p = function(g) {
        let Z = [];
        return g.forEach((H) => {
          H.children && (Z = [...Z, ...p(H.children)]), Z.push(H);
        }), Z;
      }, F = function(g) {
        var H;
        let Z = p((H = y == null ? void 0 : y.schemas[0]) == null ? void 0 : H.children);
        return Object.keys(g).forEach((D) => {
          var u, c, P, T, I, h, z;
          const i = Z.find((U) => U.field === D), 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((T = i == null ? void 0 : i.componentProps) == null ? void 0 : T.type)) && typeof g[D] == "string")
            g[D] = (I = g[D]) == 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[D] == "string")
            g[D].indexOf(";") === -1 && g[D].indexOf(";") === -1 ? g[D][g[D]] : g[D].indexOf(";") > -1 ? g[D] = g[D].split(";").map((U) => U.split(",")) : g[D].indexOf(";") === -1 ? g[D] = g[D].split(",") : g[D].indexOf(";") > -1 ? g[D] = g[D].split(";").map((U) => U.split(",")) : g[D].indexOf(";") === -1 && (g[D] = g[D].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[D] == "string") {
            let U = [];
            Object.entries(g).forEach(([W, r]) => {
              g[D] === r && W !== i.field && W.indexOf("@") > -1 && W.indexOf(D) > -1 && (U = W.split("@")[1].split(","));
            }), g[D] = g[D].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[D] = Number(g[D]) : (i == null ? void 0 : i.type) === "switch" && (g[D] = typeof g[D] == "boolean" ? g[D] : g[D].indexOf("true") > -1);
        }), g;
      }(t);
      console.log("%c [ data1 ]-131", "font-size:13px; background:pink; color:#bf2c9f;", F), n.setFormData(F, S);
      const C = (b = o.value) == null ? void 0 : b[S];
      C == null || C.clearValidate();
    } else {
      n.setFormData(t, S);
      const p = (R = o.value) == null ? void 0 : R[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 b = o.value[y];
      b && (S[y] = ne(await t(b)));
    }
    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 bt = {
  key: 0,
  class: "epic-loading-box"
}, Dt = { 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: b } = St(), R = e, p = pe({
      schemas: []
    });
    X(
      () => R.pageSchema,
      (u) => {
        he(p, u);
      },
      {
        immediate: !0,
        deep: !0
      }
    ), X(
      () => R.formData,
      (u) => {
        if (u) {
          let c = H(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 T(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) => T(x, U)).flat(), W;
          });
        const z = P(I);
        return Array.isArray(z.children) && (z.children = z.children.map((U) => T(U, h)).flat()), z;
      }
      return u.map((I) => T(I, c)).flat();
    }
    function C(u, c = "", P = { root: 0 }) {
      const T = c || "root";
      return c || (P.root = 0), P[T] === void 0 && (P[T] = 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[T]}]` : `${z}[${P[T]}]`, P[T]++) : 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 = "", T = {}) {
      const I = P || "root";
      return T[I] === void 0 && (T[I] = 0), u.forEach((h) => {
        const z = h.field || "";
        let U = P ? `${P}.${z}` : `${z}`;
        h.type === "card" && h.multiple ? (typeof c[U][`${T[I]}`] == "object" ? Object.keys(c[U][`${T[I]}`]).forEach((W) => {
          c[`${U}[${T[I]}].${W}`] = c[U][`${T[I]}`][W];
        }) : c[`${U}[${T[I]}]`] = c[U][`${T[I]}`], h.children && (h.children = g(
          h.children,
          c,
          `${U}[${T[I]}]` || P,
          T
        )), T[I]++) : h.children && (h.children = g(h.children, c, P, T));
      }), T[I] = 0, c;
    }
    function Z(u, c, P) {
      let T = g(ne(u), ne(c));
      return {
        obj: C(u),
        dataObj: T
      };
    }
    function H(u) {
      let c = _(R.pageSchema.schemas[0].children);
      a.value = c.filter((h) => h.type === "card" && h.multiple);
      const P = F(R.pageSchema.schemas[0].children, u);
      let { obj: T, dataObj: I } = Z(P, u, a.value);
      return u = I, R.pageSchema.schemas[0].children = T, Object.keys(u).forEach((h) => {
        var z, U, W, r, x, V, E;
        if (h.indexOf("@") < 0) {
          const d = c.find((G) => G.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 = (V = d == null ? void 0 : d.componentProps) == null ? void 0 : V.props) != null && E.multiple) && typeof u[h] == "string")
            u[h].indexOf(";") > -1 ? u[h] = u[h].split(";").map((G) => G.split(",")) : u[h] = u[h].split(","), u[h].indexOf(";") > -1 ? u[h] = u[h].split(";").map((G) => G.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 G = [];
            Object.entries(u).forEach(([L, j]) => {
              u[h] === j && L !== d.field && L.indexOf("@") > -1 && L.indexOf(h) > -1 && (G = L.split("@")[1].split(","));
            }), u[h] = u[h].split(",").map((L, j) => ({
              url: L,
              name: G[j] || 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;
    }
    X(
      () => p.script,
      (u) => {
        u && w.setMethods(u, !0);
      },
      {
        immediate: !0
      }
    ), te("slots", et()), te("pageManager", w), te("forms", O), te("pageSchema", p), te(
      "disabled",
      ae(() => R.disabled)
    );
    const D = we(), i = D == null ? void 0 : D.proxy;
    function B() {
      de(() => {
        s.value = !0, f("ready", w), i && w.addComponentInstance("builder", i);
      });
    }
    return oe.on("updateformData" + (R.id ? R.id : ""), (u) => {
      f("change", u);
    }), n({
      ready: s,
      pageManager: w,
      getData: A,
      setData: m,
      validate: N,
      getForms: t,
      setForms: S,
      validateAll: y,
      getFormInstance: b
    }), (u, c) => K(q).initialized.value ? (k(), le(We, {
      key: 1,
      onResolve: B
    }, {
      default: Q(() => [
        re("div", Dt, [
          (k(!0), ye(Le, null, tt(p.schemas, (P, T) => (k(), le(K(wt), {
            id: R.id,
            key: T,
            sourceDateUrl: R.sourceDateUrl,
            componentSchema: P
          }, null, 8, ["id", "sourceDateUrl", "componentSchema"]))), 128))
        ])
      ]),
      fallback: Q(() => [
        re("div", Et, [
          se(K(l))
        ])
      ]),
      _: 1
    })) : (k(), ye("div", bt));
  }
});
function Re(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))), Re(f), o);
}
function ue(e) {
  return typeof e == "function" ? e() : K(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 He = (e) => e();
function Ct(e = He) {
  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 Tt(e, n, o = {}) {
  const {
    eventFilter: l = He,
    ...f
  } = o;
  return X(
    e,
    $t(
      l,
      n
    ),
    f
  );
}
function Vt(e, n, o = {}) {
  const {
    eventFilter: l,
    ...f
  } = o, { eventFilter: a, pause: v, resume: s, isActive: w } = Ct(l);
  return { stop: Tt(
    e,
    n,
    {
      ...f,
      eventFilter: a
    }
  ), pause: v, resume: s, isActive: w };
}
function Ke(e, n = !0, o) {
  Pt() ? Ve(e, o) : n ? e() : de(e);
}
function Mt(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 = X(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 Te(...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 = X(
    () => [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 Re(O), O;
}
function Rt(e) {
  return typeof e == "function" ? e : typeof e == "string" ? (n) => n.key === e : Array.isArray(e) ? (n) => e.includes(n.key) : () => !0;
}
function Xe(...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 = Rt(n);
  return Te(f, a, (A) => {
    A.repeat && ue(s) || w(A) && o(A);
  }, v);
}
function xe(e, n, o = {}) {
  return Xe(e, n, { ...o, eventName: "keydown" });
}
function Ne(e, n, o = {}) {
  return Xe(e, n, { ...o, eventName: "keyup" });
}
function Ut() {
  const e = $(!1), n = we();
  return n && Ve(() => {
    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 : {}, be = "__vueuse_ssr_handlers__", Jt = /* @__PURE__ */ Lt();
function Lt() {
  return be in Se || (Se[be] = Se[be] || {}), Se[be];
}
function Wt(e, n) {
  return Jt[e] || n;
}
function Gt(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 Ht = {
  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 b = ue(n), R = Gt(b), p = (f = l.serializer) != null ? f : Ht[R], { pause: _, resume: F } = Vt(
    y,
    () => g(y.value),
    { flush: a, deep: v, eventFilter: N }
  );
  m && s && Ke(() => {
    o instanceof Storage ? Te(m, "storage", H) : Te(m, Be, D), S && H();
  }), S || H();
  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 Z(i) {
    const B = i ? i.newValue : o.getItem(e);
    if (B == null)
      return w && b != null && o.setItem(e, p.write(b)), b;
    if (!i && O) {
      const u = p.read(B);
      return typeof O == "function" ? O(u, b) : R === "object" && !Array.isArray(u) ? { ...b, ...u } : u;
    } else return typeof B != "string" ? B : p.read(B);
  }
  function H(i) {
    if (!(i && i.storageArea !== o)) {
      if (i && i.key == null) {
        y.value = b;
        return;
      }
      if (!(i && i.key !== e)) {
        _();
        try {
          (i == null ? void 0 : i.newValue) !== p.write(y.value) && (y.value = Z(i));
        } catch (B) {
          t(B);
        } finally {
          i ? de(F) : F();
        }
      }
    }
  }
  function D(i) {
    H(i.detail);
  }
  return y;
}
function Kt(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 = X(
    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 Re(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 } = Kt(
    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
  );
  Ke(() => {
    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 = X(
    () => 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 b = (_) => s ? typeof s == "function" ? s(_) : zt(_) : _, R = () => It(e[n]) ? b(e[n]) : m, p = (_) => {
    N ? N(_) && S(y, _) : S(y, _);
  };
  if (w) {
    const _ = R(), F = $(_);
    let C = !1;
    return X(
      () => e[n],
      (g) => {
        C || (C = !0, F.value = b(g), de(() => C = !1));
      }
    ), X(
      F,
      (g) => {
        !C && (g !== e[n] || A) && p(g);
      },
      { deep: A }
    ), F;
  } else
    return ae({
      get() {
        return R();
      },
      set(_) {
        p(_);
      }
    });
}
function bn() {
  const { isDark: e } = Oe(), n = Mt(e);
  return {
    isDark: e,
    toggleDark: n
  };
}
function Xt() {
  const e = $(!1);
  return Ve(() => {
    Zt(e), Qt(e);
  }), X(
    () => e.value,
    () => {
      e.value ? document.documentElement.classList.add("dark") : document.documentElement.classList.remove("dark");
    }
  ), {
    isDark: e
  };
}
function Zt(e) {
  var n = document.documentElement;
  n && (n.classList.contains("dark") ? e.value = !0 : e.value = !1);
}
function Qt(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 Yt() {
  const e = $(1), n = $(!1), { isDark: o } = Xt(), { pressSpace: l, pressShift: f, pressCtrl: a } = kt();
  return {
    canvasScale: e,
    pressSpace: l,
    pressShift: f,
    pressCtrl: a,
    disabledZoom: n,
    isDark: o
  };
}
const Oe = _t(Yt);
function kt() {
  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 Dn(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 X(
    () => 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 qt = { 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 b;
          (b = f.value) == null || b.setValue(s.value);
        }), v.value = !0;
      } catch (y) {
        console.error(y);
      }
    }
    return n({
      handleOpen: t
    }), (y, b) => (k(), le(K(l), {
      modelValue: a.value,
      "onUpdate:modelValue": b[1] || (b[1] = (R) => a.value = R),
      title: "预览",
      class: "w-900px",
      width: "900px",
      onClose: N,
      onOk: S,
      okText: "表单数据"
    }, {
      default: Q(() => [
        re("div", qt, [
          (k(), le(K(Ot), {
            key: A.value,
            ref_key: "kb",
            ref: O,
            "page-schema": K(w)
          }, null, 8, ["page-schema"])),
          se(K(l), {
            modelValue: v.value,
            "onUpdate:modelValue": b[0] || (b[0] = (R) => v.value = R),
            title: "表单数据",
            class: "w-860px",
            width: "860px",
            onClose: m,
            onOk: m
          }, {
            default: Q(() => [
              re("div", jt, [
                se(K(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 } = Me(), f = fe(() => import("./index-D4GbR8l1.js")), a = fe(() => import("./index-D7FrAFgH.js")), v = fe(() => import("./index-BDbay10H.js")), s = fe(() => import("./index-DdqQ7Qh_.js")), w = fe(() => import("./index-B5pPrBIF.js")), O = Ge(), 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: []
    }), b = pe({
      schemas: [],
      script: N.script
    }), { disabledZoom: R } = Oe();
    Ee(() => {
      R.value = m.disabledZoom;
    }), Ee(() => {
      const c = b.script;
      c && c !== "" && O.setMethods(c);
    }), te("pageSchema", b), te("revoke", A), te("pageManager", O), te(
      "designerProps",
      ae(() => m)
    ), te("designer", {
      setCheckedNode: _,
      setHoverNode: F,
      setDisableHover: g,
      handleToggleDeviceMode: B,
      reset: D,
      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() {
      b.schemas = ne(N.schemas), _(b.schemas[0]), A.push(b.schemas, "初始化撤销功能");
    }
    async function _(c = b.schemas[0]) {
      y.checkedNode = c, y.matched = dt(b.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 Z(c) {
      he(b, ne(c));
    }
    function H() {
      return Ue(b);
    }
    function D() {
      Pe(b.schemas, N.schemas) && b.script === N.script || (he(b.schemas, N.schemas), b.script = N.script, _(b.schemas[0]), A.push(b.schemas, "重置操作"), t("reset", b));
    }
    function i() {
      t("save", Ue(b));
    }
    function B(c) {
      t("toggleDeviceMode", c);
    }
    function u() {
      S.value.handleOpen();
    }
    return p(), n({
      revoke: A,
      setData: Z,
      getData: H,
      reset: D,
      preview: u
    }), (c, P) => K(q).initialized.value ? (k(), le(We, {
      key: 1,
      onResolve: C
    }, {
      default: Q(() => [
        re("div", nn, [
          re("div", on, [
            ee(c.$slots, "header", {}, () => [
              m.hiddenHeader ? Ce("", !0) : (k(), le(K(f), {
                key: 0,
                onPreview: u,
                onSave: i
              }, {
                header: Q(() => [
                  ee(c.$slots, "header-prefix")
                ]),
                prefix: Q(() => [
                  ee(c.$slots, "header-prefix")
                ]),
                title: Q(() => [
                  ee(c.$slots, "header-title")
                ]),
                "right-prefix": Q(() => [
                  ee(c.$slots, "header-right-prefix")
                ]),
                "right-action": Q(() => [
                  ee(c.$slots, "header-right-action")
                ]),
                "right-suffix": Q(() => [
                  ee(c.$slots, "header-right-suffix")
                ]),
                _: 3
              }))
            ])
          ]),
          re("div", {
            class: lt(["epic-split-view-container", { "hidden-header": e.hiddenHeader }])
          }, [
            se(K(a)),
            se(K(v)),
            se(K(s))
          ], 2),
          se(en, {
            ref_key: "previewRef",
            ref: S
          }, null, 512)
        ])
      ]),
      fallback: Q(() => [
        re("div", an, [
          se(K(w))
        ])
      ]),
      _: 3
    })) : (k(), ye("div", tn));
  }
}), rn = {
  component: async () => await import("./index-9lgyy2hu.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 } = Me(), 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: De } = Me();
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-eQ-IMRBN.js")), e.component("ERuleEditor", async () => await import("./index-Da85fWdr.js")), e.component("EOptionsEditor", async () => await import("./index-C6ECxORQ.js")), e.component("ENode", async () => await import("./index-Cd-W4VAA.js")), e.component("EDataSource", async () => await import("./index-3OLiEs0w.js")), e.component("EColumnEditor", async () => await import("./index-azKN3Lou.js")), e.component("PaddingMarginControl", async () => await import("./index-BTCAAOYE.js")), e.component("ESourceDataSelect", async () => await import("./index-DU5wl0TC.js")), e.component("EValidateParam", async () => await import("./index-sUe23miY.js")), e.component("EDescribe", async () => await import("./index-DXvodSAE.js")), e.registerActivitybar({
    id: "component_view",
    title: De("component"),
    icon: "icon--epic--extension-outline",
    component: async () => await import("./index-D23fumx-.js")
  }), e.registerActivitybar({
    id: "outline_view",
    title: De("outline"),
    icon: "icon--epic--account-tree-outline-rounded",
    component: async () => await import("./outline-XI5k60Hm.js")
  }), e.registerRightSidebar({
    id: "attribute_view",
    title: De("attribute"),
    component: async () => await import("./attributeView-DTaSQU3v.js")
  }), e.registerRightSidebar({
    id: "style_view",
    title: De("style"),
    component: async () => await import("./styleView-CJp3F3e4.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,
  bn as b,
  Oe as c,
  On as d,
  Kt as e,
  Dn as f,
  wn as g,
  En as h,
  vn as i,
  _n as j,
  Zt as k,
  Yt as l,
  Xt as m,
  kt as n,
  Ge as o,
  pt as p,
  Sn as u,
  gn as w
};