(function webpackUniversalModuleDefinition(root, factory) {
	if(typeof exports === 'object' && typeof module === 'object')
		module.exports = factory();
	else if(typeof define === 'function' && define.amd)
		define([], factory);
	else if(typeof exports === 'object')
		exports["devworkspace-client"] = factory();
	else
		root["devworkspace-client"] = factory();
})(window, function() {
return /******/ (function(modules) { // webpackBootstrap
/******/ 	// The module cache
/******/ 	var installedModules = {};
/******/
/******/ 	// The require function
/******/ 	function __webpack_require__(moduleId) {
/******/
/******/ 		// Check if module is in cache
/******/ 		if(installedModules[moduleId]) {
/******/ 			return installedModules[moduleId].exports;
/******/ 		}
/******/ 		// Create a new module (and put it into the cache)
/******/ 		var module = installedModules[moduleId] = {
/******/ 			i: moduleId,
/******/ 			l: false,
/******/ 			exports: {}
/******/ 		};
/******/
/******/ 		// Execute the module function
/******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ 		// Flag the module as loaded
/******/ 		module.l = true;
/******/
/******/ 		// Return the exports of the module
/******/ 		return module.exports;
/******/ 	}
/******/
/******/
/******/ 	// expose the modules object (__webpack_modules__)
/******/ 	__webpack_require__.m = modules;
/******/
/******/ 	// expose the module cache
/******/ 	__webpack_require__.c = installedModules;
/******/
/******/ 	// define getter function for harmony exports
/******/ 	__webpack_require__.d = function(exports, name, getter) {
/******/ 		if(!__webpack_require__.o(exports, name)) {
/******/ 			Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ 		}
/******/ 	};
/******/
/******/ 	// define __esModule on exports
/******/ 	__webpack_require__.r = function(exports) {
/******/ 		if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ 			Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ 		}
/******/ 		Object.defineProperty(exports, '__esModule', { value: true });
/******/ 	};
/******/
/******/ 	// create a fake namespace object
/******/ 	// mode & 1: value is a module id, require it
/******/ 	// mode & 2: merge all properties of value into the ns
/******/ 	// mode & 4: return value when already ns object
/******/ 	// mode & 8|1: behave like require
/******/ 	__webpack_require__.t = function(value, mode) {
/******/ 		if(mode & 1) value = __webpack_require__(value);
/******/ 		if(mode & 8) return value;
/******/ 		if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ 		var ns = Object.create(null);
/******/ 		__webpack_require__.r(ns);
/******/ 		Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ 		if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ 		return ns;
/******/ 	};
/******/
/******/ 	// getDefaultExport function for compatibility with non-harmony modules
/******/ 	__webpack_require__.n = function(module) {
/******/ 		var getter = module && module.__esModule ?
/******/ 			function getDefault() { return module['default']; } :
/******/ 			function getModuleExports() { return module; };
/******/ 		__webpack_require__.d(getter, 'a', getter);
/******/ 		return getter;
/******/ 	};
/******/
/******/ 	// Object.prototype.hasOwnProperty.call
/******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ 	// __webpack_public_path__
/******/ 	__webpack_require__.p = "";
/******/
/******/
/******/ 	// Load entry module and return exports
/******/ 	return __webpack_require__(__webpack_require__.s = "./src/index.ts");
/******/ })
/************************************************************************/
/******/ ({

/***/ "./node_modules/process/browser.js":
/*!*****************************************!*\
  !*** ./node_modules/process/browser.js ***!
  \*****************************************/
/*! no static exports found */
/***/ (function(module, exports) {



/***/ }),

/***/ "./src/browser/helper.ts":
/*!*******************************!*\
  !*** ./src/browser/helper.ts ***!
  \*******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    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) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { 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 });
exports.findApi = exports.isOpenShiftCluster = void 0;
var common_1 = __webpack_require__(/*! ../common */ "./src/common/index.ts");
function isOpenShiftCluster(axios) {
    return __awaiter(this, void 0, void 0, function () {
        return __generator(this, function (_a) {
            return [2 /*return*/, findApi(axios, common_1.projectApiGroup)];
        });
    });
}
exports.isOpenShiftCluster = isOpenShiftCluster;
function findApi(axios, apiName, version) {
    return __awaiter(this, void 0, void 0, function () {
        var resp, responseData;
        return __generator(this, function (_a) {
            switch (_a.label) {
                case 0: return [4 /*yield*/, axios.get('/apis')];
                case 1:
                    resp = _a.sent();
                    return [4 /*yield*/, resp.data.groups];
                case 2:
                    responseData = _a.sent();
                    return [2 /*return*/, responseData.filter(function (apiGroup) {
                            if (version) {
                                return apiGroup.name === apiName && apiGroup.versions.filter(function (versionGroup) { return versionGroup.version === version; }).length > 0;
                            }
                            return apiGroup.name === apiName;
                        }).length > 0];
            }
        });
    });
}
exports.findApi = findApi;


/***/ }),

