import { defineComponent as W, useCssVars as A, ref as S, computed as E, watch as z, onMounted as G, resolveComponent as K, createElementBlock as a, createCommentVNode as M, openBlock as c, createVNode as $, normalizeStyle as u, Fragment as V, renderList as I, createElementVNode as O, toDisplayString as D, unref as d, withCtx as L } from "vue";
import { debounce as f, cloneDeep as w, isEqual as R } from "lodash";
import { nanoid as k } from "nanoid";
import { RecycleScroller as Q } from "vue-virtual-scroller";
import "../text-text-basic/index.mjs";
import "./index.mjs";
import "../chart-other-gauge/index.mjs";
import "../chart-other-gauge-stage/index.mjs";
import "../chart-other-gauge-grade/index.mjs";
import "../chart-other-word-cloud/index.mjs";
import "../chart-other-liquidfill/index.mjs";
import "../chart-other-funnel/index.mjs";
import "../chart-other-force/index.mjs";
import "../chart-other-radar/index.mjs";
import "../chart-other-funnel-split/index.mjs";
import "../chart-other-funnel-contrast/index.mjs";
import "../chart-other-candlestick-basic/index.mjs";
import "../chart-other-candlestick-shanghai/index.mjs";
import "../chart-other-candlestick-demo/index.mjs";
import "../chart-other-heatmap/index.mjs";
import "../chart-other-force2/index.mjs";
import "../chart-other-graph-basic/index.mjs";
import "../chart-other-graph-basic2/index.mjs";
import "../chart-other-graph-calendar/index.mjs";
import "../chart-other-tree-line/index.mjs";
import "../chart-other-treemap-basic/index.mjs";
import "../chart-other-sunburst-basic/index.mjs";
import "../chart-other-sunburst-basic2/index.mjs";
import "../chart-other-sunburst-basic3/index.mjs";
import "../chart-other-sunburst-basic4/index.mjs";
import "../chart-other-sunburst-book/index.mjs";
import "../chart-other-sunburst-radius/index.mjs";
import "../chart-other-sunburst-flavors/index.mjs";
import "../chart-other-parallel-basic/index.mjs";
import "../chart-other-parallel-mul/index.mjs";
import "../chart-other-circular-graph/index.mjs";
import "../map-earth-basic/index.mjs";
import "../map-earth-cool-tech/index.mjs";
import "../map-earth-particle/index.mjs";
import "../map-earth-hacker/index.mjs";
import "../map-earth-fly-line/index.mjs";
import "../chart-other-grid-percentage/index.mjs";
import "../chart-other-radar-stack/index.mjs";
import "../chart-other-funnel2/index.mjs";
import "../chart-other-label-gauge/index.mjs";
import "../chart-other-theme-river/index.mjs";
import "../chart-other-tree/index.mjs";
import "../chart-other-treemap/index.mjs";
import "../commons-product-model/index.mjs";
import "../commons-vr-photo/index.mjs";
import "../commons-vr-video/index.mjs";
import "../commons-three-loader/index.mjs";
import "../commons-three-loader3/index.mjs";
import "../commons-loop-iterator/index.mjs";
import "../commons-gaussian-splatting-view/index.mjs";
import "../commons-babylon/index.mjs";
import "../commons-svg/index.mjs";
import "../commons-weather/index.mjs";
import "../commons-weather-dynamic/index.mjs";
import "../media-wavesurfer/index.mjs";
import "../interaction-tabs/index.mjs";
import "../interaction-tabs2/index.mjs";
import "../interaction-button/index.mjs";
import "../interaction-button-image/index.mjs";
import "../interaction-select/index.mjs";
import "../interaction-input/index.mjs";
import "../interaction-radio/index.mjs";
import "../interaction-slider/index.mjs";
import "../interaction-switch/index.mjs";
import "../interaction-data-picker/index.mjs";
import "../interaction-button-refresh/index.mjs";
import "../media-image/index.mjs";
import "../text-title/index.mjs";
import "../commons-qrcode/index.mjs";
import "../media-video/index.mjs";
import "../media-audio/index.mjs";
import "../text-real-time/index.mjs";
import "../media-carousel/index.mjs";
import "../media-carousel-slides/index.mjs";
import "../media-iframe-carousel/index.mjs";
import "../media-iframe/index.mjs";
import "../media-m3u8/index.mjs";
import "../media-m3u8-dynamic/index.mjs";
import "../media-audio-dynamic/index.mjs";
import "../media-video-dynamic/index.mjs";
import "../media-image-dynamic/index.mjs";
import "../media-iframe-dynamic/index.mjs";
import "../media-flv/index.mjs";
import "../commons-echarts/index.mjs";
import "../text-over-number/index.mjs";
import "../text-table-scroll/index.mjs";
import "../text-carousel/index.mjs";
import "../text-row-scroll/index.mjs";
import "../text-text-dynamic/index.mjs";
import "../text-count-down/index.mjs";
import "../graphical-circle/index.mjs";
import "../graphical-diamond/index.mjs";
import "../graphical-hexagon/index.mjs";
import "../graphical-isosceles-triangle/index.mjs";
import "../graphical-pentagon/index.mjs";
import "../graphical-rect/index.mjs";
import "../graphical-right-triangle/index.mjs";
import "../scene-map3d/index.mjs";
import "../scene-amap2d/index.mjs";
import "../scene-amap3d/index.mjs";
import "../scene-vr/index.mjs";
import "../scene-unity-iframe/index.mjs";
import "../scene-unity-webgl/index.mjs";
import "../scene-ue-iframe/index.mjs";
import "../scene-ue-shj/index.mjs";
import "../scene-default/index.mjs";
import "../interaction/tabs/index.mjs";
import "../interaction/tabs-icon/index.mjs";
import "../interaction/button/index.mjs";
import "../interaction/date-picker/src/date-picker/index.mjs";
import "../interaction/date-picker/src/date-picker-range/index.mjs";
import "../text/list/index.mjs";
import "../chart/src/bar/basic/index.mjs";
import "../chart/src/bar/animation/index.mjs";
import "../chart/src/bar/contrast/index.mjs";
import "../chart/src/bar/contrast2/index.mjs";
import "../chart/src/bar/contrast3/index.mjs";
import "../chart/src/bar/gradient-column-chart/index.mjs";
import "../chart/src/bar/horizontal/index.mjs";
import "../chart/src/bar/horizontal-stack/index.mjs";
import "../chart/src/bar/line-bar/index.mjs";
import "../chart/src/bar/line-bar2/index.mjs";
import "../chart/src/bar/loop/index.mjs";
import "../chart/src/bar/mini/index.mjs";
import "../chart/src/bar/polar/index.mjs";
import "../chart/src/bar/polar-stack/index.mjs";
import "../chart/src/bar/polar2/index.mjs";
import "../chart/src/bar/radius-circle/index.mjs";
import "../chart/src/bar/rank/index.mjs";
import "../chart/src/bar/segmented-progress/index.mjs";
import "../chart/src/bar/spire/index.mjs";
import "../chart/src/bar/stack/index.mjs";
import "../chart/src/bar/stack-line/index.mjs";
import "../chart/src/bar/stack2/index.mjs";
import "../chart/src/bar/stack3/index.mjs";
import "../chart/src/bar/staggered/index.mjs";
import "../chart/src/bar/three/index.mjs";
import "../chart/src/bar/waterfall/index.mjs";
import "../chart/src/bar/zebra/index.mjs";
import "../chart/src/line/area-gradient/index.mjs";
import "../chart/src/line/area-highlight/index.mjs";
import "../chart/src/line/area-highlight2/index.mjs";
import "../chart/src/line/basic/index.mjs";
import "../chart/src/line/bump/index.mjs";
import "../chart/src/line/dashed/index.mjs";
import "../chart/src/line/ladder/index.mjs";
import "../chart/src/line/logarithm/index.mjs";
import "../chart/src/line/multix/index.mjs";
import "../chart/src/line/polar-double/index.mjs";
import "../chart/src/line/rain-flow/index.mjs";
import "../chart/src/line/scale/index.mjs";
import "../chart/src/line/smooth/index.mjs";
import "../chart/src/line/smooth-area/index.mjs";
import "../chart/src/line/stack/index.mjs";
import "../chart/src/line/stack-area/index.mjs";
import "../chart/src/line/temp/index.mjs";
import "../chart/src/line/vertical/index.mjs";
import "../chart/src/map/basic/index.mjs";
import "../chart/src/map/bmap-basic/index.mjs";
import "../chart/src/map/bmap-heatmap/index.mjs";
import "../chart/src/map/bmap-rich/index.mjs";
import "../chart/src/map/customize/index.mjs";
import "../chart/src/map/lines/index.mjs";
import "../chart/src/map/scatter/index.mjs";
import "../chart/src/pie/3d/index.mjs";
import "../chart/src/pie/basic/index.mjs";
import "../chart/src/pie/basic2/index.mjs";
import "../chart/src/pie/customized/index.mjs";
import "../chart/src/pie/index/index.mjs";
import "../chart/src/pie/interval/index.mjs";
import "../chart/src/pie/legend-scroll/index.mjs";
import "../chart/src/pie/radius/index.mjs";
import "../chart/src/pie/rose/index.mjs";
import "../chart/src/pie/round/index.mjs";
import "../chart/src/pie/sunburst/index.mjs";
import "../chart/src/scatter/basic/index.mjs";
import "../chart/src/scatter/basic2/index.mjs";
import "../chart/src/scatter/bubble/index.mjs";
import "../chart/src/scatter/ripples/index.mjs";
/* empty css                        */
/* empty css                               */
import { SHJDatasourceV2 as U } from "../../plugins/datasource/index.mjs";
import { SHJParseEvent as l } from "../../plugins/event/index.mjs";
import "vue-virtual-scroller/dist/vue-virtual-scroller.css";
const X = ["onClick", "onMouseenter", "onMouseout"], Y = ["onClick"], Z = W({ name: "zv-text-table-basic" }), zr = /* @__PURE__ */ W({
  ...Z,
  props: {
    basicOption: {},
    useEvents: {},
    sources: {},
    uuid: {}
  },
  emits: ["on-click-item", "on-click-row", "on-mouseenter-row", "on-mouseout-row"],
  setup(B, { expose: N, emit: j }) {
    A((t) => ({
      "1454cdc3": t.basicOption.css.table.borderWidth + "px",
      "907bc916": t.basicOption.css.table.borderStyle,
      "9243a5b2": t.basicOption.css.table.borderColor,
      "36c18145": t.basicOption.css.table.paddingLeft + "px",
      "863f79aa": t.basicOption.css.table.alignItems,
      "39d66f39": t.basicOption.css.table.justifyContent,
      "5e305fdf": t.basicOption.css.header.background,
      "607b0d96": t.basicOption.css.header.height + "px",
      "0de50bdc": t.basicOption.css.header.color,
      "0a01958c": t.basicOption.css.header.fontSize + "px",
      fc5ce350: t.basicOption.css.header.fontWeight,
      df3c545e: t.basicOption.css.header.fontStyle,
      "162d48ec": t.basicOption.css.body.height + "px",
      "17e3a5aa": t.basicOption.css.body.background,
      39728167: t.basicOption.css.body.color,
      fe0d92be: t.basicOption.css.body.fontSize + "px",
      "3b84d423": t.basicOption.css.body.fontWeight,
      "7d992aa6": t.basicOption.css.body.fontStyle
    }));
    const b = j, v = S(k()), s = S([]), p = B, H = () => {
      if (!s.value.length) return;
      const t = Object.keys(s.value[0]), o = p.basicOption.columns || [], r = t.map((i, m) => {
        const e = o.find((C) => C.name === i) || {};
        return {
          name: e.name || i,
          // 如果用户没有提供 name，使用 key 作为 name
          label: e.label || i,
          // 如果用户没有提供 label，使用 key 作为 label
          visible: e.visible !== void 0 ? e.visible : !0,
          // 如果用户没有提供 visible，默认可见
          index: e.index !== void 0 ? e.index : m,
          // 如果用户没有提供 index，使用默认顺序
          width: e.width || { auto: !0, width: 100 },
          // 如果用户没有提供 width，使用默认宽度
          font: e.font || { auto: !0, color: "#ffffff", fontSize: 12, fontStyle: "normal" }
          // 如果用户没有提供 font，使用默认字体
        };
      });
      p.basicOption.columns = r.sort((i, m) => i.index - m.index);
    }, h = E(() => p.basicOption.columns || []), y = E(() => h.value.filter((t) => t.visible).map((t) => t.name)), n = () => {
      U.parse({
        tId: p.uuid,
        sources: p.sources,
        callback: (t) => {
          try {
            l.parseEvents(p.useEvents, "dataListener", s), v.value = k(), s.value = w(t.data[0].data).map((o, r) => ({
              id: o.id || r,
              // 使用索引作为 id
              ...o
            })), H();
          } catch {
            l.parseEvents(p.useEvents, "dataListener", null), v.value = k(), s.value = [];
          }
        }
      });
    }, g = (t) => {
      const o = h.value.find((r) => r.name === t);
      return o != null && o.width.auto ? null : `${o == null ? void 0 : o.width.width}px`;
    }, J = (t) => {
      const o = h.value.find((i) => i.name === t);
      if (!o) return {};
      const r = {
        whiteSpace: "nowrap",
        // 默认不换行
        textOverflow: "ellipsis",
        // 默认溢出省略号
        overflow: "hidden"
        // 默认隐藏溢出内容
      };
      return {
        color: o.font.color,
        fontSize: `${o.font.fontSize}px`,
        fontStyle: o.font.fontStyle,
        ...r,
        ...o.textStyle
        // 用户自定义样式
      };
    }, q = f((t, o) => {
      const r = { row: t, rowIndex: o };
      b("on-click-row", r), l.parseEvents(p.useEvents, "on-click-row", r);
    }, 100), F = f((t, o) => {
      const r = { row: t, rowIndex: o };
      b("on-mouseenter-row", r), l.parseEvents(p.useEvents, "on-mouseenter-row", r);
    }, 100), P = f((t, o) => {
      const r = { row: t, rowIndex: o };
      b("on-mouseout-row", r), l.parseEvents(p.useEvents, "on-mouseout-row", r);
    }, 100), T = f((t, o, r, i) => {
      const m = { row: t, item: o, rowIndex: r, columnIndex: i };
      b("on-click-item", m), l.parseEvents(p.useEvents, "on-click-item", m);
    }, 100);
    return z(() => w(p.sources), (t, o) => {
      R(t, o) || n();
    }, { deep: !0 }), z(() => w(p.basicOption), (t, o) => {
      R(t, o) || n();
    }, { deep: !0 }), G(() => n()), N({
      refresh: () => n(),
      refreshView: () => n(),
      refreshData: () => n()
    }), (t, o) => {
      const r = K("el-tooltip");
      return s.value.length > 0 ? (c(), a("div", {
        key: v.value,
        class: "table-scroll"
      }, [
        t.basicOption.css.header.show ? (c(), a("div", {
          key: 0,
          class: "table-header",
          style: u({
            "--header-background-image": `url(${t.basicOption.css.header.background})`
          })
        }, [
          (c(!0), a(V, null, I(y.value, (i) => (c(), a("div", {
            key: i,
            class: "th",
            style: u({ width: g(i) })
          }, [
            O("p", null, D(i), 1)
          ], 4))), 128))
        ], 4)) : M("", !0),
        $(d(Q), {
          id: "",
          class: "table-body",
          items: s.value,
          "item-size": t.basicOption.css.body.height,
          "key-field": "id"
        }, {
          default: L(({ item: i, index: m }) => [
            O("div", {
              class: "tr",
              style: u({
                "--row-hover": t.basicOption.css.hoverColor,
                "--odd-background": t.basicOption.css.oddBackground
              }),
              onClick: (e) => d(q)(i, m),
              onMouseenter: (e) => d(F)(i, m),
              onMouseout: (e) => d(P)(i, m)
            }, [
              (c(!0), a(V, null, I(y.value, (e) => (c(), a("div", {
                key: e,
                class: "td",
                style: u({ width: g(e) }),
                onClick: (C) => d(T)(i, i[e], m, y.value.indexOf(e))
              }, [
                $(r, {
                  content: i[e]
                }, {
                  default: L(() => [
                    O("p", {
                      style: u(J(e))
                    }, D(i[e]), 5)
                  ]),
                  _: 2
                }, 1032, ["content"])
              ], 12, Y))), 128))
            ], 44, X)
          ]),
          _: 1
        }, 8, ["items", "item-size"])
      ])) : M("", !0);
    };
  }
});
export {
  zr as default
};
