@elaraai/e3-ui-components 1.0.4 → 1.0.6
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.
- package/README.md +3 -2
- package/dist/decision/constraint-format.d.ts +20 -0
- package/dist/decision/constraint-format.d.ts.map +1 -0
- package/dist/decision/facets.d.ts +23 -0
- package/dist/decision/facets.d.ts.map +1 -0
- package/dist/decision/handle-runtime.d.ts +78 -0
- package/dist/decision/handle-runtime.d.ts.map +1 -0
- package/dist/decision/journal.d.ts +10 -0
- package/dist/decision/journal.d.ts.map +1 -0
- package/dist/decision/lever-editor.d.ts +28 -0
- package/dist/decision/lever-editor.d.ts.map +1 -0
- package/dist/decision/queue.d.ts +10 -0
- package/dist/decision/queue.d.ts.map +1 -0
- package/dist/decision/types.d.ts +11 -0
- package/dist/decision/types.d.ts.map +1 -0
- package/dist/diff/index.d.ts +1 -1
- package/dist/diff/index.d.ts.map +1 -1
- package/dist/index.cjs +1234 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1229 -12
- package/dist/index.js.map +1 -1
- package/dist/ontology/bind-runtime.d.ts +1 -1
- package/dist/ontology/bind-runtime.d.ts.map +1 -1
- package/dist/ontology/index.d.ts +1 -1
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/types.d.ts +1 -1
- package/dist/ontology/types.d.ts.map +1 -1
- package/dist/platform/bind-runtime.d.ts +1 -1
- package/dist/platform/bind-runtime.d.ts.map +1 -1
- package/package.json +14 -14
package/dist/index.cjs
CHANGED
|
@@ -5,8 +5,8 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
|
|
|
5
5
|
var _a;
|
|
6
6
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
7
|
const east = require("@elaraai/east");
|
|
8
|
-
const internal = require("@elaraai/east/internal");
|
|
9
|
-
const
|
|
8
|
+
const internal$1 = require("@elaraai/east/internal");
|
|
9
|
+
const internal = require("@elaraai/e3-ui/internal");
|
|
10
10
|
const platform = require("@elaraai/east-ui-components/platform");
|
|
11
11
|
const e3ApiClient = require("@elaraai/e3-api-client");
|
|
12
12
|
const jsxRuntime = require("react/jsx-runtime");
|
|
@@ -14,6 +14,7 @@ const React = require("react");
|
|
|
14
14
|
const react = require("@chakra-ui/react");
|
|
15
15
|
const eastUiComponents = require("@elaraai/east-ui-components");
|
|
16
16
|
const reactDom = require("react-dom");
|
|
17
|
+
const internal$2 = require("@elaraai/east-ui/internal");
|
|
17
18
|
const reactQuery = require("@tanstack/react-query");
|
|
18
19
|
const reactVirtual = require("@tanstack/react-virtual");
|
|
19
20
|
function _interopNamespaceDefault(e2) {
|
|
@@ -693,10 +694,10 @@ function clearStagedStoreSingleton() {
|
|
|
693
694
|
}
|
|
694
695
|
const UNCHANGED_VARIANT = east.variant("unchanged", null);
|
|
695
696
|
const blobEqual = east.equalFor(east.BlobType);
|
|
696
|
-
const eastTypeEqual = east.equalFor(internal.EastTypeType);
|
|
697
|
+
const eastTypeEqual = east.equalFor(internal$1.EastTypeType);
|
|
697
698
|
const helpersCache = new east.SortedMap(
|
|
698
699
|
void 0,
|
|
699
|
-
east.compareFor(internal.EastTypeType)
|
|
700
|
+
east.compareFor(internal$1.EastTypeType)
|
|
700
701
|
);
|
|
701
702
|
function getBindingHelpers(sourceType) {
|
|
702
703
|
let cached = helpersCache.get(sourceType);
|
|
@@ -1161,7 +1162,7 @@ class BindRuntime {
|
|
|
1161
1162
|
* Pass `allowed=null` for an unscoped impl (the global
|
|
1162
1163
|
* `BindPlatform`); pass a Set for manifest scoping. */
|
|
1163
1164
|
buildPlatform(allowed) {
|
|
1164
|
-
return
|
|
1165
|
+
return internal.bindPlatformFn.implement(
|
|
1165
1166
|
(sourceType) => (sourcePathArg, patchOpt, modeVariant) => {
|
|
1166
1167
|
const sourcePath = sourcePathArg;
|
|
1167
1168
|
const { patchPath, mode } = resolveOptions(patchOpt, modeVariant);
|
|
@@ -5263,7 +5264,7 @@ function parseManualDraft(leafType, draft) {
|
|
|
5263
5264
|
return { ok: false };
|
|
5264
5265
|
}
|
|
5265
5266
|
}
|
|
5266
|
-
const diffValueEqual = east.equalFor(
|
|
5267
|
+
const diffValueEqual = east.equalFor(internal.Diff.Component.schema);
|
|
5267
5268
|
function getOpt$1(opt) {
|
|
5268
5269
|
return opt.type === "some" ? opt.value : void 0;
|
|
5269
5270
|
}
|
|
@@ -6241,7 +6242,7 @@ const EastChakraDiff = React.memo(function EastChakraDiff2({ value }) {
|
|
|
6241
6242
|
function rowKey(pathStr, leafPath) {
|
|
6242
6243
|
return `${pathStr}::${leafPath}`;
|
|
6243
6244
|
}
|
|
6244
|
-
eastUiComponents.implementUIComponent(
|
|
6245
|
+
eastUiComponents.implementUIComponent(internal.Diff.Component, EastChakraDiff);
|
|
6245
6246
|
function cc(names) {
|
|
6246
6247
|
if (typeof names === "string" || typeof names === "number") return "" + names;
|
|
6247
6248
|
let out = "";
|
|
@@ -18318,7 +18319,7 @@ var hashIntsArray = function hashIntsArray2(ints, seed) {
|
|
|
18318
18319
|
};
|
|
18319
18320
|
return hashIterableInts(iterator, seed);
|
|
18320
18321
|
};
|
|
18321
|
-
var hashString = function
|
|
18322
|
+
var hashString$1 = function hashString(str, seed) {
|
|
18322
18323
|
var entry = {
|
|
18323
18324
|
value: 0,
|
|
18324
18325
|
done: false
|
|
@@ -18345,9 +18346,9 @@ var hashStringsArray = function hashStringsArray2(strs) {
|
|
|
18345
18346
|
for (var i = 0; i < strs.length; i++) {
|
|
18346
18347
|
var str = strs[i];
|
|
18347
18348
|
if (i === 0) {
|
|
18348
|
-
hash2 = hashString(str);
|
|
18349
|
+
hash2 = hashString$1(str);
|
|
18349
18350
|
} else {
|
|
18350
|
-
hash2 = hashString(str, hash2);
|
|
18351
|
+
hash2 = hashString$1(str, hash2);
|
|
18351
18352
|
}
|
|
18352
18353
|
}
|
|
18353
18354
|
return hash2;
|
|
@@ -25485,7 +25486,7 @@ var cache = function cache2(fn3, name) {
|
|
|
25485
25486
|
var _p = eles[0]._private;
|
|
25486
25487
|
var tch = _p.traversalCache = _p.traversalCache || {};
|
|
25487
25488
|
var ch = tch[name] = tch[name] || [];
|
|
25488
|
-
var hash2 = hashString(key);
|
|
25489
|
+
var hash2 = hashString$1(key);
|
|
25489
25490
|
var cacheHit = ch[hash2];
|
|
25490
25491
|
if (cacheHit) {
|
|
25491
25492
|
return cacheHit;
|
|
@@ -28091,13 +28092,13 @@ function styleCache(key, fn3, ele) {
|
|
|
28091
28092
|
}
|
|
28092
28093
|
}
|
|
28093
28094
|
function cacheStyleFunction(key, fn3) {
|
|
28094
|
-
key = hashString(key);
|
|
28095
|
+
key = hashString$1(key);
|
|
28095
28096
|
return function cachedStyleFunction(ele) {
|
|
28096
28097
|
return styleCache(key, fn3, ele);
|
|
28097
28098
|
};
|
|
28098
28099
|
}
|
|
28099
28100
|
function cachePrototypeStyleFunction(key, fn3) {
|
|
28100
|
-
key = hashString(key);
|
|
28101
|
+
key = hashString$1(key);
|
|
28101
28102
|
var selfFn = function selfFn2(ele) {
|
|
28102
28103
|
return fn3.call(ele);
|
|
28103
28104
|
};
|
|
@@ -38368,7 +38369,7 @@ BRp$9.applyLabelDimensions = function(ele) {
|
|
|
38368
38369
|
BRp$9.applyPrefixedLabelDimensions = function(ele, prefix2) {
|
|
38369
38370
|
var _p = ele._private;
|
|
38370
38371
|
var text = this.getLabelText(ele, prefix2);
|
|
38371
|
-
var cacheKey = hashString(text, ele._private.labelDimsKey);
|
|
38372
|
+
var cacheKey = hashString$1(text, ele._private.labelDimsKey);
|
|
38372
38373
|
if (getPrefixedProperty(_p.rscratch, "prefixedLabelDimsKey", prefix2) === cacheKey) {
|
|
38373
38374
|
return;
|
|
38374
38375
|
}
|
|
@@ -42764,7 +42765,7 @@ CRp$9.drawArrowShape = function(edge, context, fill, edgeWidth, shape, shapeWidt
|
|
|
42764
42765
|
var shapeImpl = r2.arrowShapes[shape];
|
|
42765
42766
|
if (usePaths) {
|
|
42766
42767
|
var cache3 = r2.arrowPathCache = r2.arrowPathCache || [];
|
|
42767
|
-
var key = hashString(shape);
|
|
42768
|
+
var key = hashString$1(shape);
|
|
42768
42769
|
var cachedPath = cache3[key];
|
|
42769
42770
|
if (cachedPath != null) {
|
|
42770
42771
|
path = context = cachedPath;
|
|
@@ -53055,7 +53056,1220 @@ const EastChakraOntology = React.memo(function EastChakraOntology2({ value }) {
|
|
|
53055
53056
|
}
|
|
53056
53057
|
);
|
|
53057
53058
|
});
|
|
53058
|
-
eastUiComponents.implementUIComponent(
|
|
53059
|
+
eastUiComponents.implementUIComponent(internal.Ontology.Component, EastChakraOntology);
|
|
53060
|
+
const SELECTION_TYPE = east.OptionType(east.StringType);
|
|
53061
|
+
const encodeSelection = east.encodeBeast2For(SELECTION_TYPE);
|
|
53062
|
+
const decodeSelection = east.decodeBeast2For(SELECTION_TYPE);
|
|
53063
|
+
function deriveSelectionKey(decisions) {
|
|
53064
|
+
return ["decision.selection", ...decisions.map((d2) => datasetPathToString(d2.source))].join("|");
|
|
53065
|
+
}
|
|
53066
|
+
function viewFor(binding) {
|
|
53067
|
+
const workspace = getReactiveDatasetCache().getConfig().workspace ?? "";
|
|
53068
|
+
const source = binding.source;
|
|
53069
|
+
const types = getBindingTypes(workspace, source);
|
|
53070
|
+
if (!types) {
|
|
53071
|
+
throw new Error(
|
|
53072
|
+
`Decision.bind: no binding registered for ${datasetPathToString(source)} — bind it with Data.bind on the same surface first`
|
|
53073
|
+
);
|
|
53074
|
+
}
|
|
53075
|
+
const patch = binding.patch.type === "some" ? binding.patch.value : void 0;
|
|
53076
|
+
return defaultBindRuntime.buildBindHandle(types.sourceType, source, patch, binding.mode.type);
|
|
53077
|
+
}
|
|
53078
|
+
const DECISION_SLICE_CONFIG = {
|
|
53079
|
+
fields: /* @__PURE__ */ new Map([
|
|
53080
|
+
["kind", east.variant("string", { label: "Kind", accessor: (d2) => d2.kind })],
|
|
53081
|
+
["title", east.variant("string", { label: "Title", accessor: (d2) => d2.title })],
|
|
53082
|
+
["value", east.variant("float", { label: "Value", accessor: (d2) => d2.value })]
|
|
53083
|
+
]),
|
|
53084
|
+
rangeFieldId: east.none,
|
|
53085
|
+
searchFieldIds: ["kind", "title"],
|
|
53086
|
+
breakdownFieldIds: []
|
|
53087
|
+
};
|
|
53088
|
+
function deriveSliceKey(decisions, sliceInit) {
|
|
53089
|
+
const sources = decisions.map((d2) => datasetPathToString(d2.source));
|
|
53090
|
+
const seed = sliceInit === void 0 ? "none" : hashString2(stableStringify(sliceInit));
|
|
53091
|
+
return ["decision.slice", ...sources, seed].join("|");
|
|
53092
|
+
}
|
|
53093
|
+
function stableStringify(v3) {
|
|
53094
|
+
return JSON.stringify(v3, (_k, x2) => {
|
|
53095
|
+
if (typeof x2 === "bigint") return `${x2}n`;
|
|
53096
|
+
if (x2 instanceof Date) return x2.toISOString();
|
|
53097
|
+
if (x2 instanceof Set) return [...x2].sort();
|
|
53098
|
+
if (x2 instanceof Map) return [...x2.entries()].sort((a2, b2) => String(a2[0]).localeCompare(String(b2[0])));
|
|
53099
|
+
return x2;
|
|
53100
|
+
});
|
|
53101
|
+
}
|
|
53102
|
+
function hashString2(s2) {
|
|
53103
|
+
let h2 = 5381;
|
|
53104
|
+
for (let i = 0; i < s2.length; i++) h2 = (h2 << 5) + h2 + s2.charCodeAt(i) | 0;
|
|
53105
|
+
return (h2 >>> 0).toString(36);
|
|
53106
|
+
}
|
|
53107
|
+
function buildDecisionHandle(decisions, judgements, sliceInit) {
|
|
53108
|
+
const selectionKey = deriveSelectionKey(decisions);
|
|
53109
|
+
const readSelection = () => {
|
|
53110
|
+
eastUiComponents.StateRuntime.trackKey(selectionKey);
|
|
53111
|
+
const bytes = eastUiComponents.StateRuntime.getStore().read(selectionKey);
|
|
53112
|
+
return bytes === void 0 ? east.none : decodeSelection(bytes);
|
|
53113
|
+
};
|
|
53114
|
+
const writeSelection = (value) => {
|
|
53115
|
+
eastUiComponents.StateRuntime.getStore().write(selectionKey, encodeSelection(value));
|
|
53116
|
+
return null;
|
|
53117
|
+
};
|
|
53118
|
+
const queue = () => decisions.flatMap((b2) => viewFor(b2).read());
|
|
53119
|
+
const readJudgements = () => viewFor(judgements).read();
|
|
53120
|
+
const writeJudgements = (next2) => {
|
|
53121
|
+
viewFor(judgements).write(next2);
|
|
53122
|
+
};
|
|
53123
|
+
const judgementFor = (caseId) => readJudgements().get(caseId) ?? {
|
|
53124
|
+
caseId,
|
|
53125
|
+
answers: /* @__PURE__ */ new Map(),
|
|
53126
|
+
knowledge: east.none,
|
|
53127
|
+
constraints: [],
|
|
53128
|
+
verdict: east.none,
|
|
53129
|
+
resolvedAt: east.none
|
|
53130
|
+
};
|
|
53131
|
+
const stageJudgement = (caseId, change) => {
|
|
53132
|
+
const dict = new Map(readJudgements());
|
|
53133
|
+
dict.set(caseId, { ...judgementFor(caseId), ...change });
|
|
53134
|
+
writeJudgements(dict);
|
|
53135
|
+
return null;
|
|
53136
|
+
};
|
|
53137
|
+
const removeFromOwningView = (caseId) => {
|
|
53138
|
+
for (const binding of decisions) {
|
|
53139
|
+
const view = viewFor(binding);
|
|
53140
|
+
const rows = view.read();
|
|
53141
|
+
if (rows.some((d2) => d2.id === caseId)) {
|
|
53142
|
+
view.write(rows.filter((d2) => d2.id !== caseId));
|
|
53143
|
+
}
|
|
53144
|
+
}
|
|
53145
|
+
};
|
|
53146
|
+
const slice3 = eastUiComponents.buildSliceHandle(
|
|
53147
|
+
deriveSliceKey(decisions, sliceInit),
|
|
53148
|
+
DECISION_SLICE_CONFIG,
|
|
53149
|
+
sliceInit ?? eastUiComponents.DEFAULT_SLICE_STATE,
|
|
53150
|
+
() => queue(),
|
|
53151
|
+
east.none
|
|
53152
|
+
);
|
|
53153
|
+
return {
|
|
53154
|
+
decisions,
|
|
53155
|
+
judgements,
|
|
53156
|
+
sliceInit: sliceInit !== void 0 ? east.some(sliceInit) : east.none,
|
|
53157
|
+
slice: slice3,
|
|
53158
|
+
queue,
|
|
53159
|
+
selected: readSelection,
|
|
53160
|
+
select: (caseId) => writeSelection(east.some(caseId)),
|
|
53161
|
+
clearSelection: () => writeSelection(east.none),
|
|
53162
|
+
decision: () => {
|
|
53163
|
+
const selection2 = readSelection();
|
|
53164
|
+
if (selection2.type === "none") return east.none;
|
|
53165
|
+
const found = queue().find((d2) => d2.id === selection2.value);
|
|
53166
|
+
return found === void 0 ? east.none : east.some(found);
|
|
53167
|
+
},
|
|
53168
|
+
update: (edited) => {
|
|
53169
|
+
for (const binding of decisions) {
|
|
53170
|
+
const view = viewFor(binding);
|
|
53171
|
+
const rows = view.read();
|
|
53172
|
+
if (rows.some((d2) => d2.id === edited.id)) {
|
|
53173
|
+
view.write(rows.map((d2) => d2.id === edited.id ? edited : d2));
|
|
53174
|
+
}
|
|
53175
|
+
}
|
|
53176
|
+
return null;
|
|
53177
|
+
},
|
|
53178
|
+
judgement: judgementFor,
|
|
53179
|
+
answer: (caseId, prompt, response) => {
|
|
53180
|
+
const answers = new Map(judgementFor(caseId).answers);
|
|
53181
|
+
answers.set(prompt, response);
|
|
53182
|
+
return stageJudgement(caseId, { answers });
|
|
53183
|
+
},
|
|
53184
|
+
addKnowledge: (caseId, text) => stageJudgement(caseId, { knowledge: east.some(text) }),
|
|
53185
|
+
inject: (caseId, constraint) => {
|
|
53186
|
+
const constraints = judgementFor(caseId).constraints.filter((c2) => c2.type !== constraint.type).concat([constraint]);
|
|
53187
|
+
return stageJudgement(caseId, { constraints });
|
|
53188
|
+
},
|
|
53189
|
+
resolve: (caseId, verdict) => {
|
|
53190
|
+
stageJudgement(caseId, { verdict: east.some(verdict), resolvedAt: east.some(/* @__PURE__ */ new Date()) });
|
|
53191
|
+
removeFromOwningView(caseId);
|
|
53192
|
+
writeSelection(east.none);
|
|
53193
|
+
return null;
|
|
53194
|
+
},
|
|
53195
|
+
journal: () => {
|
|
53196
|
+
const entries = [...readJudgements().values()].filter((j2) => j2.verdict.type === "some");
|
|
53197
|
+
const at = (j2) => j2.resolvedAt.type === "some" ? j2.resolvedAt.value.getTime() : 0;
|
|
53198
|
+
return entries.sort((a2, b2) => at(b2) - at(a2));
|
|
53199
|
+
},
|
|
53200
|
+
commitState: (caseId) => {
|
|
53201
|
+
const decision = queue().find((d2) => d2.id === caseId);
|
|
53202
|
+
const prompts = (decision == null ? void 0 : decision.prompts) ?? [];
|
|
53203
|
+
const answers = judgementFor(caseId).answers;
|
|
53204
|
+
const responses = prompts.map((p2) => {
|
|
53205
|
+
var _a2;
|
|
53206
|
+
return (_a2 = answers.get(p2.id)) == null ? void 0 : _a2.type;
|
|
53207
|
+
});
|
|
53208
|
+
if (responses.some((r2) => r2 === "no")) return east.variant("blocked", null);
|
|
53209
|
+
if (responses.some((r2) => r2 === "unknown")) return east.variant("handoff", null);
|
|
53210
|
+
const unanswered = responses.filter((r2) => r2 === void 0).length;
|
|
53211
|
+
if (unanswered > 0) return east.variant("gated", BigInt(unanswered));
|
|
53212
|
+
return east.variant("ready", null);
|
|
53213
|
+
}
|
|
53214
|
+
};
|
|
53215
|
+
}
|
|
53216
|
+
const DecisionBindPlatform = [
|
|
53217
|
+
// Generic over the constraint contract — the type argument resolver
|
|
53218
|
+
// receives the contract type value; the JS impl is type-agnostic.
|
|
53219
|
+
internal.decisionBindPlatformFn.implement((_constraintType) => (decisionsArg, judgementsArg, sliceInitArg) => buildDecisionHandle(
|
|
53220
|
+
decisionsArg,
|
|
53221
|
+
judgementsArg,
|
|
53222
|
+
eastUiComponents.getSomeorUndefined(sliceInitArg)
|
|
53223
|
+
))
|
|
53224
|
+
];
|
|
53225
|
+
eastUiComponents.registerPlatformImplementation(DecisionBindPlatform);
|
|
53226
|
+
function useHandleVersion(handle) {
|
|
53227
|
+
const staged = getStagedStore();
|
|
53228
|
+
const cache3 = getReactiveDatasetCache();
|
|
53229
|
+
const state = eastUiComponents.StateRuntime.getStore();
|
|
53230
|
+
const workspace = cache3.getConfig().workspace ?? "";
|
|
53231
|
+
const keys = React.useMemo(() => {
|
|
53232
|
+
if (!handle) return [];
|
|
53233
|
+
const bindings = [...handle.decisions, handle.judgements];
|
|
53234
|
+
const ks = [];
|
|
53235
|
+
for (const b2 of bindings) {
|
|
53236
|
+
ks.push(datasetCacheKey(workspace, b2.source));
|
|
53237
|
+
if (b2.patch.type === "some") ks.push(datasetCacheKey(workspace, b2.patch.value));
|
|
53238
|
+
}
|
|
53239
|
+
return ks;
|
|
53240
|
+
}, [workspace, handle]);
|
|
53241
|
+
const selectionKey = handle ? deriveSelectionKey(handle.decisions) : void 0;
|
|
53242
|
+
const subscribe = React.useCallback((cb) => {
|
|
53243
|
+
const unsubs = keys.flatMap((k2) => [staged.subscribe(k2, cb), cache3.subscribe(k2, cb)]);
|
|
53244
|
+
if (selectionKey !== void 0) unsubs.push(state.subscribe(selectionKey, cb));
|
|
53245
|
+
return () => {
|
|
53246
|
+
for (const u2 of unsubs) u2();
|
|
53247
|
+
};
|
|
53248
|
+
}, [staged, cache3, state, keys, selectionKey]);
|
|
53249
|
+
const getSnapshot = React.useCallback(
|
|
53250
|
+
() => keys.reduce((sum, k2) => sum + staged.getKeyVersion(k2) + cache3.getKeyVersion(k2), 0) + (selectionKey !== void 0 ? state.getKeyVersion(selectionKey) : 0),
|
|
53251
|
+
[staged, cache3, state, keys, selectionKey]
|
|
53252
|
+
);
|
|
53253
|
+
return React.useSyncExternalStore(subscribe, getSnapshot);
|
|
53254
|
+
}
|
|
53255
|
+
function useDecisionHandle(ref) {
|
|
53256
|
+
const version2 = useHandleVersion(ref);
|
|
53257
|
+
const fns = React.useMemo(
|
|
53258
|
+
() => ref ? buildDecisionHandle(
|
|
53259
|
+
[...ref.decisions],
|
|
53260
|
+
ref.judgements,
|
|
53261
|
+
eastUiComponents.getSomeorUndefined(ref.slice)
|
|
53262
|
+
) : null,
|
|
53263
|
+
[ref]
|
|
53264
|
+
);
|
|
53265
|
+
const { decisions, selected: selected2, journal } = React.useMemo(() => {
|
|
53266
|
+
try {
|
|
53267
|
+
if (!fns) return { decisions: null, selected: null, journal: null };
|
|
53268
|
+
const sel = fns.selected();
|
|
53269
|
+
return {
|
|
53270
|
+
decisions: fns.queue(),
|
|
53271
|
+
selected: sel.type === "some" ? sel.value : null,
|
|
53272
|
+
journal: fns.journal()
|
|
53273
|
+
};
|
|
53274
|
+
} catch {
|
|
53275
|
+
return { decisions: null, selected: null, journal: null };
|
|
53276
|
+
}
|
|
53277
|
+
}, [fns, version2]);
|
|
53278
|
+
const judgementFor = React.useCallback((caseId) => {
|
|
53279
|
+
try {
|
|
53280
|
+
return fns ? fns.judgement(caseId) : null;
|
|
53281
|
+
} catch {
|
|
53282
|
+
return null;
|
|
53283
|
+
}
|
|
53284
|
+
}, [fns, version2]);
|
|
53285
|
+
const commitStateFor = React.useCallback((caseId) => {
|
|
53286
|
+
try {
|
|
53287
|
+
return fns ? fns.commitState(caseId) : null;
|
|
53288
|
+
} catch {
|
|
53289
|
+
return null;
|
|
53290
|
+
}
|
|
53291
|
+
}, [fns, version2]);
|
|
53292
|
+
const select2 = React.useCallback((caseId) => {
|
|
53293
|
+
fns == null ? void 0 : fns.select(caseId);
|
|
53294
|
+
}, [fns]);
|
|
53295
|
+
const clearSelection = React.useCallback(() => {
|
|
53296
|
+
fns == null ? void 0 : fns.clearSelection();
|
|
53297
|
+
}, [fns]);
|
|
53298
|
+
const update2 = React.useCallback((next2) => {
|
|
53299
|
+
fns == null ? void 0 : fns.update(next2);
|
|
53300
|
+
}, [fns]);
|
|
53301
|
+
const answer = React.useCallback((caseId, promptId, response) => {
|
|
53302
|
+
fns == null ? void 0 : fns.answer(caseId, promptId, east.variant(response, null));
|
|
53303
|
+
}, [fns]);
|
|
53304
|
+
const addKnowledge = React.useCallback((caseId, text) => {
|
|
53305
|
+
fns == null ? void 0 : fns.addKnowledge(caseId, text);
|
|
53306
|
+
}, [fns]);
|
|
53307
|
+
const inject = React.useCallback((caseId, constraint) => {
|
|
53308
|
+
fns == null ? void 0 : fns.inject(caseId, constraint);
|
|
53309
|
+
}, [fns]);
|
|
53310
|
+
const resolve2 = React.useCallback((caseId, verdict) => {
|
|
53311
|
+
fns == null ? void 0 : fns.resolve(caseId, verdict);
|
|
53312
|
+
}, [fns]);
|
|
53313
|
+
return {
|
|
53314
|
+
decisions,
|
|
53315
|
+
selected: selected2,
|
|
53316
|
+
journal,
|
|
53317
|
+
judgementFor,
|
|
53318
|
+
commitStateFor,
|
|
53319
|
+
select: select2,
|
|
53320
|
+
clearSelection,
|
|
53321
|
+
update: update2,
|
|
53322
|
+
answer,
|
|
53323
|
+
addKnowledge,
|
|
53324
|
+
inject,
|
|
53325
|
+
resolve: resolve2,
|
|
53326
|
+
slice: fns ? fns.slice : null
|
|
53327
|
+
};
|
|
53328
|
+
}
|
|
53329
|
+
const OP_WORDS = {
|
|
53330
|
+
eq: "=",
|
|
53331
|
+
neq: "≠",
|
|
53332
|
+
atMost: "at most",
|
|
53333
|
+
atLeast: "at least",
|
|
53334
|
+
between: "between",
|
|
53335
|
+
before: "before",
|
|
53336
|
+
after: "after",
|
|
53337
|
+
in: "in",
|
|
53338
|
+
notIn: "not in",
|
|
53339
|
+
is: "is"
|
|
53340
|
+
};
|
|
53341
|
+
function formatScalar(v3) {
|
|
53342
|
+
if (v3 instanceof Date) {
|
|
53343
|
+
return `${v3.toLocaleString("en", { month: "short" })} ${v3.getDate()}`;
|
|
53344
|
+
}
|
|
53345
|
+
if (v3 instanceof Set) {
|
|
53346
|
+
return `{${[...v3].map(formatScalar).join(", ")}}`;
|
|
53347
|
+
}
|
|
53348
|
+
if (v3 !== null && typeof v3 === "object" && !v3.type) {
|
|
53349
|
+
return Object.entries(v3).map(([k2, x2]) => `${k2} ${formatScalar(x2)}`).join(" · ");
|
|
53350
|
+
}
|
|
53351
|
+
return String(v3);
|
|
53352
|
+
}
|
|
53353
|
+
function formatConstraint(constraint, payloadType, levers) {
|
|
53354
|
+
var _a2, _b;
|
|
53355
|
+
const c2 = constraint;
|
|
53356
|
+
const lever = ((_a2 = levers == null ? void 0 : levers.find((l2) => l2.case === c2.type)) == null ? void 0 : _a2.label) ?? c2.type;
|
|
53357
|
+
if ((payloadType == null ? void 0 : payloadType.type) === "Variant") {
|
|
53358
|
+
const op = c2.value;
|
|
53359
|
+
const word = OP_WORDS[op.type] ?? op.type;
|
|
53360
|
+
const opType = (_b = payloadType.cases) == null ? void 0 : _b[op.type];
|
|
53361
|
+
if ((opType == null ? void 0 : opType.type) === "Struct" && op.value !== null && typeof op.value === "object") {
|
|
53362
|
+
const r2 = op.value;
|
|
53363
|
+
if ("min" in r2 && "max" in r2) {
|
|
53364
|
+
return { lever, op: word, value: `${formatScalar(r2.min)} – ${formatScalar(r2.max)}` };
|
|
53365
|
+
}
|
|
53366
|
+
}
|
|
53367
|
+
return { lever, op: word, value: formatScalar(op.value) };
|
|
53368
|
+
}
|
|
53369
|
+
return { lever, op: "·", value: formatScalar(c2.value) };
|
|
53370
|
+
}
|
|
53371
|
+
const PRIMITIVES = /* @__PURE__ */ new Set(["String", "Integer", "Float", "DateTime", "Boolean"]);
|
|
53372
|
+
function normalizeTypeValue(tv) {
|
|
53373
|
+
var _a2;
|
|
53374
|
+
const n2 = tv;
|
|
53375
|
+
if (n2.cases !== void 0 || n2.fields !== void 0) {
|
|
53376
|
+
const out = { type: n2.type };
|
|
53377
|
+
if (n2.cases) out.cases = Object.fromEntries(Object.entries(n2.cases).map(([k2, v3]) => [k2, normalizeTypeValue(v3)]));
|
|
53378
|
+
if (n2.fields) out.fields = Object.fromEntries(Object.entries(n2.fields).map(([k2, v3]) => [k2, normalizeTypeValue(v3)]));
|
|
53379
|
+
if (n2.key) out.key = normalizeTypeValue(n2.key);
|
|
53380
|
+
if (n2.value !== void 0 && (n2.type === "Array" || n2.type === "Dict")) out.value = normalizeTypeValue(n2.value);
|
|
53381
|
+
return out;
|
|
53382
|
+
}
|
|
53383
|
+
switch (n2.type) {
|
|
53384
|
+
case "Struct":
|
|
53385
|
+
return { type: "Struct", fields: Object.fromEntries(n2.value.map((f2) => [f2.name, normalizeTypeValue(f2.type)])) };
|
|
53386
|
+
case "Variant":
|
|
53387
|
+
return { type: "Variant", cases: Object.fromEntries(n2.value.map((f2) => [f2.name, normalizeTypeValue(f2.type)])) };
|
|
53388
|
+
case "Array":
|
|
53389
|
+
return { type: "Array", value: normalizeTypeValue(n2.value) };
|
|
53390
|
+
case "Dict": {
|
|
53391
|
+
const d2 = n2.value;
|
|
53392
|
+
return { type: "Dict", key: normalizeTypeValue(d2.key), value: normalizeTypeValue(d2.value) };
|
|
53393
|
+
}
|
|
53394
|
+
case "Recursive": {
|
|
53395
|
+
const w2 = n2.value;
|
|
53396
|
+
if ((w2 == null ? void 0 : w2.type) === "wrapper" && ((_a2 = w2.value) == null ? void 0 : _a2.inner)) return normalizeTypeValue(w2.value.inner);
|
|
53397
|
+
return { type: n2.type };
|
|
53398
|
+
}
|
|
53399
|
+
default:
|
|
53400
|
+
return { type: n2.type };
|
|
53401
|
+
}
|
|
53402
|
+
}
|
|
53403
|
+
function emptyFor(node2) {
|
|
53404
|
+
switch (node2.type) {
|
|
53405
|
+
case "Integer":
|
|
53406
|
+
return 0n;
|
|
53407
|
+
case "Float":
|
|
53408
|
+
return 0;
|
|
53409
|
+
case "DateTime":
|
|
53410
|
+
return /* @__PURE__ */ new Date();
|
|
53411
|
+
case "Boolean":
|
|
53412
|
+
return false;
|
|
53413
|
+
case "String":
|
|
53414
|
+
return "";
|
|
53415
|
+
case "Struct":
|
|
53416
|
+
return Object.fromEntries(Object.entries(node2.fields ?? {}).map(([k2, f2]) => [k2, emptyFor(f2)]));
|
|
53417
|
+
default:
|
|
53418
|
+
return null;
|
|
53419
|
+
}
|
|
53420
|
+
}
|
|
53421
|
+
function leverPayloadEditable(node2) {
|
|
53422
|
+
if (!node2) return false;
|
|
53423
|
+
if (PRIMITIVES.has(node2.type)) return true;
|
|
53424
|
+
if (node2.type === "Struct") return Object.values(node2.fields ?? {}).every((f2) => PRIMITIVES.has(f2.type));
|
|
53425
|
+
if (node2.type === "Variant") return Object.values(node2.cases ?? {}).every((c2) => PRIMITIVES.has(c2.type) || c2.type === "Struct" && Object.values(c2.fields ?? {}).every((f2) => PRIMITIVES.has(f2.type)));
|
|
53426
|
+
return false;
|
|
53427
|
+
}
|
|
53428
|
+
const inputStyle = east.some({ size: east.some(east.variant("sm", null)) });
|
|
53429
|
+
function LeverEditor({ leverCase, payload, onInject }) {
|
|
53430
|
+
var _a2;
|
|
53431
|
+
const button = react.useRecipe({ key: "button" });
|
|
53432
|
+
const isOpVariant = payload.type === "Variant";
|
|
53433
|
+
const ops = React.useMemo(() => isOpVariant ? Object.keys(payload.cases ?? {}) : [], [isOpVariant, payload]);
|
|
53434
|
+
const [opTag, setOpTag] = React.useState(ops[0] ?? "");
|
|
53435
|
+
const active = isOpVariant ? ((_a2 = payload.cases) == null ? void 0 : _a2[opTag]) ?? { type: "Null" } : payload;
|
|
53436
|
+
const valRef = React.useRef(emptyFor(active));
|
|
53437
|
+
const keyRef = React.useRef(`${leverCase}:${opTag}`);
|
|
53438
|
+
if (keyRef.current !== `${leverCase}:${opTag}`) {
|
|
53439
|
+
keyRef.current = `${leverCase}:${opTag}`;
|
|
53440
|
+
valRef.current = emptyFor(active);
|
|
53441
|
+
}
|
|
53442
|
+
const primitiveInput = (node2, key, get3, set3) => {
|
|
53443
|
+
switch (node2.type) {
|
|
53444
|
+
case "Integer":
|
|
53445
|
+
return /* @__PURE__ */ jsxRuntime.jsx(eastUiComponents.EastChakraIntegerInput, { value: { value: get3(), onChange: east.some(set3), style: inputStyle } }, key);
|
|
53446
|
+
case "Float":
|
|
53447
|
+
return /* @__PURE__ */ jsxRuntime.jsx(eastUiComponents.EastChakraFloatInput, { value: { value: get3(), onChange: east.some(set3), style: inputStyle } }, key);
|
|
53448
|
+
case "DateTime":
|
|
53449
|
+
return /* @__PURE__ */ jsxRuntime.jsx(eastUiComponents.EastChakraDateTimeInput, { value: { value: get3(), onChange: east.some(set3), style: inputStyle } }, key);
|
|
53450
|
+
case "Boolean":
|
|
53451
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
53452
|
+
eastUiComponents.EastChakraSelect,
|
|
53453
|
+
{
|
|
53454
|
+
ariaLabel: key,
|
|
53455
|
+
value: {
|
|
53456
|
+
value: east.some(String(get3())),
|
|
53457
|
+
items: [{ value: "true", label: "true", disabled: east.none }, { value: "false", label: "false", disabled: east.none }],
|
|
53458
|
+
placeholder: east.none,
|
|
53459
|
+
multiple: east.none,
|
|
53460
|
+
disabled: east.none,
|
|
53461
|
+
onChange: east.some((v3) => set3(v3 === "true")),
|
|
53462
|
+
onChangeMultiple: east.none,
|
|
53463
|
+
onOpenChange: east.none,
|
|
53464
|
+
style: inputStyle
|
|
53465
|
+
}
|
|
53466
|
+
},
|
|
53467
|
+
key
|
|
53468
|
+
);
|
|
53469
|
+
default:
|
|
53470
|
+
return /* @__PURE__ */ jsxRuntime.jsx(eastUiComponents.EastChakraStringInput, { value: { value: String(get3() ?? ""), onChange: east.some(set3), style: inputStyle } }, key);
|
|
53471
|
+
}
|
|
53472
|
+
};
|
|
53473
|
+
const valueControls = React.useMemo(() => {
|
|
53474
|
+
const k2 = keyRef.current;
|
|
53475
|
+
if (active.type === "Struct") {
|
|
53476
|
+
return Object.entries(active.fields ?? {}).map(([field, node2]) => /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", alignItems: "center", gap: "6px", minW: 0, children: [
|
|
53477
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { as: "span", textStyle: "caption.eyebrow", color: "fg.subtle", flexShrink: 0, children: field }),
|
|
53478
|
+
primitiveInput(
|
|
53479
|
+
node2,
|
|
53480
|
+
`${k2}.${field}.in`,
|
|
53481
|
+
() => valRef.current[field],
|
|
53482
|
+
(v3) => {
|
|
53483
|
+
valRef.current[field] = v3;
|
|
53484
|
+
}
|
|
53485
|
+
)
|
|
53486
|
+
] }, `${k2}.${field}`));
|
|
53487
|
+
}
|
|
53488
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { width: "180px", flexShrink: 0, children: primitiveInput(active, `${k2}.value`, () => valRef.current, (v3) => {
|
|
53489
|
+
valRef.current = v3;
|
|
53490
|
+
}) }, `${k2}.wrap`);
|
|
53491
|
+
}, [active, opTag, leverCase]);
|
|
53492
|
+
const submit = () => {
|
|
53493
|
+
const value = valRef.current;
|
|
53494
|
+
const payloadValue = active.type === "Struct" ? { ...value } : value;
|
|
53495
|
+
const constraint = isOpVariant ? east.variant(leverCase, east.variant(opTag, payloadValue)) : east.variant(leverCase, payloadValue);
|
|
53496
|
+
onInject(constraint);
|
|
53497
|
+
valRef.current = emptyFor(active);
|
|
53498
|
+
};
|
|
53499
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
53500
|
+
react.Box,
|
|
53501
|
+
{
|
|
53502
|
+
display: "flex",
|
|
53503
|
+
alignItems: "center",
|
|
53504
|
+
gap: "8px",
|
|
53505
|
+
flexWrap: "wrap",
|
|
53506
|
+
minW: 0,
|
|
53507
|
+
css: {
|
|
53508
|
+
"& [data-scope=select][data-part=root]": { width: "auto", minWidth: "110px", flexShrink: 0 },
|
|
53509
|
+
"& [data-scope=number-input][data-part=root]": { width: "150px", flexShrink: 0 }
|
|
53510
|
+
},
|
|
53511
|
+
children: [
|
|
53512
|
+
isOpVariant && /* @__PURE__ */ jsxRuntime.jsx(
|
|
53513
|
+
eastUiComponents.EastChakraSelect,
|
|
53514
|
+
{
|
|
53515
|
+
ariaLabel: "Operator",
|
|
53516
|
+
value: {
|
|
53517
|
+
value: east.some(opTag),
|
|
53518
|
+
items: ops.map((o2) => ({ value: o2, label: OP_WORDS[o2] ?? o2, disabled: east.none })),
|
|
53519
|
+
placeholder: east.none,
|
|
53520
|
+
multiple: east.none,
|
|
53521
|
+
disabled: east.none,
|
|
53522
|
+
onChange: east.some((v3) => setOpTag(v3)),
|
|
53523
|
+
onChangeMultiple: east.none,
|
|
53524
|
+
onOpenChange: east.none,
|
|
53525
|
+
style: inputStyle
|
|
53526
|
+
}
|
|
53527
|
+
}
|
|
53528
|
+
),
|
|
53529
|
+
valueControls,
|
|
53530
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.chakra.button, { type: "button", css: button({ variant: "solid", size: "xs" }), onClick: submit, children: "Add" })
|
|
53531
|
+
]
|
|
53532
|
+
}
|
|
53533
|
+
);
|
|
53534
|
+
}
|
|
53535
|
+
function fmt(d2, n2, showSign = false) {
|
|
53536
|
+
return eastUiComponents.formatTick(n2, eastUiComponents.getSomeorUndefined(d2.format), showSign);
|
|
53537
|
+
}
|
|
53538
|
+
const caption = { textStyle: "caption.eyebrow", color: "fg.muted" };
|
|
53539
|
+
const EvidenceFacet = React.memo(function EvidenceFacet2({ decision, children: children2 }) {
|
|
53540
|
+
const stakes = eastUiComponents.getSomeorUndefined(decision.stakes);
|
|
53541
|
+
const downside = eastUiComponents.getSomeorUndefined(decision.downside);
|
|
53542
|
+
const confidence = eastUiComponents.getSomeorUndefined(decision.confidence);
|
|
53543
|
+
const detail = eastUiComponents.getSomeorUndefined(decision.detail);
|
|
53544
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", flexDirection: "column", gap: "10px", children: [
|
|
53545
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", alignItems: "baseline", gap: "12px", flexWrap: "wrap", children: [
|
|
53546
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, color: "fg", children: "Why this is recommended" }),
|
|
53547
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Text, { ...caption, children: [
|
|
53548
|
+
stakes !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53549
|
+
"stakes ",
|
|
53550
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontFamily: "mono", fontWeight: "semibold", children: stakes.type }),
|
|
53551
|
+
" · "
|
|
53552
|
+
] }),
|
|
53553
|
+
downside !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53554
|
+
"if wrong ",
|
|
53555
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontFamily: "mono", fontWeight: "semibold", color: "fg.danger", children: fmt(decision, downside, true) }),
|
|
53556
|
+
" · "
|
|
53557
|
+
] }),
|
|
53558
|
+
confidence !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53559
|
+
"confidence ",
|
|
53560
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Text, { as: "span", fontFamily: "mono", fontWeight: "semibold", children: [
|
|
53561
|
+
Math.round(confidence * 100),
|
|
53562
|
+
"%"
|
|
53563
|
+
] })
|
|
53564
|
+
] })
|
|
53565
|
+
] })
|
|
53566
|
+
] }),
|
|
53567
|
+
detail !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "12.5px", color: "fg.muted", children: detail }),
|
|
53568
|
+
decision.evidence.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(react.Box, { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(180px, 1fr))", gap: "8px", children: decision.evidence.map((e2, i) => {
|
|
53569
|
+
const note = eastUiComponents.getSomeorUndefined(e2.note);
|
|
53570
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { borderWidth: "1px", borderColor: "border.subtle", borderRadius: "4px", px: "10px", py: "8px", bg: "bg.canvas", children: [
|
|
53571
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, children: e2.label }),
|
|
53572
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "13px", fontWeight: "medium", children: e2.text }),
|
|
53573
|
+
note !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "11px", fontFamily: "mono", color: "fg.subtle", children: note })
|
|
53574
|
+
] }, i);
|
|
53575
|
+
}) }),
|
|
53576
|
+
children2
|
|
53577
|
+
] });
|
|
53578
|
+
});
|
|
53579
|
+
function rankOptions(d2) {
|
|
53580
|
+
const alternatives = [...d2.alternatives].sort((a2, b2) => b2.value - a2.value).map((a2) => ({
|
|
53581
|
+
label: a2.label,
|
|
53582
|
+
value: a2.value,
|
|
53583
|
+
downside: eastUiComponents.getSomeorUndefined(a2.downside),
|
|
53584
|
+
confidence: eastUiComponents.getSomeorUndefined(a2.confidence),
|
|
53585
|
+
note: eastUiComponents.getSomeorUndefined(a2.note),
|
|
53586
|
+
recommended: false
|
|
53587
|
+
}));
|
|
53588
|
+
return [
|
|
53589
|
+
{
|
|
53590
|
+
label: d2.title,
|
|
53591
|
+
value: d2.value,
|
|
53592
|
+
downside: eastUiComponents.getSomeorUndefined(d2.downside),
|
|
53593
|
+
confidence: eastUiComponents.getSomeorUndefined(d2.confidence),
|
|
53594
|
+
note: eastUiComponents.getSomeorUndefined(d2.summary),
|
|
53595
|
+
recommended: true
|
|
53596
|
+
},
|
|
53597
|
+
...alternatives
|
|
53598
|
+
].map((o2, i) => ({ ...o2, rank: i + 1 }));
|
|
53599
|
+
}
|
|
53600
|
+
function metaLine(o2) {
|
|
53601
|
+
const parts = [];
|
|
53602
|
+
if (o2.recommended) parts.push("recommended");
|
|
53603
|
+
if (o2.confidence !== void 0) parts.push(`${Math.round(o2.confidence * 100)}% conf`);
|
|
53604
|
+
if (!o2.recommended && o2.note !== void 0) parts.push(o2.note);
|
|
53605
|
+
return parts.join(" · ");
|
|
53606
|
+
}
|
|
53607
|
+
const OptionsFacet = React.memo(function OptionsFacet2({ decision, narrow }) {
|
|
53608
|
+
const options2 = rankOptions(decision);
|
|
53609
|
+
const maxUp = Math.max(...options2.map((o2) => Math.max(o2.value, 0)), 1e-9);
|
|
53610
|
+
const maxDown = Math.max(...options2.map((o2) => Math.abs(o2.downside ?? 0)), 1e-9);
|
|
53611
|
+
if (narrow) {
|
|
53612
|
+
const meter = (label, frac, display, tone) => /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "grid", gridTemplateColumns: "80px 1fr 64px", alignItems: "center", gap: "8px", children: [
|
|
53613
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, whiteSpace: "nowrap", children: label }),
|
|
53614
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { height: "6px", bg: "border.subtle", borderRadius: "3px", overflow: "hidden", children: /* @__PURE__ */ jsxRuntime.jsx(react.Box, { height: "100%", width: `${Math.round(Math.min(Math.abs(frac), 1) * 100)}%`, bg: tone === "success" ? "fg.success" : tone === "danger" ? "fg.danger" : "fg.subtle", opacity: 0.7 }) }),
|
|
53615
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "11px", fontFamily: "mono", fontWeight: "semibold", textAlign: "right", children: display })
|
|
53616
|
+
] });
|
|
53617
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", flexDirection: "column", gap: "10px", children: [
|
|
53618
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Text, { ...caption, color: "fg", children: [
|
|
53619
|
+
"Options · ",
|
|
53620
|
+
options2.length,
|
|
53621
|
+
" evaluated"
|
|
53622
|
+
] }),
|
|
53623
|
+
options2.map((o2) => /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", flexDirection: "column", gap: "4px", pl: "8px", ...o2.recommended ? { boxShadow: "inset 2px 0 0 var(--chakra-colors-accent-brand)" } : {}, children: [
|
|
53624
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Text, { fontSize: "12.5px", children: [
|
|
53625
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontFamily: "mono", color: "fg.subtle", children: o2.rank }),
|
|
53626
|
+
" ",
|
|
53627
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontWeight: o2.recommended ? "semibold" : "normal", children: o2.label })
|
|
53628
|
+
] }),
|
|
53629
|
+
meter("Uplift", o2.value / maxUp, fmt(decision, o2.value, true), "success"),
|
|
53630
|
+
meter("If wrong", (o2.downside ?? 0) / maxDown, o2.downside !== void 0 ? fmt(decision, o2.downside, true) : "—", "danger")
|
|
53631
|
+
] }, o2.rank))
|
|
53632
|
+
] });
|
|
53633
|
+
}
|
|
53634
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", flexDirection: "column", gap: "6px", children: [
|
|
53635
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "grid", gridTemplateColumns: "minmax(180px, 1.1fr) 1fr 1fr", alignItems: "baseline", gap: "8px", children: [
|
|
53636
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Text, { ...caption, color: "fg", children: [
|
|
53637
|
+
"Options · ",
|
|
53638
|
+
options2.length,
|
|
53639
|
+
" evaluated"
|
|
53640
|
+
] }),
|
|
53641
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, textAlign: "center", children: "If wrong" }),
|
|
53642
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, textAlign: "right", children: "Uplift" })
|
|
53643
|
+
] }),
|
|
53644
|
+
options2.map((o2) => {
|
|
53645
|
+
const downFrac = Math.min(Math.abs(o2.downside ?? 0) / maxDown, 1);
|
|
53646
|
+
const upFrac = Math.min(Math.max(o2.value, 0) / maxUp, 1);
|
|
53647
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
53648
|
+
react.Box,
|
|
53649
|
+
{
|
|
53650
|
+
display: "grid",
|
|
53651
|
+
gridTemplateColumns: "minmax(180px, 1.1fr) 1fr 1fr",
|
|
53652
|
+
alignItems: "center",
|
|
53653
|
+
gap: "8px",
|
|
53654
|
+
py: "4px",
|
|
53655
|
+
...o2.recommended ? { bg: "bg.brand.subtle", boxShadow: "inset 2px 0 0 var(--chakra-colors-accent-brand)" } : {},
|
|
53656
|
+
children: [
|
|
53657
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { minW: 0, pl: o2.recommended ? "6px" : "0", display: "flex", alignItems: "baseline", gap: "6px", children: [
|
|
53658
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontFamily: "mono", fontSize: "11px", color: "fg.subtle", flexShrink: 0, children: o2.rank }),
|
|
53659
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontSize: "12.5px", fontWeight: o2.recommended ? "semibold" : "normal", flexShrink: 0, children: o2.label }),
|
|
53660
|
+
metaLine(o2) !== "" && /* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontFamily: "mono", fontSize: "10.5px", color: "fg.muted", minW: 0, truncate: true, children: metaLine(o2) })
|
|
53661
|
+
] }),
|
|
53662
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { display: "flex", justifyContent: "flex-end", alignItems: "center", gap: "6px", height: "16px", children: o2.downside !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53663
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "10.5px", fontFamily: "mono", color: "fg.danger", flexShrink: 0, children: fmt(decision, o2.downside, true) }),
|
|
53664
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { height: "12px", width: `${Math.round(downFrac * 100)}%`, bg: "fg.danger", opacity: 0.55 })
|
|
53665
|
+
] }) }),
|
|
53666
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { display: "flex", alignItems: "center", gap: "6px", height: "16px", borderLeftWidth: "1px", borderColor: "border.strong", children: o2.value > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53667
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { height: "12px", width: `${Math.round(upFrac * 100)}%`, bg: "fg.success", opacity: 0.6 }),
|
|
53668
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "10.5px", fontFamily: "mono", color: "fg.success", flexShrink: 0, children: fmt(decision, o2.value, true) })
|
|
53669
|
+
] }) })
|
|
53670
|
+
]
|
|
53671
|
+
},
|
|
53672
|
+
o2.rank
|
|
53673
|
+
);
|
|
53674
|
+
})
|
|
53675
|
+
] });
|
|
53676
|
+
});
|
|
53677
|
+
const ANSWERS = [
|
|
53678
|
+
{ literal: "yes", label: "Yes" },
|
|
53679
|
+
{ literal: "no", label: "No" },
|
|
53680
|
+
{ literal: "unknown", label: "Don't know" }
|
|
53681
|
+
];
|
|
53682
|
+
const JudgementFacet = React.memo(function JudgementFacet2({ decision, handle, leverPayloads }) {
|
|
53683
|
+
var _a2;
|
|
53684
|
+
const button = react.useRecipe({ key: "button" });
|
|
53685
|
+
const input = react.useRecipe({ key: "input" });
|
|
53686
|
+
const judgement = handle.judgementFor(decision.id);
|
|
53687
|
+
const stagedKnowledge = (judgement == null ? void 0 : judgement.knowledge.type) === "some" ? judgement.knowledge.value : "";
|
|
53688
|
+
const [knowledge, setKnowledge] = React.useState(stagedKnowledge);
|
|
53689
|
+
React.useEffect(() => {
|
|
53690
|
+
setKnowledge(stagedKnowledge);
|
|
53691
|
+
}, [stagedKnowledge]);
|
|
53692
|
+
const commitKnowledge = React.useCallback(() => {
|
|
53693
|
+
if (knowledge !== stagedKnowledge) handle.addKnowledge(decision.id, knowledge);
|
|
53694
|
+
}, [knowledge, stagedKnowledge, handle, decision.id]);
|
|
53695
|
+
const levers = React.useMemo(
|
|
53696
|
+
() => decision.levers.filter((l2) => leverPayloadEditable(leverPayloads[l2.case])),
|
|
53697
|
+
[decision.levers, leverPayloads]
|
|
53698
|
+
);
|
|
53699
|
+
const [leverCase, setLeverCase] = React.useState(((_a2 = levers[0]) == null ? void 0 : _a2.case) ?? "");
|
|
53700
|
+
const activeLever = levers.find((l2) => l2.case === leverCase) ?? levers[0];
|
|
53701
|
+
const gate = handle.commitStateFor(decision.id);
|
|
53702
|
+
const gateHint = (gate == null ? void 0 : gate.type) === "gated" ? gate.value === 1n ? "Answer the judgement question to enable apply" : `Answer the ${gate.value} judgement questions to enable apply` : (gate == null ? void 0 : gate.type) === "blocked" ? "Commit blocked — an answer contradicts the recommendation" : (gate == null ? void 0 : gate.type) === "handoff" ? "Awaiting handoff — an answer was don't know" : null;
|
|
53703
|
+
const onInject = React.useCallback((constraint) => {
|
|
53704
|
+
handle.inject(decision.id, constraint);
|
|
53705
|
+
}, [handle, decision.id]);
|
|
53706
|
+
if (!judgement) return null;
|
|
53707
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", flexDirection: "column", gap: "10px", children: [
|
|
53708
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", alignItems: "baseline", gap: "12px", children: [
|
|
53709
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, color: "fg.warning", children: "Required before commit" }),
|
|
53710
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, marginLeft: "auto", children: "human-only signal · model can’t see this" })
|
|
53711
|
+
] }),
|
|
53712
|
+
decision.prompts.map((prompt) => {
|
|
53713
|
+
var _a3;
|
|
53714
|
+
const current = (_a3 = judgement.answers.get(prompt.id)) == null ? void 0 : _a3.type;
|
|
53715
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", alignItems: "center", gap: "12px", flexWrap: "wrap", children: [
|
|
53716
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontSize: "13px", fontWeight: "medium", flex: "1", minW: "180px", children: prompt.text }),
|
|
53717
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { display: "flex", gap: "6px", flexShrink: 0, children: ANSWERS.map((a2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
53718
|
+
react.chakra.button,
|
|
53719
|
+
{
|
|
53720
|
+
type: "button",
|
|
53721
|
+
css: button({ variant: current === a2.literal ? "solid" : "outline", size: "xs" }),
|
|
53722
|
+
onClick: () => handle.answer(decision.id, prompt.id, a2.literal),
|
|
53723
|
+
children: a2.label
|
|
53724
|
+
},
|
|
53725
|
+
a2.literal
|
|
53726
|
+
)) })
|
|
53727
|
+
] }, prompt.id);
|
|
53728
|
+
}),
|
|
53729
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", flexDirection: "column", gap: "4px", children: [
|
|
53730
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, children: "Knowledge · what the model can’t see" }),
|
|
53731
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
53732
|
+
react.chakra.textarea,
|
|
53733
|
+
{
|
|
53734
|
+
css: input({ size: "sm" }),
|
|
53735
|
+
rows: 2,
|
|
53736
|
+
value: knowledge,
|
|
53737
|
+
placeholder: "Private context — persists with the case",
|
|
53738
|
+
onChange: (e2) => setKnowledge(e2.target.value),
|
|
53739
|
+
onBlur: commitKnowledge
|
|
53740
|
+
}
|
|
53741
|
+
)
|
|
53742
|
+
] }),
|
|
53743
|
+
(levers.length > 0 || judgement.constraints.length > 0) && /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", flexDirection: "column", gap: "6px", children: [
|
|
53744
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, children: "Inject constraint · next run folds it in" }),
|
|
53745
|
+
judgement.constraints.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(react.Box, { display: "flex", gap: "12px", flexWrap: "wrap", children: judgement.constraints.map((c2, i) => {
|
|
53746
|
+
const tag = c2.type;
|
|
53747
|
+
const f2 = formatConstraint(c2, leverPayloads[tag], decision.levers);
|
|
53748
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Text, { as: "span", fontFamily: "mono", fontSize: "11px", children: [
|
|
53749
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", color: "accent.brand", fontWeight: "semibold", children: f2.lever }),
|
|
53750
|
+
" ",
|
|
53751
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", color: "fg.subtle", children: f2.op }),
|
|
53752
|
+
" ",
|
|
53753
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontWeight: "semibold", children: f2.value })
|
|
53754
|
+
] }, i);
|
|
53755
|
+
}) }),
|
|
53756
|
+
activeLever !== void 0 && /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", alignItems: "center", gap: "8px", flexWrap: "wrap", children: [
|
|
53757
|
+
levers.length > 1 ? /* @__PURE__ */ jsxRuntime.jsx(react.Box, { flexShrink: 0, css: { "& [data-scope=select][data-part=root]": { width: "auto", minWidth: "160px" } }, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
53758
|
+
eastUiComponents.EastChakraSelect,
|
|
53759
|
+
{
|
|
53760
|
+
ariaLabel: "Lever",
|
|
53761
|
+
value: {
|
|
53762
|
+
value: east.some(activeLever.case),
|
|
53763
|
+
items: levers.map((l2) => ({ value: l2.case, label: l2.label, disabled: east.none })),
|
|
53764
|
+
placeholder: east.none,
|
|
53765
|
+
multiple: east.none,
|
|
53766
|
+
disabled: east.none,
|
|
53767
|
+
onChange: east.some((v3) => setLeverCase(v3)),
|
|
53768
|
+
onChangeMultiple: east.none,
|
|
53769
|
+
onOpenChange: east.none,
|
|
53770
|
+
style: east.some({ size: east.some(east.variant("sm", null)) })
|
|
53771
|
+
}
|
|
53772
|
+
}
|
|
53773
|
+
) }) : /* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, color: "fg", flexShrink: 0, children: activeLever.label }),
|
|
53774
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { flex: "1", minW: "260px", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
53775
|
+
LeverEditor,
|
|
53776
|
+
{
|
|
53777
|
+
leverCase: activeLever.case,
|
|
53778
|
+
payload: leverPayloads[activeLever.case],
|
|
53779
|
+
onInject
|
|
53780
|
+
},
|
|
53781
|
+
activeLever.case
|
|
53782
|
+
) })
|
|
53783
|
+
] })
|
|
53784
|
+
] }),
|
|
53785
|
+
gateHint !== null && /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", alignItems: "center", gap: "8px", pt: "4px", children: [
|
|
53786
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { width: "7px", height: "7px", borderRadius: "full", bg: "fg.warning", flexShrink: 0 }),
|
|
53787
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { ...caption, children: gateHint }),
|
|
53788
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
53789
|
+
react.chakra.button,
|
|
53790
|
+
{
|
|
53791
|
+
type: "button",
|
|
53792
|
+
css: button({ variant: "outline", size: "xs" }),
|
|
53793
|
+
marginLeft: "auto",
|
|
53794
|
+
onClick: () => handle.resolve(decision.id, east.variant("deferred", east.none)),
|
|
53795
|
+
children: "Defer"
|
|
53796
|
+
}
|
|
53797
|
+
)
|
|
53798
|
+
] })
|
|
53799
|
+
] });
|
|
53800
|
+
});
|
|
53801
|
+
const URGENCY_RANK = {
|
|
53802
|
+
overdue: 0,
|
|
53803
|
+
due: 1,
|
|
53804
|
+
routine: 2
|
|
53805
|
+
};
|
|
53806
|
+
const FACETS = [
|
|
53807
|
+
{ key: "evidence", label: "Evidence" },
|
|
53808
|
+
{ key: "options", label: "Options" },
|
|
53809
|
+
{ key: "judgement", label: "Judgement" },
|
|
53810
|
+
{ key: "modify", label: "Modify" }
|
|
53811
|
+
];
|
|
53812
|
+
const URGENCY_TONE = {
|
|
53813
|
+
overdue: "danger",
|
|
53814
|
+
due: "warning",
|
|
53815
|
+
routine: "neutral"
|
|
53816
|
+
};
|
|
53817
|
+
const EXIT_MS = 560;
|
|
53818
|
+
const NARROW_PX = 560;
|
|
53819
|
+
function decisionValue(d2, n2, showSign = false) {
|
|
53820
|
+
return eastUiComponents.formatTick(n2, eastUiComponents.getSomeorUndefined(d2.format), showSign);
|
|
53821
|
+
}
|
|
53822
|
+
function deadlineSuffix(d2) {
|
|
53823
|
+
const deadline = eastUiComponents.getSomeorUndefined(d2.deadline);
|
|
53824
|
+
if (deadline === void 0) return "";
|
|
53825
|
+
if (d2.urgency.type === "overdue") {
|
|
53826
|
+
const hours = Math.round((Date.now() - deadline.getTime()) / 36e5);
|
|
53827
|
+
if (hours < 1) return " <1h";
|
|
53828
|
+
if (hours < 48) return ` ${hours}h`;
|
|
53829
|
+
return ` ${Math.round(hours / 24)}d`;
|
|
53830
|
+
}
|
|
53831
|
+
if (d2.urgency.type === "due") {
|
|
53832
|
+
const h2 = deadline.getHours();
|
|
53833
|
+
const m2 = deadline.getMinutes();
|
|
53834
|
+
const meridiem = h2 >= 12 ? "pm" : "am";
|
|
53835
|
+
const clock2 = h2 % 12 === 0 ? 12 : h2 % 12;
|
|
53836
|
+
return m2 === 0 ? ` ${clock2}${meridiem}` : ` ${clock2}:${String(m2).padStart(2, "0")}${meridiem}`;
|
|
53837
|
+
}
|
|
53838
|
+
return "";
|
|
53839
|
+
}
|
|
53840
|
+
function useLeverPayloads(ref) {
|
|
53841
|
+
const cache3 = getReactiveDatasetCache();
|
|
53842
|
+
const workspace = cache3.getConfig().workspace ?? "";
|
|
53843
|
+
return React.useMemo(() => {
|
|
53844
|
+
var _a2, _b, _c;
|
|
53845
|
+
if (!ref) return {};
|
|
53846
|
+
const judgements = getBindingTypes(workspace, ref.judgements.source);
|
|
53847
|
+
if (!(judgements == null ? void 0 : judgements.sourceType)) return {};
|
|
53848
|
+
const root2 = normalizeTypeValue(judgements.sourceType);
|
|
53849
|
+
const constraint = (_c = (_b = (_a2 = root2.value) == null ? void 0 : _a2.fields) == null ? void 0 : _b["constraints"]) == null ? void 0 : _c.value;
|
|
53850
|
+
return (constraint == null ? void 0 : constraint.type) === "Variant" ? constraint.cases ?? {} : {};
|
|
53851
|
+
}, [ref, workspace]);
|
|
53852
|
+
}
|
|
53853
|
+
const Row = React.memo(function Row2({ decision, handle, selected: selected2, narrow, leverPayloads, modify, detail, defaultFacet, apply: apply2, reject: reject2, leaving, storageKey }) {
|
|
53854
|
+
const dq = react.useSlotRecipe({ key: "decisionQueue" });
|
|
53855
|
+
const status = react.useSlotRecipe({ key: "status" });
|
|
53856
|
+
const tabs = react.useSlotRecipe({ key: "facetTabs" });
|
|
53857
|
+
const button = react.useRecipe({ key: "button" });
|
|
53858
|
+
const rs = dq({});
|
|
53859
|
+
const ts = tabs({});
|
|
53860
|
+
const st = status({ status: URGENCY_TONE[decision.urgency.type], size: "md" });
|
|
53861
|
+
const [facet, setFacet] = React.useState(defaultFacet);
|
|
53862
|
+
React.useEffect(() => {
|
|
53863
|
+
if (!selected2) setFacet(defaultFacet);
|
|
53864
|
+
}, [selected2, defaultFacet]);
|
|
53865
|
+
const gate = handle.commitStateFor(decision.id);
|
|
53866
|
+
const applyEnabled = gate === null || gate.type === "ready";
|
|
53867
|
+
const gatePulse = !applyEnabled && decision.prompts.length > 0;
|
|
53868
|
+
const summary = eastUiComponents.getSomeorUndefined(decision.summary);
|
|
53869
|
+
const handleSelect = React.useCallback(() => {
|
|
53870
|
+
if (!selected2) handle.select(decision.id);
|
|
53871
|
+
}, [selected2, handle, decision.id]);
|
|
53872
|
+
const handleApply = React.useCallback(() => {
|
|
53873
|
+
if (applyEnabled) apply2(decision);
|
|
53874
|
+
}, [applyEnabled, apply2, decision]);
|
|
53875
|
+
const handleReject = React.useCallback(() => {
|
|
53876
|
+
reject2(decision);
|
|
53877
|
+
}, [reject2, decision]);
|
|
53878
|
+
const probe = React.useMemo(() => {
|
|
53879
|
+
if (!selected2 || facet !== "modify" || !modify) return null;
|
|
53880
|
+
return modify(decision, handle.update);
|
|
53881
|
+
}, [selected2, facet, modify, decision, handle.update]);
|
|
53882
|
+
const canvas = React.useMemo(() => {
|
|
53883
|
+
if (!selected2 || facet !== "evidence" || !detail) return null;
|
|
53884
|
+
return detail(decision);
|
|
53885
|
+
}, [selected2, facet, detail, decision]);
|
|
53886
|
+
const facetTabs = /* @__PURE__ */ jsxRuntime.jsx(react.Box, { css: ts.root, ...narrow ? { display: "flex", width: "100%" } : {}, children: FACETS.filter((f2) => f2.key !== "modify" || modify !== void 0).map((f2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
53887
|
+
react.Box,
|
|
53888
|
+
{
|
|
53889
|
+
as: "button",
|
|
53890
|
+
css: ts.tab,
|
|
53891
|
+
...narrow ? { flex: 1 } : {},
|
|
53892
|
+
...facet === f2.key ? { "data-on": "" } : {},
|
|
53893
|
+
...f2.key === "judgement" && gatePulse ? { "data-pulse": "" } : {},
|
|
53894
|
+
"aria-pressed": facet === f2.key,
|
|
53895
|
+
onClick: () => setFacet(f2.key),
|
|
53896
|
+
children: f2.label
|
|
53897
|
+
},
|
|
53898
|
+
f2.key
|
|
53899
|
+
)) });
|
|
53900
|
+
const commands = /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", gap: "6px", ...narrow ? { justifyContent: "flex-end" } : {}, children: [
|
|
53901
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
53902
|
+
react.Box,
|
|
53903
|
+
{
|
|
53904
|
+
as: "button",
|
|
53905
|
+
css: button({ variant: "solid", size: "xs" }),
|
|
53906
|
+
"aria-disabled": !applyEnabled,
|
|
53907
|
+
opacity: applyEnabled ? void 0 : 0.5,
|
|
53908
|
+
cursor: applyEnabled ? void 0 : "not-allowed",
|
|
53909
|
+
title: applyEnabled ? void 0 : "Answer the judgement to enable apply",
|
|
53910
|
+
onClick: handleApply,
|
|
53911
|
+
children: "Apply"
|
|
53912
|
+
}
|
|
53913
|
+
),
|
|
53914
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { as: "button", css: button({ variant: "ghost", size: "xs" }), onClick: handleReject, children: "Reject" })
|
|
53915
|
+
] });
|
|
53916
|
+
const title = /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { minW: 0, cursor: selected2 ? void 0 : "pointer", onClick: handleSelect, children: [
|
|
53917
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontWeight: "semibold", children: decision.kind }),
|
|
53918
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", color: "fg.subtle", children: " · " }),
|
|
53919
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", children: decision.title }),
|
|
53920
|
+
summary !== void 0 && !narrow && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53921
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", color: "fg.subtle", children: " · " }),
|
|
53922
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", color: "fg.muted", children: summary })
|
|
53923
|
+
] })
|
|
53924
|
+
] });
|
|
53925
|
+
const urgency = /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { as: "span", css: st.root, flexShrink: 0, children: [
|
|
53926
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { as: "span", css: st.indicator }),
|
|
53927
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { as: "span", css: st.label, children: [
|
|
53928
|
+
decision.urgency.type,
|
|
53929
|
+
deadlineSuffix(decision)
|
|
53930
|
+
] })
|
|
53931
|
+
] });
|
|
53932
|
+
const valueText = /* @__PURE__ */ jsxRuntime.jsx(react.Text, { fontFamily: "mono", fontWeight: "semibold", textAlign: "right", ...decision.value >= 0 && selected2 ? { color: "fg.success" } : {}, children: decisionValue(decision, decision.value, selected2) });
|
|
53933
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { css: rs.rowShell, ...leaving ? { "data-leaving": leaving } : {}, children: [
|
|
53934
|
+
narrow ? /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { px: "14px", py: "10px", children: [
|
|
53935
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", justifyContent: "space-between", alignItems: "baseline", children: [
|
|
53936
|
+
urgency,
|
|
53937
|
+
valueText
|
|
53938
|
+
] }),
|
|
53939
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { mt: "2px", fontSize: "13px", children: title }),
|
|
53940
|
+
selected2 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
53941
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { mt: "8px", children: facetTabs }),
|
|
53942
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { mt: "8px", children: commands })
|
|
53943
|
+
] })
|
|
53944
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { css: rs.row, children: [
|
|
53945
|
+
urgency,
|
|
53946
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { css: rs.title, p: 0, children: title }),
|
|
53947
|
+
valueText,
|
|
53948
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", alignItems: "center", gap: "12px", children: [
|
|
53949
|
+
selected2 && facetTabs,
|
|
53950
|
+
commands
|
|
53951
|
+
] })
|
|
53952
|
+
] }),
|
|
53953
|
+
selected2 && /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { px: narrow ? "14px" : "18px", py: "12px", borderTopWidth: "1px", borderColor: "border.subtle", bg: "bg.canvas", children: [
|
|
53954
|
+
facet === "evidence" && /* @__PURE__ */ jsxRuntime.jsx(EvidenceFacet, { decision, children: canvas != null && /* @__PURE__ */ jsxRuntime.jsx(eastUiComponents.EastChakraComponent, { value: canvas, storageKey: `${storageKey}-detail-${decision.id}` }) }),
|
|
53955
|
+
facet === "options" && /* @__PURE__ */ jsxRuntime.jsx(OptionsFacet, { decision, narrow }),
|
|
53956
|
+
facet === "judgement" && /* @__PURE__ */ jsxRuntime.jsx(JudgementFacet, { decision, handle, leverPayloads }),
|
|
53957
|
+
facet === "modify" && probe != null && /* @__PURE__ */ jsxRuntime.jsx(eastUiComponents.EastChakraComponent, { value: probe, storageKey: `${storageKey}-modify-${decision.id}` })
|
|
53958
|
+
] })
|
|
53959
|
+
] });
|
|
53960
|
+
});
|
|
53961
|
+
const RoutineGroup = React.memo(function RoutineGroup2({ routine, acceptAll, leaving, narrow }) {
|
|
53962
|
+
const dq = react.useSlotRecipe({ key: "decisionQueue" });
|
|
53963
|
+
const status = react.useSlotRecipe({ key: "status" });
|
|
53964
|
+
const button = react.useRecipe({ key: "button" });
|
|
53965
|
+
const rs = dq({});
|
|
53966
|
+
const st = status({ status: "neutral", size: "md" });
|
|
53967
|
+
const total = React.useMemo(() => routine.reduce((acc, d2) => acc + d2.value, 0), [routine]);
|
|
53968
|
+
const format = routine[0] ? eastUiComponents.getSomeorUndefined(routine[0].format) : void 0;
|
|
53969
|
+
const handleAcceptAll = React.useCallback(() => {
|
|
53970
|
+
if (acceptAll) acceptAll(routine);
|
|
53971
|
+
}, [acceptAll, routine]);
|
|
53972
|
+
if (routine.length === 0) return null;
|
|
53973
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { css: rs.routineGroup, children: [
|
|
53974
|
+
routine.map((d2) => /* @__PURE__ */ jsxRuntime.jsx(react.Box, { css: rs.rowShell, ...leaving.has(d2.id) ? { "data-leaving": leaving.get(d2.id) } : {}, children: /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { css: rs.routineRow, children: [
|
|
53975
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { as: "span", css: st.root, children: [
|
|
53976
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { as: "span", css: st.indicator }),
|
|
53977
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { as: "span", css: st.label, children: "routine" })
|
|
53978
|
+
] }),
|
|
53979
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { minW: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", children: [
|
|
53980
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontFamily: "mono", children: d2.id }),
|
|
53981
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Text, { as: "span", color: "fg.muted", children: [
|
|
53982
|
+
" · ",
|
|
53983
|
+
d2.kind
|
|
53984
|
+
] })
|
|
53985
|
+
] }),
|
|
53986
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { css: rs.routineValue, children: decisionValue(d2, d2.value) })
|
|
53987
|
+
] }) }, d2.id)),
|
|
53988
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { css: rs.summary, ...narrow ? { marginLeft: "0", flexWrap: "wrap" } : {}, children: [
|
|
53989
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { as: "span", css: rs.summaryCap, children: [
|
|
53990
|
+
routine.length,
|
|
53991
|
+
" routine"
|
|
53992
|
+
] }),
|
|
53993
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", color: "fg.subtle", children: "·" }),
|
|
53994
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontFamily: "mono", fontWeight: "semibold", children: eastUiComponents.formatTick(total, format) }),
|
|
53995
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", color: "fg.muted", children: "total" }),
|
|
53996
|
+
acceptAll && /* @__PURE__ */ jsxRuntime.jsx(react.Box, { as: "button", css: button({ variant: "solid", size: "xs" }), ml: "auto", onClick: handleAcceptAll, children: "Accept all" })
|
|
53997
|
+
] })
|
|
53998
|
+
] });
|
|
53999
|
+
});
|
|
54000
|
+
const EastChakraDecisionQueue = React.memo(function EastChakraDecisionQueue2({ value, storageKey }) {
|
|
54001
|
+
var _a2;
|
|
54002
|
+
const eyebrow = react.useSlotRecipe({ key: "eyebrowRow" });
|
|
54003
|
+
const es = eyebrow({});
|
|
54004
|
+
const handleRef = value.handle;
|
|
54005
|
+
const handle = useDecisionHandle(handleRef);
|
|
54006
|
+
const decisions = handle.decisions;
|
|
54007
|
+
const leverPayloads = useLeverPayloads(handleRef);
|
|
54008
|
+
const railAffordances = eastUiComponents.getSomeorUndefined(value.slice);
|
|
54009
|
+
const sliceHandle = handle.slice;
|
|
54010
|
+
eastUiComponents.useSliceReactivity(sliceHandle == null ? void 0 : sliceHandle.key);
|
|
54011
|
+
const sliceState = sliceHandle !== null ? sliceHandle.read() : null;
|
|
54012
|
+
const rootRef = React.useRef(null);
|
|
54013
|
+
const [narrow, setNarrow] = React.useState(false);
|
|
54014
|
+
React.useLayoutEffect(() => {
|
|
54015
|
+
const el = rootRef.current;
|
|
54016
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
54017
|
+
const ro = new ResizeObserver((entries) => {
|
|
54018
|
+
var _a3;
|
|
54019
|
+
const width2 = ((_a3 = entries[0]) == null ? void 0 : _a3.contentRect.width) ?? 0;
|
|
54020
|
+
setNarrow(width2 > 0 && width2 < NARROW_PX);
|
|
54021
|
+
});
|
|
54022
|
+
ro.observe(el);
|
|
54023
|
+
return () => ro.disconnect();
|
|
54024
|
+
}, []);
|
|
54025
|
+
const [exiting, setExiting] = React.useState(/* @__PURE__ */ new Map());
|
|
54026
|
+
const prevRef = React.useRef(null);
|
|
54027
|
+
const reasonsRef = React.useRef(/* @__PURE__ */ new Map());
|
|
54028
|
+
const timersRef = React.useRef([]);
|
|
54029
|
+
React.useLayoutEffect(() => {
|
|
54030
|
+
const prev2 = prevRef.current;
|
|
54031
|
+
prevRef.current = decisions;
|
|
54032
|
+
if (!prev2 || !decisions) return;
|
|
54033
|
+
const ids = new Set(decisions.map((d2) => d2.id));
|
|
54034
|
+
const removed = prev2.filter((d2) => !ids.has(d2.id));
|
|
54035
|
+
if (removed.length === 0) return;
|
|
54036
|
+
setExiting((old) => {
|
|
54037
|
+
const next2 = new Map(old);
|
|
54038
|
+
for (const d2 of removed) {
|
|
54039
|
+
next2.set(d2.id, { decision: d2, reason: reasonsRef.current.get(d2.id) ?? "removed" });
|
|
54040
|
+
reasonsRef.current.delete(d2.id);
|
|
54041
|
+
}
|
|
54042
|
+
return next2;
|
|
54043
|
+
});
|
|
54044
|
+
timersRef.current.push(setTimeout(() => {
|
|
54045
|
+
setExiting((old) => {
|
|
54046
|
+
const next2 = new Map(old);
|
|
54047
|
+
for (const d2 of removed) next2.delete(d2.id);
|
|
54048
|
+
return next2;
|
|
54049
|
+
});
|
|
54050
|
+
}, EXIT_MS));
|
|
54051
|
+
}, [decisions]);
|
|
54052
|
+
React.useEffect(() => () => {
|
|
54053
|
+
for (const t2 of timersRef.current) clearTimeout(t2);
|
|
54054
|
+
}, []);
|
|
54055
|
+
const heading = eastUiComponents.getSomeorUndefined(value.heading) ?? "Decisions waiting";
|
|
54056
|
+
const onApply = React.useMemo(() => eastUiComponents.getSomeorUndefined(value.onApply), [value.onApply]);
|
|
54057
|
+
const onReject = React.useMemo(() => eastUiComponents.getSomeorUndefined(value.onReject), [value.onReject]);
|
|
54058
|
+
const modify = React.useMemo(
|
|
54059
|
+
() => eastUiComponents.getSomeorUndefined(value.modify),
|
|
54060
|
+
[value.modify]
|
|
54061
|
+
);
|
|
54062
|
+
const detail = React.useMemo(
|
|
54063
|
+
() => eastUiComponents.getSomeorUndefined(value.detail),
|
|
54064
|
+
[value.detail]
|
|
54065
|
+
);
|
|
54066
|
+
const defaultFacet = ((_a2 = eastUiComponents.getSomeorUndefined(value.defaultFacet)) == null ? void 0 : _a2.type) ?? "evidence";
|
|
54067
|
+
const defaultExpanded = eastUiComponents.getSomeorUndefined(value.defaultExpanded);
|
|
54068
|
+
const selectedId = handle.selected ?? (defaultExpanded == null ? void 0 : defaultExpanded.id) ?? null;
|
|
54069
|
+
const resolve2 = React.useCallback((ds, hook2, reason) => {
|
|
54070
|
+
if (hook2) for (const d2 of ds) {
|
|
54071
|
+
const decision = d2;
|
|
54072
|
+
queueMicrotask(() => hook2(decision));
|
|
54073
|
+
}
|
|
54074
|
+
for (const d2 of ds) {
|
|
54075
|
+
reasonsRef.current.set(d2.id, reason);
|
|
54076
|
+
handle.resolve(d2.id, reason === "reject" ? east.variant("rejected", null) : east.variant("accepted", ""));
|
|
54077
|
+
}
|
|
54078
|
+
}, [handle]);
|
|
54079
|
+
const apply2 = React.useCallback((d2) => resolve2([d2], onApply, "apply"), [resolve2, onApply]);
|
|
54080
|
+
const reject2 = React.useCallback((d2) => resolve2([d2], onReject, "reject"), [resolve2, onReject]);
|
|
54081
|
+
const acceptAll = React.useCallback((ds) => resolve2(ds, onApply, "apply"), [resolve2, onApply]);
|
|
54082
|
+
const { active, routine, pastSla, visible } = React.useMemo(() => {
|
|
54083
|
+
const scoped = decisions ?? [];
|
|
54084
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
54085
|
+
const live = sliceState !== null ? scoped.filter((d2) => internal$2.sliceMatches(sliceState, DECISION_SLICE_CONFIG, d2, now2)) : scoped;
|
|
54086
|
+
const merged = [...live];
|
|
54087
|
+
for (const { decision } of exiting.values()) {
|
|
54088
|
+
if (!merged.some((d2) => d2.id === decision.id)) merged.push(decision);
|
|
54089
|
+
}
|
|
54090
|
+
merged.sort((a2, b2) => {
|
|
54091
|
+
var _a3, _b;
|
|
54092
|
+
const r2 = URGENCY_RANK[a2.urgency.type] - URGENCY_RANK[b2.urgency.type];
|
|
54093
|
+
if (r2 !== 0) return r2;
|
|
54094
|
+
const da = ((_a3 = eastUiComponents.getSomeorUndefined(a2.deadline)) == null ? void 0 : _a3.getTime()) ?? Infinity;
|
|
54095
|
+
const db = ((_b = eastUiComponents.getSomeorUndefined(b2.deadline)) == null ? void 0 : _b.getTime()) ?? Infinity;
|
|
54096
|
+
if (da !== db) return da - db;
|
|
54097
|
+
return b2.value - a2.value;
|
|
54098
|
+
});
|
|
54099
|
+
return {
|
|
54100
|
+
active: merged.filter((d2) => d2.urgency.type !== "routine"),
|
|
54101
|
+
routine: merged.filter((d2) => d2.urgency.type === "routine"),
|
|
54102
|
+
pastSla: merged.filter((d2) => d2.urgency.type === "overdue").length,
|
|
54103
|
+
visible: live.length
|
|
54104
|
+
};
|
|
54105
|
+
}, [decisions, exiting, sliceState]);
|
|
54106
|
+
const exitingReasons = React.useMemo(() => {
|
|
54107
|
+
const m2 = /* @__PURE__ */ new Map();
|
|
54108
|
+
for (const [id3, e2] of exiting) m2.set(id3, e2.reason);
|
|
54109
|
+
return m2;
|
|
54110
|
+
}, [exiting]);
|
|
54111
|
+
if (decisions === null) {
|
|
54112
|
+
return /* @__PURE__ */ jsxRuntime.jsx(react.Box, { layerStyle: "frame", p: "16px", children: /* @__PURE__ */ jsxRuntime.jsx(react.Text, { color: "fg.muted", fontSize: "13px", children: "Loading decisions…" }) });
|
|
54113
|
+
}
|
|
54114
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { ref: rootRef, layerStyle: "frame", overflow: "hidden", children: [
|
|
54115
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { css: es.root, children: [
|
|
54116
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { css: es.lbl, children: heading }),
|
|
54117
|
+
sliceHandle !== null && railAffordances !== void 0 && /* @__PURE__ */ jsxRuntime.jsx(react.Box, { display: "flex", alignItems: "center", minWidth: "0", flex: "1", justifyContent: "flex-end", marginRight: "10px", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
54118
|
+
eastUiComponents.SliceRailCluster,
|
|
54119
|
+
{
|
|
54120
|
+
slice: sliceHandle,
|
|
54121
|
+
affordanceKinds: railAffordances.map((a2) => a2.type)
|
|
54122
|
+
}
|
|
54123
|
+
) }),
|
|
54124
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { css: es.meta, gap: "10px", children: [
|
|
54125
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { as: "span", children: [
|
|
54126
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", color: "fg", fontWeight: "semibold", children: visible }),
|
|
54127
|
+
narrow ? "" : " decisions"
|
|
54128
|
+
] }),
|
|
54129
|
+
pastSla > 0 && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
54130
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { as: "span", css: es.sep, children: "·" }),
|
|
54131
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { as: "span", children: [
|
|
54132
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", color: "fg.danger", fontWeight: "semibold", children: pastSla }),
|
|
54133
|
+
narrow ? " SLA" : " past SLA"
|
|
54134
|
+
] })
|
|
54135
|
+
] })
|
|
54136
|
+
] })
|
|
54137
|
+
] }),
|
|
54138
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
54139
|
+
react.Box,
|
|
54140
|
+
{
|
|
54141
|
+
maxHeight: eastUiComponents.getSomeorUndefined(value.maxHeight),
|
|
54142
|
+
overflowY: value.maxHeight.type === "some" ? "auto" : void 0,
|
|
54143
|
+
children: [
|
|
54144
|
+
active.map((d2) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
54145
|
+
Row,
|
|
54146
|
+
{
|
|
54147
|
+
decision: d2,
|
|
54148
|
+
handle,
|
|
54149
|
+
selected: selectedId === d2.id,
|
|
54150
|
+
narrow,
|
|
54151
|
+
leverPayloads,
|
|
54152
|
+
modify,
|
|
54153
|
+
detail,
|
|
54154
|
+
defaultFacet,
|
|
54155
|
+
apply: apply2,
|
|
54156
|
+
reject: reject2,
|
|
54157
|
+
leaving: exitingReasons.get(d2.id),
|
|
54158
|
+
storageKey
|
|
54159
|
+
},
|
|
54160
|
+
d2.id
|
|
54161
|
+
)),
|
|
54162
|
+
/* @__PURE__ */ jsxRuntime.jsx(RoutineGroup, { routine, acceptAll, leaving: exitingReasons, narrow })
|
|
54163
|
+
]
|
|
54164
|
+
}
|
|
54165
|
+
)
|
|
54166
|
+
] });
|
|
54167
|
+
});
|
|
54168
|
+
eastUiComponents.implementUIComponent(internal.DecisionQueue.Component, EastChakraDecisionQueue);
|
|
54169
|
+
function verdictPresentation(verdict) {
|
|
54170
|
+
switch (verdict.type) {
|
|
54171
|
+
case "accepted":
|
|
54172
|
+
return { tone: "success", verb: "accepted", detail: verdict.value !== "" ? verdict.value : null };
|
|
54173
|
+
case "rejected":
|
|
54174
|
+
return { tone: "danger", verb: "rejected", detail: null };
|
|
54175
|
+
case "deferred":
|
|
54176
|
+
return { tone: "neutral", verb: "deferred", detail: verdict.value.type === "some" ? verdict.value.value : null };
|
|
54177
|
+
case "handoff":
|
|
54178
|
+
return { tone: "warning", verb: "handed off", detail: verdict.value !== "" ? verdict.value : null };
|
|
54179
|
+
}
|
|
54180
|
+
}
|
|
54181
|
+
function formatResolvedAt(j2) {
|
|
54182
|
+
if (j2.resolvedAt.type !== "some") return null;
|
|
54183
|
+
const d2 = j2.resolvedAt.value;
|
|
54184
|
+
const month = d2.toLocaleString("en", { month: "short" });
|
|
54185
|
+
const time2 = `${String(d2.getHours()).padStart(2, "0")}:${String(d2.getMinutes()).padStart(2, "0")}`;
|
|
54186
|
+
return `${month} ${d2.getDate()} · ${time2}`;
|
|
54187
|
+
}
|
|
54188
|
+
const EastChakraDecisionJournal = React.memo(function EastChakraDecisionJournal2({ value }) {
|
|
54189
|
+
const eyebrow = react.useSlotRecipe({ key: "eyebrowRow" });
|
|
54190
|
+
const status = react.useSlotRecipe({ key: "status" });
|
|
54191
|
+
const es = eyebrow({});
|
|
54192
|
+
const handle = useDecisionHandle(value.handle);
|
|
54193
|
+
const heading = eastUiComponents.getSomeorUndefined(value.heading) ?? "Decision journal";
|
|
54194
|
+
const cache3 = getReactiveDatasetCache();
|
|
54195
|
+
const workspace = cache3.getConfig().workspace ?? "";
|
|
54196
|
+
const leverPayloads = React.useMemo(() => {
|
|
54197
|
+
var _a2, _b, _c;
|
|
54198
|
+
const judgements = getBindingTypes(workspace, value.handle.judgements.source);
|
|
54199
|
+
if (!(judgements == null ? void 0 : judgements.sourceType)) return {};
|
|
54200
|
+
const root2 = normalizeTypeValue(judgements.sourceType);
|
|
54201
|
+
const constraint = (_c = (_b = (_a2 = root2.value) == null ? void 0 : _a2.fields) == null ? void 0 : _b["constraints"]) == null ? void 0 : _c.value;
|
|
54202
|
+
return (constraint == null ? void 0 : constraint.type) === "Variant" ? constraint.cases ?? {} : {};
|
|
54203
|
+
}, [workspace, value.handle]);
|
|
54204
|
+
const entries = React.useMemo(() => handle.journal ?? [], [handle.journal]);
|
|
54205
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(react.Box, { borderWidth: "1px", borderColor: "border.strong", borderRadius: "6px", background: "bg.canvas", overflow: "hidden", children: [
|
|
54206
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { css: es.root, children: [
|
|
54207
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { css: es.lbl, children: heading }),
|
|
54208
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { css: es.meta, children: entries.length === 1 ? "1 entry" : `${entries.length} entries` })
|
|
54209
|
+
] }),
|
|
54210
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
54211
|
+
react.Box,
|
|
54212
|
+
{
|
|
54213
|
+
maxHeight: eastUiComponents.getSomeorUndefined(value.maxHeight),
|
|
54214
|
+
overflowY: value.maxHeight.type === "some" ? "auto" : void 0,
|
|
54215
|
+
children: entries.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx(react.Text, { px: "16px", py: "14px", fontSize: "13px", color: "fg.muted", children: "No resolved cases yet — verdicts land here as the queue clears." }) : entries.map((j2, i) => {
|
|
54216
|
+
const verdict = j2.verdict.type === "some" ? j2.verdict.value : null;
|
|
54217
|
+
if (!verdict) return null;
|
|
54218
|
+
const { tone, verb, detail } = verdictPresentation(verdict);
|
|
54219
|
+
const st = status({ status: tone, size: "md" });
|
|
54220
|
+
const when = formatResolvedAt(j2);
|
|
54221
|
+
const knowledge = j2.knowledge.type === "some" && j2.knowledge.value !== "" ? j2.knowledge.value : null;
|
|
54222
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
54223
|
+
react.Box,
|
|
54224
|
+
{
|
|
54225
|
+
px: "16px",
|
|
54226
|
+
py: "10px",
|
|
54227
|
+
borderTopWidth: i === 0 ? void 0 : "1px",
|
|
54228
|
+
borderColor: "border.subtle",
|
|
54229
|
+
display: "flex",
|
|
54230
|
+
flexDirection: "column",
|
|
54231
|
+
gap: "6px",
|
|
54232
|
+
children: [
|
|
54233
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { display: "flex", alignItems: "baseline", gap: "10px", children: [
|
|
54234
|
+
/* @__PURE__ */ jsxRuntime.jsxs(react.Box, { as: "span", css: st.root, flexShrink: 0, children: [
|
|
54235
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { as: "span", css: st.indicator }),
|
|
54236
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Box, { as: "span", css: st.label, children: verb })
|
|
54237
|
+
] }),
|
|
54238
|
+
/* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontFamily: "mono", fontSize: "12px", color: "fg.muted", children: j2.caseId }),
|
|
54239
|
+
detail !== null && /* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontSize: "13px", minW: 0, flex: "1", truncate: true, children: detail }),
|
|
54240
|
+
when !== null && /* @__PURE__ */ jsxRuntime.jsx(react.Text, { as: "span", fontFamily: "mono", fontSize: "11.5px", color: "fg.muted", marginLeft: "auto", flexShrink: 0, children: when })
|
|
54241
|
+
] }),
|
|
54242
|
+
knowledge !== null && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
54243
|
+
react.Text,
|
|
54244
|
+
{
|
|
54245
|
+
fontSize: "12.5px",
|
|
54246
|
+
fontStyle: "italic",
|
|
54247
|
+
color: "fg.muted",
|
|
54248
|
+
borderLeftWidth: "2px",
|
|
54249
|
+
borderColor: "border.strong",
|
|
54250
|
+
paddingLeft: "10px",
|
|
54251
|
+
children: [
|
|
54252
|
+
"“",
|
|
54253
|
+
knowledge,
|
|
54254
|
+
"”"
|
|
54255
|
+
]
|
|
54256
|
+
}
|
|
54257
|
+
),
|
|
54258
|
+
j2.constraints.length > 0 && /* @__PURE__ */ jsxRuntime.jsx(react.Box, { display: "flex", gap: "12px", flexWrap: "wrap", children: j2.constraints.map((c2, k2) => {
|
|
54259
|
+
const tag = c2.type;
|
|
54260
|
+
const f2 = formatConstraint(c2, leverPayloads[tag]);
|
|
54261
|
+
return /* @__PURE__ */ jsxRuntime.jsx(eastUiComponents.ClauseChip, { field: f2.lever, op: f2.op, value: f2.value }, k2);
|
|
54262
|
+
}) })
|
|
54263
|
+
]
|
|
54264
|
+
},
|
|
54265
|
+
j2.caseId
|
|
54266
|
+
);
|
|
54267
|
+
})
|
|
54268
|
+
}
|
|
54269
|
+
)
|
|
54270
|
+
] });
|
|
54271
|
+
});
|
|
54272
|
+
eastUiComponents.implementUIComponent(internal.DecisionJournal.Component, EastChakraDecisionJournal);
|
|
53059
54273
|
function formatApiError(error3) {
|
|
53060
54274
|
if (error3 instanceof e3ApiClient.ApiError && error3.details != null) {
|
|
53061
54275
|
const details = error3.details;
|
|
@@ -53981,7 +55195,7 @@ const UITaskPreview = React.memo(function UITaskPreview2({
|
|
|
53981
55195
|
const manifest = React.useMemo(() => {
|
|
53982
55196
|
if (!details || !isUI) return null;
|
|
53983
55197
|
const meta3 = getTaskMetadata(details);
|
|
53984
|
-
return meta3 ?
|
|
55198
|
+
return meta3 ? internal.decodeManifest(meta3) : { paths: [] };
|
|
53985
55199
|
}, [details, isUI]);
|
|
53986
55200
|
const outputPath = details ? treePathToString$1(details.output) : null;
|
|
53987
55201
|
const preloads = React.useMemo(
|
|
@@ -54569,6 +55783,8 @@ exports.BindRuntime = BindRuntime;
|
|
|
54569
55783
|
exports.DataTaskPreview = DataTaskPreview;
|
|
54570
55784
|
exports.DatasetPreview = DatasetPreview;
|
|
54571
55785
|
exports.E3Provider = E3Provider;
|
|
55786
|
+
exports.EastChakraDecisionJournal = EastChakraDecisionJournal;
|
|
55787
|
+
exports.EastChakraDecisionQueue = EastChakraDecisionQueue;
|
|
54572
55788
|
exports.EastChakraDiff = EastChakraDiff;
|
|
54573
55789
|
exports.EastChakraOntology = EastChakraOntology;
|
|
54574
55790
|
exports.EastValueViewer = EastValueViewer;
|
|
@@ -54628,6 +55844,7 @@ exports.useDatasetListWithStatus = useDatasetListWithStatus;
|
|
|
54628
55844
|
exports.useDatasetSet = useDatasetSet;
|
|
54629
55845
|
exports.useDatasetStatus = useDatasetStatus;
|
|
54630
55846
|
exports.useDatasetValue = useDatasetValue;
|
|
55847
|
+
exports.useDecisionHandle = useDecisionHandle;
|
|
54631
55848
|
exports.useE3Config = useE3Config;
|
|
54632
55849
|
exports.useE3ConfigOptional = useE3ConfigOptional;
|
|
54633
55850
|
exports.usePackageExport = usePackageExport;
|