pi-mega-compact 0.20.72 → 0.20.74

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 (75) hide show
  1. package/dist/extensions/dashboard-server/routes-setup-cortex-actions.js +7 -0
  2. package/dist/extensions/dashboard-server/routes-setup-enc2a.js +21 -5
  3. package/dist/extensions/dashboard-server/routes-setup-enc2b.js +53 -2
  4. package/dist/extensions/dashboard-server/routes-vector-cortex-helpers.js +8 -0
  5. package/dist/src/vector-cortex/encoder/native-qualify-retest.js +25 -9
  6. package/dist/vector-cortex/encoder/native-qualify-retest.js +25 -9
  7. package/extensions/dashboard-client/dist/assets/{AdminTab-ZyVtgYrZ.js → AdminTab-CqhIxrlT.js} +2 -2
  8. package/extensions/dashboard-client/dist/assets/{AdminTab-ZyVtgYrZ.js.map → AdminTab-CqhIxrlT.js.map} +1 -1
  9. package/extensions/dashboard-client/dist/assets/{AreaChart-7ms8Hk1m.js → AreaChart-D4EY7yiY.js} +2 -2
  10. package/extensions/dashboard-client/dist/assets/{AreaChart-7ms8Hk1m.js.map → AreaChart-D4EY7yiY.js.map} +1 -1
  11. package/extensions/dashboard-client/dist/assets/{BarChart-DeTE0NXA.js → BarChart-r_BFpd7a.js} +2 -2
  12. package/extensions/dashboard-client/dist/assets/{BarChart-DeTE0NXA.js.map → BarChart-r_BFpd7a.js.map} +1 -1
  13. package/extensions/dashboard-client/dist/assets/{CacheTab-CpIrpr_X.js → CacheTab-Bf5rwce6.js} +2 -2
  14. package/extensions/dashboard-client/dist/assets/{CacheTab-CpIrpr_X.js.map → CacheTab-Bf5rwce6.js.map} +1 -1
  15. package/extensions/dashboard-client/dist/assets/{ConfigTab-BNMrO7uz.js → ConfigTab-RFUXAUIP.js} +2 -2
  16. package/extensions/dashboard-client/dist/assets/{ConfigTab-BNMrO7uz.js.map → ConfigTab-RFUXAUIP.js.map} +1 -1
  17. package/extensions/dashboard-client/dist/assets/{EventsTab-j42vDTjs.js → EventsTab-DEqHbSHf.js} +2 -2
  18. package/extensions/dashboard-client/dist/assets/{EventsTab-j42vDTjs.js.map → EventsTab-DEqHbSHf.js.map} +1 -1
  19. package/extensions/dashboard-client/dist/assets/{HealthTab-D0Tf8XM_.js → HealthTab-WGEwtqmO.js} +2 -2
  20. package/extensions/dashboard-client/dist/assets/{HealthTab-D0Tf8XM_.js.map → HealthTab-WGEwtqmO.js.map} +1 -1
  21. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-CleWX_RM.js → MaintenanceTab-ClT1D4P9.js} +2 -2
  22. package/extensions/dashboard-client/dist/assets/{MaintenanceTab-CleWX_RM.js.map → MaintenanceTab-ClT1D4P9.js.map} +1 -1
  23. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-LUpPJzNP.js → MemoryMapTab-DaAxLJ5x.js} +2 -2
  24. package/extensions/dashboard-client/dist/assets/{MemoryMapTab-LUpPJzNP.js.map → MemoryMapTab-DaAxLJ5x.js.map} +1 -1
  25. package/extensions/dashboard-client/dist/assets/{MetricsCards-G4_uynTE.js → MetricsCards-CprVx2Yq.js} +2 -2
  26. package/extensions/dashboard-client/dist/assets/{MetricsCards-G4_uynTE.js.map → MetricsCards-CprVx2Yq.js.map} +1 -1
  27. package/extensions/dashboard-client/dist/assets/MetricsTab-8WBHRpRp.js +2 -0
  28. package/extensions/dashboard-client/dist/assets/{MetricsTab-yypKMQXf.js.map → MetricsTab-8WBHRpRp.js.map} +1 -1
  29. package/extensions/dashboard-client/dist/assets/{OverviewTab-M47NMRaT.js → OverviewTab-C5ClXheK.js} +2 -2
  30. package/extensions/dashboard-client/dist/assets/{OverviewTab-M47NMRaT.js.map → OverviewTab-C5ClXheK.js.map} +1 -1
  31. package/extensions/dashboard-client/dist/assets/{ReposTab-BX3ZxrAI.js → ReposTab-BOX5sOBg.js} +2 -2
  32. package/extensions/dashboard-client/dist/assets/{ReposTab-BX3ZxrAI.js.map → ReposTab-BOX5sOBg.js.map} +1 -1
  33. package/extensions/dashboard-client/dist/assets/{SessionsTab-CSUmsNeZ.js → SessionsTab-DKUO5gCp.js} +2 -2
  34. package/extensions/dashboard-client/dist/assets/{SessionsTab-CSUmsNeZ.js.map → SessionsTab-DKUO5gCp.js.map} +1 -1
  35. package/extensions/dashboard-client/dist/assets/{SetupTab-jF9BsQjw.js → SetupTab-CeeRk5Rd.js} +3 -3
  36. package/extensions/dashboard-client/dist/assets/{SetupTab-jF9BsQjw.js.map → SetupTab-CeeRk5Rd.js.map} +1 -1
  37. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-qfwO1WJ3.js → TimeSavedCard-Dlhljae9.js} +2 -2
  38. package/extensions/dashboard-client/dist/assets/{TimeSavedCard-qfwO1WJ3.js.map → TimeSavedCard-Dlhljae9.js.map} +1 -1
  39. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-C7NQo_xi.js → TurnMemoryView-B8fWymMP.js} +2 -2
  40. package/extensions/dashboard-client/dist/assets/{TurnMemoryView-C7NQo_xi.js.map → TurnMemoryView-B8fWymMP.js.map} +1 -1
  41. package/extensions/dashboard-client/dist/assets/TurnsTab-kJ4sfWSd.js +2 -0
  42. package/extensions/dashboard-client/dist/assets/{TurnsTab-D-19giqQ.js.map → TurnsTab-kJ4sfWSd.js.map} +1 -1
  43. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-DTHlwuUJ.js → VcStatusBadge-FJZlkrD7.js} +2 -2
  44. package/extensions/dashboard-client/dist/assets/{VcStatusBadge-DTHlwuUJ.js.map → VcStatusBadge-FJZlkrD7.js.map} +1 -1
  45. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-Dvgdcwvs.js → VectorCortexTab-C1iE6z4c.js} +2 -2
  46. package/extensions/dashboard-client/dist/assets/{VectorCortexTab-Dvgdcwvs.js.map → VectorCortexTab-C1iE6z4c.js.map} +1 -1
  47. package/extensions/dashboard-client/dist/assets/{WikiTab-CYUEAQmZ.js → WikiTab-BXqRiTbt.js} +2 -2
  48. package/extensions/dashboard-client/dist/assets/{WikiTab-CYUEAQmZ.js.map → WikiTab-BXqRiTbt.js.map} +1 -1
  49. package/extensions/dashboard-client/dist/assets/{button-DPOwTRN8.js → button-CUeN3VyF.js} +2 -2
  50. package/extensions/dashboard-client/dist/assets/{button-DPOwTRN8.js.map → button-CUeN3VyF.js.map} +1 -1
  51. package/extensions/dashboard-client/dist/assets/{card-CUipkgi9.js → card-DtOD33bZ.js} +2 -2
  52. package/extensions/dashboard-client/dist/assets/{card-CUipkgi9.js.map → card-DtOD33bZ.js.map} +1 -1
  53. package/extensions/dashboard-client/dist/assets/{client-extra-9lcKX-iO.js → client-extra-_tIKSPZ3.js} +2 -2
  54. package/extensions/dashboard-client/dist/assets/{client-extra-9lcKX-iO.js.map → client-extra-_tIKSPZ3.js.map} +1 -1
  55. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-_WpiJebf.js → generateCategoricalChart-8AyWGIrK.js} +2 -2
  56. package/extensions/dashboard-client/dist/assets/{generateCategoricalChart-_WpiJebf.js.map → generateCategoricalChart-8AyWGIrK.js.map} +1 -1
  57. package/extensions/dashboard-client/dist/assets/{index-DlHJ7LBL.js → index-BBJ8LglL.js} +3 -3
  58. package/extensions/dashboard-client/dist/assets/{index-DlHJ7LBL.js.map → index-BBJ8LglL.js.map} +1 -1
  59. package/extensions/dashboard-client/dist/assets/{switch-Cx6-1wnT.js → switch-Drm0yRgr.js} +2 -2
  60. package/extensions/dashboard-client/dist/assets/{switch-Cx6-1wnT.js.map → switch-Drm0yRgr.js.map} +1 -1
  61. package/extensions/dashboard-client/dist/assets/{toggle-Y3vbE0NG.js → toggle-DnRtZDPW.js} +2 -2
  62. package/extensions/dashboard-client/dist/assets/{toggle-Y3vbE0NG.js.map → toggle-DnRtZDPW.js.map} +1 -1
  63. package/extensions/dashboard-client/dist/assets/{useSSE-CnJdk56R.js → useSSE-l_bpRt_v.js} +2 -2
  64. package/extensions/dashboard-client/dist/assets/{useSSE-CnJdk56R.js.map → useSSE-l_bpRt_v.js.map} +1 -1
  65. package/extensions/dashboard-client/dist/index.html +1 -1
  66. package/extensions/dashboard-client/src/tabs/SetupTab/CortexRuntimeCard.tsx +6 -11
  67. package/extensions/dashboard-server/api-contracts/setup.ts +4 -2
  68. package/extensions/dashboard-server/routes-setup-cortex-actions.ts +7 -0
  69. package/extensions/dashboard-server/routes-setup-enc2a.ts +20 -10
  70. package/extensions/dashboard-server/routes-setup-enc2b.ts +53 -2
  71. package/extensions/dashboard-server/routes-vector-cortex-helpers.ts +8 -0
  72. package/package.json +1 -1
  73. package/src/vector-cortex/encoder/native-qualify-retest.ts +26 -10
  74. package/extensions/dashboard-client/dist/assets/MetricsTab-yypKMQXf.js +0 -2
  75. package/extensions/dashboard-client/dist/assets/TurnsTab-D-19giqQ.js +0 -2
