import { defineComponent as g, ref as b, openBlock as m, createElementBlock as f, normalizeClass as a, unref as t, createElementVNode as v, toDisplayString as w, createBlock as B, withCtx as u, createVNode as r, withModifiers as d, createCommentVNode as C } from "vue";
import { EditOutlined as x, DeleteOutlined as N } from "@ant-design/icons-vue";
import { Flex as A, Popover as D } from "@aplus-frontend/antdv";
import "../../../../config-provider/index.mjs";
import { useInjectApColumnSetting as E } from "../context.mjs";
import "./edit-form.vue.mjs";
import { useNamespace as S } from "../../../../config-provider/hooks/use-namespace.mjs";
import V from "./edit-form.vue2.mjs";
const I = /* @__PURE__ */ g({
  __name: "item",
  props: {
    value: {},
    isActive: { type: Boolean },
    onClick: { type: Function },
    shouldRemove: { type: Boolean }
  },
  setup(l) {
    const p = l, { b: o } = S("ap-column-setting-template-item"), n = b(!1), { deleteTemplate: k, cacheConfig: c } = E();
    function y(i) {
      if (!i || i === p.value.label)
        return;
      const e = p.value;
      e.label = i, c.value?.onChange?.(e.columnState, e), n.value = !1;
    }
    return (i, e) => (m(), f("div", {
      class: a([t(o)(), { [t(o)("active")]: l.isActive }]),
      onClick: e[4] || (e[4] = //@ts-ignore
      (...s) => l.onClick && l.onClick(...s))
    }, [
      v("span", {
        class: a(t(o)("label"))
      }, w(l.value.label), 3),
      t(c).persistenceKey ? (m(), B(t(A), {
        key: 0,
        gap: 8,
        class: a(t(o)("action-wrapper"))
      }, {
        default: u(() => [
          r(t(D), {
            open: n.value,
            "onUpdate:open": e[2] || (e[2] = (s) => n.value = s),
            trigger: "click",
            arrow: !1,
            placement: "bottom",
            "destroy-tooltip-on-hide": ""
          }, {
            content: u(() => [
              r(V, {
                "is-edit": "",
                "initial-values": { label: l.value.label },
                onConfirm: y,
                onCancel: e[1] || (e[1] = () => n.value = !1)
              }, null, 8, ["initial-values"])
            ]),
            default: u(() => [
              v("span", {
                class: a(t(o)("icon-wrapper")),
                onClick: e[0] || (e[0] = d((s) => n.value = !0, ["stop"]))
              }, [
                r(t(x))
              ], 2)
            ]),
            _: 1
          }, 8, ["open"]),
          l.shouldRemove ? (m(), f("span", {
            key: 0,
            class: a(t(o)("icon-wrapper")),
            onClick: e[3] || (e[3] = d(() => t(k)(l.value.key), ["stop"]))
          }, [
            r(t(N))
          ], 2)) : C("", !0)
        ]),
        _: 1
      }, 8, ["class"])) : C("", !0)
    ], 2));
  }
});
export {
  I as default
};
