copperflow 0.3.4 → 0.4.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 (295) hide show
  1. package/README.md +107 -13
  2. package/dist/app/THIRD_PARTY_LICENSES.txt +5 -0
  3. package/dist/app/assets/NewPartDialog-BBJaZFCo.js +160 -0
  4. package/dist/app/assets/VerifyPartDialog-BHLqD_WJ.css +1 -0
  5. package/dist/app/assets/VerifyPartDialog-Ey6xpQ_U.js +2 -0
  6. package/dist/app/assets/index-BKoIKo22.css +1 -0
  7. package/dist/app/assets/index-DPmr2dR1.js +20 -0
  8. package/dist/app/assets/texture-worker-CyI_g_XZ.js +1 -0
  9. package/dist/app/index.html +2 -2
  10. package/dist/cli-commands.js +120 -16
  11. package/dist/cli-commands.js.map +1 -1
  12. package/dist/cli-impedance.d.ts +4 -0
  13. package/dist/cli-impedance.js +56 -0
  14. package/dist/cli-impedance.js.map +1 -0
  15. package/dist/cli-simulate.d.ts +3 -0
  16. package/dist/cli-simulate.js +54 -0
  17. package/dist/cli-simulate.js.map +1 -0
  18. package/dist/core/analyze.js +5 -2
  19. package/dist/core/analyze.js.map +1 -1
  20. package/dist/core/bom.d.ts +6 -1
  21. package/dist/core/bom.js +23 -4
  22. package/dist/core/bom.js.map +1 -1
  23. package/dist/core/case-results.d.ts +4 -0
  24. package/dist/core/case-results.js +9 -0
  25. package/dist/core/case-results.js.map +1 -0
  26. package/dist/core/change-files.d.ts +31 -0
  27. package/dist/core/change-files.js +67 -0
  28. package/dist/core/change-files.js.map +1 -0
  29. package/dist/core/change-render.d.ts +18 -0
  30. package/dist/core/change-render.js +48 -0
  31. package/dist/core/change-render.js.map +1 -0
  32. package/dist/core/change-view.d.ts +33 -0
  33. package/dist/core/change-view.js +73 -0
  34. package/dist/core/change-view.js.map +1 -0
  35. package/dist/core/change-words.d.ts +39 -0
  36. package/dist/core/change-words.js +214 -0
  37. package/dist/core/change-words.js.map +1 -0
  38. package/dist/core/checklist-text.d.ts +21 -0
  39. package/dist/core/checklist-text.js +59 -0
  40. package/dist/core/checklist-text.js.map +1 -0
  41. package/dist/core/edit.js +5 -2
  42. package/dist/core/edit.js.map +1 -1
  43. package/dist/core/fabrication.d.ts +9 -2
  44. package/dist/core/fabrication.js +29 -10
  45. package/dist/core/fabrication.js.map +1 -1
  46. package/dist/core/library.d.ts +46 -0
  47. package/dist/core/library.js +54 -16
  48. package/dist/core/library.js.map +1 -1
  49. package/dist/core/modules.d.ts +1 -0
  50. package/dist/core/modules.js +17 -0
  51. package/dist/core/modules.js.map +1 -1
  52. package/dist/core/order-report.d.ts +10 -0
  53. package/dist/core/order-report.js +93 -0
  54. package/dist/core/order-report.js.map +1 -0
  55. package/dist/core/pin-header.d.ts +5 -0
  56. package/dist/core/pin-header.js +77 -0
  57. package/dist/core/pin-header.js.map +1 -0
  58. package/dist/core/pin-map.d.ts +46 -0
  59. package/dist/core/pin-map.js +101 -0
  60. package/dist/core/pin-map.js.map +1 -0
  61. package/dist/core/render.d.ts +24 -4
  62. package/dist/core/render.js +16 -6
  63. package/dist/core/render.js.map +1 -1
  64. package/dist/core/sheet-card.d.ts +4 -0
  65. package/dist/core/sheet-card.js +46 -1
  66. package/dist/core/sheet-card.js.map +1 -1
  67. package/dist/core/sheet-files.js +10 -3
  68. package/dist/core/sheet-files.js.map +1 -1
  69. package/dist/core/simulate.d.ts +19 -0
  70. package/dist/core/simulate.js +72 -0
  71. package/dist/core/simulate.js.map +1 -0
  72. package/dist/core/step-export.d.ts +17 -0
  73. package/dist/core/step-export.js +35 -0
  74. package/dist/core/step-export.js.map +1 -0
  75. package/dist/core/supplier-prop.d.ts +6 -0
  76. package/dist/core/supplier-prop.js +21 -0
  77. package/dist/core/supplier-prop.js.map +1 -0
  78. package/dist/core/workspace.d.ts +2 -1
  79. package/dist/core/workspace.js +2 -1
  80. package/dist/core/workspace.js.map +1 -1
  81. package/dist/engine/board.js +3 -1
  82. package/dist/engine/board.js.map +1 -1
  83. package/dist/engine/checks/fast-lines.d.ts +60 -0
  84. package/dist/engine/checks/fast-lines.js +209 -0
  85. package/dist/engine/checks/fast-lines.js.map +1 -0
  86. package/dist/engine/checks/index.js +2 -0
  87. package/dist/engine/checks/index.js.map +1 -1
  88. package/dist/engine/design-diff.d.ts +120 -0
  89. package/dist/engine/design-diff.js +249 -0
  90. package/dist/engine/design-diff.js.map +1 -0
  91. package/dist/engine/design.d.ts +3 -0
  92. package/dist/engine/design.js +7 -2
  93. package/dist/engine/design.js.map +1 -1
  94. package/dist/engine/fab/export.d.ts +17 -1
  95. package/dist/engine/fab/export.js +26 -4
  96. package/dist/engine/fab/export.js.map +1 -1
  97. package/dist/engine/fab/names.d.ts +2 -2
  98. package/dist/engine/fab/names.js +4 -2
  99. package/dist/engine/fab/names.js.map +1 -1
  100. package/dist/engine/fab/picture/board-picture.d.ts +52 -0
  101. package/dist/engine/fab/picture/board-picture.js +102 -0
  102. package/dist/engine/fab/picture/board-picture.js.map +1 -0
  103. package/dist/engine/fab/picture/board-view.d.ts +20 -0
  104. package/dist/engine/fab/picture/board-view.js +50 -0
  105. package/dist/engine/fab/picture/board-view.js.map +1 -0
  106. package/dist/engine/fab/picture/compose.d.ts +50 -0
  107. package/dist/engine/fab/picture/compose.js +208 -0
  108. package/dist/engine/fab/picture/compose.js.map +1 -0
  109. package/dist/engine/fab/picture/layer-images.d.ts +9 -0
  110. package/dist/engine/fab/picture/layer-images.js +67 -0
  111. package/dist/engine/fab/picture/layer-images.js.map +1 -0
  112. package/dist/engine/fab/picture/looks.d.ts +152 -0
  113. package/dist/engine/fab/picture/looks.js +53 -0
  114. package/dist/engine/fab/picture/looks.js.map +1 -0
  115. package/dist/engine/fab/picture/png.d.ts +31 -0
  116. package/dist/engine/fab/picture/png.js +47 -0
  117. package/dist/engine/fab/picture/png.js.map +1 -0
  118. package/dist/engine/fab/picture/raster.d.ts +46 -0
  119. package/dist/engine/fab/picture/raster.js +170 -0
  120. package/dist/engine/fab/picture/raster.js.map +1 -0
  121. package/dist/engine/fab/zip.d.ts +2 -1
  122. package/dist/engine/fab/zip.js +1 -1
  123. package/dist/engine/fab/zip.js.map +1 -1
  124. package/dist/engine/impedance.d.ts +72 -0
  125. package/dist/engine/impedance.js +133 -0
  126. package/dist/engine/impedance.js.map +1 -0
  127. package/dist/engine/line-length.d.ts +15 -0
  128. package/dist/engine/line-length.js +116 -0
  129. package/dist/engine/line-length.js.map +1 -0
  130. package/dist/engine/model.d.ts +2 -0
  131. package/dist/engine/model.js.map +1 -1
  132. package/dist/engine/pcb-place/roles.d.ts +3 -1
  133. package/dist/engine/pcb-place/roles.js +5 -0
  134. package/dist/engine/pcb-place/roles.js.map +1 -1
  135. package/dist/engine/rules/impedance-widths.d.ts +20 -0
  136. package/dist/engine/rules/impedance-widths.js +57 -0
  137. package/dist/engine/rules/impedance-widths.js.map +1 -0
  138. package/dist/engine/rules/load.js +11 -2
  139. package/dist/engine/rules/load.js.map +1 -1
  140. package/dist/engine/rules/pairs.d.ts +27 -0
  141. package/dist/engine/rules/pairs.js +86 -0
  142. package/dist/engine/rules/pairs.js.map +1 -0
  143. package/dist/engine/rules/profiles.js +16 -0
  144. package/dist/engine/rules/profiles.js.map +1 -1
  145. package/dist/engine/rules/schema.d.ts +44 -0
  146. package/dist/engine/rules/schema.js +16 -1
  147. package/dist/engine/rules/schema.js.map +1 -1
  148. package/dist/engine/sim/answer.d.ts +13 -0
  149. package/dist/engine/sim/answer.js +101 -0
  150. package/dist/engine/sim/answer.js.map +1 -0
  151. package/dist/engine/sim/cases.d.ts +29 -0
  152. package/dist/engine/sim/cases.js +63 -0
  153. package/dist/engine/sim/cases.js.map +1 -0
  154. package/dist/engine/sim/devices.d.ts +109 -0
  155. package/dist/engine/sim/devices.js +137 -0
  156. package/dist/engine/sim/devices.js.map +1 -0
  157. package/dist/engine/sim/elements.d.ts +49 -0
  158. package/dist/engine/sim/elements.js +2 -0
  159. package/dist/engine/sim/elements.js.map +1 -0
  160. package/dist/engine/sim/from-circuit.d.ts +52 -0
  161. package/dist/engine/sim/from-circuit.js +354 -0
  162. package/dist/engine/sim/from-circuit.js.map +1 -0
  163. package/dist/engine/sim/limits.d.ts +12 -0
  164. package/dist/engine/sim/limits.js +79 -0
  165. package/dist/engine/sim/limits.js.map +1 -0
  166. package/dist/engine/sim/linear.d.ts +2 -0
  167. package/dist/engine/sim/linear.js +49 -0
  168. package/dist/engine/sim/linear.js.map +1 -0
  169. package/dist/engine/sim/model-schema.d.ts +246 -0
  170. package/dist/engine/sim/model-schema.js +115 -0
  171. package/dist/engine/sim/model-schema.js.map +1 -0
  172. package/dist/engine/sim/part-models.d.ts +47 -0
  173. package/dist/engine/sim/part-models.js +102 -0
  174. package/dist/engine/sim/part-models.js.map +1 -0
  175. package/dist/engine/sim/run.d.ts +14 -0
  176. package/dist/engine/sim/run.js +13 -0
  177. package/dist/engine/sim/run.js.map +1 -0
  178. package/dist/engine/sim/solve.d.ts +42 -0
  179. package/dist/engine/sim/solve.js +294 -0
  180. package/dist/engine/sim/solve.js.map +1 -0
  181. package/dist/engine/sim/spice.d.ts +5 -0
  182. package/dist/engine/sim/spice.js +66 -0
  183. package/dist/engine/sim/spice.js.map +1 -0
  184. package/dist/engine/sim/values.d.ts +4 -0
  185. package/dist/engine/sim/values.js +40 -0
  186. package/dist/engine/sim/values.js.map +1 -0
  187. package/dist/engine/solid/heights.d.ts +29 -0
  188. package/dist/engine/solid/heights.js +87 -0
  189. package/dist/engine/solid/heights.js.map +1 -0
  190. package/dist/engine/solid/limits.d.ts +7 -0
  191. package/dist/engine/solid/limits.js +20 -0
  192. package/dist/engine/solid/limits.js.map +1 -0
  193. package/dist/engine/solid/model.d.ts +54 -0
  194. package/dist/engine/solid/model.js +147 -0
  195. package/dist/engine/solid/model.js.map +1 -0
  196. package/dist/engine/solid/step.d.ts +5 -0
  197. package/dist/engine/solid/step.js +164 -0
  198. package/dist/engine/solid/step.js.map +1 -0
  199. package/dist/engine/solid/thickness.d.ts +11 -0
  200. package/dist/engine/solid/thickness.js +10 -0
  201. package/dist/engine/solid/thickness.js.map +1 -0
  202. package/dist/library/kicad/board.d.ts +26 -0
  203. package/dist/library/kicad/board.js +96 -0
  204. package/dist/library/kicad/board.js.map +1 -0
  205. package/dist/library/kicad/copper.d.ts +44 -0
  206. package/dist/library/kicad/copper.js +106 -0
  207. package/dist/library/kicad/copper.js.map +1 -0
  208. package/dist/library/kicad/footprints.d.ts +62 -0
  209. package/dist/library/kicad/footprints.js +184 -0
  210. package/dist/library/kicad/footprints.js.map +1 -0
  211. package/dist/library/kicad/geometry.d.ts +36 -0
  212. package/dist/library/kicad/geometry.js +84 -0
  213. package/dist/library/kicad/geometry.js.map +1 -0
  214. package/dist/library/kicad/import.d.ts +58 -0
  215. package/dist/library/kicad/import.js +240 -0
  216. package/dist/library/kicad/import.js.map +1 -0
  217. package/dist/library/kicad/plan.d.ts +40 -0
  218. package/dist/library/kicad/plan.js +139 -0
  219. package/dist/library/kicad/plan.js.map +1 -0
  220. package/dist/library/kicad/read.d.ts +30 -0
  221. package/dist/library/kicad/read.js +105 -0
  222. package/dist/library/kicad/read.js.map +1 -0
  223. package/dist/library/kicad/sexpr.d.ts +36 -0
  224. package/dist/library/kicad/sexpr.js +153 -0
  225. package/dist/library/kicad/sexpr.js.map +1 -0
  226. package/dist/library/kicad/tally.d.ts +32 -0
  227. package/dist/library/kicad/tally.js +55 -0
  228. package/dist/library/kicad/tally.js.map +1 -0
  229. package/dist/library/kicad/write.d.ts +37 -0
  230. package/dist/library/kicad/write.js +146 -0
  231. package/dist/library/kicad/write.js.map +1 -0
  232. package/dist/library/new-part.d.ts +2 -0
  233. package/dist/library/new-part.js +1 -0
  234. package/dist/library/new-part.js.map +1 -1
  235. package/dist/mcp/board-import-tool.d.ts +1 -1
  236. package/dist/mcp/board-import-tool.js +14 -4
  237. package/dist/mcp/board-import-tool.js.map +1 -1
  238. package/dist/mcp/copper-summary.d.ts +2 -0
  239. package/dist/mcp/copper-summary.js +4 -2
  240. package/dist/mcp/copper-summary.js.map +1 -1
  241. package/dist/mcp/create-part.d.ts +23 -0
  242. package/dist/mcp/create-part.js +1 -0
  243. package/dist/mcp/create-part.js.map +1 -1
  244. package/dist/mcp/fast-summary.d.ts +3 -0
  245. package/dist/mcp/fast-summary.js +46 -0
  246. package/dist/mcp/fast-summary.js.map +1 -0
  247. package/dist/mcp/render-tool.d.ts +33 -2
  248. package/dist/mcp/render-tool.js +21 -5
  249. package/dist/mcp/render-tool.js.map +1 -1
  250. package/dist/mcp/server.js +18 -8
  251. package/dist/mcp/server.js.map +1 -1
  252. package/dist/mcp/sheet-card-tools.d.ts +3 -1
  253. package/dist/mcp/sheet-card-tools.js +3 -1
  254. package/dist/mcp/sheet-card-tools.js.map +1 -1
  255. package/dist/mcp/simulate-tool.d.ts +10 -0
  256. package/dist/mcp/simulate-tool.js +12 -0
  257. package/dist/mcp/simulate-tool.js.map +1 -0
  258. package/dist/render/render.js +8113 -108
  259. package/dist/studio/change-route.d.ts +18 -0
  260. package/dist/studio/change-route.js +24 -0
  261. package/dist/studio/change-route.js.map +1 -0
  262. package/dist/studio/http-error.d.ts +5 -0
  263. package/dist/studio/http-error.js +9 -0
  264. package/dist/studio/http-error.js.map +1 -0
  265. package/dist/studio/live.d.ts +2 -0
  266. package/dist/studio/live.js.map +1 -1
  267. package/dist/studio/server.js +43 -15
  268. package/dist/studio/server.js.map +1 -1
  269. package/dist/studio/verify-routes.d.ts +42 -0
  270. package/dist/studio/verify-routes.js +110 -0
  271. package/dist/studio/verify-routes.js.map +1 -0
  272. package/dist/version.d.ts +1 -1
  273. package/dist/version.js +1 -1
  274. package/library/modules/CanNode/CanNode.sheet.tsx +1 -1
  275. package/library/modules/CanNode/parts/MCP2515-I-SO/MCP2515_I_SO.tsx +1 -0
  276. package/library/modules/CanNode/parts/MCP2515-I-SO/part.yaml +2 -0
  277. package/library/modules/CanNode/parts/MCP2515-I-SO/verification.md +2 -1
  278. package/library/modules/CanNode/parts/TJA1051T-3/TJA1051T_3.tsx +1 -0
  279. package/library/modules/CanNode/parts/TJA1051T-3/part.yaml +2 -0
  280. package/library/modules/CanNode/parts/TJA1051T-3/verification.md +2 -1
  281. package/library/modules/DigitalInput24V/DigitalInput24V.sheet.tsx +7 -7
  282. package/library/modules/RelayDriver/RelayDriver.sheet.tsx +3 -3
  283. package/library/modules/RelayDriver/parts/AO3400A/part.yaml +34 -0
  284. package/library/modules/RelayDriver/parts/AO3400A/verification.md +11 -1
  285. package/library/modules/RelayDriver/parts/SRD-12VDC-SL-C/SRD_12VDC_SL_C.tsx +1 -0
  286. package/library/modules/RelayDriver/parts/SRD-12VDC-SL-C/part.yaml +14 -0
  287. package/library/modules/RelayDriver/parts/SRD-12VDC-SL-C/verification.md +4 -1
  288. package/package.json +1 -1
  289. package/skills/copperflow/references/copper.md +8 -0
  290. package/skills/copperflow/references/design-rules.md +48 -0
  291. package/skills/copperflow/references/modules.md +26 -0
  292. package/skills/copperflow/references/writing-circuits.md +3 -0
  293. package/dist/app/assets/NewPartDialog-C4sKWnGI.js +0 -160
  294. package/dist/app/assets/index-BgzJedaB.css +0 -1
  295. package/dist/app/assets/index-C_U9me2P.js +0 -19
