@lando/platformsh
Version:
A Lando plugin that provides a tight integration with Platform.sh.
2 lines • 505 kB
JavaScript
/*! For license information please see platform-api.js.LICENSE.txt */
!function(e,a){if("object"==typeof exports&&"object"==typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var t=a();for(var p in t)("object"==typeof exports?exports:e)[p]=t[p]}}(global,(function(){return function(e){var a={};function t(p){if(a[p])return a[p].exports;var d=a[p]={i:p,l:!1,exports:{}};return e[p].call(d.exports,d,d.exports,t),d.l=!0,d.exports}return t.m=e,t.c=a,t.d=function(e,a,p){t.o(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:p})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,a){if(1&a&&(e=t(e)),8&a)return e;if(4&a&&"object"==typeof e&&e&&e.__esModule)return e;var p=Object.create(null);if(t.r(p),Object.defineProperty(p,"default",{enumerable:!0,value:e}),2&a&&"string"!=typeof e)for(var d in e)t.d(p,d,function(a){return e[a]}.bind(null,d));return p},t.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(a,"a",a),a},t.o=function(e,a){return Object.prototype.hasOwnProperty.call(e,a)},t.p="",t(t.s=60)}([function(e,a){function t(a){return e.exports=t=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},e.exports.__esModule=!0,e.exports.default=e.exports,t(a)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,a,t){"use strict";t.d(a,"b",(function(){return r})),t.d(a,"a",(function(){return n}));var p=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"https://accounts.platform.sh",a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"https://api.platform.sh/api";return{provider:"cg",client_id:"platform@d4tobd5qpizwa.eu.platform.sh",account_url:"".concat(e.replace(/(\/api\/?)$/,""),"/api"),api_url:a,authentication_url:e,scope:[],authorization:"".concat(e,"/oauth2/authorize"),logout_url:"".concat(e,"/user/logout"),prompt:"",redirect_uri:"",response_type:"code"}},d=p(),r=function(e){d=Object.assign(Object.assign({},p(e.base_url,e.api_url)),e)},n=function(){return d}},function(e,a,t){var p=t(38)();e.exports=p;try{regeneratorRuntime=p}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=p:Function("r","regeneratorRuntime = r")(p)}},function(e,a,t){var p=t(57);function d(){return"undefined"!=typeof Reflect&&Reflect.get?(e.exports=d=Reflect.get.bind(),e.exports.__esModule=!0,e.exports.default=e.exports):(e.exports=d=function(e,a,t){var d=p(e,a);if(d){var r=Object.getOwnPropertyDescriptor(d,a);return r.get?r.get.call(arguments.length<3?e:t):r.value}},e.exports.__esModule=!0,e.exports.default=e.exports),d.apply(this,arguments)}e.exports=d,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,a){e.exports=function(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,a,t){var p=t(29);function d(e,a){for(var t=0;t<a.length;t++){var d=a[t];d.enumerable=d.enumerable||!1,d.configurable=!0,"value"in d&&(d.writable=!0),Object.defineProperty(e,p(d.key),d)}}e.exports=function(e,a,t){return a&&d(e.prototype,a),t&&d(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,a,t){"use strict";t.d(a,"a",(function(){return k}));var p=t(4),d=t.n(p),r=t(5),n=t.n(r),i=t(52),o=t.n(i),l=t(15),s=t.n(l),m=t(2),c=t.n(m),u=t(33),v=t.n(u),f=t(10),h=t(21),y=t(9),g=t(19),w=function(e,a,t,p){return new(t||(t=Promise))((function(d,r){function n(e){try{o(p.next(e))}catch(e){r(e)}}function i(e){try{o(p.throw(e))}catch(e){r(e)}}function o(e){var a;e.done?d(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(n,i)}o((p=p.apply(e,a||[])).next())}))},b={get:function(e,a){return"symbol"!==s()(a)&&!a.startsWith("_")&&"data"!==a&&e.hasOwnProperty(a)?e.data&&e.data[a]:e[a]},set:function(e,a,t){return"data"!==a&&e.hasOwnProperty(a)?(e.data[a]=t,!0):(e[a]=t,!0)}},_=function(e,a){return Object.keys(e).filter((function(e){return-1!==a.indexOf(e)})).reduce((function(a,t){return a[t]=e[t],a}),{})},O=["integration.webhook","integration.script"];function j(e){for(var a=Object.create((null==e?void 0:e.prototype)||null),t=arguments.length,p=new Array(t>1?t-1:0),d=1;d<t;d++)p[d-1]=arguments[d];return o()(a.constructor,p)}var k=function(){function e(a,t,p,r){var n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:[],i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:[];if(d()(this,e),this.constructor===e)throw new Error("Can't instantiate abstract class");this.copy(r);var o=a||this.getLink("self");this._params=p,this._url=Object(f.a)(o,p,t);var l=v()(o);return"http"!==l[1]&&"https"!==l[1]||(this._baseUrl="".concat(l[1],":").concat(l[2]).concat(l[3]).concat(l[4]?":".concat(l[4]):"")),this._creatableField=n,this._modifiableField=i,this._paramDefaults=t,new Proxy(this,b)}return n()(e,[{key:"checkProperty",value:function(e,a){return{}}},{key:"checkUpdate",value:function(e){if(e){var a={};for(var t in Object.keys(e))a=this.checkProperty(t,e[t]);return Object.keys(a).length?a:void 0}}},{key:"update",value:function(e,a){var t=this;if(!this._modifiableField.length)throw new Error("Can't call update on this ressource");var p,d=this.checkUpdate(this.data);if(d)return Promise.reject(d);try{p=this.getLink("#edit",!0)}catch(e){if(!a)throw new Error("Not allowed to edit")}return p||(p=Object(f.a)(a||this._url,this.data,this._paramDefaults)),Object(y.c)(p,"PATCH",_(e,this._modifiableField)).then((function(e){return new g.a(e,t._url,t.constructor)}))}},{key:"updateLocal",value:function(e){return new this.constructor(Object.assign(Object.assign({},this.data),e),this._url)}},{key:"getRequired",value:function(){return this._required||[]}},{key:"checkNew",value:function(e){if(e){var a={},t=Object.keys(e),p=this.getRequired().filter((function(e){return t.indexOf(e)<0}));p.length&&(a._error="Missing ".concat(p.join(", ")));for(var d=0;d<t.length;d++){var r=t[d];a=Object.assign(Object.assign({},a),this.checkProperty(r,e[r]))}return Object.keys(a).length?a:void 0}}},{key:"save",value:function(){var e=this;if(!this._creatableField.length)throw new Error("Can't call save on this ressource");var a=this.checkNew(this.data);if(a)return Promise.reject(a);var t=this._queryUrl||this._url;return Object(y.c)(t,"POST",this.data&&_(this.data,this._creatableField)).then((function(a){return new g.a(a,t,e.constructor)}))}},{key:"delete",value:function(e){var a=this,t=e||this.getLink("#delete");if(!t)throw new Error("Not allowed to delete");return Object(y.c)(t,"DELETE",{}).then((function(e){return new g.a(e,a._url,a.constructor)}))}},{key:"copy",value:function(e){this.data=Object.assign(Object.assign({},this.data),e)}},{key:"refresh",value:function(e){var a=this;return Object(y.c)(this.getUri(),"GET",e).then((function(e){return a.copy(e),a}))}},{key:"operationAvailable",value:function(e){var a,t=null===(a=this.data)||void 0===a?void 0:a._links,p=t&&t["#".concat(e)];return!!(null==p?void 0:p.href)}},{key:"hasLink",value:function(e){var a;return Object(h.d)(null===(a=this.data)||void 0===a?void 0:a._links,e)}},{key:"hasEmbedded",value:function(e){var a;return!!((null===(a=this.data)||void 0===a?void 0:a._embedded)&&this.data._embedded[e]&&this.data._embedded[e].length)}},{key:"getEmbedded",value:function(e){var a;if(!this.hasEmbedded(e))throw new Error("Embedded not found: ".concat(e));return(null===(a=this.data)||void 0===a?void 0:a._embedded)&&this.data._embedded[e]}},{key:"getLink",value:function(e){var a,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],p=Object(h.a)(null===(a=this.data)||void 0===a?void 0:a._links,e,t,this._baseUrl);return"string"==typeof p?p:""}},{key:"getLinks",value:function(){var e;return null===(e=this.data)||void 0===e?void 0:e._links}},{key:"getUri",value:function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.getLink("self",e)}},{key:"makeAbsoluteUrl",value:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this._baseUrl;return Object(h.e)("".concat(a).concat(e),a)}},{key:"runOperation",value:function(e){var a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"POST",t=arguments.length>2?arguments[2]:void 0;if(!this.operationAvailable(e))throw new Error("Operation not available: ".concat(e));return Object(y.c)(this.getLink("#".concat(e)),a,t)}},{key:"runLongOperation",value:function(e){var a=this,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"POST",p=arguments.length>2?arguments[2]:void 0;return this.runOperation(e,t,p).then((function(e){var t=new g.a(e,a.getUri()).getActivities().filter((function(e){return!O.includes(e.type)}));if(1!==t.length)throw new Error("Expected one activity, found ".concat(t.length));return t[0]}))}},{key:"hasPermission",value:function(e){var a;return(null===(a=this.data)||void 0===a?void 0:a._links)&&!!this.data._links[e]}},{key:"getRef",value:function(e,a){var t,p=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return Object(h.b)(null===(t=this.data)||void 0===t?void 0:t._links,e,a,p,this._baseUrl)}},{key:"getRefs",value:function(e,a){var t,p=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];return w(this,void 0,void 0,c.a.mark((function d(){return c.a.wrap((function(d){for(;;)switch(d.prev=d.next){case 0:return d.abrupt("return",Object(h.c)(null===(t=this.data)||void 0===t?void 0:t._links,e,a,p,this._baseUrl));case 1:case"end":return d.stop()}}),d,this)})))}}],[{key:"getQueryUrl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return e.substring(0,e.lastIndexOf("/"))}},{key:"_get",value:function(e,a,t,p,d){var r=this,n=Object(f.a)(e,a,t);return Object(y.c)(n,"GET",p,{},0,d).then((function(e){return j(r,e,n,a)}))}},{key:"_query",value:function(e,a,t,p,d,r){var n=this,i=Object(f.a)(e,a,t);return Object(y.c)(i,"GET",p,{},0,r).then((function(e){var a=e;return d&&(a=d(e)),a.map((function(e){return j(n,e,"".concat(i,"/").concat(e.id))}))}))}},{key:"wrap",value:function(e){var a=this;return e.map((function(e){return j(a,e)}))}}]),e}()},function(e,a,t){var p=t(51);e.exports=function(e,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(a&&a.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),a&&p(e,a)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,a,t){var p=t(15).default,d=t(58);e.exports=function(e,a){if(a&&("object"===p(a)||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return d(e)},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,a,t){"use strict";t.d(a,"f",(function(){return u})),t.d(a,"d",(function(){return v})),t.d(a,"e",(function(){return g})),t.d(a,"a",(function(){return w})),t.d(a,"b",(function(){return b}));var p,d=t(22),r=t.n(d),n=t(23),i=t.n(n),o=(t(26),t(32)),l=t.n(o),s=t(16),m=t(1),c=t(18),u=function(e){p=e},v=function(){return p},f={};s.a&&(f["Content-Type"]="application/json");var h=function(e){return"undefined"!=typeof FormData&&e instanceof FormData},y=function(e){var a=(e.get("WWW-Authenticate")||"").replace("Bearer","").split(",").reduce((function(e,a){var t=a.replace(/"/g,"").trim().split("="),p=i()(t,2),d=p[0],r=p[1];return e[d]=r,e}),{});return["max_age","acr_values"].reduce((function(e,t){return a[t]&&(e[t]=a[t]),e}),{})},g=function(e,a,t){var p=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,n=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},i=t instanceof Array?t&&r()(t):t&&Object.assign({},t),o=e;if("GET"===a){var s=l()(i||{},"",{arrayPrefix:n.queryStringArrayPrefix||""});o="".concat(e).concat(s.length?"?".concat(s):"")}var u=Object.assign(Object.assign({method:a},n),{headers:Object.assign(Object.assign({},f),p)});if("GET"!==a&&"HEAD"!==a&&i){var v=h(t)?t:JSON.stringify(i);u.body=v}return new Promise((function(r,i){fetch(o,u).then((function(o){if(401===o.status){var l=Object(m.a)(),s=y(o.headers);if(void 0===l.access_token&&d<2)return Object(c.default)(Object.assign(Object.assign({},l),{extra_params:s}),!0).then((function(i){r(w(e,a,t,p,d+1,n))}))}var u=o.headers.get("Content-Type"),v=!u||"application/json"===u||"application/hal+json; charset=utf-8"===u;return o.ok?u&&["image/gif","image/jpeg","image/png"].includes(u)||202===o.status?r(o):r(o.text().then((function(e){var a;try{a=JSON.parse(e)}catch(t){a=e}return a}))):v?o.json().then((function(e){return i(e)})).catch((function(e){console.log(e)})):o.text().then((function(e){return i(e)}))})).catch((function(e){i(e)}))}))},w=function e(a){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"GET",d=arguments.length>2?arguments[2]:void 0,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,i=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{};return p.then((function(p){if(!p)throw new Error("Token is mandatory");r.hasOwnProperty("Content-Type")||h(d)||(r["Content-Type"]="application/json");var o=Math.round((new Date).getTime()/1e3),l=p.expires;if(-1!==l&&o>=l){var s=Object(m.a)();return console.log("Token expiration detected"),Object(c.default)(s,!0).then((function(p){return e(a,t,d,r,n+1,i)}))}var u={Authorization:"Bearer ".concat(p.access_token)};return g(a,t,d,Object.assign(Object.assign({},r),u),n,i)}))},b=function(e){return p.then((function(a){return new window.EventSource("".concat(e,"?access_token=").concat(a.access_token))}))};a.c=w},function(e,a,t){"use strict";var p=/(:[0-z]+)/g;a.a=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},d=e.match(p);if(!d||!d.length)return e;for(var r=e,n=0;n<d.length;n++){var i=d[n].substring(1),o=t[i]||i;a[o]&&(r=r.replace(d[n],a[o]))}return r}},function(e,a){e.exports=require("stream")},function(e,a,t){"use strict";const p=t(30),d=t(48),r={ftp:21,file:null,gopher:70,http:80,https:443,ws:80,wss:443},n=Symbol("failure");function i(e){return p.ucs2.decode(e).length}function o(e,a){const t=e[a];return isNaN(t)?void 0:String.fromCodePoint(t)}function l(e){return e>=48&&e<=57}function s(e){return e>=65&&e<=90||e>=97&&e<=122}function m(e){return l(e)||e>=65&&e<=70||e>=97&&e<=102}function c(e){return"."===e||"%2e"===e.toLowerCase()}function u(e){return 2===e.length&&s(e.codePointAt(0))&&(":"===e[1]||"|"===e[1])}function v(e){return void 0!==r[e]}function f(e){return v(e.scheme)}function h(e){let a=e.toString(16).toUpperCase();return 1===a.length&&(a="0"+a),"%"+a}function y(e){return e<=31||e>126}const g=new Set([32,34,35,60,62,63,96,123,125]);function w(e){return y(e)||g.has(e)}const b=new Set([47,58,59,61,64,91,92,93,94,124]);function _(e){return w(e)||b.has(e)}function O(e,a){const t=String.fromCodePoint(e);return a(e)?function(e){const a=new Buffer(e);let t="";for(let e=0;e<a.length;++e)t+=h(a[e]);return t}(t):t}function j(e){let a=10;if(e.length>=2&&"0"===e.charAt(0)&&"x"===e.charAt(1).toLowerCase()?(e=e.substring(2),a=16):e.length>=2&&"0"===e.charAt(0)&&(e=e.substring(1),a=8),""===e)return 0;return(10===a?/[^0-9]/:16===a?/[^0-9A-Fa-f]/:/[^0-7]/).test(e)?n:parseInt(e,a)}function k(e,a){if("["===e[0])return"]"!==e[e.length-1]?n:function(e){const a=[0,0,0,0,0,0,0,0];let t=0,d=null,r=0;if(58===(e=p.ucs2.decode(e))[r]){if(58!==e[r+1])return n;r+=2,++t,d=t}for(;r<e.length;){if(8===t)return n;if(58===e[r]){if(null!==d)return n;++r,++t,d=t;continue}let p=0,i=0;for(;i<4&&m(e[r]);)p=16*p+parseInt(o(e,r),16),++r,++i;if(46===e[r]){if(0===i)return n;if(r-=i,t>6)return n;let p=0;for(;void 0!==e[r];){let d=null;if(p>0){if(!(46===e[r]&&p<4))return n;++r}if(!l(e[r]))return n;for(;l(e[r]);){const a=parseInt(o(e,r));if(null===d)d=a;else{if(0===d)return n;d=10*d+a}if(d>255)return n;++r}a[t]=256*a[t]+d,++p,2!==p&&4!==p||++t}if(4!==p)return n;break}if(58===e[r]){if(++r,void 0===e[r])return n}else if(void 0!==e[r])return n;a[t]=p,++t}if(null!==d){let e=t-d;for(t=7;0!==t&&e>0;){const p=a[d+e-1];a[d+e-1]=a[t],a[t]=p,--t,--e}}else if(null===d&&8!==t)return n;return a}(e.substring(1,e.length-1));if(!a)return function(e){if(a=e,-1!==a.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|\/|:|\?|@|\[|\\|\]/))return n;var a;let t="";const d=p.ucs2.decode(e);for(let e=0;e<d.length;++e)t+=O(d[e],y);return t}(e);const t=function(e){const a=new Buffer(e),t=[];for(let e=0;e<a.length;++e)37!==a[e]?t.push(a[e]):37===a[e]&&m(a[e+1])&&m(a[e+2])?(t.push(parseInt(a.slice(e+1,e+3).toString(),16)),e+=2):t.push(a[e]);return new Buffer(t).toString()}(e),r=d.toASCII(t,!1,d.PROCESSING_OPTIONS.NONTRANSITIONAL,!1);if(null===r)return n;if(-1!==r.search(/\u0000|\u0009|\u000A|\u000D|\u0020|#|%|\/|:|\?|@|\[|\\|\]/))return n;const i=function(e){const a=e.split(".");if(""===a[a.length-1]&&a.length>1&&a.pop(),a.length>4)return e;const t=[];for(const p of a){if(""===p)return e;const a=j(p);if(a===n)return e;t.push(a)}for(let e=0;e<t.length-1;++e)if(t[e]>255)return n;if(t[t.length-1]>=Math.pow(256,5-t.length))return n;let p=t.pop(),d=0;for(const e of t)p+=e*Math.pow(256,3-d),++d;return p}(r);return"number"==typeof i||i===n?i:r}function S(e){return"number"==typeof e?function(e){let a="",t=e;for(let e=1;e<=4;++e)a=String(t%256)+a,4!==e&&(a="."+a),t=Math.floor(t/256);return a}(e):e instanceof Array?"["+function(e){let a="";const t=function(e){let a=null,t=1,p=null,d=0;for(let r=0;r<e.length;++r)0!==e[r]?(d>t&&(a=p,t=d),p=null,d=0):(null===p&&(p=r),++d);d>t&&(a=p,t=d);return{idx:a,len:t}}(e).idx;let p=!1;for(let d=0;d<=7;++d)if(!p||0!==e[d])if(p&&(p=!1),t!==d)a+=e[d].toString(16),7!==d&&(a+=":");else{a+=0===d?"::":":",p=!0}return a}(e)+"]":e}function x(e){const a=e.path;var t;0!==a.length&&("file"===e.scheme&&1===a.length&&(t=a[0],/^[A-Za-z]:$/.test(t))||a.pop())}function N(e){return""!==e.username||""!==e.password}function T(e,a,t,d,r){if(this.pointer=0,this.input=e,this.base=a||null,this.encodingOverride=t||"utf-8",this.stateOverride=r,this.url=d,this.failure=!1,this.parseError=!1,!this.url){this.url={scheme:"",username:"",password:"",host:null,port:null,path:[],query:null,fragment:null,cannotBeABaseURL:!1};const e=function(e){return e.replace(/^[\u0000-\u001F\u0020]+|[\u0000-\u001F\u0020]+$/g,"")}(this.input);e!==this.input&&(this.parseError=!0),this.input=e}const i=function(e){return e.replace(/\u0009|\u000A|\u000D/g,"")}(this.input);for(i!==this.input&&(this.parseError=!0),this.input=i,this.state=r||"scheme start",this.buffer="",this.atFlag=!1,this.arrFlag=!1,this.passwordTokenSeenFlag=!1,this.input=p.ucs2.decode(this.input);this.pointer<=this.input.length;++this.pointer){const e=this.input[this.pointer],a=isNaN(e)?void 0:String.fromCodePoint(e),t=this["parse "+this.state](e,a);if(!t)break;if(t===n){this.failure=!0;break}}}T.prototype["parse scheme start"]=function(e,a){if(s(e))this.buffer+=a.toLowerCase(),this.state="scheme";else{if(this.stateOverride)return this.parseError=!0,n;this.state="no scheme",--this.pointer}return!0},T.prototype["parse scheme"]=function(e,a){if(function(e){return s(e)||l(e)}(e)||43===e||45===e||46===e)this.buffer+=a.toLowerCase();else if(58===e){if(this.stateOverride){if(f(this.url)&&!v(this.buffer))return!1;if(!f(this.url)&&v(this.buffer))return!1;if((N(this.url)||null!==this.url.port)&&"file"===this.buffer)return!1;if("file"===this.url.scheme&&(""===this.url.host||null===this.url.host))return!1}if(this.url.scheme=this.buffer,this.buffer="",this.stateOverride)return!1;"file"===this.url.scheme?(47===this.input[this.pointer+1]&&47===this.input[this.pointer+2]||(this.parseError=!0),this.state="file"):f(this.url)&&null!==this.base&&this.base.scheme===this.url.scheme?this.state="special relative or authority":f(this.url)?this.state="special authority slashes":47===this.input[this.pointer+1]?(this.state="path or authority",++this.pointer):(this.url.cannotBeABaseURL=!0,this.url.path.push(""),this.state="cannot-be-a-base-URL path")}else{if(this.stateOverride)return this.parseError=!0,n;this.buffer="",this.state="no scheme",this.pointer=-1}return!0},T.prototype["parse no scheme"]=function(e){return null===this.base||this.base.cannotBeABaseURL&&35!==e?n:(this.base.cannotBeABaseURL&&35===e?(this.url.scheme=this.base.scheme,this.url.path=this.base.path.slice(),this.url.query=this.base.query,this.url.fragment="",this.url.cannotBeABaseURL=!0,this.state="fragment"):"file"===this.base.scheme?(this.state="file",--this.pointer):(this.state="relative",--this.pointer),!0)},T.prototype["parse special relative or authority"]=function(e){return 47===e&&47===this.input[this.pointer+1]?(this.state="special authority ignore slashes",++this.pointer):(this.parseError=!0,this.state="relative",--this.pointer),!0},T.prototype["parse path or authority"]=function(e){return 47===e?this.state="authority":(this.state="path",--this.pointer),!0},T.prototype["parse relative"]=function(e){return this.url.scheme=this.base.scheme,isNaN(e)?(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.url.path=this.base.path.slice(),this.url.query=this.base.query):47===e?this.state="relative slash":63===e?(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.url.path=this.base.path.slice(),this.url.query="",this.state="query"):35===e?(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.url.path=this.base.path.slice(),this.url.query=this.base.query,this.url.fragment="",this.state="fragment"):f(this.url)&&92===e?(this.parseError=!0,this.state="relative slash"):(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.url.path=this.base.path.slice(0,this.base.path.length-1),this.state="path",--this.pointer),!0},T.prototype["parse relative slash"]=function(e){return!f(this.url)||47!==e&&92!==e?47===e?this.state="authority":(this.url.username=this.base.username,this.url.password=this.base.password,this.url.host=this.base.host,this.url.port=this.base.port,this.state="path",--this.pointer):(92===e&&(this.parseError=!0),this.state="special authority ignore slashes"),!0},T.prototype["parse special authority slashes"]=function(e){return 47===e&&47===this.input[this.pointer+1]?(this.state="special authority ignore slashes",++this.pointer):(this.parseError=!0,this.state="special authority ignore slashes",--this.pointer),!0},T.prototype["parse special authority ignore slashes"]=function(e){return 47!==e&&92!==e?(this.state="authority",--this.pointer):this.parseError=!0,!0},T.prototype["parse authority"]=function(e,a){if(64===e){this.parseError=!0,this.atFlag&&(this.buffer="%40"+this.buffer),this.atFlag=!0;const e=i(this.buffer);for(let a=0;a<e;++a){const e=this.buffer.codePointAt(a);if(58===e&&!this.passwordTokenSeenFlag){this.passwordTokenSeenFlag=!0;continue}const t=O(e,_);this.passwordTokenSeenFlag?this.url.password+=t:this.url.username+=t}this.buffer=""}else if(isNaN(e)||47===e||63===e||35===e||f(this.url)&&92===e){if(this.atFlag&&""===this.buffer)return this.parseError=!0,n;this.pointer-=i(this.buffer)+1,this.buffer="",this.state="host"}else this.buffer+=a;return!0},T.prototype["parse hostname"]=T.prototype["parse host"]=function(e,a){if(this.stateOverride&&"file"===this.url.scheme)--this.pointer,this.state="file host";else if(58!==e||this.arrFlag)if(isNaN(e)||47===e||63===e||35===e||f(this.url)&&92===e){if(--this.pointer,f(this.url)&&""===this.buffer)return this.parseError=!0,n;if(this.stateOverride&&""===this.buffer&&(N(this.url)||null!==this.url.port))return this.parseError=!0,!1;const e=k(this.buffer,f(this.url));if(e===n)return n;if(this.url.host=e,this.buffer="",this.state="path start",this.stateOverride)return!1}else 91===e?this.arrFlag=!0:93===e&&(this.arrFlag=!1),this.buffer+=a;else{if(""===this.buffer)return this.parseError=!0,n;const e=k(this.buffer,f(this.url));if(e===n)return n;if(this.url.host=e,this.buffer="",this.state="port","hostname"===this.stateOverride)return!1}return!0},T.prototype["parse port"]=function(e,a){if(l(e))this.buffer+=a;else{if(!(isNaN(e)||47===e||63===e||35===e||f(this.url)&&92===e||this.stateOverride))return this.parseError=!0,n;if(""!==this.buffer){const e=parseInt(this.buffer);if(e>Math.pow(2,16)-1)return this.parseError=!0,n;this.url.port=e===(t=this.url.scheme,r[t])?null:e,this.buffer=""}if(this.stateOverride)return!1;this.state="path start",--this.pointer}var t;return!0};const V=new Set([47,92,63,35]);T.prototype["parse file"]=function(e){var a,t;return this.url.scheme="file",47===e||92===e?(92===e&&(this.parseError=!0),this.state="file slash"):null!==this.base&&"file"===this.base.scheme?isNaN(e)?(this.url.host=this.base.host,this.url.path=this.base.path.slice(),this.url.query=this.base.query):63===e?(this.url.host=this.base.host,this.url.path=this.base.path.slice(),this.url.query="",this.state="query"):35===e?(this.url.host=this.base.host,this.url.path=this.base.path.slice(),this.url.query=this.base.query,this.url.fragment="",this.state="fragment"):(this.input.length-this.pointer-1==0||(a=e,t=this.input[this.pointer+1],!s(a)||58!==t&&124!==t)||this.input.length-this.pointer-1>=2&&!V.has(this.input[this.pointer+2])?(this.url.host=this.base.host,this.url.path=this.base.path.slice(),x(this.url)):this.parseError=!0,this.state="path",--this.pointer):(this.state="path",--this.pointer),!0},T.prototype["parse file slash"]=function(e){var a;return 47===e||92===e?(92===e&&(this.parseError=!0),this.state="file host"):(null!==this.base&&"file"===this.base.scheme&&(2===(a=this.base.path[0]).length&&s(a.codePointAt(0))&&":"===a[1]?this.url.path.push(this.base.path[0]):this.url.host=this.base.host),this.state="path",--this.pointer),!0},T.prototype["parse file host"]=function(e,a){if(isNaN(e)||47===e||92===e||63===e||35===e)if(--this.pointer,!this.stateOverride&&u(this.buffer))this.parseError=!0,this.state="path";else if(""===this.buffer){if(this.url.host="",this.stateOverride)return!1;this.state="path start"}else{let e=k(this.buffer,f(this.url));if(e===n)return n;if("localhost"===e&&(e=""),this.url.host=e,this.stateOverride)return!1;this.buffer="",this.state="path start"}else this.buffer+=a;return!0},T.prototype["parse path start"]=function(e){return f(this.url)?(92===e&&(this.parseError=!0),this.state="path",47!==e&&92!==e&&--this.pointer):this.stateOverride||63!==e?this.stateOverride||35!==e?void 0!==e&&(this.state="path",47!==e&&--this.pointer):(this.url.fragment="",this.state="fragment"):(this.url.query="",this.state="query"),!0},T.prototype["parse path"]=function(e){if(isNaN(e)||47===e||f(this.url)&&92===e||!this.stateOverride&&(63===e||35===e)){if(f(this.url)&&92===e&&(this.parseError=!0),".."===(a=(a=this.buffer).toLowerCase())||"%2e."===a||".%2e"===a||"%2e%2e"===a?(x(this.url),47===e||f(this.url)&&92===e||this.url.path.push("")):!c(this.buffer)||47===e||f(this.url)&&92===e?c(this.buffer)||("file"===this.url.scheme&&0===this.url.path.length&&u(this.buffer)&&(""!==this.url.host&&null!==this.url.host&&(this.parseError=!0,this.url.host=""),this.buffer=this.buffer[0]+":"),this.url.path.push(this.buffer)):this.url.path.push(""),this.buffer="","file"===this.url.scheme&&(void 0===e||63===e||35===e))for(;this.url.path.length>1&&""===this.url.path[0];)this.parseError=!0,this.url.path.shift();63===e&&(this.url.query="",this.state="query"),35===e&&(this.url.fragment="",this.state="fragment")}else 37!==e||m(this.input[this.pointer+1])&&m(this.input[this.pointer+2])||(this.parseError=!0),this.buffer+=O(e,w);var a;return!0},T.prototype["parse cannot-be-a-base-URL path"]=function(e){return 63===e?(this.url.query="",this.state="query"):35===e?(this.url.fragment="",this.state="fragment"):(isNaN(e)||37===e||(this.parseError=!0),37!==e||m(this.input[this.pointer+1])&&m(this.input[this.pointer+2])||(this.parseError=!0),isNaN(e)||(this.url.path[0]=this.url.path[0]+O(e,y))),!0},T.prototype["parse query"]=function(e,a){if(isNaN(e)||!this.stateOverride&&35===e){f(this.url)&&"ws"!==this.url.scheme&&"wss"!==this.url.scheme||(this.encodingOverride="utf-8");const a=new Buffer(this.buffer);for(let e=0;e<a.length;++e)a[e]<33||a[e]>126||34===a[e]||35===a[e]||60===a[e]||62===a[e]?this.url.query+=h(a[e]):this.url.query+=String.fromCodePoint(a[e]);this.buffer="",35===e&&(this.url.fragment="",this.state="fragment")}else 37!==e||m(this.input[this.pointer+1])&&m(this.input[this.pointer+2])||(this.parseError=!0),this.buffer+=a;return!0},T.prototype["parse fragment"]=function(e){return isNaN(e)||(0===e?this.parseError=!0:(37!==e||m(this.input[this.pointer+1])&&m(this.input[this.pointer+2])||(this.parseError=!0),this.url.fragment+=O(e,y))),!0},e.exports.serializeURL=function(e,a){let t=e.scheme+":";if(null!==e.host?(t+="//",""===e.username&&""===e.password||(t+=e.username,""!==e.password&&(t+=":"+e.password),t+="@"),t+=S(e.host),null!==e.port&&(t+=":"+e.port)):null===e.host&&"file"===e.scheme&&(t+="//"),e.cannotBeABaseURL)t+=e.path[0];else for(const a of e.path)t+="/"+a;return null!==e.query&&(t+="?"+e.query),a||null===e.fragment||(t+="#"+e.fragment),t},e.exports.serializeURLOrigin=function(a){switch(a.scheme){case"blob":try{return e.exports.serializeURLOrigin(e.exports.parseURL(a.path[0]))}catch(e){return"null"}case"ftp":case"gopher":case"http":case"https":case"ws":case"wss":return function(e){let a=e.scheme+"://";return a+=S(e.host),null!==e.port&&(a+=":"+e.port),a}({scheme:a.scheme,host:a.host,port:a.port});case"file":return"file://";default:return"null"}},e.exports.basicURLParse=function(e,a){void 0===a&&(a={});const t=new T(e,a.baseURL,a.encodingOverride,a.url,a.stateOverride);return t.failure?"failure":t.url},e.exports.setTheUsername=function(e,a){e.username="";const t=p.ucs2.decode(a);for(let a=0;a<t.length;++a)e.username+=O(t[a],_)},e.exports.setThePassword=function(e,a){e.password="";const t=p.ucs2.decode(a);for(let a=0;a<t.length;++a)e.password+=O(t[a],_)},e.exports.serializeHost=S,e.exports.cannotHaveAUsernamePasswordPort=function(e){return null===e.host||""===e.host||e.cannotBeABaseURL||"file"===e.scheme},e.exports.serializeInteger=function(e){return String(e)},e.exports.parseURL=function(a,t){return void 0===t&&(t={}),e.exports.basicURLParse(a,{baseURL:t.baseURL,encodingOverride:t.encodingOverride})}},function(e,a){e.exports=require("zlib")},function(e,a,t){var p=t(29);e.exports=function(e,a,t){return(a=p(a))in e?Object.defineProperty(e,a,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[a]=t,e},e.exports.__esModule=!0,e.exports.default=e.exports},function(e,a){function t(a){return e.exports=t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.__esModule=!0,e.exports.default=e.exports,t(a)}e.exports=t,e.exports.__esModule=!0,e.exports.default=e.exports},function(e,a,t){"use strict";a.a="[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)},function(e,a,t){"use strict";t.r(a),t.d(a,"default",(function(){return S}));var p=t(4),d=t.n(p),r=t(5),n=t.n(r),i=t(3),o=t.n(i),l=t(7),s=t.n(l),m=t(8),c=t.n(m),u=t(0),v=t.n(u),f=t(2),h=t.n(f),y=t(6),g=t(1),w=t(9);function b(e){var a=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}();return function(){var t,p=v()(e);if(a){var d=v()(this).constructor;t=Reflect.construct(p,arguments,d)}else t=p.apply(this,arguments);return c()(this,t)}}var _=function(e,a,t,p){return new(t||(t=Promise))((function(d,r){function n(e){try{o(p.next(e))}catch(e){r(e)}}function i(e){try{o(p.throw(e))}catch(e){r(e)}}function o(e){var a;e.done?d(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(n,i)}o((p=p.apply(e,a||[])).next())}))},O=function(e,a){var t={};for(var p in e)Object.prototype.hasOwnProperty.call(e,p)&&a.indexOf(p)<0&&(t[p]=e[p]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var d=0;for(p=Object.getOwnPropertySymbols(e);d<p.length;d++)a.indexOf(p[d])<0&&Object.prototype.propertyIsEnumerable.call(e,p[d])&&(t[p[d]]=e[p[d]])}return t},j={},k="/projects/:projectId/environments/:environmentId/activities",S=function(e){s()(t,e);var a=b(t);function t(e,p){var r;return d()(this,t),(r=a.call(this,p,j,{},e,["name","ssl"])).RESULT_SUCCESS="success",r.RESULT_FAILURE="failure",r.STATE_COMPLETE="complete",r.STATE_IN_PROGRESS="in_progress",r.STATE_PENDING="pending",r.id="",r.completion_percent=0,r.log="",r.created_at="",r.updated_at="",r.cancelled_at="",r.environments=[],r.completed_at="",r.parameters=[],r.project="",r.state="",r.result="",r.started_at="",r.type="",r.payload=[],r.timings={},r}return n()(t,[{key:"wait",value:function(e,a){var t=this,p=arguments.length>2&&void 0!==arguments[2]?arguments[2]:1,d=this.log||"";a&&d.trim().length&&a("".concat(d.trim(),"\n"));var r=d.length,n=0;return new Promise((function(d,i){var o=setInterval((function(){t.isComplete()&&(d(t),clearInterval(o)),t.refresh({timeout:p+5}).then((function(p){if(e&&e(p),a){var d=(t.log||"").substring(r);a("".concat(d.trim(),"\n")),r=d.length}})).catch((function(e){if(-1!==e.message.indexOf("cURL error 28")&&n<=5)return n++;i(e)}))}),1e3*p)}))}},{key:"isComplete",value:function(){return this.getCompletionPercent()>=100}},{key:"getCompletionPercent",value:function(){return this.completion_percent}},{key:"restore",value:function(){if("environment.backup"!==this.type)throw new Error("Cannot restore activity (wrong type)");if(!this.isComplete())throw new Error("Cannot restore backup (not complete)");return this.runLongOperation("restore","POST",{})}},{key:"getLogAt",value:function(e,a){var t=this;return a?new Promise((function(p){setTimeout((function(){return p(Object(w.c)(t.getLink("log"),"GET",{start_at:e}))}),a)})):Object(w.c)(this.getLink("log"),"GET",{start_at:e})}},{key:"getLogs",value:function(e){var a=this,t=!1;return{cancel:function(){t=!0},exec:function(){return _(a,void 0,void 0,h.a.mark((function a(){var p,d,r,n,i,o;return h.a.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:if(this.hasLink("log")){a.next=2;break}return a.abrupt("return",e(this.log));case 2:p=0,r=0,n=0;case 5:if(d&&d[d.data.length-1].seal||!(r<5)||t){a.next=31;break}return a.prev=6,a.next=9,this.getLogAt(p,n);case 9:if((i=a.sent)&&i.length){a.next=14;break}return n=3e3,r++,a.abrupt("continue",5);case 14:if(n=0,r=0,o=i.split("\n").filter((function(e){return e.length})).map((function(e){return JSON.parse(e)})),d=o[o.length-1],p++,e(o),!o[o.length-1].seal){a.next=22;break}return a.abrupt("break",31);case 22:a.next=29;break;case 24:a.prev=24,a.t0=a.catch(6),a.t0 instanceof Response&&(a.t0.status<500||a.t0.status>599)&&e([],a.t0),n=3e3,r++;case 29:a.next=5;break;case 31:case"end":return a.stop()}}),a,this,[[6,24]])})))}}}},{key:"getDescription",value:function(){var e=this.type,a=this.payload;switch(e){case"project.domain.create":return"".concat(a.user.display_name," added domain ").concat(a.domain.name);case"project.domain.delete":return"".concat(a.user.display_name," deleted domain ").concat(a.domain.name);case"project.domain.update":return"".concat(a.user.display_name," updated domain ").concat(a.domain.name);case"project.modify.title":return"".concat(a.user.display_name," changed project name to ").concat(a.new_title);case"environment.activate":return"".concat(a.user.display_name," activated environment ").concat(a.environment.title);case"environment.backup":return"".concat(a.user.display_name," created a snapshot of ").concat(a.environment.title);case"environment.branch":return"".concat(a.user.display_name," branched ").concat(a.outcome.title," from ").concat(a.parent.title);case"environment.delete":return"".concat(a.user.display_name," deleted environment ").concat(a.environment.title);case"environment.deactivate":return"".concat(a.user.display_name," deactivated environment ").concat(a.environment.title);case"environment.initialize":return"".concat(a.user.display_name," initialized environment ").concat(a.outcome.title," with profile ").concat(a.profile);case"environment.merge":return"".concat(a.user.display_name," merged ").concat(a.outcome.title," into ").concat(a.environment.title);case"environment.push":return"".concat(a.user.display_name," pushed to ").concat(a.environment.title);case"environment.restore":return"".concat(a.user.display_name," restored ").concat(a.environment," from snapshot ").concat(a.backup_name.substr(0,7));case"environment.synchronize":var t=!a.synchronize_code,p="data";return t&&!a.synchronize_data?p="code and data":t&&(p="code"),"".concat(a.user.display_name," synced ").concat(a.outcome.title,"'s ").concat(p," with ").concat(a.environment.title);case"environment.access.add":return"".concat(a.user.display_name," added ").concat(a.access.display_name," to ").concat(a.environment.title);case"environment.access.remove":return"".concat(a.user.display_name," removed ").concat(a.access.display_name," from ").concat(a.environment.title);case"environment.variable.create":return"".concat(a.user.display_name," added variable ").concat(a.variable.name);case"environment.variable.delete":return"".concat(a.user.display_name," deleted variable ").concat(a.variable.name);case"environment.variable.update":return"".concat(a.user.display_name," modified variable ").concat(a.variable.name);case"environment.update.http_access":return"".concat(a.user.display_name," updated HTTP Access settings on environment ").concat(a.environment.title);case"environment.update.smtp":return"".concat(a.user.display_name," updated SMTP settings on environment ").concat(a.environment.title);case"environment.route.create":return"".concat(a.user.display_name," added route ").concat(a.route.route);case"environment.route.delete":return"".concat(a.user.display_name," deleted route ").concat(a.route.route);case"environment.route.update":return"".concat(a.user.display_name," modified route ").concat(a.route.route);case"environment.subscription.update":return"".concat(a.user.display_name," modified subscription");case"project.create":return"".concat(a.user.display_name," created a new project ").concat(a.outcome.title)}return e}}],[{key:"get",value:function(e,a){var p=e.projectId,d=e.environmentId,r=e.id,n=O(e,["projectId","environmentId","id"]),i=Object(g.a)().api_url;return o()(v()(t),"_get",this).call(this,a?"".concat(a,"/:id"):"".concat(i).concat(k,"/:id"),{projectId:p,environmentId:d,id:r},j,n)}},{key:"query",value:function(e,a){var p=e.projectId,d=e.environmentId,r=O(e,["projectId","environmentId"]),n=Object(g.a)().api_url;return o()(v()(t),"_query",this).call(this,a||"".concat(n).concat(k),{projectId:p,environmentId:d},j,r)}}]),t}(y.a)},function(e,a,t){"use strict";t.r(a),t.d(a,"authenticatedRequest",(function(){return ae})),t.d(a,"wipeToken",(function(){return te}));var p=t(9),d=t(14),r=t.n(d),n=t(2),i=t.n(n),o=t(16);function l(e,a,t,p){return new(t||(t=Promise))((function(d,r){function n(e){try{o(p.next(e))}catch(e){r(e)}}function i(e){try{o(p.throw(e))}catch(e){r(e)}}function o(e){var a;e.done?d(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(n,i)}o((p=p.apply(e,a||[])).next())}))}class s{constructor(e){this.authorizationUri=e.authorizationUri,this.clientId=e.clientId,this.redirectUri=e.redirectUri,this.scope=e.scope,this.responseType=e.responseType||"token",this.accessTokenStorageKey=e.accessTokenStorageKey||"token",this.accessTokenResponseKey=e.accessTokenResponseKey||"access_token",this.storage=e.storage||window.localStorage,this.pollingTime=e.pollingTime||200,this.additionalAuthorizationParameters=e.additionalAuthorizationParameters,this.tokenValidator=e.tokenValidator,this.beforePopup=e.beforePopup,this.afterResponse=e.afterResponse,this._eventListeners={}}get _rawToken(){return this.storage.getItem(this.accessTokenStorageKey)||void 0}set _rawToken(e){null!=e&&this.storage.setItem(this.accessTokenStorageKey,e)}get _rawTokenPayload(){const e=this._rawToken;if(!e)return;const a=e.split(".")[1];if(!a)return;const t=window.atob(a.replace("-","+").replace("_","/"));return s.jsonParseOrUndefined(t)}loggedIn(){const e=this._rawTokenPayload;if(!e)return!1;if(this.tokenValidator){const a=this._rawToken;if(!this.tokenValidator({payload:e,token:a}))return!1}const a=e.exp;return!!a&&!((new Date).getTime()>1e3*a)}tokenExpired(){const e=this._rawTokenPayload;if(!e)return!1;const a=e.exp;return!!a&&!((new Date).getTime()<=1e3*a)}logout(){this.storage.removeItem(this.accessTokenStorageKey),this.dispatchEvent(new Event("logout"))}handleRedirect(){if(!window.location.href.startsWith(this.redirectUri))return"REDIRECT_URI_MISMATCH";const e=window.location.hash;if(!e)return"FALSY_HASH";const a=/#(.*)/.exec(e);if(!a)return"NO_HASH_MATCH";const t=a[1],p=s.decodeUriToObject(t);this.afterResponse&&this.afterResponse(p);const d=p[this.accessTokenResponseKey];return d?(this._rawToken=d,window.location.hash="","SUCCESS"):"FALSY_TOKEN"}addEventListener(e,a){const t=this._eventListeners[e]||[];t.push(a),this._eventListeners[e]=t}dispatchEvent(e){const a=this._eventListeners[e.type]||[];for(const t of a){("function"==typeof t?t:"object"==typeof t&&"function"==typeof t.handleEvent?t.handleEvent.bind(t):()=>{})(e)}return!0}removeEventListener(e,a){const t=this._eventListeners[e]||[];this._eventListeners[e]=t.filter(e=>e!==a)}tryLoginPopup(){return l(this,void 0,void 0,(function*(){if(this.loggedIn())return"ALREADY_LOGGED_IN";this.beforePopup&&(yield Promise.resolve(this.beforePopup()));const e="function"==typeof this.additionalAuthorizationParameters?this.additionalAuthorizationParameters():"object"==typeof this.additionalAuthorizationParameters?this.additionalAuthorizationParameters:{},a=window.open(`${this.authorizationUri}?${s.encodeObjectToUri(Object.assign({client_id:this.clientId,response_type:this.responseType,redirect_uri:this.redirectUri,scope:this.scope},e))}`);return a?(yield this.authenticated(),a.close(),this.dispatchEvent(new Event("login")),"SUCCESS"):"POPUP_FAILED"}))}authenticated(){return l(this,void 0,void 0,(function*(){for(;!this.loggedIn();)yield s.time(this.pollingTime)}))}token(){return l(this,void 0,void 0,(function*(){yield this.authenticated();const e=this._rawToken;if(!e)throw new Error("Token was falsy after being authenticated.");return e}))}tokenPayload(){return l(this,void 0,void 0,(function*(){yield this.authenticated();const e=this._rawTokenPayload;if(!e)throw new Error("Token payload was falsy after being authenticated.");return e}))}static jsonParseOrUndefined(e){try{return JSON.parse(e)}catch(e){return}}static time(e){return new Promise(a=>window.setTimeout(()=>a("TIMER"),e))}static decodeUri(e){try{return decodeURIComponent(e)}catch(a){return e}}static encodeObjectToUri(e){return Object.keys(e).map(a=>({key:a,value:e[a]})).map(({key:e,value:a})=>`${encodeURIComponent(e)}=${encodeURIComponent(a)}`).join("&")}static decodeUriToObject(e){return e.split("&").reduce((e,a)=>{const[t,p]=a.split("="),d=this.decodeUri(t),r=this.decodeUri(p);return e[d]=r,e},{})}}t(26);var m,c,u,v=t(22),f=t.n(v),h=t(4),y=t.n(h),g=t(5),w=t.n(g),b=function(e,a,t,p){return new(t||(t=Promise))((function(d,r){function n(e){try{o(p.next(e))}catch(e){r(e)}}function i(e){try{o(p.throw(e))}catch(e){r(e)}}function o(e){var a;e.done?d(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(n,i)}o((p=p.apply(e,a||[])).next())}))},_={debug:!1},O={},j=function(e){_.debug&&console&&console.log&&console.log(e)},k=function(e,a){var t,p=e,d=0,r=-1===e.indexOf("?")?"?":"&";for(t in a)p+=(0==d++?r:"&")+encodeURIComponent(t)+"="+encodeURIComponent(a[t]);return p};c=function(e){window.location.href=e},u=new(function(){function e(){y()(this,e)}return w()(e,[{key:"saveState",value:function(e,a,t){localStorage.setItem("state-".concat(a,"-").concat(e),JSON.stringify(t))}},{key:"getState",value:function(e,a){var t=JSON.parse(localStorage.getItem("state-".concat(a,"-").concat(e)));return localStorage.removeItem("state-".concat(a,"-").concat(e)),t}},{key:"hasScope",value:function(e,a){var t;if(!e.scopes)return!1;for(t=0;t<e.scopes.length;t++)if(e.scopes[t]===a)return!0;return!1}},{key:"filterTokens",value:function(e,a){var t,p,d,r=[],n=Math.round((new Date).getTime()/1e3);for(a||(a=[]),t=0;t<e.length;t++){for(d=!0,e[t].expires&&e[t].expires<n+1&&(d=!1),p=0;p<a.length;p++)this.hasScope(e[t],a[p])||(d=!1);d&&r.push(e[t])}return r}},{key:"saveTokens",value:function(e,a){localStorage.setItem("tokens-".concat(e),JSON.stringify(a))}},{key:"getTokens",value:function(e){var a=JSON.parse(localStorage.getItem("tokens-".concat(e)));return a||(a=[]),a}},{key:"wipeTokens",value:function(e){localStorage.removeItem("tokens-".concat(e))}},{key:"saveToken",value:function(e,a){var t=this.getTokens(e);(t=this.filterTokens(t)).push(a),this.saveTokens(e,t)}},{key:"getToken",value:function(e,a){var t=this.getTokens(e);return(t=this.filterTokens(t,a)).length<1?null:t[0]}},{key:"saveCodeVerifier",value:function(e,a){localStorage.setItem("".concat(e,"-code-verifier"),a)}},{key:"getCodeVerifier",value:function(e){return localStorage.getItem("".concat(e,"-code-verifier"))}}]),e}());var S,x=function(e){return u.getCodeVerifier(e)},N=function(e,a){u.saveCodeVerifier(e,a)},T=function(e){var a=window.location.hash;if(e){if(-1===e.indexOf("#"))return;a=e.substring(e.indexOf("#"))}return function(e){var a,t=/\+/g,p=/([^&;=]+)=?([^&;]*)/g,d=function(e){return decodeURIComponent(e.replace(t," "))},r=e,n={};for(a=p.exec(r);a;)n[d(a[1])]=d(a[2]),a=p.exec(r);return n}(a.substring(1))},V=function(e){var a=function(e){var a=new URLSearchParams(e?"?".concat(e.split("?")[1]):window.location.search);if(a.has("code"))return{code:a.get("code"),state:a.get("state")}}(e);if(null==a?void 0:a.code)return a},D=function(e,a){var t=Math.round((new Date).getTime()/1e3);return e.expires_in&&(e.expires=t+parseInt(e.expires_in,10)),e},I=function(e,a,t,p){var d,r,n;if(j("jso_checkfortoken(".concat(e,")")),null==(d=T(t))?void 0:d.state){if(!(r=u.getState(d.state,a)))throw new Error("Could not retrieve state");if(!r.providerID)throw new Error("Could not get providerid from state");if(!m[r.providerID])throw new Error("Could not retrieve config for this provider.");n=m[r.providerID],!(null==d?void 0:d.state)&&n.scope&&(r.scopes=n.scope),(null==(d=D(d))?void 0:d.scope)?d.scopes=d.scope.split(" "):r.scopes&&(d.scopes=r.scopes),u.saveToken(r.providerID,d),p||(r.location?window.location.href=r.location:window.location.hash=""),d.state&&O[d.state]&&"function"==typeof O[d.state]&&(O[d.state](),delete O[d.state])}else{if(!e)throw new Error("Could not get [state] and no default providerid is provided.");r={providerID:e}}},P=function(e,a,t,p){var d,r,n;if(!m[e])throw new Error("Could not find configuration for provider ".concat(e));return n=m[e],d="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var a=16*Math.random()|0;return("x"===e?a:3&a|8).toString(16)})),(r={response_type:"token"}).state=d,n.redirect_uri&&(r.redirect_uri=n.redirect_uri),n.client_id&&(r.client_id=n.client_id),a&&(r.scope=a.join(" ")),n.response_mode&&(r.response_mode=n.response_mode),n.response_type&&(r.response_type=n.response_type),n.prompt&&(r.prompt=n.prompt),void 0!==t&&(r.response_mode=t),void 0!==p&&(r.prompt=p),r.location=window.location.href,r.providerID=e,a&&(r.scopes=a),j("Saving state [".concat(d,"]")),j(JSON.parse(JSON.stringify(r))),u.saveState(d,e,r),r},R=function(e,a,t){var p;p=function(e,a,t){var p,d;if(!m[e])throw new Error("Could not find configuration for provider ".concat(e));return d=m[e],p=P(e,a,""),t&&(p.code_challenge=t,p.code_challenge_method="S256"),k(d.authorization,p)}(e,a,t),c(p)},E=function(e,a,t,p){var d,r,n;for(d in e)if(r=void 0,e[d]&&(r=e[d]),n=u.getToken(d,r),j("Ensure token for provider ["+d+"] "),j(n),null===n||a){var i=window.location,o="".concat(i.pathname).concat(i.search).concat(i.hash);if(t)t(o);else localStorage.getItem("auth-redirect-uri")||localStorage.setItem("auth-redirect-uri",o);R(d,r,p)}return!0},A=function(e,a,t){m=e,function(e){if(e)for(var a in e)e.hasOwnProperty(a)&&(_[a]=e[a])}(a);try{var p=Object.keys(e)[0];!t&&p&&"token"===e[p].response_type&&I(e[p].client_id,p)}catch(e){j("Error when retrieving token from hash: "+e),window.location.hash=""}},z=function(){for(var e in j("jso_wipe()"),m)j("Wipping tokens for "+e),u.wipeTokens(e)},B=function(e,a){u.saveToken(e,a)},U=function(e,a){var t=u.getToken(e,a);return t&&t.access_token?t:null},C=function(){for(var e in localStorage)e.startsWith("state-")&&localStorage.removeItem(e)},L=function(e){return btoa(String.fromCharCode.apply(null,f()(new Uint8Array(e)))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},q=function(){return b(void 0,void 0,void 0,i.a.mark((function e(){var a,t,p,d,r;return i.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=new Uint32Array(80),window.crypto.getRandomValues(a),t=L(a),p=new TextEncoder,d=p.encode(t),e.t0=L,e.next=8,crypto.subtle.digest("SHA-256",d);case 8:return e.t1=e.sent,r=(0,e.t0)(e.t1),e.abrupt("return",{codeVerifier:t,codeChallenge:r});case 11:case"end":return e.stop()}}),e)})))},F=t(1),M=function(e,a,t,p){return new(t||(t=Promise))((function(d,r){function n(e){try{o(p.next(e))}catch(e){r(e)}}function i(e){try{o(p.throw(e))}catch(e){r(e)}}function o(e){var a;e.done?d(e.value):(a=e.value,a instanceof t?a:new t((function(e){e(a)}))).then(n,i)}o((p=p.apply(e,a||[])).next