@pie-element/categorize 11.0.1-next.0 → 11.0.2-esm.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.
@@ -0,0 +1,4667 @@
1
+ import React, { createContext, isValidElement, cloneElement, createRef, Component } from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import { ModelUpdatedEvent, InsertImageEvent, DeleteImageEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
4
+ import { renderMath } from '@pie-lib/math-rendering';
5
+ import PropTypes from 'prop-types';
6
+ import { withStyles } from '@material-ui/core/styles';
7
+ import { choiceUtils, Checkbox, layout, AlertDialog, InputContainer as InputContainer$1, FeedbackConfig, settings } from '@pie-lib/config-ui';
8
+ import { removeCategory, moveChoiceToCategory, verifyAllowMultiplePlacements, removeChoiceFromCategory, moveChoiceToAlternate, removeChoiceFromAlternate, removeAllChoices, rearrangeChoices, ensureNoExtraChoicesInAnswer, ensureNoExtraChoicesInAlternate, countInAnswer } from '@pie-lib/categorize';
9
+ import EditableHtml from '@pie-lib/editable-html';
10
+ import { Choice as Choice$2, PlaceHolder as PlaceHolder$1, uid, withDragContext } from '@pie-lib/drag';
11
+ import classNames from 'classnames';
12
+ import Info from '@material-ui/icons/Info';
13
+ import Tooltip from '@material-ui/core/Tooltip';
14
+ import Card from '@material-ui/core/Card';
15
+ import CardActions from '@material-ui/core/CardActions';
16
+ import Button from '@material-ui/core/Button';
17
+ import '@material-ui/core/Divider';
18
+ import IconButton from '@material-ui/core/IconButton';
19
+ import RemoveCircleOutlineIcon from '@material-ui/icons/RemoveCircleOutline';
20
+ import { HtmlAndMath, color, InputContainer } from '@pie-lib/render-ui';
21
+ import debug from 'debug';
22
+ import { jsx } from 'react/jsx-runtime';
23
+ import Typography from '@material-ui/core/Typography';
24
+ import DragHandle from '@material-ui/icons/DragHandle';
25
+ import flow from 'lodash/flow';
26
+ import TextField from '@material-ui/core/TextField';
27
+ import cloneDeep from 'lodash/cloneDeep';
28
+ import Translator from '@pie-lib/translator';
29
+
30
+ function _extends() {
31
+ _extends = Object.assign || function (target) {
32
+ for (var i = 1; i < arguments.length; i++) {
33
+ var source = arguments[i];
34
+
35
+ for (var key in source) {
36
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
37
+ target[key] = source[key];
38
+ }
39
+ }
40
+ }
41
+
42
+ return target;
43
+ };
44
+
45
+ return _extends.apply(this, arguments);
46
+ }
47
+
48
+ function _objectWithoutPropertiesLoose(source, excluded) {
49
+ if (source == null) return {};
50
+ var target = {};
51
+ var sourceKeys = Object.keys(source);
52
+ var key, i;
53
+
54
+ for (i = 0; i < sourceKeys.length; i++) {
55
+ key = sourceKeys[i];
56
+ if (excluded.indexOf(key) >= 0) continue;
57
+ target[key] = source[key];
58
+ }
59
+
60
+ return target;
61
+ }
62
+
63
+ const getPluginProps = (props = {}, baseInputConfiguration = {}) => _extends({}, baseInputConfiguration, props);
64
+
65
+ class InputHeader extends React.Component {
66
+ constructor(props) {
67
+ super(props);
68
+ }
69
+
70
+ componentDidMount() {
71
+ const {
72
+ focusedEl,
73
+ index
74
+ } = this.props;
75
+
76
+ if (focusedEl && index && focusedEl === index) {
77
+ this.inputRef.focus('end', null, true);
78
+ }
79
+ }
80
+
81
+ render() {
82
+ const {
83
+ onChange,
84
+ configuration,
85
+ label,
86
+ classes,
87
+ className,
88
+ deleteFocusedEl,
89
+ disabled,
90
+ imageSupport,
91
+ toolbarOpts,
92
+ spellCheck,
93
+ error,
94
+ maxImageWidth,
95
+ maxImageHeight,
96
+ uploadSoundSupport,
97
+ mathMlOptions = {}
98
+ } = this.props;
99
+ const {
100
+ headers,
101
+ baseInputConfiguration
102
+ } = configuration;
103
+ return /*#__PURE__*/React.createElement("div", {
104
+ className: classNames(classes.inputHeader, className)
105
+ }, /*#__PURE__*/React.createElement(EditableHtml, {
106
+ imageSupport: imageSupport,
107
+ disabled: disabled,
108
+ ref: ref => this.inputRef = ref,
109
+ autoWidthToolbar: true,
110
+ label: 'label',
111
+ markup: label,
112
+ onChange: onChange,
113
+ className: classes.editor,
114
+ pluginProps: getPluginProps(headers == null ? void 0 : headers.inputConfiguration, baseInputConfiguration),
115
+ toolbarOpts: toolbarOpts,
116
+ spellCheck: spellCheck,
117
+ error: error,
118
+ maxImageWidth: maxImageWidth,
119
+ maxImageHeight: maxImageHeight,
120
+ uploadSoundSupport: uploadSoundSupport,
121
+ languageCharactersProps: [{
122
+ language: 'spanish'
123
+ }, {
124
+ language: 'special'
125
+ }],
126
+ onDone: () => {
127
+ deleteFocusedEl && deleteFocusedEl();
128
+ },
129
+ mathMlOptions: mathMlOptions
130
+ }));
131
+ }
132
+
133
+ }
134
+ InputHeader.propTypes = {
135
+ classes: PropTypes.object.isRequired,
136
+ className: PropTypes.string,
137
+ configuration: PropTypes.object.isRequired,
138
+ deleteFocusedEl: PropTypes.func,
139
+ disabled: PropTypes.bool,
140
+ focusedEl: PropTypes.number,
141
+ index: PropTypes.number,
142
+ label: PropTypes.string,
143
+ maxImageWidth: PropTypes.object,
144
+ maxImageHeight: PropTypes.object,
145
+ onChange: PropTypes.func,
146
+ onDelete: PropTypes.func,
147
+ imageSupport: PropTypes.shape({
148
+ add: PropTypes.func.isRequired,
149
+ delete: PropTypes.func.isRequired
150
+ }),
151
+ uploadSoundSupport: PropTypes.shape({
152
+ add: PropTypes.func.isRequired,
153
+ delete: PropTypes.func.isRequired
154
+ }),
155
+ toolbarOpts: PropTypes.object,
156
+ error: PropTypes.string,
157
+ spellCheck: PropTypes.bool
158
+ };
159
+ InputHeader.defaultProps = {};
160
+
161
+ const styles$d = theme => ({
162
+ editor: {
163
+ flex: '1',
164
+ paddingBottom: theme.spacing.unit,
165
+ maxWidth: '100%'
166
+ },
167
+ iconButtonRoot: {
168
+ width: 'auto',
169
+ height: 'auto'
170
+ },
171
+ inputHeader: {
172
+ display: 'flex',
173
+ justifyContent: 'space-between'
174
+ }
175
+ });
176
+
177
+ var InputHeader$1 = withStyles(styles$d)(InputHeader);
178
+
179
+ class RawAddButton extends React.Component {
180
+ render() {
181
+ const {
182
+ classes,
183
+ className,
184
+ label,
185
+ onClick,
186
+ disabled
187
+ } = this.props;
188
+ return /*#__PURE__*/React.createElement(Button, {
189
+ onClick: onClick,
190
+ disabled: disabled,
191
+ className: classNames(classes.addButton, className),
192
+ size: "small",
193
+ variant: "contained",
194
+ color: "primary"
195
+ }, label);
196
+ }
197
+
198
+ }
199
+ RawAddButton.propTypes = {
200
+ classes: PropTypes.object.isRequired,
201
+ className: PropTypes.string,
202
+ label: PropTypes.string,
203
+ onClick: PropTypes.func,
204
+ disabled: PropTypes.bool
205
+ };
206
+ RawAddButton.defaultProps = {
207
+ label: 'Add'
208
+ };
209
+
210
+ const styles$c = theme => ({
211
+ addButton: {
212
+ height: theme.spacing.unit * 4
213
+ }
214
+ });
215
+
216
+ const AddButton = withStyles(styles$c)(RawAddButton);
217
+ const DeleteButton = withStyles(() => ({
218
+ deleteButton: {
219
+ margin: 0,
220
+ padding: 0
221
+ }
222
+ }))(({
223
+ classes,
224
+ label,
225
+ onClick,
226
+ disabled
227
+ }) => /*#__PURE__*/React.createElement(Button, {
228
+ className: classes.deleteButton,
229
+ onClick: onClick,
230
+ size: "small",
231
+ color: "primary",
232
+ disabled: disabled
233
+ }, label));
234
+
235
+ class ChoicePreview extends React.Component {
236
+ constructor(...args) {
237
+ super(...args);
238
+
239
+ this.delete = () => {
240
+ const {
241
+ onDelete,
242
+ choice
243
+ } = this.props;
244
+ onDelete(choice);
245
+ };
246
+ }
247
+
248
+ render() {
249
+ const {
250
+ alternateResponseIndex,
251
+ category,
252
+ classes,
253
+ className,
254
+ choice,
255
+ choiceIndex
256
+ } = this.props;
257
+ return /*#__PURE__*/React.createElement("div", {
258
+ className: classNames(classes.choicePreview, className)
259
+ }, choice ? /*#__PURE__*/React.createElement(Choice$2, {
260
+ alternateResponseIndex: alternateResponseIndex,
261
+ category: category,
262
+ choice: choice,
263
+ choiceIndex: choiceIndex,
264
+ className: classes.overflowChoice,
265
+ onRemoveChoice: () => this.delete()
266
+ }, /*#__PURE__*/React.createElement(HtmlAndMath, {
267
+ html: choice == null ? void 0 : choice.content,
268
+ className: `${classes.breakWord}`
269
+ }), /*#__PURE__*/React.createElement(IconButton, {
270
+ "aria-label": "delete",
271
+ className: classNames(classes.delete, classes.customColor),
272
+ onClick: this.delete
273
+ }, /*#__PURE__*/React.createElement(RemoveCircleOutlineIcon, null))) : null);
274
+ }
275
+
276
+ }
277
+ ChoicePreview.propTypes = {
278
+ alternateResponseIndex: PropTypes.number,
279
+ category: PropTypes.object,
280
+ classes: PropTypes.object.isRequired,
281
+ className: PropTypes.string,
282
+ choice: PropTypes.object.isRequired,
283
+ choiceIndex: PropTypes.number,
284
+ onDelete: PropTypes.func.isRequired
285
+ };
286
+ ChoicePreview.defaultProps = {};
287
+
288
+ const styles$b = () => ({
289
+ choicePreview: {
290
+ position: 'relative',
291
+ overflow: 'auto'
292
+ },
293
+ delete: {
294
+ position: 'absolute',
295
+ right: 0,
296
+ top: 0
297
+ },
298
+ breakWord: {
299
+ maxWidth: '90%',
300
+ wordBreak: 'break-all'
301
+ },
302
+ customColor: {
303
+ color: `${color.tertiary()} !important`
304
+ },
305
+ overflowChoice: {
306
+ overflow: 'auto'
307
+ }
308
+ });
309
+
310
+ var ChoicePreview$1 = withStyles(styles$b)(ChoicePreview);
311
+
312
+ /**
313
+ * Create the React Context
314
+ */
315
+
316
+ var DndContext = createContext({
317
+ dragDropManager: undefined
318
+ });
319
+
320
+ /**
321
+ * Use invariant() to assert state which your program assumes to be true.
322
+ *
323
+ * Provide sprintf-style format (only %s is supported) and arguments
324
+ * to provide information about what broke and what you were
325
+ * expecting.
326
+ *
327
+ * The invariant message will be stripped in production, but the invariant
328
+ * will remain to ensure logic does not differ in production.
329
+ */
330
+ function invariant(condition, format) {
331
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
332
+ args[_key - 2] = arguments[_key];
333
+ }
334
+
335
+ if (process.env.NODE_ENV !== 'production') {
336
+ if (format === undefined) {
337
+ throw new Error('invariant requires an error message argument');
338
+ }
339
+ }
340
+
341
+ if (!condition) {
342
+ var error;
343
+
344
+ if (format === undefined) {
345
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
346
+ } else {
347
+ var argIndex = 0;
348
+ error = new Error(format.replace(/%s/g, function () {
349
+ return args[argIndex++];
350
+ }));
351
+ error.name = 'Invariant Violation';
352
+ }
353
+
354
+ error.framesToPop = 1; // we don't care about invariant's own frame
355
+
356
+ throw error;
357
+ }
358
+ }
359
+
360
+ function _classCallCheck$7(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
361
+
362
+ function _defineProperties$7(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
363
+
364
+ function _createClass$7(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$7(Constructor.prototype, protoProps); if (staticProps) _defineProperties$7(Constructor, staticProps); return Constructor; }
365
+
366
+ function _defineProperty$7(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
367
+ var isCallingCanDrag = false;
368
+ var isCallingIsDragging = false;
369
+ var DragSourceMonitorImpl = /*#__PURE__*/function () {
370
+ function DragSourceMonitorImpl(manager) {
371
+ _classCallCheck$7(this, DragSourceMonitorImpl);
372
+
373
+ _defineProperty$7(this, "internalMonitor", void 0);
374
+
375
+ _defineProperty$7(this, "sourceId", null);
376
+
377
+ this.internalMonitor = manager.getMonitor();
378
+ }
379
+
380
+ _createClass$7(DragSourceMonitorImpl, [{
381
+ key: "receiveHandlerId",
382
+ value: function receiveHandlerId(sourceId) {
383
+ this.sourceId = sourceId;
384
+ }
385
+ }, {
386
+ key: "getHandlerId",
387
+ value: function getHandlerId() {
388
+ return this.sourceId;
389
+ }
390
+ }, {
391
+ key: "canDrag",
392
+ value: function canDrag() {
393
+ invariant(!isCallingCanDrag, 'You may not call monitor.canDrag() inside your canDrag() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor');
394
+
395
+ try {
396
+ isCallingCanDrag = true;
397
+ return this.internalMonitor.canDragSource(this.sourceId);
398
+ } finally {
399
+ isCallingCanDrag = false;
400
+ }
401
+ }
402
+ }, {
403
+ key: "isDragging",
404
+ value: function isDragging() {
405
+ if (!this.sourceId) {
406
+ return false;
407
+ }
408
+
409
+ invariant(!isCallingIsDragging, 'You may not call monitor.isDragging() inside your isDragging() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source-monitor');
410
+
411
+ try {
412
+ isCallingIsDragging = true;
413
+ return this.internalMonitor.isDraggingSource(this.sourceId);
414
+ } finally {
415
+ isCallingIsDragging = false;
416
+ }
417
+ }
418
+ }, {
419
+ key: "subscribeToStateChange",
420
+ value: function subscribeToStateChange(listener, options) {
421
+ return this.internalMonitor.subscribeToStateChange(listener, options);
422
+ }
423
+ }, {
424
+ key: "isDraggingSource",
425
+ value: function isDraggingSource(sourceId) {
426
+ return this.internalMonitor.isDraggingSource(sourceId);
427
+ }
428
+ }, {
429
+ key: "isOverTarget",
430
+ value: function isOverTarget(targetId, options) {
431
+ return this.internalMonitor.isOverTarget(targetId, options);
432
+ }
433
+ }, {
434
+ key: "getTargetIds",
435
+ value: function getTargetIds() {
436
+ return this.internalMonitor.getTargetIds();
437
+ }
438
+ }, {
439
+ key: "isSourcePublic",
440
+ value: function isSourcePublic() {
441
+ return this.internalMonitor.isSourcePublic();
442
+ }
443
+ }, {
444
+ key: "getSourceId",
445
+ value: function getSourceId() {
446
+ return this.internalMonitor.getSourceId();
447
+ }
448
+ }, {
449
+ key: "subscribeToOffsetChange",
450
+ value: function subscribeToOffsetChange(listener) {
451
+ return this.internalMonitor.subscribeToOffsetChange(listener);
452
+ }
453
+ }, {
454
+ key: "canDragSource",
455
+ value: function canDragSource(sourceId) {
456
+ return this.internalMonitor.canDragSource(sourceId);
457
+ }
458
+ }, {
459
+ key: "canDropOnTarget",
460
+ value: function canDropOnTarget(targetId) {
461
+ return this.internalMonitor.canDropOnTarget(targetId);
462
+ }
463
+ }, {
464
+ key: "getItemType",
465
+ value: function getItemType() {
466
+ return this.internalMonitor.getItemType();
467
+ }
468
+ }, {
469
+ key: "getItem",
470
+ value: function getItem() {
471
+ return this.internalMonitor.getItem();
472
+ }
473
+ }, {
474
+ key: "getDropResult",
475
+ value: function getDropResult() {
476
+ return this.internalMonitor.getDropResult();
477
+ }
478
+ }, {
479
+ key: "didDrop",
480
+ value: function didDrop() {
481
+ return this.internalMonitor.didDrop();
482
+ }
483
+ }, {
484
+ key: "getInitialClientOffset",
485
+ value: function getInitialClientOffset() {
486
+ return this.internalMonitor.getInitialClientOffset();
487
+ }
488
+ }, {
489
+ key: "getInitialSourceClientOffset",
490
+ value: function getInitialSourceClientOffset() {
491
+ return this.internalMonitor.getInitialSourceClientOffset();
492
+ }
493
+ }, {
494
+ key: "getSourceClientOffset",
495
+ value: function getSourceClientOffset() {
496
+ return this.internalMonitor.getSourceClientOffset();
497
+ }
498
+ }, {
499
+ key: "getClientOffset",
500
+ value: function getClientOffset() {
501
+ return this.internalMonitor.getClientOffset();
502
+ }
503
+ }, {
504
+ key: "getDifferenceFromInitialOffset",
505
+ value: function getDifferenceFromInitialOffset() {
506
+ return this.internalMonitor.getDifferenceFromInitialOffset();
507
+ }
508
+ }]);
509
+
510
+ return DragSourceMonitorImpl;
511
+ }();
512
+
513
+ function _classCallCheck$6(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
514
+
515
+ function _defineProperties$6(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
516
+
517
+ function _createClass$6(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$6(Constructor.prototype, protoProps); if (staticProps) _defineProperties$6(Constructor, staticProps); return Constructor; }
518
+
519
+ function _defineProperty$6(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
520
+ var isCallingCanDrop = false;
521
+ var DropTargetMonitorImpl = /*#__PURE__*/function () {
522
+ function DropTargetMonitorImpl(manager) {
523
+ _classCallCheck$6(this, DropTargetMonitorImpl);
524
+
525
+ _defineProperty$6(this, "internalMonitor", void 0);
526
+
527
+ _defineProperty$6(this, "targetId", null);
528
+
529
+ this.internalMonitor = manager.getMonitor();
530
+ }
531
+
532
+ _createClass$6(DropTargetMonitorImpl, [{
533
+ key: "receiveHandlerId",
534
+ value: function receiveHandlerId(targetId) {
535
+ this.targetId = targetId;
536
+ }
537
+ }, {
538
+ key: "getHandlerId",
539
+ value: function getHandlerId() {
540
+ return this.targetId;
541
+ }
542
+ }, {
543
+ key: "subscribeToStateChange",
544
+ value: function subscribeToStateChange(listener, options) {
545
+ return this.internalMonitor.subscribeToStateChange(listener, options);
546
+ }
547
+ }, {
548
+ key: "canDrop",
549
+ value: function canDrop() {
550
+ // Cut out early if the target id has not been set. This should prevent errors
551
+ // where the user has an older version of dnd-core like in
552
+ // https://github.com/react-dnd/react-dnd/issues/1310
553
+ if (!this.targetId) {
554
+ return false;
555
+ }
556
+
557
+ invariant(!isCallingCanDrop, 'You may not call monitor.canDrop() inside your canDrop() implementation. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target-monitor');
558
+
559
+ try {
560
+ isCallingCanDrop = true;
561
+ return this.internalMonitor.canDropOnTarget(this.targetId);
562
+ } finally {
563
+ isCallingCanDrop = false;
564
+ }
565
+ }
566
+ }, {
567
+ key: "isOver",
568
+ value: function isOver(options) {
569
+ if (!this.targetId) {
570
+ return false;
571
+ }
572
+
573
+ return this.internalMonitor.isOverTarget(this.targetId, options);
574
+ }
575
+ }, {
576
+ key: "getItemType",
577
+ value: function getItemType() {
578
+ return this.internalMonitor.getItemType();
579
+ }
580
+ }, {
581
+ key: "getItem",
582
+ value: function getItem() {
583
+ return this.internalMonitor.getItem();
584
+ }
585
+ }, {
586
+ key: "getDropResult",
587
+ value: function getDropResult() {
588
+ return this.internalMonitor.getDropResult();
589
+ }
590
+ }, {
591
+ key: "didDrop",
592
+ value: function didDrop() {
593
+ return this.internalMonitor.didDrop();
594
+ }
595
+ }, {
596
+ key: "getInitialClientOffset",
597
+ value: function getInitialClientOffset() {
598
+ return this.internalMonitor.getInitialClientOffset();
599
+ }
600
+ }, {
601
+ key: "getInitialSourceClientOffset",
602
+ value: function getInitialSourceClientOffset() {
603
+ return this.internalMonitor.getInitialSourceClientOffset();
604
+ }
605
+ }, {
606
+ key: "getSourceClientOffset",
607
+ value: function getSourceClientOffset() {
608
+ return this.internalMonitor.getSourceClientOffset();
609
+ }
610
+ }, {
611
+ key: "getClientOffset",
612
+ value: function getClientOffset() {
613
+ return this.internalMonitor.getClientOffset();
614
+ }
615
+ }, {
616
+ key: "getDifferenceFromInitialOffset",
617
+ value: function getDifferenceFromInitialOffset() {
618
+ return this.internalMonitor.getDifferenceFromInitialOffset();
619
+ }
620
+ }]);
621
+
622
+ return DropTargetMonitorImpl;
623
+ }();
624
+
625
+ function throwIfCompositeComponentElement(element) {
626
+ // Custom components can no longer be wrapped directly in React DnD 2.0
627
+ // so that we don't need to depend on findDOMNode() from react-dom.
628
+ if (typeof element.type === 'string') {
629
+ return;
630
+ }
631
+
632
+ var displayName = element.type.displayName || element.type.name || 'the component';
633
+ throw new Error('Only native element nodes can now be passed to React DnD connectors.' + "You can either wrap ".concat(displayName, " into a <div>, or turn it into a ") + 'drag source or a drop target itself.');
634
+ }
635
+
636
+ function wrapHookToRecognizeElement(hook) {
637
+ return function () {
638
+ var elementOrNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
639
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
640
+
641
+ // When passed a node, call the hook straight away.
642
+ if (!isValidElement(elementOrNode)) {
643
+ var node = elementOrNode;
644
+ hook(node, options); // return the node so it can be chained (e.g. when within callback refs
645
+ // <div ref={node => connectDragSource(connectDropTarget(node))}/>
646
+
647
+ return node;
648
+ } // If passed a ReactElement, clone it and attach this function as a ref.
649
+ // This helps us achieve a neat API where user doesn't even know that refs
650
+ // are being used under the hood.
651
+
652
+
653
+ var element = elementOrNode;
654
+ throwIfCompositeComponentElement(element); // When no options are passed, use the hook directly
655
+
656
+ var ref = options ? function (node) {
657
+ return hook(node, options);
658
+ } : hook;
659
+ return cloneWithRef(element, ref);
660
+ };
661
+ }
662
+
663
+ function wrapConnectorHooks(hooks) {
664
+ var wrappedHooks = {};
665
+ Object.keys(hooks).forEach(function (key) {
666
+ var hook = hooks[key]; // ref objects should be passed straight through without wrapping
667
+
668
+ if (key.endsWith('Ref')) {
669
+ wrappedHooks[key] = hooks[key];
670
+ } else {
671
+ var wrappedHook = wrapHookToRecognizeElement(hook);
672
+
673
+ wrappedHooks[key] = function () {
674
+ return wrappedHook;
675
+ };
676
+ }
677
+ });
678
+ return wrappedHooks;
679
+ }
680
+
681
+ function setRef(ref, node) {
682
+ if (typeof ref === 'function') {
683
+ ref(node);
684
+ } else {
685
+ ref.current = node;
686
+ }
687
+ }
688
+
689
+ function cloneWithRef(element, newRef) {
690
+ var previousRef = element.ref;
691
+ invariant(typeof previousRef !== 'string', 'Cannot connect React DnD to an element with an existing string ref. ' + 'Please convert it to use a callback ref instead, or wrap it into a <span> or <div>. ' + 'Read more: https://reactjs.org/docs/refs-and-the-dom.html#callback-refs');
692
+
693
+ if (!previousRef) {
694
+ // When there is no ref on the element, use the new ref directly
695
+ return cloneElement(element, {
696
+ ref: newRef
697
+ });
698
+ } else {
699
+ return cloneElement(element, {
700
+ ref: function ref(node) {
701
+ setRef(previousRef, node);
702
+ setRef(newRef, node);
703
+ }
704
+ });
705
+ }
706
+ }
707
+
708
+ function _typeof$2(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$2 = function _typeof(obj) { return typeof obj; }; } else { _typeof$2 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$2(obj); }
709
+
710
+ function isRef(obj) {
711
+ return (// eslint-disable-next-line no-prototype-builtins
712
+ obj !== null && _typeof$2(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current')
713
+ );
714
+ }
715
+
716
+ function shallowEqual(objA, objB, compare, compareContext) {
717
+ var compareResult = compare ? compare.call(compareContext, objA, objB) : void 0;
718
+
719
+ if (compareResult !== void 0) {
720
+ return !!compareResult;
721
+ }
722
+
723
+ if (objA === objB) {
724
+ return true;
725
+ }
726
+
727
+ if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
728
+ return false;
729
+ }
730
+
731
+ var keysA = Object.keys(objA);
732
+ var keysB = Object.keys(objB);
733
+
734
+ if (keysA.length !== keysB.length) {
735
+ return false;
736
+ }
737
+
738
+ var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB); // Test for A's keys different from B.
739
+
740
+ for (var idx = 0; idx < keysA.length; idx++) {
741
+ var key = keysA[idx];
742
+
743
+ if (!bHasOwnProperty(key)) {
744
+ return false;
745
+ }
746
+
747
+ var valueA = objA[key];
748
+ var valueB = objB[key];
749
+ compareResult = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
750
+
751
+ if (compareResult === false || compareResult === void 0 && valueA !== valueB) {
752
+ return false;
753
+ }
754
+ }
755
+
756
+ return true;
757
+ }
758
+
759
+ function _classCallCheck$5(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
760
+
761
+ function _defineProperties$5(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
762
+
763
+ function _createClass$5(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$5(Constructor.prototype, protoProps); if (staticProps) _defineProperties$5(Constructor, staticProps); return Constructor; }
764
+
765
+ function _defineProperty$5(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
766
+ var SourceConnector = /*#__PURE__*/function () {
767
+ // The drop target may either be attached via ref or connect function
768
+ // The drag preview may either be attached via ref or connect function
769
+ function SourceConnector(backend) {
770
+ var _this = this;
771
+
772
+ _classCallCheck$5(this, SourceConnector);
773
+
774
+ _defineProperty$5(this, "hooks", wrapConnectorHooks({
775
+ dragSource: function dragSource(node, options) {
776
+ _this.clearDragSource();
777
+
778
+ _this.dragSourceOptions = options || null;
779
+
780
+ if (isRef(node)) {
781
+ _this.dragSourceRef = node;
782
+ } else {
783
+ _this.dragSourceNode = node;
784
+ }
785
+
786
+ _this.reconnectDragSource();
787
+ },
788
+ dragPreview: function dragPreview(node, options) {
789
+ _this.clearDragPreview();
790
+
791
+ _this.dragPreviewOptions = options || null;
792
+
793
+ if (isRef(node)) {
794
+ _this.dragPreviewRef = node;
795
+ } else {
796
+ _this.dragPreviewNode = node;
797
+ }
798
+
799
+ _this.reconnectDragPreview();
800
+ }
801
+ }));
802
+
803
+ _defineProperty$5(this, "handlerId", null);
804
+
805
+ _defineProperty$5(this, "dragSourceRef", null);
806
+
807
+ _defineProperty$5(this, "dragSourceNode", void 0);
808
+
809
+ _defineProperty$5(this, "dragSourceOptionsInternal", null);
810
+
811
+ _defineProperty$5(this, "dragSourceUnsubscribe", void 0);
812
+
813
+ _defineProperty$5(this, "dragPreviewRef", null);
814
+
815
+ _defineProperty$5(this, "dragPreviewNode", void 0);
816
+
817
+ _defineProperty$5(this, "dragPreviewOptionsInternal", null);
818
+
819
+ _defineProperty$5(this, "dragPreviewUnsubscribe", void 0);
820
+
821
+ _defineProperty$5(this, "lastConnectedHandlerId", null);
822
+
823
+ _defineProperty$5(this, "lastConnectedDragSource", null);
824
+
825
+ _defineProperty$5(this, "lastConnectedDragSourceOptions", null);
826
+
827
+ _defineProperty$5(this, "lastConnectedDragPreview", null);
828
+
829
+ _defineProperty$5(this, "lastConnectedDragPreviewOptions", null);
830
+
831
+ _defineProperty$5(this, "backend", void 0);
832
+
833
+ this.backend = backend;
834
+ }
835
+
836
+ _createClass$5(SourceConnector, [{
837
+ key: "receiveHandlerId",
838
+ value: function receiveHandlerId(newHandlerId) {
839
+ if (this.handlerId === newHandlerId) {
840
+ return;
841
+ }
842
+
843
+ this.handlerId = newHandlerId;
844
+ this.reconnect();
845
+ }
846
+ }, {
847
+ key: "connectTarget",
848
+ get: function get() {
849
+ return this.dragSource;
850
+ }
851
+ }, {
852
+ key: "dragSourceOptions",
853
+ get: function get() {
854
+ return this.dragSourceOptionsInternal;
855
+ },
856
+ set: function set(options) {
857
+ this.dragSourceOptionsInternal = options;
858
+ }
859
+ }, {
860
+ key: "dragPreviewOptions",
861
+ get: function get() {
862
+ return this.dragPreviewOptionsInternal;
863
+ },
864
+ set: function set(options) {
865
+ this.dragPreviewOptionsInternal = options;
866
+ }
867
+ }, {
868
+ key: "reconnect",
869
+ value: function reconnect() {
870
+ this.reconnectDragSource();
871
+ this.reconnectDragPreview();
872
+ }
873
+ }, {
874
+ key: "reconnectDragSource",
875
+ value: function reconnectDragSource() {
876
+ var dragSource = this.dragSource; // if nothing has changed then don't resubscribe
877
+
878
+ var didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange();
879
+
880
+ if (didChange) {
881
+ this.disconnectDragSource();
882
+ }
883
+
884
+ if (!this.handlerId) {
885
+ return;
886
+ }
887
+
888
+ if (!dragSource) {
889
+ this.lastConnectedDragSource = dragSource;
890
+ return;
891
+ }
892
+
893
+ if (didChange) {
894
+ this.lastConnectedHandlerId = this.handlerId;
895
+ this.lastConnectedDragSource = dragSource;
896
+ this.lastConnectedDragSourceOptions = this.dragSourceOptions;
897
+ this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions);
898
+ }
899
+ }
900
+ }, {
901
+ key: "reconnectDragPreview",
902
+ value: function reconnectDragPreview() {
903
+ var dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe
904
+
905
+ var didChange = this.didHandlerIdChange() || this.didConnectedDragPreviewChange() || this.didDragPreviewOptionsChange();
906
+
907
+ if (didChange) {
908
+ this.disconnectDragPreview();
909
+ }
910
+
911
+ if (!this.handlerId) {
912
+ return;
913
+ }
914
+
915
+ if (!dragPreview) {
916
+ this.lastConnectedDragPreview = dragPreview;
917
+ return;
918
+ }
919
+
920
+ if (didChange) {
921
+ this.lastConnectedHandlerId = this.handlerId;
922
+ this.lastConnectedDragPreview = dragPreview;
923
+ this.lastConnectedDragPreviewOptions = this.dragPreviewOptions;
924
+ this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, dragPreview, this.dragPreviewOptions);
925
+ }
926
+ }
927
+ }, {
928
+ key: "didHandlerIdChange",
929
+ value: function didHandlerIdChange() {
930
+ return this.lastConnectedHandlerId !== this.handlerId;
931
+ }
932
+ }, {
933
+ key: "didConnectedDragSourceChange",
934
+ value: function didConnectedDragSourceChange() {
935
+ return this.lastConnectedDragSource !== this.dragSource;
936
+ }
937
+ }, {
938
+ key: "didConnectedDragPreviewChange",
939
+ value: function didConnectedDragPreviewChange() {
940
+ return this.lastConnectedDragPreview !== this.dragPreview;
941
+ }
942
+ }, {
943
+ key: "didDragSourceOptionsChange",
944
+ value: function didDragSourceOptionsChange() {
945
+ return !shallowEqual(this.lastConnectedDragSourceOptions, this.dragSourceOptions);
946
+ }
947
+ }, {
948
+ key: "didDragPreviewOptionsChange",
949
+ value: function didDragPreviewOptionsChange() {
950
+ return !shallowEqual(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions);
951
+ }
952
+ }, {
953
+ key: "disconnectDragSource",
954
+ value: function disconnectDragSource() {
955
+ if (this.dragSourceUnsubscribe) {
956
+ this.dragSourceUnsubscribe();
957
+ this.dragSourceUnsubscribe = undefined;
958
+ }
959
+ }
960
+ }, {
961
+ key: "disconnectDragPreview",
962
+ value: function disconnectDragPreview() {
963
+ if (this.dragPreviewUnsubscribe) {
964
+ this.dragPreviewUnsubscribe();
965
+ this.dragPreviewUnsubscribe = undefined;
966
+ this.dragPreviewNode = null;
967
+ this.dragPreviewRef = null;
968
+ }
969
+ }
970
+ }, {
971
+ key: "dragSource",
972
+ get: function get() {
973
+ return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
974
+ }
975
+ }, {
976
+ key: "dragPreview",
977
+ get: function get() {
978
+ return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current;
979
+ }
980
+ }, {
981
+ key: "clearDragSource",
982
+ value: function clearDragSource() {
983
+ this.dragSourceNode = null;
984
+ this.dragSourceRef = null;
985
+ }
986
+ }, {
987
+ key: "clearDragPreview",
988
+ value: function clearDragPreview() {
989
+ this.dragPreviewNode = null;
990
+ this.dragPreviewRef = null;
991
+ }
992
+ }]);
993
+
994
+ return SourceConnector;
995
+ }();
996
+
997
+ function _classCallCheck$4(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
998
+
999
+ function _defineProperties$4(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1000
+
1001
+ function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; }
1002
+
1003
+ function _defineProperty$4(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1004
+ var TargetConnector = /*#__PURE__*/function () {
1005
+ // The drop target may either be attached via ref or connect function
1006
+ function TargetConnector(backend) {
1007
+ var _this = this;
1008
+
1009
+ _classCallCheck$4(this, TargetConnector);
1010
+
1011
+ _defineProperty$4(this, "hooks", wrapConnectorHooks({
1012
+ dropTarget: function dropTarget(node, options) {
1013
+ _this.clearDropTarget();
1014
+
1015
+ _this.dropTargetOptions = options;
1016
+
1017
+ if (isRef(node)) {
1018
+ _this.dropTargetRef = node;
1019
+ } else {
1020
+ _this.dropTargetNode = node;
1021
+ }
1022
+
1023
+ _this.reconnect();
1024
+ }
1025
+ }));
1026
+
1027
+ _defineProperty$4(this, "handlerId", null);
1028
+
1029
+ _defineProperty$4(this, "dropTargetRef", null);
1030
+
1031
+ _defineProperty$4(this, "dropTargetNode", void 0);
1032
+
1033
+ _defineProperty$4(this, "dropTargetOptionsInternal", null);
1034
+
1035
+ _defineProperty$4(this, "unsubscribeDropTarget", void 0);
1036
+
1037
+ _defineProperty$4(this, "lastConnectedHandlerId", null);
1038
+
1039
+ _defineProperty$4(this, "lastConnectedDropTarget", null);
1040
+
1041
+ _defineProperty$4(this, "lastConnectedDropTargetOptions", null);
1042
+
1043
+ _defineProperty$4(this, "backend", void 0);
1044
+
1045
+ this.backend = backend;
1046
+ }
1047
+
1048
+ _createClass$4(TargetConnector, [{
1049
+ key: "connectTarget",
1050
+ get: function get() {
1051
+ return this.dropTarget;
1052
+ }
1053
+ }, {
1054
+ key: "reconnect",
1055
+ value: function reconnect() {
1056
+ // if nothing has changed then don't resubscribe
1057
+ var didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange();
1058
+
1059
+ if (didChange) {
1060
+ this.disconnectDropTarget();
1061
+ }
1062
+
1063
+ var dropTarget = this.dropTarget;
1064
+
1065
+ if (!this.handlerId) {
1066
+ return;
1067
+ }
1068
+
1069
+ if (!dropTarget) {
1070
+ this.lastConnectedDropTarget = dropTarget;
1071
+ return;
1072
+ }
1073
+
1074
+ if (didChange) {
1075
+ this.lastConnectedHandlerId = this.handlerId;
1076
+ this.lastConnectedDropTarget = dropTarget;
1077
+ this.lastConnectedDropTargetOptions = this.dropTargetOptions;
1078
+ this.unsubscribeDropTarget = this.backend.connectDropTarget(this.handlerId, dropTarget, this.dropTargetOptions);
1079
+ }
1080
+ }
1081
+ }, {
1082
+ key: "receiveHandlerId",
1083
+ value: function receiveHandlerId(newHandlerId) {
1084
+ if (newHandlerId === this.handlerId) {
1085
+ return;
1086
+ }
1087
+
1088
+ this.handlerId = newHandlerId;
1089
+ this.reconnect();
1090
+ }
1091
+ }, {
1092
+ key: "dropTargetOptions",
1093
+ get: function get() {
1094
+ return this.dropTargetOptionsInternal;
1095
+ },
1096
+ set: function set(options) {
1097
+ this.dropTargetOptionsInternal = options;
1098
+ }
1099
+ }, {
1100
+ key: "didHandlerIdChange",
1101
+ value: function didHandlerIdChange() {
1102
+ return this.lastConnectedHandlerId !== this.handlerId;
1103
+ }
1104
+ }, {
1105
+ key: "didDropTargetChange",
1106
+ value: function didDropTargetChange() {
1107
+ return this.lastConnectedDropTarget !== this.dropTarget;
1108
+ }
1109
+ }, {
1110
+ key: "didOptionsChange",
1111
+ value: function didOptionsChange() {
1112
+ return !shallowEqual(this.lastConnectedDropTargetOptions, this.dropTargetOptions);
1113
+ }
1114
+ }, {
1115
+ key: "disconnectDropTarget",
1116
+ value: function disconnectDropTarget() {
1117
+ if (this.unsubscribeDropTarget) {
1118
+ this.unsubscribeDropTarget();
1119
+ this.unsubscribeDropTarget = undefined;
1120
+ }
1121
+ }
1122
+ }, {
1123
+ key: "dropTarget",
1124
+ get: function get() {
1125
+ return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current;
1126
+ }
1127
+ }, {
1128
+ key: "clearDropTarget",
1129
+ value: function clearDropTarget() {
1130
+ this.dropTargetRef = null;
1131
+ this.dropTargetNode = null;
1132
+ }
1133
+ }]);
1134
+
1135
+ return TargetConnector;
1136
+ }();
1137
+
1138
+ function registerTarget(type, target, manager) {
1139
+ var registry = manager.getRegistry();
1140
+ var targetId = registry.addTarget(type, target);
1141
+ return [targetId, function () {
1142
+ return registry.removeTarget(targetId);
1143
+ }];
1144
+ }
1145
+ function registerSource(type, source, manager) {
1146
+ var registry = manager.getRegistry();
1147
+ var sourceId = registry.addSource(type, source);
1148
+ return [sourceId, function () {
1149
+ return registry.removeSource(sourceId);
1150
+ }];
1151
+ }
1152
+
1153
+ function _typeof$1(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof$1 = function _typeof(obj) { return typeof obj; }; } else { _typeof$1 = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof$1(obj); }
1154
+
1155
+ function getDecoratedComponent(instanceRef) {
1156
+ var currentRef = instanceRef.current;
1157
+
1158
+ if (currentRef == null) {
1159
+ return null;
1160
+ } else if (currentRef.decoratedRef) {
1161
+ // go through the private field in decorateHandler to avoid the invariant hit
1162
+ return currentRef.decoratedRef.current;
1163
+ } else {
1164
+ return currentRef;
1165
+ }
1166
+ }
1167
+ function isClassComponent(Component) {
1168
+ return Component && Component.prototype && typeof Component.prototype.render === 'function';
1169
+ }
1170
+ function isRefForwardingComponent(C) {
1171
+ var _item$$$typeof;
1172
+
1173
+ var item = C;
1174
+ return (item === null || item === void 0 ? void 0 : (_item$$$typeof = item.$$typeof) === null || _item$$$typeof === void 0 ? void 0 : _item$$$typeof.toString()) === 'Symbol(react.forward_ref)';
1175
+ }
1176
+ function isRefable(C) {
1177
+ return isClassComponent(C) || isRefForwardingComponent(C);
1178
+ }
1179
+ function checkDecoratorArguments(functionName, signature) {
1180
+ if (process.env.NODE_ENV !== 'production') {
1181
+ for (var i = 0; i < (arguments.length <= 2 ? 0 : arguments.length - 2); i++) {
1182
+ var arg = i + 2 < 2 || arguments.length <= i + 2 ? undefined : arguments[i + 2];
1183
+
1184
+ if (arg && arg.prototype && arg.prototype.render) {
1185
+ // eslint-disable-next-line no-console
1186
+ console.error('You seem to be applying the arguments in the wrong order. ' + "It should be ".concat(functionName, "(").concat(signature, ")(Component), not the other way around. ") + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#you-seem-to-be-applying-the-arguments-in-the-wrong-order');
1187
+ return;
1188
+ }
1189
+ }
1190
+ }
1191
+ }
1192
+ function isFunction(input) {
1193
+ return typeof input === 'function';
1194
+ }
1195
+ function noop() {// noop
1196
+ }
1197
+
1198
+ function isObjectLike(input) {
1199
+ return _typeof$1(input) === 'object' && input !== null;
1200
+ }
1201
+
1202
+ function isPlainObject(input) {
1203
+ if (!isObjectLike(input)) {
1204
+ return false;
1205
+ }
1206
+
1207
+ if (Object.getPrototypeOf(input) === null) {
1208
+ return true;
1209
+ }
1210
+
1211
+ var proto = input;
1212
+
1213
+ while (Object.getPrototypeOf(proto) !== null) {
1214
+ proto = Object.getPrototypeOf(proto);
1215
+ }
1216
+
1217
+ return Object.getPrototypeOf(input) === proto;
1218
+ }
1219
+ function isValidType(type, allowArray) {
1220
+ return typeof type === 'string' || _typeof$1(type) === 'symbol' || !!allowArray && Array.isArray(type) && type.every(function (t) {
1221
+ return isValidType(t, false);
1222
+ });
1223
+ }
1224
+
1225
+ function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1226
+
1227
+ function _defineProperties$3(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1228
+
1229
+ function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; }
1230
+
1231
+ function _defineProperty$3(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1232
+ /**
1233
+ * Provides a set of static methods for creating Disposables.
1234
+ * @param {Function} action Action to run during the first call to dispose.
1235
+ * The action is guaranteed to be run at most once.
1236
+ */
1237
+
1238
+ var Disposable = /*#__PURE__*/function () {
1239
+ function Disposable(action) {
1240
+ _classCallCheck$3(this, Disposable);
1241
+
1242
+ _defineProperty$3(this, "isDisposed", false);
1243
+
1244
+ _defineProperty$3(this, "action", void 0);
1245
+
1246
+ this.action = isFunction(action) ? action : noop;
1247
+ }
1248
+ /** Performs the task of cleaning up resources. */
1249
+
1250
+
1251
+ _createClass$3(Disposable, [{
1252
+ key: "dispose",
1253
+ value: function dispose() {
1254
+ if (!this.isDisposed) {
1255
+ this.action();
1256
+ this.isDisposed = true;
1257
+ }
1258
+ }
1259
+ }], [{
1260
+ key: "isDisposable",
1261
+ value:
1262
+ /**
1263
+ * Gets the disposable that does nothing when disposed.
1264
+ */
1265
+
1266
+ /**
1267
+ * Validates whether the given object is a disposable
1268
+ * @param {Object} Object to test whether it has a dispose method
1269
+ * @returns {Boolean} true if a disposable object, else false.
1270
+ */
1271
+ function isDisposable(d) {
1272
+ return Boolean(d && isFunction(d.dispose));
1273
+ }
1274
+ }, {
1275
+ key: "_fixup",
1276
+ value: function _fixup(result) {
1277
+ return Disposable.isDisposable(result) ? result : Disposable.empty;
1278
+ }
1279
+ /**
1280
+ * Creates a disposable object that invokes the specified action when disposed.
1281
+ * @param {Function} dispose Action to run during the first call to dispose.
1282
+ * The action is guaranteed to be run at most once.
1283
+ * @return {Disposable} The disposable object that runs the given action upon disposal.
1284
+ */
1285
+
1286
+ }, {
1287
+ key: "create",
1288
+ value: function create(action) {
1289
+ return new Disposable(action);
1290
+ }
1291
+ }]);
1292
+
1293
+ return Disposable;
1294
+ }();
1295
+ /**
1296
+ * Represents a group of disposable resources that are disposed together.
1297
+ * @constructor
1298
+ */
1299
+
1300
+ _defineProperty$3(Disposable, "empty", {
1301
+ dispose: noop
1302
+ });
1303
+
1304
+ var CompositeDisposable = /*#__PURE__*/function () {
1305
+ function CompositeDisposable() {
1306
+ _classCallCheck$3(this, CompositeDisposable);
1307
+
1308
+ _defineProperty$3(this, "isDisposed", false);
1309
+
1310
+ _defineProperty$3(this, "disposables", void 0);
1311
+
1312
+ for (var _len = arguments.length, disposables = new Array(_len), _key = 0; _key < _len; _key++) {
1313
+ disposables[_key] = arguments[_key];
1314
+ }
1315
+
1316
+ this.disposables = disposables;
1317
+ }
1318
+ /**
1319
+ * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
1320
+ * @param {Any} item Disposable to add.
1321
+ */
1322
+
1323
+
1324
+ _createClass$3(CompositeDisposable, [{
1325
+ key: "add",
1326
+ value: function add(item) {
1327
+ if (this.isDisposed) {
1328
+ item.dispose();
1329
+ } else {
1330
+ this.disposables.push(item);
1331
+ }
1332
+ }
1333
+ /**
1334
+ * Removes and disposes the first occurrence of a disposable from the CompositeDisposable.
1335
+ * @param {Any} item Disposable to remove.
1336
+ * @returns {Boolean} true if found; false otherwise.
1337
+ */
1338
+
1339
+ }, {
1340
+ key: "remove",
1341
+ value: function remove(item) {
1342
+ var shouldDispose = false;
1343
+
1344
+ if (!this.isDisposed) {
1345
+ var idx = this.disposables.indexOf(item);
1346
+
1347
+ if (idx !== -1) {
1348
+ shouldDispose = true;
1349
+ this.disposables.splice(idx, 1);
1350
+ item.dispose();
1351
+ }
1352
+ }
1353
+
1354
+ return shouldDispose;
1355
+ }
1356
+ /**
1357
+ * Disposes all disposables in the group and removes them from the group but
1358
+ * does not dispose the CompositeDisposable.
1359
+ */
1360
+
1361
+ }, {
1362
+ key: "clear",
1363
+ value: function clear() {
1364
+ if (!this.isDisposed) {
1365
+ var len = this.disposables.length;
1366
+ var currentDisposables = new Array(len);
1367
+
1368
+ for (var i = 0; i < len; i++) {
1369
+ currentDisposables[i] = this.disposables[i];
1370
+ }
1371
+
1372
+ this.disposables = [];
1373
+
1374
+ for (var _i = 0; _i < len; _i++) {
1375
+ currentDisposables[_i].dispose();
1376
+ }
1377
+ }
1378
+ }
1379
+ /**
1380
+ * Disposes all disposables in the group and removes them from the group.
1381
+ */
1382
+
1383
+ }, {
1384
+ key: "dispose",
1385
+ value: function dispose() {
1386
+ if (!this.isDisposed) {
1387
+ this.isDisposed = true;
1388
+ var len = this.disposables.length;
1389
+ var currentDisposables = new Array(len);
1390
+
1391
+ for (var i = 0; i < len; i++) {
1392
+ currentDisposables[i] = this.disposables[i];
1393
+ }
1394
+
1395
+ this.disposables = [];
1396
+
1397
+ for (var _i2 = 0; _i2 < len; _i2++) {
1398
+ currentDisposables[_i2].dispose();
1399
+ }
1400
+ }
1401
+ }
1402
+ }]);
1403
+
1404
+ return CompositeDisposable;
1405
+ }();
1406
+ /**
1407
+ * Represents a disposable resource whose underlying disposable resource can
1408
+ * be replaced by another disposable resource, causing automatic disposal of
1409
+ * the previous underlying disposable resource.
1410
+ */
1411
+
1412
+ var SerialDisposable = /*#__PURE__*/function () {
1413
+ function SerialDisposable() {
1414
+ _classCallCheck$3(this, SerialDisposable);
1415
+
1416
+ _defineProperty$3(this, "isDisposed", false);
1417
+
1418
+ _defineProperty$3(this, "current", void 0);
1419
+ }
1420
+
1421
+ _createClass$3(SerialDisposable, [{
1422
+ key: "getDisposable",
1423
+ value:
1424
+ /**
1425
+ * Gets the underlying disposable.
1426
+ * @returns {Any} the underlying disposable.
1427
+ */
1428
+ function getDisposable() {
1429
+ return this.current;
1430
+ }
1431
+ }, {
1432
+ key: "setDisposable",
1433
+ value: function setDisposable(value) {
1434
+ var shouldDispose = this.isDisposed;
1435
+
1436
+ if (!shouldDispose) {
1437
+ var old = this.current;
1438
+ this.current = value;
1439
+
1440
+ if (old) {
1441
+ old.dispose();
1442
+ }
1443
+ }
1444
+
1445
+ if (shouldDispose && value) {
1446
+ value.dispose();
1447
+ }
1448
+ }
1449
+ /** Performs the task of cleaning up resources. */
1450
+
1451
+ }, {
1452
+ key: "dispose",
1453
+ value: function dispose() {
1454
+ if (!this.isDisposed) {
1455
+ this.isDisposed = true;
1456
+ var old = this.current;
1457
+ this.current = undefined;
1458
+
1459
+ if (old) {
1460
+ old.dispose();
1461
+ }
1462
+ }
1463
+ }
1464
+ }]);
1465
+
1466
+ return SerialDisposable;
1467
+ }();
1468
+
1469
+ var reactIs$1 = {exports: {}};
1470
+
1471
+ var reactIs_production_min = {};
1472
+
1473
+ /** @license React v16.13.1
1474
+ * react-is.production.min.js
1475
+ *
1476
+ * Copyright (c) Facebook, Inc. and its affiliates.
1477
+ *
1478
+ * This source code is licensed under the MIT license found in the
1479
+ * LICENSE file in the root directory of this source tree.
1480
+ */
1481
+ var b="function"===typeof Symbol&&Symbol.for,c=b?Symbol.for("react.element"):60103,d=b?Symbol.for("react.portal"):60106,e=b?Symbol.for("react.fragment"):60107,f=b?Symbol.for("react.strict_mode"):60108,g=b?Symbol.for("react.profiler"):60114,h=b?Symbol.for("react.provider"):60109,k=b?Symbol.for("react.context"):60110,l=b?Symbol.for("react.async_mode"):60111,m=b?Symbol.for("react.concurrent_mode"):60111,n=b?Symbol.for("react.forward_ref"):60112,p=b?Symbol.for("react.suspense"):60113,q=b?
1482
+ Symbol.for("react.suspense_list"):60120,r=b?Symbol.for("react.memo"):60115,t=b?Symbol.for("react.lazy"):60116,v=b?Symbol.for("react.block"):60121,w=b?Symbol.for("react.fundamental"):60117,x=b?Symbol.for("react.responder"):60118,y=b?Symbol.for("react.scope"):60119;
1483
+ function z(a){if("object"===typeof a&&null!==a){var u=a.$$typeof;switch(u){case c:switch(a=a.type,a){case l:case m:case e:case g:case f:case p:return a;default:switch(a=a&&a.$$typeof,a){case k:case n:case t:case r:case h:return a;default:return u}}case d:return u}}}function A(a){return z(a)===m}reactIs_production_min.AsyncMode=l;reactIs_production_min.ConcurrentMode=m;reactIs_production_min.ContextConsumer=k;reactIs_production_min.ContextProvider=h;reactIs_production_min.Element=c;reactIs_production_min.ForwardRef=n;reactIs_production_min.Fragment=e;reactIs_production_min.Lazy=t;reactIs_production_min.Memo=r;reactIs_production_min.Portal=d;
1484
+ reactIs_production_min.Profiler=g;reactIs_production_min.StrictMode=f;reactIs_production_min.Suspense=p;reactIs_production_min.isAsyncMode=function(a){return A(a)||z(a)===l};reactIs_production_min.isConcurrentMode=A;reactIs_production_min.isContextConsumer=function(a){return z(a)===k};reactIs_production_min.isContextProvider=function(a){return z(a)===h};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===c};reactIs_production_min.isForwardRef=function(a){return z(a)===n};reactIs_production_min.isFragment=function(a){return z(a)===e};reactIs_production_min.isLazy=function(a){return z(a)===t};
1485
+ reactIs_production_min.isMemo=function(a){return z(a)===r};reactIs_production_min.isPortal=function(a){return z(a)===d};reactIs_production_min.isProfiler=function(a){return z(a)===g};reactIs_production_min.isStrictMode=function(a){return z(a)===f};reactIs_production_min.isSuspense=function(a){return z(a)===p};
1486
+ reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===e||a===m||a===g||a===f||a===p||a===q||"object"===typeof a&&null!==a&&(a.$$typeof===t||a.$$typeof===r||a.$$typeof===h||a.$$typeof===k||a.$$typeof===n||a.$$typeof===w||a.$$typeof===x||a.$$typeof===y||a.$$typeof===v)};reactIs_production_min.typeOf=z;
1487
+
1488
+ var reactIs_development = {};
1489
+
1490
+ /** @license React v16.13.1
1491
+ * react-is.development.js
1492
+ *
1493
+ * Copyright (c) Facebook, Inc. and its affiliates.
1494
+ *
1495
+ * This source code is licensed under the MIT license found in the
1496
+ * LICENSE file in the root directory of this source tree.
1497
+ */
1498
+
1499
+
1500
+
1501
+ if (process.env.NODE_ENV !== "production") {
1502
+ (function() {
1503
+
1504
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
1505
+ // nor polyfill, then a plain number is used for performance.
1506
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
1507
+ var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
1508
+ var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
1509
+ var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
1510
+ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
1511
+ var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
1512
+ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
1513
+ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
1514
+ // (unstable) APIs that have been removed. Can we remove the symbols?
1515
+
1516
+ var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
1517
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
1518
+ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
1519
+ var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
1520
+ var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
1521
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
1522
+ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
1523
+ var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
1524
+ var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
1525
+ var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
1526
+ var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
1527
+
1528
+ function isValidElementType(type) {
1529
+ return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1530
+ type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE || type.$$typeof === REACT_BLOCK_TYPE);
1531
+ }
1532
+
1533
+ function typeOf(object) {
1534
+ if (typeof object === 'object' && object !== null) {
1535
+ var $$typeof = object.$$typeof;
1536
+
1537
+ switch ($$typeof) {
1538
+ case REACT_ELEMENT_TYPE:
1539
+ var type = object.type;
1540
+
1541
+ switch (type) {
1542
+ case REACT_ASYNC_MODE_TYPE:
1543
+ case REACT_CONCURRENT_MODE_TYPE:
1544
+ case REACT_FRAGMENT_TYPE:
1545
+ case REACT_PROFILER_TYPE:
1546
+ case REACT_STRICT_MODE_TYPE:
1547
+ case REACT_SUSPENSE_TYPE:
1548
+ return type;
1549
+
1550
+ default:
1551
+ var $$typeofType = type && type.$$typeof;
1552
+
1553
+ switch ($$typeofType) {
1554
+ case REACT_CONTEXT_TYPE:
1555
+ case REACT_FORWARD_REF_TYPE:
1556
+ case REACT_LAZY_TYPE:
1557
+ case REACT_MEMO_TYPE:
1558
+ case REACT_PROVIDER_TYPE:
1559
+ return $$typeofType;
1560
+
1561
+ default:
1562
+ return $$typeof;
1563
+ }
1564
+
1565
+ }
1566
+
1567
+ case REACT_PORTAL_TYPE:
1568
+ return $$typeof;
1569
+ }
1570
+ }
1571
+
1572
+ return undefined;
1573
+ } // AsyncMode is deprecated along with isAsyncMode
1574
+
1575
+ var AsyncMode = REACT_ASYNC_MODE_TYPE;
1576
+ var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
1577
+ var ContextConsumer = REACT_CONTEXT_TYPE;
1578
+ var ContextProvider = REACT_PROVIDER_TYPE;
1579
+ var Element = REACT_ELEMENT_TYPE;
1580
+ var ForwardRef = REACT_FORWARD_REF_TYPE;
1581
+ var Fragment = REACT_FRAGMENT_TYPE;
1582
+ var Lazy = REACT_LAZY_TYPE;
1583
+ var Memo = REACT_MEMO_TYPE;
1584
+ var Portal = REACT_PORTAL_TYPE;
1585
+ var Profiler = REACT_PROFILER_TYPE;
1586
+ var StrictMode = REACT_STRICT_MODE_TYPE;
1587
+ var Suspense = REACT_SUSPENSE_TYPE;
1588
+ var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
1589
+
1590
+ function isAsyncMode(object) {
1591
+ {
1592
+ if (!hasWarnedAboutDeprecatedIsAsyncMode) {
1593
+ hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
1594
+
1595
+ console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 17+. Update your code to use ' + 'ReactIs.isConcurrentMode() instead. It has the exact same API.');
1596
+ }
1597
+ }
1598
+
1599
+ return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
1600
+ }
1601
+ function isConcurrentMode(object) {
1602
+ return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
1603
+ }
1604
+ function isContextConsumer(object) {
1605
+ return typeOf(object) === REACT_CONTEXT_TYPE;
1606
+ }
1607
+ function isContextProvider(object) {
1608
+ return typeOf(object) === REACT_PROVIDER_TYPE;
1609
+ }
1610
+ function isElement(object) {
1611
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1612
+ }
1613
+ function isForwardRef(object) {
1614
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
1615
+ }
1616
+ function isFragment(object) {
1617
+ return typeOf(object) === REACT_FRAGMENT_TYPE;
1618
+ }
1619
+ function isLazy(object) {
1620
+ return typeOf(object) === REACT_LAZY_TYPE;
1621
+ }
1622
+ function isMemo(object) {
1623
+ return typeOf(object) === REACT_MEMO_TYPE;
1624
+ }
1625
+ function isPortal(object) {
1626
+ return typeOf(object) === REACT_PORTAL_TYPE;
1627
+ }
1628
+ function isProfiler(object) {
1629
+ return typeOf(object) === REACT_PROFILER_TYPE;
1630
+ }
1631
+ function isStrictMode(object) {
1632
+ return typeOf(object) === REACT_STRICT_MODE_TYPE;
1633
+ }
1634
+ function isSuspense(object) {
1635
+ return typeOf(object) === REACT_SUSPENSE_TYPE;
1636
+ }
1637
+
1638
+ reactIs_development.AsyncMode = AsyncMode;
1639
+ reactIs_development.ConcurrentMode = ConcurrentMode;
1640
+ reactIs_development.ContextConsumer = ContextConsumer;
1641
+ reactIs_development.ContextProvider = ContextProvider;
1642
+ reactIs_development.Element = Element;
1643
+ reactIs_development.ForwardRef = ForwardRef;
1644
+ reactIs_development.Fragment = Fragment;
1645
+ reactIs_development.Lazy = Lazy;
1646
+ reactIs_development.Memo = Memo;
1647
+ reactIs_development.Portal = Portal;
1648
+ reactIs_development.Profiler = Profiler;
1649
+ reactIs_development.StrictMode = StrictMode;
1650
+ reactIs_development.Suspense = Suspense;
1651
+ reactIs_development.isAsyncMode = isAsyncMode;
1652
+ reactIs_development.isConcurrentMode = isConcurrentMode;
1653
+ reactIs_development.isContextConsumer = isContextConsumer;
1654
+ reactIs_development.isContextProvider = isContextProvider;
1655
+ reactIs_development.isElement = isElement;
1656
+ reactIs_development.isForwardRef = isForwardRef;
1657
+ reactIs_development.isFragment = isFragment;
1658
+ reactIs_development.isLazy = isLazy;
1659
+ reactIs_development.isMemo = isMemo;
1660
+ reactIs_development.isPortal = isPortal;
1661
+ reactIs_development.isProfiler = isProfiler;
1662
+ reactIs_development.isStrictMode = isStrictMode;
1663
+ reactIs_development.isSuspense = isSuspense;
1664
+ reactIs_development.isValidElementType = isValidElementType;
1665
+ reactIs_development.typeOf = typeOf;
1666
+ })();
1667
+ }
1668
+
1669
+ if (process.env.NODE_ENV === 'production') {
1670
+ reactIs$1.exports = reactIs_production_min;
1671
+ } else {
1672
+ reactIs$1.exports = reactIs_development;
1673
+ }
1674
+
1675
+ var reactIs = reactIs$1.exports;
1676
+
1677
+ /**
1678
+ * Copyright 2015, Yahoo! Inc.
1679
+ * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
1680
+ */
1681
+ var REACT_STATICS = {
1682
+ childContextTypes: true,
1683
+ contextType: true,
1684
+ contextTypes: true,
1685
+ defaultProps: true,
1686
+ displayName: true,
1687
+ getDefaultProps: true,
1688
+ getDerivedStateFromError: true,
1689
+ getDerivedStateFromProps: true,
1690
+ mixins: true,
1691
+ propTypes: true,
1692
+ type: true
1693
+ };
1694
+ var KNOWN_STATICS = {
1695
+ name: true,
1696
+ length: true,
1697
+ prototype: true,
1698
+ caller: true,
1699
+ callee: true,
1700
+ arguments: true,
1701
+ arity: true
1702
+ };
1703
+ var FORWARD_REF_STATICS = {
1704
+ '$$typeof': true,
1705
+ render: true,
1706
+ defaultProps: true,
1707
+ displayName: true,
1708
+ propTypes: true
1709
+ };
1710
+ var MEMO_STATICS = {
1711
+ '$$typeof': true,
1712
+ compare: true,
1713
+ defaultProps: true,
1714
+ displayName: true,
1715
+ propTypes: true,
1716
+ type: true
1717
+ };
1718
+ var TYPE_STATICS = {};
1719
+ TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
1720
+ TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
1721
+
1722
+ function getStatics(component) {
1723
+ // React v16.11 and below
1724
+ if (reactIs.isMemo(component)) {
1725
+ return MEMO_STATICS;
1726
+ } // React v16.12 and above
1727
+
1728
+
1729
+ return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
1730
+ }
1731
+
1732
+ var defineProperty = Object.defineProperty;
1733
+ var getOwnPropertyNames = Object.getOwnPropertyNames;
1734
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
1735
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
1736
+ var getPrototypeOf = Object.getPrototypeOf;
1737
+ var objectPrototype = Object.prototype;
1738
+ function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
1739
+ if (typeof sourceComponent !== 'string') {
1740
+ // don't hoist over string (html) components
1741
+ if (objectPrototype) {
1742
+ var inheritedComponent = getPrototypeOf(sourceComponent);
1743
+
1744
+ if (inheritedComponent && inheritedComponent !== objectPrototype) {
1745
+ hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
1746
+ }
1747
+ }
1748
+
1749
+ var keys = getOwnPropertyNames(sourceComponent);
1750
+
1751
+ if (getOwnPropertySymbols) {
1752
+ keys = keys.concat(getOwnPropertySymbols(sourceComponent));
1753
+ }
1754
+
1755
+ var targetStatics = getStatics(targetComponent);
1756
+ var sourceStatics = getStatics(sourceComponent);
1757
+
1758
+ for (var i = 0; i < keys.length; ++i) {
1759
+ var key = keys[i];
1760
+
1761
+ if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
1762
+ var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
1763
+
1764
+ try {
1765
+ // Avoid failures from read-only properties
1766
+ defineProperty(targetComponent, key, descriptor);
1767
+ } catch (e) {}
1768
+ }
1769
+ }
1770
+ }
1771
+
1772
+ return targetComponent;
1773
+ }
1774
+
1775
+ var hoistNonReactStatics_cjs = hoistNonReactStatics;
1776
+
1777
+ var hoistStatics = hoistNonReactStatics_cjs;
1778
+
1779
+ function _typeof(obj) { "@babel/helpers - typeof"; 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); }
1780
+
1781
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
1782
+
1783
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
1784
+
1785
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
1786
+
1787
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
1788
+
1789
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
1790
+
1791
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
1792
+
1793
+ function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1794
+
1795
+ function _defineProperties$2(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
1796
+
1797
+ function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); return Constructor; }
1798
+
1799
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
1800
+
1801
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
1802
+
1803
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
1804
+
1805
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
1806
+
1807
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
1808
+
1809
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
1810
+
1811
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1812
+
1813
+ function _defineProperty$2(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
1814
+ function decorateHandler(_ref) {
1815
+ var DecoratedComponent = _ref.DecoratedComponent,
1816
+ createHandler = _ref.createHandler,
1817
+ createMonitor = _ref.createMonitor,
1818
+ createConnector = _ref.createConnector,
1819
+ registerHandler = _ref.registerHandler,
1820
+ containerDisplayName = _ref.containerDisplayName,
1821
+ getType = _ref.getType,
1822
+ collect = _ref.collect,
1823
+ options = _ref.options;
1824
+ var _options$arePropsEqua = options.arePropsEqual,
1825
+ arePropsEqual = _options$arePropsEqua === void 0 ? shallowEqual : _options$arePropsEqua;
1826
+ var Decorated = DecoratedComponent;
1827
+ var displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component';
1828
+
1829
+ var DragDropContainer = /*#__PURE__*/function (_Component) {
1830
+ _inherits(DragDropContainer, _Component);
1831
+
1832
+ var _super = _createSuper(DragDropContainer);
1833
+
1834
+ function DragDropContainer(props) {
1835
+ var _this;
1836
+
1837
+ _classCallCheck$2(this, DragDropContainer);
1838
+
1839
+ _this = _super.call(this, props);
1840
+
1841
+ _defineProperty$2(_assertThisInitialized(_this), "decoratedRef", createRef());
1842
+
1843
+ _defineProperty$2(_assertThisInitialized(_this), "handlerId", void 0);
1844
+
1845
+ _defineProperty$2(_assertThisInitialized(_this), "manager", void 0);
1846
+
1847
+ _defineProperty$2(_assertThisInitialized(_this), "handlerMonitor", void 0);
1848
+
1849
+ _defineProperty$2(_assertThisInitialized(_this), "handlerConnector", void 0);
1850
+
1851
+ _defineProperty$2(_assertThisInitialized(_this), "handler", void 0);
1852
+
1853
+ _defineProperty$2(_assertThisInitialized(_this), "disposable", void 0);
1854
+
1855
+ _defineProperty$2(_assertThisInitialized(_this), "currentType", void 0);
1856
+
1857
+ _defineProperty$2(_assertThisInitialized(_this), "handleChange", function () {
1858
+ var nextState = _this.getCurrentState();
1859
+
1860
+ if (!shallowEqual(nextState, _this.state)) {
1861
+ _this.setState(nextState);
1862
+ }
1863
+ });
1864
+
1865
+ _this.disposable = new SerialDisposable();
1866
+
1867
+ _this.receiveProps(props);
1868
+
1869
+ _this.dispose();
1870
+
1871
+ return _this;
1872
+ }
1873
+
1874
+ _createClass$2(DragDropContainer, [{
1875
+ key: "getHandlerId",
1876
+ value: function getHandlerId() {
1877
+ return this.handlerId;
1878
+ }
1879
+ }, {
1880
+ key: "getDecoratedComponentInstance",
1881
+ value: function getDecoratedComponentInstance() {
1882
+ invariant(this.decoratedRef.current, 'In order to access an instance of the decorated component, it must either be a class component or use React.forwardRef()');
1883
+ return this.decoratedRef.current;
1884
+ }
1885
+ }, {
1886
+ key: "shouldComponentUpdate",
1887
+ value: function shouldComponentUpdate(nextProps, nextState) {
1888
+ return !arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state);
1889
+ }
1890
+ }, {
1891
+ key: "componentDidMount",
1892
+ value: function componentDidMount() {
1893
+ this.disposable = new SerialDisposable();
1894
+ this.currentType = undefined;
1895
+ this.receiveProps(this.props);
1896
+ this.handleChange();
1897
+ }
1898
+ }, {
1899
+ key: "componentDidUpdate",
1900
+ value: function componentDidUpdate(prevProps) {
1901
+ if (!arePropsEqual(this.props, prevProps)) {
1902
+ this.receiveProps(this.props);
1903
+ this.handleChange();
1904
+ }
1905
+ }
1906
+ }, {
1907
+ key: "componentWillUnmount",
1908
+ value: function componentWillUnmount() {
1909
+ this.dispose();
1910
+ }
1911
+ }, {
1912
+ key: "receiveProps",
1913
+ value: function receiveProps(props) {
1914
+ if (!this.handler) {
1915
+ return;
1916
+ }
1917
+
1918
+ this.handler.receiveProps(props);
1919
+ this.receiveType(getType(props));
1920
+ }
1921
+ }, {
1922
+ key: "receiveType",
1923
+ value: function receiveType(type) {
1924
+ if (!this.handlerMonitor || !this.manager || !this.handlerConnector) {
1925
+ return;
1926
+ }
1927
+
1928
+ if (type === this.currentType) {
1929
+ return;
1930
+ }
1931
+
1932
+ this.currentType = type;
1933
+
1934
+ var _registerHandler = registerHandler(type, this.handler, this.manager),
1935
+ _registerHandler2 = _slicedToArray(_registerHandler, 2),
1936
+ handlerId = _registerHandler2[0],
1937
+ unregister = _registerHandler2[1];
1938
+
1939
+ this.handlerId = handlerId;
1940
+ this.handlerMonitor.receiveHandlerId(handlerId);
1941
+ this.handlerConnector.receiveHandlerId(handlerId);
1942
+ var globalMonitor = this.manager.getMonitor();
1943
+ var unsubscribe = globalMonitor.subscribeToStateChange(this.handleChange, {
1944
+ handlerIds: [handlerId]
1945
+ });
1946
+ this.disposable.setDisposable(new CompositeDisposable(new Disposable(unsubscribe), new Disposable(unregister)));
1947
+ }
1948
+ }, {
1949
+ key: "dispose",
1950
+ value: function dispose() {
1951
+ this.disposable.dispose();
1952
+
1953
+ if (this.handlerConnector) {
1954
+ this.handlerConnector.receiveHandlerId(null);
1955
+ }
1956
+ }
1957
+ }, {
1958
+ key: "getCurrentState",
1959
+ value: function getCurrentState() {
1960
+ if (!this.handlerConnector) {
1961
+ return {};
1962
+ }
1963
+
1964
+ var nextState = collect(this.handlerConnector.hooks, this.handlerMonitor, this.props);
1965
+
1966
+ if (process.env.NODE_ENV !== 'production') {
1967
+ invariant(isPlainObject(nextState), 'Expected `collect` specified as the second argument to ' + '%s for %s to return a plain object of props to inject. ' + 'Instead, received %s.', containerDisplayName, displayName, nextState);
1968
+ }
1969
+
1970
+ return nextState;
1971
+ }
1972
+ }, {
1973
+ key: "render",
1974
+ value: function render() {
1975
+ var _this2 = this;
1976
+
1977
+ return jsx(DndContext.Consumer, {
1978
+ children: function children(_ref2) {
1979
+ var dragDropManager = _ref2.dragDropManager;
1980
+
1981
+ _this2.receiveDragDropManager(dragDropManager);
1982
+
1983
+ if (typeof requestAnimationFrame !== 'undefined') {
1984
+ requestAnimationFrame(function () {
1985
+ var _this2$handlerConnect;
1986
+
1987
+ return (_this2$handlerConnect = _this2.handlerConnector) === null || _this2$handlerConnect === void 0 ? void 0 : _this2$handlerConnect.reconnect();
1988
+ });
1989
+ }
1990
+
1991
+ return jsx(Decorated, Object.assign({}, _this2.props, _this2.getCurrentState(), {
1992
+ // NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component.
1993
+ ref: isRefable(Decorated) ? _this2.decoratedRef : null
1994
+ }), void 0);
1995
+ }
1996
+ }, void 0);
1997
+ }
1998
+ }, {
1999
+ key: "receiveDragDropManager",
2000
+ value: function receiveDragDropManager(dragDropManager) {
2001
+ if (this.manager !== undefined) {
2002
+ return;
2003
+ }
2004
+
2005
+ invariant(dragDropManager !== undefined, 'Could not find the drag and drop manager in the context of %s. ' + 'Make sure to render a DndProvider component in your top-level component. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/troubleshooting#could-not-find-the-drag-and-drop-manager-in-the-context', displayName, displayName);
2006
+
2007
+ if (dragDropManager === undefined) {
2008
+ return;
2009
+ }
2010
+
2011
+ this.manager = dragDropManager;
2012
+ this.handlerMonitor = createMonitor(dragDropManager);
2013
+ this.handlerConnector = createConnector(dragDropManager.getBackend());
2014
+ this.handler = createHandler(this.handlerMonitor, this.decoratedRef);
2015
+ }
2016
+ }]);
2017
+
2018
+ return DragDropContainer;
2019
+ }(Component);
2020
+
2021
+ _defineProperty$2(DragDropContainer, "DecoratedComponent", DecoratedComponent);
2022
+
2023
+ _defineProperty$2(DragDropContainer, "displayName", "".concat(containerDisplayName, "(").concat(displayName, ")"));
2024
+
2025
+ return hoistStatics(DragDropContainer, DecoratedComponent);
2026
+ }
2027
+
2028
+ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2029
+
2030
+ function _defineProperties$1(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2031
+
2032
+ function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
2033
+
2034
+ function _defineProperty$1(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2035
+ var ALLOWED_SPEC_METHODS$1 = ['canDrag', 'beginDrag', 'isDragging', 'endDrag'];
2036
+ var REQUIRED_SPEC_METHODS = ['beginDrag'];
2037
+
2038
+ var SourceImpl = /*#__PURE__*/function () {
2039
+ function SourceImpl(spec, monitor, ref) {
2040
+ var _this = this;
2041
+
2042
+ _classCallCheck$1(this, SourceImpl);
2043
+
2044
+ _defineProperty$1(this, "props", null);
2045
+
2046
+ _defineProperty$1(this, "spec", void 0);
2047
+
2048
+ _defineProperty$1(this, "monitor", void 0);
2049
+
2050
+ _defineProperty$1(this, "ref", void 0);
2051
+
2052
+ _defineProperty$1(this, "beginDrag", function () {
2053
+ if (!_this.props) {
2054
+ return;
2055
+ }
2056
+
2057
+ var item = _this.spec.beginDrag(_this.props, _this.monitor, _this.ref.current);
2058
+
2059
+ if (process.env.NODE_ENV !== 'production') {
2060
+ invariant(isPlainObject(item), 'beginDrag() must return a plain object that represents the dragged item. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', item);
2061
+ }
2062
+
2063
+ return item;
2064
+ });
2065
+
2066
+ this.spec = spec;
2067
+ this.monitor = monitor;
2068
+ this.ref = ref;
2069
+ }
2070
+
2071
+ _createClass$1(SourceImpl, [{
2072
+ key: "receiveProps",
2073
+ value: function receiveProps(props) {
2074
+ this.props = props;
2075
+ }
2076
+ }, {
2077
+ key: "canDrag",
2078
+ value: function canDrag() {
2079
+ if (!this.props) {
2080
+ return false;
2081
+ }
2082
+
2083
+ if (!this.spec.canDrag) {
2084
+ return true;
2085
+ }
2086
+
2087
+ return this.spec.canDrag(this.props, this.monitor);
2088
+ }
2089
+ }, {
2090
+ key: "isDragging",
2091
+ value: function isDragging(globalMonitor, sourceId) {
2092
+ if (!this.props) {
2093
+ return false;
2094
+ }
2095
+
2096
+ if (!this.spec.isDragging) {
2097
+ return sourceId === globalMonitor.getSourceId();
2098
+ }
2099
+
2100
+ return this.spec.isDragging(this.props, this.monitor);
2101
+ }
2102
+ }, {
2103
+ key: "endDrag",
2104
+ value: function endDrag() {
2105
+ if (!this.props) {
2106
+ return;
2107
+ }
2108
+
2109
+ if (!this.spec.endDrag) {
2110
+ return;
2111
+ }
2112
+
2113
+ this.spec.endDrag(this.props, this.monitor, getDecoratedComponent(this.ref));
2114
+ }
2115
+ }]);
2116
+
2117
+ return SourceImpl;
2118
+ }();
2119
+
2120
+ function createSourceFactory(spec) {
2121
+ Object.keys(spec).forEach(function (key) {
2122
+ invariant(ALLOWED_SPEC_METHODS$1.indexOf(key) > -1, 'Expected the drag source specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', ALLOWED_SPEC_METHODS$1.join(', '), key);
2123
+ invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]);
2124
+ });
2125
+ REQUIRED_SPEC_METHODS.forEach(function (key) {
2126
+ invariant(typeof spec[key] === 'function', 'Expected %s in the drag source specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', key, key, spec[key]);
2127
+ });
2128
+ return function createSource(monitor, ref) {
2129
+ return new SourceImpl(spec, monitor, ref);
2130
+ };
2131
+ }
2132
+
2133
+ /**
2134
+ * Decorates a component as a dragsource
2135
+ * @param type The dragsource type
2136
+ * @param spec The drag source specification
2137
+ * @param collect The props collector function
2138
+ * @param options DnD options
2139
+ */
2140
+
2141
+ function DragSource(type, spec, collect) {
2142
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2143
+ checkDecoratorArguments('DragSource', 'type, spec, collect[, options]', type, spec, collect, options);
2144
+ var getType = type;
2145
+
2146
+ if (typeof type !== 'function') {
2147
+ invariant(isValidType(type), 'Expected "type" provided as the first argument to DragSource to be ' + 'a string, or a function that returns a string given the current props. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', type);
2148
+
2149
+ getType = function getType() {
2150
+ return type;
2151
+ };
2152
+ }
2153
+
2154
+ invariant(isPlainObject(spec), 'Expected "spec" provided as the second argument to DragSource to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', spec);
2155
+ var createSource = createSourceFactory(spec);
2156
+ invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DragSource to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect);
2157
+ invariant(isPlainObject(options), 'Expected "options" provided as the fourth argument to DragSource to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drag-source', collect);
2158
+ return function decorateSource(DecoratedComponent) {
2159
+ return decorateHandler({
2160
+ containerDisplayName: 'DragSource',
2161
+ createHandler: createSource,
2162
+ registerHandler: registerSource,
2163
+ createConnector: function createConnector(backend) {
2164
+ return new SourceConnector(backend);
2165
+ },
2166
+ createMonitor: function createMonitor(manager) {
2167
+ return new DragSourceMonitorImpl(manager);
2168
+ },
2169
+ DecoratedComponent: DecoratedComponent,
2170
+ getType: getType,
2171
+ collect: collect,
2172
+ options: options
2173
+ });
2174
+ };
2175
+ }
2176
+
2177
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2178
+
2179
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
2180
+
2181
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2182
+
2183
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
2184
+ var ALLOWED_SPEC_METHODS = ['canDrop', 'hover', 'drop'];
2185
+
2186
+ var TargetImpl = /*#__PURE__*/function () {
2187
+ function TargetImpl(spec, monitor, ref) {
2188
+ _classCallCheck(this, TargetImpl);
2189
+
2190
+ _defineProperty(this, "props", null);
2191
+
2192
+ _defineProperty(this, "spec", void 0);
2193
+
2194
+ _defineProperty(this, "monitor", void 0);
2195
+
2196
+ _defineProperty(this, "ref", void 0);
2197
+
2198
+ this.spec = spec;
2199
+ this.monitor = monitor;
2200
+ this.ref = ref;
2201
+ }
2202
+
2203
+ _createClass(TargetImpl, [{
2204
+ key: "receiveProps",
2205
+ value: function receiveProps(props) {
2206
+ this.props = props;
2207
+ }
2208
+ }, {
2209
+ key: "receiveMonitor",
2210
+ value: function receiveMonitor(monitor) {
2211
+ this.monitor = monitor;
2212
+ }
2213
+ }, {
2214
+ key: "canDrop",
2215
+ value: function canDrop() {
2216
+ if (!this.spec.canDrop) {
2217
+ return true;
2218
+ }
2219
+
2220
+ return this.spec.canDrop(this.props, this.monitor);
2221
+ }
2222
+ }, {
2223
+ key: "hover",
2224
+ value: function hover() {
2225
+ if (!this.spec.hover || !this.props) {
2226
+ return;
2227
+ }
2228
+
2229
+ this.spec.hover(this.props, this.monitor, getDecoratedComponent(this.ref));
2230
+ }
2231
+ }, {
2232
+ key: "drop",
2233
+ value: function drop() {
2234
+ if (!this.spec.drop) {
2235
+ return undefined;
2236
+ }
2237
+
2238
+ var dropResult = this.spec.drop(this.props, this.monitor, this.ref.current);
2239
+
2240
+ if (process.env.NODE_ENV !== 'production') {
2241
+ invariant(typeof dropResult === 'undefined' || isPlainObject(dropResult), 'drop() must either return undefined, or an object that represents the drop result. ' + 'Instead received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', dropResult);
2242
+ }
2243
+
2244
+ return dropResult;
2245
+ }
2246
+ }]);
2247
+
2248
+ return TargetImpl;
2249
+ }();
2250
+
2251
+ function createTargetFactory(spec) {
2252
+ Object.keys(spec).forEach(function (key) {
2253
+ invariant(ALLOWED_SPEC_METHODS.indexOf(key) > -1, 'Expected the drop target specification to only have ' + 'some of the following keys: %s. ' + 'Instead received a specification with an unexpected "%s" key. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', ALLOWED_SPEC_METHODS.join(', '), key);
2254
+ invariant(typeof spec[key] === 'function', 'Expected %s in the drop target specification to be a function. ' + 'Instead received a specification with %s: %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', key, key, spec[key]);
2255
+ });
2256
+ return function createTarget(monitor, ref) {
2257
+ return new TargetImpl(spec, monitor, ref);
2258
+ };
2259
+ }
2260
+
2261
+ /**
2262
+ * @param type The accepted target type
2263
+ * @param spec The DropTarget specification
2264
+ * @param collect The props collector function
2265
+ * @param options Options
2266
+ */
2267
+
2268
+ function DropTarget(type, spec, collect) {
2269
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2270
+ checkDecoratorArguments('DropTarget', 'type, spec, collect[, options]', type, spec, collect, options);
2271
+ var getType = type;
2272
+
2273
+ if (typeof type !== 'function') {
2274
+ invariant(isValidType(type, true), 'Expected "type" provided as the first argument to DropTarget to be ' + 'a string, an array of strings, or a function that returns either given ' + 'the current props. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', type);
2275
+
2276
+ getType = function getType() {
2277
+ return type;
2278
+ };
2279
+ }
2280
+
2281
+ invariant(isPlainObject(spec), 'Expected "spec" provided as the second argument to DropTarget to be ' + 'a plain object. Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', spec);
2282
+ var createTarget = createTargetFactory(spec);
2283
+ invariant(typeof collect === 'function', 'Expected "collect" provided as the third argument to DropTarget to be ' + 'a function that returns a plain object of props to inject. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect);
2284
+ invariant(isPlainObject(options), 'Expected "options" provided as the fourth argument to DropTarget to be ' + 'a plain object when specified. ' + 'Instead, received %s. ' + 'Read more: http://react-dnd.github.io/react-dnd/docs/api/drop-target', collect);
2285
+ return function decorateTarget(DecoratedComponent) {
2286
+ return decorateHandler({
2287
+ containerDisplayName: 'DropTarget',
2288
+ createHandler: createTarget,
2289
+ registerHandler: registerTarget,
2290
+ createMonitor: function createMonitor(manager) {
2291
+ return new DropTargetMonitorImpl(manager);
2292
+ },
2293
+ createConnector: function createConnector(backend) {
2294
+ return new TargetConnector(backend);
2295
+ },
2296
+ DecoratedComponent: DecoratedComponent,
2297
+ getType: getType,
2298
+ collect: collect,
2299
+ options: options
2300
+ });
2301
+ };
2302
+ }
2303
+
2304
+ const log$1 = debug('@pie-element:categorize:configure');
2305
+ const Helper = withStyles(theme => ({
2306
+ helper: {
2307
+ display: 'flex',
2308
+ alignItems: 'center',
2309
+ fontSize: theme.typography.fontSize - 2,
2310
+ color: `rgba(${theme.palette.common.black}, 0.4)`,
2311
+ width: '100%',
2312
+ height: '100%'
2313
+ }
2314
+ }))(({
2315
+ classes
2316
+ }) => /*#__PURE__*/React.createElement("div", {
2317
+ className: classes.helper
2318
+ }, "Drag your correct answers here"));
2319
+
2320
+ const Previews = ({
2321
+ alternateResponseIndex,
2322
+ category,
2323
+ choices,
2324
+ onDeleteChoice
2325
+ }) => /*#__PURE__*/React.createElement(React.Fragment, null, choices.map((c, index) => c && /*#__PURE__*/React.createElement(ChoicePreview$1, {
2326
+ alternateResponseIndex: alternateResponseIndex,
2327
+ category: category,
2328
+ choice: c,
2329
+ key: index,
2330
+ choiceIndex: index,
2331
+ onDelete: choice => onDeleteChoice(choice, index)
2332
+ })));
2333
+
2334
+ Previews.propTypes = {
2335
+ alternateResponseIndex: PropTypes.number,
2336
+ category: PropTypes.object,
2337
+ choices: PropTypes.array,
2338
+ onDeleteChoice: PropTypes.func
2339
+ };
2340
+ class DroppablePlaceHolder extends React.Component {
2341
+ render() {
2342
+ const {
2343
+ alternateResponseIndex,
2344
+ isOver,
2345
+ category,
2346
+ choices,
2347
+ classes,
2348
+ className,
2349
+ connectDropTarget,
2350
+ onDeleteChoice
2351
+ } = this.props;
2352
+ return connectDropTarget( /*#__PURE__*/React.createElement("div", {
2353
+ className: classNames(classes.droppablePlaceholder, className)
2354
+ }, /*#__PURE__*/React.createElement(PlaceHolder$1, {
2355
+ isOver: isOver,
2356
+ className: classes.placeHolder
2357
+ }, (choices || []).length === 0 ? /*#__PURE__*/React.createElement(Helper, null) : /*#__PURE__*/React.createElement(Previews, {
2358
+ alternateResponseIndex: alternateResponseIndex,
2359
+ category: category,
2360
+ choices: choices,
2361
+ onDeleteChoice: onDeleteChoice
2362
+ }))));
2363
+ }
2364
+
2365
+ }
2366
+ DroppablePlaceHolder.propTypes = {
2367
+ alternateResponseIndex: PropTypes.number,
2368
+ category: PropTypes.object,
2369
+ classes: PropTypes.object.isRequired,
2370
+ className: PropTypes.string,
2371
+ connectDropTarget: PropTypes.func.isRequired,
2372
+ choices: PropTypes.array,
2373
+ onDropChoice: PropTypes.func.isRequired,
2374
+ onMoveChoice: PropTypes.func,
2375
+ isOver: PropTypes.bool,
2376
+ onDeleteChoice: PropTypes.func,
2377
+ categoryId: PropTypes.string.isRequired
2378
+ };
2379
+ DroppablePlaceHolder.defaultProps = {};
2380
+
2381
+ const styles$a = () => ({
2382
+ droppablePlaceholder: {
2383
+ minHeight: '100px'
2384
+ },
2385
+ placeHolder: {
2386
+ width: '100%',
2387
+ minHeight: '100px',
2388
+ height: 'auto'
2389
+ }
2390
+ });
2391
+
2392
+ const Styled = withStyles(styles$a)(DroppablePlaceHolder);
2393
+ const spec$1 = {
2394
+ drop: (props, monitor) => {
2395
+ log$1('[drop] props: ', props);
2396
+ const item = monitor.getItem();
2397
+
2398
+ if (item.from && item.alternateResponseIndex === props.alternateResponseIndex) {
2399
+ props.onMoveChoice(item.choiceId, item.from, props.categoryId, item.choiceIndex, item.alternateResponseIndex);
2400
+ } else if (!item.from) {
2401
+ // avoid dropping choice when user tries to move it to an alternate with other index
2402
+ props.onDropChoice(item, props.categoryId);
2403
+ }
2404
+ },
2405
+ canDrop: (props
2406
+ /*, monitor*/
2407
+ ) => {
2408
+ return !props.disabled;
2409
+ }
2410
+ };
2411
+ const WithTarget = DropTarget(({
2412
+ uid
2413
+ }) => uid, spec$1, (connect, monitor) => ({
2414
+ connectDropTarget: connect.dropTarget(),
2415
+ isOver: monitor.isOver()
2416
+ }))(Styled);
2417
+ var PlaceHolder = uid.withUid(WithTarget);
2418
+
2419
+ class Category extends React.Component {
2420
+ constructor(...args) {
2421
+ super(...args);
2422
+
2423
+ this.changeLabel = l => {
2424
+ const {
2425
+ category,
2426
+ onChange
2427
+ } = this.props;
2428
+ category.label = l;
2429
+ onChange(category);
2430
+ };
2431
+ }
2432
+
2433
+ render() {
2434
+ const {
2435
+ alternateResponseIndex,
2436
+ category,
2437
+ classes,
2438
+ className,
2439
+ configuration,
2440
+ deleteFocusedEl,
2441
+ focusedEl,
2442
+ index,
2443
+ error,
2444
+ isDuplicated,
2445
+ onDelete,
2446
+ onDeleteChoice,
2447
+ onAddChoice,
2448
+ onMoveChoice,
2449
+ imageSupport,
2450
+ spellCheck,
2451
+ toolbarOpts,
2452
+ maxImageWidth,
2453
+ maxImageHeight,
2454
+ uploadSoundSupport,
2455
+ mathMlOptions = {}
2456
+ } = this.props;
2457
+ const isCategoryHeaderDisabled = !!alternateResponseIndex || alternateResponseIndex === 0;
2458
+ return /*#__PURE__*/React.createElement(Card, {
2459
+ className: classNames(classes.category, className, {
2460
+ [classes.duplicateError]: isDuplicated
2461
+ })
2462
+ }, /*#__PURE__*/React.createElement("span", null, !isCategoryHeaderDisabled ? /*#__PURE__*/React.createElement(InputHeader$1, {
2463
+ label: category.label,
2464
+ focusedEl: focusedEl,
2465
+ deleteFocusedEl: deleteFocusedEl,
2466
+ index: index,
2467
+ disabled: !!alternateResponseIndex || alternateResponseIndex === 0,
2468
+ error: error,
2469
+ onChange: this.changeLabel,
2470
+ onDelete: onDelete,
2471
+ imageSupport: imageSupport,
2472
+ toolbarOpts: toolbarOpts,
2473
+ spellCheck: spellCheck,
2474
+ maxImageWidth: maxImageWidth,
2475
+ maxImageHeight: maxImageHeight,
2476
+ uploadSoundSupport: uploadSoundSupport,
2477
+ mathMlOptions: mathMlOptions,
2478
+ configuration: configuration
2479
+ }) : /*#__PURE__*/React.createElement("div", {
2480
+ className: classes.categoryHeader,
2481
+ dangerouslySetInnerHTML: {
2482
+ __html: category.label
2483
+ }
2484
+ }), error && /*#__PURE__*/React.createElement("div", {
2485
+ className: classes.errorText
2486
+ }, error)), /*#__PURE__*/React.createElement(PlaceHolder, {
2487
+ className: classes.placeHolder,
2488
+ alternateResponseIndex: alternateResponseIndex,
2489
+ category: category,
2490
+ choices: category.choices,
2491
+ onDeleteChoice: onDeleteChoice,
2492
+ onDropChoice: onAddChoice,
2493
+ onMoveChoice: onMoveChoice,
2494
+ categoryId: category.id
2495
+ }), onDelete && /*#__PURE__*/React.createElement(CardActions, {
2496
+ className: classes.actions
2497
+ }, /*#__PURE__*/React.createElement(DeleteButton, {
2498
+ label: 'delete',
2499
+ onClick: onDelete
2500
+ })));
2501
+ }
2502
+
2503
+ }
2504
+ Category.propTypes = {
2505
+ alternateResponseIndex: PropTypes.number,
2506
+ classes: PropTypes.object.isRequired,
2507
+ className: PropTypes.string,
2508
+ category: PropTypes.object.isRequired,
2509
+ configuration: PropTypes.object.isRequired,
2510
+ defaultImageMaxHeight: PropTypes.number,
2511
+ defaultImageMaxWidth: PropTypes.number,
2512
+ deleteFocusedEl: PropTypes.func,
2513
+ focusedEl: PropTypes.number,
2514
+ index: PropTypes.number,
2515
+ error: PropTypes.string,
2516
+ isDuplicated: PropTypes.bool,
2517
+ maxImageWidth: PropTypes.object,
2518
+ maxImageHeight: PropTypes.object,
2519
+ onChange: PropTypes.func,
2520
+ onDelete: PropTypes.func,
2521
+ onDeleteChoice: PropTypes.func,
2522
+ onAddChoice: PropTypes.func,
2523
+ onMoveChoice: PropTypes.func,
2524
+ imageSupport: PropTypes.shape({
2525
+ add: PropTypes.func.isRequired,
2526
+ delete: PropTypes.func.isRequired
2527
+ }),
2528
+ toolbarOpts: PropTypes.object,
2529
+ spellCheck: PropTypes.bool,
2530
+ uploadSoundSupport: PropTypes.shape({
2531
+ add: PropTypes.func.isRequired,
2532
+ delete: PropTypes.func.isRequired
2533
+ })
2534
+ };
2535
+ Category.defaultProps = {};
2536
+
2537
+ const styles$9 = theme => ({
2538
+ placeHolder: {
2539
+ minHeight: '100px'
2540
+ },
2541
+ deleteButton: {
2542
+ margin: 0
2543
+ },
2544
+ actions: {
2545
+ padding: 0,
2546
+ paddingBottom: 0,
2547
+ paddingTop: theme.spacing.unit
2548
+ },
2549
+ iconButtonRoot: {
2550
+ width: 'auto',
2551
+ height: 'auto'
2552
+ },
2553
+ header: {
2554
+ display: 'flex',
2555
+ justifyContent: 'space-between'
2556
+ },
2557
+ category: {
2558
+ minWidth: '196px',
2559
+ padding: theme.spacing.unit,
2560
+ overflow: 'visible'
2561
+ },
2562
+ categoryHeader: {
2563
+ padding: theme.spacing.unit * 2,
2564
+ '& p': {
2565
+ margin: 0
2566
+ }
2567
+ },
2568
+ duplicateError: {
2569
+ border: '1px solid red'
2570
+ },
2571
+ errorText: {
2572
+ fontSize: theme.typography.fontSize - 2,
2573
+ color: theme.palette.error.main,
2574
+ paddingBottom: theme.spacing.unit
2575
+ },
2576
+ editor: {
2577
+ flex: '1',
2578
+ paddingBottom: theme.spacing.unit * 2
2579
+ }
2580
+ });
2581
+
2582
+ var Category$1 = withStyles(styles$9)(Category);
2583
+
2584
+ class Header extends React.Component {
2585
+ render() {
2586
+ const {
2587
+ classes,
2588
+ className,
2589
+ onAdd,
2590
+ label,
2591
+ buttonLabel,
2592
+ info,
2593
+ buttonDisabled,
2594
+ variant,
2595
+ tooltip
2596
+ } = this.props;
2597
+ return /*#__PURE__*/React.createElement("div", {
2598
+ className: classNames(classes.header, className)
2599
+ }, /*#__PURE__*/React.createElement("div", {
2600
+ className: classes.titleContainer
2601
+ }, /*#__PURE__*/React.createElement(Typography, {
2602
+ variant: variant || 'title',
2603
+ className: classes.title
2604
+ }, label), info), /*#__PURE__*/React.createElement(Tooltip, {
2605
+ title: tooltip || '',
2606
+ classes: {
2607
+ tooltip: classes.tooltip
2608
+ },
2609
+ enterTouchDelay: 50 // Appear quickly after a touch
2610
+ ,
2611
+ leaveTouchDelay: 3000 // Stay visible for 3 seconds
2612
+
2613
+ }, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(AddButton, {
2614
+ onClick: onAdd,
2615
+ label: buttonLabel,
2616
+ disabled: buttonDisabled
2617
+ }))));
2618
+ }
2619
+
2620
+ }
2621
+ Header.propTypes = {
2622
+ classes: PropTypes.object.isRequired,
2623
+ className: PropTypes.string,
2624
+ buttonLabel: PropTypes.string,
2625
+ onAdd: PropTypes.func.isRequired,
2626
+ label: PropTypes.string.isRequired,
2627
+ info: PropTypes.any,
2628
+ buttonDisabled: PropTypes.bool,
2629
+ variant: PropTypes.string,
2630
+ tooltip: PropTypes.string
2631
+ };
2632
+ Header.defaultProps = {};
2633
+
2634
+ const styles$8 = theme => ({
2635
+ header: {
2636
+ display: 'flex',
2637
+ justifyContent: 'space-between',
2638
+ marginBottom: theme.spacing.unit
2639
+ },
2640
+ titleContainer: {
2641
+ display: 'flex',
2642
+ alignItems: 'center'
2643
+ },
2644
+ tooltip: {
2645
+ fontSize: theme.typography.fontSize - 2,
2646
+ whiteSpace: 'pre',
2647
+ maxWidth: '500px'
2648
+ }
2649
+ });
2650
+
2651
+ var Header$1 = withStyles(styles$8)(Header);
2652
+
2653
+ const generateValidationMessage = config => {
2654
+ let {
2655
+ minChoices,
2656
+ maxChoices,
2657
+ maxCategories
2658
+ } = config || {};
2659
+ minChoices = minChoices || 1;
2660
+ const validationMessage = '\nThe choices content should ' + 'not be empty and should be unique.\nThere should be at least 1 ' + (maxCategories ? `and at most ${maxCategories} ` : '') + 'category' + (maxCategories ? 's' : '') + ' defined.' + (minChoices ? `\nThere should be at least ${minChoices} choices defined.` : '') + (maxChoices ? `\nNo more than ${maxChoices} choices should be defined.` : '') + '\nAt least one token should be assigned to at least one category.';
2661
+ return 'Validation requirements:' + validationMessage;
2662
+ }; // used in controller too, for consistency modify it there too
2663
+
2664
+ const multiplePlacements = {
2665
+ enabled: 'Yes',
2666
+ disabled: 'No',
2667
+ perChoice: 'Set Per Choice'
2668
+ }; // Find the length of the largest array from an array
2669
+
2670
+ const maxLength = array => (array || []).reduce((max, arr) => {
2671
+ return Math.max(max, arr.length);
2672
+ }, 0);
2673
+ const getMaxCategoryChoices = model => {
2674
+ const {
2675
+ correctResponse = []
2676
+ } = model || {};
2677
+ return correctResponse.reduce((max, correctRes) => {
2678
+ var _correctRes$choices;
2679
+
2680
+ const correctRespLength = (correctRes == null ? void 0 : (_correctRes$choices = correctRes.choices) == null ? void 0 : _correctRes$choices.length) || 0;
2681
+ const alternates = (correctRes == null ? void 0 : correctRes.alternateResponses) || [];
2682
+ const maxChoices = Math.max(correctRespLength, maxLength(alternates));
2683
+ return maxChoices > max ? maxChoices : max;
2684
+ }, 0);
2685
+ };
2686
+
2687
+ const styles$7 = theme => ({
2688
+ rowLabel: {
2689
+ gridColumn: '1/3'
2690
+ },
2691
+ rowLabelHolder: {
2692
+ paddingTop: theme.spacing.unit * 2,
2693
+ width: '100%'
2694
+ }
2695
+ });
2696
+
2697
+ const RowLabel = withStyles(styles$7)(({
2698
+ categoriesPerRow,
2699
+ classes,
2700
+ configuration,
2701
+ disabled,
2702
+ markup,
2703
+ imageSupport,
2704
+ onChange,
2705
+ toolbarOpts,
2706
+ spellCheck,
2707
+ maxImageWidth,
2708
+ maxImageHeight,
2709
+ uploadSoundSupport,
2710
+ mathMlOptions: _mathMlOptions = {}
2711
+ }) => {
2712
+ const {
2713
+ rowLabels,
2714
+ baseInputConfiguration
2715
+ } = configuration;
2716
+ return /*#__PURE__*/React.createElement("div", {
2717
+ style: {
2718
+ gridColumn: `1/${categoriesPerRow + 1}`,
2719
+ width: '100%'
2720
+ }
2721
+ }, /*#__PURE__*/React.createElement(InputContainer, {
2722
+ label: "Row Label",
2723
+ className: classes.rowLabelHolder
2724
+ }, /*#__PURE__*/React.createElement(EditableHtml, {
2725
+ disabled: disabled,
2726
+ markup: markup,
2727
+ onChange: onChange,
2728
+ imageSupport: imageSupport,
2729
+ nonEmpty: false,
2730
+ toolbarOpts: toolbarOpts,
2731
+ pluginProps: getPluginProps(rowLabels == null ? void 0 : rowLabels.inputConfiguration, baseInputConfiguration),
2732
+ spellCheck: spellCheck,
2733
+ maxImageWidth: maxImageWidth,
2734
+ maxImageHeight: maxImageHeight,
2735
+ uploadSoundSupport: uploadSoundSupport,
2736
+ languageCharactersProps: [{
2737
+ language: 'spanish'
2738
+ }, {
2739
+ language: 'special'
2740
+ }],
2741
+ mathMlOptions: _mathMlOptions
2742
+ })));
2743
+ });
2744
+
2745
+ const styles$6 = theme => ({
2746
+ categories: {
2747
+ marginBottom: theme.spacing.unit * 3
2748
+ },
2749
+ categoriesHolder: {
2750
+ display: 'grid',
2751
+ gridRowGap: `${theme.spacing.unit}px`,
2752
+ gridColumnGap: `${theme.spacing.unit}px`
2753
+ },
2754
+ row: {
2755
+ display: 'grid',
2756
+ gridTemplateColumns: 'repeat(2, 1fr)',
2757
+ gridColumnGap: `${theme.spacing.unit}px`,
2758
+ alignItems: 'baseline',
2759
+ width: '100%',
2760
+ marginTop: theme.spacing.unit,
2761
+ marginBottom: 2 * theme.spacing.unit
2762
+ },
2763
+ rowLabel: {
2764
+ gridColumn: '1/3'
2765
+ },
2766
+ rowLabelHolder: {
2767
+ width: '100%'
2768
+ },
2769
+ tooltip: {
2770
+ fontSize: theme.typography.fontSize - 2,
2771
+ whiteSpace: 'pre',
2772
+ maxWidth: '500px'
2773
+ },
2774
+ errorText: {
2775
+ fontSize: theme.typography.fontSize - 2,
2776
+ color: theme.palette.error.main,
2777
+ paddingTop: theme.spacing.unit / 2
2778
+ }
2779
+ });
2780
+
2781
+ class Categories extends React.Component {
2782
+ constructor(...args) {
2783
+ super(...args);
2784
+ this.state = {
2785
+ focusedEl: null
2786
+ };
2787
+
2788
+ this.add = () => {
2789
+ const {
2790
+ model,
2791
+ categories: oldCategories
2792
+ } = this.props;
2793
+ const {
2794
+ categoriesPerRow,
2795
+ correctResponse,
2796
+ allowAlternateEnabled
2797
+ } = model;
2798
+ const id = choiceUtils.firstAvailableIndex(model.categories.map(a => a.id), 1);
2799
+ const data = {
2800
+ id,
2801
+ label: 'Category ' + id
2802
+ };
2803
+ const addRowLabel = model.categories.length % categoriesPerRow === 0;
2804
+ const rowLabels = [...model.rowLabels];
2805
+
2806
+ if (addRowLabel) {
2807
+ rowLabels.push('');
2808
+ }
2809
+
2810
+ this.setState({
2811
+ focusedEl: oldCategories.length
2812
+ }, () => {
2813
+ this.props.onModelChanged({
2814
+ rowLabels,
2815
+ categories: model.categories.concat([data]),
2816
+ correctResponse: allowAlternateEnabled ? [...correctResponse, {
2817
+ category: id,
2818
+ choices: [],
2819
+ alternateResponses: []
2820
+ }] : correctResponse
2821
+ });
2822
+ });
2823
+ };
2824
+
2825
+ this.deleteFocusedEl = () => {
2826
+ this.setState({
2827
+ focusedEl: null
2828
+ });
2829
+ };
2830
+
2831
+ this.delete = category => {
2832
+ const {
2833
+ model,
2834
+ onModelChanged
2835
+ } = this.props;
2836
+ const index = model.categories.findIndex(a => a.id === category.id);
2837
+
2838
+ if (index !== -1) {
2839
+ model.categories.splice(index, 1);
2840
+ model.correctResponse = removeCategory(category.id, model.correctResponse);
2841
+ onModelChanged(model);
2842
+ }
2843
+ };
2844
+
2845
+ this.change = c => {
2846
+ const {
2847
+ categories
2848
+ } = this.props;
2849
+ const index = categories.findIndex(a => a.id === c.id);
2850
+
2851
+ if (index !== -1) {
2852
+ categories.splice(index, 1, c);
2853
+ this.props.onModelChanged({
2854
+ categories
2855
+ });
2856
+ }
2857
+ };
2858
+
2859
+ this.addChoiceToCategory = (addedChoice, categoryId) => {
2860
+ const {
2861
+ model,
2862
+ onModelChanged
2863
+ } = this.props;
2864
+ let {
2865
+ choices = [],
2866
+ correctResponse = [],
2867
+ maxChoicesPerCategory = 0
2868
+ } = model || {};
2869
+ const choice = (choices || []).find(choice => choice.id === addedChoice.id);
2870
+ correctResponse = moveChoiceToCategory(addedChoice.id, undefined, categoryId, 0, model.correctResponse); // if multiplePlacements not allowed, ensure the consistency in the other categories
2871
+
2872
+ if (choice.categoryCount !== 0) {
2873
+ correctResponse = verifyAllowMultiplePlacements(addedChoice, categoryId, correctResponse);
2874
+ }
2875
+
2876
+ const maxCategoryChoices = getMaxCategoryChoices(model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
2877
+
2878
+ onModelChanged({
2879
+ correctResponse,
2880
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
2881
+ });
2882
+ };
2883
+
2884
+ this.deleteChoiceFromCategory = (category, choice, choiceIndex) => {
2885
+ const {
2886
+ model,
2887
+ onModelChanged
2888
+ } = this.props;
2889
+ const correctResponse = removeChoiceFromCategory(choice.id, category.id, choiceIndex, model.correctResponse);
2890
+ onModelChanged({
2891
+ correctResponse
2892
+ });
2893
+ };
2894
+
2895
+ this.moveChoice = (choiceId, from, to, choiceIndex) => {
2896
+ const {
2897
+ model,
2898
+ onModelChanged
2899
+ } = this.props;
2900
+ let {
2901
+ choices,
2902
+ correctResponse = [],
2903
+ maxChoicesPerCategory = 0
2904
+ } = model || {};
2905
+ const choice = (choices || []).find(choice => choice.id === choiceId);
2906
+
2907
+ if (to === from || !choice) {
2908
+ return;
2909
+ }
2910
+
2911
+ if (choice.categoryCount !== 0) {
2912
+ correctResponse = moveChoiceToCategory(choice.id, from, to, choiceIndex, correctResponse);
2913
+ correctResponse = verifyAllowMultiplePlacements(choice, to, correctResponse);
2914
+ } else if (choice.categoryCount === 0) {
2915
+ correctResponse = moveChoiceToCategory(choice.id, undefined, to, 0, correctResponse);
2916
+ }
2917
+
2918
+ const maxCategoryChoices = getMaxCategoryChoices(model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
2919
+
2920
+ onModelChanged({
2921
+ correctResponse,
2922
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
2923
+ });
2924
+ };
2925
+
2926
+ this.changeRowLabel = (val, index) => {
2927
+ const {
2928
+ model
2929
+ } = this.props;
2930
+ const {
2931
+ rowLabels
2932
+ } = model;
2933
+ const newRowLabels = [...rowLabels];
2934
+
2935
+ if (newRowLabels.length < index) {
2936
+ newRowLabels.push(val);
2937
+ } else {
2938
+ newRowLabels[index] = val;
2939
+ }
2940
+
2941
+ this.props.onModelChanged({
2942
+ rowLabels: newRowLabels
2943
+ });
2944
+ };
2945
+ }
2946
+
2947
+ componentDidMount() {
2948
+ try {
2949
+ // eslint-disable-next-line react/no-find-dom-node
2950
+ const domNode = ReactDOM.findDOMNode(this);
2951
+ renderMath(domNode);
2952
+ } catch (e) {
2953
+ // Added try-catch block to handle "Unable to find node on an unmounted component" error from tests, thrown because of the usage of shallow
2954
+ console.error('DOM not mounted');
2955
+ }
2956
+ }
2957
+
2958
+ componentDidUpdate() {
2959
+ try {
2960
+ // eslint-disable-next-line react/no-find-dom-node
2961
+ const domNode = ReactDOM.findDOMNode(this);
2962
+ renderMath(domNode);
2963
+ } catch (e) {
2964
+ // Added try-catch block to handle "Unable to find node on an unmounted component" error from tests, thrown because of the usage of shallow
2965
+ console.error('DOM not mounted');
2966
+ }
2967
+ }
2968
+
2969
+ render() {
2970
+ const {
2971
+ model,
2972
+ classes,
2973
+ className,
2974
+ categories,
2975
+ imageSupport,
2976
+ uploadSoundSupport,
2977
+ toolbarOpts,
2978
+ spellCheck,
2979
+ configuration,
2980
+ defaultImageMaxHeight,
2981
+ defaultImageMaxWidth,
2982
+ mathMlOptions = {}
2983
+ } = this.props;
2984
+ const {
2985
+ categoriesPerRow,
2986
+ rowLabels,
2987
+ errors
2988
+ } = model;
2989
+ const {
2990
+ associationError,
2991
+ categoriesError,
2992
+ categoriesErrors
2993
+ } = errors || {};
2994
+ const {
2995
+ maxCategories,
2996
+ maxImageWidth = {},
2997
+ maxImageHeight = {}
2998
+ } = configuration || {};
2999
+ const holderStyle = {
3000
+ gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`
3001
+ };
3002
+ const validationMessage = generateValidationMessage(configuration);
3003
+ return /*#__PURE__*/React.createElement("div", {
3004
+ className: classNames(classes.categories, className)
3005
+ }, /*#__PURE__*/React.createElement(Header$1, {
3006
+ label: "Categories",
3007
+ buttonLabel: "ADD A CATEGORY",
3008
+ onAdd: this.add,
3009
+ info: /*#__PURE__*/React.createElement(Tooltip, {
3010
+ classes: {
3011
+ tooltip: classes.tooltip
3012
+ },
3013
+ disableFocusListener: true,
3014
+ disableTouchListener: true,
3015
+ placement: 'right',
3016
+ title: validationMessage
3017
+ }, /*#__PURE__*/React.createElement(Info, {
3018
+ fontSize: 'small',
3019
+ color: 'primary',
3020
+ style: {
3021
+ marginLeft: '5px'
3022
+ }
3023
+ })),
3024
+ buttonDisabled: maxCategories && categories && maxCategories === categories.length
3025
+ }), /*#__PURE__*/React.createElement("div", {
3026
+ className: classes.categoriesHolder,
3027
+ style: holderStyle
3028
+ }, categories.map((category, index) => {
3029
+ const hasRowLabel = index % categoriesPerRow === 0;
3030
+ const rowIndex = index / categoriesPerRow;
3031
+ return /*#__PURE__*/React.createElement(React.Fragment, {
3032
+ key: index
3033
+ }, hasRowLabel && /*#__PURE__*/React.createElement(RowLabel, {
3034
+ categoriesPerRow: categoriesPerRow,
3035
+ disabled: false,
3036
+ rowIndex: rowIndex,
3037
+ markup: rowLabels[rowIndex] || '',
3038
+ onChange: val => this.changeRowLabel(val, rowIndex),
3039
+ imageSupport: imageSupport,
3040
+ toolbarOpts: toolbarOpts,
3041
+ spellCheck: spellCheck,
3042
+ maxImageWidth: maxImageWidth && maxImageWidth.rowLabel || defaultImageMaxWidth,
3043
+ maxImageHeight: maxImageHeight && maxImageHeight.rowLabel || defaultImageMaxHeight,
3044
+ uploadSoundSupport: uploadSoundSupport,
3045
+ mathMlOptions: mathMlOptions,
3046
+ configuration: configuration
3047
+ }), /*#__PURE__*/React.createElement(Category$1, {
3048
+ imageSupport: imageSupport,
3049
+ focusedEl: this.state.focusedEl,
3050
+ deleteFocusedEl: this.deleteFocusedEl,
3051
+ index: index,
3052
+ category: category,
3053
+ error: categoriesErrors && categoriesErrors[category.id],
3054
+ onChange: this.change,
3055
+ onDelete: () => this.delete(category),
3056
+ onAddChoice: this.addChoiceToCategory,
3057
+ onMoveChoice: (choiceId, from, to, choiceIndex) => this.moveChoice(choiceId, from, to, choiceIndex),
3058
+ toolbarOpts: toolbarOpts,
3059
+ spellCheck: spellCheck,
3060
+ onDeleteChoice: (choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex),
3061
+ maxImageWidth: maxImageWidth && maxImageWidth.categoryLabel || defaultImageMaxWidth,
3062
+ maxImageHeight: maxImageHeight && maxImageHeight.categoryLabel || defaultImageMaxHeight,
3063
+ uploadSoundSupport: uploadSoundSupport,
3064
+ configuration: configuration
3065
+ }));
3066
+ })), associationError && /*#__PURE__*/React.createElement("div", {
3067
+ className: classes.errorText
3068
+ }, associationError), categoriesError && /*#__PURE__*/React.createElement("div", {
3069
+ className: classes.errorText
3070
+ }, categoriesError));
3071
+ }
3072
+
3073
+ }
3074
+ Categories.propTypes = {
3075
+ defaultImageMaxHeight: PropTypes.number,
3076
+ defaultImageMaxWidth: PropTypes.number,
3077
+ imageSupport: PropTypes.shape({
3078
+ add: PropTypes.func.isRequired,
3079
+ delete: PropTypes.func.isRequired
3080
+ }),
3081
+ uploadSoundSupport: PropTypes.shape({
3082
+ add: PropTypes.func.isRequired,
3083
+ delete: PropTypes.func.isRequired
3084
+ }),
3085
+ classes: PropTypes.object.isRequired,
3086
+ className: PropTypes.string,
3087
+ categories: PropTypes.array,
3088
+ onModelChanged: PropTypes.func,
3089
+ model: PropTypes.object.isRequired,
3090
+ configuration: PropTypes.object.isRequired,
3091
+ toolbarOpts: PropTypes.object,
3092
+ spellCheck: PropTypes.bool
3093
+ };
3094
+ var Categories$1 = withStyles(styles$6)(Categories);
3095
+
3096
+ const styles$5 = theme => ({
3097
+ categories: {
3098
+ marginBottom: theme.spacing.unit * 2.5
3099
+ },
3100
+ categoriesHolder: {
3101
+ display: 'grid',
3102
+ gridRowGap: `${theme.spacing.unit}px`,
3103
+ gridColumnGap: `${theme.spacing.unit}px`
3104
+ },
3105
+ row: {
3106
+ display: 'grid',
3107
+ gridTemplateColumns: 'repeat(2, 1fr)',
3108
+ gridColumnGap: `${theme.spacing.unit}px`,
3109
+ alignItems: 'baseline',
3110
+ width: '100%',
3111
+ marginTop: theme.spacing.unit,
3112
+ marginBottom: 2 * theme.spacing.unit
3113
+ },
3114
+ rowLabel: {
3115
+ gridColumn: '1/3'
3116
+ }
3117
+ });
3118
+
3119
+ class AlternateResponses extends React.Component {
3120
+ constructor(...args) {
3121
+ super(...args);
3122
+
3123
+ this.addChoiceToCategory = (addedChoice, categoryId) => {
3124
+ const {
3125
+ altIndex,
3126
+ model: {
3127
+ correctResponse,
3128
+ choices,
3129
+ maxChoicesPerCategory = 0
3130
+ },
3131
+ onModelChanged
3132
+ } = this.props;
3133
+ const choice = choices.find(c => c.id === addedChoice.id);
3134
+ correctResponse.forEach(a => {
3135
+ if (a.category === categoryId) {
3136
+ a.alternateResponses = a.alternateResponses || [];
3137
+
3138
+ if (!a.alternateResponses[altIndex]) {
3139
+ a.alternateResponses[altIndex] = [];
3140
+ }
3141
+
3142
+ a.alternateResponses[altIndex].push(addedChoice.id);
3143
+
3144
+ if (choice.categoryCount && choice.categoryCount !== 0) {
3145
+ a.alternateResponses[altIndex] = a.alternateResponses[altIndex].reduce((acc, currentValue) => {
3146
+ if (currentValue === choice.id) {
3147
+ const foundIndex = acc.findIndex(c => c === choice.id);
3148
+
3149
+ if (foundIndex === -1) {
3150
+ acc.push(currentValue);
3151
+ }
3152
+ } else {
3153
+ acc.push(currentValue);
3154
+ }
3155
+
3156
+ return acc;
3157
+ }, []);
3158
+ }
3159
+
3160
+ return a;
3161
+ } else {
3162
+ if (a.alternateResponses[altIndex] && choice.categoryCount !== 0) {
3163
+ a.alternateResponses[altIndex] = a.alternateResponses[altIndex].filter(c => c !== addedChoice.id);
3164
+ return a;
3165
+ }
3166
+ }
3167
+
3168
+ return a;
3169
+ });
3170
+ const maxCategoryChoices = getMaxCategoryChoices(this.props.model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
3171
+
3172
+ onModelChanged({
3173
+ correctResponse,
3174
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
3175
+ });
3176
+ };
3177
+
3178
+ this.moveChoice = (choiceId, from, to, choiceIndex, alternateIndex) => {
3179
+ const {
3180
+ model,
3181
+ onModelChanged
3182
+ } = this.props;
3183
+ let {
3184
+ choices,
3185
+ correctResponse = [],
3186
+ maxChoicesPerCategory = 0
3187
+ } = model || {};
3188
+ const choice = (choices || []).find(choice => choice.id === choiceId);
3189
+ correctResponse = moveChoiceToAlternate(choiceId, from, to, choiceIndex, correctResponse, alternateIndex, choice == null ? void 0 : choice.categoryCount);
3190
+ const maxCategoryChoices = getMaxCategoryChoices(this.props.model); // when maxChoicesPerCategory is set to 0, there is no limit so it should not be updated
3191
+
3192
+ onModelChanged({
3193
+ correctResponse,
3194
+ maxChoicesPerCategory: maxChoicesPerCategory !== 0 && maxChoicesPerCategory < maxCategoryChoices ? maxChoicesPerCategory + 1 : maxChoicesPerCategory
3195
+ });
3196
+ };
3197
+
3198
+ this.deleteChoiceFromCategory = (category, choice, choiceIndex) => {
3199
+ const {
3200
+ model,
3201
+ altIndex,
3202
+ onModelChanged
3203
+ } = this.props;
3204
+ const correctResponse = removeChoiceFromAlternate(choice.id, category.id, choiceIndex, altIndex, model.correctResponse);
3205
+ onModelChanged({
3206
+ correctResponse
3207
+ });
3208
+ };
3209
+ }
3210
+
3211
+ render() {
3212
+ const {
3213
+ altIndex,
3214
+ model,
3215
+ configuration,
3216
+ classes,
3217
+ className,
3218
+ categories,
3219
+ imageSupport,
3220
+ spellCheck,
3221
+ uploadSoundSupport,
3222
+ mathMlOptions = {}
3223
+ } = this.props;
3224
+ const {
3225
+ categoriesPerRow,
3226
+ errors,
3227
+ rowLabels
3228
+ } = model;
3229
+ const {
3230
+ duplicateAlternate
3231
+ } = errors || {};
3232
+ const holderStyle = {
3233
+ gridTemplateColumns: `repeat(${categoriesPerRow}, 1fr)`
3234
+ };
3235
+ const isDuplicated = duplicateAlternate ? duplicateAlternate.index === altIndex : false;
3236
+ return /*#__PURE__*/React.createElement("div", {
3237
+ className: classNames(classes.categories, className)
3238
+ }, /*#__PURE__*/React.createElement("div", {
3239
+ className: classes.categoriesHolder,
3240
+ style: holderStyle
3241
+ }, categories.map((category, index) => {
3242
+ const hasRowLabel = index % categoriesPerRow === 0;
3243
+ const rowIndex = index / categoriesPerRow;
3244
+ return /*#__PURE__*/React.createElement(React.Fragment, {
3245
+ key: index
3246
+ }, hasRowLabel && /*#__PURE__*/React.createElement("div", {
3247
+ style: {
3248
+ gridColumn: `1/${categoriesPerRow + 1}`,
3249
+ width: '100%'
3250
+ },
3251
+ className: classes.rowLabel,
3252
+ dangerouslySetInnerHTML: {
3253
+ __html: rowLabels[rowIndex] || ''
3254
+ }
3255
+ }), /*#__PURE__*/React.createElement(Category$1, {
3256
+ key: index,
3257
+ alternateResponseIndex: altIndex,
3258
+ imageSupport: imageSupport,
3259
+ isDuplicated: isDuplicated && duplicateAlternate.category === category.id,
3260
+ category: category,
3261
+ spellCheck: spellCheck,
3262
+ onAddChoice: this.addChoiceToCategory,
3263
+ onDeleteChoice: (choice, choiceIndex) => this.deleteChoiceFromCategory(category, choice, choiceIndex),
3264
+ onMoveChoice: (choiceId, from, to, choiceIndex, alternateIndex) => this.moveChoice(choiceId, from, to, choiceIndex, alternateIndex),
3265
+ uploadSoundSupport: uploadSoundSupport,
3266
+ mathMlOptions: mathMlOptions,
3267
+ configuration: configuration
3268
+ }));
3269
+ })));
3270
+ }
3271
+
3272
+ }
3273
+ AlternateResponses.propTypes = {
3274
+ altIndex: PropTypes.number.isRequired,
3275
+ configuration: PropTypes.object,
3276
+ imageSupport: PropTypes.shape({
3277
+ add: PropTypes.func.isRequired,
3278
+ delete: PropTypes.func.isRequired
3279
+ }),
3280
+ classes: PropTypes.object.isRequired,
3281
+ className: PropTypes.string,
3282
+ categories: PropTypes.array,
3283
+ onModelChanged: PropTypes.func,
3284
+ model: PropTypes.object.isRequired,
3285
+ uploadSoundSupport: PropTypes.shape({
3286
+ add: PropTypes.func.isRequired,
3287
+ delete: PropTypes.func.isRequired
3288
+ }),
3289
+ spellCheck: PropTypes.bool
3290
+ };
3291
+ var AlternateResponses$1 = withStyles(styles$5)(AlternateResponses);
3292
+
3293
+ const log = debug('@pie-element:categorize:configure:choice');
3294
+
3295
+ const canDrag = props => {
3296
+ if (props.lockChoiceOrder) {
3297
+ return true;
3298
+ }
3299
+
3300
+ const count = props.choice.categoryCount || 0;
3301
+
3302
+ if (count === 0) {
3303
+ return true;
3304
+ } else {
3305
+ return props.correctResponseCount < count;
3306
+ }
3307
+ };
3308
+
3309
+ class Choice extends React.Component {
3310
+ constructor(...args) {
3311
+ super(...args);
3312
+
3313
+ this.changeContent = content => {
3314
+ const {
3315
+ onChange,
3316
+ choice
3317
+ } = this.props;
3318
+ choice.content = content;
3319
+ onChange(choice);
3320
+ };
3321
+
3322
+ this.changeCategoryCount = () => {
3323
+ const {
3324
+ onChange,
3325
+ choice
3326
+ } = this.props;
3327
+
3328
+ if (choice.categoryCount === 1) {
3329
+ choice.categoryCount = 0;
3330
+ } else {
3331
+ choice.categoryCount = 1;
3332
+ }
3333
+
3334
+ onChange(choice);
3335
+ };
3336
+
3337
+ this.isCheckboxShown = allowMultiplePlacements => allowMultiplePlacements === multiplePlacements.perChoice;
3338
+ }
3339
+
3340
+ render() {
3341
+ const {
3342
+ allowMultiplePlacements,
3343
+ classes,
3344
+ className,
3345
+ configuration,
3346
+ choice,
3347
+ deleteFocusedEl,
3348
+ focusedEl,
3349
+ index,
3350
+ onDelete,
3351
+ connectDropTarget,
3352
+ connectDragSource,
3353
+ connectDragPreview,
3354
+ imageSupport,
3355
+ spellCheck,
3356
+ toolbarOpts,
3357
+ error,
3358
+ maxImageWidth,
3359
+ maxImageHeight,
3360
+ uploadSoundSupport
3361
+ } = this.props;
3362
+ const showRemoveAfterPlacing = this.isCheckboxShown(allowMultiplePlacements);
3363
+ const draggable = canDrag(this.props);
3364
+ return /*#__PURE__*/React.createElement(Card, {
3365
+ className: classNames(classes.choice, className)
3366
+ }, /*#__PURE__*/React.createElement(CardActions, {
3367
+ className: classes.actions
3368
+ }, connectDragSource(connectDropTarget( /*#__PURE__*/React.createElement("span", {
3369
+ className: classNames(classes.dragHandle, draggable === false && classes.dragDisabled)
3370
+ }, /*#__PURE__*/React.createElement(DragHandle, {
3371
+ color: draggable ? 'primary' : 'disabled'
3372
+ }))))), connectDragPreview( /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(InputHeader$1, {
3373
+ imageSupport: imageSupport,
3374
+ focusedEl: focusedEl,
3375
+ deleteFocusedEl: deleteFocusedEl,
3376
+ index: index,
3377
+ label: choice.content,
3378
+ onChange: this.changeContent,
3379
+ onDelete: onDelete,
3380
+ toolbarOpts: toolbarOpts,
3381
+ spellCheck: spellCheck,
3382
+ error: error,
3383
+ maxImageWidth: maxImageWidth,
3384
+ maxImageHeight: maxImageHeight,
3385
+ uploadSoundSupport: uploadSoundSupport,
3386
+ configuration: configuration
3387
+ }), error && /*#__PURE__*/React.createElement("div", {
3388
+ className: classes.errorText
3389
+ }, error))), /*#__PURE__*/React.createElement(CardActions, {
3390
+ className: classes.actions
3391
+ }, /*#__PURE__*/React.createElement(DeleteButton, {
3392
+ label: 'delete',
3393
+ onClick: onDelete
3394
+ }), showRemoveAfterPlacing && /*#__PURE__*/React.createElement(Checkbox, {
3395
+ mini: true,
3396
+ label: 'Remove after placing',
3397
+ checked: choice.categoryCount === 1,
3398
+ onChange: this.changeCategoryCount
3399
+ })));
3400
+ }
3401
+
3402
+ }
3403
+ Choice.propTypes = {
3404
+ allowMultiplePlacements: PropTypes.string,
3405
+ classes: PropTypes.object.isRequired,
3406
+ className: PropTypes.string,
3407
+ configuration: PropTypes.object.isRequired,
3408
+ choice: PropTypes.object.isRequired,
3409
+ connectDropTarget: PropTypes.func,
3410
+ deleteFocusedEl: PropTypes.func,
3411
+ focusedEl: PropTypes.number,
3412
+ index: PropTypes.number,
3413
+ lockChoiceOrder: PropTypes.bool,
3414
+ maxImageHeight: PropTypes.object,
3415
+ maxImageWidth: PropTypes.object,
3416
+ onChange: PropTypes.func.isRequired,
3417
+ onDelete: PropTypes.func.isRequired,
3418
+ connectDragSource: PropTypes.func.isRequired,
3419
+ connectDragPreview: PropTypes.func.isRequired,
3420
+ correctResponseCount: PropTypes.number.isRequired,
3421
+ imageSupport: PropTypes.shape({
3422
+ add: PropTypes.func.isRequired,
3423
+ delete: PropTypes.func.isRequired
3424
+ }),
3425
+ toolbarOpts: PropTypes.object,
3426
+ error: PropTypes.string,
3427
+ uploadSoundSupport: PropTypes.shape({
3428
+ add: PropTypes.func.isRequired,
3429
+ delete: PropTypes.func.isRequired
3430
+ }),
3431
+ spellCheck: PropTypes.bool
3432
+ };
3433
+ Choice.defaultProps = {};
3434
+
3435
+ const styles$4 = theme => ({
3436
+ actions: {
3437
+ padding: 0,
3438
+ justifyContent: 'space-between'
3439
+ },
3440
+ choice: {
3441
+ minWidth: '196px',
3442
+ padding: theme.spacing.unit,
3443
+ overflow: 'visible'
3444
+ },
3445
+ dragHandle: {
3446
+ cursor: 'move'
3447
+ },
3448
+ dragDisabled: {
3449
+ cursor: 'inherit'
3450
+ },
3451
+ errorText: {
3452
+ fontSize: theme.typography.fontSize - 2,
3453
+ color: theme.palette.error.main,
3454
+ paddingBottom: theme.spacing.unit
3455
+ }
3456
+ });
3457
+
3458
+ const StyledChoice = withStyles(styles$4)(Choice);
3459
+ const spec = {
3460
+ canDrag,
3461
+ beginDrag: props => {
3462
+ const out = {
3463
+ id: props.choice.id,
3464
+ index: props.index
3465
+ };
3466
+ log('[beginDrag] out:', out);
3467
+ return out;
3468
+ },
3469
+ endDrag: (props, monitor) => {
3470
+ if (!monitor.didDrop()) {
3471
+ const item = monitor.getItem();
3472
+
3473
+ if (item.categoryId) {
3474
+ log('wasnt droppped - what to do?');
3475
+ props.onRemoveChoice(item);
3476
+ }
3477
+ }
3478
+ }
3479
+ };
3480
+ const specTarget = {
3481
+ drop: (props, monitor) => {
3482
+ log('[drop] props: ', props);
3483
+ const item = monitor.getItem();
3484
+ props.rearrangeChoices(item.index, props.index);
3485
+ },
3486
+ canDrop: (props, monitor) => {
3487
+ const item = monitor.getItem();
3488
+ return props.choice.id !== item.id;
3489
+ }
3490
+ };
3491
+ var Choice$1 = uid.withUid(flow(DragSource(({
3492
+ uid
3493
+ }) => uid, spec, (connect, monitor) => ({
3494
+ connectDragSource: connect.dragSource(),
3495
+ connectDragPreview: connect.dragPreview(),
3496
+ isDragging: monitor.isDragging()
3497
+ })), DropTarget(({
3498
+ uid
3499
+ }) => uid, specTarget, (connect, monitor) => ({
3500
+ connectDropTarget: connect.dropTarget(),
3501
+ isOver: monitor.isOver()
3502
+ })))(StyledChoice));
3503
+
3504
+ class Config extends React.Component {
3505
+ constructor(...args) {
3506
+ super(...args);
3507
+
3508
+ this.changeLabel = ({
3509
+ target
3510
+ }) => {
3511
+ this.props.onModelChanged({
3512
+ choicesLabel: target.value
3513
+ });
3514
+ };
3515
+ }
3516
+
3517
+ render() {
3518
+ const {
3519
+ classes,
3520
+ className,
3521
+ config,
3522
+ spellCheck
3523
+ } = this.props;
3524
+ return /*#__PURE__*/React.createElement("div", {
3525
+ className: classNames(classes.config, className)
3526
+ }, /*#__PURE__*/React.createElement(TextField, {
3527
+ className: classes.label,
3528
+ InputLabelProps: {
3529
+ shrink: true
3530
+ },
3531
+ variant: "outlined",
3532
+ label: "Label",
3533
+ value: config.choicesLabel,
3534
+ onChange: this.changeLabel,
3535
+ spellCheck: spellCheck
3536
+ }));
3537
+ }
3538
+
3539
+ }
3540
+ Config.propTypes = {
3541
+ classes: PropTypes.object.isRequired,
3542
+ className: PropTypes.string,
3543
+ config: PropTypes.object,
3544
+ onModelChanged: PropTypes.func,
3545
+ spellCheck: PropTypes.bool
3546
+ };
3547
+ Config.defaultProps = {};
3548
+
3549
+ const styles$3 = theme => ({
3550
+ config: {
3551
+ paddingTop: theme.spacing.unit,
3552
+ marginBottom: theme.spacing.unit
3553
+ },
3554
+ label: {
3555
+ width: '100%'
3556
+ }
3557
+ });
3558
+
3559
+ var Config$1 = withStyles(styles$3)(Config);
3560
+
3561
+ class Choices extends React.Component {
3562
+ constructor(...args) {
3563
+ super(...args);
3564
+ this.state = {
3565
+ focusedEl: null
3566
+ };
3567
+
3568
+ this.changeChoice = choice => {
3569
+ const {
3570
+ choices,
3571
+ onModelChanged
3572
+ } = this.props;
3573
+ const index = choices.findIndex(h => h.id === choice.id);
3574
+
3575
+ if (index !== -1) {
3576
+ choices.splice(index, 1, choice);
3577
+ onModelChanged({
3578
+ choices
3579
+ });
3580
+ }
3581
+ };
3582
+
3583
+ this.allChoicesHaveCount = count => {
3584
+ const {
3585
+ choices
3586
+ } = this.props;
3587
+ return Array.isArray(choices) && choices.every(c => c.categoryCount === count);
3588
+ };
3589
+
3590
+ this.addChoice = () => {
3591
+ var _model$choices;
3592
+
3593
+ const {
3594
+ onModelChanged,
3595
+ model,
3596
+ choices: oldChoices
3597
+ } = this.props;
3598
+ let {
3599
+ maxAnswerChoices
3600
+ } = model || {};
3601
+
3602
+ if (maxAnswerChoices && ((_model$choices = model.choices) == null ? void 0 : _model$choices.length) >= maxAnswerChoices) {
3603
+ return;
3604
+ }
3605
+
3606
+ const id = choiceUtils.firstAvailableIndex(model.choices.map(a => a.id), 1);
3607
+ const data = {
3608
+ id,
3609
+ content: 'Choice ' + id
3610
+ };
3611
+ this.setState({
3612
+ focusedEl: oldChoices.length
3613
+ }, () => {
3614
+ onModelChanged({
3615
+ choices: model.choices.concat([data])
3616
+ });
3617
+ });
3618
+ };
3619
+
3620
+ this.deleteFocusedEl = () => {
3621
+ this.setState({
3622
+ focusedEl: null
3623
+ });
3624
+ };
3625
+
3626
+ this.deleteChoice = choice => {
3627
+ const {
3628
+ model,
3629
+ onModelChanged
3630
+ } = this.props;
3631
+ const index = model.choices.findIndex(a => a.id === choice.id);
3632
+
3633
+ if (index !== -1) {
3634
+ model.choices.splice(index, 1);
3635
+ model.correctResponse = removeAllChoices(choice.id, model.correctResponse);
3636
+ onModelChanged(model);
3637
+ }
3638
+ };
3639
+
3640
+ this.rearrangeChoices = (indexFrom, indexTo) => {
3641
+ const {
3642
+ model,
3643
+ onModelChanged
3644
+ } = this.props || {};
3645
+ let {
3646
+ choices
3647
+ } = model || [];
3648
+ choices = rearrangeChoices(choices, indexFrom, indexTo);
3649
+ onModelChanged({
3650
+ choices
3651
+ });
3652
+ };
3653
+ }
3654
+
3655
+ render() {
3656
+ const {
3657
+ focusedEl
3658
+ } = this.state;
3659
+ const {
3660
+ classes,
3661
+ className,
3662
+ choices,
3663
+ model,
3664
+ imageSupport,
3665
+ uploadSoundSupport,
3666
+ onModelChanged,
3667
+ spellCheck,
3668
+ toolbarOpts,
3669
+ configuration,
3670
+ defaultImageMaxWidth,
3671
+ defaultImageMaxHeight
3672
+ } = this.props;
3673
+ const {
3674
+ errors,
3675
+ allowMultiplePlacementsEnabled,
3676
+ lockChoiceOrder,
3677
+ maxAnswerChoices
3678
+ } = model;
3679
+ const {
3680
+ choicesError,
3681
+ choicesErrors
3682
+ } = errors || {};
3683
+ const {
3684
+ maxImageWidth = {},
3685
+ maxImageHeight = {}
3686
+ } = configuration || {};
3687
+ const choiceHolderStyle = {
3688
+ gridTemplateColumns: `repeat(${model.categoriesPerRow}, 1fr)`
3689
+ };
3690
+ const addChoiceButtonTooltip = maxAnswerChoices && (choices == null ? void 0 : choices.length) >= maxAnswerChoices ? `Only ${maxAnswerChoices} allowed maximum` : '';
3691
+ return /*#__PURE__*/React.createElement("div", {
3692
+ className: classNames(classes.choices, className)
3693
+ }, /*#__PURE__*/React.createElement(Header$1, {
3694
+ label: "Choices",
3695
+ buttonLabel: "ADD A CHOICE",
3696
+ onAdd: this.addChoice,
3697
+ buttonDisabled: maxAnswerChoices && choices && (choices == null ? void 0 : choices.length) >= maxAnswerChoices,
3698
+ tooltip: addChoiceButtonTooltip
3699
+ }), /*#__PURE__*/React.createElement(Config$1, {
3700
+ config: model,
3701
+ onModelChanged: onModelChanged,
3702
+ spellCheck: spellCheck
3703
+ }), /*#__PURE__*/React.createElement("div", {
3704
+ className: classes.choiceHolder,
3705
+ style: choiceHolderStyle
3706
+ }, choices.map((h, index) => {
3707
+ return /*#__PURE__*/React.createElement(Choice$1, {
3708
+ choice: h,
3709
+ focusedEl: focusedEl,
3710
+ deleteFocusedEl: this.deleteFocusedEl,
3711
+ correctResponseCount: h.correctResponseCount,
3712
+ allowMultiplePlacements: allowMultiplePlacementsEnabled,
3713
+ lockChoiceOrder: lockChoiceOrder,
3714
+ index: index,
3715
+ key: index,
3716
+ imageSupport: imageSupport,
3717
+ onChange: this.changeChoice,
3718
+ onDelete: () => this.deleteChoice(h),
3719
+ rearrangeChoices: (indexFrom, indexTo) => this.rearrangeChoices(indexFrom, indexTo),
3720
+ toolbarOpts: toolbarOpts,
3721
+ spellCheck: spellCheck,
3722
+ error: choicesErrors && choicesErrors[h.id],
3723
+ maxImageWidth: maxImageWidth && maxImageWidth.choice || defaultImageMaxWidth,
3724
+ maxImageHeight: maxImageHeight && maxImageHeight.choice || defaultImageMaxHeight,
3725
+ uploadSoundSupport: uploadSoundSupport,
3726
+ configuration: configuration
3727
+ });
3728
+ })), choicesError && /*#__PURE__*/React.createElement("div", {
3729
+ className: classes.errorText
3730
+ }, choicesError));
3731
+ }
3732
+
3733
+ }
3734
+ Choices.propTypes = {
3735
+ model: PropTypes.object.isRequired,
3736
+ configuration: PropTypes.object.isRequired,
3737
+ classes: PropTypes.object.isRequired,
3738
+ className: PropTypes.string,
3739
+ choices: PropTypes.array.isRequired,
3740
+ defaultImageMaxWidth: PropTypes.number,
3741
+ defaultImageMaxHeight: PropTypes.number,
3742
+ onModelChanged: PropTypes.func.isRequired,
3743
+ imageSupport: PropTypes.shape({
3744
+ add: PropTypes.func.isRequired,
3745
+ delete: PropTypes.func.isRequired
3746
+ }),
3747
+ uploadSoundSupport: PropTypes.shape({
3748
+ add: PropTypes.func.isRequired,
3749
+ delete: PropTypes.func.isRequired
3750
+ }),
3751
+ toolbarOpts: PropTypes.object,
3752
+ spellCheck: PropTypes.bool
3753
+ };
3754
+ Choices.defaultProps = {};
3755
+
3756
+ const styles$2 = theme => ({
3757
+ choiceHolder: {
3758
+ paddingTop: theme.spacing.unit,
3759
+ paddingBottom: theme.spacing.unit,
3760
+ display: 'grid',
3761
+ gridRowGap: `${theme.spacing.unit}px`,
3762
+ gridColumnGap: `${theme.spacing.unit}px`
3763
+ },
3764
+ choices: {
3765
+ marginBottom: theme.spacing.unit * 2.5
3766
+ },
3767
+ errorText: {
3768
+ fontSize: theme.typography.fontSize - 2,
3769
+ color: theme.palette.error.main,
3770
+ paddingTop: theme.spacing.unit / 2
3771
+ }
3772
+ });
3773
+
3774
+ var Choices$1 = withStyles(styles$2)(Choices);
3775
+
3776
+ const buildCategories = (categories, choices, correctResponse) => {
3777
+ const clonedCategories = cloneDeep(categories);
3778
+ return clonedCategories.map(category => {
3779
+ const cr = correctResponse.find(cr => cr.category === category.id);
3780
+
3781
+ if (cr) {
3782
+ category.choices = (cr.choices || []).map(choiceId => {
3783
+ const choice = choices.find(h => h.id === choiceId);
3784
+
3785
+ if (choice) {
3786
+ return Object.assign({}, {
3787
+ id: choice.id,
3788
+ content: choice.content
3789
+ });
3790
+ }
3791
+ });
3792
+ }
3793
+
3794
+ return category;
3795
+ });
3796
+ };
3797
+
3798
+ const getChoices = (cat, choices, index) => {
3799
+ if (!cat.alternateResponses || cat.alternateResponses.length === 0) {
3800
+ return [];
3801
+ }
3802
+
3803
+ return (cat.alternateResponses[index] || []).map(alt => {
3804
+ return choices.find(ch => ch.id === alt);
3805
+ });
3806
+ };
3807
+
3808
+ const buildAlternateResponses = (categories, choices, correctResponse) => {
3809
+ const mostAlternates = correctResponse.reduce((mostAlt, cat) => {
3810
+ if (cat.alternateResponses && cat.alternateResponses.length >= mostAlt) {
3811
+ return cat.alternateResponses.length;
3812
+ }
3813
+
3814
+ return mostAlt;
3815
+ }, 0);
3816
+ const alternatesArray = new Array(mostAlternates).fill(0);
3817
+ return alternatesArray.map((val, index) => {
3818
+ return correctResponse.map((cat, catIndex) => {
3819
+ const currentCategory = categories[catIndex];
3820
+ return {
3821
+ id: currentCategory.id,
3822
+ label: currentCategory.label,
3823
+ choices: getChoices(cat, choices, index)
3824
+ };
3825
+ });
3826
+ });
3827
+ };
3828
+
3829
+ const {
3830
+ translator
3831
+ } = Translator;
3832
+ const {
3833
+ dropdown,
3834
+ Panel,
3835
+ toggle,
3836
+ radio,
3837
+ numberField
3838
+ } = settings;
3839
+ const {
3840
+ Provider: IdProvider
3841
+ } = uid;
3842
+ class Design extends React.Component {
3843
+ constructor(_props) {
3844
+ super(_props);
3845
+
3846
+ this.updateModel = props => {
3847
+ const {
3848
+ model,
3849
+ onChange
3850
+ } = this.props;
3851
+
3852
+ const updatedModel = _extends({}, model, props);
3853
+
3854
+ updatedModel.choices = updatedModel.choices.map(c => _extends({}, c, {
3855
+ categoryCount: this.checkAllowMultiplePlacements(updatedModel.allowMultiplePlacementsEnabled, c)
3856
+ })); //Ensure that there are no extra choices in correctResponse, if the user has decided that only one choice may be used.
3857
+
3858
+ updatedModel.correctResponse = ensureNoExtraChoicesInAnswer(updatedModel.correctResponse || [], updatedModel.choices); //Ensure that there are no extra choices in alternate responses, if the user has decided that only one choice may be used.
3859
+
3860
+ updatedModel.correctResponse = ensureNoExtraChoicesInAlternate(updatedModel.correctResponse || [], updatedModel.choices); //clean categories
3861
+
3862
+ updatedModel.categories = updatedModel.categories.map(c => ({
3863
+ id: c.id,
3864
+ label: c.label
3865
+ }));
3866
+ updatedModel.choices = updatedModel.choices.map(h => ({
3867
+ id: h.id,
3868
+ content: h.content,
3869
+ categoryCount: h.categoryCount
3870
+ })); // ensure that maxChoicesPerCategory is reset if author switch back the corresponding switch (allowMaxChoicesPerCategory)
3871
+
3872
+ updatedModel.maxChoicesPerCategory = updatedModel.allowMaxChoicesPerCategory ? updatedModel.maxChoicesPerCategory : 0;
3873
+ onChange(updatedModel);
3874
+ };
3875
+
3876
+ this.changeRationale = rationale => {
3877
+ const {
3878
+ model,
3879
+ onChange
3880
+ } = this.props;
3881
+ onChange(_extends({}, model, {
3882
+ rationale
3883
+ }));
3884
+ };
3885
+
3886
+ this.changeTeacherInstructions = teacherInstructions => {
3887
+ const {
3888
+ model,
3889
+ onChange
3890
+ } = this.props;
3891
+ onChange(_extends({}, model, {
3892
+ teacherInstructions
3893
+ }));
3894
+ };
3895
+
3896
+ this.changeFeedback = feedback => {
3897
+ this.updateModel({
3898
+ feedback
3899
+ });
3900
+ };
3901
+
3902
+ this.onAddAlternateResponse = () => {
3903
+ const {
3904
+ model: {
3905
+ correctResponse
3906
+ }
3907
+ } = this.props;
3908
+ this.updateModel({
3909
+ correctResponse: (correctResponse || []).map(cr => _extends({}, cr, {
3910
+ alternateResponses: [...(cr.alternateResponses || []), []]
3911
+ }))
3912
+ });
3913
+ };
3914
+
3915
+ this.onPromptChanged = prompt => this.updateModel({
3916
+ prompt
3917
+ });
3918
+
3919
+ this.onRemoveAlternateResponse = index => {
3920
+ const {
3921
+ model: {
3922
+ correctResponse
3923
+ }
3924
+ } = this.props;
3925
+ this.updateModel({
3926
+ correctResponse: (correctResponse || []).map(cr => _extends({}, cr, {
3927
+ alternateResponses: (cr.alternateResponses || []).filter((alt, altIndex) => altIndex !== index)
3928
+ }))
3929
+ });
3930
+ };
3931
+
3932
+ this.countChoiceInCorrectResponse = choice => {
3933
+ const {
3934
+ model
3935
+ } = this.props;
3936
+ return countInAnswer(choice.id, model.correctResponse);
3937
+ };
3938
+
3939
+ this.checkAllowMultiplePlacements = (allowMultiplePlacements, c) => {
3940
+ if (allowMultiplePlacements === multiplePlacements.enabled) {
3941
+ return 0;
3942
+ }
3943
+
3944
+ if (allowMultiplePlacements === multiplePlacements.disabled) {
3945
+ return 1;
3946
+ }
3947
+
3948
+ return c.categoryCount || 0;
3949
+ };
3950
+
3951
+ this.isAlertModalOpened = () => {
3952
+ const {
3953
+ model
3954
+ } = this.props;
3955
+ const {
3956
+ maxChoicesPerCategory = 0
3957
+ } = model || {};
3958
+ const maxChoices = getMaxCategoryChoices(model); // when maxChoicesPerCategory is set to 0, there is no limit so modal should not be opened
3959
+
3960
+ return maxChoicesPerCategory !== 0 ? maxChoices > maxChoicesPerCategory : false;
3961
+ };
3962
+
3963
+ this.onAlertModalCancel = () => {
3964
+ const {
3965
+ model
3966
+ } = this.props;
3967
+ const maxChoices = getMaxCategoryChoices(model);
3968
+ this.updateModel({
3969
+ maxChoicesPerCategory: maxChoices
3970
+ });
3971
+ };
3972
+
3973
+ this.uid = _props.uid || uid.generateId();
3974
+ }
3975
+
3976
+ render() {
3977
+ const {
3978
+ classes,
3979
+ configuration,
3980
+ imageSupport,
3981
+ model,
3982
+ uploadSoundSupport,
3983
+ onConfigurationChanged
3984
+ } = this.props;
3985
+ const {
3986
+ allowAlternate = {},
3987
+ allowMultiplePlacements = {},
3988
+ baseInputConfiguration = {},
3989
+ categoriesPerRow = {},
3990
+ choicesPosition = {},
3991
+ contentDimensions = {},
3992
+ feedback = {},
3993
+ lockChoiceOrder = {},
3994
+ maxImageHeight = {},
3995
+ maxImageWidth = {},
3996
+ maxPlacements = {},
3997
+ minCategoriesPerRow = 1,
3998
+ partialScoring = {},
3999
+ prompt = {},
4000
+ rationale = {},
4001
+ scoringType = {},
4002
+ settingsPanelDisabled,
4003
+ spellCheck = {},
4004
+ studentInstructions = {},
4005
+ teacherInstructions = {},
4006
+ withRubric = {},
4007
+ mathMlOptions = {},
4008
+ language = {},
4009
+ languageChoices = {},
4010
+ allowMaxAnswerChoices = {}
4011
+ } = configuration || {};
4012
+ const {
4013
+ allowAlternateEnabled,
4014
+ allowMaxChoicesPerCategory,
4015
+ errors,
4016
+ feedbackEnabled,
4017
+ maxChoicesPerCategory,
4018
+ promptEnabled,
4019
+ rationaleEnabled,
4020
+ spellCheckEnabled,
4021
+ teacherInstructionsEnabled,
4022
+ toolbarEditorPosition,
4023
+ extraCSSRules
4024
+ } = model || {};
4025
+ const {
4026
+ prompt: promptError,
4027
+ rationale: rationaleError,
4028
+ teacherInstructions: teacherInstructionsError
4029
+ } = errors || {};
4030
+ const toolbarOpts = {
4031
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
4032
+ };
4033
+ const config = model.config || {};
4034
+ config.choices = config.choices || {
4035
+ label: '',
4036
+ columns: 2
4037
+ };
4038
+ const categories = buildCategories(model.categories || [], model.choices || [], model.correctResponse || []);
4039
+ const alternateResponses = buildAlternateResponses(model.categories || [], model.choices || [], model.correctResponse || []);
4040
+ const choices = model.choices.map(c => {
4041
+ c.correctResponseCount = this.countChoiceInCorrectResponse(c); // ensure categoryCount is set even though updatedModel hasn't been called
4042
+
4043
+ c.categoryCount = this.checkAllowMultiplePlacements(model.allowMultiplePlacementsEnabled, c);
4044
+ return c;
4045
+ });
4046
+ const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
4047
+ const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
4048
+ const panelSettings = {
4049
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
4050
+ lockChoiceOrder: lockChoiceOrder.settings && toggle(lockChoiceOrder.label),
4051
+ categoriesPerRow: categoriesPerRow.settings && numberField(categoriesPerRow.label, {
4052
+ label: categoriesPerRow.label,
4053
+ min: minCategoriesPerRow,
4054
+ max: 6
4055
+ }),
4056
+ choicesPosition: choicesPosition.settings && radio(choicesPosition.label, ['below', 'above', 'left', 'right']),
4057
+ allowMultiplePlacementsEnabled: allowMultiplePlacements.settings && dropdown(allowMultiplePlacements.label, [multiplePlacements.enabled, multiplePlacements.disabled, multiplePlacements.perChoice]),
4058
+ maxAnswerChoices: allowMaxAnswerChoices.settings && numberField(allowMaxAnswerChoices.label, {
4059
+ label: '',
4060
+ min: (choices == null ? void 0 : choices.length) || 0,
4061
+ max: 30
4062
+ }),
4063
+ allowMaxChoicesPerCategory: maxPlacements.settings && toggle(maxPlacements.label),
4064
+ maxChoicesPerCategory: allowMaxChoicesPerCategory === true && numberField(maxPlacements.label, {
4065
+ label: '',
4066
+ min: 0,
4067
+ max: 30
4068
+ }),
4069
+ promptEnabled: prompt.settings && toggle(prompt.label),
4070
+ feedbackEnabled: feedback.settings && toggle(feedback.label),
4071
+ allowAlternateEnabled: allowAlternate.settings && toggle(allowAlternate.label),
4072
+ 'language.enabled': language.settings && toggle(language.label, true),
4073
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
4074
+ };
4075
+ const panelProperties = {
4076
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
4077
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
4078
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
4079
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
4080
+ scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
4081
+ rubricEnabled: (withRubric == null ? void 0 : withRubric.settings) && toggle(withRubric == null ? void 0 : withRubric.label)
4082
+ };
4083
+ const isOpened = this.isAlertModalOpened();
4084
+ const alertMaxChoicesMsg = translator.t('translation:categorize:maxChoicesPerCategoryRestriction', {
4085
+ lng: model.language,
4086
+ maxChoicesPerCategory
4087
+ });
4088
+ return /*#__PURE__*/React.createElement(IdProvider, {
4089
+ value: this.uid
4090
+ }, /*#__PURE__*/React.createElement(layout.ConfigLayout, {
4091
+ extraCSSRules: extraCSSRules,
4092
+ dimensions: contentDimensions,
4093
+ hideSettings: settingsPanelDisabled,
4094
+ settings: /*#__PURE__*/React.createElement(Panel, {
4095
+ model: model,
4096
+ onChangeModel: this.updateModel,
4097
+ configuration: configuration,
4098
+ onChangeConfiguration: onConfigurationChanged,
4099
+ groups: {
4100
+ Settings: panelSettings,
4101
+ Properties: panelProperties
4102
+ },
4103
+ modal: /*#__PURE__*/React.createElement(AlertDialog, {
4104
+ title: 'Warning',
4105
+ text: alertMaxChoicesMsg,
4106
+ open: isOpened,
4107
+ onClose: this.onAlertModalCancel
4108
+ })
4109
+ })
4110
+ }, teacherInstructionsEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
4111
+ label: teacherInstructions.label,
4112
+ className: classes.inputContainer
4113
+ }, /*#__PURE__*/React.createElement(EditableHtml, {
4114
+ className: classes.input,
4115
+ markup: model.teacherInstructions || '',
4116
+ onChange: this.changeTeacherInstructions,
4117
+ imageSupport: imageSupport,
4118
+ error: teacherInstructionsError,
4119
+ nonEmpty: false,
4120
+ toolbarOpts: toolbarOpts,
4121
+ pluginProps: getPluginProps(teacherInstructions == null ? void 0 : teacherInstructions.inputConfiguration, baseInputConfiguration),
4122
+ spellCheck: spellCheckEnabled,
4123
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
4124
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
4125
+ uploadSoundSupport: uploadSoundSupport,
4126
+ languageCharactersProps: [{
4127
+ language: 'spanish'
4128
+ }, {
4129
+ language: 'special'
4130
+ }],
4131
+ mathMlOptions: mathMlOptions
4132
+ }), teacherInstructionsError && /*#__PURE__*/React.createElement("div", {
4133
+ className: classes.errorText
4134
+ }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
4135
+ label: prompt.label,
4136
+ className: classes.inputContainer
4137
+ }, /*#__PURE__*/React.createElement(EditableHtml, {
4138
+ className: classes.input,
4139
+ markup: model.prompt || '',
4140
+ onChange: this.onPromptChanged,
4141
+ imageSupport: imageSupport,
4142
+ error: promptError,
4143
+ nonEmpty: false,
4144
+ disableUnderline: true,
4145
+ toolbarOpts: toolbarOpts,
4146
+ pluginProps: getPluginProps(prompt == null ? void 0 : prompt.inputConfiguration, baseInputConfiguration),
4147
+ spellCheck: spellCheckEnabled,
4148
+ maxImageWidth: maxImageWidth && maxImageWidth.prompt,
4149
+ maxImageHeight: maxImageHeight && maxImageHeight.prompt,
4150
+ uploadSoundSupport: uploadSoundSupport,
4151
+ languageCharactersProps: [{
4152
+ language: 'spanish'
4153
+ }, {
4154
+ language: 'special'
4155
+ }],
4156
+ mathMlOptions: mathMlOptions
4157
+ }), promptError && /*#__PURE__*/React.createElement("div", {
4158
+ className: classes.errorText
4159
+ }, promptError)), /*#__PURE__*/React.createElement(Categories$1, {
4160
+ imageSupport: imageSupport,
4161
+ uploadSoundSupport: uploadSoundSupport,
4162
+ model: model,
4163
+ categories: categories || [],
4164
+ onModelChanged: this.updateModel,
4165
+ toolbarOpts: toolbarOpts,
4166
+ spellCheck: spellCheckEnabled,
4167
+ configuration: configuration,
4168
+ defaultImageMaxWidth: defaultImageMaxWidth,
4169
+ defaultImageMaxHeight: defaultImageMaxHeight,
4170
+ mathMlOptions: mathMlOptions
4171
+ }), /*#__PURE__*/React.createElement(Choices$1, {
4172
+ imageSupport: imageSupport,
4173
+ uploadSoundSupport: uploadSoundSupport,
4174
+ choices: choices,
4175
+ model: model,
4176
+ onModelChanged: this.updateModel,
4177
+ toolbarOpts: toolbarOpts,
4178
+ spellCheck: spellCheckEnabled,
4179
+ configuration: configuration,
4180
+ defaultImageMaxWidth: defaultImageMaxWidth,
4181
+ defaultImageMaxHeight: defaultImageMaxHeight
4182
+ }), allowAlternateEnabled && /*#__PURE__*/React.createElement(Header$1, {
4183
+ className: classes.alternatesHeader,
4184
+ label: "Alternate Responses",
4185
+ buttonLabel: "ADD AN ALTERNATE RESPONSE",
4186
+ onAdd: this.onAddAlternateResponse
4187
+ }), allowAlternateEnabled && alternateResponses.map((categoriesList, index) => {
4188
+ return /*#__PURE__*/React.createElement(React.Fragment, {
4189
+ key: index
4190
+ }, /*#__PURE__*/React.createElement(Header$1, {
4191
+ className: classes.alternatesHeader,
4192
+ variant: 'subtitle1',
4193
+ label: "Alternate Response",
4194
+ buttonLabel: "REMOVE ALTERNATE RESPONSE",
4195
+ onAdd: () => this.onRemoveAlternateResponse(index)
4196
+ }), /*#__PURE__*/React.createElement(AlternateResponses$1, {
4197
+ altIndex: index,
4198
+ imageSupport: imageSupport,
4199
+ model: model,
4200
+ configuration: configuration,
4201
+ categories: categoriesList,
4202
+ onModelChanged: this.updateModel,
4203
+ uploadSoundSupport: uploadSoundSupport,
4204
+ mathMlOptions: mathMlOptions
4205
+ }));
4206
+ }), rationaleEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
4207
+ label: rationale.label,
4208
+ className: classes.inputContainer
4209
+ }, /*#__PURE__*/React.createElement(EditableHtml, {
4210
+ className: classes.input,
4211
+ markup: model.rationale || '',
4212
+ onChange: this.changeRationale,
4213
+ imageSupport: imageSupport,
4214
+ error: rationaleError,
4215
+ nonEmpty: false,
4216
+ toolbarOpts: toolbarOpts,
4217
+ pluginProps: getPluginProps(prompt == null ? void 0 : prompt.inputConfiguration, baseInputConfiguration),
4218
+ spellCheck: spellCheckEnabled,
4219
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
4220
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
4221
+ uploadSoundSupport: uploadSoundSupport,
4222
+ languageCharactersProps: [{
4223
+ language: 'spanish'
4224
+ }, {
4225
+ language: 'special'
4226
+ }],
4227
+ mathMlOptions: mathMlOptions
4228
+ }), rationaleError && /*#__PURE__*/React.createElement("div", {
4229
+ className: classes.errorText
4230
+ }, rationaleError)), feedbackEnabled && /*#__PURE__*/React.createElement(FeedbackConfig, {
4231
+ feedback: model.feedback,
4232
+ onChange: this.changeFeedback,
4233
+ toolbarOpts: toolbarOpts
4234
+ })));
4235
+ }
4236
+
4237
+ }
4238
+ Design.propTypes = {
4239
+ classes: PropTypes.object.isRequired,
4240
+ configuration: PropTypes.object,
4241
+ className: PropTypes.string,
4242
+ onConfigurationChanged: PropTypes.func,
4243
+ model: PropTypes.object.isRequired,
4244
+ onChange: PropTypes.func.isRequired,
4245
+ uid: PropTypes.string,
4246
+ imageSupport: PropTypes.shape({
4247
+ add: PropTypes.func.isRequired,
4248
+ delete: PropTypes.func.isRequired
4249
+ }),
4250
+ uploadSoundSupport: PropTypes.shape({
4251
+ add: PropTypes.func.isRequired,
4252
+ delete: PropTypes.func.isRequired
4253
+ })
4254
+ };
4255
+
4256
+ const styles$1 = theme => ({
4257
+ alternatesHeader: {
4258
+ marginBottom: theme.spacing.unit * 2
4259
+ },
4260
+ text: {
4261
+ paddingTop: theme.spacing.unit * 2,
4262
+ paddingBottom: theme.spacing.unit * 2
4263
+ },
4264
+ inputContainer: {
4265
+ width: '100%',
4266
+ paddingTop: theme.spacing.unit * 2,
4267
+ marginBottom: theme.spacing.unit * 2
4268
+ },
4269
+ title: {
4270
+ marginBottom: theme.spacing.unit * 4
4271
+ },
4272
+ errorText: {
4273
+ fontSize: theme.typography.fontSize - 2,
4274
+ color: theme.palette.error.main,
4275
+ paddingTop: theme.spacing.unit
4276
+ }
4277
+ });
4278
+
4279
+ var Design$1 = withDragContext(withStyles(styles$1)(Design));
4280
+
4281
+ class Main extends React.Component {
4282
+ render() {
4283
+ const {
4284
+ model,
4285
+ onModelChanged,
4286
+ configuration,
4287
+ onConfigurationChanged,
4288
+ imageSupport,
4289
+ uploadSoundSupport
4290
+ } = this.props;
4291
+ return /*#__PURE__*/React.createElement(Design$1, {
4292
+ imageSupport: imageSupport,
4293
+ uploadSoundSupport: uploadSoundSupport,
4294
+ title: "Design",
4295
+ model: model,
4296
+ configuration: configuration,
4297
+ onChange: onModelChanged,
4298
+ onConfigurationChanged: onConfigurationChanged
4299
+ });
4300
+ }
4301
+
4302
+ }
4303
+ Main.propTypes = {
4304
+ classes: PropTypes.object.isRequired,
4305
+ configuration: PropTypes.object,
4306
+ className: PropTypes.string,
4307
+ onConfigurationChanged: PropTypes.func,
4308
+ model: PropTypes.object.isRequired,
4309
+ onModelChanged: PropTypes.func.isRequired,
4310
+ imageSupport: PropTypes.object,
4311
+ uploadSoundSupport: PropTypes.object
4312
+ };
4313
+ Main.defaultProps = {};
4314
+
4315
+ const styles = () => ({});
4316
+
4317
+ var Main$1 = withStyles(styles)(Main);
4318
+
4319
+ var defaults = {
4320
+ model: {
4321
+ allowAlternateEnabled: true,
4322
+ allowMaxChoicesPerCategory: false,
4323
+ allowMultiplePlacementsEnabled: multiplePlacements.enabled,
4324
+ alternates: [],
4325
+ categories: [],
4326
+ categoriesPerRow: 2,
4327
+ choices: [],
4328
+ choicesLabel: '',
4329
+ choicesPosition: 'below',
4330
+ correctResponse: [],
4331
+ feedbackEnabled: false,
4332
+ lockChoiceOrder: true,
4333
+ maxAnswerChoices: 6,
4334
+ maxChoicesPerCategory: 0,
4335
+ partialScoring: true,
4336
+ promptEnabled: true,
4337
+ rationaleEnabled: true,
4338
+ rowLabels: [''],
4339
+ studentInstructionsEnabled: true,
4340
+ teacherInstructionsEnabled: true,
4341
+ toolbarEditorPosition: 'bottom',
4342
+ minRowHeight: '80px'
4343
+ },
4344
+ configuration: {
4345
+ baseInputConfiguration: {
4346
+ audio: {
4347
+ disabled: false
4348
+ },
4349
+ video: {
4350
+ disabled: false
4351
+ },
4352
+ image: {
4353
+ disabled: false
4354
+ },
4355
+ textAlign: {
4356
+ disabled: true
4357
+ },
4358
+ showParagraphs: {
4359
+ disabled: false
4360
+ },
4361
+ separateParagraphs: {
4362
+ disabled: true
4363
+ }
4364
+ },
4365
+ spellCheck: {
4366
+ label: 'Spellcheck',
4367
+ settings: false,
4368
+ enabled: true
4369
+ },
4370
+ feedback: {
4371
+ settings: true,
4372
+ label: 'Feedback',
4373
+ enabled: true
4374
+ },
4375
+ lockChoiceOrder: {
4376
+ settings: true,
4377
+ label: 'Lock Choice Order'
4378
+ },
4379
+ choicesPosition: {
4380
+ settings: true,
4381
+ label: 'Choices Position'
4382
+ },
4383
+ allowMultiplePlacements: {
4384
+ settings: true,
4385
+ label: 'Allow Multiple Placements'
4386
+ },
4387
+ maxPlacements: {
4388
+ settings: true,
4389
+ label: 'Max choices per category'
4390
+ },
4391
+ allowAlternate: {
4392
+ settings: true,
4393
+ label: 'Allow Alternate Correct Answers'
4394
+ },
4395
+ categoriesPerRow: {
4396
+ settings: true,
4397
+ label: 'Categories per row'
4398
+ },
4399
+ partialScoring: {
4400
+ settings: false,
4401
+ label: 'Allow Partial Scoring'
4402
+ },
4403
+ prompt: {
4404
+ settings: true,
4405
+ label: 'Prompt',
4406
+ required: false,
4407
+ inputConfiguration: {
4408
+ audio: {
4409
+ disabled: false
4410
+ },
4411
+ video: {
4412
+ disabled: false
4413
+ },
4414
+ image: {
4415
+ disabled: false
4416
+ }
4417
+ }
4418
+ },
4419
+ rationale: {
4420
+ settings: true,
4421
+ label: 'Rationale',
4422
+ required: false,
4423
+ inputConfiguration: {
4424
+ audio: {
4425
+ disabled: false
4426
+ },
4427
+ video: {
4428
+ disabled: false
4429
+ },
4430
+ image: {
4431
+ disabled: false
4432
+ }
4433
+ }
4434
+ },
4435
+ scoringType: {
4436
+ settings: false,
4437
+ label: 'Scoring Type'
4438
+ },
4439
+ settingsPanelDisabled: false,
4440
+ studentInstructions: {
4441
+ settings: false,
4442
+ label: 'Student Instructions'
4443
+ },
4444
+ teacherInstructions: {
4445
+ settings: true,
4446
+ label: 'Teacher Instructions',
4447
+ required: false,
4448
+ inputConfiguration: {
4449
+ audio: {
4450
+ disabled: false
4451
+ },
4452
+ video: {
4453
+ disabled: false
4454
+ },
4455
+ image: {
4456
+ disabled: false
4457
+ }
4458
+ }
4459
+ },
4460
+ headers: {
4461
+ inputConfiguration: {
4462
+ audio: {
4463
+ disabled: true
4464
+ },
4465
+ video: {
4466
+ disabled: true
4467
+ },
4468
+ image: {
4469
+ disabled: false
4470
+ }
4471
+ }
4472
+ },
4473
+ rowLabels: {
4474
+ inputConfiguration: {
4475
+ audio: {
4476
+ disabled: false
4477
+ },
4478
+ video: {
4479
+ disabled: false
4480
+ },
4481
+ image: {
4482
+ disabled: false
4483
+ }
4484
+ }
4485
+ },
4486
+ toolbarEditorPosition: {
4487
+ settings: false,
4488
+ label: 'Toolbar Editor Position'
4489
+ },
4490
+ maxImageWidth: {
4491
+ teacherInstructions: 300,
4492
+ prompt: 300,
4493
+ rationale: 300,
4494
+ rowLabel: 200,
4495
+ categoryLabel: 260,
4496
+ choices: 240
4497
+ },
4498
+ maxImageHeight: {
4499
+ teacherInstructions: 300,
4500
+ prompt: 300,
4501
+ rationale: 300,
4502
+ rowLabel: 100,
4503
+ categoryLabel: 100,
4504
+ choices: 150
4505
+ },
4506
+ withRubric: {
4507
+ settings: false,
4508
+ label: 'Add Rubric'
4509
+ },
4510
+ minCategoriesPerRow: 1,
4511
+ allowMaxAnswerChoices: {
4512
+ settings: true,
4513
+ label: 'Max answer choices'
4514
+ },
4515
+ mathMlOptions: {
4516
+ mmlOutput: false,
4517
+ mmlEditing: false
4518
+ },
4519
+ language: {
4520
+ settings: false,
4521
+ label: 'Specify Language',
4522
+ enabled: false
4523
+ },
4524
+ languageChoices: {
4525
+ label: 'Language Choices',
4526
+ options: []
4527
+ }
4528
+ }
4529
+ };
4530
+
4531
+ const _excluded = ["alternateResponses"];
4532
+ class CategorizeConfigure extends HTMLElement {
4533
+ // PD-2960: make sure we don't have alternates in model or possibility to add them (temporary solution)
4534
+ // this function is used in controller, too
4535
+ constructor() {
4536
+ super();
4537
+ this._model = CategorizeConfigure.createDefaultModel();
4538
+ this._configuration = defaults.configuration;
4539
+ }
4540
+
4541
+ set model(m) {
4542
+ this._model = CategorizeConfigure.createDefaultModel(m);
4543
+
4544
+ if (m.choices && m.choices.length >= m.maxAnswerChoices) {
4545
+ this._model.maxAnswerChoices = m.choices.length;
4546
+ console.warn("Max Answer Choices can't be less than choices length!");
4547
+ }
4548
+
4549
+ this.render();
4550
+ }
4551
+
4552
+ set configuration(c) {
4553
+ var _newConfiguration$lan;
4554
+
4555
+ const newConfiguration = _extends({}, defaults.configuration, c);
4556
+
4557
+ this._configuration = newConfiguration; // if language:enabled is true, then the corresponding default item model should include a language value;
4558
+ // if it is false, then the language field should be omitted from the item model.
4559
+ // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
4560
+ // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
4561
+
4562
+ if (newConfiguration != null && (_newConfiguration$lan = newConfiguration.language) != null && _newConfiguration$lan.enabled) {
4563
+ var _newConfiguration$lan2, _newConfiguration$lan3;
4564
+
4565
+ if (newConfiguration != null && (_newConfiguration$lan2 = newConfiguration.languageChoices) != null && (_newConfiguration$lan3 = _newConfiguration$lan2.options) != null && _newConfiguration$lan3.length) {
4566
+ this._model.language = newConfiguration == null ? void 0 : newConfiguration.languageChoices.options[0].value;
4567
+ }
4568
+ } else if (newConfiguration.language.settings && this._model.language) {
4569
+ this._configuration.language.enabled = true;
4570
+
4571
+ if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
4572
+ this._configuration.languageChoices.options = [];
4573
+ } // check if the language is already included in the languageChoices.options array
4574
+ // and if not, then add it.
4575
+
4576
+
4577
+ if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
4578
+ this._configuration.languageChoices.options.push({
4579
+ value: this._model.language,
4580
+ label: this._model.language
4581
+ });
4582
+ }
4583
+ } else {
4584
+ delete this._model.language;
4585
+ }
4586
+
4587
+ this.render();
4588
+ }
4589
+
4590
+ onModelChanged(m) {
4591
+ this._model = m;
4592
+ this.render();
4593
+ this.dispatchEvent(new ModelUpdatedEvent(this._model, false));
4594
+ }
4595
+
4596
+ onConfigurationChanged(c) {
4597
+ this._configuration = c;
4598
+ this.render();
4599
+ }
4600
+
4601
+ connectedCallback() {
4602
+ this.render();
4603
+ }
4604
+ /**
4605
+ *
4606
+ * @param {done, progress, file} handler
4607
+ */
4608
+
4609
+
4610
+ insertImage(handler) {
4611
+ this.dispatchEvent(new InsertImageEvent(handler));
4612
+ }
4613
+
4614
+ onDeleteImage(src, done) {
4615
+ this.dispatchEvent(new DeleteImageEvent(src, done));
4616
+ }
4617
+
4618
+ insertSound(handler) {
4619
+ this.dispatchEvent(new InsertSoundEvent(handler));
4620
+ }
4621
+
4622
+ onDeleteSound(src, done) {
4623
+ this.dispatchEvent(new DeleteSoundEvent(src, done));
4624
+ }
4625
+
4626
+ render() {
4627
+ const el = /*#__PURE__*/React.createElement(Main$1, {
4628
+ model: this._model,
4629
+ configuration: this._configuration,
4630
+ onModelChanged: this.onModelChanged.bind(this),
4631
+ onConfigurationChanged: this.onConfigurationChanged.bind(this),
4632
+ imageSupport: {
4633
+ add: this.insertImage.bind(this),
4634
+ delete: this.onDeleteImage.bind(this)
4635
+ },
4636
+ uploadSoundSupport: {
4637
+ add: this.insertSound.bind(this),
4638
+ delete: this.onDeleteSound.bind(this)
4639
+ }
4640
+ });
4641
+ ReactDOM.render(el, this, () => {
4642
+ renderMath(this);
4643
+ });
4644
+ }
4645
+
4646
+ }
4647
+
4648
+ CategorizeConfigure.createDefaultModel = (model = {}) => _extends({}, defaults.model, model);
4649
+
4650
+ CategorizeConfigure.disableAlternateResponses = m => {
4651
+ let {
4652
+ correctResponse
4653
+ } = m || {};
4654
+ correctResponse = correctResponse || [];
4655
+ const mappedCorrectResponse = correctResponse.map(cr => {
4656
+ const response = _objectWithoutPropertiesLoose(cr, _excluded);
4657
+
4658
+ return response;
4659
+ });
4660
+ return _extends({}, m, {
4661
+ correctResponse: mappedCorrectResponse,
4662
+ allowAlternateEnabled: false
4663
+ });
4664
+ };
4665
+
4666
+ export { CategorizeConfigure as default };
4667
+ //# sourceMappingURL=configure.js.map