@@ -26,6 +26,7 @@ import { VC9B_ENABLED, ENC_0G_ENABLED, ENC_0F_ENABLED, ENC_2C_ENABLED, } from ".
26
26
  import { setupCortexActionBlockers, computeSetupCortexBlockers } from "./setup-cortex-blockers.js";
27
27
  import { readEncoderManifest, detectPlatform } from "../../src/vector-cortex/encoder/asset.js";
28
28
  import { readQualificationRecord, encoderStateDir, } from "./qualification-record.js";
29
+ import { readEnc2aGuide } from "./routes-setup-enc2a.js";
29
30
  import { runSetupCortexAction, readActionLogTail, } from "./setup-cortex-actions.js";
30
31
  const ACTION_KINDS = new Set([
31
32
  "fetch-model",
@@ -72,6 +73,12 @@ function liveActionBlockers() {
72
73
  platform: detectPlatform(),
73
74
  qualification: record,
74
75
  headCount,
76
+ // ENC-2c: the install action's HG-3 gate closes when the native binding is
77
+ // installed on this device. The action would be a no-op without this — a
78
+ // stale "open" HG-3 permanently blocks the install button even after the
79
+ // binding is on disk, because the compute default is nativeOrtInstalledVersion
80
+ // = null (not installed). Read the ENC-2a guide probe to get the true state.
81
+ nativeOrtInstalledVersion: readEnc2aGuide(encoderStateDir()).installedVersion,
75
82
  });
76
83
  }
77
84
  /** Flag-off response, byte-identical regardless of request (VC9B absent). */
@@ -37,8 +37,13 @@ import { NATIVE_ORT_VERSION, NATIVE_ORT_PACKAGE, NATIVE_ORT_INSTALLABLE_PLATFORM
37
37
  /** The committed operator script that performs the install (repo-relative). */
38
38
  const ENC_2A_SCRIPT_PATH = "scripts/encoder/install-native-ort.mjs";
39
39
  /** Where the operator script installs the native binding (absolute install
40
- * prefix used verbatim in the guide commands + the version probe). */
40
+ * prefix used verbatim in the guide commands + the version probe). The
41
+ * MEGACOMPACT_NATIVE_ORT_ROOT override exists so tests can point at an empty
42
+ * dir (isolation from a globally-installed binding). */
41
43
  function nativeOrtDir() {
44
+ const override = process.env.MEGACOMPACT_NATIVE_ORT_ROOT;
45
+ if (override !== undefined && override.length > 0)
46
+ return override;
42
47
  return join(process.env.HOME ?? "", ".pi", "mega-compact", "native-ort");
43
48
  }
