import { defineComponent as gt, computed as O, resolveComponent as g, openBlock as G, createElementBlock as Je, normalizeClass as C, unref as l, createElementVNode as H, createVNode as c, withCtx as m, normalizeStyle as rt, toDisplayString as ke, getCurrentInstance as Et, reactive as Nt, watch as Se, onMounted as xt, onUnmounted as _t, toRefs as Gt, ref as st, isRef as Fe, createBlock as q, createCommentVNode as ie, renderSlot as Rt, createTextVNode as L, Fragment as Tt, renderList as Dt } from "vue";
import { b as ft, u as jt, f as Zt, n as Qt } from "./layer-select-Ba4IEiWY.js";
import { b as D, i as ct, c as qe, _ as bt, u as Yt, g as Lt } from "./utils-B4smQbM-.js";
import { i as Ot, e as ut, f as zt, c as mt, g as dt, h as Pt, k as Wt } from "./vendor-D4icwOYu.js";
import "ant-design-vue";
import { c as He } from "./query-BQ2UHSN1.js";
import { ViewEventType as J, Feature as ht, ElevationInfo as Ut, ElevationMode as Vt, GeometryEngine as Bt, Geometry as we } from "@mapgis/webclient-common";
const Xe = {
  /**
   * @description 图层参数
   */
  layerParams: {
    type: Object
  },
  /**
   * @description 其他查询选项
   */
  queryOtherOptions: {
    type: Object
  },
  /**
   * @description 显示样式
   */
  queryShowStyle: {
    type: Object,
    default: () => ({
      ...He
    })
  },
  /**
   * @description 自定义属性表容器高度
   */
  customMaxHeight: {
    type: Function,
    default: (o) => document.body.clientHeight - o.getBoundingClientRect().top
  },
  /**
   * @description 是否可关闭，默认不显示关闭按钮
   */
  closable: {
    type: Boolean,
    default: !1
  },
  /**
   * @description 是否启用属性过滤，默认启用
   */
  enableFilter: {
    type: Boolean,
    default: !0
  },
  /**
   * @description 是否启用属性统计，默认启用
   */
  enableStatistics: {
    type: Boolean,
    default: !0
  }
}, Ke = {
  // 属性表行单击
  attributeTableRowClick: ({ layer: o, feature: b, prevent: f }) => D(o) && D(b) && qe(f),
  // 属性表行双击
  attributeTableRowDoubleClick: ({ layer: o, feature: b, prevent: f }) => D(o) && D(b) && qe(f),
  // 打开弹窗前
  beforePopupOpen: ({ layer: o, feature: b, popupOptions: { component: f, anchor: x, nameWidth: S, valueWidth: y, prevent: s } }) => D(o) && D(b) && (D(f) || ct(f) || Ot(f)) && ct(x) && ut(S) && ut(y) && qe(s),
  // 关闭弹窗后
  afterPopupClosed: ({ layer: o }) => D(o),
  // 关闭
  close: () => !0
}, Ft = {
  ...Xe,
  /**
   * @description 是否激活，默认不激活
   */
  isActive: {
    type: Boolean,
    default: !1
  }
}, qt = {
  ...Ke
}, ci = {
  ...Xe
}, ui = {
  ...Ke
}, mi = {
  /**
   * @description 图层列表参数
   */
  layersParams: {
    type: Array
  },
  ...Xe
}, di = {
  ...Ke
}, yt = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAbCAYAAAB836/YAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9za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ieG1wLmRpZDo2MjQ0MUEyNDI0RDQxMUU3QkE1OUM2RjdGQjAxMDQ2NCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/Pldf8IIAAAHiSURBVHjaYvz//z8DIyMjAzr46mzmBqTCgNgJiGWhwo+BeB8Qr+Lee2oXSC86YEQX/OZirgKkZgOxAwN+cACI07j2nLyN00CgYTZAaiMQCzEQB94BsT/Q0CMYBgINUwVSp4GYn4E08BGITWEuZUKSmEuGYQxQPXNRXAh0HSi89jNQBhyArjwIc2EYViVsbAxsOSUMnJv2gTFbTjEDAwsrLgPBZrBAOfZYzUvNYWAJCIXzWQKAev79Z/g1rQ+bcnvkMJTGpoLZ3QdTzNUTlwtlkA3kZqAccCEb+Aqbij9b1mOKbd2Ay8DXyGF4Hoil0FX8njeDgZGVFehNLwYGYGr4u2c7w+8Fs3AZeA452WQA2dMp9HImMNnMgHl5CczJZILXUDMgYQg0+QuQKqLAwCKoGRiFwzSQ00k0bDrQsCwYhwlNMheIN5Ng2DaoHrzlIRe0EDUnYNhJUOELdN03vAZCDRUFUmeAWA6HYQ+hRdZrgiU2kqH6QOoUKEujSf0CYjOgYRex6WPCmY8gGtqxSLXjMgyvgVDQCcRvkPhvoGIMZBkIdMl3IDUVSWgyVIyBXBeCwFok9npCinFGCloEPYW6WJqQWnBpo9OEXxEwqm+CLCek7kodovhiICIRExM8DAABBgBD8KOM5w279wAAAABJRU5ErkJggg==", Jt = ["title"], Ht = ["title"], Xt = /* @__PURE__ */ gt({
  __name: "attribute-table-popup",
  props: {
    feature: {
      type: Object
    },
    nameWidth: {
      type: Number
    },
    valueWidth: {
      type: Number
    },
    closePopup: {
      type: Function
    }
  },
  setup(o) {
    const b = o, f = ft("attribute-table-popup"), x = O(() => Object.entries(b.feature.attributes).map(([S, y]) => ({
      name: S,
      value: y
    })));
    return (S, y) => {
      const s = g("mapgis-ui-iconfont"), z = g("a-list-item"), P = g("a-list");
      return G(), Je("div", {
        class: C([l(f).b()])
      }, [
        H("div", {
          class: C(l(f).e("header"))
        }, [
          c(s, {
            type: "mapgis-close",
            class: C(l(f).em("header", "close")),
            onClick: y[0] || (y[0] = (E) => o.closePopup())
          }, null, 8, ["class"])
        ], 2),
        c(P, {
          class: C(l(f).e("content")),
          "item-layout": "horizontal",
          "data-source": x.value,
          size: "small"
        }, {
          renderItem: m(({ item: E }) => [
            c(z, {
              class: C(l(f).em("content", "item"))
            }, {
              default: m(() => [
                H("div", {
                  style: rt({ width: `${o.nameWidth}px` }),
                  title: E.name
                }, ke(E.name), 13, Jt),
                H("div", {
                  style: rt({ width: `${o.valueWidth}px` }),
                  title: E.value
                }, ke(E.value), 13, Ht)
              ]),
              _: 2
            }, 1032, ["class"])
          ]),
          _: 1
        }, 8, ["class", "data-source"])
      ], 2);
    };
  }
}), Kt = /* @__PURE__ */ bt(Xt, [["__scopeId", "data-v-a4218dac"]]), $t = (o, b, f, x) => {
  const S = Et(), { zondy: y, viewState: s, map: z } = jt(), { toggle: P, isFullscreen: E } = zt(f), { GeometryType: w, LayerType: ve, SubLayerType: Ce } = y.enum, t = Nt({
    // 属性表加载状态
    loading: !1,
    // 属性表展示的列
    tableColumns: [],
    // 属性表初始展示的列
    tableColumnsCache: [],
    // 属性表数据（要素列表，包含属性、几何等信息）
    attributeTableData: [],
    // 属性表分页器参数
    pagination: {
      current: 1,
      pageSize: 10,
      total: 0,
      pageSizeOptions: ["5", "10", "20", "30", "50"]
    },
    // 是否使用水平滚动条
    useScrollX: !1,
    // 垂直滚动条的高度
    scrollY: 0,
    // 是否随地图范围过滤
    filterWithMap: !1,
    // 高亮已选择
    hightlightSelection: !1,
    // 选中的行
    selection: [],
    // 查询结果显示样式
    queryShowStyle: void 0,
    // 显示模式
    selectedShowMode: [],
    // 内置的属性过滤相关参数
    // 属性过滤是否显示
    filterVisible: !1,
    // 属性过滤表达式
    filterExpression: "",
    // 查询参数featureIds
    featureIds: [],
    // 属性表要素查询参数
    layerQueryOptions: null,
    // 内置的属性统计相关参数
    statisticsVisible: !1
  });
  let k, X, j, W, R, T, d, Z, N = [], K = [], h, Q, Y, U = !1;
  const ne = ["BYTE", "SHORT", "INT", "LONG", "FLOAT", "DOUBLE", "BINARY"], le = ["TIME", "DATE", "TIMESTAMP"];
  !o.queryShowStyle || !Object.keys(o.queryShowStyle).length ? t.queryShowStyle = { ...He } : t.queryShowStyle = { ...He, ...o.queryShowStyle }, t.queryShowStyle.markerStyle.defaultImage === "" && (t.queryShowStyle.markerStyle.defaultImage = yt), t.queryShowStyle.markerStyle.highlightImage === "" && (t.queryShowStyle.markerStyle.highlightImage = pt), t.selectedShowMode = [t.queryShowStyle.showMode];
  const Ae = O(() => o.queryShowStyle.showMode === "markerHighlight"), Ie = O(() => {
    const e = t.tableColumns.filter((i) => i.visible);
    return t.useScrollX || e.forEach((i) => {
      i.width = `${100 / e.length}%`;
    }), e;
  }), Me = O(() => {
    if (o.layerParams && o.layerParams.layer) {
      const e = ae.value.length, { title: i } = o.layerParams.layer;
      return `${i}（${e} 已选择）`;
    }
    return "";
  }), ae = O(() => t.selection.map((e) => e.id)), oe = O(() => !$.value && t.tableColumns.some((e) => e.visible)), $ = O(() => t.tableColumns.every((e) => e.visible));
  Se(
    () => o.layerParams,
    () => {
      B(), I();
    }
  ), Se(
    () => o.queryOtherOptions,
    () => {
      B(), I();
    }
  ), Se(
    () => E.value,
    () => {
      de();
    }
  ), Se(
    () => o.isActive,
    (e) => {
      e ? At() : It();
    }
  ), xt(() => {
    B(), I(), ye();
  }), _t(() => {
    me();
  });
  function Ee(e) {
    t.filterExpression = e, t.pagination.current = 1, I();
  }
  function Ne(e, i) {
    return `显示${i[0]}-${i[1]}条，共有 ${e}条`;
  }
  function xe(e, i) {
    t.pagination.current = e, t.pagination.pageSize = i, I();
  }
  function _e(e) {
    t.pagination.current = e, I();
  }
  function Ge(e, i) {
    t.selection = i, fe(), U = !0, r();
  }
  function Re(e) {
    const i = {
      layer: o.layerParams.layer,
      feature: e,
      prevent: !1
    };
    if (b("attributeTableRowClick", i), !i.prevent) {
      const { extent: n } = $e(e.geometry);
      if (n) {
        const { xmax: a, xmin: v, ymax: u, ymin: te } = n, Be = [(v + a) / 2, (te + u) / 2];
        if (s.viewMode === "3D") {
          const Mt = s.view.getInnerView().camera.positionCartographic.height;
          Be.push(Mt), s.view.flyTo({ center: Be });
        } else
          s.view.flyTo({ center: Be, zoom: s.view.zoom });
      }
    }
  }
  function Te(e) {
    const i = we.fromJSON(e.geometry).extent, n = {
      layer: o.layerParams.layer,
      feature: e,
      prevent: !1
    };
    b("attributeTableRowDoubleClick", n), n.prevent || i && s.view.flyTo({ extent: i });
  }
  async function De({ key: e }) {
    t.queryShowStyle.showMode = e, t.selectedShowMode = [e], ge(), await We(), fe();
  }
  function je({ key: e }) {
    if (k) {
      const i = {
        ...tt(),
        pageNumber: 1,
        pageSize: t.pagination.total
      };
      k.exportAttributes(i, {
        f: e
      });
    }
  }
  function Ze() {
    I();
  }
  function Qe() {
    $.value ? t.tableColumns.forEach((e) => e.visible = !1) : oe.value ? t.tableColumns.forEach((e) => e.visible = !0) : t.tableColumns.forEach((e) => e.visible = !0);
  }
  function Ye() {
    t.tableColumns = Object.assign(t.tableColumns, mt(t.tableColumnsCache));
  }
  function Le(e) {
    e ? (R = s.view.getExtent(), he()) : F(), U = !1, t.pagination.current = 1, I();
  }
  function _(e) {
    if (d && t.queryShowStyle.showMode === "markerHighlight")
      if (e) {
        const i = t.selection.map((n) => n.id);
        d.graphics.items.forEach((n) => {
          i.includes(n.id) ? n.visible = !0 : N.includes(n.id) && (n.visible = !1);
        });
      } else
        d.graphics.items.forEach((i) => {
          N.includes(i.id) && (i.visible = !1);
        });
  }
  function r() {
    if (t.selection.length == 0) return;
    T = St();
    const e = s.view.getExtent();
    (e.ymin !== T.ymin || e.xmin !== T.xmin || e.ymax !== T.ymax || e.xmax !== T.xmax) && s.view.flyTo({ extent: T });
  }
  function re() {
    ue();
  }
  function A() {
    P();
  }
  function se() {
    me(), b("close");
  }
  function V(e, i) {
    t.filterExpression = e, t.featureIds = i, ee();
  }
  function ce() {
    t.filterExpression = "", t.featureIds = o.layerParams.featureIds || [], ee();
  }
  function ee() {
    t.filterVisible = !1, t.pagination.current = 1, I();
  }
  async function B() {
    const { layerParams: e } = o;
    if (e && (t.pagination.current = 1, k = Zt(e.layer), X = e.geometry, j = e.attributeFilter, W = e.featureIds || [], e.featureIds && (t.featureIds = e.featureIds), k)) {
      const i = await k.getFields();
      Oe(e.fieldList, i);
    }
  }
  async function I() {
    if (!k) return;
    t.loading = !0, ue(), ge();
    const e = tt();
    t.layerQueryOptions = e, t.pagination.total = await k.queryFeaturesCount(e);
    const i = await k.queryFeatures(e);
    t.attributeTableData = i.map((n) => ({
      id: Yt(),
      ...n
    })), de(), We(), t.loading = !1;
  }
  function Oe(e, i) {
    if (e && e.length > 0 && (i = i.filter((n) => e.includes(n.name))), k.layer) {
      const { type: n } = k.layer;
      [ve.IGSFeature, Ce.IGSMapImageSub].includes(n) && i.unshift({
        name: "FID",
        type: "long"
      });
    }
    t.useScrollX = i.length > 10, t.tableColumns = i.map((n) => {
      const a = {
        title: n.alias || n.name,
        key: n.name,
        dataIndex: `attributes.${n.name}`,
        align: "left",
        ellipsis: !0,
        visible: !0,
        customRender: ({ record: u }) => u.attributes[n.name]
      };
      return t.useScrollX ? a.width = 180 : a.width = `${100 / i.length}%`, [...ne, ...le].includes(n.type.toUpperCase()) && (a.sorter = (u, te) => ze(u.attributes[a.key], te.attributes[a.key], n.type)), a;
    }), t.tableColumnsCache = mt(t.tableColumns);
  }
  function ze(e, i, n) {
    return ne.includes(n.toUpperCase()) ? e - i : le.includes(n.toUpperCase()) ? dt(e).isAfter(dt(i)) : !1;
  }
  function ue() {
    t.selection = [], fe();
  }
  function me() {
    ge(), d && (s.view.graphicsLayers.remove(d), d = null), pe(), F();
  }
  function de() {
    var e, i, n;
    !x.value || !((e = x.value) != null && e.$el) || (E.value ? t.scrollY = window.innerHeight - ((i = x.value) == null ? void 0 : i.$el.getBoundingClientRect().top) - 30 - 31 : t.scrollY = o.customMaxHeight((n = x.value) == null ? void 0 : n.$el) - 30 - 31);
  }
  function he() {
    Y = Wt(Pe, 500), s.view.on(J.viewChange, Y);
  }
  function Pe(e) {
    U ? U = !1 : (R = s.view.getExtent(), t.pagination.current = 1, I());
  }
  function F() {
    R = void 0, Y && (s.view.off(J.viewChange, Y), Y.cancel());
  }
  function ye() {
    s.view.on(J.click, p), Q = Pt(M, 100), s.view.on(J.pointerMove, Q);
  }
  function p(e) {
    if (!e)
      return;
    const i = s.view.hitTest({
      x: e.x,
      y: e.y
    });
    i && (t.queryShowStyle.showMode === "markerHighlight" ? kt(i) : t.queryShowStyle.showMode === "featureHighlight" && vt(i));
  }
  function M(e) {
    if (!e)
      return;
    const i = s.view.hitTest({
      x: e.x,
      y: e.y
    });
    i && t.queryShowStyle.showMode === "markerHighlight" && Ct(i);
  }
  function pe() {
    s.view.off(J.click, p), Q && (s.view.off(J.pointerMove, Q), Q.cancel());
  }
  function St() {
    let e;
    const i = t.selection.reduce(
      (a, v) => {
        const { extent: u } = v.geometry;
        return e || (e = v.geometry.spatialReference), {
          xmin: u.xmin < a.xmin ? u.xmin : a.xmin,
          ymin: u.ymin < a.ymin ? u.ymin : a.ymin,
          xmax: u.xmax > a.xmax ? u.xmax : a.xmax,
          ymax: u.ymax > a.ymax ? u.ymax : a.ymax
        };
      },
      {
        xmin: Number.MAX_VALUE,
        ymin: Number.MAX_VALUE,
        xmax: Number.MIN_VALUE,
        ymax: Number.MIN_VALUE
      }
    );
    return new y.geometry.Extent({ ...i, spatialReference: e });
  }
  function $e(e) {
    let i = we.fromJSON(e);
    return i.spatialReference.wkid !== z.spatialReference.wkid && (i = y.geometry.Projection.project(i, z.spatialReference)), i;
  }
  function et(e) {
    let i = we.fromJSON(e);
    return i.spatialReference.wkid !== 4326 && (i = y.geometry.Projection.project(
      i,
      new y.SpatialReference({
        wkid: 4326
      })
    )), i;
  }
  function tt() {
    let e = j, i = [...W];
    return t.filterExpression && t.filterExpression.trim().length > 0 && (j && j.trim().length > 0 ? e = `(${j}) AND (${t.filterExpression})` : e = t.filterExpression), t.featureIds && t.featureIds.length && (i = t.featureIds), {
      geometry: t.filterWithMap ? R : X,
      distance: o.layerParams.distance,
      attributeFilter: e,
      featureIds: i,
      fieldList: o.layerParams.fieldList,
      pageNumber: t.pagination.current,
      pageSize: t.pagination.pageSize
    };
  }
  async function We() {
    d ? d.removeAll() : (d = new y.layer.GraphicsLayer(), s.view.graphicsLayers.add(d));
    const e = t.attributeTableData.map((i) => {
      const n = new ht(i);
      return n.visible = !1, n;
    }).filter((i) => i.geometry);
    if (N = e.map((i) => i.id), t.queryShowStyle.showMode === "markerHighlight") {
      e.forEach((n) => {
        Ve(n);
      }), d.addMany(e), await wt();
      const i = e.map((n) => {
        const a = nt(n.geometry);
        return new ht({
          id: `${n.id}_marker`,
          // 考虑到geometry坐标系问题，直接克隆geometry
          geometry: a.clone(),
          // 将图片的底部中心点跟位置对齐
          symbol: new y.symbol.PictureMarkerSymbol({
            url: t.queryShowStyle.markerStyle.defaultImage,
            width: t.queryShowStyle.markerStyle.width,
            height: t.queryShowStyle.markerStyle.height,
            xoffset: 0,
            yoffset: t.queryShowStyle.markerStyle.height / 2
          }),
          elevationInfo: new Ut({
            mode: Vt.OnTheScene
          }),
          attributes: n.attributes,
          visible: !0
        });
      });
      d.addMany(i), K = i.map((n) => n.id);
    } else t.queryShowStyle.showMode === "featureHighlight" && (e.forEach((i) => {
      Ue(i), i.visible = !0;
    }), d.addMany(e));
  }
  function ge() {
    d && d.removeAll(), be(), h = null;
  }
  function Ue(e) {
    it(e, t.queryShowStyle.featureStyle);
  }
  function Ve(e) {
    it(e, t.queryShowStyle.highlightFeatureStyle);
  }
  function it(e, i) {
    const { geometry: n } = e;
    let a;
    if (n !== null) {
      switch (n.type) {
        case w.point:
        case w.multiPoint:
          a = y.symbol.Symbol.fromJSON(i.marker);
          break;
        case w.lineString:
        case w.multiLineString:
          a = y.symbol.Symbol.fromJSON(i.line);
          break;
        case w.polygon:
        case w.multiPolygon:
          a = y.symbol.Symbol.fromJSON(i.fill);
          break;
      }
      e.symbol = a;
    }
  }
  async function wt() {
    if (t.queryShowStyle.markerStyle.width === 0 || t.queryShowStyle.markerStyle.height === 0)
      try {
        const e = await Lt(t.queryShowStyle.markerStyle.defaultImage);
        t.queryShowStyle.markerStyle.width = e.width, t.queryShowStyle.markerStyle.height = e.height;
      } catch {
        t.queryShowStyle.markerStyle.width = 20, t.queryShowStyle.markerStyle.height = 27;
      }
  }
  function nt(e) {
    let i = Bt.getLabelPoint(e);
    if (!i) {
      const { extent: n } = $e(e);
      if (n) {
        const { xmax: a, xmin: v, ymax: u, ymin: te } = n;
        i = we.fromJSON({ type: w.point, coordinates: [(v + a) / 2, (te + u) / 2] });
      }
    }
    return i;
  }
  function fe() {
    if (d) {
      const e = t.selection.map((n) => n.id), i = t.selection.map((n) => `${n.id}_marker`);
      d.graphics.items.forEach((n) => {
        t.queryShowStyle.showMode === "markerHighlight" ? (t.hightlightSelection && e.includes(n.id) ? n.visible = !0 : N.includes(n.id) && (n.visible = !1), i.includes(n.id) ? n.symbol.url = pt : K.includes(n.id) && (n.symbol.url = yt)) : t.queryShowStyle.showMode === "featureHighlight" && (e.includes(n.id) ? Ve(n) : N.includes(n.id) && Ue(n));
      });
    }
  }
  function lt(e, i, n, a, v) {
    be();
    const u = {
      layer: o.layerParams.layer,
      feature: e,
      popupOptions: {
        component: t.queryShowStyle.popupStyle.component,
        anchor: t.queryShowStyle.popupStyle.anchor,
        nameWidth: t.queryShowStyle.popupStyle.nameWidth,
        valueWidth: t.queryShowStyle.popupStyle.valueWidth,
        prevent: !1
      }
    };
    b("beforePopupOpen", u), u.popupOptions.prevent || (Z = Qt(
      s.engine,
      s.engineContext,
      {
        longitude: i,
        latitude: n
      },
      {
        anchor: u.popupOptions.anchor,
        offset: [a, v],
        content: u.popupOptions.component || Kt,
        props: {
          feature: e,
          nameWidth: u.popupOptions.nameWidth,
          valueWidth: u.popupOptions.valueWidth
        }
      },
      S
    ), Z.openPopup());
  }
  function be() {
    Z && (Z.closePopup(), Z = null), b("afterPopupClosed", { layer: o.layerParams.layer });
  }
  function at(e) {
    t.hightlightSelection && t.selection.find((n) => n.id === e.id) || (e.visible = !1);
  }
  function ot(e) {
    t.selection.find((n) => n.id === e.id) || Ue(e);
  }
  function kt(e) {
    if (e.length > 0) {
      const i = e.find((n) => n.graphic && typeof n.graphic.id == "string" ? K.includes(n.graphic.id) : !1);
      if (i) {
        const n = i.graphic.id.split("_marker")[0], a = d.findGraphicById(n);
        if (a) {
          const v = et(i.graphic.geometry);
          lt(
            a,
            v.coordinates[0],
            v.coordinates[1],
            0,
            -t.queryShowStyle.markerStyle.height
          );
          return;
        }
      }
    }
    be();
  }
  function vt(e) {
    if (e.length > 0) {
      const i = e.find((n) => n.graphic && typeof n.graphic.id == "string" ? N.includes(n.graphic.id) : !1);
      if (i) {
        const n = d.findGraphicById(i.graphic.id);
        if (n) {
          let a = nt(n.geometry);
          if (a = et(a), !h || h.id !== n.id) {
            lt(n, a.coordinates[0], a.coordinates[1], 0, 0), h && h.id !== n.id && ot(h), h = n, Ve(n);
            return;
          }
        }
      }
    }
    be(), h && (ot(h), h = null);
  }
  function Ct(e) {
    if (e.length > 0) {
      const i = e.find((n) => n.graphic && typeof n.graphic.id == "string" ? n.graphic.id.endsWith("_marker") : !1);
      if (i) {
        const n = i.graphic.id.split("_marker")[0], a = d.findGraphicById(n);
        if (a) {
          (!h || h.id !== a.id) && (h && h.id !== a.id && at(h), h = a, a.visible || (a.visible = !0));
          return;
        }
      }
    }
    h && (at(h), h = null);
  }
  async function At() {
    await We(), fe(), ye(), t.filterWithMap && he();
  }
  function It() {
    ge(), pe(), F();
  }
  return {
    ...Gt(t),
    isFullscreen: E,
    // 下面是计算属性
    hightlightable: Ae,
    visibleColumns: Ie,
    selectedRowKeys: ae,
    columnSelectIndeterminate: oe,
    isColumnAllSelected: $,
    selectedDescription: Me,
    // 下面是方法
    filterAttributes: Ee,
    showPaginationTotal: Ne,
    handlePaginationShowSizeChange: xe,
    handlePaginationChange: _e,
    handleSelectChange: Ge,
    handleRowClick: Re,
    handleRowDbClick: Te,
    handleShowModeClick: De,
    handleExportMenuClick: je,
    handleRefreshClick: Ze,
    handleColumnAllSelectChange: Qe,
    handleResetColumns: Ye,
    handleFilterWithMapChange: Le,
    handleHightlightSelectionChange: _,
    handleZoomTo: r,
    handleClearSelection: re,
    handleToggleScreen: A,
    handleClose: se,
    handleFilterSubmit: V,
    handleFilterReset: ce
  };
}, ei = /* @__PURE__ */ gt({
  name: "MapgisAttributeTable",
  __name: "attribute-table",
  props: Ft,
  emits: qt,
  setup(o, { emit: b }) {
    const f = o, x = b, S = ft("attribute-table"), y = st(), s = st(), {
      loading: z,
      tableColumns: P,
      attributeTableData: E,
      pagination: w,
      useScrollX: ve,
      scrollY: Ce,
      filterWithMap: t,
      hightlightSelection: k,
      isFullscreen: X,
      queryShowStyle: j,
      selectedShowMode: W,
      filterVisible: R,
      filterExpression: T,
      featureIds: d,
      layerQueryOptions: Z,
      statisticsVisible: N,
      // 下面是计算属性
      hightlightable: K,
      visibleColumns: h,
      selectedRowKeys: Q,
      columnSelectIndeterminate: Y,
      isColumnAllSelected: U,
      selectedDescription: ne,
      // 下面是方法
      filterAttributes: le,
      showPaginationTotal: Ae,
      handlePaginationShowSizeChange: Ie,
      handlePaginationChange: Me,
      handleSelectChange: ae,
      handleRowClick: oe,
      handleRowDbClick: $,
      handleShowModeClick: Ee,
      handleExportMenuClick: Ne,
      handleRefreshClick: xe,
      handleColumnAllSelectChange: _e,
      handleResetColumns: Ge,
      handleFilterWithMapChange: Re,
      handleHightlightSelectionChange: Te,
      handleZoomTo: De,
      handleClearSelection: je,
      handleToggleScreen: Ze,
      handleClose: Qe,
      handleFilterSubmit: Ye,
      handleFilterReset: Le
    } = $t(f, x, s, y);
    return (_, r) => {
      const re = g("a-switch"), A = g("mapgis-ui-toolbar-command"), se = g("mapgis-ui-toolbar-space"), V = g("a-menu-item"), ce = g("a-menu"), ee = g("a-dropdown"), B = g("a-checkbox"), I = g("a-button"), Oe = g("a-row"), ze = g("a-popover"), ue = g("mapgis-ui-toolbar-command-group"), me = g("mapgis-ui-toolbar"), de = g("a-table"), he = g("a-pagination"), Pe = g("mapgis-attribute-filter"), F = g("a-modal"), ye = g("mapgis-attribute-statistics");
      return G(), Je("div", {
        class: C([l(S).b()]),
        ref_key: "attributeTableContainerRef",
        ref: s
      }, [
        c(me, {
          class: C([l(S).e("header")]),
          bordered: !1,
          size: "small"
        }, {
          default: m(() => [
            H("span", null, ke(l(ne)), 1),
            c(re, {
              "checked-children": "范围过滤",
              "un-checked-children": "范围过滤",
              checked: l(t),
              "onUpdate:checked": r[0] || (r[0] = (p) => Fe(t) ? t.value = p : null),
              size: "small",
              class: C([l(S).em("header", "operation")]),
              onChange: l(Re)
            }, null, 8, ["checked", "class", "onChange"]),
            l(K) ? (G(), q(re, {
              key: 0,
              "checked-children": "高亮已选择",
              "un-checked-children": "高亮已选择",
              checked: l(k),
              "onUpdate:checked": r[1] || (r[1] = (p) => Fe(k) ? k.value = p : null),
              size: "small",
              class: C([l(S).em("header", "operation")]),
              onChange: l(Te)
            }, null, 8, ["checked", "class", "onChange"])) : ie("", !0),
            c(A, {
              title: "缩放至已选择",
              icon: "mapgis-map",
              size: "small",
              onClick: l(De)
            }, null, 8, ["onClick"]),
            c(A, {
              title: "清除选择",
              icon: "mapgis-close-circle",
              size: "small",
              onClick: l(je)
            }, null, 8, ["onClick"]),
            c(se),
            c(ue, null, {
              default: m(() => {
                var p;
                return [
                  Rt(_.$slots, "toolbar", {
                    layer: (p = _.layerParams) == null ? void 0 : p.layer,
                    filterAttributes: l(le)
                  }, void 0, !0),
                  _.enableStatistics ? (G(), q(A, {
                    key: 0,
                    title: "属性统计",
                    icon: "mapgis-barchart",
                    size: "small",
                    onClick: r[2] || (r[2] = (M) => N.value = !0)
                  })) : ie("", !0),
                  _.enableFilter ? (G(), q(A, {
                    key: 1,
                    title: "属性过滤",
                    icon: "mapgis-filter",
                    size: "small",
                    onClick: r[3] || (r[3] = (M) => R.value = !0)
                  })) : ie("", !0),
                  c(se),
                  c(ee, {
                    getPopupContainer: () => s.value
                  }, {
                    overlay: m(() => [
                      c(ce, {
                        selectedKeys: l(W),
                        "onUpdate:selectedKeys": r[4] || (r[4] = (M) => Fe(W) ? W.value = M : null),
                        onClick: l(Ee)
                      }, {
                        default: m(() => [
                          c(V, { key: "markerHighlight" }, {
                            default: m(() => [...r[9] || (r[9] = [
                              L(" 标注高亮模式 ", -1)
                            ])]),
                            _: 1
                          }),
                          c(V, { key: "featureHighlight" }, {
                            default: m(() => [...r[10] || (r[10] = [
                              L(" 要素高亮模式 ", -1)
                            ])]),
                            _: 1
                          })
                        ]),
                        _: 1
                      }, 8, ["selectedKeys", "onClick"])
                    ]),
                    default: m(() => [
                      c(A, {
                        title: "",
                        icon: l(j).showMode === "markerHighlight" ? "mapgis-map-pin" : "mapgis-area",
                        size: "small"
                      }, null, 8, ["icon"])
                    ]),
                    _: 1
                  }, 8, ["getPopupContainer"]),
                  c(ee, {
                    getPopupContainer: () => s.value
                  }, {
                    overlay: m(() => [
                      c(ce, { onClick: l(Ne) }, {
                        default: m(() => [
                          c(V, { key: "json" }, {
                            default: m(() => [...r[11] || (r[11] = [
                              L(" 导出json文件 ", -1)
                            ])]),
                            _: 1
                          }),
                          c(V, { key: "csv" }, {
                            default: m(() => [...r[12] || (r[12] = [
                              L(" 导出csv文件 ", -1)
                            ])]),
                            _: 1
                          })
                        ]),
                        _: 1
                      }, 8, ["onClick"])
                    ]),
                    default: m(() => [
                      c(A, {
                        title: "",
                        icon: "mapgis-download",
                        size: "small"
                      })
                    ]),
                    _: 1
                  }, 8, ["getPopupContainer"]),
                  c(A, {
                    title: "刷新",
                    icon: "mapgis-redo",
                    size: "small",
                    onClick: l(xe)
                  }, null, 8, ["onClick"]),
                  l(P).length ? (G(), q(ze, {
                    key: 2,
                    placement: "bottomRight",
                    trigger: "click",
                    getPopupContainer: () => s.value
                  }, {
                    title: m(() => [
                      H("div", {
                        class: C(l(S).em("columns", "title"))
                      }, [
                        c(B, {
                          indeterminate: l(Y),
                          checked: l(U),
                          onChange: l(_e)
                        }, {
                          default: m(() => [...r[13] || (r[13] = [
                            L(" 列展示 ", -1)
                          ])]),
                          _: 1
                        }, 8, ["indeterminate", "checked", "onChange"]),
                        c(I, {
                          size: "small",
                          type: "link",
                          onClick: l(Ge)
                        }, {
                          default: m(() => [...r[14] || (r[14] = [
                            L(" 重置 ", -1)
                          ])]),
                          _: 1
                        }, 8, ["onClick"])
                      ], 2)
                    ]),
                    content: m(() => [
                      H("div", {
                        class: C(l(S).em("columns", "content"))
                      }, [
                        (G(!0), Je(Tt, null, Dt(l(P), (M) => (G(), q(Oe, {
                          key: M.dataIndex
                        }, {
                          default: m(() => [
                            c(B, {
                              checked: M.visible,
                              "onUpdate:checked": (pe) => M.visible = pe
                            }, {
                              default: m(() => [
                                L(ke(M.title), 1)
                              ]),
                              _: 2
                            }, 1032, ["checked", "onUpdate:checked"])
                          ]),
                          _: 2
                        }, 1024))), 128))
                      ], 2)
                    ]),
                    default: m(() => [
                      c(A, {
                        title: "列配置",
                        size: "small",
                        icon: "mapgis-setting"
                      })
                    ]),
                    _: 1
                  }, 8, ["getPopupContainer"])) : ie("", !0),
                  c(A, {
                    title: l(X) ? "取消全屏" : "全屏",
                    icon: l(X) ? "mapgis-collapse" : "mapgis-expand",
                    size: "small",
                    onClick: l(Ze)
                  }, null, 8, ["title", "icon", "onClick"]),
                  _.closable ? (G(), q(A, {
                    key: 3,
                    title: "关闭",
                    icon: "mapgis-close",
                    size: "small",
                    onClick: l(Qe)
                  }, null, 8, ["onClick"])) : ie("", !0)
                ];
              }),
              _: 3
            })
          ]),
          _: 3
        }, 8, ["class"]),
        c(de, {
          ref_key: "attributeTableRef",
          ref: y,
          class: C([l(S).e("table")]),
          bordered: "",
          size: "small",
          loading: l(z),
          columns: l(h),
          dataSource: l(E),
          pagination: !1,
          showSorterTooltip: !1,
          rowKey: (p) => p.id,
          scroll: {
            x: l(ve) ? "100%" : !1,
            y: l(Ce)
          },
          rowSelection: {
            selectedRowKeys: l(Q),
            onChange: l(ae),
            type: "checkbox",
            fixed: !0,
            columnWidth: "50px"
          },
          customRow: (p) => ({
            onClick: (M) => l(oe)(p),
            onDblclick: (M) => l($)(p)
          })
        }, null, 8, ["class", "loading", "columns", "dataSource", "rowKey", "scroll", "rowSelection", "customRow"]),
        c(he, {
          class: C([l(S).e("pagination")]),
          size: "small",
          current: l(w).current,
          "onUpdate:current": r[5] || (r[5] = (p) => l(w).current = p),
          pageSize: l(w).pageSize,
          "onUpdate:pageSize": r[6] || (r[6] = (p) => l(w).pageSize = p),
          pageSizeOptions: l(w).pageSizeOptions,
          total: l(w).total,
          showTotal: l(Ae),
          showSizeChanger: "",
          showQuickJumper: "",
          showLessItems: "",
          onShowSizeChange: l(Ie),
          onChange: l(Me)
        }, null, 8, ["class", "current", "pageSize", "pageSizeOptions", "total", "showTotal", "onShowSizeChange", "onChange"]),
        c(F, {
          open: l(R),
          title: "属性过滤",
          width: 360,
          mask: !1,
          footer: null,
          onCancel: r[7] || (r[7] = (p) => R.value = !1)
        }, {
          default: m(() => [
            c(Pe, {
              showAttributeSearchType: "",
              filterExpression: l(T),
              featureIds: l(d),
              layerQueryOptions: l(Z),
              layer: _.layerParams.layer,
              onSubmit: l(Ye),
              onReset: l(Le)
            }, null, 8, ["filterExpression", "featureIds", "layerQueryOptions", "layer", "onSubmit", "onReset"])
          ]),
          _: 1
        }, 8, ["open"]),
        c(F, {
          open: l(N),
          title: "属性统计",
          width: 480,
          mask: !1,
          footer: null,
          onCancel: r[8] || (r[8] = (p) => N.value = !1)
        }, {
          default: m(() => [
            c(ye, {
              layer: _.layerParams.layer
            }, null, 8, ["layer"])
          ]),
          _: 1
        }, 8, ["open"])
      ], 2);
    };
  }
}), hi = /* @__PURE__ */ bt(ei, [["__scopeId", "data-v-255070b9"]]);
export {
  hi as A,
  ui as a,
  ci as b,
  di as c,
  mi as d,
  Ke as e,
  Xe as f,
  qt as g,
  Ft as h,
  $t as u
};
