import { b as buildProp, s as isNumber, y as isStringNumber, x as isString, f as debugWarn, m as isClient, w as isShadowRoot, c as camelize } from "./error-DEV4o0cD.js";
import { inject, computed, unref } from "vue";
const componentSizes = [
  "",
  "default",
  "small",
  "large"
];
const useSizeProp = buildProp({
  type: String,
  values: componentSizes,
  required: false
});
const SIZE_INJECTION_KEY = Symbol("size");
const useGlobalSize = () => {
  const injectedSize = inject(SIZE_INJECTION_KEY, {});
  return computed(() => {
    return unref(injectedSize.size) || "";
  });
};
const SCOPE = "utils/dom/style";
const classNameToArray = (cls = "") => cls.split(" ").filter((item) => !!item.trim());
const hasClass = (el, cls) => {
  if (!el || !cls) return false;
  if (cls.includes(" ")) throw new Error("className should not contain space.");
  return el.classList.contains(cls);
};
const addClass = (el, cls) => {
  if (!el || !cls.trim()) return;
  el.classList.add(...classNameToArray(cls));
};
const removeClass = (el, cls) => {
  if (!el || !cls.trim()) return;
  el.classList.remove(...classNameToArray(cls));
};
const getStyle = (element, styleName) => {
  var _a;
  if (!isClient || !element || !styleName || isShadowRoot(element)) return "";
  let key = camelize(styleName);
  if (key === "float") key = "cssFloat";
  try {
    const style = element.style[key];
    if (style) return style;
    const computed2 = (_a = document.defaultView) == null ? void 0 : _a.getComputedStyle(element, "");
    return computed2 ? computed2[key] : "";
  } catch {
    return element.style[key];
  }
};
function addUnit(value, defaultUnit = "px") {
  if (!value && value !== 0) return "";
  if (isNumber(value) || isStringNumber(value)) return `${value}${defaultUnit}`;
  else if (isString(value)) return value;
  debugWarn(SCOPE, "binding value must be a string or number");
}
export {
  SIZE_INJECTION_KEY as S,
  addClass as a,
  addUnit as b,
  componentSizes as c,
  useSizeProp as d,
  getStyle as g,
  hasClass as h,
  removeClass as r,
  useGlobalSize as u
};
//# sourceMappingURL=style-D2s_cWsv.js.map
