import { ref, computed, defineComponent, openBlock, createBlock, unref, createElementBlock, normalizeClass, createElementVNode, createCommentVNode, toDisplayString, createVNode, render, watch, normalizeStyle, renderSlot, useCssVars, watchEffect, withDirectives, vShow, createTextVNode, mergeProps, withCtx, withModifiers, Fragment, renderList, useSlots, nextTick, toRaw } from "vue";
import WlSvg from "@wltech/svg";
import { Circle, Popup } from "vant";
const useStack = () => {
  const stack = ref([]);
  const showBack = computed(() => stack.value.length > 1);
  const currentList = computed(() => stack.value[stack.value.length - 1]);
  const onAddStack = (list) => stack.value.push(list);
  const onPopStack = () => stack.value.pop();
  const onChangeStack = (list, order = stack.value.length - 1) => {
    stack.value[order] = list;
  };
  return {
    stack,
    showBack,
    currentList,
    onPopStack,
    onAddStack,
    onChangeStack
  };
};
var employeeSelector = {
  employeeData: null,
  topFiveEmployeeData: null,
  organization: null,
  organization_count: null,
  count: 0,
  dept_list: [],
  company_list: [],
  company_list_count: 0,
  companyEmployeeList: [],
  totalCompanyEmployeeList: [],
  totalCompanyEmployeeObjList: []
};
let Store = {
  sid: "",
  app_id: "",
  user_id: "",
  user_name: "",
  corp_id: "",
  node_env: "",
  domain: "",
  token: "",
  card_resource: "",
  employeeSelector
};
var Store$1 = new Proxy(Store, {
  get(target, name, property) {
    return Reflect.get(target, name, property);
  },
  set(target, name, value, property) {
    return Reflect.set(target, name, value, property);
  }
});
const proxy_api = {
  dev_uat: "/uat_api",
  dev_stg: "/stg_api",
  dev_prd: "/prd_api",
  dev_cos_api: "/cos_api",
  dev_uat_xsf: "/xsf_api",
  dev: "/uat_api",
  uat: "",
  stg: "",
  prd: "",
  gray: "",
  production: "",
  uat_xsf: "https://test.xsfapi.weiling.cn",
  stg_xsf: "https://pre-xsfapi.weiling.cn",
  prd_xsf: "https://xsfapi.weiling.cn",
  gray_xsf: "https://xsfapi.weiling.cn"
};
const token_key = {
  dev_uat: "auth-token-mp-test",
  dev_stg: "auth-token-mp",
  dev_prd: "auth-token-mp",
  dev_uat_xsf: "auth-token-se-test",
  dev_stg_xsf: "auth-token-se",
  dev_gray_xsf: "auth-token-se",
  dev_prd_xsf: "auth-token-se",
  uat: "auth-token-mp-test",
  stg: "auth-token-mp",
  prd: "auth-token-mp",
  gray: "auth-token-mp",
  uat_xsf: "auth-token-se-test",
  stg_xsf: "auth-token-se",
  prd_xsf: "auth-token-se",
  gray_xsf: "auth-token-se"
};
const __default__$c = {
  name: "WlSvgIcon"
};
const _sfc_main$c = /* @__PURE__ */ defineComponent({
  ...__default__$c,
  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"]);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$5 = "";
const _hoisted_1$a = { class: "icon" };
const _hoisted_2$a = { class: "text" };
const __default__$b = {
  name: "WlNotice"
};
const _sfc_main$b = /* @__PURE__ */ defineComponent({
  ...__default__$b,
  props: {
    show_toast: { type: Boolean, default: true },
    message: { default: "" },
    type: { default: "success" },
    duration: { default: 1500 }
  },
  setup(__props) {
    return (_ctx, _cache) => {
      return __props.show_toast ? (openBlock(), createElementBlock("div", {
        key: 0,
        class: normalizeClass(`notice ${__props.type}`),
        "data-weiling-mobile-ui-wl-notice": ""
      }, [
        createElementVNode("div", _hoisted_1$a, [
          __props.type === "success" ? (openBlock(), createBlock(_sfc_main$c, {
            key: 0,
            type: "successFill",
            width: "24",
            height: "24",
            color: "#45ce03"
          })) : __props.type === "warning" ? (openBlock(), createBlock(_sfc_main$c, {
            key: 1,
            type: "warningFill",
            width: "24",
            height: "24",
            color: "#f3a401"
          })) : __props.type === "alert" ? (openBlock(), createBlock(_sfc_main$c, {
            key: 2,
            type: "tipsFill",
            width: "24",
            height: "24",
            color: "#1b9fff"
          })) : __props.type === "error" ? (openBlock(), createBlock(_sfc_main$c, {
            key: 3,
            type: "closeFill",
            width: "24",
            height: "24",
            color: "#ff2a2d"
          })) : createCommentVNode("", true)
        ]),
        createElementVNode("p", _hoisted_2$a, toDisplayString(__props.message), 1)
      ], 2)) : createCommentVNode("", true);
    };
  }
});
let mountNode$1 = null;
var WlNotice = (options) => {
  const duration = options.duration | 2e3;
  if (mountNode$1) {
    document.body.removeChild(mountNode$1);
    mountNode$1 = null;
  }
  const app = createVNode(_sfc_main$b, {
    ...options,
    duration,
    show_toast: true
  });
  let timer = setTimeout(() => {
    if (mountNode$1) {
      document.body.removeChild(mountNode$1);
      mountNode$1 = null;
    }
    clearTimeout(timer);
  }, duration);
  mountNode$1 = document.createElement("div");
  render(app, mountNode$1);
  document.body.appendChild(mountNode$1);
};
const onDebounce = (fn, delay) => {
  let timer;
  return function(...args) {
    if (timer) {
      clearTimeout(timer);
    }
    timer = setTimeout(
      () => {
        typeof fn === "function" && fn.apply(null, [...args]);
        clearTimeout(timer);
      },
      delay > 0 ? delay : 100
    );
  };
};
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 removeEmptyField = (obj) => {
  let newObj = {};
  if (typeof obj === "string") {
    obj = JSON.parse(obj);
  }
  if (obj instanceof Array) {
    newObj = [];
  }
  if (obj instanceof Object) {
    for (let attr in obj) {
      if (obj[attr] !== "" && obj[attr] !== null && obj[attr] !== void 0) {
        if (obj[attr] instanceof Object) {
          if (JSON.stringify(obj[attr]) === "{}" || JSON.stringify(obj[attr]) === "[]") {
            continue;
          }
          newObj[attr] = removeEmptyField(obj[attr]);
        } else if (typeof obj[attr] === "string" && (obj[attr].indexOf("{") > -1 && obj[attr].indexOf("}") > -1 || obj[attr].indexOf("[") > -1 && obj[attr].indexOf("]") > -1)) {
          try {
            let attrObj = JSON.parse(obj[attr]);
            if (attrObj instanceof Object) {
              newObj[attr] = removeEmptyField(attrObj);
            }
          } catch (e) {
            newObj[attr] = obj[attr];
          }
        } else {
          newObj[attr] = obj[attr];
        }
      }
    }
  }
  return newObj;
};
function obj2String(obj, arr = [], idx = 0) {
  for (let item in obj) {
    arr[idx++] = [item, obj[item]];
  }
  return new URLSearchParams(arr).toString();
}
function getOptions(options) {
  const { sid = "", corp_id = "", card_resource = "" } = Store$1 != null ? Store$1 : {};
  const params = {
    sid,
    corp_id,
    card_resource,
    ...options
  };
  return obj2String(params);
}
const onHandleUrl = (url) => {
  const { node_env } = Store$1;
  const isPersonMiniApp = node_env.includes("xsf");
  if (isPersonMiniApp) {
    return setPersonMiniAppUrl(url);
  }
  return url;
};
const setPersonMiniAppUrl = (url) => {
  let filterUrl = url;
  if (filterUrl.includes("/api/user/share/path")) {
    filterUrl = filterUrl.replace("/api/user/share/path", "/apise/material/share/path");
  } else if (filterUrl.includes("/interact/")) {
    filterUrl = filterUrl.replace("/interact/", "/apise/");
  } else if (filterUrl.includes("/api/")) {
    filterUrl = filterUrl.replace("/api/", "/apise/");
  } else if (filterUrl.includes("/wx/track")) {
    filterUrl = filterUrl.replace("/wx/track", "/apise/track/wx/track");
  }
  return filterUrl;
};
function request(url, options, method = "GET") {
  const staticOption = {
    sid: Store$1.sid,
    corp_id: Store$1.corp_id,
    tab_change: 0
  };
  const data = {
    ...staticOption,
    ...options
  };
  const searchStr = getOptions(removeEmptyField(data));
  const staticSearchStr = getOptions(removeEmptyField(staticOption));
  let initObj = {};
  let params = "";
  if (method === "GET") {
    initObj = {
      method,
      credentials: "include",
      headers: new Headers({
        [token_key[Store$1.node_env]]: Store$1.token
      })
    };
    params = searchStr;
  } else if (method === "FormPOST") {
    initObj = {
      method: "POST",
      credentials: "include",
      headers: new Headers({
        [token_key[Store$1.node_env]]: Store$1.token
      }),
      body: options
    };
    params = staticSearchStr;
  } else {
    initObj = {
      method,
      credentials: "include",
      headers: new Headers({
        Accept: "application/json, text/plain, */*",
        "Content-Type": "application/json",
        [token_key[Store$1.node_env]]: Store$1.token
      }),
      body: JSON.stringify(data)
    };
    params = staticSearchStr;
  }
  const filterUrl = onHandleUrl(url) + "?" + params;
  return fetch(filterUrl, initObj).then((res) => {
    const isArea = url.includes("region.json");
    return res.json().then((result) => {
      var _a;
      if (result.code === 200 || isArea) {
        return result;
      } else {
        WlNotice({ message: (_a = result.msg) != null ? _a : "\u670D\u52A1\u5668\u5185\u90E8\u9519\u8BEF", type: "error", duration: 3e3 });
        throw Error(result);
      }
    });
  }).then((res) => {
    return res;
  });
}
const POST = (url, options) => {
  return request(url, options, "POST");
};
const getDept = (params) => {
  return POST(`${proxy_api[Store$1.node_env]}/saas/user_picker/dept`, params);
};
const domain = "https://wlmvp-cos.weiling.cn";
const loadingPic = domain + "/frontend/weilingMobileUI/loading.png";
const loadingFailPic = domain + "/frontend/weilingMobileUI/loadingFail.png";
const _hoisted_1$9 = ["src", "alt"];
const _hoisted_2$9 = ["src"];
const _hoisted_3$5 = ["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__$a = {
  name: "WlPic"
};
const _sfc_main$a = /* @__PURE__ */ defineComponent({
  ...__default__$a,
  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$9)) : 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$9)) : 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$5)) : createCommentVNode("", true),
        renderSlot(_ctx.$slots, "picFooter")
      ], 2);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$4 = "";
