"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
const Vue = require("vue");
const useRoute = require("../composables/use-route.js");
const index = require("../icon/index.js");
const basic = require("../utils/basic.js");
const create = require("../utils/create.js");
const props = require("../utils/props.js");
const [name, bem] = create.createNamespace("cell");
const cellSharedProps = {
  tag: props.makeStringProp("div"),
  icon: String,
  size: String,
  title: props.numericProp,
  value: props.numericProp,
  label: props.numericProp,
  center: Boolean,
  isLink: Boolean,
  border: props.truthProp,
  iconPrefix: String,
  valueClass: props.unknownProp,
  labelClass: props.unknownProp,
  titleClass: props.unknownProp,
  titleStyle: null,
  arrowDirection: String,
  required: {
    type: [Boolean, String],
    default: null
  },
  clickable: {
    type: Boolean,
    default: null
  }
};
const cellProps = basic.extend({}, cellSharedProps, useRoute.routeProps);
var stdin_default = Vue.defineComponent({
  name,
  props: cellProps,
  setup(props2, {
    slots
  }) {
    const route = useRoute.useRoute();
    const renderLabel = () => {
      const showLabel = slots.label || basic.isDef(props2.label);
      if (showLabel) {
        return Vue.createVNode("div", {
          "class": [bem("label"), props2.labelClass]
        }, [slots.label ? slots.label() : props2.label]);
      }
    };
    const renderTitle = () => {
      var _a;
      if (slots.title || basic.isDef(props2.title)) {
        const titleSlot = (_a = slots.title) == null ? void 0 : _a.call(slots);
        if (Array.isArray(titleSlot) && titleSlot.length === 0) {
          return;
        }
        return Vue.createVNode("div", {
          "class": [bem("title"), props2.titleClass],
          "style": props2.titleStyle
        }, [titleSlot || Vue.createVNode("span", null, [props2.title]), renderLabel()]);
      }
    };
    const renderValue = () => {
      const slot = slots.value || slots.default;
      const hasValue = slot || basic.isDef(props2.value);
      if (hasValue) {
        return Vue.createVNode("div", {
          "class": [bem("value"), props2.valueClass]
        }, [slot ? slot() : Vue.createVNode("span", null, [props2.value])]);
      }
    };
    const renderLeftIcon = () => {
      if (slots.icon) {
        return slots.icon();
      }
      if (props2.icon) {
        return Vue.createVNode(index.Icon, {
          "name": props2.icon,
          "class": bem("left-icon"),
          "classPrefix": props2.iconPrefix
        }, null);
      }
    };
    const renderRightIcon = () => {
      if (slots["right-icon"]) {
        return slots["right-icon"]();
      }
      if (props2.isLink) {
        const name2 = props2.arrowDirection && props2.arrowDirection !== "right" ? `arrow-${props2.arrowDirection}` : "arrow";
        return Vue.createVNode(index.Icon, {
          "name": name2,
          "class": bem("right-icon")
        }, null);
      }
    };
    return () => {
      var _a;
      const {
        tag,
        size,
        center,
        border,
        isLink,
        required
      } = props2;
      const clickable = (_a = props2.clickable) != null ? _a : isLink;
      const classes = {
        center,
        required: !!required,
        clickable,
        borderless: !border
      };
      if (size) {
        classes[size] = !!size;
      }
      return Vue.createVNode(tag, {
        "class": bem(classes),
        "role": clickable ? "button" : void 0,
        "tabindex": clickable ? 0 : void 0,
        "onClick": route
      }, {
        default: () => {
          var _a2;
          return [renderLeftIcon(), renderTitle(), renderValue(), renderRightIcon(), (_a2 = slots.extra) == null ? void 0 : _a2.call(slots)];
        }
      });
    };
  }
});
exports.cellProps = cellProps;
exports.cellSharedProps = cellSharedProps;
exports.default = stdin_default;
