"use strict";
var introspection_1 = require('./introspection');
/**
 * Plugin Base implementation
 */
var Plugin = (function () {
    function Plugin(document, urlResolver, graphdocPackage, projectPackage) {
        this.document = document;
        this.url = urlResolver;
        this.graphdocPackage = graphdocPackage;
        this.projectPackage = projectPackage;
        if (document.queryType) {
            this.queryType = this.document.types
                .find(function (type) { return type.name === document.queryType.name; });
        }
        if (document.mutationType) {
            this.mutationType = this.document.types
                .find(function (type) { return type.name === document.mutationType.name; });
        }
        if (document.subscriptionType) {
            this.subscriptionType = this.document.types
                .find(function (type) { return type.name === document.subscriptionType.name; });
        }
        this.document.types = this.document.types.sort(sortTypes);
        this.document.directives = this.document.directives.sort(function (a, b) { return a.name.localeCompare(b.name); });
    }
    Plugin.prototype.getNavigations = function (buildForType) {
        return [];
    };
    Plugin.prototype.getDocuments = function (buildForType) {
        return [];
    };
    Plugin.prototype.getHeaders = function (buildForType) {
        return [];
    };
    Plugin.prototype.getAssets = function () {
        return [];
    };
    return Plugin;
}());
exports.Plugin = Plugin;
var NavigationSection = (function () {
    function NavigationSection(title, items) {
        if (items === void 0) { items = []; }
        this.title = title;
        this.items = items;
    }
    return NavigationSection;
}());
exports.NavigationSection = NavigationSection;
var NavigationItem = (function () {
    function NavigationItem(text, href, isActive) {
        this.text = text;
        this.href = href;
        this.isActive = isActive;
    }
    return NavigationItem;
}());
exports.NavigationItem = NavigationItem;
/**
 *
 */
function resolveUrlFor(baseUrl) {
    return function resolveUrl(type) {
        var name = introspection_1.getTypeOf(type).name.toLowerCase();
        if (name[0] === '_' && name[1] === '_')
            return baseUrl + name.slice(2) + '.spec.html';
        return baseUrl + name + '.doc.html';
    };
}
exports.resolveUrlFor = resolveUrlFor;
;
function priorityType(type) {
    return (0 /* initial priority */ |
        (type.name[0] === '_' ? 1 : 0) /* protected type priority */ |
        (type.name[0] === '_' && type.name[1] === '_' ? 2 : 0) /* spec type priority */);
}
function sortTypes(a, b) {
    var priorityA = priorityType(a);
    var priorityB = priorityType(b);
    if (priorityA === priorityB) {
        return a.name.localeCompare(b.name);
    }
    else {
        return priorityA - priorityB;
    }
}
exports.sortTypes = sortTypes;
//# sourceMappingURL=plugin.js.map