import { useState as m, useEffect as q } from "react";
import { X as N, av as k, N as _, O as i, Z as c, c2 as j, c3 as H, L as T, eE as M, a3 as y, d5 as W, dA as G, az as J, U as X, eS as v, F as a, G as E, eR as Z, eT as K, bU as P, a6 as S, a7 as u, Y as l, dB as Q, a8 as s, a9 as p, ac as d, dD as O, dE as U, aa as ee, dF as te } from "./603b75d9.js";
import { FormDataPropertyView as ae } from "./f9847c56.js";
import { getStyle as le, textInputChildren as ne, textInputValidate as V, TextInputBasicSection as re, TextInputInteractionSection as ue, TextInputValidationSection as ie, TextInputConfigs as R } from "./41aba172.js";
import { autoCompleteDate as se, convertAutoCompleteData as oe, itemsDataTooltip as me, autoCompleteRefMethods as ce, valueOrLabelOption as ye, autoCompleteType as de, autocompleteIconColor as Ce, componentSize as fe } from "./c236c7a3.js";
import "react-dom";
const ve = N(te)`
box-shadow: ${(e) => {
  var r, C;
  return `${(r = e.$style) == null ? void 0 : r.boxShadow} ${(C = e.$style) == null ? void 0 : C.boxShadowColor}`;
}};
  ${(e) => {
  var r;
  return k`
    ${le(e.$style)}
    input {
      padding: ${(r = e.style) == null ? void 0 : r.padding};
    }
    .ant-select-single {
      width: 100% !important;
    }
  `;
}}
`, Se = {
  ...ne,
  viewRef: _,
  allowClear: i.DEFAULT_TRUE,
  style: c(j, "style"),
  labelStyle: c(H, "labelStyle"),
  prefixIcon: T,
  suffixIcon: T,
  items: M(oe, se),
  ignoreCase: i.DEFAULT_TRUE,
  searchFirstPY: i.DEFAULT_TRUE,
  searchCompletePY: i,
  searchLabelOnly: i.DEFAULT_TRUE,
  valueOrLabel: y(ye, "label"),
  autoCompleteType: y(de, "normal"),
  autocompleteIconColor: y(Ce, "blue"),
  componentSize: y(fe, "small"),
  valueInItems: W("valueInItems"),
  inputFieldStyle: c(G, "inputFieldStyle"),
  animationStyle: c(J, "animationStyle")
}, ge = (e) => e.hasOwnProperty("validateStatus") && e.validateStatus === "error" ? "error" : "";
let g = function() {
  return new X(Se, (e) => {
    const {
      items: r,
      onEvent: C,
      placeholder: D,
      searchFirstPY: b,
      searchCompletePY: x,
      searchLabelOnly: A,
      ignoreCase: w,
      valueOrLabel: h,
      autoCompleteType: be,
      autocompleteIconColor: xe,
      componentSize: $
    } = e, I = () => ({
      value: {
        value: e.value.value
      },
      required: e.required,
      minLength: (e == null ? void 0 : e.minLength) ?? 0,
      maxLength: (e == null ? void 0 : e.maxLength) ?? 0,
      validationType: e.validationType,
      regex: e.regex,
      customRule: e.customRule
    }), [B, Y] = m(!1), [z, f] = m(e.value.value), [F, L] = m({}), [o, we] = m(v() === "zh-cn");
    return q(() => {
      f(e.value.value), B && L(V(I()));
    }, [e.value.value, e.required, e == null ? void 0 : e.minLength, e == null ? void 0 : e.maxLength, e.validationType, e.regex, e.customRule]), e.label({
      required: e.required,
      children: /* @__PURE__ */ a(E, {
        children: /* @__PURE__ */ a(Z, {
          theme: {
            token: {
              colorBgContainer: e.inputFieldStyle.background,
              colorBorder: e.inputFieldStyle.border,
              borderRadius: parseInt(e.inputFieldStyle.radius),
              colorText: e.inputFieldStyle.text,
              colorPrimary: e.inputFieldStyle.accent,
              controlHeight: $ === "small" ? 30 : 38
            }
          },
          children: /* @__PURE__ */ a(K, {
            disabled: e.disabled,
            value: z,
            options: r,
            style: {
              width: "100%"
            },
            onChange: (n, t) => {
              e.valueInItems.onChange(!1), L(V(I())), f(n), e.value.onChange(n), e.onEvent("change");
            },
            onFocus: () => {
              Y(!0), e.onEvent("focus");
            },
            onBlur: () => e.onEvent("blur"),
            onSelect: (n, t) => {
              f(t[h]), e.valueInItems.onChange(!0), e.value.onChange(t[h]), e.onEvent("submit");
            },
            filterOption: (n, t) => {
              if (w) {
                if (t != null && t.label && (t == null ? void 0 : t.label.toUpperCase().indexOf(n.toUpperCase())) !== -1)
                  return !0;
              } else if (t != null && t.label && (t == null ? void 0 : t.label.indexOf(n)) !== -1)
                return !0;
              if (o && b && (t != null && t.label) && t.label.spell("first").toString().toLowerCase().indexOf(n.toLowerCase()) >= 0 || o && x && (t != null && t.label) && t.label.spell().toString().toLowerCase().indexOf(n.toLowerCase()) >= 0)
                return !0;
              if (!A) {
                if (w) {
                  if (t != null && t.value && (t == null ? void 0 : t.value.toUpperCase().indexOf(n.toUpperCase())) !== -1)
                    return !0;
                } else if (t != null && t.value && (t == null ? void 0 : t.value.indexOf(n)) !== -1)
                  return !0;
                if (o && b && (t != null && t.value) && t.value.spell("first").toString().toLowerCase().indexOf(n.toLowerCase()) >= 0 || o && x && (t != null && t.value) && t.value.spell().toString().toLowerCase().indexOf(n.toLowerCase()) >= 0)
                  return !0;
              }
              return !1;
            },
            children: /* @__PURE__ */ a(ve, {
              ref: e.viewRef,
              placeholder: D,
              allowClear: e.allowClear,
              $style: e.inputFieldStyle,
              prefix: P(e.prefixIcon) && e.prefixIcon,
              suffix: P(e.suffixIcon) && e.suffixIcon,
              status: ge(F),
              onPressEnter: void 0
            })
          })
        })
      }),
      style: e.style,
      labelStyle: e.labelStyle,
      inputFieldStyle: e.inputFieldStyle,
      animationStyle: e.animationStyle,
      showValidationWhenEmpty: e.showValidationWhenEmpty,
      ...F
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ S(E, {
    children: [/* @__PURE__ */ S(u, {
      children: [e.autoCompleteType.getView() === "normal" && e.prefixIcon.propertyView({
        label: l("button.prefixIcon")
      }), e.autoCompleteType.getView() === "normal" && e.suffixIcon.propertyView({
        label: l("button.suffixIcon")
      }), Q(e)]
    }), /* @__PURE__ */ S(u, {
      name: l("autoComplete.SectionDataName"),
      children: [e.items.propertyView({
        label: l("autoComplete.value"),
        tooltip: me,
        placeholder: "[]"
      }), v() === "zh-cn" && e.searchFirstPY.propertyView({
        label: l("autoComplete.searchFirstPY")
      }), v() === "zh-cn" && e.searchCompletePY.propertyView({
        label: l("autoComplete.searchCompletePY")
      }), e.searchLabelOnly.propertyView({
        label: l("autoComplete.searchLabelOnly")
      }), e.ignoreCase.propertyView({
        label: l("autoComplete.ignoreCase")
      }), e.valueOrLabel.propertyView({
        label: l("autoComplete.checkedValueFrom"),
        radioButton: !0
      })]
    }), /* @__PURE__ */ a(re, {
      ...e
    }), /* @__PURE__ */ a(ae, {
      ...e
    }), e.label.getPropertyView(), /* @__PURE__ */ a(ue, {
      ...e
    }), /* @__PURE__ */ a(ie, {
      ...e
    }), /* @__PURE__ */ a(u, {
      name: s.layout,
      children: p(e)
    }), /* @__PURE__ */ a(u, {
      name: s.style,
      children: e.style.getPropertyView()
    }), /* @__PURE__ */ a(u, {
      name: s.labelStyle,
      children: e.labelStyle.getPropertyView()
    }), /* @__PURE__ */ a(u, {
      name: s.inputFieldStyle,
      children: e.inputFieldStyle.getPropertyView()
    }), /* @__PURE__ */ a(u, {
      name: s.animationStyle,
      hasTooltip: !0,
      children: e.animationStyle.getPropertyView()
    })]
  })).setExposeMethodConfigs(ce).setExposeStateConfigs([new d("value", l("export.inputValueDesc")), new d("valueInItems", l("autoComplete.valueInItems")), O, U, ...R]).build();
}();
g = class extends g {
  autoHeight() {
    return !0;
  }
};
const Pe = ee(g, [new d("value", l("export.inputValueDesc")), new d("valueInItems", l("autoComplete.valueInItems")), O, U, ...R]);
export {
  Pe as AutoCompleteComp
};
