import { defineComponent as z, computed as k, ref as v, onMounted as M, nextTick as R, resolveDirective as X, withDirectives as Y, createElementBlock as n, openBlock as s, normalizeClass as w, createElementVNode as c, createVNode as F, normalizeStyle as f, createCommentVNode as x, toDisplayString as $, Transition as U, withCtx as W, Fragment as q, renderList as A, withModifiers as G } from "vue";
import { nanoid as O } from "nanoid";
import { cloneDeep as K } from "lodash";
/* empty css                                     */
/* empty css                                     */
import "../Tabs/index.mjs";
import "../Tabs-icon/index.mjs";
import "../Button/index.mjs";
import "../DatePicker/index.mjs";
import "../DatePickerRange/index.mjs";
import "../Switch/index.mjs";
import "../Input/index.mjs";
import "./index.mjs";
import "../Slider/index.mjs";
import "../../../Text/components/List/index.mjs";
import "../../../Text/components/Text/index.mjs";
import "../../../Text/components/TextDynamic/index.mjs";
import "../../../Text/components/TableBasic/index.mjs";
import "../../../Text/components/TableScroll/index.mjs";
import "../../../Text/components/RowScroll/index.mjs";
import "../../../Text/components/RealTime/index.mjs";
import "../../../Text/components/OverNumber/index.mjs";
import "../../../Text/components/CountDown/index.mjs";
import "../../../Text/components/TextCarousel/index.mjs";
import "../../../Media/components/Audio/index.mjs";
import "../../../Media/components/Video/index.mjs";
import "../../../Media/components/Carousel/index.mjs";
import "../../../Media/components/Flv/index.mjs";
import "../../../Media/components/Iframe/index.mjs";
import "../../../Media/components/IframeCarousel/index.mjs";
import "../../../Media/components/Image/index.mjs";
import "../../../Media/components/ImageDynamic/index.mjs";
import "../../../Media/components/M3u8/index.mjs";
import "../../../Media/components/Wavesurfer/index.mjs";
import "../../../Media/components/Weather/index.mjs";
import "../../../Media/components/Qrcode/index.mjs";
import "../../../Chart/components/bar/basic/index.mjs";
import "../../../Chart/components/bar/animation/index.mjs";
import "../../../Chart/components/bar/contrast/index.mjs";
import "../../../Chart/components/bar/contrast2/index.mjs";
import "../../../Chart/components/bar/contrast3/index.mjs";
import "../../../Chart/components/bar/gradient-column-chart/index.mjs";
import "../../../Chart/components/bar/horizontal/index.mjs";
import "../../../Chart/components/bar/horizontal-stack/index.mjs";
import "../../../Chart/components/bar/line-bar/index.mjs";
import "../../../Chart/components/bar/line-bar2/index.mjs";
import "../../../Chart/components/bar/loop/index.mjs";
import "../../../Chart/components/bar/mini/index.mjs";
import "../../../Chart/components/bar/polar/index.mjs";
import "../../../Chart/components/bar/polar-stack/index.mjs";
import "../../../Chart/components/bar/polar2/index.mjs";
import "../../../Chart/components/bar/radius-circle/index.mjs";
import "../../../Chart/components/bar/rank/index.mjs";
import "../../../Chart/components/bar/segmented-progress/index.mjs";
import "../../../Chart/components/bar/spire/index.mjs";
import "../../../Chart/components/bar/stack/index.mjs";
import "../../../Chart/components/bar/stack-line/index.mjs";
import "../../../Chart/components/bar/stack2/index.mjs";
import "../../../Chart/components/bar/stack3/index.mjs";
import "../../../Chart/components/bar/staggered/index.mjs";
import "../../../Chart/components/bar/three/index.mjs";
import "../../../Chart/components/bar/waterfall/index.mjs";
import "../../../Chart/components/bar/zebra/index.mjs";
import "../../../Chart/components/line/area-gradient/index.mjs";
import "../../../Chart/components/line/area-highlight/index.mjs";
import "../../../Chart/components/line/area-highlight2/index.mjs";
import "../../../Chart/components/line/basic/index.mjs";
import "../../../Chart/components/line/bump/index.mjs";
import "../../../Chart/components/line/dashed/index.mjs";
import "../../../Chart/components/line/ladder/index.mjs";
import "../../../Chart/components/line/logarithm/index.mjs";
import "../../../Chart/components/line/multix/index.mjs";
import "../../../Chart/components/line/polar-double/index.mjs";
import "../../../Chart/components/line/rain-flow/index.mjs";
import "../../../Chart/components/line/scale/index.mjs";
import "../../../Chart/components/line/smooth/index.mjs";
import "../../../Chart/components/line/smooth-area/index.mjs";
import "../../../Chart/components/line/stack/index.mjs";
import "../../../Chart/components/line/stack-area/index.mjs";
import "../../../Chart/components/line/temp/index.mjs";
import "../../../Chart/components/line/vertical/index.mjs";
import "../../../Chart/components/map/basic/index.mjs";
import "../../../Chart/components/map/bmap-basic/index.mjs";
import "../../../Chart/components/map/bmap-heatmap/index.mjs";
import "../../../Chart/components/map/bmap-rich/index.mjs";
import "../../../Chart/components/map/customize/index.mjs";
import "../../../Chart/components/map/lines/index.mjs";
import "../../../Chart/components/map/scatter/index.mjs";
import "../../../Chart/components/pie/3d/index.mjs";
import "../../../Chart/components/pie/basic/index.mjs";
import "../../../Chart/components/pie/basic2/index.mjs";
import "../../../Chart/components/pie/customized/index.mjs";
import "../../../Chart/components/pie/index/index.mjs";
import "../../../Chart/components/pie/interval/index.mjs";
import "../../../Chart/components/pie/legend-scroll/index.mjs";
import "../../../Chart/components/pie/radius/index.mjs";
import "../../../Chart/components/pie/rose/index.mjs";
import "../../../Chart/components/pie/round/index.mjs";
import "../../../Chart/components/pie/sunburst/index.mjs";
import "../../../Chart/components/scatter/basic/index.mjs";
import "../../../Chart/components/scatter/basic2/index.mjs";
import "../../../Chart/components/scatter/bubble/index.mjs";
import "../../../Chart/components/scatter/ripples/index.mjs";
import "../../../Chart/components/other/candlestick-basic/index.mjs";
import "../../../Chart/components/other/sunburst-basic/index.mjs";
import "../../../Chart/components/other/sunburst-basic2/index.mjs";
import "../../../Chart/components/other/sunburst-basic3/index.mjs";
import "../../../Chart/components/other/sunburst-basic4/index.mjs";
import "../../../Chart/components/other/sunburst-book/index.mjs";
import "../../../Chart/components/other/sunburst-flavors/index.mjs";
import "../../../Chart/components/other/sunburst-radius/index.mjs";
import "../../../Chart/components/other/funnel/index.mjs";
import "../../../Chart/components/other/funnel-contrast/index.mjs";
import "../../../Chart/components/other/funnel-split/index.mjs";
import "../../../Chart/components/other/funnel2/index.mjs";
import "../../../Chart/components/other/force/index.mjs";
import "../../../Chart/components/other/force2/index.mjs";
import "../../../Chart/components/other/gauge/index.mjs";
import "../../../Chart/components/other/gauge-grade/index.mjs";
import "../../../Chart/components/other/gauge-stage/index.mjs";
import "../../../Chart/components/other/graph-basic/index.mjs";
import "../../../Chart/components/other/graph-basic2/index.mjs";
import "../../../Chart/components/other/graph-calendar/index.mjs";
import "../../../Chart/components/other/circular-graph/index.mjs";
import "../../../Chart/components/other/heatmap/index.mjs";
import "../../../Chart/components/other/liquidfill/index.mjs";
import "../../../Chart/components/other/parallel-basic/index.mjs";
import "../../../Chart/components/other/parallel-mul/index.mjs";
import "../../../Chart/components/other/radar-stack/index.mjs";
import "../../../Chart/components/other/tree/index.mjs";
import "../../../Chart/components/other/tree-line/index.mjs";
import "../../../Chart/components/other/word-cloud/index.mjs";
import "../../../Chart/components/other/treemap/index.mjs";
import "../../../Chart/components/other/treemap-basic/index.mjs";
import "../../../Chart/components/other/label-gauge/index.mjs";
import "../../../Chart/components/other/grid-percentage/index.mjs";
import "../../../Chart/components/other/radar/index.mjs";
import "../../../Commons/components/CustomComponentRender/index.mjs";
import "../../../Commons/components/Graphical/index.mjs";
import "../../../Commons/components/Svg/index.mjs";
import "../../../Commons/components/ModelViewer/index.mjs";
import "../../../Commons/components/VrVideo/index.mjs";
import "../../../Commons/components/VrPhoto/index.mjs";
import "../../../Commons/components/Babylon/index.mjs";
import "../../../Commons/components/Echarts/index.mjs";
import "../../../Commons/components/GSViewer/index.mjs";
import "../../../Scene/components/Amap2d/index.mjs";
import "../../../Scene/components/Amap3d/index.mjs";
import "../../../Scene/components/Default/index.mjs";
import "../../../Scene/components/Map2d/index.mjs";
import "../../../Scene/components/Map3d/index.mjs";
import "../../../Scene/components/UeIframe/index.mjs";
import "../../../Scene/components/UeShj/index.mjs";
import "../../../Scene/components/UnityIframe/index.mjs";
import "../../../Scene/components/UnityWebgl/index.mjs";
import "../../../Scene/components/Vr/index.mjs";
import "../../../Scene/components/Earth/index.mjs";
import { SHJDatasourceV2 as Q } from "../../../../commons/plugins/datasource/index.mjs";
import { SHJParseEvent as j } from "../../../../commons/plugins/event/index.mjs";
import { upgradeSelect as Z } from "./version.mjs";
import { useWatch as C } from "./hooks/useWatch.mjs";
import { Utils as i } from "../../../../commons/utils/utils.mjs";
const ee = { style: { display: "flex", "align-items": "center", gap: "4px" } }, te = {
  key: 1,
  class: "zerov-widget-select__prefix"
}, oe = ["src"], re = ["src"], ie = ["onClick"], pe = ["src"], ae = { class: "zerov-widget-select__option-label" }, me = z({ name: "ShjSelect" }), sr = /* @__PURE__ */ z({
  ...me,
  props: {
    option: {},
    sources: {},
    useEvents: {}
  },
  emits: ["update:modelValue", "on-change"],
  setup(u, { expose: E, emit: D }) {
    const o = k(() => Z(u.option)), d = v(), I = (e) => {
      if (d.value) {
        const t = v("");
        return e.boxShadow && (t.value = `${e.boxShadow.isInset ? "inset" : ""} ${e.boxShadow.offsetX}px ${e.boxShadow.offsetY}px ${e.boxShadow.blur}px ${e.boxShadow.diffus}px ${e.boxShadow.color}`), {
          ...i.json2cssObject(e),
          ...i.json2cssObject(e.hover, "hover"),
          ...i.json2cssObject(e.focus, "focus"),
          boxShadow: t.value,
          padding: `${e.padding.map((r) => `${r}px`).join(" ")}`,
          background: e.isBgImage ? `no-repeat center/100% url(${e.backgroundImage})` : e.backgroundColor
        };
      }
      return {};
    }, V = (e) => {
      if (d.value) {
        const t = `${e.boxShadow.isInset ? "inset" : ""} ${e.boxShadow.offsetX}px ${e.boxShadow.offsetY}px ${e.boxShadow.blur}px ${e.boxShadow.diffus}px ${e.boxShadow.color}`;
        return e.placement === "bottom" ? {
          ...i.json2cssObject(e),
          top: "100%",
          marginTop: "6px",
          boxShadow: t,
          padding: `${e.padding.map((r) => `${r}px`).join(" ")}`
        } : {
          ...i.json2cssObject(e),
          bottom: "100%",
          marginBottom: "6px",
          boxShadow: t,
          padding: `${e.padding.map((r) => `${r}px`).join(" ")}`
        };
      }
    }, B = (e) => {
      if (d.value)
        return {
          padding: `${e.padding.map((t) => `${t}px`).join(" ")}`,
          ...i.json2cssObject(e),
          ...i.json2cssObject(e.hover, "hover"),
          ...i.json2cssObject(e.active, "active")
        };
    }, L = (e) => {
      if (d.value)
        return {
          ...i.json2cssObject(e)
        };
    }, P = (e) => {
      if (d.value)
        return {
          ...i.json2cssObject(e),
          ...i.json2cssObject(e, "hover"),
          ...i.json2cssObject(e, "focus")
        };
    }, g = (e, t) => {
      const r = t.find((p) => p.type === e);
      return r ? r.url : "";
    }, T = (e, t) => {
      if (d.value) {
        const r = t.find((p) => p.type === e);
        if (r)
          return {
            ...i.json2cssObject(r)
          };
      }
    }, S = v(), a = v([]), h = () => {
      Q.parse({
        sources: u.sources,
        callback: (e) => {
          try {
            if (j.parseEvents(u.useEvents, "dataListener", a), S.value = O(), e && e.data ? a.value = K(e.data[0].data) : a.value = [], o.value.default.isDefaultSelect) {
              m.value = o.value.default.value, !m.value && a.value.length > 0 && (m.value = a.value[0].value);
              const t = a.value.find(
                (r) => r.value === m.value
              );
              b("update:modelValue", t.value), b("on-change", t), j.parseEvents(u.useEvents, "on-change", {
                data: t
              });
            } else
              m.value = "";
          } catch {
            j.parseEvents(u.useEvents, "dataListener", null), S.value = O(), a.value = [];
          }
        }
      });
    }, b = D, m = v(""), l = v(!1), _ = k(() => {
      const e = a.value.find(
        (t) => t.value === m.value
      );
      return e ? e.label : "";
    }), N = () => {
      l.value = !l.value;
    }, y = v(""), H = (e) => {
      m.value = e.value, y.value = e.type, b("update:modelValue", e.value), b("on-change", e), j.parseEvents(u.useEvents, "on-change", {
        data: e
      }), l.value = !1;
    }, J = () => {
      l.value = !1;
    };
    return M(() => {
      R(() => {
        h();
      });
    }), C({ option: o.value, sources: u.sources }, h), E({
      refresh: () => h(),
      refreshView: () => h(),
      refreshData: () => h()
    }), (e, t) => {
      const r = X("click-out-side");
      return Y((s(), n("div", {
        key: S.value,
        ref_key: "selectRef",
        ref: d,
        class: w(["zerov-widget-select", { "is-open": l.value }]),
        onClick: N
      }, [
        c("div", {
          class: w(["zerov-widget-select__trigger", { "is-active": l.value }]),
          style: f({
            ...I(o.value.input)
          })
        }, [
          c("div", ee, [
            _.value ? x("", !0) : (s(), n("span", {
              key: 0,
              class: "zerov-widget-select__placeholder",
              style: f({
                ...L(o.value.input.placeholder)
              })
            }, $(o.value.input.placeholder.value), 5)),
            _.value && g(y.value, o.value.dropdown.option.prefixs) ? (s(), n("span", te, [
              c("img", {
                src: g(y.value, o.value.dropdown.option.prefixs),
                alt: ""
              }, null, 8, oe)
            ])) : x("", !0),
            _.value ? (s(), n("span", {
              key: 2,
              class: "zerov-widget-select__selected",
              style: f({
                ...P(o.value.input.selected)
              })
            }, $(_.value), 5)) : x("", !0)
          ]),
          c("span", {
            class: w(["zerov-widget-select__arrow", { "is-open": l.value }])
          }, [
            c("img", {
              src: o.value.input.arrow.url,
              alt: ""
            }, null, 8, re)
          ], 2)
        ], 6),
        F(U, { name: "fade-in-linear" }, {
          default: W(() => [
            l.value ? (s(), n("div", {
              key: 0,
              class: "zerov-widget-select__dropdown",
              style: f({
                ...V(o.value.dropdown)
              })
            }, [
              c("ul", null, [
                (s(!0), n(q, null, A(a.value, (p) => (s(), n("li", {
                  key: p.value,
                  class: w([{ "is-selected": p.value === m.value }, "zerov-widget-select__option"]),
                  style: f({
                    ...B(o.value.dropdown.option)
                  }),
                  onClick: G((le) => H(p), ["stop"])
                }, [
                  g(p.type, o.value.dropdown.option.prefixs) ? (s(), n("span", {
                    key: 0,
                    class: "zerov-widget-select__option-prefix",
                    style: f({
                      ...T(
                        p.type,
                        o.value.dropdown.option.prefixs
                      )
                    })
                  }, [
                    c("img", {
                      src: g(p.type, o.value.dropdown.option.prefixs),
                      alt: ""
                    }, null, 8, pe)
                  ], 4)) : x("", !0),
                  c("span", ae, $(p.label), 1)
                ], 14, ie))), 128))
              ])
            ], 4)) : x("", !0)
          ]),
          _: 1
        })
      ], 2)), [
        [r, J]
      ]);
    };
  }
});
export {
  sr as default
};
