@wangeditor-next/yjs-for-react 0.1.10-beta.0 → 0.1.10

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/dist/index.js CHANGED
@@ -1,839 +1,2 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('@wangeditor-next/yjs'), require('@wangeditor-next/editor'), require('slate')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', '@wangeditor-next/yjs', '@wangeditor-next/editor', 'slate'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WangEditorCodeHighLight = {}, global.require$$0, global.yjs, global.editor, global.slate));
5
- })(this, (function (exports, require$$0, yjs, editor, slate) { 'use strict';
6
-
7
- var EditorContext = require$$0.createContext(null);
8
- var useEditorStatic = function () {
9
- var editor = require$$0.useContext(EditorContext);
10
- if (!editor) {
11
- // throw new Error(
12
- // `The \`useEditorStatic\` hook must be used inside the <EditorContext> component's context.`
13
- // )
14
- console.warn("The `useEditorStatic` hook must be used inside the <EditorContext> component's context.");
15
- }
16
- return editor;
17
- };
18
-
19
- /******************************************************************************
20
- Copyright (c) Microsoft Corporation.
21
-
22
- Permission to use, copy, modify, and/or distribute this software for any
23
- purpose with or without fee is hereby granted.
24
-
25
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
26
- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
27
- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
28
- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
29
- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
30
- OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
31
- PERFORMANCE OF THIS SOFTWARE.
32
- ***************************************************************************** */
33
- /* global Reflect, Promise, SuppressedError, Symbol */
34
-
35
-
36
- var __assign = function() {
37
- __assign = Object.assign || function __assign(t) {
38
- for (var s, i = 1, n = arguments.length; i < n; i++) {
39
- s = arguments[i];
40
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
41
- }
42
- return t;
43
- };
44
- return __assign.apply(this, arguments);
45
- };
46
-
47
- function __rest(s, e) {
48
- var t = {};
49
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
50
- t[p] = s[p];
51
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
52
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
53
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
54
- t[p[i]] = s[p[i]];
55
- }
56
- return t;
57
- }
58
-
59
- function __values(o) {
60
- var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
61
- if (m) return m.call(o);
62
- if (o && typeof o.length === "number") return {
63
- next: function () {
64
- if (o && i >= o.length) o = void 0;
65
- return { value: o && o[i++], done: !o };
66
- }
67
- };
68
- throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
69
- }
70
-
71
- function __read(o, n) {
72
- var m = typeof Symbol === "function" && o[Symbol.iterator];
73
- if (!m) return o;
74
- var i = m.call(o), r, ar = [], e;
75
- try {
76
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
77
- }
78
- catch (error) { e = { error: error }; }
79
- finally {
80
- try {
81
- if (r && !r.done && (m = i["return"])) m.call(i);
82
- }
83
- finally { if (e) throw e.error; }
84
- }
85
- return ar;
86
- }
87
-
88
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
89
- var e = new Error(message);
90
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
91
- };
92
-
93
- var CHILDREN_TO_CURSOR_STATE_TO_RANGE = new WeakMap();
94
- function getCursorRange(editor, cursorState) {
95
- if (!cursorState.relativeSelection) {
96
- return null;
97
- }
98
- var cursorStates = CHILDREN_TO_CURSOR_STATE_TO_RANGE.get(editor.children);
99
- if (!cursorStates) {
100
- cursorStates = new WeakMap();
101
- CHILDREN_TO_CURSOR_STATE_TO_RANGE.set(editor.children, cursorStates);
102
- }
103
- var range = cursorStates.get(cursorState);
104
- if (range === undefined) {
105
- try {
106
- range = yjs.relativeRangeToSlateRange(editor.sharedRoot, editor, cursorState.relativeSelection);
107
- cursorStates.set(cursorState, range);
108
- }
109
- catch (e) {
110
- return null;
111
- }
112
- }
113
- return range;
114
- }
115
-
116
- function reactEditorToDomRangeSafe(editor$1, range) {
117
- try {
118
- return editor.DomEditor.toDOMRange(editor$1, range);
119
- }
120
- catch (e) {
121
- return null;
122
- }
123
- }
124
-
125
- function getOverlayPosition(editor$1, range, _a) {
126
- var e_1, _b;
127
- var yOffset = _a.yOffset, xOffset = _a.xOffset, shouldGenerateOverlay = _a.shouldGenerateOverlay;
128
- var _c = __read(slate.Range.edges(range), 2), start = _c[0], end = _c[1];
129
- var domRange = reactEditorToDomRangeSafe(editor$1, range);
130
- if (!domRange) {
131
- return {
132
- caretPosition: null,
133
- selectionRects: [],
134
- };
135
- }
136
- var selectionRects = [];
137
- var nodeIterator = slate.Editor.nodes(editor$1, {
138
- at: range,
139
- match: function (n, p) { return slate.Text.isText(n) && (!shouldGenerateOverlay || shouldGenerateOverlay(n, p)); },
140
- });
141
- var caretPosition = null;
142
- var isBackward = slate.Range.isBackward(range);
143
- try {
144
- for (var nodeIterator_1 = __values(nodeIterator), nodeIterator_1_1 = nodeIterator_1.next(); !nodeIterator_1_1.done; nodeIterator_1_1 = nodeIterator_1.next()) {
145
- var _d = __read(nodeIterator_1_1.value, 2), node = _d[0], path = _d[1];
146
- var domNode = editor.DomEditor.toDOMNode(editor$1, node);
147
- var isStartNode = slate.Path.equals(path, start.path);
148
- var isEndNode = slate.Path.equals(path, end.path);
149
- var clientRects = null;
150
- if (isStartNode || isEndNode) {
151
- var nodeRange = document.createRange();
152
- nodeRange.selectNode(domNode);
153
- if (isStartNode) {
154
- nodeRange.setStart(domRange.startContainer, domRange.startOffset);
155
- }
156
- if (isEndNode) {
157
- nodeRange.setEnd(domRange.endContainer, domRange.endOffset);
158
- }
159
- clientRects = nodeRange.getClientRects();
160
- }
161
- else {
162
- clientRects = domNode.getClientRects();
163
- }
164
- var isCaret = isBackward ? isStartNode : isEndNode;
165
- for (var i = 0; i < clientRects.length; i += 1) {
166
- var clientRect = clientRects.item(i);
167
- if (!clientRect) {
168
- continue;
169
- }
170
- var isCaretRect = isCaret && (isBackward ? i === 0 : i === clientRects.length - 1);
171
- var top_1 = clientRect.top - yOffset;
172
- var left = clientRect.left - xOffset;
173
- if (isCaretRect) {
174
- caretPosition = {
175
- height: clientRect.height,
176
- top: top_1,
177
- left: left + (isBackward || slate.Range.isCollapsed(range) ? 0 : clientRect.width),
178
- };
179
- }
180
- selectionRects.push({
181
- width: clientRect.width,
182
- height: clientRect.height,
183
- top: top_1,
184
- left: left,
185
- });
186
- }
187
- }
188
- }
189
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
190
- finally {
191
- try {
192
- if (nodeIterator_1_1 && !nodeIterator_1_1.done && (_b = nodeIterator_1.return)) _b.call(nodeIterator_1);
193
- }
194
- finally { if (e_1) throw e_1.error; }
195
- }
196
- return {
197
- selectionRects: selectionRects,
198
- caretPosition: caretPosition,
199
- };
200
- }
201
-
202
- function useRemoteCursorEditor() {
203
- var editor = useEditorStatic();
204
- if (!yjs.CursorEditor.isCursorEditor(editor)) {
205
- console.warn('Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor');
206
- }
207
- return editor;
208
- }
209
-
210
- var shim = {exports: {}};
211
-
212
- var useSyncExternalStoreShim_development = {};
213
-
214
- /**
215
- * @license React
216
- * use-sync-external-store-shim.development.js
217
- *
218
- * Copyright (c) Facebook, Inc. and its affiliates.
219
- *
220
- * This source code is licensed under the MIT license found in the
221
- * LICENSE file in the root directory of this source tree.
222
- */
223
-
224
- var hasRequiredUseSyncExternalStoreShim_development;
225
-
226
- function requireUseSyncExternalStoreShim_development () {
227
- if (hasRequiredUseSyncExternalStoreShim_development) return useSyncExternalStoreShim_development;
228
- hasRequiredUseSyncExternalStoreShim_development = 1;
229
-
230
- {
231
- (function() {
232
-
233
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
234
- if (
235
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
236
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
237
- 'function'
238
- ) {
239
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
240
- }
241
- var React = require$$0;
242
-
243
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
244
-
245
- function error(format) {
246
- {
247
- {
248
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
249
- args[_key2 - 1] = arguments[_key2];
250
- }
251
-
252
- printWarning('error', format, args);
253
- }
254
- }
255
- }
256
-
257
- function printWarning(level, format, args) {
258
- // When changing this logic, you might want to also
259
- // update consoleWithStackDev.www.js as well.
260
- {
261
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
262
- var stack = ReactDebugCurrentFrame.getStackAddendum();
263
-
264
- if (stack !== '') {
265
- format += '%s';
266
- args = args.concat([stack]);
267
- } // eslint-disable-next-line react-internal/safe-string-coercion
268
-
269
-
270
- var argsWithFormat = args.map(function (item) {
271
- return String(item);
272
- }); // Careful: RN currently depends on this prefix
273
-
274
- argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
275
- // breaks IE9: https://github.com/facebook/react/issues/13610
276
- // eslint-disable-next-line react-internal/no-production-logging
277
-
278
- Function.prototype.apply.call(console[level], console, argsWithFormat);
279
- }
280
- }
281
-
282
- /**
283
- * inlined Object.is polyfill to avoid requiring consumers ship their own
284
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
285
- */
286
- function is(x, y) {
287
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
288
- ;
289
- }
290
-
291
- var objectIs = typeof Object.is === 'function' ? Object.is : is;
292
-
293
- // dispatch for CommonJS interop named imports.
294
-
295
- var useState = React.useState,
296
- useEffect = React.useEffect,
297
- useLayoutEffect = React.useLayoutEffect,
298
- useDebugValue = React.useDebugValue;
299
- var didWarnOld18Alpha = false;
300
- var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
301
- // because of a very particular set of implementation details and assumptions
302
- // -- change any one of them and it will break. The most important assumption
303
- // is that updates are always synchronous, because concurrent rendering is
304
- // only available in versions of React that also have a built-in
305
- // useSyncExternalStore API. And we only use this shim when the built-in API
306
- // does not exist.
307
- //
308
- // Do not assume that the clever hacks used by this hook also work in general.
309
- // The point of this shim is to replace the need for hacks by other libraries.
310
-
311
- function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
312
- // React do not expose a way to check if we're hydrating. So users of the shim
313
- // will need to track that themselves and return the correct value
314
- // from `getSnapshot`.
315
- getServerSnapshot) {
316
- {
317
- if (!didWarnOld18Alpha) {
318
- if (React.startTransition !== undefined) {
319
- didWarnOld18Alpha = true;
320
-
321
- error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
322
- }
323
- }
324
- } // Read the current snapshot from the store on every render. Again, this
325
- // breaks the rules of React, and only works here because of specific
326
- // implementation details, most importantly that updates are
327
- // always synchronous.
328
-
329
-
330
- var value = getSnapshot();
331
-
332
- {
333
- if (!didWarnUncachedGetSnapshot) {
334
- var cachedValue = getSnapshot();
335
-
336
- if (!objectIs(value, cachedValue)) {
337
- error('The result of getSnapshot should be cached to avoid an infinite loop');
338
-
339
- didWarnUncachedGetSnapshot = true;
340
- }
341
- }
342
- } // Because updates are synchronous, we don't queue them. Instead we force a
343
- // re-render whenever the subscribed state changes by updating an some
344
- // arbitrary useState hook. Then, during render, we call getSnapshot to read
345
- // the current value.
346
- //
347
- // Because we don't actually use the state returned by the useState hook, we
348
- // can save a bit of memory by storing other stuff in that slot.
349
- //
350
- // To implement the early bailout, we need to track some things on a mutable
351
- // object. Usually, we would put that in a useRef hook, but we can stash it in
352
- // our useState hook instead.
353
- //
354
- // To force a re-render, we call forceUpdate({inst}). That works because the
355
- // new object always fails an equality check.
356
-
357
-
358
- var _useState = useState({
359
- inst: {
360
- value: value,
361
- getSnapshot: getSnapshot
362
- }
363
- }),
364
- inst = _useState[0].inst,
365
- forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
366
- // in the layout phase so we can access it during the tearing check that
367
- // happens on subscribe.
368
-
369
-
370
- useLayoutEffect(function () {
371
- inst.value = value;
372
- inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
373
- // commit phase if there was an interleaved mutation. In concurrent mode
374
- // this can happen all the time, but even in synchronous mode, an earlier
375
- // effect may have mutated the store.
376
-
377
- if (checkIfSnapshotChanged(inst)) {
378
- // Force a re-render.
379
- forceUpdate({
380
- inst: inst
381
- });
382
- }
383
- }, [subscribe, value, getSnapshot]);
384
- useEffect(function () {
385
- // Check for changes right before subscribing. Subsequent changes will be
386
- // detected in the subscription handler.
387
- if (checkIfSnapshotChanged(inst)) {
388
- // Force a re-render.
389
- forceUpdate({
390
- inst: inst
391
- });
392
- }
393
-
394
- var handleStoreChange = function () {
395
- // TODO: Because there is no cross-renderer API for batching updates, it's
396
- // up to the consumer of this library to wrap their subscription event
397
- // with unstable_batchedUpdates. Should we try to detect when this isn't
398
- // the case and print a warning in development?
399
- // The store changed. Check if the snapshot changed since the last time we
400
- // read from the store.
401
- if (checkIfSnapshotChanged(inst)) {
402
- // Force a re-render.
403
- forceUpdate({
404
- inst: inst
405
- });
406
- }
407
- }; // Subscribe to the store and return a clean-up function.
408
-
409
-
410
- return subscribe(handleStoreChange);
411
- }, [subscribe]);
412
- useDebugValue(value);
413
- return value;
414
- }
415
-
416
- function checkIfSnapshotChanged(inst) {
417
- var latestGetSnapshot = inst.getSnapshot;
418
- var prevValue = inst.value;
419
-
420
- try {
421
- var nextValue = latestGetSnapshot();
422
- return !objectIs(prevValue, nextValue);
423
- } catch (error) {
424
- return true;
425
- }
426
- }
427
-
428
- function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
429
- // Note: The shim does not use getServerSnapshot, because pre-18 versions of
430
- // React do not expose a way to check if we're hydrating. So users of the shim
431
- // will need to track that themselves and return the correct value
432
- // from `getSnapshot`.
433
- return getSnapshot();
434
- }
435
-
436
- var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
437
-
438
- var isServerEnvironment = !canUseDOM;
439
-
440
- var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
441
- var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
442
-
443
- useSyncExternalStoreShim_development.useSyncExternalStore = useSyncExternalStore$2;
444
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
445
- if (
446
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
447
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
448
- 'function'
449
- ) {
450
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
451
- }
452
-
453
- })();
454
- }
455
- return useSyncExternalStoreShim_development;
456
- }
457
-
458
- var hasRequiredShim;
459
-
460
- function requireShim () {
461
- if (hasRequiredShim) return shim.exports;
462
- hasRequiredShim = 1;
463
-
464
- {
465
- shim.exports = requireUseSyncExternalStoreShim_development();
466
- }
467
- return shim.exports;
468
- }
469
-
470
- var shimExports = requireShim();
471
-
472
- var withSelector = {exports: {}};
473
-
474
- var withSelector_development = {};
475
-
476
- /**
477
- * @license React
478
- * use-sync-external-store-shim/with-selector.development.js
479
- *
480
- * Copyright (c) Facebook, Inc. and its affiliates.
481
- *
482
- * This source code is licensed under the MIT license found in the
483
- * LICENSE file in the root directory of this source tree.
484
- */
485
-
486
- var hasRequiredWithSelector_development;
487
-
488
- function requireWithSelector_development () {
489
- if (hasRequiredWithSelector_development) return withSelector_development;
490
- hasRequiredWithSelector_development = 1;
491
-
492
- {
493
- (function() {
494
-
495
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
496
- if (
497
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
498
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
499
- 'function'
500
- ) {
501
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
502
- }
503
- var React = require$$0;
504
- var shim = requireShim();
505
-
506
- /**
507
- * inlined Object.is polyfill to avoid requiring consumers ship their own
508
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
509
- */
510
- function is(x, y) {
511
- return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
512
- ;
513
- }
514
-
515
- var objectIs = typeof Object.is === 'function' ? Object.is : is;
516
-
517
- var useSyncExternalStore = shim.useSyncExternalStore;
518
-
519
- // for CommonJS interop.
520
-
521
- var useRef = React.useRef,
522
- useEffect = React.useEffect,
523
- useMemo = React.useMemo,
524
- useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
525
-
526
- function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
527
- // Use this to track the rendered snapshot.
528
- var instRef = useRef(null);
529
- var inst;
530
-
531
- if (instRef.current === null) {
532
- inst = {
533
- hasValue: false,
534
- value: null
535
- };
536
- instRef.current = inst;
537
- } else {
538
- inst = instRef.current;
539
- }
540
-
541
- var _useMemo = useMemo(function () {
542
- // Track the memoized state using closure variables that are local to this
543
- // memoized instance of a getSnapshot function. Intentionally not using a
544
- // useRef hook, because that state would be shared across all concurrent
545
- // copies of the hook/component.
546
- var hasMemo = false;
547
- var memoizedSnapshot;
548
- var memoizedSelection;
549
-
550
- var memoizedSelector = function (nextSnapshot) {
551
- if (!hasMemo) {
552
- // The first time the hook is called, there is no memoized result.
553
- hasMemo = true;
554
- memoizedSnapshot = nextSnapshot;
555
-
556
- var _nextSelection = selector(nextSnapshot);
557
-
558
- if (isEqual !== undefined) {
559
- // Even if the selector has changed, the currently rendered selection
560
- // may be equal to the new selection. We should attempt to reuse the
561
- // current value if possible, to preserve downstream memoizations.
562
- if (inst.hasValue) {
563
- var currentSelection = inst.value;
564
-
565
- if (isEqual(currentSelection, _nextSelection)) {
566
- memoizedSelection = currentSelection;
567
- return currentSelection;
568
- }
569
- }
570
- }
571
-
572
- memoizedSelection = _nextSelection;
573
- return _nextSelection;
574
- } // We may be able to reuse the previous invocation's result.
575
-
576
-
577
- // We may be able to reuse the previous invocation's result.
578
- var prevSnapshot = memoizedSnapshot;
579
- var prevSelection = memoizedSelection;
580
-
581
- if (objectIs(prevSnapshot, nextSnapshot)) {
582
- // The snapshot is the same as last time. Reuse the previous selection.
583
- return prevSelection;
584
- } // The snapshot has changed, so we need to compute a new selection.
585
-
586
-
587
- // The snapshot has changed, so we need to compute a new selection.
588
- var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
589
- // has changed. If it hasn't, return the previous selection. That signals
590
- // to React that the selections are conceptually equal, and we can bail
591
- // out of rendering.
592
-
593
- // If a custom isEqual function is provided, use that to check if the data
594
- // has changed. If it hasn't, return the previous selection. That signals
595
- // to React that the selections are conceptually equal, and we can bail
596
- // out of rendering.
597
- if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
598
- return prevSelection;
599
- }
600
-
601
- memoizedSnapshot = nextSnapshot;
602
- memoizedSelection = nextSelection;
603
- return nextSelection;
604
- }; // Assigning this to a constant so that Flow knows it can't change.
605
-
606
-
607
- // Assigning this to a constant so that Flow knows it can't change.
608
- var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
609
-
610
- var getSnapshotWithSelector = function () {
611
- return memoizedSelector(getSnapshot());
612
- };
613
-
614
- var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
615
- return memoizedSelector(maybeGetServerSnapshot());
616
- };
617
- return [getSnapshotWithSelector, getServerSnapshotWithSelector];
618
- }, [getSnapshot, getServerSnapshot, selector, isEqual]),
619
- getSelection = _useMemo[0],
620
- getServerSelection = _useMemo[1];
621
-
622
- var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
623
- useEffect(function () {
624
- inst.hasValue = true;
625
- inst.value = value;
626
- }, [value]);
627
- useDebugValue(value);
628
- return value;
629
- }
630
-
631
- withSelector_development.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
632
- /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
633
- if (
634
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
635
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
636
- 'function'
637
- ) {
638
- __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
639
- }
640
-
641
- })();
642
- }
643
- return withSelector_development;
644
- }
645
-
646
- var hasRequiredWithSelector;
647
-
648
- function requireWithSelector () {
649
- if (hasRequiredWithSelector) return withSelector.exports;
650
- hasRequiredWithSelector = 1;
651
-
652
- {
653
- withSelector.exports = requireWithSelector_development();
654
- }
655
- return withSelector.exports;
656
- }
657
-
658
- var withSelectorExports = requireWithSelector();
659
-
660
- var EDITOR_TO_CURSOR_STORE = new WeakMap();
661
- function createRemoteCursorStateStore(editor) {
662
- var cursors = {};
663
- var changed = new Set();
664
- var addChanged = changed.add.bind(changed);
665
- var onStoreChangeListeners = new Set();
666
- var changeHandler = null;
667
- var subscribe = function (onStoreChange) {
668
- onStoreChangeListeners.add(onStoreChange);
669
- if (!changeHandler) {
670
- changeHandler = function (event) {
671
- event.added.forEach(addChanged);
672
- event.removed.forEach(addChanged);
673
- event.updated.forEach(addChanged);
674
- onStoreChangeListeners.forEach(function (listener) { return listener(); });
675
- };
676
- yjs.CursorEditor.on(editor, 'change', changeHandler);
677
- }
678
- return function () {
679
- onStoreChangeListeners.delete(onStoreChange);
680
- if (changeHandler && onStoreChangeListeners.size === 0) {
681
- yjs.CursorEditor.off(editor, 'change', changeHandler);
682
- changeHandler = null;
683
- }
684
- };
685
- };
686
- var getSnapshot = function () {
687
- if (changed.size === 0) {
688
- return cursors;
689
- }
690
- changed.forEach(function (clientId) {
691
- var state = yjs.CursorEditor.cursorState(editor, clientId);
692
- if (state === null) {
693
- delete cursors[clientId.toString()];
694
- return;
695
- }
696
- cursors[clientId] = state;
697
- });
698
- changed.clear();
699
- cursors = __assign({}, cursors);
700
- return cursors;
701
- };
702
- return [subscribe, getSnapshot];
703
- }
704
- function getCursorStateStore(editor) {
705
- var existing = EDITOR_TO_CURSOR_STORE.get(editor);
706
- if (existing) {
707
- return existing;
708
- }
709
- var store = createRemoteCursorStateStore(editor);
710
- if (editor) {
711
- EDITOR_TO_CURSOR_STORE.set(editor, store);
712
- }
713
- return store;
714
- }
715
- function useRemoteCursorStateStore() {
716
- var editor = useRemoteCursorEditor();
717
- return getCursorStateStore(editor);
718
- }
719
-
720
- function useRemoteCursorStates() {
721
- var _a = __read(useRemoteCursorStateStore(), 2), subscribe = _a[0], getSnapshot = _a[1];
722
- return shimExports.useSyncExternalStore(subscribe, getSnapshot);
723
- }
724
- function useRemoteCursorStatesSelector(selector, isEqual) {
725
- var _a = __read(useRemoteCursorStateStore(), 2), subscribe = _a[0], getSnapshot = _a[1];
726
- return withSelectorExports.useSyncExternalStoreWithSelector(subscribe, getSnapshot, null, selector, isEqual);
727
- }
728
-
729
- function useRequestRerender() {
730
- var _a = __read(require$$0.useReducer(function (s) { return s + 1; }, 0), 2), rerender = _a[1];
731
- var animationFrameIdRef = require$$0.useRef(null);
732
- var clearAnimationFrame = function () {
733
- if (animationFrameIdRef.current) {
734
- cancelAnimationFrame(animationFrameIdRef.current);
735
- animationFrameIdRef.current = 0;
736
- }
737
- };
738
- require$$0.useEffect(clearAnimationFrame);
739
- require$$0.useEffect(function () { return clearAnimationFrame; }, []);
740
- return require$$0.useCallback(function (immediately) {
741
- if (immediately === void 0) { immediately = false; }
742
- if (immediately) {
743
- rerender();
744
- return;
745
- }
746
- if (animationFrameIdRef.current) {
747
- return;
748
- }
749
- animationFrameIdRef.current = requestAnimationFrame(rerender);
750
- }, []);
751
- }
752
- function useOnResize(ref, onResize) {
753
- var onResizeRef = require$$0.useRef(onResize);
754
- onResizeRef.current = onResize;
755
- var _a = __read(require$$0.useState(function () { return new ResizeObserver(function () {
756
- onResizeRef.current();
757
- }); }), 1), observer = _a[0];
758
- require$$0.useEffect(function () {
759
- if (!(ref === null || ref === void 0 ? void 0 : ref.current)) {
760
- return;
761
- }
762
- var element = ref.current;
763
- observer.observe(element);
764
- return function () { return observer.unobserve(element); };
765
- }, [observer, ref]);
766
- }
767
-
768
- var FROZEN_EMPTY_ARRAY = Object.freeze([]);
769
- function useRemoteCursorOverlayPositions(_a) {
770
- var _b;
771
- if (_a === void 0) { _a = {}; }
772
- var containerRef = _a.containerRef, shouldGenerateOverlay = _a.shouldGenerateOverlay, opts = __rest(_a, ["containerRef", "shouldGenerateOverlay"]);
773
- var editor = useRemoteCursorEditor();
774
- var cursorStates = useRemoteCursorStates();
775
- var requestRerender = useRequestRerender();
776
- var overlayPositionCache = require$$0.useRef(new WeakMap());
777
- var _c = __read(require$$0.useState({}), 2), overlayPositions = _c[0], setOverlayPositions = _c[1];
778
- var refreshOnResize = 'refreshOnResize' in opts ? (_b = opts.refreshOnResize) !== null && _b !== void 0 ? _b : true : true;
779
- useOnResize(refreshOnResize ? containerRef : undefined, function () {
780
- overlayPositionCache.current = new WeakMap();
781
- requestRerender(refreshOnResize !== 'debounced');
782
- });
783
- // Update selection rects after paint
784
- require$$0.useLayoutEffect(function () {
785
- var _a, _b, _c;
786
- // We have a container ref but the ref is null => container
787
- // isn't mounted to we can't calculate the selection rects.
788
- if (containerRef && !containerRef.current) {
789
- return;
790
- }
791
- var containerRect = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
792
- var xOffset = (_b = containerRect === null || containerRect === void 0 ? void 0 : containerRect.x) !== null && _b !== void 0 ? _b : 0;
793
- var yOffset = (_c = containerRect === null || containerRect === void 0 ? void 0 : containerRect.y) !== null && _c !== void 0 ? _c : 0;
794
- var overlayPositionsChanged = Object.keys(overlayPositions).length !== Object.keys(cursorStates).length;
795
- var updated = Object.fromEntries(Object.entries(cursorStates).map(function (_a) {
796
- var _b = __read(_a, 2), key = _b[0], state = _b[1];
797
- var range = state.relativeSelection && getCursorRange(editor, state);
798
- if (!range) {
799
- return [key, FROZEN_EMPTY_ARRAY];
800
- }
801
- var cached = overlayPositionCache.current.get(range);
802
- if (cached) {
803
- return [key, cached];
804
- }
805
- var overlayPosition = getOverlayPosition(editor, range, {
806
- xOffset: xOffset,
807
- yOffset: yOffset,
808
- shouldGenerateOverlay: shouldGenerateOverlay,
809
- });
810
- overlayPositionsChanged = true;
811
- overlayPositionCache.current.set(range, overlayPosition);
812
- return [key, overlayPosition];
813
- }));
814
- if (overlayPositionsChanged) {
815
- setOverlayPositions(updated);
816
- }
817
- });
818
- var overlayData = require$$0.useMemo(function () { return Object.entries(cursorStates).map(function (_a) {
819
- var _b, _c;
820
- var _d = __read(_a, 2), clientId = _d[0], state = _d[1];
821
- var range = state.relativeSelection && getCursorRange(editor, state);
822
- var overlayPosition = overlayPositions[clientId];
823
- return __assign(__assign({}, state), { range: range, caretPosition: (_b = overlayPosition === null || overlayPosition === void 0 ? void 0 : overlayPosition.caretPosition) !== null && _b !== void 0 ? _b : null, selectionRects: (_c = overlayPosition === null || overlayPosition === void 0 ? void 0 : overlayPosition.selectionRects) !== null && _c !== void 0 ? _c : FROZEN_EMPTY_ARRAY });
824
- }); }, [cursorStates, editor, overlayPositions]);
825
- var refresh = require$$0.useCallback(function () {
826
- overlayPositionCache.current = new WeakMap();
827
- requestRerender(true);
828
- }, [requestRerender]);
829
- return [overlayData, refresh];
830
- }
831
-
832
- exports.EditorContext = EditorContext;
833
- exports.getCursorRange = getCursorRange;
834
- exports.useEditorStatic = useEditorStatic;
835
- exports.useRemoteCursorOverlayPositions = useRemoteCursorOverlayPositions;
836
- exports.useRemoteCursorStates = useRemoteCursorStates;
837
- exports.useRemoteCursorStatesSelector = useRemoteCursorStatesSelector;
838
-
839
- }));
1
+ !function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports,require("react"),require("@wangeditor-next/yjs"),require("@wangeditor-next/editor"),require("slate")):"function"==typeof define&&define.amd?define(["exports","react","@wangeditor-next/yjs","@wangeditor-next/editor","slate"],r):r((t="undefined"!=typeof globalThis?globalThis:t||self).WangEditorCodeHighLight={},t.require$$0,t.yjs,t.editor,t.slate)}(this,(function(t,r,n,e,u){"use strict";var i,o,f,c,a,s,l,v,p,h,d,y,g,b,m,S,w,O,E=r.createContext(null),j=function(){var t=r.useContext(E);return t||console.warn("The `useEditorStatic` hook must be used inside the <EditorContext> component's context."),t},x="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function R(){return o?i:(o=1,i=function(t){try{return!!t()}catch(t){return!0}})}function P(){if(c)return f;c=1;var t=R();return f=!t((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")}))}function A(){if(s)return a;s=1;var t=P(),r=Function.prototype,n=r.call,e=t&&r.bind.bind(n,n);return a=t?e:function(t){return function(){return n.apply(t,arguments)}},a}function T(){if(v)return l;v=1;var t=A(),r=t({}.toString),n=t("".slice);return l=function(t){return n(r(t),8,-1)}}function C(){if(h)return p;h=1;var t=A(),r=R(),n=T(),e=Object,u=t("".split);return p=r((function(){return!e("z").propertyIsEnumerable(0)}))?function(t){return"String"===n(t)?u(t,""):e(t)}:e}function k(){return y?d:(y=1,d=function(t){return null==t})}function z(){if(b)return g;b=1;var t=k(),r=TypeError;return g=function(n){if(t(n))throw new r("Can't call method on "+n);return n}}function I(){if(S)return m;S=1;var t=C(),r=z();return m=function(n){return t(r(n))}}function L(){if(O)return w;O=1;var t=function(t){return t&&t.Math===Math&&t};return w=t("object"==typeof globalThis&&globalThis)||t("object"==typeof window&&window)||t("object"==typeof self&&self)||t("object"==typeof x&&x)||t("object"==typeof w&&w)||function(){return this}()||Function("return this")()}var M,F,_,D,N,G,W,V,B,q,U,H,X,$,K,Y,J,Q,Z,tt,rt,nt,et,ut,it,ot,ft,ct,at,st={exports:{}};function lt(){return F?M:(F=1,M=!1)}function vt(){if(D)return _;D=1;var t=L(),r=Object.defineProperty;return _=function(n,e){try{r(t,n,{value:e,configurable:!0,writable:!0})}catch(r){t[n]=e}return e}}function pt(){if(N)return st.exports;N=1;var t=lt(),r=L(),n=vt(),e="__core-js_shared__",u=st.exports=r[e]||n(e,{});return(u.versions||(u.versions=[])).push({version:"3.38.1",mode:t?"pure":"global",copyright:"© 2014-2024 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.38.1/LICENSE",source:"https://github.com/zloirock/core-js"}),st.exports}function ht(){if(W)return G;W=1;var t=pt();return G=function(r,n){return t[r]||(t[r]=n||{})}}function dt(){if(B)return V;B=1;var t=z(),r=Object;return V=function(n){return r(t(n))}}function yt(){if(U)return q;U=1;var t=A(),r=dt(),n=t({}.hasOwnProperty);return q=Object.hasOwn||function(t,e){return n(r(t),e)}}function gt(){if(X)return H;X=1;var t=A(),r=0,n=Math.random(),e=t(1..toString);return H=function(t){return"Symbol("+(void 0===t?"":t)+")_"+e(++r+n,36)}}function bt(){if(J)return Y;J=1;var t,r,n=L(),e=function(){if(K)return $;K=1;var t=L().navigator,r=t&&t.userAgent;return $=r?String(r):""}(),u=n.process,i=n.Deno,o=u&&u.versions||i&&i.version,f=o&&o.v8;return f&&(r=(t=f.split("."))[0]>0&&t[0]<4?1:+(t[0]+t[1])),!r&&e&&(!(t=e.match(/Edge\/(\d+)/))||t[1]>=74)&&(t=e.match(/Chrome\/(\d+)/))&&(r=+t[1]),Y=r}function mt(){if(Z)return Q;Z=1;var t=bt(),r=R(),n=L().String;return Q=!!Object.getOwnPropertySymbols&&!r((function(){var r=Symbol("symbol detection");return!n(r)||!(Object(r)instanceof Symbol)||!Symbol.sham&&t&&t<41}))}function St(){if(rt)return tt;rt=1;var t=mt();return tt=t&&!Symbol.sham&&"symbol"==typeof Symbol.iterator}function wt(){if(et)return nt;et=1;var t=L(),r=ht(),n=yt(),e=gt(),u=mt(),i=St(),o=t.Symbol,f=r("wks"),c=i?o.for||o:o&&o.withoutSetter||e;return nt=function(t){return n(f,t)||(f[t]=u&&n(o,t)?o[t]:c("Symbol."+t)),f[t]}}function Ot(){if(it)return ut;it=1;var t="object"==typeof document&&document.all;return ut=void 0===t&&void 0!==t?function(r){return"function"==typeof r||r===t}:function(t){return"function"==typeof t}}function Et(){if(ft)return ot;ft=1;var t=Ot();return ot=function(r){return"object"==typeof r?null!==r:t(r)}}function jt(){if(at)return ct;at=1;var t=Et(),r=String,n=TypeError;return ct=function(e){if(t(e))return e;throw new n(r(e)+" is not an object")}}var xt,Rt,Pt,At,Tt={};function Ct(){if(Rt)return xt;Rt=1;var t=R();return xt=!t((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]}))}function kt(){if(At)return Pt;At=1;var t=Ct(),r=R();return Pt=t&&r((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))}var zt,It,Lt,Mt,Ft,_t,Dt,Nt,Gt,Wt,Vt,Bt,qt,Ut,Ht,Xt,$t,Kt,Yt,Jt,Qt,Zt,tr,rr,nr,er,ur,ir,or,fr,cr,ar,sr,lr,vr,pr,hr,dr,yr,gr,br,mr,Sr,wr,Or,Er,jr,xr,Rr,Pr,Ar,Tr,Cr,kr,zr,Ir,Lr,Mr,Fr,_r,Dr,Nr,Gr,Wr,Vr={};function Br(){if(It)return zt;It=1;var t=L(),r=Et(),n=t.document,e=r(n)&&r(n.createElement);return zt=function(t){return e?n.createElement(t):{}}}function qr(){if(Mt)return Lt;Mt=1;var t=Ct(),r=R(),n=Br();return Lt=!t&&!r((function(){return 7!==Object.defineProperty(n("div"),"a",{get:function(){return 7}}).a}))}function Ur(){if(_t)return Ft;_t=1;var t=P(),r=Function.prototype.call;return Ft=t?r.bind(r):function(){return r.apply(r,arguments)},Ft}function Hr(){if(Nt)return Dt;Nt=1;var t=L(),r=Ot();return Dt=function(n,e){return arguments.length<2?(u=t[n],r(u)?u:void 0):t[n]&&t[n][e];var u},Dt}function Xr(){if(Wt)return Gt;Wt=1;var t=A();return Gt=t({}.isPrototypeOf)}function $r(){if(Bt)return Vt;Bt=1;var t=Hr(),r=Ot(),n=Xr(),e=St(),u=Object;return Vt=e?function(t){return"symbol"==typeof t}:function(e){var i=t("Symbol");return r(i)&&n(i.prototype,u(e))}}function Kr(){if(Ut)return qt;Ut=1;var t=String;return qt=function(r){try{return t(r)}catch(t){return"Object"}}}function Yr(){if(Xt)return Ht;Xt=1;var t=Ot(),r=Kr(),n=TypeError;return Ht=function(e){if(t(e))return e;throw new n(r(e)+" is not a function")}}function Jr(){if(Kt)return $t;Kt=1;var t=Yr(),r=k();return $t=function(n,e){var u=n[e];return r(u)?void 0:t(u)}}function Qr(){if(Jt)return Yt;Jt=1;var t=Ur(),r=Ot(),n=Et(),e=TypeError;return Yt=function(u,i){var o,f;if("string"===i&&r(o=u.toString)&&!n(f=t(o,u)))return f;if(r(o=u.valueOf)&&!n(f=t(o,u)))return f;if("string"!==i&&r(o=u.toString)&&!n(f=t(o,u)))return f;throw new e("Can't convert object to primitive value")}}function Zr(){if(Zt)return Qt;Zt=1;var t=Ur(),r=Et(),n=$r(),e=Jr(),u=Qr(),i=wt(),o=TypeError,f=i("toPrimitive");return Qt=function(i,c){if(!r(i)||n(i))return i;var a,s=e(i,f);if(s){if(void 0===c&&(c="default"),a=t(s,i,c),!r(a)||n(a))return a;throw new o("Can't convert object to primitive value")}return void 0===c&&(c="number"),u(i,c)}}function tn(){if(rr)return tr;rr=1;var t=Zr(),r=$r();return tr=function(n){var e=t(n,"string");return r(e)?e:e+""}}function rn(){if(nr)return Vr;nr=1;var t=Ct(),r=qr(),n=kt(),e=jt(),u=tn(),i=TypeError,o=Object.defineProperty,f=Object.getOwnPropertyDescriptor,c="enumerable",a="configurable",s="writable";return Vr.f=t?n?function(t,r,n){if(e(t),r=u(r),e(n),"function"==typeof t&&"prototype"===r&&"value"in n&&s in n&&!n[s]){var i=f(t,r);i&&i[s]&&(t[r]=n.value,n={configurable:a in n?n[a]:i[a],enumerable:c in n?n[c]:i[c],writable:!1})}return o(t,r,n)}:o:function(t,n,f){if(e(t),n=u(n),e(f),r)try{return o(t,n,f)}catch(t){}if("get"in f||"set"in f)throw new i("Accessors not supported");return"value"in f&&(t[n]=f.value),t},Vr}function nn(){if(or)return ir;or=1;var t=function(){if(ur)return er;ur=1;var t=Math.ceil,r=Math.floor;return er=Math.trunc||function(n){var e=+n;return(e>0?r:t)(e)}}();return ir=function(r){var n=+r;return n!=n||0===n?0:t(n)}}function en(){if(cr)return fr;cr=1;var t=nn(),r=Math.max,n=Math.min;return fr=function(e,u){var i=t(e);return i<0?r(i+u,0):n(i,u)}}function un(){if(sr)return ar;sr=1;var t=nn(),r=Math.min;return ar=function(n){var e=t(n);return e>0?r(e,9007199254740991):0}}function on(){if(vr)return lr;vr=1;var t=un();return lr=function(r){return t(r.length)}}function fn(){return yr?dr:(yr=1,dr={})}function cn(){if(br)return gr;br=1;var t=A(),r=yt(),n=I(),e=function(){if(hr)return pr;hr=1;var t=I(),r=en(),n=on(),e=function(e){return function(u,i,o){var f=t(u),c=n(f);if(0===c)return!e&&-1;var a,s=r(o,c);if(e&&i!=i){for(;c>s;)if((a=f[s++])!=a)return!0}else for(;c>s;s++)if((e||s in f)&&f[s]===i)return e||s||0;return!e&&-1}};return pr={includes:e(!0),indexOf:e(!1)}}().indexOf,u=fn(),i=t([].push);return gr=function(t,o){var f,c=n(t),a=0,s=[];for(f in c)!r(u,f)&&r(c,f)&&i(s,f);for(;o.length>a;)r(c,f=o[a++])&&(~e(s,f)||i(s,f));return s}}function an(){return Sr?mr:(Sr=1,mr=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"])}function sn(){if(Or)return wr;Or=1;var t=cn(),r=an();return wr=Object.keys||function(n){return t(n,r)}}function ln(){if(xr)return jr;xr=1;var t=Hr();return jr=t("document","documentElement")}function vn(){if(Pr)return Rr;Pr=1;var t=ht(),r=gt(),n=t("keys");return Rr=function(t){return n[t]||(n[t]=r(t))}}function pn(){if(Tr)return Ar;Tr=1;var t,r=jt(),n=function(){if(Er)return Tt;Er=1;var t=Ct(),r=kt(),n=rn(),e=jt(),u=I(),i=sn();return Tt.f=t&&!r?Object.defineProperties:function(t,r){e(t);for(var o,f=u(r),c=i(r),a=c.length,s=0;a>s;)n.f(t,o=c[s++],f[o]);return t},Tt}(),e=an(),u=fn(),i=ln(),o=Br(),f=vn(),c="prototype",a="script",s=f("IE_PROTO"),l=function(){},v=function(t){return"<"+a+">"+t+"</"+a+">"},p=function(t){t.write(v("")),t.close();var r=t.parentWindow.Object;return t=null,r},h=function(){try{t=new ActiveXObject("htmlfile")}catch(t){}var r,n,u;h="undefined"!=typeof document?document.domain&&t?p(t):(n=o("iframe"),u="java"+a+":",n.style.display="none",i.appendChild(n),n.src=String(u),(r=n.contentWindow.document).open(),r.write(v("document.F=Object")),r.close(),r.F):p(t);for(var f=e.length;f--;)delete h[c][e[f]];return h()};return u[s]=!0,Ar=Object.create||function(t,e){var u;return null!==t?(l[c]=r(t),u=new l,l[c]=null,u[s]=t):u=h(),void 0===e?u:n.f(u,e)}}function hn(){if(kr)return Cr;kr=1;var t=wt(),r=pn(),n=rn().f,e=t("unscopables"),u=Array.prototype;return void 0===u[e]&&n(u,e,{configurable:!0,value:r(null)}),Cr=function(t){u[e][t]=!0}}function dn(){return Ir?zr:(Ir=1,zr={})}function yn(){if(Mr)return Lr;Mr=1;var t=L(),r=Ot(),n=t.WeakMap;return Lr=r(n)&&/native code/.test(String(n))}function gn(){return _r?Fr:(_r=1,Fr=function(t,r){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:r}})}function bn(){if(Nr)return Dr;Nr=1;var t=Ct(),r=rn(),n=gn();return Dr=t?function(t,e,u){return r.f(t,e,n(1,u))}:function(t,r,n){return t[r]=n,t}}function mn(){if(Wr)return Gr;Wr=1;var t,r,n,e=yn(),u=L(),i=Et(),o=bn(),f=yt(),c=pt(),a=vn(),s=fn(),l="Object already initialized",v=u.TypeError,p=u.WeakMap;if(e||c.state){var h=c.state||(c.state=new p);h.get=h.get,h.has=h.has,h.set=h.set,t=function(t,r){if(h.has(t))throw new v(l);return r.facade=t,h.set(t,r),r},r=function(t){return h.get(t)||{}},n=function(t){return h.has(t)}}else{var d=a("state");s[d]=!0,t=function(t,r){if(f(t,d))throw new v(l);return r.facade=t,o(t,d,r),r},r=function(t){return f(t,d)?t[d]:{}},n=function(t){return f(t,d)}}return Gr={set:t,get:r,has:n,enforce:function(e){return n(e)?r(e):t(e,{})},getterFor:function(t){return function(n){var e;if(!i(n)||(e=r(n)).type!==t)throw new v("Incompatible receiver, "+t+" required");return e}}}}var Sn,wn,On={},En={};function jn(){if(Sn)return En;Sn=1;var t={}.propertyIsEnumerable,r=Object.getOwnPropertyDescriptor,n=r&&!t.call({1:2},1);return En.f=n?function(t){var n=r(this,t);return!!n&&n.enumerable}:t,En}function xn(){if(wn)return On;wn=1;var t=Ct(),r=Ur(),n=jn(),e=gn(),u=I(),i=tn(),o=yt(),f=qr(),c=Object.getOwnPropertyDescriptor;return On.f=t?c:function(t,a){if(t=u(t),a=i(a),f)try{return c(t,a)}catch(t){}if(o(t,a))return e(!r(n.f,t,a),t[a])},On}var Rn,Pn,An,Tn,Cn,kn,zn,In={exports:{}};function Ln(){if(Pn)return Rn;Pn=1;var t=Ct(),r=yt(),n=Function.prototype,e=t&&Object.getOwnPropertyDescriptor,u=r(n,"name"),i=u&&"something"===function(){}.name,o=u&&(!t||t&&e(n,"name").configurable);return Rn={EXISTS:u,PROPER:i,CONFIGURABLE:o}}function Mn(){if(Tn)return An;Tn=1;var t=A(),r=Ot(),n=pt(),e=t(Function.toString);return r(n.inspectSource)||(n.inspectSource=function(t){return e(t)}),An=n.inspectSource}function Fn(){if(Cn)return In.exports;Cn=1;var t=A(),r=R(),n=Ot(),e=yt(),u=Ct(),i=Ln().CONFIGURABLE,o=Mn(),f=mn(),c=f.enforce,a=f.get,s=String,l=Object.defineProperty,v=t("".slice),p=t("".replace),h=t([].join),d=u&&!r((function(){return 8!==l((function(){}),"length",{value:8}).length})),y=String(String).split("String"),g=In.exports=function(t,r,n){"Symbol("===v(s(r),0,7)&&(r="["+p(s(r),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),n&&n.getter&&(r="get "+r),n&&n.setter&&(r="set "+r),(!e(t,"name")||i&&t.name!==r)&&(u?l(t,"name",{value:r,configurable:!0}):t.name=r),d&&n&&e(n,"arity")&&t.length!==n.arity&&l(t,"length",{value:n.arity});try{n&&e(n,"constructor")&&n.constructor?u&&l(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var o=c(t);return e(o,"source")||(o.source=h(y,"string"==typeof r?r:"")),t};return Function.prototype.toString=g((function(){return n(this)&&a(this).source||o(this)}),"toString"),In.exports}function _n(){if(zn)return kn;zn=1;var t=Ot(),r=rn(),n=Fn(),e=vt();return kn=function(u,i,o,f){f||(f={});var c=f.enumerable,a=void 0!==f.name?f.name:i;if(t(o)&&n(o,a,f),f.global)c?u[i]=o:e(i,o);else{try{f.unsafe?u[i]&&(c=!0):delete u[i]}catch(t){}c?u[i]=o:r.f(u,i,{value:o,enumerable:!1,configurable:!f.nonConfigurable,writable:!f.nonWritable})}return u}}var Dn,Nn={};function Gn(){if(Dn)return Nn;Dn=1;var t=cn(),r=an().concat("length","prototype");return Nn.f=Object.getOwnPropertyNames||function(n){return t(n,r)},Nn}var Wn,Vn,Bn,qn,Un,Hn,Xn,$n,Kn,Yn,Jn,Qn,Zn,te,re,ne,ee,ue,ie,oe,fe,ce,ae,se,le,ve,pe,he,de,ye,ge,be,me,Se={};function we(){if(Bn)return Vn;Bn=1;var t=Hr(),r=A(),n=Gn(),e=(Wn||(Wn=1,Se.f=Object.getOwnPropertySymbols),Se),u=jt(),i=r([].concat);return Vn=t("Reflect","ownKeys")||function(t){var r=n.f(u(t)),o=e.f;return o?i(r,o(t)):r}}function Oe(){if(Un)return qn;Un=1;var t=yt(),r=we(),n=xn(),e=rn();return qn=function(u,i,o){for(var f=r(i),c=e.f,a=n.f,s=0;s<f.length;s++){var l=f[s];t(u,l)||o&&t(o,l)||c(u,l,a(i,l))}}}function Ee(){if(Xn)return Hn;Xn=1;var t=R(),r=Ot(),n=/#|\.prototype\./,e=function(n,e){var c=i[u(n)];return c===f||c!==o&&(r(e)?t(e):!!e)},u=e.normalize=function(t){return String(t).replace(n,".").toLowerCase()},i=e.data={},o=e.NATIVE="N",f=e.POLYFILL="P";return Hn=e}function je(){if(Kn)return $n;Kn=1;var t=L(),r=xn().f,n=bn(),e=_n(),u=vt(),i=Oe(),o=Ee();return $n=function(f,c){var a,s,l,v,p,h=f.target,d=f.global,y=f.stat;if(a=d?t:y?t[h]||u(h,{}):t[h]&&t[h].prototype)for(s in c){if(v=c[s],l=f.dontCallGetSet?(p=r(a,s))&&p.value:a[s],!o(d?s:h+(y?".":"#")+s,f.forced)&&void 0!==l){if(typeof v==typeof l)continue;i(v,l)}(f.sham||l&&l.sham)&&n(v,"sham",!0),e(a,s,v,f)}}}function xe(){if(Zn)return Qn;Zn=1;var t=yt(),r=Ot(),n=dt(),e=vn(),u=function(){if(Jn)return Yn;Jn=1;var t=R();return Yn=!t((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype}))}(),i=e("IE_PROTO"),o=Object,f=o.prototype;return Qn=u?o.getPrototypeOf:function(e){var u=n(e);if(t(u,i))return u[i];var c=u.constructor;return r(c)&&u instanceof c?c.prototype:u instanceof o?f:null}}function Re(){if(re)return te;re=1;var t,r,n,e=R(),u=Ot(),i=Et(),o=pn(),f=xe(),c=_n(),a=wt(),s=lt(),l=a("iterator"),v=!1;return[].keys&&("next"in(n=[].keys())?(r=f(f(n)))!==Object.prototype&&(t=r):v=!0),!i(t)||e((function(){var r={};return t[l].call(r)!==r}))?t={}:s&&(t=o(t)),u(t[l])||c(t,l,(function(){return this})),te={IteratorPrototype:t,BUGGY_SAFARI_ITERATORS:v}}function Pe(){if(ee)return ne;ee=1;var t=rn().f,r=yt(),n=wt()("toStringTag");return ne=function(e,u,i){e&&!i&&(e=e.prototype),e&&!r(e,n)&&t(e,n,{configurable:!0,value:u})}}function Ae(){if(ae)return ce;ae=1;var t=Et();return ce=function(r){return t(r)||null===r}}function Te(){if(le)return se;le=1;var t=Ae(),r=String,n=TypeError;return se=function(e){if(t(e))return e;throw new n("Can't set "+r(e)+" as a prototype")}}function Ce(){if(pe)return ve;pe=1;var t=function(){if(fe)return oe;fe=1;var t=A(),r=Yr();return oe=function(n,e,u){try{return t(r(Object.getOwnPropertyDescriptor(n,e)[u]))}catch(t){}}}(),r=Et(),n=z(),e=Te();return ve=Object.setPrototypeOf||("__proto__"in{}?function(){var u,i=!1,o={};try{(u=t(Object.prototype,"__proto__","set"))(o,[]),i=o instanceof Array}catch(t){}return function(t,o){return n(t),e(o),r(t)?(i?u(t,o):t.__proto__=o,t):t}}():void 0)}function ke(){if(de)return he;de=1;var t=je(),r=Ur(),n=lt(),e=Ln(),u=Ot(),i=function(){if(ie)return ue;ie=1;var t=Re().IteratorPrototype,r=pn(),n=gn(),e=Pe(),u=dn(),i=function(){return this};return ue=function(o,f,c,a){var s=f+" Iterator";return o.prototype=r(t,{next:n(+!a,c)}),e(o,s,!1,!0),u[s]=i,o}}(),o=xe(),f=Ce(),c=Pe(),a=bn(),s=_n(),l=wt(),v=dn(),p=Re(),h=e.PROPER,d=e.CONFIGURABLE,y=p.IteratorPrototype,g=p.BUGGY_SAFARI_ITERATORS,b=l("iterator"),m="keys",S="values",w="entries",O=function(){return this};return he=function(e,l,p,E,j,x,R){i(p,l,E);var P,A,T,C=function(t){if(t===j&&M)return M;if(!g&&t&&t in I)return I[t];switch(t){case m:case S:case w:return function(){return new p(this,t)}}return function(){return new p(this)}},k=l+" Iterator",z=!1,I=e.prototype,L=I[b]||I["@@iterator"]||j&&I[j],M=!g&&L||C(j),F="Array"===l&&I.entries||L;if(F&&(P=o(F.call(new e)))!==Object.prototype&&P.next&&(n||o(P)===y||(f?f(P,y):u(P[b])||s(P,b,O)),c(P,k,!0,!0),n&&(v[k]=O)),h&&j===S&&L&&L.name!==S&&(!n&&d?a(I,"name",S):(z=!0,M=function(){return r(L,this)})),j)if(A={values:C(S),keys:x?M:C(m),entries:C(w)},R)for(T in A)(g||z||!(T in I))&&s(I,T,A[T]);else t({target:l,proto:!0,forced:g||z},A);return n&&!R||I[b]===M||s(I,b,M,{name:j}),v[l]=M,A}}function ze(){return ge?ye:(ge=1,ye=function(t,r){return{value:t,done:r}})}function Ie(){if(me)return be;me=1;var t=I(),r=hn(),n=dn(),e=mn(),u=rn().f,i=ke(),o=ze(),f=lt(),c=Ct(),a="Array Iterator",s=e.set,l=e.getterFor(a);be=i(Array,"Array",(function(r,n){s(this,{type:a,target:t(r),index:0,kind:n})}),(function(){var t=l(this),r=t.target,n=t.index++;if(!r||n>=r.length)return t.target=null,o(void 0,!0);switch(t.kind){case"keys":return o(n,!1);case"values":return o(r[n],!1)}return o([n,r[n]],!1)}),"values");var v=n.Arguments=n.Array;if(r("keys"),r("values"),r("entries"),!f&&c&&"values"!==v.name)try{u(v,"name",{value:"values"})}catch(t){}return be}Ie();var Le,Me,Fe,_e,De,Ne,Ge,We,Ve,Be,qe,Ue,He,Xe,$e,Ke,Ye,Je,Qe,Ze,tu,ru={};function nu(){if(_e)return Fe;_e=1;var t=function(){if(Me)return Le;Me=1;var t=T(),r=A();return Le=function(n){if("Function"===t(n))return r(n)}}(),r=Yr(),n=P(),e=t(t.bind);return Fe=function(t,u){return r(t),void 0===u?t:n?e(t,u):function(){return t.apply(u,arguments)}},Fe}function eu(){if(Ne)return De;Ne=1;var t=T();return De=Array.isArray||function(r){return"Array"===t(r)}}function uu(){if(We)return Ge;We=1;var t={};return t[wt()("toStringTag")]="z",Ge="[object z]"===String(t)}function iu(){if(Be)return Ve;Be=1;var t=uu(),r=Ot(),n=T(),e=wt()("toStringTag"),u=Object,i="Arguments"===n(function(){return arguments}());return Ve=t?n:function(t){var o,f,c;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(f=function(t,r){try{return t[r]}catch(t){}}(o=u(t),e))?f:i?n(o):"Object"===(c=n(o))&&r(o.callee)?"Arguments":c}}function ou(){if(Ue)return qe;Ue=1;var t=A(),r=R(),n=Ot(),e=iu(),u=Hr(),i=Mn(),o=function(){},f=u("Reflect","construct"),c=/^\s*(?:class|function)\b/,a=t(c.exec),s=!c.test(o),l=function(t){if(!n(t))return!1;try{return f(o,[],t),!0}catch(t){return!1}},v=function(t){if(!n(t))return!1;switch(e(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return s||!!a(c,i(t))}catch(t){return!0}};return v.sham=!0,qe=!f||r((function(){var t;return l(l.call)||!l(Object)||!l((function(){t=!0}))||t}))?v:l}function fu(){if(Xe)return He;Xe=1;var t=eu(),r=ou(),n=Et(),e=wt()("species"),u=Array;return He=function(i){var o;return t(i)&&(o=i.constructor,(r(o)&&(o===u||t(o.prototype))||n(o)&&null===(o=o[e]))&&(o=void 0)),void 0===o?u:o}}function cu(){if(Ke)return $e;Ke=1;var t=fu();return $e=function(r,n){return new(t(r))(0===n?0:n)}}function au(){if(Je)return Ye;Je=1;var t=nu(),r=A(),n=C(),e=dt(),u=on(),i=cu(),o=r([].push),f=function(r){var f=1===r,c=2===r,a=3===r,s=4===r,l=6===r,v=7===r,p=5===r||l;return function(h,d,y,g){for(var b,m,S=e(h),w=n(S),O=u(w),E=t(d,y),j=0,x=g||i,R=f?x(h,O):c||v?x(h,0):void 0;O>j;j++)if((p||j in w)&&(m=E(b=w[j],j,S),r))if(f)R[j]=m;else if(m)switch(r){case 3:return!0;case 5:return b;case 6:return j;case 2:o(R,b)}else switch(r){case 4:return!1;case 7:o(R,b)}return l?-1:a||s?s:R}};return Ye={forEach:f(0),map:f(1),filter:f(2),some:f(3),every:f(4),find:f(5),findIndex:f(6),filterReject:f(7)}}function su(){if(Ze)return Qe;Ze=1;var t=R(),r=wt(),n=bt(),e=r("species");return Qe=function(r){return n>=51||!t((function(){var t=[];return(t.constructor={})[e]=function(){return{foo:1}},1!==t[r](Boolean).foo}))}}!function(){if(tu)return ru;tu=1;var t=je(),r=au().map;t({target:"Array",proto:!0,forced:!su()("map")},{map:function(t){return r(this,t,arguments.length>1?arguments[1]:void 0)}})}();var lu,vu,pu,hu={};!function(){if(pu)return hu;pu=1;var t=je(),r=function(){if(vu)return lu;vu=1;var t=Ct(),r=R(),n=A(),e=xe(),u=sn(),i=I(),o=n(jn().f),f=n([].push),c=t&&r((function(){var t=Object.create(null);return t[2]=2,!o(t,2)})),a=function(r){return function(n){for(var a,s=i(n),l=u(s),v=c&&null===e(s),p=l.length,h=0,d=[];p>h;)a=l[h++],t&&!(v?a in s:o(s,a))||f(d,r?[a,s[a]]:s[a]);return d}};return lu={entries:a(!0),values:a(!1)}}().entries;t({target:"Object",stat:!0},{entries:function(t){return r(t)}})}();var du,yu,gu={};function bu(){if(yu)return du;yu=1;var t=R();return du=!t((function(){return Object.isExtensible(Object.preventExtensions({}))}))}var mu,Su,wu,Ou,Eu,ju,xu,Ru,Pu,Au={exports:{}},Tu={};function Cu(){if(Su)return mu;Su=1;var t=A();return mu=t([].slice)}function ku(){if(wu)return Tu;wu=1;var t=T(),r=I(),n=Gn().f,e=Cu(),u="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[];return Tu.f=function(i){return u&&"Window"===t(i)?function(t){try{return n(t)}catch(t){return e(u)}}(i):n(r(i))},Tu}function zu(){if(xu)return ju;xu=1;var t=R(),r=Et(),n=T(),e=function(){if(Eu)return Ou;Eu=1;var t=R();return Ou=t((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}}))}(),u=Object.isExtensible,i=t((function(){}));return ju=i||e?function(t){return!!r(t)&&((!e||"ArrayBuffer"!==n(t))&&(!u||u(t)))}:u}function Iu(){if(Ru)return Au.exports;Ru=1;var t=je(),r=A(),n=fn(),e=Et(),u=yt(),i=rn().f,o=Gn(),f=ku(),c=zu(),a=gt(),s=bu(),l=!1,v=a("meta"),p=0,h=function(t){i(t,v,{value:{objectID:"O"+p++,weakData:{}}})},d=Au.exports={enable:function(){d.enable=function(){},l=!0;var n=o.f,e=r([].splice),u={};u[v]=1,n(u).length&&(o.f=function(t){for(var r=n(t),u=0,i=r.length;u<i;u++)if(r[u]===v){e(r,u,1);break}return r},t({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:f.f}))},fastKey:function(t,r){if(!e(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!u(t,v)){if(!c(t))return"F";if(!r)return"E";h(t)}return t[v].objectID},getWeakData:function(t,r){if(!u(t,v)){if(!c(t))return!0;if(!r)return!1;h(t)}return t[v].weakData},onFreeze:function(t){return s&&l&&c(t)&&!u(t,v)&&h(t),t}};return n[v]=!0,Au.exports}!function(){if(Pu)return gu;Pu=1;var t=je(),r=bu(),n=R(),e=Et(),u=Iu().onFreeze,i=Object.freeze;t({target:"Object",stat:!0,forced:n((function(){i(1)})),sham:!r},{freeze:function(t){return i&&e(t)?i(u(t)):t}})}();var Lu,Mu,Fu,_u,Du,Nu,Gu,Wu,Vu,Bu,qu,Uu,Hu,Xu={};function $u(){if(Mu)return Lu;Mu=1;var t=wt(),r=dn(),n=t("iterator"),e=Array.prototype;return Lu=function(t){return void 0!==t&&(r.Array===t||e[n]===t)}}function Ku(){if(_u)return Fu;_u=1;var t=iu(),r=Jr(),n=k(),e=dn(),u=wt()("iterator");return Fu=function(i){if(!n(i))return r(i,u)||r(i,"@@iterator")||e[t(i)]}}function Yu(){if(Nu)return Du;Nu=1;var t=Ur(),r=Yr(),n=jt(),e=Kr(),u=Ku(),i=TypeError;return Du=function(o,f){var c=arguments.length<2?u(o):f;if(r(c))return n(t(c,o));throw new i(e(o)+" is not iterable")},Du}function Ju(){if(Wu)return Gu;Wu=1;var t=Ur(),r=jt(),n=Jr();return Gu=function(e,u,i){var o,f;r(e);try{if(!(o=n(e,"return"))){if("throw"===u)throw i;return i}o=t(o,e)}catch(t){f=!0,o=t}if("throw"===u)throw i;if(f)throw o;return r(o),i}}function Qu(){if(Bu)return Vu;Bu=1;var t=nu(),r=Ur(),n=jt(),e=Kr(),u=$u(),i=on(),o=Xr(),f=Yu(),c=Ku(),a=Ju(),s=TypeError,l=function(t,r){this.stopped=t,this.result=r},v=l.prototype;return Vu=function(p,h,d){var y,g,b,m,S,w,O,E=d&&d.that,j=!(!d||!d.AS_ENTRIES),x=!(!d||!d.IS_RECORD),R=!(!d||!d.IS_ITERATOR),P=!(!d||!d.INTERRUPTED),A=t(h,E),T=function(t){return y&&a(y,"normal",t),new l(!0,t)},C=function(t){return j?(n(t),P?A(t[0],t[1],T):A(t[0],t[1])):P?A(t,T):A(t)};if(x)y=p.iterator;else if(R)y=p;else{if(!(g=c(p)))throw new s(e(p)+" is not iterable");if(u(g)){for(b=0,m=i(p);m>b;b++)if((S=C(p[b]))&&o(v,S))return S;return new l(!1)}y=f(p,g)}for(w=x?p.next:y.next;!(O=r(w,y)).done;){try{S=C(O.value)}catch(t){a(y,"throw",t)}if("object"==typeof S&&S&&o(v,S))return S}return new l(!1)}}function Zu(){if(Uu)return qu;Uu=1;var t=Ct(),r=rn(),n=gn();return qu=function(e,u,i){t?r.f(e,u,n(0,i)):e[u]=i}}!function(){if(Hu)return Xu;Hu=1;var t=je(),r=Qu(),n=Zu();t({target:"Object",stat:!0},{fromEntries:function(t){var e={};return r(t,(function(t,r){n(e,t,r)}),{AS_ENTRIES:!0}),e}})}();var ti,ri={};!function(){if(ti)return ri;ti=1;var t=je(),r=dt(),n=sn();t({target:"Object",stat:!0,forced:R()((function(){n(1)}))},{keys:function(t){return n(r(t))}})}();var ni,ei,ui,ii={};!function(){if(ui)return ii;ui=1;var t=uu(),r=_n(),n=function(){if(ei)return ni;ei=1;var t=uu(),r=iu();return ni=t?{}.toString:function(){return"[object "+r(this)+"]"}}();t||r(Object.prototype,"toString",n,{unsafe:!0})}();var oi,fi,ci,ai,si,li={};function vi(){if(fi)return oi;fi=1;var t=iu(),r=String;return oi=function(n){if("Symbol"===t(n))throw new TypeError("Cannot convert a Symbol value to a string");return r(n)}}!function(){if(si)return li;si=1;var t=function(){if(ai)return ci;ai=1;var t=A(),r=nn(),n=vi(),e=z(),u=t("".charAt),i=t("".charCodeAt),o=t("".slice),f=function(t){return function(f,c){var a,s,l=n(e(f)),v=r(c),p=l.length;return v<0||v>=p?t?"":void 0:(a=i(l,v))<55296||a>56319||v+1===p||(s=i(l,v+1))<56320||s>57343?t?u(l,v):a:t?o(l,v,v+2):s-56320+(a-55296<<10)+65536}};return ci={codeAt:f(!1),charAt:f(!0)}}().charAt,r=vi(),n=mn(),e=ke(),u=ze(),i="String Iterator",o=n.set,f=n.getterFor(i);e(String,"String",(function(t){o(this,{type:i,string:r(t),index:0})}),(function(){var r,n=f(this),e=n.string,i=n.index;return i>=e.length?u(void 0,!0):(r=t(e,i),n.index+=r.length,u(r,!1))}))}();var pi,hi,di,yi,gi,bi,mi,Si,wi,Oi,Ei,ji,xi,Ri,Pi={};function Ai(){if(hi)return pi;hi=1;var t=_n();return pi=function(r,n,e){for(var u in n)t(r,u,n[u],e);return r}}function Ti(){if(yi)return di;yi=1;var t=Xr(),r=TypeError;return di=function(n,e){if(t(e,n))return n;throw new r("Incorrect invocation")}}function Ci(){if(bi)return gi;bi=1;var t=wt()("iterator"),r=!1;try{var n=0,e={next:function(){return{done:!!n++}},return:function(){r=!0}};e[t]=function(){return this},Array.from(e,(function(){throw 2}))}catch(t){}return gi=function(n,e){try{if(!e&&!r)return!1}catch(t){return!1}var u=!1;try{var i={};i[t]=function(){return{next:function(){return{done:u=!0}}}},n(i)}catch(t){}return u}}function ki(){if(Si)return mi;Si=1;var t=Ot(),r=Et(),n=Ce();return mi=function(e,u,i){var o,f;return n&&t(o=u.constructor)&&o!==i&&r(f=o.prototype)&&f!==i.prototype&&n(e,f),e}}function zi(){if(Oi)return wi;Oi=1;var t=je(),r=L(),n=A(),e=Ee(),u=_n(),i=Iu(),o=Qu(),f=Ti(),c=Ot(),a=k(),s=Et(),l=R(),v=Ci(),p=Pe(),h=ki();return wi=function(d,y,g){var b=-1!==d.indexOf("Map"),m=-1!==d.indexOf("Weak"),S=b?"set":"add",w=r[d],O=w&&w.prototype,E=w,j={},x=function(t){var r=n(O[t]);u(O,t,"add"===t?function(t){return r(this,0===t?0:t),this}:"delete"===t?function(t){return!(m&&!s(t))&&r(this,0===t?0:t)}:"get"===t?function(t){return m&&!s(t)?void 0:r(this,0===t?0:t)}:"has"===t?function(t){return!(m&&!s(t))&&r(this,0===t?0:t)}:function(t,n){return r(this,0===t?0:t,n),this})};if(e(d,!c(w)||!(m||O.forEach&&!l((function(){(new w).entries().next()})))))E=g.getConstructor(y,d,b,S),i.enable();else if(e(d,!0)){var R=new E,P=R[S](m?{}:-0,1)!==R,A=l((function(){R.has(1)})),T=v((function(t){new w(t)})),C=!m&&l((function(){for(var t=new w,r=5;r--;)t[S](r,r);return!t.has(-0)}));T||((E=y((function(t,r){f(t,O);var n=h(new w,t,E);return a(r)||o(r,n[S],{that:n,AS_ENTRIES:b}),n}))).prototype=O,O.constructor=E),(A||C)&&(x("delete"),x("has"),b&&x("get")),(C||P)&&x(S),m&&O.clear&&delete O.clear}return j[d]=E,t({global:!0,constructor:!0,forced:E!==w},j),p(E,d),m||g.setStrong(E,d,b),E}}function Ii(){if(ji)return Ei;ji=1;var t=A(),r=Ai(),n=Iu().getWeakData,e=Ti(),u=jt(),i=k(),o=Et(),f=Qu(),c=au(),a=yt(),s=mn(),l=s.set,v=s.getterFor,p=c.find,h=c.findIndex,d=t([].splice),y=0,g=function(t){return t.frozen||(t.frozen=new b)},b=function(){this.entries=[]},m=function(t,r){return p(t.entries,(function(t){return t[0]===r}))};return b.prototype={get:function(t){var r=m(this,t);if(r)return r[1]},has:function(t){return!!m(this,t)},set:function(t,r){var n=m(this,t);n?n[1]=r:this.entries.push([t,r])},delete:function(t){var r=h(this.entries,(function(r){return r[0]===t}));return~r&&d(this.entries,r,1),!!~r}},Ei={getConstructor:function(t,c,s,p){var h=t((function(t,r){e(t,d),l(t,{type:c,id:y++,frozen:null}),i(r)||f(r,t[p],{that:t,AS_ENTRIES:s})})),d=h.prototype,b=v(c),m=function(t,r,e){var i=b(t),o=n(u(r),!0);return!0===o?g(i).set(r,e):o[i.id]=e,t};return r(d,{delete:function(t){var r=b(this);if(!o(t))return!1;var e=n(t);return!0===e?g(r).delete(t):e&&a(e,r.id)&&delete e[r.id]},has:function(t){var r=b(this);if(!o(t))return!1;var e=n(t);return!0===e?g(r).has(t):e&&a(e,r.id)}}),r(d,s?{get:function(t){var r=b(this);if(o(t)){var e=n(t);if(!0===e)return g(r).get(t);if(e)return e[r.id]}},set:function(t,r){return m(this,t,r)}}:{add:function(t){return m(this,t,!0)}}),h}}}Ri||(Ri=1,function(){if(xi)return Pi;xi=1;var t,r=bu(),n=L(),e=A(),u=Ai(),i=Iu(),o=zi(),f=Ii(),c=Et(),a=mn().enforce,s=R(),l=yn(),v=Object,p=Array.isArray,h=v.isExtensible,d=v.isFrozen,y=v.isSealed,g=v.freeze,b=v.seal,m=!n.ActiveXObject&&"ActiveXObject"in n,S=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},w=o("WeakMap",S,f),O=w.prototype,E=e(O.set);if(l)if(m){t=f.getConstructor(S,"WeakMap",!0),i.enable();var j=e(O.delete),x=e(O.has),P=e(O.get);u(O,{delete:function(r){if(c(r)&&!h(r)){var n=a(this);return n.frozen||(n.frozen=new t),j(this,r)||n.frozen.delete(r)}return j(this,r)},has:function(r){if(c(r)&&!h(r)){var n=a(this);return n.frozen||(n.frozen=new t),x(this,r)||n.frozen.has(r)}return x(this,r)},get:function(r){if(c(r)&&!h(r)){var n=a(this);return n.frozen||(n.frozen=new t),x(this,r)?P(this,r):n.frozen.get(r)}return P(this,r)},set:function(r,n){if(c(r)&&!h(r)){var e=a(this);e.frozen||(e.frozen=new t),x(this,r)?E(this,r,n):e.frozen.set(r,n)}else E(this,r,n);return this}})}else r&&s((function(){var t=g([]);return E(new w,t,1),!d(t)}))&&u(O,{set:function(t,r){var n;return p(t)&&(d(t)?n=g:y(t)&&(n=b)),E(this,t,r),n&&n(t),this}})}());var Li,Mi,Fi,_i,Di,Ni={};function Gi(){return Mi?Li:(Mi=1,Li={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0})}function Wi(){if(_i)return Fi;_i=1;var t=Br()("span").classList,r=t&&t.constructor&&t.constructor.prototype;return Fi=r===Object.prototype?void 0:r}!function(){if(Di)return Ni;Di=1;var t=L(),r=Gi(),n=Wi(),e=Ie(),u=bn(),i=Pe(),o=wt()("iterator"),f=e.values,c=function(t,n){if(t){if(t[o]!==f)try{u(t,o,f)}catch(r){t[o]=f}if(i(t,n,!0),r[n])for(var c in e)if(t[c]!==e[c])try{u(t,c,e[c])}catch(r){t[c]=e[c]}}};for(var a in r)c(t[a]&&t[a].prototype,a);c(n,"DOMTokenList")}();var Vi=function(){return Vi=Object.assign||function(t){for(var r,n=1,e=arguments.length;n<e;n++)for(var u in r=arguments[n])Object.prototype.hasOwnProperty.call(r,u)&&(t[u]=r[u]);return t},Vi.apply(this,arguments)};function Bi(t,r){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var e,u,i=n.call(t),o=[];try{for(;(void 0===r||r-- >0)&&!(e=i.next()).done;)o.push(e.value)}catch(t){u={error:t}}finally{try{e&&!e.done&&(n=i.return)&&n.call(i)}finally{if(u)throw u.error}}return o}"function"==typeof SuppressedError&&SuppressedError;var qi=new WeakMap;function Ui(t,r){if(!r.relativeSelection)return null;var e=qi.get(t.children);e||(e=new WeakMap,qi.set(t.children,e));var u=e.get(r);if(void 0===u)try{u=n.relativeRangeToSlateRange(t.sharedRoot,t,r.relativeSelection),e.set(r,u)}catch(t){return null}return u}function Hi(t,r,n){var i,o,f=n.yOffset,c=n.xOffset,a=n.shouldGenerateOverlay,s=Bi(u.Range.edges(r),2),l=s[0],v=s[1],p=function(t,r){try{return e.DomEditor.toDOMRange(t,r)}catch(t){return null}}(t,r);if(!p)return{caretPosition:null,selectionRects:[]};var h=[],d=u.Editor.nodes(t,{at:r,match:function(t,r){return u.Text.isText(t)&&(!a||a(t,r))}}),y=null,g=u.Range.isBackward(r);try{for(var b=function(t){var r="function"==typeof Symbol&&Symbol.iterator,n=r&&t[r],e=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&e>=t.length&&(t=void 0),{value:t&&t[e++],done:!t}}};throw new TypeError(r?"Object is not iterable.":"Symbol.iterator is not defined.")}(d),m=b.next();!m.done;m=b.next()){var S=Bi(m.value,2),w=S[0],O=S[1],E=e.DomEditor.toDOMNode(t,w),j=u.Path.equals(O,l.path),x=u.Path.equals(O,v.path),R=null;if(j||x){var P=document.createRange();P.selectNode(E),j&&P.setStart(p.startContainer,p.startOffset),x&&P.setEnd(p.endContainer,p.endOffset),R=P.getClientRects()}else R=E.getClientRects();for(var A=g?j:x,T=0;T<R.length;T+=1){var C=R.item(T);if(C){var k=A&&(g?0===T:T===R.length-1),z=C.top-f,I=C.left-c;k&&(y={height:C.height,top:z,left:I+(g||u.Range.isCollapsed(r)?0:C.width)}),h.push({width:C.width,height:C.height,top:z,left:I})}}}}catch(t){i={error:t}}finally{try{m&&!m.done&&(o=b.return)&&o.call(b)}finally{if(i)throw i.error}}return{selectionRects:h,caretPosition:y}}function Xi(){var t=j();return n.CursorEditor.isCursorEditor(t)||console.warn("Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor"),t}var $i,Ki,Yi={exports:{}},Ji={};function Qi(){return Ki||(Ki=1,Yi.exports=function(){if($i)return Ji;$i=1;var t=r,n="function"==typeof Object.is?Object.is:function(t,r){return t===r&&(0!==t||1/t==1/r)||t!=t&&r!=r},e=t.useState,u=t.useEffect,i=t.useLayoutEffect,o=t.useDebugValue;function f(t){var r=t.getSnapshot;t=t.value;try{var e=r();return!n(t,e)}catch(t){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,r){return r()}:function(t,r){var n=r(),c=e({inst:{value:n,getSnapshot:r}}),a=c[0].inst,s=c[1];return i((function(){a.value=n,a.getSnapshot=r,f(a)&&s({inst:a})}),[t,n,r]),u((function(){return f(a)&&s({inst:a}),t((function(){f(a)&&s({inst:a})}))}),[t]),o(n),n};return Ji.useSyncExternalStore=void 0!==t.useSyncExternalStore?t.useSyncExternalStore:c,Ji}()),Yi.exports}var Zi,to,ro=Qi(),no={exports:{}},eo={};var uo,io,oo,fo,co,ao=(to||(to=1,no.exports=function(){if(Zi)return eo;Zi=1;var t=r,n=Qi(),e="function"==typeof Object.is?Object.is:function(t,r){return t===r&&(0!==t||1/t==1/r)||t!=t&&r!=r},u=n.useSyncExternalStore,i=t.useRef,o=t.useEffect,f=t.useMemo,c=t.useDebugValue;return eo.useSyncExternalStoreWithSelector=function(t,r,n,a,s){var l=i(null);if(null===l.current){var v={hasValue:!1,value:null};l.current=v}else v=l.current;l=f((function(){function t(t){if(!o){if(o=!0,u=t,t=a(t),void 0!==s&&v.hasValue){var r=v.value;if(s(r,t))return i=r}return i=t}if(r=i,e(u,t))return r;var n=a(t);return void 0!==s&&s(r,n)?r:(u=t,i=n)}var u,i,o=!1,f=void 0===n?null:n;return[function(){return t(r())},null===f?void 0:function(){return t(f())}]}),[r,n,a,s]);var p=u(t,l[0],l[1]);return o((function(){v.hasValue=!0,v.value=p}),[p]),c(p),p},eo}()),no.exports),so={};function lo(){if(fo)return oo;fo=1;var t=Ur(),r=yt(),n=Xr(),e=function(){if(io)return uo;io=1;var t=jt();return uo=function(){var r=t(this),n="";return r.hasIndices&&(n+="d"),r.global&&(n+="g"),r.ignoreCase&&(n+="i"),r.multiline&&(n+="m"),r.dotAll&&(n+="s"),r.unicode&&(n+="u"),r.unicodeSets&&(n+="v"),r.sticky&&(n+="y"),n}}(),u=RegExp.prototype;return oo=function(i){var o=i.flags;return void 0!==o||"flags"in u||r(i,"flags")||!n(u,i)?o:t(e,i)}}!function(){if(co)return so;co=1;var t=Ln().PROPER,r=_n(),n=jt(),e=vi(),u=R(),i=lo(),o="toString",f=RegExp.prototype,c=f[o],a=u((function(){return"/a/b"!==c.call({source:"a",flags:"b"})})),s=t&&c.name!==o;(a||s)&&r(f,o,(function(){var t=n(this);return"/"+e(t.source)+"/"+e(i(t))}),{unsafe:!0})}();var vo,po,ho,yo,go,bo,mo,So;function wo(){if(po)return vo;po=1;var t=Fn(),r=rn();return vo=function(n,e,u){return u.get&&t(u.get,e,{getter:!0}),u.set&&t(u.set,e,{setter:!0}),r.f(n,e,u)}}function Oo(){if(yo)return ho;yo=1;var t=Hr(),r=wo(),n=wt(),e=Ct(),u=n("species");return ho=function(n){var i=t(n);e&&i&&!i[u]&&r(i,u,{configurable:!0,get:function(){return this}})}}So||(So=1,mo||(mo=1,zi()("Set",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),function(){if(bo)return go;bo=1;var t=pn(),r=wo(),n=Ai(),e=nu(),u=Ti(),i=k(),o=Qu(),f=ke(),c=ze(),a=Oo(),s=Ct(),l=Iu().fastKey,v=mn(),p=v.set,h=v.getterFor;return go={getConstructor:function(f,c,a,v){var d=f((function(r,n){u(r,y),p(r,{type:c,index:t(null),first:null,last:null,size:0}),s||(r.size=0),i(n)||o(n,r[v],{that:r,AS_ENTRIES:a})})),y=d.prototype,g=h(c),b=function(t,r,n){var e,u,i=g(t),o=m(t,r);return o?o.value=n:(i.last=o={index:u=l(r,!0),key:r,value:n,previous:e=i.last,next:null,removed:!1},i.first||(i.first=o),e&&(e.next=o),s?i.size++:t.size++,"F"!==u&&(i.index[u]=o)),t},m=function(t,r){var n,e=g(t),u=l(r);if("F"!==u)return e.index[u];for(n=e.first;n;n=n.next)if(n.key===r)return n};return n(y,{clear:function(){for(var r=g(this),n=r.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=null),n=n.next;r.first=r.last=null,r.index=t(null),s?r.size=0:this.size=0},delete:function(t){var r=this,n=g(r),e=m(r,t);if(e){var u=e.next,i=e.previous;delete n.index[e.index],e.removed=!0,i&&(i.next=u),u&&(u.previous=i),n.first===e&&(n.first=u),n.last===e&&(n.last=i),s?n.size--:r.size--}return!!e},forEach:function(t){for(var r,n=g(this),u=e(t,arguments.length>1?arguments[1]:void 0);r=r?r.next:n.first;)for(u(r.value,r.key,this);r&&r.removed;)r=r.previous},has:function(t){return!!m(this,t)}}),n(y,a?{get:function(t){var r=m(this,t);return r&&r.value},set:function(t,r){return b(this,0===t?0:t,r)}}:{add:function(t){return b(this,t=0===t?0:t,t)}}),s&&r(y,"size",{configurable:!0,get:function(){return g(this).size}}),d},setStrong:function(t,r,n){var e=r+" Iterator",u=h(r),i=h(e);f(t,r,(function(t,r){p(this,{type:e,target:t,state:u(t),kind:r,last:null})}),(function(){for(var t=i(this),r=t.kind,n=t.last;n&&n.removed;)n=n.previous;return t.target&&(t.last=n=n?n.next:t.state.first)?c("keys"===r?n.key:"values"===r?n.value:[n.key,n.value],!1):(t.target=null,c(void 0,!0))}),n?"entries":"values",!n,!0),a(r)}},go}())));var Eo,jo,xo,Ro,Po,Ao={};!function(){if(Po)return Ao;Po=1;var t=L(),r=Gi(),n=Wi(),e=function(){if(Ro)return xo;Ro=1;var t=au().forEach,r=function(){if(jo)return Eo;jo=1;var t=R();return Eo=function(r,n){var e=[][r];return!!e&&t((function(){e.call(null,n||function(){return 1},1)}))}}()("forEach");return xo=r?[].forEach:function(r){return t(this,r,arguments.length>1?arguments[1]:void 0)},xo}(),u=bn(),i=function(t){if(t&&t.forEach!==e)try{u(t,"forEach",e)}catch(r){t.forEach=e}};for(var o in r)r[o]&&i(t[o]&&t[o].prototype);i(n)}();var To=new WeakMap;function Co(t){var r=To.get(t);if(r)return r;var e=function(t){var r={},e=new Set,u=e.add.bind(e),i=new Set,o=null;return[function(r){return i.add(r),o||(o=function(t){t.added.forEach(u),t.removed.forEach(u),t.updated.forEach(u),i.forEach((function(t){return t()}))},n.CursorEditor.on(t,"change",o)),function(){i.delete(r),o&&0===i.size&&(n.CursorEditor.off(t,"change",o),o=null)}},function(){return 0===e.size?r:(e.forEach((function(e){var u=n.CursorEditor.cursorState(t,e);null!==u?r[e]=u:delete r[e.toString()]})),e.clear(),r=Vi({},r))}]}(t);return t&&To.set(t,e),e}function ko(){return Co(Xi())}function zo(){var t=Bi(ko(),2),r=t[0],n=t[1];return ro.useSyncExternalStore(r,n)}var Io=Object.freeze([]);t.EditorContext=E,t.getCursorRange=Ui,t.useEditorStatic=j,t.useRemoteCursorOverlayPositions=function(t){var n;void 0===t&&(t={});var e,u,i,o=t.containerRef,f=t.shouldGenerateOverlay,c=function(t,r){var n={};for(var e in t)Object.prototype.hasOwnProperty.call(t,e)&&r.indexOf(e)<0&&(n[e]=t[e]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var u=0;for(e=Object.getOwnPropertySymbols(t);u<e.length;u++)r.indexOf(e[u])<0&&Object.prototype.propertyIsEnumerable.call(t,e[u])&&(n[e[u]]=t[e[u]])}return n}(t,["containerRef","shouldGenerateOverlay"]),a=Xi(),s=zo(),l=(e=Bi(r.useReducer((function(t){return t+1}),0),2)[1],u=r.useRef(null),i=function(){u.current&&(cancelAnimationFrame(u.current),u.current=0)},r.useEffect(i),r.useEffect((function(){return i}),[]),r.useCallback((function(t){void 0===t&&(t=!1),t?e():u.current||(u.current=requestAnimationFrame(e))}),[])),v=r.useRef(new WeakMap),p=Bi(r.useState({}),2),h=p[0],d=p[1],y=!("refreshOnResize"in c)||(null===(n=c.refreshOnResize)||void 0===n||n);!function(t,n){var e=r.useRef(n);e.current=n;var u=Bi(r.useState((function(){return new ResizeObserver((function(){e.current()}))})),1)[0];r.useEffect((function(){if(null==t?void 0:t.current){var r=t.current;return u.observe(r),function(){return u.unobserve(r)}}}),[u,t])}(y?o:void 0,(function(){v.current=new WeakMap,l("debounced"!==y)})),r.useLayoutEffect((function(){var t,r,n;if(!o||o.current){var e=null===(t=null==o?void 0:o.current)||void 0===t?void 0:t.getBoundingClientRect(),u=null!==(r=null==e?void 0:e.x)&&void 0!==r?r:0,i=null!==(n=null==e?void 0:e.y)&&void 0!==n?n:0,c=Object.keys(h).length!==Object.keys(s).length,l=Object.fromEntries(Object.entries(s).map((function(t){var r=Bi(t,2),n=r[0],e=r[1],o=e.relativeSelection&&Ui(a,e);if(!o)return[n,Io];var s=v.current.get(o);if(s)return[n,s];var l=Hi(a,o,{xOffset:u,yOffset:i,shouldGenerateOverlay:f});return c=!0,v.current.set(o,l),[n,l]})));c&&d(l)}}));var g=r.useMemo((function(){return Object.entries(s).map((function(t){var r,n,e=Bi(t,2),u=e[0],i=e[1],o=i.relativeSelection&&Ui(a,i),f=h[u];return Vi(Vi({},i),{range:o,caretPosition:null!==(r=null==f?void 0:f.caretPosition)&&void 0!==r?r:null,selectionRects:null!==(n=null==f?void 0:f.selectionRects)&&void 0!==n?n:Io})}))}),[s,a,h]);return[g,r.useCallback((function(){v.current=new WeakMap,l(!0)}),[l])]},t.useRemoteCursorStates=zo,t.useRemoteCursorStatesSelector=function(t,r){var n=Bi(ko(),2),e=n[0],u=n[1];return ao.useSyncExternalStoreWithSelector(e,u,null,t,r)}}));
2
+ //# sourceMappingURL=index.js.map