import {
  getBorderPropControllerDataSwatchIds
} from "@makeswift/prop-controllers";
import { useSwatches } from "../../runtimes/react/hooks/makeswift-api";
import { isNonNullable } from "../utils/isNonNullable";
function mapSideColor(swatches, { color, ...restOfSide }) {
  return {
    ...restOfSide,
    color: color && {
      alpha: color.alpha,
      swatch: swatches.filter(isNonNullable).find((s) => s && s.id === color.swatchId)
    }
  };
}
function useBorder(value) {
  const swatchIds = getBorderPropControllerDataSwatchIds(value);
  const swatches = useSwatches(swatchIds);
  if (value == null)
    return void 0;
  return value.map(({ value: { borderTop, borderBottom, borderLeft, borderRight }, ...rest }) => ({
    ...rest,
    value: {
      borderTop: borderTop && mapSideColor(swatches, borderTop),
      borderBottom: borderBottom && mapSideColor(swatches, borderBottom),
      borderLeft: borderLeft && mapSideColor(swatches, borderLeft),
      borderRight: borderRight && mapSideColor(swatches, borderRight)
    }
  }));
}
export {
  useBorder
};
//# sourceMappingURL=useBorder.js.map