const RESERVED_SYSTEM_ENTITY_TYPES = /* @__PURE__ */ new Set([
  "entities:custom_entity",
  "entities:custom_entity_storage",
  "entities:custom_field_def",
  "entities:custom_field_value",
  "query_index:entity_index_row",
  "query_index:entity_index_coverage",
  "query_index:search_token"
]);
function isSystemEntitySelectable(entityId) {
  if (!entityId) return false;
  return !RESERVED_SYSTEM_ENTITY_TYPES.has(entityId);
}
function flattenSystemEntityIds(allEntities, options) {
  if (!allEntities) return [];
  const predicate = options?.predicate || isSystemEntitySelectable;
  const seen = /* @__PURE__ */ new Set();
  for (const bucket of Object.values(allEntities)) {
    for (const id of Object.values(bucket ?? {})) {
      if (typeof id !== "string" || id.length === 0) continue;
      if (!predicate(id)) continue;
      seen.add(id);
    }
  }
  return Array.from(seen).sort((a, b) => a.localeCompare(b));
}
function filterSelectableSystemEntityIds(entityIds) {
  const selected = [];
  for (const id of entityIds) {
    if (isSystemEntitySelectable(id)) selected.push(id);
  }
  return selected;
}
function isReservedSystemEntityType(entityId) {
  return RESERVED_SYSTEM_ENTITY_TYPES.has(entityId);
}
export {
  filterSelectableSystemEntityIds,
  flattenSystemEntityIds,
  isReservedSystemEntityType,
  isSystemEntitySelectable
};
//# sourceMappingURL=system-entities.js.map
