@pie-element/drawing-response 10.3.4-next.0 → 10.3.4-next.3

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.
@@ -0,0 +1,814 @@
1
+ function _extends() {
2
+ _extends = Object.assign || function (target) {
3
+ for (var i = 1; i < arguments.length; i++) {
4
+ var source = arguments[i];
5
+
6
+ for (var key in source) {
7
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
8
+ target[key] = source[key];
9
+ }
10
+ }
11
+ }
12
+
13
+ return target;
14
+ };
15
+
16
+ return _extends.apply(this, arguments);
17
+ }
18
+
19
+ var browser = {exports: {}};
20
+
21
+ /**
22
+ * Helpers.
23
+ */
24
+
25
+ var s = 1000;
26
+ var m = s * 60;
27
+ var h = m * 60;
28
+ var d = h * 24;
29
+ var w = d * 7;
30
+ var y = d * 365.25;
31
+
32
+ /**
33
+ * Parse or format the given `val`.
34
+ *
35
+ * Options:
36
+ *
37
+ * - `long` verbose formatting [false]
38
+ *
39
+ * @param {String|Number} val
40
+ * @param {Object} [options]
41
+ * @throws {Error} throw an error if val is not a non-empty string or a number
42
+ * @return {String|Number}
43
+ * @api public
44
+ */
45
+
46
+ var ms = function(val, options) {
47
+ options = options || {};
48
+ var type = typeof val;
49
+ if (type === 'string' && val.length > 0) {
50
+ return parse(val);
51
+ } else if (type === 'number' && isFinite(val)) {
52
+ return options.long ? fmtLong(val) : fmtShort(val);
53
+ }
54
+ throw new Error(
55
+ 'val is not a non-empty string or a valid number. val=' +
56
+ JSON.stringify(val)
57
+ );
58
+ };
59
+
60
+ /**
61
+ * Parse the given `str` and return milliseconds.
62
+ *
63
+ * @param {String} str
64
+ * @return {Number}
65
+ * @api private
66
+ */
67
+
68
+ function parse(str) {
69
+ str = String(str);
70
+ if (str.length > 100) {
71
+ return;
72
+ }
73
+ 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(
74
+ str
75
+ );
76
+ if (!match) {
77
+ return;
78
+ }
79
+ var n = parseFloat(match[1]);
80
+ var type = (match[2] || 'ms').toLowerCase();
81
+ switch (type) {
82
+ case 'years':
83
+ case 'year':
84
+ case 'yrs':
85
+ case 'yr':
86
+ case 'y':
87
+ return n * y;
88
+ case 'weeks':
89
+ case 'week':
90
+ case 'w':
91
+ return n * w;
92
+ case 'days':
93
+ case 'day':
94
+ case 'd':
95
+ return n * d;
96
+ case 'hours':
97
+ case 'hour':
98
+ case 'hrs':
99
+ case 'hr':
100
+ case 'h':
101
+ return n * h;
102
+ case 'minutes':
103
+ case 'minute':
104
+ case 'mins':
105
+ case 'min':
106
+ case 'm':
107
+ return n * m;
108
+ case 'seconds':
109
+ case 'second':
110
+ case 'secs':
111
+ case 'sec':
112
+ case 's':
113
+ return n * s;
114
+ case 'milliseconds':
115
+ case 'millisecond':
116
+ case 'msecs':
117
+ case 'msec':
118
+ case 'ms':
119
+ return n;
120
+ default:
121
+ return undefined;
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Short format for `ms`.
127
+ *
128
+ * @param {Number} ms
129
+ * @return {String}
130
+ * @api private
131
+ */
132
+
133
+ function fmtShort(ms) {
134
+ var msAbs = Math.abs(ms);
135
+ if (msAbs >= d) {
136
+ return Math.round(ms / d) + 'd';
137
+ }
138
+ if (msAbs >= h) {
139
+ return Math.round(ms / h) + 'h';
140
+ }
141
+ if (msAbs >= m) {
142
+ return Math.round(ms / m) + 'm';
143
+ }
144
+ if (msAbs >= s) {
145
+ return Math.round(ms / s) + 's';
146
+ }
147
+ return ms + 'ms';
148
+ }
149
+
150
+ /**
151
+ * Long format for `ms`.
152
+ *
153
+ * @param {Number} ms
154
+ * @return {String}
155
+ * @api private
156
+ */
157
+
158
+ function fmtLong(ms) {
159
+ var msAbs = Math.abs(ms);
160
+ if (msAbs >= d) {
161
+ return plural(ms, msAbs, d, 'day');
162
+ }
163
+ if (msAbs >= h) {
164
+ return plural(ms, msAbs, h, 'hour');
165
+ }
166
+ if (msAbs >= m) {
167
+ return plural(ms, msAbs, m, 'minute');
168
+ }
169
+ if (msAbs >= s) {
170
+ return plural(ms, msAbs, s, 'second');
171
+ }
172
+ return ms + ' ms';
173
+ }
174
+
175
+ /**
176
+ * Pluralization helper.
177
+ */
178
+
179
+ function plural(ms, msAbs, n, name) {
180
+ var isPlural = msAbs >= n * 1.5;
181
+ return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
182
+ }
183
+
184
+ /**
185
+ * This is the common logic for both the Node.js and web browser
186
+ * implementations of `debug()`.
187
+ */
188
+
189
+ function setup(env) {
190
+ createDebug.debug = createDebug;
191
+ createDebug.default = createDebug;
192
+ createDebug.coerce = coerce;
193
+ createDebug.disable = disable;
194
+ createDebug.enable = enable;
195
+ createDebug.enabled = enabled;
196
+ createDebug.humanize = ms;
197
+ createDebug.destroy = destroy;
198
+
199
+ Object.keys(env).forEach(key => {
200
+ createDebug[key] = env[key];
201
+ });
202
+
203
+ /**
204
+ * The currently active debug mode names, and names to skip.
205
+ */
206
+
207
+ createDebug.names = [];
208
+ createDebug.skips = [];
209
+
210
+ /**
211
+ * Map of special "%n" handling functions, for the debug "format" argument.
212
+ *
213
+ * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
214
+ */
215
+ createDebug.formatters = {};
216
+
217
+ /**
218
+ * Selects a color for a debug namespace
219
+ * @param {String} namespace The namespace string for the debug instance to be colored
220
+ * @return {Number|String} An ANSI color code for the given namespace
221
+ * @api private
222
+ */
223
+ function selectColor(namespace) {
224
+ let hash = 0;
225
+
226
+ for (let i = 0; i < namespace.length; i++) {
227
+ hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
228
+ hash |= 0; // Convert to 32bit integer
229
+ }
230
+
231
+ return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
232
+ }
233
+ createDebug.selectColor = selectColor;
234
+
235
+ /**
236
+ * Create a debugger with the given `namespace`.
237
+ *
238
+ * @param {String} namespace
239
+ * @return {Function}
240
+ * @api public
241
+ */
242
+ function createDebug(namespace) {
243
+ let prevTime;
244
+ let enableOverride = null;
245
+ let namespacesCache;
246
+ let enabledCache;
247
+
248
+ function debug(...args) {
249
+ // Disabled?
250
+ if (!debug.enabled) {
251
+ return;
252
+ }
253
+
254
+ const self = debug;
255
+
256
+ // Set `diff` timestamp
257
+ const curr = Number(new Date());
258
+ const ms = curr - (prevTime || curr);
259
+ self.diff = ms;
260
+ self.prev = prevTime;
261
+ self.curr = curr;
262
+ prevTime = curr;
263
+
264
+ args[0] = createDebug.coerce(args[0]);
265
+
266
+ if (typeof args[0] !== 'string') {
267
+ // Anything else let's inspect with %O
268
+ args.unshift('%O');
269
+ }
270
+
271
+ // Apply any `formatters` transformations
272
+ let index = 0;
273
+ args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
274
+ // If we encounter an escaped % then don't increase the array index
275
+ if (match === '%%') {
276
+ return '%';
277
+ }
278
+ index++;
279
+ const formatter = createDebug.formatters[format];
280
+ if (typeof formatter === 'function') {
281
+ const val = args[index];
282
+ match = formatter.call(self, val);
283
+
284
+ // Now we need to remove `args[index]` since it's inlined in the `format`
285
+ args.splice(index, 1);
286
+ index--;
287
+ }
288
+ return match;
289
+ });
290
+
291
+ // Apply env-specific formatting (colors, etc.)
292
+ createDebug.formatArgs.call(self, args);
293
+
294
+ const logFn = self.log || createDebug.log;
295
+ logFn.apply(self, args);
296
+ }
297
+
298
+ debug.namespace = namespace;
299
+ debug.useColors = createDebug.useColors();
300
+ debug.color = createDebug.selectColor(namespace);
301
+ debug.extend = extend;
302
+ debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
303
+
304
+ Object.defineProperty(debug, 'enabled', {
305
+ enumerable: true,
306
+ configurable: false,
307
+ get: () => {
308
+ if (enableOverride !== null) {
309
+ return enableOverride;
310
+ }
311
+ if (namespacesCache !== createDebug.namespaces) {
312
+ namespacesCache = createDebug.namespaces;
313
+ enabledCache = createDebug.enabled(namespace);
314
+ }
315
+
316
+ return enabledCache;
317
+ },
318
+ set: v => {
319
+ enableOverride = v;
320
+ }
321
+ });
322
+
323
+ // Env-specific initialization logic for debug instances
324
+ if (typeof createDebug.init === 'function') {
325
+ createDebug.init(debug);
326
+ }
327
+
328
+ return debug;
329
+ }
330
+
331
+ function extend(namespace, delimiter) {
332
+ const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
333
+ newDebug.log = this.log;
334
+ return newDebug;
335
+ }
336
+
337
+ /**
338
+ * Enables a debug mode by namespaces. This can include modes
339
+ * separated by a colon and wildcards.
340
+ *
341
+ * @param {String} namespaces
342
+ * @api public
343
+ */
344
+ function enable(namespaces) {
345
+ createDebug.save(namespaces);
346
+ createDebug.namespaces = namespaces;
347
+
348
+ createDebug.names = [];
349
+ createDebug.skips = [];
350
+
351
+ let i;
352
+ const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
353
+ const len = split.length;
354
+
355
+ for (i = 0; i < len; i++) {
356
+ if (!split[i]) {
357
+ // ignore empty strings
358
+ continue;
359
+ }
360
+
361
+ namespaces = split[i].replace(/\*/g, '.*?');
362
+
363
+ if (namespaces[0] === '-') {
364
+ createDebug.skips.push(new RegExp('^' + namespaces.slice(1) + '$'));
365
+ } else {
366
+ createDebug.names.push(new RegExp('^' + namespaces + '$'));
367
+ }
368
+ }
369
+ }
370
+
371
+ /**
372
+ * Disable debug output.
373
+ *
374
+ * @return {String} namespaces
375
+ * @api public
376
+ */
377
+ function disable() {
378
+ const namespaces = [
379
+ ...createDebug.names.map(toNamespace),
380
+ ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
381
+ ].join(',');
382
+ createDebug.enable('');
383
+ return namespaces;
384
+ }
385
+
386
+ /**
387
+ * Returns true if the given mode name is enabled, false otherwise.
388
+ *
389
+ * @param {String} name
390
+ * @return {Boolean}
391
+ * @api public
392
+ */
393
+ function enabled(name) {
394
+ if (name[name.length - 1] === '*') {
395
+ return true;
396
+ }
397
+
398
+ let i;
399
+ let len;
400
+
401
+ for (i = 0, len = createDebug.skips.length; i < len; i++) {
402
+ if (createDebug.skips[i].test(name)) {
403
+ return false;
404
+ }
405
+ }
406
+
407
+ for (i = 0, len = createDebug.names.length; i < len; i++) {
408
+ if (createDebug.names[i].test(name)) {
409
+ return true;
410
+ }
411
+ }
412
+
413
+ return false;
414
+ }
415
+
416
+ /**
417
+ * Convert regexp to namespace
418
+ *
419
+ * @param {RegExp} regxep
420
+ * @return {String} namespace
421
+ * @api private
422
+ */
423
+ function toNamespace(regexp) {
424
+ return regexp.toString()
425
+ .substring(2, regexp.toString().length - 2)
426
+ .replace(/\.\*\?$/, '*');
427
+ }
428
+
429
+ /**
430
+ * Coerce `val`.
431
+ *
432
+ * @param {Mixed} val
433
+ * @return {Mixed}
434
+ * @api private
435
+ */
436
+ function coerce(val) {
437
+ if (val instanceof Error) {
438
+ return val.stack || val.message;
439
+ }
440
+ return val;
441
+ }
442
+
443
+ /**
444
+ * XXX DO NOT USE. This is a temporary stub function.
445
+ * XXX It WILL be removed in the next major release.
446
+ */
447
+ function destroy() {
448
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
449
+ }
450
+
451
+ createDebug.enable(createDebug.load());
452
+
453
+ return createDebug;
454
+ }
455
+
456
+ var common = setup;
457
+
458
+ /* eslint-env browser */
459
+
460
+ (function (module, exports) {
461
+ /**
462
+ * This is the web browser implementation of `debug()`.
463
+ */
464
+
465
+ exports.formatArgs = formatArgs;
466
+ exports.save = save;
467
+ exports.load = load;
468
+ exports.useColors = useColors;
469
+ exports.storage = localstorage();
470
+ exports.destroy = (() => {
471
+ let warned = false;
472
+
473
+ return () => {
474
+ if (!warned) {
475
+ warned = true;
476
+ console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
477
+ }
478
+ };
479
+ })();
480
+
481
+ /**
482
+ * Colors.
483
+ */
484
+
485
+ exports.colors = [
486
+ '#0000CC',
487
+ '#0000FF',
488
+ '#0033CC',
489
+ '#0033FF',
490
+ '#0066CC',
491
+ '#0066FF',
492
+ '#0099CC',
493
+ '#0099FF',
494
+ '#00CC00',
495
+ '#00CC33',
496
+ '#00CC66',
497
+ '#00CC99',
498
+ '#00CCCC',
499
+ '#00CCFF',
500
+ '#3300CC',
501
+ '#3300FF',
502
+ '#3333CC',
503
+ '#3333FF',
504
+ '#3366CC',
505
+ '#3366FF',
506
+ '#3399CC',
507
+ '#3399FF',
508
+ '#33CC00',
509
+ '#33CC33',
510
+ '#33CC66',
511
+ '#33CC99',
512
+ '#33CCCC',
513
+ '#33CCFF',
514
+ '#6600CC',
515
+ '#6600FF',
516
+ '#6633CC',
517
+ '#6633FF',
518
+ '#66CC00',
519
+ '#66CC33',
520
+ '#9900CC',
521
+ '#9900FF',
522
+ '#9933CC',
523
+ '#9933FF',
524
+ '#99CC00',
525
+ '#99CC33',
526
+ '#CC0000',
527
+ '#CC0033',
528
+ '#CC0066',
529
+ '#CC0099',
530
+ '#CC00CC',
531
+ '#CC00FF',
532
+ '#CC3300',
533
+ '#CC3333',
534
+ '#CC3366',
535
+ '#CC3399',
536
+ '#CC33CC',
537
+ '#CC33FF',
538
+ '#CC6600',
539
+ '#CC6633',
540
+ '#CC9900',
541
+ '#CC9933',
542
+ '#CCCC00',
543
+ '#CCCC33',
544
+ '#FF0000',
545
+ '#FF0033',
546
+ '#FF0066',
547
+ '#FF0099',
548
+ '#FF00CC',
549
+ '#FF00FF',
550
+ '#FF3300',
551
+ '#FF3333',
552
+ '#FF3366',
553
+ '#FF3399',
554
+ '#FF33CC',
555
+ '#FF33FF',
556
+ '#FF6600',
557
+ '#FF6633',
558
+ '#FF9900',
559
+ '#FF9933',
560
+ '#FFCC00',
561
+ '#FFCC33'
562
+ ];
563
+
564
+ /**
565
+ * Currently only WebKit-based Web Inspectors, Firefox >= v31,
566
+ * and the Firebug extension (any Firefox version) are known
567
+ * to support "%c" CSS customizations.
568
+ *
569
+ * TODO: add a `localStorage` variable to explicitly enable/disable colors
570
+ */
571
+
572
+ // eslint-disable-next-line complexity
573
+ function useColors() {
574
+ // NB: In an Electron preload script, document will be defined but not fully
575
+ // initialized. Since we know we're in Chrome, we'll just detect this case
576
+ // explicitly
577
+ if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
578
+ return true;
579
+ }
580
+
581
+ // Internet Explorer and Edge do not support colors.
582
+ if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
583
+ return false;
584
+ }
585
+
586
+ // Is webkit? http://stackoverflow.com/a/16459606/376773
587
+ // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
588
+ return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
589
+ // Is firebug? http://stackoverflow.com/a/398120/376773
590
+ (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
591
+ // Is firefox >= v31?
592
+ // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
593
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
594
+ // Double check webkit in userAgent just in case we are in a worker
595
+ (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
596
+ }
597
+
598
+ /**
599
+ * Colorize log arguments if enabled.
600
+ *
601
+ * @api public
602
+ */
603
+
604
+ function formatArgs(args) {
605
+ args[0] = (this.useColors ? '%c' : '') +
606
+ this.namespace +
607
+ (this.useColors ? ' %c' : ' ') +
608
+ args[0] +
609
+ (this.useColors ? '%c ' : ' ') +
610
+ '+' + module.exports.humanize(this.diff);
611
+
612
+ if (!this.useColors) {
613
+ return;
614
+ }
615
+
616
+ const c = 'color: ' + this.color;
617
+ args.splice(1, 0, c, 'color: inherit');
618
+
619
+ // The final "%c" is somewhat tricky, because there could be other
620
+ // arguments passed either before or after the %c, so we need to
621
+ // figure out the correct index to insert the CSS into
622
+ let index = 0;
623
+ let lastC = 0;
624
+ args[0].replace(/%[a-zA-Z%]/g, match => {
625
+ if (match === '%%') {
626
+ return;
627
+ }
628
+ index++;
629
+ if (match === '%c') {
630
+ // We only are interested in the *last* %c
631
+ // (the user may have provided their own)
632
+ lastC = index;
633
+ }
634
+ });
635
+
636
+ args.splice(lastC, 0, c);
637
+ }
638
+
639
+ /**
640
+ * Invokes `console.debug()` when available.
641
+ * No-op when `console.debug` is not a "function".
642
+ * If `console.debug` is not available, falls back
643
+ * to `console.log`.
644
+ *
645
+ * @api public
646
+ */
647
+ exports.log = console.debug || console.log || (() => {});
648
+
649
+ /**
650
+ * Save `namespaces`.
651
+ *
652
+ * @param {String} namespaces
653
+ * @api private
654
+ */
655
+ function save(namespaces) {
656
+ try {
657
+ if (namespaces) {
658
+ exports.storage.setItem('debug', namespaces);
659
+ } else {
660
+ exports.storage.removeItem('debug');
661
+ }
662
+ } catch (error) {
663
+ // Swallow
664
+ // XXX (@Qix-) should we be logging these?
665
+ }
666
+ }
667
+
668
+ /**
669
+ * Load `namespaces`.
670
+ *
671
+ * @return {String} returns the previously persisted debug modes
672
+ * @api private
673
+ */
674
+ function load() {
675
+ let r;
676
+ try {
677
+ r = exports.storage.getItem('debug');
678
+ } catch (error) {
679
+ // Swallow
680
+ // XXX (@Qix-) should we be logging these?
681
+ }
682
+
683
+ // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
684
+ if (!r && typeof process !== 'undefined' && 'env' in process) {
685
+ r = process.env.DEBUG;
686
+ }
687
+
688
+ return r;
689
+ }
690
+
691
+ /**
692
+ * Localstorage attempts to return the localstorage.
693
+ *
694
+ * This is necessary because safari throws
695
+ * when a user disables cookies/localstorage
696
+ * and you attempt to access it.
697
+ *
698
+ * @return {LocalStorage}
699
+ * @api private
700
+ */
701
+
702
+ function localstorage() {
703
+ try {
704
+ // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
705
+ // The Browser also has localStorage in the global context.
706
+ return localStorage;
707
+ } catch (error) {
708
+ // Swallow
709
+ // XXX (@Qix-) should we be logging these?
710
+ }
711
+ }
712
+
713
+ module.exports = common(exports);
714
+
715
+ const {formatters} = module.exports;
716
+
717
+ /**
718
+ * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
719
+ */
720
+
721
+ formatters.j = function (v) {
722
+ try {
723
+ return JSON.stringify(v);
724
+ } catch (error) {
725
+ return '[UnexpectedJSONParseError]: ' + error.message;
726
+ }
727
+ };
728
+ }(browser, browser.exports));
729
+
730
+ var debug = browser.exports;
731
+
732
+ var defaults = {
733
+ backgroundImageEnabled: true,
734
+ imageDimensions: {
735
+ height: 0,
736
+ width: 0
737
+ },
738
+ imageUrl: '',
739
+ prompt: '',
740
+ promptEnabled: true,
741
+ spellCheckEnabled: true,
742
+ studentInstructionsEnabled: true,
743
+ teacherInstructions: '',
744
+ teacherInstructionsEnabled: true,
745
+ toolbarEditorPosition: 'bottom'
746
+ };
747
+
748
+ const log = debug('pie-elements:drawing-response:controller');
749
+ const normalize = question => _extends({}, defaults, question);
750
+ function model(question, session, env) {
751
+ const normalizedQuestion = normalize(question);
752
+ const {
753
+ extraCSSRules,
754
+ imageUrl,
755
+ imageDimensions,
756
+ prompt,
757
+ promptEnabled,
758
+ backgroundImageEnabled,
759
+ language
760
+ } = normalizedQuestion;
761
+ return new Promise(resolve => {
762
+ const out = {
763
+ disabled: env.mode !== 'gather',
764
+ mode: env.mode,
765
+ imageDimensions,
766
+ imageUrl,
767
+ prompt: promptEnabled ? prompt : null,
768
+ backgroundImageEnabled,
769
+ language,
770
+ extraCSSRules
771
+ };
772
+
773
+ if (env.role === 'instructor' && (env.mode === 'view' || env.mode === 'evaluate')) {
774
+ out.teacherInstructions = normalizedQuestion.teacherInstructionsEnabled ? normalizedQuestion.teacherInstructions : null;
775
+ } else {
776
+ out.teacherInstructions = null;
777
+ }
778
+
779
+ resolve(out);
780
+ });
781
+ }
782
+ const createDefaultModel = (model = {}) => new Promise(resolve => {
783
+ resolve(_extends({}, defaults, model));
784
+ });
785
+ function
786
+ /*config, session*/
787
+ outcome() {
788
+ return new Promise(resolve => {
789
+ log('outcome...');
790
+ resolve({
791
+ score: 0,
792
+ completed: 'n/a',
793
+ note: 'Requires manual scoring'
794
+ });
795
+ });
796
+ } // remove all html tags
797
+
798
+
799
+ const getContent = html => (html || '').replace(/(<(?!img|iframe|source)([^>]+)>)/gi, '');
800
+
801
+ const validate = (model = {}, config = {}) => {
802
+ const errors = {};
803
+ ['teacherInstructions', 'prompt'].forEach(field => {
804
+ var _config$field;
805
+
806
+ if ((_config$field = config[field]) != null && _config$field.required && !getContent(model[field])) {
807
+ errors[field] = 'This field is required.';
808
+ }
809
+ });
810
+ return errors;
811
+ };
812
+
813
+ export { createDefaultModel, model, normalize, outcome, validate };
814
+ //# sourceMappingURL=controller.js.map