import { defineComponent, ref, computed, watch, openBlock, createElementBlock, normalizeClass, unref, normalizeStyle, createCommentVNode, renderSlot, createElementVNode, createVNode, withModifiers, toDisplayString, createBlock, mergeProps, useAttrs, resolveDynamicComponent } from "vue";
const domain = "https://wlmvp-cos.weiling.cn";
const loadingPic = domain + "/frontend/weilingMobileUI/loading.png";
const loadingFailPic = domain + "/frontend/weilingMobileUI/loadingFail.png";
const loadImage = (url) => {
  return new Promise((resolve, reject) => {
    const newImg = new Image();
    newImg.src = url;
    newImg.onerror = () => {
      reject("failure");
    };
    newImg.onload = (e) => {
      resolve(e.target);
    };
  });
};
const isTencentCosPic = (url) => {
  return url.includes("wlmvp-cos.weiling.cn");
};
const isBase64 = (str) => {
  return str.indexOf("data:") != -1 && str.indexOf("base64") != -1;
};
const _hoisted_1$6 = ["src", "alt"];
const _hoisted_2$4 = ["src"];
const _hoisted_3$1 = ["src"];
var ECosType = /* @__PURE__ */ ((ECosType2) => {
  ECosType2["normal"] = "imageView2/1/q/85";
  ECosType2["thumbnail"] = "imageView2/1/w/100/h/100/q/85";
  return ECosType2;
})(ECosType || {});
const __default__$7 = {
  name: "WlPic"
};
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
  ...__default__$7,
  props: {
    src: { default: "" },
    needCos: { type: Boolean, default: true },
    cosType: { default: "normal" },
    radius: { type: Boolean, default: false },
    round: { type: Boolean, default: false },
    needLoading: { type: Boolean, default: true },
    needMiddleCenter: { type: Boolean, default: true },
    needHeightAuto: { type: Boolean, default: false },
    fit: { default: "fill" }
  },
  setup(__props, { expose }) {
    const props = __props;
    const isLoading = ref(true);
    const isError = ref(false);
    const imgSrc = ref("");
    const imgWrapRef = ref("");
    const imgStyleComputed = computed(() => {
      return {
        "border-radius": props.round ? "50%" : "",
        "object-fit": props.fit
      };
    });
    const imgWrapClassComputed = computed(() => {
      return [
        "wl-img",
        "wh-full",
        "relative",
        "flex-col",
        props.needMiddleCenter ? "flex-middle-center" : ""
      ];
    });
    const onLoadImage = (url) => {
      return new Promise((resolve, reject) => {
        loadImage(url).then((elem) => {
          resolve(elem);
        }).catch((reason) => {
          reject(reason);
        }).finally(() => {
          isLoading.value = false;
        });
      });
    };
    const setImgSrc = (url) => {
      const needCos = isTencentCosPic(url) && props.needCos;
      const file_type = url.split(".").pop();
      let isSvg = file_type === "svg";
      let isBase64Bool = isBase64(url);
      if (isSvg || !needCos || isBase64Bool) {
        imgSrc.value = url;
        onLoadImage(imgSrc.value).catch(() => {
          isError.value = true;
        });
      } else {
        imgSrc.value = `${url}?${ECosType[props.cosType]}`;
        onLoadImage(imgSrc.value).catch(() => {
          imgSrc.value = url;
        });
      }
    };
    watch(
      () => props.src,
      (val) => {
        if (val) {
          isLoading.value = true;
          setImgSrc(props.src);
        }
      },
      { immediate: true }
    );
    expose({
      imgWrapRef
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(unref(imgWrapClassComputed)),
        ref_key: "imgWrapRef",
        ref: imgWrapRef
      }, [
        !isLoading.value && !isError.value ? (openBlock(), createElementBlock("img", {
          key: 0,
          src: imgSrc.value,
          style: normalizeStyle(unref(imgStyleComputed)),
          class: normalizeClass(`w-full block ${__props.needHeightAuto ? "h-auto" : "h-full"}`),
          alt: imgSrc.value
        }, null, 14, _hoisted_1$6)) : createCommentVNode("", true),
        isLoading.value && __props.needLoading ? (openBlock(), createElementBlock("img", {
          key: 1,
          src: unref(loadingPic),
          alt: "loading",
          class: "w-1/5 uno-min-w-20 uno-min-h-20 uno-max-w-60 uno-max-h-60 absolute-middle-center animate-spin"
        }, null, 8, _hoisted_2$4)) : createCommentVNode("", true),
        isError.value ? (openBlock(), createElementBlock("img", {
          key: 2,
          src: unref(loadingFailPic),
          alt: "failure",
          class: "w-1/5 uno-min-w-20 uno-min-h-20 uno-max-w-60 uno-max-h-60 absolute-middle-center"
        }, null, 8, _hoisted_3$1)) : createCommentVNode("", true),
        renderSlot(_ctx.$slots, "picFooter")
      ], 2);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$3 = "";
const __default__$6 = {
  name: "CircularCode"
};
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
  ...__default__$6,
  props: {
    themeColor: { default: "var(--wl-primary-color)" },
    styleExtra: { default: null },
    icon: { default: "icon-mobile-ui-erweima" }
  },
  setup(__props) {
    const defaultUrl = ref(
      "https://wlmvp-cos.weiling.cn/1356898121111711744/1656579209wp77ce6.svg"
    );
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: "circular-code-conatiner",
        style: normalizeStyle(__props.styleExtra)
      }, [
        createElementVNode("div", null, [
          createVNode(_sfc_main$7, { src: defaultUrl.value }, null, 8, ["src"])
        ])
      ], 4);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$2 = "";
