zudoku 0.25.2 → 0.26.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (264) hide show
  1. package/dist/app/demo.js +0 -1
  2. package/dist/app/demo.js.map +1 -1
  3. package/dist/app/standalone.js +0 -1
  4. package/dist/app/standalone.js.map +1 -1
  5. package/dist/cli/dev/handler.js +2 -2
  6. package/dist/cli/dev/handler.js.map +1 -1
  7. package/dist/config/validators/InputSidebarSchema.d.ts +2 -2
  8. package/dist/config/validators/common.d.ts +28 -28
  9. package/dist/config/validators/icon-types.d.ts +1 -1
  10. package/dist/config/validators/validate.d.ts +16 -16
  11. package/dist/lib/components/navigation/SidebarCategory.js +1 -1
  12. package/dist/lib/components/navigation/SidebarCategory.js.map +1 -1
  13. package/dist/lib/oas/graphql/index.d.ts +3 -0
  14. package/dist/lib/oas/graphql/index.js +12 -13
  15. package/dist/lib/oas/graphql/index.js.map +1 -1
  16. package/dist/lib/plugins/openapi/ColorizedParam.d.ts +10 -2
  17. package/dist/lib/plugins/openapi/ColorizedParam.js +16 -7
  18. package/dist/lib/plugins/openapi/ColorizedParam.js.map +1 -1
  19. package/dist/lib/plugins/openapi/OperationList.js +3 -0
  20. package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
  21. package/dist/lib/plugins/openapi/ParameterListItem.js +3 -2
  22. package/dist/lib/plugins/openapi/ParameterListItem.js.map +1 -1
  23. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js +2 -0
  24. package/dist/lib/plugins/openapi/PlaygroundDialogWrapper.js.map +1 -1
  25. package/dist/lib/plugins/openapi/RequestBodySidecarBox.d.ts +3 -2
  26. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js +3 -6
  27. package/dist/lib/plugins/openapi/RequestBodySidecarBox.js.map +1 -1
  28. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js +2 -6
  29. package/dist/lib/plugins/openapi/ResponsesSidecarBox.js.map +1 -1
  30. package/dist/lib/plugins/openapi/Sidecar.js +9 -6
  31. package/dist/lib/plugins/openapi/Sidecar.js.map +1 -1
  32. package/dist/lib/plugins/openapi/SidecarBox.js +1 -1
  33. package/dist/lib/plugins/openapi/SidecarBox.js.map +1 -1
  34. package/dist/lib/plugins/openapi/{ExampleDisplay.d.ts → SidecarExamples.d.ts} +3 -6
  35. package/dist/lib/plugins/openapi/SidecarExamples.js +65 -0
  36. package/dist/lib/plugins/openapi/SidecarExamples.js.map +1 -0
  37. package/dist/lib/plugins/openapi/client/GraphQLClient.d.ts +1 -1
  38. package/dist/lib/plugins/openapi/client/GraphQLClient.js +22 -93
  39. package/dist/lib/plugins/openapi/client/GraphQLClient.js.map +1 -1
  40. package/dist/lib/plugins/openapi/client/createServer.d.ts +2 -1
  41. package/dist/lib/plugins/openapi/client/createServer.js +5 -2
  42. package/dist/lib/plugins/openapi/client/createServer.js.map +1 -1
  43. package/dist/lib/plugins/openapi/client/useCreateQuery.d.ts +1 -1
  44. package/dist/lib/plugins/openapi/client/useCreateQuery.js +2 -13
  45. package/dist/lib/plugins/openapi/client/useCreateQuery.js.map +1 -1
  46. package/dist/lib/plugins/openapi/index.d.ts +2 -1
  47. package/dist/lib/plugins/openapi/index.js.map +1 -1
  48. package/dist/lib/plugins/openapi/playground/EnumSelector.d.ts +8 -0
  49. package/dist/lib/plugins/openapi/playground/EnumSelector.js +21 -0
  50. package/dist/lib/plugins/openapi/playground/EnumSelector.js.map +1 -0
  51. package/dist/lib/plugins/openapi/playground/PathParams.js +9 -4
  52. package/dist/lib/plugins/openapi/playground/PathParams.js.map +1 -1
  53. package/dist/lib/plugins/openapi/playground/Playground.d.ts +3 -0
  54. package/dist/lib/plugins/openapi/playground/Playground.js +5 -2
  55. package/dist/lib/plugins/openapi/playground/Playground.js.map +1 -1
  56. package/dist/lib/plugins/openapi/playground/QueryParams.js +23 -8
  57. package/dist/lib/plugins/openapi/playground/QueryParams.js.map +1 -1
  58. package/dist/lib/plugins/openapi/schema/SchemaComponents.js +2 -1
  59. package/dist/lib/plugins/openapi/schema/SchemaComponents.js.map +1 -1
  60. package/dist/lib/plugins/openapi/util/generateSchemaExample.js +19 -11
  61. package/dist/lib/plugins/openapi/util/generateSchemaExample.js.map +1 -1
  62. package/dist/lib/ui/Badge.d.ts +1 -1
  63. package/dist/lib/ui/Badge.js +2 -1
  64. package/dist/lib/ui/Badge.js.map +1 -1
  65. package/dist/lib/ui/Button.d.ts +1 -1
  66. package/dist/lib/ui/Checkbox.d.ts +8 -2
  67. package/dist/lib/ui/Checkbox.js +13 -1
  68. package/dist/lib/ui/Checkbox.js.map +1 -1
  69. package/dist/lib/util/traverse.d.ts +8 -1
  70. package/dist/lib/util/traverse.js +7 -3
  71. package/dist/lib/util/traverse.js.map +1 -1
  72. package/dist/vite/api/schema-codegen.d.ts +12 -0
  73. package/dist/vite/api/schema-codegen.js +62 -0
  74. package/dist/vite/api/schema-codegen.js.map +1 -0
  75. package/dist/vite/api/schema-codegen.test.d.ts +1 -0
  76. package/dist/vite/api/schema-codegen.test.js +247 -0
  77. package/dist/vite/api/schema-codegen.test.js.map +1 -0
  78. package/dist/vite/config.js +0 -7
  79. package/dist/vite/config.js.map +1 -1
  80. package/dist/vite/config.test.js +5 -1
  81. package/dist/vite/config.test.js.map +1 -1
  82. package/dist/vite/plugin-api.js +110 -82
  83. package/dist/vite/plugin-api.js.map +1 -1
  84. package/dist/vite/plugin-component.js +0 -1
  85. package/dist/vite/plugin-component.js.map +1 -1
  86. package/lib/{AnchorLink-DFZZbmvr.js → AnchorLink-_Vu02ceN.js} +3 -3
  87. package/lib/{AnchorLink-DFZZbmvr.js.map → AnchorLink-_Vu02ceN.js.map} +1 -1
  88. package/lib/{AuthenticationPlugin-D7G3me8L.js → AuthenticationPlugin-DNXBcsVN.js} +4 -4
  89. package/lib/{AuthenticationPlugin-D7G3me8L.js.map → AuthenticationPlugin-DNXBcsVN.js.map} +1 -1
  90. package/lib/{Button-DeAoTouo.js → Button-oroWHXAy.js} +3 -3
  91. package/lib/{Button-DeAoTouo.js.map → Button-oroWHXAy.js.map} +1 -1
  92. package/lib/{CategoryHeading-CBconmtI.js → CategoryHeading-MYL1u_6K.js} +3 -3
  93. package/lib/{CategoryHeading-CBconmtI.js.map → CategoryHeading-MYL1u_6K.js.map} +1 -1
  94. package/lib/Command-D5DE0DD7.js +611 -0
  95. package/lib/Command-D5DE0DD7.js.map +1 -0
  96. package/lib/{Markdown-CZDLNOFc.js → Markdown-BrfrjEk_.js} +1041 -1041
  97. package/lib/{Markdown-CZDLNOFc.js.map → Markdown-BrfrjEk_.js.map} +1 -1
  98. package/lib/{MdxPage-DKMbBROv.js → MdxPage-LNZLj_A5.js} +24 -24
  99. package/lib/{MdxPage-DKMbBROv.js.map → MdxPage-LNZLj_A5.js.map} +1 -1
  100. package/lib/{OperationList-BLdHAQ39.js → OperationList-PCwzTp1r.js} +1899 -1877
  101. package/lib/OperationList-PCwzTp1r.js.map +1 -0
  102. package/lib/{Route-DYwKZ_c_.js → Route-Pzk6qwIk.js} +5 -5
  103. package/lib/{Route-DYwKZ_c_.js.map → Route-Pzk6qwIk.js.map} +1 -1
  104. package/lib/{Select-B_IxRUUC.js → Select-DkOpAG0c.js} +36 -36
  105. package/lib/{Select-B_IxRUUC.js.map → Select-DkOpAG0c.js.map} +1 -1
  106. package/lib/{SlotletProvider-pfc9oejW.js → SlotletProvider-DPbx9KdU.js} +53 -53
  107. package/lib/{SlotletProvider-pfc9oejW.js.map → SlotletProvider-DPbx9KdU.js.map} +1 -1
  108. package/lib/{Spinner-DuxJLLNE.js → Spinner-C5gHXrVz.js} +2 -2
  109. package/lib/{Spinner-DuxJLLNE.js.map → Spinner-C5gHXrVz.js.map} +1 -1
  110. package/lib/{SyntaxHighlight-Bz-lOJtH.js → SyntaxHighlight-CJCSPG1F.js} +297 -301
  111. package/lib/{SyntaxHighlight-Bz-lOJtH.js.map → SyntaxHighlight-CJCSPG1F.js.map} +1 -1
  112. package/lib/{ZudokuContext-hmLMUdf2.js → ZudokuContext-D3ayHjP-.js} +357 -356
  113. package/lib/ZudokuContext-D3ayHjP-.js.map +1 -0
  114. package/lib/{chunk-D52XG6IA-Dl7HLe6j.js → chunk-SYFQ2XB5-KWlHsT7t.js} +407 -410
  115. package/lib/chunk-SYFQ2XB5-KWlHsT7t.js.map +1 -0
  116. package/lib/context-rwLGh-6_.js +22 -0
  117. package/lib/{context-h_UkBLvr.js.map → context-rwLGh-6_.js.map} +1 -1
  118. package/lib/{createServer-Bf5_6o6G.js → createServer-BcaswoFO.js} +4363 -5302
  119. package/lib/createServer-BcaswoFO.js.map +1 -0
  120. package/lib/{hook-CHq7pFyz.js → hook-DUyACbIK.js} +17 -17
  121. package/lib/{hook-CHq7pFyz.js.map → hook-DUyACbIK.js.map} +1 -1
  122. package/lib/index-CaILD1AV.js +1292 -0
  123. package/lib/index-CaILD1AV.js.map +1 -0
  124. package/lib/index-Djenk2Hj.js +36 -0
  125. package/lib/{index-CPNSgwSb.js.map → index-Djenk2Hj.js.map} +1 -1
  126. package/lib/{index-CBXSgjaE.js → index-Dl3Yl0yb.js} +65 -69
  127. package/lib/index-Dl3Yl0yb.js.map +1 -0
  128. package/lib/index-TaRXY2w1.js +43 -0
  129. package/lib/index-TaRXY2w1.js.map +1 -0
  130. package/lib/{index.esm-BSV1C092.js → index.esm-9-TF9KQB.js} +52 -52
  131. package/lib/{index.esm-BSV1C092.js.map → index.esm-9-TF9KQB.js.map} +1 -1
  132. package/lib/index.esm-CrSoEshU.js +1207 -0
  133. package/lib/index.esm-CrSoEshU.js.map +1 -0
  134. package/lib/{jsx-runtime-Dx-03ztt.js → jsx-runtime-Bdg6XQ1m.js} +135 -135
  135. package/lib/{jsx-runtime-Dx-03ztt.js.map → jsx-runtime-Bdg6XQ1m.js.map} +1 -1
  136. package/lib/post-processors/removeExtensions.js +3 -3
  137. package/lib/post-processors/traverse.js +11 -8
  138. package/lib/post-processors/traverse.js.map +1 -1
  139. package/lib/{prism-bash.min-DadFsM4Z.js → prism-bash.min-HHIMdNJ_.js} +4 -4
  140. package/lib/{prism-bash.min-DadFsM4Z.js.map → prism-bash.min-HHIMdNJ_.js.map} +1 -1
  141. package/lib/{prism-csharp.min-DUwvItt4.js → prism-csharp.min-bQAo2pmx.js} +33 -33
  142. package/lib/{prism-csharp.min-DUwvItt4.js.map → prism-csharp.min-bQAo2pmx.js.map} +1 -1
  143. package/lib/{prism-java.min-BtgBR4yd.js → prism-java.min-BpvsOuIa.js} +12 -12
  144. package/lib/{prism-java.min-BtgBR4yd.js.map → prism-java.min-BpvsOuIa.js.map} +1 -1
  145. package/lib/{prism-markdown.min-F3U-vPBi.js → prism-markdown.min-C0Qn0m-5.js} +30 -30
  146. package/lib/{prism-markdown.min-F3U-vPBi.js.map → prism-markdown.min-C0Qn0m-5.js.map} +1 -1
  147. package/lib/{prism-ruby.min-DeDXCp1r.js → prism-ruby.min-Dx9KO9ds.js} +16 -16
  148. package/lib/{prism-ruby.min-DeDXCp1r.js.map → prism-ruby.min-Dx9KO9ds.js.map} +1 -1
  149. package/lib/prism-typescript.min-CD7H2IYQ.js.map +1 -1
  150. package/lib/state-mM7uaXTW.js +202 -0
  151. package/lib/state-mM7uaXTW.js.map +1 -0
  152. package/lib/ui/Accordion.js +1 -1
  153. package/lib/ui/ActionButton.js +3 -3
  154. package/lib/ui/Alert.js +2 -2
  155. package/lib/ui/AlertDialog.js +1 -1
  156. package/lib/ui/Badge.js +4 -3
  157. package/lib/ui/Badge.js.map +1 -1
  158. package/lib/ui/Breadcrumb.js +1 -1
  159. package/lib/ui/Button.js +2 -2
  160. package/lib/ui/Callout.js +1 -1
  161. package/lib/ui/Card.js +1 -1
  162. package/lib/ui/Carousel.js +3 -3
  163. package/lib/ui/Carousel.js.map +1 -1
  164. package/lib/ui/Checkbox.js +26 -15
  165. package/lib/ui/Checkbox.js.map +1 -1
  166. package/lib/ui/Command.js +14 -550
  167. package/lib/ui/Command.js.map +1 -1
  168. package/lib/ui/Dialog.js +1 -1
  169. package/lib/ui/Drawer.js +520 -519
  170. package/lib/ui/Drawer.js.map +1 -1
  171. package/lib/ui/DropdownMenu.js +1 -1
  172. package/lib/ui/Form.js +2 -2
  173. package/lib/ui/HoverCard.js +1 -1
  174. package/lib/ui/Input.js +1 -1
  175. package/lib/ui/Label.js +2 -2
  176. package/lib/ui/Pagination.js +7 -7
  177. package/lib/ui/Popover.js +1 -1
  178. package/lib/ui/Progress.js +1 -1
  179. package/lib/ui/RadioGroup.js +1 -1
  180. package/lib/ui/ScrollArea.js +1 -1
  181. package/lib/ui/Select.js +1 -1
  182. package/lib/ui/Skeleton.js +1 -1
  183. package/lib/ui/Slider.js +1 -1
  184. package/lib/ui/Switch.js +1 -1
  185. package/lib/ui/Tabs.js +1 -1
  186. package/lib/ui/Textarea.js +1 -1
  187. package/lib/ui/Toggle.js +2 -2
  188. package/lib/ui/ToggleGroup.js +1 -1
  189. package/lib/ui/Tooltip.js +1 -1
  190. package/lib/{useExposedProps-DE9lR6MF.js → useExposedProps-BBHR7aLM.js} +2 -2
  191. package/lib/{useExposedProps-DE9lR6MF.js.map → useExposedProps-BBHR7aLM.js.map} +1 -1
  192. package/lib/zudoku.auth-auth0.js +1 -1
  193. package/lib/zudoku.auth-clerk.js +18 -18
  194. package/lib/zudoku.auth-openid.js +5 -5
  195. package/lib/zudoku.components.js +492 -477
  196. package/lib/zudoku.components.js.map +1 -1
  197. package/lib/zudoku.plugin-api-catalog.js +5 -5
  198. package/lib/zudoku.plugin-api-keys.js +7 -7
  199. package/lib/zudoku.plugin-custom-pages.js +3 -3
  200. package/lib/zudoku.plugin-markdown.js +2 -2
  201. package/lib/zudoku.plugin-openapi.js +5 -5
  202. package/lib/zudoku.plugin-redirect.js +1 -1
  203. package/lib/zudoku.plugin-search-inkeep.js +9 -9
  204. package/package.json +48 -53
  205. package/src/app/demo.tsx +0 -1
  206. package/src/app/standalone.tsx +0 -1
  207. package/src/lib/components/navigation/SidebarCategory.tsx +2 -2
  208. package/src/lib/oas/graphql/index.ts +19 -15
  209. package/src/lib/plugins/openapi/ColorizedParam.tsx +29 -12
  210. package/src/lib/plugins/openapi/OperationList.tsx +4 -0
  211. package/src/lib/plugins/openapi/ParameterListItem.tsx +5 -7
  212. package/src/lib/plugins/openapi/PlaygroundDialogWrapper.tsx +2 -0
  213. package/src/lib/plugins/openapi/RequestBodySidecarBox.tsx +9 -8
  214. package/src/lib/plugins/openapi/ResponsesSidecarBox.tsx +5 -8
  215. package/src/lib/plugins/openapi/Sidecar.tsx +14 -7
  216. package/src/lib/plugins/openapi/SidecarBox.tsx +1 -1
  217. package/src/lib/plugins/openapi/SidecarExamples.tsx +163 -0
  218. package/src/lib/plugins/openapi/client/GraphQLClient.tsx +28 -120
  219. package/src/lib/plugins/openapi/client/createServer.ts +6 -2
  220. package/src/lib/plugins/openapi/client/useCreateQuery.ts +2 -17
  221. package/src/lib/plugins/openapi/index.tsx +2 -1
  222. package/src/lib/plugins/openapi/playground/EnumSelector.tsx +86 -0
  223. package/src/lib/plugins/openapi/playground/PathParams.tsx +72 -64
  224. package/src/lib/plugins/openapi/playground/Playground.tsx +26 -13
  225. package/src/lib/plugins/openapi/playground/QueryParams.tsx +102 -73
  226. package/src/lib/plugins/openapi/schema/SchemaComponents.tsx +4 -7
  227. package/src/lib/plugins/openapi/util/generateSchemaExample.ts +26 -11
  228. package/src/lib/ui/Badge.tsx +2 -1
  229. package/src/lib/ui/Checkbox.tsx +24 -7
  230. package/src/lib/util/traverse.ts +15 -5
  231. package/dist/lib/plugins/openapi/ExampleDisplay.js +0 -78
  232. package/dist/lib/plugins/openapi/ExampleDisplay.js.map +0 -1
  233. package/dist/lib/plugins/openapi/client/worker.d.ts +0 -4
  234. package/dist/lib/plugins/openapi/client/worker.js +0 -29
  235. package/dist/lib/plugins/openapi/client/worker.js.map +0 -1
  236. package/dist/lib/plugins/openapi-worker.d.ts +0 -1
  237. package/dist/lib/plugins/openapi-worker.js +0 -8
  238. package/dist/lib/plugins/openapi-worker.js.map +0 -1
  239. package/lib/Dialog-Bxv1yEIg.js +0 -67
  240. package/lib/Dialog-Bxv1yEIg.js.map +0 -1
  241. package/lib/OperationList-BLdHAQ39.js.map +0 -1
  242. package/lib/ZudokuContext-hmLMUdf2.js.map +0 -1
  243. package/lib/assets/index-C7jnHK4b.js +0 -4841
  244. package/lib/assets/index-C7jnHK4b.js.map +0 -1
  245. package/lib/assets/worker-Cbp2r2BQ.js +0 -18592
  246. package/lib/assets/worker-Cbp2r2BQ.js.map +0 -1
  247. package/lib/chunk-D52XG6IA-Dl7HLe6j.js.map +0 -1
  248. package/lib/context-h_UkBLvr.js +0 -22
  249. package/lib/createServer-Bf5_6o6G.js.map +0 -1
  250. package/lib/index-BNx95gkf.js +0 -1284
  251. package/lib/index-BNx95gkf.js.map +0 -1
  252. package/lib/index-CBXSgjaE.js.map +0 -1
  253. package/lib/index-CPNSgwSb.js +0 -36
  254. package/lib/index-DyBL--Kz.js +0 -826
  255. package/lib/index-DyBL--Kz.js.map +0 -1
  256. package/lib/index.esm-BnnBRKJX.js +0 -1214
  257. package/lib/index.esm-BnnBRKJX.js.map +0 -1
  258. package/lib/state-CFQsUZUP.js +0 -202
  259. package/lib/state-CFQsUZUP.js.map +0 -1
  260. package/lib/zudoku.openapi-worker.js +0 -15
  261. package/lib/zudoku.openapi-worker.js.map +0 -1
  262. package/src/lib/plugins/openapi/ExampleDisplay.tsx +0 -163
  263. package/src/lib/plugins/openapi/client/worker.ts +0 -44
  264. package/src/lib/plugins/openapi-worker.ts +0 -11