44
49
  /**
@@ -96,13 +101,24 @@ export function readEnc2aGuide(stateDir) {
96
101
  scriptPath: ENC_2A_SCRIPT_PATH,
97
102
  };
98
103
  }
99
- return { guide, installedVersion: probeInstalledVersion() };
104
+ return { guide, installedVersion: probeInstalledVersion(stateDir) };
100
105
  }
101
106
  /** Probe the local native-ort package.json for the installed onnxruntime-node
102
- * version. Null when the package is absent/unreadable (reader-only, local). */
103
- function probeInstalledVersion() {
107
+ * version. Probes `<stateDir>/native-ort/` first (test isolation), then the
108
+ * global `~/.pi/mega-compact/native-ort/`. Null when the package is
109
+ * absent/unreadable in both roots (reader-only, local). */
110
+ function probeInstalledVersion(stateDir) {
111
+ for (const root of [join(stateDir, "native-ort"), nativeOrtDir()]) {
112
+ const v = probeVersionAt(root);
113
+ if (v !== null)
114
+ return v;
115
+ }
116
+ return null;
117
+ }
118
+ /** Version probe for one candidate root. */
119
+ function probeVersionAt(root) {
104
120
  try {
105
- const pkgPath = join(nativeOrtDir(), "node_modules", NATIVE_ORT_PACKAGE, "package.json");
121
+ const pkgPath = join(root, "node_modules", NATIVE_ORT_PACKAGE, "package.json");
106
122
  if (!existsSync(pkgPath))
107
123
  return null;
108
124
  const raw = JSON.parse(readFileSync(pkgPath, "utf8"));
@@ -26,8 +26,12 @@
26
26
  * Guardrails: PREVENT-PI-004 (local filesystem + in-process binding load only,
27
27
  * zero network — the retest NEVER fetches), PREVENT-011 (no `any`).
28
28
  */
29
+ import { writeFileSync, renameSync, mkdirSync } from "node:fs";
30
+ import { join } from "node:path";
29
31
  import { ENC_2B_ENABLED } from "../../src/config/vector-cortex.js";
30
32
  import { runNativeRetest, } from "../../src/vector-cortex/encoder/native-qualify-retest.js";
33
+ import { Logger } from "../../src/log.js";
34
+ import { encoderStateDir } from "./qualification-record.js";
31
35
  /**
32
36
  * Resolve the ENC-2b additive GET fields. Returns BOTH fields when the flag is
33
37
  * on AND a native binding is installed (the retest ran); returns `{}` on
@@ -43,6 +47,11 @@ export async function readEnc2bRetest(stateDir) {
43
47
  const result = await runNativeRetest(stateDir);
44
48
  if (result === null)
45
49
  return {};
50
+ // Auto-persist a qualified verdict so the ENC-0g read path + HG-5 pick up the
51
+ // native result automatically — the operator does not need to click "Retest
52
+ // now" for the record to update. Degraded/failed never overwrite.
53
+ if (result.verdict === "qualified")
54
+ persistQualifiedRecord(result);
46
55
  return {
47
56
  nativeOrtRetestResult: result,
48
57
  nativeOrtBackendEffective: result.verdict === "qualified" ? "native" : "wasm",
@@ -65,13 +74,55 @@ export function enc2bRetestRequest(body) {
65
74
  return "reject";
66
75
  return null;
67
76
  }
77
+ /**
78
+ * Atomically write a fresh `qualified` QualificationV1 record back to
79
+ * <stateDir>/encoder-qualification.json. This closes the ENC-2b loop: native
80
+ * install → retest qualifies → the HG-5 source-of-truth record is overwritten
81
+ * so the runtime can select mode A. Best-effort (PREVENT-PI-004 local FS only;
82
+ * never throws into the route). Only ever invoked on a `qualified` verdict —
83
+ * a `degraded`/`failed` retest never sweeps into the record (the incumbent
84
+ * verdict stands).
85
+ */
86
+ export function persistQualifiedRecord(result) {
87
+ const record = {
88
+ schema: "qualification-v1",
89
+ verdict: "qualified",
90
+ reasons: [],
91
+ platform: result.platform,
92
+ p95Ms: result.p95Ms,
93
+ rssMib: result.rssMiB,
94
+ opset: 21,
95
+ digest: "",
96
+ };
97
+ const dir = encoderStateDir();
98
+ const finalPath = join(dir, "encoder-qualification.json");
99
+ const tmpPath = join(dir, `encoder-qualification.json.tmp-${process.pid}`);
100
+ try {
101
+ // guardrails-allow PREVENT-PI-004: local qualification-record write (loopback)
102
+ mkdirSync(dir, { recursive: true });
103
+ writeFileSync(tmpPath, `${JSON.stringify(record, null, 2)}\n`, "utf8");
104
+ renameSync(tmpPath, finalPath);
105
+ }
106
+ catch (err) {
107
+ // Best-effort: log + continue — a persist failure must never break the route.
108
+ new Logger().warn("enc2b_qualification_record_persist_failed", {
109
+ error: String(err),
110
+ verdict: result.verdict,
111
+ });
112
+ }
113
+ }
68
114
  /**
69
115
  * Run the ENC-2b retest now (bounded, synchronous on the request) and return
70
116
  * the fresh result. Flag-off or no binding → null. Used by the POST "run"
71
- * branch; the result is returned on the response body, never persisted.
117
+ * branch; the result is returned on the response body. When the retest
118
+ * qualifies, the qualification record is atomically updated (side-effect).
72
119
  */
73
120
  export async function runEnc2bRetest(stateDir) {
74
121
  if (!ENC_2B_ENABLED())
75
122
  return null;
76
- return runNativeRetest(stateDir);
123
+ const result = await runNativeRetest(stateDir);
124
+ if (result !== null && result.verdict === "qualified") {
125
+ persistQualifiedRecord(result);
126
+ }
127
+ return result;
77
128
  }
@@ -63,6 +63,14 @@ export async function withServer(port, dir, fn) {
63
63
  env: {
64
64
  ...process.env,
65
65
  MEGACOMPACT_INDEX_DIR: dir,
66
+ // Forward test-isolation overrides so the spawned server's readers
67
+ // resolve to the test temp dir, not the operator's global install.
68
+ ...(process.env.MEGACOMPACT_STATE_DIR !== undefined
69
+ ? { MEGACOMPACT_STATE_DIR: process.env.MEGACOMPACT_STATE_DIR }
70
+ : {}),
71
+ ...(process.env.MEGACOMPACT_NATIVE_ORT_ROOT !== undefined
72
+ ? { MEGACOMPACT_NATIVE_ORT_ROOT: process.env.MEGACOMPACT_NATIVE_ORT_ROOT }
73
+ : {}),
66
74
  },
67
75
  });
68
76
  try {
@@ -28,7 +28,9 @@
28
28
  * Pi-agnostic, dependency-free. No `any` (PREVENT-011).
29
29
  */
30
30
  import { readFileSync, existsSync } from "node:fs";
31
- import { join } from "node:path";
31
+ import { join, dirname } from "node:path";
32
+ import { homedir, cpus } from "node:os";
33
+ import { fileURLToPath } from "node:url";
32
34
  import { ENCODER_LATENCY_P95_MS, ENCODER_MAX_TOKENS } from "./types.js";
33
35
  import { installBudgetMib } from "./decision.js";
34
36
  import { detectPlatform } from "./asset.js";
@@ -93,13 +95,24 @@ function readInstalledVersion(pkgJsonPath) {
93
95
  return null;
94
96
  }
95
97
  }
96
- /** Locate a LOCAL onnx model to probe against, under the native-ort roots.
97
- * Null when none exists (the retest cannot qualify without a probe target). */
98
+ /** Locate a LOCAL onnx model to probe against. Probes the native-ort root, the
99
+ * stateDir, the repo asset dir (walk-up from this module), and the installed
100
+ * extension dir. Null when none exists. */
98
101
  function findLocalModel(stateDir) {
99
102
  const candidates = [
100
103
  join(nativeOrtRootCandidates(stateDir)[0], "model.onnx"),
101
104
  join(stateDir, "model.onnx"),
105
+ join(homedir(), ".pi", "agent", "npm", "node_modules", "pi-mega-compact", "assets", "vector-cortex", "encoder-v1", "model.onnx"),
102
106
  ];
107
+ // Walk up from this module's location looking for the repo asset dir.
108
+ let dir = dirname(fileURLToPath(import.meta.url));
109
+ for (let i = 0; i < 8; i++) {
110
+ candidates.push(join(dir, "assets", "vector-cortex", "encoder-v1", "model.onnx"));
111
+ const next = dirname(dir);
112
+ if (next === dir)
113
+ break;
114
+ dir = next;
115
+ }
103
116
  for (const c of candidates) {
104
117
  if (existsSync(c))
105
118
  return c;
@@ -141,13 +154,16 @@ export async function runNativeRetest(stateDir) {
141
154
  };
142
155
  }
143
156
  // Load the LOCAL binding via dynamic import. Load failure -> failed verdict.
157
+ // onnxruntime-node's package.json "main" is "dist/index.js" (the compiled JS
158
+ // that loads the native .node binding). Fall back to the bare package import
159
+ // (resolves via the installed node_modules resolution) as a secondary path.
144
160
  let ort;
145
161
  try {
146
- ort = await import(join(rootDir, "lib", "index.js"));
162
+ ort = await import(join(rootDir, "dist", "index.js"));
147
163
  }
148
164
  catch {
149
165
  try {
150
- ort = await import(join(rootDir, "dist", "ort.node.mjs"));
166
+ ort = await import(join(rootDir));
151
167
  }
152
168
  catch {
153
169
  return {
@@ -177,18 +193,18 @@ export async function runNativeRetest(stateDir) {
177
193
  const factory = ort;
178
194
  const session = await factory.InferenceSession.create(modelPath, {
179
195
  executionProviders: ["cpu"],
180
- intraOpNumThreads: 4,
196
+ intraOpNumThreads: Math.min(8, Math.max(1, cpus().length - 1)),
181
197
  graphOptimizationLevel: "all",
182
198
  });
183
199
  const n = ENCODER_MAX_TOKENS;
184
200
  const ids = BigInt64Array.from({ length: n }, (_, i) => BigInt(i === 0 ? 101 : i === n - 1 ? 102 : 2000 + (i % 500)));
185
201
  const mask = BigInt64Array.from({ length: n }, () => 1n);
186
202
  const types = new BigInt64Array(n);
187
- // Bounded warmup (3 passes) + 10 timed passes.
188
- for (let i = 0; i < 3; i++)
203
+ // Bounded warmup (10 passes) + 30 timed passes for a stable p95.
204
+ for (let i = 0; i < 10; i++)
189
205
  await timedPass(ort, session, ids, mask, types);
190
206
  const lat = [];
191
- for (let i = 0; i < 10; i++) {
207
+ for (let i = 0; i < 30; i++) {
192
208
  const ms = await timedPass(ort, session, ids, mask, types);
193
209
  if (ms === null)
194
210
  break;
@@ -28,7 +28,9 @@
28
28
  * Pi-agnostic, dependency-free. No `any` (PREVENT-011).
29
29
  */
30
30
  import { readFileSync, existsSync } from "node:fs";
31
- import { join } from "node:path";
31
+ import { join, dirname } from "node:path";
32
+ import { homedir, cpus } from "node:os";
33
+ import { fileURLToPath } from "node:url";
32
34
  import { ENCODER_LATENCY_P95_MS, ENCODER_MAX_TOKENS } from "./types.js";
33
35
  import { installBudgetMib } from "./decision.js";
34
36
  import { detectPlatform } from "./asset.js";
@@ -93,13 +95,24 @@ function readInstalledVersion(pkgJsonPath) {
93
95
  return null;
94
96
  }
95
97
  }
96
- /** Locate a LOCAL onnx model to probe against, under the native-ort roots.
97
- * Null when none exists (the retest cannot qualify without a probe target). */
98
+ /** Locate a LOCAL onnx model to probe against. Probes the native-ort root, the
99
+ * stateDir, the repo asset dir (walk-up from this module), and the installed
100
+ * extension dir. Null when none exists. */
98
101
  function findLocalModel(stateDir) {
99
102
  const candidates = [
100
103
  join(nativeOrtRootCandidates(stateDir)[0], "model.onnx"),
101
104
  join(stateDir, "model.onnx"),
105
+ join(homedir(), ".pi", "agent", "npm", "node_modules", "pi-mega-compact", "assets", "vector-cortex", "encoder-v1", "model.onnx"),
102
106
  ];
107
+ // Walk up from this module's location looking for the repo asset dir.
108
+ let dir = dirname(fileURLToPath(import.meta.url));
109
+ for (let i = 0; i < 8; i++) {
110
+ candidates.push(join(dir, "assets", "vector-cortex", "encoder-v1", "model.onnx"));
111
+ const next = dirname(dir);
112
+ if (next === dir)
113
+ break;
114
+ dir = next;
115
+ }
103
116
  for (const c of candidates) {
104
117
  if (existsSync(c))
105
118
  return c;
@@ -141,13 +154,16 @@ export async function runNativeRetest(stateDir) {
141
154
  };
142
155
  }
143
156
  // Load the LOCAL binding via dynamic import. Load failure -> failed verdict.
157
+ // onnxruntime-node's package.json "main" is "dist/index.js" (the compiled JS
158
+ // that loads the native .node binding). Fall back to the bare package import
159
+ // (resolves via the installed node_modules resolution) as a secondary path.
144
160
  let ort;
145
161
  try {
146
- ort = await import(join(rootDir, "lib", "index.js"));
162
+ ort = await import(join(rootDir, "dist", "index.js"));
147
163
  }
148
164
  catch {
149
165
  try {
150
- ort = await import(join(rootDir, "dist", "ort.node.mjs"));
166
+ ort = await import(join(rootDir));
151
167
  }
152
168
  catch {
153
169
  return {
@@ -177,18 +193,18 @@ export async function runNativeRetest(stateDir) {
177
193
  const factory = ort;
178
194
  const session = await factory.InferenceSession.create(modelPath, {
179
195
  executionProviders: ["cpu"],
180
- intraOpNumThreads: 4,
196
+ intraOpNumThreads: Math.min(8, Math.max(1, cpus().length - 1)),
181
197
  graphOptimizationLevel: "all",
182
198
  });
183
199
  const n = ENCODER_MAX_TOKENS;
184
200
  const ids = BigInt64Array.from({ length: n }, (_, i) => BigInt(i === 0 ? 101 : i === n - 1 ? 102 : 2000 + (i % 500)));
185
201
  const mask = BigInt64Array.from({ length: n }, () => 1n);
186
202
  const types = new BigInt64Array(n);
187
- // Bounded warmup (3 passes) + 10 timed passes.
188
- for (let i = 0; i < 3; i++)
203
+ // Bounded warmup (10 passes) + 30 timed passes for a stable p95.
204
+ for (let i = 0; i < 10; i++)
189
205
  await timedPass(ort, session, ids, mask, types);
190
206
  const lat = [];
191
- for (let i = 0; i < 10; i++) {
207
+ for (let i = 0; i < 30; i++) {
192
208
  const ms = await timedPass(ort, session, ids, mask, types);
193
209
  if (ms === null)
194
210
  break;
@@ -1,2 +1,2 @@
1
- import{r as s,u as o,e as c,j as e}from"./index-DlHJ7LBL.js";import{T as i}from"./toggle-Y3vbE0NG.js";import r from"./MaintenanceTab-CleWX_RM.js";import{C as l}from"./ConfigTab-BNMrO7uz.js";import"./card-CUipkgi9.js";import"./button-DPOwTRN8.js";import"./switch-Cx6-1wnT.js";const f="MEGACOMPACT_DASH_0C";function m(n){if(!n)return!1;for(const t of n.categories)for(const a of t.settings)if(a.key===f&&a.type==="boolean")return a.value===!0;return!1}function h(){const[n,t]=s.useState("maintenance"),{data:a}=o(s.useCallback(()=>c(),[]),{pollInterval:0,maxRetries:0});return m(a)?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",role:"tablist","aria-label":"Admin views",children:[e.jsx(i,{pressed:n==="maintenance",onClick:()=>t("maintenance"),children:"Maintenance"}),e.jsx(i,{pressed:n==="config",onClick:()=>t("config"),children:"Config"})]}),n==="maintenance"?e.jsx(r,{}):e.jsx(l,{})]}):e.jsx(r,{})}export{h as default};
2
- //# sourceMappingURL=AdminTab-ZyVtgYrZ.js.map
1
+ import{r as s,u as o,e as c,j as e}from"./index-BBJ8LglL.js";import{T as i}from"./toggle-DnRtZDPW.js";import r from"./MaintenanceTab-ClT1D4P9.js";import{C as l}from"./ConfigTab-RFUXAUIP.js";import"./card-DtOD33bZ.js";import"./button-CUeN3VyF.js";import"./switch-Drm0yRgr.js";const f="MEGACOMPACT_DASH_0C";function m(n){if(!n)return!1;for(const t of n.categories)for(const a of t.settings)if(a.key===f&&a.type==="boolean")return a.value===!0;return!1}function h(){const[n,t]=s.useState("maintenance"),{data:a}=o(s.useCallback(()=>c(),[]),{pollInterval:0,maxRetries:0});return m(a)?e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"flex items-center gap-2",role:"tablist","aria-label":"Admin views",children:[e.jsx(i,{pressed:n==="maintenance",onClick:()=>t("maintenance"),children:"Maintenance"}),e.jsx(i,{pressed:n==="config",onClick:()=>t("config"),children:"Config"})]}),n==="maintenance"?e.jsx(r,{}):e.jsx(l,{})]}):e.jsx(r,{})}export{h as default};
2
+ //# sourceMappingURL=AdminTab-CqhIxrlT.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AdminTab-ZyVtgYrZ.js","sources":["../../src/tabs/AdminTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/tabs/AdminTab.tsx — Admin tab (DASH-0c delegate-shell).\n *\n * DASH-0c: the Admin surface combines the maintenance actions with the config\n * editor. A `AdminViews` toggle (\"maintenance\" / \"config\") switches between\n * `MaintenanceTab` (the maintenance shell over MaintenanceTab/*) and `ConfigTab`\n * (the config editor). Both bodies are UNCHANGED — only their hosting changes to\n * this new delegate-shell. `MaintenanceTab.tsx` and `ConfigTab.tsx` stay importable\n * from their original hosts (`ConfigTab` also stays wired into SetupTab per the\n * dual-host note). Flag-ON renders the toggle + both views; flag-OFF renders only\n * the maintenance view (the predecessor's `admin → MaintenanceTab` mapping),\n * and App.tsx keeps its current TabId routing this sprint (DASH-0d rewires).\n *\n * Flag: `MEGACOMPACT_DASH_0C` default ON. The dashboard client is a browser\n * bundle with NO `process` global, so the positive sprint flag cannot be read\n * server-side-style (`process.env`) inside the client. Instead the flag is read\n * from the server-authoritative `/api/rag-settings` state: the server resolves\n * `process.env[\"MEGACOMPACT_DASH_0C\"] ?? default` into the `SettingState.value`\n * boolean.\n */\n\nimport type React from \"react\";\nimport { useCallback, useState } from \"react\";\nimport type { SettingsResponse } from \"@contracts\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchSettings } from \"../api/client\";\nimport { Toggle } from \"../components/ui/toggle\";\nimport MaintenanceTab from \"./MaintenanceTab\";\nimport ConfigTab from \"./ConfigTab\";\n\nconst DASH_0C_KEY = \"MEGACOMPACT_DASH_0C\";\n\n/** Resolve the DASH-0c consolidation flag from the server settings state.\n * Absent/not-yet-loaded => false (flag-off posture), so flag-off users never\n * see the toggle flash; the toggle appears only once settings confirm it is ON. */\nfunction dash0cEnabled(settings: SettingsResponse | null): boolean {\n\tif (!settings) return false;\n\tfor (const cat of settings.categories) {\n\t\tfor (const s of cat.settings) {\n\t\t\tif (s.key === DASH_0C_KEY && s.type === \"boolean\") return s.value === true;\n\t\t}\n\t}\n\treturn false;\n}\n\ntype AdminViews = \"maintenance\" | \"config\";\n\nexport default function AdminTab(): React.ReactElement {\n\tconst [view, setView] = useState<AdminViews>(\"maintenance\");\n\n\tconst { data: settingsData } = useApi<SettingsResponse>(\n\t\tuseCallback(() => fetchSettings(), []),\n\t\t{ pollInterval: 0, maxRetries: 0 },\n\t);\n\tconst dash0cOn = dash0cEnabled(settingsData);\n\n\tif (!dash0cOn) {\n\t\treturn <MaintenanceTab />;\n\t}\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t<div\n\t\t\t\tclassName=\"flex items-center gap-2\"\n\t\t\t\trole=\"tablist\"\n\t\t\t\taria-label=\"Admin views\"\n\t\t\t>\n\t\t\t\t<Toggle\n\t\t\t\t\tpressed={view === \"maintenance\"}\n\t\t\t\t\tonClick={() => setView(\"maintenance\")}\n\t\t\t\t>\n\t\t\t\t\tMaintenance\n\t\t\t\t</Toggle>\n\t\t\t\t<Toggle pressed={view === \"config\"} onClick={() => setView(\"config\")}>\n\t\t\t\t\tConfig\n\t\t\t\t</Toggle>\n\t\t\t</div>\n\t\t\t{view === \"maintenance\" ? <MaintenanceTab /> : <ConfigTab />}\n\t\t</div>\n\t);\n}\n"],"names":["DASH_0C_KEY","dash0cEnabled","settings","cat","s","AdminTab","view","setView","useState","settingsData","useApi","useCallback","fetchSettings","jsxs","jsx","Toggle","MaintenanceTab","ConfigTab"],"mappings":"mRA8BA,MAAMA,EAAc,sBAKpB,SAASC,EAAcC,EAA4C,CAClE,GAAI,CAACA,EAAU,MAAO,GACtB,UAAWC,KAAOD,EAAS,WAC1B,UAAWE,KAAKD,EAAI,SACnB,GAAIC,EAAE,MAAQJ,GAAeI,EAAE,OAAS,UAAW,OAAOA,EAAE,QAAU,GAGxE,MAAO,EACR,CAIA,SAAwBC,GAA+B,CACtD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAqB,aAAa,EAEpD,CAAE,KAAMC,CAAA,EAAiBC,EAC9BC,cAAY,IAAMC,EAAA,EAAiB,EAAE,EACrC,CAAE,aAAc,EAAG,WAAY,CAAA,CAAE,EAIlC,OAFiBX,EAAcQ,CAAY,EAO1CI,EAAAA,KAAC,MAAA,CAAI,UAAU,sBACd,SAAA,CAAAA,EAAAA,KAAC,MAAA,CACA,UAAU,0BACV,KAAK,UACL,aAAW,cAEX,SAAA,CAAAC,EAAAA,IAACC,EAAA,CACA,QAAST,IAAS,cAClB,QAAS,IAAMC,EAAQ,aAAa,EACpC,SAAA,aAAA,CAAA,EAGDO,EAAAA,IAACC,EAAA,CAAO,QAAST,IAAS,SAAU,QAAS,IAAMC,EAAQ,QAAQ,EAAG,SAAA,QAAA,CAEtE,CAAA,CAAA,CAAA,EAEAD,IAAS,cAAgBQ,MAACE,EAAA,CAAA,CAAe,QAAMC,EAAA,CAAA,CAAU,CAAA,EAC3D,QArBQD,EAAA,EAAe,CAuBzB"}
1
+ {"version":3,"file":"AdminTab-CqhIxrlT.js","sources":["../../src/tabs/AdminTab.tsx"],"sourcesContent":["/**\n * dashboard-client/src/tabs/AdminTab.tsx — Admin tab (DASH-0c delegate-shell).\n *\n * DASH-0c: the Admin surface combines the maintenance actions with the config\n * editor. A `AdminViews` toggle (\"maintenance\" / \"config\") switches between\n * `MaintenanceTab` (the maintenance shell over MaintenanceTab/*) and `ConfigTab`\n * (the config editor). Both bodies are UNCHANGED — only their hosting changes to\n * this new delegate-shell. `MaintenanceTab.tsx` and `ConfigTab.tsx` stay importable\n * from their original hosts (`ConfigTab` also stays wired into SetupTab per the\n * dual-host note). Flag-ON renders the toggle + both views; flag-OFF renders only\n * the maintenance view (the predecessor's `admin → MaintenanceTab` mapping),\n * and App.tsx keeps its current TabId routing this sprint (DASH-0d rewires).\n *\n * Flag: `MEGACOMPACT_DASH_0C` default ON. The dashboard client is a browser\n * bundle with NO `process` global, so the positive sprint flag cannot be read\n * server-side-style (`process.env`) inside the client. Instead the flag is read\n * from the server-authoritative `/api/rag-settings` state: the server resolves\n * `process.env[\"MEGACOMPACT_DASH_0C\"] ?? default` into the `SettingState.value`\n * boolean.\n */\n\nimport type React from \"react\";\nimport { useCallback, useState } from \"react\";\nimport type { SettingsResponse } from \"@contracts\";\nimport { useApi } from \"../hooks/useApi\";\nimport { fetchSettings } from \"../api/client\";\nimport { Toggle } from \"../components/ui/toggle\";\nimport MaintenanceTab from \"./MaintenanceTab\";\nimport ConfigTab from \"./ConfigTab\";\n\nconst DASH_0C_KEY = \"MEGACOMPACT_DASH_0C\";\n\n/** Resolve the DASH-0c consolidation flag from the server settings state.\n * Absent/not-yet-loaded => false (flag-off posture), so flag-off users never\n * see the toggle flash; the toggle appears only once settings confirm it is ON. */\nfunction dash0cEnabled(settings: SettingsResponse | null): boolean {\n\tif (!settings) return false;\n\tfor (const cat of settings.categories) {\n\t\tfor (const s of cat.settings) {\n\t\t\tif (s.key === DASH_0C_KEY && s.type === \"boolean\") return s.value === true;\n\t\t}\n\t}\n\treturn false;\n}\n\ntype AdminViews = \"maintenance\" | \"config\";\n\nexport default function AdminTab(): React.ReactElement {\n\tconst [view, setView] = useState<AdminViews>(\"maintenance\");\n\n\tconst { data: settingsData } = useApi<SettingsResponse>(\n\t\tuseCallback(() => fetchSettings(), []),\n\t\t{ pollInterval: 0, maxRetries: 0 },\n\t);\n\tconst dash0cOn = dash0cEnabled(settingsData);\n\n\tif (!dash0cOn) {\n\t\treturn <MaintenanceTab />;\n\t}\n\n\treturn (\n\t\t<div className=\"flex flex-col gap-4\">\n\t\t\t<div\n\t\t\t\tclassName=\"flex items-center gap-2\"\n\t\t\t\trole=\"tablist\"\n\t\t\t\taria-label=\"Admin views\"\n\t\t\t>\n\t\t\t\t<Toggle\n\t\t\t\t\tpressed={view === \"maintenance\"}\n\t\t\t\t\tonClick={() => setView(\"maintenance\")}\n\t\t\t\t>\n\t\t\t\t\tMaintenance\n\t\t\t\t</Toggle>\n\t\t\t\t<Toggle pressed={view === \"config\"} onClick={() => setView(\"config\")}>\n\t\t\t\t\tConfig\n\t\t\t\t</Toggle>\n\t\t\t</div>\n\t\t\t{view === \"maintenance\" ? <MaintenanceTab /> : <ConfigTab />}\n\t\t</div>\n\t);\n}\n"],"names":["DASH_0C_KEY","dash0cEnabled","settings","cat","s","AdminTab","view","setView","useState","settingsData","useApi","useCallback","fetchSettings","jsxs","jsx","Toggle","MaintenanceTab","ConfigTab"],"mappings":"mRA8BA,MAAMA,EAAc,sBAKpB,SAASC,EAAcC,EAA4C,CAClE,GAAI,CAACA,EAAU,MAAO,GACtB,UAAWC,KAAOD,EAAS,WAC1B,UAAWE,KAAKD,EAAI,SACnB,GAAIC,EAAE,MAAQJ,GAAeI,EAAE,OAAS,UAAW,OAAOA,EAAE,QAAU,GAGxE,MAAO,EACR,CAIA,SAAwBC,GAA+B,CACtD,KAAM,CAACC,EAAMC,CAAO,EAAIC,EAAAA,SAAqB,aAAa,EAEpD,CAAE,KAAMC,CAAA,EAAiBC,EAC9BC,cAAY,IAAMC,EAAA,EAAiB,EAAE,EACrC,CAAE,aAAc,EAAG,WAAY,CAAA,CAAE,EAIlC,OAFiBX,EAAcQ,CAAY,EAO1CI,EAAAA,KAAC,MAAA,CAAI,UAAU,sBACd,SAAA,CAAAA,EAAAA,KAAC,MAAA,CACA,UAAU,0BACV,KAAK,UACL,aAAW,cAEX,SAAA,CAAAC,EAAAA,IAACC,EAAA,CACA,QAAST,IAAS,cAClB,QAAS,IAAMC,EAAQ,aAAa,EACpC,SAAA,aAAA,CAAA,EAGDO,EAAAA,IAACC,EAAA,CAAO,QAAST,IAAS,SAAU,QAAS,IAAMC,EAAQ,QAAQ,EAAG,SAAA,QAAA,CAEtE,CAAA,CAAA,CAAA,EAEAD,IAAS,cAAgBQ,MAACE,EAAA,CAAA,CAAe,QAAMC,EAAA,CAAA,CAAU,CAAA,EAC3D,QArBQD,EAAA,EAAe,CAuBzB"}
@@ -1,2 +1,2 @@
1
- import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-_WpiJebf.js";import{R as p,J as ee,r as ve}from"./index-DlHJ7LBL.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
- //# sourceMappingURL=AreaChart-7ms8Hk1m.js.map
1
+ import{b as R,c as W,m as T,i as C,d as F,A as ie,e as B,h as q,j as oe,k as G,l as se,n as le,u as ue,o as K,G as ce,p as J,q as Q,D as fe,g as pe,X as he,Y as de,f as me}from"./generateCategoricalChart-8AyWGIrK.js";import{R as p,J as ee,r as ve}from"./index-BBJ8LglL.js";var ye=["layout","type","stroke","connectNulls","isRange","ref"],be=["key"],te;function M(e){"@babel/helpers - typeof";return M=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},M(e)}function ae(e,t){if(e==null)return{};var r=Ae(e,t),a,n;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)a=i[n],!(t.indexOf(a)>=0)&&Object.prototype.propertyIsEnumerable.call(e,a)&&(r[a]=e[a])}return r}function Ae(e,t){if(e==null)return{};var r={};for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){if(t.indexOf(a)>=0)continue;r[a]=e[a]}return r}function D(){return D=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var a in r)Object.prototype.hasOwnProperty.call(r,a)&&(e[a]=r[a])}return e},D.apply(this,arguments)}function U(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable})),r.push.apply(r,a)}return r}function S(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?U(Object(r),!0).forEach(function(a){E(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):U(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function ge(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Z(e,t){for(var r=0;r<t.length;r++){var a=t[r];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(e,ne(a.key),a)}}function xe(e,t,r){return t&&Z(e.prototype,t),r&&Z(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function Pe(e,t,r){return t=$(t),Oe(e,re()?Reflect.construct(t,r||[],$(e).constructor):t.apply(e,r))}function Oe(e,t){if(t&&(M(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Ee(e)}function Ee(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function re(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(re=function(){return!!e})()}function $(e){return $=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(r){return r.__proto__||Object.getPrototypeOf(r)},$(e)}function we(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&X(e,t)}function X(e,t){return X=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,n){return a.__proto__=n,a},X(e,t)}function E(e,t,r){return t=ne(t),t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ne(e){var t=_e(e,"string");return M(t)=="symbol"?t:t+""}function _e(e,t){if(M(e)!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(M(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var L=function(e){function t(){var r;ge(this,t);for(var a=arguments.length,n=new Array(a),i=0;i<a;i++)n[i]=arguments[i];return r=Pe(this,t,[].concat(n)),E(r,"state",{isAnimationFinished:!0}),E(r,"id",ue("recharts-area-")),E(r,"handleAnimationEnd",function(){var o=r.props.onAnimationEnd;r.setState({isAnimationFinished:!0}),K(o)&&o()}),E(r,"handleAnimationStart",function(){var o=r.props.onAnimationStart;r.setState({isAnimationFinished:!1}),K(o)&&o()}),r}return we(t,e),xe(t,[{key:"renderDots",value:function(a,n,i){var o=this.props.isAnimationActive,s=this.state.isAnimationFinished;if(o&&!s)return null;var u=this.props,l=u.dot,f=u.points,c=u.dataKey,h=R(this.props,!1),A=R(l,!0),g=f.map(function(v,O){var y=S(S(S({key:"dot-".concat(O),r:3},h),A),{},{index:O,cx:v.x,cy:v.y,dataKey:c,value:v.value,payload:v.payload,points:f});return t.renderDotItem(l,y)}),x={clipPath:a?"url(#clipPath-".concat(n?"":"dots-").concat(i,")"):null};return p.createElement(W,D({className:"recharts-area-dots"},x),g)}},{key:"renderHorizontalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].x,l=o[o.length-1].x,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.y||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.y||0})),c)),C(c)?p.createElement("rect",{x:u<l?u:u-f,y:0,width:f,height:Math.floor(c+(s?parseInt("".concat(s),10):1))}):null}},{key:"renderVerticalRect",value:function(a){var n=this.props,i=n.baseLine,o=n.points,s=n.strokeWidth,u=o[0].y,l=o[o.length-1].y,f=a*Math.abs(u-l),c=T(o.map(function(h){return h.x||0}));return C(i)&&typeof i=="number"?c=Math.max(i,c):i&&Array.isArray(i)&&i.length&&(c=Math.max(T(i.map(function(h){return h.x||0})),c)),C(c)?p.createElement("rect",{x:0,y:u<l?u:u-f,width:c+(s?parseInt("".concat(s),10):1),height:Math.floor(f)}):null}},{key:"renderClipRect",value:function(a){var n=this.props.layout;return n==="vertical"?this.renderVerticalRect(a):this.renderHorizontalRect(a)}},{key:"renderAreaStatically",value:function(a,n,i,o){var s=this.props,u=s.layout,l=s.type,f=s.stroke,c=s.connectNulls,h=s.isRange;s.ref;var A=ae(s,ye);return p.createElement(W,{clipPath:i?"url(#clipPath-".concat(o,")"):null},p.createElement(F,D({},R(A,!0),{points:a,connectNulls:c,type:l,baseLine:n,layout:u,stroke:"none",className:"recharts-area-area"})),f!=="none"&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:a})),f!=="none"&&h&&p.createElement(F,D({},R(this.props,!1),{className:"recharts-area-curve",layout:u,type:l,connectNulls:c,fill:"none",points:n})))}},{key:"renderAreaWithAnimation",value:function(a,n){var i=this,o=this.props,s=o.points,u=o.baseLine,l=o.isAnimationActive,f=o.animationBegin,c=o.animationDuration,h=o.animationEasing,A=o.animationId,g=this.state,x=g.prevPoints,v=g.prevBaseLine;return p.createElement(ie,{begin:f,duration:c,isActive:l,easing:h,from:{t:0},to:{t:1},key:"area-".concat(A),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(O){var y=O.t;if(x){var _=x.length/s.length,d=s.map(function(P,N){var k=Math.floor(N*_);if(x[k]){var j=x[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P}),m;if(C(u)&&typeof u=="number"){var b=B(v,u);m=b(y)}else if(q(u)||oe(u)){var w=B(v,0);m=w(y)}else m=u.map(function(P,N){var k=Math.floor(N*_);if(v[k]){var j=v[k],I=B(j.x,P.x),V=B(j.y,P.y);return S(S({},P),{},{x:I(y),y:V(y)})}return P});return i.renderAreaStatically(d,m,a,n)}return p.createElement(W,null,p.createElement("defs",null,p.createElement("clipPath",{id:"animationClipPath-".concat(n)},i.renderClipRect(y))),p.createElement(W,{clipPath:"url(#animationClipPath-".concat(n,")")},i.renderAreaStatically(s,u,a,n)))})}},{key:"renderArea",value:function(a,n){var i=this.props,o=i.points,s=i.baseLine,u=i.isAnimationActive,l=this.state,f=l.prevPoints,c=l.prevBaseLine,h=l.totalLength;return u&&o&&o.length&&(!f&&h>0||!G(f,o)||!G(c,s))?this.renderAreaWithAnimation(a,n):this.renderAreaStatically(o,s,a,n)}},{key:"render",value:function(){var a,n=this.props,i=n.hide,o=n.dot,s=n.points,u=n.className,l=n.top,f=n.left,c=n.xAxis,h=n.yAxis,A=n.width,g=n.height,x=n.isAnimationActive,v=n.id;if(i||!s||!s.length)return null;var O=this.state.isAnimationFinished,y=s.length===1,_=ee("recharts-area",u),d=c&&c.allowDataOverflow,m=h&&h.allowDataOverflow,b=d||m,w=q(v)?this.id:v,P=(a=R(o,!1))!==null&&a!==void 0?a:{r:3,strokeWidth:2},N=P.r,k=N===void 0?3:N,j=P.strokeWidth,I=j===void 0?2:j,V=se(o)?o:{},Y=V.clipDot,H=Y===void 0?!0:Y,z=k*2+I;return p.createElement(W,{className:_},d||m?p.createElement("defs",null,p.createElement("clipPath",{id:"clipPath-".concat(w)},p.createElement("rect",{x:d?f:f-A/2,y:m?l:l-g/2,width:d?A:A*2,height:m?g:g*2})),!H&&p.createElement("clipPath",{id:"clipPath-dots-".concat(w)},p.createElement("rect",{x:f-z/2,y:l-z/2,width:A+z,height:g+z}))):null,y?null:this.renderArea(b,w),(o||y)&&this.renderDots(b,H,w),(!x||O)&&le.renderCallByParent(this.props,s))}}],[{key:"getDerivedStateFromProps",value:function(a,n){return a.animationId!==n.prevAnimationId?{prevAnimationId:a.animationId,curPoints:a.points,curBaseLine:a.baseLine,prevPoints:n.curPoints,prevBaseLine:n.curBaseLine}:a.points!==n.curPoints||a.baseLine!==n.curBaseLine?{curPoints:a.points,curBaseLine:a.baseLine}:null}}])}(ve.PureComponent);te=L;E(L,"displayName","Area");E(L,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ce.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});E(L,"getBaseValue",function(e,t,r,a){var n=e.layout,i=e.baseValue,o=t.props.baseValue,s=o??i;if(C(s)&&typeof s=="number")return s;var u=n==="horizontal"?a:r,l=u.scale.domain();if(u.type==="number"){var f=Math.max(l[0],l[1]),c=Math.min(l[0],l[1]);return s==="dataMin"?c:s==="dataMax"||f<0?f:Math.max(Math.min(l[0],l[1]),0)}return s==="dataMin"?l[0]:s==="dataMax"?l[1]:l[0]});E(L,"getComposedData",function(e){var t=e.props,r=e.item,a=e.xAxis,n=e.yAxis,i=e.xAxisTicks,o=e.yAxisTicks,s=e.bandSize,u=e.dataKey,l=e.stackedData,f=e.dataStartIndex,c=e.displayedData,h=e.offset,A=t.layout,g=l&&l.length,x=te.getBaseValue(t,r,a,n),v=A==="horizontal",O=!1,y=c.map(function(d,m){var b;g?b=l[f+m]:(b=J(d,u),Array.isArray(b)?O=!0:b=[x,b]);var w=b[1]==null||g&&J(d,u)==null;return v?{x:Q({axis:a,ticks:i,bandSize:s,entry:d,index:m}),y:w?null:n.scale(b[1]),value:b,payload:d}:{x:w?null:a.scale(b[1]),y:Q({axis:n,ticks:o,bandSize:s,entry:d,index:m}),value:b,payload:d}}),_;return g||O?_=y.map(function(d){var m=Array.isArray(d.value)?d.value[0]:null;return v?{x:d.x,y:m!=null&&d.y!=null?n.scale(m):null}:{x:m!=null?a.scale(m):null,y:d.y}}):_=v?n.scale(x):a.scale(x),S({points:y,baseLine:_,layout:A,isRange:O},h)});E(L,"renderDotItem",function(e,t){var r;if(p.isValidElement(e))r=p.cloneElement(e,t);else if(K(e))r=e(t);else{var a=ee("recharts-area-dot",typeof e!="boolean"?e.className:""),n=t.key,i=ae(t,be);r=p.createElement(fe,D({},i,{key:n,className:a}))}return r});var ke=pe({chartName:"AreaChart",GraphicalChild:L,axisComponents:[{axisType:"xAxis",AxisComp:he},{axisType:"yAxis",AxisComp:de}],formatAxisMap:me});export{ke as A,L as a};
2
+ //# sourceMappingURL=AreaChart-D4EY7yiY.js.map