@pie-element/placement-ordering 10.8.1-next.9 → 11.0.3-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,4378 @@
1
+ import { InsertImageEvent, DeleteImageEvent, ModelUpdatedEvent, InsertSoundEvent, DeleteSoundEvent } from '@pie-framework/pie-configure-events';
2
+ import { AlertDialog, layout, InputContainer as InputContainer$1, FormSection, FeedbackConfig, settings } from '@pie-lib/config-ui';
3
+ import EditableHtml, { DEFAULT_PLUGINS } from '@pie-lib/editable-html';
4
+ import { withStyles } from '@material-ui/core/styles';
5
+ import { withDragContext } from '@pie-lib/drag';
6
+ import React, { createContext, isValidElement, cloneElement, createRef, Component } from 'react';
7
+ import require$$3 from '@material-ui/core/SvgIcon';
8
+ import Tooltip from '@material-ui/core/Tooltip';
9
+ import debug from 'debug';
10
+ import cloneDeep from 'lodash/cloneDeep';
11
+ import PropTypes from 'prop-types';
12
+ import CardActions from '@material-ui/core/CardActions';
13
+ import classNames from 'classnames';
14
+ import IconButton from '@material-ui/core/IconButton';
15
+ import { color, InputContainer } from '@pie-lib/render-ui';
16
+ import { jsx } from 'react/jsx-runtime';
17
+ import isEmpty from 'lodash/isEmpty';
18
+ import uniqueId from 'lodash/uniqueId';
19
+ import shuffle from 'lodash/shuffle';
20
+ import isEqual from 'lodash/isEqual';
21
+ import Button from '@material-ui/core/Button';
22
+ import ReactDOM from 'react-dom';
23
+ import defaults from 'lodash/defaults';
24
+
25
+ function _extends() {
26
+ _extends = Object.assign || function (target) {
27
+ for (var i = 1; i < arguments.length; i++) {
28
+ var source = arguments[i];
29
+
30
+ for (var key in source) {
31
+ if (Object.prototype.hasOwnProperty.call(source, key)) {
32
+ target[key] = source[key];
33
+ }
34
+ }
35
+ }
36
+
37
+ return target;
38
+ };
39
+
40
+ return _extends.apply(this, arguments);
41
+ }
42
+
43
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
44
+
45
+ function commonjsRequire (path) {
46
+ throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
47
+ }
48
+
49
+ var Info = {};
50
+
51
+ var interopRequireDefault = {exports: {}};
52
+
53
+ (function (module) {
54
+ function _interopRequireDefault(obj) {
55
+ return obj && obj.__esModule ? obj : {
56
+ "default": obj
57
+ };
58
+ }
59
+
60
+ module.exports = _interopRequireDefault, module.exports.__esModule = true, module.exports["default"] = module.exports;
61
+ }(interopRequireDefault));
62
+
63
+ var createSvgIcon$1 = {};
64
+
65
+ var pure$1 = {};
66
+
67
+ var shouldUpdate$1 = {};
68
+
69
+ var inheritsLoose = {exports: {}};
70
+
71
+ var setPrototypeOf = {exports: {}};
72
+
73
+ (function (module) {
74
+ function _setPrototypeOf(o, p) {
75
+ module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
76
+ o.__proto__ = p;
77
+ return o;
78
+ }, module.exports.__esModule = true, module.exports["default"] = module.exports;
79
+ return _setPrototypeOf(o, p);
80
+ }
81
+
82
+ module.exports = _setPrototypeOf, module.exports.__esModule = true, module.exports["default"] = module.exports;
83
+ }(setPrototypeOf));
84
+
85
+ (function (module) {
86
+ var setPrototypeOf$1 = setPrototypeOf.exports;
87
+
88
+ function _inheritsLoose(subClass, superClass) {
89
+ subClass.prototype = Object.create(superClass.prototype);
90
+ subClass.prototype.constructor = subClass;
91
+ setPrototypeOf$1(subClass, superClass);
92
+ }
93
+
94
+ module.exports = _inheritsLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
95
+ }(inheritsLoose));
96
+
97
+ var setDisplayName$1 = {};
98
+
99
+ var setStatic$1 = {};
100
+
101
+ setStatic$1.__esModule = true;
102
+ setStatic$1.default = void 0;
103
+
104
+ var setStatic = function setStatic(key, value) {
105
+ return function (BaseComponent) {
106
+ /* eslint-disable no-param-reassign */
107
+ BaseComponent[key] = value;
108
+ /* eslint-enable no-param-reassign */
109
+
110
+ return BaseComponent;
111
+ };
112
+ };
113
+
114
+ var _default$a = setStatic;
115
+ setStatic$1.default = _default$a;
116
+
117
+ var _interopRequireDefault$8 = interopRequireDefault.exports;
118
+
119
+ setDisplayName$1.__esModule = true;
120
+ setDisplayName$1.default = void 0;
121
+
122
+ var _setStatic = _interopRequireDefault$8(setStatic$1);
123
+
124
+ var setDisplayName = function setDisplayName(displayName) {
125
+ return (0, _setStatic.default)('displayName', displayName);
126
+ };
127
+
128
+ var _default$9 = setDisplayName;
129
+ setDisplayName$1.default = _default$9;
130
+
131
+ var wrapDisplayName$1 = {};
132
+
133
+ var getDisplayName$1 = {};
134
+
135
+ getDisplayName$1.__esModule = true;
136
+ getDisplayName$1.default = void 0;
137
+
138
+ var getDisplayName = function getDisplayName(Component) {
139
+ if (typeof Component === 'string') {
140
+ return Component;
141
+ }
142
+
143
+ if (!Component) {
144
+ return undefined;
145
+ }
146
+
147
+ return Component.displayName || Component.name || 'Component';
148
+ };
149
+
150
+ var _default$8 = getDisplayName;
151
+ getDisplayName$1.default = _default$8;
152
+
153
+ var _interopRequireDefault$7 = interopRequireDefault.exports;
154
+
155
+ wrapDisplayName$1.__esModule = true;
156
+ wrapDisplayName$1.default = void 0;
157
+
158
+ var _getDisplayName = _interopRequireDefault$7(getDisplayName$1);
159
+
160
+ var wrapDisplayName = function wrapDisplayName(BaseComponent, hocName) {
161
+ return hocName + "(" + (0, _getDisplayName.default)(BaseComponent) + ")";
162
+ };
163
+
164
+ var _default$7 = wrapDisplayName;
165
+ wrapDisplayName$1.default = _default$7;
166
+
167
+ var _interopRequireDefault$6 = interopRequireDefault.exports;
168
+
169
+ shouldUpdate$1.__esModule = true;
170
+ shouldUpdate$1.default = void 0;
171
+
172
+ var _inheritsLoose2 = _interopRequireDefault$6(inheritsLoose.exports);
173
+
174
+ var _react$4 = React;
175
+
176
+ var _setDisplayName$1 = _interopRequireDefault$6(setDisplayName$1);
177
+
178
+ var _wrapDisplayName$1 = _interopRequireDefault$6(wrapDisplayName$1);
179
+
180
+ var shouldUpdate = function shouldUpdate(test) {
181
+ return function (BaseComponent) {
182
+ var factory = (0, _react$4.createFactory)(BaseComponent);
183
+
184
+ var ShouldUpdate =
185
+ /*#__PURE__*/
186
+ function (_Component) {
187
+ (0, _inheritsLoose2.default)(ShouldUpdate, _Component);
188
+
189
+ function ShouldUpdate() {
190
+ return _Component.apply(this, arguments) || this;
191
+ }
192
+
193
+ var _proto = ShouldUpdate.prototype;
194
+
195
+ _proto.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
196
+ return test(this.props, nextProps);
197
+ };
198
+
199
+ _proto.render = function render() {
200
+ return factory(this.props);
201
+ };
202
+
203
+ return ShouldUpdate;
204
+ }(_react$4.Component);
205
+
206
+ if (process.env.NODE_ENV !== 'production') {
207
+ return (0, _setDisplayName$1.default)((0, _wrapDisplayName$1.default)(BaseComponent, 'shouldUpdate'))(ShouldUpdate);
208
+ }
209
+
210
+ return ShouldUpdate;
211
+ };
212
+ };
213
+
214
+ var _default$6 = shouldUpdate;
215
+ shouldUpdate$1.default = _default$6;
216
+
217
+ var shallowEqual$2 = {};
218
+
219
+ /**
220
+ * Copyright (c) 2013-present, Facebook, Inc.
221
+ *
222
+ * This source code is licensed under the MIT license found in the
223
+ * LICENSE file in the root directory of this source tree.
224
+ *
225
+ * @typechecks
226
+ *
227
+ */
228
+
229
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
230
+
231
+ /**
232
+ * inlined Object.is polyfill to avoid requiring consumers ship their own
233
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
234
+ */
235
+ function is(x, y) {
236
+ // SameValue algorithm
237
+ if (x === y) {
238
+ // Steps 1-5, 7-10
239
+ // Steps 6.b-6.e: +0 != -0
240
+ // Added the nonzero y check to make Flow happy, but it is redundant
241
+ return x !== 0 || y !== 0 || 1 / x === 1 / y;
242
+ } else {
243
+ // Step 6.a: NaN == NaN
244
+ return x !== x && y !== y;
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Performs equality by iterating through keys on an object and returning false
250
+ * when any key has values which are not strictly equal between the arguments.
251
+ * Returns true when the values of all keys are strictly equal.
252
+ */
253
+ function shallowEqual$1(objA, objB) {
254
+ if (is(objA, objB)) {
255
+ return true;
256
+ }
257
+
258
+ if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
259
+ return false;
260
+ }
261
+
262
+ var keysA = Object.keys(objA);
263
+ var keysB = Object.keys(objB);
264
+
265
+ if (keysA.length !== keysB.length) {
266
+ return false;
267
+ }
268
+
269
+ // Test for A's keys different from B.
270
+ for (var i = 0; i < keysA.length; i++) {
271
+ if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
272
+ return false;
273
+ }
274
+ }
275
+
276
+ return true;
277
+ }
278
+
279
+ var shallowEqual_1 = shallowEqual$1;
280
+
281
+ var _interopRequireDefault$5 = interopRequireDefault.exports;
282
+
283
+ shallowEqual$2.__esModule = true;
284
+ shallowEqual$2.default = void 0;
285
+
286
+ var _shallowEqual$1 = _interopRequireDefault$5(shallowEqual_1);
287
+
288
+ var _default$5 = _shallowEqual$1.default;
289
+ shallowEqual$2.default = _default$5;
290
+
291
+ var _interopRequireDefault$4 = interopRequireDefault.exports;
292
+
293
+ pure$1.__esModule = true;
294
+ pure$1.default = void 0;
295
+
296
+ var _shouldUpdate = _interopRequireDefault$4(shouldUpdate$1);
297
+
298
+ var _shallowEqual = _interopRequireDefault$4(shallowEqual$2);
299
+
300
+ var _setDisplayName = _interopRequireDefault$4(setDisplayName$1);
301
+
302
+ var _wrapDisplayName = _interopRequireDefault$4(wrapDisplayName$1);
303
+
304
+ var pure = function pure(BaseComponent) {
305
+ var hoc = (0, _shouldUpdate.default)(function (props, nextProps) {
306
+ return !(0, _shallowEqual.default)(props, nextProps);
307
+ });
308
+
309
+ if (process.env.NODE_ENV !== 'production') {
310
+ return (0, _setDisplayName.default)((0, _wrapDisplayName.default)(BaseComponent, 'pure'))(hoc(BaseComponent));
311
+ }
312
+
313
+ return hoc(BaseComponent);
314
+ };
315
+
316
+ var _default$4 = pure;
317
+ pure$1.default = _default$4;
318
+
319
+ var _interopRequireDefault$3 = interopRequireDefault.exports;
320
+
321
+ Object.defineProperty(createSvgIcon$1, "__esModule", {
322
+ value: true
323
+ });
324
+ createSvgIcon$1.default = void 0;
325
+
326
+ var _react$3 = _interopRequireDefault$3(React);
327
+
328
+ var _pure = _interopRequireDefault$3(pure$1);
329
+
330
+ var _SvgIcon = _interopRequireDefault$3(require$$3);
331
+
332
+ function createSvgIcon(path, displayName) {
333
+ var Icon = function Icon(props) {
334
+ return _react$3.default.createElement(_SvgIcon.default, props, path);
335
+ };
336
+
337
+ Icon.displayName = "".concat(displayName, "Icon");
338
+ Icon = (0, _pure.default)(Icon);
339
+ Icon.muiName = 'SvgIcon';
340
+ return Icon;
341
+ }
342
+ var _default$3 = createSvgIcon;
343
+ createSvgIcon$1.default = _default$3;
344
+
345
+ var _interopRequireDefault$2 = interopRequireDefault.exports;
346
+
347
+ Object.defineProperty(Info, "__esModule", {
348
+ value: true
349
+ });
350
+ var default_1$2 = Info.default = void 0;
351
+
352
+ var _react$2 = _interopRequireDefault$2(React);
353
+
354
+ var _createSvgIcon$2 = _interopRequireDefault$2(createSvgIcon$1);
355
+
356
+ var _default$2 = (0, _createSvgIcon$2.default)(_react$2.default.createElement(_react$2.default.Fragment, null, _react$2.default.createElement("path", {
357
+ fill: "none",
358
+ d: "M0 0h24v24H0z"
359
+ }), _react$2.default.createElement("path", {
360
+ d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-6h2v6zm0-8h-2V7h2v2z"
361
+ })), 'Info');
362
+
363
+ default_1$2 = Info.default = _default$2;
364
+
365
+ /**
366
+ * @license nested-property https://github.com/cosmosio/nested-property
367
+ *
368
+ * The MIT License (MIT)
369
+ *
370
+ * Copyright (c) 2014-2015 Olivier Scherrer <pode.fr@gmail.com>
371
+ */
372
+
373
+ var nestedProperty = {
374
+ set: setNestedProperty,
375
+ get: getNestedProperty,
376
+ has: hasNestedProperty,
377
+ hasOwn: function (object, property, options) {
378
+ return this.has(object, property, options || {own: true});
379
+ },
380
+ isIn: isInNestedProperty
381
+ };
382
+
383
+ /**
384
+ * Get the property of an object nested in one or more objects
385
+ * given an object such as a.b.c.d = 5, getNestedProperty(a, "b.c.d") will return 5.
386
+ * @param {Object} object the object to get the property from
387
+ * @param {String} property the path to the property as a string
388
+ * @returns the object or the the property value if found
389
+ */
390
+ function getNestedProperty(object, property) {
391
+ if (object && typeof object == "object") {
392
+ if (typeof property == "string" && property !== "") {
393
+ var split = property.split(".");
394
+ return split.reduce(function (obj, prop) {
395
+ return obj && obj[prop];
396
+ }, object);
397
+ } else if (typeof property == "number") {
398
+ return object[property];
399
+ } else {
400
+ return object;
401
+ }
402
+ } else {
403
+ return object;
404
+ }
405
+ }
406
+
407
+ /**
408
+ * Tell if a nested object has a given property (or array a given index)
409
+ * given an object such as a.b.c.d = 5, hasNestedProperty(a, "b.c.d") will return true.
410
+ * It also returns true if the property is in the prototype chain.
411
+ * @param {Object} object the object to get the property from
412
+ * @param {String} property the path to the property as a string
413
+ * @param {Object} options:
414
+ * - own: set to reject properties from the prototype
415
+ * @returns true if has (property in object), false otherwise
416
+ */
417
+ function hasNestedProperty(object, property, options) {
418
+ options = options || {};
419
+
420
+ if (object && typeof object == "object") {
421
+ if (typeof property == "string" && property !== "") {
422
+ var split = property.split(".");
423
+ return split.reduce(function (obj, prop, idx, array) {
424
+ if (idx == array.length - 1) {
425
+ if (options.own) {
426
+ return !!(obj && obj.hasOwnProperty(prop));
427
+ } else {
428
+ return !!(obj !== null && typeof obj == "object" && prop in obj);
429
+ }
430
+ }
431
+ return obj && obj[prop];
432
+ }, object);
433
+ } else if (typeof property == "number") {
434
+ return property in object;
435
+ } else {
436
+ return false;
437
+ }
438
+ } else {
439
+ return false;
440
+ }
441
+ }
442
+
443
+ /**
444
+ * Set the property of an object nested in one or more objects
445
+ * If the property doesn't exist, it gets created.
446
+ * @param {Object} object
447
+ * @param {String} property
448
+ * @param value the value to set
449
+ * @returns object if no assignment was made or the value if the assignment was made
450
+ */
451
+ function setNestedProperty(object, property, value) {
452
+ if (object && typeof object == "object") {
453
+ if (typeof property == "string" && property !== "") {
454
+ var split = property.split(".");
455
+ return split.reduce(function (obj, prop, idx) {
456
+ obj[prop] = obj[prop] || {};
457
+ if (split.length == (idx + 1)) {
458
+ obj[prop] = value;
459
+ }
460
+ return obj[prop];
461
+ }, object);
462
+ } else if (typeof property == "number") {
463
+ object[property] = value;
464
+ return object[property];
465
+ } else {
466
+ return object;
467
+ }
468
+ } else {
469
+ return object;
470
+ }
471
+ }
472
+
473
+ /**
474
+ * Tell if an object is on the path to a nested property
475
+ * If the object is on the path, and the path exists, it returns true, and false otherwise.
476
+ * @param {Object} object to get the nested property from
477
+ * @param {String} property name of the nested property
478
+ * @param {Object} objectInPath the object to check
479
+ * @param {Object} options:
480
+ * - validPath: return false if the path is invalid, even if the object is in the path
481
+ * @returns {boolean} true if the object is on the path
482
+ */
483
+ function isInNestedProperty(object, property, objectInPath, options) {
484
+ options = options || {};
485
+
486
+ if (object && typeof object == "object") {
487
+ if (typeof property == "string" && property !== "") {
488
+ var split = property.split("."),
489
+ isIn = false,
490
+ pathExists;
491
+
492
+ pathExists = !!split.reduce(function (obj, prop) {
493
+ isIn = isIn || obj === objectInPath || (!!obj && obj[prop] === objectInPath);
494
+ return obj && obj[prop];
495
+ }, object);
496
+
497
+ if (options.validPath) {
498
+ return isIn && pathExists;
499
+ } else {
500
+ return isIn;
501
+ }
502
+ } else {
503
+ return false;
504
+ }
505
+ } else {
506
+ return false;
507
+ }
508
+ }
509
+
510
+ var pluralize$1 = {exports: {}};
511
+
512
+ /* global define */
513
+
514
+ (function (module, exports) {
515
+ (function (root, pluralize) {
516
+ /* istanbul ignore else */
517
+ if (typeof commonjsRequire === 'function' && 'object' === 'object' && 'object' === 'object') {
518
+ // Node.
519
+ module.exports = pluralize();
520
+ } else {
521
+ // Browser global.
522
+ root.pluralize = pluralize();
523
+ }
524
+ })(commonjsGlobal, function () {
525
+ // Rule storage - pluralize and singularize need to be run sequentially,
526
+ // while other rules can be optimized using an object for instant lookups.
527
+ var pluralRules = [];
528
+ var singularRules = [];
529
+ var uncountables = {};
530
+ var irregularPlurals = {};
531
+ var irregularSingles = {};
532
+
533
+ /**
534
+ * Sanitize a pluralization rule to a usable regular expression.
535
+ *
536
+ * @param {(RegExp|string)} rule
537
+ * @return {RegExp}
538
+ */
539
+ function sanitizeRule (rule) {
540
+ if (typeof rule === 'string') {
541
+ return new RegExp('^' + rule + '$', 'i');
542
+ }
543
+
544
+ return rule;
545
+ }
546
+
547
+ /**
548
+ * Pass in a word token to produce a function that can replicate the case on
549
+ * another word.
550
+ *
551
+ * @param {string} word
552
+ * @param {string} token
553
+ * @return {Function}
554
+ */
555
+ function restoreCase (word, token) {
556
+ // Tokens are an exact match.
557
+ if (word === token) return token;
558
+
559
+ // Lower cased words. E.g. "hello".
560
+ if (word === word.toLowerCase()) return token.toLowerCase();
561
+
562
+ // Upper cased words. E.g. "WHISKY".
563
+ if (word === word.toUpperCase()) return token.toUpperCase();
564
+
565
+ // Title cased words. E.g. "Title".
566
+ if (word[0] === word[0].toUpperCase()) {
567
+ return token.charAt(0).toUpperCase() + token.substr(1).toLowerCase();
568
+ }
569
+
570
+ // Lower cased words. E.g. "test".
571
+ return token.toLowerCase();
572
+ }
573
+
574
+ /**
575
+ * Interpolate a regexp string.
576
+ *
577
+ * @param {string} str
578
+ * @param {Array} args
579
+ * @return {string}
580
+ */
581
+ function interpolate (str, args) {
582
+ return str.replace(/\$(\d{1,2})/g, function (match, index) {
583
+ return args[index] || '';
584
+ });
585
+ }
586
+
587
+ /**
588
+ * Replace a word using a rule.
589
+ *
590
+ * @param {string} word
591
+ * @param {Array} rule
592
+ * @return {string}
593
+ */
594
+ function replace (word, rule) {
595
+ return word.replace(rule[0], function (match, index) {
596
+ var result = interpolate(rule[1], arguments);
597
+
598
+ if (match === '') {
599
+ return restoreCase(word[index - 1], result);
600
+ }
601
+
602
+ return restoreCase(match, result);
603
+ });
604
+ }
605
+
606
+ /**
607
+ * Sanitize a word by passing in the word and sanitization rules.
608
+ *
609
+ * @param {string} token
610
+ * @param {string} word
611
+ * @param {Array} rules
612
+ * @return {string}
613
+ */
614
+ function sanitizeWord (token, word, rules) {
615
+ // Empty string or doesn't need fixing.
616
+ if (!token.length || uncountables.hasOwnProperty(token)) {
617
+ return word;
618
+ }
619
+
620
+ var len = rules.length;
621
+
622
+ // Iterate over the sanitization rules and use the first one to match.
623
+ while (len--) {
624
+ var rule = rules[len];
625
+
626
+ if (rule[0].test(word)) return replace(word, rule);
627
+ }
628
+
629
+ return word;
630
+ }
631
+
632
+ /**
633
+ * Replace a word with the updated word.
634
+ *
635
+ * @param {Object} replaceMap
636
+ * @param {Object} keepMap
637
+ * @param {Array} rules
638
+ * @return {Function}
639
+ */
640
+ function replaceWord (replaceMap, keepMap, rules) {
641
+ return function (word) {
642
+ // Get the correct token and case restoration functions.
643
+ var token = word.toLowerCase();
644
+
645
+ // Check against the keep object map.
646
+ if (keepMap.hasOwnProperty(token)) {
647
+ return restoreCase(word, token);
648
+ }
649
+
650
+ // Check against the replacement map for a direct word replacement.
651
+ if (replaceMap.hasOwnProperty(token)) {
652
+ return restoreCase(word, replaceMap[token]);
653
+ }
654
+
655
+ // Run all the rules against the word.
656
+ return sanitizeWord(token, word, rules);
657
+ };
658
+ }
659
+
660
+ /**
661
+ * Check if a word is part of the map.
662
+ */
663
+ function checkWord (replaceMap, keepMap, rules, bool) {
664
+ return function (word) {
665
+ var token = word.toLowerCase();
666
+
667
+ if (keepMap.hasOwnProperty(token)) return true;
668
+ if (replaceMap.hasOwnProperty(token)) return false;
669
+
670
+ return sanitizeWord(token, token, rules) === token;
671
+ };
672
+ }
673
+
674
+ /**
675
+ * Pluralize or singularize a word based on the passed in count.
676
+ *
677
+ * @param {string} word The word to pluralize
678
+ * @param {number} count How many of the word exist
679
+ * @param {boolean} inclusive Whether to prefix with the number (e.g. 3 ducks)
680
+ * @return {string}
681
+ */
682
+ function pluralize (word, count, inclusive) {
683
+ var pluralized = count === 1
684
+ ? pluralize.singular(word) : pluralize.plural(word);
685
+
686
+ return (inclusive ? count + ' ' : '') + pluralized;
687
+ }
688
+
689
+ /**
690
+ * Pluralize a word.
691
+ *
692
+ * @type {Function}
693
+ */
694
+ pluralize.plural = replaceWord(
695
+ irregularSingles, irregularPlurals, pluralRules
696
+ );
697
+
698
+ /**
699
+ * Check if a word is plural.
700
+ *
701
+ * @type {Function}
702
+ */
703
+ pluralize.isPlural = checkWord(
704
+ irregularSingles, irregularPlurals, pluralRules
705
+ );
706
+
707
+ /**
708
+ * Singularize a word.
709
+ *
710
+ * @type {Function}
711
+ */
712
+ pluralize.singular = replaceWord(
713
+ irregularPlurals, irregularSingles, singularRules
714
+ );
715
+
716
+ /**
717
+ * Check if a word is singular.
718
+ *
719
+ * @type {Function}
720
+ */
721
+ pluralize.isSingular = checkWord(
722
+ irregularPlurals, irregularSingles, singularRules
723
+ );
724
+
725
+ /**
726
+ * Add a pluralization rule to the collection.
727
+ *
728
+ * @param {(string|RegExp)} rule
729
+ * @param {string} replacement
730
+ */
731
+ pluralize.addPluralRule = function (rule, replacement) {
732
+ pluralRules.push([sanitizeRule(rule), replacement]);
733
+ };
734
+
735
+ /**
736
+ * Add a singularization rule to the collection.
737
+ *
738
+ * @param {(string|RegExp)} rule
739
+ * @param {string} replacement
740
+ */
741
+ pluralize.addSingularRule = function (rule, replacement) {
742
+ singularRules.push([sanitizeRule(rule), replacement]);
743
+ };
744
+
745
+ /**
746
+ * Add an uncountable word rule.
747
+ *
748
+ * @param {(string|RegExp)} word
749
+ */
750
+ pluralize.addUncountableRule = function (word) {
751
+ if (typeof word === 'string') {
752
+ uncountables[word.toLowerCase()] = true;
753
+ return;
754
+ }
755
+
756
+ // Set singular and plural references for the word.
757
+ pluralize.addPluralRule(word, '$0');
758
+ pluralize.addSingularRule(word, '$0');
759
+ };
760
+
761
+ /**
762
+ * Add an irregular word definition.
763
+ *
764
+ * @param {string} single
765
+ * @param {string} plural
766
+ */
767
+ pluralize.addIrregularRule = function (single, plural) {
768
+ plural = plural.toLowerCase();
769
+ single = single.toLowerCase();
770
+
771
+ irregularSingles[single] = plural;
772
+ irregularPlurals[plural] = single;
773
+ };
774
+
775
+ /**
776
+ * Irregular rules.
777
+ */
778
+ [
779
+ // Pronouns.
780
+ ['I', 'we'],
781
+ ['me', 'us'],
782
+ ['he', 'they'],
783
+ ['she', 'they'],
784
+ ['them', 'them'],
785
+ ['myself', 'ourselves'],
786
+ ['yourself', 'yourselves'],
787
+ ['itself', 'themselves'],
788
+ ['herself', 'themselves'],
789
+ ['himself', 'themselves'],
790
+ ['themself', 'themselves'],
791
+ ['is', 'are'],
792
+ ['was', 'were'],
793
+ ['has', 'have'],
794
+ ['this', 'these'],
795
+ ['that', 'those'],
796
+ // Words ending in with a consonant and `o`.
797
+ ['echo', 'echoes'],
798
+ ['dingo', 'dingoes'],
799
+ ['volcano', 'volcanoes'],
800
+ ['tornado', 'tornadoes'],
801
+ ['torpedo', 'torpedoes'],
802
+ // Ends with `us`.
803
+ ['genus', 'genera'],
804
+ ['viscus', 'viscera'],
805
+ // Ends with `ma`.
806
+ ['stigma', 'stigmata'],
807
+ ['stoma', 'stomata'],
808
+ ['dogma', 'dogmata'],
809
+ ['lemma', 'lemmata'],
810
+ ['schema', 'schemata'],
811
+ ['anathema', 'anathemata'],
812
+ // Other irregular rules.
813
+ ['ox', 'oxen'],
814
+ ['axe', 'axes'],
815
+ ['die', 'dice'],
816
+ ['yes', 'yeses'],
817
+ ['foot', 'feet'],
818
+ ['eave', 'eaves'],
819
+ ['goose', 'geese'],
820
+ ['tooth', 'teeth'],
821
+ ['quiz', 'quizzes'],
822
+ ['human', 'humans'],
823
+ ['proof', 'proofs'],
824
+ ['carve', 'carves'],
825
+ ['valve', 'valves'],
826
+ ['looey', 'looies'],
827
+ ['thief', 'thieves'],
828
+ ['groove', 'grooves'],
829
+ ['pickaxe', 'pickaxes'],
830
+ ['passerby', 'passersby']
831
+ ].forEach(function (rule) {
832
+ return pluralize.addIrregularRule(rule[0], rule[1]);
833
+ });
834
+
835
+ /**
836
+ * Pluralization rules.
837
+ */
838
+ [
839
+ [/s?$/i, 's'],
840
+ [/[^\u0000-\u007F]$/i, '$0'],
841
+ [/([^aeiou]ese)$/i, '$1'],
842
+ [/(ax|test)is$/i, '$1es'],
843
+ [/(alias|[^aou]us|t[lm]as|gas|ris)$/i, '$1es'],
844
+ [/(e[mn]u)s?$/i, '$1s'],
845
+ [/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, '$1'],
846
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1i'],
847
+ [/(alumn|alg|vertebr)(?:a|ae)$/i, '$1ae'],
848
+ [/(seraph|cherub)(?:im)?$/i, '$1im'],
849
+ [/(her|at|gr)o$/i, '$1oes'],
850
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, '$1a'],
851
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, '$1a'],
852
+ [/sis$/i, 'ses'],
853
+ [/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, '$1$2ves'],
854
+ [/([^aeiouy]|qu)y$/i, '$1ies'],
855
+ [/([^ch][ieo][ln])ey$/i, '$1ies'],
856
+ [/(x|ch|ss|sh|zz)$/i, '$1es'],
857
+ [/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, '$1ices'],
858
+ [/\b((?:tit)?m|l)(?:ice|ouse)$/i, '$1ice'],
859
+ [/(pe)(?:rson|ople)$/i, '$1ople'],
860
+ [/(child)(?:ren)?$/i, '$1ren'],
861
+ [/eaux$/i, '$0'],
862
+ [/m[ae]n$/i, 'men'],
863
+ ['thou', 'you']
864
+ ].forEach(function (rule) {
865
+ return pluralize.addPluralRule(rule[0], rule[1]);
866
+ });
867
+
868
+ /**
869
+ * Singularization rules.
870
+ */
871
+ [
872
+ [/s$/i, ''],
873
+ [/(ss)$/i, '$1'],
874
+ [/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i, '$1fe'],
875
+ [/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, '$1f'],
876
+ [/ies$/i, 'y'],
877
+ [/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i, '$1ie'],
878
+ [/\b(mon|smil)ies$/i, '$1ey'],
879
+ [/\b((?:tit)?m|l)ice$/i, '$1ouse'],
880
+ [/(seraph|cherub)im$/i, '$1'],
881
+ [/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, '$1'],
882
+ [/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, '$1sis'],
883
+ [/(movie|twelve|abuse|e[mn]u)s$/i, '$1'],
884
+ [/(test)(?:is|es)$/i, '$1is'],
885
+ [/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, '$1us'],
886
+ [/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, '$1um'],
887
+ [/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, '$1on'],
888
+ [/(alumn|alg|vertebr)ae$/i, '$1a'],
889
+ [/(cod|mur|sil|vert|ind)ices$/i, '$1ex'],
890
+ [/(matr|append)ices$/i, '$1ix'],
891
+ [/(pe)(rson|ople)$/i, '$1rson'],
892
+ [/(child)ren$/i, '$1'],
893
+ [/(eau)x?$/i, '$1'],
894
+ [/men$/i, 'man']
895
+ ].forEach(function (rule) {
896
+ return pluralize.addSingularRule(rule[0], rule[1]);
897
+ });
898
+
899
+ /**
900
+ * Uncountable rules.
901
+ */
902
+ [
903
+ // Singular words with no plurals.
904
+ 'adulthood',
905
+ 'advice',
906
+ 'agenda',
907
+ 'aid',
908
+ 'aircraft',
909
+ 'alcohol',
910
+ 'ammo',
911
+ 'analytics',
912
+ 'anime',
913
+ 'athletics',
914
+ 'audio',
915
+ 'bison',
916
+ 'blood',
917
+ 'bream',
918
+ 'buffalo',
919
+ 'butter',
920
+ 'carp',
921
+ 'cash',
922
+ 'chassis',
923
+ 'chess',
924
+ 'clothing',
925
+ 'cod',
926
+ 'commerce',
927
+ 'cooperation',
928
+ 'corps',
929
+ 'debris',
930
+ 'diabetes',
931
+ 'digestion',
932
+ 'elk',
933
+ 'energy',
934
+ 'equipment',
935
+ 'excretion',
936
+ 'expertise',
937
+ 'firmware',
938
+ 'flounder',
939
+ 'fun',
940
+ 'gallows',
941
+ 'garbage',
942
+ 'graffiti',
943
+ 'hardware',
944
+ 'headquarters',
945
+ 'health',
946
+ 'herpes',
947
+ 'highjinks',
948
+ 'homework',
949
+ 'housework',
950
+ 'information',
951
+ 'jeans',
952
+ 'justice',
953
+ 'kudos',
954
+ 'labour',
955
+ 'literature',
956
+ 'machinery',
957
+ 'mackerel',
958
+ 'mail',
959
+ 'media',
960
+ 'mews',
961
+ 'moose',
962
+ 'music',
963
+ 'mud',
964
+ 'manga',
965
+ 'news',
966
+ 'only',
967
+ 'personnel',
968
+ 'pike',
969
+ 'plankton',
970
+ 'pliers',
971
+ 'police',
972
+ 'pollution',
973
+ 'premises',
974
+ 'rain',
975
+ 'research',
976
+ 'rice',
977
+ 'salmon',
978
+ 'scissors',
979
+ 'series',
980
+ 'sewage',
981
+ 'shambles',
982
+ 'shrimp',
983
+ 'software',
984
+ 'species',
985
+ 'staff',
986
+ 'swine',
987
+ 'tennis',
988
+ 'traffic',
989
+ 'transportation',
990
+ 'trout',
991
+ 'tuna',
992
+ 'wealth',
993
+ 'welfare',
994
+ 'whiting',
995
+ 'wildebeest',
996
+ 'wildlife',
997
+ 'you',
998
+ /pok[eé]mon$/i,
999
+ // Regexes.
1000
+ /[^aeiou]ese$/i, // "chinese", "japanese"
1001
+ /deer$/i, // "deer", "reindeer"
1002
+ /fish$/i, // "fish", "blowfish", "angelfish"
1003
+ /measles$/i,
1004
+ /o[iu]s$/i, // "carnivorous"
1005
+ /pox$/i, // "chickpox", "smallpox"
1006
+ /sheep$/i
1007
+ ].forEach(pluralize.addUncountableRule);
1008
+
1009
+ return pluralize;
1010
+ });
1011
+ }(pluralize$1));
1012
+
1013
+ var pluralize = pluralize$1.exports;
1014
+
1015
+ var DragHandle = {};
1016
+
1017
+ var _interopRequireDefault$1 = interopRequireDefault.exports;
1018
+
1019
+ Object.defineProperty(DragHandle, "__esModule", {
1020
+ value: true
1021
+ });
1022
+ var default_1$1 = DragHandle.default = void 0;
1023
+
1024
+ var _react$1 = _interopRequireDefault$1(React);
1025
+
1026
+ var _createSvgIcon$1 = _interopRequireDefault$1(createSvgIcon$1);
1027
+
1028
+ var _default$1 = (0, _createSvgIcon$1.default)(_react$1.default.createElement(_react$1.default.Fragment, null, _react$1.default.createElement("defs", null, _react$1.default.createElement("path", {
1029
+ id: "a",
1030
+ d: "M0 0h24v24H0V0z"
1031
+ })), _react$1.default.createElement("path", {
1032
+ d: "M20 9H4v2h16V9zM4 15h16v-2H4v2z"
1033
+ })), 'DragHandle');
1034
+
1035
+ default_1$1 = DragHandle.default = _default$1;
1036
+
1037
+ /**
1038
+ * Create the React Context
1039
+ */
1040
+
1041
+ var DndContext = createContext({
1042
+ dragDropManager: undefined
1043
+ });
1044
+
1045
+ /**
1046
+ * Use invariant() to assert state which your program assumes to be true.
1047
+ *
1048
+ * Provide sprintf-style format (only %s is supported) and arguments
1049
+ * to provide information about what broke and what you were
1050
+ * expecting.
1051
+ *
1052
+ * The invariant message will be stripped in production, but the invariant
1053
+ * will remain to ensure logic does not differ in production.
1054
+ */
1055
+ function invariant(condition, format) {
1056
+ for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
1057
+ args[_key - 2] = arguments[_key];
1058
+ }
1059
+
1060
+ if (process.env.NODE_ENV !== 'production') {
1061
+ if (format === undefined) {
1062
+ throw new Error('invariant requires an error message argument');
1063
+ }
1064
+ }
1065
+
1066
+ if (!condition) {
1067
+ var error;
1068
+
1069
+ if (format === undefined) {
1070
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
1071
+ } else {
1072
+ var argIndex = 0;
1073
+ error = new Error(format.replace(/%s/g, function () {
1074
+ return args[argIndex++];
1075
+ }));
1076
+ error.name = 'Invariant Violation';
1077
+ }
1078
+
1079
+ error.framesToPop = 1; // we don't care about invariant's own frame
1080
+
1081
+ throw error;
1082
+ }
1083
+ }
1084
+
1085
+ function _classCallCheck$7(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1086
+
1087
+ 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); } }
1088
+
1089
+ function _createClass$7(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$7(Constructor.prototype, protoProps); if (staticProps) _defineProperties$7(Constructor, staticProps); return Constructor; }
1090
+
1091
+ 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; }
1092
+ var isCallingCanDrag = false;
1093
+ var isCallingIsDragging = false;
1094
+ var DragSourceMonitorImpl = /*#__PURE__*/function () {
1095
+ function DragSourceMonitorImpl(manager) {
1096
+ _classCallCheck$7(this, DragSourceMonitorImpl);
1097
+
1098
+ _defineProperty$7(this, "internalMonitor", void 0);
1099
+
1100
+ _defineProperty$7(this, "sourceId", null);
1101
+
1102
+ this.internalMonitor = manager.getMonitor();
1103
+ }
1104
+
1105
+ _createClass$7(DragSourceMonitorImpl, [{
1106
+ key: "receiveHandlerId",
1107
+ value: function receiveHandlerId(sourceId) {
1108
+ this.sourceId = sourceId;
1109
+ }
1110
+ }, {
1111
+ key: "getHandlerId",
1112
+ value: function getHandlerId() {
1113
+ return this.sourceId;
1114
+ }
1115
+ }, {
1116
+ key: "canDrag",
1117
+ value: function canDrag() {
1118
+ 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');
1119
+
1120
+ try {
1121
+ isCallingCanDrag = true;
1122
+ return this.internalMonitor.canDragSource(this.sourceId);
1123
+ } finally {
1124
+ isCallingCanDrag = false;
1125
+ }
1126
+ }
1127
+ }, {
1128
+ key: "isDragging",
1129
+ value: function isDragging() {
1130
+ if (!this.sourceId) {
1131
+ return false;
1132
+ }
1133
+
1134
+ 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');
1135
+
1136
+ try {
1137
+ isCallingIsDragging = true;
1138
+ return this.internalMonitor.isDraggingSource(this.sourceId);
1139
+ } finally {
1140
+ isCallingIsDragging = false;
1141
+ }
1142
+ }
1143
+ }, {
1144
+ key: "subscribeToStateChange",
1145
+ value: function subscribeToStateChange(listener, options) {
1146
+ return this.internalMonitor.subscribeToStateChange(listener, options);
1147
+ }
1148
+ }, {
1149
+ key: "isDraggingSource",
1150
+ value: function isDraggingSource(sourceId) {
1151
+ return this.internalMonitor.isDraggingSource(sourceId);
1152
+ }
1153
+ }, {
1154
+ key: "isOverTarget",
1155
+ value: function isOverTarget(targetId, options) {
1156
+ return this.internalMonitor.isOverTarget(targetId, options);
1157
+ }
1158
+ }, {
1159
+ key: "getTargetIds",
1160
+ value: function getTargetIds() {
1161
+ return this.internalMonitor.getTargetIds();
1162
+ }
1163
+ }, {
1164
+ key: "isSourcePublic",
1165
+ value: function isSourcePublic() {
1166
+ return this.internalMonitor.isSourcePublic();
1167
+ }
1168
+ }, {
1169
+ key: "getSourceId",
1170
+ value: function getSourceId() {
1171
+ return this.internalMonitor.getSourceId();
1172
+ }
1173
+ }, {
1174
+ key: "subscribeToOffsetChange",
1175
+ value: function subscribeToOffsetChange(listener) {
1176
+ return this.internalMonitor.subscribeToOffsetChange(listener);
1177
+ }
1178
+ }, {
1179
+ key: "canDragSource",
1180
+ value: function canDragSource(sourceId) {
1181
+ return this.internalMonitor.canDragSource(sourceId);
1182
+ }
1183
+ }, {
1184
+ key: "canDropOnTarget",
1185
+ value: function canDropOnTarget(targetId) {
1186
+ return this.internalMonitor.canDropOnTarget(targetId);
1187
+ }
1188
+ }, {
1189
+ key: "getItemType",
1190
+ value: function getItemType() {
1191
+ return this.internalMonitor.getItemType();
1192
+ }
1193
+ }, {
1194
+ key: "getItem",
1195
+ value: function getItem() {
1196
+ return this.internalMonitor.getItem();
1197
+ }
1198
+ }, {
1199
+ key: "getDropResult",
1200
+ value: function getDropResult() {
1201
+ return this.internalMonitor.getDropResult();
1202
+ }
1203
+ }, {
1204
+ key: "didDrop",
1205
+ value: function didDrop() {
1206
+ return this.internalMonitor.didDrop();
1207
+ }
1208
+ }, {
1209
+ key: "getInitialClientOffset",
1210
+ value: function getInitialClientOffset() {
1211
+ return this.internalMonitor.getInitialClientOffset();
1212
+ }
1213
+ }, {
1214
+ key: "getInitialSourceClientOffset",
1215
+ value: function getInitialSourceClientOffset() {
1216
+ return this.internalMonitor.getInitialSourceClientOffset();
1217
+ }
1218
+ }, {
1219
+ key: "getSourceClientOffset",
1220
+ value: function getSourceClientOffset() {
1221
+ return this.internalMonitor.getSourceClientOffset();
1222
+ }
1223
+ }, {
1224
+ key: "getClientOffset",
1225
+ value: function getClientOffset() {
1226
+ return this.internalMonitor.getClientOffset();
1227
+ }
1228
+ }, {
1229
+ key: "getDifferenceFromInitialOffset",
1230
+ value: function getDifferenceFromInitialOffset() {
1231
+ return this.internalMonitor.getDifferenceFromInitialOffset();
1232
+ }
1233
+ }]);
1234
+
1235
+ return DragSourceMonitorImpl;
1236
+ }();
1237
+
1238
+ function _classCallCheck$6(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1239
+
1240
+ 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); } }
1241
+
1242
+ function _createClass$6(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$6(Constructor.prototype, protoProps); if (staticProps) _defineProperties$6(Constructor, staticProps); return Constructor; }
1243
+
1244
+ 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; }
1245
+ var isCallingCanDrop = false;
1246
+ var DropTargetMonitorImpl = /*#__PURE__*/function () {
1247
+ function DropTargetMonitorImpl(manager) {
1248
+ _classCallCheck$6(this, DropTargetMonitorImpl);
1249
+
1250
+ _defineProperty$6(this, "internalMonitor", void 0);
1251
+
1252
+ _defineProperty$6(this, "targetId", null);
1253
+
1254
+ this.internalMonitor = manager.getMonitor();
1255
+ }
1256
+
1257
+ _createClass$6(DropTargetMonitorImpl, [{
1258
+ key: "receiveHandlerId",
1259
+ value: function receiveHandlerId(targetId) {
1260
+ this.targetId = targetId;
1261
+ }
1262
+ }, {
1263
+ key: "getHandlerId",
1264
+ value: function getHandlerId() {
1265
+ return this.targetId;
1266
+ }
1267
+ }, {
1268
+ key: "subscribeToStateChange",
1269
+ value: function subscribeToStateChange(listener, options) {
1270
+ return this.internalMonitor.subscribeToStateChange(listener, options);
1271
+ }
1272
+ }, {
1273
+ key: "canDrop",
1274
+ value: function canDrop() {
1275
+ // Cut out early if the target id has not been set. This should prevent errors
1276
+ // where the user has an older version of dnd-core like in
1277
+ // https://github.com/react-dnd/react-dnd/issues/1310
1278
+ if (!this.targetId) {
1279
+ return false;
1280
+ }
1281
+
1282
+ 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');
1283
+
1284
+ try {
1285
+ isCallingCanDrop = true;
1286
+ return this.internalMonitor.canDropOnTarget(this.targetId);
1287
+ } finally {
1288
+ isCallingCanDrop = false;
1289
+ }
1290
+ }
1291
+ }, {
1292
+ key: "isOver",
1293
+ value: function isOver(options) {
1294
+ if (!this.targetId) {
1295
+ return false;
1296
+ }
1297
+
1298
+ return this.internalMonitor.isOverTarget(this.targetId, options);
1299
+ }
1300
+ }, {
1301
+ key: "getItemType",
1302
+ value: function getItemType() {
1303
+ return this.internalMonitor.getItemType();
1304
+ }
1305
+ }, {
1306
+ key: "getItem",
1307
+ value: function getItem() {
1308
+ return this.internalMonitor.getItem();
1309
+ }
1310
+ }, {
1311
+ key: "getDropResult",
1312
+ value: function getDropResult() {
1313
+ return this.internalMonitor.getDropResult();
1314
+ }
1315
+ }, {
1316
+ key: "didDrop",
1317
+ value: function didDrop() {
1318
+ return this.internalMonitor.didDrop();
1319
+ }
1320
+ }, {
1321
+ key: "getInitialClientOffset",
1322
+ value: function getInitialClientOffset() {
1323
+ return this.internalMonitor.getInitialClientOffset();
1324
+ }
1325
+ }, {
1326
+ key: "getInitialSourceClientOffset",
1327
+ value: function getInitialSourceClientOffset() {
1328
+ return this.internalMonitor.getInitialSourceClientOffset();
1329
+ }
1330
+ }, {
1331
+ key: "getSourceClientOffset",
1332
+ value: function getSourceClientOffset() {
1333
+ return this.internalMonitor.getSourceClientOffset();
1334
+ }
1335
+ }, {
1336
+ key: "getClientOffset",
1337
+ value: function getClientOffset() {
1338
+ return this.internalMonitor.getClientOffset();
1339
+ }
1340
+ }, {
1341
+ key: "getDifferenceFromInitialOffset",
1342
+ value: function getDifferenceFromInitialOffset() {
1343
+ return this.internalMonitor.getDifferenceFromInitialOffset();
1344
+ }
1345
+ }]);
1346
+
1347
+ return DropTargetMonitorImpl;
1348
+ }();
1349
+
1350
+ function throwIfCompositeComponentElement(element) {
1351
+ // Custom components can no longer be wrapped directly in React DnD 2.0
1352
+ // so that we don't need to depend on findDOMNode() from react-dom.
1353
+ if (typeof element.type === 'string') {
1354
+ return;
1355
+ }
1356
+
1357
+ var displayName = element.type.displayName || element.type.name || 'the component';
1358
+ 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.');
1359
+ }
1360
+
1361
+ function wrapHookToRecognizeElement(hook) {
1362
+ return function () {
1363
+ var elementOrNode = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1364
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1365
+
1366
+ // When passed a node, call the hook straight away.
1367
+ if (!isValidElement(elementOrNode)) {
1368
+ var node = elementOrNode;
1369
+ hook(node, options); // return the node so it can be chained (e.g. when within callback refs
1370
+ // <div ref={node => connectDragSource(connectDropTarget(node))}/>
1371
+
1372
+ return node;
1373
+ } // If passed a ReactElement, clone it and attach this function as a ref.
1374
+ // This helps us achieve a neat API where user doesn't even know that refs
1375
+ // are being used under the hood.
1376
+
1377
+
1378
+ var element = elementOrNode;
1379
+ throwIfCompositeComponentElement(element); // When no options are passed, use the hook directly
1380
+
1381
+ var ref = options ? function (node) {
1382
+ return hook(node, options);
1383
+ } : hook;
1384
+ return cloneWithRef(element, ref);
1385
+ };
1386
+ }
1387
+
1388
+ function wrapConnectorHooks(hooks) {
1389
+ var wrappedHooks = {};
1390
+ Object.keys(hooks).forEach(function (key) {
1391
+ var hook = hooks[key]; // ref objects should be passed straight through without wrapping
1392
+
1393
+ if (key.endsWith('Ref')) {
1394
+ wrappedHooks[key] = hooks[key];
1395
+ } else {
1396
+ var wrappedHook = wrapHookToRecognizeElement(hook);
1397
+
1398
+ wrappedHooks[key] = function () {
1399
+ return wrappedHook;
1400
+ };
1401
+ }
1402
+ });
1403
+ return wrappedHooks;
1404
+ }
1405
+
1406
+ function setRef(ref, node) {
1407
+ if (typeof ref === 'function') {
1408
+ ref(node);
1409
+ } else {
1410
+ ref.current = node;
1411
+ }
1412
+ }
1413
+
1414
+ function cloneWithRef(element, newRef) {
1415
+ var previousRef = element.ref;
1416
+ 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');
1417
+
1418
+ if (!previousRef) {
1419
+ // When there is no ref on the element, use the new ref directly
1420
+ return cloneElement(element, {
1421
+ ref: newRef
1422
+ });
1423
+ } else {
1424
+ return cloneElement(element, {
1425
+ ref: function ref(node) {
1426
+ setRef(previousRef, node);
1427
+ setRef(newRef, node);
1428
+ }
1429
+ });
1430
+ }
1431
+ }
1432
+
1433
+ 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); }
1434
+
1435
+ function isRef(obj) {
1436
+ return (// eslint-disable-next-line no-prototype-builtins
1437
+ obj !== null && _typeof$2(obj) === 'object' && Object.prototype.hasOwnProperty.call(obj, 'current')
1438
+ );
1439
+ }
1440
+
1441
+ function shallowEqual(objA, objB, compare, compareContext) {
1442
+ var compareResult = compare ? compare.call(compareContext, objA, objB) : void 0;
1443
+
1444
+ if (compareResult !== void 0) {
1445
+ return !!compareResult;
1446
+ }
1447
+
1448
+ if (objA === objB) {
1449
+ return true;
1450
+ }
1451
+
1452
+ if (typeof objA !== 'object' || !objA || typeof objB !== 'object' || !objB) {
1453
+ return false;
1454
+ }
1455
+
1456
+ var keysA = Object.keys(objA);
1457
+ var keysB = Object.keys(objB);
1458
+
1459
+ if (keysA.length !== keysB.length) {
1460
+ return false;
1461
+ }
1462
+
1463
+ var bHasOwnProperty = Object.prototype.hasOwnProperty.bind(objB); // Test for A's keys different from B.
1464
+
1465
+ for (var idx = 0; idx < keysA.length; idx++) {
1466
+ var key = keysA[idx];
1467
+
1468
+ if (!bHasOwnProperty(key)) {
1469
+ return false;
1470
+ }
1471
+
1472
+ var valueA = objA[key];
1473
+ var valueB = objB[key];
1474
+ compareResult = compare ? compare.call(compareContext, valueA, valueB, key) : void 0;
1475
+
1476
+ if (compareResult === false || compareResult === void 0 && valueA !== valueB) {
1477
+ return false;
1478
+ }
1479
+ }
1480
+
1481
+ return true;
1482
+ }
1483
+
1484
+ function _classCallCheck$5(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1485
+
1486
+ 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); } }
1487
+
1488
+ function _createClass$5(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$5(Constructor.prototype, protoProps); if (staticProps) _defineProperties$5(Constructor, staticProps); return Constructor; }
1489
+
1490
+ 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; }
1491
+ var SourceConnector = /*#__PURE__*/function () {
1492
+ // The drop target may either be attached via ref or connect function
1493
+ // The drag preview may either be attached via ref or connect function
1494
+ function SourceConnector(backend) {
1495
+ var _this = this;
1496
+
1497
+ _classCallCheck$5(this, SourceConnector);
1498
+
1499
+ _defineProperty$5(this, "hooks", wrapConnectorHooks({
1500
+ dragSource: function dragSource(node, options) {
1501
+ _this.clearDragSource();
1502
+
1503
+ _this.dragSourceOptions = options || null;
1504
+
1505
+ if (isRef(node)) {
1506
+ _this.dragSourceRef = node;
1507
+ } else {
1508
+ _this.dragSourceNode = node;
1509
+ }
1510
+
1511
+ _this.reconnectDragSource();
1512
+ },
1513
+ dragPreview: function dragPreview(node, options) {
1514
+ _this.clearDragPreview();
1515
+
1516
+ _this.dragPreviewOptions = options || null;
1517
+
1518
+ if (isRef(node)) {
1519
+ _this.dragPreviewRef = node;
1520
+ } else {
1521
+ _this.dragPreviewNode = node;
1522
+ }
1523
+
1524
+ _this.reconnectDragPreview();
1525
+ }
1526
+ }));
1527
+
1528
+ _defineProperty$5(this, "handlerId", null);
1529
+
1530
+ _defineProperty$5(this, "dragSourceRef", null);
1531
+
1532
+ _defineProperty$5(this, "dragSourceNode", void 0);
1533
+
1534
+ _defineProperty$5(this, "dragSourceOptionsInternal", null);
1535
+
1536
+ _defineProperty$5(this, "dragSourceUnsubscribe", void 0);
1537
+
1538
+ _defineProperty$5(this, "dragPreviewRef", null);
1539
+
1540
+ _defineProperty$5(this, "dragPreviewNode", void 0);
1541
+
1542
+ _defineProperty$5(this, "dragPreviewOptionsInternal", null);
1543
+
1544
+ _defineProperty$5(this, "dragPreviewUnsubscribe", void 0);
1545
+
1546
+ _defineProperty$5(this, "lastConnectedHandlerId", null);
1547
+
1548
+ _defineProperty$5(this, "lastConnectedDragSource", null);
1549
+
1550
+ _defineProperty$5(this, "lastConnectedDragSourceOptions", null);
1551
+
1552
+ _defineProperty$5(this, "lastConnectedDragPreview", null);
1553
+
1554
+ _defineProperty$5(this, "lastConnectedDragPreviewOptions", null);
1555
+
1556
+ _defineProperty$5(this, "backend", void 0);
1557
+
1558
+ this.backend = backend;
1559
+ }
1560
+
1561
+ _createClass$5(SourceConnector, [{
1562
+ key: "receiveHandlerId",
1563
+ value: function receiveHandlerId(newHandlerId) {
1564
+ if (this.handlerId === newHandlerId) {
1565
+ return;
1566
+ }
1567
+
1568
+ this.handlerId = newHandlerId;
1569
+ this.reconnect();
1570
+ }
1571
+ }, {
1572
+ key: "connectTarget",
1573
+ get: function get() {
1574
+ return this.dragSource;
1575
+ }
1576
+ }, {
1577
+ key: "dragSourceOptions",
1578
+ get: function get() {
1579
+ return this.dragSourceOptionsInternal;
1580
+ },
1581
+ set: function set(options) {
1582
+ this.dragSourceOptionsInternal = options;
1583
+ }
1584
+ }, {
1585
+ key: "dragPreviewOptions",
1586
+ get: function get() {
1587
+ return this.dragPreviewOptionsInternal;
1588
+ },
1589
+ set: function set(options) {
1590
+ this.dragPreviewOptionsInternal = options;
1591
+ }
1592
+ }, {
1593
+ key: "reconnect",
1594
+ value: function reconnect() {
1595
+ this.reconnectDragSource();
1596
+ this.reconnectDragPreview();
1597
+ }
1598
+ }, {
1599
+ key: "reconnectDragSource",
1600
+ value: function reconnectDragSource() {
1601
+ var dragSource = this.dragSource; // if nothing has changed then don't resubscribe
1602
+
1603
+ var didChange = this.didHandlerIdChange() || this.didConnectedDragSourceChange() || this.didDragSourceOptionsChange();
1604
+
1605
+ if (didChange) {
1606
+ this.disconnectDragSource();
1607
+ }
1608
+
1609
+ if (!this.handlerId) {
1610
+ return;
1611
+ }
1612
+
1613
+ if (!dragSource) {
1614
+ this.lastConnectedDragSource = dragSource;
1615
+ return;
1616
+ }
1617
+
1618
+ if (didChange) {
1619
+ this.lastConnectedHandlerId = this.handlerId;
1620
+ this.lastConnectedDragSource = dragSource;
1621
+ this.lastConnectedDragSourceOptions = this.dragSourceOptions;
1622
+ this.dragSourceUnsubscribe = this.backend.connectDragSource(this.handlerId, dragSource, this.dragSourceOptions);
1623
+ }
1624
+ }
1625
+ }, {
1626
+ key: "reconnectDragPreview",
1627
+ value: function reconnectDragPreview() {
1628
+ var dragPreview = this.dragPreview; // if nothing has changed then don't resubscribe
1629
+
1630
+ var didChange = this.didHandlerIdChange() || this.didConnectedDragPreviewChange() || this.didDragPreviewOptionsChange();
1631
+
1632
+ if (didChange) {
1633
+ this.disconnectDragPreview();
1634
+ }
1635
+
1636
+ if (!this.handlerId) {
1637
+ return;
1638
+ }
1639
+
1640
+ if (!dragPreview) {
1641
+ this.lastConnectedDragPreview = dragPreview;
1642
+ return;
1643
+ }
1644
+
1645
+ if (didChange) {
1646
+ this.lastConnectedHandlerId = this.handlerId;
1647
+ this.lastConnectedDragPreview = dragPreview;
1648
+ this.lastConnectedDragPreviewOptions = this.dragPreviewOptions;
1649
+ this.dragPreviewUnsubscribe = this.backend.connectDragPreview(this.handlerId, dragPreview, this.dragPreviewOptions);
1650
+ }
1651
+ }
1652
+ }, {
1653
+ key: "didHandlerIdChange",
1654
+ value: function didHandlerIdChange() {
1655
+ return this.lastConnectedHandlerId !== this.handlerId;
1656
+ }
1657
+ }, {
1658
+ key: "didConnectedDragSourceChange",
1659
+ value: function didConnectedDragSourceChange() {
1660
+ return this.lastConnectedDragSource !== this.dragSource;
1661
+ }
1662
+ }, {
1663
+ key: "didConnectedDragPreviewChange",
1664
+ value: function didConnectedDragPreviewChange() {
1665
+ return this.lastConnectedDragPreview !== this.dragPreview;
1666
+ }
1667
+ }, {
1668
+ key: "didDragSourceOptionsChange",
1669
+ value: function didDragSourceOptionsChange() {
1670
+ return !shallowEqual(this.lastConnectedDragSourceOptions, this.dragSourceOptions);
1671
+ }
1672
+ }, {
1673
+ key: "didDragPreviewOptionsChange",
1674
+ value: function didDragPreviewOptionsChange() {
1675
+ return !shallowEqual(this.lastConnectedDragPreviewOptions, this.dragPreviewOptions);
1676
+ }
1677
+ }, {
1678
+ key: "disconnectDragSource",
1679
+ value: function disconnectDragSource() {
1680
+ if (this.dragSourceUnsubscribe) {
1681
+ this.dragSourceUnsubscribe();
1682
+ this.dragSourceUnsubscribe = undefined;
1683
+ }
1684
+ }
1685
+ }, {
1686
+ key: "disconnectDragPreview",
1687
+ value: function disconnectDragPreview() {
1688
+ if (this.dragPreviewUnsubscribe) {
1689
+ this.dragPreviewUnsubscribe();
1690
+ this.dragPreviewUnsubscribe = undefined;
1691
+ this.dragPreviewNode = null;
1692
+ this.dragPreviewRef = null;
1693
+ }
1694
+ }
1695
+ }, {
1696
+ key: "dragSource",
1697
+ get: function get() {
1698
+ return this.dragSourceNode || this.dragSourceRef && this.dragSourceRef.current;
1699
+ }
1700
+ }, {
1701
+ key: "dragPreview",
1702
+ get: function get() {
1703
+ return this.dragPreviewNode || this.dragPreviewRef && this.dragPreviewRef.current;
1704
+ }
1705
+ }, {
1706
+ key: "clearDragSource",
1707
+ value: function clearDragSource() {
1708
+ this.dragSourceNode = null;
1709
+ this.dragSourceRef = null;
1710
+ }
1711
+ }, {
1712
+ key: "clearDragPreview",
1713
+ value: function clearDragPreview() {
1714
+ this.dragPreviewNode = null;
1715
+ this.dragPreviewRef = null;
1716
+ }
1717
+ }]);
1718
+
1719
+ return SourceConnector;
1720
+ }();
1721
+
1722
+ function _classCallCheck$4(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1723
+
1724
+ 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); } }
1725
+
1726
+ function _createClass$4(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$4(Constructor.prototype, protoProps); if (staticProps) _defineProperties$4(Constructor, staticProps); return Constructor; }
1727
+
1728
+ 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; }
1729
+ var TargetConnector = /*#__PURE__*/function () {
1730
+ // The drop target may either be attached via ref or connect function
1731
+ function TargetConnector(backend) {
1732
+ var _this = this;
1733
+
1734
+ _classCallCheck$4(this, TargetConnector);
1735
+
1736
+ _defineProperty$4(this, "hooks", wrapConnectorHooks({
1737
+ dropTarget: function dropTarget(node, options) {
1738
+ _this.clearDropTarget();
1739
+
1740
+ _this.dropTargetOptions = options;
1741
+
1742
+ if (isRef(node)) {
1743
+ _this.dropTargetRef = node;
1744
+ } else {
1745
+ _this.dropTargetNode = node;
1746
+ }
1747
+
1748
+ _this.reconnect();
1749
+ }
1750
+ }));
1751
+
1752
+ _defineProperty$4(this, "handlerId", null);
1753
+
1754
+ _defineProperty$4(this, "dropTargetRef", null);
1755
+
1756
+ _defineProperty$4(this, "dropTargetNode", void 0);
1757
+
1758
+ _defineProperty$4(this, "dropTargetOptionsInternal", null);
1759
+
1760
+ _defineProperty$4(this, "unsubscribeDropTarget", void 0);
1761
+
1762
+ _defineProperty$4(this, "lastConnectedHandlerId", null);
1763
+
1764
+ _defineProperty$4(this, "lastConnectedDropTarget", null);
1765
+
1766
+ _defineProperty$4(this, "lastConnectedDropTargetOptions", null);
1767
+
1768
+ _defineProperty$4(this, "backend", void 0);
1769
+
1770
+ this.backend = backend;
1771
+ }
1772
+
1773
+ _createClass$4(TargetConnector, [{
1774
+ key: "connectTarget",
1775
+ get: function get() {
1776
+ return this.dropTarget;
1777
+ }
1778
+ }, {
1779
+ key: "reconnect",
1780
+ value: function reconnect() {
1781
+ // if nothing has changed then don't resubscribe
1782
+ var didChange = this.didHandlerIdChange() || this.didDropTargetChange() || this.didOptionsChange();
1783
+
1784
+ if (didChange) {
1785
+ this.disconnectDropTarget();
1786
+ }
1787
+
1788
+ var dropTarget = this.dropTarget;
1789
+
1790
+ if (!this.handlerId) {
1791
+ return;
1792
+ }
1793
+
1794
+ if (!dropTarget) {
1795
+ this.lastConnectedDropTarget = dropTarget;
1796
+ return;
1797
+ }
1798
+
1799
+ if (didChange) {
1800
+ this.lastConnectedHandlerId = this.handlerId;
1801
+ this.lastConnectedDropTarget = dropTarget;
1802
+ this.lastConnectedDropTargetOptions = this.dropTargetOptions;
1803
+ this.unsubscribeDropTarget = this.backend.connectDropTarget(this.handlerId, dropTarget, this.dropTargetOptions);
1804
+ }
1805
+ }
1806
+ }, {
1807
+ key: "receiveHandlerId",
1808
+ value: function receiveHandlerId(newHandlerId) {
1809
+ if (newHandlerId === this.handlerId) {
1810
+ return;
1811
+ }
1812
+
1813
+ this.handlerId = newHandlerId;
1814
+ this.reconnect();
1815
+ }
1816
+ }, {
1817
+ key: "dropTargetOptions",
1818
+ get: function get() {
1819
+ return this.dropTargetOptionsInternal;
1820
+ },
1821
+ set: function set(options) {
1822
+ this.dropTargetOptionsInternal = options;
1823
+ }
1824
+ }, {
1825
+ key: "didHandlerIdChange",
1826
+ value: function didHandlerIdChange() {
1827
+ return this.lastConnectedHandlerId !== this.handlerId;
1828
+ }
1829
+ }, {
1830
+ key: "didDropTargetChange",
1831
+ value: function didDropTargetChange() {
1832
+ return this.lastConnectedDropTarget !== this.dropTarget;
1833
+ }
1834
+ }, {
1835
+ key: "didOptionsChange",
1836
+ value: function didOptionsChange() {
1837
+ return !shallowEqual(this.lastConnectedDropTargetOptions, this.dropTargetOptions);
1838
+ }
1839
+ }, {
1840
+ key: "disconnectDropTarget",
1841
+ value: function disconnectDropTarget() {
1842
+ if (this.unsubscribeDropTarget) {
1843
+ this.unsubscribeDropTarget();
1844
+ this.unsubscribeDropTarget = undefined;
1845
+ }
1846
+ }
1847
+ }, {
1848
+ key: "dropTarget",
1849
+ get: function get() {
1850
+ return this.dropTargetNode || this.dropTargetRef && this.dropTargetRef.current;
1851
+ }
1852
+ }, {
1853
+ key: "clearDropTarget",
1854
+ value: function clearDropTarget() {
1855
+ this.dropTargetRef = null;
1856
+ this.dropTargetNode = null;
1857
+ }
1858
+ }]);
1859
+
1860
+ return TargetConnector;
1861
+ }();
1862
+
1863
+ function registerTarget(type, target, manager) {
1864
+ var registry = manager.getRegistry();
1865
+ var targetId = registry.addTarget(type, target);
1866
+ return [targetId, function () {
1867
+ return registry.removeTarget(targetId);
1868
+ }];
1869
+ }
1870
+ function registerSource(type, source, manager) {
1871
+ var registry = manager.getRegistry();
1872
+ var sourceId = registry.addSource(type, source);
1873
+ return [sourceId, function () {
1874
+ return registry.removeSource(sourceId);
1875
+ }];
1876
+ }
1877
+
1878
+ 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); }
1879
+
1880
+ function getDecoratedComponent(instanceRef) {
1881
+ var currentRef = instanceRef.current;
1882
+
1883
+ if (currentRef == null) {
1884
+ return null;
1885
+ } else if (currentRef.decoratedRef) {
1886
+ // go through the private field in decorateHandler to avoid the invariant hit
1887
+ return currentRef.decoratedRef.current;
1888
+ } else {
1889
+ return currentRef;
1890
+ }
1891
+ }
1892
+ function isClassComponent(Component) {
1893
+ return Component && Component.prototype && typeof Component.prototype.render === 'function';
1894
+ }
1895
+ function isRefForwardingComponent(C) {
1896
+ var _item$$$typeof;
1897
+
1898
+ var item = C;
1899
+ 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)';
1900
+ }
1901
+ function isRefable(C) {
1902
+ return isClassComponent(C) || isRefForwardingComponent(C);
1903
+ }
1904
+ function checkDecoratorArguments(functionName, signature) {
1905
+ if (process.env.NODE_ENV !== 'production') {
1906
+ for (var i = 0; i < (arguments.length <= 2 ? 0 : arguments.length - 2); i++) {
1907
+ var arg = i + 2 < 2 || arguments.length <= i + 2 ? undefined : arguments[i + 2];
1908
+
1909
+ if (arg && arg.prototype && arg.prototype.render) {
1910
+ // eslint-disable-next-line no-console
1911
+ 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');
1912
+ return;
1913
+ }
1914
+ }
1915
+ }
1916
+ }
1917
+ function isFunction(input) {
1918
+ return typeof input === 'function';
1919
+ }
1920
+ function noop() {// noop
1921
+ }
1922
+
1923
+ function isObjectLike(input) {
1924
+ return _typeof$1(input) === 'object' && input !== null;
1925
+ }
1926
+
1927
+ function isPlainObject(input) {
1928
+ if (!isObjectLike(input)) {
1929
+ return false;
1930
+ }
1931
+
1932
+ if (Object.getPrototypeOf(input) === null) {
1933
+ return true;
1934
+ }
1935
+
1936
+ var proto = input;
1937
+
1938
+ while (Object.getPrototypeOf(proto) !== null) {
1939
+ proto = Object.getPrototypeOf(proto);
1940
+ }
1941
+
1942
+ return Object.getPrototypeOf(input) === proto;
1943
+ }
1944
+ function isValidType(type, allowArray) {
1945
+ return typeof type === 'string' || _typeof$1(type) === 'symbol' || !!allowArray && Array.isArray(type) && type.every(function (t) {
1946
+ return isValidType(t, false);
1947
+ });
1948
+ }
1949
+
1950
+ function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
1951
+
1952
+ 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); } }
1953
+
1954
+ function _createClass$3(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$3(Constructor.prototype, protoProps); if (staticProps) _defineProperties$3(Constructor, staticProps); return Constructor; }
1955
+
1956
+ 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; }
1957
+ /**
1958
+ * Provides a set of static methods for creating Disposables.
1959
+ * @param {Function} action Action to run during the first call to dispose.
1960
+ * The action is guaranteed to be run at most once.
1961
+ */
1962
+
1963
+ var Disposable = /*#__PURE__*/function () {
1964
+ function Disposable(action) {
1965
+ _classCallCheck$3(this, Disposable);
1966
+
1967
+ _defineProperty$3(this, "isDisposed", false);
1968
+
1969
+ _defineProperty$3(this, "action", void 0);
1970
+
1971
+ this.action = isFunction(action) ? action : noop;
1972
+ }
1973
+ /** Performs the task of cleaning up resources. */
1974
+
1975
+
1976
+ _createClass$3(Disposable, [{
1977
+ key: "dispose",
1978
+ value: function dispose() {
1979
+ if (!this.isDisposed) {
1980
+ this.action();
1981
+ this.isDisposed = true;
1982
+ }
1983
+ }
1984
+ }], [{
1985
+ key: "isDisposable",
1986
+ value:
1987
+ /**
1988
+ * Gets the disposable that does nothing when disposed.
1989
+ */
1990
+
1991
+ /**
1992
+ * Validates whether the given object is a disposable
1993
+ * @param {Object} Object to test whether it has a dispose method
1994
+ * @returns {Boolean} true if a disposable object, else false.
1995
+ */
1996
+ function isDisposable(d) {
1997
+ return Boolean(d && isFunction(d.dispose));
1998
+ }
1999
+ }, {
2000
+ key: "_fixup",
2001
+ value: function _fixup(result) {
2002
+ return Disposable.isDisposable(result) ? result : Disposable.empty;
2003
+ }
2004
+ /**
2005
+ * Creates a disposable object that invokes the specified action when disposed.
2006
+ * @param {Function} dispose Action to run during the first call to dispose.
2007
+ * The action is guaranteed to be run at most once.
2008
+ * @return {Disposable} The disposable object that runs the given action upon disposal.
2009
+ */
2010
+
2011
+ }, {
2012
+ key: "create",
2013
+ value: function create(action) {
2014
+ return new Disposable(action);
2015
+ }
2016
+ }]);
2017
+
2018
+ return Disposable;
2019
+ }();
2020
+ /**
2021
+ * Represents a group of disposable resources that are disposed together.
2022
+ * @constructor
2023
+ */
2024
+
2025
+ _defineProperty$3(Disposable, "empty", {
2026
+ dispose: noop
2027
+ });
2028
+
2029
+ var CompositeDisposable = /*#__PURE__*/function () {
2030
+ function CompositeDisposable() {
2031
+ _classCallCheck$3(this, CompositeDisposable);
2032
+
2033
+ _defineProperty$3(this, "isDisposed", false);
2034
+
2035
+ _defineProperty$3(this, "disposables", void 0);
2036
+
2037
+ for (var _len = arguments.length, disposables = new Array(_len), _key = 0; _key < _len; _key++) {
2038
+ disposables[_key] = arguments[_key];
2039
+ }
2040
+
2041
+ this.disposables = disposables;
2042
+ }
2043
+ /**
2044
+ * Adds a disposable to the CompositeDisposable or disposes the disposable if the CompositeDisposable is disposed.
2045
+ * @param {Any} item Disposable to add.
2046
+ */
2047
+
2048
+
2049
+ _createClass$3(CompositeDisposable, [{
2050
+ key: "add",
2051
+ value: function add(item) {
2052
+ if (this.isDisposed) {
2053
+ item.dispose();
2054
+ } else {
2055
+ this.disposables.push(item);
2056
+ }
2057
+ }
2058
+ /**
2059
+ * Removes and disposes the first occurrence of a disposable from the CompositeDisposable.
2060
+ * @param {Any} item Disposable to remove.
2061
+ * @returns {Boolean} true if found; false otherwise.
2062
+ */
2063
+
2064
+ }, {
2065
+ key: "remove",
2066
+ value: function remove(item) {
2067
+ var shouldDispose = false;
2068
+
2069
+ if (!this.isDisposed) {
2070
+ var idx = this.disposables.indexOf(item);
2071
+
2072
+ if (idx !== -1) {
2073
+ shouldDispose = true;
2074
+ this.disposables.splice(idx, 1);
2075
+ item.dispose();
2076
+ }
2077
+ }
2078
+
2079
+ return shouldDispose;
2080
+ }
2081
+ /**
2082
+ * Disposes all disposables in the group and removes them from the group but
2083
+ * does not dispose the CompositeDisposable.
2084
+ */
2085
+
2086
+ }, {
2087
+ key: "clear",
2088
+ value: function clear() {
2089
+ if (!this.isDisposed) {
2090
+ var len = this.disposables.length;
2091
+ var currentDisposables = new Array(len);
2092
+
2093
+ for (var i = 0; i < len; i++) {
2094
+ currentDisposables[i] = this.disposables[i];
2095
+ }
2096
+
2097
+ this.disposables = [];
2098
+
2099
+ for (var _i = 0; _i < len; _i++) {
2100
+ currentDisposables[_i].dispose();
2101
+ }
2102
+ }
2103
+ }
2104
+ /**
2105
+ * Disposes all disposables in the group and removes them from the group.
2106
+ */
2107
+
2108
+ }, {
2109
+ key: "dispose",
2110
+ value: function dispose() {
2111
+ if (!this.isDisposed) {
2112
+ this.isDisposed = true;
2113
+ var len = this.disposables.length;
2114
+ var currentDisposables = new Array(len);
2115
+
2116
+ for (var i = 0; i < len; i++) {
2117
+ currentDisposables[i] = this.disposables[i];
2118
+ }
2119
+
2120
+ this.disposables = [];
2121
+
2122
+ for (var _i2 = 0; _i2 < len; _i2++) {
2123
+ currentDisposables[_i2].dispose();
2124
+ }
2125
+ }
2126
+ }
2127
+ }]);
2128
+
2129
+ return CompositeDisposable;
2130
+ }();
2131
+ /**
2132
+ * Represents a disposable resource whose underlying disposable resource can
2133
+ * be replaced by another disposable resource, causing automatic disposal of
2134
+ * the previous underlying disposable resource.
2135
+ */
2136
+
2137
+ var SerialDisposable = /*#__PURE__*/function () {
2138
+ function SerialDisposable() {
2139
+ _classCallCheck$3(this, SerialDisposable);
2140
+
2141
+ _defineProperty$3(this, "isDisposed", false);
2142
+
2143
+ _defineProperty$3(this, "current", void 0);
2144
+ }
2145
+
2146
+ _createClass$3(SerialDisposable, [{
2147
+ key: "getDisposable",
2148
+ value:
2149
+ /**
2150
+ * Gets the underlying disposable.
2151
+ * @returns {Any} the underlying disposable.
2152
+ */
2153
+ function getDisposable() {
2154
+ return this.current;
2155
+ }
2156
+ }, {
2157
+ key: "setDisposable",
2158
+ value: function setDisposable(value) {
2159
+ var shouldDispose = this.isDisposed;
2160
+
2161
+ if (!shouldDispose) {
2162
+ var old = this.current;
2163
+ this.current = value;
2164
+
2165
+ if (old) {
2166
+ old.dispose();
2167
+ }
2168
+ }
2169
+
2170
+ if (shouldDispose && value) {
2171
+ value.dispose();
2172
+ }
2173
+ }
2174
+ /** Performs the task of cleaning up resources. */
2175
+
2176
+ }, {
2177
+ key: "dispose",
2178
+ value: function dispose() {
2179
+ if (!this.isDisposed) {
2180
+ this.isDisposed = true;
2181
+ var old = this.current;
2182
+ this.current = undefined;
2183
+
2184
+ if (old) {
2185
+ old.dispose();
2186
+ }
2187
+ }
2188
+ }
2189
+ }]);
2190
+
2191
+ return SerialDisposable;
2192
+ }();
2193
+
2194
+ var reactIs$1 = {exports: {}};
2195
+
2196
+ var reactIs_production_min = {};
2197
+
2198
+ /** @license React v16.13.1
2199
+ * react-is.production.min.js
2200
+ *
2201
+ * Copyright (c) Facebook, Inc. and its affiliates.
2202
+ *
2203
+ * This source code is licensed under the MIT license found in the
2204
+ * LICENSE file in the root directory of this source tree.
2205
+ */
2206
+ 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?
2207
+ 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;
2208
+ 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;
2209
+ 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};
2210
+ 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};
2211
+ 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;
2212
+
2213
+ var reactIs_development = {};
2214
+
2215
+ /** @license React v16.13.1
2216
+ * react-is.development.js
2217
+ *
2218
+ * Copyright (c) Facebook, Inc. and its affiliates.
2219
+ *
2220
+ * This source code is licensed under the MIT license found in the
2221
+ * LICENSE file in the root directory of this source tree.
2222
+ */
2223
+
2224
+
2225
+
2226
+ if (process.env.NODE_ENV !== "production") {
2227
+ (function() {
2228
+
2229
+ // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
2230
+ // nor polyfill, then a plain number is used for performance.
2231
+ var hasSymbol = typeof Symbol === 'function' && Symbol.for;
2232
+ var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
2233
+ var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
2234
+ var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
2235
+ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
2236
+ var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
2237
+ var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
2238
+ var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
2239
+ // (unstable) APIs that have been removed. Can we remove the symbols?
2240
+
2241
+ var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
2242
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
2243
+ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
2244
+ var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
2245
+ var REACT_SUSPENSE_LIST_TYPE = hasSymbol ? Symbol.for('react.suspense_list') : 0xead8;
2246
+ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
2247
+ var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
2248
+ var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for('react.block') : 0xead9;
2249
+ var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
2250
+ var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
2251
+ var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
2252
+
2253
+ function isValidElementType(type) {
2254
+ return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
2255
+ 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);
2256
+ }
2257
+
2258
+ function typeOf(object) {
2259
+ if (typeof object === 'object' && object !== null) {
2260
+ var $$typeof = object.$$typeof;
2261
+
2262
+ switch ($$typeof) {
2263
+ case REACT_ELEMENT_TYPE:
2264
+ var type = object.type;
2265
+
2266
+ switch (type) {
2267
+ case REACT_ASYNC_MODE_TYPE:
2268
+ case REACT_CONCURRENT_MODE_TYPE:
2269
+ case REACT_FRAGMENT_TYPE:
2270
+ case REACT_PROFILER_TYPE:
2271
+ case REACT_STRICT_MODE_TYPE:
2272
+ case REACT_SUSPENSE_TYPE:
2273
+ return type;
2274
+
2275
+ default:
2276
+ var $$typeofType = type && type.$$typeof;
2277
+
2278
+ switch ($$typeofType) {
2279
+ case REACT_CONTEXT_TYPE:
2280
+ case REACT_FORWARD_REF_TYPE:
2281
+ case REACT_LAZY_TYPE:
2282
+ case REACT_MEMO_TYPE:
2283
+ case REACT_PROVIDER_TYPE:
2284
+ return $$typeofType;
2285
+
2286
+ default:
2287
+ return $$typeof;
2288
+ }
2289
+
2290
+ }
2291
+
2292
+ case REACT_PORTAL_TYPE:
2293
+ return $$typeof;
2294
+ }
2295
+ }
2296
+
2297
+ return undefined;
2298
+ } // AsyncMode is deprecated along with isAsyncMode
2299
+
2300
+ var AsyncMode = REACT_ASYNC_MODE_TYPE;
2301
+ var ConcurrentMode = REACT_CONCURRENT_MODE_TYPE;
2302
+ var ContextConsumer = REACT_CONTEXT_TYPE;
2303
+ var ContextProvider = REACT_PROVIDER_TYPE;
2304
+ var Element = REACT_ELEMENT_TYPE;
2305
+ var ForwardRef = REACT_FORWARD_REF_TYPE;
2306
+ var Fragment = REACT_FRAGMENT_TYPE;
2307
+ var Lazy = REACT_LAZY_TYPE;
2308
+ var Memo = REACT_MEMO_TYPE;
2309
+ var Portal = REACT_PORTAL_TYPE;
2310
+ var Profiler = REACT_PROFILER_TYPE;
2311
+ var StrictMode = REACT_STRICT_MODE_TYPE;
2312
+ var Suspense = REACT_SUSPENSE_TYPE;
2313
+ var hasWarnedAboutDeprecatedIsAsyncMode = false; // AsyncMode should be deprecated
2314
+
2315
+ function isAsyncMode(object) {
2316
+ {
2317
+ if (!hasWarnedAboutDeprecatedIsAsyncMode) {
2318
+ hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
2319
+
2320
+ 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.');
2321
+ }
2322
+ }
2323
+
2324
+ return isConcurrentMode(object) || typeOf(object) === REACT_ASYNC_MODE_TYPE;
2325
+ }
2326
+ function isConcurrentMode(object) {
2327
+ return typeOf(object) === REACT_CONCURRENT_MODE_TYPE;
2328
+ }
2329
+ function isContextConsumer(object) {
2330
+ return typeOf(object) === REACT_CONTEXT_TYPE;
2331
+ }
2332
+ function isContextProvider(object) {
2333
+ return typeOf(object) === REACT_PROVIDER_TYPE;
2334
+ }
2335
+ function isElement(object) {
2336
+ return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
2337
+ }
2338
+ function isForwardRef(object) {
2339
+ return typeOf(object) === REACT_FORWARD_REF_TYPE;
2340
+ }
2341
+ function isFragment(object) {
2342
+ return typeOf(object) === REACT_FRAGMENT_TYPE;
2343
+ }
2344
+ function isLazy(object) {
2345
+ return typeOf(object) === REACT_LAZY_TYPE;
2346
+ }
2347
+ function isMemo(object) {
2348
+ return typeOf(object) === REACT_MEMO_TYPE;
2349
+ }
2350
+ function isPortal(object) {
2351
+ return typeOf(object) === REACT_PORTAL_TYPE;
2352
+ }
2353
+ function isProfiler(object) {
2354
+ return typeOf(object) === REACT_PROFILER_TYPE;
2355
+ }
2356
+ function isStrictMode(object) {
2357
+ return typeOf(object) === REACT_STRICT_MODE_TYPE;
2358
+ }
2359
+ function isSuspense(object) {
2360
+ return typeOf(object) === REACT_SUSPENSE_TYPE;
2361
+ }
2362
+
2363
+ reactIs_development.AsyncMode = AsyncMode;
2364
+ reactIs_development.ConcurrentMode = ConcurrentMode;
2365
+ reactIs_development.ContextConsumer = ContextConsumer;
2366
+ reactIs_development.ContextProvider = ContextProvider;
2367
+ reactIs_development.Element = Element;
2368
+ reactIs_development.ForwardRef = ForwardRef;
2369
+ reactIs_development.Fragment = Fragment;
2370
+ reactIs_development.Lazy = Lazy;
2371
+ reactIs_development.Memo = Memo;
2372
+ reactIs_development.Portal = Portal;
2373
+ reactIs_development.Profiler = Profiler;
2374
+ reactIs_development.StrictMode = StrictMode;
2375
+ reactIs_development.Suspense = Suspense;
2376
+ reactIs_development.isAsyncMode = isAsyncMode;
2377
+ reactIs_development.isConcurrentMode = isConcurrentMode;
2378
+ reactIs_development.isContextConsumer = isContextConsumer;
2379
+ reactIs_development.isContextProvider = isContextProvider;
2380
+ reactIs_development.isElement = isElement;
2381
+ reactIs_development.isForwardRef = isForwardRef;
2382
+ reactIs_development.isFragment = isFragment;
2383
+ reactIs_development.isLazy = isLazy;
2384
+ reactIs_development.isMemo = isMemo;
2385
+ reactIs_development.isPortal = isPortal;
2386
+ reactIs_development.isProfiler = isProfiler;
2387
+ reactIs_development.isStrictMode = isStrictMode;
2388
+ reactIs_development.isSuspense = isSuspense;
2389
+ reactIs_development.isValidElementType = isValidElementType;
2390
+ reactIs_development.typeOf = typeOf;
2391
+ })();
2392
+ }
2393
+
2394
+ if (process.env.NODE_ENV === 'production') {
2395
+ reactIs$1.exports = reactIs_production_min;
2396
+ } else {
2397
+ reactIs$1.exports = reactIs_development;
2398
+ }
2399
+
2400
+ var reactIs = reactIs$1.exports;
2401
+
2402
+ /**
2403
+ * Copyright 2015, Yahoo! Inc.
2404
+ * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
2405
+ */
2406
+ var REACT_STATICS = {
2407
+ childContextTypes: true,
2408
+ contextType: true,
2409
+ contextTypes: true,
2410
+ defaultProps: true,
2411
+ displayName: true,
2412
+ getDefaultProps: true,
2413
+ getDerivedStateFromError: true,
2414
+ getDerivedStateFromProps: true,
2415
+ mixins: true,
2416
+ propTypes: true,
2417
+ type: true
2418
+ };
2419
+ var KNOWN_STATICS = {
2420
+ name: true,
2421
+ length: true,
2422
+ prototype: true,
2423
+ caller: true,
2424
+ callee: true,
2425
+ arguments: true,
2426
+ arity: true
2427
+ };
2428
+ var FORWARD_REF_STATICS = {
2429
+ '$$typeof': true,
2430
+ render: true,
2431
+ defaultProps: true,
2432
+ displayName: true,
2433
+ propTypes: true
2434
+ };
2435
+ var MEMO_STATICS = {
2436
+ '$$typeof': true,
2437
+ compare: true,
2438
+ defaultProps: true,
2439
+ displayName: true,
2440
+ propTypes: true,
2441
+ type: true
2442
+ };
2443
+ var TYPE_STATICS = {};
2444
+ TYPE_STATICS[reactIs.ForwardRef] = FORWARD_REF_STATICS;
2445
+ TYPE_STATICS[reactIs.Memo] = MEMO_STATICS;
2446
+
2447
+ function getStatics(component) {
2448
+ // React v16.11 and below
2449
+ if (reactIs.isMemo(component)) {
2450
+ return MEMO_STATICS;
2451
+ } // React v16.12 and above
2452
+
2453
+
2454
+ return TYPE_STATICS[component['$$typeof']] || REACT_STATICS;
2455
+ }
2456
+
2457
+ var defineProperty = Object.defineProperty;
2458
+ var getOwnPropertyNames = Object.getOwnPropertyNames;
2459
+ var getOwnPropertySymbols = Object.getOwnPropertySymbols;
2460
+ var getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
2461
+ var getPrototypeOf = Object.getPrototypeOf;
2462
+ var objectPrototype = Object.prototype;
2463
+ function hoistNonReactStatics(targetComponent, sourceComponent, blacklist) {
2464
+ if (typeof sourceComponent !== 'string') {
2465
+ // don't hoist over string (html) components
2466
+ if (objectPrototype) {
2467
+ var inheritedComponent = getPrototypeOf(sourceComponent);
2468
+
2469
+ if (inheritedComponent && inheritedComponent !== objectPrototype) {
2470
+ hoistNonReactStatics(targetComponent, inheritedComponent, blacklist);
2471
+ }
2472
+ }
2473
+
2474
+ var keys = getOwnPropertyNames(sourceComponent);
2475
+
2476
+ if (getOwnPropertySymbols) {
2477
+ keys = keys.concat(getOwnPropertySymbols(sourceComponent));
2478
+ }
2479
+
2480
+ var targetStatics = getStatics(targetComponent);
2481
+ var sourceStatics = getStatics(sourceComponent);
2482
+
2483
+ for (var i = 0; i < keys.length; ++i) {
2484
+ var key = keys[i];
2485
+
2486
+ if (!KNOWN_STATICS[key] && !(blacklist && blacklist[key]) && !(sourceStatics && sourceStatics[key]) && !(targetStatics && targetStatics[key])) {
2487
+ var descriptor = getOwnPropertyDescriptor(sourceComponent, key);
2488
+
2489
+ try {
2490
+ // Avoid failures from read-only properties
2491
+ defineProperty(targetComponent, key, descriptor);
2492
+ } catch (e) {}
2493
+ }
2494
+ }
2495
+ }
2496
+
2497
+ return targetComponent;
2498
+ }
2499
+
2500
+ var hoistNonReactStatics_cjs = hoistNonReactStatics;
2501
+
2502
+ var hoistStatics = hoistNonReactStatics_cjs;
2503
+
2504
+ 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); }
2505
+
2506
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2507
+
2508
+ 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."); }
2509
+
2510
+ 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); }
2511
+
2512
+ 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; }
2513
+
2514
+ 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; }
2515
+
2516
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
2517
+
2518
+ function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2519
+
2520
+ 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); } }
2521
+
2522
+ function _createClass$2(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$2(Constructor.prototype, protoProps); if (staticProps) _defineProperties$2(Constructor, staticProps); return Constructor; }
2523
+
2524
+ 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); }
2525
+
2526
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
2527
+
2528
+ 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); }; }
2529
+
2530
+ 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); }
2531
+
2532
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
2533
+
2534
+ 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; } }
2535
+
2536
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
2537
+
2538
+ 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; }
2539
+ function decorateHandler(_ref) {
2540
+ var DecoratedComponent = _ref.DecoratedComponent,
2541
+ createHandler = _ref.createHandler,
2542
+ createMonitor = _ref.createMonitor,
2543
+ createConnector = _ref.createConnector,
2544
+ registerHandler = _ref.registerHandler,
2545
+ containerDisplayName = _ref.containerDisplayName,
2546
+ getType = _ref.getType,
2547
+ collect = _ref.collect,
2548
+ options = _ref.options;
2549
+ var _options$arePropsEqua = options.arePropsEqual,
2550
+ arePropsEqual = _options$arePropsEqua === void 0 ? shallowEqual : _options$arePropsEqua;
2551
+ var Decorated = DecoratedComponent;
2552
+ var displayName = DecoratedComponent.displayName || DecoratedComponent.name || 'Component';
2553
+
2554
+ var DragDropContainer = /*#__PURE__*/function (_Component) {
2555
+ _inherits(DragDropContainer, _Component);
2556
+
2557
+ var _super = _createSuper(DragDropContainer);
2558
+
2559
+ function DragDropContainer(props) {
2560
+ var _this;
2561
+
2562
+ _classCallCheck$2(this, DragDropContainer);
2563
+
2564
+ _this = _super.call(this, props);
2565
+
2566
+ _defineProperty$2(_assertThisInitialized(_this), "decoratedRef", createRef());
2567
+
2568
+ _defineProperty$2(_assertThisInitialized(_this), "handlerId", void 0);
2569
+
2570
+ _defineProperty$2(_assertThisInitialized(_this), "manager", void 0);
2571
+
2572
+ _defineProperty$2(_assertThisInitialized(_this), "handlerMonitor", void 0);
2573
+
2574
+ _defineProperty$2(_assertThisInitialized(_this), "handlerConnector", void 0);
2575
+
2576
+ _defineProperty$2(_assertThisInitialized(_this), "handler", void 0);
2577
+
2578
+ _defineProperty$2(_assertThisInitialized(_this), "disposable", void 0);
2579
+
2580
+ _defineProperty$2(_assertThisInitialized(_this), "currentType", void 0);
2581
+
2582
+ _defineProperty$2(_assertThisInitialized(_this), "handleChange", function () {
2583
+ var nextState = _this.getCurrentState();
2584
+
2585
+ if (!shallowEqual(nextState, _this.state)) {
2586
+ _this.setState(nextState);
2587
+ }
2588
+ });
2589
+
2590
+ _this.disposable = new SerialDisposable();
2591
+
2592
+ _this.receiveProps(props);
2593
+
2594
+ _this.dispose();
2595
+
2596
+ return _this;
2597
+ }
2598
+
2599
+ _createClass$2(DragDropContainer, [{
2600
+ key: "getHandlerId",
2601
+ value: function getHandlerId() {
2602
+ return this.handlerId;
2603
+ }
2604
+ }, {
2605
+ key: "getDecoratedComponentInstance",
2606
+ value: function getDecoratedComponentInstance() {
2607
+ 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()');
2608
+ return this.decoratedRef.current;
2609
+ }
2610
+ }, {
2611
+ key: "shouldComponentUpdate",
2612
+ value: function shouldComponentUpdate(nextProps, nextState) {
2613
+ return !arePropsEqual(nextProps, this.props) || !shallowEqual(nextState, this.state);
2614
+ }
2615
+ }, {
2616
+ key: "componentDidMount",
2617
+ value: function componentDidMount() {
2618
+ this.disposable = new SerialDisposable();
2619
+ this.currentType = undefined;
2620
+ this.receiveProps(this.props);
2621
+ this.handleChange();
2622
+ }
2623
+ }, {
2624
+ key: "componentDidUpdate",
2625
+ value: function componentDidUpdate(prevProps) {
2626
+ if (!arePropsEqual(this.props, prevProps)) {
2627
+ this.receiveProps(this.props);
2628
+ this.handleChange();
2629
+ }
2630
+ }
2631
+ }, {
2632
+ key: "componentWillUnmount",
2633
+ value: function componentWillUnmount() {
2634
+ this.dispose();
2635
+ }
2636
+ }, {
2637
+ key: "receiveProps",
2638
+ value: function receiveProps(props) {
2639
+ if (!this.handler) {
2640
+ return;
2641
+ }
2642
+
2643
+ this.handler.receiveProps(props);
2644
+ this.receiveType(getType(props));
2645
+ }
2646
+ }, {
2647
+ key: "receiveType",
2648
+ value: function receiveType(type) {
2649
+ if (!this.handlerMonitor || !this.manager || !this.handlerConnector) {
2650
+ return;
2651
+ }
2652
+
2653
+ if (type === this.currentType) {
2654
+ return;
2655
+ }
2656
+
2657
+ this.currentType = type;
2658
+
2659
+ var _registerHandler = registerHandler(type, this.handler, this.manager),
2660
+ _registerHandler2 = _slicedToArray(_registerHandler, 2),
2661
+ handlerId = _registerHandler2[0],
2662
+ unregister = _registerHandler2[1];
2663
+
2664
+ this.handlerId = handlerId;
2665
+ this.handlerMonitor.receiveHandlerId(handlerId);
2666
+ this.handlerConnector.receiveHandlerId(handlerId);
2667
+ var globalMonitor = this.manager.getMonitor();
2668
+ var unsubscribe = globalMonitor.subscribeToStateChange(this.handleChange, {
2669
+ handlerIds: [handlerId]
2670
+ });
2671
+ this.disposable.setDisposable(new CompositeDisposable(new Disposable(unsubscribe), new Disposable(unregister)));
2672
+ }
2673
+ }, {
2674
+ key: "dispose",
2675
+ value: function dispose() {
2676
+ this.disposable.dispose();
2677
+
2678
+ if (this.handlerConnector) {
2679
+ this.handlerConnector.receiveHandlerId(null);
2680
+ }
2681
+ }
2682
+ }, {
2683
+ key: "getCurrentState",
2684
+ value: function getCurrentState() {
2685
+ if (!this.handlerConnector) {
2686
+ return {};
2687
+ }
2688
+
2689
+ var nextState = collect(this.handlerConnector.hooks, this.handlerMonitor, this.props);
2690
+
2691
+ if (process.env.NODE_ENV !== 'production') {
2692
+ 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);
2693
+ }
2694
+
2695
+ return nextState;
2696
+ }
2697
+ }, {
2698
+ key: "render",
2699
+ value: function render() {
2700
+ var _this2 = this;
2701
+
2702
+ return jsx(DndContext.Consumer, {
2703
+ children: function children(_ref2) {
2704
+ var dragDropManager = _ref2.dragDropManager;
2705
+
2706
+ _this2.receiveDragDropManager(dragDropManager);
2707
+
2708
+ if (typeof requestAnimationFrame !== 'undefined') {
2709
+ requestAnimationFrame(function () {
2710
+ var _this2$handlerConnect;
2711
+
2712
+ return (_this2$handlerConnect = _this2.handlerConnector) === null || _this2$handlerConnect === void 0 ? void 0 : _this2$handlerConnect.reconnect();
2713
+ });
2714
+ }
2715
+
2716
+ return jsx(Decorated, Object.assign({}, _this2.props, _this2.getCurrentState(), {
2717
+ // NOTE: if Decorated is a Function Component, decoratedRef will not be populated unless it's a refforwarding component.
2718
+ ref: isRefable(Decorated) ? _this2.decoratedRef : null
2719
+ }), void 0);
2720
+ }
2721
+ }, void 0);
2722
+ }
2723
+ }, {
2724
+ key: "receiveDragDropManager",
2725
+ value: function receiveDragDropManager(dragDropManager) {
2726
+ if (this.manager !== undefined) {
2727
+ return;
2728
+ }
2729
+
2730
+ 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);
2731
+
2732
+ if (dragDropManager === undefined) {
2733
+ return;
2734
+ }
2735
+
2736
+ this.manager = dragDropManager;
2737
+ this.handlerMonitor = createMonitor(dragDropManager);
2738
+ this.handlerConnector = createConnector(dragDropManager.getBackend());
2739
+ this.handler = createHandler(this.handlerMonitor, this.decoratedRef);
2740
+ }
2741
+ }]);
2742
+
2743
+ return DragDropContainer;
2744
+ }(Component);
2745
+
2746
+ _defineProperty$2(DragDropContainer, "DecoratedComponent", DecoratedComponent);
2747
+
2748
+ _defineProperty$2(DragDropContainer, "displayName", "".concat(containerDisplayName, "(").concat(displayName, ")"));
2749
+
2750
+ return hoistStatics(DragDropContainer, DecoratedComponent);
2751
+ }
2752
+
2753
+ function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2754
+
2755
+ 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); } }
2756
+
2757
+ function _createClass$1(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties$1(Constructor.prototype, protoProps); if (staticProps) _defineProperties$1(Constructor, staticProps); return Constructor; }
2758
+
2759
+ 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; }
2760
+ var ALLOWED_SPEC_METHODS$1 = ['canDrag', 'beginDrag', 'isDragging', 'endDrag'];
2761
+ var REQUIRED_SPEC_METHODS = ['beginDrag'];
2762
+
2763
+ var SourceImpl = /*#__PURE__*/function () {
2764
+ function SourceImpl(spec, monitor, ref) {
2765
+ var _this = this;
2766
+
2767
+ _classCallCheck$1(this, SourceImpl);
2768
+
2769
+ _defineProperty$1(this, "props", null);
2770
+
2771
+ _defineProperty$1(this, "spec", void 0);
2772
+
2773
+ _defineProperty$1(this, "monitor", void 0);
2774
+
2775
+ _defineProperty$1(this, "ref", void 0);
2776
+
2777
+ _defineProperty$1(this, "beginDrag", function () {
2778
+ if (!_this.props) {
2779
+ return;
2780
+ }
2781
+
2782
+ var item = _this.spec.beginDrag(_this.props, _this.monitor, _this.ref.current);
2783
+
2784
+ if (process.env.NODE_ENV !== 'production') {
2785
+ 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);
2786
+ }
2787
+
2788
+ return item;
2789
+ });
2790
+
2791
+ this.spec = spec;
2792
+ this.monitor = monitor;
2793
+ this.ref = ref;
2794
+ }
2795
+
2796
+ _createClass$1(SourceImpl, [{
2797
+ key: "receiveProps",
2798
+ value: function receiveProps(props) {
2799
+ this.props = props;
2800
+ }
2801
+ }, {
2802
+ key: "canDrag",
2803
+ value: function canDrag() {
2804
+ if (!this.props) {
2805
+ return false;
2806
+ }
2807
+
2808
+ if (!this.spec.canDrag) {
2809
+ return true;
2810
+ }
2811
+
2812
+ return this.spec.canDrag(this.props, this.monitor);
2813
+ }
2814
+ }, {
2815
+ key: "isDragging",
2816
+ value: function isDragging(globalMonitor, sourceId) {
2817
+ if (!this.props) {
2818
+ return false;
2819
+ }
2820
+
2821
+ if (!this.spec.isDragging) {
2822
+ return sourceId === globalMonitor.getSourceId();
2823
+ }
2824
+
2825
+ return this.spec.isDragging(this.props, this.monitor);
2826
+ }
2827
+ }, {
2828
+ key: "endDrag",
2829
+ value: function endDrag() {
2830
+ if (!this.props) {
2831
+ return;
2832
+ }
2833
+
2834
+ if (!this.spec.endDrag) {
2835
+ return;
2836
+ }
2837
+
2838
+ this.spec.endDrag(this.props, this.monitor, getDecoratedComponent(this.ref));
2839
+ }
2840
+ }]);
2841
+
2842
+ return SourceImpl;
2843
+ }();
2844
+
2845
+ function createSourceFactory(spec) {
2846
+ Object.keys(spec).forEach(function (key) {
2847
+ 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);
2848
+ 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]);
2849
+ });
2850
+ REQUIRED_SPEC_METHODS.forEach(function (key) {
2851
+ 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]);
2852
+ });
2853
+ return function createSource(monitor, ref) {
2854
+ return new SourceImpl(spec, monitor, ref);
2855
+ };
2856
+ }
2857
+
2858
+ /**
2859
+ * Decorates a component as a dragsource
2860
+ * @param type The dragsource type
2861
+ * @param spec The drag source specification
2862
+ * @param collect The props collector function
2863
+ * @param options DnD options
2864
+ */
2865
+
2866
+ function DragSource(type, spec, collect) {
2867
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2868
+ checkDecoratorArguments('DragSource', 'type, spec, collect[, options]', type, spec, collect, options);
2869
+ var getType = type;
2870
+
2871
+ if (typeof type !== 'function') {
2872
+ 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);
2873
+
2874
+ getType = function getType() {
2875
+ return type;
2876
+ };
2877
+ }
2878
+
2879
+ 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);
2880
+ var createSource = createSourceFactory(spec);
2881
+ 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);
2882
+ 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);
2883
+ return function decorateSource(DecoratedComponent) {
2884
+ return decorateHandler({
2885
+ containerDisplayName: 'DragSource',
2886
+ createHandler: createSource,
2887
+ registerHandler: registerSource,
2888
+ createConnector: function createConnector(backend) {
2889
+ return new SourceConnector(backend);
2890
+ },
2891
+ createMonitor: function createMonitor(manager) {
2892
+ return new DragSourceMonitorImpl(manager);
2893
+ },
2894
+ DecoratedComponent: DecoratedComponent,
2895
+ getType: getType,
2896
+ collect: collect,
2897
+ options: options
2898
+ });
2899
+ };
2900
+ }
2901
+
2902
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
2903
+
2904
+ 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); } }
2905
+
2906
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
2907
+
2908
+ 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; }
2909
+ var ALLOWED_SPEC_METHODS = ['canDrop', 'hover', 'drop'];
2910
+
2911
+ var TargetImpl = /*#__PURE__*/function () {
2912
+ function TargetImpl(spec, monitor, ref) {
2913
+ _classCallCheck(this, TargetImpl);
2914
+
2915
+ _defineProperty(this, "props", null);
2916
+
2917
+ _defineProperty(this, "spec", void 0);
2918
+
2919
+ _defineProperty(this, "monitor", void 0);
2920
+
2921
+ _defineProperty(this, "ref", void 0);
2922
+
2923
+ this.spec = spec;
2924
+ this.monitor = monitor;
2925
+ this.ref = ref;
2926
+ }
2927
+
2928
+ _createClass(TargetImpl, [{
2929
+ key: "receiveProps",
2930
+ value: function receiveProps(props) {
2931
+ this.props = props;
2932
+ }
2933
+ }, {
2934
+ key: "receiveMonitor",
2935
+ value: function receiveMonitor(monitor) {
2936
+ this.monitor = monitor;
2937
+ }
2938
+ }, {
2939
+ key: "canDrop",
2940
+ value: function canDrop() {
2941
+ if (!this.spec.canDrop) {
2942
+ return true;
2943
+ }
2944
+
2945
+ return this.spec.canDrop(this.props, this.monitor);
2946
+ }
2947
+ }, {
2948
+ key: "hover",
2949
+ value: function hover() {
2950
+ if (!this.spec.hover || !this.props) {
2951
+ return;
2952
+ }
2953
+
2954
+ this.spec.hover(this.props, this.monitor, getDecoratedComponent(this.ref));
2955
+ }
2956
+ }, {
2957
+ key: "drop",
2958
+ value: function drop() {
2959
+ if (!this.spec.drop) {
2960
+ return undefined;
2961
+ }
2962
+
2963
+ var dropResult = this.spec.drop(this.props, this.monitor, this.ref.current);
2964
+
2965
+ if (process.env.NODE_ENV !== 'production') {
2966
+ 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);
2967
+ }
2968
+
2969
+ return dropResult;
2970
+ }
2971
+ }]);
2972
+
2973
+ return TargetImpl;
2974
+ }();
2975
+
2976
+ function createTargetFactory(spec) {
2977
+ Object.keys(spec).forEach(function (key) {
2978
+ 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);
2979
+ 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]);
2980
+ });
2981
+ return function createTarget(monitor, ref) {
2982
+ return new TargetImpl(spec, monitor, ref);
2983
+ };
2984
+ }
2985
+
2986
+ /**
2987
+ * @param type The accepted target type
2988
+ * @param spec The DropTarget specification
2989
+ * @param collect The props collector function
2990
+ * @param options Options
2991
+ */
2992
+
2993
+ function DropTarget(type, spec, collect) {
2994
+ var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
2995
+ checkDecoratorArguments('DropTarget', 'type, spec, collect[, options]', type, spec, collect, options);
2996
+ var getType = type;
2997
+
2998
+ if (typeof type !== 'function') {
2999
+ 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);
3000
+
3001
+ getType = function getType() {
3002
+ return type;
3003
+ };
3004
+ }
3005
+
3006
+ 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);
3007
+ var createTarget = createTargetFactory(spec);
3008
+ 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);
3009
+ 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);
3010
+ return function decorateTarget(DecoratedComponent) {
3011
+ return decorateHandler({
3012
+ containerDisplayName: 'DropTarget',
3013
+ createHandler: createTarget,
3014
+ registerHandler: registerTarget,
3015
+ createMonitor: function createMonitor(manager) {
3016
+ return new DropTargetMonitorImpl(manager);
3017
+ },
3018
+ createConnector: function createConnector(backend) {
3019
+ return new TargetConnector(backend);
3020
+ },
3021
+ DecoratedComponent: DecoratedComponent,
3022
+ getType: getType,
3023
+ collect: collect,
3024
+ options: options
3025
+ });
3026
+ };
3027
+ }
3028
+
3029
+ var RemoveCircle = {};
3030
+
3031
+ var _interopRequireDefault = interopRequireDefault.exports;
3032
+
3033
+ Object.defineProperty(RemoveCircle, "__esModule", {
3034
+ value: true
3035
+ });
3036
+ var default_1 = RemoveCircle.default = void 0;
3037
+
3038
+ var _react = _interopRequireDefault(React);
3039
+
3040
+ var _createSvgIcon = _interopRequireDefault(createSvgIcon$1);
3041
+
3042
+ var _default = (0, _createSvgIcon.default)(_react.default.createElement(_react.default.Fragment, null, _react.default.createElement("path", {
3043
+ fill: "none",
3044
+ d: "M0 0h24v24H0z"
3045
+ }), _react.default.createElement("path", {
3046
+ d: "M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm5 11H7v-2h10v2z"
3047
+ })), 'RemoveCircle');
3048
+
3049
+ default_1 = RemoveCircle.default = _default;
3050
+
3051
+ const log$2 = debug('@pie-element:placement-ordering:configure:choice-tile');
3052
+ class ChoiceTile extends React.Component {
3053
+ constructor(...args) {
3054
+ super(...args);
3055
+
3056
+ this.onLabelChange = label => {
3057
+ const {
3058
+ choice,
3059
+ onChoiceChange
3060
+ } = this.props;
3061
+ choice.label = label;
3062
+ onChoiceChange(choice);
3063
+ };
3064
+ }
3065
+
3066
+ render() {
3067
+ const {
3068
+ choice: {
3069
+ label,
3070
+ editable,
3071
+ type
3072
+ },
3073
+ isDragging,
3074
+ connectDragSource,
3075
+ connectDropTarget,
3076
+ classes,
3077
+ onDelete,
3078
+ imageSupport,
3079
+ spellCheck,
3080
+ toolbarOpts,
3081
+ pluginProps,
3082
+ maxImageWidth,
3083
+ maxImageHeight,
3084
+ error,
3085
+ mathMlOptions = {}
3086
+ } = this.props;
3087
+ const dragSourceOpts = {}; //dropEffect: moveOnDrag ? 'move' : 'copy'};
3088
+
3089
+ const filteredDefaultPlugins = (DEFAULT_PLUGINS || []).filter(p => p !== 'bulleted-list' && p !== 'numbered-list');
3090
+ const opacity = isDragging ? 0 : 1;
3091
+ const markup = /*#__PURE__*/React.createElement("div", {
3092
+ className: classes.choiceTile,
3093
+ style: {
3094
+ opacity: opacity,
3095
+ width: '100%'
3096
+ }
3097
+ }, /*#__PURE__*/React.createElement("div", {
3098
+ style: {
3099
+ width: '100%',
3100
+ display: 'flex'
3101
+ }
3102
+ }, /*#__PURE__*/React.createElement(CardActions, null, /*#__PURE__*/React.createElement("span", {
3103
+ className: classNames(classes.dragHandle)
3104
+ }, /*#__PURE__*/React.createElement(default_1$1, {
3105
+ className: classes.actions
3106
+ }))), /*#__PURE__*/React.createElement(EditableHtml, {
3107
+ disabled: !editable,
3108
+ className: classNames(classes.prompt, !editable && classes.targetPrompt),
3109
+ placeholder: type !== 'target' && !label.includes('data-latex') ? 'Enter a choice' : '',
3110
+ markup: label,
3111
+ imageSupport: imageSupport || undefined,
3112
+ onChange: this.onLabelChange,
3113
+ pluginProps: pluginProps,
3114
+ toolbarOpts: toolbarOpts,
3115
+ activePlugins: filteredDefaultPlugins,
3116
+ spellCheck: spellCheck,
3117
+ autoWidthToolbar: true,
3118
+ maxImageWidth: maxImageWidth,
3119
+ maxImageHeight: maxImageHeight,
3120
+ languageCharactersProps: [{
3121
+ language: 'spanish'
3122
+ }, {
3123
+ language: 'special'
3124
+ }],
3125
+ error: editable && error,
3126
+ mathMlOptions: mathMlOptions
3127
+ }), editable && /*#__PURE__*/React.createElement("div", {
3128
+ className: classes.controls
3129
+ }, /*#__PURE__*/React.createElement(IconButton, {
3130
+ className: classes.customColor,
3131
+ onClick: onDelete
3132
+ }, /*#__PURE__*/React.createElement(default_1, {
3133
+ classes: {
3134
+ root: classes.removeCircle
3135
+ }
3136
+ })))), editable && error && /*#__PURE__*/React.createElement("div", {
3137
+ className: classes.errorText
3138
+ }, error));
3139
+ return connectDragSource(connectDropTarget( /*#__PURE__*/React.createElement("div", null, markup)), dragSourceOpts);
3140
+ }
3141
+
3142
+ }
3143
+ ChoiceTile.propTypes = {
3144
+ connectDragSource: PropTypes.func.isRequired,
3145
+ connectDropTarget: PropTypes.func.isRequired,
3146
+ isDragging: PropTypes.bool.isRequired,
3147
+ id: PropTypes.any,
3148
+ maxImageHeight: PropTypes.object,
3149
+ maxImageWidth: PropTypes.object,
3150
+ label: PropTypes.string,
3151
+ isOver: PropTypes.bool,
3152
+ classes: PropTypes.object.isRequired,
3153
+ type: PropTypes.string,
3154
+ empty: PropTypes.bool,
3155
+ disabled: PropTypes.bool,
3156
+ outcome: PropTypes.object,
3157
+ index: PropTypes.number,
3158
+ imageSupport: PropTypes.shape({
3159
+ add: PropTypes.func.isRequired,
3160
+ delete: PropTypes.func.isRequired
3161
+ }),
3162
+ choice: PropTypes.object,
3163
+ choices: PropTypes.array.isRequired,
3164
+ onChoiceChange: PropTypes.func.isRequired,
3165
+ onDelete: PropTypes.func.isRequired,
3166
+ toolbarOpts: PropTypes.object,
3167
+ pluginProps: PropTypes.object,
3168
+ choicesLabel: PropTypes.string,
3169
+ error: PropTypes.string,
3170
+ spellCheck: PropTypes.bool
3171
+ };
3172
+ const Styled = withStyles(theme => ({
3173
+ removeCircle: {
3174
+ fill: theme.palette.error[500]
3175
+ },
3176
+ choiceTile: {
3177
+ cursor: 'move',
3178
+ backgroundColor: theme.palette.common.white,
3179
+ margin: `${theme.spacing.unit}px 0`,
3180
+ display: 'flex',
3181
+ flexDirection: 'column'
3182
+ },
3183
+ controls: {
3184
+ display: 'flex',
3185
+ justifyContent: 'flex-end'
3186
+ },
3187
+ prompt: {
3188
+ width: '80%',
3189
+ border: 'none',
3190
+ borderRadius: '4px'
3191
+ },
3192
+ targetPrompt: {
3193
+ backgroundColor: theme.palette.error['A100']
3194
+ },
3195
+ actions: {
3196
+ color: theme.palette.error[400]
3197
+ },
3198
+ errorText: {
3199
+ fontSize: theme.typography.fontSize - 2,
3200
+ color: theme.palette.error.main,
3201
+ marginLeft: theme.spacing.unit * 5,
3202
+ marginTop: theme.spacing.unit
3203
+ },
3204
+ correctOrder: {
3205
+ position: 'absolute',
3206
+ top: 0,
3207
+ fontSize: theme.typography.fontSize - 2,
3208
+ color: color.disabled()
3209
+ },
3210
+ customColor: {
3211
+ color: `${color.tertiary()} !important`
3212
+ }
3213
+ }))(ChoiceTile);
3214
+ const NAME = 'choice-config';
3215
+ const choiceSource = {
3216
+ beginDrag(props) {
3217
+ return {
3218
+ id: props.choice.id,
3219
+ index: props.index,
3220
+ type: props.choice.type,
3221
+ instanceId: props.choice.instanceId
3222
+ };
3223
+ }
3224
+
3225
+ };
3226
+ const StyledSource = DragSource(NAME, choiceSource, (connect, monitor) => ({
3227
+ connectDragSource: connect.dragSource(),
3228
+ isDragging: monitor.isDragging()
3229
+ }))(Styled);
3230
+ const choiceTarget = {
3231
+ hover() {
3232
+ log$2('[hover]');
3233
+ },
3234
+
3235
+ drop(props, monitor) {
3236
+ const item = monitor.getItem();
3237
+ log$2('[drop] item: ', item, 'didDrop?', monitor.didDrop());
3238
+ props.onDropChoice(item, props.index);
3239
+ }
3240
+
3241
+ };
3242
+ const StyledSourceAndTarget = DropTarget(NAME, choiceTarget, (connect, monitor) => ({
3243
+ connectDropTarget: connect.dropTarget(),
3244
+ isOver: monitor.isOver()
3245
+ }))(StyledSource);
3246
+
3247
+ function findFreeChoiceSlot(choices) {
3248
+ let slot = 1;
3249
+ const ids = choices.map(c => c.id);
3250
+
3251
+ while (ids.includes(`c${slot}`)) {
3252
+ slot++;
3253
+ }
3254
+
3255
+ return slot;
3256
+ }
3257
+
3258
+ const log$1 = debug('@pie-element:placement-ordering:configure:choice-editor');
3259
+
3260
+ function updateResponseOrChoices(response, choices, from, to) {
3261
+ const {
3262
+ type: fromType,
3263
+ index: fromIndex
3264
+ } = from;
3265
+ const {
3266
+ type: toType,
3267
+ index: placeAtIndex
3268
+ } = to;
3269
+
3270
+ if (fromType === 'target' && toType === 'target') {
3271
+ const updatedResponse = cloneDeep(response) || [];
3272
+ const {
3273
+ movedItem,
3274
+ remainingItems
3275
+ } = updatedResponse.reduce((acc, item, index) => {
3276
+ if (index === fromIndex) {
3277
+ acc.movedItem = item;
3278
+ } else {
3279
+ acc.remainingItems.push(item);
3280
+ }
3281
+
3282
+ return acc;
3283
+ }, {
3284
+ movedItem: null,
3285
+ remainingItems: []
3286
+ });
3287
+ return {
3288
+ response: [...remainingItems.slice(0, placeAtIndex), movedItem, ...remainingItems.slice(placeAtIndex)],
3289
+ choices
3290
+ };
3291
+ }
3292
+
3293
+ if (fromType === 'choice' && toType === 'choice') {
3294
+ const updatedChoices = cloneDeep(choices) || [];
3295
+ const {
3296
+ movedItem,
3297
+ remainingItems,
3298
+ toIndex
3299
+ } = updatedChoices.reduce((acc, item, index) => {
3300
+ if (item.id === from.id) {
3301
+ acc.movedItem = item;
3302
+ } else {
3303
+ acc.remainingItems.push(item);
3304
+ }
3305
+
3306
+ if (item.id === to.id) {
3307
+ acc.toIndex = index;
3308
+ }
3309
+
3310
+ return acc;
3311
+ }, {
3312
+ movedItem: null,
3313
+ remainingItems: [],
3314
+ toIndex: null
3315
+ });
3316
+ return {
3317
+ response,
3318
+ choices: [...remainingItems.slice(0, toIndex), movedItem, ...remainingItems.slice(toIndex)]
3319
+ };
3320
+ }
3321
+
3322
+ return {
3323
+ response,
3324
+ choices
3325
+ };
3326
+ }
3327
+
3328
+ function buildTiles(choices, response, instanceId) {
3329
+ const targets = response.map((r, index) => {
3330
+ const respId = r && r.id;
3331
+ const choice = choices.find(c => respId !== undefined && respId !== null && c.id === respId);
3332
+ return _extends({
3333
+ type: 'target',
3334
+ instanceId
3335
+ }, choice, {
3336
+ draggable: true,
3337
+ index,
3338
+ editable: false
3339
+ });
3340
+ });
3341
+ const processedChoices = choices.map(m => {
3342
+ return Object.assign({}, m, {
3343
+ type: 'choice',
3344
+ droppable: false,
3345
+ draggable: true,
3346
+ instanceId,
3347
+ editable: true
3348
+ });
3349
+ });
3350
+ return processedChoices.concat(targets);
3351
+ }
3352
+
3353
+ class ChoiceEditor extends React.Component {
3354
+ constructor(props) {
3355
+ super(props);
3356
+ this.state = {
3357
+ warning: {
3358
+ open: false
3359
+ }
3360
+ };
3361
+ this.instanceId = uniqueId();
3362
+
3363
+ this.onChoiceChange = choice => {
3364
+ const {
3365
+ choices,
3366
+ onChange,
3367
+ correctResponse
3368
+ } = this.props;
3369
+ const index = choices.findIndex(c => c.id === choice.id);
3370
+ choices.splice(index, 1, _extends({}, choices[index], {
3371
+ label: choice.label
3372
+ }));
3373
+ onChange(choices, correctResponse);
3374
+ };
3375
+
3376
+ this.onDelete = choice => {
3377
+ const {
3378
+ choices,
3379
+ onChange,
3380
+ correctResponse,
3381
+ choicesLabel
3382
+ } = this.props;
3383
+
3384
+ if (choices && choices.length === 3) {
3385
+ this.setState({
3386
+ warning: {
3387
+ open: true,
3388
+ text: `There have to be at least 3 ${choicesLabel}.`
3389
+ }
3390
+ });
3391
+ } else {
3392
+ const updatedChoices = choices.filter(c => c.id !== choice.id);
3393
+ const updatedCorrectResponse = correctResponse.filter(v => v.id !== choice.id);
3394
+ onChange(updatedChoices, updatedCorrectResponse);
3395
+ }
3396
+ };
3397
+
3398
+ this.addChoice = () => {
3399
+ const {
3400
+ choices,
3401
+ correctResponse,
3402
+ onChange,
3403
+ choicesLabel
3404
+ } = this.props;
3405
+
3406
+ if (choices && choices.length === 10) {
3407
+ this.setState({
3408
+ warning: {
3409
+ open: true,
3410
+ text: `There can be maximum 10 ${choicesLabel}.`
3411
+ }
3412
+ });
3413
+ } else {
3414
+ const freeId = findFreeChoiceSlot(choices);
3415
+ const id = `c${freeId}`;
3416
+ const newChoice = {
3417
+ id,
3418
+ label: ''
3419
+ };
3420
+ const newCorrectResponse = {
3421
+ id,
3422
+
3423
+ /**
3424
+ * Note: weights are not configurable in the existing component
3425
+ * so we'll want do disable this in the controller and ignore it for now.
3426
+ */
3427
+ weight: 0
3428
+ };
3429
+ const updatedChoices = choices.concat([newChoice]);
3430
+ const updatedCorrectResponse = correctResponse.concat([newCorrectResponse]);
3431
+ onChange(updatedChoices, updatedCorrectResponse);
3432
+ }
3433
+ };
3434
+
3435
+ this.shuffleChoices = () => {
3436
+ const {
3437
+ onChange,
3438
+ choices,
3439
+ correctResponse,
3440
+ placementArea
3441
+ } = this.props;
3442
+ let shuffled = shuffle(choices); // if placementArea is disabled, make sure we don't shuffle choices in the correct order
3443
+
3444
+ const shuffledCorrect = !placementArea && isEqual(shuffled.map(item => item.id), correctResponse.map(item => item.id));
3445
+
3446
+ if (shuffledCorrect) {
3447
+ const shuffledTwice = shuffle(shuffled);
3448
+ onChange(shuffledTwice, correctResponse);
3449
+ } else {
3450
+ onChange(shuffled, correctResponse);
3451
+ }
3452
+ };
3453
+
3454
+ this.onDropChoice = (ordering, target, source) => {
3455
+ const {
3456
+ onChange
3457
+ } = this.props;
3458
+ const from = ordering.tiles.find(t => t.id === source.id && t.type === source.type);
3459
+ const to = target;
3460
+ log$1('[onDropChoice] ', from, to);
3461
+ const {
3462
+ response,
3463
+ choices
3464
+ } = updateResponseOrChoices(ordering.response, ordering.choices, from, to);
3465
+ onChange(choices, response);
3466
+ };
3467
+ }
3468
+
3469
+ render() {
3470
+ const {
3471
+ classes,
3472
+ correctResponse,
3473
+ choices,
3474
+ imageSupport,
3475
+ toolbarOpts,
3476
+ pluginProps,
3477
+ singularChoiceLabel,
3478
+ pluralChoiceLabel,
3479
+ choicesLabel,
3480
+ spellCheck,
3481
+ maxImageWidth,
3482
+ maxImageHeight,
3483
+ errors,
3484
+ mathMlOptions = {}
3485
+ } = this.props;
3486
+ const {
3487
+ warning
3488
+ } = this.state;
3489
+ const {
3490
+ choicesErrors,
3491
+ orderError
3492
+ } = errors || {};
3493
+ const ordering = {
3494
+ choices,
3495
+ response: !correctResponse || isEmpty(correctResponse) ? new Array(choices.length) : correctResponse,
3496
+ tiles: buildTiles(choices, correctResponse, this.instanceId)
3497
+ };
3498
+ const vTilerStyle = {
3499
+ gridTemplateColumns: 'repeat(2, 1fr)',
3500
+ gridTemplateRows: `repeat(${choices.length}, 1fr)`
3501
+ };
3502
+ return /*#__PURE__*/React.createElement("div", {
3503
+ className: classes.choiceEditor
3504
+ }, /*#__PURE__*/React.createElement("div", {
3505
+ className: classes.vtiler,
3506
+ style: {
3507
+ gridTemplateColumns: 'repeat(2, 1fr)'
3508
+ }
3509
+ }, /*#__PURE__*/React.createElement(InputContainer, {
3510
+ label: `Student ${choicesLabel || 'Choices'}`,
3511
+ className: classes.columnLabel
3512
+ }), /*#__PURE__*/React.createElement(InputContainer, {
3513
+ label: "Correct Order",
3514
+ className: classes.columnLabel
3515
+ })), /*#__PURE__*/React.createElement("div", {
3516
+ className: classes.vtiler,
3517
+ style: vTilerStyle
3518
+ }, ordering.tiles.map((choice, index) => /*#__PURE__*/React.createElement(StyledSourceAndTarget, {
3519
+ choice: choice,
3520
+ index: index,
3521
+ key: index,
3522
+ imageSupport: imageSupport,
3523
+ onDelete: this.onDelete.bind(this, choice),
3524
+ onChoiceChange: this.onChoiceChange,
3525
+ onDropChoice: (source, index) => this.onDropChoice(ordering, choice, source, index),
3526
+ toolbarOpts: toolbarOpts,
3527
+ pluginProps: pluginProps,
3528
+ choices: choices,
3529
+ choicesLabel: choicesLabel,
3530
+ spellCheck: spellCheck,
3531
+ maxImageWidth: maxImageWidth,
3532
+ maxImageHeight: maxImageHeight,
3533
+ error: (choicesErrors == null ? void 0 : choicesErrors[choice.id]) || orderError && ' ' || null,
3534
+ mathMlOptions: mathMlOptions
3535
+ }))), orderError && /*#__PURE__*/React.createElement("div", {
3536
+ className: classes.errorText
3537
+ }, orderError), /*#__PURE__*/React.createElement("div", {
3538
+ className: classes.controls
3539
+ }, /*#__PURE__*/React.createElement(Button, {
3540
+ onClick: this.shuffleChoices,
3541
+ size: "small",
3542
+ variant: "contained",
3543
+ color: "default",
3544
+ classes: {
3545
+ root: classes.addButtonRoot,
3546
+ label: classes.addButtonLabel
3547
+ }
3548
+ }, `SHUFFLE ${pluralChoiceLabel}`.toUpperCase()), /*#__PURE__*/React.createElement(Button, {
3549
+ onClick: this.addChoice,
3550
+ size: "small",
3551
+ variant: "contained",
3552
+ color: "default",
3553
+ classes: {
3554
+ root: classes.addButtonRoot,
3555
+ label: classes.addButtonLabel
3556
+ }
3557
+ }, `ADD ${singularChoiceLabel}`.toUpperCase())), /*#__PURE__*/React.createElement(AlertDialog, {
3558
+ open: warning.open,
3559
+ title: "Warning",
3560
+ text: warning.text,
3561
+ onConfirm: () => this.setState({
3562
+ warning: {
3563
+ open: false
3564
+ }
3565
+ })
3566
+ }));
3567
+ }
3568
+
3569
+ }
3570
+
3571
+ ChoiceEditor.propTypes = {
3572
+ classes: PropTypes.object.isRequired,
3573
+ correctResponse: PropTypes.array.isRequired,
3574
+ choices: PropTypes.array.isRequired,
3575
+ onChange: PropTypes.func.isRequired,
3576
+ imageSupport: PropTypes.shape({
3577
+ add: PropTypes.func.isRequired,
3578
+ delete: PropTypes.func.isRequired
3579
+ }),
3580
+ maxImageHeight: PropTypes.object,
3581
+ maxImageWidth: PropTypes.object,
3582
+ toolbarOpts: PropTypes.object,
3583
+ pluginProps: PropTypes.object,
3584
+ placementArea: PropTypes.bool,
3585
+ singularChoiceLabel: PropTypes.string,
3586
+ pluralChoiceLabel: PropTypes.string,
3587
+ choicesLabel: PropTypes.string,
3588
+ errors: PropTypes.object,
3589
+ spellCheck: PropTypes.bool
3590
+ };
3591
+
3592
+ const styles = theme => ({
3593
+ allToggle: {},
3594
+ choiceEditor: {},
3595
+ controls: {
3596
+ display: 'flex',
3597
+ alignItems: 'center',
3598
+ justifyContent: 'space-between'
3599
+ },
3600
+ root: {
3601
+ width: '30px',
3602
+ height: '30px',
3603
+ fill: theme.palette.primary[500]
3604
+ },
3605
+ addButtonRoot: {
3606
+ marginTop: theme.spacing.unit * 2.5,
3607
+ paddingHorizontal: theme.spacing.unit * 1.5
3608
+ },
3609
+ addButtonLabel: {
3610
+ transition: 'opacity 200ms linear',
3611
+ '&:hover': {
3612
+ opacity: 0.3
3613
+ }
3614
+ },
3615
+ vtiler: {
3616
+ gridAutoFlow: 'column',
3617
+ display: 'grid',
3618
+ gridGap: '10px',
3619
+ alignItems: 'center'
3620
+ },
3621
+ columnLabel: {
3622
+ width: '100%',
3623
+ paddingTop: theme.spacing.unit * 2
3624
+ },
3625
+ errorText: {
3626
+ fontSize: theme.typography.fontSize - 2,
3627
+ color: theme.palette.error.main,
3628
+ paddingTop: theme.spacing.unit
3629
+ }
3630
+ });
3631
+
3632
+ var ChoiceEditor$1 = withStyles(styles)(ChoiceEditor);
3633
+
3634
+ const generateValidationMessage = () => {
3635
+ const answersMessage = '\nThere should be at least 3 tokens.' + '\nThe tokens should not be empty and should be unique.' + '\nThe correct ordering should not be identical to the initial ordering.';
3636
+ return 'Validation requirements:' + answersMessage;
3637
+ };
3638
+
3639
+ const log = debug('@pie-element:placement-ordering:design');
3640
+ const {
3641
+ Panel,
3642
+ toggle,
3643
+ radio,
3644
+ dropdown
3645
+ } = settings;
3646
+
3647
+ const getSingularAndPlural = label => !pluralize.isPlural(label) ? {
3648
+ singularLabel: label,
3649
+ pluralLabel: pluralize(label)
3650
+ } : {
3651
+ singularLabel: pluralize.singular(label),
3652
+ pluralLabel: label
3653
+ };
3654
+
3655
+ class Design extends React.Component {
3656
+ constructor(props) {
3657
+ super(props);
3658
+
3659
+ this.applyUpdate = modelFn => {
3660
+ const {
3661
+ model,
3662
+ onModelChanged
3663
+ } = this.props;
3664
+ const update = modelFn(cloneDeep(model));
3665
+ onModelChanged(update);
3666
+ };
3667
+
3668
+ this.changeHandler = (modelPath, valuePath) => {
3669
+ return value => {
3670
+ log('[changeHandler] value: ', value);
3671
+ const v = valuePath ? nestedProperty.get(value, valuePath) : value;
3672
+ this.applyUpdate(model => {
3673
+ nestedProperty.set(model, modelPath, v);
3674
+ return model;
3675
+ });
3676
+ };
3677
+ };
3678
+
3679
+ this.onPromptChange = this.changeHandler('prompt');
3680
+ this.onTeacherInstructionsChange = this.changeHandler('teacherInstructions');
3681
+ this.onRationaleChange = this.changeHandler('rationale');
3682
+ this.onChoiceAreaLabelChange = this.changeHandler('choiceLabel', 'target.value');
3683
+ this.onAnswerAreaLabelChange = this.changeHandler('targetLabel', 'target.value');
3684
+ this.onFeedbackChange = this.changeHandler('feedback');
3685
+
3686
+ this.onChoiceEditorChange = (choices, correctResponse) => {
3687
+ const {
3688
+ model,
3689
+ onModelChanged
3690
+ } = this.props;
3691
+ const update = cloneDeep(model);
3692
+ update.choices = choices;
3693
+ update.correctResponse = correctResponse;
3694
+ onModelChanged(update);
3695
+ };
3696
+ }
3697
+
3698
+ componentDidMount() {
3699
+ const {
3700
+ model,
3701
+ onModelChanged
3702
+ } = this.props || {};
3703
+ const {
3704
+ feedback
3705
+ } = model || {};
3706
+ const update = cloneDeep(model); // requirement made in PD-2182
3707
+
3708
+ if (!feedback) {
3709
+ update.feedbackEnabled = false;
3710
+ onModelChanged(update);
3711
+ }
3712
+ }
3713
+
3714
+ render() {
3715
+ const {
3716
+ model,
3717
+ classes,
3718
+ imageSupport,
3719
+ uploadSoundSupport,
3720
+ onModelChanged,
3721
+ configuration,
3722
+ onConfigurationChanged
3723
+ } = this.props;
3724
+ const {
3725
+ baseInputConfiguration = {},
3726
+ choiceLabel = {},
3727
+ choices = {},
3728
+ contentDimensions = {},
3729
+ feedback = {},
3730
+ prompt = {},
3731
+ placementArea = {},
3732
+ maxImageWidth = {},
3733
+ maxImageHeight = {},
3734
+ numberedGuides = {},
3735
+ orientation = {},
3736
+ partialScoring = {},
3737
+ rationale = {},
3738
+ removeTilesAfterPlacing = {},
3739
+ settingsPanelDisabled,
3740
+ studentInstructions = {},
3741
+ spellCheck = {},
3742
+ scoringType = {},
3743
+ targetLabel = {},
3744
+ teacherInstructions = {},
3745
+ withRubric = {},
3746
+ mathMlOptions = {},
3747
+ language = {},
3748
+ languageChoices = {}
3749
+ } = configuration || {};
3750
+ const {
3751
+ choiceLabelEnabled,
3752
+ errors,
3753
+ extraCSSRules,
3754
+ feedbackEnabled,
3755
+ promptEnabled,
3756
+ rationaleEnabled,
3757
+ spellCheckEnabled,
3758
+ teacherInstructionsEnabled,
3759
+ toolbarEditorPosition
3760
+ } = model || {};
3761
+ const {
3762
+ prompt: promptError,
3763
+ rationale: rationaleError,
3764
+ teacherInstructions: teacherInstructionsError
3765
+ } = errors || {};
3766
+ const validationMessage = generateValidationMessage();
3767
+ const {
3768
+ singularLabel = '',
3769
+ pluralLabel = ''
3770
+ } = (choices == null ? void 0 : choices.label) && getSingularAndPlural(choices.label) || {};
3771
+ const defaultImageMaxWidth = maxImageWidth && maxImageWidth.prompt;
3772
+ const defaultImageMaxHeight = maxImageHeight && maxImageHeight.prompt;
3773
+ const maxChoicesImageWidth = maxImageWidth && model.placementArea ? maxImageWidth.choicesWithPlacementArea : maxImageWidth.choicesWithoutPlacementArea || defaultImageMaxWidth;
3774
+ const maxChoicesImageHeight = maxImageHeight && maxImageHeight.choices || defaultImageMaxHeight;
3775
+ const toolbarOpts = {
3776
+ position: toolbarEditorPosition === 'top' ? 'top' : 'bottom'
3777
+ };
3778
+ const panelSettings = {
3779
+ choiceLabelEnabled: choiceLabel.settings && toggle(choiceLabel.label),
3780
+ placementArea: placementArea.settings && toggle(placementArea.label),
3781
+ numberedGuides: numberedGuides.settings && model.placementArea && toggle(numberedGuides.label),
3782
+ orientation: orientation.settings && radio(orientation.label, ['vertical', 'horizontal']),
3783
+ removeTilesAfterPlacing: removeTilesAfterPlacing.settings && toggle(removeTilesAfterPlacing.label),
3784
+ partialScoring: partialScoring.settings && toggle(partialScoring.label),
3785
+ feedbackEnabled: feedback.settings && toggle(feedback.label),
3786
+ 'language.enabled': language.settings && toggle(language.label, true),
3787
+ language: language.settings && language.enabled && dropdown(languageChoices.label, languageChoices.options)
3788
+ };
3789
+ const panelProperties = {
3790
+ teacherInstructionsEnabled: teacherInstructions.settings && toggle(teacherInstructions.label),
3791
+ studentInstructionsEnabled: studentInstructions.settings && toggle(studentInstructions.label),
3792
+ rationaleEnabled: rationale.settings && toggle(rationale.label),
3793
+ promptEnabled: prompt.settings && toggle(prompt.label),
3794
+ spellCheckEnabled: spellCheck.settings && toggle(spellCheck.label),
3795
+ scoringType: scoringType.settings && radio(scoringType.label, ['auto', 'rubric']),
3796
+ rubricEnabled: (withRubric == null ? void 0 : withRubric.settings) && toggle(withRubric == null ? void 0 : withRubric.label)
3797
+ };
3798
+
3799
+ const getPluginProps = (props = {}) => _extends({}, baseInputConfiguration, props);
3800
+
3801
+ return /*#__PURE__*/React.createElement(layout.ConfigLayout, {
3802
+ extraCSSRules: extraCSSRules,
3803
+ dimensions: contentDimensions,
3804
+ hideSettings: settingsPanelDisabled,
3805
+ settings: /*#__PURE__*/React.createElement(Panel, {
3806
+ model: model,
3807
+ configuration: configuration,
3808
+ onChangeModel: model => onModelChanged(model),
3809
+ onChangeConfiguration: configuration => onConfigurationChanged(configuration, true),
3810
+ groups: {
3811
+ Settings: panelSettings,
3812
+ Properties: panelProperties
3813
+ }
3814
+ })
3815
+ }, teacherInstructionsEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
3816
+ label: teacherInstructions.label,
3817
+ className: classes.promptHolder
3818
+ }, /*#__PURE__*/React.createElement(EditableHtml, {
3819
+ className: classes.prompt,
3820
+ markup: model.teacherInstructions || '',
3821
+ onChange: this.onTeacherInstructionsChange,
3822
+ imageSupport: imageSupport,
3823
+ nonEmpty: false,
3824
+ error: teacherInstructionsError,
3825
+ toolbarOpts: toolbarOpts,
3826
+ pluginProps: getPluginProps(teacherInstructions == null ? void 0 : teacherInstructions.inputConfiguration),
3827
+ spellCheck: spellCheckEnabled,
3828
+ maxImageWidth: maxImageWidth && maxImageWidth.teacherInstructions || defaultImageMaxWidth,
3829
+ maxImageHeight: maxImageHeight && maxImageHeight.teacherInstructions || defaultImageMaxHeight,
3830
+ uploadSoundSupport: uploadSoundSupport,
3831
+ languageCharactersProps: [{
3832
+ language: 'spanish'
3833
+ }, {
3834
+ language: 'special'
3835
+ }],
3836
+ mathMlOptions: mathMlOptions
3837
+ }), teacherInstructionsError && /*#__PURE__*/React.createElement("div", {
3838
+ className: classes.errorText
3839
+ }, teacherInstructionsError)), promptEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
3840
+ label: prompt && prompt.label,
3841
+ className: classes.promptHolder
3842
+ }, /*#__PURE__*/React.createElement(EditableHtml, {
3843
+ className: classes.prompt,
3844
+ markup: model.prompt,
3845
+ onChange: this.onPromptChange,
3846
+ imageSupport: imageSupport,
3847
+ error: promptError,
3848
+ toolbarOpts: toolbarOpts,
3849
+ pluginProps: getPluginProps(prompt == null ? void 0 : prompt.inputConfiguration),
3850
+ spellCheck: spellCheckEnabled,
3851
+ maxImageWidth: maxImageWidth && maxImageWidth.prompt,
3852
+ maxImageHeight: maxImageHeight && maxImageHeight.prompt,
3853
+ uploadSoundSupport: uploadSoundSupport,
3854
+ languageCharactersProps: [{
3855
+ language: 'spanish'
3856
+ }, {
3857
+ language: 'special'
3858
+ }],
3859
+ mathMlOptions: mathMlOptions
3860
+ }), promptError && /*#__PURE__*/React.createElement("div", {
3861
+ className: classes.errorText
3862
+ }, promptError)), /*#__PURE__*/React.createElement(FormSection, {
3863
+ className: classes.choicesWrapper,
3864
+ label: `Define ${pluralLabel}`,
3865
+ labelExtraStyle: {
3866
+ display: 'inline-flex'
3867
+ }
3868
+ }, /*#__PURE__*/React.createElement("div", {
3869
+ className: classes.inlineFlexContainer
3870
+ }, /*#__PURE__*/React.createElement(Tooltip, {
3871
+ classes: {
3872
+ tooltip: classes.tooltip
3873
+ },
3874
+ disableFocusListener: true,
3875
+ disableTouchListener: true,
3876
+ placement: 'right',
3877
+ title: validationMessage
3878
+ }, /*#__PURE__*/React.createElement(default_1$2, {
3879
+ fontSize: 'small',
3880
+ color: 'primary',
3881
+ style: {
3882
+ marginLeft: '8px'
3883
+ }
3884
+ }))), /*#__PURE__*/React.createElement("div", {
3885
+ className: classes.row
3886
+ }, choiceLabelEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
3887
+ label: choiceLabel && choiceLabel.label && `${singularLabel} label`,
3888
+ className: classes.promptHolder
3889
+ }, /*#__PURE__*/React.createElement(EditableHtml, _extends({}, model.placementArea && {
3890
+ autoWidthToolbar: true
3891
+ }, {
3892
+ className: classes.prompt,
3893
+ markup: model.choiceLabel,
3894
+ onChange: this.onChoiceAreaLabelChange,
3895
+ toolbarOpts: toolbarOpts,
3896
+ pluginProps: getPluginProps(choiceLabel == null ? void 0 : choiceLabel.inputConfiguration),
3897
+ spellCheck: spellCheckEnabled,
3898
+ maxImageWidth: maxChoicesImageWidth,
3899
+ maxImageHeight: maxChoicesImageHeight,
3900
+ uploadSoundSupport: uploadSoundSupport,
3901
+ languageCharactersProps: [{
3902
+ language: 'spanish'
3903
+ }, {
3904
+ language: 'special'
3905
+ }],
3906
+ mathMlOptions: mathMlOptions
3907
+ }))), targetLabel.settings && model.placementArea && /*#__PURE__*/React.createElement(InputContainer$1, {
3908
+ label: targetLabel && targetLabel.label && targetLabel.label,
3909
+ className: classes.promptHolder
3910
+ }, /*#__PURE__*/React.createElement(EditableHtml, {
3911
+ autoWidthToolbar: true,
3912
+ className: classes.prompt,
3913
+ markup: model.targetLabel,
3914
+ onChange: this.onAnswerAreaLabelChange,
3915
+ toolbarOpts: toolbarOpts,
3916
+ spellCheck: spellCheckEnabled,
3917
+ maxImageWidth: maxImageWidth && maxImageWidth.choicesWithPlacementArea || defaultImageMaxWidth,
3918
+ maxImageHeight: maxChoicesImageHeight,
3919
+ uploadSoundSupport: uploadSoundSupport,
3920
+ languageCharactersProps: [{
3921
+ language: 'spanish'
3922
+ }, {
3923
+ language: 'special'
3924
+ }],
3925
+ mathMlOptions: mathMlOptions
3926
+ }))), choices.settings && /*#__PURE__*/React.createElement(ChoiceEditor$1, {
3927
+ correctResponse: model.correctResponse,
3928
+ choices: model.choices,
3929
+ onChange: this.onChoiceEditorChange,
3930
+ imageSupport: imageSupport,
3931
+ toolbarOpts: toolbarOpts,
3932
+ pluginProps: getPluginProps(choices == null ? void 0 : choices.inputConfiguration),
3933
+ choicesLabel: choices.label,
3934
+ placementArea: model.placementArea,
3935
+ singularChoiceLabel: singularLabel,
3936
+ pluralChoiceLabel: pluralLabel,
3937
+ spellCheck: spellCheckEnabled,
3938
+ maxImageWidth: maxChoicesImageWidth,
3939
+ maxImageHeight: maxChoicesImageHeight,
3940
+ errors: errors || {},
3941
+ mathMlOptions: mathMlOptions
3942
+ })), rationaleEnabled && /*#__PURE__*/React.createElement(InputContainer$1, {
3943
+ label: rationale.label,
3944
+ className: classes.promptHolder
3945
+ }, /*#__PURE__*/React.createElement(EditableHtml, {
3946
+ className: classes.prompt,
3947
+ markup: model.rationale || '',
3948
+ onChange: this.onRationaleChange,
3949
+ imageSupport: imageSupport,
3950
+ error: rationaleError,
3951
+ toolbarOpts: toolbarOpts,
3952
+ pluginProps: getPluginProps(rationale == null ? void 0 : rationale.inputConfiguration),
3953
+ spellCheck: spellCheckEnabled,
3954
+ maxImageWidth: maxImageWidth && maxImageWidth.rationale || defaultImageMaxWidth,
3955
+ maxImageHeight: maxImageHeight && maxImageHeight.rationale || defaultImageMaxHeight,
3956
+ uploadSoundSupport: uploadSoundSupport,
3957
+ languageCharactersProps: [{
3958
+ language: 'spanish'
3959
+ }, {
3960
+ language: 'special'
3961
+ }],
3962
+ mathMlOptions: mathMlOptions
3963
+ }), rationaleError && /*#__PURE__*/React.createElement("div", {
3964
+ className: classes.errorText
3965
+ }, rationaleError)), feedbackEnabled && /*#__PURE__*/React.createElement(FeedbackConfig, {
3966
+ feedback: model.feedback,
3967
+ onChange: this.onFeedbackChange,
3968
+ imageSupport: imageSupport,
3969
+ toolbarOpts: toolbarOpts
3970
+ }));
3971
+ }
3972
+
3973
+ }
3974
+ Design.propTypes = {
3975
+ uploadSoundSupport: PropTypes.object
3976
+ };
3977
+ Design.defaultProps = {};
3978
+ Design.defaultProps = {
3979
+ onModelChanged: () => {},
3980
+ onConfigurationChanged: () => {}
3981
+ };
3982
+ Design.propTypes = {
3983
+ model: PropTypes.object.isRequired,
3984
+ configuration: PropTypes.object.isRequired,
3985
+ onModelChanged: PropTypes.func,
3986
+ onConfigurationChanged: PropTypes.func,
3987
+ classes: PropTypes.object.isRequired,
3988
+ imageSupport: PropTypes.object
3989
+ };
3990
+ var Main = withDragContext(withStyles(theme => ({
3991
+ promptHolder: {
3992
+ width: '100%',
3993
+ paddingTop: theme.spacing.unit * 2,
3994
+ marginBottom: theme.spacing.unit * 2
3995
+ },
3996
+ row: {
3997
+ display: 'grid',
3998
+ gridAutoFlow: 'column',
3999
+ gridAutoColumns: '1fr',
4000
+ gridGap: '8px'
4001
+ },
4002
+ choicesWrapper: {
4003
+ marginTop: 0,
4004
+ marginBottom: theme.spacing.unit * 2.5
4005
+ },
4006
+ tooltip: {
4007
+ fontSize: theme.typography.fontSize - 2,
4008
+ whiteSpace: 'pre',
4009
+ maxWidth: '500px'
4010
+ },
4011
+ inlineFlexContainer: {
4012
+ display: 'inline-flex',
4013
+ position: 'absolute'
4014
+ },
4015
+ errorText: {
4016
+ fontSize: theme.typography.fontSize - 2,
4017
+ color: theme.palette.error.main,
4018
+ paddingTop: theme.spacing.unit
4019
+ }
4020
+ }))(Design));
4021
+
4022
+ /** NOTE: teacherInstructions, studentInstructions, rationale & scoringType
4023
+ * functionalities are not defined yet - the value for those can belong to
4024
+ * model or to configuration
4025
+ */
4026
+ var defaultValues = {
4027
+ model: {
4028
+ choiceLabel: '',
4029
+ choiceLabelEnabled: true,
4030
+ choices: [],
4031
+ correctResponse: [],
4032
+ feedbackEnabled: false,
4033
+ numberedGuides: false,
4034
+ orientation: 'vertical',
4035
+ partialScoring: true,
4036
+ placementArea: false,
4037
+ prompt: '',
4038
+ promptEnabled: true,
4039
+ rationale: '',
4040
+ rationaleEnabled: true,
4041
+ removeTilesAfterPlacing: true,
4042
+ scoringType: 'auto',
4043
+ studentInstructionsEnabled: true,
4044
+ targetLabel: '',
4045
+ teacherInstructions: '',
4046
+ teacherInstructionsEnabled: true,
4047
+ toolbarEditorPosition: 'bottom'
4048
+ },
4049
+ configuration: {
4050
+ baseInputConfiguration: {
4051
+ audio: {
4052
+ disabled: false
4053
+ },
4054
+ video: {
4055
+ disabled: false
4056
+ },
4057
+ image: {
4058
+ disabled: false
4059
+ },
4060
+ textAlign: {
4061
+ disabled: true
4062
+ },
4063
+ showParagraphs: {
4064
+ disabled: false
4065
+ },
4066
+ separateParagraphs: {
4067
+ disabled: true
4068
+ }
4069
+ },
4070
+ choiceLabel: {
4071
+ settings: true,
4072
+ label: 'Choice label',
4073
+ inputConfiguration: {
4074
+ audio: {
4075
+ disabled: false
4076
+ },
4077
+ video: {
4078
+ disabled: false
4079
+ },
4080
+ image: {
4081
+ disabled: false
4082
+ }
4083
+ }
4084
+ },
4085
+ choices: {
4086
+ settings: true,
4087
+ label: 'Choices',
4088
+ inputConfiguration: {
4089
+ audio: {
4090
+ disabled: true
4091
+ },
4092
+ video: {
4093
+ disabled: true
4094
+ },
4095
+ image: {
4096
+ disabled: true
4097
+ }
4098
+ }
4099
+ },
4100
+ feedback: {
4101
+ settings: true,
4102
+ label: 'Feedback',
4103
+ enabled: true
4104
+ },
4105
+ prompt: {
4106
+ settings: true,
4107
+ label: 'Item Stem',
4108
+ required: false,
4109
+ inputConfiguration: {
4110
+ audio: {
4111
+ disabled: false
4112
+ },
4113
+ video: {
4114
+ disabled: false
4115
+ },
4116
+ image: {
4117
+ disabled: false
4118
+ }
4119
+ }
4120
+ },
4121
+ numberedGuides: {
4122
+ settings: true,
4123
+ label: 'Numbered guides'
4124
+ },
4125
+ orientation: {
4126
+ settings: true,
4127
+ label: 'Orientation'
4128
+ },
4129
+ partialScoring: {
4130
+ settings: false,
4131
+ label: 'Allow Partial Scoring'
4132
+ },
4133
+ placementArea: {
4134
+ settings: true,
4135
+ label: 'Placement Area'
4136
+ },
4137
+ rationale: {
4138
+ settings: true,
4139
+ label: 'Rationale',
4140
+ required: false,
4141
+ inputConfiguration: {
4142
+ audio: {
4143
+ disabled: false
4144
+ },
4145
+ video: {
4146
+ disabled: false
4147
+ },
4148
+ image: {
4149
+ disabled: false
4150
+ }
4151
+ }
4152
+ },
4153
+ removeTilesAfterPlacing: {
4154
+ settings: false,
4155
+ label: 'Remove Tiles after placing'
4156
+ },
4157
+ settingsPanelDisabled: false,
4158
+ scoringType: {
4159
+ settings: false,
4160
+ label: 'Scoring Type'
4161
+ },
4162
+ studentInstructions: {
4163
+ settings: false,
4164
+ label: 'Student Instructions'
4165
+ },
4166
+ targetLabel: {
4167
+ settings: true,
4168
+ label: 'Target label'
4169
+ },
4170
+ spellCheck: {
4171
+ label: 'Spellcheck',
4172
+ settings: false,
4173
+ enabled: true
4174
+ },
4175
+ teacherInstructions: {
4176
+ settings: true,
4177
+ label: 'Teacher Instructions',
4178
+ required: false,
4179
+ inputConfiguration: {
4180
+ audio: {
4181
+ disabled: false
4182
+ },
4183
+ video: {
4184
+ disabled: false
4185
+ },
4186
+ image: {
4187
+ disabled: false
4188
+ }
4189
+ }
4190
+ },
4191
+ maxImageWidth: {
4192
+ teacherInstructions: 300,
4193
+ prompt: 300,
4194
+ rationale: 300,
4195
+ choicesWithPlacementArea: 240,
4196
+ choicesWithoutPlacementArea: 300
4197
+ },
4198
+ maxImageHeight: {
4199
+ teacherInstructions: 300,
4200
+ prompt: 300,
4201
+ rationale: 300,
4202
+ choices: 150
4203
+ },
4204
+ withRubric: {
4205
+ settings: false,
4206
+ label: 'Add Rubric'
4207
+ },
4208
+ mathMlOptions: {
4209
+ mmlOutput: false,
4210
+ mmlEditing: false
4211
+ },
4212
+ language: {
4213
+ settings: false,
4214
+ label: 'Specify Language',
4215
+ enabled: false
4216
+ },
4217
+ languageChoices: {
4218
+ label: 'Language Choices',
4219
+ options: []
4220
+ }
4221
+ }
4222
+ };
4223
+
4224
+ const prepareCustomizationObject = (config, model) => {
4225
+ const configuration = defaults(config, defaultValues.configuration);
4226
+ return {
4227
+ configuration,
4228
+ model
4229
+ };
4230
+ };
4231
+
4232
+ const addWeightToCorrectResponse = correctResponse => correctResponse && correctResponse.map(correct => {
4233
+ // if weight is set
4234
+ if (correct.weight !== undefined) {
4235
+ return {
4236
+ id: correct.id,
4237
+ weight: correct.weight
4238
+ };
4239
+ } else {
4240
+ return {
4241
+ id: correct.id || correct,
4242
+ weight: 0
4243
+ };
4244
+ }
4245
+ });
4246
+ /**
4247
+ * assuming that the correct response will be set via ui, not via config,
4248
+ * correctResponse (if not set) will be initialized with choices default order
4249
+ */
4250
+
4251
+ class PlacementOrdering extends HTMLElement {
4252
+ constructor() {
4253
+ super();
4254
+ this._model = PlacementOrdering.createDefaultModel();
4255
+ this._configuration = defaultValues.configuration;
4256
+
4257
+ this.onModelChanged = (model, resetSession) => {
4258
+ this._model = model;
4259
+
4260
+ this._rerender();
4261
+
4262
+ this.dispatchUpdate(resetSession);
4263
+ };
4264
+
4265
+ this.onConfigurationChanged = configuration => {
4266
+ this._configuration = prepareCustomizationObject(configuration).configuration;
4267
+ this.onModelChanged(this._model);
4268
+
4269
+ this._rerender();
4270
+ };
4271
+
4272
+ this.insertImage = handler => {
4273
+ this.dispatchEvent(new InsertImageEvent(handler));
4274
+ };
4275
+
4276
+ this.deleteImage = (src, done) => {
4277
+ this.dispatchEvent(new DeleteImageEvent(src, done));
4278
+ };
4279
+ }
4280
+
4281
+ dispatchUpdate(reset) {
4282
+ this.dispatchEvent(new ModelUpdatedEvent(this._model, reset));
4283
+ }
4284
+
4285
+ set model(s) {
4286
+ this._model = PlacementOrdering.createDefaultModel(s);
4287
+
4288
+ this._rerender();
4289
+ }
4290
+
4291
+ set configuration(c) {
4292
+ var _newConfiguration$lan;
4293
+
4294
+ const info = prepareCustomizationObject(c, this._model);
4295
+ this.onModelChanged(info.model);
4296
+
4297
+ const newConfiguration = _extends({}, defaultValues.configuration, info.configuration);
4298
+
4299
+ this._configuration = newConfiguration; // if language:enabled is true, then the corresponding default item model should include a language value;
4300
+ // if it is false, then the language field should be omitted from the item model.
4301
+ // if a default item model includes a language value (e.g., en_US) and the corresponding authoring view settings have language:settings = true,
4302
+ // then (a) language:enabled should also be true, and (b) that default language value should be represented in languageChoices[] (as a key).
4303
+
4304
+ if (newConfiguration != null && (_newConfiguration$lan = newConfiguration.language) != null && _newConfiguration$lan.enabled) {
4305
+ var _newConfiguration$lan2, _newConfiguration$lan3;
4306
+
4307
+ if (newConfiguration != null && (_newConfiguration$lan2 = newConfiguration.languageChoices) != null && (_newConfiguration$lan3 = _newConfiguration$lan2.options) != null && _newConfiguration$lan3.length) {
4308
+ this._model.language = newConfiguration == null ? void 0 : newConfiguration.languageChoices.options[0].value;
4309
+ }
4310
+ } else if (newConfiguration.language.settings && this._model.language) {
4311
+ this._configuration.language.enabled = true;
4312
+
4313
+ if (!this._configuration.languageChoices.options || !this._configuration.languageChoices.options.length) {
4314
+ this._configuration.languageChoices.options = [];
4315
+ } // check if the language is already included in the languageChoices.options array
4316
+ // and if not, then add it.
4317
+
4318
+
4319
+ if (!this._configuration.languageChoices.options.find(option => option.value === this._model.language)) {
4320
+ this._configuration.languageChoices.options.push({
4321
+ value: this._model.language,
4322
+ label: this._model.language
4323
+ });
4324
+ }
4325
+ } else {
4326
+ delete this._model.language;
4327
+ }
4328
+
4329
+ this._rerender();
4330
+ }
4331
+
4332
+ insertSound(handler) {
4333
+ this.dispatchEvent(new InsertSoundEvent(handler));
4334
+ }
4335
+
4336
+ onDeleteSound(src, done) {
4337
+ this.dispatchEvent(new DeleteSoundEvent(src, done));
4338
+ }
4339
+
4340
+ _rerender() {
4341
+ let element = /*#__PURE__*/React.createElement(Main, {
4342
+ model: this._model,
4343
+ configuration: this._configuration,
4344
+ onModelChanged: this.onModelChanged,
4345
+ onConfigurationChanged: this.onConfigurationChanged,
4346
+ imageSupport: {
4347
+ add: this.insertImage,
4348
+ delete: this.deleteImage
4349
+ },
4350
+ uploadSoundSupport: {
4351
+ add: this.insertSound.bind(this),
4352
+ delete: this.onDeleteSound.bind(this)
4353
+ }
4354
+ });
4355
+ ReactDOM.render(element, this);
4356
+ }
4357
+
4358
+ }
4359
+
4360
+ PlacementOrdering.createDefaultModel = (model = {}) => {
4361
+ const mapChoicesToReturnCorrectResponse = choices => choices && choices.map(ch => ({
4362
+ id: ch.id,
4363
+ weight: 0
4364
+ }));
4365
+
4366
+ let correctResponse = addWeightToCorrectResponse(model.correctResponse) || mapChoicesToReturnCorrectResponse(model.choices);
4367
+
4368
+ const defaultModel = _extends({}, defaultValues.model, model);
4369
+
4370
+ if (correctResponse) {
4371
+ defaultModel.correctResponse = correctResponse;
4372
+ }
4373
+
4374
+ return defaultModel;
4375
+ };
4376
+
4377
+ export { addWeightToCorrectResponse, PlacementOrdering as default };
4378
+ //# sourceMappingURL=configure.js.map