@pie-element/math-inline 10.0.1-esmbeta.3 → 10.0.1-next.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/esm/controller.js DELETED
@@ -1,1983 +0,0 @@
1
- import { getActualFeedbackForCorrectness } from '@pie-lib/feedback';
2
- import Translator from '@pie-lib/translator';
3
- import * as mv from '@pie-framework/math-validation';
4
-
5
- function _extends() {
6
- _extends = Object.assign || function (target) {
7
- for (var i = 1; i < arguments.length; i++) {
8
- var source = arguments[i];
9
-
10
- for (var key in source) {
11
- if (Object.prototype.hasOwnProperty.call(source, key)) {
12
- target[key] = source[key];
13
- }
14
- }
15
- }
16
-
17
- return target;
18
- };
19
-
20
- return _extends.apply(this, arguments);
21
- }
22
-
23
- function _objectWithoutPropertiesLoose(source, excluded) {
24
- if (source == null) return {};
25
- var target = {};
26
- var sourceKeys = Object.keys(source);
27
- var key, i;
28
-
29
- for (i = 0; i < sourceKeys.length; i++) {
30
- key = sourceKeys[i];
31
- if (excluded.indexOf(key) >= 0) continue;
32
- target[key] = source[key];
33
- }
34
-
35
- return target;
36
- }
37
-
38
- var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
39
-
40
- var browser = {exports: {}};
41
-
42
- /**
43
- * Helpers.
44
- */
45
-
46
- var s = 1000;
47
- var m = s * 60;
48
- var h = m * 60;
49
- var d = h * 24;
50
- var w = d * 7;
51
- var y = d * 365.25;
52
-
53
- /**
54
- * Parse or format the given `val`.
55
- *
56
- * Options:
57
- *
58
- * - `long` verbose formatting [false]
59
- *
60
- * @param {String|Number} val
61
- * @param {Object} [options]
62
- * @throws {Error} throw an error if val is not a non-empty string or a number
63
- * @return {String|Number}
64
- * @api public
65
- */
66
-
67
- var ms = function (val, options) {
68
- options = options || {};
69
- var type = typeof val;
70
- if (type === 'string' && val.length > 0) {
71
- return parse(val);
72
- } else if (type === 'number' && isFinite(val)) {
73
- return options.long ? fmtLong(val) : fmtShort(val);
74
- }
75
- throw new Error(
76
- 'val is not a non-empty string or a valid number. val=' +
77
- JSON.stringify(val)
78
- );
79
- };
80
-
81
- /**
82
- * Parse the given `str` and return milliseconds.
83
- *
84
- * @param {String} str
85
- * @return {Number}
86
- * @api private
87
- */
88
-
89
- function parse(str) {
90
- str = String(str);
91
- if (str.length > 100) {
92
- return;
93
- }
94
- var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
95
- str
96
- );
97
- if (!match) {
98
- return;
99
- }
100
- var n = parseFloat(match[1]);
101
- var type = (match[2] || 'ms').toLowerCase();
102
- switch (type) {
103
- case 'years':
104
- case 'year':
105
- case 'yrs':
106
- case 'yr':
107
- case 'y':
108
- return n * y;
109
- case 'weeks':
110
- case 'week':
111
- case 'w':
112
- return n * w;
113
- case 'days':
114
- case 'day':
115
- case 'd':
116
- return n * d;
117
- case 'hours':
118
- case 'hour':
119
- case 'hrs':
120
- case 'hr':
121
- case 'h':
122
- return n * h;
123
- case 'minutes':
124
- case 'minute':
125
- case 'mins':
126
- case 'min':
127
- case 'm':
128
- return n * m;
129
- case 'seconds':
130
- case 'second':
131
- case 'secs':
132
- case 'sec':
133
- case 's':
134
- return n * s;
135
- case 'milliseconds':
136
- case 'millisecond':
137
- case 'msecs':
138
- case 'msec':
139
- case 'ms':
140
- return n;
141
- default:
142
- return undefined;
143
- }
144
- }
145
-
146
- /**
147
- * Short format for `ms`.
148
- *
149
- * @param {Number} ms
150
- * @return {String}
151
- * @api private
152
- */
153
-
154
- function fmtShort(ms) {
155
- var msAbs = Math.abs(ms);
156
- if (msAbs >= d) {
157
- return Math.round(ms / d) + 'd';
158
- }
159
- if (msAbs >= h) {
160
- return Math.round(ms / h) + 'h';
161
- }
162
- if (msAbs >= m) {
163
- return Math.round(ms / m) + 'm';
164
- }
165
- if (msAbs >= s) {
166
- return Math.round(ms / s) + 's';
167
- }
168
- return ms + 'ms';
169
- }
170
-
171
- /**
172
- * Long format for `ms`.
173
- *
174
- * @param {Number} ms
175
- * @return {String}
176
- * @api private
177
- */
178
-
179
- function fmtLong(ms) {
180
- var msAbs = Math.abs(ms);
181
- if (msAbs >= d) {
182
- return plural(ms, msAbs, d, 'day');
183
- }
184
- if (msAbs >= h) {
185
- return plural(ms, msAbs, h, 'hour');
186
- }
187
- if (msAbs >= m) {
188
- return plural(ms, msAbs, m, 'minute');
189
- }
190
- if (msAbs >= s) {
191
- return plural(ms, msAbs, s, 'second');
192
- }
193
- return ms + ' ms';
194
- }
195
-
196
- /**
197
- * Pluralization helper.
198
- */
199
-
200
- function plural(ms, msAbs, n, name) {
201
- var isPlural = msAbs >= n * 1.5;
202
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
203
- }
204
-
205
- /**
206
- * This is the common logic for both the Node.js and web browser
207
- * implementations of `debug()`.
208
- */
209
- function setup(env) {
210
- createDebug.debug = createDebug;
211
- createDebug.default = createDebug;
212
- createDebug.coerce = coerce;
213
- createDebug.disable = disable;
214
- createDebug.enable = enable;
215
- createDebug.enabled = enabled;
216
- createDebug.humanize = ms;
217
- Object.keys(env).forEach(function (key) {
218
- createDebug[key] = env[key];
219
- });
220
- /**
221
- * Active `debug` instances.
222
- */
223
-
224
- createDebug.instances = [];
225
- /**
226
- * The currently active debug mode names, and names to skip.
227
- */
228
-
229
- createDebug.names = [];
230
- createDebug.skips = [];
231
- /**
232
- * Map of special "%n" handling functions, for the debug "format" argument.
233
- *
234
- * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
235
- */
236
-
237
- createDebug.formatters = {};
238
- /**
239
- * Selects a color for a debug namespace
240
- * @param {String} namespace The namespace string for the for the debug instance to be colored
241
- * @return {Number|String} An ANSI color code for the given namespace
242
- * @api private
243
- */
244
-
245
- function selectColor(namespace) {
246
- var hash = 0;
247
-
248
- for (var i = 0; i < namespace.length; i++) {
249
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
250
- hash |= 0; // Convert to 32bit integer
251
- }
252
-
253
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
254
- }
255
-
256
- createDebug.selectColor = selectColor;
257
- /**
258
- * Create a debugger with the given `namespace`.
259
- *
260
- * @param {String} namespace
261
- * @return {Function}
262
- * @api public
263
- */
264
-
265
- function createDebug(namespace) {
266
- var prevTime;
267
-
268
- function debug() {
269
- // Disabled?
270
- if (!debug.enabled) {
271
- return;
272
- }
273
-
274
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
275
- args[_key] = arguments[_key];
276
- }
277
-
278
- var self = debug; // Set `diff` timestamp
279
-
280
- var curr = Number(new Date());
281
- var ms = curr - (prevTime || curr);
282
- self.diff = ms;
283
- self.prev = prevTime;
284
- self.curr = curr;
285
- prevTime = curr;
286
- args[0] = createDebug.coerce(args[0]);
287
-
288
- if (typeof args[0] !== 'string') {
289
- // Anything else let's inspect with %O
290
- args.unshift('%O');
291
- } // Apply any `formatters` transformations
292
-
293
-
294
- var index = 0;
295
- args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) {
296
- // If we encounter an escaped % then don't increase the array index
297
- if (match === '%%') {
298
- return match;
299
- }
300
-
301
- index++;
302
- var formatter = createDebug.formatters[format];
303
-
304
- if (typeof formatter === 'function') {
305
- var val = args[index];
306
- match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format`
307
-
308
- args.splice(index, 1);
309
- index--;
310
- }
311
-
312
- return match;
313
- }); // Apply env-specific formatting (colors, etc.)
314
-
315
- createDebug.formatArgs.call(self, args);
316
- var logFn = self.log || createDebug.log;
317
- logFn.apply(self, args);
318
- }
319
-
320
- debug.namespace = namespace;
321
- debug.enabled = createDebug.enabled(namespace);
322
- debug.useColors = createDebug.useColors();
323
- debug.color = selectColor(namespace);
324
- debug.destroy = destroy;
325
- debug.extend = extend; // Debug.formatArgs = formatArgs;
326
- // debug.rawLog = rawLog;
327
- // env-specific initialization logic for debug instances
328
-
329
- if (typeof createDebug.init === 'function') {
330
- createDebug.init(debug);
331
- }
332
-
333
- createDebug.instances.push(debug);
334
- return debug;
335
- }
336
-
337
- function destroy() {
338
- var index = createDebug.instances.indexOf(this);
339
-
340
- if (index !== -1) {
341
- createDebug.instances.splice(index, 1);
342
- return true;
343
- }
344
-
345
- return false;
346
- }
347
-
348
- function extend(namespace, delimiter) {
349
- return createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
350
- }
351
- /**
352
- * Enables a debug mode by namespaces. This can include modes
353
- * separated by a colon and wildcards.
354
- *
355
- * @param {String} namespaces
356
- * @api public
357
- */
358
-
359
-
360
- function enable(namespaces) {
361
- createDebug.save(namespaces);
362
- createDebug.names = [];
363
- createDebug.skips = [];
364
- var i;
365
- var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
366
- var len = split.length;
367
-
368
- for (i = 0; i < len; i++) {
369
- if (!split[i]) {
370
- // ignore empty strings
371
- continue;
372
- }
373
-
374
- namespaces = split[i].replace(/\*/g, '.*?');
375
-
376
- if (namespaces[0] === '-') {
377
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
378
- } else {
379
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
380
- }
381
- }
382
-
383
- for (i = 0; i < createDebug.instances.length; i++) {
384
- var instance = createDebug.instances[i];
385
- instance.enabled = createDebug.enabled(instance.namespace);
386
- }
387
- }
388
- /**
389
- * Disable debug output.
390
- *
391
- * @api public
392
- */
393
-
394
-
395
- function disable() {
396
- createDebug.enable('');
397
- }
398
- /**
399
- * Returns true if the given mode name is enabled, false otherwise.
400
- *
401
- * @param {String} name
402
- * @return {Boolean}
403
- * @api public
404
- */
405
-
406
-
407
- function enabled(name) {
408
- if (name[name.length - 1] === '*') {
409
- return true;
410
- }
411
-
412
- var i;
413
- var len;
414
-
415
- for (i = 0, len = createDebug.skips.length; i < len; i++) {
416
- if (createDebug.skips[i].test(name)) {
417
- return false;
418
- }
419
- }
420
-
421
- for (i = 0, len = createDebug.names.length; i < len; i++) {
422
- if (createDebug.names[i].test(name)) {
423
- return true;
424
- }
425
- }
426
-
427
- return false;
428
- }
429
- /**
430
- * Coerce `val`.
431
- *
432
- * @param {Mixed} val
433
- * @return {Mixed}
434
- * @api private
435
- */
436
-
437
-
438
- function coerce(val) {
439
- if (val instanceof Error) {
440
- return val.stack || val.message;
441
- }
442
-
443
- return val;
444
- }
445
-
446
- createDebug.enable(createDebug.load());
447
- return createDebug;
448
- }
449
-
450
- var common = setup;
451
-
452
- (function (module, exports) {
453
-
454
- function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
455
-
456
- /* eslint-env browser */
457
-
458
- /**
459
- * This is the web browser implementation of `debug()`.
460
- */
461
- exports.log = log;
462
- exports.formatArgs = formatArgs;
463
- exports.save = save;
464
- exports.load = load;
465
- exports.useColors = useColors;
466
- exports.storage = localstorage();
467
- /**
468
- * Colors.
469
- */
470
-
471
- exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
472
- /**
473
- * Currently only WebKit-based Web Inspectors, Firefox >= v31,
474
- * and the Firebug extension (any Firefox version) are known
475
- * to support "%c" CSS customizations.
476
- *
477
- * TODO: add a `localStorage` variable to explicitly enable/disable colors
478
- */
479
- // eslint-disable-next-line complexity
480
-
481
- function useColors() {
482
- // NB: In an Electron preload script, document will be defined but not fully
483
- // initialized. Since we know we're in Chrome, we'll just detect this case
484
- // explicitly
485
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
486
- return true;
487
- } // Internet Explorer and Edge do not support colors.
488
-
489
-
490
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
491
- return false;
492
- } // Is webkit? http://stackoverflow.com/a/16459606/376773
493
- // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
494
-
495
-
496
- return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773
497
- typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31?
498
- // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
499
- typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker
500
- typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
501
- }
502
- /**
503
- * Colorize log arguments if enabled.
504
- *
505
- * @api public
506
- */
507
-
508
-
509
- function formatArgs(args) {
510
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
511
-
512
- if (!this.useColors) {
513
- return;
514
- }
515
-
516
- var c = 'color: ' + this.color;
517
- args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other
518
- // arguments passed either before or after the %c, so we need to
519
- // figure out the correct index to insert the CSS into
520
-
521
- var index = 0;
522
- var lastC = 0;
523
- args[0].replace(/%[a-zA-Z%]/g, function (match) {
524
- if (match === '%%') {
525
- return;
526
- }
527
-
528
- index++;
529
-
530
- if (match === '%c') {
531
- // We only are interested in the *last* %c
532
- // (the user may have provided their own)
533
- lastC = index;
534
- }
535
- });
536
- args.splice(lastC, 0, c);
537
- }
538
- /**
539
- * Invokes `console.log()` when available.
540
- * No-op when `console.log` is not a "function".
541
- *
542
- * @api public
543
- */
544
-
545
-
546
- function log() {
547
- var _console;
548
-
549
- // This hackery is required for IE8/9, where
550
- // the `console.log` function doesn't have 'apply'
551
- return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments);
552
- }
553
- /**
554
- * Save `namespaces`.
555
- *
556
- * @param {String} namespaces
557
- * @api private
558
- */
559
-
560
-
561
- function save(namespaces) {
562
- try {
563
- if (namespaces) {
564
- exports.storage.setItem('debug', namespaces);
565
- } else {
566
- exports.storage.removeItem('debug');
567
- }
568
- } catch (error) {// Swallow
569
- // XXX (@Qix-) should we be logging these?
570
- }
571
- }
572
- /**
573
- * Load `namespaces`.
574
- *
575
- * @return {String} returns the previously persisted debug modes
576
- * @api private
577
- */
578
-
579
-
580
- function load() {
581
- var r;
582
-
583
- try {
584
- r = exports.storage.getItem('debug');
585
- } catch (error) {} // Swallow
586
- // XXX (@Qix-) should we be logging these?
587
- // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
588
-
589
-
590
- if (!r && typeof process !== 'undefined' && 'env' in process) {
591
- r = process.env.DEBUG;
592
- }
593
-
594
- return r;
595
- }
596
- /**
597
- * Localstorage attempts to return the localstorage.
598
- *
599
- * This is necessary because safari throws
600
- * when a user disables cookies/localstorage
601
- * and you attempt to access it.
602
- *
603
- * @return {LocalStorage}
604
- * @api private
605
- */
606
-
607
-
608
- function localstorage() {
609
- try {
610
- // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
611
- // The Browser also has localStorage in the global context.
612
- return localStorage;
613
- } catch (error) {// Swallow
614
- // XXX (@Qix-) should we be logging these?
615
- }
616
- }
617
-
618
- module.exports = common(exports);
619
- var formatters = module.exports.formatters;
620
- /**
621
- * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
622
- */
623
-
624
- formatters.j = function (v) {
625
- try {
626
- return JSON.stringify(v);
627
- } catch (error) {
628
- return '[UnexpectedJSONParseError]: ' + error.message;
629
- }
630
- };
631
- }(browser, browser.exports));
632
-
633
- var debug = browser.exports;
634
-
635
- /** Used for built-in method references. */
636
-
637
- var objectProto$6 = Object.prototype;
638
-
639
- /**
640
- * Checks if `value` is likely a prototype object.
641
- *
642
- * @private
643
- * @param {*} value The value to check.
644
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
645
- */
646
- function isPrototype$2(value) {
647
- var Ctor = value && value.constructor,
648
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
649
-
650
- return value === proto;
651
- }
652
-
653
- var _isPrototype = isPrototype$2;
654
-
655
- /**
656
- * Creates a unary function that invokes `func` with its argument transformed.
657
- *
658
- * @private
659
- * @param {Function} func The function to wrap.
660
- * @param {Function} transform The argument transform.
661
- * @returns {Function} Returns the new function.
662
- */
663
-
664
- function overArg$1(func, transform) {
665
- return function(arg) {
666
- return func(transform(arg));
667
- };
668
- }
669
-
670
- var _overArg = overArg$1;
671
-
672
- var overArg = _overArg;
673
-
674
- /* Built-in method references for those with the same name as other `lodash` methods. */
675
- var nativeKeys$1 = overArg(Object.keys, Object);
676
-
677
- var _nativeKeys = nativeKeys$1;
678
-
679
- var isPrototype$1 = _isPrototype,
680
- nativeKeys = _nativeKeys;
681
-
682
- /** Used for built-in method references. */
683
- var objectProto$5 = Object.prototype;
684
-
685
- /** Used to check objects for own properties. */
686
- var hasOwnProperty$4 = objectProto$5.hasOwnProperty;
687
-
688
- /**
689
- * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
690
- *
691
- * @private
692
- * @param {Object} object The object to query.
693
- * @returns {Array} Returns the array of property names.
694
- */
695
- function baseKeys$1(object) {
696
- if (!isPrototype$1(object)) {
697
- return nativeKeys(object);
698
- }
699
- var result = [];
700
- for (var key in Object(object)) {
701
- if (hasOwnProperty$4.call(object, key) && key != 'constructor') {
702
- result.push(key);
703
- }
704
- }
705
- return result;
706
- }
707
-
708
- var _baseKeys = baseKeys$1;
709
-
710
- /** Detect free variable `global` from Node.js. */
711
-
712
- var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
713
-
714
- var _freeGlobal = freeGlobal$1;
715
-
716
- var freeGlobal = _freeGlobal;
717
-
718
- /** Detect free variable `self`. */
719
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
720
-
721
- /** Used as a reference to the global object. */
722
- var root$7 = freeGlobal || freeSelf || Function('return this')();
723
-
724
- var _root = root$7;
725
-
726
- var root$6 = _root;
727
-
728
- /** Built-in value references. */
729
- var Symbol$3 = root$6.Symbol;
730
-
731
- var _Symbol = Symbol$3;
732
-
733
- var Symbol$2 = _Symbol;
734
-
735
- /** Used for built-in method references. */
736
- var objectProto$4 = Object.prototype;
737
-
738
- /** Used to check objects for own properties. */
739
- var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
740
-
741
- /**
742
- * Used to resolve the
743
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
744
- * of values.
745
- */
746
- var nativeObjectToString$1 = objectProto$4.toString;
747
-
748
- /** Built-in value references. */
749
- var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
750
-
751
- /**
752
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
753
- *
754
- * @private
755
- * @param {*} value The value to query.
756
- * @returns {string} Returns the raw `toStringTag`.
757
- */
758
- function getRawTag$1(value) {
759
- var isOwn = hasOwnProperty$3.call(value, symToStringTag$1),
760
- tag = value[symToStringTag$1];
761
-
762
- try {
763
- value[symToStringTag$1] = undefined;
764
- var unmasked = true;
765
- } catch (e) {}
766
-
767
- var result = nativeObjectToString$1.call(value);
768
- if (unmasked) {
769
- if (isOwn) {
770
- value[symToStringTag$1] = tag;
771
- } else {
772
- delete value[symToStringTag$1];
773
- }
774
- }
775
- return result;
776
- }
777
-
778
- var _getRawTag = getRawTag$1;
779
-
780
- /** Used for built-in method references. */
781
-
782
- var objectProto$3 = Object.prototype;
783
-
784
- /**
785
- * Used to resolve the
786
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
787
- * of values.
788
- */
789
- var nativeObjectToString = objectProto$3.toString;
790
-
791
- /**
792
- * Converts `value` to a string using `Object.prototype.toString`.
793
- *
794
- * @private
795
- * @param {*} value The value to convert.
796
- * @returns {string} Returns the converted string.
797
- */
798
- function objectToString$1(value) {
799
- return nativeObjectToString.call(value);
800
- }
801
-
802
- var _objectToString = objectToString$1;
803
-
804
- var Symbol$1 = _Symbol,
805
- getRawTag = _getRawTag,
806
- objectToString = _objectToString;
807
-
808
- /** `Object#toString` result references. */
809
- var nullTag = '[object Null]',
810
- undefinedTag = '[object Undefined]';
811
-
812
- /** Built-in value references. */
813
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
814
-
815
- /**
816
- * The base implementation of `getTag` without fallbacks for buggy environments.
817
- *
818
- * @private
819
- * @param {*} value The value to query.
820
- * @returns {string} Returns the `toStringTag`.
821
- */
822
- function baseGetTag$4(value) {
823
- if (value == null) {
824
- return value === undefined ? undefinedTag : nullTag;
825
- }
826
- return (symToStringTag && symToStringTag in Object(value))
827
- ? getRawTag(value)
828
- : objectToString(value);
829
- }
830
-
831
- var _baseGetTag = baseGetTag$4;
832
-
833
- /**
834
- * Checks if `value` is the
835
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
836
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
837
- *
838
- * @static
839
- * @memberOf _
840
- * @since 0.1.0
841
- * @category Lang
842
- * @param {*} value The value to check.
843
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
844
- * @example
845
- *
846
- * _.isObject({});
847
- * // => true
848
- *
849
- * _.isObject([1, 2, 3]);
850
- * // => true
851
- *
852
- * _.isObject(_.noop);
853
- * // => true
854
- *
855
- * _.isObject(null);
856
- * // => false
857
- */
858
-
859
- function isObject$2(value) {
860
- var type = typeof value;
861
- return value != null && (type == 'object' || type == 'function');
862
- }
863
-
864
- var isObject_1 = isObject$2;
865
-
866
- var baseGetTag$3 = _baseGetTag,
867
- isObject$1 = isObject_1;
868
-
869
- /** `Object#toString` result references. */
870
- var asyncTag = '[object AsyncFunction]',
871
- funcTag$1 = '[object Function]',
872
- genTag = '[object GeneratorFunction]',
873
- proxyTag = '[object Proxy]';
874
-
875
- /**
876
- * Checks if `value` is classified as a `Function` object.
877
- *
878
- * @static
879
- * @memberOf _
880
- * @since 0.1.0
881
- * @category Lang
882
- * @param {*} value The value to check.
883
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
884
- * @example
885
- *
886
- * _.isFunction(_);
887
- * // => true
888
- *
889
- * _.isFunction(/abc/);
890
- * // => false
891
- */
892
- function isFunction$2(value) {
893
- if (!isObject$1(value)) {
894
- return false;
895
- }
896
- // The use of `Object#toString` avoids issues with the `typeof` operator
897
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
898
- var tag = baseGetTag$3(value);
899
- return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
900
- }
901
-
902
- var isFunction_1 = isFunction$2;
903
-
904
- var root$5 = _root;
905
-
906
- /** Used to detect overreaching core-js shims. */
907
- var coreJsData$1 = root$5['__core-js_shared__'];
908
-
909
- var _coreJsData = coreJsData$1;
910
-
911
- var coreJsData = _coreJsData;
912
-
913
- /** Used to detect methods masquerading as native. */
914
- var maskSrcKey = (function() {
915
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
916
- return uid ? ('Symbol(src)_1.' + uid) : '';
917
- }());
918
-
919
- /**
920
- * Checks if `func` has its source masked.
921
- *
922
- * @private
923
- * @param {Function} func The function to check.
924
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
925
- */
926
- function isMasked$1(func) {
927
- return !!maskSrcKey && (maskSrcKey in func);
928
- }
929
-
930
- var _isMasked = isMasked$1;
931
-
932
- /** Used for built-in method references. */
933
-
934
- var funcProto$1 = Function.prototype;
935
-
936
- /** Used to resolve the decompiled source of functions. */
937
- var funcToString$1 = funcProto$1.toString;
938
-
939
- /**
940
- * Converts `func` to its source code.
941
- *
942
- * @private
943
- * @param {Function} func The function to convert.
944
- * @returns {string} Returns the source code.
945
- */
946
- function toSource$2(func) {
947
- if (func != null) {
948
- try {
949
- return funcToString$1.call(func);
950
- } catch (e) {}
951
- try {
952
- return (func + '');
953
- } catch (e) {}
954
- }
955
- return '';
956
- }
957
-
958
- var _toSource = toSource$2;
959
-
960
- var isFunction$1 = isFunction_1,
961
- isMasked = _isMasked,
962
- isObject = isObject_1,
963
- toSource$1 = _toSource;
964
-
965
- /**
966
- * Used to match `RegExp`
967
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
968
- */
969
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
970
-
971
- /** Used to detect host constructors (Safari). */
972
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
973
-
974
- /** Used for built-in method references. */
975
- var funcProto = Function.prototype,
976
- objectProto$2 = Object.prototype;
977
-
978
- /** Used to resolve the decompiled source of functions. */
979
- var funcToString = funcProto.toString;
980
-
981
- /** Used to check objects for own properties. */
982
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
983
-
984
- /** Used to detect if a method is native. */
985
- var reIsNative = RegExp('^' +
986
- funcToString.call(hasOwnProperty$2).replace(reRegExpChar, '\\$&')
987
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
988
- );
989
-
990
- /**
991
- * The base implementation of `_.isNative` without bad shim checks.
992
- *
993
- * @private
994
- * @param {*} value The value to check.
995
- * @returns {boolean} Returns `true` if `value` is a native function,
996
- * else `false`.
997
- */
998
- function baseIsNative$1(value) {
999
- if (!isObject(value) || isMasked(value)) {
1000
- return false;
1001
- }
1002
- var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
1003
- return pattern.test(toSource$1(value));
1004
- }
1005
-
1006
- var _baseIsNative = baseIsNative$1;
1007
-
1008
- /**
1009
- * Gets the value at `key` of `object`.
1010
- *
1011
- * @private
1012
- * @param {Object} [object] The object to query.
1013
- * @param {string} key The key of the property to get.
1014
- * @returns {*} Returns the property value.
1015
- */
1016
-
1017
- function getValue$1(object, key) {
1018
- return object == null ? undefined : object[key];
1019
- }
1020
-
1021
- var _getValue = getValue$1;
1022
-
1023
- var baseIsNative = _baseIsNative,
1024
- getValue = _getValue;
1025
-
1026
- /**
1027
- * Gets the native function at `key` of `object`.
1028
- *
1029
- * @private
1030
- * @param {Object} object The object to query.
1031
- * @param {string} key The key of the method to get.
1032
- * @returns {*} Returns the function if it's native, else `undefined`.
1033
- */
1034
- function getNative$5(object, key) {
1035
- var value = getValue(object, key);
1036
- return baseIsNative(value) ? value : undefined;
1037
- }
1038
-
1039
- var _getNative = getNative$5;
1040
-
1041
- var getNative$4 = _getNative,
1042
- root$4 = _root;
1043
-
1044
- /* Built-in method references that are verified to be native. */
1045
- var DataView$1 = getNative$4(root$4, 'DataView');
1046
-
1047
- var _DataView = DataView$1;
1048
-
1049
- var getNative$3 = _getNative,
1050
- root$3 = _root;
1051
-
1052
- /* Built-in method references that are verified to be native. */
1053
- var Map$1 = getNative$3(root$3, 'Map');
1054
-
1055
- var _Map = Map$1;
1056
-
1057
- var getNative$2 = _getNative,
1058
- root$2 = _root;
1059
-
1060
- /* Built-in method references that are verified to be native. */
1061
- var Promise$2 = getNative$2(root$2, 'Promise');
1062
-
1063
- var _Promise = Promise$2;
1064
-
1065
- var getNative$1 = _getNative,
1066
- root$1 = _root;
1067
-
1068
- /* Built-in method references that are verified to be native. */
1069
- var Set$1 = getNative$1(root$1, 'Set');
1070
-
1071
- var _Set = Set$1;
1072
-
1073
- var getNative = _getNative,
1074
- root = _root;
1075
-
1076
- /* Built-in method references that are verified to be native. */
1077
- var WeakMap$1 = getNative(root, 'WeakMap');
1078
-
1079
- var _WeakMap = WeakMap$1;
1080
-
1081
- var DataView = _DataView,
1082
- Map = _Map,
1083
- Promise$1 = _Promise,
1084
- Set = _Set,
1085
- WeakMap = _WeakMap,
1086
- baseGetTag$2 = _baseGetTag,
1087
- toSource = _toSource;
1088
-
1089
- /** `Object#toString` result references. */
1090
- var mapTag$2 = '[object Map]',
1091
- objectTag$1 = '[object Object]',
1092
- promiseTag = '[object Promise]',
1093
- setTag$2 = '[object Set]',
1094
- weakMapTag$1 = '[object WeakMap]';
1095
-
1096
- var dataViewTag$1 = '[object DataView]';
1097
-
1098
- /** Used to detect maps, sets, and weakmaps. */
1099
- var dataViewCtorString = toSource(DataView),
1100
- mapCtorString = toSource(Map),
1101
- promiseCtorString = toSource(Promise$1),
1102
- setCtorString = toSource(Set),
1103
- weakMapCtorString = toSource(WeakMap);
1104
-
1105
- /**
1106
- * Gets the `toStringTag` of `value`.
1107
- *
1108
- * @private
1109
- * @param {*} value The value to query.
1110
- * @returns {string} Returns the `toStringTag`.
1111
- */
1112
- var getTag$1 = baseGetTag$2;
1113
-
1114
- // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
1115
- if ((DataView && getTag$1(new DataView(new ArrayBuffer(1))) != dataViewTag$1) ||
1116
- (Map && getTag$1(new Map) != mapTag$2) ||
1117
- (Promise$1 && getTag$1(Promise$1.resolve()) != promiseTag) ||
1118
- (Set && getTag$1(new Set) != setTag$2) ||
1119
- (WeakMap && getTag$1(new WeakMap) != weakMapTag$1)) {
1120
- getTag$1 = function(value) {
1121
- var result = baseGetTag$2(value),
1122
- Ctor = result == objectTag$1 ? value.constructor : undefined,
1123
- ctorString = Ctor ? toSource(Ctor) : '';
1124
-
1125
- if (ctorString) {
1126
- switch (ctorString) {
1127
- case dataViewCtorString: return dataViewTag$1;
1128
- case mapCtorString: return mapTag$2;
1129
- case promiseCtorString: return promiseTag;
1130
- case setCtorString: return setTag$2;
1131
- case weakMapCtorString: return weakMapTag$1;
1132
- }
1133
- }
1134
- return result;
1135
- };
1136
- }
1137
-
1138
- var _getTag = getTag$1;
1139
-
1140
- /**
1141
- * Checks if `value` is object-like. A value is object-like if it's not `null`
1142
- * and has a `typeof` result of "object".
1143
- *
1144
- * @static
1145
- * @memberOf _
1146
- * @since 4.0.0
1147
- * @category Lang
1148
- * @param {*} value The value to check.
1149
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1150
- * @example
1151
- *
1152
- * _.isObjectLike({});
1153
- * // => true
1154
- *
1155
- * _.isObjectLike([1, 2, 3]);
1156
- * // => true
1157
- *
1158
- * _.isObjectLike(_.noop);
1159
- * // => false
1160
- *
1161
- * _.isObjectLike(null);
1162
- * // => false
1163
- */
1164
-
1165
- function isObjectLike$3(value) {
1166
- return value != null && typeof value == 'object';
1167
- }
1168
-
1169
- var isObjectLike_1 = isObjectLike$3;
1170
-
1171
- var baseGetTag$1 = _baseGetTag,
1172
- isObjectLike$2 = isObjectLike_1;
1173
-
1174
- /** `Object#toString` result references. */
1175
- var argsTag$1 = '[object Arguments]';
1176
-
1177
- /**
1178
- * The base implementation of `_.isArguments`.
1179
- *
1180
- * @private
1181
- * @param {*} value The value to check.
1182
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1183
- */
1184
- function baseIsArguments$1(value) {
1185
- return isObjectLike$2(value) && baseGetTag$1(value) == argsTag$1;
1186
- }
1187
-
1188
- var _baseIsArguments = baseIsArguments$1;
1189
-
1190
- var baseIsArguments = _baseIsArguments,
1191
- isObjectLike$1 = isObjectLike_1;
1192
-
1193
- /** Used for built-in method references. */
1194
- var objectProto$1 = Object.prototype;
1195
-
1196
- /** Used to check objects for own properties. */
1197
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
1198
-
1199
- /** Built-in value references. */
1200
- var propertyIsEnumerable = objectProto$1.propertyIsEnumerable;
1201
-
1202
- /**
1203
- * Checks if `value` is likely an `arguments` object.
1204
- *
1205
- * @static
1206
- * @memberOf _
1207
- * @since 0.1.0
1208
- * @category Lang
1209
- * @param {*} value The value to check.
1210
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1211
- * else `false`.
1212
- * @example
1213
- *
1214
- * _.isArguments(function() { return arguments; }());
1215
- * // => true
1216
- *
1217
- * _.isArguments([1, 2, 3]);
1218
- * // => false
1219
- */
1220
- var isArguments$1 = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1221
- return isObjectLike$1(value) && hasOwnProperty$1.call(value, 'callee') &&
1222
- !propertyIsEnumerable.call(value, 'callee');
1223
- };
1224
-
1225
- var isArguments_1 = isArguments$1;
1226
-
1227
- /**
1228
- * Checks if `value` is classified as an `Array` object.
1229
- *
1230
- * @static
1231
- * @memberOf _
1232
- * @since 0.1.0
1233
- * @category Lang
1234
- * @param {*} value The value to check.
1235
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1236
- * @example
1237
- *
1238
- * _.isArray([1, 2, 3]);
1239
- * // => true
1240
- *
1241
- * _.isArray(document.body.children);
1242
- * // => false
1243
- *
1244
- * _.isArray('abc');
1245
- * // => false
1246
- *
1247
- * _.isArray(_.noop);
1248
- * // => false
1249
- */
1250
-
1251
- var isArray$1 = Array.isArray;
1252
-
1253
- var isArray_1 = isArray$1;
1254
-
1255
- /** Used as references for various `Number` constants. */
1256
-
1257
- var MAX_SAFE_INTEGER = 9007199254740991;
1258
-
1259
- /**
1260
- * Checks if `value` is a valid array-like length.
1261
- *
1262
- * **Note:** This method is loosely based on
1263
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1264
- *
1265
- * @static
1266
- * @memberOf _
1267
- * @since 4.0.0
1268
- * @category Lang
1269
- * @param {*} value The value to check.
1270
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1271
- * @example
1272
- *
1273
- * _.isLength(3);
1274
- * // => true
1275
- *
1276
- * _.isLength(Number.MIN_VALUE);
1277
- * // => false
1278
- *
1279
- * _.isLength(Infinity);
1280
- * // => false
1281
- *
1282
- * _.isLength('3');
1283
- * // => false
1284
- */
1285
- function isLength$2(value) {
1286
- return typeof value == 'number' &&
1287
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1288
- }
1289
-
1290
- var isLength_1 = isLength$2;
1291
-
1292
- var isFunction = isFunction_1,
1293
- isLength$1 = isLength_1;
1294
-
1295
- /**
1296
- * Checks if `value` is array-like. A value is considered array-like if it's
1297
- * not a function and has a `value.length` that's an integer greater than or
1298
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1299
- *
1300
- * @static
1301
- * @memberOf _
1302
- * @since 4.0.0
1303
- * @category Lang
1304
- * @param {*} value The value to check.
1305
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1306
- * @example
1307
- *
1308
- * _.isArrayLike([1, 2, 3]);
1309
- * // => true
1310
- *
1311
- * _.isArrayLike(document.body.children);
1312
- * // => true
1313
- *
1314
- * _.isArrayLike('abc');
1315
- * // => true
1316
- *
1317
- * _.isArrayLike(_.noop);
1318
- * // => false
1319
- */
1320
- function isArrayLike$1(value) {
1321
- return value != null && isLength$1(value.length) && !isFunction(value);
1322
- }
1323
-
1324
- var isArrayLike_1 = isArrayLike$1;
1325
-
1326
- var isBuffer$1 = {exports: {}};
1327
-
1328
- /**
1329
- * This method returns `false`.
1330
- *
1331
- * @static
1332
- * @memberOf _
1333
- * @since 4.13.0
1334
- * @category Util
1335
- * @returns {boolean} Returns `false`.
1336
- * @example
1337
- *
1338
- * _.times(2, _.stubFalse);
1339
- * // => [false, false]
1340
- */
1341
-
1342
- function stubFalse() {
1343
- return false;
1344
- }
1345
-
1346
- var stubFalse_1 = stubFalse;
1347
-
1348
- (function (module, exports) {
1349
- var root = _root,
1350
- stubFalse = stubFalse_1;
1351
-
1352
- /** Detect free variable `exports`. */
1353
- var freeExports = exports && !exports.nodeType && exports;
1354
-
1355
- /** Detect free variable `module`. */
1356
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
1357
-
1358
- /** Detect the popular CommonJS extension `module.exports`. */
1359
- var moduleExports = freeModule && freeModule.exports === freeExports;
1360
-
1361
- /** Built-in value references. */
1362
- var Buffer = moduleExports ? root.Buffer : undefined;
1363
-
1364
- /* Built-in method references for those with the same name as other `lodash` methods. */
1365
- var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
1366
-
1367
- /**
1368
- * Checks if `value` is a buffer.
1369
- *
1370
- * @static
1371
- * @memberOf _
1372
- * @since 4.3.0
1373
- * @category Lang
1374
- * @param {*} value The value to check.
1375
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1376
- * @example
1377
- *
1378
- * _.isBuffer(new Buffer(2));
1379
- * // => true
1380
- *
1381
- * _.isBuffer(new Uint8Array(2));
1382
- * // => false
1383
- */
1384
- var isBuffer = nativeIsBuffer || stubFalse;
1385
-
1386
- module.exports = isBuffer;
1387
- }(isBuffer$1, isBuffer$1.exports));
1388
-
1389
- var baseGetTag = _baseGetTag,
1390
- isLength = isLength_1,
1391
- isObjectLike = isObjectLike_1;
1392
-
1393
- /** `Object#toString` result references. */
1394
- var argsTag = '[object Arguments]',
1395
- arrayTag = '[object Array]',
1396
- boolTag = '[object Boolean]',
1397
- dateTag = '[object Date]',
1398
- errorTag = '[object Error]',
1399
- funcTag = '[object Function]',
1400
- mapTag$1 = '[object Map]',
1401
- numberTag = '[object Number]',
1402
- objectTag = '[object Object]',
1403
- regexpTag = '[object RegExp]',
1404
- setTag$1 = '[object Set]',
1405
- stringTag = '[object String]',
1406
- weakMapTag = '[object WeakMap]';
1407
-
1408
- var arrayBufferTag = '[object ArrayBuffer]',
1409
- dataViewTag = '[object DataView]',
1410
- float32Tag = '[object Float32Array]',
1411
- float64Tag = '[object Float64Array]',
1412
- int8Tag = '[object Int8Array]',
1413
- int16Tag = '[object Int16Array]',
1414
- int32Tag = '[object Int32Array]',
1415
- uint8Tag = '[object Uint8Array]',
1416
- uint8ClampedTag = '[object Uint8ClampedArray]',
1417
- uint16Tag = '[object Uint16Array]',
1418
- uint32Tag = '[object Uint32Array]';
1419
-
1420
- /** Used to identify `toStringTag` values of typed arrays. */
1421
- var typedArrayTags = {};
1422
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
1423
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
1424
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
1425
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
1426
- typedArrayTags[uint32Tag] = true;
1427
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
1428
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
1429
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
1430
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
1431
- typedArrayTags[mapTag$1] = typedArrayTags[numberTag] =
1432
- typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
1433
- typedArrayTags[setTag$1] = typedArrayTags[stringTag] =
1434
- typedArrayTags[weakMapTag] = false;
1435
-
1436
- /**
1437
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
1438
- *
1439
- * @private
1440
- * @param {*} value The value to check.
1441
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1442
- */
1443
- function baseIsTypedArray$1(value) {
1444
- return isObjectLike(value) &&
1445
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
1446
- }
1447
-
1448
- var _baseIsTypedArray = baseIsTypedArray$1;
1449
-
1450
- /**
1451
- * The base implementation of `_.unary` without support for storing metadata.
1452
- *
1453
- * @private
1454
- * @param {Function} func The function to cap arguments for.
1455
- * @returns {Function} Returns the new capped function.
1456
- */
1457
-
1458
- function baseUnary$1(func) {
1459
- return function(value) {
1460
- return func(value);
1461
- };
1462
- }
1463
-
1464
- var _baseUnary = baseUnary$1;
1465
-
1466
- var _nodeUtil = {exports: {}};
1467
-
1468
- (function (module, exports) {
1469
- var freeGlobal = _freeGlobal;
1470
-
1471
- /** Detect free variable `exports`. */
1472
- var freeExports = exports && !exports.nodeType && exports;
1473
-
1474
- /** Detect free variable `module`. */
1475
- var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
1476
-
1477
- /** Detect the popular CommonJS extension `module.exports`. */
1478
- var moduleExports = freeModule && freeModule.exports === freeExports;
1479
-
1480
- /** Detect free variable `process` from Node.js. */
1481
- var freeProcess = moduleExports && freeGlobal.process;
1482
-
1483
- /** Used to access faster Node.js helpers. */
1484
- var nodeUtil = (function() {
1485
- try {
1486
- // Use `util.types` for Node.js 10+.
1487
- var types = freeModule && freeModule.require && freeModule.require('util').types;
1488
-
1489
- if (types) {
1490
- return types;
1491
- }
1492
-
1493
- // Legacy `process.binding('util')` for Node.js < 10.
1494
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
1495
- } catch (e) {}
1496
- }());
1497
-
1498
- module.exports = nodeUtil;
1499
- }(_nodeUtil, _nodeUtil.exports));
1500
-
1501
- var baseIsTypedArray = _baseIsTypedArray,
1502
- baseUnary = _baseUnary,
1503
- nodeUtil = _nodeUtil.exports;
1504
-
1505
- /* Node.js helper references. */
1506
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1507
-
1508
- /**
1509
- * Checks if `value` is classified as a typed array.
1510
- *
1511
- * @static
1512
- * @memberOf _
1513
- * @since 3.0.0
1514
- * @category Lang
1515
- * @param {*} value The value to check.
1516
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1517
- * @example
1518
- *
1519
- * _.isTypedArray(new Uint8Array);
1520
- * // => true
1521
- *
1522
- * _.isTypedArray([]);
1523
- * // => false
1524
- */
1525
- var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1526
-
1527
- var isTypedArray_1 = isTypedArray$1;
1528
-
1529
- var baseKeys = _baseKeys,
1530
- getTag = _getTag,
1531
- isArguments = isArguments_1,
1532
- isArray = isArray_1,
1533
- isArrayLike = isArrayLike_1,
1534
- isBuffer = isBuffer$1.exports,
1535
- isPrototype = _isPrototype,
1536
- isTypedArray = isTypedArray_1;
1537
-
1538
- /** `Object#toString` result references. */
1539
- var mapTag = '[object Map]',
1540
- setTag = '[object Set]';
1541
-
1542
- /** Used for built-in method references. */
1543
- var objectProto = Object.prototype;
1544
-
1545
- /** Used to check objects for own properties. */
1546
- var hasOwnProperty = objectProto.hasOwnProperty;
1547
-
1548
- /**
1549
- * Checks if `value` is an empty object, collection, map, or set.
1550
- *
1551
- * Objects are considered empty if they have no own enumerable string keyed
1552
- * properties.
1553
- *
1554
- * Array-like values such as `arguments` objects, arrays, buffers, strings, or
1555
- * jQuery-like collections are considered empty if they have a `length` of `0`.
1556
- * Similarly, maps and sets are considered empty if they have a `size` of `0`.
1557
- *
1558
- * @static
1559
- * @memberOf _
1560
- * @since 0.1.0
1561
- * @category Lang
1562
- * @param {*} value The value to check.
1563
- * @returns {boolean} Returns `true` if `value` is empty, else `false`.
1564
- * @example
1565
- *
1566
- * _.isEmpty(null);
1567
- * // => true
1568
- *
1569
- * _.isEmpty(true);
1570
- * // => true
1571
- *
1572
- * _.isEmpty(1);
1573
- * // => true
1574
- *
1575
- * _.isEmpty([1, 2, 3]);
1576
- * // => false
1577
- *
1578
- * _.isEmpty({ 'a': 1 });
1579
- * // => false
1580
- */
1581
- function isEmpty(value) {
1582
- if (value == null) {
1583
- return true;
1584
- }
1585
- if (isArrayLike(value) &&
1586
- (isArray(value) || typeof value == 'string' || typeof value.splice == 'function' ||
1587
- isBuffer(value) || isTypedArray(value) || isArguments(value))) {
1588
- return !value.length;
1589
- }
1590
- var tag = getTag(value);
1591
- if (tag == mapTag || tag == setTag) {
1592
- return !value.size;
1593
- }
1594
- if (isPrototype(value)) {
1595
- return !baseKeys(value).length;
1596
- }
1597
- for (var key in value) {
1598
- if (hasOwnProperty.call(value, key)) {
1599
- return false;
1600
- }
1601
- }
1602
- return true;
1603
- }
1604
-
1605
- var isEmpty_1 = isEmpty;
1606
-
1607
- const ResponseTypes = {
1608
- advanced: 'Advanced Multi',
1609
- simple: 'Simple'
1610
- };
1611
-
1612
- var defaults = {
1613
- allowTrailingZerosDefault: false,
1614
- customKeys: [],
1615
- equationEditor: '8',
1616
- expression: '',
1617
- feedback: {
1618
- correct: {
1619
- default: 'Correct',
1620
- type: 'none'
1621
- },
1622
- incorrect: {
1623
- default: 'Incorrect',
1624
- type: 'none'
1625
- },
1626
- partial: {
1627
- default: 'Nearly',
1628
- type: 'none'
1629
- }
1630
- },
1631
- feedbackEnabled: false,
1632
- ignoreOrderDefault: false,
1633
- partialScoring: true,
1634
- prompt: '',
1635
- promptEnabled: true,
1636
- rationale: '',
1637
- rationaleEnabled: true,
1638
- responseType: ResponseTypes.advanced,
1639
- responses: [],
1640
- scoringType: 'auto',
1641
- studentInstructionsEnabled: true,
1642
- teacherInstructions: '',
1643
- teacherInstructionsEnabled: true,
1644
- toolbarEditorPosition: 'bottom',
1645
- validationDefault: 'literal'
1646
- };
1647
-
1648
- const _excluded = ["extraCSSRules", "responses", "language"];
1649
- const {
1650
- translator
1651
- } = Translator;
1652
- const log = debug('@pie-element:math-inline:controller');
1653
-
1654
- const getResponseCorrectness = (model, answerItem, isOutcome) => {
1655
- const correctResponses = model.responses;
1656
- const isAdvanced = model.responseType === ResponseTypes.advanced;
1657
-
1658
- if (!answerItem) {
1659
- return {
1660
- correctness: 'unanswered',
1661
- score: isOutcome ? 0 : '0%',
1662
- correct: false
1663
- };
1664
- }
1665
-
1666
- const isAnswerCorrect = getIsAnswerCorrect(isAdvanced ? correctResponses : correctResponses.slice(0, 1), answerItem);
1667
- const correctnessObject = {
1668
- correctness: 'incorrect',
1669
- score: isOutcome ? 0 : '0%',
1670
- correct: false
1671
- };
1672
-
1673
- if (isAnswerCorrect) {
1674
- correctnessObject.correctness = 'correct';
1675
- correctnessObject.score = isOutcome ? 1 : '100%';
1676
- correctnessObject.correct = true;
1677
- }
1678
-
1679
- return correctnessObject;
1680
- };
1681
-
1682
- function getIsAnswerCorrect(correctResponseItems, answerItem) {
1683
- let answerCorrect = false;
1684
- (correctResponseItems || []).forEach(correctResponse => {
1685
- if (answerCorrect) return;
1686
- const opts = {
1687
- mode: correctResponse.validation || defaults.validationDefault
1688
- };
1689
-
1690
- if (opts.mode === 'literal') {
1691
- opts.literal = {
1692
- allowTrailingZeros: correctResponse.allowTrailingZeros || false,
1693
- ignoreOrder: correctResponse.ignoreOrder || false
1694
- };
1695
- }
1696
-
1697
- const acceptedValues = [correctResponse.answer].concat(Object.keys(correctResponse.alternates || {}).map(alternateId => correctResponse.alternates[alternateId]));
1698
-
1699
- for (let i = 0; i < acceptedValues.length; i++) {
1700
- try {
1701
- if (mv.latexEqual(answerItem, acceptedValues[i], opts)) {
1702
- answerCorrect = true;
1703
- break;
1704
- }
1705
- } catch (e) {
1706
- log('Parse failure when evaluating math', acceptedValues[i], answerItem, e);
1707
- continue;
1708
- }
1709
- }
1710
- });
1711
- return answerCorrect;
1712
- }
1713
-
1714
- const getCorrectness = (question, env, session, isOutcome) => {
1715
- if (env.mode === 'evaluate') {
1716
- return getResponseCorrectness(question, question.responseType === ResponseTypes.advanced ? session && session.completeAnswer || '' : session && session.response, isOutcome);
1717
- }
1718
-
1719
- return undefined;
1720
- };
1721
-
1722
- function createDefaultModel(model = {}) {
1723
- return new Promise(resolve => {
1724
- resolve({
1725
- config: _extends({}, defaults, model)
1726
- });
1727
- });
1728
- }
1729
- const outcome = (question, session, env) => {
1730
- return new Promise(resolve => {
1731
- if (env.mode !== 'evaluate') {
1732
- resolve({
1733
- score: undefined,
1734
- completed: undefined
1735
- });
1736
- } else {
1737
- if (!session || isEmpty_1(session)) {
1738
- resolve({
1739
- score: 0,
1740
- empty: true
1741
- });
1742
- } else {
1743
- const correctness = getCorrectness(question, env, session, true);
1744
- resolve({
1745
- score: correctness.score
1746
- });
1747
- }
1748
- }
1749
- });
1750
- };
1751
- const normalize = question => {
1752
- // making sure that defaults are set
1753
- if (!isEmpty_1(question.responses)) {
1754
- question.responses = question.responses.map(correctResponse => _extends({}, correctResponse, {
1755
- validation: correctResponse.validation || question.validationDefault,
1756
- allowTrailingZeros: correctResponse.allowTrailingZeros || question.allowTrailingZerosDefault,
1757
- ignoreOrder: correctResponse.ignoreOrder || question.ignoreOrderDefault
1758
- }));
1759
- }
1760
-
1761
- return _extends({}, defaults, question);
1762
- };
1763
- const model = (question, session, env) => new Promise(resolve => {
1764
- var _config$responses;
1765
-
1766
- const normalizedQuestion = normalize(question);
1767
- const correctness = getCorrectness(normalizedQuestion, env, session);
1768
-
1769
- const {
1770
- extraCSSRules,
1771
- responses,
1772
- language
1773
- } = normalizedQuestion,
1774
- config = _objectWithoutPropertiesLoose(normalizedQuestion, _excluded);
1775
-
1776
- config.responses = config.responseType === ResponseTypes.simple ? responses.slice(0, 1) : responses;
1777
- const feedback = env.mode === 'evaluate' && normalizedQuestion.feedbackEnabled ? getActualFeedbackForCorrectness(correctness == null ? void 0 : correctness.correctness, normalizedQuestion.feedback) : undefined;
1778
- const out = {
1779
- extraCSSRules,
1780
- config,
1781
- correctness,
1782
- feedback,
1783
- disabled: env.mode !== 'gather',
1784
- view: env.mode === 'view'
1785
- };
1786
- const note = normalizedQuestion.note || translator.t('mathInline.primaryCorrectWithAlternates', {
1787
- lng: language
1788
- });
1789
- const showNote = (config == null ? void 0 : (_config$responses = config.responses) == null ? void 0 : _config$responses.length) > 1 || ((config == null ? void 0 : config.responses) || []).some(response => response.validation === 'symbolic' || Object.keys(response.alternates || {}).length > 0);
1790
-
1791
- if (env.mode === 'evaluate') {
1792
- out.correctResponse = {};
1793
- out.config.showNote = showNote;
1794
- out.config.note = note;
1795
- } else {
1796
- out.config.responses = [];
1797
- out.config.showNote = false;
1798
- }
1799
-
1800
- if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
1801
- out.rationale = normalizedQuestion.rationaleEnabled ? normalizedQuestion.rationale : null;
1802
- out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
1803
- } else {
1804
- out.rationale = null;
1805
- out.teacherInstructions = null;
1806
- out.config.rationale = null;
1807
- out.config.teacherInstructions = null;
1808
- }
1809
-
1810
- out.config.env = env;
1811
- out.config.prompt = normalizedQuestion.promptEnabled ? normalizedQuestion.prompt : null;
1812
- out.language = language;
1813
- log('out: ', out);
1814
- resolve(out);
1815
- });
1816
-
1817
- const escape = string => string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
1818
-
1819
-
1820
- const simpleSessionResponse = question => new Promise(resolve => {
1821
- const {
1822
- responses,
1823
- id
1824
- } = question;
1825
- const {
1826
- answer
1827
- } = responses && responses.length ? responses[0] : {};
1828
- resolve({
1829
- id,
1830
- response: answer || '',
1831
- completeAnswer: answer || ''
1832
- });
1833
- }); // use this for items like E672793
1834
-
1835
-
1836
- const removeTrailingEscape = str => str.endsWith('\\') ? str.slice(0, -1) : str;
1837
-
1838
- const advancedSessionResponse = question => new Promise(resolve => {
1839
- const {
1840
- responses,
1841
- id
1842
- } = question;
1843
- const {
1844
- answer
1845
- } = responses && responses.length ? responses[0] : {};
1846
-
1847
- if (!answer) {
1848
- resolve({
1849
- id,
1850
- answers: {},
1851
- completeAnswer: ''
1852
- });
1853
- return;
1854
- }
1855
-
1856
- try {
1857
- const e = question.expression;
1858
- const RESPONSE_TOKEN = /\\{\\{\s*response\s*\\}\\}/g;
1859
- const o = escape(e).split(RESPONSE_TOKEN);
1860
- const to = o.map(t => t === '' ? t : t.replace(/\s+/g, () => '\\s*'));
1861
- const tt = to.join('(.*)');
1862
- const m = answer.match(new RegExp(tt));
1863
- const count = o.length - 1;
1864
-
1865
- if (!m) {
1866
- resolve({
1867
- id,
1868
- answers: {},
1869
- completeAnswer: answer
1870
- }); // eslint-disable-next-line no-console
1871
-
1872
- console.log(`can not find match: ${o} in ${answer}`);
1873
- return;
1874
- }
1875
-
1876
- m.shift();
1877
- const answers = {};
1878
-
1879
- for (var i = 0; i < count; i++) {
1880
- answers[`r${i + 1}`] = {
1881
- value: removeTrailingEscape(m[i].trim())
1882
- };
1883
- }
1884
-
1885
- resolve({
1886
- id,
1887
- answers,
1888
- completeAnswer: answer
1889
- });
1890
- } catch (e) {
1891
- resolve({
1892
- id,
1893
- answers: {},
1894
- completeAnswer: answer
1895
- }); // eslint-disable-next-line no-console
1896
-
1897
- console.error(e.toString());
1898
- }
1899
- });
1900
-
1901
- const createCorrectResponseSession = (question, env) => {
1902
- if (env.mode === 'evaluate' || env.role !== 'instructor') {
1903
- // eslint-disable-next-line no-console
1904
- console.error('can not create correct response session if mode is evaluate or role is not instructor');
1905
- return Promise.resolve(null);
1906
- }
1907
-
1908
- if ((question.responseType || '').toLowerCase() === 'simple') {
1909
- return simpleSessionResponse(question);
1910
- } else {
1911
- return advancedSessionResponse(question);
1912
- }
1913
- }; // remove all html tags
1914
-
1915
-
1916
- const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
1917
-
1918
- const validate = (model = {}, config = {}) => {
1919
- const {
1920
- expression = '',
1921
- responses,
1922
- responseType
1923
- } = model;
1924
- const {
1925
- maxResponseAreas
1926
- } = config;
1927
- const responsesErrors = {};
1928
- const errors = {};
1929
- ['teacherInstructions', 'prompt', 'rationale'].forEach(field => {
1930
- var _config$field;
1931
-
1932
- if ((_config$field = config[field]) != null && _config$field.required && !getContent(model[field])) {
1933
- errors[field] = 'This field is required.';
1934
- }
1935
- });
1936
- (responses || []).forEach((response, index) => {
1937
- const {
1938
- answer
1939
- } = response;
1940
- const reversedAlternates = [...Object.entries(response.alternates || {})].reverse();
1941
- const alternatesErrors = {};
1942
- const responseError = {};
1943
-
1944
- if (answer === '') {
1945
- responseError.answer = 'Content should not be empty.';
1946
- }
1947
-
1948
- reversedAlternates.forEach(([key, value], index) => {
1949
- if (value === '') {
1950
- alternatesErrors[key] = 'Content should not be empty.';
1951
- } else {
1952
- const identicalAnswer = answer === value || reversedAlternates.slice(index + 1).some(([, val]) => val === value);
1953
-
1954
- if (identicalAnswer) {
1955
- alternatesErrors[key] = 'Content should be unique.';
1956
- }
1957
- }
1958
- });
1959
-
1960
- if (!isEmpty_1(responseError) || !isEmpty_1(alternatesErrors)) {
1961
- responsesErrors[index] = _extends({}, responseError, alternatesErrors);
1962
- }
1963
- });
1964
-
1965
- if (responseType === 'Advanced Multi') {
1966
- const nbOfResponseAreas = (expression.match(/\{\{response\}\}/g) || []).length;
1967
-
1968
- if (nbOfResponseAreas > maxResponseAreas) {
1969
- errors.responseAreasError = `No more than ${maxResponseAreas} response areas should be defined.`;
1970
- } else if (nbOfResponseAreas < 1) {
1971
- errors.responseAreasError = 'There should be at least 1 response area defined.';
1972
- }
1973
- }
1974
-
1975
- if (!isEmpty_1(responsesErrors)) {
1976
- errors.responsesErrors = responsesErrors;
1977
- }
1978
-
1979
- return errors;
1980
- };
1981
-
1982
- export { createCorrectResponseSession, createDefaultModel, model, normalize, outcome, validate };
1983
- //# sourceMappingURL=controller.js.map