import { defineComponent, ref, computed, onMounted, openBlock, createElementBlock, createVNode, unref, withCtx, createElementVNode, toDisplayString, createCommentVNode, createBlock, createTextVNode } from 'vue';
import { ElInput } from 'element-plus';
import { MeSvgIcon } from '../../svg-icon/index.mjs';
import { MeButton } from '../../button/index.mjs';
import { MeDialog } from '../../dialog/index.mjs';
import './map.vue.mjs';
import script$1 from './map.vue2.mjs';

"use strict";
const _hoisted_1 = { class: "me-input-gps" };
const _hoisted_2 = {
  key: 0,
  style: { "color": "#999" }
};
const __default__ = defineComponent({
  name: "me-input-gps"
});
var script = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    latitude: { type: Number, required: true },
    longitude: { type: Number, required: true },
    address: { type: String, required: true },
    mapKey: { type: String, required: true }
  },
  emits: ["confirmEvent"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const coord = ref({});
    const visible = ref(false);
    const inputValue = computed(() => {
      if (!coord.value.latitude) return "";
      return `\u7ECF\u5EA6\uFF1A${coord.value.longitude}\uFF0C\u7EAC\u5EA6\uFF1A${coord.value.latitude}`;
    });
    const handleOpenMap = () => {
      visible.value = true;
    };
    const confirm = () => {
      const data = {
        latitude: coord.value.latitude,
        longitude: coord.value.longitude,
        address: coord.value.address
      };
      emit("confirmEvent", data);
      visible.value = false;
    };
    onMounted(() => {
      coord.value.latitude = props.latitude;
      coord.value.longitude = props.longitude;
    });
    const isFullscreen = ref(false);
    const handleFullscreenChange = (val) => {
      isFullscreen.value = val;
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createVNode(unref(ElInput), {
          style: { "cursor": "pointer" },
          value: inputValue.value,
          "read-only": ""
        }, {
          suffix: withCtx(() => [
            createElementVNode("div", {
              style: { "cursor": "pointer", "height": "100%" },
              onClick: handleOpenMap
            }, [
              createVNode(unref(MeSvgIcon), { name: "ri-map-pin-line" })
            ])
          ]),
          _: 1
          /* STABLE */
        }, 8, ["value"]),
        coord.value?.address ? (openBlock(), createElementBlock(
          "div",
          _hoisted_2,
          "\u4F4D\u7F6E\uFF1A" + toDisplayString(coord.value.address),
          1
          /* TEXT */
        )) : createCommentVNode("v-if", true),
        createVNode(unref(MeDialog), {
          modelValue: visible.value,
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => visible.value = $event),
          title: "\u9009\u62E9\u4F4D\u7F6E"
        }, {
          "me-dialog-footer-right": withCtx(() => [
            createVNode(unref(MeButton), { onClick: confirm }, {
              default: withCtx(() => [..._cache[2] || (_cache[2] = [
                createTextVNode(
                  "\u786E\u5B9A",
                  -1
                  /* CACHED */
                )
              ])]),
              _: 1
              /* STABLE */
            })
          ]),
          default: withCtx(() => [
            __props.mapKey ? (openBlock(), createBlock(script$1, {
              key: 0,
              isFullscreen: isFullscreen.value,
              modelValue: coord.value,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => coord.value = $event),
              "map-key": __props.mapKey
            }, null, 8, ["isFullscreen", "modelValue", "map-key"])) : createCommentVNode("v-if", true)
          ]),
          _: 1
          /* STABLE */
        }, 8, ["modelValue"])
      ]);
    };
  }
});

export { script as default };
//# sourceMappingURL=input-gps.vue2.mjs.map
