import { newCustomColumn as T } from "./0667825e.js";
import { b9 as g, fO as E, co as O, fP as R, a0 as t, P as d, bh as b, V as l, bi as a, bs as S, fQ as z, bj as x, bl as D, bm as M, fR as L, fS as $, fT as F, bt as v, fU as W, fV as G, d8 as N, fW as j, fX as Q, fY as U, fZ as X, f_ as Y, eB as Z, f$ as _, O as k, cl as A, g0 as q } from "./684d2f28.js";
import { useState as P, useMemo as J } from "react";
import { getSelectedRowKeys as K } from "./392e04da.js";
import { ColumnTypeCompMap as ee } from "./49a8125c.js";
import "./fcd1d96f.js";
import "react-dom";
import "./7281819e.js";
import "./9869e60a.js";
import "./b1144c16.js";
import "./d404aae1.js";
import "./926d8ea1.js";
import "./d6402597.js";
import "./7a630f06.js";
import "./d883a28b.js";
import "./6be5dc74.js";
import "./1312a48b.js";
import "./00dac55d.js";
import "./622ce240.js";
import "./0c4ef413.js";
import "./b8f8370b.js";
import "./ca17ca0f.js";
import "./d9d1e856.js";
import "./6538ec2e.js";
import "./226f78bd.js";
import "./8e06f4ed.js";
import "./a014bc57.js";
import "./6cf5f7c0.js";
import "./7f2964c3.js";
import "./602ac28f.js";
import "./f9c25fbe.js";
import "./2d5fc5ff.js";
import "./0f3d7a1a.js";
import "./698a4355.js";
import "./cf2c1864.js";
import "./bdf03194.js";
import "./6cb1f6af.js";
const te = g.div`
  display: flex;
  justify-content: end;
  width: 100%;
  gap: 8px;
  align-items: center;
`, ie = g.span`
  ${E};
  color: #8b8fa3;
`, le = g(L)`
  width: 16px;
  height: 16px;
  cursor: pointer;

  &:hover {
    g g {
      stroke: #4965f2;
    }
  }
`, I = O`
  height: 16px;
  width: 16px;
  display: inline-block;

  &:hover {
    cursor: pointer;
  }

  &:hover path {
    fill: #315efb;
  }
`, oe = g($)`
  ${I}
`, re = g(F)`
  ${I}
`, ne = g(v)`
  width: 100px;

  &,
  > div {
    height: 22px;
  }

  .ant-segmented-item-label {
    height: 18px;
    min-height: 18px;
    line-height: 18px;
    padding: 0;
  }
`, ae = g.div`
  display: flex;
  align-items: center;
  color: ${R}
  line-height: 16px;
  font-size: 13px;
`, de = [{
  label: t("table.allColumn"),
  value: "all"
}, {
  label: t("table.visibleColumn"),
  value: "visible"
}], ce = [{
  label: t("prop.hide"),
  value: "hide"
}, {
  label: t("table.editable"),
  value: "editable"
}, {
  label: t("table.autoWidth"),
  value: "autoWidth"
}, {
  label: t("table.sortable"),
  value: "sortable"
}, {
  label: t("table.align"),
  value: "align"
}];
function se(e) {
  const {
    hide: i,
    setHide: s
  } = e;
  return /* @__PURE__ */ l(i ? oe : re, {
    onClick: (r) => {
      s(!i);
    }
  });
}
function V(e, i) {
  const s = (r) => e === "autoWidth" ? r.children.autoWidth.getView() === "auto" : r.children[e].getView(), h = i ?? ((r) => r);
  return (r) => {
    const p = Array.isArray(r), w = p ? r : [r], f = w.map((c) => {
      if (e !== "editable")
        return !1;
      const m = c.children.render.getOriginalComp().children.comp.children.compType.getView();
      return !ee[m].canBeEditable();
    });
    let u = !0, y = !0;
    w.forEach((c, m) => {
      if (f[m]) {
        p || (u = !1);
        return;
      }
      s(c) ? y = !1 : u = !1;
    });
    const C = (c) => {
      w.forEach((m, o) => !f[o] && m.children[e].dispatch(k(A(h(c), !0))));
    };
    return e === "hide" ? /* @__PURE__ */ l(se, {
      hide: u,
      setHide: (c) => C(c)
    }) : /* @__PURE__ */ l(q, {
      indeterminate: !u && !y,
      disabled: !p && f[0],
      checked: u,
      onChange: (c) => {
        C(c.target.checked);
      }
    });
  };
}
const B = {
  hide: V("hide"),
  editable: V("editable"),
  sortable: V("sortable"),
  autoWidth: V("autoWidth", (e) => e ? "auto" : "fixed"),
  align: (e) => {
    const i = Array.isArray(e) ? e : [e], s = Array.isArray(e) ? void 0 : e.children.align.getView();
    return /* @__PURE__ */ l(ne, {
      options: _,
      value: s,
      radioButton: !0,
      onChange: (h) => {
        i.forEach((r) => r.children.align.dispatch(k(A(h, !0))));
      }
    });
  }
};
function he(e) {
  const {
    comp: i
  } = e, s = K(i.children.selection)[0] ?? "0", [h, r] = P("all"), p = i.children.columns.getView(), w = i.children.dataRowExample.getView(), f = i.children.dynamicColumn.getView(), u = i.children.data.getView(), [y, C] = P("hide"), c = J(() => p.filter((o) => h === "all" || !o.children.hide.getView()), [h, p]), m = /* @__PURE__ */ d(te, {
    children: [/* @__PURE__ */ d("div", {
      style: {
        display: "flex",
        alignItems: "center",
        marginRight: "auto"
      },
      children: [/* @__PURE__ */ l(W, {
        label: e.columnLabel
      }), /* @__PURE__ */ l(ie, {
        children: " (" + p.length + ")"
      })]
    }), w && /* @__PURE__ */ l(G, {
      title: t("table.refreshButtonTooltip"),
      children: /* @__PURE__ */ l(le, {
        onClick: () => {
          i.dispatch(N("columns", i.children.columns.dataChangedAction({
            rowExample: w,
            doGeneColumn: !0,
            dynamicColumn: f,
            data: u
          })));
        }
      })
    }), /* @__PURE__ */ l(j, {
      icon: /* @__PURE__ */ l(Q, {}),
      text: t("addItem"),
      onClick: () => {
        i.children.columns.dispatch(i.children.columns.pushAction(T()));
      }
    })]
  });
  return /* @__PURE__ */ l(b, {
    children: /* @__PURE__ */ l(U, {
      headerItem: /* @__PURE__ */ l(X, {
        title: /* @__PURE__ */ l(v, {
          border: !0,
          style: {
            width: "auto",
            marginLeft: "8px"
          },
          value: h,
          options: de,
          label: "",
          onChange: (o) => {
            r(o);
          }
        }),
        config: {
          dataIndex: "header"
        },
        draggable: !1,
        optionExtra: /* @__PURE__ */ d(ae, {
          children: [/* @__PURE__ */ l(v, {
            border: !0,
            style: {
              width: "auto"
            },
            value: y,
            options: ce,
            label: "",
            onChange: (o) => {
              C(o);
            }
          }), B[y](p)]
        })
      }),
      itemExtra: (o) => /* @__PURE__ */ l("div", {
        style: {
          display: "flex",
          alignItems: "center",
          height: "100%"
        },
        onClick: (n) => n.stopPropagation(),
        children: B[y](o)
      }),
      items: c,
      optionToolbar: m,
      itemTitle: (o) => {
        const n = o.getView();
        return n.hide ? /* @__PURE__ */ l("span", {
          style: {
            color: R
          },
          children: n.title
        }) : n.title;
      },
      popoverTitle: (o) => {
        const n = o.getView();
        return n.isCustom ? t("table.customColumn") : n.dataIndex;
      },
      content: (o, n) => /* @__PURE__ */ d(b, {
        children: [o.propertyView(s), o.getView().isCustom && /* @__PURE__ */ l(Y, {
          onClick: () => {
            Z.confirm({
              title: t("table.deleteColumn"),
              content: t("table.confirmDeleteColumn") + `${o.getView().title}?`,
              onConfirm: () => i.children.columns.dispatch(i.children.columns.deleteAction(n)),
              confirmBtnType: "delete",
              okText: t("delete")
            });
          },
          children: t("delete")
        })]
      }),
      onAdd: () => {
        i.children.columns.dispatch(i.children.columns.pushAction(T()));
      },
      onMove: (o, n) => {
        const H = i.children.columns.arrayMoveAction(o, n);
        i.children.columns.dispatch(H);
      },
      dataIndex: (o) => o.getView().dataIndex,
      scrollable: !0
    })
  });
}
function pe(e) {
  const i = t("table.columnNum");
  return [
    S({
      filterText: i
    }, /* @__PURE__ */ l(he, {
      comp: e,
      columnLabel: i
    }))
    /* comp.children.dynamicColumn.propertyView({ label: trans("table.dynamicColumn") }),
    dynamicColumn &&
      comp.children.dynamicColumnConfig.propertyView({
        label: trans("table.dynamicColumnConfig"),
        tooltip: trans("table.dynamicColumnConfigDesc"),
      }), */
  ];
}
function _e(e) {
  const i = e.editorModeStatus, s = t("data");
  return /* @__PURE__ */ d(b, {
    children: [["logic", "both"].includes(i) && /* @__PURE__ */ l(a, {
      name: t("table.dataDesc"),
      children: S({
        filterText: s
      }, /* @__PURE__ */ l("div", {
        className: z,
        children: e.children.data.propertyView({
          label: s
        })
      }))
    }), ["layout", "both"].includes(i) && /* @__PURE__ */ l(a, {
      name: t("prop.columns"),
      children: pe(e)
    }), ["logic", "both"].includes(i) && /* @__PURE__ */ d(b, {
      children: [/* @__PURE__ */ d(a, {
        name: x.interaction,
        children: [e.children.onEvent.getPropertyView(), e.children.selection.getPropertyView(), D(e.children), M(e.children)]
      }), /* @__PURE__ */ l(a, {
        name: t("prop.toolbar"),
        children: e.children.toolbar.getPropertyView()
      })]
    }), ["layout", "both"].includes(i) && /* @__PURE__ */ d(b, {
      children: [/* @__PURE__ */ d(a, {
        name: x.layout,
        children: [e.children.size.propertyView({
          label: t("table.tableSize"),
          radioButton: !0
        }), e.children.autoHeight.getPropertyView(), e.children.fixedHeader.propertyView({
          label: t("table.fixedHeader"),
          tooltip: t("table.fixedHeaderTooltip")
        }), e.children.hideHeader.propertyView({
          label: t("table.hideHeader")
        }), e.children.viewModeResizable.propertyView({
          label: t("table.viewModeResizable"),
          tooltip: t("table.viewModeResizableTooltip")
        }), e.children.visibleResizables.propertyView({
          label: t("table.visibleResizables"),
          tooltip: t("table.visibleResizablesTooltip")
        })]
      }), /* @__PURE__ */ l(a, {
        name: t("prop.pagination"),
        children: e.children.pagination.getPropertyView()
      })]
    }), ["logic", "both"].includes(i) && /* @__PURE__ */ l(b, {
      children: /* @__PURE__ */ d(a, {
        name: x.advanced,
        children: [e.children.expansion.getPropertyView(), e.children.showDataLoadSpinner.propertyView({
          label: t("table.showDataLoadSpinner")
        }), e.children.dynamicColumn.propertyView({
          label: t("table.dynamicColumn")
        }), e.children.dynamicColumn.getView() && e.children.dynamicColumnConfig.propertyView({
          label: t("table.dynamicColumnConfig"),
          tooltip: t("table.dynamicColumnConfigDesc")
        }), e.children.searchText.propertyView({
          label: t("table.searchText"),
          tooltip: t("table.searchTextTooltip"),
          placeholder: "{{input1.value}}"
        })]
      })
    }), ["layout", "both"].includes(i) && /* @__PURE__ */ d(b, {
      children: [/* @__PURE__ */ l(a, {
        name: "Table Style",
        children: e.children.style.getPropertyView()
      }), /* @__PURE__ */ l(a, {
        name: "Header Style",
        children: e.children.headerStyle.getPropertyView()
      }), /* @__PURE__ */ l(a, {
        name: "Toolbar Style",
        children: e.children.toolbarStyle.getPropertyView()
      }), /* @__PURE__ */ d(a, {
        name: "Row Style",
        children: [e.children.showRowGridBorder.propertyView({
          label: t("table.showVerticalRowGridBorder")
        }), e.children.showHRowGridBorder.propertyView({
          label: t("table.showHorizontalRowGridBorder")
        }), e.children.rowStyle.getPropertyView(), e.children.rowAutoHeight.getPropertyView(), e.children.rowHeight.getPropertyView(), e.children.rowColor.getPropertyView()]
      }), /* @__PURE__ */ l(a, {
        name: "Column Style",
        children: e.children.columnsStyle.getPropertyView()
      })]
    })]
  });
}
export {
  _e as compTablePropertyView
};