const _hoisted_1$5 = ["onClick"];
const _hoisted_2$3 = { class: "fixed-dialog-content" };
const __default__$5 = {
  name: "FixedDialog"
};
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
  ...__default__$5,
  props: {
    styleExtra: { default: () => {
      return {};
    } },
    imgUrl: { default: "" },
    title: { default: "" },
    titleStyle: { default: () => {
      return {};
    } },
    subtitle: { default: "" },
    subtitleStyle: { default: () => {
      return {};
    } },
    needCos: { type: Boolean, default: true },
    cosSuffix: { default: "imageView2/1/w/100/h/100/q/85" },
    picExtraStyle: { default: () => {
      return {};
    } },
    fixedSize: { default: "static" }
  },
  emits: ["onClickImg"],
  setup(__props, { emit }) {
    const props = __props;
    const onClickImg = () => {
      emit("onClickImg", {
        title: props.title,
        subtitle: props.subtitle,
        url: props.imgUrl
      });
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: "fixed-dialog",
        style: normalizeStyle(__props.styleExtra)
      }, [
        createElementVNode("div", {
          class: normalizeClass(["fixed-dialog-img", `${__props.fixedSize === "small" ? "fixed-dialog-img-small" : ""}`]),
          onClick: withModifiers(onClickImg, ["stop"]),
          style: normalizeStyle(__props.picExtraStyle)
        }, [
          createVNode(_sfc_main$7, {
            src: __props.imgUrl,
            needCos: __props.needCos,
            cosSuffix: __props.cosSuffix
          }, null, 8, ["src", "needCos", "cosSuffix"])
        ], 14, _hoisted_1$5),
        createElementVNode("div", _hoisted_2$3, [
          createElementVNode("span", {
            class: "fixed-dialog-content-title",
            style: normalizeStyle(__props.titleStyle)
          }, toDisplayString(__props.title), 5),
          createElementVNode("span", {
            class: "fixed-dialog-content-subtitle",
            style: normalizeStyle(__props.subtitleStyle)
          }, toDisplayString(__props.subtitle), 5)
        ]),
        renderSlot(_ctx.$slots, "default")
      ], 4);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$1 = "";