/***/ "./src/browser/index.ts":
/*!******************************!*\
  !*** ./src/browser/index.ts ***!
  \******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    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) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { 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 });
exports.RestApi = void 0;
var common_1 = __webpack_require__(/*! ../common */ "./src/common/index.ts");
var helper_1 = __webpack_require__(/*! ./helper */ "./src/browser/helper.ts");
var workspace_api_1 = __webpack_require__(/*! ./workspace-api */ "./src/browser/workspace-api.ts");
var template_api_1 = __webpack_require__(/*! ./template-api */ "./src/browser/template-api.ts");
var RestApi = /** @class */ (function () {
    function RestApi(axios) {
        this.axios = axios;
        this._workspaceApi = new workspace_api_1.RestDevWorkspaceApi(axios);
        this._templateApi = new template_api_1.RestDevWorkspaceTemplateApi(axios);
    }
    Object.defineProperty(RestApi.prototype, "workspaceApi", {
        get: function () {
            return this._workspaceApi;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(RestApi.prototype, "templateApi", {
        get: function () {
            return this._templateApi;
        },
        enumerable: false,
        configurable: true
    });
    RestApi.prototype.isDevWorkspaceApiEnabled = function () {
        return __awaiter(this, void 0, void 0, function () {
            var _a;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        if (this.apiEnabled !== undefined) {
                            return [2 /*return*/, Promise.resolve(this.apiEnabled)];
                        }
                        _a = this;
                        return [4 /*yield*/, helper_1.findApi(this.axios, common_1.devWorkspaceApiGroup, common_1.devworkspaceVersion)];
                    case 1:
                        _a.apiEnabled = _b.sent();
                        return [2 /*return*/, this.apiEnabled];
                }
            });
        });
    };
    return RestApi;
}());
exports.RestApi = RestApi;


/***/ }),

/***/ "./src/browser/template-api.ts":
/*!*************************************!*\
  !*** ./src/browser/template-api.ts ***!
  \*************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    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) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { 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 });
exports.RestDevWorkspaceTemplateApi = void 0;
var common_1 = __webpack_require__(/*! ../common */ "./src/common/index.ts");
var RestDevWorkspaceTemplateApi = /** @class */ (function () {
    function RestDevWorkspaceTemplateApi(axios) {
        this.axios = axios;
    }
    RestDevWorkspaceTemplateApi.prototype.listInNamespace = function (namespace) {
        return __awaiter(this, void 0, void 0, function () {
            var resp;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.axios.get("/apis/" + common_1.devWorkspaceApiGroup + "/" + common_1.devworkspaceVersion + "/namespaces/" + namespace + "/" + common_1.devworkspaceTemplateSubresource)];
                    case 1:
                        resp = _a.sent();
                        return [2 /*return*/, resp.data.items];
                }
            });
        });
    };
    RestDevWorkspaceTemplateApi.prototype.getByName = function (namespace, workspaceName) {
        return __awaiter(this, void 0, void 0, function () {
            var resp;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.axios.get("/apis/" + common_1.devWorkspaceApiGroup + "/" + common_1.devworkspaceVersion + "/namespaces/" + namespace + "/" + common_1.devworkspaceTemplateSubresource + "/" + workspaceName)];
                    case 1:
                        resp = _a.sent();
                        return [2 /*return*/, resp.data];
                }
            });
        });
    };
    RestDevWorkspaceTemplateApi.prototype.create = function (devworkspaceTemplate) {
        return __awaiter(this, void 0, void 0, function () {
            var resp;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.axios.post("/apis/" + common_1.devWorkspaceApiGroup + "/" + common_1.devworkspaceVersion + "/namespaces/" + devworkspaceTemplate.metadata.namespace + "/" + common_1.devworkspaceTemplateSubresource, devworkspaceTemplate, {
                            headers: {
                                'content-type': 'application/json; charset=utf-8',
                            },
                        })];
                    case 1:
                        resp = _a.sent();
                        return [2 /*return*/, resp.data];
                }
            });
        });
    };
    RestDevWorkspaceTemplateApi.prototype.delete = function (namespace, name) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                this.axios.delete("/apis/" + common_1.devWorkspaceApiGroup + "/" + common_1.devworkspaceVersion + "/namespaces/" + namespace + "/" + common_1.devworkspaceTemplateSubresource + "/" + name);
                return [2 /*return*/];
            });
        });
    };
    return RestDevWorkspaceTemplateApi;
}());
exports.RestDevWorkspaceTemplateApi = RestDevWorkspaceTemplateApi;


