UNPKG

91.9 kBJavaScriptView Raw
1(function (global, factory) {
2 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('core-js/modules/es.object.to-string'), require('core-js/modules/es.promise'), require('core-js/modules/es.symbol'), require('core-js/modules/es.symbol.description'), require('core-js/modules/es.symbol.async-iterator'), require('core-js/modules/es.symbol.iterator'), require('core-js/modules/es.symbol.to-string-tag'), require('core-js/modules/es.array.for-each'), require('core-js/modules/es.array.iterator'), require('core-js/modules/es.array.reverse'), require('core-js/modules/es.array.slice'), require('core-js/modules/es.date.to-string'), require('core-js/modules/es.function.name'), require('core-js/modules/es.json.to-string-tag'), require('core-js/modules/es.math.to-string-tag'), require('core-js/modules/es.object.create'), require('core-js/modules/es.object.define-property'), require('core-js/modules/es.object.get-prototype-of'), require('core-js/modules/es.object.set-prototype-of'), require('core-js/modules/es.regexp.to-string'), require('core-js/modules/es.string.iterator'), require('core-js/modules/web.dom-collections.for-each'), require('core-js/modules/web.dom-collections.iterator'), require('axios'), require('core-js/modules/es.array.is-array'), require('core-js/modules/es.array.map'), require('core-js/modules/es.array.splice'), require('core-js/modules/es.regexp.constructor'), require('core-js/modules/es.regexp.exec'), require('core-js/modules/es.string.replace'), require('core-js/modules/es.object.entries'), require('core-js/modules/es.array.concat'), require('core-js/modules/es.array.join'), require('core-js/modules/es.number.constructor'), require('core-js/modules/es.parse-int'), require('core-js/modules/web.timers')) :
3 typeof define === 'function' && define.amd ? define(['exports', 'core-js/modules/es.object.to-string', 'core-js/modules/es.promise', 'core-js/modules/es.symbol', 'core-js/modules/es.symbol.description', 'core-js/modules/es.symbol.async-iterator', 'core-js/modules/es.symbol.iterator', 'core-js/modules/es.symbol.to-string-tag', 'core-js/modules/es.array.for-each', 'core-js/modules/es.array.iterator', 'core-js/modules/es.array.reverse', 'core-js/modules/es.array.slice', 'core-js/modules/es.date.to-string', 'core-js/modules/es.function.name', 'core-js/modules/es.json.to-string-tag', 'core-js/modules/es.math.to-string-tag', 'core-js/modules/es.object.create', 'core-js/modules/es.object.define-property', 'core-js/modules/es.object.get-prototype-of', 'core-js/modules/es.object.set-prototype-of', 'core-js/modules/es.regexp.to-string', 'core-js/modules/es.string.iterator', 'core-js/modules/web.dom-collections.for-each', 'core-js/modules/web.dom-collections.iterator', 'axios', 'core-js/modules/es.array.is-array', 'core-js/modules/es.array.map', 'core-js/modules/es.array.splice', 'core-js/modules/es.regexp.constructor', 'core-js/modules/es.regexp.exec', 'core-js/modules/es.string.replace', 'core-js/modules/es.object.entries', 'core-js/modules/es.array.concat', 'core-js/modules/es.array.join', 'core-js/modules/es.number.constructor', 'core-js/modules/es.parse-int', 'core-js/modules/web.timers'], factory) :
4 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.CSREST = {}, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, global.axios));
5}(this, (function (exports, es_object_toString, es_promise, es_symbol, es_symbol_description, es_symbol_asyncIterator, es_symbol_iterator, es_symbol_toStringTag, es_array_forEach, es_array_iterator, es_array_reverse, es_array_slice, es_date_toString, es_function_name, es_json_toStringTag, es_math_toStringTag, es_object_create, es_object_defineProperty, es_object_getPrototypeOf, es_object_setPrototypeOf, es_regexp_toString, es_string_iterator, web_domCollections_forEach, web_domCollections_iterator, axios) { 'use strict';
6
7 function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
9 var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
10
11 function _typeof(obj) {
12 "@babel/helpers - typeof";
13
14 if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
15 _typeof = function (obj) {
16 return typeof obj;
17 };
18 } else {
19 _typeof = function (obj) {
20 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
21 };
22 }
23
24 return _typeof(obj);
25 }
26
27 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
28 try {
29 var info = gen[key](arg);
30 var value = info.value;
31 } catch (error) {
32 reject(error);
33 return;
34 }
35
36 if (info.done) {
37 resolve(value);
38 } else {
39 Promise.resolve(value).then(_next, _throw);
40 }
41 }
42
43 function _asyncToGenerator(fn) {
44 return function () {
45 var self = this,
46 args = arguments;
47 return new Promise(function (resolve, reject) {
48 var gen = fn.apply(self, args);
49
50 function _next(value) {
51 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
52 }
53
54 function _throw(err) {
55 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
56 }
57
58 _next(undefined);
59 });
60 };
61 }
62
63 function _classCallCheck(instance, Constructor) {
64 if (!(instance instanceof Constructor)) {
65 throw new TypeError("Cannot call a class as a function");
66 }
67 }
68
69 function _defineProperties(target, props) {
70 for (var i = 0; i < props.length; i++) {
71 var descriptor = props[i];
72 descriptor.enumerable = descriptor.enumerable || false;
73 descriptor.configurable = true;
74 if ("value" in descriptor) descriptor.writable = true;
75 Object.defineProperty(target, descriptor.key, descriptor);
76 }
77 }
78
79 function _createClass(Constructor, protoProps, staticProps) {
80 if (protoProps) _defineProperties(Constructor.prototype, protoProps);
81 if (staticProps) _defineProperties(Constructor, staticProps);
82 return Constructor;
83 }
84
85 function _defineProperty(obj, key, value) {
86 if (key in obj) {
87 Object.defineProperty(obj, key, {
88 value: value,
89 enumerable: true,
90 configurable: true,
91 writable: true
92 });
93 } else {
94 obj[key] = value;
95 }
96
97 return obj;
98 }
99
100 function ownKeys(object, enumerableOnly) {
101 var keys = Object.keys(object);
102
103 if (Object.getOwnPropertySymbols) {
104 var symbols = Object.getOwnPropertySymbols(object);
105 if (enumerableOnly) symbols = symbols.filter(function (sym) {
106 return Object.getOwnPropertyDescriptor(object, sym).enumerable;
107 });
108 keys.push.apply(keys, symbols);
109 }
110
111 return keys;
112 }
113
114 function _objectSpread2(target) {
115 for (var i = 1; i < arguments.length; i++) {
116 var source = arguments[i] != null ? arguments[i] : {};
117
118 if (i % 2) {
119 ownKeys(Object(source), true).forEach(function (key) {
120 _defineProperty(target, key, source[key]);
121 });
122 } else if (Object.getOwnPropertyDescriptors) {
123 Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
124 } else {
125 ownKeys(Object(source)).forEach(function (key) {
126 Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
127 });
128 }
129 }
130
131 return target;
132 }
133
134 function _slicedToArray(arr, i) {
135 return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
136 }
137
138 function _arrayWithHoles(arr) {
139 if (Array.isArray(arr)) return arr;
140 }
141
142 function _iterableToArrayLimit(arr, i) {
143 if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
144 var _arr = [];
145 var _n = true;
146 var _d = false;
147 var _e = undefined;
148
149 try {
150 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
151 _arr.push(_s.value);
152
153 if (i && _arr.length === i) break;
154 }
155 } catch (err) {
156 _d = true;
157 _e = err;
158 } finally {
159 try {
160 if (!_n && _i["return"] != null) _i["return"]();
161 } finally {
162 if (_d) throw _e;
163 }
164 }
165
166 return _arr;
167 }
168
169 function _unsupportedIterableToArray(o, minLen) {
170 if (!o) return;
171 if (typeof o === "string") return _arrayLikeToArray(o, minLen);
172 var n = Object.prototype.toString.call(o).slice(8, -1);
173 if (n === "Object" && o.constructor) n = o.constructor.name;
174 if (n === "Map" || n === "Set") return Array.from(o);
175 if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
176 }
177
178 function _arrayLikeToArray(arr, len) {
179 if (len == null || len > arr.length) len = arr.length;
180
181 for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
182
183 return arr2;
184 }
185
186 function _nonIterableRest() {
187 throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
188 }
189
190 var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
191
192 function createCommonjsModule(fn, basedir, module) {
193 return module = {
194 path: basedir,
195 exports: {},
196 require: function (path, base) {
197 return commonjsRequire(path, (base === undefined || base === null) ? module.path : base);
198 }
199 }, fn(module, module.exports), module.exports;
200 }
201
202 function getAugmentedNamespace(n) {
203 if (n.__esModule) return n;
204 var a = Object.defineProperty({}, '__esModule', {value: true});
205 Object.keys(n).forEach(function (k) {
206 var d = Object.getOwnPropertyDescriptor(n, k);
207 Object.defineProperty(a, k, d.get ? d : {
208 enumerable: true,
209 get: function () {
210 return n[k];
211 }
212 });
213 });
214 return a;
215 }
216
217 function commonjsRequire () {
218 throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
219 }
220
221 var runtime_1 = createCommonjsModule(function (module) {
222 /**
223 * Copyright (c) 2014-present, Facebook, Inc.
224 *
225 * This source code is licensed under the MIT license found in the
226 * LICENSE file in the root directory of this source tree.
227 */
228 var runtime = function (exports) {
229
230 var Op = Object.prototype;
231 var hasOwn = Op.hasOwnProperty;
232 var undefined$1; // More compressible than void 0.
233
234 var $Symbol = typeof Symbol === "function" ? Symbol : {};
235 var iteratorSymbol = $Symbol.iterator || "@@iterator";
236 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator";
237 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag";
238
239 function define(obj, key, value) {
240 Object.defineProperty(obj, key, {
241 value: value,
242 enumerable: true,
243 configurable: true,
244 writable: true
245 });
246 return obj[key];
247 }
248
249 try {
250 // IE 8 has a broken Object.defineProperty that only works on DOM objects.
251 define({}, "");
252 } catch (err) {
253 define = function define(obj, key, value) {
254 return obj[key] = value;
255 };
256 }
257
258 function wrap(innerFn, outerFn, self, tryLocsList) {
259 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator.
260 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator;
261 var generator = Object.create(protoGenerator.prototype);
262 var context = new Context(tryLocsList || []); // The ._invoke method unifies the implementations of the .next,
263 // .throw, and .return methods.
264
265 generator._invoke = makeInvokeMethod(innerFn, self, context);
266 return generator;
267 }
268
269 exports.wrap = wrap; // Try/catch helper to minimize deoptimizations. Returns a completion
270 // record like context.tryEntries[i].completion. This interface could
271 // have been (and was previously) designed to take a closure to be
272 // invoked without arguments, but in all the cases we care about we
273 // already have an existing method we want to call, so there's no need
274 // to create a new function object. We can even get away with assuming
275 // the method takes exactly one argument, since that happens to be true
276 // in every case, so we don't have to touch the arguments object. The
277 // only additional allocation required is the completion record, which
278 // has a stable shape and so hopefully should be cheap to allocate.
279
280 function tryCatch(fn, obj, arg) {
281 try {
282 return {
283 type: "normal",
284 arg: fn.call(obj, arg)
285 };
286 } catch (err) {
287 return {
288 type: "throw",
289 arg: err
290 };
291 }
292 }
293
294 var GenStateSuspendedStart = "suspendedStart";
295 var GenStateSuspendedYield = "suspendedYield";
296 var GenStateExecuting = "executing";
297 var GenStateCompleted = "completed"; // Returning this object from the innerFn has the same effect as
298 // breaking out of the dispatch switch statement.
299
300 var ContinueSentinel = {}; // Dummy constructor functions that we use as the .constructor and
301 // .constructor.prototype properties for functions that return Generator
302 // objects. For full spec compliance, you may wish to configure your
303 // minifier not to mangle the names of these two functions.
304
305 function Generator() {}
306
307 function GeneratorFunction() {}
308
309 function GeneratorFunctionPrototype() {} // This is a polyfill for %IteratorPrototype% for environments that
310 // don't natively support it.
311
312
313 var IteratorPrototype = {};
314
315 IteratorPrototype[iteratorSymbol] = function () {
316 return this;
317 };
318
319 var getProto = Object.getPrototypeOf;
320 var NativeIteratorPrototype = getProto && getProto(getProto(values([])));
321
322 if (NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) {
323 // This environment has a native %IteratorPrototype%; use it instead
324 // of the polyfill.
325 IteratorPrototype = NativeIteratorPrototype;
326 }
327
328 var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype);
329 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
330 GeneratorFunctionPrototype.constructor = GeneratorFunction;
331 GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"); // Helper for defining the .next, .throw, and .return methods of the
332 // Iterator interface in terms of a single ._invoke method.
333
334 function defineIteratorMethods(prototype) {
335 ["next", "throw", "return"].forEach(function (method) {
336 define(prototype, method, function (arg) {
337 return this._invoke(method, arg);
338 });
339 });
340 }
341
342 exports.isGeneratorFunction = function (genFun) {
343 var ctor = typeof genFun === "function" && genFun.constructor;
344 return ctor ? ctor === GeneratorFunction || // For the native GeneratorFunction constructor, the best we can
345 // do is to check its .name property.
346 (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
347 };
348
349 exports.mark = function (genFun) {
350 if (Object.setPrototypeOf) {
351 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype);
352 } else {
353 genFun.__proto__ = GeneratorFunctionPrototype;
354 define(genFun, toStringTagSymbol, "GeneratorFunction");
355 }
356
357 genFun.prototype = Object.create(Gp);
358 return genFun;
359 }; // Within the body of any async function, `await x` is transformed to
360 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test
361 // `hasOwn.call(value, "__await")` to determine if the yielded value is
362 // meant to be awaited.
363
364
365 exports.awrap = function (arg) {
366 return {
367 __await: arg
368 };
369 };
370
371 function AsyncIterator(generator, PromiseImpl) {
372 function invoke(method, arg, resolve, reject) {
373 var record = tryCatch(generator[method], generator, arg);
374
375 if (record.type === "throw") {
376 reject(record.arg);
377 } else {
378 var result = record.arg;
379 var value = result.value;
380
381 if (value && _typeof(value) === "object" && hasOwn.call(value, "__await")) {
382 return PromiseImpl.resolve(value.__await).then(function (value) {
383 invoke("next", value, resolve, reject);
384 }, function (err) {
385 invoke("throw", err, resolve, reject);
386 });
387 }
388
389 return PromiseImpl.resolve(value).then(function (unwrapped) {
390 // When a yielded Promise is resolved, its final value becomes
391 // the .value of the Promise<{value,done}> result for the
392 // current iteration.
393 result.value = unwrapped;
394 resolve(result);
395 }, function (error) {
396 // If a rejected Promise was yielded, throw the rejection back
397 // into the async generator function so it can be handled there.
398 return invoke("throw", error, resolve, reject);
399 });
400 }
401 }
402
403 var previousPromise;
404
405 function enqueue(method, arg) {
406 function callInvokeWithMethodAndArg() {
407 return new PromiseImpl(function (resolve, reject) {
408 invoke(method, arg, resolve, reject);
409 });
410 }
411
412 return previousPromise = // If enqueue has been called before, then we want to wait until
413 // all previous Promises have been resolved before calling invoke,
414 // so that results are always delivered in the correct order. If
415 // enqueue has not been called before, then it is important to
416 // call invoke immediately, without waiting on a callback to fire,
417 // so that the async generator function has the opportunity to do
418 // any necessary setup in a predictable way. This predictability
419 // is why the Promise constructor synchronously invokes its
420 // executor callback, and why async functions synchronously
421 // execute code before the first await. Since we implement simple
422 // async functions in terms of async generators, it is especially
423 // important to get this right, even though it requires care.
424 previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, // Avoid propagating failures to Promises returned by later
425 // invocations of the iterator.
426 callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
427 } // Define the unified helper method that is used to implement .next,
428 // .throw, and .return (see defineIteratorMethods).
429
430
431 this._invoke = enqueue;
432 }
433
434 defineIteratorMethods(AsyncIterator.prototype);
435
436 AsyncIterator.prototype[asyncIteratorSymbol] = function () {
437 return this;
438 };
439
440 exports.AsyncIterator = AsyncIterator; // Note that simple async functions are implemented on top of
441 // AsyncIterator objects; they just return a Promise for the value of
442 // the final result produced by the iterator.
443
444 exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) {
445 if (PromiseImpl === void 0) PromiseImpl = Promise;
446 var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl);
447 return exports.isGeneratorFunction(outerFn) ? iter // If outerFn is a generator, return the full iterator.
448 : iter.next().then(function (result) {
449 return result.done ? result.value : iter.next();
450 });
451 };
452
453 function makeInvokeMethod(innerFn, self, context) {
454 var state = GenStateSuspendedStart;
455 return function invoke(method, arg) {
456 if (state === GenStateExecuting) {
457 throw new Error("Generator is already running");
458 }
459
460 if (state === GenStateCompleted) {
461 if (method === "throw") {
462 throw arg;
463 } // Be forgiving, per 25.3.3.3.3 of the spec:
464 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume
465
466
467 return doneResult();
468 }
469
470 context.method = method;
471 context.arg = arg;
472
473 while (true) {
474 var delegate = context.delegate;
475
476 if (delegate) {
477 var delegateResult = maybeInvokeDelegate(delegate, context);
478
479 if (delegateResult) {
480 if (delegateResult === ContinueSentinel) continue;
481 return delegateResult;
482 }
483 }
484
485 if (context.method === "next") {
486 // Setting context._sent for legacy support of Babel's
487 // function.sent implementation.
488 context.sent = context._sent = context.arg;
489 } else if (context.method === "throw") {
490 if (state === GenStateSuspendedStart) {
491 state = GenStateCompleted;
492 throw context.arg;
493 }
494
495 context.dispatchException(context.arg);
496 } else if (context.method === "return") {
497 context.abrupt("return", context.arg);
498 }
499
500 state = GenStateExecuting;
501 var record = tryCatch(innerFn, self, context);
502
503 if (record.type === "normal") {
504 // If an exception is thrown from innerFn, we leave state ===
505 // GenStateExecuting and loop back for another invocation.
506 state = context.done ? GenStateCompleted : GenStateSuspendedYield;
507
508 if (record.arg === ContinueSentinel) {
509 continue;
510 }
511
512 return {
513 value: record.arg,
514 done: context.done
515 };
516 } else if (record.type === "throw") {
517 state = GenStateCompleted; // Dispatch the exception by looping back around to the
518 // context.dispatchException(context.arg) call above.
519
520 context.method = "throw";
521 context.arg = record.arg;
522 }
523 }
524 };
525 } // Call delegate.iterator[context.method](context.arg) and handle the
526 // result, either by returning a { value, done } result from the
527 // delegate iterator, or by modifying context.method and context.arg,
528 // setting context.delegate to null, and returning the ContinueSentinel.
529
530
531 function maybeInvokeDelegate(delegate, context) {
532 var method = delegate.iterator[context.method];
533
534 if (method === undefined$1) {
535 // A .throw or .return when the delegate iterator has no .throw
536 // method always terminates the yield* loop.
537 context.delegate = null;
538
539 if (context.method === "throw") {
540 // Note: ["return"] must be used for ES3 parsing compatibility.
541 if (delegate.iterator["return"]) {
542 // If the delegate iterator has a return method, give it a
543 // chance to clean up.
544 context.method = "return";
545 context.arg = undefined$1;
546 maybeInvokeDelegate(delegate, context);
547
548 if (context.method === "throw") {
549 // If maybeInvokeDelegate(context) changed context.method from
550 // "return" to "throw", let that override the TypeError below.
551 return ContinueSentinel;
552 }
553 }
554
555 context.method = "throw";
556 context.arg = new TypeError("The iterator does not provide a 'throw' method");
557 }
558
559 return ContinueSentinel;
560 }
561
562 var record = tryCatch(method, delegate.iterator, context.arg);
563
564 if (record.type === "throw") {
565 context.method = "throw";
566 context.arg = record.arg;
567 context.delegate = null;
568 return ContinueSentinel;
569 }
570
571 var info = record.arg;
572
573 if (!info) {
574 context.method = "throw";
575 context.arg = new TypeError("iterator result is not an object");
576 context.delegate = null;
577 return ContinueSentinel;
578 }
579
580 if (info.done) {
581 // Assign the result of the finished delegate to the temporary
582 // variable specified by delegate.resultName (see delegateYield).
583 context[delegate.resultName] = info.value; // Resume execution at the desired location (see delegateYield).
584
585 context.next = delegate.nextLoc; // If context.method was "throw" but the delegate handled the
586 // exception, let the outer generator proceed normally. If
587 // context.method was "next", forget context.arg since it has been
588 // "consumed" by the delegate iterator. If context.method was
589 // "return", allow the original .return call to continue in the
590 // outer generator.
591
592 if (context.method !== "return") {
593 context.method = "next";
594 context.arg = undefined$1;
595 }
596 } else {
597 // Re-yield the result returned by the delegate method.
598 return info;
599 } // The delegate iterator is finished, so forget it and continue with
600 // the outer generator.
601
602
603 context.delegate = null;
604 return ContinueSentinel;
605 } // Define Generator.prototype.{next,throw,return} in terms of the
606 // unified ._invoke helper method.
607
608
609 defineIteratorMethods(Gp);
610 define(Gp, toStringTagSymbol, "Generator"); // A Generator should always return itself as the iterator object when the
611 // @@iterator function is called on it. Some browsers' implementations of the
612 // iterator prototype chain incorrectly implement this, causing the Generator
613 // object to not be returned from this call. This ensures that doesn't happen.
614 // See https://github.com/facebook/regenerator/issues/274 for more details.
615
616 Gp[iteratorSymbol] = function () {
617 return this;
618 };
619
620 Gp.toString = function () {
621 return "[object Generator]";
622 };
623
624 function pushTryEntry(locs) {
625 var entry = {
626 tryLoc: locs[0]
627 };
628
629 if (1 in locs) {
630 entry.catchLoc = locs[1];
631 }
632
633 if (2 in locs) {
634 entry.finallyLoc = locs[2];
635 entry.afterLoc = locs[3];
636 }
637
638 this.tryEntries.push(entry);
639 }
640
641 function resetTryEntry(entry) {
642 var record = entry.completion || {};
643 record.type = "normal";
644 delete record.arg;
645 entry.completion = record;
646 }
647
648 function Context(tryLocsList) {
649 // The root entry object (effectively a try statement without a catch
650 // or a finally block) gives us a place to store values thrown from
651 // locations where there is no enclosing try statement.
652 this.tryEntries = [{
653 tryLoc: "root"
654 }];
655 tryLocsList.forEach(pushTryEntry, this);
656 this.reset(true);
657 }
658
659 exports.keys = function (object) {
660 var keys = [];
661
662 for (var key in object) {
663 keys.push(key);
664 }
665
666 keys.reverse(); // Rather than returning an object with a next method, we keep
667 // things simple and return the next function itself.
668
669 return function next() {
670 while (keys.length) {
671 var key = keys.pop();
672
673 if (key in object) {
674 next.value = key;
675 next.done = false;
676 return next;
677 }
678 } // To avoid creating an additional object, we just hang the .value
679 // and .done properties off the next function object itself. This
680 // also ensures that the minifier will not anonymize the function.
681
682
683 next.done = true;
684 return next;
685 };
686 };
687
688 function values(iterable) {
689 if (iterable) {
690 var iteratorMethod = iterable[iteratorSymbol];
691
692 if (iteratorMethod) {
693 return iteratorMethod.call(iterable);
694 }
695
696 if (typeof iterable.next === "function") {
697 return iterable;
698 }
699
700 if (!isNaN(iterable.length)) {
701 var i = -1,
702 next = function next() {
703 while (++i < iterable.length) {
704 if (hasOwn.call(iterable, i)) {
705 next.value = iterable[i];
706 next.done = false;
707 return next;
708 }
709 }
710
711 next.value = undefined$1;
712 next.done = true;
713 return next;
714 };
715
716 return next.next = next;
717 }
718 } // Return an iterator with no values.
719
720
721 return {
722 next: doneResult
723 };
724 }
725
726 exports.values = values;
727
728 function doneResult() {
729 return {
730 value: undefined$1,
731 done: true
732 };
733 }
734
735 Context.prototype = {
736 constructor: Context,
737 reset: function reset(skipTempReset) {
738 this.prev = 0;
739 this.next = 0; // Resetting context._sent for legacy support of Babel's
740 // function.sent implementation.
741
742 this.sent = this._sent = undefined$1;
743 this.done = false;
744 this.delegate = null;
745 this.method = "next";
746 this.arg = undefined$1;
747 this.tryEntries.forEach(resetTryEntry);
748
749 if (!skipTempReset) {
750 for (var name in this) {
751 // Not sure about the optimal order of these conditions:
752 if (name.charAt(0) === "t" && hasOwn.call(this, name) && !isNaN(+name.slice(1))) {
753 this[name] = undefined$1;
754 }
755 }
756 }
757 },
758 stop: function stop() {
759 this.done = true;
760 var rootEntry = this.tryEntries[0];
761 var rootRecord = rootEntry.completion;
762
763 if (rootRecord.type === "throw") {
764 throw rootRecord.arg;
765 }
766
767 return this.rval;
768 },
769 dispatchException: function dispatchException(exception) {
770 if (this.done) {
771 throw exception;
772 }
773
774 var context = this;
775
776 function handle(loc, caught) {
777 record.type = "throw";
778 record.arg = exception;
779 context.next = loc;
780
781 if (caught) {
782 // If the dispatched exception was caught by a catch block,
783 // then let that catch block handle the exception normally.
784 context.method = "next";
785 context.arg = undefined$1;
786 }
787
788 return !!caught;
789 }
790
791 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
792 var entry = this.tryEntries[i];
793 var record = entry.completion;
794
795 if (entry.tryLoc === "root") {
796 // Exception thrown outside of any try block that could handle
797 // it, so set the completion value of the entire function to
798 // throw the exception.
799 return handle("end");
800 }
801
802 if (entry.tryLoc <= this.prev) {
803 var hasCatch = hasOwn.call(entry, "catchLoc");
804 var hasFinally = hasOwn.call(entry, "finallyLoc");
805
806 if (hasCatch && hasFinally) {
807 if (this.prev < entry.catchLoc) {
808 return handle(entry.catchLoc, true);
809 } else if (this.prev < entry.finallyLoc) {
810 return handle(entry.finallyLoc);
811 }
812 } else if (hasCatch) {
813 if (this.prev < entry.catchLoc) {
814 return handle(entry.catchLoc, true);
815 }
816 } else if (hasFinally) {
817 if (this.prev < entry.finallyLoc) {
818 return handle(entry.finallyLoc);
819 }
820 } else {
821 throw new Error("try statement without catch or finally");
822 }
823 }
824 }
825 },
826 abrupt: function abrupt(type, arg) {
827 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
828 var entry = this.tryEntries[i];
829
830 if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
831 var finallyEntry = entry;
832 break;
833 }
834 }
835
836 if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
837 // Ignore the finally entry if control is not jumping to a
838 // location outside the try/catch block.
839 finallyEntry = null;
840 }
841
842 var record = finallyEntry ? finallyEntry.completion : {};
843 record.type = type;
844 record.arg = arg;
845
846 if (finallyEntry) {
847 this.method = "next";
848 this.next = finallyEntry.finallyLoc;
849 return ContinueSentinel;
850 }
851
852 return this.complete(record);
853 },
854 complete: function complete(record, afterLoc) {
855 if (record.type === "throw") {
856 throw record.arg;
857 }
858
859 if (record.type === "break" || record.type === "continue") {
860 this.next = record.arg;
861 } else if (record.type === "return") {
862 this.rval = this.arg = record.arg;
863 this.method = "return";
864 this.next = "end";
865 } else if (record.type === "normal" && afterLoc) {
866 this.next = afterLoc;
867 }
868
869 return ContinueSentinel;
870 },
871 finish: function finish(finallyLoc) {
872 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
873 var entry = this.tryEntries[i];
874
875 if (entry.finallyLoc === finallyLoc) {
876 this.complete(entry.completion, entry.afterLoc);
877 resetTryEntry(entry);
878 return ContinueSentinel;
879 }
880 }
881 },
882 "catch": function _catch(tryLoc) {
883 for (var i = this.tryEntries.length - 1; i >= 0; --i) {
884 var entry = this.tryEntries[i];
885
886 if (entry.tryLoc === tryLoc) {
887 var record = entry.completion;
888
889 if (record.type === "throw") {
890 var thrown = record.arg;
891 resetTryEntry(entry);
892 }
893
894 return thrown;
895 }
896 } // The context.catch method must only be called with a location
897 // argument that corresponds to a known catch block.
898
899
900 throw new Error("illegal catch attempt");
901 },
902 delegateYield: function delegateYield(iterable, resultName, nextLoc) {
903 this.delegate = {
904 iterator: values(iterable),
905 resultName: resultName,
906 nextLoc: nextLoc
907 };
908
909 if (this.method === "next") {
910 // Deliberately forget the last sent value so that we don't
911 // accidentally pass it on to the delegate.
912 this.arg = undefined$1;
913 }
914
915 return ContinueSentinel;
916 }
917 }; // Regardless of whether this script is executing as a CommonJS module
918 // or not, return the runtime object so that we can declare the variable
919 // regeneratorRuntime in the outer scope, which allows this module to be
920 // injected easily by `bin/regenerator --include-runtime script.js`.
921
922 return exports;
923 }( // If this script is executing as a CommonJS module, use module.exports
924 // as the regeneratorRuntime namespace. Otherwise create a new empty
925 // object. Either way, the resulting object will be used to initialize
926 // the regeneratorRuntime variable at the top of this file.
927 module.exports );
928
929 try {
930 regeneratorRuntime = runtime;
931 } catch (accidentalStrictMode) {
932 // This module should not be running in strict mode, so the above
933 // assignment should always work unless something is misconfigured. Just
934 // in case runtime.js accidentally runs in strict mode, we can escape
935 // strict mode using a global Function call. This could conceivably fail
936 // if a Content Security Policy forbids using Function, but in that case
937 // the proper solution is to fix the accidental strict mode problem. If
938 // you've misconfigured your bundler to force strict mode and applied a
939 // CSP to forbid Function, and you're not willing to fix either of those
940 // problems, please detail your unique predicament in a GitHub issue.
941 Function("r", "regeneratorRuntime = r")(runtime);
942 }
943 });
944
945 /**
946 * lodash (Custom Build) <https://lodash.com/>
947 * Build: `lodash modularize exports="npm" -o ./`
948 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
949 * Released under MIT license <https://lodash.com/license>
950 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
951 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
952 */
953
954 /** Used as the `TypeError` message for "Functions" methods. */
955
956 var FUNC_ERROR_TEXT = 'Expected a function';
957 /** Used to stand-in for `undefined` hash values. */
958
959 var HASH_UNDEFINED = '__lodash_hash_undefined__';
960 /** Used as references for various `Number` constants. */
961
962 var INFINITY = 1 / 0;
963 /** `Object#toString` result references. */
964
965 var funcTag = '[object Function]',
966 genTag = '[object GeneratorFunction]',
967 symbolTag = '[object Symbol]';
968 /** Used to match property names within property paths. */
969
970 var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
971 reIsPlainProp = /^\w*$/,
972 reLeadingDot = /^\./,
973 rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
974 /**
975 * Used to match `RegExp`
976 * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
977 */
978
979 var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
980 /** Used to match backslashes in property paths. */
981
982 var reEscapeChar = /\\(\\)?/g;
983 /** Used to detect host constructors (Safari). */
984
985 var reIsHostCtor = /^\[object .+?Constructor\]$/;
986 /** Detect free variable `global` from Node.js. */
987
988 var freeGlobal = _typeof(commonjsGlobal) == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
989 /** Detect free variable `self`. */
990
991 var freeSelf = (typeof self === "undefined" ? "undefined" : _typeof(self)) == 'object' && self && self.Object === Object && self;
992 /** Used as a reference to the global object. */
993
994 var root = freeGlobal || freeSelf || Function('return this')();
995 /**
996 * Gets the value at `key` of `object`.
997 *
998 * @private
999 * @param {Object} [object] The object to query.
1000 * @param {string} key The key of the property to get.
1001 * @returns {*} Returns the property value.
1002 */
1003
1004 function getValue(object, key) {
1005 return object == null ? undefined : object[key];
1006 }
1007 /**
1008 * Checks if `value` is a host object in IE < 9.
1009 *
1010 * @private
1011 * @param {*} value The value to check.
1012 * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
1013 */
1014
1015
1016 function isHostObject(value) {
1017 // Many host objects are `Object` objects that can coerce to strings
1018 // despite having improperly defined `toString` methods.
1019 var result = false;
1020
1021 if (value != null && typeof value.toString != 'function') {
1022 try {
1023 result = !!(value + '');
1024 } catch (e) {}
1025 }
1026
1027 return result;
1028 }
1029 /** Used for built-in method references. */
1030
1031
1032 var arrayProto = Array.prototype,
1033 funcProto = Function.prototype,
1034 objectProto = Object.prototype;
1035 /** Used to detect overreaching core-js shims. */
1036
1037 var coreJsData = root['__core-js_shared__'];
1038 /** Used to detect methods masquerading as native. */
1039
1040 var maskSrcKey = function () {
1041 var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
1042 return uid ? 'Symbol(src)_1.' + uid : '';
1043 }();
1044 /** Used to resolve the decompiled source of functions. */
1045
1046
1047 var funcToString = funcProto.toString;
1048 /** Used to check objects for own properties. */
1049
1050 var hasOwnProperty = objectProto.hasOwnProperty;
1051 /**
1052 * Used to resolve the
1053 * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
1054 * of values.
1055 */
1056
1057 var objectToString = objectProto.toString;
1058 /** Used to detect if a method is native. */
1059
1060 var reIsNative = RegExp('^' + funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&').replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$');
1061 /** Built-in value references. */
1062
1063 var _Symbol = root.Symbol,
1064 splice = arrayProto.splice;
1065 /* Built-in method references that are verified to be native. */
1066
1067 var Map = getNative(root, 'Map'),
1068 nativeCreate = getNative(Object, 'create');
1069 /** Used to convert symbols to primitives and strings. */
1070
1071 var symbolProto = _Symbol ? _Symbol.prototype : undefined,
1072 symbolToString = symbolProto ? symbolProto.toString : undefined;
1073 /**
1074 * Creates a hash object.
1075 *
1076 * @private
1077 * @constructor
1078 * @param {Array} [entries] The key-value pairs to cache.
1079 */
1080
1081 function Hash(entries) {
1082 var index = -1,
1083 length = entries ? entries.length : 0;
1084 this.clear();
1085
1086 while (++index < length) {
1087 var entry = entries[index];
1088 this.set(entry[0], entry[1]);
1089 }
1090 }
1091 /**
1092 * Removes all key-value entries from the hash.
1093 *
1094 * @private
1095 * @name clear
1096 * @memberOf Hash
1097 */
1098
1099
1100 function hashClear() {
1101 this.__data__ = nativeCreate ? nativeCreate(null) : {};
1102 }
1103 /**
1104 * Removes `key` and its value from the hash.
1105 *
1106 * @private
1107 * @name delete
1108 * @memberOf Hash
1109 * @param {Object} hash The hash to modify.
1110 * @param {string} key The key of the value to remove.
1111 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1112 */
1113
1114
1115 function hashDelete(key) {
1116 return this.has(key) && delete this.__data__[key];
1117 }
1118 /**
1119 * Gets the hash value for `key`.
1120 *
1121 * @private
1122 * @name get
1123 * @memberOf Hash
1124 * @param {string} key The key of the value to get.
1125 * @returns {*} Returns the entry value.
1126 */
1127
1128
1129 function hashGet(key) {
1130 var data = this.__data__;
1131
1132 if (nativeCreate) {
1133 var result = data[key];
1134 return result === HASH_UNDEFINED ? undefined : result;
1135 }
1136
1137 return hasOwnProperty.call(data, key) ? data[key] : undefined;
1138 }
1139 /**
1140 * Checks if a hash value for `key` exists.
1141 *
1142 * @private
1143 * @name has
1144 * @memberOf Hash
1145 * @param {string} key The key of the entry to check.
1146 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1147 */
1148
1149
1150 function hashHas(key) {
1151 var data = this.__data__;
1152 return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
1153 }
1154 /**
1155 * Sets the hash `key` to `value`.
1156 *
1157 * @private
1158 * @name set
1159 * @memberOf Hash
1160 * @param {string} key The key of the value to set.
1161 * @param {*} value The value to set.
1162 * @returns {Object} Returns the hash instance.
1163 */
1164
1165
1166 function hashSet(key, value) {
1167 var data = this.__data__;
1168 data[key] = nativeCreate && value === undefined ? HASH_UNDEFINED : value;
1169 return this;
1170 } // Add methods to `Hash`.
1171
1172
1173 Hash.prototype.clear = hashClear;
1174 Hash.prototype['delete'] = hashDelete;
1175 Hash.prototype.get = hashGet;
1176 Hash.prototype.has = hashHas;
1177 Hash.prototype.set = hashSet;
1178 /**
1179 * Creates an list cache object.
1180 *
1181 * @private
1182 * @constructor
1183 * @param {Array} [entries] The key-value pairs to cache.
1184 */
1185
1186 function ListCache(entries) {
1187 var index = -1,
1188 length = entries ? entries.length : 0;
1189 this.clear();
1190
1191 while (++index < length) {
1192 var entry = entries[index];
1193 this.set(entry[0], entry[1]);
1194 }
1195 }
1196 /**
1197 * Removes all key-value entries from the list cache.
1198 *
1199 * @private
1200 * @name clear
1201 * @memberOf ListCache
1202 */
1203
1204
1205 function listCacheClear() {
1206 this.__data__ = [];
1207 }
1208 /**
1209 * Removes `key` and its value from the list cache.
1210 *
1211 * @private
1212 * @name delete
1213 * @memberOf ListCache
1214 * @param {string} key The key of the value to remove.
1215 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1216 */
1217
1218
1219 function listCacheDelete(key) {
1220 var data = this.__data__,
1221 index = assocIndexOf(data, key);
1222
1223 if (index < 0) {
1224 return false;
1225 }
1226
1227 var lastIndex = data.length - 1;
1228
1229 if (index == lastIndex) {
1230 data.pop();
1231 } else {
1232 splice.call(data, index, 1);
1233 }
1234
1235 return true;
1236 }
1237 /**
1238 * Gets the list cache value for `key`.
1239 *
1240 * @private
1241 * @name get
1242 * @memberOf ListCache
1243 * @param {string} key The key of the value to get.
1244 * @returns {*} Returns the entry value.
1245 */
1246
1247
1248 function listCacheGet(key) {
1249 var data = this.__data__,
1250 index = assocIndexOf(data, key);
1251 return index < 0 ? undefined : data[index][1];
1252 }
1253 /**
1254 * Checks if a list cache value for `key` exists.
1255 *
1256 * @private
1257 * @name has
1258 * @memberOf ListCache
1259 * @param {string} key The key of the entry to check.
1260 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1261 */
1262
1263
1264 function listCacheHas(key) {
1265 return assocIndexOf(this.__data__, key) > -1;
1266 }
1267 /**
1268 * Sets the list cache `key` to `value`.
1269 *
1270 * @private
1271 * @name set
1272 * @memberOf ListCache
1273 * @param {string} key The key of the value to set.
1274 * @param {*} value The value to set.
1275 * @returns {Object} Returns the list cache instance.
1276 */
1277
1278
1279 function listCacheSet(key, value) {
1280 var data = this.__data__,
1281 index = assocIndexOf(data, key);
1282
1283 if (index < 0) {
1284 data.push([key, value]);
1285 } else {
1286 data[index][1] = value;
1287 }
1288
1289 return this;
1290 } // Add methods to `ListCache`.
1291
1292
1293 ListCache.prototype.clear = listCacheClear;
1294 ListCache.prototype['delete'] = listCacheDelete;
1295 ListCache.prototype.get = listCacheGet;
1296 ListCache.prototype.has = listCacheHas;
1297 ListCache.prototype.set = listCacheSet;
1298 /**
1299 * Creates a map cache object to store key-value pairs.
1300 *
1301 * @private
1302 * @constructor
1303 * @param {Array} [entries] The key-value pairs to cache.
1304 */
1305
1306 function MapCache(entries) {
1307 var index = -1,
1308 length = entries ? entries.length : 0;
1309 this.clear();
1310
1311 while (++index < length) {
1312 var entry = entries[index];
1313 this.set(entry[0], entry[1]);
1314 }
1315 }
1316 /**
1317 * Removes all key-value entries from the map.
1318 *
1319 * @private
1320 * @name clear
1321 * @memberOf MapCache
1322 */
1323
1324
1325 function mapCacheClear() {
1326 this.__data__ = {
1327 'hash': new Hash(),
1328 'map': new (Map || ListCache)(),
1329 'string': new Hash()
1330 };
1331 }
1332 /**
1333 * Removes `key` and its value from the map.
1334 *
1335 * @private
1336 * @name delete
1337 * @memberOf MapCache
1338 * @param {string} key The key of the value to remove.
1339 * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1340 */
1341
1342
1343 function mapCacheDelete(key) {
1344 return getMapData(this, key)['delete'](key);
1345 }
1346 /**
1347 * Gets the map value for `key`.
1348 *
1349 * @private
1350 * @name get
1351 * @memberOf MapCache
1352 * @param {string} key The key of the value to get.
1353 * @returns {*} Returns the entry value.
1354 */
1355
1356
1357 function mapCacheGet(key) {
1358 return getMapData(this, key).get(key);
1359 }
1360 /**
1361 * Checks if a map value for `key` exists.
1362 *
1363 * @private
1364 * @name has
1365 * @memberOf MapCache
1366 * @param {string} key The key of the entry to check.
1367 * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1368 */
1369
1370
1371 function mapCacheHas(key) {
1372 return getMapData(this, key).has(key);
1373 }
1374 /**
1375 * Sets the map `key` to `value`.
1376 *
1377 * @private
1378 * @name set
1379 * @memberOf MapCache
1380 * @param {string} key The key of the value to set.
1381 * @param {*} value The value to set.
1382 * @returns {Object} Returns the map cache instance.
1383 */
1384
1385
1386 function mapCacheSet(key, value) {
1387 getMapData(this, key).set(key, value);
1388 return this;
1389 } // Add methods to `MapCache`.
1390
1391
1392 MapCache.prototype.clear = mapCacheClear;
1393 MapCache.prototype['delete'] = mapCacheDelete;
1394 MapCache.prototype.get = mapCacheGet;
1395 MapCache.prototype.has = mapCacheHas;
1396 MapCache.prototype.set = mapCacheSet;
1397 /**
1398 * Gets the index at which the `key` is found in `array` of key-value pairs.
1399 *
1400 * @private
1401 * @param {Array} array The array to inspect.
1402 * @param {*} key The key to search for.
1403 * @returns {number} Returns the index of the matched value, else `-1`.
1404 */
1405
1406 function assocIndexOf(array, key) {
1407 var length = array.length;
1408
1409 while (length--) {
1410 if (eq(array[length][0], key)) {
1411 return length;
1412 }
1413 }
1414
1415 return -1;
1416 }
1417 /**
1418 * The base implementation of `_.get` without support for default values.
1419 *
1420 * @private
1421 * @param {Object} object The object to query.
1422 * @param {Array|string} path The path of the property to get.
1423 * @returns {*} Returns the resolved value.
1424 */
1425
1426
1427 function baseGet(object, path) {
1428 path = isKey(path, object) ? [path] : castPath(path);
1429 var index = 0,
1430 length = path.length;
1431
1432 while (object != null && index < length) {
1433 object = object[toKey(path[index++])];
1434 }
1435
1436 return index && index == length ? object : undefined;
1437 }
1438 /**
1439 * The base implementation of `_.isNative` without bad shim checks.
1440 *
1441 * @private
1442 * @param {*} value The value to check.
1443 * @returns {boolean} Returns `true` if `value` is a native function,
1444 * else `false`.
1445 */
1446
1447
1448 function baseIsNative(value) {
1449 if (!isObject(value) || isMasked(value)) {
1450 return false;
1451 }
1452
1453 var pattern = isFunction(value) || isHostObject(value) ? reIsNative : reIsHostCtor;
1454 return pattern.test(toSource(value));
1455 }
1456 /**
1457 * The base implementation of `_.toString` which doesn't convert nullish
1458 * values to empty strings.
1459 *
1460 * @private
1461 * @param {*} value The value to process.
1462 * @returns {string} Returns the string.
1463 */
1464
1465
1466 function baseToString(value) {
1467 // Exit early for strings to avoid a performance hit in some environments.
1468 if (typeof value == 'string') {
1469 return value;
1470 }
1471
1472 if (isSymbol(value)) {
1473 return symbolToString ? symbolToString.call(value) : '';
1474 }
1475
1476 var result = value + '';
1477 return result == '0' && 1 / value == -INFINITY ? '-0' : result;
1478 }
1479 /**
1480 * Casts `value` to a path array if it's not one.
1481 *
1482 * @private
1483 * @param {*} value The value to inspect.
1484 * @returns {Array} Returns the cast property path array.
1485 */
1486
1487
1488 function castPath(value) {
1489 return isArray(value) ? value : stringToPath(value);
1490 }
1491 /**
1492 * Gets the data for `map`.
1493 *
1494 * @private
1495 * @param {Object} map The map to query.
1496 * @param {string} key The reference key.
1497 * @returns {*} Returns the map data.
1498 */
1499
1500
1501 function getMapData(map, key) {
1502 var data = map.__data__;
1503 return isKeyable(key) ? data[typeof key == 'string' ? 'string' : 'hash'] : data.map;
1504 }
1505 /**
1506 * Gets the native function at `key` of `object`.
1507 *
1508 * @private
1509 * @param {Object} object The object to query.
1510 * @param {string} key The key of the method to get.
1511 * @returns {*} Returns the function if it's native, else `undefined`.
1512 */
1513
1514
1515 function getNative(object, key) {
1516 var value = getValue(object, key);
1517 return baseIsNative(value) ? value : undefined;
1518 }
1519 /**
1520 * Checks if `value` is a property name and not a property path.
1521 *
1522 * @private
1523 * @param {*} value The value to check.
1524 * @param {Object} [object] The object to query keys on.
1525 * @returns {boolean} Returns `true` if `value` is a property name, else `false`.
1526 */
1527
1528
1529 function isKey(value, object) {
1530 if (isArray(value)) {
1531 return false;
1532 }
1533
1534 var type = _typeof(value);
1535
1536 if (type == 'number' || type == 'symbol' || type == 'boolean' || value == null || isSymbol(value)) {
1537 return true;
1538 }
1539
1540 return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object(object);
1541 }
1542 /**
1543 * Checks if `value` is suitable for use as unique object key.
1544 *
1545 * @private
1546 * @param {*} value The value to check.
1547 * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1548 */
1549
1550
1551 function isKeyable(value) {
1552 var type = _typeof(value);
1553
1554 return type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean' ? value !== '__proto__' : value === null;
1555 }
1556 /**
1557 * Checks if `func` has its source masked.
1558 *
1559 * @private
1560 * @param {Function} func The function to check.
1561 * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1562 */
1563
1564
1565 function isMasked(func) {
1566 return !!maskSrcKey && maskSrcKey in func;
1567 }
1568 /**
1569 * Converts `string` to a property path array.
1570 *
1571 * @private
1572 * @param {string} string The string to convert.
1573 * @returns {Array} Returns the property path array.
1574 */
1575
1576
1577 var stringToPath = memoize(function (string) {
1578 string = toString(string);
1579 var result = [];
1580
1581 if (reLeadingDot.test(string)) {
1582 result.push('');
1583 }
1584
1585 string.replace(rePropName, function (match, number, quote, string) {
1586 result.push(quote ? string.replace(reEscapeChar, '$1') : number || match);
1587 });
1588 return result;
1589 });
1590 /**
1591 * Converts `value` to a string key if it's not a string or symbol.
1592 *
1593 * @private
1594 * @param {*} value The value to inspect.
1595 * @returns {string|symbol} Returns the key.
1596 */
1597
1598 function toKey(value) {
1599 if (typeof value == 'string' || isSymbol(value)) {
1600 return value;
1601 }
1602
1603 var result = value + '';
1604 return result == '0' && 1 / value == -INFINITY ? '-0' : result;
1605 }
1606 /**
1607 * Converts `func` to its source code.
1608 *
1609 * @private
1610 * @param {Function} func The function to process.
1611 * @returns {string} Returns the source code.
1612 */
1613
1614
1615 function toSource(func) {
1616 if (func != null) {
1617 try {
1618 return funcToString.call(func);
1619 } catch (e) {}
1620
1621 try {
1622 return func + '';
1623 } catch (e) {}
1624 }
1625
1626 return '';
1627 }
1628 /**
1629 * Creates a function that memoizes the result of `func`. If `resolver` is
1630 * provided, it determines the cache key for storing the result based on the
1631 * arguments provided to the memoized function. By default, the first argument
1632 * provided to the memoized function is used as the map cache key. The `func`
1633 * is invoked with the `this` binding of the memoized function.
1634 *
1635 * **Note:** The cache is exposed as the `cache` property on the memoized
1636 * function. Its creation may be customized by replacing the `_.memoize.Cache`
1637 * constructor with one whose instances implement the
1638 * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
1639 * method interface of `delete`, `get`, `has`, and `set`.
1640 *
1641 * @static
1642 * @memberOf _
1643 * @since 0.1.0
1644 * @category Function
1645 * @param {Function} func The function to have its output memoized.
1646 * @param {Function} [resolver] The function to resolve the cache key.
1647 * @returns {Function} Returns the new memoized function.
1648 * @example
1649 *
1650 * var object = { 'a': 1, 'b': 2 };
1651 * var other = { 'c': 3, 'd': 4 };
1652 *
1653 * var values = _.memoize(_.values);
1654 * values(object);
1655 * // => [1, 2]
1656 *
1657 * values(other);
1658 * // => [3, 4]
1659 *
1660 * object.a = 2;
1661 * values(object);
1662 * // => [1, 2]
1663 *
1664 * // Modify the result cache.
1665 * values.cache.set(object, ['a', 'b']);
1666 * values(object);
1667 * // => ['a', 'b']
1668 *
1669 * // Replace `_.memoize.Cache`.
1670 * _.memoize.Cache = WeakMap;
1671 */
1672
1673
1674 function memoize(func, resolver) {
1675 if (typeof func != 'function' || resolver && typeof resolver != 'function') {
1676 throw new TypeError(FUNC_ERROR_TEXT);
1677 }
1678
1679 var memoized = function memoized() {
1680 var args = arguments,
1681 key = resolver ? resolver.apply(this, args) : args[0],
1682 cache = memoized.cache;
1683
1684 if (cache.has(key)) {
1685 return cache.get(key);
1686 }
1687
1688 var result = func.apply(this, args);
1689 memoized.cache = cache.set(key, result);
1690 return result;
1691 };
1692
1693 memoized.cache = new (memoize.Cache || MapCache)();
1694 return memoized;
1695 } // Assign cache to `_.memoize`.
1696
1697
1698 memoize.Cache = MapCache;
1699 /**
1700 * Performs a
1701 * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1702 * comparison between two values to determine if they are equivalent.
1703 *
1704 * @static
1705 * @memberOf _
1706 * @since 4.0.0
1707 * @category Lang
1708 * @param {*} value The value to compare.
1709 * @param {*} other The other value to compare.
1710 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1711 * @example
1712 *
1713 * var object = { 'a': 1 };
1714 * var other = { 'a': 1 };
1715 *
1716 * _.eq(object, object);
1717 * // => true
1718 *
1719 * _.eq(object, other);
1720 * // => false
1721 *
1722 * _.eq('a', 'a');
1723 * // => true
1724 *
1725 * _.eq('a', Object('a'));
1726 * // => false
1727 *
1728 * _.eq(NaN, NaN);
1729 * // => true
1730 */
1731
1732 function eq(value, other) {
1733 return value === other || value !== value && other !== other;
1734 }
1735 /**
1736 * Checks if `value` is classified as an `Array` object.
1737 *
1738 * @static
1739 * @memberOf _
1740 * @since 0.1.0
1741 * @category Lang
1742 * @param {*} value The value to check.
1743 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1744 * @example
1745 *
1746 * _.isArray([1, 2, 3]);
1747 * // => true
1748 *
1749 * _.isArray(document.body.children);
1750 * // => false
1751 *
1752 * _.isArray('abc');
1753 * // => false
1754 *
1755 * _.isArray(_.noop);
1756 * // => false
1757 */
1758
1759
1760 var isArray = Array.isArray;
1761 /**
1762 * Checks if `value` is classified as a `Function` object.
1763 *
1764 * @static
1765 * @memberOf _
1766 * @since 0.1.0
1767 * @category Lang
1768 * @param {*} value The value to check.
1769 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1770 * @example
1771 *
1772 * _.isFunction(_);
1773 * // => true
1774 *
1775 * _.isFunction(/abc/);
1776 * // => false
1777 */
1778
1779 function isFunction(value) {
1780 // The use of `Object#toString` avoids issues with the `typeof` operator
1781 // in Safari 8-9 which returns 'object' for typed array and other constructors.
1782 var tag = isObject(value) ? objectToString.call(value) : '';
1783 return tag == funcTag || tag == genTag;
1784 }
1785 /**
1786 * Checks if `value` is the
1787 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1788 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1789 *
1790 * @static
1791 * @memberOf _
1792 * @since 0.1.0
1793 * @category Lang
1794 * @param {*} value The value to check.
1795 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1796 * @example
1797 *
1798 * _.isObject({});
1799 * // => true
1800 *
1801 * _.isObject([1, 2, 3]);
1802 * // => true
1803 *
1804 * _.isObject(_.noop);
1805 * // => true
1806 *
1807 * _.isObject(null);
1808 * // => false
1809 */
1810
1811
1812 function isObject(value) {
1813 var type = _typeof(value);
1814
1815 return !!value && (type == 'object' || type == 'function');
1816 }
1817 /**
1818 * Checks if `value` is object-like. A value is object-like if it's not `null`
1819 * and has a `typeof` result of "object".
1820 *
1821 * @static
1822 * @memberOf _
1823 * @since 4.0.0
1824 * @category Lang
1825 * @param {*} value The value to check.
1826 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1827 * @example
1828 *
1829 * _.isObjectLike({});
1830 * // => true
1831 *
1832 * _.isObjectLike([1, 2, 3]);
1833 * // => true
1834 *
1835 * _.isObjectLike(_.noop);
1836 * // => false
1837 *
1838 * _.isObjectLike(null);
1839 * // => false
1840 */
1841
1842
1843 function isObjectLike(value) {
1844 return !!value && _typeof(value) == 'object';
1845 }
1846 /**
1847 * Checks if `value` is classified as a `Symbol` primitive or object.
1848 *
1849 * @static
1850 * @memberOf _
1851 * @since 4.0.0
1852 * @category Lang
1853 * @param {*} value The value to check.
1854 * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
1855 * @example
1856 *
1857 * _.isSymbol(Symbol.iterator);
1858 * // => true
1859 *
1860 * _.isSymbol('abc');
1861 * // => false
1862 */
1863
1864
1865 function isSymbol(value) {
1866 return _typeof(value) == 'symbol' || isObjectLike(value) && objectToString.call(value) == symbolTag;
1867 }
1868 /**
1869 * Converts `value` to a string. An empty string is returned for `null`
1870 * and `undefined` values. The sign of `-0` is preserved.
1871 *
1872 * @static
1873 * @memberOf _
1874 * @since 4.0.0
1875 * @category Lang
1876 * @param {*} value The value to process.
1877 * @returns {string} Returns the string.
1878 * @example
1879 *
1880 * _.toString(null);
1881 * // => ''
1882 *
1883 * _.toString(-0);
1884 * // => '-0'
1885 *
1886 * _.toString([1, 2, 3]);
1887 * // => '1,2,3'
1888 */
1889
1890
1891 function toString(value) {
1892 return value == null ? '' : baseToString(value);
1893 }
1894 /**
1895 * Gets the value at `path` of `object`. If the resolved value is
1896 * `undefined`, the `defaultValue` is returned in its place.
1897 *
1898 * @static
1899 * @memberOf _
1900 * @since 3.7.0
1901 * @category Object
1902 * @param {Object} object The object to query.
1903 * @param {Array|string} path The path of the property to get.
1904 * @param {*} [defaultValue] The value returned for `undefined` resolved values.
1905 * @returns {*} Returns the resolved value.
1906 * @example
1907 *
1908 * var object = { 'a': [{ 'b': { 'c': 3 } }] };
1909 *
1910 * _.get(object, 'a[0].b.c');
1911 * // => 3
1912 *
1913 * _.get(object, ['a', '0', 'b', 'c']);
1914 * // => 3
1915 *
1916 * _.get(object, 'a.b.c', 'default');
1917 * // => 'default'
1918 */
1919
1920
1921 function get(object, path, defaultValue) {
1922 var result = object == null ? undefined : baseGet(object, path);
1923 return result === undefined ? defaultValue : result;
1924 }
1925
1926 var lodash_get = get;
1927
1928 var formDataFactory = {
1929 createFormData: function createFormData() {
1930 {
1931 return new FormData();
1932 }
1933 }
1934 };
1935
1936 function getInstance(baseURL) {
1937 var instance = axios__default['default'].create({
1938 baseURL: baseURL
1939 });
1940 instance.interceptors.response.use(function (response) {
1941 var otcsticket = lodash_get(response, 'headers.otcsticket');
1942
1943 if (otcsticket) {
1944 instance.defaults.headers.common['OTCSTicket'] = otcsticket;
1945 }
1946
1947 return response;
1948 }, function (error) {
1949 return Promise.reject(error);
1950 });
1951 return instance;
1952 }
1953
1954 function axiosFactory(options) {
1955 var instance = getInstance(options.baseURL);
1956 var username = lodash_get(options, 'username');
1957 var password = lodash_get(options, 'password');
1958 var otcsticket = lodash_get(options, 'otcsticket');
1959
1960 if (otcsticket) {
1961 instance.defaults.headers.common['OTCSTicket'] = otcsticket;
1962 } else if (username && password) {
1963 instance.interceptors.request.use( /*#__PURE__*/function () {
1964 var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(request) {
1965 var formData, response;
1966 return regeneratorRuntime.wrap(function _callee$(_context) {
1967 while (1) {
1968 switch (_context.prev = _context.next) {
1969 case 0:
1970 if (!request.headers.common['OTCSTicket']) {
1971 _context.next = 4;
1972 break;
1973 }
1974
1975 return _context.abrupt("return", request);
1976
1977 case 4:
1978 formData = formDataFactory.createFormData();
1979 formData.append('username', username);
1980 formData.append('password', password);
1981
1982 {
1983 _context.next = 13;
1984 break;
1985 }
1986
1987 case 10:
1988 _context.t0 = _context.sent;
1989 _context.next = 16;
1990 break;
1991
1992 case 13:
1993 _context.next = 15;
1994 return axios__default['default'].post("".concat(options.baseURL, "/api/v1/auth/"), formData);
1995
1996 case 15:
1997 _context.t0 = _context.sent;
1998
1999 case 16:
2000 response = _context.t0;
2001 request.headers.common['OTCSTicket'] = lodash_get(response, 'data.ticket');
2002 return _context.abrupt("return", request);
2003
2004 case 19:
2005 case "end":
2006 return _context.stop();
2007 }
2008 }
2009 }, _callee);
2010 }));
2011
2012 return function (_x) {
2013 return _ref.apply(this, arguments);
2014 };
2015 }());
2016 } else {
2017 throw 'You must provide an otcsticket or username and password.';
2018 }
2019
2020 return instance;
2021 }
2022
2023 var auth = axiosFactory;
2024
2025 var SubTypes = {
2026 FOLDER: 0,
2027 DOCUMENT: 144
2028 };
2029
2030 var nodes = function nodes(session) {
2031 return {
2032 addablenodetypes: function addablenodetypes(dataid) {
2033 return session.get("api/v1/nodes/".concat(dataid, "/addablenodetypes"));
2034 },
2035 addDocument: function addDocument(parent_id, fileHandler) {
2036 var _arguments = arguments;
2037 return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
2038 var fileName, url, formData, path, f, name, _name;
2039
2040 return regeneratorRuntime.wrap(function _callee$(_context) {
2041 while (1) {
2042 switch (_context.prev = _context.next) {
2043 case 0:
2044 fileName = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : null;
2045 url = 'api/v1/nodes';
2046 formData = formDataFactory.createFormData();
2047 formData.append('type', SubTypes.DOCUMENT);
2048 formData.append('parent_id', parent_id);
2049
2050 {
2051 _context.next = 17;
2052 break;
2053 }
2054
2055 case 10:
2056 f = _context.sent;
2057 name = fileName || path.basename(fileHandler);
2058 formData.append('file', f, name);
2059 formData.append('name', name);
2060 return _context.abrupt("return", session.post(url, formData.getBuffer(), {
2061 headers: formData.getHeaders()
2062 }));
2063
2064 case 17:
2065 // browser
2066 _name = fileName || fileHandler.name;
2067 formData.append('file', fileHandler, _name);
2068 formData.append('name', _name);
2069 return _context.abrupt("return", session.post(url, formData));
2070
2071 case 21:
2072 case "end":
2073 return _context.stop();
2074 }
2075 }
2076 }, _callee);
2077 }))();
2078 },
2079 addItem: function addItem(type, parent_id, name) {
2080 var params = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2081 return session.postForm('api/v2/nodes', _objectSpread2({
2082 type: type,
2083 parent_id: parent_id,
2084 name: name
2085 }, params));
2086 },
2087 node: function node(dataid) {
2088 var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2089 return session.getCached("api/v2/nodes/".concat(dataid), {
2090 params: params
2091 });
2092 },
2093 ancestors: function ancestors(dataid) {
2094 var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2095 return session.get("api/v1/nodes/".concat(dataid, "/ancestors"), {
2096 params: params
2097 });
2098 },
2099 volumeInfo: function volumeInfo(objType) {
2100 return session.get("api/v1/volumes/".concat(objType));
2101 },
2102 volumes: function volumes() {
2103 return session.get('api/v2/volumes');
2104 },
2105 addFolder: function addFolder(parent_id, name) {
2106 var params = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
2107 return this.addItem(SubTypes.FOLDER, parent_id, name, params);
2108 },
2109 children: function children(dataid) {
2110 var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2111 // https://developer.opentext.com/webaccess/#url=%2Fawd%2Fresources%2Fapis%2Fcs-rest-api-for-cs-16-s%23!%2Fnodes%2FgetSubnodes_get_15&tab=501
2112 return session.get("api/v2/nodes/".concat(dataid, "/nodes"), {
2113 params: params
2114 });
2115 },
2116 "delete": function _delete(dataid) {
2117 return session["delete"]("api/v1/nodes/".concat(dataid));
2118 },
2119 download: function download(dataid) {
2120
2121 // session.nodes.download(1267501, 'v2', '/Users/chris/Downloads/test.pdf')
2122 {
2123 return Promise.reject('Not implemented yet');
2124 }
2125 }
2126 };
2127 };
2128
2129 var workflow = function workflow(session) {
2130 return {
2131 start: function start(map_id) {
2132 var _this = this;
2133
2134 return this.draftprocesses(map_id).then(function (response) {
2135 return lodash_get(response, 'data.results.draftprocess_id');
2136 }).then(function (draftprocess_id) {
2137 return _this.draftprocesses_update(draftprocess_id);
2138 });
2139 },
2140 draftprocesses: function draftprocesses(workflow_id) {
2141 return session.postForm('api/v2/draftprocesses', {
2142 workflow_id: workflow_id
2143 });
2144 },
2145 draftprocesses_update: function draftprocesses_update(draftprocess_id) {
2146 return session.get('api/v1/forms/draftprocesses/update', {
2147 params: {
2148 draftprocess_id: draftprocess_id
2149 }
2150 });
2151 },
2152 draftprocesses_put: function draftprocesses_put(draftprocess_id, body) {
2153 return session.putForm("api/v2/draftprocesses/".concat(draftprocess_id), {
2154 body: body
2155 });
2156 } // draftprocesses_formUpdate(draftprocess_id, values) {
2157 // const body = {
2158 // action: "formUpdate",
2159 // values
2160 // }
2161 // return this.draftprocesses_put(draftprocess_id, body)
2162 // }
2163
2164 };
2165 };
2166
2167 var rhcore = function rhcore(session) {
2168 return {
2169 scriptNode: function scriptNode(id) {
2170 var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2171 return session.get("api/v1/rhcore/".concat(id), {
2172 params: params
2173 });
2174 }
2175 };
2176 };
2177
2178 var members = function members(session) {
2179 return {
2180 USER: 0,
2181 GROUP: 1,
2182 userQuery: function userQuery(query) {
2183 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2184 var version = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'v2';
2185
2186 var params = _objectSpread2({
2187 limit: 20,
2188 where_type: JSON.stringify([this.USER, this.GROUP]),
2189 query: query
2190 }, options);
2191
2192 return session.get("api/".concat(version, "/members"), {
2193 params: params
2194 });
2195 },
2196 member: function member(id) {
2197 var version = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'v2';
2198 return session.getCached("api/".concat(version, "/members/").concat(id));
2199 }
2200 };
2201 };
2202
2203 var versions = function versions(session) {
2204 return {
2205 addVersion: function addVersion(dataid, fileHandler) {
2206 var _arguments = arguments;
2207 return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
2208 var options, url, path, f, params, _params;
2209
2210 return regeneratorRuntime.wrap(function _callee$(_context) {
2211 while (1) {
2212 switch (_context.prev = _context.next) {
2213 case 0:
2214 options = _arguments.length > 2 && _arguments[2] !== undefined ? _arguments[2] : {};
2215 url = "api/v1/nodes/".concat(dataid, "/versions"); // const formData = FormDataFactory.createFormData()
2216
2217 {
2218 _context.next = 12;
2219 break;
2220 }
2221
2222 case 7:
2223 f = _context.sent;
2224 // let name = fileName || path.basename(fileHandler)
2225 params = _objectSpread2({
2226 file: {
2227 file: f,
2228 name: path.basename(fileHandler)
2229 }
2230 }, options); // console.log(params)
2231
2232 return _context.abrupt("return", session.postForm(url, params));
2233
2234 case 12:
2235 // browser
2236 // let name = fileName || fileHandler.name
2237 _params = _objectSpread2({
2238 file: {
2239 file: fileHandler,
2240 name: fileHandler.name
2241 }
2242 }, options);
2243 return _context.abrupt("return", session.postForm(url, _params));
2244
2245 case 14:
2246 case "end":
2247 return _context.stop();
2248 }
2249 }
2250 }, _callee);
2251 }))();
2252 },
2253 list: function list(dataid) {
2254 return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
2255 var url;
2256 return regeneratorRuntime.wrap(function _callee2$(_context2) {
2257 while (1) {
2258 switch (_context2.prev = _context2.next) {
2259 case 0:
2260 url = "api/v1/nodes/".concat(dataid, "/versions");
2261 return _context2.abrupt("return", session.get(url));
2262
2263 case 2:
2264 case "end":
2265 return _context2.stop();
2266 }
2267 }
2268 }, _callee2);
2269 }))();
2270 },
2271 version: function version(dataid) {
2272 var _arguments2 = arguments;
2273 return _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
2274 var version_number, url;
2275 return regeneratorRuntime.wrap(function _callee3$(_context3) {
2276 while (1) {
2277 switch (_context3.prev = _context3.next) {
2278 case 0:
2279 version_number = _arguments2.length > 1 && _arguments2[1] !== undefined ? _arguments2[1] : 'latest';
2280 // latest not supported in v2
2281 url = "api/v1/nodes/".concat(dataid, "/versions/").concat(version_number);
2282 return _context3.abrupt("return", session.get(url));
2283
2284 case 3:
2285 case "end":
2286 return _context3.stop();
2287 }
2288 }
2289 }, _callee3);
2290 }))();
2291 }
2292 };
2293 };
2294
2295 var webreports = function webreports(session) {
2296 return {
2297 run: function run(dataid) {
2298 var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2299 var url = "api/v1/nodes/".concat(dataid, "/output");
2300 return session.get(url, {
2301 params: params
2302 });
2303 }
2304 };
2305 };
2306
2307 /**
2308 * lodash 4.0.0 (Custom Build) <https://lodash.com/>
2309 * Build: `lodash modularize exports="npm" -o ./`
2310 * Copyright 2012-2016 The Dojo Foundation <http://dojofoundation.org/>
2311 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
2312 * Copyright 2009-2016 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
2313 * Available under MIT license <https://lodash.com/license>
2314 */
2315
2316 /**
2317 * Checks if `value` is `null` or `undefined`.
2318 *
2319 * @static
2320 * @memberOf _
2321 * @category Lang
2322 * @param {*} value The value to check.
2323 * @returns {boolean} Returns `true` if `value` is nullish, else `false`.
2324 * @example
2325 *
2326 * _.isNil(null);
2327 * // => true
2328 *
2329 * _.isNil(void 0);
2330 * // => true
2331 *
2332 * _.isNil(NaN);
2333 * // => false
2334 */
2335 function isNil(value) {
2336 return value == null;
2337 }
2338
2339 var lodash_isnil = isNil;
2340
2341 var crypt = createCommonjsModule(function (module) {
2342 (function () {
2343 var base64map = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
2344 crypt = {
2345 // Bit-wise rotation left
2346 rotl: function rotl(n, b) {
2347 return n << b | n >>> 32 - b;
2348 },
2349 // Bit-wise rotation right
2350 rotr: function rotr(n, b) {
2351 return n << 32 - b | n >>> b;
2352 },
2353 // Swap big-endian to little-endian and vice versa
2354 endian: function endian(n) {
2355 // If number given, swap endian
2356 if (n.constructor == Number) {
2357 return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;
2358 } // Else, assume array and swap all items
2359
2360
2361 for (var i = 0; i < n.length; i++) {
2362 n[i] = crypt.endian(n[i]);
2363 }
2364
2365 return n;
2366 },
2367 // Generate an array of any length of random bytes
2368 randomBytes: function randomBytes(n) {
2369 for (var bytes = []; n > 0; n--) {
2370 bytes.push(Math.floor(Math.random() * 256));
2371 }
2372
2373 return bytes;
2374 },
2375 // Convert a byte array to big-endian 32-bit words
2376 bytesToWords: function bytesToWords(bytes) {
2377 for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8) {
2378 words[b >>> 5] |= bytes[i] << 24 - b % 32;
2379 }
2380
2381 return words;
2382 },
2383 // Convert big-endian 32-bit words to a byte array
2384 wordsToBytes: function wordsToBytes(words) {
2385 for (var bytes = [], b = 0; b < words.length * 32; b += 8) {
2386 bytes.push(words[b >>> 5] >>> 24 - b % 32 & 0xFF);
2387 }
2388
2389 return bytes;
2390 },
2391 // Convert a byte array to a hex string
2392 bytesToHex: function bytesToHex(bytes) {
2393 for (var hex = [], i = 0; i < bytes.length; i++) {
2394 hex.push((bytes[i] >>> 4).toString(16));
2395 hex.push((bytes[i] & 0xF).toString(16));
2396 }
2397
2398 return hex.join('');
2399 },
2400 // Convert a hex string to a byte array
2401 hexToBytes: function hexToBytes(hex) {
2402 for (var bytes = [], c = 0; c < hex.length; c += 2) {
2403 bytes.push(parseInt(hex.substr(c, 2), 16));
2404 }
2405
2406 return bytes;
2407 },
2408 // Convert a byte array to a base-64 string
2409 bytesToBase64: function bytesToBase64(bytes) {
2410 for (var base64 = [], i = 0; i < bytes.length; i += 3) {
2411 var triplet = bytes[i] << 16 | bytes[i + 1] << 8 | bytes[i + 2];
2412
2413 for (var j = 0; j < 4; j++) {
2414 if (i * 8 + j * 6 <= bytes.length * 8) base64.push(base64map.charAt(triplet >>> 6 * (3 - j) & 0x3F));else base64.push('=');
2415 }
2416 }
2417
2418 return base64.join('');
2419 },
2420 // Convert a base-64 string to a byte array
2421 base64ToBytes: function base64ToBytes(base64) {
2422 // Remove non-base-64 characters
2423 base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
2424
2425 for (var bytes = [], i = 0, imod4 = 0; i < base64.length; imod4 = ++i % 4) {
2426 if (imod4 == 0) continue;
2427 bytes.push((base64map.indexOf(base64.charAt(i - 1)) & Math.pow(2, -2 * imod4 + 8) - 1) << imod4 * 2 | base64map.indexOf(base64.charAt(i)) >>> 6 - imod4 * 2);
2428 }
2429
2430 return bytes;
2431 }
2432 };
2433 module.exports = crypt;
2434 })();
2435 });
2436
2437 var charenc = {
2438 // UTF-8 encoding
2439 utf8: {
2440 // Convert a string to a byte array
2441 stringToBytes: function stringToBytes(str) {
2442 return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
2443 },
2444 // Convert a byte array to a string
2445 bytesToString: function bytesToString(bytes) {
2446 return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
2447 }
2448 },
2449 // Binary encoding
2450 bin: {
2451 // Convert a string to a byte array
2452 stringToBytes: function stringToBytes(str) {
2453 for (var bytes = [], i = 0; i < str.length; i++) {
2454 bytes.push(str.charCodeAt(i) & 0xFF);
2455 }
2456
2457 return bytes;
2458 },
2459 // Convert a byte array to a string
2460 bytesToString: function bytesToString(bytes) {
2461 for (var str = [], i = 0; i < bytes.length; i++) {
2462 str.push(String.fromCharCode(bytes[i]));
2463 }
2464
2465 return str.join('');
2466 }
2467 }
2468 };
2469 var charenc_1 = charenc;
2470
2471 var sha1 = createCommonjsModule(function (module) {
2472 (function () {
2473 var crypt$1 = crypt,
2474 utf8 = charenc_1.utf8,
2475 bin = charenc_1.bin,
2476 // The core
2477 sha1 = function sha1(message) {
2478 // Convert to byte array
2479 if (message.constructor == String) message = utf8.stringToBytes(message);else if (typeof Buffer !== 'undefined' && typeof Buffer.isBuffer == 'function' && Buffer.isBuffer(message)) message = Array.prototype.slice.call(message, 0);else if (!Array.isArray(message)) message = message.toString(); // otherwise assume byte array
2480
2481 var m = crypt$1.bytesToWords(message),
2482 l = message.length * 8,
2483 w = [],
2484 H0 = 1732584193,
2485 H1 = -271733879,
2486 H2 = -1732584194,
2487 H3 = 271733878,
2488 H4 = -1009589776; // Padding
2489
2490 m[l >> 5] |= 0x80 << 24 - l % 32;
2491 m[(l + 64 >>> 9 << 4) + 15] = l;
2492
2493 for (var i = 0; i < m.length; i += 16) {
2494 var a = H0,
2495 b = H1,
2496 c = H2,
2497 d = H3,
2498 e = H4;
2499
2500 for (var j = 0; j < 80; j++) {
2501 if (j < 16) w[j] = m[i + j];else {
2502 var n = w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16];
2503 w[j] = n << 1 | n >>> 31;
2504 }
2505 var t = (H0 << 5 | H0 >>> 27) + H4 + (w[j] >>> 0) + (j < 20 ? (H1 & H2 | ~H1 & H3) + 1518500249 : j < 40 ? (H1 ^ H2 ^ H3) + 1859775393 : j < 60 ? (H1 & H2 | H1 & H3 | H2 & H3) - 1894007588 : (H1 ^ H2 ^ H3) - 899497514);
2506 H4 = H3;
2507 H3 = H2;
2508 H2 = H1 << 30 | H1 >>> 2;
2509 H1 = H0;
2510 H0 = t;
2511 }
2512
2513 H0 += a;
2514 H1 += b;
2515 H2 += c;
2516 H3 += d;
2517 H4 += e;
2518 }
2519
2520 return [H0, H1, H2, H3, H4];
2521 },
2522 // Public API
2523 api = function api(message, options) {
2524 var digestbytes = crypt$1.wordsToBytes(sha1(message));
2525 return options && options.asBytes ? digestbytes : options && options.asString ? bin.bytesToString(digestbytes) : crypt$1.bytesToHex(digestbytes);
2526 };
2527
2528 api._blocksize = 16;
2529 api._digestsize = 20;
2530 module.exports = api;
2531 })();
2532 });
2533
2534 var SemaphoreItem = /*#__PURE__*/function () {
2535 function SemaphoreItem(max) {
2536 _classCallCheck(this, SemaphoreItem);
2537
2538 this.queue = [];
2539 this.max = max;
2540 this.count = 0;
2541 }
2542
2543 _createClass(SemaphoreItem, [{
2544 key: "acquire",
2545 value: function acquire() {
2546 var _this = this;
2547
2548 if (this.count < this.max) {
2549 this.count++;
2550 return Promise.resolve();
2551 } else {
2552 return new Promise(function (resolve) {
2553 _this.queue.push(resolve);
2554 });
2555 }
2556 }
2557 }, {
2558 key: "release",
2559 value: function release() {
2560 var resolveFunc = this.queue.shift();
2561
2562 if (resolveFunc) {
2563 // Give the micro task queue a small break instead of calling resoleFunc() directly
2564 setTimeout(resolveFunc, 0);
2565 } else {
2566 this.count--;
2567 }
2568 }
2569 }]);
2570
2571 return SemaphoreItem;
2572 }();
2573
2574 var defaultKey = '_default';
2575
2576 var Semaphore = /*#__PURE__*/function () {
2577 function Semaphore() {
2578 var max = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1;
2579
2580 _classCallCheck(this, Semaphore);
2581
2582 this.semaphoreItems = {};
2583 this.max = max;
2584 }
2585
2586 _createClass(Semaphore, [{
2587 key: "_getSemaphoreInstance",
2588 value: function _getSemaphoreInstance() {
2589 var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultKey;
2590
2591 if (!this.semaphoreItems[key]) {
2592 this.semaphoreItems[key] = new SemaphoreItem(this.max);
2593 }
2594
2595 return this.semaphoreItems[key];
2596 }
2597 }, {
2598 key: "_tidy",
2599 value: function _tidy() {
2600 var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultKey;
2601
2602 if (this._getSemaphoreInstance(key).count == 0) {
2603 delete this.semaphoreItems[key];
2604 }
2605 }
2606 }, {
2607 key: "acquire",
2608 value: function acquire() {
2609 var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultKey;
2610 return this._getSemaphoreInstance(key).acquire();
2611 }
2612 }, {
2613 key: "release",
2614 value: function release() {
2615 var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultKey;
2616
2617 this._getSemaphoreInstance(key).release();
2618
2619 this._tidy(key);
2620 }
2621 }, {
2622 key: "count",
2623 value: function count() {
2624 var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultKey;
2625
2626 if (this.semaphoreItems[key]) {
2627 return this.semaphoreItems[key].count;
2628 } else {
2629 return 0;
2630 }
2631 }
2632 }, {
2633 key: "hasTasks",
2634 value: function hasTasks() {
2635 var key = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultKey;
2636 return this.count(key) > 0;
2637 }
2638 }]);
2639
2640 return Semaphore;
2641 }();
2642
2643 var src = Semaphore;
2644
2645 var index_es = /*#__PURE__*/Object.freeze({
2646 __proto__: null,
2647 'default': src
2648 });
2649
2650 var Semaphore$1 = /*@__PURE__*/getAugmentedNamespace(index_es);
2651
2652 var semaphore = new Semaphore$1();
2653 var getCache = {};
2654
2655 var Session_1 = /*#__PURE__*/function () {
2656 function Session(options) {
2657 _classCallCheck(this, Session);
2658
2659 this.axios = auth(options);
2660 }
2661
2662 _createClass(Session, [{
2663 key: "_isObject",
2664 value: function _isObject(value) {
2665 return value && _typeof(value) === 'object' && value.constructor === Object;
2666 }
2667 }, {
2668 key: "_objectToForm",
2669 value: function _objectToForm(obj) {
2670 var formData = formDataFactory.createFormData();
2671
2672 for (var _i = 0, _Object$entries = Object.entries(obj); _i < _Object$entries.length; _i++) {
2673 var _Object$entries$_i = _slicedToArray(_Object$entries[_i], 2),
2674 key = _Object$entries$_i[0],
2675 value = _Object$entries$_i[1];
2676
2677 if (value && value.name && value.file) {
2678 formData.append(key, value.file, value.name);
2679 } else if (Array.isArray(value) || this._isObject(value)) {
2680 formData.append(key, JSON.stringify(value));
2681 } else if (!lodash_isnil(value)) {
2682 // should empty strings be sent?
2683 formData.append(key, value);
2684 }
2685 }
2686
2687 return formData;
2688 }
2689 }, {
2690 key: "get",
2691 value: function get() {
2692 var _this$axios;
2693
2694 return (_this$axios = this.axios).get.apply(_this$axios, arguments);
2695 }
2696 }, {
2697 key: "getCached",
2698 value: function () {
2699 var _getCached = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
2700 var _len,
2701 args,
2702 _key,
2703 key,
2704 _args = arguments;
2705
2706 return regeneratorRuntime.wrap(function _callee$(_context) {
2707 while (1) {
2708 switch (_context.prev = _context.next) {
2709 case 0:
2710 for (_len = _args.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2711 args[_key] = _args[_key];
2712 }
2713
2714 key = sha1(JSON.stringify(args));
2715 _context.prev = 2;
2716 _context.next = 5;
2717 return semaphore.acquire(key);
2718
2719 case 5:
2720 if (!getCache[key]) {
2721 getCache[key] = this.get.apply(this, args);
2722 }
2723
2724 case 6:
2725 _context.prev = 6;
2726 semaphore.release(key);
2727 return _context.finish(6);
2728
2729 case 9:
2730 return _context.abrupt("return", getCache[key]);
2731
2732 case 10:
2733 case "end":
2734 return _context.stop();
2735 }
2736 }
2737 }, _callee, this, [[2,, 6, 9]]);
2738 }));
2739
2740 function getCached() {
2741 return _getCached.apply(this, arguments);
2742 }
2743
2744 return getCached;
2745 }()
2746 }, {
2747 key: "putForm",
2748 value: function putForm(url, params) {
2749 var formData = this._objectToForm(params);
2750
2751 return this.put(url, formData);
2752 }
2753 }, {
2754 key: "postForm",
2755 value: function postForm(url, params) {
2756 var formData = this._objectToForm(params);
2757
2758 return this.post(url, formData);
2759 }
2760 }, {
2761 key: "patchForm",
2762 value: function patchForm(url, params) {
2763 var formData = this._objectToForm(params);
2764
2765 return this.patch(url, formData);
2766 }
2767 }, {
2768 key: "post",
2769 value: function post() {
2770 var _this$axios2;
2771
2772 return (_this$axios2 = this.axios).post.apply(_this$axios2, arguments);
2773 }
2774 }, {
2775 key: "put",
2776 value: function put() {
2777 var _this$axios3;
2778
2779 return (_this$axios3 = this.axios).put.apply(_this$axios3, arguments);
2780 }
2781 }, {
2782 key: "delete",
2783 value: function _delete() {
2784 var _this$axios4;
2785
2786 return (_this$axios4 = this.axios)["delete"].apply(_this$axios4, arguments);
2787 }
2788 }, {
2789 key: "options",
2790 value: function options() {
2791 var _this$axios5;
2792
2793 return (_this$axios5 = this.axios).options.apply(_this$axios5, arguments);
2794 }
2795 }, {
2796 key: "patch",
2797 value: function patch() {
2798 var _this$axios6;
2799
2800 return (_this$axios6 = this.axios).patch.apply(_this$axios6, arguments);
2801 }
2802 }, {
2803 key: "nodes",
2804 get: function get() {
2805 // this creates a circular reference.. bad?
2806 if (this._nodes == null) {
2807 this._nodes = nodes(this);
2808 }
2809
2810 return this._nodes;
2811 }
2812 }, {
2813 key: "workflow",
2814 get: function get() {
2815 // this creates a circular reference.. bad?
2816 if (this._workflow == null) {
2817 this._workflow = workflow(this);
2818 }
2819
2820 return this._workflow;
2821 }
2822 }, {
2823 key: "rhcore",
2824 get: function get() {
2825 // this creates a circular reference.. bad?
2826 if (this._rhcore == null) {
2827 this._rhcore = rhcore(this);
2828 }
2829
2830 return this._rhcore;
2831 }
2832 }, {
2833 key: "members",
2834 get: function get() {
2835 // this creates a circular reference.. bad?
2836 if (this._members == null) {
2837 this._members = members(this);
2838 }
2839
2840 return this._members;
2841 }
2842 }, {
2843 key: "webreports",
2844 get: function get() {
2845 // this creates a circular reference.. bad?
2846 if (this._webreports == null) {
2847 this._webreports = webreports(this);
2848 }
2849
2850 return this._webreports;
2851 }
2852 }, {
2853 key: "versions",
2854 get: function get() {
2855 // this creates a circular reference.. bad?
2856 if (this._versions == null) {
2857 this._versions = versions(this);
2858 }
2859
2860 return this._versions;
2861 }
2862 }]);
2863
2864 return Session;
2865 }();
2866
2867 var auth_1 = auth;
2868 var Session_1$1 = Session_1;
2869 var src$1 = {
2870 auth: auth_1,
2871 Session: Session_1$1
2872 };
2873
2874 exports.Session = Session_1$1;
2875 exports.auth = auth_1;
2876 exports.default = src$1;
2877
2878 Object.defineProperty(exports, '__esModule', { value: true });
2879
2880})));
2881//# sourceMappingURL=index.js.map