const _hoisted_1$4 = ["onClick"];
const _hoisted_2$2 = { class: "suspension-content" };
const __default__$4 = {
  name: "SuspensionDialog"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  ...__default__$4,
  props: {
    styleExtra: { default: null },
    imgUrl: { default: "url" },
    title: { default: "title" },
    titleStyle: { default: null },
    subtitle: { default: "subtitle" },
    subtitleStyle: { default: null },
    closeIcon: { default: "icon-mobile-ui-cuowu" },
    closeIconShow: { type: Boolean, default: true },
    suspensionSize: { default: "static" },
    needCos: { type: Boolean, default: true },
    cosSuffix: { default: "imageView2/1/w/100/h/100/q/85" }
  },
  emits: ["onClickIcon"],
  setup(__props, { emit }) {
    const onClickIcon = () => {
      emit("onClickIcon");
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(["suspension", __props.suspensionSize === "small" ? "suspension-small" : ""])
      }, [
        __props.closeIconShow ? (openBlock(), createElementBlock("i", {
          key: 0,
          class: normalizeClass(["iconfont icon-mobile-ui-guanbi suspension-close-icon", __props.closeIcon]),
          onClick: withModifiers(onClickIcon, ["stop"])
        }, null, 10, _hoisted_1$4)) : createCommentVNode("", true),
        createVNode(_sfc_main$7, { src: __props.imgUrl }, null, 8, ["src"]),
        createElementVNode("div", _hoisted_2$2, [
          createElementVNode("span", {
            class: "suspension-content-title",
            style: normalizeStyle(__props.titleStyle)
          }, toDisplayString(__props.title), 5),
          createElementVNode("span", {
            class: "suspension-content-subtitle",
            style: normalizeStyle(__props.subtitleStyle)
          }, toDisplayString(__props.subtitle), 5)
        ]),
        renderSlot(_ctx.$slots, "default")
      ], 2);
    };
  }
});
const _hoisted_1$3 = { style: { "height": "100%" } };
const __default__$3 = {
  name: "CodeDialog"
};
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  ...__default__$3,
  props: {
    position: { default: "suspension" },
    imgUrl: { default: "" },
    title: { default: "" },
    subtitle: { default: "" }
  },
  emits: ["onClickImg", "onClickIcon"],
  setup(__props, { emit }) {
    const props = __props;
    const onClickImg = () => {
      emit("onClickImg", {
        title: props.title,
        subtitle: props.subtitle,
        url: props.imgUrl
      });
    };
    const onClickIcon = () => {
      emit("onClickIcon", {
        title: props.title,
        subtitle: props.subtitle,
        url: props.imgUrl
      });
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1$3, [
        __props.position === "fixed" ? (openBlock(), createBlock(_sfc_main$5, mergeProps({
          key: 0,
          imgUrl: __props.imgUrl,
          title: __props.title,
          subtitle: __props.subtitle
        }, _ctx.$attrs, { onOnClickImg: onClickImg }), null, 16, ["imgUrl", "title", "subtitle"])) : (openBlock(), createBlock(_sfc_main$4, mergeProps({ key: 1 }, _ctx.$attrs, {
          imgUrl: __props.imgUrl,
          title: __props.title,
          subtitle: __props.subtitle,
          onOnClickIcon: onClickIcon,
          onOnClickImg: onClickImg
        }), null, 16, ["imgUrl", "title", "subtitle"]))
      ]);
    };
  }
});
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1$2 = ["onClick"];
const _hoisted_2$1 = { class: "text" };
const __default__$2 = {
  name: "AvatarCode"
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  ...__default__$2,
  props: {
    themeColor: { default: "var(--wl-primary-color)" },
    styleExtra: { default: null },
    text: { default: "" },
    isShowText: { type: Boolean, default: true },
    imgUrl: { default: "https://wlmvp-cos.weiling.cn/frontend/xiaowei.jpg" },
    needCos: { type: Boolean, default: true }
  },
  emits: ["onClickImg"],
  setup(__props, { emit }) {
    const props = __props;
    const onClickImg = () => {
      emit("onClickImg", {
        text: props.text,
        url: props.imgUrl
      });
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: "avatar-code",
        style: normalizeStyle(__props.styleExtra)
      }, [
        createElementVNode("div", {
          class: "avatar-code-avatar",
          style: normalizeStyle(`border-color: ${__props.themeColor};background-color: ${__props.themeColor}`),
          onClick: withModifiers(onClickImg, ["stop"])
        }, [
          createVNode(_sfc_main$7, {
            radius: "",
            src: __props.imgUrl,
            needCos: __props.needCos,
            cosType: "thumbnail"
          }, null, 8, ["src", "needCos"])
        ], 12, _hoisted_1$2),
        __props.isShowText ? (openBlock(), createElementBlock("div", {
          key: 0,
          class: "avatar-code-text",
          style: normalizeStyle({ backgroundColor: `${__props.themeColor}` })
        }, [
          createElementVNode("div", _hoisted_2$1, toDisplayString(__props.text), 1)
        ], 4)) : createCommentVNode("", true)
      ], 4);
    };
  }
});
var index_vue_vue_type_style_index_0_scoped_true_lang = "";
var _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const _hoisted_1$1 = ["onClick"];
const _hoisted_2 = { class: "message-content" };
const _hoisted_3 = {
  key: 0,
  class: "message-content-subtitle"
};
const _hoisted_4 = ["onClick"];
const __default__$1 = {
  name: "MessageCode"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    imgUrl: { default: "" },
    styleExtra: { default: null },
    isShowSubtitle: { type: Boolean, default: true },
    theme: { default: "dark" },
    titleColor: { default: "" },
    arrowColor: { default: "" },
    icon: { default: "icon-mobile-ui-you" },
    title: { default: "" },
    subtitle: { default: "" },
    needCos: { type: Boolean, default: true }
  },
  emits: ["onClickImg", "onClickIcon"],
  setup(__props, { emit }) {
    const props = __props;
    const containerStyle = computed(() => {
      if (props.theme === "light") {
        return {
          "background-color": "#FFFFFF",
          border: "0.5px solid #EEEEEE;"
        };
      } else {
        return {
          "background-color": "#1C1C1C"
        };
      }
    });
    const titleStyle = computed(() => {
      if (props.arrowColor) {
        return {
          color: props.arrowColor
        };
      } else if (props.theme === "light") {
        return {
          color: "#000000"
        };
      } else {
        return {
          color: "#FFFFFF"
        };
      }
    });
    const onClickImg = () => {
      emit("onClickImg", {
        title: props.title,
        subtitle: props.subtitle,
        url: props.imgUrl
      });
    };
    const onClickIcon = () => {
      emit("onClickIcon", {
        title: props.title,
        subtitle: props.subtitle,
        url: props.imgUrl
      });
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: "message",
        style: normalizeStyle([unref(containerStyle), __props.styleExtra])
      }, [
        createElementVNode("div", {
          class: "message-avatar",
          onClick: withModifiers(onClickImg, ["stop"])
        }, [
          createVNode(_sfc_main$7, {
            src: __props.imgUrl,
            needCos: __props.needCos,
            cosType: "thumbnail"
          }, null, 8, ["src", "needCos"])
        ], 8, _hoisted_1$1),
        createElementVNode("div", _hoisted_2, [
          createElementVNode("span", {
            style: normalizeStyle(unref(titleStyle)),
            class: "message-content-title"
          }, toDisplayString(__props.title), 5),
          __props.isShowSubtitle ? (openBlock(), createElementBlock("span", _hoisted_3, toDisplayString(__props.subtitle), 1)) : createCommentVNode("", true)
        ]),
        createElementVNode("i", {
          class: normalizeClass(["iconfont message-icon", __props.icon]),
          onClick: withModifiers(onClickIcon, ["stop"])
        }, null, 10, _hoisted_4),
        renderSlot(_ctx.$slots, "default", {}, void 0, true)
      ], 4);
    };
  }
});
var MessageCode = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__scopeId", "data-v-58948f16"]]);
const _hoisted_1 = ["onClick"];
const __default__ = {
  name: "BCSuspensionCode"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    type: { default: "circular" }
  },
  emits: ["onClick"],
  setup(__props, { emit }) {
    const props = __props;
    const attrs = useAttrs();
    const componentType = computed(() => {
      if (props.type === "circular")
        return _sfc_main$6;
      else if (props.type === "avtatar")
        return _sfc_main$2;
      else if (props.type === "msg")
        return MessageCode;
      else if (props.type === "static")
        return _sfc_main$3;
      else
        return {};
    });
    const onEmitClick = (data) => {
      emit("onClick", data);
    };
    const onClickImg = (data) => {
      onEmitClick({
        type: "img",
        data
      });
    };
    const onClickIcon = (data) => {
      onEmitClick({
        type: "icon",
        data
      });
    };
    const onClickCode = () => {
      onEmitClick({
        type: "card",
        data: attrs
      });
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: "suspension-code",
        "data-weiling-mobile-ui-bc-suspension-code": "",
        onClick: withModifiers(onClickCode, ["stop"])
      }, [
        (openBlock(), createBlock(resolveDynamicComponent(unref(componentType)), mergeProps(_ctx.$attrs, {
          onOnClickImg: onClickImg,
          onOnClickIcon: onClickIcon
        }), null, 16))
      ], 8, _hoisted_1);
    };
  }
});
var __uno = "";
_sfc_main.install = (app) => {
  app.component(_sfc_main.name, _sfc_main);
};
export { _sfc_main as default };
