 ///  ProfileHeaderCellSizeCalculator.swift
 //
 
-import Foundation
+import FutureKit
 
 
 public class ProfileHeaderCellSizeCalculator: NSObject {
     static let ratio: CGFloat = 16 / 9
     let webView: UIWebView
 
-    private let label = ElloLabel()
     private var maxWidth: CGFloat = 0.0
     private typealias CellJob = (cellItems: [StreamCellItem], width: CGFloat, columnCount: Int, completion: ElloEmptyCompletion)
     private var cellJobs: [CellJob] = []

        }
    }

// MARK: Private

    private func processJob(job: CellJob) {
        self.completion = {
            if self.cellJobs.count > 0 {
                self.cellJobs.removeAtIndex(0)

        }
    }

    func assignCellHeight(height: CGFloat) {

        if let cellItem = cellItems.safeValue(0) {
            self.cellItems.removeAtIndex(0)
            cellItem.calculatedWebHeight = height
            cellItem.calculatedOneColumnCellHeight = height
            cellItem.calculatedMultiColumnCellHeight = height
        }
        loadNext()
    }

    func calculateAggregateHeights(item: StreamCellItem) {
        var totalHeight: CGFloat = 0

        let futures = [
            ProfileActivitySizeCalculator().calculate(item),
            ProfileAvatarSizeCalculator().calculate(item),
            ProfileBioSizeCalculator().calculate(item),
            ProfileLinksSizeCalculator().calculate(item),
            ProfileNameSizeCalculator().calculate(item),
            ProfileViewsSizeCalculator().calculate(item)
        ]

        let done = after(futures.count) {
            self.assignCellHeight(totalHeight)
        }

        for future in futures {
            future
                .onSuccess { height in
                    totalHeight += height
                    done()
                }
                .onFailorCancel { _ in done() }
        }
    }
}

extension ProfileHeaderCellSizeCalculator: UIWebViewDelegate {
