@kitionstage/sdk 0.0.0-stage → 0.5.2-stage.13

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 (259) hide show
  1. package/README.md +73 -2
  2. package/dist/LICENSE +177 -0
  3. package/dist/THIRD_PARTY_NOTICES +28 -0
  4. package/dist/lib/assets/kitEngine.worker-3iMvwtlI.js +12732 -0
  5. package/dist/lib/assets/loro_wasm_bg-Gulzks_0.wasm +0 -0
  6. package/dist/lib/chunks/batch-BWpAyHvP.js +789 -0
  7. package/dist/lib/chunks/canonical-BIWfVCL-.js +87 -0
  8. package/dist/lib/chunks/envelope-D6MGY-ZN.js +61 -0
  9. package/dist/lib/chunks/replica-D8w3I4sn.js +2472 -0
  10. package/dist/lib/chunks/runtime-BVJHE1Pg.js +997 -0
  11. package/dist/lib/chunks/session-BqXC9a1-.js +281 -0
  12. package/dist/lib/chunks/toolIds-BCeSGHpV.js +821 -0
  13. package/dist/lib/chunks/workspaceTree-Destqupf.js +23 -0
  14. package/dist/lib/convergence/index.js +1035 -0
  15. package/dist/lib/convergence/node.js +8 -0
  16. package/dist/lib/embed-server/callbacks.js +37 -0
  17. package/dist/lib/embed-server/cli.js +19 -0
  18. package/dist/lib/embed-server/index.js +272 -0
  19. package/dist/lib/extensions/index.js +439 -0
  20. package/dist/lib/extensions/panel.html +208 -0
  21. package/dist/lib/extensions/runtime.js +198 -0
  22. package/dist/lib/extensions/sandbox.html +35 -0
  23. package/dist/lib/kdm/index.js +437 -0
  24. package/dist/lib/kit-dev-host/checkUiIds.mjs +44 -0
  25. package/dist/lib/kit-dev-host/index.js +308 -0
  26. package/dist/lib/kit-dev-host/lineRow.mjs +47 -0
  27. package/dist/lib/kit-dev-host/modeSmoke.mjs +178 -0
  28. package/dist/lib/kit-editor/index.js +6481 -0
  29. package/dist/lib/kit-editor/styles.css +807 -0
  30. package/dist/lib/kit-editor/workspaceTree.js +1 -0
  31. package/dist/lib/kit-engine/index.js +7 -0
  32. package/dist/lib/kit-host/index.js +530 -0
  33. package/dist/lib/kit-ui-protocol/index.js +336 -0
  34. package/dist/lib/node-only/embed-server-callbacks.js +2 -0
  35. package/dist/lib/node-only/embed-server.js +2 -0
  36. package/dist/lib/sync/index.js +1008 -0
  37. package/dist/lib/sync/openToken.js +201 -0
  38. package/dist/lib/sync/replicaVersions.js +51 -0
  39. package/dist/standalone/chunks/batch-CAGYk6m4.js +789 -0
  40. package/dist/standalone/chunks/client-B9xkOcvf.js +772 -0
  41. package/dist/standalone/chunks/collab-CTQZ9h7J.js +1022 -0
  42. package/dist/standalone/chunks/comment-Ds9t8xSE.js +94 -0
  43. package/dist/standalone/chunks/comments-uVDS8Wxp.js +41 -0
  44. package/dist/standalone/chunks/document-B5MMuYyN.js +324 -0
  45. package/dist/standalone/chunks/envelope-GX4Cynkx.js +7612 -0
  46. package/dist/standalone/chunks/index-BEgEEnhU.js +287 -0
  47. package/dist/standalone/chunks/index-EEl8hGbP.js +1967 -0
  48. package/dist/standalone/chunks/kits-Cp51mDlw.js +9 -0
  49. package/dist/standalone/chunks/replica-Di2iCPiD.js +3281 -0
  50. package/dist/standalone/chunks/replicaVersions-C3rJxnk9.js +50 -0
  51. package/dist/standalone/chunks/touched-T9jKJjxn.js +78 -0
  52. package/dist/standalone/index.js +12 -0
  53. package/dist/standalone/script/index.js +339 -0
  54. package/dist/standalone/script/kits/board.js +5 -0
  55. package/dist/standalone/script/kits/cad.js +5 -0
  56. package/dist/standalone/script/kits/design.js +5 -0
  57. package/dist/standalone/script/kits/doc.js +5 -0
  58. package/dist/standalone/script/kits/film.js +5 -0
  59. package/dist/standalone/script/kits/html.js +5 -0
  60. package/dist/standalone/script/kits/index.js +38 -0
  61. package/dist/standalone/script/kits/layout.js +5 -0
  62. package/dist/standalone/script/kits/motion.js +5 -0
  63. package/dist/standalone/script/kits/note.js +5 -0
  64. package/dist/standalone/script/kits/pdf.js +5 -0
  65. package/dist/standalone/script/kits/photo.js +5 -0
  66. package/dist/standalone/script/kits/scene.js +5 -0
  67. package/dist/standalone/script/kits/sheet.js +5 -0
  68. package/dist/standalone/script/kits/slide.js +5 -0
  69. package/dist/standalone/script/kits/table.js +5 -0
  70. package/dist/standalone/script/kits/vector.js +5 -0
  71. package/dist/standalone/script/node.js +401 -0
  72. package/dist/standalone/script/proxy.js +254 -0
  73. package/dist/types/convergence/src/adapter.d.ts +131 -0
  74. package/dist/types/convergence/src/engine.d.ts +66 -0
  75. package/dist/types/convergence/src/index.d.ts +21 -0
  76. package/dist/types/convergence/src/net.d.ts +52 -0
  77. package/dist/types/convergence/src/node.d.ts +6 -0
  78. package/dist/types/convergence/src/report.d.ts +56 -0
  79. package/dist/types/convergence/src/rng.d.ts +12 -0
  80. package/dist/types/convergence/src/scenarios.d.ts +15 -0
  81. package/dist/types/convergence/src/state.d.ts +67 -0
  82. package/dist/types/embed/src/agent.d.ts +88 -0
  83. package/dist/types/embed/src/blobs.d.ts +2 -0
  84. package/dist/types/embed/src/collab.d.ts +250 -0
  85. package/dist/types/embed/src/comments.d.ts +30 -0
  86. package/dist/types/embed/src/errors.d.ts +24 -0
  87. package/dist/types/embed/src/handlers.d.ts +92 -0
  88. package/dist/types/embed/src/index.d.ts +20 -0
  89. package/dist/types/embed/src/mount.d.ts +39 -0
  90. package/dist/types/embed/src/replicaStore.d.ts +3 -0
  91. package/dist/types/embed/src/rooms.d.ts +40 -0
  92. package/dist/types/embed/src/schemas.d.ts +7 -0
  93. package/dist/types/embed/src/syncClients.d.ts +28 -0
  94. package/dist/types/embed/src/theme.d.ts +7 -0
  95. package/dist/types/embed/src/types.d.ts +596 -0
  96. package/dist/types/embed/src/ui.d.ts +33 -0
  97. package/dist/types/embed/src/version.d.ts +2 -0
  98. package/dist/types/embed-server/src/callbacks.d.ts +30 -0
  99. package/dist/types/embed-server/src/cli.d.ts +1 -0
  100. package/dist/types/embed-server/src/index.d.ts +19 -0
  101. package/dist/types/embed-server/src/page.d.ts +15 -0
  102. package/dist/types/embed-server/src/server.d.ts +39 -0
  103. package/dist/types/embed-server/src/session.d.ts +22 -0
  104. package/dist/types/extensions/src/gate.d.ts +17 -0
  105. package/dist/types/extensions/src/generated/runtime.d.ts +8 -0
  106. package/dist/types/extensions/src/host.d.ts +135 -0
  107. package/dist/types/extensions/src/index.d.ts +13 -0
  108. package/dist/types/extensions/src/manifest.d.ts +82 -0
  109. package/dist/types/extensions/src/protocol.d.ts +159 -0
  110. package/dist/types/extensions/src/rpc.d.ts +52 -0
  111. package/dist/types/extensions/src/runtime/document.d.ts +40 -0
  112. package/dist/types/extensions/src/runtime/index.d.ts +10 -0
  113. package/dist/types/extensions/src/runtime/panel.d.ts +19 -0
  114. package/dist/types/extensions/src/runtime/runtime.d.ts +54 -0
  115. package/dist/types/extensions/src/runtime/worker.d.ts +1 -0
  116. package/dist/types/extensions/src/sandbox.d.ts +41 -0
  117. package/dist/types/kdm/src/args.d.ts +12 -0
  118. package/dist/types/kdm/src/batch.d.ts +118 -0
  119. package/dist/types/kdm/src/canonical.d.ts +25 -0
  120. package/dist/types/kdm/src/comment.d.ts +114 -0
  121. package/dist/types/kdm/src/diff.d.ts +125 -0
  122. package/dist/types/kdm/src/envelope.d.ts +27 -0
  123. package/dist/types/kdm/src/errors.d.ts +28 -0
  124. package/dist/types/kdm/src/footprint.d.ts +21 -0
  125. package/dist/types/kdm/src/ids.d.ts +57 -0
  126. package/dist/types/kdm/src/index.d.ts +18 -0
  127. package/dist/types/kdm/src/marks.d.ts +32 -0
  128. package/dist/types/kdm/src/op.d.ts +124 -0
  129. package/dist/types/kdm/src/origin.d.ts +41 -0
  130. package/dist/types/kdm/src/overlay.d.ts +92 -0
  131. package/dist/types/kdm/src/projection.d.ts +29 -0
  132. package/dist/types/kdm/src/read.d.ts +90 -0
  133. package/dist/types/kdm/src/replica.d.ts +403 -0
  134. package/dist/types/kdm/src/schema.d.ts +185 -0
  135. package/dist/types/kdm/src/testing.d.ts +28 -0
  136. package/dist/types/kdm/src/toolIds.d.ts +61 -0
  137. package/dist/types/kdm/src/touched.d.ts +24 -0
  138. package/dist/types/kdm/src/tx.d.ts +215 -0
  139. package/dist/types/kdm/src/value.d.ts +23 -0
  140. package/dist/types/kit-dev-host/src/checkNoPaths.d.ts +19 -0
  141. package/dist/types/kit-dev-host/src/checkUiIds.d.mts +2 -0
  142. package/dist/types/kit-dev-host/src/index.d.ts +179 -0
  143. package/dist/types/kit-dev-host/src/lineRow.d.mts +14 -0
  144. package/dist/types/kit-dev-host/src/memoryFiles.d.ts +15 -0
  145. package/dist/types/kit-dev-host/src/modeSmoke.d.mts +8 -0
  146. package/dist/types/kit-editor/src/CommandDialog.d.ts +22 -0
  147. package/dist/types/kit-editor/src/CommentsPanel.d.ts +45 -0
  148. package/dist/types/kit-editor/src/CustomizeDialog.d.ts +32 -0
  149. package/dist/types/kit-editor/src/HostButtons.d.ts +11 -0
  150. package/dist/types/kit-editor/src/RenderFailure.d.ts +7 -0
  151. package/dist/types/kit-editor/src/TextSink.d.ts +6 -0
  152. package/dist/types/kit-editor/src/brand.d.ts +2 -0
  153. package/dist/types/kit-editor/src/catalogMenus.d.ts +27 -0
  154. package/dist/types/kit-editor/src/chart.d.ts +138 -0
  155. package/dist/types/kit-editor/src/conflicts.d.ts +12 -0
  156. package/dist/types/kit-editor/src/drawing.d.ts +83 -0
  157. package/dist/types/kit-editor/src/editor.d.ts +544 -0
  158. package/dist/types/kit-editor/src/engine/KitCanvas.d.ts +70 -0
  159. package/dist/types/kit-editor/src/engine/backdrop.d.ts +32 -0
  160. package/dist/types/kit-editor/src/engine/createKitFile.d.ts +12 -0
  161. package/dist/types/kit-editor/src/engine/decorations.d.ts +14 -0
  162. package/dist/types/kit-editor/src/engine/engineOverlays.d.ts +197 -0
  163. package/dist/types/kit-editor/src/engine/engineTools.d.ts +116 -0
  164. package/dist/types/kit-editor/src/engine/kitDraft.d.ts +70 -0
  165. package/dist/types/kit-editor/src/engine/kitEngine.d.ts +390 -0
  166. package/dist/types/kit-editor/src/engine/kitEngine.worker.d.ts +30 -0
  167. package/dist/types/kit-editor/src/engine/kitHost.d.ts +41 -0
  168. package/dist/types/kit-editor/src/engine/kitModel.d.ts +32 -0
  169. package/dist/types/kit-editor/src/engine/kitModelRunner.d.ts +99 -0
  170. package/dist/types/kit-editor/src/engine/kitModule.d.ts +185 -0
  171. package/dist/types/kit-editor/src/engine/kitShortcuts.d.ts +32 -0
  172. package/dist/types/kit-editor/src/engine/kitTools.d.ts +79 -0
  173. package/dist/types/kit-editor/src/engine/lazyFonts.d.ts +34 -0
  174. package/dist/types/kit-editor/src/engine/lentFiles.d.ts +29 -0
  175. package/dist/types/kit-editor/src/engine/rasterViewport.d.ts +178 -0
  176. package/dist/types/kit-editor/src/engine/readOnly.d.ts +78 -0
  177. package/dist/types/kit-editor/src/engine/refusal.d.ts +39 -0
  178. package/dist/types/kit-editor/src/engine/replica.d.ts +23 -0
  179. package/dist/types/kit-editor/src/engine/useKitDocument.d.ts +154 -0
  180. package/dist/types/kit-editor/src/engine/workerRelay.d.ts +62 -0
  181. package/dist/types/kit-editor/src/files.d.ts +74 -0
  182. package/dist/types/kit-editor/src/frame/EditorFrame.d.ts +74 -0
  183. package/dist/types/kit-editor/src/frame/FocusBar.d.ts +10 -0
  184. package/dist/types/kit-editor/src/frame/MenuNodes.d.ts +20 -0
  185. package/dist/types/kit-editor/src/frame/MenuRibbon.d.ts +8 -0
  186. package/dist/types/kit-editor/src/frame/ModeButton.d.ts +7 -0
  187. package/dist/types/kit-editor/src/frame/menus.d.ts +64 -0
  188. package/dist/types/kit-editor/src/frame/modes.d.ts +51 -0
  189. package/dist/types/kit-editor/src/frame/useFrameLayout.d.ts +34 -0
  190. package/dist/types/kit-editor/src/host.d.ts +127 -0
  191. package/dist/types/kit-editor/src/index.d.ts +85 -0
  192. package/dist/types/kit-editor/src/ink.d.ts +26 -0
  193. package/dist/types/kit-editor/src/lease.d.ts +53 -0
  194. package/dist/types/kit-editor/src/oneInFlight.d.ts +7 -0
  195. package/dist/types/kit-editor/src/phrases.d.ts +25 -0
  196. package/dist/types/kit-editor/src/presence.d.ts +79 -0
  197. package/dist/types/kit-editor/src/strings.d.ts +6 -0
  198. package/dist/types/kit-editor/src/toolIcons.d.ts +32 -0
  199. package/dist/types/kit-editor/src/uiCatalog.d.ts +59 -0
  200. package/dist/types/kit-editor/src/uiConfig.d.ts +53 -0
  201. package/dist/types/kit-editor/src/uiContext.d.ts +65 -0
  202. package/dist/types/kit-editor/src/uiStore.d.ts +20 -0
  203. package/dist/types/kit-editor/src/useCommentAnchors.d.ts +29 -0
  204. package/dist/types/kit-editor/src/useKitSession.d.ts +115 -0
  205. package/dist/types/kit-editor/src/workspaceTree.d.ts +5 -0
  206. package/dist/types/kit-engine/src/contract.d.ts +154 -0
  207. package/dist/types/kit-engine/src/index.d.ts +2 -0
  208. package/dist/types/kit-engine/src/session.d.ts +133 -0
  209. package/dist/types/kit-host/src/files.d.ts +163 -0
  210. package/dist/types/kit-host/src/index.d.ts +315 -0
  211. package/dist/types/kit-ui-protocol/src/index.d.ts +1145 -0
  212. package/dist/types/loro-crdt.d.ts +9 -0
  213. package/dist/types/script/kits/board.d.ts +534 -0
  214. package/dist/types/script/kits/cad.d.ts +2937 -0
  215. package/dist/types/script/kits/design.d.ts +3213 -0
  216. package/dist/types/script/kits/doc.d.ts +2575 -0
  217. package/dist/types/script/kits/film.d.ts +4067 -0
  218. package/dist/types/script/kits/html.d.ts +38 -0
  219. package/dist/types/script/kits/index.d.ts +20 -0
  220. package/dist/types/script/kits/layout.d.ts +3483 -0
  221. package/dist/types/script/kits/motion.d.ts +4826 -0
  222. package/dist/types/script/kits/note.d.ts +631 -0
  223. package/dist/types/script/kits/pdf.d.ts +829 -0
  224. package/dist/types/script/kits/photo.d.ts +7574 -0
  225. package/dist/types/script/kits/scene.d.ts +2962 -0
  226. package/dist/types/script/kits/sheet.d.ts +2419 -0
  227. package/dist/types/script/kits/slide.d.ts +1894 -0
  228. package/dist/types/script/kits/table.d.ts +654 -0
  229. package/dist/types/script/kits/vector.d.ts +5167 -0
  230. package/dist/types/script/src/agentRelay.d.ts +48 -0
  231. package/dist/types/script/src/capabilities.d.ts +21 -0
  232. package/dist/types/script/src/document.d.ts +87 -0
  233. package/dist/types/script/src/drafts.d.ts +141 -0
  234. package/dist/types/script/src/exchange.d.ts +30 -0
  235. package/dist/types/script/src/headless.d.ts +190 -0
  236. package/dist/types/script/src/index.d.ts +15 -0
  237. package/dist/types/script/src/kitModel.d.ts +17 -0
  238. package/dist/types/script/src/kits.d.ts +8 -0
  239. package/dist/types/script/src/node.d.ts +42 -0
  240. package/dist/types/script/src/port.d.ts +89 -0
  241. package/dist/types/script/src/proxy.d.ts +132 -0
  242. package/dist/types/script/src/room.d.ts +162 -0
  243. package/dist/types/script/src/sources.d.ts +73 -0
  244. package/dist/types/sync/src/backoff.d.ts +9 -0
  245. package/dist/types/sync/src/blobSection.d.ts +23 -0
  246. package/dist/types/sync/src/capabilities.d.ts +20 -0
  247. package/dist/types/sync/src/client.d.ts +253 -0
  248. package/dist/types/sync/src/framing.d.ts +35 -0
  249. package/dist/types/sync/src/hash.d.ts +2 -0
  250. package/dist/types/sync/src/index.d.ts +19 -0
  251. package/dist/types/sync/src/leases.d.ts +82 -0
  252. package/dist/types/sync/src/openToken.d.ts +104 -0
  253. package/dist/types/sync/src/protocol.d.ts +484 -0
  254. package/dist/types/sync/src/relay.d.ts +52 -0
  255. package/dist/types/sync/src/replicaVersions.d.ts +17 -0
  256. package/dist/types/sync/src/saveMachine.d.ts +83 -0
  257. package/dist/types/sync/src/saveRun.d.ts +52 -0
  258. package/dist/types/sync/src/transport.d.ts +19 -0
  259. package/package.json +229 -4
