"use strict";

import React from 'react';
import { StyleSheet } from 'react-native';
import { Defs, LinearGradient, Stop } from 'react-native-svg';
import { useTheme } from "../theme/use-theme.js";
import { gradients } from "../styles/tokens.js";

/**
 * Style prop for Bloom icons. Icons render via `<Svg>`, which is a View-like
 * host, so the style must be View-compatible. A `color` field is allowed as a
 * convenience for consumers who set fill via the CSS `color` shorthand (the
 * icon reads this as a fallback fill when no explicit `fill` prop is given).
 *
 * Note: we intentionally avoid `TextStyle` here — React Native 0.84 introduced
 * `cursor: CursorValue` on `ViewStyle` while `expo/types/react-native-web`
 * augments `TextStyle.cursor` to `string`, and the resulting invariance
 * breaks assignment of `StyleProp<TextStyle>` to `<Svg>`'s style slot.
 */
import { jsx as _jsx } from "react/jsx-runtime";
export const sizes = {
  '2xs': 8,
  xs: 12,
  sm: 16,
  md: 20,
  lg: 24,
  xl: 28,
  '2xl': 32,
  '3xl': 48
};
export function useCommonSVGProps(props) {
  const {
    colors
  } = useTheme();
  const reactId = React.useId();
  const {
    fill,
    size,
    gradient,
    ...rest
  } = props;
  const style = StyleSheet.flatten(rest.style);
  const _size = Number(size ? sizes[size] : rest.width || sizes.md);
  let _fill = fill ?? style?.color ?? colors.primary;
  let gradientDef = null;
  if (gradient && gradients[gradient]) {
    const id = `${reactId}-${gradient}`;
    const config = gradients[gradient];
    _fill = `url(#${id})`;
    gradientDef = /*#__PURE__*/_jsx(Defs, {
      children: /*#__PURE__*/_jsx(LinearGradient, {
        id: id,
        x1: "0",
        y1: "0",
        x2: "100%",
        y2: "0",
        gradientTransform: "rotate(45)",
        children: config.values.map(([stop, fillColor]) => /*#__PURE__*/_jsx(Stop, {
          offset: String(stop),
          stopColor: fillColor
        }, String(stop)))
      })
    });
  }
  return {
    fill: _fill,
    size: _size,
    style,
    gradient: gradientDef,
    ...rest
  };
}
//# sourceMappingURL=common.js.map