base-screen 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_internal/contracts/document/schema.d.ts +7 -0
- package/dist/_internal/contracts/document/schema.js +1 -1
- package/dist/_internal/contracts/document/validate-value-ref.js +6 -1
- package/dist/_internal/contracts/screen-document.schema.json +15 -3
- package/dist/_internal/contracts/types/diagnostics.d.ts +1 -1
- package/dist/_internal/contracts/types/document.d.ts +3 -1
- package/dist/_internal/core/blueprint/runtime-simulate.d.ts +57 -0
- package/dist/_internal/core/blueprint/runtime-simulate.js +177 -0
- package/dist/_internal/core/blueprint/runtime.d.ts +1 -0
- package/dist/_internal/core/blueprint/runtime.js +1 -0
- package/dist/_internal/core/commands/apply-collection-commands.d.ts +32 -0
- package/dist/_internal/core/commands/apply-collection-commands.js +174 -0
- package/dist/_internal/core/commands/apply.js +13 -0
- package/dist/_internal/core/commands/parse-command.js +12 -0
- package/dist/_internal/core/commands/types.d.ts +29 -1
- package/dist/_internal/core/data/data-candidates.d.ts +38 -0
- package/dist/_internal/core/data/data-candidates.js +186 -0
- package/dist/_internal/core/data/dataset-profile.d.ts +71 -0
- package/dist/_internal/core/data/dataset-profile.js +170 -0
- package/dist/_internal/core/data/sample-values.d.ts +25 -0
- package/dist/_internal/core/data/sample-values.js +45 -0
- package/dist/_internal/core/diff/screen-diff.js +6 -0
- package/dist/_internal/core/index.d.ts +7 -1
- package/dist/_internal/core/index.js +7 -1
- package/dist/_internal/core/state/state-preset.d.ts +32 -0
- package/dist/_internal/core/state/state-preset.js +37 -0
- package/dist/_internal/core/validation/layout-audit.d.ts +17 -0
- package/dist/_internal/core/validation/layout-audit.js +228 -0
- package/dist/_internal/core/validation/legibility.d.ts +9 -0
- package/dist/_internal/core/validation/legibility.js +33 -0
- package/dist/_internal/engine/browser/controllers/dataset/designer-dataset-draft-controller.d.ts +6 -1
- package/dist/_internal/engine/browser/controllers/designer-change-controller.d.ts +27 -0
- package/dist/_internal/engine/browser/dom/change/designer-change-dom.d.ts +21 -5
- package/dist/_internal/engine/browser/dom/dataset/designer-data-section-diff.d.ts +4 -6
- package/dist/_internal/engine/browser/dom/value-ref/designer-value-ref-types.d.ts +2 -0
- package/dist/_internal/engine/browser/viewport/designer-canvas-aids-types.d.ts +3 -3
- package/dist/_internal/engine/browser/viewport/designer-canvas-aids.d.ts +5 -3
- package/dist/_internal/engine/browser/viewport/designer-canvas-measurements.d.ts +2 -14
- package/dist/_internal/engine/browser/viewport/designer-guide-overlay-nodes.d.ts +2 -0
- package/dist/_internal/engine/browser/viewport/designer-snap-tuning.d.ts +14 -0
- package/dist/_internal/engine/common/operations/change/designer-change-events.d.ts +2 -0
- package/dist/_internal/engine/common/operations/change/designer-change-proposal.d.ts +35 -2
- package/dist/_internal/engine/common/operations/display/designer-target-display.d.ts +2 -2
- package/dist/_internal/engine/common/operations/style/designer-component-states.d.ts +7 -2
- package/dist/_internal/engine/common/ui-text/designer-ui-text.d.ts +42 -2
- package/dist/_internal/engine/{designer-blueprint-workbench-panel-CJ3iZo5v.js → designer-blueprint-workbench-panel-BWSglfAb.js} +210 -290
- package/dist/_internal/engine/{designer-dataset-controller-CrfOg2Ys.js → designer-dataset-controller-DdbY4ILC.js} +619 -561
- package/dist/_internal/engine/designer-element/api/designer-element-change.d.ts +24 -0
- package/dist/_internal/engine/designer-element/base-screen-designer-element.d.ts +12 -0
- package/dist/_internal/engine/designer-element/designer-element-public-api.d.ts +2 -1
- package/dist/_internal/engine/designer-element/runtime/designer-element-rendering.d.ts +1 -1
- package/dist/_internal/engine/designer-element/runtime/designer-element-runtime.d.ts +4 -1
- package/dist/_internal/engine/designer-element/runtime/designer-element-sample-data.d.ts +23 -0
- package/dist/_internal/engine/{designer-field-primitives-KBZuWN_D.js → designer-field-primitives-Crn464Qg.js} +44 -3
- package/dist/_internal/engine/{designer-left-panel-groups-dom-N2OHOWjl.js → designer-left-panel-groups-dom-DFdLWxxY.js} +2 -2
- package/dist/_internal/engine/{host-resource-selection-xo2mLCD4.js → host-resource-selection-CWrPLVOc.js} +2 -2
- package/dist/_internal/engine/index.js +4742 -4360
- package/dist/_internal/host-kit/index.d.ts +1 -0
- package/dist/_internal/host-kit/index.js +1 -0
- package/dist/_internal/host-kit/intent/index.d.ts +16 -0
- package/dist/_internal/host-kit/intent/index.js +13 -0
- package/dist/_internal/host-kit/intent/intent-behavior.d.ts +59 -0
- package/dist/_internal/host-kit/intent/intent-behavior.js +812 -0
- package/dist/_internal/host-kit/intent/intent-block.d.ts +59 -0
- package/dist/_internal/host-kit/intent/intent-block.js +359 -0
- package/dist/_internal/host-kit/intent/intent-catalog.d.ts +105 -0
- package/dist/_internal/host-kit/intent/intent-catalog.js +60 -0
- package/dist/_internal/host-kit/intent/intent-compile-types.d.ts +222 -0
- package/dist/_internal/host-kit/intent/intent-compile-types.js +10 -0
- package/dist/_internal/host-kit/intent/intent-compile.d.ts +35 -0
- package/dist/_internal/host-kit/intent/intent-compile.js +465 -0
- package/dist/_internal/host-kit/intent/intent-data-check.d.ts +50 -0
- package/dist/_internal/host-kit/intent/intent-data-check.js +163 -0
- package/dist/_internal/host-kit/intent/intent-data-context.d.ts +53 -0
- package/dist/_internal/host-kit/intent/intent-data-context.js +200 -0
- package/dist/_internal/host-kit/intent/intent-dataset.d.ts +52 -0
- package/dist/_internal/host-kit/intent/intent-dataset.js +125 -0
- package/dist/_internal/host-kit/intent/intent-format.d.ts +33 -0
- package/dist/_internal/host-kit/intent/intent-format.js +94 -0
- package/dist/_internal/host-kit/intent/intent-kpi-bind.d.ts +29 -0
- package/dist/_internal/host-kit/intent/intent-kpi-bind.js +59 -0
- package/dist/_internal/host-kit/intent/intent-layout.d.ts +102 -0
- package/dist/_internal/host-kit/intent/intent-layout.js +264 -0
- package/dist/_internal/host-kit/intent/intent-parse.d.ts +39 -0
- package/dist/_internal/host-kit/intent/intent-parse.js +930 -0
- package/dist/_internal/host-kit/intent/intent-prepare.d.ts +52 -0
- package/dist/_internal/host-kit/intent/intent-prepare.js +104 -0
- package/dist/_internal/host-kit/intent/intent-session.d.ts +202 -0
- package/dist/_internal/host-kit/intent/intent-session.js +1001 -0
- package/dist/_internal/host-kit/intent/intent-stream.d.ts +28 -0
- package/dist/_internal/host-kit/intent/intent-stream.js +183 -0
- package/dist/_internal/host-kit/intent/intent-style.d.ts +37 -0
- package/dist/_internal/host-kit/intent/intent-style.js +77 -0
- package/dist/_internal/host-kit/intent/intent-types.d.ts +234 -0
- package/dist/_internal/host-kit/intent/intent-types.js +10 -0
- package/dist/_internal/material/chart.js +34 -12
- package/dist/_internal/material/table.js +52 -21
- package/dist/_internal/plugin-sdk/index.d.ts +6 -0
- package/dist/_internal/plugin-sdk/index.js +6 -0
- package/dist/_internal/plugin-sdk/material-isolated-csp.d.ts +38 -0
- package/dist/_internal/plugin-sdk/material-isolated-csp.js +67 -0
- package/dist/_internal/plugin-sdk/material-isolated-runtime.d.ts +22 -0
- package/dist/_internal/plugin-sdk/material-isolated-runtime.js +262 -0
- package/dist/_internal/plugin-sdk/material-isolated.d.ts +94 -0
- package/dist/_internal/plugin-sdk/material-isolated.js +1024 -0
- package/dist/_internal/plugin-sdk/material-rendered-element.d.ts +10 -2
- package/dist/_internal/plugin-sdk/material-rendered-element.js +71 -7
- package/dist/_internal/plugin-sdk/material-spec-audit.d.ts +2 -0
- package/dist/_internal/plugin-sdk/material-spec-audit.js +26 -6
- package/dist/_internal/plugin-sdk/material-spec.d.ts +20 -0
- package/dist/_internal/plugin-sdk/material-spec.js +78 -3
- package/dist/_internal/plugin-sdk/material-template-audit.d.ts +12 -0
- package/dist/_internal/plugin-sdk/material-template-audit.js +302 -0
- package/dist/_internal/plugin-sdk/material-template-expression.d.ts +98 -0
- package/dist/_internal/plugin-sdk/material-template-expression.js +549 -0
- package/dist/_internal/plugin-sdk/material-template-render.d.ts +32 -0
- package/dist/_internal/plugin-sdk/material-template-render.js +579 -0
- package/dist/_internal/plugin-sdk/material-template.d.ts +185 -0
- package/dist/_internal/plugin-sdk/material-template.js +879 -0
- package/dist/auto-register.js +10 -10
- package/dist/contracts.js +5 -5
- package/dist/contrast-DRPezUIl.js +131 -0
- package/dist/contrast-DRPezUIl.js.map +1 -0
- package/dist/core.js +156 -136
- package/dist/core.js.map +1 -1
- package/dist/dataset-profile-Dk6xdtsM.js +261 -0
- package/dist/dataset-profile-Dk6xdtsM.js.map +1 -0
- package/dist/{designer-3Tb0EIDV.js → designer-CFOvOmLn.js} +2 -2
- package/dist/{designer-3Tb0EIDV.js.map → designer-CFOvOmLn.js.map} +1 -1
- package/dist/designer-auto-register.js +5 -5
- package/dist/{designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js → designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js} +452 -531
- package/dist/designer-blueprint-workbench-panel-BWSglfAb-ktaj6Ci9.js.map +1 -0
- package/dist/{designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js → designer-dataset-controller-DdbY4ILC-CMdGdGbr.js} +862 -804
- package/dist/designer-dataset-controller-DdbY4ILC-CMdGdGbr.js.map +1 -0
- package/dist/{designer-field-primitives-KBZuWN_D-B3h4jpYe.js → designer-field-primitives-Crn464Qg-Bi7q8s5J.js} +45 -4
- package/dist/designer-field-primitives-Crn464Qg-Bi7q8s5J.js.map +1 -0
- package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js → designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js} +4 -4
- package/dist/{designer-left-panel-groups-dom-N2OHOWjl-D8CzGwbF.js.map → designer-left-panel-groups-dom-DFdLWxxY-BarlWMLY.js.map} +1 -1
- package/dist/designer.js +5 -5
- package/dist/{dist-6GRboBs-.js → dist-B2bW2Tru.js} +4 -4
- package/dist/{dist-6GRboBs-.js.map → dist-B2bW2Tru.js.map} +1 -1
- package/dist/{dist-BjLjFUy1.js → dist-CHK9BTXX.js} +3833 -3453
- package/dist/dist-CHK9BTXX.js.map +1 -0
- package/dist/engine.js +5 -5
- package/dist/{fragment-Y6YnW6wy.js → fragment-B-oP0Fru.js} +3 -3
- package/dist/{fragment-Y6YnW6wy.js.map → fragment-B-oP0Fru.js.map} +1 -1
- package/dist/host-kit.js +3963 -187
- package/dist/host-kit.js.map +1 -1
- package/dist/{host-resource-selection-xo2mLCD4-BR5XCcim.js → host-resource-selection-CWrPLVOc-DPDq3jau.js} +5 -5
- package/dist/{host-resource-selection-xo2mLCD4-BR5XCcim.js.map → host-resource-selection-CWrPLVOc-DPDq3jau.js.map} +1 -1
- package/dist/index.js +10 -10
- package/dist/legibility-CS28ivEz.js +12 -0
- package/dist/legibility-CS28ivEz.js.map +1 -0
- package/dist/{level-scale-BzUjE31V.js → level-scale-CwHqFEVd.js} +2 -2
- package/dist/{level-scale-BzUjE31V.js.map → level-scale-CwHqFEVd.js.map} +1 -1
- package/dist/{manager-Ch0RTu_i.js → manager-CeB4Jnr9.js} +3 -3
- package/dist/{manager-Ch0RTu_i.js.map → manager-CeB4Jnr9.js.map} +1 -1
- package/dist/{material-UbSfiuZq.js → material-DeVkzSoT.js} +2 -2
- package/dist/{material-UbSfiuZq.js.map → material-DeVkzSoT.js.map} +1 -1
- package/dist/material-auto-register.js +1 -1
- package/dist/material.js +2 -2
- package/dist/{migrate-document-D3HhCVlZ.js → migrate-document-BM888PtC.js} +2 -2
- package/dist/{migrate-document-D3HhCVlZ.js.map → migrate-document-BM888PtC.js.map} +1 -1
- package/dist/{parse-AOTE9WnD.js → parse-Ji7kE9ZT.js} +9 -4
- package/dist/parse-Ji7kE9ZT.js.map +1 -0
- package/dist/{parse-B1OD1teS.js → parse-aZat9tAS.js} +3 -3
- package/dist/{parse-B1OD1teS.js.map → parse-aZat9tAS.js.map} +1 -1
- package/dist/{parse-parts-BNrpdG5o.js → parse-parts-qzl4suzk.js} +2 -2
- package/dist/{parse-parts-BNrpdG5o.js.map → parse-parts-qzl4suzk.js.map} +1 -1
- package/dist/{plugin-DHgh9uHh.js → plugin-CstHQ5ws.js} +4 -4
- package/dist/{plugin-DHgh9uHh.js.map → plugin-CstHQ5ws.js.map} +1 -1
- package/dist/plugin-core.js +2 -2
- package/dist/plugin-manager.js +1 -1
- package/dist/plugin-package-DWifuHi1.js +4206 -0
- package/dist/plugin-package-DWifuHi1.js.map +1 -0
- package/dist/{plugin-registration-rsmb4GvS.js → plugin-registration-DTwBvnHX.js} +2 -2
- package/dist/{plugin-registration-rsmb4GvS.js.map → plugin-registration-DTwBvnHX.js.map} +1 -1
- package/dist/plugin-sdk.js +6 -6
- package/dist/{plugins-DGRHgREK.js → plugins-QDL0yIql.js} +2 -2
- package/dist/{plugins-DGRHgREK.js.map → plugins-QDL0yIql.js.map} +1 -1
- package/dist/plugins.js +8 -8
- package/dist/renderer.js +1 -1
- package/dist/{runtime-dispatch-BfnRDtMe.js → runtime-dispatch-C0gyIrTv.js} +2 -2
- package/dist/{runtime-dispatch-BfnRDtMe.js.map → runtime-dispatch-C0gyIrTv.js.map} +1 -1
- package/dist/runtime-simulate-aSYO9yDX.js +147 -0
- package/dist/runtime-simulate-aSYO9yDX.js.map +1 -0
- package/dist/{src-Bm7u11mN-_0u6cMEw.js → src-Bm7u11mN-Bi1hDVkh.js} +39 -39
- package/dist/{src-Bm7u11mN-_0u6cMEw.js.map → src-Bm7u11mN-Bi1hDVkh.js.map} +1 -1
- package/dist/state-preset-DtpygJOH.js +22 -0
- package/dist/state-preset-DtpygJOH.js.map +1 -0
- package/dist/{text-BNksUr5J.js → text-BSTz0pFQ.js} +87 -34
- package/dist/text-BSTz0pFQ.js.map +1 -0
- package/dist/{value-ref-BG_MV9C-.js → value-ref-XkLuckGV.js} +2 -2
- package/dist/{value-ref-BG_MV9C-.js.map → value-ref-XkLuckGV.js.map} +1 -1
- package/dist/{viewer-CrJupI8I-D9dVcNw4.js → viewer-CrJupI8I-BJiz1cvW.js} +4 -4
- package/dist/{viewer-CrJupI8I-D9dVcNw4.js.map → viewer-CrJupI8I-BJiz1cvW.js.map} +1 -1
- package/dist/viewer-auto-register.js +2 -2
- package/dist/viewer.js +2 -2
- package/dist/{viewport-CiCKeAQH.js → viewport-BNIRWjiT.js} +354 -155
- package/dist/viewport-BNIRWjiT.js.map +1 -0
- package/package.json +12 -12
- package/dist/designer-blueprint-workbench-panel-CJ3iZo5v-BebifP4x.js.map +0 -1
- package/dist/designer-dataset-controller-CrfOg2Ys-DhKUEJJe.js.map +0 -1
- package/dist/designer-field-primitives-KBZuWN_D-B3h4jpYe.js.map +0 -1
- package/dist/dist-BjLjFUy1.js.map +0 -1
- package/dist/parse-AOTE9WnD.js.map +0 -1
- package/dist/plugin-package-Dr5ro6h6.js +0 -1221
- package/dist/plugin-package-Dr5ro6h6.js.map +0 -1
- package/dist/text-BNksUr5J.js.map +0 -1
- package/dist/viewport-CiCKeAQH.js.map +0 -1
package/dist/host-kit.js
CHANGED
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { t as e } from "./parse-B5b0hjql.js";
|
|
2
2
|
import { i as t, n, r } from "./definition-DlTP-401.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { At as i, r as a } from "./parse-Ji7kE9ZT.js";
|
|
4
|
+
import { d as o } from "./theme-CcBXf4Ay.js";
|
|
5
|
+
import { t as s } from "./migrate-document-BM888PtC.js";
|
|
6
|
+
import { n as c } from "./runtime-simulate-aSYO9yDX.js";
|
|
7
|
+
import { o as l, r as u } from "./dataset-profile-Dk6xdtsM.js";
|
|
8
|
+
import { t as d } from "./state-preset-DtpygJOH.js";
|
|
9
|
+
import { n as f } from "./legibility-CS28ivEz.js";
|
|
5
10
|
//#region ../host-kit/dist/http.js
|
|
6
|
-
var
|
|
11
|
+
var p = {
|
|
7
12
|
code: "NETWORK",
|
|
8
13
|
message: "网络请求失败,请确认后端服务已启动。",
|
|
9
14
|
status: 0
|
|
10
15
|
};
|
|
11
|
-
function
|
|
16
|
+
function m(e) {
|
|
12
17
|
let t = e.fetch ?? fetch, n = e.baseUrl.replace(/\/+$/, "");
|
|
13
18
|
return { async request(e, r = {}) {
|
|
14
|
-
let { method: i = "GET", body: a, signal:
|
|
19
|
+
let { method: i = "GET", body: a, signal: o } = r;
|
|
15
20
|
try {
|
|
16
21
|
let r = await t(`${n}${e}`, {
|
|
17
22
|
method: i,
|
|
@@ -20,14 +25,14 @@ function s(e) {
|
|
|
20
25
|
...a === void 0 ? {} : { "Content-Type": "application/json" }
|
|
21
26
|
},
|
|
22
27
|
...a === void 0 ? {} : { body: JSON.stringify(a) },
|
|
23
|
-
...
|
|
24
|
-
}),
|
|
28
|
+
...o === void 0 ? {} : { signal: o }
|
|
29
|
+
}), s = await r.json().catch(() => null);
|
|
25
30
|
return r.ok ? {
|
|
26
31
|
ok: !0,
|
|
27
|
-
data:
|
|
32
|
+
data: s
|
|
28
33
|
} : {
|
|
29
34
|
ok: !1,
|
|
30
|
-
error:
|
|
35
|
+
error: h(s, r.status)
|
|
31
36
|
};
|
|
32
37
|
} catch (e) {
|
|
33
38
|
return e instanceof DOMException && e.name === "AbortError" ? {
|
|
@@ -39,12 +44,12 @@ function s(e) {
|
|
|
39
44
|
}
|
|
40
45
|
} : {
|
|
41
46
|
ok: !1,
|
|
42
|
-
error:
|
|
47
|
+
error: p
|
|
43
48
|
};
|
|
44
49
|
}
|
|
45
50
|
} };
|
|
46
51
|
}
|
|
47
|
-
function
|
|
52
|
+
function h(e, t) {
|
|
48
53
|
if (typeof e == "object" && e) {
|
|
49
54
|
let n = e;
|
|
50
55
|
if (typeof n.error == "string" && typeof n.message == "string") return {
|
|
@@ -59,182 +64,3953 @@ function c(e, t) {
|
|
|
59
64
|
status: t
|
|
60
65
|
};
|
|
61
66
|
}
|
|
62
|
-
function
|
|
67
|
+
function g(e) {
|
|
63
68
|
let t = new URLSearchParams();
|
|
64
69
|
for (let [n, r] of Object.entries(e)) r !== void 0 && r !== "" && t.set(n, String(r));
|
|
65
70
|
let n = t.toString();
|
|
66
71
|
return n === "" ? "" : `?${n}`;
|
|
67
72
|
}
|
|
68
|
-
function
|
|
73
|
+
function _(e) {
|
|
69
74
|
if (e === void 0) return;
|
|
70
75
|
let t = new AbortController();
|
|
71
76
|
return e.aborted ? (t.abort(), t.signal) : (e.addEventListener("abort", () => t.abort(), { once: !0 }), t.signal);
|
|
72
77
|
}
|
|
73
78
|
//#endregion
|
|
74
79
|
//#region ../host-kit/dist/operation.js
|
|
75
|
-
async function
|
|
80
|
+
async function v(e, t, n, r) {
|
|
76
81
|
try {
|
|
77
|
-
let i =
|
|
82
|
+
let i = _(n);
|
|
78
83
|
if (i === void 0) throw Error("缺少取消信号。");
|
|
79
84
|
return await e.execute(t, i, r);
|
|
80
85
|
} catch (e) {
|
|
81
86
|
return {
|
|
82
|
-
ok: !1,
|
|
83
|
-
error: {
|
|
84
|
-
code: n.aborted || typeof e == "object" && e && "name" in e && e.name === "AbortError" ? "ABORTED" : "NETWORK",
|
|
85
|
-
message: "宿主业务请求失败。"
|
|
86
|
-
}
|
|
87
|
+
ok: !1,
|
|
88
|
+
error: {
|
|
89
|
+
code: n.aborted || typeof e == "object" && e && "name" in e && e.name === "AbortError" ? "ABORTED" : "NETWORK",
|
|
90
|
+
message: "宿主业务请求失败。"
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
function y(e, t, n, r) {
|
|
96
|
+
if (e !== void 0) try {
|
|
97
|
+
let i = { ...t };
|
|
98
|
+
Reflect.deleteProperty(i, "signal");
|
|
99
|
+
let a = e({
|
|
100
|
+
request: structuredClone(i),
|
|
101
|
+
result: structuredClone(n),
|
|
102
|
+
...r === void 0 ? {} : { error: structuredClone(r) }
|
|
103
|
+
});
|
|
104
|
+
Promise.resolve(a).catch(() => {});
|
|
105
|
+
} catch {}
|
|
106
|
+
}
|
|
107
|
+
function b(e, t, n, r = (e) => e) {
|
|
108
|
+
return {
|
|
109
|
+
async execute(r, i) {
|
|
110
|
+
let a;
|
|
111
|
+
try {
|
|
112
|
+
a = t?.request?.(r) ?? n(r);
|
|
113
|
+
} catch {
|
|
114
|
+
return {
|
|
115
|
+
ok: !1,
|
|
116
|
+
error: {
|
|
117
|
+
code: "HOST_KIT_MAPPING",
|
|
118
|
+
message: "宿主请求映射失败。"
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
return i.aborted ? {
|
|
123
|
+
ok: !1,
|
|
124
|
+
error: {
|
|
125
|
+
code: "ABORTED",
|
|
126
|
+
message: "请求已取消。"
|
|
127
|
+
}
|
|
128
|
+
} : e.request(a.path, {
|
|
129
|
+
...a,
|
|
130
|
+
signal: i
|
|
131
|
+
});
|
|
132
|
+
},
|
|
133
|
+
response: (e, n) => t?.response ? t.response(e, n) : r(e)
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
//#endregion
|
|
137
|
+
//#region ../host-kit/dist/dataset-port.js
|
|
138
|
+
var x = 6e4;
|
|
139
|
+
function S(i) {
|
|
140
|
+
let a;
|
|
141
|
+
async function o(e, t, n, r, i, a) {
|
|
142
|
+
if (n.aborted) return D();
|
|
143
|
+
let o = await v(e, t, n, a);
|
|
144
|
+
if (n.aborted || !o.ok && o.error.code === "ABORTED") return D();
|
|
145
|
+
let s;
|
|
146
|
+
if (!o.ok) s = E(T(o.error), o.error.message);
|
|
147
|
+
else try {
|
|
148
|
+
let n = r(e.response ? e.response(o.data, t) : o.data);
|
|
149
|
+
s = n.ok ? n : E("HOST_DATASET_INVALID", "数据集响应格式无效。");
|
|
150
|
+
} catch {
|
|
151
|
+
s = E("HOST_DATASET_INVALID", "数据集响应格式无效。");
|
|
152
|
+
}
|
|
153
|
+
return n.aborted ? D() : (y(i, t, s, o.ok ? void 0 : o.error), s);
|
|
154
|
+
}
|
|
155
|
+
let s = i.groups;
|
|
156
|
+
return {
|
|
157
|
+
queryScope: "dataset",
|
|
158
|
+
...s === void 0 ? {} : { async groups(e) {
|
|
159
|
+
if (e.signal.aborted) return D();
|
|
160
|
+
let n = a;
|
|
161
|
+
if (n !== void 0 && Date.now() - n.at < x) return {
|
|
162
|
+
ok: !0,
|
|
163
|
+
value: n.value,
|
|
164
|
+
diagnostics: []
|
|
165
|
+
};
|
|
166
|
+
let r = await o(s, e, e.signal, t);
|
|
167
|
+
return r.ok && (a = {
|
|
168
|
+
at: Date.now(),
|
|
169
|
+
value: r.value
|
|
170
|
+
}), r;
|
|
171
|
+
} },
|
|
172
|
+
list: (e) => o(i.list, e, e.signal, r, i.onListResult),
|
|
173
|
+
describe: (e) => o(i.describe, e, e.signal, n, i.onDescribeResult),
|
|
174
|
+
query: (t, n) => o(i.query, t, n.signal, e, i.onQueryResult, n.context)
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
function C(e) {
|
|
178
|
+
let t = m(e);
|
|
179
|
+
return S({
|
|
180
|
+
groups: b(t, e.mapping?.groups, () => ({ path: `/datasets${g({ limit: 1 })}` }), (e) => {
|
|
181
|
+
if (!(typeof e != "object" || !e || Array.isArray(e))) return "groups" in e ? e.groups : [];
|
|
182
|
+
}),
|
|
183
|
+
list: b(t, e.mapping?.list, (e) => ({ path: `/datasets${g({
|
|
184
|
+
query: e.query,
|
|
185
|
+
limit: e.limit,
|
|
186
|
+
groupId: e.groupId,
|
|
187
|
+
cursor: e.cursor
|
|
188
|
+
})}` }), (e) => {
|
|
189
|
+
if (!(typeof e != "object" || !e || !("items" in e))) return {
|
|
190
|
+
items: e.items,
|
|
191
|
+
..."nextCursor" in e ? { nextCursor: e.nextCursor } : {}
|
|
192
|
+
};
|
|
193
|
+
}),
|
|
194
|
+
describe: b(t, e.mapping?.describe, (e) => ({ path: `/datasets/${encodeURIComponent(e.datasetId)}` })),
|
|
195
|
+
query: b(t, e.mapping?.query, (e) => ({ path: `/datasets/${encodeURIComponent(e.datasetId)}/query${g(w(e.params))}` }))
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function w(e) {
|
|
199
|
+
let t = {};
|
|
200
|
+
for (let [n, r] of Object.entries(e)) (typeof r == "string" || typeof r == "number" || typeof r == "boolean") && (t[n] = r);
|
|
201
|
+
return t;
|
|
202
|
+
}
|
|
203
|
+
function T(e) {
|
|
204
|
+
return e.code === "HOST_KIT_MAPPING" ? "HOST_DATASET_INVALID" : e.code === "UNKNOWN_DATASET" || e.status === 404 ? "HOST_DATASET_UNAVAILABLE" : e.status === 400 || e.status === 422 ? "HOST_DATASET_PARAMETER_INVALID" : "HOST_DATASET_UNAVAILABLE";
|
|
205
|
+
}
|
|
206
|
+
function E(e, t) {
|
|
207
|
+
return {
|
|
208
|
+
ok: !1,
|
|
209
|
+
diagnostics: [{
|
|
210
|
+
severity: "error",
|
|
211
|
+
code: e,
|
|
212
|
+
path: [],
|
|
213
|
+
message: t
|
|
214
|
+
}]
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
function D() {
|
|
218
|
+
return {
|
|
219
|
+
ok: !1,
|
|
220
|
+
diagnostics: []
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
//#endregion
|
|
224
|
+
//#region ../host-kit/dist/intent/intent-behavior.js
|
|
225
|
+
var O = /* @__PURE__ */ new Set([
|
|
226
|
+
"AGENT_INTERACTION_SOURCE_UNKNOWN",
|
|
227
|
+
"AGENT_INTERACTION_TARGET_UNKNOWN",
|
|
228
|
+
"AGENT_INTERACTION_EVENT_UNKNOWN",
|
|
229
|
+
"AGENT_INTERACTION_FIELD_UNKNOWN",
|
|
230
|
+
"AGENT_INTERACTION_TARGET_INVALID",
|
|
231
|
+
"AGENT_INTERACTION_NO_EFFECT",
|
|
232
|
+
"AGENT_STATE_FIELD_TYPE",
|
|
233
|
+
"AGENT_INTERACTION_STATE_UNKNOWN"
|
|
234
|
+
]);
|
|
235
|
+
function k(e) {
|
|
236
|
+
let t = [], n = (e) => ({
|
|
237
|
+
kind: "block",
|
|
238
|
+
origin: e.origin,
|
|
239
|
+
...e.ident === void 0 ? {} : { ident: e.ident },
|
|
240
|
+
...e.key === void 0 ? {} : { key: e.key },
|
|
241
|
+
title: e.title,
|
|
242
|
+
block: e
|
|
243
|
+
});
|
|
244
|
+
for (let r of e.regions) if (r.kind === "band") for (let e of r.items) t.push({
|
|
245
|
+
kind: "kpi",
|
|
246
|
+
origin: e.origin,
|
|
247
|
+
...e.ident === void 0 ? {} : { ident: e.ident },
|
|
248
|
+
...e.key === void 0 ? {} : { key: e.key },
|
|
249
|
+
title: e.label,
|
|
250
|
+
kpi: e
|
|
251
|
+
});
|
|
252
|
+
else r.kind === "grid" ? t.push(...r.blocks.map(n)) : t.push(...r.main.map(n), ...r.rail.map(n));
|
|
253
|
+
return t;
|
|
254
|
+
}
|
|
255
|
+
function A(e, t) {
|
|
256
|
+
let n = e.find((e) => e.key === t) ?? e.find((e) => (e.ident ?? e.origin) === t);
|
|
257
|
+
if (n !== void 0) return n;
|
|
258
|
+
let r = e.filter((e) => e.title.trim() === t.trim());
|
|
259
|
+
return r.length === 1 ? r[0] : void 0;
|
|
260
|
+
}
|
|
261
|
+
function ee(e, t) {
|
|
262
|
+
let n = [], r = e.interactions ?? [];
|
|
263
|
+
if (r.length === 0 || t === void 0) return {
|
|
264
|
+
intent: e,
|
|
265
|
+
warnings: n
|
|
266
|
+
};
|
|
267
|
+
let i = k(e), a = /* @__PURE__ */ new Map();
|
|
268
|
+
for (let e of r) {
|
|
269
|
+
if (e.kind !== "filter") continue;
|
|
270
|
+
let r = A(i, e.from);
|
|
271
|
+
if (r === void 0) continue;
|
|
272
|
+
let o = M(r, e.field, t);
|
|
273
|
+
for (let r of e.to) {
|
|
274
|
+
let s = A(i, r), c = s === void 0 ? void 0 : j(s);
|
|
275
|
+
if (s === void 0 || c === void 0) continue;
|
|
276
|
+
let l = t.datasets.find((e) => e.datasetId === c.datasetId)?.parameters?.find((t) => t.name === e.param);
|
|
277
|
+
if (l === void 0 || !l.required || l.defaultValue !== void 0 || c.params !== void 0 && Object.hasOwn(c.params, e.param)) continue;
|
|
278
|
+
let u = (o ?? []).find((e) => l.allowedValues === void 0 || l.allowedValues.includes(e));
|
|
279
|
+
u !== void 0 && (a.set(s.origin, {
|
|
280
|
+
...a.get(s.origin) ?? {},
|
|
281
|
+
[e.param]: u
|
|
282
|
+
}), n.push({
|
|
283
|
+
severity: "warning",
|
|
284
|
+
code: "INTENT_FILTER_INITIAL_FROM_SOURCE",
|
|
285
|
+
path: e.origin,
|
|
286
|
+
message: `Parameter ${e.param} of ${s.title} starts from the first value of the source (${String(u)}).`,
|
|
287
|
+
detail: {
|
|
288
|
+
param: e.param,
|
|
289
|
+
value: String(u),
|
|
290
|
+
target: s.title
|
|
291
|
+
}
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
if (a.size === 0) return {
|
|
296
|
+
intent: e,
|
|
297
|
+
warnings: n
|
|
298
|
+
};
|
|
299
|
+
let o = (e) => {
|
|
300
|
+
let t = a.get(e.origin);
|
|
301
|
+
return t === void 0 || e.bind === void 0 ? e : {
|
|
302
|
+
...e,
|
|
303
|
+
bind: {
|
|
304
|
+
...e.bind,
|
|
305
|
+
params: {
|
|
306
|
+
...e.bind.params ?? {},
|
|
307
|
+
...t
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
}, s = (e) => {
|
|
312
|
+
let t = a.get(e.origin);
|
|
313
|
+
return t === void 0 || e.bind.kind !== "dataset" ? e : {
|
|
314
|
+
...e,
|
|
315
|
+
bind: {
|
|
316
|
+
...e.bind,
|
|
317
|
+
params: {
|
|
318
|
+
...e.bind.params ?? {},
|
|
319
|
+
...t
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
};
|
|
323
|
+
};
|
|
324
|
+
return {
|
|
325
|
+
intent: {
|
|
326
|
+
...e,
|
|
327
|
+
regions: e.regions.map((e) => e.kind === "band" ? {
|
|
328
|
+
...e,
|
|
329
|
+
items: e.items.map(o)
|
|
330
|
+
} : e.kind === "grid" ? {
|
|
331
|
+
...e,
|
|
332
|
+
blocks: e.blocks.map(s)
|
|
333
|
+
} : {
|
|
334
|
+
...e,
|
|
335
|
+
main: e.main.map(s),
|
|
336
|
+
rail: e.rail.map(s)
|
|
337
|
+
})
|
|
338
|
+
},
|
|
339
|
+
warnings: n
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
function j(e) {
|
|
343
|
+
if (e.kpi?.bind !== void 0) return e.kpi.bind;
|
|
344
|
+
if (e.block?.bind.kind === "dataset") return e.block.bind;
|
|
345
|
+
}
|
|
346
|
+
function M(e, t, n) {
|
|
347
|
+
if (t === void 0) return;
|
|
348
|
+
let r = e.block?.bind;
|
|
349
|
+
if (r?.kind === "table") return [...new Set(r.table.rows.map((e) => e[t]).filter(N))];
|
|
350
|
+
let i = j(e);
|
|
351
|
+
if (i !== void 0) return n?.datasets.find((e) => e.datasetId === i.datasetId)?.values?.[t];
|
|
352
|
+
}
|
|
353
|
+
function N(e) {
|
|
354
|
+
return typeof e == "string" || typeof e == "number" || typeof e == "boolean";
|
|
355
|
+
}
|
|
356
|
+
function te(e) {
|
|
357
|
+
let t = {
|
|
358
|
+
variables: [],
|
|
359
|
+
blueprint: {
|
|
360
|
+
nodes: [],
|
|
361
|
+
edges: []
|
|
362
|
+
},
|
|
363
|
+
behaviors: []
|
|
364
|
+
}, n = k(e.intent), r = new P(e, t);
|
|
365
|
+
for (let t of e.intent.interactions ?? []) t.kind === "filter" ? r.filter(t, n) : t.kind === "show" && r.show(t, n);
|
|
366
|
+
for (let e of n) e.kpi?.states !== void 0 && r.states(e, e.kpi);
|
|
367
|
+
for (let t of e.intent.interactions ?? []) t.kind === "state" && r.setState(t, n);
|
|
368
|
+
return t;
|
|
369
|
+
}
|
|
370
|
+
var P = class {
|
|
371
|
+
input;
|
|
372
|
+
output;
|
|
373
|
+
#e = 0;
|
|
374
|
+
#t = 0;
|
|
375
|
+
#n = 0;
|
|
376
|
+
#r = /* @__PURE__ */ new Set();
|
|
377
|
+
#i = /* @__PURE__ */ new Map();
|
|
378
|
+
constructor(e, t) {
|
|
379
|
+
this.input = e, this.output = t;
|
|
380
|
+
}
|
|
381
|
+
warn(e, t, n, r) {
|
|
382
|
+
this.input.warnings.push({
|
|
383
|
+
severity: "warning",
|
|
384
|
+
code: e,
|
|
385
|
+
path: t,
|
|
386
|
+
message: n,
|
|
387
|
+
...r === void 0 ? {} : { detail: r }
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
componentsOf(e) {
|
|
391
|
+
return this.input.components.filter((t) => this.input.sources[t.id] === e.origin);
|
|
392
|
+
}
|
|
393
|
+
mainOf(e) {
|
|
394
|
+
let t = this.componentsOf(e);
|
|
395
|
+
if (e.kpi !== void 0) return t.find((e) => e.name === "指标值");
|
|
396
|
+
let n = e.block?.type;
|
|
397
|
+
return t.filter((e) => e.type === n).at(-1);
|
|
398
|
+
}
|
|
399
|
+
rootOf(e) {
|
|
400
|
+
return this.componentsOf(e).find((e) => e.parentId === null) ?? this.mainOf(e);
|
|
401
|
+
}
|
|
402
|
+
nameOf(e) {
|
|
403
|
+
return e.title.trim() === "" ? e.block?.type ?? e.origin : e.title;
|
|
404
|
+
}
|
|
405
|
+
missing(e) {
|
|
406
|
+
let t = this.input.capabilities;
|
|
407
|
+
if (t !== void 0) return e.find((e) => !t.includes(e));
|
|
408
|
+
}
|
|
409
|
+
componentNode(e) {
|
|
410
|
+
let t = `agent:c:${e}`;
|
|
411
|
+
return this.#r.has(t) || (this.#r.add(t), this.output.blueprint.nodes.push({
|
|
412
|
+
kind: "component",
|
|
413
|
+
id: t,
|
|
414
|
+
componentId: e
|
|
415
|
+
})), t;
|
|
416
|
+
}
|
|
417
|
+
edge(e) {
|
|
418
|
+
this.#t += 1, this.output.blueprint.edges.push({
|
|
419
|
+
kind: "flow",
|
|
420
|
+
id: `agent-edge-${this.#t}`,
|
|
421
|
+
...e
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
sourceEvent(e, t) {
|
|
425
|
+
let n = A(t, e.from), r = n === void 0 ? void 0 : this.mainOf(n);
|
|
426
|
+
if (n === void 0 || r === void 0) {
|
|
427
|
+
this.warn("AGENT_INTERACTION_SOURCE_UNKNOWN", e.origin, `No compiled block is addressed by "${e.from}".`);
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
let i = this.input.catalog.materials.find((e) => e.type === r.type), a = i?.events?.find((t) => t.name === e.event);
|
|
431
|
+
if (a === void 0) {
|
|
432
|
+
let t = (i?.events ?? []).map((e) => e.name).join(", ");
|
|
433
|
+
this.warn("AGENT_INTERACTION_EVENT_UNKNOWN", e.origin, `${r.type} has no event ${e.event}${t === "" ? " (it declares no events)" : ` (events: ${t})`}.`, { events: t });
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
436
|
+
return {
|
|
437
|
+
item: n,
|
|
438
|
+
component: r,
|
|
439
|
+
event: a
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
filter(e, t) {
|
|
443
|
+
let n = this.sourceEvent(e, t);
|
|
444
|
+
if (n === void 0) return;
|
|
445
|
+
let r = [
|
|
446
|
+
i.materialEvent,
|
|
447
|
+
i.eventPayload,
|
|
448
|
+
i.setVariable
|
|
449
|
+
];
|
|
450
|
+
e.reset === !0 && r.push(i.condition, i.variable);
|
|
451
|
+
let a = this.missing(r);
|
|
452
|
+
if (a !== void 0) {
|
|
453
|
+
this.warn("AGENT_INTERACTION_CAPABILITY_MISSING", e.origin, `The host has not granted ${a}; the interaction was not compiled.`, { capability: a });
|
|
454
|
+
return;
|
|
455
|
+
}
|
|
456
|
+
let o = this.payloadPath(e, n);
|
|
457
|
+
if (o === void 0) return;
|
|
458
|
+
let s = o[0] === "row" ? o[1] : o[0] === "x" ? ae(n.component) : o[0] === "value" ? ie(n.component) : void 0, c = M(n.item, s, this.input.references), l = [];
|
|
459
|
+
for (let n of e.to) {
|
|
460
|
+
let r = this.filterTarget(e, n, t);
|
|
461
|
+
r !== void 0 && l.push(r);
|
|
462
|
+
}
|
|
463
|
+
if (l.length === 0) return;
|
|
464
|
+
let u = `agent-var-${this.#e + 1}`, d = `agent:v:${u}`, f = `agent:c:${n.component.id}`, p = {
|
|
465
|
+
kind: "event-payload",
|
|
466
|
+
path: o
|
|
467
|
+
}, m = l.filter((t) => {
|
|
468
|
+
let r = this.simulateFilter({
|
|
469
|
+
interaction: e,
|
|
470
|
+
sourceComponentId: n.component.id,
|
|
471
|
+
sourceNode: f,
|
|
472
|
+
variableId: u,
|
|
473
|
+
variableNode: d,
|
|
474
|
+
edgeValue: p,
|
|
475
|
+
path: o,
|
|
476
|
+
values: c,
|
|
477
|
+
target: t
|
|
478
|
+
});
|
|
479
|
+
return r === "changes" || r === "unknown" || (this.warn("AGENT_INTERACTION_NO_EFFECT", e.origin, r === "not-allowed" ? `None of the source values is an allowed value of ${e.param} (${(t.parameter.allowedValues ?? []).join(", ")}).` : r === "failed" ? "Simulating the interaction failed; it was not compiled." : `Every source value equals the current ${e.param} (${String(t.initial)}); clicking would change nothing.`, {
|
|
480
|
+
target: this.nameOf(t.item),
|
|
481
|
+
param: e.param,
|
|
482
|
+
reason: r
|
|
483
|
+
}), !1);
|
|
484
|
+
});
|
|
485
|
+
if (m.length === 0) return;
|
|
486
|
+
this.#e += 1;
|
|
487
|
+
let h = m[0], g = this.nameOf(n.item), _ = m.map((e) => this.nameOf(e.item));
|
|
488
|
+
this.output.variables.push({
|
|
489
|
+
id: u,
|
|
490
|
+
name: oe(`${e.param}_${this.#e}`),
|
|
491
|
+
description: se(this.input.language === "en" ? `Set by clicking ${g}; filters ${_.join(", ")}` : `点「${g}」设置,筛选${_.map((e) => `「${e}」`).join("")}`, 120),
|
|
492
|
+
type: "static",
|
|
493
|
+
initialValue: h.initial
|
|
494
|
+
});
|
|
495
|
+
for (let t of m) {
|
|
496
|
+
let n = this.input.dataSources.find((e) => e.id === t.dataSourceId);
|
|
497
|
+
n !== void 0 && (n.params = {
|
|
498
|
+
...n.params,
|
|
499
|
+
[e.param]: {
|
|
500
|
+
kind: "variable",
|
|
501
|
+
variableId: u
|
|
502
|
+
}
|
|
503
|
+
}, this.input.components.filter((e) => e.dataValue?.dataSourceId === t.dataSourceId && this.input.sources[e.id] !== void 0 && !m.some((t) => t.item.origin === this.input.sources[e.id])).length > 0 && this.warn("INTENT_FILTER_SHARED_SOURCE", e.origin, `Other blocks read the same data source as ${this.nameOf(t.item)} and are filtered too.`, { target: this.nameOf(t.item) }));
|
|
504
|
+
}
|
|
505
|
+
this.#r.add(d), this.output.blueprint.nodes.push({
|
|
506
|
+
kind: "variable",
|
|
507
|
+
id: d,
|
|
508
|
+
variableId: u
|
|
509
|
+
});
|
|
510
|
+
let v = {
|
|
511
|
+
node: this.componentNode(n.component.id),
|
|
512
|
+
port: `event:${e.event}`
|
|
513
|
+
};
|
|
514
|
+
if (e.reset === !0) {
|
|
515
|
+
this.#n += 1;
|
|
516
|
+
let e = `agent:k:${this.#n}`;
|
|
517
|
+
this.#r.add(e), this.output.blueprint.nodes.push({
|
|
518
|
+
kind: "condition",
|
|
519
|
+
id: e,
|
|
520
|
+
name: this.input.language === "en" ? "Same item again?" : "再点同一项?",
|
|
521
|
+
condition: {
|
|
522
|
+
left: p,
|
|
523
|
+
operator: "eq",
|
|
524
|
+
right: {
|
|
525
|
+
kind: "variable",
|
|
526
|
+
variableId: u
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
}), this.edge({
|
|
530
|
+
from: v,
|
|
531
|
+
to: {
|
|
532
|
+
node: e,
|
|
533
|
+
port: "judge"
|
|
534
|
+
}
|
|
535
|
+
}), this.edge({
|
|
536
|
+
from: {
|
|
537
|
+
node: e,
|
|
538
|
+
port: "yes"
|
|
539
|
+
},
|
|
540
|
+
to: {
|
|
541
|
+
node: d,
|
|
542
|
+
port: "set"
|
|
543
|
+
},
|
|
544
|
+
value: {
|
|
545
|
+
kind: "literal",
|
|
546
|
+
value: h.initial
|
|
547
|
+
}
|
|
548
|
+
}), this.edge({
|
|
549
|
+
from: {
|
|
550
|
+
node: e,
|
|
551
|
+
port: "no"
|
|
552
|
+
},
|
|
553
|
+
to: {
|
|
554
|
+
node: d,
|
|
555
|
+
port: "set"
|
|
556
|
+
},
|
|
557
|
+
value: p
|
|
558
|
+
});
|
|
559
|
+
} else this.edge({
|
|
560
|
+
from: v,
|
|
561
|
+
to: {
|
|
562
|
+
node: d,
|
|
563
|
+
port: "set"
|
|
564
|
+
},
|
|
565
|
+
value: p
|
|
566
|
+
});
|
|
567
|
+
let y = e.reset === !0 ? this.input.language === "en" ? " (click again to reset)" : "(再点恢复)" : "";
|
|
568
|
+
this.output.behaviors.push({
|
|
569
|
+
kind: "filter",
|
|
570
|
+
origin: e.origin,
|
|
571
|
+
from: g,
|
|
572
|
+
to: _,
|
|
573
|
+
detail: this.input.language === "en" ? `${n.event.label ?? e.event} → filter by ${e.param}${y}` : `${n.event.label ?? e.event} → 按 ${e.param} 筛选${y}`
|
|
574
|
+
});
|
|
575
|
+
}
|
|
576
|
+
payloadPath(e, t) {
|
|
577
|
+
let n = t.event.payload, r = e.field;
|
|
578
|
+
if (n.row === "object") {
|
|
579
|
+
if (r === void 0) {
|
|
580
|
+
this.warn("AGENT_INTERACTION_FIELD_UNKNOWN", e.origin, `${e.event} carries a whole row; name the row field to filter by ("field").`);
|
|
581
|
+
return;
|
|
582
|
+
}
|
|
583
|
+
let n = ne(t.component);
|
|
584
|
+
if (n !== void 0 && !n.includes(r)) {
|
|
585
|
+
this.warn("AGENT_INTERACTION_FIELD_UNKNOWN", e.origin, `The source row has no field ${r} (fields: ${n.join(", ")}).`, { fields: n.join(", ") });
|
|
586
|
+
return;
|
|
587
|
+
}
|
|
588
|
+
return ["row", r];
|
|
589
|
+
}
|
|
590
|
+
if (r !== void 0 && n[r] !== void 0) return [r];
|
|
591
|
+
if (n.value !== void 0) return ["value"];
|
|
592
|
+
if (n.x !== void 0) return ["x"];
|
|
593
|
+
this.warn("AGENT_INTERACTION_EVENT_UNKNOWN", e.origin, `${e.event} carries no value that can drive a filter.`);
|
|
594
|
+
}
|
|
595
|
+
filterTarget(e, t, n) {
|
|
596
|
+
let r = A(n, t), i = r === void 0 ? void 0 : this.mainOf(r);
|
|
597
|
+
if (r === void 0 || i === void 0) {
|
|
598
|
+
this.warn("AGENT_INTERACTION_TARGET_UNKNOWN", e.origin, `No compiled block is addressed by "${t}".`);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
let a = i.dataValue, o = a?.kind === "data-source-field" && typeof a.dataSourceId == "string" ? a.dataSourceId : void 0, s = this.input.dataSources.find((e) => e.id === o), c = s?.source, l = c?.kind === "dataset" ? this.input.references?.datasets.find((e) => e.datasetId === c.datasetId) : void 0, u = l?.parameters?.find((t) => t.name === e.param);
|
|
602
|
+
if (o === void 0 || l === void 0 || u === void 0) {
|
|
603
|
+
this.warn("AGENT_INTERACTION_TARGET_INVALID", e.origin, `${this.nameOf(r)} does not read a dataset with parameter ${e.param}; filters only work through dataset parameters.`, {
|
|
604
|
+
target: this.nameOf(r),
|
|
605
|
+
param: e.param
|
|
606
|
+
});
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
let d = s?.params?.[e.param], f = N(d?.value) ? d.value : u.defaultValue;
|
|
610
|
+
if (f === void 0) {
|
|
611
|
+
this.warn("AGENT_INTERACTION_TARGET_INVALID", e.origin, `Parameter ${e.param} of ${this.nameOf(r)} has no starting value.`, {
|
|
612
|
+
target: this.nameOf(r),
|
|
613
|
+
param: e.param
|
|
614
|
+
});
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
return {
|
|
618
|
+
item: r,
|
|
619
|
+
dataSourceId: o,
|
|
620
|
+
initial: f,
|
|
621
|
+
parameter: u
|
|
622
|
+
};
|
|
623
|
+
}
|
|
624
|
+
simulateFilter(e) {
|
|
625
|
+
let { interaction: t, target: n, values: r } = e;
|
|
626
|
+
if (r === void 0 || r.length === 0) return "unknown";
|
|
627
|
+
let i = this.input.dataSources.find((e) => e.id === n.dataSourceId);
|
|
628
|
+
if (i === void 0) return "failed";
|
|
629
|
+
let a = {
|
|
630
|
+
canvas: {
|
|
631
|
+
width: 1920,
|
|
632
|
+
height: 1080,
|
|
633
|
+
backgroundColor: "#000000"
|
|
634
|
+
},
|
|
635
|
+
components: this.input.components,
|
|
636
|
+
variables: [{
|
|
637
|
+
id: e.variableId,
|
|
638
|
+
name: "probe",
|
|
639
|
+
type: "static",
|
|
640
|
+
initialValue: n.initial
|
|
641
|
+
}],
|
|
642
|
+
dataSources: [{
|
|
643
|
+
...i,
|
|
644
|
+
params: {
|
|
645
|
+
...i.params,
|
|
646
|
+
[t.param]: {
|
|
647
|
+
kind: "variable",
|
|
648
|
+
variableId: e.variableId
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
}],
|
|
652
|
+
blueprint: {
|
|
653
|
+
nodes: [{
|
|
654
|
+
kind: "component",
|
|
655
|
+
id: e.sourceNode,
|
|
656
|
+
componentId: e.sourceComponentId
|
|
657
|
+
}, {
|
|
658
|
+
kind: "variable",
|
|
659
|
+
id: e.variableNode,
|
|
660
|
+
variableId: e.variableId
|
|
661
|
+
}],
|
|
662
|
+
edges: [{
|
|
663
|
+
kind: "flow",
|
|
664
|
+
id: "agent-probe",
|
|
665
|
+
from: {
|
|
666
|
+
node: e.sourceNode,
|
|
667
|
+
port: `event:${t.event}`
|
|
668
|
+
},
|
|
669
|
+
to: {
|
|
670
|
+
node: e.variableNode,
|
|
671
|
+
port: "set"
|
|
672
|
+
},
|
|
673
|
+
value: e.edgeValue
|
|
674
|
+
}]
|
|
675
|
+
}
|
|
676
|
+
}, o = n.parameter.allowedValues, s = !1, l = !1;
|
|
677
|
+
for (let [i, u] of r.slice(0, 24).entries()) {
|
|
678
|
+
let r = c(a, {
|
|
679
|
+
componentId: e.sourceComponentId,
|
|
680
|
+
name: t.event,
|
|
681
|
+
payload: re(e.path, u, i)
|
|
682
|
+
});
|
|
683
|
+
if (!r.ok || r.value.failure !== void 0) return "failed";
|
|
684
|
+
let d = r.value.dataSourceChanges[n.dataSourceId]?.[t.param];
|
|
685
|
+
if (d === void 0) continue;
|
|
686
|
+
s = !0;
|
|
687
|
+
let f = d.after;
|
|
688
|
+
N(f) && (o === void 0 || o.includes(f)) && (l = !0);
|
|
689
|
+
}
|
|
690
|
+
return l ? "changes" : s ? "not-allowed" : "same";
|
|
691
|
+
}
|
|
692
|
+
show(e, t) {
|
|
693
|
+
let n = this.sourceEvent(e, t);
|
|
694
|
+
if (n === void 0) return;
|
|
695
|
+
let r = this.missing([i.materialEvent, i.componentVisibility]);
|
|
696
|
+
if (r !== void 0) {
|
|
697
|
+
this.warn("AGENT_INTERACTION_CAPABILITY_MISSING", e.origin, `The host has not granted ${r}; the interaction was not compiled.`, { capability: r });
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
let a = [];
|
|
701
|
+
for (let r of e.to) {
|
|
702
|
+
let i = A(t, r), o = i === void 0 ? void 0 : this.rootOf(i);
|
|
703
|
+
if (i === void 0 || o === void 0) {
|
|
704
|
+
this.warn("AGENT_INTERACTION_TARGET_UNKNOWN", e.origin, `No compiled block is addressed by "${r}".`);
|
|
705
|
+
continue;
|
|
706
|
+
}
|
|
707
|
+
if (i.origin === n.item.origin && e.mode !== "hide") {
|
|
708
|
+
this.warn("AGENT_INTERACTION_NO_EFFECT", e.origin, "A block cannot show or toggle itself.", {
|
|
709
|
+
target: this.nameOf(i),
|
|
710
|
+
reason: "self"
|
|
711
|
+
});
|
|
712
|
+
continue;
|
|
713
|
+
}
|
|
714
|
+
e.mode === "show" && (o.status = {
|
|
715
|
+
...o.status,
|
|
716
|
+
hidden: !0
|
|
717
|
+
}), this.edge({
|
|
718
|
+
from: {
|
|
719
|
+
node: this.componentNode(n.component.id),
|
|
720
|
+
port: `event:${e.event}`
|
|
721
|
+
},
|
|
722
|
+
to: {
|
|
723
|
+
node: this.componentNode(o.id),
|
|
724
|
+
port: e.mode
|
|
725
|
+
}
|
|
726
|
+
}), a.push(i);
|
|
727
|
+
}
|
|
728
|
+
if (a.length === 0) return;
|
|
729
|
+
let o = this.input.language === "en" ? {
|
|
730
|
+
show: "show",
|
|
731
|
+
hide: "hide",
|
|
732
|
+
toggle: "toggle"
|
|
733
|
+
}[e.mode] : {
|
|
734
|
+
show: "显示",
|
|
735
|
+
hide: "隐藏",
|
|
736
|
+
toggle: "切换显隐"
|
|
737
|
+
}[e.mode];
|
|
738
|
+
this.output.behaviors.push({
|
|
739
|
+
kind: "show",
|
|
740
|
+
origin: e.origin,
|
|
741
|
+
from: this.nameOf(n.item),
|
|
742
|
+
to: a.map((e) => this.nameOf(e)),
|
|
743
|
+
detail: `${n.event.label ?? e.event} → ${o}`
|
|
744
|
+
});
|
|
745
|
+
}
|
|
746
|
+
states(e, t) {
|
|
747
|
+
let n = t.states;
|
|
748
|
+
if (n === void 0) return;
|
|
749
|
+
let r = this.mainOf(e), i = r?.dataValue;
|
|
750
|
+
if (t.bind === void 0 || r === void 0 || i?.kind !== "data-source-field" || typeof i.dataSourceId != "string") {
|
|
751
|
+
this.warn("AGENT_STATE_NEEDS_DATA", e.origin, "Threshold states only apply to a KPI bound to a dataset field; a sample value is not real data.");
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
let a = this.input.references?.datasets.find((e) => e.datasetId === t.bind?.datasetId), s = t.bind.field, c = n.rules, l;
|
|
755
|
+
if (n.source === "level-scale") {
|
|
756
|
+
let t = a?.levelScales?.find((e) => e.path.length === 1 && e.path[0] === s);
|
|
757
|
+
if (t === void 0 || t.levels.length === 0) {
|
|
758
|
+
this.warn("AGENT_STATE_LEVEL_SCALE_UNAVAILABLE", e.origin, `The host declares no level scale for field ${s}; level states were not generated.`, {
|
|
759
|
+
target: e.title,
|
|
760
|
+
field: s
|
|
761
|
+
});
|
|
762
|
+
return;
|
|
763
|
+
}
|
|
764
|
+
l = t.levels.slice(0, 8).map((e) => e.value), c = t.levels.slice(0, 8).map((e) => ({
|
|
765
|
+
op: "eq",
|
|
766
|
+
value: typeof e.value == "boolean" ? String(e.value) : e.value,
|
|
767
|
+
tone: e.tone,
|
|
768
|
+
label: e.label
|
|
769
|
+
}));
|
|
770
|
+
} else {
|
|
771
|
+
let t = a?.columns.find((e) => e.id === s);
|
|
772
|
+
if (c.some((e) => e.op !== "eq" && e.op !== "neq") && t !== void 0 && t.type !== "number") {
|
|
773
|
+
this.warn("AGENT_STATE_FIELD_TYPE", e.origin, `Field ${s} is ${t.type}; compare it with eq / neq, not a numeric threshold.`);
|
|
774
|
+
return;
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
let u = this.input.catalog.materials.find((e) => e.type === r.type), f = u !== void 0 && "color" in u.defaults.style, p = (e) => {
|
|
778
|
+
let t = u?.statePreset === void 0 ? {} : d(u.statePreset, e);
|
|
779
|
+
return Object.keys(t).length > 0 ? t : f ? { color: o(e) } : {};
|
|
780
|
+
}, m = c.map((e, t) => ({
|
|
781
|
+
id: `agent-state-${t + 1}`,
|
|
782
|
+
name: e.label ?? ce(e.tone, this.input.language),
|
|
783
|
+
style: p(e.tone)
|
|
784
|
+
}));
|
|
785
|
+
this.#i.set(r.id, m.map((e, t) => ({
|
|
786
|
+
id: e.id,
|
|
787
|
+
name: e.name,
|
|
788
|
+
tone: c[t].tone
|
|
789
|
+
}))), r.states = {
|
|
790
|
+
items: m,
|
|
791
|
+
judge: {
|
|
792
|
+
input: {
|
|
793
|
+
kind: "data-source-field",
|
|
794
|
+
dataSourceId: i.dataSourceId,
|
|
795
|
+
path: [
|
|
796
|
+
"rows",
|
|
797
|
+
"0",
|
|
798
|
+
s
|
|
799
|
+
]
|
|
800
|
+
},
|
|
801
|
+
cases: c.map((e, t) => ({
|
|
802
|
+
operator: e.op,
|
|
803
|
+
value: l?.[t] ?? e.value,
|
|
804
|
+
stateId: `agent-state-${t + 1}`
|
|
805
|
+
}))
|
|
806
|
+
}
|
|
807
|
+
}, n.suggested === !0 && n.source !== "level-scale" && this.warn("INTENT_STATE_SUGGESTED", e.origin, `The thresholds of ${e.title} were suggested by the model; check them before adopting.`, { target: e.title });
|
|
808
|
+
let h = c.map((e) => ue(e, this.input.language)).join(";");
|
|
809
|
+
this.output.behaviors.push({
|
|
810
|
+
kind: "state",
|
|
811
|
+
origin: e.origin,
|
|
812
|
+
from: e.title,
|
|
813
|
+
to: [e.title],
|
|
814
|
+
detail: n.source === "level-scale" ? `${this.input.language === "en" ? "by host level scale: " : "按宿主分级表:"}${h}` : h,
|
|
815
|
+
...n.suggested === !0 && n.source !== "level-scale" ? { suggested: !0 } : {}
|
|
816
|
+
});
|
|
817
|
+
}
|
|
818
|
+
setState(e, t) {
|
|
819
|
+
let n = this.sourceEvent(e, t);
|
|
820
|
+
if (n === void 0) return;
|
|
821
|
+
let r = this.missing([i.materialEvent, i.componentState]);
|
|
822
|
+
if (r !== void 0) {
|
|
823
|
+
this.warn("AGENT_INTERACTION_CAPABILITY_MISSING", e.origin, `The host has not granted ${r}; the interaction was not compiled.`, { capability: r });
|
|
824
|
+
return;
|
|
825
|
+
}
|
|
826
|
+
let a = e.state.toLowerCase() === "reset", o = [], s = "";
|
|
827
|
+
for (let r of e.to) {
|
|
828
|
+
let i = A(t, r), c = i === void 0 ? void 0 : this.mainOf(i);
|
|
829
|
+
if (i === void 0 || c === void 0) {
|
|
830
|
+
this.warn("AGENT_INTERACTION_TARGET_UNKNOWN", e.origin, `No compiled block is addressed by "${r}".`);
|
|
831
|
+
continue;
|
|
832
|
+
}
|
|
833
|
+
let l = this.#i.get(c.id);
|
|
834
|
+
if (l === void 0 || l.length === 0) {
|
|
835
|
+
this.warn("AGENT_INTERACTION_TARGET_INVALID", e.origin, `${this.nameOf(i)} declares no states; give the KPI "states" first, then set one of them.`, {
|
|
836
|
+
target: this.nameOf(i),
|
|
837
|
+
reason: "no-states"
|
|
838
|
+
});
|
|
839
|
+
continue;
|
|
840
|
+
}
|
|
841
|
+
if (a) {
|
|
842
|
+
this.edge({
|
|
843
|
+
from: {
|
|
844
|
+
node: this.componentNode(n.component.id),
|
|
845
|
+
port: `event:${e.event}`
|
|
846
|
+
},
|
|
847
|
+
to: {
|
|
848
|
+
node: this.componentNode(c.id),
|
|
849
|
+
port: "reset-state"
|
|
850
|
+
}
|
|
851
|
+
}), o.push(i);
|
|
852
|
+
continue;
|
|
853
|
+
}
|
|
854
|
+
let u = e.state.trim(), d = l.find((e) => e.name === u) ?? l.find((e) => e.tone === u || ce(e.tone, this.input.language) === u);
|
|
855
|
+
if (d === void 0) {
|
|
856
|
+
let t = l.map((e) => e.name).join(", ");
|
|
857
|
+
this.warn("AGENT_INTERACTION_STATE_UNKNOWN", e.origin, `${this.nameOf(i)} has no state "${u}" (states: ${t}).`, {
|
|
858
|
+
target: this.nameOf(i),
|
|
859
|
+
states: t
|
|
860
|
+
});
|
|
861
|
+
continue;
|
|
862
|
+
}
|
|
863
|
+
s = d.name, this.edge({
|
|
864
|
+
from: {
|
|
865
|
+
node: this.componentNode(n.component.id),
|
|
866
|
+
port: `event:${e.event}`
|
|
867
|
+
},
|
|
868
|
+
to: {
|
|
869
|
+
node: this.componentNode(c.id),
|
|
870
|
+
port: "set-state"
|
|
871
|
+
},
|
|
872
|
+
stateId: d.id
|
|
873
|
+
}), o.push(i);
|
|
874
|
+
}
|
|
875
|
+
if (o.length === 0) return;
|
|
876
|
+
let c = this.input.language === "en", l = a ? c ? "reset the state of" : "恢复按判定显示" : c ? `set to "${s}":` : `设为「${s}」`;
|
|
877
|
+
this.output.behaviors.push({
|
|
878
|
+
kind: "set-state",
|
|
879
|
+
origin: e.origin,
|
|
880
|
+
from: this.nameOf(n.item),
|
|
881
|
+
to: o.map((e) => this.nameOf(e)),
|
|
882
|
+
detail: `${n.event.label ?? e.event} → ${l}`
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
function ne(e) {
|
|
887
|
+
let t = e.dataBinding?.fields;
|
|
888
|
+
if (t !== void 0) return Object.values(t).flatMap((e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : []);
|
|
889
|
+
let n = e.dataValue;
|
|
890
|
+
if (n?.kind === "inline" && Array.isArray(n.value?.fields)) return n.value.fields.map((e) => e.id).filter((e) => typeof e == "string");
|
|
891
|
+
}
|
|
892
|
+
function re(e, t, n) {
|
|
893
|
+
return e[0] === "row" && e[1] !== void 0 ? {
|
|
894
|
+
rowIndex: n,
|
|
895
|
+
row: { [e[1]]: t }
|
|
896
|
+
} : e[0] === void 0 ? {} : {
|
|
897
|
+
[e[0]]: t,
|
|
898
|
+
index: n
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
function ie(e) {
|
|
902
|
+
let t = e.dataBinding?.fields, n = t === void 0 ? void 0 : Object.values(t)[0];
|
|
903
|
+
return Array.isArray(n) && typeof n.at(-1) == "string" ? n.at(-1) : void 0;
|
|
904
|
+
}
|
|
905
|
+
function ae(e) {
|
|
906
|
+
let t = e.dataBinding?.fields;
|
|
907
|
+
if (t === void 0) return;
|
|
908
|
+
let n = t.dimension ?? Object.values(t)[0];
|
|
909
|
+
return Array.isArray(n) && typeof n[0] == "string" ? n[0] : void 0;
|
|
910
|
+
}
|
|
911
|
+
function oe(e) {
|
|
912
|
+
let t = e.replace(/[^A-Za-z0-9_]/g, "_").replace(/^[^A-Za-z_]+/, "");
|
|
913
|
+
return t === "" ? "agent_filter" : t.slice(0, 64);
|
|
914
|
+
}
|
|
915
|
+
function se(e, t) {
|
|
916
|
+
return e.length <= t ? e : `${e.slice(0, t - 1)}…`;
|
|
917
|
+
}
|
|
918
|
+
function ce(e, t) {
|
|
919
|
+
return t === "en" ? {
|
|
920
|
+
success: "Normal",
|
|
921
|
+
warning: "Warning",
|
|
922
|
+
danger: "Alert",
|
|
923
|
+
info: "Notice"
|
|
924
|
+
}[e] : {
|
|
925
|
+
success: "正常",
|
|
926
|
+
warning: "预警",
|
|
927
|
+
danger: "告警",
|
|
928
|
+
info: "提示"
|
|
929
|
+
}[e];
|
|
930
|
+
}
|
|
931
|
+
var le = {
|
|
932
|
+
gt: ">",
|
|
933
|
+
gte: "≥",
|
|
934
|
+
lt: "<",
|
|
935
|
+
lte: "≤",
|
|
936
|
+
eq: "=",
|
|
937
|
+
neq: "≠"
|
|
938
|
+
};
|
|
939
|
+
function ue(e, t) {
|
|
940
|
+
return `${le[e.op]} ${String(e.value)} ${e.label ?? ce(e.tone, t)}`;
|
|
941
|
+
}
|
|
942
|
+
//#endregion
|
|
943
|
+
//#region ../host-kit/dist/intent/intent-dataset.js
|
|
944
|
+
function de(e, t = {}) {
|
|
945
|
+
let n = e.parameters ?? [], r = Object.keys(t).filter((e) => {
|
|
946
|
+
let r = n.find((t) => t.name === e);
|
|
947
|
+
return r === void 0 || !fe(r, t[e]);
|
|
948
|
+
});
|
|
949
|
+
if (r.length > 0) return {
|
|
950
|
+
ok: !1,
|
|
951
|
+
missing: [],
|
|
952
|
+
invalid: r
|
|
953
|
+
};
|
|
954
|
+
let i = {}, a = [];
|
|
955
|
+
for (let e of n) {
|
|
956
|
+
let n = Object.hasOwn(t, e.name) ? t[e.name] : e.defaultValue;
|
|
957
|
+
n === void 0 ? e.required && a.push(e) : i[e.name] = {
|
|
958
|
+
kind: "inline",
|
|
959
|
+
value: n
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
return a.length > 0 ? {
|
|
963
|
+
ok: !1,
|
|
964
|
+
missing: a,
|
|
965
|
+
invalid: []
|
|
966
|
+
} : {
|
|
967
|
+
ok: !0,
|
|
968
|
+
params: i
|
|
969
|
+
};
|
|
970
|
+
}
|
|
971
|
+
function fe(e, t) {
|
|
972
|
+
let n = e.valueType;
|
|
973
|
+
return n === "number" && typeof t != "number" || n === "boolean" && typeof t != "boolean" || (n === "string" || n === "date") && typeof t != "string" ? !1 : e.allowedValues === void 0 || e.allowedValues.includes(t);
|
|
974
|
+
}
|
|
975
|
+
function pe(e, t, n) {
|
|
976
|
+
let r = new Map(t.columns.map((e) => [e.id, e])), i = {};
|
|
977
|
+
for (let [a, o] of Object.entries(n)) {
|
|
978
|
+
let n = e.roles.find((e) => e.id === a);
|
|
979
|
+
if (n === void 0) return {
|
|
980
|
+
ok: !1,
|
|
981
|
+
code: "AGENT_BINDING_FIELD_UNKNOWN",
|
|
982
|
+
message: `${e.type} has no binding role ${a}.`
|
|
983
|
+
};
|
|
984
|
+
for (let i of o) {
|
|
985
|
+
let o = r.get(i);
|
|
986
|
+
if (o === void 0) return {
|
|
987
|
+
ok: !1,
|
|
988
|
+
code: "AGENT_BINDING_FIELD_UNKNOWN",
|
|
989
|
+
message: `Dataset ${t.datasetId} has no field ${i}.`
|
|
990
|
+
};
|
|
991
|
+
if (n.valueTypes !== void 0 && !n.valueTypes.includes(o.type)) return {
|
|
992
|
+
ok: !1,
|
|
993
|
+
code: "AGENT_BINDING_TYPE_MISMATCH",
|
|
994
|
+
message: `Field ${i} (${o.type}) does not fit role ${a} of ${e.type}.`
|
|
995
|
+
};
|
|
996
|
+
}
|
|
997
|
+
if (o.length < n.min || o.length > n.max) return {
|
|
998
|
+
ok: !1,
|
|
999
|
+
code: "AGENT_BINDING_TYPE_MISMATCH",
|
|
1000
|
+
message: `Role ${a} of ${e.type} takes ${n.min}–${n.max} fields.`
|
|
1001
|
+
};
|
|
1002
|
+
i[a] = [...o];
|
|
1003
|
+
}
|
|
1004
|
+
let a = e.roles.find((e) => e.min > 0 && i[e.id] === void 0);
|
|
1005
|
+
return a === void 0 ? {
|
|
1006
|
+
ok: !0,
|
|
1007
|
+
fields: i
|
|
1008
|
+
} : {
|
|
1009
|
+
ok: !1,
|
|
1010
|
+
code: "AGENT_BINDING_FIELD_UNKNOWN",
|
|
1011
|
+
message: `Role ${a.id} of ${e.type} needs at least ${a.min} field(s).`
|
|
1012
|
+
};
|
|
1013
|
+
}
|
|
1014
|
+
function me(e, t, n) {
|
|
1015
|
+
let r = JSON.stringify(n);
|
|
1016
|
+
for (let n of e.dataSources) {
|
|
1017
|
+
let e = n.source;
|
|
1018
|
+
if (e?.kind === "dataset" && e.datasetId === t.datasetId && JSON.stringify(n.params) === r && typeof n.id == "string") return n.id;
|
|
1019
|
+
}
|
|
1020
|
+
let i = `agent-ds-${e.dataSources.length + 1}`;
|
|
1021
|
+
return e.dataSources.push({
|
|
1022
|
+
id: i,
|
|
1023
|
+
name: t.name,
|
|
1024
|
+
source: {
|
|
1025
|
+
kind: "dataset",
|
|
1026
|
+
datasetId: t.datasetId
|
|
1027
|
+
},
|
|
1028
|
+
params: n
|
|
1029
|
+
}), i;
|
|
1030
|
+
}
|
|
1031
|
+
function he(e, t) {
|
|
1032
|
+
let n = t[0];
|
|
1033
|
+
return {
|
|
1034
|
+
datasetId: e.datasetId,
|
|
1035
|
+
dataset: e.name,
|
|
1036
|
+
params: t.map((e) => e.name).join(", "),
|
|
1037
|
+
allowed: (n?.allowedValues ?? []).map((e) => String(e)).join(" / ")
|
|
1038
|
+
};
|
|
1039
|
+
}
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region ../host-kit/dist/intent/intent-block.js
|
|
1042
|
+
function ge(e, t, n, r) {
|
|
1043
|
+
let i = n.catalog.materials.find((t) => t.type === e.type);
|
|
1044
|
+
if (i === void 0) {
|
|
1045
|
+
r.sink.warnings.push(F("AGENT_MATERIAL_UNKNOWN", e, `The catalog has no material ${e.type}.`));
|
|
1046
|
+
return;
|
|
1047
|
+
}
|
|
1048
|
+
let a = _e(i, e, n, r);
|
|
1049
|
+
if (a === null) return;
|
|
1050
|
+
let o = n.textMaterial !== void 0 && i.type === n.textMaterial.type, s = (e.bind.kind === "text" ? e.bind.text : "").trim(), c = o && s !== "" && e.title.trim() === s, l = e.title.trim() !== "" && !c, u = l && (e.note ?? "").trim() !== "", d = l ? u ? 64 : 36 : 0;
|
|
1051
|
+
e.substituteFor !== void 0 && r.sink.warnings.push({
|
|
1052
|
+
severity: "warning",
|
|
1053
|
+
code: "INTENT_BLOCK_SUBSTITUTED",
|
|
1054
|
+
path: e.origin,
|
|
1055
|
+
message: `The model used "${i.name}" in place of "${e.substituteFor}", which the catalog does not offer.`,
|
|
1056
|
+
detail: {
|
|
1057
|
+
wanted: e.substituteFor,
|
|
1058
|
+
used: i.name
|
|
1059
|
+
}
|
|
1060
|
+
}), n.beginShell(e.title.trim() === "" ? i.name : e.title, t), l && (n.pushText("块标题", e.title, {
|
|
1061
|
+
x: t.x,
|
|
1062
|
+
y: t.y,
|
|
1063
|
+
width: t.width,
|
|
1064
|
+
height: 28
|
|
1065
|
+
}, {
|
|
1066
|
+
fontSize: 21,
|
|
1067
|
+
fontWeight: "700"
|
|
1068
|
+
}), u && n.pushText("块说明", e.note ?? "", {
|
|
1069
|
+
x: t.x,
|
|
1070
|
+
y: t.y + 30,
|
|
1071
|
+
width: t.width,
|
|
1072
|
+
height: 24
|
|
1073
|
+
}, {
|
|
1074
|
+
fontSize: 16,
|
|
1075
|
+
color: n.palette.muted
|
|
1076
|
+
}));
|
|
1077
|
+
let f = {
|
|
1078
|
+
x: t.x,
|
|
1079
|
+
y: t.y + d,
|
|
1080
|
+
width: t.width,
|
|
1081
|
+
height: t.height - d
|
|
1082
|
+
}, p = e.title.trim() === "" ? i.name : e.title, m = we(f), h = {
|
|
1083
|
+
...a.style ?? {},
|
|
1084
|
+
...Ce(i, e, m.height)
|
|
1085
|
+
};
|
|
1086
|
+
n.push(i, p, m, {
|
|
1087
|
+
props: xe(i, e.props),
|
|
1088
|
+
...a,
|
|
1089
|
+
...Object.keys(h).length === 0 ? {} : { style: h }
|
|
1090
|
+
}), n.endShell();
|
|
1091
|
+
}
|
|
1092
|
+
function _e(e, t, n, r) {
|
|
1093
|
+
let { sink: i } = r;
|
|
1094
|
+
if (e.data === "tabular") {
|
|
1095
|
+
if (t.bind.kind === "dataset") {
|
|
1096
|
+
let { datasetId: r } = t.bind, a = n.references?.datasets.find((e) => e.datasetId === r);
|
|
1097
|
+
if (a !== void 0) {
|
|
1098
|
+
let n = de(a, t.bind.params);
|
|
1099
|
+
if (!n.ok && n.invalid.length > 0) return i.warnings.push(F("AGENT_DATASET_PARAM_INVALID", t, `Parameter(s) ${n.invalid.join(", ")} of dataset ${r} are not declared or not allowed.`)), null;
|
|
1100
|
+
if (!n.ok) return i.warnings.push({
|
|
1101
|
+
...F("AGENT_DATASET_PARAM_REQUIRED", t, `Dataset ${r} requires parameter(s) ${n.missing.map((e) => e.name).join(", ")} without a default; the block is skipped.`),
|
|
1102
|
+
detail: he(a, n.missing)
|
|
1103
|
+
}), null;
|
|
1104
|
+
let o = t.bind.fields === void 0 ? void 0 : pe(e, a, t.bind.fields);
|
|
1105
|
+
if (o !== void 0 && !o.ok) return i.warnings.push(F(o.code, t, o.message)), null;
|
|
1106
|
+
let s = me(i, a, n.params);
|
|
1107
|
+
if (o !== void 0) return {
|
|
1108
|
+
dataValue: {
|
|
1109
|
+
kind: "data-source-field",
|
|
1110
|
+
dataSourceId: s,
|
|
1111
|
+
path: []
|
|
1112
|
+
},
|
|
1113
|
+
dataBinding: { fields: o.fields }
|
|
1114
|
+
};
|
|
1115
|
+
let c = ve(e, { columns: a.columns.map((e) => ({
|
|
1116
|
+
id: e.id,
|
|
1117
|
+
label: e.id,
|
|
1118
|
+
type: e.type === "number" ? "number" : "string"
|
|
1119
|
+
})) });
|
|
1120
|
+
return {
|
|
1121
|
+
dataValue: {
|
|
1122
|
+
kind: "data-source-field",
|
|
1123
|
+
dataSourceId: s,
|
|
1124
|
+
path: []
|
|
1125
|
+
},
|
|
1126
|
+
...c === null ? {} : { dataBinding: { fields: c } }
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
i.warnings.push(F("AGENT_DATASET_UNKNOWN", t, `Dataset ${r} is not part of this round's references; the block is skipped.`));
|
|
1130
|
+
}
|
|
1131
|
+
let r = t.bind.kind === "table" ? t.bind.table : void 0;
|
|
1132
|
+
if (r === void 0) return i.warnings.push(F("AGENT_BLOCK_DATA_MISSING", t, `${e.type} is a data material but no table was given.`)), null;
|
|
1133
|
+
let a = ve(e, r);
|
|
1134
|
+
return a === null ? (i.warnings.push(F("AGENT_BLOCK_BINDING_UNSATISFIED", t, `The binding roles of ${e.type} cannot be satisfied by these ${r.columns.length} columns; the block degraded to an empty one.`)), {}) : {
|
|
1135
|
+
dataValue: {
|
|
1136
|
+
kind: "inline",
|
|
1137
|
+
value: be(r),
|
|
1138
|
+
sample: !0
|
|
1139
|
+
},
|
|
1140
|
+
dataBinding: { fields: a }
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
if (e.data === "scalar") {
|
|
1144
|
+
if (t.bind.kind === "asset") {
|
|
1145
|
+
let { assetId: a } = t.bind, o = n.catalog.assets.find((e) => e.id === a);
|
|
1146
|
+
if (o === void 0) return i.warnings.push(F("AGENT_ASSET_UNKNOWN", t, `Asset ${a} is not in the host asset list.`)), null;
|
|
1147
|
+
let s = `agent-ds-${i.dataSources.length + 1}`;
|
|
1148
|
+
return i.dataSources.push({
|
|
1149
|
+
id: s,
|
|
1150
|
+
name: o.name,
|
|
1151
|
+
source: {
|
|
1152
|
+
kind: "host-resource",
|
|
1153
|
+
resourceType: "host_image",
|
|
1154
|
+
resourceId: o.id
|
|
1155
|
+
},
|
|
1156
|
+
params: {}
|
|
1157
|
+
}), r.onAsset(), {
|
|
1158
|
+
...typeof e.defaults.style.objectFit == "string" ? { style: { objectFit: "cover" } } : {},
|
|
1159
|
+
dataValue: {
|
|
1160
|
+
kind: "data-source-field",
|
|
1161
|
+
dataSourceId: s,
|
|
1162
|
+
path: []
|
|
1163
|
+
}
|
|
1164
|
+
};
|
|
1165
|
+
}
|
|
1166
|
+
if (e.asset) return i.warnings.push(F("AGENT_BLOCK_ASSET_REQUIRED", t, `${e.type} needs an assetId but only text was given; the block is skipped.`)), null;
|
|
1167
|
+
let a = t.bind.kind === "text" ? t.bind.text : "";
|
|
1168
|
+
return a === "" ? (i.warnings.push(F("AGENT_BLOCK_DATA_MISSING", t, `${e.type} is a value material but no text was given.`)), null) : {
|
|
1169
|
+
...n.textMaterial !== void 0 && e.type === n.textMaterial.type ? { style: Se(e, {
|
|
1170
|
+
fontSize: 18,
|
|
1171
|
+
color: n.palette.text,
|
|
1172
|
+
lineSpacing: a.includes("\n") ? 8 : 0
|
|
1173
|
+
}) } : {},
|
|
1174
|
+
dataValue: {
|
|
1175
|
+
kind: "inline",
|
|
1176
|
+
value: a
|
|
1177
|
+
}
|
|
1178
|
+
};
|
|
1179
|
+
}
|
|
1180
|
+
return {};
|
|
1181
|
+
}
|
|
1182
|
+
function F(e, t, n) {
|
|
1183
|
+
return {
|
|
1184
|
+
severity: "warning",
|
|
1185
|
+
code: e,
|
|
1186
|
+
path: t.origin,
|
|
1187
|
+
message: n
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
function ve(e, t) {
|
|
1191
|
+
if (e.roles.length === 0) return null;
|
|
1192
|
+
if (e.roles.every((e) => e.valueTypes !== void 0)) return ye(e, t);
|
|
1193
|
+
let n = t.columns.map((e) => e.id), r = t.columns.filter((e) => e.type === "number").map((e) => e.id), i = t.columns.filter((e) => e.type !== "number").map((e) => e.id), a = {};
|
|
1194
|
+
for (let t of e.roles) {
|
|
1195
|
+
let e = t.id.toLowerCase(), o;
|
|
1196
|
+
o = e === "columns" ? n : e === "dimension" ? i.length > 0 ? i : n : r.length > 0 ? r : n;
|
|
1197
|
+
let s = o.slice(0, t.max);
|
|
1198
|
+
if (s.length < t.min) return null;
|
|
1199
|
+
a[t.id] = s;
|
|
1200
|
+
}
|
|
1201
|
+
return a;
|
|
1202
|
+
}
|
|
1203
|
+
function ye(e, t) {
|
|
1204
|
+
let n = (e, t) => e.includes(t) || t === "string" && e.includes("date"), r = /* @__PURE__ */ new Set(), i = {};
|
|
1205
|
+
for (let a of e.roles) {
|
|
1206
|
+
let e = a.valueTypes ?? [], o = t.columns.filter((t) => n(e, t.type)), s;
|
|
1207
|
+
if (e.length === 1 && e[0] === "number") s = o.filter((e) => !r.has(e.id)).map((e) => e.id);
|
|
1208
|
+
else if (a.max === 1 && n(e, "string")) {
|
|
1209
|
+
let e = o.find((e) => e.type !== "number" && !r.has(e.id)) ?? o.find((e) => !r.has(e.id));
|
|
1210
|
+
s = e === void 0 ? [] : [e.id], e !== void 0 && r.add(e.id);
|
|
1211
|
+
} else s = o.map((e) => e.id);
|
|
1212
|
+
let c = s.slice(0, a.max);
|
|
1213
|
+
if (c.length < a.min) return null;
|
|
1214
|
+
i[a.id] = c;
|
|
1215
|
+
}
|
|
1216
|
+
return i;
|
|
1217
|
+
}
|
|
1218
|
+
function be(e) {
|
|
1219
|
+
return {
|
|
1220
|
+
fields: e.columns.map((e) => ({
|
|
1221
|
+
id: e.id,
|
|
1222
|
+
label: e.label,
|
|
1223
|
+
valueType: e.type,
|
|
1224
|
+
nullable: !1
|
|
1225
|
+
})),
|
|
1226
|
+
rows: e.rows.map((t) => {
|
|
1227
|
+
let n = {};
|
|
1228
|
+
for (let r of e.columns) n[r.id] = t[r.id] ?? null;
|
|
1229
|
+
return n;
|
|
1230
|
+
})
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
function xe(e, t) {
|
|
1234
|
+
if (t === void 0) return {};
|
|
1235
|
+
let n = {};
|
|
1236
|
+
for (let [r, i] of Object.entries(t)) {
|
|
1237
|
+
let t = e.props[r];
|
|
1238
|
+
if (t !== void 0) {
|
|
1239
|
+
if (t.kind === "enum") {
|
|
1240
|
+
typeof i == "string" && t.values?.includes(i) === !0 && (n[r] = i);
|
|
1241
|
+
continue;
|
|
1242
|
+
}
|
|
1243
|
+
if (t.kind === "number") {
|
|
1244
|
+
typeof i == "number" && Number.isFinite(i) && (n[r] = i);
|
|
1245
|
+
continue;
|
|
1246
|
+
}
|
|
1247
|
+
if (t.kind === "boolean") {
|
|
1248
|
+
typeof i == "boolean" && (n[r] = i);
|
|
1249
|
+
continue;
|
|
1250
|
+
}
|
|
1251
|
+
typeof i == "string" && (n[r] = i.slice(0, 160));
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1254
|
+
return n;
|
|
1255
|
+
}
|
|
1256
|
+
function Se(e, t) {
|
|
1257
|
+
let n = e.defaults.style, r = {};
|
|
1258
|
+
return t.fontSize !== void 0 && "fontSize" in n && (r.fontSize = t.fontSize), t.fontWeight !== void 0 && "fontWeight" in n && (r.fontWeight = t.fontWeight), t.color !== void 0 && "color" in n && (r.color = t.color), t.lineSpacing !== void 0 && "lineSpacing" in n && (r.lineSpacing = t.lineSpacing), r;
|
|
1259
|
+
}
|
|
1260
|
+
function Ce(e, t, n) {
|
|
1261
|
+
if (!("rowHeight" in e.defaults.style)) return {};
|
|
1262
|
+
let r = t.bind.kind === "table" ? t.bind.table.rows.length : 0;
|
|
1263
|
+
if (r === 0) return {};
|
|
1264
|
+
let i = e.defaults.style.rowHeight, a = typeof i == "number" && i > 0 ? i : 32, o = Math.floor((n - 4) / (r + 1));
|
|
1265
|
+
return { rowHeight: Math.min(a, Math.max(20, o)) };
|
|
1266
|
+
}
|
|
1267
|
+
function we(e) {
|
|
1268
|
+
return {
|
|
1269
|
+
x: e.x + 16,
|
|
1270
|
+
y: e.y + 16,
|
|
1271
|
+
width: Math.max(1, e.width - 32),
|
|
1272
|
+
height: Math.max(1, e.height - 32)
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
//#endregion
|
|
1276
|
+
//#region ../host-kit/dist/intent/intent-catalog.js
|
|
1277
|
+
function Te(e) {
|
|
1278
|
+
return e.materials.find((e) => e.data === "scalar" && typeof e.defaults.style.fontSize == "number");
|
|
1279
|
+
}
|
|
1280
|
+
var Ee = /(?:^|[-.])(?:ellipse|oval|circle|triangle|polygon|star|arrow|line|rule|connector|divider)(?:$|[-.])/i, De = /(?:^|[-.])(?:rectangle|rect|card|panel|surface|box|frame|tile)(?:$|[-.])/i, Oe = /(椭圆|圆形|圆|三角|多边形|星形|箭头|线条|连线|分隔线)/, ke = /(矩形|方形|底板|卡片|面板|背景|容器|框架|色块)/;
|
|
1281
|
+
function Ae(e) {
|
|
1282
|
+
let t, n = -1;
|
|
1283
|
+
for (let r of e.materials) {
|
|
1284
|
+
if (r.data !== "none" || r.children === !0 || typeof r.defaults.style.fill != "string" || Ee.test(r.type) || Oe.test(r.name)) continue;
|
|
1285
|
+
let e = 0;
|
|
1286
|
+
/(?:^|[-.])rect(?:angle)?(?:$|[-.])/i.test(r.type) && (e += 4), De.test(r.type) && (e += 2), r.name.includes("矩形") && (e += 3), ke.test(r.name) && (e += 1), "borderRadius" in r.defaults.style && (e += 1), e > n && (t = r, n = e);
|
|
1287
|
+
}
|
|
1288
|
+
return t;
|
|
1289
|
+
}
|
|
1290
|
+
function je(e) {
|
|
1291
|
+
return e.materials.find((e) => e.children === !0 && e.data === "none");
|
|
1292
|
+
}
|
|
1293
|
+
//#endregion
|
|
1294
|
+
//#region ../host-kit/dist/intent/intent-format.js
|
|
1295
|
+
var Me = "—", Ne = /^(?:[万亿千]|[KMBk](?![a-z]))/;
|
|
1296
|
+
function I(...e) {
|
|
1297
|
+
return /[⺀-鿿豈--]/.test(e.join("")) ? "zh" : "en";
|
|
1298
|
+
}
|
|
1299
|
+
function L(e, t = "zh") {
|
|
1300
|
+
if (e.value === null) return Me;
|
|
1301
|
+
let n = e.unit ?? "", r = Math.abs(e.value), [i, a] = n === "%" || Ne.test(n) ? [e.value, ""] : t === "en" ? r >= 1e9 ? [e.value / 1e9, "B"] : r >= 1e6 ? [e.value / 1e6, "M"] : [e.value, ""] : r >= 1e8 ? [e.value / 1e8, "亿"] : r >= 1e4 ? [e.value / 1e4, "万"] : [e.value, ""], o = e.precision ?? (a === "" ? Number.isInteger(i) ? 0 : Math.min(2, Le(i)) : 1), s = ze(i.toFixed(o));
|
|
1302
|
+
if (n === "%") return `${s}%`;
|
|
1303
|
+
if (t === "en") return n === "" ? `${s}${a}` : `${s}${a} ${n}`;
|
|
1304
|
+
let c = `${a}${n}`;
|
|
1305
|
+
return c === "" ? s : `${s} ${c}`;
|
|
1306
|
+
}
|
|
1307
|
+
function Pe(e, t = "zh") {
|
|
1308
|
+
let n = e.delta;
|
|
1309
|
+
if (n === void 0) return "";
|
|
1310
|
+
let r = Fe(n) ? "" : n.value > 0 ? "+" : "-", i = Math.abs(n.value);
|
|
1311
|
+
return n.unit === "percent" ? `${r}${Re(i.toFixed(1))}%` : n.unit === "point" ? `${r}${Re(i.toFixed(1))}${t === "en" ? " pp" : " 个百分点"}` : `${r}${L({
|
|
1312
|
+
value: i,
|
|
1313
|
+
...e.unit === void 0 ? {} : { unit: e.unit }
|
|
1314
|
+
}, t)}`;
|
|
1315
|
+
}
|
|
1316
|
+
function Fe(e) {
|
|
1317
|
+
return e.value === 0 || e.unit !== "absolute" && Number(Math.abs(e.value).toFixed(1)) === 0;
|
|
1318
|
+
}
|
|
1319
|
+
function Ie(e, t) {
|
|
1320
|
+
return e.direction === "neutral" || Fe(e) ? t.muted : e.direction === "up-good" == e.value > 0 ? "theme:success" : "theme:danger";
|
|
1321
|
+
}
|
|
1322
|
+
function Le(e) {
|
|
1323
|
+
let t = String(e), n = t.indexOf(".");
|
|
1324
|
+
return n < 0 ? 0 : t.length - n - 1;
|
|
1325
|
+
}
|
|
1326
|
+
function Re(e) {
|
|
1327
|
+
return e.includes(".") ? e.replace(/\.?0+$/, "") : e;
|
|
1328
|
+
}
|
|
1329
|
+
function ze(e) {
|
|
1330
|
+
let [t, n] = e.split("."), r = (t ?? "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
|
|
1331
|
+
return n === void 0 ? r : `${r}.${n}`;
|
|
1332
|
+
}
|
|
1333
|
+
//#endregion
|
|
1334
|
+
//#region ../host-kit/dist/intent/intent-kpi-bind.js
|
|
1335
|
+
function Be(e, t, n) {
|
|
1336
|
+
let r = e.bind;
|
|
1337
|
+
if (r === void 0) return !1;
|
|
1338
|
+
let i = (t, r, i) => (n.sink.warnings.push({
|
|
1339
|
+
severity: "warning",
|
|
1340
|
+
code: t,
|
|
1341
|
+
path: e.origin,
|
|
1342
|
+
message: r,
|
|
1343
|
+
...i === void 0 ? {} : { detail: i }
|
|
1344
|
+
}), !1), a = n.references?.datasets.find((e) => e.datasetId === r.datasetId);
|
|
1345
|
+
if (a === void 0) return i("AGENT_DATASET_UNKNOWN", `Dataset ${r.datasetId} is not part of this round's references; the KPI shows a placeholder.`);
|
|
1346
|
+
let o = a.columns.find((e) => e.id === r.field);
|
|
1347
|
+
if (o === void 0) return i("AGENT_BINDING_FIELD_UNKNOWN", `Dataset ${a.datasetId} has no field ${r.field}.`);
|
|
1348
|
+
if (a.rows !== void 0 && (a.rows.sampled > 1 || (a.rows.total ?? 0) > 1)) return i("AGENT_KPI_MULTI_ROW", `Dataset ${a.datasetId} returns more than one row; a KPI card only shows the first row. Use a chart or table block instead.`);
|
|
1349
|
+
let s = n.textMaterial, c = s?.roles[0];
|
|
1350
|
+
if (s === void 0 || c === void 0 || c.valueTypes !== void 0 && !c.valueTypes.includes(o.type)) return i("AGENT_KPI_BIND_UNSUPPORTED", "The catalog has no text material that can read a dataset field.");
|
|
1351
|
+
let l = de(a, r.params);
|
|
1352
|
+
if (!l.ok && l.invalid.length > 0) return i("AGENT_DATASET_PARAM_INVALID", `Parameter(s) ${l.invalid.join(", ")} of dataset ${a.datasetId} are not declared or not allowed.`);
|
|
1353
|
+
if (!l.ok) return i("AGENT_DATASET_PARAM_REQUIRED", `Dataset ${a.datasetId} requires parameter(s) ${l.missing.map((e) => e.name).join(", ")} without a default; the KPI shows a placeholder.`, he(a, l.missing));
|
|
1354
|
+
let u = me(n.sink, a, l.params), d = e.unit ?? o.unit ?? "", f = d === "" ? e.label : n.language === "en" ? `${e.label} (${d})` : `${e.label}(${d})`;
|
|
1355
|
+
return n.pushText("指标名", f, t.label, {
|
|
1356
|
+
fontSize: 18,
|
|
1357
|
+
color: n.palette.muted
|
|
1358
|
+
}), n.push(s, "指标值", t.value, {
|
|
1359
|
+
style: Se(s, {
|
|
1360
|
+
fontSize: 42,
|
|
1361
|
+
fontWeight: "700",
|
|
1362
|
+
color: n.palette.text
|
|
1363
|
+
}),
|
|
1364
|
+
dataValue: {
|
|
1365
|
+
kind: "data-source-field",
|
|
1366
|
+
dataSourceId: u,
|
|
1367
|
+
path: []
|
|
1368
|
+
},
|
|
1369
|
+
dataBinding: { fields: { [c.id]: [r.field] } }
|
|
1370
|
+
}), !0;
|
|
1371
|
+
}
|
|
1372
|
+
//#endregion
|
|
1373
|
+
//#region ../host-kit/dist/intent/intent-layout.js
|
|
1374
|
+
var Ve = 1920, He = 1080, Ue = 1026, We = 1.35, Ge = 1792, Ke = 430;
|
|
1375
|
+
function qe(e) {
|
|
1376
|
+
let t = [], n = 24 * Math.max(0, e.length - 1), r = e.map(Je);
|
|
1377
|
+
for (let [e, n] of r.entries()) if (n.kind === "band") {
|
|
1378
|
+
let r = $e(n.count);
|
|
1379
|
+
n.count > 0 && r < 240 && t.push({
|
|
1380
|
+
regionIndex: e,
|
|
1381
|
+
reason: "width",
|
|
1382
|
+
requiredPx: 240 * n.count + 24 * (n.count - 1),
|
|
1383
|
+
availablePx: Ge
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
let i = r.reduce((e, t) => e + (t.kind === "band" ? t.height : 0), 0), a = r.flatMap((e, t) => e.kind === "band" ? [] : [{
|
|
1387
|
+
plan: e,
|
|
1388
|
+
index: t
|
|
1389
|
+
}]), o = 838 - n - i, s = a.reduce((e, t) => e + t.plan.minHeight, 0);
|
|
1390
|
+
if (a.length > 0 && s > o) {
|
|
1391
|
+
let e = a.reduce((e, t) => t.plan.minHeight > e.plan.minHeight ? t : e);
|
|
1392
|
+
t.push({
|
|
1393
|
+
regionIndex: e.index,
|
|
1394
|
+
reason: "height",
|
|
1395
|
+
requiredPx: s,
|
|
1396
|
+
availablePx: o
|
|
1397
|
+
});
|
|
1398
|
+
}
|
|
1399
|
+
if (t.length > 0) return {
|
|
1400
|
+
ok: !1,
|
|
1401
|
+
issues: t
|
|
1402
|
+
};
|
|
1403
|
+
let c = /* @__PURE__ */ new Map();
|
|
1404
|
+
if (a.length > 0) {
|
|
1405
|
+
let e = a.reduce((e, t) => e + t.plan.weight, 0) || 1, t = a.map((t) => Math.max(t.plan.minHeight, Math.floor(o * t.plan.weight / e))), n = t.reduce((e, t) => e + t, 0) - o;
|
|
1406
|
+
for (; n > 0;) {
|
|
1407
|
+
let e = 0;
|
|
1408
|
+
t.forEach((n, r) => {
|
|
1409
|
+
n > (t[e] ?? 0) && (e = r);
|
|
1410
|
+
});
|
|
1411
|
+
let r = (t[e] ?? 0) - (a[e]?.plan.minHeight ?? 0);
|
|
1412
|
+
if (r <= 0) break;
|
|
1413
|
+
let i = Math.min(r, n);
|
|
1414
|
+
t[e] = (t[e] ?? 0) - i, n -= i;
|
|
1415
|
+
}
|
|
1416
|
+
a.forEach((e, n) => c.set(e.index, t[n] ?? e.plan.minHeight));
|
|
1417
|
+
}
|
|
1418
|
+
let l = [], u = 172;
|
|
1419
|
+
for (let [e, t] of r.entries()) {
|
|
1420
|
+
let n = t.kind === "band" ? t.height : c.get(e) ?? t.minHeight;
|
|
1421
|
+
l.push(Ze(t, u, n)), u += n + 24;
|
|
1422
|
+
}
|
|
1423
|
+
return {
|
|
1424
|
+
ok: !0,
|
|
1425
|
+
regions: l
|
|
1426
|
+
};
|
|
1427
|
+
}
|
|
1428
|
+
function Je(e) {
|
|
1429
|
+
if (e.kind === "band") return {
|
|
1430
|
+
kind: "band",
|
|
1431
|
+
count: e.count,
|
|
1432
|
+
height: 148
|
|
1433
|
+
};
|
|
1434
|
+
if (e.kind === "grid") {
|
|
1435
|
+
let t = tt(e.slots.map((e, t) => ({
|
|
1436
|
+
...e,
|
|
1437
|
+
index: t
|
|
1438
|
+
})));
|
|
1439
|
+
return {
|
|
1440
|
+
kind: "grid",
|
|
1441
|
+
rows: t,
|
|
1442
|
+
weight: t.reduce((e, t) => e + Ye(t), 0),
|
|
1443
|
+
minHeight: Xe(t.length)
|
|
1444
|
+
};
|
|
1445
|
+
}
|
|
1446
|
+
let t = (e) => e.reduce((e, t) => e + (t.data ? We : 1), 0);
|
|
1447
|
+
return {
|
|
1448
|
+
kind: "split",
|
|
1449
|
+
region: e,
|
|
1450
|
+
weight: Math.max(t(e.main), t(e.rail)),
|
|
1451
|
+
minHeight: Xe(Math.max(e.main.length, e.rail.length))
|
|
1452
|
+
};
|
|
1453
|
+
}
|
|
1454
|
+
function Ye(e) {
|
|
1455
|
+
return e.some((e) => e.data) ? We : 1;
|
|
1456
|
+
}
|
|
1457
|
+
function Xe(e) {
|
|
1458
|
+
return e === 0 ? 0 : 120 * e + 24 * (e - 1);
|
|
1459
|
+
}
|
|
1460
|
+
function Ze(e, t, n) {
|
|
1461
|
+
if (e.kind === "band") {
|
|
1462
|
+
let r = $e(e.count), i = [];
|
|
1463
|
+
for (let a = 0; a < e.count; a += 1) i.push({
|
|
1464
|
+
x: 64 + a * (r + 24),
|
|
1465
|
+
y: t,
|
|
1466
|
+
width: r,
|
|
1467
|
+
height: n
|
|
1468
|
+
});
|
|
1469
|
+
return {
|
|
1470
|
+
kind: "band",
|
|
1471
|
+
boxes: i
|
|
1472
|
+
};
|
|
1473
|
+
}
|
|
1474
|
+
if (e.kind === "grid") {
|
|
1475
|
+
let r = rt(e.rows, n - 24 * (e.rows.length - 1)), i = Array(e.rows.reduce((e, t) => e + t.length, 0)), a = t;
|
|
1476
|
+
return e.rows.forEach((e, t) => {
|
|
1477
|
+
let n = nt(e), o = r[t] ?? 120, s = 0;
|
|
1478
|
+
e.forEach((e, t) => {
|
|
1479
|
+
let r = n[t] ?? 1;
|
|
1480
|
+
i[e.index] = {
|
|
1481
|
+
x: 64 + s * 454,
|
|
1482
|
+
y: a,
|
|
1483
|
+
width: Ke * r + 24 * (r - 1),
|
|
1484
|
+
height: o
|
|
1485
|
+
}, s += r;
|
|
1486
|
+
}), a += o + 24;
|
|
1487
|
+
}), {
|
|
1488
|
+
kind: "grid",
|
|
1489
|
+
boxes: i
|
|
1490
|
+
};
|
|
1491
|
+
}
|
|
1492
|
+
let { region: r } = e, i = r.ratio === "even" ? 884 : Ke, a = r.ratio === "even" ? i : 1768 - i, o = r.railSide === "left" ? 64 + i + 24 : 64, s = r.railSide === "left" ? 64 : 64 + a + 24;
|
|
1493
|
+
return {
|
|
1494
|
+
kind: "split",
|
|
1495
|
+
main: Qe(r.main, o, t, a, n),
|
|
1496
|
+
rail: Qe(r.rail, s, t, i, n)
|
|
1497
|
+
};
|
|
1498
|
+
}
|
|
1499
|
+
function Qe(e, t, n, r, i) {
|
|
1500
|
+
let a = e.map((e, t) => [{
|
|
1501
|
+
data: e.data,
|
|
1502
|
+
index: t
|
|
1503
|
+
}]), o = rt(a, i - 24 * (a.length - 1)), s = [], c = n;
|
|
1504
|
+
for (let [e, n] of o.entries()) s[e] = {
|
|
1505
|
+
x: t,
|
|
1506
|
+
y: c,
|
|
1507
|
+
width: r,
|
|
1508
|
+
height: n
|
|
1509
|
+
}, c += n + 24;
|
|
1510
|
+
return s;
|
|
1511
|
+
}
|
|
1512
|
+
function $e(e) {
|
|
1513
|
+
return e <= 0 ? 0 : Math.floor((Ge - 24 * (e - 1)) / e);
|
|
1514
|
+
}
|
|
1515
|
+
function et(e) {
|
|
1516
|
+
return Number.isFinite(e) ? Math.min(4, Math.max(1, Math.round(e))) : 1;
|
|
1517
|
+
}
|
|
1518
|
+
function tt(e) {
|
|
1519
|
+
let t = [], n = [], r = 0;
|
|
1520
|
+
for (let i of e) {
|
|
1521
|
+
let e = et(i.span);
|
|
1522
|
+
r + e > 4 && n.length > 0 && (t.push(n), n = [], r = 0), n.push(i), r += e;
|
|
1523
|
+
}
|
|
1524
|
+
return n.length > 0 && t.push(n), t;
|
|
1525
|
+
}
|
|
1526
|
+
function nt(e) {
|
|
1527
|
+
let t = e.map((e) => et(e.span)), n = 4 - t.reduce((e, t) => e + t, 0);
|
|
1528
|
+
if (n <= 0 || t.length === 0) return t;
|
|
1529
|
+
let r = t.map((e, t) => ({
|
|
1530
|
+
span: e,
|
|
1531
|
+
index: t
|
|
1532
|
+
})).sort((e, t) => t.span - e.span || e.index - t.index).map((e) => e.index), i = 0;
|
|
1533
|
+
for (; n > 0;) {
|
|
1534
|
+
let e = r[i % r.length];
|
|
1535
|
+
t[e] = (t[e] ?? 1) + 1, --n, i += 1;
|
|
1536
|
+
}
|
|
1537
|
+
return t;
|
|
1538
|
+
}
|
|
1539
|
+
function rt(e, t) {
|
|
1540
|
+
if (e.length === 0) return [];
|
|
1541
|
+
let n = Math.max(120, Math.min(200, Math.floor(t / e.length))), r = e.map(Ye), i = r.reduce((e, t) => e + t, 0) || 1, a = r.map((e) => Math.max(n, Math.floor(t * e / i))), o = a.reduce((e, t) => e + t, 0) - t;
|
|
1542
|
+
for (; o > 0;) {
|
|
1543
|
+
let e = 0;
|
|
1544
|
+
a.forEach((t, n) => {
|
|
1545
|
+
t > (a[e] ?? 0) && (e = n);
|
|
1546
|
+
});
|
|
1547
|
+
let t = (a[e] ?? 0) - n;
|
|
1548
|
+
if (t <= 0) break;
|
|
1549
|
+
let r = Math.min(t, o);
|
|
1550
|
+
a[e] = (a[e] ?? 0) - r, o -= r;
|
|
1551
|
+
}
|
|
1552
|
+
return a;
|
|
1553
|
+
}
|
|
1554
|
+
//#endregion
|
|
1555
|
+
//#region ../host-kit/dist/intent/intent-style.js
|
|
1556
|
+
var it = [
|
|
1557
|
+
"deep-tech",
|
|
1558
|
+
"light-biz",
|
|
1559
|
+
"warm-care",
|
|
1560
|
+
"ink-finance"
|
|
1561
|
+
], at = {
|
|
1562
|
+
"deep-tech": {
|
|
1563
|
+
id: "deep-tech",
|
|
1564
|
+
label: "深色科技(深蓝底、冷色强调,适合监控、实时、指挥类)",
|
|
1565
|
+
palette: {
|
|
1566
|
+
canvas: "#0b1020",
|
|
1567
|
+
card: "#141b24",
|
|
1568
|
+
text: "#e9eef5",
|
|
1569
|
+
muted: "#c6d3e4",
|
|
1570
|
+
accent: "#4fcb6f",
|
|
1571
|
+
footer: "#8a97a8"
|
|
1572
|
+
}
|
|
1573
|
+
},
|
|
1574
|
+
"light-biz": {
|
|
1575
|
+
id: "light-biz",
|
|
1576
|
+
label: "浅色商务(浅灰底、白卡片、蓝色强调,适合经营分析、财务、报表类)",
|
|
1577
|
+
palette: {
|
|
1578
|
+
canvas: "#f4f6fa",
|
|
1579
|
+
card: "#ffffff",
|
|
1580
|
+
text: "#0f172a",
|
|
1581
|
+
muted: "#4a5a70",
|
|
1582
|
+
accent: "#1a63c4",
|
|
1583
|
+
footer: "#5b6b82"
|
|
1584
|
+
}
|
|
1585
|
+
},
|
|
1586
|
+
"warm-care": {
|
|
1587
|
+
id: "warm-care",
|
|
1588
|
+
label: "暖色人文(深棕底、暖色强调,适合医疗、民生、服务类)",
|
|
1589
|
+
palette: {
|
|
1590
|
+
canvas: "#1f1a17",
|
|
1591
|
+
card: "#2a221e",
|
|
1592
|
+
text: "#f6efe8",
|
|
1593
|
+
muted: "#d9c7b5",
|
|
1594
|
+
accent: "#f0a04b",
|
|
1595
|
+
footer: "#b3a291"
|
|
1596
|
+
}
|
|
1597
|
+
},
|
|
1598
|
+
"ink-finance": {
|
|
1599
|
+
id: "ink-finance",
|
|
1600
|
+
label: "墨黑金(黑底、金色强调,适合高管看板、汇总、战略类)",
|
|
1601
|
+
palette: {
|
|
1602
|
+
canvas: "#0e1116",
|
|
1603
|
+
card: "#171c24",
|
|
1604
|
+
text: "#eef1f5",
|
|
1605
|
+
muted: "#b8c2d1",
|
|
1606
|
+
accent: "#e8b84a",
|
|
1607
|
+
footer: "#8f9aab"
|
|
1608
|
+
}
|
|
1609
|
+
}
|
|
1610
|
+
}, ot = "deep-tech";
|
|
1611
|
+
function st(e) {
|
|
1612
|
+
if (typeof e == "string") {
|
|
1613
|
+
let t = it.find((t) => t === e.trim());
|
|
1614
|
+
if (t !== void 0) return at[t];
|
|
1615
|
+
}
|
|
1616
|
+
return at[ot];
|
|
1617
|
+
}
|
|
1618
|
+
//#endregion
|
|
1619
|
+
//#region ../host-kit/dist/intent/intent-compile.js
|
|
1620
|
+
var ct = 5, lt = 20;
|
|
1621
|
+
function ut(e) {
|
|
1622
|
+
let { catalog: t, references: n, stream: r } = e, i = r === void 0 ? ee(e.intent, n) : void 0, a = i?.intent ?? e.intent, o = st(a.style).palette, s = I(a.title, a.subtitle), c = {
|
|
1623
|
+
diagnostics: [],
|
|
1624
|
+
warnings: [...i?.warnings ?? []],
|
|
1625
|
+
dataSources: []
|
|
1626
|
+
}, l = r === void 0 ? pt(a) : mt(r), u = qe(l.map((e) => e.layout));
|
|
1627
|
+
if (!u.ok) return {
|
|
1628
|
+
ok: !1,
|
|
1629
|
+
diagnostics: u.issues.map((e) => gt(e, l))
|
|
1630
|
+
};
|
|
1631
|
+
let d = [], f = {}, p = "", m = "", h = (e, t = e) => {
|
|
1632
|
+
p = e, m = t;
|
|
1633
|
+
}, g = /* @__PURE__ */ new Set(), _ = /* @__PURE__ */ new Map(), v = 0, y = Te(t), b = Ae(t), x = je(t), S = null, C = !1, w = (e, t, n, r = {}) => {
|
|
1634
|
+
let i = r.pending === !0, a = wt(p), o = i ? a.pendingOffset : _.get(p) ?? 0;
|
|
1635
|
+
i || _.set(p, o + 1);
|
|
1636
|
+
let s = i ? `agent-${a.key}-pending` : `agent-${a.key}-${o}`;
|
|
1637
|
+
return f[s] = m, d.push({
|
|
1638
|
+
id: s,
|
|
1639
|
+
type: e.type,
|
|
1640
|
+
name: t,
|
|
1641
|
+
parentId: r.parentId === void 0 ? S : r.parentId,
|
|
1642
|
+
position: {
|
|
1643
|
+
x: Math.round(n.x),
|
|
1644
|
+
y: Math.round(n.y)
|
|
1645
|
+
},
|
|
1646
|
+
size: {
|
|
1647
|
+
width: Math.max(1, Math.round(n.width)),
|
|
1648
|
+
height: Math.max(1, Math.round(n.height))
|
|
1649
|
+
},
|
|
1650
|
+
rotation: 0,
|
|
1651
|
+
zIndex: a.layer + o,
|
|
1652
|
+
status: {
|
|
1653
|
+
locked: !1,
|
|
1654
|
+
hidden: !1
|
|
1655
|
+
},
|
|
1656
|
+
props: {
|
|
1657
|
+
...e.defaults.props,
|
|
1658
|
+
...r.props
|
|
1659
|
+
},
|
|
1660
|
+
style: xt({
|
|
1661
|
+
...e.defaults.style,
|
|
1662
|
+
...r.style
|
|
1663
|
+
}),
|
|
1664
|
+
dataSource: null,
|
|
1665
|
+
dataValue: r.dataValue ?? null,
|
|
1666
|
+
...r.dataBinding === void 0 ? {} : { dataBinding: r.dataBinding }
|
|
1667
|
+
}), g.add(e.type), s;
|
|
1668
|
+
}, T = (e, t) => {
|
|
1669
|
+
if (x === void 0) {
|
|
1670
|
+
C = !0;
|
|
1671
|
+
return;
|
|
1672
|
+
}
|
|
1673
|
+
S = w(x, e, t, { parentId: null });
|
|
1674
|
+
}, E = () => {
|
|
1675
|
+
S = null;
|
|
1676
|
+
}, D = (e, t, n, r = {}, i = !1) => {
|
|
1677
|
+
y !== void 0 && t !== "" && w(y, e, n, {
|
|
1678
|
+
style: Se(y, {
|
|
1679
|
+
color: o.text,
|
|
1680
|
+
...r
|
|
1681
|
+
}),
|
|
1682
|
+
dataValue: i ? {
|
|
1683
|
+
kind: "inline",
|
|
1684
|
+
value: t,
|
|
1685
|
+
sample: !0
|
|
1686
|
+
} : {
|
|
1687
|
+
kind: "inline",
|
|
1688
|
+
value: t
|
|
1689
|
+
}
|
|
1690
|
+
});
|
|
1691
|
+
}, O = (e, t, n, r = !1) => {
|
|
1692
|
+
b !== void 0 && w(b, e, t, {
|
|
1693
|
+
style: {
|
|
1694
|
+
fill: o.card,
|
|
1695
|
+
...n ?? {}
|
|
1696
|
+
},
|
|
1697
|
+
...r ? { pending: !0 } : {}
|
|
1698
|
+
});
|
|
1699
|
+
};
|
|
1700
|
+
h("title"), D("标题", a.title, {
|
|
1701
|
+
x: 64,
|
|
1702
|
+
y: 44,
|
|
1703
|
+
width: 1200,
|
|
1704
|
+
height: 62
|
|
1705
|
+
}, {
|
|
1706
|
+
fontSize: 46,
|
|
1707
|
+
fontWeight: "700"
|
|
1708
|
+
}), h("subtitle"), D("副标题", a.subtitle, {
|
|
1709
|
+
x: 64,
|
|
1710
|
+
y: 112,
|
|
1711
|
+
width: 1400,
|
|
1712
|
+
height: 30
|
|
1713
|
+
}, {
|
|
1714
|
+
fontSize: 20,
|
|
1715
|
+
color: o.muted
|
|
1716
|
+
});
|
|
1717
|
+
let k = vt(o.card), A = {
|
|
1718
|
+
catalog: t,
|
|
1719
|
+
textMaterial: y,
|
|
1720
|
+
push: w,
|
|
1721
|
+
pushText: D,
|
|
1722
|
+
references: n,
|
|
1723
|
+
palette: o,
|
|
1724
|
+
beginShell: T,
|
|
1725
|
+
endShell: E
|
|
1726
|
+
}, j = {
|
|
1727
|
+
sink: c,
|
|
1728
|
+
onAsset: () => v += 1
|
|
1729
|
+
}, M = (e, t) => {
|
|
1730
|
+
h(e.path, e.block?.origin ?? e.path), e.block === void 0 ? O("占位", t, k, !0) : ge(e.block, t, A, j);
|
|
1731
|
+
};
|
|
1732
|
+
for (let [t, r] of l.entries()) {
|
|
1733
|
+
let i = u.regions[t];
|
|
1734
|
+
r.kind === "band" && i.kind === "band" ? r.kpis.forEach((t, r) => {
|
|
1735
|
+
let a = i.boxes[r];
|
|
1736
|
+
if (h(t.path, t.kpi?.origin ?? t.path), T("指标卡", a), O(x === void 0 ? "指标卡" : "底板", a, k), t.kpi !== void 0) {
|
|
1737
|
+
let r = t.kpi, i = a.x + lt, l = a.width - 40;
|
|
1738
|
+
r.bind !== void 0 && Be(r, {
|
|
1739
|
+
label: {
|
|
1740
|
+
x: i,
|
|
1741
|
+
y: a.y + 18,
|
|
1742
|
+
width: l,
|
|
1743
|
+
height: 26
|
|
1744
|
+
},
|
|
1745
|
+
value: {
|
|
1746
|
+
x: i,
|
|
1747
|
+
y: a.y + 50,
|
|
1748
|
+
width: l,
|
|
1749
|
+
height: 54
|
|
1750
|
+
}
|
|
1751
|
+
}, {
|
|
1752
|
+
textMaterial: y,
|
|
1753
|
+
references: n,
|
|
1754
|
+
sink: c,
|
|
1755
|
+
palette: o,
|
|
1756
|
+
language: s,
|
|
1757
|
+
push: w,
|
|
1758
|
+
pushText: D
|
|
1759
|
+
}) || _t(r, a, o, e.mode, s, D);
|
|
1760
|
+
}
|
|
1761
|
+
E();
|
|
1762
|
+
}) : r.kind === "grid" && i.kind === "grid" ? r.blocks.forEach((e, t) => M(e, i.boxes[t])) : r.kind === "split" && i.kind === "split" && (r.main.forEach((e, t) => M(e, i.main[t])), r.rail.forEach((e, t) => M(e, i.rail[t])));
|
|
1763
|
+
}
|
|
1764
|
+
let N = e.mode === "llm" ? s === "en" ? "model output" : "模型输出" : e.mode === "deterministic" ? s === "en" ? "deterministic fallback · model not called" : "确定性兜底 · 未调用模型" : "";
|
|
1765
|
+
if (h(""), D("页脚", s === "en" ? `Generated by the sample agent${N === "" ? "" : ` · ${N}`} · component catalog from the host designer (${t.materials.length} materials)` : `生成自示例智能体${N === "" ? "" : ` · ${N}`} · 组件目录来自宿主设计器(${t.materials.length} 种可用物料)`, {
|
|
1766
|
+
x: 64,
|
|
1767
|
+
y: Ue,
|
|
1768
|
+
width: 1600,
|
|
1769
|
+
height: 26
|
|
1770
|
+
}, {
|
|
1771
|
+
fontSize: bt,
|
|
1772
|
+
color: o.footer
|
|
1773
|
+
}), C && c.warnings.push({
|
|
1774
|
+
severity: "warning",
|
|
1775
|
+
code: "INTENT_SHELL_UNAVAILABLE",
|
|
1776
|
+
path: "",
|
|
1777
|
+
message: "The catalog has no material that can hold child components, so cards and blocks were laid out flat instead of as movable groups."
|
|
1778
|
+
}), c.diagnostics.length > 0) return {
|
|
1779
|
+
ok: !1,
|
|
1780
|
+
diagnostics: c.diagnostics
|
|
1781
|
+
};
|
|
1782
|
+
let P = r === void 0 ? te({
|
|
1783
|
+
intent: a,
|
|
1784
|
+
catalog: t,
|
|
1785
|
+
references: n,
|
|
1786
|
+
capabilities: e.capabilities,
|
|
1787
|
+
language: s,
|
|
1788
|
+
components: d,
|
|
1789
|
+
dataSources: c.dataSources,
|
|
1790
|
+
sources: f,
|
|
1791
|
+
warnings: c.warnings
|
|
1792
|
+
}) : void 0;
|
|
1793
|
+
return d.length === 0 ? {
|
|
1794
|
+
ok: !1,
|
|
1795
|
+
diagnostics: [{
|
|
1796
|
+
severity: "error",
|
|
1797
|
+
code: "AGENT_CATALOG_UNUSABLE",
|
|
1798
|
+
path: "catalog",
|
|
1799
|
+
message: "The catalog has no basic material to lay out with (text / surface / asset)."
|
|
1800
|
+
}]
|
|
1801
|
+
} : {
|
|
1802
|
+
ok: !0,
|
|
1803
|
+
value: {
|
|
1804
|
+
imageCount: v,
|
|
1805
|
+
materials: [...g],
|
|
1806
|
+
warnings: c.warnings,
|
|
1807
|
+
sources: f,
|
|
1808
|
+
behaviors: P?.behaviors ?? [],
|
|
1809
|
+
document: {
|
|
1810
|
+
canvas: {
|
|
1811
|
+
width: Ve,
|
|
1812
|
+
height: He,
|
|
1813
|
+
backgroundColor: o.canvas
|
|
1814
|
+
},
|
|
1815
|
+
components: d,
|
|
1816
|
+
variables: P?.variables ?? [],
|
|
1817
|
+
...c.dataSources.length === 0 ? {} : { dataSources: c.dataSources },
|
|
1818
|
+
blueprint: P?.blueprint ?? {
|
|
1819
|
+
nodes: [],
|
|
1820
|
+
edges: []
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
}
|
|
1824
|
+
};
|
|
1825
|
+
}
|
|
1826
|
+
function dt(e, t) {
|
|
1827
|
+
return e.origin === "kpis" || e.origin === "blocks" ? e.origin : `regions[${t}]`;
|
|
1828
|
+
}
|
|
1829
|
+
function R(e, t, n) {
|
|
1830
|
+
return e === "kpis" || e === "blocks" ? `${e}[${n}]` : `${e}.${t}[${n}]`;
|
|
1831
|
+
}
|
|
1832
|
+
var ft = (e) => e.bind.kind === "table" || e.bind.kind === "dataset";
|
|
1833
|
+
function pt(e) {
|
|
1834
|
+
return e.regions.map((e, t) => {
|
|
1835
|
+
let n = dt(e, t), r = (e, t) => e.map((e, r) => ({
|
|
1836
|
+
path: e.ident ?? R(n, t, r),
|
|
1837
|
+
block: e
|
|
1838
|
+
}));
|
|
1839
|
+
if (e.kind === "band") {
|
|
1840
|
+
let t = n === "kpis" ? e.items.slice(0, ct) : e.items;
|
|
1841
|
+
return {
|
|
1842
|
+
kind: "band",
|
|
1843
|
+
path: n,
|
|
1844
|
+
origin: e.origin,
|
|
1845
|
+
layout: {
|
|
1846
|
+
kind: "band",
|
|
1847
|
+
count: t.length
|
|
1848
|
+
},
|
|
1849
|
+
kpis: t.map((e, t) => ({
|
|
1850
|
+
path: e.ident ?? R(n, "items", t),
|
|
1851
|
+
kpi: e
|
|
1852
|
+
}))
|
|
1853
|
+
};
|
|
1854
|
+
}
|
|
1855
|
+
return e.kind === "grid" ? {
|
|
1856
|
+
kind: "grid",
|
|
1857
|
+
path: n,
|
|
1858
|
+
origin: e.origin,
|
|
1859
|
+
layout: {
|
|
1860
|
+
kind: "grid",
|
|
1861
|
+
slots: e.blocks.map((e) => ({
|
|
1862
|
+
span: e.span,
|
|
1863
|
+
data: ft(e)
|
|
1864
|
+
}))
|
|
1865
|
+
},
|
|
1866
|
+
blocks: r(e.blocks, "blocks")
|
|
1867
|
+
} : {
|
|
1868
|
+
kind: "split",
|
|
1869
|
+
path: n,
|
|
1870
|
+
origin: e.origin,
|
|
1871
|
+
layout: {
|
|
1872
|
+
kind: "split",
|
|
1873
|
+
ratio: e.ratio,
|
|
1874
|
+
railSide: e.railSide,
|
|
1875
|
+
main: e.main.map((e) => ({ data: ft(e) })),
|
|
1876
|
+
rail: e.rail.map((e) => ({ data: ft(e) }))
|
|
1877
|
+
},
|
|
1878
|
+
main: r(e.main, "main"),
|
|
1879
|
+
rail: r(e.rail, "rail")
|
|
1880
|
+
};
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
function mt(e) {
|
|
1884
|
+
let { skeleton: t } = e;
|
|
1885
|
+
return t.regions.map((n, r) => {
|
|
1886
|
+
let i = ht(t, n, r), a = (t, n) => Array.from({ length: t }, (t, r) => {
|
|
1887
|
+
let a = R(i, n, r);
|
|
1888
|
+
return {
|
|
1889
|
+
path: a,
|
|
1890
|
+
block: e.blocks[a]
|
|
1891
|
+
};
|
|
1892
|
+
});
|
|
1893
|
+
if (n.kind === "band") {
|
|
1894
|
+
let r = t.flat === !0 ? Math.min(n.count, ct) : n.count;
|
|
1895
|
+
return {
|
|
1896
|
+
kind: "band",
|
|
1897
|
+
path: i,
|
|
1898
|
+
origin: i,
|
|
1899
|
+
layout: {
|
|
1900
|
+
kind: "band",
|
|
1901
|
+
count: r
|
|
1902
|
+
},
|
|
1903
|
+
kpis: Array.from({ length: r }, (t, n) => {
|
|
1904
|
+
let r = R(i, "items", n);
|
|
1905
|
+
return {
|
|
1906
|
+
path: r,
|
|
1907
|
+
kpi: e.kpis[r]
|
|
1908
|
+
};
|
|
1909
|
+
})
|
|
1910
|
+
};
|
|
1911
|
+
}
|
|
1912
|
+
return n.kind === "grid" ? {
|
|
1913
|
+
kind: "grid",
|
|
1914
|
+
path: i,
|
|
1915
|
+
origin: i,
|
|
1916
|
+
layout: {
|
|
1917
|
+
kind: "grid",
|
|
1918
|
+
slots: n.slots
|
|
1919
|
+
},
|
|
1920
|
+
blocks: a(n.slots.length, "blocks")
|
|
1921
|
+
} : {
|
|
1922
|
+
kind: "split",
|
|
1923
|
+
path: i,
|
|
1924
|
+
origin: i,
|
|
1925
|
+
layout: n,
|
|
1926
|
+
main: a(n.main.length, "main"),
|
|
1927
|
+
rail: a(n.rail.length, "rail")
|
|
1928
|
+
};
|
|
1929
|
+
});
|
|
1930
|
+
}
|
|
1931
|
+
function ht(e, t, n) {
|
|
1932
|
+
return e.flat === !0 ? t.kind === "band" ? "kpis" : "blocks" : `regions[${n}]`;
|
|
1933
|
+
}
|
|
1934
|
+
function gt(e, t) {
|
|
1935
|
+
return {
|
|
1936
|
+
severity: "error",
|
|
1937
|
+
code: "LAYOUT_CAPACITY_EXCEEDED",
|
|
1938
|
+
path: t[e.regionIndex]?.origin ?? "",
|
|
1939
|
+
message: e.reason === "width" ? `The band needs ${e.requiredPx}px to keep every card at least 240px wide, but only ${e.availablePx}px is available; use fewer cards.` : `The regions need ${e.requiredPx}px of height but only ${e.availablePx}px is available (short by ${e.requiredPx - e.availablePx}px); use fewer blocks.`
|
|
1940
|
+
};
|
|
1941
|
+
}
|
|
1942
|
+
function _t(e, t, n, r, i, a) {
|
|
1943
|
+
let o = t.width - 40, s = t.x + lt;
|
|
1944
|
+
a("指标名", e.label, {
|
|
1945
|
+
x: s,
|
|
1946
|
+
y: t.y + 18,
|
|
1947
|
+
width: o,
|
|
1948
|
+
height: 26
|
|
1949
|
+
}, {
|
|
1950
|
+
fontSize: 18,
|
|
1951
|
+
color: n.muted
|
|
1952
|
+
}), a("指标值", L(e, i), {
|
|
1953
|
+
x: s,
|
|
1954
|
+
y: t.y + 50,
|
|
1955
|
+
width: o,
|
|
1956
|
+
height: 54
|
|
1957
|
+
}, {
|
|
1958
|
+
fontSize: 42,
|
|
1959
|
+
fontWeight: "700",
|
|
1960
|
+
color: n.text
|
|
1961
|
+
}, r === "llm" && e.value !== null), e.delta !== void 0 && a("同比", Pe(e, i), {
|
|
1962
|
+
x: s,
|
|
1963
|
+
y: t.y + 108,
|
|
1964
|
+
width: o,
|
|
1965
|
+
height: 24
|
|
1966
|
+
}, {
|
|
1967
|
+
fontSize: 16,
|
|
1968
|
+
color: Ie(e.delta, n)
|
|
1969
|
+
});
|
|
1970
|
+
}
|
|
1971
|
+
function vt(e) {
|
|
1972
|
+
let t = e === void 0 ? null : yt(e);
|
|
1973
|
+
if (t === null) return {};
|
|
1974
|
+
let n = Math.max(...t), r = Math.min(...t);
|
|
1975
|
+
if (n === 0) return {};
|
|
1976
|
+
let i = (n + r) / 510;
|
|
1977
|
+
return (n - r) / (n + r === 0 ? 1 : 255 - Math.abs(n + r - 255)) < .45 || i > .6 ? {} : { opacity: .3 };
|
|
1978
|
+
}
|
|
1979
|
+
function yt(e) {
|
|
1980
|
+
let t = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(e.trim());
|
|
1981
|
+
if (t === null) return null;
|
|
1982
|
+
let n = t[1], r = n.length === 3 ? [...n].map((e) => e + e).join("") : n;
|
|
1983
|
+
return [
|
|
1984
|
+
Number.parseInt(r.slice(0, 2), 16),
|
|
1985
|
+
Number.parseInt(r.slice(2, 4), 16),
|
|
1986
|
+
Number.parseInt(r.slice(4, 6), 16)
|
|
1987
|
+
];
|
|
1988
|
+
}
|
|
1989
|
+
var bt = f(Ve);
|
|
1990
|
+
function xt(e) {
|
|
1991
|
+
let t = e.fontSize;
|
|
1992
|
+
return typeof t == "number" && t < bt ? {
|
|
1993
|
+
...e,
|
|
1994
|
+
fontSize: bt
|
|
1995
|
+
} : e;
|
|
1996
|
+
}
|
|
1997
|
+
var St = {
|
|
1998
|
+
items: "k",
|
|
1999
|
+
blocks: "b",
|
|
2000
|
+
main: "m",
|
|
2001
|
+
rail: "s"
|
|
2002
|
+
}, Ct = {
|
|
2003
|
+
items: 0,
|
|
2004
|
+
blocks: 0,
|
|
2005
|
+
main: 0,
|
|
2006
|
+
rail: 64
|
|
2007
|
+
};
|
|
2008
|
+
function wt(e) {
|
|
2009
|
+
if (e === "title") return {
|
|
2010
|
+
key: "title",
|
|
2011
|
+
layer: 1,
|
|
2012
|
+
pendingOffset: 19
|
|
2013
|
+
};
|
|
2014
|
+
if (e === "subtitle") return {
|
|
2015
|
+
key: "subtitle",
|
|
2016
|
+
layer: 2,
|
|
2017
|
+
pendingOffset: 19
|
|
2018
|
+
};
|
|
2019
|
+
if (e === "") return {
|
|
2020
|
+
key: "footer",
|
|
2021
|
+
layer: 1e3,
|
|
2022
|
+
pendingOffset: 19
|
|
2023
|
+
};
|
|
2024
|
+
let t = /^(kpis|blocks)\[(\d+)\]$/.exec(e);
|
|
2025
|
+
if (t !== null) {
|
|
2026
|
+
let e = Number(t[2]);
|
|
2027
|
+
return t[1] === "kpis" ? {
|
|
2028
|
+
key: `kpi-${e}`,
|
|
2029
|
+
layer: 10 + e * 10,
|
|
2030
|
+
pendingOffset: 19
|
|
2031
|
+
} : {
|
|
2032
|
+
key: `block-${e}`,
|
|
2033
|
+
layer: 100 + e * 20,
|
|
2034
|
+
pendingOffset: 19
|
|
2035
|
+
};
|
|
2036
|
+
}
|
|
2037
|
+
let n = /^regions\[(\d+)\]\.(items|blocks|main|rail)\[(\d+)\]$/.exec(e);
|
|
2038
|
+
if (n !== null) {
|
|
2039
|
+
let e = n[2], t = Number(n[1]), r = Number(n[3]);
|
|
2040
|
+
return {
|
|
2041
|
+
key: `r${t}-${St[e]}${r}`,
|
|
2042
|
+
layer: 100 + t * 140 + Ct[e] + r * 8,
|
|
2043
|
+
pendingOffset: 7
|
|
2044
|
+
};
|
|
2045
|
+
}
|
|
2046
|
+
return {
|
|
2047
|
+
key: e,
|
|
2048
|
+
layer: 1e3,
|
|
2049
|
+
pendingOffset: 19
|
|
2050
|
+
};
|
|
2051
|
+
}
|
|
2052
|
+
//#endregion
|
|
2053
|
+
//#region ../host-kit/dist/intent/intent-compile-types.js
|
|
2054
|
+
function Tt(e, t) {
|
|
2055
|
+
let n = [];
|
|
2056
|
+
return e > 0 && n.push({
|
|
2057
|
+
kind: "band",
|
|
2058
|
+
count: e
|
|
2059
|
+
}), t.length > 0 && n.push({
|
|
2060
|
+
kind: "grid",
|
|
2061
|
+
slots: t
|
|
2062
|
+
}), {
|
|
2063
|
+
regions: n,
|
|
2064
|
+
flat: !0
|
|
2065
|
+
};
|
|
2066
|
+
}
|
|
2067
|
+
//#endregion
|
|
2068
|
+
//#region ../host-kit/dist/intent/intent-data-context.js
|
|
2069
|
+
function Et(e, t) {
|
|
2070
|
+
let n = Object.keys(t).sort().map((e) => [e, t[e]]);
|
|
2071
|
+
return JSON.stringify([e, n]);
|
|
2072
|
+
}
|
|
2073
|
+
var Dt = 4, Ot = [
|
|
2074
|
+
"string",
|
|
2075
|
+
"number",
|
|
2076
|
+
"boolean",
|
|
2077
|
+
"date"
|
|
2078
|
+
];
|
|
2079
|
+
async function kt(e) {
|
|
2080
|
+
let t = [], n = [...new Set(e.datasetIds)];
|
|
2081
|
+
n.length > 4 && t.push({
|
|
2082
|
+
severity: "warning",
|
|
2083
|
+
code: "AGENT_DATASETS_TRIMMED",
|
|
2084
|
+
path: "",
|
|
2085
|
+
message: "Only the first 4 referenced datasets are profiled."
|
|
2086
|
+
});
|
|
2087
|
+
let r = n.slice(0, 4).map(() => []), i = await Promise.all(n.slice(0, 4).map((t, n) => At(t, n, e, r[n] ?? [])));
|
|
2088
|
+
for (let e of r) t.push(...e);
|
|
2089
|
+
let a = i.filter((e) => e !== void 0), o = a.map((e) => e.profile), s = l(o, Mt(e.catalog), { maxPerDataset: e.maxCandidatesPerDataset ?? 12 }), c = /* @__PURE__ */ new Map();
|
|
2090
|
+
for (let e of a) e.sample !== void 0 && c.set(e.sample.key, e.sample.value);
|
|
2091
|
+
return {
|
|
2092
|
+
profiles: o,
|
|
2093
|
+
samples: c,
|
|
2094
|
+
candidates: s.map((e) => ({
|
|
2095
|
+
id: e.id,
|
|
2096
|
+
fact: e.fact,
|
|
2097
|
+
datasetId: e.datasetId,
|
|
2098
|
+
type: e.type,
|
|
2099
|
+
fields: e.fields
|
|
2100
|
+
})),
|
|
2101
|
+
references: a.map((e) => Ft(e.definition, e.profile, e.sample?.value)),
|
|
2102
|
+
warnings: t
|
|
2103
|
+
};
|
|
2104
|
+
}
|
|
2105
|
+
async function At(e, t, n, r) {
|
|
2106
|
+
let i = new AbortController(), a = () => i.abort();
|
|
2107
|
+
n.signal.aborted ? a() : n.signal.addEventListener("abort", a, { once: !0 });
|
|
2108
|
+
let o = setTimeout(a, n.timeoutMs ?? 3e3);
|
|
2109
|
+
try {
|
|
2110
|
+
let a = await n.port.describe({
|
|
2111
|
+
datasetId: e,
|
|
2112
|
+
signal: i.signal
|
|
2113
|
+
});
|
|
2114
|
+
if (!a.ok) {
|
|
2115
|
+
r.push(jt("AGENT_DATASET_UNKNOWN", e, "describe failed"));
|
|
2116
|
+
return;
|
|
2117
|
+
}
|
|
2118
|
+
let o = a.value, s = {}, c = !1;
|
|
2119
|
+
for (let e of o.parameters) if (e.defaultValue !== void 0) s[e.name] = e.defaultValue;
|
|
2120
|
+
else if (e.required) {
|
|
2121
|
+
let t = e.allowedValues?.[0];
|
|
2122
|
+
t === void 0 ? c = !0 : s[e.name] = t;
|
|
2123
|
+
}
|
|
2124
|
+
if (c) return {
|
|
2125
|
+
definition: o,
|
|
2126
|
+
profile: u(o)
|
|
2127
|
+
};
|
|
2128
|
+
let l;
|
|
2129
|
+
try {
|
|
2130
|
+
let r = await n.port.query({
|
|
2131
|
+
datasetId: e,
|
|
2132
|
+
dataSourceId: `agent-profile-${t + 1}`,
|
|
2133
|
+
params: s
|
|
2134
|
+
}, { signal: i.signal });
|
|
2135
|
+
r.ok && (l = r.value);
|
|
2136
|
+
} catch {
|
|
2137
|
+
l = void 0;
|
|
2138
|
+
}
|
|
2139
|
+
return l === void 0 && r.push(jt("AGENT_DATASET_SAMPLE_UNAVAILABLE", e, "sample query failed")), {
|
|
2140
|
+
definition: o,
|
|
2141
|
+
profile: u(o, l),
|
|
2142
|
+
...l === void 0 ? {} : { sample: {
|
|
2143
|
+
key: Et(e, s),
|
|
2144
|
+
value: l
|
|
2145
|
+
} }
|
|
2146
|
+
};
|
|
2147
|
+
} catch {
|
|
2148
|
+
r.push(jt("AGENT_DATASET_UNKNOWN", e, "describe failed"));
|
|
2149
|
+
return;
|
|
2150
|
+
} finally {
|
|
2151
|
+
clearTimeout(o);
|
|
2152
|
+
}
|
|
2153
|
+
}
|
|
2154
|
+
function jt(e, t, n) {
|
|
2155
|
+
return {
|
|
2156
|
+
severity: "warning",
|
|
2157
|
+
code: e,
|
|
2158
|
+
path: "",
|
|
2159
|
+
message: `Dataset ${t}: ${n}.`,
|
|
2160
|
+
detail: { datasetId: t }
|
|
2161
|
+
};
|
|
2162
|
+
}
|
|
2163
|
+
function Mt(e) {
|
|
2164
|
+
return e.materials.filter((e) => e.children !== !0 && e.roles.length > 0 && (e.data === "tabular" || e.data === "scalar")).map((e) => ({
|
|
2165
|
+
type: e.type,
|
|
2166
|
+
name: e.name,
|
|
2167
|
+
roles: e.roles.map((e) => ({
|
|
2168
|
+
id: e.id,
|
|
2169
|
+
minFields: e.min,
|
|
2170
|
+
maxFields: e.max,
|
|
2171
|
+
valueTypes: [...e.valueTypes ?? Ot]
|
|
2172
|
+
}))
|
|
2173
|
+
}));
|
|
2174
|
+
}
|
|
2175
|
+
var Nt = 24;
|
|
2176
|
+
function Pt(e) {
|
|
2177
|
+
if (e === void 0 || e.rows.length === 0) return;
|
|
2178
|
+
let t = {};
|
|
2179
|
+
for (let n of e.fields) {
|
|
2180
|
+
let r = /* @__PURE__ */ new Set();
|
|
2181
|
+
for (let t of e.rows) {
|
|
2182
|
+
let e = t[n.id];
|
|
2183
|
+
if ((typeof e == "string" || typeof e == "number" || typeof e == "boolean") && (r.add(e), r.size >= Nt)) break;
|
|
2184
|
+
}
|
|
2185
|
+
r.size > 0 && (t[n.id] = [...r]);
|
|
2186
|
+
}
|
|
2187
|
+
return t;
|
|
2188
|
+
}
|
|
2189
|
+
function Ft(e, t, n) {
|
|
2190
|
+
let r = Pt(n);
|
|
2191
|
+
return {
|
|
2192
|
+
datasetId: e.datasetId,
|
|
2193
|
+
name: e.name,
|
|
2194
|
+
columns: e.fields.map((e) => ({
|
|
2195
|
+
id: e.id,
|
|
2196
|
+
type: e.valueType,
|
|
2197
|
+
label: e.label,
|
|
2198
|
+
...e.unit === void 0 ? {} : { unit: e.unit }
|
|
2199
|
+
})),
|
|
2200
|
+
parameters: e.parameters.map((e) => ({
|
|
2201
|
+
name: e.name,
|
|
2202
|
+
required: e.required,
|
|
2203
|
+
valueType: e.valueType,
|
|
2204
|
+
...e.defaultValue === void 0 ? {} : { defaultValue: e.defaultValue },
|
|
2205
|
+
...e.allowedValues === void 0 ? {} : { allowedValues: [...e.allowedValues] }
|
|
2206
|
+
})),
|
|
2207
|
+
...r === void 0 ? {} : { values: r },
|
|
2208
|
+
...t.sampled ? { rows: {
|
|
2209
|
+
sampled: t.rows.sampled,
|
|
2210
|
+
...t.rows.total === void 0 ? {} : { total: t.rows.total }
|
|
2211
|
+
} } : {}
|
|
2212
|
+
};
|
|
2213
|
+
}
|
|
2214
|
+
function It(e) {
|
|
2215
|
+
return e.profiles.map((t) => ({
|
|
2216
|
+
datasetId: t.datasetId,
|
|
2217
|
+
profile: t,
|
|
2218
|
+
candidates: e.candidates.filter((e) => e.datasetId === t.datasetId)
|
|
2219
|
+
}));
|
|
2220
|
+
}
|
|
2221
|
+
//#endregion
|
|
2222
|
+
//#region ../host-kit/dist/intent/intent-data-check.js
|
|
2223
|
+
var Lt = /^(?:kpis\[\d+\]|regions\[\d+\]\.items\[\d+\])$/;
|
|
2224
|
+
async function Rt(e) {
|
|
2225
|
+
let t = Vt(e.document.dataSources ?? [], Bt(e.document.variables ?? [])), n = /* @__PURE__ */ new Set();
|
|
2226
|
+
for (let t of e.document.components) {
|
|
2227
|
+
let e = Ht(t.dataValue);
|
|
2228
|
+
e !== void 0 && n.add(e);
|
|
2229
|
+
}
|
|
2230
|
+
let r = t.filter((e) => n.has(e.id));
|
|
2231
|
+
if (r.length === 0) return {
|
|
2232
|
+
issues: [],
|
|
2233
|
+
verified: [],
|
|
2234
|
+
unverified: [],
|
|
2235
|
+
empty: []
|
|
2236
|
+
};
|
|
2237
|
+
let i = /* @__PURE__ */ new Map(), a = [], o = [], s = [], c = await Promise.all(r.map(async (t, n) => ({
|
|
2238
|
+
instance: t,
|
|
2239
|
+
result: await zt(t, n, e)
|
|
2240
|
+
})));
|
|
2241
|
+
for (let { instance: e, result: t } of c) t === void 0 ? o.push(e.name) : (i.set(e.id, t), a.push(e.name), t.rows.length === 0 && s.push(e.name));
|
|
2242
|
+
let l = [], u = /* @__PURE__ */ new Set(), d = (e, t) => {
|
|
2243
|
+
let n = `${e}@${t}`;
|
|
2244
|
+
u.has(n) || (u.add(n), l.push({
|
|
2245
|
+
code: e,
|
|
2246
|
+
path: t
|
|
2247
|
+
}));
|
|
2248
|
+
};
|
|
2249
|
+
for (let t of e.document.components) {
|
|
2250
|
+
let n = Ht(t.dataValue), r = n === void 0 ? void 0 : i.get(n);
|
|
2251
|
+
if (r === void 0) continue;
|
|
2252
|
+
let a = e.sources[t.id] ?? "", o = Ut(t.dataBinding);
|
|
2253
|
+
if (r.rows.length === 0) continue;
|
|
2254
|
+
let s = new Set(r.fields.map((e) => e.id));
|
|
2255
|
+
if (o.some((e) => !s.has(e))) {
|
|
2256
|
+
d("DATA_FIELD_ABSENT", a);
|
|
2257
|
+
continue;
|
|
2258
|
+
}
|
|
2259
|
+
o.some((e) => r.rows.every((t) => Wt(t[e]))) && d("DATA_FIELD_ALL_NULL", a), Lt.test(a) && r.rows.length > 1 && d("AGENT_KPI_MULTI_ROW", a);
|
|
2260
|
+
}
|
|
2261
|
+
return {
|
|
2262
|
+
issues: l,
|
|
2263
|
+
verified: a,
|
|
2264
|
+
unverified: o,
|
|
2265
|
+
empty: s
|
|
2266
|
+
};
|
|
2267
|
+
}
|
|
2268
|
+
async function zt(e, t, n) {
|
|
2269
|
+
let r = n.context?.samples.get(Et(e.datasetId, e.params));
|
|
2270
|
+
if (r !== void 0) return r;
|
|
2271
|
+
let i = new AbortController(), a = () => i.abort();
|
|
2272
|
+
if (n.signal.aborted) return;
|
|
2273
|
+
n.signal.addEventListener("abort", a, { once: !0 });
|
|
2274
|
+
let o = setTimeout(a, n.timeoutMs ?? 3e3);
|
|
2275
|
+
try {
|
|
2276
|
+
let r = await n.port.query({
|
|
2277
|
+
datasetId: e.datasetId,
|
|
2278
|
+
dataSourceId: `agent-check-${t + 1}`,
|
|
2279
|
+
params: { ...e.params }
|
|
2280
|
+
}, { signal: i.signal });
|
|
2281
|
+
return r.ok && !i.signal.aborted ? r.value : void 0;
|
|
2282
|
+
} catch {
|
|
2283
|
+
return;
|
|
2284
|
+
} finally {
|
|
2285
|
+
clearTimeout(o);
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
function Bt(e) {
|
|
2289
|
+
let t = /* @__PURE__ */ new Map();
|
|
2290
|
+
for (let n of e) {
|
|
2291
|
+
let e = z(n);
|
|
2292
|
+
e !== null && typeof e.id == "string" && e.type === "static" && t.set(e.id, e.initialValue);
|
|
2293
|
+
}
|
|
2294
|
+
return t;
|
|
2295
|
+
}
|
|
2296
|
+
function Vt(e, t) {
|
|
2297
|
+
let n = [];
|
|
2298
|
+
for (let r of e) {
|
|
2299
|
+
let e = z(r), i = z(e?.source);
|
|
2300
|
+
if (e === null || i === null || i.kind !== "dataset" || typeof e.id != "string" || typeof i.datasetId != "string") continue;
|
|
2301
|
+
let a = {}, o = !0;
|
|
2302
|
+
for (let [n, r] of Object.entries(z(e.params) ?? {})) {
|
|
2303
|
+
let e = z(r), i = e?.kind === "inline" ? e.value : e?.kind === "variable" && typeof e.variableId == "string" ? t.get(e.variableId) : void 0;
|
|
2304
|
+
typeof i == "string" || typeof i == "number" || typeof i == "boolean" ? a[n] = i : o = !1;
|
|
2305
|
+
}
|
|
2306
|
+
o && n.push({
|
|
2307
|
+
id: e.id,
|
|
2308
|
+
name: typeof e.name == "string" && e.name !== "" ? e.name : i.datasetId,
|
|
2309
|
+
datasetId: i.datasetId,
|
|
2310
|
+
params: a
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
2313
|
+
return n;
|
|
2314
|
+
}
|
|
2315
|
+
function Ht(e) {
|
|
2316
|
+
let t = z(e);
|
|
2317
|
+
return t?.kind === "data-source-field" && typeof t.dataSourceId == "string" ? t.dataSourceId : void 0;
|
|
2318
|
+
}
|
|
2319
|
+
function Ut(e) {
|
|
2320
|
+
let t = z(z(e)?.fields);
|
|
2321
|
+
return t === null ? [] : Object.values(t).flatMap((e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : []);
|
|
2322
|
+
}
|
|
2323
|
+
function Wt(e) {
|
|
2324
|
+
return e == null || e === "";
|
|
2325
|
+
}
|
|
2326
|
+
function z(e) {
|
|
2327
|
+
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
2328
|
+
}
|
|
2329
|
+
//#endregion
|
|
2330
|
+
//#region ../host-kit/dist/intent/intent-parse.js
|
|
2331
|
+
var Gt = 20, Kt = 40, qt = 12, Jt = 6, Yt = 24, Xt = 32, Zt = 160, Qt = 40, $t = 4, en = 8, tn = 24, nn = 12, rn = 8, an = 80, on = 5, sn = 4, cn = 6, ln = 8, un = /[⺀-鿿豈--]/;
|
|
2332
|
+
function B(e, t) {
|
|
2333
|
+
return e.slice(0, un.test(e) ? t : t * 2);
|
|
2334
|
+
}
|
|
2335
|
+
var dn = /* @__PURE__ */ new Set([
|
|
2336
|
+
"percent",
|
|
2337
|
+
"point",
|
|
2338
|
+
"absolute"
|
|
2339
|
+
]), fn = /* @__PURE__ */ new Set([
|
|
2340
|
+
"up-good",
|
|
2341
|
+
"down-good",
|
|
2342
|
+
"neutral"
|
|
2343
|
+
]), pn = /* @__PURE__ */ new Set(["wide-narrow", "even"]), mn = /* @__PURE__ */ new Set(["left", "right"]), hn = [
|
|
2344
|
+
"pages",
|
|
2345
|
+
"facts",
|
|
2346
|
+
"variables",
|
|
2347
|
+
"states"
|
|
2348
|
+
];
|
|
2349
|
+
function gn(e, t) {
|
|
2350
|
+
let n = [], r = Yn(e);
|
|
2351
|
+
if (r === void 0) return W(n, "AGENT_SPEC_INVALID", "", "Intent output must be a JSON object.");
|
|
2352
|
+
if (Object.prototype.hasOwnProperty.call(r, "panels")) return W(n, "AGENT_SPEC_INVALID", "", "The legacy \"panels\" shape is not accepted.");
|
|
2353
|
+
let i = Xn(r.title, Gt), a = Xn(r.subtitle, Kt);
|
|
2354
|
+
if (i === "" || a === "") return W(n, "AGENT_SPEC_INVALID", "", "Intent needs a non-empty title and subtitle.");
|
|
2355
|
+
for (let e of hn) Object.prototype.hasOwnProperty.call(r, e) && n.push({
|
|
2356
|
+
severity: "warning",
|
|
2357
|
+
code: "INTENT_PART_NOT_SUPPORTED",
|
|
2358
|
+
path: e,
|
|
2359
|
+
message: `The "${e}" part is reserved and is not compiled yet; it was ignored.`
|
|
2360
|
+
});
|
|
2361
|
+
let o = Object.prototype.hasOwnProperty.call(r, "regions"), s = "kpis" in r || "blocks" in r;
|
|
2362
|
+
if (o && s) return W(n, "AGENT_SPEC_INVALID", "", "Use either \"regions\" or the flat \"kpis\" + \"blocks\" shape, not both.");
|
|
2363
|
+
let c = o ? vn(r.regions, t.catalog, n, t.placeholders === !0) : _n(r, t.catalog, n, t.placeholders === !0);
|
|
2364
|
+
if (c === void 0) return {
|
|
2365
|
+
intent: void 0,
|
|
2366
|
+
diagnostics: n
|
|
2367
|
+
};
|
|
2368
|
+
let l = typeof r.style == "string" ? r.style.trim() : void 0, u = Gn(r.interactions, n);
|
|
2369
|
+
Kn(r.gaps, n);
|
|
2370
|
+
let d = {
|
|
2371
|
+
title: i,
|
|
2372
|
+
subtitle: a,
|
|
2373
|
+
...l === void 0 ? {} : { style: l },
|
|
2374
|
+
regions: c,
|
|
2375
|
+
...u === void 0 ? {} : { interactions: u }
|
|
2376
|
+
};
|
|
2377
|
+
return c.some(wn) || n.push({
|
|
2378
|
+
severity: "error",
|
|
2379
|
+
code: "AGENT_BLOCKS_ALL_INVALID",
|
|
2380
|
+
path: "",
|
|
2381
|
+
message: "At least one usable block is required."
|
|
2382
|
+
}), {
|
|
2383
|
+
intent: d,
|
|
2384
|
+
diagnostics: n
|
|
2385
|
+
};
|
|
2386
|
+
}
|
|
2387
|
+
function _n(e, t, n, r) {
|
|
2388
|
+
if (!Array.isArray(e.kpis) || !Array.isArray(e.blocks)) {
|
|
2389
|
+
Zn(n, "AGENT_SPEC_INVALID", "Intent needs \"kpis\" and \"blocks\" arrays.");
|
|
2390
|
+
return;
|
|
2391
|
+
}
|
|
2392
|
+
let i = [];
|
|
2393
|
+
for (let [t, a] of e.kpis.slice(0, on).entries()) {
|
|
2394
|
+
let e = V(a, `kpis[${t}]`, { placeholders: r });
|
|
2395
|
+
n.push(...e.diagnostics), e.value !== void 0 && i.push(e.value);
|
|
2396
|
+
}
|
|
2397
|
+
if (i.length < 1) {
|
|
2398
|
+
Zn(n, "AGENT_SPEC_INVALID", "Intent needs at least one usable KPI.");
|
|
2399
|
+
return;
|
|
2400
|
+
}
|
|
2401
|
+
let a = [];
|
|
2402
|
+
for (let [r, i] of e.blocks.slice(0, sn).entries()) {
|
|
2403
|
+
let e = H(i, t, `blocks[${r}]`, { grid: !0 });
|
|
2404
|
+
n.push(...e.diagnostics), e.value !== void 0 && a.push(e.value);
|
|
2405
|
+
}
|
|
2406
|
+
let o = [{
|
|
2407
|
+
kind: "band",
|
|
2408
|
+
items: i,
|
|
2409
|
+
origin: "kpis"
|
|
2410
|
+
}];
|
|
2411
|
+
return a.length > 0 && o.push({
|
|
2412
|
+
kind: "grid",
|
|
2413
|
+
blocks: a,
|
|
2414
|
+
origin: "blocks"
|
|
2415
|
+
}), o;
|
|
2416
|
+
}
|
|
2417
|
+
function vn(e, t, n, r) {
|
|
2418
|
+
if (!Array.isArray(e) || e.length === 0) {
|
|
2419
|
+
Zn(n, "AGENT_SPEC_INVALID", "Intent needs a non-empty \"regions\" array.");
|
|
2420
|
+
return;
|
|
2421
|
+
}
|
|
2422
|
+
let i = [];
|
|
2423
|
+
for (let [a, o] of e.slice(0, cn).entries()) {
|
|
2424
|
+
let e = yn(o, t, `regions[${a}]`, n, r);
|
|
2425
|
+
e !== void 0 && i.push(e);
|
|
2426
|
+
}
|
|
2427
|
+
if (e.length > cn && n.push({
|
|
2428
|
+
severity: "warning",
|
|
2429
|
+
code: "INTENT_ITEMS_TRIMMED",
|
|
2430
|
+
path: "regions",
|
|
2431
|
+
message: `Only the first ${cn} regions are kept.`
|
|
2432
|
+
}), i.length === 0) {
|
|
2433
|
+
Zn(n, "AGENT_SPEC_INVALID", "No usable region is left.");
|
|
2434
|
+
return;
|
|
2435
|
+
}
|
|
2436
|
+
return i;
|
|
2437
|
+
}
|
|
2438
|
+
function yn(e, t, n, r, i) {
|
|
2439
|
+
let a = U(e), o = a?.kind;
|
|
2440
|
+
if (a === null || o !== "band" && o !== "grid" && o !== "split") {
|
|
2441
|
+
r.push(Cn(n, "A region must be an object with kind \"band\", \"grid\" or \"split\"."));
|
|
2442
|
+
return;
|
|
2443
|
+
}
|
|
2444
|
+
if (o === "band") {
|
|
2445
|
+
let e = xn(a.items, n, "items", r);
|
|
2446
|
+
if (e === void 0) return;
|
|
2447
|
+
let t = [];
|
|
2448
|
+
for (let [a, o] of e.entries()) {
|
|
2449
|
+
let e = V(o, `${n}.items[${a}]`, { placeholders: i });
|
|
2450
|
+
r.push(...e.diagnostics), e.value !== void 0 && t.push(e.value);
|
|
2451
|
+
}
|
|
2452
|
+
return t.length === 0 ? void 0 : {
|
|
2453
|
+
kind: "band",
|
|
2454
|
+
items: t,
|
|
2455
|
+
origin: n
|
|
2456
|
+
};
|
|
2457
|
+
}
|
|
2458
|
+
if (o === "grid") {
|
|
2459
|
+
let e = bn(a.blocks, t, n, "blocks", !0, r);
|
|
2460
|
+
return e === void 0 || e.length === 0 ? void 0 : {
|
|
2461
|
+
kind: "grid",
|
|
2462
|
+
blocks: e,
|
|
2463
|
+
origin: n
|
|
2464
|
+
};
|
|
2465
|
+
}
|
|
2466
|
+
let s = Sn(a.ratio, pn, "wide-narrow", `${n}.ratio`, r), c = Sn(a.railSide, mn, "right", `${n}.railSide`, r), l = bn(a.main, t, n, "main", !1, r), u = bn(a.rail, t, n, "rail", !1, r);
|
|
2467
|
+
if (l !== void 0 && u !== void 0 && l.length !== 0 && u.length !== 0) return {
|
|
2468
|
+
kind: "split",
|
|
2469
|
+
ratio: s,
|
|
2470
|
+
railSide: c,
|
|
2471
|
+
main: l,
|
|
2472
|
+
rail: u,
|
|
2473
|
+
origin: n
|
|
2474
|
+
};
|
|
2475
|
+
}
|
|
2476
|
+
function bn(e, t, n, r, i, a) {
|
|
2477
|
+
let o = xn(e, n, r, a);
|
|
2478
|
+
if (o === void 0) return;
|
|
2479
|
+
let s = [];
|
|
2480
|
+
for (let [e, c] of o.entries()) {
|
|
2481
|
+
let o = H(c, t, `${n}.${r}[${e}]`, { grid: i });
|
|
2482
|
+
a.push(...o.diagnostics), o.value !== void 0 && s.push(o.value);
|
|
2483
|
+
}
|
|
2484
|
+
return s;
|
|
2485
|
+
}
|
|
2486
|
+
function xn(e, t, n, r) {
|
|
2487
|
+
if (!Array.isArray(e) || e.length === 0) {
|
|
2488
|
+
r.push(Cn(t, `"${n}" must be a non-empty array.`));
|
|
2489
|
+
return;
|
|
2490
|
+
}
|
|
2491
|
+
return e.length > ln && r.push({
|
|
2492
|
+
severity: "warning",
|
|
2493
|
+
code: "INTENT_ITEMS_TRIMMED",
|
|
2494
|
+
path: `${t}.${n}`,
|
|
2495
|
+
message: `Only the first ${ln} items are kept.`
|
|
2496
|
+
}), e.slice(0, ln);
|
|
2497
|
+
}
|
|
2498
|
+
function Sn(e, t, n, r, i) {
|
|
2499
|
+
return e === void 0 ? n : typeof e == "string" && t.has(e) ? e : (i.push({
|
|
2500
|
+
severity: "warning",
|
|
2501
|
+
code: "INTENT_REGION_VALUE_DEFAULTED",
|
|
2502
|
+
path: r,
|
|
2503
|
+
message: `Unknown value; "${n}" was used instead.`
|
|
2504
|
+
}), n);
|
|
2505
|
+
}
|
|
2506
|
+
function Cn(e, t) {
|
|
2507
|
+
return {
|
|
2508
|
+
severity: "error",
|
|
2509
|
+
code: "INTENT_REGION_INVALID",
|
|
2510
|
+
path: e,
|
|
2511
|
+
message: t
|
|
2512
|
+
};
|
|
2513
|
+
}
|
|
2514
|
+
function wn(e) {
|
|
2515
|
+
return e.kind === "grid" ? e.blocks.length > 0 : e.kind === "split" ? e.main.length > 0 || e.rail.length > 0 : !1;
|
|
2516
|
+
}
|
|
2517
|
+
function V(e, t, n = {}) {
|
|
2518
|
+
let r = Tn(e, t, n);
|
|
2519
|
+
if (r.value === void 0) return r;
|
|
2520
|
+
let i = U(e) ?? {}, a = [...r.diagnostics], o = Un(i.key, t, a), s = Wn(i.states, t, a);
|
|
2521
|
+
return {
|
|
2522
|
+
value: {
|
|
2523
|
+
...r.value,
|
|
2524
|
+
...o === void 0 ? {} : { key: o },
|
|
2525
|
+
...s === void 0 ? {} : { states: s }
|
|
2526
|
+
},
|
|
2527
|
+
diagnostics: a
|
|
2528
|
+
};
|
|
2529
|
+
}
|
|
2530
|
+
function Tn(e, t, n) {
|
|
2531
|
+
let r = [], i = U(e), a = typeof i?.label == "string" ? i.label.trim() : "";
|
|
2532
|
+
if (i !== null && i.bind !== void 0) return En(i, a, t);
|
|
2533
|
+
let o = i?.value, s = o === null && n.placeholders === !0;
|
|
2534
|
+
if (i === null || a === "" || !s && (typeof o != "number" || !Number.isFinite(o))) return r.push({
|
|
2535
|
+
severity: "error",
|
|
2536
|
+
code: "AGENT_KPI_INVALID",
|
|
2537
|
+
path: t,
|
|
2538
|
+
message: "A KPI needs a non-empty label and a finite numeric value."
|
|
2539
|
+
}), {
|
|
2540
|
+
value: void 0,
|
|
2541
|
+
diagnostics: r
|
|
2542
|
+
};
|
|
2543
|
+
let c = typeof i.unit == "string" ? i.unit.trim().slice(0, Jt) : "", l = typeof i.precision == "number" && Number.isInteger(i.precision) ? Math.min(3, Math.max(0, i.precision)) : void 0, u = kn(i.delta);
|
|
2544
|
+
return i.delta !== void 0 && u === void 0 && r.push({
|
|
2545
|
+
severity: "error",
|
|
2546
|
+
code: "AGENT_KPI_DELTA_DROPPED",
|
|
2547
|
+
path: t,
|
|
2548
|
+
message: "The delta needs a finite value, a unit and a direction; only the value was kept."
|
|
2549
|
+
}), {
|
|
2550
|
+
value: {
|
|
2551
|
+
label: B(a, qt),
|
|
2552
|
+
value: s ? null : o,
|
|
2553
|
+
...c === "" ? {} : { unit: c },
|
|
2554
|
+
...l === void 0 ? {} : { precision: l },
|
|
2555
|
+
...u === void 0 ? {} : { delta: u },
|
|
2556
|
+
origin: t
|
|
2557
|
+
},
|
|
2558
|
+
diagnostics: r
|
|
2559
|
+
};
|
|
2560
|
+
}
|
|
2561
|
+
function En(e, t, n) {
|
|
2562
|
+
let r = [], i = (e, t) => (r.push({
|
|
2563
|
+
severity: "error",
|
|
2564
|
+
code: e,
|
|
2565
|
+
path: n,
|
|
2566
|
+
message: t
|
|
2567
|
+
}), {
|
|
2568
|
+
value: void 0,
|
|
2569
|
+
diagnostics: r
|
|
2570
|
+
}), a = U(e.bind), o = typeof a?.datasetId == "string" ? a.datasetId.trim() : "", s = typeof a?.field == "string" ? a.field.trim() : "";
|
|
2571
|
+
if (t === "" || a === null || o === "" || s === "") return i("AGENT_KPI_INVALID", "A bound KPI needs a label, bind.datasetId and bind.field.");
|
|
2572
|
+
if (e.value !== void 0 && e.value !== null || e.delta !== void 0) return i("AGENT_BIND_CONFLICT", "A KPI bound to a dataset field must not also give a literal value or delta.");
|
|
2573
|
+
let c = On(a.params);
|
|
2574
|
+
if (c === null) return i("AGENT_BIND_INVALID", "bind.params must map parameter names to scalar values.");
|
|
2575
|
+
e.precision !== void 0 && r.push({
|
|
2576
|
+
severity: "warning",
|
|
2577
|
+
code: "AGENT_KPI_PRECISION_IGNORED",
|
|
2578
|
+
path: n,
|
|
2579
|
+
message: "precision has no effect on a KPI bound to a dataset field."
|
|
2580
|
+
});
|
|
2581
|
+
let l = typeof e.unit == "string" ? e.unit.trim().slice(0, Jt) : "";
|
|
2582
|
+
return {
|
|
2583
|
+
value: {
|
|
2584
|
+
label: B(t, qt),
|
|
2585
|
+
value: null,
|
|
2586
|
+
...l === "" ? {} : { unit: l },
|
|
2587
|
+
bind: {
|
|
2588
|
+
datasetId: o,
|
|
2589
|
+
field: s,
|
|
2590
|
+
...c === void 0 ? {} : { params: c }
|
|
2591
|
+
},
|
|
2592
|
+
origin: n
|
|
2593
|
+
},
|
|
2594
|
+
diagnostics: r
|
|
2595
|
+
};
|
|
2596
|
+
}
|
|
2597
|
+
function Dn(e) {
|
|
2598
|
+
if (e === void 0) return;
|
|
2599
|
+
let t = U(e);
|
|
2600
|
+
if (t === null) return null;
|
|
2601
|
+
let n = {};
|
|
2602
|
+
for (let [e, r] of Object.entries(t)) {
|
|
2603
|
+
let t = typeof r == "string" ? [r] : r;
|
|
2604
|
+
if (!Array.isArray(t) || t.length === 0) return null;
|
|
2605
|
+
let i = t.map((e) => typeof e == "string" ? e.trim() : "");
|
|
2606
|
+
if (i.some((e) => e === "")) return null;
|
|
2607
|
+
n[e] = i;
|
|
2608
|
+
}
|
|
2609
|
+
return Object.keys(n).length === 0 ? void 0 : n;
|
|
2610
|
+
}
|
|
2611
|
+
function On(e) {
|
|
2612
|
+
if (e === void 0) return;
|
|
2613
|
+
let t = U(e);
|
|
2614
|
+
if (t === null) return null;
|
|
2615
|
+
let n = {};
|
|
2616
|
+
for (let [e, r] of Object.entries(t)) if (typeof r == "string" || typeof r == "boolean" || typeof r == "number" && Number.isFinite(r)) n[e] = r;
|
|
2617
|
+
else return null;
|
|
2618
|
+
return Object.keys(n).length === 0 ? void 0 : n;
|
|
2619
|
+
}
|
|
2620
|
+
function kn(e) {
|
|
2621
|
+
let t = U(e);
|
|
2622
|
+
if (!(t === null || typeof t.value != "number" || !Number.isFinite(t.value) || typeof t.unit != "string" || !dn.has(t.unit) || typeof t.direction != "string" || !fn.has(t.direction))) return {
|
|
2623
|
+
value: t.value,
|
|
2624
|
+
unit: t.unit,
|
|
2625
|
+
direction: t.direction
|
|
2626
|
+
};
|
|
2627
|
+
}
|
|
2628
|
+
function H(e, t, n, r) {
|
|
2629
|
+
let i = [], a = (e, t) => (i.push({
|
|
2630
|
+
severity: "error",
|
|
2631
|
+
code: e,
|
|
2632
|
+
path: n,
|
|
2633
|
+
message: t
|
|
2634
|
+
}), {
|
|
2635
|
+
value: void 0,
|
|
2636
|
+
diagnostics: i
|
|
2637
|
+
}), o = (e, t, r = n) => {
|
|
2638
|
+
i.push({
|
|
2639
|
+
severity: "warning",
|
|
2640
|
+
code: e,
|
|
2641
|
+
path: r,
|
|
2642
|
+
message: t
|
|
2643
|
+
});
|
|
2644
|
+
}, s = U(e);
|
|
2645
|
+
if (s === null) return a("AGENT_BLOCK_INVALID", "A block must be an object.");
|
|
2646
|
+
let c = typeof s.candidate == "string" ? s.candidate.trim() : "", l = c === "" ? void 0 : t.candidates?.find((e) => e.id === c);
|
|
2647
|
+
if (c !== "" && l === void 0) return a("AGENT_CANDIDATE_UNKNOWN", `Candidate ${c} is not in this round's list.`);
|
|
2648
|
+
if (l?.fact === "value") return a("AGENT_CANDIDATE_KPI_ONLY", `Candidate ${c} is a single value; use it as a KPI bind, not as a block.`);
|
|
2649
|
+
let u = l === void 0 ? typeof s.type == "string" ? s.type.trim() : "" : l.type, d = t.materials.find((e) => e.type === u);
|
|
2650
|
+
if (u === "" || d === void 0 || d.children === !0) return a("AGENT_BLOCK_TYPE_UNKNOWN", "The block type is not in the catalog.");
|
|
2651
|
+
let f = typeof s.title == "string" ? s.title.trim() : "";
|
|
2652
|
+
B(f, Yt).length < f.length && (f = B(f, Yt), o("AGENT_BLOCK_TEXT_TRIMMED", "The block title was trimmed."));
|
|
2653
|
+
let p = typeof s.note == "string" ? s.note.trim() : "";
|
|
2654
|
+
B(p, Xt).length < p.length && (p = B(p, Xt), o("AGENT_BLOCK_TEXT_TRIMMED", "The block note was trimmed."));
|
|
2655
|
+
let m = 1;
|
|
2656
|
+
if (r.grid) {
|
|
2657
|
+
let e = typeof s.span == "number" ? Math.round(s.span) : 1;
|
|
2658
|
+
m = Math.min(4, Math.max(1, Number.isFinite(e) ? e : 1)), m !== e && o("AGENT_BLOCK_SPAN_CLAMPED", "The block span was clamped to 1–4.");
|
|
2659
|
+
}
|
|
2660
|
+
let h = l === void 0 ? void 0 : On(s.params);
|
|
2661
|
+
if (h === null) return a("AGENT_BIND_INVALID", "params must map parameter names to scalar values.");
|
|
2662
|
+
let g = l === void 0 ? An(s, d, t, n, i) : {
|
|
2663
|
+
kind: "dataset",
|
|
2664
|
+
datasetId: l.datasetId,
|
|
2665
|
+
fields: l.fields,
|
|
2666
|
+
...h === void 0 ? {} : { params: h }
|
|
2667
|
+
};
|
|
2668
|
+
if (g === void 0) return {
|
|
2669
|
+
value: void 0,
|
|
2670
|
+
diagnostics: i
|
|
2671
|
+
};
|
|
2672
|
+
let _ = jn(s.props, d, n, i), v = Un(s.key, n, i), y = typeof s.substituteFor == "string" ? s.substituteFor.trim().slice(0, Qt) : "";
|
|
2673
|
+
return {
|
|
2674
|
+
value: {
|
|
2675
|
+
type: u,
|
|
2676
|
+
title: f,
|
|
2677
|
+
span: m,
|
|
2678
|
+
bind: g,
|
|
2679
|
+
...p === "" ? {} : { note: p },
|
|
2680
|
+
..._ === void 0 ? {} : { props: _ },
|
|
2681
|
+
...y === "" ? {} : { substituteFor: y },
|
|
2682
|
+
...l === void 0 ? {} : { candidate: l.id },
|
|
2683
|
+
...v === void 0 ? {} : { key: v },
|
|
2684
|
+
origin: n
|
|
2685
|
+
},
|
|
2686
|
+
diagnostics: i
|
|
2687
|
+
};
|
|
2688
|
+
}
|
|
2689
|
+
function An(e, t, n, r, i) {
|
|
2690
|
+
let a = (e, t) => {
|
|
2691
|
+
i.push({
|
|
2692
|
+
severity: "error",
|
|
2693
|
+
code: e,
|
|
2694
|
+
path: r,
|
|
2695
|
+
message: t
|
|
2696
|
+
});
|
|
2697
|
+
};
|
|
2698
|
+
if (t.data === "tabular") {
|
|
2699
|
+
let t = typeof e.datasetId == "string" ? e.datasetId.trim() : "";
|
|
2700
|
+
if (t !== "") {
|
|
2701
|
+
if (e.table !== void 0) return a("AGENT_BIND_CONFLICT", "A data block must give either datasetId or table, not both.");
|
|
2702
|
+
let n = Dn(e.fields), r = On(e.params);
|
|
2703
|
+
return n === null || r === null ? a("AGENT_BIND_INVALID", "fields must map role ids to field ids and params must map names to scalar values.") : {
|
|
2704
|
+
kind: "dataset",
|
|
2705
|
+
datasetId: t,
|
|
2706
|
+
...n === void 0 ? {} : { fields: n },
|
|
2707
|
+
...r === void 0 ? {} : { params: r }
|
|
2708
|
+
};
|
|
2709
|
+
}
|
|
2710
|
+
let n = Mn(e.table, r, i);
|
|
2711
|
+
return n === null ? a("AGENT_BLOCK_DATA_MISSING", "A data block needs a table or a dataset reference.") : {
|
|
2712
|
+
kind: "table",
|
|
2713
|
+
table: n
|
|
2714
|
+
};
|
|
2715
|
+
}
|
|
2716
|
+
if (t.data === "scalar") {
|
|
2717
|
+
let o = typeof e.assetId == "string" ? e.assetId.trim() : "";
|
|
2718
|
+
if (o !== "") return !t.asset || !n.assets.some((e) => e.id === o) ? a("AGENT_ASSET_UNKNOWN", "The asset is not in the authorized asset list.") : {
|
|
2719
|
+
kind: "asset",
|
|
2720
|
+
assetId: o
|
|
2721
|
+
};
|
|
2722
|
+
let s = typeof e.text == "string" ? e.text.trim() : "";
|
|
2723
|
+
return s === "" ? a("AGENT_BLOCK_DATA_MISSING", "A text block needs text.") : (B(s, Zt).length < s.length && (s = B(s, Zt), i.push({
|
|
2724
|
+
severity: "warning",
|
|
2725
|
+
code: "AGENT_BLOCK_TEXT_TRIMMED",
|
|
2726
|
+
path: r,
|
|
2727
|
+
message: "The block text was trimmed."
|
|
2728
|
+
})), {
|
|
2729
|
+
kind: "text",
|
|
2730
|
+
text: s
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
return { kind: "none" };
|
|
2734
|
+
}
|
|
2735
|
+
function jn(e, t, n, r) {
|
|
2736
|
+
if (e === void 0) return;
|
|
2737
|
+
let i = () => {
|
|
2738
|
+
r.push({
|
|
2739
|
+
severity: "warning",
|
|
2740
|
+
code: "AGENT_BLOCK_PROPS_DROPPED",
|
|
2741
|
+
path: n,
|
|
2742
|
+
message: "A prop that is not declared by the material was ignored."
|
|
2743
|
+
});
|
|
2744
|
+
}, a = U(e);
|
|
2745
|
+
if (a === null) {
|
|
2746
|
+
i();
|
|
2747
|
+
return;
|
|
2748
|
+
}
|
|
2749
|
+
let o = Object.keys(a);
|
|
2750
|
+
o.length > rn && i();
|
|
2751
|
+
let s = {};
|
|
2752
|
+
for (let e of o.slice(0, rn)) {
|
|
2753
|
+
let n = t.props[e], r = a[e];
|
|
2754
|
+
if (n === void 0) {
|
|
2755
|
+
i();
|
|
2756
|
+
continue;
|
|
2757
|
+
}
|
|
2758
|
+
if (n.kind === "number") {
|
|
2759
|
+
typeof r == "number" && Number.isFinite(r) ? s[e] = r : i();
|
|
2760
|
+
continue;
|
|
2761
|
+
}
|
|
2762
|
+
if (n.kind === "boolean") {
|
|
2763
|
+
typeof r == "boolean" ? s[e] = r : i();
|
|
2764
|
+
continue;
|
|
2765
|
+
}
|
|
2766
|
+
if (typeof r != "string") {
|
|
2767
|
+
i();
|
|
2768
|
+
continue;
|
|
2769
|
+
}
|
|
2770
|
+
if (n.kind === "enum" && n.values?.includes(r) !== !0) {
|
|
2771
|
+
i();
|
|
2772
|
+
continue;
|
|
2773
|
+
}
|
|
2774
|
+
s[e] = r.slice(0, an);
|
|
2775
|
+
}
|
|
2776
|
+
return Object.keys(s).length === 0 ? void 0 : s;
|
|
2777
|
+
}
|
|
2778
|
+
function Mn(e, t, n) {
|
|
2779
|
+
let r = (e, r) => {
|
|
2780
|
+
n.push({
|
|
2781
|
+
severity: "warning",
|
|
2782
|
+
code: e,
|
|
2783
|
+
path: t,
|
|
2784
|
+
message: r
|
|
2785
|
+
});
|
|
2786
|
+
}, i = U(e);
|
|
2787
|
+
if (i === null || !Array.isArray(i.columns) || !Array.isArray(i.rows) || i.columns.length < 1 || i.rows.length < 1) return null;
|
|
2788
|
+
i.columns.length > $t && r("AGENT_BLOCK_COLUMNS_TRIMMED", `A table keeps at most ${$t} columns.`);
|
|
2789
|
+
let a = [];
|
|
2790
|
+
for (let e of i.columns.slice(0, $t)) {
|
|
2791
|
+
let t = U(e);
|
|
2792
|
+
if (t === null) return null;
|
|
2793
|
+
let n = typeof t.id == "string" ? t.id.trim() : "", i = typeof t.label == "string" ? t.label.trim() : "", o = t.type;
|
|
2794
|
+
if (!/^[a-zA-Z][a-zA-Z0-9_]{0,15}$/.test(n) || i === "" || o !== "string" && o !== "number" && o !== "boolean" || a.some((e) => e.id === n)) return null;
|
|
2795
|
+
let s = i;
|
|
2796
|
+
s.length > nn && (s = s.slice(0, nn), r("AGENT_BLOCK_TEXT_TRIMMED", "A column label was trimmed.")), a.push({
|
|
2797
|
+
id: n,
|
|
2798
|
+
label: s,
|
|
2799
|
+
type: o
|
|
2800
|
+
});
|
|
2801
|
+
}
|
|
2802
|
+
i.rows.length > en && r("AGENT_BLOCK_ROWS_TRIMMED", `A table keeps at most ${en} rows.`);
|
|
2803
|
+
let o = /* @__PURE__ */ new Set(), s = [];
|
|
2804
|
+
for (let e of i.rows.slice(0, en)) {
|
|
2805
|
+
let t = U(e);
|
|
2806
|
+
if (t === null) {
|
|
2807
|
+
r("AGENT_BLOCK_INVALID", "A table row was not an object and was skipped.");
|
|
2808
|
+
continue;
|
|
2809
|
+
}
|
|
2810
|
+
let n = {};
|
|
2811
|
+
for (let e of a) {
|
|
2812
|
+
let r = t[e.id];
|
|
2813
|
+
e.type === "number" && typeof r == "number" && Number.isFinite(r) || e.type === "boolean" && typeof r == "boolean" ? n[e.id] = r : (e.type !== "string" && o.add(e.id), n[e.id] = r == null ? "" : String(r).slice(0, tn));
|
|
2814
|
+
}
|
|
2815
|
+
s.push(n);
|
|
2816
|
+
}
|
|
2817
|
+
return s.length === 0 ? null : (o.size > 0 && r("AGENT_BLOCK_COLUMN_COERCED", "A column value did not match its declared type."), {
|
|
2818
|
+
columns: a.map((e) => o.has(e.id) ? {
|
|
2819
|
+
...e,
|
|
2820
|
+
type: "string"
|
|
2821
|
+
} : e),
|
|
2822
|
+
rows: s
|
|
2823
|
+
});
|
|
2824
|
+
}
|
|
2825
|
+
var Nn = /^[a-z][a-z0-9-]{0,31}$/, Pn = 8, Fn = 4, In = 4, Ln = 8, Rn = /* @__PURE__ */ new Set([
|
|
2826
|
+
"gt",
|
|
2827
|
+
"gte",
|
|
2828
|
+
"lt",
|
|
2829
|
+
"lte",
|
|
2830
|
+
"eq",
|
|
2831
|
+
"neq"
|
|
2832
|
+
]), zn = /* @__PURE__ */ new Set([
|
|
2833
|
+
"success",
|
|
2834
|
+
"warning",
|
|
2835
|
+
"danger",
|
|
2836
|
+
"info"
|
|
2837
|
+
]), Bn = /* @__PURE__ */ new Set([
|
|
2838
|
+
"show",
|
|
2839
|
+
"hide",
|
|
2840
|
+
"toggle"
|
|
2841
|
+
]), Vn = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/, Hn = /^[A-Za-z0-9_][A-Za-z0-9_.:-]{0,127}$/;
|
|
2842
|
+
function Un(e, t, n) {
|
|
2843
|
+
if (e === void 0) return;
|
|
2844
|
+
let r = typeof e == "string" ? e.trim() : "";
|
|
2845
|
+
if (Nn.test(r)) return r;
|
|
2846
|
+
n.push({
|
|
2847
|
+
severity: "warning",
|
|
2848
|
+
code: "INTENT_KEY_INVALID",
|
|
2849
|
+
path: t,
|
|
2850
|
+
message: "A key must start with a lowercase letter and use letters, digits or hyphens (≤ 32)."
|
|
2851
|
+
});
|
|
2852
|
+
}
|
|
2853
|
+
function Wn(e, t, n) {
|
|
2854
|
+
if (e === void 0) return;
|
|
2855
|
+
let r = U(e);
|
|
2856
|
+
if (r?.source === "level-scale") return {
|
|
2857
|
+
rules: [],
|
|
2858
|
+
source: "level-scale"
|
|
2859
|
+
};
|
|
2860
|
+
let i = Array.isArray(e) ? e : Array.isArray(r?.rules) ? r.rules : void 0, a = (e) => {
|
|
2861
|
+
n.push({
|
|
2862
|
+
severity: "error",
|
|
2863
|
+
code: "INTENT_STATE_INVALID",
|
|
2864
|
+
path: t,
|
|
2865
|
+
message: e
|
|
2866
|
+
});
|
|
2867
|
+
};
|
|
2868
|
+
if (i === void 0) return a("states must be a list of { op, value, tone } rules.");
|
|
2869
|
+
let o = [];
|
|
2870
|
+
for (let e of i.slice(0, In)) {
|
|
2871
|
+
let t = U(e), n = typeof t?.op == "string" ? t.op : "", r = typeof t?.tone == "string" ? t.tone : "", i = t?.value;
|
|
2872
|
+
if (!(Rn.has(n) && zn.has(r) && (typeof i == "number" && Number.isFinite(i) || typeof i == "string" && i.trim() !== "" && (n === "eq" || n === "neq")))) {
|
|
2873
|
+
a("Each state rule needs op (gt/gte/lt/lte/eq/neq), a value and a tone.");
|
|
2874
|
+
continue;
|
|
2875
|
+
}
|
|
2876
|
+
let s = typeof t?.label == "string" ? B(t.label.trim(), Ln) : "";
|
|
2877
|
+
o.push({
|
|
2878
|
+
op: n,
|
|
2879
|
+
value: typeof i == "string" ? i.trim() : i,
|
|
2880
|
+
tone: r,
|
|
2881
|
+
...s === "" ? {} : { label: s }
|
|
2882
|
+
});
|
|
2883
|
+
}
|
|
2884
|
+
if (i.length > In && n.push({
|
|
2885
|
+
severity: "warning",
|
|
2886
|
+
code: "INTENT_ITEMS_TRIMMED",
|
|
2887
|
+
path: t,
|
|
2888
|
+
message: `Only the first ${In} state rules are kept.`
|
|
2889
|
+
}), o.length !== 0) return {
|
|
2890
|
+
rules: o,
|
|
2891
|
+
...r?.suggested === !0 ? { suggested: !0 } : {}
|
|
2892
|
+
};
|
|
2893
|
+
}
|
|
2894
|
+
function Gn(e, t) {
|
|
2895
|
+
if (e === void 0) return;
|
|
2896
|
+
if (!Array.isArray(e)) {
|
|
2897
|
+
t.push({
|
|
2898
|
+
severity: "error",
|
|
2899
|
+
code: "INTENT_INTERACTION_INVALID",
|
|
2900
|
+
path: "interactions",
|
|
2901
|
+
message: "interactions must be an array."
|
|
2902
|
+
});
|
|
2903
|
+
return;
|
|
2904
|
+
}
|
|
2905
|
+
let n = [];
|
|
2906
|
+
for (let [r, i] of e.slice(0, Pn).entries()) {
|
|
2907
|
+
let e = `interactions[${r}]`, a = Jn(i, e);
|
|
2908
|
+
typeof a == "string" ? t.push({
|
|
2909
|
+
severity: "error",
|
|
2910
|
+
code: "INTENT_INTERACTION_INVALID",
|
|
2911
|
+
path: e,
|
|
2912
|
+
message: a
|
|
2913
|
+
}) : n.push(a);
|
|
2914
|
+
}
|
|
2915
|
+
return e.length > Pn && t.push({
|
|
2916
|
+
severity: "warning",
|
|
2917
|
+
code: "INTENT_ITEMS_TRIMMED",
|
|
2918
|
+
path: "interactions",
|
|
2919
|
+
message: `Only the first ${Pn} interactions are kept.`
|
|
2920
|
+
}), n.length === 0 ? void 0 : n;
|
|
2921
|
+
}
|
|
2922
|
+
function Kn(e, t) {
|
|
2923
|
+
if (Array.isArray(e)) for (let [n, r] of e.slice(0, 3).entries()) {
|
|
2924
|
+
let e = typeof r == "string" ? B(r.trim(), 40) : "";
|
|
2925
|
+
e !== "" && t.push({
|
|
2926
|
+
severity: "warning",
|
|
2927
|
+
code: "INTENT_BEHAVIOR_GAP",
|
|
2928
|
+
path: `gaps[${n}]`,
|
|
2929
|
+
message: `The model reported a request it could not fulfil: ${e}`,
|
|
2930
|
+
detail: { text: e }
|
|
2931
|
+
});
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
function qn(e, t = 0) {
|
|
2935
|
+
let n = [];
|
|
2936
|
+
for (let [r, i] of e.entries()) {
|
|
2937
|
+
let e = Jn(i, `interactions[${t + r}]`);
|
|
2938
|
+
typeof e != "string" && n.push(e);
|
|
2939
|
+
}
|
|
2940
|
+
return n;
|
|
2941
|
+
}
|
|
2942
|
+
function Jn(e, t) {
|
|
2943
|
+
let n = U(e);
|
|
2944
|
+
if (n === null) return "An interaction must be an object.";
|
|
2945
|
+
let r = typeof n.from == "string" ? n.from.trim() : "", i = typeof n.event == "string" ? n.event.trim() : "", a = (Array.isArray(n.to) ? n.to : [n.to]).filter((e) => typeof e == "string").map((e) => e.trim()).filter((e) => e !== "");
|
|
2946
|
+
if (r === "" || a.length === 0) return "An interaction needs \"from\" and \"to\" (block keys or titles).";
|
|
2947
|
+
if (!Vn.test(i)) return "An interaction needs the event name of the source block.";
|
|
2948
|
+
let o = [...new Set(a)].slice(0, Fn);
|
|
2949
|
+
if (n.kind === "filter") {
|
|
2950
|
+
let e = typeof n.param == "string" ? n.param.trim() : "";
|
|
2951
|
+
if (!Hn.test(e)) return "A filter needs the target query parameter \"param\".";
|
|
2952
|
+
let a = typeof n.field == "string" ? n.field.trim() : "";
|
|
2953
|
+
return a !== "" && !Hn.test(a) ? "The filter field is not a field id." : {
|
|
2954
|
+
kind: "filter",
|
|
2955
|
+
from: r,
|
|
2956
|
+
event: i,
|
|
2957
|
+
to: o,
|
|
2958
|
+
param: e,
|
|
2959
|
+
...a === "" ? {} : { field: a },
|
|
2960
|
+
...n.reset === !0 ? { reset: !0 } : {},
|
|
2961
|
+
origin: t
|
|
2962
|
+
};
|
|
2963
|
+
}
|
|
2964
|
+
if (n.kind === "show") return {
|
|
2965
|
+
kind: "show",
|
|
2966
|
+
from: r,
|
|
2967
|
+
event: i,
|
|
2968
|
+
to: o,
|
|
2969
|
+
mode: typeof n.mode == "string" && Bn.has(n.mode) ? n.mode : "toggle",
|
|
2970
|
+
origin: t
|
|
2971
|
+
};
|
|
2972
|
+
if (n.kind === "state") {
|
|
2973
|
+
let e = typeof n.state == "string" ? B(n.state.trim(), 16) : "";
|
|
2974
|
+
return e === "" ? "A state interaction needs \"state\": a state name or tone of the target, or \"reset\"." : {
|
|
2975
|
+
kind: "state",
|
|
2976
|
+
from: r,
|
|
2977
|
+
event: i,
|
|
2978
|
+
to: o,
|
|
2979
|
+
state: e,
|
|
2980
|
+
origin: t
|
|
2981
|
+
};
|
|
2982
|
+
}
|
|
2983
|
+
return "Interaction kind must be \"filter\", \"show\" or \"state\".";
|
|
2984
|
+
}
|
|
2985
|
+
function Yn(e) {
|
|
2986
|
+
let t = e;
|
|
2987
|
+
if (typeof e == "string") {
|
|
2988
|
+
let n = e.trim().replace(/^```(?:json)?/i, "").replace(/```$/, "").trim();
|
|
2989
|
+
try {
|
|
2990
|
+
t = JSON.parse(n);
|
|
2991
|
+
} catch {
|
|
2992
|
+
return;
|
|
2993
|
+
}
|
|
2994
|
+
}
|
|
2995
|
+
return U(t) ?? void 0;
|
|
2996
|
+
}
|
|
2997
|
+
function Xn(e, t) {
|
|
2998
|
+
return typeof e == "string" ? B(e.trim(), t) : "";
|
|
2999
|
+
}
|
|
3000
|
+
function U(e) {
|
|
3001
|
+
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
3002
|
+
}
|
|
3003
|
+
function W(e, t, n, r) {
|
|
3004
|
+
return e.push({
|
|
3005
|
+
severity: "error",
|
|
3006
|
+
code: t,
|
|
3007
|
+
path: n,
|
|
3008
|
+
message: r
|
|
3009
|
+
}), {
|
|
3010
|
+
intent: void 0,
|
|
3011
|
+
diagnostics: e
|
|
3012
|
+
};
|
|
3013
|
+
}
|
|
3014
|
+
function Zn(e, t, n) {
|
|
3015
|
+
e.push({
|
|
3016
|
+
severity: "error",
|
|
3017
|
+
code: t,
|
|
3018
|
+
path: "",
|
|
3019
|
+
message: n
|
|
3020
|
+
});
|
|
3021
|
+
}
|
|
3022
|
+
//#endregion
|
|
3023
|
+
//#region ../host-kit/dist/intent/intent-prepare.js
|
|
3024
|
+
var Qn = /^(?:kpis\[\d+\]|blocks\[\d+\]|interactions\[\d+\]|regions\[\d+\]\.(?:items|blocks|main|rail)\[\d+\])$/, $n = /* @__PURE__ */ new Set([
|
|
3025
|
+
"AGENT_BLOCK_BINDING_UNSATISFIED",
|
|
3026
|
+
"AGENT_BINDING_FIELD_UNKNOWN",
|
|
3027
|
+
"AGENT_BINDING_TYPE_MISMATCH",
|
|
3028
|
+
"AGENT_DATASET_PARAM_INVALID",
|
|
3029
|
+
"AGENT_KPI_MULTI_ROW"
|
|
3030
|
+
]);
|
|
3031
|
+
function er(e) {
|
|
3032
|
+
let t = gn(e.output, {
|
|
3033
|
+
catalog: e.catalog,
|
|
3034
|
+
placeholders: e.mode === "deterministic"
|
|
3035
|
+
}), n = t.diagnostics.filter((e) => e.severity === "warning"), r = t.diagnostics.filter((e) => e.severity === "error").map((e) => ({
|
|
3036
|
+
code: e.code,
|
|
3037
|
+
path: e.path
|
|
3038
|
+
}));
|
|
3039
|
+
if (t.intent === void 0) return {
|
|
3040
|
+
intent: void 0,
|
|
3041
|
+
compiled: void 0,
|
|
3042
|
+
issues: rr(r),
|
|
3043
|
+
warnings: n,
|
|
3044
|
+
deliverable: !1
|
|
3045
|
+
};
|
|
3046
|
+
let i = ut({
|
|
3047
|
+
intent: t.intent,
|
|
3048
|
+
catalog: e.catalog,
|
|
3049
|
+
mode: e.mode,
|
|
3050
|
+
...e.references === void 0 ? {} : { references: e.references },
|
|
3051
|
+
...e.capabilities === void 0 ? {} : { capabilities: e.capabilities }
|
|
3052
|
+
});
|
|
3053
|
+
if (!i.ok) {
|
|
3054
|
+
for (let e of i.diagnostics) r.push({
|
|
3055
|
+
code: e.code,
|
|
3056
|
+
path: e.path
|
|
3057
|
+
});
|
|
3058
|
+
return {
|
|
3059
|
+
intent: t.intent,
|
|
3060
|
+
compiled: void 0,
|
|
3061
|
+
issues: rr(r),
|
|
3062
|
+
warnings: n,
|
|
3063
|
+
deliverable: !1
|
|
87
3064
|
};
|
|
88
3065
|
}
|
|
3066
|
+
for (let e of i.value.warnings) n.push(e), ($n.has(e.code) || O.has(e.code)) && r.push({
|
|
3067
|
+
code: e.code,
|
|
3068
|
+
path: e.path
|
|
3069
|
+
});
|
|
3070
|
+
let a = rr(r);
|
|
3071
|
+
return {
|
|
3072
|
+
intent: t.intent,
|
|
3073
|
+
compiled: i.value,
|
|
3074
|
+
issues: a,
|
|
3075
|
+
warnings: n,
|
|
3076
|
+
deliverable: a.every((e) => Qn.test(e.path))
|
|
3077
|
+
};
|
|
89
3078
|
}
|
|
90
|
-
function
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
3079
|
+
function tr(e) {
|
|
3080
|
+
return e.map((e) => `${e.code}@${e.path}`).sort().join("|");
|
|
3081
|
+
}
|
|
3082
|
+
function nr(e, t, n) {
|
|
3083
|
+
let r = [];
|
|
3084
|
+
for (let i of e) {
|
|
3085
|
+
if (i.severity !== "error" || i.code.startsWith("CHANGE_")) continue;
|
|
3086
|
+
let [e, a] = i.path, o = e === "components" && typeof a == "number" ? t[a] : void 0;
|
|
3087
|
+
r.push({
|
|
3088
|
+
code: i.code,
|
|
3089
|
+
path: o === void 0 ? "" : n[o] ?? ""
|
|
98
3090
|
});
|
|
99
|
-
|
|
100
|
-
|
|
3091
|
+
}
|
|
3092
|
+
return rr(r);
|
|
3093
|
+
}
|
|
3094
|
+
function rr(e) {
|
|
3095
|
+
let t = /* @__PURE__ */ new Set(), n = [];
|
|
3096
|
+
for (let r of e) {
|
|
3097
|
+
let e = `${r.code}@${r.path}`;
|
|
3098
|
+
if (!t.has(e) && (t.add(e), n.push(r), n.length >= 100)) break;
|
|
3099
|
+
}
|
|
3100
|
+
return n;
|
|
101
3101
|
}
|
|
102
|
-
|
|
3102
|
+
//#endregion
|
|
3103
|
+
//#region ../host-kit/dist/intent/intent-session.js
|
|
3104
|
+
function ir(e) {
|
|
103
3105
|
return {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
3106
|
+
intent: yr(e.intent),
|
|
3107
|
+
compiled: e.compiled,
|
|
3108
|
+
catalog: e.catalog,
|
|
3109
|
+
references: e.references,
|
|
3110
|
+
mode: e.mode
|
|
3111
|
+
};
|
|
3112
|
+
}
|
|
3113
|
+
function ar(e, t) {
|
|
3114
|
+
let n = e.compiled.document.canvas;
|
|
3115
|
+
return n.width === t.canvas.width && n.height === t.canvas.height;
|
|
3116
|
+
}
|
|
3117
|
+
function or(e, t, n) {
|
|
3118
|
+
let r = cr(e.intent, t, e.catalog);
|
|
3119
|
+
if (!r.ok) return r;
|
|
3120
|
+
let i = ut({
|
|
3121
|
+
intent: r.intent,
|
|
3122
|
+
catalog: e.catalog,
|
|
3123
|
+
mode: e.mode,
|
|
3124
|
+
...e.references === void 0 ? {} : { references: e.references }
|
|
3125
|
+
});
|
|
3126
|
+
if (!i.ok) return {
|
|
3127
|
+
ok: !1,
|
|
3128
|
+
diagnostics: i.diagnostics
|
|
3129
|
+
};
|
|
3130
|
+
let a = e.compiled.document, o = i.value.document, s = new Map(n.components.map((e) => [e.id, e])), c = new Map(a.components.map((e) => [e.id, e])), l = new Map(o.components.map((e) => [e.id, e])), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set();
|
|
3131
|
+
for (let [e, t] of c) {
|
|
3132
|
+
let n = s.get(e);
|
|
3133
|
+
n === void 0 ? d.add(e) : Nr(t, n) || u.add(e);
|
|
3134
|
+
}
|
|
3135
|
+
let f = [...c.keys()].filter((e) => !l.has(e)), p = o.components.filter((e) => !c.has(e.id)), m = o.components.filter((e) => {
|
|
3136
|
+
let t = c.get(e.id);
|
|
3137
|
+
return t !== void 0 && !Nr(t, e);
|
|
3138
|
+
}), h = /* @__PURE__ */ new Set(), g = [], _ = f.filter((e) => !d.has(e) && !u.has(e));
|
|
3139
|
+
for (let e of f) u.has(e) && h.add(e);
|
|
3140
|
+
let v = m.filter((e) => !d.has(e.id) && !u.has(e.id) && c.get(e.id)?.type !== e.type), y = new Set(v.map((e) => e.id)), b = /* @__PURE__ */ new Map(), x = new Map((a.dataSources ?? []).map((e) => [String(e.id), e])), S = new Map((o.dataSources ?? []).map((e) => [String(e.id), e]));
|
|
3141
|
+
for (let e of m) {
|
|
3142
|
+
let t = X(c.get(e.id)?.dataValue), n = X(e.dataValue), r = X(s.get(e.id)?.dataValue);
|
|
3143
|
+
t !== void 0 && n !== void 0 && r !== void 0 && t !== n && (b.has(n) || Lr(x.get(t), S.get(n)) && b.set(n, r));
|
|
3144
|
+
}
|
|
3145
|
+
let C = m.filter((e) => {
|
|
3146
|
+
if (d.has(e.id) || u.has(e.id) || y.has(e.id)) return !1;
|
|
3147
|
+
let t = e.dataValue;
|
|
3148
|
+
return typeof t?.dataSourceId == "string" && !b.has(t.dataSourceId) && JSON.stringify(c.get(e.id)?.dataValue ?? null) !== JSON.stringify(t);
|
|
3149
|
+
}), w = Ir(o, [
|
|
3150
|
+
...p,
|
|
3151
|
+
...v,
|
|
3152
|
+
...C
|
|
3153
|
+
], n.dataSources ?? [], b), T = jr(a, o, n, s), E = [], D = [], O = (e) => {
|
|
3154
|
+
for (let t of e) D.push(g.length), g.push(t);
|
|
3155
|
+
}, k = (e) => {
|
|
3156
|
+
E.push(g.length), g.push(e);
|
|
3157
|
+
};
|
|
3158
|
+
O(T.detach), w.fresh.length > 0 && k({
|
|
3159
|
+
type: "add-data-sources",
|
|
3160
|
+
dataSources: w.fresh
|
|
3161
|
+
}), O(T.attach);
|
|
3162
|
+
let A = n.components.reduce((e, t) => Math.max(e, t.zIndex ?? 0), 0);
|
|
3163
|
+
for (let e of m) {
|
|
3164
|
+
if (d.has(e.id)) continue;
|
|
3165
|
+
if (u.has(e.id)) {
|
|
3166
|
+
h.add(e.id);
|
|
3167
|
+
continue;
|
|
3168
|
+
}
|
|
3169
|
+
if (y.has(e.id)) continue;
|
|
3170
|
+
let t = Fr(w.applyPrevious(c.get(e.id)), w.apply(e));
|
|
3171
|
+
Object.keys(t).length !== 0 && k({
|
|
3172
|
+
type: "update-components",
|
|
3173
|
+
componentIds: [e.id],
|
|
3174
|
+
patch: t
|
|
3175
|
+
});
|
|
3176
|
+
}
|
|
3177
|
+
let ee = [..._, ...y];
|
|
3178
|
+
ee.length > 0 && k({
|
|
3179
|
+
type: "remove-components",
|
|
3180
|
+
componentIds: ee
|
|
3181
|
+
});
|
|
3182
|
+
for (let e of v) k({
|
|
3183
|
+
type: "add-component",
|
|
3184
|
+
component: w.apply({
|
|
3185
|
+
...e,
|
|
3186
|
+
zIndex: s.get(e.id)?.zIndex ?? e.zIndex + A
|
|
3187
|
+
})
|
|
3188
|
+
});
|
|
3189
|
+
for (let e of p) k({
|
|
3190
|
+
type: "add-component",
|
|
3191
|
+
component: w.apply({
|
|
3192
|
+
...e,
|
|
3193
|
+
zIndex: e.zIndex + A
|
|
3194
|
+
})
|
|
3195
|
+
});
|
|
3196
|
+
O(T.wire);
|
|
3197
|
+
let j = I(r.intent.title, r.intent.subtitle), M = sr(e.compiled.behaviors, i.value.behaviors, j), N = E.length > 0 && D.length > 0 ? [{
|
|
3198
|
+
label: j === "en" ? "Layout and content" : "版面与内容",
|
|
3199
|
+
commandIndexes: E
|
|
3200
|
+
}, {
|
|
3201
|
+
label: j === "en" ? "Interactions" : "联动",
|
|
3202
|
+
commandIndexes: D,
|
|
3203
|
+
...M.length === 0 ? {} : { notes: M }
|
|
3204
|
+
}] : void 0;
|
|
3205
|
+
return {
|
|
3206
|
+
ok: !0,
|
|
3207
|
+
session: {
|
|
3208
|
+
...e,
|
|
3209
|
+
intent: r.intent,
|
|
3210
|
+
compiled: i.value
|
|
3211
|
+
},
|
|
3212
|
+
commands: g,
|
|
3213
|
+
keptForUser: [...h],
|
|
3214
|
+
summary: {
|
|
3215
|
+
changed: m.filter((e) => !u.has(e.id) && !d.has(e.id)).length,
|
|
3216
|
+
added: p.length,
|
|
3217
|
+
removed: _.length
|
|
3218
|
+
},
|
|
3219
|
+
warnings: i.value.warnings,
|
|
3220
|
+
...N === void 0 ? {} : { groups: N }
|
|
3221
|
+
};
|
|
3222
|
+
}
|
|
3223
|
+
function sr(e, t, n) {
|
|
3224
|
+
let r = (e) => n === "en" ? `${e.from}: ${e.detail} ${e.to.join(", ")}` : `点「${e.from}」${e.detail}「${e.to.join("」「")}」`, i = (e) => JSON.stringify([
|
|
3225
|
+
e.kind,
|
|
3226
|
+
e.from,
|
|
3227
|
+
e.to,
|
|
3228
|
+
e.detail
|
|
3229
|
+
]), a = (e) => e.filter((e) => e.kind !== "state"), o = new Set(a(e).map(i)), s = new Set(a(t).map(i));
|
|
3230
|
+
return [...a(t).filter((e) => !o.has(i(e))).map((e) => `${n === "en" ? "Add" : "新增"}:${r(e)}`), ...a(e).filter((e) => !s.has(i(e))).map((e) => `${n === "en" ? "Remove" : "去掉"}:${r(e)}`)];
|
|
3231
|
+
}
|
|
3232
|
+
function cr(e, t, n) {
|
|
3233
|
+
let r = yr(e);
|
|
3234
|
+
for (let [e, i] of t.entries()) {
|
|
3235
|
+
let t = `ops[${e}]`, a = Cr(i);
|
|
3236
|
+
if (a === void 0) return q(t, "INTENT_OP_INVALID", "Unknown or malformed operation.");
|
|
3237
|
+
let o = lr(r, a, n, t);
|
|
3238
|
+
if (!o.ok) return o;
|
|
3239
|
+
r = o.intent;
|
|
3240
|
+
}
|
|
3241
|
+
return r.regions.some(_r) ? {
|
|
3242
|
+
ok: !0,
|
|
3243
|
+
intent: r
|
|
3244
|
+
} : q("ops", "INTENT_OP_INVALID", "An edit may not leave the screen without any block.");
|
|
3245
|
+
}
|
|
3246
|
+
function lr(e, t, n, r) {
|
|
3247
|
+
if (t.op === "add") return dr(e, t, n, r);
|
|
3248
|
+
if (t.op === "link") return wr(e, t, r);
|
|
3249
|
+
if (t.op === "unlink") return Tr(e, t, r);
|
|
3250
|
+
if (t.target === "title" || t.target === "subtitle") {
|
|
3251
|
+
if (t.op !== "change") return q(r, "INTENT_OP_INVALID", "The title and subtitle can only be changed.");
|
|
3252
|
+
let n = typeof t.set.text == "string" ? t.set.text.trim() : "";
|
|
3253
|
+
return n === "" ? q(r, "INTENT_OP_INVALID", "A title change needs non-empty text.") : {
|
|
3254
|
+
ok: !0,
|
|
3255
|
+
intent: {
|
|
3256
|
+
...e,
|
|
3257
|
+
[t.target]: B(n, t.target === "title" ? 20 : 40)
|
|
116
3258
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
3259
|
+
};
|
|
3260
|
+
}
|
|
3261
|
+
let i = mr(e, t.target);
|
|
3262
|
+
if (i === void 0) return q(r, "INTENT_OP_TARGET_UNKNOWN", `No item is addressed by "${t.target}".`);
|
|
3263
|
+
if (t.op === "delete") return {
|
|
3264
|
+
ok: !0,
|
|
3265
|
+
intent: Er(gr(e, i), i)
|
|
3266
|
+
};
|
|
3267
|
+
if (t.op === "rebind") return ur(e, i, t, n, r);
|
|
3268
|
+
if (t.op === "change") {
|
|
3269
|
+
if (i.kpi !== void 0 && (Array.isArray(t.set.rules) || "suggested" in t.set)) {
|
|
3270
|
+
let { rules: e, suggested: n, states: r, ...i } = t.set, a = Array.isArray(r) ? { rules: r } : typeof r == "object" && r ? r : Array.isArray(e) ? { rules: e } : void 0;
|
|
3271
|
+
a !== void 0 && (t = {
|
|
3272
|
+
...t,
|
|
3273
|
+
set: {
|
|
3274
|
+
...i,
|
|
3275
|
+
states: n === !0 ? {
|
|
3276
|
+
...a,
|
|
3277
|
+
suggested: !0
|
|
3278
|
+
} : a
|
|
122
3279
|
}
|
|
123
|
-
} : e.request(a.path, {
|
|
124
|
-
...a,
|
|
125
|
-
signal: i
|
|
126
3280
|
});
|
|
127
|
-
}
|
|
128
|
-
|
|
3281
|
+
}
|
|
3282
|
+
let e = i.kpi === void 0 ? pr : fr, n = Object.keys(t.set).filter((t) => !e.has(t));
|
|
3283
|
+
if (n.length > 0) return q(r, "INTENT_OP_INVALID", `Unknown field(s) ${n.join(", ")}; a ${i.kpi === void 0 ? "block" : "KPI"} change may set ${[...e].join(" / ")}.`);
|
|
3284
|
+
}
|
|
3285
|
+
if (i.kpi !== void 0) {
|
|
3286
|
+
if (t.op !== "change") return q(r, "INTENT_OP_INVALID", "A KPI can only be changed or deleted.");
|
|
3287
|
+
let n = V({
|
|
3288
|
+
...xr(i.kpi),
|
|
3289
|
+
...t.set
|
|
3290
|
+
}, i.kpi.origin, { placeholders: i.kpi.value === null });
|
|
3291
|
+
return n.value === void 0 ? q(r, "INTENT_OP_FAILED", "The changed KPI is not usable.") : {
|
|
3292
|
+
ok: !0,
|
|
3293
|
+
intent: hr(e, i, {
|
|
3294
|
+
...n.value,
|
|
3295
|
+
ident: i.kpi.ident ?? i.kpi.origin
|
|
3296
|
+
})
|
|
3297
|
+
};
|
|
3298
|
+
}
|
|
3299
|
+
let a = i.block, o = H(t.op === "swap" ? {
|
|
3300
|
+
...br(Sr(a)),
|
|
3301
|
+
type: t.type,
|
|
3302
|
+
props: t.props
|
|
3303
|
+
} : {
|
|
3304
|
+
...Sr(a),
|
|
3305
|
+
...t.set
|
|
3306
|
+
}, n, a.origin, { grid: i.grid }), s = o.diagnostics.filter((e) => e.severity === "error");
|
|
3307
|
+
return o.value === void 0 || s.length > 0 ? q(r, "INTENT_OP_FAILED", `The edited block is not usable (${s[0]?.code ?? "unknown"}).`) : {
|
|
3308
|
+
ok: !0,
|
|
3309
|
+
intent: hr(e, i, {
|
|
3310
|
+
...o.value,
|
|
3311
|
+
span: a.span,
|
|
3312
|
+
ident: a.ident ?? a.origin
|
|
3313
|
+
})
|
|
129
3314
|
};
|
|
130
3315
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
3316
|
+
function ur(e, t, n, r, i) {
|
|
3317
|
+
if (t.kpi !== void 0) {
|
|
3318
|
+
let r = V({
|
|
3319
|
+
label: t.kpi.label,
|
|
3320
|
+
...t.kpi.unit === void 0 ? {} : { unit: t.kpi.unit },
|
|
3321
|
+
...t.kpi.key === void 0 ? {} : { key: t.kpi.key },
|
|
3322
|
+
...t.kpi.states === void 0 ? {} : { states: t.kpi.states },
|
|
3323
|
+
bind: n.bind
|
|
3324
|
+
}, t.kpi.origin);
|
|
3325
|
+
return r.value === void 0 ? q(i, "INTENT_OP_FAILED", "The rebound KPI is not usable.") : {
|
|
3326
|
+
ok: !0,
|
|
3327
|
+
intent: hr(e, t, {
|
|
3328
|
+
...r.value,
|
|
3329
|
+
ident: G(t.kpi)
|
|
3330
|
+
})
|
|
3331
|
+
};
|
|
3332
|
+
}
|
|
3333
|
+
let a = t.block, { table: o, datasetId: s, fields: c, params: l, text: u, assetId: d, ...f } = Sr(a), p = typeof n.bind.candidate == "string" ? n.bind.candidate : void 0, m = H(p === void 0 ? {
|
|
3334
|
+
...f,
|
|
3335
|
+
...typeof n.bind.type == "string" ? { type: n.bind.type } : {},
|
|
3336
|
+
datasetId: n.bind.datasetId,
|
|
3337
|
+
...n.bind.fields === void 0 ? {} : { fields: n.bind.fields },
|
|
3338
|
+
...n.bind.params === void 0 ? {} : { params: n.bind.params }
|
|
3339
|
+
} : {
|
|
3340
|
+
...f,
|
|
3341
|
+
candidate: p,
|
|
3342
|
+
...K(n.bind.params) ? { params: n.bind.params } : {}
|
|
3343
|
+
}, r, a.origin, { grid: t.grid }), h = m.diagnostics.filter((e) => e.severity === "error");
|
|
3344
|
+
return m.value === void 0 || h.length > 0 ? q(i, "INTENT_OP_FAILED", `The rebound block is not usable (${h[0]?.code ?? "unknown"}).`) : {
|
|
3345
|
+
ok: !0,
|
|
3346
|
+
intent: hr(e, t, {
|
|
3347
|
+
...m.value,
|
|
3348
|
+
span: a.span,
|
|
3349
|
+
ident: G(a)
|
|
3350
|
+
})
|
|
3351
|
+
};
|
|
3352
|
+
}
|
|
3353
|
+
function dr(e, t, n, r) {
|
|
3354
|
+
let i = e.regions.findIndex((e) => e.origin === t.region), a = e.regions[i];
|
|
3355
|
+
if (a === void 0 || a.kind === "band") return q(r, "INTENT_OP_TARGET_UNKNOWN", `"${t.region}" is not a region that holds blocks.`);
|
|
3356
|
+
let o = a.kind === "grid" ? "blocks" : t.part === "rail" ? "rail" : "main", s = vr((a.kind === "grid" ? a.blocks : a[o === "rail" ? "rail" : "main"]).map((e) => e.ident ?? e.origin)), c = `${a.origin === "blocks" ? "blocks" : `${a.origin}.${o}`}[${s}]`, l = H(t.block, n, c, { grid: a.kind === "grid" }), u = l.diagnostics.filter((e) => e.severity === "error");
|
|
3357
|
+
if (l.value === void 0 || u.length > 0) return q(r, "INTENT_OP_FAILED", `The new block is not usable (${u[0]?.code ?? "unknown"}).`);
|
|
3358
|
+
let d = {
|
|
3359
|
+
...l.value,
|
|
3360
|
+
ident: c
|
|
3361
|
+
}, f = e.regions.map((e, t) => t === i ? e.kind === "grid" ? {
|
|
3362
|
+
...e,
|
|
3363
|
+
blocks: [...e.blocks, d]
|
|
3364
|
+
} : e.kind === "split" ? o === "rail" ? {
|
|
3365
|
+
...e,
|
|
3366
|
+
rail: [...e.rail, d]
|
|
3367
|
+
} : {
|
|
3368
|
+
...e,
|
|
3369
|
+
main: [...e.main, d]
|
|
3370
|
+
} : e : e);
|
|
3371
|
+
return {
|
|
3372
|
+
ok: !0,
|
|
3373
|
+
intent: {
|
|
3374
|
+
...e,
|
|
3375
|
+
regions: f
|
|
3376
|
+
}
|
|
3377
|
+
};
|
|
3378
|
+
}
|
|
3379
|
+
var fr = /* @__PURE__ */ new Set([
|
|
3380
|
+
"label",
|
|
3381
|
+
"value",
|
|
3382
|
+
"unit",
|
|
3383
|
+
"precision",
|
|
3384
|
+
"delta",
|
|
3385
|
+
"states",
|
|
3386
|
+
"key"
|
|
3387
|
+
]), pr = /* @__PURE__ */ new Set([
|
|
3388
|
+
"title",
|
|
3389
|
+
"note",
|
|
3390
|
+
"text",
|
|
3391
|
+
"table",
|
|
3392
|
+
"props",
|
|
3393
|
+
"substituteFor",
|
|
3394
|
+
"key"
|
|
3395
|
+
]), G = (e) => e.ident ?? e.origin;
|
|
3396
|
+
function mr(e, t) {
|
|
3397
|
+
for (let [n, r] of e.regions.entries()) {
|
|
3398
|
+
if (r.kind === "band") {
|
|
3399
|
+
let e = r.items.findIndex((e) => G(e) === t), i = r.items[e];
|
|
3400
|
+
if (i !== void 0) return {
|
|
3401
|
+
regionIndex: n,
|
|
3402
|
+
part: "items",
|
|
3403
|
+
itemIndex: e,
|
|
3404
|
+
grid: !1,
|
|
3405
|
+
kpi: i
|
|
3406
|
+
};
|
|
3407
|
+
continue;
|
|
3408
|
+
}
|
|
3409
|
+
let e = r.kind === "grid" ? ["blocks"] : ["main", "rail"];
|
|
3410
|
+
for (let i of e) {
|
|
3411
|
+
let e = r.kind === "grid" ? r.blocks : r[i], a = e.findIndex((e) => G(e) === t), o = e[a];
|
|
3412
|
+
if (o !== void 0) return {
|
|
3413
|
+
regionIndex: n,
|
|
3414
|
+
part: i,
|
|
3415
|
+
itemIndex: a,
|
|
3416
|
+
grid: r.kind === "grid",
|
|
3417
|
+
block: o
|
|
3418
|
+
};
|
|
147
3419
|
}
|
|
148
|
-
return n.aborted ? b() : (f(i, t, s, o.ok ? void 0 : o.error), s);
|
|
149
3420
|
}
|
|
150
|
-
|
|
3421
|
+
}
|
|
3422
|
+
function hr(e, t, n) {
|
|
151
3423
|
return {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
3424
|
+
...e,
|
|
3425
|
+
regions: e.regions.map((e, r) => {
|
|
3426
|
+
if (r !== t.regionIndex) return e;
|
|
3427
|
+
let i = (e) => e.map((e, r) => r === t.itemIndex ? n : e);
|
|
3428
|
+
return e.kind === "band" ? {
|
|
3429
|
+
...e,
|
|
3430
|
+
items: i(e.items)
|
|
3431
|
+
} : e.kind === "grid" ? {
|
|
3432
|
+
...e,
|
|
3433
|
+
blocks: i(e.blocks)
|
|
3434
|
+
} : t.part === "rail" ? {
|
|
3435
|
+
...e,
|
|
3436
|
+
rail: i(e.rail)
|
|
3437
|
+
} : {
|
|
3438
|
+
...e,
|
|
3439
|
+
main: i(e.main)
|
|
160
3440
|
};
|
|
161
|
-
|
|
162
|
-
return r.ok && (a = {
|
|
163
|
-
at: Date.now(),
|
|
164
|
-
value: r.value
|
|
165
|
-
}), r;
|
|
166
|
-
} },
|
|
167
|
-
list: (e) => o(i.list, e, e.signal, r, i.onListResult),
|
|
168
|
-
describe: (e) => o(i.describe, e, e.signal, n, i.onDescribeResult),
|
|
169
|
-
query: (t, n) => o(i.query, t, n.signal, e, i.onQueryResult, n.context)
|
|
3441
|
+
})
|
|
170
3442
|
};
|
|
171
3443
|
}
|
|
172
|
-
function
|
|
173
|
-
let
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
3444
|
+
function gr(e, t) {
|
|
3445
|
+
let n = [];
|
|
3446
|
+
for (let [r, i] of e.regions.entries()) {
|
|
3447
|
+
if (r !== t.regionIndex) {
|
|
3448
|
+
n.push(i);
|
|
3449
|
+
continue;
|
|
3450
|
+
}
|
|
3451
|
+
let e = (e) => e.filter((e, n) => n !== t.itemIndex);
|
|
3452
|
+
if (i.kind === "band") {
|
|
3453
|
+
let t = e(i.items);
|
|
3454
|
+
t.length > 0 && n.push({
|
|
3455
|
+
...i,
|
|
3456
|
+
items: t
|
|
3457
|
+
});
|
|
3458
|
+
} else if (i.kind === "grid") {
|
|
3459
|
+
let t = e(i.blocks);
|
|
3460
|
+
t.length > 0 && n.push({
|
|
3461
|
+
...i,
|
|
3462
|
+
blocks: t
|
|
3463
|
+
});
|
|
3464
|
+
} else {
|
|
3465
|
+
let r = t.part === "main" ? e(i.main) : i.main, a = t.part === "rail" ? e(i.rail) : i.rail;
|
|
3466
|
+
if (r.length > 0 && a.length > 0) n.push({
|
|
3467
|
+
...i,
|
|
3468
|
+
main: r,
|
|
3469
|
+
rail: a
|
|
3470
|
+
});
|
|
3471
|
+
else {
|
|
3472
|
+
let e = [...r, ...a];
|
|
3473
|
+
e.length > 0 && n.push({
|
|
3474
|
+
kind: "grid",
|
|
3475
|
+
origin: i.origin,
|
|
3476
|
+
blocks: e.map((e) => ({
|
|
3477
|
+
...e,
|
|
3478
|
+
span: 4
|
|
3479
|
+
}))
|
|
3480
|
+
});
|
|
3481
|
+
}
|
|
3482
|
+
}
|
|
3483
|
+
}
|
|
3484
|
+
return {
|
|
3485
|
+
...e,
|
|
3486
|
+
regions: n
|
|
3487
|
+
};
|
|
3488
|
+
}
|
|
3489
|
+
function _r(e) {
|
|
3490
|
+
return e.kind === "grid" ? e.blocks.length > 0 : e.kind === "split" ? e.main.length > 0 || e.rail.length > 0 : !1;
|
|
3491
|
+
}
|
|
3492
|
+
function vr(e) {
|
|
3493
|
+
let t = -1;
|
|
3494
|
+
for (let n of e) {
|
|
3495
|
+
let e = /\[(\d+)\]$/.exec(n);
|
|
3496
|
+
e !== null && (t = Math.max(t, Number(e[1])));
|
|
3497
|
+
}
|
|
3498
|
+
return t + 1;
|
|
3499
|
+
}
|
|
3500
|
+
function yr(e) {
|
|
3501
|
+
return {
|
|
3502
|
+
...e,
|
|
3503
|
+
regions: e.regions.map((e) => {
|
|
3504
|
+
let t = (e) => ({
|
|
3505
|
+
...e,
|
|
3506
|
+
ident: e.ident ?? e.origin
|
|
3507
|
+
});
|
|
3508
|
+
return e.kind === "band" ? {
|
|
3509
|
+
...e,
|
|
3510
|
+
items: e.items.map(t)
|
|
3511
|
+
} : e.kind === "grid" ? {
|
|
3512
|
+
...e,
|
|
3513
|
+
blocks: e.blocks.map(t)
|
|
3514
|
+
} : {
|
|
3515
|
+
...e,
|
|
3516
|
+
main: e.main.map(t),
|
|
3517
|
+
rail: e.rail.map(t)
|
|
187
3518
|
};
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
query: p(t, e.mapping?.query, (e) => ({ path: `/datasets/${encodeURIComponent(e.datasetId)}/query${l(_(e.params))}` }))
|
|
191
|
-
});
|
|
3519
|
+
})
|
|
3520
|
+
};
|
|
192
3521
|
}
|
|
193
|
-
function
|
|
194
|
-
let t =
|
|
195
|
-
|
|
196
|
-
return t;
|
|
3522
|
+
function br(e) {
|
|
3523
|
+
let { fields: t, ...n } = e;
|
|
3524
|
+
return n;
|
|
197
3525
|
}
|
|
198
|
-
function
|
|
199
|
-
|
|
3526
|
+
function xr(e) {
|
|
3527
|
+
let t = {
|
|
3528
|
+
...e.key === void 0 ? {} : { key: e.key },
|
|
3529
|
+
...e.states === void 0 ? {} : { states: e.states }
|
|
3530
|
+
};
|
|
3531
|
+
return e.bind === void 0 ? {
|
|
3532
|
+
label: e.label,
|
|
3533
|
+
value: e.value,
|
|
3534
|
+
...e.unit === void 0 ? {} : { unit: e.unit },
|
|
3535
|
+
...e.precision === void 0 ? {} : { precision: e.precision },
|
|
3536
|
+
...e.delta === void 0 ? {} : { delta: e.delta },
|
|
3537
|
+
...t
|
|
3538
|
+
} : {
|
|
3539
|
+
label: e.label,
|
|
3540
|
+
...e.unit === void 0 ? {} : { unit: e.unit },
|
|
3541
|
+
bind: e.bind,
|
|
3542
|
+
...t
|
|
3543
|
+
};
|
|
3544
|
+
}
|
|
3545
|
+
function Sr(e) {
|
|
3546
|
+
return {
|
|
3547
|
+
type: e.type,
|
|
3548
|
+
title: e.title,
|
|
3549
|
+
span: e.span,
|
|
3550
|
+
...e.note === void 0 ? {} : { note: e.note },
|
|
3551
|
+
...e.props === void 0 ? {} : { props: e.props },
|
|
3552
|
+
...e.substituteFor === void 0 ? {} : { substituteFor: e.substituteFor },
|
|
3553
|
+
...e.key === void 0 ? {} : { key: e.key },
|
|
3554
|
+
...e.bind.kind === "table" ? { table: e.bind.table } : {},
|
|
3555
|
+
...e.bind.kind === "dataset" ? {
|
|
3556
|
+
datasetId: e.bind.datasetId,
|
|
3557
|
+
...e.bind.fields === void 0 ? {} : { fields: e.bind.fields },
|
|
3558
|
+
...e.bind.params === void 0 ? {} : { params: e.bind.params }
|
|
3559
|
+
} : {},
|
|
3560
|
+
...e.bind.kind === "text" ? { text: e.bind.text } : {},
|
|
3561
|
+
...e.bind.kind === "asset" ? { assetId: e.bind.assetId } : {}
|
|
3562
|
+
};
|
|
3563
|
+
}
|
|
3564
|
+
function Cr(e) {
|
|
3565
|
+
if (typeof e != "object" || !e || Array.isArray(e)) return;
|
|
3566
|
+
let t = e, n = typeof t.target == "string" ? t.target : void 0;
|
|
3567
|
+
switch (t.op) {
|
|
3568
|
+
case "change": return n !== void 0 && K(t.set) ? {
|
|
3569
|
+
op: "change",
|
|
3570
|
+
target: n,
|
|
3571
|
+
set: t.set
|
|
3572
|
+
} : void 0;
|
|
3573
|
+
case "swap": return n !== void 0 && typeof t.type == "string" ? {
|
|
3574
|
+
op: "swap",
|
|
3575
|
+
target: n,
|
|
3576
|
+
type: t.type,
|
|
3577
|
+
...K(t.props) ? { props: t.props } : {}
|
|
3578
|
+
} : void 0;
|
|
3579
|
+
case "delete": return n === void 0 ? void 0 : {
|
|
3580
|
+
op: "delete",
|
|
3581
|
+
target: n
|
|
3582
|
+
};
|
|
3583
|
+
case "add": return typeof t.region == "string" && t.block !== void 0 ? {
|
|
3584
|
+
op: "add",
|
|
3585
|
+
region: t.region,
|
|
3586
|
+
...t.part === "main" || t.part === "rail" ? { part: t.part } : {},
|
|
3587
|
+
block: t.block
|
|
3588
|
+
} : void 0;
|
|
3589
|
+
case "rebind": return n !== void 0 && K(t.bind) ? {
|
|
3590
|
+
op: "rebind",
|
|
3591
|
+
target: n,
|
|
3592
|
+
bind: t.bind
|
|
3593
|
+
} : void 0;
|
|
3594
|
+
case "link": return K(t.interaction) ? {
|
|
3595
|
+
op: "link",
|
|
3596
|
+
interaction: t.interaction
|
|
3597
|
+
} : void 0;
|
|
3598
|
+
case "unlink": return n === void 0 ? void 0 : {
|
|
3599
|
+
op: "unlink",
|
|
3600
|
+
target: n
|
|
3601
|
+
};
|
|
3602
|
+
default: return;
|
|
3603
|
+
}
|
|
200
3604
|
}
|
|
201
|
-
function
|
|
3605
|
+
function K(e) {
|
|
3606
|
+
return typeof e == "object" && !!e && !Array.isArray(e);
|
|
3607
|
+
}
|
|
3608
|
+
function q(e, t, n) {
|
|
202
3609
|
return {
|
|
203
3610
|
ok: !1,
|
|
204
3611
|
diagnostics: [{
|
|
205
3612
|
severity: "error",
|
|
206
|
-
code:
|
|
207
|
-
path:
|
|
208
|
-
message:
|
|
3613
|
+
code: t,
|
|
3614
|
+
path: e,
|
|
3615
|
+
message: n
|
|
209
3616
|
}]
|
|
210
3617
|
};
|
|
211
3618
|
}
|
|
212
|
-
function
|
|
3619
|
+
function wr(e, t, n) {
|
|
3620
|
+
let r = e.interactions ?? [], i = qn([t.interaction], r.length)[0];
|
|
3621
|
+
return i === void 0 ? q(n, "INTENT_OP_INVALID", "The interaction is not usable.") : {
|
|
3622
|
+
ok: !0,
|
|
3623
|
+
intent: {
|
|
3624
|
+
...e,
|
|
3625
|
+
interactions: [...r, i]
|
|
3626
|
+
}
|
|
3627
|
+
};
|
|
3628
|
+
}
|
|
3629
|
+
function Tr(e, t, n) {
|
|
3630
|
+
let r = e.interactions ?? [], i = r.filter((e) => e.origin !== t.target);
|
|
3631
|
+
return i.length === r.length ? q(n, "INTENT_OP_TARGET_UNKNOWN", `No interaction is addressed by "${t.target}".`) : {
|
|
3632
|
+
ok: !0,
|
|
3633
|
+
intent: Dr(e, i)
|
|
3634
|
+
};
|
|
3635
|
+
}
|
|
3636
|
+
function Er(e, t) {
|
|
3637
|
+
let n = t.kpi ?? t.block;
|
|
3638
|
+
if (e.interactions === void 0 || n === void 0) return e;
|
|
3639
|
+
let r = t.kpi === void 0 ? t.block?.title ?? "" : t.kpi.label, i = (e) => e === n.key || r !== "" && e === r, a = [];
|
|
3640
|
+
for (let t of e.interactions) {
|
|
3641
|
+
if (i(t.from)) continue;
|
|
3642
|
+
let e = t.to.filter((e) => !i(e));
|
|
3643
|
+
e.length !== 0 && a.push({
|
|
3644
|
+
...t,
|
|
3645
|
+
to: e
|
|
3646
|
+
});
|
|
3647
|
+
}
|
|
3648
|
+
return Dr(e, a);
|
|
3649
|
+
}
|
|
3650
|
+
function Dr(e, t) {
|
|
3651
|
+
let { interactions: n, ...r } = e;
|
|
3652
|
+
return t.length === 0 ? r : {
|
|
3653
|
+
...r,
|
|
3654
|
+
interactions: t
|
|
3655
|
+
};
|
|
3656
|
+
}
|
|
3657
|
+
var Or = (e) => typeof e == "string" && e.startsWith("agent:"), kr = (e) => typeof e == "string" && e.startsWith("agent-edge-"), Ar = (e) => typeof e == "string" && e.startsWith("agent-var-"), J = (e) => K(e) && e.kind === "variable" && typeof e.variableId == "string";
|
|
3658
|
+
function jr(e, t, n, r) {
|
|
3659
|
+
let i = K(n.blueprint) ? n.blueprint : {}, a = (Array.isArray(i.nodes) ? i.nodes : []).filter(K), o = (Array.isArray(i.edges) ? i.edges : []).filter(K), s = (n.variables ?? []).filter(K).filter((e) => Ar(e.id)), c = (e, t) => e.some((e) => e.id === t.id && Y(e) === Y(t)), l = a.filter((e) => Or(e.id)), u = o.filter((e) => kr(e.id)), d = t.blueprint.nodes.filter(K), f = t.blueprint.edges.filter(K), p = l.filter((e) => !c(d, e)).map((e) => String(e.id)), m = new Set(p), h = u.filter((e) => !c(f, e) && !m.has(String(e.from?.node)) && !m.has(String(e.to?.node))).map((e) => String(e.id)), g = u.filter((e) => c(f, e) && !m.has(String(e.from?.node)) && !m.has(String(e.to?.node))), _ = l.filter((e) => !m.has(String(e.id))), v = d.filter((e) => !c(_, e)), y = f.filter((e) => !c(g, e)), b = s.filter((e) => !c(t.variables, e)), x = new Set(b.map((e) => String(e.id))), S = s.filter((e) => !x.has(String(e.id))), C = t.variables.filter((e) => !c(S, e)), w = /* @__PURE__ */ new Map(), T = new Map((t.dataSources ?? []).map((e) => [String(e.id), e]));
|
|
3660
|
+
for (let e of t.components) {
|
|
3661
|
+
let t = e.dataValue?.dataSourceId, n = r.get(e.id)?.dataValue?.dataSourceId, i = typeof t == "string" ? T.get(t) : void 0;
|
|
3662
|
+
if (i === void 0 || typeof n != "string") continue;
|
|
3663
|
+
let a = K(i.params) ? i.params : {};
|
|
3664
|
+
w.set(n, {
|
|
3665
|
+
...w.get(n) ?? {},
|
|
3666
|
+
...a
|
|
3667
|
+
});
|
|
3668
|
+
}
|
|
3669
|
+
let E = [], D = [];
|
|
3670
|
+
for (let e of n.dataSources ?? []) {
|
|
3671
|
+
let t = String(e.id), n = K(e.params) ? e.params : {}, r = w.get(t) ?? {}, i = {}, a = {};
|
|
3672
|
+
for (let [e, t] of Object.entries(n)) {
|
|
3673
|
+
if (!J(t) || !Ar(t.variableId)) continue;
|
|
3674
|
+
let n = r[e];
|
|
3675
|
+
J(n) && n.variableId === t.variableId && !x.has(t.variableId) || (i[e] = {
|
|
3676
|
+
kind: "inline",
|
|
3677
|
+
value: s.find((e) => e.id === t.variableId)?.initialValue ?? null
|
|
3678
|
+
}, (J(n) || n !== void 0 && Y(n) !== Y(i[e])) && (a[e] = n));
|
|
3679
|
+
}
|
|
3680
|
+
for (let [e, t] of Object.entries(r)) !J(t) || !Ar(t.variableId) || a[e] === void 0 && i[e] === void 0 && Y(n[e]) !== Y(t) && (a[e] = t);
|
|
3681
|
+
Object.keys(i).length > 0 && E.push({
|
|
3682
|
+
type: "update-data-source-params",
|
|
3683
|
+
dataSourceId: t,
|
|
3684
|
+
params: i
|
|
3685
|
+
}), Object.keys(a).length > 0 && D.push({
|
|
3686
|
+
type: "update-data-source-params",
|
|
3687
|
+
dataSourceId: t,
|
|
3688
|
+
params: a
|
|
3689
|
+
});
|
|
3690
|
+
}
|
|
3691
|
+
let O = [];
|
|
3692
|
+
return p.length + h.length > 0 && O.push({
|
|
3693
|
+
type: "remove-blueprint-elements",
|
|
3694
|
+
nodeIds: p,
|
|
3695
|
+
edgeIds: h
|
|
3696
|
+
}), O.push(...E), b.length > 0 && O.push({
|
|
3697
|
+
type: "remove-variables",
|
|
3698
|
+
variableIds: b.map((e) => String(e.id))
|
|
3699
|
+
}), C.length > 0 && O.push({
|
|
3700
|
+
type: "add-variables",
|
|
3701
|
+
variables: C
|
|
3702
|
+
}), {
|
|
3703
|
+
detach: O,
|
|
3704
|
+
attach: D,
|
|
3705
|
+
wire: v.length + y.length > 0 ? [{
|
|
3706
|
+
type: "add-blueprint-elements",
|
|
3707
|
+
nodes: v,
|
|
3708
|
+
edges: y
|
|
3709
|
+
}] : []
|
|
3710
|
+
};
|
|
3711
|
+
}
|
|
3712
|
+
var Mr = [
|
|
3713
|
+
"type",
|
|
3714
|
+
"name",
|
|
3715
|
+
"parentId",
|
|
3716
|
+
"position",
|
|
3717
|
+
"size",
|
|
3718
|
+
"rotation",
|
|
3719
|
+
"props",
|
|
3720
|
+
"style",
|
|
3721
|
+
"dataValue",
|
|
3722
|
+
"dataBinding",
|
|
3723
|
+
"states",
|
|
3724
|
+
"status"
|
|
3725
|
+
];
|
|
3726
|
+
function Nr(e, t) {
|
|
3727
|
+
let n = e, r = t;
|
|
3728
|
+
return Mr.every((e) => Y(n[e]) === Y(r[e]));
|
|
3729
|
+
}
|
|
3730
|
+
function Y(e) {
|
|
3731
|
+
return JSON.stringify(Pr(e ?? null));
|
|
3732
|
+
}
|
|
3733
|
+
function Pr(e) {
|
|
3734
|
+
return Array.isArray(e) ? e.map(Pr) : typeof e != "object" || !e ? e : Object.fromEntries(Object.entries(e).filter(([, e]) => e !== void 0).sort(([e], [t]) => e < t ? -1 : +(e > t)).map(([e, t]) => [e, Pr(t)]));
|
|
3735
|
+
}
|
|
3736
|
+
function Fr(e, t) {
|
|
3737
|
+
let n = e, r = t, i = {};
|
|
3738
|
+
for (let e of Mr) e !== "type" && Y(n[e]) !== Y(r[e]) && (i[e] = r[e]);
|
|
3739
|
+
return i;
|
|
3740
|
+
}
|
|
3741
|
+
function Ir(e, t, n, r = /* @__PURE__ */ new Map()) {
|
|
3742
|
+
let i = /* @__PURE__ */ new Set();
|
|
3743
|
+
for (let e of t) {
|
|
3744
|
+
let t = e.dataValue;
|
|
3745
|
+
typeof t?.dataSourceId == "string" && i.add(t.dataSourceId);
|
|
3746
|
+
}
|
|
3747
|
+
let a = (e) => (t) => {
|
|
3748
|
+
let n = t.dataValue, r = typeof n?.dataSourceId == "string" ? e.get(n.dataSourceId) : void 0;
|
|
3749
|
+
return r === void 0 || n === null ? t : {
|
|
3750
|
+
...t,
|
|
3751
|
+
dataValue: {
|
|
3752
|
+
...n,
|
|
3753
|
+
dataSourceId: r
|
|
3754
|
+
}
|
|
3755
|
+
};
|
|
3756
|
+
}, o = /* @__PURE__ */ new Map(), s = (t) => {
|
|
3757
|
+
let n = X(t.dataValue), i = X(e.components.find((e) => e.id === t.id)?.dataValue), s = i === void 0 ? void 0 : r.get(i);
|
|
3758
|
+
return n === void 0 || s === void 0 ? t : (o.set(n, s), a(o)(t));
|
|
3759
|
+
};
|
|
3760
|
+
if (i.size === 0) return {
|
|
3761
|
+
fresh: [],
|
|
3762
|
+
apply: a(r),
|
|
3763
|
+
applyPrevious: s
|
|
3764
|
+
};
|
|
3765
|
+
let c = new Set(n.map((e) => String(e.id))), l = new Map(r), u = [];
|
|
3766
|
+
for (let t of e.dataSources ?? []) {
|
|
3767
|
+
let e = String(t.id);
|
|
3768
|
+
if (!i.has(e) || l.has(e)) continue;
|
|
3769
|
+
let r = n.find((e) => JSON.stringify({
|
|
3770
|
+
...e,
|
|
3771
|
+
id: ""
|
|
3772
|
+
}) === JSON.stringify({
|
|
3773
|
+
...t,
|
|
3774
|
+
id: ""
|
|
3775
|
+
}));
|
|
3776
|
+
if (r !== void 0) {
|
|
3777
|
+
l.set(e, String(r.id));
|
|
3778
|
+
continue;
|
|
3779
|
+
}
|
|
3780
|
+
let a = e;
|
|
3781
|
+
for (let t = 2; c.has(a); t += 1) a = `${e}-e${t}`;
|
|
3782
|
+
c.add(a), l.set(e, a), u.push({
|
|
3783
|
+
...t,
|
|
3784
|
+
id: a
|
|
3785
|
+
});
|
|
3786
|
+
}
|
|
3787
|
+
return {
|
|
3788
|
+
fresh: u,
|
|
3789
|
+
apply: a(l),
|
|
3790
|
+
applyPrevious: s
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3793
|
+
function X(e) {
|
|
3794
|
+
return K(e) && e.kind === "data-source-field" && typeof e.dataSourceId == "string" ? e.dataSourceId : void 0;
|
|
3795
|
+
}
|
|
3796
|
+
function Lr(e, t) {
|
|
3797
|
+
if (e === void 0 || t === void 0) return !1;
|
|
3798
|
+
let n = K(e.params) ? e.params : {}, r = K(t.params) ? t.params : {}, i = (e) => J(e) && Ar(e.variableId), a = new Set([...Object.keys(n), ...Object.keys(r)].filter((e) => i(n[e]) || i(r[e]))), o = (e) => Object.fromEntries(Object.entries(e).filter(([e]) => !a.has(e)));
|
|
3799
|
+
return Y({
|
|
3800
|
+
source: e.source,
|
|
3801
|
+
name: e.name,
|
|
3802
|
+
params: o(n)
|
|
3803
|
+
}) === Y({
|
|
3804
|
+
source: t.source,
|
|
3805
|
+
name: t.name,
|
|
3806
|
+
params: o(r)
|
|
3807
|
+
});
|
|
3808
|
+
}
|
|
3809
|
+
function Rr(e, t) {
|
|
3810
|
+
let n = new Map(t.components.map((e) => [e.id, e])), r;
|
|
3811
|
+
for (let i of e) {
|
|
3812
|
+
if (!ar(i, t)) continue;
|
|
3813
|
+
let e = i.compiled.document.components, a = 0, o = 0;
|
|
3814
|
+
for (let t of e) {
|
|
3815
|
+
let e = n.get(t.id);
|
|
3816
|
+
e !== void 0 && (a += 1, Nr(t, e) && (o += 1));
|
|
3817
|
+
}
|
|
3818
|
+
if (a < 3 || a < e.length / 2) continue;
|
|
3819
|
+
let s = e.length - a, c = t.components.filter((t) => !e.some((e) => e.id === t.id)).length, l = o - s - c;
|
|
3820
|
+
(r === void 0 || l > r.score) && (r = {
|
|
3821
|
+
session: i,
|
|
3822
|
+
score: l
|
|
3823
|
+
});
|
|
3824
|
+
}
|
|
3825
|
+
return r?.session;
|
|
3826
|
+
}
|
|
3827
|
+
function zr(e) {
|
|
3828
|
+
let { intent: t } = e, n = I(t.title, t.subtitle), r = (e, t) => ({
|
|
3829
|
+
target: G(e),
|
|
3830
|
+
kind: "block",
|
|
3831
|
+
part: t,
|
|
3832
|
+
type: e.type,
|
|
3833
|
+
title: e.title === "" ? e.type : e.title,
|
|
3834
|
+
...e.key === void 0 ? {} : { key: e.key }
|
|
3835
|
+
}), i = (t.interactions ?? []).map((e) => ({
|
|
3836
|
+
target: e.origin,
|
|
3837
|
+
kind: e.kind,
|
|
3838
|
+
from: e.from,
|
|
3839
|
+
to: e.to,
|
|
3840
|
+
event: e.event,
|
|
3841
|
+
...e.kind === "filter" ? {
|
|
3842
|
+
param: e.param,
|
|
3843
|
+
...e.field === void 0 ? {} : { field: e.field },
|
|
3844
|
+
...e.reset === !0 ? { reset: !0 } : {}
|
|
3845
|
+
} : e.kind === "show" ? { mode: e.mode } : { state: e.state }
|
|
3846
|
+
}));
|
|
213
3847
|
return {
|
|
214
|
-
|
|
215
|
-
|
|
3848
|
+
title: t.title,
|
|
3849
|
+
subtitle: t.subtitle,
|
|
3850
|
+
...i.length === 0 ? {} : { interactions: i },
|
|
3851
|
+
regions: t.regions.map((e) => e.kind === "band" ? {
|
|
3852
|
+
path: e.origin,
|
|
3853
|
+
kind: "band",
|
|
3854
|
+
items: e.items.map((e) => ({
|
|
3855
|
+
target: G(e),
|
|
3856
|
+
kind: "kpi",
|
|
3857
|
+
part: "items",
|
|
3858
|
+
title: e.label,
|
|
3859
|
+
value: L(e, n),
|
|
3860
|
+
...e.key === void 0 ? {} : { key: e.key },
|
|
3861
|
+
...e.states === void 0 || e.states.rules.length === 0 ? {} : { states: e.states.rules.map((e) => e.label ?? `${e.tone}`) }
|
|
3862
|
+
}))
|
|
3863
|
+
} : e.kind === "grid" ? {
|
|
3864
|
+
path: e.origin,
|
|
3865
|
+
kind: "grid",
|
|
3866
|
+
items: e.blocks.map((e) => r(e, "blocks"))
|
|
3867
|
+
} : {
|
|
3868
|
+
path: e.origin,
|
|
3869
|
+
kind: "split",
|
|
3870
|
+
items: [...e.main.map((e) => r(e, "main")), ...e.rail.map((e) => r(e, "rail"))]
|
|
3871
|
+
})
|
|
3872
|
+
};
|
|
3873
|
+
}
|
|
3874
|
+
//#endregion
|
|
3875
|
+
//#region ../host-kit/dist/intent/intent-stream.js
|
|
3876
|
+
var Br = 6, Vr = 8, Hr = 5, Ur = 4, Wr = /* @__PURE__ */ new Set(["wide-narrow", "even"]), Gr = /* @__PURE__ */ new Set(["left", "right"]);
|
|
3877
|
+
function Kr(e, t) {
|
|
3878
|
+
let n = Xr(e);
|
|
3879
|
+
if (n === null) return;
|
|
3880
|
+
if (Array.isArray(n.regions)) {
|
|
3881
|
+
if (n.regions.length < 1 || n.regions.length > Br) return;
|
|
3882
|
+
let e = [];
|
|
3883
|
+
for (let r of n.regions) {
|
|
3884
|
+
let n = qr(r, t);
|
|
3885
|
+
if (n === void 0) return;
|
|
3886
|
+
e.push(n);
|
|
3887
|
+
}
|
|
3888
|
+
return { regions: e };
|
|
3889
|
+
}
|
|
3890
|
+
let r = n.kpis;
|
|
3891
|
+
if (typeof r != "number" || !Number.isInteger(r) || r < 1 || r > Hr) return;
|
|
3892
|
+
let i = Jr(n.blocks, t, Ur);
|
|
3893
|
+
return i === void 0 ? void 0 : Tt(r, i);
|
|
3894
|
+
}
|
|
3895
|
+
function qr(e, t) {
|
|
3896
|
+
let n = Xr(e);
|
|
3897
|
+
if (n !== null) {
|
|
3898
|
+
if (n.kind === "band") {
|
|
3899
|
+
let e = n.count;
|
|
3900
|
+
return typeof e != "number" || !Number.isInteger(e) || e < 1 || e > Vr ? void 0 : {
|
|
3901
|
+
kind: "band",
|
|
3902
|
+
count: e
|
|
3903
|
+
};
|
|
3904
|
+
}
|
|
3905
|
+
if (n.kind === "grid") {
|
|
3906
|
+
let e = Jr(n.blocks ?? n.slots, t, Vr);
|
|
3907
|
+
return e === void 0 ? void 0 : {
|
|
3908
|
+
kind: "grid",
|
|
3909
|
+
slots: e
|
|
3910
|
+
};
|
|
3911
|
+
}
|
|
3912
|
+
if (n.kind === "split") {
|
|
3913
|
+
let e = n.ratio === void 0 ? "wide-narrow" : n.ratio, r = n.railSide === void 0 ? "right" : n.railSide;
|
|
3914
|
+
if (typeof e != "string" || !Wr.has(e) || typeof r != "string" || !Gr.has(r)) return;
|
|
3915
|
+
let i = Jr(n.main, t, Vr), a = Jr(n.rail, t, Vr);
|
|
3916
|
+
return i === void 0 || a === void 0 ? void 0 : {
|
|
3917
|
+
kind: "split",
|
|
3918
|
+
ratio: e,
|
|
3919
|
+
railSide: r,
|
|
3920
|
+
main: i.map((e) => ({ data: e.data })),
|
|
3921
|
+
rail: a.map((e) => ({ data: e.data }))
|
|
3922
|
+
};
|
|
3923
|
+
}
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
function Jr(e, t, n) {
|
|
3927
|
+
if (!Array.isArray(e) || e.length < 1 || e.length > n) return;
|
|
3928
|
+
let r = [];
|
|
3929
|
+
for (let n of e) {
|
|
3930
|
+
let e = Xr(n), i = typeof e?.type == "string" ? e.type.trim() : "", a = t.materials.find((e) => e.type === i);
|
|
3931
|
+
if (e === null || a === void 0 || a.children === !0) return;
|
|
3932
|
+
let o = e.span === void 0 ? 1 : e.span;
|
|
3933
|
+
if (typeof o != "number" || !Number.isFinite(o)) return;
|
|
3934
|
+
r.push({
|
|
3935
|
+
span: Math.min(4, Math.max(1, Math.round(o))),
|
|
3936
|
+
data: a.data === "tabular"
|
|
3937
|
+
});
|
|
3938
|
+
}
|
|
3939
|
+
return r;
|
|
3940
|
+
}
|
|
3941
|
+
function Yr(e) {
|
|
3942
|
+
let t, n, r = {}, i = {}, a = {
|
|
3943
|
+
kpis: /* @__PURE__ */ new Set(),
|
|
3944
|
+
blocks: /* @__PURE__ */ new Set()
|
|
3945
|
+
}, o = /* @__PURE__ */ new Set(), s = (e) => {
|
|
3946
|
+
for (let [t, n] of e.regions.entries()) {
|
|
3947
|
+
let r = e.flat === !0 ? n.kind === "band" ? "kpis" : "blocks" : `regions[${t}]`, i = (t, n) => e.flat === !0 ? `${r}[${n}]` : `${r}.${t}[${n}]`;
|
|
3948
|
+
if (n.kind === "band") for (let e = 0; e < n.count; e += 1) a.kpis.add(i("items", e));
|
|
3949
|
+
else if (n.kind === "grid") for (let e = 0; e < n.slots.length; e += 1) a.blocks.add(i("blocks", e)), o.add(i("blocks", e));
|
|
3950
|
+
else {
|
|
3951
|
+
for (let e = 0; e < n.main.length; e += 1) a.blocks.add(i("main", e));
|
|
3952
|
+
for (let e = 0; e < n.rail.length; e += 1) a.blocks.add(i("rail", e));
|
|
3953
|
+
}
|
|
3954
|
+
}
|
|
3955
|
+
};
|
|
3956
|
+
return {
|
|
3957
|
+
skeleton(r) {
|
|
3958
|
+
if (t !== void 0) return !1;
|
|
3959
|
+
let i = Kr(r.layout, e);
|
|
3960
|
+
return i === void 0 || r.title.trim() === "" || r.subtitle.trim() === "" ? !1 : (t = r, n = i, s(i), !0);
|
|
3961
|
+
},
|
|
3962
|
+
item(t, s) {
|
|
3963
|
+
if (n === void 0) return !1;
|
|
3964
|
+
if (a.kpis.has(t)) {
|
|
3965
|
+
let e = V(s, t);
|
|
3966
|
+
return e.value === void 0 || t in r ? !1 : (r[t] = e.value, !0);
|
|
3967
|
+
}
|
|
3968
|
+
if (a.blocks.has(t)) {
|
|
3969
|
+
let n = H(s, e, t, { grid: o.has(t) });
|
|
3970
|
+
return n.value === void 0 || t in i ? !1 : (i[t] = n.value, !0);
|
|
3971
|
+
}
|
|
3972
|
+
return !1;
|
|
3973
|
+
},
|
|
3974
|
+
frame() {
|
|
3975
|
+
if (t !== void 0 && n !== void 0) return {
|
|
3976
|
+
intent: {
|
|
3977
|
+
title: B(t.title.trim(), 20),
|
|
3978
|
+
subtitle: B(t.subtitle.trim(), 40),
|
|
3979
|
+
...t.style === void 0 || t.style === "" ? {} : { style: t.style },
|
|
3980
|
+
regions: []
|
|
3981
|
+
},
|
|
3982
|
+
stream: {
|
|
3983
|
+
skeleton: n,
|
|
3984
|
+
kpis: { ...r },
|
|
3985
|
+
blocks: { ...i }
|
|
3986
|
+
}
|
|
3987
|
+
};
|
|
3988
|
+
}
|
|
216
3989
|
};
|
|
217
3990
|
}
|
|
3991
|
+
function Xr(e) {
|
|
3992
|
+
return typeof e == "object" && e && !Array.isArray(e) ? e : null;
|
|
3993
|
+
}
|
|
218
3994
|
//#endregion
|
|
219
3995
|
//#region ../host-kit/dist/project-adapter.js
|
|
220
|
-
function
|
|
221
|
-
let t = e.migrate ??
|
|
222
|
-
async function n(e, n, r,
|
|
223
|
-
if (n.signal.aborted) return
|
|
224
|
-
let o = await
|
|
225
|
-
if (n.signal.aborted || !o.ok && o.error.code === "ABORTED") return
|
|
3996
|
+
function Zr(e) {
|
|
3997
|
+
let t = e.migrate ?? s;
|
|
3998
|
+
async function n(e, n, r, i) {
|
|
3999
|
+
if (n.signal.aborted) return Z();
|
|
4000
|
+
let o = await v(e, n, n.signal);
|
|
4001
|
+
if (n.signal.aborted || !o.ok && o.error.code === "ABORTED") return Z();
|
|
226
4002
|
let s;
|
|
227
|
-
if (!o.ok) s =
|
|
4003
|
+
if (!o.ok) s = ei(r && (o.error.code === "REVISION_CONFLICT" || o.error.status === 409) ? "PROJECT_CONFLICT" : "PROJECT_UNAVAILABLE", r ? ["revision"] : [], o.error.message);
|
|
228
4004
|
else try {
|
|
229
|
-
let
|
|
230
|
-
if (n.signal.aborted) return
|
|
231
|
-
if (r) s = i
|
|
232
|
-
else if (typeof
|
|
4005
|
+
let i = e.response ? e.response(o.data, n) : o.data;
|
|
4006
|
+
if (n.signal.aborted) return Z();
|
|
4007
|
+
if (r) s = a(i);
|
|
4008
|
+
else if (typeof i != "object" || !i || !("document" in i)) s = ei("PROJECT_UNAVAILABLE", [], "项目信封格式无效。");
|
|
233
4009
|
else {
|
|
234
|
-
let e = t(
|
|
235
|
-
if (n.signal.aborted) return
|
|
236
|
-
s = e.ok ?
|
|
237
|
-
...
|
|
4010
|
+
let e = t(i.document);
|
|
4011
|
+
if (n.signal.aborted) return Z();
|
|
4012
|
+
s = e.ok ? a({
|
|
4013
|
+
...i,
|
|
238
4014
|
document: e.document
|
|
239
4015
|
}) : {
|
|
240
4016
|
ok: !1,
|
|
@@ -242,9 +4018,9 @@ function x(e) {
|
|
|
242
4018
|
};
|
|
243
4019
|
}
|
|
244
4020
|
} catch {
|
|
245
|
-
s =
|
|
4021
|
+
s = ei("PROJECT_UNAVAILABLE", [], "项目信封格式无效。");
|
|
246
4022
|
}
|
|
247
|
-
return n.signal.aborted ?
|
|
4023
|
+
return n.signal.aborted ? Z() : (y(i, n, s, o.ok ? void 0 : o.error), s);
|
|
248
4024
|
}
|
|
249
4025
|
return {
|
|
250
4026
|
capabilities: { publish: !1 },
|
|
@@ -252,22 +4028,22 @@ function x(e) {
|
|
|
252
4028
|
save: (t) => n(e.save, t, !0, e.onSaveResult)
|
|
253
4029
|
};
|
|
254
4030
|
}
|
|
255
|
-
function
|
|
256
|
-
let t =
|
|
257
|
-
return
|
|
4031
|
+
function Qr(e) {
|
|
4032
|
+
let t = m(e);
|
|
4033
|
+
return Zr({
|
|
258
4034
|
...e.migrate === void 0 ? {} : { migrate: e.migrate },
|
|
259
|
-
load:
|
|
260
|
-
save:
|
|
4035
|
+
load: b(t, e.mapping?.load, (e) => ({ path: `/screens/${encodeURIComponent(e.projectId)}` }), $r),
|
|
4036
|
+
save: b(t, e.mapping?.save, (e) => ({
|
|
261
4037
|
path: `/screens/${encodeURIComponent(e.projectId)}`,
|
|
262
4038
|
method: "PUT",
|
|
263
4039
|
body: {
|
|
264
4040
|
document: e.document,
|
|
265
4041
|
revision: Number(e.revision)
|
|
266
4042
|
}
|
|
267
|
-
}),
|
|
4043
|
+
}), $r)
|
|
268
4044
|
});
|
|
269
4045
|
}
|
|
270
|
-
function
|
|
4046
|
+
function $r(e) {
|
|
271
4047
|
if (typeof e != "object" || !e || !("screen" in e)) return;
|
|
272
4048
|
let t = e.screen;
|
|
273
4049
|
if (!(typeof t != "object" || !t || !("id" in t) || !("name" in t) || !("revision" in t) || !("document" in t) || typeof t.revision != "number" || !Number.isSafeInteger(t.revision) || t.revision < 0)) return {
|
|
@@ -279,13 +4055,13 @@ function C(e) {
|
|
|
279
4055
|
metadata: {}
|
|
280
4056
|
};
|
|
281
4057
|
}
|
|
282
|
-
function
|
|
4058
|
+
function Z() {
|
|
283
4059
|
return {
|
|
284
4060
|
ok: !1,
|
|
285
4061
|
diagnostics: []
|
|
286
4062
|
};
|
|
287
4063
|
}
|
|
288
|
-
function
|
|
4064
|
+
function ei(e, t, n) {
|
|
289
4065
|
return {
|
|
290
4066
|
ok: !1,
|
|
291
4067
|
diagnostics: [{
|
|
@@ -298,14 +4074,14 @@ function T(e, t, n) {
|
|
|
298
4074
|
}
|
|
299
4075
|
//#endregion
|
|
300
4076
|
//#region ../host-kit/dist/push-result.js
|
|
301
|
-
function
|
|
4077
|
+
function Q() {
|
|
302
4078
|
return {
|
|
303
4079
|
ok: !0,
|
|
304
4080
|
value: null,
|
|
305
4081
|
diagnostics: []
|
|
306
4082
|
};
|
|
307
4083
|
}
|
|
308
|
-
function
|
|
4084
|
+
function $(e, t) {
|
|
309
4085
|
return {
|
|
310
4086
|
ok: !1,
|
|
311
4087
|
diagnostics: [{
|
|
@@ -318,15 +4094,15 @@ function D(e, t) {
|
|
|
318
4094
|
}
|
|
319
4095
|
//#endregion
|
|
320
4096
|
//#region ../host-kit/dist/sse-subscribe.js
|
|
321
|
-
var
|
|
4097
|
+
var ti = /* @__PURE__ */ new Set([
|
|
322
4098
|
"snapshot",
|
|
323
4099
|
"append",
|
|
324
4100
|
"invalidate",
|
|
325
4101
|
"status",
|
|
326
4102
|
"heartbeat"
|
|
327
|
-
]),
|
|
328
|
-
function
|
|
329
|
-
let t = Math.max(0, e.suspendAfterMs ?? 3e4), n = e.cursorFromEventId ?? !0, r = e.events ??
|
|
4103
|
+
]), ni = [...ti], ri = 2, ii = 1e3, ai = /^(.+):(\d+)$/;
|
|
4104
|
+
function oi(e) {
|
|
4105
|
+
let t = Math.max(0, e.suspendAfterMs ?? 3e4), n = e.cursorFromEventId ?? !0, r = e.events ?? ni;
|
|
330
4106
|
return (i, a, o) => {
|
|
331
4107
|
let s;
|
|
332
4108
|
try {
|
|
@@ -334,10 +4110,10 @@ function N(e) {
|
|
|
334
4110
|
} catch {
|
|
335
4111
|
s = void 0;
|
|
336
4112
|
}
|
|
337
|
-
if (s === void 0) return
|
|
4113
|
+
if (s === void 0) return $("HOST_RESOURCE_ACCESS_DENIED", "Subscription is not allowed for this request.");
|
|
338
4114
|
let c = e.EventSource ?? globalThis.EventSource;
|
|
339
|
-
if (c === void 0) return
|
|
340
|
-
if (o.signal.aborted) return
|
|
4115
|
+
if (c === void 0) return $("HOST_RESOURCE_UNAVAILABLE", "EventSource is not available.");
|
|
4116
|
+
if (o.signal.aborted) return Q();
|
|
341
4117
|
let l = !1, u = !1, d = [], f, p, m, h, g = (e) => {
|
|
342
4118
|
if (!l) try {
|
|
343
4119
|
a.push(e);
|
|
@@ -377,7 +4153,7 @@ function N(e) {
|
|
|
377
4153
|
g(e);
|
|
378
4154
|
return;
|
|
379
4155
|
}
|
|
380
|
-
d.push(e), d.length >
|
|
4156
|
+
d.push(e), d.length > ii && d.shift();
|
|
381
4157
|
}, S = () => {
|
|
382
4158
|
let t = e.fetchSnapshot;
|
|
383
4159
|
if (t === void 0) return;
|
|
@@ -403,28 +4179,28 @@ function N(e) {
|
|
|
403
4179
|
if (l) return;
|
|
404
4180
|
let a = typeof r.lastEventId == "string" ? r.lastEventId : "", o = {
|
|
405
4181
|
event: t,
|
|
406
|
-
data:
|
|
4182
|
+
data: si(r.data),
|
|
407
4183
|
lastEventId: a
|
|
408
4184
|
}, s;
|
|
409
4185
|
try {
|
|
410
|
-
s = (e.mapEvent ??
|
|
4186
|
+
s = (e.mapEvent ?? ci)(o, i);
|
|
411
4187
|
} catch {
|
|
412
4188
|
s = void 0;
|
|
413
4189
|
}
|
|
414
4190
|
if (s === void 0) return;
|
|
415
4191
|
let c = Array.isArray(s) ? s : [s];
|
|
416
|
-
for (let e of c) x(n ?
|
|
4192
|
+
for (let e of c) x(n ? li(e, a) : e);
|
|
417
4193
|
};
|
|
418
4194
|
try {
|
|
419
4195
|
h = new c(s, e.withCredentials === void 0 ? void 0 : { withCredentials: e.withCredentials });
|
|
420
4196
|
} catch {
|
|
421
|
-
return
|
|
4197
|
+
return $("HOST_RESOURCE_UNAVAILABLE", "Subscription stream could not be opened.");
|
|
422
4198
|
}
|
|
423
4199
|
h.addEventListener("open", () => {
|
|
424
4200
|
l || (p !== void 0 && clearTimeout(p), p = void 0, _("open"), S());
|
|
425
4201
|
}), h.addEventListener("error", () => {
|
|
426
4202
|
if (!l) {
|
|
427
|
-
if (h.readyState ===
|
|
4203
|
+
if (h.readyState === ri) {
|
|
428
4204
|
y("Subscription stream was closed by the server.");
|
|
429
4205
|
return;
|
|
430
4206
|
}
|
|
@@ -434,10 +4210,10 @@ function N(e) {
|
|
|
434
4210
|
}
|
|
435
4211
|
});
|
|
436
4212
|
for (let e of /* @__PURE__ */ new Set(["message", ...r])) h.addEventListener(e, (t) => C(e, t));
|
|
437
|
-
return o.signal.addEventListener("abort", v, { once: !0 }),
|
|
4213
|
+
return o.signal.addEventListener("abort", v, { once: !0 }), Q();
|
|
438
4214
|
};
|
|
439
4215
|
}
|
|
440
|
-
function
|
|
4216
|
+
function si(e) {
|
|
441
4217
|
if (typeof e != "string") return e;
|
|
442
4218
|
try {
|
|
443
4219
|
return JSON.parse(e);
|
|
@@ -445,18 +4221,18 @@ function P(e) {
|
|
|
445
4221
|
return e;
|
|
446
4222
|
}
|
|
447
4223
|
}
|
|
448
|
-
function
|
|
4224
|
+
function ci(e) {
|
|
449
4225
|
let t = e.data;
|
|
450
4226
|
if (typeof t != "object" || !t || Array.isArray(t)) return e.event === "heartbeat" ? { type: "heartbeat" } : e.event === "invalidate" ? { type: "invalidate" } : void 0;
|
|
451
4227
|
let n = t, r = typeof n.type == "string" ? n.type : e.event;
|
|
452
|
-
if (
|
|
4228
|
+
if (ti.has(r)) return {
|
|
453
4229
|
...n,
|
|
454
4230
|
type: r
|
|
455
4231
|
};
|
|
456
4232
|
}
|
|
457
|
-
function
|
|
4233
|
+
function li(e, t) {
|
|
458
4234
|
if (e.type !== "snapshot" && e.type !== "append" || e.cursor !== void 0) return e;
|
|
459
|
-
let n =
|
|
4235
|
+
let n = ai.exec(t);
|
|
460
4236
|
if (n === null) return e;
|
|
461
4237
|
let r = Number(n[2]);
|
|
462
4238
|
return Number.isSafeInteger(r) ? {
|
|
@@ -469,14 +4245,14 @@ function I(e, t) {
|
|
|
469
4245
|
}
|
|
470
4246
|
//#endregion
|
|
471
4247
|
//#region ../host-kit/dist/subscription-hub.js
|
|
472
|
-
var
|
|
473
|
-
function
|
|
474
|
-
let t = Math.max(0, e.lingerMs ??
|
|
4248
|
+
var ui = 2e3, di = 1e3;
|
|
4249
|
+
function fi(e) {
|
|
4250
|
+
let t = Math.max(0, e.lingerMs ?? ui), n = Math.max(1, Math.floor(e.replayRows ?? di)), r = /* @__PURE__ */ new Map(), i = (e) => {
|
|
475
4251
|
e.closed || (e.closed = !0, e.lingerTimer !== void 0 && clearTimeout(e.lingerTimer), e.lingerTimer = void 0, e.listeners.clear(), r.get(e.key) === e && r.delete(e.key), e.controller.abort());
|
|
476
4252
|
}, a = (e, t) => {
|
|
477
4253
|
if (!(e.closed || typeof t != "object" || !t)) {
|
|
478
|
-
|
|
479
|
-
for (let n of [...e.listeners])
|
|
4254
|
+
pi(e, t, n);
|
|
4255
|
+
for (let n of [...e.listeners]) gi(n.sink, t);
|
|
480
4256
|
t.type === "status" && t.status === "failed" && i(e);
|
|
481
4257
|
}
|
|
482
4258
|
}, o = (e, n) => {
|
|
@@ -492,15 +4268,15 @@ function z(e) {
|
|
|
492
4268
|
};
|
|
493
4269
|
return {
|
|
494
4270
|
subscribe: (t, n, s) => {
|
|
495
|
-
if (s.signal.aborted) return
|
|
4271
|
+
if (s.signal.aborted) return Q();
|
|
496
4272
|
let c;
|
|
497
4273
|
try {
|
|
498
4274
|
c = e.keyOf(t);
|
|
499
4275
|
} catch {
|
|
500
|
-
return
|
|
4276
|
+
return $("HOST_RESOURCE_INVALID", "Subscription key could not be derived.");
|
|
501
4277
|
}
|
|
502
4278
|
let l = { sink: n }, u = r.get(c);
|
|
503
|
-
if (u !== void 0 && !u.closed) u.lingerTimer !== void 0 && clearTimeout(u.lingerTimer), u.lingerTimer = void 0, u.listeners.add(l),
|
|
4279
|
+
if (u !== void 0 && !u.closed) u.lingerTimer !== void 0 && clearTimeout(u.lingerTimer), u.lingerTimer = void 0, u.listeners.add(l), mi(u, n);
|
|
504
4280
|
else {
|
|
505
4281
|
let n = {
|
|
506
4282
|
key: c,
|
|
@@ -520,15 +4296,15 @@ function z(e) {
|
|
|
520
4296
|
signal: n.controller.signal
|
|
521
4297
|
});
|
|
522
4298
|
} catch {
|
|
523
|
-
o =
|
|
4299
|
+
o = $("HOST_RESOURCE_UNAVAILABLE", "Upstream subscription could not be opened.");
|
|
524
4300
|
}
|
|
525
4301
|
if (!o.ok) return i(n), o;
|
|
526
|
-
if (n.closed) return
|
|
4302
|
+
if (n.closed) return Q();
|
|
527
4303
|
}
|
|
528
4304
|
return s.signal.addEventListener("abort", () => {
|
|
529
4305
|
let e = r.get(c);
|
|
530
4306
|
e !== void 0 && e.listeners.has(l) && o(e, l);
|
|
531
|
-
}, { once: !0 }),
|
|
4307
|
+
}, { once: !0 }), Q();
|
|
532
4308
|
},
|
|
533
4309
|
channelCount: () => r.size,
|
|
534
4310
|
dispose: () => {
|
|
@@ -536,7 +4312,7 @@ function z(e) {
|
|
|
536
4312
|
}
|
|
537
4313
|
};
|
|
538
4314
|
}
|
|
539
|
-
function
|
|
4315
|
+
function pi(e, t, n) {
|
|
540
4316
|
switch (t.type) {
|
|
541
4317
|
case "snapshot":
|
|
542
4318
|
e.snapshot = {
|
|
@@ -547,7 +4323,7 @@ function B(e, t, n) {
|
|
|
547
4323
|
case "append": {
|
|
548
4324
|
let r = e.snapshot;
|
|
549
4325
|
if (r === void 0 || !Array.isArray(t.rows)) return;
|
|
550
|
-
let i =
|
|
4326
|
+
let i = hi(r.value);
|
|
551
4327
|
if (i === void 0) return;
|
|
552
4328
|
let a = [...i, ...t.rows], o = a.length > n ? a.slice(a.length - n) : a;
|
|
553
4329
|
e.snapshot = {
|
|
@@ -568,29 +4344,29 @@ function B(e, t, n) {
|
|
|
568
4344
|
default: return;
|
|
569
4345
|
}
|
|
570
4346
|
}
|
|
571
|
-
function
|
|
572
|
-
e.status !== void 0 &&
|
|
4347
|
+
function mi(e, t) {
|
|
4348
|
+
e.status !== void 0 && gi(t, {
|
|
573
4349
|
type: "status",
|
|
574
4350
|
status: e.status
|
|
575
4351
|
});
|
|
576
4352
|
let n = e.snapshot;
|
|
577
|
-
n !== void 0 && (
|
|
4353
|
+
n !== void 0 && (gi(t, {
|
|
578
4354
|
type: "snapshot",
|
|
579
4355
|
value: n.value,
|
|
580
4356
|
...n.cursor === void 0 ? {} : { cursor: n.cursor }
|
|
581
|
-
}), e.invalidated &&
|
|
4357
|
+
}), e.invalidated && gi(t, { type: "invalidate" }));
|
|
582
4358
|
}
|
|
583
|
-
function
|
|
4359
|
+
function hi(e) {
|
|
584
4360
|
if (typeof e != "object" || !e || Array.isArray(e)) return;
|
|
585
4361
|
let t = e.rows;
|
|
586
4362
|
return Array.isArray(t) ? t : void 0;
|
|
587
4363
|
}
|
|
588
|
-
function
|
|
4364
|
+
function gi(e, t) {
|
|
589
4365
|
try {
|
|
590
4366
|
e.push(t);
|
|
591
4367
|
} catch {}
|
|
592
4368
|
}
|
|
593
4369
|
//#endregion
|
|
594
|
-
export {
|
|
4370
|
+
export { O as BEHAVIOR_REPAIRABLE, ot as DEFAULT_INTENT_STYLE, Dt as INTENT_MAX_REFERENCED_DATASETS, at as INTENT_STYLE_PRESETS, it as INTENT_STYLE_PRESET_IDS, cr as applyIntentOps, te as compileIntentBehaviors, ut as compileScreenIntent, S as createHostDatasetPort, m as createHostKitHttp, Zr as createHostProjectAdapter, Qr as createHttpProjectAdapter, ir as createIntentSession, Yr as createIntentStreamAssembler, C as createRestDatasetPort, oi as createSseSubscribe, fi as createSubscriptionHub, zr as describeSession, I as detectIntentLanguage, or as editIntent, Tt as flatSkeleton, Pe as formatKpiDelta, L as formatKpiValue, Et as intentDatasetQueryKey, ar as isSessionUsable, nr as mapDocumentIssues, H as parseIntentBlock, V as parseIntentKpi, Kr as parseIntentSkeleton, gn as parseScreenIntent, qn as parseScreenIntentInteractions, Rr as pickSession, er as prepareIntent, kt as prepareIntentDataContext, tr as repairKey, st as resolveIntentStyle, ee as seedFilterTargets, qe as solveLayout, It as summarizeIntentDataContext, _ as toAbortSignal, g as toHostKitSearch, Rt as validateIntentData };
|
|
595
4371
|
|
|
596
4372
|
//# sourceMappingURL=host-kit.js.map
|