import { defineComponent as D, ref as v, resolveComponent as u, openBlock as S, createBlock as h, withCtx as n, createElementVNode as U, createVNode as l, createTextVNode as f, toDisplayString as b, inject as B, computed as T, createElementBlock as j, Fragment as M } from "vue";
import { d as F, p as x, o as w } from "./index-597e6e44.mjs";
const z = { class: "dialog-footer" }, P = /* @__PURE__ */ D({
  __name: "ComputedEditorDialog",
  setup(I, { expose: g }) {
    const y = v("code");
    function p(t, e) {
      a.value = t, m = e, r.value = !0;
    }
    const r = v(!1), a = v({});
    let m;
    const V = v(), c = async (t) => {
      t && await t.validate((e) => {
        e && (r.value = !1, m && m(a.value));
      });
    };
    return g({ show: p }), (t, e) => {
      const o = u("el-input"), d = u("el-form-item"), s = u("el-alert"), _ = u("b-ace-editor"), C = u("el-tab-pane"), E = u("el-tabs"), $ = u("el-form"), k = u("el-button"), R = u("el-dialog");
      return S(), h(R, {
        modelValue: r.value,
        "onUpdate:modelValue": e[7] || (e[7] = (i) => r.value = i),
        title: t.$t("_.builtIn.plugin.computedEditor.dialogTitle"),
        "close-on-click-modal": !1,
        "close-on-press-escape": !1
      }, {
        footer: n(() => [
          U("span", z, [
            l(k, {
              onClick: e[5] || (e[5] = (i) => r.value = !1)
            }, {
              default: n(() => [
                f(b(t.$t("_._.cancel")), 1)
              ]),
              _: 1
            }),
            l(k, {
              type: "primary",
              onClick: e[6] || (e[6] = (i) => c(V.value))
            }, {
              default: n(() => [
                f(b(t.$t("_._.save")), 1)
              ]),
              _: 1
            })
          ])
        ]),
        default: n(() => [
          l($, {
            ref_key: "dataEditorFormRef",
            ref: V,
            model: a.value,
            "label-width": "120px"
          }, {
            default: n(() => [
              l(d, {
                label: t.$t("_._.key"),
                prop: "key",
                required: ""
              }, {
                default: n(() => [
                  l(o, {
                    modelValue: a.value.key,
                    "onUpdate:modelValue": e[0] || (e[0] = (i) => a.value.key = i)
                  }, null, 8, ["modelValue"])
                ]),
                _: 1
              }, 8, ["label"]),
              l(d, {
                label: t.$t("_._.description"),
                prop: "description"
              }, {
                default: n(() => [
                  l(o, {
                    modelValue: a.value.description,
                    "onUpdate:modelValue": e[1] || (e[1] = (i) => a.value.description = i)
                  }, null, 8, ["modelValue"])
                ]),
                _: 1
              }, 8, ["label"]),
              l(E, {
                modelValue: y.value,
                "onUpdate:modelValue": e[4] || (e[4] = (i) => y.value = i),
                class: "demo-tabs"
              }, {
                default: n(() => [
                  l(C, {
                    label: t.$t("_.builtIn.plugin.computedEditor.code"),
                    name: "code"
                  }, {
                    default: n(() => [
                      l(d, {
                        label: "",
                        prop: "code",
                        required: "",
                        "label-width": 1
                      }, {
                        default: n(() => [
                          l(s, {
                            type: "info",
                            closable: !1,
                            title: t.$t("_.builtIn.plugin.computedEditor.codePrompt")
                          }, null, 8, ["title"]),
                          l(_, {
                            modelValue: a.value.code,
                            "onUpdate:modelValue": e[2] || (e[2] = (i) => a.value.code = i),
                            lang: "javascript",
                            width: "100%",
                            height: "30vh",
                            readonly: !1,
                            "font-size": 14
                          }, null, 8, ["modelValue"])
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  }, 8, ["label"]),
                  l(C, {
                    label: t.$t("_.builtIn.plugin.computedEditor.codeSet"),
                    name: "codeSet"
                  }, {
                    default: n(() => [
                      l(d, {
                        label: "",
                        prop: "codeSet",
                        "label-width": 1
                      }, {
                        default: n(() => [
                          l(s, {
                            type: "info",
                            closable: !1,
                            title: t.$t("_.builtIn.plugin.computedEditor.codeSetPrompt")
                          }, null, 8, ["title"]),
                          l(_, {
                            modelValue: a.value.codeSet,
                            "onUpdate:modelValue": e[3] || (e[3] = (i) => a.value.codeSet = i),
                            lang: "javascript",
                            width: "100%",
                            height: "30vh",
                            readonly: !1,
                            "font-size": 14
                          }, null, 8, ["modelValue"])
                        ]),
                        _: 1
                      })
                    ]),
                    _: 1
                  }, 8, ["label"])
                ]),
                _: 1
              }, 8, ["modelValue"])
            ]),
            _: 1
          }, 8, ["model"])
        ]),
        _: 1
      }, 8, ["modelValue", "title"]);
    };
  }
}), q = { class: "dialog-footer" }, N = /* @__PURE__ */ D({
  __name: "ComputedValueDialog",
  setup(I, { expose: g }) {
    const y = B("context"), p = v();
    let r;
    function a(c) {
      r = c, p.value = V(), m.value = !0;
    }
    const m = v(!1);
    function V(c) {
      var e;
      const t = (e = y.computedManager.get(r.key)) == null ? void 0 : e.value;
      return t != null ? typeof t == "string" ? t : JSON.stringify(t, null, 2) : "undefined";
    }
    return g({ show: a }), (c, t) => {
      const e = u("b-ace-editor"), o = u("el-button"), d = u("el-dialog");
      return S(), h(d, {
        modelValue: m.value,
        "onUpdate:modelValue": t[2] || (t[2] = (s) => m.value = s),
        title: c.$t("_.builtIn.plugin.computedEditor.valueDialogTitle")
      }, {
        footer: n(() => [
          U("span", q, [
            l(o, {
              onClick: t[1] || (t[1] = (s) => m.value = !1)
            }, {
              default: n(() => [
                f(b(c.$t("_._.close")), 1)
              ]),
              _: 1
            })
          ])
        ]),
        default: n(() => [
          l(e, {
            modelValue: p.value,
            "onUpdate:modelValue": t[0] || (t[0] = (s) => p.value = s),
            lang: "json",
            width: "100%",
            height: "50vh",
            readonly: !1,
            "font-size": 14
          }, null, 8, ["modelValue"])
        ]),
        _: 1
      }, 8, ["modelValue", "title"]);
    };
  }
}), O = /* @__PURE__ */ D({
  __name: "index",
  setup(I) {
    const g = v(), y = v();
    let p = -1;
    const r = B("context");
    function a() {
      p = -1, g.value.show({ code: "", codeSet: "" }, V);
    }
    function m(o) {
      p = o.$index;
      const d = F(o.row);
      g.value.show(d, V);
    }
    const V = (o) => {
      p < 0 ? e.value.push(o) : (e.value[p] = o, r.computedManager.clear(o.key));
    }, c = (o) => {
      x.confirm(
        w("_.builtIn.plugin.computedEditor.deletePrompt"),
        w("_._.warning"),
        {
          confirmButtonText: w("_._.yes"),
          cancelButtonText: w("_._.no"),
          type: "warning"
        }
      ).then(() => {
        e.value.splice(o.$index, 1), r.computedManager.reset(o.row.key);
      });
    }, t = (o) => {
      y.value.show(o.row);
    }, e = T(() => r.codeManager.getCode().computed);
    return (o, d) => {
      const s = u("el-table-column"), _ = u("el-button"), C = u("el-button-group"), E = u("el-table");
      return S(), j(M, null, [
        l(E, {
          data: e.value,
          border: ""
        }, {
          empty: n(() => [
            l(_, {
              type: "primary",
              onClick: d[1] || (d[1] = ($) => a())
            }, {
              default: n(() => [
                f(b(o.$t("_._.add")), 1)
              ]),
              _: 1
            })
          ]),
          default: n(() => [
            l(s, {
              prop: "key",
              label: o.$t("_._.key")
            }, null, 8, ["label"]),
            l(s, {
              prop: "description",
              label: o.$t("_._.description")
            }, null, 8, ["label"]),
            l(s, {
              fixed: "right",
              label: o.$t("_._.operation"),
              width: "280px"
            }, {
              default: n(($) => [
                l(C, null, {
                  default: n(() => [
                    l(_, {
                      type: "primary",
                      onClick: d[0] || (d[0] = (k) => a())
                    }, {
                      default: n(() => [
                        f(b(o.$t("_._.add")), 1)
                      ]),
                      _: 1
                    }),
                    l(_, {
                      type: "success",
                      onClick: (k) => m($)
                    }, {
                      default: n(() => [
                        f(b(o.$t("_._.edit")), 1)
                      ]),
                      _: 2
                    }, 1032, ["onClick"]),
                    l(_, {
                      type: "danger",
                      onClick: (k) => c($)
                    }, {
                      default: n(() => [
                        f(b(o.$t("_._.del")), 1)
                      ]),
                      _: 2
                    }, 1032, ["onClick"]),
                    l(_, {
                      type: "success",
                      onClick: (k) => t($)
                    }, {
                      default: n(() => [
                        f(b(o.$t("_.builtIn.plugin.computedEditor.value")), 1)
                      ]),
                      _: 2
                    }, 1032, ["onClick"])
                  ]),
                  _: 2
                }, 1024)
              ]),
              _: 1
            }, 8, ["label"])
          ]),
          _: 1
        }, 8, ["data"]),
        l(P, {
          ref_key: "computedEditorDialogRef",
          ref: g
        }, null, 512),
        l(N, {
          ref_key: "computedValueDialogRef",
          ref: y
        }, null, 512)
      ], 64);
    };
  }
});
export {
  O as default
};
