@entur-partner/app-shell 4.0.0 → 5.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,364 +3,334 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var React = require('react');
6
- var loader = require('@entur/loader');
7
6
  var alert = require('@entur/alert');
8
- var tokens = require('@entur/tokens');
9
7
  var typography = require('@entur/typography');
10
- var util = require('@entur-partner/util');
8
+ var loader = require('@entur/loader');
9
+ var tokens = require('@entur/tokens');
10
+ var auth0React = require('@auth0/auth0-react');
11
11
  var common = require('@entur-partner/common');
12
- var createAuth0Client = require('@auth0/auth0-spa-js');
12
+ var util = require('@entur-partner/util');
13
13
 
14
14
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
15
 
16
16
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
17
- var createAuth0Client__default = /*#__PURE__*/_interopDefaultLegacy(createAuth0Client);
18
17
 
18
+ function _construct(t, e, r) {
19
+ if (_isNativeReflectConstruct()) return Reflect.construct.apply(null, arguments);
20
+ var o = [null];
21
+ o.push.apply(o, e);
22
+ var p = new (t.bind.apply(t, o))();
23
+ return r && _setPrototypeOf(p, r.prototype), p;
24
+ }
25
+ function _isNativeReflectConstruct() {
26
+ try {
27
+ var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
28
+ } catch (t) {}
29
+ return (_isNativeReflectConstruct = function () {
30
+ return !!t;
31
+ })();
32
+ }
19
33
  function _regeneratorRuntime() {
20
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
21
-
22
34
  _regeneratorRuntime = function () {
23
- return exports;
35
+ return e;
24
36
  };
25
-
26
- var exports = {},
27
- Op = Object.prototype,
28
- hasOwn = Op.hasOwnProperty,
29
- $Symbol = "function" == typeof Symbol ? Symbol : {},
30
- iteratorSymbol = $Symbol.iterator || "@@iterator",
31
- asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator",
32
- toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
33
-
34
- function define(obj, key, value) {
35
- return Object.defineProperty(obj, key, {
36
- value: value,
37
+ var t,
38
+ e = {},
39
+ r = Object.prototype,
40
+ n = r.hasOwnProperty,
41
+ o = Object.defineProperty || function (t, e, r) {
42
+ t[e] = r.value;
43
+ },
44
+ i = "function" == typeof Symbol ? Symbol : {},
45
+ a = i.iterator || "@@iterator",
46
+ c = i.asyncIterator || "@@asyncIterator",
47
+ u = i.toStringTag || "@@toStringTag";
48
+ function define(t, e, r) {
49
+ return Object.defineProperty(t, e, {
50
+ value: r,
37
51
  enumerable: !0,
38
52
  configurable: !0,
39
53
  writable: !0
40
- }), obj[key];
54
+ }), t[e];
41
55
  }
42
-
43
56
  try {
44
57
  define({}, "");
45
- } catch (err) {
46
- define = function (obj, key, value) {
47
- return obj[key] = value;
58
+ } catch (t) {
59
+ define = function (t, e, r) {
60
+ return t[e] = r;
48
61
  };
49
62
  }
50
-
51
- function wrap(innerFn, outerFn, self, tryLocsList) {
52
- var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator,
53
- generator = Object.create(protoGenerator.prototype),
54
- context = new Context(tryLocsList || []);
55
- return generator._invoke = function (innerFn, self, context) {
56
- var state = "suspendedStart";
57
- return function (method, arg) {
58
- if ("executing" === state) throw new Error("Generator is already running");
59
-
60
- if ("completed" === state) {
61
- if ("throw" === method) throw arg;
62
- return doneResult();
63
- }
64
-
65
- for (context.method = method, context.arg = arg;;) {
66
- var delegate = context.delegate;
67
-
68
- if (delegate) {
69
- var delegateResult = maybeInvokeDelegate(delegate, context);
70
-
71
- if (delegateResult) {
72
- if (delegateResult === ContinueSentinel) continue;
73
- return delegateResult;
74
- }
75
- }
76
-
77
- if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) {
78
- if ("suspendedStart" === state) throw state = "completed", context.arg;
79
- context.dispatchException(context.arg);
80
- } else "return" === context.method && context.abrupt("return", context.arg);
81
- state = "executing";
82
- var record = tryCatch(innerFn, self, context);
83
-
84
- if ("normal" === record.type) {
85
- if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue;
86
- return {
87
- value: record.arg,
88
- done: context.done
89
- };
90
- }
91
-
92
- "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg);
93
- }
94
- };
95
- }(innerFn, self, context), generator;
63
+ function wrap(t, e, r, n) {
64
+ var i = e && e.prototype instanceof Generator ? e : Generator,
65
+ a = Object.create(i.prototype),
66
+ c = new Context(n || []);
67
+ return o(a, "_invoke", {
68
+ value: makeInvokeMethod(t, r, c)
69
+ }), a;
96
70
  }
97
-
98
- function tryCatch(fn, obj, arg) {
71
+ function tryCatch(t, e, r) {
99
72
  try {
100
73
  return {
101
74
  type: "normal",
102
- arg: fn.call(obj, arg)
75
+ arg: t.call(e, r)
103
76
  };
104
- } catch (err) {
77
+ } catch (t) {
105
78
  return {
106
79
  type: "throw",
107
- arg: err
80
+ arg: t
108
81
  };
109
82
  }
110
83
  }
111
-
112
- exports.wrap = wrap;
113
- var ContinueSentinel = {};
114
-
84
+ e.wrap = wrap;
85
+ var h = "suspendedStart",
86
+ l = "suspendedYield",
87
+ f = "executing",
88
+ s = "completed",
89
+ y = {};
115
90
  function Generator() {}
116
-
117
91
  function GeneratorFunction() {}
118
-
119
92
  function GeneratorFunctionPrototype() {}
120
-
121
- var IteratorPrototype = {};
122
- define(IteratorPrototype, iteratorSymbol, function () {
93
+ var p = {};
94
+ define(p, a, function () {
123
95
  return this;
124
96
  });
125
- var getProto = Object.getPrototypeOf,
126
- NativeIteratorPrototype = getProto && getProto(getProto(values([])));
127
- NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype);
128
- var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
129
-
130
- function defineIteratorMethods(prototype) {
131
- ["next", "throw", "return"].forEach(function (method) {
132
- define(prototype, method, function (arg) {
133
- return this._invoke(method, arg);
97
+ var d = Object.getPrototypeOf,
98
+ v = d && d(d(values([])));
99
+ v && v !== r && n.call(v, a) && (p = v);
100
+ var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
101
+ function defineIteratorMethods(t) {
102
+ ["next", "throw", "return"].forEach(function (e) {
103
+ define(t, e, function (t) {
104
+ return this._invoke(e, t);
134
105
  });
135
106
  });
136
107
  }
137
-
138
- function AsyncIterator(generator, PromiseImpl) {
139
- function invoke(method, arg, resolve, reject) {
140
- var record = tryCatch(generator[method], generator, arg);
141
-
142
- if ("throw" !== record.type) {
143
- var result = record.arg,
144
- value = result.value;
145
- return value && "object" == typeof value && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) {
146
- invoke("next", value, resolve, reject);
147
- }, function (err) {
148
- invoke("throw", err, resolve, reject);
149
- }) : PromiseImpl.resolve(value).then(function (unwrapped) {
150
- result.value = unwrapped, resolve(result);
151
- }, function (error) {
152
- return invoke("throw", error, resolve, reject);
108
+ function AsyncIterator(t, e) {
109
+ function invoke(r, o, i, a) {
110
+ var c = tryCatch(t[r], t, o);
111
+ if ("throw" !== c.type) {
112
+ var u = c.arg,
113
+ h = u.value;
114
+ return h && "object" == typeof h && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
115
+ invoke("next", t, i, a);
116
+ }, function (t) {
117
+ invoke("throw", t, i, a);
118
+ }) : e.resolve(h).then(function (t) {
119
+ u.value = t, i(u);
120
+ }, function (t) {
121
+ return invoke("throw", t, i, a);
153
122
  });
154
123
  }
155
-
156
- reject(record.arg);
124
+ a(c.arg);
157
125
  }
158
-
159
- var previousPromise;
160
-
161
- this._invoke = function (method, arg) {
162
- function callInvokeWithMethodAndArg() {
163
- return new PromiseImpl(function (resolve, reject) {
164
- invoke(method, arg, resolve, reject);
165
- });
126
+ var r;
127
+ o(this, "_invoke", {
128
+ value: function (t, n) {
129
+ function callInvokeWithMethodAndArg() {
130
+ return new e(function (e, r) {
131
+ invoke(t, n, e, r);
132
+ });
133
+ }
134
+ return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
166
135
  }
167
-
168
- return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
169
- };
136
+ });
170
137
  }
171
-
172
- function maybeInvokeDelegate(delegate, context) {
173
- var method = delegate.iterator[context.method];
174
-
175
- if (undefined === method) {
176
- if (context.delegate = null, "throw" === context.method) {
177
- if (delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel;
178
- context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method");
138
+ function makeInvokeMethod(e, r, n) {
139
+ var o = h;
140
+ return function (i, a) {
141
+ if (o === f) throw Error("Generator is already running");
142
+ if (o === s) {
143
+ if ("throw" === i) throw a;
144
+ return {
145
+ value: t,
146
+ done: !0
147
+ };
179
148
  }
180
-
181
- return ContinueSentinel;
182
- }
183
-
184
- var record = tryCatch(method, delegate.iterator, context.arg);
185
- if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel;
186
- var info = record.arg;
187
- return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel);
149
+ for (n.method = i, n.arg = a;;) {
150
+ var c = n.delegate;
151
+ if (c) {
152
+ var u = maybeInvokeDelegate(c, n);
153
+ if (u) {
154
+ if (u === y) continue;
155
+ return u;
156
+ }
157
+ }
158
+ if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
159
+ if (o === h) throw o = s, n.arg;
160
+ n.dispatchException(n.arg);
161
+ } else "return" === n.method && n.abrupt("return", n.arg);
162
+ o = f;
163
+ var p = tryCatch(e, r, n);
164
+ if ("normal" === p.type) {
165
+ if (o = n.done ? s : l, p.arg === y) continue;
166
+ return {
167
+ value: p.arg,
168
+ done: n.done
169
+ };
170
+ }
171
+ "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
172
+ }
173
+ };
188
174
  }
189
-
190
- function pushTryEntry(locs) {
191
- var entry = {
192
- tryLoc: locs[0]
175
+ function maybeInvokeDelegate(e, r) {
176
+ var n = r.method,
177
+ o = e.iterator[n];
178
+ if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
179
+ var i = tryCatch(o, e.iterator, r.arg);
180
+ if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
181
+ var a = i.arg;
182
+ return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
183
+ }
184
+ function pushTryEntry(t) {
185
+ var e = {
186
+ tryLoc: t[0]
193
187
  };
194
- 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry);
188
+ 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
195
189
  }
196
-
197
- function resetTryEntry(entry) {
198
- var record = entry.completion || {};
199
- record.type = "normal", delete record.arg, entry.completion = record;
190
+ function resetTryEntry(t) {
191
+ var e = t.completion || {};
192
+ e.type = "normal", delete e.arg, t.completion = e;
200
193
  }
201
-
202
- function Context(tryLocsList) {
194
+ function Context(t) {
203
195
  this.tryEntries = [{
204
196
  tryLoc: "root"
205
- }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0);
197
+ }], t.forEach(pushTryEntry, this), this.reset(!0);
206
198
  }
207
-
208
- function values(iterable) {
209
- if (iterable) {
210
- var iteratorMethod = iterable[iteratorSymbol];
211
- if (iteratorMethod) return iteratorMethod.call(iterable);
212
- if ("function" == typeof iterable.next) return iterable;
213
-
214
- if (!isNaN(iterable.length)) {
215
- var i = -1,
216
- next = function next() {
217
- for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next;
218
-
219
- return next.value = undefined, next.done = !0, next;
220
- };
221
-
222
- return next.next = next;
199
+ function values(e) {
200
+ if (e || "" === e) {
201
+ var r = e[a];
202
+ if (r) return r.call(e);
203
+ if ("function" == typeof e.next) return e;
204
+ if (!isNaN(e.length)) {
205
+ var o = -1,
206
+ i = function next() {
207
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
208
+ return next.value = t, next.done = !0, next;
209
+ };
210
+ return i.next = i;
223
211
  }
224
212
  }
225
-
226
- return {
227
- next: doneResult
228
- };
229
- }
230
-
231
- function doneResult() {
232
- return {
233
- value: undefined,
234
- done: !0
235
- };
213
+ throw new TypeError(typeof e + " is not iterable");
236
214
  }
237
-
238
- return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) {
239
- var ctor = "function" == typeof genFun && genFun.constructor;
240
- return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name));
241
- }, exports.mark = function (genFun) {
242
- return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun;
243
- }, exports.awrap = function (arg) {
215
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
216
+ value: GeneratorFunctionPrototype,
217
+ configurable: !0
218
+ }), o(GeneratorFunctionPrototype, "constructor", {
219
+ value: GeneratorFunction,
220
+ configurable: !0
221
+ }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
222
+ var e = "function" == typeof t && t.constructor;
223
+ return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
224
+ }, e.mark = function (t) {
225
+ return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
226
+ }, e.awrap = function (t) {
244
227
  return {
245
- __await: arg
228
+ __await: t
246
229
  };
247
- }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () {
230
+ }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
248
231
  return this;
249
- }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
250
- void 0 === PromiseImpl && (PromiseImpl = Promise);
251
- var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
252
- return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) {
253
- return result.done ? result.value : iter.next();
232
+ }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
233
+ void 0 === i && (i = Promise);
234
+ var a = new AsyncIterator(wrap(t, r, n, o), i);
235
+ return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
236
+ return t.done ? t.value : a.next();
254
237
  });
255
- }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () {
238
+ }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
256
239
  return this;
257
- }), define(Gp, "toString", function () {
240
+ }), define(g, "toString", function () {
258
241
  return "[object Generator]";
259
- }), exports.keys = function (object) {
260
- var keys = [];
261
-
262
- for (var key in object) keys.push(key);
263
-
264
- return keys.reverse(), function next() {
265
- for (; keys.length;) {
266
- var key = keys.pop();
267
- if (key in object) return next.value = key, next.done = !1, next;
242
+ }), e.keys = function (t) {
243
+ var e = Object(t),
244
+ r = [];
245
+ for (var n in e) r.push(n);
246
+ return r.reverse(), function next() {
247
+ for (; r.length;) {
248
+ var t = r.pop();
249
+ if (t in e) return next.value = t, next.done = !1, next;
268
250
  }
269
-
270
251
  return next.done = !0, next;
271
252
  };
272
- }, exports.values = values, Context.prototype = {
253
+ }, e.values = values, Context.prototype = {
273
254
  constructor: Context,
274
- reset: function (skipTempReset) {
275
- if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined);
255
+ reset: function (e) {
256
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
276
257
  },
277
258
  stop: function () {
278
259
  this.done = !0;
279
- var rootRecord = this.tryEntries[0].completion;
280
- if ("throw" === rootRecord.type) throw rootRecord.arg;
260
+ var t = this.tryEntries[0].completion;
261
+ if ("throw" === t.type) throw t.arg;
281
262
  return this.rval;
282
263
  },
283
- dispatchException: function (exception) {
284
- if (this.done) throw exception;
285
- var context = this;
286
-
287
- function handle(loc, caught) {
288
- return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught;
264
+ dispatchException: function (e) {
265
+ if (this.done) throw e;
266
+ var r = this;
267
+ function handle(n, o) {
268
+ return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
289
269
  }
290
-
291
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
292
- var entry = this.tryEntries[i],
293
- record = entry.completion;
294
- if ("root" === entry.tryLoc) return handle("end");
295
-
296
- if (entry.tryLoc <= this.prev) {
297
- var hasCatch = hasOwn.call(entry, "catchLoc"),
298
- hasFinally = hasOwn.call(entry, "finallyLoc");
299
-
300
- if (hasCatch && hasFinally) {
301
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
302
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
303
- } else if (hasCatch) {
304
- if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0);
270
+ for (var o = this.tryEntries.length - 1; o >= 0; --o) {
271
+ var i = this.tryEntries[o],
272
+ a = i.completion;
273
+ if ("root" === i.tryLoc) return handle("end");
274
+ if (i.tryLoc <= this.prev) {
275
+ var c = n.call(i, "catchLoc"),
276
+ u = n.call(i, "finallyLoc");
277
+ if (c && u) {
278
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
279
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
280
+ } else if (c) {
281
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
305
282
  } else {
306
- if (!hasFinally) throw new Error("try statement without catch or finally");
307
- if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc);
283
+ if (!u) throw Error("try statement without catch or finally");
284
+ if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
308
285
  }
309
286
  }
310
287
  }
311
288
  },
312
- abrupt: function (type, arg) {
313
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
314
- var entry = this.tryEntries[i];
315
-
316
- if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
317
- var finallyEntry = entry;
289
+ abrupt: function (t, e) {
290
+ for (var r = this.tryEntries.length - 1; r >= 0; --r) {
291
+ var o = this.tryEntries[r];
292
+ if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
293
+ var i = o;
318
294
  break;
319
295
  }
320
296
  }
321
-
322
- finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null);
323
- var record = finallyEntry ? finallyEntry.completion : {};
324
- return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record);
297
+ i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
298
+ var a = i ? i.completion : {};
299
+ return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
325
300
  },
326
- complete: function (record, afterLoc) {
327
- if ("throw" === record.type) throw record.arg;
328
- return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel;
301
+ complete: function (t, e) {
302
+ if ("throw" === t.type) throw t.arg;
303
+ return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
329
304
  },
330
- finish: function (finallyLoc) {
331
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
332
- var entry = this.tryEntries[i];
333
- if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel;
305
+ finish: function (t) {
306
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
307
+ var r = this.tryEntries[e];
308
+ if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
334
309
  }
335
310
  },
336
- catch: function (tryLoc) {
337
- for (var i = this.tryEntries.length - 1; i >= 0; --i) {
338
- var entry = this.tryEntries[i];
339
-
340
- if (entry.tryLoc === tryLoc) {
341
- var record = entry.completion;
342
-
343
- if ("throw" === record.type) {
344
- var thrown = record.arg;
345
- resetTryEntry(entry);
311
+ catch: function (t) {
312
+ for (var e = this.tryEntries.length - 1; e >= 0; --e) {
313
+ var r = this.tryEntries[e];
314
+ if (r.tryLoc === t) {
315
+ var n = r.completion;
316
+ if ("throw" === n.type) {
317
+ var o = n.arg;
318
+ resetTryEntry(r);
346
319
  }
347
-
348
- return thrown;
320
+ return o;
349
321
  }
350
322
  }
351
-
352
- throw new Error("illegal catch attempt");
323
+ throw Error("illegal catch attempt");
353
324
  },
354
- delegateYield: function (iterable, resultName, nextLoc) {
325
+ delegateYield: function (e, r, n) {
355
326
  return this.delegate = {
356
- iterator: values(iterable),
357
- resultName: resultName,
358
- nextLoc: nextLoc
359
- }, "next" === this.method && (this.arg = undefined), ContinueSentinel;
327
+ iterator: values(e),
328
+ resultName: r,
329
+ nextLoc: n
330
+ }, "next" === this.method && (this.arg = t), y;
360
331
  }
361
- }, exports;
332
+ }, e;
362
333
  }
363
-
364
334
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
365
335
  try {
366
336
  var info = gen[key](arg);
@@ -369,65 +339,53 @@ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
369
339
  reject(error);
370
340
  return;
371
341
  }
372
-
373
342
  if (info.done) {
374
343
  resolve(value);
375
344
  } else {
376
345
  Promise.resolve(value).then(_next, _throw);
377
346
  }
378
347
  }
379
-
380
348
  function _asyncToGenerator(fn) {
381
349
  return function () {
382
350
  var self = this,
383
- args = arguments;
351
+ args = arguments;
384
352
  return new Promise(function (resolve, reject) {
385
353
  var gen = fn.apply(self, args);
386
-
387
354
  function _next(value) {
388
355
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
389
356
  }
390
-
391
357
  function _throw(err) {
392
358
  asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
393
359
  }
394
-
395
360
  _next(undefined);
396
361
  });
397
362
  };
398
363
  }
399
-
400
364
  function _extends() {
401
365
  _extends = Object.assign ? Object.assign.bind() : function (target) {
402
366
  for (var i = 1; i < arguments.length; i++) {
403
367
  var source = arguments[i];
404
-
405
368
  for (var key in source) {
406
369
  if (Object.prototype.hasOwnProperty.call(source, key)) {
407
370
  target[key] = source[key];
408
371
  }
409
372
  }
410
373
  }
411
-
412
374
  return target;
413
375
  };
414
376
  return _extends.apply(this, arguments);
415
377
  }
416
-
417
378
  function _inheritsLoose(subClass, superClass) {
418
379
  subClass.prototype = Object.create(superClass.prototype);
419
380
  subClass.prototype.constructor = subClass;
420
-
421
381
  _setPrototypeOf(subClass, superClass);
422
382
  }
423
-
424
383
  function _getPrototypeOf(o) {
425
384
  _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) {
426
385
  return o.__proto__ || Object.getPrototypeOf(o);
427
386
  };
428
387
  return _getPrototypeOf(o);
429
388
  }
430
-
431
389
  function _setPrototypeOf(o, p) {
432
390
  _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) {
433
391
  o.__proto__ = p;
@@ -435,61 +393,27 @@ function _setPrototypeOf(o, p) {
435
393
  };
436
394
  return _setPrototypeOf(o, p);
437
395
  }
438
-
439
- function _isNativeReflectConstruct() {
440
- if (typeof Reflect === "undefined" || !Reflect.construct) return false;
441
- if (Reflect.construct.sham) return false;
442
- if (typeof Proxy === "function") return true;
443
-
396
+ function _isNativeFunction(fn) {
444
397
  try {
445
- Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {}));
446
- return true;
398
+ return Function.toString.call(fn).indexOf("[native code]") !== -1;
447
399
  } catch (e) {
448
- return false;
449
- }
450
- }
451
-
452
- function _construct(Parent, args, Class) {
453
- if (_isNativeReflectConstruct()) {
454
- _construct = Reflect.construct.bind();
455
- } else {
456
- _construct = function _construct(Parent, args, Class) {
457
- var a = [null];
458
- a.push.apply(a, args);
459
- var Constructor = Function.bind.apply(Parent, a);
460
- var instance = new Constructor();
461
- if (Class) _setPrototypeOf(instance, Class.prototype);
462
- return instance;
463
- };
400
+ return typeof fn === "function";
464
401
  }
465
-
466
- return _construct.apply(null, arguments);
467
- }
468
-
469
- function _isNativeFunction(fn) {
470
- return Function.toString.call(fn).indexOf("[native code]") !== -1;
471
402
  }
472
-
473
403
  function _wrapNativeSuper(Class) {
474
404
  var _cache = typeof Map === "function" ? new Map() : undefined;
475
-
476
405
  _wrapNativeSuper = function _wrapNativeSuper(Class) {
477
406
  if (Class === null || !_isNativeFunction(Class)) return Class;
478
-
479
407
  if (typeof Class !== "function") {
480
408
  throw new TypeError("Super expression must either be null or a function");
481
409
  }
482
-
483
410
  if (typeof _cache !== "undefined") {
484
411
  if (_cache.has(Class)) return _cache.get(Class);
485
-
486
412
  _cache.set(Class, Wrapper);
487
413
  }
488
-
489
414
  function Wrapper() {
490
415
  return _construct(Class, arguments, _getPrototypeOf(this).constructor);
491
416
  }
492
-
493
417
  Wrapper.prototype = Object.create(Class.prototype, {
494
418
  constructor: {
495
419
  value: Wrapper,
@@ -500,305 +424,21 @@ function _wrapNativeSuper(Class) {
500
424
  });
501
425
  return _setPrototypeOf(Wrapper, Class);
502
426
  };
503
-
504
427
  return _wrapNativeSuper(Class);
505
428
  }
506
-
507
429
  function _objectWithoutPropertiesLoose(source, excluded) {
508
430
  if (source == null) return {};
509
431
  var target = {};
510
432
  var sourceKeys = Object.keys(source);
511
433
  var key, i;
512
-
513
434
  for (i = 0; i < sourceKeys.length; i++) {
514
435
  key = sourceKeys[i];
515
436
  if (excluded.indexOf(key) >= 0) continue;
516
437
  target[key] = source[key];
517
438
  }
518
-
519
439
  return target;
520
440
  }
521
441
 
522
- var initialState$1 = {
523
- status: 'AUTHENTICATING'
524
- };
525
- function authReducer(state, event) {
526
- switch (event.type) {
527
- case 'AUTHENTICATED':
528
- return {
529
- status: 'AUTHENTICATED',
530
- user: event.data.user
531
- };
532
-
533
- case 'LOGOUT':
534
- return initialState$1;
535
-
536
- case 'ERROR':
537
- return {
538
- error: event.error,
539
- status: 'ERROR'
540
- };
541
-
542
- case 'NOT_AUTHENTICATED':
543
- return _extends({}, state, {
544
- status: 'NOT_AUTHENTICATED'
545
- });
546
-
547
- default:
548
- return state;
549
- }
550
- }
551
-
552
- var _excluded$2 = ["children", "decorateUser"];
553
- var POST_LOGIN_ROUTE_KEY = '@entur-partner:post-login-route';
554
- var LOGIN_LAST_RETRY = '@entur-partner:last-login-retry';
555
-
556
- var redirect = function redirect(pathname) {
557
- if (pathname === void 0) {
558
- pathname = '/';
559
- }
560
-
561
- return window.history.replaceState({}, document.title, pathname);
562
- }; // TODO: replace with react-router history
563
-
564
-
565
- var Auth0Context = /*#__PURE__*/React__default["default"].createContext(undefined);
566
- var useAuth = function useAuth() {
567
- var auth = React.useContext(Auth0Context);
568
- util.assertIsDefined(auth, 'A `<Auth0Provider>` component needs to be higher up in the component hierarchy.');
569
- return auth;
570
- };
571
- var initialState = {
572
- status: 'AUTHENTICATING'
573
- };
574
- var AuthProvider = function AuthProvider(_ref) {
575
- var children = _ref.children,
576
- decorateUser = _ref.decorateUser,
577
- initOptions = _objectWithoutPropertiesLoose(_ref, _excluded$2);
578
-
579
- var _useReducer = React.useReducer(authReducer, initialState),
580
- state = _useReducer[0],
581
- dispatch = _useReducer[1];
582
-
583
- var _useState = React.useState(),
584
- auth0Client = _useState[0],
585
- setAuth0 = _useState[1];
586
-
587
- React.useEffect(function () {
588
- var initAuth0 = /*#__PURE__*/function () {
589
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
590
- var client, route, postLoginRoute, isAuthenticated, auth0User, token, user;
591
- return _regeneratorRuntime().wrap(function _callee$(_context) {
592
- while (1) {
593
- switch (_context.prev = _context.next) {
594
- case 0:
595
- _context.next = 2;
596
- return createAuth0Client__default["default"](initOptions);
597
-
598
- case 2:
599
- client = _context.sent;
600
- setAuth0(client);
601
-
602
- if (!window.location.search.includes('code=')) {
603
- _context.next = 11;
604
- break;
605
- }
606
-
607
- _context.next = 7;
608
- return client.handleRedirectCallback();
609
-
610
- case 7:
611
- route = localStorage.getItem(POST_LOGIN_ROUTE_KEY);
612
- localStorage.removeItem(POST_LOGIN_ROUTE_KEY);
613
- postLoginRoute = route || '/';
614
- redirect(postLoginRoute);
615
-
616
- case 11:
617
- _context.next = 13;
618
- return client.isAuthenticated();
619
-
620
- case 13:
621
- isAuthenticated = _context.sent;
622
-
623
- if (!isAuthenticated) {
624
- _context.next = 27;
625
- break;
626
- }
627
-
628
- _context.next = 17;
629
- return client.getUser();
630
-
631
- case 17:
632
- auth0User = _context.sent;
633
- _context.next = 20;
634
- return client.getTokenSilently();
635
-
636
- case 20:
637
- token = _context.sent;
638
- _context.next = 23;
639
- return decorateUser(auth0User, token);
640
-
641
- case 23:
642
- user = _context.sent;
643
- dispatch({
644
- type: 'AUTHENTICATED',
645
- data: {
646
- user: user
647
- }
648
- });
649
- _context.next = 28;
650
- break;
651
-
652
- case 27:
653
- dispatch({
654
- type: 'NOT_AUTHENTICATED'
655
- });
656
-
657
- case 28:
658
- case "end":
659
- return _context.stop();
660
- }
661
- }
662
- }, _callee);
663
- }));
664
-
665
- return function initAuth0() {
666
- return _ref2.apply(this, arguments);
667
- };
668
- }();
669
-
670
- initAuth0()["catch"]( /*#__PURE__*/function () {
671
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(error) {
672
- var _localStorage$getItem, lastRetryEpochSeconds, nowEpochSeconds, timeSinceLastRetry, minimumTimeForRetry;
673
-
674
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
675
- while (1) {
676
- switch (_context2.prev = _context2.next) {
677
- case 0:
678
- _context2.prev = 0;
679
- lastRetryEpochSeconds = parseInt((_localStorage$getItem = localStorage.getItem(LOGIN_LAST_RETRY)) != null ? _localStorage$getItem : '0');
680
- nowEpochSeconds = Math.floor(Date.now() / 1000);
681
- timeSinceLastRetry = nowEpochSeconds - lastRetryEpochSeconds;
682
- minimumTimeForRetry = 120; // Has there been more than x seconds since last retry?
683
-
684
- if (!(timeSinceLastRetry >= minimumTimeForRetry)) {
685
- _context2.next = 12;
686
- break;
687
- }
688
-
689
- localStorage.setItem(LOGIN_LAST_RETRY, nowEpochSeconds.toString());
690
- redirect('/');
691
- _context2.next = 10;
692
- return initAuth0();
693
-
694
- case 10:
695
- _context2.next = 13;
696
- break;
697
-
698
- case 12:
699
- throw error;
700
-
701
- case 13:
702
- _context2.next = 18;
703
- break;
704
-
705
- case 15:
706
- _context2.prev = 15;
707
- _context2.t0 = _context2["catch"](0);
708
- dispatch({
709
- type: 'ERROR',
710
- error: error
711
- });
712
-
713
- case 18:
714
- case "end":
715
- return _context2.stop();
716
- }
717
- }
718
- }, _callee2, null, [[0, 15]]);
719
- }));
720
-
721
- return function (_x) {
722
- return _ref3.apply(this, arguments);
723
- };
724
- }()); // eslint-disable-next-line
725
- }, []);
726
-
727
- var logout = function logout() {
728
- util.assertIsDefined(auth0Client);
729
- var _window$location = window.location,
730
- protocol = _window$location.protocol,
731
- hostname = _window$location.hostname,
732
- port = _window$location.port;
733
- auth0Client.logout({
734
- returnTo: protocol + "//" + hostname + ":" + port
735
- });
736
- };
737
-
738
- var login = /*#__PURE__*/function () {
739
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(redirectUri) {
740
- var _window, location;
741
-
742
- return _regeneratorRuntime().wrap(function _callee3$(_context3) {
743
- while (1) {
744
- switch (_context3.prev = _context3.next) {
745
- case 0:
746
- if (redirectUri === void 0) {
747
- redirectUri = window.location.origin;
748
- }
749
-
750
- util.assertIsDefined(auth0Client);
751
- _window = window, location = _window.location;
752
- localStorage.setItem(POST_LOGIN_ROUTE_KEY, "" + location.pathname + location.search);
753
- auth0Client.loginWithRedirect({
754
- redirect_uri: redirectUri
755
- });
756
-
757
- case 5:
758
- case "end":
759
- return _context3.stop();
760
- }
761
- }
762
- }, _callee3);
763
- }));
764
-
765
- return function login(_x2) {
766
- return _ref4.apply(this, arguments);
767
- };
768
- }();
769
-
770
- var getToken = /*#__PURE__*/function () {
771
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(options) {
772
- return _regeneratorRuntime().wrap(function _callee4$(_context4) {
773
- while (1) {
774
- switch (_context4.prev = _context4.next) {
775
- case 0:
776
- util.assertIsDefined(auth0Client);
777
- return _context4.abrupt("return", auth0Client.getTokenSilently(options));
778
-
779
- case 2:
780
- case "end":
781
- return _context4.stop();
782
- }
783
- }
784
- }, _callee4);
785
- }));
786
-
787
- return function getToken(_x3) {
788
- return _ref5.apply(this, arguments);
789
- };
790
- }();
791
-
792
- return React__default["default"].createElement(Auth0Context.Provider, {
793
- value: _extends({}, state, {
794
- auth0Client: auth0Client,
795
- logout: logout,
796
- getToken: getToken,
797
- login: login
798
- })
799
- }, children);
800
- };
801
-
802
442
  var EnvironmentBanner = function EnvironmentBanner(_ref) {
803
443
  var environment = _ref.environment;
804
444
  return React__default["default"].createElement("div", {
@@ -816,83 +456,121 @@ var EnvironmentBanner = function EnvironmentBanner(_ref) {
816
456
  });
817
457
  };
818
458
 
819
- var Login = function Login(_ref) {
820
- var redirectUri = _ref.redirectUri;
821
-
822
- var _useAuth = useAuth(),
823
- login = _useAuth.login;
824
-
459
+ function userLogout(logout) {
460
+ var _window$location = window.location,
461
+ protocol = _window$location.protocol,
462
+ hostname = _window$location.hostname,
463
+ port = _window$location.port;
464
+ return logout({
465
+ logoutParams: {
466
+ returnTo: protocol + "//" + hostname + ":" + port
467
+ }
468
+ });
469
+ }
470
+ var Authenticate = function Authenticate(_ref) {
471
+ var children = _ref.children,
472
+ decorateUser = _ref.decorateUser;
473
+ var _useState = React.useState(undefined),
474
+ userWithPermission = _useState[0],
475
+ setUserWithPermission = _useState[1];
476
+ var _useAuth = auth0React.useAuth0(),
477
+ user = _useAuth.user,
478
+ getAccessTokenSilently = _useAuth.getAccessTokenSilently,
479
+ loginWithRedirect = _useAuth.loginWithRedirect,
480
+ _logout = _useAuth.logout,
481
+ isLoading = _useAuth.isLoading,
482
+ isAuthenticated = _useAuth.isAuthenticated,
483
+ error = _useAuth.error;
825
484
  React.useEffect(function () {
826
- login(redirectUri);
827
- }, [login, redirectUri]);
828
- return null;
829
- };
830
-
831
- var Authenticate = function Authenticate(_ref2) {
832
- var children = _ref2.children,
833
- redirectUri = _ref2.redirectUri;
834
-
835
- var _useAuth2 = useAuth(),
836
- status = _useAuth2.status,
837
- user = _useAuth2.user,
838
- error = _useAuth2.error,
839
- logout = _useAuth2.logout,
840
- getToken = _useAuth2.getToken;
841
-
842
- switch (status) {
843
- case 'NOT_AUTHENTICATED':
844
- return React__default["default"].createElement(Login, {
845
- redirectUri: redirectUri
846
- });
847
-
848
- case 'AUTHENTICATED':
849
- util.assertIsDefined(user);
850
- return React__default["default"].createElement(React__default["default"].Fragment, null, children({
851
- user: user,
852
- logout: logout,
853
- getToken: getToken
485
+ var fetchUserData = /*#__PURE__*/function () {
486
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
487
+ var token, decoratedUser;
488
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
489
+ while (1) switch (_context.prev = _context.next) {
490
+ case 0:
491
+ _context.prev = 0;
492
+ _context.next = 3;
493
+ return getAccessTokenSilently();
494
+ case 3:
495
+ token = _context.sent;
496
+ _context.next = 6;
497
+ return decorateUser(user, token);
498
+ case 6:
499
+ decoratedUser = _context.sent;
500
+ setUserWithPermission(decoratedUser);
501
+ _context.next = 13;
502
+ break;
503
+ case 10:
504
+ _context.prev = 10;
505
+ _context.t0 = _context["catch"](0);
506
+ console.error('Error fetching user data:', _context.t0);
507
+ case 13:
508
+ case "end":
509
+ return _context.stop();
510
+ }
511
+ }, _callee, null, [[0, 10]]);
854
512
  }));
855
-
856
- case 'AUTHENTICATING':
857
- return React__default["default"].createElement(loader.Loader, {
858
- style: {
859
- marginTop: tokens.space.extraLarge9
860
- }
861
- }, "Authenticating");
862
-
863
- case 'ERROR':
864
- console.error(error);
865
- return React__default["default"].createElement(alert.BannerAlertBox, {
866
- variant: "error",
867
- title: "Authentication failed",
868
- style: {
869
- maxWidth: '600px',
870
- margin: '0 auto'
871
- }
872
- }, React__default["default"].createElement(typography.Paragraph, null, "Something went wrong while trying to authenticate you. If the problem persists you should contact", ' ', React__default["default"].createElement(typography.Link, {
873
- href: "mailto:support@entur.org"
874
- }, "support@entur.org"), " to get it resolved."), React__default["default"].createElement(typography.Paragraph, null, "Authentication failed with: ", React__default["default"].createElement(typography.CodeText, null, error == null ? void 0 : error.toString())));
875
-
876
- default:
877
- return null;
513
+ return function fetchUserData() {
514
+ return _ref2.apply(this, arguments);
515
+ };
516
+ }();
517
+ if (isAuthenticated) {
518
+ fetchUserData();
519
+ }
520
+ }, [decorateUser, getAccessTokenSilently, isAuthenticated, user]);
521
+ if (!isLoading && !isAuthenticated) {
522
+ loginWithRedirect();
523
+ return React__default["default"].createElement(loader.Loader, {
524
+ style: {
525
+ marginTop: tokens.space.extraLarge9
526
+ }
527
+ }, "Redirecting to login page");
528
+ }
529
+ if (isLoading || !userWithPermission) {
530
+ return React__default["default"].createElement(loader.Loader, {
531
+ style: {
532
+ marginTop: tokens.space.extraLarge9
533
+ }
534
+ }, "Authenticating");
535
+ }
536
+ if (error) {
537
+ console.error(error);
538
+ return React__default["default"].createElement(alert.BannerAlertBox, {
539
+ variant: "error",
540
+ title: "Authentication failed",
541
+ style: {
542
+ maxWidth: '600px',
543
+ margin: '0 auto'
544
+ }
545
+ }, React__default["default"].createElement(typography.Paragraph, null, "Something went wrong while trying to authenticate you. If the problem persists you should contact", ' ', React__default["default"].createElement(typography.Link, {
546
+ href: "mailto:support@entur.org"
547
+ }, "support@entur.org"), " to get it resolved."), React__default["default"].createElement(typography.Paragraph, null, "Authentication failed with: ", React__default["default"].createElement(typography.CodeText, null, error == null ? void 0 : error.toString())));
878
548
  }
