import { defineComponent as f, computed as $, ref as d, onMounted as I, onBeforeUnmount as B, createElementBlock as y, openBlock as n, createCommentVNode as u, createBlock as h, normalizeStyle as T } from "vue";
import U from "axios";
import v from "../../../../commons/components/Text.vue.mjs";
/* empty css                                     */
/* empty css                                     */
import "../../../Interaction/components/Tabs/index.mjs";
import "../../../Interaction/components/Tabs-icon/index.mjs";
import "../../../Interaction/components/Button/index.mjs";
import "../../../Interaction/components/DatePicker/index.mjs";
import "../../../Interaction/components/DatePickerRange/index.mjs";
import "../../../Interaction/components/Switch/index.mjs";
import "../../../Interaction/components/Input/index.mjs";
import "../../../Interaction/components/Select/index.mjs";
import "../../../Interaction/components/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 "../Audio/index.mjs";
import "../Video/index.mjs";
import "../Carousel/index.mjs";
import "../Flv/index.mjs";
import "../Iframe/index.mjs";
import "../IframeCarousel/index.mjs";
import "../Image/index.mjs";
import "../ImageDynamic/index.mjs";
import "../M3u8/index.mjs";
import "../Wavesurfer/index.mjs";
import "./index.mjs";
import "../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 W } from "../../../../commons/plugins/datasource/index.mjs";
import { SHJParseEvent as l } from "../../../../commons/plugins/event/index.mjs";
import "lodash";
import { upgradeWeather as b } from "./version.mjs";
import { nextTick as z } from "process";
import { useWatch as R } from "./hooks/useWatch.mjs";
const V = f({ name: "ShjWeather" }), Dr = /* @__PURE__ */ f({
  ...V,
  props: {
    option: {},
    sources: {},
    useEvents: {}
  },
  emits: ["on-success", "on-error"],
  setup(o, { expose: w, emit: x }) {
    const t = $(() => b(o.option)), s = x, k = d(), e = d({
      city: "",
      date: "",
      week: "",
      dayweather: "",
      nightweather: "",
      daytemp: "",
      nighttemp: "",
      daywind: "",
      nightwind: "",
      daypower: "",
      nightpower: "",
      daytemp_float: "",
      nighttemp_float: ""
    }), p = d(null), m = () => {
      W.parse({
        sources: o.sources,
        callback: ({ data: i }) => {
          try {
            l.parseEvents(o.useEvents, "dataListener", i);
            const a = i[0].data[0];
            U.get(
              `https://restapi.amap.com/v3/weather/weatherInfo?city=${a.adcode}&key=${a.key}&extensions=all`
            ).then((r) => {
              r.status === 200 && r.data.status === "1" && r.data.forecasts.length > 0 ? (s("on-success", r), l.parseEvents(o.useEvents, "on-success", r), e.value = r.data.forecasts[0].casts[0], e.value.city = r.data.forecasts[0].city) : (s("on-error", r), l.parseEvents(o.useEvents, "on-error", r));
            }).catch(() => {
              s("on-error", null), l.parseEvents(o.useEvents, "on-error", null);
            });
          } catch {
            l.parseEvents(o.useEvents, "dataListener", null), s("on-error", null), l.parseEvents(o.useEvents, "on-error", null);
          }
        }
      });
    }, S = (i, a) => {
      if (a.find((c) => c.name === e.value.dayweather)) {
        const c = a.find((E) => E.name === e.value.dayweather).url || "";
        return {
          mask: `url(${c}) 0px 0px / 100% 100%`,
          width: `${i.size}px`,
          height: `${i.size}px`,
          background: `url(${c}) 0px 0px / 100% 100%, ${i.color}`,
          backgroundBlendMode: "overlay",
          marginRight: `${i.margin.right}px`
        };
      }
      return {};
    }, g = () => {
      p.value && clearInterval(p.value), t.value.autoUpdate !== 0 ? p.value = setInterval(() => m(), t.value.autoUpdate * 1e3) : (clearInterval(p.value), m());
    };
    return I(() => {
      z(() => {
        m(), g();
      });
    }), B(() => {
      p.value && clearInterval(p.value);
    }), R({ option: t.value, sources: o.sources }, m), w({
      refresh: () => m(),
      refreshView: () => m(),
      refreshData: () => m()
    }), (i, a) => (n(), y("div", {
      ref_key: "weatherRef",
      ref: k,
      class: "weather"
    }, [
      t.value.icon.show ? (n(), y("p", {
        key: 0,
        class: "weather-icon",
        style: T(S(t.value.icon, t.value.icons))
      }, null, 4)) : u("", !0),
      t.value.weather.city.show ? (n(), h(v, {
        key: 1,
        text: e.value.city,
        textStyle: t.value.weather.city.textStyle
      }, null, 8, ["text", "textStyle"])) : u("", !0),
      t.value.weather.type.show ? (n(), h(v, {
        key: 2,
        text: e.value.dayweather,
        textStyle: t.value.weather.type.textStyle
      }, null, 8, ["text", "textStyle"])) : u("", !0),
      t.value.weather.wind.show ? (n(), h(v, {
        key: 3,
        text: `${e.value.daywind}风${e.value.daypower}级`,
        textStyle: t.value.weather.wind.textStyle
      }, null, 8, ["text", "textStyle"])) : u("", !0),
      t.value.weather.temperature.show ? (n(), h(v, {
        key: 4,
        text: `${e.value.nighttemp} ${t.value.weather.temperature.connectors} ${e.value.daytemp} ${t.value.weather.temperature.suffix.show ? t.value.weather.temperature.suffix.suffix : ""}`,
        textStyle: t.value.weather.temperature.textStyle
      }, null, 8, ["text", "textStyle"])) : u("", !0)
    ], 512));
  }
});
export {
  Dr as default
};
