@agentshouse/mdruntime 0.1.0-c53207a379315 → 0.1.0-c55eff775df08

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 (347) hide show
  1. package/README.md +21 -19
  2. package/dist/acceptance.d.ts +3 -0
  3. package/dist/acceptance.d.ts.map +1 -0
  4. package/dist/acceptance.js +299 -0
  5. package/dist/act-lanes.d.ts +30 -0
  6. package/dist/act-lanes.d.ts.map +1 -0
  7. package/dist/act-lanes.js +225 -0
  8. package/dist/actions.d.ts +26 -0
  9. package/dist/actions.d.ts.map +1 -0
  10. package/dist/actions.js +313 -0
  11. package/dist/adapter.d.ts +180 -113
  12. package/dist/adapter.d.ts.map +1 -1
  13. package/dist/attached-model.d.ts +3 -11
  14. package/dist/attached-model.d.ts.map +1 -1
  15. package/dist/attached-model.js +28 -51
  16. package/dist/authored.d.ts +88 -0
  17. package/dist/authored.d.ts.map +1 -0
  18. package/dist/authored.js +345 -0
  19. package/dist/bootstrap.d.ts +15 -18
  20. package/dist/bootstrap.d.ts.map +1 -1
  21. package/dist/bootstrap.js +252 -158
  22. package/dist/cell.d.ts +6 -0
  23. package/dist/cell.d.ts.map +1 -0
  24. package/dist/cell.js +9 -0
  25. package/dist/chain.d.ts +2 -1
  26. package/dist/chain.d.ts.map +1 -1
  27. package/dist/change-set.d.ts +4 -0
  28. package/dist/change-set.d.ts.map +1 -1
  29. package/dist/change-set.js +6 -0
  30. package/dist/change.d.ts +5 -0
  31. package/dist/change.d.ts.map +1 -1
  32. package/dist/change.js +7 -2
  33. package/dist/chat-types.d.ts +3 -0
  34. package/dist/chat-types.d.ts.map +1 -0
  35. package/dist/chat-types.js +11 -0
  36. package/dist/client.d.ts +36 -23
  37. package/dist/client.d.ts.map +1 -1
  38. package/dist/client.js +47 -58
  39. package/dist/collection.d.ts +27 -7
  40. package/dist/collection.d.ts.map +1 -1
  41. package/dist/collection.js +29 -27
  42. package/dist/column.d.ts +5 -0
  43. package/dist/column.d.ts.map +1 -0
  44. package/dist/column.js +9 -0
  45. package/dist/compile.d.ts +8 -6
  46. package/dist/compile.d.ts.map +1 -1
  47. package/dist/compile.js +287 -329
  48. package/dist/connection.d.ts +5 -143
  49. package/dist/connection.d.ts.map +1 -1
  50. package/dist/connection.js +114 -5128
  51. package/dist/context.d.ts +2 -0
  52. package/dist/context.d.ts.map +1 -0
  53. package/dist/context.js +7 -0
  54. package/dist/conversation-live.d.ts +150 -0
  55. package/dist/conversation-live.d.ts.map +1 -0
  56. package/dist/conversation-live.js +259 -0
  57. package/dist/conversation-row.d.ts +40 -0
  58. package/dist/conversation-row.d.ts.map +1 -0
  59. package/dist/conversation-row.js +66 -0
  60. package/dist/conversation.d.ts +72 -49
  61. package/dist/conversation.d.ts.map +1 -1
  62. package/dist/conversation.js +1012 -835
  63. package/dist/declaration.d.ts +10 -0
  64. package/dist/declaration.d.ts.map +1 -0
  65. package/dist/declaration.js +24 -0
  66. package/dist/discovery.d.ts +12 -0
  67. package/dist/discovery.d.ts.map +1 -0
  68. package/dist/discovery.js +157 -0
  69. package/dist/download.d.ts +6 -0
  70. package/dist/download.d.ts.map +1 -0
  71. package/dist/download.js +42 -0
  72. package/dist/durability.d.ts +20 -1
  73. package/dist/durability.d.ts.map +1 -1
  74. package/dist/durability.js +7 -0
  75. package/dist/entry.d.ts +8 -2
  76. package/dist/entry.d.ts.map +1 -1
  77. package/dist/entry.js +39 -18
  78. package/dist/expectation.d.ts +26 -13
  79. package/dist/expectation.d.ts.map +1 -1
  80. package/dist/expectation.js +72 -19
  81. package/dist/failure.d.ts +3 -0
  82. package/dist/failure.d.ts.map +1 -1
  83. package/dist/failure.js +8 -0
  84. package/dist/figures.d.ts +49 -0
  85. package/dist/figures.d.ts.map +1 -0
  86. package/dist/figures.js +199 -0
  87. package/dist/file.d.ts +1 -1
  88. package/dist/file.d.ts.map +1 -1
  89. package/dist/file.js +3 -2
  90. package/dist/holdings.d.ts +29 -0
  91. package/dist/holdings.d.ts.map +1 -0
  92. package/dist/holdings.js +95 -0
  93. package/dist/host.d.ts +22 -9
  94. package/dist/host.d.ts.map +1 -1
  95. package/dist/host.js +90 -44
  96. package/dist/house-query.d.ts +21 -0
  97. package/dist/house-query.d.ts.map +1 -0
  98. package/dist/house-query.js +41 -0
  99. package/dist/identity.d.ts +0 -1
  100. package/dist/identity.d.ts.map +1 -1
  101. package/dist/identity.js +0 -3
  102. package/dist/index.d.ts +40 -14
  103. package/dist/index.d.ts.map +1 -1
  104. package/dist/index.js +19 -5
  105. package/dist/install.d.ts +60 -0
  106. package/dist/install.d.ts.map +1 -0
  107. package/dist/install.js +537 -0
  108. package/dist/lifecycle.d.ts +7 -0
  109. package/dist/lifecycle.d.ts.map +1 -0
  110. package/dist/lifecycle.js +282 -0
  111. package/dist/listing.d.ts +60 -0
  112. package/dist/listing.d.ts.map +1 -0
  113. package/dist/listing.js +168 -0
  114. package/dist/live.d.ts +9 -6
  115. package/dist/live.d.ts.map +1 -1
  116. package/dist/live.js +118 -36
  117. package/dist/loaded.d.ts +5 -0
  118. package/dist/loaded.d.ts.map +1 -0
  119. package/dist/loaded.js +40 -0
  120. package/dist/locks.d.ts +7 -0
  121. package/dist/locks.d.ts.map +1 -0
  122. package/dist/locks.js +32 -0
  123. package/dist/lost.d.ts +5 -0
  124. package/dist/lost.d.ts.map +1 -0
  125. package/dist/lost.js +49 -0
  126. package/dist/media.d.ts +19 -2
  127. package/dist/media.d.ts.map +1 -1
  128. package/dist/media.js +119 -31
  129. package/dist/memory.d.ts +20 -7
  130. package/dist/memory.d.ts.map +1 -1
  131. package/dist/memory.js +257 -104
  132. package/dist/messages.d.ts +35 -5
  133. package/dist/messages.d.ts.map +1 -1
  134. package/dist/messages.js +109 -39
  135. package/dist/modal.d.ts +2 -0
  136. package/dist/modal.d.ts.map +1 -0
  137. package/dist/modal.js +11 -0
  138. package/dist/model.d.ts +6 -13
  139. package/dist/model.d.ts.map +1 -1
  140. package/dist/model.js +6 -23
  141. package/dist/models.d.ts +10 -0
  142. package/dist/models.d.ts.map +1 -0
  143. package/dist/models.js +153 -0
  144. package/dist/observation.d.ts +30 -13
  145. package/dist/observation.d.ts.map +1 -1
  146. package/dist/observation.js +218 -81
  147. package/dist/online.d.ts +7 -0
  148. package/dist/online.d.ts.map +1 -0
  149. package/dist/online.js +29 -0
  150. package/dist/opened.d.ts +1 -1
  151. package/dist/opened.d.ts.map +1 -1
  152. package/dist/opened.js +5 -5
  153. package/dist/opening.d.ts +4 -0
  154. package/dist/opening.d.ts.map +1 -0
  155. package/dist/opening.js +53 -0
  156. package/dist/outcome.d.ts +17 -5
  157. package/dist/outcome.d.ts.map +1 -1
  158. package/dist/outcome.js +35 -2
  159. package/dist/overlay.d.ts +7 -2
  160. package/dist/overlay.d.ts.map +1 -1
  161. package/dist/overlay.js +48 -24
  162. package/dist/page-metadata.d.ts +8 -0
  163. package/dist/page-metadata.d.ts.map +1 -0
  164. package/dist/page-metadata.js +19 -0
  165. package/dist/parts.d.ts +5 -0
  166. package/dist/parts.d.ts.map +1 -0
  167. package/dist/parts.js +65 -0
  168. package/dist/paths.d.ts +1 -0
  169. package/dist/paths.d.ts.map +1 -1
  170. package/dist/paths.js +22 -0
  171. package/dist/preparation.d.ts +41 -0
  172. package/dist/preparation.d.ts.map +1 -0
  173. package/dist/preparation.js +314 -0
  174. package/dist/presence.d.ts +58 -0
  175. package/dist/presence.d.ts.map +1 -0
  176. package/dist/presence.js +231 -0
  177. package/dist/queries.d.ts +16 -0
  178. package/dist/queries.d.ts.map +1 -0
  179. package/dist/queries.js +285 -0
  180. package/dist/query.d.ts +14 -210
  181. package/dist/query.d.ts.map +1 -1
  182. package/dist/query.js +3 -505
  183. package/dist/questions.d.ts +30 -0
  184. package/dist/questions.d.ts.map +1 -0
  185. package/dist/questions.js +116 -0
  186. package/dist/queue.d.ts +40 -0
  187. package/dist/queue.d.ts.map +1 -0
  188. package/dist/queue.js +480 -0
  189. package/dist/reach.d.ts +26 -14
  190. package/dist/reach.d.ts.map +1 -1
  191. package/dist/reach.js +319 -153
  192. package/dist/react.d.ts +21 -3
  193. package/dist/react.d.ts.map +1 -1
  194. package/dist/react.js +33 -1
  195. package/dist/read.d.ts +7 -0
  196. package/dist/read.d.ts.map +1 -0
  197. package/dist/read.js +17 -0
  198. package/dist/readiness.d.ts +12 -21
  199. package/dist/readiness.d.ts.map +1 -1
  200. package/dist/readiness.js +7 -15
  201. package/dist/reads.d.ts +38 -10
  202. package/dist/reads.d.ts.map +1 -1
  203. package/dist/reads.js +163 -85
  204. package/dist/recovery.d.ts +4 -0
  205. package/dist/recovery.d.ts.map +1 -1
  206. package/dist/recovery.js +59 -2
  207. package/dist/refresh.d.ts +7 -5
  208. package/dist/refresh.d.ts.map +1 -1
  209. package/dist/refresh.js +35 -7
  210. package/dist/refusal.d.ts +5 -0
  211. package/dist/refusal.d.ts.map +1 -0
  212. package/dist/refusal.js +55 -0
  213. package/dist/replica.d.ts +12 -18
  214. package/dist/replica.d.ts.map +1 -1
  215. package/dist/replica.js +66 -36
  216. package/dist/retried.d.ts +30 -0
  217. package/dist/retried.d.ts.map +1 -0
  218. package/dist/retried.js +72 -0
  219. package/dist/room-draft.d.ts +51 -12
  220. package/dist/room-draft.d.ts.map +1 -1
  221. package/dist/room-draft.js +364 -110
  222. package/dist/room-drafts.d.ts +24 -0
  223. package/dist/room-drafts.d.ts.map +1 -0
  224. package/dist/room-drafts.js +220 -0
  225. package/dist/room-list.d.ts +10 -0
  226. package/dist/room-list.d.ts.map +1 -0
  227. package/dist/room-list.js +45 -0
  228. package/dist/rows.d.ts +16 -22
  229. package/dist/rows.d.ts.map +1 -1
  230. package/dist/rows.js +49 -186
  231. package/dist/running.d.ts +5 -0
  232. package/dist/running.d.ts.map +1 -0
  233. package/dist/running.js +10 -0
  234. package/dist/runtime.d.ts +35 -0
  235. package/dist/runtime.d.ts.map +1 -0
  236. package/dist/runtime.js +1 -0
  237. package/dist/save.d.ts +42 -86
  238. package/dist/save.d.ts.map +1 -1
  239. package/dist/save.js +332 -228
  240. package/dist/saves.d.ts +34 -0
  241. package/dist/saves.d.ts.map +1 -0
  242. package/dist/saves.js +437 -0
  243. package/dist/search.d.ts +12 -63
  244. package/dist/search.d.ts.map +1 -1
  245. package/dist/search.js +9 -52
  246. package/dist/seed.d.ts +11 -2
  247. package/dist/seed.d.ts.map +1 -1
  248. package/dist/seed.js +71 -1
  249. package/dist/shared.d.ts +1 -7
  250. package/dist/shared.d.ts.map +1 -1
  251. package/dist/shared.js +13 -105
  252. package/dist/shown.d.ts +35 -0
  253. package/dist/shown.d.ts.map +1 -0
  254. package/dist/shown.js +313 -0
  255. package/dist/socket/admission.d.ts +7 -0
  256. package/dist/socket/admission.d.ts.map +1 -0
  257. package/dist/socket/admission.js +39 -0
  258. package/dist/socket/answers.d.ts +6 -0
  259. package/dist/socket/answers.d.ts.map +1 -0
  260. package/dist/socket/answers.js +20 -0
  261. package/dist/socket/lanes.d.ts +28 -0
  262. package/dist/socket/lanes.d.ts.map +1 -0
  263. package/dist/socket/lanes.js +103 -0
  264. package/dist/socket/reads.d.ts +10 -0
  265. package/dist/socket/reads.d.ts.map +1 -0
  266. package/dist/socket/reads.js +31 -0
  267. package/dist/socket/session.d.ts +38 -0
  268. package/dist/socket/session.d.ts.map +1 -0
  269. package/dist/socket/session.js +23 -0
  270. package/dist/socket.d.ts +68 -0
  271. package/dist/socket.d.ts.map +1 -0
  272. package/dist/socket.js +165 -0
  273. package/dist/source.d.ts +59 -0
  274. package/dist/source.d.ts.map +1 -0
  275. package/dist/source.js +93 -0
  276. package/dist/status.d.ts +4 -5
  277. package/dist/status.d.ts.map +1 -1
  278. package/dist/status.js +3 -7
  279. package/dist/store/installs.d.ts +30 -0
  280. package/dist/store/installs.d.ts.map +1 -0
  281. package/dist/store/installs.js +40 -0
  282. package/dist/store/readiness.d.ts +11 -0
  283. package/dist/store/readiness.d.ts.map +1 -0
  284. package/dist/store/readiness.js +68 -0
  285. package/dist/store/records.d.ts +224 -0
  286. package/dist/store/records.d.ts.map +1 -0
  287. package/dist/store/records.js +466 -0
  288. package/dist/store/room-held.d.ts +8 -0
  289. package/dist/store/room-held.d.ts.map +1 -0
  290. package/dist/store/room-held.js +17 -0
  291. package/dist/store/rooms-shown.d.ts +8 -0
  292. package/dist/store/rooms-shown.d.ts.map +1 -0
  293. package/dist/store/rooms-shown.js +13 -0
  294. package/dist/store/space.d.ts +11 -0
  295. package/dist/store/space.d.ts.map +1 -0
  296. package/dist/store/space.js +41 -0
  297. package/dist/store/watchers.d.ts +17 -0
  298. package/dist/store/watchers.d.ts.map +1 -0
  299. package/dist/store/watchers.js +56 -0
  300. package/dist/store/writes.d.ts +24 -0
  301. package/dist/store/writes.d.ts.map +1 -0
  302. package/dist/store/writes.js +125 -0
  303. package/dist/store.d.ts +124 -172
  304. package/dist/store.d.ts.map +1 -1
  305. package/dist/store.js +170 -417
  306. package/dist/stored.d.ts +75 -61
  307. package/dist/stored.d.ts.map +1 -1
  308. package/dist/stored.js +370 -244
  309. package/dist/surface.d.ts +94 -0
  310. package/dist/surface.d.ts.map +1 -0
  311. package/dist/surface.js +254 -0
  312. package/dist/sync.d.ts +20 -0
  313. package/dist/sync.d.ts.map +1 -0
  314. package/dist/sync.js +549 -0
  315. package/dist/tables.d.ts +121 -104
  316. package/dist/tables.d.ts.map +1 -1
  317. package/dist/tables.js +201 -329
  318. package/dist/tallies.d.ts +18 -0
  319. package/dist/tallies.d.ts.map +1 -0
  320. package/dist/tallies.js +128 -0
  321. package/dist/transfer.d.ts +0 -5
  322. package/dist/transfer.d.ts.map +1 -1
  323. package/dist/validation.d.ts +3 -4
  324. package/dist/validation.d.ts.map +1 -1
  325. package/dist/validation.js +42 -106
  326. package/dist/windows.d.ts +1 -12
  327. package/dist/windows.d.ts.map +1 -1
  328. package/dist/windows.js +2 -75
  329. package/dist/wire.d.ts +76 -9
  330. package/dist/wire.d.ts.map +1 -1
  331. package/dist/wire.js +27 -5
  332. package/package.json +3 -2
  333. package/dist/attempt.d.ts +0 -16
  334. package/dist/attempt.d.ts.map +0 -1
  335. package/dist/attempt.js +0 -70
  336. package/dist/fence.d.ts +0 -6
  337. package/dist/fence.d.ts.map +0 -1
  338. package/dist/fence.js +0 -10
  339. package/dist/fulltext.d.ts +0 -27
  340. package/dist/fulltext.d.ts.map +0 -1
  341. package/dist/fulltext.js +0 -368
  342. package/dist/log.d.ts +0 -5
  343. package/dist/log.d.ts.map +0 -1
  344. package/dist/log.js +0 -14
  345. package/dist/words.d.ts +0 -19
  346. package/dist/words.d.ts.map +0 -1
  347. package/dist/words.js +0 -150
