function o(t) {
  return function(e) {
    var n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, r = n.width, c = r && t.matchPatterns[r] || t.matchPatterns[t.defaultMatchWidth], f = e.match(c);
    if (!f)
      return null;
    var u = f[0], l = r && t.parsePatterns[r] || t.parsePatterns[t.defaultParseWidth], d = Array.isArray(l) ? s(l, function(i) {
      return i.test(u);
    }) : h(l, function(i) {
      return i.test(u);
    }), a;
    a = t.valueCallback ? t.valueCallback(d) : d, a = n.valueCallback ? n.valueCallback(a) : a;
    var v = e.slice(u.length);
    return {
      value: a,
      rest: v
    };
  };
}
function h(t, e) {
  for (var n in t)
    if (t.hasOwnProperty(n) && e(t[n]))
      return n;
}
function s(t, e) {
  for (var n = 0; n < t.length; n++)
    if (e(t[n]))
      return n;
}
export {
  o as default
};
