import { defineComponent, useCssVars, ref, watchEffect, openBlock, createElementBlock, withDirectives, createElementVNode, vModelText, toDisplayString, createCommentVNode, createBlock, withModifiers, computed, normalizeClass, unref, normalizeStyle, createTextVNode, renderSlot, watch, Fragment, renderList, createVNode, withCtx, vShow, toRaw } from "vue";
import { Calendar } from "vant";
import { _ as _sfc_main$5, o as onDebounce, b as bo_recommand_popup, e as en_default_logo, c as calendar_icon } from "./index2.js";
import { b as _sfc_main$6, _ as _sfc_main$7, a as _sfc_main$8 } from "./index4.js";
import dayjs from "dayjs";
import "@wltech/svg";
_sfc_main$5.install = (app) => {
  app.component(_sfc_main$5.name, _sfc_main$5);
};
var index_vue_vue_type_style_index_0_lang$4 = "";
const _hoisted_1$2 = {
  class: "wl-input",
  "data-weiling-mobile-ui-wl-input": ""
};
const _hoisted_2$1 = ["maxlength", "placeholder"];
const _hoisted_3$1 = {
  key: 0,
  class: "max-len"
};
const __default__$4 = {
  name: "WlInput"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  ...__default__$4,
  props: {
    modelValue: { default: "" },
    placeholder: { default: "" },
    placeholderFontSize: { default: "14px" },
    clearable: { type: Boolean, default: false },
    needDebounce: { type: Boolean, default: true },
    inputType: { default: "text" },
    maxlength: { default: "" },
    inputHeight: { default: "44px" }
  },
  emits: ["onBlur", "onFocus", "onClear", "onChange", "update:modelValue"],
  setup(__props, { expose, emit }) {
    const props = __props;
    useCssVars((_ctx) => ({
      "08996f6c": __props.inputHeight,
      "2cb4dd88": __props.placeholderFontSize
    }));
    const formValue = ref("");
    const inputRef = ref(null);
    const onClear = () => {
      emit("update:modelValue", "");
    };
    const onBlur = () => emit("onBlur");
    const onFocus = () => emit("onFocus");
    const formatNumber = (value, is_float) => {
      value += "";
      const regExp = is_float ? /[^-0-9.]/g : /[^-0-9]/g;
      value = value.replace(regExp, "");
      if (value.indexOf(".") !== -1) {
        let arr = value.split(".");
        let firstNum = arr[0];
        arr[0] = "";
        value = firstNum + `${arr.length > 1 && is_float ? "." + arr.join("") : ""}`;
      }
      if (value.lastIndexOf("-") !== 0 && value.lastIndexOf("-") !== -1) {
        const arr = value.split("-");
        value = value.startsWith("-") ? "-" + arr.join("") : arr.join("");
      }
      return value.replace(regExp, "");
    };
    const onDebounceSave = onDebounce(() => {
      emit("onChange", formValue.value);
      emit("update:modelValue", formValue.value);
    }, 500);
    const onInput = () => {
      let val = formValue.value;
      if (["number", "digit"].includes(props.inputType)) {
        val = formatNumber(val, props.inputType === "number");
      }
      formValue.value = val;
      if (props.needDebounce) {
        onDebounceSave();
      } else {
        emit("onChange", val);
        emit("update:modelValue", val);
      }
    };
    const onTriggerFocus = () => {
      inputRef.value.focus();
    };
    watchEffect(() => {
      formValue.value = props.modelValue + "";
    });
    expose({
      onTriggerFocus
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1$2, [
        withDirectives(createElementVNode("input", {
          ref_key: "inputRef",
          ref: inputRef,
          "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => formValue.value = $event),
          onFocus,
          onBlur,
          onInput,
          maxlength: __props.maxlength,
          placeholder: __props.placeholder
        }, null, 40, _hoisted_2$1), [
          [vModelText, formValue.value]
        ]),
        __props.maxlength ? (openBlock(), createElementBlock("p", _hoisted_3$1, toDisplayString(formValue.value.length) + "/" + toDisplayString(__props.maxlength), 1)) : createCommentVNode("", true),
        formValue.value && __props.clearable ? (openBlock(), createBlock(_sfc_main$6, {
          key: 1,
          type: "closeFill",
          width: "16",
          height: "16",
          color: "#919699",
          onClick: withModifiers(onClear, ["stop"])
        }, null, 8, ["onClick"])) : createCommentVNode("", true)
      ]);
    };
  }
});
_sfc_main$4.install = (app) => {
  app.component(_sfc_main$4.name, _sfc_main$4);
};
_sfc_main$7.install = (app) => {
  app.component(_sfc_main$7.name, _sfc_main$7);
};
var index_vue_vue_type_style_index_0_lang$3 = "";
const __default__$3 = {
  name: "WlButton"
};
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  ...__default__$3,
  props: {
    text: { default: "" },
    disabled: { type: Boolean, default: false },
    type: { default: "primary" },
    size: { default: "normal" },
    shape: { default: "default" },
    styleExtra: { default: null },
    plain: { type: Boolean, default: false },
    color: { default: "" }
  },
  emits: ["onClick"],
  setup(__props, { emit }) {
    const props = __props;
    const btnClass = computed(() => {
      return {
        [`btn-plain-${props.type}`]: props.plain,
        [`btn-type-${props.type}`]: !props.plain,
        [`btn-shape-${props.shape}`]: true,
        [`btn-size-${props.size}`]: true,
        disabled: props.disabled
      };
    });
    const btnStyle = computed(() => {
      let colorStyle = {};
      if (props.plain && props.color) {
        colorStyle = {
          "border-color": props.color,
          color: props.color
        };
      } else if (!props.plain && props.color) {
        colorStyle = {
          "background-color": props.color,
          "border-color": props.color
        };
      }
      return {
        ...props.styleExtra,
        ...colorStyle
      };
    });
    const onButtonClick = onDebounce(() => {
      if (props.disabled)
        return;
      emit("onClick");
    }, 500);
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: normalizeClass([unref(btnClass), "btn"]),
        onClick: _cache[0] || (_cache[0] = withModifiers(
          (...args) => unref(onButtonClick) && unref(onButtonClick)(...args),
          ["stop"]
        )),
        style: normalizeStyle(unref(btnStyle)),
        "data-weiling-mobile-ui-wl-button": ""
      }, [
        createTextVNode(toDisplayString(__props.text) + " ", 1),
        renderSlot(_ctx.$slots, "default")
      ], 6);
    };
  }
});
_sfc_main$3.install = (app) => {
  app.component(_sfc_main$3.name, _sfc_main$3);
};
dayjs().format();
dayjs.locale("zh-cn");
const formatMoment = (val, format) => {
  if (!val)
    return "";
  val = Object.prototype.toString.call(val) === "[object String]" ? val * 1 : val;
  const current_year = dayjs().year();
  const format_year = dayjs(val).year();
  if (["MM-DD", "MM-DD HH:mm:ss"].includes(format) && current_year !== format_year) {
    return dayjs(val).format(`YYYY-${format}`);
  } else {
    return dayjs(val).format(format);
  }
};
var index_vue_vue_type_style_index_0_lang$2 = "";
const __default__$2 = {
  name: "RecommendPopover"
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  ...__default__$2,
  props: {
    modelValue: { type: Boolean, default: false },
    background_image_url: { default: "" }
  },
  emits: ["update:modelValue"],
  setup(__props, { emit }) {
    const props = __props;
    const visible = ref(false);
    const wrap_style = computed(() => {
      return {
        "background-image": `url(${props.background_image_url || bo_recommand_popup})`
      };
    });
    watchEffect(() => {
      visible.value = props.modelValue;
    });
    watch(
      () => visible.value,
      (val) => emit("update:modelValue", val)
    );
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: "recommend-popover",
        style: normalizeStyle(unref(wrap_style)),
        "data-weiling-mobile-ui-bc-business-stage-recommend-popover": ""
      }, [
        renderSlot(_ctx.$slots, "default")
      ], 4);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$1 = "";
