import { defineComponent as C, ref as b, resolveComponent as n, openBlock as V, createBlock as E, withCtx as l, createElementVNode as B, createVNode as e, createTextVNode as u, inject as $, computed as D, createElementBlock as U, Fragment as h } from "vue";
import { d as R, i as T } from "./index-9115a619.mjs";
const A = { class: "dialog-footer" }, F = /* @__PURE__ */ C({
  __name: "LifecycleEditorDialog",
  setup(w, { expose: f }) {
    function s(d, o) {
      a.value = d, m = o, r.value = !0;
    }
    const r = b(!1), a = b({});
    let m;
    const _ = b(), k = async (d) => {
      d && await d.validate((o) => {
        o && (r.value = !1, m && m(a.value));
      });
    };
    return f({ show: s }), (d, o) => {
      const t = n("el-option"), v = n("el-select"), i = n("el-form-item"), g = n("b-ace-editor"), x = n("el-form"), p = n("el-button"), y = n("el-dialog");
      return V(), E(y, {
        modelValue: r.value,
        "onUpdate:modelValue": o[4] || (o[4] = (c) => r.value = c),
        title: "Lifecycle editor",
        "close-on-click-modal": !1,
        "close-on-press-escape": !1
      }, {
        footer: l(() => [
          B("span", A, [
            e(p, {
              onClick: o[2] || (o[2] = (c) => r.value = !1)
            }, {
              default: l(() => [
                u("Cancel")
              ]),
              _: 1
            }),
            e(p, {
              type: "primary",
              onClick: o[3] || (o[3] = (c) => k(_.value))
            }, {
              default: l(() => [
                u(" Save ")
              ]),
              _: 1
            })
          ])
        ]),
        default: l(() => [
          e(x, {
            ref_key: "dataEditorFormRef",
            ref: _,
            model: a.value,
            "label-width": "120px"
          }, {
            default: l(() => [
              e(i, {
                label: "Key",
                prop: "key",
                required: ""
              }, {
                default: l(() => [
                  e(v, {
                    modelValue: a.value.key,
                    "onUpdate:modelValue": o[0] || (o[0] = (c) => a.value.key = c)
                  }, {
                    default: l(() => [
                      e(t, { value: "onMounted" }),
                      e(t, { value: "onUpdated" }),
                      e(t, { value: "onUnmounted" }),
                      e(t, { value: "onBeforeMount" }),
                      e(t, { value: "onBeforeUpdate" }),
                      e(t, { value: "onBeforeUnmount" }),
                      e(t, { value: "onErrorCaptured" }),
                      e(t, { value: "onRenderTracked" }),
                      e(t, { value: "onRenderTracked" }),
                      e(t, { value: "onActivated" }),
                      e(t, { value: "onDeactivated" })
                    ]),
                    _: 1
                  }, 8, ["modelValue"])
                ]),
                _: 1
              }),
              e(i, {
                label: "Code",
                prop: "code",
                required: ""
              }, {
                default: l(() => [
                  e(g, {
                    modelValue: a.value.code,
                    "onUpdate:modelValue": o[1] || (o[1] = (c) => a.value.code = c),
                    lang: "javascript",
                    width: "100%",
                    height: "40vh",
                    readonly: !1,
                    "font-size": 14
                  }, null, 8, ["modelValue"])
                ]),
                _: 1
              })
            ]),
            _: 1
          }, 8, ["model"])
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
}), j = /* @__PURE__ */ C({
  __name: "index",
  setup(w) {
    const f = b();
    let s = -1;
    const r = $("context");
    function a() {
      s = -1, f.value.show({ mode: "script", code: "" }, _);
    }
    function m(o) {
      s = o.$index;
      const t = R(o.row);
      f.value.show(t, _);
    }
    const _ = (o) => {
      s < 0 ? d.value.push(o) : d.value[s] = o;
    }, k = (o) => {
      T.confirm(
        "Will you want to delte this lifecycle",
        "Warning",
        {
          confirmButtonText: "Yes",
          cancelButtonText: "No",
          type: "warning"
        }
      ).then(() => {
        d.value.splice(o.$index, 1);
      });
    }, d = D(() => r.codeManager.getCode().lifecycle);
    return (o, t) => {
      const v = n("el-table-column"), i = n("el-button"), g = n("el-button-group"), x = n("el-table");
      return V(), U(h, null, [
        e(x, {
          data: d.value,
          border: ""
        }, {
          empty: l(() => [
            u(" Please "),
            e(i, {
              type: "primary",
              onClick: t[1] || (t[1] = (p) => a())
            }, {
              default: l(() => [
                u("Add")
              ]),
              _: 1
            }),
            u(" a new record ")
          ]),
          default: l(() => [
            e(v, {
              prop: "key",
              label: "Key"
            }),
            e(v, {
              fixed: "right",
              label: "Operations",
              width: "280px"
            }, {
              default: l((p) => [
                e(g, null, {
                  default: l(() => [
                    e(i, {
                      type: "primary",
                      onClick: t[0] || (t[0] = (y) => a())
                    }, {
                      default: l(() => [
                        u("Add")
                      ]),
                      _: 1
                    }),
                    e(i, {
                      type: "success",
                      onClick: (y) => m(p)
                    }, {
                      default: l(() => [
                        u("Edit")
                      ]),
                      _: 2
                    }, 1032, ["onClick"]),
                    e(i, {
                      type: "danger",
                      onClick: (y) => k(p)
                    }, {
                      default: l(() => [
                        u("Delete")
                      ]),
                      _: 2
                    }, 1032, ["onClick"])
                  ]),
                  _: 2
                }, 1024)
              ]),
              _: 1
            })
          ]),
          _: 1
        }, 8, ["data"]),
        e(F, {
          ref_key: "lifecycleEditorDialogRef",
          ref: f
        }, null, 512)
      ], 64);
    };
  }
});
export {
  j as default
};