const _hoisted_1$8 = {
  key: 0,
  class: "loading-model",
  "data-weiling-mobile-ui-wl-loading": ""
};
const _hoisted_2$8 = {
  key: 0,
  class: "percent"
};
const _hoisted_3$4 = {
  key: 1,
  class: "box"
};
const _hoisted_4$2 = {
  key: 0,
  class: "text"
};
const __default__$9 = {
  name: "WlLoading"
};
const _sfc_main$9 = /* @__PURE__ */ defineComponent({
  ...__default__$9,
  props: {
    needPercent: { type: Boolean, default: false },
    showLoading: { type: Boolean, default: true },
    currentRate: { default: 0 },
    content: { default: "\u6B63\u5728\u52A0\u8F7D\u4E2D..." },
    percent: { default: 1 },
    backgroundColor: { default: "white" },
    loadingModelBackgroundColor: { default: "rgba(0, 0, 0, 0.45)" }
  },
  setup(__props) {
    const props = __props;
    useCssVars((_ctx) => ({
      "1045e3da": __props.loadingModelBackgroundColor,
      "3aaae1a0": __props.backgroundColor
    }));
    const showLoadingValue = ref(false);
    const currentRateValue = ref(0);
    const percentValue = ref(0);
    const loadingPhoto = loadingPic;
    const onCancelUpload = () => {
      showLoadingValue.value = false;
    };
    const text = computed(() => {
      return props.currentRate.toFixed(0) + "%";
    });
    watchEffect(() => {
      showLoadingValue.value = props.showLoading;
    });
    watchEffect(() => {
      currentRateValue.value = props.currentRate;
    });
    watchEffect(() => {
      percentValue.value = props.percent;
    });
    return (_ctx, _cache) => {
      return showLoadingValue.value ? (openBlock(), createElementBlock("div", _hoisted_1$8, [
        __props.needPercent ? (openBlock(), createElementBlock("div", _hoisted_2$8, [
          createVNode(unref(Circle), {
            "current-rate": currentRateValue.value,
            "onUpdate:current-rate": _cache[0] || (_cache[0] = ($event) => currentRateValue.value = $event),
            size: "80px",
            rate: percentValue.value,
            text: unref(text),
            color: "var(--wl-primary-color)",
            "layer-color": "#eee",
            "stroke-width": 60
          }, null, 8, ["current-rate", "rate", "text"]),
          createElementVNode("div", {
            class: "cancel-upload",
            onClick: onCancelUpload
          }, "\u53D6\u6D88\u4E0A\u4F20")
        ])) : (openBlock(), createElementBlock("div", _hoisted_3$4, [
          createVNode(_sfc_main$a, {
            class: "icon",
            src: unref(loadingPhoto)
          }, null, 8, ["src"]),
          __props.content ? (openBlock(), createElementBlock("span", _hoisted_4$2, toDisplayString(__props.content), 1)) : createCommentVNode("", true)
        ]))
      ])) : createCommentVNode("", true);
    };
  }
});
let mountNode = null;
var WlLoading = (options) => {
  const {
    type,
    needPercent,
    tips,
    percent,
    currentRate,
    backgroundColor = "white",
    loadingModelBackgroundColor = "rgba(0, 0, 0, 0.45)"
  } = options;
  const app = createVNode(_sfc_main$9, {
    percent,
    needPercent,
    currentRate,
    content: tips,
    backgroundColor,
    loadingModelBackgroundColor
  });
  if (type === "hide") {
    if (mountNode) {
      if (options.parentNode) {
        options.parentNode.removeChild(mountNode);
      } else {
        document.body.removeChild(mountNode);
      }
      mountNode = null;
    }
  } else if (type === "show") {
    app.props.showLoading = true;
    mountNode = document.createElement("div");
    render(app, mountNode);
    if (options.parentNode) {
      options.parentNode.appendChild(mountNode);
    } else {
      document.body.appendChild(mountNode);
    }
  } else if (type === "changePercent") {
    app.props.currentRate = percent;
    app.props.needPercent = true;
    render(app, mountNode);
  }
};
const useHandleData = () => {
  const useArrToTree = (arr) => {
    var _a;
    const returnArr = [];
    const map = arr.reduce((acc, item) => {
      acc[item.id] = item;
      return acc;
    }, {});
    const len = arr.length;
    for (let i = 0; i < len; i++) {
      arr[i].checkedStatus = "no-check";
      arr[i].showInCheckedList = true;
      if (!arr[i].pid || arr[i].pid === "0")
        returnArr.push(arr[i]);
      const item = map[arr[i].pid];
      if (item)
        item.children = [...(_a = item.children) != null ? _a : [], arr[i]];
    }
    return returnArr;
  };
  const treeFilter = (init_data = [], pids = []) => {
    const data = init_data;
    init_data = null;
    const res = data.map((ele) => {
      const { children = [], id } = ele;
      const childrenList = treeFilter(children, [id, ...pids]);
      let childrenIds = childrenList.reduce((pre, cur) => {
        const { id: id2 = "", childrenIds: childrenIds2 = [] } = cur;
        return [...pre, id2, ...childrenIds2];
      }, []);
      return {
        ...ele,
        children: childrenList,
        childrenIds,
        parentIds: pids
      };
    });
    pids = null;
    return res;
  };
  const onGetData = () => {
    return new Promise((resolve) => {
      WlLoading({ type: "show" });
      getDept({
        pid: "",
        filter: {
          only_leader: false,
          role_types: [],
          only_dept: true,
          only_sub: true
        }
      }).then((res) => {
        var _a, _b;
        const originData = (_b = (_a = res.data) == null ? void 0 : _a.data_list) != null ? _b : [];
        const treeData = treeFilter(useArrToTree(originData));
        resolve(treeData);
        WlLoading({ type: "hide" });
      });
    });
  };
  return {
    onGetData
  };
};
const useCheckedData = () => {
  const checkedList = ref([]);
  const checkedIds = computed(() => checkedList.value.map((res) => res.id));
  const onGetCheckedList = (list) => {
    return list.filter((res) => res.checkedStatus === "checked");
  };
  const onAddCheckdList = (list) => {
    const uniqueArr = list.reduce((acc, item) => {
      return !checkedIds.value.includes(item.id) ? [...acc, item] : acc;
    }, []);
    checkedList.value = [...checkedList.value, ...uniqueArr];
  };
  const onSetCheckedbyIds = (list, idList, parentChecked = false) => {
    return list.map((ele) => {
      const { children = [], id } = ele;
      const parentIsChecked = idList.includes(id);
      const data = onSetCheckedbyIds(
        children,
        idList,
        parentChecked ? parentChecked : parentIsChecked
      );
      let isChecked = parentIsChecked ? "checked" : "no-check";
      if (!parentIsChecked) {
        let childrenCheckedLen = 0, childrenPreCheckLen = 0;
        data.forEach((element) => {
          if (element.checkedStatus === "pre-check") {
            childrenPreCheckLen++;
          } else if (element.checkedStatus === "checked") {
            childrenCheckedLen++;
          }
        });
        if (childrenCheckedLen !== 0) {
          isChecked = childrenCheckedLen === children.length ? "checked" : "pre-check";
        } else if (childrenPreCheckLen !== 0) {
          isChecked = "pre-check";
        }
      }
      const returnData = {
        ...ele,
        children: data,
        checkedStatus: parentChecked ? "checked" : isChecked
      };
      if (isChecked === "checked" && idList.includes(ele.id) || isChecked === "pre-check") {
        onAddCheckdList([returnData]);
      }
      return returnData;
    });
  };
  const onChangeCheckedStatus = (ids, status) => {
    checkedList.value = checkedList.value.map((res) => {
      const bool = ids.includes(res.id);
      return {
        ...res,
        checkedStatus: bool ? status : res.checkedStatus,
        showInCheckedList: bool || res.showInCheckedList
      };
    });
  };
  return {
    checkedIds,
    checkedList,
    onAddCheckdList,
    onSetCheckedbyIds,
    onChangeCheckedStatus,
    onGetCheckedList
  };
};
const _hoisted_1$7 = { class: "z-2 flex uno-min-w-44 uno-max-w-88" };
const _hoisted_2$7 = { class: "uno-elli-1 z-1 box-border flex-middle-center absolute text-center uno-l-44 uno-r-44" };
const _hoisted_3$3 = { class: "relative z-2 flex-middle-center uno-min-w-44" };
const __default__$8 = {
  name: "WlHeader"
};
const _sfc_main$8 = /* @__PURE__ */ defineComponent({
  ...__default__$8,
  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$7, [
          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$c, {
                type: "arrowTipLeft",
                width: "22",
                height: "22",
                color: "#000"
              })
            ], 512), [
              [vShow, __props.showBack]
            ])
          ])
        ]),
        createElementVNode("div", _hoisted_2$7, [
          renderSlot(_ctx.$slots, "default", {}, () => [
            createTextVNode(toDisplayString(__props.title), 1)
          ])
        ]),
        createElementVNode("div", _hoisted_3$3, [
          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$c, {
                type: "close",
                width: "22",
                height: "22",
                color: "#000"
              })
            ], 512), [
              [vShow, __props.showClose]
            ])
          ])
        ])
      ], 2);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$3 = "";
