import { defineComponent as I, useSlots as $, computed as f, shallowRef as A, unref as t, openBlock as r, createBlock as c, withCtx as y, createElementVNode as v, normalizeClass as i, createElementBlock as h, renderSlot as u, createCommentVNode as B, toDisplayString as U, mergeProps as z, createSlots as E, renderList as T, normalizeProps as w, guardReactiveProps as F } from "vue";
import { InputNumber as O } from "@aplus-frontend/antdv";
import { omit as W, isNil as L } from "lodash-unified";
import "../../render/index.mjs";
import { roundWith as Z, toDecimalMark as _ } from "../../utils/format.mjs";
import "../../config-provider/index.mjs";
import "../../hooks/index.mjs";
import { useDefaultPlaceholder as j } from "../hooks/use-default-placeholder.mjs";
import { useReadModeRender as q } from "../hooks/use-read-mode-render.mjs";
import G from "../style/index.mjs";
import { addZeroToDecimalPlaces as H } from "./helper.mjs";
import { useNamespace as J } from "../../config-provider/hooks/use-namespace.mjs";
import { useControllableValue as K } from "../../hooks/useControllableValue.mjs";
import Q from "../../render/render.mjs";
const fe = /* @__PURE__ */ I({
  name: "ApFieldNumber",
  __name: "index",
  props: {
    mode: {},
    class: {},
    style: {},
    emptyText: { default: "--" },
    customReadMode: {},
    size: {},
    bordered: { type: Boolean, default: !0 },
    placeholder: {},
    name: {},
    id: {},
    type: {},
    addonBefore: {},
    addonAfter: {},
    prefix: {},
    suffix: {},
    "onUpdate:value": {},
    valueModifiers: {},
    status: {},
    variant: {},
    changeOnWheel: { type: Boolean, default: void 0 },
    changeOnBlur: { type: Boolean, default: void 0 },
    stringMode: { type: Boolean },
    defaultValue: {},
    value: {},
    prefixCls: {},
    min: { default: -1 / 0 },
    max: { default: 1 / 0 },
    step: { default: 1 },
    tabindex: {},
    controls: { type: Boolean, default: !0 },
    readonly: { type: Boolean },
    disabled: { type: Boolean, default: void 0 },
    autofocus: { type: Boolean },
    keyboard: { type: Boolean, default: !0 },
    parser: {},
    formatter: {},
    precision: {},
    decimalSeparator: {},
    onInput: {},
    onChange: {},
    onPressEnter: {},
    onStep: {},
    onBlur: {},
    onFocus: {},
    inputMode: {},
    thousands: { type: Boolean, default: !1 },
    limitDecimalsRetain: { type: Boolean }
  },
  emits: ["update:value"],
  setup(l, { expose: b, emit: g }) {
    const k = g, R = $(), { b: n } = J("field-number"), S = G("field"), e = l, x = f(
      () => W(e, ["value", "onUpdate:value", "mode"])
    ), s = A(), { value: d, updateValue: C } = K(
      e,
      k
    ), M = j("Number", e), p = f(() => {
      let o = t(d);
      if (L(o))
        return e.emptyText;
      e.precision && (o = Z(o, e.precision));
      let a = e.thousands ? _(o) : String(o);
      return e.precision && e.limitDecimalsRetain && (a = H(a, e.precision)), a;
    }), { renderer: N } = q(e, p);
    function P() {
      s.value?.focus();
    }
    function D() {
      s.value?.blur();
    }
    return b({ focus: P, blur: D }), (o, a) => l.mode === "read" ? (r(), c(t(Q), {
      key: 0,
      renderer: t(N)
    }, {
      default: y(() => [
        v("span", {
          class: i([t(n)(), t(S)])
        }, [
          o.$slots.prefix ? (r(), h("span", {
            key: 0,
            class: i(t(n)("label-left"))
          }, [
            u(o.$slots, "prefix")
          ], 2)) : B("", !0),
          v("span", null, U(p.value), 1),
          o.$slots.addonAfter ? (r(), h("span", {
            key: 1,
            class: i(t(n)("label-right"))
          }, [
            u(o.$slots, "addonAfter")
          ], 2)) : B("", !0)
        ], 2)
      ]),
      _: 3
    }, 8, ["renderer"])) : (r(), c(t(O), z({ key: 1 }, x.value, {
      ref_key: "inputRef",
      ref: s,
      placeholder: t(M),
      value: t(d),
      mode: l.inputMode,
      "onUpdate:value": t(C)
    }), E({ _: 2 }, [
      T(R, (X, m) => ({
        name: m,
        fn: y((V) => [
          u(o.$slots, m, w(F(V || {})))
        ])
      }))
    ]), 1040, ["placeholder", "value", "mode", "onUpdate:value"]));
  }
});
export {
  fe as default
};
