'use strict';

function isQueryEntitiesInitialRequest(request) {
  return !request.cursor;
}
function splitRefsIntoChunks(refs, options) {
  if (!refs.length) {
    return [];
  }
  const {
    maxCountPerChunk = 1e3,
    maxStringLengthPerChunk = 90 * 2 ** 10,
    extraStringLengthPerRef = 3
  } = {};
  const chunks = [];
  let currentChunkStart = 0;
  let currentChunkStringLength = 0;
  let currentChunkSize = 0;
  for (let i = 0; i < refs.length; ++i) {
    const refLength = refs[i].length + extraStringLengthPerRef;
    if (currentChunkSize > 0) {
      if (currentChunkStringLength + refLength > maxStringLengthPerChunk || currentChunkSize + 1 > maxCountPerChunk) {
        chunks.push(refs.slice(currentChunkStart, i));
        currentChunkStart = i;
        currentChunkStringLength = 0;
        currentChunkSize = 0;
      }
    }
    currentChunkStringLength += refLength;
    currentChunkSize += 1;
  }
  chunks.push(refs.slice(currentChunkStart, refs.length));
  return chunks;
}

exports.isQueryEntitiesInitialRequest = isQueryEntitiesInitialRequest;
exports.splitRefsIntoChunks = splitRefsIntoChunks;
//# sourceMappingURL=utils.cjs.js.map
