"use strict";
const common_vendor = require("../../../../common/vendor.js");
const name = "l-radio";
const _sfc_main = /* @__PURE__ */ common_vendor.defineComponent({
  __name: "l-radio",
  props: /* @__PURE__ */ common_vendor.mergeModels({
    allowUncheck: { type: Boolean, default: false },
    checked: { type: Boolean, default: false },
    defaultChecked: { type: Boolean },
    disabled: { type: Boolean, default: false },
    icon: { default: "circle" },
    label: {},
    name: {},
    value: {},
    size: { default: "medium" },
    fontSize: {},
    iconSize: {},
    checkedColor: {},
    iconBgColor: {},
    iconBorderColor: {},
    iconDisabledColor: {},
    iconDisabledBgColor: {}
  }, {
    "modelValue": { type: Boolean, default: false },
    "modelModifiers": {}
  }),
  emits: /* @__PURE__ */ common_vendor.mergeModels(["change", "update:checked"], ["update:modelValue"]),
  setup(__props, _a) {
    var __emit = _a.emit;
    const emit = __emit;
    const props = __props;
    const radioGroupProps = common_vendor.inject("limeRadioGroupProps", null);
    const radioGroupValue = common_vendor.inject("limeRadioGroupValue", null);
    const radioGroupChange = common_vendor.inject("limeRadioGroupChange", null);
    const modelValue = common_vendor.useModel(__props, "modelValue");
    const innerChecked = common_vendor.computed({
      set(value) {
        modelValue.value = value;
        emit("change", value);
      },
      get() {
        return props.checked || modelValue.value;
      }
    });
    const isDisabled = common_vendor.computed(() => {
      var _a2;
      return props.disabled || ((_a2 = radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.disabled) !== null && _a2 !== void 0 ? _a2 : false);
    });
    common_vendor.computed(() => {
      return radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.disabled;
    });
    const radioChecked = common_vendor.computed(() => {
      return innerChecked.value || props.name != null && props.name == (radioGroupValue === null || radioGroupValue === void 0 ? void 0 : radioGroupValue.value) || props.value != null && props.value == (radioGroupValue === null || radioGroupValue === void 0 ? void 0 : radioGroupValue.value);
    });
    const finalAllowUncheck = common_vendor.computed(() => {
      var _a2;
      return props.allowUncheck || ((_a2 = radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.allowUncheck) !== null && _a2 !== void 0 ? _a2 : false);
    });
    const innerIcon = common_vendor.computed(() => {
      var _a2;
      return (_a2 = radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.icon) !== null && _a2 !== void 0 ? _a2 : props.icon;
    });
    common_vendor.computed(() => {
      var _a2;
      return (_a2 = radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.size) !== null && _a2 !== void 0 ? _a2 : props.size;
    });
    const innerIconSize = common_vendor.computed(() => {
      var _a2;
      return (_a2 = radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.iconSize) !== null && _a2 !== void 0 ? _a2 : props.iconSize;
    });
    const innerFontSize = common_vendor.computed(() => {
      var _a2;
      return (_a2 = radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.fontSize) !== null && _a2 !== void 0 ? _a2 : props.fontSize;
    });
    const innerCheckedColor = common_vendor.computed(() => {
      var _a2;
      return (_a2 = radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.checkedColor) !== null && _a2 !== void 0 ? _a2 : props.checkedColor;
    });
    common_vendor.computed(() => {
      var _a2, _b;
      return (_b = (_a2 = props.iconBgColor) !== null && _a2 !== void 0 ? _a2 : radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.iconBgColor) !== null && _b !== void 0 ? _b : "white";
    });
    const innerIconBorderColor = common_vendor.computed(() => {
      var _a2, _b;
      return (_b = (_a2 = props.iconBorderColor) !== null && _a2 !== void 0 ? _a2 : radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.iconBorderColor) !== null && _b !== void 0 ? _b : "#c5c5c5";
    });
    const innerIconDisabledColor = common_vendor.computed(() => {
      var _a2, _b;
      return (_b = (_a2 = props.iconDisabledColor) !== null && _a2 !== void 0 ? _a2 : radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.iconDisabledColor) !== null && _b !== void 0 ? _b : "#c5c5c5";
    });
    const innerIconDisabledBgColor = common_vendor.computed(() => {
      var _a2, _b;
      return (_b = (_a2 = props.iconDisabledBgColor) !== null && _a2 !== void 0 ? _a2 : radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.iconDisabledBgColor) !== null && _b !== void 0 ? _b : "#f3f3f3";
    });
    const classes = common_vendor.computed(() => {
      const cls = /* @__PURE__ */ new Map();
      cls.set(`${name}--disabled`, isDisabled.value);
      return cls;
    });
    const iconClasses = common_vendor.computed(() => {
      const cls = /* @__PURE__ */ new Map();
      cls.set(`${name}__icon--checked`, radioChecked.value);
      cls.set(`${name}__icon--${innerIcon.value}`, true);
      cls.set(`${name}__icon--disabled`, isDisabled.value);
      return cls;
    });
    const labelClass = common_vendor.computed(() => {
      const cls = /* @__PURE__ */ new Map();
      cls.set(`${name}__label--disabled`, isDisabled.value);
      return cls;
    });
    const styles = common_vendor.computed(() => {
      const style = /* @__PURE__ */ new Map();
      if (radioGroupProps != null && radioGroupProps.gap != null) {
        style.set(radioGroupProps.direction == "horizontal" ? "margin-right" : "margin-bottom", radioGroupProps.gap);
      }
      if (innerCheckedColor.value != null) {
        style.set("--l-radio-icon-checked-color", innerCheckedColor.value);
      }
      if (innerIconBorderColor.value != null) {
        style.set("--l-radio-icon-border-color", innerIconBorderColor.value);
      }
      if (innerIconDisabledColor.value != null) {
        style.set("--l-radio-icon-disabled-color", innerIconDisabledColor.value);
      }
      if (innerIconDisabledBgColor.value != null) {
        style.set("--l-radio-icon-disabled-bg-color", innerIconDisabledBgColor.value);
      }
      if (innerFontSize.value != null) {
        style.set("--l-radio-font-size", innerFontSize.value);
      }
      return style;
    });
    const iconStyle = common_vendor.computed(() => {
      const style = /* @__PURE__ */ new Map();
      if (innerIconSize.value != null) {
        style.set("width", innerIconSize.value);
        style.set("height", innerIconSize.value);
        style.set("--l-radio-icon-size", innerIconSize.value);
      }
      if (innerCheckedColor.value != null) {
        style.set("--l-radio-icon-checked-color", innerCheckedColor.value);
      }
      return style;
    });
    common_vendor.computed(() => {
      var _a2;
      const style = /* @__PURE__ */ new Map();
      const fontSize = (_a2 = props.fontSize) !== null && _a2 !== void 0 ? _a2 : radioGroupProps === null || radioGroupProps === void 0 ? void 0 : radioGroupProps.fontSize;
      if (fontSize != null) {
        style.set("font-size", fontSize);
      }
      return style;
    });
    const onClick = (e) => {
      var _a2;
      if (isDisabled.value)
        return null;
      const _name = (_a2 = props.value) !== null && _a2 !== void 0 ? _a2 : props.name;
      if (radioGroupChange != null && _name != null) {
        const value = finalAllowUncheck.value && radioChecked.value ? null : _name;
        radioGroupChange(value);
      } else {
        const value = finalAllowUncheck.value ? !radioChecked.value : true;
        innerChecked.value = value;
      }
    };
    return (_ctx = null, _cache = null) => {
      const __returned__ = common_vendor.e(new UTSJSONObject({
        a: common_vendor.sei("r0-6713f23a", "view", "iconRef"),
        b: common_vendor.n(common_vendor.unref(iconClasses)),
        c: common_vendor.s(common_vendor.unref(iconStyle)),
        d: common_vendor.r("icon", new UTSJSONObject({
          checked: common_vendor.unref(radioChecked),
          disabled: common_vendor.unref(isDisabled)
        })),
        e: _ctx.label != null || _ctx.$slots["default"] != null
      }), _ctx.label != null || _ctx.$slots["default"] != null ? new UTSJSONObject({
        f: common_vendor.t(_ctx.label),
        g: common_vendor.n(common_vendor.unref(labelClass))
      }) : new UTSJSONObject({}), new UTSJSONObject({
        h: common_vendor.r("radio", new UTSJSONObject({
          checked: common_vendor.unref(radioChecked),
          disabled: common_vendor.unref(isDisabled)
        })),
        i: common_vendor.sei(_ctx.virtualHostId, "view"),
        j: common_vendor.n(common_vendor.unref(classes)),
        k: common_vendor.s(common_vendor.unref(styles)),
        l: common_vendor.o(onClick)
      }));
      return __returned__;
    };
  }
});
wx.createComponent(_sfc_main);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/lime-radio/components/l-radio/l-radio.js.map
