import { defineComponent as C, getCurrentInstance as E, ref as u, onActivated as I, watch as y, createVNode as l, resolveComponent as a, isVNode as b, defineAsyncComponent as V } from "vue";
import { ElCollapse as h, ElCollapseItem as F, ElForm as S, ElFormItem as _, ElButton as P, ElInput as w, ElSwitch as g, ElTooltip as x, ElMessage as A } from "element-plus";
import { l as N, ab as k, A as U, ac as R } from "./main-Blxobku2.js";
import { useResolveVnode as j, useGetCompNode as B, useGetCompRefProps as D, useResolveAsyncCompLoader as O } from "@klweb/compose-app-engine";
import { e as T } from "./index-BbdVezoQ.js";
const G = {
  "copy-comp-id-icon": "_copy-comp-id-icon_1ptyb_1"
}, {
  IconCopy: K
} = T;
function L(n) {
  return typeof n == "function" || Object.prototype.toString.call(n) === "[object Object]" && !b(n);
}
const J = /* @__PURE__ */ C({
  name: "KlPropSetter",
  components: {
    ElCollapse: h,
    ElCollapseItem: F,
    ElForm: S,
    ElFormItem: _,
    ElButton: P,
    ElInput: w,
    ElSwitch: g,
    ElTooltip: x
  },
  props: {
    compId: {
      type: String,
      default: ""
    }
  },
  setup(n) {
    const {
      appContext: d
    } = E(), {
      app: r
    } = d, e = u(null), c = u(!1), p = u(""), i = u({}), s = async () => {
      if (e.value = B(n.compId), !e.value) return;
      const t = e.value.properties ? null : await D(n.compId), o = (t == null ? void 0 : t.properties) || {};
      e.value.properties = e.value.properties ?? o, i.value = e.value.properties, f();
    }, f = () => {
      var o;
      p.value = ((o = e.value) == null ? void 0 : o.component) + "PropSetter";
      const t = O(p.value);
      c.value = !!t, t && !r.component(p.value) && r.component(p.value, V({
        loader: t
      }));
    };
    s();
    const m = u(["1", "2"]), v = (t) => {
      R(t, () => {
        A.success("已复制到剪切板");
      });
    };
    return I(() => s()), y([N, k], () => {
      s();
    }), () => {
      let t;
      return e.value && l(a("el-collapse"), {
        class: "kl-editor-setter__collapse",
        modelValue: m.value,
        "onUpdate:modelValue": (o) => m.value = o
      }, {
        default: () => [l(a("el-collapse-item"), {
          title: "基础信息",
          name: "1"
        }, {
          default: () => [l(a("el-form"), {
            class: "kl-editor-setter__form",
            model: e.value,
            "label-width": "80px",
            "label-position": "left"
          }, {
            default: () => [l(a("el-form-item"), {
              label: "组件 ID"
            }, {
              default: () => [l(a("el-input"), {
                readonly: !0,
                class: "width--fill",
                modelValue: e.value.compId,
                "onUpdate:modelValue": (o) => e.value.compId = o
              }, {
                append: () => l(a("el-tooltip"), {
                  effect: "dark",
                  "hide-after": 0,
                  placement: "top",
                  content: U.COPY
                }, {
                  default: () => [l(a("el-button"), {
                    class: G["copy-comp-id-icon"],
                    icon: K,
                    onClick: () => {
                      var o;
                      return v(((o = e.value) == null ? void 0 : o.compId) ?? "");
                    }
                  }, null)]
                })
              })]
            }), l(a("el-form-item"), {
              label: "组件名称"
            }, {
              default: () => [l(a("el-input"), {
                class: "width--fill",
                modelValue: e.value.name,
                "onUpdate:modelValue": (o) => e.value.name = o
              }, null)]
            }), l(a("el-form-item"), {
              label: "是否渲染",
              class: "content-position--right"
            }, {
              default: () => [l(a("el-switch"), {
                modelValue: e.value.isRender,
                "onUpdate:modelValue": (o) => e.value.isRender = o
              }, null)]
            })]
          })]
        }), c.value && l(a("el-collapse-item"), {
          title: "属性设置",
          name: "2"
        }, L(t = j(p.value, {
          compId: n.compId,
          properties: i.value
        })) ? t : {
          default: () => [t]
        })]
      });
    };
  }
});
export {
  J as default
};