@@ -1,60 +1,70 @@
1
- import { apply, equalValue, frontmatterValue, parse, serialize, } from '@agentshouse/mdmodel';
1
+ import { apply, create, documentValue, equalValue, parse, serialize, } from '@agentshouse/mdmodel';
2
+ import { definitionsAt, governing } from './collection.js';
2
3
  import { runtimeError } from './failure.js';
3
4
  import { sha256 } from './digest.js';
5
+ import { declaredType } from './outcome.js';
4
6
  import { binaryLocalId } from './identity.js';
5
7
  import { normalize } from './paths.js';
6
- export function returnedBy(kind) {
7
- return { kind, code: kind, fields: {}, retryable: false };
8
+ export function returnedBy() {
9
+ return { kind: 'withdrawn', code: 'withdrawn', fields: {}, retryable: false };
8
10
  }
9
11
  export function staleWrite(current) {
10
- return { outcome: 'stale', code: 'stale', retryable: false, current };
12
+ return { outcome: 'stale', current };
11
13
  }
12
- function malformed() {
13
- throw runtimeError('room-draft-malformed');
14
+ function malformed(at, needs) {
15
+ throw runtimeError('room-draft-malformed', at === undefined ? 'room-draft-malformed' : `room-draft-malformed at ${at}: ${needs}`);
14
16
  }
15
17
  function plain(value) {
16
18
  return typeof value === 'object' && value !== null && !Array.isArray(value);
17
19
  }
18
- function text(value) {
19
- return typeof value === 'string' ? value : malformed();
20
+ function text(value, at) {
21
+ return typeof value === 'string' ? value : malformed(at, 'text');
20
22
  }
21
- function optionalText(value) {
22
- return value === undefined ? undefined : text(value);
23
+ function optionalText(value, at) {
24
+ return value === undefined ? undefined : text(value, at);
23
25
  }
24
- function markdownBase(value) {
25
- return value === null ? null : optionalText(value);
26
+ function markdownBase(value, at) {
27
+ return value === null ? null : optionalText(value, at);
26
28
  }
27
- function entries(value, each) {
29
+ function entries(value, at, each) {
28
30
  if (!plain(value))
29
- malformed();
31
+ malformed(at, 'an object of named values');
30
32
  const read = {};
31
33
  for (const [name, item] of Object.entries(value))
32
- read[name] = each(item);
34
+ read[name] = each(item, `${at}.${name}`);
33
35
  return read;
34
36
  }
35
- function fieldValue(value) {
37
+ function documentValueAt(item, at) {
38
+ return documentValue(item) ? item : malformed(at, 'a document value');
39
+ }
40
+ function fieldValue(value, at) {
36
41
  if (value === null)
37
42
  return null;
38
- if (!plain(value) || !Object.hasOwn(value, 'value') || !frontmatterValue(value.value)) {
39
- malformed();
43
+ if (!plain(value) || !Object.hasOwn(value, 'value') || !documentValue(value.value)) {
44
+ malformed(at, '{ value } with a document value, or null where the document lacks it');
40
45
  }
41
46
  return { value: value.value };
42
47
  }
43
- function textPart(value) {
48
+ function textPart(value, at) {
44
49
  if (!plain(value))
45
- malformed();
46
- const base = optionalText(value.base);
47
- return { value: text(value.value), ...(base === undefined ? {} : { base }) };
50
+ malformed(at, '{ value, base }');
51
+ const base = optionalText(value.base, `${at}.base`);
52
+ return { value: text(value.value, `${at}.value`), ...(base === undefined ? {} : { base }) };
48
53
  }
49
- function creationOf(value) {
54
+ function creationOf(value, at) {
50
55
  if (!plain(value))
51
- malformed();
56
+ malformed(at, '{ type, fields, sections }, or { markdown }');
52
57
  if (Object.hasOwn(value, 'markdown'))
53
- return { markdown: text(value.markdown) };
54
- const fields = entries(value.fields, (item) => (frontmatterValue(item) ? item : malformed()));
55
- return { type: text(value.type), fields, sections: entries(value.sections, text) };
58
+ return { markdown: text(value.markdown, `${at}.markdown`) };
59
+ if (typeof value.type !== 'string')
60
+ malformed(`${at}.type`, 'a type name, or markdown in place of type, fields and sections');
61
+ return {
62
+ type: value.type,
63
+ fields: entries(value.fields, `${at}.fields`, documentValueAt),
64
+ sections: entries(value.sections, `${at}.sections`, text),
65
+ };
56
66
  }
57
- const PART_NAMES = new Set([
67
+ const PART_NAMES = [
58
68
  'fields',
59
69
  'sections',
60
70
  'preamble',
@@ -63,52 +73,57 @@ const PART_NAMES = new Set([
63
73
  'move',
64
74
  'removal',
65
75
  'file',
66
- ]);
67
- export function readParts(value) {
68
- if (!plain(value) || Object.keys(value).some((name) => !PART_NAMES.has(name)))
69
- malformed();
76
+ ];
77
+ const NAMED_PARTS = `a part named ${PART_NAMES.slice(0, -1).join(', ')} or ${PART_NAMES.slice(-1).join('')}`;
78
+ export function readParts(value, path) {
79
+ if (!plain(value))
80
+ malformed(path, 'an object of parts');
81
+ const unknown = Object.keys(value).find((name) => !PART_NAMES.includes(name));
82
+ if (unknown !== undefined)
83
+ malformed(`${path} ${unknown}`, NAMED_PARTS);
70
84
  const parts = {};
71
85
  if (value.fields !== undefined) {
72
- parts.fields = entries(value.fields, (item) => {
73
- if (!plain(item) || !Object.hasOwn(item, 'value') || !frontmatterValue(item.value)) {
74
- malformed();
86
+ parts.fields = entries(value.fields, `${path} fields`, (item, at) => {
87
+ if (!plain(item) || !Object.hasOwn(item, 'value') || !documentValue(item.value)) {
88
+ malformed(at, '{ value, base } with a document value');
75
89
  }
76
90
  return item.base === undefined
77
91
  ? { value: item.value }
78
- : { value: item.value, base: fieldValue(item.base) };
92
+ : { value: item.value, base: fieldValue(item.base, `${at}.base`) };
79
93
  });
80
94
  }
81
95
  if (value.sections !== undefined)
82
- parts.sections = entries(value.sections, textPart);
96
+ parts.sections = entries(value.sections, `${path} sections`, textPart);
83
97
  if (value.preamble !== undefined)
84
- parts.preamble = textPart(value.preamble);
98
+ parts.preamble = textPart(value.preamble, `${path} preamble`);
85
99
  if (value.markdown !== undefined)
86
- parts.markdown = textPart(value.markdown);
100
+ parts.markdown = textPart(value.markdown, `${path} markdown`);
87
101
  if (value.creation !== undefined)
88
- parts.creation = creationOf(value.creation);
102
+ parts.creation = creationOf(value.creation, `${path} creation`);
89
103
  if (value.move !== undefined) {
90
104
  if (!plain(value.move))
91
- malformed();
92
- const base = markdownBase(value.move.base);
93
- const room = optionalText(value.move.room);
105
+ malformed(`${path} move`, '{ to, room, base }');
106
+ const base = markdownBase(value.move.base, `${path} move.base`);
107
+ const room = optionalText(value.move.room, `${path} move.room`);
94
108
  parts.move = {
95
- to: text(value.move.to),
109
+ to: text(value.move.to, `${path} move.to`),
96
110
  ...(room === undefined ? {} : { room }),
97
111
  ...(base === undefined ? {} : { base }),
98
112
  };
99
113
  }
100
114
  if (value.removal !== undefined) {
101
115
  if (!plain(value.removal))
102
- malformed();
103
- const base = markdownBase(value.removal.base);
116
+ malformed(`${path} removal`, '{ base }');
117
+ const base = markdownBase(value.removal.base, `${path} removal.base`);
104
118
  parts.removal = base === undefined ? {} : { base };
105
119
  }
106
120
  if (value.file !== undefined) {
107
121
  if (!plain(value.file) || !(value.file.blob instanceof Blob))
108
- malformed();
122
+ malformed(`${path} file`, '{ blob, base } with a Blob');
109
123
  if (Object.keys(value).length > 1)
110
124
  throw runtimeError('room-draft-file-exclusive');
111
- parts.file = { blob: value.file.blob };
125
+ const base = markdownBase(value.file.base, `${path} file.base`);
126
+ parts.file = base === undefined ? { blob: value.file.blob } : { blob: value.file.blob, base };
112
127
  }
113
128
  return parts;
114
129
  }
@@ -242,8 +257,10 @@ export function underneath(parts, path, visible) {
242
257
  const markdown = visible?.documents[path] ?? null;
243
258
  const document = visible?.collection.document(path);
244
259
  const report = {};
260
+ const unread = document?.type !== undefined &&
261
+ governing(visible.collection.composition, path).status === 'unavailable';
245
262
  const fields = {};
246
- for (const [name, part] of named(parts.fields)) {
263
+ for (const [name, part] of unread ? [] : named(parts.fields)) {
247
264
  const current = document !== undefined && Object.hasOwn(document.fields, name)
248
265
  ? { value: document.fields[name] }
249
266
  : null;
@@ -253,7 +270,7 @@ export function underneath(parts, path, visible) {
253
270
  if (Object.keys(fields).length > 0)
254
271
  report.fields = fields;
255
272
  const sections = {};
256
- for (const [name, part] of named(parts.sections)) {
273
+ for (const [name, part] of unread ? [] : named(parts.sections)) {
257
274
  const current = document !== undefined && Object.hasOwn(document.sections, name)
258
275
  ? document.sections[name]
259
276
  : null;
@@ -263,8 +280,9 @@ export function underneath(parts, path, visible) {
263
280
  if (Object.keys(sections).length > 0)
264
281
  report.sections = sections;
265
282
  const preamble = document?.preamble ?? null;
266
- if (parts.preamble !== undefined && preamble !== parts.preamble.base)
283
+ if (!unread && parts.preamble !== undefined && preamble !== parts.preamble.base) {
267
284
  report.preamble = preamble;
285
+ }
268
286
  if (parts.markdown !== undefined && markdown !== parts.markdown.base)
269
287
  report.markdown = markdown;
270
288
  if (parts.creation !== undefined && markdown !== null)
@@ -280,32 +298,253 @@ export function underneath(parts, path, visible) {
280
298
  }
281
299
  return report;
282
300
  }
283
- const UNTYPED_MEDIA_TYPE = 'application/octet-stream';
284
301
  export async function heldFile(blob, base) {
285
302
  return {
286
303
  localId: binaryLocalId(),
287
304
  ...(blob instanceof File ? { name: blob.name } : {}),
288
305
  byteLength: blob.size,
289
- mediaType: blob.type === '' ? UNTYPED_MEDIA_TYPE : blob.type,
306
+ mediaType: declaredType(blob),
290
307
  sha256: await sha256(blob),
291
308
  base,
292
309
  };
293
310
  }
294
311
  export function binaryBase(visible, path) {
295
- return visible?.binaries[path] === undefined ? null : (visible.revisions[path] ?? null);
312
+ const binary = visible?.binaries[path];
313
+ if (binary === undefined)
314
+ return null;
315
+ return visible?.revisions[path] ?? (binary.state === 'pending' ? binary.localId : null);
296
316
  }
297
- export function changedParts(path, report) {
317
+ export function changedParts(path, parts, visible) {
318
+ const report = underneath(parts, path, visible);
319
+ const made = parts.file?.base === null;
298
320
  return [
299
- ...(report.creation === undefined ? [] : [{ path, part: 'creation' }]),
300
321
  ...named(report.fields).map(([name]) => ({ path, part: 'field', name })),
301
322
  ...named(report.sections).map(([name]) => ({ path, part: 'section', name })),
302
323
  ...(report.preamble === undefined ? [] : [{ path, part: 'preamble' }]),
303
324
  ...(report.markdown === undefined ? [] : [{ path, part: 'markdown' }]),
304
325
  ...(report.move === undefined ? [] : [{ path, part: 'move' }]),
305
326
  ...(report.removal === undefined ? [] : [{ path, part: 'removal' }]),
306
- ...(report.file === undefined ? [] : [{ path, part: 'file' }]),
327
+ ...(report.file === undefined || made ? [] : [{ path, part: 'file' }]),
307
328
  ];
308
329
  }
330
+ function marksOf(fields, sections, rest) {
331
+ return {
332
+ ...(Object.keys(fields).length === 0 ? {} : { fields }),
333
+ ...(Object.keys(sections).length === 0 ? {} : { sections }),
334
+ ...(rest.preamble === undefined ? {} : { preamble: rest.preamble }),
335
+ ...(rest.markdown === undefined ? {} : { markdown: rest.markdown }),
336
+ ...(rest.file === undefined ? {} : { file: rest.file }),
337
+ };
338
+ }
339
+ export function marksOver(kept, under) {
340
+ return marksOf({ ...under.fields, ...kept.fields }, { ...under.sections, ...kept.sections }, {
341
+ preamble: kept.preamble ?? under.preamble,
342
+ markdown: kept.markdown ?? under.markdown,
343
+ file: kept.file ?? under.file,
344
+ });
345
+ }
346
+ export function heldMarks(marks, parts) {
347
+ const whole = parts.markdown !== undefined;
348
+ const heldIn = (record, part) => Object.fromEntries(named(record).filter(([name]) => whole || own(part, name) !== undefined));
349
+ return marksOf(heldIn(marks.fields, parts.fields), heldIn(marks.sections, parts.sections), {
350
+ preamble: whole || parts.preamble !== undefined ? marks.preamble : undefined,
351
+ markdown: whole ? marks.markdown : undefined,
352
+ file: parts.file === undefined ? undefined : marks.file,
353
+ });
354
+ }
355
+ function followedBy(first, then) {
356
+ const kept = first.replace(/(?:\r?\n)+$/u, '');
357
+ return kept.trim() === '' ? then : `${kept}\n\n${then.replace(/^(?:\r?\n)+/u, '')}`;
358
+ }
359
+ function bothSides(current, value) {
360
+ return lineEnded(current) === lineEnded(value) ? value : followedBy(current, value);
361
+ }
362
+ export function partsBetween(path, before, after) {
363
+ const changes = [];
364
+ for (const name of new Set([...Object.keys(before.fields), ...Object.keys(after.fields)])) {
365
+ const value = own(after.fields, name);
366
+ if (!equalValue(own(before.fields, name), value)) {
367
+ changes.push({ kind: 'field', path, name, value });
368
+ }
369
+ }
370
+ if (after.preamble !== before.preamble) {
371
+ changes.push({ kind: 'preamble', path, value: after.preamble });
372
+ }
373
+ for (const [name, value] of Object.entries(after.sections)) {
374
+ if (own(before.sections, name) !== value)
375
+ changes.push({ kind: 'section', path, name, value });
376
+ }
377
+ return changes;
378
+ }
379
+ export function applyParts(document, changes, definition) {
380
+ const parts = new Map();
381
+ for (const change of changes) {
382
+ if (change.kind === 'field')
383
+ parts.set(`field ${change.name}`, {
384
+ kind: 'field',
385
+ name: change.name,
386
+ value: change.value,
387
+ prior: own(document.fields, change.name),
388
+ });
389
+ if (change.kind === 'preamble')
390
+ parts.set('preamble', { kind: 'preamble', value: change.value, prior: document.preamble });
391
+ if (change.kind === 'section')
392
+ parts.set(`section ${change.name}`, {
393
+ kind: 'section',
394
+ name: change.name,
395
+ value: change.value,
396
+ prior: own(document.sections, change.name),
397
+ });
398
+ }
399
+ if (parts.size === 0)
400
+ return { outcome: 'applied', document };
401
+ return apply(document, [...parts.values()], definition);
402
+ }
403
+ function wholeJoined(part, current, path, composition, change) {
404
+ const definitions = definitionsAt(composition, path);
405
+ const read = (text) => {
406
+ const parsed = parse(text, path, definitions);
407
+ return parsed.ok ? parsed.document : undefined;
408
+ };
409
+ const base = read(part.base);
410
+ const mine = read(part.value);
411
+ const now = read(current);
412
+ if (base === undefined ||
413
+ mine === undefined ||
414
+ now === undefined ||
415
+ mine.type !== base.type ||
416
+ now.type !== base.type ||
417
+ Object.keys(base.sections).some((name) => !Object.hasOwn(mine.sections, name))) {
418
+ return null;
419
+ }
420
+ const definition = definitions(base.type);
421
+ const changes = partsBetween(path, base, mine);
422
+ const again = applyParts(base, changes, definition);
423
+ if (again.outcome !== 'applied' || serialize(again.document) !== part.value)
424
+ return null;
425
+ const fields = {};
426
+ const sections = {};
427
+ let preamble;
428
+ const over = [];
429
+ for (const one of changes) {
430
+ if (one.kind === 'field') {
431
+ const held = own(now.fields, one.name);
432
+ if (!equalValue(held, own(base.fields, one.name)) && !equalValue(held, one.value)) {
433
+ fields[one.name] = { current: held === undefined ? null : { value: held }, change };
434
+ }
435
+ over.push(one);
436
+ continue;
437
+ }
438
+ if (one.kind === 'preamble') {
439
+ const value = now.preamble === base.preamble ? one.value : bothSides(now.preamble, one.value);
440
+ if (value !== one.value)
441
+ preamble = { change };
442
+ over.push({ ...one, value });
443
+ continue;
444
+ }
445
+ const prior = own(base.sections, one.name);
446
+ const held = own(now.sections, one.name);
447
+ if (held === undefined && prior !== undefined)
448
+ return null;
449
+ const value = held === undefined || held === prior ? one.value : bothSides(held, one.value);
450
+ if (value !== one.value)
451
+ sections[one.name] = { change };
452
+ over.push({ ...one, value });
453
+ }
454
+ const joined = applyParts(now, over, definition);
455
+ if (joined.outcome !== 'applied')
456
+ return null;
457
+ return {
458
+ value: serialize(joined.document),
459
+ marks: marksOf(fields, sections, { preamble }),
460
+ };
461
+ }
462
+ export function joinedOver(parts, marks, path, visible) {
463
+ const report = underneath(parts, path, visible);
464
+ const change = visible.changes[path] ?? null;
465
+ const next = { ...parts };
466
+ const fields = {};
467
+ const sections = {};
468
+ const rest = {};
469
+ let rebased = false;
470
+ const text = (value, current, mark) => {
471
+ const joined = bothSides(current, value);
472
+ if (joined !== value)
473
+ mark();
474
+ return { value: joined, base: current };
475
+ };
476
+ const now = visible.collection.document(path);
477
+ if (now !== undefined) {
478
+ for (const [name, current] of named(report.fields)) {
479
+ const { value } = parts.fields[name];
480
+ next.fields = { ...next.fields, [name]: { value, base: current } };
481
+ if (!sameField(current, { value }))
482
+ fields[name] = { current, change };
483
+ rebased = true;
484
+ }
485
+ const removed = [];
486
+ for (const [name, current] of named(report.sections)) {
487
+ if (current === null) {
488
+ removed.push(name);
489
+ continue;
490
+ }
491
+ const joined = text(parts.sections[name].value, current, () => {
492
+ sections[name] = { change };
493
+ });
494
+ next.sections = { ...next.sections, [name]: joined };
495
+ rebased = true;
496
+ }
497
+ if (typeof report.preamble === 'string') {
498
+ next.preamble = text(parts.preamble.value, report.preamble, () => {
499
+ rest.preamble = { change };
500
+ });
501
+ rebased = true;
502
+ }
503
+ const whole = removed.length === 0
504
+ ? null
505
+ : applyParts(now, changesOf(path, next).changes, definitionsAt(visible.collection.composition, path)(now.type));
506
+ if (whole?.outcome === 'applied') {
507
+ delete next.fields;
508
+ delete next.sections;
509
+ delete next.preamble;
510
+ next.markdown = { value: serialize(whole.document), base: visible.documents[path] };
511
+ for (const name of removed)
512
+ sections[name] = { change };
513
+ rebased = true;
514
+ }
515
+ }
516
+ if (typeof report.markdown === 'string' && parts.markdown !== undefined) {
517
+ const current = report.markdown;
518
+ const whole = wholeJoined(parts.markdown, current, path, visible.collection.composition, change);
519
+ const value = whole?.value ?? bothSides(current, parts.markdown.value);
520
+ next.markdown = { value, base: current };
521
+ if (whole !== null) {
522
+ Object.assign(fields, whole.marks.fields);
523
+ Object.assign(sections, whole.marks.sections);
524
+ if (whole.marks.preamble !== undefined)
525
+ rest.preamble = whole.marks.preamble;
526
+ }
527
+ else if (value !== parts.markdown.value)
528
+ rest.markdown = { change };
529
+ rebased = true;
530
+ }
531
+ if (typeof report.move === 'string' && parts.move !== undefined) {
532
+ next.move = { ...parts.move, base: report.move };
533
+ rebased = true;
534
+ }
535
+ if (typeof report.removal === 'string' && parts.removal !== undefined) {
536
+ next.removal = { base: report.removal };
537
+ rebased = true;
538
+ }
539
+ if (typeof report.file === 'string' && parts.file !== undefined && parts.file.base !== null) {
540
+ next.file = { ...parts.file, base: report.file };
541
+ if (visible.binaries[path]?.sha256 !== parts.file.sha256) {
542
+ rest.file = { current: report.file, change };
543
+ }
544
+ rebased = true;
545
+ }
546
+ return rebased ? { parts: next, marks: marksOver(marksOf(fields, sections, rest), marks) } : null;
547
+ }
309
548
  function joined(existing, returned) {
310
549
  const merged = { ...existing };
311
550
  for (const [name, part] of named(returned))
@@ -313,33 +552,45 @@ function joined(existing, returned) {
313
552
  merged[name] = part;
314
553
  return Object.keys(merged).length === 0 ? undefined : merged;
315
554
  }
316
- function ended(text) {
555
+ export function lineEnded(text) {
317
556
  return text === '' || text.endsWith('\n') ? text : `${text}\n`;
318
557
  }
319
- function frontmatterOf(fields) {
320
- const opened = parse('---\n---\n');
321
- if (!opened.ok)
322
- return malformed();
323
- const next = apply(opened.document, fields.map(([name, part]) => ({
324
- kind: 'field',
325
- name,
326
- value: part.value,
327
- prior: undefined,
328
- })));
329
- return next.outcome === 'applied' ? serialize(next.document) : malformed();
558
+ function written(start, changes, definition) {
559
+ const next = apply(start, changes, definition);
560
+ return next.outcome === 'applied' ? next.document : malformed();
330
561
  }
331
- export function partsAfter(markdown, parts) {
562
+ function empty(definition) {
563
+ const parsed = parse('', '', definition);
564
+ return parsed.ok ? parsed.document : malformed();
565
+ }
566
+ export function partsAfter(markdown, parts, definitions) {
332
567
  const fields = named(parts.fields);
568
+ const sections = named(parts.sections);
569
+ if (fields.length === 0 && sections.length === 0 && parts.preamble === undefined)
570
+ return markdown;
571
+ const whole = parse(markdown, '', definitions);
572
+ const type = whole.ok ? whole.document.type : undefined;
573
+ const definition = definitions?.(type);
574
+ if (type !== undefined && definition === undefined)
575
+ return null;
576
+ const valued = fields.length === 0
577
+ ? empty(definition)
578
+ : written(create(type, definition), fields.map(([name, part]) => ({
579
+ kind: 'field',
580
+ name,
581
+ value: part.value,
582
+ prior: undefined,
583
+ })), definition);
584
+ const head = parts.preamble === undefined
585
+ ? valued
586
+ : written(valued, [{ kind: 'preamble', value: lineEnded(parts.preamble.value), prior: valued.preamble }], definition);
333
587
  const pieces = [
334
- ...(fields.length === 0 ? [] : [frontmatterOf(fields)]),
335
- ...(parts.preamble === undefined ? [] : [parts.preamble.value]),
336
- ...named(parts.sections).map(([name, part]) => `## ${name}\n${part.value}`),
588
+ ...(fields.length === 0 && parts.preamble === undefined ? [] : [serialize(head)]),
589
+ ...sections.map(([name, part]) => serialize(written(empty(definition), [{ kind: 'section', name, value: lineEnded(part.value), prior: undefined }], definition))),
337
590
  ];
338
- if (pieces.length === 0)
339
- return markdown;
340
- return `${ended(markdown)}\n${pieces.map(ended).join('')}`;
591
+ return followedBy(markdown, pieces.join(''));
341
592
  }
342
- export function returnedInto(existing, returned) {
593
+ export function returnedInto(existing, returned, definitions) {
343
594
  if (existing === undefined)
344
595
  return returned;
345
596
  const next = { ...existing };
@@ -359,7 +610,9 @@ export function returnedInto(existing, returned) {
359
610
  delete next.fields;
360
611
  delete next.sections;
361
612
  delete next.preamble;
362
- const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned);
613
+ const value = partsAfter(whole.value, existing.markdown === undefined ? existing : returned, definitions);
614
+ if (value === null)
615
+ return null;
363
616
  next.markdown = { value, base: whole.base };
364
617
  }
365
618
  const creation = existing.creation ?? returned.creation;
@@ -380,6 +633,36 @@ export function moveTarget(move) {
380
633
  const to = normalize(move.to);
381
634
  return to === null || to === '' ? move.to : to;
382
635
  }
636
+ export function readSavedParts(named) {
637
+ const read = named.map(({ path, parts }) => ({ path, parts: readParts(parts, path) }));
638
+ read.forEach(({ path }, at) => {
639
+ if (path === '' || normalize(path) !== path)
640
+ malformed(path, 'a path inside the Room, such as notes/a.md');
641
+ if (read.findIndex((one) => one.path === path) !== at)
642
+ malformed(path, 'each path once in one save');
643
+ });
644
+ return read;
645
+ }
646
+ export function partsChanges(named) {
647
+ const changes = [];
648
+ const preconditions = [];
649
+ for (const { path, parts } of readSavedParts(named)) {
650
+ const parted = held(undefined, parts);
651
+ const made = changesOf(path, parted);
652
+ changes.push(...made.changes);
653
+ preconditions.push(...made.bases);
654
+ for (const change of made.changes) {
655
+ if (change.kind === 'create')
656
+ preconditions.push({ kind: 'absent', path });
657
+ if (change.kind === 'move')
658
+ preconditions.push({ kind: 'absent', path: change.to });
659
+ }
660
+ const revision = parted.markdown?.base ?? parted.move?.base ?? parted.removal?.base;
661
+ if (typeof revision === 'string')
662
+ preconditions.push({ kind: 'revision', path, revision });
663
+ }
664
+ return { changes, preconditions };
665
+ }
383
666
  export function changesOf(path, parts) {
384
667
  const changes = [];
385
668
  const bases = [];
@@ -399,11 +682,11 @@ export function changesOf(path, parts) {
399
682
  bases.push({ kind: 'field', path, name, value: part.base?.value });
400
683
  }
401
684
  for (const [name, part] of named(parts.sections)) {
402
- changes.push({ kind: 'section', path, name, value: part.value });
685
+ changes.push({ kind: 'section', path, name, value: lineEnded(part.value) });
403
686
  bases.push({ kind: 'section', path, name, value: part.base });
404
687
  }
405
688
  if (parts.preamble !== undefined) {
406
- changes.push({ kind: 'preamble', path, value: parts.preamble.value });
689
+ changes.push({ kind: 'preamble', path, value: lineEnded(parts.preamble.value) });
407
690
  bases.push({ kind: 'preamble', path, value: parts.preamble.base });
408
691
  }
409
692
  if (parts.markdown !== undefined) {
@@ -415,7 +698,7 @@ export function changesOf(path, parts) {
415
698
  if (base !== null && at !== path)
416
699
  changes.push({ kind: 'move', path, to: at });
417
700
  changes.push({ kind: 'binary', path: at, ...file });
418
- if (base === null && at !== path)
701
+ if (base === null)
419
702
  bases.push({ kind: 'absent', path: at });
420
703
  return { changes, bases };
421
704
  }
@@ -427,35 +710,6 @@ export function changesOf(path, parts) {
427
710
  changes.push({ kind: 'remove', path });
428
711
  return { changes, bases };
429
712
  }
430
- function rebased(before, after) {
431
- return before === undefined ? after : { ...after, base: before.base };
432
- }
433
- function rebasedAll(before, after) {
434
- return {
435
- ...before,
436
- ...Object.fromEntries(Object.entries(after).map(([name, part]) => [name, rebased(before?.[name], part)])),
437
- };
438
- }
439
- export function joinedDraft(carried, saved) {
440
- const draft = saved.find((item) => item.path === carried.path);
441
- if (draft === undefined)
442
- return carried;
443
- const held = carried.parts;
444
- const next = draft.parts;
445
- return {
446
- path: carried.path,
447
- parts: {
448
- ...held,
449
- ...next,
450
- ...(next.fields === undefined ? {} : { fields: rebasedAll(held.fields, next.fields) }),
451
- ...(next.sections === undefined
452
- ? {}
453
- : { sections: rebasedAll(held.sections, next.sections) }),
454
- ...(next.preamble === undefined ? {} : { preamble: rebased(held.preamble, next.preamble) }),
455
- ...(next.markdown === undefined ? {} : { markdown: rebased(held.markdown, next.markdown) }),
456
- },
457
- };
458
- }
459
713
  export function withdrawnDrafts(drafts, changes) {
460
714
  return drafts.flatMap((draft) => {
461
715
  const file = draft.parts.file;
@@ -0,0 +1,24 @@
1
+ import { type ChangeSet } from './change-set.js';
2
+ import { type VisibleLayer } from './replica.js';
3
+ import { type RoomDraft, type RoomDraftWrite } from './room-draft.js';
4
+ import type { Runtime } from './runtime.js';
5
+ import type { Store } from './store.js';
6
+ export type RoomDraftSurface = {
7
+ list(): Promise<readonly RoomDraft[]>;
8
+ read(room: string, path: string): Promise<RoomDraft | null>;
9
+ write(room: string, path: string, revision: string | null, parts: unknown, next?: string): Promise<RoomDraftWrite>;
10
+ discard(room: string, path: string, revision: string): Promise<RoomDraftWrite>;
11
+ };
12
+ export type PresentationSurface = {
13
+ read(app: string): Promise<unknown>;
14
+ write(app: string, value: unknown): Promise<void>;
15
+ edit(app: string, members: Readonly<Record<string, unknown>>): Promise<void>;
16
+ };
17
+ export declare function visibleOf(store: Store, locator: string, paths: readonly string[]): Promise<VisibleLayer | undefined>;
18
+ export declare function publishRoomDrafts({ store, socket }: Runtime, waitingOnly: boolean, touched?: ChangeSet['documents'] | null): Promise<void>;
19
+ export declare function emitPresentation({ store, socket }: Runtime, app: string): Promise<void>;
20
+ export declare function roomDraftSurface(runtime: Runtime): RoomDraftSurface;
21
+ export declare function presentationSurface(runtime: Runtime): PresentationSurface;
22
+ export declare function watchRoomDrafts({ store, socket }: Runtime, deliver: (value: unknown) => void): () => void;
23
+ export declare function watchPresentation({ store, socket }: Runtime, app: string, deliver: (value: unknown) => void): () => void;
24
+ //# sourceMappingURL=room-drafts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"room-drafts.d.ts","sourceRoot":"","sources":["../src/room-drafts.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAK5D,OAAO,EAAW,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EASL,KAAK,SAAS,EAEd,KAAK,cAAc,EACpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,IAAI,OAAO,CAAC,SAAS,SAAS,EAAE,CAAC,CAAC;IACtC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAC5D,KAAK,CACH,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,EACvB,KAAK,EAAE,OAAO,EACd,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,cAAc,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAChF,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACpC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAClD,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9E,CAAC;AAMF,wBAAsB,SAAS,CAC7B,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAMnC;AA2CD,wBAAgB,iBAAiB,CAC/B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,WAAW,EAAE,OAAO,EACpB,OAAO,GAAE,SAAS,CAAC,WAAW,CAAC,GAAG,IAAW,GAC5C,OAAO,CAAC,IAAI,CAAC,CAuBf;AAOD,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAUvF;AAsDD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CAkDnE;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,mBAAmB,CA8BzE;AAED,wBAAgB,eAAe,CAC7B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAChC,MAAM,IAAI,CAiBZ;AAED,wBAAgB,iBAAiB,CAC/B,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,OAAO,EAC1B,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAChC,MAAM,IAAI,CASZ"}