@tabula-md/tabula 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/README.md +106 -0
  2. package/dist/activeDocumentRuntime.d.ts +50 -0
  3. package/dist/activeDocumentRuntime.d.ts.map +1 -0
  4. package/dist/collabCollaborators.d.ts +16 -0
  5. package/dist/collabCollaborators.d.ts.map +1 -0
  6. package/dist/collabConnectionModel.d.ts +11 -0
  7. package/dist/collabConnectionModel.d.ts.map +1 -0
  8. package/dist/collabSessionState.d.ts +24 -0
  9. package/dist/collabSessionState.d.ts.map +1 -0
  10. package/dist/collaboration.d.ts +8 -0
  11. package/dist/collaboration.d.ts.map +1 -0
  12. package/dist/collaboration.js +78 -0
  13. package/dist/collaboration.js.map +1 -0
  14. package/dist/collaborationPresence.d.ts +7 -0
  15. package/dist/collaborationPresence.d.ts.map +1 -0
  16. package/dist/collaborationTypes.d.ts +27 -0
  17. package/dist/collaborationTypes.d.ts.map +1 -0
  18. package/dist/commentRuntimeModel.d.ts +53 -0
  19. package/dist/commentRuntimeModel.d.ts.map +1 -0
  20. package/dist/data/base64Url.d.ts +3 -0
  21. package/dist/data/base64Url.d.ts.map +1 -0
  22. package/dist/data/encode.d.ts +20 -0
  23. package/dist/data/encode.d.ts.map +1 -0
  24. package/dist/data/encode.js +61 -0
  25. package/dist/data/encode.js.map +1 -0
  26. package/dist/data/encryption.d.ts +20 -0
  27. package/dist/data/encryption.d.ts.map +1 -0
  28. package/dist/data/encryption.js +13 -0
  29. package/dist/data/encryption.js.map +1 -0
  30. package/dist/data/json.d.ts +18 -0
  31. package/dist/data/json.d.ts.map +1 -0
  32. package/dist/data/json.js +18 -0
  33. package/dist/data/json.js.map +1 -0
  34. package/dist/data/restore.d.ts +3 -0
  35. package/dist/data/restore.d.ts.map +1 -0
  36. package/dist/data/restore.js +6 -0
  37. package/dist/data/restore.js.map +1 -0
  38. package/dist/documentBuffer.d.ts +68 -0
  39. package/dist/documentBuffer.d.ts.map +1 -0
  40. package/dist/documentControlsModel.d.ts +58 -0
  41. package/dist/documentControlsModel.d.ts.map +1 -0
  42. package/dist/documentMetrics.d.ts +2 -0
  43. package/dist/documentMetrics.d.ts.map +1 -0
  44. package/dist/documentPrimitives.d.ts +9 -0
  45. package/dist/documentPrimitives.d.ts.map +1 -0
  46. package/dist/documentSurfaceModel.d.ts +44 -0
  47. package/dist/documentSurfaceModel.d.ts.map +1 -0
  48. package/dist/encryption-B0xRVvlF.js +82 -0
  49. package/dist/encryption-B0xRVvlF.js.map +1 -0
  50. package/dist/index.d.ts +85 -0
  51. package/dist/index.d.ts.map +1 -0
  52. package/dist/index.js +2474 -0
  53. package/dist/index.js.map +1 -0
  54. package/dist/jsonShareLinkModel.d.ts +36 -0
  55. package/dist/jsonShareLinkModel.d.ts.map +1 -0
  56. package/dist/lineSurfaceModel.d.ts +73 -0
  57. package/dist/lineSurfaceModel.d.ts.map +1 -0
  58. package/dist/markdown/editing.d.ts +12 -0
  59. package/dist/markdown/editing.d.ts.map +1 -0
  60. package/dist/markdown/links.d.ts +23 -0
  61. package/dist/markdown/links.d.ts.map +1 -0
  62. package/dist/markdown/tasks.d.ts +22 -0
  63. package/dist/markdown/tasks.d.ts.map +1 -0
  64. package/dist/markdown.d.ts +25 -0
  65. package/dist/markdown.d.ts.map +1 -0
  66. package/dist/markdownEditing.d.ts +2 -0
  67. package/dist/markdownEditing.d.ts.map +1 -0
  68. package/dist/markdownFormatting.d.ts +11 -0
  69. package/dist/markdownFormatting.d.ts.map +1 -0
  70. package/dist/previewBlockModel.d.ts +66 -0
  71. package/dist/previewBlockModel.d.ts.map +1 -0
  72. package/dist/productPerformancePolicy.d.ts +14 -0
  73. package/dist/productPerformancePolicy.d.ts.map +1 -0
  74. package/dist/rightPanelCommentViewModel.d.ts +39 -0
  75. package/dist/rightPanelCommentViewModel.d.ts.map +1 -0
  76. package/dist/room/envelope.d.ts +27 -0
  77. package/dist/room/envelope.d.ts.map +1 -0
  78. package/dist/room/envelope.js +38 -0
  79. package/dist/room/envelope.js.map +1 -0
  80. package/dist/roomBinaryProtocol.d.ts +43 -0
  81. package/dist/roomBinaryProtocol.d.ts.map +1 -0
  82. package/dist/roomCollaboration.d.ts +39 -0
  83. package/dist/roomCollaboration.d.ts.map +1 -0
  84. package/dist/roomProtocol.d.ts +11 -0
  85. package/dist/roomProtocol.d.ts.map +1 -0
  86. package/dist/roomShareLinkModel.d.ts +20 -0
  87. package/dist/roomShareLinkModel.d.ts.map +1 -0
  88. package/dist/shareLinkViewModel.d.ts +8 -0
  89. package/dist/shareLinkViewModel.d.ts.map +1 -0
  90. package/dist/shareSnapshotPayload-CsTw9sRq.js +209 -0
  91. package/dist/shareSnapshotPayload-CsTw9sRq.js.map +1 -0
  92. package/dist/shareSnapshotPayload.d.ts +75 -0
  93. package/dist/shareSnapshotPayload.d.ts.map +1 -0
  94. package/dist/shareViewModel.d.ts +33 -0
  95. package/dist/shareViewModel.d.ts.map +1 -0
  96. package/dist/sourceScrollTransfer.d.ts +54 -0
  97. package/dist/sourceScrollTransfer.d.ts.map +1 -0
  98. package/dist/statusBarViewModel.d.ts +13 -0
  99. package/dist/statusBarViewModel.d.ts.map +1 -0
  100. package/dist/textPatches.d.ts +16 -0
  101. package/dist/textPatches.d.ts.map +1 -0
  102. package/dist/workspaceFileRuntimeModel.d.ts +11 -0
  103. package/dist/workspaceFileRuntimeModel.d.ts.map +1 -0
  104. package/dist/workspaceIoModel.d.ts +37 -0
  105. package/dist/workspaceIoModel.d.ts.map +1 -0
  106. package/dist/workspaceModel.d.ts +112 -0
  107. package/dist/workspaceModel.d.ts.map +1 -0
  108. package/dist/workspaceRoomCheckpoint.d.ts +46 -0
  109. package/dist/workspaceRoomCheckpoint.d.ts.map +1 -0
  110. package/dist/workspaceRoomCrdt.d.ts +55 -0
  111. package/dist/workspaceRoomCrdt.d.ts.map +1 -0
  112. package/dist/workspaceRoomModel-CO-5ZOpS.js +78 -0
  113. package/dist/workspaceRoomModel-CO-5ZOpS.js.map +1 -0
  114. package/dist/workspaceRoomModel.d.ts +69 -0
  115. package/dist/workspaceRoomModel.d.ts.map +1 -0
  116. package/dist/workspaceRoomSync-B3niC7cn.js +758 -0
  117. package/dist/workspaceRoomSync-B3niC7cn.js.map +1 -0
  118. package/dist/workspaceRoomSync.d.ts +98 -0
  119. package/dist/workspaceRoomSync.d.ts.map +1 -0
  120. package/dist/workspaceViewModel.d.ts +13 -0
  121. package/dist/workspaceViewModel.d.ts.map +1 -0
  122. package/package.json +82 -0
