import { T as t, _ as e, eb as a, cw as i, d8 as o } from "./index-6d97e67f.js";
import { _ as r } from "./lodash-226cb5b1.js";
import "./axios-0ffd51b8.js";
import "./redux-devtools-36ca30b8.js";
import "./alasql-f59e855e.js";
import "./ant-design-icons-a81e6d18.js";
import "react";
import "./react-router-38313ddc.js";
import "./antd-eb0b81b8.js";
import "react-dom";
import "./dayjs-63343308.js";
import "./fontawesome-7bcd29b1.js";
import "./dnd-kit-e0a0bf75.js";
import "./moment-d731d247.js";
import "./crypto-js-8020edb5.js";
import "./styled-components-b776227d.js";
import "./numbro-48e81844.js";
import "./papaparse-088c0adc.js";
import "./uuid-82f303b2.js";
import "./supabase-6aa220db.js";
import "./websockets-80729b50.js";
import "./fetch-03ca8116.js";
import "./react-draggable-1ced44e5.js";
import "./clsx-b06d39d3.js";
import "./remark-gfm-72b87c7d.js";
import "./buffer-f89d742d.js";
import "./rehype-raw-49057806.js";
import "./parse5-31d0cb5d.js";
import "./rehype-sanitize-38a120e4.js";
import "./simplebar-react-a37a9b2a.js";
import "./react-best-gradient-color-picker-2e7ff36d.js";
import "./ua-parser-js-1d18a3f8.js";
import "./loglevel-5e7e37fc.js";
import "./codemirror-8fe65581.js";
import "./really-relaxed-json-e5391d6a.js";
import "./immer-c0428a8d.js";
import "./redux-saga-3b3a9c7b.js";
import "./hotkeys-js-216206c9.js";
import "./cnchar-8c3eaa86.js";
import "./react-documents-a03b99c9.js";
import "./sql-formatter-69e8df59.js";
import "./rc-trigger-7d152aa4.js";
import "./react-json-view-364658b4.js";
import "./qrcode-react-417e3716.js";
import "./katex-05fb1c31.js";
import "./ecogis-maps-10e82de5.js";
import "./devextreme-be18bda8.js";
import "./exceljs-1678d36b.js";
import "./file-saver-es-c18fae8f.js";
const s = (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 && !r.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) => {
    }, r2 = 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(r2.length), r2.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 r3 = a2.isCustom ? a2.title : a2.dataIndex;
      if (!o2.includes(r3))
        throw new Error(`dynamic config test fail: unexpect column: ${r3}`);
    });
  }
};
function n() {
  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, r2, d2) {
  const { initColumns: m, tableData: l, exposingInfo: p } = n();
  let u = new t({ dispatch: (t2) => {
    let a3;
    a3 = r2 ? o({ readOnly: r2 }, () => u.reduce(t2)) : u.reduce(t2), u = e(a3, p);
  }, value: { ...l, dynamicColumn: a2, ...a2 && d2 && { dynamicColumnConfig: JSON.stringify(d2) } } });
  u = e(u);
  const j = async () => {
    u = e(u.reduce(u.changeChildAction("data", "{{query1.data}}")), p), await c();
  }, g = [{ dataIndex: "q1", title: "q1" }, { dataIndex: "custom1", title: "custom", isCustom: true }];
  await j(), s(u, !a2 && r2 ? m : g);
  const h = [{ q1: 1, a: 2 }];
  p.query1 = i({ data: h }), await j();
  const f = [...g, { dataIndex: "a", title: "a" }];
  expect(u.children.data.getView()).toEqual(h), s(u, !a2 && r2 ? m : f);
  const w = [{ a: 2 }];
  p.query1 = i({ data: w }), await j(), expect(u.children.data.getView()).toEqual(w), s(u, a2 ? f.filter((t2) => "q1" !== t2.dataIndex) : r2 ? m : f);
}
test("test table dynamic columns: Change unEvalValue", async () => {
  const { initColumns: a2, tableData: i2, exposingInfo: o2 } = n();
  let r2 = new t({ dispatch: (t2) => {
    r2 = e(r2.reduce(t2), o2);
  }, value: i2 });
  r2 = e(r2), s(r2, a2), r2 = e(r2.reduce(r2.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" }];
  s(r2, d2), r2 = e(r2.reduce(r2.changeChildAction("data", JSON.stringify([{ c: 2, d: 3 }])))), await c(), s(r2, 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);
