@duckcodeailabs/dql-cli 1.12.11 → 1.13.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/apps-api.d.ts +151 -3
- package/dist/apps-api.d.ts.map +1 -1
- package/dist/apps-api.js +675 -97
- package/dist/apps-api.js.map +1 -1
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-Cp0eh6zU.js +5 -0
- package/dist/assets/dql-notebook/assets/{AgentLogPage-hzHqpD3-.js → AgentLogPage-CBGEoGmU.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-BQRWoxp9.js → AiBuildDialog-CwAD3tXE.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-D9t_4sQl.js → AiBuildResult-CyqTuQe5.js} +1 -1
- package/dist/assets/dql-notebook/assets/AiSidePanel-DjB8PWHG.js +6 -0
- package/dist/assets/dql-notebook/assets/AnalyticsHome-B7BkvA-R.js +6 -0
- package/dist/assets/dql-notebook/assets/AppsView-CUrqtEGC.js +4583 -0
- package/dist/assets/dql-notebook/assets/BlockStudio-Bl0aGQJR.js +60 -0
- package/dist/assets/dql-notebook/assets/{BusinessArtifactView-CnTbFVGT.js → BusinessArtifactView-C4SZVNW-.js} +1 -1
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-B0uxitnx.js +22 -0
- package/dist/assets/dql-notebook/assets/GitPage-BfVD4tVq.js +7 -0
- package/dist/assets/dql-notebook/assets/GlobalAiRail-DUwdy3fB.js +1 -0
- package/dist/assets/dql-notebook/assets/GovernedContextPage-D9f26ZFb.js +7 -0
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-CL0vbSER.js → HelpDocsPage-BDPNVot1.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-DzAucwBW.js → HomePage-DiOnRhEG.js} +1 -1
- package/dist/assets/dql-notebook/assets/LineageDAG-BiUFX2KL.js +1 -0
- package/dist/assets/dql-notebook/assets/{LineageDetailView-DdVH-nz6.js → LineageDetailView-CfbSvlPJ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineageDrawer-BvrVZNKY.js → LineageDrawer-CgTScaGB.js} +1 -1
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-CSut-zvm.js → LineagePathBreadcrumb-D7ZA7k68.js} +3 -3
- package/dist/assets/dql-notebook/assets/{MiniLineageGraph-zg_1wW3M.js → MiniLineageGraph-GkD4y17x.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewBlockModal-9cDletl-.js → NewBlockModal-B9TfRjt7.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-V6de8L4d.js → NewNotebookModal-BbO9NKUl.js} +2 -2
- package/dist/assets/dql-notebook/assets/NotebookEditor-CuMpvXR9.js +200 -0
- package/dist/assets/dql-notebook/assets/ReadinessPage-BROJ9YBM.js +1 -0
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-Bg-MjbC9.js → SetupOnboarding-BCcZlpuQ.js} +2 -2
- package/dist/assets/dql-notebook/assets/{TrustBadge-DGuHB8kP.js → TrustBadge-vQQh8d0D.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-Dj4AXAhT.js +83 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-BDzY4MuQ.js → answer-to-notebook-DuqCcDDl.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left-IjlnAihE.js → arrow-left-CMe1kkOL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-BI4cXgOY.js → arrow-right-DvB_DONr.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-i6xhxu_I.js → book-open-text-CJ3NAvrs.js} +1 -1
- package/dist/assets/dql-notebook/assets/{bot-C6DE7Q6m.js → bot-CV8DYRrt.js} +1 -1
- package/dist/assets/dql-notebook/assets/{chevron-up-DSEILnDs.js → chevron-up-HxU1l85K.js} +1 -1
- package/dist/assets/dql-notebook/assets/{circle-x-BoAorVSm.js → circle-x-BCgtha1W.js} +1 -1
- package/dist/assets/dql-notebook/assets/{dagre.esm-CycymVj6.js → dagre.esm-GKp7qoUL.js} +1 -1
- package/dist/assets/dql-notebook/assets/{external-link-ZwE5iHsX.js → external-link-C-PXokWV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-Dnp2st8l.js → grip-vertical-B4EHbGXW.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-1mIC_XX4.js +634 -0
- package/dist/assets/dql-notebook/assets/{link-2-CTKe6Snr.js → link-2-BLx-goet.js} +1 -1
- package/dist/assets/dql-notebook/assets/{list-tree-Ced8e_S1.js → list-tree-BRFpEmvV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{maximize-2-Cojc6867.js → maximize-2-CCd5uRIZ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-CBIAE0XH.js → minimize-2-CDwSCGlO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-po3bWSeL.js → panel-right-open-CunA1xO7.js} +1 -1
- package/dist/assets/dql-notebook/assets/{pencil-Cb45c6WU.js → pencil-D_I14Wyk.js} +1 -1
- package/dist/assets/dql-notebook/assets/{rotate-ccw-B9v1LTJ0.js → rotate-ccw-DOrfTZk8.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-B6ii0an0.js → semantic-fields-AfQvjt5R.js} +1 -1
- package/dist/assets/dql-notebook/assets/{star-CO4tfaDq.js → star-DDhv4e8M.js} +1 -1
- package/dist/assets/dql-notebook/assets/{triangle-alert-BSdIu2El.js → triangle-alert-2ZXx8wAu.js} +1 -1
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-3rzkZrqc.js +18 -0
- package/dist/assets/dql-notebook/assets/{user-round-BfrV8U-W.js → user-round-BA074kiQ.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-BgTxZNBc.js → wand-sparkles-CEYHLt9b.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow--2ycp0yy.js → workflow-CZtyrcR-.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-LMCrpa9_.js → wrench-Ong23-wu.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-CeNgQwGm.js → x-CSo1M3tu.js} +1 -1
- package/dist/assets/dql-notebook/index.html +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts +4 -3
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +13 -10
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/local-operation-coordinator.d.ts +59 -0
- package/dist/local-operation-coordinator.d.ts.map +1 -0
- package/dist/local-operation-coordinator.js +256 -0
- package/dist/local-operation-coordinator.js.map +1 -0
- package/dist/local-runtime.d.ts +49 -1
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +1590 -323
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +12 -11
- package/dist/project-refresh-coordinator.d.ts +19 -0
- package/dist/project-refresh-coordinator.d.ts.map +1 -0
- package/dist/project-refresh-coordinator.js +134 -0
- package/dist/project-refresh-coordinator.js.map +1 -0
- package/dist/project-refresh-worker.d.ts +13 -0
- package/dist/project-refresh-worker.d.ts.map +1 -0
- package/dist/project-refresh-worker.js +58 -0
- package/dist/project-refresh-worker.js.map +1 -0
- package/package.json +13 -11
- package/dist/assets/dql-notebook/assets/AgentAnswerCard-CpL2kDCV.js +0 -5
- package/dist/assets/dql-notebook/assets/AiSidePanel-BCQB9rVF.js +0 -6
- package/dist/assets/dql-notebook/assets/AnalyticsHome-Ba4Ve_Gd.js +0 -6
- package/dist/assets/dql-notebook/assets/AppsView-CdAT9BOq.js +0 -4466
- package/dist/assets/dql-notebook/assets/BlockStudio-Brg4fwn5.js +0 -60
- package/dist/assets/dql-notebook/assets/DbtFirstModelingPage-CQe2FUZq.js +0 -22
- package/dist/assets/dql-notebook/assets/GitPage-DHyDBChc.js +0 -7
- package/dist/assets/dql-notebook/assets/GlobalAiRail-Cys4n_rq.js +0 -1
- package/dist/assets/dql-notebook/assets/GovernedContextPage-DyKoDSZ2.js +0 -7
- package/dist/assets/dql-notebook/assets/LineageDAG-QHqd_AM5.js +0 -1
- package/dist/assets/dql-notebook/assets/NotebookEditor-EZ0pfWVs.js +0 -200
- package/dist/assets/dql-notebook/assets/ReadinessPage-BaGvjyfd.js +0 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BlWAVEwO.js +0 -83
- package/dist/assets/dql-notebook/assets/index-BTuliKhK.js +0 -634
- package/dist/assets/dql-notebook/assets/usePersistedAgentThreadId-CkVFrrjk.js +0 -18
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckcodeailabs/dql-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Public CLI for parsing, formatting, testing, and certifying DQL blocks",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dql": "./index.js"
|
|
9
9
|
},
|
|
10
10
|
"scripts": {
|
|
11
|
-
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -b && node ./scripts/copy-runtime-assets.mjs",
|
|
11
|
+
"build": "pnpm --filter @duckcodeailabs/dql-notebook-app build && rm -rf dist tsconfig.tsbuildinfo && tsc -b && node ./scripts/copy-runtime-assets.mjs",
|
|
12
12
|
"dev": "tsx src/index.ts",
|
|
13
13
|
"test": "vitest run --passWithNoTests",
|
|
14
14
|
"bench:manifest": "tsx bench/manifest-bench.ts",
|
|
@@ -25,15 +25,16 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@anthropic-ai/sdk": "^0.104.2",
|
|
28
|
-
"@duckcodeailabs/dql-agent": "^1.
|
|
29
|
-
"@duckcodeailabs/dql-compiler": "^1.
|
|
30
|
-
"@duckcodeailabs/dql-connectors": "^1.
|
|
31
|
-
"@duckcodeailabs/dql-core": "^1.
|
|
32
|
-
"@duckcodeailabs/dql-governance": "^1.
|
|
33
|
-
"@duckcodeailabs/dql-mcp": "^1.
|
|
34
|
-
"@duckcodeailabs/dql-notebook": "^1.
|
|
35
|
-
"@duckcodeailabs/dql-project": "^1.
|
|
36
|
-
"@duckcodeailabs/dql-slack": "^1.
|
|
28
|
+
"@duckcodeailabs/dql-agent": "^1.13.0",
|
|
29
|
+
"@duckcodeailabs/dql-compiler": "^1.13.0",
|
|
30
|
+
"@duckcodeailabs/dql-connectors": "^1.13.0",
|
|
31
|
+
"@duckcodeailabs/dql-core": "^1.13.0",
|
|
32
|
+
"@duckcodeailabs/dql-governance": "^1.13.0",
|
|
33
|
+
"@duckcodeailabs/dql-mcp": "^1.13.0",
|
|
34
|
+
"@duckcodeailabs/dql-notebook": "^1.13.0",
|
|
35
|
+
"@duckcodeailabs/dql-project": "^1.13.0",
|
|
36
|
+
"@duckcodeailabs/dql-slack": "^1.13.0",
|
|
37
|
+
"better-sqlite3": "^12.11.1",
|
|
37
38
|
"isomorphic-git": "^1.27.0",
|
|
38
39
|
"js-yaml": "^4.1.0",
|
|
39
40
|
"node-cron": "^3.0.3",
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { LocalOperationCoordinator, type LocalOperation } from './local-operation-coordinator.js';
|
|
2
|
+
import type { ProjectRefreshWorkerInput, ProjectRefreshWorkerResult } from './project-refresh-worker.js';
|
|
3
|
+
/** Coalesces project mutations into a single worker-thread rebuild lane. */
|
|
4
|
+
export declare class ProjectRefreshCoordinator {
|
|
5
|
+
private readonly operations;
|
|
6
|
+
private readonly onActivated;
|
|
7
|
+
private readonly debounceMs;
|
|
8
|
+
private activeOperationId;
|
|
9
|
+
private pending;
|
|
10
|
+
private timer;
|
|
11
|
+
private readonly unsubscribe;
|
|
12
|
+
constructor(operations: LocalOperationCoordinator, onActivated: (result: ProjectRefreshWorkerResult) => void, debounceMs?: number);
|
|
13
|
+
schedule(input: ProjectRefreshWorkerInput & {
|
|
14
|
+
reason: string;
|
|
15
|
+
}): LocalOperation;
|
|
16
|
+
close(): void;
|
|
17
|
+
private startPending;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=project-refresh-coordinator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-refresh-coordinator.d.ts","sourceRoot":"","sources":["../src/project-refresh-coordinator.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EACzB,KAAK,cAAc,EAEpB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EACV,yBAAyB,EACzB,0BAA0B,EAC3B,MAAM,6BAA6B,CAAC;AAUrC,4EAA4E;AAC5E,qBAAa,yBAAyB;IAOlC,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,WAAW;IAC5B,OAAO,CAAC,QAAQ,CAAC,UAAU;IAR7B,OAAO,CAAC,iBAAiB,CAAuB;IAChD,OAAO,CAAC,OAAO,CAA+B;IAC9C,OAAO,CAAC,KAAK,CAA8C;IAC3D,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAa;gBAGtB,UAAU,EAAE,yBAAyB,EACrC,WAAW,EAAE,CAAC,MAAM,EAAE,0BAA0B,KAAK,IAAI,EACzD,UAAU,SAAM;IAenC,QAAQ,CAAC,KAAK,EAAE,yBAAyB,GAAG;QAAE,MAAM,EAAE,MAAM,CAAA;KAAE,GAAG,cAAc;IAoC/E,KAAK,IAAI,IAAI;IAMb,OAAO,CAAC,YAAY;CAmBrB"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Worker } from 'node:worker_threads';
|
|
2
|
+
const TERMINAL = new Set(['succeeded', 'failed', 'cancelled', 'interrupted']);
|
|
3
|
+
/** Coalesces project mutations into a single worker-thread rebuild lane. */
|
|
4
|
+
export class ProjectRefreshCoordinator {
|
|
5
|
+
operations;
|
|
6
|
+
onActivated;
|
|
7
|
+
debounceMs;
|
|
8
|
+
activeOperationId = null;
|
|
9
|
+
pending = null;
|
|
10
|
+
timer = null;
|
|
11
|
+
unsubscribe;
|
|
12
|
+
constructor(operations, onActivated, debounceMs = 250) {
|
|
13
|
+
this.operations = operations;
|
|
14
|
+
this.onActivated = onActivated;
|
|
15
|
+
this.debounceMs = debounceMs;
|
|
16
|
+
this.unsubscribe = operations.subscribe((operation) => {
|
|
17
|
+
if (operation.id === this.activeOperationId && TERMINAL.has(operation.status)) {
|
|
18
|
+
this.activeOperationId = null;
|
|
19
|
+
this.startPending();
|
|
20
|
+
}
|
|
21
|
+
if (operation.id === this.pending?.operationId && TERMINAL.has(operation.status)) {
|
|
22
|
+
this.pending = null;
|
|
23
|
+
if (this.timer)
|
|
24
|
+
clearTimeout(this.timer);
|
|
25
|
+
this.timer = null;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
schedule(input) {
|
|
30
|
+
if (this.pending) {
|
|
31
|
+
this.pending.input = {
|
|
32
|
+
projectRoot: input.projectRoot,
|
|
33
|
+
dbtManifestPath: input.dbtManifestPath,
|
|
34
|
+
writeManifest: this.pending.input.writeManifest || input.writeManifest,
|
|
35
|
+
};
|
|
36
|
+
this.pending.reasons.add(input.reason);
|
|
37
|
+
return this.operations.get(this.pending.operationId);
|
|
38
|
+
}
|
|
39
|
+
const operation = this.operations.create({
|
|
40
|
+
type: 'project_refresh',
|
|
41
|
+
scope: 'project',
|
|
42
|
+
phase: 'queued',
|
|
43
|
+
message: 'Project search and lineage refresh queued.',
|
|
44
|
+
cancellable: true,
|
|
45
|
+
});
|
|
46
|
+
this.pending = {
|
|
47
|
+
operationId: operation.id,
|
|
48
|
+
input: {
|
|
49
|
+
projectRoot: input.projectRoot,
|
|
50
|
+
dbtManifestPath: input.dbtManifestPath,
|
|
51
|
+
writeManifest: input.writeManifest,
|
|
52
|
+
},
|
|
53
|
+
reasons: new Set([input.reason]),
|
|
54
|
+
};
|
|
55
|
+
if (!this.activeOperationId) {
|
|
56
|
+
this.timer = setTimeout(() => {
|
|
57
|
+
this.timer = null;
|
|
58
|
+
this.startPending();
|
|
59
|
+
}, this.debounceMs);
|
|
60
|
+
}
|
|
61
|
+
return operation;
|
|
62
|
+
}
|
|
63
|
+
close() {
|
|
64
|
+
if (this.timer)
|
|
65
|
+
clearTimeout(this.timer);
|
|
66
|
+
this.timer = null;
|
|
67
|
+
this.unsubscribe();
|
|
68
|
+
}
|
|
69
|
+
startPending() {
|
|
70
|
+
if (this.activeOperationId || !this.pending)
|
|
71
|
+
return;
|
|
72
|
+
const next = this.pending;
|
|
73
|
+
this.pending = null;
|
|
74
|
+
this.activeOperationId = next.operationId;
|
|
75
|
+
this.operations.run(next.operationId, async (signal, report) => {
|
|
76
|
+
report({
|
|
77
|
+
phase: 'starting',
|
|
78
|
+
progress: 5,
|
|
79
|
+
message: `Refreshing project state (${Array.from(next.reasons).join(', ')}).`,
|
|
80
|
+
});
|
|
81
|
+
const result = await runRefreshWorker(next.input, signal, report);
|
|
82
|
+
this.onActivated(result);
|
|
83
|
+
return result;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
function runRefreshWorker(input, signal, report) {
|
|
88
|
+
return new Promise((resolve, reject) => {
|
|
89
|
+
const worker = new Worker(new URL('./project-refresh-worker.js', import.meta.url), {
|
|
90
|
+
workerData: input,
|
|
91
|
+
});
|
|
92
|
+
let settled = false;
|
|
93
|
+
const finish = (callback) => {
|
|
94
|
+
if (settled)
|
|
95
|
+
return;
|
|
96
|
+
settled = true;
|
|
97
|
+
signal.removeEventListener('abort', onAbort);
|
|
98
|
+
callback();
|
|
99
|
+
};
|
|
100
|
+
const onAbort = () => {
|
|
101
|
+
void worker.terminate();
|
|
102
|
+
finish(() => reject(Object.assign(new Error('Project refresh cancelled.'), { code: 'OPERATION_CANCELLED' })));
|
|
103
|
+
};
|
|
104
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
105
|
+
worker.on('message', (message) => {
|
|
106
|
+
if (message?.type === 'progress') {
|
|
107
|
+
report({
|
|
108
|
+
phase: String(message.phase ?? 'running'),
|
|
109
|
+
progress: Number(message.progress ?? 1),
|
|
110
|
+
message: String(message.message ?? 'Refreshing project state.'),
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else if (message?.type === 'complete') {
|
|
114
|
+
finish(() => {
|
|
115
|
+
void worker.terminate();
|
|
116
|
+
resolve(message.result);
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
else if (message?.type === 'error') {
|
|
120
|
+
const error = Object.assign(new Error(String(message.error?.message ?? 'Project refresh failed.')), { code: String(message.error?.code ?? 'PROJECT_REFRESH_FAILED') });
|
|
121
|
+
finish(() => {
|
|
122
|
+
void worker.terminate();
|
|
123
|
+
reject(error);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
worker.on('error', (error) => finish(() => reject(error)));
|
|
128
|
+
worker.on('exit', (code) => {
|
|
129
|
+
if (code !== 0)
|
|
130
|
+
finish(() => reject(new Error(`Project refresh worker exited with code ${code}.`)));
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
//# sourceMappingURL=project-refresh-coordinator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-refresh-coordinator.js","sourceRoot":"","sources":["../src/project-refresh-coordinator.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface ProjectRefreshWorkerInput {
|
|
2
|
+
projectRoot: string;
|
|
3
|
+
dbtManifestPath?: string;
|
|
4
|
+
writeManifest: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface ProjectRefreshWorkerResult {
|
|
7
|
+
snapshotId: string;
|
|
8
|
+
objectCount: number;
|
|
9
|
+
edgeCount: number;
|
|
10
|
+
metadataFingerprint: string;
|
|
11
|
+
kgFingerprint: string;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=project-refresh-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-refresh-worker.d.ts","sourceRoot":"","sources":["../src/project-refresh-worker.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,yBAAyB;IACxC,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,0BAA0B;IACzC,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { rename, rm, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { parentPort, workerData } from 'node:worker_threads';
|
|
5
|
+
import { buildManifest } from '@duckcodeailabs/dql-core';
|
|
6
|
+
import { defaultKgPath, reindexProject } from '@duckcodeailabs/dql-agent';
|
|
7
|
+
async function run(input) {
|
|
8
|
+
parentPort?.postMessage({ type: 'progress', phase: 'compiling', progress: 15, message: 'Compiling project snapshot.' });
|
|
9
|
+
const manifest = buildManifest({
|
|
10
|
+
projectRoot: input.projectRoot,
|
|
11
|
+
dqlVersion: 'notebook',
|
|
12
|
+
dbtManifestPath: input.dbtManifestPath,
|
|
13
|
+
});
|
|
14
|
+
const serializedManifest = `${JSON.stringify(manifest, null, 2)}\n`;
|
|
15
|
+
const snapshotId = createHash('sha256').update(serializedManifest).digest('hex');
|
|
16
|
+
if (input.writeManifest)
|
|
17
|
+
await writeManifestAtomically(input.projectRoot, serializedManifest);
|
|
18
|
+
parentPort?.postMessage({ type: 'progress', phase: 'indexing', progress: 55, message: 'Updating governed search indexes.' });
|
|
19
|
+
const indexed = await reindexProject(input.projectRoot, {
|
|
20
|
+
manifest,
|
|
21
|
+
kgPath: defaultKgPath(input.projectRoot),
|
|
22
|
+
forceMetadataCatalog: true,
|
|
23
|
+
forceKgIndex: true,
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
snapshotId,
|
|
27
|
+
objectCount: indexed.nodes,
|
|
28
|
+
edgeCount: indexed.edges,
|
|
29
|
+
metadataFingerprint: indexed.metadataFingerprint,
|
|
30
|
+
kgFingerprint: indexed.kgFingerprint,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
async function writeManifestAtomically(projectRoot, manifest) {
|
|
34
|
+
const manifestPath = join(projectRoot, 'dql-manifest.json');
|
|
35
|
+
const tempPath = `${manifestPath}.tmp-${process.pid}-${Date.now()}`;
|
|
36
|
+
try {
|
|
37
|
+
await writeFile(tempPath, manifest, 'utf8');
|
|
38
|
+
await rename(tempPath, manifestPath);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
await rm(tempPath, { force: true }).catch(() => undefined);
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
void run(workerData)
|
|
46
|
+
.then((result) => parentPort?.postMessage({ type: 'complete', result }))
|
|
47
|
+
.catch((error) => {
|
|
48
|
+
parentPort?.postMessage({
|
|
49
|
+
type: 'error',
|
|
50
|
+
error: {
|
|
51
|
+
code: error && typeof error === 'object' && 'code' in error
|
|
52
|
+
? String(error.code ?? 'PROJECT_REFRESH_FAILED')
|
|
53
|
+
: 'PROJECT_REFRESH_FAILED',
|
|
54
|
+
message: error instanceof Error ? error.message : String(error),
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=project-refresh-worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-refresh-worker.js","sourceRoot":"","sources":["../src/project-refresh-worker.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@duckcodeailabs/dql-cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Public CLI for parsing, formatting, testing, and certifying DQL blocks",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -20,15 +20,16 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@anthropic-ai/sdk": "^0.104.2",
|
|
23
|
-
"@duckcodeailabs/dql-agent": "^1.
|
|
24
|
-
"@duckcodeailabs/dql-compiler": "^1.
|
|
25
|
-
"@duckcodeailabs/dql-connectors": "^1.
|
|
26
|
-
"@duckcodeailabs/dql-core": "^1.
|
|
27
|
-
"@duckcodeailabs/dql-governance": "^1.
|
|
28
|
-
"@duckcodeailabs/dql-mcp": "^1.
|
|
29
|
-
"@duckcodeailabs/dql-notebook": "^1.
|
|
30
|
-
"@duckcodeailabs/dql-project": "^1.
|
|
31
|
-
"@duckcodeailabs/dql-slack": "^1.
|
|
23
|
+
"@duckcodeailabs/dql-agent": "^1.13.0",
|
|
24
|
+
"@duckcodeailabs/dql-compiler": "^1.13.0",
|
|
25
|
+
"@duckcodeailabs/dql-connectors": "^1.13.0",
|
|
26
|
+
"@duckcodeailabs/dql-core": "^1.13.0",
|
|
27
|
+
"@duckcodeailabs/dql-governance": "^1.13.0",
|
|
28
|
+
"@duckcodeailabs/dql-mcp": "^1.13.0",
|
|
29
|
+
"@duckcodeailabs/dql-notebook": "^1.13.0",
|
|
30
|
+
"@duckcodeailabs/dql-project": "^1.13.0",
|
|
31
|
+
"@duckcodeailabs/dql-slack": "^1.13.0",
|
|
32
|
+
"better-sqlite3": "^12.11.1",
|
|
32
33
|
"isomorphic-git": "^1.27.0",
|
|
33
34
|
"js-yaml": "^4.1.0",
|
|
34
35
|
"node-cron": "^3.0.3",
|
|
@@ -37,6 +38,7 @@
|
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@duckcodeailabs/dql-notebook-app": "^1.6.34",
|
|
41
|
+
"@types/better-sqlite3": "^7.6.13",
|
|
40
42
|
"@types/js-yaml": "^4.0.9",
|
|
41
43
|
"@types/node-cron": "^3.0.11",
|
|
42
44
|
"@types/nodemailer": "^6.4.17",
|
|
@@ -48,7 +50,7 @@
|
|
|
48
50
|
"node": ">=20"
|
|
49
51
|
},
|
|
50
52
|
"scripts": {
|
|
51
|
-
"build": "rm -rf dist tsconfig.tsbuildinfo && tsc -b && node ./scripts/copy-runtime-assets.mjs",
|
|
53
|
+
"build": "pnpm --filter @duckcodeailabs/dql-notebook-app build && rm -rf dist tsconfig.tsbuildinfo && tsc -b && node ./scripts/copy-runtime-assets.mjs",
|
|
52
54
|
"dev": "tsx src/index.ts",
|
|
53
55
|
"test": "vitest run --passWithNoTests",
|
|
54
56
|
"bench:manifest": "tsx bench/manifest-bench.ts",
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import{R as O,j as i,aP as We,r as $,u as $t,t as Ct,a as E}from"./index-BTuliKhK.js";import{C as ce,b as Ke,T as Ze,a as Bt,f as At}from"./usePersistedAgentThreadId-CkVFrrjk.js";import{T as zt}from"./TrustBadge-DGuHB8kP.js";import{R as Lt,G as Tt}from"./AiBuildResult-D9t_4sQl.js";const Rt={value:"Value",block:"Certified block",term:"Business term",metric:"Metric",dimension:"Dimension",model:"dbt model",source:"Source table",consumer:"Used by"};function Oe(e){const t=(e??"").toLowerCase();return t==="certified"?"success":t==="deprecated"?"neutral":t.includes("review")||t==="draft"||t==="pending"?"warning":"neutral"}function Mt({walk:e,defaultOpen:t=!1,triggerLabel:r}){const[n,o]=O.useState(t),s=Math.min(e.steps.length,2),[a,d]=O.useState(s),u=()=>d(s),l=e.steps.slice(0,a),p=e.steps.length-a;return i.jsxs("div",{style:{border:"1px solid var(--border-subtle, rgba(127,127,127,0.25))",borderRadius:8,background:"var(--bg-1, transparent)",overflow:"hidden"},children:[i.jsxs("button",{type:"button","aria-expanded":n,onClick:()=>{o(c=>!c),n&&u()},style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",gap:8,border:0,background:"transparent",color:"var(--text-secondary, inherit)",cursor:"pointer",padding:"8px 11px",font:"inherit",fontSize:12,fontWeight:700},children:[i.jsxs("span",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsx("span",{"aria-hidden":!0,style:{transform:n?"rotate(90deg)":"none",transition:"transform 120ms",display:"inline-block"},children:"▸"}),r??"Why?"]}),i.jsx("span",{style:{fontSize:11,color:"var(--text-tertiary, inherit)",fontWeight:600},children:n?"Hide derivation":"Show how this was derived"})]}),n&&i.jsxs("div",{style:{padding:"2px 11px 11px",display:"flex",flexDirection:"column",gap:10},children:[i.jsx("div",{style:{fontSize:12.5,lineHeight:1.5,color:"var(--text-primary, inherit)"},children:e.summary}),(e.trustLabel||e.freshness)&&i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[e.trustLabel&&i.jsx(We,{tone:Oe(e.trustLabel),children:Pe(e.trustLabel)}),e.freshness&&i.jsxs("span",{style:{fontSize:11,color:"var(--text-tertiary, inherit)"},children:["Fresh as of ",_t(e.freshness)]})]}),i.jsx("ol",{style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:7},children:l.map((c,f)=>i.jsxs("li",{style:{display:"flex",gap:9,alignItems:"flex-start",paddingLeft:2},children:[i.jsx("span",{"aria-hidden":!0,style:{marginTop:3,width:7,height:7,borderRadius:999,flexShrink:0,background:"var(--accent, currentColor)",opacity:.7}}),i.jsxs("div",{style:{minWidth:0,display:"flex",flexDirection:"column",gap:2},children:[i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontSize:10,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--text-tertiary, inherit)"},children:Rt[c.kind]}),i.jsx("span",{style:{fontSize:12.5,fontWeight:700,color:"var(--text-primary, inherit)",overflowWrap:"anywhere"},children:c.name}),c.status&&i.jsx(We,{tone:Oe(c.status),children:Pe(c.status)})]}),(c.owner||c.detail)&&i.jsxs("div",{style:{fontSize:11.5,color:"var(--text-secondary, inherit)",lineHeight:1.45},children:[c.owner&&i.jsxs("span",{children:["Owner: ",c.owner,". "]}),c.detail]})]})]},`${c.kind}-${c.name}-${f}`))}),p>0&&i.jsxs("button",{type:"button",onClick:()=>d(c=>Math.min(e.steps.length,c+1)),style:{alignSelf:"flex-start",border:"1px solid var(--border-default, rgba(127,127,127,0.3))",borderRadius:6,background:"transparent",color:"var(--accent, inherit)",cursor:"pointer",padding:"4px 9px",fontSize:11,fontWeight:700},children:["Show next step (",p," more)"]}),e.caveats&&e.caveats.length>0&&i.jsxs("div",{style:{borderLeft:"3px solid var(--status-warning, #d29922)",background:"var(--status-warning-bg, rgba(210,153,34,0.08))",borderRadius:6,padding:"8px 10px",display:"flex",flexDirection:"column",gap:4},children:[i.jsx("span",{style:{fontSize:10,fontWeight:800,textTransform:"uppercase",letterSpacing:"0.04em",color:"var(--status-warning, inherit)"},children:"Caveats"}),e.caveats.map((c,f)=>i.jsx("span",{style:{fontSize:11.5,color:"var(--text-secondary, inherit)",lineHeight:1.45},children:c},f))]})]})]})}function Pe(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,t=>t.toUpperCase())}function _t(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleDateString()}const ue=/date|time|day|month|year|week|quarter|period|_at$|^at$/i,fe=/(?:^|_)(?:id|uuid|key|code)$/i,he=/(?:name|title|label|display|description|customer|account|product|region|segment|category|channel)$/i,Dt=new Set(["bar","grouped-bar","stacked-bar","line","area","scatter","pie","donut","heatmap","histogram","funnel","sankey","waterfall","gauge","kpi","table"]);function qe(e){return typeof e=="number"?Number.isFinite(e):typeof e=="string"?e.trim()!==""&&Number.isFinite(Number(e)):!1}function et(e){const t=e.rows.slice(0,20);return t.length===0?[]:e.columns.filter(r=>t.some(n=>qe(n[r]))&&t.every(n=>{const o=n[r];return o==null||o===""||qe(o)}))}function It(e,t){const r=e.columns.filter(n=>!t.includes(n));return r.find(n=>he.test(n)&&!fe.test(n))??r.find(n=>!fe.test(n))??r[0]??e.columns[0]}function Wt(e){return e.columns.filter(t=>{if(!fe.test(t))return!1;const r=t.replace(/(?:_)?(?:id|uuid|key|code)$/i,"").replace(/_+$/,"");return e.columns.some(n=>n!==t&&(r.length>0&&n.toLowerCase().startsWith(r.toLowerCase())&&he.test(n)||r.length===0&&he.test(n)))})}function Ot(e,t){if(t.length===0)return e;const r=new Set(t);return{...e,columns:e.columns.filter(n=>!r.has(n)),rows:e.rows.map(n=>Object.fromEntries(Object.entries(n).filter(([o])=>!r.has(o))))}}function tt(e,t){const r=et(e),n=e.rows.length>0,o=e.columns.filter(g=>!r.includes(g));if(!(n&&r.length>=1))return{config:{...t??{},chart:"table",decisionSource:"data",rationale:"The returned rows do not contain a numeric measure to plot."},chartable:!1,reason:"No numeric measure"};const a=It(e,r),d=t!=null&&t.x&&e.columns.includes(t.x)?t.x:a,u=t!=null&&t.y&&e.columns.includes(t.y)?t.y:r.find(g=>g!==d)??r[0],l=qt(e,r,o,d),p=Pt(t==null?void 0:t.chart),c=t==null?void 0:t.decisionSource,f=c==="authored"||c==="user",h=f&&p||p&&Ft(p,e,r,o,d,u)?p:l.chart,x=!!(p&&p!==h&&!f),b=t!=null&&t.color&&e.columns.includes(t.color)?t.color:h==="sankey"?o.find(g=>g!==d):t==null?void 0:t.color,S=x?`${l.reason}; replaced the agent suggestion because the returned data is not compatible.`:p&&!f?"Agent-selected visualization validated against the returned data.":l.reason;return{config:{...t??{},chart:h,x:d,y:u,...b?{color:b}:{},decisionSource:f?c:p&&!x?"agent":"data",rationale:S},chartable:h!=="table",reason:S}}function Pt(e){if(typeof e!="string")return;const t=e.toLowerCase().replace(/_/g,"-").replace("single-value","kpi");return Dt.has(t)?t:void 0}function qt(e,t,r,n){return e.rows.length===1&&t.length>=1?{chart:"kpi",reason:"Single returned value"}:ue.test(n)&&t.length>=1?{chart:"line",reason:`Time-like field ${n}`}:r.length>0&&t.length>=2?{chart:"grouped-bar",reason:"One category with multiple numeric measures"}:r.length>0&&t.length===1?{chart:"bar",reason:"Categorical comparison with one numeric measure"}:t.length>=2?{chart:"scatter",reason:"Two continuous numeric measures"}:{chart:"table",reason:"No comparable category or time axis was returned"}}function Ft(e,t,r,n,o,s){return e==="table"?!0:e==="kpi"||e==="gauge"?r.length>=1&&t.rows.length===1:e==="line"||e==="area"?r.includes(s)&&ue.test(o):e==="scatter"?r.length>=2:e==="sankey"?n.length>=2&&r.length>=1:e==="histogram"?r.length>=1:e==="grouped-bar"||e==="stacked-bar"?n.length>=1&&r.length>=2:e==="pie"||e==="donut"?n.length>=1&&r.length>=1&&t.rows.length>=2&&t.rows.length<=8:e==="heatmap"?t.columns.length>=3&&r.length>=1:e==="funnel"||e==="waterfall"?n.length>=1&&r.length>=1:e==="bar"?n.length>=1&&r.length>=1&&!ue.test(o):!1}function Qn({result:e,themeMode:t,t:r,chartConfig:n,embedded:o=!1,tabLabels:s}){const a=e.rows.length===0,[d,u]=$.useState(),[l,p]=$.useState(!1),c=$.useMemo(()=>({...n??{},...d??{}}),[n,d]),{config:f,chartable:h}=tt(e,c),x=$.useMemo(()=>et(e),[e]),b=$.useMemo(()=>Wt(e),[e]),S=$.useMemo(()=>l?e:Ot(e,b),[b,e,l]),[g,j]=$.useState("table"),w=m=>({border:"none",background:"transparent",cursor:"pointer",fontFamily:r.font,fontSize:11,fontWeight:700,padding:"2px 4px",color:m?r.accent:r.textMuted,borderBottom:`2px solid ${m?r.accent:"transparent"}`}),T=ce.some(m=>m.value===f.chart)?f.chart:"bar";return i.jsxs("div",{style:{border:o?"none":`1px solid ${r.headerBorder}`,background:r.cellBg,borderRadius:o?0:8,overflow:"hidden"},children:[i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",padding:o?"9px 14px":"5px 9px",borderBottom:`1px solid ${r.headerBorder}`},children:[h&&i.jsx("button",{type:"button",onClick:()=>j("table"),style:w(g==="table"),children:(s==null?void 0:s.table)??"Table"}),h&&i.jsx("button",{type:"button",onClick:()=>j("chart"),style:w(g==="chart"),children:(s==null?void 0:s.chart)??"Chart"}),!h&&!a&&i.jsx("span",{style:{fontSize:11,fontWeight:700,color:r.textMuted},children:(s==null?void 0:s.table)??"Table"}),h&&g==="chart"?i.jsx("select",{value:T,onChange:m=>u(A=>({...A??{},chart:m.target.value,decisionSource:"user",rationale:"Selected manually."})),title:"Chart type",style:{fontFamily:r.font,fontSize:10.5,fontWeight:600,color:r.textSecondary,background:r.cellBg,border:`1px solid ${r.headerBorder}`,borderRadius:5,padding:"1px 4px",cursor:"pointer"},children:ce.map(m=>i.jsx("option",{value:m.value,children:m.label},m.value))}):null,h&&g==="chart"?i.jsxs(i.Fragment,{children:[i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:3,color:r.textMuted,fontSize:10.5},children:["X",i.jsx("select",{"aria-label":"X-axis field",value:f.x??"",onChange:m=>u(A=>({...A??{},x:m.target.value,decisionSource:"user",rationale:"Axis selected manually."})),style:{fontFamily:r.font,fontSize:10.5,color:r.textSecondary,background:r.cellBg,border:`1px solid ${r.headerBorder}`,borderRadius:5,padding:"1px 3px",cursor:"pointer",maxWidth:120},children:e.columns.map(m=>i.jsx("option",{value:m,children:m},m))})]}),x.length>0?i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:3,color:r.textMuted,fontSize:10.5},children:["Y",i.jsx("select",{"aria-label":"Y-axis field",value:f.y??"",onChange:m=>u(A=>({...A??{},y:m.target.value,decisionSource:"user",rationale:"Axis selected manually."})),style:{fontFamily:r.font,fontSize:10.5,color:r.textSecondary,background:r.cellBg,border:`1px solid ${r.headerBorder}`,borderRadius:5,padding:"1px 3px",cursor:"pointer",maxWidth:120},children:x.map(m=>i.jsx("option",{value:m,children:m},m))})]}):null,f.chart==="sankey"?i.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:3,color:r.textMuted,fontSize:10.5},children:["Target",i.jsx("select",{"aria-label":"Sankey target field",value:f.color??"",onChange:m=>u(A=>({...A??{},color:m.target.value,decisionSource:"user",rationale:"Sankey target selected manually."})),style:{fontFamily:r.font,fontSize:10.5,color:r.textSecondary,background:r.cellBg,border:`1px solid ${r.headerBorder}`,borderRadius:5,padding:"1px 3px",cursor:"pointer",maxWidth:120},children:e.columns.filter(m=>!x.includes(m)&&m!==f.x).map(m=>i.jsx("option",{value:m,children:m},m))})]}):null]}):null,h&&g==="chart"&&f.rationale?i.jsxs("span",{title:f.rationale,style:{fontSize:10.5,color:r.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:230},children:["Smart chart · ",f.chart]}):null,i.jsxs("span",{style:{marginLeft:"auto",fontSize:10.5,color:r.textMuted,alignSelf:"center"},children:[e.rowCount??e.rows.length," rows"]})]}),i.jsx("div",{style:{padding:o?12:8,minHeight:h&&g==="chart"?200:void 0,maxHeight:o?380:320,overflow:"auto"},children:a?i.jsxs("div",{style:{padding:"18px 8px",textAlign:"center",color:r.textMuted,fontSize:12},children:["The query ran successfully and matched 0 rows",e.columns.length>0?` (columns: ${e.columns.join(", ")})`:"","."]}):h&&g==="chart"?i.jsx(Ke,{result:e,themeMode:t,chartConfig:f,onConfigChange:m=>u(A=>({...A??{},...m,decisionSource:"user",rationale:"Adjusted manually."}))}):i.jsxs(i.Fragment,{children:[b.length>0?i.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginBottom:6},children:i.jsx("button",{type:"button",onClick:()=>p(m=>!m),style:{border:"none",background:"transparent",color:r.accent,cursor:"pointer",fontSize:10.5,padding:0},children:l?"Hide technical fields":"Show IDs"})}):null,i.jsx(Ze,{result:S,themeMode:t})]})})]})}const Et=3;function Qt(e){const{business360:t,block:r,value:n,generated:o=!1}=e,s=e.maxPerKind??Et,a=t.focus,d=[];n&&d.push({kind:"value",name:n,detail:a.name?`Reported by ${a.name}.`:void 0});const u=(r==null?void 0:r.owner)??a.owner,l=(r==null?void 0:r.status)??a.status,p=(r==null?void 0:r.reviewCadence)??oe(a.metadata,"reviewCadence");d.push({kind:"block",name:a.name,owner:u,status:l,detail:Nt({reviewCadence:p,businessOutcome:(r==null?void 0:r.businessOutcome)??oe(a.metadata,"businessOutcome"),decisionUse:r==null?void 0:r.decisionUse})});const c=Fe([...t.businessDefinition.terms,...t.businessDefinition.definedByTerms]);for(const x of c.slice(0,s))x.id!==a.id&&d.push({kind:"term",name:x.name,owner:x.owner,detail:"Business term this answer is defined in."});for(const x of se(r==null?void 0:r.metricRefs).slice(0,s))d.push({kind:"metric",name:x,detail:"Governed metric used in the calculation."});for(const x of se(r==null?void 0:r.dimensionRefs).slice(0,s))d.push({kind:"dimension",name:x,detail:"Dimension used to slice the value."});for(const x of t.technicalSources.dbtModels.slice(0,s))d.push({kind:"model",name:x.name,detail:"dbt model the certified SQL builds on."});const f=Fe([...t.technicalSources.dbtSources,...t.technicalSources.sourceTables]);for(const x of f.slice(0,s))d.push({kind:"source",name:x.name,detail:"Raw source table the data originates from."});const h=se((r==null?void 0:r.caveats)??Vt(a.metadata,"caveats"));return{value:n,summary:Ut({focus:a,blockOwner:u,reviewCadence:p,generated:o,sourceAssets:f}),steps:d,trustLabel:e.trustLabel??(o?"review_required":void 0),freshness:e.freshness??Ht(r==null?void 0:r.dataState,r==null?void 0:r.dataStateDetail)??oe(a.metadata,"freshness"),caveats:h.length>0?h:void 0}}function Ht(e,t){switch(e){case"failed":return t?`upstream failed — ${t}`:"upstream failed";case"stale":return t?`stale data — ${t}`:"stale data";default:return}}function Nt(e){const t=[];return e.businessOutcome?t.push(e.businessOutcome):e.decisionUse&&t.push(`Supports: ${e.decisionUse}.`),e.reviewCadence&&t.push(`Reviewed ${e.reviewCadence}.`),t.length>0?t.join(" "):void 0}function Ut(e){const t=e.blockOwner?` owned by ${e.blockOwner}`:"",r=e.sourceAssets.length>0?` It traces back to ${e.sourceAssets[0].name}.`:"";if(e.generated)return`This value was generated from ${e.focus.name}${t} and still needs analyst review before it can be certified.${r}`;const n=e.reviewCadence?`, reviewed ${e.reviewCadence}`:"";return`This value comes from the certified ${e.focus.name}${t}${n}.${r}`}function oe(e,t){const r=e==null?void 0:e[t];return typeof r=="string"&&r.trim().length>0?r:void 0}function Vt(e,t){const r=e==null?void 0:e[t];return Array.isArray(r)?r.filter(n=>typeof n=="string"&&n.trim().length>0):[]}function se(e){if(!e)return[];const t=new Set,r=[];for(const n of e){const o=typeof n=="string"?n.trim():"";!o||t.has(o.toLowerCase())||(t.add(o.toLowerCase()),r.push(o))}return r}function Fe(e){const t=new Set,r=[];for(const n of e)t.has(n.id)||(t.add(n.id),r.push(n));return r}function nt(e){var n,o;const t=e.dqlArtifact,r=(n=t==null?void 0:t.source)==null?void 0:n.trim();return r?{source:r,kind:t==null?void 0:t.kind,name:t==null?void 0:t.name,sourcePath:t==null?void 0:t.sourcePath,metrics:le(t==null?void 0:t.metrics),dimensions:le(t==null?void 0:t.dimensions),filters:((t==null?void 0:t.filters)??[]).map(s=>{var l,p;const a=(l=s.dimension)==null?void 0:l.trim(),d=((p=s.operator)==null?void 0:p.trim())||"equals",u=le(s.values);return!a||u.length===0?"":`${a} ${d} ${u.join(", ")}`}).filter(Boolean),timeDimension:(o=t==null?void 0:t.timeDimension)!=null&&o.name?[t.timeDimension.name,t.timeDimension.granularity].filter(Boolean).join(" / "):void 0,orderBy:((t==null?void 0:t.orderBy)??[]).map(s=>{var u,l;const a=(u=s.name)==null?void 0:u.trim(),d=(l=s.direction)==null?void 0:l.trim();return a&&d?`${a} ${d}`:""}).filter(Boolean),limit:typeof(t==null?void 0:t.limit)=="number"&&Number.isFinite(t.limit)?t.limit:void 0}:null}function Jt(e){for(let t=e.length-1;t>=0;t--){const r=e[t];if(r.kind!=="tool_result"||r.id!=="governed_answer")continue;const n=r.output;if(n&&typeof n=="object"&&"kind"in n)return n}return null}function le(e){return Array.isArray(e)?e.map(t=>typeof t=="string"?t.trim():"").filter(Boolean):[]}function Gt(e){const t=e.result;if(!t||!Array.isArray(t.rows))return null;const n=(Array.isArray(t.columns)?t.columns:[]).map(s=>typeof s=="string"?s:s&&typeof s=="object"&&typeof s.name=="string"?String(s.name):String(s)),o=t.rows.filter(s=>!!(s&&typeof s=="object"&&!Array.isArray(s))).map(s=>s);return{columns:n,rows:o,rowCount:typeof t.rowCount=="number"?t.rowCount:o.length,executionTime:t.executionTime}}function Xt(e,t){const r=e&&typeof e=="object"?e:{},n=typeof r.chart=="string"?r.chart:void 0,o=r.decisionSource==="authored"||r.decisionSource==="agent"||r.decisionSource==="data"||r.decisionSource==="user"?r.decisionSource:void 0,s=n||(typeof t.suggestedViz=="string"?t.suggestedViz:void 0),a=s?s.toLowerCase().replace(/_/g,"-")==="single-value"?"kpi":s:void 0;return{...a?{chart:a}:{},...a?{decisionSource:o??(n?"authored":"agent")}:{},...typeof r.rationale=="string"?{rationale:r.rationale}:{},...typeof r.x=="string"?{x:r.x}:{},...typeof r.y=="string"?{y:r.y}:{},...typeof r.color=="string"?{color:r.color}:{},...typeof r.title=="string"?{title:r.title}:{}}}function Yt(e,t){return!t||t.columns.length===0?e:tt(t,e).config}function ae(e){if(typeof e!="string")return;const t=e.replace(/\s+/g," ").trim();if(t)return t.length>180?`${t.slice(0,177)}...`:t}function rt(e){const t=Kt(e,["Answer","Business summary","Summary"]);if(t)return Ee(t,340);const r=/^(?:reuse evidence|certified result preview|result preview|result summary|trust status|next action|recommended action|sql used by block|reusable block sql|proposed sql|sql generated|sql draft|evidence|parameters|lineage|technical lineage)\s*:/i,n=/^(?:SELECT|WITH|FROM|WHERE|GROUP BY|ORDER BY|LIMIT)\b/i,o=[];for(const a of e.split(/\r?\n/)){const d=a.trim();if(!(!d||/^#{1,6}\s*/.test(d)||/^```/.test(d)||/^\|/.test(d))&&!/^outcome\s*:/i.test(d)){if(r.test(d)||n.test(d)){if(o.length>0)break;continue}if(o.push(d),o.length>=5)break}}const s=o.join(" ").replace(/[*_`]+/g,"").replace(/\s+/g," ").trim();return Ee(s,340)}function Kt(e,t){var p,c,f;const r=e.split(/\r?\n/),n=t.map(h=>h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|"),o=new RegExp(`^\\s*(?:#{1,6}\\s*)?(?:[-*]\\s*)?(?:\\*\\*)?(${n})(?:\\*\\*)?\\s*:\\s*(.*)$`,"i"),s=/^\s*(?:#{1,6}\s*)?(?:[-*]\s*)?(?:\*\*)?[A-Z][A-Za-z /-]{2,42}(?:\*\*)?\s*:/,a=r.findIndex(h=>o.test(h));if(a<0)return;const d=((f=(c=(p=r[a])==null?void 0:p.match(o))==null?void 0:c[2])==null?void 0:f.trim())??"",u=d?[d]:[];for(let h=a+1;h<r.length;h+=1){const x=r[h]??"";if(s.test(x)||/^\s*```/.test(x))break;x.trim()&&u.push(x.trim())}return u.join(" ").replace(/[*_`]+/g,"").replace(/\s+/g," ").trim()||void 0}function Ee(e,t){const r=e.replace(/\s+/g," ").trim();if(r.length<=t)return r;const n=r.slice(0,t-1),o=Math.max(n.lastIndexOf(". "),n.lastIndexOf("; "));if(o>100)return n.slice(0,o+1).trim();const s=n.lastIndexOf(" ");return`${n.slice(0,s>80?s:n.length).trim()}...`}function Zt({answer:e,themeMode:t,showSql:r=!0,compact:n=!1,addToAppTarget:o,sourceQuestion:s,onInvestigate:a,onInsertSql:d,onCreateBlock:u}){var we,ke,$e,Ce,Be,Ae,ze,Le,Te,Re,Me,_e,De;const l=Ct[t],{dispatch:p}=$t(),c=Gt(e),f=Xt((we=e.result)==null?void 0:we.chartConfig,e),[h,x]=$.useState(),b=Yt({...f??{},...h??{}},c),S=!!(c&&Bt(c,b)!=="table"),g=e.analysisPlan??((ke=e.evidence)==null?void 0:ke.analysisPlan),j=r?e.sql??(($e=e.result)==null?void 0:$e.sql)??e.proposedSql??(g==null?void 0:g.sql):void 0,w=nt(e),T=e.executionError??(((Be=(Ce=e.evidence)==null?void 0:Ce.execution)==null?void 0:Be.status)==="failed"?e.evidence.execution.message:void 0),m=((Ae=e.result)==null?void 0:Ae.blockPath)??((ze=e.block)==null?void 0:ze.sourcePath),A=!!(j||T||r&&m),ee=!!e.evidence,[U,pe]=$.useState("answer"),[ct,xe]=$.useState(!1),[ge,ut]=$.useState(!1),me=dt(e),ye=zn(me,l),be=(e.answer??e.text??"").replace(/\n\n_Question:_[\s\S]*$/m,"").trim(),M=n?rt(be):be,k=((Le=e.result)==null?void 0:Le.blockName)??((Te=e.block)==null?void 0:Te.name)??((Me=(Re=e.citations)==null?void 0:Re.find(y=>y.kind==="block"))==null?void 0:Me.name),te=Mn(e,k),ft=Ln(e,c,k,m),[ht,ve]=$.useState(!1),[V,J]=$.useState(null),[je,pt]=$.useState(null),xt=!!(o&&(c||j||M||k)),gt=!!(d&&j),mt=!!(u&&j),P=ae(g==null?void 0:g.question)??ae(s)??ae(M)??"Investigate this answer",yt=!!(a&&P),bt=it(e,{sql:j,executionError:T,blockName:k,result:c}),vt=()=>{!d||!j||(d(j,k??(g==null?void 0:g.question)??"AI SQL preview",{question:s??(g==null?void 0:g.question)}),pt("Inserted SQL preview cell for review."))},jt=()=>{!u||!j||u(j,{title:(w==null?void 0:w.name)??k??(g==null?void 0:g.question)??"AI DQL draft",description:M||(g==null?void 0:g.routeReason)||"AI generated DQL draft.",tags:["ai-generated","review-required"]})},St=async(y="auto")=>{if(!o)return;const W=y==="both"?["chart","data"]:y==="data"?["data"]:y==="chart"?["chart"]:c?[S?"chart":"data"]:[];ve(!0),xe(!1),J(null);try{if(e.certification==="certified"&&k){const B=await E.getDashboard(o.appId,o.dashboardId);if(!B)throw new Error("Dashboard could not be loaded.");const _=[...B.dashboard.layout.items],R=W.length>0?W:["chart"];for(const F of R){const X=R.length>1?`${k}_${F}`:k,Ie={...B.dashboard,layout:{...B.dashboard.layout,items:_}},kt=In(Ie,X);_.push({i:kt,...Dn(Ie),block:{blockId:k},viz:{type:F==="data"?"table":Wn(b==null?void 0:b.chart)},title:R.length>1?`${k} ${F==="data"?"data":"chart"}`:k})}const q={...B.dashboard.layout,items:_},L=await E.patchDashboardLayout(o.appId,o.dashboardId,q);if(!L.ok)throw new Error(L.error);J(R.length>1?"Added certified chart and data tiles.":"Added certified block tile.")}else{const B=!!(j&&window.confirm("Keep this AI result refreshed daily?")),_=k??(M.slice(0,60)||"AI result"),R=W.length>0?W:["data"];let q=c??void 0;if(!q&&j){const L=await E.previewGeneratedSql(j);if(!L.ok)throw new Error(`SQL preview failed: ${L.error}`);q=L.result}for(const L of R){const F=L==="data"?{...b??{},chart:"table",title:`${_} data`}:b,X=await E.createAiPin(o.appId,{dashboardId:o.dashboardId,title:R.length>1?`${_} ${L==="data"?"data":"chart"}`:_,answer:M||e.answer||e.text||"AI generated answer",question:g==null?void 0:g.question,sql:j,sourceTier:e.sourceTier,certification:e.certification==="certified"?"certified":"ai_generated",reviewStatus:"needs_review",refreshCadence:B?"daily":"none",chartConfig:F,result:q,citations:e.citations,analysisPlan:g,evidence:e.evidence,followUps:g==null?void 0:g.followUps});if(!X.ok)throw new Error(X.error)}J(R.length>1?"Pinned chart and data tiles for review.":"Pinned AI result for review.")}window.dispatchEvent(new CustomEvent("dql-app-dashboard-updated",{detail:o}))}catch(B){J(B instanceof Error?B.message:String(B))}finally{ve(!1)}},wt=()=>{!a||!P||a({question:P,title:te?`${te}: ${P}`:P,answerSummary:M,blockName:te,sql:j,evidence:e.evidence})},ne=[{id:"answer",label:n?"Summary":"Answer",visible:!0},{id:"dql",label:"DQL",visible:!!w},{id:"visual",label:n?"Chart":"Visualization",visible:S},{id:"data",label:"Data",visible:!!c},{id:"sql",label:"SQL / Block",visible:r&&A},{id:"lineage",label:n?"Trace":"Lineage",visible:ee},{id:"context",label:n?"Context":"Business Context",visible:ee},{id:"review",label:n?"Trust":"Review",visible:ee||!!((_e=e.citations)!=null&&_e.length)}].filter(y=>y.visible),Se=ne.some(y=>y.id===U)?U:"answer",G=ne.filter(y=>y.id!=="answer"),re=G.some(y=>y.id===U)?U:(De=G[0])==null?void 0:De.id,ie=y=>y==="answer"?i.jsx(on,{summary:M,answer:e,blockName:k,evidence:e.evidence,analysisPlan:g,result:c,sourceTier:e.sourceTier,compact:n,t:l}):y==="dql"&&w?i.jsx(Sn,{artifact:w,t:l}):y==="visual"&&c&&S?i.jsxs("div",{style:{padding:n?"8px 10px":"10px 12px",minHeight:n?180:220,display:"grid",gap:10},children:[i.jsx($n,{result:c,chartConfig:b,t:l,onChange:W=>x(B=>({...B??{},...W,decisionSource:"user",rationale:"Adjusted manually."}))}),i.jsx(Ke,{result:c,themeMode:t,chartConfig:b})]}):y==="data"&&c?i.jsx("div",{style:{maxHeight:n?320:420,overflow:"auto"},children:i.jsx(Ze,{result:c,themeMode:t})}):y==="lineage"?i.jsx(bn,{evidence:e.evidence,t:l}):y==="context"?i.jsx(vn,{evidence:e.evidence,t:l}):y==="sql"&&r&&A?i.jsx(wn,{sql:j,blockPath:m,executionError:T,t:l}):y==="review"?i.jsx(jn,{answer:e,t:l}):null;return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:n?8:10,whiteSpace:"normal"},children:[i.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",flexWrap:"wrap"},children:[i.jsx(zt,{state:me}),i.jsx(Lt,{t:l,route:e.route}),I(e.cascade)&&i.jsx("span",{style:{border:`1px solid ${l.cellBorder}`,borderRadius:999,padding:"3px 8px",fontSize:11,fontWeight:700,color:l.textSecondary,background:l.tableHeaderBg},children:I(e.cascade)}),!n&&k&&i.jsxs("span",{style:{fontSize:12,fontFamily:l.fontMono,color:l.textSecondary},children:["block: ",k]}),c&&i.jsxs("span",{style:{fontSize:12,color:l.textMuted},children:[(c.rowCount??c.rows.length).toLocaleString()," rows",c.executionTime!==void 0&&i.jsxs(i.Fragment,{children:[" - ",Math.round(c.executionTime),"ms"]})]}),xt&&i.jsx(Cn,{t:l,adding:ht,hasResult:!!c,hasChart:S,fallbackLabel:e.certification==="certified"&&k?n?"Add":"Add block":"Pin answer",open:ct,onToggle:()=>xe(y=>!y),onAdd:y=>void St(y)}),yt&&i.jsx("button",{type:"button",onClick:wt,style:{border:`1px solid ${l.accent}`,borderRadius:6,background:`${l.accent}12`,color:l.accent,cursor:"pointer",padding:n?"4px 8px":"5px 10px",fontSize:11,fontFamily:l.font,fontWeight:800},children:n?"Investigate":"Investigate deeper"}),mt&&i.jsx("button",{type:"button",onClick:jt,style:{border:`1px solid ${l.accent}`,borderRadius:6,background:l.cellBg,color:l.accent,cursor:"pointer",padding:n?"4px 8px":"5px 10px",fontSize:11,fontFamily:l.font,fontWeight:700},children:n?"DQL draft":w?"Review DQL draft":"Create DQL draft"}),gt&&i.jsx("button",{type:"button",onClick:vt,style:{border:`1px solid ${l.accent}`,borderRadius:6,background:`${l.accent}18`,color:l.accent,cursor:"pointer",padding:n?"4px 8px":"5px 10px",fontSize:11,fontFamily:l.font,fontWeight:700},children:n?"SQL preview":"Insert SQL preview"})]}),V&&i.jsx("div",{style:{fontSize:11,color:V.toLowerCase().includes("added")||V.toLowerCase().includes("pinned")?"#3fb950":"#ff7b72"},children:V}),je&&i.jsx("div",{style:{fontSize:11,color:"#3fb950"},children:je}),i.jsx(en,{outcome:bt,t:l,compact:n}),i.jsxs("div",{style:{border:`1px solid ${l.cellBorder}`,borderTop:`2px solid ${ye}`,borderRadius:n?10:6,overflow:"hidden",background:l.cellBg},children:[!n&&i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"4px 10px",borderBottom:`1px solid ${l.cellBorder}`,background:`${l.tableHeaderBg}70`,flexWrap:"wrap"},children:[ne.map(y=>i.jsx(Xe,{active:Se===y.id,label:y.label,onClick:()=>pe(y.id),t:l},y.id)),!r&&m&&i.jsx("span",{style:{marginLeft:"auto",minWidth:0,fontSize:11,fontFamily:l.fontMono,color:l.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:m})]}),ie(n?"answer":Se),n&&G.length>0&&i.jsxs("div",{style:{borderTop:`1px solid ${l.cellBorder}`,background:`${l.tableHeaderBg}45`},children:[i.jsxs("button",{type:"button",onClick:()=>ut(y=>!y),style:{width:"100%",border:0,background:"transparent",color:l.textSecondary,padding:"8px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:"pointer",fontSize:11,fontWeight:800},children:[i.jsx("span",{children:"Details"}),i.jsx("span",{style:{color:l.textMuted,fontFamily:l.fontMono},children:ge?"hide":"show evidence"})]}),ge&&i.jsxs("div",{style:{borderTop:`1px solid ${l.cellBorder}`},children:[i.jsx("div",{style:{display:"flex",alignItems:"center",gap:14,padding:"4px 12px",flexWrap:"wrap"},children:G.map(y=>i.jsx(Xe,{active:re===y.id,label:y.label,onClick:()=>pe(y.id),t:l},y.id))}),re?ie(re):null]})]}),i.jsx(kn,{items:ft,t:l,accent:ye}),i.jsx(Tt,{t:l,skills:e.appliedSkills,onOpenSkills:()=>p({type:"SET_MAIN_VIEW",view:"skills"})})]})]})}function it(e,t){var r,n,o,s,a;if(e.kind==="no_answer")return{kind:"cannot_answer",label:"Cannot answer yet",detail:"The assistant did not find enough trusted context to safely answer or generate SQL.",nextAction:"Clarify the business object, metric, grain, or source table.",tone:"error"};if(e.certification==="certified"||e.kind==="certified"){const d=t.blockName??e.sourceCertifiedBlock??((r=e.block)==null?void 0:r.name);return{kind:"reuse_certified_block",label:"Reuse certified block",detail:d?`Existing DQL block ${d} answers this request.`:"A certified DQL artifact answers this request.",nextAction:"Use the certified block instead of creating duplicate SQL.",tone:"success"}}return t.executionError||e.executionError?{kind:"fix_sql",label:"Fix SQL",detail:"The generated or selected SQL needs correction before it can become reusable DQL.",nextAction:"Ask AI to repair, edit manually, then rerun preview.",tone:"error"}:(n=e.draftBlock)!=null&&n.path||e.draftBlockId?{kind:"use_existing_draft",label:"Use existing draft",detail:`A review-required DQL draft is available at ${((o=e.draftBlock)==null?void 0:o.path)??e.draftBlockId}.`,nextAction:"Open the draft, review metadata/tests/lineage, then certify manually.",tone:"accent"}:(a=(s=e.dqlArtifact)==null?void 0:s.source)!=null&&a.trim()?{kind:"create_dql_draft",label:"Review DQL draft",detail:"A review-required DQL artifact is available for analyst review.",nextAction:"Review DQL metadata, query logic, lineage, and result preview before certification.",tone:"warning"}:t.sql?{kind:t.result?"generate_sql_cell":"create_dql_draft",label:t.result?"Review SQL preview":"Create DQL draft",detail:t.result?`Review-required SQL preview returned ${(t.result.rowCount??t.result.rows.length).toLocaleString()} row${(t.result.rowCount??t.result.rows.length)===1?"":"s"}.`:"Review-required SQL is available but still needs preview and DQL metadata review.",nextAction:t.result?"Create a DQL draft after reviewing parameters and lineage; insert SQL only as a notebook preview.":"Run preview, inspect parameters, then create a draft block.",tone:"warning"}:{kind:"needs_review",label:"Needs review",detail:"The assistant returned business context but no executable certified answer or SQL draft.",nextAction:"Review evidence and ask for a specific SQL, reuse, or DQL draft action.",tone:"muted"}}function en({outcome:e,t,compact:r}){const n=tn(e.tone,t);return i.jsxs("div",{style:{border:`1px solid ${n}45`,borderLeft:`3px solid ${n}`,borderRadius:r?10:7,background:`${n}10`,padding:r?"9px 10px":"10px 12px",display:"grid",gap:r?4:5},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,minWidth:0},children:[i.jsx("span",{style:{border:`1px solid ${n}55`,background:`${n}14`,color:n,borderRadius:999,padding:"2px 7px",fontSize:10,fontWeight:850,lineHeight:1.1,textTransform:"uppercase",letterSpacing:0,flexShrink:0},children:e.label}),i.jsx("span",{style:{fontSize:r?12:12.5,color:t.textPrimary,fontWeight:750,overflow:"hidden",textOverflow:"ellipsis"},children:e.detail})]}),i.jsxs("div",{style:{fontSize:r?11.5:12,color:t.textSecondary,lineHeight:1.45},children:["Next: ",e.nextAction]})]})}function tn(e,t){switch(e){case"success":return t.success;case"accent":return t.accent;case"warning":return t.warning;case"error":return t.error;case"muted":default:return t.textMuted}}function nn({answer:e,blockName:t}){const[r,n]=$.useState(null),[o,s]=$.useState(!1),[a,d]=$.useState(!1),u=O.useCallback(async()=>{var l,p;if(!a){d(!0),s(!0);try{const c=await E.fetchBusiness360(t);if(!c){n(null);return}const f=(l=e.evidence)==null?void 0:l.outcome,h=Qe(e,"metric"),x=Qe(e,"dimension"),b=e.certification!=="certified"&&e.kind!=="certified",S=Qt({business360:c,block:{name:t,owner:f==null?void 0:f.owner,status:((p=e.block)==null?void 0:p.status)??e.certification,reviewCadence:f==null?void 0:f.reviewCadence,caveats:f==null?void 0:f.caveats,decisionUse:f==null?void 0:f.decisionUse,metricRefs:h,dimensionRefs:x},value:rn(e),generated:b,trustLabel:e.trustLabel});n(S)}catch{n(null)}finally{s(!1)}}},[e,t,a]);return a?o?i.jsx("div",{style:{fontSize:11.5,color:"var(--text-tertiary, inherit)"},children:"Assembling derivation…"}):r?i.jsx(Mt,{walk:r,defaultOpen:!0}):null:i.jsx("button",{type:"button",onClick:()=>void u(),"aria-expanded":!1,style:{alignSelf:"flex-start",border:0,background:"transparent",color:"var(--accent, inherit)",cursor:"pointer",padding:"4px 0",fontSize:12,fontWeight:700,textDecoration:"underline",textUnderlineOffset:3},children:"Why? Show how this was derived"})}function Qe(e,t){var o,s;const r=(((o=e.evidence)==null?void 0:o.semanticObjects)??[]).filter(a=>a.kind===t).map(a=>a.name).filter(a=>!!a);if(r.length>0)return r;const n=e.analysisPlan??((s=e.evidence)==null?void 0:s.analysisPlan);return(t==="metric"?n==null?void 0:n.measures:n==null?void 0:n.dimensions)??[]}function rn(e){const t=e.result;if(t&&Array.isArray(t.rows)&&t.rows.length===1){const r=t.rows[0];if(r&&typeof r=="object"&&!Array.isArray(r)){const n=Object.values(r);if(n.length===1&&(typeof n[0]=="number"||typeof n[0]=="string"))return String(n[0])}}}function on({summary:e,answer:t,blockName:r,evidence:n,analysisPlan:o,result:s,sourceTier:a,compact:d,t:u}){var p,c,f,h,x,b,S,g,j;const l=(p=o==null?void 0:o.followUps)==null?void 0:p[0];return i.jsxs("div",{style:{padding:d?14:12,display:"flex",flexDirection:"column",gap:d?10:12},children:[e?i.jsx(ot,{text:e,t:u,compact:d,summaryOnly:d}):i.jsx("div",{style:{fontSize:12,color:u.textMuted},children:"No summary text was returned."}),t&&r&&i.jsx(nn,{answer:t,blockName:r}),d?i.jsx("div",{style:{fontSize:11.5,color:u.textMuted,display:"flex",flexWrap:"wrap",gap:6,alignItems:"center"},children:[a?An(a):null,s?`${(s.rowCount??s.rows.length).toLocaleString()} rows`:null,((c=n==null?void 0:n.validation)==null?void 0:c.status)==="failed"?"needs review":null,((f=n==null?void 0:n.execution)==null?void 0:f.status)==="failed"?"data check failed":null].filter(Boolean).map((w,T)=>i.jsxs(O.Fragment,{children:[T>0&&i.jsx("span",{style:{color:u.cellBorder},children:"·"}),i.jsx("span",{children:w})]},`${w}-${T}`))}):i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[a&&i.jsx(z,{label:C(a),t:u}),s&&i.jsx(z,{label:`${(s.rowCount??s.rows.length).toLocaleString()} rows`,t:u}),((h=n==null?void 0:n.validation)==null?void 0:h.status)&&i.jsx(z,{label:`validation: ${n.validation.status}`,t:u}),((x=n==null?void 0:n.execution)==null?void 0:x.status)&&i.jsx(z,{label:`execution: ${n.execution.status}`,t:u})]}),s&&!d&&i.jsx(yn,{result:s,t:u,compact:d}),o&&!d&&i.jsxs("div",{style:{display:"grid",gap:7,padding:d?"9px 10px":10,border:`1px solid ${u.cellBorder}`,borderRadius:8,background:`${u.tableHeaderBg}45`},children:[o.routeReason&&i.jsx("div",{style:{fontSize:d?12.5:12,lineHeight:1.45,color:u.textSecondary},children:o.routeReason}),(o.grain||((b=o.measures)==null?void 0:b.length)||((S=o.dimensions)==null?void 0:S.length))&&i.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[o.grain&&i.jsx(z,{label:`grain: ${o.grain}`,t:u}),(g=o.measures)==null?void 0:g.slice(0,2).map(w=>i.jsx(z,{label:w,t:u},`measure-${w}`)),(j=o.dimensions)==null?void 0:j.slice(0,2).map(w=>i.jsx(z,{label:w,t:u},`dimension-${w}`))]}),o.candidateJoins&&o.candidateJoins.length>0&&i.jsxs("div",{style:{fontSize:12,color:u.textMuted},children:["Join: ",i.jsx("span",{style:{color:u.textSecondary},children:at(o.candidateJoins[0])})]}),l&&i.jsxs("div",{style:{fontSize:12,color:u.textMuted},children:["Next: ",i.jsx("span",{style:{color:u.textSecondary},children:l})]})]})]})}function ot({text:e,t,compact:r=!1,summaryOnly:n=!1}){const o=n?rt(e):e,s=sn(o,t,r);return i.jsx("div",{style:{display:"flex",flexDirection:"column",gap:r?7:8,color:t.textPrimary,fontFamily:t.font,overflowWrap:"anywhere"},children:s})}function sn(e,t,r){var d;const n=ln(e).split(`
|
|
2
|
-
`),o=[];let s=0,a=0;for(;s<n.length;){const l=n[s].trim();if(!l){s+=1;continue}if(l.startsWith("```")){const h=l.replace(/^```/,"").trim(),x=[];for(s+=1;s<n.length&&!n[s].trim().startsWith("```");)x.push(n[s]),s+=1;s<n.length&&(s+=1),o.push(i.jsx("pre",{style:mn(t,r),"aria-label":h?`${h} code`:"code",children:x.join(`
|
|
3
|
-
`)},`code-${a++}`));continue}const p=l.match(/^(#{1,4})\s+(.+)$/);if(p){const h=p[1].length;o.push(i.jsx("div",{style:hn(t,r,h),children:D(p[2],t)},`heading-${a++}`)),s+=1;continue}if(/^[-*_]{3,}$/.test(l)){o.push(i.jsx("hr",{style:{width:"100%",border:0,borderTop:`1px solid ${t.cellBorder}`,margin:r?"2px 0":"4px 0"}},`hr-${a++}`)),s+=1;continue}if(an(n,s)){const h=[];for(;s<n.length&&Z(n[s].trim());)h.push(n[s].trim()),s+=1;o.push(i.jsx(cn,{lines:h,t,compact:r},`table-${a++}`));continue}if(l.startsWith(">")){const h=[];for(;s<n.length&&n[s].trim().startsWith(">");)h.push(n[s].trim().replace(/^>\s?/,"")),s+=1;o.push(i.jsx("div",{style:Ne(t,r),children:D(h.join(" "),t)},`quote-${a++}`));continue}if(/^[-*+]\s+/.test(l)){const h=[];for(;s<n.length&&/^[-*+]\s+/.test(n[s].trim());)h.push(n[s].trim().replace(/^[-*+]\s+/,"")),s+=1;o.push(i.jsx("ul",{style:Ue(t,r),children:h.map((x,b)=>i.jsx("li",{style:Ve(t,r),children:D(x,t)},`${x}-${b}`))},`ul-${a++}`));continue}if(/^\d+\.\s+/.test(l)){const h=[];for(;s<n.length&&/^\d+\.\s+/.test(n[s].trim());)h.push(n[s].trim().replace(/^\d+\.\s+/,"")),s+=1;o.push(i.jsx("ol",{style:Ue(t,r),children:h.map((x,b)=>i.jsx("li",{style:Ve(t,r),children:D(x,t)},`${x}-${b}`))},`ol-${a++}`));continue}const c=[];for(;s<n.length;){const h=n[s].trim();if(!h||He(h)&&c.length>0||(c.push(h),s+=1,He(((d=n[s])==null?void 0:d.trim())??"")))break}const f=c.join(" ");o.push(i.jsx("div",{style:o.length===0&&un(f)?Ne(t,r):fn(t,r),children:D(f,t)},`p-${a++}`))}return o}function ln(e){return e.replace(/\r\n/g,`
|
|
4
|
-
`).replace(/\|\s+\|(?=[^\n]*\|)/g,`|
|
|
5
|
-
|`)}function He(e){return!!(e.startsWith("```")||/^(#{1,4})\s+/.test(e)||/^[-*_]{3,}$/.test(e)||Z(e)||e.startsWith(">")||/^[-*+]\s+/.test(e)||/^\d+\.\s+/.test(e))}function an(e,t){var o,s;const r=((o=e[t])==null?void 0:o.trim())??"",n=((s=e[t+1])==null?void 0:s.trim())??"";return Z(r)&&dn(n)}function Z(e){return e.startsWith("|")&&e.endsWith("|")&&H(e).length>=2}function dn(e){if(!Z(e))return!1;const t=H(e);return t.length>=2&&t.every(r=>/^:?-{3,}:?$/.test(r.replace(/\s+/g,"")))}function H(e){return e.trim().replace(/^\|/,"").replace(/\|$/,"").split("|").map(t=>t.trim())}function cn({lines:e,t,compact:r}){const n=H(e[0]??""),o=H(e[1]??""),s=e.slice(2).map(H).filter(l=>l.length>0),a=Math.max(n.length,...s.map(l=>l.length),0);if(a===0)return null;const d=Array.from({length:a},(l,p)=>{var f;const c=((f=o[p])==null?void 0:f.replace(/\s+/g,""))??"";return c.startsWith(":")&&c.endsWith(":")?"center":c.endsWith(":")?"right":"left"}),u=Array.from({length:a},(l,p)=>n[p]??"");return i.jsx("div",{style:pn(t),children:i.jsxs("table",{style:xn(t,r),children:[i.jsx("thead",{children:i.jsx("tr",{children:u.map((l,p)=>i.jsx("th",{style:Je(t,r,!0,d[p]),children:D(l,t)},`h-${p}`))})}),i.jsx("tbody",{children:s.map((l,p)=>i.jsx("tr",{children:Array.from({length:a},(c,f)=>i.jsx("td",{style:Je(t,r,!1,d[f]),children:D(l[f]??"",t)},`c-${p}-${f}`))},`r-${p}`))})]})})}function un(e){return/\b(certified|uncertified|review[- ]required|draft|trusted|trust)\b/i.test(e)}function D(e,t){const r=[];let n=e,o=0;for(;n.length>0;){const s=n.match(/\*{3}(.+?)\*{3}/),a=n.match(/\*{2}(.+?)\*{2}/),d=n.match(/`([^`]+?)`/),u=n.match(/\[([^\]]+?)\]\((https?:\/\/[^)\s]+|\/[^)\s]+|#[^)\s]+)\)/),l=n.match(/\*([^\s*](?:.*?[^\s*])?)\*/),p=[s?{match:s,type:"boldItalic"}:null,a?{match:a,type:"bold"}:null,d?{match:d,type:"code"}:null,u?{match:u,type:"link"}:null,l?{match:l,type:"italic"}:null].filter(Boolean);if(p.length===0){r.push(i.jsx(O.Fragment,{children:n},`plain-${o++}`));break}const c=p.reduce((h,x)=>(h.match.index??0)<=(x.match.index??0)?h:x),f=c.match.index??0;f>0&&r.push(i.jsx(O.Fragment,{children:n.slice(0,f)},`plain-${o++}`)),c.type==="boldItalic"?r.push(i.jsx("strong",{style:{fontStyle:"italic",color:t.textPrimary},children:c.match[1]},`bi-${o++}`)):c.type==="bold"?r.push(i.jsx("strong",{style:{color:t.textPrimary},children:c.match[1]},`b-${o++}`)):c.type==="italic"?r.push(i.jsx("em",{children:c.match[1]},`i-${o++}`)):c.type==="code"?r.push(i.jsx("code",{style:gn(t),children:c.match[1]},`code-${o++}`)):c.type==="link"&&r.push(i.jsx("a",{href:c.match[2],target:"_blank",rel:"noopener noreferrer",style:{color:t.accent,textDecoration:"underline"},children:c.match[1]},`link-${o++}`)),n=n.slice(f+c.match[0].length)}return i.jsx(i.Fragment,{children:r})}function fn(e,t){return{color:e.textPrimary,fontSize:13,lineHeight:t?1.55:1.6}}function hn(e,t,r){return{color:e.textPrimary,fontSize:t?13:Math.max(13,15-r),fontWeight:800,lineHeight:1.35,marginTop:r<=2?2:0}}function Ne(e,t){return{color:e.textPrimary,fontSize:12.5,lineHeight:1.5,padding:t?"8px 9px":"9px 10px",border:`1px solid ${e.cellBorder}`,borderLeft:`3px solid ${e.accent}`,borderRadius:6,background:`${e.tableHeaderBg}55`}}function Ue(e,t){return{margin:0,paddingLeft:t?18:20,color:e.textPrimary,display:"grid",gap:t?4:5}}function Ve(e,t){return{color:e.textPrimary,fontSize:13,lineHeight:1.5,paddingLeft:2}}function pn(e){return{width:"100%",maxWidth:"100%",overflowX:"auto",border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.editorBg}}function xn(e,t){return{width:"100%",minWidth:t?360:420,borderCollapse:"collapse",color:e.textPrimary,fontSize:t?12:12.5,lineHeight:1.45}}function Je(e,t,r,n){return{padding:t?"6px 8px":"7px 9px",borderBottom:`1px solid ${e.cellBorder}`,color:r?e.textMuted:e.textPrimary,background:r?`${e.tableHeaderBg}75`:void 0,fontFamily:r?e.fontMono:e.font,fontSize:r?t?10.5:11:void 0,fontWeight:r?800:500,textAlign:n,whiteSpace:"nowrap",verticalAlign:"top"}}function gn(e){return{background:e.editorBg,border:`1px solid ${e.cellBorder}`,borderRadius:4,color:e.accent,fontFamily:e.fontMono,fontSize:"0.92em",padding:"1px 4px"}}function mn(e,t){return{margin:0,padding:t?9:10,overflow:"auto",maxHeight:t?220:280,borderRadius:6,background:e.editorBg,color:e.textPrimary,border:`1px solid ${e.cellBorder}`,fontSize:t?11.5:12,fontFamily:e.fontMono,lineHeight:1.5,whiteSpace:"pre"}}function yn({result:e,t,compact:r}){const n=(e.columns.length>0?e.columns:Object.keys(e.rows[0]??{})).slice(0,r?3:4),o=e.rows.slice(0,r?4:5);return n.length===0||o.length===0?null:i.jsxs("div",{style:{border:`1px solid ${t.cellBorder}`,borderRadius:8,overflow:"hidden",background:t.editorBg},children:[i.jsxs("div",{style:{display:"flex",justifyContent:"space-between",gap:10,padding:"7px 9px",borderBottom:`1px solid ${t.cellBorder}`,color:t.textMuted,fontSize:11,fontFamily:t.fontMono,textTransform:"uppercase",letterSpacing:"0.06em"},children:[i.jsx("span",{children:"Preview"}),i.jsxs("span",{children:[o.length," of ",(e.rowCount??e.rows.length).toLocaleString()," rows"]})]}),i.jsx("div",{style:{overflowX:"auto"},children:i.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",tableLayout:"fixed"},children:[i.jsx("thead",{children:i.jsx("tr",{children:n.map(s=>i.jsx("th",{style:{textAlign:"left",padding:"7px 9px",color:t.textMuted,fontSize:11,fontFamily:t.fontMono,borderBottom:`1px solid ${t.cellBorder}`,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:C(s)},s))})}),i.jsx("tbody",{children:o.map((s,a)=>i.jsx("tr",{children:n.map(d=>i.jsx("td",{style:{padding:"7px 9px",color:t.textPrimary,fontSize:r?12:12.5,borderBottom:a<o.length-1?`1px solid ${t.cellBorder}`:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Bn(d,s[d],o.map(u=>u[d]))},`${a}-${d}`))},a))})]})})]})}function bn({evidence:e,t}){const r=(e==null?void 0:e.lineage)??[];return r.length===0?i.jsx(lt,{t,children:"No lineage evidence was returned for this answer."}):i.jsx("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:10},children:r.map((n,o)=>i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"20px 1fr",gap:8},children:[i.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center"},children:[i.jsx("div",{style:{width:8,height:8,borderRadius:8,marginTop:5,background:n.role==="question"?t.accent:t.textMuted}}),o<r.length-1&&i.jsx("div",{style:{width:1,flex:1,minHeight:18,background:t.cellBorder}})]}),i.jsxs("div",{style:{minWidth:0},children:[i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:700,color:t.textPrimary},children:n.name??n.nodeId}),n.role&&i.jsx(z,{label:C(n.role),t}),n.kind&&i.jsx(z,{label:C(n.kind),t})]}),n.description&&i.jsx("div",{style:{fontSize:12,color:t.textSecondary,marginTop:3},children:n.description}),(n.sourcePath||n.provenance)&&i.jsxs("div",{style:{fontSize:11,color:t.textMuted,fontFamily:t.fontMono,marginTop:3,overflow:"hidden",textOverflow:"ellipsis"},children:[n.provenance??n.sourcePath,n.sourcePath&&n.provenance?` - ${n.sourcePath}`:""]})]})]},`${n.nodeId??n.name}-${o}`))})}function vn({evidence:e,t}){var o;const r=(e==null?void 0:e.businessContext)??[],n=e==null?void 0:e.outcome;return!n&&r.length===0?i.jsx(lt,{t,children:"No business context was returned for this answer."}):i.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:12},children:[n&&i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsx(N,{t,children:"Outcome"}),n.name&&i.jsx(v,{label:"Outcome",value:n.name,t}),n.owner&&i.jsx(v,{label:"Owner",value:n.owner,t}),n.decisionUse&&i.jsx(v,{label:"Decision Use",value:n.decisionUse,t}),n.reviewCadence&&i.jsx(v,{label:"Review Cadence",value:n.reviewCadence,t}),(o=n.caveats)==null?void 0:o.map((s,a)=>i.jsx(v,{label:"Caveat",value:s,t},`caveat-${a}`))]}),r.length>0&&i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsx(N,{t,children:"Context"}),r.map((s,a)=>i.jsx(v,{label:s.label??"Context",value:s.value??"",source:s.source,t},`${s.label}-${a}`))]}),(e==null?void 0:e.semanticObjects)&&e.semanticObjects.length>0&&i.jsx(Ge,{title:"Semantic Objects",assets:e.semanticObjects,t}),(e==null?void 0:e.sourceTables)&&e.sourceTables.length>0&&i.jsx(Ge,{title:"Source Tables",assets:e.sourceTables,t})]})}function jn({answer:e,t}){var s,a;const r=e.evidence,n=e.analysisPlan??(r==null?void 0:r.analysisPlan),o=(r==null?void 0:r.citations)??e.citations??[];return i.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:12},children:[i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsx(v,{label:"Certification",value:C(e.certification??e.kind),t}),I(e.cascade)&&i.jsx(v,{label:"Cascade",value:I(e.cascade)??"",t}),e.reviewStatus&&i.jsx(v,{label:"Review Status",value:C(e.reviewStatus),t}),typeof e.confidence=="number"&&i.jsx(v,{label:"Confidence",value:`${Math.round(e.confidence*100)}%`,t}),((s=r==null?void 0:r.validation)==null?void 0:s.message)&&i.jsx(v,{label:`Validation ${r.validation.status??""}`.trim(),value:r.validation.message,t}),((a=r==null?void 0:r.execution)==null?void 0:a.message)&&i.jsx(v,{label:`Execution ${r.execution.status??""}`.trim(),value:r.execution.message,t}),e.executionError&&i.jsx(v,{label:"Execution Error",value:e.executionError,t}),e.kind!=="certified"&&i.jsx(v,{label:"Promotion Path",value:"Create draft block, edit SQL, attach tests, then certify after analyst approval.",t})]}),n&&i.jsxs("div",{style:{display:"grid",gap:6},children:[i.jsx(N,{t,children:"Analysis Plan"}),n.question&&i.jsx(v,{label:"Question",value:n.question,t}),n.intent&&i.jsx(v,{label:"Intent",value:C(n.intent),t}),n.grain&&i.jsx(v,{label:"Grain",value:n.grain,t}),n.candidateTables&&n.candidateTables.length>0&&i.jsx(v,{label:"Tables",value:n.candidateTables.slice(0,5).map(d=>d.relation).filter(Boolean).join(", "),t}),n.candidateJoins&&n.candidateJoins.length>0&&i.jsx(v,{label:"Join Paths",value:n.candidateJoins.slice(0,3).map(at).join("; "),t}),n.assumptions&&n.assumptions.length>0&&i.jsx(v,{label:"Assumptions",value:n.assumptions.join(" "),t}),typeof n.repairAttempts=="number"&&n.repairAttempts>0&&i.jsx(v,{label:"SQL Repair",value:`${n.repairAttempts} retry`,t})]}),o.length>0&&i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx(N,{t,children:"Citations"}),o.slice(0,8).map((d,u)=>i.jsxs("div",{style:{fontSize:12,color:t.textSecondary,fontFamily:t.fontMono},children:[d.kind??"source",": ",d.name??"unknown",d.provenance&&i.jsxs("span",{style:{color:t.textMuted},children:[" (",d.provenance,")"]})]},`${d.kind}-${d.name}-${u}`))]})]})}function Ge({title:e,assets:t,t:r}){return i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[i.jsx(N,{t:r,children:e}),t.map((n,o)=>i.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2,paddingBottom:4},children:[i.jsxs("div",{style:{display:"flex",gap:6,alignItems:"center",flexWrap:"wrap"},children:[i.jsx("span",{style:{fontSize:12,fontWeight:700,color:r.textPrimary},children:n.name??n.nodeId}),n.kind&&i.jsx(z,{label:C(n.kind),t:r}),n.certification&&i.jsx(z,{label:C(n.certification),t:r})]}),n.description&&i.jsx("div",{style:{fontSize:12,color:r.textSecondary},children:n.description}),(n.sourcePath||n.owner||n.domain)&&i.jsx("div",{style:{fontSize:11,color:r.textMuted,fontFamily:r.fontMono},children:[n.domain,n.owner,n.sourcePath].filter(Boolean).join(" - ")})]},`${n.nodeId??n.name}-${o}`))]})}function Sn({artifact:e,t}){const r=[e.kind?{label:"Kind",value:C(e.kind)}:null,e.name?{label:"Name",value:e.name}:null,e.sourcePath?{label:"Source Path",value:e.sourcePath}:null,e.metrics.length>0?{label:"Metrics",value:e.metrics.join(", ")}:null,e.dimensions.length>0?{label:"Dimensions",value:e.dimensions.join(", ")}:null,e.timeDimension?{label:"Time",value:e.timeDimension}:null,e.filters.length>0?{label:"Filters",value:e.filters.join("; ")}:null].filter(n=>!!n);return i.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:10},children:[r.length>0&&i.jsx("div",{style:{display:"grid",gap:6},children:r.map(n=>i.jsx(v,{label:n.label,value:n.value,t},n.label))}),i.jsx("pre",{style:st(t,340),children:e.source})]})}function wn({sql:e,blockPath:t,executionError:r,t:n}){return i.jsxs("div",{style:{padding:12,display:"flex",flexDirection:"column",gap:8},children:[t&&i.jsxs("div",{style:{fontSize:12,color:n.textSecondary},children:["Source block: ",i.jsx("span",{style:{fontFamily:n.fontMono,color:n.textPrimary},children:t})]}),r&&i.jsx("div",{style:{padding:10,border:"1px solid rgba(248, 81, 73, 0.35)",borderRadius:6,background:"rgba(248, 81, 73, 0.10)",color:"#ff7b72",fontSize:12,lineHeight:1.45,whiteSpace:"pre-wrap"},children:r}),e?i.jsx("pre",{style:st(n,260),children:e}):i.jsx("div",{style:{fontSize:12,color:n.textMuted},children:"No SQL text was returned for this answer."})]})}function st(e,t){return{margin:0,padding:10,overflow:"auto",maxHeight:t,borderRadius:4,background:e.editorBg,color:e.textPrimary,border:`1px solid ${e.cellBorder}`,fontSize:12,fontFamily:e.fontMono,whiteSpace:"pre"}}function v({label:e,value:t,source:r,t:n}){return t?i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"130px 1fr",gap:10,fontSize:12,alignItems:"baseline"},children:[i.jsx("span",{style:{color:n.textMuted},children:e}),i.jsxs("span",{style:{color:n.textSecondary},children:[t,r&&i.jsxs("span",{style:{color:n.textMuted},children:[" (",r,")"]})]})]}):null}function N({children:e,t}){return i.jsx("div",{style:{fontSize:11,fontWeight:700,fontFamily:t.fontMono,color:t.textMuted,textTransform:"uppercase",letterSpacing:"0.08em"},children:e})}function lt({children:e,t}){return i.jsx("div",{style:{padding:12,fontSize:12,color:t.textMuted},children:e})}function z({label:e,t}){return i.jsx("span",{style:{fontSize:11,fontFamily:t.fontMono,color:t.textSecondary,padding:"2px 6px",borderRadius:4,background:t.editorBg,border:`1px solid ${t.cellBorder}`},children:e})}function kn({items:e,t,accent:r}){return e.length===0?null:i.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"6px 16px",alignItems:"center",padding:"7px 10px",borderTop:`1px solid ${t.cellBorder}`,boxShadow:`inset 0 2px 0 ${r}`,background:t.editorBg,color:t.textMuted,fontFamily:t.fontMono,fontSize:10.5},children:e.map(n=>i.jsxs("span",{style:{minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[i.jsx("span",{style:{color:t.textMuted},children:n.label})," ",i.jsx("strong",{style:{color:t.textSecondary,fontWeight:600},children:n.value})]},`${n.label}-${n.value}`))})}function Xe({active:e,label:t,onClick:r,t:n}){return i.jsx("button",{onClick:r,style:{padding:"4px 2px",fontSize:11.5,border:0,borderBottom:`2px solid ${e?n.accent:"transparent"}`,borderRadius:0,background:"transparent",color:e?n.accent:n.textSecondary,fontWeight:e?700:500,cursor:"pointer"},children:t})}function $n({result:e,chartConfig:t,t:r,onChange:n}){const o=e.columns;if(o.length===0)return null;const s=ce.filter(l=>l.value!=="table"),a=t!=null&&t.x&&o.includes(t.x)?t.x:o[0]??"",d=t!=null&&t.y&&o.includes(t.y)?t.y:o.find(l=>l!==a)??o[0]??"",u=t!=null&&t.color&&o.includes(t.color)?t.color:"";return i.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(130px, 1fr))",gap:8,alignItems:"end",border:`1px solid ${r.cellBorder}`,borderRadius:7,background:`${r.tableHeaderBg}55`,padding:10},children:[i.jsx(Y,{label:"Chart type",t:r,children:i.jsx("select",{value:(t==null?void 0:t.chart)??"bar",onChange:l=>n({chart:l.target.value}),style:K(r),children:s.map(l=>i.jsx("option",{value:l.value,children:l.label},l.value))})}),i.jsx(Y,{label:"X axis",t:r,children:i.jsx("select",{value:a,onChange:l=>n({x:l.target.value}),style:K(r),children:o.map(l=>i.jsx("option",{value:l,children:l},l))})}),i.jsx(Y,{label:"Y axis",t:r,children:i.jsx("select",{value:d,onChange:l=>n({y:l.target.value}),style:K(r),children:o.map(l=>i.jsx("option",{value:l,children:l},l))})}),i.jsx(Y,{label:"Color",t:r,children:i.jsxs("select",{value:u,onChange:l=>n({color:l.target.value||void 0}),style:K(r),children:[i.jsx("option",{value:"",children:"None"}),o.map(l=>i.jsx("option",{value:l,children:l},l))]})})]})}function Y({label:e,t,children:r}){return i.jsxs("label",{style:{display:"grid",gap:4,minWidth:0},children:[i.jsx("span",{style:{fontSize:10.5,color:t.textMuted,fontWeight:800,textTransform:"uppercase",letterSpacing:0},children:e}),r]})}function K(e){return{width:"100%",minWidth:0,height:30,border:`1px solid ${e.inputBorder}`,borderRadius:6,background:e.editorBg,color:e.textPrimary,fontFamily:e.font,fontSize:12,padding:"0 8px"}}function Cn({t:e,adding:t,hasResult:r,hasChart:n,fallbackLabel:o,open:s,onToggle:a,onAdd:d}){if(!r)return i.jsx("button",{type:"button",onClick:()=>d("auto"),disabled:t,style:{...Ye(e,t),marginLeft:"auto"},children:t?"Adding...":o});const u=n?[{mode:"both",label:"Chart + data",description:"Add chart and table tiles"},{mode:"chart",label:"Chart only",description:"Add the visualization tile"},{mode:"data",label:"Data table",description:"Add the rows as a table tile"}]:[{mode:"data",label:"Data table",description:"Add the rows as a table tile"}];return i.jsxs("div",{style:{marginLeft:"auto",position:"relative"},children:[i.jsxs("button",{type:"button",onClick:a,disabled:t,style:Ye(e,t),children:[t?"Adding...":"Add to App",!t&&i.jsx("span",{style:{marginLeft:6,fontSize:10},children:"v"})]}),s&&!t&&i.jsx("div",{style:{position:"absolute",right:0,top:"calc(100% + 6px)",zIndex:30,width:190,border:`1px solid ${e.cellBorder}`,borderRadius:8,background:e.cellBg,boxShadow:"0 14px 34px rgba(0, 0, 0, 0.18)",padding:6},children:u.map(l=>i.jsxs("button",{type:"button",onClick:()=>d(l.mode),style:{width:"100%",border:0,borderRadius:6,background:"transparent",color:e.textPrimary,textAlign:"left",padding:"8px 9px",cursor:"pointer"},children:[i.jsx("div",{style:{fontSize:12,fontWeight:700},children:l.label}),i.jsx("div",{style:{fontSize:11,color:e.textMuted,marginTop:2},children:l.description})]},l.mode))})]})}function Ye(e,t){return{border:`1px solid ${e.btnBorder}`,borderRadius:5,background:t?e.editorBg:`${e.accent}18`,color:t?e.textMuted:e.accent,padding:"4px 8px",fontSize:11,cursor:t?"default":"pointer"}}function C(e){return e.replace(/_/g," ")}function at(e){const t=[e.leftRelation,e.leftColumn].filter(Boolean).join("."),r=[e.rightRelation,e.rightColumn].filter(Boolean).join("."),n=[t,r].filter(Boolean).join(" to ");return e.reason?`${n} (${e.reason})`:n}function Bn(e,t,r){return t==null?"-":At(e,t,r)}function An(e){const t=e.toLowerCase();return t.includes("certified")?"trusted business context":t.includes("ai")||t.includes("generated")?"AI draft":t.includes("no_answer")?"needs more context":C(e)}function dt(e){var t;switch((t=e.trustLabelInfo)==null?void 0:t.id){case"certified":return"certified";case"reviewed":return"review";case"ai_generated":return"ai_generated";case"conflict":return"review";case"insufficient_context":return e.kind==="no_answer"?"no_answer":"uncertified"}return e.kind==="no_answer"?"no_answer":e.certification==="certified"||e.reviewStatus==="certified"?"certified":e.reviewStatus==="draft_ready"||e.reviewStatus==="analyst_review_required"?"review":e.certification==="ai_generated"?"ai_generated":e.certification==="analyst_review_required"||e.certification==="uncertified"?"uncertified":e.kind==="certified"?"certified":"draft"}function zn(e,t){return e==="certified"?t.success:e==="no_answer"?t.error:e==="deprecated"?t.textMuted:t.warning}function Ln(e,t,r,n){var u,l,p,c,f,h,x,b;const o=[],s=((l=(u=e.evidence)==null?void 0:u.selectedAssets)==null?void 0:l[0])??((c=(p=e.evidence)==null?void 0:p.lineage)==null?void 0:c.find(S=>S.owner||S.domain||S.sourcePath)),a=r??(s==null?void 0:s.name),d=n??(s==null?void 0:s.sourcePath)??(s==null?void 0:s.provenance);if(a&&o.push({label:e.kind==="certified"?"source":"draft source",value:a}),((s==null?void 0:s.owner)??((h=(f=e.evidence)==null?void 0:f.outcome)==null?void 0:h.owner))&&o.push({label:"owner",value:(s==null?void 0:s.owner)??((b=(x=e.evidence)==null?void 0:x.outcome)==null?void 0:b.owner)??""}),d&&o.push({label:"path",value:d}),e.sourceTier&&o.push({label:"tier",value:C(e.sourceTier)}),I(e.cascade)&&o.push({label:"cascade",value:I(e.cascade)??""}),t){const S=t.rowCount??t.rows.length,g=t.executionTime!==void 0?` - ${Math.round(t.executionTime)}ms`:"";o.push({label:"run",value:`${S.toLocaleString()} rows${g}`})}return e.reviewStatus&&e.reviewStatus!=="certified"&&o.push({label:"next",value:C(e.reviewStatus)}),_n(o).slice(0,5)}function I(e){if(!(e!=null&&e.terminalLane)&&!(e!=null&&e.routeTier))return;const t=Tn(e.terminalLane),r=Rn(e.routeTier);return[t,r].filter(Boolean).join(" · ")||void 0}function Tn(e){switch(e){case"certified":return"Lane 1 certified";case"semantic":return"Lane 2 semantic";case"generated":return"Lane 3 generated";case"refusal":return"Lane 4 refusal";default:return e?C(e):void 0}}function Rn(e){switch(e){case"certified_block":return"Certified block";case"semantic_metric":return"Semantic metric";case"generated_sql":return"Generated SQL";case"business_context":return"Business context";case"no_answer":return"No answer";default:return e?C(e):void 0}}function Mn(e,t){var r,n,o,s;return Q(e.sourceCertifiedBlock)??de((r=e.evidence)==null?void 0:r.selectedAssets)??de((n=e.evidence)==null?void 0:n.lineage)??de(e.citations)??Q((o=e.block)==null?void 0:o.name)??Q((s=e.result)==null?void 0:s.blockName)??Q(t)}function de(e){return e==null?void 0:e.map(t=>t.kind==="block"?Q(t.name):void 0).find(t=>!!t)}function Q(e){return typeof e!="string"?void 0:e.replace(/\s+/g," ").trim()||void 0}function _n(e){const t=new Set;return e.filter(r=>{const n=r.value.trim();if(!n)return!1;const o=`${r.label}:${n}`;return t.has(o)?!1:(t.add(o),!0)})}function Dn(e){return{x:0,y:e.layout.items.reduce((r,n)=>Math.max(r,n.y+n.h),0),w:6,h:3}}function In(e,t){const r=t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"tile",n=new Set(e.layout.items.map(o=>o.i));if(!n.has(r))return r;for(let o=2;o<1e3;o++){const s=`${r}-${o}`;if(!n.has(s))return s}return`${r}-${Date.now()}`}function Wn(e){const t=String(e??"table").toLowerCase().replace(/-/g,"_");return t==="single_value"||t==="kpi"||t==="line"||t==="bar"||t==="area"||t==="pie"||t==="donut"||t==="grouped_bar"||t==="stacked_bar"||t==="scatter"||t==="heatmap"||t==="histogram"||t==="waterfall"||t==="pivot"||t==="map"||t==="funnel"||t==="sankey"?t:"table"}const Hn=Object.freeze(Object.defineProperty({__proto__:null,AgentAnswerCard:Zt,StructuredAnswerText:ot,extractGovernedAnswer:Jt,formatCascadeOutcome:I,resolveAgentOutcome:it,resolveAnswerTrustState:dt,resolveDqlArtifactMeta:nt},Symbol.toStringTag,{value:"Module"}));export{Hn as A,Qn as R,ot as S,tt as d};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{c as g,j as i,S as j,L as w}from"./index-BTuliKhK.js";import{M as v}from"./minimize-2-CBIAE0XH.js";import{M as k}from"./maximize-2-Cojc6867.js";import{X as I}from"./x-CeNgQwGm.js";/**
|
|
2
|
-
* @license lucide-react v0.563.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const A=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M12 8v6",key:"1ib9pf"}],["path",{d:"M9 11h6",key:"1fldmi"}]],S=g("message-square-plus",A),p=420,W=720;function B({t:e,title:a,subtitle:s,children:l,onClose:o,expanded:n=!1,onToggleExpanded:c,onNewChat:x,headerActions:f,running:u=!1,compact:r=!1,floating:t=!1,dock:h="column",ariaLabel:m=a,className:y,style:b}){return i.jsxs("aside",{"aria-label":m,className:y,"data-ai-side-panel":"true","data-expanded":n?"true":"false",style:{minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",background:e.cellBg,...h==="overlay"&&!r?{position:"absolute",inset:"0 0 0 auto",zIndex:30,width:n?`min(${W}px, calc(100% - 40px))`:`min(${p}px, calc(100% - 40px))`,maxWidth:n?"72vw":"52vw",minWidth:Math.min(p,400),flex:"0 0 auto",boxShadow:"-16px 0 36px rgba(0,0,0,0.18)"}:{},...h==="overlay"&&r?{position:"relative",width:"100%",flex:"0 0 auto"}:{},borderLeft:r?"none":`1px solid ${e.headerBorder}`,border:t?`1px solid ${e.headerBorder}`:void 0,borderRadius:t?12:void 0,boxShadow:t?"0 18px 60px rgba(15, 23, 42, 0.22)":void 0,transition:"width 180ms ease, max-width 180ms ease",...b},children:[i.jsxs("div",{style:{minHeight:52,padding:"9px 12px",borderBottom:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",alignItems:"center",gap:10,flex:"0 0 auto"},children:[i.jsx("div",{"aria-hidden":"true",style:{width:30,height:30,borderRadius:8,background:`${e.accent}14`,border:`1px solid ${e.accent}36`,color:e.accent,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:i.jsx(j,{size:16,strokeWidth:2.1})}),i.jsxs("div",{style:{flex:1,minWidth:0},children:[i.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[i.jsx("span",{style:{fontSize:13,fontWeight:800,color:e.textPrimary,fontFamily:e.font},children:a}),u?i.jsx(w,{size:12,"aria-label":"AI is working",style:{color:e.accent,animation:"dql-agent-run-spin 0.8s linear infinite"}}):null]}),i.jsx("div",{title:s,style:{marginTop:2,color:e.textMuted,fontSize:11,fontFamily:e.font,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s})]}),f,x?i.jsx(d,{t:e,label:"New AI chat",onClick:x,children:i.jsx(S,{size:15,strokeWidth:2})}):null,!r&&c?i.jsx(d,{t:e,label:n?"Return AI panel to standard width":"Expand AI panel",onClick:c,children:n?i.jsx(v,{size:15,strokeWidth:2}):i.jsx(k,{size:15,strokeWidth:2})}):null,i.jsx(d,{t:e,label:`Close ${a}`,onClick:o,children:i.jsx(I,{size:15,strokeWidth:2})})]}),i.jsx("div",{style:{flex:1,minHeight:0,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:l})]})}function d({t:e,label:a,onClick:s,active:l=!1,children:o}){return i.jsx("button",{type:"button","aria-label":a,title:a,onClick:s,style:{width:30,height:30,borderRadius:7,border:`1px solid ${l?`${e.accent}66`:e.btnBorder}`,background:l?`${e.accent}14`:e.btnBg,color:l?e.accent:e.textSecondary,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto"},children:o})}export{B as A,S as M,W as a,p as b,d as c};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{c as ne,u as re,t as ie,r as f,a as R,j as o,m as oe,P as se,L as J,h as ae,T as de}from"./index-BTuliKhK.js";import{u as ce,f as le,c as ue}from"./answer-to-notebook-BDzY4MuQ.js";import{U as fe}from"./UnifiedAgentRunPanel-BlWAVEwO.js";import{S as G}from"./star-CO4tfaDq.js";import{P as pe}from"./pencil-Cb45c6WU.js";import"./react-CRB3T2We.js";import"./AgentAnswerCard-CpL2kDCV.js";import"./usePersistedAgentThreadId-CkVFrrjk.js";import"./TrustBadge-DGuHB8kP.js";import"./AiBuildResult-D9t_4sQl.js";import"./user-round-BfrV8U-W.js";import"./triangle-alert-BSdIu2El.js";import"./rotate-ccw-B9v1LTJ0.js";import"./x-CeNgQwGm.js";import"./list-tree-Ced8e_S1.js";import"./wrench-LMCrpa9_.js";import"./arrow-right-BI4cXgOY.js";import"./chevron-up-DSEILnDs.js";/**
|
|
2
|
-
* @license lucide-react v0.563.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const he=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],me=ne("message-square",he),H="dql-ask-domain-scope",K="dql-ask-domain-context";function Y(e){if(e)try{const t=JSON.parse(e);return typeof t.domain!="string"||!t.domain.trim()?void 0:{domain:t.domain.trim(),purpose:typeof t.purpose=="string"?t.purpose:void 0,modelAreaId:typeof t.modelAreaId=="string"?t.modelAreaId:void 0}}catch{return}}function ge(e,t){try{const s=Y(e.getItem(K));return e.removeItem(K),s?(t.setItem(H,JSON.stringify(s)),s):Y(t.getItem(H))}catch{return}}function xe(e,t){try{t||e.removeItem(H)}catch{}}function Ae(){if(!(typeof window>"u"))return ge(window.sessionStorage,window.localStorage)}function Ie(e){typeof window>"u"||xe(window.localStorage,e)}const B="dql-ask-conversations",Z="dql-ask-active-conversation",Q="dql-ask-deleted-thread-queue",N=100;function Se(e){return(e??"AI analysis").replace(/[^a-zA-Z0-9_ -]+/g," ").replace(/\s+/g,"_").replace(/^_+|_+$/g,"").slice(0,48)||"ai_analysis"}function ve(e){var S,p,a,d,w;const t=(p=(S=e.dqlArtifact)==null?void 0:S.source)==null?void 0:p.trim(),s=(a=e.sql)==null?void 0:a.trim(),n=t||s;if(!n)return;const u=oe(t?"dql":"sql",n);return u.name=Se(e.title??((d=e.dqlArtifact)==null?void 0:d.name)),e.result&&(u.result=e.result,u.status="success",u.executionCount=1),e.chartConfig&&(u.chartConfig=e.chartConfig),u.correctionProvenance=ue({question:e.question,generatedSql:e.sql??((w=e.dqlArtifact)==null?void 0:w.compiledSql),generatedDql:t,sourceRunId:e.sourceRunId}),e.dqlArtifact&&(u.dqlArtifact={source:e.dqlArtifact.source,sql:e.sql,name:e.dqlArtifact.name,sourcePath:e.dqlArtifact.sourcePath,kind:e.dqlArtifact.kind,metrics:e.dqlArtifact.metrics,dimensions:e.dqlArtifact.dimensions,parameters:e.dqlArtifact.parameters,parameterValues:e.dqlArtifact.parameterValues,persistence:e.dqlArtifact.persistence,trustState:e.dqlArtifact.trustState,compiledSql:e.dqlArtifact.compiledSql??e.sql,reviewState:e.dqlArtifact.trustState==="certified"?"certified":"review_required",...e.question?{question:e.question}:{}},u.dqlParameterValues=e.dqlArtifact.parameterValues),u}function L(){return`conv_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function ee(e){return`conv_server_${e}`}function we(e,t,s=new Set){const n=t.filter(a=>!s.has(a.id)),u=new Map(e.flatMap(a=>a.threadId?[[a.threadId,a]]:[])),S=n.map(a=>{var w;const d=u.get(a.id);return{id:(d==null?void 0:d.id)??ee(a.id),title:((w=a.title)==null?void 0:w.trim())||(d!=null&&d.title&&d.title!=="New chat"?d.title:"Recovered chat"),createdAt:(d==null?void 0:d.createdAt)??a.createdAt,updatedAt:a.updatedAt>((d==null?void 0:d.updatedAt)??"")?a.updatedAt:(d==null?void 0:d.updatedAt)??a.updatedAt,items:(d==null?void 0:d.items)??[],threadId:a.id,favorite:a.favorite??(d==null?void 0:d.favorite)??!1}}),p=new Set(n.map(a=>a.id));return[...S,...e.filter(a=>(!a.threadId||!p.has(a.threadId))&&(!a.threadId||!s.has(a.threadId)))].sort((a,d)=>d.updatedAt.localeCompare(a.updatedAt)).slice(0,N)}function b(){if(typeof window>"u")return new Set;try{const e=JSON.parse(window.localStorage.getItem(Q)??"[]");return new Set(Array.isArray(e)?e.filter(t=>typeof t=="string"):[])}catch{return new Set}}function te(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Q,JSON.stringify([...e].slice(-N)))}catch{}}function ke(e){const t=b();t.add(e),te(t)}function U(e){const t=b();t.delete(e),te(t)}function ye(e){return Array.isArray(e)?e.flatMap(t=>{if(!t||typeof t!="object")return[];const s=t;if(s.kind==="run"&&s.run&&typeof s.run=="object"){const n=s.run;n.nextActions=Array.isArray(n.nextActions)?n.nextActions:[],n.artifacts=Array.isArray(n.artifacts)?n.artifacts:[],n.evaluations=Array.isArray(n.evaluations)?n.evaluations:[],n.steps=Array.isArray(n.steps)?n.steps:[]}return[t]}):[]}function Ce(){if(typeof window>"u")return[];try{const e=window.localStorage.getItem(B);if(!e)return[];const t=JSON.parse(e);if(!Array.isArray(t))return[];const s=b();return t.filter(n=>!n.threadId||!s.has(n.threadId)).map(n=>({...n,items:ye(n.items)}))}catch{return[]}}function qe(){if(!(typeof window>"u"))try{return window.localStorage.getItem(Z)??void 0}catch{return}}function X(e){return e.map(t=>({...t,items:t.items.map(s=>s.kind==="run"?{...s,run:{...s.run,events:[]}}:s)}))}function C(e){const t=e.slice(0,N);if(typeof window>"u")return t;try{return window.localStorage.setItem(B,JSON.stringify(X(t))),t}catch{const s=t.slice(0,8);try{window.localStorage.setItem(B,JSON.stringify(X(s)))}catch{}return s}}function be(e){const t=e.find(n=>n.kind==="user"),s=t&&t.kind==="user"?t.text.trim():"";return s?s.length>48?`${s.slice(0,48).trimEnd()}…`:s:"New chat"}function je(e){const t=new Date(e).getTime();if(Number.isNaN(t))return"";const s=Date.now()-t,n=Math.floor(s/6e4);if(n<1)return"just now";if(n<60)return`${n}m`;const u=Math.floor(n/60);if(u<24)return`${u}h`;const S=Math.floor(u/24);return S<7?`${S}d`:new Date(e).toLocaleDateString()}function Ke(){var V;const{state:e,dispatch:t}=re(),s=ce(),n=ie[e.themeMode],[u,S]=f.useState(()=>Ae()),[p,a]=f.useState(()=>Ce()),[d,w]=f.useState(!0),j=f.useMemo(()=>p.length>0,[]),[h,y]=f.useState(()=>{const r=qe();return r&&p.some(i=>i.id===r)?r:L()}),[v,D]=f.useState(!1);f.useEffect(()=>{try{window.localStorage.setItem(Z,h)}catch{}},[h]),f.useEffect(()=>{for(const r of b())R.deleteAgentThread(r).then(()=>U(r)).catch(()=>{})},[]),f.useEffect(()=>{let r=!1;const i=b();return R.listAgentThreads({limit:N}).then(({threads:l})=>{if(r)return;const m=l.filter(x=>x.surface==="ask"||x.surface==="notebook"&&!x.notebookPath),g=new Set([...i,...b()]),k=m.filter(x=>!g.has(x.id));a(x=>C(we(x,k,g))),!j&&k[0]&&y(ee(k[0].id))}).catch(()=>{}).finally(()=>{r||w(!1)}),()=>{r=!0}},[j]);const T=f.useMemo(()=>{var r;return((r=p.find(i=>i.id===h))==null?void 0:r.items)??[]},[p,h]),E=f.useMemo(()=>{var r;return(r=p.find(i=>i.id===h))==null?void 0:r.threadId},[p,h]),_=f.useCallback(r=>{r.length!==0&&a(i=>{const l=i.find(x=>x.id===h);if(l&&l.items.length>=r.length)return i;const m=new Date().toISOString(),k=[{id:h,title:be(r),createdAt:(l==null?void 0:l.createdAt)??m,updatedAt:m,items:r,threadId:l==null?void 0:l.threadId},...i.filter(x=>x.id!==h)].slice(0,N);return C(k)})},[h]),$=f.useCallback(r=>{a(i=>{const l=i.find(g=>g.id===h),m=new Date().toISOString();return C(l?i.map(g=>g.id===h?{...g,threadId:r}:g):[{id:h,title:"New chat",createdAt:m,updatedAt:m,items:[],threadId:r},...i])})},[h]),O=f.useCallback((r,i)=>{var g;const l=i.trim();if(!l)return;a(k=>C(k.map(x=>x.id===r?{...x,title:l}:x)));const m=(g=p.find(k=>k.id===r))==null?void 0:g.threadId;m&&R.updateAgentThread(m,{title:l}).catch(()=>{})},[p]),M=f.useCallback(r=>{const i=p.find(m=>m.id===r),l=!(i!=null&&i.favorite);a(m=>C(m.map(g=>g.id===r?{...g,favorite:l}:g))),i!=null&&i.threadId&&R.updateAgentThread(i.threadId,{favorite:l}).catch(()=>{})},[p]),P=f.useCallback(()=>{v||y(L())},[v]),c=f.useCallback(r=>{v||y(r)},[v]),A=f.useCallback(r=>{var l;if(v)return;const i=(l=p.find(m=>m.id===r))==null?void 0:l.threadId;i&&(ke(i),R.deleteAgentThread(i).then(()=>U(i)).catch(()=>{})),a(m=>C(m.filter(g=>g.id!==r))),r===h&&y(L())},[h,p,v]),q=(r,i)=>{t({type:"OPEN_APP",appId:r,dashboardId:i})},z=(r,i)=>{t({type:"OPEN_GLOBAL_AI",audience:"stakeholder",context:{title:"Research",scopeHint:"Follow up on this research",selectedObject:{kind:"research",id:r,path:i}}})},I=f.useCallback(r=>{if(!e.activeFile||e.activeFile.type==="block"){s(r);return}const i=ve(r);i&&(t({type:"ADD_CELL",cell:i}),t({type:"SET_MAIN_VIEW",view:"notebook"}),le(i.id))},[t,s,e.activeFile]);return o.jsxs("div",{style:{flex:1,minWidth:0,display:"flex",overflow:"hidden",background:n.appBg},children:[o.jsx(De,{t:n,conversations:p,activeId:h,busy:v,loading:d,onNewChat:P,onSelect:c,onDelete:A,onRename:O,onToggleFavorite:M}),o.jsx("div",{style:{flex:1,minWidth:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:o.jsx(fe,{themeMode:e.themeMode,title:"Ask your data",askLayout:!0,scopeHint:u?`Scoped to ${u.domain}${u.modelAreaId?` · ${(V=u.modelAreaId.split("::").at(-1))==null?void 0:V.replace(/_/g," ")}`:""}${u.purpose?` for ${u.purpose}`:""}`:"Ask a question or request deep research",onClearScope:u?()=>{S(void 0),Ie(void 0)}:void 0,workspaceContext:u,audience:"stakeholder",initialMode:"auto",initialItems:T,onItemsChange:_,threadId:E,onThreadIdChange:$,onRunningChange:D,onOpenResearch:z,onOpenApp:q,onInsertSql:(r,i,l)=>I({sql:r,title:i,question:l==null?void 0:l.question,sourceRunId:l==null?void 0:l.sourceRunId}),onInsertDql:I,insertDqlActionLabel:"Open in notebook"},h)})]})}function De({t:e,conversations:t,activeId:s,busy:n,loading:u,onNewChat:S,onSelect:p,onDelete:a,onRename:d,onToggleFavorite:w}){const j=n?"Finish the current question first":void 0,[h,y]=f.useState(null),[v,D]=f.useState(null),[T,E]=f.useState(""),_=t.filter(c=>c.favorite),$=t.filter(c=>!c.favorite),O=c=>{D(c.id),E(c.title)},M=()=>{v&&T.trim()&&d(v,T),D(null)},P=c=>{const A=c.id===s,q=h===c.id,z=v===c.id;return o.jsxs("div",{onMouseEnter:()=>y(c.id),onMouseLeave:()=>y(I=>I===c.id?null:I),style:{position:"relative",display:"flex",alignItems:"center"},children:[z?o.jsx("input",{autoFocus:!0,value:T,onChange:I=>E(I.target.value),onBlur:M,onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),M()),I.key==="Escape"&&(I.preventDefault(),D(null))},"aria-label":"Conversation name",style:{flex:1,minWidth:0,padding:"7px 10px",borderRadius:7,border:`1px solid ${e.accent}`,background:e.appBg,color:e.textPrimary,fontSize:12.5,fontWeight:600}}):o.jsxs("button",{type:"button",onClick:()=>p(c.id),onDoubleClick:()=>O(c),disabled:n&&!A,title:n&&!A?j:`${c.title} — double-click to rename`,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:8,padding:"8px 10px",borderRadius:7,border:"none",background:A?`${e.accent}1f`:q?`${e.textPrimary}0d`:"transparent",color:A?e.accent:e.textSecondary,cursor:n&&!A?"not-allowed":"pointer",opacity:n&&!A?.5:1,textAlign:"left",fontSize:12.5,fontWeight:A?600:500,paddingRight:q?56:10},children:[A&&n?o.jsx(J,{size:13,style:{flexShrink:0,color:e.accent,animation:"dql-agent-run-spin 0.8s linear infinite"}}):c.favorite?o.jsx(G,{size:13,style:{flexShrink:0,color:e.accent},fill:"currentColor"}):o.jsx(me,{size:13,style:{flexShrink:0,opacity:.7}}),o.jsx("span",{style:{flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A&&n?"Working…":c.title}),q?null:o.jsx("span",{style:{flexShrink:0,fontSize:10,color:A&&n?e.accent:e.textMuted,fontWeight:A&&n?650:400},children:A&&n?"Live":je(c.updatedAt)})]}),q&&!z?o.jsxs("div",{style:{position:"absolute",right:4,display:"inline-flex",gap:2},children:[o.jsx(W,{t:e,label:c.favorite?"Unpin conversation":"Pin conversation",onClick:()=>w(c.id),children:o.jsx(G,{size:12,fill:c.favorite?"currentColor":"none"})}),o.jsx(W,{t:e,label:"Rename conversation",onClick:()=>O(c),children:o.jsx(pe,{size:12})}),o.jsx(W,{t:e,label:"Delete conversation",onClick:()=>a(c.id),children:o.jsx(de,{size:12})})]}):null]},c.id)};return o.jsxs("aside",{style:{width:248,flexShrink:0,borderRight:`1px solid ${e.headerBorder}`,background:e.cellBg,display:"flex",flexDirection:"column",minHeight:0},children:[o.jsx("div",{style:{padding:12},children:o.jsxs("button",{type:"button",onClick:S,disabled:n,title:j,style:{width:"100%",display:"inline-flex",alignItems:"center",gap:8,justifyContent:"center",padding:"9px 12px",borderRadius:8,border:`1px solid ${e.accent}`,background:e.accent,color:"var(--accent-on, #fff)",fontSize:13,fontWeight:650,cursor:n?"not-allowed":"pointer",opacity:n?.55:1},children:[o.jsx(se,{size:15,strokeWidth:2.4})," New chat"]})}),o.jsx("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"0 8px 12px",display:"flex",flexDirection:"column",gap:2},children:u&&t.length===0?o.jsxs("div",{style:{padding:"10px 8px",display:"flex",alignItems:"center",gap:7,fontSize:11.5,color:e.textMuted},children:[o.jsx(J,{size:13,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}),"Restoring project chats…"]}):t.length===0?o.jsx("div",{style:{padding:"10px 8px",fontSize:11.5,color:e.textMuted,lineHeight:1.5},children:"No past chats yet. Your conversations show up here so you can pick up where you left off."}):o.jsxs(o.Fragment,{children:[_.length>0?o.jsxs(o.Fragment,{children:[o.jsx(F,{t:e,children:"Favourites"}),_.map(c=>P(c)),o.jsx(F,{t:e,children:"Recent"})]}):o.jsx(F,{t:e,children:"Recent"}),$.map(c=>P(c))]})}),o.jsxs("div",{style:{padding:"10px 12px",borderTop:`1px solid ${e.headerBorder}`,display:"flex",alignItems:"center",gap:7,fontSize:11,color:e.textMuted},children:[o.jsx(ae,{size:12,style:{flexShrink:0,color:e.success}}),o.jsx("span",{children:"Private project history · not committed to Git"})]})]})}function F({t:e,children:t}){return o.jsx("div",{style:{padding:"8px 8px 4px",fontSize:10,fontWeight:700,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted},children:t})}function W({t:e,label:t,onClick:s,children:n}){return o.jsx("button",{type:"button","aria-label":t,title:t,onClick:u=>{u.stopPropagation(),s()},style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,borderRadius:5,border:"none",background:e.cellBg,color:e.textMuted,cursor:"pointer"},children:n})}export{Ke as AnalyticsHome,ve as askNotebookCellFromPayload,we as mergePersistedAskConversations};
|