@feltdb/core 0.12.0 → 0.12.2

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 (138) hide show
  1. package/dist/agent-state.d.ts +489 -0
  2. package/dist/agent-state.d.ts.map +1 -0
  3. package/dist/agent-state.js +993 -0
  4. package/dist/build-identity.json +28 -0
  5. package/dist/cli/commands.js +88 -43
  6. package/dist/collection.d.ts +41 -4
  7. package/dist/collection.d.ts.map +1 -1
  8. package/dist/collection.js +116 -47
  9. package/dist/composition.d.ts.map +1 -1
  10. package/dist/composition.js +11 -1
  11. package/dist/create/build-identity.json +28 -0
  12. package/dist/create/cli.js +3 -3
  13. package/dist/create/create.js +17 -19
  14. package/dist/create/package-versions.js +1 -1
  15. package/dist/create/server-source/Cargo.lock +18 -3
  16. package/dist/create/server-source/Cargo.toml +4 -2
  17. package/dist/create/server-source/crates/feltdb/Cargo.toml +20 -0
  18. package/dist/create/server-source/crates/feltdb/LICENSE +21 -0
  19. package/dist/create/server-source/crates/feltdb/README.md +75 -0
  20. package/dist/create/server-source/crates/feltdb/src/agent_state.rs +320 -0
  21. package/dist/create/server-source/crates/feltdb/src/agent_transition_contract.rs +1545 -0
  22. package/dist/create/server-source/crates/feltdb/src/authority.rs +145 -15
  23. package/dist/create/server-source/crates/feltdb/src/lib.rs +238 -23
  24. package/dist/create/server-source/crates/feltdb/src/query_performance.rs +4 -1
  25. package/dist/create/server-source/crates/feltdb/src/state_model.rs +850 -155
  26. package/dist/create/server-source/crates/feltdb/tests/agent_state_native.rs +1188 -0
  27. package/dist/create/server-source/crates/feltdb/tests/agent_transition_contract_conformance.rs +2884 -0
  28. package/dist/create/server-source/crates/feltdb/tests/authority_transaction_identity.rs +534 -0
  29. package/dist/create/server-source/crates/feltdb/tests/fixtures/agent_transition_corpus.json +23340 -0
  30. package/dist/create/server-source/crates/feltdb/tests/generalized_version_control_substrate_completion.rs +31 -13
  31. package/dist/create/server-source/crates/feltdb/tests/state_ref_authority.rs +918 -0
  32. package/dist/create/server-source/crates/feltdb/tests/workload_envelope_contract.rs +15 -2
  33. package/dist/create/server-source/crates/feltdb-client/Cargo.toml +29 -0
  34. package/dist/create/server-source/crates/feltdb-client/LICENSE +21 -0
  35. package/dist/create/server-source/crates/feltdb-client/README.md +70 -0
  36. package/dist/create/server-source/crates/feltdb-client/src/application.rs +527 -0
  37. package/dist/create/server-source/crates/feltdb-client/src/authority.rs +679 -0
  38. package/dist/create/server-source/crates/feltdb-client/src/control.rs +292 -0
  39. package/dist/create/server-source/crates/feltdb-client/src/error.rs +227 -0
  40. package/dist/create/server-source/crates/feltdb-client/src/events.rs +146 -0
  41. package/dist/create/server-source/crates/feltdb-client/src/lib.rs +466 -0
  42. package/dist/create/server-source/crates/feltdb-client/tests/fixtures/README.md +4 -0
  43. package/dist/create/server-source/crates/feltdb-client/tests/fixtures/private-ca.pem +20 -0
  44. package/dist/create/server-source/crates/feltdb-client/tests/fixtures/server-key.pem +28 -0
  45. package/dist/create/server-source/crates/feltdb-client/tests/fixtures/server.pem +20 -0
  46. package/dist/create/server-source/crates/feltdb-client/tests/private_ca.rs +95 -0
  47. package/dist/create/server-source/crates/feltdb-server/Cargo.toml +24 -1
  48. package/dist/create/server-source/crates/feltdb-server/LICENSE +21 -0
  49. package/dist/create/server-source/crates/feltdb-server/README.md +12 -1
  50. package/dist/create/server-source/crates/feltdb-server/benches/query_shape_observer.rs +136 -0
  51. package/dist/create/server-source/crates/feltdb-server/src/app_state.rs +3 -0
  52. package/dist/create/server-source/crates/feltdb-server/src/backup.rs +6 -2
  53. package/dist/create/server-source/crates/feltdb-server/src/lib.rs +21 -0
  54. package/dist/create/server-source/crates/feltdb-server/src/main.rs +75 -8
  55. package/dist/create/server-source/crates/feltdb-server/src/query_shape.rs +1137 -0
  56. package/dist/create/server-source/crates/feltdb-server/tests/fixtures/query-shape-trace.expected.json +300 -0
  57. package/dist/create/server-source/crates/feltdb-server/tests/fixtures/query-shape-trace.json +25 -0
  58. package/dist/create/server-source/crates/feltdb-server/tests/query_shape_trace.rs +128 -0
  59. package/dist/create/server-source/crates/feltdb-server/tests/rust_client.rs +683 -0
  60. package/dist/create/server-source/crates/feltdb-wasm/Cargo.toml +3 -1
  61. package/dist/create/template/default-project/README.md +12 -7
  62. package/dist/create/template/default-project/src/pages/Dashboard.tsx +1 -1
  63. package/dist/create/template/dot-feltdb-README.md +3 -3
  64. package/dist/db.d.ts.map +1 -1
  65. package/dist/db.js +43 -17
  66. package/dist/development-runtime-bridge.d.ts.map +1 -1
  67. package/dist/development-runtime-bridge.js +22 -1
  68. package/dist/embedded-transaction.d.ts +75 -8
  69. package/dist/embedded-transaction.d.ts.map +1 -1
  70. package/dist/embedded-transaction.js +124 -18
  71. package/dist/error-codes.d.ts +2 -0
  72. package/dist/error-codes.d.ts.map +1 -1
  73. package/dist/error-codes.js +2 -0
  74. package/dist/feltdb.d.ts +1 -11
  75. package/dist/feltdb.d.ts.map +1 -1
  76. package/dist/file-db.d.ts +6 -0
  77. package/dist/file-db.d.ts.map +1 -1
  78. package/dist/file-db.js +43 -11
  79. package/dist/index-core.d.ts +1 -0
  80. package/dist/index-core.d.ts.map +1 -1
  81. package/dist/index-core.js +1 -0
  82. package/dist/indexeddb-db.d.ts.map +1 -1
  83. package/dist/indexeddb-db.js +65 -41
  84. package/dist/memory-db.d.ts.map +1 -1
  85. package/dist/memory-db.js +29 -8
  86. package/dist/studio/{KeyManagementPanel-DZuSeWBK.js → KeyManagementPanel-D5FMvvU9.js} +1 -0
  87. package/dist/studio/app.d.ts.map +1 -1
  88. package/dist/studio/components/GlobalSearch.d.ts.map +1 -1
  89. package/dist/studio/components/KeyManagementPanel.d.ts.map +1 -1
  90. package/dist/studio/components/KeyManagementPanel.js +1 -1
  91. package/dist/studio/components/RouteErrorBoundary.d.ts +5 -0
  92. package/dist/studio/components/RouteErrorBoundary.d.ts.map +1 -0
  93. package/dist/studio/components/index.js +2 -2
  94. package/dist/studio/{components-BHTKlUgT.js → components-B4eKIUN5.js} +3 -2
  95. package/dist/studio/control-plane/Agents.d.ts.map +1 -1
  96. package/dist/studio/control-plane/Data.d.ts.map +1 -1
  97. package/dist/studio/control-plane/Instance.d.ts.map +1 -1
  98. package/dist/studio/control-plane/Operations.d.ts.map +1 -1
  99. package/dist/studio/control-plane/Overview.d.ts.map +1 -1
  100. package/dist/studio/control-plane/Schema.d.ts.map +1 -1
  101. package/dist/studio/control-plane/State.d.ts +11 -0
  102. package/dist/studio/control-plane/State.d.ts.map +1 -1
  103. package/dist/studio/control-plane/context.d.ts +4 -1
  104. package/dist/studio/control-plane/context.d.ts.map +1 -1
  105. package/dist/studio/control-plane/index.d.ts +1 -1
  106. package/dist/studio/control-plane/index.d.ts.map +1 -1
  107. package/dist/studio/control-plane/index.js +2 -2
  108. package/dist/studio/control-plane/primitives.d.ts +22 -2
  109. package/dist/studio/control-plane/primitives.d.ts.map +1 -1
  110. package/dist/studio/control-plane-fxMcJn74.js +4173 -0
  111. package/dist/studio/index.js +307 -235
  112. package/dist/studio/studio.css +1 -1
  113. package/dist/studio/utils/control-plane-api.d.ts.map +1 -1
  114. package/dist/studio/utils/control-plane-api.js +4 -3
  115. package/dist/studio/utils/service-api.d.ts.map +1 -1
  116. package/dist/studio/utils/service-api.js +5 -4
  117. package/dist/studio-app/assets/{feltdb_wasm-DYfWAV0E.js → feltdb_wasm-BatwwogY.js} +1 -1
  118. package/dist/studio-app/assets/feltdb_wasm_bg-BX0newOr.wasm +0 -0
  119. package/dist/studio-app/assets/index-CiC8VY-a.css +1 -0
  120. package/dist/studio-app/assets/index-DoVvbIay.js +30 -0
  121. package/dist/studio-app/index.html +2 -2
  122. package/dist/telemetry.d.ts +1 -0
  123. package/dist/telemetry.d.ts.map +1 -1
  124. package/dist/telemetry.js +4 -3
  125. package/dist/transaction-identity.d.ts +62 -0
  126. package/dist/transaction-identity.d.ts.map +1 -0
  127. package/dist/transaction-identity.js +138 -0
  128. package/dist/transaction.d.ts +50 -5
  129. package/dist/transaction.d.ts.map +1 -1
  130. package/dist/transaction.js +28 -0
  131. package/dist/wasm/feltdb_wasm_bg.wasm +0 -0
  132. package/dist/wasm/package.json +1 -1
  133. package/package.json +2 -2
  134. package/dist/create/server-source/crates/feltdb-wasm/test.db +0 -0
  135. package/dist/studio/control-plane-DP8ljTDO.js +0 -3207
  136. package/dist/studio-app/assets/feltdb_wasm_bg-DHiOUhoQ.wasm +0 -0
  137. package/dist/studio-app/assets/index-6f6KVx5R.js +0 -30
  138. package/dist/studio-app/assets/index-BrsF-kWL.css +0 -1
