var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/pro/Selector/components/Indicator/index.tsx
var Indicator_exports = {};
__export(Indicator_exports, {
  default: () => Indicator_default
});
module.exports = __toCommonJS(Indicator_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_index = require("./index.less");
var sizeMap = {
  small: 20,
  middle: 24,
  large: 28
};
var Indicator = (props) => {
  const {
    mode = "single",
    variant = "outlined",
    disabled = false,
    className,
    styles = {},
    children,
    size = "middle",
    onChange,
    defaultChecked,
    checked: checkedProp
  } = props;
  const [internalChecked, setInternalChecked] = (0, import_react.useState)(
    defaultChecked || false
  );
  (0, import_react.useEffect)(() => {
    if (checkedProp !== void 0) {
      setInternalChecked(checkedProp);
    }
  }, [checkedProp]);
  const isControlled = checkedProp !== void 0;
  const checked = isControlled ? checkedProp : internalChecked;
  const prefixCls = "pisell-pro-indicator";
  const classes = (0, import_classnames.default)(
    prefixCls,
    `${prefixCls}-${mode}`,
    `${prefixCls}-${variant}`,
    {
      [`${prefixCls}-checked`]: checked,
      [`${prefixCls}-disabled`]: disabled
    },
    className
  );
  const indicatorStyle = (0, import_react.useMemo)(() => {
    const sizeValue = sizeMap[size] || Number(size);
    return {
      width: sizeValue,
      height: sizeValue,
      ...styles.indicator
    };
  }, [size, styles.indicator]);
  const handleInputChange = (e) => {
    if (disabled) return;
    if (!isControlled) {
      setInternalChecked(e.target.checked);
    }
    onChange == null ? void 0 : onChange(e);
  };
  const renderCheckIcon = () => {
    const sizeValue = sizeMap[size] || Number(size);
    const iconSize = sizeValue * 0.6;
    const strokeWidth = iconSize * 0.15;
    return /* @__PURE__ */ import_react.default.createElement(
      "svg",
      {
        className: `${prefixCls}-check-icon`,
        width: iconSize,
        height: iconSize * 0.76,
        viewBox: "0 0 17 13",
        fill: "none",
        xmlns: "http://www.w3.org/2000/svg"
      },
      /* @__PURE__ */ import_react.default.createElement(
        "path",
        {
          d: "M14.8814 1.44043L5.64141 10.6804L1.44141 6.48043",
          stroke: "currentColor",
          strokeWidth,
          strokeLinecap: "round",
          strokeLinejoin: "round"
        }
      )
    );
  };
  return /* @__PURE__ */ import_react.default.createElement("label", { className: classes, style: styles == null ? void 0 : styles.container }, /* @__PURE__ */ import_react.default.createElement(
    "input",
    {
      type: mode === "single" ? "radio" : "checkbox",
      className: `${prefixCls}-input`,
      checked: !!checked,
      disabled,
      onChange: handleInputChange
    }
  ), /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-inner`, style: indicatorStyle }, checked && /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, mode === "single" && variant === "outlined" ? /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-dot` }) : renderCheckIcon())), children && /* @__PURE__ */ import_react.default.createElement("span", { className: `${prefixCls}-content`, style: styles == null ? void 0 : styles.content }, children));
};
var Indicator_default = Indicator;