/***/ }),

/***/ "./src/browser/workspace-api.ts":
/*!**************************************!*\
  !*** ./src/browser/workspace-api.ts ***!
  \**************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    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) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
var __generator = (this && this.__generator) || function (thisArg, body) {
    var _ = { label: 0, sent: function() { 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 });
exports.RestDevWorkspaceApi = void 0;
var injector_1 = __webpack_require__(/*! ../common/injector */ "./src/common/injector.ts");
var converter_1 = __webpack_require__(/*! ../common/converter */ "./src/common/converter.ts");
var helper_1 = __webpack_require__(/*! ../common/helper */ "./src/common/helper.ts");
var common_1 = __webpack_require__(/*! ../common */ "./src/common/index.ts");
var models_1 = __webpack_require__(/*! ../common/models */ "./src/common/models.ts");
var helper_2 = __webpack_require__(/*! ./helper */ "./src/browser/helper.ts");
var RestDevWorkspaceApi = /** @class */ (function () {
    function RestDevWorkspaceApi(axios) {
        this.axios = axios;
    }
    RestDevWorkspaceApi.prototype.listInNamespace = function (namespace) {
        return __awaiter(this, void 0, void 0, function () {
            var resp;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.axios.get("/apis/" + common_1.devWorkspaceApiGroup + "/" + common_1.devworkspaceVersion + "/namespaces/" + namespace + "/" + common_1.devworkspaceSubresource)];
                    case 1:
                        resp = _a.sent();
                        return [2 /*return*/, resp.data.items];
                }
            });
        });
    };
    RestDevWorkspaceApi.prototype.getByName = function (namespace, workspaceName) {
        return __awaiter(this, void 0, void 0, function () {
            var resp;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.axios.get("/apis/" + common_1.devWorkspaceApiGroup + "/" + common_1.devworkspaceVersion + "/namespaces/" + namespace + "/" + common_1.devworkspaceSubresource + "/" + workspaceName)];
                    case 1:
                        resp = _a.sent();
                        return [2 /*return*/, resp.data];
                }
            });
        });
    };
    RestDevWorkspaceApi.prototype.create = function (devfile, defaultEditor, defaultPlugins) {
        return __awaiter(this, void 0, void 0, function () {
            var devworkspace, pluginsNeeded, _i, pluginsNeeded_1, plugin, stringifiedDevWorkspace, resp, responseData, namespace, name, found, count, potentialWorkspace;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        devworkspace = converter_1.devfileToDevWorkspace(devfile);
                        if (defaultEditor && !injector_1.hasEditor(devfile)) {
                            devworkspace.spec.template.components.push(injector_1.createKubernetesComponent(defaultEditor));
                        }
                        pluginsNeeded = defaultPlugins
                            ? injector_1.pluginsToInject(devfile, defaultPlugins)
                            : [];
                        if (pluginsNeeded.length > 0) {
                            for (_i = 0, pluginsNeeded_1 = pluginsNeeded; _i < pluginsNeeded_1.length; _i++) {
                                plugin = pluginsNeeded_1[_i];
                                devworkspace.spec.template.components.push(injector_1.createKubernetesComponent(plugin));
                            }
                        }
                        stringifiedDevWorkspace = JSON.stringify(devworkspace);
                        return [4 /*yield*/, this.axios.post("/apis/" + common_1.devWorkspaceApiGroup + "/" + common_1.devworkspaceVersion + "/namespaces/" + devfile.metadata.namespace + "/" + common_1.devworkspaceSubresource, stringifiedDevWorkspace, {
                                headers: {
                                    'content-type': 'application/json; charset=utf-8',
                                },
                            })];
                    case 1:
                        resp = _a.sent();
                        return [4 /*yield*/, resp.data];
                    case 2:
                        responseData = _a.sent();
                        namespace = responseData.metadata.namespace;
                        name = responseData.metadata.name;
                        count = 0;
                        _a.label = 3;
                    case 3:
                        if (!(count < 5 && !found)) return [3 /*break*/, 5];
                        return [4 /*yield*/, this.getByName(namespace, name)];
                    case 4:
                        potentialWorkspace = _a.sent();
                        if (potentialWorkspace === null || potentialWorkspace === void 0 ? void 0 : potentialWorkspace.status) {
                            found = potentialWorkspace;
                        }
                        else {
                            count += 1;
                            helper_1.delay();
                        }
                        return [3 /*break*/, 3];
                    case 5:
                        if (!found) {
                            throw new Error("Was not able to find a workspace with name " + name + " in namespace " + namespace);
                        }
                        return [2 /*return*/, found];
                }
            });
        });
    };
    RestDevWorkspaceApi.prototype.delete = function (namespace, name) {
        return __awaiter(this, void 0, void 0, function () {
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, this.axios.delete("/apis/" + common_1.devWorkspaceApiGroup + "/" + common_1.devworkspaceVersion + "/namespaces/" + namespace + "/" + common_1.devworkspaceSubresource + "/" + name)];
                    case 1:
                        _a.sent();
                        return [2 /*return*/];
                }
            });
        });
    };
    RestDevWorkspaceApi.prototype.changeStatus = function (namespace, name, started) {
        return __awaiter(this, void 0, void 0, function () {
            var patch, resp;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0:
                        patch = [
                            {
                                path: '/spec/started',
                                op: 'replace',
                                value: started,
                            },
                        ];
                        return [4 /*yield*/, this.axios.patch("/apis/" + common_1.devWorkspaceApiGroup + "/" + common_1.devworkspaceVersion + "/namespaces/" + namespace + "/" + common_1.devworkspaceSubresource + "/" + name, patch, {
                                headers: {
                                    'Content-type': 'application/json-patch+json',
                                },
                            })];
                    case 1:
                        resp = _a.sent();
                        return [2 /*return*/, resp.data];
                }
            });
        });
    };
    RestDevWorkspaceApi.prototype.initializeNamespace = function (namespace) {
        return __awaiter(this, void 0, void 0, function () {
            var isOpenShift, doesProjectAlreadyExist;
            return __generator(this, function (_a) {
                switch (_a.label) {
                    case 0: return [4 /*yield*/, helper_2.isOpenShiftCluster(this.axios)];
                    case 1:
                        isOpenShift = _a.sent();
                        if (!isOpenShift) return [3 /*break*/, 3];
                        return [4 /*yield*/, this.doesProjectExist(namespace)];
                    case 2:
                        doesProjectAlreadyExist = _a.sent();
                        if (!doesProjectAlreadyExist) {
                            this.createProject(namespace);
                        }
                        _a.label = 3;
                    case 3: return [2 /*return*/];
                }
            });
        });
    };
    RestDevWorkspaceApi.prototype.doesProjectExist = function (projectName) {
        return __awaiter(this, void 0, void 0, function () {
            var projects, _i, _a, proj, e_1;
            return __generator(this, function (_b) {
                switch (_b.label) {
                    case 0:
                        _b.trys.push([0, 2, , 3]);
                        return [4 /*yield*/, this.axios.get("/apis/" + common_1.projectApiGroup + "/v1/" + common_1.projectsId)];
                    case 1:
                        projects = _b.sent();
                        for (_i = 0, _a = projects.data.items; _i < _a.length; _i++) {
                            proj = _a[_i];
                            if (proj.metadata.name === projectName) {
                                return [2 /*return*/, true];
                            }
                        }
                        return [2 /*return*/, false];
                    case 2:
                        e_1 = _b.sent();
                        return [2 /*return*/, false];
                    case 3: return [2 /*return*/];
                }
            });
        });
    };
    RestDevWorkspaceApi.prototype.createProject = function (namespace) {
        this.axios.post("/apis/" + common_1.projectApiGroup + "/v1/" + common_1.projectRequestId, models_1.projectRequestModel(namespace));
    };
    return RestDevWorkspaceApi;
}());
exports.RestDevWorkspaceApi = RestDevWorkspaceApi;


