import { defineComponent, openBlock, createBlock, unref, ref, computed, watch, createElementBlock, normalizeClass, normalizeStyle, createCommentVNode, renderSlot, createElementVNode, withDirectives, createVNode, vShow, createTextVNode, toDisplayString, watchEffect, mergeProps, withCtx, Fragment, renderList, withModifiers, isRef } from "vue";
import WlSvg from "@wltech/svg";
import { Popup } from "vant";
const __default__$4 = {
  name: "WlSvgIcon"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  ...__default__$4,
  props: {
    type: { default: "" },
    color: { default: "var(--wl-text-color-title-1)" },
    width: { default: "16" },
    height: { default: "16" }
  },
  setup(__props) {
    const sub = location.origin;
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(WlSvg), {
        type: __props.type,
        width: __props.width,
        height: __props.height,
        color: __props.color,
        sub: unref(sub)
      }, null, 8, ["type", "width", "height", "color", "sub"]);
    };
  }
});
const domain = "https://wlmvp-cos.weiling.cn";
const loadingPic = domain + "/frontend/weilingMobileUI/loading.png";
const loadingFailPic = domain + "/frontend/weilingMobileUI/loadingFail.png";
const en_default_logo = domain + "/frontend/images/company-default-logo.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$3 = ["src", "alt"];
const _hoisted_2$3 = ["src"];
const _hoisted_3$2 = ["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__$3 = {
  name: "WlPic"
};
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  ...__default__$3,
  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$3)) : 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$3)) : 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$2)) : createCommentVNode("", true),
        renderSlot(_ctx.$slots, "picFooter")
      ], 2);
    };
  }
});
const _hoisted_1$2 = { class: "z-2 flex uno-min-w-44 uno-max-w-88" };
const _hoisted_2$2 = { class: "uno-elli-1 z-1 box-border flex-middle-center absolute text-center uno-l-44 uno-r-44" };
const _hoisted_3$1 = { class: "relative z-2 flex-middle-center uno-min-w-44" };
const __default__$2 = {
  name: "WlHeader"
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  ...__default__$2,
  props: {
    title: { default: "" },
    showBack: { type: Boolean, default: false },
    showClose: { type: Boolean, default: false },
    needAutoBack: { type: Boolean, default: true },
    needBottomBorder: { type: Boolean, default: false }
  },
  emits: ["onBack", "onClose"],
  setup(__props, { emit }) {
    const props = __props;
    const onBackPage = () => {
      if (props.needAutoBack) {
        history.back();
      } else {
        emit("onBack");
      }
    };
    const onClose = () => {
      emit("onClose");
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass(`uno-fs-16 uno-h-44 relative font-medium box-border text-base-color bg-white flex-between ${__props.needBottomBorder ? "border-bottom" : " "}`)
      }, [
        createElementVNode("div", _hoisted_1$2, [
          renderSlot(_ctx.$slots, "header_part_left", {}, () => [
            withDirectives(createElementVNode("div", {
              class: "box-content flex-middle-center cursor-pointer uno-h-44 uno-w-44",
              onClick: onBackPage
            }, [
              createVNode(_sfc_main$4, {
                type: "arrowTipLeft",
                width: "22",
                height: "22",
                color: "#000"
              })
            ], 512), [
              [vShow, __props.showBack]
            ])
          ])
        ]),
        createElementVNode("div", _hoisted_2$2, [
          renderSlot(_ctx.$slots, "default", {}, () => [
            createTextVNode(toDisplayString(__props.title), 1)
          ])
        ]),
        createElementVNode("div", _hoisted_3$1, [
          renderSlot(_ctx.$slots, "header_part_right", {}, () => [
            withDirectives(createElementVNode("div", {
              class: "box-content flex-middle-center cursor-pointer uno-h-44 uno-w-44",
              onClick: onClose
            }, [
              createVNode(_sfc_main$4, {
                type: "close",
                width: "22",
                height: "22",
                color: "#000"
              })
            ], 512), [
              [vShow, __props.showClose]
            ])
          ])
        ])
      ], 2);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$1 = "";
const _hoisted_1$1 = {
  class: "popup-wrap",
  "data-weiling-mobile-ui-wl-popup": ""
};
const _hoisted_2$1 = { class: "popup-content" };
const __default__$1 = {
  name: "WlPopup"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    modelValue: { type: Boolean, default: false },
    teleport: { default: "body" },
    position: { default: "bottom" },
    headerVisible: { type: Boolean, default: false },
    title: { default: "" },
    showRightClose: { type: Boolean, default: true },
    showBack: { type: Boolean, default: false },
    needAutoBack: { type: Boolean, default: true }
  },
  emits: ["update:modelValue", "onClose", "onBack"],
  setup(__props, { emit }) {
    const props = __props;
    const popUpVisible = ref(false);
    const popupStyle = computed(() => {
      return {
        height: "70%"
      };
    });
    const onClose = () => {
      emit("update:modelValue", false);
      emit("onClose");
    };
    const onOpen = () => {
      emit("update:modelValue", true);
    };
    const onBack = () => {
      emit("onBack");
    };
    watchEffect(() => {
      popUpVisible.value = props.modelValue;
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(unref(Popup), mergeProps({
        show: popUpVisible.value,
        "onUpdate:show": _cache[0] || (_cache[0] = ($event) => popUpVisible.value = $event),
        teleport: __props.teleport,
        position: __props.position,
        "close-on-popstate": true,
        style: unref(popupStyle)
      }, _ctx.$attrs, {
        onClose,
        onOpen
      }), {
        default: withCtx(() => [
          createElementVNode("div", _hoisted_1$1, [
            __props.headerVisible ? (openBlock(), createBlock(_sfc_main$2, {
              key: 0,
              title: __props.title,
              showClose: __props.showRightClose,
              onOnClose: onClose,
              onOnBack: onBack,
              showBack: __props.showBack,
              needAutoBack: __props.needAutoBack
            }, {
              header_part_left: withCtx(() => [
                renderSlot(_ctx.$slots, "header_part_left")
              ]),
              _: 3
            }, 8, ["title", "showClose", "showBack", "needAutoBack"])) : createCommentVNode("", true),
            createElementVNode("div", _hoisted_2$1, [
              renderSlot(_ctx.$slots, "default")
            ])
          ])
        ]),
        _: 3
      }, 16, ["show", "teleport", "position", "style"]);
    };
  }
});
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = {
  class: "enterprise-list",
  "data-weiling-mobile-ui-bc-enterprise-list": ""
};
const _hoisted_2 = ["onClick"];
const _hoisted_3 = { class: "avatar" };
const _hoisted_4 = { class: "item-name" };
const _hoisted_5 = ["onClick"];
const _hoisted_6 = { class: "retract-avatars" };
const _hoisted_7 = { class: "retract-text-wrap" };
const _hoisted_8 = { class: "retract-text name" };
const _hoisted_9 = { class: "retract-text" };
const _hoisted_10 = {
  class: "enterprise-popup",
  "data-weiling-mobile-ui-bc-enterprise-list-enterprise-popup": ""
};
const _hoisted_11 = { class: "content" };
const _hoisted_12 = ["onClick"];
const _hoisted_13 = { class: "avatar" };
const _hoisted_14 = { class: "item-name" };
const __default__ = {
  name: "BCEnterpriseList"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    data: { default: () => [] },
    retract: { default: 2 },
    defaultAvatar: { default: en_default_logo }
  },
  emits: ["onClickEnterprise", "onClickRetract"],
  setup(__props, { emit }) {
    const props = __props;
    let popupVisible = ref(false);
    const retractImgs = computed(() => {
      const temp_arr = props.data.slice(0, props.retract + 1);
      return temp_arr.reduce((acc, item) => {
        if (props.retract < props.data.length) {
          acc.push(item["image_url"]);
        }
        return acc;
      }, []);
    });
    const onClickEnterprise = (item) => {
      emit("onClickEnterprise", item);
    };
    const onClickRetract = () => {
      popupVisible.value = true;
      emit("onClickRetract", true);
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1, [
        __props.data.length <= __props.retract ? (openBlock(true), createElementBlock(Fragment, { key: 0 }, renderList(__props.data, (item) => {
          return openBlock(), createElementBlock("div", {
            class: "enterprise-item",
            key: item.company_id,
            onClick: withModifiers(($event) => onClickEnterprise(item), ["stop"])
          }, [
            createElementVNode("p", _hoisted_3, [
              createVNode(_sfc_main$3, {
                src: item.image_url || __props.defaultAvatar
              }, null, 8, ["src"])
            ]),
            createElementVNode("p", _hoisted_4, toDisplayString(item.company_name), 1)
          ], 8, _hoisted_2);
        }), 128)) : (openBlock(), createElementBlock("div", {
          key: 1,
          class: "retract-enterprise",
          onClick: withModifiers(onClickRetract, ["stop"])
        }, [
          createElementVNode("div", _hoisted_6, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(unref(retractImgs), (item, index) => {
              return openBlock(), createElementBlock("p", {
                class: "avatar",
                key: index
              }, [
                createVNode(_sfc_main$3, {
                  src: item || __props.defaultAvatar
                }, null, 8, ["src"])
              ]);
            }), 128))
          ]),
          createElementVNode("div", _hoisted_7, [
            createElementVNode("p", _hoisted_8, toDisplayString(__props.data[0].company_name), 1),
            createElementVNode("p", _hoisted_9, "\u5171" + toDisplayString(__props.data.length) + "\u5BB6", 1)
          ])
        ], 8, _hoisted_5)),
        createVNode(_sfc_main$1, {
          modelValue: unref(popupVisible),
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(popupVisible) ? popupVisible.value = $event : popupVisible = $event),
          position: "bottom",
          style: { height: "300px" },
          round: "",
          title: "\u4F01\u4E1A",
          headerVisible: true
        }, {
          default: withCtx(() => [
            createElementVNode("div", _hoisted_10, [
              createElementVNode("div", _hoisted_11, [
                (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data, (item) => {
                  return openBlock(), createElementBlock("div", {
                    class: "enterprise-popup-item",
                    key: item.company_id,
                    onClick: withModifiers(($event) => onClickEnterprise(item), ["stop"])
                  }, [
                    createElementVNode("p", _hoisted_13, [
                      createVNode(_sfc_main$3, {
                        src: item.image_url || __props.defaultAvatar
                      }, null, 8, ["src"])
                    ]),
                    createElementVNode("p", _hoisted_14, toDisplayString(item.company_name), 1),
                    createVNode(_sfc_main$4, {
                      type: "arrowRight",
                      width: "16",
                      height: "16",
                      color: "var(--wl-text-color-secondary-2)"
                    })
                  ], 8, _hoisted_12);
                }), 128))
              ])
            ])
          ]),
          _: 1
        }, 8, ["modelValue"])
      ]);
    };
  }
});
var __uno = "";
_sfc_main.install = (app) => {
  app.component(_sfc_main.name, _sfc_main);
};
export { _sfc_main as default };