549
+ util.assertIsDefined(userWithPermission);
550
+ return React__default["default"].createElement(React__default["default"].Fragment, null, children({
551
+ user: userWithPermission,
552
+ logout: function logout() {
553
+ return userLogout(_logout);
554
+ },
555
+ getToken: getAccessTokenSilently
556
+ }));
879
557
  };
880
-
881
558
  var AppShell = function AppShell(_ref3) {
882
559
  var children = _ref3.children,
883
- audience = _ref3.audience,
884
- domain = _ref3.domain,
885
- clientId = _ref3.clientId,
886
- redirectUri = _ref3.redirectUri,
887
- decorateUser = _ref3.decorateUser,
888
- environment = _ref3.environment;
889
- return React__default["default"].createElement(AuthProvider, {
890
- audience: audience,
560
+ audience = _ref3.audience,
561
+ domain = _ref3.domain,
562
+ clientId = _ref3.clientId,
563
+ decorateUser = _ref3.decorateUser,
564
+ environment = _ref3.environment;
565
+ return React__default["default"].createElement(auth0React.Auth0Provider, {
891
566
  domain: domain,
892
- client_id: clientId,
893
- decorateUser: decorateUser
567
+ clientId: clientId,
568
+ authorizationParams: {
569
+ redirect_uri: window.location.origin,
570
+ audience: audience
571
+ }
894
572
  }, React__default["default"].createElement(Authenticate, {
895
- redirectUri: redirectUri
573
+ decorateUser: decorateUser
896
574
  }, function (params) {
897
575
  return React__default["default"].createElement(React__default["default"].Fragment, null, environment && environment !== common.Environment.Production && React__default["default"].createElement(EnvironmentBanner, {
898
576
  environment: environment
@@ -901,18 +579,15 @@ var AppShell = function AppShell(_ref3) {
901
579
  };
902
580
 
903
581
  var _excluded$1 = ["navigate", "children", "onClick", "target"];
904
-
905
582
  function isModifiedEvent(event) {
906
583
  return !!(event.metaKey || event.altKey || event.ctrlKey || event.shiftKey);
907
584
  }
908
-
909
585
  var MicroFrontendLink = function MicroFrontendLink(_ref) {
910
586
  var navigate = _ref.navigate,
911
- children = _ref.children,
912
- _onClick = _ref.onClick,
913
- target = _ref.target,
914
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
915
-
587
+ children = _ref.children,
588
+ _onClick = _ref.onClick,
589
+ target = _ref.target,
590
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$1);
916
591
  return React__default["default"].createElement("a", _extends({
917
592
  onClick: function onClick(event) {
918
593
  try {
@@ -921,10 +596,12 @@ var MicroFrontendLink = function MicroFrontendLink(_ref) {
921
596
  event.preventDefault();
922
597
  throw ex;
923
598
  }
924
-
925
- if (!event.defaultPrevented && // onClick prevented default
926
- event.button === 0 && ( // ignore everything but right clicks
927
- !target || target === '_self') && // let browser handle "target=_blank" etc.
599
+ if (!event.defaultPrevented &&
600
+ // onClick prevented default
601
+ event.button === 0 && (
602
+ // ignore everything but right clicks
603
+ !target || target === '_self') &&
604
+ // let browser handle "target=_blank" etc.
928
605
  !isModifiedEvent(event) // ignore clicks with modifier keys
929
606
  ) {
930
607
  event.preventDefault();
@@ -954,47 +631,37 @@ var useMenu = function useMenu() {
954
631
  };
955
632
  var useMFNavigation = function useMFNavigation(path) {
956
633
  var _useMenu = useMenu(),
957
- getMFNavigate = _useMenu.getMFNavigate;
958
-
634
+ getMFNavigate = _useMenu.getMFNavigate;
959
635
  return getMFNavigate(path);
960
636
  };
961
637
  var MenuProvider = function MenuProvider(_ref) {
962
638
  var children = _ref.children;
963
-
964
639
  var _useState = React.useState({}),
965
- groups = _useState[0],
966
- setGroups = _useState[1];
967
-
640
+ groups = _useState[0],
641
+ setGroups = _useState[1];
968
642
  var _useState2 = React.useState({}),
969
- navFuncs = _useState2[0],
970
- setNavFuncs = _useState2[1];
971
-
643
+ navFuncs = _useState2[0],
644
+ setNavFuncs = _useState2[1];
972
645
  var addItems = React.useCallback(function (newItems, path) {
973
646
  setGroups(function (prevState) {
974
647
  var _extends2;
975
-
976
648
  return _extends({}, prevState, (_extends2 = {}, _extends2[path] = newItems, _extends2));
977
649
  });
978
650
  }, [setGroups]);
979
-
980
651
  var getMFNavigate = function getMFNavigate(path) {
981
652
  return navFuncs[path];
982
653
  };
983
-
984
654
  var setMFNavigate = function setMFNavigate(path, navigation) {
985
655
  return setNavFuncs(function (prev) {
986
656
  var _extends3;
987
-
988
657
  return _extends({}, prev, (_extends3 = {}, _extends3[path] = navigation, _extends3));
989
658
  });
990
659
  };
991
-
992
660
  return React__default["default"].createElement(MenuContext.Provider, {
993
661
  value: {
994
662
  addItems: addItems,
995
663
  getItemsForPath: function getItemsForPath(path) {
996
664
  var _groups$path;
997
-
998
665
  return (_groups$path = groups[path]) != null ? _groups$path : [];
999
666
  },
1000
667
  getMFNavigate: getMFNavigate,
@@ -1033,26 +700,21 @@ var useOrganisationId = function useOrganisationId() {
1033
700
  util.assertIsDefined(context);
1034
701
  return context.organisationId;
1035
702
  };
1036
-
1037
703
  var useOrganisationState = function useOrganisationState(initialOrganisationId) {
1038
704
  var _useState = React.useState(Number(initialOrganisationId)),
1039
- organisationId = _useState[0],
1040
- setOrganisationId = _useState[1];
1041
-
705
+ organisationId = _useState[0],
706
+ setOrganisationId = _useState[1];
1042
707
  React.useEffect(function () {
1043
708
  organisationStorage.set(organisationId.toString());
1044
709
  }, [organisationId]);
1045
710
  return [organisationId, setOrganisationId];
1046
711
  };
1047
-
1048
712
  var OrganisationProvider = function OrganisationProvider(_ref) {
1049
713
  var children = _ref.children,
1050
- organisationId = _ref.organisationId;
1051
-
714
+ organisationId = _ref.organisationId;
1052
715
  var _useOrganisationState = useOrganisationState(organisationId),
1053
- orgId = _useOrganisationState[0],
1054
- setOrganisationId = _useOrganisationState[1];
1055
-
716
+ orgId = _useOrganisationState[0],
717
+ setOrganisationId = _useOrganisationState[1];
1056
718
  return React__default["default"].createElement(OrganisationContext.Provider, {
1057
719
  value: {
1058
720
  organisationId: orgId,
@@ -1062,18 +724,15 @@ var OrganisationProvider = function OrganisationProvider(_ref) {
1062
724
  };
1063
725
 
1064
726
  var LanguageContext = /*#__PURE__*/React__default["default"].createContext(undefined);
1065
-
1066
727
  var useLanguageState = function useLanguageState(language) {
1067
728
  var _useState = React.useState(language),
1068
- activeLanguage = _useState[0],
1069
- setLanguage = _useState[1];
1070
-
729
+ activeLanguage = _useState[0],
730
+ setLanguage = _useState[1];
1071
731
  React.useEffect(function () {
1072
732
  languageStorage.set(activeLanguage);
1073
733
  }, [activeLanguage]);
1074
734
  return [activeLanguage, setLanguage];
1075
735
  };
1076
-
1077
736
  var useLanguage = function useLanguage() {
1078
737
  var context = React.useContext(LanguageContext);
1079
738
  util.assertIsDefined(context);
@@ -1081,12 +740,10 @@ var useLanguage = function useLanguage() {
1081
740
  };
1082
741
  var LanguageProvider = function LanguageProvider(_ref) {
1083
742
  var children = _ref.children,
1084
- language = _ref.language;
1085
-
743
+ language = _ref.language;
1086
744
  var _useLanguageState = useLanguageState(language),
1087
- activeLanguage = _useLanguageState[0],
1088
- setLanguage = _useLanguageState[1];
1089
-
745
+ activeLanguage = _useLanguageState[0],
746
+ setLanguage = _useLanguageState[1];
1090
747
  return React__default["default"].createElement(LanguageContext.Provider, {
1091
748
  value: {
1092
749
  language: activeLanguage,
@@ -1096,109 +753,87 @@ var LanguageProvider = function LanguageProvider(_ref) {
1096
753
  };
1097
754
 
1098
755
  var OrganisationsError = /*#__PURE__*/function (_Error) {
1099
- _inheritsLoose(OrganisationsError, _Error);
1100
-
1101
756
  function OrganisationsError() {
1102
757
  var _this;
1103
-
1104
758
  for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
1105
759
  args[_key] = arguments[_key];
1106
760
  }
1107
-
1108
761
  _this = _Error.call.apply(_Error, [this].concat(args)) || this;
1109
762
  _this.message = 'Failed fetching organisations';
1110
763
  return _this;
1111
764
  }
1112
-
765
+ _inheritsLoose(OrganisationsError, _Error);
1113
766
  return OrganisationsError;
1114
767
  }( /*#__PURE__*/_wrapNativeSuper(Error));
1115
768
 
1116
769
  var _excluded = ["getToken", "getOrganisations", "value", "onChange"];
1117
770
  var OrganisationSelector = function OrganisationSelector(_ref) {
1118
771
  var getToken = _ref.getToken,
1119
- getOrganisations = _ref.getOrganisations,
1120
- value = _ref.value,
1121
- onChange = _ref.onChange,
1122
- rest = _objectWithoutPropertiesLoose(_ref, _excluded);
1123
-
772
+ getOrganisations = _ref.getOrganisations,
773
+ value = _ref.value,
774
+ onChange = _ref.onChange,
775
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded);
1124
776
  var _useState = React.useState([]),
1125
- organisations = _useState[0],
1126
- setOrganisations = _useState[1];
1127
-
777
+ organisations = _useState[0],
778
+ setOrganisations = _useState[1];
1128
779
  var _useLanguage = useLanguage(),
1129
- language = _useLanguage.language;
1130
-
780
+ language = _useLanguage.language;
1131
781
  var _useState2 = React.useState('LOADING'),
1132
- status = _useState2[0],
1133
- setStatus = _useState2[1];
1134
-
782
+ status = _useState2[0],
783
+ setStatus = _useState2[1];
1135
784
  React.useEffect(function () {
1136
785
  var fetchOrganisations = /*#__PURE__*/function () {
1137
786
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
1138
787
  var token, organisations;
1139
788
  return _regeneratorRuntime().wrap(function _callee$(_context) {
1140
- while (1) {
1141
- switch (_context.prev = _context.next) {
1142
- case 0:
1143
- _context.next = 2;
1144
- return getToken();
1145
-
1146
- case 2:
1147
- token = _context.sent;
1148
-
1149
- if (!(typeof getOrganisations === 'string')) {
1150
- _context.next = 9;
1151
- break;
1152
- }
1153
-
1154
- _context.next = 6;
1155
- return fetch(getOrganisations, {
1156
- headers: {
1157
- Authorization: "Bearer " + token,
1158
- Accept: 'application/json'
1159
- }
1160
- }).then(function (response) {
1161
- return response.json();
1162
- });
1163
-
1164
- case 6:
1165
- organisations = _context.sent;
1166
- _context.next = 12;
789
+ while (1) switch (_context.prev = _context.next) {
790
+ case 0:
791
+ _context.next = 2;
792
+ return getToken();
793
+ case 2:
794
+ token = _context.sent;
795
+ if (!(typeof getOrganisations === 'string')) {
796
+ _context.next = 9;
1167
797
  break;
1168
-
1169
- case 9:
1170
- _context.next = 11;
1171
- return getOrganisations(token);
1172
-
1173
- case 11:
1174
- organisations = _context.sent;
1175
-
1176
- case 12:
1177
- setOrganisations(organisations);
1178
- setStatus('SUCCESS');
1179
-
1180
- case 14:
1181
- case "end":
1182
- return _context.stop();
1183
- }
798
+ }
799
+ _context.next = 6;
800
+ return fetch(getOrganisations, {
801
+ headers: {
802
+ Authorization: "Bearer " + token,
803
+ Accept: 'application/json'
804
+ }
805
+ }).then(function (response) {
806
+ return response.json();
807
+ });
808
+ case 6:
809
+ organisations = _context.sent;
810
+ _context.next = 12;
811
+ break;
812
+ case 9:
813
+ _context.next = 11;
814
+ return getOrganisations(token);
815
+ case 11:
816
+ organisations = _context.sent;
817
+ case 12:
818
+ setOrganisations(organisations);
819
+ setStatus('SUCCESS');
820
+ case 14:
821
+ case "end":
822
+ return _context.stop();
1184
823
  }
1185
824
  }, _callee);
1186
825
  }));
1187
-
1188
826
  return function fetchOrganisations() {
1189
827
  return _ref2.apply(this, arguments);
1190
828
  };
1191
829
  }();
1192
-
1193
830
  fetchOrganisations()["catch"](function (error) {
1194
831
  {
1195
832
  console.error(error);
1196
833
  }
1197
-
1198
834
  setStatus('ERROR');
1199
835
  });
1200
836
  }, [getOrganisations, getToken]);
1201
-
1202
837
  switch (status) {
1203
838
  case 'LOADING':
1204
839
  return React__default["default"].createElement("div", {
@@ -1208,7 +843,6 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
1208
843
  height: '2.4rem'
1209
844
  }
1210
845
  }));
1211
-
1212
846
  case 'SUCCESS':
1213
847
  return React__default["default"].createElement(common.OrganisationDropDown, _extends({
1214
848
  label: language === 'nb' ? 'Organisasjon' : 'Organisation',
@@ -1216,10 +850,8 @@ var OrganisationSelector = function OrganisationSelector(_ref) {
1216
850
  organisations: organisations,
1217
851
  onChange: onChange
1218
852
  }, rest));
1219
-
1220
853
  case 'ERROR':
1221
854
  throw new OrganisationsError();
1222
-
1223
855
  default:
1224
856
  return null;
1225
857
  }