 out) > maxInt - n)
      error("overflow");
    n += floor(i / out), i %= out, output.splice(i++, 0, n);
  }
  return @String.fromCodePoint(...output);
}, encode = function(input_) {
  let output = [], input = ucs2decode(input_), inputLength = input.length, n = initialN, delta = 0, bias = initialBias;
  for (let currentValue of input)
    if (currentValue < 128)
      output.push(stringFromCharCode(currentValue));
  let basicLength = output.length, handledCPCount = basicLength;
  if (basicLength)
    output.push(delimiter);
  while (handledCPCount < inputLength) {
    let m = maxInt;
    for (let currentValue of input)
      if (currentValue >= n && currentValue < m)
        m = currentValue;
    let handledCPCountPlusOne = handledCPCount + 1;
    if (m - n > floor((maxInt - delta) / handledCPCountPlusOne))
      error("overflow");
    delta += (m - n) * handledCPCountPlusOne, n = m;
    for (let currentValue of input) {
      if (currentValue < n && ++delta > maxInt)
        error("overflow");
      if (currentValue === n) {
        let q = delta;
        for (let k = base;; k += base) {
          let t = k <= bias ? tMin : k >= bias + tMax ? tMax : k - bias;
          if (q < t)
            break;
          let qMinusT = q - t, baseMinusT = base - t;
          output.push(stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0))), q = floor(qMinusT / baseMinusT);
        }
        output.push(stringFromCharCode(digitToBasic(q, 0))), bias = adapt(delta, handledCPCountPlusOne, handledCPCount === basicLength), delta = 0, ++handledCPCount;
      }
    }
    ++delta, ++n;
  }
  return output.join("");
}, toUnicode = function(input) {
  return mapDomain(input, function(string) {
    return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
  });
}, toASCII = function(input) {
  return mapDomain(input, function(string) {
    return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
  });
};
$ = {
  version: "2.1.0",
  ucs2: {
    decode: ucs2decode,
    encode: ucs2encode
  },
  decode,
  encode,
  toASCII,
  toUnicode
};
return $})

