@horizon36596/zenith-cli 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +18 -0
  3. package/README.md +207 -0
  4. package/dist/autoLoad.d.ts +54 -0
  5. package/dist/autoLoad.d.ts.map +1 -0
  6. package/dist/autoLoad.js +139 -0
  7. package/dist/autoLoad.js.map +1 -0
  8. package/dist/calibrateFit.d.ts +38 -0
  9. package/dist/calibrateFit.d.ts.map +1 -0
  10. package/dist/calibrateFit.js +69 -0
  11. package/dist/calibrateFit.js.map +1 -0
  12. package/dist/commandLibrary.d.ts +19 -0
  13. package/dist/commandLibrary.d.ts.map +1 -0
  14. package/dist/commandLibrary.js +27 -0
  15. package/dist/commandLibrary.js.map +1 -0
  16. package/dist/commands/calibrate.d.ts +18 -0
  17. package/dist/commands/calibrate.d.ts.map +1 -0
  18. package/dist/commands/calibrate.js +116 -0
  19. package/dist/commands/calibrate.js.map +1 -0
  20. package/dist/commands/codegen.d.ts +12 -0
  21. package/dist/commands/codegen.d.ts.map +1 -0
  22. package/dist/commands/codegen.js +63 -0
  23. package/dist/commands/codegen.js.map +1 -0
  24. package/dist/commands/deploy.d.ts +63 -0
  25. package/dist/commands/deploy.d.ts.map +1 -0
  26. package/dist/commands/deploy.js +181 -0
  27. package/dist/commands/deploy.js.map +1 -0
  28. package/dist/commands/diff.d.ts +11 -0
  29. package/dist/commands/diff.d.ts.map +1 -0
  30. package/dist/commands/diff.js +68 -0
  31. package/dist/commands/diff.js.map +1 -0
  32. package/dist/commands/estimate.d.ts +9 -0
  33. package/dist/commands/estimate.d.ts.map +1 -0
  34. package/dist/commands/estimate.js +81 -0
  35. package/dist/commands/estimate.js.map +1 -0
  36. package/dist/commands/init.d.ts +10 -0
  37. package/dist/commands/init.d.ts.map +1 -0
  38. package/dist/commands/init.js +67 -0
  39. package/dist/commands/init.js.map +1 -0
  40. package/dist/commands/new.d.ts +10 -0
  41. package/dist/commands/new.d.ts.map +1 -0
  42. package/dist/commands/new.js +28 -0
  43. package/dist/commands/new.js.map +1 -0
  44. package/dist/commands/propose.d.ts +15 -0
  45. package/dist/commands/propose.d.ts.map +1 -0
  46. package/dist/commands/propose.js +67 -0
  47. package/dist/commands/propose.js.map +1 -0
  48. package/dist/commands/render.d.ts +16 -0
  49. package/dist/commands/render.d.ts.map +1 -0
  50. package/dist/commands/render.js +90 -0
  51. package/dist/commands/render.js.map +1 -0
  52. package/dist/commands/sim.d.ts +31 -0
  53. package/dist/commands/sim.d.ts.map +1 -0
  54. package/dist/commands/sim.js +213 -0
  55. package/dist/commands/sim.js.map +1 -0
  56. package/dist/commands/validate.d.ts +19 -0
  57. package/dist/commands/validate.d.ts.map +1 -0
  58. package/dist/commands/validate.js +97 -0
  59. package/dist/commands/validate.js.map +1 -0
  60. package/dist/coreGate.d.ts +19 -0
  61. package/dist/coreGate.d.ts.map +1 -0
  62. package/dist/coreGate.js +23 -0
  63. package/dist/coreGate.js.map +1 -0
  64. package/dist/fieldImage.d.ts +19 -0
  65. package/dist/fieldImage.d.ts.map +1 -0
  66. package/dist/fieldImage.js +63 -0
  67. package/dist/fieldImage.js.map +1 -0
  68. package/dist/findings.d.ts +20 -0
  69. package/dist/findings.d.ts.map +1 -0
  70. package/dist/findings.js +57 -0
  71. package/dist/findings.js.map +1 -0
  72. package/dist/index.d.ts +32 -0
  73. package/dist/index.d.ts.map +1 -0
  74. package/dist/index.js +194 -0
  75. package/dist/index.js.map +1 -0
  76. package/dist/javaCodegen.d.ts +44 -0
  77. package/dist/javaCodegen.d.ts.map +1 -0
  78. package/dist/javaCodegen.js +537 -0
  79. package/dist/javaCodegen.js.map +1 -0
  80. package/dist/launcher.d.ts +39 -0
  81. package/dist/launcher.d.ts.map +1 -0
  82. package/dist/launcher.js +153 -0
  83. package/dist/launcher.js.map +1 -0
  84. package/dist/lib.d.ts +13 -0
  85. package/dist/lib.d.ts.map +1 -0
  86. package/dist/lib.js +13 -0
  87. package/dist/lib.js.map +1 -0
  88. package/dist/project.d.ts +33 -0
  89. package/dist/project.d.ts.map +1 -0
  90. package/dist/project.js +104 -0
  91. package/dist/project.js.map +1 -0
  92. package/dist/skeletons.d.ts +16 -0
  93. package/dist/skeletons.d.ts.map +1 -0
  94. package/dist/skeletons.js +120 -0
  95. package/dist/skeletons.js.map +1 -0
  96. package/dist/traceReport.d.ts +75 -0
  97. package/dist/traceReport.d.ts.map +1 -0
  98. package/dist/traceReport.js +91 -0
  99. package/dist/traceReport.js.map +1 -0
  100. package/dist/version.d.ts +3 -0
  101. package/dist/version.d.ts.map +1 -0
  102. package/dist/version.js +4 -0
  103. package/dist/version.js.map +1 -0
  104. package/package.json +71 -0
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { VERSION } from "./version.js";
4
+ export * from "./lib.js";
5
+ export { VERSION };
6
+ /**
7
+ * The `zenith` binary (site/docs/cli-reference.md).
8
+ *
9
+ * Every verb has `--json` and none of them ever prompts, so an agent can drive the CLI. Exit codes
10
+ * are the same convention across every verb: 0 ok, 1 the auto has findings errors, 2 usage, IO, or a
11
+ * verb that depends on a `@horizon36596/zenith-core` M1 export (`estimate`, `ledger`, `render`, `diff`) that has
12
+ * not landed yet.
13
+ */
14
+ export declare function buildProgram(): Command;
15
+ /**
16
+ * Drops a single leading bare `--` from the verb's own arguments (`argv[2]`, right after the node
17
+ * executable and the script path). `pnpm zenith -- <verb> ...` forwards that `--` literally, and
18
+ * without stripping it commander treats it as "end of options": every flag after it, `--project`
19
+ * included, is read as an operand instead of being parsed.
20
+ */
21
+ export declare function stripWrapperSeparator(argv: readonly string[]): string[];
22
+ export declare function main(argv: readonly string[]): Promise<number>;
23
+ /**
24
+ * True when `entry`, the script Node was started with, is the module at `moduleUrl`.
25
+ *
26
+ * Both sides are resolved through symlinks first. npm installs a package's bin on Linux and macOS as
27
+ * a symlink in `node_modules/.bin`, and Node reports that link's path in `process.argv[1]` while
28
+ * `import.meta.url` is the real file, so a plain comparison is false there and the CLI would exit
29
+ * without doing anything. On Windows npm writes a `.cmd` shim that passes the real path instead.
30
+ */
31
+ export declare function isEntryPoint(entry: string | undefined, moduleUrl: string): boolean;
32
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,CAAC;AAEnB;;;;;;;GAOG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAiJtC;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,EAAE,CAGvE;AAED,wBAAsB,IAAI,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAWnE;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAOlF"}
package/dist/index.js ADDED
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env node
2
+ import { realpathSync } from "node:fs";
3
+ import { fileURLToPath, pathToFileURL } from "node:url";
4
+ import { Command } from "commander";
5
+ import { runCalibrate } from "./commands/calibrate.js";
6
+ import { runCodegen } from "./commands/codegen.js";
7
+ import { runDeploy } from "./commands/deploy.js";
8
+ import { runDiff } from "./commands/diff.js";
9
+ import { runEstimate } from "./commands/estimate.js";
10
+ import { runInit } from "./commands/init.js";
11
+ import { runNew } from "./commands/new.js";
12
+ import { runPropose } from "./commands/propose.js";
13
+ import { runRender } from "./commands/render.js";
14
+ import { runSim } from "./commands/sim.js";
15
+ import { runValidate } from "./commands/validate.js";
16
+ import { VERSION } from "./version.js";
17
+ export * from "./lib.js";
18
+ export { VERSION };
19
+ /**
20
+ * The `zenith` binary (site/docs/cli-reference.md).
21
+ *
22
+ * Every verb has `--json` and none of them ever prompts, so an agent can drive the CLI. Exit codes
23
+ * are the same convention across every verb: 0 ok, 1 the auto has findings errors, 2 usage, IO, or a
24
+ * verb that depends on a `@horizon36596/zenith-core` M1 export (`estimate`, `ledger`, `render`, `diff`) that has
25
+ * not landed yet.
26
+ */
27
+ export function buildProgram() {
28
+ const program = new Command();
29
+ program
30
+ .name("zenith")
31
+ .description("An auto planner for FTC that humans and agents share. Horizon (FTC 36596).")
32
+ .version(VERSION)
33
+ .showHelpAfterError();
34
+ program
35
+ .command("validate")
36
+ .description("Check autos against the schema and the feasibility rules; exit 1 on any error.")
37
+ .argument("<autos...>", "paths to .auto.json files")
38
+ .option("--json", "print findings as JSON")
39
+ .option("--explain", "say what each finding means and how to fix it")
40
+ .option("--project <dir>", "the directory holding zenith.json")
41
+ .action((autos, options) => {
42
+ process.exitCode = runValidate(autos, options);
43
+ });
44
+ program
45
+ .command("init")
46
+ .description("Write zenith.json and an autos directory that validates.")
47
+ .option("--json", "print what was written as JSON")
48
+ .option("--force", "overwrite files that already exist")
49
+ .option("--command-library <library>", "solverslib or ivy: the command library your robot code uses")
50
+ .action((options) => {
51
+ process.exitCode = runInit(options);
52
+ });
53
+ program
54
+ .command("new")
55
+ .description("Write a new auto from a canonical skeleton.")
56
+ .argument("<name>", "the auto's name, used for the file name too")
57
+ .option("--json", "print what was written as JSON")
58
+ .option("--force", "overwrite the file if it exists")
59
+ .option("--project <dir>", "the directory holding zenith.json")
60
+ .option("--alliance <alliance>", "RED or BLUE", "RED")
61
+ .action((name, options) => {
62
+ process.exitCode = runNew(name, options);
63
+ });
64
+ program
65
+ .command("estimate")
66
+ .description("Print the per-step time estimate and the total against the auto period.")
67
+ .argument("<auto>", "path to a .auto.json file, or its bare name in autosDir")
68
+ .option("--json", "print the estimate as JSON")
69
+ .option("--explain", "also print the assumptions behind the numbers")
70
+ .option("--project <dir>", "the directory holding zenith.json")
71
+ .action((auto, options) => {
72
+ process.exitCode = runEstimate(auto, options);
73
+ });
74
+ program
75
+ .command("render")
76
+ .description("Draw an auto to SVG or PNG: the field, the path, findings and the ledger.")
77
+ .argument("<auto>", "path to a .auto.json file, or its bare name in autosDir")
78
+ .option("--svg <out>", "write an SVG file")
79
+ .option("--png <out>", "write a PNG file (via @resvg/resvg-js)")
80
+ .option("--alliance <alliance>", "RED or BLUE; mirrors the preview")
81
+ .option("--base <auto>", "another auto to load for comparison (overlay pending core.render support)")
82
+ .option("--json", "print what was written as JSON")
83
+ .option("--project <dir>", "the directory holding zenith.json")
84
+ .action(async (auto, options) => {
85
+ process.exitCode = await runRender(auto, options);
86
+ });
87
+ program
88
+ .command("codegen")
89
+ .description("Write the readable, derived Java class for an auto (never edited by hand).")
90
+ .argument("<auto>", "path to a .auto.json file, or its bare name in autosDir")
91
+ .option("--json", "print what was written as JSON")
92
+ .option("--project <dir>", "the directory holding zenith.json")
93
+ .action((auto, options) => {
94
+ process.exitCode = runCodegen(auto, options);
95
+ });
96
+ program
97
+ .command("deploy")
98
+ .description("Copy the autos, waypoints, robot and field files to the deploy directory, and refresh the @Autonomous stubs.")
99
+ .option("--dry-run", "list what would happen without writing anything")
100
+ .option("--json", "print the action list as JSON")
101
+ .option("--project <dir>", "the directory holding zenith.json")
102
+ .action((options) => {
103
+ process.exitCode = runDeploy(options);
104
+ });
105
+ program
106
+ .command("diff")
107
+ .description("Print the structural diff between two autos.")
108
+ .argument("<a>", "path to the first .auto.json file")
109
+ .argument("<b>", "path to the second .auto.json file")
110
+ .option("--json", "print the diff as JSON")
111
+ .action((a, b, options) => {
112
+ process.exitCode = runDiff(a, b, options);
113
+ });
114
+ program
115
+ .command("sim")
116
+ .description("Run zenith.json's sim command and print estimate vs actual per step from its trace.")
117
+ .argument("<auto>", "path to a .auto.json file, or its bare name in autosDir")
118
+ .option("--open", "also render an SVG of the plan next to the trace, and print its path")
119
+ .option("--timeout <seconds>", "kill the sim command after this many seconds", (value) => Number(value))
120
+ .option("--json", "print the report as JSON")
121
+ .option("--project <dir>", "the directory holding zenith.json")
122
+ .action(async (auto, options) => {
123
+ process.exitCode = await runSim(auto, options);
124
+ });
125
+ program
126
+ .command("calibrate")
127
+ .description("Fit accel, settleS and a per-heading-mode scale from recorded sim traces.")
128
+ .option("--traces <dir>", "directory of *.trace.json files (default: traces/, or zenith.json's sim.trace directory)")
129
+ .option("--write", "write the fitted accelInPerS2 and settleS into robot.json")
130
+ .option("--date <date>", "the provenance date (default: today)")
131
+ .option("--json", "print the fit as JSON")
132
+ .option("--project <dir>", "the directory holding zenith.json")
133
+ .action((options) => {
134
+ process.exitCode = runCalibrate(options);
135
+ });
136
+ program
137
+ .command("propose")
138
+ .description("Validate, render and print a PR body for an auto. Only --dry-run is implemented today.")
139
+ .argument("<auto>", "path to a .auto.json file, or its bare name in autosDir")
140
+ .option("--dry-run", "the only mode this build supports: print the PR body to stdout")
141
+ .option("--base <branch>", "accepted for forward compatibility with GitHub mode; unused by --dry-run")
142
+ .option("--json", "print the render path and the PR body as JSON")
143
+ .option("--project <dir>", "the directory holding zenith.json")
144
+ .action((auto, options) => {
145
+ process.exitCode = runPropose(auto, options);
146
+ });
147
+ return program;
148
+ }
149
+ /**
150
+ * Drops a single leading bare `--` from the verb's own arguments (`argv[2]`, right after the node
151
+ * executable and the script path). `pnpm zenith -- <verb> ...` forwards that `--` literally, and
152
+ * without stripping it commander treats it as "end of options": every flag after it, `--project`
153
+ * included, is read as an operand instead of being parsed.
154
+ */
155
+ export function stripWrapperSeparator(argv) {
156
+ if (argv[2] !== "--")
157
+ return [...argv];
158
+ return [...argv.slice(0, 2), ...argv.slice(3)];
159
+ }
160
+ export async function main(argv) {
161
+ try {
162
+ await buildProgram().parseAsync(stripWrapperSeparator(argv));
163
+ return process.exitCode === undefined ? 0 : Number(process.exitCode);
164
+ }
165
+ catch (error) {
166
+ process.stderr.write(`zenith: ${error instanceof Error ? error.message : String(error)}\n`);
167
+ // Every thrown error reaching here is a usage or IO problem: loadProject not finding a project,
168
+ // a missing zenith.json section, a bad --alliance, and so on. A verb's own findings-related
169
+ // failure returns 1 directly from its run* function instead of throwing.
170
+ return 2;
171
+ }
172
+ }
173
+ /**
174
+ * True when `entry`, the script Node was started with, is the module at `moduleUrl`.
175
+ *
176
+ * Both sides are resolved through symlinks first. npm installs a package's bin on Linux and macOS as
177
+ * a symlink in `node_modules/.bin`, and Node reports that link's path in `process.argv[1]` while
178
+ * `import.meta.url` is the real file, so a plain comparison is false there and the CLI would exit
179
+ * without doing anything. On Windows npm writes a `.cmd` shim that passes the real path instead.
180
+ */
181
+ export function isEntryPoint(entry, moduleUrl) {
182
+ if (entry === undefined)
183
+ return false;
184
+ try {
185
+ return pathToFileURL(realpathSync(entry)).href === pathToFileURL(realpathSync(fileURLToPath(moduleUrl))).href;
186
+ }
187
+ catch {
188
+ return false;
189
+ }
190
+ }
191
+ if (isEntryPoint(process.argv[1], import.meta.url)) {
192
+ process.exitCode = await main(process.argv);
193
+ }
194
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACxD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,OA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,CAAC;QAC5F,gGAAgG;QAChG,4FAA4F;QAC5F,yEAAyE;QACzE,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,YAAY,CAAC,KAAyB,EAAE,SAAiB;IACvE,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACtC,IAAI,CAAC;QACH,OAAO,aAAa,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,aAAa,CAAC,YAAY,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAChH,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,IAAI,YAAY,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IACnD,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,44 @@
1
+ import type { Plan } from "@horizon36596/zenith-core";
2
+ import { type CommandLibrary } from "./commandLibrary.js";
3
+ /**
4
+ * `zenith codegen`: a readable Java class a student can read as the plan
5
+ * (site/docs/robot-runtime.md, "Generated Java"). It is derived and never edited; the file
6
+ * is the source of truth. It is an abstract subclass of the chosen runtime's `AutoFromFile`
7
+ * (`deploy.commandLibrary`, which has no default) that overrides `startPose()` and `buildRoutine()`,
8
+ * and every call here is against that runtime's real API (`PathMarkers`, `RobotTimeout`,
9
+ * `WaitRobotTime`, `NamedCommands`, `DeferredPath`, and the `AutoContext` methods `step`, `alliance`,
10
+ * `followPath` and `defaultSpeedFraction`, and `AutoFromFile`'s `headingRad` and `turnRad`), so a
11
+ * reader who goes looking for `PathMarkers.wrap` or `NamedCommands.build` finds them. Every pose goes
12
+ * through `alliance(...)` and every heading through `headingRad` and `turnRad`, so the class mirrors a
13
+ * file run as the other alliance exactly as the runtime's AutoBuilder does.
14
+ *
15
+ * The two forms build the same tree as their runtime's AutoBuilder. The SolversLib form
16
+ * (`org.horizon36596.zenith.solverslib`) uses SolversLib's `Pose2d`, converted with `Poses.toPedro`, and its
17
+ * `SequentialCommandGroup`, `ConditionalCommand`, `WaitUntilCommand` and `InstantCommand`. The Ivy
18
+ * form (`org.horizon36596.zenith.ivy`) uses Pedro's `Pose`, the runtime's `Sequence` and `Branch`, and
19
+ * Ivy's `Commands.waitUntil` and `Commands.instant`.
20
+ *
21
+ * A path whose first segment starts from `"current"` is written as `DeferredPath.of`, the call the
22
+ * runtime's AutoBuilder makes for such a step, so it is built when the step starts from the live pose.
23
+ * Only the numbers that come from the path's length (the segment lengths that place a marker anywhere
24
+ * but the start, a heading shared out by arc length) are the planned path's there, and the class
25
+ * says so.
26
+ *
27
+ * Deterministic: every number in the plan is already resolved (waypoints included), so the same
28
+ * auto and the same sha always produce byte-identical Java. No clock, no randomness.
29
+ */
30
+ export interface CodegenOptions {
31
+ /** Dotted Java package, e.g. `org.firstinspires.ftc.teamcode.opmode.Auto`. */
32
+ packageName: string;
33
+ /** Short hex digest of the source file's canonical bytes, printed in the header comment. */
34
+ shaHex: string;
35
+ /** The auto file's path as it should read in the header, e.g. `autos/first-auto.auto.json`. */
36
+ sourcePath: string;
37
+ /** `zenith.json` `deploy.commandLibrary`: which runtime the class is written against. */
38
+ commandLibrary: CommandLibrary;
39
+ }
40
+ /** `first-auto` -> `FirstAuto`; the class is `<Pascal>Generated`. */
41
+ export declare function pascalCase(name: string): string;
42
+ /** Renders the full generated class. Pure: every input is the plan's own numbers. */
43
+ export declare function generateAutoJava(plan: Plan, options: CodegenOptions): string;
44
+ //# sourceMappingURL=javaCodegen.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"javaCodegen.d.ts","sourceRoot":"","sources":["../src/javaCodegen.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAkB,MAAM,2BAA2B,CAAC;AAWtE,OAAO,EAAmB,KAAK,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE3E;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,MAAM,WAAW,cAAc;IAC7B,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,4FAA4F;IAC5F,MAAM,EAAE,MAAM,CAAC;IACf,+FAA+F;IAC/F,UAAU,EAAE,MAAM,CAAC;IACnB,yFAAyF;IACzF,cAAc,EAAE,cAAc,CAAC;CAChC;AAsFD,qEAAqE;AACrE,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAM/C;AAweD,qFAAqF;AACrF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,cAAc,GAAG,MAAM,CAgD5E"}