/***/ }),

/***/ "./src/common/converter.ts":
/*!*********************************!*\
  !*** ./src/common/converter.ts ***!
  \*********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.devWorkspaceToDevfile = exports.devfileToDevWorkspace = void 0;
var _1 = __webpack_require__(/*! . */ "./src/common/index.ts");
function devfileToDevWorkspace(devfile) {
    devfile.metadata.annotations = {};
    var template = {
        apiVersion: _1.devWorkspaceApiGroup + "/" + _1.devworkspaceVersion,
        kind: 'DevWorkspace',
        metadata: devfile.metadata,
        spec: {
            started: true,
            template: {
                components: []
            }
        }
    };
    if (devfile.projects) {
        template.spec.template.projects = devfile.projects;
    }
    if (devfile.components) {
        template.spec.template.components = devfile.components;
    }
    if (devfile.commands) {
        template.spec.template.commands = devfile.commands;
    }
    if (devfile.events) {
        template.spec.template.events = devfile.events;
    }
    return template;
}
exports.devfileToDevWorkspace = devfileToDevWorkspace;
function devWorkspaceToDevfile(devworkspace) {
    var template = {
        schemaVersion: '2.0.0',
        metadata: {
            name: devworkspace.metadata.name,
            namespace: devworkspace.metadata.namespace
        },
    };
    if (devworkspace.spec.template.projects) {
        template.projects = devworkspace.spec.template.projects;
    }
    if (devworkspace.spec.template.components) {
        template.components = devworkspace.spec.template.components;
    }
    if (devworkspace.spec.template.commands) {
        template.commands = devworkspace.spec.template.commands;
    }
    if (devworkspace.spec.template.events) {
        template.events = devworkspace.spec.template.events;
    }
    return template;
}
exports.devWorkspaceToDevfile = devWorkspaceToDevfile;


