import { isOrganizationAccessAllowed } from "@open-mercato/shared/lib/auth/organizationAccess";
function isOrganizationReadAccessAllowed(input) {
  const isSuperAdmin = input.auth?.isSuperAdmin === true;
  if (isSuperAdmin || input.scope?.allowedIds === null) return true;
  const allowedOrganizationIds = /* @__PURE__ */ new Set();
  if (input.scope?.filterIds?.length) {
    for (const id of input.scope.filterIds) {
      if (typeof id === "string" && id.trim().length) allowedOrganizationIds.add(id);
    }
  } else if (input.auth?.orgId) {
    allowedOrganizationIds.add(input.auth.orgId);
  }
  return isOrganizationAccessAllowed({
    isSuperAdmin,
    allowedOrganizationIds: Array.from(allowedOrganizationIds),
    targetOrganizationId: input.organizationId
  });
}
export {
  isOrganizationReadAccessAllowed
};
//# sourceMappingURL=organizationScopeGuard.js.map
