import { defineComponent, useAttrs, ref, computed, watch, resolveComponent, createElementBlock, openBlock, mergeProps, unref, createVNode, createCommentVNode, createSlots, renderList, withCtx, renderSlot, normalizeProps, guardReactiveProps, Fragment, createTextVNode, toDisplayString, normalizeClass } from 'vue';
import '../../../utils/index.mjs';
import { omit, isNil } from 'lodash-es';
import './config/index.mjs';
import { inputNumberEmits, inputNumberProps } from './input-number.mjs';
import { createNamespace } from '../../../utils/create-namespace.mjs';
import { integerDict } from './config/input-number.mjs';
import { getAmountChinese } from '../../../utils/number.mjs';

"use strict";
var _sfc_main = /* @__PURE__ */ defineComponent({
  ...{ name: "LlInputNumber", inheritAttrs: false },
  __name: "input-number",
  props: inputNumberProps,
  emits: inputNumberEmits,
  setup(__props, { expose: __expose, emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const bem = createNamespace("input-number");
    const attrs = useAttrs();
    const innerValue = ref("");
    const inputRef = ref();
    const containerAttrs = computed(() => ({
      class: attrs.class,
      style: attrs.style
    }));
    const componentAttrs = computed(() => {
      const bindValue = {
        ...omit(attrs, ["class", "style"]),
        ...integerConfig.value
      };
      return bindValue;
    });
    const showAmountChinese = computed(
      () => props.isAmountChinese && !isNil(innerValue.value)
    );
    const integerConfig = computed(() => {
      let obj = {};
      if (props.integer) {
        obj = integerDict[props.integer];
      }
      return obj;
    });
    const setValue = (value) => {
      innerValue.value = isNil(value) || isNaN(value) ? null : value;
    };
    const onChange = (value) => {
      emit("update:value", value);
      emit("change", value);
    };
    const focus = () => {
      inputRef.value.focus();
    };
    watch(
      () => props.value,
      (val) => {
        setValue(val);
      },
      { immediate: true }
    );
    __expose({ focus });
    return (_ctx, _cache) => {
      const _component_a_input_number = resolveComponent("a-input-number");
      return openBlock(), createElementBlock(
        "div",
        mergeProps({
          class: [
            unref(bem).b(),
            unref(bem).is(_ctx.isGray ? "gray-input-number" : ""),
            unref(bem).is(showAmountChinese.value ? "show-amount-chinese" : "")
          ]
        }, containerAttrs.value),
        [
          createVNode(_component_a_input_number, mergeProps({
            ref_key: "inputRef",
            ref: inputRef
          }, componentAttrs.value, {
            value: innerValue.value,
            "onUpdate:value": _cache[0] || (_cache[0] = ($event) => innerValue.value = $event),
            onChange
          }), createSlots({
            _: 2
            /* DYNAMIC */
          }, [
            renderList(Object.keys(_ctx.$slots).filter(
              (name) => name !== "addonAfter"
            ), (item) => {
              return {
                name: item,
                fn: withCtx((data) => [
                  renderSlot(_ctx.$slots, item, normalizeProps(guardReactiveProps(data || {})))
                ])
              };
            }),
            _ctx.$slots.addonAfter || _ctx.unit ? {
              name: "addonAfter",
              fn: withCtx(() => [
                _ctx.$slots.addonAfter ? renderSlot(_ctx.$slots, "addonAfter", { key: 0 }) : _ctx.unit ? (openBlock(), createElementBlock(
                  Fragment,
                  { key: 1 },
                  [
                    createTextVNode(
                      toDisplayString(_ctx.unit),
                      1
                      /* TEXT */
                    )
                  ],
                  64
                  /* STABLE_FRAGMENT */
                )) : createCommentVNode("v-if", true)
              ]),
              key: "0"
            } : void 0
          ]), 1040, ["value"]),
          createCommentVNode(" \u4E2D\u6587\u5927\u5199\u91D1\u989D "),
          showAmountChinese.value ? (openBlock(), createElementBlock(
            "span",
            {
              key: 0,
              class: normalizeClass(unref(bem).e("amount-chinese-name"))
            },
            toDisplayString(unref(getAmountChinese)(Number(innerValue.value))),
            3
            /* TEXT, CLASS */
          )) : createCommentVNode("v-if", true)
        ],
        16
        /* FULL_PROPS */
      );
    };
  }
});

export { _sfc_main as default };
//# sourceMappingURL=input-number.vue2.mjs.map
