'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../utils/index.js');
var lodashEs = require('lodash-es');
require('./config/index.js');
var inputNumber$1 = require('./input-number.js');
var createNamespace = require('../../../utils/create-namespace.js');
var inputNumber = require('./config/input-number.js');
var number = require('../../../utils/number.js');

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

exports.default = _sfc_main;
//# sourceMappingURL=input-number.vue2.js.map
