@pie-element/passage 7.1.2-next.5 → 7.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.json +227 -0
  2. package/CHANGELOG.md +1473 -0
  3. package/LICENSE.md +5 -0
  4. package/README.md +3 -0
  5. package/configure/CHANGELOG.md +685 -0
  6. package/configure/lib/common.js +74 -0
  7. package/configure/lib/common.js.map +1 -0
  8. package/configure/lib/defaults.js +174 -0
  9. package/configure/lib/defaults.js.map +1 -0
  10. package/configure/lib/design.js +185 -0
  11. package/configure/lib/design.js.map +1 -0
  12. package/configure/lib/index.js +87 -0
  13. package/configure/lib/index.js.map +1 -0
  14. package/configure/lib/passage.js +194 -0
  15. package/configure/lib/passage.js.map +1 -0
  16. package/configure/package.json +23 -0
  17. package/controller/CHANGELOG.json +1 -0
  18. package/controller/CHANGELOG.md +113 -0
  19. package/controller/lib/defaults.js +23 -0
  20. package/controller/lib/defaults.js.map +1 -0
  21. package/controller/lib/index.js +80 -0
  22. package/controller/lib/index.js.map +1 -0
  23. package/controller/package.json +13 -0
  24. package/docs/config-schema.json +1325 -0
  25. package/docs/config-schema.json.md +974 -0
  26. package/docs/demo/config.js +8 -0
  27. package/docs/demo/generate.js +32 -0
  28. package/docs/demo/index.html +1 -0
  29. package/docs/pie-schema.json +775 -0
  30. package/docs/pie-schema.json.md +561 -0
  31. package/lib/index.js +144 -0
  32. package/lib/index.js.map +1 -0
  33. package/lib/print.js +78 -0
  34. package/lib/print.js.map +1 -0
  35. package/lib/stimulus-tabs.js +427 -0
  36. package/lib/stimulus-tabs.js.map +1 -0
  37. package/module/configure.js +1 -0
  38. package/module/controller.js +920 -0
  39. package/module/demo.js +57 -0
  40. package/module/element.js +1 -0
  41. package/module/index.html +21 -0
  42. package/module/manifest.json +10 -0
  43. package/module/print-demo.js +95 -0
  44. package/module/print.html +18 -0
  45. package/module/print.js +1 -0
  46. package/package.json +19 -86
  47. package/configure.js +0 -2
  48. package/controller.js +0 -1
  49. package/dist/author/common.d.ts +0 -36
  50. package/dist/author/common.js +0 -56
  51. package/dist/author/defaults.d.ts +0 -175
  52. package/dist/author/defaults.js +0 -113
  53. package/dist/author/design.d.ts +0 -28
  54. package/dist/author/design.js +0 -120
  55. package/dist/author/index.d.ts +0 -36
  56. package/dist/author/index.js +0 -66
  57. package/dist/author/passage.d.ts +0 -27
  58. package/dist/author/passage.js +0 -127
  59. package/dist/browser/author/index.js +0 -44688
  60. package/dist/browser/author/index.js.map +0 -1
  61. package/dist/browser/controller/index.js +0 -64
  62. package/dist/browser/controller/index.js.map +0 -1
  63. package/dist/browser/delivery/index.js +0 -117
  64. package/dist/browser/delivery/index.js.map +0 -1
  65. package/dist/browser/dist-ByX3voUB.js +0 -9618
  66. package/dist/browser/dist-ByX3voUB.js.map +0 -1
  67. package/dist/browser/dist-CeIdmqCq.js +0 -92
  68. package/dist/browser/dist-CeIdmqCq.js.map +0 -1
  69. package/dist/browser/passage.css +0 -2
  70. package/dist/browser/print/index.js +0 -48
  71. package/dist/browser/print/index.js.map +0 -1
  72. package/dist/browser/stimulus-tabs-CxiQ79gz.js +0 -218
  73. package/dist/browser/stimulus-tabs-CxiQ79gz.js.map +0 -1
  74. package/dist/controller/defaults.d.ts +0 -23
  75. package/dist/controller/defaults.js +0 -17
  76. package/dist/controller/index.d.ts +0 -18
  77. package/dist/controller/index.js +0 -50
  78. package/dist/delivery/index.d.ts +0 -22
  79. package/dist/delivery/index.js +0 -83
  80. package/dist/delivery/stimulus-tabs.d.ts +0 -21
  81. package/dist/delivery/stimulus-tabs.js +0 -220
  82. package/dist/index.d.ts +0 -1
  83. package/dist/index.iife.d.ts +0 -8
  84. package/dist/index.iife.js +0 -145
  85. package/dist/index.js +0 -2
  86. package/dist/print/index.d.ts +0 -15
  87. package/dist/print/index.js +0 -47
  88. package/dist/runtime-support.d.ts +0 -12
  89. package/dist/runtime-support.js +0 -12