@@ -0,0 +1,4173 @@
1
+ import { StudioServiceApi as e, isSecretField as t, resolveStudioApplicationId as n, safeDisplayValue as r } from "./utils/service-api.js";
2
+ import { CapabilitySet as i, ControlPlaneApi as a, controlPlaneErrorMessage as o, formatStatePath as s } from "./utils/control-plane-api.js";
3
+ import c, { Fragment as l, createContext as u, createElement as d, isValidElement as f, useContext as p, useEffect as m, useId as h, useMemo as g, useRef as _, useState as v } from "react";
4
+ import { Link as y, useSearchParams as b } from "react-router-dom";
5
+ import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
6
+ Object.freeze([
7
+ "positive",
8
+ "progress",
9
+ "attention",
10
+ "critical",
11
+ "neutral",
12
+ "unknown"
13
+ ]);
14
+ var w = Object.freeze({
15
+ positive: "●",
16
+ progress: "◐",
17
+ attention: "▲",
18
+ critical: "✕",
19
+ neutral: "○",
20
+ unknown: "?"
21
+ });
22
+ Object.freeze([
23
+ "submitted",
24
+ "accepted",
25
+ "completed",
26
+ "failed",
27
+ "cancelled",
28
+ "rejected",
29
+ "outcome_unknown"
30
+ ]), Object.freeze({
31
+ submitted: "Sending…",
32
+ accepted: "Started",
33
+ completed: "Done",
34
+ failed: "Failed",
35
+ cancelled: "Cancelled",
36
+ rejected: "Not accepted",
37
+ outcome_unknown: "Result unknown — check current state"
38
+ });
39
+ var ee = Object.freeze([
40
+ "verified",
41
+ "verification_failed",
42
+ "not_verified",
43
+ "not_evaluated"
44
+ ]);
45
+ Object.freeze([
46
+ "live",
47
+ "cached",
48
+ "stale",
49
+ "unknown"
50
+ ]), Object.freeze([
51
+ "available",
52
+ "partial",
53
+ "unsupported"
54
+ ]);
55
+ function T(e) {
56
+ let t = String(e).replace(/_/g, " ");
57
+ return t && t[0].toUpperCase() + t.slice(1);
58
+ }
59
+ var E = "positive", D = "progress", O = "attention", k = "critical", A = "neutral", j = "unknown", te = {
60
+ "compute.environment.actual_state": {
61
+ running: E,
62
+ completed: E,
63
+ pending: D,
64
+ starting: D,
65
+ stopping: D,
66
+ degraded: O,
67
+ failed: k,
68
+ denied: k,
69
+ stopped: A
70
+ },
71
+ "compute.health": {
72
+ healthy: E,
73
+ unhealthy: k,
74
+ unknown: j
75
+ },
76
+ "compute.environment.readiness": {
77
+ ready: E,
78
+ created: D,
79
+ starting: D,
80
+ degraded: O,
81
+ failed: k,
82
+ unavailable: k
83
+ },
84
+ "compute.process.readiness": {
85
+ ready: E,
86
+ starting: D,
87
+ unready: O
88
+ },
89
+ "compute.process.state": {
90
+ ready: E,
91
+ running: E,
92
+ pending: D,
93
+ starting: D,
94
+ stopping: D,
95
+ unready: O,
96
+ failed: k,
97
+ lost: k,
98
+ stopped: A,
99
+ exited: A,
100
+ destroyed: A,
101
+ expired: A,
102
+ unverified: j,
103
+ unreachable: j
104
+ },
105
+ "compute.deployment.status": {
106
+ active: E,
107
+ complete: E,
108
+ pending: D,
109
+ starting: D,
110
+ ready: D,
111
+ network_ready: D,
112
+ switching: D,
113
+ draining: D,
114
+ failed: k,
115
+ rolled_back: k
116
+ },
117
+ "compute.version.status": {
118
+ published: E,
119
+ publishing: D,
120
+ failed: k
121
+ },
122
+ "compute.rollout.status": {
123
+ active: E,
124
+ applying: D,
125
+ failed: k,
126
+ superseded: A
127
+ },
128
+ "compute.job.status": {
129
+ succeeded: E,
130
+ created: D,
131
+ accepted: D,
132
+ queued: D,
133
+ waiting_for_capacity: D,
134
+ reserved: D,
135
+ admitted: D,
136
+ preparing: D,
137
+ running: D,
138
+ failed: k,
139
+ rejected: k,
140
+ timed_out: k,
141
+ cancelled: A
142
+ },
143
+ "compute.computer.observed": {
144
+ running: E,
145
+ starting: D,
146
+ reconciling: D,
147
+ stopping: D,
148
+ failed: k,
149
+ lost: k,
150
+ stopped: A,
151
+ destroyed: A,
152
+ expired: A,
153
+ unverified: j,
154
+ unreachable: j
155
+ },
156
+ "compute.computer.status": {
157
+ running: E,
158
+ pending: D,
159
+ provisioning: D,
160
+ resuming: D,
161
+ stopping: D,
162
+ destroying: D,
163
+ failed: k,
164
+ lost: k,
165
+ stopped: A,
166
+ destroyed: A,
167
+ expired: A,
168
+ unreachable: j
169
+ },
170
+ "feltdb.health.ready_state": {
171
+ healthy: E,
172
+ recovering: D,
173
+ degraded: O,
174
+ unavailable: k
175
+ },
176
+ "feltdb.authority.availability": {
177
+ available: E,
178
+ recovering: D,
179
+ degraded: O,
180
+ closed: A,
181
+ unknown: j
182
+ },
183
+ "feltdb.authority.lease_clock_healthy": {
184
+ true: [E, "Healthy"],
185
+ false: [O, "Degraded"]
186
+ }
187
+ }, ne = { "feltdb.revision.integrity_verified": {
188
+ true: "verified",
189
+ false: "verification_failed"
190
+ } }, re = {
191
+ "compute.response.state": {
192
+ live: "live",
193
+ cached: "cached",
194
+ stale: "stale"
195
+ },
196
+ "feltdb.snapshot.staleness": {
197
+ current: "live",
198
+ stale: "stale",
199
+ unknown: "unknown"
200
+ }
201
+ }, ie = (e) => Object.freeze(Object.fromEntries(Object.entries(e).map(([e, t]) => [e, Object.freeze({ ...t })]))), ae = ie(te), oe = ie(ne);
202
+ ie(re);
203
+ var se = (e, t) => Object.prototype.hasOwnProperty.call(e, t);
204
+ function ce(e, t, n) {
205
+ let r = ae[e];
206
+ if (!r) throw Error(`unknown field: ${e}`);
207
+ let i = String(t), a = se(r, i) ? r[i] : null, [o, s] = a === null ? [j, null] : Array.isArray(a) ? a : [a, null];
208
+ return {
209
+ field: e,
210
+ value: i,
211
+ tone: o,
212
+ label: n && n.label || s || (a === null ? i : T(i)),
213
+ glyph: w[o],
214
+ mapped: a !== null
215
+ };
216
+ }
217
+ function le(e, t) {
218
+ let n = de(t), r = ee.includes(e) ? e : "not_evaluated";
219
+ return r === "verified" && n.length === 0 && (r = "not_evaluated"), r === "verified" && n.some((e) => e.status === "failed") && (r = "verification_failed"), {
220
+ state: r,
221
+ checks: n
222
+ };
223
+ }
224
+ function ue(e, t, n) {
225
+ let r = oe[e];
226
+ if (!r) throw Error(`unknown field: ${e}`);
227
+ let i = String(t), a = se(r, i) ? r[i] : "not_evaluated";
228
+ return le(a, de(n).map((e) => ({
229
+ ...e,
230
+ status: e.status || (a === "verified" ? "passed" : a === "verification_failed" ? "failed" : void 0)
231
+ })));
232
+ }
233
+ function de(e) {
234
+ return e ? e.map((e) => typeof e == "string" ? { label: e } : {
235
+ label: String(e.label),
236
+ ...e.status ? { status: e.status } : {}
237
+ }) : [];
238
+ }
239
+ //#endregion
240
+ //#region vendor/stack-ui/core/src/view.js
241
+ var M = (e, t, n, r, i) => ({
242
+ t: e,
243
+ a: t || {},
244
+ c: n === void 0 ? [] : [].concat(n),
245
+ ...r ? { on: r } : {},
246
+ ...i == null ? {} : { k: String(i) }
247
+ }), fe = (e) => !!(e && typeof e == "object" && typeof e.t == "string" && e.a && Array.isArray(e.c)), N = (...e) => e.filter(Boolean).join(" "), P = (e) => e != null && e !== "", F = (e) => {
248
+ let t = {};
249
+ for (let [n, r] of Object.entries(e || {})) (/^(data-|aria-)/.test(n) || n === "id" || n === "title") && (t[n] = r);
250
+ return t;
251
+ };
252
+ function pe(e) {
253
+ let t = new Date(e);
254
+ return Number.isNaN(t.getTime()) ? String(e) : `${t.toISOString().slice(0, 19).replace("T", " ")} UTC`;
255
+ }
256
+ var me = (e, t) => {
257
+ let n = new Date(e);
258
+ return Number.isNaN(n.getTime()) ? M("span", { class: t }, String(e)) : M("time", {
259
+ class: t,
260
+ datetime: n.toISOString()
261
+ }, pe(e));
262
+ };
263
+ function he(e) {
264
+ let { field: t, value: n, detail: r, className: i, attrs: a } = e, o = t ? ce(t, n, { label: e.label }) : null, s = o ? o.tone : e.tone || "unknown", c = o ? o.label : P(e.label) ? e.label : T(s), l = e.glyph || w[s] || w.unknown;
265
+ return M("span", {
266
+ class: N("stack-status", `stack-status--${s}`, i),
267
+ "data-tone": s,
268
+ ...o ? {
269
+ "data-field": o.field,
270
+ "data-value": o.value
271
+ } : {},
272
+ ...F(a)
273
+ }, [
274
+ M("span", {
275
+ class: "stack-status__glyph",
276
+ "aria-hidden": "true"
277
+ }, l),
278
+ M("span", { class: "stack-status__label" }, c),
279
+ P(r) ? M("span", { class: "stack-status__detail" }, r) : null
280
+ ]);
281
+ }
282
+ var ge = {
283
+ verified: "✓",
284
+ verification_failed: "✕",
285
+ not_verified: "!",
286
+ not_evaluated: "–"
287
+ };
288
+ function _e(e) {
289
+ let { state: t, checks: n } = le(e.state, e.checks), r = n.filter((e) => e.status === "failed"), i;
290
+ if (t === "verified") i = n.length === 1 ? `Verified · ${n[0].label}` : `Verified · ${n.length} checks`;
291
+ else if (t === "verification_failed") {
292
+ let e = r.length ? r : n;
293
+ i = e.length === 1 ? `Verification failed · ${e[0].label}` : e.length ? `Verification failed · ${e.length} checks` : "Verification failed";
294
+ } else i = t === "not_verified" ? "Not verified" : "Not evaluated";
295
+ return M("div", {
296
+ class: N("stack-verification", `stack-verification--${t}`, e.className),
297
+ "data-verification": t,
298
+ ...F(e.attrs)
299
+ }, [
300
+ M("span", {
301
+ class: "stack-verification__glyph",
302
+ "aria-hidden": "true"
303
+ }, ge[t]),
304
+ M("span", { class: "stack-verification__label" }, i),
305
+ P(e.at) ? [" · ", me(e.at, "stack-verification__at")] : null,
306
+ P(e.evidenceHref) ? M("a", {
307
+ class: "stack-verification__evidence",
308
+ href: e.evidenceHref
309
+ }, "Evidence") : null,
310
+ n.length > 1 ? M("ul", { class: "stack-verification__checks" }, n.map((e) => M("li", {
311
+ class: "stack-verification__check",
312
+ ...e.status ? { "data-check-status": e.status } : {}
313
+ }, e.status ? `${e.label} — ${e.status}` : e.label))) : null
314
+ ]);
315
+ }
316
+ var ve = {
317
+ live: "Live",
318
+ cached: "Cached",
319
+ stale: "Stale",
320
+ unknown: "Freshness unknown"
321
+ }, ye = {
322
+ live: "●",
323
+ cached: "◷",
324
+ stale: "▲",
325
+ unknown: "?"
326
+ };
327
+ function be(e) {
328
+ let t = ve[e.freshness] ? e.freshness : "unknown", n = P(e.asOf) && t !== "live";
329
+ return M("span", {
330
+ class: N("stack-freshness", `stack-freshness--${t}`, e.className),
331
+ "data-freshness": t,
332
+ ...F(e.attrs)
333
+ }, [M("span", {
334
+ class: "stack-freshness__glyph",
335
+ "aria-hidden": "true"
336
+ }, ye[t]), M("span", { class: "stack-freshness__label" }, [
337
+ ve[t],
338
+ n ? [" · as of ", me(e.asOf, "stack-freshness__as-of")] : null,
339
+ P(e.source) ? ` · ${e.source}` : null
340
+ ])]);
341
+ }
342
+ function xe(e) {
343
+ let t = e.status === "partial" ? "partial" : "unsupported", n = P(e.title) ? e.title : t === "partial" ? "Partly available" : "Not available";
344
+ return M("div", {
345
+ class: N("stack-unavailable", `stack-unavailable--${t}`, e.className),
346
+ role: "note",
347
+ "data-capability-status": t,
348
+ ...P(e.capability) ? { "data-capability": e.capability } : {},
349
+ ...F(e.attrs)
350
+ }, [
351
+ M(e.headingLevel ? Ce(e.headingLevel) : "p", { class: "stack-unavailable__title" }, n),
352
+ P(e.reason) ? M("p", { class: "stack-unavailable__reason" }, e.reason) : null,
353
+ e.children || null
354
+ ]);
355
+ }
356
+ function Se(e) {
357
+ let t = P(e.what) ? e.what : "", n = e.long ? `Still loading${t ? ` ${t}` : ""}…` : `Loading${t ? ` ${t}` : ""}…`;
358
+ return M("div", {
359
+ class: N("stack-loading", e.long ? "stack-loading--long" : null, e.className),
360
+ role: "status",
361
+ "aria-live": "polite",
362
+ ...F(e.attrs)
363
+ }, [M("span", {
364
+ class: "stack-loading__indicator",
365
+ "aria-hidden": "true"
366
+ }), M("span", { class: "stack-loading__label" }, n)]);
367
+ }
368
+ var Ce = (e) => `h${Math.min(6, Math.max(1, Number(e) || 2))}`;
369
+ function I(e) {
370
+ let t = e.variant === "no-match" ? "no-match" : "empty", n = P(e.title) ? e.title : t === "no-match" ? "Nothing matches" : "Nothing here yet";
371
+ return M("div", {
372
+ class: N("stack-empty", `stack-empty--${t}`, e.className),
373
+ ...F(e.attrs)
374
+ }, [
375
+ M(Ce(e.headingLevel), { class: "stack-empty__title" }, n),
376
+ P(e.body) ? M("p", { class: "stack-empty__body" }, e.body) : null,
377
+ e.action ? M("div", { class: "stack-empty__action" }, e.action) : null
378
+ ]);
379
+ }
380
+ function L(e) {
381
+ let t = [P(e.code) ? ["Code ", M("code", {}, e.code)] : null, P(e.requestId) ? [
382
+ P(e.code) ? " · " : "",
383
+ "Request ",
384
+ M("code", {}, e.requestId)
385
+ ] : null].filter(Boolean);
386
+ return M("div", {
387
+ class: N("stack-error", e.className),
388
+ role: "alert",
389
+ ...F(e.attrs)
390
+ }, [
391
+ M("p", { class: "stack-error__title" }, P(e.title) ? e.title : "Something went wrong"),
392
+ P(e.message) ? M("p", { class: "stack-error__message" }, e.message) : null,
393
+ t.length ? M("p", { class: "stack-error__meta" }, t) : null,
394
+ e.onRetry || e.actions ? M("div", { class: "stack-error__actions" }, [e.onRetry ? Oe({
395
+ label: e.retryLabel || "Retry",
396
+ onClick: e.onRetry
397
+ }) : null, e.actions || null]) : null
398
+ ]);
399
+ }
400
+ function we(e) {
401
+ return M("dl", {
402
+ class: N("stack-meta", e.className),
403
+ ...F(e.attrs)
404
+ }, (e.items || []).map((e) => {
405
+ let t = !P(e.value) && e.value !== 0 && e.value !== !1;
406
+ return M("div", {
407
+ class: "stack-meta__item",
408
+ ...F(e.attrs)
409
+ }, [
410
+ M("dt", { class: "stack-meta__label" }, e.label),
411
+ M("dd", {
412
+ class: N("stack-meta__value", e.mono ? "stack-meta__value--mono" : null),
413
+ ...t ? { "data-missing": "true" } : {}
414
+ }, t ? "—" : typeof e.value == "boolean" ? String(e.value) : e.value),
415
+ P(e.hint) ? M("dd", { class: "stack-meta__hint" }, e.hint) : null
416
+ ]);
417
+ }));
418
+ }
419
+ function Te(e) {
420
+ let t = Number(e.length) || 12, n = P(e.id) ? String(e.id) : null, r = n && n.length > t ? `${n.slice(0, t)}…` : n, i = P(e.name) ? M(e.href ? "a" : "span", {
421
+ class: "stack-identity__name",
422
+ ...e.href ? { href: e.href } : {}
423
+ }, e.name) : null;
424
+ return M("span", {
425
+ class: N("stack-identity", e.className),
426
+ ...F(e.attrs)
427
+ }, [
428
+ P(e.kind) ? M("span", { class: "stack-identity__kind" }, e.kind) : null,
429
+ i,
430
+ n ? M("code", {
431
+ class: "stack-identity__id",
432
+ title: n
433
+ }, r === n ? n : [M("span", { "aria-hidden": "true" }, r), M("span", { class: "stack-visually-hidden" }, n)]) : null
434
+ ]);
435
+ }
436
+ function R(e) {
437
+ return M("header", {
438
+ class: N("stack-page-header", e.className),
439
+ ...F(e.attrs)
440
+ }, [
441
+ P(e.eyebrow) ? M("p", { class: "stack-page-header__eyebrow" }, e.eyebrow) : null,
442
+ M("div", { class: "stack-page-header__title-row" }, [
443
+ M(Ce(e.headingLevel || 1), { class: "stack-page-header__title" }, e.title),
444
+ e.status ? M("span", { class: "stack-page-header__status" }, e.status) : null,
445
+ e.actions ? M("div", { class: "stack-page-header__actions" }, e.actions) : null
446
+ ]),
447
+ P(e.description) ? M("p", { class: "stack-page-header__description" }, e.description) : null,
448
+ e.meta ? M("div", { class: "stack-page-header__meta" }, e.meta) : null
449
+ ]);
450
+ }
451
+ var Ee = [
452
+ "primary",
453
+ "secondary",
454
+ "danger",
455
+ "ghost"
456
+ ], De = [
457
+ "sm",
458
+ "md",
459
+ "lg"
460
+ ];
461
+ function Oe(e) {
462
+ let t = Ee.includes(e.variant) ? e.variant : "secondary", n = De.includes(e.size) ? e.size : "md", r = !!(e.disabled || e.busy);
463
+ return M("button", {
464
+ class: N("stack-button", `stack-button--${t}`, `stack-button--${n}`, e.className),
465
+ type: e.type === "submit" ? "submit" : "button",
466
+ ...r ? { disabled: !0 } : {},
467
+ ...e.busy ? { "aria-busy": "true" } : {},
468
+ ...F(e.attrs)
469
+ }, [e.busy ? M("span", {
470
+ class: "stack-button__busy",
471
+ "aria-hidden": "true"
472
+ }) : null, M("span", { class: "stack-button__label" }, e.label)], e.onClick && !r ? { click: e.onClick } : void 0);
473
+ }
474
+ function ke(e) {
475
+ let t = (e.items || []).filter((e) => e && P(e.label));
476
+ return M("nav", {
477
+ class: N("stack-breadcrumbs", e.className),
478
+ "aria-label": e.label || "Breadcrumb",
479
+ ...F(e.attrs)
480
+ }, M("ol", { class: "stack-breadcrumbs__list" }, t.map((e, n) => {
481
+ let r = n === t.length - 1;
482
+ return M("li", { class: "stack-breadcrumbs__item" }, [n > 0 ? M("span", {
483
+ class: "stack-breadcrumbs__separator",
484
+ "aria-hidden": "true"
485
+ }, "/") : null, r || !P(e.href) ? M("span", {
486
+ class: "stack-breadcrumbs__current",
487
+ ...r ? { "aria-current": "page" } : {}
488
+ }, e.label) : M("a", {
489
+ class: "stack-breadcrumbs__link",
490
+ href: e.href
491
+ }, e.label)]);
492
+ })));
493
+ }
494
+ function Ae(e) {
495
+ if (![
496
+ "ArrowRight",
497
+ "ArrowLeft",
498
+ "ArrowDown",
499
+ "ArrowUp",
500
+ "Home",
501
+ "End"
502
+ ].includes(e.key)) return;
503
+ let t = e.currentTarget, n = Array.from(t.querySelectorAll("[role=\"tab\"]:not([disabled])"));
504
+ if (!n.length) return;
505
+ let r = n.indexOf(t.ownerDocument.activeElement), i = t.getAttribute("aria-orientation") === "vertical", a = i ? "ArrowDown" : "ArrowRight", o = i ? "ArrowUp" : "ArrowLeft", s;
506
+ if (e.key === "Home") s = 0;
507
+ else if (e.key === "End") s = n.length - 1;
508
+ else if (e.key === a) s = r < 0 ? 0 : (r + 1) % n.length;
509
+ else if (e.key === o) s = r < 0 ? n.length - 1 : (r - 1 + n.length) % n.length;
510
+ else return;
511
+ e.preventDefault(), n[s].focus();
512
+ }
513
+ var je = (e) => String(e).replace(/[^A-Za-z0-9_-]/g, "-"), Me = (e) => (t) => {
514
+ let n = t.currentTarget.ownerDocument.getElementById(e);
515
+ n && (t.preventDefault(), n.focus(), typeof n.scrollIntoView == "function" && n.scrollIntoView());
516
+ };
517
+ function Ne(e) {
518
+ let t = je(e.idPrefix || "stack-tabs"), n = e.tabs || [], r = n.some((t) => t.id === e.active && !t.disabled) ? e.active : null;
519
+ return M("div", {
520
+ class: N("stack-tabs", e.className),
521
+ role: "tablist",
522
+ ...P(e.label) ? { "aria-label": e.label } : {},
523
+ ...F(e.attrs)
524
+ }, n.map((n, i) => {
525
+ let a = n.id === r, o = a || r === null && i === 0;
526
+ return M("button", {
527
+ class: N("stack-tabs__tab", a ? "stack-tabs__tab--selected" : null, n.className),
528
+ type: "button",
529
+ role: "tab",
530
+ id: `${t}-tab-${je(n.id)}`,
531
+ "aria-selected": a ? "true" : "false",
532
+ ...P(e.panelId) ? { "aria-controls": e.panelId } : {},
533
+ tabindex: o ? "0" : "-1",
534
+ ...n.disabled ? {
535
+ disabled: !0,
536
+ ...P(n.reason) ? { title: n.reason } : {}
537
+ } : {},
538
+ ...F(n.attrs)
539
+ }, [n.label, P(n.badge) ? M("span", { class: "stack-tabs__badge" }, n.badge) : null], e.onSelect && !n.disabled ? { click: () => e.onSelect(n.id) } : void 0);
540
+ }), { keydown: Ae });
541
+ }
542
+ function Pe(e) {
543
+ let t = je(e.idPrefix || "stack-tabs");
544
+ return M("div", {
545
+ class: N("stack-tabpanel", e.className),
546
+ role: "tabpanel",
547
+ id: e.id,
548
+ ...P(e.active) ? { "aria-labelledby": `${t}-tab-${je(e.active)}` } : {},
549
+ tabindex: "0",
550
+ ...F(e.attrs)
551
+ }, e.children || null);
552
+ }
553
+ var Fe = {
554
+ ascending: "▲",
555
+ descending: "▼"
556
+ }, Ie = (e) => (t) => {
557
+ t.target === t.currentTarget && (t.key === "Enter" || t.key === " ") && (t.preventDefault(), e());
558
+ };
559
+ function Le(e) {
560
+ let t = e.columns || [], n = e.rows || [], r = P(e.label) ? e.label : "Table";
561
+ if (e.error) return L({
562
+ title: e.error.title || `${r} could not be read`,
563
+ message: e.error.message,
564
+ code: e.error.code,
565
+ requestId: e.error.requestId,
566
+ onRetry: e.error.onRetry,
567
+ className: N("stack-table-state", e.className),
568
+ attrs: e.attrs
569
+ });
570
+ if (e.loading && !n.length) return Se({
571
+ what: e.loadingWhat || r.toLowerCase(),
572
+ className: N("stack-table-state", e.className),
573
+ attrs: e.attrs
574
+ });
575
+ if (!n.length) {
576
+ let t = !!e.noMatch;
577
+ return I({
578
+ variant: t ? "no-match" : "empty",
579
+ title: t ? e.noMatchTitle || "Nothing matches" : e.emptyTitle || "Nothing here yet",
580
+ body: t ? e.noMatchBody : e.emptyBody,
581
+ action: t ? null : e.emptyAction,
582
+ headingLevel: e.emptyHeadingLevel || 3,
583
+ className: N("stack-table-state", e.className),
584
+ attrs: e.attrs
585
+ });
586
+ }
587
+ let i = e.sort || {}, a = M("thead", {}, M("tr", {}, t.map((t) => {
588
+ let n = i.column === t.id && Fe[i.direction] ? i.direction : null, r = t.sortable && e.onSort ? M("button", {
589
+ class: "stack-table__sort",
590
+ type: "button"
591
+ }, [t.header, M("span", {
592
+ class: "stack-table__sort-indicator",
593
+ "aria-hidden": "true"
594
+ }, n ? Fe[n] : "↕")], { click: () => e.onSort(t.id) }) : t.header;
595
+ return M("th", {
596
+ class: N("stack-table__header", t.align === "end" ? "stack-table__cell--end" : null),
597
+ scope: "col",
598
+ ...t.sortable && e.onSort ? { "aria-sort": n || "none" } : {}
599
+ }, r);
600
+ }))), o = M("tbody", {}, n.map((e) => {
601
+ let n = typeof e.onSelect == "function";
602
+ return M("tr", {
603
+ class: N("stack-table__row", n ? "stack-table__row--selectable" : null, e.selected ? "stack-table__row--selected" : null, e.className),
604
+ ...n ? { tabindex: "0" } : {},
605
+ ...e.selected ? { "aria-current": "true" } : {},
606
+ ...F(e.attrs)
607
+ }, t.map((t) => {
608
+ let n = e.cells ? e.cells[t.id] : void 0, r = n == null;
609
+ return M("td", {
610
+ class: N("stack-table__cell", t.align === "end" ? "stack-table__cell--end" : null),
611
+ ...r ? { "data-missing": "true" } : {}
612
+ }, r ? "—" : n);
613
+ }), n ? {
614
+ click: e.onSelect,
615
+ keydown: Ie(e.onSelect)
616
+ } : void 0, e.key);
617
+ }));
618
+ return M("div", {
619
+ class: N("stack-table", e.className),
620
+ role: "region",
621
+ "aria-label": r,
622
+ tabindex: "0",
623
+ ...e.loading ? { "aria-busy": "true" } : {},
624
+ ...F(e.attrs)
625
+ }, M("table", { class: "stack-table__table" }, [
626
+ M("caption", { class: e.captionVisible ? "stack-table__caption" : "stack-visually-hidden" }, r),
627
+ a,
628
+ o
629
+ ]));
630
+ }
631
+ function Re(e, t, n) {
632
+ let r = `${t}-${je(e.id)}`, i = P(e.value) ? String(e.value) : "", a = n ? (t) => n(e.id, t.target.value) : null, o = e.type === "select" ? M("select", {
633
+ class: "stack-filter__control",
634
+ id: r,
635
+ name: e.id
636
+ }, (e.options || []).map((e) => {
637
+ let t = String(typeof e == "object" ? e.value : e);
638
+ return M("option", {
639
+ value: t,
640
+ ...t === i ? { selected: !0 } : {}
641
+ }, typeof e == "object" ? e.label : e);
642
+ }), a ? { change: a } : void 0) : M("input", {
643
+ class: "stack-filter__control",
644
+ id: r,
645
+ name: e.id,
646
+ type: "search",
647
+ value: i,
648
+ ...P(e.placeholder) ? { placeholder: e.placeholder } : {}
649
+ }, [], a ? { input: a } : void 0);
650
+ return M("div", { class: "stack-filter__field" }, [M("label", {
651
+ class: "stack-filter__label",
652
+ for: r
653
+ }, e.label), o]);
654
+ }
655
+ function ze(e) {
656
+ let t = je(e.idPrefix || "stack-filter"), n = Number(e.applied) || 0;
657
+ return M("form", {
658
+ class: N("stack-filter", e.className),
659
+ role: "search",
660
+ "aria-label": e.label || "Filters",
661
+ ...F(e.attrs)
662
+ }, [M("div", { class: "stack-filter__controls" }, [(e.filters || []).map((n) => Re(n, t, e.onChange)), M("div", { class: "stack-filter__actions" }, [Oe({
663
+ label: e.applyLabel || "Apply",
664
+ type: "submit",
665
+ variant: "secondary"
666
+ }), n && e.onClear ? Oe({
667
+ label: e.clearLabel || "Clear",
668
+ variant: "ghost",
669
+ onClick: e.onClear
670
+ }) : null])]), M("p", {
671
+ class: "stack-filter__result",
672
+ role: "status",
673
+ "aria-live": "polite"
674
+ }, P(e.result) ? e.result : "")], e.onSubmit ? { submit: (t) => {
675
+ t.preventDefault(), e.onSubmit();
676
+ } } : void 0);
677
+ }
678
+ function Be(e) {
679
+ return M("nav", {
680
+ class: N("stack-pagination", e.className),
681
+ "aria-label": e.label || "Pagination",
682
+ ...F(e.attrs)
683
+ }, [P(e.summary) ? M("p", { class: "stack-pagination__summary" }, e.summary) : null, M("div", { class: "stack-pagination__actions" }, [Oe({
684
+ label: e.previousLabel || "← Previous",
685
+ variant: "ghost",
686
+ disabled: !e.hasPrevious,
687
+ onClick: e.onPrevious,
688
+ attrs: { "data-page": "previous" }
689
+ }), Oe({
690
+ label: e.nextLabel || "Next →",
691
+ variant: "ghost",
692
+ disabled: !e.hasNext,
693
+ onClick: e.onNext,
694
+ attrs: { "data-page": "next" }
695
+ })])]);
696
+ }
697
+ var Ve = Object.freeze([
698
+ {
699
+ value: "system",
700
+ label: "System theme"
701
+ },
702
+ {
703
+ value: "light",
704
+ label: "Light theme"
705
+ },
706
+ {
707
+ value: "dark",
708
+ label: "Dark theme"
709
+ }
710
+ ]);
711
+ function He(e) {
712
+ let t = e.product || {}, n = (t) => e.onNavigate ? { click: (n) => {
713
+ n.defaultPrevented || n.button !== 0 || n.metaKey || n.ctrlKey || n.shiftKey || n.altKey || (n.preventDefault(), e.onNavigate(t));
714
+ } } : void 0, r = je(e.mainId || "stack-main"), i = [];
715
+ for (let t of e.navigation || []) {
716
+ let e = t.group || "", n = i.find((t) => t.name === e);
717
+ n || i.push(n = {
718
+ name: e,
719
+ items: []
720
+ }), n.items.push(t);
721
+ }
722
+ for (let e of i) e.items.sort((e, t) => (e.order ?? 0) - (t.order ?? 0));
723
+ let a = (e) => M("li", { class: "stack-shell__nav-entry" }, M("a", {
724
+ class: N("stack-shell__nav-item", e.className),
725
+ href: e.href,
726
+ ...e.current ? { "aria-current": "page" } : {},
727
+ ...F(e.attrs)
728
+ }, e.label, n(e.href))), o = e.theme, s = `${r}-theme`, c = e.otherProducts || [];
729
+ return M("div", {
730
+ class: N("stack-shell", e.className),
731
+ ...F(e.attrs)
732
+ }, [
733
+ M("a", {
734
+ class: "stack-shell__skip",
735
+ href: `#${r}`
736
+ }, e.skipLabel || "Skip to content", { click: Me(r) }),
737
+ M("header", { class: "stack-shell__bar" }, [
738
+ M("a", {
739
+ class: "stack-shell__product",
740
+ href: t.homeHref || "#"
741
+ }, [P(t.mark) ? M("span", {
742
+ class: "stack-shell__mark",
743
+ "aria-hidden": "true"
744
+ }, t.mark) : null, M("span", { class: "stack-shell__product-name" }, t.name || "")], n(t.homeHref || "#")),
745
+ e.context ? M("div", { class: "stack-shell__context" }, e.context) : null,
746
+ e.search ? M("div", { class: "stack-shell__search" }, e.search) : null,
747
+ M("div", { class: "stack-shell__end" }, [o ? M("div", { class: "stack-shell__prefs" }, [M("label", {
748
+ class: "stack-visually-hidden",
749
+ for: s
750
+ }, "Theme"), M("select", {
751
+ class: "stack-shell__theme",
752
+ id: s
753
+ }, Ve.map((e) => M("option", {
754
+ value: e.value,
755
+ ...e.value === (o.preference || "system") ? { selected: !0 } : {}
756
+ }, e.label)), o.onChange ? { change: (e) => o.onChange(e.target.value) } : void 0)]) : null, e.account ? M("div", { class: "stack-shell__account" }, e.account) : null])
757
+ ]),
758
+ M("div", { class: "stack-shell__body" }, [M("nav", {
759
+ class: "stack-shell__nav",
760
+ "aria-label": `${t.name || "Product"} navigation`
761
+ }, [
762
+ i.map((e) => M("div", { class: "stack-shell__nav-group" }, [P(e.name) ? M("p", { class: "stack-shell__nav-heading" }, e.name) : null, M("ul", { class: "stack-shell__nav-list" }, e.items.map(a))])),
763
+ P(e.activityHref) ? M("div", { class: "stack-shell__nav-group stack-shell__activity" }, M("ul", { class: "stack-shell__nav-list" }, a({
764
+ label: e.activityLabel || "Activity",
765
+ href: e.activityHref,
766
+ current: e.activityCurrent
767
+ }))) : null,
768
+ c.length ? M("div", { class: "stack-shell__nav-group stack-shell__switcher" }, [M("p", { class: "stack-shell__nav-heading" }, "Other Stack products"), M("ul", { class: "stack-shell__nav-list" }, c.map((e) => M("li", { class: "stack-shell__nav-entry" }, M("a", {
769
+ class: "stack-shell__nav-item",
770
+ href: e.href
771
+ }, e.name))))]) : null
772
+ ]), M("main", {
773
+ class: "stack-shell__main",
774
+ id: r,
775
+ tabindex: "-1",
776
+ ...F(e.mainAttrs)
777
+ }, e.children || null)])
778
+ ]);
779
+ }
780
+ var Ue = Object.freeze({
781
+ Breadcrumbs: ke,
782
+ Tabs: Ne,
783
+ TabPanel: Pe,
784
+ DataTable: Le,
785
+ FilterBar: ze,
786
+ Pagination: Be,
787
+ Shell: He,
788
+ StatusIndicator: he,
789
+ VerificationBadge: _e,
790
+ FreshnessLabel: be,
791
+ Unavailable: xe,
792
+ Loading: Se,
793
+ EmptyState: I,
794
+ ErrorPanel: L,
795
+ MetadataList: we,
796
+ ResourceIdentity: Te,
797
+ PageHeader: R,
798
+ Button: Oe
799
+ }), We = {
800
+ class: "className",
801
+ for: "htmlFor",
802
+ datetime: "dateTime",
803
+ tabindex: "tabIndex"
804
+ }, Ge = {
805
+ click: "onClick",
806
+ change: "onChange",
807
+ input: "onInput",
808
+ submit: "onSubmit",
809
+ keydown: "onKeyDown"
810
+ };
811
+ function Ke(e, t) {
812
+ if (e == null || e === !1 || e === !0) return null;
813
+ if (typeof e == "string" || typeof e == "number") return e;
814
+ if (Array.isArray(e)) return d(l, t === void 0 ? null : { key: t }, ...e.map((e, t) => Ke(e, t)));
815
+ if (f(e)) return t === void 0 ? e : d(l, { key: t }, e);
816
+ if (fe(e)) {
817
+ let n = e.k === void 0 ? t : e.k, r = n === void 0 ? {} : { key: n };
818
+ for (let [t, n] of Object.entries(e.a)) n != null && n !== !1 && (r[We[t] || t] = n);
819
+ let i = e.t === "input" || e.t === "select" || e.t === "textarea";
820
+ for (let [t, n] of Object.entries(e.on || {})) {
821
+ if (!Ge[t]) throw Error(`toReact: unsupported event ${t}`);
822
+ r[i && (t === "input" || t === "change") ? "onChange" : Ge[t]] = n;
823
+ }
824
+ let a = e.c;
825
+ if (e.t === "select") {
826
+ let e = a.find((e) => fe(e) && e.t === "option" && e.a.selected);
827
+ a = a.map((e) => fe(e) && e.t === "option" && e.a.selected ? {
828
+ ...e,
829
+ a: {
830
+ ...e.a,
831
+ selected: !1
832
+ }
833
+ } : e), e && (r.value = e.a.value);
834
+ }
835
+ i && "value" in r && !r.onChange && (r.defaultValue = r.value, delete r.value);
836
+ let o = a.map((e, t) => Ke(e, t));
837
+ return d(e.t, r, ...o);
838
+ }
839
+ throw TypeError("toReact: unsupported child");
840
+ }
841
+ var z = (e) => {
842
+ let t = Ue[e], n = (e) => Ke(t(e || {}));
843
+ return n.displayName = `Stack${e}`, n;
844
+ }, qe = z("StatusIndicator"), Je = z("VerificationBadge");
845
+ z("FreshnessLabel");
846
+ var Ye = z("Unavailable"), Xe = z("Loading");
847
+ z("EmptyState");
848
+ var Ze = z("ErrorPanel"), Qe = z("MetadataList");
849
+ z("ResourceIdentity");
850
+ var $e = z("PageHeader");
851
+ z("Button"), z("Breadcrumbs");
852
+ var et = z("Tabs"), tt = z("TabPanel"), nt = z("DataTable"), rt = z("FilterBar"), it = z("Pagination"), at = z("Shell"), ot = u(null);
853
+ function st({ options: e, runtime: t = "", children: n }) {
854
+ let { baseUrl: r = "", token: o = "", applicationId: s = "", environment: c = "production" } = e, l = g(() => new a({
855
+ baseUrl: r,
856
+ token: o,
857
+ applicationId: s,
858
+ environment: c
859
+ }), [
860
+ r,
861
+ o,
862
+ s,
863
+ c
864
+ ]), [u, d] = v(new i(null)), [f, p] = v(!0), [h, _] = v(""), [y, b] = v(0);
865
+ m(() => {
866
+ let e = !0;
867
+ return p(!0), l.capabilities().then((t) => {
868
+ e && (d(t), _(""));
869
+ }).catch((t) => {
870
+ e && (d(new i(null)), _(t instanceof Error ? t.message : "The control plane did not answer."));
871
+ }).finally(() => {
872
+ e && p(!1);
873
+ }), () => {
874
+ e = !1;
875
+ };
876
+ }, [l, y]);
877
+ let x = g(() => ({
878
+ api: l,
879
+ capabilities: u,
880
+ loading: f,
881
+ error: h,
882
+ applicationId: s,
883
+ environment: c,
884
+ runtime: t,
885
+ baseUrl: r,
886
+ token: o,
887
+ reload: () => b((e) => e + 1)
888
+ }), [
889
+ l,
890
+ u,
891
+ f,
892
+ h,
893
+ s,
894
+ c,
895
+ t,
896
+ r,
897
+ o
898
+ ]);
899
+ return /* @__PURE__ */ S(ot.Provider, {
900
+ value: x,
901
+ children: n
902
+ });
903
+ }
904
+ function B() {
905
+ let e = p(ot);
906
+ if (!e) throw Error("useControlPlane requires a ControlPlaneProvider");
907
+ return e;
908
+ }
909
+ function V(e, t, n = {}) {
910
+ let { api: r } = B(), i = n.enabled !== !1, [a, s] = v(), [c, l] = v(i), [u, d] = v(""), [f, p] = v(0);
911
+ return m(() => {
912
+ if (!i) {
913
+ l(!1);
914
+ return;
915
+ }
916
+ let t = !0, a = () => {
917
+ e(r).then((e) => {
918
+ t && (s(e), d(""));
919
+ }).catch((e) => {
920
+ t && d(o(e, n.subject));
921
+ }).finally(() => {
922
+ t && l(!1);
923
+ });
924
+ };
925
+ if (l(!0), a(), !n.refreshMs) return () => {
926
+ t = !1;
927
+ };
928
+ let c = window.setInterval(a, n.refreshMs);
929
+ return () => {
930
+ t = !1, window.clearInterval(c);
931
+ };
932
+ }, [
933
+ r,
934
+ i,
935
+ f,
936
+ ...t
937
+ ]), {
938
+ value: a,
939
+ loading: c,
940
+ error: u,
941
+ refresh: () => p((e) => e + 1)
942
+ };
943
+ }
944
+ //#endregion
945
+ //#region src/control-plane/primitives.tsx
946
+ function H({ status: e }) {
947
+ return /* @__PURE__ */ S("span", {
948
+ className: `cp-pill cp-pill-${e}`,
949
+ children: e.replace(/[-_]/g, " ")
950
+ });
951
+ }
952
+ function U({ capability: e, title: t }) {
953
+ let { capabilities: n } = B(), r = n.get(e), i = n.status(e);
954
+ return /* @__PURE__ */ S(Ye, {
955
+ status: i === "partial" ? "partial" : "unsupported",
956
+ capability: e,
957
+ title: t || r?.title || "Not available on this instance",
958
+ headingLevel: 3,
959
+ reason: n.note(e),
960
+ children: /* @__PURE__ */ C("p", {
961
+ className: "cp-unavailable-id",
962
+ children: [
963
+ "Capability ",
964
+ /* @__PURE__ */ S("code", { children: e }),
965
+ " · declared ",
966
+ /* @__PURE__ */ S(H, { status: i })
967
+ ]
968
+ })
969
+ });
970
+ }
971
+ function W({ capability: e, requireFull: t, children: n }) {
972
+ let { capabilities: r } = B(), i = r.status(e);
973
+ return i === "unsupported" || t && i !== "available" ? /* @__PURE__ */ S(U, { capability: e }) : /* @__PURE__ */ S(x, { children: n });
974
+ }
975
+ function ct({ capability: e }) {
976
+ let { capabilities: t } = B();
977
+ return t.status(e) === "partial" ? /* @__PURE__ */ S("p", {
978
+ className: "cp-notice",
979
+ children: t.note(e)
980
+ }) : null;
981
+ }
982
+ function G({ what: e }) {
983
+ return /* @__PURE__ */ S(Xe, { what: e });
984
+ }
985
+ function K({ message: e, onRetry: t }) {
986
+ return e ? /* @__PURE__ */ S(Ze, {
987
+ title: e,
988
+ onRetry: t
989
+ }) : null;
990
+ }
991
+ function q({ children: e }) {
992
+ return /* @__PURE__ */ S("p", {
993
+ className: "cp-empty",
994
+ children: e
995
+ });
996
+ }
997
+ function J({ label: e, value: t, hint: n }) {
998
+ let r = t == null ? "—" : typeof t == "number" ? t.toLocaleString() : String(t);
999
+ return /* @__PURE__ */ C("div", {
1000
+ className: "cp-stat",
1001
+ children: [/* @__PURE__ */ S("small", { children: e }), /* @__PURE__ */ S("strong", {
1002
+ title: n,
1003
+ children: r
1004
+ })]
1005
+ });
1006
+ }
1007
+ function Y({ value: e }) {
1008
+ return /* @__PURE__ */ S("pre", {
1009
+ className: "cp-json",
1010
+ children: JSON.stringify(e, null, 2)
1011
+ });
1012
+ }
1013
+ function lt({ path: e }) {
1014
+ return /* @__PURE__ */ S("code", {
1015
+ className: "cp-path",
1016
+ children: s(e)
1017
+ });
1018
+ }
1019
+ function X({ ms: e }) {
1020
+ if (!e) return /* @__PURE__ */ S("span", {
1021
+ className: "cp-muted",
1022
+ children: "—"
1023
+ });
1024
+ let t = new Date(e);
1025
+ return /* @__PURE__ */ S("time", {
1026
+ dateTime: t.toISOString(),
1027
+ title: t.toISOString(),
1028
+ children: t.toLocaleString()
1029
+ });
1030
+ }
1031
+ function Z({ value: e, length: t = 12 }) {
1032
+ return e ? /* @__PURE__ */ S("code", {
1033
+ className: "cp-identity",
1034
+ title: e,
1035
+ children: e.length > t ? `${e.slice(0, t)}…` : e
1036
+ }) : /* @__PURE__ */ S("span", {
1037
+ className: "cp-muted",
1038
+ children: "—"
1039
+ });
1040
+ }
1041
+ function Q({ tabs: e, active: t, onSelect: n, label: r, children: i }) {
1042
+ let a = `cp-tabs${h()}`, o = `${a}-panel`;
1043
+ return /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(et, {
1044
+ className: "cp-tabs",
1045
+ idPrefix: a,
1046
+ panelId: o,
1047
+ label: r,
1048
+ tabs: e,
1049
+ active: t,
1050
+ onSelect: (e) => n(e)
1051
+ }), /* @__PURE__ */ S(tt, {
1052
+ id: o,
1053
+ idPrefix: a,
1054
+ active: t,
1055
+ className: "cp-tabpanel",
1056
+ children: i
1057
+ })] });
1058
+ }
1059
+ function $({ eyebrow: e, title: t, description: n, children: r }) {
1060
+ return /* @__PURE__ */ C("div", {
1061
+ className: "cp-page",
1062
+ children: [/* @__PURE__ */ S($e, {
1063
+ eyebrow: e,
1064
+ title: t,
1065
+ description: n
1066
+ }), r]
1067
+ });
1068
+ }
1069
+ function ut() {
1070
+ let { runtime: e } = B();
1071
+ return e === "browser" ? /* @__PURE__ */ S("p", {
1072
+ className: "cp-notice",
1073
+ role: "note",
1074
+ "data-notice": "browser-runtime",
1075
+ children: "This application stores its records in the browser (IndexedDB) on its own origin. Studio reads the development authority, which receives no application writes in this mode, so record counts and tables here stay empty even while the application holds data. The Live Activity screen shows the application’s operations as they happen."
1076
+ }) : null;
1077
+ }
1078
+ //#endregion
1079
+ //#region src/control-plane/Overview.tsx
1080
+ function dt(e) {
1081
+ return e == null ? null : typeof e == "number" ? e.toLocaleString() : String(e);
1082
+ }
1083
+ var ft = (e) => e.map((e) => ({
1084
+ label: e.label,
1085
+ value: dt(e.value),
1086
+ hint: e.hint
1087
+ }));
1088
+ function pt() {
1089
+ let { value: e, loading: t, error: n, refresh: r } = V((e) => e.overview(), [], {
1090
+ refreshMs: 1e4,
1091
+ subject: "the instance overview"
1092
+ }), { capabilities: i } = B(), { value: a } = V((e) => e.replication(), [], {
1093
+ enabled: i.usable("replication.health"),
1094
+ refreshMs: 15e3,
1095
+ subject: "replication health"
1096
+ }), { value: o } = V((e) => e.transactions({ limit: 8 }), [], {
1097
+ enabled: i.usable("provenance.transactions"),
1098
+ refreshMs: 1e4,
1099
+ subject: "recent commits"
1100
+ });
1101
+ if (t && !e) return /* @__PURE__ */ S($, {
1102
+ eyebrow: "Instance",
1103
+ title: "Overview",
1104
+ children: /* @__PURE__ */ S(G, { what: "the instance" })
1105
+ });
1106
+ if (!e) return /* @__PURE__ */ S($, {
1107
+ eyebrow: "Instance",
1108
+ title: "Overview",
1109
+ children: /* @__PURE__ */ S(K, {
1110
+ message: n,
1111
+ onRetry: r
1112
+ })
1113
+ });
1114
+ let s = e.storage?.log_recovery || {}, c = e.storage?.collections, l = (e, t, n) => typeof e == "boolean" ? e ? t : n : void 0, u = a?.peers || [], d = o?.transactions?.[0];
1115
+ return /* @__PURE__ */ S($, {
1116
+ eyebrow: "Instance",
1117
+ title: "Overview",
1118
+ description: [e.instance?.namespace, e.instance?.instance_id].filter(Boolean).join(" · ") || void 0,
1119
+ children: /* @__PURE__ */ C(W, {
1120
+ capability: "overview.instance",
1121
+ children: [
1122
+ /* @__PURE__ */ S(ut, {}),
1123
+ /* @__PURE__ */ S(K, {
1124
+ message: n,
1125
+ onRetry: r
1126
+ }),
1127
+ /* @__PURE__ */ S("section", {
1128
+ "aria-label": "Instance status",
1129
+ children: /* @__PURE__ */ S(Qe, { items: ft([
1130
+ {
1131
+ label: "Engine",
1132
+ value: e.instance?.engine_version
1133
+ },
1134
+ {
1135
+ label: "Protocol",
1136
+ value: e.instance?.protocol_version
1137
+ },
1138
+ {
1139
+ label: "Uptime",
1140
+ value: e.instance?.uptime_seconds === void 0 ? void 0 : `${e.instance?.uptime_seconds}s`
1141
+ },
1142
+ {
1143
+ label: "Authentication",
1144
+ value: l(e.instance?.authentication_enabled, "Enabled", "Disabled")
1145
+ }
1146
+ ]) })
1147
+ }),
1148
+ /* @__PURE__ */ C("section", {
1149
+ className: "cp-panels",
1150
+ children: [
1151
+ /* @__PURE__ */ C("article", {
1152
+ className: "studio-card",
1153
+ children: [
1154
+ /* @__PURE__ */ S("span", {
1155
+ className: "card-kind",
1156
+ children: "Authority"
1157
+ }),
1158
+ /* @__PURE__ */ S(Qe, { items: [...ft([{
1159
+ label: "Authority revision",
1160
+ value: e.authority?.authority_revision,
1161
+ hint: "Monotonic commit order. One transaction advances it once."
1162
+ }, {
1163
+ label: "State version",
1164
+ value: e.authority?.state_version
1165
+ }]), {
1166
+ label: "Lease clock",
1167
+ value: typeof e.authority?.lease_clock_healthy == "boolean" ? /* @__PURE__ */ S(qe, {
1168
+ field: "feltdb.authority.lease_clock_healthy",
1169
+ value: e.authority?.lease_clock_healthy,
1170
+ attrs: { "data-overview": "lease-clock" }
1171
+ }) : null
1172
+ }] }),
1173
+ e.authority?.advertise_url && /* @__PURE__ */ C("p", {
1174
+ className: "cp-muted",
1175
+ children: ["Advertised at ", /* @__PURE__ */ S("code", { children: e.authority?.advertise_url })]
1176
+ })
1177
+ ]
1178
+ }),
1179
+ /* @__PURE__ */ C("article", {
1180
+ className: "studio-card",
1181
+ children: [
1182
+ /* @__PURE__ */ S("span", {
1183
+ className: "card-kind",
1184
+ children: "Storage and durability"
1185
+ }),
1186
+ /* @__PURE__ */ S(Qe, { items: ft([
1187
+ {
1188
+ label: "Records",
1189
+ value: e.storage?.records
1190
+ },
1191
+ {
1192
+ label: "State revisions",
1193
+ value: e.storage?.state_revisions
1194
+ },
1195
+ {
1196
+ label: "Collections",
1197
+ value: c?.length
1198
+ }
1199
+ ]) }),
1200
+ s.status && /* @__PURE__ */ S("p", {
1201
+ className: s.status === "clean" ? "cp-muted" : "cp-notice",
1202
+ children: s.status === "clean" ? "The durable log opened clean: every byte was a complete record." : `Log recovery discarded an incomplete final append at byte ${s.byte_offset} (${s.discarded_bytes} bytes). The last write before restart did not land.`
1203
+ })
1204
+ ]
1205
+ }),
1206
+ /* @__PURE__ */ C("article", {
1207
+ className: "studio-card",
1208
+ children: [/* @__PURE__ */ S("span", {
1209
+ className: "card-kind",
1210
+ children: "FeltDB runtime"
1211
+ }), /* @__PURE__ */ S(Qe, { items: ft([
1212
+ {
1213
+ label: "Autonomous worker",
1214
+ value: l(e.runtime?.worker_enabled, "Running", "Off")
1215
+ },
1216
+ {
1217
+ label: "Request deadline",
1218
+ value: e.runtime?.request_deadline_ms === void 0 ? void 0 : `${e.runtime?.request_deadline_ms} ms`
1219
+ },
1220
+ {
1221
+ label: "Admission slots free",
1222
+ value: e.runtime?.admission_permits_available
1223
+ }
1224
+ ]) })]
1225
+ }),
1226
+ /* @__PURE__ */ C("article", {
1227
+ className: "studio-card",
1228
+ children: [/* @__PURE__ */ S("span", {
1229
+ className: "card-kind",
1230
+ children: "Replication"
1231
+ }), /* @__PURE__ */ S(Qe, { items: ft([
1232
+ {
1233
+ label: "Peers",
1234
+ value: a ? u.length : void 0
1235
+ },
1236
+ {
1237
+ label: "Sync failures",
1238
+ value: a?.health?.peer_sync_failures
1239
+ },
1240
+ {
1241
+ label: "Operations sent",
1242
+ value: a?.health?.operations_sent
1243
+ }
1244
+ ]) })]
1245
+ })
1246
+ ]
1247
+ }),
1248
+ /* @__PURE__ */ C("section", {
1249
+ className: "studio-card",
1250
+ children: [
1251
+ /* @__PURE__ */ S("span", {
1252
+ className: "card-kind",
1253
+ children: "Activity"
1254
+ }),
1255
+ /* @__PURE__ */ S(Qe, { items: ft([
1256
+ {
1257
+ label: "Requests",
1258
+ value: e.activity?.requests
1259
+ },
1260
+ {
1261
+ label: "State reads",
1262
+ value: e.activity?.state_reads
1263
+ },
1264
+ {
1265
+ label: "State mutations",
1266
+ value: e.activity?.state_mutations
1267
+ },
1268
+ {
1269
+ label: "Requests shed",
1270
+ value: e.activity?.requests_shed,
1271
+ hint: "Refused at the door because the server was already at its in-flight limit."
1272
+ },
1273
+ {
1274
+ label: "Deadlines exceeded",
1275
+ value: e.activity?.request_deadlines_exceeded
1276
+ },
1277
+ {
1278
+ label: "Authentication failures",
1279
+ value: e.activity?.authentication_failures
1280
+ }
1281
+ ]) }),
1282
+ d ? /* @__PURE__ */ C("p", {
1283
+ className: "cp-muted",
1284
+ children: [
1285
+ "Last recorded commit ",
1286
+ /* @__PURE__ */ S("code", { children: d.transaction_id }),
1287
+ " by ",
1288
+ /* @__PURE__ */ S("strong", { children: d.subject || "an unnamed actor" }),
1289
+ " · ",
1290
+ /* @__PURE__ */ S(X, { ms: d.unix_ms })
1291
+ ]
1292
+ }) : /* @__PURE__ */ S("p", {
1293
+ className: "cp-muted",
1294
+ children: "No commit is inside the attribution window yet."
1295
+ })
1296
+ ]
1297
+ }),
1298
+ /* @__PURE__ */ C("section", {
1299
+ className: "studio-card",
1300
+ children: [/* @__PURE__ */ S("span", {
1301
+ className: "card-kind",
1302
+ children: "Collections"
1303
+ }), c ? c.length === 0 ? /* @__PURE__ */ S(q, { children: "This instance holds no application collections yet." }) : /* @__PURE__ */ S(nt, {
1304
+ label: "Application collections",
1305
+ columns: [
1306
+ {
1307
+ id: "collection",
1308
+ header: "Collection"
1309
+ },
1310
+ {
1311
+ id: "capability",
1312
+ header: "Capability"
1313
+ },
1314
+ {
1315
+ id: "records",
1316
+ header: "Records",
1317
+ align: "end"
1318
+ }
1319
+ ],
1320
+ rows: c.map((e) => ({
1321
+ key: e.capability,
1322
+ cells: {
1323
+ collection: e.collection,
1324
+ capability: /* @__PURE__ */ S("code", { children: e.capability }),
1325
+ records: Number(e.records).toLocaleString()
1326
+ }
1327
+ }))
1328
+ }) : /* @__PURE__ */ S(q, { children: "This instance did not report its collections." })]
1329
+ }),
1330
+ /* @__PURE__ */ C("details", {
1331
+ className: "cp-raw",
1332
+ children: [/* @__PURE__ */ S("summary", { children: "Raw overview document" }), /* @__PURE__ */ S(Y, { value: e })]
1333
+ })
1334
+ ]
1335
+ })
1336
+ });
1337
+ }
1338
+ //#endregion
1339
+ //#region src/control-plane/Data.tsx
1340
+ function mt({ field: e, value: t }) {
1341
+ let n = r(e, t);
1342
+ return n == null ? /* @__PURE__ */ S("span", {
1343
+ className: "data-null",
1344
+ children: "—"
1345
+ }) : typeof n == "boolean" ? /* @__PURE__ */ S("span", {
1346
+ className: `data-boolean ${n}`,
1347
+ children: n ? "True" : "False"
1348
+ }) : typeof n == "object" ? /* @__PURE__ */ C("details", { children: [/* @__PURE__ */ S("summary", { children: Array.isArray(n) ? `${n.length} items` : "Object" }), /* @__PURE__ */ S("pre", { children: JSON.stringify(n, null, 2) })] }) : /* @__PURE__ */ S(x, { children: String(n) });
1349
+ }
1350
+ function ht({ action: e, fields: n, initial: r, onSubmit: i, onCancel: a }) {
1351
+ let [s, c] = v(() => {
1352
+ let t = { id: r?.id === void 0 ? "" : String(r.id) };
1353
+ for (let n of e.input_fields) {
1354
+ let e = r?.[n];
1355
+ t[n] = e == null ? "" : typeof e == "object" ? JSON.stringify(e) : String(e);
1356
+ }
1357
+ return t;
1358
+ }), [l, u] = v(!1), [d, f] = v(""), p = (e) => n.find((t) => t.name === e)?.type || "text", m = async () => {
1359
+ u(!0), f("");
1360
+ try {
1361
+ let t = {};
1362
+ s.id.trim() && (t.id = s.id.trim());
1363
+ for (let n of e.input_fields) {
1364
+ let e = s[n];
1365
+ if (e === "") continue;
1366
+ let r = p(n);
1367
+ if (r === "boolean") t[n] = e === "true";
1368
+ else if (/integer|number|decimal/.test(r)) t[n] = Number(e);
1369
+ else if (/json|object|array|map/.test(r)) try {
1370
+ t[n] = JSON.parse(e);
1371
+ } catch {
1372
+ throw Error(`${n} is declared ${r} and must be valid JSON.`);
1373
+ }
1374
+ else t[n] = e;
1375
+ }
1376
+ await i(t);
1377
+ } catch (t) {
1378
+ f(t instanceof Error && !("code" in t) ? t.message : o(t, e.name));
1379
+ } finally {
1380
+ u(!1);
1381
+ }
1382
+ };
1383
+ return /* @__PURE__ */ C("form", {
1384
+ className: "studio-card cp-action-form",
1385
+ onSubmit: (e) => {
1386
+ e.preventDefault(), m();
1387
+ },
1388
+ children: [
1389
+ /* @__PURE__ */ C("span", {
1390
+ className: "card-kind",
1391
+ children: [
1392
+ e.operation,
1393
+ " · ",
1394
+ e.name
1395
+ ]
1396
+ }),
1397
+ /* @__PURE__ */ C("label", { children: ["id", /* @__PURE__ */ S("input", {
1398
+ value: s.id,
1399
+ onChange: (e) => c((t) => ({
1400
+ ...t,
1401
+ id: e.target.value
1402
+ })),
1403
+ placeholder: e.operation === "create" ? "optional — FeltDB derives one" : "required"
1404
+ })] }),
1405
+ e.operation !== "delete" && e.input_fields.map((e) => /* @__PURE__ */ C("label", { children: [
1406
+ e,
1407
+ " ",
1408
+ /* @__PURE__ */ C("small", { children: [p(e), t(e) ? " · secret" : ""] }),
1409
+ p(e) === "boolean" ? /* @__PURE__ */ C("select", {
1410
+ value: s[e],
1411
+ onChange: (t) => c((n) => ({
1412
+ ...n,
1413
+ [e]: t.target.value
1414
+ })),
1415
+ children: [
1416
+ /* @__PURE__ */ S("option", {
1417
+ value: "",
1418
+ children: "unset"
1419
+ }),
1420
+ /* @__PURE__ */ S("option", {
1421
+ value: "true",
1422
+ children: "true"
1423
+ }),
1424
+ /* @__PURE__ */ S("option", {
1425
+ value: "false",
1426
+ children: "false"
1427
+ })
1428
+ ]
1429
+ }) : /* @__PURE__ */ S("input", {
1430
+ value: s[e],
1431
+ onChange: (t) => c((n) => ({
1432
+ ...n,
1433
+ [e]: t.target.value
1434
+ }))
1435
+ })
1436
+ ] }, e)),
1437
+ /* @__PURE__ */ S(K, { message: d }),
1438
+ /* @__PURE__ */ C("div", {
1439
+ className: "cp-actions",
1440
+ children: [/* @__PURE__ */ S("button", {
1441
+ type: "button",
1442
+ className: "btn btn-ghost",
1443
+ onClick: a,
1444
+ children: "Cancel"
1445
+ }), /* @__PURE__ */ S("button", {
1446
+ className: "btn btn-primary",
1447
+ disabled: l,
1448
+ children: l ? "Running…" : `Run ${e.name}`
1449
+ })]
1450
+ })
1451
+ ]
1452
+ });
1453
+ }
1454
+ function gt({ collection: e, id: t }) {
1455
+ let { value: n, loading: r, error: i, refresh: a } = V((n) => n.provenance(e, t), [e, t], { subject: "this record’s provenance" });
1456
+ if (r && !n) return /* @__PURE__ */ S(G, { what: "provenance" });
1457
+ if (!n) return /* @__PURE__ */ S(K, {
1458
+ message: i,
1459
+ onRetry: a
1460
+ });
1461
+ let o = n.attribution.actor;
1462
+ return /* @__PURE__ */ C(x, { children: [
1463
+ /* @__PURE__ */ C("p", {
1464
+ className: "cp-attribution",
1465
+ children: [
1466
+ o ? /* @__PURE__ */ C(x, { children: ["Last changed by ", /* @__PURE__ */ S("strong", { children: o })] }) : /* @__PURE__ */ S(x, { children: "No actor is recorded for the last change" }),
1467
+ n.attribution.authority && /* @__PURE__ */ C(x, { children: [" on authority ", /* @__PURE__ */ S("code", { children: n.attribution.authority })] }),
1468
+ " · ",
1469
+ /* @__PURE__ */ S(X, { ms: n.updated_ms })
1470
+ ]
1471
+ }),
1472
+ /* @__PURE__ */ C("div", {
1473
+ className: "cp-stats",
1474
+ children: [
1475
+ /* @__PURE__ */ S(J, {
1476
+ label: "Attribution source",
1477
+ value: n.attribution.source,
1478
+ hint: "transaction: an actor's commit named this record. authority: only the writing instance is known."
1479
+ }),
1480
+ /* @__PURE__ */ S(J, {
1481
+ label: "Content hash",
1482
+ value: n.content_hash ? `${n.content_hash.slice(0, 12)}…` : void 0
1483
+ }),
1484
+ /* @__PURE__ */ S(J, {
1485
+ label: "Commits held",
1486
+ value: n.transactions.length
1487
+ }),
1488
+ /* @__PURE__ */ S(J, {
1489
+ label: "State revisions",
1490
+ value: n.revisions.length
1491
+ })
1492
+ ]
1493
+ }),
1494
+ /* @__PURE__ */ S("h3", { children: "Commits that named this record" }),
1495
+ /* @__PURE__ */ S(ct, { capability: "provenance.transactions" }),
1496
+ n.transactions.length === 0 ? /* @__PURE__ */ S(q, { children: "No commit inside the attribution window named this record." }) : /* @__PURE__ */ S("div", {
1497
+ className: "table-shell",
1498
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
1499
+ /* @__PURE__ */ S("th", { children: "When" }),
1500
+ /* @__PURE__ */ S("th", { children: "Actor" }),
1501
+ /* @__PURE__ */ S("th", { children: "Transaction" }),
1502
+ /* @__PURE__ */ S("th", { children: "Records" }),
1503
+ /* @__PURE__ */ S("th", { children: "Revision" })
1504
+ ] }) }), /* @__PURE__ */ S("tbody", { children: n.transactions.map((e) => /* @__PURE__ */ C("tr", { children: [
1505
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(X, { ms: e.unix_ms }) }),
1506
+ /* @__PURE__ */ S("td", { children: e.subject || /* @__PURE__ */ S("span", {
1507
+ className: "cp-muted",
1508
+ children: "unnamed"
1509
+ }) }),
1510
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, {
1511
+ value: e.transaction_id,
1512
+ length: 16
1513
+ }) }),
1514
+ /* @__PURE__ */ S("td", { children: e.operations }),
1515
+ /* @__PURE__ */ C("td", { children: [
1516
+ e.base_revision,
1517
+ " → ",
1518
+ e.commit_revision
1519
+ ] })
1520
+ ] }, e.transaction_id)) })] })
1521
+ }),
1522
+ /* @__PURE__ */ S("h3", { children: "State revisions" }),
1523
+ n.revisions.length === 0 ? /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(ct, { capability: "data.records.history" }), /* @__PURE__ */ S(q, { children: "This record has no state revisions. Its write path advances the authority revision without minting one." })] }) : /* @__PURE__ */ S("div", {
1524
+ className: "table-shell",
1525
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
1526
+ /* @__PURE__ */ S("th", { children: "#" }),
1527
+ /* @__PURE__ */ S("th", { children: "State ID" }),
1528
+ /* @__PURE__ */ S("th", { children: "Parent" }),
1529
+ /* @__PURE__ */ S("th", { children: "Authority" }),
1530
+ /* @__PURE__ */ S("th", { children: "When" })
1531
+ ] }) }), /* @__PURE__ */ S("tbody", { children: n.revisions.map((e) => /* @__PURE__ */ C("tr", { children: [
1532
+ /* @__PURE__ */ S("td", { children: e.sequence }),
1533
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, { value: e.state_id }) }),
1534
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, { value: e.parent_id }) }),
1535
+ /* @__PURE__ */ S("td", { children: e.authority }),
1536
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(X, { ms: e.timestamp_ms }) })
1537
+ ] }, e.state_id)) })] })
1538
+ }),
1539
+ /* @__PURE__ */ C("details", {
1540
+ className: "cp-raw",
1541
+ children: [/* @__PURE__ */ S("summary", { children: "Raw operation record" }), /* @__PURE__ */ S(Y, { value: n.operation })]
1542
+ })
1543
+ ] });
1544
+ }
1545
+ function _t({ schema: e }) {
1546
+ return /* @__PURE__ */ S("div", {
1547
+ className: "table-shell",
1548
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
1549
+ /* @__PURE__ */ S("th", { children: "Field" }),
1550
+ /* @__PURE__ */ S("th", { children: "Type" }),
1551
+ /* @__PURE__ */ S("th", { children: "Required" }),
1552
+ /* @__PURE__ */ S("th", { children: "Reference" })
1553
+ ] }) }), /* @__PURE__ */ S("tbody", { children: e.fields.map((e) => /* @__PURE__ */ C("tr", { children: [
1554
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: e.name }) }),
1555
+ /* @__PURE__ */ S("td", { children: e.type }),
1556
+ /* @__PURE__ */ S("td", { children: e.required ? "required" : "optional" }),
1557
+ /* @__PURE__ */ S("td", { children: e.reference ? /* @__PURE__ */ C("span", {
1558
+ className: "reference-value",
1559
+ children: ["→ ", e.reference]
1560
+ }) : /* @__PURE__ */ S("span", {
1561
+ className: "cp-muted",
1562
+ children: "—"
1563
+ }) })
1564
+ ] }, e.name)) })] })
1565
+ });
1566
+ }
1567
+ function vt({ collection: e, report: t, onRebuild: n }) {
1568
+ let { capabilities: r } = B();
1569
+ if (!t) return /* @__PURE__ */ S(G, { what: "indexes" });
1570
+ let i = t.declared.filter((t) => t.collection === e), a = t.access_paths.find((t) => t.collection === e);
1571
+ return /* @__PURE__ */ C(x, { children: [
1572
+ /* @__PURE__ */ S("h3", { children: "Declared indexes" }),
1573
+ i.length === 0 ? /* @__PURE__ */ C(q, { children: [
1574
+ "The application contract declares no index on ",
1575
+ e,
1576
+ "."
1577
+ ] }) : /* @__PURE__ */ S("div", {
1578
+ className: "table-shell",
1579
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
1580
+ /* @__PURE__ */ S("th", { children: "Index" }),
1581
+ /* @__PURE__ */ S("th", { children: "Fields" }),
1582
+ /* @__PURE__ */ S("th", { children: "Unique" }),
1583
+ /* @__PURE__ */ S("th", { children: "State" }),
1584
+ /* @__PURE__ */ S("th", {})
1585
+ ] }) }), /* @__PURE__ */ S("tbody", { children: i.map((e) => /* @__PURE__ */ C("tr", { children: [
1586
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: e.name }) }),
1587
+ /* @__PURE__ */ S("td", { children: e.fields.map((e) => /* @__PURE__ */ S("span", {
1588
+ className: e.backed ? "cp-grant granted" : "cp-grant denied",
1589
+ children: e.field
1590
+ }, e.field)) }),
1591
+ /* @__PURE__ */ S("td", { children: e.unique ? "unique" : "non-unique" }),
1592
+ /* @__PURE__ */ C("td", { children: [
1593
+ /* @__PURE__ */ S(H, { status: e.state === "backed" ? "available" : "partial" }),
1594
+ " ",
1595
+ e.state
1596
+ ] }),
1597
+ /* @__PURE__ */ S("td", { children: r.usable("data.indexes.rebuild") && e.fields.map((e) => /* @__PURE__ */ C("button", {
1598
+ className: "btn btn-ghost",
1599
+ onClick: () => n(e.field),
1600
+ children: ["Rebuild ", e.field]
1601
+ }, e.field)) })
1602
+ ] }, e.name)) })] })
1603
+ }),
1604
+ /* @__PURE__ */ S("h3", { children: "Access paths" }),
1605
+ /* @__PURE__ */ S("p", {
1606
+ className: "cp-muted",
1607
+ children: "How an equality filter on each field would be served. A field served by a scan is still filterable — it is filterable by reading the collection, which is the thing an operator needs to know before running it against a large collection."
1608
+ }),
1609
+ /* @__PURE__ */ S("div", {
1610
+ className: "table-shell",
1611
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [/* @__PURE__ */ S("th", { children: "Field" }), /* @__PURE__ */ S("th", { children: "Access method" })] }) }), /* @__PURE__ */ S("tbody", { children: (a?.fields || []).map((e) => /* @__PURE__ */ C("tr", { children: [/* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: e.field }) }), /* @__PURE__ */ C("td", { children: [
1612
+ /* @__PURE__ */ S(H, { status: e.access_method === "index" ? "available" : "partial" }),
1613
+ " ",
1614
+ e.access_method === "index" ? "index" : "full scan"
1615
+ ] })] }, e.field)) })] })
1616
+ })
1617
+ ] });
1618
+ }
1619
+ function yt({ focus: t, onFocusHandled: r }) {
1620
+ let { api: i, applicationId: a, environment: s, capabilities: l, baseUrl: u, token: d } = B(), [f, p] = b(), m = f.get("collection") || "", h = g(() => new e({
1621
+ baseUrl: u,
1622
+ token: d,
1623
+ applicationId: a,
1624
+ environment: s
1625
+ }), [
1626
+ u,
1627
+ d,
1628
+ a,
1629
+ s
1630
+ ]), [_, y] = v(""), [w, ee] = v("browse"), [T, E] = v(""), [D, O] = v("data"), [k, A] = v(""), [j, te] = v(""), [ne, re] = v({}), [ie, ae] = v(), [oe, se] = v([]), [ce, le] = v(null), [ue, de] = v(""), { value: M, loading: fe, error: N, refresh: P } = V(() => h.schema(), [h], { subject: "the application schema" }), { value: F } = V((e) => e.actions(), [], {
1631
+ enabled: [
1632
+ "data.records.create",
1633
+ "data.records.update",
1634
+ "data.records.delete"
1635
+ ].some((e) => l.usable(e)),
1636
+ subject: "declared actions"
1637
+ }), { value: pe, refresh: me } = V((e) => e.indexes(), [], {
1638
+ enabled: l.usable("data.indexes.inspect"),
1639
+ subject: "indexes"
1640
+ }), he = n(a, M), ge = g(() => new e({
1641
+ baseUrl: u,
1642
+ token: d,
1643
+ applicationId: he,
1644
+ environment: s
1645
+ }), [
1646
+ u,
1647
+ d,
1648
+ he,
1649
+ s
1650
+ ]);
1651
+ c.useEffect(() => {
1652
+ M?.collections.length && y((e) => M.collections.some((e) => e.collection === m) ? m : M.collections.some((t) => t.collection === e) ? e : M.collections[0].collection);
1653
+ }, [M, m]), c.useEffect(() => {
1654
+ t && (y(t.collection), E(t.id), O("provenance"), r?.());
1655
+ }, [t]);
1656
+ let _e = JSON.stringify([
1657
+ _,
1658
+ ie ?? null,
1659
+ ne
1660
+ ]), { value: ve, loading: ye, error: be, refresh: xe } = V(() => ge.records(_, ie, ne).then((e) => ({
1661
+ ...e,
1662
+ request: _e
1663
+ })), [ge, _e], {
1664
+ enabled: !!_,
1665
+ subject: _
1666
+ }), { value: Se, error: Ce } = V(() => ge.record(_, T), [
1667
+ ge,
1668
+ _,
1669
+ T
1670
+ ], {
1671
+ enabled: !!(_ && T),
1672
+ subject: `record ${T}`
1673
+ }), I = M?.collections.find((e) => e.collection === _), L = ve?.request === _e && ve.collection === _ ? ve : void 0, we = F?.collections.find((e) => e.collection === _)?.actions || [], Te = (e) => {
1674
+ let t = new URLSearchParams(f);
1675
+ t.set("collection", e), p(t), y(e), E(""), se([]), ae(void 0), re({});
1676
+ }, R = (e) => we.find((t) => t.operation === e), Ee = async (e, t) => {
1677
+ await i.runAction(F.revision_id, e.name, t), le(null), de(`${e.name} committed.`), xe(), e.operation === "delete" && E("");
1678
+ }, De = async (e) => {
1679
+ de("");
1680
+ try {
1681
+ await i.rebuildIndex(_, e), de(`Rebuilt the index on ${_}.${e}.`), me();
1682
+ } catch (t) {
1683
+ de(o(t, `${_}.${e}`));
1684
+ }
1685
+ };
1686
+ if (fe && !M) return /* @__PURE__ */ S($, {
1687
+ eyebrow: "Data",
1688
+ title: "Data",
1689
+ children: /* @__PURE__ */ S(G, { what: "application data" })
1690
+ });
1691
+ if (!M) {
1692
+ let e = !!(a || u || d);
1693
+ return /* @__PURE__ */ S($, {
1694
+ eyebrow: "Data",
1695
+ title: "Data",
1696
+ children: /* @__PURE__ */ C("section", {
1697
+ className: "studio-card",
1698
+ role: e ? "alert" : "status",
1699
+ children: [
1700
+ /* @__PURE__ */ S("span", {
1701
+ className: "card-kind",
1702
+ children: "Application data"
1703
+ }),
1704
+ /* @__PURE__ */ S("h2", { children: e ? "Data unavailable" : "No application connected" }),
1705
+ /* @__PURE__ */ S("p", { children: e ? "Studio could not read application data from the current FeltDB authority. Check that the development authority is running." : "Connect Studio to a FeltDB application to inspect its data." }),
1706
+ /* @__PURE__ */ S("button", {
1707
+ className: "btn btn-ghost",
1708
+ onClick: P,
1709
+ children: "Retry"
1710
+ })
1711
+ ]
1712
+ })
1713
+ });
1714
+ }
1715
+ return /* @__PURE__ */ C($, {
1716
+ eyebrow: "Data",
1717
+ title: "Data",
1718
+ description: "Records as FeltDB holds them, authorized and redacted by the Service API.",
1719
+ children: [/* @__PURE__ */ S(ut, {}), /* @__PURE__ */ C(W, {
1720
+ capability: "data.collections.list",
1721
+ children: [
1722
+ /* @__PURE__ */ S(K, { message: N }),
1723
+ ue && /* @__PURE__ */ S("p", {
1724
+ className: "cp-notice",
1725
+ children: ue
1726
+ }),
1727
+ /* @__PURE__ */ C("div", {
1728
+ className: "data-layout",
1729
+ children: [/* @__PURE__ */ C("aside", {
1730
+ className: "studio-card",
1731
+ children: [
1732
+ /* @__PURE__ */ S("span", {
1733
+ className: "card-kind",
1734
+ children: "Collections"
1735
+ }),
1736
+ (M?.collections || []).map((e) => {
1737
+ let t = pe?.declared.filter((t) => t.collection === e.collection).length || 0;
1738
+ return /* @__PURE__ */ C("button", {
1739
+ className: e.collection === _ ? "active" : "",
1740
+ onClick: () => Te(e.collection),
1741
+ children: [e.collection, /* @__PURE__ */ C("small", { children: [
1742
+ e.fields.length,
1743
+ " fields · ",
1744
+ t,
1745
+ " indexes"
1746
+ ] })]
1747
+ }, e.collection);
1748
+ }),
1749
+ !M?.collections.length && /* @__PURE__ */ S(q, { children: "No collections in this contract." })
1750
+ ]
1751
+ }), /* @__PURE__ */ C("section", {
1752
+ className: "data-browser",
1753
+ children: [/* @__PURE__ */ C("header", { children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("span", {
1754
+ className: "card-kind",
1755
+ children: "collection"
1756
+ }), /* @__PURE__ */ S("h2", { children: _ || "Data" })] }), /* @__PURE__ */ C("div", {
1757
+ className: "cp-actions",
1758
+ children: [R("create") && l.usable("data.records.create") && /* @__PURE__ */ C("button", {
1759
+ className: "btn btn-primary",
1760
+ onClick: () => le({ action: R("create") }),
1761
+ children: ["New ", _]
1762
+ }), !R("create") && _ && /* @__PURE__ */ C("span", {
1763
+ className: "cp-muted",
1764
+ children: [
1765
+ "No declared create action for ",
1766
+ _,
1767
+ ", so nothing can create one."
1768
+ ]
1769
+ })]
1770
+ })] }), /* @__PURE__ */ C(Q, {
1771
+ label: `${_ || "Collection"} sections`,
1772
+ active: w,
1773
+ onSelect: ee,
1774
+ tabs: [
1775
+ {
1776
+ id: "browse",
1777
+ label: "Browse"
1778
+ },
1779
+ {
1780
+ id: "schema",
1781
+ label: "Schema"
1782
+ },
1783
+ {
1784
+ id: "indexes",
1785
+ label: "Indexes"
1786
+ }
1787
+ ],
1788
+ children: [
1789
+ w === "schema" && I && /* @__PURE__ */ S(_t, { schema: I }),
1790
+ w === "indexes" && /* @__PURE__ */ S(W, {
1791
+ capability: "data.indexes.inspect",
1792
+ children: /* @__PURE__ */ S(vt, {
1793
+ collection: _,
1794
+ report: pe,
1795
+ onRebuild: (e) => void De(e)
1796
+ })
1797
+ }),
1798
+ w === "browse" && /* @__PURE__ */ C(W, {
1799
+ capability: "data.records.browse",
1800
+ children: [
1801
+ I && /* @__PURE__ */ S(rt, {
1802
+ label: `Filter ${_}`,
1803
+ idPrefix: "data-filter",
1804
+ filters: [{
1805
+ id: "field",
1806
+ label: "Field",
1807
+ type: "select",
1808
+ value: k,
1809
+ options: [{
1810
+ value: "",
1811
+ label: "Choose a field"
1812
+ }, ...I.fields.map((e) => {
1813
+ let t = pe?.access_paths.find((e) => e.collection === _)?.fields.find((t) => t.field === e.name)?.access_method;
1814
+ return {
1815
+ value: e.name,
1816
+ label: `${e.name}${t ? ` (${t === "index" ? "indexed" : "scan"})` : ""}`
1817
+ };
1818
+ })]
1819
+ }, {
1820
+ id: "value",
1821
+ label: "Equals",
1822
+ value: j,
1823
+ placeholder: "Value"
1824
+ }],
1825
+ onChange: (e, t) => e === "field" ? A(t) : te(t),
1826
+ onSubmit: () => {
1827
+ se([]), ae(void 0), re(k && j ? { [k]: j } : {});
1828
+ },
1829
+ applied: Object.keys(ne).length,
1830
+ onClear: () => {
1831
+ se([]), ae(void 0), A(""), te(""), re({});
1832
+ },
1833
+ result: L && Object.keys(ne).length ? `${L.records.length} ${L.records.length === 1 ? "record matches" : "records match"}${L.pagination.nextCursor ? " on this page" : ""}` : ""
1834
+ }),
1835
+ l.status("data.records.sort") === "unsupported" && /* @__PURE__ */ C("p", {
1836
+ className: "cp-muted",
1837
+ children: ["Listed in record-key order. ", l.note("data.records.sort")]
1838
+ }),
1839
+ I && /* @__PURE__ */ S(nt, {
1840
+ label: `${_} records`,
1841
+ loading: !be && (ye || !L),
1842
+ loadingWhat: _,
1843
+ error: be ? {
1844
+ message: be,
1845
+ onRetry: xe
1846
+ } : null,
1847
+ columns: [{
1848
+ id: "id",
1849
+ header: "id"
1850
+ }, ...I.fields.map((e) => ({
1851
+ id: `field:${e.name}`,
1852
+ header: /* @__PURE__ */ C(x, { children: [e.name, /* @__PURE__ */ S("small", { children: e.type })] })
1853
+ }))],
1854
+ rows: (L?.records || []).map((e) => ({
1855
+ key: String(e.id),
1856
+ selected: String(e.id) === T,
1857
+ onSelect: () => {
1858
+ E(String(e.id)), O("data");
1859
+ },
1860
+ attrs: { "data-record": String(e.id) },
1861
+ cells: {
1862
+ id: /* @__PURE__ */ S("code", { children: String(e.id) }),
1863
+ ...Object.fromEntries(I.fields.map((t) => [`field:${t.name}`, /* @__PURE__ */ S(mt, {
1864
+ field: t,
1865
+ value: e[t.name]
1866
+ })]))
1867
+ }
1868
+ })),
1869
+ noMatch: Object.keys(ne).length > 0,
1870
+ noMatchTitle: "No records match",
1871
+ noMatchBody: "Change or clear the filter.",
1872
+ emptyTitle: "No records yet"
1873
+ }),
1874
+ /* @__PURE__ */ S(it, {
1875
+ label: `${_} pages`,
1876
+ summary: L ? `${L.records.length} shown · state version ${L.state_version}` : void 0,
1877
+ hasPrevious: oe.length > 0,
1878
+ hasNext: !!L?.pagination.nextCursor,
1879
+ onPrevious: () => {
1880
+ let e = oe.at(-1);
1881
+ se((e) => e.slice(0, -1)), ae(e);
1882
+ },
1883
+ onNext: () => {
1884
+ se((e) => [...e, ie]), ae(L.pagination.nextCursor);
1885
+ }
1886
+ })
1887
+ ]
1888
+ })
1889
+ ]
1890
+ })]
1891
+ })]
1892
+ }),
1893
+ ce && I && /* @__PURE__ */ S(ht, {
1894
+ action: ce.action,
1895
+ fields: I.fields,
1896
+ initial: ce.initial,
1897
+ onCancel: () => le(null),
1898
+ onSubmit: (e) => Ee(ce.action, e)
1899
+ }),
1900
+ T && l.usable("data.records.inspect") && /* @__PURE__ */ C("section", {
1901
+ className: "cp-detail studio-card",
1902
+ children: [
1903
+ /* @__PURE__ */ C("header", {
1904
+ className: "cp-detail-header",
1905
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("span", {
1906
+ className: "card-kind",
1907
+ children: "record"
1908
+ }), /* @__PURE__ */ C("h2", { children: [
1909
+ _,
1910
+ " / ",
1911
+ T
1912
+ ] })] }), /* @__PURE__ */ C("div", {
1913
+ className: "cp-actions",
1914
+ children: [
1915
+ R("update") && Se && l.usable("data.records.update") && /* @__PURE__ */ S("button", {
1916
+ className: "btn btn-ghost",
1917
+ onClick: () => le({
1918
+ action: R("update"),
1919
+ initial: Se.record
1920
+ }),
1921
+ children: "Edit"
1922
+ }),
1923
+ R("delete") && l.usable("data.records.delete") && /* @__PURE__ */ S("button", {
1924
+ className: "btn btn-ghost",
1925
+ onClick: () => le({
1926
+ action: R("delete"),
1927
+ initial: { id: T }
1928
+ }),
1929
+ children: "Delete"
1930
+ }),
1931
+ /* @__PURE__ */ S("button", {
1932
+ className: "data-close",
1933
+ onClick: () => E(""),
1934
+ "aria-label": "Close record",
1935
+ children: "×"
1936
+ })
1937
+ ]
1938
+ })]
1939
+ }),
1940
+ !R("update") && !R("delete") && /* @__PURE__ */ S("p", {
1941
+ className: "cp-muted",
1942
+ children: "This collection declares no update or delete action, so nothing — Studio, an application, or an agent — can change these records in place."
1943
+ }),
1944
+ /* @__PURE__ */ C(Q, {
1945
+ label: "Record sections",
1946
+ active: D,
1947
+ onSelect: O,
1948
+ tabs: [{
1949
+ id: "data",
1950
+ label: "Data"
1951
+ }, {
1952
+ id: "provenance",
1953
+ label: "Provenance"
1954
+ }],
1955
+ children: [
1956
+ /* @__PURE__ */ S(K, { message: Ce }),
1957
+ D === "data" && Se && I && /* @__PURE__ */ C("dl", {
1958
+ className: "cp-record",
1959
+ children: [
1960
+ /* @__PURE__ */ S("dt", { children: "id" }),
1961
+ /* @__PURE__ */ S("dd", { children: /* @__PURE__ */ S("code", { children: String(Se.record.id) }) }),
1962
+ I.fields.map((e) => /* @__PURE__ */ C(c.Fragment, { children: [/* @__PURE__ */ C("dt", { children: [e.name, /* @__PURE__ */ C("small", { children: [e.type, e.required ? " · required" : ""] })] }), /* @__PURE__ */ S("dd", { children: /* @__PURE__ */ S(mt, {
1963
+ field: e,
1964
+ value: Se.record[e.name]
1965
+ }) })] }, e.name))
1966
+ ]
1967
+ }),
1968
+ D === "provenance" && /* @__PURE__ */ S(W, {
1969
+ capability: "provenance.record",
1970
+ children: /* @__PURE__ */ S(gt, {
1971
+ collection: _,
1972
+ id: T
1973
+ })
1974
+ })
1975
+ ]
1976
+ })
1977
+ ]
1978
+ })
1979
+ ]
1980
+ })]
1981
+ });
1982
+ }
1983
+ //#endregion
1984
+ //#region src/control-plane/Schema.tsx
1985
+ function bt() {
1986
+ let { applicationId: t, environment: n, baseUrl: r, token: i, capabilities: a } = B(), [o, s] = v("declared"), c = g(() => new e({
1987
+ baseUrl: r,
1988
+ token: i,
1989
+ applicationId: t,
1990
+ environment: n
1991
+ }), [
1992
+ r,
1993
+ i,
1994
+ t,
1995
+ n
1996
+ ]), { value: l, loading: u, error: d, refresh: f } = V(() => c.schema(), [c], { subject: "the application schema" }), { value: p } = V(() => c.application(), [c], {
1997
+ enabled: !!t,
1998
+ subject: "the application"
1999
+ }), { value: m } = V((e) => e.indexes(), [], {
2000
+ enabled: a.usable("data.indexes.inspect"),
2001
+ subject: "indexes"
2002
+ }), [h, _] = v({}), [y, b] = v(!1), [w, ee] = v(""), T = async () => {
2003
+ if (l) {
2004
+ b(!0), ee("");
2005
+ try {
2006
+ let e = {};
2007
+ for (let t of l.collections) {
2008
+ let n = await c.records(t.collection, void 0, {}, 50), r = {};
2009
+ for (let e of n.records) for (let [t, n] of Object.entries(e)) {
2010
+ if (t === "_relationships") continue;
2011
+ let e = n === null ? "null" : Array.isArray(n) ? "array" : typeof n;
2012
+ (r[t] || (r[t] = /* @__PURE__ */ new Set())).add(e);
2013
+ }
2014
+ e[t.collection] = {
2015
+ sampled: n.records.length,
2016
+ fields: r
2017
+ };
2018
+ }
2019
+ _(e);
2020
+ } catch (e) {
2021
+ ee(e instanceof Error ? e.message : "Unable to sample records.");
2022
+ } finally {
2023
+ b(!1);
2024
+ }
2025
+ }
2026
+ };
2027
+ return /* @__PURE__ */ S($, {
2028
+ eyebrow: "Contract",
2029
+ title: "Schema",
2030
+ description: p ? `${p.application_name || p.application_id} · contract v${p.version}` : void 0,
2031
+ children: /* @__PURE__ */ C(W, {
2032
+ capability: "data.schema.inspect",
2033
+ children: [
2034
+ /* @__PURE__ */ S(K, {
2035
+ message: d,
2036
+ onRetry: f
2037
+ }),
2038
+ u && !l && /* @__PURE__ */ S(G, { what: "the schema" }),
2039
+ p && /* @__PURE__ */ C("section", {
2040
+ className: "cp-stats",
2041
+ children: [
2042
+ /* @__PURE__ */ S(J, {
2043
+ label: "Contract version",
2044
+ value: p.version
2045
+ }),
2046
+ /* @__PURE__ */ S(J, {
2047
+ label: "Contract hash",
2048
+ value: p.contract_hash ? `${p.contract_hash.slice(0, 12)}…` : void 0
2049
+ }),
2050
+ /* @__PURE__ */ S(J, {
2051
+ label: "Flow hash",
2052
+ value: p.flow_hash ? `${p.flow_hash.slice(0, 12)}…` : "not recorded"
2053
+ }),
2054
+ /* @__PURE__ */ S(J, {
2055
+ label: "Collections",
2056
+ value: l?.collections.length
2057
+ })
2058
+ ]
2059
+ }),
2060
+ /* @__PURE__ */ C(Q, {
2061
+ label: "Schema views",
2062
+ active: o,
2063
+ onSelect: s,
2064
+ tabs: [{
2065
+ id: "declared",
2066
+ label: "Declared"
2067
+ }, {
2068
+ id: "observed",
2069
+ label: "Observed"
2070
+ }],
2071
+ children: [
2072
+ o === "declared" && (l?.collections || []).map((e) => {
2073
+ let t = m?.declared.filter((t) => t.collection === e.collection) || [];
2074
+ return /* @__PURE__ */ C("section", {
2075
+ className: "studio-card",
2076
+ children: [
2077
+ /* @__PURE__ */ S("span", {
2078
+ className: "card-kind",
2079
+ children: "collection"
2080
+ }),
2081
+ /* @__PURE__ */ S("h3", { children: e.collection }),
2082
+ /* @__PURE__ */ S("div", {
2083
+ className: "table-shell",
2084
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2085
+ /* @__PURE__ */ S("th", { children: "Field" }),
2086
+ /* @__PURE__ */ S("th", { children: "Type" }),
2087
+ /* @__PURE__ */ S("th", { children: "Required" }),
2088
+ /* @__PURE__ */ S("th", { children: "Reference" }),
2089
+ /* @__PURE__ */ S("th", { children: "Indexed" })
2090
+ ] }) }), /* @__PURE__ */ S("tbody", { children: e.fields.map((t) => {
2091
+ let n = m?.access_paths.find((t) => t.collection === e.collection)?.fields.find((e) => e.field === t.name)?.access_method;
2092
+ return /* @__PURE__ */ C("tr", { children: [
2093
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: t.name }) }),
2094
+ /* @__PURE__ */ S("td", { children: t.type }),
2095
+ /* @__PURE__ */ S("td", { children: t.required ? "required" : "optional" }),
2096
+ /* @__PURE__ */ S("td", { children: t.reference ? /* @__PURE__ */ C("span", {
2097
+ className: "reference-value",
2098
+ children: ["→ ", t.reference]
2099
+ }) : /* @__PURE__ */ S("span", {
2100
+ className: "cp-muted",
2101
+ children: "—"
2102
+ }) }),
2103
+ /* @__PURE__ */ S("td", { children: n ? /* @__PURE__ */ S(H, { status: n === "index" ? "available" : "partial" }) : /* @__PURE__ */ S("span", {
2104
+ className: "cp-muted",
2105
+ children: "—"
2106
+ }) })
2107
+ ] }, t.name);
2108
+ }) })] })
2109
+ }),
2110
+ t.length > 0 && /* @__PURE__ */ C("p", {
2111
+ className: "cp-muted",
2112
+ children: ["Indexes: ", t.map((e) => `${e.name} (${e.fields.map((e) => e.field).join(", ")}${e.unique ? ", unique" : ""}) · ${e.state}`).join(" · ")]
2113
+ }),
2114
+ e.relationships.length > 0 && /* @__PURE__ */ C("p", {
2115
+ className: "cp-muted",
2116
+ children: ["Relationships: ", e.relationships.map((e) => `${e.name} → ${e.target_collection} (${e.cardinality})`).join(" · ")]
2117
+ })
2118
+ ]
2119
+ }, e.collection);
2120
+ }),
2121
+ o === "observed" && /* @__PURE__ */ C(x, { children: [
2122
+ /* @__PURE__ */ S("p", {
2123
+ className: "cp-muted",
2124
+ children: "What the data actually holds, from one page of records per collection. This is a sample of the current data, not the contract and not a survey of the whole collection."
2125
+ }),
2126
+ /* @__PURE__ */ S("div", {
2127
+ className: "cp-actions",
2128
+ children: /* @__PURE__ */ S("button", {
2129
+ className: "btn btn-ghost",
2130
+ disabled: y,
2131
+ onClick: () => void T(),
2132
+ children: y ? "Sampling…" : "Sample records"
2133
+ })
2134
+ }),
2135
+ /* @__PURE__ */ S(K, { message: w }),
2136
+ Object.keys(h).length === 0 ? /* @__PURE__ */ S(q, { children: "No sample taken yet." }) : Object.entries(h).map(([e, t]) => {
2137
+ let n = new Set((l?.collections.find((t) => t.collection === e)?.fields || []).map((e) => e.name));
2138
+ return /* @__PURE__ */ C("section", {
2139
+ className: "studio-card",
2140
+ children: [
2141
+ /* @__PURE__ */ S("span", {
2142
+ className: "card-kind",
2143
+ children: "observed"
2144
+ }),
2145
+ /* @__PURE__ */ C("h3", { children: [
2146
+ e,
2147
+ " ",
2148
+ /* @__PURE__ */ C("small", { children: [t.sampled, " records sampled"] })
2149
+ ] }),
2150
+ Object.keys(t.fields).length === 0 ? /* @__PURE__ */ S(q, { children: "No records to observe." }) : /* @__PURE__ */ S("div", {
2151
+ className: "table-shell",
2152
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2153
+ /* @__PURE__ */ S("th", { children: "Field" }),
2154
+ /* @__PURE__ */ S("th", { children: "Observed types" }),
2155
+ /* @__PURE__ */ S("th", { children: "Declared" })
2156
+ ] }) }), /* @__PURE__ */ S("tbody", { children: Object.entries(t.fields).map(([e, t]) => /* @__PURE__ */ C("tr", { children: [
2157
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: e }) }),
2158
+ /* @__PURE__ */ S("td", { children: [...t].join(", ") }),
2159
+ /* @__PURE__ */ S("td", { children: e === "id" || n.has(e) ? "declared" : /* @__PURE__ */ S(H, { status: "partial" }) })
2160
+ ] }, e)) })] })
2161
+ })
2162
+ ]
2163
+ }, e);
2164
+ })
2165
+ ] }),
2166
+ o === "declared" && l && /* @__PURE__ */ C("details", {
2167
+ className: "cp-raw",
2168
+ children: [/* @__PURE__ */ S("summary", { children: "Raw contract schema" }), /* @__PURE__ */ S(Y, { value: l })]
2169
+ })
2170
+ ]
2171
+ })
2172
+ ]
2173
+ })
2174
+ });
2175
+ }
2176
+ //#endregion
2177
+ //#region src/control-plane/Agents.tsx
2178
+ function xt({ agent: e, onOpenRecord: t }) {
2179
+ let n = e.did.transactions;
2180
+ return n.length ? /* @__PURE__ */ S("div", {
2181
+ className: "table-shell",
2182
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2183
+ /* @__PURE__ */ S("th", { children: "When" }),
2184
+ /* @__PURE__ */ S("th", { children: "Transaction" }),
2185
+ /* @__PURE__ */ S("th", { children: "Records" }),
2186
+ /* @__PURE__ */ S("th", { children: "Revision" }),
2187
+ /* @__PURE__ */ S("th", { children: "Touched" })
2188
+ ] }) }), /* @__PURE__ */ S("tbody", { children: n.map((e) => /* @__PURE__ */ C("tr", { children: [
2189
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(X, { ms: e.unix_ms }) }),
2190
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, {
2191
+ value: e.transaction_id,
2192
+ length: 16
2193
+ }) }),
2194
+ /* @__PURE__ */ S("td", { children: e.operations.toLocaleString() }),
2195
+ /* @__PURE__ */ C("td", { children: [
2196
+ e.base_revision,
2197
+ " → ",
2198
+ e.commit_revision
2199
+ ] }),
2200
+ /* @__PURE__ */ C("td", {
2201
+ className: "cp-keys",
2202
+ children: [e.keys.map((e) => {
2203
+ let n = e.split(":"), r = n.pop(), i = n.pop() || "";
2204
+ return /* @__PURE__ */ C("button", {
2205
+ className: "reference-value",
2206
+ onClick: () => t(i, r),
2207
+ children: [
2208
+ i,
2209
+ "/",
2210
+ r
2211
+ ]
2212
+ }, e);
2213
+ }), e.keys.length < e.operations && /* @__PURE__ */ C("span", {
2214
+ className: "cp-muted",
2215
+ children: [
2216
+ " +",
2217
+ e.operations - e.keys.length,
2218
+ " more"
2219
+ ]
2220
+ })]
2221
+ })
2222
+ ] }, e.transaction_id)) })] })
2223
+ }) : /* @__PURE__ */ S(q, { children: "This agent has made no commit inside the instance's attribution window. That is not proof it has never written — it means nothing it wrote is still in the window." });
2224
+ }
2225
+ function St({ agent: e }) {
2226
+ return /* @__PURE__ */ C(x, { children: [
2227
+ /* @__PURE__ */ S("p", {
2228
+ className: "cp-muted",
2229
+ children: "Computed from the capabilities this principal holds and the actions the application contract declares — not from what the agent has done or what it is called."
2230
+ }),
2231
+ /* @__PURE__ */ S("p", {
2232
+ className: "cp-capabilities",
2233
+ children: e.access.capabilities.length ? e.access.capabilities.map((e) => /* @__PURE__ */ S("code", { children: e }, e)) : /* @__PURE__ */ S("span", {
2234
+ className: "cp-muted",
2235
+ children: "No capabilities granted. This agent can do nothing."
2236
+ })
2237
+ }),
2238
+ /* @__PURE__ */ S("div", {
2239
+ className: "table-shell",
2240
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2241
+ /* @__PURE__ */ S("th", { children: "Collection" }),
2242
+ /* @__PURE__ */ S("th", { children: "Read policy" }),
2243
+ /* @__PURE__ */ S("th", { children: "Write actions" })
2244
+ ] }) }), /* @__PURE__ */ S("tbody", { children: e.access.collections.map((e) => /* @__PURE__ */ C("tr", { children: [
2245
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("strong", { children: e.collection }) }),
2246
+ /* @__PURE__ */ S("td", { children: e.read.policy || /* @__PURE__ */ S("span", {
2247
+ className: "cp-muted",
2248
+ children: "no declared policy"
2249
+ }) }),
2250
+ /* @__PURE__ */ S("td", { children: e.write.actions.length === 0 ? /* @__PURE__ */ S("span", {
2251
+ className: "cp-muted",
2252
+ children: "The contract declares no write action for this collection, so nothing can write it."
2253
+ }) : e.write.actions.map((e) => /* @__PURE__ */ C("span", {
2254
+ className: e.permitted ? "cp-grant granted" : "cp-grant denied",
2255
+ children: [
2256
+ e.operation,
2257
+ " · ",
2258
+ e.name,
2259
+ e.required_capabilities.length > 0 && /* @__PURE__ */ C("small", { children: [" needs ", e.required_capabilities.join(", ")] })
2260
+ ]
2261
+ }, e.name)) })
2262
+ ] }, e.collection)) })] })
2263
+ })
2264
+ ] });
2265
+ }
2266
+ function Ct({ agent: e }) {
2267
+ let { capabilities: t } = B();
2268
+ return /* @__PURE__ */ C(x, { children: [
2269
+ /* @__PURE__ */ S("h3", { children: "Sessions" }),
2270
+ e.doing.sessions.length === 0 ? /* @__PURE__ */ S(q, { children: "No session has been opened for this agent." }) : /* @__PURE__ */ S("div", {
2271
+ className: "table-shell",
2272
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2273
+ /* @__PURE__ */ S("th", { children: "Session" }),
2274
+ /* @__PURE__ */ S("th", { children: "Status" }),
2275
+ /* @__PURE__ */ S("th", { children: "Worker" }),
2276
+ /* @__PURE__ */ S("th", { children: "Started" }),
2277
+ /* @__PURE__ */ S("th", { children: "Capabilities" })
2278
+ ] }) }), /* @__PURE__ */ S("tbody", { children: e.doing.sessions.map((e) => /* @__PURE__ */ C("tr", { children: [
2279
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, {
2280
+ value: e.session_id,
2281
+ length: 18
2282
+ }) }),
2283
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(H, { status: String(e.status) }) }),
2284
+ /* @__PURE__ */ S("td", { children: e.worker_id ? /* @__PURE__ */ S(Z, { value: e.worker_id }) : /* @__PURE__ */ S("span", {
2285
+ className: "cp-muted",
2286
+ children: "unassigned"
2287
+ }) }),
2288
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(X, { ms: e.started_at ? e.started_at * 1e3 : null }) }),
2289
+ /* @__PURE__ */ S("td", { children: e.capabilities.length })
2290
+ ] }, e.session_id)) })] })
2291
+ }),
2292
+ /* @__PURE__ */ S("h3", { children: "Durable work" }),
2293
+ t.usable("agents.work") ? /* @__PURE__ */ S(ct, { capability: "agents.task_context" }) : /* @__PURE__ */ S(U, { capability: "agents.work" }),
2294
+ e.doing.work.length === 0 ? /* @__PURE__ */ S(q, { children: "No durable workload names this agent." }) : /* @__PURE__ */ S("div", {
2295
+ className: "table-shell",
2296
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2297
+ /* @__PURE__ */ S("th", { children: "Workload" }),
2298
+ /* @__PURE__ */ S("th", { children: "Definition" }),
2299
+ /* @__PURE__ */ S("th", { children: "State" }),
2300
+ /* @__PURE__ */ S("th", { children: "Attempts" }),
2301
+ /* @__PURE__ */ S("th", { children: "Last failure" })
2302
+ ] }) }), /* @__PURE__ */ S("tbody", { children: e.doing.work.map((e) => /* @__PURE__ */ C("tr", { children: [
2303
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, {
2304
+ value: String(e.workload_id),
2305
+ length: 18
2306
+ }) }),
2307
+ /* @__PURE__ */ S("td", { children: String(e.definition_id) }),
2308
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(H, { status: String(e.state) }) }),
2309
+ /* @__PURE__ */ S("td", { children: String(e.attempts) }),
2310
+ /* @__PURE__ */ S("td", { children: e.last_failure ? String(e.last_failure) : /* @__PURE__ */ S("span", {
2311
+ className: "cp-muted",
2312
+ children: "—"
2313
+ }) })
2314
+ ] }, String(e.workload_id))) })] })
2315
+ }),
2316
+ /* @__PURE__ */ S("h3", { children: "Working with this agent" }),
2317
+ /* @__PURE__ */ S(U, {
2318
+ capability: "agents.work.review_gate",
2319
+ title: "Reviewing an agent's changes before they apply"
2320
+ })
2321
+ ] });
2322
+ }
2323
+ function wt({ agentId: e, onBack: t, onOpenRecord: n }) {
2324
+ let [r, i] = v("access"), { capabilities: a } = B(), { value: o, loading: s, error: c, refresh: l } = V((t) => t.agent(e), [e], {
2325
+ refreshMs: 15e3,
2326
+ subject: "this agent"
2327
+ });
2328
+ return s && !o ? /* @__PURE__ */ S(G, { what: "the agent" }) : o ? /* @__PURE__ */ S(W, {
2329
+ capability: "agents.identity",
2330
+ children: /* @__PURE__ */ C("section", {
2331
+ className: "cp-detail studio-card",
2332
+ children: [
2333
+ /* @__PURE__ */ C("header", {
2334
+ className: "cp-detail-header",
2335
+ children: [/* @__PURE__ */ C("div", { children: [
2336
+ /* @__PURE__ */ S("span", {
2337
+ className: "card-kind",
2338
+ children: "agent"
2339
+ }),
2340
+ /* @__PURE__ */ S("h2", { children: o.identity.name }),
2341
+ /* @__PURE__ */ C("p", {
2342
+ className: "cp-muted",
2343
+ children: [
2344
+ /* @__PURE__ */ S(Z, {
2345
+ value: o.identity.agent_id,
2346
+ length: 24
2347
+ }),
2348
+ " · ",
2349
+ /* @__PURE__ */ S(H, { status: String(o.identity.status) }),
2350
+ " ·",
2351
+ " ",
2352
+ "registered by ",
2353
+ o.identity.created_by,
2354
+ " ",
2355
+ /* @__PURE__ */ S(X, { ms: o.identity.created_at * 1e3 })
2356
+ ]
2357
+ }),
2358
+ /* @__PURE__ */ C("p", {
2359
+ className: "cp-muted",
2360
+ children: [
2361
+ "Application ",
2362
+ /* @__PURE__ */ S("code", { children: o.identity.application_id }),
2363
+ " · environment ",
2364
+ /* @__PURE__ */ S("code", { children: o.identity.environment }),
2365
+ " ·",
2366
+ " ",
2367
+ "contract ",
2368
+ /* @__PURE__ */ S(Z, { value: o.identity.application_revision })
2369
+ ]
2370
+ })
2371
+ ] }), /* @__PURE__ */ S("button", {
2372
+ className: "btn btn-ghost",
2373
+ onClick: t,
2374
+ children: "← All agents"
2375
+ })]
2376
+ }),
2377
+ /* @__PURE__ */ C("div", {
2378
+ className: "cp-stats",
2379
+ children: [
2380
+ /* @__PURE__ */ S(J, {
2381
+ label: "Recent commits",
2382
+ value: o.did.transactions.length
2383
+ }),
2384
+ /* @__PURE__ */ S(J, {
2385
+ label: "Records changed",
2386
+ value: o.did.records_changed
2387
+ }),
2388
+ /* @__PURE__ */ S(J, {
2389
+ label: "Sessions",
2390
+ value: o.doing.sessions.length
2391
+ }),
2392
+ /* @__PURE__ */ S(J, {
2393
+ label: "Last activity",
2394
+ value: o.did.last_activity_ms ? new Date(o.did.last_activity_ms).toLocaleString() : void 0
2395
+ })
2396
+ ]
2397
+ }),
2398
+ /* @__PURE__ */ C(Q, {
2399
+ label: "Agent sections",
2400
+ active: r,
2401
+ onSelect: i,
2402
+ tabs: [
2403
+ {
2404
+ id: "access",
2405
+ label: "What it can access"
2406
+ },
2407
+ {
2408
+ id: "did",
2409
+ label: "What it has done"
2410
+ },
2411
+ {
2412
+ id: "doing",
2413
+ label: "What it is doing"
2414
+ },
2415
+ {
2416
+ id: "decisions",
2417
+ label: "Authorization"
2418
+ }
2419
+ ],
2420
+ children: [
2421
+ r === "access" && /* @__PURE__ */ S(St, { agent: o }),
2422
+ r === "did" && /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(ct, { capability: "provenance.transactions" }), /* @__PURE__ */ S(xt, {
2423
+ agent: o,
2424
+ onOpenRecord: n
2425
+ })] }),
2426
+ r === "doing" && /* @__PURE__ */ S(W, {
2427
+ capability: "agents.sessions",
2428
+ children: /* @__PURE__ */ S(Ct, { agent: o })
2429
+ }),
2430
+ r === "decisions" && (a.usable("agents.authorization_decisions") ? o.authorization_decisions.length === 0 ? /* @__PURE__ */ S(q, { children: "No authorization decision has been recorded for this agent." }) : /* @__PURE__ */ S("div", {
2431
+ className: "table-shell",
2432
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2433
+ /* @__PURE__ */ S("th", { children: "When" }),
2434
+ /* @__PURE__ */ S("th", { children: "Event" }),
2435
+ /* @__PURE__ */ S("th", { children: "Actor" }),
2436
+ /* @__PURE__ */ S("th", { children: "Capability" }),
2437
+ /* @__PURE__ */ S("th", { children: "Decision" })
2438
+ ] }) }), /* @__PURE__ */ S("tbody", { children: o.authorization_decisions.map((e, t) => /* @__PURE__ */ C("tr", { children: [
2439
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(X, { ms: e.at * 1e3 }) }),
2440
+ /* @__PURE__ */ S("td", { children: e.event }),
2441
+ /* @__PURE__ */ S("td", { children: e.actor }),
2442
+ /* @__PURE__ */ S("td", { children: e.capability ? /* @__PURE__ */ S("code", { children: e.capability }) : /* @__PURE__ */ S("span", {
2443
+ className: "cp-muted",
2444
+ children: "—"
2445
+ }) }),
2446
+ /* @__PURE__ */ S("td", { children: e.decision === null ? /* @__PURE__ */ S("span", {
2447
+ className: "cp-muted",
2448
+ children: "—"
2449
+ }) : /* @__PURE__ */ S(H, { status: e.decision ? "available" : "unsupported" }) })
2450
+ ] }, `${e.event}-${e.at}-${t}`)) })] })
2451
+ }) : /* @__PURE__ */ S(U, { capability: "agents.authorization_decisions" }))
2452
+ ]
2453
+ })
2454
+ ]
2455
+ })
2456
+ }) : /* @__PURE__ */ S(K, {
2457
+ message: c,
2458
+ onRetry: l
2459
+ });
2460
+ }
2461
+ function Tt({ onConnected: e }) {
2462
+ let { api: t, capabilities: n } = B(), [r, i] = v(""), [a, s] = v([]), [c, l] = v(!1), [u, d] = v(""), [f, p] = v(null), m = [
2463
+ "state:read",
2464
+ "state:write",
2465
+ "events:read",
2466
+ "workloads:execute",
2467
+ "applications:read"
2468
+ ];
2469
+ if (!n.usable("agents.register")) return /* @__PURE__ */ S(U, { capability: "agents.register" });
2470
+ let h = async () => {
2471
+ l(!0), d("");
2472
+ try {
2473
+ let n = await t.registerAgent(r.trim());
2474
+ for (let e of a) await t.grantAgentCapability(n.id, e);
2475
+ p({
2476
+ id: n.id,
2477
+ name: n.name
2478
+ }), i(""), s([]), e();
2479
+ } catch (e) {
2480
+ d(o(e, "agent registration"));
2481
+ } finally {
2482
+ l(!1);
2483
+ }
2484
+ };
2485
+ return /* @__PURE__ */ C("section", {
2486
+ className: "studio-card cp-connect",
2487
+ children: [
2488
+ /* @__PURE__ */ S("span", {
2489
+ className: "card-kind",
2490
+ children: "Connect an agent"
2491
+ }),
2492
+ /* @__PURE__ */ S("p", {
2493
+ className: "cp-muted",
2494
+ children: "Registers an agent principal against this application and grants it capabilities. The agent then operates through the application's declared actions — the same interface an application uses — and everything it writes is attributable here."
2495
+ }),
2496
+ /* @__PURE__ */ C("label", { children: ["Agent name", /* @__PURE__ */ S("input", {
2497
+ value: r,
2498
+ onChange: (e) => i(e.target.value),
2499
+ placeholder: "Customer Operations Agent"
2500
+ })] }),
2501
+ /* @__PURE__ */ C("fieldset", { children: [/* @__PURE__ */ S("legend", { children: "Capabilities" }), m.map((e) => /* @__PURE__ */ C("label", {
2502
+ className: "cp-check",
2503
+ children: [/* @__PURE__ */ S("input", {
2504
+ type: "checkbox",
2505
+ checked: a.includes(e),
2506
+ onChange: (t) => s((n) => t.target.checked ? [...n, e] : n.filter((t) => t !== e))
2507
+ }), /* @__PURE__ */ S("code", { children: e })]
2508
+ }, e))] }),
2509
+ /* @__PURE__ */ S(K, { message: u }),
2510
+ /* @__PURE__ */ S("div", {
2511
+ className: "cp-actions",
2512
+ children: /* @__PURE__ */ S("button", {
2513
+ className: "btn btn-primary",
2514
+ disabled: c || !r.trim(),
2515
+ onClick: () => void h(),
2516
+ children: c ? "Connecting…" : "Connect agent"
2517
+ })
2518
+ }),
2519
+ f && /* @__PURE__ */ C("div", {
2520
+ className: "cp-connected",
2521
+ children: [/* @__PURE__ */ C("p", { children: [
2522
+ /* @__PURE__ */ S("strong", { children: f.name }),
2523
+ " is registered as ",
2524
+ /* @__PURE__ */ S("code", { children: f.id }),
2525
+ "."
2526
+ ] }), /* @__PURE__ */ S("p", {
2527
+ className: "cp-muted",
2528
+ children: "Give the agent this identity and an API key with the capabilities above. Connection details for the endpoint itself are under Developer."
2529
+ })]
2530
+ })
2531
+ ]
2532
+ });
2533
+ }
2534
+ function Et({ onOpenRecord: e }) {
2535
+ let { capabilities: t } = B(), [n, r] = v(""), i = t.usable("agents.list"), { value: a, loading: o, error: s, refresh: c } = V((e) => e.agents(), [], {
2536
+ enabled: i,
2537
+ refreshMs: 2e4,
2538
+ subject: "agents"
2539
+ });
2540
+ return /* @__PURE__ */ C($, {
2541
+ eyebrow: "Agents",
2542
+ title: "Agents",
2543
+ description: "What each agent may do, what it has done, and what it is doing — read from the same durable state every other writer produces.",
2544
+ children: [/* @__PURE__ */ C(W, {
2545
+ capability: "agents.list",
2546
+ children: [/* @__PURE__ */ S(K, {
2547
+ message: s,
2548
+ onRetry: c
2549
+ }), n ? /* @__PURE__ */ S(wt, {
2550
+ agentId: n,
2551
+ onBack: () => r(""),
2552
+ onOpenRecord: e
2553
+ }) : /* @__PURE__ */ C(x, { children: [
2554
+ o && !a && /* @__PURE__ */ S(G, { what: "agents" }),
2555
+ a && (a.agents.length === 0 ? /* @__PURE__ */ S(q, { children: "No agent is registered against this application yet." }) : /* @__PURE__ */ S("div", {
2556
+ className: "cp-cards",
2557
+ children: a.agents.map((e) => /* @__PURE__ */ C("button", {
2558
+ className: "studio-card cp-agent-card",
2559
+ onClick: () => r(e.agent_id),
2560
+ children: [
2561
+ /* @__PURE__ */ S("span", {
2562
+ className: "card-kind",
2563
+ children: "agent"
2564
+ }),
2565
+ /* @__PURE__ */ S("h3", { children: e.name }),
2566
+ /* @__PURE__ */ C("p", {
2567
+ className: "cp-muted",
2568
+ children: [
2569
+ /* @__PURE__ */ S(Z, {
2570
+ value: e.agent_id,
2571
+ length: 20
2572
+ }),
2573
+ " · ",
2574
+ /* @__PURE__ */ S(H, { status: String(e.status) })
2575
+ ]
2576
+ }),
2577
+ /* @__PURE__ */ C("div", {
2578
+ className: "cp-stats",
2579
+ children: [
2580
+ /* @__PURE__ */ S(J, {
2581
+ label: "Sessions running",
2582
+ value: e.sessions.running
2583
+ }),
2584
+ /* @__PURE__ */ S(J, {
2585
+ label: "Recent commits",
2586
+ value: e.activity.recent_transactions
2587
+ }),
2588
+ /* @__PURE__ */ S(J, {
2589
+ label: "Records changed",
2590
+ value: e.activity.records_changed
2591
+ })
2592
+ ]
2593
+ }),
2594
+ /* @__PURE__ */ S("p", {
2595
+ className: "cp-capabilities",
2596
+ children: e.capabilities.length ? e.capabilities.map((e) => /* @__PURE__ */ S("code", { children: e }, e)) : /* @__PURE__ */ S("span", {
2597
+ className: "cp-muted",
2598
+ children: "no capabilities granted"
2599
+ })
2600
+ }),
2601
+ /* @__PURE__ */ C("p", {
2602
+ className: "cp-muted",
2603
+ children: ["Last activity ", /* @__PURE__ */ S(X, { ms: e.activity.last_activity_ms })]
2604
+ })
2605
+ ]
2606
+ }, e.agent_id))
2607
+ })),
2608
+ /* @__PURE__ */ S(Tt, { onConnected: c })
2609
+ ] })]
2610
+ }), !i && /* @__PURE__ */ C("p", {
2611
+ className: "cp-muted",
2612
+ children: [
2613
+ "Agents declared by this project are listed under",
2614
+ " ",
2615
+ /* @__PURE__ */ S(y, {
2616
+ to: {
2617
+ pathname: "/agent-definitions",
2618
+ search: window.location.search
2619
+ },
2620
+ children: "Agent definitions"
2621
+ }),
2622
+ ", and their runs under ",
2623
+ /* @__PURE__ */ S(y, {
2624
+ to: {
2625
+ pathname: "/executions",
2626
+ search: window.location.search
2627
+ },
2628
+ children: "Executions"
2629
+ }),
2630
+ "."
2631
+ ]
2632
+ })]
2633
+ });
2634
+ }
2635
+ //#endregion
2636
+ //#region src/control-plane/State.tsx
2637
+ function Dt() {
2638
+ let { value: e, loading: t, refresh: n } = V((e) => e.overview().then((e) => e.authority_state), [], {
2639
+ refreshMs: 1e4,
2640
+ subject: "the authority state summary"
2641
+ });
2642
+ return t && !e ? /* @__PURE__ */ S("section", {
2643
+ className: "studio-card",
2644
+ children: /* @__PURE__ */ S(G, { what: "state" })
2645
+ }) : e ? /* @__PURE__ */ C("section", {
2646
+ className: "studio-card",
2647
+ "aria-label": "Authority state summary",
2648
+ children: [
2649
+ /* @__PURE__ */ S("span", {
2650
+ className: "card-kind",
2651
+ children: "Authority state"
2652
+ }),
2653
+ /* @__PURE__ */ C("div", {
2654
+ className: "cp-stats",
2655
+ children: [
2656
+ /* @__PURE__ */ S(J, {
2657
+ label: "Current sequence",
2658
+ value: e.current_sequence
2659
+ }),
2660
+ /* @__PURE__ */ S(J, {
2661
+ label: "Records",
2662
+ value: e.records
2663
+ }),
2664
+ /* @__PURE__ */ S(J, {
2665
+ label: "Events",
2666
+ value: e.events
2667
+ }),
2668
+ /* @__PURE__ */ S(J, {
2669
+ label: "Collections with state",
2670
+ value: e.collections.length
2671
+ })
2672
+ ]
2673
+ }),
2674
+ e.collections.length > 0 && /* @__PURE__ */ S("div", {
2675
+ className: "table-shell",
2676
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [/* @__PURE__ */ S("th", { children: "Collection with state" }), /* @__PURE__ */ S("th", { children: "Records" })] }) }), /* @__PURE__ */ S("tbody", { children: e.collections.map((e) => /* @__PURE__ */ C("tr", { children: [/* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: e.collection }) }), /* @__PURE__ */ S("td", { children: e.records.toLocaleString() })] }, e.collection)) })] })
2677
+ })
2678
+ ]
2679
+ }) : /* @__PURE__ */ C("section", {
2680
+ className: "studio-card",
2681
+ role: "alert",
2682
+ children: [
2683
+ /* @__PURE__ */ S("span", {
2684
+ className: "card-kind",
2685
+ children: "Authority state"
2686
+ }),
2687
+ /* @__PURE__ */ S("h2", { children: "State unavailable" }),
2688
+ /* @__PURE__ */ S("p", { children: "Studio could not read the current FeltDB authority state. Check that the development authority is running." }),
2689
+ /* @__PURE__ */ S("button", {
2690
+ className: "btn btn-ghost",
2691
+ onClick: n,
2692
+ children: "Retry"
2693
+ })
2694
+ ]
2695
+ });
2696
+ }
2697
+ function Ot({ revisions: e, selected: t, onToggle: n }) {
2698
+ return /* @__PURE__ */ S("div", {
2699
+ className: "table-shell",
2700
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2701
+ /* @__PURE__ */ S("th", {}),
2702
+ /* @__PURE__ */ S("th", { children: "#" }),
2703
+ /* @__PURE__ */ S("th", { children: "State ID" }),
2704
+ /* @__PURE__ */ S("th", { children: "Parent" }),
2705
+ /* @__PURE__ */ S("th", { children: "Authority" }),
2706
+ /* @__PURE__ */ S("th", { children: "Committed" })
2707
+ ] }) }), /* @__PURE__ */ S("tbody", { children: e.map((e) => /* @__PURE__ */ C("tr", {
2708
+ className: t.includes(e.state_id) ? "selected" : "",
2709
+ children: [
2710
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("input", {
2711
+ type: "checkbox",
2712
+ "aria-label": `Select revision ${e.state_id}`,
2713
+ checked: t.includes(e.state_id),
2714
+ onChange: () => n(e.state_id)
2715
+ }) }),
2716
+ /* @__PURE__ */ S("td", { children: e.sequence }),
2717
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, {
2718
+ value: e.state_id,
2719
+ length: 16
2720
+ }) }),
2721
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, {
2722
+ value: e.parent_id,
2723
+ length: 16
2724
+ }) }),
2725
+ /* @__PURE__ */ S("td", { children: e.authority }),
2726
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(X, { ms: e.timestamp_ms }) })
2727
+ ]
2728
+ }, e.state_id)) })] })
2729
+ });
2730
+ }
2731
+ function kt({ diff: e }) {
2732
+ return /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ C("p", {
2733
+ className: "cp-muted",
2734
+ children: [
2735
+ e.from.sequence,
2736
+ " → ",
2737
+ e.to.sequence,
2738
+ " · ",
2739
+ e.relationship === "parent" ? "one step in this resource’s history" : e.relationship === "same-resource" ? "two points in one resource’s history" : "two different resources"
2740
+ ]
2741
+ }), e.changes.length === 0 ? /* @__PURE__ */ S(q, { children: "These two revisions hold the same content." }) : /* @__PURE__ */ S("div", {
2742
+ className: "table-shell",
2743
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2744
+ /* @__PURE__ */ S("th", { children: "Path" }),
2745
+ /* @__PURE__ */ S("th", { children: "Change" }),
2746
+ /* @__PURE__ */ S("th", { children: "From" }),
2747
+ /* @__PURE__ */ S("th", { children: "To" })
2748
+ ] }) }), /* @__PURE__ */ S("tbody", { children: e.changes.map((e) => /* @__PURE__ */ C("tr", { children: [
2749
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(lt, { path: e.path }) }),
2750
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(H, { status: e.kind }) }),
2751
+ /* @__PURE__ */ S("td", {
2752
+ className: "cp-value-old",
2753
+ children: e.old_value === void 0 || e.old_value === null ? /* @__PURE__ */ S("span", {
2754
+ className: "cp-muted",
2755
+ children: "—"
2756
+ }) : /* @__PURE__ */ S("code", { children: JSON.stringify(e.old_value) })
2757
+ }),
2758
+ /* @__PURE__ */ S("td", {
2759
+ className: "cp-value-new",
2760
+ children: e.new_value === void 0 || e.new_value === null ? /* @__PURE__ */ S("span", {
2761
+ className: "cp-muted",
2762
+ children: "—"
2763
+ }) : /* @__PURE__ */ S("code", { children: JSON.stringify(e.new_value) })
2764
+ })
2765
+ ] }, s(e.path))) })] })
2766
+ })] });
2767
+ }
2768
+ function At({ classification: e }) {
2769
+ return /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ C("p", {
2770
+ className: "cp-attribution",
2771
+ children: [
2772
+ "Overall: ",
2773
+ /* @__PURE__ */ S(H, { status: e.overall }),
2774
+ e.overall === "independent" && " — both branches’ changes can be applied without either overwriting the other.",
2775
+ e.overall === "convergent" && " — the branches reached the same result.",
2776
+ e.overall === "conflict" && " — at least one path cannot take both branches. Reconciliation needs an explicit decision there."
2777
+ ]
2778
+ }), /* @__PURE__ */ S("div", {
2779
+ className: "table-shell",
2780
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
2781
+ /* @__PURE__ */ S("th", { children: "Path" }),
2782
+ /* @__PURE__ */ S("th", { children: "Class" }),
2783
+ /* @__PURE__ */ S("th", { children: "Base" }),
2784
+ /* @__PURE__ */ S("th", { children: "Left" }),
2785
+ /* @__PURE__ */ S("th", { children: "Right" })
2786
+ ] }) }), /* @__PURE__ */ S("tbody", { children: e.path_conflicts.map((e) => /* @__PURE__ */ C("tr", {
2787
+ className: e.classification === "conflict" ? "cp-row-conflict" : "",
2788
+ children: [
2789
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(lt, { path: e.path }) }),
2790
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(H, { status: e.classification }) }),
2791
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: JSON.stringify(e.base_value ?? null) }) }),
2792
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: JSON.stringify(e.left_value ?? null) }) }),
2793
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: JSON.stringify(e.right_value ?? null) }) })
2794
+ ]
2795
+ }, s(e.path))) })] })
2796
+ })] });
2797
+ }
2798
+ var jt = "Content matches revision id";
2799
+ function Mt({ revision: e }) {
2800
+ let t = ue("feltdb.revision.integrity_verified", e.integrity_verified, [jt]);
2801
+ return /* @__PURE__ */ C("div", {
2802
+ className: "studio-card cp-committed",
2803
+ "data-committed-revision": String(e.state_id),
2804
+ children: [
2805
+ /* @__PURE__ */ S("span", {
2806
+ className: "card-kind",
2807
+ children: "Committed"
2808
+ }),
2809
+ /* @__PURE__ */ C("p", { children: [
2810
+ "Revision ",
2811
+ /* @__PURE__ */ S(Z, {
2812
+ value: String(e.state_id),
2813
+ length: 20
2814
+ }),
2815
+ " at sequence ",
2816
+ String(e.sequence),
2817
+ ", authored by ",
2818
+ /* @__PURE__ */ S("strong", { children: String(e.authority) }),
2819
+ ", parent ",
2820
+ /* @__PURE__ */ S(Z, { value: String(e.parent_id) }),
2821
+ "."
2822
+ ] }),
2823
+ /* @__PURE__ */ S(Je, {
2824
+ state: t.state,
2825
+ checks: t.checks,
2826
+ attrs: { "data-integrity": t.state }
2827
+ })
2828
+ ]
2829
+ });
2830
+ }
2831
+ function Nt({ base: e, left: t, right: n, onCommitted: r }) {
2832
+ let { api: i } = B(), [a, c] = v("left"), [l, u] = v([]), [d, f] = v(null), [p, m] = v(null), [h, g] = v(""), [_, y] = v(!1), b = () => ({
2833
+ base: e,
2834
+ left: t,
2835
+ right: n,
2836
+ parent_choice: a,
2837
+ overrides: l.filter((e) => e.value.trim() !== "").map((e) => {
2838
+ try {
2839
+ return {
2840
+ path: e.path,
2841
+ value: JSON.parse(e.value)
2842
+ };
2843
+ } catch {
2844
+ return {
2845
+ path: e.path,
2846
+ value: e.value
2847
+ };
2848
+ }
2849
+ })
2850
+ }), x = async () => {
2851
+ y(!0), g(""), m(null);
2852
+ try {
2853
+ let e = await i.reconciliationPlan(b());
2854
+ f(e), u((t) => {
2855
+ let n = new Set(t.map((e) => s(e.path)));
2856
+ return [...t, ...e.unresolved.filter((e) => !n.has(s(e))).map((e) => ({
2857
+ path: e,
2858
+ value: ""
2859
+ }))];
2860
+ });
2861
+ } catch (e) {
2862
+ f(null), g(o(e, "the reconciliation plan"));
2863
+ } finally {
2864
+ y(!1);
2865
+ }
2866
+ }, w = async () => {
2867
+ y(!0), g("");
2868
+ try {
2869
+ let e = await i.reconciliationExecute(b());
2870
+ m(e.revision), r();
2871
+ } catch (e) {
2872
+ g(o(e, "the reconciliation"));
2873
+ } finally {
2874
+ y(!1);
2875
+ }
2876
+ };
2877
+ return /* @__PURE__ */ C("section", {
2878
+ className: "cp-reconcile",
2879
+ children: [
2880
+ /* @__PURE__ */ S("p", {
2881
+ className: "cp-muted",
2882
+ children: "Reconciliation is an explicit decision, never an automatic merge. Choose which branch the result starts from, decide any path the branches genuinely conflict on, and preview the exact state before committing it. The committed result is a new revision of the resource — it adds to history rather than rewriting it."
2883
+ }),
2884
+ /* @__PURE__ */ S("div", {
2885
+ className: "cp-parent-choice",
2886
+ role: "radiogroup",
2887
+ "aria-label": "Parent branch",
2888
+ children: ["left", "right"].map((e) => /* @__PURE__ */ C("label", {
2889
+ className: "cp-check",
2890
+ children: [
2891
+ /* @__PURE__ */ S("input", {
2892
+ type: "radio",
2893
+ name: "parent",
2894
+ checked: a === e,
2895
+ onChange: () => c(e)
2896
+ }),
2897
+ "Start from ",
2898
+ /* @__PURE__ */ S("strong", { children: e }),
2899
+ " ",
2900
+ /* @__PURE__ */ S(Z, { value: e === "left" ? t : n })
2901
+ ]
2902
+ }, e))
2903
+ }),
2904
+ l.length > 0 && /* @__PURE__ */ C("div", {
2905
+ className: "cp-overrides",
2906
+ children: [/* @__PURE__ */ S("h4", { children: "Decided paths" }), l.map((e, t) => /* @__PURE__ */ C("label", { children: [/* @__PURE__ */ S(lt, { path: e.path }), /* @__PURE__ */ S("input", {
2907
+ value: e.value,
2908
+ placeholder: "JSON value",
2909
+ onChange: (e) => u((n) => n.map((n, r) => r === t ? {
2910
+ ...n,
2911
+ value: e.target.value
2912
+ } : n))
2913
+ })] }, s(e.path)))]
2914
+ }),
2915
+ /* @__PURE__ */ S(K, { message: h }),
2916
+ /* @__PURE__ */ C("div", {
2917
+ className: "cp-actions",
2918
+ children: [/* @__PURE__ */ S("button", {
2919
+ className: "btn btn-ghost",
2920
+ disabled: _,
2921
+ onClick: () => void x(),
2922
+ children: _ ? "Working…" : "Preview result"
2923
+ }), /* @__PURE__ */ S("button", {
2924
+ className: "btn btn-primary",
2925
+ disabled: _ || !d,
2926
+ onClick: () => void w(),
2927
+ children: "Commit reconciled revision"
2928
+ })]
2929
+ }),
2930
+ d && /* @__PURE__ */ C("div", {
2931
+ className: "studio-card",
2932
+ children: [
2933
+ /* @__PURE__ */ S("span", {
2934
+ className: "card-kind",
2935
+ children: "Preview"
2936
+ }),
2937
+ /* @__PURE__ */ C("div", {
2938
+ className: "cp-stats",
2939
+ children: [
2940
+ /* @__PURE__ */ S(J, {
2941
+ label: "Content identity",
2942
+ value: `${d.preview.content_id.slice(0, 12)}…`
2943
+ }),
2944
+ /* @__PURE__ */ S(J, {
2945
+ label: "Parent",
2946
+ value: `#${d.preview.parent.sequence}`
2947
+ }),
2948
+ /* @__PURE__ */ S(J, {
2949
+ label: "Undecided conflicts",
2950
+ value: d.unresolved.length
2951
+ })
2952
+ ]
2953
+ }),
2954
+ d.unresolved.length > 0 && /* @__PURE__ */ C("p", {
2955
+ className: "cp-notice",
2956
+ children: [
2957
+ d.unresolved.length,
2958
+ " path",
2959
+ d.unresolved.length === 1 ? "" : "s",
2960
+ " conflict and have no decision:",
2961
+ " ",
2962
+ d.unresolved.map((e) => s(e)).join(", "),
2963
+ ". Committing now takes the chosen branch\\u2019s value there."
2964
+ ]
2965
+ }),
2966
+ /* @__PURE__ */ S(Y, { value: d.preview.content })
2967
+ ]
2968
+ }),
2969
+ p && /* @__PURE__ */ S(Mt, { revision: p })
2970
+ ]
2971
+ });
2972
+ }
2973
+ function Pt() {
2974
+ let { api: e, capabilities: t } = B(), [n, r] = v(""), [i, a] = v(""), [s, c] = v([]), [l, u] = v("history"), [d, f] = v(null), [p, m] = v(null), [h, g] = v(""), [_, y] = v(0), { value: b, loading: w, error: ee, refresh: T } = V((e) => e.stateResources({
2975
+ prefix: n,
2976
+ limit: 200
2977
+ }), [n, _], {
2978
+ enabled: t.usable("state.resources.list"),
2979
+ subject: "state resources"
2980
+ }), { value: E, loading: D, refresh: O } = V((e) => e.stateHistory(i), [i, _], {
2981
+ enabled: !!i,
2982
+ subject: "this resource’s history"
2983
+ }), k = (e) => c((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e].slice(-3)), A = async () => {
2984
+ g("");
2985
+ try {
2986
+ f(await e.stateDiff(s[0], s[1])), u("diff");
2987
+ } catch (e) {
2988
+ f(null), g(o(e, "the diff"));
2989
+ }
2990
+ }, j = async () => {
2991
+ g("");
2992
+ try {
2993
+ m(await e.stateConflicts(s[0], s[1], s[2])), u("conflicts");
2994
+ } catch (e) {
2995
+ m(null), g(o(e, "the conflict classification"));
2996
+ }
2997
+ };
2998
+ return /* @__PURE__ */ C($, {
2999
+ eyebrow: "State",
3000
+ title: "State",
3001
+ description: "What changed, who changed it, what state it came from, why two states conflict, and what reconciliation would do.",
3002
+ children: [/* @__PURE__ */ S(Dt, {}), /* @__PURE__ */ S(W, {
3003
+ capability: "state.history",
3004
+ children: /* @__PURE__ */ C("div", {
3005
+ className: "data-layout",
3006
+ children: [/* @__PURE__ */ C("aside", {
3007
+ className: "studio-card",
3008
+ children: [/* @__PURE__ */ S("span", {
3009
+ className: "card-kind",
3010
+ children: "Resources"
3011
+ }), /* @__PURE__ */ C(W, {
3012
+ capability: "state.resources.list",
3013
+ children: [
3014
+ /* @__PURE__ */ S("input", {
3015
+ "aria-label": "Resource prefix",
3016
+ value: n,
3017
+ onChange: (e) => r(e.target.value),
3018
+ placeholder: "Filter by prefix…"
3019
+ }),
3020
+ w && !b && /* @__PURE__ */ S(G, { what: "resources" }),
3021
+ b && (b.resources.length === 0 ? /* @__PURE__ */ C(q, { children: [
3022
+ "No resource in this instance has revision history",
3023
+ n ? ` under “${n}”` : "",
3024
+ "."
3025
+ ] }) : b.resources.map((e) => /* @__PURE__ */ C("button", {
3026
+ className: e.resource === i ? "active" : "",
3027
+ onClick: () => {
3028
+ a(e.resource), c([]), f(null), m(null), u("history");
3029
+ },
3030
+ children: [e.resource, /* @__PURE__ */ C("small", { children: [
3031
+ e.revisions,
3032
+ " revisions",
3033
+ e.head ? ` · head #${e.head.sequence}` : ""
3034
+ ] })]
3035
+ }, e.resource))),
3036
+ /* @__PURE__ */ S(K, {
3037
+ message: ee,
3038
+ onRetry: T
3039
+ })
3040
+ ]
3041
+ })]
3042
+ }), /* @__PURE__ */ S("section", {
3043
+ className: "data-browser",
3044
+ children: i ? /* @__PURE__ */ C(x, { children: [
3045
+ /* @__PURE__ */ C("header", { children: [/* @__PURE__ */ C("div", { children: [
3046
+ /* @__PURE__ */ S("span", {
3047
+ className: "card-kind",
3048
+ children: "resource"
3049
+ }),
3050
+ /* @__PURE__ */ S("h2", { children: i }),
3051
+ E && /* @__PURE__ */ C("p", {
3052
+ className: "cp-muted",
3053
+ children: [
3054
+ E.revisions.length,
3055
+ " retained revisions · retention ",
3056
+ E.retention.keep_last === null ? "keeps everything" : `keeps the last ${E.retention.keep_last}`,
3057
+ " · horizon #",
3058
+ E.retention.horizon
3059
+ ]
3060
+ })
3061
+ ] }), /* @__PURE__ */ C("div", {
3062
+ className: "cp-actions",
3063
+ children: [
3064
+ /* @__PURE__ */ S("button", {
3065
+ className: "btn btn-ghost",
3066
+ disabled: s.length !== 2,
3067
+ onClick: () => void A(),
3068
+ children: "Diff 2 selected"
3069
+ }),
3070
+ /* @__PURE__ */ S("button", {
3071
+ className: "btn btn-ghost",
3072
+ disabled: s.length !== 3,
3073
+ onClick: () => void j(),
3074
+ children: "Classify 3 selected"
3075
+ }),
3076
+ /* @__PURE__ */ S("button", {
3077
+ className: "btn btn-ghost",
3078
+ disabled: s.length !== 3,
3079
+ onClick: () => u("reconcile"),
3080
+ children: "Reconcile"
3081
+ })
3082
+ ]
3083
+ })] }),
3084
+ /* @__PURE__ */ S("p", {
3085
+ className: "cp-muted",
3086
+ children: "Select two revisions to diff them, or three — base, left, right, in selection order — to classify how two branches interact and to reconcile them."
3087
+ }),
3088
+ /* @__PURE__ */ S(K, { message: h }),
3089
+ /* @__PURE__ */ C(Q, {
3090
+ label: "History views",
3091
+ active: l,
3092
+ onSelect: u,
3093
+ tabs: [
3094
+ {
3095
+ id: "history",
3096
+ label: "History"
3097
+ },
3098
+ {
3099
+ id: "diff",
3100
+ label: "Diff"
3101
+ },
3102
+ {
3103
+ id: "conflicts",
3104
+ label: "Conflicts"
3105
+ },
3106
+ {
3107
+ id: "reconcile",
3108
+ label: "Reconciliation"
3109
+ }
3110
+ ],
3111
+ children: [
3112
+ l === "history" && t.status("state.branch.heads") === "unsupported" && /* @__PURE__ */ S(U, { capability: "state.branch.heads" }),
3113
+ l === "history" && (D && !E ? /* @__PURE__ */ S(G, { what: "history" }) : E && /* @__PURE__ */ S(Ot, {
3114
+ revisions: E.revisions,
3115
+ selected: s,
3116
+ onToggle: k
3117
+ })),
3118
+ l === "diff" && /* @__PURE__ */ S(W, {
3119
+ capability: "state.diff.semantic",
3120
+ children: d ? /* @__PURE__ */ S(kt, { diff: d }) : /* @__PURE__ */ S(q, { children: "Select two revisions and press “Diff 2 selected”." })
3121
+ }),
3122
+ l === "conflicts" && /* @__PURE__ */ S(W, {
3123
+ capability: "state.conflict.classify",
3124
+ children: p ? /* @__PURE__ */ S(At, { classification: p }) : /* @__PURE__ */ S(q, { children: "Select three revisions — base, left, right — and press “Classify 3 selected”." })
3125
+ }),
3126
+ l === "reconcile" && /* @__PURE__ */ S(W, {
3127
+ capability: "state.reconciliation.execute",
3128
+ children: s.length === 3 ? /* @__PURE__ */ S(W, {
3129
+ capability: "state.reconciliation.plan",
3130
+ children: /* @__PURE__ */ S(Nt, {
3131
+ base: s[0],
3132
+ left: s[1],
3133
+ right: s[2],
3134
+ onCommitted: () => {
3135
+ y((e) => e + 1), O();
3136
+ }
3137
+ })
3138
+ }) : /* @__PURE__ */ S(q, { children: "Reconciliation needs three revisions: a common ancestor and the two branches to reconcile." })
3139
+ })
3140
+ ]
3141
+ })
3142
+ ] }) : /* @__PURE__ */ S(q, { children: "Select a resource to see its history." })
3143
+ })]
3144
+ })
3145
+ })]
3146
+ });
3147
+ }
3148
+ //#endregion
3149
+ //#region src/control-plane/Operations.tsx
3150
+ function Ft(e, t, n) {
3151
+ return e ? "loading" : t ? "connection-failure" : n === "unsupported" ? "unsupported" : "supported";
3152
+ }
3153
+ function It() {
3154
+ return /* @__PURE__ */ C("section", {
3155
+ className: "cp-unavailable",
3156
+ role: "note",
3157
+ children: [
3158
+ /* @__PURE__ */ S("h3", { children: "Not available" }),
3159
+ /* @__PURE__ */ S("p", { children: "Transaction observability isn't available from this FeltDB runtime." }),
3160
+ /* @__PURE__ */ S("p", { children: "This does not affect the application's ability to run." })
3161
+ ]
3162
+ });
3163
+ }
3164
+ function Lt({ transactionId: e, onClose: t }) {
3165
+ let { value: n, loading: r, error: i, refresh: a } = V((t) => t.transaction(e), [e], { subject: "this transaction" });
3166
+ return /* @__PURE__ */ C("section", {
3167
+ className: "cp-detail studio-card",
3168
+ children: [
3169
+ /* @__PURE__ */ C("header", {
3170
+ className: "cp-detail-header",
3171
+ children: [/* @__PURE__ */ C("div", { children: [/* @__PURE__ */ S("span", {
3172
+ className: "card-kind",
3173
+ children: "transaction"
3174
+ }), /* @__PURE__ */ S("h2", { children: /* @__PURE__ */ S(Z, {
3175
+ value: e,
3176
+ length: 32
3177
+ }) })] }), /* @__PURE__ */ S("button", {
3178
+ className: "data-close",
3179
+ onClick: t,
3180
+ "aria-label": "Close transaction",
3181
+ children: "×"
3182
+ })]
3183
+ }),
3184
+ r && !n && /* @__PURE__ */ S(G, { what: "the transaction" }),
3185
+ /* @__PURE__ */ S(K, {
3186
+ message: i,
3187
+ onRetry: a
3188
+ }),
3189
+ n && /* @__PURE__ */ C(x, { children: [
3190
+ /* @__PURE__ */ C("div", {
3191
+ className: "cp-stats",
3192
+ children: [
3193
+ /* @__PURE__ */ S(J, {
3194
+ label: "Applied",
3195
+ value: n.applied ? "Yes" : "No"
3196
+ }),
3197
+ /* @__PURE__ */ S(J, {
3198
+ label: "Attribution held",
3199
+ value: n.attribution_available ? "Yes" : "No",
3200
+ hint: "Whether this commit is still inside the instance's bounded attribution window."
3201
+ }),
3202
+ /* @__PURE__ */ S(J, {
3203
+ label: "Actor",
3204
+ value: n.attribution?.subject ?? void 0
3205
+ }),
3206
+ /* @__PURE__ */ S(J, {
3207
+ label: "Records",
3208
+ value: n.attribution?.operations
3209
+ })
3210
+ ]
3211
+ }),
3212
+ /* @__PURE__ */ S("p", {
3213
+ className: "cp-muted",
3214
+ children: n.idempotent_replay
3215
+ }),
3216
+ n.applied && !n.attribution_available && /* @__PURE__ */ S("p", {
3217
+ className: "cp-notice",
3218
+ children: "This transaction applied, but it committed longer ago than the attribution window keeps. Who committed it is in the durable transaction log, which no route reads back."
3219
+ })
3220
+ ] })
3221
+ ]
3222
+ });
3223
+ }
3224
+ function Rt({ onOpenRecord: e }) {
3225
+ let { capabilities: t } = B(), [n, r] = v(""), [i, a] = v({
3226
+ subject: "",
3227
+ collection: ""
3228
+ }), [{ subject: o, collection: s }, c] = v({
3229
+ subject: "",
3230
+ collection: ""
3231
+ }), l = JSON.stringify([o, s]), { value: u, loading: d, error: f, refresh: p } = V((e) => e.transactions({
3232
+ subject: o || void 0,
3233
+ collection: s || void 0,
3234
+ limit: 100
3235
+ }).then((e) => ({
3236
+ ...e,
3237
+ request: l
3238
+ })), [l], {
3239
+ refreshMs: 8e3,
3240
+ subject: "recent commits"
3241
+ }), m = u?.request === l ? u : void 0;
3242
+ return /* @__PURE__ */ C(x, { children: [
3243
+ /* @__PURE__ */ S(rt, {
3244
+ label: "Filter commits",
3245
+ idPrefix: "commit-filter",
3246
+ filters: [{
3247
+ id: "subject",
3248
+ label: "Actor",
3249
+ value: i.subject,
3250
+ placeholder: "Subject"
3251
+ }, {
3252
+ id: "collection",
3253
+ label: "Collection",
3254
+ value: i.collection,
3255
+ placeholder: "Collection"
3256
+ }],
3257
+ onChange: (e, t) => a((n) => ({
3258
+ ...n,
3259
+ [e]: t
3260
+ })),
3261
+ onSubmit: () => c({
3262
+ subject: i.subject.trim(),
3263
+ collection: i.collection.trim()
3264
+ }),
3265
+ applied: +!!o + +!!s,
3266
+ onClear: () => {
3267
+ a({
3268
+ subject: "",
3269
+ collection: ""
3270
+ }), c({
3271
+ subject: "",
3272
+ collection: ""
3273
+ });
3274
+ },
3275
+ result: m && (o || s) ? `${m.transactions.length} ${m.transactions.length === 1 ? "commit matches" : "commits match"}` : ""
3276
+ }),
3277
+ /* @__PURE__ */ S("div", {
3278
+ className: "cp-actions",
3279
+ children: /* @__PURE__ */ S("button", {
3280
+ className: "btn btn-ghost",
3281
+ onClick: p,
3282
+ children: "Refresh"
3283
+ })
3284
+ }),
3285
+ m && /* @__PURE__ */ C("p", {
3286
+ className: "cp-muted",
3287
+ children: [
3288
+ m.window.note,
3289
+ " Holding ",
3290
+ m.window.held,
3291
+ " of ",
3292
+ m.window.capacity,
3293
+ "."
3294
+ ]
3295
+ }),
3296
+ /* @__PURE__ */ S(nt, {
3297
+ label: "Recent commits",
3298
+ loading: !f && (d || !m),
3299
+ loadingWhat: "commits",
3300
+ error: f ? {
3301
+ message: f,
3302
+ onRetry: p
3303
+ } : null,
3304
+ columns: [
3305
+ {
3306
+ id: "when",
3307
+ header: "When"
3308
+ },
3309
+ {
3310
+ id: "actor",
3311
+ header: "Actor"
3312
+ },
3313
+ {
3314
+ id: "application",
3315
+ header: "Application"
3316
+ },
3317
+ {
3318
+ id: "transaction",
3319
+ header: "Transaction"
3320
+ },
3321
+ {
3322
+ id: "records",
3323
+ header: "Records",
3324
+ align: "end"
3325
+ },
3326
+ {
3327
+ id: "revision",
3328
+ header: "Revision"
3329
+ },
3330
+ {
3331
+ id: "touched",
3332
+ header: "Touched"
3333
+ }
3334
+ ],
3335
+ rows: (m?.transactions || []).map((t) => ({
3336
+ key: t.transaction_id,
3337
+ selected: t.transaction_id === n,
3338
+ attrs: { "data-transaction": t.transaction_id },
3339
+ cells: {
3340
+ when: /* @__PURE__ */ S(X, { ms: t.unix_ms }),
3341
+ actor: t.subject ? /* @__PURE__ */ S("strong", { children: t.subject }) : /* @__PURE__ */ S("span", {
3342
+ className: "cp-muted",
3343
+ children: "unnamed"
3344
+ }),
3345
+ application: t.application_id ? /* @__PURE__ */ S("code", { children: t.application_id }) : null,
3346
+ transaction: /* @__PURE__ */ S("button", {
3347
+ className: "record-link",
3348
+ onClick: () => r(t.transaction_id),
3349
+ children: /* @__PURE__ */ S(Z, {
3350
+ value: t.transaction_id,
3351
+ length: 16
3352
+ })
3353
+ }),
3354
+ records: t.operations.toLocaleString(),
3355
+ revision: `${t.base_revision} → ${t.commit_revision}`,
3356
+ touched: /* @__PURE__ */ C("span", {
3357
+ className: "cp-keys",
3358
+ children: [t.keys.slice(0, 6).map((t) => {
3359
+ let n = t.split(":"), r = n.pop(), i = n.pop() || "";
3360
+ return /* @__PURE__ */ C("button", {
3361
+ className: "reference-value",
3362
+ onClick: () => e(i, r),
3363
+ children: [
3364
+ i,
3365
+ "/",
3366
+ r
3367
+ ]
3368
+ }, t);
3369
+ }), t.operations > Math.min(t.keys.length, 6) && /* @__PURE__ */ C("span", {
3370
+ className: "cp-muted",
3371
+ children: [
3372
+ " +",
3373
+ t.operations - Math.min(t.keys.length, 6),
3374
+ " more"
3375
+ ]
3376
+ })]
3377
+ })
3378
+ }
3379
+ })),
3380
+ noMatch: !!(o || s),
3381
+ noMatchTitle: "No commit in the window matches",
3382
+ noMatchBody: "Change or clear the filters.",
3383
+ emptyTitle: "No commits in the attribution window yet"
3384
+ }),
3385
+ t.status("operations.correlation_id") === "unsupported" && /* @__PURE__ */ S("p", {
3386
+ className: "cp-muted",
3387
+ children: t.note("operations.correlation_id")
3388
+ }),
3389
+ n && t.usable("operations.transaction_status") && /* @__PURE__ */ S(Lt, {
3390
+ transactionId: n,
3391
+ onClose: () => r("")
3392
+ })
3393
+ ] });
3394
+ }
3395
+ function zt() {
3396
+ let [e, t] = v(""), [n, r] = v(""), { value: i, loading: a, error: o, refresh: s } = V((t) => t.operations({
3397
+ collection: e || void 0,
3398
+ kind: n || void 0,
3399
+ limit: 100
3400
+ }), [e, n], {
3401
+ refreshMs: 8e3,
3402
+ subject: "recent operations"
3403
+ });
3404
+ return /* @__PURE__ */ C(x, { children: [
3405
+ /* @__PURE__ */ C("form", {
3406
+ className: "cp-filter",
3407
+ onSubmit: (e) => e.preventDefault(),
3408
+ children: [
3409
+ /* @__PURE__ */ S("input", {
3410
+ "aria-label": "Collection",
3411
+ value: e,
3412
+ onChange: (e) => t(e.target.value),
3413
+ placeholder: "Collection…"
3414
+ }),
3415
+ /* @__PURE__ */ C("select", {
3416
+ "aria-label": "Operation type",
3417
+ value: n,
3418
+ onChange: (e) => r(e.target.value),
3419
+ children: [
3420
+ /* @__PURE__ */ S("option", {
3421
+ value: "",
3422
+ children: "Any operation"
3423
+ }),
3424
+ /* @__PURE__ */ S("option", {
3425
+ value: "insert",
3426
+ children: "insert"
3427
+ }),
3428
+ /* @__PURE__ */ S("option", {
3429
+ value: "update",
3430
+ children: "update"
3431
+ }),
3432
+ /* @__PURE__ */ S("option", {
3433
+ value: "delete",
3434
+ children: "delete"
3435
+ })
3436
+ ]
3437
+ }),
3438
+ /* @__PURE__ */ S("button", {
3439
+ className: "btn btn-ghost",
3440
+ onClick: s,
3441
+ children: "Refresh"
3442
+ })
3443
+ ]
3444
+ }),
3445
+ i && /* @__PURE__ */ S("p", {
3446
+ className: "cp-muted",
3447
+ children: i.retained.note
3448
+ }),
3449
+ /* @__PURE__ */ S(K, {
3450
+ message: o,
3451
+ onRetry: s
3452
+ }),
3453
+ a && !i && /* @__PURE__ */ S(G, { what: "operations" }),
3454
+ i && (i.operations.length === 0 ? /* @__PURE__ */ S(q, { children: "No operation in the retained log matches." }) : /* @__PURE__ */ S("div", {
3455
+ className: "table-shell",
3456
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
3457
+ /* @__PURE__ */ S("th", { children: "When" }),
3458
+ /* @__PURE__ */ S("th", { children: "Type" }),
3459
+ /* @__PURE__ */ S("th", { children: "Collection" }),
3460
+ /* @__PURE__ */ S("th", { children: "Key" }),
3461
+ /* @__PURE__ */ S("th", { children: "Authority" }),
3462
+ /* @__PURE__ */ S("th", { children: "Sequence" }),
3463
+ /* @__PURE__ */ S("th", { children: "Revision" })
3464
+ ] }) }), /* @__PURE__ */ S("tbody", { children: i.operations.map((e) => /* @__PURE__ */ C("tr", { children: [
3465
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(X, { ms: e.timestamp_ms }) }),
3466
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(H, { status: e.type }) }),
3467
+ /* @__PURE__ */ S("td", { children: e.collection }),
3468
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: e.key }) }),
3469
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, { value: e.instance_id }) }),
3470
+ /* @__PURE__ */ S("td", { children: e.sequence }),
3471
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, { value: e.state_id }) })
3472
+ ] }, `${e.instance_id}-${e.operation_id}-${e.sequence}`)) })] })
3473
+ }))
3474
+ ] });
3475
+ }
3476
+ function Bt() {
3477
+ let { baseUrl: e, capabilities: t } = B(), [n, r] = v([]), [i, a] = v(!1), [o, s] = v(""), [c, l] = v(""), u = _(null);
3478
+ m(() => {
3479
+ if (!t.usable("operations.events")) return;
3480
+ let n = `${e.replace(/\/$/, "")}/v1/events`, i;
3481
+ try {
3482
+ i = new EventSource(n);
3483
+ } catch {
3484
+ s("The browser could not open the event stream.");
3485
+ return;
3486
+ }
3487
+ return u.current = i, i.onopen = () => {
3488
+ a(!0), s("");
3489
+ }, i.onerror = () => {
3490
+ a(!1), s("The event stream is not connected. It requires an endpoint reachable without an Authorization header.");
3491
+ }, i.addEventListener("state.changed", (e) => {
3492
+ try {
3493
+ r((t) => [JSON.parse(e.data), ...t].slice(0, 200));
3494
+ } catch {}
3495
+ }), () => {
3496
+ i.close(), u.current = null, a(!1);
3497
+ };
3498
+ }, [e, t]);
3499
+ let d = n.filter((e) => !c || JSON.stringify(e).toLowerCase().includes(c.toLowerCase()));
3500
+ return /* @__PURE__ */ C(x, { children: [
3501
+ /* @__PURE__ */ C("p", {
3502
+ className: "cp-muted",
3503
+ children: [
3504
+ "Live state changes as they commit. ",
3505
+ i ? "Connected." : "Not connected.",
3506
+ " This is a stream, not a log: it shows what happens while the page is open."
3507
+ ]
3508
+ }),
3509
+ /* @__PURE__ */ S("form", {
3510
+ className: "cp-filter",
3511
+ onSubmit: (e) => e.preventDefault(),
3512
+ children: /* @__PURE__ */ S("input", {
3513
+ "aria-label": "Search events",
3514
+ value: c,
3515
+ onChange: (e) => l(e.target.value),
3516
+ placeholder: "Search resource, actor, id…"
3517
+ })
3518
+ }),
3519
+ /* @__PURE__ */ S(K, { message: o }),
3520
+ d.length === 0 ? /* @__PURE__ */ S(q, { children: i ? "No change has been observed since this page opened." : "No events." }) : /* @__PURE__ */ S("div", {
3521
+ className: "table-shell",
3522
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
3523
+ /* @__PURE__ */ S("th", { children: "When" }),
3524
+ /* @__PURE__ */ S("th", { children: "Type" }),
3525
+ /* @__PURE__ */ S("th", { children: "Resource" }),
3526
+ /* @__PURE__ */ S("th", { children: "Id" }),
3527
+ /* @__PURE__ */ S("th", { children: "Actor" })
3528
+ ] }) }), /* @__PURE__ */ S("tbody", { children: d.map((e) => /* @__PURE__ */ C("tr", { children: [
3529
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(X, { ms: Number(e.timestamp) * 1e3 }) }),
3530
+ /* @__PURE__ */ S("td", { children: String(e.type) }),
3531
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S("code", { children: String(e.resource) }) }),
3532
+ /* @__PURE__ */ S("td", { children: String(e.resource_id) }),
3533
+ /* @__PURE__ */ S("td", { children: String(e.actor) })
3534
+ ] }, String(e.event_id))) })] })
3535
+ })
3536
+ ] });
3537
+ }
3538
+ function Vt({ onOpenRecord: e }) {
3539
+ let [t, n] = v("transactions"), { capabilities: r, loading: i, error: a, reload: o } = B(), s = Ft(i, a, r.status("provenance.transactions"));
3540
+ return s === "loading" ? /* @__PURE__ */ S($, {
3541
+ eyebrow: "Operations",
3542
+ title: "Operations",
3543
+ children: /* @__PURE__ */ S(G, { what: "runtime capabilities" })
3544
+ }) : s === "connection-failure" ? /* @__PURE__ */ S($, {
3545
+ eyebrow: "Operations",
3546
+ title: "Operations unavailable",
3547
+ description: "Studio could not connect to the FeltDB authority.",
3548
+ children: /* @__PURE__ */ S(K, {
3549
+ message: a,
3550
+ onRetry: o
3551
+ })
3552
+ }) : /* @__PURE__ */ S($, {
3553
+ eyebrow: "Operations",
3554
+ title: "Operations",
3555
+ description: "What was asked for, what the engine did, and what is happening right now.",
3556
+ children: /* @__PURE__ */ C(Q, {
3557
+ label: "Operations views",
3558
+ active: t,
3559
+ onSelect: n,
3560
+ tabs: [
3561
+ {
3562
+ id: "transactions",
3563
+ label: "Transactions"
3564
+ },
3565
+ {
3566
+ id: "operations",
3567
+ label: "Operations"
3568
+ },
3569
+ {
3570
+ id: "events",
3571
+ label: "Events"
3572
+ }
3573
+ ],
3574
+ children: [
3575
+ t === "transactions" && (s === "unsupported" ? /* @__PURE__ */ S(It, {}) : /* @__PURE__ */ C(x, { children: [/* @__PURE__ */ S(ct, { capability: "operations.rejections" }), /* @__PURE__ */ S(Rt, { onOpenRecord: e })] })),
3576
+ t === "operations" && /* @__PURE__ */ S(W, {
3577
+ capability: "operations.recent",
3578
+ children: /* @__PURE__ */ S(zt, {})
3579
+ }),
3580
+ t === "events" && /* @__PURE__ */ C(W, {
3581
+ capability: "operations.events",
3582
+ children: [/* @__PURE__ */ S(Bt, {}), /* @__PURE__ */ S(U, {
3583
+ capability: "operations.audit_log",
3584
+ title: "Searching past events"
3585
+ })]
3586
+ })
3587
+ ]
3588
+ })
3589
+ });
3590
+ }
3591
+ //#endregion
3592
+ //#region src/control-plane/Instance.tsx
3593
+ function Ht(e) {
3594
+ return e.capabilityLoading ? "loading" : e.capabilityError ? "discovery-failure" : e.capabilityStatus === "unsupported" ? "unsupported" : e.healthLoading || !e.hasHealth && !e.healthError ? "loading" : e.healthError ? "health-failure" : "supported";
3595
+ }
3596
+ function Ut() {
3597
+ return /* @__PURE__ */ C("section", {
3598
+ className: "cp-unavailable",
3599
+ role: "note",
3600
+ children: [
3601
+ /* @__PURE__ */ S("h3", { children: "Replication health" }),
3602
+ /* @__PURE__ */ S("p", { children: /* @__PURE__ */ S("strong", { children: "Not available from this runtime" }) }),
3603
+ /* @__PURE__ */ S("p", { children: "No replication health data is exposed by this FeltDB runtime." })
3604
+ ]
3605
+ });
3606
+ }
3607
+ function Wt() {
3608
+ let { capabilities: e, loading: t, error: n, reload: r } = B(), i = e.status("replication.health"), { value: a, loading: o, error: s, refresh: c } = V((e) => e.replication(), [], {
3609
+ enabled: !t && !n && i !== "unsupported",
3610
+ refreshMs: 1e4,
3611
+ subject: "replication"
3612
+ }), l = Ht({
3613
+ capabilityLoading: t,
3614
+ capabilityError: n,
3615
+ capabilityStatus: i,
3616
+ healthLoading: o,
3617
+ healthError: s,
3618
+ hasHealth: !!a
3619
+ });
3620
+ if (l === "loading") return /* @__PURE__ */ S($, {
3621
+ eyebrow: "Distributed state",
3622
+ title: "Replication",
3623
+ children: /* @__PURE__ */ S(G, { what: "replication status" })
3624
+ });
3625
+ if (l === "discovery-failure") return /* @__PURE__ */ S($, {
3626
+ eyebrow: "Distributed state",
3627
+ title: "Replication unavailable",
3628
+ description: "Studio could not determine replication status from the connected FeltDB authority.",
3629
+ children: /* @__PURE__ */ S(K, {
3630
+ message: n,
3631
+ onRetry: r
3632
+ })
3633
+ });
3634
+ if (l === "unsupported") return /* @__PURE__ */ S($, {
3635
+ eyebrow: "Distributed state",
3636
+ title: "Replication",
3637
+ children: /* @__PURE__ */ S(Ut, {})
3638
+ });
3639
+ if (l === "health-failure" || !a) return /* @__PURE__ */ S($, {
3640
+ eyebrow: "Distributed state",
3641
+ title: "Replication unavailable",
3642
+ description: "Studio could not determine replication status from the connected FeltDB authority.",
3643
+ children: /* @__PURE__ */ S(K, {
3644
+ message: s,
3645
+ onRetry: c
3646
+ })
3647
+ });
3648
+ let u = a.peers || [], d = a.causal_position || {}, f = a.retained_operation_floors || {};
3649
+ return /* @__PURE__ */ C($, {
3650
+ eyebrow: "Distributed state",
3651
+ title: "Replication",
3652
+ description: "Authorities, causal position, and what replication still owes.",
3653
+ children: [
3654
+ /* @__PURE__ */ C("section", {
3655
+ className: "cp-stats",
3656
+ children: [
3657
+ /* @__PURE__ */ S(J, {
3658
+ label: "Local authority",
3659
+ value: a.local?.instance_id
3660
+ }),
3661
+ /* @__PURE__ */ S(J, {
3662
+ label: "Peers",
3663
+ value: u.length
3664
+ }),
3665
+ /* @__PURE__ */ S(J, {
3666
+ label: "Sync successes",
3667
+ value: a.health?.peer_sync_successes
3668
+ }),
3669
+ /* @__PURE__ */ S(J, {
3670
+ label: "Sync failures",
3671
+ value: a.health?.peer_sync_failures
3672
+ }),
3673
+ /* @__PURE__ */ S(J, {
3674
+ label: "Operations sent",
3675
+ value: a.health?.operations_sent
3676
+ }),
3677
+ /* @__PURE__ */ S(J, {
3678
+ label: "Operations received",
3679
+ value: a.health?.operations_received
3680
+ }),
3681
+ /* @__PURE__ */ S(J, {
3682
+ label: "Operations compacted",
3683
+ value: a.health?.operations_compacted
3684
+ })
3685
+ ]
3686
+ }),
3687
+ /* @__PURE__ */ C("section", {
3688
+ className: "studio-card",
3689
+ children: [
3690
+ /* @__PURE__ */ S("span", {
3691
+ className: "card-kind",
3692
+ children: "Causal position"
3693
+ }),
3694
+ /* @__PURE__ */ S("p", {
3695
+ className: "cp-muted",
3696
+ children: "The highest operation sequence this instance holds from each origin, and the lowest it still retains. An origin whose floor has risen above a peer's position is a peer that can no longer catch up incrementally."
3697
+ }),
3698
+ Object.keys(d).length === 0 ? /* @__PURE__ */ S(q, { children: "No origin has produced an operation this instance holds." }) : /* @__PURE__ */ S("div", {
3699
+ className: "table-shell",
3700
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
3701
+ /* @__PURE__ */ S("th", { children: "Origin" }),
3702
+ /* @__PURE__ */ S("th", { children: "Highest held" }),
3703
+ /* @__PURE__ */ S("th", { children: "Retained from" })
3704
+ ] }) }), /* @__PURE__ */ S("tbody", { children: Object.entries(d).map(([e, t]) => /* @__PURE__ */ C("tr", { children: [
3705
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, {
3706
+ value: e,
3707
+ length: 20
3708
+ }) }),
3709
+ /* @__PURE__ */ S("td", { children: t }),
3710
+ /* @__PURE__ */ S("td", { children: f[e] ?? /* @__PURE__ */ S("span", {
3711
+ className: "cp-muted",
3712
+ children: "—"
3713
+ }) })
3714
+ ] }, e)) })] })
3715
+ })
3716
+ ]
3717
+ }),
3718
+ /* @__PURE__ */ C("section", {
3719
+ className: "studio-card",
3720
+ children: [/* @__PURE__ */ S("span", {
3721
+ className: "card-kind",
3722
+ children: "Peers"
3723
+ }), u.length === 0 ? /* @__PURE__ */ S(q, { children: "This instance has no peers. It is a single authority." }) : /* @__PURE__ */ S(Y, { value: u })]
3724
+ }),
3725
+ /* @__PURE__ */ C("details", {
3726
+ className: "cp-raw",
3727
+ children: [/* @__PURE__ */ S("summary", { children: "Membership" }), /* @__PURE__ */ S(Y, { value: a.membership })]
3728
+ })
3729
+ ]
3730
+ });
3731
+ }
3732
+ function Gt() {
3733
+ let { capabilities: e } = B(), { value: t, loading: n, error: r, refresh: i } = V((e) => e.applications(), [], {
3734
+ enabled: e.usable("applications.list"),
3735
+ refreshMs: 2e4,
3736
+ subject: "applications"
3737
+ });
3738
+ return /* @__PURE__ */ S($, {
3739
+ eyebrow: "Runtimes",
3740
+ title: "Applications",
3741
+ description: "Applications on this instance and the FeltDB runtimes serving them.",
3742
+ children: /* @__PURE__ */ C(W, {
3743
+ capability: "applications.list",
3744
+ children: [
3745
+ /* @__PURE__ */ S(K, {
3746
+ message: r,
3747
+ onRetry: i
3748
+ }),
3749
+ n && !t && /* @__PURE__ */ S(G, { what: "applications" }),
3750
+ t && (t.applications.length === 0 ? /* @__PURE__ */ S(q, { children: "No application is visible to you on this instance." }) : /* @__PURE__ */ S("div", {
3751
+ className: "cp-cards",
3752
+ children: t.applications.map((e) => /* @__PURE__ */ C("article", {
3753
+ className: "studio-card",
3754
+ children: [
3755
+ /* @__PURE__ */ S("span", {
3756
+ className: "card-kind",
3757
+ children: "application"
3758
+ }),
3759
+ /* @__PURE__ */ S("h3", { children: String(e.application_name) }),
3760
+ /* @__PURE__ */ C("p", {
3761
+ className: "cp-muted",
3762
+ children: [
3763
+ /* @__PURE__ */ S(Z, {
3764
+ value: String(e.application_id),
3765
+ length: 22
3766
+ }),
3767
+ " · tenant ",
3768
+ String(e.tenant_name),
3769
+ " ·",
3770
+ " ",
3771
+ /* @__PURE__ */ S(H, { status: String(e.status) })
3772
+ ]
3773
+ }),
3774
+ /* @__PURE__ */ S("div", {
3775
+ className: "table-shell",
3776
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
3777
+ /* @__PURE__ */ S("th", { children: "Environment" }),
3778
+ /* @__PURE__ */ S("th", { children: "Contract revision" }),
3779
+ /* @__PURE__ */ S("th", { children: "FeltDB runtime" }),
3780
+ /* @__PURE__ */ S("th", { children: "Started" })
3781
+ ] }) }), /* @__PURE__ */ S("tbody", { children: (e.environments || []).map((e) => /* @__PURE__ */ C("tr", { children: [
3782
+ /* @__PURE__ */ S("td", { children: String(e.environment) }),
3783
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(Z, { value: String(e.revision_id) }) }),
3784
+ /* @__PURE__ */ S("td", { children: e.runtime ? /* @__PURE__ */ S(H, { status: String(e.runtime.status) }) : /* @__PURE__ */ S("span", {
3785
+ className: "cp-muted",
3786
+ children: "not running"
3787
+ }) }),
3788
+ /* @__PURE__ */ S("td", { children: e.runtime ? /* @__PURE__ */ S(X, { ms: Number(e.runtime.started_at) * 1e3 }) : /* @__PURE__ */ S("span", {
3789
+ className: "cp-muted",
3790
+ children: "—"
3791
+ }) })
3792
+ ] }, String(e.environment))) })] })
3793
+ })
3794
+ ]
3795
+ }, String(e.application_id)))
3796
+ }))
3797
+ ]
3798
+ })
3799
+ });
3800
+ }
3801
+ function Kt() {
3802
+ let { capabilities: e } = B(), { value: t, loading: n, error: r, refresh: i } = V((e) => e.overview(), [], {
3803
+ refreshMs: 5e3,
3804
+ subject: "instance activity"
3805
+ }), { value: a } = V((e) => e.replication(), [], {
3806
+ enabled: e.usable("replication.health"),
3807
+ refreshMs: 1e4,
3808
+ subject: "replication health"
3809
+ });
3810
+ if (n && !t) return /* @__PURE__ */ S($, {
3811
+ eyebrow: "Health",
3812
+ title: "Monitoring",
3813
+ children: /* @__PURE__ */ S(G, { what: "activity" })
3814
+ });
3815
+ if (!t) return /* @__PURE__ */ S($, {
3816
+ eyebrow: "Health",
3817
+ title: "Monitoring",
3818
+ children: /* @__PURE__ */ S(K, {
3819
+ message: r,
3820
+ onRetry: i
3821
+ })
3822
+ });
3823
+ let o = t.activity || {};
3824
+ return /* @__PURE__ */ C($, {
3825
+ eyebrow: "Health",
3826
+ title: "Monitoring",
3827
+ description: "What this instance counts. Refreshed every five seconds.",
3828
+ children: [/* @__PURE__ */ C(W, {
3829
+ capability: "monitoring.metrics",
3830
+ children: [
3831
+ /* @__PURE__ */ C("section", {
3832
+ className: "cp-stats",
3833
+ children: [
3834
+ /* @__PURE__ */ S(J, {
3835
+ label: "Requests",
3836
+ value: o.requests
3837
+ }),
3838
+ /* @__PURE__ */ S(J, {
3839
+ label: "State reads",
3840
+ value: o.state_reads
3841
+ }),
3842
+ /* @__PURE__ */ S(J, {
3843
+ label: "State mutations",
3844
+ value: o.state_mutations
3845
+ }),
3846
+ /* @__PURE__ */ S(J, {
3847
+ label: "Event connections",
3848
+ value: o.event_connections
3849
+ })
3850
+ ]
3851
+ }),
3852
+ /* @__PURE__ */ C("section", {
3853
+ className: "cp-stats",
3854
+ children: [
3855
+ /* @__PURE__ */ S(J, {
3856
+ label: "Requests shed",
3857
+ value: o.requests_shed,
3858
+ hint: "Refused at the door because the in-flight limit was reached."
3859
+ }),
3860
+ /* @__PURE__ */ S(J, {
3861
+ label: "Deadlines exceeded",
3862
+ value: o.request_deadlines_exceeded
3863
+ }),
3864
+ /* @__PURE__ */ S(J, {
3865
+ label: "Authentication failures",
3866
+ value: o.authentication_failures
3867
+ }),
3868
+ /* @__PURE__ */ S(J, {
3869
+ label: "Admission slots free",
3870
+ value: t.runtime?.admission_permits_available
3871
+ })
3872
+ ]
3873
+ }),
3874
+ /* @__PURE__ */ C("section", {
3875
+ className: "cp-stats",
3876
+ children: [
3877
+ /* @__PURE__ */ S(J, {
3878
+ label: "Records",
3879
+ value: t.storage?.records
3880
+ }),
3881
+ /* @__PURE__ */ S(J, {
3882
+ label: "State revisions",
3883
+ value: t.storage?.state_revisions
3884
+ }),
3885
+ /* @__PURE__ */ S(J, {
3886
+ label: "Authority revision",
3887
+ value: t.authority?.authority_revision
3888
+ }),
3889
+ /* @__PURE__ */ S(J, {
3890
+ label: "Replication backlog sent",
3891
+ value: a?.health?.operations_sent
3892
+ })
3893
+ ]
3894
+ }),
3895
+ /* @__PURE__ */ C("section", {
3896
+ className: "studio-card",
3897
+ children: [/* @__PURE__ */ S("span", {
3898
+ className: "card-kind",
3899
+ children: "Audit writer"
3900
+ }), /* @__PURE__ */ S(Y, { value: t.storage?.audit })]
3901
+ })
3902
+ ]
3903
+ }), /* @__PURE__ */ S(U, { capability: "monitoring.latency" })]
3904
+ });
3905
+ }
3906
+ function qt() {
3907
+ let { capabilities: e } = B(), { value: t, loading: n, error: r, refresh: i } = V((e) => e.overview(), [], { subject: "instance settings" }), { value: a } = V((e) => e.diagnostics(), [], {
3908
+ enabled: e.usable("settings.instance"),
3909
+ subject: "instance diagnostics"
3910
+ }), o = e.declaration;
3911
+ return /* @__PURE__ */ C($, {
3912
+ eyebrow: "Instance",
3913
+ title: "Settings",
3914
+ description: "What this instance is configured as, and what it can do.",
3915
+ children: [
3916
+ /* @__PURE__ */ C(W, {
3917
+ capability: "settings.instance",
3918
+ children: [
3919
+ /* @__PURE__ */ S(K, {
3920
+ message: r,
3921
+ onRetry: i
3922
+ }),
3923
+ n && !t && /* @__PURE__ */ S(G, { what: "settings" }),
3924
+ t && /* @__PURE__ */ C(x, { children: [
3925
+ /* @__PURE__ */ C("section", {
3926
+ className: "studio-card",
3927
+ children: [/* @__PURE__ */ S("span", {
3928
+ className: "card-kind",
3929
+ children: "Identity"
3930
+ }), /* @__PURE__ */ C("div", {
3931
+ className: "cp-stats",
3932
+ children: [
3933
+ /* @__PURE__ */ S(J, {
3934
+ label: "Instance",
3935
+ value: t.instance?.instance_id
3936
+ }),
3937
+ /* @__PURE__ */ S(J, {
3938
+ label: "Namespace",
3939
+ value: t.instance?.namespace
3940
+ }),
3941
+ /* @__PURE__ */ S(J, {
3942
+ label: "Engine",
3943
+ value: t.instance?.engine_version
3944
+ }),
3945
+ /* @__PURE__ */ S(J, {
3946
+ label: "Protocol",
3947
+ value: t.instance?.protocol_version
3948
+ })
3949
+ ]
3950
+ })]
3951
+ }),
3952
+ /* @__PURE__ */ C("section", {
3953
+ className: "studio-card",
3954
+ children: [/* @__PURE__ */ S("span", {
3955
+ className: "card-kind",
3956
+ children: "Authority and storage"
3957
+ }), /* @__PURE__ */ C("div", {
3958
+ className: "cp-stats",
3959
+ children: [
3960
+ /* @__PURE__ */ S(J, {
3961
+ label: "Authority revision",
3962
+ value: t.authority?.authority_revision
3963
+ }),
3964
+ /* @__PURE__ */ S(J, {
3965
+ label: "Lease clock",
3966
+ value: typeof t.authority?.lease_clock_healthy == "boolean" ? t.authority.lease_clock_healthy ? "Healthy" : "Degraded" : void 0
3967
+ }),
3968
+ /* @__PURE__ */ S(J, {
3969
+ label: "Log recovery",
3970
+ value: t.storage?.log_recovery?.status
3971
+ }),
3972
+ /* @__PURE__ */ S(J, {
3973
+ label: "Autonomous worker",
3974
+ value: typeof t.runtime?.worker_enabled == "boolean" ? t.runtime.worker_enabled ? "Running" : "Off" : void 0
3975
+ })
3976
+ ]
3977
+ })]
3978
+ }),
3979
+ /* @__PURE__ */ C("section", {
3980
+ className: "studio-card",
3981
+ children: [/* @__PURE__ */ S("span", {
3982
+ className: "card-kind",
3983
+ children: "Limits"
3984
+ }), /* @__PURE__ */ C("div", {
3985
+ className: "cp-stats",
3986
+ children: [
3987
+ /* @__PURE__ */ S(J, {
3988
+ label: "Request deadline",
3989
+ value: t.runtime?.request_deadline_ms === void 0 ? void 0 : `${t.runtime.request_deadline_ms} ms`
3990
+ }),
3991
+ /* @__PURE__ */ S(J, {
3992
+ label: "Admission slots free",
3993
+ value: t.runtime?.admission_permits_available
3994
+ }),
3995
+ /* @__PURE__ */ S(J, {
3996
+ label: "Authentication",
3997
+ value: typeof t.instance?.authentication_enabled == "boolean" ? t.instance.authentication_enabled ? "Enabled" : "Disabled" : void 0
3998
+ })
3999
+ ]
4000
+ })]
4001
+ }),
4002
+ a && /* @__PURE__ */ C("details", {
4003
+ className: "cp-raw",
4004
+ children: [/* @__PURE__ */ S("summary", { children: "Diagnostics" }), /* @__PURE__ */ S(Y, { value: a })]
4005
+ })
4006
+ ] })
4007
+ ]
4008
+ }),
4009
+ /* @__PURE__ */ S(U, {
4010
+ capability: "settings.mutate",
4011
+ title: "Changing instance configuration"
4012
+ }),
4013
+ /* @__PURE__ */ C("section", {
4014
+ className: "studio-card",
4015
+ children: [
4016
+ /* @__PURE__ */ S("span", {
4017
+ className: "card-kind",
4018
+ children: "Capability matrix"
4019
+ }),
4020
+ /* @__PURE__ */ S("p", {
4021
+ className: "cp-muted",
4022
+ children: "What this instance declares it can do. Studio renders only what is declared here; anything unsupported appears as unavailable, with the reason below, rather than as a control that cannot work."
4023
+ }),
4024
+ o ? /* @__PURE__ */ S("div", {
4025
+ className: "table-shell",
4026
+ children: /* @__PURE__ */ C("table", { children: [/* @__PURE__ */ S("thead", { children: /* @__PURE__ */ C("tr", { children: [
4027
+ /* @__PURE__ */ S("th", { children: "Capability" }),
4028
+ /* @__PURE__ */ S("th", { children: "Area" }),
4029
+ /* @__PURE__ */ S("th", { children: "Status" }),
4030
+ /* @__PURE__ */ S("th", { children: "Surface" }),
4031
+ /* @__PURE__ */ S("th", { children: "Note" })
4032
+ ] }) }), /* @__PURE__ */ S("tbody", { children: o.capabilities.map((e) => /* @__PURE__ */ C("tr", { children: [
4033
+ /* @__PURE__ */ C("td", { children: [
4034
+ /* @__PURE__ */ S("strong", { children: e.title }),
4035
+ /* @__PURE__ */ S("br", {}),
4036
+ /* @__PURE__ */ S("code", { children: e.id })
4037
+ ] }),
4038
+ /* @__PURE__ */ S("td", { children: e.area }),
4039
+ /* @__PURE__ */ S("td", { children: /* @__PURE__ */ S(H, { status: e.status }) }),
4040
+ /* @__PURE__ */ S("td", {
4041
+ className: "cp-keys",
4042
+ children: e.surface.length === 0 ? /* @__PURE__ */ S("span", {
4043
+ className: "cp-muted",
4044
+ children: "none"
4045
+ }) : e.surface.map((e) => /* @__PURE__ */ S("code", { children: e }, e))
4046
+ }),
4047
+ /* @__PURE__ */ S("td", {
4048
+ className: "cp-note",
4049
+ children: e.note || /* @__PURE__ */ S("span", {
4050
+ className: "cp-muted",
4051
+ children: "—"
4052
+ })
4053
+ })
4054
+ ] }, e.id)) })] })
4055
+ }) : /* @__PURE__ */ S(q, { children: "The instance did not answer with a capability declaration, so Studio is treating every capability as unavailable." })
4056
+ ]
4057
+ })
4058
+ ]
4059
+ });
4060
+ }
4061
+ function Jt() {
4062
+ let { capabilities: e } = B(), t = e.usable("developer.access"), { value: n, loading: r, error: i, refresh: a } = V((e) => e.developer(), [], {
4063
+ enabled: t,
4064
+ subject: "developer access"
4065
+ });
4066
+ if (!t) return /* @__PURE__ */ S($, {
4067
+ eyebrow: "Connect",
4068
+ title: "Developer",
4069
+ children: /* @__PURE__ */ S(W, {
4070
+ capability: "developer.access",
4071
+ children: /* @__PURE__ */ S(x, {})
4072
+ })
4073
+ });
4074
+ if (r && !n) return /* @__PURE__ */ S($, {
4075
+ eyebrow: "Connect",
4076
+ title: "Developer",
4077
+ children: /* @__PURE__ */ S(G, { what: "connection details" })
4078
+ });
4079
+ if (!n) return /* @__PURE__ */ S($, {
4080
+ eyebrow: "Connect",
4081
+ title: "Developer",
4082
+ children: /* @__PURE__ */ S(K, {
4083
+ message: i,
4084
+ onRetry: a
4085
+ })
4086
+ });
4087
+ let o = n.environment || {};
4088
+ return /* @__PURE__ */ S($, {
4089
+ eyebrow: "Connect",
4090
+ title: "Developer",
4091
+ description: "How an application, an agent, or a person connects to this instance.",
4092
+ children: /* @__PURE__ */ C(W, {
4093
+ capability: "developer.access",
4094
+ children: [
4095
+ /* @__PURE__ */ C("section", {
4096
+ className: "cp-stats",
4097
+ children: [
4098
+ /* @__PURE__ */ S(J, {
4099
+ label: "Endpoint",
4100
+ value: n.endpoint || "not advertised"
4101
+ }),
4102
+ /* @__PURE__ */ S(J, {
4103
+ label: "Namespace",
4104
+ value: n.namespace
4105
+ }),
4106
+ /* @__PURE__ */ S(J, {
4107
+ label: "Protocol",
4108
+ value: n.protocol_version
4109
+ }),
4110
+ /* @__PURE__ */ S(J, {
4111
+ label: "Authentication",
4112
+ value: n.authentication
4113
+ })
4114
+ ]
4115
+ }),
4116
+ /* @__PURE__ */ C("section", {
4117
+ className: "studio-card",
4118
+ children: [
4119
+ /* @__PURE__ */ S("span", {
4120
+ className: "card-kind",
4121
+ children: "SDK"
4122
+ }),
4123
+ /* @__PURE__ */ S("p", {
4124
+ className: "cp-muted",
4125
+ children: n.sdk?.install
4126
+ }),
4127
+ /* @__PURE__ */ S("pre", {
4128
+ className: "cp-json",
4129
+ children: n.sdk?.snippet
4130
+ })
4131
+ ]
4132
+ }),
4133
+ /* @__PURE__ */ C("section", {
4134
+ className: "studio-card",
4135
+ children: [/* @__PURE__ */ S("span", {
4136
+ className: "card-kind",
4137
+ children: "CLI"
4138
+ }), /* @__PURE__ */ S("pre", {
4139
+ className: "cp-json",
4140
+ children: n.cli?.snippet
4141
+ })]
4142
+ }),
4143
+ /* @__PURE__ */ C("section", {
4144
+ className: "studio-card",
4145
+ children: [/* @__PURE__ */ S("span", {
4146
+ className: "card-kind",
4147
+ children: "Environment"
4148
+ }), /* @__PURE__ */ S("pre", {
4149
+ className: "cp-json",
4150
+ children: Object.entries(o).map(([e, t]) => `${e}=${t || ""}`).join("\n")
4151
+ })]
4152
+ }),
4153
+ /* @__PURE__ */ C("section", {
4154
+ className: "studio-card",
4155
+ children: [/* @__PURE__ */ S("span", {
4156
+ className: "card-kind",
4157
+ children: "Interface description"
4158
+ }), /* @__PURE__ */ C("p", {
4159
+ className: "cp-muted",
4160
+ children: [
4161
+ "The instance describes its own application interface at ",
4162
+ /* @__PURE__ */ S("code", { children: n.openapi }),
4163
+ ". An agent that can read it needs nothing else to discover what this application declares and what it may call."
4164
+ ]
4165
+ })]
4166
+ }),
4167
+ /* @__PURE__ */ S(U, { capability: "developer.tool_projection" })
4168
+ ]
4169
+ })
4170
+ });
4171
+ }
4172
+ //#endregion
4173
+ export { Q as A, Y as C, lt as D, ct as E, V as F, at as I, Ue as L, U as M, st as N, J as O, B as P, fe as R, Z as S, $ as T, pt as _, Ut as a, q as b, Vt as c, Mt as d, jt as f, yt as g, bt as h, Wt as i, X as j, H as k, It as l, Et as m, Jt as n, qt as o, Pt as p, Kt as r, Ht as s, Gt as t, Ft as u, ut as v, G as w, K as x, W as y };