/***/ }),

/***/ "./src/common/helper.ts":
/*!******************************!*\
  !*** ./src/common/helper.ts ***!
  \******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.delay = void 0;
var delay = function (ms) {
    if (ms === void 0) { ms = 500; }
    return new Promise(function (resolve) { return setTimeout(resolve, ms); });
};
exports.delay = delay;


/***/ }),

/***/ "./src/common/index.ts":
/*!*****************************!*\
  !*** ./src/common/index.ts ***!
  \*****************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.devWorkspaceApiGroup = exports.projectApiGroup = exports.projectRequestId = exports.projectsId = exports.devworkspaceTemplateSubresource = exports.devworkspaceSubresource = exports.devworkspaceVersion = void 0;
exports.devworkspaceVersion = 'v1alpha2';
exports.devworkspaceSubresource = 'devworkspaces';
exports.devworkspaceTemplateSubresource = 'devworkspacetemplates';
exports.projectsId = 'projects';
exports.projectRequestId = 'projectrequests';
exports.projectApiGroup = 'project.openshift.io';
exports.devWorkspaceApiGroup = 'workspace.devfile.io';


/***/ }),

/***/ "./src/common/injector.ts":
/*!********************************!*\
  !*** ./src/common/injector.ts ***!
  \********************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.createKubernetesComponent = exports.pluginsToInject = exports.hasPlugin = exports.hasEditor = void 0;
/**
 * Check the devfile to see an editor already exists
 * @param devfile a v2 devfile
 */