const _hoisted_1$6 = {
  class: "popup-wrap",
  "data-weiling-mobile-ui-wl-popup": ""
};
const _hoisted_2$6 = { class: "popup-content" };
const __default__$7 = {
  name: "WlPopup"
};
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
  ...__default__$7,
  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$6, [
            __props.headerVisible ? (openBlock(), createBlock(_sfc_main$8, {
              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$6, [
              renderSlot(_ctx.$slots, "default")
            ])
          ])
        ]),
        _: 3
      }, 16, ["show", "teleport", "position", "style"]);
    };
  }
});
var index_vue_vue_type_style_index_0_lang$2 = "";
const _hoisted_1$5 = ["onClick"];
const _hoisted_2$5 = {
  key: 1,
  class: "dot"
};
const _hoisted_3$2 = {
  key: 2,
  class: "count"
};
const _hoisted_4$1 = {
  key: 0,
  class: "uno-pl-8"
};
const __default__$6 = {
  name: "WlRadioIcon"
};
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
  ...__default__$6,
  props: {
    isChoosed: { type: Boolean, default: false },
    disabled: { type: Boolean, default: false },
    size: { default: 18 },
    color: { default: "var(--wl-primary-color)" },
    count: { default: 1 },
    type: { default: "hook" },
    iconType: { default: "" },
    text: { default: "" }
  },
  emits: ["onClick"],
  setup(__props, { emit }) {
    const props = __props;
    useCssVars((_ctx) => ({
      "56e71e8b": unref(iconSize),
      "0a993a92": __props.color
    }));
    const isChecked = ref(false);
    const iconSize = computed(() => props.size + "px");
    const svgType = computed(() => props.type === "hook" ? "successFill" : props.iconType);
    const radioWrapClass = computed(() => {
      return `radio-wrap ${isChecked.value ? "" : "checked"}`;
    });
    const onClick = () => {
      if (props.disabled)
        return;
      emit("onClick", isChecked.value);
    };
    watchEffect(() => {
      isChecked.value = props.isChoosed;
    });
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", {
        class: "radio-icon-wrap",
        onClick: withModifiers(onClick, ["stop"]),
        "data-weiling-mobile-ui-wl-radio-icon": ""
      }, [
        createElementVNode("div", {
          class: normalizeClass(unref(radioWrapClass))
        }, [
          isChecked.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
            ["hook", "icon"].includes(__props.type) ? (openBlock(), createBlock(unref(WlSvg), {
              key: 0,
              type: unref(svgType),
              color: "var(--wl-primary-color)",
              height: unref(iconSize),
              width: unref(iconSize)
            }, null, 8, ["type", "height", "width"])) : __props.type === "dot" ? (openBlock(), createElementBlock("p", _hoisted_2$5)) : __props.type === "count" ? (openBlock(), createElementBlock("p", _hoisted_3$2, toDisplayString(__props.count), 1)) : createCommentVNode("", true)
          ], 64)) : createCommentVNode("", true)
        ], 2),
        __props.text ? (openBlock(), createElementBlock("p", _hoisted_4$1, toDisplayString(__props.text), 1)) : createCommentVNode("", true)
      ], 8, _hoisted_1$5);
    };
  }
});
var __uno = "";
_sfc_main$6.install = (app) => {
  app.component(_sfc_main$6.name, _sfc_main$6);
};
var index_vue_vue_type_style_index_0_scoped_true_lang$3 = "";
var _export_sfc = (sfc, props) => {
  const target = sfc.__vccOpts || sfc;
  for (const [key, val] of props) {
    target[key] = val;
  }
  return target;
};
const _hoisted_1$4 = ["onClick"];
const _hoisted_2$4 = { class: "choose-item-name" };
const _hoisted_3$1 = ["onClick"];
const __default__$5 = {
  name: "DepartmentList"
};
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
  ...__default__$5,
  props: {
    list: { default: () => [] },
    selectedList: { default: () => [] },
    isSelectAll: { type: Boolean, default: false }
  },
  emits: ["onChoose", "onMore", "update:isSelectAll"],
  setup(__props, { emit }) {
    const props = __props;
    let selectedLen = 0;
    const getCheckedStatus = (data, selectedList, index) => {
      if (index === 1) {
        selectedLen = 0;
      }
      const { parentIds = [], id = "", childrenIds = [] } = data;
      if (selectedList.findIndex((ele) => ele.id === id) !== -1) {
        if (index !== 0) {
          selectedLen++;
          if (index === props.list.length && selectedLen === props.list.length) {
            emit("update:isSelectAll", true);
          }
        }
        return "checked";
      }
      for (const iterator of parentIds) {
        if (selectedList.findIndex((ele) => ele.id === iterator) !== -1) {
          if (index !== 0) {
            selectedLen++;
            if (index === props.list.length && selectedLen === props.list.length) {
              emit("update:isSelectAll", true);
            }
          }
          return "checked";
        }
      }
      for (const iterator of childrenIds) {
        if (selectedList.findIndex((ele) => ele.id === iterator) !== -1) {
          emit("update:isSelectAll", false);
          return "pre-check";
        }
      }
      emit("update:isSelectAll", false);
      return "no-checked";
    };
    const getRadioIconType = computed(() => {
      return (item, index = 0) => {
        const typeDict = {
          "pre-check": "icon",
          "checked": "hook",
          "no-check": ""
        };
        const checkStatus = getCheckedStatus(item, props.selectedList, index);
        const type = typeDict[checkStatus];
        const icon = checkStatus === "pre-check" ? "prohibitFill" : "";
        const isChoosed = ["pre-check", "checked"].includes(checkStatus);
        return {
          type,
          icon,
          checkStatus,
          isChoosed
        };
      };
    });
    const onMore = (item) => emit("onMore", item);
    const onChoose = (item, status) => emit("onChoose", item, status);
    return (_ctx, _cache) => {
      return openBlock(true), createElementBlock(Fragment, null, renderList(__props.list, (item, index) => {
        return openBlock(), createElementBlock("div", {
          class: "choose-item",
          key: item.id,
          onClick: ($event) => onChoose(item, unref(getRadioIconType)(item).checkStatus)
        }, [
          createVNode(unref(_sfc_main$6), {
            type: unref(getRadioIconType)(item, index + 1).type,
            iconType: unref(getRadioIconType)(item).icon,
            isChoosed: unref(getRadioIconType)(item).isChoosed,
            onClick: ($event) => onChoose(item, unref(getRadioIconType)(item).checkStatus)
          }, null, 8, ["type", "iconType", "isChoosed", "onClick"]),
          createElementVNode("div", _hoisted_2$4, toDisplayString(item.name), 1),
          item.children && item.children.length > 0 ? (openBlock(), createElementBlock("div", {
            key: 0,
            class: "arrow",
            onClick: withModifiers(($event) => onMore(item), ["stop"])
          }, [
            createVNode(_sfc_main$c, {
              type: "arrowRight",
              width: "18",
              height: "18",
              color: "#919699"
            })
          ], 8, _hoisted_3$1)) : createCommentVNode("", true)
        ], 8, _hoisted_1$4);
      }), 128);
    };
  }
});
var DepartmentList = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-27b8cff0"]]);
var index_vue_vue_type_style_index_0_lang$1 = "";
const __default__$4 = {
  name: "WlButton"
};
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
  ...__default__$4,
  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$4.install = (app) => {
  app.component(_sfc_main$4.name, _sfc_main$4);
};
var index_vue_vue_type_style_index_0_scoped_true_lang$2 = "";
const _hoisted_1$3 = {
  key: 0,
  class: "text-swiper"
};
const _hoisted_2$3 = {
  key: 0,
  class: "text-swiper-list-item"
};
const __default__$3 = {
  name: "WlTextSwiper"
};
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
  ...__default__$3,
  props: {
    data: { default: () => [] },
    distance: { default: 30 }
  },
  setup(__props) {
    const props = __props;
    const leftArrowDisabled = ref(false);
    const rightArrowDisabled = ref(false);
    const scrollDiatance = ref(0);
    const swiperListRef = ref();
    const swiperScrollRef = ref();
    const hasSlot = computed(() => {
      let slots = useSlots();
      return !!slots.default;
    });
    const onChangeArrowColor = () => {
      nextTick(() => {
        var _a, _b;
        const scroll = ((_a = swiperScrollRef.value) == null ? void 0 : _a.clientWidth) - ((_b = swiperListRef.value) == null ? void 0 : _b.clientWidth);
        const isMore = Math.abs(scrollDiatance.value) >= scroll;
        leftArrowDisabled.value = scrollDiatance.value === 0;
        rightArrowDisabled.value = scroll < 0 || isMore;
      });
    };
    const scrollStyle = computed(() => {
      return {
        transform: `translateX(${scrollDiatance.value}px)`
      };
    });
    const scrollListLen = computed(() => props.data.length);
    const onScrollLeft = () => {
      if (!leftArrowDisabled.value) {
        scrollDiatance.value += props.distance;
        onChangeArrowColor();
      }
    };
    const onScrollRight = () => {
      if (!rightArrowDisabled.value) {
        scrollDiatance.value -= props.distance;
        onChangeArrowColor();
      }
    };
    watch(
      () => scrollListLen.value,
      () => {
        onChangeArrowColor();
      },
      { immediate: true }
    );
    return (_ctx, _cache) => {
      return __props.data.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_1$3, [
        createElementVNode("div", {
          class: "left-arrow",
          onClick: onScrollLeft
        }, [
          createVNode(_sfc_main$c, {
            type: "leftFill",
            width: "36",
            height: "36",
            color: leftArrowDisabled.value ? "#e3e3e3" : "var(--wl-primary-color)"
          }, null, 8, ["color"])
        ]),
        createElementVNode("div", {
          class: "text-swiper-list",
          ref_key: "swiperListRef",
          ref: swiperListRef
        }, [
          createElementVNode("div", {
            class: "text-swiper-list-container",
            style: normalizeStyle(unref(scrollStyle)),
            ref_key: "swiperScrollRef",
            ref: swiperScrollRef
          }, [
            (openBlock(true), createElementBlock(Fragment, null, renderList(__props.data, (item) => {
              return openBlock(), createElementBlock(Fragment, {
                key: item.id
              }, [
                !unref(hasSlot) ? (openBlock(), createElementBlock("p", _hoisted_2$3, toDisplayString(item.name), 1)) : renderSlot(_ctx.$slots, "default", {
                  key: 1,
                  row: item
                }, void 0, true)
              ], 64);
            }), 128))
          ], 4)
        ], 512),
        createElementVNode("div", {
          class: "right-arrow",
          onClick: onScrollRight
        }, [
          createVNode(_sfc_main$c, {
            type: "rightFill",
            width: "36",
            height: "36",
            color: rightArrowDisabled.value ? "#e3e3e3" : "var(--wl-primary-color)"
          }, null, 8, ["color"])
        ])
      ])) : createCommentVNode("", true);
    };
  }
});
var Comp$1 = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["__scopeId", "data-v-2c842030"]]);
Comp$1.install = (app) => {
  app.component(Comp$1.name, Comp$1);
};
var index_vue_vue_type_style_index_0_scoped_true_lang$1 = "";
const _hoisted_1$2 = { class: "department-footer" };
const _hoisted_2$2 = { class: "department-swiper" };
const _hoisted_3 = { class: "sure-btn-text" };
const _hoisted_4 = /* @__PURE__ */ createTextVNode("\u786E\u5B9A ");
const _hoisted_5 = { key: 0 };
const __default__$2 = {
  name: "DepartmentFooter"
};
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
  ...__default__$2,
  props: {
    list: { default: () => [] }
  },
  emits: ["onConfirm"],
  setup(__props, { emit }) {
    const props = __props;
    const checkedLen = computed(() => props.list.length);
    const onConfirm = () => {
      emit("onConfirm", props.list);
    };
    return (_ctx, _cache) => {
      return openBlock(), createElementBlock("div", _hoisted_1$2, [
        createElementVNode("div", _hoisted_2$2, [
          createVNode(unref(Comp$1), {
            data: __props.list,
            distance: 200
          }, null, 8, ["data"])
        ]),
        createVNode(unref(_sfc_main$4), {
          type: "primary",
          size: "normal",
          onOnClick: onConfirm,
          class: "sure-btn"
        }, {
          default: withCtx(() => [
            createElementVNode("p", _hoisted_3, [
              _hoisted_4,
              unref(checkedLen) > 0 ? (openBlock(), createElementBlock("span", _hoisted_5, toDisplayString(unref(checkedLen)), 1)) : createCommentVNode("", true)
            ])
          ]),
          _: 1
        })
      ]);
    };
  }
});
var DepartmentFooter = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["__scopeId", "data-v-5e9ced7d"]]);
var index_vue_vue_type_style_index_0_lang = "";
const _hoisted_1$1 = { class: "header-part-left" };
const _hoisted_2$1 = { class: "header-part-right" };
const __default__$1 = {
  name: "DepartmentHeader"
};
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
  ...__default__$1,
  props: {
    showBtn: { type: Boolean, default: false },
    showBack: { type: Boolean, default: false },
    isAllChecked: { type: Boolean, default: false }
  },
  emits: ["onBack", "onClose", "onChooseAll"],
  setup(__props, { emit }) {
    const props = __props;
    const allCheckedBool = ref(false);
    const checkedText = computed(() => {
      return allCheckedBool.value ? "\u53D6\u6D88\u5168\u9009" : "\u5168\u9009";
    });
    const all_checked_class = computed(() => {
      return {
        "choose-all": true,
        "isAllChecked": allCheckedBool.value
      };
    });
    const onBack = () => emit("onBack");
    const onClose = () => emit("onClose");
    const onChooseAll = () => {
      allCheckedBool.value = !allCheckedBool.value;
      emit("onChooseAll", allCheckedBool.value);
    };
    watchEffect(() => {
      allCheckedBool.value = props.isAllChecked;
    });
    return (_ctx, _cache) => {
      return openBlock(), createBlock(_sfc_main$8, { title: "\u9009\u62E9\u90E8\u95E8" }, {
        header_part_left: withCtx(() => [
          createElementVNode("div", _hoisted_1$1, [
            __props.showBack ? (openBlock(), createElementBlock("div", {
              key: 0,
              class: "back-icon",
              onClick: onBack
            }, [
              createVNode(_sfc_main$c, {
                type: "arrowTipLeft",
                width: "30",
                height: "30",
                color: "#000"
              })
            ])) : createCommentVNode("", true),
            createElementVNode("div", {
              class: "close-icon",
              onClick: onClose
            }, [
              createVNode(_sfc_main$c, {
                type: "close",
                width: "30",
                height: "30",
                color: "#000"
              })
            ])
          ])
        ]),
        header_part_right: withCtx(() => [
          createElementVNode("div", _hoisted_2$1, [
            createElementVNode("div", {
              class: normalizeClass(unref(all_checked_class)),
              onClick: onChooseAll
            }, toDisplayString(unref(checkedText)), 3)
          ])
        ]),
        _: 1
      });
    };
  }
});
var index_vue_vue_type_style_index_0_scoped_true_lang = "";
const _hoisted_1 = { class: "popup-content" };
const _hoisted_2 = { class: "main-wrap" };
const __default__ = {
  name: "BCDepartmentSelectorPopup"
};
const _sfc_main = /* @__PURE__ */ defineComponent({
  ...__default__,
  props: {
    show: { type: Boolean, default: false },
    envData: { default: null },
    defaultData: { default: () => [] }
  },
  emits: ["onClose", "update:show", "onConfirm"],
  setup(__props, { emit }) {
    const props = __props;
    const { onGetData } = useHandleData();
    const { stack, showBack, currentList, onChangeStack, onPopStack, onAddStack } = useStack();
    const { checkedList, checkedIds, onAddCheckdList, onGetCheckedList, onSetCheckedbyIds } = useCheckedData();
    const popupVisible = ref(false);
    const isAllChecked = ref(false);
    const originTreeData = ref(null);
    const checkedListArr = ref(props.defaultData);
    const isSelectAllBool = ref(false);
    const checkedListIds = computed(() => checkedListArr.value.map((res) => res.id));
    const onGetIndex = (list, id) => {
      return (list != null ? list : []).findIndex((ele) => ele.id === id);
    };
    const onJudgeExist = (list, id) => {
      return onGetIndex(list, id) !== -1;
    };
    const onGetDefauleData = (list, selectVal) => {
      if (!(list == null ? void 0 : list.length))
        return [];
      let data = [];
      list.forEach((element) => {
        const { id = "", children = [] } = element;
        if (onJudgeExist(selectVal, id)) {
          data.push(element);
        } else {
          const childSelect = onGetDefauleData(children, selectVal);
          data = [...data, ...childSelect];
        }
      });
      return data;
    };
    watch(
      () => [props.defaultData, originTreeData.value],
      () => {
        var _a, _b, _c;
        if (((_a = props.defaultData) == null ? void 0 : _a.length) !== 0) {
          let data = onGetDefauleData(toRaw(originTreeData.value), props.defaultData);
          if (((_b = props.defaultData) == null ? void 0 : _b.length) !== data.length) {
            const unEmpowerData = ((_c = props.defaultData) != null ? _c : []).filter(
              (ele) => !onJudgeExist(data, ele.id)
            );
            data = data.concat(unEmpowerData);
          }
          checkedListArr.value = data;
        }
      }
    );
    const unSelectAll = (list, selectedList) => {
      if (list.length === 0)
        return;
      for (const iterator of list) {
        selectedList = unSelect(iterator, selectedList, originTreeData.value);
      }
      return selectedList;
    };
    const onSelectItem = (item, selectedList) => {
      const { childrenIds } = item;
      const data = [];
      if (selectedList.length !== 0) {
        for (const iterator of selectedList) {
          if (!childrenIds.includes(iterator.id) && !checkedListIds.value.includes(item.id)) {
            data.push(iterator);
          }
        }
      }
      data.push(item);
      return data;
    };
    const selectAll = (list, selectedList) => {
      console.log("\u9009\u62E9\u6240\u6709\u7684", list, selectedList);
      const [item] = list;
      const { parentIds = [] } = item;
      const [parent] = parentIds;
      if (onJudgeExist(selectedList, parent))
        return selectedList;
      for (const iterator of list) {
        selectedList = onSelectItem(iterator, selectedList);
      }
      return selectedList;
    };
    const getNode = (list, id) => {
      for (const iterator of list) {
        if (id === iterator.id) {
          return iterator;
        }
        const { children = [] } = iterator;
        const data = getNode(children, id);
        if (data) {
          return data;
        }
      }
      return null;
    };
    const unSelect = (item, selectedList, list) => {
      const { id = "", parentIds = [] } = item;
      const index = onGetIndex(selectedList, id);
      if (index !== -1) {
        return [...selectedList.slice(0, index), ...selectedList.slice(index + 1)];
      }
      let parentId = "", parentIndex = 0;
      for (const iterator of parentIds) {
        const i = onGetIndex(selectedList, iterator);
        if (i !== -1) {
          parentId = iterator;
          selectedList.splice(i, 1);
          break;
        }
        parentIndex++;
      }
      const parentNode = getNode(list, parentId);
      let { children = [] } = parentNode;
      for (let i = parentIndex; i >= 0; i--) {
        if (i === 0) {
          children.forEach((ele) => {
            if (ele.id !== id) {
              selectedList.push(ele);
            }
          });
        } else {
          const pId = parentIds[i - 1];
          let nextIndex = 0;
          children.forEach((element, index2) => {
            if (element.id !== pId) {
              selectedList.push(element);
            } else {
              nextIndex = index2;
            }
          });
          const nextChild = children[nextIndex];
          if (nextChild) {
            children = nextChild.children;
          }
        }
      }
      return selectedList;
    };
    const onChooseAll = (bool) => {
      if (bool) {
        checkedListArr.value = selectAll(currentList.value, checkedListArr.value);
      } else {
        checkedListArr.value = unSelectAll(currentList.value, checkedListArr.value);
      }
    };
    const onChangeChooseAllStatus = () => {
      isAllChecked.value = currentList.value.every((item) => item.checkedStatus === "checked");
    };
    const onChoose = (item, status) => {
      if (status === "checked") {
        checkedListArr.value = unSelect(item, checkedListArr.value, originTreeData.value);
      } else {
        checkedListArr.value = onSelectItem(item, checkedListArr.value);
      }
    };
    const getParentItem = () => {
      const parentId = currentList.value[0].pid;
      const parentList = stack.value[stack.value.length - 2];
      const parentItem = parentList.filter((res) => res.id === parentId);
      return parentItem.length > 0 ? parentItem[0] : {};
    };
    const onSetParentCheckedStatus = () => {
      if (stack.value.length <= 1)
        return;
      const currentListLen = currentList.value.length;
      const parentItem = getParentItem();
      let order = currentList.value.length - 1;
      let parentStatus = "no-check";
      let noCheckedCount = 0;
      let showInCheckedList = true;
      while (order >= 0) {
        const cur = currentList.value[order];
        if (cur.checkedStatus === "pre-check") {
          break;
        } else if (cur.checkedStatus === "no-check") {
          noCheckedCount++;
        }
        order--;
      }
      if (noCheckedCount === currentListLen) {
        parentStatus = "no-check";
      } else {
        parentStatus = "pre-check";
        showInCheckedList = false;
      }
      parentItem.checkedStatus = parentStatus;
      parentItem.showInCheckedList = showInCheckedList;
      if (["pre-check", "checked"].includes(parentStatus))
        onAddCheckdList([parentItem]);
    };
    const onGetMoreData = (item) => {
      var _a;
      return ((_a = item.children) != null ? _a : []).reduce((acc, res) => {
        var _a2;
        let status = "no-check", showInCheckedList = true;
        if (item.checkedStatus === "checked") {
          status = "checked";
          showInCheckedList = false;
        } else if (item.checkedStatus === "pre-check") {
          const idx = ((_a2 = checkedIds.value) != null ? _a2 : []).findIndex((id) => res.id === id);
          status = idx === -1 ? "no-check" : checkedList.value[idx].checkedStatus;
        }
        return acc.concat({
          ...res,
          showInCheckedList,
          checkedStatus: status
        });
      }, []);
    };
    const onMore = (item) => {
      isSelectAllBool.value = false;
      const moreList = onGetMoreData(item);
      onPushData(moreList);
      onChangeChooseAllStatus();
      onAddCheckdList(onGetCheckedList(moreList));
    };
    const onConfirm = (list) => {
      emit("onConfirm", toRaw(list));
    };
    const onPushData = (list) => onAddStack(list);
    const onBack = () => {
      if (stack.value.length < 2)
        return;
      onSetParentCheckedStatus();
      onPopStack();
      onChangeChooseAllStatus();
    };
    const onClose = () => {
      emit("onClose");
      emit("update:show", false);
      popupVisible.value = false;
    };
    const onSetDefaultData = () => {
      var _a;
      if (((_a = props.defaultData) != null ? _a : []).length === 0)
        return;
      const filterData = props.defaultData.map((res) => {
        return { ...res, checkedStatus: "checked", showInCheckedList: true };
      });
      onAddCheckdList(filterData);
      const ids = filterData.map((res) => res.id);
      onChangeStack(onSetCheckedbyIds(originTreeData.value, ids));
      onChangeChooseAllStatus();
    };
    Store$1.sid = props.envData.sid;
    Store$1.token = props.envData.token;
    Store$1.corp_id = props.envData.corp_id;
    Store$1.node_env = props.envData.node_env;
    Store$1.card_resource = props.envData.card_resource;
    watchEffect(() => {
      popupVisible.value = props.show;
    });
    onGetData().then((data) => {
      onPushData(data);
      originTreeData.value = data;
    });
    const setDefaultDataComputed = computed(() => {
      return originTreeData.value && props.defaultData;
    });
    watch(
      () => setDefaultDataComputed.value,
      () => onSetDefaultData()
    );
    return (_ctx, _cache) => {
      return openBlock(), createBlock(_sfc_main$7, {
        class: "department-selector-wrap",
        "data-weiling-mobile-ui-bc-department-selector-popup": "",
        modelValue: popupVisible.value,
        "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => popupVisible.value = $event),
        style: { height: "90%" },
        position: "bottom",
        round: "",
        onClosed: onClose
      }, {
        default: withCtx(() => [
          createElementVNode("div", _hoisted_1, [
            createVNode(_sfc_main$1, {
              showBack: unref(showBack),
              isAllChecked: isSelectAllBool.value,
              onOnBack: onBack,
              onOnClose: onClose,
              onOnChooseAll: onChooseAll
            }, null, 8, ["showBack", "isAllChecked"]),
            createElementVNode("div", _hoisted_2, [
              createVNode(DepartmentList, {
                isSelectAll: isSelectAllBool.value,
                "onUpdate:isSelectAll": _cache[0] || (_cache[0] = ($event) => isSelectAllBool.value = $event),
                list: unref(currentList),
                selectedList: checkedListArr.value,
                onOnChoose: onChoose,
                onOnMore: onMore
              }, null, 8, ["isSelectAll", "list", "selectedList"])
            ]),
            createVNode(DepartmentFooter, {
              list: checkedListArr.value,
              onOnConfirm: onConfirm
            }, null, 8, ["list"])
          ])
        ]),
        _: 1
      }, 8, ["modelValue"]);
    };
  }
});
var Comp = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-1635fe32"]]);
Comp.install = (app) => {
  app.component(Comp.name, Comp);
};
export { Comp as default };
