"use strict";

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var __awaiter = undefined && undefined.__awaiter || function (thisArg, _arguments, P, generator) {
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) {
            try {
                step(generator.next(value));
            } catch (e) {
                reject(e);
            }
        }
        function rejected(value) {
            try {
                step(generator["throw"](value));
            } catch (e) {
                reject(e);
            }
        }
        function step(result) {
            result.done ? resolve(result.value) : new P(function (resolve) {
                resolve(result.value);
            }).then(fulfilled, rejected);
        }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = undefined && undefined.__generator || function (thisArg, body) {
    var _ = { label: 0, sent: function sent() {
            if (t[0] & 1) throw t[1];return t[1];
        }, trys: [], ops: [] },
        f,
        y,
        t,
        g;
    return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () {
        return this;
    }), g;
    function verb(n) {
        return function (v) {
            return step([n, v]);
        };
    }
    function step(op) {
        if (f) throw new TypeError("Generator is already executing.");
        while (_) {
            try {
                if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
                if (y = 0, t) op = [op[0] & 2, t.value];
                switch (op[0]) {
                    case 0:case 1:
                        t = op;break;
                    case 4:
                        _.label++;return { value: op[1], done: false };
                    case 5:
                        _.label++;y = op[1];op = [0];continue;
                    case 7:
                        op = _.ops.pop();_.trys.pop();continue;
                    default:
                        if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
                            _ = 0;continue;
                        }
                        if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
                            _.label = op[1];break;
                        }
                        if (op[0] === 6 && _.label < t[1]) {
                            _.label = t[1];t = op;break;
                        }
                        if (t && _.label < t[2]) {
                            _.label = t[2];_.ops.push(op);break;
                        }
                        if (t[2]) _.ops.pop();
                        _.trys.pop();continue;
                }
                op = body.call(thisArg, _);
            } catch (e) {
                op = [6, e];y = 0;
            } finally {
                f = t = 0;
            }
        }if (op[0] & 5) throw op[1];return { value: op[0] ? op[1] : void 0, done: true };
    }
};
Object.defineProperty(exports, "__esModule", { value: true });
var React = require("react");
var ReactDOM = require("react-dom");
var MiddlewareApp_1 = require("./components/MiddlewareApp");
require("./index.css");
var apollo_link_http_1 = require("apollo-link-http");
var buildPrismaSchema_1 = require("./utils/buildPrismaSchema");
// import { exampleSchema } from './fixtures/exampleSchema'
if (process.env.NODE_ENV !== 'production') {}
/* tslint:disable-next-line */
// const { whyDidYouUpdate } = require('why-did-you-update')
// whyDidYouUpdate(React)

/* tslint:disable-next-line */
;
window['GraphQLPlayground'] = {
    init: function init(element, options) {
        return __awaiter(this, void 0, void 0, function () {
            var _a;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        if (!options.datamodelEndpoint) return [3 /*break*/, 2];
                        _a = options;
                        return [4 /*yield*/, buildPrismaSchema_1.buildPrismaSchema(options.datamodelEndpoint)];
                    case 1:
                        _a.schema = _b.sent();
                        _b.label = 2;
                    case 2:
                        ReactDOM.render(React.createElement(MiddlewareApp_1.default, _extends({ setTitle: true, showNewWorkspace: false }, options, { createApolloLink: customLinkCreator })), element);
                        return [2 /*return*/];
                }
            });
        });
    }
};
// const configString = `projects:
// app:
//   schemaPath: "src/schema.graphql"
//   extensions:
//     endpoints:
//       default: "http://localhost:4000"
// database:
//   schemaPath: "src/generated/prisma.graphql"
//   extensions:
//     prisma: database/prisma.yml`
// const config = {
//   projects: {
//     prisma: {
//       schemaPath: 'src/generated/prisma.graphql',
//       includes: ['database/seed.graphql'],
//       extensions: {
//         prisma: 'database/prisma.yml',
//         'prepare-binding': {
//           output: 'src/generated/prisma.ts',
//           generator: 'prisma-ts',
//         },
//         endpoints: {
//           dev2: {
//             url: 'https://eu1.prisma.sh/public-asdf/session65/dev',
//             // headers: {
//             //   Authorization:
//             //     'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjp7InNlcnZpY2UiOiJhc2RmQGRldiIsInJvbGVzIjpbImFkbWluIl19LCJpYXQiOjE1MjM1MTg3NTYsImV4cCI6MTUyNDEyMzU1Nn0.fzKhXa1JpN9M1UGTbS6p2KMUWDrKLxYD3i3a9eVfOQQ',
//             // },
//           },
//         },
//       },
//     },
//     app: {
//       schemaPath: 'src/schema.graphql',
//       includes: ['queries/{booking,queries}.graphql'],
//       extensions: {
//         endpoints: {
//           default: 'http://localhost:4000',
//         },
//       },
//     },
//   },
// }
// const tabs: Tab[] = [
//   {
//     query: '{ users { id } }',
//     endpoint: 'https://eu1.prisma.sh/public-asdf/session65/dev',
//     responses: ['{}'],
//   },
//   {
//     query: '{ users { id } }',
//     endpoint: 'https://eu1.prisma.sh/public-asdf/session65/dev',
//   },
// ]
var customLinkCreator = function customLinkCreator(session, wsEndpoint) {
    var headers = session.headers,
        credentials = session.credentials;
    var link = new apollo_link_http_1.HttpLink({
        uri: session.endpoint,
        fetch: fetch,
        headers: headers,
        credentials: credentials
    });
    return { link: link };
};
// const lightEditorColours = {
//   property: '#328c8c',
//   comment: 'rgba(0, 0, 0, 0.3)',
//   punctuation: 'rgba(23,42,58,.8)',
//   keyword: '#366b6b',
//   def: 'rgb(56, 189, 193)',
//   qualifier: '#1c92a9',
//   attribute: '#b56531',
//   number: '#1f6ed6;',
//   string: '#d64292',
//   builtin: '#d47509',
//   string2: '#0b7fc7',
//   variable: 'rgb(236, 95, 103)',
//   meta: '#b33086',
//   atom: 'rgb(245, 160, 0)',
//   ws: 'rgba(23, 42, 58, 0.8)',
//   selection: '#d1e9fd',
//   cursorColor: 'rgba(0, 0, 0, 0.4)',
//   editorBackground: '#f6f7f7',
//   resultBackground: '#eeeff0',
//   leftDrawerBackground: '#e9eaea',
//   rightDrawerBackground: '#e5e7e7',
// }
//# sourceMappingURL=localDevIndex.jsx.map