const _hoisted_1$1 = {
  class: "user-groups",
  "data-weiling-mobile-ui-wl-user-groups": ""
};
const __default__$1 = {
  name: "WlUserGroups"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    data: { default: null },
    size: { default: "16" },
    avatar_offset: { default: "-10px" }
  },
  setup(__props) {
    const props = __props;
    const avatarStyle = computed(() => {
      let offset = typeof props.avatar_offset === "number" ? props.avatar_offset + "px" : props.avatar_offset;
      return {
        width: `${props.size}px`,
        height: `${props.size}px`,
        "--avatarOffset": offset
      };
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("ul", _hoisted_1$1, [
        (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data, (item, index) => {
          return openBlock(), createElementBlock("li", {
            key: index,
            style: normalizeStyle(unref(avatarStyle))
          }, [
            createVNode(_sfc_main$5, {
              src: item == null ? void 0 : item.avatar
            }, null, 8, ["src"])
          ], 4);
        }), 128))
      ]);
    };
  }
});
_sfc_main$1.install = (app) => {
  app.component(_sfc_main$1.name, _sfc_main$1);
};
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1 = {
  class: "success-popup",
  "data-weiling-mobile-ui-bc-business-stage-popup-success-popup": ""
};
const _hoisted_2 = { class: "header" };
const _hoisted_3 = /* @__PURE__ */ createTextVNode("\u8D62\u5355\u4FE1\u606F");
const _hoisted_4 = { class: "info-list" };
const _hoisted_5 = { class: "line" };
const _hoisted_6 = /* @__PURE__ */ createElementVNode("p", { class: "label" }, "\u7B7E\u5355\u5BA2\u6237", -1);
const _hoisted_7 = { class: "base-info" };
const _hoisted_8 = { class: "name" };
const _hoisted_9 = /* @__PURE__ */ createElementVNode("p", { class: "label" }, "\u7B7E\u5355\u4F01\u4E1A", -1);
const _hoisted_10 = { class: "base-info" };
const _hoisted_11 = { class: "company_avatar" };
const _hoisted_12 = { class: "name" };
const _hoisted_13 = { class: "line" };
const _hoisted_14 = /* @__PURE__ */ createElementVNode("p", { class: "label" }, [
  /* @__PURE__ */ createTextVNode("\u8D62\u5355\u91D1\u989D"),
  /* @__PURE__ */ createElementVNode("span", null, "*")
], -1);
const _hoisted_15 = { class: "info price" };
const _hoisted_16 = /* @__PURE__ */ createElementVNode("p", { class: "prefix" }, "\uFFE5", -1);
const _hoisted_17 = { class: "content" };
const _hoisted_18 = {
  key: 0,
  class: "recommand-wrap"
};
const _hoisted_19 = { class: "recommand" };
const _hoisted_20 = { class: "pre-price" };
const _hoisted_21 = /* @__PURE__ */ createElementVNode("p", { class: "text" }, "\u9884\u8BA1\u6210\u4EA4\u91D1\u989D\uFF1A", -1);
const _hoisted_22 = { class: "num" };
const _hoisted_23 = ["onClick"];
const _hoisted_24 = /* @__PURE__ */ createElementVNode("p", null, "\u586B\u5165", -1);
const _hoisted_25 = [
  _hoisted_24
];
const _hoisted_26 = /* @__PURE__ */ createElementVNode("p", { class: "suffix" }, "\u5143", -1);
const _hoisted_27 = { class: "line" };
const _hoisted_28 = /* @__PURE__ */ createElementVNode("p", { class: "label" }, [
  /* @__PURE__ */ createTextVNode("\u8D62\u5355\u65E5\u671F"),
  /* @__PURE__ */ createElementVNode("span", null, "*")
], -1);
const _hoisted_29 = ["onClick"];
const _hoisted_30 = { class: "prefix" };
const _hoisted_31 = { class: "icon" };
const _hoisted_32 = { class: "content" };
const _hoisted_33 = { class: "placeholder" };
const _hoisted_34 = { class: "footer" };
const _hoisted_35 = /* @__PURE__ */ createTextVNode("\u53D6\u6D88");
const _hoisted_36 = /* @__PURE__ */ createTextVNode("\u786E\u5B9A");
const __default__ = {
  name: "BOSucessPopup"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    modelValue: { type: Boolean, default: false },
    data: { default: null }
  },
  emits: ["update:modelValue", "onSubmit"],
  setup(__props, { emit }) {
    const props = __props;
    const popupVisible = ref(false);
    const calendarVisible = ref(false);
    const pricePlaceholder = ref("");
    const recommendPopoverVisible = ref(true);
    const currentYear = new Date().getFullYear();
    const minDate = ref(new Date(currentYear - 2, 1, 1));
    const maxDate = ref(new Date(currentYear + 2, 12, 31));
    const successData = ref(null);
    const base_info = computed(() => {
      const { company_info = null, customers = [] } = props.data || {};
      const { company_name = "", image_url = "" } = company_info || {};
      const { nick_name = "" } = customers && customers.length > 0 ? customers[0] : {};
      const user_name = customers.length > 1 ? `${nick_name}\u7B49${customers.length}\u4EBA` : nick_name;
      const urls = customers.slice(0, 3).map((ele) => {
        const { head_img_url = "" } = ele;
        return { avatar: head_img_url, ...ele };
      });
      return {
        is_company: !!company_info,
        name: company_info ? company_name : user_name,
        company_avatar: image_url || en_default_logo,
        user_avatars: urls
      };
    });
    const submit_bnt_disabled = computed(() => {
      const { winning_date = "", winning_amount = "" } = successData.value;
      return !!(winning_date && winning_amount);
    });
    const except_amount = computed(() => {
      const { except_amount: except_amount2 = "" } = props.data || {};
      return except_amount2 && recommendPopoverVisible.value;
    });
    watch(
      () => popupVisible.value,
      (val) => emit("update:modelValue", val)
    );
    watchEffect(() => {
      popupVisible.value = !!props.modelValue;
    });
    watchEffect(() => {
      const { winning_date = "", except_amount: except_amount2 = "" } = props.data || {};
      let dateText = "";
      if (winning_date) {
        dateText = formatMoment(winning_date, "YYYY-MM-DD");
      } else {
        dateText = formatMoment(new Date().getTime(), "YYYY-MM-DD");
      }
      successData.value = {
        winning_amount: "",
        ...props.data,
        except_amount_text: except_amount2,
        dateText,
        winning_date: winning_date || new Date().getTime()
      };
    });
    const onShowCalendar = () => {
      calendarVisible.value = true;
    };
    const onClose = () => popupVisible.value = false;
    const onSelectDate = (date) => {
      const time = date.getTime();
      successData.value = {
        ...successData.value,
        winning_date: time,
        dateText: formatMoment(time, "YYYY-MM-DD")
      };
      calendarVisible.value = false;
    };
    const onSubmit = () => {
      emit("onSubmit", toRaw(successData.value));
    };
    const onClickPrice = () => {
      const { except_amount: except_amount2 = "" } = props.data;
      successData.value = {
        ...successData.value,
        winning_amount: except_amount2
      };
      recommendPopoverVisible.value = false;
    };
    const onBlur = () => pricePlaceholder.value = "\u8BF7\u8F93\u5165\u91D1\u989D";
    const onFocus = () => pricePlaceholder.value = "0.00";
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock(Fragment, null, [
        createVNode(_sfc_main$8, {
          modelValue: popupVisible.value,
          "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => popupVisible.value = $event),
          round: "",
          style: { "height": "60%" },
          position: "bottom"
        }, {
          default: withCtx(() => [
            createElementVNode("div", _hoisted_1, [
              createElementVNode("div", _hoisted_2, [
                createVNode(unref(_sfc_main$7), {
                  showClose: "",
                  onOnClose: onClose
                }, {
                  default: withCtx(() => [
                    _hoisted_3
                  ]),
                  _: 1
                })
              ]),
              createElementVNode("div", _hoisted_4, [
                createElementVNode("div", _hoisted_5, [
                  !unref(base_info).is_company ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
                    _hoisted_6,
                    createElementVNode("div", _hoisted_7, [
                      createVNode(unref(_sfc_main$1), {
                        size: "26",
                        avatar_offset: "-20px",
                        data: unref(base_info).user_avatars
                      }, null, 8, ["data"]),
                      createElementVNode("p", _hoisted_8, toDisplayString(unref(base_info).name), 1)
                    ])
                  ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
                    _hoisted_9,
                    createElementVNode("div", _hoisted_10, [
                      createElementVNode("div", _hoisted_11, [
                        createVNode(unref(_sfc_main$5), {
                          src: unref(base_info).company_avatar
                        }, null, 8, ["src"])
                      ]),
                      createElementVNode("p", _hoisted_12, toDisplayString(unref(base_info).name), 1)
                    ])
                  ], 64))
                ]),
                createElementVNode("div", _hoisted_13, [
                  _hoisted_14,
                  createElementVNode("div", _hoisted_15, [
                    _hoisted_16,
                    createElementVNode("div", _hoisted_17, [
                      createVNode(unref(_sfc_main$4), {
                        modelValue: successData.value.winning_amount,
                        "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => successData.value.winning_amount = $event),
                        placeholder: pricePlaceholder.value,
                        class: "input",
                        inputType: "number",
                        onOnBlur: onBlur,
                        onOnFocus: onFocus
                      }, null, 8, ["modelValue", "placeholder"]),
                      unref(except_amount) ? (openBlock(), createElementBlock("div", _hoisted_18, [
                        createVNode(_sfc_main$2, null, {
                          default: withCtx(() => [
                            createElementVNode("div", _hoisted_19, [
                              createElementVNode("div", _hoisted_20, [
                                _hoisted_21,
                                createElementVNode("p", _hoisted_22, toDisplayString(successData.value.except_amount_text) + "\u5143", 1)
                              ]),
                              createElementVNode("div", {
                                class: "add-price",
                                onClick: withModifiers(onClickPrice, ["stop"])
                              }, _hoisted_25, 8, _hoisted_23)
                            ])
                          ]),
                          _: 1
                        })
                      ])) : createCommentVNode("", true)
                    ]),
                    _hoisted_26
                  ])
                ]),
                createElementVNode("div", _hoisted_27, [
                  _hoisted_28,
                  createElementVNode("div", {
                    class: "info date",
                    onClick: withModifiers(onShowCalendar, ["stop"])
                  }, [
                    createElementVNode("div", _hoisted_30, [
                      createElementVNode("div", _hoisted_31, [
                        createVNode(unref(_sfc_main$5), { src: unref(calendar_icon) }, null, 8, ["src"])
                      ])
                    ]),
                    createElementVNode("div", _hoisted_32, [
                      createTextVNode(toDisplayString(successData.value.dateText) + " ", 1),
                      withDirectives(createElementVNode("span", _hoisted_33, "\u8BF7\u9009\u62E9\u65E5\u671F", 512), [
                        [vShow, !successData.value.dateText]
                      ])
                    ])
                  ], 8, _hoisted_29)
                ])
              ]),
              createElementVNode("div", _hoisted_34, [
                createVNode(unref(_sfc_main$3), {
                  class: "btn canel",
                  onOnClick: onClose,
                  pain: ""
                }, {
                  default: withCtx(() => [
                    _hoisted_35
                  ]),
                  _: 1
                }),
                createVNode(unref(_sfc_main$3), {
                  class: "btn confirm",
                  disabled: !unref(submit_bnt_disabled),
                  onOnClick: onSubmit
                }, {
                  default: withCtx(() => [
                    _hoisted_36
                  ]),
                  _: 1
                }, 8, ["disabled"])
              ])
            ])
          ]),
          _: 1
        }, 8, ["modelValue"]),
        createVNode(unref(Calendar), {
          color: "rgb(28,159,255)",
          "min-date": minDate.value,
          "max-date": maxDate.value,
          show: calendarVisible.value,
          "onUpdate:show": _cache[2] || (_cache[2] = ($event) => calendarVisible.value = $event),
          onConfirm: onSelectDate
        }, null, 8, ["min-date", "max-date", "show"])
      ], 64);
    };
  }
});
export { _sfc_main as default };