function hasEditor(devfile) {
    // no-op for now
    return false;
}
exports.hasEditor = hasEditor;
/**
 * Check to see if a plugin already exists in the devworkspace. A plugin is considered to already exist
 * if the pluginName matches a component name
 * @param devfile a v2 devfile
 * @param pluginName the name of the plugin you want to check
 */
function hasPlugin(devfile, pluginName) {
    if (!devfile.components) {
        return false;
    }
    for (var _i = 0, _a = devfile.components; _i < _a.length; _i++) {
        var component = _a[_i];
        if (component.name === pluginName) {
            return true;
        }
    }
    return false;
}
exports.hasPlugin = hasPlugin;
/**
 * Get a list of plugins that need to be injected into the devfile
 * @param devfile a v2 devfile
 * @param plugins the plugins you want to inject
 */
function pluginsToInject(devfile, plugins) {
    var pluginsNeeded = [];
    for (var _i = 0, plugins_1 = plugins; _i < plugins_1.length; _i++) {
        var plugin = plugins_1[_i];
        if (!hasPlugin(devfile, plugin)) {
            pluginsNeeded.push(plugin);
        }
    }
    return pluginsNeeded;
}
exports.pluginsToInject = pluginsToInject;
/**
 * Create a kubernetes component for an editor/plugin
 * @param componentName The name you want for the kubernetes component
 */
function createKubernetesComponent(componentName) {
    return {
        name: componentName,
        plugin: {
            kubernetes: {
                name: componentName,
                namespace: 'devworkspace-plugins'
            }
        }
    };
}
exports.createKubernetesComponent = createKubernetesComponent;


/***/ }),

/***/ "./src/common/models.ts":
/*!******************************!*\
  !*** ./src/common/models.ts ***!
  \******************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.projectRequestModel = void 0;
var _1 = __webpack_require__(/*! . */ "./src/common/index.ts");
var projectRequestModel = function (namespace) {
    return {
        apiVersion: _1.projectApiGroup + "/v1",
        kind: 'ProjectRequest',
        metadata: {
            name: namespace,
        },
    };
};
exports.projectRequestModel = projectRequestModel;


/***/ }),

/***/ "./src/index.ts":
/*!**********************!*\
  !*** ./src/index.ts ***!
  \**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";
/* WEBPACK VAR INJECTION */(function(process) {
/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
    for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DevWorkspaceClient = void 0;
var browser_1 = __webpack_require__(/*! ./browser */ "./src/browser/index.ts");
__exportStar(__webpack_require__(/*! ./common/converter */ "./src/common/converter.ts"), exports);
__exportStar(__webpack_require__(/*! ./types */ "./src/types.ts"), exports);
var DevWorkspaceClient = /** @class */ (function () {
    function DevWorkspaceClient() {
    }
    DevWorkspaceClient.getRestApi = function (axios) {
        return new browser_1.RestApi(axios);
    };
    DevWorkspaceClient.getNodeApi = function (config) {
        if (config === void 0) { config = {
            inCluster: true
        }; }
        if (!DevWorkspaceClient.isItNode()) {
            throw new Error('getNodeApi is only available when running in nodejs');
        }
        else {
            var nodeApi = __webpack_require__(/*! ./node */ "./src/node/index.ts").NodeApi;
            return new nodeApi(config);
        }
    };
    DevWorkspaceClient.isItNode = function () {
        return (typeof process !== 'undefined') && (typeof process.versions.node !== 'undefined');
    };
    return DevWorkspaceClient;
}());
exports.DevWorkspaceClient = DevWorkspaceClient;

/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../node_modules/process/browser.js */ "./node_modules/process/browser.js")))

/***/ }),

/***/ "./src/node/index.ts":
/*!***************************!*\
  !*** ./src/node/index.ts ***!
  \***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";



/***/ }),

/***/ "./src/types.ts":
/*!**********************!*\
  !*** ./src/types.ts ***!
  \**********************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {

"use strict";

/*
 * Copyright (c) 2018-2021 Red Hat, Inc.
 * This program and the accompanying materials are made
 * available under the terms of the Eclipse Public License 2.0
 * which is available at https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Red Hat, Inc. - initial API and implementation
 */
Object.defineProperty(exports, "__esModule", { value: true });


/***/ })

/******/ });
});
//# sourceMappingURL=client.js.map