@@ -1,160 +0,0 @@
1
- import{a as e,i as t,n,r,t as i}from"./index-C_U9me2P.js";var a=e();function o(e,t,n){let r=e.span.max-e.span.min,i=e.terminal.max-e.terminal.min,a=e.width.max-e.width.min,o=e.span.min-2*e.terminal.max,s=e.span.max-2*e.terminal.min,c=Math.sqrt(r**2+2*i**2),l=s-(s-o-c)/2,u=e=>Math.sqrt(e**2+n.fabrication**2+n.placement**2);return{Z:e.span.min+2*t.toe+u(r),G:l-2*t.heel-u(c),X:e.width.min+2*t.side+u(a)}}function s(e,t,n){let r=o(e,t,n),i=e.span.max-e.span.min,a=e.terminal.max-e.terminal.min,s=e.span.min-2*e.terminal.max,c=e.span.max-2*e.terminal.min,l=c-(c-s-Math.sqrt(i**2+2*a**2))/2,u=Math.sqrt(i**2+n.fabrication**2+n.placement**2);return{...r,G:l-2*t.heel-u}}var c=Object.freeze({fabrication:.1,placement:.05});function l(e,t,n){return Object.freeze({goals:Object.freeze(e),roundOff:t,courtyardExcess:n})}var u=l({toe:.35,heel:0,side:0},.05,.25),d=l({toe:.2,heel:0,side:0},.02,.15),f=l({toe:.35,heel:.35,side:.03},.05,.25),p=l({toe:.35,heel:.35,side:-.02},.05,.25);function m(e){return e>.625000001?f:p}var h=l({toe:.3,heel:0,side:-.04},.05,.25),g=l({toe:.15,heel:.5,side:-.05},.05,.25),_=.15;function v(e){return(e.min+e.max)/2<1.599999999?d:u}function y(e,t,n=f){let r=e.span.min-2*e.terminal.max,i=e.terminal.max-e.terminal.min;return r<=t+1e-9&&i<=.500000001?{...n.goals,heel:_}:{...n.goals}}var ee=1e-6;function b(e,t,n){let r=e/t;return n===`up`?Math.ceil(r-ee):Math.round(r+ee)}function x(e,t){return b(e,t,`up`)/Math.round(1/t)}var te=.25,ne=.25;function re(e,t){let n=Math.round(1/t),r=b(e.Z,t,`nearest`),i=b(e.G,t,`nearest`),a=b(e.X,t,`nearest`);if(i<=0||r<=i)throw Error(`land pattern has no gap between its pads (Z ${e.Z}, G ${e.G})`);return{length:(r-i)/(2*n),width:a/n,centre:(r+i)/(4*n)}}function ie(e,t){let n=re(e,t);return[ae(`1`,-n.centre,0,n.length,n.width),ae(`2`,n.centre,0,n.length,n.width)]}function ae(e,t,n,r,i){return{number:e,shape:`roundrect`,x:t,y:n,width:r,height:i,rotation:0,layers:`top`,cornerRadius:Math.min(ne,te*Math.min(r,i))}}var S=.15,oe=1e6;function C(e){return Math.round(e*oe)/oe+0}function se(e,t){return Array.from({length:e},(n,r)=>C((r-(e-1)/2)*t))}function ce(e){return Math.abs(e.rotation%180)===90?{x:e.height/2,y:e.width/2}:{x:e.width/2,y:e.height/2}}function w(e){return e.reduce((e,t)=>{let n=ce(t);return{x:Math.max(e.x,Math.abs(t.x)+n.x),y:Math.max(e.y,Math.abs(t.y)+n.y)}},{x:0,y:0})}function le(e,t){let n=e.map(e=>({pad:e,half:ce(e)}));return n.every((e,r)=>n.slice(r+1).every(n=>{let r=Math.abs(e.pad.x-n.pad.x)-e.half.x-n.half.x,i=Math.abs(e.pad.y-n.pad.y)-e.half.y-n.half.y;return Math.max(r,i)>=t-1e-9}))}function ue(e,t=`x`){return Math.min(...e.map(e=>Math.abs(e[t])-ce(e)[t]))}function de(e){return[{x:-e.x,y:-e.y},{x:e.x,y:-e.y},{x:e.x,y:e.y},{x:-e.x,y:e.y}]}function T(e,t,n){let r=w(e);return de({x:x(Math.max(r.x,t.x)+n.courtyardExcess,n.roundOff),y:x(Math.max(r.y,t.y)+n.courtyardExcess,n.roundOff)})}function fe(e){let t={x:C(e.x),y:C(e.y)};return[...de(t),{x:-t.x,y:-t.y}]}function pe(e){return[fe(e)]}function me(e,t){return C(Math.max(t.y,w(e).y+S))}function he(e,t){let n=me(e,t),r=C(Math.min(t.x,ue(e)));return[[{x:-r,y:n},{x:r,y:n}],[{x:-r,y:-n},{x:r,y:-n}]]}function ge(e,t){let n=ue(e)-S,r=C(n>0?n:w(e).x+S),i=me(e,t);return[{x:r,y:-i},{x:r,y:i}]}function _e(e,t){let[n,r]=he(e,t),[,i]=n;return[[{x:-C(w(e).x),y:i.y},i],r]}function ve(e,t){let n=w(e),r=C(Math.max(t.x,n.x+S)),i=C(Math.min(t.y,ue(e,`y`)));return[[{x:-r,y:-C(n.y)},{x:-r,y:i}],[{x:r,y:-i},{x:r,y:i}]]}function ye(e){let t=ce(e);return Math.abs(e.x)>Math.abs(e.y)?Math.abs(e.y)+t.y:Math.abs(e.x)+t.x}function be(e,t){let n=C(Math.max(...e.map(ye))+S),r=C(Math.max(t.x,n)),i=(e,t)=>[{x:C(e*r),y:C(t*n)},{x:C(e*r),y:C(t*r)},{x:C(e*n),y:C(t*r)}];return[[{x:-r,y:n},{x:-r,y:r}],[{x:-C(w(e).x),y:r},{x:-n,y:r}],i(1,1),i(1,-1),i(-1,-1)]}function xe(e,t,n,r,i=5){let a=Math.max(1,Math.ceil(Math.abs(r-n)/i));return Array.from({length:a+1},(i,o)=>{let s=(n+(r-n)*o/a)*Math.PI/180;return{x:C(e.x+t*Math.cos(s)),y:C(e.y+t*Math.sin(s))}})}function Se(e,t){let n=ce(t);if(t.shape===`circle`)return Math.hypot(e.x-t.x,e.y-t.y)-n.x;let r=Math.max(Math.abs(e.x-t.x)-n.x,0),i=Math.max(Math.abs(e.y-t.y)-n.y,0);return Math.hypot(r,i)}function Ce(e,t){let n=[],r=[];for(let i of e)t.every(e=>Se(i,e)>=.16999999999999998)?r.push(i):(r.length>1&&n.push(r),r=[]);return r.length>1&&n.push(r),n}var we=1;function Te(e,t){return[{x:C(e.x-we/2),y:C(t)},{x:C(e.x+we/2),y:C(t)}]}var E=e=>({refused:e}),Ee=e=>typeof e==`object`&&!!e&&`refused`in e,De=.1,D=e=>String(C(e)),Oe=e=>e.x===e.y?D(e.x):`${D(e.x)}x${D(e.y)}`;function ke(e){return Object.keys(e.params).every(e=>e===`p`)&&e.pairs===void 0}function Ae(e,t){let n=[...Object.keys(e.params),...Object.keys(e.pairs??{})].filter(e=>e!==`p`&&e!==`ep`);if(n.length>0)return E(`a ${t} takes only _p and _ep, not _${n[0]}`);let r=e.params.ep,i=e.pairs?.ep;if(r===!0)return E(`_ep needs the exposed pad's size, such as _ep3.1 or _ep1.6x2.4`);if(typeof r==`number`)return r>0?{x:r,y:r}:E(`the exposed pad needs a size above 0`);if(i)return i[0]>0&&i[1]>0?{x:i[0],y:i[1]}:E(`the exposed pad needs a size above 0`)}function je(e,t){return le(e,.1)?void 0:le(t?e.slice(0,-1):e,.1)?E(`the exposed pad would touch the pins`):E(`the pins would come closer than ${De} mm to each other`)}var Me=`ABCDEFGHJKLMNPRTUVWY`;function Ne(e){let t=``;for(let n=e+1;n>0;n=Math.floor((n-1)/20))t=Me[(n-1)%20]+t;return t}var Pe=new Map([[1.27,.75],[1,.5],[.8,.45],[.65,.35],[.5,.3],[.4,.25]]),Fe=.25,Ie=.2,Le=.05,Re={courtyardExcess:1,roundOff:.05},ze=.3,Be=1,Ve=4096,He=1e-9;function Ue(e){for(let[t,n]of Pe)if(!(Math.abs(t-e)>He))return{ball:n,land:C(Math.round(n*(1-(n>=.5499999990000001?Fe:Ie))/Le+1e-6)*Le)}}function We(e,t){if(t){let[n,r]=t;return Number.isInteger(n)&&Number.isInteger(r)&&n*r===e?{rows:n,columns:r}:E(`_rows${n}x${r} is not a full grid of ${e} balls`)}let n=Math.round(Math.sqrt(e));return n*n===e?{rows:n,columns:n}:E(`${e} balls are no square grid; give _rows<R>x<C>`)}var Ge=[...Pe.keys()].join(`, `);function Ke(e,t,n,r){let i=se(t,n);return[...se(e,n)].reverse().flatMap((e,t)=>i.map((n,i)=>({number:`${Ne(t)}${i+1}`,shape:`circle`,x:n,y:e,width:r,height:r,rotation:0,layers:`top`})))}function qe(e,t){let n=w(e),r={x:C(Math.max(t.x,n.x+S)),y:C(Math.max(t.y,n.y+S))},i=C(-r.x-ze),a=C(r.y+ze);return[fe(r),[{x:i,y:C(a-Be)},{x:i,y:a},{x:C(i+Be),y:a}]]}function Je(e){if(e.kind!==`bga`||e.variant!==void 0||e.cross!==void 0||e.suffix!==void 0)return;let t=e.size,n=e.params.p;if(!t)return E(`a BGA needs its body, such as bga256_17x17_p1`);if(typeof n!=`number`)return E(`a BGA needs its pitch, such as _p1`);let r=[...Object.keys(e.params),...Object.keys(e.pairs??{})].find(e=>e!==`p`&&e!==`rows`);if(r!==void 0)return E(`a BGA takes only _p and _rows, not _${r}`);let i=Number(e.code);if(!Number.isInteger(i)||i<1||i>Ve)return E(`a BGA has 1 to ${Ve} balls`);let a=Ue(n);if(!a)return E(`BGA pitch must be one of ${Ge} mm`);let o=We(i,e.pairs?.rows);if(Ee(o))return o;let[s,c]=t,l=(e,t)=>(e-1)*n+a.land<=t+He;if(!l(o.columns,s)||!l(o.rows,c))return E(`a ${o.rows}×${o.columns} grid at ${D(n)} mm does not fit the body`);let u=Ke(o.rows,o.columns,n,a.land),d={x:s/2,y:c/2},f=o.rows===o.columns;return{name:`bga${i}_${D(s)}x${D(c)}_p${D(n)}${f?``:`_rows${o.rows}x${o.columns}`}`,pads:u,courtyard:T(u,d,Re),silkscreen:qe(u,d),fabrication:[fe(d)],origin:`IPC-7351B nominal, BGA-${i} ${D(s)}×${D(c)} mm, ${D(n)} mm pitch, ${o.rows}×${o.columns} grid, ${D(a.ball)} mm balls on ${D(a.land)} mm lands`}}function O(e,t){let n=e=>Math.round(e*1e6)/1e6;return{min:n(e-t),max:n(e+t)}}var Ye={"0201":{length:O(.6,.03),width:O(.3,.03),terminal:O(.15,.05)},"0402":{length:O(1,.05),width:O(.5,.05),terminal:O(.3,.1)},"0603":{length:O(1.6,.15),width:O(.8,.15),terminal:O(.35,.15)},"0805":{length:O(2,.2),width:O(1.25,.2),terminal:O(.5,.25)},1206:{length:O(3.2,.2),width:O(1.6,.2),terminal:O(.5,.25)},1210:{length:O(3.2,.2),width:O(2.5,.2),terminal:O(.5,.25)},1812:{length:O(4.5,.3),width:O(3.2,.3),terminal:O(.6,.35)}},Xe={2010:{length:O(5,.15),width:O(2.5,.15),terminal:O(.6,.2)},2512:{length:O(6.3,.2),width:O(3.15,.15),terminal:O(.6,.2)}},Ze={...Ye,...Xe};function Qe(e){if(!Object.hasOwn(Ze,e))return;let t=Ze[e],n={span:t.length,terminal:t.terminal,width:t.width},r=v(t.length),i=ie(o(n,r.goals,c),r.roundOff),a={x:t.length.max/2,y:t.width.max/2};return{name:e,pads:i,courtyard:T(i,a,r),silkscreen:he(i,a),fabrication:pe(a),origin:`IPC-7351B nominal, EIA ${e}`}}var k=(e,t)=>({min:e,max:t});function $e(e){return{span:e.span,terminal:e.terminal,width:e.leadWidth}}function et(e){let t=m(e.pitch),n=y($e(e),e.bodyAcross.max,t);return{row:re(s($e(e),n,c),t.roundOff),table:t}}function tt(e){return{row:re(o($e(e),h.goals,c),h.roundOff),table:h}}var nt=1e-6,rt=e=>(e.min+e.max)/2;function it(e,t,n=[]){return Object.entries(e).every(([e,r])=>e===`p`?r!==!0&&Math.abs(r-t.pitch)<nt:e===`w`?r!==!0&&Math.abs(r-rt(t.span))<nt:n.includes(e)&&r===!0)}var at=.2,ot=.05,st=.5,ct=.05,lt={courtyardExcess:.25,roundOff:ct};function ut(e,t){return t?Math.hypot(e.max,t.max):e.max}function dt(e){let t=x(e+at,ct);return{drill:t,pad:x(t+2*ot+st,ct)}}function ft(e,t,n,r,i=!1){return{number:e,shape:i?`rect`:`circle`,x:t,y:n,width:r.pad,height:r.pad,rotation:0,layers:`through`,drill:{width:r.drill,height:r.drill}}}var pt=4.88,mt=k(.4,.46),ht=11.05,gt=4.65,_t=.2,vt=new Map([[void 0,`HC-49/U`],[`s`,`HC-49/S`]]);function yt(){let e=gt/2,t=xe({x:ht/2-e,y:0},e,-90,90,10),n=xe({x:-3.2,y:0},e,90,270,10);return[...t,...n,t[0]]}function bt(e){let t=e.kind===`hc`&&e.code===`49`?vt.get(e.suffix):void 0,n=e.cross===void 0&&e.size===void 0&&e.pairs===void 0&&e.variant===void 0;if(!t||!n||Object.keys(e.params).length>0)return;let r=dt(ut(mt)),i=[ft(`1`,-4.88/2,0,r,!0),ft(`2`,pt/2,0,r)],a=yt(),o=C(-(w(i).y+S+_t));return{name:`hc49${e.suffix??``}`,pads:i,courtyard:T(i,{x:ht/2,y:gt/2},lt),silkscreen:[a,Te(i[0],o)],fabrication:[a],origin:`Through-hole, ${t} crystal: ${r.drill} mm holes, ${r.pad} mm lands (IPC-2222 level B)`}}var xt=String.raw`\d+(?:\.\d+)?`,St=new RegExp(String.raw`^([a-z]*)(${xt})?(?:x(${xt}))?([a-z]*)$`),Ct=/^\d+$/,wt=/^([a-z]+)(.*)$/,Tt=new RegExp(String.raw`^(${xt})(?:mm)?x(${xt})(?:mm)?$`);function Et(e){let[t=``,...n]=e.trim().toLowerCase().split(`_`),r=St.exec(t);if(!r||t===``)return;let[,i=``,a=``,o,s=``]=r,c=Ct.test(n[0]??``)?n[0]:void 0,l=c===void 0?n:n.slice(1),u=l.filter(e=>Tt.test(e));if(u.length>1)return;let d=kt(l.filter(e=>!Tt.test(e)));if(!d)return;let f=u[0]===void 0?void 0:Ot(u[0]);return{kind:i,code:a,...o===void 0?{}:{cross:o},...s===``?{}:{suffix:s},...c===void 0?{}:{variant:c},...f===void 0?{}:{size:f},params:d.params,...Object.keys(d.pairs).length===0?{}:{pairs:d.pairs}}}function Dt(e){return e.cross===void 0&&e.suffix===void 0&&e.size===void 0&&e.pairs===void 0}function Ot(e){let t=Tt.exec(e);return t?[Number(t[1]),Number(t[2])]:void 0}function kt(e){let n={},r={};for(let i of e){let e=wt.exec(i);if(!e)return;let a=e[1]??``,o=e[2]??``;if(Object.hasOwn(n,a)||Object.hasOwn(r,a))return;let s=Ot(o);if(s){r[a]=s;continue}let c=o===``||t(o);if(c===void 0)return;n[a]=c}return{params:n,pairs:r}}var At=(e,t)=>Array.from({length:(t-e)/2+1},(t,n)=>e+2*n),jt=[{kind:`soic`,suffix:``,label:e=>`SOIC-${e}`,pins:At(8,16),lead:{pitch:1.27,span:k(5.8,6.2),terminal:k(.41,1.27),leadWidth:k(.33,.51),bodyAcross:k(3.8,4)},bodyLength:new Map([[8,k(4.8,5)],[14,k(8.55,8.75)],[16,k(9.8,10)]]),overhang:.53,bodyTolerance:.1},{kind:`soic`,suffix:`w`,label:e=>`SOIC-${e} wide`,pins:[16,18,20,24,28],lead:{pitch:1.27,span:k(10,10.65),terminal:k(.4,1.27),leadWidth:k(.31,.51),bodyAcross:k(7.4,7.6)},bodyLength:new Map([[16,k(10.1,10.5)],[18,k(11.35,11.75)],[20,k(12.6,13)],[24,k(15.2,15.6)],[28,k(17.7,18.1)]]),overhang:.6,bodyTolerance:.2},{kind:`sop`,suffix:``,label:e=>`SOP-${e}`,pins:At(8,16),lead:{pitch:1.27,span:k(7.7,8.1),terminal:k(.51,.8),leadWidth:k(.36,.48),bodyAcross:k(5.18,5.38)},bodyLength:new Map([[8,k(5.18,5.33)]]),overhang:.72,bodyTolerance:.08},{kind:`ssop`,suffix:``,label:e=>`SSOP-${e}`,pins:[14,16,20,24,28],lead:{pitch:.65,span:k(7.4,8.2),terminal:k(.55,.95),leadWidth:k(.22,.38),bodyAcross:k(5,5.6)},bodyLength:new Map([[14,k(5.9,6.5)],[16,k(5.9,6.5)],[20,k(6.9,7.5)],[24,k(7.9,8.5)],[28,k(9.9,10.5)]]),overhang:.7,bodyTolerance:.3},{kind:`tssop`,suffix:``,label:e=>`TSSOP-${e}`,pins:At(8,28),lead:{pitch:.65,span:k(6.2,6.6),terminal:k(.45,.75),leadWidth:k(.19,.3),bodyAcross:k(4.3,4.5)},bodyLength:new Map([[8,k(2.9,3.1)],[14,k(4.9,5.1)],[16,k(4.9,5.1)],[20,k(6.4,6.6)],[24,k(7.7,7.9)],[28,k(9.6,9.8)]]),overhang:.6,bodyTolerance:.1}],Mt=jt.map(e=>({form:`${e.kind}<N>${e.suffix}`,pins:e.pins}));function Nt(e,t){let n=e.bodyLength.get(t),r=(t/2-1)*e.lead.pitch+2*e.overhang,i=n??k(r-e.bodyTolerance,r+e.bodyTolerance);return{...e.lead,label:e.label(t),bodyAlong:i}}function Pt(e,t,n){let r=se(e/2,t),i=[...r].reverse().map((e,t)=>ae(String(t+1),-n.centre,e,n.length,n.width)),a=r.map((t,r)=>ae(String(e/2+r+1),n.centre,t,n.length,n.width));return[...i,...a]}function Ft(e,t){if(e.cross!==void 0||e.size!==void 0||e.pairs!==void 0||e.variant!==void 0)return;let n=Number(e.code);return String(n)===e.code&&t.pins.includes(n)?n:void 0}function It(e){let t=jt.find(t=>t.kind===e.kind&&t.suffix===(e.suffix??``)),n=t&&Ft(e,t);if(!t||n===void 0)return;let r=Nt(t,n);if(!it(e.params,r))return;let{row:i,table:a}=et(r),o=Pt(n,r.pitch,i),s={x:r.bodyAcross.max/2,y:r.bodyAlong.max/2},c=(n/2-1)/2*r.pitch+r.leadWidth.max/2,l={x:r.span.max/2,y:Math.max(s.y,c)};return{name:`${e.kind}${e.code}${t.suffix}`,pads:o,courtyard:T(o,l,a),silkscreen:_e(o,s),fabrication:pe(s),origin:`IPC-7351B nominal, ${r.label}`}}var Lt=.1,Rt=k(.3,.5),zt=new Map([[.4,k(.15,.25)],[.5,k(.18,.3)],[.65,k(.25,.35)]]),Bt=k(.45,.75),Vt=new Map([[.4,k(.13,.23)],[.5,k(.17,.27)],[.65,k(.22,.38)],[.8,k(.3,.4)]]),Ht=2,Ut=.15,Wt=.25,Gt=1024,Kt=1,qt=60,Jt=1e-9,Yt=(e,t)=>k(Xt(e-t),Xt(e+t)),Xt=e=>Math.round(e*1e6)/1e6;function Zt(e,t){for(let[n,r]of e)if(Math.abs(n-t)<Jt)return r}function Qt(e,t,n){let r=Number(e);return!Number.isInteger(r)||r<=0||r>Gt?E(`a ${n} has 1 to ${Gt} pins`):r%t===0?r:E(`a ${n} has a pin count divisible by ${t}`)}var $t=e=>{let t=[...e.keys()].map(String);return`${t.slice(0,-1).join(`, `)} or ${t[t.length-1]} mm`};function en(e,t){return t.every(e=>e>=Kt&&e<=qt)?void 0:E(`a ${e} body is ${Kt} to ${qt} mm`)}function tn(e,t,n,r){return(e-1)*t+n.max<=r+Jt?void 0:E(`${e} pins a side at ${t} mm do not fit a ${r} mm side`)}function nn(...e){for(let t of e){let e=t();if(e)return e}}function rn(e,t,n,r,i){let a=Qt(t,4,e);if(Ee(a))return a;let o=Zt(i,r);if(!o)return E(`${e} pitch must be ${$t(i)}`);let[s,c]=n;return nn(()=>Math.abs(s-c)>Jt?E(`${e} bodies must be square`):void 0,()=>en(e,n),()=>tn(a/4,r,o,s))??{pins:a,side:s,width:o}}function an(e,t,n){let r=rn(`QFN`,e,t,n,zt);if(Ee(r))return r;let{pins:i,side:a,width:o}=r,s=Yt(a,Lt);return{label:`QFN-${i} ${a}×${a} mm, ${n} mm pitch`,pitch:n,span:s,terminal:Rt,leadWidth:o,bodyAcross:s,bodyAlong:s}}function on(e,t,n){let r=Qt(e,2,`DFN`);if(Ee(r))return r;let i=Zt(zt,n);if(!i)return E(`DFN pitch must be ${$t(zt)}`);let[a,o]=t,s=nn(()=>en(`DFN`,t),()=>tn(r/2,n,i,o));if(s)return s;let c=Yt(a,Lt);return{label:`DFN-${r} ${a}×${o} mm, ${n} mm pitch`,pitch:n,span:c,terminal:Rt,leadWidth:i,bodyAcross:c,bodyAlong:Yt(o,Lt)}}function sn(e,t,n){let r=rn(`QFP`,e,t,n,Vt);if(Ee(r))return r;let{pins:i,side:a,width:o}=r,s=a<=10.000000001?Ut:Wt,c=Yt(a,Lt);return{label:`LQFP-${i} ${a}×${a} mm, ${n} mm pitch`,pitch:n,span:Yt(a+Ht,s),terminal:Bt,leadWidth:o,bodyAcross:c,bodyAlong:c}}function cn(e){if(e.kind!==`dfn`||e.variant!==void 0||e.cross!==void 0||e.suffix!==void 0)return;let t=e.size,n=e.params.p;if(!t)return E(`a DFN needs its body, such as dfn8_3x3_p0.65`);if(typeof n!=`number`)return E(`a DFN needs its pitch, such as _p0.65`);let r=on(e.code,t,n);if(Ee(r))return r;let i=Ae(e,`DFN`);if(Ee(i))return i;let a=Number(e.code),{row:o,table:s}=tt(r),c=Pt(a,n,o),l=i?[...c,ae(String(a+1),0,0,i.x,i.y)]:c,u=je(l,i!==void 0);if(u)return u;let d={x:r.bodyAcross.max/2,y:r.bodyAlong.max/2};return{name:`dfn${a}_${D(t[0])}x${D(t[1])}_p${D(n)}${i?`_ep${Oe(i)}`:``}`,pads:l,courtyard:T(l,d,s),silkscreen:_e(c,d),fabrication:pe(d),origin:`IPC-7351B nominal, ${r.label}${i?` with exposed pad`:``}`}}var ln=2.54,un=k(.36,.56),dn=k(.2,.36),fn=1.27,pn=7.62,mn=64,hn=.75;function gn(e,t){let n=dt(ut(un,dn)),r=se(e/2,ln),i=[...r].reverse().map((e,r)=>ft(String(r+1),C(-t/2),e,n,r===0)),a=r.map((r,i)=>ft(String(e/2+i+1),C(t/2),r,n));return[...i,...a]}function _n(e,t){let n=Math.min(...e.map(e=>Math.abs(e.x)-e.width/2)),r=C(Math.min(t.x,n-S)),i=C(Math.max(t.y,w(e).y+S)),a=xe({x:0,y:i},hn,0,-180,15);return[[{x:-.75,y:i},{x:-r,y:i},{x:-r,y:-i},{x:r,y:-i},{x:r,y:i},...a]]}function vn(e){if(e.kind!==`dip`||!Dt(e)||e.variant!==void 0)return;let t=Object.keys(e.params).find(e=>e!==`w`);if(t!==void 0)return E(`a DIP takes only _w, not _${t}`);let n=Number(e.code),r=e.params.w??7.62;if(!Number.isInteger(n)||n<4||n>mn||n%2!=0)return E(`a DIP has an even pin count from 4 to ${mn}`);if(r===!0||r<7.619999999)return E(`DIP rows are at least ${pn} mm apart`);let i=gn(n,r),a={x:(r-fn)/2,y:n/2*(ln/2)},o=i[0];return{name:Math.abs(r-7.62)<1e-9?`dip${n}`:`dip${n}_w${D(r)}`,pads:i,courtyard:T(i,a,lt),silkscreen:_n(i,a),fabrication:pe(a),origin:`Through-hole, DIP-${n} with rows ${D(r)} mm apart: ${D(o.drill?.width??0)} mm holes, ${D(o.width)} mm lands (IPC-2222 level B)`}}var yn=Symbol.for(`yaml.alias`),bn=Symbol.for(`yaml.document`),xn=Symbol.for(`yaml.map`),Sn=Symbol.for(`yaml.pair`),Cn=Symbol.for(`yaml.scalar`),wn=Symbol.for(`yaml.seq`),A=Symbol.for(`yaml.node.type`),Tn=e=>!!e&&typeof e==`object`&&e[A]===yn,En=e=>!!e&&typeof e==`object`&&e[A]===bn,Dn=e=>!!e&&typeof e==`object`&&e[A]===xn,j=e=>!!e&&typeof e==`object`&&e[A]===Sn,M=e=>!!e&&typeof e==`object`&&e[A]===Cn,On=e=>!!e&&typeof e==`object`&&e[A]===wn;function N(e){if(e&&typeof e==`object`)switch(e[A]){case xn:case wn:return!0}return!1}function P(e){if(e&&typeof e==`object`)switch(e[A]){case yn:case xn:case Cn:case wn:return!0}return!1}var kn=e=>(M(e)||N(e))&&!!e.anchor,An=Symbol(`break visit`),jn=Symbol(`skip children`),Mn=Symbol(`remove node`);function Nn(e,t){let n=Fn(t);En(e)?Pn(null,e.contents,n,Object.freeze([e]))===Mn&&(e.contents=null):Pn(null,e,n,Object.freeze([]))}Nn.BREAK=An,Nn.SKIP=jn,Nn.REMOVE=Mn;function Pn(e,t,n,r){let i=In(e,t,n,r);if(P(i)||j(i))return Ln(e,r,i),Pn(e,i,n,r);if(typeof i!=`symbol`){if(N(t)){r=Object.freeze(r.concat(t));for(let e=0;e<t.items.length;++e){let i=Pn(e,t.items[e],n,r);if(typeof i==`number`)e=i-1;else if(i===An)return An;else i===Mn&&(t.items.splice(e,1),--e)}}else if(j(t)){r=Object.freeze(r.concat(t));let e=Pn(`key`,t.key,n,r);if(e===An)return An;e===Mn&&(t.key=null);let i=Pn(`value`,t.value,n,r);if(i===An)return An;i===Mn&&(t.value=null)}}return i}function Fn(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function In(e,t,n,r){if(typeof n==`function`)return n(e,t,r);if(Dn(t))return n.Map?.(e,t,r);if(On(t))return n.Seq?.(e,t,r);if(j(t))return n.Pair?.(e,t,r);if(M(t))return n.Scalar?.(e,t,r);if(Tn(t))return n.Alias?.(e,t,r)}function Ln(e,t,n){let r=t[t.length-1];if(N(r))r.items[e]=n;else if(j(r))e===`key`?r.key=n:r.value=n;else if(En(r))r.contents=n;else{let e=Tn(r)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}var Rn={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},zn=e=>e.replace(/[!,[\]{}]/g,e=>Rn[e]),Bn=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+zn(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let t=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],n=Object.entries(this.tags),r;if(e&&n.length>0&&P(e.contents)){let t={};Nn(e.contents,(e,n)=>{P(n)&&n.tag&&(t[n.tag]=!0)}),r=Object.keys(t)}else r=[];for(let[i,a]of n)i===`!!`&&a===`tag:yaml.org,2002:`||e&&!r.some(e=>e.startsWith(a))||t.push(`%TAG ${i} ${a}`);return t.join(`
2
- `)}};Bn.defaultYaml={explicit:!1,version:`1.2`},Bn.defaultTags={"!!":`tag:yaml.org,2002:`};function Vn(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function Hn(e){let t=new Set;return Nn(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function Un(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function Wn(e,t){let n=[],r=new Map,i=null;return{onAnchor:r=>{n.push(r),i??=Hn(e);let a=Un(t,i);return i.add(a),a},setAnchors:()=>{for(let e of n){let t=r.get(e);if(typeof t==`object`&&t.anchor&&(M(t.node)||N(t.node)))t.node.anchor=t.anchor;else{let t=Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:r}}function Gn(e,t,n,r){if(r&&typeof r==`object`){if(Array.isArray(r))for(let t=0,n=r.length;t<n;++t){let n=r[t],i=Gn(e,r,String(t),n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}else if(r instanceof Map)for(let t of Array.from(r.keys())){let n=r.get(t),i=Gn(e,r,t,n);i===void 0?r.delete(t):i!==n&&r.set(t,i)}else if(r instanceof Set)for(let t of Array.from(r)){let n=Gn(e,r,t,t);n===void 0?r.delete(t):n!==t&&(r.delete(t),r.add(n))}else for(let[t,n]of Object.entries(r)){let i=Gn(e,r,t,n);i===void 0?delete r[t]:i!==n&&(r[t]=i)}}return e.call(t,n,r)}function F(e,t,n){if(Array.isArray(e))return e.map((e,t)=>F(e,String(t),n));if(e&&typeof e.toJSON==`function`){if(!n||!kn(e))return e.toJSON(t,n);let r={aliasCount:0,count:1,res:void 0};n.anchors.set(e,r),n.onCreate=e=>{r.res=e,delete n.onCreate};let i=e.toJSON(t,n);return n.onCreate&&n.onCreate(i),i}return typeof e==`bigint`&&!n?.keep?Number(e):e}var Kn=class{constructor(e){Object.defineProperty(this,A,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:n,onAnchor:r,reviver:i}={}){if(!En(e))throw TypeError(`A document argument is required`);let a={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof n==`number`?n:100},o=F(this,``,a);if(typeof r==`function`)for(let{count:e,res:t}of a.anchors.values())r(t,e);return typeof i==`function`?Gn(i,{"":o},``,o):o}},qn=class extends Kn{constructor(e){super(yn),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let n;t?.aliasResolveCache?n=t.aliasResolveCache:(n=[],Nn(e,{Node:(e,t)=>{(Tn(t)||kn(t))&&n.push(t)}}),t&&(t.aliasResolveCache=n));let r;for(let e of n){if(e===this)break;e.anchor===this.source&&(r=e)}if(r&&t){let{anchors:e,doc:n,maxAliasCount:i}=t,a=e.get(r);if(a||=(F(r,null,t),e.get(r)),a?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(i>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Jn(n,r,e)),a.count*a.aliasCount>i))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return r}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,t,n){let r=`*${this.source}`;if(e){if(Vn(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${r} `}return r}};function Jn(e,t,n){if(Tn(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(N(t)){let r=0;for(let i of t.items){let t=Jn(e,i,n);t>r&&(r=t)}return r}if(j(t)){let r=Jn(e,t.key,n),i=Jn(e,t.value,n);return Math.max(r,i)}return 1}var Yn=e=>!e||typeof e!=`function`&&typeof e!=`object`,I=class extends Kn{constructor(e){super(Cn),this.value=e}toJSON(e,t){return t?.keep?this.value:F(this.value,e,t)}toString(){return String(this.value)}};I.BLOCK_FOLDED=`BLOCK_FOLDED`,I.BLOCK_LITERAL=`BLOCK_LITERAL`,I.PLAIN=`PLAIN`,I.QUOTE_DOUBLE=`QUOTE_DOUBLE`,I.QUOTE_SINGLE=`QUOTE_SINGLE`;var Xn=`tag:yaml.org,2002:`;function Zn(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function Qn(e,t,n){if(En(e)&&(e=e.contents),P(e))return e;if(j(e)){let t=n.schema[xn].createNode?.(n.schema,null,n);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:r,onAnchor:i,onTagObj:a,schema:o,sourceObjects:s}=n,c;if(r&&e&&typeof e==`object`){if(c=s.get(e),c)return c.anchor??(c.anchor=i(e)),new qn(c.anchor);c={anchor:null,node:null},s.set(e,c)}t?.startsWith(`!!`)&&(t=Xn+t.slice(2));let l=Zn(e,t,o.tags);if(!l){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new I(e);return c&&(c.node=t),t}l=e instanceof Map?o[xn]:Symbol.iterator in Object(e)?o[wn]:o[xn]}a&&(a(l),delete n.onTagObj);let u=l?.createNode?l.createNode(n.schema,e,n):typeof l?.nodeClass?.from==`function`?l.nodeClass.from(n.schema,e,n):new I(e);return t?u.tag=t:l.default||(u.tag=l.tag),c&&(c.node=u),u}function $n(e,t,n){let r=n;for(let e=t.length-1;e>=0;--e){let n=t[e];if(typeof n==`number`&&Number.isInteger(n)&&n>=0){let e=[];e[n]=r,r=e}else r=new Map([[n,r]])}return Qn(r,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:new Map})}var er=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done,tr=class extends Kn{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>P(t)||j(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(er(e))this.add(t);else{let[n,...r]=e,i=this.get(n,!0);if(N(i))i.addIn(r,t);else if(i===void 0&&this.schema)this.set(n,$n(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}deleteIn(e){let[t,...n]=e;if(n.length===0)return this.delete(t);let r=this.get(t,!0);if(N(r))return r.deleteIn(n);throw Error(`Expected YAML collection at ${t}. Remaining path: ${n}`)}getIn(e,t){let[n,...r]=e,i=this.get(n,!0);return r.length===0?!t&&M(i)?i.value:i:N(i)?i.getIn(r,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!j(t))return!1;let n=t.value;return n==null||e&&M(n)&&n.value==null&&!n.commentBefore&&!n.comment&&!n.tag})}hasIn(e){let[t,...n]=e;if(n.length===0)return this.has(t);let r=this.get(t,!0);return N(r)?r.hasIn(n):!1}setIn(e,t){let[n,...r]=e;if(r.length===0)this.set(n,t);else{let e=this.get(n,!0);if(N(e))e.setIn(r,t);else if(e===void 0&&this.schema)this.set(n,$n(this.schema,r,t));else throw Error(`Expected YAML collection at ${n}. Remaining path: ${r}`)}}},nr=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function rr(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var ir=(e,t,n)=>e.endsWith(`
3
- `)?rr(n,t):n.includes(`
4
- `)?`
5
- `+rr(n,t):(e.endsWith(` `)?``:` `)+n,ar=`flow`,or=`block`,sr=`quoted`;function cr(e,t,n=`flow`,{indentAtStart:r,lineWidth:i=80,minContentWidth:a=20,onFold:o,onOverflow:s}={}){if(!i||i<0)return e;i<a&&(a=0);let c=Math.max(1+a,1+i-t.length);if(e.length<=c)return e;let l=[],u={},d=i-t.length;typeof r==`number`&&(r>i-Math.max(2,a)?l.push(0):d=i-r);let f,p,m=!1,h=-1,g=-1,_=-1;n===`block`&&(h=lr(e,h,t.length),h!==-1&&(d=h+c));for(let r;r=e[h+=1];){if(n===`quoted`&&r===`\\`){switch(g=h,e[h+1]){case`x`:h+=3;break;case`u`:h+=5;break;case`U`:h+=9;break;default:h+=1}_=h}if(r===`
6
- `)n===`block`&&(h=lr(e,h,t.length)),d=h+t.length+c,f=void 0;else{if(r===` `&&p&&p!==` `&&p!==`
7
- `&&p!==` `){let t=e[h+1];t&&t!==` `&&t!==`
8
- `&&t!==` `&&(f=h)}if(h>=d){if(f)l.push(f),d=f+c,f=void 0;else if(n===`quoted`){for(;p===` `||p===` `;)p=r,r=e[h+=1],m=!0;let t=h>_+1?h-2:g-1;if(u[t])return e;l.push(t),u[t]=!0,d=t+c,f=void 0}else m=!0}}p=r}if(m&&s&&s(),l.length===0)return e;o&&o();let v=e.slice(0,l[0]);for(let r=0;r<l.length;++r){let i=l[r],a=l[r+1]||e.length;i===0?v=`\n${t}${e.slice(0,a)}`:(n===`quoted`&&u[i]&&(v+=`${e[i]}\\`),v+=`\n${t}${e.slice(i+1,a)}`)}return v}function lr(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
9
- `);r=t,i=t+1,a=e[i]}return r}var ur=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),dr=e=>/^(%|---|\.\.\.)/m.test(e);function fr(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
10
- `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function pr(e,t){let n=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return n;let{implicitKey:r}=t,i=t.options.doubleQuotedMinMultiLineLength,a=t.indent||(dr(e)?` `:``),o=``,s=0;for(let e=0,t=n[e];t;t=n[++e])if(t===` `&&n[e+1]===`\\`&&n[e+2]===`n`&&(o+=n.slice(s,e)+`\\ `,e+=1,s=e,t=`\\`),t===`\\`)switch(n[e+1]){case`u`:{o+=n.slice(s,e);let t=n.substr(e+2,4);switch(t){case`0000`:o+=`\\0`;break;case`0007`:o+=`\\a`;break;case`000b`:o+=`\\v`;break;case`001b`:o+=`\\e`;break;case`0085`:o+=`\\N`;break;case`00a0`:o+=`\\_`;break;case`2028`:o+=`\\L`;break;case`2029`:o+=`\\P`;break;default:t.substr(0,2)===`00`?o+=`\\x`+t.substr(2):o+=n.substr(e,6)}e+=5,s=e+1}break;case`n`:if(r||n[e+2]===`"`||n.length<i)e+=1;else{for(o+=n.slice(s,e)+`
11
-
12
- `;n[e+2]===`\\`&&n[e+3]===`n`&&n[e+4]!==`"`;)o+=`
13
- `,e+=2;o+=a,n[e+2]===` `&&(o+=`\\`),e+=1,s=e+1}break;default:e+=1}return o=s?o+n.slice(s):n,r?o:cr(o,a,sr,ur(t,!1))}function mr(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
14
- `)||/[ \t]\n|\n[ \t]/.test(e))return pr(e,t);let n=t.indent||(dr(e)?` `:``),r=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${n}`)+`'`;return t.implicitKey?r:cr(r,n,ar,ur(t,!1))}function hr(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=pr;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?mr:i&&!t?pr:n?mr:pr}return r(e,t)}var gr;try{gr=RegExp(`(^|(?<!
15
- ))
16
- +(?!
17
- |$)`,`g`)}catch{gr=/\n+(?!\n|$)/g}function _r({comment:e,type:t,value:n},r,i,a){let{blockQuote:o,commentString:s,lineWidth:c}=r.options;if(!o||/\n[\t ]+$/.test(n))return hr(n,r);let l=r.indent||(r.forceBlockIndent||dr(n)?` `:``),u=o===`literal`?!0:o===`folded`||t===I.BLOCK_FOLDED?!1:t===I.BLOCK_LITERAL||!fr(n,c,l.length);if(!n)return u?`|
18
- `:`>
19
- `;let d,f;for(f=n.length;f>0;--f){let e=n[f-1];if(e!==`
20
- `&&e!==` `&&e!==` `)break}let p=n.substring(f),m=p.indexOf(`
21
- `);m===-1?d=`-`:n===p||m!==p.length-1?(d=`+`,a&&a()):d=``,p&&=(n=n.slice(0,-p.length),p[p.length-1]===`
22
- `&&(p=p.slice(0,-1)),p.replace(gr,`$&${l}`));let h=!1,g,_=-1;for(g=0;g<n.length;++g){let e=n[g];if(e===` `)h=!0;else if(e===`
23
- `)_=g;else break}let v=n.substring(0,_<g?_+1:g);v&&=(n=n.substring(v.length),v.replace(/\n+/g,`$&${l}`));let y=(h?l?`2`:`1`:``)+d;if(e&&(y+=` `+s(e.replace(/ ?[\r\n]+/g,` `)),i&&i()),!u){let e=n.replace(/\n+/g,`
24
- $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${l}`),i=!1,a=ur(r,!0);o!==`folded`&&t!==I.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let s=cr(`${v}${e}${p}`,l,or,a);if(!i)return`>${y}\n${l}${s}`}return n=n.replace(/\n+/g,`$&${l}`),`|${y}\n${l}${v}${n}${p}`}function vr(e,t,n,r){let{type:i,value:a}=e,{actualString:o,implicitKey:s,indent:c,indentStep:l,inFlow:u}=t;if(s&&a.includes(`
25
- `)||u&&/[[\]{},]/.test(a))return hr(a,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(a))return s||u||!a.includes(`
26
- `)?hr(a,t):_r(e,t,n,r);if(!s&&!u&&i!==I.PLAIN&&a.includes(`
27
- `))return _r(e,t,n,r);if(dr(a)){if(c===``)return t.forceBlockIndent=!0,_r(e,t,n,r);if(s&&c===l)return hr(a,t)}let d=a.replace(/\n+/g,`$&\n${c}`);if(o){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(d),{compat:n,tags:r}=t.doc.schema;if(r.some(e)||n?.some(e))return hr(a,t)}return s?d:cr(d,c,ar,ur(t,!1))}function yr(e,t,n,r){let{implicitKey:i,inFlow:a}=t,o=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:s}=e;s!==I.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(s=I.QUOTE_DOUBLE);let c=e=>{switch(e){case I.BLOCK_FOLDED:case I.BLOCK_LITERAL:return i||a?hr(o.value,t):_r(o,t,n,r);case I.QUOTE_DOUBLE:return pr(o.value,t);case I.QUOTE_SINGLE:return mr(o.value,t);case I.PLAIN:return vr(o,t,n,r);default:return null}},l=c(s);if(l===null){let{defaultKeyType:e,defaultStringType:n}=t.options,r=i&&e||n;if(l=c(r),l===null)throw Error(`Unsupported default string type ${r}`)}return l}function br(e,t){let n=Object.assign({blockQuote:!0,commentString:nr,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),r;switch(n.collectionStyle){case`block`:r=!1;break;case`flow`:r=!0;break;default:r=null}return{anchors:new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:r,options:n}}function xr(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let n,r;if(M(t)){r=t.value;let i=e.filter(e=>e.identify?.(r));if(i.length>1){let e=i.filter(e=>e.test);e.length>0&&(i=e)}n=i.find(e=>e.format===t.format)??i.find(e=>!e.format)}else r=t,n=e.find(e=>e.nodeClass&&r instanceof e.nodeClass);if(!n){let e=r?.constructor?.name??(r===null?`null`:typeof r);throw Error(`Tag not resolved for ${e} value`)}return n}function Sr(e,t,{anchors:n,doc:r}){if(!r.directives)return``;let i=[],a=(M(e)||N(e))&&e.anchor;a&&Vn(a)&&(n.add(a),i.push(`&${a}`));let o=e.tag??(t.default?null:t.tag);return o&&i.push(r.directives.tagString(o)),i.join(` `)}function Cr(e,t,n,r){if(j(e))return e.toString(t,n,r);if(Tn(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let i,a=P(e)?e:t.doc.createNode(e,{onTagObj:e=>i=e});i??=xr(t.doc.schema.tags,a);let o=Sr(a,i,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let s=typeof i.stringify==`function`?i.stringify(a,t,n,r):M(a)?yr(a,t,n,r):a.toString(t,n,r);return o?M(a)||s[0]===`{`||s[0]===`[`?`${o} ${s}`:`${o}\n${t.indent}${s}`:s}function wr({key:e,value:t},n,r,i){let{allNullValues:a,doc:o,indent:s,indentStep:c,options:{commentString:l,indentSeq:u,simpleKeys:d}}=n,f=P(e)&&e.comment||null;if(d){if(f)throw Error(`With simple keys, key nodes cannot have comments`);if(N(e)||!P(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let p=!d&&(!e||f&&t==null&&!n.inFlow||N(e)||(M(e)?e.type===I.BLOCK_FOLDED||e.type===I.BLOCK_LITERAL:typeof e==`object`));n=Object.assign({},n,{allNullValues:!1,implicitKey:!p&&(d||!a),indent:s+c});let m=!1,h=!1,g=Cr(e,n,()=>m=!0,()=>h=!0);if(!p&&!n.inFlow&&g.length>1024){if(d)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);p=!0}if(n.inFlow){if(a||t==null)return m&&r&&r(),g===``?`?`:p?`? ${g}`:g}else if(a&&!d||t==null&&p)return g=`? ${g}`,f&&!m?g+=ir(g,n.indent,l(f)):h&&i&&i(),g;m&&(f=null),p?(f&&(g+=ir(g,n.indent,l(f))),g=`? ${g}\n${s}:`):(g=`${g}:`,f&&(g+=ir(g,n.indent,l(f))));let _,v,y;P(t)?(_=!!t.spaceBefore,v=t.commentBefore,y=t.comment):(_=!1,v=null,y=null,t&&typeof t==`object`&&(t=o.createNode(t))),n.implicitKey=!1,!p&&!f&&M(t)&&(n.indentAtStart=g.length+1),h=!1,!u&&c.length>=2&&!n.inFlow&&!p&&On(t)&&!t.flow&&!t.tag&&!t.anchor&&(n.indent=n.indent.substring(2));let ee=!1,b=Cr(t,n,()=>ee=!0,()=>h=!0),x=` `;if(f||_||v){if(x=_?`
28
- `:``,v){let e=l(v);x+=`\n${rr(e,n.indent)}`}b===``&&!n.inFlow?x===`
29
- `&&y&&(x=`
30
-
31
- `):x+=`\n${n.indent}`}else if(!p&&N(t)){let e=b[0],r=b.indexOf(`
32
- `),i=r!==-1,a=n.inFlow??t.flow??t.items.length===0;if(i||!a){let t=!1;if(i&&(e===`&`||e===`!`)){let n=b.indexOf(` `);e===`&`&&n!==-1&&n<r&&b[n+1]===`!`&&(n=b.indexOf(` `,n+1)),(n===-1||r<n)&&(t=!0)}t||(x=`\n${n.indent}`)}}else(b===``||b[0]===`
33
- `)&&(x=``);return g+=x+b,n.inFlow?ee&&r&&r():y&&!ee?g+=ir(g,n.indent,l(y)):h&&i&&i(),g}function Tr(e,t){(e===`debug`||e===`warn`)&&console.warn(t)}var Er=`<<`,Dr={identify:e=>e===Er||typeof e==`symbol`&&e.description===Er,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new I(Symbol(Er)),{addToJSMap:kr}),stringify:()=>Er},Or=(e,t)=>(Dr.identify(t)||M(t)&&(!t.type||t.type===I.PLAIN)&&Dr.identify(t.value))&&e?.doc.schema.tags.some(e=>e.tag===Dr.tag&&e.default);function kr(e,t,n){let r=jr(e,n);if(On(r))for(let n of r.items)Ar(e,t,n);else if(Array.isArray(r))for(let n of r)Ar(e,t,n);else Ar(e,t,r)}function Ar(e,t,n){let r=jr(e,n);if(!Dn(r))throw Error(`Merge sources must be maps or map aliases`);let i=r.toJSON(null,e,Map);for(let[e,n]of i)t instanceof Map?t.has(e)||t.set(e,n):t instanceof Set?t.add(e):Object.prototype.hasOwnProperty.call(t,e)||Object.defineProperty(t,e,{value:n,writable:!0,enumerable:!0,configurable:!0});return t}function jr(e,t){return e&&Tn(t)?t.resolve(e.doc,e):t}function Mr(e,t,{key:n,value:r}){if(P(n)&&n.addToJSMap)n.addToJSMap(e,t,r);else if(Or(e,n))kr(e,t,r);else{let i=F(n,``,e);if(t instanceof Map)t.set(i,F(r,i,e));else if(t instanceof Set)t.add(i);else{let a=Nr(n,i,e),o=F(r,a,e);a in t?Object.defineProperty(t,a,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[a]=o}}return t}function Nr(e,t,n){if(t===null)return``;if(typeof t!=`object`)return String(t);if(P(e)&&n?.doc){let t=br(n.doc,{});t.anchors=new Set;for(let e of n.anchors.keys())t.anchors.add(e.anchor);t.inFlow=!0,t.inStringifyKey=!0;let r=e.toString(t);if(!n.mapKeyWarned){let e=JSON.stringify(r);e.length>40&&(e=e.substring(0,36)+`..."`),Tr(n.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),n.mapKeyWarned=!0}return r}return JSON.stringify(t)}function Pr(e,t,n){return new L(Qn(e,void 0,n),Qn(t,void 0,n))}var L=class e{constructor(e,t=null){Object.defineProperty(this,A,{value:Sn}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return P(n)&&(n=n.clone(t)),P(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){return Mr(t,t?.mapAsMap?new Map:{},this)}toString(e,t,n){return e?.doc?wr(this,e,t,n):JSON.stringify(this)}};function Fr(e,t,n){return(t.inFlow??e.flow?Lr:Ir)(e,t,n)}function Ir({comment:e,items:t},n,{blockItemPrefix:r,flowChars:i,itemIndent:a,onChompKeep:o,onComment:s}){let{indent:c,options:{commentString:l}}=n,u=Object.assign({},n,{indent:a,type:null}),d=!1,f=[];for(let e=0;e<t.length;++e){let i=t[e],o=null;if(P(i))!d&&i.spaceBefore&&f.push(``),Rr(n,f,i.commentBefore,d),i.comment&&(o=i.comment);else if(j(i)){let e=P(i.key)?i.key:null;e&&(!d&&e.spaceBefore&&f.push(``),Rr(n,f,e.commentBefore,d))}d=!1;let s=Cr(i,u,()=>o=null,()=>d=!0);o&&(s+=ir(s,a,l(o))),d&&o&&(d=!1),f.push(r+s)}let p;if(f.length===0)p=i.start+i.end;else{p=f[0];for(let e=1;e<f.length;++e){let t=f[e];p+=t?`\n${c}${t}`:`
34
- `}}return e?(p+=`
35
- `+rr(l(e),c),s&&s()):d&&o&&o(),p}function Lr({items:e},t,{flowChars:n,itemIndent:r}){let{indent:i,indentStep:a,flowCollectionPadding:o,options:{commentString:s}}=t;r+=a;let c=Object.assign({},t,{indent:r,inFlow:!0,type:null}),l=!1,u=0,d=[];for(let n=0;n<e.length;++n){let i=e[n],a=null;if(P(i))i.spaceBefore&&d.push(``),Rr(t,d,i.commentBefore,!1),i.comment&&(a=i.comment);else if(j(i)){let e=P(i.key)?i.key:null;e&&(e.spaceBefore&&d.push(``),Rr(t,d,e.commentBefore,!1),e.comment&&(l=!0));let n=P(i.value)?i.value:null;n?(n.comment&&(a=n.comment),n.commentBefore&&(l=!0)):i.value==null&&e?.comment&&(a=e.comment)}a&&(l=!0);let o=Cr(i,c,()=>a=null);l||=d.length>u||o.includes(`
36
- `),n<e.length-1?o+=`,`:t.options.trailingComma&&(t.options.lineWidth>0&&(l||=d.reduce((e,t)=>e+t.length+2,2)+(o.length+2)>t.options.lineWidth),l&&(o+=`,`)),a&&(o+=ir(o,r,s(a))),d.push(o),u=d.length}let{start:f,end:p}=n;if(d.length===0)return f+p;if(!l){let e=d.reduce((e,t)=>e+t.length+2,2);l=t.options.lineWidth>0&&e>t.options.lineWidth}if(l){let e=f;for(let t of d)e+=t?`\n${a}${i}${t}`:`
37
- `;return`${e}\n${i}${p}`}return`${f}${o}${d.join(` `)}${o}${p}`}function Rr({indent:e,options:{commentString:t}},n,r,i){if(r&&i&&(r=r.replace(/^\n+/,``)),r){let i=rr(t(r),e);n.push(i.trimStart())}}function zr(e,t){let n=M(t)?t.value:t;for(let r of e)if(j(r)&&(r.key===t||r.key===n||M(r.key)&&r.key.value===n))return r}var R=class extends tr{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(xn,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,a=new this(e),o=(e,o)=>{if(typeof i==`function`)o=i.call(t,e,o);else if(Array.isArray(i)&&!i.includes(e))return;(o!==void 0||r)&&a.items.push(Pr(e,o,n))};if(t instanceof Map)for(let[e,n]of t)o(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))o(e,t[e]);return typeof e.sortMapEntries==`function`&&a.items.sort(e.sortMapEntries),a}add(e,t){let n;n=j(e)?e:!e||typeof e!=`object`||!(`key`in e)?new L(e,e?.value):new L(e.key,e.value);let r=zr(this.items,n.key),i=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);M(r.value)&&Yn(n.value)?r.value.value=n.value:r.value=n.value}else if(i){let e=this.items.findIndex(e=>i(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=zr(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=zr(this.items,e)?.value;return(!t&&M(n)?n.value:n)??void 0}has(e){return!!zr(this.items,e)}set(e,t){this.add(new L(e,t),!0)}toJSON(e,t,n){let r=n?new n:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(r);for(let e of this.items)Mr(t,r,e);return r}toString(e,t,n){if(!e)return JSON.stringify(this);for(let e of this.items)if(!j(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),Fr(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:n,onComment:t})}},Br={collection:`map`,default:!0,nodeClass:R,tag:`tag:yaml.org,2002:map`,resolve(e,t){return Dn(e)||t(`Expected a mapping for this tag`),e},createNode:(e,t,n)=>R.from(e,t,n)},Vr=class extends tr{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(wn,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=Hr(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=Hr(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&M(r)?r.value:r}has(e){let t=Hr(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=Hr(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];M(r)&&Yn(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(F(e,String(r++),t));return n}toString(e,t,n){return e?Fr(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:n,onComment:t}):JSON.stringify(this)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t)){let e=0;for(let a of t){if(typeof r==`function`){let n=t instanceof Set?a:String(e++);a=r.call(t,n,a)}i.items.push(Qn(a,void 0,n))}}return i}};function Hr(e){let t=M(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}var Ur={collection:`seq`,default:!0,nodeClass:Vr,tag:`tag:yaml.org,2002:seq`,resolve(e,t){return On(e)||t(`Expected a sequence for this tag`),e},createNode:(e,t,n)=>Vr.from(e,t,n)},Wr={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,t,n,r){return t=Object.assign({actualString:!0},t),yr(e,t,n,r)}},Gr={identify:e=>e==null,createNode:()=>new I(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new I(null),stringify:({source:e},t)=>typeof e==`string`&&Gr.test.test(e)?e:t.options.nullStr},Kr={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new I(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},n){return e&&Kr.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?n.options.trueStr:n.options.falseStr}};function z({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}var qr={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:z},Jr={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():z(e)}},Yr={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new I(parseFloat(e)),n=e.indexOf(`.`);return n!==-1&&e[e.length-1]===`0`&&(t.minFractionDigits=e.length-n-1),t},stringify:z},Xr=e=>typeof e==`bigint`||Number.isInteger(e),Zr=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function Qr(e,t,n){let{value:r}=e;return Xr(r)&&r>=0?n+r.toString(t):z(e)}var $r={identify:e=>Xr(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>Zr(e,2,8,n),stringify:e=>Qr(e,8,`0o`)},ei={identify:Xr,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>Zr(e,0,10,n),stringify:z},ti={identify:e=>Xr(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>Zr(e,2,16,n),stringify:e=>Qr(e,16,`0x`)},ni=[Br,Ur,Wr,Gr,Kr,$r,ei,ti,qr,Jr,Yr];function ri(e){return typeof e==`bigint`||Number.isInteger(e)}var ii=({value:e})=>JSON.stringify(e),ai=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:ii},{identify:e=>e==null,createNode:()=>new I(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:ii},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:ii},{identify:ri,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>ri(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:ii}],oi=[Br,Ur].concat(ai,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}}),si={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,t){if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return t(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:t,value:n},r,i,a){if(!n)return``;let o=n,s;if(typeof btoa==`function`){let e=``;for(let t=0;t<o.length;++t)e+=String.fromCharCode(o[t]);s=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(t??=I.BLOCK_LITERAL,t!==I.QUOTE_DOUBLE){let e=Math.max(r.options.lineWidth-r.indent.length,r.options.minContentWidth),n=Math.ceil(s.length/e),i=Array(n);for(let t=0,r=0;t<n;++t,r+=e)i[t]=s.substr(r,e);s=i.join(t===I.BLOCK_LITERAL?`
38
- `:` `)}return yr({comment:e,type:t,value:s},r,i,a)}};function ci(e,t){if(On(e))for(let n=0;n<e.items.length;++n){let r=e.items[n];if(!j(r)){if(Dn(r)){r.items.length>1&&t(`Each pair must have its own sequence indicator`);let e=r.items[0]||new L(new I(null));if(r.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${r.commentBefore}\n${e.key.commentBefore}`:r.commentBefore),r.comment){let t=e.value??e.key;t.comment=t.comment?`${r.comment}\n${t.comment}`:r.comment}r=e}e.items[n]=j(r)?r:new L(r)}}else t(`Expected a sequence for this tag`);return e}function li(e,t,n){let{replacer:r}=n,i=new Vr(e);i.tag=`tag:yaml.org,2002:pairs`;let a=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof r==`function`&&(e=r.call(t,String(a++),e));let o,s;if(Array.isArray(e)){if(e.length===2)o=e[0],s=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)o=t[0],s=e[o];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else o=e;i.items.push(Pr(o,s,n))}return i}var ui={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:ci,createNode:li},di=class e extends Vr{constructor(){super(),this.add=R.prototype.add.bind(this),this.delete=R.prototype.delete.bind(this),this.get=R.prototype.get.bind(this),this.has=R.prototype.has.bind(this),this.set=R.prototype.set.bind(this),this.tag=e.tag}toJSON(e,t){if(!t)return super.toJSON(e);let n=new Map;t?.onCreate&&t.onCreate(n);for(let e of this.items){let r,i;if(j(e)?(r=F(e.key,``,t),i=F(e.value,r,t)):r=F(e,``,t),n.has(r))throw Error(`Ordered maps must not include duplicate keys`);n.set(r,i)}return n}static from(e,t,n){let r=li(e,t,n),i=new this;return i.items=r.items,i}};di.tag=`tag:yaml.org,2002:omap`;var fi={collection:`seq`,identify:e=>e instanceof Map,nodeClass:di,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,t){let n=ci(e,t),r=[];for(let{key:e}of n.items)M(e)&&(r.includes(e.value)?t(`Ordered maps must not include duplicate keys: ${e.value}`):r.push(e.value));return Object.assign(new di,n)},createNode:(e,t,n)=>di.from(e,t,n)};function pi({value:e,source:t},n){return t&&(e?mi:hi).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}var mi={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new I(!0),stringify:pi},hi={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new I(!1),stringify:pi},gi={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:z},_i={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():z(e)}},vi={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new I(parseFloat(e.replace(/_/g,``))),n=e.indexOf(`.`);if(n!==-1){let r=e.substring(n+1).replace(/_/g,``);r[r.length-1]===`0`&&(t.minFractionDigits=r.length)}return t},stringify:z},yi=e=>typeof e==`bigint`||Number.isInteger(e);function bi(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function xi(e,t,n){let{value:r}=e;if(yi(r)){let e=r.toString(t);return r<0?`-`+n+e.substr(1):n+e}return z(e)}var Si={identify:yi,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>bi(e,2,2,n),stringify:e=>xi(e,2,`0b`)},Ci={identify:yi,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>bi(e,1,8,n),stringify:e=>xi(e,8,`0`)},wi={identify:yi,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>bi(e,0,10,n),stringify:z},Ti={identify:yi,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>bi(e,2,16,n),stringify:e=>xi(e,16,`0x`)},Ei=class e extends R{constructor(t){super(t),this.tag=e.tag}add(e){let t;t=j(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new L(e.key,null):new L(e,null),zr(this.items,t.key)||this.items.push(t)}get(e,t){let n=zr(this.items,e);return!t&&j(n)?M(n.key)?n.key.value:n.key:n}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let n=zr(this.items,e);n&&!t?this.items.splice(this.items.indexOf(n),1):!n&&t&&this.items.push(new L(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,n){let{replacer:r}=n,i=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof r==`function`&&(e=r.call(t,e,e)),i.items.push(Pr(e,null,n));return i}};Ei.tag=`tag:yaml.org,2002:set`;var Di={collection:`map`,identify:e=>e instanceof Set,nodeClass:Ei,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>Ei.from(e,t,n),resolve(e,t){if(Dn(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ei,e);t(`Set items must all have null values`)}else t(`Expected a mapping for this tag`);return e}};function Oi(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function ki(e){let{value:t}=e,n=e=>e;if(typeof t==`bigint`)n=e=>BigInt(e);else if(isNaN(t)||!isFinite(t))return z(e);let r=``;t<0&&(r=`-`,t*=n(-1));let i=n(60),a=[t%i];return t<60?a.unshift(0):(t=(t-a[0])/i,a.unshift(t%i),t>=60&&(t=(t-a[0])/i,a.unshift(t))),r+a.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}var Ai={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:n})=>Oi(e,n),stringify:ki},ji={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Oi(e,!1),stringify:ki},Mi={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,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})?))?)?$`),resolve(e){let t=e.match(Mi.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,n,r,i,a,o,s]=t.map(Number),c=t[7]?Number((t[7]+`00`).substr(1,3)):0,l=Date.UTC(n,r-1,i,a||0,o||0,s||0,c),u=t[8];if(u&&u!==`Z`){let e=Oi(u,!1);Math.abs(e)<30&&(e*=60),l-=6e4*e}return new Date(l)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``},Ni=[Br,Ur,Wr,Gr,mi,hi,Si,Ci,wi,Ti,gi,_i,vi,si,Dr,fi,ui,Di,Ai,ji,Mi],Pi=new Map([[`core`,ni],[`failsafe`,[Br,Ur,Wr]],[`json`,oi],[`yaml11`,Ni],[`yaml-1.1`,Ni]]),Fi={binary:si,bool:Kr,float:Yr,floatExp:Jr,floatNaN:qr,floatTime:ji,int:ei,intHex:ti,intOct:$r,intTime:Ai,map:Br,merge:Dr,null:Gr,omap:fi,pairs:ui,seq:Ur,set:Di,timestamp:Mi},Ii={"tag:yaml.org,2002:binary":si,"tag:yaml.org,2002:merge":Dr,"tag:yaml.org,2002:omap":fi,"tag:yaml.org,2002:pairs":ui,"tag:yaml.org,2002:set":Di,"tag:yaml.org,2002:timestamp":Mi};function Li(e,t,n){let r=Pi.get(t);if(r&&!e)return n&&!r.includes(Dr)?r.concat(Dr):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(Pi.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(Dr)),i.reduce((e,t)=>{let n=typeof t==`string`?Fi[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(Fi).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}var Ri=(e,t)=>e.key<t.key?-1:+(e.key>t.key),zi=class e{constructor({compat:e,customTags:t,merge:n,resolveKnownTags:r,schema:i,sortMapEntries:a,toStringDefaults:o}){this.compat=Array.isArray(e)?Li(e,`compat`):e?Li(null,e):null,this.name=typeof i==`string`&&i||`core`,this.knownTags=r?Ii:{},this.tags=Li(t,this.name,n),this.toStringOptions=o??null,Object.defineProperty(this,xn,{value:Br}),Object.defineProperty(this,Cn,{value:Wr}),Object.defineProperty(this,wn,{value:Ur}),this.sortMapEntries=typeof a==`function`?a:a===!0?Ri:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};function Bi(e,t){let n=[],r=t.directives===!0;if(t.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(n.push(t),r=!0):e.directives.docStart&&(r=!0)}r&&n.push(`---`);let i=br(e,t),{commentString:a}=i.options;if(e.commentBefore){n.length!==1&&n.unshift(``);let t=a(e.commentBefore);n.unshift(rr(t,``))}let o=!1,s=null;if(e.contents){if(P(e.contents)){if(e.contents.spaceBefore&&r&&n.push(``),e.contents.commentBefore){let t=a(e.contents.commentBefore);n.push(rr(t,``))}i.forceBlockIndent=!!e.comment,s=e.contents.comment}let t=s?void 0:()=>o=!0,c=Cr(e.contents,i,()=>s=null,t);s&&(c+=ir(c,``,a(s))),(c[0]===`|`||c[0]===`>`)&&n[n.length-1]===`---`?n[n.length-1]=`--- ${c}`:n.push(c)}else n.push(Cr(e.contents,i));if(e.directives?.docEnd){if(e.comment){let t=a(e.comment);t.includes(`
39
- `)?(n.push(`...`),n.push(rr(t,``))):n.push(`... ${t}`)}else n.push(`...`)}else{let t=e.comment;t&&o&&(t=t.replace(/^\n+/,``)),t&&((!o||s)&&n[n.length-1]!==``&&n.push(``),n.push(rr(a(t),``)))}return n.join(`
40
- `)+`
41
- `}var Vi=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,A,{value:bn});let r=null;typeof t==`function`||Array.isArray(t)?r=t:n===void 0&&t&&(n=t,t=void 0);let i=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=i;let{version:a}=i;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(a=this.directives.yaml.version)):this.directives=new Bn({version:a}),this.setSchema(a,n),this.contents=e===void 0?null:this.createNode(e,r,n)}clone(){let t=Object.create(e.prototype,{[A]:{value:bn}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=P(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){Hi(this.contents)&&this.contents.add(e)}addIn(e,t){Hi(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){let n=Hn(this);e.anchor=!t||n.has(t)?Un(t||`a`,n):t}return new qn(e.anchor)}createNode(e,t,n){let r;if(typeof t==`function`)e=t.call({"":e},``,e),r=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),r=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:i,anchorPrefix:a,flow:o,keepUndefined:s,onTagObj:c,tag:l}=n??{},{onAnchor:u,setAnchors:d,sourceObjects:f}=Wn(this,a||`a`),p={aliasDuplicateObjects:i??!0,keepUndefined:s??!1,onAnchor:u,onTagObj:c,replacer:r,schema:this.schema,sourceObjects:f},m=Qn(e,l,p);return o&&N(m)&&(m.flow=!0),d(),m}createPair(e,t,n={}){return new L(this.createNode(e,null,n),this.createNode(t,null,n))}delete(e){return Hi(this.contents)?this.contents.delete(e):!1}deleteIn(e){return er(e)?this.contents!=null&&(this.contents=null,!0):Hi(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return N(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return er(e)?!t&&M(this.contents)?this.contents.value:this.contents:N(this.contents)?this.contents.getIn(e,t):void 0}has(e){return N(this.contents)?this.contents.has(e):!1}hasIn(e){return er(e)?this.contents!==void 0:N(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=$n(this.schema,[e],t):Hi(this.contents)&&this.contents.set(e,t)}setIn(e,t){er(e)?this.contents=t:this.contents==null?this.contents=$n(this.schema,Array.from(e),t):Hi(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new Bn({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new Bn({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new zi(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:a}={}){let o={anchors:new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},s=F(this.contents,t??``,o);if(typeof i==`function`)for(let{count:e,res:t}of o.anchors.values())i(t,e);return typeof a==`function`?Gn(a,{"":s},``,s):s}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return Bi(this,e)}};function Hi(e){if(N(e))return!0;throw Error(`Expected a YAML collection as document contents`)}var Ui=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},Wi=class extends Ui{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},Gi=class extends Ui{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}},Ki=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
42
- `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}};function qi(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,ee=null,b=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:ee&&n===`seq-item-ind`||(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,b??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,b??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),ee&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),ee=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let x=e[e.length-1],te=x?x.offset+x.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:ee,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:te,start:b??te}}function Ji(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
43
- `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let t of e.items){for(let e of t.start)if(e.type===`newline`)return!0;if(t.sep){for(let e of t.sep)if(e.type===`newline`)return!0}if(Ji(t.key)||Ji(t.value))return!0}return!1;default:return!0}}function Yi(e,t,n){if(t?.type===`flow-collection`){let r=t.end[0];r.indent===e&&(r.source===`]`||r.source===`}`)&&Ji(t)&&n(r,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}function Xi(e,t,n){let{uniqueKeys:r}=e.options;if(r===!1)return!1;let i=typeof r==`function`?r:(e,t)=>e===t||M(e)&&M(t)&&e.value===t.value;return t.some(e=>i(e.key,n))}var Zi=`All mapping items must start at the same column`;function Qi({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??R)(n.schema);n.atRoot&&=!1;let s=r.offset,c=null;for(let a of r.items){let{start:l,key:u,sep:d,value:f}=a,p=qi(l,{indicator:`explicit-key-ind`,next:u??d?.[0],offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0}),m=!p.found;if(m){if(u&&(u.type===`block-seq`?i(s,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in u&&u.indent!==r.indent&&i(s,`BAD_INDENT`,Zi)),!p.anchor&&!p.tag&&!d){c=p.end,p.comment&&(o.comment?o.comment+=`
44
- `+p.comment:o.comment=p.comment);continue}(p.newlineAfterProp||Ji(u))&&i(u??l[l.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else p.found?.indent!==r.indent&&i(s,`BAD_INDENT`,Zi);n.atKey=!0;let h=p.end,g=u?e(n,u,p,i):t(n,h,l,null,p,i);n.schema.compat&&Yi(r.indent,u,i),n.atKey=!1,Xi(n,o.items,g)&&i(h,`DUPLICATE_KEY`,`Map keys must be unique`);let _=qi(d??[],{indicator:`map-value-ind`,next:f,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!u||u.type===`block-scalar`});if(s=_.end,_.found){m&&(f?.type===`block-map`&&!_.hasNewline&&i(s,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),n.options.strict&&p.start<_.found.offset-1024&&i(g.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let c=f?e(n,f,_,i):t(n,s,d,null,_,i);n.schema.compat&&Yi(r.indent,f,i),s=c.range[2];let l=new L(g,c);n.options.keepSourceTokens&&(l.srcToken=a),o.items.push(l)}else{m&&i(g.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),_.comment&&(g.comment?g.comment+=`
45
- `+_.comment:g.comment=_.comment);let e=new L(g);n.options.keepSourceTokens&&(e.srcToken=a),o.items.push(e)}}return c&&c<s&&i(c,`IMPOSSIBLE`,`Map comment with trailing content`),o.range=[r.offset,s,c??s],o}function $i({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=new((a?.nodeClass)??Vr)(n.schema);n.atRoot&&=!1,n.atKey&&=!1;let s=r.offset,c=null;for(let{start:a,value:l}of r.items){let u=qi(a,{indicator:`seq-item-ind`,next:l,offset:s,onError:i,parentIndent:r.indent,startOnNewline:!0});if(!u.found){if(u.anchor||u.tag||l)l?.type===`block-seq`?i(u.end,`BAD_INDENT`,`All sequence items must start at the same column`):i(s,`MISSING_CHAR`,`Sequence item without - indicator`);else{c=u.end,u.comment&&(o.comment=u.comment);continue}}let d=l?e(n,l,u,i):t(n,u.end,a,null,u,i);n.schema.compat&&Yi(r.indent,l,i),s=d.range[2],o.items.push(d)}return o.range=[r.offset,s,c??s],o}function ea(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}var ta=`Block collections are not allowed within flow collections`,na=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function ra({composeNode:e,composeEmptyNode:t},n,r,i,a){let o=r.start.source===`{`,s=o?`flow map`:`flow sequence`,c=new((a?.nodeClass)??(o?R:Vr))(n.schema);c.flow=!0;let l=n.atRoot;l&&(n.atRoot=!1),n.atKey&&=!1;let u=r.offset+r.start.source.length;for(let a=0;a<r.items.length;++a){let l=r.items[a],{start:d,key:f,sep:p,value:m}=l,h=qi(d,{flow:s,indicator:`explicit-key-ind`,next:f??p?.[0],offset:u,onError:i,parentIndent:r.indent,startOnNewline:!1});if(!h.found){if(!h.anchor&&!h.tag&&!p&&!m){a===0&&h.comma?i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`):a<r.items.length-1&&i(h.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${s}`),h.comment&&(c.comment?c.comment+=`
46
- `+h.comment:c.comment=h.comment),u=h.end;continue}!o&&n.options.strict&&Ji(f)&&i(f,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(a===0)h.comma&&i(h.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${s}`);else if(h.comma||i(h.start,`MISSING_CHAR`,`Missing , between ${s} items`),h.comment){let e=``;loop:for(let t of d)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let t=c.items[c.items.length-1];j(t)&&(t=t.value??t.key),t.comment?t.comment+=`
47
- `+e:t.comment=e,h.comment=h.comment.substring(e.length+1)}}if(!o&&!p&&!h.found){let r=m?e(n,m,h,i):t(n,h.end,p,null,h,i);c.items.push(r),u=r.range[2],na(m)&&i(r.range,`BLOCK_IN_FLOW`,ta)}else{n.atKey=!0;let a=h.end,g=f?e(n,f,h,i):t(n,a,d,null,h,i);na(f)&&i(g.range,`BLOCK_IN_FLOW`,ta),n.atKey=!1;let _=qi(p??[],{flow:s,indicator:`map-value-ind`,next:m,offset:g.range[2],onError:i,parentIndent:r.indent,startOnNewline:!1});if(_.found){if(!o&&!h.found&&n.options.strict){if(p)for(let e of p){if(e===_.found)break;if(e.type===`newline`){i(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}h.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`)}}else m&&(`source`in m&&m.source?.[0]===`:`?i(m,`MISSING_CHAR`,`Missing space after : in ${s}`):i(_.start,`MISSING_CHAR`,`Missing , or : between ${s} items`));let v=m?e(n,m,_,i):_.found?t(n,_.end,p,null,_,i):null;v?na(m)&&i(v.range,`BLOCK_IN_FLOW`,ta):_.comment&&(g.comment?g.comment+=`
48
- `+_.comment:g.comment=_.comment);let y=new L(g,v);if(n.options.keepSourceTokens&&(y.srcToken=l),o){let e=c;Xi(n,e.items,g)&&i(a,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(y)}else{let e=new R(n.schema);e.flow=!0,e.items.push(y);let t=(v??g).range;e.range=[g.range[0],t[1],t[2]],c.items.push(e)}u=v?v.range[2]:_.end}}let d=o?`}`:`]`,[f,...p]=r.end,m=u;if(f?.source===d)m=f.offset+f.source.length;else{let e=s[0].toUpperCase()+s.substring(1),t=l?`${e} must end with a ${d}`:`${e} in block collection must be sufficiently indented and end with a ${d}`;i(u,l?`MISSING_CHAR`:`BAD_INDENT`,t),f&&f.source.length!==1&&p.unshift(f)}if(p.length>0){let e=ea(p,m,n.options.strict,i);e.comment&&(c.comment?c.comment+=`
49
- `+e.comment:c.comment=e.comment),c.range=[r.offset,m,e.offset]}else c.range=[r.offset,m,m];return c}function ia(e,t,n,r,i,a){let o=n.type===`block-map`?Qi(e,t,n,r,a):n.type===`block-seq`?$i(e,t,n,r,a):ra(e,t,n,r,a),s=o.constructor;return i===`!`||i===s.tagName?(o.tag=s.tagName,o):(i&&(o.tag=i),o)}function aa(e,t,n,r,i){let a=r.tag,o=a?t.directives.tagName(a.source,e=>i(a,`TAG_RESOLVE_FAILED`,e)):null;if(n.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=r,n=e&&a?e.offset>a.offset?e:a:e??a;n&&(!t||t.offset<n.offset)&&i(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let s=n.type===`block-map`?`map`:n.type===`block-seq`?`seq`:n.start.source===`{`?`map`:`seq`;if(!a||!o||o===`!`||o===R.tagName&&s===`map`||o===Vr.tagName&&s===`seq`)return ia(e,t,n,i,o);let c=t.schema.tags.find(e=>e.tag===o&&e.collection===s);if(!c){let r=t.schema.knownTags[o];if(r?.collection===s)t.schema.tags.push(Object.assign({},r,{default:!1})),c=r;else return r?i(a,`BAD_COLLECTION_TYPE`,`${r.tag} used for ${s} collection, but expects ${r.collection??`scalar`}`,!0):i(a,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${o}`,!0),ia(e,t,n,i,o)}let l=ia(e,t,n,i,o,c),u=c.resolve?.(l,e=>i(a,`TAG_RESOLVE_FAILED`,e),t.options)??l,d=P(u)?u:new I(u);return d.range=l.range,d.tag=o,c?.format&&(d.format=c.format),d}function oa(e,t,n){let r=t.offset,i=sa(t,e.options.strict,n);if(!i)return{value:``,type:null,comment:``,range:[r,r,r]};let a=i.mode===`>`?I.BLOCK_FOLDED:I.BLOCK_LITERAL,o=t.source?ca(t.source):[],s=o.length;for(let e=o.length-1;e>=0;--e){let t=o[e][1];if(t===``||t===`\r`)s=e;else break}if(s===0){let e=i.chomp===`+`&&o.length>0?`
50
- `.repeat(Math.max(1,o.length-1)):``,n=r+i.length;return t.source&&(n+=t.source.length),{value:e,type:a,comment:i.comment,range:[r,n,n]}}let c=t.indent+i.indent,l=t.offset+i.length,u=0;for(let t=0;t<s;++t){let[r,a]=o[t];if(a===``||a===`\r`)i.indent===0&&r.length>c&&(c=r.length);else{r.length<c&&n(l+r.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),i.indent===0&&(c=r.length),u=t,c===0&&!e.atRoot&&n(l,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}l+=r.length+a.length+1}for(let e=o.length-1;e>=s;--e)o[e][0].length>c&&(s=e+1);let d=``,f=``,p=!1;for(let e=0;e<u;++e)d+=o[e][0].slice(c)+`
51
- `;for(let e=u;e<s;++e){let[t,r]=o[e];l+=t.length+r.length+1;let s=r[r.length-1]===`\r`;if(s&&(r=r.slice(0,-1)),r&&t.length<c){let e=`Block scalar lines must not be less indented than their ${i.indent?`explicit indentation indicator`:`first line`}`;n(l-r.length-(s?2:1),`BAD_INDENT`,e),t=``}a===I.BLOCK_LITERAL?(d+=f+t.slice(c)+r,f=`
52
- `):t.length>c||r[0]===` `?(f===` `?f=`
53
- `:!p&&f===`
54
- `&&(f=`
55
-
56
- `),d+=f+t.slice(c)+r,f=`
57
- `,p=!0):r===``?f===`
58
- `?d+=`
59
- `:f=`
60
- `:(d+=f+r,f=` `,p=!1)}switch(i.chomp){case`-`:break;case`+`:for(let e=s;e<o.length;++e)d+=`
61
- `+o[e][0].slice(c);d[d.length-1]!==`
62
- `&&(d+=`
63
- `);break;default:d+=`
64
- `}let m=r+i.length+t.source.length;return{value:d,type:a,comment:i.comment,range:[r,m,m]}}function sa({offset:e,props:t},n,r){if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function ca(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}function la(e,t,n){let{offset:r,type:i,source:a,end:o}=e,s,c,l=(e,t,i)=>n(r+e,t,i);switch(i){case`scalar`:s=I.PLAIN,c=ua(a,l);break;case`single-quoted-scalar`:s=I.QUOTE_SINGLE,c=da(a,l);break;case`double-quoted-scalar`:s=I.QUOTE_DOUBLE,c=pa(a,l);break;default:return n(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${i}`),{value:``,type:null,comment:``,range:[r,r+a.length,r+a.length]}}let u=r+a.length,d=ea(o,u,t,n);return{value:c,type:s,comment:d.comment,range:[r,u,d.offset]}}function ua(e,t){let n=``;switch(e[0]){case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),fa(e)}function da(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),fa(e.slice(1,-1)).replace(/''/g,`'`)}function fa(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
65
- `?a+=o:o=`
66
- `:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function pa(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
67
- `){if(i===`
68
- `){let{fold:t,offset:i}=ma(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=ha[i];if(a)n+=a;else if(i===`
69
- `)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
70
- `)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=ga(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
71
- `&&(a!==`\r`||e[r+2]!==`
72
- `)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function ma(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
73
- `||r===`\r`)&&(r!==`\r`||e[t+2]===`
74
- `);)r===`
75
- `&&(n+=`
76
- `),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}var ha={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
77
- `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function ga(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}function _a(e,t,n,r){let{value:i,type:a,comment:o,range:s}=t.type===`block-scalar`?oa(e,t,r):la(t,e.options.strict,r),c=n?e.directives.tagName(n.source,e=>r(n,`TAG_RESOLVE_FAILED`,e)):null,l;l=e.options.stringKeys&&e.atKey?e.schema[Cn]:c?va(e.schema,i,c,n,r):t.type===`scalar`?ya(e,i,t,r):e.schema[Cn];let u;try{let a=l.resolve(i,e=>r(n??t,`TAG_RESOLVE_FAILED`,e),e.options);u=M(a)?a:new I(a)}catch(e){let a=e instanceof Error?e.message:String(e);r(n??t,`TAG_RESOLVE_FAILED`,a),u=new I(i)}return u.range=s,u.source=i,a&&(u.type=a),c&&(u.tag=c),l.format&&(u.format=l.format),o&&(u.comment=o),u}function va(e,t,n,r,i){if(n===`!`)return e[Cn];let a=[];for(let t of e.tags)if(!t.collection&&t.tag===n){if(t.default&&t.test)a.push(t);else return t}for(let e of a)if(e.test?.test(t))return e;let o=e.knownTags[n];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(r,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${n}`,n!==`tag:yaml.org,2002:str`),e[Cn])}function ya({atKey:e,directives:t,schema:n},r,i,a){let o=n.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(r))||n[Cn];if(n.compat){let e=n.compat.find(e=>e.default&&e.test?.test(r))??n[Cn];o.tag!==e.tag&&a(i,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${t.tagString(o.tag)} or ${t.tagString(e.tag)}`,!0)}return o}function ba(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}var xa={composeNode:Sa,composeEmptyNode:Ca};function Sa(e,t,n,r){let i=e.atKey,{spaceBefore:a,comment:o,anchor:s,tag:c}=n,l,u=!0;switch(t.type){case`alias`:l=wa(e,t,r),(s||c)&&r(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:l=_a(e,t,c,r),s&&(l.anchor=s.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{l=aa(xa,e,t,n,r),s&&(l.anchor=s.source.substring(1))}catch(e){r(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:r(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),u=!1}return l??=Ca(e,t.offset,void 0,null,n,r),s&&l.anchor===``&&r(s,`BAD_ALIAS`,`Anchor cannot be an empty string`),i&&e.options.stringKeys&&(!M(l)||typeof l.value!=`string`||l.tag&&l.tag!==`tag:yaml.org,2002:str`)&&r(c??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),a&&(l.spaceBefore=!0),o&&(t.type===`scalar`&&t.source===``?l.comment=o:l.commentBefore=o),e.options.keepSourceTokens&&u&&(l.srcToken=t),l}function Ca(e,t,n,r,{spaceBefore:i,comment:a,anchor:o,tag:s,end:c},l){let u=_a(e,{type:`scalar`,offset:ba(t,n,r),indent:-1,source:``},s,l);return o&&(u.anchor=o.source.substring(1),u.anchor===``&&l(o,`BAD_ALIAS`,`Anchor cannot be an empty string`)),i&&(u.spaceBefore=!0),a&&(u.comment=a,u.range[2]=c),u}function wa({options:e},{offset:t,source:n,end:r},i){let a=new qn(n.substring(1));a.source===``&&i(t,`BAD_ALIAS`,`Alias cannot be an empty string`),a.source.endsWith(`:`)&&i(t+n.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let o=t+n.length,s=ea(r,o,e.strict,i);return a.range=[t,o,s.offset],s.comment&&(a.comment=s.comment),a}function Ta(e,t,{offset:n,start:r,value:i,end:a},o){let s=new Vi(void 0,Object.assign({_directives:t},e)),c={atKey:!1,atRoot:!0,directives:s.directives,options:s.options,schema:s.schema},l=qi(r,{indicator:`doc-start`,next:i??a?.[0],offset:n,onError:o,parentIndent:0,startOnNewline:!0});l.found&&(s.directives.docStart=!0,i&&(i.type===`block-map`||i.type===`block-seq`)&&!l.hasNewline&&o(l.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),s.contents=i?Sa(c,i,l,o):Ca(c,l.end,r,null,l,o);let u=s.contents.range[2],d=ea(a,u,!1,o);return d.comment&&(s.comment=d.comment),s.range=[n,u,d.offset],s}function Ea(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function Da(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
78
-
79
- `:`
80
- `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}var Oa=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let i=Ea(e);r?this.warnings.push(new Gi(i,t,n)):this.errors.push(new Wi(i,t,n))},this.directives=new Bn({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=Da(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(N(i)&&!i.flow&&i.items.length>0){let e=i.items[0];j(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Da(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=Ea(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=Ta(this.options,this.directives,e,this.onError);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;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new Wi(Ea(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new Wi(Ea(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=ea(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new Wi(Ea(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=new Vi(void 0,Object.assign({_directives:this.directives},this.options));this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),e.range=[0,t,t],this.decorate(e,!1),yield e}}},ka=Symbol(`break visit`),Aa=Symbol(`skip children`),ja=Symbol(`remove item`);function Ma(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),Na(Object.freeze([]),e,t)}Ma.BREAK=ka,Ma.SKIP=Aa,Ma.REMOVE=ja,Ma.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},Ma.parentCollection=(e,t)=>{let n=Ma.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],i=n?.[r];if(i&&`items`in i)return i;throw Error(`Parent collection not found`)};function Na(e,t,n){let r=n(t,e);if(typeof r==`symbol`)return r;for(let i of[`key`,`value`]){let a=t[i];if(a&&`items`in a){for(let t=0;t<a.items.length;++t){let r=Na(Object.freeze(e.concat([[i,t]])),a.items[t],n);if(typeof r==`number`)t=r-1;else if(r===ka)return ka;else r===ja&&(a.items.splice(t,1),--t)}typeof r==`function`&&i===`key`&&(r=r(t,e))}}return typeof r==`function`?r(t,e):r}function Pa(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
81
- `:case`\r
82
- `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}function Fa(e){switch(e){case void 0:case` `:case`
83
- `:case`\r`:case` `:return!0;default:return!1}}var Ia=new Set(`0123456789ABCDEFabcdef`),La=new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),Ra=new Set(`,[]{}`),za=new Set(` ,[]{}
84
- \r `),Ba=e=>!e||za.has(e),Va=class{constructor(){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}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
85
- `||t===`\r`&&this.buffer[e+1]===`
86
- `}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
87
- `||!t&&!this.atEnd)return e+n+1}return t===`
88
- `||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&Fa(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
89
- `,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===``&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield``,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&Fa(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Fa(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&Fa(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(Ba),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,n=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=n=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);let r=this.getLine();if(r===null)return this.setNext(`flow`);if((n!==-1&&n<this.indentNext&&r[0]!==`#`||n===0&&(r.startsWith(`---`)||r.startsWith(`...`))&&Fa(r[3]))&&(n!==this.indentNext-1||this.flowLevel!==1||r[0]!==`]`&&r[0]!==`}`))return this.flowLevel=0,yield``,yield*this.parseLineStart();let i=0;for(;r[i]===`,`;)i+=yield*this.pushCount(1),i+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(i+=yield*this.pushIndicators(),r[i]){case void 0:return`flow`;case`#`:return yield*this.pushCount(r.length-i),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(Ba),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||Fa(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
90
- `,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
91
- `,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>Fa(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,t=0,n;loop:for(let r=this.pos;n=this.buffer[r];++r)switch(n){case` `:t+=1;break;case`
92
- `:e=r,t=0;break;case`\r`:{let e=this.buffer[r+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
93
- `)break}default:break loop}if(!n&&!this.atEnd)return this.setNext(`block-scalar`);if(t>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?t:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
94
- `,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let r=e+1;for(n=this.buffer[r];n===` `;)n=this.buffer[++r];if(n===` `){for(;n===` `||n===` `||n===`\r`||n===`
95
- `;)n=this.buffer[++r];e=r-1}else if(!this.blockScalarKeep)do{let n=e-1,r=this.buffer[n];r===`\r`&&(r=this.buffer[--n]);let i=n;for(;r===` `;)r=this.buffer[--n];if(r===`
96
- `&&n>=this.pos&&n+1+t>i)e=n;else break}while(1);return yield``,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,t=this.pos-1,n=this.pos-1,r;for(;r=this.buffer[++n];)if(r===`:`){let r=this.buffer[n+1];if(Fa(r)||e&&Ra.has(r))break;t=n}else if(Fa(r)){let i=this.buffer[n+1];if(r===`\r`&&(i===`
97
- `?(n+=1,r=`
98
- `,i=this.buffer[n+1]):t=n),i===`#`||e&&Ra.has(i))break;if(r===`
99
- `){let e=this.continueScalar(n+1);if(e===-1)break;n=Math.max(n,e-2)}}else{if(e&&Ra.has(r))break;t=n}return!r&&!this.atEnd?this.setNext(`plain-scalar`):(yield``,yield*this.pushToIndex(t+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(Ba),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,n=this.charAt(1);if(Fa(n)||t&&Ra.has(n)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!Fa(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(La.has(t))t=this.buffer[++e];else if(t===`%`&&Ia.has(this.buffer[e+1])&&Ia.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
100
- `?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
101
- `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}},Ha=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}};function Ua(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function Wa(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function Ga(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function Ka(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;default:return[]}}function qa(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function Ja(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function Ya(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!Ua(t.start,`explicit-key-ind`)&&!Ua(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,Ga(t.value)?t.value.end?Ja(t.value.end,t.sep):t.value.end=t.sep:Ja(t.start,t.sep),delete t.sep)}var Xa=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new Va,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let t=Pa(e);if(!t){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(t===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=t,yield*this.step(),t){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source})}else{if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}yield*this.pop()}}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&Ya(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&Wa(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:Wa(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=qa(Ka(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
102
- `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
103
- `,e)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ja(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,i=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(i=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(i.push(this.sourceToken),e.items.push({start:i}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(i.push(this.sourceToken),e.items.push({start:i,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(Ua(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=qa(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ua(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]});else if(Ga(t.key)&&!Ua(t.sep,`newline`)){let e=qa(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else i.length>0?t.sep=t.sep.concat(i,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:i,key:null,sep:[this.sourceToken]}):Ua(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:i,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!Ua(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:i});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){Ja(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||Ua(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!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]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=qa(Ka(t));Ya(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
104
- `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
105
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=qa(Ka(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=qa(Ka(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}};function Za(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Ha||null,prettyErrors:t}}function Qa(e,t={}){let{lineCounter:n,prettyErrors:r}=Za(t),i=new Xa(n?.addNewLine),a=new Oa(t),o=null;for(let t of a.compose(i.parse(e),!0,e.length))if(!o)o=t;else if(o.options.logLevel!==`silent`){o.errors.push(new Wi(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return r&&n&&(o.errors.forEach(Ki(e,n)),o.warnings.forEach(Ki(e,n))),o}function $a(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let i=Qa(e,n);if(!i)return null;if(i.warnings.forEach(e=>Tr(i.options.logLevel,e)),i.errors.length>0){if(i.options.logLevel!==`silent`)throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:r},n))}function eo(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function to(e,t=`|`){return e.map(e=>Eo(e)).join(t)}function no(e,t){return typeof t==`bigint`?t.toString():t}var ro=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function io(e){return new ro(e)}function ao(e){return e==null}function oo(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function so(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function co(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function lo(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function uo(e){return lo(e._zod.def)??e._zod.def.shape}function fo(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return co(this,t,e),e},enumerable:!0,configurable:!0})}function po(e,t,n){t in e?co(e,t,n):e[t]=n}function mo(e,t,n,r){let i=uo(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?fo(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):po(e,a,r?r(n.value,a):n.value))}}function ho(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?fo(e,n,()=>t[n]):po(e,n,r.value))}}function B(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function go(e){return JSON.stringify(e)}function _o(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var vo=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function yo(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var bo=io(()=>{if(hs.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function xo(e){if(yo(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return yo(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function So(e){return xo(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Co=new Set([`string`,`number`,`symbol`]);function wo(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function To(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function V(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function Eo(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function Do(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var Oo={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ko={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function Ao(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return mo(i,e,jo(e,t)),To(e,B(n,{shape:i,checks:[]}))}function jo(e,t){let n=uo(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function Mo(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(jo(e,t)),a={};return mo(a,e,Reflect.ownKeys(uo(e)).filter(e=>!i.has(e))),To(e,B(n,{shape:a,checks:[]}))}function No(e,t){if(!xo(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=uo(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return To(e,B(e._zod.def,{shape:Po(e,t)}))}function Po(e,t){let n={};return mo(n,e,Reflect.ownKeys(uo(e))),ho(n,t),n}function Fo(e,t){if(!xo(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return To(e,B(e._zod.def,{shape:Po(e,t)}))}function Io(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return mo(n,e,Reflect.ownKeys(uo(e))),mo(n,t,Reflect.ownKeys(uo(t))),To(e,B(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function Lo(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(jo(t,n)):void 0,o={};return mo(o,t,Reflect.ownKeys(uo(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),To(t,B(t._zod.def,{shape:o,checks:[]}))}function Ro(e,t,n){let r=n?new Set(jo(t,n)):void 0,i={};return mo(i,t,Reflect.ownKeys(uo(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),To(t,B(t._zod.def,{shape:i}))}function zo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function Bo(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function Vo(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function Ho(e){return typeof e==`string`?e:e?.message}function Uo(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function Wo(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function Go(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:Ho(e.inst?._zod.def?.error?.(e))??Ho(a?.(e))??Ho(t?.error?.(e))??Ho(n.customError?.(e))??Ho(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var Ko=/[\uD800-\uDBFF]/;function qo(e){let t=e.length;if(!Ko.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function Jo(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Yo(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Xo(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Zo(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):ts(e,n,r.value)}}function Qo(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function $o(e,t,n){return Qo(e,t,n,!1)}function es(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Qo(this,n,r(this))},set(e){Qo(this,n,e)}})}return t}function ts(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Qo(this,t,n.bind(this))},set(e){Qo(this,t,e)}})}function ns(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var rs,is=!1,as={configurable:!0,get(){is=!0}};function H(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&rs!==e._zod?rs=void 0:(rs=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,as);let e=is;is=!1;try{let r=n(this);return is?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),is||=e,r}catch(n){throw delete this[t],is||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function os(e,t,n,r){let i=ns(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var ss=`~constantCatch`;function cs(e){let t=()=>e;return t[ss]=!0,t}var ls,us={value:void 0,enumerable:!1},ds=`captureStackTrace`in Error?Error:null;function fs(e){let t=ds;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return ds=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function U(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){us.value=new a(r);try{Object.defineProperty(n,"_zod",us)}finally{us.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Zo(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?fs(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var ps=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},ms=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(ls=globalThis).__zod_globalConfig??(ls.__zod_globalConfig={});var hs=globalThis.__zod_globalConfig;function gs(e){return e&&Object.assign(hs,e),hs}function _s(){let e=this._zod;return e.message??=JSON.stringify(e.def,no,2),e.message}function vs(e){this._zod.message=e}var ys={get:_s,set:vs,enumerable:!0,configurable:!0},bs={value:void 0,enumerable:!1},xs=new WeakSet([Object.prototype,Error.prototype]),Ss=U(`$ZodError`,(e,t)=>{e.name=`$ZodError`,bs.value=t,Object.defineProperty(e,"issues",bs),bs.value=void 0,Object.defineProperty(e,"message",ys);let n=Object.getPrototypeOf(e);xs.has(n)||(xs.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function Cs(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function ws(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?Cs(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ts(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function Es(e,t){return{callee:t?.callee??e,Err:t?.Err}}var Ds=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new ps;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Go(e,o,gs())));throw vo(n,a?.callee??t),n}return s.value};return t},Os=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>Go(e,o,gs())));throw vo(n,a?.callee??t),n}return s.value};return t},ks=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new ps;return a.issues.length?As(e,a.issues,i):{success:!0,data:a.value}};function As(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>Go(e,n,gs()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var js=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?As(e,a.issues,i):{success:!0,data:a.value}},Ms=Symbol.for(`zod.compile.invalid`),Ns=Symbol.for(`zod.compile.fallback`),Ps=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==Ms)return!0;if(r.definite===!0&&n===void 0)return!1}return Fs(e,t,n)});function Fs(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[Ns]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new ps;return a.issues.length===0}var Is=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},Ls=e=>{let t=Ds(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,Es(n,a))};return n},Rs=e=>{let t=Ds(e),n=(e,r,i,a)=>t(e,r,i,Es(n,a));return n},zs=e=>{let t=Os(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,Es(n,a))};return n},Bs=e=>{let t=Os(e),n=async(e,r,i,a)=>await t(e,r,i,Es(n,a));return n},Vs=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ks(e)(t,n,i)},Hs=e=>(t,n,r)=>ks(e)(t,n,r),Us=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return js(e)(t,n,i)},Ws=e=>async(t,n,r)=>js(e)(t,n,r),Gs=/^[cC][0-9a-z]{6,}$/,Ks=/^[0-9a-z]+$/,qs=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Js=/^[0-9a-vA-V]{20}$/,Ys=/^[A-Za-z0-9]{27}$/,Xs=/^[a-zA-Z0-9_-]{21}$/;function Zs(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var Qs=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,$s=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,ec=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,tc=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,nc=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function rc(){return new RegExp(nc,`u`)}var ic=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,ac=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,oc=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,sc=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,cc=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,lc=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,uc=/^https?$/,dc=/^\+[1-9]\d{6,14}$/,fc=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function pc(e){return RegExp(`^${e}$`)}var mc=pc(fc);function hc(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function gc(e){return RegExp(`^${hc(e)}$`)}function _c(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${hc({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${hc({precision:e.precision})}`:n;return RegExp(`^${fc}T(?:${r})$`)}var vc=/^[\s\S]{0,}$/,yc=/^-?\d+(?:\.\d+)?$/,bc=/^(?:true|false)$/i,xc=/^[^A-Z]*$/,Sc=/^[^a-z]*$/,W=U(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Cc=e=>{let t=e.value;return!ao(t)&&t.length!==void 0},wc={number:`number`,bigint:`bigint`,object:`date`},Tc=U(`$ZodCheckLessThan`,(e,t)=>{W.init(e,t);let n=wc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:wc[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Ec=U(`$ZodCheckGreaterThan`,(e,t)=>{W.init(e,t);let n=wc[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:wc[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Dc=U(`$ZodCheckMultipleOf`,(e,t)=>{W.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):so(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),Oc=U(`$ZodCheckNumberFormat`,(e,t)=>{W.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=Oo[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),kc=U(`$ZodCheckMaxLength`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=Cc),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?qo(r):i)<=t.maximum)return;let a=Jo(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ac=U(`$ZodCheckMinLength`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=Cc),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?qo(r):i)>=t.minimum)return;let a=Jo(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),jc=U(`$ZodCheckLengthEquals`,(e,t)=>{var n;W.init(e,t),(n=e._zod.def).when??(n.when=Cc),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?qo(r):i;if(a===t.length)return;let o=Jo(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Mc=U(`$ZodCheckStringFormat`,(e,t)=>{var n,r;W.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Nc=U(`$ZodCheckRegex`,(e,t)=>{Mc.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Pc=U(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=xc,Mc.init(e,t)}),Fc=U(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=Sc,Mc.init(e,t)}),Ic=U(`$ZodCheckIncludes`,(e,t)=>{W.init(e,t);let n=wo(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),Lc=U(`$ZodCheckStartsWith`,(e,t)=>{W.init(e,t);let n=RegExp(`^${wo(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Rc=U(`$ZodCheckEndsWith`,(e,t)=>{W.init(e,t);let n=RegExp(`.*${wo(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),zc=U(`$ZodCheckOverwrite`,(e,t)=>{W.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Bc=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
106
- `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
107
- `)}\n};`)(...Object.values(this.closed))}},Vc={major:4,minor:6,patch:7},G=U(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Vc;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=zo(t),a;for(let o of n){if(o._zod.def.when){if(Bo(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new ps;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(Wo(t.issues,n,e),i||=zo(t,n))});else{if(t.issues.length===n)continue;Wo(t.issues,n,e),i||=zo(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(zo(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new ps;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new ps;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return $o(this,`~standard`,Wc(this))},set"~standard"(e){Qo(this,`~standard`,e)}}),Hc=(e,t)=>e.issues.length?{issues:e.issues.map(e=>Go(e,t,gs()))}:{value:e.value};async function Uc(e,t){let n={async:!0};return Hc(await e._zod.run({value:t,issues:[]},n),n)}function Wc(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Hc(r,n)}catch{}return Uc(e,t)},vendor:`zod`,version:1}}var Gc=U(`$ZodString`,(e,t)=>{G.init(e,t),e._zod.pattern=t.pattern??vc,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),K=U(`$ZodStringFormat`,(e,t)=>{Mc.init(e,t),Gc.init(e,t)}),Kc=U(`$ZodGUID`,(e,t)=>{t.pattern??=$s,K.init(e,t)}),qc=U(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=ec(e)}else t.pattern??=ec();K.init(e,t)}),Jc=U(`$ZodEmail`,(e,t)=>{t.pattern??=tc,K.init(e,t)});function Yc(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function Xc(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Yc(e)||2:Zc(e,t)}function Zc(e,t){if(!t.normalize&&t.protocol?.source===uc.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Qc=/[\t\n\r]/g;function $c(e){return e.replace(Qc,``)}function el(e,t){return t.lastIndex=0,t.test(e.hostname)}function tl(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var nl=U(`$ZodURL`,(e,t)=>{K.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=Xc(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=$c(r);return}t.hostname&&!el(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!tl(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:$c(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),rl=U(`$ZodEmoji`,(e,t)=>{t.pattern??=rc(),K.init(e,t)}),il=U(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Xs:Zs(t.length),K.init(e,t)}),al=U(`$ZodCUID`,(e,t)=>{t.pattern??=Gs,K.init(e,t)}),ol=U(`$ZodCUID2`,(e,t)=>{t.pattern??=Ks,K.init(e,t)}),sl=U(`$ZodULID`,(e,t)=>{t.pattern??=qs,K.init(e,t)}),cl=U(`$ZodXID`,(e,t)=>{t.pattern??=Js,K.init(e,t)}),ll=U(`$ZodKSUID`,(e,t)=>{t.pattern??=Ys,K.init(e,t)}),ul=U(`$ZodISODateTime`,(e,t)=>{t.pattern??=_c(t),K.init(e,t)}),dl=U(`$ZodISODate`,(e,t)=>{t.pattern??=mc,K.init(e,t)}),fl=U(`$ZodISOTime`,(e,t)=>{t.pattern??=gc(t),K.init(e,t)}),pl=U(`$ZodISODuration`,(e,t)=>{t.pattern??=Qs,K.init(e,t)}),ml=U(`$ZodIPv4`,(e,t)=>{t.pattern??=ic,K.init(e,t)}),hl=/^[0-9a-fA-F:.]+$/;function gl(e){return hl.test(e)?Yc(`http://[${e}]`):!1}var _l=U(`$ZodIPv6`,(e,t)=>{t.pattern??=ac,K.init(e,t),e._zod.check=n=>{gl(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),vl=U(`$ZodCIDRv4`,(e,t)=>{t.pattern??=oc,K.init(e,t)});function yl(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:gl(n)}var bl=U(`$ZodCIDRv6`,(e,t)=>{t.pattern??=sc,K.init(e,t),e._zod.check=n=>{yl(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function xl(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var Sl=/^[0-9a-zA-Z+/]*={0,2}$/,Cl=U(`$ZodBase64`,(e,t)=>{t.pattern??=Sl,K.init(e,t),e._zod.check=n=>{xl(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),wl=/^[A-Za-z0-9_-]*$/;function Tl(e){if(!wl.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return xl(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var El=U(`$ZodBase64URL`,(e,t)=>{t.pattern??=wl,K.init(e,t),e._zod.check=n=>{Tl(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),Dl=U(`$ZodE164`,(e,t)=>{t.pattern??=dc,K.init(e,t)});function Ol(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var kl=U(`$ZodJWT`,(e,t)=>{K.init(e,t),e._zod.check=n=>{Ol(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),Al=U(`$ZodNumber`,(e,t)=>{G.init(e,t),e._zod.pattern=yc,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),jl=U(`$ZodNumberFormat`,(e,t)=>{Oc.init(e,t),Al.init(e,t)}),Ml=U(`$ZodBoolean`,(e,t)=>{G.init(e,t),e._zod.pattern=bc,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),Nl=U(`$ZodUnknown`,(e,t)=>{G.init(e,t),e._zod.parse=e=>e}),Pl=U(`$ZodNever`,(e,t)=>{G.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function Fl(e,t){let n=Uo(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of Uo(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,Wo(n.issues,t,e),n}}return i(n,a)}}var Il=e=>Array.isArray(e)?e.length:-1;function Ll(e,t,n){e.issues.length&&t.issues.push(...Vo(n,e.issues)),t.value[n]=e.value}var Rl=U(`$ZodArray`,(e,t)=>{G.init(e,t);let n=hs.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>Ll(t,r,e)));else if(Ll(c,r,e),s&&c.issues.length!==0&&zo(c))break}return o.length?Promise.all(o).then(()=>r):r},Fl(e,Il)});function zl(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(...Vo(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var Bl=[];function Vl(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:Bl,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=Do(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Hl(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(zo(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>zl(e,n,i,t,d,f))):zl(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var Ul=U(`$ZodObject`,(e,t)=>{G.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=io(()=>Vl(t));H(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||co(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=yo,o=t.catchall,s,c=hs.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(zo(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>zl(n,t,e,r,a,o))):zl(s,t,e,r,a,o)}return o?Hl(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Wl=U(`$ZodObjectJIT`,(e,t)=>{Ul.init(e,t);let n=e._zod.parse,r=io(()=>Vl(t)),i=hs.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new Bc([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
108
- let ${e}_ab = false;
109
- for (let i = 0; i < ${e}.issues.length; i++) {
110
- const iss = ${e}.issues[i];
111
- iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
112
- payload.issues.push(iss);
113
- if (iss.continue !== true) ${e}_ab = true;
114
- }
115
- if (${e}_ab && ctx && ctx.abortEarly) {
116
- payload.value = newResult;
117
- return payload;
118
- }`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:go(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
119
- const ${n}_present = ${i};
120
- if (!${n}.issues.length || ${n}_present) {
121
- if (${n}.issues.length) {${c(n,r)}
122
- }
123
-
124
- if (${e}) {
125
- newResult[${r}] = ${n}.value;
126
- }
127
- }
128
-
129
- `)}else f?(o.write(`
130
- if (${n}.issues.length) {${c(n,r)}
131
- }
132
- `),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
133
- if (${n}.value !== undefined || ${i}) {
134
- newResult[${r}] = ${n}.value;
135
- }
136
- `)):o.write(`
137
- const ${n}_present = ${i};
138
- if (${n}.issues.length) {${c(n,r)}
139
- }
140
- if (!${n}_present && !${n}.issues.length) {
141
- payload.issues.push({
142
- code: "invalid_type",
143
- expected: "nonoptional",
144
- input: undefined,
145
- path: [${r}]
146
- });
147
- if (ctx && ctx.abortEarly) {
148
- payload.value = newResult;
149
- return payload;
150
- }
151
- }
152
-
153
- if (${n}_present) {
154
- newResult[${r}] = ${n}.value;
155
- }
156
-
157
- `)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=yo,c=!hs.jitless,l=c&&bo.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Hl([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Gl(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!zo(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>Go(e,r,gs())))}),t)}var Kl=U(`$ZodUnion`,(e,t)=>{G.init(e,t),H(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),H(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),H(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),H(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>oo(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Gl(t,r,e,i)):Gl(o,r,e,i)}}),ql=U(`$ZodIntersection`,(e,t)=>{G.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Yl(e,t,n)):Yl(e,i,a)}});function Jl(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(xo(e)&&xo(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=Jl(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Jl(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Yl(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=Jl(t.value,n.value);if(!c.valid){if(zo(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var Xl=U(`$ZodTuple`,(e,t)=>{G.init(e,t);let n=t.items,r=hs.memoizer;r?.attach(e),e._zod.parse=(i,a)=>{let o=i.value;if(!Array.isArray(o))return i.issues.push({input:o,inst:e,expected:`tuple`,code:`invalid_type`}),i;i.value=r?r.alloc(e,i,[],a):[];let s=[],c=Zl(n,`optin`),l=Zl(n,`optout`);if(!t.rest){if(o.length<c)return i.issues.push({code:`too_small`,minimum:c,inclusive:!0,input:o,inst:e,origin:`array`}),i;o.length>n.length&&i.issues.push({code:`too_big`,maximum:n.length,inclusive:!0,input:o,inst:e,origin:`array`})}let u=Array(n.length),d=t.rest?a?.abortEarly:void 0,f=!1;for(let e=0;e<n.length;e++){let t=n[e]._zod.run({value:o[e],issues:[]},a);t instanceof Promise?s.push(t.then(t=>{u[e]=t})):(u[e]=t,d&&!f&&t.issues.length&&(f=zo(t)))}if(t.rest&&!f){let e=n.length-1,r=o.slice(n.length),c=i.issues.length;for(let n of r){if(d&&i.issues.length!==c){if(zo(i,c))break;c=i.issues.length}e++;let r=t.rest._zod.run({value:n,issues:[]},a);r instanceof Promise?s.push(r.then(t=>Ql(t,i,e))):Ql(r,i,e)}}return s.length?Promise.all(s).then(()=>$l(u,i,n,o,l)):$l(u,i,n,o,l)}});function Zl(e,t){for(let n=e.length-1;n>=0;n--)if(!(t===`optin`?e[n]._zod.optin!==void 0:e[n]._zod.optout===`optional`))return n+1;return 0}function Ql(e,t,n){e.issues.length&&t.issues.push(...Vo(n,e.issues)),t.value[n]=e.value}function $l(e,t,n,r,i){for(let a=0;a<n.length;a++){let o=e[a],s=a<r.length;if(!s&&a>=i&&n[a]._zod.optin===`optional`){t.value.length=a;break}if(o.issues.length){if(!s&&a>=i){t.value.length=a;break}t.issues.push(...Vo(a,o.issues))}t.value[a]=o.value}for(let e=t.value.length-1;e>=r.length&&n[e]._zod.optout===`optional`&&t.value[e]===void 0;e--)t.value.length=e;return t}var eu=U(`$ZodEnum`,(e,t)=>{G.init(e,t);let n=eo(t.entries),r=new Set(n);e._zod.values=r,H(e,`pattern`,e=>{let t=eo(e.def.entries).filter(e=>Co.has(typeof e));return RegExp(t.length?`^(${t.map(e=>wo(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),tu=U(`$ZodTransform`,(e,t)=>{G.init(e,t),e._zod.optin=`optional`,hs.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ms(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new ps;return n.value=i,n}});function nu(e,t){return e.value=t.issues.length?void 0:t.value,e}var ru=U(`$ZodOptional`,(e,t)=>{G.init(e,t),H(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,H(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),H(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${oo(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>nu(e,t)):nu(e,r)}return t.innerType._zod.run(e,n)}}),iu=U(`$ZodExactOptional`,(e,t)=>{ru.init(e,t),H(e,`values`,e=>e.def.innerType._zod.values),H(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),au=U(`$ZodNullable`,(e,t)=>{G.init(e,t),H(e,`optin`,e=>e.def.innerType._zod.optin),H(e,`optout`,e=>e.def.innerType._zod.optout),H(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${oo(t.source)}|null)$`):void 0}),H(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),ou=U(`$ZodDefault`,(e,t)=>{G.init(e,t),e._zod.optin=`defaulted`,H(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>su(e,t)):su(r,t)}});function su(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var cu=U(`$ZodPrefault`,(e,t)=>{G.init(e,t),e._zod.optin=`defaulted`,H(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),lu=U(`$ZodNonOptional`,(e,t)=>{G.init(e,t),H(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>uu(t,e)):uu(i,e)}});function uu(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function du(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>Go(e,r,gs()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var fu=U(`$ZodCatch`,(e,t)=>{G.init(e,t),H(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),H(e,`optout`,e=>e.def.innerType._zod.optout),H(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>du(e,r,t,n)):du(e,r,t,n)}}),pu=U(`$ZodPipe`,(e,t)=>{G.init(e,t),H(e,`values`,e=>e.def.in._zod.values),H(e,`optin`,e=>e.def.in._zod.optin),H(e,`optout`,e=>e.def.out._zod.optout),H(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>mu(e,t.in,n)):mu(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>mu(e,t.out,n)):mu(r,t.out,n)}});function mu(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var hu=U(`$ZodReadonly`,(e,t)=>{G.init(e,t),H(e,`propValues`,e=>e.def.innerType._zod.propValues),H(e,`values`,e=>e.def.innerType._zod.values),H(e,`optin`,e=>e.def.innerType?._zod?.optin),H(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(gu):gu(r)}});function gu(e){return e.memo||(e.value=Object.freeze(e.value)),e}var _u=U(`$ZodCustom`,(e,t)=>{W.init(e,t),G.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>vu(t,n,r,e));vu(i,n,r,e)}});function vu(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Xo(e))}}var yu=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},bu=`~memo`,xu=[];function Su(e){return typeof e==`object`&&!!e}function Cu(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var wu=new WeakMap,Tu=0,Eu=1,Du=2;function Ou(e,t,n){let r=wu.get(e);if(r!==void 0)return r?Du:Tu;if(t.has(e))return Du;t.add(e);let i=Tu,a=e=>{if(i!==Du&&e?._zod){let r=Ou(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=Tu;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?Eu:o.value?._zod?Ou(o.value,t,n):Tu;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=lo(c);s(e?o(e,!0):Eu),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?Ou(r,t,!1):Eu);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),ku(e,i)}function ku(e,t){return t!==Eu&&wu.set(e,t===Du),t}function Au(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var ju,Mu=[],Nu={alloc(e,t,n){let r=ju;if(!r)return n;ju=void 0;let i={value:n,issues:null};return r.set(t.value,i),Mu.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&Fu(n,e.value))throw new yu;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=Ou(e,new Set,!1);if(i===Tu)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===Du||r?n=!0:r=!0}let l=s.value;if(!Su(l))return t(s,c);let u=c[bu];u||(u={buckets:new WeakMap,backEdges:void 0},c[bu]=u);let d;i===c?d=a:(d=Au(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...Cu(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;ju=d;let p=Mu.length,m=t(s,c);ju=void 0;let h=Mu.length>p?Mu.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?Cu(e.issues):xu),e)):(h&&(h.issues=m.issues.length?Cu(m.issues):xu),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function Pu(){return Nu}function Fu(e,t){let n=e[bu]?.backEdges;return n!==void 0&&Su(t)&&n.has(t)}var Iu=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Yo(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${Eo(e.values[0])}`:`Invalid option: expected one of ${to(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${to(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function Lu(){return{localeError:Iu()}}var Ru,zu=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Bu(){return new zu}(Ru=globalThis).__zod_globalRegistry??(Ru.__zod_globalRegistry=Bu());var Vu=globalThis.__zod_globalRegistry;function Hu(e){return e.checks&&=[...e.checks],e}function Uu(e,t){return new e(Hu({type:`string`,...V(t)}))}function Wu(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...V(t)})}function Gu(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...V(t)})}function Ku(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...V(t)})}function qu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...V(t)})}function Ju(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...V(t)})}function Yu(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...V(t)})}function Xu(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...V(t)})}function Zu(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...V(t)})}function Qu(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...V(t)})}function $u(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...V(t)})}function ed(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...V(t)})}function td(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...V(t)})}function nd(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...V(t)})}function rd(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...V(t)})}function id(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...V(t)})}function ad(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...V(t)})}function od(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...V(t)})}function sd(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...V(t)})}function cd(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...V(t)})}function ld(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...V(t)})}function ud(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...V(t)})}function dd(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...V(t)})}function fd(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...V(t)})}function pd(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...V(t)})}function md(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...V(t)})}function hd(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...V(t)})}function gd(e,t){return new e(Hu({type:`number`,checks:[],...V(t)}))}function _d(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...V(t)})}function vd(e,t){return new e({type:`boolean`,...V(t)})}function yd(e){return new e({type:`unknown`})}function bd(e,t){return new e({type:`never`,...V(t)})}function xd(e,t){return new Tc({check:`less_than`,...V(t),value:e,inclusive:!1})}function Sd(e,t){return new Tc({check:`less_than`,...V(t),value:e,inclusive:!0})}function Cd(e,t){return new Ec({check:`greater_than`,...V(t),value:e,inclusive:!1})}function wd(e,t){return new Ec({check:`greater_than`,...V(t),value:e,inclusive:!0})}function Td(e,t){return new Dc({check:`multiple_of`,...V(t),value:e})}function Ed(e,t){return new kc({check:`max_length`,...V(t),maximum:e})}function Dd(e,t){return new Ac({check:`min_length`,...V(t),minimum:e})}function Od(e,t){return new jc({check:`length_equals`,...V(t),length:e})}function kd(e,t){return new Nc({check:`string_format`,format:`regex`,...V(t),pattern:e})}function Ad(e){return new Pc({check:`string_format`,format:`lowercase`,...V(e)})}function jd(e){return new Fc({check:`string_format`,format:`uppercase`,...V(e)})}function Md(e,t){return new Ic({check:`string_format`,format:`includes`,...V(t),includes:e})}function Nd(e,t){return new Lc({check:`string_format`,format:`starts_with`,...V(t),prefix:e})}function Pd(e,t){return new Rc({check:`string_format`,format:`ends_with`,...V(t),suffix:e})}function Fd(e){return new zc({check:`overwrite`,tx:e})}function Id(e){return Fd(t=>t.normalize(e))}function Ld(){return Fd(e=>e.trim())}function Rd(){return Fd(e=>e.toLowerCase())}function zd(){return Fd(e=>e.toUpperCase())}function Bd(){return Fd(e=>_o(e))}function Vd(e,t,n){return new e({type:`array`,element:t,...V(n)})}function Hd(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...V(n)})}function Ud(e,t){let n=Wd(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Xo(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Xo(r))}},e(t.value,t)),t);return n}function Wd(e,t){let n=new W({check:`custom`,...V(t)});return n._zod.check=e,n}function Gd(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&co(e,t,n[t]);return e}function Kd(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Vu,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function qd(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function q(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,q(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Gd(o.schema,c),t.io===`input`&&J(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Jd(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function Yd(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Jd(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Jd(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
158
-
159
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Xd(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Xd(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var Zd=new Set([`type`,`properties`,`required`,`additionalProperties`]),Qd=[`oneOf`,`anyOf`];function $d(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function ef(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!Zd.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??$d(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}co(n,r,e.length===1?e[0]:ef(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=$d(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function tf(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of Zd)if(t in e)return;let n=t.filter(e=>Qd.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=ef(t);else{let e=n[0],i=Qd.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>ef([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,Gd(e,r))}function nf(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Gd(i,s),Gd(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Xd(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])tf(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Gd(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,co(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:af(t,`input`,e.processors),output:af(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function J(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return J(r.element,n);if(r.type===`set`)return J(r.valueType,n);if(r.type===`lazy`)return J(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return J(r.innerType,n);if(r.type===`intersection`)return J(r.left,n)||J(r.right,n);if(r.type===`record`||r.type===`map`)return J(r.keyType,n)||J(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:J(r.in,n)||J(r.out,n);if(r.type===`object`){for(let e in r.shape)if(J(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(J(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(J(e,n))return!0;return!!(r.rest&&J(r.rest,n))}return!1}var rf=(e,t={})=>n=>{let r=Kd({...n,processors:t});return q(e,r),Yd(r,e),nf(r,e)},af=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Kd({...i??{},target:a,io:t,processors:n});return q(e,o),Yd(o,e),nf(o,e)},of=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},sf=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},cf=(e,t)=>{of(e,`minimum`,t),sf(e,`maximum`,t)},lf=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},uf=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},df=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},ff=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},pf=(e,t)=>of(e,`minimum`,t.minimum),mf=(e,t)=>sf(e,`maximum`,t.maximum),hf=e=>(t,n)=>{ff(t,n.format);let[r,i]=e[n.format];of(t,`minimum`,r),sf(t,`maximum`,i)},gf={greater_than:(e,t)=>of(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>sf(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>lf(e,t.value),number_format:hf(Oo),bigint_format:hf(ko),min_length:pf,max_length:mf,length_equals:(e,t)=>cf(e,t.length),min_size:pf,max_size:mf,size_equals:(e,t)=>cf(e,t.size),string_format:(e,t)=>{ff(e,t.format),t.pattern&&uf(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>df(e,t.mime)};function _f(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)gf[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&of(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&of(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&sf(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&sf(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&lf(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&df(t,i.mime);for(let e of i.patterns??[])uf(t,e);return t}var vf={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},yf=new Map([[Sl,cc],[wl,lc]]),bf=e=>yf.get(e)??e,xf=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=_f(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=vf[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(bf);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},Sf=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=_f(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):qd(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},Cf=(e,t,n,r)=>{n.type=`boolean`},wf=(e,t,n,r)=>{n.not={}},Tf=(e,t,n,r)=>{let i=e._zod.def,a=eo(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},Ef=(e,t,n,r)=>{qd(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},Df=(e,t,n,r)=>{qd(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},Of=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=_f(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=q(a.element,t,{...r,path:[...r.path,`items`]})};function kf(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?kf(t.out):t.type===`catch`?kf(t.innerType):e._zod.optin}var Af=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&qd(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)co(i.properties,e,q(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?kf(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=q(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},jf=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>q(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},Mf=(e,t,n,r)=>{let i=e._zod.def,a=q(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=q(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)},Nf=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`array`;let o=t.target===`draft-2020-12`?`prefixItems`:`items`,s=t.target===`draft-2020-12`||t.target===`openapi-3.0`?`items`:`additionalItems`,c=a.items.map((e,n)=>q(e,t,{...r,path:[...r.path,o,n]})),l=a.rest?q(a.rest,t,{...r,path:[...r.path,s,...t.target===`openapi-3.0`?[a.items.length]:[]]}):null,u=a.items.length;for(;u>0;){let e=a.items[u-1];if(!(t.io===`input`?kf(e)!==void 0:e._zod.optout===`optional`))break;u--}let d=a.items.length,f=!a.rest;t.target===`draft-2020-12`?(i.prefixItems=c,f?i.items=!1:l&&(i.items=l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):t.target===`openapi-3.0`?(i.items={anyOf:c},l&&i.items.anyOf.push(l),u>0&&(i.minItems=u),f&&(i.maxItems=d)):(i.items=c,f?i.additionalItems=!1:l&&(i.additionalItems=l),u>0&&(i.minItems=u),f&&(i.maxItems=d));let{minimum:p,maximum:m}=_f(e);typeof p==`number`&&(i.minItems=p),typeof m==`number`&&(i.maxItems=m)},Pf=(e,t,n,r)=>{let i=e._zod.def,a=q(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},Ff=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},If=Symbol();function Lf(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(qd(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),If):JSON.parse(o)}var Rf=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=Lf(i.defaultValue,e,t,n,r);o!==If&&(n.default=o)},zf=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=Lf(i.defaultValue,e,t,n,r);o!==If&&(n._prefault=o)},Bf=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{qd(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},Vf=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;q(o,t,r);let s=t.seen.get(e);s.ref=o},Hf=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Uf=(e,t,n,r)=>{let i=e._zod.def;q(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Wf=new WeakSet([Object.prototype,Error.prototype]);function Gf(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var Y=U(`ZodError`,(e,t)=>{Ss.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Wf.has(n)||(Wf.add(n),Gf(n,`format`,e=>t=>Ts(e,t)),Gf(n,`flatten`,e=>t=>ws(e,t)),Gf(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,no,2)}),Gf(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,no,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Kf=Ds(Y),qf=Os(Y),Jf=ks(Y),Yf=js(Y),Xf=Ls(Y),Zf=Rs(Y),Qf=zs(Y),$f=Bs(Y),ep=Vs(Y),tp=Hs(Y),np=Us(Y),rp=Ws(Y);function ip(){hs.localeError||gs(Lu())}function ap(){hs.memoizer||gs({memoizer:Pu()})}var X=U(`ZodType`,(e,t)=>(ip(),G.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(B(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return To(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(xm(e,t))},superRefine(e,t){return this.check(Sm(e,t))},overwrite(e){return this.check(Fd(e))},optional(){return rm(this)},exactOptional(){return am(this)},nullable(){return sm(this)},nullish(){return rm(sm(this))},nonoptional(e){return pm(this,e)},array(){return Up(this)},or(e){return qp([this,e])},and(e){return Yp(this,e)},transform(e){return _m(this,tm(e))},default(e){return lm(this,e)},prefault(e){return dm(this,e)},catch(e){return hm(this,e)},pipe(e){return _m(this,e)},readonly(){return ym(this)},describe(e){let t=this.clone();return Vu.add(t,{description:e}),t},meta(...e){if(e.length===0)return Vu.get(this);let t=this.clone();return Vu.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return $o(this,`~standard`,{...Wc(this),jsonSchema:{input:af(this,`input`),output:af(this,`output`)}})},set"~standard"(e){Qo(this,`~standard`,e)},parse:function e(t,n){return Kf(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await qf(this,t,n,{callee:e})},safeParse(e,t){return Jf(this,e,t)},async safeParseAsync(e,t){return Yf(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Qo(this,`spa`,e)},validate(e,t){return Ps(this,e,t)},validateAsync(e,t){return Is(this,e,t)},encode:function e(t,n){return Xf(this,t,n,{callee:e})},decode:function e(t,n){return Zf(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Qf(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await $f(this,t,n,{callee:e})},safeEncode(e,t){return ep(this,e,t)},safeDecode(e,t){return tp(this,e,t)},async safeEncodeAsync(e,t){return np(this,e,t)},async safeDecodeAsync(e,t){return rp(this,e,t)},toJSONSchema(e){return rf(this,{})(e)},get description(){return Vu.get(this)?.description},get _def(){return this._zod.def}}),op=U(`_ZodString`,(e,t)=>{Gc.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xf(e,t,n,r)},es({format:e=>_f(e).format??null,minLength:e=>_f(e).minimum??null,maxLength:e=>_f(e).maximum??null},{regex(...e){return this.check(kd(...e))},includes(...e){return this.check(Md(...e))},startsWith(...e){return this.check(Nd(...e))},endsWith(...e){return this.check(Pd(...e))},min(...e){return this.check(Dd(...e))},max(...e){return this.check(Ed(...e))},length(...e){return this.check(Od(...e))},nonempty(...e){return this.check(Dd(1,...e))},lowercase(e){return this.check(Ad(e))},uppercase(e){return this.check(jd(e))},trim(){return this.check(Ld())},normalize(...e){return this.check(Id(...e))},toLowerCase(){return this.check(Rd())},toUpperCase(){return this.check(zd())},slugify(){return this.check(Bd())}})),sp=U(`ZodString`,(e,t)=>{Gc.init(e,t),op.init(e,t)},{email(e){return this.check(Wu(pp,e))},url(e){return this.check(Xu(gp,e))},jwt(e){return this.check(dd(jp,e))},emoji(e){return this.check(Zu(_p,e))},guid(e){return this.check(Gu(mp,e))},uuid(e){return this.check(Ku(hp,e))},uuidv4(e){return this.check(qu(hp,e))},uuidv6(e){return this.check(Ju(hp,e))},uuidv7(e){return this.check(Yu(hp,e))},nanoid(e){return this.check(Qu(vp,e))},cuid(e){return this.check($u(yp,e))},cuid2(e){return this.check(ed(bp,e))},ulid(e){return this.check(td(xp,e))},base64(e){return this.check(cd(Op,e))},base64url(e){return this.check(ld(kp,e))},xid(e){return this.check(nd(Sp,e))},ksuid(e){return this.check(rd(Cp,e))},ipv4(e){return this.check(id(wp,e))},ipv6(e){return this.check(ad(Tp,e))},cidrv4(e){return this.check(od(Ep,e))},cidrv6(e){return this.check(sd(Dp,e))},e164(e){return this.check(ud(Ap,e))},datetime(e){return this.check(fd(lp,e))},date(e){return this.check(pd(up,e))},time(e){return this.check(md(dp,e))},duration(e){return this.check(hd(fp,e))}});function cp(e){return Uu(sp,e)}var Z=U(`ZodStringFormat`,(e,t)=>{K.init(e,t),op.init(e,t)}),lp=U(`ZodISODateTime`,(e,t)=>{ul.init(e,t),Z.init(e,t)}),up=U(`ZodISODate`,(e,t)=>{dl.init(e,t),Z.init(e,t)}),dp=U(`ZodISOTime`,(e,t)=>{fl.init(e,t),Z.init(e,t)}),fp=U(`ZodISODuration`,(e,t)=>{pl.init(e,t),Z.init(e,t)}),pp=U(`ZodEmail`,(e,t)=>{Jc.init(e,t),Z.init(e,t)}),mp=U(`ZodGUID`,(e,t)=>{Kc.init(e,t),Z.init(e,t)}),hp=U(`ZodUUID`,(e,t)=>{qc.init(e,t),Z.init(e,t)}),gp=U(`ZodURL`,(e,t)=>{nl.init(e,t),Z.init(e,t)}),_p=U(`ZodEmoji`,(e,t)=>{rl.init(e,t),Z.init(e,t)}),vp=U(`ZodNanoID`,(e,t)=>{il.init(e,t),Z.init(e,t)}),yp=U(`ZodCUID`,(e,t)=>{al.init(e,t),Z.init(e,t)}),bp=U(`ZodCUID2`,(e,t)=>{ol.init(e,t),Z.init(e,t)}),xp=U(`ZodULID`,(e,t)=>{sl.init(e,t),Z.init(e,t)}),Sp=U(`ZodXID`,(e,t)=>{cl.init(e,t),Z.init(e,t)}),Cp=U(`ZodKSUID`,(e,t)=>{ll.init(e,t),Z.init(e,t)}),wp=U(`ZodIPv4`,(e,t)=>{ml.init(e,t),Z.init(e,t)}),Tp=U(`ZodIPv6`,(e,t)=>{_l.init(e,t),Z.init(e,t)}),Ep=U(`ZodCIDRv4`,(e,t)=>{vl.init(e,t),Z.init(e,t)}),Dp=U(`ZodCIDRv6`,(e,t)=>{bl.init(e,t),Z.init(e,t)}),Op=U(`ZodBase64`,(e,t)=>{Cl.init(e,t),Z.init(e,t)}),kp=U(`ZodBase64URL`,(e,t)=>{El.init(e,t),Z.init(e,t)}),Ap=U(`ZodE164`,(e,t)=>{Dl.init(e,t),Z.init(e,t)}),jp=U(`ZodJWT`,(e,t)=>{kl.init(e,t),Z.init(e,t)}),Mp=U(`ZodNumber`,(e,t)=>{Al.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sf(e,t,n,r),e.isFinite=!0},es({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=_f(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=_f(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=_f(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>_f(e).format??null},{gt(e,t){return this.check(Cd(e,t))},gte(e,t){return this.check(wd(e,t))},min(e,t){return this.check(wd(e,t))},lt(e,t){return this.check(xd(e,t))},lte(e,t){return this.check(Sd(e,t))},max(e,t){return this.check(Sd(e,t))},int(e){return this.check(Fp(e))},safe(e){return this.check(Fp(e))},positive(e){return this.check(Cd(0,e))},nonnegative(e){return this.check(wd(0,e))},negative(e){return this.check(xd(0,e))},nonpositive(e){return this.check(Sd(0,e))},multipleOf(e,t){return this.check(Td(e,t))},step(e,t){return this.check(Td(e,t))},finite(){return this}}));function Np(e){return gd(Mp,e)}var Pp=U(`ZodNumberFormat`,(e,t)=>{jl.init(e,t),Mp.init(e,t)});function Fp(e){return _d(Pp,e)}var Ip=U(`ZodBoolean`,(e,t)=>{Ml.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cf(e,t,n,r)});function Lp(e){return vd(Ip,e)}var Rp=U(`ZodUnknown`,(e,t)=>{Nl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function zp(){return yd(Rp)}var Bp=U(`ZodNever`,(e,t)=>{Pl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wf(e,t,n,r)});function Vp(e){return bd(Bp,e)}var Hp=U(`ZodArray`,(e,t)=>{ap(),Rl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Of(e,t,n,r),e.element=t.element},{min(e,t){return this.check(Dd(e,t))},nonempty(e){return this.check(Dd(1,e))},max(e,t){return this.check(Ed(e,t))},length(e,t){return this.check(Od(e,t))},unwrap(){return this.element}});function Up(e,t){return Vd(Hp,e,t)}var Wp=U(`ZodObject`,(e,t)=>{ap(),Wl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Af(e,t,n,r),os(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return $p(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(B(this._zod.def,{catchall:e}))},passthrough(){return this.clone(B(this._zod.def,{catchall:zp()}))},loose(){return this.clone(B(this._zod.def,{catchall:zp()}))},strict(){return this.clone(B(this._zod.def,{catchall:Vp()}))},strip(){return this.clone(B(this._zod.def,{catchall:void 0}))},extend(e){return No(this,e)},safeExtend(e){return Fo(this,e)},merge(e){return Io(this,e)},pick(e){return Ao(this,e)},omit(e){return Mo(this,e)},partial(...e){return Lo(nm,this,e[0])},exactPartial(...e){return Lo(im,this,e[0],`exactPartial`)},required(...e){return Ro(fm,this,e[0])}});function Gp(e,t){return new Wp({type:`object`,shape:e??{},...V(t)})}var Kp=U(`ZodUnion`,(e,t)=>{Kl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>jf(e,t,n,r),e.options=t.options});function qp(e,t){return new Kp({type:`union`,options:e,...V(t)})}var Jp=U(`ZodIntersection`,(e,t)=>{ql.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Mf(e,t,n,r)});function Yp(e,t){return new Jp({type:`intersection`,left:e,right:t})}var Xp=U(`ZodTuple`,(e,t)=>{ap(),Xl.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Nf(e,t,n,r)},{rest(e){return this.clone({...this._zod.def,rest:e})},partial(){let e=this._zod.def;if(e.checks?.length)throw Error(`.partial() cannot be used on tuple schemas containing refinements`);return this.clone({...e,items:e.items.map(e=>new nm({type:`optional`,innerType:e}))})}});function Zp(e,t,n){let r=t instanceof G;return new Xp({type:`tuple`,items:e,rest:r?t:null,...V(r?n:t)})}var Qp=U(`ZodEnum`,(e,t)=>{eu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tf(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Qp({...t,checks:[],...V(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Qp({...t,checks:[],...V(r),entries:i})}});function $p(e,t){return new Qp({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...V(t)})}var em=U(`ZodTransform`,(e,t)=>{ap(),tu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Df(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new ms(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Xo(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Xo(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function tm(e){return new em({type:`transform`,transform:e})}var nm=U(`ZodOptional`,(e,t)=>{ru.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function rm(e){return new nm({type:`optional`,innerType:e})}var im=U(`ZodExactOptional`,(e,t)=>{iu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Uf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function am(e){return new im({type:`optional`,innerType:e})}var om=U(`ZodNullable`,(e,t)=>{au.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Pf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function sm(e){return new om({type:`nullable`,innerType:e})}var cm=U(`ZodDefault`,(e,t)=>{ou.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Rf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function lm(e,t){return new cm({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():So(t)}})}var um=U(`ZodPrefault`,(e,t)=>{cu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>zf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function dm(e,t){return new um({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():So(t)}})}var fm=U(`ZodNonOptional`,(e,t)=>{lu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ff(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function pm(e,t){return new fm({type:`nonoptional`,innerType:e,...V(t)})}var mm=U(`ZodCatch`,(e,t)=>{fu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Bf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function hm(e,t){return new mm({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:cs(t)})}var gm=U(`ZodPipe`,(e,t)=>{pu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Vf(e,t,n,r),e.in=t.in,e.out=t.out});function _m(e,t){return new gm({type:`pipe`,in:e,out:t})}var vm=U(`ZodReadonly`,(e,t)=>{hu.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Hf(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ym(e){return new vm({type:`readonly`,innerType:e})}var bm=U(`ZodCustom`,(e,t)=>{_u.init(e,t),X.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Ef(e,t,n,r)});function xm(e,t={}){return Hd(bm,e,t)}function Sm(e,t){return Ud(e,t)}var Cm=.25,wm=Np().finite(),Tm=Np().finite().positive(),Em=Zp([wm,wm]),Dm=Gp({number:cp().regex(/^[1-9][0-9]*$/,`pad numbers are pin numbers: digits, starting at 1`),shape:$p([`rect`,`roundrect`,`circle`,`oval`]),x:wm,y:wm,width:Tm,height:Tm,rotation:wm.optional(),layers:$p([`top`,`through`]).optional(),drill:qp([Tm,Gp({width:Tm,height:Tm}).strict()]).optional()}).strict(),Om=e=>Gp({pads:Up(Dm).min(1),courtyard:Up(e).min(3).optional(),silkscreen:Up(Up(e).min(2)).optional(),body:Up(e).min(3).optional(),placeholder:Lp().optional()}).strict(),km=Om(Em);Om(Up(wm).length(2));function Am(e,t){let n=t=>({error:`${e}: ${t}`}),r;try{r=$a(t)}catch(e){return n(`not valid YAML (${e.message.split(`
160
- `)[0]})`)}let i=km.safeParse(Fm(r));if(!i.success)return n(i.error.issues.map(e=>`${e.path.join(`.`)}: ${e.message}`).join(`; `));let a=jm(i.data);return a.length>0?n(a.join(`; `)):Mm(e,i.data)}function jm(e){let t=[];for(let[n,r]of e.pads.entries()){let e=`pad ${r.number} (entry ${n+1})`,i=r.layers===`through`;i&&r.drill===void 0&&t.push(`${e} is a through pad and needs a drill`),!i&&r.drill!==void 0&&t.push(`${e} is a top pad and must not have a drill`)}return t}function Mm(e,t){let n=t.pads.map(Nm),r=([e,t])=>({x:e,y:t});return{name:e,pads:n,courtyard:t.courtyard?t.courtyard.map(r):Pm(n,Cm),silkscreen:(t.silkscreen??[]).map(e=>e.map(r)),fabrication:t.body?[(e=>[...e,...e[0]?[e[0]]:[]])(t.body.map(r))]:[],origin:`copperflow footprint file ${e}`,...t.placeholder?{placeholder:!0}:{}}}function Nm(e){let t=typeof e.drill==`number`?{width:e.drill,height:e.drill}:e.drill;return{number:e.number,shape:e.shape,x:e.x,y:e.y,width:e.width,height:e.height,rotation:e.rotation??0,layers:e.layers??`top`,...t?{drill:{...t}}:{}}}function Pm(e,t,n=[]){let r=n.map(e=>e.x),i=n.map(e=>e.y);for(let t of e){let e=t.rotation*Math.PI/180,n=(Math.abs(t.width*Math.cos(e))+Math.abs(t.height*Math.sin(e)))/2,a=(Math.abs(t.width*Math.sin(e))+Math.abs(t.height*Math.cos(e)))/2;r.push(t.x-n,t.x+n),i.push(t.y-a,t.y+a)}let a=Math.min(...r)-t,o=Math.max(...r)+t,s=Math.min(...i)-t,c=Math.max(...i)+t;return[{x:a,y:s},{x:o,y:s},{x:o,y:c},{x:a,y:c}]}function Fm(e){if(typeof e!=`object`||!e||!Array.isArray(e.pads))return e;let t=e.pads.map(e=>typeof e==`object`&&e&&Number.isInteger(e.number)?{...e,number:String(e.number)}:e);return{...e,pads:t}}var Im=[`chips 0201 0402 0603 0805 1206 1210 1812 2010 2512`,`sod123 sod323`,`sma smb smc (do214ac do214aa do214ab)`,`sot23 sot23_5 sot23_6 sot223 sot89`,...Mt.map(({form:e,pins:t})=>`${e} (N ${Lm(t)})`),`qfp32 qfp48 qfp64 qfp100, qfp<N>_<b>x<b>_p<pitch> (lqfp, tqfp)`,`qfn16 qfn32 qfn48 with _ep, qfn<N>_<b>x<b>_p<pitch>[_ep<size>]`,`dfn<N>_<a>x<b>_p<pitch>`,`bga<N>_<x>x<y>_p<pitch>`,`dip<N>[_w<spacing>]`,`to220 to92 hc49 hc49s`,`radial<can>x<spacing>`,`pinrow<N>[_p<pitch>] pinrow2x<N>`].join(`; `);function Lm(e){return e.length>2&&e.every((t,n)=>n===0||t-(e[n-1]??0)===2)?`even ${e[0]}–${e[e.length-1]}`:e.join(`, `)}var Rm=[`0201`,`0402`,`0603`,`0805`,`1206`,`1210`,`1812`,`2010`,`2512`],zm=(e,t,n)=>Array.from({length:Math.floor((t-e)/n)+1},(t,r)=>e+r*n),Bm=[...Rm,`sod123`,`sod323`,`sot23`,`sot223`,`sot89`,`do214ac`,`do214aa`,`do214ab`,...Mt.flatMap(({form:e,pins:t})=>t.map(t=>e.replace(`<N>`,String(t)))),...[`qfp`,`lqfp`,`tqfp`].flatMap(e=>[32,48,64,100].map(t=>`${e}${t}`)),...[16,32,48].map(e=>`qfn${e}`),...zm(4,64,2).map(e=>`dip${e}`),`to220`,`to92`,`hc49`,`hc49s`,...zm(1,40,1).map(e=>`pinrow${e}`)],Vm=3,Hm=3,Um=Bm.flatMap(e=>{let t=Et(e);return t?[{text:e,kind:t.kind,number:Number(t.code||0),suffix:t.suffix??``}]:[]});function Wm(e){let t=Et(e);if(!t)return[];let n=Number(t.code||0),r=t.suffix??``,i=e=>(e.suffix===r?0:Hm)+Math.abs(e.number-n);return Um.filter(e=>e.kind===t.kind).sort((e,t)=>i(e)-i(t)||e.number-t.number||e.text.localeCompare(t.text)).slice(0,Vm).sort((e,t)=>e.number-t.number||e.text.localeCompare(t.text)).map(e=>e.text)}function Gm(e){let t=Wm(e);return`copperflow cannot make footprint "${e}":${t.length>0?` nearest are ${t.join(`, `)};`:``} known families are ${Im} (see the skill's parts library reference)`}var Q=(e,t)=>({min:e,max:t}),Km={label:`DO-214AC (SMA)`,span:Q(4.93,5.28),terminal:Q(.76,1.52),leadWidth:Q(1.25,1.65),bodyLength:Q(3.99,4.5),bodyWidth:Q(2.54,2.79)},qm={label:`DO-214AA (SMB)`,span:Q(5.21,5.59),terminal:Q(.76,1.52),leadWidth:Q(1.95,2.2),bodyLength:Q(4.06,4.57),bodyWidth:Q(3.3,3.94)},Jm={label:`DO-214AB (SMC)`,span:Q(7.75,8.13),terminal:Q(.76,1.52),leadWidth:Q(2.9,3.2),bodyLength:Q(6.6,7.11),bodyWidth:Q(5.59,6.22)},Ym=new Map([[`sma`,Km],[`smb`,qm],[`smc`,Jm],[`do214ac`,Km],[`do214aa`,qm],[`do214ab`,Jm]]);function Xm(e){if(!(e.variant!==void 0||e.cross!==void 0||e.size!==void 0||e.pairs!==void 0||Object.keys(e.params).length>0))return`${e.kind}${e.code}${e.suffix??``}`}function Zm(e){if(e.kind===`do`&&e.code===`214`&&!Ym.has(`do214${e.suffix??``}`))return E(`do214 needs a suffix: do214ac, do214aa or do214ab`);let t=Xm(e),n=t===void 0?void 0:Ym.get(t);if(!t||!n)return;let r=ie(o({span:n.span,terminal:n.terminal,width:n.leadWidth},g.goals,c),g.roundOff),i={x:n.bodyLength.max/2,y:n.bodyWidth.max/2};return{name:t,pads:r,courtyard:T(r,{x:n.span.max/2,y:Math.max(n.bodyWidth.max,n.leadWidth.max)/2},g),silkscreen:[...he(r,i),ge(r,i)],fabrication:pe(i),origin:`IPC-7351B nominal, ${n.label}`}}var Qm=1,$m=1.7,eh=.25,th=1e3,nh=e=>String(C(e));function rh(e,t){return`pinrow${e}_p${nh(t)}mm`}function ih(e,t,n=0){return{number:String(e),shape:e===1?`rect`:`circle`,x:t,y:n,width:$m,height:$m,rotation:0,layers:`through`,drill:{width:Qm,height:Qm}}}function ah(e){if(e.kind!==`pinrow`||e.variant!==void 0||Object.keys(e.params).some(e=>e!==`p`))return;let t=e.params.p??2.54;if(t===!0||t<=$m)return;if(e.cross!==void 0)return lh(e,t);if(!Dt(e))return;let n=Number(e.code);if(!Number.isInteger(n)||n<1||n>th)return;let r=se(n,t).map((e,t)=>ih(t+1,e));return{name:rh(n,t),...oh(r),origin:`Fixed pin row, not an IPC-7351B calculation: ${nh(t)} mm pitch, ${Qm.toFixed(1)} mm drill, ${$m.toFixed(1)} mm pads`}}function oh(e){let t=w(e),n=e=>({x:C(t.x+e),y:C(t.y+e)});return{pads:e,courtyard:de(n(eh)),silkscreen:[fe(n(S))],fabrication:[]}}var sh=.3,ch=.1;function lh(e,t){let n=e.suffix===void 0&&e.size===void 0&&e.pairs===void 0,r=Number(e.cross);if(!n)return;if(e.code!==`2`)return E(`headers have one row (pinrow<N>) or two (pinrow2x<N>)`);if(!Number.isInteger(r)||r<1||r>th/2)return E(`a two-row header has 1 to ${th/2} pins a row`);let i=se(r,t).flatMap((e,n)=>[ih(2*n+1,e,C(t/2)),ih(2*n+2,e,C(-t/2))]),a=oh(i),o=w(i),s=C(-(o.x+S+sh)),c=C(t/2+$m/2);return{name:`pinrow2x${r}_p${nh(t)}mm`,...a,courtyard:de({x:C(-s+ch),y:C(o.y+eh)}),silkscreen:[...a.silkscreen,[{x:s,y:c},{x:s,y:C(c-$m)}]],origin:`Fixed two-row pin header, not an IPC-7351B calculation: ${nh(t)} mm pitch, ${Qm.toFixed(1)} mm drill, ${$m.toFixed(1)} mm pads`}}var uh=(e,t,n,r,i)=>({label:`LQFP-${e}`,pitch:t,span:n,terminal:k(.45,.75),leadWidth:r,bodyAcross:i,bodyAlong:i}),dh=new Map([[`32`,uh(32,.8,k(8.85,9.15),k(.3,.4),k(6.9,7.1))],[`48`,uh(48,.5,k(8.85,9.15),k(.17,.27),k(6.9,7.1))],[`64`,uh(64,.5,k(11.85,12.15),k(.17,.27),k(9.9,10.1))],[`100`,uh(100,.5,k(15.75,16.25),k(.17,.27),k(13.9,14.1))]]),fh=(e,t,n)=>({label:`QFN-${e}`,pitch:.5,span:t,terminal:k(.3,.5),leadWidth:k(.18,.3),bodyAcross:t,bodyAlong:t,exposedPad:n}),ph=new Map([[`16`,fh(16,k(2.9,3.1),k(1.45,1.75))],[`32`,fh(32,k(4.9,5.1),k(2.95,3.25))],[`48`,fh(48,k(6.9,7.1),k(4.95,5.25))]]);function mh(e,t,n){let r=se(e/4,t),i=[...r].reverse(),a=n.centre,o=(e,t)=>({x:e,y:t,width:n.length,height:n.width}),s=(e,t)=>({x:e,y:t,width:n.width,height:n.length});return[...i.map(e=>o(-a,e)),...r.map(e=>s(e,-a)),...r.map(e=>o(a,e)),...i.map(e=>s(e,a))].map((e,t)=>ae(String(t+1),e.x,e.y,e.width,e.height))}var hh=new Set([`qfn`,...new Set([`qfp`,`lqfp`,`tqfp`])]);function gh(e){if(hh.has(e.kind)&&e.variant===void 0)return e.size?yh(e,e.size):_h(e)}function _h(e){let t=e.kind===`qfn`,n=t?ph.get(e.code):dh.get(e.code);if(!n||!Dt(e)||!it(e.params,n,t?[`ep`]:[]))return;let r=e.params.ep===!0&&n.exposedPad?vh(n.exposedPad):void 0;return bh(e.kind+e.code+(r?`_ep`:``),Number(e.code),n,t,r)}var vh=e=>{let t=C((e.min+e.max)/2);return{x:t,y:t}};function yh(e,t){let n=e.kind===`qfn`,r=n?`QFN`:`QFP`,i=e.params.p;if(e.cross!==void 0||e.suffix!==void 0)return;if(typeof i!=`number`)return E(`a ${r} named by its body needs its pitch, such as _p0.5`);let a=n?an(e.code,t,i):sn(e.code,t,i);if(Ee(a))return a;let o=n?Ae(e,r):ke(e)?void 0:E(`a QFP takes only _p`);return Ee(o)?o:bh(`${e.kind}${e.code}_${D(t[0])}x${D(t[1])}_p${D(i)}${o?`_ep${Oe(o)}`:``}`,Number(e.code),a,n,o)}function bh(e,t,n,r,i){let{row:a,table:o}=r?tt(n):et(n),s=mh(t,n.pitch,a),c=i?[...s,ae(String(t+1),0,0,i.x,i.y)]:s,l=je(c,i!==void 0);if(l)return l;let u=n.bodyAcross.max/2,d=Math.max(n.span.max,n.bodyAcross.max)/2;return{name:e,pads:c,courtyard:T(c,{x:d,y:d},o),silkscreen:be(s,{x:u,y:u}),fabrication:pe({x:u,y:u}),origin:`IPC-7351B nominal, ${n.label}${i?` with exposed pad`:``}`}}var xh=[{upTo:7.99,lead:k(.4,.5)},{upTo:10,lead:k(.55,.65)},{upTo:1/0,lead:k(.75,.85)}],Sh=3,Ch=40,wh=.4;function Th(e){let t=C(e.y+e.height/2+S+.05+wh);return[[{x:C(e.x-wh),y:t},{x:C(e.x+wh),y:t}],[{x:C(e.x),y:C(t-wh)},{x:C(e.x),y:C(t+wh)}]]}function Eh(e){let t=e.suffix===void 0&&e.size===void 0&&e.pairs===void 0&&e.variant===void 0;if(e.kind!==`radial`||!t||Object.keys(e.params).length>0)return;if(e.cross===void 0)return E(`a radial capacitor is radial<can diameter>x<lead spacing>, such as radial6.3x2.5`);let n=Number(e.code),r=Number(e.cross),i=xh.find(e=>n<=e.upTo)?.lead;if(!i||n<Sh||n>Ch)return E(`the can is ${Sh} to ${Ch} mm across`);if(r<=0||r>=n)return E(`the leads must be closer together than the ${D(n)} mm can is wide`);let a=dt(ut(i));if(r-a.pad<.1)return E(`${a.pad} mm lands ${D(r)} mm apart would touch`);let o=[ft(`1`,C(-r/2),0,a,!0),ft(`2`,C(r/2),0,a)],s=n/2,c=Math.max(s,r/2+a.pad*Math.SQRT2/2+S);return{name:`radial${D(n)}x${D(r)}`,pads:o,courtyard:T(o,{x:c,y:c},lt),silkscreen:[xe({x:0,y:0},c,0,360,5),...Th(o[0])],fabrication:[xe({x:0,y:0},s,0,360,5)],origin:`Through-hole, radial electrolytic ${D(n)} mm can, leads ${D(r)} mm apart: ${a.drill} mm holes, ${a.pad} mm lands (IPC-2222 level B)`}}var Dh=(e,t)=>({min:e,max:t}),Oh={123:{label:`SOD-123`,span:Dh(3.55,3.85),terminal:Dh(.25,.4),leadWidth:Dh(.52,.62),bodyLength:Dh(2.55,2.85),bodyWidth:Dh(1.4,1.7)},323:{label:`SOD-323`,span:Dh(2.3,2.7),terminal:Dh(.2,.4),leadWidth:Dh(.25,.35),bodyLength:Dh(1.6,1.8),bodyWidth:Dh(1.2,1.4)}};function kh(e){if(!Object.hasOwn(Oh,e))return;let t=Oh[e],n={span:t.span,terminal:t.terminal,width:t.leadWidth},r=ie(o(n,y(n,t.bodyLength.max),c),f.roundOff),i={x:t.bodyLength.max/2,y:t.bodyWidth.max/2},a={x:Math.max(t.span.max,t.bodyLength.max)/2,y:Math.max(t.bodyWidth.max,t.leadWidth.max)/2};return{name:`sod${e}`,pads:r,courtyard:T(r,a,f),silkscreen:[...he(r,i),ge(r,i)],fabrication:pe(i),origin:`IPC-7351B nominal, ${t.label}`}}var Ah={pkg:{label:`SOT-23`,pitch:.95,span:k(2.1,2.5),terminal:k(.15,.45),leadWidth:k(.38,.48),bodyAcross:k(1.2,1.4),bodyAlong:k(2.8,3)},bottom:[-1,1],top:[0]},jh=e=>({label:`SOT-23-${e}`,pitch:.95,span:k(2.7,3),terminal:k(.35,.55),leadWidth:k(.35,.5),bodyAcross:k(1.5,1.7),bodyAlong:k(2.9,3.1)}),Mh=new Map([[void 0,Ah],[`5`,{pkg:jh(5),bottom:[-1,0,1],top:[1,-1]}],[`6`,{pkg:jh(6),bottom:[-1,0,1],top:[1,0,-1]}]]);function Nh(e,t,n,r){let i=t=>C(t*e.pkg.pitch),a=e.bottom.map((e,a)=>ae(String(a+1),i(e),-t,r,n)),o=e.bottom.length+1,s=e.top.map((e,a)=>ae(String(o+a),i(e),t,r,n));return[...a,...s]}function Ph(e){let t=e.kind===`sot`&&e.code===`23`?Mh.get(e.variant):void 0;if(!t||!Dt(e)||!it(e.params,t.pkg))return;let{pkg:n}=t,{row:r,table:i}=et(n),a=Nh(t,r.centre,r.length,r.width),o={x:n.bodyAlong.max/2,y:n.bodyAcross.max/2},s=Math.max(...[...t.bottom,...t.top].map(Math.abs))*n.pitch+n.leadWidth.max/2,c={x:Math.max(o.x,s),y:n.span.max/2};return{name:e.variant===void 0?`sot23`:`sot23_${e.variant}`,pads:a,courtyard:T(a,c,i),silkscreen:ve(a,o),fabrication:pe(o),origin:`IPC-7351B nominal, ${n.label}`}}var Fh={pkg:{label:`SOT-223`,pitch:2.3,span:k(6.7,7.3),terminal:k(.7,1.1),leadWidth:k(.6,.8),bodyAcross:k(3.3,3.7),bodyAlong:k(6.3,6.7)},tabWidth:k(2.9,3.1),tabNumber:`4`},Ih={pkg:{label:`SOT-89`,pitch:1.5,span:k(3.94,4.25),terminal:k(.89,1.2),leadWidth:k(.44,.56),bodyAcross:k(2.4,2.6),bodyAlong:k(4.4,4.6)},tabWidth:k(1.62,1.83),tabNumber:`2`,tabUnderBody:!0},Lh=new Map([[`223`,Fh],[`89`,Ih]]),Rh=.3;function zh(e){let{row:t}=et(e.pkg),n=et({...e.pkg,leadWidth:e.tabWidth}).row,r=e.pkg.pitch,i=[-r,0,r].map((e,n)=>ae(String(n+1),e,-t.centre,t.width,t.length)),a=n.centre+n.length/2,o=e.tabUnderBody?-t.centre+t.length/2+Rh:n.centre-n.length/2;return[...i,ae(e.tabNumber,0,C((a+o)/2),n.width,C(a-o))]}function Bh(e,t){let n=w(e),r=C(Math.max(t.x,n.x+S)),i=C(t.y);return[[{x:-r,y:-C(n.y)},{x:-r,y:i}],[{x:r,y:-i},{x:r,y:i}]]}function Vh(e){let t=e.kind===`sot`?Lh.get(e.code):void 0;if(!t||!Dt(e)||e.variant!==void 0||Object.keys(e.params).length>0)return;let{pkg:n}=t,{table:r}=et(n),i=zh(t),a={x:n.bodyAlong.max/2,y:n.bodyAcross.max/2},o=n.pitch+n.leadWidth.max/2,s={x:Math.max(a.x,o,t.tabWidth.max/2),y:n.span.max/2};return{name:`sot${e.code}`,pads:i,courtyard:T(i,s,r),silkscreen:Bh(i,a),fabrication:pe(a),origin:`IPC-7351B nominal, ${n.label}`}}var Hh=2.54,Uh=k(.7,.9),Wh=k(.45,.6),Gh=10.66,Kh=-2,qh=2.5,Jh=1.23,Yh=Gh/2;function Xh(){let[e,t,n]=[C(Yh),C(Kh),C(qh)];return[{x:-e,y:t},{x:e,y:t},{x:e,y:n},{x:-e,y:n},{x:-e,y:t}]}function Zh(e){let t=Dt(e)&&e.variant===void 0&&Object.keys(e.params).length===0;if(e.kind!==`to`||e.code!==`220`||!t)return;let n=dt(ut(Uh,Wh)),r=se(3,Hh).map((e,t)=>ft(String(t+1),e,0,n,t===0)),i=[{x:-C(Yh),y:C(Jh)},{x:C(Yh),y:C(Jh)}];return{name:`to220`,pads:r,courtyard:T(r,{x:Yh,y:Math.max(2,qh)},lt),silkscreen:[Xh(),i,Te(r[0],-2.3)],fabrication:[Xh(),i],origin:`Through-hole, TO-220 upright: ${n.drill} mm holes, ${n.pad} mm lands (IPC-2222 level B)`}}var Qh=2.54,$h=k(.36,.53),eg=k(.36,.51),tg=5.21/2,ng=-1.5850000000000004;function rg(){let e=Math.asin(ng/tg)*180/Math.PI;return xe({x:0,y:0},tg,e,180-e,2).concat([xe({x:0,y:0},tg,e,e)[0]])}function ig(e){let t=Dt(e)&&e.variant===void 0&&Object.keys(e.params).length===0;if(e.kind!==`to`||e.code!==`92`||!t)return;let n=dt(ut($h,eg)),r=[-2.54,0,Qh].map((e,t)=>ft(String(t+1),e,0,n,t===0)),i=rg();return{name:`to92`,pads:r,courtyard:T(r,{x:tg,y:tg},lt),silkscreen:[...Ce(i,r),Te(r[0],C(-1.8850000000000005))],fabrication:[i],origin:`Through-hole, TO-92 with leads formed to 2.54 mm: ${n.drill} mm holes, ${n.pad} mm lands (IPC-2222 level B)`}}var ag=e=>Dt(e)&&e.variant===void 0&&Object.keys(e.params).length===0,og=[e=>e.kind===``&&ag(e)?Qe(e.code):void 0,e=>e.kind===`sod`&&ag(e)?kh(e.code):void 0,Ph,Vh,Zm,It,gh,cn,Je,ah,vn,Zh,ig,bt,Eh],sg=512,cg=new Map,lg=/^parts\/[A-Za-z0-9._-]+\/footprint\.yaml$/,ug=e=>e.includes(`/`);function dg(e,t){if(ug(e))return mg(fg(e,t));let n=cg.get(e);if(n)return n;let r=mg(pg(e));return cg.size>=sg&&cg.delete(cg.keys().next().value),cg.set(e,r),r}function fg(e,t){if(!lg.test(e)||e.split(`/`).some(e=>e.includes(`..`)))return{error:`"${e}" is not a footprint file: only parts/<id>/footprint.yaml can be read`};if(!t)return{error:`"${e}" is a footprint file and needs a way to read files`};let n=t(e);return n===void 0?{error:`${e}: footprint file not found`}:Am(e,n)}function pg(e){let t=Et(e);if(t)for(let n of og){let r=n(t);if(Ee(r))return{error:`copperflow cannot make footprint "${e}": ${r.refused}`};if(r)return r}return{error:Gm(e)}}function mg(e){if(typeof e==`object`&&e&&!Object.isFrozen(e)){for(let t of Object.values(e))mg(t);Object.freeze(e)}return e}var hg=`Type a footprint string such as soic8, qfn32_5x5_p0.5 or hc49s.`;function gg(e,t){let n=e.trim();if(n===``)return{error:hg};if(n.includes(`/`))return{error:`"${n}" is not a footprint string`};let r=dg(n);if(`error`in r)return{error:r.error};let i=vg([...r.courtyard,...r.silkscreen.flat(),...r.fabrication.flat(),...r.pads.flatMap(_g)]),a=Math.min((t.width-20)/Math.max(i.width,1e-6),(t.height-20)/Math.max(i.height,1e-6)),o=e=>({x:t.width/2+(e.x-i.cx)*a,y:t.height/2-(e.y-i.cy)*a}),s=r.pads.map(e=>{let t=o(e);return{number:e.number,shape:e.shape,x:t.x,y:t.y,width:e.width*a,height:e.height*a,rotation:-e.rotation,through:e.layers===`through`,...e.drill?{drill:Math.min(e.drill.width,e.drill.height)*a}:{}}}),c=vg(r.courtyard),l=r.pads.length;return{pads:s,courtyard:r.courtyard.map(o),silkscreen:r.silkscreen.map(e=>e.map(o)),body:r.fabrication.map(e=>e.map(o)),scale:a,summary:`${l} pad${l===1?``:`s`}, courtyard ${yg(c.width)} × ${yg(c.height)} mm`}}function _g(e){let[t,n]=[e.width/2,e.height/2],r=e.rotation*Math.PI/180,[i,a]=[Math.cos(r),Math.sin(r)];return[[-t,-n],[t,-n],[t,n],[-t,n]].map(([t=0,n=0])=>({x:e.x+t*i-n*a,y:e.y+t*a+n*i}))}function vg(e){let t=e.map(e=>e.x),n=e.map(e=>e.y),[r,i,a,o]=[Math.min(...t),Math.max(...t),Math.min(...n),Math.max(...n)];return{width:i-r,height:o-a,cx:(r+i)/2,cy:(a+o)/2}}var yg=e=>Number(e.toFixed(2)),bg=[`power_in`,`power_out`,`ground`,`input`,`output`,`bidirectional`,`passive`,`no_connect`],xg=/^[A-Za-z](?:[A-Za-z0-9._-]{0,62}[A-Za-z0-9])?$/,Sg=/^[1-9][0-9]*$/,Cg=/^[A-Za-z_][A-Za-z0-9_]*$/,wg=`${bg.slice(0,-1).join(`, `)} or ${bg[bg.length-1]}`;function Tg(e){let t=e.split(/\r?\n/),n=Dg(t),r=t.findIndex(e=>e.trim()!==``),i=[],a=[],o=new Map;return t.forEach((e,t)=>{let s=e.trim();if(s===``)return;let c=Og(s,n);if(t===r&&Ag(s,c[0]??``))return;let l=t+1,u=jg(c,o);typeof u==`string`?a.push({line:l,text:s,message:`Line ${l}: ${u}`}):(o.set(u.number,l),i.push(u))}),{pins:i,errors:a}}function Eg(e){let t=e.replace(/[^A-Za-z0-9_]/g,`_`);return/^[A-Za-z_]/.test(t)?t:`_${t}`}function Dg(e){let t=e.map(e=>e.trim()).filter(e=>e!==``);return t.some(e=>e.includes(` `))?`tab`:t.some(e=>/^[^\s,]+\s*,/.test(e))?`comma`:t.some(e=>/ {2,}/.test(e))?`spaces`:`space`}function Og(e,t){let n={tab:/\t/,comma:/,/,spaces:/ {2,}/,space:/\s+/}[t],r=t===`space`||t===`spaces`&&!/ {2,}/.test(e),i=e.split(r?/\s+/:n).map(e=>e.trim());return r&&i.length>3?[...i.slice(0,3),i.slice(3).join(` `)]:i}var kg=/\b(pin|no|number|name|type|function|description)\b/i;function Ag(e,t){return!/[0-9]/.test(e)||!Sg.test(t)&&kg.test(e)}function jg(e,t){let[n=``,r=``,i=``,...a]=e;if(!Sg.test(n))return`"${n}" is not a pin number; pins are numbered 1, 2, 3 …`;let o=t.get(n);if(o!==void 0)return`pin ${n} is already on line ${o}`;if(r===``)return`pin ${n} has no name`;if(!Cg.test(r))return`"${r}" is not a pin name; use letters, digits and _, starting with a letter (e.g. ${Eg(r)})`;let s=i===``?`passive`:Mg(i);if(!s)return`"${i}" is not a pin type; use ${wg}`;let c=a.filter(e=>e!==``).join(`, `);return{number:n,name:r,type:s,...c?{description:c}:{}}}function Mg(e){let t=e.toLowerCase().replace(/[-\s]+/g,`_`);return bg.find(e=>e===t)}var Ng={id:``,title:``,manufacturer:``,mpn:``,packageKind:`string`,packageText:``,pins:[],suppliers:[{supplier:`lcsc`,number:``}],datasheet:``,replace:!1},Pg=/^[a-z0-9_]+$/,Fg=e=>e.number.trim()===``&&e.name.trim()===``,Ig=(e,t)=>(Number(e.number)||1/0)-(Number(t.number)||1/0);function Lg(e){let t=Math.max(0,...e.map(e=>Number(e.number)).filter(e=>Number.isInteger(e)));return[...e,{number:String(t+1),name:``,type:`passive`,description:``}]}function Rg(e,t,n){return e.map((e,r)=>r===t?{...e,...n}:e)}function zg(e,t){return e.filter((e,n)=>n!==t)}function Bg(e,t){let n=Tg(t),r=new Map(n.pins.map(e=>[e.number,{...e,description:e.description??``}]));return{pins:[...e.filter(e=>!Fg(e)&&!r.has(e.number.trim())),...r.values()].sort(Ig),errors:n.errors}}function Vg(e){let t=e.id.trim(),n=e.title.trim(),r=Ug(e.pins),i=Wg(e.suppliers),a=e.datasheet.trim(),o=[...t===``?[`Give the part an id, such as its part number.`]:xg.test(t)&&!t.includes(`..`)?[]:[`"${t}" is not a part id: start with a letter, end with a letter or digit, and use letters, digits, ".", "_" or "-".`],...n===``?[`Give the part a title.`]:[],...Hg(e),...r.problems,...i.problems,...a===``||/^https?:\/\/\S+$/.test(a)?[]:[`The datasheet link must start with http:// or https://.`]];if(o.length>0)return{problems:o};let s=t=>e[t].trim()?{[t]:e[t].trim()}:{};return{id:t,title:n,...s(`manufacturer`),...s(`mpn`),package:e.packageKind===`file`?{file:`footprint.yaml`}:e.packageText.trim(),pins:r.rows,...Object.keys(i.record).length>0?{suppliers:i.record}:{},...a?{datasheet:{url:a}}:{},replace:e.replace}}function Hg(e){if(e.packageKind===`file`)return[];let t=e.packageText.trim();if(t===``)return[`Type a footprint string such as soic8, or choose a footprint file.`];if(t.includes(`/`))return[`"${t}" is not a footprint string.`];let n=dg(t);return`error`in n?[n.error]:[]}function Ug(e){let t=e.map((e,t)=>({pin:e,row:t+1})).filter(({pin:e})=>!Fg(e));if(t.length===0)return{rows:[],problems:[`Add the pins: type them in the rows or paste the datasheet's pin table.`]};let n=[],r=[],i=new Map;for(let{pin:e,row:a}of t){let[t,o,s]=[e.number.trim(),e.name.trim(),e.description.trim()],c=e=>r.push(`Pin row ${a}: ${e}`);if(!Sg.test(t)){c(`"${t}" is not a pin number; pins are numbered 1, 2, 3 ….`);continue}let l=i.get(t);l===void 0?i.set(t,a):c(`pin ${t} is already in row ${l}.`),o===``?c(`pin ${t} has no name.`):Cg.test(o)||c(`"${o}" is not a pin name; use letters, digits and _, starting with a letter (e.g. ${Eg(o)}).`),n.push({number:t,name:o,type:e.type,...s?{description:s}:{}})}return{rows:n,problems:r}}function Wg(e){let t={},n=[];for(let r of e){let[e,i]=[r.supplier.trim(),r.number.trim()];if(e===``&&i===``)continue;let a=e.toLowerCase();if(!Pg.test(a)||i===``||a in t){let t=a.split(/[^a-z0-9_]/)[0]||`lcsc`;n.push(`Supplier "${e}": name it with lower-case letters, digits and _ (e.g. ${t}) and give its part number.`)}else t[a]=i}return{record:t,problems:n}}var $=n(),Gg={width:240,height:150},Kg={board:r.background,pad:r.topCopper,throughPad:r.multiLayer,drill:r.drill,outline:r.topAssembly,silk:r.topSilk};function qg(e,t){let n=window.devicePixelRatio||1;e.width=Gg.width*n,e.height=Gg.height*n;let r=e.getContext(`2d`);if(!r)return;r.setTransform(n,0,0,n,0,0),r.fillStyle=Kg.board,r.fillRect(0,0,Gg.width,Gg.height);let i=(e,t,n,i=[])=>{r.strokeStyle=t,r.lineWidth=1,r.setLineDash(i);for(let t of e)r.beginPath(),t.forEach((e,t)=>t===0?r.moveTo(e.x,e.y):r.lineTo(e.x,e.y)),n&&r.closePath(),r.stroke();r.setLineDash([])};i([t.courtyard],Kg.outline,!0,[3,3]),i(t.body,Kg.outline,!1),i(t.silkscreen,Kg.silk,!1);for(let e of t.pads)r.save(),r.translate(e.x,e.y),r.rotate(e.rotation*Math.PI/180),r.fillStyle=e.through?Kg.throughPad:Kg.pad,r.beginPath(),e.shape===`circle`||e.shape===`oval`?r.ellipse(0,0,e.width/2,e.height/2,0,0,2*Math.PI):r.rect(-e.width/2,-e.height/2,e.width,e.height),r.fill(),e.drill&&(r.fillStyle=Kg.drill,r.beginPath(),r.arc(0,0,e.drill/2,0,2*Math.PI),r.fill()),r.restore();let a=t.pads.find(e=>e.number===`1`);a&&(r.fillStyle=Kg.silk,r.font=`10px sans-serif`,r.fillText(`1`,a.x-a.width/2-8,a.y+3))}function Jg({text:e}){let t=(0,a.useRef)(null),n=(0,a.useMemo)(()=>gg(e,Gg),[e]);return(0,a.useEffect)(()=>{t.current&&!(`error`in n)&&qg(t.current,n)},[n]),`error`in n?(0,$.jsx)(`p`,{className:`new-part-preview-note`,children:n.error}):(0,$.jsxs)(`figure`,{className:`new-part-preview`,children:[(0,$.jsx)(`canvas`,{ref:t,style:Gg,role:`img`,"aria-label":`Footprint ${e.trim()}: ${n.summary}`}),(0,$.jsx)(`figcaption`,{children:n.summary})]})}function Yg({pins:e,onChange:t}){return(0,$.jsxs)(`table`,{className:`new-part-pins`,children:[(0,$.jsx)(`thead`,{children:(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`th`,{children:`Pin`}),(0,$.jsx)(`th`,{children:`Name`}),(0,$.jsx)(`th`,{children:`Type`}),(0,$.jsx)(`th`,{children:`Description`}),(0,$.jsx)(`th`,{})]})}),(0,$.jsx)(`tbody`,{children:e.map((n,r)=>(0,$.jsxs)(`tr`,{children:[(0,$.jsx)(`td`,{children:(0,$.jsx)(`input`,{"aria-label":`Row ${r+1} pin number`,value:n.number,onChange:n=>t(Rg(e,r,{number:n.target.value}))})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`input`,{"aria-label":`Row ${r+1} pin name`,value:n.name,onChange:n=>t(Rg(e,r,{name:n.target.value}))})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`select`,{"aria-label":`Row ${r+1} pin type`,value:n.type,onChange:n=>t(Rg(e,r,{type:n.target.value})),children:bg.map(e=>(0,$.jsx)(`option`,{value:e,children:e},e))})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`input`,{"aria-label":`Row ${r+1} description`,value:n.description,onChange:n=>t(Rg(e,r,{description:n.target.value}))})}),(0,$.jsx)(`td`,{children:(0,$.jsx)(`button`,{type:`button`,"aria-label":`Remove row ${r+1}`,onClick:()=>t(zg(e,r)),children:`×`})})]},r))})]})}function Xg({pins:e,onChange:t}){let[n,r]=(0,a.useState)(``),[i,o]=(0,a.useState)([]),s=(0,a.useId)();return(0,$.jsxs)(`div`,{className:`new-part-paste`,children:[(0,$.jsx)(`label`,{htmlFor:s,children:`Paste a pin table: one pin per line, "1 VDD power_in", tab or comma separated; no type means passive.`}),(0,$.jsx)(`textarea`,{id:s,rows:4,value:n,onChange:e=>r(e.target.value)}),(0,$.jsx)(`button`,{type:`button`,onClick:()=>{let i=Bg(e,n);t(i.pins),o(i.errors),i.errors.length===0&&r(``)},disabled:n.trim()===``,children:`Add pasted pins`}),i.length>0&&(0,$.jsx)(`ul`,{role:`alert`,children:i.map(e=>(0,$.jsx)(`li`,{children:e.message},e.line))})]})}function Zg({fields:e,onChange:t}){let n=(n,r,i)=>t(e.map((e,t)=>t===n?{...e,[r]:i}:e));return(0,$.jsxs)($.Fragment,{children:[e.map((e,t)=>(0,$.jsxs)(`div`,{className:`new-part-supplier`,children:[(0,$.jsx)(`input`,{"aria-label":`Supplier ${t+1}`,placeholder:`lcsc`,value:e.supplier,onChange:e=>n(t,`supplier`,e.target.value)}),(0,$.jsx)(`input`,{"aria-label":`Supplier ${t+1} part number`,placeholder:`C16212`,value:e.number,onChange:e=>n(t,`number`,e.target.value)})]},t)),(0,$.jsx)(`button`,{type:`button`,className:`new-part-add`,onClick:()=>t([...e,{supplier:``,number:``}]),children:`Add supplier`})]})}function Qg({result:e}){return(0,$.jsxs)(`div`,{className:`import-result`,role:`status`,children:[(0,$.jsx)(`p`,{children:(0,$.jsx)(`strong`,{children:i(e)})}),e.notes.length>0&&(0,$.jsx)(`ul`,{children:e.notes.map(e=>(0,$.jsx)(`li`,{children:e},e))}),(0,$.jsx)(`h3`,{children:`Written`}),(0,$.jsx)(`ul`,{children:e.files.map(e=>(0,$.jsx)(`li`,{children:(0,$.jsx)(`code`,{children:e})},e))}),(0,$.jsx)(`h3`,{children:(0,$.jsx)(`code`,{children:e.verification})}),(0,$.jsx)(`pre`,{className:`new-part-checklist`,children:e.checklist})]})}function $g({panel:e,onClose:t}){let[n,r]=(0,a.useState)(()=>({...Ng,pins:Lg([])})),[i,o]=(0,a.useState)([]),[s,c]=(0,a.useState)(!1),[l,u]=(0,a.useState)(),d=(0,a.useId)(),f=(e,t)=>r(n=>({...n,[e]:t})),p=async r=>{if(r.preventDefault(),s)return;if(l)return t();let i=Vg(n);if(`problems`in i)return o(i.problems);c(!0),o([]);try{u(await e.create(i))}catch(e){o([e.message])}finally{c(!1)}};if(l)return(0,$.jsxs)(`form`,{className:`rules-form new-part-form`,onSubmit:e=>void p(e),children:[(0,$.jsx)(Qg,{result:l}),(0,$.jsx)(`button`,{type:`submit`,children:`Close`})]});let m=(e,t,r)=>(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`${d}-${e}`,children:t}),(0,$.jsx)(`input`,{id:`${d}-${e}`,value:n[e],placeholder:r,onChange:t=>f(e,t.target.value)})]});return(0,$.jsxs)(`form`,{className:`rules-form new-part-form`,onSubmit:e=>void p(e),children:[(0,$.jsxs)(`fieldset`,{className:`new-part-fields`,disabled:s,children:[m(`id`,`Part id`,`AP2112K-3.3`),m(`title`,`Title`,`3.3 V LDO regulator`),m(`manufacturer`,`Manufacturer`,`Diodes Incorporated`),m(`mpn`,`MPN`,`AP2112K-3.3TRG1`),(0,$.jsx)(`span`,{children:`Package`}),(0,$.jsxs)(`div`,{className:`new-part-package`,children:[(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`radio`,name:`${d}-kind`,checked:n.packageKind===`string`,onChange:()=>f(`packageKind`,`string`)}),` Footprint string`]}),(0,$.jsxs)(`label`,{children:[(0,$.jsx)(`input`,{type:`radio`,name:`${d}-kind`,checked:n.packageKind===`file`,onChange:()=>f(`packageKind`,`file`)}),` Footprint file`]})]}),n.packageKind===`string`?(0,$.jsxs)($.Fragment,{children:[(0,$.jsx)(`label`,{htmlFor:`${d}-package`,children:`Footprint`}),(0,$.jsx)(`input`,{id:`${d}-package`,value:n.packageText,placeholder:`soic8, qfn32_5x5_p0.5, hc49s`,onChange:e=>f(`packageText`,e.target.value)}),(0,$.jsx)(Jg,{text:n.packageText})]}):(0,$.jsx)(`p`,{children:`footprint.yaml is written as a placeholder, one pad per pin. The schematic can use the part now; the board reports an error for it until you draw its pads from the datasheet's land pattern and delete "placeholder: true".`}),(0,$.jsx)(`h3`,{children:`Pins`}),(0,$.jsx)(Yg,{pins:n.pins,onChange:e=>f(`pins`,e)}),(0,$.jsx)(`button`,{type:`button`,className:`new-part-add`,onClick:()=>f(`pins`,Lg(n.pins)),children:`Add pin`}),(0,$.jsx)(Xg,{pins:n.pins,onChange:e=>f(`pins`,e)}),(0,$.jsx)(`h3`,{children:`Suppliers`}),(0,$.jsx)(Zg,{fields:n.suppliers,onChange:e=>f(`suppliers`,e)}),m(`datasheet`,`Datasheet URL`,`https://…`),(0,$.jsxs)(`label`,{className:`make-sheet-rename`,children:[(0,$.jsx)(`input`,{type:`checkbox`,checked:n.replace,onChange:e=>f(`replace`,e.target.checked)}),`Replace a part with this id that is not verified`]})]}),i.length>0&&(0,$.jsx)(`ul`,{className:`new-part-problems`,role:`alert`,children:i.map(e=>(0,$.jsx)(`li`,{children:e},e))}),(0,$.jsx)(`p`,{children:`The part is written unverified; check it against the datasheet in its verification.md.`}),(0,$.jsx)(`button`,{type:`submit`,disabled:s,children:s?`Writing…`:`Create part`})]})}export{$g as NewPartForm};