@pie-element/select-text 6.5.2 → 6.5.3-next.1008

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/module/element.js DELETED
@@ -1,2617 +0,0 @@
1
- import {_dll_react, _dll_prop_types, _dll_material_ui__core, _dll_material_ui__core_styles, _dll_lodash, _dll_pie_lib__render_ui, _dll_react_dom_server, _dll_pie_lib__correct_answer_toggle, _dll_react_dom, _dll_pie_framework__pie_player_events, _dll_pie_lib__math_rendering} from "../../../@pie-ui/shared-lib@^4.3.3/module/index.js";
2
- const React = _dll_react;
3
- const PropTypes = _dll_prop_types;
4
- const {Button: Button} = _dll_material_ui__core;
5
- const {Switch: Switch} = _dll_material_ui__core;
6
- const {FormControlLabel: FormControlLabel} = _dll_material_ui__core;
7
- const {withStyles: withStyles} = _dll_material_ui__core_styles;
8
- const _jsxFileName = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/tokenizer/controls.jsx";
9
- class Controls extends React.Component {
10
- static __initStatic() {
11
- this.propTypes = {
12
- classes: PropTypes.object.isRequired,
13
- onClear: PropTypes.func.isRequired,
14
- onWords: PropTypes.func.isRequired,
15
- onSentences: PropTypes.func.isRequired,
16
- onParagraphs: PropTypes.func.isRequired,
17
- setCorrectMode: PropTypes.bool.isRequired,
18
- onToggleCorrectMode: PropTypes.func.isRequired
19
- };
20
- }
21
- static __initStatic2() {
22
- this.defaultProps = {};
23
- }
24
- render() {
25
- const {classes, onClear, onWords, onSentences, onParagraphs, setCorrectMode, onToggleCorrectMode} = this.props;
26
- return React.createElement('div', {
27
- className: classes.controls,
28
- __self: this,
29
- __source: {
30
- fileName: _jsxFileName,
31
- lineNumber: 33
32
- }
33
- }, React.createElement('div', {
34
- __self: this,
35
- __source: {
36
- fileName: _jsxFileName,
37
- lineNumber: 34
38
- }
39
- }, React.createElement(Button, {
40
- onClick: onWords,
41
- className: classes.button,
42
- size: "small",
43
- color: "primary",
44
- disabled: setCorrectMode,
45
- __self: this,
46
- __source: {
47
- fileName: _jsxFileName,
48
- lineNumber: 35
49
- }
50
- }, "Words"), React.createElement(Button, {
51
- onClick: onSentences,
52
- className: classes.button,
53
- size: "small",
54
- color: "primary",
55
- disabled: setCorrectMode,
56
- __self: this,
57
- __source: {
58
- fileName: _jsxFileName,
59
- lineNumber: 44
60
- }
61
- }, "Sentences"), React.createElement(Button, {
62
- onClick: onParagraphs,
63
- className: classes.button,
64
- size: "small",
65
- color: "primary",
66
- disabled: setCorrectMode,
67
- __self: this,
68
- __source: {
69
- fileName: _jsxFileName,
70
- lineNumber: 53
71
- }
72
- }, "Paragraphs"), React.createElement(Button, {
73
- className: classes.button,
74
- size: "small",
75
- color: "secondary",
76
- onClick: onClear,
77
- disabled: setCorrectMode,
78
- __self: this,
79
- __source: {
80
- fileName: _jsxFileName,
81
- lineNumber: 62
82
- }
83
- }, "Clear")), React.createElement(FormControlLabel, {
84
- control: React.createElement(Switch, {
85
- checked: setCorrectMode,
86
- onChange: onToggleCorrectMode,
87
- __self: this,
88
- __source: {
89
- fileName: _jsxFileName,
90
- lineNumber: 73
91
- }
92
- }),
93
- label: "Set correct answers",
94
- __self: this,
95
- __source: {
96
- fileName: _jsxFileName,
97
- lineNumber: 72
98
- }
99
- }));
100
- }
101
- }
102
- Controls.__initStatic();
103
- Controls.__initStatic2();
104
- var Controls$1 = withStyles(theme => ({
105
- button: {
106
- marginRight: theme.spacing.unit
107
- },
108
- controls: {
109
- display: 'flex',
110
- alignItems: 'center',
111
- justifyContent: 'space-between'
112
- }
113
- }))(Controls);
114
- var nlcstToString_1 = nlcstToString;
115
- function nlcstToString(node, separator) {
116
- var sep = separator || '';
117
- var values;
118
- var length;
119
- var children;
120
- if (!node || !(('length' in node)) && !node.type) {
121
- throw new Error('Expected node, not `' + node + '`');
122
- }
123
- if (typeof node.value === 'string') {
124
- return node.value;
125
- }
126
- children = ('length' in node) ? node : node.children;
127
- length = children.length;
128
- if (length === 1 && ('value' in children[0])) {
129
- return children[0].value;
130
- }
131
- values = [];
132
- while (length--) {
133
- values[length] = nlcstToString(children[length], sep);
134
- }
135
- return values.join(sep);
136
- }
137
- var unistUtilVisitChildren = visitChildren;
138
- function visitChildren(callback) {
139
- return visitor;
140
- function visitor(parent) {
141
- var index = -1;
142
- var children = parent && parent.children;
143
- if (!children) {
144
- throw new Error('Missing children in `parent` for `visitor`');
145
- }
146
- while ((++index in children)) {
147
- callback(children[index], index, parent);
148
- }
149
- }
150
- }
151
- var arrayIterate = iterate;
152
- var own = ({}).hasOwnProperty;
153
- function iterate(values, callback, context) {
154
- var index = -1;
155
- var result;
156
- if (!values) {
157
- throw new Error('Iterate requires that |this| not be ' + values);
158
- }
159
- if (!own.call(values, 'length')) {
160
- throw new Error('Iterate requires that |this| has a `length`');
161
- }
162
- if (typeof callback !== 'function') {
163
- throw new Error('`callback` must be a function');
164
- }
165
- while (++index < values.length) {
166
- if (!((index in values))) {
167
- continue;
168
- }
169
- result = callback.call(context, values[index], index, values);
170
- if (typeof result === 'number') {
171
- if (result < 0) {
172
- index = 0;
173
- }
174
- index = result - 1;
175
- }
176
- }
177
- }
178
- var unistUtilModifyChildren = modifierFactory;
179
- function modifierFactory(callback) {
180
- return iteratorFactory(wrapperFactory(callback));
181
- }
182
- function iteratorFactory(callback) {
183
- return iterator;
184
- function iterator(parent) {
185
- var children = parent && parent.children;
186
- if (!children) {
187
- throw new Error('Missing children in `parent` for `modifier`');
188
- }
189
- return arrayIterate(children, callback, parent);
190
- }
191
- }
192
- function wrapperFactory(callback) {
193
- return wrapper;
194
- function wrapper(value, index) {
195
- return callback(value, index, this);
196
- }
197
- }
198
- var tokenizer = tokenizerFactory;
199
- function tokenizerFactory(childType, expression) {
200
- return tokenizer;
201
- function tokenizer(node) {
202
- var children = [];
203
- var tokens = node.children;
204
- var type = node.type;
205
- var length = tokens.length;
206
- var index = -1;
207
- var lastIndex = length - 1;
208
- var start = 0;
209
- var first;
210
- var last;
211
- var parent;
212
- while (++index < length) {
213
- if (index === lastIndex || tokens[index].type === childType && expression.test(nlcstToString_1(tokens[index]))) {
214
- first = tokens[start];
215
- last = tokens[index];
216
- parent = {
217
- type: type,
218
- children: tokens.slice(start, index + 1)
219
- };
220
- if (first.position && last.position) {
221
- parent.position = {
222
- start: first.position.start,
223
- end: last.position.end
224
- };
225
- }
226
- children.push(parent);
227
- start = index + 1;
228
- }
229
- }
230
- return children;
231
- }
232
- }
233
- var parser = parserFactory;
234
- function parserFactory(options) {
235
- var type = options.type;
236
- var tokenizerProperty = options.tokenizer;
237
- var delimiter = options.delimiter;
238
- var tokenize = delimiter && tokenizer(options.delimiterType, delimiter);
239
- return parser;
240
- function parser(value) {
241
- var children = this[tokenizerProperty](value);
242
- return {
243
- type: type,
244
- children: tokenize ? tokenize(children) : children
245
- };
246
- }
247
- }
248
- var expressions = {
249
- affixSymbol: /^([!"').?\u0F3B\u0F3D\u169C\u2019\u201D\u2026\u203A\u203D\u2046\u207E\u208E\u2309\u230B\u232A\u2769\u276B\u276D\u276F\u2771\u2773\u2775\u27C6\u27E7\u27E9\u27EB\u27ED\u27EF\u2984\u2986\u2988\u298A\u298C\u298E\u2990\u2992\u2994\u2996\u2998\u29D9\u29DB\u29FD\u2E03\u2E05\u2E0A\u2E0D\u2E1D\u2E21\u2E23\u2E25\u2E27\u2E29\u3009\u300B\u300D\u300F\u3011\u3015\u3017\u3019\u301B\u301E\u301F\uFD3E\uFE18\uFE36\uFE38\uFE3A\uFE3C\uFE3E\uFE40\uFE42\uFE44\uFE48\uFE5A\uFE5C\uFE5E\uFF09\uFF3D\uFF5D\uFF60\uFF63\xBB\]}])\1*$/,
250
- newLine: /^[ \t]*((\r?\n|\r)[\t ]*)+$/,
251
- newLineMulti: /^[ \t]*((\r?\n|\r)[\t ]*){2,}$/,
252
- terminalMarker: /^([!.?\u2026\u203D]+)$/,
253
- wordSymbolInner: /^([&'\-.:=?@\xAD\xB7\u2010\u2011\u2019\u2027]|_+)$/,
254
- numerical: /^(?:[\d\xB2\xB3\xB9\xBC-\xBE\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F\u09E6-\u09EF\u09F4-\u09F9\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0B72-\u0B77\u0BE6-\u0BF2\u0C66-\u0C6F\u0C78-\u0C7E\u0CE6-\u0CEF\u0D58-\u0D5E\u0D66-\u0D78\u0DE6-\u0DEF\u0E50-\u0E59\u0ED0-\u0ED9\u0F20-\u0F33\u1040-\u1049\u1090-\u1099\u1369-\u137C\u16EE-\u16F0\u17E0-\u17E9\u17F0-\u17F9\u1810-\u1819\u1946-\u194F\u19D0-\u19DA\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\u2070\u2074-\u2079\u2080-\u2089\u2150-\u2182\u2185-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2CFD\u3007\u3021-\u3029\u3038-\u303A\u3192-\u3195\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\uA620-\uA629\uA6E6-\uA6EF\uA830-\uA835\uA8D0-\uA8D9\uA900-\uA909\uA9D0-\uA9D9\uA9F0-\uA9F9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19]|\uD800[\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDEE1-\uDEFB\uDF20-\uDF23\uDF41\uDF4A\uDFD1-\uDFD5]|\uD801[\uDCA0-\uDCA9]|\uD802[\uDC58-\uDC5F\uDC79-\uDC7F\uDCA7-\uDCAF\uDCFB-\uDCFF\uDD16-\uDD1B\uDDBC\uDDBD\uDDC0-\uDDCF\uDDD2-\uDDFF\uDE40-\uDE48\uDE7D\uDE7E\uDE9D-\uDE9F\uDEEB-\uDEEF\uDF58-\uDF5F\uDF78-\uDF7F\uDFA9-\uDFAF]|\uD803[\uDCFA-\uDCFF\uDD30-\uDD39\uDE60-\uDE7E\uDF1D-\uDF26\uDF51-\uDF54\uDFC5-\uDFCB]|\uD804[\uDC52-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9\uDDE1-\uDDF4\uDEF0-\uDEF9]|\uD805[\uDC50-\uDC59\uDCD0-\uDCD9\uDE50-\uDE59\uDEC0-\uDEC9\uDF30-\uDF3B]|\uD806[\uDCE0-\uDCF2\uDD50-\uDD59]|\uD807[\uDC50-\uDC6C\uDD50-\uDD59\uDDA0-\uDDA9\uDFC0-\uDFD4]|\uD809[\uDC00-\uDC6E]|\uD81A[\uDE60-\uDE69\uDF50-\uDF59\uDF5B-\uDF61]|\uD81B[\uDE80-\uDE96]|\uD834[\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDFCE-\uDFFF]|\uD838[\uDD40-\uDD49\uDEF0-\uDEF9]|\uD83A[\uDCC7-\uDCCF\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9])+$/,
255
- digitStart: /^\d/,
256
- lowerInitial: /^(?:[a-z\xB5\xDF-\xF6\xF8-\xFF\u0101\u0103\u0105\u0107\u0109\u010B\u010D\u010F\u0111\u0113\u0115\u0117\u0119\u011B\u011D\u011F\u0121\u0123\u0125\u0127\u0129\u012B\u012D\u012F\u0131\u0133\u0135\u0137\u0138\u013A\u013C\u013E\u0140\u0142\u0144\u0146\u0148\u0149\u014B\u014D\u014F\u0151\u0153\u0155\u0157\u0159\u015B\u015D\u015F\u0161\u0163\u0165\u0167\u0169\u016B\u016D\u016F\u0171\u0173\u0175\u0177\u017A\u017C\u017E-\u0180\u0183\u0185\u0188\u018C\u018D\u0192\u0195\u0199-\u019B\u019E\u01A1\u01A3\u01A5\u01A8\u01AA\u01AB\u01AD\u01B0\u01B4\u01B6\u01B9\u01BA\u01BD-\u01BF\u01C6\u01C9\u01CC\u01CE\u01D0\u01D2\u01D4\u01D6\u01D8\u01DA\u01DC\u01DD\u01DF\u01E1\u01E3\u01E5\u01E7\u01E9\u01EB\u01ED\u01EF\u01F0\u01F3\u01F5\u01F9\u01FB\u01FD\u01FF\u0201\u0203\u0205\u0207\u0209\u020B\u020D\u020F\u0211\u0213\u0215\u0217\u0219\u021B\u021D\u021F\u0221\u0223\u0225\u0227\u0229\u022B\u022D\u022F\u0231\u0233-\u0239\u023C\u023F\u0240\u0242\u0247\u0249\u024B\u024D\u024F-\u0293\u0295-\u02AF\u0371\u0373\u0377\u037B-\u037D\u0390\u03AC-\u03CE\u03D0\u03D1\u03D5-\u03D7\u03D9\u03DB\u03DD\u03DF\u03E1\u03E3\u03E5\u03E7\u03E9\u03EB\u03ED\u03EF-\u03F3\u03F5\u03F8\u03FB\u03FC\u0430-\u045F\u0461\u0463\u0465\u0467\u0469\u046B\u046D\u046F\u0471\u0473\u0475\u0477\u0479\u047B\u047D\u047F\u0481\u048B\u048D\u048F\u0491\u0493\u0495\u0497\u0499\u049B\u049D\u049F\u04A1\u04A3\u04A5\u04A7\u04A9\u04AB\u04AD\u04AF\u04B1\u04B3\u04B5\u04B7\u04B9\u04BB\u04BD\u04BF\u04C2\u04C4\u04C6\u04C8\u04CA\u04CC\u04CE\u04CF\u04D1\u04D3\u04D5\u04D7\u04D9\u04DB\u04DD\u04DF\u04E1\u04E3\u04E5\u04E7\u04E9\u04EB\u04ED\u04EF\u04F1\u04F3\u04F5\u04F7\u04F9\u04FB\u04FD\u04FF\u0501\u0503\u0505\u0507\u0509\u050B\u050D\u050F\u0511\u0513\u0515\u0517\u0519\u051B\u051D\u051F\u0521\u0523\u0525\u0527\u0529\u052B\u052D\u052F\u0560-\u0588\u10D0-\u10FA\u10FD-\u10FF\u13F8-\u13FD\u1C80-\u1C88\u1D00-\u1D2B\u1D6B-\u1D77\u1D79-\u1D9A\u1E01\u1E03\u1E05\u1E07\u1E09\u1E0B\u1E0D\u1E0F\u1E11\u1E13\u1E15\u1E17\u1E19\u1E1B\u1E1D\u1E1F\u1E21\u1E23\u1E25\u1E27\u1E29\u1E2B\u1E2D\u1E2F\u1E31\u1E33\u1E35\u1E37\u1E39\u1E3B\u1E3D\u1E3F\u1E41\u1E43\u1E45\u1E47\u1E49\u1E4B\u1E4D\u1E4F\u1E51\u1E53\u1E55\u1E57\u1E59\u1E5B\u1E5D\u1E5F\u1E61\u1E63\u1E65\u1E67\u1E69\u1E6B\u1E6D\u1E6F\u1E71\u1E73\u1E75\u1E77\u1E79\u1E7B\u1E7D\u1E7F\u1E81\u1E83\u1E85\u1E87\u1E89\u1E8B\u1E8D\u1E8F\u1E91\u1E93\u1E95-\u1E9D\u1E9F\u1EA1\u1EA3\u1EA5\u1EA7\u1EA9\u1EAB\u1EAD\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\u1EB9\u1EBB\u1EBD\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7\u1EC9\u1ECB\u1ECD\u1ECF\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3\u1EE5\u1EE7\u1EE9\u1EEB\u1EED\u1EEF\u1EF1\u1EF3\u1EF5\u1EF7\u1EF9\u1EFB\u1EFD\u1EFF-\u1F07\u1F10-\u1F15\u1F20-\u1F27\u1F30-\u1F37\u1F40-\u1F45\u1F50-\u1F57\u1F60-\u1F67\u1F70-\u1F7D\u1F80-\u1F87\u1F90-\u1F97\u1FA0-\u1FA7\u1FB0-\u1FB4\u1FB6\u1FB7\u1FBE\u1FC2-\u1FC4\u1FC6\u1FC7\u1FD0-\u1FD3\u1FD6\u1FD7\u1FE0-\u1FE7\u1FF2-\u1FF4\u1FF6\u1FF7\u210A\u210E\u210F\u2113\u212F\u2134\u2139\u213C\u213D\u2146-\u2149\u214E\u2184\u2C30-\u2C5E\u2C61\u2C65\u2C66\u2C68\u2C6A\u2C6C\u2C71\u2C73\u2C74\u2C76-\u2C7B\u2C81\u2C83\u2C85\u2C87\u2C89\u2C8B\u2C8D\u2C8F\u2C91\u2C93\u2C95\u2C97\u2C99\u2C9B\u2C9D\u2C9F\u2CA1\u2CA3\u2CA5\u2CA7\u2CA9\u2CAB\u2CAD\u2CAF\u2CB1\u2CB3\u2CB5\u2CB7\u2CB9\u2CBB\u2CBD\u2CBF\u2CC1\u2CC3\u2CC5\u2CC7\u2CC9\u2CCB\u2CCD\u2CCF\u2CD1\u2CD3\u2CD5\u2CD7\u2CD9\u2CDB\u2CDD\u2CDF\u2CE1\u2CE3\u2CE4\u2CEC\u2CEE\u2CF3\u2D00-\u2D25\u2D27\u2D2D\uA641\uA643\uA645\uA647\uA649\uA64B\uA64D\uA64F\uA651\uA653\uA655\uA657\uA659\uA65B\uA65D\uA65F\uA661\uA663\uA665\uA667\uA669\uA66B\uA66D\uA681\uA683\uA685\uA687\uA689\uA68B\uA68D\uA68F\uA691\uA693\uA695\uA697\uA699\uA69B\uA723\uA725\uA727\uA729\uA72B\uA72D\uA72F-\uA731\uA733\uA735\uA737\uA739\uA73B\uA73D\uA73F\uA741\uA743\uA745\uA747\uA749\uA74B\uA74D\uA74F\uA751\uA753\uA755\uA757\uA759\uA75B\uA75D\uA75F\uA761\uA763\uA765\uA767\uA769\uA76B\uA76D\uA76F\uA771-\uA778\uA77A\uA77C\uA77F\uA781\uA783\uA785\uA787\uA78C\uA78E\uA791\uA793-\uA795\uA797\uA799\uA79B\uA79D\uA79F\uA7A1\uA7A3\uA7A5\uA7A7\uA7A9\uA7AF\uA7B5\uA7B7\uA7B9\uA7BB\uA7BD\uA7BF\uA7C3\uA7C8\uA7CA\uA7F6\uA7FA\uAB30-\uAB5A\uAB60-\uAB68\uAB70-\uABBF\uFB00-\uFB06\uFB13-\uFB17\uFF41-\uFF5A]|\uD801[\uDC28-\uDC4F\uDCD8-\uDCFB]|\uD803[\uDCC0-\uDCF2]|\uD806[\uDCC0-\uDCDF]|\uD81B[\uDE60-\uDE7F]|\uD835[\uDC1A-\uDC33\uDC4E-\uDC54\uDC56-\uDC67\uDC82-\uDC9B\uDCB6-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDCCF\uDCEA-\uDD03\uDD1E-\uDD37\uDD52-\uDD6B\uDD86-\uDD9F\uDDBA-\uDDD3\uDDEE-\uDE07\uDE22-\uDE3B\uDE56-\uDE6F\uDE8A-\uDEA5\uDEC2-\uDEDA\uDEDC-\uDEE1\uDEFC-\uDF14\uDF16-\uDF1B\uDF36-\uDF4E\uDF50-\uDF55\uDF70-\uDF88\uDF8A-\uDF8F\uDFAA-\uDFC2\uDFC4-\uDFC9\uDFCB]|\uD83A[\uDD22-\uDD43])/,
257
- surrogates: /[\uD800-\uDFFF]/,
258
- punctuation: /[!"'-),-/:;?[-\]_{}\xA1\xA7\xAB\xB6\xB7\xBB\xBF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u09FD\u0A76\u0AF0\u0C77\u0C84\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u201F\u2022-\u2027\u2032-\u203A\u203C-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2308-\u230B\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E4F\u2E52\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA8FC\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]|\uD800[\uDD00-\uDD02\uDF9F\uDFD0]|\uD801\uDD6F|\uD802[\uDC57\uDD1F\uDD3F\uDE50-\uDE58\uDE7F\uDEF0-\uDEF6\uDF39-\uDF3F\uDF99-\uDF9C]|\uD803[\uDEAD\uDF55-\uDF59]|\uD804[\uDC47-\uDC4D\uDCBB\uDCBC\uDCBE-\uDCC1\uDD40-\uDD43\uDD74\uDD75\uDDC5-\uDDC8\uDDCD\uDDDB\uDDDD-\uDDDF\uDE38-\uDE3D\uDEA9]|\uD805[\uDC4B-\uDC4F\uDC5A\uDC5B\uDC5D\uDCC6\uDDC1-\uDDD7\uDE41-\uDE43\uDE60-\uDE6C\uDF3C-\uDF3E]|\uD806[\uDC3B\uDD44-\uDD46\uDDE2\uDE3F-\uDE46\uDE9A-\uDE9C\uDE9E-\uDEA2]|\uD807[\uDC41-\uDC45\uDC70\uDC71\uDEF7\uDEF8\uDFFF]|\uD809[\uDC70-\uDC74]|\uD81A[\uDE6E\uDE6F\uDEF5\uDF37-\uDF3B\uDF44]|\uD81B[\uDE97-\uDE9A\uDFE2]|\uD82F\uDC9F|\uD836[\uDE87-\uDE8B]|\uD83A[\uDD5E\uDD5F]/,
259
- word: /[\dA-Za-z\xAA\xB2\xB3\xB5\xB9\xBA\xBC-\xBE\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376\u0377\u037A-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u0483-\u052F\u0531-\u0556\u0559\u0560-\u0588\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u05D0-\u05EA\u05EF-\u05F2\u0610-\u061A\u0620-\u0669\u066E-\u06D3\u06D5-\u06DC\u06DF-\u06E8\u06EA-\u06FC\u06FF\u0710-\u074A\u074D-\u07B1\u07C0-\u07F5\u07FA\u07FD\u0800-\u082D\u0840-\u085B\u0860-\u086A\u08A0-\u08B4\u08B6-\u08C7\u08D3-\u08E1\u08E3-\u0963\u0966-\u096F\u0971-\u0983\u0985-\u098C\u098F\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BC-\u09C4\u09C7\u09C8\u09CB-\u09CE\u09D7\u09DC\u09DD\u09DF-\u09E3\u09E6-\u09F1\u09F4-\u09F9\u09FC\u09FE\u0A01-\u0A03\u0A05-\u0A0A\u0A0F\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32\u0A33\u0A35\u0A36\u0A38\u0A39\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A59-\u0A5C\u0A5E\u0A66-\u0A75\u0A81-\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2\u0AB3\u0AB5-\u0AB9\u0ABC-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AD0\u0AE0-\u0AE3\u0AE6-\u0AEF\u0AF9-\u0AFF\u0B01-\u0B03\u0B05-\u0B0C\u0B0F\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32\u0B33\u0B35-\u0B39\u0B3C-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B55-\u0B57\u0B5C\u0B5D\u0B5F-\u0B63\u0B66-\u0B6F\u0B71-\u0B77\u0B82\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99\u0B9A\u0B9C\u0B9E\u0B9F\u0BA3\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD0\u0BD7\u0BE6-\u0BF2\u0C00-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C39\u0C3D-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C58-\u0C5A\u0C60-\u0C63\u0C66-\u0C6F\u0C78-\u0C7E\u0C80-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBC-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CDE\u0CE0-\u0CE3\u0CE6-\u0CEF\u0CF1\u0CF2\u0D00-\u0D0C\u0D0E-\u0D10\u0D12-\u0D44\u0D46-\u0D48\u0D4A-\u0D4E\u0D54-\u0D63\u0D66-\u0D78\u0D7A-\u0D7F\u0D81-\u0D83\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DE6-\u0DEF\u0DF2\u0DF3\u0E01-\u0E3A\u0E40-\u0E4E\u0E50-\u0E59\u0E81\u0E82\u0E84\u0E86-\u0E8A\u0E8C-\u0EA3\u0EA5\u0EA7-\u0EBD\u0EC0-\u0EC4\u0EC6\u0EC8-\u0ECD\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39\u0F3E-\u0F47\u0F49-\u0F6C\u0F71-\u0F84\u0F86-\u0F97\u0F99-\u0FBC\u0FC6\u1000-\u1049\u1050-\u109D\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u135D-\u135F\u1369-\u137C\u1380-\u138F\u13A0-\u13F5\u13F8-\u13FD\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F8\u1700-\u170C\u170E-\u1714\u1720-\u1734\u1740-\u1753\u1760-\u176C\u176E-\u1770\u1772\u1773\u1780-\u17D3\u17D7\u17DC\u17DD\u17E0-\u17E9\u17F0-\u17F9\u180B-\u180D\u1810-\u1819\u1820-\u1878\u1880-\u18AA\u18B0-\u18F5\u1900-\u191E\u1920-\u192B\u1930-\u193B\u1946-\u196D\u1970-\u1974\u1980-\u19AB\u19B0-\u19C9\u19D0-\u19DA\u1A00-\u1A1B\u1A20-\u1A5E\u1A60-\u1A7C\u1A7F-\u1A89\u1A90-\u1A99\u1AA7\u1AB0-\u1AC0\u1B00-\u1B4B\u1B50-\u1B59\u1B6B-\u1B73\u1B80-\u1BF3\u1C00-\u1C37\u1C40-\u1C49\u1C4D-\u1C7D\u1C80-\u1C88\u1C90-\u1CBA\u1CBD-\u1CBF\u1CD0-\u1CD2\u1CD4-\u1CFA\u1D00-\u1DF9\u1DFB-\u1F15\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u2070\u2071\u2074-\u2079\u207F-\u2089\u2090-\u209C\u20D0-\u20F0\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u2189\u2460-\u249B\u24EA-\u24FF\u2776-\u2793\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2CE4\u2CEB-\u2CF3\u2CFD\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F\u2D7F-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u2DE0-\u2DFF\u2E2F\u3005-\u3007\u3021-\u302F\u3031-\u3035\u3038-\u303C\u3041-\u3096\u3099\u309A\u309D-\u309F\u30A1-\u30FA\u30FC-\u30FF\u3105-\u312F\u3131-\u318E\u3192-\u3195\u31A0-\u31BF\u31F0-\u31FF\u3220-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u3400-\u4DBF\u4E00-\u9FFC\uA000-\uA48C\uA4D0-\uA4FD\uA500-\uA60C\uA610-\uA62B\uA640-\uA672\uA674-\uA67D\uA67F-\uA6F1\uA717-\uA71F\uA722-\uA788\uA78B-\uA7BF\uA7C2-\uA7CA\uA7F5-\uA827\uA82C\uA830-\uA835\uA840-\uA873\uA880-\uA8C5\uA8D0-\uA8D9\uA8E0-\uA8F7\uA8FB\uA8FD-\uA92D\uA930-\uA953\uA960-\uA97C\uA980-\uA9C0\uA9CF-\uA9D9\uA9E0-\uA9FE\uAA00-\uAA36\uAA40-\uAA4D\uAA50-\uAA59\uAA60-\uAA76\uAA7A-\uAAC2\uAADB-\uAADD\uAAE0-\uAAEF\uAAF2-\uAAF6\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E\uAB30-\uAB5A\uAB5C-\uAB69\uAB70-\uABEA\uABEC\uABED\uABF0-\uABF9\uAC00-\uD7A3\uD7B0-\uD7C6\uD7CB-\uD7FB\uF900-\uFA6D\uFA70-\uFAD9\uFB00-\uFB06\uFB13-\uFB17\uFB1D-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE00-\uFE0F\uFE20-\uFE2F\uFE70-\uFE74\uFE76-\uFEFC\uFF10-\uFF19\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF\uFFD2-\uFFD7\uFFDA-\uFFDC]|\uD800[\uDC00-\uDC0B\uDC0D-\uDC26\uDC28-\uDC3A\uDC3C\uDC3D\uDC3F-\uDC4D\uDC50-\uDC5D\uDC80-\uDCFA\uDD07-\uDD33\uDD40-\uDD78\uDD8A\uDD8B\uDDFD\uDE80-\uDE9C\uDEA0-\uDED0\uDEE0-\uDEFB\uDF00-\uDF23\uDF2D-\uDF4A\uDF50-\uDF7A\uDF80-\uDF9D\uDFA0-\uDFC3\uDFC8-\uDFCF\uDFD1-\uDFD5]|\uD801[\uDC00-\uDC9D\uDCA0-\uDCA9\uDCB0-\uDCD3\uDCD8-\uDCFB\uDD00-\uDD27\uDD30-\uDD63\uDE00-\uDF36\uDF40-\uDF55\uDF60-\uDF67]|\uD802[\uDC00-\uDC05\uDC08\uDC0A-\uDC35\uDC37\uDC38\uDC3C\uDC3F-\uDC55\uDC58-\uDC76\uDC79-\uDC9E\uDCA7-\uDCAF\uDCE0-\uDCF2\uDCF4\uDCF5\uDCFB-\uDD1B\uDD20-\uDD39\uDD80-\uDDB7\uDDBC-\uDDCF\uDDD2-\uDE03\uDE05\uDE06\uDE0C-\uDE13\uDE15-\uDE17\uDE19-\uDE35\uDE38-\uDE3A\uDE3F-\uDE48\uDE60-\uDE7E\uDE80-\uDE9F\uDEC0-\uDEC7\uDEC9-\uDEE6\uDEEB-\uDEEF\uDF00-\uDF35\uDF40-\uDF55\uDF58-\uDF72\uDF78-\uDF91\uDFA9-\uDFAF]|\uD803[\uDC00-\uDC48\uDC80-\uDCB2\uDCC0-\uDCF2\uDCFA-\uDD27\uDD30-\uDD39\uDE60-\uDE7E\uDE80-\uDEA9\uDEAB\uDEAC\uDEB0\uDEB1\uDF00-\uDF27\uDF30-\uDF54\uDFB0-\uDFCB\uDFE0-\uDFF6]|\uD804[\uDC00-\uDC46\uDC52-\uDC6F\uDC7F-\uDCBA\uDCD0-\uDCE8\uDCF0-\uDCF9\uDD00-\uDD34\uDD36-\uDD3F\uDD44-\uDD47\uDD50-\uDD73\uDD76\uDD80-\uDDC4\uDDC9-\uDDCC\uDDCE-\uDDDA\uDDDC\uDDE1-\uDDF4\uDE00-\uDE11\uDE13-\uDE37\uDE3E\uDE80-\uDE86\uDE88\uDE8A-\uDE8D\uDE8F-\uDE9D\uDE9F-\uDEA8\uDEB0-\uDEEA\uDEF0-\uDEF9\uDF00-\uDF03\uDF05-\uDF0C\uDF0F\uDF10\uDF13-\uDF28\uDF2A-\uDF30\uDF32\uDF33\uDF35-\uDF39\uDF3B-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF50\uDF57\uDF5D-\uDF63\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC00-\uDC4A\uDC50-\uDC59\uDC5E-\uDC61\uDC80-\uDCC5\uDCC7\uDCD0-\uDCD9\uDD80-\uDDB5\uDDB8-\uDDC0\uDDD8-\uDDDD\uDE00-\uDE40\uDE44\uDE50-\uDE59\uDE80-\uDEB8\uDEC0-\uDEC9\uDF00-\uDF1A\uDF1D-\uDF2B\uDF30-\uDF3B]|\uD806[\uDC00-\uDC3A\uDCA0-\uDCF2\uDCFF-\uDD06\uDD09\uDD0C-\uDD13\uDD15\uDD16\uDD18-\uDD35\uDD37\uDD38\uDD3B-\uDD43\uDD50-\uDD59\uDDA0-\uDDA7\uDDAA-\uDDD7\uDDDA-\uDDE1\uDDE3\uDDE4\uDE00-\uDE3E\uDE47\uDE50-\uDE99\uDE9D\uDEC0-\uDEF8]|\uD807[\uDC00-\uDC08\uDC0A-\uDC36\uDC38-\uDC40\uDC50-\uDC6C\uDC72-\uDC8F\uDC92-\uDCA7\uDCA9-\uDCB6\uDD00-\uDD06\uDD08\uDD09\uDD0B-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD47\uDD50-\uDD59\uDD60-\uDD65\uDD67\uDD68\uDD6A-\uDD8E\uDD90\uDD91\uDD93-\uDD98\uDDA0-\uDDA9\uDEE0-\uDEF6\uDFB0\uDFC0-\uDFD4]|\uD808[\uDC00-\uDF99]|\uD809[\uDC00-\uDC6E\uDC80-\uDD43]|[\uD80C\uD81C-\uD820\uD822\uD840-\uD868\uD86A-\uD86C\uD86F-\uD872\uD874-\uD879\uD880-\uD883][\uDC00-\uDFFF]|\uD80D[\uDC00-\uDC2E]|\uD811[\uDC00-\uDE46]|\uD81A[\uDC00-\uDE38\uDE40-\uDE5E\uDE60-\uDE69\uDED0-\uDEED\uDEF0-\uDEF4\uDF00-\uDF36\uDF40-\uDF43\uDF50-\uDF59\uDF5B-\uDF61\uDF63-\uDF77\uDF7D-\uDF8F]|\uD81B[\uDE40-\uDE96\uDF00-\uDF4A\uDF4F-\uDF87\uDF8F-\uDF9F\uDFE0\uDFE1\uDFE3\uDFE4\uDFF0\uDFF1]|\uD821[\uDC00-\uDFF7]|\uD823[\uDC00-\uDCD5\uDD00-\uDD08]|\uD82C[\uDC00-\uDD1E\uDD50-\uDD52\uDD64-\uDD67\uDD70-\uDEFB]|\uD82F[\uDC00-\uDC6A\uDC70-\uDC7C\uDC80-\uDC88\uDC90-\uDC99\uDC9D\uDC9E]|\uD834[\uDD65-\uDD69\uDD6D-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44\uDEE0-\uDEF3\uDF60-\uDF78]|\uD835[\uDC00-\uDC54\uDC56-\uDC9C\uDC9E\uDC9F\uDCA2\uDCA5\uDCA6\uDCA9-\uDCAC\uDCAE-\uDCB9\uDCBB\uDCBD-\uDCC3\uDCC5-\uDD05\uDD07-\uDD0A\uDD0D-\uDD14\uDD16-\uDD1C\uDD1E-\uDD39\uDD3B-\uDD3E\uDD40-\uDD44\uDD46\uDD4A-\uDD50\uDD52-\uDEA5\uDEA8-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFCB\uDFCE-\uDFFF]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDD00-\uDD2C\uDD30-\uDD3D\uDD40-\uDD49\uDD4E\uDEC0-\uDEF9]|\uD83A[\uDC00-\uDCC4\uDCC7-\uDCD6\uDD00-\uDD4B\uDD50-\uDD59]|\uD83B[\uDC71-\uDCAB\uDCAD-\uDCAF\uDCB1-\uDCB4\uDD01-\uDD2D\uDD2F-\uDD3D\uDE00-\uDE03\uDE05-\uDE1F\uDE21\uDE22\uDE24\uDE27\uDE29-\uDE32\uDE34-\uDE37\uDE39\uDE3B\uDE42\uDE47\uDE49\uDE4B\uDE4D-\uDE4F\uDE51\uDE52\uDE54\uDE57\uDE59\uDE5B\uDE5D\uDE5F\uDE61\uDE62\uDE64\uDE67-\uDE6A\uDE6C-\uDE72\uDE74-\uDE77\uDE79-\uDE7C\uDE7E\uDE80-\uDE89\uDE8B-\uDE9B\uDEA1-\uDEA3\uDEA5-\uDEA9\uDEAB-\uDEBB]|\uD83C[\uDD00-\uDD0C]|\uD83E[\uDFF0-\uDFF9]|\uD869[\uDC00-\uDEDD\uDF00-\uDFFF]|\uD86D[\uDC00-\uDF34\uDF40-\uDFFF]|\uD86E[\uDC00-\uDC1D\uDC20-\uDFFF]|\uD873[\uDC00-\uDEA1\uDEB0-\uDFFF]|\uD87A[\uDC00-\uDFE0]|\uD87E[\uDC00-\uDE1D]|\uD884[\uDC00-\uDF4A]|\uDB40[\uDD00-\uDDEF]/,
260
- whiteSpace: /[\t-\r \x85\xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000]/
261
- };
262
- var unistUtilModifyChildren$1 = modifierFactory$1;
263
- function modifierFactory$1(callback) {
264
- return iteratorFactory$1(wrapperFactory$1(callback));
265
- }
266
- function iteratorFactory$1(callback) {
267
- return iterator;
268
- function iterator(parent) {
269
- var children = parent && parent.children;
270
- if (!children) {
271
- throw new Error('Missing children in `parent` for `modifier`');
272
- }
273
- arrayIterate(children, callback, parent);
274
- }
275
- }
276
- function wrapperFactory$1(callback) {
277
- return wrapper;
278
- function wrapper(value, index) {
279
- return callback(value, index, this);
280
- }
281
- }
282
- var mergeInitialWordSymbol_1 = unistUtilModifyChildren$1(mergeInitialWordSymbol);
283
- function mergeInitialWordSymbol(child, index, parent) {
284
- var children;
285
- var next;
286
- if (child.type !== 'SymbolNode' && child.type !== 'PunctuationNode' || nlcstToString_1(child) !== '&') {
287
- return;
288
- }
289
- children = parent.children;
290
- next = children[index + 1];
291
- if (index !== 0 && children[index - 1].type === 'WordNode' || !(next && next.type === 'WordNode')) {
292
- return;
293
- }
294
- children.splice(index, 1);
295
- next.children.unshift(child);
296
- if (next.position && child.position) {
297
- next.position.start = child.position.start;
298
- }
299
- return index - 1;
300
- }
301
- var mergeFinalWordSymbol_1 = unistUtilModifyChildren$1(mergeFinalWordSymbol);
302
- function mergeFinalWordSymbol(child, index, parent) {
303
- var children;
304
- var previous;
305
- var next;
306
- if (index !== 0 && (child.type === 'SymbolNode' || child.type === 'PunctuationNode') && nlcstToString_1(child) === '-') {
307
- children = parent.children;
308
- previous = children[index - 1];
309
- next = children[index + 1];
310
- if ((!next || next.type !== 'WordNode') && previous && previous.type === 'WordNode') {
311
- children.splice(index, 1);
312
- previous.children.push(child);
313
- if (previous.position && child.position) {
314
- previous.position.end = child.position.end;
315
- }
316
- return index;
317
- }
318
- }
319
- }
320
- var mergeInnerWordSymbol_1 = unistUtilModifyChildren$1(mergeInnerWordSymbol);
321
- var wordSymbolInner = expressions.wordSymbolInner;
322
- function mergeInnerWordSymbol(child, index, parent) {
323
- var siblings;
324
- var sibling;
325
- var previous;
326
- var last;
327
- var position;
328
- var tokens;
329
- var queue;
330
- if (index !== 0 && (child.type === 'SymbolNode' || child.type === 'PunctuationNode')) {
331
- siblings = parent.children;
332
- previous = siblings[index - 1];
333
- if (previous && previous.type === 'WordNode') {
334
- position = index - 1;
335
- tokens = [];
336
- queue = [];
337
- while (siblings[++position]) {
338
- sibling = siblings[position];
339
- if (sibling.type === 'WordNode') {
340
- tokens = tokens.concat(queue, sibling.children);
341
- queue = [];
342
- } else if ((sibling.type === 'SymbolNode' || sibling.type === 'PunctuationNode') && wordSymbolInner.test(nlcstToString_1(sibling))) {
343
- queue.push(sibling);
344
- } else {
345
- break;
346
- }
347
- }
348
- if (tokens.length !== 0) {
349
- if (queue.length !== 0) {
350
- position -= queue.length;
351
- }
352
- siblings.splice(index, position - index);
353
- previous.children = previous.children.concat(tokens);
354
- last = tokens[tokens.length - 1];
355
- if (previous.position && last.position) {
356
- previous.position.end = last.position.end;
357
- }
358
- return index;
359
- }
360
- }
361
- }
362
- }
363
- var mergeInnerWordSlash_1 = unistUtilModifyChildren$1(mergeInnerWordSlash);
364
- var slash = '/';
365
- function mergeInnerWordSlash(child, index, parent) {
366
- var siblings = parent.children;
367
- var previous;
368
- var next;
369
- var previousValue;
370
- var nextValue;
371
- var queue;
372
- var tail;
373
- var count;
374
- previous = siblings[index - 1];
375
- next = siblings[index + 1];
376
- if (previous && previous.type === 'WordNode' && (child.type === 'SymbolNode' || child.type === 'PunctuationNode') && nlcstToString_1(child) === slash) {
377
- previousValue = nlcstToString_1(previous);
378
- tail = child;
379
- queue = [child];
380
- count = 1;
381
- if (next && next.type === 'WordNode') {
382
- nextValue = nlcstToString_1(next);
383
- tail = next;
384
- queue = queue.concat(next.children);
385
- count++;
386
- }
387
- if (previousValue.length < 3 && (!nextValue || nextValue.length < 3)) {
388
- previous.children = previous.children.concat(queue);
389
- siblings.splice(index, count);
390
- if (previous.position && tail.position) {
391
- previous.position.end = tail.position.end;
392
- }
393
- return index;
394
- }
395
- }
396
- }
397
- var mergeInitialisms_1 = unistUtilModifyChildren$1(mergeInitialisms);
398
- var numerical = expressions.numerical;
399
- function mergeInitialisms(child, index, parent) {
400
- var siblings;
401
- var previous;
402
- var children;
403
- var length;
404
- var position;
405
- var otherChild;
406
- var isAllDigits;
407
- var value;
408
- if (index !== 0 && nlcstToString_1(child) === '.') {
409
- siblings = parent.children;
410
- previous = siblings[index - 1];
411
- children = previous.children;
412
- length = children && children.length;
413
- if (previous.type === 'WordNode' && length !== 1 && length % 2 !== 0) {
414
- position = length;
415
- isAllDigits = true;
416
- while (children[--position]) {
417
- otherChild = children[position];
418
- value = nlcstToString_1(otherChild);
419
- if (position % 2 === 0) {
420
- if (value.length > 1) {
421
- return;
422
- }
423
- if (!numerical.test(value)) {
424
- isAllDigits = false;
425
- }
426
- } else if (value !== '.') {
427
- if (position < length - 2) {
428
- break;
429
- } else {
430
- return;
431
- }
432
- }
433
- }
434
- if (!isAllDigits) {
435
- siblings.splice(index, 1);
436
- children.push(child);
437
- if (previous.position && child.position) {
438
- previous.position.end = child.position.end;
439
- }
440
- return index;
441
- }
442
- }
443
- }
444
- }
445
- var mergeWords = unistUtilModifyChildren$1(mergeFinalWordSymbol$1);
446
- function mergeFinalWordSymbol$1(child, index, parent) {
447
- var siblings = parent.children;
448
- var next;
449
- if (child.type === 'WordNode') {
450
- next = siblings[index + 1];
451
- if (next && next.type === 'WordNode') {
452
- siblings.splice(index + 1, 1);
453
- child.children = child.children.concat(next.children);
454
- if (next.position && child.position) {
455
- child.position.end = next.position.end;
456
- }
457
- return index;
458
- }
459
- }
460
- }
461
- var patchPosition_1 = unistUtilVisitChildren(patchPosition);
462
- function patchPosition(child, index, node) {
463
- var siblings = node.children;
464
- if (!child.position) {
465
- return;
466
- }
467
- if (index === 0 && (!node.position || !node.position.start)) {
468
- patch(node);
469
- node.position.start = child.position.start;
470
- }
471
- if (index === siblings.length - 1 && (!node.position || !node.position.end)) {
472
- patch(node);
473
- node.position.end = child.position.end;
474
- }
475
- }
476
- function patch(node) {
477
- if (!node.position) {
478
- node.position = {};
479
- }
480
- }
481
- var mergeNonWordSentences_1 = unistUtilModifyChildren$1(mergeNonWordSentences);
482
- function mergeNonWordSentences(child, index, parent) {
483
- var children = child.children;
484
- var position = -1;
485
- var previous;
486
- var next;
487
- while (children[++position]) {
488
- if (children[position].type === 'WordNode') {
489
- return;
490
- }
491
- }
492
- previous = parent.children[index - 1];
493
- if (previous) {
494
- previous.children = previous.children.concat(children);
495
- parent.children.splice(index, 1);
496
- if (previous.position && child.position) {
497
- previous.position.end = child.position.end;
498
- }
499
- return index;
500
- }
501
- next = parent.children[index + 1];
502
- if (next) {
503
- next.children = children.concat(next.children);
504
- if (next.position && child.position) {
505
- next.position.start = child.position.start;
506
- }
507
- parent.children.splice(index, 1);
508
- }
509
- }
510
- var mergeAffixSymbol_1 = unistUtilModifyChildren$1(mergeAffixSymbol);
511
- var affixSymbol = expressions.affixSymbol;
512
- function mergeAffixSymbol(child, index, parent) {
513
- var children = child.children;
514
- var first;
515
- var second;
516
- var previous;
517
- if (children && children.length !== 0 && index !== 0) {
518
- first = children[0];
519
- second = children[1];
520
- previous = parent.children[index - 1];
521
- if ((first.type === 'SymbolNode' || first.type === 'PunctuationNode') && affixSymbol.test(nlcstToString_1(first))) {
522
- previous.children.push(children.shift());
523
- if (first.position && previous.position) {
524
- previous.position.end = first.position.end;
525
- }
526
- if (second && second.position && child.position) {
527
- child.position.start = second.position.start;
528
- }
529
- return index - 1;
530
- }
531
- }
532
- }
533
- var mergeInitialLowerCaseLetterSentences_1 = unistUtilModifyChildren$1(mergeInitialLowerCaseLetterSentences);
534
- var lowerInitial = expressions.lowerInitial;
535
- function mergeInitialLowerCaseLetterSentences(child, index, parent) {
536
- var children = child.children;
537
- var position;
538
- var node;
539
- var siblings;
540
- var previous;
541
- if (children && children.length !== 0 && index !== 0) {
542
- position = -1;
543
- while (children[++position]) {
544
- node = children[position];
545
- if (node.type === 'WordNode') {
546
- if (!lowerInitial.test(nlcstToString_1(node))) {
547
- return;
548
- }
549
- siblings = parent.children;
550
- previous = siblings[index - 1];
551
- previous.children = previous.children.concat(children);
552
- siblings.splice(index, 1);
553
- if (previous.position && child.position) {
554
- previous.position.end = child.position.end;
555
- }
556
- return index;
557
- }
558
- if (node.type === 'SymbolNode' || node.type === 'PunctuationNode') {
559
- return;
560
- }
561
- }
562
- }
563
- }
564
- var mergeInitialDigitSentences_1 = unistUtilModifyChildren$1(mergeInitialDigitSentences);
565
- var digit = expressions.digitStart;
566
- function mergeInitialDigitSentences(child, index, parent) {
567
- var children = child.children;
568
- var siblings = parent.children;
569
- var previous = siblings[index - 1];
570
- var head = children[0];
571
- if (previous && head && head.type === 'WordNode' && digit.test(nlcstToString_1(head))) {
572
- previous.children = previous.children.concat(children);
573
- siblings.splice(index, 1);
574
- if (previous.position && child.position) {
575
- previous.position.end = child.position.end;
576
- }
577
- return index;
578
- }
579
- }
580
- var mergePrefixExceptions_1 = unistUtilModifyChildren$1(mergePrefixExceptions);
581
- var abbreviationPrefix = new RegExp('^(' + '[0-9]{1,3}|' + '[a-z]|' + 'al|ca|cap|cca|cent|cf|cit|con|cp|cwt|ead|etc|ff|' + 'fl|ibid|id|nem|op|pro|seq|sic|stat|tem|viz' + ')$');
582
- function mergePrefixExceptions(child, index, parent) {
583
- var children = child.children;
584
- var period;
585
- var node;
586
- var next;
587
- if (children && children.length > 1) {
588
- period = children[children.length - 1];
589
- if (period && nlcstToString_1(period) === '.') {
590
- node = children[children.length - 2];
591
- if (node && node.type === 'WordNode' && abbreviationPrefix.test(nlcstToString_1(node).toLowerCase())) {
592
- node.children.push(period);
593
- children.pop();
594
- if (period.position && node.position) {
595
- node.position.end = period.position.end;
596
- }
597
- next = parent.children[index + 1];
598
- if (next) {
599
- child.children = children.concat(next.children);
600
- parent.children.splice(index + 1, 1);
601
- if (next.position && child.position) {
602
- child.position.end = next.position.end;
603
- }
604
- return index - 1;
605
- }
606
- }
607
- }
608
- }
609
- }
610
- var mergeAffixExceptions_1 = unistUtilModifyChildren$1(mergeAffixExceptions);
611
- function mergeAffixExceptions(child, index, parent) {
612
- var children = child.children;
613
- var node;
614
- var position;
615
- var value;
616
- var previousChild;
617
- if (!children || children.length === 0 || index === 0) {
618
- return;
619
- }
620
- position = -1;
621
- while (children[++position]) {
622
- node = children[position];
623
- if (node.type === 'WordNode') {
624
- return;
625
- }
626
- if (node.type === 'SymbolNode' || node.type === 'PunctuationNode') {
627
- value = nlcstToString_1(node);
628
- if (value !== ',' && value !== ';') {
629
- return;
630
- }
631
- previousChild = parent.children[index - 1];
632
- previousChild.children = previousChild.children.concat(children);
633
- if (previousChild.position && child.position) {
634
- previousChild.position.end = child.position.end;
635
- }
636
- parent.children.splice(index, 1);
637
- return index;
638
- }
639
- }
640
- }
641
- var mergeRemainingFullStops_1 = unistUtilVisitChildren(mergeRemainingFullStops);
642
- var terminalMarker = expressions.terminalMarker;
643
- function mergeRemainingFullStops(child) {
644
- var children = child.children;
645
- var position = children.length;
646
- var hasFoundDelimiter = false;
647
- var grandchild;
648
- var previous;
649
- var next;
650
- var nextNext;
651
- while (children[--position]) {
652
- grandchild = children[position];
653
- if (grandchild.type !== 'SymbolNode' && grandchild.type !== 'PunctuationNode') {
654
- if (grandchild.type === 'WordNode') {
655
- hasFoundDelimiter = true;
656
- }
657
- continue;
658
- }
659
- if (!terminalMarker.test(nlcstToString_1(grandchild))) {
660
- continue;
661
- }
662
- if (!hasFoundDelimiter) {
663
- hasFoundDelimiter = true;
664
- continue;
665
- }
666
- if (nlcstToString_1(grandchild) !== '.') {
667
- continue;
668
- }
669
- previous = children[position - 1];
670
- next = children[position + 1];
671
- if (previous && previous.type === 'WordNode') {
672
- nextNext = children[position + 2];
673
- if (next && nextNext && next.type === 'WhiteSpaceNode' && nlcstToString_1(nextNext) === '.') {
674
- continue;
675
- }
676
- children.splice(position, 1);
677
- previous.children.push(grandchild);
678
- if (grandchild.position && previous.position) {
679
- previous.position.end = grandchild.position.end;
680
- }
681
- position--;
682
- } else if (next && next.type === 'WordNode') {
683
- children.splice(position, 1);
684
- next.children.unshift(grandchild);
685
- if (grandchild.position && next.position) {
686
- next.position.start = grandchild.position.start;
687
- }
688
- }
689
- }
690
- }
691
- var makeInitialWhiteSpaceSiblings_1 = unistUtilVisitChildren(makeInitialWhiteSpaceSiblings);
692
- function makeInitialWhiteSpaceSiblings(child, index, parent) {
693
- var children = child.children;
694
- var next;
695
- if (children && children.length !== 0 && children[0].type === 'WhiteSpaceNode') {
696
- parent.children.splice(index, 0, children.shift());
697
- next = children[0];
698
- if (next && next.position && child.position) {
699
- child.position.start = next.position.start;
700
- }
701
- }
702
- }
703
- var makeFinalWhiteSpaceSiblings_1 = unistUtilModifyChildren$1(makeFinalWhiteSpaceSiblings);
704
- function makeFinalWhiteSpaceSiblings(child, index, parent) {
705
- var children = child.children;
706
- var previous;
707
- if (children && children.length !== 0 && children[children.length - 1].type === 'WhiteSpaceNode') {
708
- parent.children.splice(index + 1, 0, child.children.pop());
709
- previous = children[children.length - 1];
710
- if (previous && previous.position && child.position) {
711
- child.position.end = previous.position.end;
712
- }
713
- return index;
714
- }
715
- }
716
- var breakImplicitSentences_1 = unistUtilModifyChildren$1(breakImplicitSentences);
717
- var multiNewLine = expressions.newLineMulti;
718
- function breakImplicitSentences(child, index, parent) {
719
- var children;
720
- var position;
721
- var length;
722
- var tail;
723
- var head;
724
- var end;
725
- var insertion;
726
- var node;
727
- if (child.type !== 'SentenceNode') {
728
- return;
729
- }
730
- children = child.children;
731
- length = children.length - 1;
732
- position = 0;
733
- while (++position < length) {
734
- node = children[position];
735
- if (node.type !== 'WhiteSpaceNode' || !multiNewLine.test(nlcstToString_1(node))) {
736
- continue;
737
- }
738
- child.children = children.slice(0, position);
739
- insertion = {
740
- type: 'SentenceNode',
741
- children: children.slice(position + 1)
742
- };
743
- tail = children[position - 1];
744
- head = children[position + 1];
745
- parent.children.splice(index + 1, 0, node, insertion);
746
- if (child.position && tail.position && head.position) {
747
- end = child.position.end;
748
- child.position.end = tail.position.end;
749
- insertion.position = {
750
- start: head.position.start,
751
- end: end
752
- };
753
- }
754
- return index + 1;
755
- }
756
- }
757
- var removeEmptyNodes_1 = unistUtilModifyChildren$1(removeEmptyNodes);
758
- function removeEmptyNodes(child, index, parent) {
759
- if (('children' in child) && child.children.length === 0) {
760
- parent.children.splice(index, 1);
761
- return index;
762
- }
763
- }
764
- var lib = ParseLatin;
765
- function ParseLatin(doc, file) {
766
- var value = file || doc;
767
- if (!(this instanceof ParseLatin)) {
768
- return new ParseLatin(doc, file);
769
- }
770
- this.doc = value ? String(value) : null;
771
- }
772
- var proto = ParseLatin.prototype;
773
- proto.position = true;
774
- proto.tokenizeSymbol = createTextFactory('Symbol');
775
- proto.tokenizeWhiteSpace = createTextFactory('WhiteSpace');
776
- proto.tokenizePunctuation = createTextFactory('Punctuation');
777
- proto.tokenizeSource = createTextFactory('Source');
778
- proto.tokenizeText = createTextFactory('Text');
779
- proto.run = run;
780
- proto.use = useFactory(function (context, key, plugins) {
781
- context[key] = context[key].concat(plugins);
782
- });
783
- proto.useFirst = useFactory(function (context, key, plugins) {
784
- context[key] = plugins.concat(context[key]);
785
- });
786
- proto.parse = function (value) {
787
- return this.tokenizeRoot(value || this.doc);
788
- };
789
- proto.tokenize = function (value) {
790
- return tokenize(this, value);
791
- };
792
- pluggable(ParseLatin, 'tokenizeWord', function (value, eat) {
793
- var add = (eat || noopEat)('');
794
- var parent = {
795
- type: 'WordNode',
796
- children: []
797
- };
798
- this.tokenizeText(value, eat, parent);
799
- return add(parent);
800
- });
801
- pluggable(ParseLatin, 'tokenizeSentence', parser({
802
- type: 'SentenceNode',
803
- tokenizer: 'tokenize'
804
- }));
805
- pluggable(ParseLatin, 'tokenizeParagraph', parser({
806
- type: 'ParagraphNode',
807
- delimiter: expressions.terminalMarker,
808
- delimiterType: 'PunctuationNode',
809
- tokenizer: 'tokenizeSentence'
810
- }));
811
- pluggable(ParseLatin, 'tokenizeRoot', parser({
812
- type: 'RootNode',
813
- delimiter: expressions.newLine,
814
- delimiterType: 'WhiteSpaceNode',
815
- tokenizer: 'tokenizeParagraph'
816
- }));
817
- proto.use('tokenizeSentence', [mergeInitialWordSymbol_1, mergeFinalWordSymbol_1, mergeInnerWordSymbol_1, mergeInnerWordSlash_1, mergeInitialisms_1, mergeWords, patchPosition_1]);
818
- proto.use('tokenizeParagraph', [mergeNonWordSentences_1, mergeAffixSymbol_1, mergeInitialLowerCaseLetterSentences_1, mergeInitialDigitSentences_1, mergePrefixExceptions_1, mergeAffixExceptions_1, mergeRemainingFullStops_1, makeInitialWhiteSpaceSiblings_1, makeFinalWhiteSpaceSiblings_1, breakImplicitSentences_1, removeEmptyNodes_1, patchPosition_1]);
819
- proto.use('tokenizeRoot', [makeInitialWhiteSpaceSiblings_1, makeFinalWhiteSpaceSiblings_1, removeEmptyNodes_1, patchPosition_1]);
820
- function createTextFactory(type) {
821
- type += 'Node';
822
- return createText;
823
- function createText(value, eat, parent) {
824
- if (value === null || value === undefined) {
825
- value = '';
826
- }
827
- return (eat || noopEat)(value)({
828
- type: type,
829
- value: String(value)
830
- }, parent);
831
- }
832
- }
833
- function run(key, nodes) {
834
- var wareKey = key + 'Plugins';
835
- var plugins = this[wareKey];
836
- var index = -1;
837
- if (plugins) {
838
- while (plugins[++index]) {
839
- plugins[index](nodes);
840
- }
841
- }
842
- return nodes;
843
- }
844
- function pluggable(Constructor, key, callback) {
845
- Constructor.prototype[key] = function () {
846
- return this.run(key, callback.apply(this, arguments));
847
- };
848
- }
849
- function useFactory(callback) {
850
- return use;
851
- function use(key, plugins) {
852
- var self = this;
853
- var wareKey;
854
- if (!((key in self))) {
855
- throw new Error('Illegal Invocation: Unsupported `key` for ' + '`use(key, plugins)`. Make sure `key` is a ' + 'supported function');
856
- }
857
- if (!plugins) {
858
- return;
859
- }
860
- wareKey = key + 'Plugins';
861
- if (typeof plugins === 'function') {
862
- plugins = [plugins];
863
- } else {
864
- plugins = plugins.concat();
865
- }
866
- if (!self[wareKey]) {
867
- self[wareKey] = [];
868
- }
869
- callback(self, wareKey, plugins);
870
- }
871
- }
872
- var wordRe = expressions.word;
873
- var surrogatesRe = expressions.surrogates;
874
- var punctuationRe = expressions.punctuation;
875
- var whiteSpaceRe = expressions.whiteSpace;
876
- function tokenize(parser, value) {
877
- var tokens;
878
- var offset;
879
- var line;
880
- var column;
881
- var index;
882
- var length;
883
- var character;
884
- var queue;
885
- var previous;
886
- var left;
887
- var right;
888
- var eater;
889
- if (value === null || value === undefined) {
890
- value = '';
891
- } else if (value instanceof String) {
892
- value = value.toString();
893
- }
894
- if (typeof value !== 'string') {
895
- if (('length' in value) && (!value[0] || value[0].type)) {
896
- return value;
897
- }
898
- throw new Error("Illegal invocation: '" + value + "' is not a valid argument for 'ParseLatin'");
899
- }
900
- tokens = [];
901
- if (!value) {
902
- return tokens;
903
- }
904
- index = 0;
905
- offset = 0;
906
- line = 1;
907
- column = 1;
908
- eater = parser.position ? eat : noPositionEat;
909
- length = value.length;
910
- previous = '';
911
- queue = '';
912
- while (index < length) {
913
- character = value.charAt(index);
914
- if (whiteSpaceRe.test(character)) {
915
- right = 'WhiteSpace';
916
- } else if (punctuationRe.test(character)) {
917
- right = 'Punctuation';
918
- } else if (wordRe.test(character)) {
919
- right = 'Word';
920
- } else {
921
- right = 'Symbol';
922
- }
923
- tick();
924
- previous = character;
925
- character = '';
926
- left = right;
927
- right = null;
928
- index++;
929
- }
930
- tick();
931
- return tokens;
932
- function tick() {
933
- if (left === right && (left === 'Word' || left === 'WhiteSpace' || character === previous || surrogatesRe.test(character))) {
934
- queue += character;
935
- } else {
936
- if (queue) {
937
- parser['tokenize' + left](queue, eater);
938
- }
939
- queue = character;
940
- }
941
- }
942
- function eat(subvalue) {
943
- var pos = position();
944
- update(subvalue);
945
- return apply;
946
- function apply() {
947
- return pos(add.apply(null, arguments));
948
- }
949
- }
950
- function noPositionEat() {
951
- return apply;
952
- function apply() {
953
- return add.apply(null, arguments);
954
- }
955
- }
956
- function add(node, parent) {
957
- if (parent) {
958
- parent.children.push(node);
959
- } else {
960
- tokens.push(node);
961
- }
962
- return node;
963
- }
964
- function position() {
965
- var before = now();
966
- function patch(node) {
967
- node.position = new Position(before);
968
- return node;
969
- }
970
- return patch;
971
- }
972
- function update(subvalue) {
973
- var subvalueLength = subvalue.length;
974
- var character = -1;
975
- var lastIndex = -1;
976
- offset += subvalueLength;
977
- while (++character < subvalueLength) {
978
- if (subvalue.charAt(character) === '\n') {
979
- lastIndex = character;
980
- line++;
981
- }
982
- }
983
- if (lastIndex === -1) {
984
- column += subvalueLength;
985
- } else {
986
- column = subvalueLength - lastIndex;
987
- }
988
- }
989
- function Position(start) {
990
- this.start = start;
991
- this.end = now();
992
- }
993
- function now() {
994
- return {
995
- line: line,
996
- column: column,
997
- offset: offset
998
- };
999
- }
1000
- }
1001
- function noopAdd(node, parent) {
1002
- if (parent) {
1003
- parent.children.push(node);
1004
- }
1005
- return node;
1006
- }
1007
- function noopEat() {
1008
- return noopAdd;
1009
- }
1010
- var parseLatin = lib;
1011
- var parseEnglish = ParseEnglish;
1012
- ParserPrototype.prototype = parseLatin.prototype;
1013
- var proto$1 = new ParserPrototype();
1014
- ParseEnglish.prototype = proto$1;
1015
- proto$1.tokenizeSentencePlugins = [unistUtilVisitChildren(mergeEnglishElisionExceptions)].concat(proto$1.tokenizeSentencePlugins);
1016
- proto$1.tokenizeParagraphPlugins = [unistUtilModifyChildren(mergeEnglishPrefixExceptions)].concat([mergeNonWordSentences_1, mergeAffixSymbol_1, mergeInitialLowerCaseLetterSentences_1, mergeInitialDigitSentences_1, mergeAffixExceptions_1, mergeRemainingFullStops_1, makeInitialWhiteSpaceSiblings_1, makeFinalWhiteSpaceSiblings_1, breakImplicitSentences_1, removeEmptyNodes_1, patchPosition_1]);
1017
- function ParseEnglish(doc, file) {
1018
- if (!(this instanceof ParseEnglish)) {
1019
- return new ParseEnglish(doc, file);
1020
- }
1021
- parseLatin.apply(this, arguments);
1022
- }
1023
- function ParserPrototype() {}
1024
- var abbreviations = new RegExp('^(' + 'al|ca|cap|cca|cent|cf|cit|con|cp|cwt|ead|etc|ff|' + 'fl|ibid|id|nem|op|pro|seq|sic|stat|tem|viz' + 'inc|ltd|' + 'bbls?|cu|doz|fl|ft|gal|gr|gro|in|kt|lbs?|mi|oz|pt|qt|sq|tbsp|' + 'tsp|yds?|' + 'sec|min|hr|mon|tue|tues|wed|thu|thurs|fri|sat|sun|jan|feb|mar|' + 'apr|jun|jul|aug|sep|sept|oct|nov|dec' + ')$');
1025
- var abbreviationsSensitive = new RegExp('^(' + 'Mr|Mrs|Miss|Ms|Mss|Mses|Mlle|Mme|M|Messrs|Mmes|Jr|Sr|Snr|' + 'Dr|Mgr|Atty|Prof|Hon|Rev|Fr|Msgr|Sr|Br|St|Pres|Supt|Rep|Sen|' + 'Gov|Amb|Treas|Sec|Amd|Brig|Gen|Cdr|Col|Capt|Lt|Maj|Sgt|Po|Wo|Ph|' + 'Ave|Blvd|Mt|Rd|Bldgs?|Nat|Natl|Rt|Rte|Co|Pk|Sq|Dr|Pt|St|' + 'Ft|Pen|Terr|Hwy|Fwy|Pkwy|' + 'Ala|Ariz|Ark|Cal|Calif|Col|Colo|Conn|Del|Fla|Ga|Ida|Id|Ill|Ind|' + 'Ia|Kan|Kans|Ken|Ky|La|Me|Md|Mass|Mich|Minn|Miss|Mo|Mont|Neb|' + 'Nebr|Nev|Mex|Dak|Okla|Ok|Ore|Penna|Penn|Pa|Tenn|Tex|Ut|Vt|Va|' + 'Wash|Wis|Wisc|Wyo|' + 'Alta|Man|Ont|Qu\u00E9|Que|Sask|Yuk|' + 'Beds|Berks|Bucks|Cambs|Ches|Corn|Cumb|Derbys|Derbs|Dev|Dor|Dur|' + 'Glos|Hants|Here|Heref|Herts|Hunts|Lancs|Leics|Lincs|Mx|Middx|Mddx|' + 'Norf|Northants|Northumb|Northd|Notts|Oxon|Rut|Shrops|Salop|Som|' + 'Staffs|Staf|Suff|Sy|Sx|Ssx|Warks|War|Warw|Westm|Wilts|Worcs|Yorks' + ')$');
1026
- var elisionPrefix = new RegExp('^(' + 'o|ol' + ')$');
1027
- var elisionAffix = new RegExp('^(' + 'im|er|em|cause|' + 'twas|tis|twere|' + '\\d\\ds?' + ')$');
1028
- var apostrophe = /^['\u2019]$/;
1029
- function mergeEnglishPrefixExceptions(sentence, index, paragraph) {
1030
- var children = sentence.children;
1031
- var period = children[children.length - 1];
1032
- var word = children[children.length - 2];
1033
- var value;
1034
- var next;
1035
- if (period && nlcstToString_1(period) === '.' && word && word.type === 'WordNode') {
1036
- value = nlcstToString_1(word);
1037
- if (abbreviations.test(lower(value)) || abbreviationsSensitive.test(value)) {
1038
- word.children.push(period);
1039
- children.pop();
1040
- if (period.position && word.position) {
1041
- word.position.end = period.position.end;
1042
- }
1043
- next = paragraph.children[index + 1];
1044
- if (next) {
1045
- sentence.children = children.concat(next.children);
1046
- paragraph.children.splice(index + 1, 1);
1047
- if (next.position && sentence.position) {
1048
- sentence.position.end = next.position.end;
1049
- }
1050
- return index - 1;
1051
- }
1052
- }
1053
- }
1054
- }
1055
- function mergeEnglishElisionExceptions(child, index, sentence) {
1056
- var siblings;
1057
- var sibling;
1058
- var other;
1059
- var length;
1060
- var value;
1061
- if (child.type !== 'PunctuationNode' && child.type !== 'SymbolNode') {
1062
- return;
1063
- }
1064
- siblings = sentence.children;
1065
- length = siblings.length;
1066
- value = nlcstToString_1(child);
1067
- if (value === '/') {
1068
- sibling = siblings[index - 1];
1069
- if (sibling && lower(nlcstToString_1(sibling)) === 'w') {
1070
- siblings.splice(index, 1);
1071
- sibling.children.push(child);
1072
- if (sibling.position && child.position) {
1073
- sibling.position.end = child.position.end;
1074
- }
1075
- }
1076
- } else if (apostrophe.test(value)) {
1077
- sibling = siblings[index - 1];
1078
- if (index > 2 && index < length - 1 && sibling.type === 'WordNode' && siblings[index - 2].type === 'WhiteSpaceNode' && siblings[index + 1].type === 'WhiteSpaceNode' && elisionPrefix.test(lower(nlcstToString_1(sibling)))) {
1079
- siblings.splice(index, 1);
1080
- sibling.children.push(child);
1081
- if (sibling.position && child.position) {
1082
- sibling.position.end = child.position.end;
1083
- }
1084
- return;
1085
- }
1086
- if (index !== length - 1 && siblings[index + 1].type === 'WordNode' && (index === 0 || siblings[index - 1].type !== 'WordNode')) {
1087
- sibling = siblings[index + 1];
1088
- value = lower(nlcstToString_1(sibling));
1089
- if (elisionAffix.test(value)) {
1090
- siblings.splice(index, 1);
1091
- sibling.children = [child].concat(sibling.children);
1092
- if (sibling.position && child.position) {
1093
- sibling.position.start = child.position.start;
1094
- }
1095
- } else if (value === 'n' && index < length - 2 && apostrophe.test(nlcstToString_1(siblings[index + 2]))) {
1096
- other = siblings[index + 2];
1097
- siblings.splice(index, 1);
1098
- siblings.splice(index + 1, 1);
1099
- sibling.children = [child].concat(sibling.children, other);
1100
- if (sibling.position) {
1101
- if (child.position) {
1102
- sibling.position.start = child.position.start;
1103
- }
1104
- if (other.position) {
1105
- sibling.position.end = other.position.end;
1106
- }
1107
- }
1108
- }
1109
- }
1110
- }
1111
- }
1112
- function lower(value) {
1113
- return value.toLowerCase();
1114
- }
1115
- const {compact: compact} = _dll_lodash;
1116
- const {clone: clone} = _dll_lodash;
1117
- const g = (str, node) => {
1118
- if (node.children) {
1119
- return node.children.reduce(g, str);
1120
- } else if (node.value) {
1121
- return str + node.value;
1122
- } else {
1123
- return str;
1124
- }
1125
- };
1126
- const getParagraph = p => g('', p);
1127
- const getSentence = s => g('', s);
1128
- const getWord = w => g('', w);
1129
- const paragraphs = text => {
1130
- const tree = new parseEnglish().parse(text);
1131
- const out = tree.children.reduce((acc, child) => {
1132
- if (child.type === 'ParagraphNode') {
1133
- const paragraph = {
1134
- text: getParagraph(child),
1135
- start: child.position.start.offset,
1136
- end: child.position.end.offset
1137
- };
1138
- return acc.concat([paragraph]);
1139
- } else {
1140
- return acc;
1141
- }
1142
- }, []);
1143
- return out;
1144
- };
1145
- const handleSentence = (child, acc) => {
1146
- const sentenceChilds = [];
1147
- let newAcc = child.children.reduce(function (acc, child) {
1148
- if (child.type === 'WhiteSpaceNode' && child.value === '\n') {
1149
- if (sentenceChilds.length) {
1150
- const firstWord = sentenceChilds[0];
1151
- const sentence = {
1152
- text: sentenceChilds.map(d => getSentence(d)).join(''),
1153
- start: firstWord.position.start.offset,
1154
- end: child.position.start.offset
1155
- };
1156
- sentenceChilds.splice(0, sentenceChilds.length);
1157
- return acc.concat([sentence]);
1158
- }
1159
- } else {
1160
- sentenceChilds.push(child);
1161
- }
1162
- return acc;
1163
- }, acc);
1164
- if (sentenceChilds.length) {
1165
- const firstWord = sentenceChilds[0];
1166
- const lastWord = sentenceChilds[sentenceChilds.length - 1];
1167
- const sentence = {
1168
- text: sentenceChilds.map(d => getSentence(d)).join(''),
1169
- start: firstWord.position.start.offset,
1170
- end: lastWord.position.end.offset
1171
- };
1172
- newAcc = newAcc.concat([sentence]);
1173
- sentenceChilds.splice(0, sentenceChilds.length);
1174
- }
1175
- return newAcc;
1176
- };
1177
- const sentences = text => {
1178
- const tree = new parseEnglish().parse(text);
1179
- const out = tree.children.reduce((acc, child) => {
1180
- if (child.type === 'ParagraphNode') {
1181
- return child.children.reduce((acc, child) => {
1182
- if (child.type === 'SentenceNode') {
1183
- const newAcc = handleSentence(child, acc);
1184
- return newAcc || acc;
1185
- } else {
1186
- return acc;
1187
- }
1188
- }, acc);
1189
- } else {
1190
- return acc;
1191
- }
1192
- }, []);
1193
- return out;
1194
- };
1195
- const words = text => {
1196
- const tree = new parseEnglish().parse(text);
1197
- const out = tree.children.reduce((acc, child) => {
1198
- if (child.type === 'ParagraphNode') {
1199
- return child.children.reduce((acc, child) => {
1200
- if (child.type === 'SentenceNode') {
1201
- return child.children.reduce((acc, child) => {
1202
- if (child.type === 'WordNode') {
1203
- const node = {
1204
- text: getWord(child),
1205
- start: child.position.start.offset,
1206
- end: child.position.end.offset
1207
- };
1208
- return acc.concat([node]);
1209
- } else {
1210
- return acc;
1211
- }
1212
- }, acc);
1213
- } else {
1214
- return acc;
1215
- }
1216
- }, acc);
1217
- } else {
1218
- return acc;
1219
- }
1220
- }, []);
1221
- return out;
1222
- };
1223
- class Intersection {
1224
- constructor(results) {
1225
- this.results = results;
1226
- }
1227
- get hasOverlap() {
1228
- return this.results.filter(r => r.type === 'overlap').length > 0;
1229
- }
1230
- get surroundedTokens() {
1231
- return this.results.filter(r => r.type === 'within-selection').map(t => t.token);
1232
- }
1233
- }
1234
- const intersection = (selection, tokens) => {
1235
- const {start, end} = selection;
1236
- const startsWithin = t => start >= t.start && start < t.end;
1237
- const endsWithin = t => end > t.start && end <= t.end;
1238
- const mapped = tokens.map(t => {
1239
- if (start === t.start && end === t.end) {
1240
- return {
1241
- token: t,
1242
- type: 'exact-fit'
1243
- };
1244
- } else if (start <= t.start && end >= t.end) {
1245
- return {
1246
- token: t,
1247
- type: 'within-selection'
1248
- };
1249
- } else if (startsWithin(t) || endsWithin(t)) {
1250
- return {
1251
- token: t,
1252
- type: 'overlap'
1253
- };
1254
- }
1255
- });
1256
- return new Intersection(compact(mapped));
1257
- };
1258
- const sort = tokens => {
1259
- if (!Array.isArray(tokens)) {
1260
- return tokens;
1261
- } else {
1262
- const out = clone(tokens);
1263
- out.sort((a, b) => {
1264
- const s = a.start < b.start ? -1 : a.start > b.start ? 1 : 0;
1265
- const e = a.end < b.end ? -1 : a.end > b.end ? 1 : 0;
1266
- if (s === -1 && e !== -1) {
1267
- throw new Error(`sort does not support intersecting tokens. a: ${a.start}-${a.end}, b: ${b.start}-${b.end}`);
1268
- }
1269
- return s;
1270
- });
1271
- return out;
1272
- }
1273
- };
1274
- const normalize = (textToNormalize, tokens) => {
1275
- const text = textToNormalize || '';
1276
- if (!Array.isArray(tokens) || tokens.length === 0) {
1277
- return [{
1278
- text,
1279
- start: 0,
1280
- end: text.length
1281
- }];
1282
- }
1283
- const out = sort(tokens).reduce((acc, t, index, outer) => {
1284
- let tokens = [];
1285
- const lastIndex = acc.lastIndex;
1286
- if (t.start === lastIndex) {
1287
- tokens = [{
1288
- text: text.substring(lastIndex, t.end),
1289
- start: lastIndex,
1290
- end: t.end,
1291
- predefined: true,
1292
- correct: t.correct
1293
- }];
1294
- } else if (lastIndex < t.start) {
1295
- tokens = [{
1296
- text: text.substring(lastIndex, t.start),
1297
- start: lastIndex,
1298
- end: t.start
1299
- }, {
1300
- text: text.substring(t.start, t.end),
1301
- start: t.start,
1302
- end: t.end,
1303
- predefined: true,
1304
- correct: t.correct
1305
- }];
1306
- }
1307
- if (index === outer.length - 1 && t.end < text.length) {
1308
- const last = {
1309
- text: text.substring(t.end),
1310
- start: t.end,
1311
- end: text.length
1312
- };
1313
- tokens.push(last);
1314
- }
1315
- return {
1316
- lastIndex: tokens.length ? tokens[tokens.length - 1].end : lastIndex,
1317
- result: acc.result.concat(tokens)
1318
- };
1319
- }, {
1320
- result: [],
1321
- lastIndex: 0
1322
- });
1323
- return out.result;
1324
- };
1325
- function createCommonjsModule(fn, module) {
1326
- return (module = {
1327
- exports: {}
1328
- }, fn(module, module.exports), module.exports);
1329
- }
1330
- var classnames = createCommonjsModule(function (module) {
1331
- (function () {
1332
- var hasOwn = ({}).hasOwnProperty;
1333
- function classNames() {
1334
- var classes = [];
1335
- for (var i = 0; i < arguments.length; i++) {
1336
- var arg = arguments[i];
1337
- if (!arg) continue;
1338
- var argType = typeof arg;
1339
- if (argType === 'string' || argType === 'number') {
1340
- classes.push(arg);
1341
- } else if (Array.isArray(arg) && arg.length) {
1342
- var inner = classNames.apply(null, arg);
1343
- if (inner) {
1344
- classes.push(inner);
1345
- }
1346
- } else if (argType === 'object') {
1347
- for (var key in arg) {
1348
- if (hasOwn.call(arg, key) && arg[key]) {
1349
- classes.push(key);
1350
- }
1351
- }
1352
- }
1353
- }
1354
- return classes.join(' ');
1355
- }
1356
- if (module.exports) {
1357
- classNames.default = classNames;
1358
- module.exports = classNames;
1359
- } else {
1360
- window.classNames = classNames;
1361
- }
1362
- })();
1363
- });
1364
- const noSelect = () => ({
1365
- cursor: 'default',
1366
- '-webkit-user-select': 'none',
1367
- '-moz-user-select': 'none',
1368
- '-ms-user-select': 'none',
1369
- 'user-select': 'none'
1370
- });
1371
- var s = 1000;
1372
- var m = s * 60;
1373
- var h = m * 60;
1374
- var d = h * 24;
1375
- var w = d * 7;
1376
- var y = d * 365.25;
1377
- var ms = function (val, options) {
1378
- options = options || ({});
1379
- var type = typeof val;
1380
- if (type === 'string' && val.length > 0) {
1381
- return parse(val);
1382
- } else if (type === 'number' && isFinite(val)) {
1383
- return options.long ? fmtLong(val) : fmtShort(val);
1384
- }
1385
- throw new Error('val is not a non-empty string or a valid number. val=' + JSON.stringify(val));
1386
- };
1387
- function parse(str) {
1388
- str = String(str);
1389
- if (str.length > 100) {
1390
- return;
1391
- }
1392
- var match = (/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i).exec(str);
1393
- if (!match) {
1394
- return;
1395
- }
1396
- var n = parseFloat(match[1]);
1397
- var type = (match[2] || 'ms').toLowerCase();
1398
- switch (type) {
1399
- case 'years':
1400
- case 'year':
1401
- case 'yrs':
1402
- case 'yr':
1403
- case 'y':
1404
- return n * y;
1405
- case 'weeks':
1406
- case 'week':
1407
- case 'w':
1408
- return n * w;
1409
- case 'days':
1410
- case 'day':
1411
- case 'd':
1412
- return n * d;
1413
- case 'hours':
1414
- case 'hour':
1415
- case 'hrs':
1416
- case 'hr':
1417
- case 'h':
1418
- return n * h;
1419
- case 'minutes':
1420
- case 'minute':
1421
- case 'mins':
1422
- case 'min':
1423
- case 'm':
1424
- return n * m;
1425
- case 'seconds':
1426
- case 'second':
1427
- case 'secs':
1428
- case 'sec':
1429
- case 's':
1430
- return n * s;
1431
- case 'milliseconds':
1432
- case 'millisecond':
1433
- case 'msecs':
1434
- case 'msec':
1435
- case 'ms':
1436
- return n;
1437
- default:
1438
- return undefined;
1439
- }
1440
- }
1441
- function fmtShort(ms) {
1442
- var msAbs = Math.abs(ms);
1443
- if (msAbs >= d) {
1444
- return Math.round(ms / d) + 'd';
1445
- }
1446
- if (msAbs >= h) {
1447
- return Math.round(ms / h) + 'h';
1448
- }
1449
- if (msAbs >= m) {
1450
- return Math.round(ms / m) + 'm';
1451
- }
1452
- if (msAbs >= s) {
1453
- return Math.round(ms / s) + 's';
1454
- }
1455
- return ms + 'ms';
1456
- }
1457
- function fmtLong(ms) {
1458
- var msAbs = Math.abs(ms);
1459
- if (msAbs >= d) {
1460
- return plural(ms, msAbs, d, 'day');
1461
- }
1462
- if (msAbs >= h) {
1463
- return plural(ms, msAbs, h, 'hour');
1464
- }
1465
- if (msAbs >= m) {
1466
- return plural(ms, msAbs, m, 'minute');
1467
- }
1468
- if (msAbs >= s) {
1469
- return plural(ms, msAbs, s, 'second');
1470
- }
1471
- return ms + ' ms';
1472
- }
1473
- function plural(ms, msAbs, n, name) {
1474
- var isPlural = msAbs >= n * 1.5;
1475
- return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
1476
- }
1477
- function setup(env) {
1478
- createDebug.debug = createDebug;
1479
- createDebug.default = createDebug;
1480
- createDebug.coerce = coerce;
1481
- createDebug.disable = disable;
1482
- createDebug.enable = enable;
1483
- createDebug.enabled = enabled;
1484
- createDebug.humanize = ms;
1485
- createDebug.destroy = destroy;
1486
- Object.keys(env).forEach(key => {
1487
- createDebug[key] = env[key];
1488
- });
1489
- createDebug.names = [];
1490
- createDebug.skips = [];
1491
- createDebug.formatters = {};
1492
- function selectColor(namespace) {
1493
- let hash = 0;
1494
- for (let i = 0; i < namespace.length; i++) {
1495
- hash = (hash << 5) - hash + namespace.charCodeAt(i);
1496
- hash |= 0;
1497
- }
1498
- return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
1499
- }
1500
- createDebug.selectColor = selectColor;
1501
- function createDebug(namespace) {
1502
- let prevTime;
1503
- let enableOverride = null;
1504
- function debug(...args) {
1505
- if (!debug.enabled) {
1506
- return;
1507
- }
1508
- const self = debug;
1509
- const curr = Number(new Date());
1510
- const ms = curr - (prevTime || curr);
1511
- self.diff = ms;
1512
- self.prev = prevTime;
1513
- self.curr = curr;
1514
- prevTime = curr;
1515
- args[0] = createDebug.coerce(args[0]);
1516
- if (typeof args[0] !== 'string') {
1517
- args.unshift('%O');
1518
- }
1519
- let index = 0;
1520
- args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
1521
- if (match === '%%') {
1522
- return '%';
1523
- }
1524
- index++;
1525
- const formatter = createDebug.formatters[format];
1526
- if (typeof formatter === 'function') {
1527
- const val = args[index];
1528
- match = formatter.call(self, val);
1529
- args.splice(index, 1);
1530
- index--;
1531
- }
1532
- return match;
1533
- });
1534
- createDebug.formatArgs.call(self, args);
1535
- const logFn = self.log || createDebug.log;
1536
- logFn.apply(self, args);
1537
- }
1538
- debug.namespace = namespace;
1539
- debug.useColors = createDebug.useColors();
1540
- debug.color = createDebug.selectColor(namespace);
1541
- debug.extend = extend;
1542
- debug.destroy = createDebug.destroy;
1543
- Object.defineProperty(debug, 'enabled', {
1544
- enumerable: true,
1545
- configurable: false,
1546
- get: () => enableOverride === null ? createDebug.enabled(namespace) : enableOverride,
1547
- set: v => {
1548
- enableOverride = v;
1549
- }
1550
- });
1551
- if (typeof createDebug.init === 'function') {
1552
- createDebug.init(debug);
1553
- }
1554
- return debug;
1555
- }
1556
- function extend(namespace, delimiter) {
1557
- const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
1558
- newDebug.log = this.log;
1559
- return newDebug;
1560
- }
1561
- function enable(namespaces) {
1562
- createDebug.save(namespaces);
1563
- createDebug.names = [];
1564
- createDebug.skips = [];
1565
- let i;
1566
- const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
1567
- const len = split.length;
1568
- for (i = 0; i < len; i++) {
1569
- if (!split[i]) {
1570
- continue;
1571
- }
1572
- namespaces = split[i].replace(/\*/g, '.*?');
1573
- if (namespaces[0] === '-') {
1574
- createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
1575
- } else {
1576
- createDebug.names.push(new RegExp('^' + namespaces + '$'));
1577
- }
1578
- }
1579
- }
1580
- function disable() {
1581
- const namespaces = [...createDebug.names.map(toNamespace), ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)].join(',');
1582
- createDebug.enable('');
1583
- return namespaces;
1584
- }
1585
- function enabled(name) {
1586
- if (name[name.length - 1] === '*') {
1587
- return true;
1588
- }
1589
- let i;
1590
- let len;
1591
- for ((i = 0, len = createDebug.skips.length); i < len; i++) {
1592
- if (createDebug.skips[i].test(name)) {
1593
- return false;
1594
- }
1595
- }
1596
- for ((i = 0, len = createDebug.names.length); i < len; i++) {
1597
- if (createDebug.names[i].test(name)) {
1598
- return true;
1599
- }
1600
- }
1601
- return false;
1602
- }
1603
- function toNamespace(regexp) {
1604
- return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*');
1605
- }
1606
- function coerce(val) {
1607
- if (val instanceof Error) {
1608
- return val.stack || val.message;
1609
- }
1610
- return val;
1611
- }
1612
- function destroy() {
1613
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1614
- }
1615
- createDebug.enable(createDebug.load());
1616
- return createDebug;
1617
- }
1618
- var common = setup;
1619
- var browser = createCommonjsModule(function (module, exports) {
1620
- exports.formatArgs = formatArgs;
1621
- exports.save = save;
1622
- exports.load = load;
1623
- exports.useColors = useColors;
1624
- exports.storage = localstorage();
1625
- exports.destroy = (() => {
1626
- let warned = false;
1627
- return () => {
1628
- if (!warned) {
1629
- warned = true;
1630
- console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
1631
- }
1632
- };
1633
- })();
1634
- exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33'];
1635
- function useColors() {
1636
- if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
1637
- return true;
1638
- }
1639
- if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
1640
- return false;
1641
- }
1642
- return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/);
1643
- }
1644
- function formatArgs(args) {
1645
- args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff);
1646
- if (!this.useColors) {
1647
- return;
1648
- }
1649
- const c = 'color: ' + this.color;
1650
- args.splice(1, 0, c, 'color: inherit');
1651
- let index = 0;
1652
- let lastC = 0;
1653
- args[0].replace(/%[a-zA-Z%]/g, match => {
1654
- if (match === '%%') {
1655
- return;
1656
- }
1657
- index++;
1658
- if (match === '%c') {
1659
- lastC = index;
1660
- }
1661
- });
1662
- args.splice(lastC, 0, c);
1663
- }
1664
- exports.log = console.debug || console.log || (() => {});
1665
- function save(namespaces) {
1666
- try {
1667
- if (namespaces) {
1668
- exports.storage.setItem('debug', namespaces);
1669
- } else {
1670
- exports.storage.removeItem('debug');
1671
- }
1672
- } catch (error) {}
1673
- }
1674
- function load() {
1675
- let r;
1676
- try {
1677
- r = exports.storage.getItem('debug');
1678
- } catch (error) {}
1679
- if (!r && typeof process !== 'undefined' && ('env' in process)) {
1680
- r = process.env.DEBUG;
1681
- }
1682
- return r;
1683
- }
1684
- function localstorage() {
1685
- try {
1686
- return localStorage;
1687
- } catch (error) {}
1688
- }
1689
- module.exports = common(exports);
1690
- const {formatters} = module.exports;
1691
- formatters.j = function (v) {
1692
- try {
1693
- return JSON.stringify(v);
1694
- } catch (error) {
1695
- return '[UnexpectedJSONParseError]: ' + error.message;
1696
- }
1697
- };
1698
- });
1699
- browser.formatArgs;
1700
- browser.save;
1701
- browser.load;
1702
- browser.useColors;
1703
- browser.storage;
1704
- browser.destroy;
1705
- browser.colors;
1706
- browser.log;
1707
- const clearSelection = () => {
1708
- if (document.getSelection) {
1709
- document.getSelection().removeAllRanges();
1710
- document.getSelection().addRange(document.createRange());
1711
- } else if (window.getSelection) {
1712
- if (window.getSelection().removeAllRanges) {
1713
- window.getSelection().removeAllRanges();
1714
- window.getSelection().addRange(document.createRange());
1715
- } else if (window.getSelection().empty) {
1716
- window.getSelection().empty();
1717
- }
1718
- } else if (document.selection) {
1719
- document.selection.empty();
1720
- }
1721
- };
1722
- const getCaretCharacterOffsetWithin = element => {
1723
- var caretOffset = 0;
1724
- var doc = element.ownerDocument || element.document;
1725
- var win = doc.defaultView || doc.parentWindow;
1726
- var sel;
1727
- if (typeof win.getSelection !== 'undefined') {
1728
- sel = win.getSelection();
1729
- if (sel.rangeCount > 0) {
1730
- var range = win.getSelection().getRangeAt(0);
1731
- var selected = range.toString().length;
1732
- var preCaretRange = range.cloneRange();
1733
- preCaretRange.selectNodeContents(element);
1734
- preCaretRange.setEnd(range.endContainer, range.endOffset);
1735
- if (selected) {
1736
- caretOffset = preCaretRange.toString().length - selected;
1737
- } else {
1738
- caretOffset = preCaretRange.toString().length;
1739
- }
1740
- }
1741
- } else if ((sel = doc.selection) && sel.type != 'Control') {
1742
- var textRange = sel.createRange();
1743
- var preCaretTextRange = doc.body.createTextRange();
1744
- preCaretTextRange.moveToElementText(element);
1745
- preCaretTextRange.setEndPoint('EndToEnd', textRange);
1746
- caretOffset = preCaretTextRange.text.length;
1747
- }
1748
- return caretOffset;
1749
- };
1750
- const React$1 = _dll_react;
1751
- const PropTypes$1 = _dll_prop_types;
1752
- const {withStyles: withStyles$1} = _dll_material_ui__core_styles;
1753
- const {colors: {yellow: yellow}} = _dll_material_ui__core;
1754
- const {colors: {green: green}} = _dll_material_ui__core;
1755
- const _jsxFileName$1 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/tokenizer/token-text.jsx";
1756
- const log = browser('@pie-lib:text-select:token-text');
1757
- const Text = withStyles$1(() => ({
1758
- predefined: {
1759
- cursor: 'pointer',
1760
- backgroundColor: yellow[100],
1761
- border: `dashed 0px ${yellow[700]}`
1762
- },
1763
- correct: {
1764
- backgroundColor: green[500]
1765
- }
1766
- }))(({text, predefined, classes, onClick, correct}) => {
1767
- const formattedText = (text || '').replace(/\n/g, '<br>');
1768
- if (predefined) {
1769
- const className = classnames(classes.predefined, correct && classes.correct);
1770
- return React$1.createElement('span', {
1771
- onClick: onClick,
1772
- className: className,
1773
- dangerouslySetInnerHTML: {
1774
- __html: formattedText
1775
- },
1776
- __self: undefined,
1777
- __source: {
1778
- fileName: _jsxFileName$1,
1779
- lineNumber: 30
1780
- }
1781
- });
1782
- } else {
1783
- return React$1.createElement('span', {
1784
- dangerouslySetInnerHTML: {
1785
- __html: formattedText
1786
- },
1787
- __self: undefined,
1788
- __source: {
1789
- fileName: _jsxFileName$1,
1790
- lineNumber: 37
1791
- }
1792
- });
1793
- }
1794
- });
1795
- class TokenText extends React$1.Component {
1796
- constructor(...args) {
1797
- super(...args);
1798
- TokenText.prototype.__init.call(this);
1799
- }
1800
- static __initStatic() {
1801
- this.propTypes = {
1802
- text: PropTypes$1.string.isRequired,
1803
- tokens: PropTypes$1.array.isRequired,
1804
- onTokenClick: PropTypes$1.func.isRequired,
1805
- onSelectToken: PropTypes$1.func.isRequired,
1806
- className: PropTypes$1.string
1807
- };
1808
- }
1809
- __init() {
1810
- this.mouseUp = event => {
1811
- event.preventDefault();
1812
- const {onSelectToken, text, tokens} = this.props;
1813
- if (typeof window === 'undefined') {
1814
- return;
1815
- }
1816
- const selection = window.getSelection();
1817
- const textSelected = selection.toString();
1818
- if (textSelected.length > 0) {
1819
- if (this.root) {
1820
- const offset = getCaretCharacterOffsetWithin(this.root);
1821
- if (offset !== undefined) {
1822
- const endIndex = offset + textSelected.length;
1823
- if (endIndex <= text.length) {
1824
- const i = intersection({
1825
- start: offset,
1826
- end: endIndex
1827
- }, tokens);
1828
- if (i.hasOverlap) {
1829
- log('hasOverlap - do nothing');
1830
- clearSelection();
1831
- } else {
1832
- const tokensToRemove = i.surroundedTokens;
1833
- const token = {
1834
- text: textSelected,
1835
- start: offset,
1836
- end: endIndex
1837
- };
1838
- onSelectToken(token, tokensToRemove);
1839
- clearSelection();
1840
- }
1841
- }
1842
- }
1843
- }
1844
- }
1845
- };
1846
- }
1847
- render() {
1848
- const {text, tokens, className, onTokenClick} = this.props;
1849
- const normalized = normalize(text, tokens);
1850
- return React$1.createElement('div', {
1851
- className: className,
1852
- ref: r => this.root = r,
1853
- onMouseUp: this.mouseUp,
1854
- __self: this,
1855
- __source: {
1856
- fileName: _jsxFileName$1,
1857
- lineNumber: 95
1858
- }
1859
- }, normalized.map((t, index) => {
1860
- return React$1.createElement(Text, {
1861
- key: index,
1862
- ...t,
1863
- onClick: () => onTokenClick(t),
1864
- __self: this,
1865
- __source: {
1866
- fileName: _jsxFileName$1,
1867
- lineNumber: 97
1868
- }
1869
- });
1870
- }));
1871
- }
1872
- }
1873
- TokenText.__initStatic();
1874
- const React$2 = _dll_react;
1875
- const PropTypes$2 = _dll_prop_types;
1876
- const {withStyles: withStyles$2} = _dll_material_ui__core_styles;
1877
- const {clone: clone$1} = _dll_lodash;
1878
- const {isEqual: isEqual} = _dll_lodash;
1879
- const {differenceWith: differenceWith} = _dll_lodash;
1880
- const _jsxFileName$2 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/tokenizer/index.jsx";
1881
- class Tokenizer extends React$2.Component {
1882
- static __initStatic() {
1883
- this.propTypes = {
1884
- text: PropTypes$2.string.isRequired,
1885
- tokens: PropTypes$2.arrayOf(PropTypes$2.shape({
1886
- text: PropTypes$2.string,
1887
- correct: PropTypes$2.bool,
1888
- start: PropTypes$2.number,
1889
- end: PropTypes$2.number
1890
- })),
1891
- classes: PropTypes$2.object.isRequired,
1892
- className: PropTypes$2.string,
1893
- onChange: PropTypes$2.func.isRequired
1894
- };
1895
- }
1896
- static __initStatic2() {
1897
- this.defaultProps = {};
1898
- }
1899
- constructor(props) {
1900
- super(props);
1901
- Tokenizer.prototype.__init.call(this);
1902
- Tokenizer.prototype.__init2.call(this);
1903
- Tokenizer.prototype.__init3.call(this);
1904
- Tokenizer.prototype.__init4.call(this);
1905
- Tokenizer.prototype.__init5.call(this);
1906
- Tokenizer.prototype.__init6.call(this);
1907
- Tokenizer.prototype.__init7.call(this);
1908
- Tokenizer.prototype.__init8.call(this);
1909
- Tokenizer.prototype.__init9.call(this);
1910
- this.state = {
1911
- setCorrectMode: false,
1912
- mode: ''
1913
- };
1914
- }
1915
- __init() {
1916
- this.onChangeHandler = (token, mode) => {
1917
- this.props.onChange(token, mode);
1918
- this.setState({
1919
- mode
1920
- });
1921
- };
1922
- }
1923
- __init2() {
1924
- this.toggleCorrectMode = () => this.setState({
1925
- setCorrectMode: !this.state.setCorrectMode
1926
- });
1927
- }
1928
- __init3() {
1929
- this.clear = () => {
1930
- this.onChangeHandler([], '');
1931
- };
1932
- }
1933
- __init4() {
1934
- this.buildTokens = (type, fn) => {
1935
- const {text} = this.props;
1936
- const tokens = fn(text);
1937
- this.onChangeHandler(tokens, type);
1938
- };
1939
- }
1940
- __init5() {
1941
- this.selectToken = (newToken, tokensToRemove) => {
1942
- const {tokens} = this.props;
1943
- const update = differenceWith(clone$1(tokens), tokensToRemove, isEqual);
1944
- update.push(newToken);
1945
- this.onChangeHandler(update, this.state.mode);
1946
- };
1947
- }
1948
- __init6() {
1949
- this.tokenClick = token => {
1950
- const {setCorrectMode} = this.state;
1951
- if (setCorrectMode) {
1952
- this.setCorrect(token);
1953
- } else {
1954
- this.removeToken(token);
1955
- }
1956
- };
1957
- }
1958
- __init7() {
1959
- this.tokenIndex = token => {
1960
- const {tokens} = this.props;
1961
- return tokens.findIndex(t => {
1962
- return t.text == token.text && t.start == token.start && t.end == token.end;
1963
- });
1964
- };
1965
- }
1966
- __init8() {
1967
- this.setCorrect = token => {
1968
- const {tokens} = this.props;
1969
- const index = this.tokenIndex(token);
1970
- if (index !== -1) {
1971
- const t = tokens[index];
1972
- t.correct = !t.correct;
1973
- const update = clone$1(tokens);
1974
- update.splice(index, 1, t);
1975
- this.onChangeHandler(update, this.state.mode);
1976
- }
1977
- };
1978
- }
1979
- __init9() {
1980
- this.removeToken = token => {
1981
- const {tokens} = this.props;
1982
- const index = this.tokenIndex(token);
1983
- if (index !== -1) {
1984
- const update = clone$1(tokens);
1985
- update.splice(index, 1);
1986
- this.onChangeHandler(update, this.state.mode);
1987
- }
1988
- };
1989
- }
1990
- render() {
1991
- const {text, tokens, classes, className} = this.props;
1992
- const {setCorrectMode} = this.state;
1993
- const tokenClassName = classnames(classes.text, setCorrectMode && classes.noselect);
1994
- const rootName = classnames(classes.tokenizer, className);
1995
- return React$2.createElement('div', {
1996
- className: rootName,
1997
- __self: this,
1998
- __source: {
1999
- fileName: _jsxFileName$2,
2000
- lineNumber: 123
2001
- }
2002
- }, React$2.createElement(Controls$1, {
2003
- onClear: this.clear,
2004
- onWords: () => this.buildTokens('words', words),
2005
- onSentences: () => this.buildTokens('sentence', sentences),
2006
- onParagraphs: () => this.buildTokens('paragraphs', paragraphs),
2007
- setCorrectMode: setCorrectMode,
2008
- onToggleCorrectMode: this.toggleCorrectMode,
2009
- __self: this,
2010
- __source: {
2011
- fileName: _jsxFileName$2,
2012
- lineNumber: 124
2013
- }
2014
- }), React$2.createElement(TokenText, {
2015
- className: tokenClassName,
2016
- text: text,
2017
- tokens: tokens,
2018
- onTokenClick: this.tokenClick,
2019
- onSelectToken: this.selectToken,
2020
- __self: this,
2021
- __source: {
2022
- fileName: _jsxFileName$2,
2023
- lineNumber: 132
2024
- }
2025
- }));
2026
- }
2027
- }
2028
- Tokenizer.__initStatic();
2029
- Tokenizer.__initStatic2();
2030
- withStyles$2(theme => ({
2031
- text: {
2032
- marginTop: theme.spacing.unit,
2033
- paddingTop: theme.spacing.unit,
2034
- paddingBottom: theme.spacing.unit
2035
- },
2036
- noselect: {
2037
- ...noSelect()
2038
- }
2039
- }))(Tokenizer);
2040
- const React$3 = _dll_react;
2041
- const PropTypes$3 = _dll_prop_types;
2042
- const {withStyles: withStyles$3} = _dll_material_ui__core_styles;
2043
- const {color: color} = _dll_pie_lib__render_ui;
2044
- const _jsxFileName$3 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/token-select/token.jsx";
2045
- const TokenTypes = {
2046
- text: PropTypes$3.string,
2047
- selectable: PropTypes$3.bool
2048
- };
2049
- class Token extends React$3.Component {
2050
- static __initStatic() {
2051
- this.rootClassName = 'tokenRootClass';
2052
- }
2053
- static __initStatic2() {
2054
- this.propTypes = {
2055
- ...TokenTypes,
2056
- classes: PropTypes$3.object.isRequired,
2057
- className: PropTypes$3.string,
2058
- disabled: PropTypes$3.bool,
2059
- highlight: PropTypes$3.bool,
2060
- correct: PropTypes$3.bool,
2061
- text: PropTypes$3.string.isRequired
2062
- };
2063
- }
2064
- static __initStatic3() {
2065
- this.defaultProps = {
2066
- selectable: false,
2067
- text: ''
2068
- };
2069
- }
2070
- render() {
2071
- const {text, selectable, selected, classes, className: classNameProp, disabled, index, highlight, correct} = this.props;
2072
- let className;
2073
- if (correct === undefined && selected && disabled) {
2074
- className = classnames(classes.token, classes.selected, classes.disabled);
2075
- } else if (correct !== undefined) {
2076
- className = classnames(Token.rootClassName, classes.custom, correct === true && classes.correct, correct === false && classes.incorrect);
2077
- } else {
2078
- className = classnames(Token.rootClassName, classes.token, disabled && classes.disabled, selectable && !disabled && classes.selectable, selected && !disabled && classes.selected, selected && disabled && classes.disabledAndSelected, highlight && selectable && !disabled && !selected && classes.highlight, classNameProp);
2079
- }
2080
- return React$3.createElement('span', {
2081
- className: className,
2082
- dangerouslySetInnerHTML: {
2083
- __html: (text || '').replace(/\n/g, '<br>')
2084
- },
2085
- 'data-indexkey': index,
2086
- __self: this,
2087
- __source: {
2088
- fileName: _jsxFileName$3,
2089
- lineNumber: 68
2090
- }
2091
- });
2092
- }
2093
- }
2094
- Token.__initStatic();
2095
- Token.__initStatic2();
2096
- Token.__initStatic3();
2097
- var Token$1 = withStyles$3(theme => {
2098
- return {
2099
- token: {
2100
- cursor: 'pointer',
2101
- textIndent: 0,
2102
- padding: theme.spacing.unit / 2,
2103
- paddingRight: 0,
2104
- paddingLeft: 0,
2105
- transition: 'background-color 100ms ease-in'
2106
- },
2107
- disabled: {
2108
- cursor: 'inherit',
2109
- color: 'grey'
2110
- },
2111
- disabledAndSelected: {
2112
- backgroundColor: 'pink'
2113
- },
2114
- selectable: {
2115
- '&:hover': {
2116
- backgroundColor: color.primaryLight(),
2117
- '& > *': {
2118
- backgroundColor: color.primaryLight()
2119
- }
2120
- }
2121
- },
2122
- selected: {
2123
- lineHeight: 2,
2124
- marginTop: theme.spacing.unit / 2,
2125
- '&:hover': {
2126
- backgroundColor: color.primaryLight()
2127
- },
2128
- backgroundColor: color.primaryLight(),
2129
- '& > *': {
2130
- backgroundColor: color.primaryLight()
2131
- }
2132
- },
2133
- highlight: {
2134
- border: 'dashed 2px gray',
2135
- lineHeight: 2,
2136
- boxSizing: 'border-box',
2137
- marginTop: theme.spacing.unit / 2,
2138
- display: 'inline-block',
2139
- padding: theme.spacing.unit
2140
- },
2141
- custom: {
2142
- display: 'initial'
2143
- },
2144
- correct: {
2145
- backgroundColor: color.correct()
2146
- },
2147
- incorrect: {
2148
- backgroundColor: color.incorrect()
2149
- }
2150
- };
2151
- })(Token);
2152
- const React$4 = _dll_react;
2153
- const PropTypes$4 = _dll_prop_types;
2154
- const {withStyles: withStyles$4} = _dll_material_ui__core_styles;
2155
- const {clone: clone$2} = _dll_lodash;
2156
- const {renderToString: renderToString} = _dll_react_dom_server;
2157
- const _jsxFileName$4 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/token-select/index.jsx";
2158
- const log$1 = browser('@pie-lib:text-select:token-select');
2159
- class TokenSelect extends React$4.Component {
2160
- constructor(...args) {
2161
- super(...args);
2162
- TokenSelect.prototype.__init.call(this);
2163
- TokenSelect.prototype.__init2.call(this);
2164
- TokenSelect.prototype.__init3.call(this);
2165
- TokenSelect.prototype.__init4.call(this);
2166
- }
2167
- static __initStatic() {
2168
- this.propTypes = {
2169
- tokens: PropTypes$4.arrayOf(PropTypes$4.shape(TokenTypes)).isRequired,
2170
- className: PropTypes$4.string,
2171
- classes: PropTypes$4.object.isRequired,
2172
- onChange: PropTypes$4.func.isRequired,
2173
- disabled: PropTypes$4.bool,
2174
- highlightChoices: PropTypes$4.bool,
2175
- maxNoOfSelections: PropTypes$4.number
2176
- };
2177
- }
2178
- static __initStatic2() {
2179
- this.defaultProps = {
2180
- highlightChoices: false,
2181
- maxNoOfSelections: 0,
2182
- tokens: []
2183
- };
2184
- }
2185
- __init() {
2186
- this.selectedCount = () => this.props.tokens.filter(t => t.selected).length;
2187
- }
2188
- __init2() {
2189
- this.canSelectMore = selectedCount => {
2190
- const {maxNoOfSelections} = this.props;
2191
- log$1('[canSelectMore] maxNoOfSelections: ', maxNoOfSelections, 'selectedCount: ', selectedCount);
2192
- return maxNoOfSelections <= 0 || isFinite(maxNoOfSelections) && selectedCount < maxNoOfSelections;
2193
- };
2194
- }
2195
- __init3() {
2196
- this.toggleToken = event => {
2197
- const {target} = event;
2198
- const tokens = clone$2(this.props.tokens);
2199
- const targetSpanWrapper = target.closest(`.${Token$1.rootClassName}`);
2200
- const targetedTokenIndex = targetSpanWrapper && targetSpanWrapper.dataset && targetSpanWrapper.dataset.indexkey;
2201
- const t = targetedTokenIndex && tokens[targetedTokenIndex];
2202
- if (t && t.correct === undefined) {
2203
- const {onChange, maxNoOfSelections} = this.props;
2204
- const selected = !t.selected;
2205
- if (selected && maxNoOfSelections > 0 && this.selectedCount() >= maxNoOfSelections) {
2206
- log$1('skip toggle max reached');
2207
- return;
2208
- }
2209
- const update = {
2210
- ...t,
2211
- selected: !t.selected
2212
- };
2213
- tokens.splice(targetedTokenIndex, 1, update);
2214
- onChange(tokens);
2215
- }
2216
- };
2217
- }
2218
- __init4() {
2219
- this.generateTokensInHtml = () => {
2220
- const {tokens, disabled, highlightChoices} = this.props;
2221
- const selectedCount = this.selectedCount();
2222
- const isLineBreak = text => text === '\n';
2223
- const isNewParagraph = text => text === '\n\n';
2224
- const reducer = (accumulator, t, index) => {
2225
- const selectable = t.selected || t.selectable && this.canSelectMore(selectedCount);
2226
- const showCorrectAnswer = t.correct !== undefined && (t.selectable || t.selected);
2227
- let finalAcc = accumulator;
2228
- if (isNewParagraph(t.text)) {
2229
- return finalAcc + '</p><p>';
2230
- }
2231
- if (isLineBreak(t.text)) {
2232
- return finalAcc + '<br>';
2233
- }
2234
- if (!disabled || showCorrectAnswer || t.selected) {
2235
- return finalAcc + renderToString(React$4.createElement(Token$1, {
2236
- key: index,
2237
- disabled: disabled,
2238
- index: index,
2239
- ...t,
2240
- selectable: selectable,
2241
- highlight: highlightChoices,
2242
- __self: this,
2243
- __source: {
2244
- fileName: _jsxFileName$4,
2245
- lineNumber: 97
2246
- }
2247
- }));
2248
- } else {
2249
- return accumulator + t.text;
2250
- }
2251
- };
2252
- const reduceResult = (tokens || []).reduce(reducer, '<p>');
2253
- return reduceResult + '</p>';
2254
- };
2255
- }
2256
- render() {
2257
- const {classes, className: classNameProp} = this.props;
2258
- const className = classnames(classes.tokenSelect, classNameProp);
2259
- const html = this.generateTokensInHtml();
2260
- return React$4.createElement('div', {
2261
- className: className,
2262
- dangerouslySetInnerHTML: {
2263
- __html: html
2264
- },
2265
- onClick: this.toggleToken,
2266
- __self: this,
2267
- __source: {
2268
- fileName: _jsxFileName$4,
2269
- lineNumber: 123
2270
- }
2271
- });
2272
- }
2273
- }
2274
- TokenSelect.__initStatic();
2275
- TokenSelect.__initStatic2();
2276
- var TokenSelect$1 = withStyles$4(() => ({
2277
- tokenSelect: {
2278
- backgroundColor: 'none',
2279
- whiteSpace: 'pre',
2280
- ...noSelect()
2281
- }
2282
- }))(TokenSelect);
2283
- const React$5 = _dll_react;
2284
- const PropTypes$5 = _dll_prop_types;
2285
- const _jsxFileName$5 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-lib/text-select/src/text-select.jsx";
2286
- const log$2 = browser('@pie-lib:text-select');
2287
- class TextSelect extends React$5.Component {
2288
- constructor(...args) {
2289
- super(...args);
2290
- TextSelect.prototype.__init.call(this);
2291
- }
2292
- static __initStatic() {
2293
- this.propTypes = {
2294
- onChange: PropTypes$5.func,
2295
- disabled: PropTypes$5.bool,
2296
- tokens: PropTypes$5.arrayOf(PropTypes$5.shape(TokenTypes)).isRequired,
2297
- selectedTokens: PropTypes$5.arrayOf(PropTypes$5.shape(TokenTypes)).isRequired,
2298
- text: PropTypes$5.string.isRequired,
2299
- className: PropTypes$5.string,
2300
- highlightChoices: PropTypes$5.bool,
2301
- maxNoOfSelections: PropTypes$5.number
2302
- };
2303
- }
2304
- __init() {
2305
- this.change = tokens => {
2306
- const {onChange} = this.props;
2307
- if (!onChange) {
2308
- return;
2309
- }
2310
- const out = tokens.filter(t => t.selected).map(t => ({
2311
- start: t.start,
2312
- end: t.end
2313
- }));
2314
- onChange(out);
2315
- };
2316
- }
2317
- render() {
2318
- const {text, disabled, tokens, selectedTokens, className, highlightChoices, maxNoOfSelections} = this.props;
2319
- const normalized = normalize(text, tokens);
2320
- log$2('normalized: ', normalized);
2321
- const prepped = normalized.map(t => {
2322
- const selectedIndex = selectedTokens.findIndex(s => {
2323
- return s.start === t.start && s.end === t.end;
2324
- });
2325
- const selected = selectedIndex !== -1;
2326
- const correct = selected ? t.correct : undefined;
2327
- return {
2328
- ...t,
2329
- selectable: !disabled && t.predefined,
2330
- selected,
2331
- correct
2332
- };
2333
- });
2334
- return React$5.createElement(TokenSelect$1, {
2335
- highlightChoices: !disabled && highlightChoices,
2336
- className: className,
2337
- tokens: prepped,
2338
- disabled: disabled,
2339
- onChange: this.change,
2340
- maxNoOfSelections: maxNoOfSelections,
2341
- __self: this,
2342
- __source: {
2343
- fileName: _jsxFileName$5,
2344
- lineNumber: 63
2345
- }
2346
- });
2347
- }
2348
- }
2349
- TextSelect.__initStatic();
2350
- const React$6 = _dll_react;
2351
- const PropTypes$6 = _dll_prop_types;
2352
- const CorrectAnswerToggle = _dll_pie_lib__correct_answer_toggle;
2353
- const {color: color$1} = _dll_pie_lib__render_ui;
2354
- const {Feedback: Feedback} = _dll_pie_lib__render_ui;
2355
- const {Collapsible: Collapsible} = _dll_pie_lib__render_ui;
2356
- const {hasText: hasText} = _dll_pie_lib__render_ui;
2357
- const {withStyles: withStyles$5} = _dll_material_ui__core_styles;
2358
- const _jsxFileName$6 = "/home/ede/dev/github/pie-framework/pie-elements/node_modules/@pie-ui/select-text/src/main.jsx";
2359
- const log$3 = browser('@pie-ui:select-text');
2360
- const Types = {
2361
- model: PropTypes$6.object,
2362
- session: PropTypes$6.object,
2363
- onSelectionChange: PropTypes$6.func.isRequired
2364
- };
2365
- class Main extends React$6.Component {
2366
- static __initStatic() {
2367
- this.propTypes = {
2368
- ...Types,
2369
- classes: PropTypes$6.object.isRequired
2370
- };
2371
- }
2372
- static __initStatic2() {
2373
- this.defaultProps = {};
2374
- }
2375
- constructor(props) {
2376
- super(props);
2377
- Main.prototype.__init.call(this);
2378
- Main.prototype.__init2.call(this);
2379
- this.state = {
2380
- showCorrectAnswer: false
2381
- };
2382
- }
2383
- UNSAFE_componentWillReceiveProps() {
2384
- this.setState({
2385
- showCorrectAnswer: false
2386
- });
2387
- }
2388
- __init() {
2389
- this.toggleShowCorrect = () => {
2390
- this.setState({
2391
- showCorrectAnswer: !this.state.showCorrectAnswer
2392
- });
2393
- };
2394
- }
2395
- __init2() {
2396
- this.correctAnswer = () => {
2397
- const {model} = this.props;
2398
- return model.tokens.filter(t => t.correct);
2399
- };
2400
- }
2401
- render() {
2402
- const {model, session, onSelectionChange, classes} = this.props;
2403
- const {showCorrectAnswer} = this.state;
2404
- const selectedTokens = showCorrectAnswer ? this.correctAnswer() : session.selectedTokens;
2405
- log$3('[render] selectedTokens:', selectedTokens);
2406
- return React$6.createElement('div', {
2407
- className: classes.mainContainer,
2408
- __self: this,
2409
- __source: {
2410
- fileName: _jsxFileName$6,
2411
- lineNumber: 55
2412
- }
2413
- }, model.teacherInstructions && hasText(model.teacherInstructions) && React$6.createElement(Collapsible, {
2414
- labels: {
2415
- hidden: 'Show Teacher Instructions',
2416
- visible: 'Hide Teacher Instructions'
2417
- },
2418
- className: classes.collapsible,
2419
- __self: this,
2420
- __source: {
2421
- fileName: _jsxFileName$6,
2422
- lineNumber: 58
2423
- }
2424
- }, React$6.createElement('div', {
2425
- dangerouslySetInnerHTML: {
2426
- __html: model.teacherInstructions
2427
- },
2428
- __self: this,
2429
- __source: {
2430
- fileName: _jsxFileName$6,
2431
- lineNumber: 62
2432
- }
2433
- })), React$6.createElement('br', {
2434
- __self: this,
2435
- __source: {
2436
- fileName: _jsxFileName$6,
2437
- lineNumber: 66
2438
- }
2439
- }), React$6.createElement('div', {
2440
- className: classes.prompt,
2441
- dangerouslySetInnerHTML: {
2442
- __html: model.prompt
2443
- },
2444
- __self: this,
2445
- __source: {
2446
- fileName: _jsxFileName$6,
2447
- lineNumber: 67
2448
- }
2449
- }), React$6.createElement(CorrectAnswerToggle, {
2450
- show: model.disabled && model.incorrect,
2451
- toggled: showCorrectAnswer,
2452
- onToggle: this.toggleShowCorrect,
2453
- __self: this,
2454
- __source: {
2455
- fileName: _jsxFileName$6,
2456
- lineNumber: 71
2457
- }
2458
- }), React$6.createElement(TextSelect, {
2459
- className: classes.textSelect,
2460
- disabled: model.disabled,
2461
- text: model.text,
2462
- tokens: model.tokens,
2463
- selectedTokens: selectedTokens,
2464
- onChange: onSelectionChange,
2465
- highlightChoices: model.highlightChoices,
2466
- maxNoOfSelections: model.maxSelections,
2467
- __self: this,
2468
- __source: {
2469
- fileName: _jsxFileName$6,
2470
- lineNumber: 76
2471
- }
2472
- }), model.rationale && hasText(model.rationale) && React$6.createElement(Collapsible, {
2473
- labels: {
2474
- hidden: 'Show Rationale',
2475
- visible: 'Hide Rationale'
2476
- },
2477
- className: classes.collapsible,
2478
- __self: this,
2479
- __source: {
2480
- fileName: _jsxFileName$6,
2481
- lineNumber: 88
2482
- }
2483
- }, React$6.createElement('div', {
2484
- dangerouslySetInnerHTML: {
2485
- __html: model.rationale
2486
- },
2487
- __self: this,
2488
- __source: {
2489
- fileName: _jsxFileName$6,
2490
- lineNumber: 92
2491
- }
2492
- })), model.correctness && model.feedback && !showCorrectAnswer && React$6.createElement(Feedback, {
2493
- correctness: model.correctness,
2494
- feedback: model.feedback,
2495
- __self: this,
2496
- __source: {
2497
- fileName: _jsxFileName$6,
2498
- lineNumber: 97
2499
- }
2500
- }));
2501
- }
2502
- }
2503
- Main.__initStatic();
2504
- Main.__initStatic2();
2505
- const StyledMain = withStyles$5(theme => ({
2506
- mainContainer: {
2507
- paddingLeft: theme.spacing.unit,
2508
- paddingRight: theme.spacing.unit,
2509
- paddingBottom: theme.spacing.unit,
2510
- color: color$1.text(),
2511
- backgroundColor: color$1.background()
2512
- },
2513
- textSelect: {
2514
- marginBottom: theme.spacing.unit,
2515
- marginTop: theme.spacing.unit
2516
- },
2517
- prompt: {
2518
- verticalAlign: 'middle',
2519
- marginBottom: theme.spacing.unit
2520
- },
2521
- collapsible: {
2522
- paddingTop: theme.spacing.unit * 2,
2523
- paddingBottom: theme.spacing.unit * 3
2524
- }
2525
- }))(Main);
2526
- class Stateful extends React$6.Component {
2527
- static __initStatic3() {
2528
- this.propTypes = Types;
2529
- }
2530
- constructor(props) {
2531
- super(props);
2532
- Stateful.prototype.__init3.call(this);
2533
- this.state = {
2534
- model: props.model,
2535
- session: props.session
2536
- };
2537
- }
2538
- UNSAFE_componentWillReceiveProps(nextProps) {
2539
- this.setState({
2540
- model: nextProps.model,
2541
- session: nextProps.session
2542
- });
2543
- }
2544
- __init3() {
2545
- this.change = selectedTokens => {
2546
- const session = {
2547
- ...this.state.session,
2548
- selectedTokens
2549
- };
2550
- this.setState({
2551
- session
2552
- }, () => {
2553
- this.props.onSelectionChange(this.state.session.selectedTokens);
2554
- });
2555
- };
2556
- }
2557
- render() {
2558
- const {model, session} = this.state;
2559
- return React$6.createElement(StyledMain, {
2560
- model: model,
2561
- session: session,
2562
- onSelectionChange: this.change,
2563
- __self: this,
2564
- __source: {
2565
- fileName: _jsxFileName$6,
2566
- lineNumber: 151
2567
- }
2568
- });
2569
- }
2570
- }
2571
- Stateful.__initStatic3();
2572
- const React$7 = _dll_react;
2573
- const ReactDOM = _dll_react_dom;
2574
- const {SessionChangedEvent: SessionChangedEvent} = _dll_pie_framework__pie_player_events;
2575
- const {ModelSetEvent: ModelSetEvent} = _dll_pie_framework__pie_player_events;
2576
- const {renderMath: renderMath} = _dll_pie_lib__math_rendering;
2577
- class SelectText extends HTMLElement {
2578
- constructor() {
2579
- super();
2580
- }
2581
- set model(m) {
2582
- this._model = m;
2583
- this.render();
2584
- this.dispatchEvent(new ModelSetEvent(this.tagName.toLowerCase(), this.isSessionComplete(), this._model !== undefined));
2585
- }
2586
- set session(s) {
2587
- this._session = s;
2588
- if (!Array.isArray(this._session.selectedTokens)) {
2589
- this._session.selectedTokens = [];
2590
- }
2591
- this.render();
2592
- }
2593
- isSessionComplete() {
2594
- const {selectedTokens} = this._session || ({});
2595
- return Array.isArray(selectedTokens) && selectedTokens.length > 0;
2596
- }
2597
- selectionChanged(selection) {
2598
- this._session.selectedTokens = selection;
2599
- this.dispatchEvent(new SessionChangedEvent(this.tagName.toLowerCase(), this.isSessionComplete()));
2600
- }
2601
- connectedCallback() {
2602
- this.render();
2603
- }
2604
- render() {
2605
- if (this._model && this._session) {
2606
- const el = React$7.createElement(Stateful, {
2607
- model: this._model,
2608
- session: this._session,
2609
- onSelectionChange: this.selectionChanged.bind(this)
2610
- });
2611
- ReactDOM.render(el, this, () => {
2612
- renderMath(this);
2613
- });
2614
- }
2615
- }
2616
- }
2617
- export default SelectText;