var __extends = (this && this.__extends) || function (d, b) {
    for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
    function __() { this.constructor = d; }
    d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
import { NgZone } from '@angular/core';
import { App } from '../components/app/app';
import { Config } from '../config/config';
import { Content } from '../components/content/content';
import { DeepLinker } from '../navigation/deep-linker';
import { DomController } from '../platform/dom-controller';
import { GestureController } from '../gestures/gesture-controller';
import { Haptic } from '../tap-click/haptic';
import { IonicApp } from '../components/app/app-root';
import { Keyboard } from '../platform/keyboard';
import { Menu } from '../components/menu/menu';
import { NavControllerBase } from '../navigation/nav-controller-base';
import { OverlayPortal } from '../components/nav/overlay-portal';
import { PageTransition } from '../transitions/page-transition';
import { Platform } from '../platform/platform';
import { QueryParams } from '../platform/query-params';
import { Tab } from '../components/tabs/tab';
import { Tabs } from '../components/tabs/tabs';
import { TransitionController } from '../transitions/transition-controller';
import { UrlSerializer } from '../navigation/url-serializer';
import { ViewController } from '../navigation/view-controller';
import { ViewState } from '../navigation/nav-util';
/**
 * @param {?=} config
 * @param {?=} url
 * @param {?=} platform
 * @return {?}
 */
export function mockConfig(config, url, platform) {
    if (url === void 0) { url = '/'; }
    var /** @type {?} */ c = new Config();
    var /** @type {?} */ p = platform || mockPlatform();
    c.init(config, p);
    return c;
}
/**
 * @param {?=} url
 * @return {?}
 */
export function mockQueryParams(url) {
    if (url === void 0) { url = '/'; }
    var /** @type {?} */ qp = new QueryParams();
    qp.parseUrl(url);
    return qp;
}
/**
 * @return {?}
 */
export function mockPlatform() {
    return new MockPlatform();
}
export var MockPlatform = (function (_super) {
    __extends(MockPlatform, _super);
    function MockPlatform() {
        _super.call(this);
        this.timeoutIds = 0;
        this.timeouts = [];
        this.rafIds = 0;
        this.timeStamps = 0;
        this.rafs = [];
        var doc = document.implementation.createHTMLDocument('');
        this.setWindow(window);
        this.setDocument(doc);
        this.setCssProps(doc.documentElement);
    }
    /**
     * @param {?} callback
     * @param {?} timeout
     * @return {?}
     */
    MockPlatform.prototype.timeout = function (callback, timeout) {
        var /** @type {?} */ timeoutId = ++this.timeoutIds;
        this.timeouts.push({
            callback: callback,
            timeout: timeout,
            timeoutId: timeoutId
        });
        return timeoutId;
    };
    /**
     * @param {?} timeoutId
     * @return {?}
     */
    MockPlatform.prototype.cancelTimeout = function (timeoutId) {
        for (var /** @type {?} */ i = 0; i < this.timeouts.length; i++) {
            if (timeoutId === this.timeouts[i].timeoutId) {
                this.timeouts.splice(i, 1);
                break;
            }
        }
    };
    /**
     * @param {?} done
     * @return {?}
     */
    MockPlatform.prototype.flushTimeouts = function (done) {
        var _this = this;
        setTimeout(function () {
            _this.timeouts.sort(function (a, b) {
                if (a.timeout < b.timeout)
                    return -1;
                if (a.timeout > b.timeout)
                    return 1;
                return 0;
            }).forEach(function (t) {
                t.callback();
            });
            _this.timeouts.length = 0;
            done();
        });
    };
    /**
     * @param {?} timeout
     * @param {?} done
     * @return {?}
     */
    MockPlatform.prototype.flushTimeoutsUntil = function (timeout, done) {
        var _this = this;
        setTimeout(function () {
            _this.timeouts.sort(function (a, b) {
                if (a.timeout < b.timeout)
                    return -1;
                if (a.timeout > b.timeout)
                    return 1;
                return 0;
            });
            var /** @type {?} */ keepers = [];
            _this.timeouts.forEach(function (t) {
                if (t.timeout < timeout) {
                    t.callback();
                }
                else {
                    keepers.push(t);
                }
            });
            _this.timeouts = keepers;
            done();
        });
    };
    /**
     * @param {?} callback
     * @return {?}
     */
    MockPlatform.prototype.raf = function (callback) {
        var /** @type {?} */ rafId = ++this.rafIds;
        this.rafs.push({
            callback: callback,
            rafId: rafId
        });
        return rafId;
    };
    /**
     * @param {?} rafId
     * @return {?}
     */
    MockPlatform.prototype.cancelRaf = function (rafId) {
        for (var /** @type {?} */ i = 0; i < this.rafs.length; i++) {
            if (rafId === this.rafs[i].rafId) {
                this.rafs.splice(i, 1);
                break;
            }
        }
    };
    /**
     * @param {?} done
     * @return {?}
     */
    MockPlatform.prototype.flushRafs = function (done) {
        var _this = this;
        var /** @type {?} */ timestamp = ++this.timeStamps;
        setTimeout(function () {
            _this.rafs.forEach(function (raf) {
                raf.callback(timestamp);
            });
            _this.rafs.length = 0;
            done(timestamp);
        });
    };
    return MockPlatform;
}(Platform));
function MockPlatform_tsickle_Closure_declarations() {
    /** @type {?} */
    MockPlatform.prototype.timeoutIds;
    /** @type {?} */
    MockPlatform.prototype.timeouts;
    /** @type {?} */
    MockPlatform.prototype.rafIds;
    /** @type {?} */
    MockPlatform.prototype.timeStamps;
    /** @type {?} */
    MockPlatform.prototype.rafs;
}
/**
 * @param {?=} platform
 * @return {?}
 */
export function mockDomController(platform) {
    platform = platform || mockPlatform();
    return new MockDomController(platform);
}
export var MockDomController = (function (_super) {
    __extends(MockDomController, _super);
    /**
     * @param {?} mockedPlatform
     */
    function MockDomController(mockedPlatform) {
        _super.call(this, mockedPlatform);
        this.mockedPlatform = mockedPlatform;
    }
    /**
     * @param {?} done
     * @return {?}
     */
    MockDomController.prototype.flush = function (done) {
        var _this = this;
        this.mockedPlatform.flushTimeouts(function () {
            _this.mockedPlatform.flushRafs(function (timeStamp) {
                done(timeStamp);
            });
        });
    };
    /**
     * @param {?} timeout
     * @param {?} done
     * @return {?}
     */
    MockDomController.prototype.flushUntil = function (timeout, done) {
        var _this = this;
        this.mockedPlatform.flushTimeoutsUntil(timeout, function () {
            _this.mockedPlatform.flushRafs(function (timeStamp) {
                done(timeStamp);
            });
        });
    };
    return MockDomController;
}(DomController));
function MockDomController_tsickle_Closure_declarations() {
    /** @type {?} */
    MockDomController.prototype.mockedPlatform;
}
/**
 * @param {?=} config
 * @param {?=} platform
 * @return {?}
 */
export function mockApp(config, platform) {
    platform = platform || mockPlatform();
    config = config || mockConfig(null, '/', platform);
    var /** @type {?} */ app = new App(config, platform);
    mockIonicApp(app, config, platform);
    return app;
}
/**
 * @param {?} app
 * @param {?} config
 * @param {?} plt
 * @return {?}
 */
export function mockIonicApp(app, config, plt) {
    var /** @type {?} */ appRoot = new IonicApp(null, null, mockElementRef(), mockRenderer(), config, plt, app);
    appRoot._loadingPortal = mockOverlayPortal(app, config, plt);
    appRoot._toastPortal = mockOverlayPortal(app, config, plt);
    appRoot._overlayPortal = mockOverlayPortal(app, config, plt);
    appRoot._modalPortal = mockOverlayPortal(app, config, plt);
    return appRoot;
}
export var /** @type {?} */ mockTrasitionController = function (config) {
    var /** @type {?} */ platform = mockPlatform();
    platform.raf = (function (callback) {
        callback();
    });
    var /** @type {?} */ trnsCtrl = new TransitionController(platform, config);
    trnsCtrl.get = function (trnsId, enteringView, leavingView, opts) {
        var /** @type {?} */ trns = new PageTransition(platform, enteringView, leavingView, opts);
        trns.trnsId = trnsId;
        return trns;
    };
    return trnsCtrl;
};
/**
 * @return {?}
 */
export function mockContent() {
    var /** @type {?} */ platform = mockPlatform();
    return new Content(mockConfig(), platform, mockDomController(platform), mockElementRef(), mockRenderer(), null, null, mockZone(), null, null);
}
/**
 * @return {?}
 */
export function mockZone() {
    return new NgZone(false);
}
/**
 * @return {?}
 */
export function mockChangeDetectorRef() {
    var /** @type {?} */ cd = {
        reattach: function () { },
        detach: function () { },
        detectChanges: function () { }
    };
    return cd;
}
export var MockElementRef = (function () {
    function MockElementRef() {
        this.nativeElement = new MockElement();
    }
    return MockElementRef;
}());
function MockElementRef_tsickle_Closure_declarations() {
    /** @type {?} */
    MockElementRef.prototype.nativeElement;
}
export var MockElement = (function () {
    function MockElement() {
        this.children = [];
        this.classList = new ClassList();
        this.attributes = {};
        this.style = {};
        this.clientWidth = 0;
        this.clientHeight = 0;
        this.clientTop = 0;
        this.clientLeft = 0;
        this.offsetWidth = 0;
        this.offsetHeight = 0;
        this.offsetTop = 0;
        this.offsetLeft = 0;
        this.scrollTop = 0;
        this.scrollHeight = 0;
    }
    Object.defineProperty(MockElement.prototype, "className", {
        /**
         * @return {?}
         */
        get: function () {
            return this.classList.classes.join(' ');
        },
        /**
         * @param {?} val
         * @return {?}
         */
        set: function (val) {
            this.classList.classes = val.split(' ');
        },
        enumerable: true,
        configurable: true
    });
    /**
     * @param {?} name
     * @return {?}
     */
    MockElement.prototype.hasAttribute = function (name) {
        return !!this.attributes[name];
    };
    /**
     * @param {?} name
     * @return {?}
     */
    MockElement.prototype.getAttribute = function (name) {
        return this.attributes[name];
    };
    /**
     * @param {?} name
     * @param {?} val
     * @return {?}
     */
    MockElement.prototype.setAttribute = function (name, val) {
        this.attributes[name] = val;
    };
    /**
     * @param {?} name
     * @return {?}
     */
    MockElement.prototype.removeAttribute = function (name) {
        delete this.attributes[name];
    };
    return MockElement;
}());
function MockElement_tsickle_Closure_declarations() {
    /** @type {?} */
    MockElement.prototype.children;
    /** @type {?} */
    MockElement.prototype.classList;
    /** @type {?} */
    MockElement.prototype.attributes;
    /** @type {?} */
    MockElement.prototype.style;
    /** @type {?} */
    MockElement.prototype.clientWidth;
    /** @type {?} */
    MockElement.prototype.clientHeight;
    /** @type {?} */
    MockElement.prototype.clientTop;
    /** @type {?} */
    MockElement.prototype.clientLeft;
    /** @type {?} */
    MockElement.prototype.offsetWidth;
    /** @type {?} */
    MockElement.prototype.offsetHeight;
    /** @type {?} */
    MockElement.prototype.offsetTop;
    /** @type {?} */
    MockElement.prototype.offsetLeft;
    /** @type {?} */
    MockElement.prototype.scrollTop;
    /** @type {?} */
    MockElement.prototype.scrollHeight;
}
export var ClassList = (function () {
    function ClassList() {
        this.classes = [];
    }
    /**
     * @param {?} className
     * @return {?}
     */
    ClassList.prototype.add = function (className) {
        if (!this.contains(className)) {
            this.classes.push(className);
        }
    };
    /**
     * @param {?} className
     * @return {?}
     */
    ClassList.prototype.remove = function (className) {
        var /** @type {?} */ index = this.classes.indexOf(className);
        if (index > -1) {
            this.classes.splice(index, 1);
        }
    };
    /**
     * @param {?} className
     * @return {?}
     */
    ClassList.prototype.toggle = function (className) {
        if (this.contains(className)) {
            this.remove(className);
        }
        else {
            this.add(className);
        }
    };
    /**
     * @param {?} className
     * @return {?}
     */
    ClassList.prototype.contains = function (className) {
        return this.classes.indexOf(className) > -1;
    };
    return ClassList;
}());
function ClassList_tsickle_Closure_declarations() {
    /** @type {?} */
    ClassList.prototype.classes;
}
/**
 * @return {?}
 */
export function mockElementRef() {
    return new MockElementRef();
}
export var MockRenderer = (function () {
    function MockRenderer() {
    }
    /**
     * @param {?} renderElement
     * @param {?} name
     * @param {?} val
     * @return {?}
     */
    MockRenderer.prototype.setElementAttribute = function (renderElement, name, val) {
        if (name === null) {
            renderElement.removeAttribute(name);
        }
        else {
            renderElement.setAttribute(name, val);
        }
    };
    /**
     * @param {?} renderElement
     * @param {?} className
     * @param {?} isAdd
     * @return {?}
     */
    MockRenderer.prototype.setElementClass = function (renderElement, className, isAdd) {
        if (isAdd) {
            renderElement.classList.add(className);
        }
        else {
            renderElement.classList.remove(className);
        }
    };
    /**
     * @param {?} renderElement
     * @param {?} styleName
     * @param {?} styleValue
     * @return {?}
     */
    MockRenderer.prototype.setElementStyle = function (renderElement, styleName, styleValue) {
        renderElement.style[styleName] = styleValue;
    };
    return MockRenderer;
}());
/**
 * @return {?}
 */
export function mockRenderer() {
    var /** @type {?} */ renderer = new MockRenderer();
    return renderer;
}
/**
 * @return {?}
 */
export function mockLocation() {
    var /** @type {?} */ location = {
        path: function () { return ''; },
        subscribe: function () { },
        go: function () { },
        back: function () { }
    };
    return location;
}
/**
 * @param {?=} component
 * @param {?=} data
 * @return {?}
 */
export function mockView(component, data) {
    if (!component) {
        component = MockView;
    }
    var /** @type {?} */ view = new ViewController(component, data);
    view.init(mockComponentRef());
    return view;
}
/**
 * @param {?} nav
 * @param {?} views
 * @return {?}
 */
export function mockViews(nav, views) {
    nav._views = views;
    views.forEach(function (v) { return v._setNav(nav); });
}
/**
 * @return {?}
 */
export function mockComponentRef() {
    var /** @type {?} */ componentRef = {
        location: mockElementRef(),
        changeDetectorRef: mockChangeDetectorRef(),
        destroy: function () { }
    };
    return componentRef;
}
/**
 * @param {?=} linkConfig
 * @param {?=} app
 * @return {?}
 */
export function mockDeepLinker(linkConfig, app) {
    if (linkConfig === void 0) { linkConfig = null; }
    var /** @type {?} */ serializer = new UrlSerializer(linkConfig);
    var /** @type {?} */ location = mockLocation();
    return new DeepLinker(app || mockApp(), serializer, location);
}
/**
 * @return {?}
 */
export function mockNavController() {
    var /** @type {?} */ platform = mockPlatform();
    var /** @type {?} */ config = mockConfig(null, '/', platform);
    var /** @type {?} */ app = mockApp(config, platform);
    var /** @type {?} */ zone = mockZone();
    var /** @type {?} */ dom = mockDomController(platform);
    var /** @type {?} */ keyboard = new Keyboard(config, platform, zone, dom);
    var /** @type {?} */ elementRef = mockElementRef();
    var /** @type {?} */ renderer = mockRenderer();
    var /** @type {?} */ componentFactoryResolver = null;
    var /** @type {?} */ gestureCtrl = new GestureController(app);
    var /** @type {?} */ linker = mockDeepLinker(null, app);
    var /** @type {?} */ trnsCtrl = mockTrasitionController(config);
    var /** @type {?} */ nav = new NavControllerBase(null, app, config, platform, keyboard, elementRef, zone, renderer, componentFactoryResolver, gestureCtrl, trnsCtrl, linker, dom);
    nav._viewInit = function (enteringView) {
        enteringView.init(mockComponentRef());
        enteringView._state = ViewState.INITIALIZED;
    };
    ((nav))._orgViewInsert = nav._viewAttachToDOM;
    nav._viewAttachToDOM = function (view, componentRef, viewport) {
        var /** @type {?} */ mockedViewport = {
            insert: function () { }
        };
        ((nav))._orgViewInsert(view, componentRef, mockedViewport);
    };
    return nav;
}
/**
 * @param {?} app
 * @param {?} config
 * @param {?} plt
 * @return {?}
 */
export function mockOverlayPortal(app, config, plt) {
    var /** @type {?} */ zone = mockZone();
    var /** @type {?} */ dom = mockDomController(plt);
    var /** @type {?} */ keyboard = new Keyboard(config, plt, zone, dom);
    var /** @type {?} */ elementRef = mockElementRef();
    var /** @type {?} */ renderer = mockRenderer();
    var /** @type {?} */ componentFactoryResolver = null;
    var /** @type {?} */ gestureCtrl = new GestureController(app);
    var /** @type {?} */ serializer = new UrlSerializer(null);
    var /** @type {?} */ location = mockLocation();
    var /** @type {?} */ deepLinker = new DeepLinker(app, serializer, location);
    return new OverlayPortal(app, config, plt, keyboard, elementRef, zone, renderer, componentFactoryResolver, gestureCtrl, null, deepLinker, null, dom);
}
/**
 * @param {?} parentTabs
 * @return {?}
 */
export function mockTab(parentTabs) {
    var /** @type {?} */ platform = mockPlatform();
    var /** @type {?} */ config = mockConfig(null, '/', platform);
    var /** @type {?} */ app = ((parentTabs))._app || mockApp(config, platform);
    var /** @type {?} */ zone = mockZone();
    var /** @type {?} */ dom = mockDomController(platform);
    var /** @type {?} */ keyboard = new Keyboard(config, platform, zone, dom);
    var /** @type {?} */ elementRef = mockElementRef();
    var /** @type {?} */ renderer = mockRenderer();
    var /** @type {?} */ changeDetectorRef = mockChangeDetectorRef();
    var /** @type {?} */ compiler = null;
    var /** @type {?} */ gestureCtrl = new GestureController(app);
    var /** @type {?} */ linker = mockDeepLinker(null, app);
    var /** @type {?} */ tab = new Tab(parentTabs, app, config, platform, keyboard, elementRef, zone, renderer, compiler, changeDetectorRef, gestureCtrl, null, linker, dom);
    tab.load = function (opts, cb) {
        cb();
    };
    return tab;
}
/**
 * @param {?=} app
 * @return {?}
 */
export function mockTabs(app) {
    var /** @type {?} */ platform = mockPlatform();
    var /** @type {?} */ config = mockConfig(null, '/', platform);
    app = app || mockApp(config, platform);
    var /** @type {?} */ elementRef = mockElementRef();
    var /** @type {?} */ renderer = mockRenderer();
    var /** @type {?} */ linker = mockDeepLinker();
    return new Tabs(null, null, app, config, elementRef, platform, renderer, linker);
}
/**
 * @return {?}
 */
export function mockMenu() {
    var /** @type {?} */ app = mockApp();
    var /** @type {?} */ gestureCtrl = new GestureController(app);
    var /** @type {?} */ dom = mockDomController();
    return new Menu(null, null, null, null, null, null, null, gestureCtrl, dom, app);
}
/**
 * @param {?=} links
 * @return {?}
 */
export function mockDeepLinkConfig(links) {
    return {
        links: links || [
            { component: MockView1, name: 'viewone' },
            { component: MockView2, name: 'viewtwo' },
            { component: MockView3, name: 'viewthree' },
            { component: MockView4, name: 'viewfour' },
            { component: MockView5, name: 'viewfive' }
        ]
    };
}
/**
 * @return {?}
 */
export function mockHaptic() {
    return new Haptic(mockPlatform());
}
export var MockView = (function () {
    function MockView() {
    }
    return MockView;
}());
export var MockView1 = (function () {
    function MockView1() {
    }
    return MockView1;
}());
export var MockView2 = (function () {
    function MockView2() {
    }
    return MockView2;
}());
export var MockView3 = (function () {
    function MockView3() {
    }
    return MockView3;
}());
export var MockView4 = (function () {
    function MockView4() {
    }
    return MockView4;
}());
export var MockView5 = (function () {
    function MockView5() {
    }
    return MockView5;
}());
/**
 * @return {?}
 */
export function noop() { return 'noop'; }
;
//# sourceMappingURL=mock-providers.js.map