@kangsicj/nexussync 1.0.0 → 1.0.1
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/README.md +3 -1
- package/assets/icon.svg +22 -0
- package/dist/NexusSync.meta.js +5 -6
- package/dist/NexusSync.user.js +42 -21
- package/package.json +26 -6
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
<br>
|
|
6
6
|
|
|
7
|
-
[](./CHANGELOG.md)
|
|
8
8
|
[](https://www.tampermonkey.net/)
|
|
9
9
|
[](https://apps.apple.com/app/userscripts/id1463298887)
|
|
10
10
|
[](https://fairy.hada.io/@jinny)
|
|
@@ -80,6 +80,8 @@ No subtitles on that video? Turn on live speech recognition with translation int
|
|
|
80
80
|
|
|
81
81
|
<div align="center">
|
|
82
82
|
|
|
83
|
+
<img src="assets/icon.svg" width="88" alt="NexusSync icon">
|
|
84
|
+
|
|
83
85
|
### [⬇️ Install NexusSync](https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.user.js)
|
|
84
86
|
|
|
85
87
|
<sub>Opens the install page of your userscript manager · updates arrive automatically</sub>
|
package/assets/icon.svg
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" role="img" aria-label="NexusSync">
|
|
2
|
+
<defs>
|
|
3
|
+
<linearGradient id="nxbg" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#5b2eff"/><stop offset="1" stop-color="#ff4fa3"/></linearGradient>
|
|
4
|
+
<radialGradient id="nxglow" cx="0.82" cy="0.14" r="0.7"><stop offset="0" stop-color="#7cf9ff" stop-opacity="0.55"/><stop offset="1" stop-color="#7cf9ff" stop-opacity="0"/></radialGradient>
|
|
5
|
+
<linearGradient id="nxplay" x1="0" y1="0" x2="1" y2="1"><stop offset="0" stop-color="#ffffff"/><stop offset="1" stop-color="#ffe3f1"/></linearGradient>
|
|
6
|
+
<clipPath id="nxr"><rect width="256" height="256" rx="58"/></clipPath>
|
|
7
|
+
</defs>
|
|
8
|
+
<g clip-path="url(#nxr)">
|
|
9
|
+
<rect width="256" height="256" fill="url(#nxbg)"/>
|
|
10
|
+
<rect width="256" height="256" fill="url(#nxglow)"/>
|
|
11
|
+
<!-- sync ring: two arcs chasing each other -->
|
|
12
|
+
<g fill="none" stroke="#ffffff" stroke-width="15" stroke-linecap="round">
|
|
13
|
+
<path d="M60 116 A70 70 0 0 1 178 72"/>
|
|
14
|
+
<path d="M196 140 A70 70 0 0 1 78 184"/>
|
|
15
|
+
</g>
|
|
16
|
+
<path d="M186 50 L200 92 L157 86 Z" fill="#ffffff"/>
|
|
17
|
+
<path d="M70 206 L56 164 L99 170 Z" fill="#ffffff"/>
|
|
18
|
+
<!-- play -->
|
|
19
|
+
<path d="M110 92 Q104 88 104 96 L104 160 Q104 168 110 164 L162 132 Q168 128 162 124 Z" fill="url(#nxplay)"/>
|
|
20
|
+
<circle cx="200" cy="200" r="0" fill="none"/>
|
|
21
|
+
</g>
|
|
22
|
+
</svg>
|
package/dist/NexusSync.meta.js
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
// @author kangsicj
|
|
7
7
|
// @homepageURL https://github.com/kangsicj/NexusSync
|
|
8
8
|
// @supportURL https://fairy.hada.io/@jinny
|
|
9
|
+
// @icon https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/assets/icon.svg
|
|
9
10
|
// @updateURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.meta.js
|
|
10
11
|
// @downloadURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.user.js
|
|
11
|
-
// @version 1.0.
|
|
12
|
-
// @description Watch
|
|
13
|
-
// @description:ko
|
|
12
|
+
// @version 1.0.1
|
|
13
|
+
// @description Watch any web video together in perfect sync: cinema mode, live AI subtitles & translation, chat bubbles with auto-translation, quick ink, cover, go-together to the next episode.
|
|
14
|
+
// @description:ko 어떤 웹 영상이든 완벽한 싱크로 함께 보기: 시네마 모드, 실시간 AI 자막·번역, 자동 번역 말풍선 채팅, 잠깐 그리기, 가리기, 다음 화도 함께.
|
|
14
15
|
// @match *://*/*
|
|
15
16
|
// @include *
|
|
16
17
|
// @allFrames true
|
|
@@ -26,12 +27,10 @@
|
|
|
26
27
|
// @grant GM.xmlHttpRequest
|
|
27
28
|
// @connect translate.googleapis.com
|
|
28
29
|
// @connect nexussync-dd5b4-default-rtdb.asia-southeast1.firebasedatabase.app
|
|
29
|
-
// @connect esm.sh
|
|
30
|
-
// @connect cdn.jsdelivr.net
|
|
31
30
|
// @connect api.openai.com
|
|
32
31
|
// @connect api.groq.com
|
|
33
32
|
// @connect api.anthropic.com
|
|
34
33
|
// @connect api-free.deepl.com
|
|
35
34
|
// @connect api.deepl.com
|
|
36
|
-
// @require https://cdnjs.cloudflare.com/ajax/libs/lz-string/1.5.0/lz-string.min.js
|
|
35
|
+
// @require https://cdnjs.cloudflare.com/ajax/libs/lz-string/1.5.0/lz-string.min.js#sha256=95f4d1cbf099f57161b664bc048426ec3df92637801a4c79116e83315aa787e7
|
|
37
36
|
// ==/UserScript==
|
package/dist/NexusSync.user.js
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
// @author kangsicj
|
|
7
7
|
// @homepageURL https://github.com/kangsicj/NexusSync
|
|
8
8
|
// @supportURL https://fairy.hada.io/@jinny
|
|
9
|
+
// @icon https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/assets/icon.svg
|
|
9
10
|
// @updateURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.meta.js
|
|
10
11
|
// @downloadURL https://cdn.jsdelivr.net/npm/@kangsicj/nexussync@latest/dist/NexusSync.user.js
|
|
11
|
-
// @version 1.0.
|
|
12
|
-
// @description Watch
|
|
13
|
-
// @description:ko
|
|
12
|
+
// @version 1.0.1
|
|
13
|
+
// @description Watch any web video together in perfect sync: cinema mode, live AI subtitles & translation, chat bubbles with auto-translation, quick ink, cover, go-together to the next episode.
|
|
14
|
+
// @description:ko 어떤 웹 영상이든 완벽한 싱크로 함께 보기: 시네마 모드, 실시간 AI 자막·번역, 자동 번역 말풍선 채팅, 잠깐 그리기, 가리기, 다음 화도 함께.
|
|
14
15
|
// @match *://*/*
|
|
15
16
|
// @include *
|
|
16
17
|
// @allFrames true
|
|
@@ -26,14 +27,12 @@
|
|
|
26
27
|
// @grant GM.xmlHttpRequest
|
|
27
28
|
// @connect translate.googleapis.com
|
|
28
29
|
// @connect nexussync-dd5b4-default-rtdb.asia-southeast1.firebasedatabase.app
|
|
29
|
-
// @connect esm.sh
|
|
30
|
-
// @connect cdn.jsdelivr.net
|
|
31
30
|
// @connect api.openai.com
|
|
32
31
|
// @connect api.groq.com
|
|
33
32
|
// @connect api.anthropic.com
|
|
34
33
|
// @connect api-free.deepl.com
|
|
35
34
|
// @connect api.deepl.com
|
|
36
|
-
// @require https://cdnjs.cloudflare.com/ajax/libs/lz-string/1.5.0/lz-string.min.js
|
|
35
|
+
// @require https://cdnjs.cloudflare.com/ajax/libs/lz-string/1.5.0/lz-string.min.js#sha256=95f4d1cbf099f57161b664bc048426ec3df92637801a4c79116e83315aa787e7
|
|
37
36
|
// ==/UserScript==
|
|
38
37
|
|
|
39
38
|
(async function () {
|
|
@@ -41,12 +40,15 @@
|
|
|
41
40
|
|
|
42
41
|
// The version of the code that is actually running (the manager's metadata can lag
|
|
43
42
|
// behind when an old copy is still installed).
|
|
44
|
-
const NXU_VERSION = '1.0.
|
|
43
|
+
const NXU_VERSION = '1.0.1';
|
|
45
44
|
// Rank used by the one-instance guard below and to tell newer builds apart in a room.
|
|
46
45
|
// It is independent of the public version (1.0.0 is the first public release, after
|
|
47
46
|
// private builds that reached ranks up to 10.2.0), so every older copy still installed
|
|
48
47
|
// steps aside instead of this release.
|
|
49
|
-
const NXU_RANK = '11.0.
|
|
48
|
+
const NXU_RANK = '11.0.1';
|
|
49
|
+
const NXU_SESSION = Math.random().toString(36).slice(2, 10); // this page load // raise with every release
|
|
50
|
+
// App icon (same artwork as assets/icon.svg / @icon), inlined so it shows offline too.
|
|
51
|
+
const NXU_ICON = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyNTYgMjU2IiByb2xlPSJpbWciIGFyaWEtbGFiZWw9Ik5leHVzU3luYyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJueGJnIiB4MT0iMCIgeTE9IjAiIHgyPSIxIiB5Mj0iMSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjNWIyZWZmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmY0ZmEzIi8+PC9saW5lYXJHcmFkaWVudD48cmFkaWFsR3JhZGllbnQgaWQ9Im54Z2xvdyIgY3g9IjAuODIiIGN5PSIwLjE0IiByPSIwLjciPjxzdG9wIG9mZnNldD0iMCIgc3RvcC1jb2xvcj0iIzdjZjlmZiIgc3RvcC1vcGFjaXR5PSIwLjU1Ii8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjN2NmOWZmIiBzdG9wLW9wYWNpdHk9IjAiLz48L3JhZGlhbEdyYWRpZW50PjxsaW5lYXJHcmFkaWVudCBpZD0ibnhwbGF5IiB4MT0iMCIgeTE9IjAiIHgyPSIxIiB5Mj0iMSI+PHN0b3Agb2Zmc2V0PSIwIiBzdG9wLWNvbG9yPSIjZmZmZmZmIi8+PHN0b3Agb2Zmc2V0PSIxIiBzdG9wLWNvbG9yPSIjZmZlM2YxIi8+PC9saW5lYXJHcmFkaWVudD48Y2xpcFBhdGggaWQ9Im54ciI+PHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIHJ4PSI1OCIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNueHIpIj48cmVjdCB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgZmlsbD0idXJsKCNueGJnKSIvPjxyZWN0IHdpZHRoPSIyNTYiIGhlaWdodD0iMjU2IiBmaWxsPSJ1cmwoI254Z2xvdykiLz48ZyBmaWxsPSJub25lIiBzdHJva2U9IiNmZmZmZmYiIHN0cm9rZS13aWR0aD0iMTUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCI+PHBhdGggZD0iTTYwIDExNiBBNzAgNzAgMCAwIDEgMTc4IDcyIi8+PHBhdGggZD0iTTE5NiAxNDAgQTcwIDcwIDAgMCAxIDc4IDE4NCIvPjwvZz48cGF0aCBkPSJNMTg2IDUwIEwyMDAgOTIgTDE1NyA4NiBaIiBmaWxsPSIjZmZmZmZmIi8+PHBhdGggZD0iTTcwIDIwNiBMNTYgMTY0IEw5OSAxNzAgWiIgZmlsbD0iI2ZmZmZmZiIvPjxwYXRoIGQ9Ik0xMTAgOTIgUTEwNCA4OCAxMDQgOTYgTDEwNCAxNjAgUTEwNCAxNjggMTEwIDE2NCBMMTYyIDEzMiBRMTY4IDEyOCAxNjIgMTI0IFoiIGZpbGw9InVybCgjbnhwbGF5KSIvPjwvZz48L3N2Zz4=';
|
|
50
52
|
const IS_TOP = (() => { try { return window === window.top; } catch (_) { return false; } })();
|
|
51
53
|
const IS_IOS = /iPad|iPhone|iPod/.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && Number(navigator.maxTouchPoints) > 1);
|
|
52
54
|
const IS_TOUCH = IS_IOS || (typeof matchMedia === 'function' && matchMedia('(pointer: coarse)').matches);
|
|
@@ -4371,15 +4373,11 @@
|
|
|
4371
4373
|
window.addEventListener('pagehide', (e) => { if (!e.persisted) { try { TRAVEL.onLeavePage(); } catch (_) { } _cleanupHostNodes(); } });
|
|
4372
4374
|
|
|
4373
4375
|
async function initYjsSystem() {
|
|
4374
|
-
const sources = ['https://esm.sh/yjs@13.6.14?bundle', 'https://cdn.jsdelivr.net/npm/yjs@13.6.14/+esm'];
|
|
4375
4376
|
try {
|
|
4376
4377
|
if (ydoc) { ydoc.destroy(); ydoc = yVideo = yChat = yStrokes = yBookmarks = yPresence = null; }
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
}
|
|
4381
|
-
if (!Y) throw new Error('all sources blocked');
|
|
4382
|
-
}
|
|
4378
|
+
// The sync engine ships inside the script: no code is downloaded and run at
|
|
4379
|
+
// connect time, and sites with strict security policies work the same.
|
|
4380
|
+
if (!Y) Y = nxuLoadYjs();
|
|
4383
4381
|
ydoc = new Y.Doc();
|
|
4384
4382
|
yVideo = ydoc.getMap('video');
|
|
4385
4383
|
yChat = ydoc.getArray('chat');
|
|
@@ -4761,7 +4759,7 @@
|
|
|
4761
4759
|
syncServerClock();
|
|
4762
4760
|
try { TRAVEL.onConnected(); } catch (_) { }
|
|
4763
4761
|
// Pre-encrypted goodbye for tab close (pagehide cannot wait for encryption).
|
|
4764
|
-
encryptData({ id: 'bye_' + STATE.userId + '_' + Date.now().toString(36), t: 'peer_leave', s: STATE.senderId, d: { uid: STATE.userId } }).then(packet => { NETWORK.byePacket = packet; }).catch(() => { });
|
|
4762
|
+
encryptData({ id: 'bye_' + STATE.userId + '_' + Date.now().toString(36), t: 'peer_leave', s: STATE.senderId, d: { uid: STATE.userId, sess: NXU_SESSION } }).then(packet => { NETWORK.byePacket = packet; }).catch(() => { });
|
|
4765
4763
|
spawnMandatoryShield();
|
|
4766
4764
|
}
|
|
4767
4765
|
|
|
@@ -4773,6 +4771,10 @@
|
|
|
4773
4771
|
case 'peer_leave': {
|
|
4774
4772
|
// Everyone is equal: someone leaving never ends the room for the others.
|
|
4775
4773
|
const uid = typeof d.uid === 'string' ? d.uid : null;
|
|
4774
|
+
// The page someone just left (next episode) says goodbye while their new page
|
|
4775
|
+
// is already back in the room under the same name: that goodbye is old news.
|
|
4776
|
+
const cur = uid && yPresence ? yPresence.get(uid) : null;
|
|
4777
|
+
if (uid && typeof d.sess === 'string' && cur && typeof cur.sess === 'string' && cur.sess !== d.sess) break;
|
|
4776
4778
|
if (uid && uid !== STATE.userId) {
|
|
4777
4779
|
const name = participantName(uid);
|
|
4778
4780
|
PRESENCE.seen.delete(uid);
|
|
@@ -5433,11 +5435,16 @@
|
|
|
5433
5435
|
if (STATE._presenceTimer) return;
|
|
5434
5436
|
const beat = () => {
|
|
5435
5437
|
if (ydoc && yPresence && STATE.role !== 'IDLE' && !STATE.isReadOnly) {
|
|
5436
|
-
ydoc.transact(() => yPresence.set(STATE.userId, { ts: Date.now(), color: STATE.color, viewer: !!STATE.isViewer, nick: STATE.nickname || '', v: NXU_VERSION, r: NXU_RANK }), 'local');
|
|
5438
|
+
ydoc.transact(() => yPresence.set(STATE.userId, { ts: Date.now(), color: STATE.color, viewer: !!STATE.isViewer, nick: STATE.nickname || '', v: NXU_VERSION, r: NXU_RANK, sess: NXU_SESSION }), 'local');
|
|
5437
5439
|
}
|
|
5438
5440
|
PRESENCE.refresh();
|
|
5439
5441
|
};
|
|
5440
5442
|
beat();
|
|
5443
|
+
// Once more after the room's history has arrived: a fresh page (reload, next episode)
|
|
5444
|
+
// starts from an empty document, so its first note can lose to the one its previous
|
|
5445
|
+
// page left; a note written after the sync always wins.
|
|
5446
|
+
setTimeout(beat, 1500);
|
|
5447
|
+
setTimeout(beat, 4000);
|
|
5441
5448
|
STATE._presenceTimer = setInterval(beat, 8000);
|
|
5442
5449
|
}
|
|
5443
5450
|
|
|
@@ -5449,7 +5456,7 @@
|
|
|
5449
5456
|
// Leaving only takes *this* device out; the room goes on for everyone else.
|
|
5450
5457
|
const alone = PRESENCE.others().length === 0;
|
|
5451
5458
|
try { if (ydoc && yPresence) ydoc.transact(() => yPresence.delete(STATE.userId), 'local'); } catch (_) { }
|
|
5452
|
-
const bye = Promise.resolve(sendFirebaseCmd('peer_leave', { uid: STATE.userId }, 'nexus_rooms')).catch(() => { });
|
|
5459
|
+
const bye = Promise.resolve(sendFirebaseCmd('peer_leave', { uid: STATE.userId, sess: NXU_SESSION }, 'nexus_rooms')).catch(() => { });
|
|
5453
5460
|
if (STATE.lobbyTimer) clearTimeout(STATE.lobbyTimer);
|
|
5454
5461
|
if (STATE.role === 'HOST') wipeDatabaseCompletely('nexus_lobbies', STATE.lobbyId);
|
|
5455
5462
|
(STATE.inviteLobbies || []).forEach(id => wipeDatabaseCompletely('nexus_lobbies', id));
|
|
@@ -6584,6 +6591,7 @@
|
|
|
6584
6591
|
.nx-cover.compact .nx-cover-actions { bottom:8px; } .nx-cover.compact .nx-cover-btn { padding:5px 10px; font-size:11.5px; }
|
|
6585
6592
|
.react-btn.together-btn.cover-btn { box-shadow:0 0 0 1.5px rgba(255,138,128,0.65) inset; }
|
|
6586
6593
|
/* profile & chat extras */
|
|
6594
|
+
.nx-logo { width:20px; height:20px; border-radius:6px; vertical-align:-4px; margin-right:7px; box-shadow:0 2px 8px rgba(91,46,255,0.45); }
|
|
6587
6595
|
.nx-me-dot { background:var(--c, #69f0ae) !important; box-shadow:0 0 0 2px rgba(255,255,255,0.25), 0 0 10px var(--c, #69f0ae); }
|
|
6588
6596
|
.nx-profile { display:flex; flex-direction:column; gap:7px; padding:6px 4px 2px; }
|
|
6589
6597
|
.nx-profile-title { font-size:11.5px; font-weight:800; color:rgba(255,255,255,0.7); padding-left:4px; }
|
|
@@ -6941,7 +6949,8 @@
|
|
|
6941
6949
|
// Connect panel
|
|
6942
6950
|
const manualModal = createEl('div', 'window-frame');
|
|
6943
6951
|
manualModal.id = 'manual-modal';
|
|
6944
|
-
const manualHeader = createWindowHeader('
|
|
6952
|
+
const manualHeader = createWindowHeader('NexusSync', [{ className: 'close-btn', text: '✖' }]);
|
|
6953
|
+
manualHeader.firstElementChild?.prepend(createEl('img', 'nx-logo', '', { src: NXU_ICON, alt: '', width: '20', height: '20' }));
|
|
6945
6954
|
const manualBody = createEl('div', 'manual-body');
|
|
6946
6955
|
const hostBtn = createEl('button', 'btn', '🏠 ' + t('createRoom'));
|
|
6947
6956
|
const pinDisplay = createEl('div', 'pin-display', '------');
|
|
@@ -7462,7 +7471,7 @@
|
|
|
7462
7471
|
},
|
|
7463
7472
|
publish() {
|
|
7464
7473
|
try {
|
|
7465
|
-
if (ydoc && yPresence && STATE.handshakeVerified) ydoc.transact(() => yPresence.set(STATE.userId, { ts: Date.now(), color: STATE.color, viewer: !!STATE.isViewer, nick: STATE.nickname || '', v: NXU_VERSION, r: NXU_RANK }), 'local');
|
|
7474
|
+
if (ydoc && yPresence && STATE.handshakeVerified) ydoc.transact(() => yPresence.set(STATE.userId, { ts: Date.now(), color: STATE.color, viewer: !!STATE.isViewer, nick: STATE.nickname || '', v: NXU_VERSION, r: NXU_RANK, sess: NXU_SESSION }), 'local');
|
|
7466
7475
|
} catch (_) { }
|
|
7467
7476
|
},
|
|
7468
7477
|
// Small editor: name + colour swatches + any colour.
|
|
@@ -10578,7 +10587,7 @@
|
|
|
10578
10587
|
initFirebaseStreaming(STATE.handshakeVerified ? 'nexus_rooms' : (NETWORK.streamNode || 'nexus_rooms'),
|
|
10579
10588
|
STATE.handshakeVerified ? STATE.topicId : (NETWORK.streamNode === 'nexus_lobbies' ? STATE.lobbyId : STATE.topicId));
|
|
10580
10589
|
if (STATE.handshakeVerified) {
|
|
10581
|
-
try { if (ydoc && yPresence) ydoc.transact(() => yPresence.set(STATE.userId, { ts: Date.now(), color: STATE.color, viewer: !!STATE.isViewer, nick: STATE.nickname || '', v: NXU_VERSION, r: NXU_RANK }), 'local'); } catch (_) { }
|
|
10590
|
+
try { if (ydoc && yPresence) ydoc.transact(() => yPresence.set(STATE.userId, { ts: Date.now(), color: STATE.color, viewer: !!STATE.isViewer, nick: STATE.nickname || '', v: NXU_VERSION, r: NXU_RANK, sess: NXU_SESSION }), 'local'); } catch (_) { }
|
|
10582
10591
|
sendFirebaseCmd('heartbeat', { ts: Date.now() }, 'nexus_rooms');
|
|
10583
10592
|
syncServerClock();
|
|
10584
10593
|
if (RTC.isHost && STATE.connectionMode === 'HTTP_RELAY') RTC.init();
|
|
@@ -10824,6 +10833,18 @@
|
|
|
10824
10833
|
console.info('[NexusSync] v' + NXU_VERSION + ' handed over to a newer version on this page.');
|
|
10825
10834
|
});
|
|
10826
10835
|
|
|
10836
|
+
// ───────────────────────── Bundled sync engine
|
|
10837
|
+
// Yjs 13.6.14 with lib0 — MIT License, © Kevin Jahns (https://github.com/yjs/yjs).
|
|
10838
|
+
// Built with esbuild (--format=iife --minify); see scripts in the repository.
|
|
10839
|
+
function nxuLoadYjs() {
|
|
10840
|
+
var Y=(()=>{var Je=Object.defineProperty;var Zi=Object.getOwnPropertyDescriptor;var Qi=Object.getOwnPropertyNames;var to=Object.prototype.hasOwnProperty;var eo=(e,t,n)=>t in e?Je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var no=(e,t)=>{for(var n in t)Je(e,n,{get:t[n],enumerable:!0})},ro=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Qi(t))!to.call(e,s)&&s!==n&&Je(e,s,{get:()=>t[s],enumerable:!(r=Zi(t,s))||r.enumerable});return e};var so=e=>ro(Je({},"__esModule",{value:!0}),e);var Xe=(e,t,n)=>eo(e,typeof t!="symbol"?t+"":t,n);var na={};no(na,{AbsolutePosition:()=>Tn,AbstractConnector:()=>Tr,AbstractStruct:()=>ae,AbstractType:()=>C,Array:()=>Vt,ContentAny:()=>yt,ContentBinary:()=>Bt,ContentDeleted:()=>he,ContentDoc:()=>Mt,ContentEmbed:()=>at,ContentFormat:()=>E,ContentJSON:()=>ze,ContentString:()=>Y,ContentType:()=>K,Doc:()=>Tt,GC:()=>N,ID:()=>ct,Item:()=>S,Map:()=>Ot,PermanentUserData:()=>vr,RelativePosition:()=>ce,Skip:()=>O,Snapshot:()=>Me,Text:()=>le,Transaction:()=>vn,UndoManager:()=>Lr,UpdateDecoderV1:()=>j,UpdateDecoderV2:()=>R,UpdateEncoderV1:()=>nt,UpdateEncoderV2:()=>J,XmlElement:()=>Lt,XmlFragment:()=>Nt,XmlHook:()=>Ge,XmlText:()=>Rn,YArrayEvent:()=>Nn,YEvent:()=>vt,YMapEvent:()=>Ln,YTextEvent:()=>Bn,YXmlEvent:()=>Mn,applyUpdate:()=>Lc,applyUpdateV2:()=>jn,cleanupYTextFormatting:()=>Ji,compareIDs:()=>At,compareRelativePositions:()=>Wc,convertUpdateFormatV1ToV2:()=>yl,convertUpdateFormatV2ToV1:()=>Ti,createAbsolutePositionFromRelativePosition:()=>Yc,createDeleteSet:()=>Fn,createDeleteSetFromStructStore:()=>Fr,createDocFromSnapshot:()=>rl,createID:()=>w,createRelativePositionFromJSON:()=>Gc,createRelativePositionFromTypeIndex:()=>Hc,createSnapshot:()=>Jr,decodeRelativePosition:()=>Kc,decodeSnapshot:()=>tl,decodeSnapshotV2:()=>mi,decodeStateVector:()=>Gr,decodeUpdate:()=>ul,decodeUpdateV2:()=>_i,diffUpdate:()=>gl,diffUpdateV2:()=>Xr,emptySnapshot:()=>el,encodeRelativePosition:()=>Xc,encodeSnapshot:()=>Qc,encodeSnapshotV2:()=>gi,encodeStateAsUpdate:()=>Mc,encodeStateAsUpdateV2:()=>di,encodeStateVector:()=>Fc,encodeStateVectorFromUpdate:()=>dl,encodeStateVectorFromUpdateV2:()=>Ui,equalDeleteSets:()=>hi,equalSnapshots:()=>Zc,findIndexSS:()=>P,findRootTypeKey:()=>Hr,getItem:()=>Ve,getState:()=>_,getTypeChildren:()=>Sl,isDeleted:()=>Rt,isParentOf:()=>Be,iterateDeletedStructs:()=>It,logType:()=>jc,logUpdate:()=>hl,logUpdateV2:()=>Si,mergeUpdates:()=>Ei,mergeUpdatesV2:()=>$e,obfuscateUpdate:()=>ml,obfuscateUpdateV2:()=>wl,parseUpdateMeta:()=>fl,parseUpdateMetaV2:()=>Ci,readUpdate:()=>Nc,readUpdateV2:()=>qr,relativePositionToJSON:()=>qc,snapshot:()=>nl,snapshotContainsUpdate:()=>il,transact:()=>k,tryGc:()=>ll,typeListToArraySnapshot:()=>_l,typeMapGetAllSnapshot:()=>ji,typeMapGetSnapshot:()=>Cl});var A=()=>new Map,Pe=e=>{let t=A();return e.forEach((n,r)=>{t.set(r,n)}),t},L=(e,t,n)=>{let r=e.get(t);return r===void 0&&e.set(t,r=n()),r},ts=(e,t)=>{let n=[];for(let[r,s]of e)n.push(t(s,r));return n},es=(e,t)=>{for(let[n,r]of e)if(t(r,n))return!0;return!1};var st=()=>new Set;var Ke=e=>e[e.length-1];var ns=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},W=Array.from,Ye=(e,t)=>{for(let n=0;n<e.length;n++)if(!t(e[n],n,e))return!1;return!0},fe=(e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1};var rs=(e,t)=>{let n=new Array(e);for(let r=0;r<e;r++)n[r]=t(r,n);return n};var it=Array.isArray;var $t=class{constructor(){this._observers=A()}on(t,n){return L(this._observers,t,st).add(n),n}once(t,n){let r=(...s)=>{this.off(t,r),n(...s)};this.on(t,r)}off(t,n){let r=this._observers.get(t);r!==void 0&&(r.delete(n),r.size===0&&this._observers.delete(t))}emit(t,n){return W((this._observers.get(t)||A()).values()).forEach(r=>r(...n))}destroy(){this._observers=A()}};var B=Math.floor;var xt=Math.abs;var We=(e,t)=>e<t?e:t,ot=(e,t)=>e>t?e:t,ia=Number.isNaN;var Ze=e=>e!==0?e<0:1/e<0;var Ft=Number.MAX_SAFE_INTEGER,Jn=Number.MIN_SAFE_INTEGER,oa=1<<31;var ss=Number.isInteger||(e=>typeof e=="number"&&isFinite(e)&&B(e)===e),ca=Number.isNaN,la=Number.parseInt;var Pn=String.fromCharCode,io=String.fromCodePoint,aa=Pn(65535),oo=e=>e.toLowerCase(),co=/^\s*/g,lo=e=>e.replace(co,""),ao=/([A-Z])/g,Kn=(e,t)=>lo(e.replace(ao,n=>`${t}${oo(n)}`));var ho=e=>{let t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let s=0;s<n;s++)r[s]=t.codePointAt(s);return r},qt=typeof TextEncoder!="undefined"?new TextEncoder:null,uo=e=>qt.encode(e),is=qt?uo:ho;var jt=typeof TextDecoder=="undefined"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});jt&&jt.decode(new Uint8Array).length===1&&(jt=null);var Qe=(e,t)=>rs(t,()=>e).join("");var bt=class{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}},St=()=>new bt;var fo=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t};var G=e=>{let t=new Uint8Array(fo(e)),n=0;for(let r=0;r<e.bufs.length;r++){let s=e.bufs[r];t.set(s,n),n+=s.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},po=(e,t)=>{let n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(ot(n,t)*2),e.cpos=0)},T=(e,t)=>{let n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(n*2),e.cpos=0),e.cbuf[e.cpos++]=t};var Jt=T;var g=(e,t)=>{for(;t>127;)T(e,128|127&t),t=B(t/128);T(e,127&t)},ye=(e,t)=>{let n=Ze(t);for(n&&(t=-t),T(e,(t>63?128:0)|(n?64:0)|63&t),t=B(t/64);t>0;)T(e,(t>127?128:0)|127&t),t=B(t/128)},Yn=new Uint8Array(3e4),go=Yn.length/3,mo=(e,t)=>{if(t.length<go){let n=qt.encodeInto(t,Yn).written||0;g(e,n);for(let r=0;r<n;r++)T(e,Yn[r])}else $(e,is(t))},wo=(e,t)=>{let n=unescape(encodeURIComponent(t)),r=n.length;g(e,r);for(let s=0;s<r;s++)T(e,n.codePointAt(s))},ht=qt&&qt.encodeInto?mo:wo;var hs=(e,t)=>Xt(e,G(t)),Xt=(e,t)=>{let n=e.cbuf.length,r=e.cpos,s=We(n-r,t.length),i=t.length-s;e.cbuf.set(t.subarray(0,s),r),e.cpos+=s,i>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(ot(n*2,i)),e.cbuf.set(t.subarray(s)),e.cpos=i)},$=(e,t)=>{g(e,t.byteLength),Xt(e,t)},Wn=(e,t)=>{po(e,t);let n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},yo=(e,t)=>Wn(e,4).setFloat32(0,t,!1),xo=(e,t)=>Wn(e,8).setFloat64(0,t,!1),bo=(e,t)=>Wn(e,8).setBigInt64(0,t,!1);var cs=new DataView(new ArrayBuffer(4)),ko=e=>(cs.setFloat32(0,e),cs.getFloat32(0)===e),zt=(e,t)=>{switch(typeof t){case"string":T(e,119),ht(e,t);break;case"number":ss(t)&&xt(t)<=2147483647?(T(e,125),ye(e,t)):ko(t)?(T(e,124),yo(e,t)):(T(e,123),xo(e,t));break;case"bigint":T(e,122),bo(e,t);break;case"object":if(t===null)T(e,126);else if(it(t)){T(e,117),g(e,t.length);for(let n=0;n<t.length;n++)zt(e,t[n])}else if(t instanceof Uint8Array)T(e,116),$(e,t);else{T(e,118);let n=Object.keys(t);g(e,n.length);for(let r=0;r<n.length;r++){let s=n[r];ht(e,s),zt(e,t[s])}}break;case"boolean":T(e,t?120:121);break;default:T(e,127)}},we=class extends bt{constructor(t){super(),this.w=t,this.s=null,this.count=0}write(t){this.s===t?this.count++:(this.count>0&&g(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}};var ls=e=>{e.count>0&&(ye(e.encoder,e.count===1?e.s:-e.s),e.count>1&&g(e.encoder,e.count-2))},kt=class{constructor(){this.encoder=new bt,this.s=0,this.count=0}write(t){this.s===t?this.count++:(ls(this),this.count=1,this.s=t)}toUint8Array(){return ls(this),G(this.encoder)}};var as=e=>{if(e.count>0){let t=e.diff*2+(e.count===1?0:1);ye(e.encoder,t),e.count>1&&g(e.encoder,e.count-2)}},Ht=class{constructor(){this.encoder=new bt,this.s=0,this.count=0,this.diff=0}write(t){this.diff===t-this.s?(this.s=t,this.count++):(as(this),this.count=1,this.diff=t-this.s,this.s=t)}toUint8Array(){return as(this),G(this.encoder)}},tn=class{constructor(){this.sarr=[],this.s="",this.lensE=new kt}write(t){this.s+=t,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}toUint8Array(){let t=new bt;return this.sarr.push(this.s),this.s="",ht(t,this.sarr.join("")),Xt(t,this.lensE.toUint8Array()),G(t)}};var z=e=>new Error(e),H=()=>{throw z("Method unimplemented")},D=()=>{throw z("Unexpected case")};var nn=z("Unexpected end of array"),us=z("Integer out of Range"),_o=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw nn;return new Uint8Array(e.buffer,e.byteOffset+t,n)},Eo=(e,t,n)=>{if(t<0||n<0||t+n>e.length)throw nn;return new DataView(e.buffer,e.byteOffset+t,n)},Pt=class{constructor(t){this.arr=t,this.pos=0}},V=e=>new Pt(e),Qn=e=>e.pos!==e.arr.length;var Uo=(e,t)=>{let n=_o(e.arr,e.pos,t);return e.pos+=t,n},F=e=>Uo(e,y(e));var _t=e=>e.arr[e.pos++];var y=e=>{let t=0,n=1,r=e.arr.length;for(;e.pos<r;){let s=e.arr[e.pos++];if(t=t+(s&127)*n,n*=128,s<128)return t;if(t>Ft)throw us}throw nn},be=e=>{let t=e.arr[e.pos++],n=t&63,r=64,s=(t&64)>0?-1:1;if(!(t&128))return s*n;let i=e.arr.length;for(;e.pos<i;){if(t=e.arr[e.pos++],n=n+(t&127)*r,r*=128,t<128)return s*n;if(n>Ft)throw us}throw nn};var Co=e=>{let t=y(e);if(t===0)return"";{let n=String.fromCodePoint(_t(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(_t(e));else for(;t>0;){let r=t<1e4?t:1e4,s=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,s),t-=r}return decodeURIComponent(escape(n))}},Ao=e=>jt.decode(F(e)),dt=jt?Ao:Co;var tr=(e,t)=>{let n=Eo(e.arr,e.pos,t);return e.pos+=t,n},Io=e=>tr(e,4).getFloat32(0,!1),To=e=>tr(e,8).getFloat64(0,!1),Do=e=>tr(e,8).getBigInt64(0,!1);var vo=[e=>{},e=>null,be,Io,To,Do,e=>!1,e=>!0,dt,e=>{let t=y(e),n={};for(let r=0;r<t;r++){let s=dt(e);n[s]=Kt(e)}return n},e=>{let t=y(e),n=[];for(let r=0;r<t;r++)n.push(Kt(e));return n},F],Kt=e=>vo[127-_t(e)](e),xe=class extends Pt{constructor(t,n){super(t),this.reader=n,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),Qn(this)?this.count=y(this)+1:this.count=-1),this.count--,this.s}};var Et=class extends Pt{constructor(t){super(t),this.s=0,this.count=0}read(){if(this.count===0){this.s=be(this);let t=Ze(this.s);this.count=1,t&&(this.s=-this.s,this.count=y(this)+2)}return this.count--,this.s}};var Yt=class extends Pt{constructor(t){super(t),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){let t=be(this),n=t&1;this.diff=B(t/2),this.count=1,n&&(this.count=y(this)+2)}return this.s+=this.diff,this.count--,this.s}},en=class{constructor(t){this.decoder=new Et(t),this.str=dt(this.decoder),this.spos=0}read(){let t=this.spos+this.decoder.read(),n=this.str.slice(this.spos,t);return this.spos=t,n}};var da=crypto.subtle,ds=crypto.getRandomValues.bind(crypto);var er=()=>ds(new Uint32Array(1))[0];var Oo="10000000-1000-4000-8000"+-1e11,fs=()=>Oo.replace(/[018]/g,e=>(e^er()&15>>e/4).toString(16));var rn=Date.now;var nr=e=>new Promise(e);var ga=Promise.all.bind(Promise);var rr=e=>e===void 0?null:e;var sr=class{constructor(){this.map=new Map}setItem(t,n){this.map.set(t,n)}getItem(t){return this.map.get(t)}},gs=new sr,Mo=!0;try{typeof localStorage!="undefined"&&localStorage&&(gs=localStorage,Mo=!1)}catch{}var ms=gs;var Ut=Symbol("Equality"),sn=(e,t)=>{var n;return e===t||!!((n=e==null?void 0:e[Ut])!=null&&n.call(e,t))||!1};var ws=e=>typeof e=="object",ys=Object.assign,$o=Object.keys;var xs=(e,t)=>{for(let n in e)t(e[n],n)};var ke=e=>$o(e).length;var bs=e=>{for(let t in e)return!1;return!0},Wt=(e,t)=>{for(let n in e)if(!t(e[n],n))return!1;return!0},Se=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),or=(e,t)=>e===t||ke(e)===ke(t)&&Wt(e,(n,r)=>(n!==void 0||Se(t,r))&&sn(t[r],n));var Ee=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&Ee(e,t,n+1)}};var lr=e=>e;var _e=(e,t)=>{if(e===t)return!0;if(e==null||t==null||e.constructor!==t.constructor&&(e.constructor||Object)!==(t.constructor||Object))return!1;if(e[Ut]!=null)return e[Ut](t);switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:{if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break}case Set:{if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;break}case Map:{if(e.size!==t.size)return!1;for(let n of e.keys())if(!t.has(n)||!_e(e.get(n),t.get(n)))return!1;break}case void 0:case Object:if(ke(e)!==ke(t))return!1;for(let n in e)if(!Se(e,n)||!_e(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!_e(e[n],t[n]))return!1;break;default:return!1}return!0},ks=(e,t)=>t.includes(e);var Ue=typeof process!="undefined"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]";var ma=typeof navigator!="undefined"?/Mac/.test(navigator.platform):!1,Z,Fo=[],jo=()=>{if(Z===void 0)if(Ue){Z=A();let e=process.argv,t=null;for(let n=0;n<e.length;n++){let r=e[n];r[0]==="-"?(t!==null&&Z.set(t,""),t=r):t!==null?(Z.set(t,r),t=null):Fo.push(r)}t!==null&&Z.set(t,"")}else typeof location=="object"?(Z=A(),(location.search||"?").slice(1).split("&").forEach(e=>{if(e.length!==0){let[t,n]=e.split("=");Z.set(`--${Kn(t,"-")}`,n),Z.set(`-${Kn(t,"-")}`,n)}})):Z=A();return Z},hr=e=>jo().has(e);var ur=e=>Ue?rr(process.env[e.toUpperCase().replaceAll("-","_")]):rr(ms.getItem(e));var Ss=e=>hr("--"+e)||ur(e)!==null,_s=Ss("production"),qo=Ue&&ks(process.env.FORCE_COLOR,["true","1","2"]),Es=qo||!hr("--no-colors")&&!Ss("no-color")&&(!Ue||process.stdout.isTTY)&&(!Ue||hr("--color")||ur("COLORTERM")!==null||(ur("TERM")||"").includes("color"));var Go=e=>new Uint8Array(e);var Cs=e=>{let t=Go(e.byteLength);return t.set(e),t};var dr=class{constructor(t,n){this.left=t,this.right=n}},Q=(e,t)=>new dr(e,t);var fr=e=>e.next()>=.5,on=(e,t,n)=>B(e.next()*(n+1-t)+t);var pr=(e,t,n)=>B(e.next()*(n+1-t)+t);var gr=(e,t,n)=>pr(e,t,n);var Jo=e=>Pn(gr(e,97,122)),As=(e,t=0,n=20)=>{let r=gr(e,t,n),s="";for(let i=0;i<r;i++)s+=Jo(e);return s};var cn=(e,t)=>t[gr(e,0,t.length-1)];var Po=Symbol("0schema"),mr=class{constructor(){this._rerrs=[]}extend(t,n,r,s=null){this._rerrs.push({path:t,expected:n,has:r,message:s})}toString(){let t=[];for(let n=this._rerrs.length-1;n>0;n--){let r=this._rerrs[n];t.push(Qe(" ",(this._rerrs.length-n)*2)+`${r.path!=null?`[${r.path}] `:""}${r.has} doesn't match ${r.expected}. ${r.message}`)}return t.join(`
|
|
10841
|
+
`)}},wr=(e,t)=>e===t?!0:e==null||t==null||e.constructor!==t.constructor?!1:e[Ut]?sn(e,t):it(e)?Ye(e,n=>fe(t,r=>wr(n,r))):ws(e)?Wt(e,(n,r)=>wr(n,t[r])):!1,v=class{extends(t){let[n,r]=[this.shape,t.shape];return this.constructor._dilutes&&([r,n]=[n,r]),wr(n,r)}equals(t){return this.constructor===t.constructor&&_e(this.shape,t.shape)}[Po](){return!0}[Ut](t){return this.equals(t)}validate(t){return this.check(t)}check(t,n){H()}get nullable(){return re(this,bn)}get optional(){return new ln(this)}cast(t){return Is(t,this),t}expect(t){return Is(t,this),t}};Xe(v,"_dilutes",!1);var Ce=class extends v{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n=void 0){let r=(t==null?void 0:t.constructor)===this.shape&&(this._c==null||this._c(t));return!r&&(n==null||n.extend(null,this.shape.name,t==null?void 0:t.constructor.name,(t==null?void 0:t.constructor)!==this.shape?"Constructor match failed":"Check failed")),r}},U=(e,t=null)=>new Ce(e,t),ya=U(Ce),Ae=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape(t);return!r&&(n==null||n.extend(null,"custom prop",t==null?void 0:t.constructor.name,"failed to check custom prop")),r}},I=e=>new Ae(e),xa=U(Ae),ee=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=this.shape.some(s=>s===t);return!r&&(n==null||n.extend(null,this.shape.join(" | "),t.toString())),r}},yn=(...e)=>new ee(e),Ts=U(ee),Ko=RegExp.escape||(e=>e.replace(/[().|&,$^[\]]/g,t=>"\\"+t)),Ds=e=>{if(ne.check(e))return[Ko(e)];if(Ts.check(e))return e.shape.map(t=>t+"");if(Ls.check(e))return["[+-]?\\d+.?\\d*"];if(Bs.check(e))return[".*"];if(gn.check(e))return e.shape.map(Ds).flat(1);D()},yr=class extends v{constructor(t){super(),this.shape=t,this._r=new RegExp("^"+t.map(Ds).map(n=>`(${n.join("|")})`).join("")+"$")}check(t,n){let r=this._r.exec(t)!=null;return!r&&(n==null||n.extend(null,this._r.toString(),t.toString(),"String doesn't match string template.")),r}};var ba=U(yr),Yo=Symbol("optional"),ln=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=t===void 0||this.shape.check(t);return!r&&(n==null||n.extend(null,"undefined (optional)","()")),r}get[Yo](){return!0}},Wo=U(ln),an=class extends v{check(t,n){return n==null||n.extend(null,"never",typeof t),!1}},ka=new an,Sa=U(an),wn=class wn extends v{constructor(t,n=!1){super(),this.shape=t,this._isPartial=n}get partial(){return new wn(this.shape,!0)}check(t,n){return t==null?(n==null||n.extend(null,"object","null"),!1):Wt(this.shape,(r,s)=>{let i=this._isPartial&&!Se(t,s)||r.check(t[s],n);return!i&&(n==null||n.extend(s.toString(),r.toString(),typeof t[s],"Object property does not match")),i})}};Xe(wn,"_dilutes",!0);var hn=wn,Zo=e=>new hn(e),Qo=U(hn),tc=I(e=>e!=null&&(e.constructor===Object||e.constructor==null)),un=class extends v{constructor(t,n){super(),this.shape={keys:t,values:n}}check(t,n){return t!=null&&Wt(t,(r,s)=>{let i=this.shape.keys.check(s,n);return!i&&(n==null||n.extend(s+"","Record",typeof t,i?"Key doesn't match schema":"Value doesn't match value")),i&&this.shape.values.check(r,n)})}},vs=(e,t)=>new un(e,t),ec=U(un),dn=class extends v{constructor(t){super(),this.shape=t}check(t,n){return t!=null&&Wt(this.shape,(r,s)=>{let i=r.check(t[s],n);return!i&&(n==null||n.extend(s.toString(),"Tuple",typeof r)),i})}},nc=(...e)=>new dn(e),_a=U(dn),fn=class extends v{constructor(t){super(),this.shape=t.length===1?t[0]:new Qt(t)}check(t,n){let r=it(t)&&Ye(t,s=>this.shape.check(s));return!r&&(n==null||n.extend(null,"Array","")),r}},Vs=(...e)=>new fn(e),rc=U(fn),sc=I(e=>it(e)),pn=class extends v{constructor(t,n){super(),this.shape=t,this._c=n}check(t,n){let r=t instanceof this.shape&&(this._c==null||this._c(t));return!r&&(n==null||n.extend(null,this.shape.name,t==null?void 0:t.constructor.name)),r}},ic=(e,t=null)=>new pn(e,t),Ea=U(pn),oc=ic(v),xr=class extends v{constructor(t){super(),this.len=t.length-1,this.args=nc(...t.slice(-1)),this.res=t[this.len]}check(t,n){let r=t.constructor===Function&&t.length<=this.len;return!r&&(n==null||n.extend(null,"function",typeof t)),r}};var cc=U(xr),lc=I(e=>typeof e=="function"),br=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=Ye(this.shape,s=>s.check(t,n));return!r&&(n==null||n.extend(null,"Intersectinon",typeof t)),r}};var Ua=U(br,e=>e.shape.length>0),Qt=class extends v{constructor(t){super(),this.shape=t}check(t,n){let r=fe(this.shape,s=>s.check(t,n));return n==null||n.extend(null,"Union",typeof t),r}};Xe(Qt,"_dilutes",!0);var re=(...e)=>e.findIndex(t=>gn.check(t))>=0?re(...e.map(t=>Ie(t)).map(t=>gn.check(t)?t.shape:[t]).flat(1)):e.length===1?e[0]:new Qt(e),gn=U(Qt),Os=()=>!0,mn=I(Os),ac=U(Ae,e=>e.shape===Os),Sr=I(e=>typeof e=="bigint"),hc=I(e=>e===Sr),Ns=I(e=>typeof e=="symbol"),Ca=I(e=>e===Ns),te=I(e=>typeof e=="number"),Ls=I(e=>e===te),ne=I(e=>typeof e=="string"),Bs=I(e=>e===ne),xn=I(e=>typeof e=="boolean"),uc=I(e=>e===xn),Ms=yn(void 0),Aa=U(ee,e=>e.shape.length===1&&e.shape[0]===void 0),Ia=yn(void 0);var bn=yn(null),dc=U(ee,e=>e.shape.length===1&&e.shape[0]===null),Ta=U(Uint8Array),Da=U(Ce,e=>e.shape===Uint8Array),fc=re(te,ne,bn,Ms,Sr,xn,Ns),va=(()=>{let e=Vs(mn),t=vs(ne,mn),n=re(te,ne,bn,xn,e,t);return e.shape=n,t.shape.values=n,n})(),Ie=e=>{if(oc.check(e))return e;if(tc.check(e)){let t={};for(let n in e)t[n]=Ie(e[n]);return Zo(t)}else{if(sc.check(e))return re(...e.map(Ie));if(fc.check(e))return yn(e);if(lc.check(e))return U(e)}D()},Is=_s?()=>{}:(e,t)=>{let n=new mr;if(!t.check(e,n))throw z(`Expected value to be of type ${t.constructor.name}.
|
|
10842
|
+
${n.toString()}`)},kr=class{constructor(t){this.patterns=[],this.$state=t}if(t,n){return this.patterns.push({if:Ie(t),h:n}),this}else(t){return this.if(mn,t)}done(){return(t,n)=>{for(let r=0;r<this.patterns.length;r++){let s=this.patterns[r];if(s.if.check(t))return s.h(t,n)}throw z("Unhandled pattern")}}},pc=e=>new kr(e),Rs=pc(mn).if(Ls,(e,t)=>on(t,Jn,Ft)).if(Bs,(e,t)=>As(t)).if(uc,(e,t)=>fr(t)).if(hc,(e,t)=>BigInt(on(t,Jn,Ft))).if(gn,(e,t)=>Zt(t,cn(t,e.shape))).if(Qo,(e,t)=>{let n={};for(let r in e.shape){let s=e.shape[r];if(Wo.check(s)){if(fr(t))continue;s=s.shape}n[r]=Rs(s,t)}return n}).if(rc,(e,t)=>{let n=[],r=pr(t,0,42);for(let s=0;s<r;s++)n.push(Zt(t,e.shape));return n}).if(Ts,(e,t)=>cn(t,e.shape)).if(dc,(e,t)=>null).if(cc,(e,t)=>{let n=Zt(t,e.res);return()=>n}).if(ac,(e,t)=>Zt(t,cn(t,[te,ne,bn,Ms,Sr,xn,Vs(te),vs(re("a","b","c"),te)]))).if(ec,(e,t)=>{let n={},r=on(t,0,3);for(let s=0;s<r;s++){let i=Zt(t,e.shape.keys),o=Zt(t,e.shape.values);n[i]=o}return n}).done(),Zt=(e,t)=>Rs(Ie(t),e);var Ct=typeof document!="undefined"?document:{};var Oa=I(e=>e.nodeType===xc);var Na=typeof DOMParser!="undefined"?new DOMParser:null;var La=I(e=>e.nodeType===mc);var Ba=I(e=>e.nodeType===wc);var $s=e=>ts(e,(t,n)=>`${n}:${t};`).join("");var mc=Ct.ELEMENT_NODE,wc=Ct.TEXT_NODE,Ma=Ct.CDATA_SECTION_NODE,Ra=Ct.COMMENT_NODE,yc=Ct.DOCUMENT_NODE,$a=Ct.DOCUMENT_TYPE_NODE,xc=Ct.DOCUMENT_FRAGMENT_NODE,Fa=I(e=>e.nodeType===yc);var tt=Symbol;var Te=tt(),De=tt(),_r=tt(),Er=tt(),Ur=tt(),ve=tt(),Cr=tt(),se=tt(),Ar=tt(),Fs=e=>{var s;e.length===1&&((s=e[0])==null?void 0:s.constructor)===Function&&(e=e[0]());let t=[],n=[],r=0;for(;r<e.length;r++){let i=e[r];if(i===void 0)break;if(i.constructor===String||i.constructor===Number)t.push(i);else if(i.constructor===Object)break}for(r>0&&n.push(t.join(""));r<e.length;r++){let i=e[r];i instanceof Symbol||n.push(i)}return n};var ja=rn();var _c={[Te]:Q("font-weight","bold"),[De]:Q("font-weight","normal"),[_r]:Q("color","blue"),[Ur]:Q("color","green"),[Er]:Q("color","grey"),[ve]:Q("color","red"),[Cr]:Q("color","purple"),[se]:Q("color","orange"),[Ar]:Q("color","black")},Ec=e=>{var o;e.length===1&&((o=e[0])==null?void 0:o.constructor)===Function&&(e=e[0]());let t=[],n=[],r=A(),s=[],i=0;for(;i<e.length;i++){let c=e[i],l=_c[c];if(l!==void 0)r.set(l.left,l.right);else{if(c===void 0)break;if(c.constructor===String||c.constructor===Number){let u=$s(r);i>0||u.length>0?(t.push("%c"+c),n.push(u)):t.push(c)}else break}}for(i>0&&(s=n,s.unshift(t.join("")));i<e.length;i++){let c=e[i];c instanceof Symbol||s.push(c)}return s},js=Es?Ec:Fs,kn=(...e)=>{console.log(...js(e)),Gs.forEach(t=>t.print(e))},qs=(...e)=>{console.warn(...js(e)),e.unshift(se),Gs.forEach(t=>t.print(e))};var Gs=st();var zs=e=>({[Symbol.iterator](){return this},next:e}),Hs=(e,t)=>zs(()=>{let n;do n=e.next();while(!n.done&&!t(n.value));return n}),Sn=(e,t)=>zs(()=>{let{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}});var Tr=class extends $t{constructor(t,n){super(),this.doc=t,this.awareness=n}},Ne=class{constructor(t,n){this.clock=t,this.len=n}},mt=class{constructor(){this.clients=new Map}},It=(e,t,n)=>t.clients.forEach((r,s)=>{let i=e.doc.store.clients.get(s);for(let o=0;o<r.length;o++){let c=r[o];yi(e,i,c.clock,c.len,n)}}),Tc=(e,t)=>{let n=0,r=e.length-1;for(;n<=r;){let s=B((n+r)/2),i=e[s],o=i.clock;if(o<=t){if(t<o+i.len)return s;n=s+1}else r=s-1}return null},Rt=(e,t)=>{let n=e.clients.get(t.client);return n!==void 0&&Tc(n,t.clock)!==null},$r=e=>{e.clients.forEach(t=>{t.sort((s,i)=>s.clock-i.clock);let n,r;for(n=1,r=1;n<t.length;n++){let s=t[r-1],i=t[n];s.clock+s.len>=i.clock?s.len=ot(s.len,i.clock+i.len-s.clock):(r<n&&(t[r]=i),r++)}t.length=r})},ie=e=>{let t=new mt;for(let n=0;n<e.length;n++)e[n].clients.forEach((r,s)=>{if(!t.clients.has(s)){let i=r.slice();for(let o=n+1;o<e.length;o++)ns(i,e[o].clients.get(s)||[]);t.clients.set(s,i)}});return $r(t),t},Le=(e,t,n,r)=>{L(e.clients,t,()=>[]).push(new Ne(n,r))},Fn=()=>new mt,Fr=e=>{let t=Fn();return e.clients.forEach((n,r)=>{let s=[];for(let i=0;i<n.length;i++){let o=n[i];if(o.deleted){let c=o.id.clock,l=o.length;if(i+1<n.length)for(let u=n[i+1];i+1<n.length&&u.deleted;u=n[++i+1])l+=u.length;s.push(new Ne(c,l))}}s.length>0&&t.clients.set(r,s)}),t},et=(e,t)=>{g(e.restEncoder,t.clients.size),W(t.clients.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{e.resetDsCurVal(),g(e.restEncoder,n);let s=r.length;g(e.restEncoder,s);for(let i=0;i<s;i++){let o=r[i];e.writeDsClock(o.clock),e.writeDsLen(o.len)}})},lt=e=>{let t=new mt,n=y(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();let s=y(e.restDecoder),i=y(e.restDecoder);if(i>0){let o=L(t.clients,s,()=>[]);for(let c=0;c<i;c++)o.push(new Ne(e.readDsClock(),e.readDsLen()))}}return t},Ps=(e,t,n)=>{let r=new mt,s=y(e.restDecoder);for(let i=0;i<s;i++){e.resetDsCurVal();let o=y(e.restDecoder),c=y(e.restDecoder),l=n.clients.get(o)||[],u=_(n,o);for(let a=0;a<c;a++){let h=e.readDsClock(),d=h+e.readDsLen();if(h<u){u<d&&Le(r,o,u,d-u);let f=P(l,h),p=l[f];for(!p.deleted&&p.id.clock<h&&(l.splice(f+1,0,$n(t,p,h-p.id.clock)),f++);f<l.length&&(p=l[f++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&l.splice(f,0,$n(t,p,d-p.id.clock)),p.delete(t))}else Le(r,o,h,d-h)}}if(r.clients.size>0){let i=new J;return g(i.restEncoder,0),et(i,r),i.toUint8Array()}return null},hi=(e,t)=>{if(e.clients.size!==t.clients.size)return!1;for(let[n,r]of e.clients.entries()){let s=t.clients.get(n);if(s===void 0||r.length!==s.length)return!1;for(let i=0;i<r.length;i++){let o=r[i],c=s[i];if(o.clock!==c.clock||o.len!==c.len)return!1}}return!0},ui=er,Tt=class e extends $t{constructor({guid:t=fs(),collectionid:n=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:c=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=ui(),this.guid=t,this.collectionid=n,this.share=new Map,this.store=new Dn,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=c,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=nr(u=>{this.on("load",()=>{this.isLoaded=!0,u(this)})});let l=()=>nr(u=>{let a=h=>{(h===void 0||h===!0)&&(this.off("sync",a),u())};this.on("sync",a)});this.on("sync",u=>{u===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=u===void 0||u===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){let t=this._item;t!==null&&!this.shouldLoad&&k(t.parent.doc,n=>{n.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(W(this.subdocs).map(t=>t.guid))}transact(t,n=null){return k(this,t,n)}get(t,n=C){let r=L(this.share,t,()=>{let i=new n;return i._integrate(this,null),i}),s=r.constructor;if(n!==C&&s!==n)if(s===C){let i=new n;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(t,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${t} has already been defined with a different constructor`);return r}getArray(t=""){return this.get(t,Vt)}getText(t=""){return this.get(t,le)}getMap(t=""){return this.get(t,Ot)}getXmlElement(t=""){return this.get(t,Lt)}getXmlFragment(t=""){return this.get(t,Nt)}toJSON(){let t={};return this.share.forEach((n,r)=>{t[r]=n.toJSON()}),t}destroy(){W(this.subdocs).forEach(n=>n.destroy());let t=this._item;if(t!==null){this._item=null;let n=t.content;n.doc=new e({guid:this.guid,...n.opts,shouldLoad:!1}),n.doc._item=t,k(t.parent.doc,r=>{let s=n.doc;t.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}},Dt=class{constructor(t){this.restDecoder=t}resetDsCurVal(){}readDsClock(){return y(this.restDecoder)}readDsLen(){return y(this.restDecoder)}},j=class extends Dt{readLeftID(){return w(y(this.restDecoder),y(this.restDecoder))}readRightID(){return w(y(this.restDecoder),y(this.restDecoder))}readClient(){return y(this.restDecoder)}readInfo(){return _t(this.restDecoder)}readString(){return dt(this.restDecoder)}readParentInfo(){return y(this.restDecoder)===1}readTypeRef(){return y(this.restDecoder)}readLen(){return y(this.restDecoder)}readAny(){return Kt(this.restDecoder)}readBuf(){return Cs(F(this.restDecoder))}readJSON(){return JSON.parse(dt(this.restDecoder))}readKey(){return dt(this.restDecoder)}},In=class{constructor(t){this.dsCurrVal=0,this.restDecoder=t}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=y(this.restDecoder),this.dsCurrVal}readDsLen(){let t=y(this.restDecoder)+1;return this.dsCurrVal+=t,t}},R=class extends In{constructor(t){super(t),this.keys=[],y(t),this.keyClockDecoder=new Yt(F(t)),this.clientDecoder=new Et(F(t)),this.leftClockDecoder=new Yt(F(t)),this.rightClockDecoder=new Yt(F(t)),this.infoDecoder=new xe(F(t),_t),this.stringDecoder=new en(F(t)),this.parentInfoDecoder=new xe(F(t),_t),this.typeRefDecoder=new Et(F(t)),this.lenDecoder=new Et(F(t))}readLeftID(){return new ct(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new ct(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Kt(this.restDecoder)}readBuf(){return F(this.restDecoder)}readJSON(){return Kt(this.restDecoder)}readKey(){let t=this.keyClockDecoder.read();if(t<this.keys.length)return this.keys[t];{let n=this.stringDecoder.read();return this.keys.push(n),n}}},wt=class{constructor(){this.restEncoder=St()}toUint8Array(){return G(this.restEncoder)}resetDsCurVal(){}writeDsClock(t){g(this.restEncoder,t)}writeDsLen(t){g(this.restEncoder,t)}},nt=class extends wt{writeLeftID(t){g(this.restEncoder,t.client),g(this.restEncoder,t.clock)}writeRightID(t){g(this.restEncoder,t.client),g(this.restEncoder,t.clock)}writeClient(t){g(this.restEncoder,t)}writeInfo(t){Jt(this.restEncoder,t)}writeString(t){ht(this.restEncoder,t)}writeParentInfo(t){g(this.restEncoder,t?1:0)}writeTypeRef(t){g(this.restEncoder,t)}writeLen(t){g(this.restEncoder,t)}writeAny(t){zt(this.restEncoder,t)}writeBuf(t){$(this.restEncoder,t)}writeJSON(t){ht(this.restEncoder,JSON.stringify(t))}writeKey(t){ht(this.restEncoder,t)}},oe=class{constructor(){this.restEncoder=St(),this.dsCurrVal=0}toUint8Array(){return G(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(t){let n=t-this.dsCurrVal;this.dsCurrVal=t,g(this.restEncoder,n)}writeDsLen(t){t===0&&D(),g(this.restEncoder,t-1),this.dsCurrVal+=t}},J=class extends oe{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new Ht,this.clientEncoder=new kt,this.leftClockEncoder=new Ht,this.rightClockEncoder=new Ht,this.infoEncoder=new we(Jt),this.stringEncoder=new tn,this.parentInfoEncoder=new we(Jt),this.typeRefEncoder=new kt,this.lenEncoder=new kt}toUint8Array(){let t=St();return g(t,0),$(t,this.keyClockEncoder.toUint8Array()),$(t,this.clientEncoder.toUint8Array()),$(t,this.leftClockEncoder.toUint8Array()),$(t,this.rightClockEncoder.toUint8Array()),$(t,G(this.infoEncoder)),$(t,this.stringEncoder.toUint8Array()),$(t,G(this.parentInfoEncoder)),$(t,this.typeRefEncoder.toUint8Array()),$(t,this.lenEncoder.toUint8Array()),Xt(t,G(this.restEncoder)),G(t)}writeLeftID(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}writeRightID(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}writeClient(t){this.clientEncoder.write(t)}writeInfo(t){this.infoEncoder.write(t)}writeString(t){this.stringEncoder.write(t)}writeParentInfo(t){this.parentInfoEncoder.write(t?1:0)}writeTypeRef(t){this.typeRefEncoder.write(t)}writeLen(t){this.lenEncoder.write(t)}writeAny(t){zt(this.restEncoder,t)}writeBuf(t){$(this.restEncoder,t)}writeJSON(t){zt(this.restEncoder,t)}writeKey(t){let n=this.keyMap.get(t);n===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(n)}},Dc=(e,t,n,r)=>{r=ot(r,t[0].id.clock);let s=P(t,r);g(e.restEncoder,t.length-s),e.writeClient(n),g(e.restEncoder,r);let i=t[s];i.write(e,r-i.id.clock);for(let o=s+1;o<t.length;o++)t[o].write(e,0)},jr=(e,t,n)=>{let r=new Map;n.forEach((s,i)=>{_(t,i)>s&&r.set(i,s)}),He(t).forEach((s,i)=>{n.has(i)||r.set(i,0)}),g(e.restEncoder,r.size),W(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{Dc(e,t.clients.get(s),s,i)})},vc=(e,t)=>{let n=A(),r=y(e.restDecoder);for(let s=0;s<r;s++){let i=y(e.restDecoder),o=new Array(i),c=e.readClient(),l=y(e.restDecoder);n.set(c,{i:0,refs:o});for(let u=0;u<i;u++){let a=e.readInfo();switch(31&a){case 0:{let h=e.readLen();o[u]=new N(w(c,l),h),l+=h;break}case 10:{let h=y(e.restDecoder);o[u]=new O(w(c,l),h),l+=h;break}default:{let h=(a&192)===0,d=new S(w(c,l),null,(a&128)===128?e.readLeftID():null,null,(a&64)===64?e.readRightID():null,h?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,h&&(a&32)===32?e.readString():null,Ki(e,a));o[u]=d,l+=d.length}}}}return n},Vc=(e,t,n)=>{let r=[],s=W(n.keys()).sort((f,p)=>f-p);if(s.length===0)return null;let i=()=>{if(s.length===0)return null;let f=n.get(s[s.length-1]);for(;f.refs.length===f.i;)if(s.pop(),s.length>0)f=n.get(s[s.length-1]);else return null;return f},o=i();if(o===null)return null;let c=new Dn,l=new Map,u=(f,p)=>{let b=l.get(f);(b==null||b>p)&&l.set(f,p)},a=o.refs[o.i++],h=new Map,d=()=>{for(let f of r){let p=f.id.client,b=n.get(p);b?(b.i--,c.clients.set(p,b.refs.slice(b.i)),n.delete(p),b.i=0,b.refs=[]):c.clients.set(p,[f]),s=s.filter(m=>m!==p)}r.length=0};for(;;){if(a.constructor!==O){let p=L(h,a.id.client,()=>_(t,a.id.client))-a.id.clock;if(p<0)r.push(a),u(a.id.client,a.id.clock-1),d();else{let b=a.getMissing(e,t);if(b!==null){r.push(a);let m=n.get(b)||{refs:[],i:0};if(m.refs.length===m.i)u(b,_(t,b)),d();else{a=m.refs[m.i++];continue}}else(p===0||p<a.length)&&(a.integrate(e,p),h.set(a.id.client,a.id.clock+a.length))}}if(r.length>0)a=r.pop();else if(o!==null&&o.i<o.refs.length)a=o.refs[o.i++];else{if(o=i(),o===null)break;a=o.refs[o.i++]}}if(c.clients.size>0){let f=new J;return jr(f,c,new Map),g(f.restEncoder,0),{missing:l,update:f.toUint8Array()}}return null},Oc=(e,t)=>jr(e,t.doc.store,t.beforeState),qr=(e,t,n,r=new R(e))=>k(t,s=>{s.local=!1;let i=!1,o=s.doc,c=o.store,l=vc(r,o),u=Vc(s,c,l),a=c.pendingStructs;if(a){for(let[d,f]of a.missing)if(f<_(c,d)){i=!0;break}if(u){for(let[d,f]of u.missing){let p=a.missing.get(d);(p==null||p>f)&&a.missing.set(d,f)}a.update=$e([a.update,u.update])}}else c.pendingStructs=u;let h=Ps(r,s,c);if(c.pendingDs){let d=new R(V(c.pendingDs));y(d.restDecoder);let f=Ps(d,s,c);h&&f?c.pendingDs=$e([h,f]):c.pendingDs=h||f}else c.pendingDs=h;if(i){let d=c.pendingStructs.update;c.pendingStructs=null,jn(s.doc,d)}},n,!1),Nc=(e,t,n)=>qr(e,t,n,new j(e)),jn=(e,t,n,r=R)=>{let s=V(t);qr(s,e,n,new r(s))},Lc=(e,t,n)=>jn(e,t,n,j),Bc=(e,t,n=new Map)=>{jr(e,t.store,n),et(e,Fr(t.store))},di=(e,t=new Uint8Array([0]),n=new J)=>{let r=Gr(t);Bc(n,e,r);let s=[n.toUint8Array()];if(e.store.pendingDs&&s.push(e.store.pendingDs),e.store.pendingStructs&&s.push(Xr(e.store.pendingStructs.update,t)),s.length>1){if(n.constructor===nt)return Ei(s.map((i,o)=>o===0?i:Ti(i)));if(n.constructor===J)return $e(s)}return s[0]},Mc=(e,t)=>di(e,t,new nt),fi=e=>{let t=new Map,n=y(e.restDecoder);for(let r=0;r<n;r++){let s=y(e.restDecoder),i=y(e.restDecoder);t.set(s,i)}return t},Gr=e=>fi(new Dt(V(e))),zr=(e,t)=>(g(e.restEncoder,t.size),W(t.entries()).sort((n,r)=>r[0]-n[0]).forEach(([n,r])=>{g(e.restEncoder,n),g(e.restEncoder,r)}),e),Rc=(e,t)=>zr(e,He(t.store)),$c=(e,t=new oe)=>(e instanceof Map?zr(t,e):Rc(t,e),t.toUint8Array()),Fc=e=>$c(e,new wt),Dr=class{constructor(){this.l=[]}},Ks=()=>new Dr,Ys=(e,t)=>e.l.push(t),Ws=(e,t)=>{let n=e.l,r=n.length;e.l=n.filter(s=>t!==s),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},pi=(e,t,n)=>Ee(e.l,[t,n]),ct=class{constructor(t,n){this.client=t,this.clock=n}},At=(e,t)=>e===t||e!==null&&t!==null&&e.client===t.client&&e.clock===t.clock,w=(e,t)=>new ct(e,t),Zs=(e,t)=>{g(e,t.client),g(e,t.clock)},Qs=e=>w(y(e),y(e)),Hr=e=>{for(let[t,n]of e.doc.share.entries())if(n===e)return t;throw D()},Be=(e,t)=>{for(;t!==null;){if(t.parent===e)return!0;t=t.parent._item}return!1},jc=e=>{let t=[],n=e._start;for(;n;)t.push(n),n=n.right;console.log("Children: ",t),console.log("Children content: ",t.filter(r=>!r.deleted).map(r=>r.content))},vr=class{constructor(t,n=t.getMap("users")){let r=new Map;this.yusers=n,this.doc=t,this.clients=new Map,this.dss=r;let s=(i,o)=>{let c=i.get("ds"),l=i.get("ids"),u=a=>this.clients.set(a,o);c.observe(a=>{a.changes.added.forEach(h=>{h.content.getContent().forEach(d=>{d instanceof Uint8Array&&this.dss.set(o,ie([this.dss.get(o)||Fn(),lt(new Dt(V(d)))]))})})}),this.dss.set(o,ie(c.map(a=>lt(new Dt(V(a)))))),l.observe(a=>a.changes.added.forEach(h=>h.content.getContent().forEach(u))),l.forEach(u)};n.observe(i=>{i.keysChanged.forEach(o=>s(n.get(o),o))}),n.forEach(s)}setUserMapping(t,n,r,{filter:s=()=>!0}={}){let i=this.yusers,o=i.get(r);o||(o=new Ot,o.set("ids",new Vt),o.set("ds",new Vt),i.set(r,o)),o.get("ids").push([n]),i.observe(c=>{setTimeout(()=>{let l=i.get(r);if(l!==o){o=l,this.clients.forEach((h,d)=>{r===h&&o.get("ids").push([d])});let u=new wt,a=this.dss.get(r);a&&(et(u,a),o.get("ds").push([u.toUint8Array()]))}},0)}),t.on("afterTransaction",c=>{setTimeout(()=>{let l=o.get("ds"),u=c.deleteSet;if(c.local&&u.clients.size>0&&s(c,u)){let a=new wt;et(a,u),l.push([a.toUint8Array()])}})})}getUserByClientId(t){return this.clients.get(t)||null}getUserByDeletedId(t){for(let[n,r]of this.dss.entries())if(Rt(r,t))return n;return null}},ce=class{constructor(t,n,r,s=0){this.type=t,this.tname=n,this.item=r,this.assoc=s}},qc=e=>{let t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),e.assoc!=null&&(t.assoc=e.assoc),t},Gc=e=>new ce(e.type==null?null:w(e.type.client,e.type.clock),e.tname||null,e.item==null?null:w(e.item.client,e.item.clock),e.assoc==null?0:e.assoc),Tn=class{constructor(t,n,r=0){this.type=t,this.index=n,this.assoc=r}},zc=(e,t,n=0)=>new Tn(e,t,n),_n=(e,t,n)=>{let r=null,s=null;return e._item===null?s=Hr(e):r=w(e._item.id.client,e._item.id.clock),new ce(r,s,t,n)},Hc=(e,t,n=0)=>{let r=e._start;if(n<0){if(t===0)return _n(e,null,n);t--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>t)return _n(e,w(r.id.client,r.id.clock+t),n);t-=r.length}if(r.right===null&&n<0)return _n(e,r.lastId,n);r=r.right}return _n(e,null,n)},Jc=(e,t)=>{let{type:n,tname:r,item:s,assoc:i}=t;if(s!==null)g(e,0),Zs(e,s);else if(r!==null)Jt(e,1),ht(e,r);else if(n!==null)Jt(e,2),Zs(e,n);else throw D();return ye(e,i),e},Xc=e=>{let t=St();return Jc(t,e),G(t)},Pc=e=>{let t=null,n=null,r=null;switch(y(e)){case 0:r=Qs(e);break;case 1:n=dt(e);break;case 2:t=Qs(e)}let s=Qn(e)?be(e):0;return new ce(t,n,r,s)},Kc=e=>Pc(V(e)),Yc=(e,t)=>{let n=t.store,r=e.item,s=e.type,i=e.tname,o=e.assoc,c=null,l=0;if(r!==null){if(_(n,r.client)<=r.clock)return null;let u=Mr(n,r),a=u.item;if(!(a instanceof S))return null;if(c=a.parent,c._item===null||!c._item.deleted){l=a.deleted||!a.countable?0:u.diff+(o>=0?0:1);let h=a.left;for(;h!==null;)!h.deleted&&h.countable&&(l+=h.length),h=h.left}}else{if(i!==null)c=t.get(i);else if(s!==null){if(_(n,s.client)<=s.clock)return null;let{item:u}=Mr(n,s);if(u instanceof S&&u.content instanceof K)c=u.content.type;else return null}else throw D();o>=0?l=c._length:l=0}return zc(c,l,e.assoc)},Wc=(e,t)=>e===t||e!==null&&t!==null&&e.tname===t.tname&&At(e.item,t.item)&&At(e.type,t.type)&&e.assoc===t.assoc,Me=class{constructor(t,n){this.ds=t,this.sv=n}},Zc=(e,t)=>{let n=e.ds.clients,r=t.ds.clients,s=e.sv,i=t.sv;if(s.size!==i.size||n.size!==r.size)return!1;for(let[o,c]of s.entries())if(i.get(o)!==c)return!1;for(let[o,c]of n.entries()){let l=r.get(o)||[];if(c.length!==l.length)return!1;for(let u=0;u<c.length;u++){let a=c[u],h=l[u];if(a.clock!==h.clock||a.len!==h.len)return!1}}return!0},gi=(e,t=new oe)=>(et(t,e.ds),zr(t,e.sv),t.toUint8Array()),Qc=e=>gi(e,new wt),mi=(e,t=new In(V(e)))=>new Me(lt(t),fi(t)),tl=e=>mi(e,new Dt(V(e))),Jr=(e,t)=>new Me(e,t),el=Jr(Fn(),new Map),nl=e=>Jr(Fr(e.store),He(e.store)),ft=(e,t)=>t===void 0?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Rt(t.ds,e.id),Vr=(e,t)=>{let n=L(e.meta,Vr,st),r=e.doc.store;n.has(t)||(t.sv.forEach((s,i)=>{s<_(r,i)&&M(e,w(i,s))}),It(e,t.ds,s=>{}),n.add(t))},rl=(e,t,n=new Tt)=>{if(e.gc)throw new Error("Garbage-collection must be disabled in `originDoc`!");let{sv:r,ds:s}=t,i=new J;return e.transact(o=>{let c=0;r.forEach(l=>{l>0&&c++}),g(i.restEncoder,c);for(let[l,u]of r){if(u===0)continue;u<_(e.store,l)&&M(o,w(l,u));let a=e.store.clients.get(l)||[],h=P(a,u-1);g(i.restEncoder,h+1),i.writeClient(l),g(i.restEncoder,0);for(let d=0;d<=h;d++)a[d].write(i,0)}et(i,s)}),jn(n,i.toUint8Array(),"snapshot"),n},sl=(e,t,n=R)=>{let r=new n(V(t)),s=new rt(r,!1);for(let o=s.curr;o!==null;o=s.next())if((e.sv.get(o.id.client)||0)<o.id.clock+o.length)return!1;let i=ie([e.ds,lt(r)]);return hi(e.ds,i)},il=(e,t)=>sl(e,t,j),Dn=class{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}},He=e=>{let t=new Map;return e.clients.forEach((n,r)=>{let s=n[n.length-1];t.set(r,s.id.clock+s.length)}),t},_=(e,t)=>{let n=e.clients.get(t);if(n===void 0)return 0;let r=n[n.length-1];return r.id.clock+r.length},wi=(e,t)=>{let n=e.clients.get(t.id.client);if(n===void 0)n=[],e.clients.set(t.id.client,n);else{let r=n[n.length-1];if(r.id.clock+r.length!==t.id.clock)throw D()}n.push(t)},P=(e,t)=>{let n=0,r=e.length-1,s=e[r],i=s.id.clock;if(i===t)return r;let o=B(t/(i+s.length-1)*r);for(;n<=r;){if(s=e[o],i=s.id.clock,i<=t){if(t<i+s.length)return o;n=o+1}else r=o-1;o=B((n+r)/2)}throw D()},ol=(e,t)=>{let n=e.clients.get(t.client);return n[P(n,t.clock)]},Ve=ol,Or=(e,t,n)=>{let r=P(t,n),s=t[r];return s.id.clock<n&&s instanceof S?(t.splice(r+1,0,$n(e,s,n-s.id.clock)),r+1):r},M=(e,t)=>{let n=e.doc.store.clients.get(t.client);return n[Or(e,n,t.clock)]},ti=(e,t,n)=>{let r=t.clients.get(n.client),s=P(r,n.clock),i=r[s];return n.clock!==i.id.clock+i.length-1&&i.constructor!==N&&r.splice(s+1,0,$n(e,i,n.clock-i.id.clock+1)),i},cl=(e,t,n)=>{let r=e.clients.get(t.id.client);r[P(r,t.id.clock)]=n},yi=(e,t,n,r,s)=>{if(r===0)return;let i=n+r,o=Or(e,t,n),c;do c=t[o++],i<c.id.clock+c.length&&Or(e,t,i),s(c);while(o<t.length&&t[o].id.clock<i)},vn=class{constructor(t,n,r){this.doc=t,this.deleteSet=new mt,this.beforeState=He(t.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=n,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}},ei=(e,t)=>t.deleteSet.clients.size===0&&!es(t.afterState,(n,r)=>t.beforeState.get(r)!==n)?!1:($r(t.deleteSet),Oc(e,t),et(e,t.deleteSet),!0),ni=(e,t,n)=>{let r=t._item;(r===null||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&L(e.changed,t,st).add(n)},Cn=(e,t)=>{let n=e[t],r=e[t-1],s=t;for(;s>0;n=r,r=e[--s-1]){if(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n)){n instanceof S&&n.parentSub!==null&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);continue}break}let i=t-s;return i&&e.splice(t+1-i,i),i},xi=(e,t,n)=>{for(let[r,s]of e.clients.entries()){let i=t.clients.get(r);for(let o=s.length-1;o>=0;o--){let c=s[o],l=c.clock+c.len;for(let u=P(i,c.clock),a=i[u];u<i.length&&a.id.clock<l;a=i[++u]){let h=i[u];if(c.clock+c.len<=h.id.clock)break;h instanceof S&&h.deleted&&!h.keep&&n(h)&&h.gc(t,!1)}}}},bi=(e,t)=>{e.clients.forEach((n,r)=>{let s=t.clients.get(r);for(let i=n.length-1;i>=0;i--){let o=n[i],c=We(s.length-1,1+P(s,o.clock+o.len-1));for(let l=c,u=s[l];l>0&&u.id.clock>=o.clock;u=s[l])l-=1+Cn(s,l)}})},ll=(e,t,n)=>{xi(e,t,n),bi(e,t)},ki=(e,t)=>{if(t<e.length){let n=e[t],r=n.doc,s=r.store,i=n.deleteSet,o=n._mergeStructs;try{$r(i),n.afterState=He(n.doc.store),r.emit("beforeObserverCalls",[n,r]);let c=[];n.changed.forEach((l,u)=>c.push(()=>{(u._item===null||!u._item.deleted)&&u._callObserver(n,l)})),c.push(()=>{n.changedParentTypes.forEach((l,u)=>{u._dEH.l.length>0&&(u._item===null||!u._item.deleted)&&(l=l.filter(a=>a.target._item===null||!a.target._item.deleted),l.forEach(a=>{a.currentTarget=u,a._path=null}),l.sort((a,h)=>a.path.length-h.path.length),pi(u._dEH,l,n))})}),c.push(()=>r.emit("afterTransaction",[n,r])),Ee(c,[]),n._needFormattingCleanup&&Dl(n)}finally{r.gc&&xi(i,s,r.gcFilter),bi(i,s),n.afterState.forEach((a,h)=>{let d=n.beforeState.get(h)||0;if(d!==a){let f=s.clients.get(h),p=ot(P(f,d),1);for(let b=f.length-1;b>=p;)b-=1+Cn(f,b)}});for(let a=o.length-1;a>=0;a--){let{client:h,clock:d}=o[a].id,f=s.clients.get(h),p=P(f,d);p+1<f.length&&Cn(f,p+1)>1||p>0&&Cn(f,p)}if(!n.local&&n.afterState.get(r.clientID)!==n.beforeState.get(r.clientID)&&(kn(se,Te,"[yjs] ",De,ve,"Changed the client-id because another client seems to be using it."),r.clientID=ui()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){let a=new nt;ei(a,n)&&r.emit("update",[a.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){let a=new J;ei(a,n)&&r.emit("updateV2",[a.toUint8Array(),n.origin,r,n])}let{subdocsAdded:c,subdocsLoaded:l,subdocsRemoved:u}=n;(c.size>0||u.size>0||l.size>0)&&(c.forEach(a=>{a.clientID=r.clientID,a.collectionid==null&&(a.collectionid=r.collectionid),r.subdocs.add(a)}),u.forEach(a=>r.subdocs.delete(a)),r.emit("subdocs",[{loaded:l,added:c,removed:u},r,n]),u.forEach(a=>a.destroy())),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):ki(e,t+1)}}},k=(e,t,n=null,r=!0)=>{let s=e._transactionCleanups,i=!1,o=null;e._transaction===null&&(i=!0,e._transaction=new vn(e,n,r),s.push(e._transaction),s.length===1&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{o=t(e._transaction)}finally{if(i){let c=e._transaction===s[0];e._transaction=null,c&&ki(s,0)}}return o},Nr=class{constructor(t,n){this.insertions=n,this.deletions=t,this.meta=new Map}},ri=(e,t,n)=>{It(e,n.deletions,r=>{r instanceof S&&t.scope.some(s=>Be(s,r))&&Zr(r,!1)})},si=(e,t,n)=>{let r=null,s=e.doc,i=e.scope;if(k(s,o=>{for(;t.length>0&&e.currStackItem===null;){let c=s.store,l=t.pop(),u=new Set,a=[],h=!1;It(o,l.insertions,d=>{if(d instanceof S){if(d.redone!==null){let{item:f,diff:p}=Mr(c,d.id);p>0&&(f=M(o,w(f.id.client,f.id.clock+p))),d=f}!d.deleted&&i.some(f=>Be(f,d))&&a.push(d)}}),It(o,l.deletions,d=>{d instanceof S&&i.some(f=>Be(f,d))&&!Rt(l.insertions,d.id)&&u.add(d)}),u.forEach(d=>{h=Pi(o,d,u,l.insertions,e.ignoreRemoteMapChanges,e)!==null||h});for(let d=a.length-1;d>=0;d--){let f=a[d];e.deleteFilter(f)&&(f.delete(o),h=!0)}e.currStackItem=h?l:null}o.changed.forEach((c,l)=>{c.has(null)&&l._searchMarker&&(l._searchMarker.length=0)}),r=o},e),e.currStackItem!=null){let o=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:e.currStackItem,type:n,changedParentTypes:o,origin:e},e]),e.currStackItem=null}return e.currStackItem},Lr=class extends $t{constructor(t,{captureTimeout:n=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:c=it(t)?t[0].doc:t.doc}={}){super(),this.scope=[],this.doc=c,this.addToScope(t),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=n,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(m=>l.changedParentTypes.has(m))||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;let u=this.undoing,a=this.redoing,h=u?this.redoStack:this.undoStack;u?this.stopCapturing():a||this.clear(!1,!0);let d=new mt;l.afterState.forEach((m,x)=>{let q=l.beforeState.get(x)||0,Qr=m-q;Qr>0&&Le(d,x,q,Qr)});let f=rn(),p=!1;if(this.lastChange>0&&f-this.lastChange<this.captureTimeout&&h.length>0&&!u&&!a){let m=h[h.length-1];m.deletions=ie([m.deletions,l.deleteSet]),m.insertions=ie([m.insertions,d])}else h.push(new Nr(l.deleteSet,d)),p=!0;!u&&!a&&(this.lastChange=f),It(l,l.deleteSet,m=>{m instanceof S&&this.scope.some(x=>Be(x,m))&&Zr(m,!0)});let b=[{stackItem:h[h.length-1],origin:l.origin,type:u?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",b):this.emit("stack-item-updated",b)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(t){t=it(t)?t:[t],t.forEach(n=>{this.scope.every(r=>r!==n)&&(n.doc!==this.doc&&qs("[yjs#509] Not same Y.Doc"),this.scope.push(n))})}addTrackedOrigin(t){this.trackedOrigins.add(t)}removeTrackedOrigin(t){this.trackedOrigins.delete(t)}clear(t=!0,n=!0){(t&&this.canUndo()||n&&this.canRedo())&&this.doc.transact(r=>{t&&(this.undoStack.forEach(s=>ri(r,this,s)),this.undoStack=[]),n&&(this.redoStack.forEach(s=>ri(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:t,redoStackCleared:n}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let t;try{t=si(this,this.undoStack,"undo")}finally{this.undoing=!1}return t}redo(){this.redoing=!0;let t;try{t=si(this,this.redoStack,"redo")}finally{this.redoing=!1}return t}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}};function*al(e){let t=y(e.restDecoder);for(let n=0;n<t;n++){let r=y(e.restDecoder),s=e.readClient(),i=y(e.restDecoder);for(let o=0;o<r;o++){let c=e.readInfo();if(c===10){let l=y(e.restDecoder);yield new O(w(s,i),l),i+=l}else if(31&c){let l=(c&192)===0,u=new S(w(s,i),null,(c&128)===128?e.readLeftID():null,null,(c&64)===64?e.readRightID():null,l?e.readParentInfo()?e.readString():e.readLeftID():null,l&&(c&32)===32?e.readString():null,Ki(e,c));yield u,i+=u.length}else{let l=e.readLen();yield new N(w(s,i),l),i+=l}}}}var rt=class{constructor(t,n){this.gen=al(t),this.curr=null,this.done=!1,this.filterSkips=n,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===O);return this.curr}},hl=e=>Si(e,j),Si=(e,t=R)=>{let n=[],r=new t(V(e)),s=new rt(r,!1);for(let o=s.curr;o!==null;o=s.next())n.push(o);kn("Structs: ",n);let i=lt(r);kn("DeleteSet: ",i)},ul=e=>_i(e,j),_i=(e,t=R)=>{let n=[],r=new t(V(e)),s=new rt(r,!1);for(let i=s.curr;i!==null;i=s.next())n.push(i);return{structs:n,ds:lt(r)}},Re=class{constructor(t){this.currClient=0,this.startClock=0,this.written=0,this.encoder=t,this.clientStructs=[]}},Ei=e=>$e(e,j,nt),Ui=(e,t=oe,n=R)=>{let r=new t,s=new rt(new n(V(e)),!1),i=s.curr;if(i!==null){let o=0,c=i.id.client,l=i.id.clock!==0,u=l?0:i.id.clock+i.length;for(;i!==null;i=s.next())c!==i.id.client&&(u!==0&&(o++,g(r.restEncoder,c),g(r.restEncoder,u)),c=i.id.client,u=0,l=i.id.clock!==0),i.constructor===O&&(l=!0),l||(u=i.id.clock+i.length);u!==0&&(o++,g(r.restEncoder,c),g(r.restEncoder,u));let a=St();return g(a,o),hs(a,r.restEncoder),r.restEncoder=a,r.toUint8Array()}else return g(r.restEncoder,0),r.toUint8Array()},dl=e=>Ui(e,wt,j),Ci=(e,t=R)=>{let n=new Map,r=new Map,s=new rt(new t(V(e)),!1),i=s.curr;if(i!==null){let o=i.id.client,c=i.id.clock;for(n.set(o,c);i!==null;i=s.next())o!==i.id.client&&(r.set(o,c),n.set(i.id.client,i.id.clock),o=i.id.client),c=i.id.clock+i.length;r.set(o,c)}return{from:n,to:r}},fl=e=>Ci(e,j),pl=(e,t)=>{if(e.constructor===N){let{client:n,clock:r}=e.id;return new N(w(n,r+t),e.length-t)}else if(e.constructor===O){let{client:n,clock:r}=e.id;return new O(w(n,r+t),e.length-t)}else{let n=e,{client:r,clock:s}=n.id;return new S(w(r,s+t),null,w(r,s+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},$e=(e,t=R,n=J)=>{if(e.length===1)return e[0];let r=e.map(a=>new t(V(a))),s=r.map(a=>new rt(a,!0)),i=null,o=new n,c=new Re(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,f)=>{if(d.curr.id.client===f.curr.id.client){let p=d.curr.id.clock-f.curr.id.clock;return p===0?d.curr.constructor===f.curr.constructor?0:d.curr.constructor===O?1:-1:p}else return f.curr.id.client-d.curr.id.client}),s.length!==0;){let a=s[0],h=a.curr.id.client;if(i!==null){let d=a.curr,f=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=a.next(),f=!0;if(d===null||d.id.client!==h||f&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(h!==i.struct.id.client)pt(c,i.struct,i.offset),i={struct:d,offset:0},a.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===O)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{pt(c,i.struct,i.offset);let p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new O(w(h,i.struct.id.clock+i.struct.length),p),offset:0}}else{let p=i.struct.id.clock+i.struct.length-d.id.clock;p>0&&(i.struct.constructor===O?i.struct.length-=p:d=pl(d,p)),i.struct.mergeWith(d)||(pt(c,i.struct,i.offset),i={struct:d,offset:0},a.next())}}else i={struct:a.curr,offset:0},a.next();for(let d=a.curr;d!==null&&d.id.client===h&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==O;d=a.next())pt(c,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(pt(c,i.struct,i.offset),i=null),Pr(c);let l=r.map(a=>lt(a)),u=ie(l);return et(o,u),o.toUint8Array()},Xr=(e,t,n=R,r=J)=>{let s=Gr(t),i=new r,o=new Re(i),c=new n(V(e)),l=new rt(c,!1);for(;l.curr;){let a=l.curr,h=a.id.client,d=s.get(h)||0;if(l.curr.constructor===O){l.next();continue}if(a.id.clock+a.length>d)for(pt(o,a,ot(d-a.id.clock,0)),l.next();l.curr&&l.curr.id.client===h;)pt(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===h&&l.curr.id.clock+l.curr.length<=d;)l.next()}Pr(o);let u=lt(c);return et(i,u),i.toUint8Array()},gl=(e,t)=>Xr(e,t,j,nt),Ai=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:G(e.encoder.restEncoder)}),e.encoder.restEncoder=St(),e.written=0)},pt=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&Ai(e),e.written===0&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),g(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},Pr=e=>{Ai(e);let t=e.encoder.restEncoder;g(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){let r=e.clientStructs[n];g(t,r.written),Xt(t,r.restEncoder)}},qn=(e,t,n,r)=>{let s=new n(V(e)),i=new rt(s,!1),o=new r,c=new Re(o);for(let u=i.curr;u!==null;u=i.next())pt(c,t(u),0);Pr(c);let l=lt(s);return et(o,l),o.toUint8Array()},Ii=({formatting:e=!0,subdocs:t=!0,yxml:n=!0}={})=>{let r=0,s=A(),i=A(),o=A(),c=A();return c.set(null,null),l=>{switch(l.constructor){case N:case O:return l;case S:{let u=l,a=u.content;switch(a.constructor){case he:break;case K:{if(n){let h=a.type;h instanceof Lt&&(h.nodeName=L(i,h.nodeName,()=>"node-"+r)),h instanceof Ge&&(h.hookName=L(i,h.hookName,()=>"hook-"+r))}break}case yt:{let h=a;h.arr=h.arr.map(()=>r);break}case Bt:{let h=a;h.content=new Uint8Array([r]);break}case Mt:{let h=a;t&&(h.opts={},h.doc.guid=r+"");break}case at:{let h=a;h.embed={};break}case E:{let h=a;e&&(h.key=L(o,h.key,()=>r+""),h.value=L(c,h.value,()=>({i:r})));break}case ze:{let h=a;h.arr=h.arr.map(()=>r);break}case Y:{let h=a;h.str=Qe(r%10+"",h.str.length);break}default:D()}return u.parentSub&&(u.parentSub=L(s,u.parentSub,()=>r+"")),r++,l}default:D()}}},ml=(e,t)=>qn(e,Ii(t),j,nt),wl=(e,t)=>qn(e,Ii(t),R,J),yl=e=>qn(e,lr,j,J),Ti=e=>qn(e,lr,R,nt),ii="You must not compute changes after the event-handler fired.",vt=class{constructor(t,n){this.target=t,this.currentTarget=t,this.transaction=n,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=xl(this.currentTarget,this.target))}deletes(t){return Rt(this.transaction.deleteSet,t.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw z(ii);let t=new Map,n=this.target;this.transaction.changed.get(n).forEach(s=>{if(s!==null){let i=n._map.get(s),o,c;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",c=Ke(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",c=Ke(l.content.getContent())):(o="add",c=void 0)}else if(this.deletes(i))o="delete",c=Ke(i.content.getContent());else return;t.set(s,{action:o,oldValue:c})}}),this._keys=t}return this._keys}get delta(){return this.changes.delta}adds(t){return t.id.clock>=(this.transaction.beforeState.get(t.id.client)||0)}get changes(){let t=this._changes;if(t===null){if(this.transaction.doc._transactionCleanups.length===0)throw z(ii);let n=this.target,r=st(),s=st(),i=[];if(t={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(n).has(null)){let c=null,l=()=>{c&&i.push(c)};for(let u=n._start;u!==null;u=u.right)u.deleted?this.deletes(u)&&!this.adds(u)&&((c===null||c.delete===void 0)&&(l(),c={delete:0}),c.delete+=u.length,s.add(u)):this.adds(u)?((c===null||c.insert===void 0)&&(l(),c={insert:[]}),c.insert=c.insert.concat(u.content.getContent()),r.add(u)):((c===null||c.retain===void 0)&&(l(),c={retain:0}),c.retain+=u.length);c!==null&&c.retain===void 0&&l()}this._changes=t}return t}},xl=(e,t)=>{let n=[];for(;t._item!==null&&t!==e;){if(t._item.parentSub!==null)n.unshift(t._item.parentSub);else{let r=0,s=t._item.parent._start;for(;s!==t._item&&s!==null;)s.deleted||r++,s=s.right;n.unshift(r)}t=t._item.parent}return n},Di=80,Kr=0,Br=class{constructor(t,n){t.marker=!0,this.p=t,this.index=n,this.timestamp=Kr++}},bl=e=>{e.timestamp=Kr++},vi=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Kr++},kl=(e,t,n)=>{if(e.length>=Di){let r=e.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return vi(r,t,n),r}else{let r=new Br(t,n);return e.push(r),r}},Gn=(e,t)=>{if(e._start===null||t===0||e._searchMarker===null)return null;let n=e._searchMarker.length===0?null:e._searchMarker.reduce((i,o)=>xt(t-i.index)<xt(t-o.index)?i:o),r=e._start,s=0;for(n!==null&&(r=n.p,s=n.index,bl(n));r.right!==null&&s<t;){if(!r.deleted&&r.countable){if(t<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>t;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return n!==null&&xt(n.index-s)<r.parent.length/Di?(vi(n,r,s),n):kl(e._searchMarker,r,s)},Fe=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){let s=e[r];if(n>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){e.splice(r,1);continue}s.p=i,i.marker=!0}(t<s.index||n>0&&t===s.index)&&(s.index=ot(t,s.index+n))}},Sl=e=>{let t=e._start,n=[];for(;t;)n.push(t),t=t.right;return n},zn=(e,t,n)=>{let r=e,s=t.changedParentTypes;for(;L(s,e,()=>[]).push(n),e._item!==null;)e=e._item.parent;pi(r._eH,n,t)},C=class{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=Ks(),this._dEH=Ks(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(t,n){this.doc=t,this._item=n}_copy(){throw H()}clone(){throw H()}_write(t){}get _first(){let t=this._start;for(;t!==null&&t.deleted;)t=t.right;return t}_callObserver(t,n){!t.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(t){Ys(this._eH,t)}observeDeep(t){Ys(this._dEH,t)}unobserve(t){Ws(this._eH,t)}unobserveDeep(t){Ws(this._dEH,t)}toJSON(){}},Vi=(e,t,n)=>{t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t,s=[],i=e._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){let o=i.content.getContent();if(o.length<=t)t-=o.length;else{for(let c=t;c<o.length&&r>0;c++)s.push(o[c]),r--;t=0}}i=i.right}return s},Oi=e=>{let t=[],n=e._start;for(;n!==null;){if(n.countable&&!n.deleted){let r=n.content.getContent();for(let s=0;s<r.length;s++)t.push(r[s])}n=n.right}return t},_l=(e,t)=>{let n=[],r=e._start;for(;r!==null;){if(r.countable&&ft(r,t)){let s=r.content.getContent();for(let i=0;i<s.length;i++)n.push(s[i])}r=r.right}return n},je=(e,t)=>{let n=0,r=e._start;for(;r!==null;){if(r.countable&&!r.deleted){let s=r.content.getContent();for(let i=0;i<s.length;i++)t(s[i],n++,e)}r=r.right}},Ni=(e,t)=>{let n=[];return je(e,(r,s)=>{n.push(t(r,s,e))}),n},El=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(n===null){for(;t!==null&&t.deleted;)t=t.right;if(t===null)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}let s=n[r++];return n.length<=r&&(n=null),{done:!1,value:s}}}},Li=(e,t)=>{let n=Gn(e,t),r=e._start;for(n!==null&&(r=n.p,t-=n.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},Vn=(e,t,n,r)=>{let s=n,i=e.doc,o=i.clientID,c=i.store,l=n===null?t._start:n.right,u=[],a=()=>{u.length>0&&(s=new S(w(o,_(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new yt(u)),s.integrate(e,0),u=[])};r.forEach(h=>{if(h===null)u.push(h);else switch(h.constructor){case Number:case Object:case Boolean:case Array:case String:u.push(h);break;default:switch(a(),h.constructor){case Uint8Array:case ArrayBuffer:s=new S(w(o,_(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new Bt(new Uint8Array(h))),s.integrate(e,0);break;case Tt:s=new S(w(o,_(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new Mt(h)),s.integrate(e,0);break;default:if(h instanceof C)s=new S(w(o,_(c,o)),s,s&&s.lastId,l,l&&l.id,t,null,new K(h)),s.integrate(e,0);else throw new Error("Unexpected content type in insert operation")}}}),a()},Bi=()=>z("Length exceeded!"),Mi=(e,t,n,r)=>{if(n>t._length)throw Bi();if(n===0)return t._searchMarker&&Fe(t._searchMarker,n,r.length),Vn(e,t,null,r);let s=n,i=Gn(t,n),o=t._start;for(i!==null&&(o=i.p,n-=i.index,n===0&&(o=o.prev,n+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(n<=o.length){n<o.length&&M(e,w(o.id.client,o.id.clock+n));break}n-=o.length}return t._searchMarker&&Fe(t._searchMarker,s,r.length),Vn(e,t,o,r)},Ul=(e,t,n)=>{let s=(t._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:t._start}).p;if(s)for(;s.right;)s=s.right;return Vn(e,t,s,n)},Ri=(e,t,n,r)=>{if(r===0)return;let s=n,i=r,o=Gn(t,n),c=t._start;for(o!==null&&(c=o.p,n-=o.index);c!==null&&n>0;c=c.right)!c.deleted&&c.countable&&(n<c.length&&M(e,w(c.id.client,c.id.clock+n)),n-=c.length);for(;r>0&&c!==null;)c.deleted||(r<c.length&&M(e,w(c.id.client,c.id.clock+r)),c.delete(e),r-=c.length),c=c.right;if(r>0)throw Bi();t._searchMarker&&Fe(t._searchMarker,s,-i+r)},On=(e,t,n)=>{let r=t._map.get(n);r!==void 0&&r.delete(e)},Yr=(e,t,n,r)=>{let s=t._map.get(n)||null,i=e.doc,o=i.clientID,c;if(r==null)c=new yt([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:c=new yt([r]);break;case Uint8Array:c=new Bt(r);break;case Tt:c=new Mt(r);break;default:if(r instanceof C)c=new K(r);else throw new Error("Unexpected content type")}new S(w(o,_(i.store,o)),s,s&&s.lastId,null,null,t,n,c).integrate(e,0)},Wr=(e,t)=>{let n=e._map.get(t);return n!==void 0&&!n.deleted?n.content.getContent()[n.length-1]:void 0},$i=e=>{let t={};return e._map.forEach((n,r)=>{n.deleted||(t[r]=n.content.getContent()[n.length-1])}),t},Fi=(e,t)=>{let n=e._map.get(t);return n!==void 0&&!n.deleted},Cl=(e,t,n)=>{let r=e._map.get(t)||null;for(;r!==null&&(!n.sv.has(r.id.client)||r.id.clock>=(n.sv.get(r.id.client)||0));)r=r.left;return r!==null&&ft(r,n)?r.content.getContent()[r.length-1]:void 0},ji=(e,t)=>{let n={};return e._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!t.sv.has(i.id.client)||i.id.clock>=(t.sv.get(i.id.client)||0));)i=i.left;i!==null&&ft(i,t)&&(n[s]=i.content.getContent()[i.length-1])}),n},En=e=>Hs(e.entries(),t=>!t[1].deleted),Nn=class extends vt{constructor(t,n){super(t,n),this._transaction=n}},Vt=class e extends C{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(t){let n=new e;return n.push(t),n}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),t}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(t,n){super._callObserver(t,n),zn(this,t,new Nn(this,t))}insert(t,n){this.doc!==null?k(this.doc,r=>{Mi(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}push(t){this.doc!==null?k(this.doc,n=>{Ul(n,this,t)}):this._prelimContent.push(...t)}unshift(t){this.insert(0,t)}delete(t,n=1){this.doc!==null?k(this.doc,r=>{Ri(r,this,t,n)}):this._prelimContent.splice(t,n)}get(t){return Li(this,t)}toArray(){return Oi(this)}slice(t=0,n=this.length){return Vi(this,t,n)}toJSON(){return this.map(t=>t instanceof C?t.toJSON():t)}map(t){return Ni(this,t)}forEach(t){je(this,t)}[Symbol.iterator](){return El(this)}_write(t){t.writeTypeRef(Jl)}},Al=e=>new Vt,Ln=class extends vt{constructor(t,n,r){super(t,n),this.keysChanged=r}},Ot=class e extends C{constructor(t){super(),this._prelimContent=null,t===void 0?this._prelimContent=new Map:this._prelimContent=new Map(t)}_integrate(t,n){super._integrate(t,n),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return this.forEach((n,r)=>{t.set(r,n instanceof C?n.clone():n)}),t}_callObserver(t,n){zn(this,t,new Ln(this,t,n))}toJSON(){let t={};return this._map.forEach((n,r)=>{if(!n.deleted){let s=n.content.getContent()[n.length-1];t[r]=s instanceof C?s.toJSON():s}}),t}get size(){return[...En(this._map)].length}keys(){return Sn(En(this._map),t=>t[0])}values(){return Sn(En(this._map),t=>t[1].content.getContent()[t[1].length-1])}entries(){return Sn(En(this._map),t=>[t[0],t[1].content.getContent()[t[1].length-1]])}forEach(t){this._map.forEach((n,r)=>{n.deleted||t(n.content.getContent()[n.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(t){this.doc!==null?k(this.doc,n=>{On(n,this,t)}):this._prelimContent.delete(t)}set(t,n){return this.doc!==null?k(this.doc,r=>{Yr(r,this,t,n)}):this._prelimContent.set(t,n),n}get(t){return Wr(this,t)}has(t){return Fi(this,t)}clear(){this.doc!==null?k(this.doc,t=>{this.forEach(function(n,r,s){On(t,s,r)})}):this._prelimContent.clear()}_write(t){t.writeTypeRef(Xl)}},Il=e=>new Ot,gt=(e,t)=>e===t||typeof e=="object"&&typeof t=="object"&&e&&t&&or(e,t),qe=class{constructor(t,n,r,s){this.left=t,this.right=n,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&D(),this.right.content.constructor){case E:this.right.deleted||ue(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}},oi=(e,t,n)=>{for(;t.right!==null&&n>0;){switch(t.right.content.constructor){case E:t.right.deleted||ue(t.currentAttributes,t.right.content);break;default:t.right.deleted||(n<t.right.length&&M(e,w(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);break}t.left=t.right,t.right=t.right.right}return t},Un=(e,t,n,r)=>{let s=new Map,i=r?Gn(t,n):null;if(i){let o=new qe(i.p.left,i.p,i.index,s);return oi(e,o,n-i.index)}else{let o=new qe(null,t._start,0,s);return oi(e,o,n)}},qi=(e,t,n,r)=>{for(;n.right!==null&&(n.right.deleted===!0||n.right.content.constructor===E&>(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();let s=e.doc,i=s.clientID;r.forEach((o,c)=>{let l=n.left,u=n.right,a=new S(w(i,_(s.store,i)),l,l&&l.lastId,u,u&&u.id,t,null,new E(c,o));a.integrate(e,0),n.right=a,n.forward()})},ue=(e,t)=>{let{key:n,value:r}=t;r===null?e.delete(n):e.set(n,r)},Gi=(e,t)=>{var n;for(;e.right!==null;){if(!(e.right.deleted||e.right.content.constructor===E&>((n=t[e.right.content.key])!=null?n:null,e.right.content.value)))break;e.forward()}},zi=(e,t,n,r)=>{var c;let s=e.doc,i=s.clientID,o=new Map;for(let l in r){let u=r[l],a=(c=n.currentAttributes.get(l))!=null?c:null;if(!gt(a,u)){o.set(l,a);let{left:h,right:d}=n;n.right=new S(w(i,_(s.store,i)),h,h&&h.lastId,d,d&&d.id,t,null,new E(l,u)),n.right.integrate(e,0),n.forward()}}return o},Ir=(e,t,n,r,s)=>{n.currentAttributes.forEach((d,f)=>{s[f]===void 0&&(s[f]=null)});let i=e.doc,o=i.clientID;Gi(n,s);let c=zi(e,t,n,s),l=r.constructor===String?new Y(r):r instanceof C?new K(r):new at(r),{left:u,right:a,index:h}=n;t._searchMarker&&Fe(t._searchMarker,n.index,l.getLength()),a=new S(w(o,_(i.store,o)),u,u&&u.lastId,a,a&&a.id,t,null,l),a.integrate(e,0),n.right=a,n.index=h,n.forward(),qi(e,t,n,c)},ci=(e,t,n,r,s)=>{let i=e.doc,o=i.clientID;Gi(n,s);let c=zi(e,t,n,s);t:for(;n.right!==null&&(r>0||c.size>0&&(n.right.deleted||n.right.content.constructor===E));){if(!n.right.deleted)switch(n.right.content.constructor){case E:{let{key:l,value:u}=n.right.content,a=s[l];if(a!==void 0){if(gt(a,u))c.delete(l);else{if(r===0)break t;c.set(l,u)}n.right.delete(e)}else n.currentAttributes.set(l,u);break}default:r<n.right.length&&M(e,w(n.right.id.client,n.right.id.clock+r)),r-=n.right.length;break}n.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
|
10843
|
+
`;n.right=new S(w(o,_(i.store,o)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new Y(l)),n.right.integrate(e,0),n.forward()}qi(e,t,n,c)},Hi=(e,t,n,r,s)=>{var u,a;let i=t,o=A();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===E){let h=i.content;o.set(h.key,h)}i=i.right}let c=0,l=!1;for(;t!==i;){if(n===t&&(l=!0),!t.deleted){let h=t.content;switch(h.constructor){case E:{let{key:d,value:f}=h,p=(u=r.get(d))!=null?u:null;(o.get(d)!==h||p===f)&&(t.delete(e),c++,!l&&((a=s.get(d))!=null?a:null)===f&&p!==f&&(p===null?s.delete(d):s.set(d,p))),!l&&!t.deleted&&ue(s,h);break}}}t=t.right}return c},Tl=(e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;let n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===E){let r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}},Ji=e=>{let t=0;return k(e.doc,n=>{let r=e._start,s=e._start,i=A(),o=Pe(i);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case E:ue(o,s.content);break;default:t+=Hi(n,r,s,i,o),i=Pe(o),r=s;break}s=s.right}}),t},Dl=e=>{let t=new Set,n=e.doc;for(let[r,s]of e.afterState.entries()){let i=e.beforeState.get(r)||0;s!==i&&yi(e,n.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===E&&o.constructor!==N&&t.add(o.parent)})}k(n,r=>{It(e,e.deleteSet,s=>{if(s instanceof N||!s.parent._hasFormatting||t.has(s.parent))return;let i=s.parent;s.content.constructor===E?t.add(i):Tl(r,s)});for(let s of t)Ji(s)})},li=(e,t,n)=>{let r=n,s=Pe(t.currentAttributes),i=t.right;for(;n>0&&t.right!==null;){if(t.right.deleted===!1)switch(t.right.content.constructor){case K:case at:case Y:n<t.right.length&&M(e,w(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e);break}t.forward()}i&&Hi(e,i,t.right,s,t.currentAttributes);let o=(t.left||t.right).parent;return o._searchMarker&&Fe(o._searchMarker,t.index,-r+n),t},Bn=class extends vt{constructor(t,n,r){super(t,n),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){let t={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=t}return this._changes}get delta(){if(this._delta===null){let t=this.target.doc,n=[];k(t,r=>{var f,p,b;let s=new Map,i=new Map,o=this.target._start,c=null,l={},u="",a=0,h=0,d=()=>{if(c!==null){let m=null;switch(c){case"delete":h>0&&(m={delete:h}),h=0;break;case"insert":(typeof u=="object"||u.length>0)&&(m={insert:u},s.size>0&&(m.attributes={},s.forEach((x,q)=>{x!==null&&(m.attributes[q]=x)}))),u="";break;case"retain":a>0&&(m={retain:a},bs(l)||(m.attributes=ys({},l))),a=0;break}m&&n.push(m),c=null}};for(;o!==null;){switch(o.content.constructor){case K:case at:this.adds(o)?this.deletes(o)||(d(),c="insert",u=o.content.getContent()[0],d()):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),h+=1):o.deleted||(c!=="retain"&&(d(),c="retain"),a+=1);break;case Y:this.adds(o)?this.deletes(o)||(c!=="insert"&&(d(),c="insert"),u+=o.content.str):this.deletes(o)?(c!=="delete"&&(d(),c="delete"),h+=o.length):o.deleted||(c!=="retain"&&(d(),c="retain"),a+=o.length);break;case E:{let{key:m,value:x}=o.content;if(this.adds(o)){if(!this.deletes(o)){let q=(f=s.get(m))!=null?f:null;gt(q,x)?x!==null&&o.delete(r):(c==="retain"&&d(),gt(x,(p=i.get(m))!=null?p:null)?delete l[m]:l[m]=x)}}else if(this.deletes(o)){i.set(m,x);let q=(b=s.get(m))!=null?b:null;gt(q,x)||(c==="retain"&&d(),l[m]=q)}else if(!o.deleted){i.set(m,x);let q=l[m];q!==void 0&&(gt(q,x)?q!==null&&o.delete(r):(c==="retain"&&d(),x===null?delete l[m]:l[m]=x))}o.deleted||(c==="insert"&&d(),ue(s,o.content));break}}o=o.right}for(d();n.length>0;){let m=n[n.length-1];if(m.retain!==void 0&&m.attributes===void 0)n.pop();else break}}),this._delta=n}return this._delta}},le=class e extends C{constructor(t){super(),this._pending=t!==void 0?[()=>this.insert(0,t)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(t,n){super._integrate(t,n);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}_callObserver(t,n){super._callObserver(t,n);let r=new Bn(this,t,n);zn(this,t,r),!t.local&&this._hasFormatting&&(t._needFormattingCleanup=!0)}toString(){let t="",n=this._start;for(;n!==null;)!n.deleted&&n.countable&&n.content.constructor===Y&&(t+=n.content.str),n=n.right;return t}toJSON(){return this.toString()}applyDelta(t,{sanitize:n=!0}={}){this.doc!==null?k(this.doc,r=>{let s=new qe(null,this._start,0,new Map);for(let i=0;i<t.length;i++){let o=t[i];if(o.insert!==void 0){let c=!n&&typeof o.insert=="string"&&i===t.length-1&&s.right===null&&o.insert.slice(-1)===`
|
|
10844
|
+
`?o.insert.slice(0,-1):o.insert;(typeof c!="string"||c.length>0)&&Ir(r,this,s,c,o.attributes||{})}else o.retain!==void 0?ci(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&li(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(t))}toDelta(t,n,r){let s=[],i=new Map,o=this.doc,c="",l=this._start;function u(){if(c.length>0){let h={},d=!1;i.forEach((p,b)=>{d=!0,h[b]=p});let f={insert:c};d&&(f.attributes=h),s.push(f),c=""}}let a=()=>{for(;l!==null;){if(ft(l,t)||n!==void 0&&ft(l,n))switch(l.content.constructor){case Y:{let h=i.get("ychange");t!==void 0&&!ft(l,t)?(h===void 0||h.user!==l.id.client||h.type!=="removed")&&(u(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):n!==void 0&&!ft(l,n)?(h===void 0||h.user!==l.id.client||h.type!=="added")&&(u(),i.set("ychange",r?r("added",l.id):{type:"added"})):h!==void 0&&(u(),i.delete("ychange")),c+=l.content.str;break}case K:case at:{u();let h={insert:l.content.getContent()[0]};if(i.size>0){let d={};h.attributes=d,i.forEach((f,p)=>{d[p]=f})}s.push(h);break}case E:ft(l,t)&&(u(),ue(i,l.content));break}l=l.right}u()};return t||n?k(o,h=>{t&&Vr(h,t),n&&Vr(h,n),a()},"cleanup"):a(),s}insert(t,n,r){if(n.length<=0)return;let s=this.doc;s!==null?k(s,i=>{let o=Un(i,this,t,!r);r||(r={},o.currentAttributes.forEach((c,l)=>{r[l]=c})),Ir(i,this,o,n,r)}):this._pending.push(()=>this.insert(t,n,r))}insertEmbed(t,n,r){let s=this.doc;s!==null?k(s,i=>{let o=Un(i,this,t,!r);Ir(i,this,o,n,r||{})}):this._pending.push(()=>this.insertEmbed(t,n,r||{}))}delete(t,n){if(n===0)return;let r=this.doc;r!==null?k(r,s=>{li(s,Un(s,this,t,!0),n)}):this._pending.push(()=>this.delete(t,n))}format(t,n,r){if(n===0)return;let s=this.doc;s!==null?k(s,i=>{let o=Un(i,this,t,!1);o.right!==null&&ci(i,this,o,n,r)}):this._pending.push(()=>this.format(t,n,r))}removeAttribute(t){this.doc!==null?k(this.doc,n=>{On(n,this,t)}):this._pending.push(()=>this.removeAttribute(t))}setAttribute(t,n){this.doc!==null?k(this.doc,r=>{Yr(r,this,t,n)}):this._pending.push(()=>this.setAttribute(t,n))}getAttribute(t){return Wr(this,t)}getAttributes(){return $i(this)}_write(t){t.writeTypeRef(Pl)}},vl=e=>new le,Oe=class{constructor(t,n=()=>!0){this._filter=n,this._root=t,this._currentNode=t._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let t=this._currentNode,n=t&&t.content&&t.content.type;if(t!==null&&(!this._firstCall||t.deleted||!this._filter(n)))do if(n=t.content.type,!t.deleted&&(n.constructor===Lt||n.constructor===Nt)&&n._start!==null)t=n._start;else for(;t!==null;)if(t.right!==null){t=t.right;break}else t.parent===this._root?t=null:t=t.parent._item;while(t!==null&&(t.deleted||!this._filter(t.content.type)));return this._firstCall=!1,t===null?{value:void 0,done:!0}:(this._currentNode=t,{value:t.content.type,done:!1})}},Nt=class e extends C{constructor(){super(),this._prelimContent=[]}get firstChild(){let t=this._first;return t?t.content.getContent()[0]:null}_integrate(t,n){super._integrate(t,n),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new e}clone(){let t=new e;return t.insert(0,this.toArray().map(n=>n instanceof C?n.clone():n)),t}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(t){return new Oe(this,t)}querySelector(t){t=t.toUpperCase();let r=new Oe(this,s=>s.nodeName&&s.nodeName.toUpperCase()===t).next();return r.done?null:r.value}querySelectorAll(t){return t=t.toUpperCase(),W(new Oe(this,n=>n.nodeName&&n.nodeName.toUpperCase()===t))}_callObserver(t,n){zn(this,t,new Mn(this,n,t))}toString(){return Ni(this,t=>t.toString()).join("")}toJSON(){return this.toString()}toDOM(t=document,n={},r){let s=t.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),je(this,i=>{s.insertBefore(i.toDOM(t,n,r),null)}),s}insert(t,n){this.doc!==null?k(this.doc,r=>{Mi(r,this,t,n)}):this._prelimContent.splice(t,0,...n)}insertAfter(t,n){if(this.doc!==null)k(this.doc,r=>{let s=t&&t instanceof C?t._item:t;Vn(r,this,s,n)});else{let r=this._prelimContent,s=t===null?0:r.findIndex(i=>i===t)+1;if(s===0&&t!==null)throw z("Reference item not found");r.splice(s,0,...n)}}delete(t,n=1){this.doc!==null?k(this.doc,r=>{Ri(r,this,t,n)}):this._prelimContent.splice(t,n)}toArray(){return Oi(this)}push(t){this.insert(this.length,t)}unshift(t){this.insert(0,t)}get(t){return Li(this,t)}slice(t=0,n=this.length){return Vi(this,t,n)}forEach(t){je(this,t)}_write(t){t.writeTypeRef(Yl)}},Vl=e=>new Nt,Lt=class e extends Nt{constructor(t="UNDEFINED"){super(),this.nodeName=t,this._prelimAttrs=new Map}get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_integrate(t,n){super._integrate(t,n),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new e(this.nodeName)}clone(){let t=new e(this.nodeName),n=this.getAttributes();return xs(n,(r,s)=>{typeof r=="string"&&t.setAttribute(s,r)}),t.insert(0,this.toArray().map(r=>r instanceof C?r.clone():r)),t}toString(){let t=this.getAttributes(),n=[],r=[];for(let c in t)r.push(c);r.sort();let s=r.length;for(let c=0;c<s;c++){let l=r[c];n.push(l+'="'+t[l]+'"')}let i=this.nodeName.toLocaleLowerCase(),o=n.length>0?" "+n.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(t){this.doc!==null?k(this.doc,n=>{On(n,this,t)}):this._prelimAttrs.delete(t)}setAttribute(t,n){this.doc!==null?k(this.doc,r=>{Yr(r,this,t,n)}):this._prelimAttrs.set(t,n)}getAttribute(t){return Wr(this,t)}hasAttribute(t){return Fi(this,t)}getAttributes(t){return t?ji(this,t):$i(this)}toDOM(t=document,n={},r){let s=t.createElement(this.nodeName),i=this.getAttributes();for(let o in i){let c=i[o];typeof c=="string"&&s.setAttribute(o,c)}return je(this,o=>{s.appendChild(o.toDOM(t,n,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(t){t.writeTypeRef(Kl),t.writeKey(this.nodeName)}},Ol=e=>new Lt(e.readKey()),Mn=class extends vt{constructor(t,n,r){super(t,r),this.childListChanged=!1,this.attributesChanged=new Set,n.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}},Ge=class e extends Ot{constructor(t){super(),this.hookName=t}_copy(){return new e(this.hookName)}clone(){let t=new e(this.hookName);return this.forEach((n,r)=>{t.set(r,n)}),t}toDOM(t=document,n={},r){let s=n[this.hookName],i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(t){t.writeTypeRef(Wl),t.writeKey(this.hookName)}},Nl=e=>new Ge(e.readKey()),Rn=class e extends le{get nextSibling(){let t=this._item?this._item.next:null;return t?t.content.type:null}get prevSibling(){let t=this._item?this._item.prev:null;return t?t.content.type:null}_copy(){return new e}clone(){let t=new e;return t.applyDelta(this.toDelta()),t}toDOM(t=document,n,r){let s=t.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(t=>{let n=[];for(let s in t.attributes){let i=[];for(let o in t.attributes[s])i.push({key:o,value:t.attributes[s][o]});i.sort((o,c)=>o.key<c.key?-1:1),n.push({nodeName:s,attrs:i})}n.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<n.length;s++){let i=n[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){let c=i.attrs[o];r+=` ${c.key}="${c.value}"`}r+=">"}r+=t.insert;for(let s=n.length-1;s>=0;s--)r+=`</${n[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(t){t.writeTypeRef(Zl)}},Ll=e=>new Rn,ae=class{constructor(t,n){this.id=t,this.length=n}get deleted(){throw H()}mergeWith(t){return!1}write(t,n,r){throw H()}integrate(t,n){throw H()}},Bl=0,N=class extends ae{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){n>0&&(this.id.clock+=n,this.length-=n),wi(t.doc.store,this)}write(t,n){t.writeInfo(Bl),t.writeLen(this.length-n)}getMissing(t,n){return null}},Bt=class e{constructor(t){this.content=t}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new e(this.content)}splice(t){throw H()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeBuf(this.content)}getRef(){return 3}},Ml=e=>new Bt(e.readBuf()),he=class e{constructor(t){this.len=t}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.len)}splice(t){let n=new e(this.len-t);return this.len=t,n}mergeWith(t){return this.len+=t.len,!0}integrate(t,n){Le(t.deleteSet,n.id.client,n.id.clock,this.len),n.markDeleted()}delete(t){}gc(t){}write(t,n){t.writeLen(this.len-n)}getRef(){return 1}},Rl=e=>new he(e.readLen()),Xi=(e,t)=>new Tt({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1}),Mt=class e{constructor(t){t._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=t;let n={};this.opts=n,t.gc||(n.gc=!1),t.autoLoad&&(n.autoLoad=!0),t.meta!==null&&(n.meta=t.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new e(Xi(this.doc.guid,this.opts))}splice(t){throw H()}mergeWith(t){return!1}integrate(t,n){this.doc._item=n,t.subdocsAdded.add(this.doc),this.doc.shouldLoad&&t.subdocsLoaded.add(this.doc)}delete(t){t.subdocsAdded.has(this.doc)?t.subdocsAdded.delete(this.doc):t.subdocsRemoved.add(this.doc)}gc(t){}write(t,n){t.writeString(this.doc.guid),t.writeAny(this.opts)}getRef(){return 9}},$l=e=>new Mt(Xi(e.readString(),e.readAny())),at=class e{constructor(t){this.embed=t}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new e(this.embed)}splice(t){throw H()}mergeWith(t){return!1}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeJSON(this.embed)}getRef(){return 5}},Fl=e=>new at(e.readJSON()),E=class e{constructor(t,n){this.key=t,this.value=n}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new e(this.key,this.value)}splice(t){throw H()}mergeWith(t){return!1}integrate(t,n){let r=n.parent;r._searchMarker=null,r._hasFormatting=!0}delete(t){}gc(t){}write(t,n){t.writeKey(this.key),t.writeJSON(this.value)}getRef(){return 6}},jl=e=>new E(e.readKey(),e.readJSON()),ze=class e{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];t.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}},ql=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++){let s=e.readString();s==="undefined"?n.push(void 0):n.push(JSON.parse(s))}return new ze(n)},yt=class e{constructor(t){this.arr=t}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new e(this.arr)}splice(t){let n=new e(this.arr.slice(t));return this.arr=this.arr.slice(0,t),n}mergeWith(t){return this.arr=this.arr.concat(t.arr),!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){let r=this.arr.length;t.writeLen(r-n);for(let s=n;s<r;s++){let i=this.arr[s];t.writeAny(i)}}getRef(){return 8}},Gl=e=>{let t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new yt(n)},Y=class e{constructor(t){this.str=t}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new e(this.str)}splice(t){let n=new e(this.str.slice(t));this.str=this.str.slice(0,t);let r=this.str.charCodeAt(t-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,t-1)+"\uFFFD",n.str="\uFFFD"+n.str.slice(1)),n}mergeWith(t){return this.str+=t.str,!0}integrate(t,n){}delete(t){}gc(t){}write(t,n){t.writeString(n===0?this.str:this.str.slice(n))}getRef(){return 4}},zl=e=>new Y(e.readString()),Hl=[Al,Il,vl,Ol,Vl,Nl,Ll],Jl=0,Xl=1,Pl=2,Kl=3,Yl=4,Wl=5,Zl=6,K=class e{constructor(t){this.type=t}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new e(this.type._copy())}splice(t){throw H()}mergeWith(t){return!1}integrate(t,n){this.type._integrate(t.doc,n)}delete(t){let n=this.type._start;for(;n!==null;)n.deleted?n.id.clock<(t.beforeState.get(n.id.client)||0)&&t._mergeStructs.push(n):n.delete(t),n=n.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(t.beforeState.get(r.id.client)||0)&&t._mergeStructs.push(r):r.delete(t)}),t.changed.delete(this.type)}gc(t){let n=this.type._start;for(;n!==null;)n.gc(t,!0),n=n.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(t,!0),r=r.left}),this.type._map=new Map}write(t,n){this.type._write(t)}getRef(){return 7}},Ql=e=>new K(Hl[e.readTypeRef()](e)),Mr=(e,t)=>{let n=t,r=0,s;do r>0&&(n=w(n.client,n.clock+r)),s=Ve(e,n),r=n.clock-s.id.clock,n=s.redone;while(n!==null&&s instanceof S);return{item:s,diff:r}},Zr=(e,t)=>{for(;e!==null&&e.keep!==t;)e.keep=t,e=e.parent._item},$n=(e,t,n)=>{let{client:r,clock:s}=t.id,i=new S(w(r,s+n),t,w(r,s+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&i.markDeleted(),t.keep&&(i.keep=!0),t.redone!==null&&(i.redone=w(t.redone.client,t.redone.clock+n)),t.right=i,i.right!==null&&(i.right.left=i),e._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),t.length=n,i},ai=(e,t)=>fe(e,n=>Rt(n.deletions,t)),Pi=(e,t,n,r,s,i)=>{let o=e.doc,c=o.store,l=o.clientID,u=t.redone;if(u!==null)return M(e,u);let a=t.parent._item,h=null,d;if(a!==null&&a.deleted===!0){if(a.redone===null&&(!n.has(a)||Pi(e,a,n,r,s,i)===null))return null;for(;a.redone!==null;)a=M(e,a.redone)}let f=a===null?t.parent:a.content.type;if(t.parentSub===null){for(h=t.left,d=t;h!==null;){let x=h;for(;x!==null&&x.parent._item!==a;)x=x.redone===null?null:M(e,x.redone);if(x!==null&&x.parent._item===a){h=x;break}h=h.left}for(;d!==null;){let x=d;for(;x!==null&&x.parent._item!==a;)x=x.redone===null?null:M(e,x.redone);if(x!==null&&x.parent._item===a){d=x;break}d=d.right}}else if(d=null,t.right&&!s){for(h=t;h!==null&&h.right!==null&&(h.right.redone||Rt(r,h.right.id)||ai(i.undoStack,h.right.id)||ai(i.redoStack,h.right.id));)for(h=h.right;h.redone;)h=M(e,h.redone);if(h&&h.right!==null)return null}else h=f._map.get(t.parentSub)||null;let p=_(c,l),b=w(l,p),m=new S(b,h,h&&h.lastId,d,d&&d.id,f,t.parentSub,t.content.copy());return t.redone=b,Zr(m,!0),m.integrate(e,0),m},S=class e extends ae{constructor(t,n,r,s,i,o,c,l){super(t,l.getLength()),this.origin=r,this.left=n,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=c,this.redone=null,this.content=l,this.info=this.content.isCountable()?2:0}set marker(t){(this.info&8)>0!==t&&(this.info^=8)}get marker(){return(this.info&8)>0}get keep(){return(this.info&1)>0}set keep(t){this.keep!==t&&(this.info^=1)}get countable(){return(this.info&2)>0}get deleted(){return(this.info&4)>0}set deleted(t){this.deleted!==t&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(t,n){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=_(n,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=_(n,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===ct&&this.id.client!==this.parent.client&&this.parent.clock>=_(n,this.parent.client))return this.parent.client;if(this.origin&&(this.left=ti(t,n,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=M(t,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===N||this.right&&this.right.constructor===N)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===e&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===e&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===ct){let r=Ve(n,this.parent);r.constructor===N?this.parent=null:this.parent=r.content.type}return null}integrate(t,n){if(n>0&&(this.id.clock+=n,this.left=ti(t,t.doc.store,w(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(n),this.length-=n),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;let i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),At(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(At(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Ve(t.doc.store,s.origin)))i.has(Ve(t.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){let r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(t)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),wi(t.doc.store,this),this.content.integrate(t,this),ni(t,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(t)}else new N(this.id,this.length).integrate(t,0)}get next(){let t=this.right;for(;t!==null&&t.deleted;)t=t.right;return t}get prev(){let t=this.left;for(;t!==null&&t.deleted;)t=t.left;return t}get lastId(){return this.length===1?this.id:w(this.id.client,this.id.clock+this.length-1)}mergeWith(t){if(this.constructor===t.constructor&&At(t.origin,this.lastId)&&this.right===t&&At(this.rightOrigin,t.rightOrigin)&&this.id.client===t.id.client&&this.id.clock+this.length===t.id.clock&&this.deleted===t.deleted&&this.redone===null&&t.redone===null&&this.content.constructor===t.content.constructor&&this.content.mergeWith(t.content)){let n=this.parent._searchMarker;return n&&n.forEach(r=>{r.p===t&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),t.keep&&(this.keep=!0),this.right=t.right,this.right!==null&&(this.right.left=this),this.length+=t.length,!0}return!1}delete(t){if(!this.deleted){let n=this.parent;this.countable&&this.parentSub===null&&(n._length-=this.length),this.markDeleted(),Le(t.deleteSet,this.id.client,this.id.clock,this.length),ni(t,n,this.parentSub),this.content.delete(t)}}gc(t,n){if(!this.deleted)throw D();this.content.gc(t),n?cl(t,this,new N(this.id,this.length)):this.content=new he(this.length)}write(t,n){let r=n>0?w(this.id.client,this.id.clock+n-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&31|(r===null?0:128)|(s===null?0:64)|(i===null?0:32);if(t.writeInfo(o),r!==null&&t.writeLeftID(r),s!==null&&t.writeRightID(s),r===null&&s===null){let c=this.parent;if(c._item!==void 0){let l=c._item;if(l===null){let u=Hr(c);t.writeParentInfo(!0),t.writeString(u)}else t.writeParentInfo(!1),t.writeLeftID(l.id)}else c.constructor===String?(t.writeParentInfo(!0),t.writeString(c)):c.constructor===ct?(t.writeParentInfo(!1),t.writeLeftID(c)):D();i!==null&&t.writeString(i)}this.content.write(t,n)}},Ki=(e,t)=>ta[t&31](e),ta=[()=>{D()},Rl,ql,Ml,zl,Fl,jl,Ql,Gl,$l,()=>{D()}],ea=10,O=class extends ae{get deleted(){return!0}delete(){}mergeWith(t){return this.constructor!==t.constructor?!1:(this.length+=t.length,!0)}integrate(t,n){D()}write(t,n){t.writeInfo(ea),g(t.restEncoder,this.length-n)}getMissing(t,n){return null}},Yi=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:{},Wi="__ $YJS$ __";Yi[Wi]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438");Yi[Wi]=!0;return so(na);})();
|
|
10845
|
+
return Y;
|
|
10846
|
+
}
|
|
10847
|
+
|
|
10827
10848
|
// ───────────────────────── Entry point
|
|
10828
10849
|
// Nothing is added to the page here: the UI, the fullscreen hook and tilt-to-landscape
|
|
10829
10850
|
// start only once real media is found (see UI_GATE / VIDEO_DETECTOR._setTarget).
|
package/package.json
CHANGED
|
@@ -1,15 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kangsicj/nexussync",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Watch-together userscript: media sync, cinema mode, live AI subtitles, chat bubbles and quick ink for Tampermonkey and iOS Userscripts.",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"userscript",
|
|
7
|
+
"tampermonkey",
|
|
8
|
+
"watch-together",
|
|
9
|
+
"sync",
|
|
10
|
+
"yjs",
|
|
11
|
+
"webrtc",
|
|
12
|
+
"subtitles"
|
|
13
|
+
],
|
|
6
14
|
"homepage": "https://github.com/kangsicj/NexusSync#readme",
|
|
7
|
-
"repository": {
|
|
8
|
-
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/kangsicj/NexusSync.git"
|
|
18
|
+
},
|
|
19
|
+
"funding": {
|
|
20
|
+
"type": "individual",
|
|
21
|
+
"url": "https://fairy.hada.io/@jinny"
|
|
22
|
+
},
|
|
9
23
|
"author": "kangsicj",
|
|
10
24
|
"license": "UNLICENSED",
|
|
11
|
-
"files": [
|
|
12
|
-
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/NexusSync.user.js",
|
|
27
|
+
"dist/NexusSync.meta.js",
|
|
28
|
+
"assets/icon.svg"
|
|
29
|
+
],
|
|
30
|
+
"publishConfig": {
|
|
31
|
+
"access": "public"
|
|
32
|
+
},
|
|
13
33
|
"scripts": {
|
|
14
34
|
"build": "node scripts/build.mjs",
|
|
15
35
|
"check": "node scripts/build.mjs --check",
|