import { d1 as f, w as h, W as w, V as C, bX as V, a9 as v, a5 as r, cf as x, aG as p, cg as F, c3 as P, d4 as k, ci as E, U as H, H as t, ad as i, I as u, ae as l, af as n, a4 as o, co as R, am as c, c0 as $, ag as M, ah as B, aj as g, c1 as N, a3 as O, ak as j, aC as D, cD as I, d5 as L } from "./56c67d3b.js";
import { useRef as U, useEffect as S, useContext as d } from "react";
import "react-dom";
const A = [I];
function G(a) {
  return a && a.hasOwnProperty("unChecked") ? {
    label: a.label,
    checked: a.checked,
    unchecked: a.unChecked
  } : a;
}
const T = function() {
  const a = {
    defaultValue: f("defaultValue"),
    value: f("value"),
    max: h(j, "5"),
    label: w,
    allowHalf: C,
    disabled: V,
    onEvent: v(A),
    style: r(x, "style"),
    animationStyle: r(p, "animationStyle"),
    labelStyle: r(F.filter((e) => ["accent", "validate"].includes(e.name) === !1), "labelStyle"),
    inputFieldStyle: P(r(k, "inputFieldStyle"), G),
    ...E
  };
  return new H(a, (e) => {
    const y = {
      ...e.defaultValue
    }.value, m = {
      ...e.value
    }.value, s = U(!1);
    return S(() => {
      e.value.onChange(y);
    }, [y]), S(() => {
      s.current && (e.onEvent("change"), s.current = !1);
    }, [m]), e.label({
      style: e.style,
      labelStyle: e.labelStyle,
      inputFieldStyle: e.inputFieldStyle,
      animationStyle: e.animationStyle,
      children: /* @__PURE__ */ t(X, {
        count: e.max,
        value: m,
        onChange: (b) => {
          e.value.onChange(b), s.current = !0;
        },
        allowHalf: e.allowHalf,
        disabled: e.disabled,
        $style: e.inputFieldStyle
      })
    });
  }).setPropertyViewFn((e) => /* @__PURE__ */ i(u, {
    children: [/* @__PURE__ */ i(l, {
      name: n.basic,
      children: [e.defaultValue.propertyView({
        label: o("prop.defaultValue")
      }), e.max.propertyView({
        label: o("rating.max")
      })]
    }), /* @__PURE__ */ t(R, {
      ...e
    }), ["logic", "both"].includes(d(c).editorModeStatus) && /* @__PURE__ */ i(u, {
      children: [/* @__PURE__ */ i(l, {
        name: n.interaction,
        children: [e.onEvent.getPropertyView(), $(e), M(e)]
      }), /* @__PURE__ */ t(l, {
        name: n.advanced,
        children: e.allowHalf.propertyView({
          label: o("rating.allowHalf")
        })
      })]
    }), ["layout", "both"].includes(d(c).editorModeStatus) && e.label.getPropertyView(), ["layout", "both"].includes(d(c).editorModeStatus) && /* @__PURE__ */ i(u, {
      children: [/* @__PURE__ */ t(l, {
        name: n.style,
        children: e.style.getPropertyView()
      }), /* @__PURE__ */ t(l, {
        name: n.labelStyle,
        children: e.labelStyle.getPropertyView()
      }), /* @__PURE__ */ t(l, {
        name: n.inputFieldStyle,
        children: e.inputFieldStyle.getPropertyView()
      }), /* @__PURE__ */ t(l, {
        name: n.animationStyle,
        hasTooltip: !0,
        children: e.animationStyle.getPropertyView()
      })]
    })]
  })).build();
}(), K = B(T, [new g("value", o("export.ratingValueDesc")), new g("max", o("export.ratingMaxDesc")), ...N]), W = (a) => D`
    .ant-rate {
      color: ${a.checked};
    }

    .ant-rate-star-half .ant-rate-star-first,
    .ant-rate-star-full .ant-rate-star-second {
      color: ${a.checked};
    }

    .ant-rate-star-first,
    .ant-rate-star-second {
      color: ${a.unchecked};
    }
  `, X = O(L)`
  ${(a) => a.$style && W(a.$style)}
`;
export {
  X as RateStyled,
  K as RatingComp
};