@@ -0,0 +1,920 @@
1
+ /** Detect free variable `global` from Node.js. */
2
+ var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
3
+
4
+ var freeGlobal$1 = freeGlobal;
5
+
6
+ /** Detect free variable `self`. */
7
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
8
+
9
+ /** Used as a reference to the global object. */
10
+ var root = freeGlobal$1 || freeSelf || Function('return this')();
11
+
12
+ var root$1 = root;
13
+
14
+ /** Built-in value references. */
15
+ var Symbol = root$1.Symbol;
16
+
17
+ var Symbol$1 = Symbol;
18
+
19
+ /** Used for built-in method references. */
20
+ var objectProto$6 = Object.prototype;
21
+
22
+ /** Used to check objects for own properties. */
23
+ var hasOwnProperty$4 = objectProto$6.hasOwnProperty;
24
+
25
+ /**
26
+ * Used to resolve the
27
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
28
+ * of values.
29
+ */
30
+ var nativeObjectToString$1 = objectProto$6.toString;
31
+
32
+ /** Built-in value references. */
33
+ var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
34
+
35
+ /**
36
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
37
+ *
38
+ * @private
39
+ * @param {*} value The value to query.
40
+ * @returns {string} Returns the raw `toStringTag`.
41
+ */
42
+ function getRawTag(value) {
43
+ var isOwn = hasOwnProperty$4.call(value, symToStringTag$1),
44
+ tag = value[symToStringTag$1];
45
+
46
+ try {
47
+ value[symToStringTag$1] = undefined;
48
+ var unmasked = true;
49
+ } catch (e) {}
50
+
51
+ var result = nativeObjectToString$1.call(value);
52
+ if (unmasked) {
53
+ if (isOwn) {
54
+ value[symToStringTag$1] = tag;
55
+ } else {
56
+ delete value[symToStringTag$1];
57
+ }
58
+ }
59
+ return result;
60
+ }
61
+
62
+ /** Used for built-in method references. */
63
+ var objectProto$5 = Object.prototype;
64
+
65
+ /**
66
+ * Used to resolve the
67
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
68
+ * of values.
69
+ */
70
+ var nativeObjectToString = objectProto$5.toString;
71
+
72
+ /**
73
+ * Converts `value` to a string using `Object.prototype.toString`.
74
+ *
75
+ * @private
76
+ * @param {*} value The value to convert.
77
+ * @returns {string} Returns the converted string.
78
+ */
79
+ function objectToString(value) {
80
+ return nativeObjectToString.call(value);
81
+ }
82
+
83
+ /** `Object#toString` result references. */
84
+ var nullTag = '[object Null]',
85
+ undefinedTag = '[object Undefined]';
86
+
87
+ /** Built-in value references. */
88
+ var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
89
+
90
+ /**
91
+ * The base implementation of `getTag` without fallbacks for buggy environments.
92
+ *
93
+ * @private
94
+ * @param {*} value The value to query.
95
+ * @returns {string} Returns the `toStringTag`.
96
+ */
97
+ function baseGetTag(value) {
98
+ if (value == null) {
99
+ return value === undefined ? undefinedTag : nullTag;
100
+ }
101
+ return (symToStringTag && symToStringTag in Object(value))
102
+ ? getRawTag(value)
103
+ : objectToString(value);
104
+ }
105
+
106
+ /**
107
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
108
+ * and has a `typeof` result of "object".
109
+ *
110
+ * @static
111
+ * @memberOf _
112
+ * @since 4.0.0
113
+ * @category Lang
114
+ * @param {*} value The value to check.
115
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
116
+ * @example
117
+ *
118
+ * _.isObjectLike({});
119
+ * // => true
120
+ *
121
+ * _.isObjectLike([1, 2, 3]);
122
+ * // => true
123
+ *
124
+ * _.isObjectLike(_.noop);
125
+ * // => false
126
+ *
127
+ * _.isObjectLike(null);
128
+ * // => false
129
+ */
130
+ function isObjectLike(value) {
131
+ return value != null && typeof value == 'object';
132
+ }
133
+
134
+ /**
135
+ * Checks if `value` is classified as an `Array` object.
136
+ *
137
+ * @static
138
+ * @memberOf _
139
+ * @since 0.1.0
140
+ * @category Lang
141
+ * @param {*} value The value to check.
142
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
143
+ * @example
144
+ *
145
+ * _.isArray([1, 2, 3]);
146
+ * // => true
147
+ *
148
+ * _.isArray(document.body.children);
149
+ * // => false
150
+ *
151
+ * _.isArray('abc');
152
+ * // => false
153
+ *
154
+ * _.isArray(_.noop);
155
+ * // => false
156
+ */
157
+ var isArray = Array.isArray;
158
+
159
+ var isArray$1 = isArray;
160
+
161
+ /**
162
+ * Checks if `value` is the
163
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
164
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
165
+ *
166
+ * @static
167
+ * @memberOf _
168
+ * @since 0.1.0
169
+ * @category Lang
170
+ * @param {*} value The value to check.
171
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
172
+ * @example
173
+ *
174
+ * _.isObject({});
175
+ * // => true
176
+ *
177
+ * _.isObject([1, 2, 3]);
178
+ * // => true
179
+ *
180
+ * _.isObject(_.noop);
181
+ * // => true
182
+ *
183
+ * _.isObject(null);
184
+ * // => false
185
+ */
186
+ function isObject(value) {
187
+ var type = typeof value;
188
+ return value != null && (type == 'object' || type == 'function');
189
+ }
190
+
191
+ /** `Object#toString` result references. */
192
+ var asyncTag = '[object AsyncFunction]',
193
+ funcTag$1 = '[object Function]',
194
+ genTag = '[object GeneratorFunction]',
195
+ proxyTag = '[object Proxy]';
196
+
197
+ /**
198
+ * Checks if `value` is classified as a `Function` object.
199
+ *
200
+ * @static
201
+ * @memberOf _
202
+ * @since 0.1.0
203
+ * @category Lang
204
+ * @param {*} value The value to check.
205
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
206
+ * @example
207
+ *
208
+ * _.isFunction(_);
209
+ * // => true
210
+ *
211
+ * _.isFunction(/abc/);
212
+ * // => false
213
+ */
214
+ function isFunction(value) {
215
+ if (!isObject(value)) {
216
+ return false;
217
+ }
218
+ // The use of `Object#toString` avoids issues with the `typeof` operator
219
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
220
+ var tag = baseGetTag(value);
221
+ return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
222
+ }
223
+
224
+ /** Used to detect overreaching core-js shims. */
225
+ var coreJsData = root$1['__core-js_shared__'];
226
+
227
+ var coreJsData$1 = coreJsData;
228
+
229
+ /** Used to detect methods masquerading as native. */
230
+ var maskSrcKey = (function() {
231
+ var uid = /[^.]+$/.exec(coreJsData$1 && coreJsData$1.keys && coreJsData$1.keys.IE_PROTO || '');
232
+ return uid ? ('Symbol(src)_1.' + uid) : '';
233
+ }());
234
+
235
+ /**
236
+ * Checks if `func` has its source masked.
237
+ *
238
+ * @private
239
+ * @param {Function} func The function to check.
240
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
241
+ */
242
+ function isMasked(func) {
243
+ return !!maskSrcKey && (maskSrcKey in func);
244
+ }
245
+
246
+ /** Used for built-in method references. */
247
+ var funcProto$1 = Function.prototype;
248
+
249
+ /** Used to resolve the decompiled source of functions. */
250
+ var funcToString$1 = funcProto$1.toString;
251
+
252
+ /**
253
+ * Converts `func` to its source code.
254
+ *
255
+ * @private
256
+ * @param {Function} func The function to convert.
257
+ * @returns {string} Returns the source code.
258
+ */
259
+ function toSource(func) {
260
+ if (func != null) {
261
+ try {
262
+ return funcToString$1.call(func);
263
+ } catch (e) {}
264
+ try {
265
+ return (func + '');
266
+ } catch (e) {}
267
+ }
268
+ return '';
269
+ }
270
+
271
+ /**
272
+ * Used to match `RegExp`
273
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
274
+ */
275
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
276
+
277
+ /** Used to detect host constructors (Safari). */
278
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
279
+
280
+ /** Used for built-in method references. */
281
+ var funcProto = Function.prototype,
282
+ objectProto$4 = Object.prototype;
283
+
284
+ /** Used to resolve the decompiled source of functions. */
285
+ var funcToString = funcProto.toString;
286
+
287
+ /** Used to check objects for own properties. */
288
+ var hasOwnProperty$3 = objectProto$4.hasOwnProperty;
289
+
290
+ /** Used to detect if a method is native. */
291
+ var reIsNative = RegExp('^' +
292
+ funcToString.call(hasOwnProperty$3).replace(reRegExpChar, '\\$&')
293
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
294
+ );
295
+
296
+ /**
297
+ * The base implementation of `_.isNative` without bad shim checks.
298
+ *
299
+ * @private
300
+ * @param {*} value The value to check.
301
+ * @returns {boolean} Returns `true` if `value` is a native function,
302
+ * else `false`.
303
+ */
304
+ function baseIsNative(value) {
305
+ if (!isObject(value) || isMasked(value)) {
306
+ return false;
307
+ }
308
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
309
+ return pattern.test(toSource(value));
310
+ }
311
+
312
+ /**
313
+ * Gets the value at `key` of `object`.
314
+ *
315
+ * @private
316
+ * @param {Object} [object] The object to query.
317
+ * @param {string} key The key of the property to get.
318
+ * @returns {*} Returns the property value.
319
+ */
320
+ function getValue(object, key) {
321
+ return object == null ? undefined : object[key];
322
+ }
323
+
324
+ /**
325
+ * Gets the native function at `key` of `object`.
326
+ *
327
+ * @private
328
+ * @param {Object} object The object to query.
329
+ * @param {string} key The key of the method to get.
330
+ * @returns {*} Returns the function if it's native, else `undefined`.
331
+ */
332
+ function getNative(object, key) {
333
+ var value = getValue(object, key);
334
+ return baseIsNative(value) ? value : undefined;
335
+ }
336
+
337
+ /* Built-in method references that are verified to be native. */
338
+ var WeakMap = getNative(root$1, 'WeakMap');
339
+
340
+ var WeakMap$1 = WeakMap;
341
+
342
+ /** Used as references for various `Number` constants. */
343
+ var MAX_SAFE_INTEGER = 9007199254740991;
344
+
345
+ /**
346
+ * Checks if `value` is a valid array-like length.
347
+ *
348
+ * **Note:** This method is loosely based on
349
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
350
+ *
351
+ * @static
352
+ * @memberOf _
353
+ * @since 4.0.0
354
+ * @category Lang
355
+ * @param {*} value The value to check.
356
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
357
+ * @example
358
+ *
359
+ * _.isLength(3);
360
+ * // => true
361
+ *
362
+ * _.isLength(Number.MIN_VALUE);
363
+ * // => false
364
+ *
365
+ * _.isLength(Infinity);
366
+ * // => false
367
+ *
368
+ * _.isLength('3');
369
+ * // => false
370
+ */
371
+ function isLength(value) {
372
+ return typeof value == 'number' &&
373
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
374
+ }
375
+
376
+ /**
377
+ * Checks if `value` is array-like. A value is considered array-like if it's
378
+ * not a function and has a `value.length` that's an integer greater than or
379
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
380
+ *
381
+ * @static
382
+ * @memberOf _
383
+ * @since 4.0.0
384
+ * @category Lang
385
+ * @param {*} value The value to check.
386
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
387
+ * @example
388
+ *
389
+ * _.isArrayLike([1, 2, 3]);
390
+ * // => true
391
+ *
392
+ * _.isArrayLike(document.body.children);
393
+ * // => true
394
+ *
395
+ * _.isArrayLike('abc');
396
+ * // => true
397
+ *
398
+ * _.isArrayLike(_.noop);
399
+ * // => false
400
+ */
401
+ function isArrayLike(value) {
402
+ return value != null && isLength(value.length) && !isFunction(value);
403
+ }
404
+
405
+ /** Used for built-in method references. */
406
+ var objectProto$3 = Object.prototype;
407
+
408
+ /**
409
+ * Checks if `value` is likely a prototype object.
410
+ *
411
+ * @private
412
+ * @param {*} value The value to check.
413
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
414
+ */
415
+ function isPrototype(value) {
416
+ var Ctor = value && value.constructor,
417
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$3;
418
+
419
+ return value === proto;
420
+ }
421
+
422
+ /** `Object#toString` result references. */
423
+ var argsTag$1 = '[object Arguments]';
424
+
425
+ /**
426
+ * The base implementation of `_.isArguments`.
427
+ *
428
+ * @private
429
+ * @param {*} value The value to check.
430
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
431
+ */
432
+ function baseIsArguments(value) {
433
+ return isObjectLike(value) && baseGetTag(value) == argsTag$1;
434
+ }
435
+
436
+ /** Used for built-in method references. */
437
+ var objectProto$2 = Object.prototype;
438
+
439
+ /** Used to check objects for own properties. */
440
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
441
+
442
+ /** Built-in value references. */
443
+ var propertyIsEnumerable = objectProto$2.propertyIsEnumerable;
444
+
445
+ /**
446
+ * Checks if `value` is likely an `arguments` object.
447
+ *
448
+ * @static
449
+ * @memberOf _
450
+ * @since 0.1.0
451
+ * @category Lang
452
+ * @param {*} value The value to check.
453
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
454
+ * else `false`.
455
+ * @example
456
+ *
457
+ * _.isArguments(function() { return arguments; }());
458
+ * // => true
459
+ *
460
+ * _.isArguments([1, 2, 3]);
461
+ * // => false
462
+ */
463
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
464
+ return isObjectLike(value) && hasOwnProperty$2.call(value, 'callee') &&
465
+ !propertyIsEnumerable.call(value, 'callee');
466
+ };
467
+
468
+ var isArguments$1 = isArguments;
469
+
470
+ /**
471
+ * This method returns `false`.
472
+ *
473
+ * @static
474
+ * @memberOf _
475
+ * @since 4.13.0
476
+ * @category Util
477
+ * @returns {boolean} Returns `false`.
478
+ * @example
479
+ *
480
+ * _.times(2, _.stubFalse);
481
+ * // => [false, false]
482
+ */
483
+ function stubFalse() {
484
+ return false;
485
+ }
486
+
487
+ /** Detect free variable `exports`. */
488
+ var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
489
+
490
+ /** Detect free variable `module`. */
491
+ var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
492
+
493
+ /** Detect the popular CommonJS extension `module.exports`. */
494
+ var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
495
+
496
+ /** Built-in value references. */
497
+ var Buffer = moduleExports$1 ? root$1.Buffer : undefined;
498
+
499
+ /* Built-in method references for those with the same name as other `lodash` methods. */
500
+ var nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined;
501
+
502
+ /**
503
+ * Checks if `value` is a buffer.
504
+ *
505
+ * @static
506
+ * @memberOf _
507
+ * @since 4.3.0
508
+ * @category Lang
509
+ * @param {*} value The value to check.
510
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
511
+ * @example
512
+ *
513
+ * _.isBuffer(new Buffer(2));
514
+ * // => true
515
+ *
516
+ * _.isBuffer(new Uint8Array(2));
517
+ * // => false
518
+ */
519
+ var isBuffer = nativeIsBuffer || stubFalse;
520
+
521
+ var isBuffer$1 = isBuffer;
522
+
523
+ /** `Object#toString` result references. */
524
+ var argsTag = '[object Arguments]',
525
+ arrayTag = '[object Array]',
526
+ boolTag = '[object Boolean]',
527
+ dateTag = '[object Date]',
528
+ errorTag = '[object Error]',
529
+ funcTag = '[object Function]',
530
+ mapTag$2 = '[object Map]',
531
+ numberTag = '[object Number]',
532
+ objectTag$1 = '[object Object]',
533
+ regexpTag = '[object RegExp]',
534
+ setTag$2 = '[object Set]',
535
+ stringTag = '[object String]',
536
+ weakMapTag$1 = '[object WeakMap]';
537
+
538
+ var arrayBufferTag = '[object ArrayBuffer]',
539
+ dataViewTag$1 = '[object DataView]',
540
+ float32Tag = '[object Float32Array]',
541
+ float64Tag = '[object Float64Array]',
542
+ int8Tag = '[object Int8Array]',
543
+ int16Tag = '[object Int16Array]',
544
+ int32Tag = '[object Int32Array]',
545
+ uint8Tag = '[object Uint8Array]',
546
+ uint8ClampedTag = '[object Uint8ClampedArray]',
547
+ uint16Tag = '[object Uint16Array]',
548
+ uint32Tag = '[object Uint32Array]';
549
+
550
+ /** Used to identify `toStringTag` values of typed arrays. */
551
+ var typedArrayTags = {};
552
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
553
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
554
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
555
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
556
+ typedArrayTags[uint32Tag] = true;
557
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
558
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
559
+ typedArrayTags[dataViewTag$1] = typedArrayTags[dateTag] =
560
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
561
+ typedArrayTags[mapTag$2] = typedArrayTags[numberTag] =
562
+ typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
563
+ typedArrayTags[setTag$2] = typedArrayTags[stringTag] =
564
+ typedArrayTags[weakMapTag$1] = false;
565
+
566
+ /**
567
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
568
+ *
569
+ * @private
570
+ * @param {*} value The value to check.
571
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
572
+ */
573
+ function baseIsTypedArray(value) {
574
+ return isObjectLike(value) &&
575
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
576
+ }
577
+
578
+ /**
579
+ * The base implementation of `_.unary` without support for storing metadata.
580
+ *
581
+ * @private
582
+ * @param {Function} func The function to cap arguments for.
583
+ * @returns {Function} Returns the new capped function.
584
+ */
585
+ function baseUnary(func) {
586
+ return function(value) {
587
+ return func(value);
588
+ };
589
+ }
590
+
591
+ /** Detect free variable `exports`. */
592
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
593
+
594
+ /** Detect free variable `module`. */
595
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
596
+
597
+ /** Detect the popular CommonJS extension `module.exports`. */
598
+ var moduleExports = freeModule && freeModule.exports === freeExports;
599
+
600
+ /** Detect free variable `process` from Node.js. */
601
+ var freeProcess = moduleExports && freeGlobal$1.process;
602
+
603
+ /** Used to access faster Node.js helpers. */
604
+ var nodeUtil = (function() {
605
+ try {
606
+ // Use `util.types` for Node.js 10+.
607
+ var types = freeModule && freeModule.require && freeModule.require('util').types;
608
+
609
+ if (types) {
610
+ return types;
611
+ }
612
+
613
+ // Legacy `process.binding('util')` for Node.js < 10.
614
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
615
+ } catch (e) {}
616
+ }());
617
+
618
+ var nodeUtil$1 = nodeUtil;
619
+
620
+ /* Node.js helper references. */
621
+ var nodeIsTypedArray = nodeUtil$1 && nodeUtil$1.isTypedArray;
622
+
623
+ /**
624
+ * Checks if `value` is classified as a typed array.
625
+ *
626
+ * @static
627
+ * @memberOf _
628
+ * @since 3.0.0
629
+ * @category Lang
630
+ * @param {*} value The value to check.
631
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
632
+ * @example
633
+ *
634
+ * _.isTypedArray(new Uint8Array);
635
+ * // => true
636
+ *
637
+ * _.isTypedArray([]);
638
+ * // => false
639
+ */
640
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
641
+
642
+ var isTypedArray$1 = isTypedArray;
643
+
644
+ /**
645
+ * Creates a unary function that invokes `func` with its argument transformed.
646
+ *
647
+ * @private
648
+ * @param {Function} func The function to wrap.
649
+ * @param {Function} transform The argument transform.
650
+ * @returns {Function} Returns the new function.
651
+ */
652
+ function overArg(func, transform) {
653
+ return function(arg) {
654
+ return func(transform(arg));
655
+ };
656
+ }
657
+
658
+ /* Built-in method references for those with the same name as other `lodash` methods. */
659
+ var nativeKeys = overArg(Object.keys, Object);
660
+
661
+ var nativeKeys$1 = nativeKeys;
662
+
663
+ /** Used for built-in method references. */
664
+ var objectProto$1 = Object.prototype;
665
+
666
+ /** Used to check objects for own properties. */
667
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
668
+
669
+ /**
670
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
671
+ *
672
+ * @private
673
+ * @param {Object} object The object to query.
674
+ * @returns {Array} Returns the array of property names.
675
+ */
676
+ function baseKeys(object) {
677
+ if (!isPrototype(object)) {
678
+ return nativeKeys$1(object);
679
+ }
680
+ var result = [];
681
+ for (var key in Object(object)) {
682
+ if (hasOwnProperty$1.call(object, key) && key != 'constructor') {
683
+ result.push(key);
684
+ }
685
+ }
686
+ return result;
687
+ }
688
+
689
+ /* Built-in method references that are verified to be native. */
690
+ var Map = getNative(root$1, 'Map');
691
+
692
+ var Map$1 = Map;
693
+
694
+ /* Built-in method references that are verified to be native. */
695
+ var DataView = getNative(root$1, 'DataView');
696
+
697
+ var DataView$1 = DataView;
698
+
699
+ /* Built-in method references that are verified to be native. */
700
+ var Promise$1 = getNative(root$1, 'Promise');
701
+
702
+ var Promise$2 = Promise$1;
703
+
704
+ /* Built-in method references that are verified to be native. */
705
+ var Set = getNative(root$1, 'Set');
706
+
707
+ var Set$1 = Set;
708
+
709
+ /** `Object#toString` result references. */
710
+ var mapTag$1 = '[object Map]',
711
+ objectTag = '[object Object]',
712
+ promiseTag = '[object Promise]',
713
+ setTag$1 = '[object Set]',
714
+ weakMapTag = '[object WeakMap]';
715
+
716
+ var dataViewTag = '[object DataView]';
717
+
718
+ /** Used to detect maps, sets, and weakmaps. */
719
+ var dataViewCtorString = toSource(DataView$1),
720
+ mapCtorString = toSource(Map$1),
721
+ promiseCtorString = toSource(Promise$2),
722
+ setCtorString = toSource(Set$1),
723
+ weakMapCtorString = toSource(WeakMap$1);
724
+
725
+ /**
726
+ * Gets the `toStringTag` of `value`.
727
+ *
728
+ * @private
729
+ * @param {*} value The value to query.
730
+ * @returns {string} Returns the `toStringTag`.
731
+ */
732
+ var getTag = baseGetTag;
733
+
734
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
735
+ if ((DataView$1 && getTag(new DataView$1(new ArrayBuffer(1))) != dataViewTag) ||
736
+ (Map$1 && getTag(new Map$1) != mapTag$1) ||
737
+ (Promise$2 && getTag(Promise$2.resolve()) != promiseTag) ||
738
+ (Set$1 && getTag(new Set$1) != setTag$1) ||
739
+ (WeakMap$1 && getTag(new WeakMap$1) != weakMapTag)) {
740
+ getTag = function(value) {
741
+ var result = baseGetTag(value),
742
+ Ctor = result == objectTag ? value.constructor : undefined,
743
+ ctorString = Ctor ? toSource(Ctor) : '';
744
+
745
+ if (ctorString) {
746
+ switch (ctorString) {
747
+ case dataViewCtorString: return dataViewTag;
748
+ case mapCtorString: return mapTag$1;
749
+ case promiseCtorString: return promiseTag;
750
+ case setCtorString: return setTag$1;
751
+ case weakMapCtorString: return weakMapTag;
752
+ }
753
+ }
754
+ return result;
755
+ };
756
+ }
757
+
758
+ var getTag$1 = getTag;
759
+
760
+ /** `Object#toString` result references. */
761
+ var mapTag = '[object Map]',
762
+ setTag = '[object Set]';
763
+
764
+ /** Used for built-in method references. */
765
+ var objectProto = Object.prototype;
766
+
767
+ /** Used to check objects for own properties. */
768
+ var hasOwnProperty = objectProto.hasOwnProperty;
769
+
770
+ /**
771
+ * Checks if `value` is an empty object, collection, map, or set.
772
+ *
773
+ * Objects are considered empty if they have no own enumerable string keyed
774
+ * properties.
775
+ *
776
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
777
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
778
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
779
+ *
780
+ * @static
781
+ * @memberOf _
782
+ * @since 0.1.0
783
+ * @category Lang
784
+ * @param {*} value The value to check.
785
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
786
+ * @example
787
+ *
788
+ * _.isEmpty(null);
789
+ * // => true
790
+ *
791
+ * _.isEmpty(true);
792
+ * // => true
793
+ *
794
+ * _.isEmpty(1);
795
+ * // => true
796
+ *
797
+ * _.isEmpty([1, 2, 3]);
798
+ * // => false
799
+ *
800
+ * _.isEmpty({ 'a': 1 });
801
+ * // => false
802
+ */
803
+ function isEmpty(value) {
804
+ if (value == null) {
805
+ return true;
806
+ }
807
+ if (isArrayLike(value) &&
808
+ (isArray$1(value) || typeof value == 'string' || typeof value.splice == 'function' ||
809
+ isBuffer$1(value) || isTypedArray$1(value) || isArguments$1(value))) {
810
+ return !value.length;
811
+ }
812
+ var tag = getTag$1(value);
813
+ if (tag == mapTag || tag == setTag) {
814
+ return !value.size;
815
+ }
816
+ if (isPrototype(value)) {
817
+ return !baseKeys(value).length;
818
+ }
819
+ for (var key in value) {
820
+ if (hasOwnProperty.call(value, key)) {
821
+ return false;
822
+ }
823
+ }
824
+ return true;
825
+ }
826
+
827
+ // TODO: also update '../../configure/src/defaults.js' and '../../src/print.js' when updating defaults
828
+ var defaults = {
829
+ authorEnabled: false, // TODO: should be set to true when all Studio content is updated
830
+ passages: [
831
+ {
832
+ teacherInstructions: '',
833
+ title: '',
834
+ subtitle: '',
835
+ author: '',
836
+ text: '',
837
+ },
838
+ ],
839
+ subtitleEnabled: true,
840
+ teacherInstructionsEnabled: true,
841
+ textEnabled: true,
842
+ titleEnabled: true,
843
+ };
844
+
845
+ const getContent = (html) => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
846
+
847
+ const checkNullish = (value) => value !== null && value !== undefined;
848
+
849
+ const isEnabled = (value, defaultValue) => (checkNullish(value) ? value : defaultValue);
850
+
851
+ function createDefaultModel(model = {}) {
852
+ return new Promise((resolve) => {
853
+ resolve({ ...defaults, ...model });
854
+ });
855
+ }
856
+
857
+ const normalize = (question) => ({ ...defaults, ...question });
858
+
859
+ const normalizeTeacherInstructions = (instructions, env) => {
860
+ const { role, mode } = env;
861
+
862
+ if (role === 'instructor' && (mode === 'view' || mode === 'evaluate')) {
863
+ return instructions || '';
864
+ }
865
+
866
+ return '';
867
+ };
868
+
869
+ /**
870
+ *
871
+ * @param {*} question
872
+ * @param {*} session
873
+ * @param {*} env
874
+ */
875
+ async function model(question, session, env) {
876
+ const normalizedQuestion = normalize(question);
877
+
878
+ const normalizedPassages = normalizedQuestion.passages.map((passage, index) => ({
879
+ teacherInstructions: isEnabled(passage.teacherInstructionsEnabled, normalizedQuestion.teacherInstructionsEnabled)
880
+ ? normalizeTeacherInstructions(passage.teacherInstructions, env)
881
+ : '',
882
+ label: getContent(passage.title) ? passage.title : `Passage ${index + 1}`,
883
+ title: isEnabled(passage.titleEnabled, normalizedQuestion.titleEnabled) ? passage.title || '' : '',
884
+ subtitle: isEnabled(passage.subtitleEnabled, normalizedQuestion.subtitleEnabled) ? passage.subtitle || '' : '',
885
+ author: isEnabled(passage.authorEnabled, normalizedQuestion.authorEnabled) ? passage.author || '' : '',
886
+ text: isEnabled(passage.textEnabled, normalizedQuestion.textEnabled) ? passage.text || '' : '',
887
+ }));
888
+
889
+ return {
890
+ ...normalizedQuestion,
891
+ passages: normalizedPassages,
892
+ };
893
+ }
894
+
895
+ const validate = (model = {}, config = {}) => {
896
+ const errors = {};
897
+ const passagesErrors = {};
898
+
899
+ (model.passages || []).forEach((passage, index) => {
900
+ const err = {};
901
+
902
+ ['teacherInstructions', 'title', 'subtitle', 'author', 'text'].forEach((field) => {
903
+ if (config[field]?.required && !getContent(passage[field])) {
904
+ err[field] = 'This field is required.';
905
+ }
906
+ });
907
+
908
+ if (!isEmpty(err)) {
909
+ passagesErrors[index] = err;
910
+ }
911
+ });
912
+
913
+ if (!isEmpty(passagesErrors)) {
914
+ errors.passages = passagesErrors;
915
+ }
916
+
917
+ return errors;
918
+ };
919
+
920
+ export { createDefaultModel, model, normalize, validate };