@wangeditor-next/yjs 0.1.2 → 0.1.4
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/applyToYjs/types.d.ts +2 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.esm.js +2 -1719
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -1438
- package/dist/index.js.map +1 -1
- package/dist/module/custom-types.d.ts +11 -11
- package/dist/plugins/index.d.ts +2 -2
- package/dist/plugins/withCursors.d.ts +6 -6
- package/dist/plugins/withYHistory.d.ts +2 -2
- package/dist/plugins/withYjs.d.ts +3 -3
- package/dist/utils/object.d.ts +4 -4
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,1438 +1,2 @@
|
|
|
1
|
-
(function (global, factory) {
|
|
2
|
-
|
|
3
|
-
typeof define === 'function' && define.amd ? define(['exports', 'slate', 'yjs'], factory) :
|
|
4
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.WangEditorYjsModule = {}, global.slate, global.Y));
|
|
5
|
-
})(this, (function (exports, slate, Y) { 'use strict';
|
|
6
|
-
|
|
7
|
-
function _interopNamespace(e) {
|
|
8
|
-
if (e && e.__esModule) return e;
|
|
9
|
-
var n = Object.create(null);
|
|
10
|
-
if (e) {
|
|
11
|
-
Object.keys(e).forEach(function (k) {
|
|
12
|
-
if (k !== 'default') {
|
|
13
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
get: function () { return e[k]; }
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
n["default"] = e;
|
|
22
|
-
return Object.freeze(n);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
var Y__namespace = /*#__PURE__*/_interopNamespace(Y);
|
|
26
|
-
|
|
27
|
-
/******************************************************************************
|
|
28
|
-
Copyright (c) Microsoft Corporation.
|
|
29
|
-
|
|
30
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
31
|
-
purpose with or without fee is hereby granted.
|
|
32
|
-
|
|
33
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
34
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
35
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
36
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
37
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
38
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
39
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
40
|
-
***************************************************************************** */
|
|
41
|
-
|
|
42
|
-
var __assign = function() {
|
|
43
|
-
__assign = Object.assign || function __assign(t) {
|
|
44
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
45
|
-
s = arguments[i];
|
|
46
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
47
|
-
}
|
|
48
|
-
return t;
|
|
49
|
-
};
|
|
50
|
-
return __assign.apply(this, arguments);
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
function __rest(s, e) {
|
|
54
|
-
var t = {};
|
|
55
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
56
|
-
t[p] = s[p];
|
|
57
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
58
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
59
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
60
|
-
t[p[i]] = s[p[i]];
|
|
61
|
-
}
|
|
62
|
-
return t;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function __values(o) {
|
|
66
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
67
|
-
if (m) return m.call(o);
|
|
68
|
-
if (o && typeof o.length === "number") return {
|
|
69
|
-
next: function () {
|
|
70
|
-
if (o && i >= o.length) o = void 0;
|
|
71
|
-
return { value: o && o[i++], done: !o };
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
function __read(o, n) {
|
|
78
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
79
|
-
if (!m) return o;
|
|
80
|
-
var i = m.call(o), r, ar = [], e;
|
|
81
|
-
try {
|
|
82
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
83
|
-
}
|
|
84
|
-
catch (error) { e = { error: error }; }
|
|
85
|
-
finally {
|
|
86
|
-
try {
|
|
87
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
88
|
-
}
|
|
89
|
-
finally { if (e) throw e.error; }
|
|
90
|
-
}
|
|
91
|
-
return ar;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
function __spreadArray(to, from, pack) {
|
|
95
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
96
|
-
if (ar || !(i in from)) {
|
|
97
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
98
|
-
ar[i] = from[i];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
105
|
-
var e = new Error(message);
|
|
106
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
function isObject(o) {
|
|
110
|
-
return Object.prototype.toString.call(o) === '[object Object]';
|
|
111
|
-
}
|
|
112
|
-
function isPlainObject(o) {
|
|
113
|
-
if (!isObject(o)) {
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
// If has modified constructor
|
|
117
|
-
var ctor = o.constructor;
|
|
118
|
-
if (ctor === undefined) {
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
// If has modified prototype
|
|
122
|
-
var prot = ctor.prototype;
|
|
123
|
-
if (isObject(prot) === false) {
|
|
124
|
-
return false;
|
|
125
|
-
}
|
|
126
|
-
// If constructor does not have an Object-specific method
|
|
127
|
-
if (Object.prototype.hasOwnProperty.call(prot, 'isPrototypeOfOf')) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
// Most likely a plain Object
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
// Slates deep equality function: https://github.com/ianstormtaylor/slate/blob/68aff89e892fe15a16314398ff052ade6068900b/packages/slate/src/utils/deep-equal.ts#L13
|
|
134
|
-
// We have to match slates deepEquals behavior to merge insert deltas in the same way slate does.
|
|
135
|
-
function deepEquals(node, another) {
|
|
136
|
-
// eslint-disable-next-line guard-for-in
|
|
137
|
-
for (var key in node) {
|
|
138
|
-
var a = node[key];
|
|
139
|
-
var b = another[key];
|
|
140
|
-
if (isPlainObject(a) && isPlainObject(b)) {
|
|
141
|
-
if (!deepEquals(a, b)) {
|
|
142
|
-
return false;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
else if (Array.isArray(a) && Array.isArray(b)) {
|
|
146
|
-
if (a.length !== b.length)
|
|
147
|
-
return false;
|
|
148
|
-
for (var i = 0; i < a.length; i++) {
|
|
149
|
-
if (a[i] !== b[i]) {
|
|
150
|
-
return false;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
else if (a !== b) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
for (var key in another) {
|
|
159
|
-
if (node[key] === undefined && another[key] !== undefined) {
|
|
160
|
-
return false;
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return true;
|
|
164
|
-
}
|
|
165
|
-
function pick(obj) {
|
|
166
|
-
var keys = [];
|
|
167
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
168
|
-
keys[_i - 1] = arguments[_i];
|
|
169
|
-
}
|
|
170
|
-
return Object.fromEntries(Object.entries(obj).filter(function (_a) {
|
|
171
|
-
var _b = __read(_a, 1), key = _b[0];
|
|
172
|
-
return keys.includes(key);
|
|
173
|
-
}));
|
|
174
|
-
}
|
|
175
|
-
function omit(obj) {
|
|
176
|
-
var keys = [];
|
|
177
|
-
for (var _i = 1; _i < arguments.length; _i++) {
|
|
178
|
-
keys[_i - 1] = arguments[_i];
|
|
179
|
-
}
|
|
180
|
-
return Object.fromEntries(Object.entries(obj).filter(function (_a) {
|
|
181
|
-
var _b = __read(_a, 1), key = _b[0];
|
|
182
|
-
return !keys.includes(key);
|
|
183
|
-
}));
|
|
184
|
-
}
|
|
185
|
-
function omitNullEntries(obj) {
|
|
186
|
-
return Object.fromEntries(Object.entries(obj).filter(function (_a) {
|
|
187
|
-
var _b = __read(_a, 2), value = _b[1];
|
|
188
|
-
return value !== null;
|
|
189
|
-
}));
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
function normalizeInsertDelta(delta) {
|
|
193
|
-
var e_1, _a;
|
|
194
|
-
var _b, _c;
|
|
195
|
-
var normalized = [];
|
|
196
|
-
try {
|
|
197
|
-
for (var delta_1 = __values(delta), delta_1_1 = delta_1.next(); !delta_1_1.done; delta_1_1 = delta_1.next()) {
|
|
198
|
-
var element = delta_1_1.value;
|
|
199
|
-
if (typeof element.insert === 'string' && element.insert.length === 0) {
|
|
200
|
-
continue;
|
|
201
|
-
}
|
|
202
|
-
var prev = normalized[normalized.length - 1];
|
|
203
|
-
if (!prev || typeof prev.insert !== 'string' || typeof element.insert !== 'string') {
|
|
204
|
-
normalized.push(element);
|
|
205
|
-
continue;
|
|
206
|
-
}
|
|
207
|
-
var merge = prev.attributes === element.attributes ||
|
|
208
|
-
(!prev.attributes === !element.attributes &&
|
|
209
|
-
deepEquals((_b = prev.attributes) !== null && _b !== void 0 ? _b : {}, (_c = element.attributes) !== null && _c !== void 0 ? _c : {}));
|
|
210
|
-
if (merge) {
|
|
211
|
-
prev.insert += element.insert;
|
|
212
|
-
continue;
|
|
213
|
-
}
|
|
214
|
-
normalized.push(element);
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
218
|
-
finally {
|
|
219
|
-
try {
|
|
220
|
-
if (delta_1_1 && !delta_1_1.done && (_a = delta_1.return)) _a.call(delta_1);
|
|
221
|
-
}
|
|
222
|
-
finally { if (e_1) throw e_1.error; }
|
|
223
|
-
}
|
|
224
|
-
return normalized;
|
|
225
|
-
}
|
|
226
|
-
function yTextToInsertDelta(yText) {
|
|
227
|
-
return normalizeInsertDelta(yText.toDelta());
|
|
228
|
-
}
|
|
229
|
-
function getInsertLength(_a) {
|
|
230
|
-
var insert = _a.insert;
|
|
231
|
-
return typeof insert === 'string' ? insert.length : 1;
|
|
232
|
-
}
|
|
233
|
-
function getInsertDeltaLength(delta) {
|
|
234
|
-
return delta.reduce(function (curr, element) { return curr + getInsertLength(element); }, 0);
|
|
235
|
-
}
|
|
236
|
-
function sliceInsertDelta(delta, start, length) {
|
|
237
|
-
if (length < 1) {
|
|
238
|
-
return [];
|
|
239
|
-
}
|
|
240
|
-
var currentOffset = 0;
|
|
241
|
-
var sliced = [];
|
|
242
|
-
var end = start + length;
|
|
243
|
-
for (var i = 0; i < delta.length; i++) {
|
|
244
|
-
if (currentOffset >= end) {
|
|
245
|
-
break;
|
|
246
|
-
}
|
|
247
|
-
var element = delta[i];
|
|
248
|
-
var elementLength = getInsertLength(element);
|
|
249
|
-
if (currentOffset + elementLength <= start) {
|
|
250
|
-
currentOffset += elementLength;
|
|
251
|
-
continue;
|
|
252
|
-
}
|
|
253
|
-
if (typeof element.insert !== 'string') {
|
|
254
|
-
currentOffset += elementLength;
|
|
255
|
-
sliced.push(element);
|
|
256
|
-
continue;
|
|
257
|
-
}
|
|
258
|
-
var startOffset = Math.max(0, start - currentOffset);
|
|
259
|
-
var endOffset = Math.min(elementLength, elementLength - (currentOffset + elementLength - end));
|
|
260
|
-
sliced.push(__assign(__assign({}, element), { insert: element.insert.slice(startOffset, endOffset) }));
|
|
261
|
-
currentOffset += elementLength;
|
|
262
|
-
}
|
|
263
|
-
return sliced;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
function getProperties(node) {
|
|
267
|
-
return omit(node, (slate.Text.isText(node) ? 'text' : 'children'));
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
function yTextToSlateElement(yText) {
|
|
271
|
-
var delta = yTextToInsertDelta(yText);
|
|
272
|
-
var children = delta.length > 0 ? delta.map(deltaInsertToSlateNode) : [{ text: '' }];
|
|
273
|
-
return __assign(__assign({}, yText.getAttributes()), { children: children });
|
|
274
|
-
}
|
|
275
|
-
function deltaInsertToSlateNode(insert) {
|
|
276
|
-
if (typeof insert.insert === 'string') {
|
|
277
|
-
return __assign(__assign({}, insert.attributes), { text: insert.insert });
|
|
278
|
-
}
|
|
279
|
-
return yTextToSlateElement(insert.insert);
|
|
280
|
-
}
|
|
281
|
-
function slateNodesToInsertDelta(nodes) {
|
|
282
|
-
return nodes.map(function (node) {
|
|
283
|
-
if (slate.Text.isText(node)) {
|
|
284
|
-
return { insert: node.text, attributes: getProperties(node) };
|
|
285
|
-
}
|
|
286
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
287
|
-
return { insert: slateElementToYText(node) };
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
function slateElementToYText(_a) {
|
|
291
|
-
var children = _a.children, attributes = __rest(_a, ["children"]);
|
|
292
|
-
var yElement = new Y__namespace.XmlText();
|
|
293
|
-
Object.entries(attributes).forEach(function (_a) {
|
|
294
|
-
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
295
|
-
yElement.setAttribute(key, value);
|
|
296
|
-
});
|
|
297
|
-
yElement.applyDelta(slateNodesToInsertDelta(children), { sanitize: false });
|
|
298
|
-
return yElement;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function getSlateNodeYLength(node) {
|
|
302
|
-
if (!node) {
|
|
303
|
-
return 0;
|
|
304
|
-
}
|
|
305
|
-
return slate.Text.isText(node) ? node.text.length : 1;
|
|
306
|
-
}
|
|
307
|
-
function slatePathOffsetToYOffset(element, pathOffset) {
|
|
308
|
-
return element.children
|
|
309
|
-
.slice(0, pathOffset)
|
|
310
|
-
.reduce(function (yOffset, node) { return yOffset + getSlateNodeYLength(node); }, 0);
|
|
311
|
-
}
|
|
312
|
-
function getYTarget(yRoot, slateRoot, path) {
|
|
313
|
-
var _a;
|
|
314
|
-
if (path.length === 0) {
|
|
315
|
-
throw new Error('Path has to a have a length >= 1');
|
|
316
|
-
}
|
|
317
|
-
if (slate.Text.isText(slateRoot)) {
|
|
318
|
-
throw new Error('Cannot descent into slate text');
|
|
319
|
-
}
|
|
320
|
-
var _b = __read(path), pathOffset = _b[0], childPath = _b.slice(1);
|
|
321
|
-
var yOffset = slatePathOffsetToYOffset(slateRoot, pathOffset);
|
|
322
|
-
var targetNode = slateRoot.children[pathOffset];
|
|
323
|
-
var delta = yTextToInsertDelta(yRoot);
|
|
324
|
-
var targetLength = getSlateNodeYLength(targetNode);
|
|
325
|
-
var targetDelta = sliceInsertDelta(delta, yOffset, targetLength);
|
|
326
|
-
if (targetDelta.length > 1) {
|
|
327
|
-
throw new Error("Path doesn't match yText, yTarget spans multiple nodes");
|
|
328
|
-
}
|
|
329
|
-
var yTarget = (_a = targetDelta[0]) === null || _a === void 0 ? void 0 : _a.insert;
|
|
330
|
-
if (childPath.length > 0) {
|
|
331
|
-
if (!(yTarget instanceof Y__namespace.XmlText)) {
|
|
332
|
-
throw new Error("Path doesn't match yText, cannot descent into non-yText");
|
|
333
|
-
}
|
|
334
|
-
return getYTarget(yTarget, targetNode, childPath);
|
|
335
|
-
}
|
|
336
|
-
return {
|
|
337
|
-
yParent: yRoot,
|
|
338
|
-
textRange: { start: yOffset, end: yOffset + targetLength },
|
|
339
|
-
yTarget: yTarget instanceof Y__namespace.XmlText ? yTarget : undefined,
|
|
340
|
-
slateParent: slateRoot,
|
|
341
|
-
slateTarget: targetNode,
|
|
342
|
-
targetDelta: targetDelta,
|
|
343
|
-
};
|
|
344
|
-
}
|
|
345
|
-
function yOffsetToSlateOffsets(parent, yOffset, opts) {
|
|
346
|
-
if (opts === void 0) { opts = {}; }
|
|
347
|
-
var _a = opts.assoc, assoc = _a === void 0 ? 0 : _a, _b = opts.insert, insert = _b === void 0 ? false : _b;
|
|
348
|
-
var currentOffset = 0;
|
|
349
|
-
var lastNonEmptyPathOffset = 0;
|
|
350
|
-
for (var pathOffset = 0; pathOffset < parent.children.length; pathOffset++) {
|
|
351
|
-
var child_1 = parent.children[pathOffset];
|
|
352
|
-
var nodeLength = slate.Text.isText(child_1) ? child_1.text.length : 1;
|
|
353
|
-
if (nodeLength > 0) {
|
|
354
|
-
lastNonEmptyPathOffset = pathOffset;
|
|
355
|
-
}
|
|
356
|
-
var endOffset = currentOffset + nodeLength;
|
|
357
|
-
if (nodeLength > 0 && (assoc >= 0 ? endOffset > yOffset : endOffset >= yOffset)) {
|
|
358
|
-
return [pathOffset, yOffset - currentOffset];
|
|
359
|
-
}
|
|
360
|
-
currentOffset += nodeLength;
|
|
361
|
-
}
|
|
362
|
-
if (yOffset > currentOffset + (insert ? 1 : 0)) {
|
|
363
|
-
throw new Error('yOffset out of bounds');
|
|
364
|
-
}
|
|
365
|
-
if (insert) {
|
|
366
|
-
return [parent.children.length, 0];
|
|
367
|
-
}
|
|
368
|
-
var child = parent.children[lastNonEmptyPathOffset];
|
|
369
|
-
var textOffset = slate.Text.isText(child) ? child.text.length : 1;
|
|
370
|
-
return [lastNonEmptyPathOffset, textOffset];
|
|
371
|
-
}
|
|
372
|
-
function getSlatePath(sharedRoot, slateRoot, yText) {
|
|
373
|
-
var yNodePath = [yText];
|
|
374
|
-
while (yNodePath[0] !== sharedRoot) {
|
|
375
|
-
var yParent = yNodePath[0].parent;
|
|
376
|
-
if (!yParent) {
|
|
377
|
-
throw new Error("yText isn't a descendant of root element");
|
|
378
|
-
}
|
|
379
|
-
if (!(yParent instanceof Y__namespace.XmlText)) {
|
|
380
|
-
throw new Error('Unexpected y parent type');
|
|
381
|
-
}
|
|
382
|
-
yNodePath.unshift(yParent);
|
|
383
|
-
}
|
|
384
|
-
if (yNodePath.length < 2) {
|
|
385
|
-
return [];
|
|
386
|
-
}
|
|
387
|
-
var slateParent = slateRoot;
|
|
388
|
-
return yNodePath.reduce(function (path, yParent, idx) {
|
|
389
|
-
var e_1, _a;
|
|
390
|
-
var yChild = yNodePath[idx + 1];
|
|
391
|
-
if (!yChild) {
|
|
392
|
-
return path;
|
|
393
|
-
}
|
|
394
|
-
var yOffset = 0;
|
|
395
|
-
var currentDelta = yTextToInsertDelta(yParent);
|
|
396
|
-
try {
|
|
397
|
-
for (var currentDelta_1 = __values(currentDelta), currentDelta_1_1 = currentDelta_1.next(); !currentDelta_1_1.done; currentDelta_1_1 = currentDelta_1.next()) {
|
|
398
|
-
var element = currentDelta_1_1.value;
|
|
399
|
-
if (element.insert === yChild) {
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
yOffset += typeof element.insert === 'string' ? element.insert.length : 1;
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
406
|
-
finally {
|
|
407
|
-
try {
|
|
408
|
-
if (currentDelta_1_1 && !currentDelta_1_1.done && (_a = currentDelta_1.return)) _a.call(currentDelta_1);
|
|
409
|
-
}
|
|
410
|
-
finally { if (e_1) throw e_1.error; }
|
|
411
|
-
}
|
|
412
|
-
if (slate.Text.isText(slateParent)) {
|
|
413
|
-
throw new Error('Cannot descent into slate text');
|
|
414
|
-
}
|
|
415
|
-
var _b = __read(yOffsetToSlateOffsets(slateParent, yOffset), 1), pathOffset = _b[0];
|
|
416
|
-
slateParent = slateParent.children[pathOffset];
|
|
417
|
-
return path.concat(pathOffset);
|
|
418
|
-
}, []);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
function applyDelta(node, slatePath, delta) {
|
|
422
|
-
var ops = [];
|
|
423
|
-
var yOffset = delta.reduce(function (length, change) {
|
|
424
|
-
if ('retain' in change) {
|
|
425
|
-
return length + change.retain;
|
|
426
|
-
}
|
|
427
|
-
if ('delete' in change) {
|
|
428
|
-
return length + change.delete;
|
|
429
|
-
}
|
|
430
|
-
return length;
|
|
431
|
-
}, 0);
|
|
432
|
-
// Apply changes in reverse order to avoid path changes.
|
|
433
|
-
delta.reverse().forEach(function (change) {
|
|
434
|
-
var _a;
|
|
435
|
-
if ('attributes' in change && 'retain' in change) {
|
|
436
|
-
var _b = __read(yOffsetToSlateOffsets(node, yOffset - change.retain), 2), startPathOffset = _b[0], startTextOffset = _b[1];
|
|
437
|
-
var _c = __read(yOffsetToSlateOffsets(node, yOffset, { assoc: -1 }), 2), endPathOffset = _c[0], endTextOffset = _c[1];
|
|
438
|
-
for (var pathOffset = endPathOffset; pathOffset >= startPathOffset; pathOffset--) {
|
|
439
|
-
var child = node.children[pathOffset];
|
|
440
|
-
var childPath = __spreadArray(__spreadArray([], __read(slatePath)), [pathOffset]);
|
|
441
|
-
if (!slate.Text.isText(child)) {
|
|
442
|
-
// Ignore attribute updates on non-text nodes (which are backed by Y.XmlText)
|
|
443
|
-
// to be consistent with deltaInsertToSlateNode. Y.XmlText attributes don't show
|
|
444
|
-
// up in deltas but in key changes (YEvent.changes.keys).
|
|
445
|
-
continue;
|
|
446
|
-
}
|
|
447
|
-
var newProperties = change.attributes;
|
|
448
|
-
var properties = pick.apply(void 0, __spreadArray([node], __read(Object.keys(change.attributes))));
|
|
449
|
-
if (pathOffset === startPathOffset || pathOffset === endPathOffset) {
|
|
450
|
-
var start = pathOffset === startPathOffset ? startTextOffset : 0;
|
|
451
|
-
var end = pathOffset === endPathOffset ? endTextOffset : child.text.length;
|
|
452
|
-
if (end !== child.text.length) {
|
|
453
|
-
ops.push({
|
|
454
|
-
type: 'split_node',
|
|
455
|
-
path: childPath,
|
|
456
|
-
position: end,
|
|
457
|
-
properties: getProperties(child),
|
|
458
|
-
});
|
|
459
|
-
}
|
|
460
|
-
if (start !== 0) {
|
|
461
|
-
ops.push({
|
|
462
|
-
type: 'split_node',
|
|
463
|
-
path: childPath,
|
|
464
|
-
position: start,
|
|
465
|
-
properties: omitNullEntries(__assign(__assign({}, getProperties(child)), newProperties)),
|
|
466
|
-
});
|
|
467
|
-
continue;
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
ops.push({
|
|
471
|
-
type: 'set_node',
|
|
472
|
-
newProperties: newProperties,
|
|
473
|
-
path: childPath,
|
|
474
|
-
properties: properties,
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
}
|
|
478
|
-
if ('retain' in change) {
|
|
479
|
-
yOffset -= change.retain;
|
|
480
|
-
}
|
|
481
|
-
if ('delete' in change) {
|
|
482
|
-
var _d = __read(yOffsetToSlateOffsets(node, yOffset - change.delete), 2), startPathOffset = _d[0], startTextOffset = _d[1];
|
|
483
|
-
var _e = __read(yOffsetToSlateOffsets(node, yOffset, { assoc: -1 }), 2), endPathOffset = _e[0], endTextOffset = _e[1];
|
|
484
|
-
for (var pathOffset = endTextOffset === 0 ? endPathOffset - 1 : endPathOffset; pathOffset >= startPathOffset; pathOffset--) {
|
|
485
|
-
var child = node.children[pathOffset];
|
|
486
|
-
var childPath = __spreadArray(__spreadArray([], __read(slatePath)), [pathOffset]);
|
|
487
|
-
if (slate.Text.isText(child) &&
|
|
488
|
-
(pathOffset === startPathOffset || pathOffset === endPathOffset)) {
|
|
489
|
-
var start = pathOffset === startPathOffset ? startTextOffset : 0;
|
|
490
|
-
var end = pathOffset === endPathOffset ? endTextOffset : child.text.length;
|
|
491
|
-
ops.push({
|
|
492
|
-
type: 'remove_text',
|
|
493
|
-
offset: start,
|
|
494
|
-
text: child.text.slice(start, end),
|
|
495
|
-
path: childPath,
|
|
496
|
-
});
|
|
497
|
-
yOffset -= end - start;
|
|
498
|
-
continue;
|
|
499
|
-
}
|
|
500
|
-
ops.push({
|
|
501
|
-
type: 'remove_node',
|
|
502
|
-
node: child,
|
|
503
|
-
path: childPath,
|
|
504
|
-
});
|
|
505
|
-
yOffset -= getSlateNodeYLength(child);
|
|
506
|
-
}
|
|
507
|
-
return;
|
|
508
|
-
}
|
|
509
|
-
if ('insert' in change) {
|
|
510
|
-
var _f = __read(yOffsetToSlateOffsets(node, yOffset, {
|
|
511
|
-
insert: true,
|
|
512
|
-
}), 2), pathOffset = _f[0], textOffset = _f[1];
|
|
513
|
-
var child = node.children[pathOffset];
|
|
514
|
-
var childPath = __spreadArray(__spreadArray([], __read(slatePath)), [pathOffset]);
|
|
515
|
-
if (slate.Text.isText(child)) {
|
|
516
|
-
var lastOp = ops[ops.length - 1];
|
|
517
|
-
/**
|
|
518
|
-
* The props that exist at the current path
|
|
519
|
-
* Since we're not actually using slate to update the node
|
|
520
|
-
* this is a simulation
|
|
521
|
-
*/
|
|
522
|
-
var currentProps = lastOp != null && lastOp.type === 'insert_node' ? lastOp.node : getProperties(child);
|
|
523
|
-
var lastPath = [];
|
|
524
|
-
if (lastOp != null &&
|
|
525
|
-
(lastOp.type === 'insert_node' ||
|
|
526
|
-
lastOp.type === 'insert_text' ||
|
|
527
|
-
lastOp.type === 'split_node' ||
|
|
528
|
-
lastOp.type === 'set_node')) {
|
|
529
|
-
lastPath = lastOp.path;
|
|
530
|
-
}
|
|
531
|
-
/**
|
|
532
|
-
* If the insert is a string and the attributes are the same as the
|
|
533
|
-
* props at the current path, we can just insert a text node
|
|
534
|
-
*/
|
|
535
|
-
if (typeof change.insert === 'string' &&
|
|
536
|
-
deepEquals((_a = change.attributes) !== null && _a !== void 0 ? _a : {}, currentProps) &&
|
|
537
|
-
slate.Path.equals(childPath, lastPath)) {
|
|
538
|
-
return ops.push({
|
|
539
|
-
type: 'insert_text',
|
|
540
|
-
offset: textOffset,
|
|
541
|
-
text: change.insert,
|
|
542
|
-
path: childPath,
|
|
543
|
-
});
|
|
544
|
-
}
|
|
545
|
-
var toInsert = deltaInsertToSlateNode(change);
|
|
546
|
-
if (textOffset === 0) {
|
|
547
|
-
return ops.push({
|
|
548
|
-
type: 'insert_node',
|
|
549
|
-
path: childPath,
|
|
550
|
-
node: toInsert,
|
|
551
|
-
});
|
|
552
|
-
}
|
|
553
|
-
if (textOffset < child.text.length) {
|
|
554
|
-
ops.push({
|
|
555
|
-
type: 'split_node',
|
|
556
|
-
path: childPath,
|
|
557
|
-
position: textOffset,
|
|
558
|
-
properties: getProperties(child),
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
return ops.push({
|
|
562
|
-
type: 'insert_node',
|
|
563
|
-
path: slate.Path.next(childPath),
|
|
564
|
-
node: toInsert,
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
return ops.push({
|
|
568
|
-
type: 'insert_node',
|
|
569
|
-
path: childPath,
|
|
570
|
-
node: deltaInsertToSlateNode(change),
|
|
571
|
-
});
|
|
572
|
-
}
|
|
573
|
-
});
|
|
574
|
-
return ops;
|
|
575
|
-
}
|
|
576
|
-
function translateYTextEvent(sharedRoot, editor, event) {
|
|
577
|
-
var target = event.target, changes = event.changes;
|
|
578
|
-
var delta = event.delta;
|
|
579
|
-
if (!(target instanceof Y__namespace.XmlText)) {
|
|
580
|
-
throw new Error('Unexpected target node type');
|
|
581
|
-
}
|
|
582
|
-
var ops = [];
|
|
583
|
-
var slatePath = getSlatePath(sharedRoot, editor, target);
|
|
584
|
-
var targetElement = slate.Node.get(editor, slatePath);
|
|
585
|
-
if (slate.Text.isText(targetElement)) {
|
|
586
|
-
throw new Error('Cannot apply yTextEvent to text node');
|
|
587
|
-
}
|
|
588
|
-
var keyChanges = Array.from(changes.keys.entries());
|
|
589
|
-
if (slatePath.length > 0 && keyChanges.length > 0) {
|
|
590
|
-
var newProperties = Object.fromEntries(keyChanges.map(function (_a) {
|
|
591
|
-
var _b = __read(_a, 2), key = _b[0], info = _b[1];
|
|
592
|
-
return [
|
|
593
|
-
key,
|
|
594
|
-
info.action === 'delete' ? null : target.getAttribute(key),
|
|
595
|
-
];
|
|
596
|
-
}));
|
|
597
|
-
var properties = Object.fromEntries(keyChanges.map(function (_a) {
|
|
598
|
-
var _b = __read(_a, 1), key = _b[0];
|
|
599
|
-
return [key, targetElement[key]];
|
|
600
|
-
}));
|
|
601
|
-
ops.push({ type: 'set_node', newProperties: newProperties, properties: properties, path: slatePath });
|
|
602
|
-
}
|
|
603
|
-
if (delta.length > 0) {
|
|
604
|
-
ops.push.apply(ops, __spreadArray([], __read(applyDelta(targetElement, slatePath, delta))));
|
|
605
|
-
}
|
|
606
|
-
return ops;
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
/**
|
|
610
|
-
* Translate a yjs event into slate operations. The editor state has to match the
|
|
611
|
-
* yText state before the event occurred.
|
|
612
|
-
*
|
|
613
|
-
* @param sharedType
|
|
614
|
-
* @param op
|
|
615
|
-
*/
|
|
616
|
-
function translateYjsEvent(sharedRoot, editor, event) {
|
|
617
|
-
if (event instanceof Y__namespace.YTextEvent) {
|
|
618
|
-
return translateYTextEvent(sharedRoot, editor, event);
|
|
619
|
-
}
|
|
620
|
-
throw new Error('Unexpected Y event type');
|
|
621
|
-
}
|
|
622
|
-
/**
|
|
623
|
-
* Translates yjs events into slate operations and applies them to the editor. The
|
|
624
|
-
* editor state has to match the yText state before the events occurred.
|
|
625
|
-
*
|
|
626
|
-
* @param sharedRoot
|
|
627
|
-
* @param editor
|
|
628
|
-
* @param events
|
|
629
|
-
*/
|
|
630
|
-
function applyYjsEvents(sharedRoot, editor, events) {
|
|
631
|
-
slate.Editor.withoutNormalizing(editor, function () {
|
|
632
|
-
events.forEach(function (event) {
|
|
633
|
-
translateYjsEvent(sharedRoot, editor, event).forEach(function (op) {
|
|
634
|
-
editor.apply(op);
|
|
635
|
-
});
|
|
636
|
-
});
|
|
637
|
-
});
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
function insertNode(sharedRoot, slateRoot, op) {
|
|
641
|
-
var _a = getYTarget(sharedRoot, slateRoot, op.path), yParent = _a.yParent, textRange = _a.textRange;
|
|
642
|
-
if (slate.Text.isText(op.node)) {
|
|
643
|
-
return yParent.insert(textRange.start, op.node.text, getProperties(op.node));
|
|
644
|
-
}
|
|
645
|
-
yParent.insertEmbed(textRange.start, slateElementToYText(op.node));
|
|
646
|
-
}
|
|
647
|
-
|
|
648
|
-
function cloneInsertDeltaDeep(delta) {
|
|
649
|
-
return delta.map(function (element) {
|
|
650
|
-
if (typeof element.insert === 'string') {
|
|
651
|
-
return element;
|
|
652
|
-
}
|
|
653
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
654
|
-
return __assign(__assign({}, element), { insert: cloneDeep(element.insert) });
|
|
655
|
-
});
|
|
656
|
-
}
|
|
657
|
-
function cloneDeep(yText) {
|
|
658
|
-
var clone = new Y__namespace.XmlText();
|
|
659
|
-
var attributes = yText.getAttributes();
|
|
660
|
-
Object.entries(attributes).forEach(function (_a) {
|
|
661
|
-
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
662
|
-
clone.setAttribute(key, value);
|
|
663
|
-
});
|
|
664
|
-
clone.applyDelta(cloneInsertDeltaDeep(yTextToInsertDelta(yText)), {
|
|
665
|
-
sanitize: false,
|
|
666
|
-
});
|
|
667
|
-
return clone;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
671
|
-
function assertDocumentAttachment(sharedType) {
|
|
672
|
-
if (!sharedType.doc) {
|
|
673
|
-
throw new Error("shared type isn't attached to a document");
|
|
674
|
-
}
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
var STORED_POSITION_PREFIX = '__slateYjsStoredPosition_';
|
|
678
|
-
function slatePointToRelativePosition(sharedRoot, slateRoot, point) {
|
|
679
|
-
var _a = getYTarget(sharedRoot, slateRoot, point.path), yTarget = _a.yTarget, yParent = _a.yParent, textRange = _a.textRange;
|
|
680
|
-
if (yTarget) {
|
|
681
|
-
throw new Error('Slate point points to a non-text element inside sharedRoot');
|
|
682
|
-
}
|
|
683
|
-
var index = textRange.start + point.offset;
|
|
684
|
-
return Y__namespace.createRelativePositionFromTypeIndex(yParent, index, index === textRange.end ? -1 : 0);
|
|
685
|
-
}
|
|
686
|
-
function absolutePositionToSlatePoint(sharedRoot, slateRoot, _a) {
|
|
687
|
-
var type = _a.type, index = _a.index, assoc = _a.assoc;
|
|
688
|
-
if (!(type instanceof Y__namespace.XmlText)) {
|
|
689
|
-
throw new Error('Absolute position points to a non-XMLText');
|
|
690
|
-
}
|
|
691
|
-
var parentPath = getSlatePath(sharedRoot, slateRoot, type);
|
|
692
|
-
var parent = slate.Node.get(slateRoot, parentPath);
|
|
693
|
-
if (slate.Text.isText(parent)) {
|
|
694
|
-
throw new Error("Absolute position doesn't match slateRoot, cannot descent into text");
|
|
695
|
-
}
|
|
696
|
-
var _b = __read(yOffsetToSlateOffsets(parent, index, {
|
|
697
|
-
assoc: assoc,
|
|
698
|
-
}), 2), pathOffset = _b[0], textOffset = _b[1];
|
|
699
|
-
var target = parent.children[pathOffset];
|
|
700
|
-
if (!slate.Text.isText(target)) {
|
|
701
|
-
return null;
|
|
702
|
-
}
|
|
703
|
-
return { path: __spreadArray(__spreadArray([], __read(parentPath)), [pathOffset]), offset: textOffset };
|
|
704
|
-
}
|
|
705
|
-
function relativePositionToSlatePoint(sharedRoot, slateRoot, pos) {
|
|
706
|
-
if (!sharedRoot.doc) {
|
|
707
|
-
throw new Error("sharedRoot isn't attach to a yDoc");
|
|
708
|
-
}
|
|
709
|
-
var absPos = Y__namespace.createAbsolutePositionFromRelativePosition(pos, sharedRoot.doc);
|
|
710
|
-
return absPos && absolutePositionToSlatePoint(sharedRoot, slateRoot, absPos);
|
|
711
|
-
}
|
|
712
|
-
function getStoredPosition(sharedRoot, key) {
|
|
713
|
-
var rawPosition = sharedRoot.getAttribute(STORED_POSITION_PREFIX + key);
|
|
714
|
-
if (!rawPosition) {
|
|
715
|
-
return null;
|
|
716
|
-
}
|
|
717
|
-
return Y__namespace.decodeRelativePosition(rawPosition);
|
|
718
|
-
}
|
|
719
|
-
function getStoredPositions(sharedRoot) {
|
|
720
|
-
return Object.fromEntries(Object.entries(sharedRoot.getAttributes())
|
|
721
|
-
.filter(function (_a) {
|
|
722
|
-
var _b = __read(_a, 1), key = _b[0];
|
|
723
|
-
return key.startsWith(STORED_POSITION_PREFIX);
|
|
724
|
-
})
|
|
725
|
-
.map(function (_a) {
|
|
726
|
-
var _b = __read(_a, 2), key = _b[0], position = _b[1];
|
|
727
|
-
return [
|
|
728
|
-
key.slice(STORED_POSITION_PREFIX.length),
|
|
729
|
-
Y__namespace.createRelativePositionFromJSON(position),
|
|
730
|
-
];
|
|
731
|
-
}));
|
|
732
|
-
}
|
|
733
|
-
function getStoredPositionsAbsolute(sharedRoot) {
|
|
734
|
-
assertDocumentAttachment(sharedRoot);
|
|
735
|
-
return Object.fromEntries(Object.entries(sharedRoot.getAttributes())
|
|
736
|
-
.filter(function (_a) {
|
|
737
|
-
var _b = __read(_a, 1), key = _b[0];
|
|
738
|
-
return key.startsWith(STORED_POSITION_PREFIX);
|
|
739
|
-
})
|
|
740
|
-
.map(function (_a) {
|
|
741
|
-
var _b = __read(_a, 2), key = _b[0], position = _b[1];
|
|
742
|
-
return [
|
|
743
|
-
key.slice(STORED_POSITION_PREFIX.length),
|
|
744
|
-
Y__namespace.createAbsolutePositionFromRelativePosition(Y__namespace.decodeRelativePosition(position), sharedRoot.doc),
|
|
745
|
-
];
|
|
746
|
-
})
|
|
747
|
-
.filter(function (_a) {
|
|
748
|
-
var _b = __read(_a, 2), position = _b[1];
|
|
749
|
-
return position;
|
|
750
|
-
}));
|
|
751
|
-
}
|
|
752
|
-
function removeStoredPosition(sharedRoot, key) {
|
|
753
|
-
sharedRoot.removeAttribute(STORED_POSITION_PREFIX + key);
|
|
754
|
-
}
|
|
755
|
-
function setStoredPosition(sharedRoot, key, position) {
|
|
756
|
-
sharedRoot.setAttribute(STORED_POSITION_PREFIX + key, Y__namespace.encodeRelativePosition(position));
|
|
757
|
-
}
|
|
758
|
-
function getAbsolutePositionsInTextRange(absolutePositions, yTarget, textRange) {
|
|
759
|
-
return Object.fromEntries(Object.entries(absolutePositions).filter(function (_a) {
|
|
760
|
-
var _b = __read(_a, 2), position = _b[1];
|
|
761
|
-
if (position.type !== yTarget) {
|
|
762
|
-
return false;
|
|
763
|
-
}
|
|
764
|
-
if (!textRange) {
|
|
765
|
-
return true;
|
|
766
|
-
}
|
|
767
|
-
return position.assoc >= 0
|
|
768
|
-
? position.index >= textRange.start && position.index < textRange.end
|
|
769
|
-
: position.index > textRange.start && position.index >= textRange.end;
|
|
770
|
-
}));
|
|
771
|
-
}
|
|
772
|
-
function getAbsolutePositionsInYText(absolutePositions, yText, parentPath) {
|
|
773
|
-
var _a;
|
|
774
|
-
if (parentPath === void 0) { parentPath = ''; }
|
|
775
|
-
var positions = (_a = {},
|
|
776
|
-
_a[parentPath] = getAbsolutePositionsInTextRange(absolutePositions, yText),
|
|
777
|
-
_a);
|
|
778
|
-
var insertDelta = yTextToInsertDelta(yText);
|
|
779
|
-
insertDelta.forEach(function (_a, i) {
|
|
780
|
-
var insert = _a.insert;
|
|
781
|
-
if (insert instanceof Y__namespace.XmlText) {
|
|
782
|
-
Object.assign(positions, getAbsolutePositionsInYText(absolutePositions, insert, parentPath ? parentPath + "." + i : i.toString()));
|
|
783
|
-
}
|
|
784
|
-
});
|
|
785
|
-
return positions;
|
|
786
|
-
}
|
|
787
|
-
function getStoredPositionsInDeltaAbsolute(sharedRoot, yText, delta, deltaOffset) {
|
|
788
|
-
if (deltaOffset === void 0) { deltaOffset = 0; }
|
|
789
|
-
var absolutePositions = getStoredPositionsAbsolute(sharedRoot);
|
|
790
|
-
var positions = {
|
|
791
|
-
'': getAbsolutePositionsInTextRange(absolutePositions, yText, {
|
|
792
|
-
start: deltaOffset,
|
|
793
|
-
end: deltaOffset + getInsertDeltaLength(delta),
|
|
794
|
-
}),
|
|
795
|
-
};
|
|
796
|
-
delta.forEach(function (_a, i) {
|
|
797
|
-
var insert = _a.insert;
|
|
798
|
-
if (insert instanceof Y__namespace.XmlText) {
|
|
799
|
-
Object.assign(positions, getAbsolutePositionsInYText(absolutePositions, insert, i.toString()));
|
|
800
|
-
}
|
|
801
|
-
});
|
|
802
|
-
return positions;
|
|
803
|
-
}
|
|
804
|
-
function restoreStoredPositionsWithDeltaAbsolute(sharedRoot, yText, absolutePositions, delta, newDeltaOffset, previousDeltaOffset, path) {
|
|
805
|
-
if (newDeltaOffset === void 0) { newDeltaOffset = 0; }
|
|
806
|
-
if (previousDeltaOffset === void 0) { previousDeltaOffset = 0; }
|
|
807
|
-
if (path === void 0) { path = ''; }
|
|
808
|
-
var toRestore = absolutePositions[path];
|
|
809
|
-
if (toRestore) {
|
|
810
|
-
Object.entries(toRestore).forEach(function (_a) {
|
|
811
|
-
var _b = __read(_a, 2), key = _b[0], position = _b[1];
|
|
812
|
-
setStoredPosition(sharedRoot, key, Y__namespace.createRelativePositionFromTypeIndex(yText, position.index - previousDeltaOffset + newDeltaOffset, position.assoc));
|
|
813
|
-
});
|
|
814
|
-
}
|
|
815
|
-
delta.forEach(function (_a, i) {
|
|
816
|
-
var insert = _a.insert;
|
|
817
|
-
if (insert instanceof Y__namespace.XmlText) {
|
|
818
|
-
restoreStoredPositionsWithDeltaAbsolute(sharedRoot, insert, absolutePositions, yTextToInsertDelta(insert), 0, 0, path ? path + "." + i : i.toString());
|
|
819
|
-
}
|
|
820
|
-
});
|
|
821
|
-
}
|
|
822
|
-
function slateRangeToRelativeRange(sharedRoot, slateRoot, range) {
|
|
823
|
-
return {
|
|
824
|
-
anchor: slatePointToRelativePosition(sharedRoot, slateRoot, range.anchor),
|
|
825
|
-
focus: slatePointToRelativePosition(sharedRoot, slateRoot, range.focus),
|
|
826
|
-
};
|
|
827
|
-
}
|
|
828
|
-
function relativeRangeToSlateRange(sharedRoot, slateRoot, range) {
|
|
829
|
-
var anchor = relativePositionToSlatePoint(sharedRoot, slateRoot, range.anchor);
|
|
830
|
-
if (!anchor) {
|
|
831
|
-
return null;
|
|
832
|
-
}
|
|
833
|
-
var focus = relativePositionToSlatePoint(sharedRoot, slateRoot, range.focus);
|
|
834
|
-
if (!focus) {
|
|
835
|
-
return null;
|
|
836
|
-
}
|
|
837
|
-
return { anchor: anchor, focus: focus };
|
|
838
|
-
}
|
|
839
|
-
|
|
840
|
-
function mergeNode(sharedRoot, slateRoot, op) {
|
|
841
|
-
var target = getYTarget(sharedRoot, slateRoot, op.path);
|
|
842
|
-
var prev = getYTarget(target.yParent, target.slateParent, slate.Path.previous(op.path.slice(-1)));
|
|
843
|
-
if (!target.yTarget !== !prev.yTarget) {
|
|
844
|
-
throw new Error('Cannot merge y text with y element');
|
|
845
|
-
}
|
|
846
|
-
if (!prev.yTarget || !target.yTarget) {
|
|
847
|
-
var parent_1 = target.yParent, textRange = target.textRange, slateTarget = target.slateTarget;
|
|
848
|
-
if (!slateTarget) {
|
|
849
|
-
throw new Error('Expected Slate target node for merge op.');
|
|
850
|
-
}
|
|
851
|
-
var prevSibling = slate.Node.get(slateRoot, slate.Path.previous(op.path));
|
|
852
|
-
if (!slate.Text.isText(prevSibling)) {
|
|
853
|
-
throw new Error('Path points to Y.Text but not a Slate text node.');
|
|
854
|
-
}
|
|
855
|
-
var targetProps = getProperties(slateTarget);
|
|
856
|
-
var prevSiblingProps_1 = getProperties(prevSibling);
|
|
857
|
-
var unsetProps = Object.keys(targetProps).reduce(function (acc, key) {
|
|
858
|
-
var _a;
|
|
859
|
-
var prevSiblingHasProp = key in prevSiblingProps_1;
|
|
860
|
-
return prevSiblingHasProp ? acc : __assign(__assign({}, acc), (_a = {}, _a[key] = null, _a));
|
|
861
|
-
}, {});
|
|
862
|
-
return parent_1.format(textRange.start, textRange.end - textRange.start, __assign(__assign({}, unsetProps), prevSiblingProps_1));
|
|
863
|
-
}
|
|
864
|
-
var deltaApplyYOffset = prev.yTarget.length;
|
|
865
|
-
var targetDelta = yTextToInsertDelta(target.yTarget);
|
|
866
|
-
var clonedDelta = cloneInsertDeltaDeep(targetDelta);
|
|
867
|
-
var storedPositions = getStoredPositionsInDeltaAbsolute(sharedRoot, target.yTarget, targetDelta, deltaApplyYOffset);
|
|
868
|
-
var applyDelta = __spreadArray([{ retain: deltaApplyYOffset }], __read(clonedDelta));
|
|
869
|
-
prev.yTarget.applyDelta(applyDelta, {
|
|
870
|
-
sanitize: false,
|
|
871
|
-
});
|
|
872
|
-
target.yParent.delete(target.textRange.start, target.textRange.end - target.textRange.start);
|
|
873
|
-
restoreStoredPositionsWithDeltaAbsolute(sharedRoot, prev.yTarget, storedPositions, clonedDelta, deltaApplyYOffset);
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
function moveNode(sharedRoot, slateRoot, op) {
|
|
877
|
-
var newParentPath = slate.Path.parent(op.newPath);
|
|
878
|
-
var newPathOffset = op.newPath[op.newPath.length - 1];
|
|
879
|
-
var parent = slate.Node.get(slateRoot, newParentPath);
|
|
880
|
-
if (slate.Text.isText(parent)) {
|
|
881
|
-
throw new Error('Cannot move slate node into text element');
|
|
882
|
-
}
|
|
883
|
-
var normalizedNewPath = __spreadArray(__spreadArray([], __read(newParentPath)), [Math.min(newPathOffset, parent.children.length)]);
|
|
884
|
-
var origin = getYTarget(sharedRoot, slateRoot, op.path);
|
|
885
|
-
var target = getYTarget(sharedRoot, slateRoot, normalizedNewPath);
|
|
886
|
-
var insertDelta = cloneInsertDeltaDeep(origin.targetDelta);
|
|
887
|
-
var storedPositions = getStoredPositionsInDeltaAbsolute(sharedRoot, origin.yParent, origin.targetDelta);
|
|
888
|
-
origin.yParent.delete(origin.textRange.start, origin.textRange.end - origin.textRange.start);
|
|
889
|
-
var targetLength = getInsertDeltaLength(yTextToInsertDelta(target.yParent));
|
|
890
|
-
var deltaApplyYOffset = Math.min(target.textRange.start, targetLength);
|
|
891
|
-
var applyDelta = __spreadArray([{ retain: deltaApplyYOffset }], __read(insertDelta));
|
|
892
|
-
target.yParent.applyDelta(applyDelta, { sanitize: false });
|
|
893
|
-
restoreStoredPositionsWithDeltaAbsolute(sharedRoot, target.yParent, storedPositions, insertDelta, deltaApplyYOffset, origin.textRange.start);
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
function removeNode(sharedRoot, slateRoot, op) {
|
|
897
|
-
var _a = getYTarget(sharedRoot, slateRoot, op.path), parent = _a.yParent, textRange = _a.textRange;
|
|
898
|
-
parent.delete(textRange.start, textRange.end - textRange.start);
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
function setNode(sharedRoot, slateRoot, op) {
|
|
902
|
-
var _a = getYTarget(sharedRoot, slateRoot, op.path), yTarget = _a.yTarget, textRange = _a.textRange, yParent = _a.yParent;
|
|
903
|
-
if (yTarget) {
|
|
904
|
-
Object.entries(op.newProperties).forEach(function (_a) {
|
|
905
|
-
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
906
|
-
if (value === null) {
|
|
907
|
-
return yTarget.removeAttribute(key);
|
|
908
|
-
}
|
|
909
|
-
yTarget.setAttribute(key, value);
|
|
910
|
-
});
|
|
911
|
-
return Object.entries(op.properties).forEach(function (_a) {
|
|
912
|
-
var _b = __read(_a, 1), key = _b[0];
|
|
913
|
-
if (!Object.prototype.hasOwnProperty.call(op.newProperties, key)) {
|
|
914
|
-
yTarget.removeAttribute(key);
|
|
915
|
-
}
|
|
916
|
-
});
|
|
917
|
-
}
|
|
918
|
-
var unset = Object.fromEntries(Object.keys(op.properties).map(function (key) { return [key, null]; }));
|
|
919
|
-
var newProperties = __assign(__assign({}, unset), op.newProperties);
|
|
920
|
-
yParent.format(textRange.start, textRange.end - textRange.start, newProperties);
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
function splitNode(sharedRoot, slateRoot, op) {
|
|
924
|
-
var target = getYTarget(sharedRoot, slateRoot, op.path);
|
|
925
|
-
if (!target.slateTarget) {
|
|
926
|
-
throw new Error('Y target without corresponding slate node');
|
|
927
|
-
}
|
|
928
|
-
if (!target.yTarget) {
|
|
929
|
-
if (!slate.Text.isText(target.slateTarget)) {
|
|
930
|
-
throw new Error('Mismatch node type between y target and slate node');
|
|
931
|
-
}
|
|
932
|
-
var unset_1 = {};
|
|
933
|
-
target.targetDelta.forEach(function (element) {
|
|
934
|
-
if (element.attributes) {
|
|
935
|
-
Object.keys(element.attributes).forEach(function (key) {
|
|
936
|
-
unset_1[key] = null;
|
|
937
|
-
});
|
|
938
|
-
}
|
|
939
|
-
});
|
|
940
|
-
return target.yParent.format(target.textRange.start, target.textRange.end - target.textRange.start, __assign(__assign({}, unset_1), op.properties));
|
|
941
|
-
}
|
|
942
|
-
if (slate.Text.isText(target.slateTarget)) {
|
|
943
|
-
throw new Error('Mismatch node type between y target and slate node');
|
|
944
|
-
}
|
|
945
|
-
var splitTarget = getYTarget(target.yTarget, target.slateTarget, [op.position]);
|
|
946
|
-
var ySplitOffset = target.slateTarget.children
|
|
947
|
-
.slice(0, op.position)
|
|
948
|
-
.reduce(function (length, child) { return length + getSlateNodeYLength(child); }, 0);
|
|
949
|
-
var length = target.slateTarget.children.reduce(function (current, child) { return current + getSlateNodeYLength(child); }, 0);
|
|
950
|
-
var splitDelta = sliceInsertDelta(yTextToInsertDelta(target.yTarget), ySplitOffset, length - ySplitOffset);
|
|
951
|
-
var clonedDelta = cloneInsertDeltaDeep(splitDelta);
|
|
952
|
-
var storedPositions = getStoredPositionsInDeltaAbsolute(sharedRoot, target.yTarget, splitDelta, ySplitOffset);
|
|
953
|
-
var toInsert = new Y__namespace.XmlText();
|
|
954
|
-
toInsert.applyDelta(clonedDelta, {
|
|
955
|
-
sanitize: false,
|
|
956
|
-
});
|
|
957
|
-
Object.entries(op.properties).forEach(function (_a) {
|
|
958
|
-
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
959
|
-
toInsert.setAttribute(key, value);
|
|
960
|
-
});
|
|
961
|
-
target.yTarget.delete(splitTarget.textRange.start, target.yTarget.length - splitTarget.textRange.start);
|
|
962
|
-
target.yParent.insertEmbed(target.textRange.end, toInsert);
|
|
963
|
-
restoreStoredPositionsWithDeltaAbsolute(sharedRoot, toInsert, storedPositions, clonedDelta, 0, ySplitOffset);
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
var NODE_MAPPER = {
|
|
967
|
-
insert_node: insertNode,
|
|
968
|
-
remove_node: removeNode,
|
|
969
|
-
set_node: setNode,
|
|
970
|
-
merge_node: mergeNode,
|
|
971
|
-
move_node: moveNode,
|
|
972
|
-
split_node: splitNode,
|
|
973
|
-
};
|
|
974
|
-
|
|
975
|
-
function insertText(sharedRoot, slateRoot, op) {
|
|
976
|
-
var _a = getYTarget(sharedRoot, slateRoot, op.path), target = _a.yParent, textRange = _a.textRange;
|
|
977
|
-
var targetNode = slate.Node.get(slateRoot, op.path);
|
|
978
|
-
if (!slate.Text.isText(targetNode)) {
|
|
979
|
-
throw new Error('Cannot insert text into non-text node');
|
|
980
|
-
}
|
|
981
|
-
target.insert(textRange.start + op.offset, op.text, getProperties(targetNode));
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
function removeText(sharedRoot, slateRoot, op) {
|
|
985
|
-
var _a = getYTarget(sharedRoot, slateRoot, op.path), target = _a.yParent, textRange = _a.textRange;
|
|
986
|
-
target.delete(textRange.start + op.offset, op.text.length);
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
var TEXT_MAPPER = {
|
|
990
|
-
insert_text: insertText,
|
|
991
|
-
remove_text: removeText,
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
995
|
-
var NOOP = function () { };
|
|
996
|
-
var opMappers = __assign(__assign(__assign({}, TEXT_MAPPER), NODE_MAPPER), { set_selection: NOOP });
|
|
997
|
-
function applySlateOp(sharedRoot, slateRoot, op) {
|
|
998
|
-
var apply = opMappers[op.type];
|
|
999
|
-
if (!apply) {
|
|
1000
|
-
throw new Error("Unknown operation: " + op.type);
|
|
1001
|
-
}
|
|
1002
|
-
apply(sharedRoot, slateRoot, op);
|
|
1003
|
-
}
|
|
1004
|
-
|
|
1005
|
-
var DEFAULT_LOCAL_ORIGIN = Symbol('slate-yjs-operation');
|
|
1006
|
-
var DEFAULT_POSITION_STORAGE_ORIGIN = Symbol('slate-yjs-position-storage');
|
|
1007
|
-
var ORIGIN = new WeakMap();
|
|
1008
|
-
var LOCAL_CHANGES = new WeakMap();
|
|
1009
|
-
var CONNECTED = new WeakSet();
|
|
1010
|
-
var YjsEditor = {
|
|
1011
|
-
isYjsEditor: function (value) {
|
|
1012
|
-
return (slate.Editor.isEditor(value) &&
|
|
1013
|
-
value.sharedRoot instanceof Y__namespace.XmlText &&
|
|
1014
|
-
'localOrigin' in value &&
|
|
1015
|
-
'positionStorageOrigin' in value &&
|
|
1016
|
-
typeof value.applyRemoteEvents === 'function' &&
|
|
1017
|
-
typeof value.storeLocalChange === 'function' &&
|
|
1018
|
-
typeof value.flushLocalChanges === 'function' &&
|
|
1019
|
-
typeof value.isLocalOrigin === 'function' &&
|
|
1020
|
-
typeof value.connect === 'function' &&
|
|
1021
|
-
typeof value.disconnect === 'function');
|
|
1022
|
-
},
|
|
1023
|
-
localChanges: function (editor) {
|
|
1024
|
-
var _a;
|
|
1025
|
-
return (_a = LOCAL_CHANGES.get(editor)) !== null && _a !== void 0 ? _a : [];
|
|
1026
|
-
},
|
|
1027
|
-
applyRemoteEvents: function (editor, events, origin) {
|
|
1028
|
-
editor.applyRemoteEvents(events, origin);
|
|
1029
|
-
},
|
|
1030
|
-
storeLocalChange: function (editor, op) {
|
|
1031
|
-
editor.storeLocalChange(op);
|
|
1032
|
-
},
|
|
1033
|
-
flushLocalChanges: function (editor) {
|
|
1034
|
-
editor.flushLocalChanges();
|
|
1035
|
-
},
|
|
1036
|
-
connected: function (editor) {
|
|
1037
|
-
return CONNECTED.has(editor);
|
|
1038
|
-
},
|
|
1039
|
-
connect: function (editor) {
|
|
1040
|
-
editor.connect();
|
|
1041
|
-
},
|
|
1042
|
-
disconnect: function (editor) {
|
|
1043
|
-
editor.disconnect();
|
|
1044
|
-
},
|
|
1045
|
-
isLocal: function (editor) {
|
|
1046
|
-
return editor.isLocalOrigin(YjsEditor.origin(editor));
|
|
1047
|
-
},
|
|
1048
|
-
origin: function (editor) {
|
|
1049
|
-
var origin = ORIGIN.get(editor);
|
|
1050
|
-
return origin !== undefined ? origin : editor.localOrigin;
|
|
1051
|
-
},
|
|
1052
|
-
withOrigin: function (editor, origin, fn) {
|
|
1053
|
-
var prev = YjsEditor.origin(editor);
|
|
1054
|
-
ORIGIN.set(editor, origin);
|
|
1055
|
-
fn();
|
|
1056
|
-
ORIGIN.set(editor, prev);
|
|
1057
|
-
},
|
|
1058
|
-
storePosition: function (editor, key, point) {
|
|
1059
|
-
var sharedRoot = editor.sharedRoot, locationStorageOrigin = editor.positionStorageOrigin;
|
|
1060
|
-
assertDocumentAttachment(sharedRoot);
|
|
1061
|
-
var position = slatePointToRelativePosition(sharedRoot, editor, point);
|
|
1062
|
-
sharedRoot.doc.transact(function () {
|
|
1063
|
-
setStoredPosition(sharedRoot, key, position);
|
|
1064
|
-
}, locationStorageOrigin);
|
|
1065
|
-
},
|
|
1066
|
-
removeStoredPosition: function (editor, key) {
|
|
1067
|
-
var sharedRoot = editor.sharedRoot, locationStorageOrigin = editor.positionStorageOrigin;
|
|
1068
|
-
assertDocumentAttachment(sharedRoot);
|
|
1069
|
-
sharedRoot.doc.transact(function () {
|
|
1070
|
-
removeStoredPosition(sharedRoot, key);
|
|
1071
|
-
}, locationStorageOrigin);
|
|
1072
|
-
},
|
|
1073
|
-
position: function (editor, key) {
|
|
1074
|
-
var position = getStoredPosition(editor.sharedRoot, key);
|
|
1075
|
-
if (!position) {
|
|
1076
|
-
return undefined;
|
|
1077
|
-
}
|
|
1078
|
-
return relativePositionToSlatePoint(editor.sharedRoot, editor, position);
|
|
1079
|
-
},
|
|
1080
|
-
storedPositionsRelative: function (editor) {
|
|
1081
|
-
return getStoredPositions(editor.sharedRoot);
|
|
1082
|
-
},
|
|
1083
|
-
};
|
|
1084
|
-
function withYjs(sharedRoot, options) {
|
|
1085
|
-
if (options === void 0) { options = {}; }
|
|
1086
|
-
return function (editor) {
|
|
1087
|
-
var _a, _b;
|
|
1088
|
-
var e = editor;
|
|
1089
|
-
e.sharedRoot = sharedRoot;
|
|
1090
|
-
e.localOrigin = (_a = options.localOrigin) !== null && _a !== void 0 ? _a : DEFAULT_LOCAL_ORIGIN;
|
|
1091
|
-
e.positionStorageOrigin = (_b = options.positionStorageOrigin) !== null && _b !== void 0 ? _b : DEFAULT_POSITION_STORAGE_ORIGIN;
|
|
1092
|
-
e.applyRemoteEvents = function (events, origin) {
|
|
1093
|
-
YjsEditor.flushLocalChanges(e);
|
|
1094
|
-
slate.Editor.withoutNormalizing(e, function () {
|
|
1095
|
-
YjsEditor.withOrigin(e, origin, function () {
|
|
1096
|
-
applyYjsEvents(e.sharedRoot, e, events);
|
|
1097
|
-
});
|
|
1098
|
-
});
|
|
1099
|
-
};
|
|
1100
|
-
e.isLocalOrigin = function (origin) { return origin === e.localOrigin; };
|
|
1101
|
-
var handleYEvents = function (events, transaction) {
|
|
1102
|
-
if (e.isLocalOrigin(transaction.origin)) {
|
|
1103
|
-
return;
|
|
1104
|
-
}
|
|
1105
|
-
YjsEditor.applyRemoteEvents(e, events, transaction.origin);
|
|
1106
|
-
};
|
|
1107
|
-
var autoConnectTimeoutId = null;
|
|
1108
|
-
if (options.autoConnect) {
|
|
1109
|
-
autoConnectTimeoutId = setTimeout(function () {
|
|
1110
|
-
autoConnectTimeoutId = null;
|
|
1111
|
-
YjsEditor.connect(e);
|
|
1112
|
-
});
|
|
1113
|
-
}
|
|
1114
|
-
e.connect = function () {
|
|
1115
|
-
if (YjsEditor.connected(e)) {
|
|
1116
|
-
throw new Error('already connected');
|
|
1117
|
-
}
|
|
1118
|
-
e.sharedRoot.observeDeep(handleYEvents);
|
|
1119
|
-
var content = yTextToSlateElement(e.sharedRoot);
|
|
1120
|
-
e.children = content.children;
|
|
1121
|
-
CONNECTED.add(e);
|
|
1122
|
-
slate.Editor.normalize(editor, { force: true });
|
|
1123
|
-
if (!editor.operations.length) {
|
|
1124
|
-
editor.onChange();
|
|
1125
|
-
}
|
|
1126
|
-
};
|
|
1127
|
-
e.disconnect = function () {
|
|
1128
|
-
if (autoConnectTimeoutId) {
|
|
1129
|
-
clearTimeout(autoConnectTimeoutId);
|
|
1130
|
-
}
|
|
1131
|
-
YjsEditor.flushLocalChanges(e);
|
|
1132
|
-
e.sharedRoot.unobserveDeep(handleYEvents);
|
|
1133
|
-
CONNECTED.delete(e);
|
|
1134
|
-
};
|
|
1135
|
-
e.storeLocalChange = function (op) {
|
|
1136
|
-
LOCAL_CHANGES.set(e, __spreadArray(__spreadArray([], __read(YjsEditor.localChanges(e))), [
|
|
1137
|
-
{ op: op, doc: editor.children, origin: YjsEditor.origin(e) },
|
|
1138
|
-
]));
|
|
1139
|
-
};
|
|
1140
|
-
e.flushLocalChanges = function () {
|
|
1141
|
-
assertDocumentAttachment(e.sharedRoot);
|
|
1142
|
-
var localChanges = YjsEditor.localChanges(e);
|
|
1143
|
-
LOCAL_CHANGES.delete(e);
|
|
1144
|
-
var txGroups = [];
|
|
1145
|
-
localChanges.forEach(function (change) {
|
|
1146
|
-
var currentGroup = txGroups[txGroups.length - 1];
|
|
1147
|
-
if (currentGroup && currentGroup[0].origin === change.origin) {
|
|
1148
|
-
return currentGroup.push(change);
|
|
1149
|
-
}
|
|
1150
|
-
txGroups.push([change]);
|
|
1151
|
-
});
|
|
1152
|
-
txGroups.forEach(function (txGroup) {
|
|
1153
|
-
assertDocumentAttachment(e.sharedRoot);
|
|
1154
|
-
e.sharedRoot.doc.transact(function () {
|
|
1155
|
-
txGroup.forEach(function (change) {
|
|
1156
|
-
assertDocumentAttachment(e.sharedRoot);
|
|
1157
|
-
applySlateOp(e.sharedRoot, { children: change.doc }, change.op);
|
|
1158
|
-
});
|
|
1159
|
-
}, txGroup[0].origin);
|
|
1160
|
-
});
|
|
1161
|
-
};
|
|
1162
|
-
var apply = e.apply, onChange = e.onChange;
|
|
1163
|
-
e.apply = function (op) {
|
|
1164
|
-
if (YjsEditor.connected(e) && YjsEditor.isLocal(e)) {
|
|
1165
|
-
YjsEditor.storeLocalChange(e, op);
|
|
1166
|
-
}
|
|
1167
|
-
apply(op);
|
|
1168
|
-
};
|
|
1169
|
-
e.onChange = function () {
|
|
1170
|
-
if (YjsEditor.connected(e)) {
|
|
1171
|
-
YjsEditor.flushLocalChanges(e);
|
|
1172
|
-
}
|
|
1173
|
-
onChange();
|
|
1174
|
-
};
|
|
1175
|
-
return e;
|
|
1176
|
-
};
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
var LAST_SELECTION = new WeakMap();
|
|
1180
|
-
var DEFAULT_WITHOUT_SAVING_ORIGIN = Symbol('slate-yjs-history-without-saving');
|
|
1181
|
-
var YHistoryEditor = {
|
|
1182
|
-
isYHistoryEditor: function (value) {
|
|
1183
|
-
return (YjsEditor.isYjsEditor(value) &&
|
|
1184
|
-
value.undoManager instanceof Y__namespace.UndoManager &&
|
|
1185
|
-
typeof value.undo === 'function' &&
|
|
1186
|
-
typeof value.redo === 'function' &&
|
|
1187
|
-
'withoutSavingOrigin' in value);
|
|
1188
|
-
},
|
|
1189
|
-
canUndo: function (editor) {
|
|
1190
|
-
return editor.undoManager.undoStack.length > 0;
|
|
1191
|
-
},
|
|
1192
|
-
canRedo: function (editor) {
|
|
1193
|
-
return editor.undoManager.redoStack.length > 0;
|
|
1194
|
-
},
|
|
1195
|
-
isSaving: function (editor) {
|
|
1196
|
-
return editor.undoManager.trackedOrigins.has(YjsEditor.origin(editor));
|
|
1197
|
-
},
|
|
1198
|
-
withoutSaving: function (editor, fn) {
|
|
1199
|
-
YjsEditor.withOrigin(editor, editor.withoutSavingOrigin, fn);
|
|
1200
|
-
},
|
|
1201
|
-
};
|
|
1202
|
-
function withYHistory(options) {
|
|
1203
|
-
if (options === void 0) { options = {}; }
|
|
1204
|
-
return function (editor) {
|
|
1205
|
-
var e = editor;
|
|
1206
|
-
// 将 trackedOrigins 的初始化放到 editor 被传入之后
|
|
1207
|
-
var _a = options.withoutSavingOrigin, withoutSavingOrigin = _a === void 0 ? DEFAULT_WITHOUT_SAVING_ORIGIN : _a, _b = options.trackedOrigins, trackedOrigins = _b === void 0 ? new Set([e.localOrigin]) : _b, restOptions = __rest(options, ["withoutSavingOrigin", "trackedOrigins"]);
|
|
1208
|
-
var undoManager = new Y__namespace.UndoManager(e.sharedRoot, __assign({ trackedOrigins: trackedOrigins }, restOptions));
|
|
1209
|
-
e.undoManager = undoManager;
|
|
1210
|
-
e.withoutSavingOrigin = withoutSavingOrigin;
|
|
1211
|
-
var onChange = e.onChange, isLocalOrigin = e.isLocalOrigin;
|
|
1212
|
-
e.onChange = function () {
|
|
1213
|
-
onChange();
|
|
1214
|
-
LAST_SELECTION.set(e, e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection));
|
|
1215
|
-
};
|
|
1216
|
-
e.isLocalOrigin = function (origin) { return origin === e.withoutSavingOrigin || isLocalOrigin(origin); };
|
|
1217
|
-
var handleStackItemAdded = function (_a) {
|
|
1218
|
-
var stackItem = _a.stackItem;
|
|
1219
|
-
stackItem.meta.set('selection', e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection));
|
|
1220
|
-
stackItem.meta.set('selectionBefore', LAST_SELECTION.get(e));
|
|
1221
|
-
};
|
|
1222
|
-
var handleStackItemUpdated = function (_a) {
|
|
1223
|
-
var stackItem = _a.stackItem;
|
|
1224
|
-
stackItem.meta.set('selection', e.selection && slateRangeToRelativeRange(e.sharedRoot, e, e.selection));
|
|
1225
|
-
};
|
|
1226
|
-
var handleStackItemPopped = function (_a) {
|
|
1227
|
-
var stackItem = _a.stackItem, type = _a.type;
|
|
1228
|
-
// TODO: Change once https://github.com/yjs/yjs/issues/353 is resolved
|
|
1229
|
-
var inverseStack = type === 'undo' ? e.undoManager.redoStack : e.undoManager.undoStack;
|
|
1230
|
-
var inverseItem = inverseStack[inverseStack.length - 1];
|
|
1231
|
-
if (inverseItem) {
|
|
1232
|
-
inverseItem.meta.set('selection', stackItem.meta.get('selectionBefore'));
|
|
1233
|
-
inverseItem.meta.set('selectionBefore', stackItem.meta.get('selection'));
|
|
1234
|
-
}
|
|
1235
|
-
var relativeSelection = stackItem.meta.get('selectionBefore');
|
|
1236
|
-
if (!relativeSelection) {
|
|
1237
|
-
return;
|
|
1238
|
-
}
|
|
1239
|
-
var selection = relativeRangeToSlateRange(e.sharedRoot, e, relativeSelection);
|
|
1240
|
-
if (!selection) {
|
|
1241
|
-
return;
|
|
1242
|
-
}
|
|
1243
|
-
slate.Transforms.select(e, selection);
|
|
1244
|
-
};
|
|
1245
|
-
var connect = e.connect, disconnect = e.disconnect;
|
|
1246
|
-
e.connect = function () {
|
|
1247
|
-
connect();
|
|
1248
|
-
e.undoManager.on('stack-item-added', handleStackItemAdded);
|
|
1249
|
-
e.undoManager.on('stack-item-popped', handleStackItemPopped);
|
|
1250
|
-
e.undoManager.on('stack-item-updated', handleStackItemUpdated);
|
|
1251
|
-
};
|
|
1252
|
-
e.disconnect = function () {
|
|
1253
|
-
e.undoManager.off('stack-item-added', handleStackItemAdded);
|
|
1254
|
-
e.undoManager.off('stack-item-popped', handleStackItemPopped);
|
|
1255
|
-
e.undoManager.off('stack-item-updated', handleStackItemUpdated);
|
|
1256
|
-
disconnect();
|
|
1257
|
-
};
|
|
1258
|
-
e.undo = function () {
|
|
1259
|
-
if (YjsEditor.connected(e)) {
|
|
1260
|
-
YjsEditor.flushLocalChanges(e);
|
|
1261
|
-
e.undoManager.undo();
|
|
1262
|
-
}
|
|
1263
|
-
};
|
|
1264
|
-
e.redo = function () {
|
|
1265
|
-
if (YjsEditor.connected(e)) {
|
|
1266
|
-
YjsEditor.flushLocalChanges(e);
|
|
1267
|
-
e.undoManager.redo();
|
|
1268
|
-
}
|
|
1269
|
-
};
|
|
1270
|
-
return e;
|
|
1271
|
-
};
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
var CURSOR_CHANGE_EVENT_LISTENERS = new WeakMap();
|
|
1275
|
-
var CursorEditor = {
|
|
1276
|
-
isCursorEditor: function (value) {
|
|
1277
|
-
return (YjsEditor.isYjsEditor(value) &&
|
|
1278
|
-
value.awareness &&
|
|
1279
|
-
typeof value.cursorDataField === 'string' &&
|
|
1280
|
-
typeof value.selectionStateField === 'string' &&
|
|
1281
|
-
typeof value.sendCursorPosition === 'function' &&
|
|
1282
|
-
typeof value.sendCursorData === 'function');
|
|
1283
|
-
},
|
|
1284
|
-
sendCursorPosition: function (editor, range) {
|
|
1285
|
-
if (range === void 0) { range = editor.selection; }
|
|
1286
|
-
editor.sendCursorPosition(range);
|
|
1287
|
-
},
|
|
1288
|
-
sendCursorData: function (editor, data) {
|
|
1289
|
-
editor.sendCursorData(data);
|
|
1290
|
-
},
|
|
1291
|
-
on: function (editor, event, handler) {
|
|
1292
|
-
var _a;
|
|
1293
|
-
if (event !== 'change') {
|
|
1294
|
-
return;
|
|
1295
|
-
}
|
|
1296
|
-
if (!editor)
|
|
1297
|
-
return;
|
|
1298
|
-
var listeners = (_a = CURSOR_CHANGE_EVENT_LISTENERS.get(editor)) !== null && _a !== void 0 ? _a : new Set();
|
|
1299
|
-
listeners.add(handler);
|
|
1300
|
-
CURSOR_CHANGE_EVENT_LISTENERS.set(editor, listeners);
|
|
1301
|
-
},
|
|
1302
|
-
off: function (editor, event, listener) {
|
|
1303
|
-
if (event !== 'change') {
|
|
1304
|
-
return;
|
|
1305
|
-
}
|
|
1306
|
-
var listeners = CURSOR_CHANGE_EVENT_LISTENERS.get(editor);
|
|
1307
|
-
if (listeners) {
|
|
1308
|
-
listeners.delete(listener);
|
|
1309
|
-
}
|
|
1310
|
-
},
|
|
1311
|
-
cursorState: function (editor, clientId) {
|
|
1312
|
-
var _a;
|
|
1313
|
-
if (clientId === editor.awareness.clientID || !YjsEditor.connected(editor)) {
|
|
1314
|
-
return null;
|
|
1315
|
-
}
|
|
1316
|
-
var state = editor.awareness.getStates().get(clientId);
|
|
1317
|
-
if (!state) {
|
|
1318
|
-
return null;
|
|
1319
|
-
}
|
|
1320
|
-
return {
|
|
1321
|
-
relativeSelection: (_a = state[editor.selectionStateField]) !== null && _a !== void 0 ? _a : null,
|
|
1322
|
-
data: state[editor.cursorDataField],
|
|
1323
|
-
clientId: clientId,
|
|
1324
|
-
};
|
|
1325
|
-
},
|
|
1326
|
-
cursorStates: function (editor) {
|
|
1327
|
-
if (!YjsEditor.connected(editor)) {
|
|
1328
|
-
return {};
|
|
1329
|
-
}
|
|
1330
|
-
return Object.fromEntries(Array.from(editor.awareness.getStates().entries(), function (_a) {
|
|
1331
|
-
var _b = __read(_a, 2), id = _b[0], state = _b[1];
|
|
1332
|
-
// Ignore own state
|
|
1333
|
-
if (id === editor.awareness.clientID || !state) {
|
|
1334
|
-
return null;
|
|
1335
|
-
}
|
|
1336
|
-
return [
|
|
1337
|
-
id,
|
|
1338
|
-
{
|
|
1339
|
-
relativeSelection: state[editor.selectionStateField],
|
|
1340
|
-
data: state[editor.cursorDataField],
|
|
1341
|
-
},
|
|
1342
|
-
];
|
|
1343
|
-
}).filter(Array.isArray));
|
|
1344
|
-
},
|
|
1345
|
-
};
|
|
1346
|
-
function withCursors(awareness, options) {
|
|
1347
|
-
if (options === void 0) { options = {}; }
|
|
1348
|
-
return function (editor) {
|
|
1349
|
-
var _a = options.cursorStateField, selectionStateField = _a === void 0 ? 'selection' : _a, _b = options.cursorDataField, cursorDataField = _b === void 0 ? 'data' : _b, _c = options.autoSend, autoSend = _c === void 0 ? true : _c, data = options.data;
|
|
1350
|
-
var e = editor;
|
|
1351
|
-
e.awareness = awareness;
|
|
1352
|
-
e.cursorDataField = cursorDataField;
|
|
1353
|
-
e.selectionStateField = selectionStateField;
|
|
1354
|
-
e.sendCursorData = function (cursorData) {
|
|
1355
|
-
e.awareness.setLocalStateField(e.cursorDataField, cursorData);
|
|
1356
|
-
};
|
|
1357
|
-
e.sendCursorPosition = function (range) {
|
|
1358
|
-
var localState = e.awareness.getLocalState();
|
|
1359
|
-
var currentRange = localState === null || localState === void 0 ? void 0 : localState[selectionStateField];
|
|
1360
|
-
if (!range) {
|
|
1361
|
-
if (currentRange) {
|
|
1362
|
-
e.awareness.setLocalStateField(e.selectionStateField, null);
|
|
1363
|
-
}
|
|
1364
|
-
return;
|
|
1365
|
-
}
|
|
1366
|
-
var _a = slateRangeToRelativeRange(e.sharedRoot, e, range), anchor = _a.anchor, focus = _a.focus;
|
|
1367
|
-
if (!currentRange ||
|
|
1368
|
-
!Y__namespace.compareRelativePositions(anchor, currentRange) ||
|
|
1369
|
-
!Y__namespace.compareRelativePositions(focus, currentRange)) {
|
|
1370
|
-
e.awareness.setLocalStateField(e.selectionStateField, { anchor: anchor, focus: focus });
|
|
1371
|
-
}
|
|
1372
|
-
};
|
|
1373
|
-
var awarenessChangeListener = function (yEvent) {
|
|
1374
|
-
var listeners = CURSOR_CHANGE_EVENT_LISTENERS.get(e);
|
|
1375
|
-
if (!listeners) {
|
|
1376
|
-
return;
|
|
1377
|
-
}
|
|
1378
|
-
var localId = e.awareness.clientID;
|
|
1379
|
-
var event = {
|
|
1380
|
-
added: yEvent.added.filter(function (id) { return id !== localId; }),
|
|
1381
|
-
removed: yEvent.removed.filter(function (id) { return id !== localId; }),
|
|
1382
|
-
updated: yEvent.updated.filter(function (id) { return id !== localId; }),
|
|
1383
|
-
};
|
|
1384
|
-
if (event.added.length > 0 || event.removed.length > 0 || event.updated.length > 0) {
|
|
1385
|
-
listeners.forEach(function (listener) { return listener(event); });
|
|
1386
|
-
}
|
|
1387
|
-
};
|
|
1388
|
-
var connect = e.connect, disconnect = e.disconnect;
|
|
1389
|
-
e.connect = function () {
|
|
1390
|
-
connect();
|
|
1391
|
-
e.awareness.on('change', awarenessChangeListener);
|
|
1392
|
-
awarenessChangeListener({
|
|
1393
|
-
removed: [],
|
|
1394
|
-
added: Array.from(e.awareness.getStates().keys()),
|
|
1395
|
-
updated: [],
|
|
1396
|
-
});
|
|
1397
|
-
if (autoSend) {
|
|
1398
|
-
if (data) {
|
|
1399
|
-
CursorEditor.sendCursorData(e, data);
|
|
1400
|
-
}
|
|
1401
|
-
var onChange_1 = e.onChange;
|
|
1402
|
-
e.onChange = function () {
|
|
1403
|
-
onChange_1();
|
|
1404
|
-
if (YjsEditor.connected(e)) {
|
|
1405
|
-
CursorEditor.sendCursorPosition(e);
|
|
1406
|
-
}
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
|
-
};
|
|
1410
|
-
e.disconnect = function () {
|
|
1411
|
-
e.awareness.off('change', awarenessChangeListener);
|
|
1412
|
-
awarenessChangeListener({
|
|
1413
|
-
removed: Array.from(e.awareness.getStates().keys()),
|
|
1414
|
-
added: [],
|
|
1415
|
-
updated: [],
|
|
1416
|
-
});
|
|
1417
|
-
disconnect();
|
|
1418
|
-
};
|
|
1419
|
-
return e;
|
|
1420
|
-
};
|
|
1421
|
-
}
|
|
1422
|
-
|
|
1423
|
-
exports.CursorEditor = CursorEditor;
|
|
1424
|
-
exports.YHistoryEditor = YHistoryEditor;
|
|
1425
|
-
exports.YjsEditor = YjsEditor;
|
|
1426
|
-
exports.relativePositionToSlatePoint = relativePositionToSlatePoint;
|
|
1427
|
-
exports.relativeRangeToSlateRange = relativeRangeToSlateRange;
|
|
1428
|
-
exports.slateNodesToInsertDelta = slateNodesToInsertDelta;
|
|
1429
|
-
exports.slatePointToRelativePosition = slatePointToRelativePosition;
|
|
1430
|
-
exports.slateRangeToRelativeRange = slateRangeToRelativeRange;
|
|
1431
|
-
exports.withCursors = withCursors;
|
|
1432
|
-
exports.withYHistory = withYHistory;
|
|
1433
|
-
exports.withYjs = withYjs;
|
|
1434
|
-
exports.yTextToSlateElement = yTextToSlateElement;
|
|
1435
|
-
|
|
1436
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
1437
|
-
|
|
1438
|
-
}));
|
|
1
|
+
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("yjs"),require("slate")):"function"==typeof define&&define.amd?define(["exports","yjs","slate"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).WangEditorYjsModule={},t.Y,t.slate)}(this,(function(t,e,n){"use strict";function r(t){if(t&&t.__esModule)return t;var e=Object.create(null);return t&&Object.keys(t).forEach((function(n){if("default"!==n){var r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:function(){return t[n]}})}})),e.default=t,Object.freeze(e)}var o=r(e),i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function a(t){var e={exports:{}};return t(e,e.exports),e.exports}var u,c,s=function(t){return t&&t.Math===Math&&t},f=s("object"==typeof globalThis&&globalThis)||s("object"==typeof window&&window)||s("object"==typeof self&&self)||s("object"==typeof i&&i)||s("object"==typeof i&&i)||function(){return this}()||Function("return this")(),l=function(t){try{return!!t()}catch(t){return!0}},d=!l((function(){return 7!==Object.defineProperty({},1,{get:function(){return 7}})[1]})),h=!l((function(){var t=function(){}.bind();return"function"!=typeof t||t.hasOwnProperty("prototype")})),p=Function.prototype.call,v=h?p.bind(p):function(){return p.apply(p,arguments)},g={}.propertyIsEnumerable,y=Object.getOwnPropertyDescriptor,b=y&&!g.call({1:2},1)?function(t){var e=y(this,t);return!!e&&e.enumerable}:g,m={f:b},w=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},O=Function.prototype,x=O.call,S=h&&O.bind.bind(x,x),E=h?S:function(t){return function(){return x.apply(t,arguments)}},T=E({}.toString),j=E("".slice),P=function(t){return j(T(t),8,-1)},R=Object,A=E("".split),C=l((function(){return!R("z").propertyIsEnumerable(0)}))?function(t){return"String"===P(t)?A(t,""):R(t)}:R,k=function(t){return null==t},L=TypeError,F=function(t){if(k(t))throw new L("Can't call method on "+t);return t},_=function(t){return C(F(t))},M="object"==typeof document&&document.all,D=void 0===M&&void 0!==M?function(t){return"function"==typeof t||t===M}:function(t){return"function"==typeof t},I=function(t){return"object"==typeof t?null!==t:D(t)},z=function(t,e){return arguments.length<2?(n=f[t],D(n)?n:void 0):f[t]&&f[t][e];var n},N=E({}.isPrototypeOf),W=f.navigator,Y=W&&W.userAgent,X=Y?String(Y):"",G=f.process,B=f.Deno,U=G&&G.versions||B&&B.version,V=U&&U.v8;V&&(c=(u=V.split("."))[0]>0&&u[0]<4?1:+(u[0]+u[1])),!c&&X&&(!(u=X.match(/Edge\/(\d+)/))||u[1]>=74)&&(u=X.match(/Chrome\/(\d+)/))&&(c=+u[1]);var q=c,H=f.String,$=!!Object.getOwnPropertySymbols&&!l((function(){var t=Symbol("symbol detection");return!H(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&q&&q<41})),J=$&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,K=Object,Q=J?function(t){return"symbol"==typeof t}:function(t){var e=z("Symbol");return D(e)&&N(e.prototype,K(t))},Z=String,tt=function(t){try{return Z(t)}catch(t){return"Object"}},et=TypeError,nt=function(t){if(D(t))return t;throw new et(tt(t)+" is not a function")},rt=function(t,e){var n=t[e];return k(n)?void 0:nt(n)},ot=TypeError,it=Object.defineProperty,at=function(t,e){try{it(f,t,{value:e,configurable:!0,writable:!0})}catch(n){f[t]=e}return e},ut=a((function(t){var e="__core-js_shared__",n=t.exports=f[e]||at(e,{});(n.versions||(n.versions=[])).push({version:"3.38.1",mode:"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"})})),ct=function(t,e){return ut[t]||(ut[t]=e||{})},st=Object,ft=function(t){return st(F(t))},lt=E({}.hasOwnProperty),dt=Object.hasOwn||function(t,e){return lt(ft(t),e)},ht=0,pt=Math.random(),vt=E(1..toString),gt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+vt(++ht+pt,36)},yt=f.Symbol,bt=ct("wks"),mt=J?yt.for||yt:yt&&yt.withoutSetter||gt,wt=function(t){return dt(bt,t)||(bt[t]=$&&dt(yt,t)?yt[t]:mt("Symbol."+t)),bt[t]},Ot=TypeError,xt=wt("toPrimitive"),St=function(t,e){if(!I(t)||Q(t))return t;var n,r=rt(t,xt);if(r){if(void 0===e&&(e="default"),n=v(r,t,e),!I(n)||Q(n))return n;throw new Ot("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var n,r;if("string"===e&&D(n=t.toString)&&!I(r=v(n,t)))return r;if(D(n=t.valueOf)&&!I(r=v(n,t)))return r;if("string"!==e&&D(n=t.toString)&&!I(r=v(n,t)))return r;throw new ot("Can't convert object to primitive value")}(t,e)},Et=function(t){var e=St(t,"string");return Q(e)?e:e+""},Tt=f.document,jt=I(Tt)&&I(Tt.createElement),Pt=function(t){return jt?Tt.createElement(t):{}},Rt=!d&&!l((function(){return 7!==Object.defineProperty(Pt("div"),"a",{get:function(){return 7}}).a})),At=Object.getOwnPropertyDescriptor,Ct={f:d?At:function(t,e){if(t=_(t),e=Et(e),Rt)try{return At(t,e)}catch(t){}if(dt(t,e))return w(!v(m.f,t,e),t[e])}},kt=d&&l((function(){return 42!==Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype})),Lt=String,Ft=TypeError,_t=function(t){if(I(t))return t;throw new Ft(Lt(t)+" is not an object")},Mt=TypeError,Dt=Object.defineProperty,It=Object.getOwnPropertyDescriptor,zt="enumerable",Nt="configurable",Wt="writable",Yt={f:d?kt?function(t,e,n){if(_t(t),e=Et(e),_t(n),"function"==typeof t&&"prototype"===e&&"value"in n&&Wt in n&&!n[Wt]){var r=It(t,e);r&&r[Wt]&&(t[e]=n.value,n={configurable:Nt in n?n[Nt]:r[Nt],enumerable:zt in n?n[zt]:r[zt],writable:!1})}return Dt(t,e,n)}:Dt:function(t,e,n){if(_t(t),e=Et(e),_t(n),Rt)try{return Dt(t,e,n)}catch(t){}if("get"in n||"set"in n)throw new Mt("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},Xt=d?function(t,e,n){return Yt.f(t,e,w(1,n))}:function(t,e,n){return t[e]=n,t},Gt=Function.prototype,Bt=d&&Object.getOwnPropertyDescriptor,Ut=dt(Gt,"name"),Vt={EXISTS:Ut,PROPER:Ut&&"something"===function(){}.name,CONFIGURABLE:Ut&&(!d||d&&Bt(Gt,"name").configurable)},qt=E(Function.toString);D(ut.inspectSource)||(ut.inspectSource=function(t){return qt(t)});var Ht,$t,Jt,Kt=ut.inspectSource,Qt=f.WeakMap,Zt=D(Qt)&&/native code/.test(String(Qt)),te=ct("keys"),ee=function(t){return te[t]||(te[t]=gt(t))},ne={},re="Object already initialized",oe=f.TypeError,ie=f.WeakMap;if(Zt||ut.state){var ae=ut.state||(ut.state=new ie);ae.get=ae.get,ae.has=ae.has,ae.set=ae.set,Ht=function(t,e){if(ae.has(t))throw new oe(re);return e.facade=t,ae.set(t,e),e},$t=function(t){return ae.get(t)||{}},Jt=function(t){return ae.has(t)}}else{var ue=ee("state");ne[ue]=!0,Ht=function(t,e){if(dt(t,ue))throw new oe(re);return e.facade=t,Xt(t,ue,e),e},$t=function(t){return dt(t,ue)?t[ue]:{}},Jt=function(t){return dt(t,ue)}}var ce={set:Ht,get:$t,has:Jt,enforce:function(t){return Jt(t)?$t(t):Ht(t,{})},getterFor:function(t){return function(e){var n;if(!I(e)||(n=$t(e)).type!==t)throw new oe("Incompatible receiver, "+t+" required");return n}}},se=a((function(t){var e=Vt.CONFIGURABLE,n=ce.enforce,r=ce.get,o=String,i=Object.defineProperty,a=E("".slice),u=E("".replace),c=E([].join),s=d&&!l((function(){return 8!==i((function(){}),"length",{value:8}).length})),f=String(String).split("String"),h=t.exports=function(t,r,l){"Symbol("===a(o(r),0,7)&&(r="["+u(o(r),/^Symbol\(([^)]*)\).*$/,"$1")+"]"),l&&l.getter&&(r="get "+r),l&&l.setter&&(r="set "+r),(!dt(t,"name")||e&&t.name!==r)&&(d?i(t,"name",{value:r,configurable:!0}):t.name=r),s&&l&&dt(l,"arity")&&t.length!==l.arity&&i(t,"length",{value:l.arity});try{l&&dt(l,"constructor")&&l.constructor?d&&i(t,"prototype",{writable:!1}):t.prototype&&(t.prototype=void 0)}catch(t){}var h=n(t);return dt(h,"source")||(h.source=c(f,"string"==typeof r?r:"")),t};Function.prototype.toString=h((function(){return D(this)&&r(this).source||Kt(this)}),"toString")})),fe=function(t,e,n,r){r||(r={});var o=r.enumerable,i=void 0!==r.name?r.name:e;if(D(n)&&se(n,i,r),r.global)o?t[e]=n:at(e,n);else{try{r.unsafe?t[e]&&(o=!0):delete t[e]}catch(t){}o?t[e]=n:Yt.f(t,e,{value:n,enumerable:!1,configurable:!r.nonConfigurable,writable:!r.nonWritable})}return t},le=Math.ceil,de=Math.floor,he=Math.trunc||function(t){var e=+t;return(e>0?de:le)(e)},pe=function(t){var e=+t;return e!=e||0===e?0:he(e)},ve=Math.max,ge=Math.min,ye=function(t,e){var n=pe(t);return n<0?ve(n+e,0):ge(n,e)},be=Math.min,me=function(t){var e=pe(t);return e>0?be(e,9007199254740991):0},we=function(t){return me(t.length)},Oe=function(t){return function(e,n,r){var o=_(e),i=we(o);if(0===i)return!t&&-1;var a,u=ye(r,i);if(t&&n!=n){for(;i>u;)if((a=o[u++])!=a)return!0}else for(;i>u;u++)if((t||u in o)&&o[u]===n)return t||u||0;return!t&&-1}},xe={includes:Oe(!0),indexOf:Oe(!1)},Se=xe.indexOf,Ee=E([].push),Te=function(t,e){var n,r=_(t),o=0,i=[];for(n in r)!dt(ne,n)&&dt(r,n)&&Ee(i,n);for(;e.length>o;)dt(r,n=e[o++])&&(~Se(i,n)||Ee(i,n));return i},je=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],Pe=je.concat("length","prototype"),Re={f:Object.getOwnPropertyNames||function(t){return Te(t,Pe)}},Ae={f:Object.getOwnPropertySymbols},Ce=E([].concat),ke=z("Reflect","ownKeys")||function(t){var e=Re.f(_t(t)),n=Ae.f;return n?Ce(e,n(t)):e},Le=function(t,e,n){for(var r=ke(e),o=Yt.f,i=Ct.f,a=0;a<r.length;a++){var u=r[a];dt(t,u)||n&&dt(n,u)||o(t,u,i(e,u))}},Fe=/#|\.prototype\./,_e=function(t,e){var n=De[Me(t)];return n===ze||n!==Ie&&(D(e)?l(e):!!e)},Me=_e.normalize=function(t){return String(t).replace(Fe,".").toLowerCase()},De=_e.data={},Ie=_e.NATIVE="N",ze=_e.POLYFILL="P",Ne=_e,We=Ct.f,Ye=function(t,e){var n,r,o,i,a,u=t.target,c=t.global,s=t.stat;if(n=c?f:s?f[u]||at(u,{}):f[u]&&f[u].prototype)for(r in e){if(i=e[r],o=t.dontCallGetSet?(a=We(n,r))&&a.value:n[r],!Ne(c?r:u+(s?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;Le(i,o)}(t.sham||o&&o.sham)&&Xt(i,"sham",!0),fe(n,r,i,t)}},Xe=function(t){if("Function"===P(t))return E(t)},Ge=Xe(Xe.bind),Be=function(t,e){return nt(t),void 0===e?t:h?Ge(t,e):function(){return t.apply(e,arguments)}},Ue=Array.isArray||function(t){return"Array"===P(t)},Ve={};Ve[wt("toStringTag")]="z";var qe="[object z]"===String(Ve),He=wt("toStringTag"),$e=Object,Je="Arguments"===P(function(){return arguments}()),Ke=qe?P:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=$e(t),He))?n:Je?P(e):"Object"===(r=P(e))&&D(e.callee)?"Arguments":r},Qe=function(){},Ze=z("Reflect","construct"),tn=/^\s*(?:class|function)\b/,en=E(tn.exec),nn=!tn.test(Qe),rn=function(t){if(!D(t))return!1;try{return Ze(Qe,[],t),!0}catch(t){return!1}},on=function(t){if(!D(t))return!1;switch(Ke(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return nn||!!en(tn,Kt(t))}catch(t){return!0}};on.sham=!0;var an=!Ze||l((function(){var t;return rn(rn.call)||!rn(Object)||!rn((function(){t=!0}))||t}))?on:rn,un=wt("species"),cn=Array,sn=function(t,e){return new(function(t){var e;return Ue(t)&&(e=t.constructor,(an(e)&&(e===cn||Ue(e.prototype))||I(e)&&null===(e=e[un]))&&(e=void 0)),void 0===e?cn:e}(t))(0===e?0:e)},fn=E([].push),ln=function(t){var e=1===t,n=2===t,r=3===t,o=4===t,i=6===t,a=7===t,u=5===t||i;return function(c,s,f,l){for(var d,h,p=ft(c),v=C(p),g=we(v),y=Be(s,f),b=0,m=l||sn,w=e?m(c,g):n||a?m(c,0):void 0;g>b;b++)if((u||b in v)&&(h=y(d=v[b],b,p),t))if(e)w[b]=h;else if(h)switch(t){case 3:return!0;case 5:return d;case 6:return b;case 2:fn(w,d)}else switch(t){case 4:return!1;case 7:fn(w,d)}return i?-1:r||o?o:w}},dn={forEach:ln(0),map:ln(1),filter:ln(2),some:ln(3),every:ln(4),find:ln(5),findIndex:ln(6),filterReject:ln(7)},hn=wt("species"),pn=function(t){return q>=51||!l((function(){var e=[];return(e.constructor={})[hn]=function(){return{foo:1}},1!==e[t](Boolean).foo}))},vn=dn.filter,gn=pn("filter");Ye({target:"Array",proto:!0,forced:!gn},{filter:function(t){return vn(this,t,arguments.length>1?arguments[1]:void 0)}});var yn=function(t,e,n){var r,o;_t(t);try{if(!(r=rt(t,"return"))){if("throw"===e)throw n;return n}r=v(r,t)}catch(t){o=!0,r=t}if("throw"===e)throw n;if(o)throw r;return _t(r),n},bn=function(t,e,n,r){try{return r?e(_t(n)[0],n[1]):e(n)}catch(e){yn(t,"throw",e)}},mn={},wn=wt("iterator"),On=Array.prototype,xn=function(t){return void 0!==t&&(mn.Array===t||On[wn]===t)},Sn=function(t,e,n){d?Yt.f(t,e,w(0,n)):t[e]=n},En=wt("iterator"),Tn=function(t){if(!k(t))return rt(t,En)||rt(t,"@@iterator")||mn[Ke(t)]},jn=TypeError,Pn=function(t,e){var n=arguments.length<2?Tn(t):e;if(nt(n))return _t(v(n,t));throw new jn(tt(t)+" is not iterable")},Rn=Array,An=wt("iterator"),Cn=!1;try{var kn=0,Ln={next:function(){return{done:!!kn++}},return:function(){Cn=!0}};Ln[An]=function(){return this},Array.from(Ln,(function(){throw 2}))}catch(t){}var Fn=function(t,e){try{if(!e&&!Cn)return!1}catch(t){return!1}var n=!1;try{var r={};r[An]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n},_n=!Fn((function(t){Array.from(t)}));Ye({target:"Array",stat:!0,forced:_n},{from:function(t){var e=ft(t),n=an(this),r=arguments.length,o=r>1?arguments[1]:void 0,i=void 0!==o;i&&(o=Be(o,r>2?arguments[2]:void 0));var a,u,c,s,f,l,d=Tn(e),h=0;if(!d||this===Rn&&xn(d))for(a=we(e),u=n?new this(a):Rn(a);a>h;h++)l=i?o(e[h],h):e[h],Sn(u,h,l);else for(u=n?new this:[],f=(s=Pn(e,d)).next;!(c=v(f,s)).done;h++)l=i?bn(s,o,[c.value,h],!0):c.value,Sn(u,h,l);return u.length=h,u}});var Mn,Dn=Object.keys||function(t){return Te(t,je)},In=d&&!kt?Object.defineProperties:function(t,e){_t(t);for(var n,r=_(e),o=Dn(e),i=o.length,a=0;i>a;)Yt.f(t,n=o[a++],r[n]);return t},zn={f:In},Nn=z("document","documentElement"),Wn="prototype",Yn="script",Xn=ee("IE_PROTO"),Gn=function(){},Bn=function(t){return"<"+Yn+">"+t+"</"+Yn+">"},Un=function(t){t.write(Bn("")),t.close();var e=t.parentWindow.Object;return t=null,e},Vn=function(){try{Mn=new ActiveXObject("htmlfile")}catch(t){}var t,e,n;Vn="undefined"!=typeof document?document.domain&&Mn?Un(Mn):(e=Pt("iframe"),n="java"+Yn+":",e.style.display="none",Nn.appendChild(e),e.src=String(n),(t=e.contentWindow.document).open(),t.write(Bn("document.F=Object")),t.close(),t.F):Un(Mn);for(var r=je.length;r--;)delete Vn[Wn][je[r]];return Vn()};ne[Xn]=!0;var qn=Object.create||function(t,e){var n;return null!==t?(Gn[Wn]=_t(t),n=new Gn,Gn[Wn]=null,n[Xn]=t):n=Vn(),void 0===e?n:zn.f(n,e)},Hn=Yt.f,$n=wt("unscopables"),Jn=Array.prototype;void 0===Jn[$n]&&Hn(Jn,$n,{configurable:!0,value:qn(null)});var Kn,Qn,Zn,tr=function(t){Jn[$n][t]=!0},er=!l((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),nr=ee("IE_PROTO"),rr=Object,or=rr.prototype,ir=er?rr.getPrototypeOf:function(t){var e=ft(t);if(dt(e,nr))return e[nr];var n=e.constructor;return D(n)&&e instanceof n?n.prototype:e instanceof rr?or:null},ar=wt("iterator"),ur=!1;[].keys&&("next"in(Zn=[].keys())?(Qn=ir(ir(Zn)))!==Object.prototype&&(Kn=Qn):ur=!0);var cr=!I(Kn)||l((function(){var t={};return Kn[ar].call(t)!==t}));cr&&(Kn={}),D(Kn[ar])||fe(Kn,ar,(function(){return this}));var sr={IteratorPrototype:Kn,BUGGY_SAFARI_ITERATORS:ur},fr=Yt.f,lr=wt("toStringTag"),dr=function(t,e,n){t&&!n&&(t=t.prototype),t&&!dt(t,lr)&&fr(t,lr,{configurable:!0,value:e})},hr=sr.IteratorPrototype,pr=function(){return this},vr=String,gr=TypeError,yr=function(t){if(function(t){return I(t)||null===t}(t))return t;throw new gr("Can't set "+vr(t)+" as a prototype")},br=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=function(t,e,n){try{return E(nt(Object.getOwnPropertyDescriptor(t,e)[n]))}catch(t){}}(Object.prototype,"__proto__","set"))(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return F(n),yr(r),I(n)?(e?t(n,r):n.__proto__=r,n):n}}():void 0),mr=Vt.PROPER,wr=Vt.CONFIGURABLE,Or=sr.IteratorPrototype,xr=sr.BUGGY_SAFARI_ITERATORS,Sr=wt("iterator"),Er="keys",Tr="values",jr="entries",Pr=function(){return this},Rr=function(t,e,n,r,o,i,a){!function(t,e,n,r){var o=e+" Iterator";t.prototype=qn(hr,{next:w(+!r,n)}),dr(t,o,!1),mn[o]=pr}(n,e,r);var u,c,s,f=function(t){if(t===o&&g)return g;if(!xr&&t&&t in h)return h[t];switch(t){case Er:case Tr:case jr:return function(){return new n(this,t)}}return function(){return new n(this)}},l=e+" Iterator",d=!1,h=t.prototype,p=h[Sr]||h["@@iterator"]||o&&h[o],g=!xr&&p||f(o),y="Array"===e&&h.entries||p;if(y&&(u=ir(y.call(new t)))!==Object.prototype&&u.next&&(ir(u)!==Or&&(br?br(u,Or):D(u[Sr])||fe(u,Sr,Pr)),dr(u,l,!0)),mr&&o===Tr&&p&&p.name!==Tr&&(wr?Xt(h,"name",Tr):(d=!0,g=function(){return v(p,this)})),o)if(c={values:f(Tr),keys:i?g:f(Er),entries:f(jr)},a)for(s in c)(xr||d||!(s in h))&&fe(h,s,c[s]);else Ye({target:e,proto:!0,forced:xr||d},c);return h[Sr]!==g&&fe(h,Sr,g,{name:o}),mn[e]=g,c},Ar=function(t,e){return{value:t,done:e}},Cr=Yt.f,kr="Array Iterator",Lr=ce.set,Fr=ce.getterFor(kr),_r=Rr(Array,"Array",(function(t,e){Lr(this,{type:kr,target:_(t),index:0,kind:e})}),(function(){var t=Fr(this),e=t.target,n=t.index++;if(!e||n>=e.length)return t.target=null,Ar(void 0,!0);switch(t.kind){case"keys":return Ar(n,!1);case"values":return Ar(e[n],!1)}return Ar([n,e[n]],!1)}),"values"),Mr=mn.Arguments=mn.Array;if(tr("keys"),tr("values"),tr("entries"),d&&"values"!==Mr.name)try{Cr(Mr,"name",{value:"values"})}catch(t){}var Dr=TypeError,Ir=function(t,e){this.stopped=t,this.result=e},zr=Ir.prototype,Nr=function(t,e,n){var r,o,i,a,u,c,s,f=n&&n.that,l=!(!n||!n.AS_ENTRIES),d=!(!n||!n.IS_RECORD),h=!(!n||!n.IS_ITERATOR),p=!(!n||!n.INTERRUPTED),g=Be(e,f),y=function(t){return r&&yn(r,"normal",t),new Ir(!0,t)},b=function(t){return l?(_t(t),p?g(t[0],t[1],y):g(t[0],t[1])):p?g(t,y):g(t)};if(d)r=t.iterator;else if(h)r=t;else{if(!(o=Tn(t)))throw new Dr(tt(t)+" is not iterable");if(xn(o)){for(i=0,a=we(t);a>i;i++)if((u=b(t[i]))&&N(zr,u))return u;return new Ir(!1)}r=Pn(t,o)}for(c=d?t.next:r.next;!(s=v(c,r)).done;){try{u=b(s.value)}catch(t){yn(r,"throw",t)}if("object"==typeof u&&u&&N(zr,u))return u}return new Ir(!1)};Ye({target:"Object",stat:!0},{fromEntries:function(t){var e={};return Nr(t,(function(t,n){Sn(e,t,n)}),{AS_ENTRIES:!0}),e}});var Wr=qe?{}.toString:function(){return"[object "+Ke(this)+"]"};qe||fe(Object.prototype,"toString",Wr,{unsafe:!0});var Yr=E([].slice),Xr=Re.f,Gr="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],Br={f:function(t){return Gr&&"Window"===P(t)?function(t){try{return Xr(t)}catch(t){return Yr(Gr)}}(t):Xr(_(t))}},Ur=l((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})),Vr=Object.isExtensible,qr=l((function(){Vr(1)}))||Ur?function(t){return!!I(t)&&((!Ur||"ArrayBuffer"!==P(t))&&(!Vr||Vr(t)))}:Vr,Hr=!l((function(){return Object.isExtensible(Object.preventExtensions({}))})),$r=a((function(t){var e=Yt.f,n=!1,r=gt("meta"),o=0,i=function(t){e(t,r,{value:{objectID:"O"+o++,weakData:{}}})},a=t.exports={enable:function(){a.enable=function(){},n=!0;var t=Re.f,e=E([].splice),o={};o[r]=1,t(o).length&&(Re.f=function(n){for(var o=t(n),i=0,a=o.length;i<a;i++)if(o[i]===r){e(o,i,1);break}return o},Ye({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:Br.f}))},fastKey:function(t,e){if(!I(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!dt(t,r)){if(!qr(t))return"F";if(!e)return"E";i(t)}return t[r].objectID},getWeakData:function(t,e){if(!dt(t,r)){if(!qr(t))return!0;if(!e)return!1;i(t)}return t[r].weakData},onFreeze:function(t){return Hr&&n&&qr(t)&&!dt(t,r)&&i(t),t}};ne[r]=!0})),Jr=TypeError,Kr=function(t,e){if(N(e,t))return t;throw new Jr("Incorrect invocation")},Qr=function(t,e,n){var r=-1!==t.indexOf("Map"),o=-1!==t.indexOf("Weak"),i=r?"set":"add",a=f[t],u=a&&a.prototype,c=a,s={},d=function(t){var e=E(u[t]);fe(u,t,"add"===t?function(t){return e(this,0===t?0:t),this}:"delete"===t?function(t){return!(o&&!I(t))&&e(this,0===t?0:t)}:"get"===t?function(t){return o&&!I(t)?void 0:e(this,0===t?0:t)}:"has"===t?function(t){return!(o&&!I(t))&&e(this,0===t?0:t)}:function(t,n){return e(this,0===t?0:t,n),this})};if(Ne(t,!D(a)||!(o||u.forEach&&!l((function(){(new a).entries().next()})))))c=n.getConstructor(e,t,r,i),$r.enable();else if(Ne(t,!0)){var h=new c,p=h[i](o?{}:-0,1)!==h,v=l((function(){h.has(1)})),g=Fn((function(t){new a(t)})),y=!o&&l((function(){for(var t=new a,e=5;e--;)t[i](e,e);return!t.has(-0)}));g||((c=e((function(t,e){Kr(t,u);var n=function(t,e,n){var r,o;return br&&D(r=e.constructor)&&r!==n&&I(o=r.prototype)&&o!==n.prototype&&br(t,o),t}(new a,t,c);return k(e)||Nr(e,n[i],{that:n,AS_ENTRIES:r}),n}))).prototype=u,u.constructor=c),(v||y)&&(d("delete"),d("has"),r&&d("get")),(y||p)&&d(i),o&&u.clear&&delete u.clear}return s[t]=c,Ye({global:!0,constructor:!0,forced:c!==a},s),dr(c,t),o||n.setStrong(c,t,r),c},Zr=function(t,e,n){return n.get&&se(n.get,e,{getter:!0}),n.set&&se(n.set,e,{setter:!0}),Yt.f(t,e,n)},to=function(t,e,n){for(var r in e)fe(t,r,e[r],n);return t},eo=wt("species"),no=$r.fastKey,ro=ce.set,oo=ce.getterFor,io={getConstructor:function(t,e,n,r){var o=t((function(t,o){Kr(t,i),ro(t,{type:e,index:qn(null),first:null,last:null,size:0}),d||(t.size=0),k(o)||Nr(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,a=oo(e),u=function(t,e,n){var r,o,i=a(t),u=c(t,e);return u?u.value=n:(i.last=u={index:o=no(e,!0),key:e,value:n,previous:r=i.last,next:null,removed:!1},i.first||(i.first=u),r&&(r.next=u),d?i.size++:t.size++,"F"!==o&&(i.index[o]=u)),t},c=function(t,e){var n,r=a(t),o=no(e);if("F"!==o)return r.index[o];for(n=r.first;n;n=n.next)if(n.key===e)return n};return to(i,{clear:function(){for(var t=a(this),e=t.first;e;)e.removed=!0,e.previous&&(e.previous=e.previous.next=null),e=e.next;t.first=t.last=null,t.index=qn(null),d?t.size=0:this.size=0},delete:function(t){var e=this,n=a(e),r=c(e,t);if(r){var o=r.next,i=r.previous;delete n.index[r.index],r.removed=!0,i&&(i.next=o),o&&(o.previous=i),n.first===r&&(n.first=o),n.last===r&&(n.last=i),d?n.size--:e.size--}return!!r},forEach:function(t){for(var e,n=a(this),r=Be(t,arguments.length>1?arguments[1]:void 0);e=e?e.next:n.first;)for(r(e.value,e.key,this);e&&e.removed;)e=e.previous},has:function(t){return!!c(this,t)}}),to(i,n?{get:function(t){var e=c(this,t);return e&&e.value},set:function(t,e){return u(this,0===t?0:t,e)}}:{add:function(t){return u(this,t=0===t?0:t,t)}}),d&&Zr(i,"size",{configurable:!0,get:function(){return a(this).size}}),o},setStrong:function(t,e,n){var r=e+" Iterator",o=oo(e),i=oo(r);Rr(t,e,(function(t,e){ro(this,{type:r,target:t,state:o(t),kind:e,last:null})}),(function(){for(var t=i(this),e=t.kind,n=t.last;n&&n.removed;)n=n.previous;return t.target&&(t.last=n=n?n.next:t.state.first)?Ar("keys"===e?n.key:"values"===e?n.value:[n.key,n.value],!1):(t.target=null,Ar(void 0,!0))}),n?"entries":"values",!n,!0),function(t){var e=z(t);d&&e&&!e[eo]&&Zr(e,eo,{configurable:!0,get:function(){return this}})}(e)}};Qr("Set",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),io);var ao=String,uo=function(t){if("Symbol"===Ke(t))throw new TypeError("Cannot convert a Symbol value to a string");return ao(t)},co=E("".charAt),so=E("".charCodeAt),fo=E("".slice),lo=function(t){return function(e,n){var r,o,i=uo(F(e)),a=pe(n),u=i.length;return a<0||a>=u?t?"":void 0:(r=so(i,a))<55296||r>56319||a+1===u||(o=so(i,a+1))<56320||o>57343?t?co(i,a):r:t?fo(i,a,a+2):o-56320+(r-55296<<10)+65536}},ho={codeAt:lo(!1),charAt:lo(!0)}.charAt,po="String Iterator",vo=ce.set,go=ce.getterFor(po);Rr(String,"String",(function(t){vo(this,{type:po,string:uo(t),index:0})}),(function(){var t,e=go(this),n=e.string,r=e.index;return r>=n.length?Ar(void 0,!0):(t=ho(n,r),e.index+=t.length,Ar(t,!1))}));var yo,bo=/"/g,mo=E("".replace);Ye({target:"String",proto:!0,forced:(yo="anchor",l((function(){var t=""[yo]('"');return t!==t.toLowerCase()||t.split('"').length>3})))},{anchor:function(t){return e="a",n="name",r=t,o=uo(F(this)),i="<"+e,""!==n&&(i+=" "+n+'="'+mo(uo(r),bo,""")+'"'),i+">"+o+"</"+e+">";var e,n,r,o,i}});var wo=$r.getWeakData,Oo=ce.set,xo=ce.getterFor,So=dn.find,Eo=dn.findIndex,To=E([].splice),jo=0,Po=function(t){return t.frozen||(t.frozen=new Ro)},Ro=function(){this.entries=[]},Ao=function(t,e){return So(t.entries,(function(t){return t[0]===e}))};Ro.prototype={get:function(t){var e=Ao(this,t);if(e)return e[1]},has:function(t){return!!Ao(this,t)},set:function(t,e){var n=Ao(this,t);n?n[1]=e:this.entries.push([t,e])},delete:function(t){var e=Eo(this.entries,(function(e){return e[0]===t}));return~e&&To(this.entries,e,1),!!~e}};var Co,ko={getConstructor:function(t,e,n,r){var o=t((function(t,o){Kr(t,i),Oo(t,{type:e,id:jo++,frozen:null}),k(o)||Nr(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,a=xo(e),u=function(t,e,n){var r=a(t),o=wo(_t(e),!0);return!0===o?Po(r).set(e,n):o[r.id]=n,t};return to(i,{delete:function(t){var e=a(this);if(!I(t))return!1;var n=wo(t);return!0===n?Po(e).delete(t):n&&dt(n,e.id)&&delete n[e.id]},has:function(t){var e=a(this);if(!I(t))return!1;var n=wo(t);return!0===n?Po(e).has(t):n&&dt(n,e.id)}}),to(i,n?{get:function(t){var e=a(this);if(I(t)){var n=wo(t);if(!0===n)return Po(e).get(t);if(n)return n[e.id]}},set:function(t,e){return u(this,t,e)}}:{add:function(t){return u(this,t,!0)}}),o}},Lo=ce.enforce,Fo=Object,_o=Array.isArray,Mo=Fo.isExtensible,Do=Fo.isFrozen,Io=Fo.isSealed,zo=Fo.freeze,No=Fo.seal,Wo=!f.ActiveXObject&&"ActiveXObject"in f,Yo=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Xo=Qr("WeakMap",Yo,ko),Go=Xo.prototype,Bo=E(Go.set);if(Zt)if(Wo){Co=ko.getConstructor(Yo,"WeakMap",!0),$r.enable();var Uo=E(Go.delete),Vo=E(Go.has),qo=E(Go.get);to(Go,{delete:function(t){if(I(t)&&!Mo(t)){var e=Lo(this);return e.frozen||(e.frozen=new Co),Uo(this,t)||e.frozen.delete(t)}return Uo(this,t)},has:function(t){if(I(t)&&!Mo(t)){var e=Lo(this);return e.frozen||(e.frozen=new Co),Vo(this,t)||e.frozen.has(t)}return Vo(this,t)},get:function(t){if(I(t)&&!Mo(t)){var e=Lo(this);return e.frozen||(e.frozen=new Co),Vo(this,t)?qo(this,t):e.frozen.get(t)}return qo(this,t)},set:function(t,e){if(I(t)&&!Mo(t)){var n=Lo(this);n.frozen||(n.frozen=new Co),Vo(this,t)?Bo(this,t,e):n.frozen.set(t,e)}else Bo(this,t,e);return this}})}else Hr&&l((function(){var t=zo([]);return Bo(new Xo,t,1),!Do(t)}))&&to(Go,{set:function(t,e){var n;return _o(t)&&(Do(t)?n=zo:Io(t)&&(n=No)),Bo(this,t,e),n&&n(t),this}});var Ho={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},$o=Pt("span").classList,Jo=$o&&$o.constructor&&$o.constructor.prototype,Ko=Jo===Object.prototype?void 0:Jo,Qo=dn.forEach,Zo=function(t,e){var n=[][t];return!!n&&l((function(){n.call(null,e||function(){return 1},1)}))}("forEach"),ti=Zo?[].forEach:function(t){return Qo(this,t,arguments.length>1?arguments[1]:void 0)},ei=function(t){if(t&&t.forEach!==ti)try{Xt(t,"forEach",ti)}catch(e){t.forEach=ti}};for(var ni in Ho)Ho[ni]&&ei(f[ni]&&f[ni].prototype);ei(Ko);var ri=wt("iterator"),oi=_r.values,ii=function(t,e){if(t){if(t[ri]!==oi)try{Xt(t,ri,oi)}catch(e){t[ri]=oi}if(dr(t,e,!0),Ho[e])for(var n in _r)if(t[n]!==_r[n])try{Xt(t,n,_r[n])}catch(e){t[n]=_r[n]}}};for(var ai in Ho)ii(f[ai]&&f[ai].prototype,ai);ii(Ko,"DOMTokenList");var ui=function(){return ui=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ui.apply(this,arguments)};function ci(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}function si(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function fi(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)a.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return a}function li(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var di=TypeError,hi=function(t){if(t>9007199254740991)throw di("Maximum allowed index exceeded");return t},pi=wt("isConcatSpreadable"),vi=q>=51||!l((function(){var t=[];return t[pi]=!1,t.concat()[0]!==t})),gi=function(t){if(!I(t))return!1;var e=t[pi];return void 0!==e?!!e:Ue(t)},yi=!vi||!pn("concat");Ye({target:"Array",proto:!0,arity:1,forced:yi},{concat:function(t){var e,n,r,o,i,a=ft(this),u=sn(a,0),c=0;for(e=-1,r=arguments.length;e<r;e++)if(gi(i=-1===e?a:arguments[e]))for(o=we(i),hi(c+o),n=0;n<o;n++,c++)n in i&&Sn(u,c,i[n]);else hi(c+1),Sn(u,c++,i);return u.length=c,u}});var bi=dn.map,mi=pn("map");Ye({target:"Array",proto:!0,forced:!mi},{map:function(t){return bi(this,t,arguments.length>1?arguments[1]:void 0)}});var wi=pn("slice"),Oi=wt("species"),xi=Array,Si=Math.max;Ye({target:"Array",proto:!0,forced:!wi},{slice:function(t,e){var n,r,o,i=_(this),a=we(i),u=ye(t,a),c=ye(void 0===e?a:e,a);if(Ue(i)&&(n=i.constructor,(an(n)&&(n===xi||Ue(n.prototype))||I(n)&&null===(n=n[Oi]))&&(n=void 0),n===xi||void 0===n))return Yr(i,u,c);for(r=new(void 0===n?xi:n)(Si(c-u,0)),o=0;u<c;u++,o++)u in i&&Sn(r,o,i[u]);return r.length=o,r}});var Ei=Object.assign,Ti=Object.defineProperty,ji=E([].concat),Pi=!Ei||l((function(){if(d&&1!==Ei({b:1},Ei(Ti({},"a",{enumerable:!0,get:function(){Ti(this,"b",{value:3,enumerable:!1})}}),{b:2})).b)return!0;var t={},e={},n=Symbol("assign detection"),r="abcdefghijklmnopqrst";return t[n]=7,r.split("").forEach((function(t){e[t]=t})),7!==Ei({},t)[n]||Dn(Ei({},e)).join("")!==r}))?function(t,e){for(var n=ft(t),r=arguments.length,o=1,i=Ae.f,a=m.f;r>o;)for(var u,c=C(arguments[o++]),s=i?ji(Dn(c),i(c)):Dn(c),f=s.length,l=0;f>l;)u=s[l++],d&&!v(a,c,u)||(n[u]=c[u]);return n}:Ei;Ye({target:"Object",stat:!0,arity:2,forced:Object.assign!==Pi},{assign:Pi});var Ri=m.f,Ai=E(Ri),Ci=E([].push),ki=d&&l((function(){var t=Object.create(null);return t[2]=2,!Ai(t,2)})),Li=function(t){return function(e){for(var n,r=_(e),o=Dn(r),i=ki&&null===ir(r),a=o.length,u=0,c=[];a>u;)n=o[u++],d&&!(i?n in r:Ai(r,n))||Ci(c,t?[n,r[n]]:r[n]);return c}},Fi={entries:Li(!0),values:Li(!1)}.entries;Ye({target:"Object",stat:!0},{entries:function(t){return Fi(t)}});var _i=function(){var t=_t(this),e="";return t.hasIndices&&(e+="d"),t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.unicodeSets&&(e+="v"),t.sticky&&(e+="y"),e},Mi=RegExp.prototype,Di=Vt.PROPER,Ii="toString",zi=RegExp.prototype,Ni=zi[Ii],Wi=l((function(){return"/a/b"!==Ni.call({source:"a",flags:"b"})})),Yi=Di&&Ni.name!==Ii;(Wi||Yi)&&fe(zi,Ii,(function(){var t=_t(this),e=uo(t.source),n=uo(function(t){var e=t.flags;return void 0!==e||"flags"in Mi||dt(t,"flags")||!N(Mi,t)?e:v(_i,t)}(t));return"/"+e+"/"+n}),{unsafe:!0});var Xi,Gi=wt("match"),Bi=TypeError,Ui=function(t){if(function(t){var e;return I(t)&&(void 0!==(e=t[Gi])?!!e:"RegExp"===P(t))}(t))throw new Bi("The method doesn't accept regular expressions");return t},Vi=wt("match"),qi=Ct.f,Hi=Xe("".slice),$i=Math.min,Ji=function(t){var e=/./;try{"/./"[t](e)}catch(n){try{return e[Vi]=!1,"/./"[t](e)}catch(t){}}return!1}("startsWith"),Ki=!(Ji||(Xi=qi(String.prototype,"startsWith"),!Xi||Xi.writable));Ye({target:"String",proto:!0,forced:!Ki&&!Ji},{startsWith:function(t){var e=uo(F(this));Ui(t);var n=me($i(arguments.length>1?arguments[1]:void 0,e.length)),r=uo(t);return Hi(e,n,n+r.length)===r}});var Qi=xe.includes,Zi=l((function(){return!Array(1).includes()}));function ta(t){return"[object Object]"===Object.prototype.toString.call(t)}function ea(t){if(!ta(t))return!1;var e=t.constructor;if(void 0===e)return!0;var n=e.prototype;return!1!==ta(n)&&!Object.prototype.hasOwnProperty.call(n,"isPrototypeOfOf")}function na(t,e){for(var n in t){var r=t[n],o=e[n];if(ea(r)&&ea(o)){if(!na(r,o))return!1}else if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(var i=0;i<r.length;i+=1)if(r[i]!==o[i])return!1}else if(r!==o)return!1}for(var n in e)if(void 0===t[n]&&void 0!==e[n])return!1;return!0}function ra(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return Object.fromEntries(Object.entries(t).filter((function(t){var n=fi(t,1)[0];return e.includes(n)})))}function oa(t){return function(t){var e,n,r,o,i=[];try{for(var a=si(t),u=a.next();!u.done;u=a.next()){var c=u.value;if("string"!=typeof c.insert||0!==c.insert.length){var s=i[i.length-1];s&&"string"==typeof s.insert&&"string"==typeof c.insert&&(s.attributes===c.attributes||!s.attributes==!c.attributes&&na(null!==(r=s.attributes)&&void 0!==r?r:{},null!==(o=c.attributes)&&void 0!==o?o:{}))?s.insert+=c.insert:i.push(c)}}}catch(t){e={error:t}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(e)throw e.error}}return i}(t.toDelta())}function ia(t){var e=t.insert;return"string"==typeof e?e.length:1}function aa(t){return t.reduce((function(t,e){return t+ia(e)}),0)}function ua(t,e,n){if(n<1)return[];for(var r=0,o=[],i=e+n,a=0;a<t.length&&!(r>=i);a+=1){var u=t[a],c=ia(u);if(r+c<=e)r+=c;else if("string"==typeof u.insert){var s=Math.max(0,e-r),f=Math.min(c,c-(r+c-i));o.push(ui(ui({},u),{insert:u.insert.slice(s,f)})),r+=c}else r+=c,o.push(u)}return o}function ca(t){return t?n.Text.isText(t)?t.text.length:1:0}function sa(t,e,r){var i;if(0===r.length)throw new Error("Path has to a have a length >= 1");if(n.Text.isText(e))throw new Error("Cannot descent into slate text");var a=fi(r),u=a[0],c=a.slice(1),s=function(t,e){return t.children.slice(0,e).reduce((function(t,e){return t+ca(e)}),0)}(e,u),f=e.children[u],l=oa(t),d=ca(f),h=ua(l,s,d);if(h.length>1)throw new Error("Path doesn't match yText, yTarget spans multiple nodes");var p=null===(i=h[0])||void 0===i?void 0:i.insert;if(c.length>0){if(!(p instanceof o.XmlText))throw new Error("Path doesn't match yText, cannot descent into non-yText");return sa(p,f,c)}return{yParent:t,textRange:{start:s,end:s+d},yTarget:p instanceof o.XmlText?p:void 0,slateParent:e,slateTarget:f,targetDelta:h}}function fa(t,e,r){void 0===r&&(r={});for(var o=r.assoc,i=void 0===o?0:o,a=r.insert,u=void 0!==a&&a,c=0,s=0,f=0;f<t.children.length;f+=1){var l=t.children[f],d=n.Text.isText(l)?l.text.length:1;d>0&&(s=f);var h=c+d;if(d>0&&(i>=0?h>e:h>=e))return[f,e-c];c+=d}if(e>c+(u?1:0))throw new Error("yOffset out of bounds");if(u)return[t.children.length,0];var p=t.children[s];return[s,n.Text.isText(p)?p.text.length:1]}function la(t,e,r){for(var i=[r];i[0]!==t;){var a=i[0].parent;if(!a)throw new Error("yText isn't a descendant of root element");if(!(a instanceof o.XmlText))throw new Error("Unexpected y parent type");i.unshift(a)}if(i.length<2)return[];var u=e;return i.reduce((function(t,e,r){var o,a,c=i[r+1];if(!c)return t;var s=0,f=oa(e);try{for(var l=si(f),d=l.next();!d.done;d=l.next()){var h=d.value;if(h.insert===c)break;s+="string"==typeof h.insert?h.insert.length:1}}catch(t){o={error:t}}finally{try{d&&!d.done&&(a=l.return)&&a.call(l)}finally{if(o)throw o.error}}if(n.Text.isText(u))throw new Error("Cannot descent into slate text");var p=fi(fa(u,s),1)[0];return u=u.children[p],t.concat(p)}),[])}function da(t){if(!t.doc)throw new Error("shared type isn't attached to a document")}Ye({target:"Array",proto:!0,forced:Zi},{includes:function(t){return Qi(this,t,arguments.length>1?arguments[1]:void 0)}}),tr("includes");var ha="__slateYjsStoredPosition_";function pa(t,e,n){var r=sa(t,e,n.path),i=r.yTarget,a=r.yParent,u=r.textRange;if(i)throw new Error("Slate point points to a non-text element inside sharedRoot");var c=u.start+n.offset;return o.createRelativePositionFromTypeIndex(a,c,c===u.end?-1:0)}function va(t,e,r){if(!t.doc)throw new Error("sharedRoot isn't attach to a yDoc");var i=o.createAbsolutePositionFromRelativePosition(r,t.doc);return i&&function(t,e,r){var i=r.type,a=r.index,u=r.assoc;if(!(i instanceof o.XmlText))throw new Error("Absolute position points to a non-XMLText");var c=la(t,e,i),s=n.Node.get(e,c);if(n.Text.isText(s))throw new Error("Absolute position doesn't match slateRoot, cannot descent into text");var f=fi(fa(s,a,{assoc:u}),2),l=f[0],d=f[1],h=s.children[l];return n.Text.isText(h)?{path:li(li([],fi(c),!1),[l],!1),offset:d}:null}(t,e,i)}function ga(t,e,n){t.setAttribute(ha+e,o.encodeRelativePosition(n))}function ya(t,e,n){return Object.fromEntries(Object.entries(t).filter((function(t){var r=fi(t,2)[1];return r.type===e&&(!n||(r.assoc>=0?r.index>=n.start&&r.index<n.end:r.index>n.start&&r.index>=n.end))})))}function ba(t,e,n){var r;void 0===n&&(n="");var i=((r={})[n]=ya(t,e),r);return oa(e).forEach((function(e,r){var a=e.insert;a instanceof o.XmlText&&Object.assign(i,ba(t,a,n?"".concat(n,".").concat(r):r.toString()))})),i}function ma(t,e,n,r){void 0===r&&(r=0);var i=function(t){return da(t),Object.fromEntries(Object.entries(t.getAttributes()).filter((function(t){return fi(t,1)[0].startsWith(ha)})).map((function(e){var n=fi(e,2),r=n[0],i=n[1];return[r.slice(ha.length),o.createAbsolutePositionFromRelativePosition(o.decodeRelativePosition(i),t.doc)]})).filter((function(t){return fi(t,2)[1]})))}(t),a={"":ya(i,e,{start:r,end:r+aa(n)})};return n.forEach((function(t,e){var n=t.insert;n instanceof o.XmlText&&Object.assign(a,ba(i,n,e.toString()))})),a}function wa(t,e,n,r,i,a,u){void 0===i&&(i=0),void 0===a&&(a=0),void 0===u&&(u="");var c=n[u];c&&Object.entries(c).forEach((function(n){var r=fi(n,2),u=r[0],c=r[1];ga(t,u,o.createRelativePositionFromTypeIndex(e,c.index-a+i,c.assoc))})),r.forEach((function(e,r){var i=e.insert;i instanceof o.XmlText&&wa(t,i,n,oa(i),0,0,u?"".concat(u,".").concat(r):r.toString())}))}function Oa(t,e,n){return{anchor:pa(t,e,n.anchor),focus:pa(t,e,n.focus)}}function xa(t,e,n){var r=va(t,e,n.anchor);if(!r)return null;var o=va(t,e,n.focus);return o?{anchor:r,focus:o}:null}var Sa={f:wt},Ea=f,Ta=Yt.f,ja=dn.forEach,Pa=ee("hidden"),Ra="Symbol",Aa="prototype",Ca=ce.set,ka=ce.getterFor(Ra),La=Object[Aa],Fa=f.Symbol,_a=Fa&&Fa[Aa],Ma=f.RangeError,Da=f.TypeError,Ia=f.QObject,za=Ct.f,Na=Yt.f,Wa=Br.f,Ya=m.f,Xa=E([].push),Ga=ct("symbols"),Ba=ct("op-symbols"),Ua=ct("wks"),Va=!Ia||!Ia[Aa]||!Ia[Aa].findChild,qa=function(t,e,n){var r=za(La,e);r&&delete La[e],Na(t,e,n),r&&t!==La&&Na(La,e,r)},Ha=d&&l((function(){return 7!==qn(Na({},"a",{get:function(){return Na(this,"a",{value:7}).a}})).a}))?qa:Na,$a=function(t,e){var n=Ga[t]=qn(_a);return Ca(n,{type:Ra,tag:t,description:e}),d||(n.description=e),n},Ja=function(t,e,n){t===La&&Ja(Ba,e,n),_t(t);var r=Et(e);return _t(n),dt(Ga,r)?(n.enumerable?(dt(t,Pa)&&t[Pa][r]&&(t[Pa][r]=!1),n=qn(n,{enumerable:w(0,!1)})):(dt(t,Pa)||Na(t,Pa,w(1,qn(null))),t[Pa][r]=!0),Ha(t,r,n)):Na(t,r,n)},Ka=function(t,e){_t(t);var n=_(e),r=Dn(n).concat(eu(n));return ja(r,(function(e){d&&!v(Qa,n,e)||Ja(t,e,n[e])})),t},Qa=function(t){var e=Et(t),n=v(Ya,this,e);return!(this===La&&dt(Ga,e)&&!dt(Ba,e))&&(!(n||!dt(this,e)||!dt(Ga,e)||dt(this,Pa)&&this[Pa][e])||n)},Za=function(t,e){var n=_(t),r=Et(e);if(n!==La||!dt(Ga,r)||dt(Ba,r)){var o=za(n,r);return!o||!dt(Ga,r)||dt(n,Pa)&&n[Pa][r]||(o.enumerable=!0),o}},tu=function(t){var e=Wa(_(t)),n=[];return ja(e,(function(t){dt(Ga,t)||dt(ne,t)||Xa(n,t)})),n},eu=function(t){var e=t===La,n=Wa(e?Ba:_(t)),r=[];return ja(n,(function(t){!dt(Ga,t)||e&&!dt(La,t)||Xa(r,Ga[t])})),r};$||(Fa=function(){if(N(_a,this))throw new Da("Symbol is not a constructor");var t=arguments.length&&void 0!==arguments[0]?uo(arguments[0]):void 0,e=gt(t),n=function(t){var r=void 0===this?f:this;r===La&&v(n,Ba,t),dt(r,Pa)&&dt(r[Pa],e)&&(r[Pa][e]=!1);var o=w(1,t);try{Ha(r,e,o)}catch(t){if(!(t instanceof Ma))throw t;qa(r,e,o)}};return d&&Va&&Ha(La,e,{configurable:!0,set:n}),$a(e,t)},_a=Fa[Aa],fe(_a,"toString",(function(){return ka(this).tag})),fe(Fa,"withoutSetter",(function(t){return $a(gt(t),t)})),m.f=Qa,Yt.f=Ja,zn.f=Ka,Ct.f=Za,Re.f=Br.f=tu,Ae.f=eu,Sa.f=function(t){return $a(wt(t),t)},d&&(Zr(_a,"description",{configurable:!0,get:function(){return ka(this).description}}),fe(La,"propertyIsEnumerable",Qa,{unsafe:!0}))),Ye({global:!0,constructor:!0,wrap:!0,forced:!$,sham:!$},{Symbol:Fa}),ja(Dn(Ua),(function(t){!function(t){var e=Ea.Symbol||(Ea.Symbol={});dt(e,t)||Ta(e,t,{value:Sa.f(t)})}(t)})),Ye({target:Ra,stat:!0,forced:!$},{useSetter:function(){Va=!0},useSimple:function(){Va=!1}}),Ye({target:"Object",stat:!0,forced:!$,sham:!d},{create:function(t,e){return void 0===e?qn(t):Ka(qn(t),e)},defineProperty:Ja,defineProperties:Ka,getOwnPropertyDescriptor:Za}),Ye({target:"Object",stat:!0,forced:!$},{getOwnPropertyNames:tu}),function(){var t=z("Symbol"),e=t&&t.prototype,n=e&&e.valueOf,r=wt("toPrimitive");e&&!e[r]&&fe(e,r,(function(t){return v(n,this)}),{arity:1})}(),dr(Fa,Ra),ne[Pa]=!0;var nu=$&&!!Symbol.for&&!!Symbol.keyFor,ru=ct("string-to-symbol-registry"),ou=ct("symbol-to-string-registry");Ye({target:"Symbol",stat:!0,forced:!nu},{for:function(t){var e=uo(t);if(dt(ru,e))return ru[e];var n=z("Symbol")(e);return ru[e]=n,ou[n]=e,n}});var iu=ct("symbol-to-string-registry");Ye({target:"Symbol",stat:!0,forced:!nu},{keyFor:function(t){if(!Q(t))throw new TypeError(tt(t)+" is not a symbol");if(dt(iu,t))return iu[t]}});var au=Function.prototype,uu=au.apply,cu=au.call,su="object"==typeof Reflect&&Reflect.apply||(h?cu.bind(uu):function(){return cu.apply(uu,arguments)}),fu=E([].push),lu=String,du=z("JSON","stringify"),hu=E(/./.exec),pu=E("".charAt),vu=E("".charCodeAt),gu=E("".replace),yu=E(1..toString),bu=/[\uD800-\uDFFF]/g,mu=/^[\uD800-\uDBFF]$/,wu=/^[\uDC00-\uDFFF]$/,Ou=!$||l((function(){var t=z("Symbol")("stringify detection");return"[null]"!==du([t])||"{}"!==du({a:t})||"{}"!==du(Object(t))})),xu=l((function(){return'"\\udf06\\ud834"'!==du("\udf06\ud834")||'"\\udead"'!==du("\udead")})),Su=function(t,e){var n=Yr(arguments),r=function(t){if(D(t))return t;if(Ue(t)){for(var e=t.length,n=[],r=0;r<e;r++){var o=t[r];"string"==typeof o?fu(n,o):"number"!=typeof o&&"Number"!==P(o)&&"String"!==P(o)||fu(n,uo(o))}var i=n.length,a=!0;return function(t,e){if(a)return a=!1,e;if(Ue(this))return e;for(var r=0;r<i;r++)if(n[r]===t)return e}}}(e);if(D(r)||void 0!==t&&!Q(t))return n[1]=function(t,e){if(D(r)&&(e=v(r,this,lu(t),e)),!Q(e))return e},su(du,null,n)},Eu=function(t,e,n){var r=pu(n,e-1),o=pu(n,e+1);return hu(mu,t)&&!hu(wu,o)||hu(wu,t)&&!hu(mu,r)?"\\u"+yu(vu(t,0),16):t};du&&Ye({target:"JSON",stat:!0,arity:3,forced:Ou||xu},{stringify:function(t,e,n){var r=Yr(arguments),o=su(Ou?Su:du,null,r);return xu&&"string"==typeof o?gu(o,bu,Eu):o}});var Tu=!$||l((function(){Ae.f(1)}));Ye({target:"Object",stat:!0,forced:Tu},{getOwnPropertySymbols:function(t){var e=Ae.f;return e?e(ft(t)):[]}});var ju=f.Symbol,Pu=ju&&ju.prototype;if(d&&D(ju)&&(!("description"in Pu)||void 0!==ju().description)){var Ru={},Au=function(){var t=arguments.length<1||void 0===arguments[0]?void 0:uo(arguments[0]),e=N(Pu,this)?new ju(t):void 0===t?ju():ju(t);return""===t&&(Ru[e]=!0),e};Le(Au,ju),Au.prototype=Pu,Pu.constructor=Au;var Cu="Symbol(description detection)"===String(ju("description detection")),ku=E(Pu.valueOf),Lu=E(Pu.toString),Fu=/^Symbol\((.*)\)[^)]+$/,_u=E("".replace),Mu=E("".slice);Zr(Pu,"description",{configurable:!0,get:function(){var t=ku(this);if(dt(Ru,t))return"";var e=Lu(t),n=Cu?Mu(e,7,-1):_u(e,Fu,"$1");return""===n?void 0:n}}),Ye({global:!0,constructor:!0,forced:!0},{Symbol:Au})}Qr("WeakSet",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),ko);var Du=l((function(){Dn(1)}));function Iu(t){return function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return Object.fromEntries(Object.entries(t).filter((function(t){var n=fi(t,1)[0];return!e.includes(n)})))}(t,n.Text.isText(t)?"text":"children")}function zu(t){var e=oa(t),n=e.length>0?e.map(Nu):[{text:""}];return ui(ui({},t.getAttributes()),{children:n})}function Nu(t){return"string"==typeof t.insert?ui(ui({},t.attributes),{text:t.insert}):zu(t.insert)}function Wu(t){return t.map((function(t){return n.Text.isText(t)?{insert:t.text,attributes:Iu(t)}:{insert:Yu(t)}}))}function Yu(t){var e=t.children,n=ci(t,["children"]),r=new o.XmlText;return Object.entries(n).forEach((function(t){var e=fi(t,2),n=e[0],o=e[1];r.setAttribute(n,o)})),r.applyDelta(Wu(e),{sanitize:!1}),r}function Xu(t,e,r){var i=r.target,a=r.changes,u=r.delta;if(!(i instanceof o.XmlText))throw new Error("Unexpected target node type");var c=[],s=la(t,e,i),f=n.Node.get(e,s);if(n.Text.isText(f))throw new Error("Cannot apply yTextEvent to text node");var l=Array.from(a.keys.entries());if(s.length>0&&l.length>0){var d=Object.fromEntries(l.map((function(t){var e=fi(t,2),n=e[0];return[n,"delete"===e[1].action?null:i.getAttribute(n)]}))),h=Object.fromEntries(l.map((function(t){var e=fi(t,1)[0];return[e,f[e]]})));c.push({type:"set_node",newProperties:d,properties:h,path:s})}return u.length>0&&c.push.apply(c,li([],fi(function(t,e,r){var o=[],i=r.reduce((function(t,e){return"retain"in e?t+e.retain:"delete"in e?t+e.delete:t}),0);return r.reverse().forEach((function(r){var a,u;if("attributes"in r&&"retain"in r)for(var c=fi(fa(t,i-r.retain),2),s=c[0],f=c[1],l=fi(fa(t,i,{assoc:-1}),2),d=l[0],h=l[1],p=d;p>=s;p-=1){var v=t.children[p],g=li(li([],fi(e),!1),[p],!1);if(n.Text.isText(v)){var y=r.attributes,b=ra.apply(void 0,li([t],fi(Object.keys(r.attributes)),!1));if(p===s||p===d){var m=p===s?f:0;if((x=p===d?h:v.text.length)!==v.text.length&&o.push({type:"split_node",path:g,position:x,properties:Iu(v)}),0!==m){o.push({type:"split_node",path:g,position:m,properties:(u=ui(ui({},Iu(v)),y),Object.fromEntries(Object.entries(u).filter((function(t){return null!==fi(t,2)[1]}))))});continue}}o.push({type:"set_node",newProperties:y,path:g,properties:b})}}if("retain"in r&&(i-=r.retain),"delete"in r){var w=fi(fa(t,i-r.delete),2),O=(s=w[0],f=w[1],fi(fa(t,i,{assoc:-1}),2));for(d=O[0],p=0===(h=O[1])?d-1:d;p>=s;p-=1)if(v=t.children[p],g=li(li([],fi(e),!1),[p],!1),!n.Text.isText(v)||p!==s&&p!==d)o.push({type:"remove_node",node:v,path:g}),i-=ca(v);else{m=p===s?f:0;var x=p===d?h:v.text.length;o.push({type:"remove_text",offset:m,text:v.text.slice(m,x),path:g}),i-=x-m}}else if("insert"in r){var S=fi(fa(t,i,{insert:!0}),2),E=(p=S[0],S[1]);if(v=t.children[p],g=li(li([],fi(e),!1),[p],!1),n.Text.isText(v)){var T=o[o.length-1],j=null!=T&&"insert_node"===T.type?T.node:Iu(v),P=[];if(null==T||"insert_node"!==T.type&&"insert_text"!==T.type&&"split_node"!==T.type&&"set_node"!==T.type||(P=T.path),"string"==typeof r.insert&&na(null!==(a=r.attributes)&&void 0!==a?a:{},j)&&n.Path.equals(g,P))return o.push({type:"insert_text",offset:E,text:r.insert,path:g});var R=Nu(r);return 0===E?o.push({type:"insert_node",path:g,node:R}):(E<v.text.length&&o.push({type:"split_node",path:g,position:E,properties:Iu(v)}),o.push({type:"insert_node",path:n.Path.next(g),node:R}))}return o.push({type:"insert_node",path:g,node:Nu(r)})}})),o}(f,s,u)),!1)),c}function Gu(t,e,r){n.Editor.withoutNormalizing(e,(function(){r.forEach((function(n){(function(t,e,n){if(n instanceof o.YTextEvent)return Xu(t,e,n);throw new Error("Unexpected Y event type")})(t,e,n).forEach((function(t){e.apply(t)}))}))}))}function Bu(t){return t.map((function(t){return"string"==typeof t.insert?t:ui(ui({},t),{insert:Uu(t.insert)})}))}function Uu(t){var e=new o.XmlText,n=t.getAttributes();return Object.entries(n).forEach((function(t){var n=fi(t,2),r=n[0],o=n[1];e.setAttribute(r,o)})),e.applyDelta(Bu(oa(t)),{sanitize:!1}),e}Ye({target:"Object",stat:!0,forced:Du},{keys:function(t){return Dn(ft(t))}});var Vu={insert_node:function(t,e,r){var o=sa(t,e,r.path),i=o.yParent,a=o.textRange;if(n.Text.isText(r.node))return i.insert(a.start,r.node.text,Iu(r.node));i.insertEmbed(a.start,Yu(r.node))},remove_node:function(t,e,n){var r=sa(t,e,n.path),o=r.yParent,i=r.textRange;o.delete(i.start,i.end-i.start)},set_node:function(t,e,n){var r=sa(t,e,n.path),o=r.yTarget,i=r.textRange,a=r.yParent;if(o)return Object.entries(n.newProperties).forEach((function(t){var e=fi(t,2),n=e[0],r=e[1];if(null===r)return o.removeAttribute(n);o.setAttribute(n,r)})),Object.entries(n.properties).forEach((function(t){var e=fi(t,1)[0];Object.prototype.hasOwnProperty.call(n.newProperties,e)||o.removeAttribute(e)}));var u=Object.fromEntries(Object.keys(n.properties).map((function(t){return[t,null]}))),c=ui(ui({},u),n.newProperties);a.format(i.start,i.end-i.start,c)},merge_node:function(t,e,r){var o=sa(t,e,r.path),i=sa(o.yParent,o.slateParent,n.Path.previous(r.path.slice(-1)));if(!o.yTarget!=!i.yTarget)throw new Error("Cannot merge y text with y element");if(!i.yTarget||!o.yTarget){var a=o.yParent,u=o.textRange,c=o.slateTarget;if(!c)throw new Error("Expected Slate target node for merge op.");var s=n.Node.get(e,n.Path.previous(r.path));if(!n.Text.isText(s))throw new Error("Path points to Y.Text but not a Slate text node.");var f=Iu(c),l=Iu(s),d=Object.keys(f).reduce((function(t,e){var n;return e in l?t:ui(ui({},t),((n={})[e]=null,n))}),{});return a.format(u.start,u.end-u.start,ui(ui({},d),l))}var h=i.yTarget.length,p=oa(o.yTarget),v=Bu(p),g=ma(t,o.yTarget,p,h),y=li([{retain:h}],fi(v),!1);i.yTarget.applyDelta(y,{sanitize:!1}),o.yParent.delete(o.textRange.start,o.textRange.end-o.textRange.start),wa(t,i.yTarget,g,v,h)},move_node:function(t,e,r){var o=n.Path.parent(r.newPath),i=r.newPath[r.newPath.length-1],a=n.Node.get(e,o);if(n.Text.isText(a))throw new Error("Cannot move slate node into text element");var u=li(li([],fi(o),!1),[Math.min(i,a.children.length)],!1),c=sa(t,e,r.path),s=sa(t,e,u),f=Bu(c.targetDelta),l=ma(t,c.yParent,c.targetDelta);c.yParent.delete(c.textRange.start,c.textRange.end-c.textRange.start);var d=aa(oa(s.yParent)),h=Math.min(s.textRange.start,d),p=li([{retain:h}],fi(f),!1);s.yParent.applyDelta(p,{sanitize:!1}),wa(t,s.yParent,l,f,h,c.textRange.start)},split_node:function(t,e,r){var i=sa(t,e,r.path);if(!i.slateTarget)throw new Error("Y target without corresponding slate node");if(!i.yTarget){if(!n.Text.isText(i.slateTarget))throw new Error("Mismatch node type between y target and slate node");var a={};return i.targetDelta.forEach((function(t){t.attributes&&Object.keys(t.attributes).forEach((function(t){a[t]=null}))})),i.yParent.format(i.textRange.start,i.textRange.end-i.textRange.start,ui(ui({},a),r.properties))}if(n.Text.isText(i.slateTarget))throw new Error("Mismatch node type between y target and slate node");var u=sa(i.yTarget,i.slateTarget,[r.position]),c=i.slateTarget.children.slice(0,r.position).reduce((function(t,e){return t+ca(e)}),0),s=i.slateTarget.children.reduce((function(t,e){return t+ca(e)}),0),f=ua(oa(i.yTarget),c,s-c),l=Bu(f),d=ma(t,i.yTarget,f,c),h=new o.XmlText;h.applyDelta(l,{sanitize:!1}),Object.entries(r.properties).forEach((function(t){var e=fi(t,2),n=e[0],r=e[1];h.setAttribute(n,r)})),i.yTarget.delete(u.textRange.start,i.yTarget.length-u.textRange.start),i.yParent.insertEmbed(i.textRange.end,h),wa(t,h,d,l,0,c)}};var qu=ui(ui(ui({},{insert_text:function(t,e,r){var o=sa(t,e,r.path),i=o.yParent,a=o.textRange,u=n.Node.get(e,r.path);if(!n.Text.isText(u))throw new Error("Cannot insert text into non-text node");i.insert(a.start+r.offset,r.text,Iu(u))},remove_text:function(t,e,n){var r=sa(t,e,n.path),o=r.yParent,i=r.textRange;o.delete(i.start+n.offset,n.text.length)}}),Vu),{set_selection:function(){}});var Hu=Symbol("slate-yjs-operation"),$u=Symbol("slate-yjs-position-storage"),Ju=new WeakMap,Ku=new WeakMap,Qu=new WeakSet,Zu={isYjsEditor:function(t){return n.Editor.isEditor(t)&&t.sharedRoot instanceof o.XmlText&&"localOrigin"in t&&"positionStorageOrigin"in t&&"function"==typeof t.applyRemoteEvents&&"function"==typeof t.storeLocalChange&&"function"==typeof t.flushLocalChanges&&"function"==typeof t.isLocalOrigin&&"function"==typeof t.connect&&"function"==typeof t.disconnect},localChanges:function(t){var e;return null!==(e=Ku.get(t))&&void 0!==e?e:[]},applyRemoteEvents:function(t,e,n){t.applyRemoteEvents(e,n)},storeLocalChange:function(t,e){t.storeLocalChange(e)},flushLocalChanges:function(t){t.flushLocalChanges()},connected:function(t){return Qu.has(t)},connect:function(t){t.connect()},disconnect:function(t){t.disconnect()},isLocal:function(t){return t.isLocalOrigin(Zu.origin(t))},origin:function(t){var e=Ju.get(t);return void 0!==e?e:t.localOrigin},withOrigin:function(t,e,n){var r=Zu.origin(t);Ju.set(t,e),n(),Ju.set(t,r)},storePosition:function(t,e,n){var r=t.sharedRoot,o=t.positionStorageOrigin;da(r);var i=pa(r,t,n);r.doc.transact((function(){ga(r,e,i)}),o)},removeStoredPosition:function(t,e){var n=t.sharedRoot,r=t.positionStorageOrigin;da(n),n.doc.transact((function(){!function(t,e){t.removeAttribute(ha+e)}(n,e)}),r)},position:function(t,e){var n=function(t,e){var n=t.getAttribute(ha+e);return n?o.decodeRelativePosition(n):null}(t.sharedRoot,e);if(n)return va(t.sharedRoot,t,n)},storedPositionsRelative:function(t){return e=t.sharedRoot,Object.fromEntries(Object.entries(e.getAttributes()).filter((function(t){return fi(t,1)[0].startsWith(ha)})).map((function(t){var e=fi(t,2),n=e[0],r=e[1];return[n.slice(ha.length),o.createRelativePositionFromJSON(r)]})));var e}};var tc=new WeakMap,ec={isCursorEditor:function(t){return Zu.isYjsEditor(t)&&t.awareness&&"string"==typeof t.cursorDataField&&"string"==typeof t.selectionStateField&&"function"==typeof t.sendCursorPosition&&"function"==typeof t.sendCursorData},sendCursorPosition:function(t,e){void 0===e&&(e=t.selection),t.sendCursorPosition(e)},sendCursorData:function(t,e){t.sendCursorData(e)},on:function(t,e,n){var r;if("change"===e){var o=null!==(r=tc.get(t))&&void 0!==r?r:new Set;o.add(n),t&&tc.set(t,o)}},off:function(t,e,n){if("change"===e){var r=tc.get(t);r&&r.delete(n)}},cursorState:function(t,e){var n;if(e===t.awareness.clientID||!Zu.connected(t))return null;var r=t.awareness.getStates().get(e);return r?{relativeSelection:null!==(n=r[t.selectionStateField])&&void 0!==n?n:null,data:r[t.cursorDataField],clientId:e}:null},cursorStates:function(t){return Zu.connected(t)?Object.fromEntries(Array.from(t.awareness.getStates().entries(),(function(e){var n=fi(e,2),r=n[0],o=n[1];return r!==t.awareness.clientID&&o?[r,{relativeSelection:o[t.selectionStateField],data:o[t.cursorDataField]}]:null})).filter(Array.isArray)):{}}};var nc=new WeakMap,rc=Symbol("slate-yjs-history-without-saving"),oc={isYHistoryEditor:function(t){return Zu.isYjsEditor(t)&&t.undoManager instanceof o.UndoManager&&"function"==typeof t.undo&&"function"==typeof t.redo&&"withoutSavingOrigin"in t},canUndo:function(t){return t.undoManager.undoStack.length>0},canRedo:function(t){return t.undoManager.redoStack.length>0},isSaving:function(t){return t.undoManager.trackedOrigins.has(Zu.origin(t))},withoutSaving:function(t,e){Zu.withOrigin(t,t.withoutSavingOrigin,e)}};t.CursorEditor=ec,t.YHistoryEditor=oc,t.YjsEditor=Zu,t.relativePositionToSlatePoint=va,t.relativeRangeToSlateRange=xa,t.slateNodesToInsertDelta=Wu,t.slatePointToRelativePosition=pa,t.slateRangeToRelativeRange=Oa,t.withCursors=function(t,e){return void 0===e&&(e={}),function(n){var r=e.cursorStateField,i=void 0===r?"selection":r,a=e.cursorDataField,u=void 0===a?"data":a,c=e.autoSend,s=void 0===c||c,f=e.data,l=n;l.awareness=t,l.cursorDataField=u,l.selectionStateField=i,l.sendCursorData=function(t){l.awareness.setLocalStateField(l.cursorDataField,t)},l.sendCursorPosition=function(t){var e=l.awareness.getLocalState(),n=null==e?void 0:e[i];if(t){var r=Oa(l.sharedRoot,l,t),a=r.anchor,u=r.focus;n&&o.compareRelativePositions(a,n)&&o.compareRelativePositions(u,n)||l.awareness.setLocalStateField(l.selectionStateField,{anchor:a,focus:u})}else n&&l.awareness.setLocalStateField(l.selectionStateField,null)};var d=function(t){var e=tc.get(l);if(e){var n=l.awareness.clientID,r={added:t.added.filter((function(t){return t!==n})),removed:t.removed.filter((function(t){return t!==n})),updated:t.updated.filter((function(t){return t!==n}))};(r.added.length>0||r.removed.length>0||r.updated.length>0)&&e.forEach((function(t){return t(r)}))}},h=l.connect,p=l.disconnect;return l.connect=function(){if(h(),l.awareness.on("change",d),d({removed:[],added:Array.from(l.awareness.getStates().keys()),updated:[]}),s){f&&ec.sendCursorData(l,f);var t=l.onChange;l.onChange=function(){t(),Zu.connected(l)&&ec.sendCursorPosition(l)}}},l.disconnect=function(){l.awareness.off("change",d),d({removed:Array.from(l.awareness.getStates().keys()),added:[],updated:[]}),p()},l}},t.withYHistory=function(t){return void 0===t&&(t={}),function(e){var r=e,i=t.withoutSavingOrigin,a=void 0===i?rc:i,u=t.trackedOrigins,c=void 0===u?new Set([r.localOrigin]):u,s=ci(t,["withoutSavingOrigin","trackedOrigins"]),f=new o.UndoManager(r.sharedRoot,ui({trackedOrigins:c},s));r.undoManager=f,r.withoutSavingOrigin=a;var l=r.onChange,d=r.isLocalOrigin;r.onChange=function(){l(),nc.set(r,r.selection&&Oa(r.sharedRoot,r,r.selection))},r.isLocalOrigin=function(t){return t===r.withoutSavingOrigin||d(t)};var h=function(t){var e=t.stackItem;e.meta.set("selection",r.selection&&Oa(r.sharedRoot,r,r.selection)),e.meta.set("selectionBefore",nc.get(r))},p=function(t){t.stackItem.meta.set("selection",r.selection&&Oa(r.sharedRoot,r,r.selection))},v=function(t){var e=t.stackItem,o="undo"===t.type?r.undoManager.redoStack:r.undoManager.undoStack,i=o[o.length-1];i&&(i.meta.set("selection",e.meta.get("selectionBefore")),i.meta.set("selectionBefore",e.meta.get("selection")));var a=e.meta.get("selectionBefore");if(a){var u=xa(r.sharedRoot,r,a);u&&n.Transforms.select(r,u)}},g=r.connect,y=r.disconnect;return r.connect=function(){g(),r.undoManager.on("stack-item-added",h),r.undoManager.on("stack-item-popped",v),r.undoManager.on("stack-item-updated",p)},r.disconnect=function(){r.undoManager.off("stack-item-added",h),r.undoManager.off("stack-item-popped",v),r.undoManager.off("stack-item-updated",p),y()},r.undo=function(){Zu.connected(r)&&(Zu.flushLocalChanges(r),r.undoManager.undo())},r.redo=function(){Zu.connected(r)&&(Zu.flushLocalChanges(r),r.undoManager.redo())},r}},t.withYjs=function(t,e){return void 0===e&&(e={}),function(r){var o,i,a=r;a.sharedRoot=t,a.localOrigin=null!==(o=e.localOrigin)&&void 0!==o?o:Hu,a.positionStorageOrigin=null!==(i=e.positionStorageOrigin)&&void 0!==i?i:$u,a.applyRemoteEvents=function(t,e){Zu.flushLocalChanges(a),n.Editor.withoutNormalizing(a,(function(){Zu.withOrigin(a,e,(function(){Gu(a.sharedRoot,a,t)}))}))},a.isLocalOrigin=function(t){return t===a.localOrigin};var u=function(t,e){a.isLocalOrigin(e.origin)||Zu.applyRemoteEvents(a,t,e.origin)},c=null;e.autoConnect&&(c=setTimeout((function(){c=null,Zu.connect(a)}))),a.connect=function(){if(Zu.connected(a))throw new Error("already connected");a.sharedRoot.observeDeep(u);var t=zu(a.sharedRoot);a.children=t.children,Qu.add(a),n.Editor.normalize(r,{force:!0}),r.operations.length||r.onChange()},a.disconnect=function(){c&&clearTimeout(c),Zu.flushLocalChanges(a),a.sharedRoot.unobserveDeep(u),Qu.delete(a)},a.storeLocalChange=function(t){Ku.set(a,li(li([],fi(Zu.localChanges(a)),!1),[{op:t,doc:r.children,origin:Zu.origin(a)}],!1))},a.flushLocalChanges=function(){da(a.sharedRoot);var t=Zu.localChanges(a);Ku.delete(a);var e=[];t.forEach((function(t){var n=e[e.length-1];if(n&&n[0].origin===t.origin)return n.push(t);e.push([t])})),e.forEach((function(t){da(a.sharedRoot),a.sharedRoot.doc.transact((function(){t.forEach((function(t){da(a.sharedRoot),function(t,e,n){var r=qu[n.type];if(!r)throw new Error("Unknown operation: ".concat(n.type));r(t,e,n)}(a.sharedRoot,{children:t.doc},t.op)}))}),t[0].origin)}))};var s=a.apply,f=a.onChange;return a.apply=function(t){Zu.connected(a)&&Zu.isLocal(a)&&Zu.storeLocalChange(a,t),s(t)},a.onChange=function(){Zu.connected(a)&&Zu.flushLocalChanges(a),f()},a}},t.yTextToSlateElement=zu,Object.defineProperty(t,"__esModule",{value:!0})}));
|
|
2
|
+
//# sourceMappingURL=index.js.map
|