"use strict";

exports.__esModule = true;
exports.assignRef = assignRef;
exports.mergeRefs = mergeRefs;
var _assertions = require("./assertions");
function assignRef(ref, value) {
  if (ref == null) return;
  if ((0, _assertions.isFunction)(ref)) {
    ref(value);
    return;
  }
  try {
    ref.current = value;
  } catch (error) {
    throw new Error("Cannot assign value '" + value + "' to ref '" + ref + "'");
  }
}
function mergeRefs() {
  for (var _len = arguments.length, refs = new Array(_len), _key = 0; _key < _len; _key++) {
    refs[_key] = arguments[_key];
  }
  return function (node) {
    refs.forEach(function (ref) {
      return assignRef(ref, node);
    });
  };
}