import {
  Loading
} from "./chunk-4C6QPDC3.js";
import {
  Popup,
  popupSharedPropKeys,
  popupSharedProps
} from "./chunk-ILUPPEMR.js";
import {
  Icon
} from "./chunk-D5TWCK54.js";
import {
  HAPTICS_FEEDBACK,
  createNamespace,
  extend,
  makeArrayProp,
  makeStringProp,
  pick,
  truthProp,
  withInstall
} from "./chunk-6TMJMNX7.js";

// ../../../../../ProjectSpace/UniAppSpace/nurseapp_v3/node_modules/vant/es/action-sheet/ActionSheet.mjs
import { nextTick, defineComponent, createVNode as _createVNode, mergeProps as _mergeProps } from "vue";
var [name, bem] = 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_default = defineComponent({
  name,
  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 _createVNode("div", {
          "class": bem("header")
        }, [props.title, props.closeable && _createVNode(Icon, {
          "name": props.closeIcon,
          "class": [bem("close"), HAPTICS_FEEDBACK],
          "onClick": onCancel
        }, null)]);
      }
    };
    const renderCancel = () => {
      if (slots.cancel || props.cancelText) {
        return [_createVNode("div", {
          "class": bem("gap")
        }, null), _createVNode("button", {
          "type": "button",
          "class": bem("cancel"),
          "onClick": onCancel
        }, [slots.cancel ? slots.cancel() : props.cancelText])];
      }
    };
    const renderIcon = (action) => {
      if (action.icon) {
        return _createVNode(Icon, {
          "class": bem("item-icon"),
          "name": action.icon
        }, null);
      }
    };
    const renderActionContent = (action, index) => {
      if (action.loading) {
        return _createVNode(Loading, {
          "class": bem("loading-icon")
        }, null);
      }
      if (slots.action) {
        return slots.action({
          action,
          index
        });
      }
      return [_createVNode("span", {
        "class": bem("name")
      }, [action.name]), action.subname && _createVNode("div", {
        "class": bem("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);
        }
        nextTick(() => emit("select", action, index));
      };
      return _createVNode("button", {
        "type": "button",
        "style": {
          color
        },
        "class": [bem("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 _createVNode("div", {
          "class": bem("description")
        }, [content]);
      }
    };
    return () => _createVNode(Popup, _mergeProps({
      "class": bem(),
      "position": "bottom",
      "onUpdate:show": updateShow
    }, pick(props, popupInheritKeys)), {
      default: () => {
        var _a;
        return [renderHeader(), renderDescription(), _createVNode("div", {
          "class": bem("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_default);
var stdin_default2 = ActionSheet;

export {
  actionSheetProps,
  ActionSheet,
  stdin_default2 as stdin_default
};
//# sourceMappingURL=chunk-UVZZP7IK.js.map
