"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const usePlaceholder = require("../composables/use-placeholder.js");
const index = require("../icon/index.js");
const props = require("../utils/props.js");
const create = require("../utils/create.js");
const format = require("../utils/format.js");
const constant = require("../utils/constant.js");
const [name, bem] = create.createNamespace("nav-bar");
const navBarProps = {
  title: String,
  fixed: Boolean,
  zIndex: props.numericProp,
  border: props.truthProp,
  leftText: String,
  rightText: String,
  leftDisabled: Boolean,
  rightDisabled: Boolean,
  leftArrow: Boolean,
  placeholder: Boolean,
  safeAreaInsetTop: Boolean,
  clickable: props.truthProp
};
var stdin_default = Vue.defineComponent({
  name,
  props: navBarProps,
  emits: ["clickLeft", "clickRight"],
  setup(props2, {
    emit,
    slots
  }) {
    const navBarRef = Vue.ref();
    const renderPlaceholder = usePlaceholder.usePlaceholder(navBarRef, bem);
    const onClickLeft = (event) => {
      if (!props2.leftDisabled) {
        emit("clickLeft", event);
      }
    };
    const onClickRight = (event) => {
      if (!props2.rightDisabled) {
        emit("clickRight", event);
      }
    };
    const renderLeft = () => {
      if (slots.left) {
        return slots.left();
      }
      return [props2.leftArrow && Vue.createVNode(index.Icon, {
        "class": bem("arrow"),
        "name": "arrow-left"
      }, null), props2.leftText && Vue.createVNode("span", {
        "class": bem("text")
      }, [props2.leftText])];
    };
    const renderRight = () => {
      if (slots.right) {
        return slots.right();
      }
      return Vue.createVNode("span", {
        "class": bem("text")
      }, [props2.rightText]);
    };
    const renderNavBar = () => {
      const {
        title,
        fixed,
        border,
        zIndex
      } = props2;
      const style = format.getZIndexStyle(zIndex);
      const hasLeft = props2.leftArrow || props2.leftText || slots.left;
      const hasRight = props2.rightText || slots.right;
      return Vue.createVNode("div", {
        "ref": navBarRef,
        "style": style,
        "class": [bem({
          fixed
        }), {
          [constant.BORDER_BOTTOM]: border,
          "van-safe-area-top": props2.safeAreaInsetTop
        }]
      }, [Vue.createVNode("div", {
        "class": bem("content")
      }, [hasLeft && Vue.createVNode("div", {
        "class": [bem("left", {
          disabled: props2.leftDisabled
        }), props2.clickable && !props2.leftDisabled ? constant.HAPTICS_FEEDBACK : ""],
        "onClick": onClickLeft
      }, [renderLeft()]), Vue.createVNode("div", {
        "class": [bem("title"), "van-ellipsis"]
      }, [slots.title ? slots.title() : title]), hasRight && Vue.createVNode("div", {
        "class": [bem("right", {
          disabled: props2.rightDisabled
        }), props2.clickable && !props2.rightDisabled ? constant.HAPTICS_FEEDBACK : ""],
        "onClick": onClickRight
      }, [renderRight()])])]);
    };
    return () => {
      if (props2.fixed && props2.placeholder) {
        return renderPlaceholder(renderNavBar);
      }
      return renderNavBar();
    };
  }
});
exports.default = stdin_default;
exports.navBarProps = navBarProps;
