import { T as t, P as e, dZ as a, c8 as i, cQ as o } from "./index-f927b013.js";
import { _ as n } from "./lodash-b5661970.js";
import "./axios-04f95181.js";
import "./redux-devtools-8dd21e4f.js";
import "./alasql-f60045ee.js";
import "./ant-design-icons-6bfdc7d5.js";
import "react";
import "./antd-2abdded3.js";
import "react-dom";
import "./dayjs-2035e031.js";
import "./fontawesome-3904a214.js";
import "./dnd-kit-8227a2db.js";
import "./moment-059406e8.js";
import "./styled-components-7cfa37e6.js";
import "./numbro-47982265.js";
import "./papaparse-07642d76.js";
import "./uuid-bd83cae2.js";
import "./supabase-b2e314d0.js";
import "./fetch-648a91f6.js";
import "./react-draggable-ed505bfc.js";
import "./remark-gfm-18306abe.js";
import "./buffer-d3713d77.js";
import "./rehype-raw-6ebcba88.js";
import "./parse5-f837f753.js";
import "./rehype-sanitize-953d0761.js";
import "./simplebar-react-2133d981.js";
import "./react-best-gradient-color-picker-92c01739.js";
import "./ua-parser-js-c952c07b.js";
import "./clsx-469c2c43.js";
import "./loglevel-b4003767.js";
import "./file-saver-55285fc1.js";
import "./codemirror-8412b963.js";
import "./really-relaxed-json-056be70b.js";
import "./immer-c0428a8d.js";
import "./hotkeys-js-699906bc.js";
import "./cnchar-e1339167.js";
import "./react-documents-041601c7.js";
import "./react-sortable-hoc-4fbe0c32.js";
import "./sql-formatter-577b4ab0.js";
import "./rc-trigger-3f038851.js";
import "./react-json-view-5330ce92.js";
import "./qrcode-react-d377d762.js";
const r = (t2, e2) => {
  const i2 = t2.children.columns.getView().map((t3) => t3.getView());
  expect(e2.length).toEqual(i2.length), e2.forEach((t3) => {
    const e3 = i2.find((e4) => e4.dataIndex === t3.dataIndex);
    if (!e3)
      throw new Error(`expect column: ${JSON.stringify(t3)}, but not found.`);
    Object.keys(t3).forEach((a2) => {
      const i3 = e3[a2], o3 = t3[a2];
      if (void 0 !== o3 && !n.isEqual(i3, o3))
        throw new Error(`ColumnKey:${a2}, expect: "${o3}", but found: "${i3}"`);
    });
  });
  const o2 = t2.children.dynamicColumnConfig.getView();
  if ((o2 == null ? void 0 : o2.length) > 0) {
    const e3 = (t3) => {
    }, n2 = a(i2, t2.children.sort.getView(), t2.children.toolbar.getView().columnSetting, t2.children.size.getView(), t2.children.dynamicColumn.getView(), o2, t2.columnAggrData, t2.children.editModeClicks.getView(), e3);
    expect(i2.length).toBeGreaterThanOrEqual(n2.length), n2.forEach((t3) => {
      const e4 = t3.dataIndex, a2 = i2.find((t4) => t4.dataIndex === e4);
      if (!a2)
        throw new Error(`Error, column should not be undefined, column: ${JSON.stringify(t3)}`);
      const n3 = a2.isCustom ? a2.title : a2.dataIndex;
      if (!o2.includes(n3))
        throw new Error(`dynamic config test fail: unexpect column: ${n3}`);
    });
  }
};
function s() {
  const t2 = { query1: i({ data: [{ q1: 1 }] }), query2: i({ data: [{ q2: 2 }] }) };
  return { tableData: { data: JSON.stringify([{ a: 1 }]), columns: [{ dataIndex: "a", title: "a", hide: true }, { title: "custom", dataIndex: "custom1", isCustom: true }] }, exposingInfo: t2, initColumns: [{ dataIndex: "a", hide: true, title: "a" }, { dataIndex: "custom1", hide: false, title: "custom", isCustom: true }] };
}
async function c() {
  await new Promise((t2) => setTimeout(t2, 20));
}
async function d(a2, n2, d2) {
  const { initColumns: m, tableData: l, exposingInfo: u } = s();
  let p = new t({ dispatch: (t2) => {
    let a3;
    a3 = n2 ? o({ readOnly: n2 }, () => p.reduce(t2)) : p.reduce(t2), p = e(a3, u);
  }, value: { ...l, dynamicColumn: a2, ...a2 && d2 && { dynamicColumnConfig: JSON.stringify(d2) } } });
  p = e(p);
  const j = async () => {
    p = e(p.reduce(p.changeChildAction("data", "{{query1.data}}")), u), await c();
  }, h = [{ dataIndex: "q1", title: "q1" }, { dataIndex: "custom1", title: "custom", isCustom: true }];
  await j(), r(p, !a2 && n2 ? m : h);
  const g = [{ q1: 1, a: 2 }];
  u.query1 = i({ data: g }), await j();
  const f = [...h, { dataIndex: "a", title: "a" }];
  expect(p.children.data.getView()).toEqual(g), r(p, !a2 && n2 ? m : f);
  const w = [{ a: 2 }];
  u.query1 = i({ data: w }), await j(), expect(p.children.data.getView()).toEqual(w), r(p, a2 ? f.filter((t2) => "q1" !== t2.dataIndex) : n2 ? m : f);
}
test("test table dynamic columns: Change unEvalValue", async () => {
  const { initColumns: a2, tableData: i2, exposingInfo: o2 } = s();
  let n2 = new t({ dispatch: (t2) => {
    n2 = e(n2.reduce(t2), o2);
  }, value: i2 });
  n2 = e(n2), r(n2, a2), n2 = e(n2.reduce(n2.changeChildAction("data", JSON.stringify([{ a: 1, c: 2, d: 3 }])))), await c();
  const d2 = [...a2, { dataIndex: "c", hide: false, title: "c" }, { dataIndex: "d", title: "d" }];
  r(n2, d2), n2 = e(n2.reduce(n2.changeChildAction("data", JSON.stringify([{ c: 2, d: 3 }])))), await c(), r(n2, d2.filter((t2) => "a" !== t2.dataIndex));
}, 1e3), test("test table dynamic columns", async () => {
  await d(false, false), await d(false, true), await d(true, false), await d(true, true), await d(true, false, ["custom", "q1"]), await d(true, true, ["custom", "q1"]);
}, 2e3);
