Navan's frontend receives raw trip objects and must prepare them for an itinerary card list. Write a function that filters eligible trips, transforms each remaining object into a display-ready shape, and sorts the results by departure date.
A trip is eligible when its status is "confirmed", its totalCents is no greater than maxTotalCents, and its country appears in allowedCountries. The input order must not affect the required date ordering.
Implement transform_trips(trips, maxTotalCents, allowedCountries).
trips is an array of objects with string fields id, travelerName, city, country, departureDate, status, and integer field totalCents.maxTotalCents is a non-negative integer.allowedCountries is an array of country strings.id, traveler, route, totalCents, and departureDate.traveler to travelerName and route to "city, country".departureDate ascending. If dates are equal, sort by id ascending.trips or any input object.def transform_trips(trips, maxTotalCents, allowedCountries):