import { unescapeAll as u } from "../common/utils.js";
function c(o, n, t) {
  let r, e = n;
  const i = {
    ok: !1,
    pos: 0,
    str: ""
  };
  if (o.charCodeAt(e) === 60) {
    for (e++; e < t; ) {
      if (r = o.charCodeAt(e), r === 10 || r === 60)
        return i;
      if (r === 62)
        return i.pos = e + 1, i.str = u(o.slice(n + 1, e)), i.ok = !0, i;
      if (r === 92 && e + 1 < t) {
        e += 2;
        continue;
      }
      e++;
    }
    return i;
  }
  let f = 0;
  for (; e < t && (r = o.charCodeAt(e), !(r === 32 || r < 32 || r === 127)); ) {
    if (r === 92 && e + 1 < t) {
      if (o.charCodeAt(e + 1) === 32)
        break;
      e += 2;
      continue;
    }
    if (r === 40 && (f++, f > 32))
      return i;
    if (r === 41) {
      if (f === 0)
        break;
      f--;
    }
    e++;
  }
  return n === e || f !== 0 || (i.str = u(o.slice(n, e)), i.pos = e, i.ok = !0), i;
}
export {
  c as default
};