package/dist/index.js ADDED
@@ -0,0 +1,2474 @@
1
+ import { parseDocument as lt, isMap as ut, isScalar as dt } from "yaml";
2
+ import { b as Z } from "./encryption-B0xRVvlF.js";
3
+ import { A as xo, D as Co, c as vo, d as wo, a as Po, e as yo, g as No, f as Fo, i as $o, t as Wo } from "./encryption-B0xRVvlF.js";
4
+ import { decodeEncryptedData as Ho, encodeEncryptedData as Bo } from "./data/encode.js";
5
+ import { parseShareSnapshot as Vo, restoreShareSnapshot as Go, serializeShareSnapshot as Ko } from "./data/json.js";
6
+ import { restoreShareSnapshotPayload as Yo } from "./data/restore.js";
7
+ import { createRoomAad as Xo, createRoomEnvelope as Jo, decryptRoomEnvelope as qo, isEnvelopeKind as Zo, validateRoomPayload as Qo } from "./room/envelope.js";
8
+ import { A as ti, D as ni, a as ri, b as si, c as oi, H as ii, R as ai, d as ci, e as li, f as ui, i as di, j as fi, k as mi, l as hi, m as gi, n as pi, o as Li, p as Ei, q as Oi, r as Ii, s as Ri, t as Si, u as Mi, v as _i, w as bi, x as ki, y as Ti, z as Ai, B as xi, C as Ci, E as vi, F as wi, G as Pi, I as yi, J as Ni, K as Fi, L as $i, M as Wi, N as Di, O as Hi, P as Bi, Q as Ui, S as Vi, T as Gi, U as Ki, V as zi, W as Yi, X as ji, Y as Xi, Z as Ji, _ as qi, $ as Zi, a0 as Qi, a1 as ea } from "./workspaceRoomSync-B3niC7cn.js";
9
+ import { W as na, a as ra, b as sa, c as oa, d as ia, e as aa, f as ca, g as la, h as ua, v as da, i as fa } from "./workspaceRoomModel-CO-5ZOpS.js";
10
+ import { S as ha, c as ga, a as pa, a as La, v as Ea } from "./shareSnapshotPayload-CsTw9sRq.js";
11
+ const ft = ["narrow", "standard", "wide"], rs = ["edit", "split", "preview"], be = 0.5, mt = 0.28, ht = 0.72, ke = (e) => {
12
+ const t = typeof e == "number" && Number.isFinite(e) ? e : be;
13
+ return Math.min(
14
+ ht,
15
+ Math.max(mt, t)
16
+ );
17
+ }, gt = /^---\s*$/, pt = /^(?:---|\.\.\.)\s*$/, Lt = (e, t) => e.startsWith(`\r
18
+ `, t) ? 2 : 1, v = (e) => e === null || typeof e > "u" ? "" : Array.isArray(e) ? e.map(v).join(", ") : typeof e == "object" ? Object.entries(e).map(([t, n]) => `${t}: ${v(n)}`).join(`
19
+ `) : String(e).replace(/\n$/, ""), Et = (e) => {
20
+ const t = e.search(/\r?\n/);
21
+ if (t === -1)
22
+ return null;
23
+ const n = e.slice(0, t);
24
+ if (!gt.test(n))
25
+ return null;
26
+ const r = t + Lt(e, t);
27
+ let s = r;
28
+ for (; s < e.length; ) {
29
+ const o = e.indexOf(`
30
+ `, s), i = o === -1 ? e.length : e[o - 1] === "\r" ? o - 1 : o, a = e.slice(s, i);
31
+ if (pt.test(a)) {
32
+ const c = o === -1 ? e.length : o + 1;
33
+ return {
34
+ rawFrontmatter: e.slice(r, s).replace(/\r?\n$/, ""),
35
+ body: e.slice(c)
36
+ };
37
+ }
38
+ if (o === -1)
39
+ break;
40
+ s = o + 1;
41
+ }
42
+ return null;
43
+ }, Te = (e) => ({ body: e, sourceLineOffset: 0 }), k = (e) => {
44
+ var s;
45
+ const t = Et(e);
46
+ if (!t)
47
+ return { attributes: [], body: e };
48
+ const n = lt(t.rawFrontmatter, { prettyErrors: !1 });
49
+ if (n.errors.length > 0 || !ut(n.contents))
50
+ return { attributes: [], body: e };
51
+ const r = [];
52
+ for (const o of n.contents.items) {
53
+ if (!dt(o.key))
54
+ return { attributes: [], body: e };
55
+ const i = v(o.key.value).trim();
56
+ if (!i)
57
+ return { attributes: [], body: e };
58
+ r.push({
59
+ key: i,
60
+ value: v((s = o.value) == null ? void 0 : s.toJSON())
61
+ });
62
+ }
63
+ return r.length > 0 ? { attributes: r, body: t.body } : { attributes: [], body: e };
64
+ }, ss = (e) => {
65
+ var s, o, i;
66
+ const t = k(e), n = (s = t.attributes.find((a) => a.key.toLowerCase() === "title")) == null ? void 0 : s.value.trim();
67
+ return n || ((i = (o = t.body.match(/^#{1,2}\s+(.+?)\s*#*\s*$/m)) == null ? void 0 : o[1]) == null ? void 0 : i.trim()) || "";
68
+ }, os = (e) => e.body.split(`
69
+ `).map((t, n) => {
70
+ const r = t.match(/^(#{1,3})\s+(.+)$/);
71
+ return r ? {
72
+ depth: r[1].length,
73
+ text: r[2].replace(/\s+#+\s*$/, "").trim(),
74
+ lineIndex: n,
75
+ sourceLineIndex: n + e.sourceLineOffset
76
+ } : null;
77
+ }).filter((t) => !!(t != null && t.text)), Ae = (e) => {
78
+ const t = [];
79
+ let n = 0, r = 0;
80
+ for (; r <= e.length; ) {
81
+ const s = e.indexOf(`
82
+ `, r), o = s === -1 ? e.length : e[s - 1] === "\r" ? s - 1 : s, a = e.slice(r, o).match(/^(#{1,3})\s+(.+)$/);
83
+ if (a) {
84
+ const c = a[2].replace(/\s+#+\s*$/, "").trim();
85
+ c && t.push({
86
+ depth: a[1].length,
87
+ text: c,
88
+ lineIndex: n,
89
+ sourceLineIndex: n
90
+ });
91
+ }
92
+ if (s === -1)
93
+ break;
94
+ n += 1, r = s + 1;
95
+ }
96
+ return t;
97
+ }, xe = (e, t) => {
98
+ var s;
99
+ const n = e.split(`
100
+ `);
101
+ let r = 0;
102
+ for (let o = 0; o < t; o += 1)
103
+ r += (((s = n[o]) == null ? void 0 : s.length) ?? 0) + 1;
104
+ return r;
105
+ }, is = (e, t) => e.slice(0, t).split(`
106
+ `).length, Ot = (e) => e.trim() ? e.trim().split(/\s+/).length : 0, It = (e, t) => t.from - e.from || t.to - e.to, Rt = (e, t) => e.from - t.from || e.to - t.to, St = (e, t) => {
107
+ let n = 0;
108
+ for (; n < e.length && n < t.length && e[n] === t[n]; )
109
+ n += 1;
110
+ let r = e.length, s = t.length;
111
+ for (; r > n && s > n && e[r - 1] === t[s - 1]; )
112
+ r -= 1, s -= 1;
113
+ return {
114
+ from: n,
115
+ to: r,
116
+ insert: t.slice(n, s)
117
+ };
118
+ }, P = (e) => [...e].sort(Rt), Mt = (e, t) => {
119
+ let n = 0;
120
+ for (const r of P(t)) {
121
+ if (!Number.isInteger(r.from) || !Number.isInteger(r.to) || r.from < 0 || r.to < r.from || r.to > e.length || r.from < n)
122
+ return !1;
123
+ n = r.to;
124
+ }
125
+ return !0;
126
+ }, Q = (e, t) => Mt(e, t) ? [...t].sort(It).reduce(
127
+ (n, r) => `${n.slice(0, r.from)}${r.insert}${n.slice(r.to)}`,
128
+ e
129
+ ) : null, as = (e, t, n) => {
130
+ if (n != null && n.length && Q(e, n) === t)
131
+ return P(n);
132
+ const r = St(e, t);
133
+ return r.from === r.to && r.insert === "" ? [] : [r];
134
+ }, _t = 64e3, bt = 800, kt = 8e3, Ce = 8e3, Tt = 120, At = 24e3, xt = 16, ce = 80, le = 12e3, W = 27, Ct = 10, vt = 24, wt = {
135
+ 1: 49,
136
+ 2: 43,
137
+ 3: 38,
138
+ 4: 33,
139
+ 5: 29,
140
+ 6: 27
141
+ }, Pt = 40, ve = 4e3, yt = 92, Nt = 240, Ft = 0, $t = 1, Wt = 4, Dt = 4, ue = 0.8, Ht = 80, de = 1, b = /^ {0,3}(`{3,}|~{3,})/, we = /^ {0,3}#{1,6}\s+\S/, ee = /^ {0,3}(?:-{3,}|\*{3,}|_{3,})\s*$/, y = /^ {0,3}>/, N = /^ {0,3}(?:[-+*]|\d{1,9}[.)])\s+/, Bt = /^(?: {2,}|\t)\S/, Pe = /^ {0,3}\|?\s*:?-{1,}:?\s*(?:\|\s*:?-{1,}:?\s*)+\|?\s*$/, F = /^ {0,3}<\/?[A-Za-z][A-Za-z0-9-]*(?:\s|>|\/>)/, ye = /^ {0,3}\$\$\s*$/, fe = /^(?:mermaid|mmd|math|tex|latex|katex)$/i, K = /^---\s*$/, Ut = /^[A-Za-z0-9_-]+:\s*/, Vt = /^ {0,3}\[\^[^\]\n]+]:/, Gt = /\[\^[^\]\n]+]/, Kt = /^ {0,3}\[(?!\^)([^\]\n]+)]:\s+\S/, zt = /\[[^\]\n]+]\[[^\]\n]*]/, Yt = /^ {0,3}:\s+\S/, Ne = (e) => {
142
+ if (e.length === 0)
143
+ return 1;
144
+ let t = 1;
145
+ for (let n = 0; n < e.length; n += 1)
146
+ e.charCodeAt(n) === 10 && (t += 1);
147
+ return t;
148
+ }, cs = (e, t = Ce) => {
149
+ let n = 0;
150
+ for (let r = 0; r < e.length; r += 1) {
151
+ const s = e.charCodeAt(r);
152
+ if (s === 10) {
153
+ if (n >= t)
154
+ return !0;
155
+ n = 0;
156
+ continue;
157
+ }
158
+ s !== 13 && (n += 1);
159
+ }
160
+ return n >= t;
161
+ }, jt = (e) => {
162
+ let t = 0, n = !1;
163
+ for (let r = 0; r < e.length; r += 1) {
164
+ const s = e.charCodeAt(r);
165
+ if (s === 32 || s === 9 || s === 10 || s === 13 || s === 12 || s === 11) {
166
+ n = !1;
167
+ continue;
168
+ }
169
+ if (!n) {
170
+ if (t += 1, t >= kt)
171
+ return !0;
172
+ n = !0;
173
+ }
174
+ }
175
+ return !1;
176
+ }, Xt = (e) => {
177
+ let t = 0, n = 0, r = !1;
178
+ const s = () => t >= Ce || (n = r ? n + 1 : 0, n >= Tt) ? !0 : (t = 0, r = !1, !1);
179
+ for (let o = 0; o < e.length; o += 1) {
180
+ const i = e.charCodeAt(o);
181
+ if (i === 10) {
182
+ if (s())
183
+ return !0;
184
+ continue;
185
+ }
186
+ i !== 13 && (t += 1), i === 124 && (r = !0);
187
+ }
188
+ return s();
189
+ }, Fe = (e) => e.length >= _t || Ne(e) >= bt || jt(e) || Xt(e), Jt = (e) => {
190
+ var d;
191
+ const t = e.split(/\r?\n/);
192
+ let n = 0, r = !1, s = "", o = 0, i = "", a = 0, c = 0, l = !1;
193
+ const u = () => {
194
+ const m = fe.test(i) || a >= ce || c >= le;
195
+ return i = "", a = 0, c = 0, m;
196
+ };
197
+ for (const m of t) {
198
+ const h = m.match(/^ {0,3}(`{3,}|~{3,})\s*([A-Za-z0-9_-]+)?/);
199
+ if (h) {
200
+ const f = h[1];
201
+ if (!r) {
202
+ if (r = !0, s = f[0], o = f.length, i = ((d = h[2]) == null ? void 0 : d.toLowerCase()) ?? "", a = 0, c = 0, fe.test(i))
203
+ return !0;
204
+ continue;
205
+ }
206
+ if (f[0] === s && f.length >= o) {
207
+ if (r = !1, u())
208
+ return !0;
209
+ continue;
210
+ }
211
+ }
212
+ if (r) {
213
+ if (a += 1, c += m.length, a >= ce || c >= le)
214
+ return !0;
215
+ continue;
216
+ }
217
+ if (ye.test(m))
218
+ return l = !l, !0;
219
+ if (l || F.test(m) || (n = m.includes("|") ? n + 1 : 0, n >= xt))
220
+ return !0;
221
+ }
222
+ return r ? u() : !1;
223
+ }, ls = (e) => {
224
+ const t = e.split(/\r?\n/);
225
+ let n = !1, r = "", s = 0;
226
+ if (t.length >= 3 && K.test(t[0] ?? "") && t.slice(1, Math.min(t.length, 40)).some((o) => Ut.test(o)) && t.slice(1).some((o) => K.test(o)))
227
+ return !0;
228
+ for (const o of t) {
229
+ const i = o.match(/^ {0,3}(`{3,}|~{3,})/);
230
+ if (i) {
231
+ const a = i[1];
232
+ if (!n) {
233
+ n = !0, r = a[0], s = a.length;
234
+ continue;
235
+ }
236
+ if (a[0] === r && a.length >= s) {
237
+ n = !1;
238
+ continue;
239
+ }
240
+ }
241
+ if (!n && (Vt.test(o) || Gt.test(o) || Kt.test(o) || zt.test(o) || Yt.test(o)))
242
+ return !0;
243
+ }
244
+ return !1;
245
+ }, us = (e) => e.length <= At && !Fe(e) && !Jt(e), z = (e) => {
246
+ if (e.length === 0)
247
+ return [{ text: "", startOffset: 0, endOffset: 0 }];
248
+ const t = [];
249
+ let n = 0;
250
+ for (; n <= e.length; ) {
251
+ const r = e.indexOf(`
252
+ `, n), s = r === -1 ? e.length : r, o = s > n && e.charCodeAt(s - 1) === 13 ? s - 1 : s;
253
+ if (t.push({
254
+ text: e.slice(n, o),
255
+ startOffset: n,
256
+ endOffset: o
257
+ }), r === -1)
258
+ break;
259
+ n = r + 1;
260
+ }
261
+ return t;
262
+ }, O = (e) => e.text.trim().length === 0, qt = (e, t) => O(e) || b.test(e.text) || we.test(e.text) || ee.test(e.text) || y.test(e.text) || N.test(e.text) || F.test(e.text) || te(e, t), te = (e, t) => !!(t && e.text.includes("|") && Pe.test(t.text)), $e = (e) => {
263
+ var r;
264
+ const t = e.match(/^ {0,3}(#{1,6})\s+\S/), n = (r = t == null ? void 0 : t[1]) == null ? void 0 : r.length;
265
+ return n === 1 || n === 2 || n === 3 || n === 4 || n === 5 || n === 6 ? n : void 0;
266
+ }, We = (e, t, n = "") => e === "blank" ? 0 : e === "fence" ? Math.max(54, t * vt + 34) : e === "heading" ? wt[$e(n) ?? 3] : e === "table" ? Math.max(52, t * W + 20) : Math.max(W, t * W) + Ct, De = (e, t, n, r, s) => {
267
+ var m, h;
268
+ const o = t + 1, i = n + 1, a = ((m = e[t]) == null ? void 0 : m.startOffset) ?? 0, c = ((h = e[n]) == null ? void 0 : h.endOffset) ?? a, l = e.slice(t, n + 1).map((f) => f.text).join(`
269
+ `), u = r === "heading" ? $e(l) : void 0, d = We(r, i - o + 1, l);
270
+ return {
271
+ id: `${o}:${i}:${a}`,
272
+ kind: r,
273
+ text: l,
274
+ ...u ? { headingLevel: u } : {},
275
+ startLine: o,
276
+ endLine: i,
277
+ startOffset: a,
278
+ endOffset: c,
279
+ estimatedTop: s,
280
+ estimatedHeight: d
281
+ };
282
+ }, Zt = (e, t) => {
283
+ const n = Math.min(e.length, t + ve);
284
+ if (n >= e.length)
285
+ return e.length;
286
+ const r = Math.min(e.length, n + 600);
287
+ for (let s = n; s < r; s += 1) {
288
+ const o = e.charCodeAt(s);
289
+ if (o === 32 || o === 9)
290
+ return s + 1;
291
+ }
292
+ return n;
293
+ }, Qt = (e, t, n, r, s) => {
294
+ const o = t + 1, i = e.startOffset + n, a = e.startOffset + r, c = e.text.slice(n, r), l = Math.max(1, Math.ceil(c.length / yt)), u = We("paragraph", l, c);
295
+ return {
296
+ id: `${o}:${o}:${i}:${a}`,
297
+ kind: "paragraph",
298
+ text: c,
299
+ startLine: o,
300
+ endLine: o,
301
+ startOffset: i,
302
+ endOffset: a,
303
+ estimatedTop: s,
304
+ estimatedHeight: u
305
+ };
306
+ }, en = (e, t, n, r) => {
307
+ const s = [];
308
+ if (t === n && e[t].text.length > ve) {
309
+ const a = e[t];
310
+ let c = 0, l = r;
311
+ for (; c < a.text.length; ) {
312
+ const u = Zt(a.text, c), d = Qt(a, t, c, u, l);
313
+ s.push(d), l += d.estimatedHeight, c = u;
314
+ }
315
+ return { blocks: s, estimatedTop: l };
316
+ }
317
+ let o = t, i = r;
318
+ for (; o <= n; ) {
319
+ const a = Math.min(n, o + Pt - 1), c = De(e, o, a, "paragraph", i);
320
+ s.push(c), i += c.estimatedHeight, o = a + 1;
321
+ }
322
+ return { blocks: s, estimatedTop: i };
323
+ }, tn = (e, t) => {
324
+ var s;
325
+ const n = (s = e[t]) == null ? void 0 : s.text.match(b);
326
+ if (!n)
327
+ return t;
328
+ const r = n[1];
329
+ for (let o = t + 1; o < e.length; o += 1) {
330
+ const i = e[o].text.match(b);
331
+ if (i && i[1][0] === r[0] && i[1].length >= r.length)
332
+ return o;
333
+ }
334
+ return e.length - 1;
335
+ }, nn = (e) => {
336
+ const t = e.match(/^ {0,3}<([A-Za-z][A-Za-z0-9-]*)(?:\s|>|\/>)/);
337
+ if (!t || e.trimStart().startsWith("</"))
338
+ return null;
339
+ const n = t[1];
340
+ return new RegExp(`</${n}>`, "i").test(e) || /\/>\s*$/.test(e) ? null : n;
341
+ }, rn = (e, t) => {
342
+ var i;
343
+ const n = nn(((i = e[t]) == null ? void 0 : i.text) ?? "");
344
+ if (!n)
345
+ return null;
346
+ const r = new RegExp(`^ {0,3}<${n}(?:\\s|>|/>)`, "i"), s = new RegExp(`</${n}>`, "i");
347
+ let o = 0;
348
+ for (let a = t; a < e.length; a += 1) {
349
+ const c = e[a].text;
350
+ if (r.test(c) && !/\/>\s*$/.test(c) && !s.test(c) && (o += 1), s.test(c) && (o -= 1, o <= 0))
351
+ return a;
352
+ }
353
+ return null;
354
+ }, sn = (e, t) => {
355
+ const n = rn(e, t);
356
+ if (n !== null)
357
+ return n;
358
+ for (let r = t + 1; r < e.length; r += 1)
359
+ if (O(e[r]))
360
+ return r - 1;
361
+ return e.length - 1;
362
+ }, on = (e, t) => {
363
+ let n = !1;
364
+ for (let r = t + 1; r < e.length; r += 1) {
365
+ const s = e[r];
366
+ if (O(s)) {
367
+ n = !0;
368
+ continue;
369
+ }
370
+ if (N.test(s.text) || Bt.test(s.text)) {
371
+ n = !1;
372
+ continue;
373
+ }
374
+ return n ? r - 2 : r - 1;
375
+ }
376
+ return e.length - 1;
377
+ }, an = (e, t) => {
378
+ for (let n = t + 1; n < e.length; n += 1)
379
+ if (O(e[n]) || !y.test(e[n].text))
380
+ return n - 1;
381
+ return e.length - 1;
382
+ }, cn = (e, t) => {
383
+ for (let n = t + 2; n < e.length; n += 1)
384
+ if (!e[n].text.includes("|") || O(e[n]))
385
+ return n - 1;
386
+ return e.length - 1;
387
+ }, ln = (e, t) => {
388
+ for (let n = t + 1; n < e.length; n += 1)
389
+ if (qt(e[n], e[n + 1]))
390
+ return n - 1;
391
+ return e.length - 1;
392
+ }, un = (e, t) => {
393
+ const n = e[t], r = e[t + 1];
394
+ if (O(n)) {
395
+ let s = t;
396
+ for (; s + 1 < e.length && O(e[s + 1]); )
397
+ s += 1;
398
+ return { endIndex: s, kind: "blank" };
399
+ }
400
+ return b.test(n.text) ? { endIndex: tn(e, t), kind: "fence" } : te(n, r) ? { endIndex: cn(e, t), kind: "table" } : we.test(n.text) ? { endIndex: t, kind: "heading" } : ee.test(n.text) ? { endIndex: t, kind: "thematic" } : y.test(n.text) ? { endIndex: an(e, t), kind: "blockquote" } : N.test(n.text) ? { endIndex: on(e, t), kind: "list" } : F.test(n.text) ? { endIndex: sn(e, t), kind: "html" } : { endIndex: ln(e, t), kind: "paragraph" };
401
+ }, dn = (e) => {
402
+ const t = z(e), n = [];
403
+ let r = 0, s = 0;
404
+ for (; r < t.length; ) {
405
+ const { endIndex: o, kind: i } = un(t, r), a = Math.max(r, Math.min(o, t.length - 1));
406
+ if (i === "paragraph") {
407
+ const l = en(t, r, a, s);
408
+ n.push(...l.blocks), s = l.estimatedTop, r = a + 1;
409
+ continue;
410
+ }
411
+ const c = De(t, r, a, i, s);
412
+ n.push(c), s += c.estimatedHeight, r = a + 1;
413
+ }
414
+ return {
415
+ blocks: n,
416
+ lineCount: t.length,
417
+ totalEstimatedHeight: s
418
+ };
419
+ }, fn = (e, t) => {
420
+ if (e === t)
421
+ return null;
422
+ const n = Math.min(e.length, t.length);
423
+ let r = 0;
424
+ for (; r < n && e.charCodeAt(r) === t.charCodeAt(r); )
425
+ r += 1;
426
+ let s = 0;
427
+ const o = n - r;
428
+ for (; s < o && e.charCodeAt(e.length - s - 1) === t.charCodeAt(t.length - s - 1); )
429
+ s += 1;
430
+ return {
431
+ nextEndOffset: t.length - s,
432
+ nextStartOffset: r,
433
+ previousEndOffset: e.length - s,
434
+ previousStartOffset: r
435
+ };
436
+ }, mn = (e, t, n) => {
437
+ if (n.length === 0)
438
+ return e === t ? null : void 0;
439
+ const r = P(n);
440
+ if (Q(e, r) !== t)
441
+ return;
442
+ let s = Number.POSITIVE_INFINITY, o = 0, i = Number.POSITIVE_INFINITY, a = 0, c = 0;
443
+ for (const l of r) {
444
+ const u = l.from + c, d = u + l.insert.length;
445
+ s = Math.min(s, l.from), o = Math.max(o, l.to), i = Math.min(i, u), a = Math.max(a, d), c += l.insert.length - (l.to - l.from);
446
+ }
447
+ return {
448
+ nextEndOffset: a,
449
+ nextStartOffset: i,
450
+ previousEndOffset: o,
451
+ previousStartOffset: s
452
+ };
453
+ }, me = (e, t) => {
454
+ var r;
455
+ if (e.length === 0)
456
+ return 1;
457
+ const n = Math.max(0, t);
458
+ for (let s = 0; s < e.length; s += 1) {
459
+ const o = (r = e[s + 1]) == null ? void 0 : r.startOffset;
460
+ if (typeof o != "number" || n < o)
461
+ return s + 1;
462
+ }
463
+ return e.length;
464
+ }, he = (e, t, n) => {
465
+ const r = me(e, t), s = me(e, Math.max(t, n - 1));
466
+ return {
467
+ endLine: Math.max(r, s),
468
+ startLine: r
469
+ };
470
+ }, D = (e, t) => e ? b.test(e.text) || ee.test(e.text) || y.test(e.text) || N.test(e.text) || Pe.test(e.text) || te(e, t) || F.test(e.text) || ye.test(e.text) || K.test(e.text) : !0, hn = (e, t, n) => {
471
+ const r = e[t];
472
+ return r ? O(r) ? n.blankIsUnsafe && (D(e[t - 1], r) || D(e[t + 1], e[t + 2])) : D(r, e[t + 1]) : !0;
473
+ }, ge = (e, t, n = {}) => {
474
+ const r = Math.max(0, t.startLine - 1), s = Math.min(e.length - 1, t.endLine - 1), o = n.blankIsUnsafe ?? !0;
475
+ for (let i = r; i <= s; i += 1)
476
+ if (hn(e, i, { blankIsUnsafe: o }))
477
+ return !0;
478
+ return !1;
479
+ }, gn = (e, t) => e.findIndex((n) => n.endLine >= t), pn = (e, t) => {
480
+ for (let n = e.length - 1; n >= 0; n -= 1)
481
+ if (e[n].startLine <= t)
482
+ return n;
483
+ return -1;
484
+ }, Ln = (e, t) => {
485
+ var n;
486
+ return ((n = e[Math.max(0, Math.min(e.length - 1, t - 1))]) == null ? void 0 : n.startOffset) ?? 0;
487
+ }, En = (e, t) => {
488
+ var n;
489
+ return ((n = e[Math.max(0, Math.min(e.length - 1, t - 1))]) == null ? void 0 : n.endOffset) ?? 0;
490
+ }, He = (e, t, n, r, s) => e.id.split(":").length >= 4 ? `${t}:${n}:${r}:${s}` : `${t}:${n}:${r}`, On = (e, t) => {
491
+ const n = e.startLine + t.lineOffset, r = e.endLine + t.lineOffset, s = e.startOffset + t.offsetBase, o = e.endOffset + t.offsetBase;
492
+ return {
493
+ ...e,
494
+ id: He(e, n, r, s, o),
495
+ startLine: n,
496
+ endLine: r,
497
+ startOffset: s,
498
+ endOffset: o
499
+ };
500
+ }, In = (e, t) => {
501
+ if (t.charDelta === 0 && t.lineDelta === 0)
502
+ return e;
503
+ const n = e.startLine + t.lineDelta, r = e.endLine + t.lineDelta, s = e.startOffset + t.charDelta, o = e.endOffset + t.charDelta;
504
+ return {
505
+ ...e,
506
+ id: He(e, n, r, s, o),
507
+ startLine: n,
508
+ endLine: r,
509
+ startOffset: s,
510
+ endOffset: o
511
+ };
512
+ }, Rn = (e) => {
513
+ let t = 0;
514
+ return e.map((n) => {
515
+ const r = n.estimatedTop === t ? n : { ...n, estimatedTop: t };
516
+ return t += r.estimatedHeight, r;
517
+ });
518
+ }, Be = (e, t, n, r) => {
519
+ if (!r)
520
+ return e;
521
+ if (e.blocks.length === 0)
522
+ return null;
523
+ const s = z(t), o = z(n), i = he(
524
+ s,
525
+ r.previousStartOffset,
526
+ r.previousEndOffset
527
+ ), a = he(
528
+ o,
529
+ r.nextStartOffset,
530
+ r.nextEndOffset
531
+ );
532
+ if (Math.max(
533
+ i.endLine - i.startLine + 1,
534
+ a.endLine - a.startLine + 1
535
+ ) > Ht || ge(s, i) || ge(o, a, { blankIsUnsafe: !1 }))
536
+ return null;
537
+ const l = gn(
538
+ e.blocks,
539
+ i.startLine
540
+ ), u = pn(
541
+ e.blocks,
542
+ i.endLine
543
+ );
544
+ if (l === -1 || u === -1)
545
+ return null;
546
+ const d = Math.max(
547
+ 0,
548
+ l - de
549
+ ), m = Math.min(
550
+ e.blocks.length - 1,
551
+ u + de
552
+ ), h = e.blocks[d], f = e.blocks[m], g = o.length - s.length, x = n.length - t.length, $ = Math.max(1, Math.min(o.length, h.startLine)), rt = Math.max(
553
+ $,
554
+ Math.min(o.length, f.endLine + g)
555
+ ), ie = Ln(o, $), st = En(o, rt), ot = dn(n.slice(ie, st)).blocks.map(
556
+ (_) => On(_, {
557
+ lineOffset: $ - 1,
558
+ offsetBase: ie
559
+ })
560
+ ), it = e.blocks.slice(m + 1).map((_) => In(_, { charDelta: x, lineDelta: g })), ae = Rn([
561
+ ...e.blocks.slice(0, d),
562
+ ...ot,
563
+ ...it
564
+ ]), at = ae.reduce((_, ct) => _ + ct.estimatedHeight, 0);
565
+ return {
566
+ blocks: ae,
567
+ lineCount: o.length,
568
+ totalEstimatedHeight: at
569
+ };
570
+ }, ds = (e, t, n) => Be(
571
+ e,
572
+ t,
573
+ n,
574
+ fn(t, n)
575
+ ), fs = (e, t, n, r) => {
576
+ const s = mn(t, n, r);
577
+ return s === void 0 ? null : Be(
578
+ e,
579
+ t,
580
+ n,
581
+ s
582
+ );
583
+ }, ms = (e, t) => {
584
+ let n = 0;
585
+ const r = e.blocks.map((s) => {
586
+ const o = t[s.id], i = Number.isFinite(o) && o >= 0 ? o : s.estimatedHeight, a = s.estimatedTop === n && s.estimatedHeight === i ? s : {
587
+ ...s,
588
+ estimatedTop: n,
589
+ estimatedHeight: i
590
+ };
591
+ return n += i, a;
592
+ });
593
+ return {
594
+ ...e,
595
+ blocks: r,
596
+ totalEstimatedHeight: n
597
+ };
598
+ }, Sn = (e, t) => {
599
+ const n = Math.max(1, Math.floor(t)), r = e.filter((a) => Number.isFinite(a.startLine) && Number.isFinite(a.endLine)).map((a) => ({
600
+ ...a,
601
+ endLine: Math.max(a.startLine, a.endLine),
602
+ startLine: a.startLine
603
+ })), s = r.some(
604
+ (a) => a.startLine <= n && a.endLine >= n && !a.rendered
605
+ ), o = r.filter((a) => a.rendered);
606
+ if (o.length === 0)
607
+ return null;
608
+ const i = (a) => {
609
+ const c = a.startLine <= n && a.endLine >= n, l = a.sourceElement ? 0 : 1;
610
+ return c ? [0, l, Math.abs(a.startLine - n)] : a.endLine < n ? [
611
+ s ? 2 : 1,
612
+ n - a.endLine,
613
+ l
614
+ ] : [
615
+ s ? 1 : 2,
616
+ a.startLine - n,
617
+ l
618
+ ];
619
+ };
620
+ return [...o].sort((a, c) => {
621
+ const l = i(a), u = i(c);
622
+ for (let d = 0; d < l.length; d += 1) {
623
+ const m = l[d] - u[d];
624
+ if (m !== 0)
625
+ return m;
626
+ }
627
+ return a.startLine - c.startLine;
628
+ })[0] ?? null;
629
+ }, H = (e) => e.kind !== "blank" && e.estimatedHeight > 0, B = (e, t, n) => Math.max(0, Math.min(Math.max(0, t - n), e)), hs = (e, t, n) => {
630
+ const r = Math.max(1, n.viewportHeight), s = n.edgePadding ?? 32;
631
+ if (t.align === "end")
632
+ return B(e.totalEstimatedHeight, e.totalEstimatedHeight, r);
633
+ const o = Math.max(1, Math.floor(t.lineNumber)), i = Math.max(0, Math.min(1, t.lineOffsetRatio ?? 0)), a = Mn(e, o);
634
+ if (e.blocks.filter(H).length === 0)
635
+ return 0;
636
+ if (a && H(a)) {
637
+ const d = Math.max(1, a.endLine - a.startLine + 1), h = Math.max(
638
+ 0,
639
+ Math.min(d, o - a.startLine + i)
640
+ ) / d;
641
+ return B(
642
+ a.estimatedTop + a.estimatedHeight * h - s,
643
+ e.totalEstimatedHeight,
644
+ r
645
+ );
646
+ }
647
+ const l = Sn(
648
+ e.blocks.map((d) => ({
649
+ ...d,
650
+ rendered: H(d)
651
+ })),
652
+ o
653
+ );
654
+ if (!l)
655
+ return 0;
656
+ const u = l.endLine < o ? l.estimatedTop + l.estimatedHeight : l.estimatedTop;
657
+ return B(u - s, e.totalEstimatedHeight, r);
658
+ }, gs = (e, t, n, r = 1200) => {
659
+ if (e.blocks.length === 0)
660
+ return {
661
+ blocks: [],
662
+ startIndex: 0,
663
+ endIndex: 0
664
+ };
665
+ const s = Math.min(r, Nt), o = r + (r - s), i = Math.max(0, t - s), a = Math.max(i, t + n + o), c = e.blocks.findIndex(
666
+ (x) => x.estimatedTop + x.estimatedHeight >= i
667
+ ), l = c === -1 ? e.blocks.length - 1 : Math.max(0, c);
668
+ let u = l;
669
+ for (; u < e.blocks.length && e.blocks[u].estimatedTop <= a; )
670
+ u += 1;
671
+ const d = e.totalEstimatedHeight <= 0 ? 0 : Math.max(0, Math.min(1, t / e.totalEstimatedHeight)), m = d >= ue ? Wt : Ft, h = d >= ue ? Dt : $t, f = Math.max(0, l - m), g = Math.min(e.blocks.length, u + h);
672
+ return {
673
+ blocks: e.blocks.slice(f, g),
674
+ startIndex: f,
675
+ endIndex: g
676
+ };
677
+ }, Mn = (e, t) => e.blocks.find((n) => n.startLine <= t && n.endLine >= t) ?? null, _n = {
678
+ attributes: [],
679
+ body: ""
680
+ }, bn = {
681
+ body: "",
682
+ sourceLineOffset: 0
683
+ }, Ue = {
684
+ previewBodyStartOffset: 0,
685
+ renderedPreview: bn
686
+ }, Ve = {
687
+ outlineHeadings: [],
688
+ parsedMarkdown: _n
689
+ }, kn = (e, t = {}) => {
690
+ const n = t.text ?? (e == null ? void 0 : e.text) ?? "", r = (e == null ? void 0 : e.viewMode) ?? "edit", s = (e == null ? void 0 : e.readingWidth) ?? "wide", o = ke((e == null ? void 0 : e.splitRatio) ?? be), i = (e == null ? void 0 : e.lineWrapping) ?? !0, a = (e == null ? void 0 : e.lineNumbers) ?? !0, c = (e == null ? void 0 : e.bookmarks) ?? [], l = (e == null ? void 0 : e.title) ?? "No file open", u = t.wordCount ?? Ot(n), d = !!e, m = Fe(n);
691
+ return {
692
+ bookmarks: c,
693
+ canCopy: n.trim().length > 0,
694
+ canFormat: d && r !== "preview",
695
+ hasFile: d,
696
+ largeDocumentMode: m,
697
+ lineNumbers: a,
698
+ lineWrapping: i,
699
+ readingWidth: s,
700
+ splitRatio: o,
701
+ text: n,
702
+ title: l,
703
+ viewMode: r,
704
+ wordCount: u
705
+ };
706
+ }, Tn = (e, t = {}) => {
707
+ if (!e)
708
+ return {
709
+ ...Ue,
710
+ ...Ve
711
+ };
712
+ const n = t.text ?? e.text, r = k(n), s = Te(r.body), o = n.indexOf(r.body), i = (o === -1 ? 0 : o) + xe(r.body, s.sourceLineOffset);
713
+ return {
714
+ outlineHeadings: Ae(r.body),
715
+ parsedMarkdown: r,
716
+ previewBodyStartOffset: i,
717
+ renderedPreview: s
718
+ };
719
+ }, ps = (e, t = {}) => {
720
+ if (!e)
721
+ return Ue;
722
+ const n = t.text ?? e.text, r = k(n), s = Te(r.body), o = n.indexOf(r.body);
723
+ return {
724
+ previewBodyStartOffset: (o === -1 ? 0 : o) + xe(r.body, s.sourceLineOffset),
725
+ renderedPreview: s
726
+ };
727
+ }, Ls = (e, t = {}) => {
728
+ if (!e)
729
+ return Ve;
730
+ const n = t.text ?? e.text, r = k(n);
731
+ return {
732
+ outlineHeadings: Ae(r.body),
733
+ parsedMarkdown: r
734
+ };
735
+ }, Es = (e, t = {}) => ({
736
+ ...kn(e, t),
737
+ ...Tn(e, t)
738
+ }), Os = (e, t, n = "") => `${e}/v1/rooms/${encodeURIComponent(t)}${n}`, Is = (e) => {
739
+ if (!e || typeof e != "object" || Array.isArray(e))
740
+ return !1;
741
+ const t = e;
742
+ return t.v === 1 && typeof t.roomId == "string" && t.kind === "room-event" && typeof t.version == "number" && typeof t.iv == "string" && typeof t.ciphertext == "string" && typeof t.createdAt == "string";
743
+ }, An = (e) => [...e].sort((t, n) => t.name.localeCompare(n.name)), U = (e, t) => Math.max(0, Math.min(e, t)), xn = (e, t) => e === t || !!e && !!t && (e == null ? void 0 : e.documentId) === (t == null ? void 0 : t.documentId) && (e == null ? void 0 : e.from) === (t == null ? void 0 : t.from) && (e == null ? void 0 : e.to) === (t == null ? void 0 : t.to), Cn = (e, t) => e === t || !!e && !!t && (e == null ? void 0 : e.length) === (t == null ? void 0 : t.length) && (e == null ? void 0 : e.every((n, r) => n === (t == null ? void 0 : t[r]))), vn = (e, t) => e.id === t.id && e.name === t.name && e.color === t.color && e.activeDocumentId === t.activeDocumentId && e.kind === t.kind && e.client === t.client && e.joinedAt === t.joinedAt && Cn(e.capabilities, t.capabilities) && e.roomId === t.roomId && e.fileTitle === t.fileTitle && xn(e.selection, t.selection), V = (e, t, n, r = -1) => {
744
+ let s = 0;
745
+ for (const o of P(t)) {
746
+ const i = o.insert.length, a = o.to - o.from;
747
+ if (e < o.from)
748
+ break;
749
+ if (e > o.to) {
750
+ s += i - a;
751
+ continue;
752
+ }
753
+ return e === o.from && a === 0 ? U(e + s + (r > 0 ? i : 0), n) : U(o.from + s + (r > 0 ? i : 0), n);
754
+ }
755
+ return U(e + s, n);
756
+ }, wn = (e, t, n) => {
757
+ if (e.from === e.to) {
758
+ const r = V(e.to, t, n, -1);
759
+ return { from: r, to: r };
760
+ }
761
+ return {
762
+ from: V(e.from, t, n, -1),
763
+ to: V(e.to, t, n, 1)
764
+ };
765
+ }, Rs = () => {
766
+ const e = /* @__PURE__ */ new Map();
767
+ return {
768
+ upsert(t, n) {
769
+ if (t.id === n)
770
+ return !1;
771
+ const r = e.get(t.id);
772
+ return r && vn(r, t) ? !1 : (e.set(t.id, t), !0);
773
+ },
774
+ prune(t) {
775
+ const n = new Set(t);
776
+ let r = !1;
777
+ for (const s of e.keys())
778
+ n.has(s) || (e.delete(s), r = !0);
779
+ return r;
780
+ },
781
+ remapSelections(t, n) {
782
+ if (t.length === 0)
783
+ return !1;
784
+ let r = !1;
785
+ for (const [s, o] of e) {
786
+ if (!o.selection)
787
+ continue;
788
+ const i = wn(o.selection, t, n);
789
+ i.from === o.selection.from && i.to === o.selection.to || (e.set(s, {
790
+ ...o,
791
+ selection: i
792
+ }), r = !0);
793
+ }
794
+ return r;
795
+ },
796
+ clear() {
797
+ const t = e.size > 0;
798
+ return e.clear(), t;
799
+ },
800
+ list() {
801
+ return An(e.values());
802
+ }
803
+ };
804
+ }, Ss = () => {
805
+ let e = !1, t = !1, n = !1;
806
+ return {
807
+ markJoinBlocked() {
808
+ t = !0;
809
+ },
810
+ markJoined() {
811
+ const r = e;
812
+ return e = !0, n = !1, r ? {
813
+ reconnected: !0,
814
+ message: "Connection restored and room state was resynced."
815
+ } : {
816
+ reconnected: !1
817
+ };
818
+ },
819
+ markOffline(r) {
820
+ const s = r === "disconnect" ? e ? "reconnecting" : "disconnected" : e ? "reconnecting" : "failed";
821
+ return t ? { status: "failed", notify: !1 } : n ? { status: s, notify: !1 } : r === "disconnect" && !e ? { status: s, notify: !1 } : (n = !0, {
822
+ status: s,
823
+ notify: !0,
824
+ message: r === "disconnect" ? "The collaboration server disconnected. Local edits will sync when it reconnects." : "The collaboration server is not reachable. Local edits stay in this browser."
825
+ });
826
+ },
827
+ isBlocked() {
828
+ return t;
829
+ }
830
+ };
831
+ }, Pn = (e, t) => Math.max(0, Math.min(t, e.length)), yn = (e, t) => {
832
+ const n = Pn(e, t);
833
+ let r = 1;
834
+ for (let s = 0; s < n; s += 1)
835
+ e.charCodeAt(s) === 10 && (r += 1);
836
+ return r;
837
+ }, Ge = (e, t) => {
838
+ if (!t)
839
+ return null;
840
+ const n = t.lineNumber ?? t.toLineNumber;
841
+ return typeof n == "number" && Number.isInteger(n) && n > 0 ? n : yn(e, t.to);
842
+ }, Nn = (e, t, n, r) => {
843
+ var o;
844
+ const s = e.activeDocumentId ?? ((o = e.selection) == null ? void 0 : o.documentId);
845
+ return r || s ? !!(r && s === r) : n && e.roomId ? e.roomId === n : !t || !e.fileTitle || e.fileTitle === t;
846
+ }, Ms = (e, t, n, r, s) => {
847
+ var l;
848
+ if (!(e.activeDocumentId ?? ((l = e.selection) == null ? void 0 : l.documentId)) && !e.fileTitle)
849
+ return e.kind === "agent" ? "Agent in workspace" : "In workspace";
850
+ if (!Nn(e, n, r, s))
851
+ return `${e.kind === "agent" ? "Agent viewing" : "Viewing"} ${e.fileTitle}`;
852
+ const i = Ge(t, e.selection), a = e.kind === "agent" ? "Agent" : "", c = i ? `Line ${i}` : "In this file";
853
+ return a ? `${a} - ${c}` : c;
854
+ }, _s = (e, t = "") => {
855
+ const n = Ge(t, e.selection), r = [e.name];
856
+ return e.kind === "agent" && r.push("agent"), e.fileTitle && r.push(e.fileTitle), n && r.push(`line ${n}`), r.join(" - ");
857
+ }, Fn = {
858
+ rowTolerance: 1
859
+ }, $n = {
860
+ fallbackGap: 6,
861
+ fallbackHeight: 24,
862
+ minRowHeight: 20
863
+ }, Wn = (e) => e.left + e.width, Dn = (e) => e.top + e.height, Y = (e, t) => Math.max(0, Math.min(e, Math.max(0, t))), Hn = (e, t) => {
864
+ const n = Y(Math.min(e.start, e.end), t), r = Y(Math.max(e.start, e.end), t);
865
+ return { start: n, end: r };
866
+ }, Bn = (e) => {
867
+ const t = /* @__PURE__ */ new Map();
868
+ return e.forEach((n) => {
869
+ const r = t.get(n.runIndex);
870
+ if (r) {
871
+ r.push(n);
872
+ return;
873
+ }
874
+ t.set(n.runIndex, [n]);
875
+ }), t;
876
+ }, bs = (e, t = {}) => {
877
+ const n = { ...Fn, ...t }, r = [];
878
+ return Bn(e).forEach((s) => {
879
+ const o = [...s].sort((a, c) => a.top - c.top || a.left - c.left), i = [];
880
+ o.forEach((a) => {
881
+ const c = i[i.length - 1];
882
+ if (!c || Math.abs(a.top - c.top) > n.rowTolerance) {
883
+ i.push({ top: a.top, rectangles: [a] });
884
+ return;
885
+ }
886
+ c.rectangles.push(a), c.top = Math.min(c.top, a.top);
887
+ }), i.forEach((a, c) => {
888
+ var h, f;
889
+ const l = a.top, u = Math.max(...a.rectangles.map(Dn)), d = (h = i[c + 1]) == null ? void 0 : h.top, m = typeof d == "number" && d > l ? d : u;
890
+ r.push({
891
+ runIndex: ((f = a.rectangles[0]) == null ? void 0 : f.runIndex) ?? 0,
892
+ rowIndex: c,
893
+ left: Math.min(...a.rectangles.map((g) => g.left)),
894
+ right: Math.max(...a.rectangles.map(Wn)),
895
+ top: l,
896
+ bottom: l + Math.max(1, m - l),
897
+ rectangles: a.rectangles
898
+ });
899
+ });
900
+ }), r.sort((s, o) => s.runIndex - o.runIndex || s.rowIndex - o.rowIndex);
901
+ }, ks = (e, t) => !!(e && t && e.runIndex === t.runIndex && e.rowIndex + 1 === t.rowIndex), ne = (e, t, n) => t === n ? e === t : e >= t && e <= n, Ke = (e, t) => {
902
+ const n = Math.min(e.start, e.end), r = Math.max(e.start, e.end);
903
+ return t.start === t.end ? n <= t.start && r >= t.start : n === r ? ne(n, t.start, t.end) : r > t.start && n < t.end;
904
+ }, Ts = ({
905
+ docLength: e,
906
+ position: t,
907
+ resolveLineAt: n
908
+ }) => n(Y(t, e)).number, As = ({
909
+ docLength: e,
910
+ ranges: t,
911
+ resolveLineAt: n
912
+ }) => {
913
+ const r = /* @__PURE__ */ new Set();
914
+ return t.forEach((s) => {
915
+ const o = Hn(s, e), i = n(o.start).number, a = o.end > o.start ? n(Math.max(o.start, o.end - 1)).number : i;
916
+ for (let c = i; c <= a; c += 1)
917
+ r.add(c);
918
+ }), r;
919
+ }, xs = (e) => e.map(
920
+ (t) => [
921
+ t.lineNumber,
922
+ t.start,
923
+ t.end,
924
+ t.hasBookmark ? 1 : 0,
925
+ t.hasComment ? 1 : 0,
926
+ t.hasActiveComment ? 1 : 0
927
+ ].join(":")
928
+ ).join("|"), Cs = (e, t) => e.length === t.length && e.every((n, r) => {
929
+ const s = t[r];
930
+ return n.lineNumber === s.lineNumber && n.start === s.start && n.end === s.end && n.hasBookmark === s.hasBookmark && n.hasComment === s.hasComment && n.hasActiveComment === s.hasActiveComment && Math.abs(n.top - s.top) < 0.5 && Math.abs(n.height - s.height) < 0.5;
931
+ }), Un = (e, t, n) => {
932
+ const r = [...t].reverse().find((o) => o.endLine < e), s = t.find((o) => o.startLine > e);
933
+ return r && s ? r.bottom + Math.max(0, s.top - r.bottom) / 2 - n.fallbackHeight / 2 : r ? r.bottom + n.fallbackGap : s ? Math.max(0, s.top - n.fallbackHeight - n.fallbackGap) : 0;
934
+ }, vs = (e, t, n = {}) => {
935
+ const r = { ...$n, ...n };
936
+ return e.map((s) => {
937
+ const o = t.find(
938
+ (c) => c.startLine <= s.lineNumber && c.endLine >= s.lineNumber
939
+ );
940
+ if (!o)
941
+ return {
942
+ ...s,
943
+ top: Un(s.lineNumber, t, r),
944
+ height: r.fallbackHeight
945
+ };
946
+ const i = Math.max(1, o.endLine - o.startLine + 1), a = Math.max(r.minRowHeight, (o.bottom - o.top) / i);
947
+ return {
948
+ ...s,
949
+ top: o.top + (s.lineNumber - o.startLine) * a,
950
+ height: a
951
+ };
952
+ }).filter((s, o, i) => i.findIndex((a) => a.lineNumber === s.lineNumber) === o);
953
+ }, Vn = (e, t, n) => ne(e, t, n), ws = ({
954
+ bookmarks: e,
955
+ createId: t,
956
+ lineStart: n,
957
+ lineEnd: r,
958
+ nowIso: s
959
+ }) => {
960
+ const o = e.find(
961
+ (i) => Vn(i.position, n, r)
962
+ );
963
+ return o ? e.filter((i) => i.id !== o.id) : [
964
+ ...e,
965
+ {
966
+ id: t(),
967
+ position: n,
968
+ createdAt: s
969
+ }
970
+ ];
971
+ }, Ps = ({
972
+ commentAnchors: e,
973
+ previewBody: t,
974
+ previewBodyStartOffset: n
975
+ }) => e.map((r) => ({
976
+ id: r.id,
977
+ start: r.start - n,
978
+ end: r.end - n
979
+ })).filter((r) => r.end > 0 && r.start < t.length).map((r) => ({
980
+ ...r,
981
+ start: Math.max(0, r.start),
982
+ end: Math.min(t.length, r.end)
983
+ })).filter((r) => r.end > r.start), ys = ({
984
+ body: e,
985
+ bodyStartOffset: t,
986
+ bookmarks: n,
987
+ commentAnchors: r,
988
+ activeCommentId: s,
989
+ includeEmptyLines: o = !0
990
+ }) => {
991
+ const i = e.split(`
992
+ `);
993
+ let a = 0;
994
+ return i.flatMap((c, l) => {
995
+ const u = t + a, d = u + c.length, m = { start: u, end: d }, h = n.some(
996
+ (g) => ne(g.position, u, d)
997
+ ), f = r.filter(
998
+ (g) => Ke(g, m)
999
+ );
1000
+ return a += c.length + 1, !o && !h && f.length === 0 ? [] : [{
1001
+ lineNumber: l + 1,
1002
+ start: u,
1003
+ end: d,
1004
+ hasBookmark: h,
1005
+ hasComment: f.length > 0,
1006
+ hasActiveComment: f.some(
1007
+ (g) => g.id === s
1008
+ )
1009
+ }];
1010
+ });
1011
+ }, Ns = ({
1012
+ items: e,
1013
+ lineStart: t,
1014
+ lineEnd: n,
1015
+ resolveRange: r
1016
+ }) => e.filter((s) => {
1017
+ const o = r(s);
1018
+ return !!(o && Ke(o, {
1019
+ start: t,
1020
+ end: n
1021
+ }));
1022
+ }), Fs = (e, t = Date.now()) => {
1023
+ const n = new Date(e);
1024
+ if (Number.isNaN(n.getTime()))
1025
+ return "";
1026
+ const r = Math.max(0, Math.floor((t - n.getTime()) / 1e3));
1027
+ if (r < 45)
1028
+ return "just now";
1029
+ const s = Math.floor(r / 60);
1030
+ if (s < 60)
1031
+ return `${s} ${s === 1 ? "minute" : "minutes"} ago`;
1032
+ const o = Math.floor(s / 60);
1033
+ if (o < 24)
1034
+ return `${o} ${o === 1 ? "hour" : "hours"} ago`;
1035
+ const i = Math.floor(o / 24);
1036
+ return i < 7 ? `${i} ${i === 1 ? "day" : "days"} ago` : new Intl.DateTimeFormat(void 0, {
1037
+ month: "short",
1038
+ day: "numeric"
1039
+ }).format(n);
1040
+ }, Gn = (e, t) => e === "preview" ? t.viewControls : e === "split" ? t.layoutControls : t.editorControls, Kn = (e, t) => [
1041
+ { active: e === "edit", icon: "edit", label: t.edit, viewMode: "edit" },
1042
+ { active: e === "split", icon: "split", label: t.split, viewMode: "split" },
1043
+ { active: e === "preview", icon: "preview", label: t.preview, viewMode: "preview" }
1044
+ ], $s = ({
1045
+ activeLineNumbers: e,
1046
+ activeLineWrapping: t,
1047
+ activeReadingWidth: n,
1048
+ activeSyncScrolling: r,
1049
+ activeViewMode: s,
1050
+ copy: o
1051
+ }) => {
1052
+ const i = {
1053
+ narrow: o.focusWidth,
1054
+ standard: o.standardWidth,
1055
+ wide: o.fillWidth
1056
+ };
1057
+ return {
1058
+ controlsLabel: Gn(s, o),
1059
+ documentControlsLabel: o.documentControlsLabel,
1060
+ lineNumbers: {
1061
+ active: e,
1062
+ label: o.lineNumbers
1063
+ },
1064
+ lineWrapping: {
1065
+ active: t,
1066
+ label: o.lineWrapping
1067
+ },
1068
+ readingWidthLabel: o.textWidth,
1069
+ readingWidthOptions: ft.map((a) => ({
1070
+ active: a === n,
1071
+ label: i[a],
1072
+ readingWidth: a
1073
+ })),
1074
+ searchLabel: o.search,
1075
+ showEditorToggles: s !== "preview",
1076
+ showSplitToggles: s === "split",
1077
+ syncScrolling: {
1078
+ active: r,
1079
+ label: o.syncScrolling
1080
+ },
1081
+ viewModeLabel: `${o.documentControlsLabel}: ${o.edit}, ${o.split}, ${o.preview}`,
1082
+ viewModeOptions: Kn(s, o)
1083
+ };
1084
+ }, R = (...e) => e.filter(Boolean).join(" "), Ws = ({
1085
+ document: e,
1086
+ hasSelectionActionPosition: t,
1087
+ searchOpen: n,
1088
+ selectedCharacterCount: r,
1089
+ shareOpen: s,
1090
+ splitDividerDragging: o
1091
+ }) => {
1092
+ const i = `view-${e.viewMode} reading-${e.readingWidth}`, a = e.lineNumbers ? "line-numbers-on" : "line-numbers-off", c = e.lineWrapping ? "line-wrapping-on" : "line-wrapping-off";
1093
+ return {
1094
+ centerWorkbenchClassName: R(
1095
+ "center-workbench",
1096
+ e.hasFile ? `has-file ${i}` : "empty",
1097
+ e.hasFile && a,
1098
+ e.hasFile && c
1099
+ ),
1100
+ documentControls: {
1101
+ activeLineNumbers: e.lineNumbers,
1102
+ activeLineWrapping: e.lineWrapping,
1103
+ activeReadingWidth: e.readingWidth,
1104
+ activeViewMode: e.viewMode
1105
+ },
1106
+ documentToolbarClassName: R(
1107
+ "document-toolbar-row",
1108
+ e.viewMode,
1109
+ `reading-${e.readingWidth}`,
1110
+ e.canFormat && "with-formatting"
1111
+ ),
1112
+ editorSurfaceClassName: R(
1113
+ "editor-surface",
1114
+ a,
1115
+ c,
1116
+ r > 0 && "has-text-selection"
1117
+ ),
1118
+ fileShellClassName: R(
1119
+ "file-shell",
1120
+ e.hasFile ? i : "empty",
1121
+ e.hasFile && "comments-enabled",
1122
+ e.hasFile && a,
1123
+ e.hasFile && c,
1124
+ e.canFormat && "with-format-toolbar",
1125
+ n && "with-search-row",
1126
+ s && "share-modal-open"
1127
+ ),
1128
+ formattingToolbarClassName: R(
1129
+ e.viewMode,
1130
+ `reading-${e.readingWidth}`
1131
+ ),
1132
+ showFormattingToolbar: e.canFormat,
1133
+ showSelectionCommentPopover: !!(e.hasFile && r > 0 && t),
1134
+ showSplitResizeHandle: e.viewMode === "split" && !s,
1135
+ statusBar: {
1136
+ activeFileTitle: e.title,
1137
+ activeViewMode: e.viewMode,
1138
+ wordCount: e.wordCount
1139
+ },
1140
+ workspaceClassName: R(
1141
+ "workspace",
1142
+ e.viewMode,
1143
+ `reading-${e.readingWidth}`,
1144
+ o && "split-resizing"
1145
+ )
1146
+ };
1147
+ }, Ds = (e, t) => t === void 0 ? { fileId: e } : { fileId: e, text: t }, ze = (e, t, n) => {
1148
+ if (typeof e.text == "string")
1149
+ return e.text;
1150
+ const r = n == null ? void 0 : n();
1151
+ return typeof r == "string" ? r : t;
1152
+ }, Hs = ({
1153
+ committedText: e,
1154
+ fileId: t,
1155
+ pendingCommit: n,
1156
+ readPendingText: r
1157
+ }) => (n == null ? void 0 : n.fileId) !== t ? e : ze(n, e, r), Bs = ({
1158
+ committedText: e,
1159
+ fileId: t,
1160
+ pendingCommit: n,
1161
+ readPendingText: r
1162
+ }) => {
1163
+ const s = (n == null ? void 0 : n.fileId) === t, o = s ? ze(n, e, r) : e;
1164
+ return {
1165
+ committedText: e,
1166
+ fileId: t,
1167
+ pending: s,
1168
+ pendingTextAvailable: s && typeof n.text == "string",
1169
+ visibleText: o
1170
+ };
1171
+ }, Us = (e, t) => !!(t && e && e.fileId === t.id && e.text !== void 0 && t.text !== e.text), Vs = ({
1172
+ fileId: e,
1173
+ revision: t = 0,
1174
+ text: n
1175
+ }) => {
1176
+ let r = n, s = !1, o = e, i = !1, a, c = !1, l = t, u = n;
1177
+ const d = (f) => {
1178
+ a = void 0, i = !0, c = !0, f !== u && (u = f, l += 1), s = u !== r;
1179
+ };
1180
+ return {
1181
+ applyPatch(f) {
1182
+ const g = Q(u, f);
1183
+ return typeof g != "string" ? !1 : (d(g), !0);
1184
+ },
1185
+ flush() {
1186
+ if (a) {
1187
+ const f = a();
1188
+ typeof f == "string" && f !== u && (u = f, s || (l += 1));
1189
+ }
1190
+ return a = void 0, i = !1, c = !0, !s && u === r ? null : (r = u, s = !1, { fileId: o, revision: l, text: u });
1191
+ },
1192
+ getSnapshot: () => ({
1193
+ committedText: r,
1194
+ dirty: s,
1195
+ fileId: o,
1196
+ pendingCommit: i,
1197
+ pendingTextAvailable: c,
1198
+ revision: l,
1199
+ text: u
1200
+ }),
1201
+ getText: () => u,
1202
+ getVisibleText: () => {
1203
+ if (a) {
1204
+ const f = a();
1205
+ if (typeof f == "string")
1206
+ return f;
1207
+ }
1208
+ return u;
1209
+ },
1210
+ replaceAll: d,
1211
+ setPendingCommit(f) {
1212
+ if (i = !0, a = f.readText, c = typeof f.text == "string", typeof f.text == "string") {
1213
+ d(f.text);
1214
+ return;
1215
+ }
1216
+ s = !0, l += 1;
1217
+ },
1218
+ syncCommitted(f) {
1219
+ o = f.fileId, r = f.text, u = f.text, s = !1, i = !1, a = void 0, c = !0, l = f.revision ?? l;
1220
+ }
1221
+ };
1222
+ }, zn = 32, w = /^[A-Za-z0-9_-]+$/, Yn = "/api/v2/", Gs = "/api/v2/post/", jn = (e) => e.replace(/\/+$/, ""), Ks = (e, t, n) => `${e}/#json=${t},${n}`, Ye = (e) => {
1223
+ const t = e.replace(/^#/, "").trim();
1224
+ if (!t.startsWith("json="))
1225
+ return null;
1226
+ const n = t.slice(5), [r, s, o] = n.split(",");
1227
+ if (o !== void 0 || n.includes("&") || !r || !w.test(r) || !s || !w.test(s))
1228
+ return null;
1229
+ try {
1230
+ return Z(s).byteLength === zn ? { snapshotId: r, key: s } : null;
1231
+ } catch {
1232
+ return null;
1233
+ }
1234
+ }, zs = (e) => e.pathname !== "/" ? null : Ye(e.hash), Ys = (e) => {
1235
+ if (e.pathname !== "/")
1236
+ return null;
1237
+ const t = e.hash.replace(/^#/, "").trim();
1238
+ if (!t.startsWith("json="))
1239
+ return null;
1240
+ const n = Ye(e.hash);
1241
+ if (n)
1242
+ return {
1243
+ status: "valid",
1244
+ route: n,
1245
+ routeKey: `${n.snapshotId}:${n.key}`
1246
+ };
1247
+ const r = t.slice(5), [s, o, i] = r.split(","), a = `invalid:${r}`;
1248
+ return !s || i !== void 0 || r.includes("&") || !w.test(s) ? {
1249
+ status: "invalid",
1250
+ routeKey: a,
1251
+ errorMessage: "This export link is invalid."
1252
+ } : o ? {
1253
+ status: "invalid",
1254
+ routeKey: a,
1255
+ errorMessage: "This export link has an invalid client-only key."
1256
+ } : {
1257
+ status: "invalid",
1258
+ routeKey: a,
1259
+ errorMessage: "This export link is missing its client-only key."
1260
+ };
1261
+ }, js = (e) => {
1262
+ try {
1263
+ const t = new URL(e), [n] = t.hash.split(",");
1264
+ return `${t.host}/${n}...`;
1265
+ } catch {
1266
+ return e;
1267
+ }
1268
+ }, Xs = (e, t) => {
1269
+ if (!Jn(e))
1270
+ throw new Error("Share link failed: invalid service response");
1271
+ const n = j(e.id, "id");
1272
+ if (!w.test(n))
1273
+ throw new Error("Share link failed: invalid service response id");
1274
+ const r = j(e.data, "data"), s = `${jn(t)}${Yn}${n}`;
1275
+ if (r !== s)
1276
+ throw new Error("Share link failed: invalid service response data");
1277
+ const o = qn(e.expiresAt, "expiresAt");
1278
+ return {
1279
+ id: n,
1280
+ data: r,
1281
+ ...o ? { expiresAt: o } : {}
1282
+ };
1283
+ }, Xn = (e, t) => {
1284
+ if (typeof e != "string")
1285
+ throw new Error(`Share link failed: missing ${t}`);
1286
+ return e;
1287
+ }, j = (e, t) => {
1288
+ const n = Xn(e, t);
1289
+ if (!n)
1290
+ throw new Error(`Share link failed: missing ${t}`);
1291
+ return n;
1292
+ }, Jn = (e) => typeof e == "object" && e !== null && !Array.isArray(e), qn = (e, t) => {
1293
+ if (e === void 0)
1294
+ return;
1295
+ const n = j(e, t);
1296
+ if (!Number.isFinite(Date.parse(n)))
1297
+ throw new Error(`Share link failed: invalid service response ${t}`);
1298
+ return n;
1299
+ }, Zn = 96, Qn = 32, M = (e, t, n) => Math.max(t, Math.min(n, e)), je = (e, t) => M(Number.isFinite(e) ? Math.floor(e) : 1, 1, Math.max(1, t)), er = (e) => M(Number.isFinite(e) ? e : 0, 0, 1), X = (e, t = 0) => {
1300
+ const n = e ?? t;
1301
+ return Number.isFinite(n) ? Math.max(0, n) : Math.max(0, t);
1302
+ }, tr = (e, t) => e.kind !== "blank" && t > 0, pe = (e, t, n) => {
1303
+ const r = Math.max(0, t - Math.max(1, n)), s = M(e, 0, r);
1304
+ return {
1305
+ clamped: Math.abs(s - e) > 0.5,
1306
+ scrollTop: s
1307
+ };
1308
+ }, nr = (e, t, n) => n <= 1 ? t >= 1 ? 1 : 0 : M((e - 1 + t) / n, 0, 1), rr = (e, t) => e.find(
1309
+ (n) => n.sourceStartLine <= t && n.sourceEndLine >= t
1310
+ ) ?? null, sr = (e, t) => t ? e.find((n) => n.id === t) ?? null : null, or = (e, t, n) => {
1311
+ const r = Math.max(1, e.sourceEndLine - e.sourceStartLine + 1), s = M(t - e.sourceStartLine + n, 0, r);
1312
+ return M(s / r, 0, 1);
1313
+ }, ir = (e) => e.filter((t) => t.renderable && t.previewHeight > 0), ar = (e, t, n) => {
1314
+ var o;
1315
+ const r = ir(e);
1316
+ if (r.length === 0)
1317
+ return 0;
1318
+ if (!t) {
1319
+ const i = [...r].sort((a, c) => {
1320
+ const l = n < a.sourceStartLine ? a.sourceStartLine - n : n - a.sourceEndLine, u = n < c.sourceStartLine ? c.sourceStartLine - n : n - c.sourceEndLine;
1321
+ return l - u || a.sourceStartLine - c.sourceStartLine;
1322
+ })[0];
1323
+ return (i == null ? void 0 : i.previewTop) ?? 0;
1324
+ }
1325
+ const s = r.find(
1326
+ (i) => i.sourceStartLine > t.sourceEndLine
1327
+ );
1328
+ if (s)
1329
+ return s.previewTop;
1330
+ for (let i = r.length - 1; i >= 0; i -= 1) {
1331
+ const a = r[i];
1332
+ if (a.sourceEndLine < t.sourceStartLine)
1333
+ return a.previewTop + a.previewHeight;
1334
+ }
1335
+ return ((o = r[0]) == null ? void 0 : o.previewTop) ?? 0;
1336
+ }, cr = (e, t, n = {}) => {
1337
+ const r = Math.max(0, Math.floor(n.sourceLineOffset ?? 0)), s = Math.max(
1338
+ 0,
1339
+ Math.floor(n.frontmatterLineCount ?? r)
1340
+ ), o = X(
1341
+ n.frontmatterMeasuredHeight,
1342
+ s > 0 ? n.frontmatterEstimatedHeight ?? Zn : 0
1343
+ ), i = Ne(e), a = Math.max(
1344
+ 1,
1345
+ Math.floor(n.sourceLineCount ?? r + i),
1346
+ s,
1347
+ ...t.blocks.map((u) => u.endLine + r)
1348
+ );
1349
+ let c = 0;
1350
+ const l = [];
1351
+ s > 0 && (l.push({
1352
+ id: "frontmatter",
1353
+ kind: "frontmatter",
1354
+ measured: typeof n.frontmatterMeasuredHeight == "number",
1355
+ previewHeight: o,
1356
+ previewTop: c,
1357
+ renderable: o > 0,
1358
+ sourceEndLine: s,
1359
+ sourceStartLine: 1
1360
+ }), c += o);
1361
+ for (const u of t.blocks) {
1362
+ const d = X(u.estimatedHeight);
1363
+ l.push({
1364
+ blockId: u.id,
1365
+ id: `block:${u.id}`,
1366
+ kind: u.kind,
1367
+ measured: !1,
1368
+ previewHeight: d,
1369
+ previewTop: c,
1370
+ renderable: tr(u, d),
1371
+ sourceEndLine: Math.max(1, u.endLine + r),
1372
+ sourceStartLine: Math.max(1, u.startLine + r)
1373
+ }), c += d;
1374
+ }
1375
+ return l.push({
1376
+ id: "document-end",
1377
+ kind: "document-end",
1378
+ measured: !0,
1379
+ previewHeight: 0,
1380
+ previewTop: c,
1381
+ renderable: !1,
1382
+ sourceEndLine: a,
1383
+ sourceStartLine: a
1384
+ }), {
1385
+ lineCount: a,
1386
+ segments: l,
1387
+ totalPreviewHeight: c
1388
+ };
1389
+ }, lr = (e, t) => {
1390
+ const n = Math.max(1, t.lineCount), r = e.atDocumentEnd ? n : je(e.lineNumber, n), s = e.atDocumentEnd ? 1 : er(e.lineOffsetRatio), o = e.atDocumentEnd ? t.segments.at(-1) ?? null : rr(t.segments, r), i = o ? or(o, r, s) : 0, a = e.atDocumentEnd ? 1 : nr(r, s, n);
1391
+ return {
1392
+ atDocumentEnd: e.atDocumentEnd,
1393
+ lineNumber: r,
1394
+ lineOffsetRatio: s,
1395
+ segmentId: (o == null ? void 0 : o.id) ?? null,
1396
+ segmentProgress: i,
1397
+ sourceProgress: a
1398
+ };
1399
+ }, ur = (e, t, n) => {
1400
+ const r = Math.max(1, n.viewportHeight), s = n.edgePadding ?? Qn, o = je(t.lineNumber, e.lineCount);
1401
+ if (t.atDocumentEnd)
1402
+ return {
1403
+ ...pe(
1404
+ e.totalPreviewHeight,
1405
+ e.totalPreviewHeight,
1406
+ r
1407
+ ),
1408
+ sourceLineNumber: o,
1409
+ sourceProgress: 1
1410
+ };
1411
+ const i = sr(e.segments, t.segmentId), a = i && i.renderable && i.previewHeight > 0 ? i.previewTop + i.previewHeight * t.segmentProgress - s : ar(e.segments, i, o) - s;
1412
+ return {
1413
+ ...pe(a, e.totalPreviewHeight, r),
1414
+ sourceLineNumber: o,
1415
+ sourceProgress: t.sourceProgress
1416
+ };
1417
+ }, Js = (e, t, n, r, s = {}) => {
1418
+ const o = cr(e, t, s), i = lr(n, o);
1419
+ return ur(o, i, r);
1420
+ }, qs = (e, t) => {
1421
+ let n = 0;
1422
+ const r = e.segments.map((s) => {
1423
+ const o = s.blockId !== void 0 ? t[s.blockId] : t[s.id], i = X(o, s.previewHeight), a = {
1424
+ ...s,
1425
+ measured: s.measured || typeof o == "number",
1426
+ previewHeight: i,
1427
+ previewTop: n,
1428
+ renderable: s.kind !== "blank" && s.kind !== "document-end" && i > 0
1429
+ };
1430
+ return n += i, a;
1431
+ });
1432
+ return {
1433
+ ...e,
1434
+ segments: r,
1435
+ totalPreviewHeight: n
1436
+ };
1437
+ }, Zs = {
1438
+ betaMarkdownBytes: 15e4,
1439
+ launchMarkdownBytes: 1e6,
1440
+ collaborationMinPeople: 2,
1441
+ collaborationMaxPeople: 5,
1442
+ collaborationSoakDurationMs: 1800 * 1e3
1443
+ }, Qs = {
1444
+ editorResponsivenessFirst: !0,
1445
+ splitViewPriority: "editor-responsiveness",
1446
+ previewRefresh: "idle-only",
1447
+ showTransientPreviewStatus: !1
1448
+ }, dr = /^(\s*)(\d+)(\.\s+)/, fr = /^(\s*)(?:[-*+]\s+\[[ xX]\]\s+|[-*+]\s+|\d+\.\s+)/, mr = (e, t) => {
1449
+ const n = Math.max(0, Math.min(Math.min(t.from, t.to), e.length)), r = Math.max(0, Math.min(Math.max(t.from, t.to), e.length)), s = e.lastIndexOf(`
1450
+ `, Math.max(0, n - 1)) + 1, o = r > n && e[r - 1] === `
1451
+ ` ? r - 1 : r, i = e.indexOf(`
1452
+ `, o), a = i === -1 ? e.length : i;
1453
+ return {
1454
+ from: s,
1455
+ to: a,
1456
+ selectionFrom: n,
1457
+ selectionTo: r,
1458
+ lines: e.slice(s, a).split(`
1459
+ `)
1460
+ };
1461
+ }, hr = (e, t) => {
1462
+ const n = e.match(fr);
1463
+ if (!n)
1464
+ return e;
1465
+ if (t === "indent")
1466
+ return ` ${e}`;
1467
+ const r = n[1], s = Math.min(2, r.length);
1468
+ return s === 0 ? e : e.slice(s);
1469
+ }, gr = (e, t) => {
1470
+ let n = 0;
1471
+ for (; n < e.length && n < t.length && e[n] === t[n]; )
1472
+ n += 1;
1473
+ return n;
1474
+ }, pr = (e, t, n) => {
1475
+ let r = 0;
1476
+ for (; r + n < e.length && r + n < t.length && e[e.length - r - 1] === t[t.length - r - 1]; )
1477
+ r += 1;
1478
+ return r;
1479
+ }, Lr = (e, t, n) => {
1480
+ if (t === n)
1481
+ return e;
1482
+ const r = gr(t, n), s = pr(t, n, r), o = t.length - s, i = n.length - s;
1483
+ return e === r && o === r && i > r ? i : e <= r ? e : e >= o ? Math.max(r, e + n.length - t.length) : i;
1484
+ }, Le = (e, t, n, r) => {
1485
+ let s = 0, o = 0;
1486
+ for (let i = 0; i < n.length; i += 1) {
1487
+ const a = n[i] ?? "", c = r[i] ?? "", l = s + a.length;
1488
+ if (e <= t + l) {
1489
+ const u = Math.max(0, e - t - s);
1490
+ return t + o + Lr(u, a, c);
1491
+ }
1492
+ s += a.length + 1, o += c.length + 1;
1493
+ }
1494
+ return t + r.join(`
1495
+ `).length;
1496
+ }, Er = (e) => {
1497
+ const t = /* @__PURE__ */ new Map();
1498
+ return e.map((n) => {
1499
+ const r = n.match(dr);
1500
+ if (!r)
1501
+ return n.trim().length > 0 && t.clear(), n;
1502
+ const s = r[1], o = t.get(s), i = o === void 0 ? Number(r[2]) : o + 1;
1503
+ t.set(s, i);
1504
+ for (const a of t.keys())
1505
+ a.length > s.length && t.delete(a);
1506
+ return `${s}${i}${r[3]}${n.slice(r[0].length)}`;
1507
+ });
1508
+ }, eo = (e, t, n) => {
1509
+ const r = mr(e, t), s = r.lines.map((c) => hr(c, n)), o = Er(s);
1510
+ if (!o.some((c, l) => c !== r.lines[l]))
1511
+ return null;
1512
+ const a = o.join(`
1513
+ `);
1514
+ return {
1515
+ from: r.from,
1516
+ to: r.to,
1517
+ insert: a,
1518
+ selection: {
1519
+ from: Le(r.selectionFrom, r.from, r.lines, o),
1520
+ to: Le(r.selectionTo, r.from, r.lines, o)
1521
+ }
1522
+ };
1523
+ }, Or = /(!?)\[([^\]\n]*(?:\\.[^\]\n]*)*)\]\(([^)\s]+)\)/g, Ir = /^(?:https?:\/\/|mailto:|\/(?!\/)|#|\.\.?\/)/i, Rr = (e) => Ir.test(e.trim()), Xe = (e) => Array.from(e.matchAll(Or)).map((t) => {
1524
+ const n = t[0], r = t.index ?? 0, i = r + t[1].length + 1 + t[2].length + 2, a = t[3], c = i + a.length;
1525
+ return {
1526
+ from: r,
1527
+ to: r + n.length,
1528
+ text: t[2],
1529
+ url: a,
1530
+ urlFrom: i,
1531
+ urlTo: c,
1532
+ isImage: t[1] === "!",
1533
+ isSafe: Rr(a)
1534
+ };
1535
+ }), to = (e, t) => {
1536
+ const n = Math.max(0, Math.min(t, e.length));
1537
+ return Xe(e).find(
1538
+ (r) => !r.isImage && n >= r.from && n <= r.to
1539
+ ) ?? null;
1540
+ }, no = (e, t, n) => {
1541
+ const r = Xe(e).find((s) => s.from === t && !s.isImage);
1542
+ return !r || r.url === n ? null : {
1543
+ patch: {
1544
+ from: r.urlFrom,
1545
+ to: r.urlTo,
1546
+ insert: n
1547
+ },
1548
+ selection: {
1549
+ from: r.urlFrom,
1550
+ to: r.urlFrom + n.length
1551
+ }
1552
+ };
1553
+ }, Sr = /^(\s*[-*+]\s+\[)([ xX])(\]\s+)/, Mr = (e) => {
1554
+ const t = [];
1555
+ let n = 0;
1556
+ for (; n <= e.length; ) {
1557
+ const r = e.indexOf(`
1558
+ `, n), s = r === -1 ? e.length : r;
1559
+ if (t.push({ start: n, end: s, text: e.slice(n, s) }), r === -1)
1560
+ break;
1561
+ n = r + 1;
1562
+ }
1563
+ return t;
1564
+ }, Je = (e) => Mr(e).map((t) => {
1565
+ const n = t.text.match(Sr);
1566
+ if (!n)
1567
+ return null;
1568
+ const r = t.start + n[1].length;
1569
+ return {
1570
+ lineStart: t.start,
1571
+ lineEnd: t.end,
1572
+ markerStart: t.start + n[1].length - 1,
1573
+ markerEnd: t.start + n[0].length,
1574
+ stateStart: r,
1575
+ stateEnd: r + 1,
1576
+ checked: n[2].toLowerCase() === "x"
1577
+ };
1578
+ }).filter((t) => t !== null), _r = (e, t) => {
1579
+ const n = Math.max(0, Math.min(t, e.length));
1580
+ return Je(e).find(
1581
+ (r) => n >= r.markerStart && n <= r.markerEnd
1582
+ ) ?? null;
1583
+ }, ro = (e, t) => {
1584
+ const n = _r(e, t);
1585
+ if (!n)
1586
+ return null;
1587
+ const r = n.checked ? " " : "x";
1588
+ return {
1589
+ patch: {
1590
+ from: n.stateStart,
1591
+ to: n.stateEnd,
1592
+ insert: r
1593
+ },
1594
+ selection: {
1595
+ from: n.stateStart,
1596
+ to: n.stateStart + r.length
1597
+ }
1598
+ };
1599
+ }, so = (e, t) => {
1600
+ const n = Math.max(0, Math.min(t, e.length)), r = Je(e).find((o) => o.lineStart === n);
1601
+ if (!r)
1602
+ return null;
1603
+ const s = r.checked ? " " : "x";
1604
+ return {
1605
+ patch: {
1606
+ from: r.stateStart,
1607
+ to: r.stateEnd,
1608
+ insert: s
1609
+ },
1610
+ selection: {
1611
+ from: r.stateStart,
1612
+ to: r.stateStart + s.length
1613
+ }
1614
+ };
1615
+ }, Ee = (e, t) => Math.max(0, Math.min(e, t)), E = (e, t) => {
1616
+ const n = Ee(Math.min(t.from, t.to), e.length), r = Ee(Math.max(t.from, t.to), e.length);
1617
+ return { from: n, to: r };
1618
+ }, p = (e, t, n, r, s, o) => ({
1619
+ text: `${e.slice(0, t)}${r}${e.slice(n)}`,
1620
+ selection: {
1621
+ from: s,
1622
+ to: o
1623
+ }
1624
+ }), C = (e, t, { prefix: n, suffix: r = n, placeholder: s }) => {
1625
+ const { from: o, to: i } = E(e, t), a = e.slice(o, i);
1626
+ if (!a) {
1627
+ const f = `${n}${s}${r}`, g = o + n.length;
1628
+ return p(e, o, i, f, g, g + s.length);
1629
+ }
1630
+ const c = o - n.length, l = i + r.length;
1631
+ if (c >= 0 && e.slice(c, o) === n && e.slice(i, l) === r)
1632
+ return p(e, c, l, a, c, c + a.length);
1633
+ if (a.startsWith(n) && a.endsWith(r) && a.length >= n.length + r.length) {
1634
+ const f = a.slice(n.length, a.length - r.length);
1635
+ return p(e, o, i, f, o, o + f.length);
1636
+ }
1637
+ const m = `${n}${a}${r}`, h = o + n.length;
1638
+ return p(e, o, i, m, h, h + a.length);
1639
+ }, br = (e, t) => {
1640
+ const { from: n, to: r } = E(e, t), s = e.slice(n, r) || "link", o = `[${s}](url)`, i = n + s.length + 3;
1641
+ return p(e, n, r, o, i, i + 3);
1642
+ }, kr = (e, t) => {
1643
+ const { from: n, to: r } = E(e, t), s = e.slice(n, r) || "image alt", o = `![${s}](image-url)`, i = n + s.length + 4;
1644
+ return p(e, n, r, o, i, i + 9);
1645
+ }, re = (e, t) => {
1646
+ const { from: n, to: r } = E(e, t), s = e.lastIndexOf(`
1647
+ `, Math.max(0, n - 1)) + 1, o = r > n && e[r - 1] === `
1648
+ ` ? r - 1 : r, i = e.indexOf(`
1649
+ `, o), a = i === -1 ? e.length : i;
1650
+ return {
1651
+ from: s,
1652
+ to: a,
1653
+ lines: e.slice(s, a).split(`
1654
+ `)
1655
+ };
1656
+ }, T = (e, t, n) => {
1657
+ const r = re(e, t), s = n(r.lines).join(`
1658
+ `);
1659
+ return p(e, r.from, r.to, s, r.from, r.from + s.length);
1660
+ }, A = (e, t, n, r, s) => {
1661
+ const o = E(e, t), i = re(e, t);
1662
+ if (o.from !== o.to || i.lines.length !== 1 || i.lines[0] !== "")
1663
+ return null;
1664
+ const a = i.from + r;
1665
+ return p(e, i.from, i.to, n, a, a + s);
1666
+ }, se = (e) => {
1667
+ const t = e.match(/^(\s*)(?:- \[[ xX]\]\s+|\d+\.\s+|[-*+]\s+)?(.*)$/);
1668
+ return t ? {
1669
+ indent: t[1],
1670
+ content: t[2]
1671
+ } : { indent: "", content: e };
1672
+ }, L = (e) => e.trim().length > 0, G = (e, t, n) => A(
1673
+ e,
1674
+ t,
1675
+ `${"#".repeat(n)} Heading`,
1676
+ n + 1,
1677
+ 7
1678
+ ) ?? T(e, t, (r) => {
1679
+ const s = "#".repeat(n), o = r.filter(L), i = o.length > 0 && o.every((a) => new RegExp(`^#{${n}}\\s+`).test(a.trimStart()));
1680
+ return r.map((a) => {
1681
+ var u;
1682
+ if (!L(a))
1683
+ return a;
1684
+ const c = ((u = a.match(/^\s*/)) == null ? void 0 : u[0]) ?? "", l = a.trimStart().replace(/^#{1,6}\s+/, "");
1685
+ return i ? `${c}${l}` : `${c}${s} ${l}`;
1686
+ });
1687
+ }), Tr = (e, t) => A(e, t, "> quote", 2, 5) ?? T(e, t, (n) => {
1688
+ const r = n.some(L) && n.filter(L).every((s) => /^>\s?/.test(s));
1689
+ return n.map((s) => r ? s.replace(/^>\s?/, "") : `> ${s}`);
1690
+ }), Ar = (e, t) => A(e, t, "- item", 2, 4) ?? T(e, t, (n) => {
1691
+ const r = n.filter(L), s = r.length > 0 && r.every((o) => /^\s*[-*+]\s+/.test(o));
1692
+ return n.map((o) => {
1693
+ if (!L(o))
1694
+ return o;
1695
+ const { indent: i, content: a } = se(o);
1696
+ return s ? `${i}${a}` : `${i}- ${a}`;
1697
+ });
1698
+ }), xr = (e, t) => A(e, t, "1. item", 3, 4) ?? T(e, t, (n) => {
1699
+ const r = n.filter(L), s = r.length > 0 && r.every((i) => /^\s*\d+\.\s+/.test(i));
1700
+ let o = 1;
1701
+ return n.map((i) => {
1702
+ if (!L(i))
1703
+ return i;
1704
+ const { indent: a, content: c } = se(i);
1705
+ if (s)
1706
+ return `${a}${c}`;
1707
+ const l = `${a}${o}. ${c}`;
1708
+ return o += 1, l;
1709
+ });
1710
+ }), Cr = (e, t) => A(e, t, "- [ ] item", 6, 4) ?? T(e, t, (n) => {
1711
+ const r = n.filter(L), s = r.length > 0 && r.every((o) => /^\s*- \[[ xX]\]\s+/.test(o));
1712
+ return n.map((o) => {
1713
+ if (!L(o))
1714
+ return o;
1715
+ const { indent: i, content: a } = se(o);
1716
+ return s ? `${i}${a}` : `${i}- [ ] ${a}`;
1717
+ });
1718
+ }), vr = (e) => /^\s*(?:---|\*\*\*|___)\s*$/.test(e), wr = (e, t) => {
1719
+ const n = E(e, t), r = re(e, n), s = r.lines.filter(L);
1720
+ if (s.length > 0 && s.every(vr))
1721
+ return p(e, r.from, r.to, "", r.from, r.from);
1722
+ if (n.from === n.to && r.lines.length === 1 && r.lines[0].trim().length === 0)
1723
+ return p(e, r.from, r.to, "---", r.from + 3, r.from + 3);
1724
+ const o = r.to, i = e.slice(0, o), a = e.slice(o), c = i.length === 0 || i.endsWith(`
1725
+
1726
+ `) ? "" : i.endsWith(`
1727
+ `) ? `
1728
+ ` : `
1729
+
1730
+ `, l = a.length === 0 || a.startsWith(`
1731
+
1732
+ `) ? "" : a.startsWith(`
1733
+ `) ? `
1734
+ ` : `
1735
+
1736
+ `, u = `${c}---${l}`, d = o + c.length + 3;
1737
+ return p(e, o, o, u, d, d);
1738
+ }, Pr = (e, t) => {
1739
+ const { from: n, to: r } = E(e, t), s = e.slice(n, r), o = s.match(/^```[^\n]*\n([\s\S]*?)\n```$/);
1740
+ if (o) {
1741
+ const u = o[1];
1742
+ return p(e, n, r, u, n, n + u.length);
1743
+ }
1744
+ const i = s || "code", a = "language", c = `\`\`\`${a}
1745
+ ${i}
1746
+ \`\`\``, l = n + 3;
1747
+ return p(
1748
+ e,
1749
+ n,
1750
+ r,
1751
+ c,
1752
+ l,
1753
+ l + a.length
1754
+ );
1755
+ }, qe = (e, t, n, r, s) => {
1756
+ const { from: o, to: i } = E(e, t), a = e.slice(0, o), c = e.slice(i), l = a.length === 0 || a.endsWith(`
1757
+
1758
+ `) ? "" : a.endsWith(`
1759
+ `) ? `
1760
+ ` : `
1761
+
1762
+ `, u = c.length === 0 || c.startsWith(`
1763
+
1764
+ `) ? "" : c.startsWith(`
1765
+ `) ? `
1766
+ ` : `
1767
+
1768
+ `, d = `${l}${n}${u}`, m = o + l.length + r;
1769
+ return p(
1770
+ e,
1771
+ o,
1772
+ i,
1773
+ d,
1774
+ m,
1775
+ m + s
1776
+ );
1777
+ }, yr = (e, t) => qe(
1778
+ e,
1779
+ t,
1780
+ `| Column 1 | Column 2 |
1781
+ | --- | --- |
1782
+ | Value 1 | Value 2 |`,
1783
+ 2,
1784
+ 8
1785
+ ), Nr = (e, t) => {
1786
+ const { from: n, to: r } = E(e, t), s = `---
1787
+ title: Untitled
1788
+ ---
1789
+
1790
+ `, o = 11;
1791
+ return n === 0 && r === 0 ? p(e, 0, 0, s, o, o + 8) : qe(e, t, `---
1792
+ title: Untitled
1793
+ ---`, 11, 8);
1794
+ }, Fr = (e, t) => {
1795
+ const { from: n, to: r } = E(e, t), s = e.slice(n, r) || "note", o = `[^1]
1796
+
1797
+ [^1]: ${s}`, i = n + o.length - s.length;
1798
+ return p(e, n, r, o, i, i + s.length);
1799
+ }, $r = (e) => e.replace(/\*\*([^*\n]+)\*\*/g, "$1").replace(/__([^_\n]+)__/g, "$1").replace(/~~([^~\n]+)~~/g, "$1").replace(/`([^`\n]+)`/g, "$1").replace(/!\[([^\]\n]*)\]\([^)]+\)/g, "$1").replace(/\[([^\]\n]+)\]\([^)]+\)/g, "$1").replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g, "$1$2").replace(/(^|[^_])_([^_\n]+)_(?!_)/g, "$1$2"), Wr = (e) => {
1800
+ const t = e.replace(/^(\s*)#{1,6}\s+/, "$1").replace(/^(\s*)>\s?/, "$1").replace(/^(\s*)(?:- \[[ xX]\]\s+|\d+\.\s+|[-*+]\s+)/, "$1");
1801
+ return $r(t);
1802
+ }, Dr = (e, t) => {
1803
+ const { from: n, to: r } = E(e, t);
1804
+ if (n === r)
1805
+ return { text: e, selection: { from: n, to: r } };
1806
+ const o = e.slice(n, r).split(`
1807
+ `).map(Wr).join(`
1808
+ `);
1809
+ return p(e, n, r, o, n, n + o.length);
1810
+ }, oo = (e, t, n) => {
1811
+ switch (n) {
1812
+ case "bold":
1813
+ return C(e, t, { prefix: "**", placeholder: "bold text" });
1814
+ case "italic":
1815
+ return C(e, t, { prefix: "_", placeholder: "italic text" });
1816
+ case "strikethrough":
1817
+ return C(e, t, { prefix: "~~", placeholder: "struck text" });
1818
+ case "inline-code":
1819
+ return C(e, t, { prefix: "`", placeholder: "code" });
1820
+ case "link":
1821
+ return br(e, t);
1822
+ case "image":
1823
+ return kr(e, t);
1824
+ case "quote":
1825
+ return Tr(e, t);
1826
+ case "heading-1":
1827
+ return G(e, t, 1);
1828
+ case "heading-2":
1829
+ return G(e, t, 2);
1830
+ case "heading-3":
1831
+ return G(e, t, 3);
1832
+ case "bullet-list":
1833
+ return Ar(e, t);
1834
+ case "numbered-list":
1835
+ return xr(e, t);
1836
+ case "check-list":
1837
+ return Cr(e, t);
1838
+ case "horizontal-rule":
1839
+ return wr(e, t);
1840
+ case "code-block":
1841
+ return Pr(e, t);
1842
+ case "table":
1843
+ return yr(e, t);
1844
+ case "frontmatter":
1845
+ return Nr(e, t);
1846
+ case "footnote":
1847
+ return Fr(e, t);
1848
+ case "clear-formatting":
1849
+ return Dr(e, t);
1850
+ }
1851
+ }, io = (e) => e.replace(/\.md$/i, ""), Oe = (e, t) => e[t] ?? [], J = (e) => {
1852
+ const t = (e.replies ?? []).map((n) => Date.parse(n.createdAt)).filter(Number.isFinite);
1853
+ return Math.max(Date.parse(e.createdAt) || 0, ...t);
1854
+ }, Ie = (e) => Math.max(0, ...e.comments.map((t) => J(t))), Re = (e) => e.map((t) => ({
1855
+ ...t,
1856
+ comments: [...t.comments].sort((n, r) => J(r) - J(n))
1857
+ })).sort((t, n) => Ie(n) - Ie(t)), ao = (e, t) => {
1858
+ const n = e.map((s) => ({
1859
+ file: s,
1860
+ comments: Oe(t, s.id).filter((o) => !o.resolved)
1861
+ })).filter((s) => s.comments.length > 0), r = e.map((s) => ({
1862
+ file: s,
1863
+ comments: Oe(t, s.id).filter((o) => o.resolved)
1864
+ })).filter((s) => s.comments.length > 0);
1865
+ return {
1866
+ openCommentGroups: n,
1867
+ resolvedCommentGroups: r
1868
+ };
1869
+ }, co = ({
1870
+ activeFileId: e,
1871
+ openCommentGroups: t,
1872
+ resolvedCommentGroups: n,
1873
+ commentScope: r
1874
+ }) => {
1875
+ const s = t.find((c) => c.file.id === e), o = n.find((c) => c.file.id === e), i = r === "current" ? s ? [s] : [] : Re(t), a = r === "current" ? o ? [o] : [] : Re(n);
1876
+ return {
1877
+ scopedOpenCommentGroups: i,
1878
+ scopedResolvedCommentGroups: a,
1879
+ hasAnyComments: i.length > 0 || a.length > 0,
1880
+ hideSingleActiveFileHeader: r === "current"
1881
+ };
1882
+ }, lo = 16, Ze = 32, q = /^[A-Za-z0-9_-]+$/, Qe = (e) => {
1883
+ const t = e.replace(/^#/, "").trim();
1884
+ if (!t.startsWith("room="))
1885
+ return null;
1886
+ const n = t.slice(5), [r, s, o] = n.split(",");
1887
+ if (o !== void 0 || n.includes("&") || !r || !q.test(r) || !s || !q.test(s))
1888
+ return null;
1889
+ try {
1890
+ return Z(s).byteLength === Ze ? { roomId: r, roomKey: s } : null;
1891
+ } catch {
1892
+ return null;
1893
+ }
1894
+ }, uo = (e) => {
1895
+ var n;
1896
+ const t = (n = Qe(e)) == null ? void 0 : n.roomKey;
1897
+ if (!t || !q.test(t))
1898
+ return null;
1899
+ try {
1900
+ return Z(t).byteLength === Ze ? t : null;
1901
+ } catch {
1902
+ return null;
1903
+ }
1904
+ }, Hr = (e, t, n) => `${e}/#room=${t},${n}`, Br = (e) => {
1905
+ if (e.pathname !== "/")
1906
+ return null;
1907
+ const t = Qe(e.hash);
1908
+ return t ? {
1909
+ roomId: t.roomId,
1910
+ roomKey: t.roomKey,
1911
+ shareUrl: Hr(e.origin, t.roomId, t.roomKey)
1912
+ } : null;
1913
+ }, Ur = (e) => {
1914
+ try {
1915
+ return Br(new URL(e));
1916
+ } catch {
1917
+ return null;
1918
+ }
1919
+ }, Se = "Invite link unavailable", Vr = (e) => e.length > 12 ? `${e.slice(0, 8)}...` : e, Gr = (e, t) => {
1920
+ const n = e ? Ur(e) : null;
1921
+ return !n || t && n.roomId !== t ? {
1922
+ canCopy: !1,
1923
+ display: Se,
1924
+ title: e ?? Se
1925
+ } : {
1926
+ canCopy: !0,
1927
+ display: `${new URL(n.shareUrl).origin}/#room=${Vr(n.roomId)},...`,
1928
+ title: n.shareUrl,
1929
+ url: n.shareUrl
1930
+ };
1931
+ }, fo = ({
1932
+ canStartSession: e,
1933
+ isLive: t,
1934
+ labels: n,
1935
+ jsonShareCanExport: r,
1936
+ jsonShareDisabledReason: s,
1937
+ jsonShareExporting: o,
1938
+ jsonShareUrl: i,
1939
+ roomId: a,
1940
+ shareUrl: c,
1941
+ startSessionUnavailableReason: l
1942
+ }) => {
1943
+ const u = !!i, d = !!s;
1944
+ return {
1945
+ live: {
1946
+ status: t ? "active" : e ? "ready" : "blocked",
1947
+ canStart: e,
1948
+ disabledReason: l,
1949
+ link: Gr(c, a)
1950
+ },
1951
+ shareable: {
1952
+ status: o ? "exporting" : d ? "blocked" : u ? "exported" : "ready",
1953
+ canExport: r,
1954
+ disabledReason: s,
1955
+ hasLink: u,
1956
+ primaryLabel: o ? n.exporting : n.exportToLink
1957
+ }
1958
+ };
1959
+ }, mo = ({
1960
+ isLive: e,
1961
+ roomAttentionLabels: t = [
1962
+ "Reconnecting",
1963
+ "Disconnected",
1964
+ "Connection failed",
1965
+ "Room offline",
1966
+ "Changes aren’t backed up"
1967
+ ],
1968
+ roomOfflineLabel: n = "Room offline",
1969
+ savedLocallyLabel: r = "Saved locally",
1970
+ statusLabel: s
1971
+ }) => e ? t.includes(s) ? { label: s, tone: "attention", visible: !0 } : s === n ? { label: n, tone: "attention", visible: !0 } : { label: s, tone: "saved", visible: !1 } : { label: r, tone: "saved", visible: !0 };
1972
+ function ho(e, t) {
1973
+ if (!(t in e))
1974
+ return e;
1975
+ const { [t]: n, ...r } = e;
1976
+ return r;
1977
+ }
1978
+ function go(e, t, n) {
1979
+ if (e.some((s) => s.id === t.id))
1980
+ return e;
1981
+ const r = [...e];
1982
+ return r.splice(Math.min(Math.max(0, n), r.length), 0, t), r;
1983
+ }
1984
+ function po(e, t, n) {
1985
+ if (!n.includes(t) || e.includes(t))
1986
+ return e;
1987
+ const r = n.indexOf(t), s = [...e];
1988
+ return s.splice(
1989
+ Math.min(r, s.length),
1990
+ 0,
1991
+ t
1992
+ ), s;
1993
+ }
1994
+ const Lo = (e) => e.title.trim().toLowerCase().replace(/\.md$/, ""), I = (e, t) => ({
1995
+ ...e,
1996
+ ...t
1997
+ }), Me = (e, t) => typeof t == "function" ? t(e) : t, et = (e, t) => {
1998
+ const n = [];
1999
+ for (const r of e)
2000
+ !t.has(r) || n.includes(r) || n.push(r);
2001
+ return n;
2002
+ }, _e = ({
2003
+ files: e,
2004
+ openFileIds: t,
2005
+ activeFileId: n
2006
+ }) => {
2007
+ const r = new Set(e.map((a) => a.id)), s = et(t, r), i = !!(n && r.has(n)) ? n : s[0] ?? "";
2008
+ return i && !s.includes(i) && s.push(i), {
2009
+ files: e,
2010
+ openFileIds: s,
2011
+ activeFileId: i
2012
+ };
2013
+ }, tt = (e) => e.openFileIds.map((t) => e.files.find((n) => n.id === t)).filter((t) => !!t), Kr = (e) => tt(e).find((t) => t.id === e.activeFileId), oe = (e) => {
2014
+ const t = e.trim().split("\0").join(" ").replace(/[/\\]/g, " ").replace(/\s+/g, " ");
2015
+ return !t || t === "." || t === ".." ? "Untitled.md" : /\.[A-Za-z0-9]+$/.test(t) ? t : `${t}.md`;
2016
+ }, Eo = (e, t) => {
2017
+ const n = oe(t), r = new Set(e.map((l) => l.title.toLowerCase()));
2018
+ if (!r.has(n.toLowerCase()))
2019
+ return n;
2020
+ const s = n.match(/(\.[A-Za-z0-9]+)$/), o = (s == null ? void 0 : s[1]) ?? "", i = o ? n.slice(0, -o.length) : n;
2021
+ let a = 2, c = `${i} ${a}${o}`;
2022
+ for (; r.has(c.toLowerCase()); )
2023
+ a += 1, c = `${i} ${a}${o}`;
2024
+ return c;
2025
+ }, zr = (e, t, n) => {
2026
+ const r = n.trim().replace(/\s+/g, " ");
2027
+ if (!r)
2028
+ return {
2029
+ state: e,
2030
+ result: {
2031
+ ok: !1,
2032
+ reason: "empty",
2033
+ title: "",
2034
+ message: "File name cannot be empty."
2035
+ }
2036
+ };
2037
+ const s = oe(r);
2038
+ return e.files.find(
2039
+ (i) => i.id !== t && i.title.toLowerCase() === s.toLowerCase()
2040
+ ) ? {
2041
+ state: e,
2042
+ result: {
2043
+ ok: !1,
2044
+ reason: "duplicate",
2045
+ title: s,
2046
+ message: "File name already exists."
2047
+ }
2048
+ } : {
2049
+ state: {
2050
+ ...e,
2051
+ files: e.files.map(
2052
+ (i) => i.id === t ? I(i, { title: s }) : i
2053
+ )
2054
+ },
2055
+ result: { ok: !0, title: s }
2056
+ };
2057
+ }, nt = (e, t) => e.files.some((n) => n.id === t) ? {
2058
+ ...e,
2059
+ activeFileId: t,
2060
+ openFileIds: e.openFileIds.includes(t) ? e.openFileIds : [...e.openFileIds, t]
2061
+ } : e, Yr = (e, t) => t ? nt(e, t) : {
2062
+ ...e,
2063
+ activeFileId: ""
2064
+ }, jr = (e, t, n = {}) => {
2065
+ const r = [...e.files], s = n.insertAfterFileId ? r.findIndex((o) => o.id === n.insertAfterFileId) : -1;
2066
+ return s === -1 ? r.push(t) : r.splice(s + 1, 0, t), {
2067
+ files: r,
2068
+ openFileIds: e.openFileIds.includes(t.id) ? e.openFileIds : [...e.openFileIds, t.id],
2069
+ activeFileId: t.id
2070
+ };
2071
+ }, Xr = (e, t) => {
2072
+ const n = e.openFileIds.findIndex((a) => a === t);
2073
+ if (n === -1)
2074
+ return;
2075
+ const r = e.openFileIds.filter((a) => a !== t), s = t === e.activeFileId, o = s ? r[n] ?? r[n - 1] ?? r[0] ?? "" : e.activeFileId, i = s ? e.files.find((a) => a.id === o) : e.files.find((a) => a.id === e.activeFileId);
2076
+ return {
2077
+ state: {
2078
+ ...e,
2079
+ openFileIds: r,
2080
+ activeFileId: s ? (i == null ? void 0 : i.id) ?? "" : e.activeFileId
2081
+ },
2082
+ result: { closedActiveFile: s, nextActiveFile: i }
2083
+ };
2084
+ }, Jr = (e, t) => {
2085
+ if (!e.files.find((l) => l.id === t))
2086
+ return;
2087
+ const r = e.openFileIds.findIndex((l) => l === t), s = e.openFileIds.filter((l) => l !== t), o = t === e.activeFileId, i = o ? s[r] ?? s[r - 1] ?? s[0] ?? "" : e.activeFileId, a = e.files.filter((l) => l.id !== t), c = o ? a.find((l) => l.id === i) : Kr(e);
2088
+ return {
2089
+ state: {
2090
+ files: a,
2091
+ openFileIds: s,
2092
+ activeFileId: o ? (c == null ? void 0 : c.id) ?? "" : e.activeFileId
2093
+ },
2094
+ result: { closedActiveFile: o, nextActiveFile: c }
2095
+ };
2096
+ }, qr = (e, t, n) => {
2097
+ if (t === n)
2098
+ return e;
2099
+ const r = e.openFileIds.indexOf(t), s = e.openFileIds.indexOf(n);
2100
+ if (r === -1 || s === -1)
2101
+ return e;
2102
+ const o = [...e.openFileIds], [i] = o.splice(r, 1);
2103
+ return o.splice(s, 0, i), {
2104
+ ...e,
2105
+ openFileIds: o
2106
+ };
2107
+ }, Oo = (e, t) => {
2108
+ const n = tt(e);
2109
+ if (n.length < 2)
2110
+ return { state: e };
2111
+ const s = (Math.max(
2112
+ 0,
2113
+ n.findIndex((i) => i.id === e.activeFileId)
2114
+ ) + t + n.length) % n.length, o = n[s];
2115
+ return {
2116
+ state: {
2117
+ ...e,
2118
+ activeFileId: o.id
2119
+ },
2120
+ file: o
2121
+ };
2122
+ }, Zr = (e, t, n) => e.files.some((r) => r.id === t) ? {
2123
+ ...e,
2124
+ files: e.files.map((r) => r.id === t ? n(r) : r)
2125
+ } : e, S = (e, t) => e.activeFileId ? Zr(e, e.activeFileId, t) : e, Io = (e, t) => {
2126
+ var n, r;
2127
+ switch (t.type) {
2128
+ case "replaceWorkspace":
2129
+ return _e(t.state);
2130
+ case "replaceFiles":
2131
+ return _e({
2132
+ ...e,
2133
+ files: Me(e.files, t.update)
2134
+ });
2135
+ case "replaceOpenFileIds": {
2136
+ const s = new Set(e.files.map((a) => a.id)), o = et(Me(e.openFileIds, t.update), s), i = e.activeFileId && s.has(e.activeFileId) && !o.includes(e.activeFileId) ? [...o, e.activeFileId] : o;
2137
+ return {
2138
+ ...e,
2139
+ openFileIds: i,
2140
+ activeFileId: e.activeFileId && i.includes(e.activeFileId) ? e.activeFileId : i[0] ?? ""
2141
+ };
2142
+ }
2143
+ case "setActiveFileId":
2144
+ return Yr(e, t.fileId);
2145
+ case "selectFile":
2146
+ return nt(e, t.fileId);
2147
+ case "addFile":
2148
+ return jr(e, t.file, { insertAfterFileId: t.insertAfterFileId });
2149
+ case "renameFile":
2150
+ return zr(e, t.fileId, t.title).state;
2151
+ case "closeFile":
2152
+ return ((n = Xr(e, t.fileId)) == null ? void 0 : n.state) ?? e;
2153
+ case "deleteFile":
2154
+ return ((r = Jr(e, t.fileId)) == null ? void 0 : r.state) ?? e;
2155
+ case "reorderOpenFile":
2156
+ return qr(e, t.sourceFileId, t.targetFileId);
2157
+ case "setActiveFileText":
2158
+ return S(
2159
+ e,
2160
+ (s) => I(s, { text: t.text })
2161
+ );
2162
+ case "setActiveFileViewMode":
2163
+ return S(
2164
+ e,
2165
+ (s) => I(s, { viewMode: t.viewMode })
2166
+ );
2167
+ case "setActiveFileReadingWidth":
2168
+ return S(
2169
+ e,
2170
+ (s) => I(s, { readingWidth: t.readingWidth })
2171
+ );
2172
+ case "setActiveFileLineWrapping":
2173
+ return S(
2174
+ e,
2175
+ (s) => I(s, { lineWrapping: t.lineWrapping })
2176
+ );
2177
+ case "setActiveFileLineNumbers":
2178
+ return S(
2179
+ e,
2180
+ (s) => I(s, { lineNumbers: t.lineNumbers })
2181
+ );
2182
+ case "setActiveFileSplitRatio":
2183
+ return S(
2184
+ e,
2185
+ (s) => I(s, {
2186
+ splitRatio: ke(t.splitRatio)
2187
+ })
2188
+ );
2189
+ default:
2190
+ return e;
2191
+ }
2192
+ };
2193
+ function Qr(e) {
2194
+ return {
2195
+ viewMode: e.newFileViewMode,
2196
+ readingWidth: e.readingWidth,
2197
+ lineWrapping: e.lineWrapping,
2198
+ lineNumbers: e.lineNumbers
2199
+ };
2200
+ }
2201
+ const Ro = (e) => {
2202
+ const t = e.name.toLowerCase();
2203
+ return t.endsWith(".md") || t.endsWith(".markdown") || e.type === "text/markdown" || e.type === "text/plain";
2204
+ }, So = (e) => ({
2205
+ fileName: e.title,
2206
+ content: e.text,
2207
+ type: "text/markdown;charset=utf-8"
2208
+ }), Mo = (e, t, n) => ({
2209
+ title: oe(e || "Imported.md"),
2210
+ text: t,
2211
+ viewMode: n.newFileViewMode,
2212
+ overrides: Qr(n)
2213
+ }), _o = (e) => ({
2214
+ idle: "Local draft",
2215
+ connecting: "Connecting",
2216
+ connected: "Live session",
2217
+ reconnecting: "Reconnecting",
2218
+ disconnected: "Disconnected",
2219
+ failed: "Connection failed"
2220
+ })[e], bo = ({
2221
+ isLive: e,
2222
+ connectionStatus: t
2223
+ }) => e ? t : "idle", ko = (e) => {
2224
+ var r;
2225
+ const n = ((r = k(e.text).attributes.find((s) => s.key.toLowerCase() === "title")) == null ? void 0 : r.value) ?? "";
2226
+ return `${e.title} ${n}`;
2227
+ };
2228
+ export {
2229
+ xo as AES_GCM_IV_BYTES,
2230
+ ti as AGENT_ROOM_CAPABILITIES,
2231
+ ni as DEFAULT_ACTOR_COLOR,
2232
+ ri as DEFAULT_ACTOR_NAME,
2233
+ si as DEFAULT_AGENT_ACTOR_CLIENT,
2234
+ Co as DEFAULT_ENCRYPTION_KEY_BYTES,
2235
+ oi as DEFAULT_HUMAN_ACTOR_CLIENT,
2236
+ be as DEFAULT_SPLIT_EDITOR_RATIO,
2237
+ rs as FILE_VIEW_MODES,
2238
+ le as HEAVY_PREVIEW_FENCE_CHAR_THRESHOLD,
2239
+ ce as HEAVY_PREVIEW_FENCE_LINE_THRESHOLD,
2240
+ xt as HEAVY_PREVIEW_TABLE_RUN_THRESHOLD,
2241
+ ii as HUMAN_ROOM_CAPABILITIES,
2242
+ Yn as JSON_SHARE_API_PREFIX,
2243
+ w as JSON_SHARE_ID_PATTERN,
2244
+ zn as JSON_SHARE_KEY_BYTES,
2245
+ Gs as JSON_SHARE_POST_PATH,
2246
+ _t as LARGE_DOCUMENT_CHAR_THRESHOLD,
2247
+ bt as LARGE_DOCUMENT_LINE_THRESHOLD,
2248
+ Ce as LARGE_DOCUMENT_LONG_LINE_THRESHOLD,
2249
+ Tt as LARGE_DOCUMENT_TABLE_RUN_THRESHOLD,
2250
+ kt as LARGE_DOCUMENT_WORD_THRESHOLD,
2251
+ At as LIVE_PREVIEW_CHAR_THRESHOLD,
2252
+ ht as MAX_SPLIT_EDITOR_RATIO,
2253
+ mt as MIN_SPLIT_EDITOR_RATIO,
2254
+ ft as READING_WIDTHS,
2255
+ ai as REMOTE_AWARENESS_ORIGIN,
2256
+ ci as REMOTE_SYNC_ORIGIN,
2257
+ li as ROOM_ACTOR_ADJECTIVES,
2258
+ ui as ROOM_ACTOR_COLORS,
2259
+ di as ROOM_CHECKPOINT_RETENTION_MS,
2260
+ lo as ROOM_ID_BYTES,
2261
+ Ze as ROOM_KEY_BYTES,
2262
+ q as ROOM_KEY_PATTERN,
2263
+ fi as ROOM_WIRE_CHUNK_BYTES,
2264
+ mi as ROOM_WIRE_CHUNK_PAYLOAD_BYTES,
2265
+ hi as ROOM_WIRE_CHUNK_TTL_MS,
2266
+ gi as ROOM_WIRE_MAX_BUFFERED_BYTES,
2267
+ pi as ROOM_WIRE_MAX_CHUNKS,
2268
+ Li as ROOM_WIRE_MAX_CRDT_STATE_BYTES,
2269
+ Ei as ROOM_WIRE_MAX_INFLIGHT_PER_ACTOR,
2270
+ Oi as ROOM_WIRE_MAX_MESSAGE_BYTES,
2271
+ Ii as ROOM_WIRE_PROTOCOL_VERSION,
2272
+ ha as SHARE_SNAPSHOT_SCHEMA_VERSION,
2273
+ Qs as TABULA_LARGE_DOCUMENT_UX_POLICY,
2274
+ Zs as TABULA_PRODUCT_SUPPORT_TARGETS,
2275
+ na as WORKSPACE_ROOM_MAX_COMMENTS,
2276
+ ra as WORKSPACE_ROOM_MAX_COMMENT_LENGTH,
2277
+ sa as WORKSPACE_ROOM_MAX_CONTENT_BYTES,
2278
+ oa as WORKSPACE_ROOM_MAX_DOCUMENTS,
2279
+ ia as WORKSPACE_ROOM_MAX_FOLDERS,
2280
+ aa as WORKSPACE_ROOM_MAX_REPLIES,
2281
+ ca as WORKSPACE_ROOM_MAX_TREE_DEPTH,
2282
+ la as WORKSPACE_ROOM_ROOT_ID,
2283
+ ua as WORKSPACE_ROOM_SCHEMA_VERSION,
2284
+ jr as addWorkspaceFile,
2285
+ Ri as addWorkspaceRoomCommentReply,
2286
+ oo as applyMarkdownFormat,
2287
+ ms as applyPreviewBlockMeasurements,
2288
+ qs as applyPreviewSegmentMeasurements,
2289
+ Q as applyTextPatches,
2290
+ Cs as areLineSurfaceRowsEqual,
2291
+ Mt as areTextPatchesApplicable,
2292
+ $s as buildDocumentControlsModel,
2293
+ Ws as buildDocumentSurface,
2294
+ vs as buildLineSurfaceAnnotationRows,
2295
+ bs as buildLineSurfaceVisualRows,
2296
+ fo as buildShareViewModel,
2297
+ cr as buildSourceScrollSegments,
2298
+ Sn as choosePreviewRenderableAnchor,
2299
+ ke as clampSplitEditorRatio,
2300
+ Xr as closeWorkspaceFile,
2301
+ kn as createActiveDocumentEditorRuntime,
2302
+ ps as createActiveDocumentPreviewBodyRuntime,
2303
+ Ls as createActiveDocumentPreviewMetadataRuntime,
2304
+ Tn as createActiveDocumentPreviewRuntime,
2305
+ Es as createActiveDocumentRuntime,
2306
+ Ss as createCollabSessionState,
2307
+ Rs as createCollaboratorRegistry,
2308
+ So as createCurrentFileDownloadDraft,
2309
+ Bs as createDocumentBufferTextState,
2310
+ Vs as createEditorDocumentRuntime,
2311
+ vo as createIV,
2312
+ Mo as createImportedWorkspaceFileDraft,
2313
+ Ks as createJsonShareUrl,
2314
+ ds as createOptimisticPreviewBlockIndex,
2315
+ fs as createOptimisticPreviewBlockIndexFromPatches,
2316
+ Ds as createPendingDocumentBufferCommit,
2317
+ dn as createPreviewBlockIndex,
2318
+ Xo as createRoomAad,
2319
+ Si as createRoomActor,
2320
+ Mi as createRoomActorColor,
2321
+ _i as createRoomActorName,
2322
+ Os as createRoomApiUrl,
2323
+ bi as createRoomChunkAssembler,
2324
+ Jo as createRoomEnvelope,
2325
+ Hr as createRoomShareUrl,
2326
+ ga as createShareSnapshot,
2327
+ pa as createShareSnapshotPayload,
2328
+ La as createShareSnapshotPayloadFromData,
2329
+ _e as createWorkspaceModelState,
2330
+ ki as createWorkspaceRoomCrdt,
2331
+ Ti as createWorkspaceRoomDocument,
2332
+ Ai as createWorkspaceRoomFolder,
2333
+ xi as createWorkspaceRoomSyncController,
2334
+ Z as decodeBase64Url,
2335
+ Ho as decodeEncryptedData,
2336
+ Ci as decodeRoomWirePacket,
2337
+ wo as decryptData,
2338
+ qo as decryptRoomEnvelope,
2339
+ vi as decryptWorkspaceRoomCheckpoint,
2340
+ Jr as deleteWorkspaceFile,
2341
+ wi as deleteWorkspaceRoomComment,
2342
+ Pi as deleteWorkspaceRoomNode,
2343
+ St as diffTextPatch,
2344
+ Po as encodeBase64Url,
2345
+ Bo as encodeEncryptedData,
2346
+ yi as encodeRoomWirePacket,
2347
+ Ni as encodeRoomWirePackets,
2348
+ yo as encryptData,
2349
+ Fi as encryptWorkspaceRoomCheckpoint,
2350
+ Fs as formatCommentDate,
2351
+ js as formatJsonShareUrlPreview,
2352
+ No as generateEncryptionKey,
2353
+ Kr as getActiveWorkspaceFile,
2354
+ bo as getActiveWorkspaceStatus,
2355
+ Eo as getAvailableWorkspaceFileTitle,
2356
+ Ms as getCollaboratorPresenceDetail,
2357
+ _s as getCollaboratorPresenceLabel,
2358
+ Fo as getCrypto,
2359
+ $i as getDefaultRoomCapabilities,
2360
+ Hs as getDocumentBufferVisibleText,
2361
+ Ns as getItemsInSourceLineRange,
2362
+ Ys as getJsonShareImportRoute,
2363
+ zs as getJsonShareRoute,
2364
+ is as getLineNumberForOffset,
2365
+ yn as getLineNumberForPresenceOffset,
2366
+ Ge as getLineNumberForPresenceSelection,
2367
+ Ts as getLineNumberForSourcePosition,
2368
+ As as getLineNumbersForSourceRanges,
2369
+ xe as getLineStartOffset,
2370
+ xs as getLineSurfaceAnnotationsSignature,
2371
+ Dn as getLineSurfaceRectBottom,
2372
+ Wn as getLineSurfaceRectRight,
2373
+ ss as getMarkdownDocumentTitle,
2374
+ eo as getMarkdownIndentEdit,
2375
+ Ne as getMarkdownLineCount,
2376
+ to as getMarkdownLinkAtOffset,
2377
+ Xe as getMarkdownLinks,
2378
+ _r as getMarkdownTaskAtOffset,
2379
+ Je as getMarkdownTaskMarkers,
2380
+ Ot as getMarkdownWordCount,
2381
+ Qr as getNewFilePreferenceOverrides,
2382
+ tt as getOpenWorkspaceFiles,
2383
+ os as getOutlineHeadings,
2384
+ Ae as getOutlineHeadingsFromMarkdown,
2385
+ Te as getPreviewBody,
2386
+ Ps as getPreviewCommentAnchors,
2387
+ ys as getPreviewLineAnnotations,
2388
+ Js as getPreviewScrollTargetForEditorPosition,
2389
+ hs as getPreviewScrollTopForSourceLine,
2390
+ ur as getPreviewScrollTopForSourcePosition,
2391
+ gs as getPreviewWindow,
2392
+ ao as getRightPanelCommentGroups,
2393
+ co as getRightPanelCommentScopeModel,
2394
+ Gr as getRoomShareLinkView,
2395
+ mo as getStatusBarSaveState,
2396
+ as as getTextPatchesForChange,
2397
+ ko as getWorkspaceFileSearchText,
2398
+ Wi as getWorkspaceRoomComments,
2399
+ Di as getWorkspaceRoomDocument,
2400
+ Hi as getWorkspaceRoomDocumentComments,
2401
+ Bi as getWorkspaceRoomSnapshot,
2402
+ Ui as getWorkspaceRoomStructureSnapshot,
2403
+ _o as getWorkspaceStatusLabel,
2404
+ ls as hasGlobalMarkdownSyntax,
2405
+ Jt as hasHeavyMarkdownPreviewShape,
2406
+ jt as hasLargeMarkdownWordCount,
2407
+ cs as hasLongMarkdownLine,
2408
+ Vi as hasRoomCapability,
2409
+ $o as importEncryptionKey,
2410
+ Gi as initializeWorkspaceRoomCrdt,
2411
+ Nn as isCollaboratorInFile,
2412
+ Is as isEncryptedEnvelope,
2413
+ Zo as isEnvelopeKind,
2414
+ Fe as isLargeMarkdownDocument,
2415
+ Vn as isPositionInLineRange,
2416
+ Ki as isRemoteSyncOrigin,
2417
+ zi as isRoomCapability,
2418
+ Rr as isSafeMarkdownLinkUrl,
2419
+ Ro as isSupportedImportFileDescriptor,
2420
+ ks as lineSurfaceRowsAreAdjacent,
2421
+ V as mapCollaborationPositionThroughTextPatches,
2422
+ wn as mapCollaborationSelectionThroughTextPatches,
2423
+ Mn as mapPreviewLineToBlock,
2424
+ Yi as moveWorkspaceRoomNode,
2425
+ ji as normalizeRoomCapabilities,
2426
+ P as normalizeTextPatches,
2427
+ oe as normalizeWorkspaceFileTitle,
2428
+ Lo as normalizeWorkspaceFileTitleForLookup,
2429
+ k as parseFrontmatter,
2430
+ Ye as parseJsonShareFromHash,
2431
+ Xi as parseRoomActor,
2432
+ Qe as parseRoomFromHash,
2433
+ uo as parseRoomKeyFromHash,
2434
+ Br as parseRoomLocation,
2435
+ Ur as parseRoomShareUrl,
2436
+ Vo as parseShareSnapshot,
2437
+ ne as positionInSourceLine,
2438
+ ho as removeRecordKey,
2439
+ zr as renameWorkspaceFile,
2440
+ Ji as renameWorkspaceRoomNode,
2441
+ qr as reorderOpenWorkspaceFile,
2442
+ ze as resolvePendingDocumentBufferText,
2443
+ lr as resolveSourcePosition,
2444
+ go as restoreFileToList,
2445
+ po as restoreOpenFileId,
2446
+ Go as restoreShareSnapshot,
2447
+ Yo as restoreShareSnapshotPayload,
2448
+ Oo as selectAdjacentWorkspaceFile,
2449
+ nt as selectWorkspaceFile,
2450
+ Ko as serializeShareSnapshot,
2451
+ Yr as setWorkspaceActiveFileId,
2452
+ qi as setWorkspaceRoomComment,
2453
+ Zi as setWorkspaceRoomCommentResolved,
2454
+ Qi as setWorkspaceRoomNodeOrder,
2455
+ Us as shouldCancelPendingDocumentBufferCommit,
2456
+ us as shouldUseImmediateMarkdownPreview,
2457
+ An as sortCollaborators,
2458
+ Ke as sourceRangeIntersectsLine,
2459
+ io as stripMarkdownExtension,
2460
+ Wo as toArrayBuffer,
2461
+ ws as toggleLineBookmarkInList,
2462
+ ro as toggleMarkdownTaskAtOffset,
2463
+ so as toggleMarkdownTaskOnLine,
2464
+ jn as trimTrailingSlash,
2465
+ no as updateMarkdownLinkUrl,
2466
+ Xs as validateJsonShareCreateResponse,
2467
+ Qo as validateRoomPayload,
2468
+ Ea as validateShareSnapshotPayload,
2469
+ da as validateWorkspaceRoomLimits,
2470
+ ea as validateWorkspaceRoomStructure,
2471
+ fa as validateWorkspaceRoomStructureLimits,
2472
+ Io as workspaceReducer
2473
+ };
2474
+ //# sourceMappingURL=index.js.map