@graphty/graph-io 0.0.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (339) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +250 -28
  3. package/dist/chunks/children-CL3Cy0ez.js +238 -0
  4. package/dist/chunks/children-CL3Cy0ez.js.map +1 -0
  5. package/dist/chunks/escape-DyI8JofU.js +938 -0
  6. package/dist/chunks/escape-DyI8JofU.js.map +1 -0
  7. package/dist/chunks/importer-CQnJuWJw.js +2987 -0
  8. package/dist/chunks/importer-CQnJuWJw.js.map +1 -0
  9. package/dist/chunks/importer-CpCpfbxr.js +2015 -0
  10. package/dist/chunks/importer-CpCpfbxr.js.map +1 -0
  11. package/dist/chunks/importer-DbnGYr3_.js +2342 -0
  12. package/dist/chunks/importer-DbnGYr3_.js.map +1 -0
  13. package/dist/chunks/importer-GozH8DkN.js +3050 -0
  14. package/dist/chunks/importer-GozH8DkN.js.map +1 -0
  15. package/dist/chunks/records-CGpxszm1.js +605 -0
  16. package/dist/chunks/records-CGpxszm1.js.map +1 -0
  17. package/dist/chunks/text-CajMdVFy.js +189 -0
  18. package/dist/chunks/text-CajMdVFy.js.map +1 -0
  19. package/dist/chunks/writer-DxSKC7TL.js +2842 -0
  20. package/dist/chunks/writer-DxSKC7TL.js.map +1 -0
  21. package/dist/csv.d.ts +1 -0
  22. package/dist/csv.js +1702 -0
  23. package/dist/csv.js.map +1 -0
  24. package/dist/dot.d.ts +1 -0
  25. package/dist/dot.js +8 -0
  26. package/dist/dot.js.map +1 -0
  27. package/dist/gexf.d.ts +1 -0
  28. package/dist/gexf.js +3466 -0
  29. package/dist/gexf.js.map +1 -0
  30. package/dist/gml.d.ts +1 -0
  31. package/dist/gml.js +2647 -0
  32. package/dist/gml.js.map +1 -0
  33. package/dist/graph-io.d.ts +1 -0
  34. package/dist/graph-io.js +790 -0
  35. package/dist/graph-io.js.map +1 -0
  36. package/dist/graphml.d.ts +1 -0
  37. package/dist/graphml.js +8 -0
  38. package/dist/graphml.js.map +1 -0
  39. package/dist/json.d.ts +1 -0
  40. package/dist/json.js +11 -0
  41. package/dist/json.js.map +1 -0
  42. package/dist/neo4j.d.ts +1 -0
  43. package/dist/neo4j.js +2046 -0
  44. package/dist/neo4j.js.map +1 -0
  45. package/dist/pajek.d.ts +1 -0
  46. package/dist/pajek.js +8 -0
  47. package/dist/pajek.js.map +1 -0
  48. package/dist/src/children.d.ts +134 -0
  49. package/dist/src/children.d.ts.map +1 -0
  50. package/dist/src/children.js +274 -0
  51. package/dist/src/children.js.map +1 -0
  52. package/dist/src/common/attributes.d.ts +229 -0
  53. package/dist/src/common/attributes.d.ts.map +1 -0
  54. package/dist/src/common/attributes.js +368 -0
  55. package/dist/src/common/attributes.js.map +1 -0
  56. package/dist/src/common/codes.d.ts +105 -0
  57. package/dist/src/common/codes.d.ts.map +1 -0
  58. package/dist/src/common/codes.js +107 -0
  59. package/dist/src/common/codes.js.map +1 -0
  60. package/dist/src/common/declared-types.d.ts +84 -0
  61. package/dist/src/common/declared-types.d.ts.map +1 -0
  62. package/dist/src/common/declared-types.js +326 -0
  63. package/dist/src/common/declared-types.js.map +1 -0
  64. package/dist/src/common/direction.d.ts +206 -0
  65. package/dist/src/common/direction.d.ts.map +1 -0
  66. package/dist/src/common/direction.js +370 -0
  67. package/dist/src/common/direction.js.map +1 -0
  68. package/dist/src/common/escape.d.ts +92 -0
  69. package/dist/src/common/escape.d.ts.map +1 -0
  70. package/dist/src/common/escape.js +212 -0
  71. package/dist/src/common/escape.js.map +1 -0
  72. package/dist/src/common/export.d.ts +249 -0
  73. package/dist/src/common/export.d.ts.map +1 -0
  74. package/dist/src/common/export.js +594 -0
  75. package/dist/src/common/export.js.map +1 -0
  76. package/dist/src/common/format.d.ts +59 -0
  77. package/dist/src/common/format.d.ts.map +1 -0
  78. package/dist/src/common/format.js +106 -0
  79. package/dist/src/common/format.js.map +1 -0
  80. package/dist/src/common/ids.d.ts +83 -0
  81. package/dist/src/common/ids.d.ts.map +1 -0
  82. package/dist/src/common/ids.js +158 -0
  83. package/dist/src/common/ids.js.map +1 -0
  84. package/dist/src/common/input.d.ts +100 -0
  85. package/dist/src/common/input.d.ts.map +1 -0
  86. package/dist/src/common/input.js +335 -0
  87. package/dist/src/common/input.js.map +1 -0
  88. package/dist/src/common/lists.d.ts +34 -0
  89. package/dist/src/common/lists.d.ts.map +1 -0
  90. package/dist/src/common/lists.js +185 -0
  91. package/dist/src/common/lists.js.map +1 -0
  92. package/dist/src/common/options.d.ts +108 -0
  93. package/dist/src/common/options.d.ts.map +1 -0
  94. package/dist/src/common/options.js +265 -0
  95. package/dist/src/common/options.js.map +1 -0
  96. package/dist/src/common/report.d.ts +187 -0
  97. package/dist/src/common/report.d.ts.map +1 -0
  98. package/dist/src/common/report.js +274 -0
  99. package/dist/src/common/report.js.map +1 -0
  100. package/dist/src/common/temporal.d.ts +71 -0
  101. package/dist/src/common/temporal.d.ts.map +1 -0
  102. package/dist/src/common/temporal.js +266 -0
  103. package/dist/src/common/temporal.js.map +1 -0
  104. package/dist/src/common/text.d.ts +104 -0
  105. package/dist/src/common/text.d.ts.map +1 -0
  106. package/dist/src/common/text.js +255 -0
  107. package/dist/src/common/text.js.map +1 -0
  108. package/dist/src/common/weights.d.ts +77 -0
  109. package/dist/src/common/weights.d.ts.map +1 -0
  110. package/dist/src/common/weights.js +156 -0
  111. package/dist/src/common/weights.js.map +1 -0
  112. package/dist/src/common/writer.d.ts +51 -0
  113. package/dist/src/common/writer.d.ts.map +1 -0
  114. package/dist/src/common/writer.js +108 -0
  115. package/dist/src/common/writer.js.map +1 -0
  116. package/dist/src/common/xml.d.ts +245 -0
  117. package/dist/src/common/xml.d.ts.map +1 -0
  118. package/dist/src/common/xml.js +942 -0
  119. package/dist/src/common/xml.js.map +1 -0
  120. package/dist/src/formats/csv/exporter.d.ts +70 -0
  121. package/dist/src/formats/csv/exporter.d.ts.map +1 -0
  122. package/dist/src/formats/csv/exporter.js +682 -0
  123. package/dist/src/formats/csv/exporter.js.map +1 -0
  124. package/dist/src/formats/csv/header.d.ts +66 -0
  125. package/dist/src/formats/csv/header.d.ts.map +1 -0
  126. package/dist/src/formats/csv/header.js +152 -0
  127. package/dist/src/formats/csv/header.js.map +1 -0
  128. package/dist/src/formats/csv/importer.d.ts +82 -0
  129. package/dist/src/formats/csv/importer.d.ts.map +1 -0
  130. package/dist/src/formats/csv/importer.js +849 -0
  131. package/dist/src/formats/csv/importer.js.map +1 -0
  132. package/dist/src/formats/csv/index.d.ts +60 -0
  133. package/dist/src/formats/csv/index.d.ts.map +1 -0
  134. package/dist/src/formats/csv/index.js +63 -0
  135. package/dist/src/formats/csv/index.js.map +1 -0
  136. package/dist/src/formats/csv/records.d.ts +188 -0
  137. package/dist/src/formats/csv/records.d.ts.map +1 -0
  138. package/dist/src/formats/csv/records.js +702 -0
  139. package/dist/src/formats/csv/records.js.map +1 -0
  140. package/dist/src/formats/csv/values.d.ts +105 -0
  141. package/dist/src/formats/csv/values.d.ts.map +1 -0
  142. package/dist/src/formats/csv/values.js +192 -0
  143. package/dist/src/formats/csv/values.js.map +1 -0
  144. package/dist/src/formats/dot/exporter.d.ts +52 -0
  145. package/dist/src/formats/dot/exporter.d.ts.map +1 -0
  146. package/dist/src/formats/dot/exporter.js +836 -0
  147. package/dist/src/formats/dot/exporter.js.map +1 -0
  148. package/dist/src/formats/dot/importer.d.ts +102 -0
  149. package/dist/src/formats/dot/importer.d.ts.map +1 -0
  150. package/dist/src/formats/dot/importer.js +1291 -0
  151. package/dist/src/formats/dot/importer.js.map +1 -0
  152. package/dist/src/formats/dot/index.d.ts +7 -0
  153. package/dist/src/formats/dot/index.d.ts.map +1 -0
  154. package/dist/src/formats/dot/index.js +7 -0
  155. package/dist/src/formats/dot/index.js.map +1 -0
  156. package/dist/src/formats/dot/names.d.ts +29 -0
  157. package/dist/src/formats/dot/names.d.ts.map +1 -0
  158. package/dist/src/formats/dot/names.js +28 -0
  159. package/dist/src/formats/dot/names.js.map +1 -0
  160. package/dist/src/formats/dot/tokenizer.d.ts +114 -0
  161. package/dist/src/formats/dot/tokenizer.d.ts.map +1 -0
  162. package/dist/src/formats/dot/tokenizer.js +341 -0
  163. package/dist/src/formats/dot/tokenizer.js.map +1 -0
  164. package/dist/src/formats/gexf/exporter.d.ts +56 -0
  165. package/dist/src/formats/gexf/exporter.d.ts.map +1 -0
  166. package/dist/src/formats/gexf/exporter.js +1395 -0
  167. package/dist/src/formats/gexf/exporter.js.map +1 -0
  168. package/dist/src/formats/gexf/importer.d.ts +73 -0
  169. package/dist/src/formats/gexf/importer.d.ts.map +1 -0
  170. package/dist/src/formats/gexf/importer.js +1880 -0
  171. package/dist/src/formats/gexf/importer.js.map +1 -0
  172. package/dist/src/formats/gexf/index.d.ts +96 -0
  173. package/dist/src/formats/gexf/index.d.ts.map +1 -0
  174. package/dist/src/formats/gexf/index.js +97 -0
  175. package/dist/src/formats/gexf/index.js.map +1 -0
  176. package/dist/src/formats/gexf/schema.d.ts +135 -0
  177. package/dist/src/formats/gexf/schema.d.ts.map +1 -0
  178. package/dist/src/formats/gexf/schema.js +323 -0
  179. package/dist/src/formats/gexf/schema.js.map +1 -0
  180. package/dist/src/formats/gml/exporter.d.ts +69 -0
  181. package/dist/src/formats/gml/exporter.d.ts.map +1 -0
  182. package/dist/src/formats/gml/exporter.js +1093 -0
  183. package/dist/src/formats/gml/exporter.js.map +1 -0
  184. package/dist/src/formats/gml/importer.d.ts +66 -0
  185. package/dist/src/formats/gml/importer.d.ts.map +1 -0
  186. package/dist/src/formats/gml/importer.js +1331 -0
  187. package/dist/src/formats/gml/importer.js.map +1 -0
  188. package/dist/src/formats/gml/index.d.ts +85 -0
  189. package/dist/src/formats/gml/index.d.ts.map +1 -0
  190. package/dist/src/formats/gml/index.js +88 -0
  191. package/dist/src/formats/gml/index.js.map +1 -0
  192. package/dist/src/formats/gml/syntax.d.ts +186 -0
  193. package/dist/src/formats/gml/syntax.d.ts.map +1 -0
  194. package/dist/src/formats/gml/syntax.js +467 -0
  195. package/dist/src/formats/gml/syntax.js.map +1 -0
  196. package/dist/src/formats/graphml/constants.d.ts +169 -0
  197. package/dist/src/formats/graphml/constants.d.ts.map +1 -0
  198. package/dist/src/formats/graphml/constants.js +165 -0
  199. package/dist/src/formats/graphml/constants.js.map +1 -0
  200. package/dist/src/formats/graphml/exporter.d.ts +34 -0
  201. package/dist/src/formats/graphml/exporter.d.ts.map +1 -0
  202. package/dist/src/formats/graphml/exporter.js +1176 -0
  203. package/dist/src/formats/graphml/exporter.js.map +1 -0
  204. package/dist/src/formats/graphml/importer.d.ts +31 -0
  205. package/dist/src/formats/graphml/importer.d.ts.map +1 -0
  206. package/dist/src/formats/graphml/importer.js +1607 -0
  207. package/dist/src/formats/graphml/importer.js.map +1 -0
  208. package/dist/src/formats/graphml/index.d.ts +8 -0
  209. package/dist/src/formats/graphml/index.d.ts.map +1 -0
  210. package/dist/src/formats/graphml/index.js +8 -0
  211. package/dist/src/formats/graphml/index.js.map +1 -0
  212. package/dist/src/formats/graphml/tree.d.ts +72 -0
  213. package/dist/src/formats/graphml/tree.d.ts.map +1 -0
  214. package/dist/src/formats/graphml/tree.js +290 -0
  215. package/dist/src/formats/graphml/tree.js.map +1 -0
  216. package/dist/src/formats/json/dialect.d.ts +125 -0
  217. package/dist/src/formats/json/dialect.d.ts.map +1 -0
  218. package/dist/src/formats/json/dialect.js +262 -0
  219. package/dist/src/formats/json/dialect.js.map +1 -0
  220. package/dist/src/formats/json/exporter.d.ts +89 -0
  221. package/dist/src/formats/json/exporter.d.ts.map +1 -0
  222. package/dist/src/formats/json/exporter.js +1358 -0
  223. package/dist/src/formats/json/exporter.js.map +1 -0
  224. package/dist/src/formats/json/importer.d.ts +108 -0
  225. package/dist/src/formats/json/importer.d.ts.map +1 -0
  226. package/dist/src/formats/json/importer.js +1838 -0
  227. package/dist/src/formats/json/importer.js.map +1 -0
  228. package/dist/src/formats/json/index.d.ts +8 -0
  229. package/dist/src/formats/json/index.d.ts.map +1 -0
  230. package/dist/src/formats/json/index.js +8 -0
  231. package/dist/src/formats/json/index.js.map +1 -0
  232. package/dist/src/formats/neo4j/exporter.d.ts +68 -0
  233. package/dist/src/formats/neo4j/exporter.d.ts.map +1 -0
  234. package/dist/src/formats/neo4j/exporter.js +1055 -0
  235. package/dist/src/formats/neo4j/exporter.js.map +1 -0
  236. package/dist/src/formats/neo4j/header.d.ts +52 -0
  237. package/dist/src/formats/neo4j/header.d.ts.map +1 -0
  238. package/dist/src/formats/neo4j/header.js +131 -0
  239. package/dist/src/formats/neo4j/header.js.map +1 -0
  240. package/dist/src/formats/neo4j/importer.d.ts +73 -0
  241. package/dist/src/formats/neo4j/importer.d.ts.map +1 -0
  242. package/dist/src/formats/neo4j/importer.js +932 -0
  243. package/dist/src/formats/neo4j/importer.js.map +1 -0
  244. package/dist/src/formats/neo4j/index.d.ts +79 -0
  245. package/dist/src/formats/neo4j/index.d.ts.map +1 -0
  246. package/dist/src/formats/neo4j/index.js +83 -0
  247. package/dist/src/formats/neo4j/index.js.map +1 -0
  248. package/dist/src/formats/pajek/exporter.d.ts +58 -0
  249. package/dist/src/formats/pajek/exporter.d.ts.map +1 -0
  250. package/dist/src/formats/pajek/exporter.js +825 -0
  251. package/dist/src/formats/pajek/exporter.js.map +1 -0
  252. package/dist/src/formats/pajek/importer.d.ts +88 -0
  253. package/dist/src/formats/pajek/importer.d.ts.map +1 -0
  254. package/dist/src/formats/pajek/importer.js +1047 -0
  255. package/dist/src/formats/pajek/importer.js.map +1 -0
  256. package/dist/src/formats/pajek/index.d.ts +7 -0
  257. package/dist/src/formats/pajek/index.d.ts.map +1 -0
  258. package/dist/src/formats/pajek/index.js +7 -0
  259. package/dist/src/formats/pajek/index.js.map +1 -0
  260. package/dist/src/formats/pajek/syntax.d.ts +112 -0
  261. package/dist/src/formats/pajek/syntax.d.ts.map +1 -0
  262. package/dist/src/formats/pajek/syntax.js +269 -0
  263. package/dist/src/formats/pajek/syntax.js.map +1 -0
  264. package/dist/src/index.d.ts +35 -0
  265. package/dist/src/index.d.ts.map +1 -0
  266. package/dist/src/index.js +39 -0
  267. package/dist/src/index.js.map +1 -0
  268. package/dist/src/registry.d.ts +207 -0
  269. package/dist/src/registry.d.ts.map +1 -0
  270. package/dist/src/registry.js +481 -0
  271. package/dist/src/registry.js.map +1 -0
  272. package/dist/src/sniff.d.ts +104 -0
  273. package/dist/src/sniff.d.ts.map +1 -0
  274. package/dist/src/sniff.js +357 -0
  275. package/dist/src/sniff.js.map +1 -0
  276. package/dist/src/types.d.ts +238 -0
  277. package/dist/src/types.d.ts.map +1 -0
  278. package/dist/src/types.js +29 -0
  279. package/dist/src/types.js.map +1 -0
  280. package/dist/tsconfig.build.tsbuildinfo +1 -0
  281. package/package.json +122 -7
  282. package/src/children.ts +335 -0
  283. package/src/common/attributes.ts +520 -0
  284. package/src/common/codes.ts +153 -0
  285. package/src/common/declared-types.ts +374 -0
  286. package/src/common/direction.ts +518 -0
  287. package/src/common/escape.ts +231 -0
  288. package/src/common/export.ts +817 -0
  289. package/src/common/format.ts +111 -0
  290. package/src/common/ids.ts +176 -0
  291. package/src/common/input.ts +378 -0
  292. package/src/common/lists.ts +196 -0
  293. package/src/common/options.ts +377 -0
  294. package/src/common/report.ts +352 -0
  295. package/src/common/temporal.ts +302 -0
  296. package/src/common/text.ts +294 -0
  297. package/src/common/weights.ts +202 -0
  298. package/src/common/writer.ts +123 -0
  299. package/src/common/xml.ts +1053 -0
  300. package/src/formats/csv/exporter.ts +894 -0
  301. package/src/formats/csv/header.ts +172 -0
  302. package/src/formats/csv/importer.ts +1104 -0
  303. package/src/formats/csv/index.ts +88 -0
  304. package/src/formats/csv/records.ts +813 -0
  305. package/src/formats/csv/values.ts +224 -0
  306. package/src/formats/dot/exporter.ts +1014 -0
  307. package/src/formats/dot/importer.ts +1549 -0
  308. package/src/formats/dot/index.ts +7 -0
  309. package/src/formats/dot/names.ts +40 -0
  310. package/src/formats/dot/tokenizer.ts +384 -0
  311. package/src/formats/gexf/exporter.ts +1696 -0
  312. package/src/formats/gexf/importer.ts +2333 -0
  313. package/src/formats/gexf/index.ts +142 -0
  314. package/src/formats/gexf/schema.ts +361 -0
  315. package/src/formats/gml/exporter.ts +1404 -0
  316. package/src/formats/gml/importer.ts +1591 -0
  317. package/src/formats/gml/index.ts +128 -0
  318. package/src/formats/gml/syntax.ts +545 -0
  319. package/src/formats/graphml/constants.ts +225 -0
  320. package/src/formats/graphml/exporter.ts +1458 -0
  321. package/src/formats/graphml/importer.ts +2027 -0
  322. package/src/formats/graphml/index.ts +8 -0
  323. package/src/formats/graphml/tree.ts +318 -0
  324. package/src/formats/json/dialect.ts +317 -0
  325. package/src/formats/json/exporter.ts +1616 -0
  326. package/src/formats/json/importer.ts +2271 -0
  327. package/src/formats/json/index.ts +8 -0
  328. package/src/formats/neo4j/exporter.ts +1287 -0
  329. package/src/formats/neo4j/header.ts +156 -0
  330. package/src/formats/neo4j/importer.ts +1220 -0
  331. package/src/formats/neo4j/index.ts +116 -0
  332. package/src/formats/pajek/exporter.ts +1000 -0
  333. package/src/formats/pajek/importer.ts +1311 -0
  334. package/src/formats/pajek/index.ts +7 -0
  335. package/src/formats/pajek/syntax.ts +307 -0
  336. package/src/index.ts +244 -0
  337. package/src/registry.ts +617 -0
  338. package/src/sniff.ts +397 -0
  339. package/src/types.ts +262 -0
