"use strict";
const uni_modules_tdesignUniapp_components_common_src_instantiationDecorator = require("../common/src/instantiationDecorator.js");
const uni_modules_tdesignUniapp_components_common_config = require("../common/config.js");
const uni_modules_tdesignUniapp_components_icon_props = require("./props.js");
const uni_modules_tdesignUniapp_components_common_utils = require("../common/utils.js");
const uni_modules_tdesignUniapp_components_common_utils_wxs = require("../common/utils.wxs.js");
const common_vendor = require("../../../../common/vendor.js");
const name = `${uni_modules_tdesignUniapp_components_common_config.prefix}-icon`;
const _sfc_main = uni_modules_tdesignUniapp_components_common_src_instantiationDecorator.uniComponent({
  name,
  options: {
    styleIsolation: "shared"
  },
  externalClasses: [`${uni_modules_tdesignUniapp_components_common_config.prefix}-class`],
  props: {
    ...uni_modules_tdesignUniapp_components_icon_props.props
  },
  data() {
    return {
      componentPrefix: uni_modules_tdesignUniapp_components_common_config.prefix,
      classPrefix: name,
      isImage: false,
      iconStyle: void 0,
      tools: uni_modules_tdesignUniapp_components_common_utils_wxs.tools
    };
  },
  watch: {
    name: {
      handler() {
        this.setIconStyle();
      },
      immediate: true
    },
    color: {
      handler() {
        this.setIconStyle();
      },
      immediate: true
    },
    size: {
      handler() {
        this.setIconStyle();
      },
      immediate: true
    },
    style: {
      handler() {
        this.setIconStyle();
      },
      immediate: true
    }
  },
  methods: {
    onTap(t) {
      this.$emit("click", t);
    },
    setIconStyle() {
      const {
        name: name2,
        color,
        size,
        classPrefix
      } = this;
      const isImage = name2.indexOf("/") !== -1;
      const sizeValue = uni_modules_tdesignUniapp_components_common_utils.addUnit(size);
      const colorStyle = color ? {
        color
      } : {};
      const fontStyle = size ? {
        "font-size": sizeValue
      } : {};
      const iconStyle = { ...colorStyle, ...fontStyle };
      this.isImage = isImage;
      if (isImage) {
        let iconSize = sizeValue;
        if (!iconSize) {
          uni_modules_tdesignUniapp_components_common_utils.getRect(this, `.${classPrefix}`).then((res) => {
            iconSize = uni_modules_tdesignUniapp_components_common_utils.addUnit(res == null ? void 0 : res.height);
          }).catch(() => {
          });
        }
        iconStyle.width = iconSize;
        iconStyle.height = iconSize;
      }
      this.iconStyle = `${uni_modules_tdesignUniapp_components_common_utils.styles(iconStyle)}`;
    }
  }
});
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
  return common_vendor.e({
    a: _ctx.isImage
  }, _ctx.isImage ? {
    b: _ctx.name,
    c: common_vendor.n(_ctx.classPrefix + "__image"),
    d: common_vendor.n(_ctx.classPrefix + "--image")
  } : {}, {
    e: _ctx.tools.isValidIconName(_ctx.name) && !_ctx.isImage
  }, _ctx.tools.isValidIconName(_ctx.name) && !_ctx.isImage ? {
    f: common_vendor.n((_ctx.prefix ? _ctx.prefix : _ctx.classPrefix) + "-" + _ctx.name + " " + _ctx.classPrefix + "-base")
  } : {}, {
    g: common_vendor.n(_ctx.tClass),
    h: common_vendor.n(_ctx.prefix || "t-icon"),
    i: common_vendor.s(_ctx.tools._style([_ctx.iconStyle, _ctx.customStyle])),
    j: _ctx.ariaHidden,
    k: _ctx.ariaLabel,
    l: _ctx.ariaRole,
    m: common_vendor.o((...args) => _ctx.onTap && _ctx.onTap(...args))
  });
}
const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-2e2ca7b4"]]);
wx.createComponent(Component);
//# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/tdesign-uniapp/components/icon/icon.js.map