@@ -1,4841 +0,0 @@
1
- const dt = Symbol.for("yaml.alias"), lt = Symbol.for("yaml.document"), J = Symbol.for("yaml.map"), qt = Symbol.for("yaml.pair"), R = Symbol.for("yaml.scalar"), he = Symbol.for("yaml.seq"), D = Symbol.for("yaml.node.type"), x = (s) => !!s && typeof s == "object" && s[D] === dt, ee = (s) => !!s && typeof s == "object" && s[D] === lt, de = (s) => !!s && typeof s == "object" && s[D] === J, I = (s) => !!s && typeof s == "object" && s[D] === qt, E = (s) => !!s && typeof s == "object" && s[D] === R, pe = (s) => !!s && typeof s == "object" && s[D] === he;
2
- function L(s) {
3
- if (s && typeof s == "object")
4
- switch (s[D]) {
5
- case J:
6
- case he:
7
- return !0;
8
- }
9
- return !1;
10
- }
11
- function $(s) {
12
- if (s && typeof s == "object")
13
- switch (s[D]) {
14
- case dt:
15
- case J:
16
- case R:
17
- case he:
18
- return !0;
19
- }
20
- return !1;
21
- }
22
- const vs = (s) => (E(s) || L(s)) && !!s.anchor, M = Symbol("break visit"), Ft = Symbol("skip children"), F = Symbol("remove node");
23
- function G(s, e) {
24
- const t = Rt(e);
25
- ee(s) ? ie(null, s.contents, t, Object.freeze([s])) === F && (s.contents = null) : ie(null, s, t, Object.freeze([]));
26
- }
27
- G.BREAK = M;
28
- G.SKIP = Ft;
29
- G.REMOVE = F;
30
- function ie(s, e, t, n) {
31
- const i = Ut(s, e, t, n);
32
- if ($(i) || I(i))
33
- return Vt(s, n, i), ie(s, i, t, n);
34
- if (typeof i != "symbol") {
35
- if (L(e)) {
36
- n = Object.freeze(n.concat(e));
37
- for (let r = 0; r < e.items.length; ++r) {
38
- const o = ie(r, e.items[r], t, n);
39
- if (typeof o == "number")
40
- r = o - 1;
41
- else {
42
- if (o === M)
43
- return M;
44
- o === F && (e.items.splice(r, 1), r -= 1);
45
- }
46
- }
47
- } else if (I(e)) {
48
- n = Object.freeze(n.concat(e));
49
- const r = ie("key", e.key, t, n);
50
- if (r === M)
51
- return M;
52
- r === F && (e.key = null);
53
- const o = ie("value", e.value, t, n);
54
- if (o === M)
55
- return M;
56
- o === F && (e.value = null);
57
- }
58
- }
59
- return i;
60
- }
61
- async function Fe(s, e) {
62
- const t = Rt(e);
63
- ee(s) ? await re(null, s.contents, t, Object.freeze([s])) === F && (s.contents = null) : await re(null, s, t, Object.freeze([]));
64
- }
65
- Fe.BREAK = M;
66
- Fe.SKIP = Ft;
67
- Fe.REMOVE = F;
68
- async function re(s, e, t, n) {
69
- const i = await Ut(s, e, t, n);
70
- if ($(i) || I(i))
71
- return Vt(s, n, i), re(s, i, t, n);
72
- if (typeof i != "symbol") {
73
- if (L(e)) {
74
- n = Object.freeze(n.concat(e));
75
- for (let r = 0; r < e.items.length; ++r) {
76
- const o = await re(r, e.items[r], t, n);
77
- if (typeof o == "number")
78
- r = o - 1;
79
- else {
80
- if (o === M)
81
- return M;
82
- o === F && (e.items.splice(r, 1), r -= 1);
83
- }
84
- }
85
- } else if (I(e)) {
86
- n = Object.freeze(n.concat(e));
87
- const r = await re("key", e.key, t, n);
88
- if (r === M)
89
- return M;
90
- r === F && (e.key = null);
91
- const o = await re("value", e.value, t, n);
92
- if (o === M)
93
- return M;
94
- o === F && (e.value = null);
95
- }
96
- }
97
- return i;
98
- }
99
- function Rt(s) {
100
- return typeof s == "object" && (s.Collection || s.Node || s.Value) ? Object.assign({
101
- Alias: s.Node,
102
- Map: s.Node,
103
- Scalar: s.Node,
104
- Seq: s.Node
105
- }, s.Value && {
106
- Map: s.Value,
107
- Scalar: s.Value,
108
- Seq: s.Value
109
- }, s.Collection && {
110
- Map: s.Collection,
111
- Seq: s.Collection
112
- }, s) : s;
113
- }
114
- function Ut(s, e, t, n) {
115
- var i, r, o, l, a;
116
- if (typeof t == "function")
117
- return t(s, e, n);
118
- if (de(e))
119
- return (i = t.Map) == null ? void 0 : i.call(t, s, e, n);
120
- if (pe(e))
121
- return (r = t.Seq) == null ? void 0 : r.call(t, s, e, n);
122
- if (I(e))
123
- return (o = t.Pair) == null ? void 0 : o.call(t, s, e, n);
124
- if (E(e))
125
- return (l = t.Scalar) == null ? void 0 : l.call(t, s, e, n);
126
- if (x(e))
127
- return (a = t.Alias) == null ? void 0 : a.call(t, s, e, n);
128
- }
129
- function Vt(s, e, t) {
130
- const n = e[e.length - 1];
131
- if (L(n))
132
- n.items[s] = t;
133
- else if (I(n))
134
- s === "key" ? n.key = t : n.value = t;
135
- else if (ee(n))
136
- n.contents = t;
137
- else {
138
- const i = x(n) ? "alias" : "scalar";
139
- throw new Error(`Cannot replace node with ${i} parent`);
140
- }
141
- }
142
- const Bs = {
143
- "!": "%21",
144
- ",": "%2C",
145
- "[": "%5B",
146
- "]": "%5D",
147
- "{": "%7B",
148
- "}": "%7D"
149
- }, Ms = (s) => s.replace(/[!,[\]{}]/g, (e) => Bs[e]);
150
- class B {
151
- constructor(e, t) {
152
- this.docStart = null, this.docEnd = !1, this.yaml = Object.assign({}, B.defaultYaml, e), this.tags = Object.assign({}, B.defaultTags, t);
153
- }
154
- clone() {
155
- const e = new B(this.yaml, this.tags);
156
- return e.docStart = this.docStart, e;
157
- }
158
- /**
159
- * During parsing, get a Directives instance for the current document and
160
- * update the stream state according to the current version's spec.
161
- */
162
- atDocument() {
163
- const e = new B(this.yaml, this.tags);
164
- switch (this.yaml.version) {
165
- case "1.1":
166
- this.atNextDocument = !0;
167
- break;
168
- case "1.2":
169
- this.atNextDocument = !1, this.yaml = {
170
- explicit: B.defaultYaml.explicit,
171
- version: "1.2"
172
- }, this.tags = Object.assign({}, B.defaultTags);
173
- break;
174
- }
175
- return e;
176
- }
177
- /**
178
- * @param onError - May be called even if the action was successful
179
- * @returns `true` on success
180
- */
181
- add(e, t) {
182
- this.atNextDocument && (this.yaml = { explicit: B.defaultYaml.explicit, version: "1.1" }, this.tags = Object.assign({}, B.defaultTags), this.atNextDocument = !1);
183
- const n = e.trim().split(/[ \t]+/), i = n.shift();
184
- switch (i) {
185
- case "%TAG": {
186
- if (n.length !== 2 && (t(0, "%TAG directive should contain exactly two parts"), n.length < 2))
187
- return !1;
188
- const [r, o] = n;
189
- return this.tags[r] = o, !0;
190
- }
191
- case "%YAML": {
192
- if (this.yaml.explicit = !0, n.length !== 1)
193
- return t(0, "%YAML directive should contain exactly one part"), !1;
194
- const [r] = n;
195
- if (r === "1.1" || r === "1.2")
196
- return this.yaml.version = r, !0;
197
- {
198
- const o = /^\d+\.\d+$/.test(r);
199
- return t(6, `Unsupported YAML version ${r}`, o), !1;
200
- }
201
- }
202
- default:
203
- return t(0, `Unknown directive ${i}`, !0), !1;
204
- }
205
- }
206
- /**
207
- * Resolves a tag, matching handles to those defined in %TAG directives.
208
- *
209
- * @returns Resolved tag, which may also be the non-specific tag `'!'` or a
210
- * `'!local'` tag, or `null` if unresolvable.
211
- */
212
- tagName(e, t) {
213
- if (e === "!")
214
- return "!";
215
- if (e[0] !== "!")
216
- return t(`Not a valid tag: ${e}`), null;
217
- if (e[1] === "<") {
218
- const o = e.slice(2, -1);
219
- return o === "!" || o === "!!" ? (t(`Verbatim tags aren't resolved, so ${e} is invalid.`), null) : (e[e.length - 1] !== ">" && t("Verbatim tags must end with a >"), o);
220
- }
221
- const [, n, i] = e.match(/^(.*!)([^!]*)$/s);
222
- i || t(`The ${e} tag has no suffix`);
223
- const r = this.tags[n];
224
- if (r)
225
- try {
226
- return r + decodeURIComponent(i);
227
- } catch (o) {
228
- return t(String(o)), null;
229
- }
230
- return n === "!" ? e : (t(`Could not resolve tag: ${e}`), null);
231
- }
232
- /**
233
- * Given a fully resolved tag, returns its printable string form,
234
- * taking into account current tag prefixes and defaults.
235
- */
236
- tagString(e) {
237
- for (const [t, n] of Object.entries(this.tags))
238
- if (e.startsWith(n))
239
- return t + Ms(e.substring(n.length));
240
- return e[0] === "!" ? e : `!<${e}>`;
241
- }
242
- toString(e) {
243
- const t = this.yaml.explicit ? [`%YAML ${this.yaml.version || "1.2"}`] : [], n = Object.entries(this.tags);
244
- let i;
245
- if (e && n.length > 0 && $(e.contents)) {
246
- const r = {};
247
- G(e.contents, (o, l) => {
248
- $(l) && l.tag && (r[l.tag] = !0);
249
- }), i = Object.keys(r);
250
- } else
251
- i = [];
252
- for (const [r, o] of n)
253
- r === "!!" && o === "tag:yaml.org,2002:" || (!e || i.some((l) => l.startsWith(o))) && t.push(`%TAG ${r} ${o}`);
254
- return t.join(`
255
- `);
256
- }
257
- }
258
- B.defaultYaml = { explicit: !1, version: "1.2" };
259
- B.defaultTags = { "!!": "tag:yaml.org,2002:" };
260
- function Yt(s) {
261
- if (/[\x00-\x19\s,[\]{}]/.test(s)) {
262
- const t = `Anchor must not contain whitespace or control characters: ${JSON.stringify(s)}`;
263
- throw new Error(t);
264
- }
265
- return !0;
266
- }
267
- function Jt(s) {
268
- const e = /* @__PURE__ */ new Set();
269
- return G(s, {
270
- Value(t, n) {
271
- n.anchor && e.add(n.anchor);
272
- }
273
- }), e;
274
- }
275
- function Gt(s, e) {
276
- for (let t = 1; ; ++t) {
277
- const n = `${s}${t}`;
278
- if (!e.has(n))
279
- return n;
280
- }
281
- }
282
- function Ks(s, e) {
283
- const t = [], n = /* @__PURE__ */ new Map();
284
- let i = null;
285
- return {
286
- onAnchor: (r) => {
287
- t.push(r), i || (i = Jt(s));
288
- const o = Gt(e, i);
289
- return i.add(o), o;
290
- },
291
- /**
292
- * With circular references, the source node is only resolved after all
293
- * of its child nodes are. This is why anchors are set only after all of
294
- * the nodes have been created.
295
- */
296
- setAnchors: () => {
297
- for (const r of t) {
298
- const o = n.get(r);
299
- if (typeof o == "object" && o.anchor && (E(o.node) || L(o.node)))
300
- o.node.anchor = o.anchor;
301
- else {
302
- const l = new Error("Failed to resolve repeated object (this should not happen)");
303
- throw l.source = r, l;
304
- }
305
- }
306
- },
307
- sourceObjects: n
308
- };
309
- }
310
- function oe(s, e, t, n) {
311
- if (n && typeof n == "object")
312
- if (Array.isArray(n))
313
- for (let i = 0, r = n.length; i < r; ++i) {
314
- const o = n[i], l = oe(s, n, String(i), o);
315
- l === void 0 ? delete n[i] : l !== o && (n[i] = l);
316
- }
317
- else if (n instanceof Map)
318
- for (const i of Array.from(n.keys())) {
319
- const r = n.get(i), o = oe(s, n, i, r);
320
- o === void 0 ? n.delete(i) : o !== r && n.set(i, o);
321
- }
322
- else if (n instanceof Set)
323
- for (const i of Array.from(n)) {
324
- const r = oe(s, n, i, i);
325
- r === void 0 ? n.delete(i) : r !== i && (n.delete(i), n.add(r));
326
- }
327
- else
328
- for (const [i, r] of Object.entries(n)) {
329
- const o = oe(s, n, i, r);
330
- o === void 0 ? delete n[i] : o !== r && (n[i] = o);
331
- }
332
- return s.call(e, t, n);
333
- }
334
- function P(s, e, t) {
335
- if (Array.isArray(s))
336
- return s.map((n, i) => P(n, String(i), t));
337
- if (s && typeof s.toJSON == "function") {
338
- if (!t || !vs(s))
339
- return s.toJSON(e, t);
340
- const n = { aliasCount: 0, count: 1, res: void 0 };
341
- t.anchors.set(s, n), t.onCreate = (r) => {
342
- n.res = r, delete t.onCreate;
343
- };
344
- const i = s.toJSON(e, t);
345
- return t.onCreate && t.onCreate(i), i;
346
- }
347
- return typeof s == "bigint" && !(t != null && t.keep) ? Number(s) : s;
348
- }
349
- class pt {
350
- constructor(e) {
351
- Object.defineProperty(this, D, { value: e });
352
- }
353
- /** Create a copy of this node. */
354
- clone() {
355
- const e = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
356
- return this.range && (e.range = this.range.slice()), e;
357
- }
358
- /** A plain JavaScript representation of this node. */
359
- toJS(e, { mapAsMap: t, maxAliasCount: n, onAnchor: i, reviver: r } = {}) {
360
- if (!ee(e))
361
- throw new TypeError("A document argument is required");
362
- const o = {
363
- anchors: /* @__PURE__ */ new Map(),
364
- doc: e,
365
- keep: !0,
366
- mapAsMap: t === !0,
367
- mapKeyWarned: !1,
368
- maxAliasCount: typeof n == "number" ? n : 100
369
- }, l = P(this, "", o);
370
- if (typeof i == "function")
371
- for (const { count: a, res: c } of o.anchors.values())
372
- i(c, a);
373
- return typeof r == "function" ? oe(r, { "": l }, "", l) : l;
374
- }
375
- }
376
- class Re extends pt {
377
- constructor(e) {
378
- super(dt), this.source = e, Object.defineProperty(this, "tag", {
379
- set() {
380
- throw new Error("Alias nodes cannot have tags");
381
- }
382
- });
383
- }
384
- /**
385
- * Resolve the value of this alias within `doc`, finding the last
386
- * instance of the `source` anchor before this node.
387
- */
388
- resolve(e) {
389
- let t;
390
- return G(e, {
391
- Node: (n, i) => {
392
- if (i === this)
393
- return G.BREAK;
394
- i.anchor === this.source && (t = i);
395
- }
396
- }), t;
397
- }
398
- toJSON(e, t) {
399
- if (!t)
400
- return { source: this.source };
401
- const { anchors: n, doc: i, maxAliasCount: r } = t, o = this.resolve(i);
402
- if (!o) {
403
- const a = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
404
- throw new ReferenceError(a);
405
- }
406
- let l = n.get(o);
407
- if (l || (P(o, null, t), l = n.get(o)), !l || l.res === void 0) {
408
- const a = "This should not happen: Alias anchor was not resolved?";
409
- throw new ReferenceError(a);
410
- }
411
- if (r >= 0 && (l.count += 1, l.aliasCount === 0 && (l.aliasCount = ve(i, o, n)), l.count * l.aliasCount > r)) {
412
- const a = "Excessive alias count indicates a resource exhaustion attack";
413
- throw new ReferenceError(a);
414
- }
415
- return l.res;
416
- }
417
- toString(e, t, n) {
418
- const i = `*${this.source}`;
419
- if (e) {
420
- if (Yt(this.source), e.options.verifyAliasOrder && !e.anchors.has(this.source)) {
421
- const r = `Unresolved alias (the anchor must be set before the alias): ${this.source}`;
422
- throw new Error(r);
423
- }
424
- if (e.implicitKey)
425
- return `${i} `;
426
- }
427
- return i;
428
- }
429
- }
430
- function ve(s, e, t) {
431
- if (x(e)) {
432
- const n = e.resolve(s), i = t && n && t.get(n);
433
- return i ? i.count * i.aliasCount : 0;
434
- } else if (L(e)) {
435
- let n = 0;
436
- for (const i of e.items) {
437
- const r = ve(s, i, t);
438
- r > n && (n = r);
439
- }
440
- return n;
441
- } else if (I(e)) {
442
- const n = ve(s, e.key, t), i = ve(s, e.value, t);
443
- return Math.max(n, i);
444
- }
445
- return 1;
446
- }
447
- const Qt = (s) => !s || typeof s != "function" && typeof s != "object";
448
- class A extends pt {
449
- constructor(e) {
450
- super(R), this.value = e;
451
- }
452
- toJSON(e, t) {
453
- return t != null && t.keep ? this.value : P(this.value, e, t);
454
- }
455
- toString() {
456
- return String(this.value);
457
- }
458
- }
459
- A.BLOCK_FOLDED = "BLOCK_FOLDED";
460
- A.BLOCK_LITERAL = "BLOCK_LITERAL";
461
- A.PLAIN = "PLAIN";
462
- A.QUOTE_DOUBLE = "QUOTE_DOUBLE";
463
- A.QUOTE_SINGLE = "QUOTE_SINGLE";
464
- const Ps = "tag:yaml.org,2002:";
465
- function Ds(s, e, t) {
466
- if (e) {
467
- const n = t.filter((r) => r.tag === e), i = n.find((r) => !r.format) ?? n[0];
468
- if (!i)
469
- throw new Error(`Tag ${e} not found`);
470
- return i;
471
- }
472
- return t.find((n) => {
473
- var i;
474
- return ((i = n.identify) == null ? void 0 : i.call(n, s)) && !n.format;
475
- });
476
- }
477
- function ke(s, e, t) {
478
- var f, d, h;
479
- if (ee(s) && (s = s.contents), $(s))
480
- return s;
481
- if (I(s)) {
482
- const y = (d = (f = t.schema[J]).createNode) == null ? void 0 : d.call(f, t.schema, null, t);
483
- return y.items.push(s), y;
484
- }
485
- (s instanceof String || s instanceof Number || s instanceof Boolean || typeof BigInt < "u" && s instanceof BigInt) && (s = s.valueOf());
486
- const { aliasDuplicateObjects: n, onAnchor: i, onTagObj: r, schema: o, sourceObjects: l } = t;
487
- let a;
488
- if (n && s && typeof s == "object") {
489
- if (a = l.get(s), a)
490
- return a.anchor || (a.anchor = i(s)), new Re(a.anchor);
491
- a = { anchor: null, node: null }, l.set(s, a);
492
- }
493
- e != null && e.startsWith("!!") && (e = Ps + e.slice(2));
494
- let c = Ds(s, e, o.tags);
495
- if (!c) {
496
- if (s && typeof s.toJSON == "function" && (s = s.toJSON()), !s || typeof s != "object") {
497
- const y = new A(s);
498
- return a && (a.node = y), y;
499
- }
500
- c = s instanceof Map ? o[J] : Symbol.iterator in Object(s) ? o[he] : o[J];
501
- }
502
- r && (r(c), delete t.onTagObj);
503
- const p = c != null && c.createNode ? c.createNode(t.schema, s, t) : typeof ((h = c == null ? void 0 : c.nodeClass) == null ? void 0 : h.from) == "function" ? c.nodeClass.from(t.schema, s, t) : new A(s);
504
- return e ? p.tag = e : c.default || (p.tag = c.tag), a && (a.node = p), p;
505
- }
506
- function Pe(s, e, t) {
507
- let n = t;
508
- for (let i = e.length - 1; i >= 0; --i) {
509
- const r = e[i];
510
- if (typeof r == "number" && Number.isInteger(r) && r >= 0) {
511
- const o = [];
512
- o[r] = n, n = o;
513
- } else
514
- n = /* @__PURE__ */ new Map([[r, n]]);
515
- }
516
- return ke(n, void 0, {
517
- aliasDuplicateObjects: !1,
518
- keepUndefined: !1,
519
- onAnchor: () => {
520
- throw new Error("This should not happen, please report a bug.");
521
- },
522
- schema: s,
523
- sourceObjects: /* @__PURE__ */ new Map()
524
- });
525
- }
526
- const we = (s) => s == null || typeof s == "object" && !!s[Symbol.iterator]().next().done;
527
- class Wt extends pt {
528
- constructor(e, t) {
529
- super(e), Object.defineProperty(this, "schema", {
530
- value: t,
531
- configurable: !0,
532
- enumerable: !1,
533
- writable: !0
534
- });
535
- }
536
- /**
537
- * Create a copy of this collection.
538
- *
539
- * @param schema - If defined, overwrites the original's schema
540
- */
541
- clone(e) {
542
- const t = Object.create(Object.getPrototypeOf(this), Object.getOwnPropertyDescriptors(this));
543
- return e && (t.schema = e), t.items = t.items.map((n) => $(n) || I(n) ? n.clone(e) : n), this.range && (t.range = this.range.slice()), t;
544
- }
545
- /**
546
- * Adds a value to the collection. For `!!map` and `!!omap` the value must
547
- * be a Pair instance or a `{ key, value }` object, which may not have a key
548
- * that already exists in the map.
549
- */
550
- addIn(e, t) {
551
- if (we(e))
552
- this.add(t);
553
- else {
554
- const [n, ...i] = e, r = this.get(n, !0);
555
- if (L(r))
556
- r.addIn(i, t);
557
- else if (r === void 0 && this.schema)
558
- this.set(n, Pe(this.schema, i, t));
559
- else
560
- throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);
561
- }
562
- }
563
- /**
564
- * Removes a value from the collection.
565
- * @returns `true` if the item was found and removed.
566
- */
567
- deleteIn(e) {
568
- const [t, ...n] = e;
569
- if (n.length === 0)
570
- return this.delete(t);
571
- const i = this.get(t, !0);
572
- if (L(i))
573
- return i.deleteIn(n);
574
- throw new Error(`Expected YAML collection at ${t}. Remaining path: ${n}`);
575
- }
576
- /**
577
- * Returns item at `key`, or `undefined` if not found. By default unwraps
578
- * scalar values from their surrounding node; to disable set `keepScalar` to
579
- * `true` (collections are always returned intact).
580
- */
581
- getIn(e, t) {
582
- const [n, ...i] = e, r = this.get(n, !0);
583
- return i.length === 0 ? !t && E(r) ? r.value : r : L(r) ? r.getIn(i, t) : void 0;
584
- }
585
- hasAllNullValues(e) {
586
- return this.items.every((t) => {
587
- if (!I(t))
588
- return !1;
589
- const n = t.value;
590
- return n == null || e && E(n) && n.value == null && !n.commentBefore && !n.comment && !n.tag;
591
- });
592
- }
593
- /**
594
- * Checks if the collection includes a value with the key `key`.
595
- */
596
- hasIn(e) {
597
- const [t, ...n] = e;
598
- if (n.length === 0)
599
- return this.has(t);
600
- const i = this.get(t, !0);
601
- return L(i) ? i.hasIn(n) : !1;
602
- }
603
- /**
604
- * Sets a value in this collection. For `!!set`, `value` needs to be a
605
- * boolean to add/remove the item from the set.
606
- */
607
- setIn(e, t) {
608
- const [n, ...i] = e;
609
- if (i.length === 0)
610
- this.set(n, t);
611
- else {
612
- const r = this.get(n, !0);
613
- if (L(r))
614
- r.setIn(i, t);
615
- else if (r === void 0 && this.schema)
616
- this.set(n, Pe(this.schema, i, t));
617
- else
618
- throw new Error(`Expected YAML collection at ${n}. Remaining path: ${i}`);
619
- }
620
- }
621
- }
622
- const js = (s) => s.replace(/^(?!$)(?: $)?/gm, "#");
623
- function U(s, e) {
624
- return /^\n+$/.test(s) ? s.substring(1) : e ? s.replace(/^(?! *$)/gm, e) : s;
625
- }
626
- const H = (s, e, t) => s.endsWith(`
627
- `) ? U(t, e) : t.includes(`
628
- `) ? `
629
- ` + U(t, e) : (s.endsWith(" ") ? "" : " ") + t, Ht = "flow", at = "block", Be = "quoted";
630
- function Ue(s, e, t = "flow", { indentAtStart: n, lineWidth: i = 80, minContentWidth: r = 20, onFold: o, onOverflow: l } = {}) {
631
- if (!i || i < 0)
632
- return s;
633
- i < r && (r = 0);
634
- const a = Math.max(1 + r, 1 + i - e.length);
635
- if (s.length <= a)
636
- return s;
637
- const c = [], p = {};
638
- let f = i - e.length;
639
- typeof n == "number" && (n > i - Math.max(2, r) ? c.push(0) : f = i - n);
640
- let d, h, y = !1, u = -1, m = -1, b = -1;
641
- t === at && (u = $t(s, u, e.length), u !== -1 && (f = u + a));
642
- for (let N; N = s[u += 1]; ) {
643
- if (t === Be && N === "\\") {
644
- switch (m = u, s[u + 1]) {
645
- case "x":
646
- u += 3;
647
- break;
648
- case "u":
649
- u += 5;
650
- break;
651
- case "U":
652
- u += 9;
653
- break;
654
- default:
655
- u += 1;
656
- }
657
- b = u;
658
- }
659
- if (N === `
660
- `)
661
- t === at && (u = $t(s, u, e.length)), f = u + e.length + a, d = void 0;
662
- else {
663
- if (N === " " && h && h !== " " && h !== `
664
- ` && h !== " ") {
665
- const S = s[u + 1];
666
- S && S !== " " && S !== `
667
- ` && S !== " " && (d = u);
668
- }
669
- if (u >= f)
670
- if (d)
671
- c.push(d), f = d + a, d = void 0;
672
- else if (t === Be) {
673
- for (; h === " " || h === " "; )
674
- h = N, N = s[u += 1], y = !0;
675
- const S = u > b + 1 ? u - 2 : m - 1;
676
- if (p[S])
677
- return s;
678
- c.push(S), p[S] = !0, f = S + a, d = void 0;
679
- } else
680
- y = !0;
681
- }
682
- h = N;
683
- }
684
- if (y && l && l(), c.length === 0)
685
- return s;
686
- o && o();
687
- let w = s.slice(0, c[0]);
688
- for (let N = 0; N < c.length; ++N) {
689
- const S = c[N], k = c[N + 1] || s.length;
690
- S === 0 ? w = `
691
- ${e}${s.slice(0, k)}` : (t === Be && p[S] && (w += `${s[S]}\\`), w += `
692
- ${e}${s.slice(S + 1, k)}`);
693
- }
694
- return w;
695
- }
696
- function $t(s, e, t) {
697
- let n = e, i = e + 1, r = s[i];
698
- for (; r === " " || r === " "; )
699
- if (e < i + t)
700
- r = s[++e];
701
- else {
702
- do
703
- r = s[++e];
704
- while (r && r !== `
705
- `);
706
- n = e, i = e + 1, r = s[i];
707
- }
708
- return n;
709
- }
710
- const Ve = (s, e) => ({
711
- indentAtStart: e ? s.indent.length : s.indentAtStart,
712
- lineWidth: s.options.lineWidth,
713
- minContentWidth: s.options.minContentWidth
714
- }), Ye = (s) => /^(%|---|\.\.\.)/m.test(s);
715
- function qs(s, e, t) {
716
- if (!e || e < 0)
717
- return !1;
718
- const n = e - t, i = s.length;
719
- if (i <= n)
720
- return !1;
721
- for (let r = 0, o = 0; r < i; ++r)
722
- if (s[r] === `
723
- `) {
724
- if (r - o > n)
725
- return !0;
726
- if (o = r + 1, i - o <= n)
727
- return !1;
728
- }
729
- return !0;
730
- }
731
- function Se(s, e) {
732
- const t = JSON.stringify(s);
733
- if (e.options.doubleQuotedAsJSON)
734
- return t;
735
- const { implicitKey: n } = e, i = e.options.doubleQuotedMinMultiLineLength, r = e.indent || (Ye(s) ? " " : "");
736
- let o = "", l = 0;
737
- for (let a = 0, c = t[a]; c; c = t[++a])
738
- if (c === " " && t[a + 1] === "\\" && t[a + 2] === "n" && (o += t.slice(l, a) + "\\ ", a += 1, l = a, c = "\\"), c === "\\")
739
- switch (t[a + 1]) {
740
- case "u":
741
- {
742
- o += t.slice(l, a);
743
- const p = t.substr(a + 2, 4);
744
- switch (p) {
745
- case "0000":
746
- o += "\\0";
747
- break;
748
- case "0007":
749
- o += "\\a";
750
- break;
751
- case "000b":
752
- o += "\\v";
753
- break;
754
- case "001b":
755
- o += "\\e";
756
- break;
757
- case "0085":
758
- o += "\\N";
759
- break;
760
- case "00a0":
761
- o += "\\_";
762
- break;
763
- case "2028":
764
- o += "\\L";
765
- break;
766
- case "2029":
767
- o += "\\P";
768
- break;
769
- default:
770
- p.substr(0, 2) === "00" ? o += "\\x" + p.substr(2) : o += t.substr(a, 6);
771
- }
772
- a += 5, l = a + 1;
773
- }
774
- break;
775
- case "n":
776
- if (n || t[a + 2] === '"' || t.length < i)
777
- a += 1;
778
- else {
779
- for (o += t.slice(l, a) + `
780
-
781
- `; t[a + 2] === "\\" && t[a + 3] === "n" && t[a + 4] !== '"'; )
782
- o += `
783
- `, a += 2;
784
- o += r, t[a + 2] === " " && (o += "\\"), a += 1, l = a + 1;
785
- }
786
- break;
787
- default:
788
- a += 1;
789
- }
790
- return o = l ? o + t.slice(l) : t, n ? o : Ue(o, r, Be, Ve(e, !1));
791
- }
792
- function ct(s, e) {
793
- if (e.options.singleQuote === !1 || e.implicitKey && s.includes(`
794
- `) || /[ \t]\n|\n[ \t]/.test(s))
795
- return Se(s, e);
796
- const t = e.indent || (Ye(s) ? " " : ""), n = "'" + s.replace(/'/g, "''").replace(/\n+/g, `$&
797
- ${t}`) + "'";
798
- return e.implicitKey ? n : Ue(n, t, Ht, Ve(e, !1));
799
- }
800
- function le(s, e) {
801
- const { singleQuote: t } = e.options;
802
- let n;
803
- if (t === !1)
804
- n = Se;
805
- else {
806
- const i = s.includes('"'), r = s.includes("'");
807
- i && !r ? n = ct : r && !i ? n = Se : n = t ? ct : Se;
808
- }
809
- return n(s, e);
810
- }
811
- let ft;
812
- try {
813
- ft = new RegExp(`(^|(?<!
814
- ))
815
- +(?!
816
- |$)`, "g");
817
- } catch {
818
- ft = /\n+(?!\n|$)/g;
819
- }
820
- function Me({ comment: s, type: e, value: t }, n, i, r) {
821
- const { blockQuote: o, commentString: l, lineWidth: a } = n.options;
822
- if (!o || /\n[\t ]+$/.test(t) || /^\s*$/.test(t))
823
- return le(t, n);
824
- const c = n.indent || (n.forceBlockIndent || Ye(t) ? " " : ""), p = o === "literal" ? !0 : o === "folded" || e === A.BLOCK_FOLDED ? !1 : e === A.BLOCK_LITERAL ? !0 : !qs(t, a, c.length);
825
- if (!t)
826
- return p ? `|
827
- ` : `>
828
- `;
829
- let f, d;
830
- for (d = t.length; d > 0; --d) {
831
- const k = t[d - 1];
832
- if (k !== `
833
- ` && k !== " " && k !== " ")
834
- break;
835
- }
836
- let h = t.substring(d);
837
- const y = h.indexOf(`
838
- `);
839
- y === -1 ? f = "-" : t === h || y !== h.length - 1 ? (f = "+", r && r()) : f = "", h && (t = t.slice(0, -h.length), h[h.length - 1] === `
840
- ` && (h = h.slice(0, -1)), h = h.replace(ft, `$&${c}`));
841
- let u = !1, m, b = -1;
842
- for (m = 0; m < t.length; ++m) {
843
- const k = t[m];
844
- if (k === " ")
845
- u = !0;
846
- else if (k === `
847
- `)
848
- b = m;
849
- else
850
- break;
851
- }
852
- let w = t.substring(0, b < m ? b + 1 : m);
853
- w && (t = t.substring(w.length), w = w.replace(/\n+/g, `$&${c}`));
854
- let S = (u ? c ? "2" : "1" : "") + f;
855
- if (s && (S += " " + l(s.replace(/ ?[\r\n]+/g, " ")), i && i()), !p) {
856
- const k = t.replace(/\n+/g, `
857
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g, "$1$2").replace(/\n+/g, `$&${c}`);
858
- let O = !1;
859
- const T = Ve(n, !0);
860
- o !== "folded" && e !== A.BLOCK_FOLDED && (T.onOverflow = () => {
861
- O = !0;
862
- });
863
- const g = Ue(`${w}${k}${h}`, c, at, T);
864
- if (!O)
865
- return `>${S}
866
- ${c}${g}`;
867
- }
868
- return t = t.replace(/\n+/g, `$&${c}`), `|${S}
869
- ${c}${w}${t}${h}`;
870
- }
871
- function Fs(s, e, t, n) {
872
- const { type: i, value: r } = s, { actualString: o, implicitKey: l, indent: a, indentStep: c, inFlow: p } = e;
873
- if (l && r.includes(`
874
- `) || p && /[[\]{},]/.test(r))
875
- return le(r, e);
876
- if (!r || /^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))
877
- return l || p || !r.includes(`
878
- `) ? le(r, e) : Me(s, e, t, n);
879
- if (!l && !p && i !== A.PLAIN && r.includes(`
880
- `))
881
- return Me(s, e, t, n);
882
- if (Ye(r)) {
883
- if (a === "")
884
- return e.forceBlockIndent = !0, Me(s, e, t, n);
885
- if (l && a === c)
886
- return le(r, e);
887
- }
888
- const f = r.replace(/\n+/g, `$&
889
- ${a}`);
890
- if (o) {
891
- const d = (u) => {
892
- var m;
893
- return u.default && u.tag !== "tag:yaml.org,2002:str" && ((m = u.test) == null ? void 0 : m.test(f));
894
- }, { compat: h, tags: y } = e.doc.schema;
895
- if (y.some(d) || h != null && h.some(d))
896
- return le(r, e);
897
- }
898
- return l ? f : Ue(f, a, Ht, Ve(e, !1));
899
- }
900
- function Ae(s, e, t, n) {
901
- const { implicitKey: i, inFlow: r } = e, o = typeof s.value == "string" ? s : Object.assign({}, s, { value: String(s.value) });
902
- let { type: l } = s;
903
- l !== A.QUOTE_DOUBLE && /[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value) && (l = A.QUOTE_DOUBLE);
904
- const a = (p) => {
905
- switch (p) {
906
- case A.BLOCK_FOLDED:
907
- case A.BLOCK_LITERAL:
908
- return i || r ? le(o.value, e) : Me(o, e, t, n);
909
- case A.QUOTE_DOUBLE:
910
- return Se(o.value, e);
911
- case A.QUOTE_SINGLE:
912
- return ct(o.value, e);
913
- case A.PLAIN:
914
- return Fs(o, e, t, n);
915
- default:
916
- return null;
917
- }
918
- };
919
- let c = a(l);
920
- if (c === null) {
921
- const { defaultKeyType: p, defaultStringType: f } = e.options, d = i && p || f;
922
- if (c = a(d), c === null)
923
- throw new Error(`Unsupported default string type ${d}`);
924
- }
925
- return c;
926
- }
927
- function Xt(s, e) {
928
- const t = Object.assign({
929
- blockQuote: !0,
930
- commentString: js,
931
- defaultKeyType: null,
932
- defaultStringType: "PLAIN",
933
- directives: null,
934
- doubleQuotedAsJSON: !1,
935
- doubleQuotedMinMultiLineLength: 40,
936
- falseStr: "false",
937
- flowCollectionPadding: !0,
938
- indentSeq: !0,
939
- lineWidth: 80,
940
- minContentWidth: 20,
941
- nullStr: "null",
942
- simpleKeys: !1,
943
- singleQuote: null,
944
- trueStr: "true",
945
- verifyAliasOrder: !0
946
- }, s.schema.toStringOptions, e);
947
- let n;
948
- switch (t.collectionStyle) {
949
- case "block":
950
- n = !1;
951
- break;
952
- case "flow":
953
- n = !0;
954
- break;
955
- default:
956
- n = null;
957
- }
958
- return {
959
- anchors: /* @__PURE__ */ new Set(),
960
- doc: s,
961
- flowCollectionPadding: t.flowCollectionPadding ? " " : "",
962
- indent: "",
963
- indentStep: typeof t.indent == "number" ? " ".repeat(t.indent) : " ",
964
- inFlow: n,
965
- options: t
966
- };
967
- }
968
- function Rs(s, e) {
969
- var i;
970
- if (e.tag) {
971
- const r = s.filter((o) => o.tag === e.tag);
972
- if (r.length > 0)
973
- return r.find((o) => o.format === e.format) ?? r[0];
974
- }
975
- let t, n;
976
- if (E(e)) {
977
- n = e.value;
978
- let r = s.filter((o) => {
979
- var l;
980
- return (l = o.identify) == null ? void 0 : l.call(o, n);
981
- });
982
- if (r.length > 1) {
983
- const o = r.filter((l) => l.test);
984
- o.length > 0 && (r = o);
985
- }
986
- t = r.find((o) => o.format === e.format) ?? r.find((o) => !o.format);
987
- } else
988
- n = e, t = s.find((r) => r.nodeClass && n instanceof r.nodeClass);
989
- if (!t) {
990
- const r = ((i = n == null ? void 0 : n.constructor) == null ? void 0 : i.name) ?? typeof n;
991
- throw new Error(`Tag not resolved for ${r} value`);
992
- }
993
- return t;
994
- }
995
- function Us(s, e, { anchors: t, doc: n }) {
996
- if (!n.directives)
997
- return "";
998
- const i = [], r = (E(s) || L(s)) && s.anchor;
999
- r && Yt(r) && (t.add(r), i.push(`&${r}`));
1000
- const o = s.tag ? s.tag : e.default ? null : e.tag;
1001
- return o && i.push(n.directives.tagString(o)), i.join(" ");
1002
- }
1003
- function fe(s, e, t, n) {
1004
- var a;
1005
- if (I(s))
1006
- return s.toString(e, t, n);
1007
- if (x(s)) {
1008
- if (e.doc.directives)
1009
- return s.toString(e);
1010
- if ((a = e.resolvedAliases) != null && a.has(s))
1011
- throw new TypeError("Cannot stringify circular structure without alias nodes");
1012
- e.resolvedAliases ? e.resolvedAliases.add(s) : e.resolvedAliases = /* @__PURE__ */ new Set([s]), s = s.resolve(e.doc);
1013
- }
1014
- let i;
1015
- const r = $(s) ? s : e.doc.createNode(s, { onTagObj: (c) => i = c });
1016
- i || (i = Rs(e.doc.schema.tags, r));
1017
- const o = Us(r, i, e);
1018
- o.length > 0 && (e.indentAtStart = (e.indentAtStart ?? 0) + o.length + 1);
1019
- const l = typeof i.stringify == "function" ? i.stringify(r, e, t, n) : E(r) ? Ae(r, e, t, n) : r.toString(e, t, n);
1020
- return o ? E(r) || l[0] === "{" || l[0] === "[" ? `${o} ${l}` : `${o}
1021
- ${e.indent}${l}` : l;
1022
- }
1023
- function Vs({ key: s, value: e }, t, n, i) {
1024
- const { allNullValues: r, doc: o, indent: l, indentStep: a, options: { commentString: c, indentSeq: p, simpleKeys: f } } = t;
1025
- let d = $(s) && s.comment || null;
1026
- if (f) {
1027
- if (d)
1028
- throw new Error("With simple keys, key nodes cannot have comments");
1029
- if (L(s) || !$(s) && typeof s == "object") {
1030
- const T = "With simple keys, collection cannot be used as a key value";
1031
- throw new Error(T);
1032
- }
1033
- }
1034
- let h = !f && (!s || d && e == null && !t.inFlow || L(s) || (E(s) ? s.type === A.BLOCK_FOLDED || s.type === A.BLOCK_LITERAL : typeof s == "object"));
1035
- t = Object.assign({}, t, {
1036
- allNullValues: !1,
1037
- implicitKey: !h && (f || !r),
1038
- indent: l + a
1039
- });
1040
- let y = !1, u = !1, m = fe(s, t, () => y = !0, () => u = !0);
1041
- if (!h && !t.inFlow && m.length > 1024) {
1042
- if (f)
1043
- throw new Error("With simple keys, single line scalar must not span more than 1024 characters");
1044
- h = !0;
1045
- }
1046
- if (t.inFlow) {
1047
- if (r || e == null)
1048
- return y && n && n(), m === "" ? "?" : h ? `? ${m}` : m;
1049
- } else if (r && !f || e == null && h)
1050
- return m = `? ${m}`, d && !y ? m += H(m, t.indent, c(d)) : u && i && i(), m;
1051
- y && (d = null), h ? (d && (m += H(m, t.indent, c(d))), m = `? ${m}
1052
- ${l}:`) : (m = `${m}:`, d && (m += H(m, t.indent, c(d))));
1053
- let b, w, N;
1054
- $(e) ? (b = !!e.spaceBefore, w = e.commentBefore, N = e.comment) : (b = !1, w = null, N = null, e && typeof e == "object" && (e = o.createNode(e))), t.implicitKey = !1, !h && !d && E(e) && (t.indentAtStart = m.length + 1), u = !1, !p && a.length >= 2 && !t.inFlow && !h && pe(e) && !e.flow && !e.tag && !e.anchor && (t.indent = t.indent.substring(2));
1055
- let S = !1;
1056
- const k = fe(e, t, () => S = !0, () => u = !0);
1057
- let O = " ";
1058
- if (d || b || w) {
1059
- if (O = b ? `
1060
- ` : "", w) {
1061
- const T = c(w);
1062
- O += `
1063
- ${U(T, t.indent)}`;
1064
- }
1065
- k === "" && !t.inFlow ? O === `
1066
- ` && (O = `
1067
-
1068
- `) : O += `
1069
- ${t.indent}`;
1070
- } else if (!h && L(e)) {
1071
- const T = k[0], g = k.indexOf(`
1072
- `), _ = g !== -1, Y = t.inFlow ?? e.flow ?? e.items.length === 0;
1073
- if (_ || !Y) {
1074
- let te = !1;
1075
- if (_ && (T === "&" || T === "!")) {
1076
- let C = k.indexOf(" ");
1077
- T === "&" && C !== -1 && C < g && k[C + 1] === "!" && (C = k.indexOf(" ", C + 1)), (C === -1 || g < C) && (te = !0);
1078
- }
1079
- te || (O = `
1080
- ${t.indent}`);
1081
- }
1082
- } else (k === "" || k[0] === `
1083
- `) && (O = "");
1084
- return m += O + k, t.inFlow ? S && n && n() : N && !S ? m += H(m, t.indent, c(N)) : u && i && i(), m;
1085
- }
1086
- function zt(s, e) {
1087
- (s === "debug" || s === "warn") && (typeof process < "u" && process.emitWarning ? process.emitWarning(e) : console.warn(e));
1088
- }
1089
- const Ie = "<<", V = {
1090
- identify: (s) => s === Ie || typeof s == "symbol" && s.description === Ie,
1091
- default: "key",
1092
- tag: "tag:yaml.org,2002:merge",
1093
- test: /^<<$/,
1094
- resolve: () => Object.assign(new A(Symbol(Ie)), {
1095
- addToJSMap: Zt
1096
- }),
1097
- stringify: () => Ie
1098
- }, Ys = (s, e) => (V.identify(e) || E(e) && (!e.type || e.type === A.PLAIN) && V.identify(e.value)) && (s == null ? void 0 : s.doc.schema.tags.some((t) => t.tag === V.tag && t.default));
1099
- function Zt(s, e, t) {
1100
- if (t = s && x(t) ? t.resolve(s.doc) : t, pe(t))
1101
- for (const n of t.items)
1102
- et(s, e, n);
1103
- else if (Array.isArray(t))
1104
- for (const n of t)
1105
- et(s, e, n);
1106
- else
1107
- et(s, e, t);
1108
- }
1109
- function et(s, e, t) {
1110
- const n = s && x(t) ? t.resolve(s.doc) : t;
1111
- if (!de(n))
1112
- throw new Error("Merge sources must be maps or map aliases");
1113
- const i = n.toJSON(null, s, Map);
1114
- for (const [r, o] of i)
1115
- e instanceof Map ? e.has(r) || e.set(r, o) : e instanceof Set ? e.add(r) : Object.prototype.hasOwnProperty.call(e, r) || Object.defineProperty(e, r, {
1116
- value: o,
1117
- writable: !0,
1118
- enumerable: !0,
1119
- configurable: !0
1120
- });
1121
- return e;
1122
- }
1123
- function xt(s, e, { key: t, value: n }) {
1124
- if ($(t) && t.addToJSMap)
1125
- t.addToJSMap(s, e, n);
1126
- else if (Ys(s, t))
1127
- Zt(s, e, n);
1128
- else {
1129
- const i = P(t, "", s);
1130
- if (e instanceof Map)
1131
- e.set(i, P(n, i, s));
1132
- else if (e instanceof Set)
1133
- e.add(i);
1134
- else {
1135
- const r = Js(t, i, s), o = P(n, r, s);
1136
- r in e ? Object.defineProperty(e, r, {
1137
- value: o,
1138
- writable: !0,
1139
- enumerable: !0,
1140
- configurable: !0
1141
- }) : e[r] = o;
1142
- }
1143
- }
1144
- return e;
1145
- }
1146
- function Js(s, e, t) {
1147
- if (e === null)
1148
- return "";
1149
- if (typeof e != "object")
1150
- return String(e);
1151
- if ($(s) && (t != null && t.doc)) {
1152
- const n = Xt(t.doc, {});
1153
- n.anchors = /* @__PURE__ */ new Set();
1154
- for (const r of t.anchors.keys())
1155
- n.anchors.add(r.anchor);
1156
- n.inFlow = !0, n.inStringifyKey = !0;
1157
- const i = s.toString(n);
1158
- if (!t.mapKeyWarned) {
1159
- let r = JSON.stringify(i);
1160
- r.length > 40 && (r = r.substring(0, 36) + '..."'), zt(t.doc.options.logLevel, `Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`), t.mapKeyWarned = !0;
1161
- }
1162
- return i;
1163
- }
1164
- return JSON.stringify(e);
1165
- }
1166
- function mt(s, e, t) {
1167
- const n = ke(s, void 0, t), i = ke(e, void 0, t);
1168
- return new v(n, i);
1169
- }
1170
- class v {
1171
- constructor(e, t = null) {
1172
- Object.defineProperty(this, D, { value: qt }), this.key = e, this.value = t;
1173
- }
1174
- clone(e) {
1175
- let { key: t, value: n } = this;
1176
- return $(t) && (t = t.clone(e)), $(n) && (n = n.clone(e)), new v(t, n);
1177
- }
1178
- toJSON(e, t) {
1179
- const n = t != null && t.mapAsMap ? /* @__PURE__ */ new Map() : {};
1180
- return xt(t, n, this);
1181
- }
1182
- toString(e, t, n) {
1183
- return e != null && e.doc ? Vs(this, e, t, n) : JSON.stringify(this);
1184
- }
1185
- }
1186
- function es(s, e, t) {
1187
- return (e.inFlow ?? s.flow ? Qs : Gs)(s, e, t);
1188
- }
1189
- function Gs({ comment: s, items: e }, t, { blockItemPrefix: n, flowChars: i, itemIndent: r, onChompKeep: o, onComment: l }) {
1190
- const { indent: a, options: { commentString: c } } = t, p = Object.assign({}, t, { indent: r, type: null });
1191
- let f = !1;
1192
- const d = [];
1193
- for (let y = 0; y < e.length; ++y) {
1194
- const u = e[y];
1195
- let m = null;
1196
- if ($(u))
1197
- !f && u.spaceBefore && d.push(""), De(t, d, u.commentBefore, f), u.comment && (m = u.comment);
1198
- else if (I(u)) {
1199
- const w = $(u.key) ? u.key : null;
1200
- w && (!f && w.spaceBefore && d.push(""), De(t, d, w.commentBefore, f));
1201
- }
1202
- f = !1;
1203
- let b = fe(u, p, () => m = null, () => f = !0);
1204
- m && (b += H(b, r, c(m))), f && m && (f = !1), d.push(n + b);
1205
- }
1206
- let h;
1207
- if (d.length === 0)
1208
- h = i.start + i.end;
1209
- else {
1210
- h = d[0];
1211
- for (let y = 1; y < d.length; ++y) {
1212
- const u = d[y];
1213
- h += u ? `
1214
- ${a}${u}` : `
1215
- `;
1216
- }
1217
- }
1218
- return s ? (h += `
1219
- ` + U(c(s), a), l && l()) : f && o && o(), h;
1220
- }
1221
- function Qs({ items: s }, e, { flowChars: t, itemIndent: n }) {
1222
- const { indent: i, indentStep: r, flowCollectionPadding: o, options: { commentString: l } } = e;
1223
- n += r;
1224
- const a = Object.assign({}, e, {
1225
- indent: n,
1226
- inFlow: !0,
1227
- type: null
1228
- });
1229
- let c = !1, p = 0;
1230
- const f = [];
1231
- for (let y = 0; y < s.length; ++y) {
1232
- const u = s[y];
1233
- let m = null;
1234
- if ($(u))
1235
- u.spaceBefore && f.push(""), De(e, f, u.commentBefore, !1), u.comment && (m = u.comment);
1236
- else if (I(u)) {
1237
- const w = $(u.key) ? u.key : null;
1238
- w && (w.spaceBefore && f.push(""), De(e, f, w.commentBefore, !1), w.comment && (c = !0));
1239
- const N = $(u.value) ? u.value : null;
1240
- N ? (N.comment && (m = N.comment), N.commentBefore && (c = !0)) : u.value == null && (w != null && w.comment) && (m = w.comment);
1241
- }
1242
- m && (c = !0);
1243
- let b = fe(u, a, () => m = null);
1244
- y < s.length - 1 && (b += ","), m && (b += H(b, n, l(m))), !c && (f.length > p || b.includes(`
1245
- `)) && (c = !0), f.push(b), p = f.length;
1246
- }
1247
- const { start: d, end: h } = t;
1248
- if (f.length === 0)
1249
- return d + h;
1250
- if (!c) {
1251
- const y = f.reduce((u, m) => u + m.length + 2, 2);
1252
- c = e.options.lineWidth > 0 && y > e.options.lineWidth;
1253
- }
1254
- if (c) {
1255
- let y = d;
1256
- for (const u of f)
1257
- y += u ? `
1258
- ${r}${i}${u}` : `
1259
- `;
1260
- return `${y}
1261
- ${i}${h}`;
1262
- } else
1263
- return `${d}${o}${f.join(" ")}${o}${h}`;
1264
- }
1265
- function De({ indent: s, options: { commentString: e } }, t, n, i) {
1266
- if (n && i && (n = n.replace(/^\n+/, "")), n) {
1267
- const r = U(e(n), s);
1268
- t.push(r.trimStart());
1269
- }
1270
- }
1271
- function X(s, e) {
1272
- const t = E(e) ? e.value : e;
1273
- for (const n of s)
1274
- if (I(n) && (n.key === e || n.key === t || E(n.key) && n.key.value === t))
1275
- return n;
1276
- }
1277
- class K extends Wt {
1278
- static get tagName() {
1279
- return "tag:yaml.org,2002:map";
1280
- }
1281
- constructor(e) {
1282
- super(J, e), this.items = [];
1283
- }
1284
- /**
1285
- * A generic collection parsing method that can be extended
1286
- * to other node classes that inherit from YAMLMap
1287
- */
1288
- static from(e, t, n) {
1289
- const { keepUndefined: i, replacer: r } = n, o = new this(e), l = (a, c) => {
1290
- if (typeof r == "function")
1291
- c = r.call(t, a, c);
1292
- else if (Array.isArray(r) && !r.includes(a))
1293
- return;
1294
- (c !== void 0 || i) && o.items.push(mt(a, c, n));
1295
- };
1296
- if (t instanceof Map)
1297
- for (const [a, c] of t)
1298
- l(a, c);
1299
- else if (t && typeof t == "object")
1300
- for (const a of Object.keys(t))
1301
- l(a, t[a]);
1302
- return typeof e.sortMapEntries == "function" && o.items.sort(e.sortMapEntries), o;
1303
- }
1304
- /**
1305
- * Adds a value to the collection.
1306
- *
1307
- * @param overwrite - If not set `true`, using a key that is already in the
1308
- * collection will throw. Otherwise, overwrites the previous value.
1309
- */
1310
- add(e, t) {
1311
- var o;
1312
- let n;
1313
- I(e) ? n = e : !e || typeof e != "object" || !("key" in e) ? n = new v(e, e == null ? void 0 : e.value) : n = new v(e.key, e.value);
1314
- const i = X(this.items, n.key), r = (o = this.schema) == null ? void 0 : o.sortMapEntries;
1315
- if (i) {
1316
- if (!t)
1317
- throw new Error(`Key ${n.key} already set`);
1318
- E(i.value) && Qt(n.value) ? i.value.value = n.value : i.value = n.value;
1319
- } else if (r) {
1320
- const l = this.items.findIndex((a) => r(n, a) < 0);
1321
- l === -1 ? this.items.push(n) : this.items.splice(l, 0, n);
1322
- } else
1323
- this.items.push(n);
1324
- }
1325
- delete(e) {
1326
- const t = X(this.items, e);
1327
- return t ? this.items.splice(this.items.indexOf(t), 1).length > 0 : !1;
1328
- }
1329
- get(e, t) {
1330
- const n = X(this.items, e), i = n == null ? void 0 : n.value;
1331
- return (!t && E(i) ? i.value : i) ?? void 0;
1332
- }
1333
- has(e) {
1334
- return !!X(this.items, e);
1335
- }
1336
- set(e, t) {
1337
- this.add(new v(e, t), !0);
1338
- }
1339
- /**
1340
- * @param ctx - Conversion context, originally set in Document#toJS()
1341
- * @param {Class} Type - If set, forces the returned collection type
1342
- * @returns Instance of Type, Map, or Object
1343
- */
1344
- toJSON(e, t, n) {
1345
- const i = n ? new n() : t != null && t.mapAsMap ? /* @__PURE__ */ new Map() : {};
1346
- t != null && t.onCreate && t.onCreate(i);
1347
- for (const r of this.items)
1348
- xt(t, i, r);
1349
- return i;
1350
- }
1351
- toString(e, t, n) {
1352
- if (!e)
1353
- return JSON.stringify(this);
1354
- for (const i of this.items)
1355
- if (!I(i))
1356
- throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);
1357
- return !e.allNullValues && this.hasAllNullValues(!1) && (e = Object.assign({}, e, { allNullValues: !0 })), es(this, e, {
1358
- blockItemPrefix: "",
1359
- flowChars: { start: "{", end: "}" },
1360
- itemIndent: e.indent || "",
1361
- onChompKeep: n,
1362
- onComment: t
1363
- });
1364
- }
1365
- }
1366
- const me = {
1367
- collection: "map",
1368
- default: !0,
1369
- nodeClass: K,
1370
- tag: "tag:yaml.org,2002:map",
1371
- resolve(s, e) {
1372
- return de(s) || e("Expected a mapping for this tag"), s;
1373
- },
1374
- createNode: (s, e, t) => K.from(s, e, t)
1375
- };
1376
- class Q extends Wt {
1377
- static get tagName() {
1378
- return "tag:yaml.org,2002:seq";
1379
- }
1380
- constructor(e) {
1381
- super(he, e), this.items = [];
1382
- }
1383
- add(e) {
1384
- this.items.push(e);
1385
- }
1386
- /**
1387
- * Removes a value from the collection.
1388
- *
1389
- * `key` must contain a representation of an integer for this to succeed.
1390
- * It may be wrapped in a `Scalar`.
1391
- *
1392
- * @returns `true` if the item was found and removed.
1393
- */
1394
- delete(e) {
1395
- const t = Le(e);
1396
- return typeof t != "number" ? !1 : this.items.splice(t, 1).length > 0;
1397
- }
1398
- get(e, t) {
1399
- const n = Le(e);
1400
- if (typeof n != "number")
1401
- return;
1402
- const i = this.items[n];
1403
- return !t && E(i) ? i.value : i;
1404
- }
1405
- /**
1406
- * Checks if the collection includes a value with the key `key`.
1407
- *
1408
- * `key` must contain a representation of an integer for this to succeed.
1409
- * It may be wrapped in a `Scalar`.
1410
- */
1411
- has(e) {
1412
- const t = Le(e);
1413
- return typeof t == "number" && t < this.items.length;
1414
- }
1415
- /**
1416
- * Sets a value in this collection. For `!!set`, `value` needs to be a
1417
- * boolean to add/remove the item from the set.
1418
- *
1419
- * If `key` does not contain a representation of an integer, this will throw.
1420
- * It may be wrapped in a `Scalar`.
1421
- */
1422
- set(e, t) {
1423
- const n = Le(e);
1424
- if (typeof n != "number")
1425
- throw new Error(`Expected a valid index, not ${e}.`);
1426
- const i = this.items[n];
1427
- E(i) && Qt(t) ? i.value = t : this.items[n] = t;
1428
- }
1429
- toJSON(e, t) {
1430
- const n = [];
1431
- t != null && t.onCreate && t.onCreate(n);
1432
- let i = 0;
1433
- for (const r of this.items)
1434
- n.push(P(r, String(i++), t));
1435
- return n;
1436
- }
1437
- toString(e, t, n) {
1438
- return e ? es(this, e, {
1439
- blockItemPrefix: "- ",
1440
- flowChars: { start: "[", end: "]" },
1441
- itemIndent: (e.indent || "") + " ",
1442
- onChompKeep: n,
1443
- onComment: t
1444
- }) : JSON.stringify(this);
1445
- }
1446
- static from(e, t, n) {
1447
- const { replacer: i } = n, r = new this(e);
1448
- if (t && Symbol.iterator in Object(t)) {
1449
- let o = 0;
1450
- for (let l of t) {
1451
- if (typeof i == "function") {
1452
- const a = t instanceof Set ? l : String(o++);
1453
- l = i.call(t, a, l);
1454
- }
1455
- r.items.push(ke(l, void 0, n));
1456
- }
1457
- }
1458
- return r;
1459
- }
1460
- }
1461
- function Le(s) {
1462
- let e = E(s) ? s.value : s;
1463
- return e && typeof e == "string" && (e = Number(e)), typeof e == "number" && Number.isInteger(e) && e >= 0 ? e : null;
1464
- }
1465
- const ye = {
1466
- collection: "seq",
1467
- default: !0,
1468
- nodeClass: Q,
1469
- tag: "tag:yaml.org,2002:seq",
1470
- resolve(s, e) {
1471
- return pe(s) || e("Expected a sequence for this tag"), s;
1472
- },
1473
- createNode: (s, e, t) => Q.from(s, e, t)
1474
- }, Je = {
1475
- identify: (s) => typeof s == "string",
1476
- default: !0,
1477
- tag: "tag:yaml.org,2002:str",
1478
- resolve: (s) => s,
1479
- stringify(s, e, t, n) {
1480
- return e = Object.assign({ actualString: !0 }, e), Ae(s, e, t, n);
1481
- }
1482
- }, Ge = {
1483
- identify: (s) => s == null,
1484
- createNode: () => new A(null),
1485
- default: !0,
1486
- tag: "tag:yaml.org,2002:null",
1487
- test: /^(?:~|[Nn]ull|NULL)?$/,
1488
- resolve: () => new A(null),
1489
- stringify: ({ source: s }, e) => typeof s == "string" && Ge.test.test(s) ? s : e.options.nullStr
1490
- }, yt = {
1491
- identify: (s) => typeof s == "boolean",
1492
- default: !0,
1493
- tag: "tag:yaml.org,2002:bool",
1494
- test: /^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,
1495
- resolve: (s) => new A(s[0] === "t" || s[0] === "T"),
1496
- stringify({ source: s, value: e }, t) {
1497
- if (s && yt.test.test(s)) {
1498
- const n = s[0] === "t" || s[0] === "T";
1499
- if (e === n)
1500
- return s;
1501
- }
1502
- return e ? t.options.trueStr : t.options.falseStr;
1503
- }
1504
- };
1505
- function q({ format: s, minFractionDigits: e, tag: t, value: n }) {
1506
- if (typeof n == "bigint")
1507
- return String(n);
1508
- const i = typeof n == "number" ? n : Number(n);
1509
- if (!isFinite(i))
1510
- return isNaN(i) ? ".nan" : i < 0 ? "-.inf" : ".inf";
1511
- let r = JSON.stringify(n);
1512
- if (!s && e && (!t || t === "tag:yaml.org,2002:float") && /^\d/.test(r)) {
1513
- let o = r.indexOf(".");
1514
- o < 0 && (o = r.length, r += ".");
1515
- let l = e - (r.length - o - 1);
1516
- for (; l-- > 0; )
1517
- r += "0";
1518
- }
1519
- return r;
1520
- }
1521
- const ts = {
1522
- identify: (s) => typeof s == "number",
1523
- default: !0,
1524
- tag: "tag:yaml.org,2002:float",
1525
- test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
1526
- resolve: (s) => s.slice(-3).toLowerCase() === "nan" ? NaN : s[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
1527
- stringify: q
1528
- }, ss = {
1529
- identify: (s) => typeof s == "number",
1530
- default: !0,
1531
- tag: "tag:yaml.org,2002:float",
1532
- format: "EXP",
1533
- test: /^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,
1534
- resolve: (s) => parseFloat(s),
1535
- stringify(s) {
1536
- const e = Number(s.value);
1537
- return isFinite(e) ? e.toExponential() : q(s);
1538
- }
1539
- }, ns = {
1540
- identify: (s) => typeof s == "number",
1541
- default: !0,
1542
- tag: "tag:yaml.org,2002:float",
1543
- test: /^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,
1544
- resolve(s) {
1545
- const e = new A(parseFloat(s)), t = s.indexOf(".");
1546
- return t !== -1 && s[s.length - 1] === "0" && (e.minFractionDigits = s.length - t - 1), e;
1547
- },
1548
- stringify: q
1549
- }, Qe = (s) => typeof s == "bigint" || Number.isInteger(s), gt = (s, e, t, { intAsBigInt: n }) => n ? BigInt(s) : parseInt(s.substring(e), t);
1550
- function is(s, e, t) {
1551
- const { value: n } = s;
1552
- return Qe(n) && n >= 0 ? t + n.toString(e) : q(s);
1553
- }
1554
- const rs = {
1555
- identify: (s) => Qe(s) && s >= 0,
1556
- default: !0,
1557
- tag: "tag:yaml.org,2002:int",
1558
- format: "OCT",
1559
- test: /^0o[0-7]+$/,
1560
- resolve: (s, e, t) => gt(s, 2, 8, t),
1561
- stringify: (s) => is(s, 8, "0o")
1562
- }, os = {
1563
- identify: Qe,
1564
- default: !0,
1565
- tag: "tag:yaml.org,2002:int",
1566
- test: /^[-+]?[0-9]+$/,
1567
- resolve: (s, e, t) => gt(s, 0, 10, t),
1568
- stringify: q
1569
- }, ls = {
1570
- identify: (s) => Qe(s) && s >= 0,
1571
- default: !0,
1572
- tag: "tag:yaml.org,2002:int",
1573
- format: "HEX",
1574
- test: /^0x[0-9a-fA-F]+$/,
1575
- resolve: (s, e, t) => gt(s, 2, 16, t),
1576
- stringify: (s) => is(s, 16, "0x")
1577
- }, Ws = [
1578
- me,
1579
- ye,
1580
- Je,
1581
- Ge,
1582
- yt,
1583
- rs,
1584
- os,
1585
- ls,
1586
- ts,
1587
- ss,
1588
- ns
1589
- ];
1590
- function _t(s) {
1591
- return typeof s == "bigint" || Number.isInteger(s);
1592
- }
1593
- const $e = ({ value: s }) => JSON.stringify(s), Hs = [
1594
- {
1595
- identify: (s) => typeof s == "string",
1596
- default: !0,
1597
- tag: "tag:yaml.org,2002:str",
1598
- resolve: (s) => s,
1599
- stringify: $e
1600
- },
1601
- {
1602
- identify: (s) => s == null,
1603
- createNode: () => new A(null),
1604
- default: !0,
1605
- tag: "tag:yaml.org,2002:null",
1606
- test: /^null$/,
1607
- resolve: () => null,
1608
- stringify: $e
1609
- },
1610
- {
1611
- identify: (s) => typeof s == "boolean",
1612
- default: !0,
1613
- tag: "tag:yaml.org,2002:bool",
1614
- test: /^true$|^false$/,
1615
- resolve: (s) => s === "true",
1616
- stringify: $e
1617
- },
1618
- {
1619
- identify: _t,
1620
- default: !0,
1621
- tag: "tag:yaml.org,2002:int",
1622
- test: /^-?(?:0|[1-9][0-9]*)$/,
1623
- resolve: (s, e, { intAsBigInt: t }) => t ? BigInt(s) : parseInt(s, 10),
1624
- stringify: ({ value: s }) => _t(s) ? s.toString() : JSON.stringify(s)
1625
- },
1626
- {
1627
- identify: (s) => typeof s == "number",
1628
- default: !0,
1629
- tag: "tag:yaml.org,2002:float",
1630
- test: /^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,
1631
- resolve: (s) => parseFloat(s),
1632
- stringify: $e
1633
- }
1634
- ], Xs = {
1635
- default: !0,
1636
- tag: "",
1637
- test: /^/,
1638
- resolve(s, e) {
1639
- return e(`Unresolved plain scalar ${JSON.stringify(s)}`), s;
1640
- }
1641
- }, zs = [me, ye].concat(Hs, Xs), bt = {
1642
- identify: (s) => s instanceof Uint8Array,
1643
- // Buffer inherits from Uint8Array
1644
- default: !1,
1645
- tag: "tag:yaml.org,2002:binary",
1646
- /**
1647
- * Returns a Buffer in node and an Uint8Array in browsers
1648
- *
1649
- * To use the resulting buffer as an image, you'll want to do something like:
1650
- *
1651
- * const blob = new Blob([buffer], { type: 'image/jpeg' })
1652
- * document.querySelector('#photo').src = URL.createObjectURL(blob)
1653
- */
1654
- resolve(s, e) {
1655
- if (typeof Buffer == "function")
1656
- return Buffer.from(s, "base64");
1657
- if (typeof atob == "function") {
1658
- const t = atob(s.replace(/[\n\r]/g, "")), n = new Uint8Array(t.length);
1659
- for (let i = 0; i < t.length; ++i)
1660
- n[i] = t.charCodeAt(i);
1661
- return n;
1662
- } else
1663
- return e("This environment does not support reading binary tags; either Buffer or atob is required"), s;
1664
- },
1665
- stringify({ comment: s, type: e, value: t }, n, i, r) {
1666
- const o = t;
1667
- let l;
1668
- if (typeof Buffer == "function")
1669
- l = o instanceof Buffer ? o.toString("base64") : Buffer.from(o.buffer).toString("base64");
1670
- else if (typeof btoa == "function") {
1671
- let a = "";
1672
- for (let c = 0; c < o.length; ++c)
1673
- a += String.fromCharCode(o[c]);
1674
- l = btoa(a);
1675
- } else
1676
- throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");
1677
- if (e || (e = A.BLOCK_LITERAL), e !== A.QUOTE_DOUBLE) {
1678
- const a = Math.max(n.options.lineWidth - n.indent.length, n.options.minContentWidth), c = Math.ceil(l.length / a), p = new Array(c);
1679
- for (let f = 0, d = 0; f < c; ++f, d += a)
1680
- p[f] = l.substr(d, a);
1681
- l = p.join(e === A.BLOCK_LITERAL ? `
1682
- ` : " ");
1683
- }
1684
- return Ae({ comment: s, type: e, value: l }, n, i, r);
1685
- }
1686
- };
1687
- function as(s, e) {
1688
- if (pe(s))
1689
- for (let t = 0; t < s.items.length; ++t) {
1690
- let n = s.items[t];
1691
- if (!I(n)) {
1692
- if (de(n)) {
1693
- n.items.length > 1 && e("Each pair must have its own sequence indicator");
1694
- const i = n.items[0] || new v(new A(null));
1695
- if (n.commentBefore && (i.key.commentBefore = i.key.commentBefore ? `${n.commentBefore}
1696
- ${i.key.commentBefore}` : n.commentBefore), n.comment) {
1697
- const r = i.value ?? i.key;
1698
- r.comment = r.comment ? `${n.comment}
1699
- ${r.comment}` : n.comment;
1700
- }
1701
- n = i;
1702
- }
1703
- s.items[t] = I(n) ? n : new v(n);
1704
- }
1705
- }
1706
- else
1707
- e("Expected a sequence for this tag");
1708
- return s;
1709
- }
1710
- function cs(s, e, t) {
1711
- const { replacer: n } = t, i = new Q(s);
1712
- i.tag = "tag:yaml.org,2002:pairs";
1713
- let r = 0;
1714
- if (e && Symbol.iterator in Object(e))
1715
- for (let o of e) {
1716
- typeof n == "function" && (o = n.call(e, String(r++), o));
1717
- let l, a;
1718
- if (Array.isArray(o))
1719
- if (o.length === 2)
1720
- l = o[0], a = o[1];
1721
- else
1722
- throw new TypeError(`Expected [key, value] tuple: ${o}`);
1723
- else if (o && o instanceof Object) {
1724
- const c = Object.keys(o);
1725
- if (c.length === 1)
1726
- l = c[0], a = o[l];
1727
- else
1728
- throw new TypeError(`Expected tuple with one key, not ${c.length} keys`);
1729
- } else
1730
- l = o;
1731
- i.items.push(mt(l, a, t));
1732
- }
1733
- return i;
1734
- }
1735
- const wt = {
1736
- collection: "seq",
1737
- default: !1,
1738
- tag: "tag:yaml.org,2002:pairs",
1739
- resolve: as,
1740
- createNode: cs
1741
- };
1742
- class ae extends Q {
1743
- constructor() {
1744
- super(), this.add = K.prototype.add.bind(this), this.delete = K.prototype.delete.bind(this), this.get = K.prototype.get.bind(this), this.has = K.prototype.has.bind(this), this.set = K.prototype.set.bind(this), this.tag = ae.tag;
1745
- }
1746
- /**
1747
- * If `ctx` is given, the return type is actually `Map<unknown, unknown>`,
1748
- * but TypeScript won't allow widening the signature of a child method.
1749
- */
1750
- toJSON(e, t) {
1751
- if (!t)
1752
- return super.toJSON(e);
1753
- const n = /* @__PURE__ */ new Map();
1754
- t != null && t.onCreate && t.onCreate(n);
1755
- for (const i of this.items) {
1756
- let r, o;
1757
- if (I(i) ? (r = P(i.key, "", t), o = P(i.value, r, t)) : r = P(i, "", t), n.has(r))
1758
- throw new Error("Ordered maps must not include duplicate keys");
1759
- n.set(r, o);
1760
- }
1761
- return n;
1762
- }
1763
- static from(e, t, n) {
1764
- const i = cs(e, t, n), r = new this();
1765
- return r.items = i.items, r;
1766
- }
1767
- }
1768
- ae.tag = "tag:yaml.org,2002:omap";
1769
- const St = {
1770
- collection: "seq",
1771
- identify: (s) => s instanceof Map,
1772
- nodeClass: ae,
1773
- default: !1,
1774
- tag: "tag:yaml.org,2002:omap",
1775
- resolve(s, e) {
1776
- const t = as(s, e), n = [];
1777
- for (const { key: i } of t.items)
1778
- E(i) && (n.includes(i.value) ? e(`Ordered maps must not include duplicate keys: ${i.value}`) : n.push(i.value));
1779
- return Object.assign(new ae(), t);
1780
- },
1781
- createNode: (s, e, t) => ae.from(s, e, t)
1782
- };
1783
- function fs({ value: s, source: e }, t) {
1784
- return e && (s ? us : hs).test.test(e) ? e : s ? t.options.trueStr : t.options.falseStr;
1785
- }
1786
- const us = {
1787
- identify: (s) => s === !0,
1788
- default: !0,
1789
- tag: "tag:yaml.org,2002:bool",
1790
- test: /^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,
1791
- resolve: () => new A(!0),
1792
- stringify: fs
1793
- }, hs = {
1794
- identify: (s) => s === !1,
1795
- default: !0,
1796
- tag: "tag:yaml.org,2002:bool",
1797
- test: /^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,
1798
- resolve: () => new A(!1),
1799
- stringify: fs
1800
- }, Zs = {
1801
- identify: (s) => typeof s == "number",
1802
- default: !0,
1803
- tag: "tag:yaml.org,2002:float",
1804
- test: /^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,
1805
- resolve: (s) => s.slice(-3).toLowerCase() === "nan" ? NaN : s[0] === "-" ? Number.NEGATIVE_INFINITY : Number.POSITIVE_INFINITY,
1806
- stringify: q
1807
- }, xs = {
1808
- identify: (s) => typeof s == "number",
1809
- default: !0,
1810
- tag: "tag:yaml.org,2002:float",
1811
- format: "EXP",
1812
- test: /^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,
1813
- resolve: (s) => parseFloat(s.replace(/_/g, "")),
1814
- stringify(s) {
1815
- const e = Number(s.value);
1816
- return isFinite(e) ? e.toExponential() : q(s);
1817
- }
1818
- }, en = {
1819
- identify: (s) => typeof s == "number",
1820
- default: !0,
1821
- tag: "tag:yaml.org,2002:float",
1822
- test: /^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,
1823
- resolve(s) {
1824
- const e = new A(parseFloat(s.replace(/_/g, ""))), t = s.indexOf(".");
1825
- if (t !== -1) {
1826
- const n = s.substring(t + 1).replace(/_/g, "");
1827
- n[n.length - 1] === "0" && (e.minFractionDigits = n.length);
1828
- }
1829
- return e;
1830
- },
1831
- stringify: q
1832
- }, Ee = (s) => typeof s == "bigint" || Number.isInteger(s);
1833
- function We(s, e, t, { intAsBigInt: n }) {
1834
- const i = s[0];
1835
- if ((i === "-" || i === "+") && (e += 1), s = s.substring(e).replace(/_/g, ""), n) {
1836
- switch (t) {
1837
- case 2:
1838
- s = `0b${s}`;
1839
- break;
1840
- case 8:
1841
- s = `0o${s}`;
1842
- break;
1843
- case 16:
1844
- s = `0x${s}`;
1845
- break;
1846
- }
1847
- const o = BigInt(s);
1848
- return i === "-" ? BigInt(-1) * o : o;
1849
- }
1850
- const r = parseInt(s, t);
1851
- return i === "-" ? -1 * r : r;
1852
- }
1853
- function kt(s, e, t) {
1854
- const { value: n } = s;
1855
- if (Ee(n)) {
1856
- const i = n.toString(e);
1857
- return n < 0 ? "-" + t + i.substr(1) : t + i;
1858
- }
1859
- return q(s);
1860
- }
1861
- const tn = {
1862
- identify: Ee,
1863
- default: !0,
1864
- tag: "tag:yaml.org,2002:int",
1865
- format: "BIN",
1866
- test: /^[-+]?0b[0-1_]+$/,
1867
- resolve: (s, e, t) => We(s, 2, 2, t),
1868
- stringify: (s) => kt(s, 2, "0b")
1869
- }, sn = {
1870
- identify: Ee,
1871
- default: !0,
1872
- tag: "tag:yaml.org,2002:int",
1873
- format: "OCT",
1874
- test: /^[-+]?0[0-7_]+$/,
1875
- resolve: (s, e, t) => We(s, 1, 8, t),
1876
- stringify: (s) => kt(s, 8, "0")
1877
- }, nn = {
1878
- identify: Ee,
1879
- default: !0,
1880
- tag: "tag:yaml.org,2002:int",
1881
- test: /^[-+]?[0-9][0-9_]*$/,
1882
- resolve: (s, e, t) => We(s, 0, 10, t),
1883
- stringify: q
1884
- }, rn = {
1885
- identify: Ee,
1886
- default: !0,
1887
- tag: "tag:yaml.org,2002:int",
1888
- format: "HEX",
1889
- test: /^[-+]?0x[0-9a-fA-F_]+$/,
1890
- resolve: (s, e, t) => We(s, 2, 16, t),
1891
- stringify: (s) => kt(s, 16, "0x")
1892
- };
1893
- class ce extends K {
1894
- constructor(e) {
1895
- super(e), this.tag = ce.tag;
1896
- }
1897
- add(e) {
1898
- let t;
1899
- I(e) ? t = e : e && typeof e == "object" && "key" in e && "value" in e && e.value === null ? t = new v(e.key, null) : t = new v(e, null), X(this.items, t.key) || this.items.push(t);
1900
- }
1901
- /**
1902
- * If `keepPair` is `true`, returns the Pair matching `key`.
1903
- * Otherwise, returns the value of that Pair's key.
1904
- */
1905
- get(e, t) {
1906
- const n = X(this.items, e);
1907
- return !t && I(n) ? E(n.key) ? n.key.value : n.key : n;
1908
- }
1909
- set(e, t) {
1910
- if (typeof t != "boolean")
1911
- throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);
1912
- const n = X(this.items, e);
1913
- n && !t ? this.items.splice(this.items.indexOf(n), 1) : !n && t && this.items.push(new v(e));
1914
- }
1915
- toJSON(e, t) {
1916
- return super.toJSON(e, t, Set);
1917
- }
1918
- toString(e, t, n) {
1919
- if (!e)
1920
- return JSON.stringify(this);
1921
- if (this.hasAllNullValues(!0))
1922
- return super.toString(Object.assign({}, e, { allNullValues: !0 }), t, n);
1923
- throw new Error("Set items must all have null values");
1924
- }
1925
- static from(e, t, n) {
1926
- const { replacer: i } = n, r = new this(e);
1927
- if (t && Symbol.iterator in Object(t))
1928
- for (let o of t)
1929
- typeof i == "function" && (o = i.call(t, o, o)), r.items.push(mt(o, null, n));
1930
- return r;
1931
- }
1932
- }
1933
- ce.tag = "tag:yaml.org,2002:set";
1934
- const Nt = {
1935
- collection: "map",
1936
- identify: (s) => s instanceof Set,
1937
- nodeClass: ce,
1938
- default: !1,
1939
- tag: "tag:yaml.org,2002:set",
1940
- createNode: (s, e, t) => ce.from(s, e, t),
1941
- resolve(s, e) {
1942
- if (de(s)) {
1943
- if (s.hasAllNullValues(!0))
1944
- return Object.assign(new ce(), s);
1945
- e("Set items must all have null values");
1946
- } else
1947
- e("Expected a mapping for this tag");
1948
- return s;
1949
- }
1950
- };
1951
- function Ot(s, e) {
1952
- const t = s[0], n = t === "-" || t === "+" ? s.substring(1) : s, i = (o) => e ? BigInt(o) : Number(o), r = n.replace(/_/g, "").split(":").reduce((o, l) => o * i(60) + i(l), i(0));
1953
- return t === "-" ? i(-1) * r : r;
1954
- }
1955
- function ds(s) {
1956
- let { value: e } = s, t = (o) => o;
1957
- if (typeof e == "bigint")
1958
- t = (o) => BigInt(o);
1959
- else if (isNaN(e) || !isFinite(e))
1960
- return q(s);
1961
- let n = "";
1962
- e < 0 && (n = "-", e *= t(-1));
1963
- const i = t(60), r = [e % i];
1964
- return e < 60 ? r.unshift(0) : (e = (e - r[0]) / i, r.unshift(e % i), e >= 60 && (e = (e - r[0]) / i, r.unshift(e))), n + r.map((o) => String(o).padStart(2, "0")).join(":").replace(/000000\d*$/, "");
1965
- }
1966
- const ps = {
1967
- identify: (s) => typeof s == "bigint" || Number.isInteger(s),
1968
- default: !0,
1969
- tag: "tag:yaml.org,2002:int",
1970
- format: "TIME",
1971
- test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,
1972
- resolve: (s, e, { intAsBigInt: t }) => Ot(s, t),
1973
- stringify: ds
1974
- }, ms = {
1975
- identify: (s) => typeof s == "number",
1976
- default: !0,
1977
- tag: "tag:yaml.org,2002:float",
1978
- format: "TIME",
1979
- test: /^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,
1980
- resolve: (s) => Ot(s, !1),
1981
- stringify: ds
1982
- }, He = {
1983
- identify: (s) => s instanceof Date,
1984
- default: !0,
1985
- tag: "tag:yaml.org,2002:timestamp",
1986
- // If the time zone is omitted, the timestamp is assumed to be specified in UTC. The time part
1987
- // may be omitted altogether, resulting in a date format. In such a case, the time part is
1988
- // assumed to be 00:00:00Z (start of day, UTC).
1989
- test: RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),
1990
- resolve(s) {
1991
- const e = s.match(He.test);
1992
- if (!e)
1993
- throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");
1994
- const [, t, n, i, r, o, l] = e.map(Number), a = e[7] ? Number((e[7] + "00").substr(1, 3)) : 0;
1995
- let c = Date.UTC(t, n - 1, i, r || 0, o || 0, l || 0, a);
1996
- const p = e[8];
1997
- if (p && p !== "Z") {
1998
- let f = Ot(p, !1);
1999
- Math.abs(f) < 30 && (f *= 60), c -= 6e4 * f;
2000
- }
2001
- return new Date(c);
2002
- },
2003
- stringify: ({ value: s }) => s.toISOString().replace(/(T00:00:00)?\.000Z$/, "")
2004
- }, Ct = [
2005
- me,
2006
- ye,
2007
- Je,
2008
- Ge,
2009
- us,
2010
- hs,
2011
- tn,
2012
- sn,
2013
- nn,
2014
- rn,
2015
- Zs,
2016
- xs,
2017
- en,
2018
- bt,
2019
- V,
2020
- St,
2021
- wt,
2022
- Nt,
2023
- ps,
2024
- ms,
2025
- He
2026
- ], vt = /* @__PURE__ */ new Map([
2027
- ["core", Ws],
2028
- ["failsafe", [me, ye, Je]],
2029
- ["json", zs],
2030
- ["yaml11", Ct],
2031
- ["yaml-1.1", Ct]
2032
- ]), Bt = {
2033
- binary: bt,
2034
- bool: yt,
2035
- float: ns,
2036
- floatExp: ss,
2037
- floatNaN: ts,
2038
- floatTime: ms,
2039
- int: os,
2040
- intHex: ls,
2041
- intOct: rs,
2042
- intTime: ps,
2043
- map: me,
2044
- merge: V,
2045
- null: Ge,
2046
- omap: St,
2047
- pairs: wt,
2048
- seq: ye,
2049
- set: Nt,
2050
- timestamp: He
2051
- }, on = {
2052
- "tag:yaml.org,2002:binary": bt,
2053
- "tag:yaml.org,2002:merge": V,
2054
- "tag:yaml.org,2002:omap": St,
2055
- "tag:yaml.org,2002:pairs": wt,
2056
- "tag:yaml.org,2002:set": Nt,
2057
- "tag:yaml.org,2002:timestamp": He
2058
- };
2059
- function tt(s, e, t) {
2060
- const n = vt.get(e);
2061
- if (n && !s)
2062
- return t && !n.includes(V) ? n.concat(V) : n.slice();
2063
- let i = n;
2064
- if (!i)
2065
- if (Array.isArray(s))
2066
- i = [];
2067
- else {
2068
- const r = Array.from(vt.keys()).filter((o) => o !== "yaml11").map((o) => JSON.stringify(o)).join(", ");
2069
- throw new Error(`Unknown schema "${e}"; use one of ${r} or define customTags array`);
2070
- }
2071
- if (Array.isArray(s))
2072
- for (const r of s)
2073
- i = i.concat(r);
2074
- else typeof s == "function" && (i = s(i.slice()));
2075
- return t && (i = i.concat(V)), i.reduce((r, o) => {
2076
- const l = typeof o == "string" ? Bt[o] : o;
2077
- if (!l) {
2078
- const a = JSON.stringify(o), c = Object.keys(Bt).map((p) => JSON.stringify(p)).join(", ");
2079
- throw new Error(`Unknown custom tag ${a}; use one of ${c}`);
2080
- }
2081
- return r.includes(l) || r.push(l), r;
2082
- }, []);
2083
- }
2084
- const ln = (s, e) => s.key < e.key ? -1 : s.key > e.key ? 1 : 0;
2085
- class Xe {
2086
- constructor({ compat: e, customTags: t, merge: n, resolveKnownTags: i, schema: r, sortMapEntries: o, toStringDefaults: l }) {
2087
- this.compat = Array.isArray(e) ? tt(e, "compat") : e ? tt(null, e) : null, this.name = typeof r == "string" && r || "core", this.knownTags = i ? on : {}, this.tags = tt(t, this.name, n), this.toStringOptions = l ?? null, Object.defineProperty(this, J, { value: me }), Object.defineProperty(this, R, { value: Je }), Object.defineProperty(this, he, { value: ye }), this.sortMapEntries = typeof o == "function" ? o : o === !0 ? ln : null;
2088
- }
2089
- clone() {
2090
- const e = Object.create(Xe.prototype, Object.getOwnPropertyDescriptors(this));
2091
- return e.tags = this.tags.slice(), e;
2092
- }
2093
- }
2094
- function an(s, e) {
2095
- var a;
2096
- const t = [];
2097
- let n = e.directives === !0;
2098
- if (e.directives !== !1 && s.directives) {
2099
- const c = s.directives.toString(s);
2100
- c ? (t.push(c), n = !0) : s.directives.docStart && (n = !0);
2101
- }
2102
- n && t.push("---");
2103
- const i = Xt(s, e), { commentString: r } = i.options;
2104
- if (s.commentBefore) {
2105
- t.length !== 1 && t.unshift("");
2106
- const c = r(s.commentBefore);
2107
- t.unshift(U(c, ""));
2108
- }
2109
- let o = !1, l = null;
2110
- if (s.contents) {
2111
- if ($(s.contents)) {
2112
- if (s.contents.spaceBefore && n && t.push(""), s.contents.commentBefore) {
2113
- const f = r(s.contents.commentBefore);
2114
- t.push(U(f, ""));
2115
- }
2116
- i.forceBlockIndent = !!s.comment, l = s.contents.comment;
2117
- }
2118
- const c = l ? void 0 : () => o = !0;
2119
- let p = fe(s.contents, i, () => l = null, c);
2120
- l && (p += H(p, "", r(l))), (p[0] === "|" || p[0] === ">") && t[t.length - 1] === "---" ? t[t.length - 1] = `--- ${p}` : t.push(p);
2121
- } else
2122
- t.push(fe(s.contents, i));
2123
- if ((a = s.directives) != null && a.docEnd)
2124
- if (s.comment) {
2125
- const c = r(s.comment);
2126
- c.includes(`
2127
- `) ? (t.push("..."), t.push(U(c, ""))) : t.push(`... ${c}`);
2128
- } else
2129
- t.push("...");
2130
- else {
2131
- let c = s.comment;
2132
- c && o && (c = c.replace(/^\n+/, "")), c && ((!o || l) && t[t.length - 1] !== "" && t.push(""), t.push(U(r(c), "")));
2133
- }
2134
- return t.join(`
2135
- `) + `
2136
- `;
2137
- }
2138
- class ge {
2139
- constructor(e, t, n) {
2140
- this.commentBefore = null, this.comment = null, this.errors = [], this.warnings = [], Object.defineProperty(this, D, { value: lt });
2141
- let i = null;
2142
- typeof t == "function" || Array.isArray(t) ? i = t : n === void 0 && t && (n = t, t = void 0);
2143
- const r = Object.assign({
2144
- intAsBigInt: !1,
2145
- keepSourceTokens: !1,
2146
- logLevel: "warn",
2147
- prettyErrors: !0,
2148
- strict: !0,
2149
- stringKeys: !1,
2150
- uniqueKeys: !0,
2151
- version: "1.2"
2152
- }, n);
2153
- this.options = r;
2154
- let { version: o } = r;
2155
- n != null && n._directives ? (this.directives = n._directives.atDocument(), this.directives.yaml.explicit && (o = this.directives.yaml.version)) : this.directives = new B({ version: o }), this.setSchema(o, n), this.contents = e === void 0 ? null : this.createNode(e, i, n);
2156
- }
2157
- /**
2158
- * Create a deep copy of this Document and its contents.
2159
- *
2160
- * Custom Node values that inherit from `Object` still refer to their original instances.
2161
- */
2162
- clone() {
2163
- const e = Object.create(ge.prototype, {
2164
- [D]: { value: lt }
2165
- });
2166
- return e.commentBefore = this.commentBefore, e.comment = this.comment, e.errors = this.errors.slice(), e.warnings = this.warnings.slice(), e.options = Object.assign({}, this.options), this.directives && (e.directives = this.directives.clone()), e.schema = this.schema.clone(), e.contents = $(this.contents) ? this.contents.clone(e.schema) : this.contents, this.range && (e.range = this.range.slice()), e;
2167
- }
2168
- /** Adds a value to the document. */
2169
- add(e) {
2170
- se(this.contents) && this.contents.add(e);
2171
- }
2172
- /** Adds a value to the document. */
2173
- addIn(e, t) {
2174
- se(this.contents) && this.contents.addIn(e, t);
2175
- }
2176
- /**
2177
- * Create a new `Alias` node, ensuring that the target `node` has the required anchor.
2178
- *
2179
- * If `node` already has an anchor, `name` is ignored.
2180
- * Otherwise, the `node.anchor` value will be set to `name`,
2181
- * or if an anchor with that name is already present in the document,
2182
- * `name` will be used as a prefix for a new unique anchor.
2183
- * If `name` is undefined, the generated anchor will use 'a' as a prefix.
2184
- */
2185
- createAlias(e, t) {
2186
- if (!e.anchor) {
2187
- const n = Jt(this);
2188
- e.anchor = // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
2189
- !t || n.has(t) ? Gt(t || "a", n) : t;
2190
- }
2191
- return new Re(e.anchor);
2192
- }
2193
- createNode(e, t, n) {
2194
- let i;
2195
- if (typeof t == "function")
2196
- e = t.call({ "": e }, "", e), i = t;
2197
- else if (Array.isArray(t)) {
2198
- const m = (w) => typeof w == "number" || w instanceof String || w instanceof Number, b = t.filter(m).map(String);
2199
- b.length > 0 && (t = t.concat(b)), i = t;
2200
- } else n === void 0 && t && (n = t, t = void 0);
2201
- const { aliasDuplicateObjects: r, anchorPrefix: o, flow: l, keepUndefined: a, onTagObj: c, tag: p } = n ?? {}, { onAnchor: f, setAnchors: d, sourceObjects: h } = Ks(
2202
- this,
2203
- // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
2204
- o || "a"
2205
- ), y = {
2206
- aliasDuplicateObjects: r ?? !0,
2207
- keepUndefined: a ?? !1,
2208
- onAnchor: f,
2209
- onTagObj: c,
2210
- replacer: i,
2211
- schema: this.schema,
2212
- sourceObjects: h
2213
- }, u = ke(e, p, y);
2214
- return l && L(u) && (u.flow = !0), d(), u;
2215
- }
2216
- /**
2217
- * Convert a key and a value into a `Pair` using the current schema,
2218
- * recursively wrapping all values as `Scalar` or `Collection` nodes.
2219
- */
2220
- createPair(e, t, n = {}) {
2221
- const i = this.createNode(e, null, n), r = this.createNode(t, null, n);
2222
- return new v(i, r);
2223
- }
2224
- /**
2225
- * Removes a value from the document.
2226
- * @returns `true` if the item was found and removed.
2227
- */
2228
- delete(e) {
2229
- return se(this.contents) ? this.contents.delete(e) : !1;
2230
- }
2231
- /**
2232
- * Removes a value from the document.
2233
- * @returns `true` if the item was found and removed.
2234
- */
2235
- deleteIn(e) {
2236
- return we(e) ? this.contents == null ? !1 : (this.contents = null, !0) : se(this.contents) ? this.contents.deleteIn(e) : !1;
2237
- }
2238
- /**
2239
- * Returns item at `key`, or `undefined` if not found. By default unwraps
2240
- * scalar values from their surrounding node; to disable set `keepScalar` to
2241
- * `true` (collections are always returned intact).
2242
- */
2243
- get(e, t) {
2244
- return L(this.contents) ? this.contents.get(e, t) : void 0;
2245
- }
2246
- /**
2247
- * Returns item at `path`, or `undefined` if not found. By default unwraps
2248
- * scalar values from their surrounding node; to disable set `keepScalar` to
2249
- * `true` (collections are always returned intact).
2250
- */
2251
- getIn(e, t) {
2252
- return we(e) ? !t && E(this.contents) ? this.contents.value : this.contents : L(this.contents) ? this.contents.getIn(e, t) : void 0;
2253
- }
2254
- /**
2255
- * Checks if the document includes a value with the key `key`.
2256
- */
2257
- has(e) {
2258
- return L(this.contents) ? this.contents.has(e) : !1;
2259
- }
2260
- /**
2261
- * Checks if the document includes a value at `path`.
2262
- */
2263
- hasIn(e) {
2264
- return we(e) ? this.contents !== void 0 : L(this.contents) ? this.contents.hasIn(e) : !1;
2265
- }
2266
- /**
2267
- * Sets a value in this document. For `!!set`, `value` needs to be a
2268
- * boolean to add/remove the item from the set.
2269
- */
2270
- set(e, t) {
2271
- this.contents == null ? this.contents = Pe(this.schema, [e], t) : se(this.contents) && this.contents.set(e, t);
2272
- }
2273
- /**
2274
- * Sets a value in this document. For `!!set`, `value` needs to be a
2275
- * boolean to add/remove the item from the set.
2276
- */
2277
- setIn(e, t) {
2278
- we(e) ? this.contents = t : this.contents == null ? this.contents = Pe(this.schema, Array.from(e), t) : se(this.contents) && this.contents.setIn(e, t);
2279
- }
2280
- /**
2281
- * Change the YAML version and schema used by the document.
2282
- * A `null` version disables support for directives, explicit tags, anchors, and aliases.
2283
- * It also requires the `schema` option to be given as a `Schema` instance value.
2284
- *
2285
- * Overrides all previously set schema options.
2286
- */
2287
- setSchema(e, t = {}) {
2288
- typeof e == "number" && (e = String(e));
2289
- let n;
2290
- switch (e) {
2291
- case "1.1":
2292
- this.directives ? this.directives.yaml.version = "1.1" : this.directives = new B({ version: "1.1" }), n = { resolveKnownTags: !1, schema: "yaml-1.1" };
2293
- break;
2294
- case "1.2":
2295
- case "next":
2296
- this.directives ? this.directives.yaml.version = e : this.directives = new B({ version: e }), n = { resolveKnownTags: !0, schema: "core" };
2297
- break;
2298
- case null:
2299
- this.directives && delete this.directives, n = null;
2300
- break;
2301
- default: {
2302
- const i = JSON.stringify(e);
2303
- throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`);
2304
- }
2305
- }
2306
- if (t.schema instanceof Object)
2307
- this.schema = t.schema;
2308
- else if (n)
2309
- this.schema = new Xe(Object.assign(n, t));
2310
- else
2311
- throw new Error("With a null YAML version, the { schema: Schema } option is required");
2312
- }
2313
- // json & jsonArg are only used from toJSON()
2314
- toJS({ json: e, jsonArg: t, mapAsMap: n, maxAliasCount: i, onAnchor: r, reviver: o } = {}) {
2315
- const l = {
2316
- anchors: /* @__PURE__ */ new Map(),
2317
- doc: this,
2318
- keep: !e,
2319
- mapAsMap: n === !0,
2320
- mapKeyWarned: !1,
2321
- maxAliasCount: typeof i == "number" ? i : 100
2322
- }, a = P(this.contents, t ?? "", l);
2323
- if (typeof r == "function")
2324
- for (const { count: c, res: p } of l.anchors.values())
2325
- r(p, c);
2326
- return typeof o == "function" ? oe(o, { "": a }, "", a) : a;
2327
- }
2328
- /**
2329
- * A JSON representation of the document `contents`.
2330
- *
2331
- * @param jsonArg Used by `JSON.stringify` to indicate the array index or
2332
- * property name.
2333
- */
2334
- toJSON(e, t) {
2335
- return this.toJS({ json: !0, jsonArg: e, mapAsMap: !1, onAnchor: t });
2336
- }
2337
- /** A YAML representation of the document. */
2338
- toString(e = {}) {
2339
- if (this.errors.length > 0)
2340
- throw new Error("Document with errors cannot be stringified");
2341
- if ("indent" in e && (!Number.isInteger(e.indent) || Number(e.indent) <= 0)) {
2342
- const t = JSON.stringify(e.indent);
2343
- throw new Error(`"indent" option must be a positive integer, not ${t}`);
2344
- }
2345
- return an(this, e);
2346
- }
2347
- }
2348
- function se(s) {
2349
- if (L(s))
2350
- return !0;
2351
- throw new Error("Expected a YAML collection as document contents");
2352
- }
2353
- class At extends Error {
2354
- constructor(e, t, n, i) {
2355
- super(), this.name = e, this.code = n, this.message = i, this.pos = t;
2356
- }
2357
- }
2358
- class z extends At {
2359
- constructor(e, t, n) {
2360
- super("YAMLParseError", e, t, n);
2361
- }
2362
- }
2363
- class ys extends At {
2364
- constructor(e, t, n) {
2365
- super("YAMLWarning", e, t, n);
2366
- }
2367
- }
2368
- const je = (s, e) => (t) => {
2369
- if (t.pos[0] === -1)
2370
- return;
2371
- t.linePos = t.pos.map((l) => e.linePos(l));
2372
- const { line: n, col: i } = t.linePos[0];
2373
- t.message += ` at line ${n}, column ${i}`;
2374
- let r = i - 1, o = s.substring(e.lineStarts[n - 1], e.lineStarts[n]).replace(/[\n\r]+$/, "");
2375
- if (r >= 60 && o.length > 80) {
2376
- const l = Math.min(r - 39, o.length - 79);
2377
- o = "…" + o.substring(l), r -= l - 1;
2378
- }
2379
- if (o.length > 80 && (o = o.substring(0, 79) + "…"), n > 1 && /^ *$/.test(o.substring(0, r))) {
2380
- let l = s.substring(e.lineStarts[n - 2], e.lineStarts[n - 1]);
2381
- l.length > 80 && (l = l.substring(0, 79) + `…
2382
- `), o = l + o;
2383
- }
2384
- if (/[^ ]/.test(o)) {
2385
- let l = 1;
2386
- const a = t.linePos[1];
2387
- a && a.line === n && a.col > i && (l = Math.max(1, Math.min(a.col - i, 80 - r)));
2388
- const c = " ".repeat(r) + "^".repeat(l);
2389
- t.message += `:
2390
-
2391
- ${o}
2392
- ${c}
2393
- `;
2394
- }
2395
- };
2396
- function ue(s, { flow: e, indicator: t, next: n, offset: i, onError: r, parentIndent: o, startOnNewline: l }) {
2397
- let a = !1, c = l, p = l, f = "", d = "", h = !1, y = !1, u = null, m = null, b = null, w = null, N = null, S = null, k = null;
2398
- for (const g of s)
2399
- switch (y && (g.type !== "space" && g.type !== "newline" && g.type !== "comma" && r(g.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), y = !1), u && (c && g.type !== "comment" && g.type !== "newline" && r(u, "TAB_AS_INDENT", "Tabs are not allowed as indentation"), u = null), g.type) {
2400
- case "space":
2401
- !e && (t !== "doc-start" || (n == null ? void 0 : n.type) !== "flow-collection") && g.source.includes(" ") && (u = g), p = !0;
2402
- break;
2403
- case "comment": {
2404
- p || r(g, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
2405
- const _ = g.source.substring(1) || " ";
2406
- f ? f += d + _ : f = _, d = "", c = !1;
2407
- break;
2408
- }
2409
- case "newline":
2410
- c ? f ? f += g.source : a = !0 : d += g.source, c = !0, h = !0, (m || b) && (w = g), p = !0;
2411
- break;
2412
- case "anchor":
2413
- m && r(g, "MULTIPLE_ANCHORS", "A node can have at most one anchor"), g.source.endsWith(":") && r(g.offset + g.source.length - 1, "BAD_ALIAS", "Anchor ending in : is ambiguous", !0), m = g, k === null && (k = g.offset), c = !1, p = !1, y = !0;
2414
- break;
2415
- case "tag": {
2416
- b && r(g, "MULTIPLE_TAGS", "A node can have at most one tag"), b = g, k === null && (k = g.offset), c = !1, p = !1, y = !0;
2417
- break;
2418
- }
2419
- case t:
2420
- (m || b) && r(g, "BAD_PROP_ORDER", `Anchors and tags must be after the ${g.source} indicator`), S && r(g, "UNEXPECTED_TOKEN", `Unexpected ${g.source} in ${e ?? "collection"}`), S = g, c = t === "seq-item-ind" || t === "explicit-key-ind", p = !1;
2421
- break;
2422
- case "comma":
2423
- if (e) {
2424
- N && r(g, "UNEXPECTED_TOKEN", `Unexpected , in ${e}`), N = g, c = !1, p = !1;
2425
- break;
2426
- }
2427
- // else fallthrough
2428
- default:
2429
- r(g, "UNEXPECTED_TOKEN", `Unexpected ${g.type} token`), c = !1, p = !1;
2430
- }
2431
- const O = s[s.length - 1], T = O ? O.offset + O.source.length : i;
2432
- return y && n && n.type !== "space" && n.type !== "newline" && n.type !== "comma" && (n.type !== "scalar" || n.source !== "") && r(n.offset, "MISSING_CHAR", "Tags and anchors must be separated from the next token by white space"), u && (c && u.indent <= o || (n == null ? void 0 : n.type) === "block-map" || (n == null ? void 0 : n.type) === "block-seq") && r(u, "TAB_AS_INDENT", "Tabs are not allowed as indentation"), {
2433
- comma: N,
2434
- found: S,
2435
- spaceBefore: a,
2436
- comment: f,
2437
- hasNewline: h,
2438
- anchor: m,
2439
- tag: b,
2440
- newlineAfterProp: w,
2441
- end: T,
2442
- start: k ?? T
2443
- };
2444
- }
2445
- function Ne(s) {
2446
- if (!s)
2447
- return null;
2448
- switch (s.type) {
2449
- case "alias":
2450
- case "scalar":
2451
- case "double-quoted-scalar":
2452
- case "single-quoted-scalar":
2453
- if (s.source.includes(`
2454
- `))
2455
- return !0;
2456
- if (s.end) {
2457
- for (const e of s.end)
2458
- if (e.type === "newline")
2459
- return !0;
2460
- }
2461
- return !1;
2462
- case "flow-collection":
2463
- for (const e of s.items) {
2464
- for (const t of e.start)
2465
- if (t.type === "newline")
2466
- return !0;
2467
- if (e.sep) {
2468
- for (const t of e.sep)
2469
- if (t.type === "newline")
2470
- return !0;
2471
- }
2472
- if (Ne(e.key) || Ne(e.value))
2473
- return !0;
2474
- }
2475
- return !1;
2476
- default:
2477
- return !0;
2478
- }
2479
- }
2480
- function ut(s, e, t) {
2481
- if ((e == null ? void 0 : e.type) === "flow-collection") {
2482
- const n = e.end[0];
2483
- n.indent === s && (n.source === "]" || n.source === "}") && Ne(e) && t(n, "BAD_INDENT", "Flow end indicator should be more indented than parent", !0);
2484
- }
2485
- }
2486
- function gs(s, e, t) {
2487
- const { uniqueKeys: n } = s.options;
2488
- if (n === !1)
2489
- return !1;
2490
- const i = typeof n == "function" ? n : (r, o) => r === o || E(r) && E(o) && r.value === o.value;
2491
- return e.some((r) => i(r.key, t));
2492
- }
2493
- const Mt = "All mapping items must start at the same column";
2494
- function cn({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
2495
- var p;
2496
- const o = (r == null ? void 0 : r.nodeClass) ?? K, l = new o(t.schema);
2497
- t.atRoot && (t.atRoot = !1);
2498
- let a = n.offset, c = null;
2499
- for (const f of n.items) {
2500
- const { start: d, key: h, sep: y, value: u } = f, m = ue(d, {
2501
- indicator: "explicit-key-ind",
2502
- next: h ?? (y == null ? void 0 : y[0]),
2503
- offset: a,
2504
- onError: i,
2505
- parentIndent: n.indent,
2506
- startOnNewline: !0
2507
- }), b = !m.found;
2508
- if (b) {
2509
- if (h && (h.type === "block-seq" ? i(a, "BLOCK_AS_IMPLICIT_KEY", "A block sequence may not be used as an implicit map key") : "indent" in h && h.indent !== n.indent && i(a, "BAD_INDENT", Mt)), !m.anchor && !m.tag && !y) {
2510
- c = m.end, m.comment && (l.comment ? l.comment += `
2511
- ` + m.comment : l.comment = m.comment);
2512
- continue;
2513
- }
2514
- (m.newlineAfterProp || Ne(h)) && i(h ?? d[d.length - 1], "MULTILINE_IMPLICIT_KEY", "Implicit keys need to be on a single line");
2515
- } else ((p = m.found) == null ? void 0 : p.indent) !== n.indent && i(a, "BAD_INDENT", Mt);
2516
- t.atKey = !0;
2517
- const w = m.end, N = h ? s(t, h, m, i) : e(t, w, d, null, m, i);
2518
- t.schema.compat && ut(n.indent, h, i), t.atKey = !1, gs(t, l.items, N) && i(w, "DUPLICATE_KEY", "Map keys must be unique");
2519
- const S = ue(y ?? [], {
2520
- indicator: "map-value-ind",
2521
- next: u,
2522
- offset: N.range[2],
2523
- onError: i,
2524
- parentIndent: n.indent,
2525
- startOnNewline: !h || h.type === "block-scalar"
2526
- });
2527
- if (a = S.end, S.found) {
2528
- b && ((u == null ? void 0 : u.type) === "block-map" && !S.hasNewline && i(a, "BLOCK_AS_IMPLICIT_KEY", "Nested mappings are not allowed in compact mappings"), t.options.strict && m.start < S.found.offset - 1024 && i(N.range, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));
2529
- const k = u ? s(t, u, S, i) : e(t, a, y, null, S, i);
2530
- t.schema.compat && ut(n.indent, u, i), a = k.range[2];
2531
- const O = new v(N, k);
2532
- t.options.keepSourceTokens && (O.srcToken = f), l.items.push(O);
2533
- } else {
2534
- b && i(N.range, "MISSING_CHAR", "Implicit map keys need to be followed by map values"), S.comment && (N.comment ? N.comment += `
2535
- ` + S.comment : N.comment = S.comment);
2536
- const k = new v(N);
2537
- t.options.keepSourceTokens && (k.srcToken = f), l.items.push(k);
2538
- }
2539
- }
2540
- return c && c < a && i(c, "IMPOSSIBLE", "Map comment with trailing content"), l.range = [n.offset, a, c ?? a], l;
2541
- }
2542
- function fn({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
2543
- const o = (r == null ? void 0 : r.nodeClass) ?? Q, l = new o(t.schema);
2544
- t.atRoot && (t.atRoot = !1), t.atKey && (t.atKey = !1);
2545
- let a = n.offset, c = null;
2546
- for (const { start: p, value: f } of n.items) {
2547
- const d = ue(p, {
2548
- indicator: "seq-item-ind",
2549
- next: f,
2550
- offset: a,
2551
- onError: i,
2552
- parentIndent: n.indent,
2553
- startOnNewline: !0
2554
- });
2555
- if (!d.found)
2556
- if (d.anchor || d.tag || f)
2557
- f && f.type === "block-seq" ? i(d.end, "BAD_INDENT", "All sequence items must start at the same column") : i(a, "MISSING_CHAR", "Sequence item without - indicator");
2558
- else {
2559
- c = d.end, d.comment && (l.comment = d.comment);
2560
- continue;
2561
- }
2562
- const h = f ? s(t, f, d, i) : e(t, d.end, p, null, d, i);
2563
- t.schema.compat && ut(n.indent, f, i), a = h.range[2], l.items.push(h);
2564
- }
2565
- return l.range = [n.offset, a, c ?? a], l;
2566
- }
2567
- function Te(s, e, t, n) {
2568
- let i = "";
2569
- if (s) {
2570
- let r = !1, o = "";
2571
- for (const l of s) {
2572
- const { source: a, type: c } = l;
2573
- switch (c) {
2574
- case "space":
2575
- r = !0;
2576
- break;
2577
- case "comment": {
2578
- t && !r && n(l, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters");
2579
- const p = a.substring(1) || " ";
2580
- i ? i += o + p : i = p, o = "";
2581
- break;
2582
- }
2583
- case "newline":
2584
- i && (o += a), r = !0;
2585
- break;
2586
- default:
2587
- n(l, "UNEXPECTED_TOKEN", `Unexpected ${c} at node end`);
2588
- }
2589
- e += a.length;
2590
- }
2591
- }
2592
- return { comment: i, offset: e };
2593
- }
2594
- const st = "Block collections are not allowed within flow collections", nt = (s) => s && (s.type === "block-map" || s.type === "block-seq");
2595
- function un({ composeNode: s, composeEmptyNode: e }, t, n, i, r) {
2596
- const o = n.start.source === "{", l = o ? "flow map" : "flow sequence", a = (r == null ? void 0 : r.nodeClass) ?? (o ? K : Q), c = new a(t.schema);
2597
- c.flow = !0;
2598
- const p = t.atRoot;
2599
- p && (t.atRoot = !1), t.atKey && (t.atKey = !1);
2600
- let f = n.offset + n.start.source.length;
2601
- for (let m = 0; m < n.items.length; ++m) {
2602
- const b = n.items[m], { start: w, key: N, sep: S, value: k } = b, O = ue(w, {
2603
- flow: l,
2604
- indicator: "explicit-key-ind",
2605
- next: N ?? (S == null ? void 0 : S[0]),
2606
- offset: f,
2607
- onError: i,
2608
- parentIndent: n.indent,
2609
- startOnNewline: !1
2610
- });
2611
- if (!O.found) {
2612
- if (!O.anchor && !O.tag && !S && !k) {
2613
- m === 0 && O.comma ? i(O.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${l}`) : m < n.items.length - 1 && i(O.start, "UNEXPECTED_TOKEN", `Unexpected empty item in ${l}`), O.comment && (c.comment ? c.comment += `
2614
- ` + O.comment : c.comment = O.comment), f = O.end;
2615
- continue;
2616
- }
2617
- !o && t.options.strict && Ne(N) && i(
2618
- N,
2619
- // checked by containsNewline()
2620
- "MULTILINE_IMPLICIT_KEY",
2621
- "Implicit keys of flow sequence pairs need to be on a single line"
2622
- );
2623
- }
2624
- if (m === 0)
2625
- O.comma && i(O.comma, "UNEXPECTED_TOKEN", `Unexpected , in ${l}`);
2626
- else if (O.comma || i(O.start, "MISSING_CHAR", `Missing , between ${l} items`), O.comment) {
2627
- let T = "";
2628
- e: for (const g of w)
2629
- switch (g.type) {
2630
- case "comma":
2631
- case "space":
2632
- break;
2633
- case "comment":
2634
- T = g.source.substring(1);
2635
- break e;
2636
- default:
2637
- break e;
2638
- }
2639
- if (T) {
2640
- let g = c.items[c.items.length - 1];
2641
- I(g) && (g = g.value ?? g.key), g.comment ? g.comment += `
2642
- ` + T : g.comment = T, O.comment = O.comment.substring(T.length + 1);
2643
- }
2644
- }
2645
- if (!o && !S && !O.found) {
2646
- const T = k ? s(t, k, O, i) : e(t, O.end, S, null, O, i);
2647
- c.items.push(T), f = T.range[2], nt(k) && i(T.range, "BLOCK_IN_FLOW", st);
2648
- } else {
2649
- t.atKey = !0;
2650
- const T = O.end, g = N ? s(t, N, O, i) : e(t, T, w, null, O, i);
2651
- nt(N) && i(g.range, "BLOCK_IN_FLOW", st), t.atKey = !1;
2652
- const _ = ue(S ?? [], {
2653
- flow: l,
2654
- indicator: "map-value-ind",
2655
- next: k,
2656
- offset: g.range[2],
2657
- onError: i,
2658
- parentIndent: n.indent,
2659
- startOnNewline: !1
2660
- });
2661
- if (_.found) {
2662
- if (!o && !O.found && t.options.strict) {
2663
- if (S)
2664
- for (const C of S) {
2665
- if (C === _.found)
2666
- break;
2667
- if (C.type === "newline") {
2668
- i(C, "MULTILINE_IMPLICIT_KEY", "Implicit keys of flow sequence pairs need to be on a single line");
2669
- break;
2670
- }
2671
- }
2672
- O.start < _.found.offset - 1024 && i(_.found, "KEY_OVER_1024_CHARS", "The : indicator must be at most 1024 chars after the start of an implicit flow sequence key");
2673
- }
2674
- } else k && ("source" in k && k.source && k.source[0] === ":" ? i(k, "MISSING_CHAR", `Missing space after : in ${l}`) : i(_.start, "MISSING_CHAR", `Missing , or : between ${l} items`));
2675
- const Y = k ? s(t, k, _, i) : _.found ? e(t, _.end, S, null, _, i) : null;
2676
- Y ? nt(k) && i(Y.range, "BLOCK_IN_FLOW", st) : _.comment && (g.comment ? g.comment += `
2677
- ` + _.comment : g.comment = _.comment);
2678
- const te = new v(g, Y);
2679
- if (t.options.keepSourceTokens && (te.srcToken = b), o) {
2680
- const C = c;
2681
- gs(t, C.items, g) && i(T, "DUPLICATE_KEY", "Map keys must be unique"), C.items.push(te);
2682
- } else {
2683
- const C = new K(t.schema);
2684
- C.flow = !0, C.items.push(te);
2685
- const Lt = (Y ?? g).range;
2686
- C.range = [g.range[0], Lt[1], Lt[2]], c.items.push(C);
2687
- }
2688
- f = Y ? Y.range[2] : _.end;
2689
- }
2690
- }
2691
- const d = o ? "}" : "]", [h, ...y] = n.end;
2692
- let u = f;
2693
- if (h && h.source === d)
2694
- u = h.offset + h.source.length;
2695
- else {
2696
- const m = l[0].toUpperCase() + l.substring(1), b = p ? `${m} must end with a ${d}` : `${m} in block collection must be sufficiently indented and end with a ${d}`;
2697
- i(f, p ? "MISSING_CHAR" : "BAD_INDENT", b), h && h.source.length !== 1 && y.unshift(h);
2698
- }
2699
- if (y.length > 0) {
2700
- const m = Te(y, u, t.options.strict, i);
2701
- m.comment && (c.comment ? c.comment += `
2702
- ` + m.comment : c.comment = m.comment), c.range = [n.offset, u, m.offset];
2703
- } else
2704
- c.range = [n.offset, u, u];
2705
- return c;
2706
- }
2707
- function it(s, e, t, n, i, r) {
2708
- const o = t.type === "block-map" ? cn(s, e, t, n, r) : t.type === "block-seq" ? fn(s, e, t, n, r) : un(s, e, t, n, r), l = o.constructor;
2709
- return i === "!" || i === l.tagName ? (o.tag = l.tagName, o) : (i && (o.tag = i), o);
2710
- }
2711
- function hn(s, e, t, n, i) {
2712
- var d;
2713
- const r = n.tag, o = r ? e.directives.tagName(r.source, (h) => i(r, "TAG_RESOLVE_FAILED", h)) : null;
2714
- if (t.type === "block-seq") {
2715
- const { anchor: h, newlineAfterProp: y } = n, u = h && r ? h.offset > r.offset ? h : r : h ?? r;
2716
- u && (!y || y.offset < u.offset) && i(u, "MISSING_CHAR", "Missing newline after block sequence props");
2717
- }
2718
- const l = t.type === "block-map" ? "map" : t.type === "block-seq" ? "seq" : t.start.source === "{" ? "map" : "seq";
2719
- if (!r || !o || o === "!" || o === K.tagName && l === "map" || o === Q.tagName && l === "seq")
2720
- return it(s, e, t, i, o);
2721
- let a = e.schema.tags.find((h) => h.tag === o && h.collection === l);
2722
- if (!a) {
2723
- const h = e.schema.knownTags[o];
2724
- if (h && h.collection === l)
2725
- e.schema.tags.push(Object.assign({}, h, { default: !1 })), a = h;
2726
- else
2727
- return h != null && h.collection ? i(r, "BAD_COLLECTION_TYPE", `${h.tag} used for ${l} collection, but expects ${h.collection}`, !0) : i(r, "TAG_RESOLVE_FAILED", `Unresolved tag: ${o}`, !0), it(s, e, t, i, o);
2728
- }
2729
- const c = it(s, e, t, i, o, a), p = ((d = a.resolve) == null ? void 0 : d.call(a, c, (h) => i(r, "TAG_RESOLVE_FAILED", h), e.options)) ?? c, f = $(p) ? p : new A(p);
2730
- return f.range = c.range, f.tag = o, a != null && a.format && (f.format = a.format), f;
2731
- }
2732
- function bs(s, e, t) {
2733
- const n = e.offset, i = dn(e, s.options.strict, t);
2734
- if (!i)
2735
- return { value: "", type: null, comment: "", range: [n, n, n] };
2736
- const r = i.mode === ">" ? A.BLOCK_FOLDED : A.BLOCK_LITERAL, o = e.source ? pn(e.source) : [];
2737
- let l = o.length;
2738
- for (let u = o.length - 1; u >= 0; --u) {
2739
- const m = o[u][1];
2740
- if (m === "" || m === "\r")
2741
- l = u;
2742
- else
2743
- break;
2744
- }
2745
- if (l === 0) {
2746
- const u = i.chomp === "+" && o.length > 0 ? `
2747
- `.repeat(Math.max(1, o.length - 1)) : "";
2748
- let m = n + i.length;
2749
- return e.source && (m += e.source.length), { value: u, type: r, comment: i.comment, range: [n, m, m] };
2750
- }
2751
- let a = e.indent + i.indent, c = e.offset + i.length, p = 0;
2752
- for (let u = 0; u < l; ++u) {
2753
- const [m, b] = o[u];
2754
- if (b === "" || b === "\r")
2755
- i.indent === 0 && m.length > a && (a = m.length);
2756
- else {
2757
- m.length < a && t(c + m.length, "MISSING_CHAR", "Block scalars with more-indented leading empty lines must use an explicit indentation indicator"), i.indent === 0 && (a = m.length), p = u, a === 0 && !s.atRoot && t(c, "BAD_INDENT", "Block scalar values in collections must be indented");
2758
- break;
2759
- }
2760
- c += m.length + b.length + 1;
2761
- }
2762
- for (let u = o.length - 1; u >= l; --u)
2763
- o[u][0].length > a && (l = u + 1);
2764
- let f = "", d = "", h = !1;
2765
- for (let u = 0; u < p; ++u)
2766
- f += o[u][0].slice(a) + `
2767
- `;
2768
- for (let u = p; u < l; ++u) {
2769
- let [m, b] = o[u];
2770
- c += m.length + b.length + 1;
2771
- const w = b[b.length - 1] === "\r";
2772
- if (w && (b = b.slice(0, -1)), b && m.length < a) {
2773
- const S = `Block scalar lines must not be less indented than their ${i.indent ? "explicit indentation indicator" : "first line"}`;
2774
- t(c - b.length - (w ? 2 : 1), "BAD_INDENT", S), m = "";
2775
- }
2776
- r === A.BLOCK_LITERAL ? (f += d + m.slice(a) + b, d = `
2777
- `) : m.length > a || b[0] === " " ? (d === " " ? d = `
2778
- ` : !h && d === `
2779
- ` && (d = `
2780
-
2781
- `), f += d + m.slice(a) + b, d = `
2782
- `, h = !0) : b === "" ? d === `
2783
- ` ? f += `
2784
- ` : d = `
2785
- ` : (f += d + b, d = " ", h = !1);
2786
- }
2787
- switch (i.chomp) {
2788
- case "-":
2789
- break;
2790
- case "+":
2791
- for (let u = l; u < o.length; ++u)
2792
- f += `
2793
- ` + o[u][0].slice(a);
2794
- f[f.length - 1] !== `
2795
- ` && (f += `
2796
- `);
2797
- break;
2798
- default:
2799
- f += `
2800
- `;
2801
- }
2802
- const y = n + i.length + e.source.length;
2803
- return { value: f, type: r, comment: i.comment, range: [n, y, y] };
2804
- }
2805
- function dn({ offset: s, props: e }, t, n) {
2806
- if (e[0].type !== "block-scalar-header")
2807
- return n(e[0], "IMPOSSIBLE", "Block scalar header not found"), null;
2808
- const { source: i } = e[0], r = i[0];
2809
- let o = 0, l = "", a = -1;
2810
- for (let d = 1; d < i.length; ++d) {
2811
- const h = i[d];
2812
- if (!l && (h === "-" || h === "+"))
2813
- l = h;
2814
- else {
2815
- const y = Number(h);
2816
- !o && y ? o = y : a === -1 && (a = s + d);
2817
- }
2818
- }
2819
- a !== -1 && n(a, "UNEXPECTED_TOKEN", `Block scalar header includes extra characters: ${i}`);
2820
- let c = !1, p = "", f = i.length;
2821
- for (let d = 1; d < e.length; ++d) {
2822
- const h = e[d];
2823
- switch (h.type) {
2824
- case "space":
2825
- c = !0;
2826
- // fallthrough
2827
- case "newline":
2828
- f += h.source.length;
2829
- break;
2830
- case "comment":
2831
- t && !c && n(h, "MISSING_CHAR", "Comments must be separated from other tokens by white space characters"), f += h.source.length, p = h.source.substring(1);
2832
- break;
2833
- case "error":
2834
- n(h, "UNEXPECTED_TOKEN", h.message), f += h.source.length;
2835
- break;
2836
- /* istanbul ignore next should not happen */
2837
- default: {
2838
- const y = `Unexpected token in block scalar header: ${h.type}`;
2839
- n(h, "UNEXPECTED_TOKEN", y);
2840
- const u = h.source;
2841
- u && typeof u == "string" && (f += u.length);
2842
- }
2843
- }
2844
- }
2845
- return { mode: r, indent: o, chomp: l, comment: p, length: f };
2846
- }
2847
- function pn(s) {
2848
- const e = s.split(/\n( *)/), t = e[0], n = t.match(/^( *)/), r = [n != null && n[1] ? [n[1], t.slice(n[1].length)] : ["", t]];
2849
- for (let o = 1; o < e.length; o += 2)
2850
- r.push([e[o], e[o + 1]]);
2851
- return r;
2852
- }
2853
- function ws(s, e, t) {
2854
- const { offset: n, type: i, source: r, end: o } = s;
2855
- let l, a;
2856
- const c = (d, h, y) => t(n + d, h, y);
2857
- switch (i) {
2858
- case "scalar":
2859
- l = A.PLAIN, a = mn(r, c);
2860
- break;
2861
- case "single-quoted-scalar":
2862
- l = A.QUOTE_SINGLE, a = yn(r, c);
2863
- break;
2864
- case "double-quoted-scalar":
2865
- l = A.QUOTE_DOUBLE, a = gn(r, c);
2866
- break;
2867
- /* istanbul ignore next should not happen */
2868
- default:
2869
- return t(s, "UNEXPECTED_TOKEN", `Expected a flow scalar value, but found: ${i}`), {
2870
- value: "",
2871
- type: null,
2872
- comment: "",
2873
- range: [n, n + r.length, n + r.length]
2874
- };
2875
- }
2876
- const p = n + r.length, f = Te(o, p, e, t);
2877
- return {
2878
- value: a,
2879
- type: l,
2880
- comment: f.comment,
2881
- range: [n, p, f.offset]
2882
- };
2883
- }
2884
- function mn(s, e) {
2885
- let t = "";
2886
- switch (s[0]) {
2887
- /* istanbul ignore next should not happen */
2888
- case " ":
2889
- t = "a tab character";
2890
- break;
2891
- case ",":
2892
- t = "flow indicator character ,";
2893
- break;
2894
- case "%":
2895
- t = "directive indicator character %";
2896
- break;
2897
- case "|":
2898
- case ">": {
2899
- t = `block scalar indicator ${s[0]}`;
2900
- break;
2901
- }
2902
- case "@":
2903
- case "`": {
2904
- t = `reserved character ${s[0]}`;
2905
- break;
2906
- }
2907
- }
2908
- return t && e(0, "BAD_SCALAR_START", `Plain value cannot start with ${t}`), Ss(s);
2909
- }
2910
- function yn(s, e) {
2911
- return (s[s.length - 1] !== "'" || s.length === 1) && e(s.length, "MISSING_CHAR", "Missing closing 'quote"), Ss(s.slice(1, -1)).replace(/''/g, "'");
2912
- }
2913
- function Ss(s) {
2914
- let e, t;
2915
- try {
2916
- e = new RegExp(`(.*?)(?<![ ])[ ]*\r?
2917
- `, "sy"), t = new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
2918
- `, "sy");
2919
- } catch {
2920
- e = /(.*?)[ \t]*\r?\n/sy, t = /[ \t]*(.*?)[ \t]*\r?\n/sy;
2921
- }
2922
- let n = e.exec(s);
2923
- if (!n)
2924
- return s;
2925
- let i = n[1], r = " ", o = e.lastIndex;
2926
- for (t.lastIndex = o; n = t.exec(s); )
2927
- n[1] === "" ? r === `
2928
- ` ? i += r : r = `
2929
- ` : (i += r + n[1], r = " "), o = t.lastIndex;
2930
- const l = /[ \t]*(.*)/sy;
2931
- return l.lastIndex = o, n = l.exec(s), i + r + ((n == null ? void 0 : n[1]) ?? "");
2932
- }
2933
- function gn(s, e) {
2934
- let t = "";
2935
- for (let n = 1; n < s.length - 1; ++n) {
2936
- const i = s[n];
2937
- if (!(i === "\r" && s[n + 1] === `
2938
- `))
2939
- if (i === `
2940
- `) {
2941
- const { fold: r, offset: o } = bn(s, n);
2942
- t += r, n = o;
2943
- } else if (i === "\\") {
2944
- let r = s[++n];
2945
- const o = wn[r];
2946
- if (o)
2947
- t += o;
2948
- else if (r === `
2949
- `)
2950
- for (r = s[n + 1]; r === " " || r === " "; )
2951
- r = s[++n + 1];
2952
- else if (r === "\r" && s[n + 1] === `
2953
- `)
2954
- for (r = s[++n + 1]; r === " " || r === " "; )
2955
- r = s[++n + 1];
2956
- else if (r === "x" || r === "u" || r === "U") {
2957
- const l = { x: 2, u: 4, U: 8 }[r];
2958
- t += Sn(s, n + 1, l, e), n += l;
2959
- } else {
2960
- const l = s.substr(n - 1, 2);
2961
- e(n - 1, "BAD_DQ_ESCAPE", `Invalid escape sequence ${l}`), t += l;
2962
- }
2963
- } else if (i === " " || i === " ") {
2964
- const r = n;
2965
- let o = s[n + 1];
2966
- for (; o === " " || o === " "; )
2967
- o = s[++n + 1];
2968
- o !== `
2969
- ` && !(o === "\r" && s[n + 2] === `
2970
- `) && (t += n > r ? s.slice(r, n + 1) : i);
2971
- } else
2972
- t += i;
2973
- }
2974
- return (s[s.length - 1] !== '"' || s.length === 1) && e(s.length, "MISSING_CHAR", 'Missing closing "quote'), t;
2975
- }
2976
- function bn(s, e) {
2977
- let t = "", n = s[e + 1];
2978
- for (; (n === " " || n === " " || n === `
2979
- ` || n === "\r") && !(n === "\r" && s[e + 2] !== `
2980
- `); )
2981
- n === `
2982
- ` && (t += `
2983
- `), e += 1, n = s[e + 1];
2984
- return t || (t = " "), { fold: t, offset: e };
2985
- }
2986
- const wn = {
2987
- 0: "\0",
2988
- // null character
2989
- a: "\x07",
2990
- // bell character
2991
- b: "\b",
2992
- // backspace
2993
- e: "\x1B",
2994
- // escape character
2995
- f: "\f",
2996
- // form feed
2997
- n: `
2998
- `,
2999
- // line feed
3000
- r: "\r",
3001
- // carriage return
3002
- t: " ",
3003
- // horizontal tab
3004
- v: "\v",
3005
- // vertical tab
3006
- N: "…",
3007
- // Unicode next line
3008
- _: " ",
3009
- // Unicode non-breaking space
3010
- L: "\u2028",
3011
- // Unicode line separator
3012
- P: "\u2029",
3013
- // Unicode paragraph separator
3014
- " ": " ",
3015
- '"': '"',
3016
- "/": "/",
3017
- "\\": "\\",
3018
- " ": " "
3019
- };
3020
- function Sn(s, e, t, n) {
3021
- const i = s.substr(e, t), o = i.length === t && /^[0-9a-fA-F]+$/.test(i) ? parseInt(i, 16) : NaN;
3022
- if (isNaN(o)) {
3023
- const l = s.substr(e - 2, t + 2);
3024
- return n(e - 2, "BAD_DQ_ESCAPE", `Invalid escape sequence ${l}`), l;
3025
- }
3026
- return String.fromCodePoint(o);
3027
- }
3028
- function ks(s, e, t, n) {
3029
- const { value: i, type: r, comment: o, range: l } = e.type === "block-scalar" ? bs(s, e, n) : ws(e, s.options.strict, n), a = t ? s.directives.tagName(t.source, (f) => n(t, "TAG_RESOLVE_FAILED", f)) : null;
3030
- let c;
3031
- s.options.stringKeys && s.atKey ? c = s.schema[R] : a ? c = kn(s.schema, i, a, t, n) : e.type === "scalar" ? c = Nn(s, i, e, n) : c = s.schema[R];
3032
- let p;
3033
- try {
3034
- const f = c.resolve(i, (d) => n(t ?? e, "TAG_RESOLVE_FAILED", d), s.options);
3035
- p = E(f) ? f : new A(f);
3036
- } catch (f) {
3037
- const d = f instanceof Error ? f.message : String(f);
3038
- n(t ?? e, "TAG_RESOLVE_FAILED", d), p = new A(i);
3039
- }
3040
- return p.range = l, p.source = i, r && (p.type = r), a && (p.tag = a), c.format && (p.format = c.format), o && (p.comment = o), p;
3041
- }
3042
- function kn(s, e, t, n, i) {
3043
- var l;
3044
- if (t === "!")
3045
- return s[R];
3046
- const r = [];
3047
- for (const a of s.tags)
3048
- if (!a.collection && a.tag === t)
3049
- if (a.default && a.test)
3050
- r.push(a);
3051
- else
3052
- return a;
3053
- for (const a of r)
3054
- if ((l = a.test) != null && l.test(e))
3055
- return a;
3056
- const o = s.knownTags[t];
3057
- return o && !o.collection ? (s.tags.push(Object.assign({}, o, { default: !1, test: void 0 })), o) : (i(n, "TAG_RESOLVE_FAILED", `Unresolved tag: ${t}`, t !== "tag:yaml.org,2002:str"), s[R]);
3058
- }
3059
- function Nn({ atKey: s, directives: e, schema: t }, n, i, r) {
3060
- const o = t.tags.find((l) => {
3061
- var a;
3062
- return (l.default === !0 || s && l.default === "key") && ((a = l.test) == null ? void 0 : a.test(n));
3063
- }) || t[R];
3064
- if (t.compat) {
3065
- const l = t.compat.find((a) => {
3066
- var c;
3067
- return a.default && ((c = a.test) == null ? void 0 : c.test(n));
3068
- }) ?? t[R];
3069
- if (o.tag !== l.tag) {
3070
- const a = e.tagString(o.tag), c = e.tagString(l.tag), p = `Value may be parsed as either ${a} or ${c}`;
3071
- r(i, "TAG_RESOLVE_FAILED", p, !0);
3072
- }
3073
- }
3074
- return o;
3075
- }
3076
- function On(s, e, t) {
3077
- if (e) {
3078
- t === null && (t = e.length);
3079
- for (let n = t - 1; n >= 0; --n) {
3080
- let i = e[n];
3081
- switch (i.type) {
3082
- case "space":
3083
- case "comment":
3084
- case "newline":
3085
- s -= i.source.length;
3086
- continue;
3087
- }
3088
- for (i = e[++n]; (i == null ? void 0 : i.type) === "space"; )
3089
- s += i.source.length, i = e[++n];
3090
- break;
3091
- }
3092
- }
3093
- return s;
3094
- }
3095
- const An = { composeNode: Ns, composeEmptyNode: Et };
3096
- function Ns(s, e, t, n) {
3097
- const i = s.atKey, { spaceBefore: r, comment: o, anchor: l, tag: a } = t;
3098
- let c, p = !0;
3099
- switch (e.type) {
3100
- case "alias":
3101
- c = En(s, e, n), (l || a) && n(e, "ALIAS_PROPS", "An alias node must not specify any properties");
3102
- break;
3103
- case "scalar":
3104
- case "single-quoted-scalar":
3105
- case "double-quoted-scalar":
3106
- case "block-scalar":
3107
- c = ks(s, e, a, n), l && (c.anchor = l.source.substring(1));
3108
- break;
3109
- case "block-map":
3110
- case "block-seq":
3111
- case "flow-collection":
3112
- c = hn(An, s, e, t, n), l && (c.anchor = l.source.substring(1));
3113
- break;
3114
- default: {
3115
- const f = e.type === "error" ? e.message : `Unsupported token (type: ${e.type})`;
3116
- n(e, "UNEXPECTED_TOKEN", f), c = Et(s, e.offset, void 0, null, t, n), p = !1;
3117
- }
3118
- }
3119
- return l && c.anchor === "" && n(l, "BAD_ALIAS", "Anchor cannot be an empty string"), i && s.options.stringKeys && (!E(c) || typeof c.value != "string" || c.tag && c.tag !== "tag:yaml.org,2002:str") && n(a ?? e, "NON_STRING_KEY", "With stringKeys, all keys must be strings"), r && (c.spaceBefore = !0), o && (e.type === "scalar" && e.source === "" ? c.comment = o : c.commentBefore = o), s.options.keepSourceTokens && p && (c.srcToken = e), c;
3120
- }
3121
- function Et(s, e, t, n, { spaceBefore: i, comment: r, anchor: o, tag: l, end: a }, c) {
3122
- const p = {
3123
- type: "scalar",
3124
- offset: On(e, t, n),
3125
- indent: -1,
3126
- source: ""
3127
- }, f = ks(s, p, l, c);
3128
- return o && (f.anchor = o.source.substring(1), f.anchor === "" && c(o, "BAD_ALIAS", "Anchor cannot be an empty string")), i && (f.spaceBefore = !0), r && (f.comment = r, f.range[2] = a), f;
3129
- }
3130
- function En({ options: s }, { offset: e, source: t, end: n }, i) {
3131
- const r = new Re(t.substring(1));
3132
- r.source === "" && i(e, "BAD_ALIAS", "Alias cannot be an empty string"), r.source.endsWith(":") && i(e + t.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", !0);
3133
- const o = e + t.length, l = Te(n, o, s.strict, i);
3134
- return r.range = [e, o, l.offset], l.comment && (r.comment = l.comment), r;
3135
- }
3136
- function Tn(s, e, { offset: t, start: n, value: i, end: r }, o) {
3137
- const l = Object.assign({ _directives: e }, s), a = new ge(void 0, l), c = {
3138
- atKey: !1,
3139
- atRoot: !0,
3140
- directives: a.directives,
3141
- options: a.options,
3142
- schema: a.schema
3143
- }, p = ue(n, {
3144
- indicator: "doc-start",
3145
- next: i ?? (r == null ? void 0 : r[0]),
3146
- offset: t,
3147
- onError: o,
3148
- parentIndent: 0,
3149
- startOnNewline: !0
3150
- });
3151
- p.found && (a.directives.docStart = !0, i && (i.type === "block-map" || i.type === "block-seq") && !p.hasNewline && o(p.end, "MISSING_CHAR", "Block collection cannot start on same line with directives-end marker")), a.contents = i ? Ns(c, i, p, o) : Et(c, p.end, n, null, p, o);
3152
- const f = a.contents.range[2], d = Te(r, f, !1, o);
3153
- return d.comment && (a.comment = d.comment), a.range = [t, f, d.offset], a;
3154
- }
3155
- function be(s) {
3156
- if (typeof s == "number")
3157
- return [s, s + 1];
3158
- if (Array.isArray(s))
3159
- return s.length === 2 ? s : [s[0], s[1]];
3160
- const { offset: e, source: t } = s;
3161
- return [e, e + (typeof t == "string" ? t.length : 1)];
3162
- }
3163
- function Kt(s) {
3164
- var i;
3165
- let e = "", t = !1, n = !1;
3166
- for (let r = 0; r < s.length; ++r) {
3167
- const o = s[r];
3168
- switch (o[0]) {
3169
- case "#":
3170
- e += (e === "" ? "" : n ? `
3171
-
3172
- ` : `
3173
- `) + (o.substring(1) || " "), t = !0, n = !1;
3174
- break;
3175
- case "%":
3176
- ((i = s[r + 1]) == null ? void 0 : i[0]) !== "#" && (r += 1), t = !1;
3177
- break;
3178
- default:
3179
- t || (n = !0), t = !1;
3180
- }
3181
- }
3182
- return { comment: e, afterEmptyLine: n };
3183
- }
3184
- class Tt {
3185
- constructor(e = {}) {
3186
- this.doc = null, this.atDirectives = !1, this.prelude = [], this.errors = [], this.warnings = [], this.onError = (t, n, i, r) => {
3187
- const o = be(t);
3188
- r ? this.warnings.push(new ys(o, n, i)) : this.errors.push(new z(o, n, i));
3189
- }, this.directives = new B({ version: e.version || "1.2" }), this.options = e;
3190
- }
3191
- decorate(e, t) {
3192
- const { comment: n, afterEmptyLine: i } = Kt(this.prelude);
3193
- if (n) {
3194
- const r = e.contents;
3195
- if (t)
3196
- e.comment = e.comment ? `${e.comment}
3197
- ${n}` : n;
3198
- else if (i || e.directives.docStart || !r)
3199
- e.commentBefore = n;
3200
- else if (L(r) && !r.flow && r.items.length > 0) {
3201
- let o = r.items[0];
3202
- I(o) && (o = o.key);
3203
- const l = o.commentBefore;
3204
- o.commentBefore = l ? `${n}
3205
- ${l}` : n;
3206
- } else {
3207
- const o = r.commentBefore;
3208
- r.commentBefore = o ? `${n}
3209
- ${o}` : n;
3210
- }
3211
- }
3212
- t ? (Array.prototype.push.apply(e.errors, this.errors), Array.prototype.push.apply(e.warnings, this.warnings)) : (e.errors = this.errors, e.warnings = this.warnings), this.prelude = [], this.errors = [], this.warnings = [];
3213
- }
3214
- /**
3215
- * Current stream status information.
3216
- *
3217
- * Mostly useful at the end of input for an empty stream.
3218
- */
3219
- streamInfo() {
3220
- return {
3221
- comment: Kt(this.prelude).comment,
3222
- directives: this.directives,
3223
- errors: this.errors,
3224
- warnings: this.warnings
3225
- };
3226
- }
3227
- /**
3228
- * Compose tokens into documents.
3229
- *
3230
- * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
3231
- * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
3232
- */
3233
- *compose(e, t = !1, n = -1) {
3234
- for (const i of e)
3235
- yield* this.next(i);
3236
- yield* this.end(t, n);
3237
- }
3238
- /** Advance the composer by one CST token. */
3239
- *next(e) {
3240
- switch (e.type) {
3241
- case "directive":
3242
- this.directives.add(e.source, (t, n, i) => {
3243
- const r = be(e);
3244
- r[0] += t, this.onError(r, "BAD_DIRECTIVE", n, i);
3245
- }), this.prelude.push(e.source), this.atDirectives = !0;
3246
- break;
3247
- case "document": {
3248
- const t = Tn(this.options, this.directives, e, this.onError);
3249
- this.atDirectives && !t.directives.docStart && this.onError(e, "MISSING_CHAR", "Missing directives-end/doc-start indicator line"), this.decorate(t, !1), this.doc && (yield this.doc), this.doc = t, this.atDirectives = !1;
3250
- break;
3251
- }
3252
- case "byte-order-mark":
3253
- case "space":
3254
- break;
3255
- case "comment":
3256
- case "newline":
3257
- this.prelude.push(e.source);
3258
- break;
3259
- case "error": {
3260
- const t = e.source ? `${e.message}: ${JSON.stringify(e.source)}` : e.message, n = new z(be(e), "UNEXPECTED_TOKEN", t);
3261
- this.atDirectives || !this.doc ? this.errors.push(n) : this.doc.errors.push(n);
3262
- break;
3263
- }
3264
- case "doc-end": {
3265
- if (!this.doc) {
3266
- const n = "Unexpected doc-end without preceding document";
3267
- this.errors.push(new z(be(e), "UNEXPECTED_TOKEN", n));
3268
- break;
3269
- }
3270
- this.doc.directives.docEnd = !0;
3271
- const t = Te(e.end, e.offset + e.source.length, this.doc.options.strict, this.onError);
3272
- if (this.decorate(this.doc, !0), t.comment) {
3273
- const n = this.doc.comment;
3274
- this.doc.comment = n ? `${n}
3275
- ${t.comment}` : t.comment;
3276
- }
3277
- this.doc.range[2] = t.offset;
3278
- break;
3279
- }
3280
- default:
3281
- this.errors.push(new z(be(e), "UNEXPECTED_TOKEN", `Unsupported token ${e.type}`));
3282
- }
3283
- }
3284
- /**
3285
- * Call at end of input to yield any remaining document.
3286
- *
3287
- * @param forceDoc - If the stream contains no document, still emit a final document including any comments and directives that would be applied to a subsequent document.
3288
- * @param endOffset - Should be set if `forceDoc` is also set, to set the document range end and to indicate errors correctly.
3289
- */
3290
- *end(e = !1, t = -1) {
3291
- if (this.doc)
3292
- this.decorate(this.doc, !0), yield this.doc, this.doc = null;
3293
- else if (e) {
3294
- const n = Object.assign({ _directives: this.directives }, this.options), i = new ge(void 0, n);
3295
- this.atDirectives && this.onError(t, "MISSING_CHAR", "Missing directives-end indicator line"), i.range = [0, t, t], this.decorate(i, !1), yield i;
3296
- }
3297
- }
3298
- }
3299
- function In(s, e = !0, t) {
3300
- if (s) {
3301
- const n = (i, r, o) => {
3302
- const l = typeof i == "number" ? i : Array.isArray(i) ? i[0] : i.offset;
3303
- if (t)
3304
- t(l, r, o);
3305
- else
3306
- throw new z([l, l + 1], r, o);
3307
- };
3308
- switch (s.type) {
3309
- case "scalar":
3310
- case "single-quoted-scalar":
3311
- case "double-quoted-scalar":
3312
- return ws(s, e, n);
3313
- case "block-scalar":
3314
- return bs({ options: { strict: e } }, s, n);
3315
- }
3316
- }
3317
- return null;
3318
- }
3319
- function Ln(s, e) {
3320
- const { implicitKey: t = !1, indent: n, inFlow: i = !1, offset: r = -1, type: o = "PLAIN" } = e, l = Ae({ type: o, value: s }, {
3321
- implicitKey: t,
3322
- indent: n > 0 ? " ".repeat(n) : "",
3323
- inFlow: i,
3324
- options: { blockQuote: !0, lineWidth: -1 }
3325
- }), a = e.end ?? [
3326
- { type: "newline", offset: -1, indent: n, source: `
3327
- ` }
3328
- ];
3329
- switch (l[0]) {
3330
- case "|":
3331
- case ">": {
3332
- const c = l.indexOf(`
3333
- `), p = l.substring(0, c), f = l.substring(c + 1) + `
3334
- `, d = [
3335
- { type: "block-scalar-header", offset: r, indent: n, source: p }
3336
- ];
3337
- return Os(d, a) || d.push({ type: "newline", offset: -1, indent: n, source: `
3338
- ` }), { type: "block-scalar", offset: r, indent: n, props: d, source: f };
3339
- }
3340
- case '"':
3341
- return { type: "double-quoted-scalar", offset: r, indent: n, source: l, end: a };
3342
- case "'":
3343
- return { type: "single-quoted-scalar", offset: r, indent: n, source: l, end: a };
3344
- default:
3345
- return { type: "scalar", offset: r, indent: n, source: l, end: a };
3346
- }
3347
- }
3348
- function $n(s, e, t = {}) {
3349
- let { afterKey: n = !1, implicitKey: i = !1, inFlow: r = !1, type: o } = t, l = "indent" in s ? s.indent : null;
3350
- if (n && typeof l == "number" && (l += 2), !o)
3351
- switch (s.type) {
3352
- case "single-quoted-scalar":
3353
- o = "QUOTE_SINGLE";
3354
- break;
3355
- case "double-quoted-scalar":
3356
- o = "QUOTE_DOUBLE";
3357
- break;
3358
- case "block-scalar": {
3359
- const c = s.props[0];
3360
- if (c.type !== "block-scalar-header")
3361
- throw new Error("Invalid block scalar header");
3362
- o = c.source[0] === ">" ? "BLOCK_FOLDED" : "BLOCK_LITERAL";
3363
- break;
3364
- }
3365
- default:
3366
- o = "PLAIN";
3367
- }
3368
- const a = Ae({ type: o, value: e }, {
3369
- implicitKey: i || l === null,
3370
- indent: l !== null && l > 0 ? " ".repeat(l) : "",
3371
- inFlow: r,
3372
- options: { blockQuote: !0, lineWidth: -1 }
3373
- });
3374
- switch (a[0]) {
3375
- case "|":
3376
- case ">":
3377
- _n(s, a);
3378
- break;
3379
- case '"':
3380
- rt(s, a, "double-quoted-scalar");
3381
- break;
3382
- case "'":
3383
- rt(s, a, "single-quoted-scalar");
3384
- break;
3385
- default:
3386
- rt(s, a, "scalar");
3387
- }
3388
- }
3389
- function _n(s, e) {
3390
- const t = e.indexOf(`
3391
- `), n = e.substring(0, t), i = e.substring(t + 1) + `
3392
- `;
3393
- if (s.type === "block-scalar") {
3394
- const r = s.props[0];
3395
- if (r.type !== "block-scalar-header")
3396
- throw new Error("Invalid block scalar header");
3397
- r.source = n, s.source = i;
3398
- } else {
3399
- const { offset: r } = s, o = "indent" in s ? s.indent : -1, l = [
3400
- { type: "block-scalar-header", offset: r, indent: o, source: n }
3401
- ];
3402
- Os(l, "end" in s ? s.end : void 0) || l.push({ type: "newline", offset: -1, indent: o, source: `
3403
- ` });
3404
- for (const a of Object.keys(s))
3405
- a !== "type" && a !== "offset" && delete s[a];
3406
- Object.assign(s, { type: "block-scalar", indent: o, props: l, source: i });
3407
- }
3408
- }
3409
- function Os(s, e) {
3410
- if (e)
3411
- for (const t of e)
3412
- switch (t.type) {
3413
- case "space":
3414
- case "comment":
3415
- s.push(t);
3416
- break;
3417
- case "newline":
3418
- return s.push(t), !0;
3419
- }
3420
- return !1;
3421
- }
3422
- function rt(s, e, t) {
3423
- switch (s.type) {
3424
- case "scalar":
3425
- case "double-quoted-scalar":
3426
- case "single-quoted-scalar":
3427
- s.type = t, s.source = e;
3428
- break;
3429
- case "block-scalar": {
3430
- const n = s.props.slice(1);
3431
- let i = e.length;
3432
- s.props[0].type === "block-scalar-header" && (i -= s.props[0].source.length);
3433
- for (const r of n)
3434
- r.offset += i;
3435
- delete s.props, Object.assign(s, { type: t, source: e, end: n });
3436
- break;
3437
- }
3438
- case "block-map":
3439
- case "block-seq": {
3440
- const i = { type: "newline", offset: s.offset + e.length, indent: s.indent, source: `
3441
- ` };
3442
- delete s.items, Object.assign(s, { type: t, source: e, end: [i] });
3443
- break;
3444
- }
3445
- default: {
3446
- const n = "indent" in s ? s.indent : -1, i = "end" in s && Array.isArray(s.end) ? s.end.filter((r) => r.type === "space" || r.type === "comment" || r.type === "newline") : [];
3447
- for (const r of Object.keys(s))
3448
- r !== "type" && r !== "offset" && delete s[r];
3449
- Object.assign(s, { type: t, indent: n, source: e, end: i });
3450
- }
3451
- }
3452
- }
3453
- const Cn = (s) => "type" in s ? qe(s) : Ke(s);
3454
- function qe(s) {
3455
- switch (s.type) {
3456
- case "block-scalar": {
3457
- let e = "";
3458
- for (const t of s.props)
3459
- e += qe(t);
3460
- return e + s.source;
3461
- }
3462
- case "block-map":
3463
- case "block-seq": {
3464
- let e = "";
3465
- for (const t of s.items)
3466
- e += Ke(t);
3467
- return e;
3468
- }
3469
- case "flow-collection": {
3470
- let e = s.start.source;
3471
- for (const t of s.items)
3472
- e += Ke(t);
3473
- for (const t of s.end)
3474
- e += t.source;
3475
- return e;
3476
- }
3477
- case "document": {
3478
- let e = Ke(s);
3479
- if (s.end)
3480
- for (const t of s.end)
3481
- e += t.source;
3482
- return e;
3483
- }
3484
- default: {
3485
- let e = s.source;
3486
- if ("end" in s && s.end)
3487
- for (const t of s.end)
3488
- e += t.source;
3489
- return e;
3490
- }
3491
- }
3492
- }
3493
- function Ke({ start: s, key: e, sep: t, value: n }) {
3494
- let i = "";
3495
- for (const r of s)
3496
- i += r.source;
3497
- if (e && (i += qe(e)), t)
3498
- for (const r of t)
3499
- i += r.source;
3500
- return n && (i += qe(n)), i;
3501
- }
3502
- const ht = Symbol("break visit"), vn = Symbol("skip children"), As = Symbol("remove item");
3503
- function Z(s, e) {
3504
- "type" in s && s.type === "document" && (s = { start: s.start, value: s.value }), Es(Object.freeze([]), s, e);
3505
- }
3506
- Z.BREAK = ht;
3507
- Z.SKIP = vn;
3508
- Z.REMOVE = As;
3509
- Z.itemAtPath = (s, e) => {
3510
- let t = s;
3511
- for (const [n, i] of e) {
3512
- const r = t == null ? void 0 : t[n];
3513
- if (r && "items" in r)
3514
- t = r.items[i];
3515
- else
3516
- return;
3517
- }
3518
- return t;
3519
- };
3520
- Z.parentCollection = (s, e) => {
3521
- const t = Z.itemAtPath(s, e.slice(0, -1)), n = e[e.length - 1][0], i = t == null ? void 0 : t[n];
3522
- if (i && "items" in i)
3523
- return i;
3524
- throw new Error("Parent collection not found");
3525
- };
3526
- function Es(s, e, t) {
3527
- let n = t(e, s);
3528
- if (typeof n == "symbol")
3529
- return n;
3530
- for (const i of ["key", "value"]) {
3531
- const r = e[i];
3532
- if (r && "items" in r) {
3533
- for (let o = 0; o < r.items.length; ++o) {
3534
- const l = Es(Object.freeze(s.concat([[i, o]])), r.items[o], t);
3535
- if (typeof l == "number")
3536
- o = l - 1;
3537
- else {
3538
- if (l === ht)
3539
- return ht;
3540
- l === As && (r.items.splice(o, 1), o -= 1);
3541
- }
3542
- }
3543
- typeof n == "function" && i === "key" && (n = n(e, s));
3544
- }
3545
- }
3546
- return typeof n == "function" ? n(e, s) : n;
3547
- }
3548
- const ze = "\uFEFF", Ze = "", xe = "", Oe = "", Bn = (s) => !!s && "items" in s, Mn = (s) => !!s && (s.type === "scalar" || s.type === "single-quoted-scalar" || s.type === "double-quoted-scalar" || s.type === "block-scalar");
3549
- function Kn(s) {
3550
- switch (s) {
3551
- case ze:
3552
- return "<BOM>";
3553
- case Ze:
3554
- return "<DOC>";
3555
- case xe:
3556
- return "<FLOW_END>";
3557
- case Oe:
3558
- return "<SCALAR>";
3559
- default:
3560
- return JSON.stringify(s);
3561
- }
3562
- }
3563
- function Ts(s) {
3564
- switch (s) {
3565
- case ze:
3566
- return "byte-order-mark";
3567
- case Ze:
3568
- return "doc-mode";
3569
- case xe:
3570
- return "flow-error-end";
3571
- case Oe:
3572
- return "scalar";
3573
- case "---":
3574
- return "doc-start";
3575
- case "...":
3576
- return "doc-end";
3577
- case "":
3578
- case `
3579
- `:
3580
- case `\r
3581
- `:
3582
- return "newline";
3583
- case "-":
3584
- return "seq-item-ind";
3585
- case "?":
3586
- return "explicit-key-ind";
3587
- case ":":
3588
- return "map-value-ind";
3589
- case "{":
3590
- return "flow-map-start";
3591
- case "}":
3592
- return "flow-map-end";
3593
- case "[":
3594
- return "flow-seq-start";
3595
- case "]":
3596
- return "flow-seq-end";
3597
- case ",":
3598
- return "comma";
3599
- }
3600
- switch (s[0]) {
3601
- case " ":
3602
- case " ":
3603
- return "space";
3604
- case "#":
3605
- return "comment";
3606
- case "%":
3607
- return "directive-line";
3608
- case "*":
3609
- return "alias";
3610
- case "&":
3611
- return "anchor";
3612
- case "!":
3613
- return "tag";
3614
- case "'":
3615
- return "single-quoted-scalar";
3616
- case '"':
3617
- return "double-quoted-scalar";
3618
- case "|":
3619
- case ">":
3620
- return "block-scalar-header";
3621
- }
3622
- return null;
3623
- }
3624
- var Pn = /* @__PURE__ */ Object.freeze({
3625
- __proto__: null,
3626
- BOM: ze,
3627
- DOCUMENT: Ze,
3628
- FLOW_END: xe,
3629
- SCALAR: Oe,
3630
- createScalarToken: Ln,
3631
- isCollection: Bn,
3632
- isScalar: Mn,
3633
- prettyToken: Kn,
3634
- resolveAsScalar: In,
3635
- setScalarValue: $n,
3636
- stringify: Cn,
3637
- tokenType: Ts,
3638
- visit: Z
3639
- });
3640
- function j(s) {
3641
- switch (s) {
3642
- case void 0:
3643
- case " ":
3644
- case `
3645
- `:
3646
- case "\r":
3647
- case " ":
3648
- return !0;
3649
- default:
3650
- return !1;
3651
- }
3652
- }
3653
- const Pt = new Set("0123456789ABCDEFabcdef"), Dn = new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"), _e = new Set(",[]{}"), jn = new Set(` ,[]{}
3654
- \r `), ot = (s) => !s || jn.has(s);
3655
- class Is {
3656
- constructor() {
3657
- this.atEnd = !1, this.blockScalarIndent = -1, this.blockScalarKeep = !1, this.buffer = "", this.flowKey = !1, this.flowLevel = 0, this.indentNext = 0, this.indentValue = 0, this.lineEndPos = null, this.next = null, this.pos = 0;
3658
- }
3659
- /**
3660
- * Generate YAML tokens from the `source` string. If `incomplete`,
3661
- * a part of the last line may be left as a buffer for the next call.
3662
- *
3663
- * @returns A generator of lexical tokens
3664
- */
3665
- *lex(e, t = !1) {
3666
- if (e) {
3667
- if (typeof e != "string")
3668
- throw TypeError("source is not a string");
3669
- this.buffer = this.buffer ? this.buffer + e : e, this.lineEndPos = null;
3670
- }
3671
- this.atEnd = !t;
3672
- let n = this.next ?? "stream";
3673
- for (; n && (t || this.hasChars(1)); )
3674
- n = yield* this.parseNext(n);
3675
- }
3676
- atLineEnd() {
3677
- let e = this.pos, t = this.buffer[e];
3678
- for (; t === " " || t === " "; )
3679
- t = this.buffer[++e];
3680
- return !t || t === "#" || t === `
3681
- ` ? !0 : t === "\r" ? this.buffer[e + 1] === `
3682
- ` : !1;
3683
- }
3684
- charAt(e) {
3685
- return this.buffer[this.pos + e];
3686
- }
3687
- continueScalar(e) {
3688
- let t = this.buffer[e];
3689
- if (this.indentNext > 0) {
3690
- let n = 0;
3691
- for (; t === " "; )
3692
- t = this.buffer[++n + e];
3693
- if (t === "\r") {
3694
- const i = this.buffer[n + e + 1];
3695
- if (i === `
3696
- ` || !i && !this.atEnd)
3697
- return e + n + 1;
3698
- }
3699
- return t === `
3700
- ` || n >= this.indentNext || !t && !this.atEnd ? e + n : -1;
3701
- }
3702
- if (t === "-" || t === ".") {
3703
- const n = this.buffer.substr(e, 3);
3704
- if ((n === "---" || n === "...") && j(this.buffer[e + 3]))
3705
- return -1;
3706
- }
3707
- return e;
3708
- }
3709
- getLine() {
3710
- let e = this.lineEndPos;
3711
- return (typeof e != "number" || e !== -1 && e < this.pos) && (e = this.buffer.indexOf(`
3712
- `, this.pos), this.lineEndPos = e), e === -1 ? this.atEnd ? this.buffer.substring(this.pos) : null : (this.buffer[e - 1] === "\r" && (e -= 1), this.buffer.substring(this.pos, e));
3713
- }
3714
- hasChars(e) {
3715
- return this.pos + e <= this.buffer.length;
3716
- }
3717
- setNext(e) {
3718
- return this.buffer = this.buffer.substring(this.pos), this.pos = 0, this.lineEndPos = null, this.next = e, null;
3719
- }
3720
- peek(e) {
3721
- return this.buffer.substr(this.pos, e);
3722
- }
3723
- *parseNext(e) {
3724
- switch (e) {
3725
- case "stream":
3726
- return yield* this.parseStream();
3727
- case "line-start":
3728
- return yield* this.parseLineStart();
3729
- case "block-start":
3730
- return yield* this.parseBlockStart();
3731
- case "doc":
3732
- return yield* this.parseDocument();
3733
- case "flow":
3734
- return yield* this.parseFlowCollection();
3735
- case "quoted-scalar":
3736
- return yield* this.parseQuotedScalar();
3737
- case "block-scalar":
3738
- return yield* this.parseBlockScalar();
3739
- case "plain-scalar":
3740
- return yield* this.parsePlainScalar();
3741
- }
3742
- }
3743
- *parseStream() {
3744
- let e = this.getLine();
3745
- if (e === null)
3746
- return this.setNext("stream");
3747
- if (e[0] === ze && (yield* this.pushCount(1), e = e.substring(1)), e[0] === "%") {
3748
- let t = e.length, n = e.indexOf("#");
3749
- for (; n !== -1; ) {
3750
- const r = e[n - 1];
3751
- if (r === " " || r === " ") {
3752
- t = n - 1;
3753
- break;
3754
- } else
3755
- n = e.indexOf("#", n + 1);
3756
- }
3757
- for (; ; ) {
3758
- const r = e[t - 1];
3759
- if (r === " " || r === " ")
3760
- t -= 1;
3761
- else
3762
- break;
3763
- }
3764
- const i = (yield* this.pushCount(t)) + (yield* this.pushSpaces(!0));
3765
- return yield* this.pushCount(e.length - i), this.pushNewline(), "stream";
3766
- }
3767
- if (this.atLineEnd()) {
3768
- const t = yield* this.pushSpaces(!0);
3769
- return yield* this.pushCount(e.length - t), yield* this.pushNewline(), "stream";
3770
- }
3771
- return yield Ze, yield* this.parseLineStart();
3772
- }
3773
- *parseLineStart() {
3774
- const e = this.charAt(0);
3775
- if (!e && !this.atEnd)
3776
- return this.setNext("line-start");
3777
- if (e === "-" || e === ".") {
3778
- if (!this.atEnd && !this.hasChars(4))
3779
- return this.setNext("line-start");
3780
- const t = this.peek(3);
3781
- if ((t === "---" || t === "...") && j(this.charAt(3)))
3782
- return yield* this.pushCount(3), this.indentValue = 0, this.indentNext = 0, t === "---" ? "doc" : "stream";
3783
- }
3784
- return this.indentValue = yield* this.pushSpaces(!1), this.indentNext > this.indentValue && !j(this.charAt(1)) && (this.indentNext = this.indentValue), yield* this.parseBlockStart();
3785
- }
3786
- *parseBlockStart() {
3787
- const [e, t] = this.peek(2);
3788
- if (!t && !this.atEnd)
3789
- return this.setNext("block-start");
3790
- if ((e === "-" || e === "?" || e === ":") && j(t)) {
3791
- const n = (yield* this.pushCount(1)) + (yield* this.pushSpaces(!0));
3792
- return this.indentNext = this.indentValue + 1, this.indentValue += n, yield* this.parseBlockStart();
3793
- }
3794
- return "doc";
3795
- }
3796
- *parseDocument() {
3797
- yield* this.pushSpaces(!0);
3798
- const e = this.getLine();
3799
- if (e === null)
3800
- return this.setNext("doc");
3801
- let t = yield* this.pushIndicators();
3802
- switch (e[t]) {
3803
- case "#":
3804
- yield* this.pushCount(e.length - t);
3805
- // fallthrough
3806
- case void 0:
3807
- return yield* this.pushNewline(), yield* this.parseLineStart();
3808
- case "{":
3809
- case "[":
3810
- return yield* this.pushCount(1), this.flowKey = !1, this.flowLevel = 1, "flow";
3811
- case "}":
3812
- case "]":
3813
- return yield* this.pushCount(1), "doc";
3814
- case "*":
3815
- return yield* this.pushUntil(ot), "doc";
3816
- case '"':
3817
- case "'":
3818
- return yield* this.parseQuotedScalar();
3819
- case "|":
3820
- case ">":
3821
- return t += yield* this.parseBlockScalarHeader(), t += yield* this.pushSpaces(!0), yield* this.pushCount(e.length - t), yield* this.pushNewline(), yield* this.parseBlockScalar();
3822
- default:
3823
- return yield* this.parsePlainScalar();
3824
- }
3825
- }
3826
- *parseFlowCollection() {
3827
- let e, t, n = -1;
3828
- do
3829
- e = yield* this.pushNewline(), e > 0 ? (t = yield* this.pushSpaces(!1), this.indentValue = n = t) : t = 0, t += yield* this.pushSpaces(!0);
3830
- while (e + t > 0);
3831
- const i = this.getLine();
3832
- if (i === null)
3833
- return this.setNext("flow");
3834
- if ((n !== -1 && n < this.indentNext && i[0] !== "#" || n === 0 && (i.startsWith("---") || i.startsWith("...")) && j(i[3])) && !(n === this.indentNext - 1 && this.flowLevel === 1 && (i[0] === "]" || i[0] === "}")))
3835
- return this.flowLevel = 0, yield xe, yield* this.parseLineStart();
3836
- let r = 0;
3837
- for (; i[r] === ","; )
3838
- r += yield* this.pushCount(1), r += yield* this.pushSpaces(!0), this.flowKey = !1;
3839
- switch (r += yield* this.pushIndicators(), i[r]) {
3840
- case void 0:
3841
- return "flow";
3842
- case "#":
3843
- return yield* this.pushCount(i.length - r), "flow";
3844
- case "{":
3845
- case "[":
3846
- return yield* this.pushCount(1), this.flowKey = !1, this.flowLevel += 1, "flow";
3847
- case "}":
3848
- case "]":
3849
- return yield* this.pushCount(1), this.flowKey = !0, this.flowLevel -= 1, this.flowLevel ? "flow" : "doc";
3850
- case "*":
3851
- return yield* this.pushUntil(ot), "flow";
3852
- case '"':
3853
- case "'":
3854
- return this.flowKey = !0, yield* this.parseQuotedScalar();
3855
- case ":": {
3856
- const o = this.charAt(1);
3857
- if (this.flowKey || j(o) || o === ",")
3858
- return this.flowKey = !1, yield* this.pushCount(1), yield* this.pushSpaces(!0), "flow";
3859
- }
3860
- // fallthrough
3861
- default:
3862
- return this.flowKey = !1, yield* this.parsePlainScalar();
3863
- }
3864
- }
3865
- *parseQuotedScalar() {
3866
- const e = this.charAt(0);
3867
- let t = this.buffer.indexOf(e, this.pos + 1);
3868
- if (e === "'")
3869
- for (; t !== -1 && this.buffer[t + 1] === "'"; )
3870
- t = this.buffer.indexOf("'", t + 2);
3871
- else
3872
- for (; t !== -1; ) {
3873
- let r = 0;
3874
- for (; this.buffer[t - 1 - r] === "\\"; )
3875
- r += 1;
3876
- if (r % 2 === 0)
3877
- break;
3878
- t = this.buffer.indexOf('"', t + 1);
3879
- }
3880
- const n = this.buffer.substring(0, t);
3881
- let i = n.indexOf(`
3882
- `, this.pos);
3883
- if (i !== -1) {
3884
- for (; i !== -1; ) {
3885
- const r = this.continueScalar(i + 1);
3886
- if (r === -1)
3887
- break;
3888
- i = n.indexOf(`
3889
- `, r);
3890
- }
3891
- i !== -1 && (t = i - (n[i - 1] === "\r" ? 2 : 1));
3892
- }
3893
- if (t === -1) {
3894
- if (!this.atEnd)
3895
- return this.setNext("quoted-scalar");
3896
- t = this.buffer.length;
3897
- }
3898
- return yield* this.pushToIndex(t + 1, !1), this.flowLevel ? "flow" : "doc";
3899
- }
3900
- *parseBlockScalarHeader() {
3901
- this.blockScalarIndent = -1, this.blockScalarKeep = !1;
3902
- let e = this.pos;
3903
- for (; ; ) {
3904
- const t = this.buffer[++e];
3905
- if (t === "+")
3906
- this.blockScalarKeep = !0;
3907
- else if (t > "0" && t <= "9")
3908
- this.blockScalarIndent = Number(t) - 1;
3909
- else if (t !== "-")
3910
- break;
3911
- }
3912
- return yield* this.pushUntil((t) => j(t) || t === "#");
3913
- }
3914
- *parseBlockScalar() {
3915
- let e = this.pos - 1, t = 0, n;
3916
- e: for (let r = this.pos; n = this.buffer[r]; ++r)
3917
- switch (n) {
3918
- case " ":
3919
- t += 1;
3920
- break;
3921
- case `
3922
- `:
3923
- e = r, t = 0;
3924
- break;
3925
- case "\r": {
3926
- const o = this.buffer[r + 1];
3927
- if (!o && !this.atEnd)
3928
- return this.setNext("block-scalar");
3929
- if (o === `
3930
- `)
3931
- break;
3932
- }
3933
- // fallthrough
3934
- default:
3935
- break e;
3936
- }
3937
- if (!n && !this.atEnd)
3938
- return this.setNext("block-scalar");
3939
- if (t >= this.indentNext) {
3940
- this.blockScalarIndent === -1 ? this.indentNext = t : this.indentNext = this.blockScalarIndent + (this.indentNext === 0 ? 1 : this.indentNext);
3941
- do {
3942
- const r = this.continueScalar(e + 1);
3943
- if (r === -1)
3944
- break;
3945
- e = this.buffer.indexOf(`
3946
- `, r);
3947
- } while (e !== -1);
3948
- if (e === -1) {
3949
- if (!this.atEnd)
3950
- return this.setNext("block-scalar");
3951
- e = this.buffer.length;
3952
- }
3953
- }
3954
- let i = e + 1;
3955
- for (n = this.buffer[i]; n === " "; )
3956
- n = this.buffer[++i];
3957
- if (n === " ") {
3958
- for (; n === " " || n === " " || n === "\r" || n === `
3959
- `; )
3960
- n = this.buffer[++i];
3961
- e = i - 1;
3962
- } else if (!this.blockScalarKeep)
3963
- do {
3964
- let r = e - 1, o = this.buffer[r];
3965
- o === "\r" && (o = this.buffer[--r]);
3966
- const l = r;
3967
- for (; o === " "; )
3968
- o = this.buffer[--r];
3969
- if (o === `
3970
- ` && r >= this.pos && r + 1 + t > l)
3971
- e = r;
3972
- else
3973
- break;
3974
- } while (!0);
3975
- return yield Oe, yield* this.pushToIndex(e + 1, !0), yield* this.parseLineStart();
3976
- }
3977
- *parsePlainScalar() {
3978
- const e = this.flowLevel > 0;
3979
- let t = this.pos - 1, n = this.pos - 1, i;
3980
- for (; i = this.buffer[++n]; )
3981
- if (i === ":") {
3982
- const r = this.buffer[n + 1];
3983
- if (j(r) || e && _e.has(r))
3984
- break;
3985
- t = n;
3986
- } else if (j(i)) {
3987
- let r = this.buffer[n + 1];
3988
- if (i === "\r" && (r === `
3989
- ` ? (n += 1, i = `
3990
- `, r = this.buffer[n + 1]) : t = n), r === "#" || e && _e.has(r))
3991
- break;
3992
- if (i === `
3993
- `) {
3994
- const o = this.continueScalar(n + 1);
3995
- if (o === -1)
3996
- break;
3997
- n = Math.max(n, o - 2);
3998
- }
3999
- } else {
4000
- if (e && _e.has(i))
4001
- break;
4002
- t = n;
4003
- }
4004
- return !i && !this.atEnd ? this.setNext("plain-scalar") : (yield Oe, yield* this.pushToIndex(t + 1, !0), e ? "flow" : "doc");
4005
- }
4006
- *pushCount(e) {
4007
- return e > 0 ? (yield this.buffer.substr(this.pos, e), this.pos += e, e) : 0;
4008
- }
4009
- *pushToIndex(e, t) {
4010
- const n = this.buffer.slice(this.pos, e);
4011
- return n ? (yield n, this.pos += n.length, n.length) : (t && (yield ""), 0);
4012
- }
4013
- *pushIndicators() {
4014
- switch (this.charAt(0)) {
4015
- case "!":
4016
- return (yield* this.pushTag()) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
4017
- case "&":
4018
- return (yield* this.pushUntil(ot)) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
4019
- case "-":
4020
- // this is an error
4021
- case "?":
4022
- // this is an error outside flow collections
4023
- case ":": {
4024
- const e = this.flowLevel > 0, t = this.charAt(1);
4025
- if (j(t) || e && _e.has(t))
4026
- return e ? this.flowKey && (this.flowKey = !1) : this.indentNext = this.indentValue + 1, (yield* this.pushCount(1)) + (yield* this.pushSpaces(!0)) + (yield* this.pushIndicators());
4027
- }
4028
- }
4029
- return 0;
4030
- }
4031
- *pushTag() {
4032
- if (this.charAt(1) === "<") {
4033
- let e = this.pos + 2, t = this.buffer[e];
4034
- for (; !j(t) && t !== ">"; )
4035
- t = this.buffer[++e];
4036
- return yield* this.pushToIndex(t === ">" ? e + 1 : e, !1);
4037
- } else {
4038
- let e = this.pos + 1, t = this.buffer[e];
4039
- for (; t; )
4040
- if (Dn.has(t))
4041
- t = this.buffer[++e];
4042
- else if (t === "%" && Pt.has(this.buffer[e + 1]) && Pt.has(this.buffer[e + 2]))
4043
- t = this.buffer[e += 3];
4044
- else
4045
- break;
4046
- return yield* this.pushToIndex(e, !1);
4047
- }
4048
- }
4049
- *pushNewline() {
4050
- const e = this.buffer[this.pos];
4051
- return e === `
4052
- ` ? yield* this.pushCount(1) : e === "\r" && this.charAt(1) === `
4053
- ` ? yield* this.pushCount(2) : 0;
4054
- }
4055
- *pushSpaces(e) {
4056
- let t = this.pos - 1, n;
4057
- do
4058
- n = this.buffer[++t];
4059
- while (n === " " || e && n === " ");
4060
- const i = t - this.pos;
4061
- return i > 0 && (yield this.buffer.substr(this.pos, i), this.pos = t), i;
4062
- }
4063
- *pushUntil(e) {
4064
- let t = this.pos, n = this.buffer[t];
4065
- for (; !e(n); )
4066
- n = this.buffer[++t];
4067
- return yield* this.pushToIndex(t, !1);
4068
- }
4069
- }
4070
- class Ls {
4071
- constructor() {
4072
- this.lineStarts = [], this.addNewLine = (e) => this.lineStarts.push(e), this.linePos = (e) => {
4073
- let t = 0, n = this.lineStarts.length;
4074
- for (; t < n; ) {
4075
- const r = t + n >> 1;
4076
- this.lineStarts[r] < e ? t = r + 1 : n = r;
4077
- }
4078
- if (this.lineStarts[t] === e)
4079
- return { line: t + 1, col: 1 };
4080
- if (t === 0)
4081
- return { line: 0, col: e };
4082
- const i = this.lineStarts[t - 1];
4083
- return { line: t, col: e - i + 1 };
4084
- };
4085
- }
4086
- }
4087
- function W(s, e) {
4088
- for (let t = 0; t < s.length; ++t)
4089
- if (s[t].type === e)
4090
- return !0;
4091
- return !1;
4092
- }
4093
- function Dt(s) {
4094
- for (let e = 0; e < s.length; ++e)
4095
- switch (s[e].type) {
4096
- case "space":
4097
- case "comment":
4098
- case "newline":
4099
- break;
4100
- default:
4101
- return e;
4102
- }
4103
- return -1;
4104
- }
4105
- function $s(s) {
4106
- switch (s == null ? void 0 : s.type) {
4107
- case "alias":
4108
- case "scalar":
4109
- case "single-quoted-scalar":
4110
- case "double-quoted-scalar":
4111
- case "flow-collection":
4112
- return !0;
4113
- default:
4114
- return !1;
4115
- }
4116
- }
4117
- function Ce(s) {
4118
- switch (s.type) {
4119
- case "document":
4120
- return s.start;
4121
- case "block-map": {
4122
- const e = s.items[s.items.length - 1];
4123
- return e.sep ?? e.start;
4124
- }
4125
- case "block-seq":
4126
- return s.items[s.items.length - 1].start;
4127
- /* istanbul ignore next should not happen */
4128
- default:
4129
- return [];
4130
- }
4131
- }
4132
- function ne(s) {
4133
- var t;
4134
- if (s.length === 0)
4135
- return [];
4136
- let e = s.length;
4137
- e: for (; --e >= 0; )
4138
- switch (s[e].type) {
4139
- case "doc-start":
4140
- case "explicit-key-ind":
4141
- case "map-value-ind":
4142
- case "seq-item-ind":
4143
- case "newline":
4144
- break e;
4145
- }
4146
- for (; ((t = s[++e]) == null ? void 0 : t.type) === "space"; )
4147
- ;
4148
- return s.splice(e, s.length);
4149
- }
4150
- function jt(s) {
4151
- if (s.start.type === "flow-seq-start")
4152
- for (const e of s.items)
4153
- e.sep && !e.value && !W(e.start, "explicit-key-ind") && !W(e.sep, "map-value-ind") && (e.key && (e.value = e.key), delete e.key, $s(e.value) ? e.value.end ? Array.prototype.push.apply(e.value.end, e.sep) : e.value.end = e.sep : Array.prototype.push.apply(e.start, e.sep), delete e.sep);
4154
- }
4155
- class It {
4156
- /**
4157
- * @param onNewLine - If defined, called separately with the start position of
4158
- * each new line (in `parse()`, including the start of input).
4159
- */
4160
- constructor(e) {
4161
- this.atNewLine = !0, this.atScalar = !1, this.indent = 0, this.offset = 0, this.onKeyLine = !1, this.stack = [], this.source = "", this.type = "", this.lexer = new Is(), this.onNewLine = e;
4162
- }
4163
- /**
4164
- * Parse `source` as a YAML stream.
4165
- * If `incomplete`, a part of the last line may be left as a buffer for the next call.
4166
- *
4167
- * Errors are not thrown, but yielded as `{ type: 'error', message }` tokens.
4168
- *
4169
- * @returns A generator of tokens representing each directive, document, and other structure.
4170
- */
4171
- *parse(e, t = !1) {
4172
- this.onNewLine && this.offset === 0 && this.onNewLine(0);
4173
- for (const n of this.lexer.lex(e, t))
4174
- yield* this.next(n);
4175
- t || (yield* this.end());
4176
- }
4177
- /**
4178
- * Advance the parser by the `source` of one lexical token.
4179
- */
4180
- *next(e) {
4181
- if (this.source = e, this.atScalar) {
4182
- this.atScalar = !1, yield* this.step(), this.offset += e.length;
4183
- return;
4184
- }
4185
- const t = Ts(e);
4186
- if (t)
4187
- if (t === "scalar")
4188
- this.atNewLine = !1, this.atScalar = !0, this.type = "scalar";
4189
- else {
4190
- switch (this.type = t, yield* this.step(), t) {
4191
- case "newline":
4192
- this.atNewLine = !0, this.indent = 0, this.onNewLine && this.onNewLine(this.offset + e.length);
4193
- break;
4194
- case "space":
4195
- this.atNewLine && e[0] === " " && (this.indent += e.length);
4196
- break;
4197
- case "explicit-key-ind":
4198
- case "map-value-ind":
4199
- case "seq-item-ind":
4200
- this.atNewLine && (this.indent += e.length);
4201
- break;
4202
- case "doc-mode":
4203
- case "flow-error-end":
4204
- return;
4205
- default:
4206
- this.atNewLine = !1;
4207
- }
4208
- this.offset += e.length;
4209
- }
4210
- else {
4211
- const n = `Not a YAML token: ${e}`;
4212
- yield* this.pop({ type: "error", offset: this.offset, message: n, source: e }), this.offset += e.length;
4213
- }
4214
- }
4215
- /** Call at end of input to push out any remaining constructions */
4216
- *end() {
4217
- for (; this.stack.length > 0; )
4218
- yield* this.pop();
4219
- }
4220
- get sourceToken() {
4221
- return {
4222
- type: this.type,
4223
- offset: this.offset,
4224
- indent: this.indent,
4225
- source: this.source
4226
- };
4227
- }
4228
- *step() {
4229
- const e = this.peek(1);
4230
- if (this.type === "doc-end" && (!e || e.type !== "doc-end")) {
4231
- for (; this.stack.length > 0; )
4232
- yield* this.pop();
4233
- this.stack.push({
4234
- type: "doc-end",
4235
- offset: this.offset,
4236
- source: this.source
4237
- });
4238
- return;
4239
- }
4240
- if (!e)
4241
- return yield* this.stream();
4242
- switch (e.type) {
4243
- case "document":
4244
- return yield* this.document(e);
4245
- case "alias":
4246
- case "scalar":
4247
- case "single-quoted-scalar":
4248
- case "double-quoted-scalar":
4249
- return yield* this.scalar(e);
4250
- case "block-scalar":
4251
- return yield* this.blockScalar(e);
4252
- case "block-map":
4253
- return yield* this.blockMap(e);
4254
- case "block-seq":
4255
- return yield* this.blockSequence(e);
4256
- case "flow-collection":
4257
- return yield* this.flowCollection(e);
4258
- case "doc-end":
4259
- return yield* this.documentEnd(e);
4260
- }
4261
- yield* this.pop();
4262
- }
4263
- peek(e) {
4264
- return this.stack[this.stack.length - e];
4265
- }
4266
- *pop(e) {
4267
- const t = e ?? this.stack.pop();
4268
- if (!t)
4269
- yield { type: "error", offset: this.offset, source: "", message: "Tried to pop an empty stack" };
4270
- else if (this.stack.length === 0)
4271
- yield t;
4272
- else {
4273
- const n = this.peek(1);
4274
- switch (t.type === "block-scalar" ? t.indent = "indent" in n ? n.indent : 0 : t.type === "flow-collection" && n.type === "document" && (t.indent = 0), t.type === "flow-collection" && jt(t), n.type) {
4275
- case "document":
4276
- n.value = t;
4277
- break;
4278
- case "block-scalar":
4279
- n.props.push(t);
4280
- break;
4281
- case "block-map": {
4282
- const i = n.items[n.items.length - 1];
4283
- if (i.value) {
4284
- n.items.push({ start: [], key: t, sep: [] }), this.onKeyLine = !0;
4285
- return;
4286
- } else if (i.sep)
4287
- i.value = t;
4288
- else {
4289
- Object.assign(i, { key: t, sep: [] }), this.onKeyLine = !i.explicitKey;
4290
- return;
4291
- }
4292
- break;
4293
- }
4294
- case "block-seq": {
4295
- const i = n.items[n.items.length - 1];
4296
- i.value ? n.items.push({ start: [], value: t }) : i.value = t;
4297
- break;
4298
- }
4299
- case "flow-collection": {
4300
- const i = n.items[n.items.length - 1];
4301
- !i || i.value ? n.items.push({ start: [], key: t, sep: [] }) : i.sep ? i.value = t : Object.assign(i, { key: t, sep: [] });
4302
- return;
4303
- }
4304
- /* istanbul ignore next should not happen */
4305
- default:
4306
- yield* this.pop(), yield* this.pop(t);
4307
- }
4308
- if ((n.type === "document" || n.type === "block-map" || n.type === "block-seq") && (t.type === "block-map" || t.type === "block-seq")) {
4309
- const i = t.items[t.items.length - 1];
4310
- i && !i.sep && !i.value && i.start.length > 0 && Dt(i.start) === -1 && (t.indent === 0 || i.start.every((r) => r.type !== "comment" || r.indent < t.indent)) && (n.type === "document" ? n.end = i.start : n.items.push({ start: i.start }), t.items.splice(-1, 1));
4311
- }
4312
- }
4313
- }
4314
- *stream() {
4315
- switch (this.type) {
4316
- case "directive-line":
4317
- yield { type: "directive", offset: this.offset, source: this.source };
4318
- return;
4319
- case "byte-order-mark":
4320
- case "space":
4321
- case "comment":
4322
- case "newline":
4323
- yield this.sourceToken;
4324
- return;
4325
- case "doc-mode":
4326
- case "doc-start": {
4327
- const e = {
4328
- type: "document",
4329
- offset: this.offset,
4330
- start: []
4331
- };
4332
- this.type === "doc-start" && e.start.push(this.sourceToken), this.stack.push(e);
4333
- return;
4334
- }
4335
- }
4336
- yield {
4337
- type: "error",
4338
- offset: this.offset,
4339
- message: `Unexpected ${this.type} token in YAML stream`,
4340
- source: this.source
4341
- };
4342
- }
4343
- *document(e) {
4344
- if (e.value)
4345
- return yield* this.lineEnd(e);
4346
- switch (this.type) {
4347
- case "doc-start": {
4348
- Dt(e.start) !== -1 ? (yield* this.pop(), yield* this.step()) : e.start.push(this.sourceToken);
4349
- return;
4350
- }
4351
- case "anchor":
4352
- case "tag":
4353
- case "space":
4354
- case "comment":
4355
- case "newline":
4356
- e.start.push(this.sourceToken);
4357
- return;
4358
- }
4359
- const t = this.startBlockValue(e);
4360
- t ? this.stack.push(t) : yield {
4361
- type: "error",
4362
- offset: this.offset,
4363
- message: `Unexpected ${this.type} token in YAML document`,
4364
- source: this.source
4365
- };
4366
- }
4367
- *scalar(e) {
4368
- if (this.type === "map-value-ind") {
4369
- const t = Ce(this.peek(2)), n = ne(t);
4370
- let i;
4371
- e.end ? (i = e.end, i.push(this.sourceToken), delete e.end) : i = [this.sourceToken];
4372
- const r = {
4373
- type: "block-map",
4374
- offset: e.offset,
4375
- indent: e.indent,
4376
- items: [{ start: n, key: e, sep: i }]
4377
- };
4378
- this.onKeyLine = !0, this.stack[this.stack.length - 1] = r;
4379
- } else
4380
- yield* this.lineEnd(e);
4381
- }
4382
- *blockScalar(e) {
4383
- switch (this.type) {
4384
- case "space":
4385
- case "comment":
4386
- case "newline":
4387
- e.props.push(this.sourceToken);
4388
- return;
4389
- case "scalar":
4390
- if (e.source = this.source, this.atNewLine = !0, this.indent = 0, this.onNewLine) {
4391
- let t = this.source.indexOf(`
4392
- `) + 1;
4393
- for (; t !== 0; )
4394
- this.onNewLine(this.offset + t), t = this.source.indexOf(`
4395
- `, t) + 1;
4396
- }
4397
- yield* this.pop();
4398
- break;
4399
- /* istanbul ignore next should not happen */
4400
- default:
4401
- yield* this.pop(), yield* this.step();
4402
- }
4403
- }
4404
- *blockMap(e) {
4405
- var n;
4406
- const t = e.items[e.items.length - 1];
4407
- switch (this.type) {
4408
- case "newline":
4409
- if (this.onKeyLine = !1, t.value) {
4410
- const i = "end" in t.value ? t.value.end : void 0, r = Array.isArray(i) ? i[i.length - 1] : void 0;
4411
- (r == null ? void 0 : r.type) === "comment" ? i == null || i.push(this.sourceToken) : e.items.push({ start: [this.sourceToken] });
4412
- } else t.sep ? t.sep.push(this.sourceToken) : t.start.push(this.sourceToken);
4413
- return;
4414
- case "space":
4415
- case "comment":
4416
- if (t.value)
4417
- e.items.push({ start: [this.sourceToken] });
4418
- else if (t.sep)
4419
- t.sep.push(this.sourceToken);
4420
- else {
4421
- if (this.atIndentedComment(t.start, e.indent)) {
4422
- const i = e.items[e.items.length - 2], r = (n = i == null ? void 0 : i.value) == null ? void 0 : n.end;
4423
- if (Array.isArray(r)) {
4424
- Array.prototype.push.apply(r, t.start), r.push(this.sourceToken), e.items.pop();
4425
- return;
4426
- }
4427
- }
4428
- t.start.push(this.sourceToken);
4429
- }
4430
- return;
4431
- }
4432
- if (this.indent >= e.indent) {
4433
- const i = !this.onKeyLine && this.indent === e.indent, r = i && (t.sep || t.explicitKey) && this.type !== "seq-item-ind";
4434
- let o = [];
4435
- if (r && t.sep && !t.value) {
4436
- const l = [];
4437
- for (let a = 0; a < t.sep.length; ++a) {
4438
- const c = t.sep[a];
4439
- switch (c.type) {
4440
- case "newline":
4441
- l.push(a);
4442
- break;
4443
- case "space":
4444
- break;
4445
- case "comment":
4446
- c.indent > e.indent && (l.length = 0);
4447
- break;
4448
- default:
4449
- l.length = 0;
4450
- }
4451
- }
4452
- l.length >= 2 && (o = t.sep.splice(l[1]));
4453
- }
4454
- switch (this.type) {
4455
- case "anchor":
4456
- case "tag":
4457
- r || t.value ? (o.push(this.sourceToken), e.items.push({ start: o }), this.onKeyLine = !0) : t.sep ? t.sep.push(this.sourceToken) : t.start.push(this.sourceToken);
4458
- return;
4459
- case "explicit-key-ind":
4460
- !t.sep && !t.explicitKey ? (t.start.push(this.sourceToken), t.explicitKey = !0) : r || t.value ? (o.push(this.sourceToken), e.items.push({ start: o, explicitKey: !0 })) : this.stack.push({
4461
- type: "block-map",
4462
- offset: this.offset,
4463
- indent: this.indent,
4464
- items: [{ start: [this.sourceToken], explicitKey: !0 }]
4465
- }), this.onKeyLine = !0;
4466
- return;
4467
- case "map-value-ind":
4468
- if (t.explicitKey)
4469
- if (t.sep)
4470
- if (t.value)
4471
- e.items.push({ start: [], key: null, sep: [this.sourceToken] });
4472
- else if (W(t.sep, "map-value-ind"))
4473
- this.stack.push({
4474
- type: "block-map",
4475
- offset: this.offset,
4476
- indent: this.indent,
4477
- items: [{ start: o, key: null, sep: [this.sourceToken] }]
4478
- });
4479
- else if ($s(t.key) && !W(t.sep, "newline")) {
4480
- const l = ne(t.start), a = t.key, c = t.sep;
4481
- c.push(this.sourceToken), delete t.key, delete t.sep, this.stack.push({
4482
- type: "block-map",
4483
- offset: this.offset,
4484
- indent: this.indent,
4485
- items: [{ start: l, key: a, sep: c }]
4486
- });
4487
- } else o.length > 0 ? t.sep = t.sep.concat(o, this.sourceToken) : t.sep.push(this.sourceToken);
4488
- else if (W(t.start, "newline"))
4489
- Object.assign(t, { key: null, sep: [this.sourceToken] });
4490
- else {
4491
- const l = ne(t.start);
4492
- this.stack.push({
4493
- type: "block-map",
4494
- offset: this.offset,
4495
- indent: this.indent,
4496
- items: [{ start: l, key: null, sep: [this.sourceToken] }]
4497
- });
4498
- }
4499
- else
4500
- t.sep ? t.value || r ? e.items.push({ start: o, key: null, sep: [this.sourceToken] }) : W(t.sep, "map-value-ind") ? this.stack.push({
4501
- type: "block-map",
4502
- offset: this.offset,
4503
- indent: this.indent,
4504
- items: [{ start: [], key: null, sep: [this.sourceToken] }]
4505
- }) : t.sep.push(this.sourceToken) : Object.assign(t, { key: null, sep: [this.sourceToken] });
4506
- this.onKeyLine = !0;
4507
- return;
4508
- case "alias":
4509
- case "scalar":
4510
- case "single-quoted-scalar":
4511
- case "double-quoted-scalar": {
4512
- const l = this.flowScalar(this.type);
4513
- r || t.value ? (e.items.push({ start: o, key: l, sep: [] }), this.onKeyLine = !0) : t.sep ? this.stack.push(l) : (Object.assign(t, { key: l, sep: [] }), this.onKeyLine = !0);
4514
- return;
4515
- }
4516
- default: {
4517
- const l = this.startBlockValue(e);
4518
- if (l) {
4519
- i && l.type !== "block-seq" && e.items.push({ start: o }), this.stack.push(l);
4520
- return;
4521
- }
4522
- }
4523
- }
4524
- }
4525
- yield* this.pop(), yield* this.step();
4526
- }
4527
- *blockSequence(e) {
4528
- var n;
4529
- const t = e.items[e.items.length - 1];
4530
- switch (this.type) {
4531
- case "newline":
4532
- if (t.value) {
4533
- const i = "end" in t.value ? t.value.end : void 0, r = Array.isArray(i) ? i[i.length - 1] : void 0;
4534
- (r == null ? void 0 : r.type) === "comment" ? i == null || i.push(this.sourceToken) : e.items.push({ start: [this.sourceToken] });
4535
- } else
4536
- t.start.push(this.sourceToken);
4537
- return;
4538
- case "space":
4539
- case "comment":
4540
- if (t.value)
4541
- e.items.push({ start: [this.sourceToken] });
4542
- else {
4543
- if (this.atIndentedComment(t.start, e.indent)) {
4544
- const i = e.items[e.items.length - 2], r = (n = i == null ? void 0 : i.value) == null ? void 0 : n.end;
4545
- if (Array.isArray(r)) {
4546
- Array.prototype.push.apply(r, t.start), r.push(this.sourceToken), e.items.pop();
4547
- return;
4548
- }
4549
- }
4550
- t.start.push(this.sourceToken);
4551
- }
4552
- return;
4553
- case "anchor":
4554
- case "tag":
4555
- if (t.value || this.indent <= e.indent)
4556
- break;
4557
- t.start.push(this.sourceToken);
4558
- return;
4559
- case "seq-item-ind":
4560
- if (this.indent !== e.indent)
4561
- break;
4562
- t.value || W(t.start, "seq-item-ind") ? e.items.push({ start: [this.sourceToken] }) : t.start.push(this.sourceToken);
4563
- return;
4564
- }
4565
- if (this.indent > e.indent) {
4566
- const i = this.startBlockValue(e);
4567
- if (i) {
4568
- this.stack.push(i);
4569
- return;
4570
- }
4571
- }
4572
- yield* this.pop(), yield* this.step();
4573
- }
4574
- *flowCollection(e) {
4575
- const t = e.items[e.items.length - 1];
4576
- if (this.type === "flow-error-end") {
4577
- let n;
4578
- do
4579
- yield* this.pop(), n = this.peek(1);
4580
- while (n && n.type === "flow-collection");
4581
- } else if (e.end.length === 0) {
4582
- switch (this.type) {
4583
- case "comma":
4584
- case "explicit-key-ind":
4585
- !t || t.sep ? e.items.push({ start: [this.sourceToken] }) : t.start.push(this.sourceToken);
4586
- return;
4587
- case "map-value-ind":
4588
- !t || t.value ? e.items.push({ start: [], key: null, sep: [this.sourceToken] }) : t.sep ? t.sep.push(this.sourceToken) : Object.assign(t, { key: null, sep: [this.sourceToken] });
4589
- return;
4590
- case "space":
4591
- case "comment":
4592
- case "newline":
4593
- case "anchor":
4594
- case "tag":
4595
- !t || t.value ? e.items.push({ start: [this.sourceToken] }) : t.sep ? t.sep.push(this.sourceToken) : t.start.push(this.sourceToken);
4596
- return;
4597
- case "alias":
4598
- case "scalar":
4599
- case "single-quoted-scalar":
4600
- case "double-quoted-scalar": {
4601
- const i = this.flowScalar(this.type);
4602
- !t || t.value ? e.items.push({ start: [], key: i, sep: [] }) : t.sep ? this.stack.push(i) : Object.assign(t, { key: i, sep: [] });
4603
- return;
4604
- }
4605
- case "flow-map-end":
4606
- case "flow-seq-end":
4607
- e.end.push(this.sourceToken);
4608
- return;
4609
- }
4610
- const n = this.startBlockValue(e);
4611
- n ? this.stack.push(n) : (yield* this.pop(), yield* this.step());
4612
- } else {
4613
- const n = this.peek(2);
4614
- if (n.type === "block-map" && (this.type === "map-value-ind" && n.indent === e.indent || this.type === "newline" && !n.items[n.items.length - 1].sep))
4615
- yield* this.pop(), yield* this.step();
4616
- else if (this.type === "map-value-ind" && n.type !== "flow-collection") {
4617
- const i = Ce(n), r = ne(i);
4618
- jt(e);
4619
- const o = e.end.splice(1, e.end.length);
4620
- o.push(this.sourceToken);
4621
- const l = {
4622
- type: "block-map",
4623
- offset: e.offset,
4624
- indent: e.indent,
4625
- items: [{ start: r, key: e, sep: o }]
4626
- };
4627
- this.onKeyLine = !0, this.stack[this.stack.length - 1] = l;
4628
- } else
4629
- yield* this.lineEnd(e);
4630
- }
4631
- }
4632
- flowScalar(e) {
4633
- if (this.onNewLine) {
4634
- let t = this.source.indexOf(`
4635
- `) + 1;
4636
- for (; t !== 0; )
4637
- this.onNewLine(this.offset + t), t = this.source.indexOf(`
4638
- `, t) + 1;
4639
- }
4640
- return {
4641
- type: e,
4642
- offset: this.offset,
4643
- indent: this.indent,
4644
- source: this.source
4645
- };
4646
- }
4647
- startBlockValue(e) {
4648
- switch (this.type) {
4649
- case "alias":
4650
- case "scalar":
4651
- case "single-quoted-scalar":
4652
- case "double-quoted-scalar":
4653
- return this.flowScalar(this.type);
4654
- case "block-scalar-header":
4655
- return {
4656
- type: "block-scalar",
4657
- offset: this.offset,
4658
- indent: this.indent,
4659
- props: [this.sourceToken],
4660
- source: ""
4661
- };
4662
- case "flow-map-start":
4663
- case "flow-seq-start":
4664
- return {
4665
- type: "flow-collection",
4666
- offset: this.offset,
4667
- indent: this.indent,
4668
- start: this.sourceToken,
4669
- items: [],
4670
- end: []
4671
- };
4672
- case "seq-item-ind":
4673
- return {
4674
- type: "block-seq",
4675
- offset: this.offset,
4676
- indent: this.indent,
4677
- items: [{ start: [this.sourceToken] }]
4678
- };
4679
- case "explicit-key-ind": {
4680
- this.onKeyLine = !0;
4681
- const t = Ce(e), n = ne(t);
4682
- return n.push(this.sourceToken), {
4683
- type: "block-map",
4684
- offset: this.offset,
4685
- indent: this.indent,
4686
- items: [{ start: n, explicitKey: !0 }]
4687
- };
4688
- }
4689
- case "map-value-ind": {
4690
- this.onKeyLine = !0;
4691
- const t = Ce(e), n = ne(t);
4692
- return {
4693
- type: "block-map",
4694
- offset: this.offset,
4695
- indent: this.indent,
4696
- items: [{ start: n, key: null, sep: [this.sourceToken] }]
4697
- };
4698
- }
4699
- }
4700
- return null;
4701
- }
4702
- atIndentedComment(e, t) {
4703
- return this.type !== "comment" || this.indent <= t ? !1 : e.every((n) => n.type === "newline" || n.type === "space");
4704
- }
4705
- *documentEnd(e) {
4706
- this.type !== "doc-mode" && (e.end ? e.end.push(this.sourceToken) : e.end = [this.sourceToken], this.type === "newline" && (yield* this.pop()));
4707
- }
4708
- *lineEnd(e) {
4709
- switch (this.type) {
4710
- case "comma":
4711
- case "doc-start":
4712
- case "doc-end":
4713
- case "flow-seq-end":
4714
- case "flow-map-end":
4715
- case "map-value-ind":
4716
- yield* this.pop(), yield* this.step();
4717
- break;
4718
- case "newline":
4719
- this.onKeyLine = !1;
4720
- // fallthrough
4721
- case "space":
4722
- case "comment":
4723
- default:
4724
- e.end ? e.end.push(this.sourceToken) : e.end = [this.sourceToken], this.type === "newline" && (yield* this.pop());
4725
- }
4726
- }
4727
- }
4728
- function _s(s) {
4729
- const e = s.prettyErrors !== !1;
4730
- return { lineCounter: s.lineCounter || e && new Ls() || null, prettyErrors: e };
4731
- }
4732
- function qn(s, e = {}) {
4733
- const { lineCounter: t, prettyErrors: n } = _s(e), i = new It(t == null ? void 0 : t.addNewLine), r = new Tt(e), o = Array.from(r.compose(i.parse(s)));
4734
- if (n && t)
4735
- for (const l of o)
4736
- l.errors.forEach(je(s, t)), l.warnings.forEach(je(s, t));
4737
- return o.length > 0 ? o : Object.assign([], { empty: !0 }, r.streamInfo());
4738
- }
4739
- function Cs(s, e = {}) {
4740
- const { lineCounter: t, prettyErrors: n } = _s(e), i = new It(t == null ? void 0 : t.addNewLine), r = new Tt(e);
4741
- let o = null;
4742
- for (const l of r.compose(i.parse(s), !0, s.length))
4743
- if (!o)
4744
- o = l;
4745
- else if (o.options.logLevel !== "silent") {
4746
- o.errors.push(new z(l.range.slice(0, 2), "MULTIPLE_DOCS", "Source contains multiple documents; please use YAML.parseAllDocuments()"));
4747
- break;
4748
- }
4749
- return n && t && (o.errors.forEach(je(s, t)), o.warnings.forEach(je(s, t))), o;
4750
- }
4751
- function Fn(s, e, t) {
4752
- let n;
4753
- typeof e == "function" ? n = e : t === void 0 && e && typeof e == "object" && (t = e);
4754
- const i = Cs(s, t);
4755
- if (!i)
4756
- return null;
4757
- if (i.warnings.forEach((r) => zt(i.options.logLevel, r)), i.errors.length > 0) {
4758
- if (i.options.logLevel !== "silent")
4759
- throw i.errors[0];
4760
- i.errors = [];
4761
- }
4762
- return i.toJS(Object.assign({ reviver: n }, t));
4763
- }
4764
- function Rn(s, e, t) {
4765
- let n = null;
4766
- if (typeof e == "function" || Array.isArray(e) ? n = e : t === void 0 && e && (t = e), typeof t == "string" && (t = t.length), typeof t == "number") {
4767
- const i = Math.round(t);
4768
- t = i < 1 ? void 0 : i > 8 ? { indent: 8 } : { indent: i };
4769
- }
4770
- if (s === void 0) {
4771
- const { keepUndefined: i } = t ?? e ?? {};
4772
- if (!i)
4773
- return;
4774
- }
4775
- return ee(s) && !n ? s.toString(t) : new ge(s, n, t).toString(t);
4776
- }
4777
- var Un = /* @__PURE__ */ Object.freeze({
4778
- __proto__: null,
4779
- Alias: Re,
4780
- CST: Pn,
4781
- Composer: Tt,
4782
- Document: ge,
4783
- Lexer: Is,
4784
- LineCounter: Ls,
4785
- Pair: v,
4786
- Parser: It,
4787
- Scalar: A,
4788
- Schema: Xe,
4789
- YAMLError: At,
4790
- YAMLMap: K,
4791
- YAMLParseError: z,
4792
- YAMLSeq: Q,
4793
- YAMLWarning: ys,
4794
- isAlias: x,
4795
- isCollection: L,
4796
- isDocument: ee,
4797
- isMap: de,
4798
- isNode: $,
4799
- isPair: I,
4800
- isScalar: E,
4801
- isSeq: pe,
4802
- parse: Fn,
4803
- parseAllDocuments: qn,
4804
- parseDocument: Cs,
4805
- stringify: Rn,
4806
- visit: G,
4807
- visitAsync: Fe
4808
- });
4809
- export {
4810
- Re as Alias,
4811
- Pn as CST,
4812
- Tt as Composer,
4813
- ge as Document,
4814
- Is as Lexer,
4815
- Ls as LineCounter,
4816
- v as Pair,
4817
- It as Parser,
4818
- A as Scalar,
4819
- Xe as Schema,
4820
- At as YAMLError,
4821
- K as YAMLMap,
4822
- z as YAMLParseError,
4823
- Q as YAMLSeq,
4824
- ys as YAMLWarning,
4825
- Un as default,
4826
- x as isAlias,
4827
- L as isCollection,
4828
- ee as isDocument,
4829
- de as isMap,
4830
- $ as isNode,
4831
- I as isPair,
4832
- E as isScalar,
4833
- pe as isSeq,
4834
- Fn as parse,
4835
- qn as parseAllDocuments,
4836
- Cs as parseDocument,
4837
- Rn as stringify,
4838
- G as visit,
4839
- Fe as visitAsync
4840
- };
4841
- //# sourceMappingURL=index-C7jnHK4b.js.map