@@ -0,0 +1,335 @@
1
+ /**
2
+ * Input handling shared by every importer (design section 8.4): the ImportInput union (whole
3
+ * text, whole bytes, a byte stream, an async iterable of text or byte chunks) read as a sequence of
4
+ * UTF-8 text chunks, as lines, or as one string, with BOM handling, cancellation through an
5
+ * AbortSignal and byte progress.
6
+ *
7
+ * Bytes are decoded with `new TextDecoder("utf-8", { fatal: true })` in streaming mode, so a
8
+ * multi-byte character split across two chunks decodes correctly and an invalid sequence is a
9
+ * parse-error (issue code E_INVALID_UTF8) that aborts the import, never a silent U+FFFD that could
10
+ * alias two ids. A leading U+FEFF is stripped from text and from decoded bytes alike.
11
+ */
12
+ import { GraphFormatError } from "@graphty/graph-format";
13
+ import { INVALID_UTF8_CODE } from "./codes.js";
14
+ export { INVALID_UTF8_CODE };
15
+ /**
16
+ * Bytes decoded per call when the input is one in-memory Uint8Array: every consumer of textChunks()
17
+ * then sees bounded chunks whatever the input shape (a line reader or a record reader that holds
18
+ * one parse result per chunk never holds more than this much text at once), and progress stays
19
+ * granular.
20
+ */
21
+ const DECODE_SLICE = 256 * 1024;
22
+ const BOM = String.fromCharCode(0xfeff);
23
+ /**
24
+ * Whether a value is an ImportInput this module can read.
25
+ * @param input - any value
26
+ * @returns true for a string, a Uint8Array, a ReadableStream or an async iterable
27
+ */
28
+ export function isImportInput(input) {
29
+ if (typeof input === "string" || input instanceof Uint8Array) {
30
+ return true;
31
+ }
32
+ if (typeof input !== "object" || input === null) {
33
+ return false;
34
+ }
35
+ return typeof input.getReader === "function" || Symbol.asyncIterator in input;
36
+ }
37
+ /**
38
+ * The total size of an in-memory input (bytes for a Uint8Array, UTF-16 code units for a string),
39
+ * for the `bytesTotal` argument of onProgress; null for a stream or an iterable.
40
+ * @param input - the input
41
+ * @returns the size, or null when unknown up front
42
+ */
43
+ export function inputLength(input) {
44
+ if (typeof input === "string") {
45
+ return input.length;
46
+ }
47
+ if (input instanceof Uint8Array) {
48
+ return input.byteLength;
49
+ }
50
+ return null;
51
+ }
52
+ /**
53
+ * Throw the signal's reason when it is aborted, exactly as the platform's
54
+ * `AbortSignal.throwIfAborted()` does: the reason as it is (the DOMException named "AbortError"
55
+ * of a reason-less abort, or whatever the caller passed to `abort(reason)`, an Error or not), so a
56
+ * caller can compare the rejection with `signal.reason`. Only a runtime that stores no reason at
57
+ * all gets a synthesised AbortError.
58
+ * @param signal - the signal, or null
59
+ */
60
+ export function throwIfAborted(signal) {
61
+ if (signal === null || signal === undefined || !signal.aborted) {
62
+ return;
63
+ }
64
+ const { reason } = signal;
65
+ if (reason === undefined) {
66
+ throw abortError();
67
+ }
68
+ // the platform contract: the reason itself, whatever its type
69
+ throw reason;
70
+ }
71
+ /**
72
+ * An abort error for a signal that carries no reason.
73
+ * @returns a DOMException named "AbortError" where DOMException exists, else an Error with that name
74
+ */
75
+ function abortError() {
76
+ const message = "The import was aborted";
77
+ if (typeof DOMException === "function") {
78
+ return new DOMException(message, "AbortError");
79
+ }
80
+ const err = new Error(message);
81
+ err.name = "AbortError";
82
+ return err;
83
+ }
84
+ /**
85
+ * Read an ImportInput as a sequence of decoded text chunks. Chunk boundaries carry no meaning:
86
+ * a caller that needs lines uses LineReader, one that needs the whole document uses readText().
87
+ * The signal is checked before every chunk; a stream is cancelled when the consumer stops early
88
+ * or the signal fires. Progress is reported after every chunk.
89
+ * @param input - the input
90
+ * @param report - the report the decode error is recorded in (E_INVALID_UTF8, then ImportError)
91
+ * @param options - cancellation and progress
92
+ * @yields decoded text; the first chunk has any leading BOM removed
93
+ * @returns nothing
94
+ */
95
+ export async function* textChunks(input, report, options = {}) {
96
+ const signal = options.signal ?? null;
97
+ const onProgress = options.onProgress ?? null;
98
+ const total = inputLength(input);
99
+ let done = 0;
100
+ let first = true;
101
+ const emit = (text) => {
102
+ if (first && text.length > 0) {
103
+ first = false;
104
+ return text.startsWith(BOM) ? text.slice(1) : text;
105
+ }
106
+ return text;
107
+ };
108
+ throwIfAborted(signal);
109
+ if (typeof input === "string") {
110
+ const text = emit(input);
111
+ done = input.length;
112
+ if (text.length > 0) {
113
+ yield text;
114
+ }
115
+ onProgress?.(done, total ?? undefined);
116
+ return;
117
+ }
118
+ const decoder = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true });
119
+ const decode = (bytes, stream) => {
120
+ try {
121
+ return decoder.decode(bytes, { stream });
122
+ }
123
+ catch (err) {
124
+ if (err instanceof TypeError) {
125
+ report.fail(INVALID_UTF8_CODE, `invalid UTF-8 near byte ${done}`, undefined, { byteOffset: done });
126
+ }
127
+ throw err;
128
+ }
129
+ };
130
+ if (input instanceof Uint8Array) {
131
+ for (let offset = 0; offset < input.byteLength; offset += DECODE_SLICE) {
132
+ throwIfAborted(signal);
133
+ const slice = input.subarray(offset, Math.min(offset + DECODE_SLICE, input.byteLength));
134
+ const text = emit(decode(slice, offset + DECODE_SLICE < input.byteLength));
135
+ done = Math.min(offset + DECODE_SLICE, input.byteLength);
136
+ if (text.length > 0) {
137
+ yield text;
138
+ }
139
+ onProgress?.(done, total ?? undefined);
140
+ }
141
+ if (input.byteLength === 0) {
142
+ onProgress?.(0, 0);
143
+ }
144
+ return;
145
+ }
146
+ const chunks = isReadableStream(input) ? streamChunks(input, signal) : input;
147
+ for await (const chunk of chunks) {
148
+ throwIfAborted(signal);
149
+ let text;
150
+ if (typeof chunk === "string") {
151
+ // finish any byte sequence still pending in the decoder before switching to text
152
+ const pending = decode(new Uint8Array(0), false);
153
+ text = emit(pending + chunk);
154
+ done += chunk.length;
155
+ }
156
+ else if (chunk instanceof Uint8Array) {
157
+ text = emit(decode(chunk, true));
158
+ done += chunk.byteLength;
159
+ }
160
+ else {
161
+ throw new GraphFormatError("E_UNSUPPORTED", "an input chunk must be a string or a Uint8Array", {
162
+ reason: "chunk type",
163
+ found: typeof chunk,
164
+ });
165
+ }
166
+ if (text.length > 0) {
167
+ yield text;
168
+ }
169
+ onProgress?.(done);
170
+ }
171
+ const tail = emit(decode(new Uint8Array(0), false));
172
+ if (tail.length > 0) {
173
+ yield tail;
174
+ }
175
+ onProgress?.(done, done);
176
+ }
177
+ /**
178
+ * Whether an input is a ReadableStream (by duck type, so a stream from another realm qualifies).
179
+ * @param input - a non-string, non-Uint8Array input
180
+ * @returns true for a ReadableStream
181
+ */
182
+ function isReadableStream(input) {
183
+ return typeof input.getReader === "function";
184
+ }
185
+ /**
186
+ * Iterate a ReadableStream through a reader, cancelling the stream when iteration stops early.
187
+ * @param stream - the stream
188
+ * @param signal - the cancellation signal, or null
189
+ * @yields the stream's chunks
190
+ * @returns nothing
191
+ */
192
+ async function* streamChunks(stream, signal) {
193
+ const reader = stream.getReader();
194
+ let finished = false;
195
+ try {
196
+ for (;;) {
197
+ throwIfAborted(signal);
198
+ const { done, value } = await reader.read();
199
+ if (done) {
200
+ finished = true;
201
+ return;
202
+ }
203
+ yield value;
204
+ }
205
+ }
206
+ finally {
207
+ if (!finished) {
208
+ await reader.cancel(signal?.reason).catch(() => undefined);
209
+ }
210
+ reader.releaseLock();
211
+ }
212
+ }
213
+ /**
214
+ * Read the whole input as one string (the GML / DOT / JSON path, design section 8.4).
215
+ * @param input - the input
216
+ * @param report - the report the decode error is recorded in
217
+ * @param options - cancellation and progress
218
+ * @returns the decoded text without a leading BOM
219
+ */
220
+ export async function readText(input, report, options = {}) {
221
+ if (typeof input === "string") {
222
+ throwIfAborted(options.signal);
223
+ options.onProgress?.(input.length, input.length);
224
+ return input.startsWith(BOM) ? input.slice(1) : input;
225
+ }
226
+ const parts = [];
227
+ for await (const chunk of textChunks(input, report, options)) {
228
+ parts.push(chunk);
229
+ }
230
+ return parts.length === 1 ? parts[0] : parts.join("");
231
+ }
232
+ /**
233
+ * Lines of an ImportInput without allocating anything per line but the string itself: iterate with
234
+ * `for await (const text of reader)` and read `reader.line` (1-based) for the line just yielded.
235
+ * `\n`, `\r\n` and lone `\r` all end a line; the terminator is not part of the text; a final
236
+ * line without a terminator is yielded when non-empty, and every line in between is yielded even
237
+ * when empty (the importer decides what a blank line means).
238
+ */
239
+ export class LineReader {
240
+ /**
241
+ * Create a reader over an input; nothing is read until iteration starts.
242
+ * @param input - the input
243
+ * @param report - the report decode errors are recorded in
244
+ * @param options - cancellation and progress
245
+ */
246
+ constructor(input, report, options = {}) {
247
+ this.lineNumber = 0;
248
+ this.input = input;
249
+ this.report = report;
250
+ this.options = options;
251
+ }
252
+ /**
253
+ * The 1-based number of the line most recently yielded.
254
+ * @returns the line number; 0 before the first line
255
+ */
256
+ get line() {
257
+ return this.lineNumber;
258
+ }
259
+ /**
260
+ * Iterate the lines.
261
+ * @yields one line at a time, terminator removed
262
+ * @returns nothing
263
+ */
264
+ async *[Symbol.asyncIterator]() {
265
+ // The pieces of the line in progress (none of them holds a line break, except that the last
266
+ // may end with a `\r` whose meaning the next chunk decides); joined once when the line ends,
267
+ // so a line spanning many chunks costs its length, not its length times the chunk count.
268
+ const pending = [];
269
+ let trailingCr = false;
270
+ for await (const chunk of textChunks(this.input, this.report, this.options)) {
271
+ let start = 0;
272
+ const end = chunk.length;
273
+ if (trailingCr) {
274
+ // the previous chunk ended with `\r`: that ended a line, and a leading `\n` here is
275
+ // the second half of the same terminator
276
+ trailingCr = false;
277
+ this.lineNumber++;
278
+ const joined = pending.join("");
279
+ pending.length = 0;
280
+ yield joined.slice(0, -1);
281
+ if (chunk.charCodeAt(0) === 10) {
282
+ start = 1;
283
+ }
284
+ }
285
+ // the next `\n` and `\r` at or after `start`; each is searched for once per chunk and
286
+ // again only after it was consumed, so a chunk is scanned once whatever its line count
287
+ let nl = chunk.indexOf("\n", start);
288
+ let cr = chunk.indexOf("\r", start);
289
+ while (nl >= 0 || cr >= 0) {
290
+ let cut;
291
+ let next;
292
+ if (cr >= 0 && (nl < 0 || cr < nl)) {
293
+ if (cr === end - 1) {
294
+ // a trailing \r may be the first half of \r\n split across chunks
295
+ break;
296
+ }
297
+ cut = cr;
298
+ next = chunk.charCodeAt(cr + 1) === 10 ? cr + 2 : cr + 1;
299
+ }
300
+ else {
301
+ cut = nl;
302
+ next = nl + 1;
303
+ }
304
+ this.lineNumber++;
305
+ const piece = chunk.slice(start, cut);
306
+ if (pending.length === 0) {
307
+ yield piece;
308
+ }
309
+ else {
310
+ pending.push(piece);
311
+ const joined = pending.join("");
312
+ pending.length = 0;
313
+ yield joined;
314
+ }
315
+ start = next;
316
+ if (nl >= 0 && nl < next) {
317
+ nl = chunk.indexOf("\n", next);
318
+ }
319
+ if (cr >= 0 && cr < next) {
320
+ cr = chunk.indexOf("\r", next);
321
+ }
322
+ }
323
+ if (start < end) {
324
+ pending.push(start === 0 ? chunk : chunk.slice(start));
325
+ trailingCr = chunk.charCodeAt(end - 1) === 13;
326
+ }
327
+ }
328
+ if (pending.length > 0) {
329
+ this.lineNumber++;
330
+ const joined = pending.join("");
331
+ yield joined.endsWith("\r") ? joined.slice(0, -1) : joined;
332
+ }
333
+ }
334
+ }
335
+ //# sourceMappingURL=input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"input.js","sourceRoot":"","sources":["../../../src/common/input.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAG/C,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAc7B;;;;;GAKG;AACH,MAAM,YAAY,GAAG,GAAG,GAAG,IAAI,CAAC;AAEhC,MAAM,GAAG,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;AAExC;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAC3D,OAAO,IAAI,CAAC;IAChB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC9C,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,OAAO,OAAQ,KAAiC,CAAC,SAAS,KAAK,UAAU,IAAI,MAAM,CAAC,aAAa,IAAI,KAAK,CAAC;AAC/G,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,KAAkB;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC,MAAM,CAAC;IACxB,CAAC;IACD,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC,UAAU,CAAC;IAC5B,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AAC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E,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,EAAE,CAAC;oBACvB,EAAE,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;gBACnC,CAAC;YACL,CAAC;YACD,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;gBACvD,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;YAClD,CAAC;QACL,CAAC;QACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,IAAI,CAAC,UAAU,EAAE,CAAC;YAClB,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAChC,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC;QAC/D,CAAC;IACL,CAAC;CACJ"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * List value syntaxes of the text formats (design section 5.1, research note 07 section 2.1):
3
+ * GEXF 1.3 bracket lists `[1, 2, 3]` / `[foo, 'bar baz']`, GEXF 1.2 `liststring` values separated
4
+ * by `|`, `,` or `;` ("an unsafe type"), Gephi and Neo4j `;`-separated arrays. The importer splits
5
+ * the text into item texts with splitListText() and parses each item by the declared item type.
6
+ */
7
+ /** The list syntaxes an importer or exporter names. */
8
+ export type ListSyntax = "gexf" | "brackets" | "pipe" | "comma" | "semicolon";
9
+ /**
10
+ * Split a list value into its item texts.
11
+ *
12
+ * - "gexf": a bracketed text `[a, b]` is parsed with single or double quotes around items that
13
+ * contain commas; otherwise the 1.2 rule applies: the text is split on `|` when it contains one,
14
+ * else on `,` when it contains one, else on `;` when it contains one, else it is one item.
15
+ * - "brackets": bracketed only; an unbracketed text is one item.
16
+ * - "pipe" / "comma" / "semicolon": split on that separator.
17
+ *
18
+ * Items are trimmed; an empty text (or `[]`) is an empty list; an empty item between separators
19
+ * is kept as an empty string.
20
+ * @param text - the value text
21
+ * @param syntax - the syntax
22
+ * @returns the item texts
23
+ */
24
+ export declare function splitListText(text: string, syntax: ListSyntax): string[];
25
+ /**
26
+ * Join item texts into a list value of one syntax, the inverse of splitListText() for the exporters.
27
+ * Bracket syntaxes quote an item that contains a comma, a bracket or a quote (with double quotes,
28
+ * a double quote inside doubled); separator syntaxes cannot escape and leave items as they are.
29
+ * @param items - the item texts
30
+ * @param syntax - the syntax; "gexf" writes the 1.3 bracket form
31
+ * @returns the list text
32
+ */
33
+ export declare function joinListText(items: readonly string[], syntax: ListSyntax): string;
34
+ //# sourceMappingURL=lists.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lists.d.ts","sourceRoot":"","sources":["../../../src/common/lists.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,uDAAuD;AACvD,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,UAAU,GAAG,MAAM,GAAG,OAAO,GAAG,WAAW,CAAC;AAE9E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,EAAE,CA6BxE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAmBjF"}
@@ -0,0 +1,185 @@
1
+ /**
2
+ * List value syntaxes of the text formats (design section 5.1, research note 07 section 2.1):
3
+ * GEXF 1.3 bracket lists `[1, 2, 3]` / `[foo, 'bar baz']`, GEXF 1.2 `liststring` values separated
4
+ * by `|`, `,` or `;` ("an unsafe type"), Gephi and Neo4j `;`-separated arrays. The importer splits
5
+ * the text into item texts with splitListText() and parses each item by the declared item type.
6
+ */
7
+ import { GraphFormatError } from "@graphty/graph-format";
8
+ /**
9
+ * Split a list value into its item texts.
10
+ *
11
+ * - "gexf": a bracketed text `[a, b]` is parsed with single or double quotes around items that
12
+ * contain commas; otherwise the 1.2 rule applies: the text is split on `|` when it contains one,
13
+ * else on `,` when it contains one, else on `;` when it contains one, else it is one item.
14
+ * - "brackets": bracketed only; an unbracketed text is one item.
15
+ * - "pipe" / "comma" / "semicolon": split on that separator.
16
+ *
17
+ * Items are trimmed; an empty text (or `[]`) is an empty list; an empty item between separators
18
+ * is kept as an empty string.
19
+ * @param text - the value text
20
+ * @param syntax - the syntax
21
+ * @returns the item texts
22
+ */
23
+ export function splitListText(text, syntax) {
24
+ const trimmed = text.trim();
25
+ if (trimmed.length === 0) {
26
+ return [];
27
+ }
28
+ switch (syntax) {
29
+ case "gexf": {
30
+ if (isBracketed(trimmed)) {
31
+ return splitBracketed(trimmed);
32
+ }
33
+ const separator = firstSeparator(trimmed, ["|", ",", ";"]);
34
+ return separator === null ? [trimmed] : splitOn(trimmed, separator);
35
+ }
36
+ case "brackets":
37
+ return isBracketed(trimmed) ? splitBracketed(trimmed) : [trimmed];
38
+ case "pipe":
39
+ return splitOn(trimmed, "|");
40
+ case "comma":
41
+ return splitOn(trimmed, ",");
42
+ case "semicolon":
43
+ return splitOn(trimmed, ";");
44
+ default: {
45
+ const name = syntax;
46
+ throw new GraphFormatError("E_UNSUPPORTED", `unknown list syntax ${name}`, {
47
+ option: "listSyntax",
48
+ found: name,
49
+ });
50
+ }
51
+ }
52
+ }
53
+ /**
54
+ * Join item texts into a list value of one syntax, the inverse of splitListText() for the exporters.
55
+ * Bracket syntaxes quote an item that contains a comma, a bracket or a quote (with double quotes,
56
+ * a double quote inside doubled); separator syntaxes cannot escape and leave items as they are.
57
+ * @param items - the item texts
58
+ * @param syntax - the syntax; "gexf" writes the 1.3 bracket form
59
+ * @returns the list text
60
+ */
61
+ export function joinListText(items, syntax) {
62
+ switch (syntax) {
63
+ case "gexf":
64
+ case "brackets":
65
+ return `[${items.map(quoteBracketItem).join(", ")}]`;
66
+ case "pipe":
67
+ return items.join("|");
68
+ case "comma":
69
+ return items.join(",");
70
+ case "semicolon":
71
+ return items.join(";");
72
+ default: {
73
+ const name = syntax;
74
+ throw new GraphFormatError("E_UNSUPPORTED", `unknown list syntax ${name}`, {
75
+ option: "listSyntax",
76
+ found: name,
77
+ });
78
+ }
79
+ }
80
+ }
81
+ /**
82
+ * Whether a trimmed text is `[...]`.
83
+ * @param text - the trimmed text
84
+ * @returns true when bracketed
85
+ */
86
+ function isBracketed(text) {
87
+ return text.length >= 2 && text.startsWith("[") && text.endsWith("]");
88
+ }
89
+ /**
90
+ * The first of several separators that occurs in a text.
91
+ * @param text - the text
92
+ * @param candidates - separators in priority order
93
+ * @returns the first candidate found, or null
94
+ */
95
+ function firstSeparator(text, candidates) {
96
+ for (const candidate of candidates) {
97
+ if (text.includes(candidate)) {
98
+ return candidate;
99
+ }
100
+ }
101
+ return null;
102
+ }
103
+ /**
104
+ * Split on a separator and trim every item.
105
+ * @param text - the text
106
+ * @param separator - the separator
107
+ * @returns the trimmed items
108
+ */
109
+ function splitOn(text, separator) {
110
+ return text.split(separator).map((item) => item.trim());
111
+ }
112
+ /**
113
+ * Parse the inside of a bracketed list: comma-separated items, each optionally wrapped in single
114
+ * or double quotes (a doubled quote inside a quoted item is one quote).
115
+ * @param text - the bracketed text
116
+ * @returns the items
117
+ */
118
+ function splitBracketed(text) {
119
+ const inner = text.slice(1, -1);
120
+ const items = [];
121
+ const n = inner.length;
122
+ if (inner.trim().length === 0) {
123
+ return items;
124
+ }
125
+ let i = 0;
126
+ for (;;) {
127
+ while (i < n && isSpace(inner.charCodeAt(i))) {
128
+ i++;
129
+ }
130
+ let item = "";
131
+ if (i < n && (inner[i] === '"' || inner[i] === "'")) {
132
+ const quote = inner[i];
133
+ i++;
134
+ while (i < n) {
135
+ if (inner[i] === quote) {
136
+ if (inner[i + 1] === quote) {
137
+ item += quote;
138
+ i += 2;
139
+ continue;
140
+ }
141
+ i++;
142
+ break;
143
+ }
144
+ item += inner[i];
145
+ i++;
146
+ }
147
+ }
148
+ // unquoted text, or text after a closing quote that is not a separator, runs to the next comma
149
+ let end = inner.indexOf(",", i);
150
+ if (end < 0) {
151
+ end = n;
152
+ }
153
+ item += inner.slice(i, end).trim();
154
+ items.push(item);
155
+ i = end;
156
+ if (i >= n) {
157
+ return items;
158
+ }
159
+ i++;
160
+ if (inner.slice(i).trim().length === 0) {
161
+ items.push("");
162
+ return items;
163
+ }
164
+ }
165
+ }
166
+ /**
167
+ * Whether a char code is ASCII whitespace.
168
+ * @param c - the char code
169
+ * @returns true for space, tab, CR, LF
170
+ */
171
+ function isSpace(c) {
172
+ return c === 32 || c === 9 || c === 13 || c === 10;
173
+ }
174
+ /**
175
+ * Quote one item for a bracket list when it needs it.
176
+ * @param item - the item text
177
+ * @returns the item, quoted when it contains a comma, a bracket, a quote or surrounding whitespace
178
+ */
179
+ function quoteBracketItem(item) {
180
+ if (item.length === 0 || /[,[\]"']/.test(item) || item !== item.trim()) {
181
+ return `"${item.replace(/"/g, '""')}"`;
182
+ }
183
+ return item;
184
+ }
185
+ //# sourceMappingURL=lists.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lists.js","sourceRoot":"","sources":["../../../src/common/lists.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAKzD;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,MAAkB;IAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAC5B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,CAAC;IACd,CAAC;IACD,QAAQ,MAAM,EAAE,CAAC;QACb,KAAK,MAA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