@@ -0,0 +1,287 @@
1
+ import { B as H, O as U, P as q, b as G, d as W, h as X, r as Q, a as Z, c as tt, e as et, f as st, s as rt } from "./batch-CAGYk6m4.js";
2
+ import { c as N, f as j, e as x, V as D } from "./envelope-GX4Cynkx.js";
3
+ import { K as nt, o as ot } from "./envelope-GX4Cynkx.js";
4
+ import { b as at, a as lt, c as dt, C as ct, e as ht, d as ut, f as pt, g as gt, i as yt, r as mt, h as At, s as Ot } from "./comment-Ds9t8xSE.js";
5
+ import { C as St, t as Tt } from "./touched-T9jKJjxn.js";
6
+ import { R as I, n as J } from "./replica-Di2iCPiD.js";
7
+ import { E as bt, K as Nt, L as Ct, N as vt, a as Mt, b as xt, c as It, d as Rt, e as _t, f as Bt, g as jt, h as Dt, i as Jt, j as kt, k as Ft, l as Pt, m as $t, o as Lt, q as Vt, s as Kt, t as Yt, p as zt, u as Ht, r as Ut, v as qt, w as Gt, x as Wt, y as Xt, z as Qt, A as Zt, B as te, C as ee, D as se, F as re, G as ie } from "./replica-Di2iCPiD.js";
8
+ const E = 4, O = (i) => typeof i == "object" && i !== null && !Array.isArray(i), m = (i, e) => Array.isArray(i[e]) ? i[e].filter(O) : [], T = (i) => O(i) && typeof i.parent == "string" && typeof i.field == "string" ? [i.parent, i.field] : null, b = (i, e) => JSON.stringify([i, e]);
9
+ function k(i) {
10
+ const e = /* @__PURE__ */ new Map(), r = (s) => {
11
+ s && e.set(b(...s), s);
12
+ };
13
+ for (const s of [...m(i, "created"), ...m(i, "deleted")]) r(T(s.at));
14
+ for (const s of m(i, "moved"))
15
+ r(T(s.from)), r(T(s.to));
16
+ for (const s of m(i, "changed"))
17
+ if (!(!Array.isArray(s.edits) || s.edits.length > 0 || typeof s.id != "string"))
18
+ for (const n of Array.isArray(s.fields) ? s.fields : []) typeof n == "string" && r([s.id, n]);
19
+ return [...e.values()].sort((s, n) => s[0] === n[0] ? s[1] < n[1] ? -1 : s[1] > n[1] ? 1 : 0 : s[0] < n[0] ? -1 : 1);
20
+ }
21
+ function M(i, e) {
22
+ if (typeof i == "number" && typeof e == "number") {
23
+ const c = e - i;
24
+ return Number.isFinite(c) ? c : null;
25
+ }
26
+ const r = (c) => typeof c == "string" && /^-?\d+$/.test(c) ? BigInt(c) : null, [s, n] = [r(i), r(e)];
27
+ return s === null || n === null ? null : (n - s).toString();
28
+ }
29
+ function V(i, e) {
30
+ const r = JSON.parse(JSON.stringify(i)), s = new Set(["created", "deleted", "moved"].flatMap((t) => m(i, t)).map((t) => t.id)), n = /* @__PURE__ */ new Map(), c = /* @__PURE__ */ new Map(), d = [];
31
+ for (const t of m(i, "changed")) {
32
+ const f = Array.isArray(t.edits) ? t.edits : [];
33
+ if (typeof t.id != "string" || s.has(t.id) || f.length === 0) continue;
34
+ const o = [];
35
+ for (const l of f) {
36
+ if (!O(l) || typeof l.field != "string") break;
37
+ const u = M(l.before, l.after);
38
+ if (u === null) break;
39
+ o.push([l.field, u]);
40
+ }
41
+ const h = Array.isArray(t.fields) ? t.fields : [];
42
+ o.length !== f.length || h.length !== o.length || !o.every(([l]) => h.includes(l)) || (o.sort((l, u) => l[0] < u[0] ? -1 : l[0] > u[0] ? 1 : 0), o.length === 1 && (n.set(t.id, JSON.stringify(o[0])), c.set(t.id, o[0])), d.push([t.id, o]));
43
+ }
44
+ const A = [], a = /* @__PURE__ */ new Set(), p = k(i);
45
+ if (n.size >= E)
46
+ for (const [t, f] of p) {
47
+ const o = e(t, f);
48
+ if (!o) continue;
49
+ let h = 0;
50
+ for (; h < o.length; ) {
51
+ const l = n.get(o[h]);
52
+ if (l === void 0) {
53
+ h += 1;
54
+ continue;
55
+ }
56
+ let u = h + 1;
57
+ for (; u < o.length && n.get(o[u]) === l; ) u += 1;
58
+ if (u - h >= E) {
59
+ const [R, _] = c.get(o[h]);
60
+ A.push({ parent: t, field: f, from: h, count: u - h, shift: { field: R, by: _ } });
61
+ for (const B of o.slice(h, u)) a.add(B);
62
+ }
63
+ h = u;
64
+ }
65
+ }
66
+ const g = [];
67
+ for (const [t, f] of d) {
68
+ if (a.has(t)) continue;
69
+ const o = JSON.stringify(f), h = g.find(([l]) => l === o);
70
+ h ? h[2].push(t) : g.push([o, f, [t]]);
71
+ }
72
+ for (const [, t, f] of g)
73
+ if (!(f.length < E)) {
74
+ A.push({ ids: f, edits: t.map(([o, h]) => ({ field: o, by: h })) });
75
+ for (const o of f) a.add(o);
76
+ }
77
+ const y = /* @__PURE__ */ new Map();
78
+ for (const t of m(i, "changed")) {
79
+ if (typeof t.id != "string" || a.has(t.id) || s.has(t.id) || !Array.isArray(t.edits) || t.edits.length === 0 || !Array.isArray(t.fields)) continue;
80
+ const f = [];
81
+ for (const l of t.edits) {
82
+ if (!O(l) || typeof l.field != "string" || !Object.hasOwn(l, "after")) break;
83
+ const u = l.after;
84
+ if (O(u) && ("excerpt" in u || Object.keys(u).length === 1 && "size" in u)) break;
85
+ f.push({ field: l.field, after: u });
86
+ }
87
+ if (f.length !== t.edits.length || t.fields.length !== f.length || !f.every((l) => t.fields.includes(l.field))) continue;
88
+ f.sort((l, u) => N(l.field, u.field));
89
+ const o = j(f), h = y.get(o);
90
+ h ? h.ids.push(t.id) : y.set(o, { edits: f, ids: [t.id] });
91
+ }
92
+ for (const { edits: t, ids: f } of y.values())
93
+ if (!(f.length < E)) {
94
+ A.push({ ids: f, edits: t });
95
+ for (const o of f) a.add(o);
96
+ }
97
+ const w = new Set(
98
+ A.filter((t) => typeof t.parent == "string").map((t) => b(t.parent, t.field))
99
+ ), S = (t) => {
100
+ t && w.add(b(...t));
101
+ };
102
+ for (const t of [...m(i, "created"), ...m(i, "deleted")]) S(T(t.at));
103
+ for (const t of m(i, "moved"))
104
+ S(T(t.from)), S(T(t.to));
105
+ return Array.isArray(r.changed) && (r.changed = r.changed.filter((t) => {
106
+ if (!O(t) || typeof t.id != "string") return !0;
107
+ if (a.has(t.id)) return !1;
108
+ if (!Array.isArray(t.edits) || t.edits.length > 0 || !Array.isArray(t.fields)) return !0;
109
+ const f = t.id;
110
+ return t.fields = t.fields.filter((o) => typeof o != "string" || !w.has(b(f, o))), t.fields.length > 0;
111
+ })), A.length > 0 && (r.footprint = A), F(r);
112
+ }
113
+ function v(i, e, r, s, n) {
114
+ if (JSON.stringify(e) === JSON.stringify(r)) return !0;
115
+ if (O(e) && O(r)) {
116
+ const c = Object.keys(e).sort(N);
117
+ return c.some((d) => !d || d.includes(".") || d.includes("*")) || JSON.stringify(c) !== JSON.stringify(Object.keys(r).sort(N)) ? !1 : (n.add(i), c.every((d) => v(`${i}.${d}`, e[d], r[d], s, n)));
118
+ }
119
+ return Array.isArray(e) && Array.isArray(r) ? e.length !== r.length ? !1 : e.every((c, d) => v(`${i}.${d}`, c, r[d], s, n)) : M(e, r) === null ? !1 : (s.push({ field: i, before: e, after: r }), !0);
120
+ }
121
+ function F(i) {
122
+ for (const e of m(i, "changed")) {
123
+ const r = Array.isArray(e.edits) ? e.edits.filter(O) : [], s = [], n = /* @__PURE__ */ new Set();
124
+ for (const a of r) {
125
+ const p = [];
126
+ typeof a.field == "string" && (O(a.before) || Array.isArray(a.before)) && v(a.field, a.before, a.after, p, n) ? s.push(...p) : s.push(a);
127
+ }
128
+ const c = /* @__PURE__ */ new Map();
129
+ s.forEach((a, p) => {
130
+ const g = M(a.before, a.after);
131
+ if (g === null || typeof a.field != "string") return;
132
+ const y = a.field.split(".");
133
+ for (let w = 1; w < y.length - 1; w++) {
134
+ if (/^\d+$/.test(y[w]) && !n.has(y.slice(0, w).join("."))) continue;
135
+ const S = y.map((o, h) => h === w ? "*" : o).join("."), t = JSON.stringify([S, g]), f = c.get(t) ?? { field: S, by: g, members: [] };
136
+ f.members.push([p, y[w]]), c.set(t, f);
137
+ }
138
+ });
139
+ const d = /* @__PURE__ */ new Set(), A = [];
140
+ for (const a of [...c.values()].sort((p, g) => p.field < g.field ? -1 : p.field > g.field ? 1 : JSON.stringify(p.by) < JSON.stringify(g.by) ? -1 : 1)) {
141
+ const p = a.members.filter(([y]) => !d.has(y)), g = [...new Set(p.map(([, y]) => y))].sort(N);
142
+ g.length < E || g.length !== p.length || (A.push({ field: a.field, count: g.length, keys: g, shift: { by: a.by } }), p.forEach(([y]) => d.add(y)));
143
+ }
144
+ A.length && (e.edits = [...s.filter((a, p) => !d.has(p)), ...A], e.fields = [...new Set(e.edits.map((a) => a.field))].sort());
145
+ }
146
+ return i;
147
+ }
148
+ const C = (1n << 64n) - 1n;
149
+ class P {
150
+ state;
151
+ constructor(e) {
152
+ this.state = BigInt(e) * 0x9e3779b97f4a7c15n & C | 1n;
153
+ }
154
+ nextU64() {
155
+ return this.state ^= this.state >> 12n, this.state = (this.state ^ this.state << 25n) & C, this.state ^= this.state >> 27n, this.state * 0x2545f4914f6cdd1dn & C;
156
+ }
157
+ /** A value in `0..bound`, or 0 when `bound` is 0. */
158
+ below(e) {
159
+ return e <= 0 ? 0 : Number(this.nextU64() % BigInt(e));
160
+ }
161
+ shuffle(e) {
162
+ for (let r = e.length - 1; r > 0; r -= 1) {
163
+ const s = this.below(r + 1);
164
+ [e[r], e[s]] = [e[s], e[r]];
165
+ }
166
+ }
167
+ }
168
+ class K {
169
+ replicas;
170
+ rng;
171
+ /** Fails with `out-of-range` when `count` is 0: a network has at least one replica. */
172
+ constructor(e, r, s = 1) {
173
+ if (!Number.isSafeInteger(r) || r < 1) throw x.outOfRange(0, 0);
174
+ const n = I.create(e, J(), 1n), c = n.snapshot();
175
+ this.replicas = [n];
176
+ for (let d = 2; d <= r; d += 1) this.replicas.push(I.load(e, c, BigInt(d)));
177
+ this.rng = new P(s);
178
+ }
179
+ /** Sends what `to` lacks from `from`. */
180
+ deliver(e, r) {
181
+ const s = this.replica(r);
182
+ s.importChanges(this.replica(e).exportChanges(s.version()));
183
+ }
184
+ /**
185
+ * Delivers every replica's changes to every other replica in a seeded order, then sends
186
+ * everything again from scratch to prove that duplicates are harmless.
187
+ */
188
+ syncAll() {
189
+ const e = this.replicas.length, r = [];
190
+ for (let s = 0; s < e; s += 1)
191
+ for (let n = 0; n < e; n += 1) s !== n && r.push([s, n]);
192
+ this.rng.shuffle(r);
193
+ for (const [s, n] of r) this.deliver(s, n);
194
+ for (const [s, n] of r) this.replica(n).importChanges(this.replica(s).exportChanges(D.empty()));
195
+ }
196
+ /** The common canonical state; throws with both states when two replicas differ, or when there are no replicas. */
197
+ converged() {
198
+ const [e, ...r] = this.replicas;
199
+ if (!e) throw new Error("the network has no replicas");
200
+ const s = e.stateText();
201
+ return r.forEach((n, c) => {
202
+ const d = n.stateText();
203
+ if (d !== s) throw new Error(`replica 0 and ${c + 1} differ:
204
+ ${s}
205
+ ---
206
+ ${d}`);
207
+ }), s;
208
+ }
209
+ replica(e) {
210
+ if (!Number.isSafeInteger(e) || e < 0 || e >= this.replicas.length) throw x.outOfRange(e, this.replicas.length);
211
+ return this.replicas[e];
212
+ }
213
+ }
214
+ export {
215
+ H as BatchError,
216
+ at as COMMENT_THREAD_TYPE,
217
+ lt as COMMENT_THREAD_TYPE_DEF,
218
+ dt as COMMENT_TYPE,
219
+ ct as COMMENT_TYPE_DEF,
220
+ St as ChangeAudit,
221
+ bt as EXCERPT_CHARS,
222
+ E as FOOTPRINT_MIN_RUN,
223
+ Nt as KDM_VERSION,
224
+ nt as KdmError,
225
+ Ct as LEAF_EDITS,
226
+ K as Network,
227
+ vt as NodeRef,
228
+ U as OBJECT_MODEL_CAPABILITY,
229
+ q as ProjectionView,
230
+ I as Replica,
231
+ P as Rng,
232
+ Mt as ToolIds,
233
+ xt as Tx,
234
+ D as Version,
235
+ ht as addThread,
236
+ It as agent,
237
+ G as batchOrigin,
238
+ j as canonicalText,
239
+ Rt as checkValue,
240
+ ut as commentThreads,
241
+ _t as decodeCommit,
242
+ Bt as decodeOrigin,
243
+ pt as deleteComment,
244
+ gt as deleteThread,
245
+ W as describeModel,
246
+ jt as diffIsEmpty,
247
+ Dt as diffStates,
248
+ Jt as diffWithToolIds,
249
+ kt as encodeCommit,
250
+ Ft as encodeOrigin,
251
+ Pt as fieldDef,
252
+ k as footprintLists,
253
+ $t as hasMarks,
254
+ X as hasProjections,
255
+ Lt as hasToolIds,
256
+ yt as isCommentType,
257
+ Vt as isContainer,
258
+ J as newDocId,
259
+ Kt as newObjectId,
260
+ Yt as objectReadOnly,
261
+ ot as openEnvelope,
262
+ zt as parseSchema,
263
+ Ht as person,
264
+ Ut as randomActor,
265
+ Q as readField,
266
+ mt as relocateAnchorRange,
267
+ Z as replicaTarget,
268
+ At as reply,
269
+ tt as resolveValues,
270
+ et as rootId,
271
+ st as runBatch,
272
+ rt as schemaOfDescription,
273
+ Ot as setResolved,
274
+ qt as system,
275
+ Gt as textSpan,
276
+ Tt as touchesOnlyComments,
277
+ Wt as typeDef,
278
+ Xt as undoScopeOf,
279
+ Qt as uuidFromBytes,
280
+ Zt as uuidToBytes,
281
+ te as uuidV7,
282
+ ee as withDeletedBasis,
283
+ V as withFootprint,
284
+ se as withLeafEdits,
285
+ re as withTextBasis,
286
+ ie as withTextSpans
287
+ };