· 6 years ago · Mar 27, 2020, 04:02 AM
1(function () {
2 function createCommonjsModule(fn, module) {
3 return module = { exports: {} }, fn(module, module.exports), module.exports;
4 }
5
6 var runtime = createCommonjsModule(function (module) {
7 /**
8 * Copyright (c) 2014-present, Facebook, Inc.
9 *
10 * This source code is licensed under the MIT license found in the
11 * LICENSE file in the root directory of this source tree.
12 */
13 !function (global) {
14
15 var Op = Object.prototype;
16 var hasOwn = Op.hasOwnProperty;
17 var undefined$1; // More compressible than void 0.
18
19 var $Symbol = typeof Symbol === "function" ? Symbol : {};
20 var iteratorSymbol = $Symbol.iterator || "@@iterator";
21 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
22 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
23 var runtime = global.regeneratorRuntime;
24
25 if (runtime) {
26 {
27 // If regeneratorRuntime is defined globally and we're in a module,
28 // make the exports object identical to regeneratorRuntime.
29 module.exports = runtime;
30 } // Don't bother evaluating the rest of this file if the runtime was
31 // already defined globally.
32
33
34 return;
35 } // Define the runtime globally (as expected by generated code) as either
36 // module.exports (if we're in a module) or a new, empty object.
37
38
39 runtime = global.regeneratorRuntime = module.exports ;
40
41 function wrap(innerFn, outerFn, self, tryLocsList) {
42 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
43 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
44 var generator = Object.create(protoGenerator.prototype);
45 var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
46 // .throw, and .return methods.
47
48 generator._invoke = makeInvokeMethod(innerFn, self, context);
49 return generator;
50 }
51
52 runtime.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
53 // record like context.tryEntries[i].completion. This interface could
54 // have been (and was previously) designed to take a closure to be
55 // invoked without arguments, but in all the cases we care about we
56 // already have an existing method we want to call, so there's no need
57 // to create a new function object. We can even get away with assuming
58 // the method takes exactly one argument, since that happens to be true
59 // in every case, so we don't have to touch the arguments object. The
60 // only additional allocation required is the completion record, which
61 // has a stable shape and so hopefully should be cheap to allocate.
62
63 function tryCatch(fn, obj, arg) {
64 try {
65 return {
66 type: "normal",
67 arg: fn.call(obj, arg)
68 };
69 } catch (err) {
70 return {
71 type: "throw",
72 arg: err
73 };
74 }
75 }
76
77 var GenStateSuspendedStart = "suspendedStart";
78 var GenStateSuspendedYield = "suspendedYield";
79 var GenStateExecuting = "executing";
80 var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
81 // breaking out of the dispatch switch statement.
82
83 var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
84 // .constructor.prototype properties for functions that return Generator
85 // objects. For full spec compliance, you may wish to configure your
86 // minifier not to mangle the names of these two functions.
87
88 function Generator() {}
89
90 function GeneratorFunction() {}
91
92 function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
93 // don't natively support it.
94
95
96 var IteratorPrototype = {};
97
98 IteratorPrototype[iteratorSymbol] = function () {
99 return this;
100 };
101
102 var getProto = Object.getPrototypeOf;
103 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
104
105 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
106 // This environment has a native %IteratorPrototype%; use it instead
107 // of the polyfill.
108 IteratorPrototype = NativeIteratorPrototype;
109 }
110
111 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
112 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
113 GeneratorFunctionPrototype.constructor = GeneratorFunction;
114 GeneratorFunctionPrototype[toStringTagSymbol] = GeneratorFunction.displayName = "GeneratorFunction"; // Helper for defining the .next, .throw, and .return methods of the
115 // Iterator interface in terms of a single ._invoke method.
116
117 function defineIteratorMethods(prototype) {
118 ["next", "throw", "return"].forEach(function (method) {
119 prototype[method] = function (arg) {
120 return this._invoke(method, arg);
121 };
122 });
123 }
124
125 runtime.isGeneratorFunction = function (genFun) {
126 var ctor = typeof genFun === "function" && genFun.constructor;
127 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
128 // do is to check its .name property.
129 (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
130 };
131
132 runtime.mark = function (genFun) {
133 if (Object.setPrototypeOf) {
134 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
135 } else {
136 genFun.__proto__ = GeneratorFunctionPrototype;
137
138 if (!(toStringTagSymbol in genFun)) {
139 genFun[toStringTagSymbol] = "GeneratorFunction";
140 }
141 }
142
143 genFun.prototype = Object.create(Gp);
144 return genFun;
145 }; // Within the body of any async function, `await x` is transformed to
146 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
147 // `hasOwn.call(value, "__await")` to determine if the yielded value is
148 // meant to be awaited.
149
150
151 runtime.awrap = function (arg) {
152 return {
153 __await: arg
154 };
155 };
156
157 function AsyncIterator(generator) {
158 function invoke(method, arg, resolve, reject) {
159 var record = tryCatch(generator[method], generator, arg);
160
161 if (record.type === "throw") {
162 reject(record.arg);
163 } else {
164 var result = record.arg;
165 var value = result.value;
166
167 if (value && typeof value === "object" && hasOwn.call(value, "__await")) {
168 return Promise.resolve(value.__await).then(function (value) {
169 invoke("next", value, resolve, reject);
170 }, function (err) {
171 invoke("throw", err, resolve, reject);
172 });
173 }
174
175 return Promise.resolve(value).then(function (unwrapped) {
176 // When a yielded Promise is resolved, its final value becomes
177 // the .value of the Promise<{value,done}> result for the
178 // current iteration. If the Promise is rejected, however, the
179 // result for this iteration will be rejected with the same
180 // reason. Note that rejections of yielded Promises are not
181 // thrown back into the generator function, as is the case
182 // when an awaited Promise is rejected. This difference in
183 // behavior between yield and await is important, because it
184 // allows the consumer to decide what to do with the yielded
185 // rejection (swallow it and continue, manually .throw it back
186 // into the generator, abandon iteration, whatever). With
187 // await, by contrast, there is no opportunity to examine the
188 // rejection reason outside the generator function, so the
189 // only option is to throw it from the await expression, and
190 // let the generator function handle the exception.
191 result.value = unwrapped;
192 resolve(result);
193 }, reject);
194 }
195 }
196
197 var previousPromise;
198
199 function enqueue(method, arg) {
200 function callInvokeWithMethodAndArg() {
201 return new Promise(function (resolve, reject) {
202 invoke(method, arg, resolve, reject);
203 });
204 }
205
206 return previousPromise = // If enqueue has been called before, then we want to wait until
207 // all previous Promises have been resolved before calling invoke,
208 // so that results are always delivered in the correct order. If
209 // enqueue has not been called before, then it is important to
210 // call invoke immediately, without waiting on a callback to fire,
211 // so that the async generator function has the opportunity to do
212 // any necessary setup in a predictable way. This predictability
213 // is why the Promise constructor synchronously invokes its
214 // executor callback, and why async functions synchronously
215 // execute code before the first await. Since we implement simple
216 // async functions in terms of async generators, it is especially
217 // important to get this right, even though it requires care.
218 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
219 // invocations of the iterator.
220 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
221 } // Define the unified helper method that is used to implement .next,
222 // .throw, and .return (see defineIteratorMethods).
223
224
225 this._invoke = enqueue;
226 }
227
228 defineIteratorMethods(AsyncIterator.prototype);
229
230 AsyncIterator.prototype[asyncIteratorSymbol] = function () {
231 return this;
232 };
233
234 runtime.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
235 // AsyncIterator objects; they just return a Promise for the value of
236 // the final result produced by the iterator.
237
238 runtime.async = function (innerFn, outerFn, self, tryLocsList) {
239 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList));
240 return runtime.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
241 : iter.next().then(function (result) {
242 return result.done ? result.value : iter.next();
243 });
244 };
245
246 function makeInvokeMethod(innerFn, self, context) {
247 var state = GenStateSuspendedStart;
248 return function invoke(method, arg) {
249 if (state === GenStateExecuting) {
250 throw new Error("Generator is already running");
251 }
252
253 if (state === GenStateCompleted) {
254 if (method === "throw") {
255 throw arg;
256 } // Be forgiving, per 25.3.3.3.3 of the spec:
257 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
258
259
260 return doneResult();
261 }
262
263 context.method = method;
264 context.arg = arg;
265
266 while (true) {
267 var delegate = context.delegate;
268
269 if (delegate) {
270 var delegateResult = maybeInvokeDelegate(delegate, context);
271
272 if (delegateResult) {
273 if (delegateResult === ContinueSentinel) continue;
274 return delegateResult;
275 }
276 }
277
278 if (context.method === "next") {
279 // Setting context._sent for legacy support of Babel's
280 // function.sent implementation.
281 context.sent = context._sent = context.arg;
282 } else if (context.method === "throw") {
283 if (state === GenStateSuspendedStart) {
284 state = GenStateCompleted;
285 throw context.arg;
286 }
287
288 context.dispatchException(context.arg);
289 } else if (context.method === "return") {
290 context.abrupt("return", context.arg);
291 }
292
293 state = GenStateExecuting;
294 var record = tryCatch(innerFn, self, context);
295
296 if (record.type === "normal") {
297 // If an exception is thrown from innerFn, we leave state ===
298 // GenStateExecuting and loop back for another invocation.
299 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
300
301 if (record.arg === ContinueSentinel) {
302 continue;
303 }
304
305 return {
306 value: record.arg,
307 done: context.done
308 };
309 } else if (record.type === "throw") {
310 state = GenStateCompleted; // Dispatch the exception by looping back around to the
311 // context.dispatchException(context.arg) call above.
312
313 context.method = "throw";
314 context.arg = record.arg;
315 }
316 }
317 };
318 } // Call delegate.iterator[context.method](context.arg) and handle the
319 // result, either by returning a { value, done } result from the
320 // delegate iterator, or by modifying context.method and context.arg,
321 // setting context.delegate to null, and returning the ContinueSentinel.
322
323
324 function maybeInvokeDelegate(delegate, context) {
325 var method = delegate.iterator[context.method];
326
327 if (method === undefined$1) {
328 // A .throw or .return when the delegate iterator has no .throw
329 // method always terminates the yield* loop.
330 context.delegate = null;
331
332 if (context.method === "throw") {
333 if (delegate.iterator.return) {
334 // If the delegate iterator has a return method, give it a
335 // chance to clean up.
336 context.method = "return";
337 context.arg = undefined$1;
338 maybeInvokeDelegate(delegate, context);
339
340 if (context.method === "throw") {
341 // If maybeInvokeDelegate(context) changed context.method from
342 // "return" to "throw", let that override the TypeError below.
343 return ContinueSentinel;
344 }
345 }
346
347 context.method = "throw";
348 context.arg = new TypeError("The iterator does not provide a 'throw' method");
349 }
350
351 return ContinueSentinel;
352 }
353
354 var record = tryCatch(method, delegate.iterator, context.arg);
355
356 if (record.type === "throw") {
357 context.method = "throw";
358 context.arg = record.arg;
359 context.delegate = null;
360 return ContinueSentinel;
361 }
362
363 var info = record.arg;
364
365 if (!info) {
366 context.method = "throw";
367 context.arg = new TypeError("iterator result is not an object");
368 context.delegate = null;
369 return ContinueSentinel;
370 }
371
372 if (info.done) {
373 // Assign the result of the finished delegate to the temporary
374 // variable specified by delegate.resultName (see delegateYield).
375 context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
376
377 context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
378 // exception, let the outer generator proceed normally. If
379 // context.method was "next", forget context.arg since it has been
380 // "consumed" by the delegate iterator. If context.method was
381 // "return", allow the original .return call to continue in the
382 // outer generator.
383
384 if (context.method !== "return") {
385 context.method = "next";
386 context.arg = undefined$1;
387 }
388 } else {
389 // Re-yield the result returned by the delegate method.
390 return info;
391 } // The delegate iterator is finished, so forget it and continue with
392 // the outer generator.
393
394
395 context.delegate = null;
396 return ContinueSentinel;
397 } // Define Generator.prototype.{next,throw,return} in terms of the
398 // unified ._invoke helper method.
399
400
401 defineIteratorMethods(Gp);
402 Gp[toStringTagSymbol] = "Generator"; // A Generator should always return itself as the iterator object when the
403 // @@iterator function is called on it. Some browsers' implementations of the
404 // iterator prototype chain incorrectly implement this, causing the Generator
405 // object to not be returned from this call. This ensures that doesn't happen.
406 // See https://github.com/facebook/regenerator/issues/274 for more details.
407
408 Gp[iteratorSymbol] = function () {
409 return this;
410 };
411
412 Gp.toString = function () {
413 return "[object Generator]";
414 };
415
416 function pushTryEntry(locs) {
417 var entry = {
418 tryLoc: locs[0]
419 };
420
421 if (1 in locs) {
422 entry.catchLoc = locs[1];
423 }
424
425 if (2 in locs) {
426 entry.finallyLoc = locs[2];
427 entry.afterLoc = locs[3];
428 }
429
430 this.tryEntries.push(entry);
431 }
432
433 function resetTryEntry(entry) {
434 var record = entry.completion || {};
435 record.type = "normal";
436 delete record.arg;
437 entry.completion = record;
438 }
439
440 function Context(tryLocsList) {
441 // The root entry object (effectively a try statement without a catch
442 // or a finally block) gives us a place to store values thrown from
443 // locations where there is no enclosing try statement.
444 this.tryEntries = [{
445 tryLoc: "root"
446 }];
447 tryLocsList.forEach(pushTryEntry, this);
448 this.reset(true);
449 }
450
451 runtime.keys = function (object) {
452 var keys = [];
453
454 for (var key in object) {
455 keys.push(key);
456 }
457
458 keys.reverse(); // Rather than returning an object with a next method, we keep
459 // things simple and return the next function itself.
460
461 return function next() {
462 while (keys.length) {
463 var key = keys.pop();
464
465 if (key in object) {
466 next.value = key;
467 next.done = false;
468 return next;
469 }
470 } // To avoid creating an additional object, we just hang the .value
471 // and .done properties off the next function object itself. This
472 // also ensures that the minifier will not anonymize the function.
473
474
475 next.done = true;
476 return next;
477 };
478 };
479
480 function values(iterable) {
481 if (iterable) {
482 var iteratorMethod = iterable[iteratorSymbol];
483
484 if (iteratorMethod) {
485 return iteratorMethod.call(iterable);
486 }
487
488 if (typeof iterable.next === "function") {
489 return iterable;
490 }
491
492 if (!isNaN(iterable.length)) {
493 var i = -1,
494 next = function next() {
495 while (++i < iterable.length) {
496 if (hasOwn.call(iterable, i)) {
497 next.value = iterable[i];
498 next.done = false;
499 return next;
500 }
501 }
502
503 next.value = undefined$1;
504 next.done = true;
505 return next;
506 };
507
508 return next.next = next;
509 }
510 } // Return an iterator with no values.
511
512
513 return {
514 next: doneResult
515 };
516 }
517
518 runtime.values = values;
519
520 function doneResult() {
521 return {
522 value: undefined$1,
523 done: true
524 };
525 }
526
527 Context.prototype = {
528 constructor: Context,
529 reset: function (skipTempReset) {
530 this.prev = 0;
531 this.next = 0; // Resetting context._sent for legacy support of Babel's
532 // function.sent implementation.
533
534 this.sent = this._sent = undefined$1;
535 this.done = false;
536 this.delegate = null;
537 this.method = "next";
538 this.arg = undefined$1;
539 this.tryEntries.forEach(resetTryEntry);
540
541 if (!skipTempReset) {
542 for (var name in this) {
543 // Not sure about the optimal order of these conditions:
544 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
545 this[name] = undefined$1;
546 }
547 }
548 }
549 },
550 stop: function () {
551 this.done = true;
552 var rootEntry = this.tryEntries[0];
553 var rootRecord = rootEntry.completion;
554
555 if (rootRecord.type === "throw") {
556 throw rootRecord.arg;
557 }
558
559 return this.rval;
560 },
561 dispatchException: function (exception) {
562 if (this.done) {
563 throw exception;
564 }
565
566 var context = this;
567
568 function handle(loc, caught) {
569 record.type = "throw";
570 record.arg = exception;
571 context.next = loc;
572
573 if (caught) {
574 // If the dispatched exception was caught by a catch block,
575 // then let that catch block handle the exception normally.
576 context.method = "next";
577 context.arg = undefined$1;
578 }
579
580 return !!caught;
581 }
582
583 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
584 var entry = this.tryEntries[i];
585 var record = entry.completion;
586
587 if (entry.tryLoc === "root") {
588 // Exception thrown outside of any try block that could handle
589 // it, so set the completion value of the entire function to
590 // throw the exception.
591 return handle("end");
592 }
593
594 if (entry.tryLoc <= this.prev) {
595 var hasCatch = hasOwn.call(entry, "catchLoc");
596 var hasFinally = hasOwn.call(entry, "finallyLoc");
597
598 if (hasCatch && hasFinally) {
599 if (this.prev < entry.catchLoc) {
600 return handle(entry.catchLoc, true);
601 } else if (this.prev < entry.finallyLoc) {
602 return handle(entry.finallyLoc);
603 }
604 } else if (hasCatch) {
605 if (this.prev < entry.catchLoc) {
606 return handle(entry.catchLoc, true);
607 }
608 } else if (hasFinally) {
609 if (this.prev < entry.finallyLoc) {
610 return handle(entry.finallyLoc);
611 }
612 } else {
613 throw new Error("try statement without catch or finally");
614 }
615 }
616 }
617 },
618 abrupt: function (type, arg) {
619 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
620 var entry = this.tryEntries[i];
621
622 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
623 var finallyEntry = entry;
624 break;
625 }
626 }
627
628 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
629 // Ignore the finally entry if control is not jumping to a
630 // location outside the try/catch block.
631 finallyEntry = null;
632 }
633
634 var record = finallyEntry ? finallyEntry.completion : {};
635 record.type = type;
636 record.arg = arg;
637
638 if (finallyEntry) {
639 this.method = "next";
640 this.next = finallyEntry.finallyLoc;
641 return ContinueSentinel;
642 }
643
644 return this.complete(record);
645 },
646 complete: function (record, afterLoc) {
647 if (record.type === "throw") {
648 throw record.arg;
649 }
650
651 if (record.type === "break" || record.type === "continue") {
652 this.next = record.arg;
653 } else if (record.type === "return") {
654 this.rval = this.arg = record.arg;
655 this.method = "return";
656 this.next = "end";
657 } else if (record.type === "normal" && afterLoc) {
658 this.next = afterLoc;
659 }
660
661 return ContinueSentinel;
662 },
663 finish: function (finallyLoc) {
664 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
665 var entry = this.tryEntries[i];
666
667 if (entry.finallyLoc === finallyLoc) {
668 this.complete(entry.completion, entry.afterLoc);
669 resetTryEntry(entry);
670 return ContinueSentinel;
671 }
672 }
673 },
674 "catch": function (tryLoc) {
675 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
676 var entry = this.tryEntries[i];
677
678 if (entry.tryLoc === tryLoc) {
679 var record = entry.completion;
680
681 if (record.type === "throw") {
682 var thrown = record.arg;
683 resetTryEntry(entry);
684 }
685
686 return thrown;
687 }
688 } // The context.catch method must only be called with a location
689 // argument that corresponds to a known catch block.
690
691
692 throw new Error("illegal catch attempt");
693 },
694 delegateYield: function (iterable, resultName, nextLoc) {
695 this.delegate = {
696 iterator: values(iterable),
697 resultName: resultName,
698 nextLoc: nextLoc
699 };
700
701 if (this.method === "next") {
702 // Deliberately forget the last sent value so that we don't
703 // accidentally pass it on to the delegate.
704 this.arg = undefined$1;
705 }
706
707 return ContinueSentinel;
708 }
709 };
710 }( // In sloppy mode, unbound `this` refers to the global object, fallback to
711 // Function constructor if we're in global strict mode. That is sadly a form
712 // of indirect eval which violates Content Security Policy.
713 function () {
714 return this;
715 }() || Function("return this")());
716 });
717
718 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
719 try {
720 var info = gen[key](arg);
721 var value = info.value;
722 } catch (error) {
723 reject(error);
724 return;
725 }
726
727 if (info.done) {
728 resolve(value);
729 } else {
730 Promise.resolve(value).then(_next, _throw);
731 }
732 }
733
734 function _asyncToGenerator(fn) {
735 return function () {
736 var self = this,
737 args = arguments;
738 return new Promise(function (resolve, reject) {
739 var gen = fn.apply(self, args);
740
741 function _next(value) {
742 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
743 }
744
745 function _throw(err) {
746 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
747 }
748
749 _next(undefined);
750 });
751 };
752 }
753
754 function _classCallCheck(instance, Constructor) {
755 if (!(instance instanceof Constructor)) {
756 throw new TypeError("Cannot call a class as a function");
757 }
758 }
759
760 function _defineProperties(target, props) {
761 for (var i = 0; i < props.length; i++) {
762 var descriptor = props[i];
763 descriptor.enumerable = descriptor.enumerable || false;
764 descriptor.configurable = true;
765 if ("value" in descriptor) descriptor.writable = true;
766 Object.defineProperty(target, descriptor.key, descriptor);
767 }
768 }
769
770 function _createClass(Constructor, protoProps, staticProps) {
771 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
772 if (staticProps) _defineProperties(Constructor, staticProps);
773 return Constructor;
774 }
775
776 function _defineProperty(obj, key, value) {
777 if (key in obj) {
778 Object.defineProperty(obj, key, {
779 value: value,
780 enumerable: true,
781 configurable: true,
782 writable: true
783 });
784 } else {
785 obj[key] = value;
786 }
787
788 return obj;
789 }
790
791 function _inherits(subClass, superClass) {
792 if (typeof superClass !== "function" && superClass !== null) {
793 throw new TypeError("Super expression must either be null or a function");
794 }
795
796 subClass.prototype = Object.create(superClass && superClass.prototype, {
797 constructor: {
798 value: subClass,
799 writable: true,
800 configurable: true
801 }
802 });
803 if (superClass) _setPrototypeOf(subClass, superClass);
804 }
805
806 function _getPrototypeOf(o) {
807 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
808 return o.__proto__ || Object.getPrototypeOf(o);
809 };
810 return _getPrototypeOf(o);
811 }
812
813 function _setPrototypeOf(o, p) {
814 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
815 o.__proto__ = p;
816 return o;
817 };
818
819 return _setPrototypeOf(o, p);
820 }
821
822 function _assertThisInitialized(self) {
823 if (self === void 0) {
824 throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
825 }
826
827 return self;
828 }
829
830 function _possibleConstructorReturn(self, call) {
831 if (call && (typeof call === "object" || typeof call === "function")) {
832 return call;
833 }
834
835 return _assertThisInitialized(self);
836 }
837
838 var LHBaseClass =
839 /*#__PURE__*/
840 function () {
841 function LHBaseClass(params) {
842 _classCallCheck(this, LHBaseClass);
843 }
844
845 _createClass(LHBaseClass, [{
846 key: "getParam",
847 value: function getParam(params, strKey, defaultValue) {
848 params = params || {};
849
850 if (strKey in params) {
851 return params[strKey];
852 } else if (defaultValue === undefined) {
853 this.throwException(strKey + " is a required parameter", "Parameters Error");
854 } else {
855 return defaultValue;
856 }
857 }
858 }, {
859 key: "throwException",
860 value: function throwException(message) {
861 var title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "Error";
862 throw new Error(this.constructor.name + " -- " + title + ": " + message);
863 }
864 }]);
865
866 return LHBaseClass;
867 }();
868
869 var LHBaseClass_1 = LHBaseClass;
870
871 var LHDelegate =
872 /*#__PURE__*/
873 function (_LHBaseClass) {
874 _inherits(LHDelegate, _LHBaseClass);
875
876 function LHDelegate(params) {
877 var _this;
878
879 _classCallCheck(this, LHDelegate);
880
881 _this = _possibleConstructorReturn(this, _getPrototypeOf(LHDelegate).call(this, params));
882 _this.delegate = _this.getParam(params, "delegate", null);
883 _this.delegateTypes = [];
884 return _this;
885 }
886
887 _createClass(LHDelegate, [{
888 key: "notify",
889 value: function () {
890 var _notify = _asyncToGenerator(
891 /*#__PURE__*/
892 regeneratorRuntime.mark(function _callee(delegateString) {
893 var object,
894 _args = arguments;
895 return regeneratorRuntime.wrap(function _callee$(_context) {
896 while (1) {
897 switch (_context.prev = _context.next) {
898 case 0:
899 object = _args.length > 1 && _args[1] !== undefined ? _args[1] : null;
900
901 if (!this.delegateTypes.includes(delegateString)) {
902 this.throwException("delegateString:" + delegateString + " is not defined in delegateTypes");
903 }
904
905 if (this.delegate) {
906 this.delegate.receive(this, delegateString, object);
907 }
908
909 case 3:
910 case "end":
911 return _context.stop();
912 }
913 }
914 }, _callee, this);
915 }));
916
917 function notify(_x) {
918 return _notify.apply(this, arguments);
919 }
920
921 return notify;
922 }()
923 }, {
924 key: "receive",
925 value: function () {
926 var _receive = _asyncToGenerator(
927 /*#__PURE__*/
928 regeneratorRuntime.mark(function _callee2(notifier, delegateString) {
929 return regeneratorRuntime.wrap(function _callee2$(_context2) {
930 while (1) {
931 switch (_context2.prev = _context2.next) {
932 case 0:
933
934 case 1:
935 case "end":
936 return _context2.stop();
937 }
938 }
939 }, _callee2);
940 }));
941
942 function receive(_x2, _x3) {
943 return _receive.apply(this, arguments);
944 }
945
946 return receive;
947 }()
948 }]);
949
950 return LHDelegate;
951 }(LHBaseClass_1);
952
953 var LHDelegate_1 = LHDelegate;
954
955 var K2Base =
956 /*#__PURE__*/
957 function (_LHDelegate) {
958 _inherits(K2Base, _LHDelegate);
959
960 function K2Base(params) {
961 var _this;
962
963 _classCallCheck(this, K2Base);
964
965 _this = _possibleConstructorReturn(this, _getPrototypeOf(K2Base).call(this, params));
966 _this.types = {
967 STRING: "string",
968 LIST: "list",
969 BOOL: "boolean",
970 DATE: "dateTime"
971 };
972 return _this;
973 }
974
975 return K2Base;
976 }(LHDelegate_1);
977
978 var K2Base_1 = K2Base;
979
980 var K2BaseIntegration =
981 /*#__PURE__*/
982 function (_K2Base) {
983 _inherits(K2BaseIntegration, _K2Base);
984
985 function K2BaseIntegration(params) {
986 var _this;
987
988 _classCallCheck(this, K2BaseIntegration);
989
990 _this = _possibleConstructorReturn(this, _getPrototypeOf(K2BaseIntegration).call(this, params));
991 _this.metaData = {
992 systemName: null,
993 displayName: null,
994 description: null
995 };
996 _this.smartObjects = [];
997 return _this;
998 }
999
1000 _createClass(K2BaseIntegration, [{
1001 key: "getSmartObject",
1002 value: function getSmartObject(name) {
1003 var _iteratorNormalCompletion = true;
1004 var _didIteratorError = false;
1005 var _iteratorError = undefined;
1006
1007 try {
1008 for (var _iterator = this.smartObjects[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
1009 var obj = _step.value;
1010
1011 if (obj.name === name) {
1012 return obj;
1013 }
1014 }
1015 } catch (err) {
1016 _didIteratorError = true;
1017 _iteratorError = err;
1018 } finally {
1019 try {
1020 if (!_iteratorNormalCompletion && _iterator["return"] != null) {
1021 _iterator["return"]();
1022 }
1023 } finally {
1024 if (_didIteratorError) {
1025 throw _iteratorError;
1026 }
1027 }
1028 }
1029
1030 this.throwException("Smart Object does not exist!");
1031 }
1032 }, {
1033 key: "getMetaData",
1034 value: function getMetaData() {
1035 return this.metaData;
1036 }
1037 }, {
1038 key: "getSchemas",
1039 value: function getSchemas() {
1040 var returnSchema = {};
1041 var _iteratorNormalCompletion2 = true;
1042 var _didIteratorError2 = false;
1043 var _iteratorError2 = undefined;
1044
1045 try {
1046 for (var _iterator2 = this.smartObjects[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
1047 var obj = _step2.value;
1048 returnSchema[obj.name] = obj.getSchema();
1049 }
1050 } catch (err) {
1051 _didIteratorError2 = true;
1052 _iteratorError2 = err;
1053 } finally {
1054 try {
1055 if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
1056 _iterator2["return"]();
1057 }
1058 } finally {
1059 if (_didIteratorError2) {
1060 throw _iteratorError2;
1061 }
1062 }
1063 }
1064
1065 return returnSchema;
1066 }
1067 }, {
1068 key: "execute",
1069 value: function () {
1070 var _execute = _asyncToGenerator(
1071 /*#__PURE__*/
1072 regeneratorRuntime.mark(function _callee(objectName, methodName, parameters, properties) {
1073 var obj;
1074 return regeneratorRuntime.wrap(function _callee$(_context) {
1075 while (1) {
1076 switch (_context.prev = _context.next) {
1077 case 0:
1078 obj = this.getSmartObject(objectName);
1079 _context.next = 3;
1080 return obj[methodName](parameters, properties);
1081
1082 case 3:
1083 return _context.abrupt("return", _context.sent);
1084
1085 case 4:
1086 case "end":
1087 return _context.stop();
1088 }
1089 }
1090 }, _callee, this);
1091 }));
1092
1093 function execute(_x, _x2, _x3, _x4) {
1094 return _execute.apply(this, arguments);
1095 }
1096
1097 return execute;
1098 }()
1099 }]);
1100
1101 return K2BaseIntegration;
1102 }(K2Base_1);
1103
1104 var K2BaseIntegration_1 = K2BaseIntegration;
1105
1106 var K2BaseSmartObject =
1107 /*#__PURE__*/
1108 function (_K2Base) {
1109 _inherits(K2BaseSmartObject, _K2Base);
1110
1111 function K2BaseSmartObject(params) {
1112 var _this;
1113
1114 _classCallCheck(this, K2BaseSmartObject);
1115
1116 _this = _possibleConstructorReturn(this, _getPrototypeOf(K2BaseSmartObject).call(this, params));
1117 _this.name = "K2BaseSmartObject";
1118 _this.displayName = "K2 BaseSmart Object";
1119 _this.description = "K2 BaseSmart Object";
1120 _this.api = _this.getParam(params, "api");
1121 _this.props = {};
1122 return _this;
1123 }
1124
1125 _createClass(K2BaseSmartObject, [{
1126 key: "getProperties",
1127 value: function getProperties() {
1128 return {};
1129 }
1130 }, {
1131 key: "getSchema",
1132 value: function getSchema() {
1133 return {
1134 displayName: this.displayName,
1135 description: this.description,
1136 properties: this.getProperties()
1137 };
1138 }
1139 }]);
1140
1141 return K2BaseSmartObject;
1142 }(K2Base_1);
1143
1144 var K2BaseSmartObject_1 = K2BaseSmartObject;
1145
1146 var baseUriEndpoint = "https://graph.microsoft.com/v1.0";
1147
1148 var Apps =
1149 /*#__PURE__*/
1150 function (_K2BaseSmartObject) {
1151 _inherits(Apps, _K2BaseSmartObject);
1152
1153 function Apps(params) {
1154 var _this;
1155
1156 _classCallCheck(this, Apps);
1157
1158 _this = _possibleConstructorReturn(this, _getPrototypeOf(Apps).call(this, params));
1159 _this.name = "apps";
1160 _this.displayName = "Apps";
1161 _this.description = "Apps";
1162 _this.props = {
1163 id: "id",
1164 teamId: "teamId",
1165 displayName: "displayName",
1166 version: "version",
1167 teamAppDefinitionId: "teamAppDefinitionId",
1168 teamsAppId: "teamsAppId"
1169 };
1170 _this.methods = {
1171 list: "list"
1172 };
1173 return _this;
1174 }
1175
1176 _createClass(Apps, [{
1177 key: "getProperties",
1178 value: function getProperties() {
1179 var _ref;
1180
1181 return _ref = {}, _defineProperty(_ref, this.props.id, {
1182 displayName: "App Id",
1183 description: "App Id",
1184 type: "string"
1185 }), _defineProperty(_ref, this.props.teamId, {
1186 displayName: "Team Id",
1187 description: "Team Id",
1188 type: "string"
1189 }), _defineProperty(_ref, this.props.displayName, {
1190 displayName: "App Display Name",
1191 description: "App Display Name",
1192 type: "string"
1193 }), _defineProperty(_ref, this.props.version, {
1194 displayName: "version",
1195 description: "version",
1196 type: "string"
1197 }), _defineProperty(_ref, this.props.teamAppDefinitionId, {
1198 displayName: "Teams Apps Definition Id",
1199 description: "Teams Apps Definition Id",
1200 type: "string"
1201 }), _defineProperty(_ref, this.props.teamsAppId, {
1202 displayName: "Teams Apps Id",
1203 description: "Teams Apps Id",
1204 type: "string"
1205 }), _ref;
1206 }
1207 }, {
1208 key: "getMethods",
1209 value: function getMethods() {
1210 return _defineProperty({}, this.methods.list, {
1211 displayName: "List Installed apps",
1212 type: this.types.LIST,
1213 inputs: [this.props.id],
1214 requiredInputs: [this.props.id],
1215 outputs: [this.props.id, this.props.displayName, this.props.version, this.props.teamAppDefinitionId, this.props.teamsAppId]
1216 });
1217 }
1218 }, {
1219 key: "list",
1220 value: function () {
1221 var _list = _asyncToGenerator(
1222 /*#__PURE__*/
1223 regeneratorRuntime.mark(function _callee(params, properties) {
1224 var _this2 = this;
1225
1226 var id, url, response, data;
1227 return regeneratorRuntime.wrap(function _callee$(_context) {
1228 while (1) {
1229 switch (_context.prev = _context.next) {
1230 case 0:
1231 id = this.getParam(params, this.props.id);
1232 url = baseUriEndpoint + "/teams/" + properties[this.props.teamId] + "/installedApps?$expand=teamsAppDefinition";
1233 _context.next = 4;
1234 return fetch(url, {
1235 method: 'GET',
1236 credentials: 'include'
1237 });
1238
1239 case 4:
1240 response = _context.sent;
1241 _context.next = 7;
1242 return response.json();
1243
1244 case 7:
1245 data = _context.sent;
1246 postResult(data.value.map(function (x) {
1247 var _ref3;
1248
1249 return _ref3 = {}, _defineProperty(_ref3, _this2.props.id, x.id), _defineProperty(_ref3, _this2.props.displayName, x.teamsAppDefinition.displayName), _defineProperty(_ref3, _this2.props.displayName, x.teamsAppDefinition.displayName), _defineProperty(_ref3, _this2.props.version, x.teamsAppDefinition.version), _defineProperty(_ref3, _this2.props.teamAppDefinitionId, x.teamsAppDefinition.id), _defineProperty(_ref3, _this2.props.teamAppDefinitionId, x.teamsAppDefinition.teamsAppId), _ref3;
1250 }));
1251
1252 case 9:
1253 case "end":
1254 return _context.stop();
1255 }
1256 }
1257 }, _callee, this);
1258 }));
1259
1260 function list(_x, _x2) {
1261 return _list.apply(this, arguments);
1262 }
1263
1264 return list;
1265 }()
1266 }]);
1267
1268 return Apps;
1269 }(K2BaseSmartObject_1);
1270
1271 var Apps_1 = Apps;
1272
1273 var MicrosoftTeamsApi =
1274 /*#__PURE__*/
1275 function (_LHDelegate) {
1276 _inherits(MicrosoftTeamsApi, _LHDelegate);
1277
1278 function MicrosoftTeamsApi(params) {
1279 _classCallCheck(this, MicrosoftTeamsApi);
1280
1281 return _possibleConstructorReturn(this, _getPrototypeOf(MicrosoftTeamsApi).call(this, params));
1282 }
1283
1284 _createClass(MicrosoftTeamsApi, [{
1285 key: "_get",
1286 value: function () {
1287 var _get2 = _asyncToGenerator(
1288 /*#__PURE__*/
1289 regeneratorRuntime.mark(function _callee(apiURLEnding, data) {
1290 var url, response;
1291 return regeneratorRuntime.wrap(function _callee$(_context) {
1292 while (1) {
1293 switch (_context.prev = _context.next) {
1294 case 0:
1295 url = this.baseURL + apiURLEnding + '?';
1296 _context.next = 3;
1297 return fetch(urlString, {
1298 method: 'get'
1299 });
1300
1301 case 3:
1302 response = _context.sent;
1303 return _context.abrupt("return", response);
1304
1305 case 5:
1306 case "end":
1307 return _context.stop();
1308 }
1309 }
1310 }, _callee, this);
1311 }));
1312
1313 function _get(_x, _x2) {
1314 return _get2.apply(this, arguments);
1315 }
1316
1317 return _get;
1318 }()
1319 }, {
1320 key: "getInstalledAppsList",
1321 value: function () {
1322 var _getInstalledAppsList = _asyncToGenerator(
1323 /*#__PURE__*/
1324 regeneratorRuntime.mark(function _callee2(id) {
1325 var url;
1326 return regeneratorRuntime.wrap(function _callee2$(_context2) {
1327 while (1) {
1328 switch (_context2.prev = _context2.next) {
1329 case 0:
1330 url = this.baseUri + "/teams/" + id + "/installedApps?$expand=teamsAppDefinition";
1331 _context2.next = 3;
1332 return this._get(url, {});
1333
1334 case 3:
1335 return _context2.abrupt("return", _context2.sent);
1336
1337 case 4:
1338 case "end":
1339 return _context2.stop();
1340 }
1341 }
1342 }, _callee2, this);
1343 }));
1344
1345 function getInstalledAppsList(_x3) {
1346 return _getInstalledAppsList.apply(this, arguments);
1347 }
1348
1349 return getInstalledAppsList;
1350 }()
1351 }]);
1352
1353 return MicrosoftTeamsApi;
1354 }(LHDelegate_1);
1355
1356 var MicrosoftTeamsApi_1 = MicrosoftTeamsApi;
1357
1358 var Integration =
1359 /*#__PURE__*/
1360 function (_K2BaseIntegration) {
1361 _inherits(Integration, _K2BaseIntegration);
1362
1363 function Integration(params) {
1364 var _this;
1365
1366 _classCallCheck(this, Integration);
1367
1368 _this = _possibleConstructorReturn(this, _getPrototypeOf(Integration).call(this, params));
1369 _this.metaData = {
1370 systemName: "MicrosoftTeamsIntegration",
1371 displayName: "Microsoft Teams Integration",
1372 description: "a simplified example version to build others off of"
1373 };
1374 _this.api = new MicrosoftTeamsApi_1();
1375 var soParams = {
1376 api: _this.api
1377 };
1378 _this.smartObjects = [new Apps_1(soParams)];
1379 return _this;
1380 }
1381
1382 _createClass(Integration, [{
1383 key: "getMetaData",
1384 value: function getMetaData() {
1385 return this.metaData;
1386 }
1387 }]);
1388
1389 return Integration;
1390 }(K2BaseIntegration_1);
1391
1392 var Integration_1 = Integration;
1393
1394 var integration = new Integration_1();
1395 metadata = integration.getMetaData();
1396
1397 ondescribe = function ondescribe() {
1398 postSchema(integration.getSchemas());
1399 };
1400
1401 onexecute =
1402 /*#__PURE__*/
1403 function () {
1404 var _ref = _asyncToGenerator(
1405 /*#__PURE__*/
1406 regeneratorRuntime.mark(function _callee(objectName, methodName, parameters, properties) {
1407 return regeneratorRuntime.wrap(function _callee$(_context) {
1408 while (1) {
1409 switch (_context.prev = _context.next) {
1410 case 0:
1411 _context.next = 2;
1412 return integration.execute(objectName, methodName, parameters, properties);
1413
1414 case 2:
1415 return _context.abrupt("return", _context.sent);
1416
1417 case 3:
1418 case "end":
1419 return _context.stop();
1420 }
1421 }
1422 }, _callee);
1423 }));
1424
1425 return function onexecute(_x, _x2, _x3, _x4) {
1426 return _ref.apply(this, arguments);
1427 };
1428 }();
1429
1430}());
1431//# sourceMappingURL=index.js.map