   fileprivate struct SegmentCardsInfo {
     let segmentIndex: Int
     let segmentIdentifier: String?
+    let segmentMode: TKUISegmentMode
     let cards: [(TGCard, TKUISegmentMode)]
     let cardsRange: Range<Int>
     

      // We use the index here as the identifier would have changed. The index
      // gives us a good guess for finding the corresponding segment in the new
      // trip.
      let segmentIndex = SegmentCardsInfo.cardsInfo(ofCardAtIndex: currentPageIndex, in: segmentCards)?.segmentIndex
      let newSegment = cardSegments.first(where: { $0.index == segmentIndex }) ?? cardSegments.first!
      
      do {
        let newCard = try TKUITripModeByModeCard(

        )
        newCard.style = self.style
        newCard.modeByModeDelegate = self.modeByModeDelegate
        
        if let cardInfo = cardInfo, let offset = offsetToReach(mode: cardInfo.segmentMode, in: newSegment) {
          controller?.swap(for: newCard, animated: true, onCompletion: {
            newCard.move(to: newCard.currentPageIndex + offset)
          })
        } else {
          controller?.swap(for: newCard, animated: true)
        }
      } catch {
        TKLog.warn("Could not rebuild due to \(error)")
      }
