@duckcodeailabs/dql-cli 1.14.2 → 1.14.3-rc.1
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/args.d.ts +4 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +16 -0
- package/dist/args.js.map +1 -1
- package/dist/assets/dql-notebook/assets/{AgentLogPage-DKbGpRQS.js → AgentLogPage-Jbyb4so-.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildDialog-DPSu0Mly.js → AiBuildDialog-Du07X1qO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiBuildResult-1uaGnpi1.js → AiBuildResult-xKtGthWv.js} +1 -1
- package/dist/assets/dql-notebook/assets/{AiSidePanel-BwMREwa7.js → AiSidePanel-CE_L04dK.js} +1 -1
- package/dist/assets/dql-notebook/assets/AnalyticsHome-CiUE10uF.js +6 -0
- package/dist/assets/dql-notebook/assets/{AppsView-CM1tPywy.js → AppsView-DlNaTuwD.js} +30 -35
- package/dist/assets/dql-notebook/assets/AskObservabilityPage-DracZPI9.js +1 -0
- package/dist/assets/dql-notebook/assets/AskTracePage-CSMoMw9a.js +8 -0
- package/dist/assets/dql-notebook/assets/{BlockStudio--S6WFVO4.js → BlockStudio-DQS5Hcq9.js} +9 -14
- package/dist/assets/dql-notebook/assets/BusinessArtifactView-CqV4i9l_.js +1 -0
- package/dist/assets/dql-notebook/assets/{DbtFirstModelingPage-CNyU5MBX.js → DbtFirstModelingPage-JKhB_Y2H.js} +3 -3
- package/dist/assets/dql-notebook/assets/{GitPage-IcydAai3.js → GitPage-DjaNp0o3.js} +1 -1
- package/dist/assets/dql-notebook/assets/{GlobalAiRail-CSKW-5eD.js → GlobalAiRail-CsV3zlc8.js} +1 -1
- package/dist/assets/dql-notebook/assets/{GovernedContextPage-CFen0eFT.js → GovernedContextPage-uXUHUOIJ.js} +3 -3
- package/dist/assets/dql-notebook/assets/{HelpDocsPage-D0D9UCIz.js → HelpDocsPage-Hbh9IeYB.js} +1 -1
- package/dist/assets/dql-notebook/assets/{HomePage-CmSxapR3.js → HomePage-CRRl-R_v.js} +1 -1
- package/dist/assets/dql-notebook/assets/LineageDAG-OMUP2sbl.js +1 -0
- package/dist/assets/dql-notebook/assets/LineageDetailView-C964BLuV.js +1 -0
- package/dist/assets/dql-notebook/assets/LineageDrawer-CzY0nfpD.js +1 -0
- package/dist/assets/dql-notebook/assets/{LineagePathBreadcrumb-CTZJp4_r.js → LineagePathBreadcrumb-0Gi-Fm1B.js} +1 -1
- package/dist/assets/dql-notebook/assets/MiniLineageGraph-wn0wLc9m.js +1 -0
- package/dist/assets/dql-notebook/assets/{NewBlockModal-DMBFB7nE.js → NewBlockModal-kMAzk91d.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NewNotebookModal-DsC9CWlW.js → NewNotebookModal-D_cWd_6M.js} +1 -1
- package/dist/assets/dql-notebook/assets/{NotebookEditor-hs-kw8v9.js → NotebookEditor-Bax0lxaz.js} +25 -30
- package/dist/assets/dql-notebook/assets/{ReadinessPage-DJ83cMik.js → ReadinessPage-DEUIXQQY.js} +1 -1
- package/dist/assets/dql-notebook/assets/{SetupOnboarding-B1Pu_Bvv.js → SetupOnboarding-CyE-Ex41.js} +1 -1
- package/dist/assets/dql-notebook/assets/{SkillsPage-BHKDay8n.js → SkillsPage-QgvKGPxE.js} +1 -1
- package/dist/assets/dql-notebook/assets/{TrustBadge-BkyGgob2.js → TrustBadge-D5CGp0cu.js} +1 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BjsTE6yf.js +89 -0
- package/dist/assets/dql-notebook/assets/{answer-to-notebook-DmNiuLQA.js → answer-to-notebook-tACdCsTV.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-left--1rsrxm8.js → arrow-left-CF6wxXU5.js} +1 -1
- package/dist/assets/dql-notebook/assets/{arrow-right-D5TdqY1G.js → arrow-right-C7G3M_S8.js} +1 -1
- package/dist/assets/dql-notebook/assets/{book-open-text-Bw7nHbzg.js → book-open-text-DDBO8G7L.js} +1 -1
- package/dist/assets/dql-notebook/assets/chevron-left-DxajrX2v.js +6 -0
- package/dist/assets/dql-notebook/assets/{circle-x-DLe6NNM4.js → circle-x-HBvXjnT6.js} +1 -1
- package/dist/assets/dql-notebook/assets/clock-3-CJIdsPLt.js +6 -0
- package/dist/assets/dql-notebook/assets/dagre.esm-B6nvU4OB.js +1 -0
- package/dist/assets/dql-notebook/assets/{external-link-C9Q97sA3.js → external-link-WciAU8Bu.js} +1 -1
- package/dist/assets/dql-notebook/assets/{grip-vertical-CztvkIgo.js → grip-vertical-DVu7ok6x.js} +1 -1
- package/dist/assets/dql-notebook/assets/index-B_kaoARS.css +1 -0
- package/dist/assets/dql-notebook/assets/{index-zHHzDn6l.js → index-D3wnucQC.js} +133 -128
- package/dist/assets/dql-notebook/assets/{link-2-CiKAvumL.js → link-2-C6uQx50X.js} +1 -1
- package/dist/assets/dql-notebook/assets/{list-tree-BtnP2nQ5.js → list-tree-DapsIuQB.js} +1 -1
- package/dist/assets/dql-notebook/assets/{minimize-2-TSFGxcCP.js → minimize-2-BlVoipnT.js} +1 -1
- package/dist/assets/dql-notebook/assets/{panel-right-open-BfXIUWy0.js → panel-right-open-DcnKWxfx.js} +1 -1
- package/dist/assets/dql-notebook/assets/{play-DVbSFJHD.js → play-CNuRuaAs.js} +1 -1
- package/dist/assets/dql-notebook/assets/{rotate-ccw-D_cesDcX.js → rotate-ccw-B2p953Zh.js} +1 -1
- package/dist/assets/dql-notebook/assets/{semantic-fields-CoVStdYB.js → semantic-fields-2fWgkTJc.js} +1 -1
- package/dist/assets/dql-notebook/assets/{sliders-horizontal-l7xV9K5A.js → sliders-horizontal-DwRTu1w4.js} +1 -1
- package/dist/assets/dql-notebook/assets/{star-CSBS0H3b.js → star-Cbaj4F3i.js} +1 -1
- package/dist/assets/dql-notebook/assets/style-NlN9F6JE.js +23 -0
- package/dist/assets/dql-notebook/assets/{triangle-alert-BTrnyY4q.js → triangle-alert-BPHvH1wA.js} +1 -1
- package/dist/assets/dql-notebook/assets/{upload-sySLq9zb.js → upload-DIqK0KE1.js} +1 -1
- package/dist/assets/dql-notebook/assets/{usePersistedAgentThreadId-CzwgGdus.js → usePersistedAgentThreadId-DpQXOEDw.js} +1 -1
- package/dist/assets/dql-notebook/assets/{user-round-ChlgXi9j.js → user-round-DukNupB_.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wand-sparkles-CGw0ytyT.js → wand-sparkles-CAwLX0b9.js} +1 -1
- package/dist/assets/dql-notebook/assets/{workflow-C_RltiK5.js → workflow-bOT-NqdO.js} +1 -1
- package/dist/assets/dql-notebook/assets/{wrench-D-wLfeu0.js → wrench-1m0_kcza.js} +1 -1
- package/dist/assets/dql-notebook/assets/{x-B28hIJIC.js → x-fp82BETM.js} +1 -1
- package/dist/assets/dql-notebook/index.html +2 -2
- package/dist/commands/agent-eval-runtime.d.ts +9 -0
- package/dist/commands/agent-eval-runtime.d.ts.map +1 -1
- package/dist/commands/agent-eval-runtime.js +7 -0
- package/dist/commands/agent-eval-runtime.js.map +1 -1
- package/dist/commands/agent-trace.d.ts +3 -0
- package/dist/commands/agent-trace.d.ts.map +1 -0
- package/dist/commands/agent-trace.js +169 -0
- package/dist/commands/agent-trace.js.map +1 -0
- package/dist/commands/agent.d.ts +28 -2
- package/dist/commands/agent.d.ts.map +1 -1
- package/dist/commands/agent.js +408 -35
- package/dist/commands/agent.js.map +1 -1
- package/dist/commands/notebook.d.ts +2 -0
- package/dist/commands/notebook.d.ts.map +1 -1
- package/dist/commands/notebook.js +4 -0
- package/dist/commands/notebook.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts +1 -1
- package/dist/llm/providers/dql-agent-provider.d.ts.map +1 -1
- package/dist/llm/providers/dql-agent-provider.js +759 -145
- package/dist/llm/providers/dql-agent-provider.js.map +1 -1
- package/dist/llm/types.d.ts +21 -2
- package/dist/llm/types.d.ts.map +1 -1
- package/dist/local-runtime.d.ts +256 -33
- package/dist/local-runtime.d.ts.map +1 -1
- package/dist/local-runtime.js +2844 -490
- package/dist/local-runtime.js.map +1 -1
- package/dist/package.json +10 -10
- package/dist/providers/oauth/claude-oauth.d.ts.map +1 -1
- package/dist/providers/oauth/claude-oauth.js +52 -18
- package/dist/providers/oauth/claude-oauth.js.map +1 -1
- package/dist/providers/oauth/codex-oauth.d.ts.map +1 -1
- package/dist/providers/oauth/codex-oauth.js +72 -44
- package/dist/providers/oauth/codex-oauth.js.map +1 -1
- package/dist/providers/subscription-cli.d.ts +20 -0
- package/dist/providers/subscription-cli.d.ts.map +1 -1
- package/dist/providers/subscription-cli.js +69 -11
- package/dist/providers/subscription-cli.js.map +1 -1
- package/package.json +10 -10
- package/dist/assets/dql-notebook/assets/AnalyticsHome-BGfey_ve.js +0 -6
- package/dist/assets/dql-notebook/assets/BusinessArtifactView-BEAJ-yNW.js +0 -1
- package/dist/assets/dql-notebook/assets/LineageDAG-BGUcIt1B.js +0 -1
- package/dist/assets/dql-notebook/assets/LineageDetailView-Dx48Zfzb.js +0 -1
- package/dist/assets/dql-notebook/assets/LineageDrawer-zaBfSLZO.js +0 -1
- package/dist/assets/dql-notebook/assets/MiniLineageGraph-CdivNR1S.js +0 -1
- package/dist/assets/dql-notebook/assets/UnifiedAgentRunPanel-BYdrTaEW.js +0 -89
- package/dist/assets/dql-notebook/assets/dagre.esm-CW5QZdBt.js +0 -23
- package/dist/assets/dql-notebook/assets/index-B3shyZsg.css +0 -1
- /package/dist/assets/dql-notebook/assets/{dagre-BZV40eAE.css → style-BZV40eAE.css} +0 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import{c as ze,r as x,a as oe,j as t,d as Gt,g as vt,l as we,b9 as Ii,f as jt,L as Ge,aK as qi,bb as Rr,B as kt,e as Cr,u as Ut,t as Ar,a5 as _i,bc as Ke,E as zi,H as Ti,bd as $i,w as Mi,S as Ue,aH as Ir,b as Kt,aL as He,P as yt,D as Bi,G as Yt,be as Ei,bf as Li,b1 as pn,a0 as rn,ar as Ni}from"./index-D3wnucQC.js";import{S as Pt,F as Ye,P as Di,E as Pi,M as Fi,R as wn,d as kn,e as Wi,A as Oi,g as Hi,u as Qi}from"./usePersistedAgentThreadId-DpQXOEDw.js";import{C as Vi}from"./AiBuildResult-xKtGthWv.js";import{T as sn}from"./triangle-alert-BPHvH1wA.js";import{U as Gi}from"./user-round-DukNupB_.js";import{X as Ft}from"./x-fp82BETM.js";import{L as St}from"./list-tree-DapsIuQB.js";import{W as Xt}from"./wrench-1m0_kcza.js";import{M as Ui}from"./minimize-2-BlVoipnT.js";import{A as Ki}from"./arrow-right-C7G3M_S8.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 Yi=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],Xi=ze("archive",Yi);/**
|
|
7
|
+
* @license lucide-react v0.563.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const Ji=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],qr=ze("chevron-up",Ji);/**
|
|
12
|
+
* @license lucide-react v0.563.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const Zi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],es=ze("circle",Zi);/**
|
|
17
|
+
* @license lucide-react v0.563.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const ts=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],_r=ze("copy",ts);/**
|
|
22
|
+
* @license lucide-react v0.563.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const ns=[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]],Wt=ze("lightbulb",ns);/**
|
|
27
|
+
* @license lucide-react v0.563.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const rs=[["circle",{cx:"6",cy:"19",r:"3",key:"1kj8tv"}],["path",{d:"M9 19h8.5a3.5 3.5 0 0 0 0-7h-11a3.5 3.5 0 0 1 0-7H15",key:"1d8sl"}],["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}]],mt=ze("route",rs);/**
|
|
32
|
+
* @license lucide-react v0.563.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const is=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Rn=ze("save",is);/**
|
|
37
|
+
* @license lucide-react v0.563.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const ss=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],os=ze("send",ss);/**
|
|
42
|
+
* @license lucide-react v0.563.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const as=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Gn=ze("square",as);/**
|
|
47
|
+
* @license lucide-react v0.563.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const ls=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],cs=ze("zap",ls),on=[{mode:"auto",label:"Auto",hint:"Adapts per question — fast for lookups, thorough for hard ones"},{mode:"low",label:"Low · fast",hint:"Fewer thinking tokens, skips extra verification"},{mode:"medium",label:"Medium · balanced",hint:"More thinking, still skips the heavy verification"},{mode:"high",label:"High · thorough",hint:"Most thinking, cross-checks the number — slower"}];function Un({t:e,value:n,onChange:r}){const[i,s]=x.useState(null),[o,l]=x.useState(!1),c=x.useRef(null);x.useEffect(()=>{let f=!1;return oe.getProviderSettings().then(({providers:a})=>{f||s(a.find(d=>d.active)??null)}).catch(()=>{}),()=>{f=!0}},[]),x.useEffect(()=>{if(!o)return;const f=a=>{c.current&&!c.current.contains(a.target)&&l(!1)};return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[o]);const u=on.find(f=>f.mode===n)??on[0],p=i?[i.label,i.model].filter(Boolean).join(" · "):null;return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[p?t.jsxs("span",{title:"Connected model",style:Kn(e),children:[t.jsx(es,{size:7,fill:e.success,color:e.success}),t.jsx("span",{style:{color:e.textSecondary},children:p})]}):null,t.jsxs("div",{ref:c,style:{position:"relative"},children:[t.jsxs("button",{type:"button",onClick:()=>l(f=>!f),title:"How hard the model thinks for this thread",style:{...Kn(e),cursor:"pointer"},children:[t.jsx(cs,{size:12,color:e.textMuted}),t.jsxs("span",{style:{color:e.textSecondary},children:["Thinking: ",u.label]}),t.jsx(Gt,{size:12,color:e.textMuted})]}),o?t.jsx("div",{role:"menu",style:ds(e),children:on.map(f=>{const a=f.mode===n;return t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":a,onClick:()=>{r(f.mode),l(!1)},style:us(e,a),children:[t.jsxs("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[t.jsx("span",{style:{fontWeight:a?600:500,color:e.textPrimary},children:f.label}),a?t.jsx(vt,{size:13,color:e.accent}):null]}),t.jsx("span",{style:{display:"block",fontSize:11,color:e.textMuted,marginTop:2},children:f.hint})]},f.mode)})}):null]})]})}function Kn(e){return{display:"inline-flex",alignItems:"center",gap:6,padding:"4px 9px",borderRadius:8,border:`1px solid ${e.btnBorder}`,background:e.btnBg,fontSize:12,lineHeight:1.2,whiteSpace:"nowrap"}}function ds(e){return{position:"absolute",bottom:"calc(100% + 6px)",left:0,zIndex:30,width:264,background:e.cellBg,border:`1px solid ${e.cellBorder}`,borderRadius:10,padding:4,boxShadow:"0 8px 24px rgba(0,0,0,0.18)"}}function us(e,n){return{display:"block",width:"100%",textAlign:"left",padding:"8px 10px",borderRadius:7,border:"none",background:n?e.pillBg:"transparent",cursor:"pointer"}}const ps={draft:"#8b949e",review:"#d29922",certified:"#3fb950",deprecated:"#f85149",pending_recertification:"#db6d28"},fs={queued:"#8b949e",generating:"#4c8dff",running:"#4c8dff",saving:"#4c8dff",saved:"#2ea043",ready:"#2ea043",blocked:"#f85149",needs_attention:"#d29922"},gs={queued:"Queued",generating:"Generating",running:"Running",saving:"Saving",saved:"Saved",ready:"Ready",blocked:"Blocked",needs_attention:"Needs review",draft:"Draft",review:"In review",certified:"Certified",deprecated:"Deprecated",pending_recertification:"Recertify"},hs={draft:Rr,queued:qi,generating:Ge,running:Ge,saving:Ge,ready:jt,saved:jt,blocked:sn,needs_attention:sn,review:Ii,certified:we,deprecated:Xi,pending_recertification:sn},xs=new Set(["generating","running","saving"]);function ys(e){return ps[e]??fs[e]??"#8b949e"}function ms(e){return gs[e]??e.charAt(0).toUpperCase()+e.slice(1).replace(/_/g," ")}function bs({status:e,t:n,label:r}){const i=ys(e),s=hs[e]??Rr,o=r??ms(e);return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:10,fontWeight:800,color:i,background:`${i}18`,border:`1px solid ${i}33`,borderRadius:999,padding:"2px 8px",fontFamily:n.font,textTransform:"uppercase",letterSpacing:"0.03em",whiteSpace:"nowrap"},children:[t.jsx(s,{size:11,strokeWidth:2.2,className:xs.has(e)?"spin":void 0}),o]})}function vs(e){const{t:n,name:r,status:i="draft",description:s,dql:o,sqlPreview:l,grain:c,outputs:u=[],dimensions:p=[],entities:f=[],examples:a=[],sourceTables:d=[],evidence:g=[],certifierVerdict:h,owner:m,actions:b}=e,[k,W]=x.useState(!1),[L,N]=x.useState(!1);return t.jsxs("section",{style:{border:`1px solid ${n.cellBorder}`,borderRadius:10,background:n.cellBg,padding:14,display:"grid",gap:10,fontFamily:n.font},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsx(kt,{size:14,strokeWidth:2,color:n.accent}),t.jsx("div",{style:{fontSize:13,fontWeight:850,color:n.textPrimary,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}),t.jsx(bs,{status:i,t:n}),c?t.jsxs("span",{style:fn(n),children:["grain ",c]}):null]}),s?t.jsx("div",{style:{fontSize:12,color:n.textSecondary,lineHeight:1.5},children:s}):null,o?t.jsx(Yn,{open:k,onToggle:()=>W($=>!$),label:"Governed DQL",t:n,lead:!0,children:t.jsx("pre",{style:Xn(n),children:o})}):null,l?t.jsx(Yn,{open:L,onToggle:()=>N($=>!$),label:o?"Compiled SQL preview":"SQL this block will run",t:n,children:t.jsx("pre",{style:Xn(n),children:l})}):null,t.jsx(an,{label:"Outputs",items:u,t:n}),t.jsx(an,{label:"Dimensions",items:p,t:n}),t.jsx(an,{label:"Entities",items:f,t:n}),a.length>0?t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(zr,{t:n,children:"Answers questions like"}),t.jsx("ul",{style:{margin:0,padding:"0 0 0 16px",display:"grid",gap:3},children:a.slice(0,3).map($=>t.jsx("li",{style:{fontSize:11.5,color:n.textSecondary,lineHeight:1.45},children:$},$))})]}):null,d.length>0||g.length>0?t.jsxs("div",{style:{display:"grid",gap:6,border:`1px solid ${n.headerBorder}`,borderRadius:8,background:n.appBg,padding:10},children:[t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10.5,fontWeight:800,color:n.textSecondary,textTransform:"uppercase"},children:[t.jsx(we,{size:12,color:n.accent})," Grounded on"]}),d.length>0?t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:d.map($=>t.jsx("span",{style:fn(n),children:$},$))}):null,g.slice(0,5).map(($,V)=>t.jsxs("div",{style:{border:`1px solid ${n.headerBorder}`,borderRadius:7,padding:8,background:n.cellBg},children:[t.jsx("div",{style:{fontSize:11,fontWeight:800,color:n.textSecondary,overflowWrap:"anywhere"},children:$.name}),t.jsxs("div",{style:{fontSize:10,color:n.textMuted,marginTop:3},children:[$.kind,$.reason?` · ${$.reason}`:""]}),$.description?t.jsx("div",{style:{fontSize:11,color:n.textMuted,lineHeight:1.35,marginTop:5},children:$.description}):null]},`${$.objectKey??$.name}-${V}`))]}):null,t.jsx(Vi,{t:n,verdict:h}),m?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:11,color:n.textMuted},children:[t.jsx(Gi,{size:12,strokeWidth:2})," drafting as ",m]}):null,b?t.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:b}):null]})}function Yn({open:e,onToggle:n,label:r,t:i,lead:s,children:o}){return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:n,style:{display:"inline-flex",alignItems:"center",gap:5,border:"none",background:"transparent",cursor:"pointer",color:s?i.accent:i.textSecondary,fontSize:11.5,fontWeight:s?800:700,fontFamily:i.font,padding:0},children:[e?t.jsx(Gt,{size:13,strokeWidth:2}):t.jsx(Cr,{size:13,strokeWidth:2}),e?`Hide ${r.toLowerCase()}`:r]}),e?t.jsx("div",{style:{marginTop:7},children:o}):null]})}function an({label:e,items:n,t:r}){return n.length===0?null:t.jsxs("div",{style:{display:"grid",gap:5},children:[t.jsx(zr,{t:r,children:e}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:5},children:n.map(i=>t.jsx("span",{style:fn(r),children:i},i))})]})}function zr({t:e,children:n}){return t.jsx("div",{style:{fontSize:10,fontWeight:800,letterSpacing:"0.05em",textTransform:"uppercase",color:e.textMuted},children:n})}function fn(e){return{fontSize:10.5,fontWeight:700,color:e.textSecondary,background:e.pillBg,borderRadius:999,padding:"2px 8px",fontFamily:e.fontMono}}function Xn(e){return{margin:0,fontFamily:e.fontMono,fontSize:11.5,whiteSpace:"pre-wrap",color:e.textSecondary,background:e.appBg,border:`1px solid ${e.headerBorder}`,borderRadius:7,padding:10,maxHeight:240,overflow:"auto"}}function Jn(){return t.jsx("span",{style:{color:"#ff7b72",marginLeft:2},children:"*"})}function ln(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function js(e){const n=new Set,r=/@(metric|dim)\(([^)]+)\)/gi;let i;for(;i=r.exec(e);)n.add(i[2].trim());return Array.from(n)}function Zn({cell:e,onClose:n,onSaved:r,initialContent:i,initialName:s,initialDescription:o,initialTags:l,initialDomain:c,initialOwner:u}){var te;const{state:p,dispatch:f}=Ut(),a=Ar[p.themeMode],d=x.useRef(null),[g,h]=x.useState(s||e.name||"new_block"),[m,b]=x.useState(c??""),[k,W]=x.useState(u??""),[L,N]=x.useState(o??p.notebookMetadata.description??""),[$,V]=x.useState((l??p.notebookMetadata.categories??[]).join(", ")),[Z,F]=x.useState(i??e.content),[M,ie]=x.useState(""),[D,_]=x.useState(""),[I,z]=x.useState([]),[v,U]=x.useState(!1),[J,K]=x.useState(null),E=x.useMemo(()=>js(Z),[Z]),P=x.useMemo(()=>$.split(",").map(w=>w.trim()).filter(Boolean),[$]),Q=[{id:"has-name",label:"Block has name",severity:"error",passed:!!g.trim()},{id:"has-owner",label:"Block has owner",severity:"error",passed:!!k.trim()},{id:"has-description",label:"Description",severity:"warning",passed:!!L.trim()},{id:"has-domain",label:"Domain",severity:"warning",passed:!!m.trim()},{id:"has-tags",label:"Has at least one tag",severity:"warning",passed:P.length>0},{id:"has-llm-context",label:"Has LLM context (for agents)",severity:"warning",passed:!!M.trim()}],se=Q.some(w=>w.severity==="error"&&!w.passed);x.useEffect(()=>{var w;(w=d.current)==null||w.focus()},[]),x.useEffect(()=>{const w=q=>{q.key==="Escape"&&n()};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[n]);const pe=_i(m,p.authoredDomains),me=`${m.trim()?`blocks/${ln(m)}/`:"blocks/"}${ln(g)||"new-block"}.dql`,Y=async()=>{var w,q,ae;if(se){K("Enter the block name and owner before saving.");return}if(!Z.trim()){K("Block content is required.");return}U(!0),K(null);try{const X=D.split(`
|
|
52
|
+
`).map(be=>be.trim()).filter(Boolean),ve=I.map(be=>({question:be.question.trim(),sql:be.sql.trim()||void 0})).filter(be=>be.question),T=await oe.saveAsBlock({cellId:e.id,notebookPath:((w=p.activeFile)==null?void 0:w.path)??null,name:g.trim(),domain:m.trim()||void 0,owner:k.trim()||void 0,content:Z,description:L.trim()||void 0,tags:P,metricRefs:E,llmContext:M.trim()||void 0,examples:ve.length>0?ve:void 0,invariants:X.length>0?X:void 0,reviewRequired:!!((q=e.datasetRefs)!=null&&q.length),datasetRefs:e.datasetRefs,lineage:(ae=e.dqlArtifact)==null?void 0:ae.lineage}),de={name:`${ln(g)||"new-block"}.dql`,path:T.path,type:"block",folder:"blocks"};p.files.some(be=>be.path===T.path)||f({type:"FILE_ADDED",file:de});const ue=await oe.openBlockStudio(T.path);f({type:"OPEN_BLOCK_STUDIO",file:de,payload:ue}),r==null||r({...T,name:g.trim()}),n()}catch(X){K(X instanceof Error?X.message:String(X))}finally{U(!1)}},A={width:"100%",background:a.inputBg,border:`1px solid ${J?a.error:a.inputBorder}`,borderRadius:6,color:a.textPrimary,fontSize:13,fontFamily:a.font,padding:"8px 12px",outline:"none",boxSizing:"border-box"};return t.jsx("div",{onClick:w=>{w.target===w.currentTarget&&n()},style:{position:"fixed",inset:0,background:a.modalOverlay,display:"flex",alignItems:"center",justifyContent:"center",zIndex:1100,backdropFilter:"blur(4px)"},children:t.jsxs("div",{style:{width:760,maxWidth:"calc(100vw - 48px)",maxHeight:"calc(100vh - 48px)",overflow:"auto",background:a.modalBg,border:`1px solid ${a.cellBorder}`,borderRadius:12,boxShadow:"0 20px 60px rgba(0,0,0,0.5)"},children:[t.jsxs("div",{style:{padding:"20px 24px 0",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("h2",{style:{margin:0,fontSize:16,fontWeight:600,color:a.textPrimary,fontFamily:a.font},children:"Save as Block"}),t.jsx("button",{onClick:n,style:{background:"transparent",border:"none",color:a.textMuted,cursor:"pointer",fontSize:18},children:"×"})]}),t.jsxs("div",{style:{padding:"20px 24px 24px",display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("label",{style:{fontSize:12,color:a.textSecondary,fontFamily:a.font},children:["Block Name ",t.jsx(Jn,{})]}),t.jsx("input",{ref:d,value:g,onChange:w=>h(w.target.value),style:A})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,color:a.textSecondary,fontFamily:a.font},children:"Domain"}),t.jsxs("select",{value:m,onChange:w=>b(w.target.value),style:A,children:[t.jsx("option",{value:"",children:"Global / cross-domain"}),pe.map(w=>t.jsx("option",{value:w.value,disabled:w.disabled,children:w.label},w.value))]})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("label",{style:{fontSize:12,color:a.textSecondary,fontFamily:a.font},children:["Owner ",t.jsx(Jn,{})]}),t.jsx("input",{value:k,onChange:w=>W(w.target.value),style:A,placeholder:"data-platform@company.com"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,color:a.textSecondary,fontFamily:a.font},children:"Tags"}),t.jsx("input",{value:$,onChange:w=>V(w.target.value),style:A,placeholder:"revenue, dashboard"})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,color:a.textSecondary,fontFamily:a.font},children:"Description"}),t.jsx("input",{value:L,onChange:w=>N(w.target.value),style:A})]}),t.jsxs("details",{style:{border:`1px solid ${a.cellBorder}`,borderRadius:6,padding:"8px 12px"},children:[t.jsx("summary",{style:{fontSize:12,fontWeight:600,color:a.textSecondary,fontFamily:a.font,cursor:"pointer"},children:"Agent-facing metadata (optional — helps AI tools ground answers on this block)"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,paddingTop:10},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,color:a.textSecondary,fontFamily:a.font},children:"How should an AI describe this block?"}),t.jsx("textarea",{value:M,onChange:w=>ie(w.target.value),rows:3,placeholder:'One paragraph. E.g. "Monthly revenue recognized from closed-won deals, grouped by billing month. Excludes refunds."',style:{...A,fontFamily:a.font,lineHeight:1.5,resize:"vertical"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,color:a.textSecondary,fontFamily:a.font},children:"Invariants (one per line)"}),t.jsx("textarea",{value:D,onChange:w=>_(w.target.value),rows:2,placeholder:`Revenue is never negative
|
|
53
|
+
Each row is a unique month`,style:{...A,fontFamily:a.fontMono,lineHeight:1.5,resize:"vertical"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,color:a.textSecondary,fontFamily:a.font},children:"Example questions (grounding for chat cells)"}),I.map((w,q)=>t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr auto",gap:6},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsx("input",{value:w.question,onChange:ae=>{const X=[...I];X[q]={...X[q],question:ae.target.value},z(X)},placeholder:"What was revenue last month?",style:A}),t.jsx("input",{value:w.sql,onChange:ae=>{const X=[...I];X[q]={...X[q],sql:ae.target.value},z(X)},placeholder:"Optional SQL snippet",style:{...A,fontFamily:a.fontMono,fontSize:12}})]}),t.jsx("button",{type:"button",onClick:()=>z(I.filter((ae,X)=>X!==q)),style:{background:"transparent",border:`1px solid ${a.cellBorder}`,borderRadius:6,color:a.textMuted,cursor:"pointer",fontSize:12,padding:"0 10px"},children:"×"})]},q)),t.jsx("button",{type:"button",onClick:()=>z([...I,{question:"",sql:""}]),style:{alignSelf:"flex-start",background:a.btnBg,border:`1px solid ${a.btnBorder}`,borderRadius:6,color:a.textSecondary,cursor:"pointer",fontSize:12,fontFamily:a.font,padding:"4px 10px"},children:"+ Add example"})]})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,padding:"10px 12px",background:a.pillBg,borderRadius:6,border:`1px solid ${a.cellBorder}`},children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:a.textSecondary,fontFamily:a.font,letterSpacing:"0.06em",textTransform:"uppercase"},children:"Governance checks"}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:Q.map(w=>{const q=w.passed?"#3fb950":w.severity==="error"?"#ff7b72":"#e3b341",ae=w.passed?"✓":w.severity==="error"?"✕":"!";return t.jsxs("span",{title:w.passed?`${w.label} — passed`:`${w.label} — ${w.severity}`,style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:11,fontFamily:a.font,color:q,background:`${q}18`,border:`1px solid ${q}55`,borderRadius:999,padding:"2px 10px"},children:[t.jsx("span",{style:{fontWeight:700},children:ae}),w.label]},w.id)})})]}),t.jsx("div",{style:{fontSize:12,color:a.textMuted,fontFamily:a.fontMono,padding:"8px 12px",background:a.pillBg,borderRadius:6},children:me}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:12,color:a.textSecondary,fontFamily:a.font},children:"Content Preview"}),t.jsx("textarea",{value:Z,onChange:w=>F(w.target.value),style:{...A,minHeight:220,resize:"vertical",fontFamily:a.fontMono,lineHeight:1.5}})]}),E.length>0&&t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6,padding:"10px 12px",background:a.pillBg,borderRadius:6},children:[t.jsx("span",{style:{fontSize:11,color:a.textMuted,fontFamily:a.font},children:"Detected semantic refs:"}),E.map(w=>t.jsx("span",{style:{fontSize:11,color:a.accent,fontFamily:a.fontMono,background:`${a.accent}18`,borderRadius:999,padding:"2px 8px"},children:w},w))]}),J&&t.jsx("div",{style:{fontSize:12,color:a.error,fontFamily:a.font},children:J})]}),t.jsxs("div",{style:{padding:"14px 24px",borderTop:`1px solid ${a.cellBorder}`,display:"flex",justifyContent:"flex-end",gap:10},children:[t.jsx("span",{style:{fontSize:11.5,color:a.textMuted,marginRight:"auto",alignSelf:"center"},children:(te=e.datasetRefs)!=null&&te.length?"This analysis uses imported or staged data, so it will be saved as a review-required draft. Certification requires project-controlled, contracted, tested, reproducible sources.":"DQL will certify this block now when its local checks pass; otherwise it is saved as a draft."}),t.jsx("button",{onClick:n,style:{background:a.btnBg,border:`1px solid ${a.btnBorder}`,borderRadius:6,color:a.textSecondary,cursor:"pointer",fontSize:13,fontFamily:a.font,padding:"7px 16px"},children:"Cancel"}),t.jsx("button",{onClick:Y,disabled:v||se,title:se?"Fix governance errors to enable Save":void 0,style:{background:a.accent,border:`1px solid ${a.accent}`,borderRadius:6,color:"#fff",cursor:v||se?"not-allowed":"pointer",fontSize:13,fontFamily:a.font,padding:"7px 20px",opacity:v||se?.5:1},children:v?"Saving & checking…":"Save block"})]})]})})}function Tr(e){return e.policy==="dynamic"||e.policy==="optional"}function Ss({parameters:e,values:n,onChange:r,onReset:i,t:s,includeNonRuntime:o=!1,card:l=!1}){const c=e.filter(u=>o||Tr(u));return c.length===0?null:t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(170px, 1fr))",gap:8},children:c.map(u=>{const p=Object.prototype.hasOwnProperty.call(n,u.name),f=p?n[u.name]:u.default,a=g=>r(u.name,g),d=u.type==="boolean"?t.jsxs("select",{"aria-label":u.name,value:String(f??""),onChange:g=>a(g.target.value),style:er(s),children:[t.jsx("option",{value:"",children:"Select…"}),t.jsx("option",{value:"true",children:"True"}),t.jsx("option",{value:"false",children:"False"})]}):t.jsx("input",{"aria-label":u.name,type:u.type==="number"?"number":u.type==="date"?"date":"text",value:Array.isArray(f)?f.join(", "):f==null?"":String(f),placeholder:u.type.endsWith("[]")?"Comma-separated values":u.required?"Required value":"Use default",onChange:g=>a(g.target.value),style:er(s)});return t.jsxs("label",{style:{display:"grid",gap:4,minWidth:0,...l?{padding:9,border:`1px solid ${s.cellBorder}`,borderRadius:7,background:s.appBg}:{}},children:[t.jsxs("span",{style:{display:"flex",gap:5,alignItems:"center",fontSize:10.5,fontWeight:750,color:s.textSecondary},children:[ws(u.name),u.required?t.jsx("span",{style:{color:s.error},children:"*"}):null]}),d,t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:5,minHeight:14,fontSize:9.5,color:s.textMuted},children:[t.jsxs("span",{children:[u.type,o?` · ${u.policy}`:""]}),p&&i?t.jsx("button",{type:"button",onClick:()=>i(u.name),style:{marginLeft:"auto",border:0,padding:0,background:"transparent",color:s.accent,fontSize:9.5,cursor:"pointer"},children:"Reset"}):null]})]},u.name)})})}function ws(e){return e.replace(/[_-]+/g," ").replace(/\b\w/g,n=>n.toUpperCase())}function er(e){return{width:"100%",minWidth:0,boxSizing:"border-box",background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:5,color:e.textPrimary,padding:"5px 7px",fontSize:11,fontFamily:e.font}}function ks(e){const n=e.filter(o=>o.kind==="run").map(Rs).filter(o=>!!o).slice(-6);if(n.length===0)return;const r=[...n].reverse().find(o=>{var l;return(l=o.result)==null?void 0:l.columns.length})??n[n.length-1],i=r.result,s=$r(tr(r));return gn({activeSurface:"notebook",conversationStateVersion:1,activeTurnId:r.id,activeTopic:r.question,conversationSummary:zs(n),turns:n,sourceAnswerId:r.id,sourceCertifiedBlock:r.sourceCertifiedBlock,sourceQuestion:r.question,sourceAnswerSummary:r.answerSummary,answerContract:tr(r),dqlArtifact:r.dqlArtifact,cascade:r.cascade,resultColumns:i==null?void 0:i.columns,resultRowsSample:i==null?void 0:i.rowsSample,resultDimensionValues:i==null?void 0:i.dimensionValues,outputColumns:i==null?void 0:i.columns,requestedFilters:r.requestedFilters??nt(s==null?void 0:s.filters),requestedDimensions:r.requestedDimensions??nt(s==null?void 0:s.dimensions),priorLimit:r.topN??Mr(s),priorMeasures:r.requestedMeasures??(i==null?void 0:i.measureColumns),contextPackId:r.contextPackId,trustLabel:r.trustLabel,reviewStatus:r.reviewStatus,certification:r.certification,route:r.route,sourceSql:r.sourceSql,updatedAt:r.completedAt})}function Rs(e){var a,d,g,h;const n=e.run.artifacts.find(m=>m.kind==="answer")??e.run.artifacts.find(m=>m.kind==="research_run")??e.run.artifacts[0],r=ye(n==null?void 0:n.payload),i=Cs(r),s=$s(i),o=Array.isArray(i==null?void 0:i.rows)?i.rows.filter(m=>!!(m&&typeof m=="object"&&!Array.isArray(m))).slice(0,24):[],l=((a=ye(r==null?void 0:r.contextPack))==null?void 0:a.questionPlan)??(r==null?void 0:r.analysisPlan),c=$r(l),u=Bs(s,o),p=Ts(c,s),f=ce(r==null?void 0:r.sourceCertifiedBlock)??((n==null?void 0:n.kind)==="answer"?ce(n.ref):void 0)??ce((d=ye(r==null?void 0:r.block))==null?void 0:d.name);return gn({id:e.run.id,question:e.run.question,answerSummary:e.run.answer??e.run.summary,completedAt:e.run.completedAt,artifactKind:n==null?void 0:n.kind,sourceCertifiedBlock:f,route:ce((g=ye(r==null?void 0:r.route))==null?void 0:g.label)??ce((h=ye(r==null?void 0:r.route))==null?void 0:h.tier),trustLabel:ce(r==null?void 0:r.trustLabel),reviewStatus:ce(r==null?void 0:r.reviewStatus),certification:ce(r==null?void 0:r.certification),contextPackId:ce(r==null?void 0:r.contextPackId),requestedFilters:nt(c==null?void 0:c.filters),requestedDimensions:nt(c==null?void 0:c.dimensions),requestedMeasures:nt(c==null?void 0:c.measures),answerContract:l,dqlArtifact:qs(r),cascade:_s(r),topN:Mr(c),result:s.length>0||o.length>0?gn({columns:s,rowsSample:o,dimensionValues:u,measureColumns:p,rowCount:As(i)}):void 0,sourceSql:Is(r,i)})}function tr(e){return e.answerContract}function $r(e){const n=ye(e);return ye(n==null?void 0:n.requestedShape)}function Cs(e){const n=ye(e==null?void 0:e.researchRun),r=ye(e==null?void 0:e.result);return[e==null?void 0:e.result,e==null?void 0:e.resultPreview,n==null?void 0:n.resultPreview,n==null?void 0:n.result,r==null?void 0:r.result].map(ye).filter(s=>!!(s&&(Array.isArray(s.rows)||Array.isArray(s.columns)))).sort((s,o)=>nr(o)-nr(s))[0]}function nr(e){const n=Array.isArray(e.rows)?e.rows.length:0,r=typeof e.rowCount=="number"&&Number.isFinite(e.rowCount)?e.rowCount:0;return n*1e5+r}function As(e){const n=e==null?void 0:e.rowCount;return typeof n=="number"&&Number.isFinite(n)?n:Array.isArray(e==null?void 0:e.rows)?e.rows.length:void 0}function Is(e,n){var r,i;return ce(e==null?void 0:e.proposedSql)??ce(e==null?void 0:e.sql)??ce(n==null?void 0:n.sql)??ce((r=ye(e==null?void 0:e.query))==null?void 0:r.sql)??ce((i=ye(e==null?void 0:e.plan))==null?void 0:i.sql)}function qs(e){var r,i;const n=Ke(e==null?void 0:e.dqlArtifact);return n?{...n,source:n.source.slice(0,3e3),filters:(r=n.filters)==null?void 0:r.filter(s=>s.values.length>0).slice(0,12).map(s=>({...s,values:s.values.slice(0,12)})),orderBy:(i=n.orderBy)==null?void 0:i.slice(0,8)}:void 0}function _s(e){const n=ye(e==null?void 0:e.cascade);if(!n)return;const r=ce(n.terminalLane),i=ce(n.routeTier);if(!(!r&&!i))return{terminalLane:r,routeTier:i,label:ce(n.label),ref:ce(n.ref),artifactKind:ce(n.artifactKind),refusalCode:ce(n.refusalCode),outcome:ye(n.outcome)}}function zs(e){const n=e.slice(-3).map(r=>{var o,l;const i=(o=r.result)==null?void 0:o.columns.slice(0,5).join(", "),s=(l=r.result)!=null&&l.dimensionValues?Object.entries(r.result.dimensionValues).slice(0,3).map(([c,u])=>`${c}: ${u.slice(0,3).join(", ")}`).join("; "):"";return[`Q: ${r.question}`,r.answerSummary?`A: ${r.answerSummary}`:"",i?`Columns: ${i}`:"",s?`Values: ${s}`:""].filter(Boolean).join(" | ")}).filter(Boolean);return n.length>0?n.join(`
|
|
54
|
+
`):void 0}function Mr(e){const n=ye(e==null?void 0:e.topN),r=n==null?void 0:n.n;return typeof r=="number"&&Number.isFinite(r)&&r>0?r:void 0}function Ts(e,n){const r=[...nt(e==null?void 0:e.measures)??[],...n.filter(s=>/\b(revenue|sales|amount|total|count|average|avg|sum|spend|cost|margin|profit|value|points?|score|quantity|units?|rate|volume)\b/i.test(s.replace(/_/g," ")))],i=Array.from(new Set(r.map(s=>s.trim()).filter(Boolean))).slice(0,12);return i.length>0?i:void 0}function ye(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function $s(e){const r=(Array.isArray(e==null?void 0:e.columns)?e.columns:[]).map(Ms).filter(o=>!!o),i=Array.isArray(e==null?void 0:e.rows)?e.rows.find(o=>o&&typeof o=="object"&&!Array.isArray(o)):void 0,s=i?Object.keys(i):[];return Array.from(new Set([...r,...s])).slice(0,32)}function nt(e){if(!Array.isArray(e))return;const n=e.map(i=>typeof i=="string"?i.trim():"").filter(Boolean),r=Array.from(new Set(n)).slice(0,24);return r.length>0?r:void 0}function Ms(e){if(typeof e=="string"&&e.trim())return e.trim();if(e&&typeof e=="object"){const n=e;return ce(n.name)??ce(n.field)??ce(n.key)}}function Bs(e,n){const r=e.filter(s=>/\b(category|product|customer|account|user|segment|region|channel|type|name)\b/i.test(s.replace(/_/g," "))).slice(0,12),i={};for(const s of r){const o=[];for(const l of n){const c=ye(l),u=c==null?void 0:c[s],p=typeof u=="string"||typeof u=="number"?String(u).trim():"";if(!(!p||o.includes(p))&&(o.push(p),o.length>=24))break}o.length>0&&(i[Es(s)]=o)}return Object.keys(i).length>0?i:void 0}function Es(e){const n=e.toLowerCase();return n.includes("category")?"category":n.includes("product")?n.includes("name")?"product_name":"product":n.includes("customer")?n.includes("name")?"customer_name":"customer":n.includes("segment")?"segment":n.includes("region")?"region":n.includes("channel")?"channel":n.replace(/[^a-z0-9_]+/g,"_")}function ce(e){return typeof e=="string"&&e.trim()?e.trim():void 0}function gn(e){const n={};for(const[r,i]of Object.entries(e))i!=null&&(Array.isArray(i)&&i.length===0||typeof i=="object"&&!Array.isArray(i)&&Object.keys(i).length===0||(n[r]=i));return Object.keys(n).length>0?n:void 0}function Ls(e){return JSON.stringify([e.kind,e.name??null,e.source,e.persistence??null,e.parameters??[],Object.entries(e.parameterValues??{}).sort(([n],[r])=>n.localeCompare(r)),e.executionReceipt??null])}function Br(e,n){if(e.kind==="sql_block"){const s=new Map(n.columns.map(o=>[o.toLowerCase(),o]));return(e.filterableColumns??[]).flatMap(o=>{const l=s.get(o.column.toLowerCase());return l?[{column:l,field:o.predicateTarget,values:rr(n.rows.map(c=>c[l]))}]:[]})}if(e.kind!=="semantic_block"||e.persistence!=="transient")return[];const r=new Map(n.columns.map(s=>[s.toLowerCase(),s])),i=new Set((e.parameters??[]).flatMap(s=>{var o;return((o=s.binding)==null?void 0:o.kind)==="semantic_filter"?[s.binding.field.toLowerCase()]:[]}));return(e.dimensions??[]).flatMap(s=>{if(i.has(s.toLowerCase()))return[];const o=s.split(".").at(-1)??s,l=r.get(s.toLowerCase())??r.get(o.toLowerCase())??r.get(s.split(".").join("_").toLowerCase());if(!l)return[];const c=rr(n.rows.map(u=>u[l]));return[{column:l,field:s,values:c}]})}function Ns(e,n,r,i){const s=Br(e,n).find(b=>b.column===r);if(!s)throw new Error(`"${r}" is not an available semantic result filter.`);if(i==null||String(i).trim()==="")throw new Error("Choose a default filter value before adding the input.");const o=new Set((e.parameters??[]).map(b=>b.name)),l=Ds(s.field.split(".").at(-1)??s.column);let c=l,u=2;for(;o.has(c);)c=`${l}_${u++}`;const p=Array.isArray(i)?i.map(String).join(", "):String(i),f=zi(p,c);let a=Ti(e.source,{name:c,type:f,required:!1,defaultText:p,policy:"dynamic"});a=$i(a,c,s.field);const d=Mi(a).map(b=>{var k,W,L;return{...b,...((k=b.binding)==null?void 0:k.kind)==="semantic_filter"&&b.binding.field?{binding:{kind:"semantic_filter",field:b.binding.field,operator:b.binding.operator??"equals"}}:((W=b.binding)==null?void 0:W.kind)==="limit"?{binding:{kind:"limit"}}:((L=b.binding)==null?void 0:L.kind)==="sql_value"?{binding:{kind:"sql_value"}}:{binding:void 0}}}),{executionReceipt:g,compiledSql:h,...m}=e;return{artifact:{...m,source:a,parameters:d,parameterValues:{...e.parameterValues??{},[c]:i}},parameterName:c}}function rr(e){const n=new Set,r=[];for(const i of e){if(typeof i!="string"&&typeof i!="number"&&typeof i!="boolean")continue;const s=`${typeof i}:${String(i)}`;if(!n.has(s)&&(n.add(s),r.push(i),r.length>=50))break}return r}function Ds(e){const n=e.trim().toLowerCase().replace(/[^a-z0-9_]+/g,"_").replace(/^_+|_+$/g,"");return/^[a-z_][a-z0-9_]*$/.test(n)?n:"result_filter"}const Er="Canonical decision summary unavailable for this older run";function Lr(e){return e.modeOverride?e.modeOverride:e.pendingMode?e.pendingMode:e.researchMode?"research":e.initialMode==="research"?"ask":e.initialMode}function Nr(e,n,r){return e.map(i=>i.kind==="run"&&i.run.id===n?{kind:"run",id:r.id,run:r}:i)}function Dr(e){var r,i,s;const n=[];for(const o of e){if(o.kind==="user"){n.push({role:"user",text:o.text});continue}if(o.run.status==="blocked"||o.run.status==="cancelled"||o.run.stopReason==="cancelled"||((r=o.run.artifacts)==null?void 0:r.some(c=>{const u=re(c);return!!(u.executionError||u.warehouseFailure||u.analyticalFailure)}))){((i=n.at(-1))==null?void 0:i.role)==="user"&&n.pop();continue}n.push({role:"assistant",text:((s=o.run.answer)==null?void 0:s.trim())||o.run.summary})}return n.slice(-12)}const Cn="dql.agent.active-runs.v1",Pr={conversation:"Chat",certified_answer:"Certified answer",semantic_answer:"Governed semantic answer",generated_answer:"Generated answer",research:"Research plan",sql_cell:"SQL cell",dql_block_draft:"DQL block draft",modeling_draft:"Modeling proposal",skill_draft:"Skill proposal",app_build:"App plan",clarify:"Clarify",cancelled:"Stopped by user",blocked:"Blocked"};function Ps({themeMode:e,title:n="AI Copilot",scopeHint:r="Auto routes to answer, research, SQL, block, or app",composerPlaceholder:i="Ask anything about your data…",onClearScope:s,examplePrompts:o,emptyHint:l,notebookPath:c,selectedObject:u,workspaceContext:p,initialMode:f="auto",initialInput:a="",initialItems:d,onItemsChange:g,threadId:h,onThreadIdChange:m,audience:b="analyst",autoRun:k,onInsertSql:W,onInsertDql:L,onReplaceDql:N,onArtifactReady:$,onReviewAuthoringProposal:V,onOpenBlock:Z,onOpenResearch:F,onOpenApp:M,onRunningChange:ie,answerFirstCards:D=!1,insertDqlActionLabel:_,replaceDqlActionLabel:I,askLayout:z=!1}){const v=Ar[e],U=x.useRef(void 0),[J,K]=x.useState(a),[E,P]=x.useState(d??[]),[Q,se]=x.useState([]),[pe,me]=x.useState(""),[Y,A]=x.useState(!1),[te,w]=x.useState(null),[q,ae]=x.useState(null),[X,ve]=x.useState(null),[T,de]=x.useState(()=>Fs()),[ue,be]=x.useState(f==="research"),[st,Xe]=x.useState(!1),[ot,At]=x.useState([]),[Je,Ze]=x.useState(),at=x.useCallback(y=>{de(y);try{window.localStorage.setItem(Fr,y)}catch{}},[]),lt=x.useCallback(y=>{be(y),y||Xe(!1)},[]),Ne=x.useRef(null),ct=x.useRef(a),dt=x.useRef(null),Me=x.useRef(null),he=x.useRef(null),S=x.useRef(null),ee=x.useRef(null),ke=x.useRef(0),It=x.useRef(""),De=x.useRef(null),ut=x.useCallback(()=>{It.current="",De.current!==null&&(window.cancelAnimationFrame(De.current),De.current=null),me("")},[]),ji=x.useCallback(y=>{It.current+=y,De.current===null&&(De.current=window.requestAnimationFrame(()=>{De.current=null;const j=It.current;It.current="",j&&me(B=>B+j)}))},[]);x.useEffect(()=>()=>{De.current!==null&&window.cancelAnimationFrame(De.current)},[]);const qe=p==null?void 0:p.executionTarget,Mn=qe&&typeof qe=="object"&&!Array.isArray(qe)&&qe.target==="connection"&&typeof qe.connectionName=="string"?String(qe.connectionName):void 0,Si=qe&&typeof qe=="object"&&!Array.isArray(qe)&&qe.target==="local";x.useEffect(()=>{let y=!1;return oe.getConnections().then(j=>{if(y)return;const B=Object.keys(j.connections??{}).sort((O,H)=>O.localeCompare(H));At(B),Ze(Hr(B,j.default,Mn))}).catch(()=>{y||(At([]),Ze(void 0))}),()=>{y=!0}},[Mn]);const Bn=x.useCallback(y=>{Ze(y)},[]),[Pe,qt]=x.useState(null),[Be,et]=x.useState(null),[wi,tn]=x.useState(""),En=x.useRef(null),_t=x.useRef(null);x.useEffect(()=>{!a||Y||a!==ct.current&&(ct.current=a,K(a))},[a,Y]);const ki=x.useMemo(()=>Dr(E),[E]),zt=x.useRef(g);zt.current=g;const Qe=x.useRef($);Qe.current=$,x.useEffect(()=>{var y;(y=zt.current)==null||y.call(zt,E)},[E]);const je=x.useRef(h),Tt=x.useRef(m);Tt.current=m;const nn=x.useCallback((y,j)=>{var B;if(ee.current!==null&&(window.clearTimeout(ee.current),ee.current=null),gt(y.id),he.current===y.id&&(he.current=null),S.current=null,w(null),se(y.events.slice(-8)),ut(),P(O=>{if(O.some(G=>G.kind==="run"&&G.run.id===y.id))return O.map(G=>G.kind==="run"&&G.run.id===y.id?{...G,id:y.id,run:y}:G);const H=O.some(G=>G.kind==="user"&&G.text===j.question);return[...O,...H?[]:[{kind:"user",id:`${y.id}-question`,text:j.question}],{kind:"run",id:y.id,run:y}]}),y.route!=="certified_answer"){const O=Ht(y);O&&((B=Qe.current)==null||B.call(Qe,O,y))}},[ut]),Ln=x.useCallback((y,j)=>{var O;P(H=>Nr(H,y,j)),qt(H=>{if(!H||H.runId!==y)return H;const G=j.artifacts[0];return G?{runId:j.id,artifactId:G.id,tab:H.tab}:null}),ve(null);const B=Ht(j);B&&((O=Qe.current)==null||O.call(Qe,B,j))},[]),pt=x.useCallback(y=>{ee.current!==null&&window.clearTimeout(ee.current);const j=++ke.current;he.current=y.id,S.current=y,w(y),A(!0),ut(),se([]);const B=async()=>{if(!(j!==ke.current||he.current!==y.id))try{const O=await oe.getAgentRunState(y.id);if(j!==ke.current||he.current!==y.id)return;if(O.lifecycleState==="terminal"){nn(O.run,y),A(!1);return}se(O.progress.events.slice(-8)),ee.current=window.setTimeout(()=>{B()},600)}catch{if(j!==ke.current||he.current!==y.id)return;ee.current=window.setTimeout(()=>{B()},1200)}};return B(),()=>{j===ke.current&&(ke.current+=1),ee.current!==null&&(window.clearTimeout(ee.current),ee.current=null)}},[nn]),Nn=x.useRef(!1);x.useEffect(()=>{if(!h||Nn.current)return;Nn.current=!0,je.current??(je.current=h);let y=!1;return oe.getAgentThread(h).then(({turns:j,runs:B})=>{y||j.length===0||P(O=>{const H=O.filter(ge=>ge.kind==="run").length,G=Qr(j,B);if(j.length>=H)return G;const xe=new Map(G.flatMap(ge=>ge.kind==="run"?[[ge.run.id,ge.run]]:[]));return O.map(ge=>ge.kind==="run"&&xe.has(ge.run.id)?{...ge,run:xe.get(ge.run.id)}:ge)})}).catch(()=>{!y&&je.current===h&&(je.current=void 0)}),()=>{y=!0}},[h]),x.useEffect(()=>{const y=ar(h??je.current);if(!(!y||Me.current))return pt(y)},[pt,h]),x.useEffect(()=>{const y=()=>{if(document.visibilityState!=="visible"||Me.current)return;const j=S.current??ar(h??je.current);j&&pt(j)};return document.addEventListener("visibilitychange",y),()=>document.removeEventListener("visibilitychange",y)},[pt,h]);const Ee=async(y,j,B,O,H)=>{var On,Hn,Qn;const G=(y??J).trim();if(!G||Y)return;const xe=Lr({initialMode:f,researchMode:ue,modeOverride:j,pendingMode:U.current}),ge=Or(xe,st);Xe(!1),U.current=void 0;const Lt={kind:"user",id:mr("user"),text:G};P(Re=>[...Re,Lt]),K(""),ve(null),A(!0),se([]),ut();const Le=new AbortController;Me.current=Le;let le={id:mr("pending"),question:G,threadId:je.current,startedAt:new Date().toISOString()};he.current=null,S.current=le,w(le);let Ce=!1,Fn=!1,Wn=!1;try{if(!je.current)try{const fe=await oe.createAgentThread({surface:z?"ask":typeof(p==null?void 0:p.surface)=="string"?p.surface:c?"notebook":"agent",title:G,...c?{notebookPath:c}:{}});je.current=fe.id,(On=Tt.current)==null||On.call(Tt,fe.id),le={...le,threadId:fe.id},S.current=le,w(le)}catch{}const Re=xe==="modeling"||xe==="skill"?(Hn=[...E].reverse().find(fe=>fe.kind==="run"&&fe.run.artifacts.some(ft=>ft.kind===(xe==="modeling"?"modeling_change_proposal":"skill_change_proposal"))))==null?void 0:Hn.run:void 0,Vn=Re==null?void 0:Re.artifacts.find(fe=>fe.kind===(xe==="modeling"?"modeling_change_proposal":"skill_change_proposal")),Ai={question:G,...B?{selectedEvidenceId:B}:{},...O?{clarificationSourceQuestion:O}:{},requestedMode:xe,audience:b,selectedObject:u??(c?{kind:"notebook",path:c}:void 0),...H!=null&&H.executionTarget?{executionTarget:H.executionTarget}:Si?{executionTarget:{target:"local"}}:Je?{executionTarget:{target:"connection",connectionName:Je}}:{},workspaceContext:{...p??{},...c?{notebookPath:c}:{},...H?{researchSource:oi(H)}:{},...Re&&Vn?{sourceRunId:Re.id,sourceArtifactId:Vn.id,revision:(((Qn=Re.derivation)==null?void 0:Qn.revision)??1)+1}:{}},conversationContext:ks(E),history:ki,thinkingMode:T,researchResultRowsOptIn:ge,...je.current?{threadId:je.current}:{}},Nt=await oe.createAgentRunStream(Ai,fe=>{if(Ce=!0,fe.kind==="accepted"){const ft=le.id;le={...le,id:fe.runId},he.current=fe.runId,S.current=le,w(le),gt(ft),or(le),Fn=!0}else fe.kind==="event"?se(ft=>[...ft,fe.event].slice(-8)):fe.kind==="answer-delta"?ji(fe.delta):se(fe.run.events.slice(-8))},Le.signal);if(le.id!==Nt.id){const fe=le.id;le={...le,id:Nt.id},he.current=Nt.id,S.current=le,gt(fe),or(le)}nn(Nt,le)}catch(Re){Le.signal.aborted||(ve(Re instanceof Error?Re.message:String(Re)),K(G),Ce&&Fn?(Wn=!0,pt(le)):(gt(le.id),he.current===le.id&&(he.current=null),S.current=null,w(null)))}finally{Me.current===Le&&(Me.current=null),Wn||A(!1)}},$t=()=>{Ee()},Dn=()=>{var j;const y=he.current;y&&oe.cancelAgentRun(y).catch(()=>{}),(j=Me.current)==null||j.abort(),ke.current+=1,ee.current!==null&&window.clearTimeout(ee.current),gt(y??""),he.current=null,S.current=null,w(null),ut(),se([]),A(!1),ve("Stopped. No answer or draft was saved.")},Mt=x.useRef(ie);Mt.current=ie,x.useEffect(()=>{var y;(y=Mt.current)==null||y.call(Mt,Y)},[Y]),x.useEffect(()=>{!(k!=null&&k.text)||Y||dt.current!==k.nonce&&(dt.current=k.nonce,Ee(k.text,k.mode??f))},[k==null?void 0:k.nonce,k==null?void 0:k.text,k==null?void 0:k.mode,f,Y]),x.useEffect(()=>()=>{ke.current+=1,ee.current!==null&&window.clearTimeout(ee.current)},[]);const Bt={appId:typeof(p==null?void 0:p.appId)=="string"?p.appId:void 0,dashboardId:typeof(p==null?void 0:p.dashboardId)=="string"?p.dashboardId:void 0,dashboardTitle:typeof(p==null?void 0:p.dashboardTitle)=="string"?p.dashboardTitle:void 0},Et=(y,j)=>{var B,O;if(j.id==="review-modeling-proposal"||j.id==="review-skill-proposal"){const H=j.id==="review-modeling-proposal"?"modeling_change_proposal":"skill_change_proposal",G=y.artifacts.find(xe=>xe.kind===H);if(!G){ve("This authoring run does not include a reviewable proposal.");return}if(V)V(G,y);else if(G.ref){try{window.sessionStorage.setItem("dql-context-proposal-handoff",G.ref)}catch{}window.dispatchEvent(new CustomEvent("dql:open-context-proposal",{detail:{proposalId:G.ref,kind:G.kind}}))}return}if(j.id==="save-dql-block"){const H=$e(y),G=((B=H==null?void 0:H.source)==null?void 0:B.trim())??((O=_e(y))==null?void 0:O.trim());if(!G){ve("This answer does not include a reusable DQL or SQL artifact yet.");return}ae({runId:y.id,source:G,name:(H==null?void 0:H.name)??`${y.question.slice(0,48).trim()||"saved_answer"}`,dqlArtifact:H});return}if(j.id==="research-deeper"){Ee(y.question,"research",void 0,void 0,y);return}if(j.id.startsWith("suggest-question")){Ee(j.label,"auto");return}U.current=go(j.route),K(ho(y,j.route)),requestAnimationFrame(()=>{var H;return(H=Ne.current)==null?void 0:H.focus()})},Ri=x.useCallback((y,j,B="trust")=>{qt({runId:y,artifactId:j,tab:B})},[]),Ci=x.useCallback(y=>{var O,H;const j=y.trim();if(!j)return;const B=(O=Be==null?void 0:Be.text)==null?void 0:O.trim();et(null),tn("");try{(H=window.getSelection())==null||H.removeAllRanges()}catch{}Ee(B?`${j}
|
|
55
|
+
|
|
56
|
+
Regarding: "${B}"`:j),requestAnimationFrame(()=>{_t.current&&(_t.current.scrollTop=_t.current.scrollHeight)})},[Be,Ee]);if(x.useEffect(()=>{if(!z)return;const y=B=>{const O=B.target;O&&O.closest("[data-selpop]")||window.setTimeout(()=>{const H=window.getSelection(),G=H&&H.rangeCount?H.toString().trim():"";if(!G||G.length<3){et(Ce=>Ce&&null);return}const xe=H.anchorNode,ge=xe&&(xe.nodeType===1?xe:xe.parentElement),Lt=ge==null?void 0:ge.closest("[data-followup]");if(!Lt){et(Ce=>Ce&&null);return}const Le=H.getRangeAt(0).getBoundingClientRect(),Pn=Math.max(12,Math.min(Le.left,window.innerWidth-340)),le=Le.bottom+176>window.innerHeight?Math.max(12,Le.top-176):Le.bottom+8;et({text:G.slice(0,220),source:Lt.getAttribute("data-followup")||"answer",left:Pn,top:le}),tn(""),requestAnimationFrame(()=>{var Ce;return(Ce=En.current)==null?void 0:Ce.focus()})},0)},j=B=>{B.key==="Escape"&&et(null)};return document.addEventListener("mouseup",y),document.addEventListener("keydown",j),()=>{document.removeEventListener("mouseup",y),document.removeEventListener("keydown",j)}},[z]),z){const y=Pe?(()=>{const j=E.find(O=>O.kind==="run"&&O.run.id===Pe.runId);if(!j||j.kind!=="run")return null;const B=j.run.artifacts.find(O=>O.id===Pe.artifactId);return B?{run:j.run,artifact:B}:null})():null;return t.jsxs("div",{style:{display:"flex",height:"100%",minHeight:0,flex:1,minWidth:0,width:"100%",background:"var(--bg-canvas)"},children:[q?t.jsx(Zn,{cell:{id:`agent-${q.runId}`,type:q.dqlArtifact?"dql":"sql",content:q.source,name:q.name,status:"success",...q.dqlArtifact?{dqlArtifact:q.dqlArtifact}:{}},initialContent:q.source,initialName:q.name,onClose:()=>ae(null),onSaved:()=>ae(null)}):null,t.jsx("style",{children:Ys}),t.jsxs("div",{style:{flex:1,minWidth:360,display:"flex",flexDirection:"column",overflow:"hidden",background:"var(--bg-canvas)"},children:[t.jsxs("div",{style:{height:46,flexShrink:0,borderBottom:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",gap:9,padding:"0 24px"},children:[t.jsx("div",{style:{width:24,height:24,borderRadius:7,background:"var(--accent-dim)",border:"1px solid var(--status-info-border)",color:"var(--accent)",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:t.jsx(Ue,{size:13})}),t.jsx("span",{style:{fontSize:13.5,fontWeight:650,color:v.textPrimary,whiteSpace:"nowrap"},children:n==="AI Copilot"?"Ask your data":n}),t.jsx("div",{style:{flex:1}}),t.jsx("span",{style:{fontSize:11,color:v.textMuted,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",minWidth:0},children:"Certified first · semantic next · generated SQL last"})]}),t.jsxs("div",{ref:_t,style:{flex:1,minHeight:0,overflowY:"auto",overflowX:"hidden",display:"flex",flexDirection:"column"},children:[t.jsxs("div",{style:{width:"min(720px, 100% - 48px)",margin:"0 auto",padding:"26px 0 12px",display:"flex",flexDirection:"column",gap:26},children:[E.length===0&&!Y?t.jsxs("div",{style:{margin:"auto 0",display:"grid",gap:14,justifyItems:"center",textAlign:"center",color:v.textSecondary,paddingTop:40},children:[t.jsx("div",{style:br(v),children:t.jsx(Ue,{size:20})}),t.jsx("div",{style:{fontSize:13.5,lineHeight:1.5,maxWidth:400,color:v.textSecondary},children:l??ir}),t.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center",maxWidth:520},children:(o??sr).map(j=>t.jsx("button",{type:"button",className:"dql-hover dql-lift",onClick:()=>{K(j.prompt),requestAnimationFrame(()=>{var B;return(B=Ne.current)==null?void 0:B.focus()})},style:Qt(v),children:j.label},j.label))})]}):null,E.map(j=>j.kind==="user"?t.jsx("div",{style:Xs(v),children:j.text},j.id):t.jsx(hr,{run:j.run,t:v,themeMode:e,threadId:je.current,appContext:Bt,selectedArtifactId:(Pe==null?void 0:Pe.runId)===j.run.id?Pe.artifactId:void 0,onOpenArtifact:(B,O)=>Ri(j.run.id,B,O),onOpenApp:M,onInsertSql:W,onInsertDql:L,onOpenBlock:Z,onOpenResearch:F,onSelectClarification:B=>{const O=Dt(B,j.run.question);Ee(O.question,void 0,O.selectedEvidenceId,j.run.question)},onNextAction:B=>Et(j.run,B),onRepairedRun:Ln},j.id)),Y&&t.jsx(ur,{events:Q,t:v,streamingAnswer:pe,thinkingMode:T,backgroundRun:te})]}),t.jsxs("div",{style:{width:"min(720px, 100% - 48px)",margin:"auto auto 0",padding:"10px 0 16px",position:"sticky",bottom:0,background:"linear-gradient(to top, var(--bg-canvas) 82%, transparent)"},children:[X?t.jsx("div",{style:{color:v.error,fontSize:12,marginBottom:8},children:X}):null,s?t.jsxs("div",{style:{width:"fit-content",maxWidth:"100%",marginBottom:7,padding:"4px 7px 4px 9px",border:"1px solid var(--border-default)",borderRadius:999,background:"var(--bg-2)",color:v.textMuted,fontSize:10.5,display:"flex",alignItems:"center",gap:5},children:[t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r}),t.jsx("button",{type:"button",onClick:s,"aria-label":"Clear modeling scope",title:"Clear modeling scope",style:{border:0,background:"transparent",color:v.textMuted,cursor:"pointer",display:"grid",placeItems:"center",padding:1},children:t.jsx(Ft,{size:12})})]}):null,t.jsxs("div",{style:{background:"var(--bg-2)",border:"1px solid var(--border-default)",borderRadius:14,boxShadow:"0 1px 2px rgba(26,26,26,0.03), 0 6px 22px rgba(26,26,26,0.05)",display:"flex",flexDirection:"column"},children:[t.jsx("textarea",{ref:Ne,value:J,onChange:j=>{K(j.target.value),U.current=void 0},rows:2,placeholder:i,onKeyDown:j=>{j.key==="Enter"&&!j.shiftKey&&(j.preventDefault(),$t())},style:{border:"none",background:"transparent",resize:"none",outline:"none",boxShadow:"none",padding:"13px 15px 4px",fontSize:13.5,lineHeight:1.5,color:v.textPrimary,fontFamily:v.font}}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px 10px 12px"},children:[t.jsx(Un,{t:v,value:T,onChange:at}),t.jsx(lr,{checked:ue,onChange:lt,t:v}),ue?t.jsx(cr,{checked:st,onChange:Xe,t:v}):null,t.jsx(dr,{names:ot,value:Je,onChange:Bn,t:v}),t.jsx("div",{style:{flex:1}}),Y?t.jsxs("button",{type:"button",className:"dql-hover",onClick:Dn,title:"Stop the active agent run",style:{height:34,padding:"0 12px",borderRadius:10,border:`1px solid ${v.error}`,background:v.btnBg,color:v.error,display:"inline-flex",alignItems:"center",gap:6,cursor:"pointer",fontFamily:v.font,fontSize:12.5,fontWeight:600},children:[t.jsx(Gn,{size:13,fill:"currentColor"})," Stop"]}):null,t.jsx("button",{type:"button",className:"dql-hover dql-lift",title:"Ask",onClick:$t,disabled:!J.trim()||Y,style:{width:34,height:34,borderRadius:10,border:"none",background:J.trim()&&!Y?"var(--accent)":"var(--bg-4)",color:"#fff",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:J.trim()&&!Y?"pointer":"default",boxShadow:J.trim()&&!Y?"0 1px 5px rgba(107,93,211,0.3)":"none"},children:Y?t.jsx(Ge,{size:15,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}):t.jsx(Ir,{size:15})})]})]}),t.jsx("div",{style:{textAlign:"center",fontSize:10.5,color:v.textMuted,marginTop:8},children:"Every answer is grounded in your certified metrics and dbt lineage."})]})]})]}),y?t.jsx(so,{run:y.run,artifact:y.artifact,tab:Pe.tab,t:v,appContext:Bt,onOpenApp:M,onChangeTab:j=>qt(B=>B&&{...B,tab:j}),onClose:()=>qt(null),onSaveBlock:()=>Et(y.run,{id:"save-dql-block",label:"Save as block",route:"dql_block_draft"}),onInsertSql:W,onInsertDql:L}):null,Be?t.jsx(oo,{t:v,text:Be.text,source:Be.source,left:Be.left,top:Be.top,draft:wi,inputRef:En,onDraftChange:tn,onClose:()=>et(null),onSend:Ci}):null]})}return t.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",minHeight:0,flex:1,minWidth:0,width:"100%",background:v.cellBg},children:[q?t.jsx(Zn,{cell:{id:`agent-${q.runId}`,type:q.dqlArtifact?"dql":"sql",content:q.source,name:q.name,status:"success",...q.dqlArtifact?{dqlArtifact:q.dqlArtifact}:{}},initialContent:q.source,initialName:q.name,onClose:()=>ae(null),onSaved:()=>ae(null)}):null,t.jsx("style",{children:`
|
|
57
|
+
@keyframes dql-agent-run-spin { to { transform: rotate(360deg); } }
|
|
58
|
+
@keyframes dql-agent-fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
|
|
59
|
+
@keyframes dql-agent-thinking-dot { 0%, 65%, 100% { opacity: .28; transform: translateY(0); } 32% { opacity: 1; transform: translateY(-2px); } }
|
|
60
|
+
@keyframes dql-agent-activity-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
|
|
61
|
+
.dql-agent-thinking-dot { animation: dql-agent-thinking-dot 1.05s ease-in-out infinite; }
|
|
62
|
+
.dql-agent-activity { animation: dql-agent-activity-in .22s ease-out; }
|
|
63
|
+
.dql-hover { transition: filter .15s ease, transform .12s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease; }
|
|
64
|
+
.dql-hover:hover { filter: brightness(1.07); }
|
|
65
|
+
.dql-hover:active { transform: translateY(0.5px); }
|
|
66
|
+
.dql-lift:hover { transform: translateY(-1px); }
|
|
67
|
+
details > summary::-webkit-details-marker { display: none; }
|
|
68
|
+
@media (prefers-reduced-motion: reduce) { .dql-agent-thinking-dot, .dql-agent-activity { animation: none !important; } }
|
|
69
|
+
`}),t.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"14px 16px",display:"flex",flexDirection:"column",gap:12},children:[E.length===0&&!Y?t.jsxs("div",{style:{margin:"auto 0",display:"grid",gap:14,justifyItems:"center",textAlign:"center",color:v.textSecondary},children:[t.jsx("div",{style:br(v),children:t.jsx(Ue,{size:20})}),t.jsx("div",{style:{fontSize:13,lineHeight:1.5,maxWidth:380,color:v.textSecondary},children:l??ir}),t.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap",justifyContent:"center",maxWidth:520},children:(o??sr).map(y=>t.jsx("button",{type:"button",className:"dql-hover dql-lift",onClick:()=>{K(y.prompt),requestAnimationFrame(()=>{var j;return(j=Ne.current)==null?void 0:j.focus()})},style:Qt(v),children:y.label},y.label))})]}):null,E.map(y=>y.kind==="user"?t.jsx("div",{style:Ao(v),children:y.text},y.id):D?t.jsx(hr,{run:y.run,t:v,themeMode:e,threadId:je.current,appContext:Bt,onOpenApp:M,onInsertSql:W,onInsertDql:L,onReplaceDql:N,insertDqlActionLabel:_,replaceDqlActionLabel:I,onOpenBlock:Z,onOpenResearch:F,onSelectClarification:j=>{const B=Dt(j,y.run.question);Ee(B.question,void 0,B.selectedEvidenceId,y.run.question)},onNextAction:j=>Et(y.run,j),onRepairedRun:Ln},y.id):t.jsx(Ks,{run:y.run,t:v,themeMode:e,appContext:Bt,onOpenApp:M,onInsertSql:W,onInsertDql:L,onOpenBlock:Z,onOpenResearch:F,onSelectClarification:j=>{const B=Dt(j,y.run.question);Ee(B.question,void 0,B.selectedEvidenceId,y.run.question)},onNextAction:j=>Et(y.run,j)},y.id)),Y&&t.jsx(ur,{events:Q,t:v,streamingAnswer:pe,thinkingMode:T,backgroundRun:te})]}),X?t.jsx("div",{style:{margin:"0 16px 8px",color:v.error,fontSize:12},children:X}):null,t.jsxs("div",{style:{padding:"10px 16px 14px",borderTop:`1px solid ${v.headerBorder}`,display:"grid",gap:8},children:[t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center",justifyContent:"space-between",flexWrap:"wrap"},children:[t.jsxs("div",{style:{fontSize:11,color:v.textMuted,flex:1,minWidth:180,display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{children:r}),s?t.jsx("button",{type:"button",onClick:s,"aria-label":"Clear modeling scope",title:"Clear modeling scope",style:{border:0,background:"transparent",color:v.textMuted,cursor:"pointer",display:"grid",placeItems:"center",padding:2},children:t.jsx(Ft,{size:12})}):null]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(dr,{names:ot,value:Je,onChange:Bn,t:v}),t.jsx(Un,{t:v,value:T,onChange:at}),t.jsx(lr,{checked:ue,onChange:lt,t:v}),ue?t.jsx(cr,{checked:st,onChange:Xe,t:v}):null]})]}),t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-end"},children:[t.jsx("textarea",{ref:Ne,value:J,onChange:y=>{K(y.target.value),U.current=void 0},rows:2,placeholder:i,onKeyDown:y=>{y.key==="Enter"&&!y.shiftKey&&(y.preventDefault(),$t())},style:ko(v)}),t.jsxs("button",{type:"button",className:"dql-hover dql-lift",onClick:$t,disabled:!J.trim()||Y,style:vr(v,!!J.trim()&&!Y),children:[Y?t.jsx(Ge,{size:15,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}):t.jsx(os,{size:15}),t.jsx("span",{children:Y?"Working":"Ask"})]}),Y?t.jsxs("button",{type:"button",className:"dql-hover",onClick:Dn,style:{...vr(v,!0),background:v.btnBg,borderColor:v.error,color:v.error},title:"Stop the active agent run",children:[t.jsx(Gn,{size:13,fill:"currentColor"}),t.jsx("span",{children:"Stop"})]}):null]})]})]})}const ir="Ask a question — every answer is grounded in your certified metrics and dbt lineage. Use Research deeper on any answer for a slower investigation.",sr=[{label:"What is total revenue?",prompt:"What is total revenue?"},{label:"Why is revenue down by region?",prompt:"Why is revenue down by region?"},{label:"Top customers by revenue this quarter",prompt:"Top customers by revenue this quarter"},{label:"How have orders trended over the last 6 months?",prompt:"How have orders trended over the last 6 months?"}];function An(){try{const e=JSON.parse(window.localStorage.getItem(Cn)??"[]");return Array.isArray(e)?e.filter(n=>{if(!n||typeof n!="object")return!1;const r=n;return typeof r.id=="string"&&typeof r.question=="string"&&typeof r.startedAt=="string"&&(r.threadId===void 0||typeof r.threadId=="string")}):[]}catch{return[]}}function or(e){try{const n=An().filter(r=>r.id!==e.id);window.localStorage.setItem(Cn,JSON.stringify([...n,e].slice(-12)))}catch{}}function gt(e){try{const n=An().filter(r=>r.id!==e);window.localStorage.setItem(Cn,JSON.stringify(n))}catch{}}function ar(e){const n=An().sort((r,i)=>i.startedAt.localeCompare(r.startedAt));return e?n.find(r=>r.threadId===e):n.find(r=>!r.threadId)}const Fr="dql.agent.thinkingMode",Wr="One-run consent: during explicit Research, enables up to 20 redacted result rows for Research narration and up to 200 redacted local-analysis tool rows. Ordinary Ask—and Research without this selection—keeps result rows local.";function Or(e,n){return e==="research"&&n}function Hr(e,n,r){return r&&e.includes(r)?r:n&&e.includes(n)?n:e[0]}function lr({checked:e,onChange:n,t:r}){return t.jsxs("button",{type:"button","aria-pressed":e,"aria-label":"Research mode",title:"Research mode plans a bounded investigation and synthesizes the surrounding business context. Thinking effort is separate.",onClick:()=>n(!e),style:{minHeight:30,display:"inline-flex",alignItems:"center",gap:5,padding:"0 8px",border:e?"1px solid var(--accent)":"1px solid var(--border-default)",borderRadius:8,background:e?"var(--accent-dim)":"var(--bg-2)",color:e?"var(--accent-fg)":r.textMuted,fontSize:10.5,cursor:"pointer"},children:[t.jsx(Ye,{size:13})," Research"]})}function cr({checked:e,onChange:n,t:r}){return t.jsxs("label",{title:Wr,style:{minHeight:30,display:"inline-flex",alignItems:"center",gap:5,padding:"0 7px",border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-2)",color:r.textMuted,fontSize:10.5,cursor:"pointer"},children:[t.jsx("input",{type:"checkbox","aria-label":"Allow redacted local-analysis tool rows for this Research run",checked:e,onChange:i=>n(i.target.checked)}),"Research tool rows (this run)"]})}function dr({names:e,value:n,onChange:r,t:i}){return e.length===0||!n?null:t.jsxs("label",{title:"Database connection used for metadata, compilation, and execution in this conversation",style:{height:30,display:"inline-flex",alignItems:"center",gap:5,padding:"0 7px",border:"1px solid var(--border-default)",borderRadius:8,background:"var(--bg-2)",color:i.textMuted,fontSize:11},children:[t.jsx(Bi,{size:12}),t.jsx("select",{"aria-label":"Ask AI database connection",value:n,onChange:s=>r(s.target.value),style:{maxWidth:150,border:0,outline:0,background:"transparent",color:i.textSecondary,font:"inherit",cursor:e.length>1?"pointer":"default"},children:e.map(s=>t.jsx("option",{value:s,children:s},s))})]})}function Fs(){try{const e=window.localStorage.getItem(Fr);return e==="low"||e==="medium"||e==="high"||e==="auto"?e:"auto"}catch{return"auto"}}const Ws=new Set(["conversation","certified_answer","semantic_answer","generated_answer","research","sql_cell","dql_block_draft","modeling_draft","skill_draft","app_build","clarify","cancelled","blocked"]),Os=new Set(["certified","governed","grounded","review_required","blocked","not_applicable"]),Hs=new Set(["completed","needs_review","needs_clarification","cancelled","blocked"]),Qs=new Set(["conversational_reply","certified_answer_found","governed_semantic_answer","governed_compound_answer","generated_review_required","artifact_created","needs_clarification","human_review_required","cancelled","blocked"]);function Qr(e,n=[]){const r=new Map(n.map(o=>[o.id,o])),i=new Set(e.flatMap(o=>o.agentRunId?[o.agentRunId]:[])),s=new Set(n.flatMap(o=>{const l=o.derivation;return(l==null?void 0:l.kind)==="analytical_repair"&&i.has(o.id)&&typeof l.sourceRunId=="string"?[l.sourceRunId]:[]}));return e.filter(o=>!o.agentRunId||!s.has(o.agentRunId)).flatMap(o=>{const l=o.agentRunId?r.get(o.agentRunId):void 0;return[{kind:"user",id:`${o.id}-q`,text:o.question},{kind:"run",id:(l==null?void 0:l.id)??o.id,run:l??Vs(o)}]})}function Vs(e){var p,f,a;const n=Ws.has(e.route)?e.route:"generated_answer",r=Os.has(e.trustLabel)?e.trustLabel:e.certification==="certified"?"certified":"not_applicable",i=Hs.has(e.runStatus)?e.runStatus:"completed",s=Qs.has(e.stopReason)?e.stopReason:i==="cancelled"?"cancelled":i==="blocked"?"blocked":i==="needs_clarification"?"needs_clarification":i==="needs_review"?"human_review_required":n==="conversation"?"conversational_reply":r==="certified"?"certified_answer_found":"artifact_created",o=(((p=e.result)==null?void 0:p.columns)??[]).filter(d=>typeof d=="string"),l=(((f=e.result)==null?void 0:f.rowsSample)??[]).filter(d=>Array.isArray(d)).map(d=>Object.fromEntries(o.map((g,h)=>[g,d[h]]))),c=o.length>0?{columns:o,rows:l,rowCount:((a=e.result)==null?void 0:a.rowCount)??l.length}:void 0,u=c||e.sql||e.dqlArtifact||e.sourceCertifiedBlock?{id:`${e.id}-artifact`,kind:"answer",title:e.sourceCertifiedBlock??e.question,trustState:r,ref:e.sourceCertifiedBlock,payload:{...e.sourceCertifiedBlock?{sourceCertifiedBlock:e.sourceCertifiedBlock}:{},...e.certification?{certification:e.certification}:{},...e.contextPackId?{contextPackId:e.contextPackId}:{},...e.sql?{sql:e.sql}:{},...e.dqlArtifact?{dqlArtifact:e.dqlArtifact}:{},...e.cascade?{cascade:e.cascade}:{},...c?{result:c}:{},...e.contract&&Object.keys(e.contract).length>0?{contextPack:{questionPlan:{requestedShape:e.contract}}}:{}}}:void 0;return{id:e.id,question:e.question,requestedMode:"auto",route:n,status:i,trustState:r,stopReason:s,startedAt:e.createdAt,completedAt:e.createdAt,summary:e.answerSummary??e.question,answer:e.answerText??e.answerSummary,answerKind:n==="conversation"?"conversational":void 0,narrationIntegrityReceipt:e.narrationIntegrityReceipt,steps:[],artifacts:u?[u]:[],evaluations:[],events:[],nextActions:[],repairAttempts:0}}function Gs(e){switch(e){case"certified_answer":return"Found a compatible certified block";case"semantic_answer":return"Found a compatible semantic metric";case"generated_answer":return"Identified the relevant tables and columns";case"research":return"Identified evidence for deeper analysis";case"app_build":return"Found governed assets for the app";case"sql_cell":return"Identified the query context";case"dql_block_draft":return"Identified reusable governed logic";case"modeling_draft":return"Resolved current models and relationship evidence";case"skill_draft":return"Resolved current domain guidance and governed references";case"clarify":return"Identified a missing business detail";case"cancelled":return"Stopped by user";default:return"Identified the best answer path"}}function Us(e,n){if(n.some(r=>r.type==="repair.attempted"))return"Refining the query and trying again";if(n.some(r=>r.type==="escalated"))return"Expanding the evidence search";switch(e){case"certified_answer":case"semantic_answer":return"Running the governed query";case"generated_answer":return"Building and running a grounded query";case"research":return"Researching the strongest evidence";case"app_build":return"Assembling the app from governed assets";case"sql_cell":return"Building and checking the SQL";case"dql_block_draft":return"Drafting the governed logic";case"modeling_draft":return"Building a reviewable modeling proposal";case"skill_draft":return"Building a reviewable Skill proposal";case"clarify":return"Preparing a focused clarification";default:return"Preparing the answer"}}function hn(e){for(let n=e.length-1;n>=0;n-=1)if(e[n].route)return e[n].route}function Vr(e,n,r=!1){return e<12?null:!n&&e<24&&!r?{title:"Still resolving the governed evidence",detail:"The bounded request is still selecting its answer path. DQL will stop at the normal deadline instead of silently switching to a longer workflow."}:n==="research"?{title:"Deep research is validating the analysis",detail:"This can use several AI and SQL steps. Reusable relationships and semantic metrics make future investigations faster; reviewed repeat answers can be saved as blocks and certified."}:{title:r?"Applying one bounded query repair":"Finishing the bounded query path",detail:"DQL is compiling or running the selected governed path. An ordinary lookup stops at its deadline instead of silently restarting as Research."}}function Gr(e,n,r,i){return r==="certified"||e<20&&i===0||n!=="research"&&n!=="generated_answer"?null:{title:n==="research"?"Make future research faster":"Make this question faster next time",detail:"If this analysis is reusable, save it as a block, review it, then certify it. Add repeated joins to Domain Modeling and reusable measures to the semantic layer to reduce future AI work and token usage."}}function Ur(e,n=!1){if(e.length===0&&n)return[{id:"background",label:"Continuing this request in the background",state:"active"}];const r=hn(e);if(r==="conversation")return[];const i=e.some(c=>c.type==="route.decided"),s=e.some(c=>c.type==="executor.started"||c.type==="step.started"||c.type==="repair.attempted"||c.type==="escalated"),o=e.some(c=>c.type==="evaluation.recorded"),l=[{id:"search",label:"Resolving governed evidence and business meaning",state:i?"complete":"active"}];return i&&l.push({id:"match",label:Gs(r),state:s||o?"complete":"active"}),(s||o)&&l.push({id:"execute",label:Us(r,e),state:o?"complete":"active"}),o&&l.push({id:"verify",label:"Checking the result against governed evidence",state:"active"}),l}function ur({events:e,t:n,streamingAnswer:r,thinkingMode:i,backgroundRun:s}){var h;const[o,l]=x.useState(()=>Date.now());x.useEffect(()=>{const m=window.setInterval(()=>l(Date.now()),1e3);return()=>window.clearInterval(m)},[]);const c=(s==null?void 0:s.startedAt)??((h=e.find(m=>m.type==="run.started"))==null?void 0:h.at),u=c?Date.parse(c):o,p=Number.isFinite(u)?Math.max(0,Math.floor((o-u)/1e3)):0,f=Vr(p,hn(e),e.some(m=>m.type==="repair.attempted"));if(r)return t.jsx("div",{style:{alignSelf:"stretch",padding:"4px 2px 8px",fontSize:13.5,lineHeight:1.55,color:n.textPrimary,whiteSpace:"pre-wrap",animation:"dql-agent-fadein 0.22s ease-out"},children:r});if(hn(e)==="conversation")return t.jsxs("div",{role:"status","aria-live":"polite",style:{alignSelf:"stretch",display:"flex",alignItems:"center",gap:9,padding:"5px 2px 9px",color:n.textSecondary,animation:"dql-agent-fadein 0.22s ease-out"},children:[t.jsx(pr,{}),t.jsx("span",{style:{fontSize:13,lineHeight:1.4},children:"Replying…"})]});const d=Ur(e,!!s),g=p>=12?f==null?void 0:f.title:i==="high"?"Thorough mode is cross-checking the result.":null;return t.jsxs("div",{role:"status","aria-live":"polite","aria-label":"Agent activity",style:{alignSelf:"stretch",display:"grid",gap:7,padding:"5px 2px 10px",animation:"dql-agent-fadein 0.22s ease-out"},children:[d.map(m=>t.jsxs("div",{className:"dql-agent-activity",style:{display:"flex",alignItems:"center",gap:9,minHeight:18,color:m.state==="active"?n.textPrimary:n.textMuted},children:[t.jsx("span",{"aria-hidden":"true",style:{width:16,height:16,display:"inline-flex",alignItems:"center",justifyContent:"center",flex:"0 0 auto",color:m.state==="active"?n.accent:n.textMuted},children:m.state==="active"?t.jsx(pr,{}):t.jsx(vt,{size:13,strokeWidth:2.2})}),t.jsxs("span",{style:{fontSize:12.5,lineHeight:1.4,fontWeight:m.state==="active"?620:450},children:[m.label,m.state==="active"?"…":""]})]},m.id)),g?t.jsx("span",{style:{paddingLeft:25,fontSize:10.5,lineHeight:1.4,color:n.textMuted},children:g}):null]})}function pr(){return t.jsx("span",{"aria-hidden":"true",style:{width:16,height:10,display:"inline-flex",alignItems:"center",justifyContent:"center",gap:2},children:[0,1,2].map(e=>t.jsx("span",{className:"dql-agent-thinking-dot",style:{width:3,height:3,borderRadius:999,background:"var(--accent)",animationDelay:`${e*120}ms`}},e))})}function fr({items:e,t:n,renderItem:r,cap:i=4}){const[s,o]=x.useState(!1),l=s?e:e.slice(0,i);return t.jsxs(t.Fragment,{children:[l.map((c,u)=>r(c,u)),e.length>i?t.jsxs("button",{type:"button",className:"dql-hover",onClick:()=>o(c=>!c),style:{alignSelf:"flex-start",background:"none",border:"none",cursor:"pointer",color:n.accent,fontSize:11,padding:"2px 0",display:"inline-flex",alignItems:"center",gap:4},children:[s?t.jsx(qr,{size:11}):t.jsx(Gt,{size:11}),s?"Show less":`Show all (${e.length})`]}):null]})}function Ks({run:e,t:n,themeMode:r,appContext:i,onOpenApp:s,onInsertSql:o,onInsertDql:l,onOpenBlock:c,onOpenResearch:u,onSelectClarification:p,onNextAction:f}){var D;const{dispatch:a}=Ut();if(e.route==="conversation"){const _=e.answerKind==="general_knowledge";return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,animation:"dql-agent-fadein 0.3s ease-out"},children:[t.jsxs("div",{style:Io(n),children:[_?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10.5,color:n.textMuted,marginBottom:6,fontWeight:650},children:[t.jsx(Wt,{size:11})," General knowledge — not from your data"]}):null,t.jsx("div",{style:{fontSize:13.5,lineHeight:1.55,color:n.textPrimary},children:e.answer?t.jsx(Pt,{text:rt(e.answer),t:n}):e.summary})]}),e.nextActions.length>0?t.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:e.nextActions.map(I=>t.jsx("button",{type:"button",className:"dql-hover dql-lift",onClick:()=>f(I),style:Qt(n),children:I.label},I.id))}):null]})}const d=e.steps??[],g=d.length>1,h=((D=e.plan)==null?void 0:D.source)==="llm",m=$n(e),b=zn(e),k=Rt(e),W=e.route==="certified_answer"||e.route==="generated_answer",L=e.nextActions.some(_=>_.route==="research"),N=W&&k&&!L,$=$e(e),V=k&&!($!=null&&$.sourcePath)&&!!(($==null?void 0:$.source)??_e(e)),Z=Date.parse(e.startedAt),F=Date.parse(e.completedAt),M=Number.isFinite(Z)&&Number.isFinite(F)?Math.max(0,Math.round((F-Z)/1e3)):0,ie=Gr(M,e.route,e.trustState,e.repairAttempts);return t.jsxs("div",{style:qo(n),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(uo,{run:e}),t.jsx("div",{style:{minWidth:0,flex:1},children:t.jsx("div",{style:{fontSize:12.5,fontWeight:850,color:n.textPrimary},children:ao(e)})}),t.jsx(po,{run:e,t:n})]}),b?t.jsxs("div",{style:{display:"flex",gap:6,alignItems:"flex-start",fontSize:11,color:n.textMuted,lineHeight:1.4},children:[e.trustState==="certified"?t.jsx(we,{size:12,color:n.success,style:{flex:"0 0 auto",marginTop:1}}):e.trustState==="governed"||e.trustState==="grounded"?t.jsx(we,{size:12,color:n.accent,style:{flex:"0 0 auto",marginTop:1}}):t.jsx(He,{size:12,color:n.warning,style:{flex:"0 0 auto",marginTop:1}}),t.jsx("span",{children:b})]}):null,h||g||e.repairAttempts>0?t.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[h?t.jsx(dn,{t:n,icon:t.jsx(St,{size:11}),label:"AI plan",tone:"accent"}):null,g?t.jsx(dn,{t:n,icon:t.jsx(mt,{size:11}),label:`${d.length} steps`,tone:"muted"}):null,e.repairAttempts>0?t.jsx(dn,{t:n,icon:t.jsx(Xt,{size:11}),label:`${e.repairAttempts} repair${e.repairAttempts>1?"s":""}`,tone:"warning"}):null]}):null,e.summary&&!(e.answer&&xo(Ie(e.summary),rt(e.answer)))?t.jsx("div",{style:{fontSize:12.5,lineHeight:1.45,color:n.textSecondary},children:Ie(e.summary)}):null,e.answer?t.jsx("div",{style:_o(n),children:t.jsx(Pt,{text:rt(e.answer),t:n})}):null,e.analyticalTaskOutcomes&&e.analyticalTaskOutcomes.length>1?t.jsxs("div",{style:{display:"grid",gap:5,padding:"8px 10px",border:`1px solid ${n.cellBorder}`,borderRadius:8,background:n.cellBg},children:[t.jsx("div",{style:{fontSize:10.5,fontWeight:800,color:n.textMuted,textTransform:"uppercase",letterSpacing:.4},children:"Analytical tasks"}),e.analyticalTaskOutcomes.map(_=>{var v;const I=typeof _.status=="string"?_.status:"gap",z=typeof _.summary=="string"?_.summary:typeof((v=_.gap)==null?void 0:v.message)=="string"?String(_.gap.message):"Task outcome recorded.";return t.jsxs("div",{style:{display:"flex",gap:7,alignItems:"flex-start",fontSize:11.5,color:n.textSecondary},children:[t.jsx("span",{style:{color:I==="completed"?n.success:n.warning,fontWeight:800},children:I==="completed"?"✓":"!"}),t.jsxs("span",{children:[t.jsx("strong",{children:String(_.taskId)})," · ",z]})]},String(_.taskId))})]}):null,t.jsx(Jr,{run:e,t:n,onSelect:p}),m.length>0?t.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[t.jsx("span",{style:{fontSize:11,color:n.textMuted},children:"Evidence:"}),m.map(_=>t.jsxs("span",{style:xi(n,_.certified),children:[_.certified?t.jsx(we,{size:11}):t.jsx(Ye,{size:11}),t.jsx("span",{children:_.label})]},_.label))]}):null,t.jsx(hi,{run:e,t:n}),e.artifacts.length>0?t.jsx("div",{style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},children:e.artifacts.map(_=>t.jsx(di,{artifact:_,t:n,themeMode:r,onInsertSql:o,onInsertDql:l,sourceRunId:e.id,sourceQuestion:e.question,onOpenBlock:c,onOpenResearch:u,onOpenApp:s,onNextAction:f},_.id))}):null,g?t.jsx(pi,{steps:d,t:n}):t.jsx(ui,{evaluations:e.evaluations,t:n}),e.events.length>0||e.traceReference?t.jsxs("div",{style:{display:"flex",gap:12,flexWrap:"wrap",alignItems:"center"},children:[e.events.length>0?t.jsxs("button",{type:"button",className:"dql-hover",onClick:()=>a({type:"OPEN_AGENT_LOG",run:e}),style:{display:"inline-flex",alignItems:"center",gap:5,alignSelf:"flex-start",background:"transparent",border:"none",cursor:"pointer",padding:0,color:n.textMuted,fontSize:11.5,fontFamily:n.font},title:"See what the agent did and where the time went",children:[t.jsx(St,{size:12})," View steps · where the time went"]}):null,e.traceReference?t.jsxs("button",{type:"button",className:"dql-hover",onClick:()=>a({type:"OPEN_ASK_TRACE",runId:e.id}),style:{display:"inline-flex",alignItems:"center",gap:5,alignSelf:"flex-start",background:"transparent",border:"none",cursor:"pointer",padding:0,color:n.accent,fontSize:11.5,fontFamily:n.font,fontWeight:650},title:"Open the local, redacted Ask trace",children:[t.jsx(Yt,{size:12})," Open full trace"]}):null]}):null,ie?t.jsxs("div",{style:{display:"grid",gap:3,padding:"8px 9px",border:`1px solid ${n.accent}33`,borderRadius:7,background:`${n.accent}0a`},children:[t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,color:n.textSecondary,fontSize:11,fontWeight:800},children:[t.jsx(Wt,{size:11,color:n.accent})," ",ie.title]}),t.jsx("span",{style:{fontSize:10.5,color:n.textMuted,lineHeight:1.45},children:ie.detail})]}):null,k||N||e.nextActions.length>0?t.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[k?t.jsx(_n,{run:e,t:n,appContext:i,onOpenApp:s}):null,V?t.jsxs("button",{type:"button",className:"dql-hover",onClick:()=>f({id:"save-dql-block",label:"Save as block",route:"dql_block_draft"}),style:ne(n),children:[t.jsx(Rn,{size:11})," Save as block"]}):null,N?t.jsxs("button",{type:"button",className:"dql-hover",onClick:()=>f({id:"research-deeper",label:"Research this deeper",route:"research"}),style:ne(n),title:"Run a slower, multi-step investigation on this question",children:[t.jsx(Ye,{size:11}),"Research this deeper"]}):null,e.nextActions.filter(_=>_.id!=="pin-to-app"&&_.id!=="research-deeper"&&_.id!=="confirm-app-build"&&_.id!=="request-certification").map(_=>t.jsx("button",{type:"button",className:"dql-hover",onClick:()=>f(_),style:ne(n),children:_.label},_.id))]}):null]})}function Kr(e){const n=[];return e.analytical&&n.push({id:"how",label:"How it answered"}),(e.hasDql||e.analytical&&e.blocked)&&n.push({id:"dql",label:"DQL"}),(e.hasSql||e.analytical&&e.blocked)&&n.push({id:"sql",label:"SQL"}),e.hasLineage&&n.push({id:"lineage",label:"Lineage"}),n.push({id:"trust",label:"Trust & steps"}),n}const Ys=`
|
|
70
|
+
@keyframes dql-agent-run-spin { to { transform: rotate(360deg); } }
|
|
71
|
+
@keyframes dql-agent-fadein { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
|
|
72
|
+
@keyframes dql-agent-thinking-dot { 0%, 65%, 100% { opacity: .28; transform: translateY(0); } 32% { opacity: 1; transform: translateY(-2px); } }
|
|
73
|
+
@keyframes dql-agent-activity-in { from { opacity: 0; transform: translateY(2px); } to { opacity: 1; transform: none; } }
|
|
74
|
+
.dql-agent-thinking-dot { animation: dql-agent-thinking-dot 1.05s ease-in-out infinite; }
|
|
75
|
+
.dql-agent-activity { animation: dql-agent-activity-in .22s ease-out; }
|
|
76
|
+
.dql-hover { transition: filter .15s ease, transform .12s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease; }
|
|
77
|
+
.dql-hover:hover { filter: brightness(1.03); }
|
|
78
|
+
.dql-hover:active { transform: translateY(0.5px); }
|
|
79
|
+
.dql-lift:hover { transform: translateY(-1px); }
|
|
80
|
+
.dql-ask-ghost:hover { background: var(--bg-0); color: var(--text-primary) !important; }
|
|
81
|
+
.dql-ask-chip:hover { border-color: var(--accent) !important; box-shadow: 0 1px 6px rgba(107,93,211,0.12); }
|
|
82
|
+
details > summary::-webkit-details-marker { display: none; }
|
|
83
|
+
@media (prefers-reduced-motion: reduce) { .dql-agent-thinking-dot, .dql-agent-activity { animation: none !important; } }
|
|
84
|
+
`;function Xs(e){return{alignSelf:"flex-end",maxWidth:"82%",background:"var(--bg-0)",color:e.textPrimary,borderRadius:"16px 16px 4px 16px",padding:"10px 14px",fontSize:13.5,lineHeight:1.5,whiteSpace:"pre-wrap",animation:"dql-agent-fadein 0.25s ease-out"}}function We(e){return Kt(e,{variant:"ghost",size:"sm"})}function cn(e,n){return e.kind==="app_proposal"||e.kind==="dql_block_draft"||e.kind==="research_run"||!!en(n)}function Jt(e,n){var l,c;const r=[],i=Te(n),s=e.kind==="answer"?(l=i==null?void 0:i.rows)!=null&&l.length?"Table":"Answer":e.kind==="sql_cell"?"SQL":e.kind==="dql_block_draft"?"DQL block":e.kind==="research_run"?"Research":"Result";r.push(s);const o=(i==null?void 0:i.rowCount)??((c=i==null?void 0:i.rows)==null?void 0:c.length);return typeof o=="number"&&r.push(`${o} row${o===1?"":"s"}`),typeof(i==null?void 0:i.executionTime)=="number"&&r.push(i.executionTime>=1e3?`${(i.executionTime/1e3).toFixed(1)}s`:`${i.executionTime.toFixed(i.executionTime<10?1:0)}ms`),r.push(e.trustState==="certified"?"certified block":e.trustState==="governed"||e.trustState==="grounded"?"governed":"AI-generated"),r.join(" · ")}const gr=["supported","contradicted","inconclusive","failed","skipped"];function In(e){var a;const n=R(e.researchLedgerV2);if(!n)return;const r=Array.isArray(n.entries)?n.entries:[],i={supported:0,contradicted:0,inconclusive:0,failed:0,skipped:0};for(const d of r){const g=(a=R(d))==null?void 0:a.verdict;typeof g=="string"&&gr.includes(g)&&(i[g]+=1)}const s=r.length,o=typeof n.groundableBranchCount=="number"&&Number.isFinite(n.groundableBranchCount)&&n.groundableBranchCount>=0?Math.trunc(n.groundableBranchCount):s,l=n.limitedScope===!0||o<3,c=gr.flatMap(d=>{const g=i[d];return g?[`${g} ${d}`]:[]}),u=s===0?"no branch verdicts recorded":c.join(" · "),p=l?`Limited research scope · ${u}`:`Research branches · ${u}`,f=l?`Limited research scope: ${o} of at least 3 evidence-supported branches were available. Verdicts: ${u}.`:`${o} evidence-supported branches were available. Verdicts: ${u}.`;return{branchCount:s,groundableBranchCount:o,limitedScope:l,verdicts:i,compactLabel:p,detail:f}}function Yr(e){const n=e.artifacts.find(r=>r.kind==="research_run");return n?In(re(n)):void 0}function bt(e,n){const i=/^(?:certified|governed semantic|review-required|exploratory dbt-grounded) answer$/i.test(n.title.trim())?e.question:n.title,s=Ie(i).replace(/[?.!]+$/,"").trim();if(!s)return"Answer result";const o=s.charAt(0).toUpperCase()+s.slice(1);return o.length>88?`${o.slice(0,85).trimEnd()}…`:o}function R(e){return e&&typeof e=="object"&&!Array.isArray(e)?e:void 0}function Xr(e){const n=[],r=new Set,i=(s,o)=>{const l=R(s);if(!l)return;const c=[l.name,l.label,l.relation,l.objectName].find(a=>typeof a=="string"&&a.trim().length>0);if(!c)return;const u=typeof l.kind=="string"?l.kind:o,p=`${u??""}:${c}`;if(r.has(p))return;r.add(p);const f=[l.description,l.provenance,l.sourceTier,l.source].find(a=>typeof a=="string"&&a.trim().length>0);n.push({name:c,kind:u,detail:f})};for(const s of e.artifacts){const o=re(s),l=R(o.evidence);for(const p of["lineage","sourceTables","semanticObjects","selectedAssets"]){const f=l==null?void 0:l[p];Array.isArray(f)&&f.forEach(a=>i(a,p==="sourceTables"?"source":void 0))}const c=R(o.analysisPlan)??R(l==null?void 0:l.analysisPlan),u=c==null?void 0:c.candidateTables;Array.isArray(u)&&u.forEach(p=>i(p,"relation"))}return n.slice(0,24)}function qn(e,n){var i;const r=re(n);return Zt(r)?"how":(i=$e(e)??Ct(r))!=null&&i.source?"dql":_e(e)??(typeof r.sql=="string"?r.sql:void 0)?"sql":Xr(e).length>0?"lineage":"trust"}function Js({run:e,artifact:n,selected:r,t:i,themeMode:s,onInspect:o}){const l=re(n),c=Te(l),[u,p]=x.useState(!1);if(x.useEffect(()=>{if(!u)return;const m=b=>{b.key==="Escape"&&p(!1)};return document.addEventListener("keydown",m),()=>document.removeEventListener("keydown",m)},[u]),!c)return null;const f=fi(l,c),a=qn(e,n),d=$e(e)??Ct(l),g=n.trustState==="certified"?ci(n,l):void 0,h=t.jsxs("section",{"data-followup":"table","aria-label":`${bt(e,n)} result`,style:{border:`1px solid ${r?"var(--accent)":"var(--border-default)"}`,borderRadius:12,background:"var(--bg-2)",overflow:"hidden",boxShadow:u?"0 24px 80px rgba(15,23,42,0.28)":r?"0 2px 10px rgba(107,93,211,0.12)":"0 1px 3px rgba(26,26,26,0.04)",...u?{width:"min(1440px, calc(100vw - 48px))",maxHeight:"calc(100vh - 48px)"}:{}},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"11px 13px",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("span",{style:{width:30,height:30,borderRadius:8,background:n.trustState==="certified"?"var(--status-success-bg)":"var(--accent-dim)",color:n.trustState==="certified"?"var(--status-success)":"var(--accent)",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(it,{kind:n.kind})}),t.jsxs("div",{style:{minWidth:0,flex:1},children:[t.jsx("div",{style:{fontSize:12.5,fontWeight:700,color:i.textPrimary,lineHeight:1.35},children:bt(e,n)}),t.jsx("div",{style:{fontSize:11,color:i.textMuted,marginTop:2},children:Jt(n,l)})]}),t.jsxs("button",{type:"button",className:"dql-ask-ghost",onClick:()=>o(a),style:We(i),children:[t.jsx(St,{size:12})," Inspect"]}),t.jsxs("button",{type:"button",className:"dql-ask-ghost","aria-label":u?"Return result to Copilot":"Expand result",title:u?"Return result to Copilot":"Expand this result for wide tables",onClick:()=>p(m=>!m),style:We(i),children:[u?t.jsx(Ui,{size:12}):t.jsx(Fi,{size:12}),u?"Restore":"Expand result"]})]}),d?t.jsx(li,{artifact:d,certifiedBlockName:g,initialResult:c,initialChartConfig:f,payload:l,executionTarget:e.executionTarget,t:i,themeMode:s,embedded:!0,expanded:u}):t.jsx(wn,{result:c,themeMode:s,t:i,chartConfig:f,embedded:!0,tabLabels:{table:"Results",chart:"Visualization"},contentMaxHeight:u?"calc(100vh - 172px)":void 0,tableMaxHeight:u?"calc(100vh - 250px)":void 0})]});return!u||typeof document>"u"?h:t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{minHeight:96,border:"1px dashed var(--border-default)",borderRadius:12,display:"grid",placeItems:"center",color:i.textMuted,fontSize:11.5},children:"Result is open in the expanded viewer."}),Li.createPortal(t.jsx("div",{role:"dialog","aria-modal":"true","aria-label":`${bt(e,n)} expanded result`,onClick:()=>p(!1),style:{position:"fixed",inset:0,zIndex:120,display:"grid",placeItems:"center",padding:24,background:"rgba(15,23,42,0.48)",backdropFilter:"blur(3px)"},children:t.jsx("div",{onClick:m=>m.stopPropagation(),style:{minWidth:0,maxWidth:"100%"},children:h})}),document.body)]})}function hr(e){const{run:n,t:r,themeMode:i,threadId:s,appContext:o,selectedArtifactId:l,onOpenArtifact:c,onOpenApp:u,onInsertSql:p,onInsertDql:f,onReplaceDql:a,insertDqlActionLabel:d,replaceDqlActionLabel:g,onOpenBlock:h,onOpenResearch:m,onSelectClarification:b,onNextAction:k,onRepairedRun:W}=e,{dispatch:L}=Ut(),[N,$]=x.useState(!1),V=c??(()=>L({type:"OPEN_AGENT_LOG",run:n}));if(n.route==="conversation"){const T=n.answerKind==="general_knowledge";return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,animation:"dql-agent-fadein 0.3s ease-out",maxWidth:"100%"},children:[T?t.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10.5,color:r.textMuted,fontWeight:650},children:[t.jsx(Wt,{size:11})," General knowledge — not from your data"]}):null,t.jsx("div",{"data-followup":"answer",style:{fontSize:14.5,lineHeight:1.65,color:r.textPrimary},children:n.answer?t.jsx(Pt,{text:rt(n.answer),t:r}):n.summary}),n.nextActions.length>0?t.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:n.nextActions.map(de=>t.jsx("button",{type:"button",className:"dql-hover dql-lift",onClick:()=>k(de),style:Qt(r),children:de.label},de.id))}):null]})}const Z=n.trustState==="certified",F=n.status==="blocked",M=n.status==="cancelled"||n.stopReason==="cancelled"||n.route==="cancelled",ie=n.status==="needs_clarification",D=n.answer,_=M?"Stopped by user":F?"Couldn’t run this query":ie?"Needs clarification":Z?"Certified answer":"AI-generated answer",I=M?n.summary||"Stopped by user.":F?vi(n):void 0,z=mi(n),v=$n(n),U=M?[]:n.artifacts,J=U.filter(T=>{const de=re(T);return!cn(T,de)&&!!Te(de)}),K=new Set(J.map(T=>T.id)),E=U.filter(T=>!cn(T,re(T))&&!K.has(T.id)),P=U.filter(T=>cn(T,re(T))),Q=J[0]??E[0]??U[0],se=U.find(T=>T.kind==="research_run"),pe=Yr(n),me=pe?0:n.evaluations.filter(T=>T.severity==="info").length,Y=Rt(n),A=n.route==="certified_answer"||n.route==="semantic_answer"||n.route==="generated_answer",te=n.nextActions.some(T=>T.route==="research"),w=A&&Y&&!te,q=$e(n),ae=Y&&!(q!=null&&q.sourcePath)&&!!((q==null?void 0:q.source)??_e(n)),X=d&&f||g&&a?Ht(n):void 0,ve=()=>{var de;const T=D?rt(D):I??n.summary;T&&((de=navigator.clipboard)==null||de.writeText(T).catch(()=>{}),$(!0),window.setTimeout(()=>$(!1),1400))};return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10,maxWidth:"100%",animation:"dql-agent-fadein 0.3s ease-out"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7,flexWrap:"wrap"},children:[M?t.jsx(mt,{size:14,color:r.textMuted}):F?t.jsx(He,{size:14,color:r.error}):Z?t.jsx(we,{size:14,color:r.success}):t.jsx(Ue,{size:14,color:r.accent}),t.jsx("span",{style:{fontSize:12,fontWeight:650,color:M?r.textMuted:F?r.error:r.textSecondary},children:_}),Z&&v[0]?t.jsxs("span",{style:{fontSize:11,color:r.textMuted},children:["from ",t.jsx("span",{style:{color:r.accent,fontWeight:600},children:v[0].label})]}):!F&&!M&&pe&&se?t.jsxs("button",{type:"button","aria-label":"Open Research branch evidence",onClick:()=>V(se.id,"trust"),style:{fontSize:11,color:pe.limitedScope?r.warning:r.textMuted,background:"none",border:"none",cursor:"pointer",padding:0,fontFamily:r.font,display:"inline-flex",alignItems:"center",gap:4,textAlign:"left"},children:[t.jsx(Ye,{size:11,color:pe.limitedScope?r.warning:r.accent})," ",pe.compactLabel]}):!F&&!M&&Q&&me>0?t.jsxs("button",{type:"button",onClick:()=>V(Q.id,"trust"),style:{fontSize:11,color:r.textMuted,background:"none",border:"none",cursor:"pointer",padding:0,fontFamily:r.font,display:"inline-flex",alignItems:"center",gap:4},children:[t.jsx(vt,{size:11,color:r.success})," ",me," check",me===1?"":"s"," passed"]}):null]}),D?t.jsx("div",{"data-followup":"answer",style:{fontSize:14.5,lineHeight:1.65,color:r.textPrimary},children:t.jsx(Pt,{text:rt(D),t:r})}):M?t.jsx("div",{"data-followup":"answer",style:{fontSize:14,lineHeight:1.6,color:r.textMuted},children:Ie(n.summary||"Stopped by user.")}):I?t.jsx(zo,{run:n,detail:I,threadId:s,onRepaired:T=>W(n.id,T),t:r}):n.summary?t.jsx("div",{"data-followup":"answer",style:{fontSize:14,lineHeight:1.6,color:r.textSecondary},children:Ie(n.summary)}):null,z?t.jsxs("div",{role:"status",style:{fontSize:11.5,lineHeight:1.5,color:r.warning,borderLeft:`2px solid ${r.warning}`,paddingLeft:8},children:["Capture warning: ",Ie(z)," The query result is still valid."]}):null,t.jsx(Jr,{run:n,t:r,onSelect:b}),J.map(T=>t.jsx(Js,{run:n,artifact:T,selected:T.id===l,t:r,themeMode:i,onInspect:de=>V(T.id,de)},T.id)),E.map(T=>{const de=re(T),ue=T.id===l;return t.jsxs("button",{type:"button",className:"dql-ask-chip",onClick:()=>V(T.id,qn(n,T)),style:{display:"flex",alignItems:"center",gap:10,width:"fit-content",maxWidth:"100%",padding:"9px 12px",borderRadius:10,border:`1px solid ${ue?"var(--accent)":"var(--border-default)"}`,background:"var(--bg-2)",boxShadow:ue?"0 1px 6px rgba(107,93,211,0.12)":"none",cursor:"pointer",textAlign:"left",fontFamily:r.font},children:[t.jsx("span",{style:{width:30,height:30,borderRadius:7,background:T.trustState==="certified"?"var(--status-success-bg)":"var(--accent-dim)",color:T.trustState==="certified"?"var(--status-success)":"var(--accent)",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(it,{kind:T.kind})}),t.jsxs("span",{style:{display:"flex",flexDirection:"column",gap:1,minWidth:0},children:[t.jsx("span",{style:{fontSize:12.5,fontWeight:650,color:r.textPrimary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ie(T.title)}),t.jsx("span",{style:{fontSize:11,color:r.textMuted},children:Jt(T,de)})]}),t.jsx(Cr,{size:14,color:r.textMuted,style:{flexShrink:0,marginLeft:6}})]},T.id)}),P.length>0?t.jsx("div",{style:{display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},children:P.map(T=>t.jsx(di,{artifact:T,t:r,themeMode:i,onInsertSql:p,onInsertDql:f,insertDqlActionLabel:d,sourceRunId:n.id,sourceQuestion:n.question,onOpenBlock:h,onOpenResearch:m,onOpenApp:u,onNextAction:k},T.id))}):null,D||I||X||Y||ae||w||Q?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:2,flexWrap:"wrap",marginTop:-2},children:[X&&f?t.jsxs("button",{type:"button",className:"dql-ask-ghost",onClick:()=>f(X),style:We(r),children:[t.jsx(yt,{size:12})," ",d]}):null,X&&a&&g?t.jsxs("button",{type:"button",className:"dql-ask-ghost",onClick:()=>a(X),style:We(r),children:[t.jsx(Di,{size:12})," ",g]}):null,D||I?t.jsxs("button",{type:"button",className:"dql-ask-ghost",onClick:ve,style:We(r),children:[N?t.jsx(vt,{size:12}):t.jsx(_r,{size:12})," ",N?"Copied":"Copy"]}):null,Y?t.jsx(_n,{run:n,t:r,appContext:o,onOpenApp:u}):null,ae?t.jsxs("button",{type:"button",className:"dql-ask-ghost",onClick:()=>k({id:"save-dql-block",label:"Save as block",route:"dql_block_draft"}),style:We(r),children:[t.jsx(kt,{size:12})," Save as block"]}):null,w?t.jsxs("button",{type:"button",className:"dql-ask-ghost",onClick:()=>k({id:"research-deeper",label:"Research this deeper",route:"research"}),style:We(r),children:[t.jsx(Ye,{size:12})," Research deeper"]}):null,Q?t.jsxs("button",{type:"button",className:"dql-ask-ghost",onClick:()=>V(Q.id,Zt(re(Q))?"how":"trust"),style:We(r),children:[t.jsx(St,{size:12})," How it was answered"]}):null]}):null]})}function Jr({run:e,t:n,onSelect:r}){var i;return e.status!=="needs_clarification"||!((i=e.clarificationOptions)!=null&&i.length)||!r?null:t.jsx("div",{"aria-label":"Choose a governed meaning",style:{display:"grid",gap:7,maxWidth:620},children:e.clarificationOptions.map(s=>t.jsxs("button",{type:"button",className:"dql-hover dql-lift",onClick:()=>r(s),title:`Use governed evidence ${s.id}`,style:{display:"grid",gap:3,width:"100%",padding:"10px 12px",borderRadius:10,border:"1px solid var(--border-default)",background:"var(--bg-2)",color:n.textPrimary,cursor:"pointer",textAlign:"left",fontFamily:n.font},children:[t.jsx("span",{style:{fontSize:12.5,fontWeight:700},children:s.label}),s.description?t.jsx("span",{style:{fontSize:11,lineHeight:1.4,color:n.textMuted},children:s.description}):null]},s.id))})}function Zr(e){const n=e.executionError;if(typeof n=="string"&&n.trim())return{stage:"execution",message:n};const r=R(n);if(r)return{stage:"execution",...r};const i=typeof e.refusalCode=="string"?e.refusalCode:void 0;if(i){const s=R(e.refusalDetails),o=typeof(s==null?void 0:s.message)=="string"&&s.message.trim()?s.message:typeof e.answer=="string"&&e.answer.trim()?e.answer:"No answer was accepted for this question.";return{stage:"answer",code:i,message:o}}}function Zt(e){return!!(R(e.resolvedAnalyticalPlan)||R(e.analyticalExecutionGraph)||R(e.analyticalExecutionReceipt)||R(e.analyticalFailure)||R(e.semanticExecutionTrace)||R(e.diagnosticReceipt)||R(e.diagnosticReceiptV3)||R(e.diagnosticReceiptV4)||Zr(e))}function ei(e){if(!Zt(e))return;const n=R(e.diagnosticReceipt),r=R(e.diagnosticReceiptV3),i=R(e.diagnosticReceiptV4),s=i||r?{...n,...r,...i,failure:(r==null?void 0:r.failure)??(n==null?void 0:n.failure)}:n,o=R(e.resolvedAnalyticalPlan)??R(s==null?void 0:s.resolvedAnalyticalPlan);return{plan:o,frame:R(o==null?void 0:o.analyticalFrame),graph:R(e.analyticalExecutionGraph),receipt:R(e.analyticalExecutionReceipt),facts:R(e.analyticalFacts),narrative:R(e.analyticalNarrative),freshness:R(e.analyticalFreshnessObservation),failure:R(e.analyticalFailure)??R(s==null?void 0:s.failure)??Zr(e),semantic:R(e.semanticExecutionTrace),diagnostic:s,...Zs(i==null?void 0:i.summary)?{decisionSummary:i.summary}:{}}}function Zs(e){const n=R(e);return(n==null?void 0:n.version)===1&&typeof n.summaryFingerprint=="string"&&R(n.understoodRequest)!==void 0&&Array.isArray(n.evidenceByRole)&&Array.isArray(n.tierDecisions)&&typeof n.safeNextAction=="string"}function eo(){return["Performance & provider egress","Plan","DQL","Compiled SQL","Lineage","Trust & evidence","Actual steps","Failure & repair"]}function to(e){return[e.includes("retry_same_plan")?"Retry same plan":void 0,e.includes("refresh_snapshot")?"Refresh snapshot and prepare retry":void 0,e.includes("request_access")||e.includes("change_authorized_connection")?"Change connection or request access":void 0,e.includes("edit_dql")?"Open DQL to repair":void 0,e.includes("open_sql_notebook")?"Open SQL in Notebook":void 0,e.includes("reapply_semantic_runtime")?"Reapply semantic runtime settings":void 0].filter(n=>!!n)}function no(e){var p,f;const n=new Map;let r=0,i=0,s=0,o=0;for(const a of e.spans){let d;a.name==="provider.attempt"?((f=R((p=R(a.payload))==null?void 0:p.attempt))==null?void 0:f.admission)!=="denied"&&(r+=1,d="provider"):a.name==="tool.call"?(i+=1,d="tool"):a.name==="sql.execute"?(s+=1,d="sql"):a.name==="sql.repair"&&(o+=1,d="repair");const g=xr(a.durationMs);if(g===void 0)continue;const h=d??(a.stage==="provider"||a.stage==="tool"||a.stage==="sql"||a.stage==="request"?void 0:a.stage);h&&n.set(h,(n.get(h)??0)+g)}const c=["conversation","snapshot","retrieval","meaning","cascade","plan","provider","tool","sql","repair","result","narration","research","persistence"].flatMap(a=>n.has(a)?[`${a}: ${Fe(n.get(a))}`]:[]).join(" · "),u=n.get("sql");return{totalDurationMs:xr(e.envelope.durationMs),sqlExecutionDurationMs:u,stages:c||"No completed physical provider, tool, SQL, or repair stage was recorded.",providerAttempts:r,toolCalls:i,sqlExecutions:s,repairs:o}}function xr(e){return typeof e=="number"&&Number.isFinite(e)&&e>=0?e:void 0}function xn(e,n){var u;if(n){const p=no(n),f=yn(e,p.providerAttempts),a=p.totalDurationMs===void 0?void 0:Math.max(0,p.totalDurationMs-(p.sqlExecutionDurationMs??0)),d=Array.from(new Set((e.artifacts??[]).flatMap(h=>{var W;const m=re(h),b=R(m.resolvedAnalyticalPlan)??R((W=R(m.diagnosticReceipt))==null?void 0:W.resolvedAnalyticalPlan),k=R(m.analyticalExecutionReceipt);return[b==null?void 0:b.planId,k==null?void 0:k.planId].filter(L=>typeof L=="string"&&L.length>0)}))),g=Array.from(new Set((e.artifacts??[]).map(h=>h.id).filter(h=>typeof h=="string"&&h.length>0)));return[["Total",p.totalDurationMs===void 0?"Not recorded":Fe(p.totalDurationMs)],["Warehouse",p.sqlExecutionDurationMs===void 0?"Not recorded":Fe(p.sqlExecutionDurationMs)],["Orchestration",a===void 0?"Not recorded":Fe(a)],["Stages",p.stages],["Calls",`${p.providerAttempts} provider · ${p.toolCalls} tool · ${p.sqlExecutions} SQL · ${p.repairs} repair`],["Provider rows",f],["Trace evidence","Canonical local physical trace"],...e.narrationIntegrityReceipt?[["Narration",yr(e.narrationIntegrityReceipt)]]:[],["Plan ID",d.length>0?d.join(", "):"Not recorded"],["Artifact IDs",g.length>0?g.join(", "):"None"],["Fallback",((u=e.telemetry)==null?void 0:u.fallbackReason)??"None"]]}const r=e.telemetry;if(!r)return;const i=r.stageDurationsMs.total,s=r.warehouseDurationMs,o=i===void 0||s===void 0?void 0:Math.max(0,i-s),l=Array.from(new Set((e.artifacts??[]).flatMap(p=>{var g;const f=re(p),a=R(f.resolvedAnalyticalPlan)??R((g=R(f.diagnosticReceipt))==null?void 0:g.resolvedAnalyticalPlan),d=R(f.analyticalExecutionReceipt);return[a==null?void 0:a.planId,d==null?void 0:d.planId].filter(h=>typeof h=="string"&&h.length>0)}))),c=Array.from(new Set((e.artifacts??[]).map(p=>p.id).filter(p=>typeof p=="string"&&p.length>0)));return[["Total",Fe(r.stageDurationsMs.total)],["Warehouse",r.warehouseDurationMs===void 0?"Not recorded":Fe(r.warehouseDurationMs)],["Orchestration",o===void 0?"Not recorded":Fe(o)],["Stages",Object.entries(r.stageDurationsMs).filter(([p])=>p!=="total").map(([p,f])=>`${p}: ${Fe(f)}`).join(" · ")],["Calls",`${r.providerRoundTrips} provider · ${r.toolCalls} tool · ${r.sqlExecutions} SQL · ${r.repairs} repair`],["Provider rows",yn(e,r.providerRoundTrips)],...e.narrationIntegrityReceipt?[["Narration",yr(e.narrationIntegrityReceipt)]]:[],["Plan ID",l.length>0?l.join(", "):"Not recorded"],["Artifact IDs",c.length>0?c.join(", "):"None"],["Fallback",r.fallbackReason??"None"]]}function yn(e,n){if(n===0)return"0 result rows sent to providers (0 content-free receipts)";const r=e.providerEgressReceipts??[];if(r.length===0)return`No retained egress receipt for ${n} recorded provider attempt${n===1?"":"s"}`;const i=r.filter(f=>f.resultRowCount>0),s=i.reduce((f,a)=>f+a.resultRowCount,0),o=f=>{const a=typeof f.dispatchPhase=="string"?f.dispatchPhase:typeof f.purpose=="string"?f.purpose:void 0;return a==null?void 0:a.replace(/_/g," ")},l=[...new Set(r.filter(f=>f.resultRowCount===0).map(o).filter(f=>!!f))];if(s===0){const f=l.length>0?` ${l.join(", ")}`:"";return`0 result rows sent to providers (${r.length} content-free${f} receipt${r.length===1?"":"s"})`}const c=[...new Set(i.map(o).filter(f=>!!f))];return i.every(f=>f.legacyReadOnly===!0)?`${s} bounded, redacted legacy non-Research result row${s===1?"":"s"} retained as read-only evidence; not a current egress authority`:e.requestedMode==="research"&&i.every(f=>f.purpose==="research_narration"||f.purpose==="research_tool")?`${s} bounded, redacted Research result row${s===1?"":"s"} sent with explicit run consent${c.length?` during ${c.join(", ")}`:""}`:`${s} bounded, redacted Ask result row${s===1?"":"s"} sent during ${c.join(", ")||"an unrecorded provider phase"}`}function ro(e){var o,l;const n=(o=e.traceReference)==null?void 0:o.traceId,r=(l=e.traceReference)==null?void 0:l.recordingStatus,[i,s]=x.useState(()=>n?{state:"loading"}:{state:"legacy"});return x.useEffect(()=>{let c=!0;return n?r==="unavailable"||r==="detail_expired"?(s({state:"unavailable"}),()=>{c=!1}):(s({state:"loading"}),oe.getAskTraceByRun(e.id).then(u=>{c&&s(u.envelope.runId===e.id?{state:"loaded",trace:u}:{state:"unavailable"})}).catch(()=>{c&&s({state:"unavailable"})}),()=>{c=!1}):(s({state:"legacy"}),()=>{c=!1})},[e.id,n,r]),i.state==="loaded"&&i.trace.envelope.runId!==e.id?{state:"loading"}:i}function yr(e){return e.outcome==="skipped"?`Skipped${e.skipReason?` (${e.skipReason.replace(/_/g," ")})`:""}`:e.outcome==="success"?e.mode==="verified_facts"?`Fact-verified (${e.factCount} facts)`:"Preview-grounded":e.outcome==="deterministic_fallback"?`Deterministic fallback${e.validationFailures.length>0?` (${e.validationFailures.join(", ")})`:""}`:"Narration unavailable; the retained answer was not replaced."}function io({run:e,contract:n,dqlArtifact:r,sql:i,lineage:s,t:o,onInsertSql:l,onInsertDql:c,onSaveBlock:u}){var Ze,at,lt,Ne,ct,dt,Me,he;const{dispatch:p}=Ut(),f=n.plan,a=n.frame,d=n.graph,g=n.receipt,h=n.semantic,m=R(h==null?void 0:h.failure),b=n.failure??m,k=((Ze=e.diagnosticReceiptV4)==null?void 0:Ze.summary)??n.decisionSummary,W=k==null?void 0:k.researchBranchSummary,L=(W==null?void 0:W.partialSuccess)===!0?W:void 0,N=R(h==null?void 0:h.authoringRequest),$=R(h==null?void 0:h.runtimeRequest),V=Se(h==null?void 0:h.bindings),Z=Se(h==null?void 0:h.steps),F=R(h==null?void 0:h.targetBinding),M=R(F==null?void 0:F.semanticSnapshot),ie=R(F==null?void 0:F.executionTarget),D=R(ie==null?void 0:ie.redactedContext),_=R(F==null?void 0:F.compileTarget),I=R(h==null?void 0:h.executionReceipt),z=Se(m==null?void 0:m.candidates),v=R((at=n.diagnostic)==null?void 0:at.cascade),U=Se((lt=n.diagnostic)==null?void 0:lt.sourceCoverage),J=Se(v==null?void 0:v.attempts),K=R((Ne=n.diagnostic)==null?void 0:Ne.provider),E=R(a==null?void 0:a.timeContext),P=R(a==null?void 0:a.comparison),Q=R(a==null?void 0:a.ranking),se=Se(a==null?void 0:a.dimensions),pe=Se(a==null?void 0:a.memberBindings),me=Se(E==null?void 0:E.periods),Y=Se(a==null?void 0:a.requestedOutputs),A=Se(d==null?void 0:d.nodes),te=Array.from(new Set([...Ae(b==null?void 0:b.safeActions),...Ae(m==null?void 0:m.safeActions)])),w=Se(b==null?void 0:b.failedBindings),q=R(m==null?void 0:m.sqlExcerpt),ae=e.artifacts.map(S=>Te(re(S))).find(Boolean),X=ro(e),ve=X.state==="loaded"?xn(e,X.trace):X.state==="legacy"?xn(e):void 0,T=(r==null?void 0:r.name)??e.question,[de,ue]=x.useState(null),be=(S,ee)=>{const ke=ee.derivation.trustTransition;return`${S} as immutable derivation ${ee.derivation.derivationId}. Trust: ${ke.previous} → ${ke.next}${ke.requiresReview?" (review required)":""}.`},st=async()=>{if(!(!(r!=null&&r.source)||!c))try{const S=await oe.deriveAnalyticalRepair(e.id,{version:1,action:"edit_dql",dqlSource:r.source});c({sql:i,dqlArtifact:r,result:ae,title:T,sourceRunId:e.id,question:e.question}),ue(be("Opened DQL in Notebook",S))}catch(S){ue(S instanceof Error?S.message:String(S))}},Xe=async()=>{if(!(!i||!l))try{const S=await oe.deriveAnalyticalRepair(e.id,{version:1,action:"open_sql_notebook",sqlText:i});l(i,`${T} repair`,{question:e.question,sourceRunId:e.id}),ue(be("Opened SQL in Notebook",S))}catch(S){ue(S instanceof Error?S.message:String(S))}},ot=async S=>{try{const ee=await oe.deriveAnalyticalRepair(e.id,{version:1,action:S});ue(be(S==="retry_same_plan"?"Prepared the same bounded plan for retry":"Refreshed the governed snapshot and prepared the same plan for retry",ee))}catch(ee){ue(ee instanceof Error?ee.message:String(ee))}},At=async()=>{try{const S=await oe.deriveAnalyticalRepair(e.id,{version:1,action:"request_access"});ue(be("Recorded the access/connection repair and opened Database settings",S)),p({type:"SET_SETTINGS_TAB",tab:"database"}),p({type:"SET_MAIN_VIEW",view:"settings"})}catch(S){ue(S instanceof Error?S.message:String(S))}},Je=()=>{p({type:"SET_SETTINGS_TAB",tab:"project"}),p({type:"SET_MAIN_VIEW",view:"settings"}),ue("Opened Project & dbt settings. Test and apply the intended dbt Cloud Semantic Layer environment to refresh its verified metric inventory.")};return t.jsxs("div",{style:{display:"grid",gap:9},"aria-label":"How it answered",children:[t.jsxs("div",{role:"status",style:{display:"flex",gap:8,alignItems:"flex-start",padding:"10px 12px",borderRadius:8,border:`1px solid ${b?"var(--status-error-border)":"var(--status-success-border)"}`,background:b?"var(--status-error-bg)":"var(--status-success-bg)"},children:[b?t.jsx(He,{size:13,color:"var(--status-error)",style:{flexShrink:0,marginTop:2}}):t.jsx(we,{size:13,color:"var(--status-success)",style:{flexShrink:0,marginTop:2}}),t.jsxs("div",{style:{fontSize:12,color:o.textSecondary,lineHeight:1.5,minWidth:0},children:[t.jsx("div",{style:{fontWeight:700,color:b?"var(--status-error)":"var(--status-success)"},children:b?"Execution failed":"Answered successfully"}),b?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{marginTop:3,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:o.fontMono,fontSize:11},children:typeof b.message=="string"&&b.message.trim()?b.message:"The engine did not report a message. Open the DQL and SQL tabs to inspect what ran."}),t.jsx("div",{style:{marginTop:4,fontSize:10.5,color:o.textMuted},children:[b.code,b.phase?`during ${b.phase}`:""].filter(Boolean).map(C).join(" · ")})]}):t.jsx("div",{style:{marginTop:2},children:typeof(g==null?void 0:g.rowCount)=="number"?`Returned ${g.rowCount} row${g.rowCount===1?"":"s"}.`:"The query ran and returned a result."})]})]}),e.traceReference?t.jsxs("button",{type:"button",className:"dql-hover",onClick:()=>p({type:"OPEN_ASK_TRACE",runId:e.id}),style:{display:"inline-flex",alignItems:"center",justifySelf:"start",gap:5,background:"transparent",border:"none",cursor:"pointer",padding:"1px 0",color:o.accent,fontSize:11.5,fontFamily:o.font,fontWeight:700},title:"Open the local, redacted Ask trace",children:[t.jsx(Yt,{size:12})," Open full trace"]}):null,k?t.jsx(ti,{summary:k,t:o}):t.jsx(si,{t:o}),t.jsxs(ht,{index:1,label:"Performance & provider egress",t:o,open:!0,children:[X.state==="loading"?t.jsx(Ve,{t:o,children:"Loading the local physical trace. Legacy counters are withheld until its recorded attempts are available."}):ve?t.jsx(tt,{rows:ve,t:o}):X.state==="unavailable"?t.jsx(Ve,{t:o,children:"Canonical physical performance evidence is unavailable for this trace-backed run."}):t.jsx(Ve,{t:o,children:"Performance details were not recorded for this legacy run."}),X.state==="unavailable"&&e.traceReference?t.jsx("p",{style:{margin:0,color:o.textMuted,fontSize:10.5,lineHeight:1.45},children:"The local trace detail is unavailable, so physical provider and SQL counters are not shown for this trace-backed run."}):null]}),t.jsx(ht,{index:2,label:"Plan",t:o,open:!b,children:t.jsx(tt,{rows:[["Question type",C((a==null?void 0:a.questionType)??(f==null?void 0:f.questionType))],["Selected route",C((d==null?void 0:d.route)??(f==null?void 0:f.recommendedRoute))],["Metric",Ae(a==null?void 0:a.metricConceptIds).join(", ")],["Entity grain",Ae(a==null?void 0:a.entityGrainIds).join(", ")],["Dimensions",se.map(S=>`${C(S.dimensionId)} (${C(S.role)})`).join(", ")],["Member filters",pe.map(S=>`${C(S.dimensionId)}: ${Array.isArray(S.canonicalValues)?S.canonicalValues.length:0} bound value(s)`).join(", ")],["Time policy",[E==null?void 0:E.timeRole,E==null?void 0:E.grain,E==null?void 0:E.timezone,E==null?void 0:E.completenessPolicy].map(C).filter(Boolean).join(" · ")],["Periods",me.map(S=>`${C(S.id)}: ${C(S.start)} → ${C(S.end)}`).join(`
|
|
85
|
+
`)],["Comparison",P?`${C(P.basePeriodId)} vs ${Ae(P.comparisonPeriodIds).join(", ")} · ${C(P.alignment)}`:a?"Not requested":"Not available — analytical planning did not complete"],["Ranking",Q?`${C(Q.direction)} · top ${C(Q.limit)} · ${C(Q.tiePolicy)}`:a?"Not requested":"Not available — analytical planning did not complete"],["Outputs",Y.map(S=>`${C(S.id)} (${C(S.kind)})`).join(", ")],["Semantic metrics",Ae(N==null?void 0:N.metrics).join(", ")],["Semantic dimensions",Ae(N==null?void 0:N.dimensions).join(", ")]],t:o})}),t.jsx(ht,{index:3,label:"Trust & evidence",t:o,children:t.jsx(tt,{rows:[["Trust state",e.trustState],["Snapshot",C((f==null?void 0:f.snapshotId)??(d==null?void 0:d.snapshotId))],["Plan fingerprint",C((f==null?void 0:f.fingerprint)??(d==null?void 0:d.planFingerprint))],["Graph fingerprint",C(d==null?void 0:d.fingerprint)],["Receipt",C(g==null?void 0:g.receiptId)],["Result fingerprint",C(g==null?void 0:g.resultFingerprint)],["Freshness observed through",C((ct=n.freshness)==null?void 0:ct.observedThrough)],["Fact set",C((dt=n.facts)==null?void 0:dt.fingerprint)],["Semantic adapter",C(h==null?void 0:h.adapter)],["Semantic compile status",C(h==null?void 0:h.status)],["Target proof",C((Me=R(F==null?void 0:F.proof))==null?void 0:Me.status)],["Target binding",C(F==null?void 0:F.bindingFingerprint)],["Compile target",C(_==null?void 0:_.kind)],["Local semantic snapshot",C((M==null?void 0:M.semanticCatalogFingerprint)??(M==null?void 0:M.sourceFingerprint))],["Runtime metric inventory proof",C(_==null?void 0:_.semanticCatalogFingerprint)],["Execution target",[ie==null?void 0:ie.driver,D==null?void 0:D.account,D==null?void 0:D.database,D==null?void 0:D.schema,D==null?void 0:D.role,D==null?void 0:D.warehouse].map(C).filter(Boolean).join(" · ")],["Semantic receipt",C(I==null?void 0:I.receiptId)],["Warehouse query ID",C(I==null?void 0:I.queryId)],["Executed SQL proof",C(I==null?void 0:I.executedSqlFingerprint)],["Runtime metrics",Ae($==null?void 0:$.metrics).join(", ")],["Runtime dimensions",Ae($==null?void 0:$.dimensions).join(", ")],["Member bindings",V.map(S=>`${C(S.authoringReference)} → ${C(S.runtimeReference)}${Ae(S.entityPath).length?` via ${Ae(S.entityPath).join(" → ")}`:""} (${C(S.status)})`).join(`
|
|
86
|
+
`)],["Cascade",C(v==null?void 0:v.selectedTier)||C(v==null?void 0:v.stopReason)],["Plan frozen",C((he=n.diagnostic)==null?void 0:he.planFrozen)],["Provider phase/cause",[C(K==null?void 0:K.phase),C(K==null?void 0:K.cause)].filter(Boolean).join(" · ")],["Provider recovery",C(K==null?void 0:K.safeAction)],["Source coverage",U.map(S=>`${C(S.source)}: ${C(S.status)}`).join(`
|
|
87
|
+
`)]],t:o,mono:!0})}),t.jsx(ht,{index:4,label:"Actual steps",t:o,children:t.jsxs("div",{style:{display:"grid",gap:6},children:[Z.map((S,ee)=>t.jsxs("div",{style:{fontSize:11.5,color:o.textSecondary},children:[t.jsxs("strong",{style:{color:C(S.status)==="failed"?"var(--status-error)":o.textPrimary},children:[ee+1,". ",C(S.label)]})," ","— ",C(S.status)," · ",C(S.detail)]},`semantic:${C(S.id)||ee}`)),e.steps.map(S=>t.jsxs("div",{style:{fontSize:11.5,color:o.textSecondary},children:[t.jsxs("strong",{style:{color:o.textPrimary},children:[S.index+1,". ",S.goal]})," — ",S.status,", ",S.attempts," attempt",S.attempts===1?"":"s"]},S.id)),A.map((S,ee)=>t.jsxs("div",{style:{fontSize:11.5,color:o.textSecondary},children:[t.jsxs("span",{style:{color:o.accent,fontFamily:o.fontMono},children:[ee+1,". ",C(S.kind)]})," ","· ",C(S.id)]},C(S.id)||ee)),J.map((S,ee)=>t.jsxs("div",{style:{fontSize:11.5,color:o.textSecondary},children:[t.jsxs("span",{style:{color:o.accent,fontFamily:o.fontMono},children:[ee+1,". ",C(S.tier)]})," ","— ",C(S.outcome)," · ",C(S.reason)]},`cascade:${C(S.tier)}:${ee}`)),Z.length===0&&e.steps.length===0&&A.length===0&&J.length===0?t.jsx(Ve,{t:o,children:"No executable steps were recorded."}):null]})}),t.jsx(ht,{index:5,label:"Failure & repair",t:o,open:!!(b||L),children:b?t.jsxs("div",{style:{display:"grid",gap:9},children:[t.jsx(tt,{rows:[["Failure ID",C(b.failureId)],["Recoverability",C(b.recoverability)],["Failed bindings",w.map(S=>`${C(S.qualifiedId??S.role)} (${C(S.reasonCode)})`).join(", ")],["Safe actions",te.join(", ")],["DQL fingerprint",C(b.dqlFingerprint)],["SQL fingerprint",C(b.sqlFingerprint)],["Semantic failure code",C(m==null?void 0:m.code)],["Failing identifier",C(m==null?void 0:m.identifier)],["Compiled SQL proof",C(m==null?void 0:m.compiledSqlFingerprint)],["Path candidates",z.map(S=>`${C(S.label)}
|
|
88
|
+
${C(S.runtimeReference)}`).join(`
|
|
89
|
+
`)]],t:o,mono:!0}),C(q==null?void 0:q.text)?t.jsxs("div",{children:[t.jsxs("div",{style:{fontSize:10.5,fontWeight:700,color:o.textSecondary,marginBottom:5},children:["Failing SQL context · lines ",C(q==null?void 0:q.startLine),"–",C(q==null?void 0:q.endLine)]}),t.jsx("pre",{style:wt(o),children:C(q==null?void 0:q.text)})]}):null,t.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:6},"aria-label":"Safe repair actions",children:[te.includes("edit_dql")&&c?t.jsxs("button",{type:"button",onClick:()=>void st(),style:ne(o),children:[t.jsx(Xt,{size:12})," Open DQL to repair"]}):null,te.includes("open_sql_notebook")&&l?t.jsxs("button",{type:"button",onClick:()=>void Xe(),style:ne(o),children:[t.jsx(kn,{size:12})," Open SQL in Notebook"]}):null,te.includes("retry_same_plan")?t.jsxs("button",{type:"button",onClick:()=>void ot("retry_same_plan"),style:ne(o),children:[t.jsx(rn,{size:12})," Retry same plan"]}):null,te.includes("refresh_snapshot")?t.jsxs("button",{type:"button",onClick:()=>void ot("refresh_snapshot"),style:ne(o),children:[t.jsx(rn,{size:12})," Refresh snapshot and prepare retry"]}):null,te.includes("request_access")||te.includes("change_authorized_connection")?t.jsxs("button",{type:"button",onClick:()=>void At(),style:ne(o),children:[t.jsx(He,{size:12})," Change connection or request access"]}):null,te.includes("reapply_semantic_runtime")?t.jsxs("button",{type:"button",onClick:Je,style:ne(o),children:[t.jsx(rn,{size:12})," Reapply semantic runtime settings"]}):null]})]}):L?t.jsx(ni,{summary:L,t:o}):t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx(Ve,{t:o,children:"No failure was recorded for this run."}),r!=null&&r.sourcePath?null:r!=null&&r.source?t.jsxs("button",{type:"button",onClick:u,style:ne(o),children:[t.jsx(Rn,{size:12})," Save as draft block"]}):null]})}),de?t.jsx("div",{role:"status",style:{fontSize:10.5,color:de.toLowerCase().includes("created")?"var(--status-success)":"var(--status-error)"},children:de}):null]})}function ti({summary:e,t:n}){const r=e.understoodRequest,i=e.researchBranchSummary,s=(i==null?void 0:i.partialSuccess)===!0,o=[["Understood request",`${r.measures} measure${r.measures===1?"":"s"}, ${r.dimensions} dimension${r.dimensions===1?"":"s"}${r.entityRequested?", an entity output":""}${r.ranking?`, ${r.ranking.direction} ${r.ranking.limit}${r.ranking.defaultedLimit?" (default)":""}`:""}. Conversation binding: ${r.conversationBinding.replace(/_/g," ")}.`],["Evidence by role",e.evidenceByRole.length>0?e.evidenceByRole.map(c=>`${c.role.replace(/_/g," ")}: ${c.candidateCount}`).join(" · "):"No role evidence was retained for this legacy-compatible run."],["Tier decisions",e.tierDecisions.length>0?e.tierDecisions.map(c=>`${c.tier}: ${c.outcome}${c.planFrozen?" (frozen)":""}`).join(" · "):"No cascade tier receipt was recorded."],["Selected plan",e.selectedPlan?`${e.selectedPlan.tier.replace(/_/g," ")}${e.selectedPlan.planFrozen?" frozen":""}${e.selectedPlan.reviewRequired?"; review required":""}.`:"No executable plan was selected."],...i?[["Research branch evidence",ii(i)]]:[],["Failure or repair",e.terminalIncident?`${e.terminalIncident.code.replace(/_/g," ")} at ${e.terminalIncident.boundary}; ${e.terminalIncident.impact.replace(/_/g," ")}.`:s?`Research limitations: ${i.failedBranches+i.timedOutBranches+i.skippedBranches} child branches did not complete; completed receipt-backed findings remain available.`:"No terminal incident was recorded."],["Safe next action",ri(e.safeNextAction)],["Summary fingerprint",e.summaryFingerprint]],l=!!(e.terminalIncident||s);return t.jsxs("section",{"aria-label":"Ask decision story",style:{padding:"10px 12px",borderRadius:8,border:`1px solid ${l?"var(--status-error-border)":"var(--status-success-border)"}`,background:l?"var(--status-error-bg)":"var(--status-success-bg)"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:l?"var(--status-error)":"var(--status-success)",fontSize:12,fontWeight:750,marginBottom:8},children:[l?t.jsx(He,{size:13}):t.jsx(we,{size:13}),"Ask decision story"]}),t.jsx(tt,{rows:o,t:n,mono:!0})]})}function ni({summary:e,t:n}){const r=e.failedBranches+e.timedOutBranches+e.skippedBranches;return t.jsx("div",{"aria-label":"Research branch limitations",style:{display:"grid",gap:8},children:t.jsx(tt,{rows:[["Root outcome","The root Research answer remains successful; these child limitations are not a terminal incident."],["Research branch evidence",ii(e)],["Limitations",`${r} child ${r===1?"branch did":"branches did"} not complete. Receipt-backed findings remain available.`],["Safe next action",ri(e.safeAction)]],t:n})})}function ri(e){return e==="inspect_research_failures"?"Inspect failed or timed-out branches; retry narrower Research if the missing evidence matters.":e.replace(/_/g," ")}function ii(e){const n=e.failureReasons.length>0?e.failureReasons.map(i=>`${i.code.replace(/_/g," ")}: ${i.branchCount}`).join(" · "):"no displayable reason code",r=e.availableChildPlans.length>0?` Persisted child plans: ${e.availableChildPlans.map(i=>`${i.tier.replace(/_/g," ")} frozen ×${i.frozenPlanCount} for ${i.branchCount} ${i.branchCount===1?"branch":"branches"}${i.reviewRequired?" (review required)":""}`).join(" · ")}.`:" No frozen child plan evidence was retained.";return`${e.receiptBackedBranches} receipt-backed ${e.receiptBackedBranches===1?"finding":"findings"} · ${e.failedBranches} failed · ${e.timedOutBranches} timed out · ${e.skippedBranches} skipped. Reasons: ${n}.${r} ${e.linkedChildRunCount} linked child ${e.linkedChildRunCount===1?"run":"runs"}.`}function si({t:e}){return t.jsxs("section",{"aria-label":"Ask decision story unavailable",style:{padding:"10px 12px",borderRadius:8,border:"1px solid var(--status-warning-border)",background:"var(--status-warning-bg)",color:e.textSecondary,fontSize:12,lineHeight:1.45},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,color:"var(--status-warning)",fontSize:12,fontWeight:750,marginBottom:4},children:[t.jsx(He,{size:13})," Ask decision story"]}),t.jsxs("div",{children:[Er,"."]}),t.jsx("div",{style:{marginTop:3,color:e.textMuted,fontSize:11.5},children:"Open the full trace to inspect its raw advanced evidence."})]})}function ht({index:e,label:n,t:r,open:i=!1,children:s}){return t.jsxs("details",{open:i,style:{border:"1px solid var(--border-subtle)",borderRadius:8,background:"var(--bg-1)",overflow:"hidden"},children:[t.jsxs("summary",{style:{cursor:"pointer",listStyle:"none",padding:"8px 10px",display:"flex",gap:7,alignItems:"center",fontSize:11.5,fontWeight:700,color:r.textPrimary},children:[t.jsx("span",{style:{width:18,height:18,borderRadius:999,display:"inline-flex",alignItems:"center",justifyContent:"center",background:"var(--accent-dim)",color:"var(--accent)",fontSize:10},children:e}),n]}),t.jsx("div",{style:{display:"grid",gap:8,padding:"0 10px 10px"},children:s})]})}function tt({rows:e,t:n,mono:r=!1}){return t.jsx("div",{style:{display:"grid",gap:6},children:e.filter(([,i])=>i).map(([i,s])=>t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"112px minmax(0, 1fr)",gap:8,alignItems:"start"},children:[t.jsx("span",{style:{fontSize:10.5,color:n.textMuted},children:i}),t.jsx("span",{style:{fontSize:10.5,color:n.textSecondary,fontFamily:r?n.fontMono:n.font,whiteSpace:"pre-wrap",overflowWrap:"anywhere"},children:s})]},i))})}function Ve({t:e,children:n}){return t.jsx("div",{style:{fontSize:11,color:e.textMuted},children:n})}function Se(e){return Array.isArray(e)?e.flatMap(n=>R(n)?[R(n)]:[]):[]}function Ae(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):[]}function C(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function Fe(e){return typeof e!="number"||!Number.isFinite(e)||e<0?"Not recorded":e>=1e3?`${(e/1e3).toFixed(e>=1e4?0:1)}s`:`${Math.round(e)}ms`}function Dt(e,n){var i;const r=n==null?void 0:n.trim();return{question:((i=e.question)==null?void 0:i.trim())||r||e.label,selectedEvidenceId:e.id}}function oi(e){var i;const n=e.artifacts.map(s=>Te(re(s))).find(s=>!!s),r=(i=e.artifacts.find(s=>s.ref))==null?void 0:i.ref;return{runId:e.id,question:e.question,trustState:e.trustState,executionTarget:e.executionTarget,sourceCertifiedBlock:r,sql:_e(e),dqlArtifact:$e(e),...n?{result:{columns:n.columns,rows:n.rows.slice(0,24),rowCount:n.rowCount}}:{}}}function Rt(e){return!e.artifacts.some(r=>!!en(re(r)))&&e.status!=="blocked"&&e.status!=="cancelled"&&e.stopReason!=="cancelled"&&e.status!=="needs_clarification"&&(e.artifacts.some(r=>r.kind==="answer"||r.kind==="research_run")||!!($e(e)??_e(e)))}function so({run:e,artifact:n,tab:r,t:i,appContext:s,onOpenApp:o,onChangeTab:l,onClose:c,onSaveBlock:u,onInsertSql:p,onInsertDql:f}){const a=re(n),d=$e(e)??Ct(a),g=_e(e)??(typeof a.sql=="string"?a.sql:void 0),h=Te(a),m=bt(e,n),b=$n(e),k=Xr(e),W=zn(e),L=n.trustState==="certified",N=e.status==="cancelled"||e.stopReason==="cancelled"||e.route==="cancelled",$=!N&&(e.status==="blocked"||n.trustState==="blocked"),V=Rt(e),Z=ei(a),F=Kr({analytical:!!Z,blocked:$,hasDql:!!(d!=null&&d.source),hasSql:!!g,hasLineage:k.length>0}),M=F.some(I=>I.id===r)?r:F[0].id,ie=N?"Cancelled":$?"Blocked":L?"Certified":n.trustState==="governed"||n.trustState==="grounded"?"Governed":"AI-generated",D=N?"var(--text-tertiary)":$?"var(--status-error)":L?"var(--status-success)":n.trustState==="governed"||n.trustState==="grounded"?"var(--accent)":"var(--status-warning)",_=N?"var(--bg-3)":$?"var(--status-error-bg)":L?"var(--status-success-bg)":n.trustState==="governed"||n.trustState==="grounded"?"var(--accent-dim)":"var(--status-warning-bg)";return t.jsxs("div",{style:{width:"clamp(300px, 34vw, 440px)",flexShrink:0,background:"var(--bg-2)",borderLeft:"1px solid var(--border-default)",display:"flex",flexDirection:"column",minHeight:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"14px 16px 12px",borderBottom:"1px solid var(--border-subtle)"},children:[t.jsx("span",{style:{width:32,height:32,borderRadius:8,background:_,color:D,display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"1px solid var(--border-subtle)"},children:t.jsx(it,{kind:n.kind})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:13,fontWeight:650,color:i.textPrimary,lineHeight:1.35},children:bt(e,n)}),t.jsx("div",{style:{fontSize:11,color:i.textMuted,marginTop:2},children:Jt(n,a)})]}),t.jsx("span",{style:{border:`1px solid ${D}`,color:D,background:_,borderRadius:999,padding:"2px 8px",fontSize:10,fontWeight:700,flexShrink:0,marginTop:2},children:ie}),t.jsx("button",{type:"button",onClick:c,title:"Close",className:"dql-ask-ghost",style:{width:24,height:24,borderRadius:6,border:"none",background:"none",color:i.textMuted,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",flexShrink:0},children:t.jsx(Ft,{size:14})})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"10px 16px",borderBottom:"1px solid var(--border-subtle)"},children:[V?t.jsx(_n,{run:e,t:i,appContext:s,onOpenApp:o}):null,V?t.jsxs("button",{type:"button",className:"dql-hover",onClick:u,style:{display:"inline-flex",alignItems:"center",gap:6,padding:"7px 13px",borderRadius:8,border:"1px solid var(--border-default)",background:"var(--bg-2)",color:i.textSecondary,fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:i.font},children:[t.jsx(kt,{size:13})," Save as block"]}):null,t.jsx("div",{style:{flex:1}}),t.jsx("button",{type:"button",title:"More",className:"dql-hover",style:{width:28,height:28,borderRadius:7,border:"1px solid var(--border-default)",background:"var(--bg-2)",color:i.textMuted,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:t.jsx(Pi,{size:14})})]}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:16,padding:"0 16px",borderBottom:"1px solid var(--border-subtle)",flexShrink:0},children:F.map(I=>t.jsx("button",{type:"button",onClick:()=>l(I.id),style:{padding:"10px 1px",fontSize:12,fontWeight:600,cursor:"pointer",border:"none",background:"none",fontFamily:i.font,whiteSpace:"nowrap",color:M===I.id?i.textPrimary:i.textMuted,boxShadow:M===I.id?`inset 0 -2px 0 0 ${i.accent}`:"none"},children:I.label},I.id))}),t.jsxs("div",{style:{flex:1,minHeight:0,overflow:"auto",padding:"14px 16px 20px"},children:[M==="how"&&Z?t.jsx(io,{run:e,contract:Z,dqlArtifact:d,sql:g,lineage:k,t:i,onInsertSql:p,onInsertDql:f,onSaveBlock:u}):null,M==="dql"?d!=null&&d.source?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[t.jsx("span",{style:{fontSize:11,color:i.textMuted},children:"Reusable governed artifact — save it as a block to certify."}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[f?t.jsx("button",{type:"button",onClick:()=>f({sql:g,dqlArtifact:d,result:h,chartConfig:h?Oe(a,h):void 0,title:m,sourceRunId:e.id,question:e.question}),style:ne(i),children:"Open DQL in notebook"}):null,t.jsx(Ot,{text:d.source,t:i,title:"Copy DQL"})]})]}),t.jsx("pre",{style:wt(i),children:d.source})]}):t.jsx(Ve,{t:i,children:"The selected plan failed before a DQL source could be materialized. Review the Plan and Failure & repair sections."}):null,M==="sql"?g?t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[t.jsx("span",{style:{fontSize:11,color:i.textMuted},children:"Attempted compiled SQL — open it in Notebook to inspect or repair."}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[p?t.jsx("button",{type:"button",onClick:()=>p(g,m,{question:e.question,sourceRunId:e.id}),style:ne(i),children:"Open SQL in notebook"}):null,t.jsx(Ot,{text:g,t:i,title:"Copy SQL"})]})]}),t.jsx("pre",{style:wt(i),children:g})]}):t.jsx(Ve,{t:i,children:"Compilation stopped before SQL was produced. The DQL, plan, trust evidence, and failure steps are still retained."}):null,M==="lineage"?t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("div",{style:{fontSize:11,color:i.textMuted,lineHeight:1.5},children:"Governed semantic objects and physical sources used to produce this result."}),k.map(I=>t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:9,padding:"9px 10px",border:"1px solid var(--border-subtle)",borderRadius:8,background:"var(--bg-1)"},children:[t.jsx(Yt,{size:13,color:i.accent,style:{flexShrink:0,marginTop:2}}),t.jsxs("div",{style:{minWidth:0},children:[t.jsx("div",{style:{fontSize:12,fontWeight:650,color:i.textPrimary},children:I.name}),t.jsx("div",{style:{fontSize:10.5,color:i.textMuted,marginTop:2},children:[I.kind,I.detail].filter(Boolean).join(" · ")})]})]},`${I.kind??"asset"}:${I.name}`))]}):null,M==="trust"?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[W?t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start",padding:"10px 12px",borderRadius:8,background:L?"var(--status-success-bg)":"var(--status-warning-bg)",border:`1px solid ${L?"var(--status-success-border)":"var(--status-warning-border)"}`},children:[L?t.jsx(we,{size:13,color:"var(--status-success)",style:{flexShrink:0,marginTop:1}}):t.jsx(He,{size:13,color:"var(--status-warning)",style:{flexShrink:0,marginTop:1}}),t.jsx("span",{style:{fontSize:12,color:i.textSecondary,lineHeight:1.5},children:W})]}):null,b.length>0?t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:i.textMuted,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:"Evidence"}),t.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:b.map(I=>t.jsxs("span",{style:xi(i,I.certified),children:[I.certified?t.jsx(we,{size:11}):t.jsx(Ye,{size:11}),t.jsx("span",{children:I.label})]},I.label))})]}):null,e.evaluations.length>0?t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:i.textMuted,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:"Verification checks"}),t.jsx(ui,{evaluations:e.evaluations,t:i})]}):null,e.steps.length>0?t.jsxs("div",{children:[t.jsx("div",{style:{fontSize:11,fontWeight:700,color:i.textMuted,textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8},children:"Steps"}),t.jsx(pi,{steps:e.steps,t:i})]}):null,t.jsx(hi,{run:e,t:i})]}):null]})]})}function oo({t:e,text:n,source:r,left:i,top:s,draft:o,inputRef:l,onDraftChange:c,onClose:u,onSend:p}){const f=(a,d)=>t.jsx("button",{type:"button",onClick:()=>p(d),style:{border:"1px solid var(--border-subtle)",background:"var(--bg-1)",color:e.textSecondary,borderRadius:999,padding:"3px 10px",fontSize:11,fontWeight:550,cursor:"pointer",fontFamily:e.font},children:a});return t.jsxs("div",{"data-selpop":"true",style:{position:"fixed",left:i,top:s,zIndex:90,width:324,background:"var(--bg-2)",border:"1px solid var(--border-default)",borderRadius:12,boxShadow:"0 10px 32px rgba(26,26,26,0.16)",padding:10,display:"flex",flexDirection:"column",gap:8,animation:"dql-agent-fadein 0.14s ease-out",fontFamily:e.font},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx(Ue,{size:12,color:e.accent}),t.jsx("span",{style:{fontSize:11,fontWeight:700,color:e.textSecondary},children:"Follow up on this"}),t.jsx("span",{style:{fontSize:10,color:e.textMuted},children:r==="table"?"from the result":"from the answer"}),t.jsx("div",{style:{flex:1}}),t.jsx("button",{type:"button",onClick:u,style:{width:20,height:20,borderRadius:5,border:"none",background:"none",color:e.textMuted,display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer",padding:0},children:t.jsx(Ft,{size:12})})]}),t.jsxs("div",{style:{borderLeft:`2px solid ${e.accent}`,background:"var(--accent-dim)",borderRadius:"0 6px 6px 0",padding:"5px 9px",fontSize:11.5,color:e.textSecondary,lineHeight:1.45,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:["“",n,"”"]}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("input",{ref:l,value:o,onChange:a=>c(a.target.value),onKeyDown:a=>{a.key==="Enter"&&(a.preventDefault(),p(o))},placeholder:"Ask about this…",style:{flex:1,minWidth:0,border:"1px solid var(--border-default)",borderRadius:8,padding:"7px 10px",fontSize:12.5,fontFamily:e.font,color:e.textPrimary,background:"var(--bg-1)",outline:"none"}}),t.jsx("button",{type:"button",onClick:()=>p(o),title:"Send follow-up",style:{width:30,height:30,flexShrink:0,borderRadius:8,border:"none",background:"var(--accent)",color:"#fff",display:"inline-flex",alignItems:"center",justifyContent:"center",cursor:"pointer"},children:t.jsx(Ir,{size:13})})]}),t.jsxs("div",{style:{display:"flex",gap:5,flexWrap:"wrap"},children:[f("Why is this?","Why is this happening?"),f("Root cause","What is the root cause?"),f("Break it down","Break this down further")]})]})}function xt(e){const n=e.replace(/^\/\w+\s+/,"").trim().replace(/[?.!]+$/,"");return(n?n.charAt(0).toUpperCase()+n.slice(1):"New app").slice(0,60)}function mn(e,n){const r=e instanceof Error?e.message.trim():"";return e instanceof Ni&&e.status===405||/method not allowed/i.test(r)?"This Notebook server is older than the App Studio shown in your browser. Restart dql notebook, reload this page, and try again. No Project files were published.":r||n}function bn(e,n){return n!=null&&n.trim()?`${e} › ${n.trim()}`:e}function ai(e,n){const r=n.filter(s=>s.state!=="project_published"),i=new Set(r.flatMap(s=>{var o;return(o=s.baseApp)!=null&&o.appId?[s.baseApp.appId]:[]}));return[...r.map(s=>{var o,l;return{id:`draft:${s.id}`,kind:"draft",appId:s.appId,name:s.name,draft:s,pageId:(o=s.pages[0])==null?void 0:o.id,pageTitle:(l=s.pages[0])==null?void 0:l.metadata.title}}),...e.filter(s=>!i.has(s.id)).map(s=>{var l,c,u;const o=((l=s.homepage)==null?void 0:l.type)==="dashboard"?s.homepage.id:(c=s.dashboards[0])==null?void 0:c.id;return{id:`project:${s.id}`,kind:"project",appId:s.id,name:s.name,pageId:o,pageTitle:(u=s.dashboards.find(p=>p.id===o))==null?void 0:u.title}})]}function _n({run:e,t:n,appContext:r,onOpenApp:i}){const[s,o]=x.useState(!1),[l,c]=x.useState(null),[u,p]=x.useState(!1),[f,a]=x.useState("list"),[d,g]=x.useState(""),[h,m]=x.useState(!1),[b,k]=x.useState(null),[W,L]=x.useState(""),[N,$]=x.useState(null),V=x.useRef(null),Z=async()=>{c(null),p(!1);const[z,v]=await Promise.allSettled([oe.listAppsStrict(),oe.listAppBuilds()]);if(z.status==="rejected"&&v.status==="rejected"){c([]),p(!0);return}const U=ai(z.status==="fulfilled"?z.value:[],v.status==="fulfilled"?v.value.drafts:[]);c(U),U.length===0&&a("new")},F=()=>{o(!0),k(null),a("list"),V.current=null,g(xt(e.question)),L(xt(e.question)),Z()},M=()=>{h||(o(!1),k(null))},ie=async(z,v,U,J)=>{var se,pe;const K=W.trim()||xt(e.question),E=$e(e),P=un(e),Q=await oe.addAskResultToAppBuild(z.id,{expectedRevision:z.revision,expectedProposalHash:z.proposalHash,pageId:U,title:K,question:e.question,answer:e.answer??e.summary,certifiedBlockId:P,dqlSource:E==null?void 0:E.source,sql:_e(e),visualization:(se=mo(e))==null?void 0:se.chart});$({appId:Q.draft.appId,draftId:Q.draft.id,pageId:Q.pageId,name:v,pageTitle:((pe=Q.draft.pages.find(me=>me.id===Q.pageId))==null?void 0:pe.metadata.title)??J,tileTitle:K,kind:Q.deduped?"existing":P?"certified":E!=null&&E.source||_e(e)?"review":"narrative"}),window.dispatchEvent(new CustomEvent("dql-app-build-updated",{detail:{draft:Q.draft,pageId:Q.pageId,tileId:Q.tileId}})),o(!1)},D=async z=>{if(z.draft)return z.draft;const U=(await oe.listAppBuilds()).drafts.find(J=>{var K;return J.state!=="project_published"&&((K=J.baseApp)==null?void 0:K.appId)===z.appId});return U||(await oe.createAppBuild({baseAppId:z.appId,goal:`Edit ${z.name} with an Ask result`,authoringMode:"ai",sourcePolicy:un(e)?"governed_only":"include_review_required",template:"blank",entrypoint:"ask"})).draft},_=async z=>{if(!h){m(!0),k(null);try{const v=await D(z),U=(r==null?void 0:r.appId)===z.appId?r.dashboardId:z.pageId;await ie(v,z.name,U,z.pageTitle)}catch(v){k(mn(v,"Could not add to app."))}finally{m(!1)}}},I=async()=>{var v,U;if(h)return;const z=d.trim()||xt(e.question);m(!0),k(null);try{V.current||(V.current=(await oe.createAppBuild({name:z,goal:e.question,authoringMode:"ai",sourcePolicy:un(e)?"governed_only":"include_review_required",template:"blank",entrypoint:"ask"})).draft),await ie(V.current,z,(v=V.current.pages[0])==null?void 0:v.id,(U=V.current.pages[0])==null?void 0:U.metadata.title),V.current=null}catch(J){k(mn(J,"Could not create the app."))}finally{m(!1)}};return t.jsxs("div",{style:{position:"relative",display:"inline-flex",alignItems:"center",gap:6},children:[N?t.jsxs("div",{role:"status","aria-live":"polite",style:{display:"grid",gridTemplateColumns:"auto minmax(0, 1fr) auto",alignItems:"center",gap:8,minWidth:260,maxWidth:440,padding:"8px 9px",borderRadius:9,background:`${n.success}12`,color:n.success,border:`1px solid ${n.success}55`},children:[t.jsx("span",{style:{width:26,height:26,borderRadius:999,display:"grid",placeItems:"center",background:`${n.success}20`},children:t.jsx(jt,{size:15})}),t.jsxs("span",{style:{display:"grid",gap:1,minWidth:0},children:[t.jsx("b",{style:{fontSize:11.5},children:N.kind==="existing"?"Already on this page":N.kind==="certified"?"Saved as a certified tile":N.kind==="review"?"Saved — review required":"Saved as editable narrative"}),t.jsxs("span",{title:bn(N.name,N.pageTitle),style:{fontSize:10.5,color:n.textSecondary,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[bn(N.name,N.pageTitle)," · editable draft"]}),t.jsxs("span",{title:N.tileTitle,style:{fontSize:10,color:n.textMuted,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:["Tile: ",N.tileTitle]}),N.kind==="review"||N.kind==="narrative"?t.jsx("span",{style:{fontSize:10,color:n.textMuted,lineHeight:1.35},children:"Stays local and cannot publish until reviewed, promoted, or removed."}):null]}),i?t.jsxs("button",{type:"button",className:"dql-hover",onClick:()=>i(N.appId,N.pageId,N.draftId),style:{...ne(n),color:n.success,whiteSpace:"nowrap"},title:"Open the App page containing this tile",children:["Open App ",t.jsx(Ki,{size:12})]}):null]}):null,t.jsxs("button",{type:"button",className:"dql-hover dql-lift",onClick:F,style:N?ne(n):jr(n),children:[t.jsx(pn,{size:13}),N?"Add to another":"Add to app"]}),s?t.jsxs(t.Fragment,{children:[t.jsx("div",{onClick:M,style:{position:"fixed",inset:0,zIndex:40}}),t.jsxs("div",{style:Ro(n),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[t.jsx("span",{style:{fontSize:12,fontWeight:700,color:n.textPrimary},children:f==="new"?"Name the new App draft":"Save to an editable App"}),t.jsx("button",{type:"button",onClick:M,style:{border:"none",background:"transparent",color:n.textMuted,cursor:"pointer",fontSize:15,lineHeight:1},children:"×"})]}),b?t.jsx("div",{style:{fontSize:11,color:n.error,marginBottom:7,lineHeight:1.4},children:b}):null,f==="new"?t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("input",{autoFocus:!0,value:d,onChange:z=>g(z.target.value),onKeyDown:z=>{z.key==="Enter"&&I()},placeholder:"App name",style:wr(n)}),t.jsxs("div",{style:{display:"flex",gap:6},children:[l&&l.length>0?t.jsx("button",{type:"button",className:"dql-hover",onClick:()=>a("list"),style:ne(n),children:"Back"}):null,t.jsxs("button",{type:"button",className:"dql-hover",disabled:h||!d.trim(),onClick:()=>void I(),style:{...jr(n),flex:1,justifyContent:"center"},children:[h?t.jsx(Ge,{size:13,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}):t.jsx(yt,{size:13}),"Create draft & add"]})]})]}):l===null?t.jsx("div",{style:{fontSize:11.5,color:n.textMuted,padding:"8px 2px"},children:"Loading apps…"}):u?t.jsxs("div",{style:{display:"grid",gap:8},children:[t.jsx("div",{style:{fontSize:11.5,color:n.error,lineHeight:1.4},children:"Couldn't load your apps."}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{type:"button",className:"dql-hover",onClick:()=>void Z(),style:ne(n),children:"Retry"}),t.jsxs("button",{type:"button",className:"dql-hover",onClick:()=>a("new"),style:{...Sr(n),width:"auto",flex:1,marginBottom:0,justifyContent:"center"},children:[t.jsx(yt,{size:13})," New app…"]})]})]}):t.jsxs("div",{style:{display:"grid",gap:3,maxHeight:244,overflow:"auto"},children:[t.jsxs("label",{style:{display:"grid",gap:3,marginBottom:5},children:[t.jsx("span",{style:{fontSize:10.5,color:n.textMuted},children:"Tile name"}),t.jsx("input",{value:W,onChange:z=>L(z.target.value),placeholder:xt(e.question),maxLength:120,style:wr(n)})]}),t.jsxs("button",{type:"button",className:"dql-hover",onClick:()=>a("new"),style:Sr(n),children:[t.jsx(yt,{size:13})," New app…"]}),l.map(z=>t.jsxs("button",{type:"button",className:"dql-hover",disabled:h,onClick:()=>void _(z),style:Co(n),children:[t.jsx(pn,{size:13,style:{flex:"0 0 auto",opacity:.7}}),t.jsxs("span",{style:{flex:1,minWidth:0,display:"grid",gap:1,overflow:"hidden",textAlign:"left"},children:[t.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),t.jsx("small",{style:{color:n.textMuted},children:z.kind==="draft"?"Local editable draft":"Project App · creates a safe edit draft"})]})]},z.id))]})]})]}):null]})}function zn(e){var n;if(e.status==="cancelled"||e.stopReason==="cancelled"||e.route==="cancelled")return"Stopped by user. No result was accepted.";if(e.trustState==="certified")return"Answered from a certified block.";if(e.route==="dql_block_draft")return"Prepared an ownerless review draft. Add it to Block Studio when you are ready to save it.";if(e.trustState==="governed")return"Built from governed metrics and dimensions.";if(e.trustState==="grounded")return"Ran cleanly against your data. Save it as a block when it is reusable.";if(Tn(e)){const r=e.artifacts.map(o=>o.payload).filter(o=>!!(o&&typeof o=="object"&&!Array.isArray(o)));if(r.some(o=>{const l=o.result;return!!(l&&typeof l=="object"&&!Array.isArray(l))}))return"Exploratory · DBT-grounded. The query and bounded join probes ran, but no certified relationship path covers it yet.";const s=(n=r.find(o=>typeof o.executionError=="string"))==null?void 0:n.executionError;return typeof s=="string"&&s.trim()?"Exploratory · DBT-grounded. DQL prepared a review-required query, but its bounded execution failed. Inspect the error and DQL artifact before reuse.":"Exploratory · DBT-grounded. DQL prepared a review-required query, but it has not executed yet."}return e.route==="modeling_draft"?"AI-drafted modeling proposal. Review the exact source diff, then save it as a draft — nothing is written or joinable yet.":e.route==="skill_draft"?"AI-drafted Skill proposal. Review it, then save it as a draft — it will not guide any agent until you activate it.":e.trustState==="review_required"?"AI-generated answer. Save it as a block when you want to keep it.":(e.trustState==="blocked",null)}function Tn(e){return e.artifacts.some(n=>{const r=n.payload;return!!(r&&typeof r=="object"&&!Array.isArray(r)&&r.exploratoryCandidate)})}function ao(e){return e.status==="cancelled"||e.stopReason==="cancelled"||e.route==="cancelled"?"Stopped by user":e.trustState==="certified"?"Certified answer":e.route==="dql_block_draft"?"Draft block":Tn(e)?"Exploratory DBT-grounded answer":e.route==="semantic_answer"?"Semantic answer":e.route==="generated_answer"?"AI-generated answer":Pr[e.route]}function lo({artifact:e,payload:n,t:r,onOpenApp:i}){const s=typeof n.sessionId=="string"?n.sessionId:void 0,o=n.proposal&&typeof n.proposal=="object"?n.proposal:void 0,l=typeof n.proposalHash=="string"?n.proposalHash:void 0,[c,u]=x.useState(()=>o?Wi(o):new Set),[p,f]=x.useState(!1),[a,d]=x.useState(null),[g,h]=x.useState(null);if(!o||!s)return t.jsxs("div",{style:Sn(r),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(it,{kind:e.kind}),t.jsx("div",{style:{fontSize:12,fontWeight:800,color:r.textPrimary},children:e.title})]}),t.jsx("div",{style:{fontSize:11.5,color:r.textMuted},children:"This proposal is no longer available. Ask again to rebuild it."})]});const m=async b=>{var W,L;f(!0),d(null);const k=await oe.commitAppAiBuild(s,{selectedTileIds:Array.from(c),expectedProposalHash:l,...b.appName?{appName:b.appName}:{},...b.pageTitle?{pageTitle:b.pageTitle}:{},...b.audience?{audience:b.audience}:{},...Object.keys(b.tileOverrides).length>0?{tileOverrides:b.tileOverrides}:{}});if(f(!1),!k.ok){d(k.error);return}h({appId:((W=k.app)==null?void 0:W.id)??k.session.appId??"",dashboardId:k.dashboardId??void 0,name:((L=k.app)==null?void 0:L.name)??e.title})};return t.jsxs("div",{style:Sn(r),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(it,{kind:e.kind}),t.jsx("div",{style:{fontSize:12,fontWeight:800,color:r.textPrimary,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ie(e.title)})]}),g?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6,color:r.success,fontSize:12,fontWeight:750},children:[t.jsx(jt,{size:13})," Created ",g.name]}),g.appId&&i?t.jsx("button",{type:"button",className:"dql-hover",onClick:()=>i(g.appId,g.dashboardId),style:ne(r),children:"Open app"}):null]}):t.jsx(Oi,{proposal:o,t:r,selected:c,onToggle:b=>{u(k=>{const W=new Set(k);return W.has(b)?W.delete(b):W.add(b),W})},onCreate:b=>void m(b),defaultName:e.title,busy:p,error:a,compact:!0})]})}function li({artifact:e,certifiedBlockName:n,initialResult:r,initialChartConfig:i,payload:s,executionTarget:o,t:l,themeMode:c,embedded:u=!1,expanded:p=!1}){var Y;const[f,a]=x.useState(e),[d,g]=x.useState(()=>e.parameters??[]),[h,m]=x.useState(()=>({...e.parameterValues??{},...vn(s)})),[b,k]=x.useState(r),[W,L]=x.useState(i),[N,$]=x.useState(!!n),[V,Z]=x.useState(!1),[F,M]=x.useState(null),[ie,D]=x.useState(!1),[_,I]=x.useState(""),[z,v]=x.useState(""),U=x.useRef(!1),J=x.useRef(e);J.current=e;const K=Ls(e);x.useEffect(()=>{const A=J.current;if(a(A),D(!1),!n){g(A.parameters??[]),m({...A.parameterValues??{},...vn(s)}),$(!1);return}let te=!1;return $(!0),oe.getCertifiedBlockParameters(n).then(w=>{te||(g(w.parameters),m(q=>({...Object.fromEntries(w.parameters.flatMap(ae=>ae.default===void 0?[]:[[ae.name,ae.default]])),...q})))}).catch(w=>{te||M(w instanceof Error?w.message:String(w))}).finally(()=>{te||$(!1)}),()=>{te=!0}},[K,n]);const E=async()=>{if(!U.current){U.current=!0,Z(!0),M(null);try{const A=await oe.invokeDqlArtifact(f,h,void 0,n,o);k(A.result),a(A.artifact),A.result.chartConfig&&typeof A.result.chartConfig=="object"&&L(A.result.chartConfig),A.parameters.length>0&&g(A.parameters)}catch(A){M(A instanceof Error?A.message:String(A))}finally{U.current=!1,Z(!1)}}},P=x.useMemo(()=>Br(f,b),[f,b]),Q=()=>{const A=P[0];A&&(I(A.column),v(A.values[0]==null?"":String(A.values[0])),D(!0),M(null))},se=async()=>{try{const A=f.kind==="sql_block"?await oe.addDqlArtifactResultFilter(f,b.columns,_,z,o):Ns(f,b,_,z);a(A.artifact),g(A.artifact.parameters??[]),m(te=>({...te,...A.artifact.parameterValues??{}})),D(!1),M(null)}catch(A){M(A instanceof Error?A.message:String(A))}},pe=d.some(Tr),me=Object.entries(h).filter(([,A])=>A!=null&&A!=="");return t.jsxs("div",{style:{display:"grid",gap:9},children:[me.length>0?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap",padding:u?"8px 12px 0":0},children:[t.jsx("span",{style:{fontSize:10.5,fontWeight:750,color:l.textMuted},children:"Applied inputs"}),me.map(([A,te])=>t.jsxs("span",{style:{fontSize:10.5,color:l.textSecondary,border:`1px solid ${l.cellBorder}`,background:l.appBg,borderRadius:999,padding:"2px 7px"},children:[A.replace(/_/g," ")," = ",co(te)]},A))]}):null,N?t.jsx("div",{style:{fontSize:10.5,color:l.textMuted},children:"Loading reusable inputs…"}):pe||P.length>0?t.jsxs("div",{style:{display:"grid",gap:8,padding:9,margin:u?"0 12px":0,border:`1px solid ${l.cellBorder}`,borderRadius:7,background:l.appBg},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontSize:11,fontWeight:800,color:l.textPrimary},children:"Change DQL inputs"}),t.jsx("div",{style:{fontSize:10,color:l.textMuted},children:"Reruns this DQL artifact directly. It does not start another AI search."})]}),P.length>0?t.jsxs("button",{type:"button",onClick:Q,style:ne(l),children:[t.jsx(yt,{size:11})," Add result filter"]}):null,t.jsxs("button",{type:"button",disabled:V,onClick:()=>void E(),style:{...ne(l),color:l.accent,opacity:V?.65:1},children:[V?t.jsx(Ge,{size:11,style:{animation:"dql-agent-run-spin 0.8s linear infinite"}}):t.jsx(Ue,{size:11}),V?"Running…":"Apply"]})]}),ie?t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"minmax(150px, 1fr) minmax(150px, 1fr) auto auto",gap:7,alignItems:"end",padding:8,border:`1px solid ${l.cellBorder}`,borderRadius:7,background:l.cellBg},children:[t.jsxs("label",{style:{display:"grid",gap:4,fontSize:10,fontWeight:750,color:l.textSecondary},children:["Result column",t.jsx("select",{"aria-label":"Result column for new DQL input",value:_,onChange:A=>{const te=A.target.value,w=P.find(q=>q.column===te);I(te),v((w==null?void 0:w.values[0])==null?"":String(w.values[0]))},style:kr(l),children:P.map(A=>t.jsx("option",{value:A.column,children:A.column.split("_").join(" ")},A.column))})]}),t.jsxs("label",{style:{display:"grid",gap:4,fontSize:10,fontWeight:750,color:l.textSecondary},children:["Default value",t.jsx("input",{"aria-label":"Default value for new DQL input",value:z,list:`ask-filter-${_}`,onChange:A=>v(A.target.value),style:kr(l)}),t.jsx("datalist",{id:`ask-filter-${_}`,children:(((Y=P.find(A=>A.column===_))==null?void 0:Y.values)??[]).map(A=>t.jsx("option",{value:String(A)},`${typeof A}:${String(A)}`))})]}),t.jsx("button",{type:"button",onClick:()=>{se()},style:{...ne(l),color:l.accent},children:"Add input"}),t.jsx("button",{type:"button",onClick:()=>D(!1),style:ne(l),children:"Cancel"})]}):null,d.length>0?t.jsx(Ss,{parameters:d,values:h,onChange:(A,te)=>m(w=>({...w,[A]:te})),t:l}):null,P.length>0?t.jsx("div",{style:{fontSize:9.5,color:l.textMuted},children:"Extra filters are available only for semantic dimensions in this result. They stay transient until you explicitly save a block."}):null]}):null,F?t.jsx("div",{style:{fontSize:10.5,color:l.error},children:F}):null,t.jsx(wn,{result:b,themeMode:c,t:l,chartConfig:W,embedded:u,tabLabels:u?{table:"Results",chart:"Visualization"}:void 0,contentMaxHeight:p?"calc(100vh - 172px)":void 0,tableMaxHeight:p?"calc(100vh - 250px)":void 0})]})}function vn(e){const n=e.result&&typeof e.result=="object"&&!Array.isArray(e.result)?e.result:void 0,r=Array.isArray(n==null?void 0:n.parameters)?n.parameters:Array.isArray(e.parameters)?e.parameters:[];return Object.fromEntries(r.flatMap(i=>{if(!i||typeof i!="object")return[];const s=i;return typeof s.name=="string"?[[s.name,s.value]]:[]}))}function co(e){return Array.isArray(e)?e.map(n=>String(n)).join(", "):typeof e=="boolean"?e?"true":"false":String(e)}function ci(e,n){const r=n.result&&typeof n.result=="object"&&!Array.isArray(n.result)?n.result:void 0,i=n.block&&typeof n.block=="object"&&!Array.isArray(n.block)?n.block:void 0;return[r==null?void 0:r.blockName,n.sourceCertifiedBlock,i==null?void 0:i.name,e.ref].find(o=>typeof o=="string"&&o.trim().length>0)}function di({artifact:e,t:n,themeMode:r,onInsertSql:i,onInsertDql:s,insertDqlActionLabel:o,sourceRunId:l,sourceQuestion:c,onOpenBlock:u,onOpenResearch:p,onOpenApp:f,onNextAction:a}){const d=e.payload&&typeof e.payload=="object"?e.payload:{};if(e.kind==="app_proposal")return t.jsx(lo,{artifact:e,payload:d,t:n,onOpenApp:f});const g=Te(d),h=Ct(d),m=en(d),b=typeof d.sql=="string"?d.sql:typeof d.sqlPreview=="string"?d.sqlPreview:typeof d.proposedSql=="string"?d.proposedSql:void 0,k=typeof d.name=="string"?d.name:e.title,W=typeof d.path=="string"?d.path:e.ref,L=d.draftBlock&&typeof d.draftBlock=="object"&&!Array.isArray(d.draftBlock)?d.draftBlock:void 0,N=typeof(L==null?void 0:L.path)=="string"?L.path:void 0,$=typeof(L==null?void 0:L.name)=="string"?L.name:void 0,V=(h==null?void 0:h.sourcePath)??N??(e.kind==="dql_block_draft"?W:void 0),Z=(h==null?void 0:h.name)??$??k,F=(h==null?void 0:h.kind)==="sql_block"||e.kind==="dql_block_draft"?"Open DQL draft":"Open DQL artifact",M=d.plan&&typeof d.plan=="object"?d.plan:void 0,ie=Array.isArray(M==null?void 0:M.steps)?M.steps:[],D=Array.isArray(M==null?void 0:M.gaps)?M.gaps.map(String):[],_=typeof d.researchRunId=="string"?d.researchRunId:e.kind==="research_run"&&typeof e.ref=="string"?e.ref:void 0,I=typeof d.notebookPath=="string"?d.notebookPath:void 0,z=Array.isArray(d.generatedPaths)?d.generatedPaths.filter(P=>typeof P=="string"):[],v=d.narration&&typeof d.narration=="object"?d.narration:void 0,U=Array.isArray(v==null?void 0:v.keyFindings)?v.keyFindings.filter(P=>typeof P=="string"):[],J=typeof(v==null?void 0:v.recommendation)=="string"?v.recommendation:void 0,K=e.trustState==="certified"?ci(e,d):void 0,E=e.kind==="research_run"?In(d):void 0;if(e.kind==="dql_block_draft"){const P=se=>Array.isArray(se)?se.filter(pe=>typeof pe=="string"):void 0,Q=d.certifierVerdict&&typeof d.certifierVerdict=="object"?d.certifierVerdict:void 0;return t.jsx(vs,{t:n,name:typeof d.name=="string"?d.name:k,status:"draft",description:typeof d.description=="string"?d.description:void 0,dql:(h==null?void 0:h.source)??(typeof d.dqlSource=="string"?d.dqlSource:void 0),sqlPreview:b,grain:typeof d.grain=="string"?d.grain:void 0,outputs:P(d.outputs),dimensions:P(d.dimensions)??(h==null?void 0:h.dimensions),entities:P(d.entities),certifierVerdict:Q?{blocking:P(Q.blocking)??[],warnings:P(Q.warnings)??[],ready:!!Q.ready}:void 0,actions:t.jsxs(t.Fragment,{children:[b&&s?t.jsx("button",{type:"button",onClick:()=>s({sql:b,dqlArtifact:h,result:g,chartConfig:g?Oe(d,g):void 0,title:k,sourceRunId:l,question:c}),style:ne(n),children:o??"Insert as DQL cell"}):b&&i?t.jsx("button",{type:"button",onClick:()=>i(b,k,{question:c,sourceRunId:l}),style:ne(n),children:"Insert SQL preview"}):null,V&&u?t.jsx("button",{type:"button",onClick:()=>u(V,Z),style:ne(n),children:F}):null]})})}return t.jsxs("div",{style:Sn(n),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(it,{kind:e.kind}),t.jsx("div",{style:{fontSize:12,fontWeight:800,color:n.textPrimary,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:Ie(e.title)})]}),E?t.jsxs("div",{role:"status","aria-label":E.detail,style:{borderLeft:`3px solid ${E.limitedScope?n.warning:n.accent}`,padding:"7px 9px",borderRadius:6,background:E.limitedScope?`${n.warning}10`:`${n.accent}0d`,display:"grid",gap:2},children:[t.jsx("strong",{style:{fontSize:11.5,color:E.limitedScope?n.warning:n.textPrimary},children:E.limitedScope?"Limited research scope":"Research branch verdicts"}),t.jsx("span",{style:{fontSize:11,color:n.textSecondary,lineHeight:1.4},children:E.detail})]}):null,U.length>0?t.jsxs("div",{style:{display:"grid",gap:4},children:[t.jsx("div",{style:{fontSize:11,fontWeight:800,color:n.textSecondary},children:"Key findings"}),t.jsx(fr,{items:U,t:n,renderItem:(P,Q)=>t.jsxs("div",{style:{fontSize:11.5,color:n.textSecondary,lineHeight:1.4,display:"flex",gap:6},children:[t.jsx("span",{style:{color:n.accent},children:"•"}),t.jsx("span",{children:P})]},Q)})]}):ie.length>0?t.jsx("div",{style:{display:"grid",gap:5},children:t.jsx(fr,{items:ie,t:n,renderItem:(P,Q)=>t.jsxs("div",{style:{fontSize:11.5,color:n.textSecondary,lineHeight:1.35},children:[Q+1,". ",String(P.thought??P.expectation??"Research step")]},Q)})}):null,J?t.jsxs("div",{style:{fontSize:11.5,color:n.textPrimary,lineHeight:1.4,display:"flex",gap:6},children:[t.jsx("span",{style:{color:n.accent},children:"→"}),t.jsx("span",{children:J})]}):null,g?h?t.jsx(li,{artifact:h,certifiedBlockName:K,initialResult:g,initialChartConfig:Oe(d,g),payload:d,t:n,themeMode:r}):t.jsx(wn,{result:g,themeMode:r,t:n,chartConfig:Oe(d,g)}):null,h?t.jsxs("details",{children:[t.jsxs("summary",{style:{cursor:"pointer",fontSize:11,color:n.textSecondary,listStyle:"none",display:"flex",alignItems:"center",gap:5},children:[t.jsx(kt,{size:12}),t.jsx("span",{children:"View DQL artifact"}),t.jsxs("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:4},children:[h.source?t.jsx(Ot,{text:h.source,t:n,title:"Copy DQL"}):null,!V&&a?t.jsxs("button",{type:"button",className:"dql-hover",title:"Save this DQL as a reusable block",onClick:P=>{P.preventDefault(),P.stopPropagation(),a({id:"save-dql-block",label:"Save as DQL block",route:"dql_block_draft"})},style:{border:"none",background:"transparent",cursor:"pointer",color:n.accent,display:"inline-flex",alignItems:"center",gap:3,fontSize:10.5,fontWeight:700,padding:"2px 4px"},children:[t.jsx(Rn,{size:12})," Save as block"]}):null]})]}),h.sourcePath?t.jsx("div",{style:{marginTop:6,fontSize:10.5,color:n.textMuted},children:h.sourcePath}):null,t.jsx("pre",{style:{...wt(n),marginTop:6},children:h.source})]}):null,b?t.jsxs("details",{children:[t.jsxs("summary",{style:{cursor:"pointer",fontSize:11,color:n.textSecondary,listStyle:"none",display:"flex",alignItems:"center",gap:5},children:[t.jsx(kn,{size:12}),t.jsx("span",{children:gi(!!h)}),t.jsx("span",{style:{marginLeft:"auto",display:"inline-flex",alignItems:"center",gap:4},children:t.jsx(Ot,{text:b,t:n,title:"Copy SQL"})})]}),t.jsx("pre",{style:{...wt(n),marginTop:6},children:b})]}):null,D.length>0?t.jsxs("div",{style:{fontSize:11.5,color:n.textSecondary,lineHeight:1.4},children:["Gaps: ",D.join(", ")]}):null,z.length>0?t.jsxs("div",{style:{fontSize:11.5,color:n.textSecondary,lineHeight:1.4},children:["Files: ",z.join(", ")]}):null,t.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[_&&p?t.jsx("button",{type:"button","aria-label":"Open research evidence",onClick:()=>p(_,I,l),style:ne(n),children:"Open research"}):null,b&&s?t.jsx("button",{type:"button",onClick:()=>s({sql:b,dqlArtifact:h,result:g,chartConfig:g?Oe(d,g):void 0,title:k,mixedSourcePlan:m,sourceRunId:l,question:c}),style:m?{...ne(n),background:n.accent,borderColor:n.accent,color:"#fff",fontWeight:850,padding:"7px 11px"}:ne(n),children:m?"Add workflow to notebook":h?"Insert as DQL cell":"Add SQL to notebook"}):b&&i?t.jsx("button",{type:"button",onClick:()=>i(b,k,{question:c,sourceRunId:l}),style:ne(n),children:"Insert SQL preview"}):null,V&&u?t.jsx("button",{type:"button",onClick:()=>u(V,Z),style:ne(n),children:F}):null]})]})}function uo({run:e}){return e.trustState==="certified"?t.jsx(we,{size:16,color:"#16a34a"}):e.trustState==="governed"?t.jsx(we,{size:16,color:"#2563eb"}):e.trustState==="grounded"?t.jsx(we,{size:16,color:"#2563eb"}):e.status==="completed"?t.jsx(jt,{size:16,color:"#16a34a"}):e.status==="cancelled"||e.stopReason==="cancelled"?t.jsx(mt,{size:16,color:"#737373"}):e.status==="blocked"?t.jsx(mt,{size:16,color:"#ef4444"}):t.jsx(mt,{size:16,color:"#d97706"})}function it({kind:e}){return e==="sql_cell"?t.jsx(kn,{size:14}):e==="dql_block_draft"?t.jsx(kt,{size:14}):e==="app_draft"||e==="app_proposal"?t.jsx(pn,{size:14}):e==="research_run"?t.jsx(Ye,{size:14}):t.jsx(Ue,{size:14})}function po({run:e,t:n}){const r=e.trustState==="certified"?n.success:e.trustState==="governed"||e.trustState==="grounded"?n.accent:e.trustState==="blocked"?n.error:e.trustState==="not_applicable"?n.textMuted:n.warning,i=e.status==="cancelled"||e.stopReason==="cancelled"?"Cancelled":e.trustState==="certified"?"Certified":e.route==="dql_block_draft"?"Draft":Tn(e)?"Exploratory":e.status==="needs_clarification"?"Needs input":e.trustState==="blocked"?"Refused":"AI-generated";return t.jsx("span",{style:{border:`1px solid ${r}55`,color:r,background:`${r}12`,borderRadius:999,padding:"3px 7px",fontSize:10,fontWeight:850},children:i})}function ui({evaluations:e,t:n}){if(e.length===0)return null;const r=e.filter(s=>!s.passed),i=e.filter(s=>s.passed);return t.jsxs("div",{style:{display:"grid",gap:6,gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},children:[r.map(s=>t.jsx(jn,{evaluation:s,t:n},s.id)),i.length>0?t.jsxs("details",{children:[t.jsxs("summary",{className:"dql-hover",style:{cursor:"pointer",listStyle:"none",display:"inline-flex",alignItems:"center",gap:6,fontSize:11,fontWeight:700,color:n.textMuted,width:"fit-content"},children:[t.jsx(we,{size:12,color:n.success}),t.jsxs("span",{children:[i.length," check",i.length>1?"s":""," verified"]})]}),t.jsx("div",{style:{display:"grid",gap:5,marginTop:7},children:i.map(s=>t.jsx(jn,{evaluation:s,t:n},s.id))})]}):null]})}function jn({evaluation:e,t:n}){const r=e.passed?n.success:e.severity==="blocking"?n.error:n.warning;return t.jsxs("div",{style:{display:"flex",gap:7,alignItems:"flex-start",fontSize:11.5,color:n.textSecondary,minWidth:0},children:[t.jsx("span",{style:{color:r,lineHeight:"16px",flex:"0 0 auto",fontWeight:800},children:e.passed?"OK":e.severity==="blocking"?"Stop":"Review"}),t.jsxs("span",{style:{lineHeight:1.4,minWidth:0,flex:1,overflowWrap:"anywhere"},children:[e.message,!e.passed&&e.suggestedRepair?t.jsxs("span",{style:{display:"block",color:n.textMuted,marginTop:1},children:["↳ ",e.suggestedRepair]}):null]})]})}function dn({t:e,icon:n,label:r,tone:i}){const s=i==="accent"?e.accent:i==="warning"?e.warning:e.textMuted;return t.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,border:`1px solid ${s}44`,color:s,background:`${s}10`,borderRadius:999,padding:"2px 7px",fontSize:10,fontWeight:800},children:[n,t.jsx("span",{children:r})]})}function fo(e,n){switch(e){case"passed":return n.success;case"repaired":return n.accent;case"escalated":return n.accent;case"blocked":return n.error;default:return n.warning}}function pi({steps:e,t:n}){return t.jsxs("details",{style:{border:`1px solid ${n.headerBorder}`,background:n.cellBg,borderRadius:8,padding:"6px 9px"},children:[t.jsxs("summary",{style:{cursor:"pointer",fontSize:11.5,fontWeight:800,color:n.textSecondary,listStyle:"none",display:"flex",alignItems:"center",gap:6},children:[t.jsx(St,{size:13}),t.jsxs("span",{children:["Plan trace · ",e.length," steps"]})]}),t.jsx("div",{style:{display:"grid",gap:10,marginTop:8},children:e.map(r=>{const i=fo(r.status,n);return t.jsxs("div",{style:{display:"grid",gap:4,paddingLeft:8,borderLeft:`2px solid ${i}55`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[t.jsxs("span",{style:{fontSize:11.5,fontWeight:850,color:n.textPrimary},children:[r.index,". ",Pr[r.route]]}),t.jsxs("span",{style:{border:`1px solid ${i}55`,color:i,background:`${i}12`,borderRadius:999,padding:"1px 6px",fontSize:9.5,fontWeight:850,display:"inline-flex",alignItems:"center",gap:3},children:[r.status==="escalated"?t.jsx(Yt,{size:10}):r.status==="repaired"?t.jsx(Xt,{size:10}):null,r.status.split("_").join(" ")]}),r.attempts>1?t.jsxs("span",{style:{fontSize:10,color:n.textMuted},children:[r.attempts," attempts"]}):null]}),r.goal?t.jsx("div",{style:{fontSize:11,color:n.textMuted,lineHeight:1.35},children:r.goal}):null,r.evaluations.length>0?t.jsx("div",{style:{display:"grid",gap:4},children:r.evaluations.map(s=>t.jsx(jn,{evaluation:s,t:n},s.id))}):null]},r.id)})})]})}function go(e){if(e==="research")return"research";if(e==="sql_cell")return"sql";if(e==="dql_block_draft")return"block";if(e==="modeling_draft")return"modeling";if(e==="skill_draft")return"skill";if(e==="app_build")return"app";if(e==="certified_answer"||e==="semantic_answer"||e==="generated_answer")return"ask"}function ho(e,n){return n==="sql_cell"?`Create a SQL cell for: ${e.question}`:n==="dql_block_draft"?`Create a DQL block draft for: ${e.question}`:n==="modeling_draft"?`Revise the modeling proposal for: ${e.question}`:n==="skill_draft"?`Revise the Skill proposal for: ${e.question}`:n==="app_build"?`Build an app for: ${e.question}`:n==="research"?`Research deeper: ${e.question}`:e.question}function mr(e){return`${e}_${Date.now()}_${Math.random().toString(36).slice(2,8)}`}function rt(e){return e.replace(/^\s*Outcome\s*:\s*[^\n]*\n+/i,"").replace(/^\s*Review required:\s*/gim,"").replace(/\breview-required\b/gi,"AI-generated").replace(/\*\*(.+?)\*\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/^_(.+?)_$/gm,"$1").trim()}function Ie(e){return e.replace(/^\s*Review required:\s*/gim,"").replace(/\breview-required\b/gi,"AI-generated").replace(/\bqueued for review\b/gi,"saved as a draft").trim()}function xo(e,n){const r=i=>i.toLowerCase().replace(/[\s.,!?'"()`*_-]+/g," ").trim();return r(e)===r(n)}function Te(e){var r,i;const n=[e.result,e.resultPreview,(r=e.researchRun)==null?void 0:r.resultPreview,(i=e.result)==null?void 0:i.result];for(const s of n){if(!s||typeof s!="object")continue;const o=s;if(!Array.isArray(o.rows)&&!Array.isArray(o.columns))continue;const l=Ei(o),c=l.rows,u=l.columns;if(!(c.length===0&&u.length===0&&typeof o.rowCount!="number"))return{columns:u,rows:c,rowCount:l.rowCount,...l.resultFingerprint?{resultFingerprint:l.resultFingerprint}:{},...l.executionReceipt?{executionReceipt:l.executionReceipt}:{},...l.trustState?{trustState:l.trustState}:{},...l.answerTier?{answerTier:l.answerTier}:{},...l.executionTime!==void 0?{executionTime:l.executionTime}:{}}}}function Oe(e,n){const r=e.result&&typeof e.result=="object"?e.result:void 0,i=r!=null&&r.chartConfig&&typeof r.chartConfig=="object"?r.chartConfig:e.chartConfig&&typeof e.chartConfig=="object"?e.chartConfig:{},s=typeof e.suggestedViz=="string"?e.suggestedViz:typeof(r==null?void 0:r.suggestedViz)=="string"?r.suggestedViz:void 0,o=i.decisionSource==="authored"||i.decisionSource==="agent"||i.decisionSource==="data"||i.decisionSource==="user"?i.decisionSource:void 0,l=typeof i.chart=="string"?i.chart:s,c=l?l.toLowerCase().replace(/_/g,"-")==="single-value"?"kpi":l:void 0,u=n.columns,p=d=>typeof i[d]=="string"&&u.includes(i[d])?i[d]:void 0,f=Array.isArray(i.metrics)?i.metrics.filter(d=>typeof d=="string"&&u.includes(d)):[],a={...c?{chart:c}:{},...c?{decisionSource:o??"agent"}:{},...typeof i.rationale=="string"?{rationale:i.rationale}:{},...p("x")?{x:p("x")}:{},...p("y")?{y:p("y")}:{},...f.length>0?{metrics:f}:{},...p("color")?{color:p("color")}:{},...typeof i.title=="string"?{title:i.title}:{},...typeof i.colorPalette=="string"?{colorPalette:i.colorPalette}:{},...typeof i.maxItems=="number"?{maxItems:i.maxItems}:{}};return Object.keys(a).length>0?a:void 0}function fi(e,n){var i;const r=Oe(e,n);return(r==null?void 0:r.chart)==="table"&&(((i=r.metrics)==null?void 0:i.length)??0)<=1&&r.decisionSource!=="authored"&&r.decisionSource!=="user"?{...r,chart:void 0}:r}function Ct(e){const n=Ke(e.dqlArtifact);if(n)return n;const r=e.researchRun&&typeof e.researchRun=="object"&&!Array.isArray(e.researchRun)?e.researchRun:void 0;return Ke(r==null?void 0:r.dqlArtifact)}function gi(e){return e?"View compiled SQL preview":"View SQL preview"}function Ot({text:e,t:n,title:r="Copy"}){const[i,s]=x.useState(!1),o=async l=>{l.preventDefault(),l.stopPropagation();try{await navigator.clipboard.writeText(e),s(!0),setTimeout(()=>s(!1),1500)}catch{}};return t.jsxs("button",{type:"button",onClick:o,title:r,className:"dql-hover",style:{border:"none",background:"transparent",cursor:"pointer",color:i?n.success:n.textMuted,display:"inline-flex",alignItems:"center",gap:3,fontSize:10.5,fontWeight:650,padding:"2px 4px"},children:[i?t.jsx(vt,{size:12}):t.jsx(_r,{size:12}),i?"Copied":null]})}function re(e){return e.payload&&typeof e.payload=="object"&&!Array.isArray(e.payload)?e.payload:{}}function yo(e){var i,s,o;const n=[],r=new Set;for(const l of e.artifacts){const c=re(l),u=Array.isArray(c.memoryContext)?c.memoryContext:[];for(const f of u){if(!f||typeof f!="object")continue;const a=f,d=typeof a.title=="string"?a.title.trim():"";!d||r.has(`m:${d}`)||(r.add(`m:${d}`),n.push({kind:"memory",id:typeof a.id=="string"?a.id:void 0,label:d,detail:typeof a.content=="string"?a.content:void 0}))}const p=Array.isArray(c.appliedHints)?c.appliedHints:[];for(const f of p){if(!f||typeof f!="object")continue;const a=f,d=typeof a.title=="string"?a.title.trim():"";if(!d||r.has(`h:${d}`))continue;r.add(`h:${d}`);const g=typeof((i=a.lesson)==null?void 0:i.rule)=="string"?a.lesson.rule:typeof a.guidance=="string"?a.guidance:void 0,h=[typeof a.scopeReason=="string"?a.scopeReason:void 0,typeof a.graphReason=="string"?a.graphReason:void 0].filter(Boolean).join("; "),m=typeof((s=a.matchSignals)==null?void 0:s.lexicalScore)=="number"?a.matchSignals.lexicalScore:void 0,b=typeof((o=a.matchSignals)==null?void 0:o.graphScore)=="number"?a.matchSignals.graphScore:void 0,k=m!==void 0||b!==void 0?`Signals: lexical ${(m??0).toFixed(2)}, graph ${(b??0).toFixed(2)}`:void 0;n.push({kind:"hint",id:typeof a.hintId=="string"?a.hintId:void 0,label:d,detail:[g,h?`Matched: ${h}`:void 0,k].filter(Boolean).join(" · ")||void 0})}}return n.slice(0,6)}function hi({run:e,t:n}){const[r,i]=x.useState(!1),[s,o]=x.useState(new Set),l=x.useMemo(()=>yo(e).filter(u=>!u.id||!s.has(u.id)),[e,s]);if(l.length===0)return null;const c=async u=>{try{await oe.deleteAgentMemory(u),o(p=>new Set(p).add(u))}catch{}};return t.jsxs("div",{style:{display:"grid",gap:6,gridTemplateColumns:"minmax(0, 1fr)",minWidth:0},children:[t.jsxs("button",{type:"button",onClick:()=>i(u=>!u),style:bo(n),children:[t.jsx(Wt,{size:11}),t.jsxs("span",{children:["Applied ",l.length," learning",l.length>1?"s":""]}),r?t.jsx(qr,{size:11}):t.jsx(Gt,{size:11})]}),r?t.jsxs("div",{style:vo(n),children:[l.map(u=>t.jsxs("div",{style:{display:"flex",gap:8,alignItems:"flex-start"},children:[t.jsx("span",{style:jo(n,u.kind),children:u.kind==="hint"?"governed lesson":"memory"}),t.jsxs("div",{style:{minWidth:0,flex:1},children:[t.jsx("div",{style:{fontSize:11.5,fontWeight:650,color:n.textPrimary},children:u.label}),u.detail?t.jsx("div",{style:{fontSize:11,color:n.textMuted,lineHeight:1.4,marginTop:1},children:u.detail}):null]}),u.kind==="memory"&&u.id?t.jsx("button",{type:"button",onClick:()=>void c(u.id),style:So(n),children:"Stop using"}):null]},`${u.kind}:${u.label}`)),t.jsx("div",{style:{fontSize:10.5,color:n.textMuted},children:"Advisory only — learnings never override a certified answer. Manage them under Settings → Agent learning."})]}):null]})}function $n(e){const n=[],r=new Set,i=e.trustState==="certified",s=(o,l)=>{typeof o!="string"||!o.trim()||r.has(o)||(r.add(o),n.push({label:o,certified:l}))};for(const o of e.artifacts){const l=re(o);o.ref&&s(o.ref,i);const c=l.plan&&typeof l.plan=="object"?l.plan:void 0;Array.isArray(c==null?void 0:c.sources)&&c.sources.forEach(u=>s(u,i)),s(l.sourceCertifiedBlock,!0)}return n.slice(0,4)}function _e(e){for(const n of e.artifacts){const r=re(n),i=r.researchRun&&typeof r.researchRun=="object"?r.researchRun:void 0,s=r.result&&typeof r.result=="object"&&!Array.isArray(r.result)?r.result:void 0,o=Ke(r.dqlArtifact),l=r.proposedSql??r.sql??r.sqlPreview??(s==null?void 0:s.sql)??(i==null?void 0:i.generatedSql)??(i==null?void 0:i.reviewedSql)??(o==null?void 0:o.compiledSql);if(typeof l=="string"&&l.trim())return l}}function un(e){var n;if(e.trustState==="certified")for(const r of e.artifacts){const i=re(r),s=i.blockName??i.blockId??((n=Ke(i.dqlArtifact))==null?void 0:n.name);if(typeof s=="string"&&s.trim())return s.trim()}}function mo(e){for(const n of e.artifacts){const r=re(n),i=Te(r);if(!i)continue;const s=Oe(r,i);if(s)return s}}function $e(e){for(const n of e.artifacts){const r=re(n),i=Ke(r.dqlArtifact);if(i)return i;const s=r.researchRun&&typeof r.researchRun=="object"&&!Array.isArray(r.researchRun)?r.researchRun:void 0,o=Ke(s==null?void 0:s.dqlArtifact);if(o)return o}}function Ht(e){const n=e.route==="dql_block_draft"&&e.status!=="blocked"&&e.status!=="cancelled"&&e.stopReason!=="cancelled"&&e.status!=="needs_clarification";if(e.route==="certified_answer"||!Rt(e)&&!n)return;const r=$e(e),i=_e(e);if(!((!(r!=null&&r.source)||r.sourcePath)&&!i)){for(const s of e.artifacts){const o=re(s),l=Te(o),c=en(o);if(l)return{sql:i,dqlArtifact:r,result:l,chartConfig:Oe(o,l),title:(r==null?void 0:r.name)??s.title??e.question,mixedSourcePlan:c,sourceRunId:e.id,question:e.question,executionTarget:e.executionTarget};if(c)return{sql:i,dqlArtifact:r,title:(r==null?void 0:r.name)??s.title??e.question,mixedSourcePlan:c,sourceRunId:e.id,question:e.question,executionTarget:e.executionTarget}}return{sql:i,dqlArtifact:r,title:(r==null?void 0:r.name)??e.question,sourceRunId:e.id,question:e.question,executionTarget:e.executionTarget}}}function en(e){const n=e.mixedSourcePlan;if(!n||typeof n!="object"||Array.isArray(n))return;const r=n;if(["localDataset","localAlias","localKey","warehouseKey","warehouseExpression","warehouseSql"].every(s=>typeof r[s]=="string"&&String(r[s]).trim()))return{datasetId:typeof r.datasetId=="string"?r.datasetId:void 0,datasetName:typeof r.datasetName=="string"?r.datasetName:void 0,localDataset:String(r.localDataset),localAlias:String(r.localAlias),localKey:String(r.localKey),warehouseKey:String(r.warehouseKey),warehouseExpression:String(r.warehouseExpression),warehouseSql:String(r.warehouseSql),warehouseRelations:Array.isArray(r.warehouseRelations)?r.warehouseRelations.filter(s=>typeof s=="string"):void 0}}function xi(e,n){return{display:"inline-flex",alignItems:"center",gap:4,fontSize:10.5,padding:"2px 7px",borderRadius:999,background:n?`${e.success}14`:e.cellBg,color:n?e.success:e.textMuted,border:`1px solid ${n?`${e.success}44`:e.headerBorder}`}}function bo(e){return{display:"inline-flex",alignItems:"center",gap:5,alignSelf:"flex-start",fontSize:10.5,fontWeight:600,padding:"2px 8px",borderRadius:999,background:`${e.accent}14`,color:e.accent,border:`1px solid ${e.accent}33`,cursor:"pointer"}}function vo(e){return{display:"grid",gap:8,padding:10,borderRadius:8,background:e.cellBg,border:`1px solid ${e.headerBorder}`}}function jo(e,n){const r=n==="hint";return{flex:"0 0 auto",fontSize:9,fontWeight:700,textTransform:"uppercase",letterSpacing:"0.04em",padding:"2px 6px",borderRadius:4,marginTop:1,background:r?`${e.accent}1f`:`${e.textMuted}1f`,color:r?e.accent:e.textMuted}}function So(e){return{flex:"0 0 auto",fontSize:10.5,border:`1px solid ${e.headerBorder}`,background:"transparent",color:e.textMuted,borderRadius:6,padding:"2px 7px",cursor:"pointer"}}function wo(e){return{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"}}function br(e){return{...wo(e),width:40,height:40}}function Qt(e){return{...Kt(e,{variant:"secondary",size:"md",pill:!0}),fontWeight:550}}function ko(e){return{flex:1,minHeight:54,maxHeight:140,resize:"none",border:`1px solid ${e.btnBorder}`,background:e.inputBg,color:e.textPrimary,borderRadius:12,padding:"11px 13px",fontSize:13,lineHeight:1.45,fontFamily:e.font,outline:"none",boxShadow:"none"}}function vr(e,n){return{...Kt(e,{variant:n?"primary":"secondary",size:"lg"}),...n?{}:{color:e.textMuted}}}function jr(e){return{border:"none",background:e.accent,color:"#fff",borderRadius:8,padding:"7px 13px",display:"inline-flex",alignItems:"center",gap:6,fontSize:12,fontWeight:700,fontFamily:e.font,cursor:"pointer",boxShadow:`0 1px 5px ${e.accent}4d`}}function Ro(e){return{position:"absolute",bottom:"calc(100% + 6px)",left:0,zIndex:41,width:264,background:e.cellBg,border:`1px solid ${e.headerBorder}`,borderRadius:10,boxShadow:"0 12px 32px rgba(0,0,0,0.2)",padding:10}}function Co(e){return{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 9px",borderRadius:7,border:"none",background:"transparent",color:e.textSecondary,fontSize:12.5,fontWeight:550,fontFamily:e.font,cursor:"pointer"}}function Sr(e){return{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 9px",borderRadius:7,border:`1px dashed ${e.accent}66`,background:`${e.accent}0d`,color:e.accent,fontSize:12.5,fontWeight:650,fontFamily:e.font,cursor:"pointer",marginBottom:2}}function wr(e){return{width:"100%",boxSizing:"border-box",border:`1px solid ${e.btnBorder}`,background:e.inputBg,color:e.textPrimary,borderRadius:8,padding:"8px 10px",fontSize:12.5,fontFamily:e.font,outline:"none"}}function Ao(e){return{alignSelf:"flex-end",maxWidth:"88%",background:`${e.accent}16`,color:e.textPrimary,border:`1px solid ${e.accent}32`,borderRadius:8,padding:"8px 10px",fontSize:12.5,lineHeight:1.45}}function Io(e){return{alignSelf:"flex-start",maxWidth:"92%",color:e.textPrimary,border:`1px solid ${e.cellBorder}`,background:e.appBg,borderRadius:10,padding:"10px 12px"}}function qo(e){return{border:`1px solid ${e.cellBorder}`,background:e.appBg,borderRadius:8,padding:10,display:"grid",gap:10,gridTemplateColumns:"minmax(0, 1fr)",minWidth:0,maxWidth:"100%"}}function Sn(e){return{border:`1px solid ${e.headerBorder}`,background:e.cellBg,borderRadius:8,padding:9,display:"grid",gap:8,gridTemplateColumns:"minmax(0, 1fr)",minWidth:0,maxWidth:"100%"}}function _o(e){return{border:`1px solid ${e.headerBorder}`,background:e.cellBg,borderRadius:8,padding:9,fontSize:12.5,color:e.textPrimary,lineHeight:1.45}}function wt(e){return{margin:0,maxHeight:180,overflow:"auto",border:`1px solid ${e.headerBorder}`,background:e.editorBg,color:e.textPrimary,borderRadius:7,padding:9,fontSize:11,lineHeight:1.45,fontFamily:e.fontMono,whiteSpace:"pre-wrap"}}function kr(e){return{width:"100%",minWidth:0,boxSizing:"border-box",background:e.inputBg,border:`1px solid ${e.inputBorder}`,borderRadius:5,color:e.textPrimary,padding:"5px 7px",fontSize:11,fontFamily:e.font}}function ne(e){return Kt(e,{variant:"secondary",size:"sm"})}const Vt={warehouse:{title:"The warehouse rejected the query",hint:"The SQL reached your warehouse and it refused. The message below is the driver’s own."},dql_compilation:{title:"DQL could not build a reusable block",hint:"The query itself is fine — only saving this answer as a block is affected."},governance_gate:{title:"DQL stopped this before running it",hint:"A governance check refused the query, so it never reached the warehouse."},retrieval_gap:{title:"DQL could not confirm this data exists",hint:"The relation was not in the inspected metadata. Refreshing the connection scope usually resolves it."},ambiguity:{title:"One detail is missing",hint:"Answer the question above and DQL will continue."},provider:{title:"The AI provider failed",hint:"Nothing was run. Retry, or check the provider in Settings."},orchestration_budget:{title:"Ask could not freeze one executable plan",hint:"Nothing was run. Ask stopped its own planning loop before another provider call; narrow the metric or dimension and retry."},host:{title:"DQL hit an internal error",hint:"This is a defect in DQL. The detail below is what to report."},modeling_gap:{title:"The governed model does not cover this question",hint:"No query ran. Add or review the missing metric, dimension, relationship, or allocation rule."},proof_integrity:{title:"Not executed: exact semantic proof was not established",hint:"DQL could not establish the exact metric, requested grain, join keys, and fanout proof. Warehouse success cannot create that authority."},identity_integrity:{title:"DQL found an internal identity or target-binding defect",hint:"No query ran. This is an orchestration integrity defect, not missing business modeling."},policy:{title:"Policy or permissions blocked this query",hint:"No AI repair was attempted. Use only the server-provided access or connection actions."},result_contract:{title:"The warehouse result did not match the frozen plan",hint:"The query ran, but DQL rejected the returned columns, types, grain, or row bound."},compile:{title:"DQL could not compile the frozen plan",hint:"The query did not reach the warehouse. Review the exact plan binding and compiler diagnostic."},timeout:{title:"This run reached its hard deadline",hint:"DQL stopped the run at its request-owned deadline and did not accept a later result."},cancel:{title:"This run was cancelled",hint:"Cancellation is terminal and no later provider or warehouse result was accepted."},unknown:{title:"The query could not be completed",hint:"Inspect the details or use the bounded repair when it is available."}};function yi(e){var n,r,i,s,o,l,c,u,p,f,a;if(e.status==="cancelled"||e.stopReason==="cancelled"||e.route==="cancelled"||((r=(n=e.diagnosticReceipt)==null?void 0:n.failure)==null?void 0:r.code)==="RUN_CANCELLED")return"cancel";for(const d of e.artifacts??[]){const g=re(d),h=(i=g==null?void 0:g.warehouseFailure)==null?void 0:i.origin,m=typeof((s=g==null?void 0:g.analyticalFailure)==null?void 0:s.code)=="string"?g.analyticalFailure.code:"";if((g==null?void 0:g.refusalCode)==="modeling_gap")return"modeling_gap";if(((o=g==null?void 0:g.aggregationSafetyProof)==null?void 0:o.status)==="blocked")return"proof_integrity";if(["IDENTIFIER_SCOPE_INVALID","EXECUTION_TARGET_MISMATCH","SEMANTIC_TARGET_BINDING_MISSING","SEMANTIC_SOURCE_DRIFT"].includes(m))return"identity_integrity";if(["POLICY_DENIED","PERMISSION_DENIED"].includes(m))return"policy";if(m==="RESULT_CONTRACT_MISMATCH")return"result_contract";if(["TIMEOUT","SEMANTIC_COMPILATION_TIMEOUT"].includes(m))return"timeout";if(m==="EXECUTION_CANCELLED")return"cancel";if(["COMPILATION_FAILED","DIALECT_ERROR","SEMANTIC_ADAPTER_NOT_READY"].includes(m))return"compile";if(typeof h=="string"&&h in Vt)return h;if(((l=g==null?void 0:g.providerFailure)==null?void 0:l.code)==="orchestration_budget_exhausted"||((c=g==null?void 0:g.providerFailure)==null?void 0:c.code)==="PROVIDER_DISPATCH_BUDGET_EXHAUSTED")return"orchestration_budget";if(g!=null&&g.providerFailure||(g==null?void 0:g.refusalCode)==="provider_error")return"provider";if((g==null?void 0:g.refusalCode)==="ambiguous")return"ambiguity";if((g==null?void 0:g.refusalCode)==="grounding_gap")return"retrieval_gap"}return((p=(u=e.diagnosticReceipt)==null?void 0:u.failure)==null?void 0:p.code)==="orchestration_budget_exhausted"?"orchestration_budget":((a=(f=e.diagnosticReceipt)==null?void 0:f.failure)==null?void 0:a.code)==="AI_PROVIDER_FAILURE"?"provider":"unknown"}function mi(e){for(const n of e.artifacts??[]){const r=re(n),s=(Array.isArray(r.validationWarnings)?r.validationWarnings.filter(o=>typeof o=="string"):[]).find(o=>/captur|reusable DQL block|save as (?:a )?block/i.test(o));if(s)return s}}function bi(e){const n=e.repairCapability;return(n==null?void 0:n.version)===1&&n.automatic.eligible===!0&&n.automatic.action==="repair_embedded_sql"&&n.automatic.correctionCode==="SQL_EXECUTION_REPAIR"&&n.automatic.attemptsRemaining>0&&n.routeLocked===!0&&n.targetLocked===!0&&n.sourceImmutable===!0}function zo({run:e,detail:n,threadId:r,onRepaired:i,t:s}){const o=yi(e),l=Vt[o]??Vt.unknown,[c,u]=x.useState(!1),[p,f]=x.useState(null),a=bi(e),d=async()=>{if(!c){u(!0),f(null);try{const g=await oe.repairAgentRunExecution(e.id,r);i(g.run)}catch(g){f(g instanceof Error?g.message:String(g))}finally{u(!1)}}};return t.jsxs("div",{"data-followup":"answer",style:{display:"flex",flexDirection:"column",gap:6,padding:"11px 13px",borderRadius:9,border:`1px solid ${s.error}33`,background:`${s.error}0d`},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:7},children:[t.jsx(He,{size:13,color:s.error,style:{flexShrink:0}}),t.jsx("span",{style:{fontSize:12.5,fontWeight:700,color:s.textPrimary},children:l.title})]}),t.jsx("div",{style:{fontSize:12.5,lineHeight:1.6,color:s.textSecondary,wordBreak:"break-word"},children:Ie(n)}),t.jsx("div",{style:{fontSize:11.5,lineHeight:1.5,color:s.textMuted},children:l.hint}),a?t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",marginTop:2},children:[t.jsxs("button",{type:"button",className:"dql-hover",disabled:c,onClick:()=>void d(),style:{...ne(s),opacity:c?.7:1},children:[t.jsx(Xt,{size:12})," ",c?"Fixing and retrying…":"Fix and retry"]}),t.jsx("span",{style:{fontSize:10.5,color:s.textMuted},children:"One bounded repair attempt on the same data target."})]}):null,p?t.jsx("div",{role:"alert",style:{fontSize:11.5,lineHeight:1.45,color:s.error},children:Ie(p)}):null]})}function vi(e){var i,s,o;const n=To(e);if(n)return n;for(const l of e.artifacts??[]){const c=re(l),u=c==null?void 0:c.warehouseFailure,p=[u==null?void 0:u.redactedMessage,u==null?void 0:u.diagnostic,c==null?void 0:c.executionError,(i=c==null?void 0:c.refusalDetails)==null?void 0:i.message].find(f=>typeof f=="string"&&f.trim().length>0);if(p)return p}const r=$o(e);return r||e.summary||((o=(s=e.diagnosticReceipt)==null?void 0:s.failure)==null?void 0:o.message)}function To(e){const n=[R(e.diagnosticReceiptV3),...e.artifacts.map(l=>R(re(l).diagnosticReceiptV3))],r=R(e.routeDecision),i=R(r==null?void 0:r.terminalOutcome),s=R(i==null?void 0:i.gap);if([...n.flatMap(l=>{var c;return[R(l==null?void 0:l.terminalGap),R((c=R(l==null?void 0:l.cascade))==null?void 0:c.terminalGap)]}),s].some(l=>(l==null?void 0:l.code)==="MISSING_RELATIONSHIP"))return"This Ask needs a certified relationship or approved allocation proof before it can run. DQL did not infer a relationship or execute a query."}function $o(e){var r;const n=[R((r=R(e.diagnosticReceipt))==null?void 0:r.resolvedAnalyticalPlan),...(e.artifacts??[]).flatMap(i=>{var o;const s=re(i);return[R(s.resolvedAnalyticalPlan),R((o=R(s.diagnosticReceipt))==null?void 0:o.resolvedAnalyticalPlan)]})].filter(i=>!!i);for(const i of n){const s=R(i.query),l=[...Se(s==null?void 0:s.measures).map(p=>({kind:"metric",binding:p})),...Se(s==null?void 0:s.dimensions).map(p=>({kind:"dimension",binding:p})),...Se(s==null?void 0:s.filters).flatMap(p=>{const f=R(p.binding);return f?[{kind:"filter",binding:f}]:[]})].find(({binding:p})=>p.status==="ambiguous"||p.status==="unresolved");if(!l)continue;const c=C(l.binding.requested)||`requested ${l.kind}`,u=Array.isArray(l.binding.candidateIds)?l.binding.candidateIds.filter(p=>typeof p=="string").map(Mo):[];return l.binding.status==="ambiguous"&&u.length>1?`I found more than one governed ${l.kind} for “${c}”: ${u.join(" or ")}. Choose one before I run the query.`:`I couldn’t identify one governed ${l.kind} for “${c}”. Review that model binding before retrying.`}}function Mo(e){return(e.split(/[:./]/).filter(Boolean).at(-1)??e).replace(/[_-]+/g," ").replace(/\b\w/g,r=>r.toUpperCase())}const Qo=Object.freeze(Object.defineProperty({__proto__:null,ASK_FAILURE_PRESENTATION:Vt,CANONICAL_DECISION_SUMMARY_UNAVAILABLE:Er,InspectorDecisionStory:ti,InspectorDecisionSummaryUnavailable:si,RESEARCH_TOOL_ROWS_CONSENT_TITLE:Wr,ResearchPartialFailureRepair:ni,UnifiedAgentRunPanel:Ps,agentRunHistoryFromItems:Dr,agentRunPerformanceRows:xn,analyticalInspectorContract:ei,analyticalInspectorSections:eo,analyticalRepairActionLabels:to,appPinDestinationLabel:bn,artifactReadyPayloadFromRun:Ht,artifactSqlDisclosureLabel:gi,askAppDestinations:ai,askAppWriteErrorMessage:mn,askArtifactMeta:Jt,askFailureDetail:vi,askFailureOrigin:yi,askInspectorTabsForState:Kr,askRunAllowsExecutionRepair:bi,askRunCaptureWarning:mi,clarificationSelectionInput:Dt,completedRunGuidanceFor:Gr,deriveResultChartConfig:Hi,extractResult:Te,hasAnalyticalInspectorContract:Zt,inlineAskChartConfig:fi,isAgentRunPinnable:Rt,liveAgentActivityFor:Ur,longRunGuidanceFor:Vr,preferredAskInspectorTab:qn,providerEgressSummary:yn,replacePresentedAgentRun:Nr,researchResultRowsOptInForRun:Or,researchSourceFromRun:oi,researchVerdictSummary:In,researchVerdictSummaryForRun:Yr,resolveArtifactDqlView:Ct,resolveComposerRequestedMode:Lr,resolvedParameterValues:vn,selectAgentExecutionConnection:Hr,threadItemsFromTurns:Qr,trustExplainer:zn,usePersistedAgentThreadId:Qi},Symbol.toStringTag,{value:"Module"}));export{Ss as B,qr as C,Zn as S,Ps as U,ps as a,bs as b,Qo as c};
|