import {
  Icon,
  useGlobalZIndex
} from "./chunk-ABCXCBTJ.js";
import {
  HAPTICS_FEEDBACK,
  TAP_OFFSET,
  addUnit,
  callInterceptor,
  createNamespace,
  extend,
  getScrollParent,
  getSizeStyle,
  getZIndexStyle,
  isDef,
  makeArrayProp,
  makeStringProp,
  numericProp,
  onMountedOrActivated,
  pick,
  preventDefault,
  truthProp,
  unknownProp,
  useEventListener,
  withInstall
} from "./chunk-VTNTUAMG.js";

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/action-sheet/ActionSheet.mjs
import { nextTick as nextTick2, defineComponent as defineComponent4, createVNode as _createVNode4, mergeProps as _mergeProps3 } from "vue";

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/popup/Popup.mjs
import { ref as ref4, watch as watch4, provide, Teleport as Teleport2, nextTick, computed, onMounted, Transition as Transition2, onActivated, onDeactivated as onDeactivated2, defineComponent as defineComponent2, mergeProps as _mergeProps2, createVNode as _createVNode2, vShow as _vShow2, withDirectives as _withDirectives2, Fragment as _Fragment } from "vue";

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/popup/shared.mjs
var popupSharedProps = {
  // whether to show popup
  show: Boolean,
  // z-index
  zIndex: numericProp,
  // whether to show overlay
  overlay: truthProp,
  // transition duration
  duration: numericProp,
  // teleport
  teleport: [String, Object],
  // prevent body scroll
  lockScroll: truthProp,
  // whether to lazy render
  lazyRender: truthProp,
  // callback function before close
  beforeClose: Function,
  // overlay props
  overlayProps: Object,
  // overlay custom style
  overlayStyle: Object,
  // overlay custom class name
  overlayClass: unknownProp,
  // Initial rendering animation
  transitionAppear: Boolean,
  // whether to close popup when overlay is clicked
  closeOnClickOverlay: truthProp
};
var popupSharedPropKeys = Object.keys(
  popupSharedProps
);

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/composables/use-expose.mjs
import { getCurrentInstance } from "vue";
function useExpose(apis) {
  const instance = getCurrentInstance();
  if (instance) {
    extend(instance.proxy, apis);
  }
}

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/composables/use-lock-scroll.mjs
import { watch, onBeforeUnmount, onDeactivated } from "vue";

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/composables/use-touch.mjs
import { ref } from "vue";
function getDirection(x, y) {
  if (x > y) {
    return "horizontal";
  }
  if (y > x) {
    return "vertical";
  }
  return "";
}
function useTouch() {
  const startX = ref(0);
  const startY = ref(0);
  const deltaX = ref(0);
  const deltaY = ref(0);
  const offsetX = ref(0);
  const offsetY = ref(0);
  const direction = ref("");
  const isTap = ref(true);
  const isVertical = () => direction.value === "vertical";
  const isHorizontal = () => direction.value === "horizontal";
  const reset = () => {
    deltaX.value = 0;
    deltaY.value = 0;
    offsetX.value = 0;
    offsetY.value = 0;
    direction.value = "";
    isTap.value = true;
  };
  const start = (event) => {
    reset();
    startX.value = event.touches[0].clientX;
    startY.value = event.touches[0].clientY;
  };
  const move = (event) => {
    const touch = event.touches[0];
    deltaX.value = (touch.clientX < 0 ? 0 : touch.clientX) - startX.value;
    deltaY.value = touch.clientY - startY.value;
    offsetX.value = Math.abs(deltaX.value);
    offsetY.value = Math.abs(deltaY.value);
    const LOCK_DIRECTION_DISTANCE = 10;
    if (!direction.value || offsetX.value < LOCK_DIRECTION_DISTANCE && offsetY.value < LOCK_DIRECTION_DISTANCE) {
      direction.value = getDirection(offsetX.value, offsetY.value);
    }
    if (isTap.value && (offsetX.value > TAP_OFFSET || offsetY.value > TAP_OFFSET)) {
      isTap.value = false;
    }
  };
  return {
    move,
    start,
    reset,
    startX,
    startY,
    deltaX,
    deltaY,
    offsetX,
    offsetY,
    direction,
    isVertical,
    isHorizontal,
    isTap
  };
}

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/composables/use-lock-scroll.mjs
var totalLockCount = 0;
var BODY_LOCK_CLASS = "van-overflow-hidden";
function useLockScroll(rootRef, shouldLock) {
  const touch = useTouch();
  const DIRECTION_UP = "01";
  const DIRECTION_DOWN = "10";
  const onTouchMove = (event) => {
    touch.move(event);
    const direction = touch.deltaY.value > 0 ? DIRECTION_DOWN : DIRECTION_UP;
    const el = getScrollParent(
      event.target,
      rootRef.value
    );
    const { scrollHeight, offsetHeight, scrollTop } = el;
    let status = "11";
    if (scrollTop === 0) {
      status = offsetHeight >= scrollHeight ? "00" : "01";
    } else if (scrollTop + offsetHeight >= scrollHeight) {
      status = "10";
    }
    if (status !== "11" && touch.isVertical() && !(parseInt(status, 2) & parseInt(direction, 2))) {
      preventDefault(event, true);
    }
  };
  const lock = () => {
    document.addEventListener("touchstart", touch.start);
    document.addEventListener("touchmove", onTouchMove, { passive: false });
    if (!totalLockCount) {
      document.body.classList.add(BODY_LOCK_CLASS);
    }
    totalLockCount++;
  };
  const unlock = () => {
    if (totalLockCount) {
      document.removeEventListener("touchstart", touch.start);
      document.removeEventListener("touchmove", onTouchMove);
      totalLockCount--;
      if (!totalLockCount) {
        document.body.classList.remove(BODY_LOCK_CLASS);
      }
    }
  };
  const init = () => shouldLock() && lock();
  const destroy = () => shouldLock() && unlock();
  onMountedOrActivated(init);
  onDeactivated(destroy);
  onBeforeUnmount(destroy);
  watch(shouldLock, (value) => {
    value ? lock() : unlock();
  });
}

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/composables/use-lazy-render.mjs
import { ref as ref2, watch as watch2 } from "vue";
function useLazyRender(show) {
  const inited = ref2(false);
  watch2(
    show,
    (value) => {
      if (value) {
        inited.value = value;
      }
    },
    { immediate: true }
  );
  return (render) => () => inited.value ? render() : null;
}

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/composables/on-popup-reopen.mjs
import { inject, watch as watch3 } from "vue";
var POPUP_TOGGLE_KEY = Symbol();
function onPopupReopen(callback) {
  const popupToggleStatus = inject(POPUP_TOGGLE_KEY, null);
  if (popupToggleStatus) {
    watch3(popupToggleStatus, (show) => {
      if (show) {
        callback();
      }
    });
  }
}

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/composables/use-scope-id.mjs
import { getCurrentInstance as getCurrentInstance2 } from "vue";
var useScopeId = () => {
  var _a;
  const { scopeId } = ((_a = getCurrentInstance2()) == null ? void 0 : _a.vnode) || {};
  return scopeId ? { [scopeId]: "" } : null;
};

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/overlay/Overlay.mjs
import { ref as ref3, defineComponent, Teleport, Transition, vShow as _vShow, mergeProps as _mergeProps, createVNode as _createVNode, withDirectives as _withDirectives } from "vue";
var [name, bem] = createNamespace("overlay");
var overlayProps = {
  show: Boolean,
  zIndex: numericProp,
  duration: numericProp,
  className: unknownProp,
  lockScroll: truthProp,
  lazyRender: truthProp,
  customStyle: Object,
  teleport: [String, Object]
};
var stdin_default = defineComponent({
  name,
  inheritAttrs: false,
  props: overlayProps,
  setup(props, {
    attrs,
    slots
  }) {
    const root = ref3();
    const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
    const onTouchMove = (event) => {
      if (props.lockScroll) {
        preventDefault(event, true);
      }
    };
    const renderOverlay = lazyRender(() => {
      var _a;
      const style = extend(getZIndexStyle(props.zIndex), props.customStyle);
      if (isDef(props.duration)) {
        style.animationDuration = `${props.duration}s`;
      }
      return _withDirectives(_createVNode("div", _mergeProps({
        "ref": root,
        "style": style,
        "class": [bem(), props.className]
      }, attrs), [(_a = slots.default) == null ? void 0 : _a.call(slots)]), [[_vShow, props.show]]);
    });
    useEventListener("touchmove", onTouchMove, {
      target: root
    });
    return () => {
      const Content = _createVNode(Transition, {
        "name": "van-fade",
        "appear": true
      }, {
        default: renderOverlay
      });
      if (props.teleport) {
        return _createVNode(Teleport, {
          "to": props.teleport
        }, {
          default: () => [Content]
        });
      }
      return Content;
    };
  }
});

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/overlay/index.mjs
var Overlay = withInstall(stdin_default);

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/popup/Popup.mjs
var popupProps = extend({}, popupSharedProps, {
  round: Boolean,
  position: makeStringProp("center"),
  closeIcon: makeStringProp("cross"),
  closeable: Boolean,
  transition: String,
  iconPrefix: String,
  closeOnPopstate: Boolean,
  closeIconPosition: makeStringProp("top-right"),
  destroyOnClose: Boolean,
  safeAreaInsetTop: Boolean,
  safeAreaInsetBottom: Boolean
});
var [name2, bem2] = createNamespace("popup");
var stdin_default2 = defineComponent2({
  name: name2,
  inheritAttrs: false,
  props: popupProps,
  emits: ["open", "close", "opened", "closed", "keydown", "update:show", "clickOverlay", "clickCloseIcon"],
  setup(props, {
    emit,
    attrs,
    slots
  }) {
    let opened;
    let shouldReopen;
    const zIndex = ref4();
    const popupRef = ref4();
    const lazyRender = useLazyRender(() => props.show || !props.lazyRender);
    const style = computed(() => {
      const style2 = {
        zIndex: zIndex.value
      };
      if (isDef(props.duration)) {
        const key = props.position === "center" ? "animationDuration" : "transitionDuration";
        style2[key] = `${props.duration}s`;
      }
      return style2;
    });
    const open = () => {
      if (!opened) {
        opened = true;
        zIndex.value = props.zIndex !== void 0 ? +props.zIndex : useGlobalZIndex();
        emit("open");
      }
    };
    const close = () => {
      if (opened) {
        callInterceptor(props.beforeClose, {
          done() {
            opened = false;
            emit("close");
            emit("update:show", false);
          }
        });
      }
    };
    const onClickOverlay = (event) => {
      emit("clickOverlay", event);
      if (props.closeOnClickOverlay) {
        close();
      }
    };
    const renderOverlay = () => {
      if (props.overlay) {
        const overlayProps2 = extend({
          show: props.show,
          class: props.overlayClass,
          zIndex: zIndex.value,
          duration: props.duration,
          customStyle: props.overlayStyle,
          role: props.closeOnClickOverlay ? "button" : void 0,
          tabindex: props.closeOnClickOverlay ? 0 : void 0
        }, props.overlayProps);
        return _createVNode2(Overlay, _mergeProps2(overlayProps2, useScopeId(), {
          "onClick": onClickOverlay
        }), {
          default: slots["overlay-content"]
        });
      }
    };
    const onClickCloseIcon = (event) => {
      emit("clickCloseIcon", event);
      close();
    };
    const renderCloseIcon = () => {
      if (props.closeable) {
        return _createVNode2(Icon, {
          "role": "button",
          "tabindex": 0,
          "name": props.closeIcon,
          "class": [bem2("close-icon", props.closeIconPosition), HAPTICS_FEEDBACK],
          "classPrefix": props.iconPrefix,
          "onClick": onClickCloseIcon
        }, null);
      }
    };
    let timer;
    const onOpened = () => {
      if (timer)
        clearTimeout(timer);
      timer = setTimeout(() => {
        emit("opened");
      });
    };
    const onClosed = () => emit("closed");
    const onKeydown = (event) => emit("keydown", event);
    const renderPopup = lazyRender(() => {
      var _a;
      const {
        destroyOnClose,
        round,
        position,
        safeAreaInsetTop,
        safeAreaInsetBottom,
        show
      } = props;
      if (!show && destroyOnClose) {
        return;
      }
      return _withDirectives2(_createVNode2("div", _mergeProps2({
        "ref": popupRef,
        "style": style.value,
        "role": "dialog",
        "tabindex": 0,
        "class": [bem2({
          round,
          [position]: position
        }), {
          "van-safe-area-top": safeAreaInsetTop,
          "van-safe-area-bottom": safeAreaInsetBottom
        }],
        "onKeydown": onKeydown
      }, attrs, useScopeId()), [(_a = slots.default) == null ? void 0 : _a.call(slots), renderCloseIcon()]), [[_vShow2, show]]);
    });
    const renderTransition = () => {
      const {
        position,
        transition,
        transitionAppear
      } = props;
      const name22 = position === "center" ? "van-fade" : `van-popup-slide-${position}`;
      return _createVNode2(Transition2, {
        "name": transition || name22,
        "appear": transitionAppear,
        "onAfterEnter": onOpened,
        "onAfterLeave": onClosed
      }, {
        default: renderPopup
      });
    };
    watch4(() => props.show, (show) => {
      if (show && !opened) {
        open();
        if (attrs.tabindex === 0) {
          nextTick(() => {
            var _a;
            (_a = popupRef.value) == null ? void 0 : _a.focus();
          });
        }
      }
      if (!show && opened) {
        opened = false;
        emit("close");
      }
    });
    useExpose({
      popupRef
    });
    useLockScroll(popupRef, () => props.show && props.lockScroll);
    useEventListener("popstate", () => {
      if (props.closeOnPopstate) {
        close();
        shouldReopen = false;
      }
    });
    onMounted(() => {
      if (props.show) {
        open();
      }
    });
    onActivated(() => {
      if (shouldReopen) {
        emit("update:show", true);
        shouldReopen = false;
      }
    });
    onDeactivated2(() => {
      if (props.show && props.teleport) {
        close();
        shouldReopen = true;
      }
    });
    provide(POPUP_TOGGLE_KEY, () => props.show);
    return () => {
      if (props.teleport) {
        return _createVNode2(Teleport2, {
          "to": props.teleport
        }, {
          default: () => [renderOverlay(), renderTransition()]
        });
      }
      return _createVNode2(_Fragment, null, [renderOverlay(), renderTransition()]);
    };
  }
});

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/popup/index.mjs
var Popup = withInstall(stdin_default2);

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/loading/Loading.mjs
import { computed as computed2, defineComponent as defineComponent3, createVNode as _createVNode3 } from "vue";
var [name3, bem3] = createNamespace("loading");
var SpinIcon = Array(12).fill(null).map((_, index) => _createVNode3("i", {
  "class": bem3("line", String(index + 1))
}, null));
var CircularIcon = _createVNode3("svg", {
  "class": bem3("circular"),
  "viewBox": "25 25 50 50"
}, [_createVNode3("circle", {
  "cx": "50",
  "cy": "50",
  "r": "20",
  "fill": "none"
}, null)]);
var loadingProps = {
  size: numericProp,
  type: makeStringProp("circular"),
  color: String,
  vertical: Boolean,
  textSize: numericProp,
  textColor: String
};
var stdin_default3 = defineComponent3({
  name: name3,
  props: loadingProps,
  setup(props, {
    slots
  }) {
    const spinnerStyle = computed2(() => extend({
      color: props.color
    }, getSizeStyle(props.size)));
    const renderIcon = () => {
      const DefaultIcon = props.type === "spinner" ? SpinIcon : CircularIcon;
      return _createVNode3("span", {
        "class": bem3("spinner", props.type),
        "style": spinnerStyle.value
      }, [slots.icon ? slots.icon() : DefaultIcon]);
    };
    const renderText = () => {
      var _a;
      if (slots.default) {
        return _createVNode3("span", {
          "class": bem3("text"),
          "style": {
            fontSize: addUnit(props.textSize),
            color: (_a = props.textColor) != null ? _a : props.color
          }
        }, [slots.default()]);
      }
    };
    return () => {
      const {
        type,
        vertical
      } = props;
      return _createVNode3("div", {
        "class": bem3([type, {
          vertical
        }]),
        "aria-live": "polite",
        "aria-busy": true
      }, [renderIcon(), renderText()]);
    };
  }
});

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/loading/index.mjs
var Loading = withInstall(stdin_default3);

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/action-sheet/ActionSheet.mjs
var [name4, bem4] = createNamespace("action-sheet");
var actionSheetProps = extend({}, popupSharedProps, {
  title: String,
  round: truthProp,
  actions: makeArrayProp(),
  closeIcon: makeStringProp("cross"),
  closeable: truthProp,
  cancelText: String,
  description: String,
  closeOnPopstate: truthProp,
  closeOnClickAction: Boolean,
  safeAreaInsetBottom: truthProp
});
var popupInheritKeys = [...popupSharedPropKeys, "round", "closeOnPopstate", "safeAreaInsetBottom"];
var stdin_default4 = defineComponent4({
  name: name4,
  props: actionSheetProps,
  emits: ["select", "cancel", "update:show"],
  setup(props, {
    slots,
    emit
  }) {
    const updateShow = (show) => emit("update:show", show);
    const onCancel = () => {
      updateShow(false);
      emit("cancel");
    };
    const renderHeader = () => {
      if (props.title) {
        return _createVNode4("div", {
          "class": bem4("header")
        }, [props.title, props.closeable && _createVNode4(Icon, {
          "name": props.closeIcon,
          "class": [bem4("close"), HAPTICS_FEEDBACK],
          "onClick": onCancel
        }, null)]);
      }
    };
    const renderCancel = () => {
      if (slots.cancel || props.cancelText) {
        return [_createVNode4("div", {
          "class": bem4("gap")
        }, null), _createVNode4("button", {
          "type": "button",
          "class": bem4("cancel"),
          "onClick": onCancel
        }, [slots.cancel ? slots.cancel() : props.cancelText])];
      }
    };
    const renderIcon = (action) => {
      if (action.icon) {
        return _createVNode4(Icon, {
          "class": bem4("item-icon"),
          "name": action.icon
        }, null);
      }
    };
    const renderActionContent = (action, index) => {
      if (action.loading) {
        return _createVNode4(Loading, {
          "class": bem4("loading-icon")
        }, null);
      }
      if (slots.action) {
        return slots.action({
          action,
          index
        });
      }
      return [_createVNode4("span", {
        "class": bem4("name")
      }, [action.name]), action.subname && _createVNode4("div", {
        "class": bem4("subname")
      }, [action.subname])];
    };
    const renderAction = (action, index) => {
      const {
        color,
        loading,
        callback,
        disabled,
        className
      } = action;
      const onClick = () => {
        if (disabled || loading) {
          return;
        }
        if (callback) {
          callback(action);
        }
        if (props.closeOnClickAction) {
          updateShow(false);
        }
        nextTick2(() => emit("select", action, index));
      };
      return _createVNode4("button", {
        "type": "button",
        "style": {
          color
        },
        "class": [bem4("item", {
          loading,
          disabled
        }), className],
        "onClick": onClick
      }, [renderIcon(action), renderActionContent(action, index)]);
    };
    const renderDescription = () => {
      if (props.description || slots.description) {
        const content = slots.description ? slots.description() : props.description;
        return _createVNode4("div", {
          "class": bem4("description")
        }, [content]);
      }
    };
    return () => _createVNode4(Popup, _mergeProps3({
      "class": bem4(),
      "position": "bottom",
      "onUpdate:show": updateShow
    }, pick(props, popupInheritKeys)), {
      default: () => {
        var _a;
        return [renderHeader(), renderDescription(), _createVNode4("div", {
          "class": bem4("content")
        }, [props.actions.map(renderAction), (_a = slots.default) == null ? void 0 : _a.call(slots)]), renderCancel()];
      }
    });
  }
});

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/action-sheet/index.mjs
var ActionSheet = withInstall(stdin_default4);
var stdin_default5 = ActionSheet;

export {
  popupSharedProps,
  popupSharedPropKeys,
  useExpose,
  useTouch,
  useLockScroll,
  useLazyRender,
  onPopupReopen,
  useScopeId,
  overlayProps,
  Overlay,
  popupProps,
  Popup,
  loadingProps,
  Loading,
  actionSheetProps,
  ActionSheet,
  stdin_default5 as stdin_default
};
//# sourceMappingURL=chunk-OG3FNEFL.js.map
